teamhandbook-orchestrator 0.2.0 → 0.4.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.
- package/bin/main.mjs +4788 -2604
- package/dist/server.js +36764 -30711
- package/dist/web/assets/index-BMv15rPj.js +102 -0
- package/dist/web/assets/index-CofBKhPG.css +1 -0
- package/dist/web/index.html +2 -2
- package/dist/web/sw.js +18 -0
- package/package.json +1 -1
- package/dist/web/assets/index-CHWIvcta.css +0 -1
- package/dist/web/assets/index-D8JhITfw.js +0 -86
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
var Cv=Object.defineProperty;var $v=(t,n,a)=>n in t?Cv(t,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[n]=a;var _p=(t,n,a)=>$v(t,typeof n!="symbol"?n+"":n,a);(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))l(o);new MutationObserver(o=>{for(const c of o)if(c.type==="childList")for(const d of c.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&l(d)}).observe(document,{childList:!0,subtree:!0});function a(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function l(o){if(o.ep)return;o.ep=!0;const c=a(o);fetch(o.href,c)}})();var vu={exports:{}},kl={},ku={exports:{}},De={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react.production.min.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var Up;function Tv(){if(Up)return De;Up=1;var t=Symbol.for("react.element"),n=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),d=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),x=Symbol.iterator;function y(A){return A===null||typeof A!="object"?null:(A=x&&A[x]||A["@@iterator"],typeof A=="function"?A:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,v={};function k(A,H,X){this.props=A,this.context=H,this.refs=v,this.updater=X||b}k.prototype.isReactComponent={},k.prototype.setState=function(A,H){if(typeof A!="object"&&typeof A!="function"&&A!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,A,H,"setState")},k.prototype.forceUpdate=function(A){this.updater.enqueueForceUpdate(this,A,"forceUpdate")};function S(){}S.prototype=k.prototype;function $(A,H,X){this.props=A,this.context=H,this.refs=v,this.updater=X||b}var E=$.prototype=new S;E.constructor=$,N(E,k.prototype),E.isPureReactComponent=!0;var C=Array.isArray,R=Object.prototype.hasOwnProperty,P={current:null},M={key:!0,ref:!0,__self:!0,__source:!0};function O(A,H,X){var de,Se={},Ne=null,xe=null;if(H!=null)for(de in H.ref!==void 0&&(xe=H.ref),H.key!==void 0&&(Ne=""+H.key),H)R.call(H,de)&&!M.hasOwnProperty(de)&&(Se[de]=H[de]);var ie=arguments.length-2;if(ie===1)Se.children=X;else if(1<ie){for(var me=Array(ie),Fe=0;Fe<ie;Fe++)me[Fe]=arguments[Fe+2];Se.children=me}if(A&&A.defaultProps)for(de in ie=A.defaultProps,ie)Se[de]===void 0&&(Se[de]=ie[de]);return{$$typeof:t,type:A,key:Ne,ref:xe,props:Se,_owner:P.current}}function _(A,H){return{$$typeof:t,type:A.type,key:H,ref:A.ref,props:A.props,_owner:A._owner}}function I(A){return typeof A=="object"&&A!==null&&A.$$typeof===t}function L(A){var H={"=":"=0",":":"=2"};return"$"+A.replace(/[=:]/g,function(X){return H[X]})}var K=/\/+/g;function B(A,H){return typeof A=="object"&&A!==null&&A.key!=null?L(""+A.key):H.toString(36)}function ne(A,H,X,de,Se){var Ne=typeof A;(Ne==="undefined"||Ne==="boolean")&&(A=null);var xe=!1;if(A===null)xe=!0;else switch(Ne){case"string":case"number":xe=!0;break;case"object":switch(A.$$typeof){case t:case n:xe=!0}}if(xe)return xe=A,Se=Se(xe),A=de===""?"."+B(xe,0):de,C(Se)?(X="",A!=null&&(X=A.replace(K,"$&/")+"/"),ne(Se,H,X,"",function(Fe){return Fe})):Se!=null&&(I(Se)&&(Se=_(Se,X+(!Se.key||xe&&xe.key===Se.key?"":(""+Se.key).replace(K,"$&/")+"/")+A)),H.push(Se)),1;if(xe=0,de=de===""?".":de+":",C(A))for(var ie=0;ie<A.length;ie++){Ne=A[ie];var me=de+B(Ne,ie);xe+=ne(Ne,H,X,me,Se)}else if(me=y(A),typeof me=="function")for(A=me.call(A),ie=0;!(Ne=A.next()).done;)Ne=Ne.value,me=de+B(Ne,ie++),xe+=ne(Ne,H,X,me,Se);else if(Ne==="object")throw H=String(A),Error("Objects are not valid as a React child (found: "+(H==="[object Object]"?"object with keys {"+Object.keys(A).join(", ")+"}":H)+"). If you meant to render a collection of children, use an array instead.");return xe}function Z(A,H,X){if(A==null)return A;var de=[],Se=0;return ne(A,de,"","",function(Ne){return H.call(X,Ne,Se++)}),de}function D(A){if(A._status===-1){var H=A._result;H=H(),H.then(function(X){(A._status===0||A._status===-1)&&(A._status=1,A._result=X)},function(X){(A._status===0||A._status===-1)&&(A._status=2,A._result=X)}),A._status===-1&&(A._status=0,A._result=H)}if(A._status===1)return A._result.default;throw A._result}var te={current:null},Q={transition:null},ee={ReactCurrentDispatcher:te,ReactCurrentBatchConfig:Q,ReactCurrentOwner:P};function W(){throw Error("act(...) is not supported in production builds of React.")}return De.Children={map:Z,forEach:function(A,H,X){Z(A,function(){H.apply(this,arguments)},X)},count:function(A){var H=0;return Z(A,function(){H++}),H},toArray:function(A){return Z(A,function(H){return H})||[]},only:function(A){if(!I(A))throw Error("React.Children.only expected to receive a single React element child.");return A}},De.Component=k,De.Fragment=a,De.Profiler=o,De.PureComponent=$,De.StrictMode=l,De.Suspense=m,De.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ee,De.act=W,De.cloneElement=function(A,H,X){if(A==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+A+".");var de=N({},A.props),Se=A.key,Ne=A.ref,xe=A._owner;if(H!=null){if(H.ref!==void 0&&(Ne=H.ref,xe=P.current),H.key!==void 0&&(Se=""+H.key),A.type&&A.type.defaultProps)var ie=A.type.defaultProps;for(me in H)R.call(H,me)&&!M.hasOwnProperty(me)&&(de[me]=H[me]===void 0&&ie!==void 0?ie[me]:H[me])}var me=arguments.length-2;if(me===1)de.children=X;else if(1<me){ie=Array(me);for(var Fe=0;Fe<me;Fe++)ie[Fe]=arguments[Fe+2];de.children=ie}return{$$typeof:t,type:A.type,key:Se,ref:Ne,props:de,_owner:xe}},De.createContext=function(A){return A={$$typeof:d,_currentValue:A,_currentValue2:A,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},A.Provider={$$typeof:c,_context:A},A.Consumer=A},De.createElement=O,De.createFactory=function(A){var H=O.bind(null,A);return H.type=A,H},De.createRef=function(){return{current:null}},De.forwardRef=function(A){return{$$typeof:u,render:A}},De.isValidElement=I,De.lazy=function(A){return{$$typeof:g,_payload:{_status:-1,_result:A},_init:D}},De.memo=function(A,H){return{$$typeof:f,type:A,compare:H===void 0?null:H}},De.startTransition=function(A){var H=Q.transition;Q.transition={};try{A()}finally{Q.transition=H}},De.unstable_act=W,De.useCallback=function(A,H){return te.current.useCallback(A,H)},De.useContext=function(A){return te.current.useContext(A)},De.useDebugValue=function(){},De.useDeferredValue=function(A){return te.current.useDeferredValue(A)},De.useEffect=function(A,H){return te.current.useEffect(A,H)},De.useId=function(){return te.current.useId()},De.useImperativeHandle=function(A,H,X){return te.current.useImperativeHandle(A,H,X)},De.useInsertionEffect=function(A,H){return te.current.useInsertionEffect(A,H)},De.useLayoutEffect=function(A,H){return te.current.useLayoutEffect(A,H)},De.useMemo=function(A,H){return te.current.useMemo(A,H)},De.useReducer=function(A,H,X){return te.current.useReducer(A,H,X)},De.useRef=function(A){return te.current.useRef(A)},De.useState=function(A){return te.current.useState(A)},De.useSyncExternalStore=function(A,H,X){return te.current.useSyncExternalStore(A,H,X)},De.useTransition=function(){return te.current.useTransition()},De.version="18.3.1",De}var Dp;function Vd(){return Dp||(Dp=1,ku.exports=Tv()),ku.exports}/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.production.min.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var Bp;function Ev(){if(Bp)return kl;Bp=1;var t=Vd(),n=Symbol.for("react.element"),a=Symbol.for("react.fragment"),l=Object.prototype.hasOwnProperty,o=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function d(u,m,f){var g,x={},y=null,b=null;f!==void 0&&(y=""+f),m.key!==void 0&&(y=""+m.key),m.ref!==void 0&&(b=m.ref);for(g in m)l.call(m,g)&&!c.hasOwnProperty(g)&&(x[g]=m[g]);if(u&&u.defaultProps)for(g in m=u.defaultProps,m)x[g]===void 0&&(x[g]=m[g]);return{$$typeof:n,type:u,key:y,ref:b,props:x,_owner:o.current}}return kl.Fragment=a,kl.jsx=d,kl.jsxs=d,kl}var qp;function Rv(){return qp||(qp=1,vu.exports=Ev()),vu.exports}var e=Rv(),h=Vd(),Vo={},bu={exports:{}},Qt={},wu={exports:{}},Nu={};/**
|
|
18
|
+
* @license React
|
|
19
|
+
* scheduler.production.min.js
|
|
20
|
+
*
|
|
21
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
22
|
+
*
|
|
23
|
+
* This source code is licensed under the MIT license found in the
|
|
24
|
+
* LICENSE file in the root directory of this source tree.
|
|
25
|
+
*/var Wp;function Pv(){return Wp||(Wp=1,(function(t){function n(Q,ee){var W=Q.length;Q.push(ee);e:for(;0<W;){var A=W-1>>>1,H=Q[A];if(0<o(H,ee))Q[A]=ee,Q[W]=H,W=A;else break e}}function a(Q){return Q.length===0?null:Q[0]}function l(Q){if(Q.length===0)return null;var ee=Q[0],W=Q.pop();if(W!==ee){Q[0]=W;e:for(var A=0,H=Q.length,X=H>>>1;A<X;){var de=2*(A+1)-1,Se=Q[de],Ne=de+1,xe=Q[Ne];if(0>o(Se,W))Ne<H&&0>o(xe,Se)?(Q[A]=xe,Q[Ne]=W,A=Ne):(Q[A]=Se,Q[de]=W,A=de);else if(Ne<H&&0>o(xe,W))Q[A]=xe,Q[Ne]=W,A=Ne;else break e}}return ee}function o(Q,ee){var W=Q.sortIndex-ee.sortIndex;return W!==0?W:Q.id-ee.id}if(typeof performance=="object"&&typeof performance.now=="function"){var c=performance;t.unstable_now=function(){return c.now()}}else{var d=Date,u=d.now();t.unstable_now=function(){return d.now()-u}}var m=[],f=[],g=1,x=null,y=3,b=!1,N=!1,v=!1,k=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,$=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function E(Q){for(var ee=a(f);ee!==null;){if(ee.callback===null)l(f);else if(ee.startTime<=Q)l(f),ee.sortIndex=ee.expirationTime,n(m,ee);else break;ee=a(f)}}function C(Q){if(v=!1,E(Q),!N)if(a(m)!==null)N=!0,D(R);else{var ee=a(f);ee!==null&&te(C,ee.startTime-Q)}}function R(Q,ee){N=!1,v&&(v=!1,S(O),O=-1),b=!0;var W=y;try{for(E(ee),x=a(m);x!==null&&(!(x.expirationTime>ee)||Q&&!L());){var A=x.callback;if(typeof A=="function"){x.callback=null,y=x.priorityLevel;var H=A(x.expirationTime<=ee);ee=t.unstable_now(),typeof H=="function"?x.callback=H:x===a(m)&&l(m),E(ee)}else l(m);x=a(m)}if(x!==null)var X=!0;else{var de=a(f);de!==null&&te(C,de.startTime-ee),X=!1}return X}finally{x=null,y=W,b=!1}}var P=!1,M=null,O=-1,_=5,I=-1;function L(){return!(t.unstable_now()-I<_)}function K(){if(M!==null){var Q=t.unstable_now();I=Q;var ee=!0;try{ee=M(!0,Q)}finally{ee?B():(P=!1,M=null)}}else P=!1}var B;if(typeof $=="function")B=function(){$(K)};else if(typeof MessageChannel<"u"){var ne=new MessageChannel,Z=ne.port2;ne.port1.onmessage=K,B=function(){Z.postMessage(null)}}else B=function(){k(K,0)};function D(Q){M=Q,P||(P=!0,B())}function te(Q,ee){O=k(function(){Q(t.unstable_now())},ee)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(Q){Q.callback=null},t.unstable_continueExecution=function(){N||b||(N=!0,D(R))},t.unstable_forceFrameRate=function(Q){0>Q||125<Q?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):_=0<Q?Math.floor(1e3/Q):5},t.unstable_getCurrentPriorityLevel=function(){return y},t.unstable_getFirstCallbackNode=function(){return a(m)},t.unstable_next=function(Q){switch(y){case 1:case 2:case 3:var ee=3;break;default:ee=y}var W=y;y=ee;try{return Q()}finally{y=W}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(Q,ee){switch(Q){case 1:case 2:case 3:case 4:case 5:break;default:Q=3}var W=y;y=Q;try{return ee()}finally{y=W}},t.unstable_scheduleCallback=function(Q,ee,W){var A=t.unstable_now();switch(typeof W=="object"&&W!==null?(W=W.delay,W=typeof W=="number"&&0<W?A+W:A):W=A,Q){case 1:var H=-1;break;case 2:H=250;break;case 5:H=1073741823;break;case 4:H=1e4;break;default:H=5e3}return H=W+H,Q={id:g++,callback:ee,priorityLevel:Q,startTime:W,expirationTime:H,sortIndex:-1},W>A?(Q.sortIndex=W,n(f,Q),a(m)===null&&Q===a(f)&&(v?(S(O),O=-1):v=!0,te(C,W-A))):(Q.sortIndex=H,n(m,Q),N||b||(N=!0,D(R))),Q},t.unstable_shouldYield=L,t.unstable_wrapCallback=function(Q){var ee=y;return function(){var W=y;y=ee;try{return Q.apply(this,arguments)}finally{y=W}}}})(Nu)),Nu}var zp;function Av(){return zp||(zp=1,wu.exports=Pv()),wu.exports}/**
|
|
26
|
+
* @license React
|
|
27
|
+
* react-dom.production.min.js
|
|
28
|
+
*
|
|
29
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
30
|
+
*
|
|
31
|
+
* This source code is licensed under the MIT license found in the
|
|
32
|
+
* LICENSE file in the root directory of this source tree.
|
|
33
|
+
*/var Hp;function Iv(){if(Hp)return Qt;Hp=1;var t=Vd(),n=Av();function a(s){for(var r="https://reactjs.org/docs/error-decoder.html?invariant="+s,i=1;i<arguments.length;i++)r+="&args[]="+encodeURIComponent(arguments[i]);return"Minified React error #"+s+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var l=new Set,o={};function c(s,r){d(s,r),d(s+"Capture",r)}function d(s,r){for(o[s]=r,s=0;s<r.length;s++)l.add(r[s])}var u=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),m=Object.prototype.hasOwnProperty,f=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,g={},x={};function y(s){return m.call(x,s)?!0:m.call(g,s)?!1:f.test(s)?x[s]=!0:(g[s]=!0,!1)}function b(s,r,i,p){if(i!==null&&i.type===0)return!1;switch(typeof r){case"function":case"symbol":return!0;case"boolean":return p?!1:i!==null?!i.acceptsBooleans:(s=s.toLowerCase().slice(0,5),s!=="data-"&&s!=="aria-");default:return!1}}function N(s,r,i,p){if(r===null||typeof r>"u"||b(s,r,i,p))return!0;if(p)return!1;if(i!==null)switch(i.type){case 3:return!r;case 4:return r===!1;case 5:return isNaN(r);case 6:return isNaN(r)||1>r}return!1}function v(s,r,i,p,j,w,T){this.acceptsBooleans=r===2||r===3||r===4,this.attributeName=p,this.attributeNamespace=j,this.mustUseProperty=i,this.propertyName=s,this.type=r,this.sanitizeURL=w,this.removeEmptyString=T}var k={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(s){k[s]=new v(s,0,!1,s,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(s){var r=s[0];k[r]=new v(r,1,!1,s[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(s){k[s]=new v(s,2,!1,s.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(s){k[s]=new v(s,2,!1,s,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(s){k[s]=new v(s,3,!1,s.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(s){k[s]=new v(s,3,!0,s,null,!1,!1)}),["capture","download"].forEach(function(s){k[s]=new v(s,4,!1,s,null,!1,!1)}),["cols","rows","size","span"].forEach(function(s){k[s]=new v(s,6,!1,s,null,!1,!1)}),["rowSpan","start"].forEach(function(s){k[s]=new v(s,5,!1,s.toLowerCase(),null,!1,!1)});var S=/[\-:]([a-z])/g;function $(s){return s[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(s){var r=s.replace(S,$);k[r]=new v(r,1,!1,s,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(s){var r=s.replace(S,$);k[r]=new v(r,1,!1,s,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(s){var r=s.replace(S,$);k[r]=new v(r,1,!1,s,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(s){k[s]=new v(s,1,!1,s.toLowerCase(),null,!1,!1)}),k.xlinkHref=new v("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(s){k[s]=new v(s,1,!1,s.toLowerCase(),null,!0,!0)});function E(s,r,i,p){var j=k.hasOwnProperty(r)?k[r]:null;(j!==null?j.type!==0:p||!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(N(r,i,j,p)&&(i=null),p||j===null?y(r)&&(i===null?s.removeAttribute(r):s.setAttribute(r,""+i)):j.mustUseProperty?s[j.propertyName]=i===null?j.type===3?!1:"":i:(r=j.attributeName,p=j.attributeNamespace,i===null?s.removeAttribute(r):(j=j.type,i=j===3||j===4&&i===!0?"":""+i,p?s.setAttributeNS(p,r,i):s.setAttribute(r,i))))}var C=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,R=Symbol.for("react.element"),P=Symbol.for("react.portal"),M=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),_=Symbol.for("react.profiler"),I=Symbol.for("react.provider"),L=Symbol.for("react.context"),K=Symbol.for("react.forward_ref"),B=Symbol.for("react.suspense"),ne=Symbol.for("react.suspense_list"),Z=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),te=Symbol.for("react.offscreen"),Q=Symbol.iterator;function ee(s){return s===null||typeof s!="object"?null:(s=Q&&s[Q]||s["@@iterator"],typeof s=="function"?s:null)}var W=Object.assign,A;function H(s){if(A===void 0)try{throw Error()}catch(i){var r=i.stack.trim().match(/\n( *(at )?)/);A=r&&r[1]||""}return`
|
|
34
|
+
`+A+s}var X=!1;function de(s,r){if(!s||X)return"";X=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(r)if(r=function(){throw Error()},Object.defineProperty(r.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(r,[])}catch(J){var p=J}Reflect.construct(s,[],r)}else{try{r.call()}catch(J){p=J}s.call(r.prototype)}else{try{throw Error()}catch(J){p=J}s()}}catch(J){if(J&&p&&typeof J.stack=="string"){for(var j=J.stack.split(`
|
|
35
|
+
`),w=p.stack.split(`
|
|
36
|
+
`),T=j.length-1,F=w.length-1;1<=T&&0<=F&&j[T]!==w[F];)F--;for(;1<=T&&0<=F;T--,F--)if(j[T]!==w[F]){if(T!==1||F!==1)do if(T--,F--,0>F||j[T]!==w[F]){var q=`
|
|
37
|
+
`+j[T].replace(" at new "," at ");return s.displayName&&q.includes("<anonymous>")&&(q=q.replace("<anonymous>",s.displayName)),q}while(1<=T&&0<=F);break}}}finally{X=!1,Error.prepareStackTrace=i}return(s=s?s.displayName||s.name:"")?H(s):""}function Se(s){switch(s.tag){case 5:return H(s.type);case 16:return H("Lazy");case 13:return H("Suspense");case 19:return H("SuspenseList");case 0:case 2:case 15:return s=de(s.type,!1),s;case 11:return s=de(s.type.render,!1),s;case 1:return s=de(s.type,!0),s;default:return""}}function Ne(s){if(s==null)return null;if(typeof s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case M:return"Fragment";case P:return"Portal";case _:return"Profiler";case O:return"StrictMode";case B:return"Suspense";case ne:return"SuspenseList"}if(typeof s=="object")switch(s.$$typeof){case L:return(s.displayName||"Context")+".Consumer";case I:return(s._context.displayName||"Context")+".Provider";case K:var r=s.render;return s=s.displayName,s||(s=r.displayName||r.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case Z:return r=s.displayName||null,r!==null?r:Ne(s.type)||"Memo";case D:r=s._payload,s=s._init;try{return Ne(s(r))}catch{}}return null}function xe(s){var r=s.type;switch(s.tag){case 24:return"Cache";case 9:return(r.displayName||"Context")+".Consumer";case 10:return(r._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return s=r.render,s=s.displayName||s.name||"",r.displayName||(s!==""?"ForwardRef("+s+")":"ForwardRef");case 7:return"Fragment";case 5:return r;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Ne(r);case 8:return r===O?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r}return null}function ie(s){switch(typeof s){case"boolean":case"number":case"string":case"undefined":return s;case"object":return s;default:return""}}function me(s){var r=s.type;return(s=s.nodeName)&&s.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function Fe(s){var r=me(s)?"checked":"value",i=Object.getOwnPropertyDescriptor(s.constructor.prototype,r),p=""+s[r];if(!s.hasOwnProperty(r)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var j=i.get,w=i.set;return Object.defineProperty(s,r,{configurable:!0,get:function(){return j.call(this)},set:function(T){p=""+T,w.call(this,T)}}),Object.defineProperty(s,r,{enumerable:i.enumerable}),{getValue:function(){return p},setValue:function(T){p=""+T},stopTracking:function(){s._valueTracker=null,delete s[r]}}}}function Ve(s){s._valueTracker||(s._valueTracker=Fe(s))}function le(s){if(!s)return!1;var r=s._valueTracker;if(!r)return!0;var i=r.getValue(),p="";return s&&(p=me(s)?s.checked?"true":"false":s.value),s=p,s!==i?(r.setValue(s),!0):!1}function pe(s){if(s=s||(typeof document<"u"?document:void 0),typeof s>"u")return null;try{return s.activeElement||s.body}catch{return s.body}}function Be(s,r){var i=r.checked;return W({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??s._wrapperState.initialChecked})}function We(s,r){var i=r.defaultValue==null?"":r.defaultValue,p=r.checked!=null?r.checked:r.defaultChecked;i=ie(r.value!=null?r.value:i),s._wrapperState={initialChecked:p,initialValue:i,controlled:r.type==="checkbox"||r.type==="radio"?r.checked!=null:r.value!=null}}function St(s,r){r=r.checked,r!=null&&E(s,"checked",r,!1)}function gt(s,r){St(s,r);var i=ie(r.value),p=r.type;if(i!=null)p==="number"?(i===0&&s.value===""||s.value!=i)&&(s.value=""+i):s.value!==""+i&&(s.value=""+i);else if(p==="submit"||p==="reset"){s.removeAttribute("value");return}r.hasOwnProperty("value")?Zt(s,r.type,i):r.hasOwnProperty("defaultValue")&&Zt(s,r.type,ie(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(s.defaultChecked=!!r.defaultChecked)}function Lt(s,r,i){if(r.hasOwnProperty("value")||r.hasOwnProperty("defaultValue")){var p=r.type;if(!(p!=="submit"&&p!=="reset"||r.value!==void 0&&r.value!==null))return;r=""+s._wrapperState.initialValue,i||r===s.value||(s.value=r),s.defaultValue=r}i=s.name,i!==""&&(s.name=""),s.defaultChecked=!!s._wrapperState.initialChecked,i!==""&&(s.name=i)}function Zt(s,r,i){(r!=="number"||pe(s.ownerDocument)!==s)&&(i==null?s.defaultValue=""+s._wrapperState.initialValue:s.defaultValue!==""+i&&(s.defaultValue=""+i))}var Qn=Array.isArray;function Oe(s,r,i,p){if(s=s.options,r){r={};for(var j=0;j<i.length;j++)r["$"+i[j]]=!0;for(i=0;i<s.length;i++)j=r.hasOwnProperty("$"+s[i].value),s[i].selected!==j&&(s[i].selected=j),j&&p&&(s[i].defaultSelected=!0)}else{for(i=""+ie(i),r=null,j=0;j<s.length;j++){if(s[j].value===i){s[j].selected=!0,p&&(s[j].defaultSelected=!0);return}r!==null||s[j].disabled||(r=s[j])}r!==null&&(r.selected=!0)}}function is(s,r){if(r.dangerouslySetInnerHTML!=null)throw Error(a(91));return W({},r,{value:void 0,defaultValue:void 0,children:""+s._wrapperState.initialValue})}function Bt(s,r){var i=r.value;if(i==null){if(i=r.children,r=r.defaultValue,i!=null){if(r!=null)throw Error(a(92));if(Qn(i)){if(1<i.length)throw Error(a(93));i=i[0]}r=i}r==null&&(r=""),i=r}s._wrapperState={initialValue:ie(i)}}function cs(s,r){var i=ie(r.value),p=ie(r.defaultValue);i!=null&&(i=""+i,i!==s.value&&(s.value=i),r.defaultValue==null&&s.defaultValue!==i&&(s.defaultValue=i)),p!=null&&(s.defaultValue=""+p)}function yt(s){var r=s.textContent;r===s._wrapperState.initialValue&&r!==""&&r!==null&&(s.value=r)}function Ls(s){switch(s){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Ct(s,r){return s==null||s==="http://www.w3.org/1999/xhtml"?Ls(r):s==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":s}var tt,us=(function(s){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(r,i,p,j){MSApp.execUnsafeLocalFunction(function(){return s(r,i,p,j)})}:s})(function(s,r){if(s.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in s)s.innerHTML=r;else{for(tt=tt||document.createElement("div"),tt.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=tt.firstChild;s.firstChild;)s.removeChild(s.firstChild);for(;r.firstChild;)s.appendChild(r.firstChild)}});function nt(s,r){if(r){var i=s.firstChild;if(i&&i===s.lastChild&&i.nodeType===3){i.nodeValue=r;return}}s.textContent=r}var qt={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},ds=["Webkit","ms","Moz","O"];Object.keys(qt).forEach(function(s){ds.forEach(function(r){r=r+s.charAt(0).toUpperCase()+s.substring(1),qt[r]=qt[s]})});function An(s,r,i){return r==null||typeof r=="boolean"||r===""?"":i||typeof r!="number"||r===0||qt.hasOwnProperty(s)&&qt[s]?(""+r).trim():r+"px"}function st(s,r){s=s.style;for(var i in r)if(r.hasOwnProperty(i)){var p=i.indexOf("--")===0,j=An(i,r[i],p);i==="float"&&(i="cssFloat"),p?s.setProperty(i,j):s[i]=j}}var Wt=W({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function hs(s,r){if(r){if(Wt[s]&&(r.children!=null||r.dangerouslySetInnerHTML!=null))throw Error(a(137,s));if(r.dangerouslySetInnerHTML!=null){if(r.children!=null)throw Error(a(60));if(typeof r.dangerouslySetInnerHTML!="object"||!("__html"in r.dangerouslySetInnerHTML))throw Error(a(61))}if(r.style!=null&&typeof r.style!="object")throw Error(a(62))}}function Ft(s,r){if(s.indexOf("-")===-1)return typeof r.is=="string";switch(s){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var gn=null;function en(s){return s=s.target||s.srcElement||window,s.correspondingUseElement&&(s=s.correspondingUseElement),s.nodeType===3?s.parentNode:s}var xn=null,In=null,jn=null;function tn(s){if(s=ll(s)){if(typeof xn!="function")throw Error(a(280));var r=s.stateNode;r&&(r=co(r),xn(s.stateNode,s.type,r))}}function nn(s){In?jn?jn.push(s):jn=[s]:In=s}function lt(){if(In){var s=In,r=jn;if(jn=In=null,tn(s),r)for(s=0;s<r.length;s++)tn(r[s])}}function Le(s,r){return s(r)}function ga(){}var ms=!1;function sn(s,r,i){if(ms)return s(r,i);ms=!0;try{return Le(s,r,i)}finally{ms=!1,(In!==null||jn!==null)&&(ga(),lt())}}function On(s,r){var i=s.stateNode;if(i===null)return null;var p=co(i);if(p===null)return null;i=p[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(p=!p.disabled)||(s=s.type,p=!(s==="button"||s==="input"||s==="select"||s==="textarea")),s=!p;break e;default:s=!1}if(s)return null;if(i&&typeof i!="function")throw Error(a(231,r,typeof i));return i}var Jn=!1;if(u)try{var Ln={};Object.defineProperty(Ln,"passive",{get:function(){Jn=!0}}),window.addEventListener("test",Ln,Ln),window.removeEventListener("test",Ln,Ln)}catch{Jn=!1}function an(s,r,i,p,j,w,T,F,q){var J=Array.prototype.slice.call(arguments,3);try{r.apply(i,J)}catch(ae){this.onError(ae)}}var Fn=!1,Xn=null,ps=!1,fs=null,Ga={onError:function(s){Fn=!0,Xn=s}};function xa(s,r,i,p,j,w,T,F,q){Fn=!1,Xn=null,an.apply(Ga,arguments)}function Zn(s,r,i,p,j,w,T,F,q){if(xa.apply(this,arguments),Fn){if(Fn){var J=Xn;Fn=!1,Xn=null}else throw Error(a(198));ps||(ps=!0,fs=J)}}function yn(s){var r=s,i=s;if(s.alternate)for(;r.return;)r=r.return;else{s=r;do r=s,(r.flags&4098)!==0&&(i=r.return),s=r.return;while(s)}return r.tag===3?i:null}function ja(s){if(s.tag===13){var r=s.memoizedState;if(r===null&&(s=s.alternate,s!==null&&(r=s.memoizedState)),r!==null)return r.dehydrated}return null}function ue(s){if(yn(s)!==s)throw Error(a(188))}function ze(s){var r=s.alternate;if(!r){if(r=yn(s),r===null)throw Error(a(188));return r!==s?null:s}for(var i=s,p=r;;){var j=i.return;if(j===null)break;var w=j.alternate;if(w===null){if(p=j.return,p!==null){i=p;continue}break}if(j.child===w.child){for(w=j.child;w;){if(w===i)return ue(j),s;if(w===p)return ue(j),r;w=w.sibling}throw Error(a(188))}if(i.return!==p.return)i=j,p=w;else{for(var T=!1,F=j.child;F;){if(F===i){T=!0,i=j,p=w;break}if(F===p){T=!0,p=j,i=w;break}F=F.sibling}if(!T){for(F=w.child;F;){if(F===i){T=!0,i=w,p=j;break}if(F===p){T=!0,p=w,i=j;break}F=F.sibling}if(!T)throw Error(a(189))}}if(i.alternate!==p)throw Error(a(190))}if(i.tag!==3)throw Error(a(188));return i.stateNode.current===i?s:r}function Rt(s){return s=ze(s),s!==null?vn(s):null}function vn(s){if(s.tag===5||s.tag===6)return s;for(s=s.child;s!==null;){var r=vn(s);if(r!==null)return r;s=s.sibling}return null}var rn=n.unstable_scheduleCallback,pt=n.unstable_cancelCallback,Ka=n.unstable_shouldYield,vt=n.unstable_requestPaint,_e=n.unstable_now,Fs=n.unstable_getCurrentPriorityLevel,Mn=n.unstable_ImmediatePriority,Ms=n.unstable_UserBlockingPriority,gs=n.unstable_NormalPriority,Wi=n.unstable_LowPriority,Ya=n.unstable_IdlePriority,_s=null,Mt=null;function zl(s){if(Mt&&typeof Mt.onCommitFiberRoot=="function")try{Mt.onCommitFiberRoot(_s,s,void 0,(s.current.flags&128)===128)}catch{}}var zt=Math.clz32?Math.clz32:Hl,Ur=Math.log,zi=Math.LN2;function Hl(s){return s>>>=0,s===0?32:31-(Ur(s)/zi|0)|0}var Us=64,Va=4194304;function Ds(s){switch(s&-s){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return s&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return s&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return s}}function ya(s,r){var i=s.pendingLanes;if(i===0)return 0;var p=0,j=s.suspendedLanes,w=s.pingedLanes,T=i&268435455;if(T!==0){var F=T&~j;F!==0?p=Ds(F):(w&=T,w!==0&&(p=Ds(w)))}else T=i&~j,T!==0?p=Ds(T):w!==0&&(p=Ds(w));if(p===0)return 0;if(r!==0&&r!==p&&(r&j)===0&&(j=p&-p,w=r&-r,j>=w||j===16&&(w&4194240)!==0))return r;if((p&4)!==0&&(p|=i&16),r=s.entangledLanes,r!==0)for(s=s.entanglements,r&=p;0<r;)i=31-zt(r),j=1<<i,p|=s[i],r&=~j;return p}function Gl(s,r){switch(s){case 1:case 2:case 4:return r+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Hi(s,r){for(var i=s.suspendedLanes,p=s.pingedLanes,j=s.expirationTimes,w=s.pendingLanes;0<w;){var T=31-zt(w),F=1<<T,q=j[T];q===-1?((F&i)===0||(F&p)!==0)&&(j[T]=Gl(F,r)):q<=r&&(s.expiredLanes|=F),w&=~F}}function Qa(s){return s=s.pendingLanes&-1073741825,s!==0?s:s&1073741824?1073741824:0}function va(){var s=Us;return Us<<=1,(Us&4194240)===0&&(Us=64),s}function Dr(s){for(var r=[],i=0;31>i;i++)r.push(s);return r}function ka(s,r,i){s.pendingLanes|=r,r!==536870912&&(s.suspendedLanes=0,s.pingedLanes=0),s=s.eventTimes,r=31-zt(r),s[r]=i}function Ja(s,r){var i=s.pendingLanes&~r;s.pendingLanes=r,s.suspendedLanes=0,s.pingedLanes=0,s.expiredLanes&=r,s.mutableReadLanes&=r,s.entangledLanes&=r,r=s.entanglements;var p=s.eventTimes;for(s=s.expirationTimes;0<i;){var j=31-zt(i),w=1<<j;r[j]=0,p[j]=-1,s[j]=-1,i&=~w}}function Br(s,r){var i=s.entangledLanes|=r;for(s=s.entanglements;i;){var p=31-zt(i),j=1<<p;j&r|s[p]&r&&(s[p]|=r),i&=~j}}var Ye=0;function Kl(s){return s&=-s,1<s?4<s?(s&268435455)!==0?16:536870912:4:1}var qr,Xa,Wr,zr,Hr,Za=!1,ba=[],_n=null,Un=null,Dn=null,V=new Map,$e=new Map,Ue=[],Bs="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Yl(s,r){switch(s){case"focusin":case"focusout":_n=null;break;case"dragenter":case"dragleave":Un=null;break;case"mouseover":case"mouseout":Dn=null;break;case"pointerover":case"pointerout":V.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":$e.delete(r.pointerId)}}function Gr(s,r,i,p,j,w){return s===null||s.nativeEvent!==w?(s={blockedOn:r,domEventName:i,eventSystemFlags:p,nativeEvent:w,targetContainers:[j]},r!==null&&(r=ll(r),r!==null&&Xa(r)),s):(s.eventSystemFlags|=p,r=s.targetContainers,j!==null&&r.indexOf(j)===-1&&r.push(j),s)}function Vj(s,r,i,p,j){switch(r){case"focusin":return _n=Gr(_n,s,r,i,p,j),!0;case"dragenter":return Un=Gr(Un,s,r,i,p,j),!0;case"mouseover":return Dn=Gr(Dn,s,r,i,p,j),!0;case"pointerover":var w=j.pointerId;return V.set(w,Gr(V.get(w)||null,s,r,i,p,j)),!0;case"gotpointercapture":return w=j.pointerId,$e.set(w,Gr($e.get(w)||null,s,r,i,p,j)),!0}return!1}function bh(s){var r=wa(s.target);if(r!==null){var i=yn(r);if(i!==null){if(r=i.tag,r===13){if(r=ja(i),r!==null){s.blockedOn=r,Hr(s.priority,function(){Wr(i)});return}}else if(r===3&&i.stateNode.current.memoizedState.isDehydrated){s.blockedOn=i.tag===3?i.stateNode.containerInfo:null;return}}}s.blockedOn=null}function Vl(s){if(s.blockedOn!==null)return!1;for(var r=s.targetContainers;0<r.length;){var i=Ki(s.domEventName,s.eventSystemFlags,r[0],s.nativeEvent);if(i===null){i=s.nativeEvent;var p=new i.constructor(i.type,i);gn=p,i.target.dispatchEvent(p),gn=null}else return r=ll(i),r!==null&&Xa(r),s.blockedOn=i,!1;r.shift()}return!0}function wh(s,r,i){Vl(s)&&i.delete(r)}function Qj(){Za=!1,_n!==null&&Vl(_n)&&(_n=null),Un!==null&&Vl(Un)&&(Un=null),Dn!==null&&Vl(Dn)&&(Dn=null),V.forEach(wh),$e.forEach(wh)}function Kr(s,r){s.blockedOn===r&&(s.blockedOn=null,Za||(Za=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,Qj)))}function Yr(s){function r(j){return Kr(j,s)}if(0<ba.length){Kr(ba[0],s);for(var i=1;i<ba.length;i++){var p=ba[i];p.blockedOn===s&&(p.blockedOn=null)}}for(_n!==null&&Kr(_n,s),Un!==null&&Kr(Un,s),Dn!==null&&Kr(Dn,s),V.forEach(r),$e.forEach(r),i=0;i<Ue.length;i++)p=Ue[i],p.blockedOn===s&&(p.blockedOn=null);for(;0<Ue.length&&(i=Ue[0],i.blockedOn===null);)bh(i),i.blockedOn===null&&Ue.shift()}var er=C.ReactCurrentBatchConfig,Ql=!0;function Jj(s,r,i,p){var j=Ye,w=er.transition;er.transition=null;try{Ye=1,Gi(s,r,i,p)}finally{Ye=j,er.transition=w}}function Xj(s,r,i,p){var j=Ye,w=er.transition;er.transition=null;try{Ye=4,Gi(s,r,i,p)}finally{Ye=j,er.transition=w}}function Gi(s,r,i,p){if(Ql){var j=Ki(s,r,i,p);if(j===null)uc(s,r,p,Jl,i),Yl(s,p);else if(Vj(j,s,r,i,p))p.stopPropagation();else if(Yl(s,p),r&4&&-1<Bs.indexOf(s)){for(;j!==null;){var w=ll(j);if(w!==null&&qr(w),w=Ki(s,r,i,p),w===null&&uc(s,r,p,Jl,i),w===j)break;j=w}j!==null&&p.stopPropagation()}else uc(s,r,p,null,i)}}var Jl=null;function Ki(s,r,i,p){if(Jl=null,s=en(p),s=wa(s),s!==null)if(r=yn(s),r===null)s=null;else if(i=r.tag,i===13){if(s=ja(r),s!==null)return s;s=null}else if(i===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;s=null}else r!==s&&(s=null);return Jl=s,null}function Nh(s){switch(s){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Fs()){case Mn:return 1;case Ms:return 4;case gs:case Wi:return 16;case Ya:return 536870912;default:return 16}default:return 16}}var qs=null,Yi=null,Xl=null;function Sh(){if(Xl)return Xl;var s,r=Yi,i=r.length,p,j="value"in qs?qs.value:qs.textContent,w=j.length;for(s=0;s<i&&r[s]===j[s];s++);var T=i-s;for(p=1;p<=T&&r[i-p]===j[w-p];p++);return Xl=j.slice(s,1<p?1-p:void 0)}function Zl(s){var r=s.keyCode;return"charCode"in s?(s=s.charCode,s===0&&r===13&&(s=13)):s=r,s===10&&(s=13),32<=s||s===13?s:0}function eo(){return!0}function Ch(){return!1}function ln(s){function r(i,p,j,w,T){this._reactName=i,this._targetInst=j,this.type=p,this.nativeEvent=w,this.target=T,this.currentTarget=null;for(var F in s)s.hasOwnProperty(F)&&(i=s[F],this[F]=i?i(w):w[F]);return this.isDefaultPrevented=(w.defaultPrevented!=null?w.defaultPrevented:w.returnValue===!1)?eo:Ch,this.isPropagationStopped=Ch,this}return W(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var i=this.nativeEvent;i&&(i.preventDefault?i.preventDefault():typeof i.returnValue!="unknown"&&(i.returnValue=!1),this.isDefaultPrevented=eo)},stopPropagation:function(){var i=this.nativeEvent;i&&(i.stopPropagation?i.stopPropagation():typeof i.cancelBubble!="unknown"&&(i.cancelBubble=!0),this.isPropagationStopped=eo)},persist:function(){},isPersistent:eo}),r}var tr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(s){return s.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Vi=ln(tr),Vr=W({},tr,{view:0,detail:0}),Zj=ln(Vr),Qi,Ji,Qr,to=W({},Vr,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Zi,button:0,buttons:0,relatedTarget:function(s){return s.relatedTarget===void 0?s.fromElement===s.srcElement?s.toElement:s.fromElement:s.relatedTarget},movementX:function(s){return"movementX"in s?s.movementX:(s!==Qr&&(Qr&&s.type==="mousemove"?(Qi=s.screenX-Qr.screenX,Ji=s.screenY-Qr.screenY):Ji=Qi=0,Qr=s),Qi)},movementY:function(s){return"movementY"in s?s.movementY:Ji}}),$h=ln(to),ey=W({},to,{dataTransfer:0}),ty=ln(ey),ny=W({},Vr,{relatedTarget:0}),Xi=ln(ny),sy=W({},tr,{animationName:0,elapsedTime:0,pseudoElement:0}),ay=ln(sy),ry=W({},tr,{clipboardData:function(s){return"clipboardData"in s?s.clipboardData:window.clipboardData}}),ly=ln(ry),oy=W({},tr,{data:0}),Th=ln(oy),iy={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},cy={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},uy={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function dy(s){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(s):(s=uy[s])?!!r[s]:!1}function Zi(){return dy}var hy=W({},Vr,{key:function(s){if(s.key){var r=iy[s.key]||s.key;if(r!=="Unidentified")return r}return s.type==="keypress"?(s=Zl(s),s===13?"Enter":String.fromCharCode(s)):s.type==="keydown"||s.type==="keyup"?cy[s.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Zi,charCode:function(s){return s.type==="keypress"?Zl(s):0},keyCode:function(s){return s.type==="keydown"||s.type==="keyup"?s.keyCode:0},which:function(s){return s.type==="keypress"?Zl(s):s.type==="keydown"||s.type==="keyup"?s.keyCode:0}}),my=ln(hy),py=W({},to,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Eh=ln(py),fy=W({},Vr,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Zi}),gy=ln(fy),xy=W({},tr,{propertyName:0,elapsedTime:0,pseudoElement:0}),jy=ln(xy),yy=W({},to,{deltaX:function(s){return"deltaX"in s?s.deltaX:"wheelDeltaX"in s?-s.wheelDeltaX:0},deltaY:function(s){return"deltaY"in s?s.deltaY:"wheelDeltaY"in s?-s.wheelDeltaY:"wheelDelta"in s?-s.wheelDelta:0},deltaZ:0,deltaMode:0}),vy=ln(yy),ky=[9,13,27,32],ec=u&&"CompositionEvent"in window,Jr=null;u&&"documentMode"in document&&(Jr=document.documentMode);var by=u&&"TextEvent"in window&&!Jr,Rh=u&&(!ec||Jr&&8<Jr&&11>=Jr),Ph=" ",Ah=!1;function Ih(s,r){switch(s){case"keyup":return ky.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Oh(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var nr=!1;function wy(s,r){switch(s){case"compositionend":return Oh(r);case"keypress":return r.which!==32?null:(Ah=!0,Ph);case"textInput":return s=r.data,s===Ph&&Ah?null:s;default:return null}}function Ny(s,r){if(nr)return s==="compositionend"||!ec&&Ih(s,r)?(s=Sh(),Xl=Yi=qs=null,nr=!1,s):null;switch(s){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return Rh&&r.locale!=="ko"?null:r.data;default:return null}}var Sy={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Lh(s){var r=s&&s.nodeName&&s.nodeName.toLowerCase();return r==="input"?!!Sy[s.type]:r==="textarea"}function Fh(s,r,i,p){nn(p),r=lo(r,"onChange"),0<r.length&&(i=new Vi("onChange","change",null,i,p),s.push({event:i,listeners:r}))}var Xr=null,Zr=null;function Cy(s){em(s,0)}function no(s){var r=or(s);if(le(r))return s}function $y(s,r){if(s==="change")return r}var Mh=!1;if(u){var tc;if(u){var nc="oninput"in document;if(!nc){var _h=document.createElement("div");_h.setAttribute("oninput","return;"),nc=typeof _h.oninput=="function"}tc=nc}else tc=!1;Mh=tc&&(!document.documentMode||9<document.documentMode)}function Uh(){Xr&&(Xr.detachEvent("onpropertychange",Dh),Zr=Xr=null)}function Dh(s){if(s.propertyName==="value"&&no(Zr)){var r=[];Fh(r,Zr,s,en(s)),sn(Cy,r)}}function Ty(s,r,i){s==="focusin"?(Uh(),Xr=r,Zr=i,Xr.attachEvent("onpropertychange",Dh)):s==="focusout"&&Uh()}function Ey(s){if(s==="selectionchange"||s==="keyup"||s==="keydown")return no(Zr)}function Ry(s,r){if(s==="click")return no(r)}function Py(s,r){if(s==="input"||s==="change")return no(r)}function Ay(s,r){return s===r&&(s!==0||1/s===1/r)||s!==s&&r!==r}var Bn=typeof Object.is=="function"?Object.is:Ay;function el(s,r){if(Bn(s,r))return!0;if(typeof s!="object"||s===null||typeof r!="object"||r===null)return!1;var i=Object.keys(s),p=Object.keys(r);if(i.length!==p.length)return!1;for(p=0;p<i.length;p++){var j=i[p];if(!m.call(r,j)||!Bn(s[j],r[j]))return!1}return!0}function Bh(s){for(;s&&s.firstChild;)s=s.firstChild;return s}function qh(s,r){var i=Bh(s);s=0;for(var p;i;){if(i.nodeType===3){if(p=s+i.textContent.length,s<=r&&p>=r)return{node:i,offset:r-s};s=p}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Bh(i)}}function Wh(s,r){return s&&r?s===r?!0:s&&s.nodeType===3?!1:r&&r.nodeType===3?Wh(s,r.parentNode):"contains"in s?s.contains(r):s.compareDocumentPosition?!!(s.compareDocumentPosition(r)&16):!1:!1}function zh(){for(var s=window,r=pe();r instanceof s.HTMLIFrameElement;){try{var i=typeof r.contentWindow.location.href=="string"}catch{i=!1}if(i)s=r.contentWindow;else break;r=pe(s.document)}return r}function sc(s){var r=s&&s.nodeName&&s.nodeName.toLowerCase();return r&&(r==="input"&&(s.type==="text"||s.type==="search"||s.type==="tel"||s.type==="url"||s.type==="password")||r==="textarea"||s.contentEditable==="true")}function Iy(s){var r=zh(),i=s.focusedElem,p=s.selectionRange;if(r!==i&&i&&i.ownerDocument&&Wh(i.ownerDocument.documentElement,i)){if(p!==null&&sc(i)){if(r=p.start,s=p.end,s===void 0&&(s=r),"selectionStart"in i)i.selectionStart=r,i.selectionEnd=Math.min(s,i.value.length);else if(s=(r=i.ownerDocument||document)&&r.defaultView||window,s.getSelection){s=s.getSelection();var j=i.textContent.length,w=Math.min(p.start,j);p=p.end===void 0?w:Math.min(p.end,j),!s.extend&&w>p&&(j=p,p=w,w=j),j=qh(i,w);var T=qh(i,p);j&&T&&(s.rangeCount!==1||s.anchorNode!==j.node||s.anchorOffset!==j.offset||s.focusNode!==T.node||s.focusOffset!==T.offset)&&(r=r.createRange(),r.setStart(j.node,j.offset),s.removeAllRanges(),w>p?(s.addRange(r),s.extend(T.node,T.offset)):(r.setEnd(T.node,T.offset),s.addRange(r)))}}for(r=[],s=i;s=s.parentNode;)s.nodeType===1&&r.push({element:s,left:s.scrollLeft,top:s.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i<r.length;i++)s=r[i],s.element.scrollLeft=s.left,s.element.scrollTop=s.top}}var Oy=u&&"documentMode"in document&&11>=document.documentMode,sr=null,ac=null,tl=null,rc=!1;function Hh(s,r,i){var p=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;rc||sr==null||sr!==pe(p)||(p=sr,"selectionStart"in p&&sc(p)?p={start:p.selectionStart,end:p.selectionEnd}:(p=(p.ownerDocument&&p.ownerDocument.defaultView||window).getSelection(),p={anchorNode:p.anchorNode,anchorOffset:p.anchorOffset,focusNode:p.focusNode,focusOffset:p.focusOffset}),tl&&el(tl,p)||(tl=p,p=lo(ac,"onSelect"),0<p.length&&(r=new Vi("onSelect","select",null,r,i),s.push({event:r,listeners:p}),r.target=sr)))}function so(s,r){var i={};return i[s.toLowerCase()]=r.toLowerCase(),i["Webkit"+s]="webkit"+r,i["Moz"+s]="moz"+r,i}var ar={animationend:so("Animation","AnimationEnd"),animationiteration:so("Animation","AnimationIteration"),animationstart:so("Animation","AnimationStart"),transitionend:so("Transition","TransitionEnd")},lc={},Gh={};u&&(Gh=document.createElement("div").style,"AnimationEvent"in window||(delete ar.animationend.animation,delete ar.animationiteration.animation,delete ar.animationstart.animation),"TransitionEvent"in window||delete ar.transitionend.transition);function ao(s){if(lc[s])return lc[s];if(!ar[s])return s;var r=ar[s],i;for(i in r)if(r.hasOwnProperty(i)&&i in Gh)return lc[s]=r[i];return s}var Kh=ao("animationend"),Yh=ao("animationiteration"),Vh=ao("animationstart"),Qh=ao("transitionend"),Jh=new Map,Xh="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Ws(s,r){Jh.set(s,r),c(r,[s])}for(var oc=0;oc<Xh.length;oc++){var ic=Xh[oc],Ly=ic.toLowerCase(),Fy=ic[0].toUpperCase()+ic.slice(1);Ws(Ly,"on"+Fy)}Ws(Kh,"onAnimationEnd"),Ws(Yh,"onAnimationIteration"),Ws(Vh,"onAnimationStart"),Ws("dblclick","onDoubleClick"),Ws("focusin","onFocus"),Ws("focusout","onBlur"),Ws(Qh,"onTransitionEnd"),d("onMouseEnter",["mouseout","mouseover"]),d("onMouseLeave",["mouseout","mouseover"]),d("onPointerEnter",["pointerout","pointerover"]),d("onPointerLeave",["pointerout","pointerover"]),c("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),c("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),c("onBeforeInput",["compositionend","keypress","textInput","paste"]),c("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),c("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),c("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var nl="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),My=new Set("cancel close invalid load scroll toggle".split(" ").concat(nl));function Zh(s,r,i){var p=s.type||"unknown-event";s.currentTarget=i,Zn(p,r,void 0,s),s.currentTarget=null}function em(s,r){r=(r&4)!==0;for(var i=0;i<s.length;i++){var p=s[i],j=p.event;p=p.listeners;e:{var w=void 0;if(r)for(var T=p.length-1;0<=T;T--){var F=p[T],q=F.instance,J=F.currentTarget;if(F=F.listener,q!==w&&j.isPropagationStopped())break e;Zh(j,F,J),w=q}else for(T=0;T<p.length;T++){if(F=p[T],q=F.instance,J=F.currentTarget,F=F.listener,q!==w&&j.isPropagationStopped())break e;Zh(j,F,J),w=q}}}if(ps)throw s=fs,ps=!1,fs=null,s}function Xe(s,r){var i=r[gc];i===void 0&&(i=r[gc]=new Set);var p=s+"__bubble";i.has(p)||(tm(r,s,2,!1),i.add(p))}function cc(s,r,i){var p=0;r&&(p|=4),tm(i,s,p,r)}var ro="_reactListening"+Math.random().toString(36).slice(2);function sl(s){if(!s[ro]){s[ro]=!0,l.forEach(function(i){i!=="selectionchange"&&(My.has(i)||cc(i,!1,s),cc(i,!0,s))});var r=s.nodeType===9?s:s.ownerDocument;r===null||r[ro]||(r[ro]=!0,cc("selectionchange",!1,r))}}function tm(s,r,i,p){switch(Nh(r)){case 1:var j=Jj;break;case 4:j=Xj;break;default:j=Gi}i=j.bind(null,r,i,s),j=void 0,!Jn||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(j=!0),p?j!==void 0?s.addEventListener(r,i,{capture:!0,passive:j}):s.addEventListener(r,i,!0):j!==void 0?s.addEventListener(r,i,{passive:j}):s.addEventListener(r,i,!1)}function uc(s,r,i,p,j){var w=p;if((r&1)===0&&(r&2)===0&&p!==null)e:for(;;){if(p===null)return;var T=p.tag;if(T===3||T===4){var F=p.stateNode.containerInfo;if(F===j||F.nodeType===8&&F.parentNode===j)break;if(T===4)for(T=p.return;T!==null;){var q=T.tag;if((q===3||q===4)&&(q=T.stateNode.containerInfo,q===j||q.nodeType===8&&q.parentNode===j))return;T=T.return}for(;F!==null;){if(T=wa(F),T===null)return;if(q=T.tag,q===5||q===6){p=w=T;continue e}F=F.parentNode}}p=p.return}sn(function(){var J=w,ae=en(i),oe=[];e:{var se=Jh.get(s);if(se!==void 0){var fe=Vi,ye=s;switch(s){case"keypress":if(Zl(i)===0)break e;case"keydown":case"keyup":fe=my;break;case"focusin":ye="focus",fe=Xi;break;case"focusout":ye="blur",fe=Xi;break;case"beforeblur":case"afterblur":fe=Xi;break;case"click":if(i.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":fe=$h;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":fe=ty;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":fe=gy;break;case Kh:case Yh:case Vh:fe=ay;break;case Qh:fe=jy;break;case"scroll":fe=Zj;break;case"wheel":fe=vy;break;case"copy":case"cut":case"paste":fe=ly;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":fe=Eh}var ve=(r&4)!==0,dt=!ve&&s==="scroll",G=ve?se!==null?se+"Capture":null:se;ve=[];for(var z=J,Y;z!==null;){Y=z;var ce=Y.stateNode;if(Y.tag===5&&ce!==null&&(Y=ce,G!==null&&(ce=On(z,G),ce!=null&&ve.push(al(z,ce,Y)))),dt)break;z=z.return}0<ve.length&&(se=new fe(se,ye,null,i,ae),oe.push({event:se,listeners:ve}))}}if((r&7)===0){e:{if(se=s==="mouseover"||s==="pointerover",fe=s==="mouseout"||s==="pointerout",se&&i!==gn&&(ye=i.relatedTarget||i.fromElement)&&(wa(ye)||ye[xs]))break e;if((fe||se)&&(se=ae.window===ae?ae:(se=ae.ownerDocument)?se.defaultView||se.parentWindow:window,fe?(ye=i.relatedTarget||i.toElement,fe=J,ye=ye?wa(ye):null,ye!==null&&(dt=yn(ye),ye!==dt||ye.tag!==5&&ye.tag!==6)&&(ye=null)):(fe=null,ye=J),fe!==ye)){if(ve=$h,ce="onMouseLeave",G="onMouseEnter",z="mouse",(s==="pointerout"||s==="pointerover")&&(ve=Eh,ce="onPointerLeave",G="onPointerEnter",z="pointer"),dt=fe==null?se:or(fe),Y=ye==null?se:or(ye),se=new ve(ce,z+"leave",fe,i,ae),se.target=dt,se.relatedTarget=Y,ce=null,wa(ae)===J&&(ve=new ve(G,z+"enter",ye,i,ae),ve.target=Y,ve.relatedTarget=dt,ce=ve),dt=ce,fe&&ye)t:{for(ve=fe,G=ye,z=0,Y=ve;Y;Y=rr(Y))z++;for(Y=0,ce=G;ce;ce=rr(ce))Y++;for(;0<z-Y;)ve=rr(ve),z--;for(;0<Y-z;)G=rr(G),Y--;for(;z--;){if(ve===G||G!==null&&ve===G.alternate)break t;ve=rr(ve),G=rr(G)}ve=null}else ve=null;fe!==null&&nm(oe,se,fe,ve,!1),ye!==null&&dt!==null&&nm(oe,dt,ye,ve,!0)}}e:{if(se=J?or(J):window,fe=se.nodeName&&se.nodeName.toLowerCase(),fe==="select"||fe==="input"&&se.type==="file")var we=$y;else if(Lh(se))if(Mh)we=Py;else{we=Ey;var Ee=Ty}else(fe=se.nodeName)&&fe.toLowerCase()==="input"&&(se.type==="checkbox"||se.type==="radio")&&(we=Ry);if(we&&(we=we(s,J))){Fh(oe,we,i,ae);break e}Ee&&Ee(s,se,J),s==="focusout"&&(Ee=se._wrapperState)&&Ee.controlled&&se.type==="number"&&Zt(se,"number",se.value)}switch(Ee=J?or(J):window,s){case"focusin":(Lh(Ee)||Ee.contentEditable==="true")&&(sr=Ee,ac=J,tl=null);break;case"focusout":tl=ac=sr=null;break;case"mousedown":rc=!0;break;case"contextmenu":case"mouseup":case"dragend":rc=!1,Hh(oe,i,ae);break;case"selectionchange":if(Oy)break;case"keydown":case"keyup":Hh(oe,i,ae)}var Re;if(ec)e:{switch(s){case"compositionstart":var Ae="onCompositionStart";break e;case"compositionend":Ae="onCompositionEnd";break e;case"compositionupdate":Ae="onCompositionUpdate";break e}Ae=void 0}else nr?Ih(s,i)&&(Ae="onCompositionEnd"):s==="keydown"&&i.keyCode===229&&(Ae="onCompositionStart");Ae&&(Rh&&i.locale!=="ko"&&(nr||Ae!=="onCompositionStart"?Ae==="onCompositionEnd"&&nr&&(Re=Sh()):(qs=ae,Yi="value"in qs?qs.value:qs.textContent,nr=!0)),Ee=lo(J,Ae),0<Ee.length&&(Ae=new Th(Ae,s,null,i,ae),oe.push({event:Ae,listeners:Ee}),Re?Ae.data=Re:(Re=Oh(i),Re!==null&&(Ae.data=Re)))),(Re=by?wy(s,i):Ny(s,i))&&(J=lo(J,"onBeforeInput"),0<J.length&&(ae=new Th("onBeforeInput","beforeinput",null,i,ae),oe.push({event:ae,listeners:J}),ae.data=Re))}em(oe,r)})}function al(s,r,i){return{instance:s,listener:r,currentTarget:i}}function lo(s,r){for(var i=r+"Capture",p=[];s!==null;){var j=s,w=j.stateNode;j.tag===5&&w!==null&&(j=w,w=On(s,i),w!=null&&p.unshift(al(s,w,j)),w=On(s,r),w!=null&&p.push(al(s,w,j))),s=s.return}return p}function rr(s){if(s===null)return null;do s=s.return;while(s&&s.tag!==5);return s||null}function nm(s,r,i,p,j){for(var w=r._reactName,T=[];i!==null&&i!==p;){var F=i,q=F.alternate,J=F.stateNode;if(q!==null&&q===p)break;F.tag===5&&J!==null&&(F=J,j?(q=On(i,w),q!=null&&T.unshift(al(i,q,F))):j||(q=On(i,w),q!=null&&T.push(al(i,q,F)))),i=i.return}T.length!==0&&s.push({event:r,listeners:T})}var _y=/\r\n?/g,Uy=/\u0000|\uFFFD/g;function sm(s){return(typeof s=="string"?s:""+s).replace(_y,`
|
|
38
|
+
`).replace(Uy,"")}function oo(s,r,i){if(r=sm(r),sm(s)!==r&&i)throw Error(a(425))}function io(){}var dc=null,hc=null;function mc(s,r){return s==="textarea"||s==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var pc=typeof setTimeout=="function"?setTimeout:void 0,Dy=typeof clearTimeout=="function"?clearTimeout:void 0,am=typeof Promise=="function"?Promise:void 0,By=typeof queueMicrotask=="function"?queueMicrotask:typeof am<"u"?function(s){return am.resolve(null).then(s).catch(qy)}:pc;function qy(s){setTimeout(function(){throw s})}function fc(s,r){var i=r,p=0;do{var j=i.nextSibling;if(s.removeChild(i),j&&j.nodeType===8)if(i=j.data,i==="/$"){if(p===0){s.removeChild(j),Yr(r);return}p--}else i!=="$"&&i!=="$?"&&i!=="$!"||p++;i=j}while(i);Yr(r)}function zs(s){for(;s!=null;s=s.nextSibling){var r=s.nodeType;if(r===1||r===3)break;if(r===8){if(r=s.data,r==="$"||r==="$!"||r==="$?")break;if(r==="/$")return null}}return s}function rm(s){s=s.previousSibling;for(var r=0;s;){if(s.nodeType===8){var i=s.data;if(i==="$"||i==="$!"||i==="$?"){if(r===0)return s;r--}else i==="/$"&&r++}s=s.previousSibling}return null}var lr=Math.random().toString(36).slice(2),es="__reactFiber$"+lr,rl="__reactProps$"+lr,xs="__reactContainer$"+lr,gc="__reactEvents$"+lr,Wy="__reactListeners$"+lr,zy="__reactHandles$"+lr;function wa(s){var r=s[es];if(r)return r;for(var i=s.parentNode;i;){if(r=i[xs]||i[es]){if(i=r.alternate,r.child!==null||i!==null&&i.child!==null)for(s=rm(s);s!==null;){if(i=s[es])return i;s=rm(s)}return r}s=i,i=s.parentNode}return null}function ll(s){return s=s[es]||s[xs],!s||s.tag!==5&&s.tag!==6&&s.tag!==13&&s.tag!==3?null:s}function or(s){if(s.tag===5||s.tag===6)return s.stateNode;throw Error(a(33))}function co(s){return s[rl]||null}var xc=[],ir=-1;function Hs(s){return{current:s}}function Ze(s){0>ir||(s.current=xc[ir],xc[ir]=null,ir--)}function Qe(s,r){ir++,xc[ir]=s.current,s.current=r}var Gs={},Pt=Hs(Gs),Ht=Hs(!1),Na=Gs;function cr(s,r){var i=s.type.contextTypes;if(!i)return Gs;var p=s.stateNode;if(p&&p.__reactInternalMemoizedUnmaskedChildContext===r)return p.__reactInternalMemoizedMaskedChildContext;var j={},w;for(w in i)j[w]=r[w];return p&&(s=s.stateNode,s.__reactInternalMemoizedUnmaskedChildContext=r,s.__reactInternalMemoizedMaskedChildContext=j),j}function Gt(s){return s=s.childContextTypes,s!=null}function uo(){Ze(Ht),Ze(Pt)}function lm(s,r,i){if(Pt.current!==Gs)throw Error(a(168));Qe(Pt,r),Qe(Ht,i)}function om(s,r,i){var p=s.stateNode;if(r=r.childContextTypes,typeof p.getChildContext!="function")return i;p=p.getChildContext();for(var j in p)if(!(j in r))throw Error(a(108,xe(s)||"Unknown",j));return W({},i,p)}function ho(s){return s=(s=s.stateNode)&&s.__reactInternalMemoizedMergedChildContext||Gs,Na=Pt.current,Qe(Pt,s),Qe(Ht,Ht.current),!0}function im(s,r,i){var p=s.stateNode;if(!p)throw Error(a(169));i?(s=om(s,r,Na),p.__reactInternalMemoizedMergedChildContext=s,Ze(Ht),Ze(Pt),Qe(Pt,s)):Ze(Ht),Qe(Ht,i)}var js=null,mo=!1,jc=!1;function cm(s){js===null?js=[s]:js.push(s)}function Hy(s){mo=!0,cm(s)}function Ks(){if(!jc&&js!==null){jc=!0;var s=0,r=Ye;try{var i=js;for(Ye=1;s<i.length;s++){var p=i[s];do p=p(!0);while(p!==null)}js=null,mo=!1}catch(j){throw js!==null&&(js=js.slice(s+1)),rn(Mn,Ks),j}finally{Ye=r,jc=!1}}return null}var ur=[],dr=0,po=null,fo=0,kn=[],bn=0,Sa=null,ys=1,vs="";function Ca(s,r){ur[dr++]=fo,ur[dr++]=po,po=s,fo=r}function um(s,r,i){kn[bn++]=ys,kn[bn++]=vs,kn[bn++]=Sa,Sa=s;var p=ys;s=vs;var j=32-zt(p)-1;p&=~(1<<j),i+=1;var w=32-zt(r)+j;if(30<w){var T=j-j%5;w=(p&(1<<T)-1).toString(32),p>>=T,j-=T,ys=1<<32-zt(r)+j|i<<j|p,vs=w+s}else ys=1<<w|i<<j|p,vs=s}function yc(s){s.return!==null&&(Ca(s,1),um(s,1,0))}function vc(s){for(;s===po;)po=ur[--dr],ur[dr]=null,fo=ur[--dr],ur[dr]=null;for(;s===Sa;)Sa=kn[--bn],kn[bn]=null,vs=kn[--bn],kn[bn]=null,ys=kn[--bn],kn[bn]=null}var on=null,cn=null,at=!1,qn=null;function dm(s,r){var i=Cn(5,null,null,0);i.elementType="DELETED",i.stateNode=r,i.return=s,r=s.deletions,r===null?(s.deletions=[i],s.flags|=16):r.push(i)}function hm(s,r){switch(s.tag){case 5:var i=s.type;return r=r.nodeType!==1||i.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(s.stateNode=r,on=s,cn=zs(r.firstChild),!0):!1;case 6:return r=s.pendingProps===""||r.nodeType!==3?null:r,r!==null?(s.stateNode=r,on=s,cn=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(i=Sa!==null?{id:ys,overflow:vs}:null,s.memoizedState={dehydrated:r,treeContext:i,retryLane:1073741824},i=Cn(18,null,null,0),i.stateNode=r,i.return=s,s.child=i,on=s,cn=null,!0):!1;default:return!1}}function kc(s){return(s.mode&1)!==0&&(s.flags&128)===0}function bc(s){if(at){var r=cn;if(r){var i=r;if(!hm(s,r)){if(kc(s))throw Error(a(418));r=zs(i.nextSibling);var p=on;r&&hm(s,r)?dm(p,i):(s.flags=s.flags&-4097|2,at=!1,on=s)}}else{if(kc(s))throw Error(a(418));s.flags=s.flags&-4097|2,at=!1,on=s}}}function mm(s){for(s=s.return;s!==null&&s.tag!==5&&s.tag!==3&&s.tag!==13;)s=s.return;on=s}function go(s){if(s!==on)return!1;if(!at)return mm(s),at=!0,!1;var r;if((r=s.tag!==3)&&!(r=s.tag!==5)&&(r=s.type,r=r!=="head"&&r!=="body"&&!mc(s.type,s.memoizedProps)),r&&(r=cn)){if(kc(s))throw pm(),Error(a(418));for(;r;)dm(s,r),r=zs(r.nextSibling)}if(mm(s),s.tag===13){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(a(317));e:{for(s=s.nextSibling,r=0;s;){if(s.nodeType===8){var i=s.data;if(i==="/$"){if(r===0){cn=zs(s.nextSibling);break e}r--}else i!=="$"&&i!=="$!"&&i!=="$?"||r++}s=s.nextSibling}cn=null}}else cn=on?zs(s.stateNode.nextSibling):null;return!0}function pm(){for(var s=cn;s;)s=zs(s.nextSibling)}function hr(){cn=on=null,at=!1}function wc(s){qn===null?qn=[s]:qn.push(s)}var Gy=C.ReactCurrentBatchConfig;function ol(s,r,i){if(s=i.ref,s!==null&&typeof s!="function"&&typeof s!="object"){if(i._owner){if(i=i._owner,i){if(i.tag!==1)throw Error(a(309));var p=i.stateNode}if(!p)throw Error(a(147,s));var j=p,w=""+s;return r!==null&&r.ref!==null&&typeof r.ref=="function"&&r.ref._stringRef===w?r.ref:(r=function(T){var F=j.refs;T===null?delete F[w]:F[w]=T},r._stringRef=w,r)}if(typeof s!="string")throw Error(a(284));if(!i._owner)throw Error(a(290,s))}return s}function xo(s,r){throw s=Object.prototype.toString.call(r),Error(a(31,s==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":s))}function fm(s){var r=s._init;return r(s._payload)}function gm(s){function r(G,z){if(s){var Y=G.deletions;Y===null?(G.deletions=[z],G.flags|=16):Y.push(z)}}function i(G,z){if(!s)return null;for(;z!==null;)r(G,z),z=z.sibling;return null}function p(G,z){for(G=new Map;z!==null;)z.key!==null?G.set(z.key,z):G.set(z.index,z),z=z.sibling;return G}function j(G,z){return G=ta(G,z),G.index=0,G.sibling=null,G}function w(G,z,Y){return G.index=Y,s?(Y=G.alternate,Y!==null?(Y=Y.index,Y<z?(G.flags|=2,z):Y):(G.flags|=2,z)):(G.flags|=1048576,z)}function T(G){return s&&G.alternate===null&&(G.flags|=2),G}function F(G,z,Y,ce){return z===null||z.tag!==6?(z=pu(Y,G.mode,ce),z.return=G,z):(z=j(z,Y),z.return=G,z)}function q(G,z,Y,ce){var we=Y.type;return we===M?ae(G,z,Y.props.children,ce,Y.key):z!==null&&(z.elementType===we||typeof we=="object"&&we!==null&&we.$$typeof===D&&fm(we)===z.type)?(ce=j(z,Y.props),ce.ref=ol(G,z,Y),ce.return=G,ce):(ce=Bo(Y.type,Y.key,Y.props,null,G.mode,ce),ce.ref=ol(G,z,Y),ce.return=G,ce)}function J(G,z,Y,ce){return z===null||z.tag!==4||z.stateNode.containerInfo!==Y.containerInfo||z.stateNode.implementation!==Y.implementation?(z=fu(Y,G.mode,ce),z.return=G,z):(z=j(z,Y.children||[]),z.return=G,z)}function ae(G,z,Y,ce,we){return z===null||z.tag!==7?(z=Oa(Y,G.mode,ce,we),z.return=G,z):(z=j(z,Y),z.return=G,z)}function oe(G,z,Y){if(typeof z=="string"&&z!==""||typeof z=="number")return z=pu(""+z,G.mode,Y),z.return=G,z;if(typeof z=="object"&&z!==null){switch(z.$$typeof){case R:return Y=Bo(z.type,z.key,z.props,null,G.mode,Y),Y.ref=ol(G,null,z),Y.return=G,Y;case P:return z=fu(z,G.mode,Y),z.return=G,z;case D:var ce=z._init;return oe(G,ce(z._payload),Y)}if(Qn(z)||ee(z))return z=Oa(z,G.mode,Y,null),z.return=G,z;xo(G,z)}return null}function se(G,z,Y,ce){var we=z!==null?z.key:null;if(typeof Y=="string"&&Y!==""||typeof Y=="number")return we!==null?null:F(G,z,""+Y,ce);if(typeof Y=="object"&&Y!==null){switch(Y.$$typeof){case R:return Y.key===we?q(G,z,Y,ce):null;case P:return Y.key===we?J(G,z,Y,ce):null;case D:return we=Y._init,se(G,z,we(Y._payload),ce)}if(Qn(Y)||ee(Y))return we!==null?null:ae(G,z,Y,ce,null);xo(G,Y)}return null}function fe(G,z,Y,ce,we){if(typeof ce=="string"&&ce!==""||typeof ce=="number")return G=G.get(Y)||null,F(z,G,""+ce,we);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case R:return G=G.get(ce.key===null?Y:ce.key)||null,q(z,G,ce,we);case P:return G=G.get(ce.key===null?Y:ce.key)||null,J(z,G,ce,we);case D:var Ee=ce._init;return fe(G,z,Y,Ee(ce._payload),we)}if(Qn(ce)||ee(ce))return G=G.get(Y)||null,ae(z,G,ce,we,null);xo(z,ce)}return null}function ye(G,z,Y,ce){for(var we=null,Ee=null,Re=z,Ae=z=0,wt=null;Re!==null&&Ae<Y.length;Ae++){Re.index>Ae?(wt=Re,Re=null):wt=Re.sibling;var Ke=se(G,Re,Y[Ae],ce);if(Ke===null){Re===null&&(Re=wt);break}s&&Re&&Ke.alternate===null&&r(G,Re),z=w(Ke,z,Ae),Ee===null?we=Ke:Ee.sibling=Ke,Ee=Ke,Re=wt}if(Ae===Y.length)return i(G,Re),at&&Ca(G,Ae),we;if(Re===null){for(;Ae<Y.length;Ae++)Re=oe(G,Y[Ae],ce),Re!==null&&(z=w(Re,z,Ae),Ee===null?we=Re:Ee.sibling=Re,Ee=Re);return at&&Ca(G,Ae),we}for(Re=p(G,Re);Ae<Y.length;Ae++)wt=fe(Re,G,Ae,Y[Ae],ce),wt!==null&&(s&&wt.alternate!==null&&Re.delete(wt.key===null?Ae:wt.key),z=w(wt,z,Ae),Ee===null?we=wt:Ee.sibling=wt,Ee=wt);return s&&Re.forEach(function(na){return r(G,na)}),at&&Ca(G,Ae),we}function ve(G,z,Y,ce){var we=ee(Y);if(typeof we!="function")throw Error(a(150));if(Y=we.call(Y),Y==null)throw Error(a(151));for(var Ee=we=null,Re=z,Ae=z=0,wt=null,Ke=Y.next();Re!==null&&!Ke.done;Ae++,Ke=Y.next()){Re.index>Ae?(wt=Re,Re=null):wt=Re.sibling;var na=se(G,Re,Ke.value,ce);if(na===null){Re===null&&(Re=wt);break}s&&Re&&na.alternate===null&&r(G,Re),z=w(na,z,Ae),Ee===null?we=na:Ee.sibling=na,Ee=na,Re=wt}if(Ke.done)return i(G,Re),at&&Ca(G,Ae),we;if(Re===null){for(;!Ke.done;Ae++,Ke=Y.next())Ke=oe(G,Ke.value,ce),Ke!==null&&(z=w(Ke,z,Ae),Ee===null?we=Ke:Ee.sibling=Ke,Ee=Ke);return at&&Ca(G,Ae),we}for(Re=p(G,Re);!Ke.done;Ae++,Ke=Y.next())Ke=fe(Re,G,Ae,Ke.value,ce),Ke!==null&&(s&&Ke.alternate!==null&&Re.delete(Ke.key===null?Ae:Ke.key),z=w(Ke,z,Ae),Ee===null?we=Ke:Ee.sibling=Ke,Ee=Ke);return s&&Re.forEach(function(Sv){return r(G,Sv)}),at&&Ca(G,Ae),we}function dt(G,z,Y,ce){if(typeof Y=="object"&&Y!==null&&Y.type===M&&Y.key===null&&(Y=Y.props.children),typeof Y=="object"&&Y!==null){switch(Y.$$typeof){case R:e:{for(var we=Y.key,Ee=z;Ee!==null;){if(Ee.key===we){if(we=Y.type,we===M){if(Ee.tag===7){i(G,Ee.sibling),z=j(Ee,Y.props.children),z.return=G,G=z;break e}}else if(Ee.elementType===we||typeof we=="object"&&we!==null&&we.$$typeof===D&&fm(we)===Ee.type){i(G,Ee.sibling),z=j(Ee,Y.props),z.ref=ol(G,Ee,Y),z.return=G,G=z;break e}i(G,Ee);break}else r(G,Ee);Ee=Ee.sibling}Y.type===M?(z=Oa(Y.props.children,G.mode,ce,Y.key),z.return=G,G=z):(ce=Bo(Y.type,Y.key,Y.props,null,G.mode,ce),ce.ref=ol(G,z,Y),ce.return=G,G=ce)}return T(G);case P:e:{for(Ee=Y.key;z!==null;){if(z.key===Ee)if(z.tag===4&&z.stateNode.containerInfo===Y.containerInfo&&z.stateNode.implementation===Y.implementation){i(G,z.sibling),z=j(z,Y.children||[]),z.return=G,G=z;break e}else{i(G,z);break}else r(G,z);z=z.sibling}z=fu(Y,G.mode,ce),z.return=G,G=z}return T(G);case D:return Ee=Y._init,dt(G,z,Ee(Y._payload),ce)}if(Qn(Y))return ye(G,z,Y,ce);if(ee(Y))return ve(G,z,Y,ce);xo(G,Y)}return typeof Y=="string"&&Y!==""||typeof Y=="number"?(Y=""+Y,z!==null&&z.tag===6?(i(G,z.sibling),z=j(z,Y),z.return=G,G=z):(i(G,z),z=pu(Y,G.mode,ce),z.return=G,G=z),T(G)):i(G,z)}return dt}var mr=gm(!0),xm=gm(!1),jo=Hs(null),yo=null,pr=null,Nc=null;function Sc(){Nc=pr=yo=null}function Cc(s){var r=jo.current;Ze(jo),s._currentValue=r}function $c(s,r,i){for(;s!==null;){var p=s.alternate;if((s.childLanes&r)!==r?(s.childLanes|=r,p!==null&&(p.childLanes|=r)):p!==null&&(p.childLanes&r)!==r&&(p.childLanes|=r),s===i)break;s=s.return}}function fr(s,r){yo=s,Nc=pr=null,s=s.dependencies,s!==null&&s.firstContext!==null&&((s.lanes&r)!==0&&(Kt=!0),s.firstContext=null)}function wn(s){var r=s._currentValue;if(Nc!==s)if(s={context:s,memoizedValue:r,next:null},pr===null){if(yo===null)throw Error(a(308));pr=s,yo.dependencies={lanes:0,firstContext:s}}else pr=pr.next=s;return r}var $a=null;function Tc(s){$a===null?$a=[s]:$a.push(s)}function jm(s,r,i,p){var j=r.interleaved;return j===null?(i.next=i,Tc(r)):(i.next=j.next,j.next=i),r.interleaved=i,ks(s,p)}function ks(s,r){s.lanes|=r;var i=s.alternate;for(i!==null&&(i.lanes|=r),i=s,s=s.return;s!==null;)s.childLanes|=r,i=s.alternate,i!==null&&(i.childLanes|=r),i=s,s=s.return;return i.tag===3?i.stateNode:null}var Ys=!1;function Ec(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function ym(s,r){s=s.updateQueue,r.updateQueue===s&&(r.updateQueue={baseState:s.baseState,firstBaseUpdate:s.firstBaseUpdate,lastBaseUpdate:s.lastBaseUpdate,shared:s.shared,effects:s.effects})}function bs(s,r){return{eventTime:s,lane:r,tag:0,payload:null,callback:null,next:null}}function Vs(s,r,i){var p=s.updateQueue;if(p===null)return null;if(p=p.shared,(He&2)!==0){var j=p.pending;return j===null?r.next=r:(r.next=j.next,j.next=r),p.pending=r,ks(s,i)}return j=p.interleaved,j===null?(r.next=r,Tc(p)):(r.next=j.next,j.next=r),p.interleaved=r,ks(s,i)}function vo(s,r,i){if(r=r.updateQueue,r!==null&&(r=r.shared,(i&4194240)!==0)){var p=r.lanes;p&=s.pendingLanes,i|=p,r.lanes=i,Br(s,i)}}function vm(s,r){var i=s.updateQueue,p=s.alternate;if(p!==null&&(p=p.updateQueue,i===p)){var j=null,w=null;if(i=i.firstBaseUpdate,i!==null){do{var T={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};w===null?j=w=T:w=w.next=T,i=i.next}while(i!==null);w===null?j=w=r:w=w.next=r}else j=w=r;i={baseState:p.baseState,firstBaseUpdate:j,lastBaseUpdate:w,shared:p.shared,effects:p.effects},s.updateQueue=i;return}s=i.lastBaseUpdate,s===null?i.firstBaseUpdate=r:s.next=r,i.lastBaseUpdate=r}function ko(s,r,i,p){var j=s.updateQueue;Ys=!1;var w=j.firstBaseUpdate,T=j.lastBaseUpdate,F=j.shared.pending;if(F!==null){j.shared.pending=null;var q=F,J=q.next;q.next=null,T===null?w=J:T.next=J,T=q;var ae=s.alternate;ae!==null&&(ae=ae.updateQueue,F=ae.lastBaseUpdate,F!==T&&(F===null?ae.firstBaseUpdate=J:F.next=J,ae.lastBaseUpdate=q))}if(w!==null){var oe=j.baseState;T=0,ae=J=q=null,F=w;do{var se=F.lane,fe=F.eventTime;if((p&se)===se){ae!==null&&(ae=ae.next={eventTime:fe,lane:0,tag:F.tag,payload:F.payload,callback:F.callback,next:null});e:{var ye=s,ve=F;switch(se=r,fe=i,ve.tag){case 1:if(ye=ve.payload,typeof ye=="function"){oe=ye.call(fe,oe,se);break e}oe=ye;break e;case 3:ye.flags=ye.flags&-65537|128;case 0:if(ye=ve.payload,se=typeof ye=="function"?ye.call(fe,oe,se):ye,se==null)break e;oe=W({},oe,se);break e;case 2:Ys=!0}}F.callback!==null&&F.lane!==0&&(s.flags|=64,se=j.effects,se===null?j.effects=[F]:se.push(F))}else fe={eventTime:fe,lane:se,tag:F.tag,payload:F.payload,callback:F.callback,next:null},ae===null?(J=ae=fe,q=oe):ae=ae.next=fe,T|=se;if(F=F.next,F===null){if(F=j.shared.pending,F===null)break;se=F,F=se.next,se.next=null,j.lastBaseUpdate=se,j.shared.pending=null}}while(!0);if(ae===null&&(q=oe),j.baseState=q,j.firstBaseUpdate=J,j.lastBaseUpdate=ae,r=j.shared.interleaved,r!==null){j=r;do T|=j.lane,j=j.next;while(j!==r)}else w===null&&(j.shared.lanes=0);Ra|=T,s.lanes=T,s.memoizedState=oe}}function km(s,r,i){if(s=r.effects,r.effects=null,s!==null)for(r=0;r<s.length;r++){var p=s[r],j=p.callback;if(j!==null){if(p.callback=null,p=i,typeof j!="function")throw Error(a(191,j));j.call(p)}}}var il={},ts=Hs(il),cl=Hs(il),ul=Hs(il);function Ta(s){if(s===il)throw Error(a(174));return s}function Rc(s,r){switch(Qe(ul,r),Qe(cl,s),Qe(ts,il),s=r.nodeType,s){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:Ct(null,"");break;default:s=s===8?r.parentNode:r,r=s.namespaceURI||null,s=s.tagName,r=Ct(r,s)}Ze(ts),Qe(ts,r)}function gr(){Ze(ts),Ze(cl),Ze(ul)}function bm(s){Ta(ul.current);var r=Ta(ts.current),i=Ct(r,s.type);r!==i&&(Qe(cl,s),Qe(ts,i))}function Pc(s){cl.current===s&&(Ze(ts),Ze(cl))}var ot=Hs(0);function bo(s){for(var r=s;r!==null;){if(r.tag===13){var i=r.memoizedState;if(i!==null&&(i=i.dehydrated,i===null||i.data==="$?"||i.data==="$!"))return r}else if(r.tag===19&&r.memoizedProps.revealOrder!==void 0){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===s)break;for(;r.sibling===null;){if(r.return===null||r.return===s)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var Ac=[];function Ic(){for(var s=0;s<Ac.length;s++)Ac[s]._workInProgressVersionPrimary=null;Ac.length=0}var wo=C.ReactCurrentDispatcher,Oc=C.ReactCurrentBatchConfig,Ea=0,it=null,xt=null,kt=null,No=!1,dl=!1,hl=0,Ky=0;function At(){throw Error(a(321))}function Lc(s,r){if(r===null)return!1;for(var i=0;i<r.length&&i<s.length;i++)if(!Bn(s[i],r[i]))return!1;return!0}function Fc(s,r,i,p,j,w){if(Ea=w,it=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,wo.current=s===null||s.memoizedState===null?Jy:Xy,s=i(p,j),dl){w=0;do{if(dl=!1,hl=0,25<=w)throw Error(a(301));w+=1,kt=xt=null,r.updateQueue=null,wo.current=Zy,s=i(p,j)}while(dl)}if(wo.current=$o,r=xt!==null&&xt.next!==null,Ea=0,kt=xt=it=null,No=!1,r)throw Error(a(300));return s}function Mc(){var s=hl!==0;return hl=0,s}function ns(){var s={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return kt===null?it.memoizedState=kt=s:kt=kt.next=s,kt}function Nn(){if(xt===null){var s=it.alternate;s=s!==null?s.memoizedState:null}else s=xt.next;var r=kt===null?it.memoizedState:kt.next;if(r!==null)kt=r,xt=s;else{if(s===null)throw Error(a(310));xt=s,s={memoizedState:xt.memoizedState,baseState:xt.baseState,baseQueue:xt.baseQueue,queue:xt.queue,next:null},kt===null?it.memoizedState=kt=s:kt=kt.next=s}return kt}function ml(s,r){return typeof r=="function"?r(s):r}function _c(s){var r=Nn(),i=r.queue;if(i===null)throw Error(a(311));i.lastRenderedReducer=s;var p=xt,j=p.baseQueue,w=i.pending;if(w!==null){if(j!==null){var T=j.next;j.next=w.next,w.next=T}p.baseQueue=j=w,i.pending=null}if(j!==null){w=j.next,p=p.baseState;var F=T=null,q=null,J=w;do{var ae=J.lane;if((Ea&ae)===ae)q!==null&&(q=q.next={lane:0,action:J.action,hasEagerState:J.hasEagerState,eagerState:J.eagerState,next:null}),p=J.hasEagerState?J.eagerState:s(p,J.action);else{var oe={lane:ae,action:J.action,hasEagerState:J.hasEagerState,eagerState:J.eagerState,next:null};q===null?(F=q=oe,T=p):q=q.next=oe,it.lanes|=ae,Ra|=ae}J=J.next}while(J!==null&&J!==w);q===null?T=p:q.next=F,Bn(p,r.memoizedState)||(Kt=!0),r.memoizedState=p,r.baseState=T,r.baseQueue=q,i.lastRenderedState=p}if(s=i.interleaved,s!==null){j=s;do w=j.lane,it.lanes|=w,Ra|=w,j=j.next;while(j!==s)}else j===null&&(i.lanes=0);return[r.memoizedState,i.dispatch]}function Uc(s){var r=Nn(),i=r.queue;if(i===null)throw Error(a(311));i.lastRenderedReducer=s;var p=i.dispatch,j=i.pending,w=r.memoizedState;if(j!==null){i.pending=null;var T=j=j.next;do w=s(w,T.action),T=T.next;while(T!==j);Bn(w,r.memoizedState)||(Kt=!0),r.memoizedState=w,r.baseQueue===null&&(r.baseState=w),i.lastRenderedState=w}return[w,p]}function wm(){}function Nm(s,r){var i=it,p=Nn(),j=r(),w=!Bn(p.memoizedState,j);if(w&&(p.memoizedState=j,Kt=!0),p=p.queue,Dc($m.bind(null,i,p,s),[s]),p.getSnapshot!==r||w||kt!==null&&kt.memoizedState.tag&1){if(i.flags|=2048,pl(9,Cm.bind(null,i,p,j,r),void 0,null),bt===null)throw Error(a(349));(Ea&30)!==0||Sm(i,r,j)}return j}function Sm(s,r,i){s.flags|=16384,s={getSnapshot:r,value:i},r=it.updateQueue,r===null?(r={lastEffect:null,stores:null},it.updateQueue=r,r.stores=[s]):(i=r.stores,i===null?r.stores=[s]:i.push(s))}function Cm(s,r,i,p){r.value=i,r.getSnapshot=p,Tm(r)&&Em(s)}function $m(s,r,i){return i(function(){Tm(r)&&Em(s)})}function Tm(s){var r=s.getSnapshot;s=s.value;try{var i=r();return!Bn(s,i)}catch{return!0}}function Em(s){var r=ks(s,1);r!==null&&Gn(r,s,1,-1)}function Rm(s){var r=ns();return typeof s=="function"&&(s=s()),r.memoizedState=r.baseState=s,s={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:ml,lastRenderedState:s},r.queue=s,s=s.dispatch=Qy.bind(null,it,s),[r.memoizedState,s]}function pl(s,r,i,p){return s={tag:s,create:r,destroy:i,deps:p,next:null},r=it.updateQueue,r===null?(r={lastEffect:null,stores:null},it.updateQueue=r,r.lastEffect=s.next=s):(i=r.lastEffect,i===null?r.lastEffect=s.next=s:(p=i.next,i.next=s,s.next=p,r.lastEffect=s)),s}function Pm(){return Nn().memoizedState}function So(s,r,i,p){var j=ns();it.flags|=s,j.memoizedState=pl(1|r,i,void 0,p===void 0?null:p)}function Co(s,r,i,p){var j=Nn();p=p===void 0?null:p;var w=void 0;if(xt!==null){var T=xt.memoizedState;if(w=T.destroy,p!==null&&Lc(p,T.deps)){j.memoizedState=pl(r,i,w,p);return}}it.flags|=s,j.memoizedState=pl(1|r,i,w,p)}function Am(s,r){return So(8390656,8,s,r)}function Dc(s,r){return Co(2048,8,s,r)}function Im(s,r){return Co(4,2,s,r)}function Om(s,r){return Co(4,4,s,r)}function Lm(s,r){if(typeof r=="function")return s=s(),r(s),function(){r(null)};if(r!=null)return s=s(),r.current=s,function(){r.current=null}}function Fm(s,r,i){return i=i!=null?i.concat([s]):null,Co(4,4,Lm.bind(null,r,s),i)}function Bc(){}function Mm(s,r){var i=Nn();r=r===void 0?null:r;var p=i.memoizedState;return p!==null&&r!==null&&Lc(r,p[1])?p[0]:(i.memoizedState=[s,r],s)}function _m(s,r){var i=Nn();r=r===void 0?null:r;var p=i.memoizedState;return p!==null&&r!==null&&Lc(r,p[1])?p[0]:(s=s(),i.memoizedState=[s,r],s)}function Um(s,r,i){return(Ea&21)===0?(s.baseState&&(s.baseState=!1,Kt=!0),s.memoizedState=i):(Bn(i,r)||(i=va(),it.lanes|=i,Ra|=i,s.baseState=!0),r)}function Yy(s,r){var i=Ye;Ye=i!==0&&4>i?i:4,s(!0);var p=Oc.transition;Oc.transition={};try{s(!1),r()}finally{Ye=i,Oc.transition=p}}function Dm(){return Nn().memoizedState}function Vy(s,r,i){var p=Zs(s);if(i={lane:p,action:i,hasEagerState:!1,eagerState:null,next:null},Bm(s))qm(r,i);else if(i=jm(s,r,i,p),i!==null){var j=Ut();Gn(i,s,p,j),Wm(i,r,p)}}function Qy(s,r,i){var p=Zs(s),j={lane:p,action:i,hasEagerState:!1,eagerState:null,next:null};if(Bm(s))qm(r,j);else{var w=s.alternate;if(s.lanes===0&&(w===null||w.lanes===0)&&(w=r.lastRenderedReducer,w!==null))try{var T=r.lastRenderedState,F=w(T,i);if(j.hasEagerState=!0,j.eagerState=F,Bn(F,T)){var q=r.interleaved;q===null?(j.next=j,Tc(r)):(j.next=q.next,q.next=j),r.interleaved=j;return}}catch{}finally{}i=jm(s,r,j,p),i!==null&&(j=Ut(),Gn(i,s,p,j),Wm(i,r,p))}}function Bm(s){var r=s.alternate;return s===it||r!==null&&r===it}function qm(s,r){dl=No=!0;var i=s.pending;i===null?r.next=r:(r.next=i.next,i.next=r),s.pending=r}function Wm(s,r,i){if((i&4194240)!==0){var p=r.lanes;p&=s.pendingLanes,i|=p,r.lanes=i,Br(s,i)}}var $o={readContext:wn,useCallback:At,useContext:At,useEffect:At,useImperativeHandle:At,useInsertionEffect:At,useLayoutEffect:At,useMemo:At,useReducer:At,useRef:At,useState:At,useDebugValue:At,useDeferredValue:At,useTransition:At,useMutableSource:At,useSyncExternalStore:At,useId:At,unstable_isNewReconciler:!1},Jy={readContext:wn,useCallback:function(s,r){return ns().memoizedState=[s,r===void 0?null:r],s},useContext:wn,useEffect:Am,useImperativeHandle:function(s,r,i){return i=i!=null?i.concat([s]):null,So(4194308,4,Lm.bind(null,r,s),i)},useLayoutEffect:function(s,r){return So(4194308,4,s,r)},useInsertionEffect:function(s,r){return So(4,2,s,r)},useMemo:function(s,r){var i=ns();return r=r===void 0?null:r,s=s(),i.memoizedState=[s,r],s},useReducer:function(s,r,i){var p=ns();return r=i!==void 0?i(r):r,p.memoizedState=p.baseState=r,s={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:r},p.queue=s,s=s.dispatch=Vy.bind(null,it,s),[p.memoizedState,s]},useRef:function(s){var r=ns();return s={current:s},r.memoizedState=s},useState:Rm,useDebugValue:Bc,useDeferredValue:function(s){return ns().memoizedState=s},useTransition:function(){var s=Rm(!1),r=s[0];return s=Yy.bind(null,s[1]),ns().memoizedState=s,[r,s]},useMutableSource:function(){},useSyncExternalStore:function(s,r,i){var p=it,j=ns();if(at){if(i===void 0)throw Error(a(407));i=i()}else{if(i=r(),bt===null)throw Error(a(349));(Ea&30)!==0||Sm(p,r,i)}j.memoizedState=i;var w={value:i,getSnapshot:r};return j.queue=w,Am($m.bind(null,p,w,s),[s]),p.flags|=2048,pl(9,Cm.bind(null,p,w,i,r),void 0,null),i},useId:function(){var s=ns(),r=bt.identifierPrefix;if(at){var i=vs,p=ys;i=(p&~(1<<32-zt(p)-1)).toString(32)+i,r=":"+r+"R"+i,i=hl++,0<i&&(r+="H"+i.toString(32)),r+=":"}else i=Ky++,r=":"+r+"r"+i.toString(32)+":";return s.memoizedState=r},unstable_isNewReconciler:!1},Xy={readContext:wn,useCallback:Mm,useContext:wn,useEffect:Dc,useImperativeHandle:Fm,useInsertionEffect:Im,useLayoutEffect:Om,useMemo:_m,useReducer:_c,useRef:Pm,useState:function(){return _c(ml)},useDebugValue:Bc,useDeferredValue:function(s){var r=Nn();return Um(r,xt.memoizedState,s)},useTransition:function(){var s=_c(ml)[0],r=Nn().memoizedState;return[s,r]},useMutableSource:wm,useSyncExternalStore:Nm,useId:Dm,unstable_isNewReconciler:!1},Zy={readContext:wn,useCallback:Mm,useContext:wn,useEffect:Dc,useImperativeHandle:Fm,useInsertionEffect:Im,useLayoutEffect:Om,useMemo:_m,useReducer:Uc,useRef:Pm,useState:function(){return Uc(ml)},useDebugValue:Bc,useDeferredValue:function(s){var r=Nn();return xt===null?r.memoizedState=s:Um(r,xt.memoizedState,s)},useTransition:function(){var s=Uc(ml)[0],r=Nn().memoizedState;return[s,r]},useMutableSource:wm,useSyncExternalStore:Nm,useId:Dm,unstable_isNewReconciler:!1};function Wn(s,r){if(s&&s.defaultProps){r=W({},r),s=s.defaultProps;for(var i in s)r[i]===void 0&&(r[i]=s[i]);return r}return r}function qc(s,r,i,p){r=s.memoizedState,i=i(p,r),i=i==null?r:W({},r,i),s.memoizedState=i,s.lanes===0&&(s.updateQueue.baseState=i)}var To={isMounted:function(s){return(s=s._reactInternals)?yn(s)===s:!1},enqueueSetState:function(s,r,i){s=s._reactInternals;var p=Ut(),j=Zs(s),w=bs(p,j);w.payload=r,i!=null&&(w.callback=i),r=Vs(s,w,j),r!==null&&(Gn(r,s,j,p),vo(r,s,j))},enqueueReplaceState:function(s,r,i){s=s._reactInternals;var p=Ut(),j=Zs(s),w=bs(p,j);w.tag=1,w.payload=r,i!=null&&(w.callback=i),r=Vs(s,w,j),r!==null&&(Gn(r,s,j,p),vo(r,s,j))},enqueueForceUpdate:function(s,r){s=s._reactInternals;var i=Ut(),p=Zs(s),j=bs(i,p);j.tag=2,r!=null&&(j.callback=r),r=Vs(s,j,p),r!==null&&(Gn(r,s,p,i),vo(r,s,p))}};function zm(s,r,i,p,j,w,T){return s=s.stateNode,typeof s.shouldComponentUpdate=="function"?s.shouldComponentUpdate(p,w,T):r.prototype&&r.prototype.isPureReactComponent?!el(i,p)||!el(j,w):!0}function Hm(s,r,i){var p=!1,j=Gs,w=r.contextType;return typeof w=="object"&&w!==null?w=wn(w):(j=Gt(r)?Na:Pt.current,p=r.contextTypes,w=(p=p!=null)?cr(s,j):Gs),r=new r(i,w),s.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=To,s.stateNode=r,r._reactInternals=s,p&&(s=s.stateNode,s.__reactInternalMemoizedUnmaskedChildContext=j,s.__reactInternalMemoizedMaskedChildContext=w),r}function Gm(s,r,i,p){s=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(i,p),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(i,p),r.state!==s&&To.enqueueReplaceState(r,r.state,null)}function Wc(s,r,i,p){var j=s.stateNode;j.props=i,j.state=s.memoizedState,j.refs={},Ec(s);var w=r.contextType;typeof w=="object"&&w!==null?j.context=wn(w):(w=Gt(r)?Na:Pt.current,j.context=cr(s,w)),j.state=s.memoizedState,w=r.getDerivedStateFromProps,typeof w=="function"&&(qc(s,r,w,i),j.state=s.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof j.getSnapshotBeforeUpdate=="function"||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(r=j.state,typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount(),r!==j.state&&To.enqueueReplaceState(j,j.state,null),ko(s,i,j,p),j.state=s.memoizedState),typeof j.componentDidMount=="function"&&(s.flags|=4194308)}function xr(s,r){try{var i="",p=r;do i+=Se(p),p=p.return;while(p);var j=i}catch(w){j=`
|
|
39
|
+
Error generating stack: `+w.message+`
|
|
40
|
+
`+w.stack}return{value:s,source:r,stack:j,digest:null}}function zc(s,r,i){return{value:s,source:null,stack:i??null,digest:r??null}}function Hc(s,r){try{console.error(r.value)}catch(i){setTimeout(function(){throw i})}}var ev=typeof WeakMap=="function"?WeakMap:Map;function Km(s,r,i){i=bs(-1,i),i.tag=3,i.payload={element:null};var p=r.value;return i.callback=function(){Lo||(Lo=!0,lu=p),Hc(s,r)},i}function Ym(s,r,i){i=bs(-1,i),i.tag=3;var p=s.type.getDerivedStateFromError;if(typeof p=="function"){var j=r.value;i.payload=function(){return p(j)},i.callback=function(){Hc(s,r)}}var w=s.stateNode;return w!==null&&typeof w.componentDidCatch=="function"&&(i.callback=function(){Hc(s,r),typeof p!="function"&&(Js===null?Js=new Set([this]):Js.add(this));var T=r.stack;this.componentDidCatch(r.value,{componentStack:T!==null?T:""})}),i}function Vm(s,r,i){var p=s.pingCache;if(p===null){p=s.pingCache=new ev;var j=new Set;p.set(r,j)}else j=p.get(r),j===void 0&&(j=new Set,p.set(r,j));j.has(i)||(j.add(i),s=pv.bind(null,s,r,i),r.then(s,s))}function Qm(s){do{var r;if((r=s.tag===13)&&(r=s.memoizedState,r=r!==null?r.dehydrated!==null:!0),r)return s;s=s.return}while(s!==null);return null}function Jm(s,r,i,p,j){return(s.mode&1)===0?(s===r?s.flags|=65536:(s.flags|=128,i.flags|=131072,i.flags&=-52805,i.tag===1&&(i.alternate===null?i.tag=17:(r=bs(-1,1),r.tag=2,Vs(i,r,1))),i.lanes|=1),s):(s.flags|=65536,s.lanes=j,s)}var tv=C.ReactCurrentOwner,Kt=!1;function _t(s,r,i,p){r.child=s===null?xm(r,null,i,p):mr(r,s.child,i,p)}function Xm(s,r,i,p,j){i=i.render;var w=r.ref;return fr(r,j),p=Fc(s,r,i,p,w,j),i=Mc(),s!==null&&!Kt?(r.updateQueue=s.updateQueue,r.flags&=-2053,s.lanes&=~j,ws(s,r,j)):(at&&i&&yc(r),r.flags|=1,_t(s,r,p,j),r.child)}function Zm(s,r,i,p,j){if(s===null){var w=i.type;return typeof w=="function"&&!mu(w)&&w.defaultProps===void 0&&i.compare===null&&i.defaultProps===void 0?(r.tag=15,r.type=w,ep(s,r,w,p,j)):(s=Bo(i.type,null,p,r,r.mode,j),s.ref=r.ref,s.return=r,r.child=s)}if(w=s.child,(s.lanes&j)===0){var T=w.memoizedProps;if(i=i.compare,i=i!==null?i:el,i(T,p)&&s.ref===r.ref)return ws(s,r,j)}return r.flags|=1,s=ta(w,p),s.ref=r.ref,s.return=r,r.child=s}function ep(s,r,i,p,j){if(s!==null){var w=s.memoizedProps;if(el(w,p)&&s.ref===r.ref)if(Kt=!1,r.pendingProps=p=w,(s.lanes&j)!==0)(s.flags&131072)!==0&&(Kt=!0);else return r.lanes=s.lanes,ws(s,r,j)}return Gc(s,r,i,p,j)}function tp(s,r,i){var p=r.pendingProps,j=p.children,w=s!==null?s.memoizedState:null;if(p.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},Qe(yr,un),un|=i;else{if((i&1073741824)===0)return s=w!==null?w.baseLanes|i:i,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:s,cachePool:null,transitions:null},r.updateQueue=null,Qe(yr,un),un|=s,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},p=w!==null?w.baseLanes:i,Qe(yr,un),un|=p}else w!==null?(p=w.baseLanes|i,r.memoizedState=null):p=i,Qe(yr,un),un|=p;return _t(s,r,j,i),r.child}function np(s,r){var i=r.ref;(s===null&&i!==null||s!==null&&s.ref!==i)&&(r.flags|=512,r.flags|=2097152)}function Gc(s,r,i,p,j){var w=Gt(i)?Na:Pt.current;return w=cr(r,w),fr(r,j),i=Fc(s,r,i,p,w,j),p=Mc(),s!==null&&!Kt?(r.updateQueue=s.updateQueue,r.flags&=-2053,s.lanes&=~j,ws(s,r,j)):(at&&p&&yc(r),r.flags|=1,_t(s,r,i,j),r.child)}function sp(s,r,i,p,j){if(Gt(i)){var w=!0;ho(r)}else w=!1;if(fr(r,j),r.stateNode===null)Ro(s,r),Hm(r,i,p),Wc(r,i,p,j),p=!0;else if(s===null){var T=r.stateNode,F=r.memoizedProps;T.props=F;var q=T.context,J=i.contextType;typeof J=="object"&&J!==null?J=wn(J):(J=Gt(i)?Na:Pt.current,J=cr(r,J));var ae=i.getDerivedStateFromProps,oe=typeof ae=="function"||typeof T.getSnapshotBeforeUpdate=="function";oe||typeof T.UNSAFE_componentWillReceiveProps!="function"&&typeof T.componentWillReceiveProps!="function"||(F!==p||q!==J)&&Gm(r,T,p,J),Ys=!1;var se=r.memoizedState;T.state=se,ko(r,p,T,j),q=r.memoizedState,F!==p||se!==q||Ht.current||Ys?(typeof ae=="function"&&(qc(r,i,ae,p),q=r.memoizedState),(F=Ys||zm(r,i,F,p,se,q,J))?(oe||typeof T.UNSAFE_componentWillMount!="function"&&typeof T.componentWillMount!="function"||(typeof T.componentWillMount=="function"&&T.componentWillMount(),typeof T.UNSAFE_componentWillMount=="function"&&T.UNSAFE_componentWillMount()),typeof T.componentDidMount=="function"&&(r.flags|=4194308)):(typeof T.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=p,r.memoizedState=q),T.props=p,T.state=q,T.context=J,p=F):(typeof T.componentDidMount=="function"&&(r.flags|=4194308),p=!1)}else{T=r.stateNode,ym(s,r),F=r.memoizedProps,J=r.type===r.elementType?F:Wn(r.type,F),T.props=J,oe=r.pendingProps,se=T.context,q=i.contextType,typeof q=="object"&&q!==null?q=wn(q):(q=Gt(i)?Na:Pt.current,q=cr(r,q));var fe=i.getDerivedStateFromProps;(ae=typeof fe=="function"||typeof T.getSnapshotBeforeUpdate=="function")||typeof T.UNSAFE_componentWillReceiveProps!="function"&&typeof T.componentWillReceiveProps!="function"||(F!==oe||se!==q)&&Gm(r,T,p,q),Ys=!1,se=r.memoizedState,T.state=se,ko(r,p,T,j);var ye=r.memoizedState;F!==oe||se!==ye||Ht.current||Ys?(typeof fe=="function"&&(qc(r,i,fe,p),ye=r.memoizedState),(J=Ys||zm(r,i,J,p,se,ye,q)||!1)?(ae||typeof T.UNSAFE_componentWillUpdate!="function"&&typeof T.componentWillUpdate!="function"||(typeof T.componentWillUpdate=="function"&&T.componentWillUpdate(p,ye,q),typeof T.UNSAFE_componentWillUpdate=="function"&&T.UNSAFE_componentWillUpdate(p,ye,q)),typeof T.componentDidUpdate=="function"&&(r.flags|=4),typeof T.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof T.componentDidUpdate!="function"||F===s.memoizedProps&&se===s.memoizedState||(r.flags|=4),typeof T.getSnapshotBeforeUpdate!="function"||F===s.memoizedProps&&se===s.memoizedState||(r.flags|=1024),r.memoizedProps=p,r.memoizedState=ye),T.props=p,T.state=ye,T.context=q,p=J):(typeof T.componentDidUpdate!="function"||F===s.memoizedProps&&se===s.memoizedState||(r.flags|=4),typeof T.getSnapshotBeforeUpdate!="function"||F===s.memoizedProps&&se===s.memoizedState||(r.flags|=1024),p=!1)}return Kc(s,r,i,p,w,j)}function Kc(s,r,i,p,j,w){np(s,r);var T=(r.flags&128)!==0;if(!p&&!T)return j&&im(r,i,!1),ws(s,r,w);p=r.stateNode,tv.current=r;var F=T&&typeof i.getDerivedStateFromError!="function"?null:p.render();return r.flags|=1,s!==null&&T?(r.child=mr(r,s.child,null,w),r.child=mr(r,null,F,w)):_t(s,r,F,w),r.memoizedState=p.state,j&&im(r,i,!0),r.child}function ap(s){var r=s.stateNode;r.pendingContext?lm(s,r.pendingContext,r.pendingContext!==r.context):r.context&&lm(s,r.context,!1),Rc(s,r.containerInfo)}function rp(s,r,i,p,j){return hr(),wc(j),r.flags|=256,_t(s,r,i,p),r.child}var Yc={dehydrated:null,treeContext:null,retryLane:0};function Vc(s){return{baseLanes:s,cachePool:null,transitions:null}}function lp(s,r,i){var p=r.pendingProps,j=ot.current,w=!1,T=(r.flags&128)!==0,F;if((F=T)||(F=s!==null&&s.memoizedState===null?!1:(j&2)!==0),F?(w=!0,r.flags&=-129):(s===null||s.memoizedState!==null)&&(j|=1),Qe(ot,j&1),s===null)return bc(r),s=r.memoizedState,s!==null&&(s=s.dehydrated,s!==null)?((r.mode&1)===0?r.lanes=1:s.data==="$!"?r.lanes=8:r.lanes=1073741824,null):(T=p.children,s=p.fallback,w?(p=r.mode,w=r.child,T={mode:"hidden",children:T},(p&1)===0&&w!==null?(w.childLanes=0,w.pendingProps=T):w=qo(T,p,0,null),s=Oa(s,p,i,null),w.return=r,s.return=r,w.sibling=s,r.child=w,r.child.memoizedState=Vc(i),r.memoizedState=Yc,s):Qc(r,T));if(j=s.memoizedState,j!==null&&(F=j.dehydrated,F!==null))return nv(s,r,T,p,F,j,i);if(w){w=p.fallback,T=r.mode,j=s.child,F=j.sibling;var q={mode:"hidden",children:p.children};return(T&1)===0&&r.child!==j?(p=r.child,p.childLanes=0,p.pendingProps=q,r.deletions=null):(p=ta(j,q),p.subtreeFlags=j.subtreeFlags&14680064),F!==null?w=ta(F,w):(w=Oa(w,T,i,null),w.flags|=2),w.return=r,p.return=r,p.sibling=w,r.child=p,p=w,w=r.child,T=s.child.memoizedState,T=T===null?Vc(i):{baseLanes:T.baseLanes|i,cachePool:null,transitions:T.transitions},w.memoizedState=T,w.childLanes=s.childLanes&~i,r.memoizedState=Yc,p}return w=s.child,s=w.sibling,p=ta(w,{mode:"visible",children:p.children}),(r.mode&1)===0&&(p.lanes=i),p.return=r,p.sibling=null,s!==null&&(i=r.deletions,i===null?(r.deletions=[s],r.flags|=16):i.push(s)),r.child=p,r.memoizedState=null,p}function Qc(s,r){return r=qo({mode:"visible",children:r},s.mode,0,null),r.return=s,s.child=r}function Eo(s,r,i,p){return p!==null&&wc(p),mr(r,s.child,null,i),s=Qc(r,r.pendingProps.children),s.flags|=2,r.memoizedState=null,s}function nv(s,r,i,p,j,w,T){if(i)return r.flags&256?(r.flags&=-257,p=zc(Error(a(422))),Eo(s,r,T,p)):r.memoizedState!==null?(r.child=s.child,r.flags|=128,null):(w=p.fallback,j=r.mode,p=qo({mode:"visible",children:p.children},j,0,null),w=Oa(w,j,T,null),w.flags|=2,p.return=r,w.return=r,p.sibling=w,r.child=p,(r.mode&1)!==0&&mr(r,s.child,null,T),r.child.memoizedState=Vc(T),r.memoizedState=Yc,w);if((r.mode&1)===0)return Eo(s,r,T,null);if(j.data==="$!"){if(p=j.nextSibling&&j.nextSibling.dataset,p)var F=p.dgst;return p=F,w=Error(a(419)),p=zc(w,p,void 0),Eo(s,r,T,p)}if(F=(T&s.childLanes)!==0,Kt||F){if(p=bt,p!==null){switch(T&-T){case 4:j=2;break;case 16:j=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:j=32;break;case 536870912:j=268435456;break;default:j=0}j=(j&(p.suspendedLanes|T))!==0?0:j,j!==0&&j!==w.retryLane&&(w.retryLane=j,ks(s,j),Gn(p,s,j,-1))}return hu(),p=zc(Error(a(421))),Eo(s,r,T,p)}return j.data==="$?"?(r.flags|=128,r.child=s.child,r=fv.bind(null,s),j._reactRetry=r,null):(s=w.treeContext,cn=zs(j.nextSibling),on=r,at=!0,qn=null,s!==null&&(kn[bn++]=ys,kn[bn++]=vs,kn[bn++]=Sa,ys=s.id,vs=s.overflow,Sa=r),r=Qc(r,p.children),r.flags|=4096,r)}function op(s,r,i){s.lanes|=r;var p=s.alternate;p!==null&&(p.lanes|=r),$c(s.return,r,i)}function Jc(s,r,i,p,j){var w=s.memoizedState;w===null?s.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:p,tail:i,tailMode:j}:(w.isBackwards=r,w.rendering=null,w.renderingStartTime=0,w.last=p,w.tail=i,w.tailMode=j)}function ip(s,r,i){var p=r.pendingProps,j=p.revealOrder,w=p.tail;if(_t(s,r,p.children,i),p=ot.current,(p&2)!==0)p=p&1|2,r.flags|=128;else{if(s!==null&&(s.flags&128)!==0)e:for(s=r.child;s!==null;){if(s.tag===13)s.memoizedState!==null&&op(s,i,r);else if(s.tag===19)op(s,i,r);else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===r)break e;for(;s.sibling===null;){if(s.return===null||s.return===r)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}p&=1}if(Qe(ot,p),(r.mode&1)===0)r.memoizedState=null;else switch(j){case"forwards":for(i=r.child,j=null;i!==null;)s=i.alternate,s!==null&&bo(s)===null&&(j=i),i=i.sibling;i=j,i===null?(j=r.child,r.child=null):(j=i.sibling,i.sibling=null),Jc(r,!1,j,i,w);break;case"backwards":for(i=null,j=r.child,r.child=null;j!==null;){if(s=j.alternate,s!==null&&bo(s)===null){r.child=j;break}s=j.sibling,j.sibling=i,i=j,j=s}Jc(r,!0,i,null,w);break;case"together":Jc(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function Ro(s,r){(r.mode&1)===0&&s!==null&&(s.alternate=null,r.alternate=null,r.flags|=2)}function ws(s,r,i){if(s!==null&&(r.dependencies=s.dependencies),Ra|=r.lanes,(i&r.childLanes)===0)return null;if(s!==null&&r.child!==s.child)throw Error(a(153));if(r.child!==null){for(s=r.child,i=ta(s,s.pendingProps),r.child=i,i.return=r;s.sibling!==null;)s=s.sibling,i=i.sibling=ta(s,s.pendingProps),i.return=r;i.sibling=null}return r.child}function sv(s,r,i){switch(r.tag){case 3:ap(r),hr();break;case 5:bm(r);break;case 1:Gt(r.type)&&ho(r);break;case 4:Rc(r,r.stateNode.containerInfo);break;case 10:var p=r.type._context,j=r.memoizedProps.value;Qe(jo,p._currentValue),p._currentValue=j;break;case 13:if(p=r.memoizedState,p!==null)return p.dehydrated!==null?(Qe(ot,ot.current&1),r.flags|=128,null):(i&r.child.childLanes)!==0?lp(s,r,i):(Qe(ot,ot.current&1),s=ws(s,r,i),s!==null?s.sibling:null);Qe(ot,ot.current&1);break;case 19:if(p=(i&r.childLanes)!==0,(s.flags&128)!==0){if(p)return ip(s,r,i);r.flags|=128}if(j=r.memoizedState,j!==null&&(j.rendering=null,j.tail=null,j.lastEffect=null),Qe(ot,ot.current),p)break;return null;case 22:case 23:return r.lanes=0,tp(s,r,i)}return ws(s,r,i)}var cp,Xc,up,dp;cp=function(s,r){for(var i=r.child;i!==null;){if(i.tag===5||i.tag===6)s.appendChild(i.stateNode);else if(i.tag!==4&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===r)break;for(;i.sibling===null;){if(i.return===null||i.return===r)return;i=i.return}i.sibling.return=i.return,i=i.sibling}},Xc=function(){},up=function(s,r,i,p){var j=s.memoizedProps;if(j!==p){s=r.stateNode,Ta(ts.current);var w=null;switch(i){case"input":j=Be(s,j),p=Be(s,p),w=[];break;case"select":j=W({},j,{value:void 0}),p=W({},p,{value:void 0}),w=[];break;case"textarea":j=is(s,j),p=is(s,p),w=[];break;default:typeof j.onClick!="function"&&typeof p.onClick=="function"&&(s.onclick=io)}hs(i,p);var T;i=null;for(J in j)if(!p.hasOwnProperty(J)&&j.hasOwnProperty(J)&&j[J]!=null)if(J==="style"){var F=j[J];for(T in F)F.hasOwnProperty(T)&&(i||(i={}),i[T]="")}else J!=="dangerouslySetInnerHTML"&&J!=="children"&&J!=="suppressContentEditableWarning"&&J!=="suppressHydrationWarning"&&J!=="autoFocus"&&(o.hasOwnProperty(J)?w||(w=[]):(w=w||[]).push(J,null));for(J in p){var q=p[J];if(F=j!=null?j[J]:void 0,p.hasOwnProperty(J)&&q!==F&&(q!=null||F!=null))if(J==="style")if(F){for(T in F)!F.hasOwnProperty(T)||q&&q.hasOwnProperty(T)||(i||(i={}),i[T]="");for(T in q)q.hasOwnProperty(T)&&F[T]!==q[T]&&(i||(i={}),i[T]=q[T])}else i||(w||(w=[]),w.push(J,i)),i=q;else J==="dangerouslySetInnerHTML"?(q=q?q.__html:void 0,F=F?F.__html:void 0,q!=null&&F!==q&&(w=w||[]).push(J,q)):J==="children"?typeof q!="string"&&typeof q!="number"||(w=w||[]).push(J,""+q):J!=="suppressContentEditableWarning"&&J!=="suppressHydrationWarning"&&(o.hasOwnProperty(J)?(q!=null&&J==="onScroll"&&Xe("scroll",s),w||F===q||(w=[])):(w=w||[]).push(J,q))}i&&(w=w||[]).push("style",i);var J=w;(r.updateQueue=J)&&(r.flags|=4)}},dp=function(s,r,i,p){i!==p&&(r.flags|=4)};function fl(s,r){if(!at)switch(s.tailMode){case"hidden":r=s.tail;for(var i=null;r!==null;)r.alternate!==null&&(i=r),r=r.sibling;i===null?s.tail=null:i.sibling=null;break;case"collapsed":i=s.tail;for(var p=null;i!==null;)i.alternate!==null&&(p=i),i=i.sibling;p===null?r||s.tail===null?s.tail=null:s.tail.sibling=null:p.sibling=null}}function It(s){var r=s.alternate!==null&&s.alternate.child===s.child,i=0,p=0;if(r)for(var j=s.child;j!==null;)i|=j.lanes|j.childLanes,p|=j.subtreeFlags&14680064,p|=j.flags&14680064,j.return=s,j=j.sibling;else for(j=s.child;j!==null;)i|=j.lanes|j.childLanes,p|=j.subtreeFlags,p|=j.flags,j.return=s,j=j.sibling;return s.subtreeFlags|=p,s.childLanes=i,r}function av(s,r,i){var p=r.pendingProps;switch(vc(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return It(r),null;case 1:return Gt(r.type)&&uo(),It(r),null;case 3:return p=r.stateNode,gr(),Ze(Ht),Ze(Pt),Ic(),p.pendingContext&&(p.context=p.pendingContext,p.pendingContext=null),(s===null||s.child===null)&&(go(r)?r.flags|=4:s===null||s.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,qn!==null&&(cu(qn),qn=null))),Xc(s,r),It(r),null;case 5:Pc(r);var j=Ta(ul.current);if(i=r.type,s!==null&&r.stateNode!=null)up(s,r,i,p,j),s.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!p){if(r.stateNode===null)throw Error(a(166));return It(r),null}if(s=Ta(ts.current),go(r)){p=r.stateNode,i=r.type;var w=r.memoizedProps;switch(p[es]=r,p[rl]=w,s=(r.mode&1)!==0,i){case"dialog":Xe("cancel",p),Xe("close",p);break;case"iframe":case"object":case"embed":Xe("load",p);break;case"video":case"audio":for(j=0;j<nl.length;j++)Xe(nl[j],p);break;case"source":Xe("error",p);break;case"img":case"image":case"link":Xe("error",p),Xe("load",p);break;case"details":Xe("toggle",p);break;case"input":We(p,w),Xe("invalid",p);break;case"select":p._wrapperState={wasMultiple:!!w.multiple},Xe("invalid",p);break;case"textarea":Bt(p,w),Xe("invalid",p)}hs(i,w),j=null;for(var T in w)if(w.hasOwnProperty(T)){var F=w[T];T==="children"?typeof F=="string"?p.textContent!==F&&(w.suppressHydrationWarning!==!0&&oo(p.textContent,F,s),j=["children",F]):typeof F=="number"&&p.textContent!==""+F&&(w.suppressHydrationWarning!==!0&&oo(p.textContent,F,s),j=["children",""+F]):o.hasOwnProperty(T)&&F!=null&&T==="onScroll"&&Xe("scroll",p)}switch(i){case"input":Ve(p),Lt(p,w,!0);break;case"textarea":Ve(p),yt(p);break;case"select":case"option":break;default:typeof w.onClick=="function"&&(p.onclick=io)}p=j,r.updateQueue=p,p!==null&&(r.flags|=4)}else{T=j.nodeType===9?j:j.ownerDocument,s==="http://www.w3.org/1999/xhtml"&&(s=Ls(i)),s==="http://www.w3.org/1999/xhtml"?i==="script"?(s=T.createElement("div"),s.innerHTML="<script><\/script>",s=s.removeChild(s.firstChild)):typeof p.is=="string"?s=T.createElement(i,{is:p.is}):(s=T.createElement(i),i==="select"&&(T=s,p.multiple?T.multiple=!0:p.size&&(T.size=p.size))):s=T.createElementNS(s,i),s[es]=r,s[rl]=p,cp(s,r,!1,!1),r.stateNode=s;e:{switch(T=Ft(i,p),i){case"dialog":Xe("cancel",s),Xe("close",s),j=p;break;case"iframe":case"object":case"embed":Xe("load",s),j=p;break;case"video":case"audio":for(j=0;j<nl.length;j++)Xe(nl[j],s);j=p;break;case"source":Xe("error",s),j=p;break;case"img":case"image":case"link":Xe("error",s),Xe("load",s),j=p;break;case"details":Xe("toggle",s),j=p;break;case"input":We(s,p),j=Be(s,p),Xe("invalid",s);break;case"option":j=p;break;case"select":s._wrapperState={wasMultiple:!!p.multiple},j=W({},p,{value:void 0}),Xe("invalid",s);break;case"textarea":Bt(s,p),j=is(s,p),Xe("invalid",s);break;default:j=p}hs(i,j),F=j;for(w in F)if(F.hasOwnProperty(w)){var q=F[w];w==="style"?st(s,q):w==="dangerouslySetInnerHTML"?(q=q?q.__html:void 0,q!=null&&us(s,q)):w==="children"?typeof q=="string"?(i!=="textarea"||q!=="")&&nt(s,q):typeof q=="number"&&nt(s,""+q):w!=="suppressContentEditableWarning"&&w!=="suppressHydrationWarning"&&w!=="autoFocus"&&(o.hasOwnProperty(w)?q!=null&&w==="onScroll"&&Xe("scroll",s):q!=null&&E(s,w,q,T))}switch(i){case"input":Ve(s),Lt(s,p,!1);break;case"textarea":Ve(s),yt(s);break;case"option":p.value!=null&&s.setAttribute("value",""+ie(p.value));break;case"select":s.multiple=!!p.multiple,w=p.value,w!=null?Oe(s,!!p.multiple,w,!1):p.defaultValue!=null&&Oe(s,!!p.multiple,p.defaultValue,!0);break;default:typeof j.onClick=="function"&&(s.onclick=io)}switch(i){case"button":case"input":case"select":case"textarea":p=!!p.autoFocus;break e;case"img":p=!0;break e;default:p=!1}}p&&(r.flags|=4)}r.ref!==null&&(r.flags|=512,r.flags|=2097152)}return It(r),null;case 6:if(s&&r.stateNode!=null)dp(s,r,s.memoizedProps,p);else{if(typeof p!="string"&&r.stateNode===null)throw Error(a(166));if(i=Ta(ul.current),Ta(ts.current),go(r)){if(p=r.stateNode,i=r.memoizedProps,p[es]=r,(w=p.nodeValue!==i)&&(s=on,s!==null))switch(s.tag){case 3:oo(p.nodeValue,i,(s.mode&1)!==0);break;case 5:s.memoizedProps.suppressHydrationWarning!==!0&&oo(p.nodeValue,i,(s.mode&1)!==0)}w&&(r.flags|=4)}else p=(i.nodeType===9?i:i.ownerDocument).createTextNode(p),p[es]=r,r.stateNode=p}return It(r),null;case 13:if(Ze(ot),p=r.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(at&&cn!==null&&(r.mode&1)!==0&&(r.flags&128)===0)pm(),hr(),r.flags|=98560,w=!1;else if(w=go(r),p!==null&&p.dehydrated!==null){if(s===null){if(!w)throw Error(a(318));if(w=r.memoizedState,w=w!==null?w.dehydrated:null,!w)throw Error(a(317));w[es]=r}else hr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;It(r),w=!1}else qn!==null&&(cu(qn),qn=null),w=!0;if(!w)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=i,r):(p=p!==null,p!==(s!==null&&s.memoizedState!==null)&&p&&(r.child.flags|=8192,(r.mode&1)!==0&&(s===null||(ot.current&1)!==0?jt===0&&(jt=3):hu())),r.updateQueue!==null&&(r.flags|=4),It(r),null);case 4:return gr(),Xc(s,r),s===null&&sl(r.stateNode.containerInfo),It(r),null;case 10:return Cc(r.type._context),It(r),null;case 17:return Gt(r.type)&&uo(),It(r),null;case 19:if(Ze(ot),w=r.memoizedState,w===null)return It(r),null;if(p=(r.flags&128)!==0,T=w.rendering,T===null)if(p)fl(w,!1);else{if(jt!==0||s!==null&&(s.flags&128)!==0)for(s=r.child;s!==null;){if(T=bo(s),T!==null){for(r.flags|=128,fl(w,!1),p=T.updateQueue,p!==null&&(r.updateQueue=p,r.flags|=4),r.subtreeFlags=0,p=i,i=r.child;i!==null;)w=i,s=p,w.flags&=14680066,T=w.alternate,T===null?(w.childLanes=0,w.lanes=s,w.child=null,w.subtreeFlags=0,w.memoizedProps=null,w.memoizedState=null,w.updateQueue=null,w.dependencies=null,w.stateNode=null):(w.childLanes=T.childLanes,w.lanes=T.lanes,w.child=T.child,w.subtreeFlags=0,w.deletions=null,w.memoizedProps=T.memoizedProps,w.memoizedState=T.memoizedState,w.updateQueue=T.updateQueue,w.type=T.type,s=T.dependencies,w.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext}),i=i.sibling;return Qe(ot,ot.current&1|2),r.child}s=s.sibling}w.tail!==null&&_e()>vr&&(r.flags|=128,p=!0,fl(w,!1),r.lanes=4194304)}else{if(!p)if(s=bo(T),s!==null){if(r.flags|=128,p=!0,i=s.updateQueue,i!==null&&(r.updateQueue=i,r.flags|=4),fl(w,!0),w.tail===null&&w.tailMode==="hidden"&&!T.alternate&&!at)return It(r),null}else 2*_e()-w.renderingStartTime>vr&&i!==1073741824&&(r.flags|=128,p=!0,fl(w,!1),r.lanes=4194304);w.isBackwards?(T.sibling=r.child,r.child=T):(i=w.last,i!==null?i.sibling=T:r.child=T,w.last=T)}return w.tail!==null?(r=w.tail,w.rendering=r,w.tail=r.sibling,w.renderingStartTime=_e(),r.sibling=null,i=ot.current,Qe(ot,p?i&1|2:i&1),r):(It(r),null);case 22:case 23:return du(),p=r.memoizedState!==null,s!==null&&s.memoizedState!==null!==p&&(r.flags|=8192),p&&(r.mode&1)!==0?(un&1073741824)!==0&&(It(r),r.subtreeFlags&6&&(r.flags|=8192)):It(r),null;case 24:return null;case 25:return null}throw Error(a(156,r.tag))}function rv(s,r){switch(vc(r),r.tag){case 1:return Gt(r.type)&&uo(),s=r.flags,s&65536?(r.flags=s&-65537|128,r):null;case 3:return gr(),Ze(Ht),Ze(Pt),Ic(),s=r.flags,(s&65536)!==0&&(s&128)===0?(r.flags=s&-65537|128,r):null;case 5:return Pc(r),null;case 13:if(Ze(ot),s=r.memoizedState,s!==null&&s.dehydrated!==null){if(r.alternate===null)throw Error(a(340));hr()}return s=r.flags,s&65536?(r.flags=s&-65537|128,r):null;case 19:return Ze(ot),null;case 4:return gr(),null;case 10:return Cc(r.type._context),null;case 22:case 23:return du(),null;case 24:return null;default:return null}}var Po=!1,Ot=!1,lv=typeof WeakSet=="function"?WeakSet:Set,je=null;function jr(s,r){var i=s.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(p){ct(s,r,p)}else i.current=null}function Zc(s,r,i){try{i()}catch(p){ct(s,r,p)}}var hp=!1;function ov(s,r){if(dc=Ql,s=zh(),sc(s)){if("selectionStart"in s)var i={start:s.selectionStart,end:s.selectionEnd};else e:{i=(i=s.ownerDocument)&&i.defaultView||window;var p=i.getSelection&&i.getSelection();if(p&&p.rangeCount!==0){i=p.anchorNode;var j=p.anchorOffset,w=p.focusNode;p=p.focusOffset;try{i.nodeType,w.nodeType}catch{i=null;break e}var T=0,F=-1,q=-1,J=0,ae=0,oe=s,se=null;t:for(;;){for(var fe;oe!==i||j!==0&&oe.nodeType!==3||(F=T+j),oe!==w||p!==0&&oe.nodeType!==3||(q=T+p),oe.nodeType===3&&(T+=oe.nodeValue.length),(fe=oe.firstChild)!==null;)se=oe,oe=fe;for(;;){if(oe===s)break t;if(se===i&&++J===j&&(F=T),se===w&&++ae===p&&(q=T),(fe=oe.nextSibling)!==null)break;oe=se,se=oe.parentNode}oe=fe}i=F===-1||q===-1?null:{start:F,end:q}}else i=null}i=i||{start:0,end:0}}else i=null;for(hc={focusedElem:s,selectionRange:i},Ql=!1,je=r;je!==null;)if(r=je,s=r.child,(r.subtreeFlags&1028)!==0&&s!==null)s.return=r,je=s;else for(;je!==null;){r=je;try{var ye=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(ye!==null){var ve=ye.memoizedProps,dt=ye.memoizedState,G=r.stateNode,z=G.getSnapshotBeforeUpdate(r.elementType===r.type?ve:Wn(r.type,ve),dt);G.__reactInternalSnapshotBeforeUpdate=z}break;case 3:var Y=r.stateNode.containerInfo;Y.nodeType===1?Y.textContent="":Y.nodeType===9&&Y.documentElement&&Y.removeChild(Y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(a(163))}}catch(ce){ct(r,r.return,ce)}if(s=r.sibling,s!==null){s.return=r.return,je=s;break}je=r.return}return ye=hp,hp=!1,ye}function gl(s,r,i){var p=r.updateQueue;if(p=p!==null?p.lastEffect:null,p!==null){var j=p=p.next;do{if((j.tag&s)===s){var w=j.destroy;j.destroy=void 0,w!==void 0&&Zc(r,i,w)}j=j.next}while(j!==p)}}function Ao(s,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&s)===s){var p=i.create;i.destroy=p()}i=i.next}while(i!==r)}}function eu(s){var r=s.ref;if(r!==null){var i=s.stateNode;switch(s.tag){case 5:s=i;break;default:s=i}typeof r=="function"?r(s):r.current=s}}function mp(s){var r=s.alternate;r!==null&&(s.alternate=null,mp(r)),s.child=null,s.deletions=null,s.sibling=null,s.tag===5&&(r=s.stateNode,r!==null&&(delete r[es],delete r[rl],delete r[gc],delete r[Wy],delete r[zy])),s.stateNode=null,s.return=null,s.dependencies=null,s.memoizedProps=null,s.memoizedState=null,s.pendingProps=null,s.stateNode=null,s.updateQueue=null}function pp(s){return s.tag===5||s.tag===3||s.tag===4}function fp(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||pp(s.return))return null;s=s.return}for(s.sibling.return=s.return,s=s.sibling;s.tag!==5&&s.tag!==6&&s.tag!==18;){if(s.flags&2||s.child===null||s.tag===4)continue e;s.child.return=s,s=s.child}if(!(s.flags&2))return s.stateNode}}function tu(s,r,i){var p=s.tag;if(p===5||p===6)s=s.stateNode,r?i.nodeType===8?i.parentNode.insertBefore(s,r):i.insertBefore(s,r):(i.nodeType===8?(r=i.parentNode,r.insertBefore(s,i)):(r=i,r.appendChild(s)),i=i._reactRootContainer,i!=null||r.onclick!==null||(r.onclick=io));else if(p!==4&&(s=s.child,s!==null))for(tu(s,r,i),s=s.sibling;s!==null;)tu(s,r,i),s=s.sibling}function nu(s,r,i){var p=s.tag;if(p===5||p===6)s=s.stateNode,r?i.insertBefore(s,r):i.appendChild(s);else if(p!==4&&(s=s.child,s!==null))for(nu(s,r,i),s=s.sibling;s!==null;)nu(s,r,i),s=s.sibling}var $t=null,zn=!1;function Qs(s,r,i){for(i=i.child;i!==null;)gp(s,r,i),i=i.sibling}function gp(s,r,i){if(Mt&&typeof Mt.onCommitFiberUnmount=="function")try{Mt.onCommitFiberUnmount(_s,i)}catch{}switch(i.tag){case 5:Ot||jr(i,r);case 6:var p=$t,j=zn;$t=null,Qs(s,r,i),$t=p,zn=j,$t!==null&&(zn?(s=$t,i=i.stateNode,s.nodeType===8?s.parentNode.removeChild(i):s.removeChild(i)):$t.removeChild(i.stateNode));break;case 18:$t!==null&&(zn?(s=$t,i=i.stateNode,s.nodeType===8?fc(s.parentNode,i):s.nodeType===1&&fc(s,i),Yr(s)):fc($t,i.stateNode));break;case 4:p=$t,j=zn,$t=i.stateNode.containerInfo,zn=!0,Qs(s,r,i),$t=p,zn=j;break;case 0:case 11:case 14:case 15:if(!Ot&&(p=i.updateQueue,p!==null&&(p=p.lastEffect,p!==null))){j=p=p.next;do{var w=j,T=w.destroy;w=w.tag,T!==void 0&&((w&2)!==0||(w&4)!==0)&&Zc(i,r,T),j=j.next}while(j!==p)}Qs(s,r,i);break;case 1:if(!Ot&&(jr(i,r),p=i.stateNode,typeof p.componentWillUnmount=="function"))try{p.props=i.memoizedProps,p.state=i.memoizedState,p.componentWillUnmount()}catch(F){ct(i,r,F)}Qs(s,r,i);break;case 21:Qs(s,r,i);break;case 22:i.mode&1?(Ot=(p=Ot)||i.memoizedState!==null,Qs(s,r,i),Ot=p):Qs(s,r,i);break;default:Qs(s,r,i)}}function xp(s){var r=s.updateQueue;if(r!==null){s.updateQueue=null;var i=s.stateNode;i===null&&(i=s.stateNode=new lv),r.forEach(function(p){var j=gv.bind(null,s,p);i.has(p)||(i.add(p),p.then(j,j))})}}function Hn(s,r){var i=r.deletions;if(i!==null)for(var p=0;p<i.length;p++){var j=i[p];try{var w=s,T=r,F=T;e:for(;F!==null;){switch(F.tag){case 5:$t=F.stateNode,zn=!1;break e;case 3:$t=F.stateNode.containerInfo,zn=!0;break e;case 4:$t=F.stateNode.containerInfo,zn=!0;break e}F=F.return}if($t===null)throw Error(a(160));gp(w,T,j),$t=null,zn=!1;var q=j.alternate;q!==null&&(q.return=null),j.return=null}catch(J){ct(j,r,J)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)jp(r,s),r=r.sibling}function jp(s,r){var i=s.alternate,p=s.flags;switch(s.tag){case 0:case 11:case 14:case 15:if(Hn(r,s),ss(s),p&4){try{gl(3,s,s.return),Ao(3,s)}catch(ve){ct(s,s.return,ve)}try{gl(5,s,s.return)}catch(ve){ct(s,s.return,ve)}}break;case 1:Hn(r,s),ss(s),p&512&&i!==null&&jr(i,i.return);break;case 5:if(Hn(r,s),ss(s),p&512&&i!==null&&jr(i,i.return),s.flags&32){var j=s.stateNode;try{nt(j,"")}catch(ve){ct(s,s.return,ve)}}if(p&4&&(j=s.stateNode,j!=null)){var w=s.memoizedProps,T=i!==null?i.memoizedProps:w,F=s.type,q=s.updateQueue;if(s.updateQueue=null,q!==null)try{F==="input"&&w.type==="radio"&&w.name!=null&&St(j,w),Ft(F,T);var J=Ft(F,w);for(T=0;T<q.length;T+=2){var ae=q[T],oe=q[T+1];ae==="style"?st(j,oe):ae==="dangerouslySetInnerHTML"?us(j,oe):ae==="children"?nt(j,oe):E(j,ae,oe,J)}switch(F){case"input":gt(j,w);break;case"textarea":cs(j,w);break;case"select":var se=j._wrapperState.wasMultiple;j._wrapperState.wasMultiple=!!w.multiple;var fe=w.value;fe!=null?Oe(j,!!w.multiple,fe,!1):se!==!!w.multiple&&(w.defaultValue!=null?Oe(j,!!w.multiple,w.defaultValue,!0):Oe(j,!!w.multiple,w.multiple?[]:"",!1))}j[rl]=w}catch(ve){ct(s,s.return,ve)}}break;case 6:if(Hn(r,s),ss(s),p&4){if(s.stateNode===null)throw Error(a(162));j=s.stateNode,w=s.memoizedProps;try{j.nodeValue=w}catch(ve){ct(s,s.return,ve)}}break;case 3:if(Hn(r,s),ss(s),p&4&&i!==null&&i.memoizedState.isDehydrated)try{Yr(r.containerInfo)}catch(ve){ct(s,s.return,ve)}break;case 4:Hn(r,s),ss(s);break;case 13:Hn(r,s),ss(s),j=s.child,j.flags&8192&&(w=j.memoizedState!==null,j.stateNode.isHidden=w,!w||j.alternate!==null&&j.alternate.memoizedState!==null||(ru=_e())),p&4&&xp(s);break;case 22:if(ae=i!==null&&i.memoizedState!==null,s.mode&1?(Ot=(J=Ot)||ae,Hn(r,s),Ot=J):Hn(r,s),ss(s),p&8192){if(J=s.memoizedState!==null,(s.stateNode.isHidden=J)&&!ae&&(s.mode&1)!==0)for(je=s,ae=s.child;ae!==null;){for(oe=je=ae;je!==null;){switch(se=je,fe=se.child,se.tag){case 0:case 11:case 14:case 15:gl(4,se,se.return);break;case 1:jr(se,se.return);var ye=se.stateNode;if(typeof ye.componentWillUnmount=="function"){p=se,i=se.return;try{r=p,ye.props=r.memoizedProps,ye.state=r.memoizedState,ye.componentWillUnmount()}catch(ve){ct(p,i,ve)}}break;case 5:jr(se,se.return);break;case 22:if(se.memoizedState!==null){kp(oe);continue}}fe!==null?(fe.return=se,je=fe):kp(oe)}ae=ae.sibling}e:for(ae=null,oe=s;;){if(oe.tag===5){if(ae===null){ae=oe;try{j=oe.stateNode,J?(w=j.style,typeof w.setProperty=="function"?w.setProperty("display","none","important"):w.display="none"):(F=oe.stateNode,q=oe.memoizedProps.style,T=q!=null&&q.hasOwnProperty("display")?q.display:null,F.style.display=An("display",T))}catch(ve){ct(s,s.return,ve)}}}else if(oe.tag===6){if(ae===null)try{oe.stateNode.nodeValue=J?"":oe.memoizedProps}catch(ve){ct(s,s.return,ve)}}else if((oe.tag!==22&&oe.tag!==23||oe.memoizedState===null||oe===s)&&oe.child!==null){oe.child.return=oe,oe=oe.child;continue}if(oe===s)break e;for(;oe.sibling===null;){if(oe.return===null||oe.return===s)break e;ae===oe&&(ae=null),oe=oe.return}ae===oe&&(ae=null),oe.sibling.return=oe.return,oe=oe.sibling}}break;case 19:Hn(r,s),ss(s),p&4&&xp(s);break;case 21:break;default:Hn(r,s),ss(s)}}function ss(s){var r=s.flags;if(r&2){try{e:{for(var i=s.return;i!==null;){if(pp(i)){var p=i;break e}i=i.return}throw Error(a(160))}switch(p.tag){case 5:var j=p.stateNode;p.flags&32&&(nt(j,""),p.flags&=-33);var w=fp(s);nu(s,w,j);break;case 3:case 4:var T=p.stateNode.containerInfo,F=fp(s);tu(s,F,T);break;default:throw Error(a(161))}}catch(q){ct(s,s.return,q)}s.flags&=-3}r&4096&&(s.flags&=-4097)}function iv(s,r,i){je=s,yp(s)}function yp(s,r,i){for(var p=(s.mode&1)!==0;je!==null;){var j=je,w=j.child;if(j.tag===22&&p){var T=j.memoizedState!==null||Po;if(!T){var F=j.alternate,q=F!==null&&F.memoizedState!==null||Ot;F=Po;var J=Ot;if(Po=T,(Ot=q)&&!J)for(je=j;je!==null;)T=je,q=T.child,T.tag===22&&T.memoizedState!==null?bp(j):q!==null?(q.return=T,je=q):bp(j);for(;w!==null;)je=w,yp(w),w=w.sibling;je=j,Po=F,Ot=J}vp(s)}else(j.subtreeFlags&8772)!==0&&w!==null?(w.return=j,je=w):vp(s)}}function vp(s){for(;je!==null;){var r=je;if((r.flags&8772)!==0){var i=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:Ot||Ao(5,r);break;case 1:var p=r.stateNode;if(r.flags&4&&!Ot)if(i===null)p.componentDidMount();else{var j=r.elementType===r.type?i.memoizedProps:Wn(r.type,i.memoizedProps);p.componentDidUpdate(j,i.memoizedState,p.__reactInternalSnapshotBeforeUpdate)}var w=r.updateQueue;w!==null&&km(r,w,p);break;case 3:var T=r.updateQueue;if(T!==null){if(i=null,r.child!==null)switch(r.child.tag){case 5:i=r.child.stateNode;break;case 1:i=r.child.stateNode}km(r,T,i)}break;case 5:var F=r.stateNode;if(i===null&&r.flags&4){i=F;var q=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":q.autoFocus&&i.focus();break;case"img":q.src&&(i.src=q.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(r.memoizedState===null){var J=r.alternate;if(J!==null){var ae=J.memoizedState;if(ae!==null){var oe=ae.dehydrated;oe!==null&&Yr(oe)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(a(163))}Ot||r.flags&512&&eu(r)}catch(se){ct(r,r.return,se)}}if(r===s){je=null;break}if(i=r.sibling,i!==null){i.return=r.return,je=i;break}je=r.return}}function kp(s){for(;je!==null;){var r=je;if(r===s){je=null;break}var i=r.sibling;if(i!==null){i.return=r.return,je=i;break}je=r.return}}function bp(s){for(;je!==null;){var r=je;try{switch(r.tag){case 0:case 11:case 15:var i=r.return;try{Ao(4,r)}catch(q){ct(r,i,q)}break;case 1:var p=r.stateNode;if(typeof p.componentDidMount=="function"){var j=r.return;try{p.componentDidMount()}catch(q){ct(r,j,q)}}var w=r.return;try{eu(r)}catch(q){ct(r,w,q)}break;case 5:var T=r.return;try{eu(r)}catch(q){ct(r,T,q)}}}catch(q){ct(r,r.return,q)}if(r===s){je=null;break}var F=r.sibling;if(F!==null){F.return=r.return,je=F;break}je=r.return}}var cv=Math.ceil,Io=C.ReactCurrentDispatcher,su=C.ReactCurrentOwner,Sn=C.ReactCurrentBatchConfig,He=0,bt=null,ft=null,Tt=0,un=0,yr=Hs(0),jt=0,xl=null,Ra=0,Oo=0,au=0,jl=null,Yt=null,ru=0,vr=1/0,Ns=null,Lo=!1,lu=null,Js=null,Fo=!1,Xs=null,Mo=0,yl=0,ou=null,_o=-1,Uo=0;function Ut(){return(He&6)!==0?_e():_o!==-1?_o:_o=_e()}function Zs(s){return(s.mode&1)===0?1:(He&2)!==0&&Tt!==0?Tt&-Tt:Gy.transition!==null?(Uo===0&&(Uo=va()),Uo):(s=Ye,s!==0||(s=window.event,s=s===void 0?16:Nh(s.type)),s)}function Gn(s,r,i,p){if(50<yl)throw yl=0,ou=null,Error(a(185));ka(s,i,p),((He&2)===0||s!==bt)&&(s===bt&&((He&2)===0&&(Oo|=i),jt===4&&ea(s,Tt)),Vt(s,p),i===1&&He===0&&(r.mode&1)===0&&(vr=_e()+500,mo&&Ks()))}function Vt(s,r){var i=s.callbackNode;Hi(s,r);var p=ya(s,s===bt?Tt:0);if(p===0)i!==null&&pt(i),s.callbackNode=null,s.callbackPriority=0;else if(r=p&-p,s.callbackPriority!==r){if(i!=null&&pt(i),r===1)s.tag===0?Hy(Np.bind(null,s)):cm(Np.bind(null,s)),By(function(){(He&6)===0&&Ks()}),i=null;else{switch(Kl(p)){case 1:i=Mn;break;case 4:i=Ms;break;case 16:i=gs;break;case 536870912:i=Ya;break;default:i=gs}i=Ap(i,wp.bind(null,s))}s.callbackPriority=r,s.callbackNode=i}}function wp(s,r){if(_o=-1,Uo=0,(He&6)!==0)throw Error(a(327));var i=s.callbackNode;if(kr()&&s.callbackNode!==i)return null;var p=ya(s,s===bt?Tt:0);if(p===0)return null;if((p&30)!==0||(p&s.expiredLanes)!==0||r)r=Do(s,p);else{r=p;var j=He;He|=2;var w=Cp();(bt!==s||Tt!==r)&&(Ns=null,vr=_e()+500,Aa(s,r));do try{hv();break}catch(F){Sp(s,F)}while(!0);Sc(),Io.current=w,He=j,ft!==null?r=0:(bt=null,Tt=0,r=jt)}if(r!==0){if(r===2&&(j=Qa(s),j!==0&&(p=j,r=iu(s,j))),r===1)throw i=xl,Aa(s,0),ea(s,p),Vt(s,_e()),i;if(r===6)ea(s,p);else{if(j=s.current.alternate,(p&30)===0&&!uv(j)&&(r=Do(s,p),r===2&&(w=Qa(s),w!==0&&(p=w,r=iu(s,w))),r===1))throw i=xl,Aa(s,0),ea(s,p),Vt(s,_e()),i;switch(s.finishedWork=j,s.finishedLanes=p,r){case 0:case 1:throw Error(a(345));case 2:Ia(s,Yt,Ns);break;case 3:if(ea(s,p),(p&130023424)===p&&(r=ru+500-_e(),10<r)){if(ya(s,0)!==0)break;if(j=s.suspendedLanes,(j&p)!==p){Ut(),s.pingedLanes|=s.suspendedLanes&j;break}s.timeoutHandle=pc(Ia.bind(null,s,Yt,Ns),r);break}Ia(s,Yt,Ns);break;case 4:if(ea(s,p),(p&4194240)===p)break;for(r=s.eventTimes,j=-1;0<p;){var T=31-zt(p);w=1<<T,T=r[T],T>j&&(j=T),p&=~w}if(p=j,p=_e()-p,p=(120>p?120:480>p?480:1080>p?1080:1920>p?1920:3e3>p?3e3:4320>p?4320:1960*cv(p/1960))-p,10<p){s.timeoutHandle=pc(Ia.bind(null,s,Yt,Ns),p);break}Ia(s,Yt,Ns);break;case 5:Ia(s,Yt,Ns);break;default:throw Error(a(329))}}}return Vt(s,_e()),s.callbackNode===i?wp.bind(null,s):null}function iu(s,r){var i=jl;return s.current.memoizedState.isDehydrated&&(Aa(s,r).flags|=256),s=Do(s,r),s!==2&&(r=Yt,Yt=i,r!==null&&cu(r)),s}function cu(s){Yt===null?Yt=s:Yt.push.apply(Yt,s)}function uv(s){for(var r=s;;){if(r.flags&16384){var i=r.updateQueue;if(i!==null&&(i=i.stores,i!==null))for(var p=0;p<i.length;p++){var j=i[p],w=j.getSnapshot;j=j.value;try{if(!Bn(w(),j))return!1}catch{return!1}}}if(i=r.child,r.subtreeFlags&16384&&i!==null)i.return=r,r=i;else{if(r===s)break;for(;r.sibling===null;){if(r.return===null||r.return===s)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function ea(s,r){for(r&=~au,r&=~Oo,s.suspendedLanes|=r,s.pingedLanes&=~r,s=s.expirationTimes;0<r;){var i=31-zt(r),p=1<<i;s[i]=-1,r&=~p}}function Np(s){if((He&6)!==0)throw Error(a(327));kr();var r=ya(s,0);if((r&1)===0)return Vt(s,_e()),null;var i=Do(s,r);if(s.tag!==0&&i===2){var p=Qa(s);p!==0&&(r=p,i=iu(s,p))}if(i===1)throw i=xl,Aa(s,0),ea(s,r),Vt(s,_e()),i;if(i===6)throw Error(a(345));return s.finishedWork=s.current.alternate,s.finishedLanes=r,Ia(s,Yt,Ns),Vt(s,_e()),null}function uu(s,r){var i=He;He|=1;try{return s(r)}finally{He=i,He===0&&(vr=_e()+500,mo&&Ks())}}function Pa(s){Xs!==null&&Xs.tag===0&&(He&6)===0&&kr();var r=He;He|=1;var i=Sn.transition,p=Ye;try{if(Sn.transition=null,Ye=1,s)return s()}finally{Ye=p,Sn.transition=i,He=r,(He&6)===0&&Ks()}}function du(){un=yr.current,Ze(yr)}function Aa(s,r){s.finishedWork=null,s.finishedLanes=0;var i=s.timeoutHandle;if(i!==-1&&(s.timeoutHandle=-1,Dy(i)),ft!==null)for(i=ft.return;i!==null;){var p=i;switch(vc(p),p.tag){case 1:p=p.type.childContextTypes,p!=null&&uo();break;case 3:gr(),Ze(Ht),Ze(Pt),Ic();break;case 5:Pc(p);break;case 4:gr();break;case 13:Ze(ot);break;case 19:Ze(ot);break;case 10:Cc(p.type._context);break;case 22:case 23:du()}i=i.return}if(bt=s,ft=s=ta(s.current,null),Tt=un=r,jt=0,xl=null,au=Oo=Ra=0,Yt=jl=null,$a!==null){for(r=0;r<$a.length;r++)if(i=$a[r],p=i.interleaved,p!==null){i.interleaved=null;var j=p.next,w=i.pending;if(w!==null){var T=w.next;w.next=j,p.next=T}i.pending=p}$a=null}return s}function Sp(s,r){do{var i=ft;try{if(Sc(),wo.current=$o,No){for(var p=it.memoizedState;p!==null;){var j=p.queue;j!==null&&(j.pending=null),p=p.next}No=!1}if(Ea=0,kt=xt=it=null,dl=!1,hl=0,su.current=null,i===null||i.return===null){jt=1,xl=r,ft=null;break}e:{var w=s,T=i.return,F=i,q=r;if(r=Tt,F.flags|=32768,q!==null&&typeof q=="object"&&typeof q.then=="function"){var J=q,ae=F,oe=ae.tag;if((ae.mode&1)===0&&(oe===0||oe===11||oe===15)){var se=ae.alternate;se?(ae.updateQueue=se.updateQueue,ae.memoizedState=se.memoizedState,ae.lanes=se.lanes):(ae.updateQueue=null,ae.memoizedState=null)}var fe=Qm(T);if(fe!==null){fe.flags&=-257,Jm(fe,T,F,w,r),fe.mode&1&&Vm(w,J,r),r=fe,q=J;var ye=r.updateQueue;if(ye===null){var ve=new Set;ve.add(q),r.updateQueue=ve}else ye.add(q);break e}else{if((r&1)===0){Vm(w,J,r),hu();break e}q=Error(a(426))}}else if(at&&F.mode&1){var dt=Qm(T);if(dt!==null){(dt.flags&65536)===0&&(dt.flags|=256),Jm(dt,T,F,w,r),wc(xr(q,F));break e}}w=q=xr(q,F),jt!==4&&(jt=2),jl===null?jl=[w]:jl.push(w),w=T;do{switch(w.tag){case 3:w.flags|=65536,r&=-r,w.lanes|=r;var G=Km(w,q,r);vm(w,G);break e;case 1:F=q;var z=w.type,Y=w.stateNode;if((w.flags&128)===0&&(typeof z.getDerivedStateFromError=="function"||Y!==null&&typeof Y.componentDidCatch=="function"&&(Js===null||!Js.has(Y)))){w.flags|=65536,r&=-r,w.lanes|=r;var ce=Ym(w,F,r);vm(w,ce);break e}}w=w.return}while(w!==null)}Tp(i)}catch(we){r=we,ft===i&&i!==null&&(ft=i=i.return);continue}break}while(!0)}function Cp(){var s=Io.current;return Io.current=$o,s===null?$o:s}function hu(){(jt===0||jt===3||jt===2)&&(jt=4),bt===null||(Ra&268435455)===0&&(Oo&268435455)===0||ea(bt,Tt)}function Do(s,r){var i=He;He|=2;var p=Cp();(bt!==s||Tt!==r)&&(Ns=null,Aa(s,r));do try{dv();break}catch(j){Sp(s,j)}while(!0);if(Sc(),He=i,Io.current=p,ft!==null)throw Error(a(261));return bt=null,Tt=0,jt}function dv(){for(;ft!==null;)$p(ft)}function hv(){for(;ft!==null&&!Ka();)$p(ft)}function $p(s){var r=Pp(s.alternate,s,un);s.memoizedProps=s.pendingProps,r===null?Tp(s):ft=r,su.current=null}function Tp(s){var r=s;do{var i=r.alternate;if(s=r.return,(r.flags&32768)===0){if(i=av(i,r,un),i!==null){ft=i;return}}else{if(i=rv(i,r),i!==null){i.flags&=32767,ft=i;return}if(s!==null)s.flags|=32768,s.subtreeFlags=0,s.deletions=null;else{jt=6,ft=null;return}}if(r=r.sibling,r!==null){ft=r;return}ft=r=s}while(r!==null);jt===0&&(jt=5)}function Ia(s,r,i){var p=Ye,j=Sn.transition;try{Sn.transition=null,Ye=1,mv(s,r,i,p)}finally{Sn.transition=j,Ye=p}return null}function mv(s,r,i,p){do kr();while(Xs!==null);if((He&6)!==0)throw Error(a(327));i=s.finishedWork;var j=s.finishedLanes;if(i===null)return null;if(s.finishedWork=null,s.finishedLanes=0,i===s.current)throw Error(a(177));s.callbackNode=null,s.callbackPriority=0;var w=i.lanes|i.childLanes;if(Ja(s,w),s===bt&&(ft=bt=null,Tt=0),(i.subtreeFlags&2064)===0&&(i.flags&2064)===0||Fo||(Fo=!0,Ap(gs,function(){return kr(),null})),w=(i.flags&15990)!==0,(i.subtreeFlags&15990)!==0||w){w=Sn.transition,Sn.transition=null;var T=Ye;Ye=1;var F=He;He|=4,su.current=null,ov(s,i),jp(i,s),Iy(hc),Ql=!!dc,hc=dc=null,s.current=i,iv(i),vt(),He=F,Ye=T,Sn.transition=w}else s.current=i;if(Fo&&(Fo=!1,Xs=s,Mo=j),w=s.pendingLanes,w===0&&(Js=null),zl(i.stateNode),Vt(s,_e()),r!==null)for(p=s.onRecoverableError,i=0;i<r.length;i++)j=r[i],p(j.value,{componentStack:j.stack,digest:j.digest});if(Lo)throw Lo=!1,s=lu,lu=null,s;return(Mo&1)!==0&&s.tag!==0&&kr(),w=s.pendingLanes,(w&1)!==0?s===ou?yl++:(yl=0,ou=s):yl=0,Ks(),null}function kr(){if(Xs!==null){var s=Kl(Mo),r=Sn.transition,i=Ye;try{if(Sn.transition=null,Ye=16>s?16:s,Xs===null)var p=!1;else{if(s=Xs,Xs=null,Mo=0,(He&6)!==0)throw Error(a(331));var j=He;for(He|=4,je=s.current;je!==null;){var w=je,T=w.child;if((je.flags&16)!==0){var F=w.deletions;if(F!==null){for(var q=0;q<F.length;q++){var J=F[q];for(je=J;je!==null;){var ae=je;switch(ae.tag){case 0:case 11:case 15:gl(8,ae,w)}var oe=ae.child;if(oe!==null)oe.return=ae,je=oe;else for(;je!==null;){ae=je;var se=ae.sibling,fe=ae.return;if(mp(ae),ae===J){je=null;break}if(se!==null){se.return=fe,je=se;break}je=fe}}}var ye=w.alternate;if(ye!==null){var ve=ye.child;if(ve!==null){ye.child=null;do{var dt=ve.sibling;ve.sibling=null,ve=dt}while(ve!==null)}}je=w}}if((w.subtreeFlags&2064)!==0&&T!==null)T.return=w,je=T;else e:for(;je!==null;){if(w=je,(w.flags&2048)!==0)switch(w.tag){case 0:case 11:case 15:gl(9,w,w.return)}var G=w.sibling;if(G!==null){G.return=w.return,je=G;break e}je=w.return}}var z=s.current;for(je=z;je!==null;){T=je;var Y=T.child;if((T.subtreeFlags&2064)!==0&&Y!==null)Y.return=T,je=Y;else e:for(T=z;je!==null;){if(F=je,(F.flags&2048)!==0)try{switch(F.tag){case 0:case 11:case 15:Ao(9,F)}}catch(we){ct(F,F.return,we)}if(F===T){je=null;break e}var ce=F.sibling;if(ce!==null){ce.return=F.return,je=ce;break e}je=F.return}}if(He=j,Ks(),Mt&&typeof Mt.onPostCommitFiberRoot=="function")try{Mt.onPostCommitFiberRoot(_s,s)}catch{}p=!0}return p}finally{Ye=i,Sn.transition=r}}return!1}function Ep(s,r,i){r=xr(i,r),r=Km(s,r,1),s=Vs(s,r,1),r=Ut(),s!==null&&(ka(s,1,r),Vt(s,r))}function ct(s,r,i){if(s.tag===3)Ep(s,s,i);else for(;r!==null;){if(r.tag===3){Ep(r,s,i);break}else if(r.tag===1){var p=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof p.componentDidCatch=="function"&&(Js===null||!Js.has(p))){s=xr(i,s),s=Ym(r,s,1),r=Vs(r,s,1),s=Ut(),r!==null&&(ka(r,1,s),Vt(r,s));break}}r=r.return}}function pv(s,r,i){var p=s.pingCache;p!==null&&p.delete(r),r=Ut(),s.pingedLanes|=s.suspendedLanes&i,bt===s&&(Tt&i)===i&&(jt===4||jt===3&&(Tt&130023424)===Tt&&500>_e()-ru?Aa(s,0):au|=i),Vt(s,r)}function Rp(s,r){r===0&&((s.mode&1)===0?r=1:(r=Va,Va<<=1,(Va&130023424)===0&&(Va=4194304)));var i=Ut();s=ks(s,r),s!==null&&(ka(s,r,i),Vt(s,i))}function fv(s){var r=s.memoizedState,i=0;r!==null&&(i=r.retryLane),Rp(s,i)}function gv(s,r){var i=0;switch(s.tag){case 13:var p=s.stateNode,j=s.memoizedState;j!==null&&(i=j.retryLane);break;case 19:p=s.stateNode;break;default:throw Error(a(314))}p!==null&&p.delete(r),Rp(s,i)}var Pp;Pp=function(s,r,i){if(s!==null)if(s.memoizedProps!==r.pendingProps||Ht.current)Kt=!0;else{if((s.lanes&i)===0&&(r.flags&128)===0)return Kt=!1,sv(s,r,i);Kt=(s.flags&131072)!==0}else Kt=!1,at&&(r.flags&1048576)!==0&&um(r,fo,r.index);switch(r.lanes=0,r.tag){case 2:var p=r.type;Ro(s,r),s=r.pendingProps;var j=cr(r,Pt.current);fr(r,i),j=Fc(null,r,p,s,j,i);var w=Mc();return r.flags|=1,typeof j=="object"&&j!==null&&typeof j.render=="function"&&j.$$typeof===void 0?(r.tag=1,r.memoizedState=null,r.updateQueue=null,Gt(p)?(w=!0,ho(r)):w=!1,r.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,Ec(r),j.updater=To,r.stateNode=j,j._reactInternals=r,Wc(r,p,s,i),r=Kc(null,r,p,!0,w,i)):(r.tag=0,at&&w&&yc(r),_t(null,r,j,i),r=r.child),r;case 16:p=r.elementType;e:{switch(Ro(s,r),s=r.pendingProps,j=p._init,p=j(p._payload),r.type=p,j=r.tag=jv(p),s=Wn(p,s),j){case 0:r=Gc(null,r,p,s,i);break e;case 1:r=sp(null,r,p,s,i);break e;case 11:r=Xm(null,r,p,s,i);break e;case 14:r=Zm(null,r,p,Wn(p.type,s),i);break e}throw Error(a(306,p,""))}return r;case 0:return p=r.type,j=r.pendingProps,j=r.elementType===p?j:Wn(p,j),Gc(s,r,p,j,i);case 1:return p=r.type,j=r.pendingProps,j=r.elementType===p?j:Wn(p,j),sp(s,r,p,j,i);case 3:e:{if(ap(r),s===null)throw Error(a(387));p=r.pendingProps,w=r.memoizedState,j=w.element,ym(s,r),ko(r,p,null,i);var T=r.memoizedState;if(p=T.element,w.isDehydrated)if(w={element:p,isDehydrated:!1,cache:T.cache,pendingSuspenseBoundaries:T.pendingSuspenseBoundaries,transitions:T.transitions},r.updateQueue.baseState=w,r.memoizedState=w,r.flags&256){j=xr(Error(a(423)),r),r=rp(s,r,p,i,j);break e}else if(p!==j){j=xr(Error(a(424)),r),r=rp(s,r,p,i,j);break e}else for(cn=zs(r.stateNode.containerInfo.firstChild),on=r,at=!0,qn=null,i=xm(r,null,p,i),r.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(hr(),p===j){r=ws(s,r,i);break e}_t(s,r,p,i)}r=r.child}return r;case 5:return bm(r),s===null&&bc(r),p=r.type,j=r.pendingProps,w=s!==null?s.memoizedProps:null,T=j.children,mc(p,j)?T=null:w!==null&&mc(p,w)&&(r.flags|=32),np(s,r),_t(s,r,T,i),r.child;case 6:return s===null&&bc(r),null;case 13:return lp(s,r,i);case 4:return Rc(r,r.stateNode.containerInfo),p=r.pendingProps,s===null?r.child=mr(r,null,p,i):_t(s,r,p,i),r.child;case 11:return p=r.type,j=r.pendingProps,j=r.elementType===p?j:Wn(p,j),Xm(s,r,p,j,i);case 7:return _t(s,r,r.pendingProps,i),r.child;case 8:return _t(s,r,r.pendingProps.children,i),r.child;case 12:return _t(s,r,r.pendingProps.children,i),r.child;case 10:e:{if(p=r.type._context,j=r.pendingProps,w=r.memoizedProps,T=j.value,Qe(jo,p._currentValue),p._currentValue=T,w!==null)if(Bn(w.value,T)){if(w.children===j.children&&!Ht.current){r=ws(s,r,i);break e}}else for(w=r.child,w!==null&&(w.return=r);w!==null;){var F=w.dependencies;if(F!==null){T=w.child;for(var q=F.firstContext;q!==null;){if(q.context===p){if(w.tag===1){q=bs(-1,i&-i),q.tag=2;var J=w.updateQueue;if(J!==null){J=J.shared;var ae=J.pending;ae===null?q.next=q:(q.next=ae.next,ae.next=q),J.pending=q}}w.lanes|=i,q=w.alternate,q!==null&&(q.lanes|=i),$c(w.return,i,r),F.lanes|=i;break}q=q.next}}else if(w.tag===10)T=w.type===r.type?null:w.child;else if(w.tag===18){if(T=w.return,T===null)throw Error(a(341));T.lanes|=i,F=T.alternate,F!==null&&(F.lanes|=i),$c(T,i,r),T=w.sibling}else T=w.child;if(T!==null)T.return=w;else for(T=w;T!==null;){if(T===r){T=null;break}if(w=T.sibling,w!==null){w.return=T.return,T=w;break}T=T.return}w=T}_t(s,r,j.children,i),r=r.child}return r;case 9:return j=r.type,p=r.pendingProps.children,fr(r,i),j=wn(j),p=p(j),r.flags|=1,_t(s,r,p,i),r.child;case 14:return p=r.type,j=Wn(p,r.pendingProps),j=Wn(p.type,j),Zm(s,r,p,j,i);case 15:return ep(s,r,r.type,r.pendingProps,i);case 17:return p=r.type,j=r.pendingProps,j=r.elementType===p?j:Wn(p,j),Ro(s,r),r.tag=1,Gt(p)?(s=!0,ho(r)):s=!1,fr(r,i),Hm(r,p,j),Wc(r,p,j,i),Kc(null,r,p,!0,s,i);case 19:return ip(s,r,i);case 22:return tp(s,r,i)}throw Error(a(156,r.tag))};function Ap(s,r){return rn(s,r)}function xv(s,r,i,p){this.tag=s,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=p,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Cn(s,r,i,p){return new xv(s,r,i,p)}function mu(s){return s=s.prototype,!(!s||!s.isReactComponent)}function jv(s){if(typeof s=="function")return mu(s)?1:0;if(s!=null){if(s=s.$$typeof,s===K)return 11;if(s===Z)return 14}return 2}function ta(s,r){var i=s.alternate;return i===null?(i=Cn(s.tag,r,s.key,s.mode),i.elementType=s.elementType,i.type=s.type,i.stateNode=s.stateNode,i.alternate=s,s.alternate=i):(i.pendingProps=r,i.type=s.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=s.flags&14680064,i.childLanes=s.childLanes,i.lanes=s.lanes,i.child=s.child,i.memoizedProps=s.memoizedProps,i.memoizedState=s.memoizedState,i.updateQueue=s.updateQueue,r=s.dependencies,i.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},i.sibling=s.sibling,i.index=s.index,i.ref=s.ref,i}function Bo(s,r,i,p,j,w){var T=2;if(p=s,typeof s=="function")mu(s)&&(T=1);else if(typeof s=="string")T=5;else e:switch(s){case M:return Oa(i.children,j,w,r);case O:T=8,j|=8;break;case _:return s=Cn(12,i,r,j|2),s.elementType=_,s.lanes=w,s;case B:return s=Cn(13,i,r,j),s.elementType=B,s.lanes=w,s;case ne:return s=Cn(19,i,r,j),s.elementType=ne,s.lanes=w,s;case te:return qo(i,j,w,r);default:if(typeof s=="object"&&s!==null)switch(s.$$typeof){case I:T=10;break e;case L:T=9;break e;case K:T=11;break e;case Z:T=14;break e;case D:T=16,p=null;break e}throw Error(a(130,s==null?s:typeof s,""))}return r=Cn(T,i,r,j),r.elementType=s,r.type=p,r.lanes=w,r}function Oa(s,r,i,p){return s=Cn(7,s,p,r),s.lanes=i,s}function qo(s,r,i,p){return s=Cn(22,s,p,r),s.elementType=te,s.lanes=i,s.stateNode={isHidden:!1},s}function pu(s,r,i){return s=Cn(6,s,null,r),s.lanes=i,s}function fu(s,r,i){return r=Cn(4,s.children!==null?s.children:[],s.key,r),r.lanes=i,r.stateNode={containerInfo:s.containerInfo,pendingChildren:null,implementation:s.implementation},r}function yv(s,r,i,p,j){this.tag=r,this.containerInfo=s,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Dr(0),this.expirationTimes=Dr(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Dr(0),this.identifierPrefix=p,this.onRecoverableError=j,this.mutableSourceEagerHydrationData=null}function gu(s,r,i,p,j,w,T,F,q){return s=new yv(s,r,i,F,q),r===1?(r=1,w===!0&&(r|=8)):r=0,w=Cn(3,null,null,r),s.current=w,w.stateNode=s,w.memoizedState={element:p,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ec(w),s}function vv(s,r,i){var p=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:P,key:p==null?null:""+p,children:s,containerInfo:r,implementation:i}}function Ip(s){if(!s)return Gs;s=s._reactInternals;e:{if(yn(s)!==s||s.tag!==1)throw Error(a(170));var r=s;do{switch(r.tag){case 3:r=r.stateNode.context;break e;case 1:if(Gt(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}}r=r.return}while(r!==null);throw Error(a(171))}if(s.tag===1){var i=s.type;if(Gt(i))return om(s,i,r)}return r}function Op(s,r,i,p,j,w,T,F,q){return s=gu(i,p,!0,s,j,w,T,F,q),s.context=Ip(null),i=s.current,p=Ut(),j=Zs(i),w=bs(p,j),w.callback=r??null,Vs(i,w,j),s.current.lanes=j,ka(s,j,p),Vt(s,p),s}function Wo(s,r,i,p){var j=r.current,w=Ut(),T=Zs(j);return i=Ip(i),r.context===null?r.context=i:r.pendingContext=i,r=bs(w,T),r.payload={element:s},p=p===void 0?null:p,p!==null&&(r.callback=p),s=Vs(j,r,T),s!==null&&(Gn(s,j,T,w),vo(s,j,T)),T}function zo(s){if(s=s.current,!s.child)return null;switch(s.child.tag){case 5:return s.child.stateNode;default:return s.child.stateNode}}function Lp(s,r){if(s=s.memoizedState,s!==null&&s.dehydrated!==null){var i=s.retryLane;s.retryLane=i!==0&&i<r?i:r}}function xu(s,r){Lp(s,r),(s=s.alternate)&&Lp(s,r)}function kv(){return null}var Fp=typeof reportError=="function"?reportError:function(s){console.error(s)};function ju(s){this._internalRoot=s}Ho.prototype.render=ju.prototype.render=function(s){var r=this._internalRoot;if(r===null)throw Error(a(409));Wo(s,r,null,null)},Ho.prototype.unmount=ju.prototype.unmount=function(){var s=this._internalRoot;if(s!==null){this._internalRoot=null;var r=s.containerInfo;Pa(function(){Wo(null,s,null,null)}),r[xs]=null}};function Ho(s){this._internalRoot=s}Ho.prototype.unstable_scheduleHydration=function(s){if(s){var r=zr();s={blockedOn:null,target:s,priority:r};for(var i=0;i<Ue.length&&r!==0&&r<Ue[i].priority;i++);Ue.splice(i,0,s),i===0&&bh(s)}};function yu(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11)}function Go(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11&&(s.nodeType!==8||s.nodeValue!==" react-mount-point-unstable "))}function Mp(){}function bv(s,r,i,p,j){if(j){if(typeof p=="function"){var w=p;p=function(){var J=zo(T);w.call(J)}}var T=Op(r,p,s,0,null,!1,!1,"",Mp);return s._reactRootContainer=T,s[xs]=T.current,sl(s.nodeType===8?s.parentNode:s),Pa(),T}for(;j=s.lastChild;)s.removeChild(j);if(typeof p=="function"){var F=p;p=function(){var J=zo(q);F.call(J)}}var q=gu(s,0,!1,null,null,!1,!1,"",Mp);return s._reactRootContainer=q,s[xs]=q.current,sl(s.nodeType===8?s.parentNode:s),Pa(function(){Wo(r,q,i,p)}),q}function Ko(s,r,i,p,j){var w=i._reactRootContainer;if(w){var T=w;if(typeof j=="function"){var F=j;j=function(){var q=zo(T);F.call(q)}}Wo(r,T,s,j)}else T=bv(i,r,s,j,p);return zo(T)}qr=function(s){switch(s.tag){case 3:var r=s.stateNode;if(r.current.memoizedState.isDehydrated){var i=Ds(r.pendingLanes);i!==0&&(Br(r,i|1),Vt(r,_e()),(He&6)===0&&(vr=_e()+500,Ks()))}break;case 13:Pa(function(){var p=ks(s,1);if(p!==null){var j=Ut();Gn(p,s,1,j)}}),xu(s,1)}},Xa=function(s){if(s.tag===13){var r=ks(s,134217728);if(r!==null){var i=Ut();Gn(r,s,134217728,i)}xu(s,134217728)}},Wr=function(s){if(s.tag===13){var r=Zs(s),i=ks(s,r);if(i!==null){var p=Ut();Gn(i,s,r,p)}xu(s,r)}},zr=function(){return Ye},Hr=function(s,r){var i=Ye;try{return Ye=s,r()}finally{Ye=i}},xn=function(s,r,i){switch(r){case"input":if(gt(s,i),r=i.name,i.type==="radio"&&r!=null){for(i=s;i.parentNode;)i=i.parentNode;for(i=i.querySelectorAll("input[name="+JSON.stringify(""+r)+'][type="radio"]'),r=0;r<i.length;r++){var p=i[r];if(p!==s&&p.form===s.form){var j=co(p);if(!j)throw Error(a(90));le(p),gt(p,j)}}}break;case"textarea":cs(s,i);break;case"select":r=i.value,r!=null&&Oe(s,!!i.multiple,r,!1)}},Le=uu,ga=Pa;var wv={usingClientEntryPoint:!1,Events:[ll,or,co,nn,lt,uu]},vl={findFiberByHostInstance:wa,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Nv={bundleType:vl.bundleType,version:vl.version,rendererPackageName:vl.rendererPackageName,rendererConfig:vl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:C.ReactCurrentDispatcher,findHostInstanceByFiber:function(s){return s=Rt(s),s===null?null:s.stateNode},findFiberByHostInstance:vl.findFiberByHostInstance||kv,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Yo=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Yo.isDisabled&&Yo.supportsFiber)try{_s=Yo.inject(Nv),Mt=Yo}catch{}}return Qt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=wv,Qt.createPortal=function(s,r){var i=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!yu(r))throw Error(a(200));return vv(s,r,null,i)},Qt.createRoot=function(s,r){if(!yu(s))throw Error(a(299));var i=!1,p="",j=Fp;return r!=null&&(r.unstable_strictMode===!0&&(i=!0),r.identifierPrefix!==void 0&&(p=r.identifierPrefix),r.onRecoverableError!==void 0&&(j=r.onRecoverableError)),r=gu(s,1,!1,null,null,i,!1,p,j),s[xs]=r.current,sl(s.nodeType===8?s.parentNode:s),new ju(r)},Qt.findDOMNode=function(s){if(s==null)return null;if(s.nodeType===1)return s;var r=s._reactInternals;if(r===void 0)throw typeof s.render=="function"?Error(a(188)):(s=Object.keys(s).join(","),Error(a(268,s)));return s=Rt(r),s=s===null?null:s.stateNode,s},Qt.flushSync=function(s){return Pa(s)},Qt.hydrate=function(s,r,i){if(!Go(r))throw Error(a(200));return Ko(null,s,r,!0,i)},Qt.hydrateRoot=function(s,r,i){if(!yu(s))throw Error(a(405));var p=i!=null&&i.hydratedSources||null,j=!1,w="",T=Fp;if(i!=null&&(i.unstable_strictMode===!0&&(j=!0),i.identifierPrefix!==void 0&&(w=i.identifierPrefix),i.onRecoverableError!==void 0&&(T=i.onRecoverableError)),r=Op(r,null,s,1,i??null,j,!1,w,T),s[xs]=r.current,sl(s),p)for(s=0;s<p.length;s++)i=p[s],j=i._getVersion,j=j(i._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[i,j]:r.mutableSourceEagerHydrationData.push(i,j);return new Ho(r)},Qt.render=function(s,r,i){if(!Go(r))throw Error(a(200));return Ko(null,s,r,!1,i)},Qt.unmountComponentAtNode=function(s){if(!Go(s))throw Error(a(40));return s._reactRootContainer?(Pa(function(){Ko(null,null,s,!1,function(){s._reactRootContainer=null,s[xs]=null})}),!0):!1},Qt.unstable_batchedUpdates=uu,Qt.unstable_renderSubtreeIntoContainer=function(s,r,i,p){if(!Go(i))throw Error(a(200));if(s==null||s._reactInternals===void 0)throw Error(a(38));return Ko(s,r,i,!1,p)},Qt.version="18.3.1-next-f1338f8080-20240426",Qt}var Gp;function Wg(){if(Gp)return bu.exports;Gp=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(n){console.error(n)}}return t(),bu.exports=Iv(),bu.exports}var Kp;function Ov(){if(Kp)return Vo;Kp=1;var t=Wg();return Vo.createRoot=t.createRoot,Vo.hydrateRoot=t.hydrateRoot,Vo}var Lv=Ov();const zg=["image/png","image/jpeg","image/gif","image/webp","application/pdf","text/plain","application/json"],Fv=[...zg,".txt",".md",".json",".log"].join(","),Mv=10*1024*1024,Yp=20;function ld(t){return t.type.startsWith("text/")&&t.type!=="text/html"?"text/plain":t.type?t.type:/\.(txt|md|log)$/i.test(t.name)?"text/plain":/\.json$/i.test(t.name)?"application/json":""}function _v(t,n){return n>=Yp?`A task takes up to ${Yp} files.`:zg.includes(ld(t))?t.size>Mv?`${t.name} is over 10 MB.`:t.size===0?`${t.name} is empty.`:null:`${t.name} is not a file the agent reads: PNG, JPEG, GIF, WebP, PDF, text or JSON.`}function Vp(t){return t?[...t.files].map((n,a)=>n.name?n:new File([n],`pasted-${a+1}.${(n.type.split("/")[1]??"png").replace("jpeg","jpg")}`,{type:n.type})):[]}function da(t){const n=t.trim();if(!n)return n;const a=/^[a-z]+ /.test(n)?`${n.charAt(0).toUpperCase()}${n.slice(1)}`:n;return/[.!?]$/.test(a)?a:`${a}.`}const Qp=": git merge ";function Tl(t){const n=t.lastIndexOf(Qp);if(n<0)return null;const a=t.slice(n+2).replace(/\.$/,"").trim();return a.length>Qp.length-2?{said:t.slice(0,n),command:a}:null}let bl=null;const od=new Set,Jp=()=>od.forEach(t=>t()),Nr={lost(){bl===null&&(bl=Date.now(),Jp())},found(){bl!==null&&(bl=null,Jp())},since:()=>bl,subscribe(t){return od.add(t),()=>{od.delete(t)}}};function Me(t){return t.role==="owner"||t.role==="admin"}class ht extends Error{constructor(n,a,l,o={}){super(n),this.code=a,this.status=l,this.body=o}}class Ua extends ht{constructor(n,a="signed-out"){super(n,a,401)}}class Os extends ht{constructor(n,a="not-found"){super(n,a,404)}}function Xp(t,n){const a=new URLSearchParams;for(const[l,o]of Object.entries(t))o&&a.set(l,o);return n&&a.set("after",n),a}let gi="",Hg="/api";const id="orchestrator:onboarding";function Uv(t,n){Hg=!t||t===n?"/api":`/api/orgs/${encodeURIComponent(t)}`}function Pn(t){return t==="/api/orgs"?t:`${Hg}${t.slice(4)}`}function U(t,n,a){return Et(t,Pn(n),a,gi)}async function Et(t,n,a,l,o){const c={...(o==null?void 0:o.headers)??{}};o?c["content-type"]=o.type:a!==void 0&&(c["content-type"]="application/json"),t!=="GET"&&(c["x-csrf-token"]=l);const d=await fetch(n,{method:t,headers:c,body:o?o.data:a===void 0?void 0:JSON.stringify(a)}).catch(()=>{throw Nr.lost(),new Error("The orchestrator did not answer. Check that it is running and reachable from here, then try again.")});Nr.found();const u=await d.json().catch(()=>({})),m=typeof u.error=="string"&&u.error.trim()?da(u.error):null;if(d.status===401)throw new Ua(m??"Sign in first.",typeof u.code=="string"?u.code:void 0);const f=typeof u.code=="string"?u.code:"error";if(d.status===404)throw new Os(m??"Not found.",f==="error"?"not-found":f);if(!d.ok)throw new ht(m??`The orchestrator failed to answer (${d.status} ${d.statusText}). Try again; when it keeps failing, the orchestrator's log says why.`,f,d.status,u);return u}function ke(t){return U("GET",t)}const ut={config:()=>Et("GET","/api/identity/config",void 0,"").then(t=>t.mode==="self-hosted"?null:t,t=>{if(t instanceof Os)return null;throw t}),me:()=>Et("GET","/api/identity",void 0,""),addLogin:(t,n)=>Et("POST",`/api/identity/logins/${t}`,void 0,n),removeLogin:(t,n)=>Et("DELETE",`/api/identity/logins/${t}`,void 0,n),awaitingLogin:t=>Et("GET",`/api/identity/logins/confirm/${encodeURIComponent(t)}`,void 0,""),confirmLogin:(t,n)=>Et("POST",`/api/identity/logins/confirm/${encodeURIComponent(t)}`,void 0,n),createOrganization:(t,n)=>Et("POST","/api/signup/organization",t,n),signOut:t=>Et("POST","/api/identity/logout",void 0,t),operatorFunnel:t=>Et("GET",`/api/operator/funnel?days=${t}`,void 0,""),join:(t,n)=>Et("POST","/api/identity/join",{token:t},n),orgs:()=>Et("GET","/api/me/orgs",void 0,""),joinByDirectory:(t,n)=>Et("POST",`/api/me/joinable/${encodeURIComponent(t)}`,void 0,n),acceptInvitation:(t,n)=>Et("POST",`/api/me/invitations/${encodeURIComponent(t)}/accept`,void 0,n),declineInvitation:(t,n)=>Et("DELETE",`/api/me/invitations/${encodeURIComponent(t)}`,void 0,n)},xi={sessions:()=>ke("/api/me/sessions").then(t=>t.sessions),end:t=>U("DELETE",`/api/me/sessions/${encodeURIComponent(t)}`),apps:()=>ke("/api/me/apps").then(t=>t.apps),takeBack:t=>U("DELETE",`/api/me/apps/${encodeURIComponent(t)}`)},Ol={config:()=>ke("/api/auth/config"),me:async()=>{const t=await ke("/api/me");return gi=t.csrf,t.user},login:(t,n)=>U("POST","/api/auth/login",{email:t,password:n}),setup:t=>U("POST","/api/auth/setup",t),logout:()=>U("POST","/api/auth/logout"),changePassword:(t,n)=>U("POST","/api/me/password",{current:t,next:n})},pn={users:()=>ke("/api/users").then(t=>t.users),teams:()=>ke("/api/teams").then(t=>t.teams),create:t=>U("POST","/api/users",t).then(n=>n.user),update:(t,n)=>U("PATCH",`/api/users/${t}`,n).then(a=>a.user),remove:t=>U("DELETE",`/api/users/${t}`)},Pr={page:t=>ke(`/api/members/${t}`),invites:()=>ke("/api/invites").then(t=>t.invites),invite:t=>U("POST","/api/invites",t),resend:t=>U("POST",`/api/invites/${t}/resend`).then(n=>n.invite),revoke:t=>U("DELETE",`/api/invites/${t}`),leave:()=>U("POST","/api/me/leave")},Gg=["repositories","requests","tasks","usage","members","settings","keys"],Dv={repositories:"write",requests:"write",tasks:"write",usage:"read",members:"read",settings:"read",keys:"write"},Da={list:t=>ke(`/api/keys${t?`?serviceAccount=${t}`:""}`).then(n=>n.keys),create:t=>U("POST","/api/keys",t),revoke:t=>U("DELETE",`/api/keys/${t}`),serviceAccounts:()=>ke("/api/service-accounts").then(t=>t.serviceAccounts),createServiceAccount:t=>U("POST","/api/service-accounts",t).then(n=>n.serviceAccount),updateServiceAccount:(t,n)=>U("PATCH",`/api/service-accounts/${t}`,n),removeServiceAccount:t=>U("DELETE",`/api/service-accounts/${t}`)},Zp={read:()=>ke("/api/directory-join"),set:(t,n="member")=>U("PUT","/api/directory-join",{on:t,role:n}).then(a=>a.join)},Qo={list:()=>ke("/api/sso/domains"),add:t=>U("POST","/api/sso/domains",{domain:t}).then(n=>n.domain),verify:t=>U("POST",`/api/sso/domains/${encodeURIComponent(t)}/verify`).then(n=>n.domain),remove:t=>U("DELETE",`/api/sso/domains/${encodeURIComponent(t)}`)},ji={read:()=>ke("/api/directory"),preview:t=>U("POST","/api/directory/preview",{mapping:t}),apply:(t,n)=>U("PUT","/api/directory",{mapping:t,fingerprint:n}),setTags:(t,n)=>U("PUT",`/api/members/${t}/tags`,{tags:n}).then(a=>a.tags)},ef={read:()=>ke("/api/org"),rename:t=>U("PUT","/api/org",{name:t})},yi={read:()=>ke("/api/settings/task-limits"),change:t=>U("PUT","/api/settings/task-limits",t)},tf={read:()=>ke("/api/privacy"),change:t=>U("PUT","/api/privacy",t).then(n=>n.privacy)};async function Su(t,n,a,l,o){const c=t===n?"/api":`/api/orgs/${encodeURIComponent(t)}`,d=async(m,f,g,x)=>{const y=await fetch(`${c}${f}`,{method:m,headers:{...g===void 0?{}:{"content-type":"application/json"},...x?{"x-csrf-token":x}:{}},body:g===void 0?void 0:JSON.stringify(g)}).catch(()=>{throw new Error("The orchestrator did not answer. Check that it is running and reachable from here, then try again.")}),b=await y.json().catch(()=>({}));if(y.status===401)throw new Ua(typeof b.error=="string"?da(b.error):"Sign in first.",typeof b.code=="string"?b.code:void 0);if(!y.ok)throw new ht(b.error??`The orchestrator failed to answer (${y.status} ${y.statusText}).`,typeof b.code=="string"?b.code:"error",y.status);return b};if(a==="GET")return d(a,l);const{csrf:u}=await d("GET","/me");return d(a,l,o,u)}const vi={orgs:async()=>await Ce.orgs()??{default:"",orgs:[]},rename:(t,n,a)=>Su(t,n,"PATCH","/me",{name:a}),summary:(t,n)=>Su(t,n,"GET","/me/deletion").then(a=>a.summary),remove:(t,n,a)=>Su(t,n,"POST","/me/deletion",{confirm:a})},cd={list:()=>ke("/api/task-secrets"),set:t=>U("PUT","/api/task-secrets",t).then(n=>n.secret),remove:t=>U("DELETE","/api/task-secrets",t)},Cu={read:()=>ke("/api/scim"),create:()=>U("POST","/api/scim/token"),remove:()=>U("DELETE","/api/scim/token")},nf={read:t=>U("POST","/api/join/read",{token:t}),accept:(t,n)=>U("POST","/api/join",{token:t,...n})},Ce={summary:()=>ke("/api/activity/summary"),onboarding:()=>ke("/api/activity/onboarding"),changeOnboarding:t=>U("PUT","/api/activity/onboarding",t).then(n=>(window.dispatchEvent(new Event(id)),n)),usageReport:(t,n)=>ke(`/api/activity/usage?${new URLSearchParams({days:String(t),...n?{repo:n}:{}})}`),usageExport:(t,n,a)=>Pn(`/api/activity/usage/export?${new URLSearchParams({days:String(t),format:n,...a?{repo:a}:{}})}`),leaderboard:t=>ke(`/api/activity/leaderboard?days=${t}`),audit:(t,n)=>ke(`/api/events?${Xp(t,n)}`).catch(a=>{if(a instanceof Os)return null;throw a}),event:t=>ke(`/api/events/${encodeURIComponent(t)}`),auditExport:(t,n)=>Pn(`/api/events/export?${Xp(t,null)}&format=${n}`),orgs:()=>ke("/api/orgs").catch(t=>{if(t instanceof Ua)return null;throw t}),repos:()=>ke("/api/repos").then(t=>t.repos),inventory:t=>ke(`/api/repos/${t}/inventory`),history:(t,n)=>ke(`/api/repos/${t}/history${n?`?path=${encodeURIComponent(n)}`:""}`).then(a=>a.history),sync:t=>U("POST",`/api/repos/${t}/sync`),disconnect:t=>U("DELETE",`/api/repos/${t}`),connectRepo:t=>U("POST","/api/repos",t).then(n=>n.repo),usage:t=>ke(`/api/usage?repo=${t}`),overlaps:t=>ke(`/api/repos/${t}/overlaps`),pending:t=>ke(`/api/repos/${t}/pending`),requests:t=>{const n=new URLSearchParams({...t.after?{after:t.after}:{},...t.repoId?{repo:t.repoId}:{},...t.status?{status:t.status}:{}});return ke(`/api/requests?${n}`)},skill:(t,n)=>ke(`/api/repos/${t}/skills/${n}`),command:(t,n)=>ke(`/api/repos/${t}/commands/${encodeURIComponent(n)}`),mcpServer:(t,n)=>ke(`/api/repos/${t}/mcp-servers/${encodeURIComponent(n)}`),proposal:(t,n)=>U("POST",`/api/repos/${t}/changes/proposal`,{change:n}),propose:(t,n,a,l,o)=>U("POST",`/api/repos/${t}/changes`,{baseSha:n,change:a,message:l,branch:o}).then(c=>c.request),requestDescription:(t,n)=>ke(`/api/repos/${t}/requests/${n}/description`),requestAction:(t,n,a)=>U("POST",`/api/repos/${t}/requests/${n}/${a}`).then(l=>l.request),onForge:(t,n)=>ke(`/api/repos/${t}/requests/${n}/on-forge`),openOnForge:(t,n)=>U("POST",`/api/repos/${t}/requests/${n}/on-forge`),forge:t=>ke(`/api/repos/${t}/forge`),saveForge:(t,n)=>U("PUT",`/api/repos/${t}/forge`,n),removeForge:t=>U("DELETE",`/api/repos/${t}/forge`),usageProposal:(t,n)=>U("POST",`/api/repos/${t}/usage/proposal`,{action:n}),proposeUsage:(t,n,a,l,o)=>U("POST",`/api/repos/${t}/usage/propose`,{action:o,baseSha:n,message:a,branch:l}).then(c=>c.request)},ki=5,bi={upload:(t,n)=>Et("POST",Pn(`/api/tasks/${t}/attachments`),void 0,gi,{data:n,type:ld(n)||"application/octet-stream",headers:{"x-attachment-name":encodeURIComponent(n.name)}}).then(a=>a.attachment),uploadFree:t=>Et("POST",Pn("/api/attachments"),void 0,gi,{data:t,type:ld(t)||"application/octet-stream",headers:{"x-attachment-name":encodeURIComponent(t.name)}}).then(n=>n.attachment),list:t=>ke(`/api/tasks/${t}/attachments`).then(n=>n.attachments??[]),remove:(t,n)=>U("DELETE",`/api/tasks/${t}/attachments/${encodeURIComponent(n)}`),url:(t,n)=>ke(`/api/tasks/${t}/attachments/${encodeURIComponent(n)}/url`).then(a=>a.url)},Bv={of:t=>ke(`/api/repos/${encodeURIComponent(t)}/branches`)},qv={windows:t=>ke(`/api/agents/${encodeURIComponent(t)}/limit`).then(n=>n.windows)},Wv={range:(t,n)=>ke(`/api/tasks/cost-range?${new URLSearchParams({repo:t,agent:n})}`)},zv={tasks:t=>ke(`/api/search?${new URLSearchParams({q:t})}`)},ge={budgets:()=>ke("/api/policies/current-budgets"),options:()=>ke("/api/tasks/options"),page:(t,n)=>{const a=new URLSearchParams({...t?{after:t}:{},...n?{since:n}:{}}).toString();return ke(a?`/api/tasks?${a}`:"/api/tasks")},since:async t=>{const n=[];for(let a=null;;){const l=await ge.page(a,t);if(n.push(...l.tasks),!l.next)return n;a=l.next}},get:(t,n)=>ke(`/api/tasks/${t}?after=${n}`),eventsUrl:(t,n)=>`/api/tasks/${t}/events?after=${n}`,where:t=>U("POST","/api/tasks/where",t),start:t=>U("POST","/api/tasks",t).then(n=>n.task),startRepeating:t=>U("POST","/api/tasks",t).then(n=>n.repeat),repeats:()=>U("GET","/api/tasks/repeats").then(t=>t.repeats),stopRepeat:t=>U("POST",`/api/tasks/repeats/${encodeURIComponent(t)}/stop`),stopStep:t=>U("POST",`/api/tasks/${t}/stop-step`).then(n=>n.task),cancel:t=>U("POST",`/api/tasks/${t}/cancel`).then(n=>n.task),answerStopped:(t,n)=>U("POST",`/api/tasks/${encodeURIComponent(t)}/answer`,{answer:n}).then(a=>a.task),move:(t,n)=>U("POST",`/api/tasks/${encodeURIComponent(t)}/move`,{path:n}),giveSecret:(t,n,a)=>U("POST",`/api/tasks/${t}/secrets/${encodeURIComponent(n)}`,{value:a}),declineSecret:(t,n)=>U("POST",`/api/tasks/${t}/requests/${encodeURIComponent(n)}`,{answer:{provided:!1},commandId:crypto.randomUUID()}),answerQuestions:(t,n,a)=>U("POST",`/api/tasks/${t}/requests/${encodeURIComponent(n)}`,{answer:{answers:a},commandId:crypto.randomUUID()}),answerPlan:(t,n,a,l)=>U("POST",`/api/tasks/${t}/requests/${encodeURIComponent(n)}`,{answer:{decision:a,...l?{plan:l}:{}},commandId:crypto.randomUUID()}),answer:(t,n,a,l)=>U("POST",`/api/tasks/${t}/requests/${encodeURIComponent(n)}`,{answer:{decision:a,...a==="deny"&&l?{note:l}:{}},commandId:crypto.randomUUID()}),message:(t,n,a)=>{var l;return U("POST",`/api/tasks/${t}/messages`,{text:n.text,...n.quotes.length?{quotes:n.quotes}:{},...(l=n.attachments)!=null&&l.length?{attachments:n.attachments}:{},commandId:a}).then(o=>o.followUp)},editMessage:(t,n,a)=>U("PATCH",`/api/tasks/${t}/messages/${encodeURIComponent(n)}`,a).then(l=>l.message),removeMessage:(t,n)=>U("DELETE",`/api/tasks/${t}/messages/${encodeURIComponent(n)}`),suggest:(t,n,a)=>U("POST",`/api/tasks/${t}/suggestions`,{text:n.text,...n.quotes.length?{quotes:n.quotes}:{},commandId:a}),answerSuggestion:(t,n,a)=>U("POST",`/api/tasks/${t}/suggestions/${encodeURIComponent(n)}/${a}`),turns:t=>U("GET",`/api/tasks/${t}/turns`).then(n=>n.turns),newFromTurn:(t,n,a)=>U("POST",`/api/tasks/${t}/turns/${n}/new-task`,{commandId:crypto.randomUUID(),...a?{text:a}:{}}).then(l=>l.task),undoFromTurn:(t,n,a)=>U("POST",`/api/tasks/${t}/turns/${n}/undo`,{commandId:crypto.randomUUID(),...a?{reason:a}:{}}).then(l=>l.turns),targetOnForge:(t,n)=>U("GET",`/api/tasks/${t}/targets/${n}/on-forge`).then(a=>a.onForge),dropFromRequest:(t,n)=>U("POST",`/api/tasks/${t}/request/drop`,{path:n}),undo:(t,n={})=>U("POST",`/api/tasks/${t}/undo`,{commandId:crypto.randomUUID(),...n}),keep:t=>U("POST",`/api/tasks/${t}/keep`,{commandId:crypto.randomUUID()}).then(n=>n.task),openKept:(t,n)=>U("POST",`/api/tasks/${t}/targets/${n}/on-forge`),continueWithSecondSignIn:t=>U("POST",`/api/tasks/${t}/continue`,{commandId:crypto.randomUUID(),secondSignIn:!0}).then(n=>n.task),continue:t=>U("POST",`/api/tasks/${t}/continue`,{commandId:crypto.randomUUID()}).then(n=>n.task),continueWithPlan:(t,n)=>U("POST",`/api/tasks/${t}/continue`,{commandId:crypto.randomUUID(),approvePlan:!0,...n?{plan:n}:{}}).then(a=>a.task),suggestSkills:t=>U("POST","/api/tasks/skill-suggestions",t),suggestSkillsFor:t=>U("POST","/api/tasks/skill-suggestions",t),startMany:t=>U("POST","/api/tasks/batch",t),readiness:t=>ke(`/api/agents/readiness${t?"?fresh=1":""}`)},Nt={signInState:t=>ke(`/api/forge/${t}/sign-in`),signIn:t=>U("POST",`/api/forge/${t}/sign-in`,{}),deviceSignIn:t=>U("POST",`/api/forge/${t}/device`,{}),deviceSignOut:t=>U("DELETE",`/api/forge/${t}/device`),connection:t=>ke(`/api/forge/${t}/connection`),connect:t=>U("POST",`/api/forge/${t}/connect`,{}),disconnect:t=>U("DELETE",`/api/forge/${t}/connection`),repos:t=>ke(`/api/forge/${t}/repos`),connectRepo:(t,n)=>U("POST",`/api/forge/${t}/repos/connect`,n),teamRepo:(t,n)=>U("POST",`/api/forge/${t}/team-repo`,n),gitlabApp:()=>ke("/api/forge/gitlab/app"),saveGitlabApp:t=>U("PUT","/api/forge/gitlab/app",t),removeGitlabApp:()=>U("DELETE","/api/forge/gitlab/app"),hosts:()=>ke("/api/forge/hosts"),check:t=>ke(`/api/forge/${t}/connection/check`)},Dt={list:()=>ke("/api/integrations"),saveSlack:t=>U("PUT","/api/integrations/slack",t),testSlack:()=>U("POST","/api/integrations/slack/test").then(t=>t.delivery),removeSlack:()=>U("DELETE","/api/integrations/slack"),saveTracker:t=>U("PUT","/api/integrations/tracker",t),saveWrites:t=>U("PUT","/api/integrations/writes",{on:t}),addSlack:()=>U("POST","/api/integrations/slack/add").then(t=>t.authorizeUrl),signInJira:()=>U("POST","/api/integrations/jira/sign-in").then(t=>t.authorizeUrl),signInService:t=>t==="jira"?Dt.signInJira():t==="gitlab"?U("POST","/api/integrations/gitlab/sign-in").then(n=>n.authorizeUrl):Dt.signInCatalog(t),signInCatalog:t=>U("POST",`/api/integrations/catalog/${encodeURIComponent(t)}/sign-in`).then(n=>n.authorizeUrl),removeTracker:()=>U("DELETE","/api/integrations/tracker"),mcpProposal:t=>U("POST",`/api/integrations/orchestrator-mcp/${t}/proposal`),proposeMcp:(t,n,a,l)=>U("POST",`/api/integrations/orchestrator-mcp/${t}/propose`,{baseSha:n,message:a,branch:l}).then(o=>o.request)},rs={list:()=>ke("/api/me/mcp-servers"),add:t=>U("POST","/api/me/mcp-servers",t),update:(t,n)=>U("PATCH",`/api/me/mcp-servers/${encodeURIComponent(t)}`,n),remove:t=>U("DELETE",`/api/me/mcp-servers/${encodeURIComponent(t)}`),connect:t=>U("POST",`/api/me/mcp-servers/${encodeURIComponent(t)}/connect`).then(n=>n.authorizeUrl),disconnect:t=>U("POST",`/api/me/mcp-servers/${encodeURIComponent(t)}/disconnect`),tools:t=>ke(`/api/me/mcp-servers/${encodeURIComponent(t)}/tools`).then(n=>n.tools)},Hv={read:t=>ke(`/api/analytics/ai-requests?days=${t}`)},Cl={list:()=>ke("/api/team-mcp-servers"),connectForEveryone:t=>U("POST",`/api/team-mcp-servers/${t}/connect`).then(n=>n.authorizeUrl),disconnectForEveryone:t=>U("DELETE",`/api/team-mcp-servers/${t}/connection`),tools:t=>ke(`/api/team-mcp-servers/${t}/tools`).then(n=>n.tools),saveTools:(t,n)=>U("PATCH",`/api/team-mcp-servers/${t}`,{tools:n})},Gv={preview:t=>ke(`/api/issues/preview?url=${encodeURIComponent(t)}`)};function he({what:t,panel:n=!1}){return e.jsxs("div",{className:n?"panel loading":"loading",children:[e.jsxs("p",{className:"muted",role:"status",children:["Loading ",t,"…"]}),e.jsxs("div",{className:"skeleton","aria-hidden":"true",children:[e.jsx("span",{className:"skeleton-line"}),e.jsx("span",{className:"skeleton-line"}),e.jsx("span",{className:"skeleton-line"})]})]})}function Kg({what:t}){return e.jsxs("p",{className:"muted small",children:["Refreshing ",t,"…"]})}function be({what:t,reason:n,panel:a=!1,...l}){const o=e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"error",children:["Couldn't load ",t,". ",n]}),l.onRetry?e.jsxs("button",{type:"button",className:"secondary small",onClick:l.onRetry,children:["Retry ",t]}):e.jsx("p",{children:l.next})]});return a?e.jsx("div",{className:"panel problem",role:"alert",children:o}):e.jsx("div",{className:"problem",role:"alert",children:o})}function Oi({what:t,reason:n,onRetry:a}){return e.jsxs("div",{className:"problem stale",role:"alert",children:[e.jsxs("p",{className:"error",children:["Refresh failed. Showing the last loaded ",t,". ",n]}),e.jsxs("button",{type:"button",className:"secondary small",onClick:a,children:["Retry ",t]})]})}const Kv=[7,30,90];function Yv(t){const n=t.merged+t.kept,a=n+t.closed+t.undone;return a?Math.round(n/a*100):null}function Vv({days:t}){const[n,a]=h.useState(null),[l,o]=h.useState(null),[c,d]=h.useState(0);return h.useEffect(()=>{let u=!0;return a(null),o(null),U("GET",`/api/analytics/people?days=${t}`).then(m=>u&&a(m.people),m=>u&&o(m.message)),()=>{u=!1}},[t,c]),e.jsxs("section",{className:"panel","aria-labelledby":"people-outcomes-h",children:[e.jsxs("h2",{id:"people-outcomes-h",children:["Tasks by person ",e.jsxs("span",{className:"count",children:["every repository, ",t," days"]})]}),l?e.jsx(be,{what:"tasks by person",reason:l,onRetry:()=>d(u=>u+1)}):n?n.length?e.jsxs("table",{className:"row-cards",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Person"}),e.jsx("th",{scope:"col",children:"Tasks"}),e.jsx("th",{scope:"col",children:"Landed"}),e.jsx("th",{scope:"col",children:"Dropped"}),e.jsx("th",{scope:"col",children:"Failed"}),e.jsx("th",{scope:"col",children:"Kept of decided"})]})}),e.jsx("tbody",{children:n.map(u=>{const m=Yv(u);return e.jsxs("tr",{children:[e.jsx("td",{className:"rc-title",children:u.name??u.email}),e.jsx("td",{className:"rc-meta",children:u.tasks}),e.jsx("td",{className:"rc-meta",children:u.merged+u.kept}),e.jsx("td",{className:"rc-meta",children:u.closed+u.undone}),e.jsx("td",{className:"rc-meta",children:u.failed}),e.jsx("td",{className:"rc-status",children:m===null?e.jsx("span",{className:"muted",children:"none decided"}):`${m}%`})]},u.email)})})]}):e.jsxs("p",{className:"muted",children:["No task was started in the last ",t," days; each person's tasks and how they ended land here."]}):e.jsx(he,{what:"tasks by person"})]})}var Qv=Wg();const Jv=8;function Pe({label:t,labelHidden:n=!1,value:a,onChange:l,options:o,disabled:c=!1,describedBy:d,invalid:u=!1,placeholder:m="Choose…"}){var ee;const f=h.useId(),[g,x]=h.useState(!1),[y,b]=h.useState(0),[N,v]=h.useState(""),[k,S]=h.useState(null),$=h.useRef(null),E=h.useRef(null),C=h.useRef({text:"",at:0}),R=o.length>Jv,P=N.trim().toLowerCase(),M=P?o.filter(W=>`${W.label} ${W.hint??""}`.toLowerCase().includes(P)):o,O=o.find(W=>W.value===a),_=()=>{var H;const W=(H=$.current)==null?void 0:H.getBoundingClientRect();if(!W)return;const A=window.innerHeight-W.bottom;S({left:W.left,top:W.bottom,width:W.width,up:A<240&&W.top>A})},I=()=>{c||(_(),v(""),b(Math.max(0,o.findIndex(W=>W.value===a))),x(!0))},L=(W=!0)=>{var A;x(!1),W&&((A=$.current)==null||A.focus())},K=W=>{!W||W.disabled||(W.value!==a&&l(W.value),L())},B=(W,A)=>{for(let H=W+A;H>=0&&H<M.length;H+=A)if(!M[H].disabled)return b(H)};h.useLayoutEffect(()=>{if(!g)return;const W=H=>{var X;(X=E.current)!=null&&X.contains(H.target)||_()},A=H=>{var de,Se,Ne;const X=H.target;(de=$.current)!=null&&de.contains(X)||(Ne=(Se=E.current)==null?void 0:Se.parentElement)!=null&&Ne.contains(X)||L(!1)};return window.addEventListener("resize",W),window.addEventListener("scroll",W,!0),document.addEventListener("mousedown",A),()=>{window.removeEventListener("resize",W),window.removeEventListener("scroll",W,!0),document.removeEventListener("mousedown",A)}},[g]),h.useEffect(()=>{const W=E.current,A=W==null?void 0:W.querySelector(`[data-index="${y}"]`);!g||!W||!A||(A.offsetTop<W.scrollTop?W.scrollTop=A.offsetTop:A.offsetTop+A.offsetHeight>W.scrollTop+W.clientHeight&&(W.scrollTop=A.offsetTop+A.offsetHeight-W.clientHeight))},[g,y]);const ne=W=>{if(!g){["ArrowDown","ArrowUp","Enter"," "].includes(W.key)&&(W.preventDefault(),I());return}if(W.key==="ArrowDown")W.preventDefault(),B(y,1);else if(W.key==="ArrowUp")W.preventDefault(),B(y,-1);else if(W.key==="Home")W.preventDefault(),B(-1,1);else if(W.key==="End")W.preventDefault(),B(M.length,-1);else if(W.key==="Enter")W.preventDefault(),K(M[y]);else if(W.key==="Escape")W.preventDefault(),W.stopPropagation(),L();else if(W.key==="Tab")L(!1);else if(!R&&W.key.length===1){const A=Date.now();C.current={text:(A-C.current.at<700?C.current.text:"")+W.key.toLowerCase(),at:A};const H=M.findIndex(X=>!X.disabled&&X.label.toLowerCase().startsWith(C.current.text));H>=0&&b(H)}},Z=`${f}-label`,D=`${f}-list`,te=W=>`${f}-option-${W}`,Q=g&&k?e.jsxs("div",{className:"select-layer",style:{left:k.left,width:Math.max(k.width,200),...k.up?{bottom:window.innerHeight-k.top+(((ee=$.current)==null?void 0:ee.offsetHeight)??0)+4}:{top:k.top+4}},children:[R?e.jsx("input",{className:"select-filter","aria-label":`Filter ${t}`,"aria-controls":D,"aria-activedescendant":M[y]?te(y):void 0,autoFocus:!0,value:N,onChange:W=>{v(W.target.value),b(0)},onKeyDown:ne,placeholder:"Type to filter"}):null,e.jsxs("ul",{ref:E,id:D,role:"listbox","aria-labelledby":Z,className:"select-list",children:[M.map((W,A)=>e.jsxs("li",{id:te(A),"data-index":A,role:"option","aria-selected":W.value===a,"aria-disabled":W.disabled||void 0,className:A===y?"active":void 0,onMouseEnter:()=>b(A),onMouseDown:H=>H.preventDefault(),onClick:()=>K(W),children:[e.jsx("span",{children:W.label}),W.hint?e.jsxs("span",{className:"muted",children:[" ",W.hint]}):null]},W.value)),M.length?null:e.jsxs("li",{className:"muted",role:"presentation",children:["Nothing matches “",N.trim(),"”."]})]})]}):null;return e.jsxs("div",{className:"select-field",children:[e.jsx("span",{id:Z,className:n?"visually-hidden":"select-label",children:t}),e.jsxs("button",{ref:$,type:"button",role:"combobox",className:"select-button","aria-labelledby":Z,"aria-haspopup":"listbox","aria-expanded":g,"aria-controls":g?D:void 0,"aria-activedescendant":g&&!R&&M[y]?te(y):void 0,"aria-describedby":d,"aria-invalid":u||void 0,disabled:c,onClick:()=>g?L():I(),onKeyDown:ne,children:[e.jsx("span",{className:O?void 0:"muted",children:(O==null?void 0:O.label)??m}),e.jsx("span",{className:"select-chevron","aria-hidden":"true"})]}),Q?Qv.createPortal(Q,document.body):null]})}const $u=720,Tu=180,Xv=22;function sf(t){return new Date(`${t}T00:00:00Z`).toLocaleDateString("en-US",{month:"short",day:"numeric",timeZone:"UTC"})}function Zv(t,n,a,l){const o=Math.min(4,a/2,l),c=n-l;return`M${t},${n}V${c+o}Q${t},${c} ${t+o},${c}H${t+a-o}Q${t+a},${c} ${t+a},${c+o}V${n}Z`}function ek({series:t}){const[n,a]=h.useState(null),l=Math.max(1,...t.map(f=>f.count)),o=$u/t.length,c=Math.max(2,Math.min(28,o-2)),d=Tu-Xv,u=[0,Math.round(t.length/2),t.length-1].filter((f,g,x)=>x.indexOf(f)===g),m=n===null?null:t[n];return e.jsxs("figure",{className:"chart",children:[e.jsxs("svg",{viewBox:`0 0 ${$u} ${Tu}`,role:"img","aria-label":`Skill use per day, ${t.length} days, highest ${l}`,onMouseLeave:()=>a(null),children:[e.jsx("line",{x1:0,x2:$u,y1:d,y2:d,className:"chart-axis"}),t.map((f,g)=>{const x=f.count?Math.max(2,f.count/l*(d-8)):0,y=g*o+(o-c)/2;return e.jsxs("g",{onMouseEnter:()=>a(g),children:[e.jsx("rect",{x:g*o,y:0,width:o,height:d,className:"chart-hit"}),x?e.jsx("path",{className:`chart-bar ${n===g?"active":""}`,d:Zv(y,d,c,x)}):null]},f.day)}),u.map(f=>e.jsx("text",{x:f*o+o/2,y:Tu-6,textAnchor:f===0?"start":f===t.length-1?"end":"middle",className:"chart-label",children:sf(t[f].day)},f))]}),e.jsx("figcaption",{className:"muted",children:m?`${sf(m.day)}: ${m.count.toLocaleString("en-US")} ${m.count===1?"use":"uses"}`:"Point at a day to read its count."})]})}function Qd({days:t,onDays:n}){return e.jsx("div",{className:"segmented",role:"group","aria-label":"Time range",children:Kv.map(a=>e.jsxs("button",{type:"button",className:"secondary small","aria-pressed":a===t,onClick:()=>n(a),children:[a," days"]},a))})}function tk({me:t,repos:n}){const[a,l]=h.useState(30),[o,c]=h.useState(""),[d,u]=h.useState(null),[m,f]=h.useState(0),[g,x]=h.useState(null);return h.useEffect(()=>{let y=!0;return u(null),x(null),Ce.usageReport(a,o||void 0).then(b=>y&&u(b),b=>y&&x(b.message)),()=>{y=!1}},[a,o,m]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"toolbar",children:[e.jsx(Qd,{days:a,onDays:l}),e.jsx(Pe,{label:"Repository",value:o,onChange:c,options:[{value:"",label:"Every repository"},...(n??[]).map(y=>({value:y.id,label:y.name,hint:y.team}))]}),d!=null&&d.byTeam.length?e.jsxs("span",{className:"toolbar-end",children:[e.jsx("a",{className:"button secondary small",href:Ce.usageExport(a,"csv",o||void 0),download:!0,children:"Export CSV"}),e.jsx("a",{className:"button secondary small",href:Ce.usageExport(a,"json",o||void 0),download:!0,children:"Export JSON"})]}):null]}),g?e.jsx(be,{what:"skill use",reason:g,onRetry:()=>f(m+1),panel:!0}):d?e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"panel","aria-labelledby":"usage-chart-h",children:[e.jsxs("h2",{id:"usage-chart-h",children:["Skill use per day ",e.jsxs("span",{className:"count",children:[d.total.toLocaleString("en-US")," in ",d.days," days"]})]}),d.total?e.jsx(ek,{series:d.series}):e.jsx("p",{className:"muted",children:"No skill use reported in this range. A team reports once it is asked from its repository's page and each teammate agrees on their own machine."}),d.total?e.jsxs("details",{children:[e.jsx("summary",{children:"Show as a table"}),e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Day"}),e.jsx("th",{children:"Uses"})]})}),e.jsx("tbody",{children:d.series.map(y=>e.jsxs("tr",{children:[e.jsx("td",{children:y.day}),e.jsx("td",{children:y.count})]},y.day))})]})]}):null]}),d.scope?e.jsx("p",{className:"muted",children:d.byTeam.length?`By team and by skill for the teams you own: ${d.scope.teams.join(", ")}. Owners and admins see every team.`:`The teams you own (${d.scope.teams.join(", ")}) reported no skill use in this range.`}):null,d.total&&!d.byTeam.length&&!d.scope?e.jsx("p",{className:"muted",children:"Owners and admins see use by team and by skill; an owner can show it to members under Settings, Privacy."}):null,d.total&&d.byTeam.length?e.jsxs("div",{className:"tiles",children:[e.jsxs("section",{className:"panel","aria-labelledby":"by-team-h",children:[e.jsx("h2",{id:"by-team-h",children:"By team"}),e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Team"}),e.jsx("th",{children:"Uses"})]})}),e.jsx("tbody",{children:d.byTeam.map(y=>e.jsxs("tr",{children:[e.jsx("td",{children:y.team}),e.jsx("td",{children:e.jsx(nk,{count:y.count,total:d.total})})]},y.team))})]})]}),e.jsxs("section",{className:"panel","aria-labelledby":"by-skill-h",children:[e.jsxs("h2",{id:"by-skill-h",children:["By skill ",e.jsx("span",{className:"count",children:d.bySkill.length})]}),e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Skill"}),e.jsx("th",{children:"Team"}),e.jsx("th",{children:"Uses"})]})}),e.jsx("tbody",{children:d.bySkill.slice(0,20).map(y=>e.jsxs("tr",{children:[e.jsx("td",{className:"mono",children:y.skill}),e.jsx("td",{children:y.team}),e.jsx("td",{children:y.count})]},`${y.repoId}/${y.skill}`))})]}),d.bySkill.length>20?e.jsxs("p",{className:"muted",children:["The export lists the other ",d.bySkill.length-20,"."]}):null]})]}):null]}):e.jsx(he,{what:"skill use",panel:!0}),e.jsx("p",{className:"muted",children:"Only skill names and counts arrive, from teams that were asked and teammates who agreed. No one's name, prompt or file is reported."}),t.mode==="local"?null:e.jsx(Vv,{days:a})]})}function nk({count:t,total:n}){return e.jsxs("span",{className:"share",children:[e.jsx("span",{className:"share-bar","aria-hidden":"true",children:e.jsx("span",{style:{width:`${Math.round(t/n*100)}%`}})}),t.toLocaleString("en-US")]})}function sk({me:t}){const[n,a]=h.useState(30),[l,o]=h.useState(null),[c,d]=h.useState(null),[u,m]=h.useState(0);return h.useEffect(()=>{let f=!0;return o(null),d(null),Ce.leaderboard(n).then(g=>f&&o(g),g=>f&&d(g.message)),()=>{f=!1}},[n,u]),!Me(t)&&c?e.jsx("div",{className:"panel",children:e.jsx("p",{className:"muted",children:c})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"toolbar",children:e.jsx(Qd,{days:n,onDays:a})}),l!=null&&l.scope?e.jsxs("p",{className:"muted",children:["Ranked among the teams you own: ",l.scope.teams.join(", "),". Owners and admins see every team."]}):null,c?e.jsx(be,{what:"the leaderboard",reason:c,onRetry:()=>m(f=>f+1),panel:!0}):l?l.teams.length?e.jsxs("div",{className:"tiles",children:[e.jsxs("section",{className:"panel","aria-labelledby":"lb-teams-h",children:[e.jsx("h2",{id:"lb-teams-h",children:"Teams"}),e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Rank"}),e.jsx("th",{children:"Team"}),e.jsx("th",{children:"Skills used"}),e.jsx("th",{children:"Uses"})]})}),e.jsx("tbody",{children:l.teams.map((f,g)=>e.jsxs("tr",{children:[e.jsx("td",{children:g+1}),e.jsx("td",{children:f.team}),e.jsx("td",{children:f.skills}),e.jsx("td",{children:f.count})]},f.team))})]})]}),e.jsxs("section",{className:"panel","aria-labelledby":"lb-skills-h",children:[e.jsx("h2",{id:"lb-skills-h",children:"Skills"}),e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Rank"}),e.jsx("th",{children:"Skill"}),e.jsx("th",{children:"Team"}),e.jsx("th",{children:"Uses"})]})}),e.jsx("tbody",{children:l.skills.map((f,g)=>e.jsxs("tr",{children:[e.jsx("td",{children:g+1}),e.jsx("td",{className:"mono",children:f.skill}),e.jsx("td",{children:f.team}),e.jsx("td",{children:f.count})]},`${f.repoId}/${f.skill}`))})]})]})]}):e.jsx("div",{className:"panel",children:e.jsxs("p",{className:"muted",children:["No skill use reported in the last ",l.days," days."]})}):e.jsx(he,{what:"the leaderboard",panel:!0}),e.jsx("p",{className:"muted",children:"Teams and skills are ranked; people are not, since a usage report carries no one's name."})]})}const Yg=t=>t===null?"—":`${Math.round(t*100)}%`,wi=t=>t?`${t.median} h (p90 ${t.p90} h)`:"—";function Eu({rows:t,first:n}){return e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:n}),e.jsx("th",{scope:"col",children:"Merged"}),e.jsx("th",{scope:"col",children:"AI-assisted"}),e.jsx("th",{scope:"col",children:"Share"}),e.jsx("th",{scope:"col",children:"Time to merge, AI-assisted"}),e.jsx("th",{scope:"col",children:"Time to merge, others"})]})}),e.jsx("tbody",{children:t.map(a=>e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:a.label}),e.jsx("td",{children:a.merged}),e.jsx("td",{children:a.aiAssisted}),e.jsx("td",{children:Yg(a.share)}),e.jsx("td",{children:wi(a.hoursToMerge.ai)}),e.jsx("td",{children:wi(a.hoursToMerge.other)})]},a.key))})]})}function ak(){const[t,n]=h.useState(30),[a,l]=h.useState(null),[o,c]=h.useState(0),[d,u]=h.useState(null);return h.useEffect(()=>{let m=!0;return l(null),u(null),Hv.read(t).then(f=>m&&l(f),f=>m&&u(f.message)),()=>{m=!1}},[t,o]),e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"toolbar",children:e.jsx(Qd,{days:t,onDays:n})}),d?e.jsx(be,{what:"AI-assisted requests",reason:d,onRetry:()=>c(o+1),panel:!0}):a?e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"panel","aria-labelledby":"ai-total-h",children:[e.jsxs("h2",{id:"ai-total-h",children:["Merged requests ",e.jsxs("span",{className:"count",children:["last ",a.days," days"]})]}),e.jsxs("dl",{className:"facts wide",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Merged"}),e.jsx("dd",{children:a.total.merged})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"AI-assisted"}),e.jsxs("dd",{children:[a.total.aiAssisted," (",Yg(a.total.share),")"]})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Time to merge, AI-assisted"}),e.jsx("dd",{children:wi(a.total.hoursToMerge.ai)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Time to merge, others"}),e.jsx("dd",{children:wi(a.total.hoursToMerge.other)})]})]}),a.byAgent.some(m=>m.requests)?e.jsx("p",{children:a.byAgent.filter(m=>m.requests).map(m=>`${m.label}: ${m.requests}`).join(" · ")}):null,e.jsx("p",{className:"muted",children:"Read from each repository's history: a request counts as AI-assisted when one of its commits carries a coding agent's trailer, such as Co-Authored-By: Claude. An agent that leaves none, a fast-forward merge and a squash without its number are not counted, so these are a floor. Time to merge runs from a request's first commit."}),a.truncated.length?e.jsxs("p",{className:"muted",children:["Only the latest requests were read in ",a.truncated.join(", "),"; pick a shorter range for all of them."]}):null]}),a.total.merged?e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"panel","aria-labelledby":"ai-teams-h",children:[e.jsx("h2",{id:"ai-teams-h",children:"By team"}),e.jsx(Eu,{first:"Team",rows:a.byTeam.map(m=>({key:m.team,label:m.team,...m}))})]}),e.jsxs("section",{className:"panel","aria-labelledby":"ai-repos-h",children:[e.jsx("h2",{id:"ai-repos-h",children:"By repository"}),e.jsx(Eu,{first:"Repository",rows:a.byRepo.map(m=>({key:m.repoId,label:`${m.team} · ${m.repoId}`,...m}))})]}),a.byPerson?e.jsxs("section",{className:"panel","aria-labelledby":"ai-people-h",children:[e.jsxs("h2",{id:"ai-people-h",children:["By person ",e.jsx("span",{className:"count",children:"owners and admins see this"})]}),e.jsx(Eu,{first:"Person",rows:a.byPerson.map(m=>({key:m.email,label:`${m.name} (${m.email})`,...m}))})]}):null]}):e.jsx("p",{className:"muted panel",children:"No request was merged in this range."})]}):e.jsx(he,{what:"AI-assisted requests",panel:!0})]})}function rk(t){let n=t===null?"":String(t);return/^[=+\-@\t\r]/.test(n)&&(n=`'${n}`),/[",\r\n]/.test(n)?`"${n.replaceAll('"','""')}"`:n}function lk(t,n){return`${[t,...n].map(a=>a.map(rk).join(",")).join(`\r
|
|
41
|
+
`)}\r
|
|
42
|
+
`}const Dl=50;function Li({page:t,total:n,pageSize:a=Dl,more:l,onPage:o,label:c}){const d=Math.max(t,Math.ceil(n/a));return d<=1&&!l?null:e.jsxs("nav",{className:"pager","aria-label":c,children:[e.jsx("button",{type:"button",className:"secondary small",disabled:t<=1,onClick:()=>o(t-1),children:"Previous"}),e.jsxs("span",{children:["Page ",t," of ",d]}),e.jsx("button",{type:"button",className:"secondary small",disabled:l===void 0?t>=d:!l,onClick:()=>o(t+1),children:"Next"})]})}function Jd(t,n,a=Dl){const l=Math.max(1,Math.ceil(t.length/a)),o=Math.min(n,l);return{shown:t.slice((o-1)*a,o*a),page:o}}const ok=["activity","work","repositories","tasks","team","controls","integrations","settings","welcome"];function Ts(t){const[n,a,...l]=t.split("/").filter(Boolean).map(decodeURIComponent);return{org:n??null,section:ok.includes(a??"")?a:null,named:a!==void 0,rest:l}}function Te(t,...n){return`/${[t,...n].map(encodeURIComponent).join("/")}`}function ik(t,n){var o,c;const a=new URLSearchParams(t),l=((o=a.get("url"))==null?void 0:o.trim())||((c=a.get("text"))==null?void 0:c.trim());return l?`${Te(n,"work","new")}?${new URLSearchParams({issue:l})}`:a.get("go")==="tasks"?Te(n,"tasks"):a.get("go")==="my-work"?`${Te(n,"work")}?mine=1`:Te(n,"tasks")}function ck(t,n,a){return n==="activity"&&!a.length||n==="repositories"&&(!a.length||a.length===1&&a[0]==="requests")?Te(t,"tasks"):n==="controls"?a.length?Te(t,"team","policies",...a):Te(t,"team"):null}function re(...t){return Te(Ts(window.location.pathname).org??"",...t)}function uk(t,n){const[a]=t.replace(/^#/,"").split("?"),[l,o]=(a??"").split("/").filter(Boolean);return a===void 0||!a.startsWith("/")||l==="join"?null:l==="repo"&&o?Te(n,"repositories",o):l==="tasks"?o?Te(n,"tasks",o):Te(n,"tasks"):l==="requests"?Te(n,"tasks"):l==="people"?Te(n,"settings","members"):!l||l==="login"?Te(n,"tasks"):Te(n,...a.split("/").filter(Boolean))}const ud="orchestrator:navigate";function Ge(t,n=!1){n?window.history.replaceState(null,"",t):window.history.pushState(null,"",t),window.dispatchEvent(new Event(ud))}function Bl(){const t=()=>({pathname:window.location.pathname,search:window.location.search,hash:window.location.hash}),[n,a]=h.useState(t);return h.useEffect(()=>{const l=()=>a(t());return window.addEventListener("popstate",l),window.addEventListener("hashchange",l),window.addEventListener(ud,l),()=>{window.removeEventListener("popstate",l),window.removeEventListener("hashchange",l),window.removeEventListener(ud,l)}},[]),n}function af(t){var l,o;if(t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return;const n=(o=(l=t.target)==null?void 0:l.closest)==null?void 0:o.call(l,"a");if(!n||n.target||n.hasAttribute("download"))return;const a=new URL(n.href,window.location.href);a.origin!==window.location.origin||a.pathname.startsWith("/api/")||a.hash&&a.pathname===window.location.pathname&&a.search===window.location.search||(t.preventDefault(),Ge(a.pathname+a.search+a.hash))}const Vg=["gitlab","github","gitea"],La=t=>t.split("/").map(encodeURIComponent).join("/"),rf=new Set(["127.0.0.1","localhost","[::1]"]),rt={gitlab:{kind:"gitlab",label:"GitLab",capabilities:{term:"merge request",review:"approve-only",checksAlwaysReport:!0,templates:[".gitlab/merge_request_templates/Default.md",".gitlab/merge_request_templates/*.md"]},projectShape:"group/project",homeHosts:["gitlab.com"],gitUser:"oauth2",allowsHost:()=>!0,apiUrlFor:t=>`${t.origin}/api/v4`,requestRef:t=>`refs/merge-requests/${t}/head`,newRequestUrl:(t,n,a,l)=>`${t.replace(/\/+$/,"")}/${La(n)}/-/merge_requests/new?${new URLSearchParams({"merge_request[source_branch]":a,"merge_request[target_branch]":l})}`,credentials:{tokenPage:t=>`${t.replace(/\/+$/,"")}/-/user_settings/personal_access_tokens?name=TeamHandbook&scopes=api`,scopes:["api"]},visibilities:["private","internal","public"],group:{label:"Group (optional)",placeholder:"acme/platform",meaning:"The group or subgroup the repository is made in; left empty, the connected account's own namespace holds it."},emptyListHint:"Give the GitLab account you connected access to the team's repository, then read the list again."},github:{kind:"github",label:"GitHub",capabilities:{term:"pull request",review:"approve-or-request-changes",checksAlwaysReport:!1,templates:[".github/pull_request_template.md","pull_request_template.md","docs/pull_request_template.md",".github/PULL_REQUEST_TEMPLATE/*.md"]},projectShape:"owner/repository",homeHosts:["github.com"],gitUser:"x-access-token",allowsHost:t=>t==="github.com"||rf.has(t),apiUrlFor:t=>rf.has(t.hostname)?`${t.origin}/api`:"https://api.github.com",requestRef:t=>`refs/pull/${t}/head`,newRequestUrl:(t,n,a,l)=>`${t.replace(/\/+$/,"")}/${La(n)}/compare/${La(l)}...${La(a)}?expand=1`,credentials:{tokenPage:t=>`${t.replace(/\/+$/,"")}/settings/personal-access-tokens/new`,scopes:["Contents: read and write","Pull requests: read and write","Commit statuses: read and write","Metadata: read"]},visibilities:["private","public"],group:null,emptyListHint:"Where the app is installed on chosen repositories only, add the team's repository to its installation on GitHub, then read the list again."},gitea:{kind:"gitea",label:"Gitea",capabilities:{term:"pull request",review:"approve-or-request-changes",checksAlwaysReport:!1,templates:["PULL_REQUEST_TEMPLATE.md","pull_request_template.md",".gitea/PULL_REQUEST_TEMPLATE.md",".gitea/pull_request_template.md",".github/PULL_REQUEST_TEMPLATE.md",".github/pull_request_template.md"]},projectShape:"owner/repository",homeHosts:["gitea.com","codeberg.org"],gitUser:"oauth2",allowsHost:()=>!0,apiUrlFor:t=>`${t.origin}/api/v1`,requestRef:t=>`refs/pull/${t}/head`,newRequestUrl:(t,n,a,l)=>`${t.replace(/\/+$/,"")}/${La(n)}/compare/${La(l)}...${La(a)}`,credentials:{tokenPage:t=>`${t.replace(/\/+$/,"")}/user/settings/applications`,scopes:["write:repository","write:issue","read:user"]},visibilities:["private","public"],group:{label:"Organization (optional)",placeholder:"acme",meaning:"The organization the repository is made in; left empty, the account whose token is connected owns it."},emptyListHint:"Give the Gitea account whose token is connected access to the team's repository, then read the list again."}};function Xd(t,n){const{term:a}=rt[t].capabilities;return`${a.charAt(0).toUpperCase()}${a.slice(1)} ${t==="gitlab"?"!":"#"}${n} on ${rt[t].label}`}function Ar(t){return typeof t=="string"&&Vg.includes(t)}const dk={waiting:"waiting its turn",working:"working","usage-limit":"at the usage limit","waiting-machine":"waiting for your machine","needs-you":"needs you",kept:"kept on this machine","in-review":"in review",merged:"merged",undone:"undone",failed:"failed",stopped:"stopped","finished-nothing-changed":"finished, nothing changed"},hk={waiting:"neutral",working:"info","usage-limit":"warn","waiting-machine":"warn","needs-you":"warn",kept:"ok","in-review":"info",merged:"ok",undone:"neutral",failed:"error",stopped:"neutral","finished-nothing-changed":"neutral"};function Lr(t,n){const a=t==="in-review"&&n&&Ar(n.kind)?` on ${rt[n.kind].label}`:"";return{word:`${dk[t]}${a}`,tone:hk[t]}}function Ba(t){var a,l,o,c;if(t.state)return t.state;if(t.next==="answer"||t.next==="review"||t.next==="follow-up"||t.attention||t.status==="needs-answer"||t.status==="failed"&&t.question&&!t.question.answer||(a=t.requests)!=null&&a.some(d=>d.status==="pending"&&d.responseCapability==="live"))return"needs-you";if(t.waitingFor==="limit")return"usage-limit";if(t.waitingFor)return"waiting-machine";if(t.status==="queued")return"waiting";if(t.status==="running")return"working";if(t.status==="cancelled"||t.status==="interrupted"||t.next==="continue")return"stopped";if(t.status==="failed"||t.next==="retry")return"failed";const n=t.changes;return n!=null&&n.undone||((l=t.request)==null?void 0:l.status)==="closed"?"undone":((o=t.request)==null?void 0:o.status)==="merged"?t.request.provider==="local"?"kept":"merged":n!=null&&n.kept||t.phase==="merged"?t.request&&t.request.provider!=="local"?"merged":"kept":t.phase==="failed"?"undone":((c=t.request)==null?void 0:c.status)==="open"&&t.request.provider!=="local"&&t.request.provider!==void 0?"in-review":"needs-you"}const Ru=30,mk=["waiting","working","usage-limit","waiting-machine","needs-you","kept","in-review","merged","undone","failed","stopped"];function pk(t,n,a,l){return n.map(o=>({at:o.createdAt,title:o.title,repoId:o.repoId,team:o.team,state:Ba(o),status:Lr(Ba(o),o.forge).word,by:l&&o.createdBy===l?"you":o.createdBy,to:Te(t,"tasks",o.id)})).filter(o=>o.at>=a).sort((o,c)=>c.at.localeCompare(o.at))}function fk(t){return lk(["time","title","repository","team","status","by"],t.map(n=>[n.at,n.title,n.repoId,n.team,n.status,n.by]))}function lf(t,n,a){const l=URL.createObjectURL(new Blob([a],{type:n})),o=document.createElement("a");o.href=l,o.download=t,o.click(),URL.revokeObjectURL(l)}function gk({repos:t,me:n}){const[a,l]=h.useState(null),[o,c]=h.useState(null),[d,u]=h.useState(""),[m,f]=h.useState(""),[g,x]=h.useState(""),[y,b]=h.useState(1),N=()=>{const C=new Date(Date.now()-Ru*864e5).toISOString();c(null),ge.since(C).then(R=>l(pk(Ts(window.location.pathname).org??"",R,C,n)),R=>c(R.message))};h.useEffect(N,[t,n]);const v=g.trim().toLowerCase(),k=(a??[]).filter(C=>(!d||C.state===d)&&(!m||C.repoId===m)&&(!v||`${C.title} ${C.by} ${C.status}`.toLowerCase().includes(v))),S=Jd(k,y),$=C=>R=>{C(R.target.value),b(1)},E=new Date().toISOString().slice(0,10);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"toolbar",children:[e.jsx(Pe,{label:"State",value:d,onChange:C=>$(u)({target:{value:C}}),options:[{value:"",label:"Every state"},...mk.map(C=>({value:C,label:Lr(C,null).word}))]}),e.jsx(Pe,{label:"Repository",value:m,onChange:C=>$(f)({target:{value:C}}),options:[{value:"",label:"Every repository"},...(t??[]).map(C=>({value:C.id,label:C.name,hint:C.team}))]}),e.jsxs("label",{className:"inline-label",children:["Find",e.jsx("input",{type:"search",value:g,onChange:$(x)})]}),e.jsxs("span",{className:"toolbar-end",children:[e.jsx("button",{type:"button",className:"secondary small",disabled:!k.length,onClick:()=>lf(`logs-${E}.csv`,"text/csv",fk(k)),children:"Export CSV"}),e.jsx("button",{type:"button",className:"secondary small",disabled:!k.length,onClick:()=>lf(`logs-${E}.json`,"application/json",JSON.stringify(k,null,2)),children:"Export JSON"})]})]}),e.jsxs("section",{className:"panel","aria-labelledby":"logs-h",children:[e.jsxs("h2",{id:"logs-h",children:["Tasks, last ",Ru," days ",e.jsx("span",{className:"count",children:a?k.length:""})]}),o?e.jsx(be,{what:"the tasks",reason:o,onRetry:N}):a?k.length?e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Time"}),e.jsx("th",{children:"What"}),e.jsx("th",{children:"Repository"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"By"})]})}),e.jsx("tbody",{children:S.shown.map(C=>e.jsxs("tr",{children:[e.jsx("td",{children:C.at.slice(0,16).replace("T"," ")}),e.jsx("td",{children:e.jsx("a",{href:C.to,children:C.title})}),e.jsx("td",{children:C.repoId}),e.jsx("td",{children:C.status}),e.jsx("td",{children:C.by})]},`${C.to}:${C.title}`))})]}):e.jsx("p",{className:"muted",children:a.length?"Nothing matches these filters.":`Nothing ran or was proposed in the last ${Ru} days.`}):e.jsx(he,{what:"the tasks"}),e.jsx(Li,{page:S.page,total:k.length,pageSize:Dl,onPage:b,label:"Pages of the log"})]})]})}function Qg(t){return t.actor.kind==="orchestrator"?"System":t.actor.name||t.actor.email||"someone removed since"}function xk(t){const[n,...a]=t.changes??[];if(!n)return t.detail;const l=o=>o===null?"none":o;return`${n.field}: ${l(n.from)} → ${l(n.to)}${a.length?` +${a.length}`:""}`}function jk({me:t,repos:n}){var $,E;const[a,l]=h.useState({}),[o,c]=h.useState(""),[d,u]=h.useState(null),[m,f]=h.useState(!1),[g,x]=h.useState(null),[y,b]=h.useState(!1);if(h.useEffect(()=>{if(!Me(t))return;let C=!0;return u(null),x(null),Ce.audit(a,null).then(R=>{C&&(R===null?f(!0):u([R]))},R=>C&&x(R.message)),()=>{C=!1}},[a]),!Me(t))return e.jsx("div",{className:"panel",children:e.jsx("p",{className:"muted",children:"Owners and admins read the audit log."})});if(m)return e.jsx("div",{className:"panel",children:e.jsx("p",{className:"muted",children:"Audit recording has not started. Every request the orchestrator opens is on the Logs page meanwhile."})});const N=()=>{var R;const C=(R=d==null?void 0:d.at(-1))==null?void 0:R.next;C&&(b(!0),Ce.audit(a,C).then(P=>{P&&u([...d??[],P]),b(!1)},P=>{x(P.message),b(!1)}))},v=(d==null?void 0:d.flatMap(C=>C.events))??[],k=($=d==null?void 0:d[0])==null?void 0:$.retentionDays,S=C=>{C.preventDefault();const R=new FormData(C.currentTarget),P=M=>String(R.get(M)??"").trim()||void 0;l({repo:o||void 0,kind:P("kind"),since:P("since"),until:P("until")})};return e.jsxs(e.Fragment,{children:[e.jsxs("form",{className:"toolbar",onSubmit:S,"aria-label":"Filter the audit log",children:[e.jsx(Pe,{label:"Repository",value:o,onChange:c,options:[{value:"",label:"Every repository"},...(n??[]).map(C=>({value:C.id,label:C.name,hint:C.team}))]}),e.jsxs("label",{className:"inline-label",children:["Action",e.jsx("input",{name:"kind",defaultValue:a.kind??"",placeholder:"request"})]}),e.jsxs("label",{className:"inline-label",children:["From",e.jsx("input",{name:"since",type:"date",defaultValue:a.since??""})]}),e.jsxs("label",{className:"inline-label",children:["To",e.jsx("input",{name:"until",type:"date",defaultValue:a.until??""})]}),e.jsx("button",{type:"submit",className:"secondary small",children:"Filter"}),e.jsxs("span",{className:"toolbar-end",children:[e.jsx("a",{className:"button secondary small",href:Ce.auditExport(a,"csv"),download:!0,children:"Export CSV"}),e.jsx("a",{className:"button secondary small",href:Ce.auditExport(a,"jsonl"),download:!0,children:"Export JSON Lines"})]})]}),e.jsxs("section",{className:"panel","aria-labelledby":"audit-h",children:[e.jsxs("h2",{id:"audit-h",children:["Changes ",k?e.jsxs("span",{className:"count",children:["kept ",k," days"]}):null]}),g?e.jsx(be,{what:"changes",reason:g,onRetry:()=>l({...a})}):d?v.length?e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Time"}),e.jsx("th",{children:"Action"}),e.jsx("th",{children:"Resource"}),e.jsx("th",{children:"Change"}),e.jsx("th",{children:"Changed by"})]})}),e.jsx("tbody",{children:v.map(C=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("a",{href:re("activity","audit",C.id),children:C.at.slice(0,16).replace("T"," ")})}),e.jsx("td",{className:"mono",children:C.kind}),e.jsx("td",{children:[C.repoId,C.subject].filter(Boolean).join(" · ")}),e.jsx("td",{children:xk(C)}),e.jsx("td",{children:Qg(C)})]},C.id))})]}):e.jsx("p",{className:"muted",children:"No change matches these filters."}):e.jsx(he,{what:"changes"}),(E=d==null?void 0:d.at(-1))!=null&&E.next?e.jsx("div",{className:"actions",children:e.jsx("button",{type:"button",className:"secondary small",disabled:y,onClick:N,children:"Show older changes"})}):null]})]})}const yk={user:"Person",service:"Service account",orchestrator:"The orchestrator itself"};function vk({me:t,id:n}){var y;const[a,l]=h.useState(null),[o,c]=h.useState(null),[d,u]=h.useState(null);h.useEffect(()=>{Me(t)&&(l(null),c(null),Ce.event(n).then(l,b=>c(b instanceof Os?"This organization's audit log has no such change; it is from another organization, or older than the log keeps.":b.message)))},[n]);const m=e.jsx("p",{children:e.jsx("a",{href:re("activity","audit"),children:"All changes"})});if(!Me(t))return e.jsx("div",{className:"panel",children:e.jsx("p",{className:"muted",children:"Owners and admins read the audit log."})});if(o)return e.jsxs("div",{className:"panel",role:"alert",children:[e.jsx("p",{className:"error",children:o}),m]});if(!a)return e.jsx(he,{what:"the change",panel:!0});const{event:f,link:g}=a,x=()=>{if(!navigator.clipboard)return u("select it and copy");navigator.clipboard.writeText(g).then(()=>u("copied"),()=>u("select it and copy"))};return e.jsxs(e.Fragment,{children:[m,e.jsxs("section",{className:"panel","aria-labelledby":"entry-h",children:[e.jsx("h2",{id:"entry-h",children:e.jsx("span",{className:"mono",children:f.kind})}),e.jsxs("dl",{className:"facts wide",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Time"}),e.jsxs("dd",{children:[f.at.replace("T"," ").slice(0,19)," UTC"]})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Changed by"}),e.jsxs("dd",{children:[Qg(f),f.actor.email&&f.actor.kind!=="orchestrator"?e.jsxs("span",{className:"muted",children:[" · ",f.actor.email]}):null]})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Kind of actor"}),e.jsx("dd",{children:yk[f.actor.kind]})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Repository"}),e.jsx("dd",{children:f.repoId??"none"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Resource"}),e.jsx("dd",{className:"mono",children:f.subject??"none"})]})]}),e.jsx("p",{children:f.detail})]}),(y=f.changes)!=null&&y.length?e.jsxs("section",{className:"panel","aria-labelledby":"entry-changes-h",children:[e.jsxs("h2",{id:"entry-changes-h",children:["Fields changed ",e.jsx("span",{className:"count",children:f.changes.length})]}),e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Field"}),e.jsx("th",{children:"Before"}),e.jsx("th",{children:"After"})]})}),e.jsx("tbody",{children:f.changes.map(b=>e.jsxs("tr",{children:[e.jsx("td",{children:b.field}),e.jsx("td",{className:"mono",children:b.from??"none"}),e.jsx("td",{className:"mono",children:b.to??"none"})]},b.field))})]})]}):null,e.jsxs("section",{className:"panel","aria-labelledby":"entry-link-h",children:[e.jsx("h2",{id:"entry-link-h",children:"Link to this change"}),e.jsxs("p",{children:[e.jsx("code",{className:"link",children:g})," ",e.jsx("button",{type:"button",className:"secondary small",onClick:x,children:"Copy link"}),d?e.jsxs("span",{className:"muted",role:"status",children:[" ",d]}):null]}),e.jsx("p",{className:"muted",children:"It opens for owners and admins of this organization."})]})]})}const Jg=[{id:"usage",label:"Usage"},{id:"leaderboard",label:"Leaderboard",for:"team owners"},{id:"ai",label:"AI requests"},{id:"logs",label:"Logs"},{id:"audit",label:"Audit",for:"managers"},{id:"news",label:"What's new"}],ui=[{id:"account",label:"Your account"},{id:"code",label:"Where your code lives"},{id:"task-limits",label:"Task limits"},{id:"members",label:"Members"},{id:"service-accounts",label:"Service accounts"},{id:"api-keys",label:"API keys"},{id:"access",label:"Access"},{id:"task-secrets",label:"Task secrets"},{id:"agents",label:"Agent readiness"},{id:"machines",label:"Your machines"},{id:"security",label:"Security"},{id:"privacy",label:"Privacy"},{id:"organization",label:"Organization"},{id:"updates",label:"Updates"}],kk=["account","members","api-keys","access","machines"],Xg=["account","code","task-limits","agents","task-secrets","privacy","updates"],bk=["usage","leaderboard","audit","ai"];function Zd(t,n){return t.mode!=="local"||!bk.includes(n)}function Zg(t){return Jg.filter(n=>Zd(t,n.id)&&(!("for"in n)||Me(t)||n.for==="team owners"&&t.ownedTeams.length>0))}function eh(t,n){return t.mode==="local"?Xg.includes(n):n!=="updates"&&(n!=="machines"||t.runners===!0)}function ex(t){return t.mode==="local"?ui.filter(a=>Xg.includes(a.id)):(Me(t)?[...ui]:ui.filter(a=>kk.includes(a.id))).filter(a=>eh(t,a.id))}function Sr({org:t,path:n}){return e.jsxs("div",{className:"page",children:[e.jsx("header",{className:"page-head",children:e.jsx("h1",{children:"Page not found"})}),e.jsxs("section",{className:"panel","aria-label":"Page not found",children:[e.jsxs("p",{children:["This orchestrator has no page at ",e.jsx("code",{className:"link",children:n}),". The link is mistyped, or it is from a page that has moved."]}),e.jsx("p",{children:e.jsxs("a",{className:"button secondary",href:Te(t,"tasks"),children:["Back to ",t]})})]})]})}const dd={approval:{label:"needs your approval",tone:"warn",title:t=>`${t} needs your approval`},answer:{label:"asks you a question",tone:"warn",title:t=>`${t} asks you a question`},limited:{label:"at the usage limit",tone:"warn",title:t=>`${t} paused at a usage limit`},"follow-up":{label:"follow-up suggested",tone:"warn",title:t=>`A teammate suggests a follow-up on ${t}`},review:{label:"needs review",tone:"warn",title:t=>`${t} needs review`},failed:{label:"failed",tone:"error",title:t=>`${t} failed`}},of=["approval","answer","limited","follow-up","review","failed"];function tx(t){var a,l,o,c;if(t.status!=="needs-review")return null;const n=t.result==="changes";return(a=t.changes)!=null&&a.undone||n&&t.phase==="failed"?"undone":(l=t.changes)!=null&&l.kept||n&&t.phase==="merged"?"kept":n?null:((o=t.request)==null?void 0:o.status)==="closed"||(c=t.requests)!=null&&c.length&&t.requests.every(d=>d.status==="closed")||t.phase==="failed"?"closed":null}function El(t){var n;return t.attention?t.attention:t.status==="running"&&Ba(t)==="needs-you"?"approval":t.status==="needs-answer"||t.status==="failed"&&t.question&&!t.question.answer?"answer":(n=t.suggestions)!=null&&n.some(a=>a.canAnswer)?"follow-up":tx(t)?null:t.phase==="review"||!t.phase&&t.status==="needs-review"?"review":t.phase==="failed"||t.status==="failed"?"failed":null}function wk(t,n){return of.indexOf(t)-of.indexOf(n)}function Nk(t,n,a,l){if(!t)return[];const o=[];for(const c of n){const d=El(c);!d||t.get(c.id)===d||a.has(`${c.id}:${d}`)||c.id===l||o.push({id:c.id,attention:d})}return o}function Sk(t,n,a,l){return t.map(d=>{const u=d.createdBy===n?El(d):null;return{task:d,call:u,unread:u!==null&&!a.has(`${d.id}:${u}`)}}).filter(d=>l==="all").map((d,u)=>({row:d,at:u})).sort((d,u)=>(d.row.call&&u.row.call?wk(d.row.call,u.row.call):d.row.call?-1:u.row.call?1:0)||d.at-u.at).map(({row:d})=>d)}const hd=new Map,md="orchestrator:pref";function Es(t){if(hd.has(t))return hd.get(t);try{return window.localStorage.getItem(t)}catch{return null}}function Rs(t,n){hd.set(t,n);try{n===null?window.localStorage.removeItem(t):window.localStorage.setItem(t,n)}catch{}window.dispatchEvent(new Event(md))}function Ps(t){const[n,a]=h.useState(()=>Es(t));return h.useEffect(()=>{const l=()=>a(Es(t));return window.addEventListener(md,l),()=>window.removeEventListener(md,l)},[t]),[n,l=>Rs(t,l)]}const nx="orchestrator.theme";function sx(t){t==="light"||t==="dark"?document.documentElement.dataset.theme=t:delete document.documentElement.dataset.theme}const th="orchestrator.attention.notify",ax="orchestrator.attention.seen",Ck=500,$k=15e3,Tk=6e4,Ek=1440*60*1e3;function nh(){try{return new Set(JSON.parse(localStorage.getItem(ax)??"[]"))}catch{return new Set}}function Rk(t){try{localStorage.setItem(ax,JSON.stringify([...t].slice(-Ck)))}catch{}}function Pk(){var t;return((t=/\/tasks\/([^/]+)$/.exec(window.location.pathname))==null?void 0:t[1])??null}let Pu=null;function Ak(t){const n=document.createElement("canvas");n.width=n.height=64;const a=n.getContext("2d");if(!a)return;a.fillStyle="#2856d8",a.beginPath(),a.roundRect(0,0,64,64,14),a.fill(),a.fillStyle="#ffffff",a.fillRect(18,18,28,7),a.fillRect(28.5,25,7,21),a.textAlign="center",a.textBaseline="middle",t>0&&(a.fillStyle="#b42318",a.beginPath(),a.arc(46,18,16,0,Math.PI*2),a.fill(),a.fillStyle="#ffffff",a.font="bold 22px sans-serif",a.fillText(t>9?"9+":String(t),46,19));const l=n.toDataURL("image/png");t===0&&(Pu=l);let o=document.querySelector('link[rel="icon"]');o||(o=document.createElement("link"),o.rel="icon",document.head.append(o)),o.href=t===0&&Pu?Pu:l}function Ik({me:t}){const[n]=Ps(th),a=h.useRef(null),l=h.useRef(document.title.replace(/^\(\d+\+?\) /,""));return h.useEffect(()=>{let o,c=!1;const d=async()=>{var u,m,f;try{const g=(await ge.since(new Date(Date.now()-Ek).toISOString())).filter(k=>k.createdBy===t.email),x=nh(),y=document.hidden?null:Pk();for(const k of g){const S=El(k);S&&k.id===y&&x.add(`${k.id}:${S}`)}const b=Nk(a.current,g,x,y);if(n==="yes"&&"Notification"in window&&Notification.permission==="granted")for(const k of b){const S=g.find(E=>E.id===k.id),$=new Notification(dd[k.attention].title(S.title),{tag:`${k.id}:${k.attention}`,body:"TeamHandbook Orchestrator"});$.onclick=()=>{window.focus(),Ge(re("tasks",k.id))}}a.current=new Map(g.map(k=>[k.id,El(k)])),Rk(x);const N=g.filter(k=>{const S=El(k);return S&&!x.has(`${k.id}:${S}`)}).length;Ak(N);const v=navigator;(f=N?(u=v.setAppBadge)==null?void 0:u.call(v,N):(m=v.clearAppBadge)==null?void 0:m.call(v))==null||f.catch(()=>{}),document.title=N?`(${N>9?"9+":N}) ${l.current}`:l.current}catch{}c||(o=setTimeout(d,document.hidden?Tk:$k))};return d(),()=>{c=!0,clearTimeout(o)}},[t.email,n]),null}const Ok="orchestrator.attention.asked";function Lk(){const[t,n]=Ps(th),[a,l]=Ps(Ok),[o,c]=h.useState(()=>"Notification"in window?Notification.permission:"denied");if(o==="denied"||a||t==="yes"&&o==="granted")return null;const d=()=>{Notification.requestPermission().then(u=>{c(u),u==="granted"?n("yes"):u==="denied"&&l("yes")})};return e.jsxs("p",{className:"muted small",role:"note","aria-label":"Notifications",children:["Away from this page when it needs you?"," ",e.jsx("button",{type:"button",className:"link",onClick:d,children:"Get a notification"})," ",e.jsx("button",{type:"button",className:"link",onClick:()=>l("yes"),children:"Not now"})]})}const Fk=["Actions","Pages","Repositories","Folders","Tasks"],rx=5;function Mk(t,n){const a=n.trim().toLowerCase(),l=t.filter(c=>c.pinned&&(!a||c.label.toLowerCase().includes(a)));if(!a)return l;const o=c=>{if(c.group==="Folders"||c.asked)return 0;const d=c.label.toLowerCase();return d.startsWith(a)?0:d.includes(a)?1:c.detail.toLowerCase().includes(a)?2:null};return[...l,...Fk.flatMap(c=>t.filter(d=>d.group===c&&!d.pinned).flatMap(d=>{const u=o(d);return u===null?[]:[{j:d,s:u}]}).sort((d,u)=>d.s-u.s).slice(0,rx).map(d=>d.j))]}function _k(t){const n=t.trim();if(!n)return null;if(!/^(~|\/)/.test(n))return{q:n};if(n==="~"||n.endsWith("/"))return{under:n==="~"?"~":n.replace(/\/+$/,"")||"/"};const a=n.lastIndexOf("/");return{under:n.slice(0,a)||(n.startsWith("~")?"~":"/"),prefix:n.slice(a+1)}}function cf(t){if(!/^(~|\/).*\/$/.test(t)||t==="/"||t==="~/")return null;const n=t.replace(/[^/]+\/$/,"");return n==="~"?"~/":n}const Uk=t=>[...new Set(t.map(n=>n.group))].map(n=>[n,t.filter(a=>a.group===n)]),uf=150;function Dk({open:t,onClose:n,jumps:a,more:l,folders:o,finds:c}){const d=h.useRef(null),[u,m]=h.useState(""),[f,g]=h.useState([]),[x,y]=h.useState(0),[b,N]=h.useState([]),[v,k]=h.useState([]),[S,$]=h.useState(null),E=h.useId();h.useEffect(()=>{if($(null),!t||!o||!u.trim())return N([]);let L=!0;const K=setTimeout(()=>void o(u).then(B=>L&&N(B),()=>L&&N([])),uf);return()=>{L=!1,clearTimeout(K)}},[t,o,u]),h.useEffect(()=>{if(!t||!c||!u.trim())return k([]);let L=!0;const K=setTimeout(()=>void c(u).then(B=>L&&k(B),()=>L&&k([])),uf);return()=>{L=!1,clearTimeout(K)}},[t,c,u]),h.useEffect(()=>{const L=d.current;L&&(t&&!L.open?(m(""),y(0),L.showModal(),l==null||l().then(g,()=>g([]))):!t&&L.open&&L.close())},[t,l]);const C=Mk([...a,...f,...b,...v.filter(L=>!f.some(K=>K.to===L.to))],u),R=C[Math.min(x,C.length-1)],P=L=>{if(L.run){n(),L.run();return}if(L.open){L.open().then(K=>{n(),Ge(K)},K=>$(K.message));return}n(),Ge(L.to)},M=L=>L.currentTarget.selectionStart===L.currentTarget.value.length&&L.currentTarget.selectionEnd===L.currentTarget.value.length,O=L=>{m(L),y(0)},_=L=>{L.key==="ArrowDown"||L.key==="ArrowUp"?(L.preventDefault(),y(K=>Math.min(Math.max(K+(L.key==="ArrowDown"?1:-1),0),Math.max(C.length-1,0)))):L.key==="ArrowRight"&&(R!=null&&R.inside)&&M(L)?(L.preventDefault(),O(R.inside)):L.key==="Backspace"&&M(L)&&o&&cf(u)?(L.preventDefault(),O(cf(u))):L.key==="Enter"&&R?(L.preventDefault(),P(R)):L.key==="Escape"&&(L.preventDefault(),n())},I=L=>`${E}-${L}`;return e.jsx("dialog",{ref:d,className:"palette","aria-label":"Search",onClose:n,onClick:L=>{L.target===d.current&&n()},children:t?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"search","aria-label":o?"Search pages, projects, folders and tasks":"Search pages, projects and tasks",placeholder:o?"Search pages, projects, folders and tasks":"Search pages, projects and tasks",autoComplete:"off",value:u,"aria-controls":E,"aria-activedescendant":R?I(C.indexOf(R)):void 0,onChange:L=>O(L.target.value),onKeyDown:_}),e.jsx("p",{className:"visually-hidden",role:"status",children:u.trim()?C.length?`${C.length} found`:"Nothing found":""}),C.length?e.jsx("div",{id:E,role:"listbox","aria-label":"Found",className:"palette-list",children:Uk(C).map(([L,K])=>e.jsxs("div",{role:"group","aria-labelledby":`${E}-${L}`,children:[e.jsx("p",{id:`${E}-${L}`,className:"palette-group",children:L}),K.map(B=>e.jsxs("div",{id:I(C.indexOf(B)),role:"option","aria-selected":B===R,className:"palette-option",onMouseDown:ne=>ne.preventDefault(),onClick:()=>P(B),children:[e.jsx("span",{className:B.group==="Folders"?"palette-label mono":"palette-label",children:B.label}),B.detail?e.jsx("span",{className:"palette-detail",children:B.detail}):null]},B.to||B.label))]},L))}):e.jsx("p",{className:"palette-note",children:u.trim()?`Nothing matches “${u.trim()}”.`:o?"Type a page, a project, a task, or a folder's path from ~/.":"Type a page, a project or a task."}),S?e.jsx("p",{className:"error",role:"alert",children:S}):null]}):null})}const Je={folders:(t={},n)=>{const a=new URLSearchParams(Object.entries(t).filter(o=>!!o[1])).toString(),l=n?`/api/machines/${encodeURIComponent(n)}/folders`:"/api/local/folders";return U("GET",a?`${l}?${a}`:l)},open:(t,n)=>U("POST","/api/projects",{path:t,...n?{machineId:n}:{}}),workFolders:()=>U("GET","/api/work-folders"),list:()=>U("GET","/api/projects"),gitInit:t=>U("POST",`/api/projects/${encodeURIComponent(t)}/git/init`,{commandId:crypto.randomUUID()}),commitPlan:t=>U("GET",`/api/projects/${encodeURIComponent(t)}/git/commit`),commit:(t,n,a)=>U("POST",`/api/projects/${encodeURIComponent(t)}/git/commit`,{commandId:crypto.randomUUID(),message:n,exclude:a}),clone:(t,n)=>U("POST","/api/projects/clone",{commandId:crypto.randomUUID(),url:t,...n?{into:n}:{}}),rename:(t,n)=>U("PATCH",`/api/projects/${encodeURIComponent(t)}`,{name:n}),readSkillsFrom:(t,n)=>U("PATCH",`/api/projects/${encodeURIComponent(t)}`,{skillsFrom:n}),repositories:t=>U("GET",`/api/projects/${encodeURIComponent(t)}/repositories`),trust:(t,n)=>U("PUT",`/api/projects/${encodeURIComponent(t)}/trust`,{trusted:n})};function oa(t,n){const a=t.trim();return n&&(a==="~"||a.startsWith("~/"))?`${n}${a.slice(1)}`:a}function Kn(t,n){return n?t===n?"~":t.startsWith(`${n}/`)?`~${t.slice(n.length)}`:t:t}function lx(t,n){var a;return((a=t.machine)==null?void 0:a.path)??Kn(t.url.replace(/^file:\/\//,""),n)}function Au(t){return/^(~|\/)/.test(t.trim())}function Bk(t,n){if(t!==n&&!t.startsWith(`${n}/`))return[{label:t,path:t}];const a=t.slice(n.length).split("/").filter(Boolean);return[{label:"~",path:n},...a.map((l,o)=>({label:l,path:`${n}/${a.slice(0,o+1).join("/")}`}))]}function qk(t){var a;const n=((a=t.trim().replace(/\/+$/,"").split(/[/:]/).pop())==null?void 0:a.replace(/\.git$/,""))??"";return/^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/.test(n)?n:null}function ox(t){return t.label.slice(0,1).toLowerCase()}function Wk(t,n,a,l=!1){if(l)return t.toLowerCase()==="k"?{kind:"search",anywhere:!0}:null;if(n){const o=a.find(c=>ox(c)===t.toLowerCase());return o?{kind:"go",section:o.section}:null}return t==="?"?{kind:"help"}:t==="/"?{kind:"search",anywhere:!1}:t==="g"?{kind:"then"}:null}function zk(t){return t instanceof HTMLElement?t.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(t.tagName)||t.closest("[role='listbox'], [role='menu']")!==null:!1}const Hk=1500,Gk=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)?"⌘":"Ctrl";function Kk({org:t,tabs:n,onSearch:a}){const l=h.useRef(null),[o,c]=h.useState(!1);return h.useEffect(()=>{let d=!1,u;const m=f=>{var y;const g=f.metaKey||f.ctrlKey;if(f.defaultPrevented||f.altKey||!g&&zk(f.target)||(y=l.current)!=null&&y.open)return;const x=Wk(f.key,d,n,g);d=!1,clearTimeout(u),x&&(f.preventDefault(),x.kind==="then"?(d=!0,u=setTimeout(()=>{d=!1},Hk)):x.kind==="help"?c(!0):x.kind==="search"?a(x.anywhere):Ge(Te(t,x.section)))};return document.addEventListener("keydown",m),()=>{document.removeEventListener("keydown",m),clearTimeout(u)}},[t,n,a]),h.useEffect(()=>{var d,u;o&&!((d=l.current)!=null&&d.open)&&((u=l.current)==null||u.showModal())},[o]),e.jsx("dialog",{ref:l,className:"dialog","aria-labelledby":"shortcuts-h",onClose:()=>c(!1),children:o?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"dialog-body",children:[e.jsx("h2",{id:"shortcuts-h",children:"Keyboard shortcuts"}),e.jsxs("dl",{className:"shortcut-list",children:[e.jsxs("div",{children:[e.jsx("dt",{children:e.jsx("kbd",{children:"?"})}),e.jsx("dd",{children:"Show this list"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:e.jsx("kbd",{children:"/"})}),e.jsx("dd",{children:"Search pages, projects and tasks, or this page's own list"})]}),e.jsxs("div",{children:[e.jsxs("dt",{children:[e.jsx("kbd",{children:Gk})," ",e.jsx("kbd",{children:"K"})]}),e.jsx("dd",{children:"Search pages, projects and tasks from anywhere, a field included"})]}),n.map(d=>e.jsxs("div",{children:[e.jsxs("dt",{children:[e.jsx("kbd",{children:"g"})," ",e.jsx("kbd",{children:ox(d)})]}),e.jsxs("dd",{children:["Go to ",d.label]})]},d.section)),e.jsxs("div",{children:[e.jsx("dt",{children:e.jsx("kbd",{children:"Esc"})}),e.jsx("dd",{children:"Close a menu or this list"})]})]})]}),e.jsx("form",{method:"dialog",className:"dialog-foot",children:e.jsx("button",{type:"submit",children:"Close"})})]}):null})}const pd="orchestrator.push.subscription",Yk=()=>"serviceWorker"in navigator&&"PushManager"in window,Vk=t=>{const n=atob(t.replace(/-/g,"+").replace(/_/g,"/"));return Uint8Array.from(n,a=>a.charCodeAt(0))};async function Qk(){if(!Yk())return"unavailable";try{const{publicKey:t}=await U("GET","/api/push/key"),n=await navigator.serviceWorker.register("/sw.js");await navigator.serviceWorker.ready;const a=await n.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Vk(t)}),{endpoint:l,keys:o}=a.toJSON(),{id:c}=await U("POST","/api/push/subscriptions",{endpoint:l,keys:o});return Rs(pd,c),"on"}catch(t){return t.code==="no-vault"?"no-vault":"unavailable"}}async function Jk(){var a,l;const t=Es(pd);Rs(pd,null),t&&await U("DELETE",`/api/push/subscriptions/${encodeURIComponent(t)}`).catch(()=>{});const n=await((a=navigator.serviceWorker)==null?void 0:a.getRegistration("/sw.js").catch(()=>{}));await((l=await(n==null?void 0:n.pushManager.getSubscription()))==null?void 0:l.unsubscribe().catch(()=>{}))}const Ni="orchestrator:find-in-task",fd="orchestrator:show-log-line";function ix(t){window.dispatchEvent(new CustomEvent(fd,{detail:t}))}const Xk=5e3,Zk=6e4,eb=5e3,tb=t=>new Date(t).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hourCycle:"h23"});function nb({onBack:t}){const n=h.useSyncExternalStore(Nr.subscribe,Nr.since),[a,l]=h.useState(Date.now()),[o,c]=h.useState(!1);if(h.useEffect(()=>{if(n===null){o&&(c(!1),t());return}const u=setInterval(()=>l(Date.now()),1e3),m=setInterval(()=>void fetch(Pn("/api/me"),{credentials:"same-origin"}).then(Nr.found,()=>{}),eb);return()=>{clearInterval(u),clearInterval(m)}},[n]),h.useEffect(()=>{n!==null&&a-n>=Xk&&c(!0)},[n,a]),n===null||!o)return null;const d=a-n>=Zk;return e.jsx("p",{className:"waiting connection-band",role:"status",children:d?e.jsxs(e.Fragment,{children:["The orchestrator does not answer; this page shows what it had at ",tb(n),". ",e.jsx("button",{type:"button",className:"link",onClick:()=>void fetch(Pn("/api/me"),{credentials:"same-origin"}).then(Nr.found,()=>{}),children:"Try again"})]}):"Reconnecting to the orchestrator…"})}const Jo=[{section:"work",label:"Work"},{section:"tasks",label:"Tasks"},{section:"team",label:"Team"},{section:"integrations",label:"Integrations"}];function ql({label:t,summary:n,className:a,children:l}){const[o,c]=h.useState(!1),d=h.useId(),u=h.useRef(null),m=h.useRef(null);h.useEffect(()=>{if(!o)return;const x=y=>{var b;(b=u.current)!=null&&b.contains(y.target)||c(!1)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[o]);const f=()=>{var x;c(!1),(x=m.current)==null||x.focus()},g=x=>{x.key==="Escape"&&o&&(x.stopPropagation(),f())};return e.jsxs("div",{className:`disclosure ${a??""}`,ref:u,onKeyDown:g,children:[e.jsx("button",{ref:m,type:"button",className:"ghost","aria-expanded":o,"aria-controls":d,"aria-label":t,onClick:()=>c(!o),children:n}),e.jsx("div",{id:d,className:"popover",hidden:!o,children:o?l(()=>c(!1)):null})]})}function sb({onJoined:t}){const[n,a]=h.useState(null),[l,o]=h.useState(null),c=()=>ut.orgs().then(u=>a(u.invitations),u=>o(u.message));h.useEffect(()=>{c()},[]);const d=(u,m)=>{o(null),ut.me().then(f=>m?ut.acceptInvitation(u,f.csrf).then(g=>{t(),Ge(g.next)}):ut.declineInvitation(u,f.csrf).then(c)).catch(f=>o(f.message))};return l?e.jsx("p",{className:"error small",role:"alert",children:l}):n!=null&&n.length?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"popover-title",children:"Invitations"}),e.jsx("ul",{className:"plain invitations",children:n.map(u=>e.jsxs("li",{children:[e.jsxs("span",{children:[u.orgName," ",e.jsxs("span",{className:"muted",children:["· ",u.role,", from ",u.invitedBy]})]}),e.jsxs("span",{className:"row-actions",children:[e.jsx("button",{type:"button",className:"small",onClick:()=>d(u.id,!0),children:"Accept"}),e.jsx("button",{type:"button",className:"secondary small","aria-label":`Decline the invitation to ${u.orgName}`,onClick:()=>d(u.id,!1),children:"Decline"})]})]},u.id))})]}):null}function ab({me:t,orgs:n,org:a,section:l}){const[o,c]=h.useState(""),d=h.useId(),u=t.mode==="cloud";if(t.mode==="local"||n.length<2&&!u)return null;const m=x=>x.orgName??x.tenant,f=n.find(x=>x.tenant===a),g=f?m(f):a;return e.jsx(ql,{label:`Organization: ${g}`,summary:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"org-mark","aria-hidden":"true",children:g.slice(0,1).toUpperCase()}),e.jsx("span",{className:"org-name",children:g})]}),className:"org-picker",children:x=>e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"popover-title",children:"Organizations"}),e.jsx("ul",{className:"plain",children:n.map(y=>e.jsx("li",{children:e.jsxs("a",{href:Te(y.tenant,l??"tasks"),"aria-current":y.tenant===a?"true":void 0,onClick:x,children:[m(y)," ",e.jsxs("span",{className:"muted",children:["· ",y.role]})]})},y.tenant))}),u?e.jsxs(e.Fragment,{children:[e.jsx(sb,{onJoined:x}),e.jsx("p",{children:e.jsx("a",{href:"/signup/organization",onClick:x,children:"New organization"})})]}):e.jsxs("form",{className:"form",onSubmit:y=>{y.preventDefault(),o.trim()&&(x(),Ge(Te(o.trim(),"tasks")))},children:[e.jsx("label",{htmlFor:d,children:"Sign in to another organization"}),e.jsx("input",{id:d,value:o,onChange:y=>c(y.target.value),placeholder:"Its name",autoComplete:"off"})]})]})})}function rb(t,n,a){const l=(c,d,u)=>({label:c,detail:d,to:u,group:"Pages"}),o=(c,d,u)=>({label:c,detail:d,to:u,group:"Actions"});return[o("New task","Say what needs doing",Te(t,"tasks","new")),o("Start agents","On the issues of the Work board",Te(t,"work")),l("Work","Sprint board and backlog",Te(t,"work")),l("Tasks",a.mode==="local"?"Agent tasks and your folders":"Agent tasks and the repositories they run in",Te(t,"tasks")),l("Team",a.mode==="local"?"Lessons and what your Claude Code loads":"People, policies and what the team shares",Te(t,"team")),l("Integrations","Forges",Te(t,"integrations")),...Zg(a).map(c=>l(c.label,"Account menu",Te(t,"activity",c.id))),l("Settings",Me(a)&&a.mode!=="local"?"Organization":"Your account",Te(t,"settings")),...ex(a).map(c=>l(c.label,"Settings",Te(t,"settings",c.id))),...n.map(c=>({label:c.name,detail:a.mode==="local"?"":c.team,to:`${Te(t,"tasks")}?${new URLSearchParams({repo:c.id})}`,group:a.mode==="local"?"Folders":"Repositories"}))]}function lb(t){let n=null;return async a=>{var m;const l=_k(a);if(!l)return[];n??(n=(await Je.folders()).under);const o=l.under===void 0?void 0:oa(l.under,n),c=await Je.folders({...o?{under:o}:{},...l.q?{q:l.q}:{}}),d=((m=l.prefix)==null?void 0:m.toLowerCase())??"";return(l.q?c.matches??[]:c.folders.filter(f=>f.name.toLowerCase().startsWith(d))).slice(0,rx).map(f=>{const g=Kn(f.path,n);return{label:g,detail:f.git==="none"?"":"Git",to:`folder:${f.path}`,group:"Folders",inside:`${g}/`,open:()=>Je.open(f.path).then(({project:x})=>Te(t,"repositories",x.id))}})}}function ob(t,n){const a=new Map(n.map(l=>[l.id,l.name]));return async l=>{const o=await zv.tasks(l.trim()),c=(d,u)=>({label:d.title,detail:[a.get(d.repoId),u].filter(Boolean).join(", "),to:Te(t,"tasks",d.id),group:"Tasks",asked:!0});return[...o.tasks.map(d=>c(d,"")),...o.inLog.map(d=>c(d,"in its log"))]}}function ib(t,n){const a=new Map(n.map(l=>[l.id,l.name]));return ge.page(null).then(l=>l.tasks.map(o=>({label:o.title,detail:[o.issueKey,a.get(o.repoId)].filter(Boolean).join(", "),to:Te(t,"tasks",o.id),group:"Tasks"})))}function cb(){return document.querySelector("main [data-page-search]")}function ub(t){return t.mode==="cloud"?ut.me().then(n=>ut.signOut(n.csrf)):Ol.logout()}function db({local:t}){const[n,a]=Ps(th),[l,o]=h.useState(()=>"Notification"in window&&Notification.permission==="denied"),[c,d]=h.useState(null);if(!("Notification"in window))return null;const u=n==="yes"&&Notification.permission==="granted",m=()=>{if(u){a(null),d(null),t&&Jk();return}Notification.requestPermission().then(f=>{o(f==="denied"),f==="granted"&&(a("yes"),t&&Qk().then(d))})};return e.jsxs("div",{className:"notify-switch",children:[e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:u,disabled:l,onChange:m}),"Notify me when my tasks need me"]}),e.jsx("p",{className:"muted small",children:l?"This browser blocks notices; allow them in its site settings to turn this on.":u?c==="no-vault"?"Notices with this page closed need this machine's vault.":t&&c!=="unavailable"?"On in this browser, with this page closed too.":"On in this browser while this page is open.":"A notice says only that a task needs you, failed or stopped; it opens the task."})]})}function hb({me:t,org:n,onSignedOut:a}){const[l,o]=Ps(nx),[c,d]=h.useState(!1);h.useEffect(()=>{if(!Me(t))return;const f=()=>Ce.onboarding().then(g=>d(g.dismissed),()=>d(!1));return f(),window.addEventListener(id,f),()=>window.removeEventListener(id,f)},[]);const u=f=>{o(f==="system"?null:f),sx(f)},m=`${t.role==="owner"?"Owner":t.role==="admin"?"Admin":"Member"}${t.ownedTeams.length?`, owns ${t.ownedTeams.join(", ")}`:""}`;return e.jsx(ql,{label:`Account: ${t.name}`,summary:e.jsx("span",{className:"avatar","aria-hidden":"true",children:t.name.slice(0,1).toUpperCase()}),className:"user-menu",children:f=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"who",children:[e.jsx("strong",{children:t.name}),e.jsx("span",{className:"muted",children:t.email}),t.mode==="local"?null:e.jsx("span",{className:"muted",children:m})]}),e.jsxs("fieldset",{className:"theme-pick",children:[e.jsx("legend",{children:"Theme"}),["system","light","dark"].map(g=>e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"radio",name:"theme",checked:(l??"system")===g,onChange:()=>u(g)}),g==="system"?"Match the system":g==="light"?"Light":"Dark"]},g))]}),e.jsx(db,{local:t.mode==="local"}),e.jsxs("nav",{className:"account-links","aria-label":"Account",children:[e.jsx("a",{href:Te(n,"settings"),onClick:f,children:"Settings"}),e.jsx("a",{href:Te(n,"activity","news"),onClick:f,children:"What's new"}),Zd(t,"usage")?e.jsx("a",{href:Te(n,"activity","usage"),onClick:f,children:"Skill use over time"}):null]}),c?e.jsx("button",{type:"button",className:"link",onClick:()=>{Ce.changeOnboarding({dismissed:!1}),f()},children:"Show the getting started guide"}):null,e.jsx("button",{type:"button",className:"secondary",onClick:()=>ub(t).finally(a),children:"Sign out"})]})})}function mb({me:t,orgs:n,org:a,section:l,repos:o,onSignedOut:c,children:d}){var $;const u=(($=Jo.find(E=>E.section===l))==null?void 0:$.label)??"Sections",[m,f]=h.useState(!1),[g,x]=h.useState(0),y=l==="tasks"&&Ts(window.location.pathname).rest.length>0,b=h.useMemo(()=>[...y?[{label:"Find in this task",detail:"",to:"",group:"Actions",pinned:!0,run:()=>window.dispatchEvent(new Event(Ni))}]:[],...rb(a,o,t)],[a,o,t,y]),N=h.useCallback(()=>ib(a,o),[a,o]),v=h.useMemo(()=>t.mode==="local"?lb(a):void 0,[a,t.mode]),k=h.useMemo(()=>ob(a,o??[]),[a,o]),S=h.useCallback(E=>{const C=E?null:cb();C?C.focus():!E&&y?window.dispatchEvent(new Event(Ni)):f(!0)},[y]);return e.jsxs("div",{className:"shell",children:[e.jsx("a",{className:"skip",href:"#content",children:"Skip to content"}),e.jsxs("header",{className:"topbar",children:[e.jsxs("a",{className:"brand",href:Te(a,"tasks"),children:["TeamHandbook ",e.jsx("span",{children:"Orchestrator"})]}),e.jsx(ab,{me:t,orgs:n,org:a,section:l}),e.jsx(ql,{label:`Sections: ${u}`,summary:e.jsxs(e.Fragment,{children:[u," ",e.jsx("span",{className:"select-chevron","aria-hidden":"true"})]}),className:"section-menu",children:E=>e.jsx("ul",{className:"plain",children:Jo.map(C=>e.jsx("li",{children:e.jsx("a",{href:Te(a,C.section),"aria-current":C.section===l?"page":void 0,onClick:E,children:C.label})},C.section))})}),e.jsx("nav",{className:"tabs","aria-label":"Orchestrator",children:Jo.map(E=>e.jsx("a",{href:Te(a,E.section),"aria-current":E.section===l?"page":void 0,children:E.label},E.section))}),e.jsxs("div",{className:"topbar-end",children:[e.jsxs("button",{type:"button",className:"ghost search-button",onClick:()=>S(!1),title:"Search pages, projects and tasks (/ or Cmd/Ctrl+K)",children:["Search ",e.jsx("kbd",{children:"/"})]}),e.jsx(hb,{me:t,org:a,onSignedOut:c})]})]}),e.jsx(nb,{onBack:()=>x(E=>E+1)}),e.jsx(Ik,{me:t}),e.jsx(Kk,{org:a,tabs:Jo,onSearch:S}),e.jsx(Dk,{open:m,onClose:()=>f(!1),jumps:b,more:N,finds:k,...v?{folders:v}:{}}),e.jsx("main",{id:"content",tabIndex:-1,children:d},g)]})}function Fi({label:t,links:n,current:a}){var d;const l=n.length>5,o=e.jsx("nav",{className:l?"subnav subnav-gathers":"subnav","aria-label":t,children:n.map(u=>e.jsx("a",{href:u.to,"aria-current":u.to===a?"page":void 0,children:u.label},u.to))});if(!l)return o;const c=((d=n.find(u=>u.to===a))==null?void 0:d.label)??t;return e.jsxs(e.Fragment,{children:[e.jsx(ql,{label:`${t}: ${c}`,summary:e.jsxs(e.Fragment,{children:[c," ",e.jsx("span",{className:"select-chevron","aria-hidden":"true"})]}),className:"section-menu subnav-menu",children:u=>e.jsx("ul",{className:"plain",children:n.map(m=>e.jsx("li",{children:e.jsx("a",{href:m.to,"aria-current":m.to===a?"page":void 0,onClick:u,children:m.label})},m.to))})}),o]})}function Yn({title:t,summary:n,actions:a,also:l,crumb:o,sticky:c=!1,mainAtFoot:d=!1,below:u,children:m}){return e.jsxs("header",{className:`page-head${c?" sticky":""}${d?" main-at-foot":""}`,children:[o?e.jsx("p",{className:"page-crumb",children:o}):null,e.jsxs("div",{className:"page-head-line",children:[e.jsx("h1",{dir:"auto",children:t}),m]}),n?e.jsx("p",{className:"page-summary",children:n}):null,a||l?e.jsxs("div",{className:"actions",children:[a&&d?e.jsx("span",{className:"main-wide",children:a}):a,l]}):null,u]})}const pb=[{id:"2026-11-four-sections",title:"Work, Tasks, Team and Integrations",body:"The orchestrator opens on Tasks. Your repositories are the list on its left, each one's settings a panel from there, and Controls is now Team. Settings, What's new and skill use moved to your account menu. Old links still open the page they used to.",link:{section:"tasks",label:"Go to Tasks"}},{id:"2026-10-sections",title:"Activity, Repositories, Tasks, Controls, Integrations and Settings",body:"The orchestrator's pages now sit under six tabs at the top, inside your organization. Old links still open the page they used to. Forge access moved to Integrations, and people to Settings.",link:{section:"activity",page:"usage",label:"See skill use over time"}}];function fb(){return e.jsx("ul",{className:"plain news-list",children:pb.map(t=>e.jsxs("li",{children:[e.jsx("h2",{children:t.title}),e.jsx("p",{className:"muted",children:t.body}),t.link?e.jsx("p",{children:e.jsx("a",{href:t.link.page?re(t.link.section,t.link.page):re(t.link.section),children:t.link.label})}):null]},t.id))})}function gb({me:t,repos:n,page:a,entry:l}){const o=Jg.find(u=>u.id===a&&Zd(t,u.id));if(!o)return e.jsx(Sr,{org:Ts(window.location.pathname).org??"",path:window.location.pathname});const c=u=>re("activity",u),d=e.jsx(Fi,{label:"Activity",current:c(o.id),links:Zg(t).map(u=>({to:c(u.id),label:u.label}))});return e.jsxs("div",{className:"page",children:[e.jsx(Yn,{title:o.label}),d,o.id==="news"?e.jsx(fb,{}):null,o.id==="usage"?e.jsx(tk,{me:t,repos:n}):null,o.id==="leaderboard"?e.jsx(sk,{me:t}):null,o.id==="ai"?e.jsx(ak,{}):null,o.id==="logs"?e.jsx(gk,{repos:n,me:t.email}):null,o.id==="audit"?l?e.jsx(vk,{me:t,id:l}):e.jsx(jk,{me:t,repos:n}):null]})}function qe({trigger:t,triggerLabel:n,consequence:a,confirm:l,keep:o,onConfirm:c,reason:d,small:u=!1,primary:m=!1,danger:f=!1}){const[g,x]=h.useState(!1),[y,b]=h.useState(!1),[N,v]=h.useState(null),[k,S]=h.useState(""),$=h.useRef(null),E=h.useRef(null),C=h.useRef(!1);h.useEffect(()=>{var O,_;g?(O=E.current)==null||O.focus():C.current&&((_=$.current)==null||_.focus())},[g]);const R=u?" small":"";if(!g)return e.jsx("button",{ref:$,type:"button",className:`${f?"danger":m?"":"secondary"}${R}`.trim()||void 0,"aria-label":n,onClick:()=>x(!0),children:t});const P=()=>{b(!0),v(null),c(k.trim()).then(()=>{b(!1),S(""),C.current=!1,x(!1)},O=>{v(O.message),b(!1)})},M=()=>{C.current=!0,v(null),x(!1)};return e.jsxs("div",{className:"confirm",role:"group","aria-label":l,children:[e.jsx("p",{children:a}),d?e.jsxs("label",{children:[d.label,e.jsx("input",{type:"text",value:k,onChange:O=>S(O.target.value),maxLength:300,disabled:y}),e.jsx("span",{className:"muted small",children:d.note})]}):null,e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",className:`confirm-go${R}`,onClick:P,disabled:y,children:y?`${l}…`:l}),e.jsx("button",{ref:E,type:"button",className:`secondary${R}`,onClick:M,disabled:y,children:o})]}),N?e.jsx("p",{className:"error",role:"alert",children:N}):null]})}function xb(t){const n=window.getSelection();if(!t||!n)return;const a=document.createRange();a.selectNodeContents(t),n.removeAllRanges(),n.addRange(a)}function sh({text:t,target:n,label:a="Copy",primary:l=!1,small:o=!0}){const[c,d]=h.useState(null),u=()=>{xb(n.current),d("Copy failed; it is selected, so copy it with the keyboard.")},m=()=>{if(!navigator.clipboard)return u();navigator.clipboard.writeText(t).then(()=>d("Copied"),u)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`${l?"":"secondary"}${o?" small":""}`.trim()||void 0,"aria-label":a==="Copy"?`Copy ${t}`:a,onClick:m,children:a}),c?e.jsxs("span",{className:"muted",role:"status",children:[" ",c]}):null]})}function mt({text:t,label:n,primary:a=!1,well:l=!1}){const o=h.useRef(null);return e.jsxs("span",{className:l?"copy-text well":"copy-text",children:[e.jsx("code",{ref:o,className:"link",children:t})," ",e.jsx(sh,{text:t,target:o,label:n,primary:a})]})}function Ie({label:t,children:n}){return e.jsxs("details",{className:"hint",children:[e.jsx("summary",{"aria-label":`About ${t}`,children:"i"}),e.jsx("p",{children:n})]})}const gd={google:"Google",github:"GitHub",microsoft:"Microsoft"},df={browser:"This sign-in was started in another browser or tab. Start it again here.",expired:"This sign-in took too long or was already used. Start it again.","provider-error":"The provider did not finish the sign-in. Try again.","unverified-email":"Your provider has not verified this account's email address. Verify it there, or sign in another way.","personal-microsoft":"Microsoft sign-in takes work and school accounts only. Sign in with Google or GitHub instead.","unvouched-microsoft":"Microsoft does not vouch for this account's email address: only your organization's Microsoft admin can, by verifying its domain. Sign in with Google or GitHub instead, or ask that admin.","address-taken":"This email address already signs in with another provider. Sign in with that one, then add this provider under Your account.","invite-unknown":"This invitation link was used already or is no longer valid: if you joined with it, sign in, and otherwise ask whoever invited you for a new one.","invite-email":"This invitation is for another email address. Sign in with the account that has that address.","invite-elsewhere":"An invitation is accepted only from the orchestrator's own page. Open its link again.","plan-limit":"This organization has as many members as its plan allows. Ask an owner to make room.","invite-expired":"This invitation expired. Ask whoever invited you for a new one.","already-member":"You are already a member of that organization.","already-account":"This email address already has an account in that organization. Ask its owner to remove it and invite you again.","login-taken":"That account already signs in to this orchestrator as someone else, so it is not added to yours."},jb="That sign-in did not finish. Try again.";function xd(t,n=null){const a=(n??"").split(",").filter(l=>Object.hasOwn(gd,l)).map(l=>gd[l]);return t==="address-taken"&&a.length?`This email address already signs in with ${a.join(" or ")}. Sign in with ${a.length>1?"one of those":a[0]}, then add this provider under Your account.`:Object.hasOwn(df,t)?df[t]:jb}function Si({privacyUrl:t,termsUrl:n}){return!t&&!n?null:e.jsxs("p",{className:"muted legal",children:[n?e.jsx("a",{href:n,children:"Terms of use"}):null,n&&t?" · ":null,t?e.jsx("a",{href:t,children:"Privacy policy"}):null]})}function yb(t){return t.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,39)}function Ll({config:t}){return t.helpUrl?e.jsx("p",{className:"muted",children:e.jsx("a",{href:t.helpUrl,children:"Stuck? Get help"})}):null}function vb({config:t}){return t.providers.length?e.jsx("div",{className:"stack",children:t.providers.map(n=>e.jsxs("a",{className:"button",href:`/api/auth/${n}/start`,children:["Sign in with ",gd[n]]},n))}):e.jsx("p",{className:"error",children:"Nobody can sign in here yet: the orchestrator's operator has not set up Google, GitHub or Microsoft."})}function kb({config:t}){const[n,a]=h.useState(void 0),l=new URLSearchParams(window.location.search).get("problem");if(h.useEffect(()=>{ut.me().then(a,()=>a(null))},[]),n===void 0)return e.jsx(he,{what:"your sign-in"});if(n){const o=n.memberships.filter(c=>c.reachable);return e.jsxs(e.Fragment,{children:[e.jsxs("h1",{id:"signup-h",children:["Signed in as ",n.identity.email]}),l?e.jsx("p",{className:"error",role:"alert",children:xd(l,new URLSearchParams(window.location.search).get("with"))}):null,e.jsxs("p",{className:"muted",children:["Not you, or another address? ",e.jsx("button",{type:"button",className:"link",onClick:()=>ut.signOut(n.csrf).then(()=>a(null),()=>a(null)),children:"Use another account"})]}),o.length?e.jsx("ul",{className:"plain",children:o.map(c=>e.jsx("li",{children:e.jsxs("a",{href:Te(c.tenant,"tasks"),children:["Open ",c.name]})},c.tenant))}):e.jsxs("p",{children:["You are not a member of an organization yet. Create one, or ask a teammate to invite ",n.identity.email,"."]}),t.signupOpen?e.jsx("a",{className:"button",href:"/signup/organization",children:"Create an organization"}):null,e.jsx(Ll,{config:t})]})}return e.jsxs(e.Fragment,{children:[e.jsx("h1",{id:"signup-h",children:t.signupOpen?"Start with TeamHandbook Orchestrator":"Sign in"}),e.jsx("p",{children:"Your team's skills, MCP servers and commands in one place, with every change reviewed by the team."}),l?e.jsx("p",{className:"error",role:"alert",children:xd(l,new URLSearchParams(window.location.search).get("with"))}):null,e.jsx(vb,{config:t}),e.jsx(Ll,{config:t}),e.jsxs("p",{className:"muted",children:["An organization you create is yours: nobody joins without an invitation. ",e.jsx(Ie,{label:"signing up",children:"Microsoft takes work and school accounts only."})]}),e.jsxs("p",{className:"muted",children:["This is the hosted TeamHandbook Orchestrator; to run it on your own machine, see ",t.readmeUrl?e.jsx("a",{href:t.readmeUrl,children:"the README"}):"the README","."]})]})}function bb({config:t}){const[n,a]=h.useState(null),[l,o]=h.useState(""),[c,d]=h.useState(""),[u,m]=h.useState(!1),[f,g]=h.useState(!1),[x,y]=h.useState(!1),[b,N]=h.useState(null),v=h.useId(),k=h.useId(),S=()=>ut.me().then(a,C=>C instanceof Ua?Ge("/signup",!0):N(C.message));if(h.useEffect(()=>{S()},[]),!t.signupOpen)return e.jsx("p",{className:"error",role:"alert",children:"Signup is closed until this orchestrator's operator publishes its privacy policy and terms of use."});if(!n)return b?e.jsx(be,{what:"your sign-in",reason:b,onRetry:()=>{N(null),S()}}):e.jsx(he,{what:"your sign-in"});const $=b?{"aria-describedby":v}:{},E=C=>{C.preventDefault(),y(!0),N(null),ut.createOrganization({name:l.trim(),slug:c,acceptTerms:f},n.csrf).then(R=>window.location.assign(R.next),R=>{N(R.message),y(!1)})};return e.jsxs("form",{className:"form",onSubmit:E,"aria-labelledby":"create-org-h",children:[e.jsx("h1",{id:"create-org-h",children:"Create your organization"}),e.jsxs("p",{className:"muted",children:["Signed in as ",n.identity.email,". You become its owner and invite your team from Settings."]}),e.jsxs("label",{children:["Organization name",e.jsx("input",{value:l,onChange:C=>{o(C.target.value),u||d(yb(C.target.value))},required:!0,maxLength:80,autoComplete:"organization",...$})]}),e.jsxs("label",{children:["Web address",e.jsx("input",{value:c,onChange:C=>{m(!0),d(C.target.value.toLowerCase())},required:!0,pattern:"[a-z0-9][a-z0-9\\-]{1,38}",autoComplete:"off",spellCheck:!1,"aria-describedby":b?`${k} ${v}`:k})]}),e.jsxs("p",{className:"muted",id:k,children:["Your organization is at /",c||"your-address",", in lowercase letters, digits and dashes. ",e.jsx(Ie,{label:"the web address",children:"It does not change later, and nobody else gets it, even after the organization is deleted."})]}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:f,onChange:C=>g(C.target.checked),required:!0,...$})," I accept the ",e.jsx("a",{href:t.termsUrl,children:"terms of use"})," and have read the ",e.jsx("a",{href:t.privacyUrl,children:"privacy policy"}),"."]}),b?e.jsx("p",{className:"error",role:"alert",id:v,children:b}):null,e.jsx("div",{className:"actions",children:e.jsx("button",{type:"submit",disabled:x,children:x?"Creating…":"Create organization"})}),e.jsx(Ll,{config:t})]})}function wb({config:t}){const n=window.location.pathname.replace(/\/+$/,"")==="/signup/organization";return e.jsx("main",{className:"gate",children:e.jsxs("section",{className:"panel form","aria-labelledby":n?"create-org-h":"signup-h",children:[e.jsxs("div",{className:"brand",children:["TeamHandbook ",e.jsx("span",{children:"Orchestrator"})]}),n?e.jsx(bb,{config:t}):e.jsx(kb,{config:t}),e.jsx(Si,{privacyUrl:t.privacyUrl,termsUrl:t.termsUrl})]})})}function Nb(){const t=window.location.hash.split("?")[1];return t?new URLSearchParams(t).get("problem"):null}function Sb({config:t,org:n=null,ended:a=null,onSignedIn:l}){const[o,c]=h.useState(""),[d,u]=h.useState(""),[m,f]=h.useState(Nb()),[g,x]=h.useState(!1),y=h.useId(),b=m?{"aria-invalid":!0,"aria-describedby":y}:{},N=v=>{v.preventDefault(),x(!0),f(null),Ol.login(o,d).then(l,k=>{f(k.message),x(!1)})};return e.jsx("main",{className:"gate",children:e.jsxs("form",{className:"panel form",onSubmit:N,"aria-labelledby":"signin-h",children:[e.jsxs("div",{className:"brand",children:["TeamHandbook ",e.jsx("span",{children:"Orchestrator"})]}),e.jsx("h1",{id:"signin-h",children:"Sign in"}),n?e.jsxs("p",{className:"muted",children:["to ",n]}):null,a?e.jsx("p",{role:"status",children:a}):null,e.jsxs("label",{children:["Email",e.jsx("input",{type:"email",autoComplete:"username",value:o,onChange:v=>c(v.target.value),required:!0,...b})]}),e.jsxs("label",{children:["Password",e.jsx("input",{type:"password",autoComplete:"current-password",value:d,onChange:v=>u(v.target.value),required:!0,...b})]}),m?e.jsx("p",{className:"error",role:"alert",id:y,children:m}):null,e.jsx("button",{type:"submit",disabled:g,children:"Sign in"}),t.sso?e.jsx("a",{className:"button secondary",href:Pn("/api/auth/oidc/start"),children:"Sign in with SSO"}):null,e.jsx(Si,{privacyUrl:t.privacyUrl,termsUrl:t.termsUrl})]})})}function Cb({onSignedIn:t}){const[n,a]=h.useState({code:"",name:"",email:"",password:""}),[l,o]=h.useState(null),[c,d]=h.useState(!1),u=h.useId(),m=g=>({value:n[g],onChange:x=>a({...n,[g]:x.target.value}),...l?{"aria-invalid":!0,"aria-describedby":u}:{}}),f=g=>{g.preventDefault(),d(!0),o(null),Ol.setup(n).then(t,x=>{o(x.message),d(!1)})};return e.jsx("main",{className:"gate",children:e.jsxs("form",{className:"panel form",onSubmit:f,"aria-labelledby":"setup-h",children:[e.jsxs("div",{className:"brand",children:["TeamHandbook ",e.jsx("span",{children:"Orchestrator"})]}),e.jsx("h1",{id:"setup-h",children:"Create the first owner"}),e.jsxs("p",{className:"muted",children:["No account exists yet; the setup code is in the orchestrator's log, and it works once. ",e.jsxs(Ie,{label:"the setup code",children:["Run without Docker, it is in the output of the terminal the orchestrator runs in. To choose it yourself, start the orchestrator with ",e.jsx("code",{children:"ORCHESTRATOR_SETUP_TOKEN"})," set; the log then names no code."]})]}),e.jsx(mt,{text:'docker compose logs orchestrator | grep "setup code"',label:"Copy the command for Docker Compose"}),e.jsxs("label",{children:["Setup code",e.jsx("input",{autoComplete:"off",...m("code"),required:!0})]}),e.jsxs("label",{children:["Name",e.jsx("input",{autoComplete:"name",...m("name")})]}),e.jsxs("label",{children:["Email",e.jsx("input",{type:"email",autoComplete:"username",...m("email"),required:!0})]}),e.jsxs("label",{children:["Password",e.jsx("input",{type:"password",autoComplete:"new-password",minLength:12,...m("password"),required:!0})]}),l?e.jsx("p",{className:"error",role:"alert",id:u,children:l}):null,e.jsx("button",{type:"submit",disabled:c,children:"Create owner and sign in"})]})})}function cx(t,n,a,l=!1){const o=(...g)=>Te(t,...g),c=a?o("repositories",a):o("repositories"),d=o("welcome"),{open:u,merged:m,closed:f}=n.requests;return[{id:"forge",required:!0,done:l||n.forges.connected>0,to:`${d}?step=forge`,action:"Connect",title:"Connect GitLab or GitHub",detail:"So each change opens as a merge request or pull request where its reviewers see it, and the orchestrator can set up your team's repository there."},{id:"repo",required:!0,done:n.repos>0,to:`${d}?step=repo`,action:"Set up the repository",title:"Pick your team's skills repository",detail:"The repository your team's skills, MCP servers and commands live in, which teammates install in Claude Code."},{id:"members",required:!0,done:n.members>1,to:o("settings","members"),action:"Invite your team",title:"Invite your team",detail:"Invite teammates by email and make each team's lead its owner."},{id:"start",required:!1,done:n.tasks.total>0||n.tracker,to:o("work"),action:"Open Work",title:"Start a task or connect Jira",detail:"Start from your sprint's issues on Work."},{id:"propose",required:!0,done:u+m+f>0,to:c,action:"Open a repository",title:"Propose your first change",detail:"Edit a skill, an MCP server or a command on a repository's page, and it opens as a request."},{id:"merge",required:!0,done:m>0,to:o("repositories","requests"),action:"Open requests",title:"Merge your first request",detail:"A request reaches teammates once a reviewer merges it."}]}const $b=3e3,Tb=10;function Eb(t){const[n,a]=h.useState(null),[l,o]=h.useState(0);return h.useEffect(()=>{let c=!0,d;const u=m=>ge.options().then(f=>{c&&(a(f.agents),m>0&&f.agents.length&&f.agents.every(g=>!g.readiness)&&(d=setTimeout(()=>u(m-1),$b)))},()=>c&&a([]));return u(Tb),()=>{c=!1,clearTimeout(d)}},[t,l]),[n,()=>{a(null),o(c=>c+1)}]}function Xt({name:t,count:n,why:a,empty:l,children:o,hideCount:c=!1}){const d=h.useId();return e.jsxs("section",{className:"turn","aria-labelledby":d,children:[e.jsxs("div",{className:"turn-side",children:[e.jsxs("h2",{id:d,children:[t,c?null:e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{className:"count",children:n})]})]}),a?e.jsx("p",{className:"turn-why",children:a}):null]}),e.jsx("div",{className:"turn-body",children:n===0?e.jsx("p",{className:"turn-empty",children:l}):o})]})}const Fl=["gitlab","github"],mn={gitlab:"GitLab",github:"GitHub"},Cs={connection:t=>U("GET",`/api/forge/${t}/connection`),connect:(t,n)=>U("POST",`/api/forge/${t}/connect`,n?{return:n}:{}),repos:t=>U("GET",`/api/forge/${t}/repos`).then(n=>n.repos),connectRepo:(t,n)=>U("POST",`/api/forge/${t}/repos/connect`,n),gitlabApp:()=>U("GET","/api/forge/gitlab/app"),setGitlabApp:t=>U("PUT","/api/forge/gitlab/app",t),teamRepo:(t,n)=>U("POST",`/api/forge/${t}/team-repo`,n)};function ah(t){const[n,a]=h.useState(null),l=()=>{t&&Promise.all(Fl.map(o=>Cs.connection(o).catch(()=>null))).then(([o,c])=>a({gitlab:o??null,github:c??null}))};return h.useEffect(l,[t]),[n,l]}function Mi(t){return Fl.find(n=>{var a;return(a=t==null?void 0:t[n])==null?void 0:a.connection})??null}const za={owner:"Owner",admin:"Admin",member:"Member",viewer:"Viewer"},Rb={password:"Password",sso:"SSO",google:"Google",github:"GitHub",microsoft:"Microsoft"},ux=t=>t.map(n=>Rb[n]??n).join(", ")||"none",rh={owner:"Full control: changes any role and removes any member.",admin:"Manages members, service accounts, repositories and settings.",member:"Reads every team and edits the teams they own.",viewer:"Reads every team's skills, tasks and requests and changes nothing; owns no team."},pa={owner:2,admin:1,member:0,viewer:-1};function lh(t){return["owner","admin","member","viewer"].filter(n=>pa[n]<=pa[t.role])}function dx(t){return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function _i({teams:t,value:n,onChange:a,label:l,disabled:o}){return t.length?e.jsxs("fieldset",{className:"teams",children:[e.jsx("legend",{className:"visually-hidden",children:l}),t.map(c=>e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:n.includes(c.team),disabled:o,onChange:d=>a(d.target.checked?[...n,c.team]:n.filter(u=>u!==c.team))}),c.team]},c.team))]}):e.jsx("span",{className:"muted",children:"No team yet"})}function hx({sent:t,skipped:n}){return e.jsxs("section",{className:"panel","aria-labelledby":"links-h",children:[e.jsx("h2",{id:"links-h",children:"Links to send"}),t.length?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Send each person their link: it works once, for 7 days, and is not shown again. ",e.jsx(Ie,{label:"invitation links",children:"The orchestrator sends no email, so the link reaches them only from you."})]}),e.jsx("ul",{className:"plain",children:t.map(a=>e.jsxs("li",{children:[a.email,": ",e.jsx(mt,{text:a.link,label:`Copy the link for ${a.email}`})]},a.id))})]}):null,n.map(a=>e.jsxs("p",{className:"muted",children:[a.email,": ",a.reason]},a.email))]})}const hf=/[\s,;]+/;function oh({me:t,teams:n,onSent:a,onCancel:l}){const[o,c]=h.useState([]),[d,u]=h.useState(""),[m,f]=h.useState("member"),[g,x]=h.useState([]),[y,b]=h.useState(null),[N,v]=h.useState(!1),k=h.useId(),S=h.useId(),$=P=>c(M=>[...M,...P.filter((O,_)=>O&&!M.includes(O)&&P.indexOf(O)===_)]),E=P=>{const M=P.split(hf);u(M.pop()??""),$(M)},C=P=>{P.preventDefault();const M=[...o,...d.split(hf).filter(O=>O&&!o.includes(O))];v(!0),b(null),Pr.invite({emails:M.join(" "),role:m,teams:m==="viewer"?[]:g}).then(O=>{c([]),u(""),x([]),v(!1),a(O.invited,O.skipped)},O=>{b(O.message),v(!1)})},R=y?{"aria-describedby":k}:{};return e.jsxs("form",{className:"form",onSubmit:C,"aria-labelledby":"invite-h",children:[e.jsx("h2",{id:"invite-h",children:"Invite members"}),o.length?e.jsx("ul",{className:"plain actions","aria-label":"Addresses to invite",children:o.map(P=>e.jsxs("li",{className:"badge",children:[P," ",e.jsx("button",{type:"button",className:"ghost small","aria-label":`Leave out ${P}`,onClick:()=>c(o.filter(M=>M!==P)),children:"×"})]},P))}):null,e.jsxs("label",{children:["Emails",e.jsx("input",{value:d,onChange:P=>E(P.target.value),onKeyDown:P=>{P.key==="Enter"&&d.trim()?(P.preventDefault(),E(`${d} `)):P.key==="Backspace"&&!d&&o.length&&c(o.slice(0,-1))},required:!o.length,autoComplete:"off",spellCheck:!1,"aria-describedby":y?`${S} ${k}`:S})]}),e.jsx("p",{className:"muted",id:S,children:"Separate addresses with spaces, commas or new lines."}),e.jsxs("fieldset",{children:[e.jsx("legend",{children:"Role"}),lh(t).map(P=>e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"radio",name:"invite-role",value:P,checked:m===P,onChange:()=>f(P),...R})," ",za[P]]},P))]}),e.jsx("p",{className:"muted",children:rh[m]}),m==="viewer"?null:e.jsxs("div",{children:[e.jsx("span",{children:"Team owner of"}),e.jsx(_i,{teams:n,value:g,onChange:x,label:"Teams they will own"})]}),y?e.jsx("p",{className:"error",role:"alert",id:k,children:y}):null,e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",disabled:N,children:"Create invitation links"}),l?e.jsx("button",{type:"button",className:"secondary",onClick:l,disabled:N,children:"Cancel"}):null]})]})}function Pb({invites:t,me:n,hideEmpty:a=!1,onChanged:l,onLink:o}){const[c,d]=h.useState(null),[u,m]=h.useState(null);if(a&&!t.length)return null;const f=t.find(x=>x.id===c)??null,g=x=>x.then(l,y=>m(y.message));return e.jsxs(Xt,{name:"Invitations",count:t.length,why:"Each waits for its person to open the link they were sent.",empty:"No invitation waits; Invite members makes links to send.",children:[u?e.jsx("p",{className:"error",role:"alert",children:u}):null,e.jsxs("table",{className:"member-table row-cards",children:[e.jsxs("colgroup",{children:[e.jsx("col",{className:"c-who"}),e.jsx("col",{className:"c-role"}),e.jsx("col",{className:"c-teams"}),e.jsx("col",{className:"c-when"}),e.jsx("col",{className:"c-way"})]}),e.jsx("thead",{className:"visually-hidden",children:e.jsxs("tr",{children:[e.jsx("th",{children:"Email"}),e.jsx("th",{children:"Role"}),e.jsx("th",{children:"Team owner of"}),e.jsx("th",{children:"Expires"}),e.jsx("th",{children:"Invited by"})]})}),e.jsx("tbody",{children:t.map(x=>e.jsxs("tr",{className:x.id===c?"picked":void 0,onClick:()=>d(x.id),children:[e.jsx("td",{className:"rc-title",children:e.jsx("button",{type:"button",className:"row-pick","aria-pressed":x.id===c,onClick:()=>d(x.id),children:x.email})}),e.jsx("td",{className:"rc-status",children:za[x.role]}),e.jsx("td",{className:x.teams.length?"rc-meta":"rc-meta muted member-wide-only",children:x.teams.length?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"member-cell-label",children:"Owns "}),e.jsx("span",{children:x.teams.join(", ")})]}):"none"}),e.jsx("td",{className:"rc-meta",children:x.expired?e.jsx("span",{className:"badge warn",children:"expired"}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"member-cell-label",children:"Expires "}),dx(x.expiresAt)]})}),e.jsx("td",{className:"rc-extra muted",children:x.invitedBy})]},x.id))})]}),f&&pa[f.role]<=pa[n.role]?e.jsxs("div",{className:"actions row-line",children:[e.jsx("button",{type:"button",className:"secondary","aria-label":`Resend the invitation to ${f.email}`,onClick:()=>g(Pr.resend(f.id).then(o)),children:"Resend the link"}),e.jsx(qe,{trigger:"Revoke…",triggerLabel:`Revoke the invitation to ${f.email}`,consequence:`The link sent to ${f.email} stops working at once.`,confirm:"Revoke invitation",keep:"Keep invitation",onConfirm:()=>Pr.revoke(f.id).then(()=>{d(null),l()})})]}):f?null:e.jsx("p",{className:"muted small row-line",children:"Pick an invitation to resend or revoke it."})]})}function Ab({user:t,teams:n,editable:a,onSave:l}){const[o,c]=h.useState(null);return o?e.jsxs(e.Fragment,{children:[e.jsx(_i,{teams:n,value:o,onChange:c,label:`Teams ${t.email} owns`}),e.jsxs("div",{className:"row-actions",children:[e.jsx("button",{type:"button",className:"small","aria-label":`Save the teams ${t.email} owns`,onClick:()=>l(o).then(()=>c(null),()=>{}),children:"Save"}),e.jsx("button",{type:"button",className:"secondary small",onClick:()=>c(null),children:"Cancel"})]})]}):e.jsxs("div",{className:"row-actions",children:[e.jsx("span",{children:t.ownedTeams.join(", ")||e.jsx("span",{className:"muted",children:"none"})}),a&&n.length?e.jsx("button",{type:"button",className:"secondary small","aria-label":`Edit the teams ${t.email} owns`,onClick:()=>c(t.ownedTeams),children:"Edit"}):null]})}function Ib({user:t,me:n,onChanged:a,onRemoved:l}){const[o,c]=h.useState([]),[d,u]=h.useState(null),m=h.useId();h.useEffect(()=>{pn.teams().then(c,()=>c([]))},[]);const f=y=>pn.update(t.id,y).then(a,b=>{throw u(b.message),b}),g=Me(n)&&pa[t.role]<=pa[n.role],x=t.id===n.id||!g;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx(Pe,{label:`Role of ${t.email}`,describedBy:d?m:void 0,value:t.role,disabled:x,onChange:y=>void f({role:y}).catch(()=>{}),options:["owner","admin","member","viewer"].filter(y=>y===t.role||lh(n).includes(y)).map(y=>({value:y,label:za[y]}))}),e.jsx("p",{className:"muted",children:t.id===n.id?"Nobody changes their own role.":rh[t.role]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"label",children:"Team owner of"}),e.jsx(Ab,{user:t,teams:o,editable:g,onSave:y=>f({teams:y})})]}),d?e.jsx("p",{className:"error",role:"alert",id:m,children:d}):null,t.id!==n.id&&g?e.jsx(qe,{trigger:`Remove ${t.name}`,triggerLabel:`Remove ${t.email}`,consequence:`${t.email} loses access at once: their sessions end and their API keys stop working. The requests and tasks they started stay with their teams.`,confirm:"Remove member",keep:"Keep member",onConfirm:()=>pn.remove(t.id).then(l)}):null]})}function Ob({user:t,me:n,onChanged:a,extra:l}){const[o,c]=h.useState(null),d=h.useId(),u=t.id===n.id||pa[t.role]>pa[n.role];return e.jsxs("tr",{children:[e.jsxs("td",{className:"rc-title",children:[e.jsx("a",{href:re("settings","members",t.id),children:t.name}),t.id===n.id?e.jsx("span",{className:"muted",children:" (you)"}):null,e.jsx("div",{className:"muted",children:t.email})]}),e.jsxs("td",{className:"rc-status",children:[e.jsx(Pe,{label:`Role of ${t.email}`,labelHidden:!0,describedBy:o?d:void 0,value:t.role,disabled:u,onChange:m=>pn.update(t.id,{role:m}).then(a,f=>c(f.message)),options:["owner","admin","member","viewer"].filter(m=>m===t.role||lh(n).includes(m)).map(m=>({value:m,label:za[m]}))}),o?e.jsx("p",{className:"error",role:"alert",id:d,children:o}):null]}),e.jsx("td",{className:t.ownedTeams.length?"rc-meta":"rc-meta muted member-wide-only",children:t.ownedTeams.length?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"member-cell-label",children:"Owns "}),e.jsx("span",{children:t.ownedTeams.join(", ")})]}):"none"}),e.jsxs("td",{className:"rc-meta",children:[e.jsx("span",{className:"member-cell-label",children:"Joined "}),dx(t.createdAt)]}),e.jsx("td",{className:"rc-meta",children:ux(t.signIn)}),l?e.jsxs("td",{className:"rc-meta",children:[e.jsxs("span",{className:"member-cell-label",children:[l.name,": "]}),l.cell]}):null]})}function Lb({me:t,onLeft:n}){const[a,l]=h.useState(null),[o,c]=h.useState(null),d=()=>pn.teams().then(l,u=>c(u.message));return h.useEffect(()=>{d()},[]),e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"panel","aria-labelledby":"teams-h",children:[e.jsxs("h2",{id:"teams-h",children:["Teams ",a?e.jsx("span",{className:"count",children:a.length}):null]}),e.jsxs("p",{className:"muted",children:["You read every team",t.ownedTeams.length?` and are team owner of ${t.ownedTeams.join(", ")}`:"","; ",e.jsx("a",{href:re("settings","members",t.id),children:"open your own member page"}),". ",e.jsx(Ie,{label:"teams",children:"A team's owners edit its skills, MCP servers and commands; an owner or an admin manages members."})]}),o?e.jsx(be,{what:"teams",reason:o,onRetry:()=>{c(null),d()}}):a?a.length?e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Team"}),e.jsx("th",{children:"Team owners"}),e.jsx("th",{children:"Repositories"})]})}),e.jsx("tbody",{children:a.map(u=>e.jsxs("tr",{children:[e.jsx("td",{children:u.team}),e.jsx("td",{children:u.owners.map(m=>m.name).join(", ")||e.jsx("span",{className:"muted",children:"none yet"})}),e.jsx("td",{children:u.repos.join(", ")})]},u.team))})]}):e.jsx("p",{className:"muted",children:"No team yet."}):e.jsx(he,{what:"teams"})]}),e.jsx(mx,{me:t,onLeft:n})]})}function mx({me:t,onLeft:n}){return e.jsxs("section",{className:"panel","aria-labelledby":"leave-h",children:[e.jsx("h2",{id:"leave-h",children:"Leave the organization"}),t.role==="owner"?e.jsx("p",{className:"muted",children:"Make another member an owner first; then you can leave."}):e.jsx(qe,{trigger:"Leave…",consequence:"You lose access to every team here at once. An owner or an admin invites you again if you need to come back.",confirm:"Leave the organization",keep:"Stay",onConfirm:()=>Pr.leave().then(n)})]})}const Fb=[{role:"owner",name:"Owners",empty:"No owner."},{role:"admin",name:"Admins",empty:"No admin yet; an owner makes one by changing a member's role."},{role:"member",name:"Members",empty:"No member yet; invite the people who work on your team's skills."},{role:"viewer",name:"Viewers",empty:"No viewer yet; a viewer reads every team and changes nothing."}],mf=(t,n,a)=>`${t} ${t===1?n:a}`;function px(t){const[n,a]=h.useState(null),[l,o]=h.useState([]),[c,d]=h.useState([]),[u,m]=h.useState(null),[f,g]=h.useState(null),[x,y]=h.useState(null),b=Me(t),N=()=>{b&&(g(null),y(null),pn.users().then(a,v=>g(v.message)),pn.teams().then(o,()=>o([])),Pr.invites().then(d,v=>y(v.message)))};return h.useEffect(N,[b]),{users:n,teams:l,invites:c,sent:u,setSent:m,error:f,invitesError:x,reload:N}}function fx({me:t,data:n,extra:a,hideEmpty:l=!1}){const[o,c]=h.useState(""),[d,u]=h.useState(1),{users:m,invites:f,sent:g,setSent:x,error:y,invitesError:b,reload:N}=n,v=o.trim().toLowerCase(),k=(m??[]).filter(C=>!v||C.name.toLowerCase().includes(v)||C.email.toLowerCase().includes(v)),S=Jd(k,d),$=["Member","Role","Team owner of","Joined","Signs in with",...a?[a.name]:[]],E=a?" with-extra":"";return e.jsxs(e.Fragment,{children:[g?e.jsx(hx,{sent:g.sent,skipped:g.skipped}):null,y?e.jsx(be,{what:"members",reason:y,onRetry:N}):m?e.jsxs(e.Fragment,{children:[m.length>Dl?e.jsxs("label",{className:"filter",children:["Find a member",e.jsx("input",{type:"search","data-page-search":!0,value:o,onChange:C=>{c(C.target.value),u(1)}})]}):null,v&&!k.length?e.jsxs("p",{className:"muted",children:["No one matches “",o.trim(),"”."]}):null,e.jsxs("div",{className:"turn-columns member-head","aria-hidden":"true",children:[e.jsx("span",{}),e.jsx("span",{className:`member-columns${E}`,children:$.map(C=>e.jsx("span",{children:C},C))})]}),Fb.map(({role:C,name:R,empty:P})=>{const M=S.shown.filter(O=>O.role===C);return l&&!v&&!k.some(O=>O.role===C)?null:e.jsx(Xt,{name:R,count:k.filter(O=>O.role===C).length,why:rh[C],empty:v?`No one here matches “${o.trim()}”.`:P,children:M.length?e.jsxs("table",{className:`member-table row-cards${E}`,children:[e.jsxs("colgroup",{children:[e.jsx("col",{className:"c-who"}),e.jsx("col",{className:"c-role"}),e.jsx("col",{className:"c-teams"}),e.jsx("col",{className:"c-when"}),e.jsx("col",{className:"c-way"}),a?e.jsx("col",{className:"c-extra"}):null]}),e.jsx("thead",{className:"visually-hidden",children:e.jsx("tr",{children:$.map(O=>e.jsx("th",{children:O},O))})}),e.jsx("tbody",{children:M.map(O=>e.jsx(Ob,{user:O,me:t,onChanged:N,extra:a?{name:a.name,cell:a.cell(O)}:void 0},O.id))})]}):e.jsx("p",{className:"turn-empty",children:"On another page of this list."})},C)}),e.jsx(Li,{page:S.page,total:k.length,onPage:u,label:"Pages of members"})]}):e.jsx(he,{what:"members"}),b?e.jsx(be,{what:"invitations",reason:b,onRetry:N}):e.jsx(Pb,{invites:f,me:t,hideEmpty:l,onChanged:N,onLink:C=>x({sent:[C],skipped:[]})})]})}function Mb({me:t,nav:n,onLeft:a}){const l=px(t),[o,c]=h.useState(!1);if(!Me(t))return e.jsxs(e.Fragment,{children:[e.jsx(Yn,{title:"Members",summary:"Who owns each team, so you know whom to ask."}),n,e.jsx(Lb,{me:t,onLeft:a})]});const{users:d,invites:u}=l,m=d?`${mf(d.length,"person","people")} in this organization${u.length?`; ${mf(u.length,"invitation waits","invitations wait")} to be taken up`:""}.`:void 0;return e.jsxs(e.Fragment,{children:[e.jsx(Yn,{title:"Members",summary:m,actions:o?null:e.jsx("button",{type:"button",onClick:()=>c(!0),children:"Invite members"})}),n,o?e.jsx("section",{className:"panel",children:e.jsx(oh,{me:t,teams:l.teams,onCancel:()=>c(!1),onSent:(f,g)=>{l.setSent({sent:f,skipped:g}),c(!1),l.reload()}})}):null,e.jsx(fx,{me:t,data:l}),e.jsx(mx,{me:t,onLeft:a})]})}const _b={catalog:()=>U("GET","/api/tags").then(t=>t.tags.map(n=>({tag:n.tag,members:n.members.length})))},gx={get:t=>U("GET",`/api/members/${encodeURIComponent(t)}/config`),preview:(t,n,a)=>U("POST",`/api/members/${encodeURIComponent(t)}/config/preview`,{audience:n,rules:a})},hn={list:()=>U("GET","/api/policies"),preview:(t,n)=>U("POST","/api/policies/preview",{audience:t,rules:n}),proposal:(t,n)=>U("POST","/api/policies/proposal",n?{...t?{id:t}:{},policy:n}:{id:t,remove:!0}),save:(t,n,a)=>t?U("PUT",`/api/policies/${encodeURIComponent(t)}`,{policy:n,...a}):U("POST","/api/policies",{policy:n,...a}),remove:(t,n)=>U("DELETE",`/api/policies/${encodeURIComponent(t)}`,n??{})},As=t=>t.role==="admin"||t.role==="owner",pf=t=>t.startsWith("service:");function Ub(t,n){const a=t.split("*").map(l=>l.replace(/[.+?^${}()|[\]\\]/g,"\\$&"));return new RegExp(`^${a.join(".*")}$`).test(n)}function Db(t){switch(t.kind){case"skill.add":case"skill.edit":case"skill.delete":return{subject:t.slug,resource:`skill:${t.slug}`,removing:t.kind==="skill.delete",skill:t.slug};case"mcp.add":case"mcp.edit":case"mcp.remove":return{subject:t.name,resource:`mcp:${t.name}`,removing:t.kind==="mcp.remove",skill:null};case"command.add":case"command.edit":case"command.delete":return{subject:`/${t.name}`,resource:null,removing:t.kind==="command.delete",skill:null};default:return null}}function Bb(t,n,a){const l=Db(n);if(!l)return null;const o=a.teams.find(u=>u.repos.includes(t))??null,c=l.skill?a.usage.filter(u=>u.repoId===t&&u.skill===l.skill):[],d=l.resource?a.policies.filter(u=>(!u.repos||u.repos.includes(t))&&u.rules.some(m=>"resources"in m&&m.resources.some(f=>Ub(f,l.resource)||f.startsWith(`${l.resource}/`)))):[];return{subject:l.subject,removing:l.removing,team:(o==null?void 0:o.team)??null,overlap:l.skill?a.overlaps[l.skill]??null:null,usage:l.skill?{count:c.reduce((u,m)=>u+m.count,0),days:a.usageDays,lastHour:c.map(u=>u.lastHour).sort().at(-1)??null}:null,policies:d.map(u=>({id:u.id,name:u.name}))}}const xx=["approval-required","auto-accept-edits","auto","full-access"],jd={"approval-required":"Approval required","auto-accept-edits":"Auto-accept edits",auto:"Auto","full-access":"Full access"},qb={"approval-required":"asks before every edit and command","auto-accept-edits":"edits files on its own and asks before a command",auto:"edits and runs the commands its rules allow without asking","full-access":"runs anything in its sandbox without asking; its work still ends in a request someone reviews"},Wb="auto",ff=t=>xx.indexOf(t),zb=["workspace","teams","members","except-members","tags","except-tags","service-accounts"],Hb=["skill-access","mcp-access","tool-access"],Ci=20,gf=20,yd=100,vd=200,kd=1e6,xf=["Bash","Read","Edit","Glob","Grep","WebFetch","WebSearch"],Ml=t=>Hb.includes(t);function En(t){return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t.at(-1)}`}function bd(t,n,a){return t===1?n:a}function ih(t){return`$${t.toLocaleString("en-US",{maximumFractionDigits:2})}`}const Gb={"skill-access":"skill:","mcp-access":"mcp:","tool-access":"tool:"};function ch(t,n){return`${Gb[t]}${n.trim()}`}function wd(t){const[n,...a]=t.split(":");if(n==="tool"){const[l,...o]=a,c=o.join(":");return c==="*"||!c?`${l}`:`${l} (${c})`}if(n==="mcp"){const[l,o]=a.join(":").split("/");return o?`${o} on ${l}`:`${l}`}return a.join(":")||t}function jf(t,n=a=>a){if(t.kind==="workspace")return"Everyone in the organization";const a=En(t.ids.map(n));switch(t.kind){case"teams":return a?`Members of ${a}`:"Members of the chosen teams";case"members":return a||"The chosen members";case"except-members":return a?`Everyone except ${a}`:"Everyone except the chosen members";case"tags":return a?`Members tagged ${a}`:"Members with the chosen tags";case"except-tags":return a?`Everyone except members tagged ${a}`:"Everyone except members with the chosen tags";case"service-accounts":return a?`The service ${bd(t.ids.length,"account","accounts")} ${a}`:"The chosen service accounts"}}function Kb(t){switch(t.kind){case"skill-access":case"mcp-access":case"tool-access":{const n=En(t.resources.map(wd));return t.kind==="skill-access"?n?`cannot use the ${bd(t.resources.length,"skill","skills")} ${n}`:"cannot use the chosen skills":t.kind==="mcp-access"?n?`cannot use the MCP ${bd(t.resources.length,"server","servers")} ${n}`:"cannot use the chosen MCP servers":n?`cannot use ${n} in Claude Code`:"cannot use the chosen tools in Claude Code"}case"task-budget":{const n=t.monthlyUsd===null?"a monthly limit":ih(t.monthlyUsd);return t.per==="member"?`can each spend up to ${n} a month on tasks`:`can spend up to ${n} a month on tasks, together`}case"repo-access":{const n=En(t.repos)||"the chosen repositories";return t.effect==="allow"?`can start tasks on ${n}`:`cannot start tasks on ${n}`}case"task-mode":return`can run tasks on ${t.repos.includes("*")?"every repository":En(t.repos)||"the chosen repositories"} in ${jd[t.ceiling]} mode at most`;case"own-setup":{const n=t.repos.includes("*")?"every repository":En(t.repos)||"the chosen repositories";return t.allowed?`can run tasks on ${n} with their own Claude Code setup`:`can run tasks on ${n} only with their sign-in and the team's skills`}}}function uh(t,n){return t.rules.length?`${jf(t.audience,n)} ${En(t.rules.map(Kb))}.`:`${jf(t.audience,n)}: add a rule to say what this policy does.`}const Yb={teams:"Choose teams",members:"Choose members","except-members":"Choose the members to leave out",tags:"Choose tags","except-tags":"Choose the tags to leave out","service-accounts":"Choose service accounts"},Vb={"skill-access":"Name the skills this rule blocks","mcp-access":"Name the MCP servers this rule blocks","tool-access":"Name the tools this rule blocks"},Qb="Rules that reach teammates' sessions are saved as a request and the orchestrator's own rules apply at once; put them in two policies.",jx="Rules that reach teammates' sessions apply to whole teams: a teammate's machine does not say who is at it.";function yx(t){if(t.audience.kind!=="workspace"&&!t.audience.ids.length)return`${Yb[t.audience.kind]} to continue.`;if(!t.rules.length)return"Add a rule to continue.";if(t.rules.length>Ci)return`A policy holds at most ${Ci} rules; split it in two.`;for(const a of t.rules)if(a.kind==="task-budget"){if(a.monthlyUsd===null||!Number.isFinite(a.monthlyUsd))return"Enter a monthly limit to continue.";if(a.monthlyUsd<=0||a.monthlyUsd>kd)return`Enter a monthly limit above $0 and at most ${ih(kd)}.`}else if(a.kind==="repo-access"||a.kind==="task-mode"||a.kind==="own-setup"){if(!a.repos.length)return"Choose repositories to continue."}else{if(!a.resources.length)return`${Vb[a.kind]} to continue.`;if(a.resources.length>gf)return`A rule names at most ${gf} entries; add another rule for the rest.`;if(!a.reason.trim())return"Say why this is blocked; teammates read it when a call is stopped.";if(a.reason.length>vd)return`Keep the reason to ${vd} characters.`}const n=t.rules.filter(a=>Ml(a.kind)).length;return n&&n<t.rules.length?Qb:n&&t.audience.kind!=="workspace"&&t.audience.kind!=="teams"?jx:null}function Jb(t){const n=t.name.trim();return n?n.length>yd?`Keep the name to ${yd} characters.`:yx(t):"Name the policy to continue."}function Rn(t){return t.rules.some(n=>Ml(n.kind))}function Xb(t){return Rn(t)?"Saved as a request; teammates get it once it is merged.":"Applies now to the tasks this orchestrator runs, and is recorded in the audit log."}function Zb(t){const n=t.rules.flatMap(a=>a.kind==="task-budget"?[`tasks stop counting against its ${a.monthlyUsd===null?"monthly":`${ih(a.monthlyUsd)} monthly`} budget`]:a.kind==="repo-access"?["its rules on where tasks start stop holding"]:a.kind==="task-mode"?["its ceiling on how much agents do without asking stops holding"]:a.kind==="own-setup"&&!a.allowed?["tasks use their starter's own Claude Code setup again"]:[]);return`Deleting it applies at once: ${En([...new Set(n)])||"its rules stop holding"}. The deletion is recorded in the audit log.`}function ew(t,n){if(n.rules.length>=Ci)return`A policy holds at most ${Ci} rules.`;const a=Ml(t);return n.rules.some(l=>Ml(l.kind)!==a)?a?"This policy holds the orchestrator's own rules; block things on teammates' machines in a policy of its own.":"This policy reaches teammates' machines; orchestrator rules go in a policy of their own.":!a&&!n.isAdmin?"Only an admin sets the orchestrator's own rules.":!a&&!n.orchestratorRulesStored?"This orchestrator's database does not keep its own rules yet. Ask whoever runs the orchestrator to update it to the latest release.":null}function yf(t,n){return Rn({rules:n})&&t!=="workspace"&&t!=="teams"?jx:null}function tw(t){return t==="task-budget"?{kind:t,monthlyUsd:null,per:"audience"}:t==="repo-access"?{kind:t,effect:"allow",repos:[]}:t==="task-mode"?{kind:t,ceiling:"auto",repos:["*"]}:t==="own-setup"?{kind:t,allowed:!1,repos:["*"]}:{kind:t,effect:"deny",resources:[],reason:""}}const Nd=[{kind:"skill-access",label:"Skills",hint:"Block skills in teammates' sessions"},{kind:"mcp-access",label:"MCP servers",hint:"Retire or block MCP servers"},{kind:"tool-access",label:"Tools",hint:"Block Claude Code tools and commands"},{kind:"task-budget",label:"Task budget",hint:"Cap what agent tasks spend each month"},{kind:"repo-access",label:"Repository access",hint:"Choose where tasks may run"},{kind:"task-mode",label:"Permission ceiling",hint:"Cap how much agents do without asking"},{kind:"own-setup",label:"Starter's own setup",hint:"Choose whether tasks bring the starter's Claude Code setup"}],Iu=[{id:"retire-mcp",name:"Retire an MCP server",description:"Stop everyone using a server the team replaced.",draft:t=>({name:"Retire an MCP server",audience:t.everyone?{kind:"workspace"}:{kind:"teams",ids:[...t.teams]},rules:[{kind:"mcp-access",effect:"deny",resources:[],reason:"This server is retired; the team uses its replacement."}]})},{id:"read-only-bash",name:"Read-only Bash for a team",description:"A team keeps Bash for reading; commands that change files or history are blocked.",draft:t=>({name:"Read-only Bash",audience:{kind:"teams",ids:t.everyone?[]:[...t.teams]},rules:[{kind:"tool-access",effect:"deny",resources:["rm *","mv *","git commit *","git reset *"].map(n=>ch("tool-access",`Bash:${n}`)),reason:"This team uses Bash to read; changes go through a teammate."}]})},{id:"team-task-budget",name:"Monthly task budget per team",description:"Cap what agent tasks for a team spend in a month.",draft:()=>({name:"Monthly task budget",audience:{kind:"teams",ids:[]},rules:[{kind:"task-budget",monthlyUsd:null,per:"audience"}]})},{id:"skill-one-team",name:"Keep a skill to one team",description:"Block a skill for every team listed; take the team that keeps it off the list.",draft:t=>({name:"Keep a skill to one team",audience:{kind:"teams",ids:[...t.teams]},rules:[{kind:"skill-access",effect:"deny",resources:[],reason:"This skill belongs to another team's work."}]})}];function vx(t,n,a=!1){return a?t?Iu.filter(l=>!Rn(l.draft({teams:[],everyone:!0}))).map(l=>({...l,name:l.name.replace(/ per team$/,""),description:"Cap what your agent tasks spend in a month.",draft:o=>({...l.draft(o),audience:{kind:"workspace"}})})):[]:t?Iu:n?Iu.filter(l=>Rn(l.draft({teams:[],everyone:!1}))):[]}function nw(t){if(t.length<=1)return t[0]??"";let n=t[0];for(const a of t.slice(1)){let l=0;for(;l<n.length&&l<a.length&&n[n.length-1-l]===a[a.length-1-l];)l++;n=n.slice(n.length-l)}return n.trimStart()}function sw(t){return t?`${t.toLocaleString("en-US")} policies hold groups to rules.`:"No policy holds anyone to a rule yet."}function aw({repoId:t,change:n}){const[a,l]=h.useState(void 0),o=JSON.stringify(n);if(h.useEffect(()=>{let d=!0;const u=n.kind.startsWith("skill.");return Promise.all([pn.teams().catch(()=>[]),u?Ce.usage(t).catch(()=>({days:30,usage:[]})):Promise.resolve({days:30,usage:[]}),u?Ce.overlaps(t).then(m=>m.overlaps).catch(()=>({})):Promise.resolve({}),hn.list().then(m=>m.policies).catch(()=>[])]).then(([m,f,g,x])=>{d&&l(Bb(t,n,{teams:m,usage:f.usage,usageDays:f.days,overlaps:g,policies:x}))}),()=>{d=!1}},[t,o]),a===null)return null;if(a===void 0)return e.jsx("p",{className:"muted change-preview","aria-busy":"true",children:"Checking what this change touches…"});const c=a.team?`teammates on ${a.team}`:"teammates using this repository";return e.jsxs("section",{className:"change-preview","aria-label":"What this change touches",children:[e.jsx("p",{className:"field-label",children:"What this change touches"}),e.jsxs("ul",{className:"plain",children:[e.jsx("li",{children:a.removing?`Once merged, ${c} lose ${a.subject}.`:`Once merged, ${c} get this version of ${a.subject}.`}),a.usage?e.jsx("li",{children:a.usage.count?`Used ${a.usage.count.toLocaleString("en-US")} ${a.usage.count===1?"time":"times"} in the last ${a.usage.days} days${a.usage.lastHour?`, last on ${a.usage.lastHour.slice(0,10)}`:""}.`:`No reported use in the last ${a.usage.days} days.`}):null,a.overlap&&!a.removing?e.jsxs("li",{children:["Answers the same requests as ",En(a.overlap.names),a.overlap.more?` and ${a.overlap.more} more`:"","; a session picks one of them."]}):null,a.policies.map(d=>e.jsxs("li",{children:["The policy ",e.jsx("a",{href:re("team","policies",d.id),children:d.name})," ",a.removing?"blocks it today; that rule stays in the team file.":"blocks it; teammates keep being stopped from using it after the merge."]},d.id))]})]})}const rw={impact:(t,n,a)=>U("GET",`/api/repos/${encodeURIComponent(t)}/removal?${new URLSearchParams({[n]:a})}`)};function lw(t){if(!t.counted)return"This team does not report skill use, so recent use is not counted.";if(!t.count)return`No reported use in the last ${t.days} days.`;const n=t.lastHour?`, last on ${t.lastHour.slice(0,10)}`:"";return`Used ${t.count.toLocaleString("en-US")} ${t.count===1?"time":"times"} in the last ${t.days} days${n}.`}const ow={add:"adds the policy",change:"changes the policy",remove:"removes the policy"};function kx({plan:t,action:n,onConfirm:a,onCancel:l}){const o=h.useId(),[c,d]=h.useState(()=>nw(t.repos.map(v=>v.proposal))),[u,m]=h.useState(()=>Object.fromEntries(t.repos.map(v=>[v.repoId,v.branch]))),[f,g]=h.useState(!1),[x,y]=h.useState(null),b=async()=>{g(!0),y(null),await a({message:c,branches:u,baseShas:Object.fromEntries(t.repos.map(v=>[v.repoId,v.head]))}).catch(v=>y(v.message)),g(!1)},N=t.repos.length;return e.jsxs("section",{className:"panel confirm","aria-labelledby":`${o}-h`,onKeyDown:v=>v.key==="Enter"&&v.target instanceof HTMLInputElement&&v.preventDefault(),children:[e.jsxs("h2",{id:`${o}-h`,children:[n," as ",N===1?"a request":`${N} requests`]}),e.jsx("p",{className:"muted",children:"Each team repository gets its own request, and teammates get the change once it is merged there."}),e.jsxs("div",{className:"field",children:[e.jsx("label",{htmlFor:`${o}-msg`,children:"Commit message"}),e.jsx("input",{id:`${o}-msg`,value:c,onChange:v=>d(v.target.value)})]}),e.jsx("ul",{className:"plain confirm-repos",children:t.repos.map(v=>e.jsxs("li",{children:[e.jsxs("p",{children:[e.jsx("strong",{children:v.name})," ",e.jsxs("span",{className:"muted",children:["(",ow[v.change],")"]})]}),e.jsxs("p",{className:"muted small-print",children:["Proposed: ",e.jsx("span",{className:"mono",children:v.proposal})]}),e.jsx("label",{className:"inline-label",htmlFor:`${o}-b-${v.repoId}`,children:"Branch"}),e.jsx("input",{id:`${o}-b-${v.repoId}`,className:"mono",value:u[v.repoId]??"",onChange:k=>m({...u,[v.repoId]:k.target.value})})]},v.repoId))}),x?e.jsx("p",{className:"error",role:"alert",children:x}):null,e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",onClick:b,disabled:f||!c.trim(),children:f?"Opening…":N===1?"Open the request":`Open ${N} requests`}),e.jsx("button",{type:"button",className:"secondary",onClick:l,disabled:f,children:"Back to the policy"})]})]})}function bx({saved:t,repoName:n,back:a}){return e.jsxs("section",{className:"panel",role:"status","aria-labelledby":"opened-h",children:[e.jsx("h2",{id:"opened-h",children:t.requests.length?"Saved as a request; reaches teammates when merged":"No request opened"}),t.requests.length?e.jsx("ul",{className:"plain",children:t.requests.map(l=>e.jsxs("li",{children:[e.jsxs("a",{href:l.url,target:"_blank",rel:"noreferrer",children:[n(l.repoId)," #",l.number]})," ",e.jsx("span",{className:"muted",children:l.title})]},`${l.repoId}/${l.number}`))}):null,t.failed.length?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"error",children:"These repositories did not get a request:"}),e.jsx("ul",{className:"plain",children:t.failed.map(l=>e.jsxs("li",{children:[e.jsx("strong",{children:n(l.repoId)}),": ",l.error]},l.repoId))})]}):null,e.jsx("p",{children:e.jsx("a",{href:a,children:"Back to policies"})})]})}function wx({repoId:t,kind:n,name:a}){const[l,o]=h.useState(void 0),[c,d]=h.useState({at:"offer"}),[u,m]=h.useState(!1),[f,g]=h.useState(null);if(h.useEffect(()=>{let v=!0;return rw.impact(t,n,a).then(k=>v&&o(k),()=>v&&o(null)),()=>{v=!1}},[t,n,a]),l===null)return null;if(l===void 0)return e.jsxs("p",{className:"muted removal-impact","aria-busy":"true",children:["Checking what removing ",a," takes away…"]});const x=l.disable,y=x&&x.audience.kind==="teams"?En(x.audience.ids):null,b=async()=>{x&&(m(!0),g(null),await hn.proposal(null,x).then(v=>v.applies==="request"?d({at:"confirm",plan:v}):g("This policy would not open a request; disable it from Controls."),v=>g(v.message)),m(!1))},N=async v=>{if(!x)return;const k=await hn.save(null,x,v);k.saved==="request"&&d({at:"opened",saved:k})};return e.jsxs("section",{className:"removal-impact","aria-label":"What this removal takes away",children:[e.jsxs("ul",{className:"plain",children:[e.jsxs("li",{children:[y?`Teammates on ${y}`:"Teammates using this repository"," lose ",a," once the request is merged."]}),l.usage?e.jsx("li",{children:lw(l.usage)}):null]}),l.blockedBy.length?e.jsxs("p",{className:"muted",children:["Already blocked by ",l.blockedBy.map((v,k)=>e.jsxs("span",{children:[k?", ":"",e.jsx("a",{href:re("team","policies",v.id),children:v.name})]},v.id)),"; removing it also deletes its files."]}):null,x&&c.at==="offer"?e.jsxs("div",{className:"disable-instead",children:[e.jsxs("p",{className:"muted",children:["Keeps its files and blocks it for the team. ",e.jsxs(Ie,{label:"disabling instead",children:["It is written to every repository of ",y??"the team"," and reviewed there; deleting the policy later turns ",a," back on."]})]}),f?e.jsx("p",{className:"error",role:"alert",children:f}):null,e.jsx("button",{type:"button",className:"secondary small",onClick:b,disabled:u,children:u?"Preparing…":"Disable instead"})]}):null,c.at==="confirm"?e.jsx(kx,{plan:c.plan,action:`Disable ${a}`,onConfirm:N,onCancel:()=>d({at:"offer"})}):null,c.at==="opened"?e.jsx(bx,{saved:c.saved,repoName:v=>v,back:re("team")}):null]})}const iw=t=>t.split("/").map(encodeURIComponent).join("/");function dh(t){return{changes:()=>U("GET",t).then(n=>n.changes),file:n=>U("GET",`${t}/${iw(n)}`).then(a=>a.file)}}function Ui(t,n){return dh(`/api/repos/${encodeURIComponent(t)}/requests/${n}/changes`)}function cw(t,n){return dh(`/api/tasks/${encodeURIComponent(t)}/turns/${n}/changes`)}function uw(t){return dh(`/api/tasks/${encodeURIComponent(t)}/changes`)}function dw(t,n,a){let l=!1;return{changes:()=>t.changes().catch(o=>{if(!(o instanceof ht&&o.code==="changes-on-machine"))throw o;return l=!0,a(),{files:n,omitted:0}}),file:o=>l?Promise.resolve({patch:null,truncated:!1,note:"its patch stays on the computer the task ran on; open the folder there to read it"}):t.file(o)}}function Nx(t,n){return U("GET",`/api/repos/${encodeURIComponent(t)}/requests/${n}/status`).then(a=>a.status)}const hw=3;let Ou=0;const vf=[];async function mw(t){var n;Ou>=hw&&await new Promise(a=>vf.push(a)),Ou+=1;try{return await t()}finally{Ou-=1,(n=vf.shift())==null||n()}}function Sx(t){const n=t.checks.filter(a=>a.state==="failure").length;return t.state==="failing"?`${n||"some"} ${n===1?"check":"checks"} failing`:{passing:"checks passing",pending:"checks running","no-ci":"no CI",unknown:"no check reported yet"}[t.state]}function pw(t){return t.decision==="approved"?t.approvedBy.length?`approved by ${t.approvedBy.join(", ")}`:"approved":{"changes-requested":"changes requested",pending:"waiting for a reviewer",none:"no reviewer asked"}[t.decision]}function fw(t){return t.state==="not-open"?null:t.state==="blocked"?t.reason?`blocked: ${t.reason}`:"blocked":{mergeable:"ready to merge",conflict:"has a conflict to resolve",checking:"checking whether it merges"}[t.state]}function gw(t){const n=t.filter(a=>a.kind!=="bot");return n.length?`${n.length} ${n.length===1?"comment":"comments"}, the newest from ${n[0].author}`:null}function xw(t){const{detail:n}=t,a=fw(n.mergeability),l=n.checks.state==="failing",o=n.mergeability.state==="mergeable"&&!l?"ok":n.mergeability.state==="conflict"||n.mergeability.state==="blocked"||l?"warn":"neutral",c=t.source==="local"?[]:[Sx(n.checks),pw(n.review),gw(t.comments)];return{merge:a,tone:o,rest:c.filter(Boolean).join(", ")}}function hh({request:t}){const[n,a]=h.useState(null),[l,o]=h.useState(null),c=t.status==="open",d=t.provider==="local";if(h.useEffect(()=>{if(!c)return;let m=!0;return mw(()=>Nx(t.repoId,t.number)).then(f=>m&&a(f),f=>m&&o(f.message)),()=>{m=!1}},[t.repoId,t.number,c]),!c)return null;if(t.heldHead||t.heldReason!==void 0)return e.jsxs("p",{className:"small forge-state",children:[e.jsx("span",{className:"state warn",children:"changed after the check"})," ",e.jsxs("span",{className:"muted",children:[t.heldReason?`${t.heldReason.charAt(0).toUpperCase()}${t.heldReason.slice(1)}. `:"","It merges once a later push passes the team's rules."]})]});if(l)return d?null:e.jsxs("p",{className:"muted small forge-state",children:["Where it stands is not known: ",l]});if(!n)return d?null:e.jsx("p",{className:"muted small forge-state",children:"Reading the forge…"});const u=xw(n);return!u.merge&&!u.rest?null:e.jsxs("p",{className:"small forge-state",children:[u.merge?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`state ${u.tone}`,children:u.merge})," "]}):null,u.rest?e.jsx("span",{className:"muted",children:u.rest}):null]})}function Cx(t){try{const n=new URL(t);return n.protocol==="https:"||n.protocol==="http:"?n.href:null}catch{return null}}const jw=/`([^`]+)`|\*\*([^*]+)\*\*|__([^_]+)__|\*([^*\s][^*]*)\*|_([^_\s][^_]*)_|!?\[([^\]]*)\]\(([^)\s]+)\)/g;function aa(t){const n=[];let a=0;for(const l of t.matchAll(jw)){l.index>a&&n.push({kind:"text",text:t.slice(a,l.index)});const[o,c,d,u,m,f,g,x]=l;if(c!==void 0)n.push({kind:"code",text:c});else if(d!==void 0||u!==void 0)n.push({kind:"strong",children:aa(d??u)});else if(m!==void 0||f!==void 0)n.push({kind:"em",children:aa(m??f)});else if(o.startsWith("!"))n.push({kind:"image",src:x,alt:g??""});else{const y=Cx(x);n.push(y?{kind:"link",href:y,children:aa(g||x)}:{kind:"text",text:o})}a=l.index+o.length}return a<t.length&&n.push({kind:"text",text:t.slice(a)}),n}const kf=/^\s{0,3}(?:([-*+])|(\d{1,9})[.)])\s+(.*)$/,yw=8,Lu=t=>t.trim().replace(/^\|/,"").replace(/\|$/,"").split(new RegExp("(?<!\\\\)\\|")).map(n=>n.replace(/\\\|/g,"|").trim()),vw=/^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/,kw=12,bw=200;function $x(t,n=0){const a=t.replace(/\r\n?/g,`
|
|
43
|
+
`).split(`
|
|
44
|
+
`),l=[];let o=[];const c=()=>{o.length&&l.push({kind:"paragraph",children:aa(o.join(" "))}),o=[]};for(let d=0;d<a.length;d++){const u=a[d],m=/^\s{0,3}(`{3,}|~{3,})\s*([\w+-]*)\s*$/.exec(u);if(m){c();const x=m[1],y=new RegExp(`^\\s{0,3}${x[0]==="`"?"`":"~"}{${x.length},}\\s*$`),b=[];for(;++d<a.length&&!y.test(a[d]);)b.push(a[d]);l.push({kind:"code",lang:m[2]??"",text:b.join(`
|
|
45
|
+
`)});continue}const f=/^\s{0,3}(#{1,6})\s+(.*?)\s*#*\s*$/.exec(u);if(f){c(),l.push({kind:"heading",level:f[1].length,children:aa(f[2])});continue}if(/^\s{0,3}([-*_])(\s*\1){2,}\s*$/.test(u)){c(),l.push({kind:"rule"});continue}if(n<yw&&/^\s{0,3}>/.test(u)){c();const x=[];for(;d<a.length&&/^\s{0,3}>/.test(a[d]);d++)x.push(a[d].replace(/^\s{0,3}>\s?/,""));d--,l.push({kind:"quote",children:$x(x.join(`
|
|
46
|
+
`),n+1)});continue}if(u.includes("|")&&d+1<a.length&&vw.test(a[d+1])&&a[d+1].includes("-")){const x=Lu(u);if(x.length>=2&&x.length<=kw&&Lu(a[d+1]).length===x.length){c();const y=[];for(d+=2;d<a.length&&a[d].includes("|")&&a[d].trim()&&y.length<bw;d++){const b=Lu(a[d]);y.push(x.map((N,v)=>aa(b[v]??"")))}d--,l.push({kind:"table",head:x.map(b=>aa(b)),rows:y});continue}}const g=kf.exec(u);if(g){c();const x=g[2]!==void 0,y=[];for(;d<a.length;d++){const b=kf.exec(a[d]);if(b&&b[2]!==void 0===x)y.push(aa(b[3]));else if(a[d].trim()&&/^\s{2,}/.test(a[d])&&y.length)y[y.length-1].push({kind:"text",text:` ${a[d].trim()}`});else break}d--,l.push({kind:"list",ordered:x,items:y});continue}u.trim()?o.push(u.trim()):c()}return c(),l}const Jt={comment:"//[^\\n]*|/\\*[\\s\\S]*?(?:\\*/|$)",keywords:"abstract|as|async|await|break|case|catch|class|const|continue|default|delete|do|else|enum|export|extends|false|finally|for|fn|from|func|function|go|if|implements|import|in|instanceof|interface|let|match|new|null|of|package|private|protected|public|return|static|struct|super|switch|this|throw|true|try|type|typeof|undefined|use|val|var|void|while|yield"},bf={comment:"#[^\\n]*",keywords:"and|as|assert|async|await|break|class|continue|def|del|elif|else|except|False|finally|for|from|global|if|import|in|is|lambda|None|not|or|pass|raise|return|True|try|while|with|yield"},Xo={comment:"#[^\\n]*",keywords:"case|do|done|elif|else|esac|export|fi|for|function|if|in|local|return|then|until|while"},ww={ts:Jt,tsx:Jt,typescript:Jt,js:Jt,jsx:Jt,javascript:Jt,java:Jt,kotlin:Jt,kt:Jt,go:Jt,rust:Jt,rs:Jt,c:Jt,cpp:Jt,json:{comment:"(?!)",keywords:"true|false|null"},py:bf,python:bf,sh:Xo,bash:Xo,shell:Xo,zsh:Xo,yaml:{comment:"#[^\\n]*",keywords:"true|false|null"},yml:{comment:"#[^\\n]*",keywords:"true|false|null"}},Nw="\"(?:[^\"\\\\\\n]|\\\\.)*\"?|'(?:[^'\\\\\\n]|\\\\.)*'?|`(?:[^`\\\\]|\\\\[\\s\\S])*(?:`|$)",Sw="\\b\\d[\\d_]*(?:\\.\\d+)?(?:e[+-]?\\d+)?\\b",wf=new Map;function Cw(t){let n=wf.get(t);return n||(n=new RegExp(`(${t.comment})|(${Nw})|(${Sw})|\\b(${t.keywords})\\b`,"gi"),wf.set(t,n)),n.lastIndex=0,n}const Fu=(t,n,a)=>{if(!a)return;const l=t.at(-1);(l==null?void 0:l.kind)===n?l.text+=a:t.push({kind:n,text:a})};function $w(t,n){const a=ww[n.trim().toLowerCase()];if(!a)return t?[{kind:"plain",text:t}]:[];const l=[],o=Cw(a);let c=0;for(let d=o.exec(t);d;d=o.exec(t)){if(d[0]===""){o.lastIndex++;continue}Fu(l,"plain",t.slice(c,d.index)),Fu(l,d[1]!==void 0?"comment":d[2]!==void 0?"string":d[3]!==void 0?"number":"keyword",d[0]),c=d.index+d[0].length}return Fu(l,"plain",t.slice(c)),l}function Tw({src:t,alt:n,media:a}){const[l,o]=h.useState(!1),c=a==null?void 0:a(t);if(c&&!l)return e.jsx("img",{src:c,alt:n,loading:"lazy",onError:()=>o(!0)});const d=`image: ${n||t}`,u=Cx(t);return u?e.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer nofollow",children:d}):e.jsx(e.Fragment,{children:d})}function ra(t,n){return t.map((a,l)=>a.kind==="text"?a.text:a.kind==="code"?e.jsx("code",{children:a.text},l):a.kind==="strong"?e.jsx("strong",{children:ra(a.children,n)},l):a.kind==="em"?e.jsx("em",{children:ra(a.children,n)},l):a.kind==="image"?e.jsx(Tw,{src:a.src,alt:a.alt,media:n},l):e.jsx("a",{href:a.href,target:"_blank",rel:"noopener noreferrer nofollow",children:ra(a.children,n)},l))}const Ew=["h3","h3","h4","h5","h6","h6"];function Tx(t,n,a){if(t.kind==="heading"){const l=Ew[t.level-1];return e.jsx(l,{children:ra(t.children,a)},n)}if(t.kind==="paragraph")return e.jsx("p",{children:ra(t.children,a)},n);if(t.kind==="code")return e.jsx("pre",{className:"pre mono",children:e.jsx("code",{children:$w(t.text,t.lang).map((l,o)=>l.kind==="plain"?l.text:e.jsx("span",{className:`tok-${l.kind}`,children:l.text},o))})},n);if(t.kind==="table")return e.jsx("div",{className:"markdown-table",tabIndex:0,role:"region","aria-label":"Table",children:e.jsxs("table",{children:[e.jsx("thead",{children:e.jsx("tr",{children:t.head.map((l,o)=>e.jsx("th",{scope:"col",children:ra(l,a)},o))})}),e.jsx("tbody",{children:t.rows.map((l,o)=>e.jsx("tr",{children:l.map((c,d)=>e.jsx("td",{children:ra(c,a)},d))},o))})]})},n);if(t.kind==="quote")return e.jsx("blockquote",{children:t.children.map((l,o)=>Tx(l,o,a))},n);if(t.kind==="list"){const l=t.items.map((o,c)=>e.jsx("li",{children:ra(o,a)},c));return t.ordered?e.jsx("ol",{children:l},n):e.jsx("ul",{children:l},n)}return e.jsx("hr",{},n)}function Ha({text:t,media:n}){const a=h.useMemo(()=>$x(t),[t]);return e.jsx("div",{className:"markdown",dir:"auto",children:a.map((l,o)=>Tx(l,o,n))})}function mh({added:t,removed:n}){return e.jsxs(e.Fragment,{children:[t?e.jsxs("span",{className:"diff-add",children:["+",t]}):null,t&&n?" ":null,n?e.jsxs("span",{className:"diff-del",children:["−",n]}):null]})}const di=5,Rw=6;function Pw(t,n){const a=t+n;if(a<=0)return{added:0,removed:0,empty:di};const l=Math.min(di,Math.ceil(a/Rw)),o=Math.round(t/a*l);return{added:o,removed:l-o,empty:di-l}}function Di({added:t,removed:n}){const a=Pw(t,n),l=[...Array(a.added).fill("add"),...Array(a.removed).fill("del"),...Array(a.empty).fill("none")];return e.jsx("span",{className:"change-weight",role:"img","aria-label":`${t} ${t===1?"line":"lines"} added, ${n} removed`,children:l.slice(0,di).map((o,c)=>e.jsx("i",{className:o},c))})}function Aw(t){let n=!1;return t.split(`
|
|
47
|
+
`).map(a=>a.startsWith("diff --git ")?(n=!1,"meta"):a.startsWith("@@")?(n=!0,"hunk"):n?a.startsWith("+")?"add":a.startsWith("-")?"del":a.startsWith("\\")?"meta":"context":a.startsWith("--- ")||a.startsWith("+++ ")||a.startsWith("index ")?"meta":"context")}function Iw(t){const n=t.indexOf("hunk");return n<0?0:n}function Ex(t){const n=t.endsWith(`
|
|
48
|
+
`)?t.slice(0,-1):t,a=Aw(n);let l=0,o=0;return n.split(`
|
|
49
|
+
`).map((c,d)=>{const u=a[d];if(u==="hunk"){const m=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(c);return l=m?Number(m[1]):l,o=m?Number(m[2]):o,{kind:u,text:c,old:null,new:null}}return u==="add"?{kind:u,text:c,old:null,new:o++}:u==="del"?{kind:u,text:c,old:l++,new:null}:u==="context"&&(l||o)?{kind:u,text:c,old:l++,new:o++}:{kind:u,text:c,old:null,new:null}})}function Rx({patch:t}){const n=Ex(t),a=Iw(n.map(l=>l.kind));return e.jsx(e.Fragment,{children:n.map((l,o)=>o<a?null:e.jsxs("span",{"data-i":o,className:`diff-line ${l.kind}`,children:[e.jsx("span",{className:"diff-num","aria-hidden":"true","data-old":l.old??"","data-new":l.new??""}),l.text||" "]},o))})}function Px(){const t=h.useRef(null),[n,a]=h.useState(!1);return h.useEffect(()=>{const l=t.current;if(!l)return;const o=()=>a(l.scrollLeft+l.clientWidth<l.scrollWidth-1);o(),l.addEventListener("scroll",o,{passive:!0});const c=new ResizeObserver(o);return c.observe(l),()=>{l.removeEventListener("scroll",o),c.disconnect()}},[]),[t,n]}function ph({patch:t}){const[n,a]=Px();return e.jsx("div",{className:"patch-scroll","data-more-right":a||void 0,children:e.jsx("pre",{ref:n,className:"pre mono diff-patch",children:e.jsx(Rx,{patch:t})})})}const Ax="the agent's log",Ow=40,Ix=4e3,Nf=t=>t.length===1||t[0]===t.at(-1)?`${t[0]}`:`${t[0]}-${t.at(-1)}`;function Lw(t,n,a,l){const[o,c]=a<=l?[a,l]:[l,a],d=Ex(n).slice(o,c+1).filter(x=>x.kind==="add"||x.kind==="del"||x.kind==="context"&&x.new!==null).slice(0,Ow);let u=0;const m=d.filter(x=>(u+=x.text.length+1)<=Ix+1);if(!m.length)return null;const f=m.flatMap(x=>x.new===null?[]:[x.new]),g=m.flatMap(x=>x.old===null?[]:[x.old]);return{path:t,lines:f.length?Nf(f):`${Nf(g)} before the change`,text:m.map(x=>x.text).join(`
|
|
50
|
+
`)}}const Fw="orchestrator.diff.hide-tests",Mw={added:"added",modified:"changed",deleted:"deleted",renamed:"renamed"};function _w(t){return t.split("/").flatMap((n,a,l)=>a<l.length-1?[n,"/",e.jsx("wbr",{},a)]:[n])}function Uw({path:t,patch:n,onQuote:a}){const[l,o]=Px(),[c,d]=h.useState(null),u=f=>{var x,y;const g=(x=f instanceof Element?f:f==null?void 0:f.parentElement)==null?void 0:x.closest("[data-i]");return g&&((y=l.current)!=null&&y.contains(g))?Number(g.dataset.i):null},m=()=>{const f=window.getSelection(),g=f&&!f.isCollapsed?u(f.anchorNode):null,x=f&&!f.isCollapsed?u(f.focusNode):null;d(g===null||x===null?null:Lw(t,n,g,x))};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"patch-scroll","data-more-right":o||void 0,children:e.jsx("pre",{ref:l,className:"pre mono diff-patch",onMouseUp:m,onKeyUp:m,children:e.jsx(Rx,{patch:n})})}),c?e.jsx("div",{className:"actions",children:e.jsxs("button",{type:"button",className:"secondary small",onClick:()=>{var f;a(c),d(null),(f=window.getSelection())==null||f.removeAllRanges()},children:["Quote lines ",c.lines," in a follow-up"]})}):null]})}const fh={label:"Why",note:"Goes in the task's log"};function Dw({file:t,read:n,onQuote:a,onDrop:l,onUndo:o,undone:c=!1,ownCopy:d=!1,opened:u=!1}){const[m,f]=h.useState(null),[g,x]=h.useState(null),y=N=>{N&&!m&&!g&&!t.binary&&n(t.path).then(f,v=>x(v.message))};h.useEffect(()=>y(u),[]);const b=d?{trigger:"Discard this file's change…",triggerLabel:`Discard the change to ${t.path}`,consequence:t.status==="added"?`${t.path} is dropped from the task's branch; the other files stay as they are.`:`${t.path} goes back to how it was before the task on the task's branch; the other files stay as they are.`,confirm:"Discard its change",keep:"Keep it"}:{trigger:"Take out of the request…",triggerLabel:`Take ${t.path} out of the request`,consequence:t.status==="added"?"The file is deleted from the request's branch in one commit, and the request is checked again.":"The file goes back to how it was before the task, in one commit on the request's branch, and the request is checked again.",confirm:"Take it out",keep:"Keep it in"};return e.jsx("li",{children:e.jsxs("details",{open:u,onToggle:N=>y(N.currentTarget.open),children:[e.jsxs("summary",{children:[e.jsx("span",{className:"mono",children:_w(t.previousPath&&t.status==="renamed"?`${t.previousPath} → ${t.path}`:t.path)})," ",e.jsxs("span",{className:"muted small",children:[c?"undone":Mw[t.status],t.binary?", binary":null]}),t.binary||c?null:e.jsxs(e.Fragment,{children:[" ",e.jsxs("span",{className:"diff-stat",children:[e.jsx(Di,{added:t.additions??0,removed:t.deletions??0})," ",e.jsx(mh,{added:t.additions??0,removed:t.deletions??0})]})]})]}),t.binary?e.jsx("p",{className:"muted small",children:"A binary file; its contents are not shown."}):g?e.jsx("p",{className:"muted small",children:g}):m?m.patch===null?null:a?e.jsx(Uw,{path:t.path,patch:m.patch,onQuote:a}):e.jsx(ph,{patch:m.patch}):e.jsx(he,{what:"the patch"}),m!=null&&m.note?e.jsx("p",{className:"muted small",children:da(m.note)}):null,o&&!c?e.jsx("div",{className:"actions",children:e.jsx(qe,{small:!0,trigger:"Undo this file…",triggerLabel:`Undo ${t.path}`,consequence:t.status==="added"?`${t.path} is deleted; the other files stay as they are.`:`${t.path} goes back to how it was before the task; the other files stay as they are.`,confirm:"Undo this file",keep:"Keep it",reason:fh,onConfirm:N=>o(t.path,N)})}):null,l?e.jsx("div",{className:"actions",children:e.jsx(qe,{small:!0,...b,onConfirm:()=>l(t.path)})}):null]})})}const Bw=10;function Fr({reads:t,open:n=!1,bare:a=!1,onClosed:l,onQuote:o,onDrop:c,onUndo:d,undone:u=[],ownCopy:m=!1,onRead:f}){var R;const[g]=h.useState(()=>t),[x,y]=h.useState(null),[b,N]=h.useState(null),[v,k]=Ps(Fw),S=(P,M=!1)=>{!P||x||b&&!M||(N(null),g.changes().then(O=>{y(O),f==null||f(!0)},O=>{N(O.message),f==null||f(!1)}))};h.useEffect(()=>S(n||a),[n,a]);const $=x?v==="yes"?x.files.filter(P=>!P.test):x.files:[],E=x?x.files.filter(P=>P.test).length:0,C=b?e.jsx(be,{what:"the changes",reason:b,onRetry:()=>S(!0,!0)}):x?e.jsxs(e.Fragment,{children:[a?x.omitted?e.jsxs("p",{className:"muted small",children:[x.omitted," more not shown."]}):null:e.jsxs("p",{className:"muted small",children:[x.files.length," ",x.files.length===1?"file":"files",", +",x.files.reduce((P,M)=>P+(M.additions??0),0)," −",x.files.reduce((P,M)=>P+(M.deletions??0),0),x.omitted?`; ${x.omitted} more not shown`:""]}),E?e.jsxs("label",{className:"check small",children:[e.jsx("input",{type:"checkbox",checked:v==="yes",onChange:P=>k(P.target.checked?"yes":null)}),"Hide test files (",E,")"]}):null,e.jsx("ul",{className:"plain diff-files",children:$.map(P=>e.jsx(Dw,{file:P,read:g.file,onQuote:o,...c?{onDrop:c}:{},...d?{onUndo:d}:{},undone:u.includes(P.path),ownCopy:m,opened:a&&$.length<=Bw&&!u.includes(P.path)},P.path))}),(R=x.untracked)!=null&&R.length?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"muted small",children:"The orchestrator keeps no copy of these files, such as one that looks like it holds a secret, so Undo leaves them as the agent left them."}),e.jsx("ul",{className:"plain",children:x.untracked.map(P=>e.jsx("li",{className:"mono small",children:P.path},P.path))})]}):null]}):e.jsx(he,{what:"the changes"});return a?e.jsx("div",{className:"request-diff",children:C}):e.jsxs("details",{className:"request-diff",open:n,onToggle:P=>{const M=P.currentTarget.open;S(M),M||l==null||l()},children:[e.jsx("summary",{children:"Changes"}),C]})}const qw={"needs-review":"warn","needs review":"warn",interrupted:"warn","awaiting review":"warn",open:"warn",asks:"warn",running:"info",working:"info",tests:"info",request:"info",review:"warn",merged:"ok",kept:"ok","changes kept":"ok",failed:"error",queued:"neutral",cancelled:"neutral",closed:"neutral",undone:"neutral","changes undone":"neutral"};function Ww(t){return qw[t]??"neutral"}function Mr(t,n){return Me(t)||t.ownedTeams.includes(n)}function gh(t){var a;const n=(a=t.notes)!=null&&a.length?` ${t.notes.join(" ")}`:"";return`Request #${t.number} opened on ${t.branch}. It changes nothing until someone merges it.${n}`}function Vn({repoId:t,head:n,build:a,steps:l,children:o,submitLabel:c,onOpened:d,onCancel:u,onRefused:m}){const[f,g]=h.useState(null),[x,y]=h.useState(""),[b,N]=h.useState(null),[v,k]=h.useState(!1),S=h.useId(),$=b?{"aria-invalid":!0,"aria-describedby":S}:{},E=R=>{R.preventDefault(),N(null),k(!0),(l?l.proposal():Ce.proposal(t,a())).then(P=>{g(P.proposal),y(P.branch),k(!1)},P=>{N(P.message),k(!1),m==null||m()})},C=R=>{R.preventDefault(),N(null),k(!0),(l?l.send(f??"",x):Ce.propose(t,n,a(),f??"",x)).then(d,P=>{N(P.message),k(!1)})};return e.jsxs("form",{className:"form editor",onSubmit:f===null?E:C,children:[e.jsx("fieldset",{disabled:f!==null,className:"plain-fieldset",children:o==null?void 0:o(f===null?$:{})}),f!==null?e.jsxs(e.Fragment,{children:[a?e.jsx(aw,{repoId:t,change:a()}):null,e.jsxs("label",{children:["Commit message",e.jsx("input",{value:f,onChange:R=>g(R.target.value),required:!0,...$})]}),e.jsxs("label",{children:["Branch",e.jsx("input",{value:x,onChange:R=>y(R.target.value),required:!0,spellCheck:!1,...$})]}),x.includes("<TICKET>")?e.jsx("p",{className:"muted",children:"This team's branches start with a ticket: put it in place of <TICKET>."}):null]}):null,b?e.jsx("p",{className:"error",role:"alert",id:S,children:b}):null,e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",disabled:v,children:f===null?c:"Open request"}),f!==null?e.jsx("button",{type:"button",className:"secondary",onClick:()=>g(null),children:"Back"}):null,e.jsx("button",{type:"button",className:"secondary",onClick:u,children:"Cancel"})]})]})}const zw=`---
|
|
51
|
+
name:
|
|
52
|
+
description: Use when
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
`;function Sd({repoId:t,head:n,slug:a,onOpened:l,onCancel:o}){const[c,d]=h.useState(a??""),[u,m]=h.useState(a?null:zw),[f,g]=h.useState(null);return h.useEffect(()=>{a&&Ce.skill(t,a).then(x=>m(x.content),x=>g(x.message))},[t,a]),f?e.jsxs("div",{className:"editor",role:"alert",children:[e.jsxs("p",{className:"error",children:[a," did not load, so it cannot be edited now. ",f]}),e.jsx("button",{type:"button",className:"secondary",onClick:o,children:"Close"})]}):u===null?e.jsx("p",{className:"muted",children:"Loading the skill…"}):e.jsx(Vn,{repoId:t,head:n,submitLabel:a?"Review the edit":"Review the new skill",build:()=>({kind:a?"skill.edit":"skill.add",slug:c,content:u}),onOpened:l,onCancel:o,children:x=>e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:a?`Edit ${a}`:"Add a skill"}),a?null:e.jsxs("label",{children:["Skill name",e.jsx("input",{value:c,onChange:y=>d(y.target.value),placeholder:"on-call-handover",required:!0,...x})]}),e.jsxs("label",{children:["SKILL.md",e.jsx("textarea",{"aria-label":"SKILL.md",value:u,onChange:y=>m(y.target.value),spellCheck:!1,...x})]})]})})}const Hw=`---
|
|
56
|
+
description: What the command does, in one line.
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
The steps Claude follows when someone types the command.
|
|
60
|
+
`;function Cd({repoId:t,head:n,name:a,onOpened:l,onCancel:o}){const[c,d]=h.useState(a??""),[u,m]=h.useState(a?null:Hw),[f,g]=h.useState(null);return h.useEffect(()=>{a&&Ce.command(t,a).then(x=>m(x.content),x=>g(x.message))},[t,a]),f?e.jsxs("div",{className:"editor",role:"alert",children:[e.jsxs("p",{className:"error",children:["/",a," did not load, so it cannot be edited here. ",f]}),e.jsx("button",{type:"button",className:"secondary",onClick:o,children:"Close"})]}):u===null?e.jsx("p",{className:"muted",children:"Loading the command…"}):e.jsx(Vn,{repoId:t,head:n,submitLabel:a?"Review the edit":"Review the new command",build:()=>({kind:a?"command.edit":"command.add",name:c,content:u}),onOpened:l,onCancel:o,children:x=>e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:a?`Edit /${a}`:"Add a slash command"}),a?null:e.jsxs("label",{children:["Command name, a colon between a folder and the name",e.jsx("input",{value:c,onChange:y=>d(y.target.value),placeholder:"git:sync",required:!0,...x})]}),e.jsxs("label",{children:["Command text",e.jsx("textarea",{"aria-label":"Command text",value:u,onChange:y=>m(y.target.value),spellCheck:!1,...x})]})]})})}function Ox({repoId:t,head:n,name:a,onOpened:l,onCancel:o}){return e.jsx(Vn,{repoId:t,head:n,submitLabel:`Review removing /${a}`,build:()=>({kind:"command.delete",name:a}),onOpened:l,onCancel:o,children:()=>e.jsxs(e.Fragment,{children:[e.jsxs("h3",{children:["Remove /",a]}),e.jsx("p",{className:"muted",children:"The request deletes its file under commands/. Teammates lose the command once the request is merged."})]})})}function Lx({repoId:t,head:n,slug:a,onOpened:l,onCancel:o}){return e.jsx(Vn,{repoId:t,head:n,submitLabel:`Review removing ${a}`,build:()=>({kind:"skill.delete",slug:a}),onOpened:l,onCancel:o,children:()=>e.jsxs(e.Fragment,{children:[e.jsxs("h3",{children:["Remove ",a]}),e.jsx("p",{className:"muted",children:"The request deletes every file the skill ships. Teammates lose it once the request is merged."}),e.jsx(wx,{repoId:t,kind:"skill",name:a})]})})}function Sf(t){const n=t.split(`
|
|
61
|
+
`).map(a=>a.trim()).filter(Boolean).map(a=>{const l=a.indexOf("=");return l<0?[a,""]:[a.slice(0,l).trim(),a.slice(l+1).trim()]});return n.length?Object.fromEntries(n):void 0}const Gw=new Set(["command","args","env","type","url","headers"]),Cf=t=>t&&typeof t=="object"?Object.entries(t).map(([n,a])=>`${n}=${String(a)}`).join(`
|
|
62
|
+
`):"";function Kw(t,n){const a=typeof n.command=="string";return{form:{name:t,transport:a?"stdio":String(n.type??"http"),command:a?String(n.command):"",args:Array.isArray(n.args)?n.args.map(String).join(`
|
|
63
|
+
`):"",url:typeof n.url=="string"?n.url:"",env:Cf(n.env),headers:Cf(n.headers)},kept:Object.fromEntries(Object.entries(n).filter(([l])=>!Gw.has(l)))}}function $d({repoId:t,head:n,name:a,onOpened:l,onCancel:o}){const[c,d]=h.useState({name:a??"",transport:"stdio",command:"",args:"",url:"",env:"",headers:""}),[u,m]=h.useState({}),[f,g]=h.useState(!a),[x,y]=h.useState(null);h.useEffect(()=>{a&&Ce.mcpServer(t,a).then(k=>{const S=Kw(a,k.config);d(S.form),m(S.kept),g(!0)},k=>{y(k.message),g(!0)})},[t,a]);const b=k=>S=>d({...c,[k]:S.target.value}),N=()=>{const k=Sf(c.env),S=Sf(c.headers),$=c.args.split(`
|
|
64
|
+
`).map(C=>C.trim()).filter(Boolean),E=c.transport==="stdio"?{...u,command:c.command,...$.length?{args:$}:{},...k?{env:k}:{}}:{...u,type:c.transport,url:c.url,...S?{headers:S}:{}};return a?{kind:"mcp.edit",name:a,config:E}:{kind:"mcp.add",name:c.name,config:E}},v=()=>d(k=>({...k,args:"",url:"",env:"",headers:""}));return f?e.jsx(Vn,{repoId:t,head:n,submitLabel:"Review the server",build:N,onOpened:l,onCancel:o,onRefused:v,children:k=>e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:a?`Edit ${a}`:"Add an MCP server"}),e.jsxs("p",{className:"muted",children:["Values in env and headers travel only as ",e.jsx("code",{children:"${VAR}"})," references; each teammate supplies the value on their own machine."]}),x?e.jsxs("p",{className:"muted",children:[a,": ",x,". Write it again here; the request replaces it."]}):null,Object.keys(u).length?e.jsxs("p",{className:"muted",children:["Kept as written: ",Object.keys(u).join(", "),"."]}):null,a?null:e.jsxs("label",{children:["Server name",e.jsx("input",{value:c.name,onChange:b("name"),required:!0,...k})]}),e.jsx(Pe,{label:"Transport",value:c.transport,onChange:S=>d({...c,transport:S}),describedBy:k["aria-describedby"],invalid:!!k["aria-invalid"],options:[{value:"stdio",label:"stdio (starts a command)"},{value:"http",label:"http"},{value:"sse",label:"sse"}]}),c.transport==="stdio"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:["Command",e.jsx("input",{value:c.command,onChange:b("command"),required:!0,...k})]}),e.jsxs("label",{children:["Arguments, one per line",e.jsx("textarea",{className:"short",value:c.args,onChange:b("args"),...k})]}),e.jsxs("label",{children:["Environment, NAME=$","{","VAR","}"," per line",e.jsx("textarea",{className:"short","aria-label":"Environment",value:c.env,onChange:b("env"),...k})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:["URL",e.jsx("input",{value:c.url,onChange:b("url"),required:!0,...k})]}),e.jsxs("label",{children:["Headers, Name=$","{","VAR","}"," per line",e.jsx("textarea",{className:"short","aria-label":"Headers",value:c.headers,onChange:b("headers"),...k})]})]})]})}):e.jsx("p",{className:"muted",children:"Loading the server…"})}function Fx({repoId:t,head:n,name:a,onOpened:l,onCancel:o}){return e.jsx(Vn,{repoId:t,head:n,submitLabel:`Review removing ${a}`,build:()=>({kind:"mcp.remove",name:a}),onOpened:l,onCancel:o,children:()=>e.jsxs(e.Fragment,{children:[e.jsxs("h3",{children:["Remove ",a]}),e.jsxs("p",{className:"muted",children:["The request takes ",a," out of .mcp.json and keeps every other entry. Teammates' Claude Code stops starting it once the request is merged."]}),e.jsx(wx,{repoId:t,kind:"mcp",name:a})]})})}const $f={ask:{title:"Ask this team to report skill use",text:"The request sets the orchestrator's usage endpoint in .teamhandbook.json. Nothing is reported until it is merged and each teammate agrees on their own machine."},rotate:{title:"Give this team a new usage address",text:"The address teammates use today stops counting as soon as the request opens, and counts resume once it is merged. Each teammate's agreement covers one exact address, so every teammate is asked again before anything is sent to the new one."},stop:{title:"Stop asking this team for skill use",text:"The request takes usage out of .teamhandbook.json. Once it is merged, no teammate reports skill use for this repository; the counts already here stay."}};function Yw({repoId:t,head:n,action:a="ask",onOpened:l,onCancel:o}){return e.jsx(Vn,{repoId:t,head:n,steps:{proposal:()=>Ce.usageProposal(t,a),send:(c,d)=>Ce.proposeUsage(t,n,c,d,a)},submitLabel:"Review the request",onOpened:l,onCancel:o,children:()=>e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:$f[a].title}),e.jsx("p",{className:"muted",children:$f[a].text})]})})}const Tf=t=>t.split(",").map(n=>n.trim()).filter(Boolean);function Vw({repoId:t,head:n,team:a,onOpened:l,onCancel:o}){const[c,d]=h.useState(((a==null?void 0:a.reviewers)??[]).join(", ")),[u,m]=h.useState(((a==null?void 0:a.labels)??[]).join(", "));return e.jsx(Vn,{repoId:t,head:n,submitLabel:"Review the change",build:()=>({kind:"team.settings",reviewers:Tf(c),labels:Tf(u)}),onOpened:l,onCancel:o,children:f=>e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:"Reviewers and labels"}),e.jsx("p",{className:"muted",children:"Every other setting in .teamhandbook.json stays as it is."}),e.jsxs("label",{children:["Reviewers, forge logins separated by commas",e.jsx("input",{value:c,onChange:g=>d(g.target.value),...f})]}),e.jsxs("label",{children:["Labels, separated by commas",e.jsx("input",{value:u,onChange:g=>m(g.target.value),...f})]})]})})}function Qw({repoId:t,head:n,team:a,onOpened:l,onCancel:o}){const[c,d]=h.useState((a==null?void 0:a.commitPrefix)??""),[u,m]=h.useState((a==null?void 0:a.branchExample)??"");return e.jsx(Vn,{repoId:t,head:n,submitLabel:"Review the change",build:()=>({kind:"team.naming",commitPrefix:c,branchExample:u}),onOpened:l,onCancel:o,children:f=>e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:"How commits and branches are named"}),e.jsx("p",{className:"muted",children:"Teammates' TeamHandbook and this orchestrator name every commit and branch they propose this way. Every other setting in .teamhandbook.json stays as it is."}),e.jsxs("label",{children:["Commit prefix, what the repository asks at the front of every commit title; empty for none",e.jsx("input",{value:c,onChange:g=>d(g.target.value),...f})]}),e.jsxs("label",{children:["Example branch name, one written the way this repository names them; empty for none",e.jsx("input",{value:u,onChange:g=>m(g.target.value),...f})]})]})})}function Jw({request:t,repo:n,me:a,onChanged:l}){const[o,c]=h.useState(null);if(!n||!Mr(a,n.team))return null;const d=m=>{c(null),Ce.requestAction(n.id,t.number,m).then(l,f=>c(f.message))},u=o?Tl(o):null;return e.jsxs("div",{className:"row-actions",children:[t.provider==="local"&&t.status==="open"?e.jsxs(e.Fragment,{children:[t.heldHead?null:e.jsx("button",{type:"button",className:"secondary",onClick:()=>d("merge"),children:"Merge"}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>d("close"),children:"Close"})]}):null,t.provider!=="local"?e.jsx("button",{type:"button",className:"secondary",onClick:()=>d("refresh"),children:"Refresh"}):null,o?e.jsx("p",{className:"error",role:"alert",children:u?e.jsxs(e.Fragment,{children:[u.said,": ",e.jsx(mt,{text:u.command})]}):o}):null]})}function Xw({request:t}){const[n,a]=h.useState(null),l=t.provider==="local"?void 0:c=>Pn(`/api/repos/${encodeURIComponent(t.repoId)}/media?${new URLSearchParams({request:String(t.number),src:c})}`),o=c=>{!c||n!==null||Ce.requestDescription(t.repoId,t.number).then(d=>a(d.description??"This request's description is where the request is; open it there."),d=>a(d.message))};return e.jsxs("details",{onToggle:c=>o(c.currentTarget.open),children:[e.jsx("summary",{children:"Description"}),n===null?e.jsx(he,{what:"the description"}):e.jsx(Ha,{text:n,...l?{media:l}:{}})]})}function Zw({requests:t,repos:n,me:a,showRepo:l,onChanged:o}){if(!t.length){const c=l?n.find(d=>d.configured!==!1&&Mr(a,d.team)):void 0;return e.jsxs("div",{className:"empty-state",children:[e.jsx("p",{className:"empty-state-title",children:"No request opened from the orchestrator yet"}),e.jsx("p",{className:"muted",children:"A change proposed on a repository's page, or a task's result, opens one here."}),c?e.jsx("div",{className:"actions",children:e.jsx("a",{className:"button",href:re("repositories",c.id,"skills"),children:"Propose your first change"})}):null]})}return e.jsxs("table",{className:"row-cards",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[l?e.jsx("th",{children:"Repository"}):null,e.jsx("th",{children:"#"}),e.jsx("th",{children:"Title"}),e.jsx("th",{children:"Branch"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Opened by"}),e.jsx("th",{children:e.jsx("span",{className:"visually-hidden",children:"Actions"})})]})}),e.jsx("tbody",{children:t.map(c=>e.jsxs("tr",{children:[l?e.jsx("td",{className:"mono rc-meta",children:c.repoId}):null,e.jsx("td",{className:"rc-meta",children:c.url.startsWith("http")?e.jsx("a",{href:c.url,target:"_blank",rel:"noreferrer",children:c.number}):c.number}),e.jsxs("td",{className:"rc-title",children:[e.jsx("span",{dir:"auto",children:c.title}),e.jsx(Xw,{request:c}),e.jsx(Fr,{reads:Ui(c.repoId,c.number)})]}),e.jsx("td",{className:"mono rc-extra",children:c.branch}),e.jsxs("td",{className:"rc-status",children:[e.jsx("span",{className:`badge ${Ww(c.status)}`,children:c.status==="open"?"awaiting review":c.status}),e.jsx(hh,{request:c})]}),e.jsx("td",{className:"rc-meta",children:c.createdBy}),e.jsx("td",{className:"rc-wide",children:e.jsx(Jw,{request:c,repo:n.find(d=>d.id===c.repoId),me:a,onChanged:o})})]},`${c.repoId}-${c.number}`))})]})}const Ef=[{value:"",label:"Every request",none:""},{value:"open",label:"Awaiting review",none:"No request is awaiting review."},{value:"merged",label:"Merged",none:"No request has been merged."},{value:"closed",label:"Closed",none:"No request has been closed."}];function eN({repoId:t,repos:n,me:a,showRepo:l,version:o=0,onCounts:c,onChanged:d}){const[u,m]=h.useState(""),[f,g]=h.useState([]),[x,y]=h.useState(null),[b,N]=h.useState(null),[v,k]=h.useState(0);h.useEffect(()=>{let E=!0;return N(null),Ce.requests({repoId:t,status:u||null,after:f.at(-1)??null}).then(C=>{if(E){if(!C.requests.length&&f.length)return g(f.slice(0,-1));y(C),c==null||c(C)}},C=>E&&N(C.message)),()=>{E=!1}},[t,u,f,o,v]);const S=()=>k(E=>E+1),$=Ef.find(E=>E.value===u);return e.jsxs("div",{className:"request-list",children:[u||x!=null&&x.total?e.jsx("div",{className:"filter",children:e.jsx(Pe,{label:"Show",value:u,onChange:E=>{m(E),g([])},options:Ef.map(E=>({value:E.value,label:E.label}))})}):null,b?e.jsx(be,{what:"requests",reason:b,onRetry:S}):x?u&&!x.requests.length?e.jsx("p",{className:"muted",children:$.none}):e.jsxs(e.Fragment,{children:[e.jsx(Zw,{requests:x.requests,repos:n,me:a,showRepo:l,onChanged:d??S}),e.jsx(Li,{page:f.length+1,total:x.total,pageSize:x.pageSize,more:x.next!==null,onPage:E=>g(E>f.length+1?[...f,x.next]:f.slice(0,-1)),label:"Pages of requests"})]}):e.jsx(he,{what:"requests"})]})}function tN({repo:t,suggest:n}){const[a,l]=h.useState(null),[o,c]=h.useState({kind:"gitlab",apiUrl:"https://gitlab.com/api/v4",project:"",token:"",...n}),[d,u]=h.useState(null),[m,f]=h.useState(null),g=h.useId(),x=m?{"aria-invalid":!0,"aria-describedby":g}:{},y=()=>Ce.forge(t.id).then(N=>{l(N),N.config&&c({kind:N.config.kind,apiUrl:N.config.apiUrl,project:N.config.project,token:""})},N=>f(N.message));if(h.useEffect(()=>{y()},[t.id]),t.url.startsWith("file://"))return e.jsx("p",{className:"muted",children:"This repository is read by path, so its requests open in the repository itself, on this machine."});if(!a)return m?e.jsx(be,{what:"the forge access",reason:m,onRetry:()=>{f(null),y()}}):e.jsx(he,{what:"the forge access"});const b=N=>{N.preventDefault(),u(null),f(null),Ce.saveForge(t.id,{kind:o.kind,apiUrl:o.apiUrl,project:o.project,...o.token?{token:o.token}:{}}).then(()=>{c({...o,token:""}),u("Saved. The token is sealed; the orchestrator never shows it again."),y()},v=>{c({...o,token:""}),f(v.message)})};return e.jsxs("form",{className:"form inline-form",onSubmit:b,"aria-label":"Forge access",children:[e.jsx(Pe,{label:"Forge",value:o.kind,onChange:N=>c({...o,kind:N,apiUrl:rt[N].apiUrlFor(new URL(`https://${rt[N].homeHosts[0]}`))}),describedBy:x["aria-describedby"],invalid:!!x["aria-invalid"],options:Vg.filter(N=>{var v;return N!=="gitea"||o.kind==="gitea"||((v=a.forges)==null?void 0:v.includes(N))}).map(N=>({value:N,label:rt[N].label}))}),e.jsxs("label",{children:["API address",e.jsx("input",{value:o.apiUrl,onChange:N=>c({...o,apiUrl:N.target.value}),required:!0,...x})]}),e.jsxs("label",{children:["Project",e.jsx("input",{value:o.project,onChange:N=>c({...o,project:N.target.value}),placeholder:rt[o.kind].projectShape,required:!0,...x})]}),e.jsxs("label",{children:["Token",e.jsx("input",{type:"password",autoComplete:"off",value:o.token,onChange:N=>c({...o,token:N.target.value}),...x,placeholder:a.token.set?`set${a.token.updatedAt?` ${a.token.updatedAt.slice(0,10)}`:""}; empty keeps it while forge, address and project stay`:"a project access token"})]}),e.jsx("button",{type:"submit",disabled:!a.vault,children:"Save"}),a.vault?null:e.jsx("p",{className:"error",children:"This orchestrator keeps no tokens until whoever runs it sets ORCHESTRATOR_SECRET_KEY and starts it again."}),m?e.jsx("p",{className:"error",role:"alert",id:g,children:m}):null,d?e.jsx("p",{role:"status",children:d}):null]})}const Mu={own:t=>U("GET",`/api/handbook/own?repo=${encodeURIComponent(t)}`),proposal:(t,n)=>U("POST",`/api/repos/${encodeURIComponent(t)}/handbook/proposal`,n),propose:(t,n,a,l,o)=>U("POST",`/api/repos/${encodeURIComponent(t)}/handbook`,{...n,message:a,branch:l,baseSha:o}).then(c=>c.request)},Rl=[{id:"skills",label:"Skills"},{id:"mcp",label:"MCP servers"},{id:"commands",label:"Commands"}],_u=(t,n,a)=>`${t} ${t===1?n:a}`,nN={skills:"skills",mcp:"mcpServers",commands:"commands"},Uu=(t,n)=>`${t}/${n}`;function sN(t){return[_u(t.skills.length,"skill","skills"),_u(t.mcpServers.length,"MCP server","MCP servers"),_u(t.commands.length,"command","commands")].filter((n,a)=>[t.skills,t.mcpServers,t.commands][a].length).join(" and ")}function aN({repoId:t,head:n,onProposed:a,onCancel:l}){const[o,c]=h.useState(null),[d,u]=h.useState(null),[m,f]=h.useState("skills"),[g,x]=h.useState(new Set),[y,b]=h.useState(null),[N,v]=h.useState(null),[k,S]=h.useState(!1),$=()=>{u(null),Mu.own(t).then(c,I=>u(I.message))};if(h.useEffect($,[t]),d)return e.jsx(be,{what:"your Claude Code",reason:d,onRetry:$});if(!o)return e.jsx(he,{what:"your Claude Code"});if(!o.available)return e.jsxs("div",{role:"status",children:[e.jsx("p",{className:"muted",children:o.why}),e.jsx("p",{children:e.jsx("button",{type:"button",className:"secondary",onClick:l,children:"Close"})})]});const E=I=>I==="skills"?o.skills:I==="mcp"?o.mcpServers:o.commands,C={skills:[],mcpServers:[],commands:[]};for(const I of Rl)for(const L of E(I.id))g.has(Uu(I.id,L.name))&&C[nN[I.id]].push(L.name);const R=C.skills.length+C.mcpServers.length+C.commands.length,P=I=>{const L=new Set(g);L.delete(I)||L.add(I),x(L)},M=()=>{v(null),S(!0),Mu.proposal(t,C).then(I=>{b({message:I.proposal,branch:I.branch}),S(!1)},I=>{v(I.message),S(!1)})},O=I=>{I.preventDefault(),y&&(v(null),S(!0),Mu.propose(t,C,y.message,y.branch,n).then(L=>a(C,L),L=>{v(L.message),S(!1)}))};if(y)return e.jsxs("form",{className:"form editor",onSubmit:O,children:[e.jsxs("p",{children:[sN(C)," from your Claude Code, as one request to the team's repository."]}),e.jsxs("label",{children:["Commit message",e.jsx("input",{value:y.message,onChange:I=>b({...y,message:I.target.value}),required:!0})]}),e.jsxs("label",{children:["Branch",e.jsx("input",{value:y.branch,onChange:I=>b({...y,branch:I.target.value}),required:!0,spellCheck:!1})]}),N?e.jsx("p",{className:"error",role:"alert",children:N}):null,e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",disabled:k,children:"Open request"}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>b(null),children:"Back"}),e.jsx("button",{type:"button",className:"secondary",onClick:l,children:"Cancel"})]})]});const _=E(m);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"segmented",role:"tablist","aria-label":"Your Claude Code",children:Rl.map(I=>e.jsx("button",{type:"button",role:"tab",className:"secondary","aria-selected":m===I.id,onClick:()=>f(I.id),children:I.label},I.id))}),_.length?e.jsx("ul",{className:"team-rows","aria-label":`Your ${Rl.find(I=>I.id===m).label}`,children:_.map(I=>e.jsxs("li",{children:[e.jsxs("label",{className:"team-pick",children:[e.jsx("input",{type:"checkbox",checked:g.has(Uu(m,I.name)),disabled:!I.addable,onChange:()=>P(Uu(m,I.name))}),e.jsx("span",{className:"mono",children:I.name})]}),I.description?e.jsxs("span",{className:"muted",children:[" ",I.description]}):null,e.jsxs("span",{className:"muted",children:[" ",I.addable?I.inTeam?"in the team; ticking updates it from yours":"from your Claude Code":I.why??"cannot be shared"]})]},I.name))}):e.jsx("p",{className:"muted",children:"Your Claude Code holds none of these."}),N?e.jsx("p",{className:"error",role:"alert",children:N}):null,e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",disabled:!R||k,onClick:M,children:R?`Propose ${R} to the team`:"Tick what to propose"}),e.jsx("button",{type:"button",className:"secondary",onClick:l,children:"Cancel"})]})]})}const Rf={addition:"Proposed in",update:"Update proposed in",removal:"Removal proposed in"},_a=(t,n,a)=>`${t}/${n}/${a}`,rN=t=>t==null?"":t?`, ${t} ${t===1?"task":"tasks"} this month`:", no task this month";function lN(t,n,a){return n==="skills"?t.skills.map(l=>{var o;return{name:l.slug,sentence:l.description,tasks:(o=a.skills.find(c=>c.name===l.slug||c.name===l.name))==null?void 0:o.tasks}}):n==="mcp"?t.mcpServers.map(l=>{var o;return{name:l.name,sentence:`${l.transport} server, ${l.target}`,tasks:(o=a.mcpServers.find(c=>c.name===l.name))==null?void 0:o.tasks}}):t.commands.map(l=>({name:l.name,sentence:l.description,tasks:void 0}))}function oN({me:t,repos:n,counts:a,picked:l,proposed:o,onPick:c,onProposed:d}){const u=n.filter(D=>D.kind==="skills"&&D.configured!==!1),[m,f]=h.useState(null),[g,x]=h.useState("skills"),[y,b]=h.useState(null),[N,v]=h.useState(null),[k,S]=h.useState(null),[$,E]=h.useState(!1),C=u.find(D=>D.id===m)??u[0],R=D=>{S(null),Ce.inventory(D).then(te=>{b(te.inventory),v(te.join)},te=>S(te.message))};h.useEffect(()=>{b(null),E(!1),C&&R(C.id)},[C==null?void 0:C.id]);const P=t.mode==="local"?"handbook repository":"team repository",M=`Nothing is shared yet. A skill, MCP server or command added to the ${P} lands here once it is merged.`;if(!C)return e.jsx(Xt,{name:"Team handbook",count:0,why:t.mode==="local"?"What your Claude Code loads from the handbook repository you started or joined.":"What every teammate's Claude Code loads from the team's repository.",empty:M});if(k)return e.jsx(be,{what:"the team handbook",reason:k,onRetry:()=>R(C.id)});if(!y)return e.jsx(he,{what:"the team handbook"});const O=y.skills.length+y.mcpServers.length+y.commands.length,_=Mr(t,C.team),I=lN(y,g,a),L=_a(C.id,g,""),K=[...o.keys()].filter(D=>D.startsWith(L)&&!I.some(te=>te.name===D.slice(L.length))).map(D=>({name:D.slice(L.length),sentence:"",tasks:void 0})),B=[...I,...K],ne=Rl.find(D=>D.id===g).label,Z=B.length?e.jsx("ul",{className:"team-rows","aria-label":ne,children:B.map(D=>{const te=o.get(_a(C.id,g,D.name)),Q=(l==null?void 0:l.repo.id)===C.id&&l.tab===g&&l.name===D.name;return e.jsxs("li",{className:Q?"picked":void 0,children:[e.jsx("button",{type:"button",className:"row-pick","aria-pressed":Q,onClick:()=>c({repo:C,head:y.head,tab:g,name:D.name,sentence:D.sentence,editable:_}),children:e.jsx("span",{className:"mono",children:D.name})}),D.sentence?e.jsxs("span",{className:"muted",children:[" ",D.sentence]}):null,e.jsxs("span",{className:"muted",children:[" from ",e.jsx("span",{className:"mono",children:C.name}),rN(D.tasks)]}),te?e.jsxs("span",{className:"muted",children:[" ",te.url&&/^https?:\/\//.test(te.url)?e.jsxs("a",{href:te.url,children:[Rf[te.what]," !",te.number]}):e.jsxs(e.Fragment,{children:[Rf[te.what]," !",te.number]}),", lands once merged"]}):null]},D.name)})}):e.jsxs("p",{className:"muted",children:[ne," is empty in the ",P,"."]});return e.jsxs(Xt,{name:"Team handbook",count:O,why:t.mode==="local"?"What your Claude Code loads from the handbook repository you started or joined.":"What every teammate's Claude Code loads from the team's repository.",empty:M,children:[u.length>1&&t.mode!=="local"?e.jsx("div",{className:"handbook-repo",children:e.jsx(Pe,{label:"Team repository",value:C.id,onChange:f,options:u.map(D=>({value:D.id,label:D.name}))})}):null,$?e.jsx(aN,{repoId:C.id,head:y.head,onCancel:()=>E(!1),onProposed:(D,te)=>{E(!1),d(C.id,D,te)}}):e.jsxs(e.Fragment,{children:[_?e.jsx("p",{children:e.jsx("button",{type:"button",className:"secondary",onClick:()=>E(!0),children:"Add from your Claude Code"})}):null,e.jsx("div",{className:"segmented",role:"tablist","aria-label":"Team handbook",children:Rl.map(D=>e.jsx("button",{type:"button",role:"tab",className:"secondary","aria-selected":g===D.id,onClick:()=>x(D.id),children:D.label},D.id))}),Z,t.mode!=="local"&&N&&"use"in N?e.jsxs("p",{className:"muted handbook-join",children:["To get these in your own Claude Code: ",N.use.map(D=>e.jsx(mt,{text:D},D))]}):null]})]})}function iN({pick:t,onOpened:n}){const{repo:a,head:l,tab:o,name:c}=t,[d,u]=h.useState(null),[m,f]=h.useState(null),[g,x]=h.useState(null);h.useEffect(()=>{u(null),f(null),x(null),o!=="mcp"&&(o==="skills"?Ce.skill(a.id,c):Ce.command(a.id,c)).then(b=>u(b.content),b=>f(b.message))},[a.id,o,c]);const y={repoId:a.id,head:l,onOpened:b=>n(b,g==="remove"?"removal":"update"),onCancel:()=>x(null)};return e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"mono",children:c}),o==="mcp"?e.jsxs("p",{className:"muted",children:[t.sentence,". Its values stay sealed; the repository holds only the names it needs."]}):m?e.jsx("p",{className:"error",role:"alert",children:m}):d===null?e.jsxs("p",{className:"muted",children:["Reading ",c,"…"]}):e.jsx("pre",{className:"handbook-text",children:d}),t.editable?null:e.jsxs("p",{className:"muted",children:["Only an admin or an owner of ",a.team," proposes changes to this repository."]}),t.editable&&!g?e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",className:"secondary",onClick:()=>x("update"),children:"Update…"}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>x("remove"),children:"Remove…"})]}):null,g==="update"&&o==="skills"?e.jsx(Sd,{...y,slug:c},`u-${c}`):null,g==="update"&&o==="commands"?e.jsx(Cd,{...y,name:c},`u-${c}`):null,g==="update"&&o==="mcp"?e.jsx($d,{...y,name:c},`u-${c}`):null,g==="remove"&&o==="skills"?e.jsx(Lx,{...y,slug:c},`r-${c}`):null,g==="remove"&&o==="commands"?e.jsx(Ox,{...y,name:c},`r-${c}`):null,g==="remove"&&o==="mcp"?e.jsx(Fx,{...y,name:c},`r-${c}`):null]})}const Mx=new Map,_x=t=>Pn(t),Ss=t=>Mx.get(_x(t));function Ir(t,n){return Mx.set(_x(t),n),n}const qa={sources:[],skills:[],commands:[],mcpServers:[]},Du=t=>`/api/handbook/sources${t?`?${new URLSearchParams({folder:t})}`:""}`,Bu="/api/handbook/defaults",$n={lastSources:t=>Ss(Du(t)),lastDefaults:()=>Ss(Bu),defaults:()=>U("GET",Bu).then(t=>Ir(Bu,{...qa,...t.off,sources:[]})),sources:t=>U("GET",Du(t)).then(n=>Ir(Du(t),n)),noticed:t=>U("POST","/api/handbook/noticed",{plugin:t}),skill:(t,n)=>U("GET",`/api/handbook/skill?${new URLSearchParams({source:t,name:n})}`).then(a=>a.content)},Tn=(t,n)=>!n.enabled||t.sources.includes(n.id),cN=(t,n,a,l)=>Tn(t,a)||t[n].some(o=>o.source===a.id&&o.name===l);function uN(t,n){return t.sources.includes(n)?{...t,sources:t.sources.filter(a=>a!==n)}:{...t,sources:[...t.sources,n]}}function dN(t,n,a,l){const o=t[n].some(c=>c.source===a&&c.name===l);return{...t,[n]:o?t[n].filter(c=>!(c.source===a&&c.name===l)):[...t[n],{source:a,name:l}]}}const hN="It comes with its plugin; turn the plugin off.",mN="It comes with its plugin; turn the plugin off.",pN="Claude Code does not leave out one hook; turn off the plugin it comes with.",fN="Claude Code runs your own hooks in every session.",gN="Off for agents started here. Your terminal still has it.",xN="Off for agents started here: the agent cannot call it; its name still shows.",jN="The agent cannot call it; its name still shows.",yN=t=>`Two skills are named ${t}; one cannot be left out without the other.`,Pf=t=>t.source.kind==="yours"?"yours":"this folder's";function vN(t,n,a){const l=(a.get(t)??[]).find(c=>c.source.id!==n.source.id||c.kind!==n.kind);if(!l)return;if(n.kind==="Skill"&&l.kind==="Skill"){const[c,d]=n.source.kind==="yours"?[n,l]:[l,n];return`Two skills are named ${t}: ${Pf(c)} is listed first to the agent, ${Pf(d)} after it.`}return n.kind==="Command"&&l.kind==="Command"?`Two commands are named /${t}, in yours and this folder; which one an agent gets is not known.`:(n.kind==="Command"?n:l).source.kind==="yours"?`A skill and a command are named ${t}: the skill is listed first to the agent, the command after it.`:`A skill and a command are named ${t}; which one an agent gets is not known.`}const Af=t=>t.kind==="yours"?0:t.kind==="folder"?1:t.kind==="team-repo"?2:3,Ux=t=>[...t].sort((n,a)=>Af(n)-Af(a)||n.name.localeCompare(a.name));function fa(t,n,a){const l=Ux(t),o=new Map;for(const m of l)if(m.kind!=="plugin")for(const f of m.skills)o.set(f.name,(o.get(f.name)??0)+1);const c=new Map,d=(m,f)=>c.set(m,[...c.get(m)??[],f]);for(const m of l)if(!(m.kind!=="yours"&&m.kind!=="folder")){for(const f of m.skills)d(f.name,{kind:"Skill",source:m});for(const f of m.commands)d(f.name,{kind:"Command",source:m})}const u=(m,f,g)=>{const x=f.kind==="yours"||f.kind==="folder"?vN(g,{kind:m,source:f},c):void 0;return x?{clash:x}:{}};return l.flatMap(m=>{const f=Tn(n,m),g=m.kind==="plugin",x=($,E,C,R,P,M)=>{const O=E?!cN(n,E,m,C):!f,_=!!E&&!M&&!f;return{key:`${m.id}
|
|
65
|
+
${$}
|
|
66
|
+
${C}`,name:R,kind:$,source:m,on:O,switchable:_,...E&&!M?{list:E}:{},...P,...M?{whyNot:M}:{}}},y=a==="default"?gN:void 0,b=m.skills.map($=>x("Skill","skills",$.name,$.name,{...$.description?{sentence:$.description}:{},...$.context?{context:$.context}:{},...$.used?{used:$.used}:{},...u("Skill",m,$.name),...g?{offNote:a==="default"?xN:jN}:y?{offNote:y}:{}},$.whyNot??(!g&&(o.get($.name)??0)>1?yN($.name):void 0))),N=m.mcpServers.map($=>x("Server",g?void 0:"mcpServers",$.name,$.name,{sentence:"An MCP server.",...$.context?{context:$.context}:{},...$.used?{used:$.used}:{},...y&&!g?{offNote:y}:{}},$.whyNot??(g?hN:void 0))),v=m.commands.map($=>x("Command",g?void 0:"commands",$.name,`/${$.name}`,{...y&&!g?{offNote:y}:{},...u("Command",m,$.name)},$.whyNot??(g?mN:void 0))),k=m.hooks.map($=>x("Hook",void 0,$.name,$.name,{hook:{matchers:$.matchers??[],commands:$.commands??[]}},g?pN:fN)),S=m.claudeMd?[x("Rules",void 0,"CLAUDE.md","CLAUDE.md",{},void 0)]:[];return[...b,...N,...v,...k,...S]})}const kN=(t,n)=>n.list?dN(t,n.list,n.source.id,n.kind==="Command"?n.name.replace(/^\//,""):n.name):t;function $i(t){return t.kind==="yours"?"Yours":t.kind==="folder"?`this folder (${t.name})`:t.kind==="team-repo"?`the team's ${t.name}`:`${t.name}${t.version?` ${t.version}`:""}`}const Td=t=>t>=1e3?`${Math.round(t/100)/10}k`:String(t),bN=t=>`In every task about ${Td(t.tokens)} tokens${t.percent===void 0?"":`, ${t.percent}% of the context`}.`,wN=30,NN=t=>t.replace(/^---\s*\n[\s\S]*?\n---\s*\n?/,"").trimStart(),SN=t=>t.tasks===0?`Not used in ${wN} days.`:`Used in ${t.tasks} ${t.tasks===1?"task":"tasks"}${t.lastAt?`, last ${new Date(t.lastAt).toLocaleDateString(void 0,{month:"short",day:"numeric"})}`:""}.`,CN=10;function $N(t,n,a){const l=a.filter(y=>y.on),o=l.filter(y=>y.kind!=="Server"&&y.context),c=o.reduce((y,b)=>y+b.context.tokens,0),d=l.filter(y=>y.kind==="Server"&&y.context).reduce((y,b)=>y+b.context.tokens,0),u=t.filter(y=>y.latest&&!Tn(n,y)).length,m=l.reduce((y,b)=>{var N;return y+(((N=b.context)==null?void 0:N.percent)??0)},0),f=`${t.length} ${t.length===1?"handbook":"handbooks"}, ${l.length} of ${a.length} on`,g=o.length?`, about ${Td(c)} tokens in every task`:"",x=d?`${o.length?", plus":", about"} ${Td(d)} ${o.length?"for servers":"tokens for servers"}, as measured in your last task`:"";return{text:`${f}${u?`, ${u} ${u===1?"update":"updates"}`:""}${g}${x}`,heavy:m>=CN}}function TN(t,n,a){const l=fa(t,n,"task"),o=new Map(fa(t,a,"task").map(d=>[d.key,d.on]));return t.filter(d=>d.kind==="plugin"&&n.sources.includes(d.id)!==a.sources.includes(d.id)).length+l.filter(d=>d.list&&o.get(d.key)!==d.on&&!Tn(n,d.source)&&!Tn(a,d.source)).length}const Or={read:(t,n,a)=>U("GET",`/api/handbook/file?${new URLSearchParams({source:t,kind:n,name:a})}`),save:(t,n,a,l,o)=>U("PUT","/api/handbook/file",{source:t,kind:n,name:a,content:l,expectedDigest:o}),remove:(t,n,a,l)=>U("DELETE","/api/handbook/file",{source:t,kind:n,name:a,expectedDigest:l})},EN=t=>t==="yours"||t.startsWith("folder:");function Ti(t,n,a){const l=t==="yours"?"~/.claude":`${t.slice(7)}/.claude`;return n==="skill"?`${l}/skills/${a}`:`${l}/commands/${a.split(":").join("/")}.md`}const Dx=(t,n,a)=>n==="skill"?`${Ti(t,n,a)}/SKILL.md`:Ti(t,n,a);function RN(t,n,a){return`---
|
|
67
|
+
name: ${t}
|
|
68
|
+
description: ${n.replace(/\s+/g," ").trim()}
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
${a.trim()}
|
|
72
|
+
`}function PN(t,n){const a=t.replace(/\n$/,"").split(`
|
|
73
|
+
`),l=n.replace(/\n$/,"").split(`
|
|
74
|
+
`),o=Array.from({length:a.length+1},()=>new Array(l.length+1).fill(0));for(let m=a.length-1;m>=0;m--)for(let f=l.length-1;f>=0;f--)o[m][f]=a[m]===l[f]?o[m+1][f+1]+1:Math.max(o[m+1][f],o[m][f+1]);const c=[];let d=0,u=0;for(;d<a.length||u<l.length;)d<a.length&&u<l.length&&a[d]===l[u]?(c.push(` ${a[d++]}`),u++):d<a.length&&(u===l.length||o[d+1][u]>=o[d][u+1])?c.push(`-${a[d++]}`):c.push(`+${l[u++]}`);return[`@@ -1,${a.length} +1,${l.length} @@`,...c].join(`
|
|
75
|
+
`)}const AN=/^[a-z0-9][a-z0-9-]{0,63}$/;function IN({source:t,kind:n,name:a,onDone:l}){const[o,c]=h.useState(null),[d,u]=h.useState(""),[m,f]=h.useState(!1),[g,x]=h.useState(null),[y,b]=h.useState(!1),N=h.useId();if(h.useEffect(()=>{Or.read(t,n,a).then(k=>{c(k),u(k.content??"")},k=>x(k.message))},[t,n,a]),!o)return g?e.jsx("p",{className:"error small",role:"alert",children:g}):e.jsx(he,{what:`the ${n}`});if(o.content===null)return e.jsx("p",{className:"muted small",children:"It is not there any more."});const v=()=>{b(!0),x(null),Or.save(t,n,a,d,o.digest).then(()=>l(!0),k=>{x(k.message),f(!1)}).finally(()=>b(!1))};return e.jsx("div",{className:"handbook-edit",children:m?e.jsxs(e.Fragment,{children:[e.jsx(ph,{patch:PN(o.content,d)}),e.jsxs("p",{className:"muted small",children:["Saves ",e.jsx("span",{className:"mono",children:Dx(t,n,a)}),"."]}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",disabled:y,onClick:v,children:"Save"}),e.jsx("button",{type:"button",className:"secondary",disabled:y,onClick:()=>f(!1),children:"Keep editing"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"visually-hidden",htmlFor:N,children:[n==="skill"?"SKILL.md":`${a}.md`," of ",a]}),e.jsx("textarea",{id:N,className:"mono",rows:16,spellCheck:!1,value:d,onChange:k=>u(k.target.value)}),g?e.jsx("p",{className:"error small",role:"alert",children:g}):null,e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",disabled:d===o.content,onClick:()=>f(!0),children:"Save…"}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>l(!1),children:"Cancel"})]})]})})}function ON({source:t,kind:n,name:a,onDone:l}){return e.jsx(qe,{trigger:"Remove…",triggerLabel:`Remove ${a}`,consequence:`This deletes ${Ti(t,n,a)} and nothing else.`,confirm:"Remove",keep:"Keep it",small:!0,danger:!0,onConfirm:async()=>{const o=await Or.read(t,n,a);if(o.digest===null)throw new Error("It is not there any more.");await Or.remove(t,n,a,o.digest),l()}})}function LN({source:t,name:n,read:a,onDone:l}){const[o,c]=h.useState(null),[d,u]=h.useState(!1),m=()=>{u(!0),c(null),a(t,n).then(f=>Or.save("yours","skill",n,f,null)).then(()=>{c({ok:!0,text:`Copied to ${Ti("yours","skill",n)}.`}),l()},f=>c({ok:!1,text:f.message})).finally(()=>u(!1))};return e.jsxs("div",{children:[e.jsx("button",{type:"button",className:"secondary small",disabled:d,onClick:m,children:"Copy to Yours"}),o?e.jsx("p",{className:o.ok?"muted small":"error small",role:o.ok?"status":"alert",children:o.text}):null]})}function FN({kind:t,onDone:n}){const[a,l]=h.useState(""),[o,c]=h.useState(""),[d,u]=h.useState(""),[m,f]=h.useState(null),[g,x]=h.useState(!1),y=AN.test(a),b=y&&d.trim()!==""&&(t==="command"||o.trim()!==""),N=()=>{x(!0),f(null);const v=t==="skill"?RN(a,o,d):`${d.trim()}
|
|
76
|
+
`;Or.save("yours",t,a,v,null).then(()=>n(!0),k=>f(k.message)).finally(()=>x(!1))};return e.jsxs("form",{className:"form handbook-edit",onSubmit:v=>{v.preventDefault(),b&&N()},"aria-label":t==="skill"?"New skill":"New command",children:[e.jsxs("label",{children:["Name",e.jsx("input",{className:"mono",value:a,onChange:v=>l(v.target.value),autoComplete:"off",spellCheck:!1})]}),a&&!y?e.jsx("p",{className:"muted small",children:"Lower-case letters, digits and dashes."}):null,t==="skill"?e.jsxs("label",{children:["When to use it",e.jsx("input",{value:o,onChange:v=>c(v.target.value)})]}):null,e.jsxs("label",{children:[t==="skill"?"Body":"Text",e.jsx("textarea",{className:"mono",rows:10,spellCheck:!1,value:d,onChange:v=>u(v.target.value)})]}),y?e.jsxs("p",{className:"muted small",children:["Saves ",e.jsx("span",{className:"mono",children:Dx("yours",t,a)}),"."]}):null,m?e.jsx("p",{className:"error small",role:"alert",children:m}):null,e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",disabled:!b||g,children:"Save"}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>n(!1),children:"Cancel"})]})]})}const Ei=80,hi=160,If=7,MN=20,ls=(t,n)=>t.length>n?`${t.slice(0,n).trimEnd()}…`:t,_N={default:"How agents started here begin. Turning a plugin off turns it off in your terminal too.",task:null,readonly:null};function Of({source:t,name:n,read:a}){const[l,o]=h.useState(null),[c,d]=h.useState(null);return h.useEffect(()=>{let u=!0;return a(t,n).then(m=>u&&o(m),m=>u&&d(m.message)),()=>{u=!1}},[t,n]),c!==null?e.jsx("p",{className:"error small",role:"alert",children:c}):l===null?e.jsx(he,{what:"the skill"}):e.jsx("pre",{className:"pre mono small",children:NN(l)})}function Bx({on:t,mixed:n=!1,label:a,disabled:l=!1,onChange:o}){return e.jsx("button",{type:"button",role:"switch",className:"switch","aria-checked":n?"mixed":t,"aria-label":a,disabled:l,onClick:o,children:e.jsx("span",{className:"switch-track","aria-hidden":"true",children:e.jsx("span",{className:"switch-knob"})})})}function UN({entry:t,locked:n,changed:a,state:l,read:o,onFlip:c,files:d}){var S;const[u,m]=h.useState(!1),[f,g]=h.useState(!1),x=t.kind==="Skill"?"skill":t.kind==="Command"?"command":null,y=EN(t.source.id),b=h.useId(),N=ls(t.name,Ei),v=!!t.whyNot&&!n&&!l,k=t.kind!=="Hook"||(((S=t.hook)==null?void 0:S.commands.length)??0)>0;return e.jsxs("li",{className:"handbook-row",children:[e.jsxs("div",{className:"handbook-line",children:[k?e.jsx("button",{type:"button",className:"link mono handbook-name",title:t.name,"aria-expanded":u,"aria-controls":b,onClick:()=>m(!u),dir:"auto",children:N}):e.jsx("span",{className:"mono handbook-name",title:t.name,children:N}),e.jsxs("span",{className:"handbook-meta",children:[e.jsx("span",{className:"muted small",children:t.kind}),a?e.jsx("span",{className:"muted small",children:"Changed"}):null,!t.on&&t.offNote&&!l?e.jsx("span",{className:"muted small",children:t.offNote}):null,(l==null?void 0:l.seq)!==void 0?e.jsx("button",{type:"button",className:"link small",onClick:()=>ix(l.seq),children:"Show where"}):null]}),l?e.jsx("span",{className:`handbook-end ${l.danger?"error small":"muted small"}`,children:l.word}):t.switchable&&!n?e.jsx("span",{className:"handbook-end",children:e.jsx(Bx,{on:t.on,label:`Use ${N}`,onChange:c})}):null]}),v?e.jsx("p",{className:"muted small handbook-why",children:ls(t.whyNot,hi)}):null,u?e.jsxs("div",{id:b,className:"handbook-open small",children:[t.sentence?e.jsx("p",{dir:"auto",children:ls(t.sentence,hi)}):null,t.context?e.jsx("p",{className:"muted",children:bN(t.context)}):null,t.used?e.jsx("p",{className:"muted",children:SN(t.used)}):null,t.clash?e.jsx("p",{className:"muted",children:t.clash}):null,t.hook?e.jsxs("dl",{className:"plugin-changes",children:[t.hook.matchers.length?e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Matches"}),e.jsx("dd",{className:"mono",children:t.hook.matchers.join(", ")})]}):null,e.jsx("dt",{children:"Runs"}),e.jsx("dd",{className:"mono",children:t.hook.commands.join("; ")})]}):null,t.kind==="Rules"?e.jsx(Of,{source:t.source.id,name:t.name,read:o}):null,t.whyNot&&!v?e.jsx("p",{className:"muted",children:ls(t.whyNot,hi)}):null,f&&x?e.jsx(IN,{source:t.source.id,kind:x,name:t.name,onDone:$=>{g(!1),$&&(d==null||d.onChanged())}}):t.kind==="Skill"?e.jsx(Of,{source:t.source.id,name:t.name,read:o}):null,d&&x&&!f?y?e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",className:"secondary small","aria-label":`Edit ${N}`,onClick:()=>g(!0),children:"Edit…"}),e.jsx(ON,{source:t.source.id,kind:x,name:t.name,onDone:d.onChanged})]}):x==="skill"?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"muted",children:["It changes in ",ls($i(t.source),Ei),"."]}),e.jsx(LN,{source:t.source.id,name:t.name,read:o,onDone:d.onChanged})]}):null:null]}):null]})}function DN({entries:t,rowFor:n}){const[a,l]=h.useState(!1),o=t.filter(d=>d.on),c=t.filter(d=>!d.on);return e.jsxs("div",{className:"handbook-things",children:[e.jsx("ul",{className:"plain",children:(a?o:o.slice(0,If)).map(n)}),o.length>If&&!a?e.jsx("p",{children:e.jsxs("button",{type:"button",className:"link small",onClick:()=>l(!0),children:["Show all (",o.length,")"]})}):null,c.length?e.jsxs("details",{className:"handbooks-off small",children:[e.jsxs("summary",{children:["Off (",c.length,")"]}),e.jsx("ul",{className:"plain",children:c.map(n)})]}):null]})}function qx({sources:t,off:n,defaultOff:a,level:l,onChange:o,onPlugin:c,stateOf:d,read:u=$n.skill,pluginActions:m,files:f,look:g}){const[x,y]=h.useState(null);h.useEffect(()=>{g&&y(g.source)},[g]);const[b,N]=h.useState(""),v=h.useId(),k=l==="readonly"||!o,S=fa(t,n,l),$=$N(t,n,S),E=_N[l],C=a?new Map(fa(t,a,l).map(Z=>[Z.key,Z.on])):null,R=Z=>!!(C&&Z.list&&C.get(Z.key)!==Z.on),P=b.trim().toLowerCase(),M=Z=>e.jsx(UN,{entry:Z,locked:k,changed:R(Z),...d?{state:d(Z)}:{},read:u,onFlip:()=>o==null?void 0:o(kN(n,Z)),...f?{files:f}:{}},Z.key);if(!t.length)return e.jsx("p",{className:"muted",children:"Your Claude Code has no skills of its own yet."});const[O,_]=h.useState(!1),I=Z=>(Tn(n,Z)||_(!0),c?c(Z,Tn(n,Z)):o==null?void 0:o(uN(n,Z.id))),L=Ux(t),K=L.filter(Z=>Tn(n,Z)),B=L.filter(Z=>!Tn(n,Z)),ne=Z=>{const D=S.filter(A=>A.source.id===Z.id),te=Tn(n,Z),Q=te?0:D.filter(A=>A.on).length,ee=x===Z.id,W=Z.kind==="plugin";return e.jsxs("li",{className:"handbook",children:[e.jsxs("div",{className:"handbook-line",children:[e.jsx("button",{type:"button",className:"link handbook-name","aria-expanded":ee,"aria-controls":`${v}-${Z.id}`,onClick:()=>y(ee?null:Z.id),dir:"auto",children:ls(Z.kind==="yours"?"Yours":Z.kind==="folder"?`This folder (${Z.name})`:Z.name,Ei)}),e.jsxs("span",{className:"handbook-meta",children:[Z.version?e.jsxs("span",{className:"muted small",children:[ls(Z.version,24),Z.latest?` → ${ls(Z.latest.version,24)}`:""]}):null,Z.latest&&m&&!ee?e.jsx("button",{type:"button",className:"link small",onClick:()=>y(Z.id),children:"Update…"}):null,e.jsx("span",{className:"muted small",children:te?"off":`${Q} of ${D.length} on`})]}),W&&!k&&!Z.whyNot?e.jsx("span",{className:"handbook-end",children:e.jsx(Bx,{on:!te,mixed:!te&&Q<D.length,label:`Use ${ls($i(Z),Ei)}`,disabled:l==="task"&&!Z.enabled,onChange:()=>I(Z)})}):null]}),Z.whyNot?e.jsx("p",{className:"muted small",children:ls(Z.whyNot,hi)}):null,ee?e.jsxs("div",{id:`${v}-${Z.id}`,className:"handbook-opened",children:[e.jsx(DN,{entries:D,rowFor:M}),W&&m?m(Z):null]}):null]},Z.id)};return e.jsxs("div",{className:"handbook-list",children:[E?e.jsx("p",{className:"handbook-lead",children:E}):null,l==="task"?null:e.jsx("p",{className:$.heavy?"waiting small":"muted small",children:$.text}),S.length>MN?e.jsxs("label",{className:"filter small",children:["Find in this list",e.jsx("input",{type:"search",value:b,onChange:Z=>N(Z.target.value)})]}):null,P?e.jsx("ul",{className:"plain handbook-things",children:S.filter(Z=>`${Z.name} ${$i(Z.source)}`.toLowerCase().includes(P)).map(M)}):e.jsx(e.Fragment,{children:e.jsxs("ul",{className:"plain handbooks",children:[B.map(ne),K.length?e.jsxs("li",{className:"handbook-off",children:[e.jsxs("div",{className:"handbook-line",children:[e.jsx("button",{type:"button",className:"link handbook-name","aria-expanded":O,"aria-controls":`${v}-off`,onClick:()=>_(!O),children:"Off"}),e.jsx("span",{className:"handbook-end",children:e.jsxs("span",{className:"muted small",children:[K.length," ",K.length===1?"handbook":"handbooks"]})})]}),O?e.jsx("div",{id:`${v}-off`,className:"handbook-opened",children:e.jsx("ul",{className:"plain handbooks",children:K.map(ne)})}):null]}):null]})})]})}const ha={list:()=>U("GET","/api/machines"),pair:()=>U("POST","/api/machines/pair"),remove:t=>U("DELETE",`/api/machines/${encodeURIComponent(t)}`)},BN={PreToolUse:"before each tool call",PostToolUse:"after each tool call",UserPromptSubmit:"on each prompt",SessionStart:"when a session starts",SessionEnd:"when a session ends",Stop:"when the agent stops",SubagentStop:"when a subagent stops",Notification:"on each notification",PreCompact:"before the conversation is compacted"},Wx=t=>BN[t]??t,Lf=(t,n,a)=>t?`${t} ${t===1?n:a}`:null;function Ed(t,n){const a=t.length?` (${t.map(l=>Wx(l.name)).join(", ")})`:"";return[t.length?`${Lf(t.length,"hook","hooks")}${a}`:null,Lf(n.length,"MCP server","MCP servers")].filter(Boolean).join(" and ")}function Rd({hooks:t,mcpServers:n}){return!t.length&&!n.length?null:e.jsxs("dl",{className:"plugin-changes",children:[t.length?e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Hooks"}),e.jsx("dd",{children:t.map(a=>e.jsxs("div",{children:[Wx(a.name),": ",e.jsx("span",{className:"mono",children:a.commands.join("; ")||"no command"})]},a.name))})]}):null,n.length?e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"MCP servers"}),e.jsx("dd",{className:"mono",children:n.join(", ")})]}):null]})}const qN="claude-plugins-official",qu=8;function WN(t,n,a){const l=n.trim().toLowerCase();return t.filter(o=>(a===""||o.marketplace===a)&&(l?`${o.name} ${o.description??""}`.toLowerCase().includes(l):a!==""||o.marketplace!==qN))}function zN({onRan:t,onCancel:n}){const[a,l]=h.useState(null),[o,c]=h.useState(null),[d,u]=h.useState(null),[m,f]=h.useState(!1),[g,x]=h.useState(""),[y,b]=h.useState(""),[N,v]=h.useState(!1),k=()=>{c(null),U("GET","/api/handbook/plugins/available").then(E=>l(E.plugins),E=>c(E.message))};if(h.useEffect(k,[]),o)return e.jsx(be,{what:"the plugins on offer",reason:o,onRetry:k});if(!a)return e.jsx(he,{what:"the plugins on offer"});const S=WN(a,g,y),$=E=>{f(!0),U("POST","/api/handbook/plugins/install",{plugin:E.id}).then(t,C=>c(C.message)).finally(()=>f(!1))};return e.jsx("div",{className:"plugin-add",role:"group","aria-label":"Add a plugin",children:d?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["This runs ",e.jsxs("code",{children:["claude plugin install ",d.name,"@",d.marketplace]}),"; your terminal gets it too. ",Ed(d.hooks??[],d.mcpServers)?`It runs ${Ed(d.hooks??[],d.mcpServers)}, in your terminal and in tasks started here.`:""]}),e.jsx(Rd,{hooks:d.hooks??[],mcpServers:d.mcpServers}),e.jsxs("div",{className:"actions",children:[e.jsxs("button",{type:"button",disabled:m,onClick:()=>$(d),children:["Install ",d.name]}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>u(null),children:"Back"})]})]}):e.jsxs(e.Fragment,{children:[a.length?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"plugin-add-find",children:[e.jsxs("label",{className:"filter small",children:["Find a plugin",e.jsx("input",{type:"search",value:g,onChange:E=>{x(E.target.value),v(!1)}})]}),e.jsxs("label",{className:"filter small",children:["From",e.jsxs("select",{value:y,onChange:E=>{b(E.target.value),v(!1)},children:[e.jsx("option",{value:"",children:"Marketplaces you added"}),[...new Set(a.map(E=>E.marketplace))].sort().map(E=>e.jsx("option",{value:E,children:E},E))]})]})]}),S.length?e.jsx("ul",{className:"team-rows plugin-add-list",children:(N?S:S.slice(0,qu)).map(E=>e.jsxs("li",{className:"plugin-add-row",children:[e.jsxs("span",{className:"plugin-add-what",children:[e.jsx("span",{className:"mono",children:E.name})," ",e.jsxs("span",{className:"muted plugin-add-line",children:[E.marketplace,E.version?` ${E.version}`:"",E.description?`: ${E.description}`:""]})]}),e.jsx("button",{type:"button",className:"secondary small",onClick:()=>u(E),children:"Install…"})]},E.id))}):e.jsx("p",{className:"muted",children:g.trim()?"No plugin matches.":"Search for a plugin, or pick a marketplace."}),!N&&S.length>qu?e.jsx("p",{children:e.jsxs("button",{type:"button",className:"link small",onClick:()=>v(!0),children:["Show more (",S.length-qu,")"]})}):null]}):e.jsxs("p",{className:"muted",children:["The marketplaces your Claude Code knows offer nothing you have not installed. Add another with ",e.jsx("code",{children:"claude plugin marketplace add"})," in your terminal."]}),e.jsx("p",{children:e.jsx("button",{type:"button",className:"secondary",onClick:n,children:"Close"})})]})})}const Ff=(t,n,a)=>t?`${t} ${t===1?n:a}`:null;function HN(t){if(t.length===1){const[n]=t,a=n.notice,l=[Ff(a.hooks,"hook","hooks"),Ff(a.mcpServers,"MCP server","MCP servers")].filter(Boolean).join(" and ");return`${n.name}${n.version?` ${n.version}`:""} runs ${l}.`}return`${t.length} plugins run hooks or servers: ${t.map(n=>n.name).join(", ")}.`}function zx({sources:t,look:n,putAway:a}){const[l,o]=h.useState([]),[c,d]=h.useState(!1),u=t.filter(f=>f.kind==="plugin"&&f.notice&&(f.notice.hooks||f.notice.mcpServers)&&!l.includes(f.id)),m=()=>{o(f=>[...f,...u.map(g=>g.id)]),d(!0);for(const f of u)a(f).catch(()=>{})};return u.length?e.jsxs("p",{className:"muted small handbook-news",children:[HN(u)," ",n," ",e.jsx("button",{type:"button",className:"secondary small",onClick:m,children:"Got it"})]}):c?e.jsx("p",{className:"muted small","aria-live":"polite",children:"Put away; nothing changed."}):null}const sa=t=>t.length?t.join(", "):null,GN=t=>t.length>1?`${t.slice(0,-1).join(", ")} and ${t.at(-1)}`:t[0]??"";function Mf(t){const n=Ed(t.hooks,t.mcpServers),a=GN([t.added.length?`adds ${t.added.join(", ")}`:null,t.changed.length?`changes ${t.changed.join(", ")}`:null,t.removed.length?`removes ${t.removed.join(", ")}`:null].filter(o=>o!==null)),l=n&&a?`brings ${n}, ${a}`:n?`brings ${n}`:a;return l?`${t.version} ${l}.`:""}const Zo=t=>[...t.added.map(n=>`${n} (added)`),...t.changed.map(n=>`${n} (changed)`),...t.removed.map(n=>`${n} (removed)`)];function KN({source:t,onRan:n,machine:a}){var S,$;const l=a?`?${new URLSearchParams({machine:a.id})}`:"",[o,c]=h.useState(null),[d,u]=h.useState(null),[m,f]=h.useState(null),[g,x]=h.useState(!1),[y,b]=h.useState(null),N=E=>{b({name:E,text:null,truncated:!1}),U("GET",`/api/handbook/plugins/${encodeURIComponent(t.marketplace??"")}/${encodeURIComponent(t.name)}/changes/skills/${encodeURIComponent(E)}`).then(C=>b({name:E,text:C.patch,truncated:C.truncated}),C=>b({name:E,text:C.message,truncated:!1}))},v=E=>{x(!0),U("POST",`/api/handbook/plugins/${E}${l}`,{plugin:t.id}).then(C=>{c(null),n(C)},C=>f(C.message)).finally(()=>x(!1))},k=()=>{c("update"),f(null),!a&&U("GET",`/api/handbook/plugins/${encodeURIComponent(t.marketplace??"")}/${encodeURIComponent(t.name)}/changes`).then(u,E=>f(E.message))};return e.jsxs("div",{className:"plugin-actions",children:[o==="update"?e.jsxs("div",{className:"plugin-ask",role:"group","aria-label":`Update ${t.name}`,children:[!d&&!m&&!a?e.jsxs("p",{className:"muted",children:["Reading what ",((S=t.latest)==null?void 0:S.version)??"the update"," changes…"]}):null,d?e.jsxs("dl",{className:"plugin-changes",children:[sa(d.freshness.added)?e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Adds"}),e.jsx("dd",{className:"mono",children:sa(d.freshness.added)})]}):null,d.freshness.changed.length?e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Changes"}),e.jsx("dd",{children:d.freshness.changed.map((E,C)=>e.jsxs("span",{children:[C?", ":"",e.jsx("button",{type:"button",className:"link mono","aria-pressed":(y==null?void 0:y.name)===E,onClick:()=>N(E),children:E})]},E))})]}):null,sa(d.freshness.removed)?e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Removes"}),e.jsx("dd",{className:"mono",children:sa(d.freshness.removed)})]}):null,sa(Zo(d.commands))?e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Commands"}),e.jsx("dd",{className:"mono",children:sa(Zo(d.commands))})]}):null,sa(Zo(d.mcpServers))?e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"MCP servers"}),e.jsx("dd",{className:"mono",children:sa(Zo(d.mcpServers))})]}):null]}):null,y?e.jsxs("pre",{className:"handbook-text","aria-label":`What changes in ${y.name}`,children:[y.text??`Reading ${y.name}…`,y.truncated?`
|
|
77
|
+
…`:""]}):null,e.jsxs("p",{children:["This runs ",e.jsxs("code",{children:["claude plugin marketplace update ",t.marketplace]})," and ",e.jsxs("code",{children:["claude plugin update ",t.name,"@",t.marketplace]}),a?` on ${a.name}`:"","; your terminal gets it too. ",t.latest?Mf(t.latest):""]}),t.latest?e.jsx(Rd,{hooks:t.latest.hooks,mcpServers:t.latest.mcpServers}):null,e.jsxs("div",{className:"actions",children:[e.jsxs("button",{type:"button",disabled:g||!d&&!a,onClick:()=>v("update"),children:["Update to ",(($=t.latest)==null?void 0:$.version)??"the newer version"]}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>c(null),children:"Cancel"})]})]}):o==="remove"?e.jsxs("div",{className:"plugin-ask",role:"group","aria-label":`Remove ${t.name}`,children:[e.jsxs("p",{children:["This runs ",e.jsxs("code",{children:["claude plugin uninstall ",t.name,"@",t.marketplace]}),a?` on ${a.name}`:"","; your terminal loses it too, and it cannot be put back from here. Turn it off instead?"]}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",disabled:g,onClick:()=>v("disable"),children:"Turn off"}),e.jsx("button",{type:"button",className:"danger",disabled:g,onClick:()=>v("uninstall"),children:"Remove"}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>c(null),children:"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[t.latest?e.jsx("p",{children:Mf(t.latest)}):null,t.latest?e.jsx(Rd,{hooks:t.latest.hooks,mcpServers:t.latest.mcpServers}):null,e.jsxs("div",{className:"actions",children:[t.latest?e.jsxs("button",{type:"button",className:"small",onClick:k,children:["Update to ",t.latest.version,"…"]}):null,e.jsx("button",{type:"button",className:"link small",onClick:()=>c("remove"),children:"Remove…"})]})]}),m?e.jsx("p",{className:"error",role:"alert",children:m}):null]})}const YN=t=>(n,a)=>U("GET",`/api/handbook/skill?${new URLSearchParams({source:n,name:a,machine:t})}`).then(l=>l.content);function VN(t,n){return t.filter(a=>a.userId===n).sort((a,l)=>(l.lastSeenAt??"").localeCompare(a.lastSeenAt??""))[0]??null}function QN({me:t}){const[n,a]=h.useState(void 0);return h.useEffect(()=>{ha.list().then(l=>a(VN(l.machines,t)),()=>a(null))},[t]),n?e.jsx(Hx,{machine:{id:n.id,name:n.name},fallback:null}):null}function Hx({fallback:t,machine:n}){const a=n?`?${new URLSearchParams({machine:n.id})}`:"",l=`/api/handbook/sources${a}`,o=Ss(l),[c,d]=h.useState((o==null?void 0:o.sources)??null),[u,m]=h.useState(null),[f,g]=h.useState((o==null?void 0:o.off)??qa),[x,y]=h.useState(!1),[b,N]=h.useState(null),[v,k]=h.useState(null),[S,$]=h.useState(!1),[E,C]=h.useState(null),[R,P]=h.useState(void 0),M=()=>{N(null),y(!0),(n?U("GET",`/api/handbook/sources${a}`):$n.sources()).then(async B=>{if("available"in B&&B.available===!1)return m(B.why);const ne=await $n.defaults().catch(()=>qa),Z=Ir(l,{sources:B.sources,off:ne});g(Z.off),d(Z.sources)},B=>N(B.message)).finally(()=>y(!1))};if(h.useEffect(M,[]),b)return e.jsx(be,{what:"your handbooks",reason:b,onRetry:M});if(u)return n?e.jsx(Xt,{name:"Your handbooks",count:0,why:`Read from ${n.name}.`,empty:`${u}.`}):e.jsx(e.Fragment,{children:t});if(!c)return e.jsx(he,{what:"your handbooks"});const O=B=>{const ne=f;g(B),k(null),U("PUT","/api/handbook/defaults",{off:{skills:B.skills,commands:B.commands,mcpServers:B.mcpServers}}).then(()=>Ir(l,{sources:c,off:B})).catch(Z=>{g(ne),k({tone:"refused",text:Z.message})})},_=B=>{k(B.ok?{tone:"done",text:`Ran ${B.command}.`}:{tone:"refused",text:`Claude Code refused ${B.command}: ${B.why}`}),M()},I=()=>{$(!0),k(null),U("POST","/api/handbook/marketplaces/update").then(_,B=>k({tone:"refused",text:B.message})).finally(()=>$(!1))},L=(B,ne)=>{$(!0),k(null),U("POST",`/api/handbook/plugins/${ne?"enable":"disable"}${a}`,{plugin:B.id}).then(_,Z=>k({tone:"refused",text:Z.message})).finally(()=>$(!1))},K=c.length;return e.jsxs(Xt,{name:"Your handbooks",count:K,hideCount:!0,why:n?`Read from your Claude Code on ${n.name}.`:"Read from your Claude Code on this computer.",empty:"Your Claude Code has nothing of its own yet; a skill, plugin or server you add there shows here.",children:[x?e.jsx(Kg,{what:"your handbooks"}):null,v?e.jsx("p",{className:v.tone==="done"?"muted":"error",role:v.tone==="done"?"status":"alert",children:v.text}):null,e.jsx(zx,{sources:c,look:e.jsx("button",{type:"button",className:"link small",onClick:()=>P({source:c.find(B=>B.notice).id}),children:"Look"}),putAway:B=>U("POST",`/api/handbook/noticed${a}`,{plugin:B.id})}),e.jsx("div",{"aria-busy":S,children:e.jsx(qx,{sources:c,off:f,level:"default",onChange:O,onPlugin:(B,ne)=>void(!S&&L(B,ne)),pluginActions:B=>e.jsx(KN,{source:B,onRan:_,...n?{machine:n}:{}}),...n?{read:YN(n.id)}:{files:{onChanged:M}},look:R})}),n?null:e.jsxs("div",{className:"handbook-add",children:[E===null?e.jsx("button",{type:"button",className:"handbook-add-row",onClick:()=>C("menu"),children:"Add a skill, a command, an MCP server or a plugin"}):null,E===null?e.jsx("button",{type:"button",className:"link small",disabled:S,onClick:I,children:"Check for updates"}):null,E==="menu"?e.jsxs("div",{className:"handbook-add-options",children:[e.jsx("button",{type:"button",className:"secondary",onClick:()=>C("skill"),children:"New skill"}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>C("command"),children:"New command"}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>C("plugin"),children:"Add a plugin"}),e.jsx("button",{type:"button",className:"link muted",onClick:()=>C(null),children:"Cancel"})]}):null,E==="skill"||E==="command"?e.jsx(FN,{kind:E,onDone:B=>{C(null),B&&M()}}):null,E==="plugin"?e.jsx(zN,{onCancel:()=>C(null),onRan:B=>{C(null),_(B)}}):null]})]})}const JN="handbook",XN="teamhandbook",ZN=1500,eS=8;function Gx(t){const[n,a]=h.useState(null);return h.useEffect(()=>{if(!t)return;let l=!0,o;const c=d=>{ge.options().then(u=>{var f;if(!l)return;const m=((f=u.agents.find(g=>g.id==="claude-code"))==null?void 0:f.personal)??null;m?a(m):d>1&&(o=setTimeout(()=>c(d-1),ZN))},()=>{})};return c(eS),()=>{l=!1,clearTimeout(o)}},[t]),n}const tS="orchestrator.handbook-plugin.dismissed";function Kx({me:t,quiet:n=!1}){const[a,l]=h.useState({at:"offer"}),[o,c]=Ps(tS),d=t.mode==="local"&&Me(t),u=Gx(d),m=!!u&&!u.plugins.some(g=>g.name===JN&&g.marketplace===XN);if(!d||!m&&a.at!=="done"||o&&a.at==="offer")return null;const f=()=>{l({at:"busy"}),U("POST","/api/handbook/plugin").then(g=>l(g.installed?{at:"done"}:{at:"failed",why:g.why}),g=>l({at:"failed",why:g.message}))};return e.jsx("div",{className:n?"plugin-card plugin-card-quiet":"plugin-card",role:"status",children:a.at==="done"?e.jsx("p",{children:"The handbook plugin is installed; your next Claude Code session has it."}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Add the handbook plugin to your Claude Code."}),n?null:" It turns what your sessions teach into skills you keep or share."]}),a.at==="asking"||a.at==="busy"?e.jsxs("p",{className:"muted",children:["This adds the TeamHandbook marketplace to your Claude Code and installs the handbook plugin from it, with ",e.jsx("code",{children:"claude plugin marketplace add"})," and ",e.jsx("code",{children:"claude plugin install"}),". Nothing else changes."]}):null,a.at==="failed"?e.jsx("p",{className:"error",role:"alert",children:a.why}):null,e.jsxs("div",{className:"actions",children:[a.at==="offer"||a.at==="failed"?e.jsx("button",{type:"button",className:n?"secondary":void 0,onClick:()=>l({at:"asking"}),children:"Install the plugin…"}):null,a.at==="asking"||a.at==="busy"?e.jsx("button",{type:"button",disabled:a.at==="busy",onClick:f,children:a.at==="busy"?"Installing…":"Install"}):null,e.jsx("button",{type:"button",className:"secondary",disabled:a.at==="busy",onClick:()=>a.at==="offer"?c("yes"):l({at:"offer"}),children:a.at==="offer"?"Not now":"Cancel"})]})]})})}const _f="(max-width: 1023px)";function nS({label:t,onClose:n,children:a}){const[l,o]=h.useState(()=>window.matchMedia(_f).matches),c=h.useRef(null);return h.useEffect(()=>{const d=window.matchMedia(_f),u=()=>o(d.matches);return d.addEventListener("change",u),()=>d.removeEventListener("change",u)},[]),h.useEffect(()=>{l&&c.current&&!c.current.open&&c.current.showModal()},[l]),l?e.jsxs("dialog",{ref:c,className:"side-panel","aria-label":t,onClose:n,children:[e.jsxs("header",{children:[e.jsx("h2",{children:t}),e.jsx("div",{className:"actions",children:e.jsx("button",{type:"button",className:"secondary",onClick:n,children:"Close"})})]}),e.jsx("section",{children:a})]}):e.jsx("aside",{className:"rail","aria-label":t,children:a})}const Wu=(t,n,a="")=>`/api/tasks/${encodeURIComponent(t)}/lessons/${encodeURIComponent(n)}${a}`,Tr={ofTask:t=>U("GET",`/api/tasks/${encodeURIComponent(t)}/lessons`),read:(t,n)=>U("GET",Wu(t,n)).then(a=>a.lesson),keep:(t,n,a="yours")=>U("POST",Wu(t,n,"/keep"),{target:a}),reject:(t,n,a)=>U("POST",Wu(t,n,"/reject"),{never:a}),outcomes:t=>U("GET",`/api/skills/${encodeURIComponent(t)}/outcomes?days=30`)},Ma=(t,n)=>`${t} ${n}${t===1?"":"s"}`;function sS({skills:t,candidates:n},a=!1){var x,y;const l=[t.team.length?Ma(t.team.length,"team skill"):"",t.project.length?Ma(t.project.length,"project skill"):""].filter(Boolean),o=n??[],c=o.filter(b=>b.status==="pending").length,d=o.filter(b=>b.status==="approved").length,u=o.filter(b=>b.status==="sent"),m=[...new Set(u.map(b=>b.machine).filter(b=>!!b))],f=[a?"":l.length?`Started with ${l.join(" and ")}${(x=t.used)!=null&&x.length?`, the agent called ${t.used.length}`:""}`:(y=t.used)!=null&&y.length?`The agent called ${Ma(t.used.length,"skill")}`:"",c?`${Ma(c,"lesson")} ${c===1?"waits":"wait"} for your review`:"",d?`${Ma(d,"lesson")} kept as your skill${d===1?"":"s"}`:"",u.length?`${Ma(u.length,"lesson")} ${u.length===1?"waits":"wait"} in your review queue${m.length===1?` on ${m[0]}`:""}`:""].filter(Boolean);if(!f.length)return null;const g=f.join("; ");return`${g[0].toUpperCase()}${g.slice(1)}.`}const aS=2e4,rS=5*6e4,Yx=t=>t.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n/,""),br=(t,n)=>`${t} of ${n}`;function lS(t){if(!t.pivot)return null;if(t.with.tasks<t.minimum)return{phrase:`${Ma(t.with.tasks,"task")} decided since, compared from ${t.minimum}`,facts:[]};const n=t.before.tasks>=t.minimum,a=(l,o)=>n?`${l}; before, ${o}`:l;return{phrase:`kept without a follow-up in ${br(t.with.acceptedWithoutRevision,t.with.tasks)} tasks since${n?`, ${br(t.before.acceptedWithoutRevision,t.before.tasks)} before`:""}`,facts:[{term:"Kept without a follow-up",value:a(br(t.with.acceptedWithoutRevision,t.with.tasks),br(t.before.acceptedWithoutRevision,t.before.tasks))},{term:"Follow-ups, median",value:a(String(t.with.revisionRoundsMedian??0),String(t.before.revisionRoundsMedian??0))},{term:"Undone or closed",value:a(br(t.with.rejected,t.with.tasks),br(t.before.rejected,t.before.tasks))}]}}function oS({task:t,finishedAt:n,folder:a=null,usedShown:l=!1}){const[o,c]=h.useState(null),[d,u]=h.useState(0),[m,f]=h.useState([]);h.useEffect(()=>{let N=!0;return Tr.ofTask(t).then(v=>N&&c(v),()=>N&&c(null)),()=>{N=!1}},[t,d]);const x=!!n&&Date.now()-Date.parse(n)<rS&&!!(o!=null&&o.candidates)&&o.candidates.length===0;h.useEffect(()=>{if(!x)return;const N=setTimeout(()=>u(v=>v+1),aS);return()=>clearTimeout(N)},[x,d]);const y=o?sS(o,l):null;if(!o||!y)return null;const b=(o.candidates??[]).filter(N=>N.status==="pending"||N.status==="sent"||N.status==="approved");return e.jsxs("section",{"aria-labelledby":"task-learned-h",children:[e.jsx("h2",{id:"task-learned-h",children:"Learned"}),e.jsx("p",{children:y}),b.length?e.jsx("ul",{className:"plain",children:b.map(N=>e.jsx("li",{children:N.status==="approved"?e.jsx(iS,{slug:N.slug,toTeam:m.includes(N.slug)}):e.jsx(cS,{task:t,lesson:N,folder:a,onDecided:v=>{v&&f(k=>[...k,N.slug]),u(k=>k+1)}})},N.slug))}):null]})}function iS({slug:t,toTeam:n}){const[a,l]=h.useState(null);h.useEffect(()=>{let c=!0;return Tr.outcomes(t).then(d=>c&&l(lS(d)),()=>c&&l(null)),()=>{c=!1}},[t]);const o=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mono",children:t})," kept as your skill",a?`; ${a.phrase}`:"",n?e.jsxs(e.Fragment,{children:["; ",e.jsx("a",{href:re("team"),children:"share it with the team on Team"})]}):null]});return a!=null&&a.facts.length?e.jsxs("details",{children:[e.jsx("summary",{children:o}),e.jsx("dl",{children:a.facts.map(c=>e.jsxs(h.Fragment,{children:[e.jsx("dt",{children:c.term}),e.jsx("dd",{children:c.value})]},c.term))})]}):o}function cS({task:t,lesson:n,folder:a,onDecided:l}){const[o,c]=h.useState("yours"),[d,u]=h.useState(null),[m,f]=h.useState(null),[g,x]=h.useState(!1),[y,b]=h.useState(!1),N=()=>{d||(f(null),Tr.read(t,n.slug).then(u,k=>f(k.message)))},v=(k,S=!1)=>{b(!0),f(null),k.then(()=>l(S),$=>f($.message)).finally(()=>b(!1))};return e.jsxs("details",{onToggle:k=>k.currentTarget.open?N():void 0,children:[e.jsx("summary",{dir:"auto",children:n.description??e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mono",children:n.slug}),n.machine?`, on ${n.machine}`:""]})}),d?e.jsxs(e.Fragment,{children:[d.quote?e.jsxs("p",{dir:"auto",children:["You said: “",d.quote,"”"]}):null,e.jsx(Ha,{text:Yx(d.skillMd)}),e.jsxs("div",{className:"segmented",role:"group","aria-label":"Where it lands",children:[e.jsx("button",{type:"button",className:"secondary small","aria-pressed":o==="yours",onClick:()=>c("yours"),children:"Yours"}),a?e.jsxs("button",{type:"button",className:"secondary small","aria-pressed":o==="folder",onClick:()=>c("folder"),children:["This folder (",a,")"]}):null,e.jsx("button",{type:"button",className:"secondary small","aria-pressed":o==="team",onClick:()=>c("team"),children:"The team"})]}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",className:"small",disabled:y,onClick:()=>v(Tr.keep(t,n.slug,o==="folder"?"folder":"yours"),o==="team"),children:"Keep"}),e.jsx("button",{type:"button",className:"secondary small",disabled:y,onClick:()=>v(Tr.reject(t,n.slug,g)),children:"Reject"}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:g,onChange:k=>x(k.target.checked)}),"Never suggest it again"]})]})]}):m?null:e.jsx("p",{className:"muted small",children:"Loading the lesson…"}),m?e.jsx("p",{className:"error",role:"alert",children:m}):null]})}const mi=50,Uf=t=>({slug:t.slug,source:t.origin==="task"?{kind:"task",label:"From a task"}:{kind:"session",label:"From a session"},taskId:t.origin==="task"?t.sessionId:null,createdAt:t.createdAt,firstLine:t.firstLine||t.description||null}),uS=(t,n)=>{const a=new Set(t);return a.delete(n)||a.add(n),a},dS=(t,n)=>new Set(n.filter(a=>t.has(a.slug)).map(a=>a.slug)),Vx=t=>t.filter(n=>n.ok).map(n=>n.slug);function Qx(t){const n=t.filter(a=>!a.ok);return n.length?`${n.length===1?"1 lesson was":`${n.length} lessons were`} not decided: ${n[0].error??"not decided"}`:null}const ma={list:t=>U("GET",`/api/lessons/review?${new URLSearchParams({offset:String(t),limit:String(mi)})}`),read:t=>U("GET",`/api/lessons/review/${encodeURIComponent(t)}`).then(n=>n.lesson),keep:(t,n,a)=>U("POST","/api/lessons/review/keep",{slugs:t,target:n,...a?{message:a}:{}}),reject:(t,n=!1)=>U("POST","/api/lessons/review/reject",{slugs:t,...n?{never:!0}:{}})};function hS(){const[t,n]=h.useState(null),[a,l]=h.useState(null);h.useEffect(()=>{ma.list(0).then(d=>{n(d.items.map(Uf)),l(d.total)},()=>n(null))},[]);const o=()=>ma.list((t==null?void 0:t.length)??0).then(d=>{n(u=>[...u??[],...d.items.map(Uf)]),l(d.total)}),c=({results:d,waiting:u})=>{const m=new Set(Vx(d));n(f=>f&&f.filter(g=>!m.has(g.slug))),l(u)};return{rows:t,waiting:a,hasMore:t!==null&&a!==null&&t.length<a,more:o,settled:c}}const Jx=[{value:"yours",label:"Yours"},{value:"folder",label:"This folder"},{value:"team",label:"Team"}],Xx=t=>t.slice(0,10);function mS({review:t,picked:n,onPick:a}){const{rows:l,waiting:o,hasMore:c,more:d,settled:u}=t,[m,f]=h.useState(mi),[g,x]=h.useState(new Set),[y,b]=h.useState("yours"),[N,v]=h.useState(!1),[k,S]=h.useState(null),[$,E]=h.useState(null);if(h.useEffect(()=>{l&&x(O=>dS(O,l))},[l]),!l||!l.length)return null;const C=O=>{u(O),S(Qx(O.results));const _=O.results.find(I=>!I.ok&&I.proposedMessage);E(_?{slugs:O.results.filter(I=>!I.ok&&I.proposedMessage).map(I=>I.slug),message:_.proposedMessage}:null)},R=O=>{v(!0),S(null),E(null),O.then(C,_=>S(_.message)).finally(()=>v(!1))},P=l.slice(0,m),M=l.length-P.length;return e.jsxs(Xt,{name:"Lessons to review",count:o??l.length,why:"What a task or a session taught, offered as a skill; keep it and every later task loads it.",empty:"No lesson waits. A task you correct or finish leaves its lesson here.",children:[g.size?e.jsxs("div",{className:"lessons-bulk",role:"group","aria-label":"Decide the picked lessons",children:[e.jsxs("span",{children:[g.size," picked"]}),e.jsx(Pe,{label:"Keep in",labelHidden:!0,value:y,onChange:O=>b(O),options:Jx,disabled:N}),e.jsx("button",{type:"button",disabled:N,onClick:()=>R(ma.keep([...g],y)),children:"Keep"}),e.jsx("button",{type:"button",className:"secondary",disabled:N,onClick:()=>R(ma.reject([...g])),children:"Reject"}),e.jsx("button",{type:"button",className:"link",disabled:N,onClick:()=>x(new Set),children:"Clear"})]}):null,k?e.jsx("p",{className:"error",role:"alert",children:k}):null,$?e.jsxs("div",{className:"lessons-bulk",role:"group","aria-label":"Commit wording for the team",children:[e.jsxs("label",{children:["Commit message ",e.jsx("input",{type:"text",value:$.message,onChange:O=>E({...$,message:O.target.value})})]}),e.jsx("button",{type:"button",disabled:N||!$.message.trim(),onClick:()=>R(ma.keep($.slugs,"team",$.message.trim())),children:"Keep for the team"})]}):null,e.jsx("ul",{className:"team-rows lessons-rows",children:P.map(O=>e.jsxs("li",{className:O.slug===n?"picked":void 0,children:[e.jsx("input",{type:"checkbox","aria-label":`Pick ${O.slug}`,checked:g.has(O.slug),onChange:()=>x(uS(g,O.slug))}),e.jsxs("div",{className:"lesson-text",children:[e.jsx("button",{type:"button",className:"row-pick","aria-pressed":O.slug===n,onClick:()=>a(O),dir:"auto",children:O.firstLine??O.slug}),e.jsxs("p",{className:"muted small",children:[O.taskId?e.jsx("a",{href:re("tasks",O.taskId),children:O.source.label}):O.source.label,", ",Xx(O.createdAt)]})]})]},O.slug))}),M>0||c?e.jsx("p",{children:e.jsxs("button",{type:"button",className:"link small",disabled:N,onClick:()=>M>0?f(m+mi):d().then(()=>f(m+mi),O=>S(O.message)),children:["Show more",o!==null?` (${o-P.length})`:""]})}):null]})}function pS({row:t,onDecided:n}){const[a,l]=h.useState(null),[o,c]=h.useState(null),[d,u]=h.useState(!1),[m,f]=h.useState("yours"),[g,x]=h.useState(!1);h.useEffect(()=>{l(null),c(null),ma.read(t.slug).then(l,b=>c(b.message))},[t.slug]);const y=b=>{x(!0),c(null),b.then(N=>Vx(N.results).length?n(N):c(Qx(N.results)),N=>c(N.message)).finally(()=>x(!1))};return e.jsxs("section",{"aria-labelledby":"lesson-h",children:[e.jsx("h2",{id:"lesson-h",dir:"auto",children:t.firstLine??t.slug}),e.jsxs("p",{className:"muted small",children:[t.taskId?e.jsx("a",{href:re("tasks",t.taskId),children:t.source.label}):t.source.label,", ",Xx(t.createdAt)]}),o?e.jsx("p",{className:"error",role:"alert",children:o}):null,a?e.jsxs(e.Fragment,{children:[a.quote?e.jsxs("p",{dir:"auto",children:["You said: “",a.quote,"”"]}):null,e.jsx(Ha,{text:Yx(a.skillMd)}),e.jsxs("div",{className:"actions",children:[e.jsx(Pe,{label:"Keep in",value:m,onChange:b=>f(b),options:Jx,disabled:g}),e.jsx("button",{type:"button",className:"secondary",disabled:g,onClick:()=>y(ma.keep([t.slug],m)),children:"Keep"}),e.jsx("button",{type:"button",className:"secondary",disabled:g,onClick:()=>y(ma.reject([t.slug],d)),children:"Reject"})]}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:d,onChange:b=>u(b.target.checked)})," Never suggest it again"]})]}):o?null:e.jsx(he,{what:"the lesson"})]})}function Er({label:t,values:n,onChange:a,choices:l=[],free:o=!0,placeholder:c,show:d=u=>{var m;return((m=l.find(f=>f.id===u))==null?void 0:m.label)??u}}){const u=h.useId(),[m,f]=h.useState(""),[g,x]=h.useState(null),y=()=>{const b=m.trim();if(!b)return;const N=l.find(k=>k.id===b||k.label.toLowerCase()===b.toLowerCase());if(!N&&!o){x(`${b} is not one of the choices.`);return}const v=(N==null?void 0:N.id)??b;n.includes(v)||a([...n,v]),f(""),x(null)};return e.jsxs("div",{className:"chip-field",children:[e.jsx("label",{htmlFor:`${u}-in`,children:t}),n.length?e.jsx("ul",{className:"chips","aria-label":t,children:n.map(b=>e.jsxs("li",{className:"chip",children:[e.jsx("span",{children:d(b)}),e.jsx("button",{type:"button",className:"chip-remove","aria-label":`Remove ${d(b)}`,onClick:()=>a(n.filter(N=>N!==b)),children:"×"})]},b))}):null,e.jsxs("div",{className:"chip-add",children:[e.jsx("input",{id:`${u}-in`,value:m,list:l.length?`${u}-list`:void 0,placeholder:c,"aria-describedby":g?`${u}-problem`:void 0,onChange:b=>f(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),y())}}),e.jsx("button",{type:"button",className:"secondary small",onClick:y,disabled:!m.trim(),children:"Add"})]}),l.length?e.jsx("datalist",{id:`${u}-list`,children:l.filter(b=>!n.includes(b.id)).map(b=>e.jsx("option",{value:b.id,children:b.label},b.id))}):null,g?e.jsx("p",{id:`${u}-problem`,className:"error",children:g}):null]})}function fS(t,n){var l,o;const a=[];for(const c of n.repos){const d=t.repos.find(u=>u.repoId===c.repoId);for(const u of c.skills)u.removedBy&&!((l=d==null?void 0:d.skills.find(m=>m.slug===u.slug))!=null&&l.removedBy)&&a.push({what:`The skill ${u.slug} in ${c.name}`,reason:u.removedBy.reason});for(const u of c.mcpServers){const m=d==null?void 0:d.mcpServers.find(f=>f.name===u.name);u.removedBy&&!(m!=null&&m.removedBy)&&a.push({what:`The MCP server ${u.name} in ${c.name}`,reason:u.removedBy.reason});for(const f of u.tools)m!=null&&m.tools.some(g=>g.resource===f.resource)||a.push({what:`The tool ${f.tool} on ${u.name} in ${c.name}`,reason:f.reason})}for(const u of c.tools)d!=null&&d.tools.some(m=>m.resource===u.resource)||a.push({what:`${u.resource.replace(/^tool:/,"")} in ${c.name}`,reason:u.reason})}for(const c of n.tasks)c.refusal&&!((o=t.tasks.find(d=>d.repoId===c.repoId))!=null&&o.refusal)&&a.push({what:`Starting a task on ${c.name}`,reason:c.refusal});return a}function ei({reason:t}){return e.jsxs("span",{className:"held",children:[" Blocked: ",t]})}function gS({repo:t}){return e.jsxs("section",{className:"reach","aria-labelledby":`reach-${t.repoId}`,children:[e.jsxs("h3",{id:`reach-${t.repoId}`,children:[e.jsx("a",{href:re("repositories",t.repoId),children:t.name})," ",e.jsx("span",{className:"count",children:t.team})]}),t.problem?e.jsxs("p",{className:"error",children:["The team's rules here do not read: ",t.problem]}):null,e.jsxs("p",{className:"field-label",children:["Skills ",e.jsx("span",{className:"count",children:t.skills.length})]}),t.skills.length?e.jsx("ul",{className:"plain",children:t.skills.map(n=>e.jsxs("li",{children:[e.jsx("span",{className:"mono",children:n.slug}),n.removedBy?e.jsx(ei,{reason:n.removedBy.reason}):null]},n.slug))}):e.jsx("p",{className:"muted",children:"None."}),e.jsxs("p",{className:"field-label",children:["MCP servers ",e.jsx("span",{className:"count",children:t.mcpServers.length})]}),t.mcpServers.length?e.jsx("ul",{className:"plain",children:t.mcpServers.map(n=>e.jsxs("li",{children:[e.jsx("span",{className:"mono",children:n.name}),n.removedBy?e.jsx(ei,{reason:n.removedBy.reason}):null,n.tools.length?e.jsx("ul",{className:"plain nested",children:n.tools.map(a=>e.jsxs("li",{children:["tool ",e.jsx("span",{className:"mono",children:a.tool}),e.jsx(ei,{reason:a.reason})]},a.resource))}):null]},n.name))}):e.jsx("p",{className:"muted",children:"None."}),e.jsxs("p",{className:"field-label",children:["Commands ",e.jsx("span",{className:"count",children:t.commands.length})]}),t.commands.length?e.jsx("p",{className:"mono",children:t.commands.map(n=>`/${n}`).join(" ")}):e.jsx("p",{className:"muted",children:"None."}),t.tools.length?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"field-label",children:"Claude Code tools held back"}),e.jsx("ul",{className:"plain",children:t.tools.map(n=>e.jsxs("li",{children:[e.jsx("span",{className:"mono",children:n.resource.replace(/^tool:/,"")}),e.jsx(ei,{reason:n.reason})]},n.resource))})]}):null]})}function xS({id:t}){const[n,a]=h.useState(null),[l,o]=h.useState(null),[c,d]=h.useState(0);h.useEffect(()=>{let m=!0;return a(null),o(null),gx.get(t).then(f=>m&&a(f),f=>m&&o(f.message)),()=>{m=!1}},[t,c]);const u=(n==null?void 0:n.tasks.filter(m=>m.refusal))??[];return e.jsxs("section",{className:"panel member-config","aria-labelledby":"member-config-h","aria-busy":!n&&!l,children:[e.jsx("h2",{id:"member-config-h",children:"What reaches their sessions"}),l?e.jsxs("div",{role:"alert",children:[e.jsxs("p",{className:"error",children:["Couldn't load this member's configuration. ",l]}),e.jsx("button",{type:"button",className:"secondary small",onClick:()=>d(m=>m+1),children:"Retry"})]}):null,!n&&!l?e.jsx("p",{className:"muted",children:"Reading their teams' repositories…"}):null,n?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"muted",children:n.teams.length?`Through ${n.teams.join(", ")}: what each team repository gives their Claude Code, and what the team's rules take away.`:"Not on a team, so no team repository reaches their sessions."}),n.repos.map(m=>e.jsx(gS,{repo:m},m.repoId)),e.jsx("h3",{children:"Starting tasks"}),u.length?e.jsx("ul",{className:"plain",children:u.map(m=>e.jsxs("li",{children:[e.jsx("strong",{children:m.name}),": ",m.refusal]},m.repoId))}):e.jsx("p",{className:"muted",children:"No orchestrator rule keeps them from starting a task."})]}):null]})}function jS({members:t,audience:n,rules:a,ready:l}){var x;h.useId();const[o,c]=h.useState(""),[d,u]=h.useState(null),m=l&&o?JSON.stringify({member:o,audience:n,rules:a}):null;if(h.useEffect(()=>{if(!m)return;let y=!0;const b=setTimeout(()=>{gx.preview(o,n,a).then(N=>y&&u({key:m,effects:fS(N.before,N.after),error:null}),N=>y&&u({key:m,effects:null,error:N.message}))},350);return()=>{y=!1,clearTimeout(b)}},[m]),!t.length)return null;const f=((x=t.find(y=>y.id===o))==null?void 0:x.label)??"",g=d&&d.key===m?d:null;return e.jsxs("div",{className:"member-preview",children:[e.jsxs("div",{className:"member-pick",children:[e.jsx(Pe,{label:"Preview for a member",value:o,onChange:c,options:[{value:"",label:"Choose a member"},...t.map(y=>({value:y.id,label:y.label}))]}),o?e.jsx("button",{type:"button",className:"secondary small",onClick:()=>c(""),children:"Close member preview"}):null]}),o?null:e.jsx("p",{className:"muted small-print",children:"Choose members to preview this policy."}),o&&!l?e.jsxs("p",{className:"muted small-print",children:["Complete this policy to preview it for ",f,"."]}):null,o&&l?e.jsxs("div",{role:"status","aria-live":"polite",children:[g!=null&&g.error?e.jsxs("p",{className:"error",children:["Couldn't preview this policy for ",f,". ",g.error]}):null,g?null:e.jsxs("p",{className:"muted small-print",children:["Reading what reaches ",f,"…"]}),g!=null&&g.effects?g.effects.length?e.jsx("ul",{className:"plain",children:g.effects.map(y=>e.jsxs("li",{children:[e.jsx("strong",{children:y.what}),e.jsxs("span",{className:"held",children:[" · ",y.reason]})]},y.what))}):e.jsxs("p",{className:"muted",children:["This policy takes nothing from ",f,"."]}):null]}):null]})}const Df=12;function Zx(t,n,a){return`${t.toLocaleString("en-US")} ${t===1?n:a}`}function Bf({title:t,people:n}){if(!n.length)return null;const a=n.length-Df;return e.jsxs("div",{children:[e.jsx("p",{className:"field-label",children:t}),e.jsx("ul",{className:"chips",children:n.slice(0,Df).map(l=>e.jsx("li",{className:"chip chip-plain",children:l.name},l.id))}),a>0?e.jsxs("p",{className:"muted small-print",children:["and ",Zx(a,"more","more")]}):null]})}function yS({draft:t,repoName:n,members:a,exportable:l}){const o=yx(t),c=o?null:JSON.stringify({audience:t.audience,rules:t.rules}),[d,u]=h.useState(null),[m,f]=h.useState(0);h.useEffect(()=>{if(!c)return;let y=!0;const b=setTimeout(()=>{hn.preview(t.audience,t.rules).then(N=>y&&u({key:c,preview:N,error:null}),N=>y&&u({key:c,preview:null,error:N.message}))},350);return()=>{y=!1,clearTimeout(b)}},[c,m]);const g=Rn(t),x=d&&d.key===c?d:null;return e.jsxs("section",{className:"panel preview","aria-labelledby":"preview-h","aria-busy":c!==null&&!x,children:[e.jsxs("h2",{id:"preview-h",children:["Preview ",e.jsx("span",{className:"count",children:"who this covers and what they ran"})]}),o?e.jsx("p",{className:"muted",children:(t.audience.kind==="tags"||t.audience.kind==="except-tags")&&!t.audience.ids.length?"Add a tag to see who this applies to.":"Choose who this applies to and add a rule to preview it."}):x!=null&&x.error?e.jsxs("div",{role:"alert",children:[e.jsxs("p",{className:"error",children:["Couldn't preview this policy. ",x.error]}),e.jsx("button",{type:"button",className:"secondary small",onClick:()=>{u(null),f(y=>y+1)},children:"Retry the preview"})]}):x!=null&&x.preview?e.jsx(kS,{preview:x.preview,request:g,repoName:n,exportable:l}):e.jsx("p",{className:"muted",children:"Working out who this covers…"}),e.jsx(jS,{members:a,audience:t.audience,rules:t.rules,ready:!o})]})}const ej="Where an organization allows only managed hooks, policies reach teammates through the managed-settings export.";function vS({exportable:t,repos:n=[]}){return t?e.jsxs("p",{className:"muted small-print managed-hooks",children:[(n.length?n:[null]).map((a,l)=>e.jsxs("span",{children:[l?", ":"",e.jsx("a",{href:`/api/policies/export?${a?`repo=${encodeURIComponent(a.id)}&`:""}download=1`,download:!0,children:a?`Export the saved policies for ${a.name}`:"Export the saved policies"})]},(a==null?void 0:a.id)??"workspace"))," ",e.jsx(Ie,{label:"the managed-settings export",children:ej})]}):null}function kS({preview:t,request:n,repoName:a,exportable:l}){const o=t.members.filter(g=>!pf(g.id)),c=t.members.filter(g=>pf(g.id)),{tasks:d,usd:u,unknownCost:m}=t.usage30d,f=t.repos.map(a);return e.jsxs("div",{className:"preview-body",children:[e.jsxs("dl",{className:"facts",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Members"}),e.jsx("dd",{children:o.length.toLocaleString("en-US")})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Teams"}),e.jsx("dd",{children:t.teams.length.toLocaleString("en-US")})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Service accounts"}),e.jsx("dd",{children:c.length.toLocaleString("en-US")})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Tasks, last 30 days"}),e.jsxs("dd",{children:[d.toLocaleString("en-US"),u===null?"":` · $${u.toLocaleString("en-US",{maximumFractionDigits:2})}`]})]})]}),m?e.jsxs("p",{className:"muted small-print",children:[Zx(m,"task","tasks")," reported no cost and ",m===1?"is":"are"," not in the total."]}):null,t.members.length?null:e.jsx("p",{className:"muted",children:"Nobody is covered yet."}),e.jsx(Bf,{title:"Members",people:o}),e.jsx(Bf,{title:"Service accounts",people:c}),t.teams.length?e.jsxs("p",{children:[e.jsx("span",{className:"field-label",children:"Teams"}),e.jsx("br",{}),En(t.teams)]}):null,n?e.jsxs("div",{className:"applies applies-request",children:[e.jsx("p",{children:e.jsx("strong",{children:"Saved as a request; reaches teammates when merged."})}),e.jsx("p",{className:"muted",children:f.length?`Saving opens a request on ${En(f)}.`:"No covered team has a connected repository."}),e.jsx(vS,{exportable:l,repos:t.repos.map(g=>({id:g,name:a(g)}))})]}):e.jsxs("div",{className:"applies applies-now",children:[e.jsx("p",{children:e.jsx("strong",{children:"Applies now."})}),e.jsx("p",{className:"muted",children:f.length?`Holds tasks this orchestrator starts on ${En(f)}, from the moment you save.`:"Holds the tasks this orchestrator starts, from the moment you save. Nothing changes on teammates' machines."})]})]})}const bS={"skill-access":"skill:","mcp-access":"mcp:","tool-access":"tool:"};function wS({rule:t,onChange:n}){const a=h.useId(),[l,o]=h.useState(xf[0]),[c,d]=h.useState(""),u=()=>{const m=ch("tool-access",`${l}:${c.trim()||"*"}`);t.resources.includes(m)||n({...t,resources:[...t.resources,m]}),d("")};return e.jsxs("div",{className:"chip-field",children:[e.jsx("span",{className:"field-label",id:`${a}-l`,children:"Tools and what they are held to"}),t.resources.length?e.jsx("ul",{className:"chips","aria-labelledby":`${a}-l`,children:t.resources.map(m=>e.jsxs("li",{className:"chip",children:[e.jsx("span",{children:wd(m)}),e.jsx("button",{type:"button",className:"chip-remove","aria-label":`Remove ${wd(m)}`,onClick:()=>n({...t,resources:t.resources.filter(f=>f!==m)}),children:"×"})]},m))}):null,e.jsxs("div",{className:"chip-add",children:[e.jsx(Pe,{label:"Tool",labelHidden:!0,value:l,onChange:o,options:xf.map(m=>({value:m,label:m}))}),e.jsx("label",{className:"visually-hidden",htmlFor:`${a}-pattern`,children:"Pattern"}),e.jsx("input",{id:`${a}-pattern`,value:c,placeholder:l==="Bash"?"rm *":l==="WebFetch"?"https://example.com/*":"*.env",onChange:m=>d(m.target.value),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),u())}}),e.jsx("button",{type:"button",className:"secondary small",onClick:u,children:"Add"})]}),e.jsxs("p",{className:"muted small-print",children:["An empty pattern blocks the whole tool. ",e.jsx(Ie,{label:"tool patterns",children:"Edit covers every tool that changes a file."})]})]})}function NS({rule:t,onChange:n}){const a=h.useId(),l=bS[t.kind];return e.jsxs(e.Fragment,{children:[t.kind==="tool-access"?e.jsx(wS,{rule:t,onChange:n}):e.jsx(Er,{label:t.kind==="skill-access"?"Skills to block":"MCP servers to block",placeholder:t.kind==="skill-access"?"deploy-checklist":"server or server/tool",values:t.resources.map(o=>o.slice(l.length)),onChange:o=>n({...t,resources:o.map(c=>ch(t.kind,c))})}),e.jsxs("div",{className:"field",children:[e.jsx("label",{htmlFor:`${a}-reason`,children:"Reason teammates see"}),e.jsx("input",{id:`${a}-reason`,value:t.reason,maxLength:vd,placeholder:"Say why, in a sentence",onChange:o=>n({...t,reason:o.target.value})})]})]})}function SS({rule:t,index:n,onChange:a,onRemove:l,repos:o}){var u;const c=h.useId(),d=((u=Nd.find(m=>m.kind===t.kind))==null?void 0:u.label)??t.kind;return e.jsxs("section",{className:"panel rule-block","aria-labelledby":`${c}-h`,children:[e.jsxs("h2",{id:`${c}-h`,children:[d," ",e.jsxs("span",{className:"count",children:["rule ",n+1]}),e.jsx("button",{type:"button",className:"secondary small","aria-label":`Remove the ${d} rule`,onClick:l,children:"Remove"})]}),t.kind==="task-budget"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{htmlFor:`${c}-usd`,children:"Monthly limit in US dollars"}),e.jsx("input",{id:`${c}-usd`,type:"number",inputMode:"decimal",min:.01,max:kd,step:"any",value:t.monthlyUsd??"",onChange:m=>a({...t,monthlyUsd:m.target.value===""?null:Number(m.target.value)})})]}),e.jsxs("fieldset",{className:"plain-fieldset choice-row",children:[e.jsx("legend",{children:"The limit is"}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"radio",name:`${c}-per`,checked:t.per==="audience",onChange:()=>a({...t,per:"audience"})})," shared by everyone it applies to"]}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"radio",name:`${c}-per`,checked:t.per==="member",onChange:()=>a({...t,per:"member"})})," for each member"]})]}),e.jsxs("p",{className:"muted small-print",children:["Counts what agents report for tasks this calendar month (UTC). ",e.jsx(Ie,{label:"task budgets",children:"A task that reports no cost is not counted."})]})]}):t.kind==="repo-access"?e.jsxs(e.Fragment,{children:[e.jsxs("fieldset",{className:"plain-fieldset choice-row",children:[e.jsx("legend",{children:"Tasks on these repositories are"}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"radio",name:`${c}-effect`,checked:t.effect==="allow",onChange:()=>a({...t,effect:"allow"})})," allowed"]}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"radio",name:`${c}-effect`,checked:t.effect==="deny",onChange:()=>a({...t,effect:"deny"})})," blocked"]})]}),e.jsx(Er,{label:"Repositories",placeholder:"repository id, or * for every one",values:t.repos,choices:o,onChange:m=>a({...t,repos:m})}),e.jsx("p",{className:"muted small-print",children:"The last rule that matches decides; a repository no rule names stays open."})]}):t.kind==="task-mode"?e.jsxs(e.Fragment,{children:[e.jsx(Pe,{label:"Agents work at most in",value:t.ceiling,onChange:m=>a({...t,ceiling:m}),options:xx.map(m=>({value:m,label:`${jd[m]}: ${qb[m]}`}))}),e.jsx(Er,{label:"Repositories",placeholder:"repository id, or * for every one",values:t.repos,choices:o,onChange:m=>a({...t,repos:m})}),e.jsx("p",{className:"muted small-print",children:ff(t.ceiling)<ff(Wb)?`A task that names no mode starts in the most its agent offers up to ${jd[t.ceiling]}, and asks its starter before anything more; one asking for more is refused, and an agent that runs in no mode this low takes no task here.`:"A task asking for more is refused, both when it starts and again before its agent runs; a task can always ask for less. The lowest ceiling that covers a task holds."})]}):t.kind==="own-setup"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:t.allowed,onChange:m=>a({...t,allowed:m.target.checked})})," Tasks use the starter's own Claude Code setup"]}),e.jsx(Er,{label:"Repositories",placeholder:"repository id, or * for every one",values:t.repos,choices:o,onChange:m=>a({...t,repos:m})}),e.jsx("p",{className:"muted small-print",children:t.allowed?"A task on a person's machine runs with their memory, CLAUDE.md, skills, plugins, MCP servers and hooks, and the team's skills on top.":"A task on a person's machine runs with their sign-in and the team's skills only."})]}):e.jsx(NS,{rule:t,onChange:a})]})}const CS={workspace:"Everyone in the organization",teams:"Members of teams",members:"These members","except-members":"Everyone except these members",tags:"Members tagged","except-tags":"Everyone except those tagged","service-accounts":"These service accounts"};function $S({audience:t,rules:n,sources:a,onChange:l}){h.useId();const o=yf(t.kind,n),c=t.kind==="teams"?a.teams:t.kind==="members"||t.kind==="except-members"?a.members:[];return e.jsxs("fieldset",{className:"plain-fieldset",children:[e.jsx("legend",{className:"field-label",children:"Applies to"}),e.jsx(Pe,{label:"Who this policy applies to",labelHidden:!0,value:t.kind,onChange:d=>{const u=d;l(u==="workspace"?{kind:u}:{kind:u,ids:[]})},options:zb.map(d=>({value:d,label:CS[d],disabled:d!==t.kind&&yf(d,n)!==null}))}),Rn({rules:n})?e.jsx("p",{className:"muted small-print",children:"Blocking rules reach teammates' sessions, which apply to whole teams, so only the organization or teams fit."}):null,o?e.jsx("p",{className:"error",children:o}):null,t.kind==="tags"||t.kind==="except-tags"?e.jsx(TS,{tags:a.tags,ids:t.ids,onChange:d=>l({kind:t.kind,ids:d})}):t.kind==="workspace"?null:e.jsx(Er,{label:t.kind==="teams"?"Teams":t.kind==="service-accounts"?"Service accounts":"Members",placeholder:t.kind==="service-accounts"?"service account id":t.kind==="teams"?"team":"name or email",values:t.ids,choices:c,free:t.kind!=="teams",onChange:d=>l({kind:t.kind,ids:d})})]})}function TS({tags:t,ids:n,onChange:a}){return t===null?e.jsx("p",{className:"muted",children:"Only an owner or an admin sees members' tags."}):!t.length&&!n.length?e.jsxs("p",{className:"muted",children:["No member has a tag yet; add one on a member's page in ",e.jsx("a",{href:re("settings","members"),children:"Settings"}),"."]}):e.jsx(Er,{label:"Tags",placeholder:"pick a tag",values:n,choices:t,free:!1,show:l=>l,onChange:a})}function ES({rules:t,me:n,orchestratorRulesStored:a,onAdd:l}){const c=(n.mode==="local"?Nd.filter(u=>!Ml(u.kind)):Nd).map(u=>({...u,refusal:ew(u.kind,{rules:t,isAdmin:As(n),orchestratorRulesStored:a})})),d=[...new Set(c.flatMap(u=>u.refusal?[u.refusal]:[]))];return e.jsxs("nav",{className:"panel add-blocks","aria-labelledby":"add-blocks-h",children:[e.jsx("h2",{id:"add-blocks-h",children:"Add a rule"}),e.jsx("ul",{className:"plain",children:c.map(u=>{const m=`add-${u.kind}-hint`;return e.jsxs("li",{children:[e.jsxs("button",{type:"button",className:"block-button",disabled:u.refusal!==null,"aria-describedby":m,onClick:()=>l(tw(u.kind)),children:[e.jsx("span",{"aria-hidden":"true",children:"+ "}),u.label]}),e.jsx("p",{id:m,className:u.refusal?"visually-hidden":"muted small-print",children:u.refusal??u.hint})]},u.kind)})}),d.map(u=>e.jsx("p",{className:"muted small-print locked-blocks","aria-hidden":"true",children:u},u))]})}function RS({me:t,initial:n,existing:a,sources:l,back:o,repoName:c}){const[d,u]=h.useState(n),[m,f]=h.useState(()=>n.rules.map((I,L)=>L)),g=h.useRef(n.rules.length),[x,y]=h.useState({at:"edit"}),[b,N]=h.useState(!1),[v,k]=h.useState(null),S=(a==null?void 0:a.id)??null,$=I=>{var L,K;return((L=l.teams.find(B=>B.id===I))==null?void 0:L.label)??((K=l.members.find(B=>B.id===I))==null?void 0:K.label)??I},E=Jb(d),C=(I,L)=>u({...d,rules:d.rules.map((K,B)=>B===I?L:K)}),R=I=>{I.saved==="request"?y({at:"opened",saved:I}):Ge(o)},P=async I=>{N(!0),k(null),await I().catch(L=>k(L.message)),N(!1)},M=()=>P(async()=>{if(!Rn(d))return R(await hn.save(S,d));const I=await hn.proposal(S,d);if(I.applies==="now")return R(await hn.save(S,d));y({at:"confirm",plan:I,removing:!1})}),O=()=>P(async()=>{if(!S)return;const I=await hn.proposal(S,null);if(I.applies==="now")return R(await hn.remove(S));y({at:"confirm",plan:I,removing:!0})}),_=async I=>{x.at==="confirm"&&R(x.removing&&S?await hn.remove(S,I):await hn.save(S,d,I))};return x.at==="opened"?e.jsx(bx,{saved:x.saved,repoName:c,back:o}):x.at==="confirm"?e.jsx(kx,{plan:x.plan,action:x.removing?"Remove this policy":"Save this policy",onConfirm:_,onCancel:()=>y({at:"edit"})}):e.jsxs("div",{className:"policy-editor",children:[e.jsx("p",{className:"policy-summary",role:"status","aria-live":"polite",children:uh(d,$)}),e.jsxs("div",{className:"policy-columns",children:[e.jsxs("section",{className:"panel form policy-form","aria-label":"Policy",children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{htmlFor:"policy-name",children:"Name"}),e.jsx("input",{id:"policy-name",value:d.name,maxLength:yd,onChange:I=>u({...d,name:I.target.value})})]}),e.jsx($S,{audience:d.audience,rules:d.rules,sources:l,onChange:I=>u({...d,audience:I})})]}),e.jsx("div",{className:"policy-rules",children:d.rules.length?d.rules.map((I,L)=>e.jsx(SS,{rule:I,index:L,repos:l.repos,onChange:K=>C(L,K),onRemove:()=>{u({...d,rules:d.rules.filter((K,B)=>B!==L)}),f(m.filter((K,B)=>B!==L))}},m[L])):e.jsx("div",{className:"panel",children:e.jsx("p",{className:"muted",children:"No rules yet."})})}),e.jsx(ES,{rules:d.rules,me:t,orchestratorRulesStored:l.orchestratorRulesStored,onAdd:I=>{u({...d,rules:[...d.rules,I]}),f([...m,g.current++])}}),e.jsx(yS,{draft:d,repoName:c,members:l.members,exportable:As(t)}),e.jsxs("section",{className:"panel save-bar","aria-label":"Save",children:[e.jsx("p",{className:"muted",children:Xb(d)}),E?e.jsx("p",{id:"locked-reason",className:"locked",children:E}):null,v?e.jsx("p",{className:"error",role:"alert",children:v}):null,e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",onClick:M,disabled:b||E!==null,"aria-describedby":E?"locked-reason":void 0,children:b?"Saving…":"Save policy"}),e.jsx("a",{className:"button secondary",href:o,children:"Cancel"}),a&&Rn(a)?e.jsx("button",{type:"button",className:"secondary danger",onClick:O,disabled:b,children:"Delete this policy"}):null,a&&!Rn(a)?e.jsx(qe,{trigger:"Delete this policy",consequence:Zb(a),confirm:"Delete policy",keep:"Keep policy",onConfirm:()=>hn.remove(a.id).then(()=>Ge(o))}):null]})]})]})]})}function tj(t,n){return As(t)?{teams:n.teams.map(a=>a.team),everyone:!0}:{teams:[...t.ownedTeams],everyone:!1}}const nj=t=>As(t)||t.ownedTeams.length>0;function sj(t){const[n,a]=h.useState(null),[l,o]=h.useState(null),c=()=>{o(null);const d=As(t)?pn.users().catch(()=>[]):Promise.resolve([]),u=As(t)?_b.catalog().catch(()=>null):Promise.resolve(null);Promise.all([hn.list(),pn.teams(),Ce.repos(),d,u]).then(([m,f,g,x,y])=>a({list:m,teams:f,repos:g,users:x,tags:y}),m=>o(m.message))};return h.useEffect(c,[t.id]),{data:n,error:l,reload:c}}function PS({templates:t,reach:n,blank:a}){const l=t.some(o=>!Rn(o.draft(n)));return e.jsx(Xt,{name:"Control templates",count:t.length,why:e.jsxs(e.Fragment,{children:["Start from one; each opens as a draft",a?e.jsxs(e.Fragment,{children:[", or ",a]}):null,". ",e.jsxs(Ie,{label:"templates",children:[n.everyone?"Four templates cover":"These templates cover"," what teams most often hold to a rule. A rule saved as a request reaches teammates once a reviewer merges it on the team repository",l?"; one that applies now holds this orchestrator's tasks from the moment it is saved":"",".",n.everyone?"":" Monthly task budgets and where tasks run are rules on this orchestrator's own tasks; an owner or admin sets these."," ",ej,n.everyone?e.jsxs(e.Fragment,{children:[" ",e.jsx("a",{href:"/api/policies/export?download=1",download:!0,children:"Export the saved policies"})]}):null]})]}),empty:"",children:e.jsx("ul",{className:"team-rows",children:t.map(o=>e.jsx("li",{children:e.jsxs("a",{className:"template",href:`${re("team","policies","new")}?template=${o.id}`,children:[e.jsx("span",{className:"template-name",children:o.name})," ",e.jsxs("span",{className:"muted",children:[o.description," ",Rn(o.draft(n))?"Saved as a request.":"Applies now."]})]})},o.id))})})}function AS({policy:t,names:n}){const a=Rn(t);return e.jsxs("li",{className:"policy-row",children:[e.jsxs("div",{children:[e.jsx("p",{className:"policy-name",children:e.jsx("a",{href:re("team","policies",t.id),children:t.name})}),e.jsx("p",{className:"muted",children:uh(t,n)})]}),e.jsxs("div",{className:"policy-facts",children:[e.jsx("span",{className:`badge ${a?"badge-request":"badge-now"}`,children:a?"Reaches teammates through the team file":"Applies to orchestrator tasks"}),t.updatedBy?e.jsxs("span",{className:"muted small-print",children:["Changed by ",t.updatedBy,t.updatedAt?` on ${t.updatedAt.slice(0,10)}`:""]}):null]})]})}function IS({me:t}){const{data:n,error:a,reload:l}=sj(t);if(!nj(t))return null;if(a&&!n)return e.jsx(be,{what:"policies",reason:a,onRetry:l});if(!n)return e.jsx(he,{what:"policies"});const o=Pd(n),{policies:c,problems:d}=n.list,u=e.jsx("a",{href:re("team","policies","new"),children:"Add policy"});return e.jsxs(e.Fragment,{children:[d.length?e.jsxs("section",{role:"alert","aria-labelledby":"policy-problems-h",children:[e.jsx("h2",{id:"policy-problems-h",children:"Team files with policies the orchestrator cannot read"}),e.jsx("ul",{className:"plain",children:d.map(m=>e.jsxs("li",{children:[e.jsx("strong",{children:o(m.repoId)}),": ",m.problem]},m.repoId))})]}):null,c.length?e.jsx(Xt,{name:"Policies",count:c.length,why:e.jsxs(e.Fragment,{children:["The rules the team is held to. ",e.jsx(Ie,{label:"policies",children:"A rule that blocks skills, MCP servers or tools in teammates' Claude Code is saved as a request and reaches them once a reviewer merges it; a rule on the tasks this orchestrator runs applies at once."}),c.length?e.jsxs(e.Fragment,{children:[" ",u]}):null]}),empty:e.jsxs(e.Fragment,{children:[sw(0)," Start from a template below, or ",u,"."]}),children:e.jsx("ul",{className:"plain policy-rows",children:c.map(m=>e.jsx(AS,{policy:m,names:o},m.id))})}):null,e.jsx(PS,{blank:c.length?void 0:u,templates:vx(As(t),t.ownedTeams.length>0,t.mode==="local"),reach:tj(t,n)}),As(t)&&t.mode!=="local"?e.jsx(OS,{}):null]})}function OS(){const[t,n]=h.useState(null),[a,l]=h.useState(null);h.useEffect(()=>{U("GET","/api/work/automations").then(c=>n(c.enabled),()=>n(null))},[]);const o=c=>{l(null),n(c),U("PUT","/api/work/automations",{enabled:c}).then(d=>n(d.enabled),d=>{n(!c),l(d.message)})};return t===null?null:e.jsxs("section",{className:"panel","aria-labelledby":"automations-h",children:[e.jsx("h2",{id:"automations-h",children:"Automations"}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:c=>o(c.target.checked)}),"Run automations"]}),e.jsxs("p",{className:"muted",children:[t===!1?"Every automation is off: changes on the tracker are logged and set nothing going.":"Tracker changes start the automations set up under Integrations; turning this off stops every one of them at once."," ",e.jsx("a",{href:re("integrations"),children:"Manage automations"})]}),a?e.jsx("p",{className:"error",role:"alert",children:a}):null]})}function LS({then:t}){return e.jsxs("section",{className:"panel","aria-labelledby":"policies-who-h",children:[e.jsx("h2",{id:"policies-who-h",children:"Who sets policies"}),e.jsxs("p",{className:"muted",children:["Ask an owner, an admin or your team's owner for the rule your team needs; ",t]})]})}function Pd(t){return n=>{var a,l;return((a=t.repos.find(o=>o.id===n))==null?void 0:a.name)??((l=t.users.find(o=>o.id===n))==null?void 0:l.name)??n}}function FS(t){var n;return{teams:t.teams.map(a=>({id:a.team,label:a.team})),members:t.users.map(a=>({id:a.id,label:`${a.name} (${a.email})`})),repos:t.repos.filter(a=>a.configured!==!1).map(a=>({id:a.id,label:a.name})),tags:((n=t.tags)==null?void 0:n.map(a=>({id:a.tag,label:`${a.tag} (${a.members.toLocaleString("en-US")} ${a.members===1?"member":"members"})`})))??null,orchestratorRulesStored:t.list.orchestratorRulesStored}}const MS={name:"",audience:{kind:"workspace"},rules:[]};function _S({me:t,page:n}){const{data:a,error:l,reload:o}=sj(t),{search:c}=Bl(),d=n!=="new"?(a==null?void 0:a.list.policies.find(f=>f.id===n))??null:null,u=n==="new"?"Add policy":(d==null?void 0:d.name)??"Policy";let m;if(l&&!a)m=e.jsx(be,{what:"policies",reason:l,onRetry:o,panel:!0});else if(!a)m=e.jsx(he,{what:"policies",panel:!0});else if(n!=="new"&&!d)m=e.jsx("div",{className:"panel",role:"alert",children:e.jsxs("p",{children:["No policy with this address. ",e.jsx("a",{href:re("team"),children:"Back to policies"})]})});else if(!nj(t))m=e.jsxs(e.Fragment,{children:[d?e.jsxs("section",{className:"panel","aria-labelledby":"policy-read-h",children:[e.jsx("h2",{id:"policy-read-h",children:"What it does"}),e.jsx("p",{children:uh(d,Pd(a))})]}):null,e.jsx(LS,{then:e.jsx("a",{href:re("team"),children:"back to the policies in force"})})]});else{const f=vx(As(t),t.ownedTeams.length>0,t.mode==="local").find(x=>x.id===new URLSearchParams(c).get("template")),g=d??(f==null?void 0:f.draft(tj(t,a)))??MS;m=e.jsx(RS,{me:t,initial:g,existing:d,sources:FS(a),back:re("team"),repoName:Pd(a)},`${n}:${(f==null?void 0:f.id)??""}`)}return e.jsxs("div",{className:"page",children:[e.jsx(Yn,{title:u,crumb:e.jsx("a",{href:re("team"),children:"Team"})}),l&&a?e.jsx(Oi,{what:"policies",reason:l,onRetry:o}):null,m]})}const ia=(t,n,a)=>`${t.toLocaleString("en-US")} ${t===1?n:a}`;function US({people:t,shared:n,lessons:a}){const o=[t===null?"":ia(t,"person","people"),n===null?"":n.skills.length||n.mcpServers.length?`${ia(n.skills.length,"skill","skills")} and ${ia(n.mcpServers.length,"MCP server","MCP servers")} shared`:"nothing shared yet",a?`${ia(a,"lesson waits","lessons wait")} for review`:""].filter(Boolean).join("; ");return o?`${o[0].toUpperCase()}${o.slice(1)}.`:""}const DS=new Set(["forge","repo","members","join","start","task"]);function BS(t,n){const a=t.filter(o=>!o.done&&DS.has(o.id)),l=o=>n.includes(o.id)?2:o.required?0:1;return[...a].sort((o,c)=>l(o)-l(c))}function aj(t){if(!t||!t.tasks)return"no task";const n=t.unknownCost?`${ia(t.unknownCost,"task","tasks")} with no cost`:"",a=t.usd>0?`$${t.usd.toFixed(2)}${n?` and ${n}`:""}`:n,l=[t.kept?`${t.kept} kept`:"",t.undone?`${t.undone} undone`:"",t.merged?`${t.merged} merged`:"",a].filter(Boolean);return l.length?l.join(", "):`${ia(t.tasks,"task","tasks")}, none kept or merged yet`}function qS(t){const[n,a]=h.useState(null);return h.useEffect(()=>{t&&U("GET","/api/analytics/people?days=30").then(l=>a(new Map(l.people.map(o=>[o.email,o]))),()=>a(new Map))},[t]),n}function WS(){const[t,n]=h.useState(null);return h.useEffect(()=>{U("GET","/api/team/shared?days=30").then(a=>n({skills:a.skills.map(l=>({name:l.name||l.slug,repo:l.repoName,tasks:l.tasks})),mcpServers:a.mcpServers.map(l=>({name:l.name,repo:l.repoName,tasks:l.tasks}))}),()=>n({skills:[],mcpServers:[]}))},[]),t}function zS(){const[t,n]=h.useState([]);return h.useEffect(()=>{U("GET","/api/team/setup").then(a=>n(a.problems),()=>n([]))},[]),t}function HS({problem:t}){const[n,a]=h.useState(!1),[l,o]=h.useState(null),c=()=>{a(!0),o(null),ge.start({title:"",description:"",issueUrl:"",repoId:t.repoId,agent:"",template:{kind:"scaffold.refresh",commitVersioning:!1}}).then(d=>Ge(re("tasks",d.id)),d=>{o(d.message),a(!1)})};return e.jsxs("div",{className:"setup-problem",role:"status",children:[e.jsxs("p",{children:[e.jsx("span",{className:"state warn",children:t.repoName})," ",t.title,t.next&&!t.fix?` ${t.next}`:""]}),t.fix==="refresh"?e.jsx("button",{type:"button",className:"secondary",disabled:n,onClick:c,children:"Update TeamHandbook's files"}):null,l?e.jsx("p",{className:"error",role:"alert",children:l}):null]})}function GS({steps:t,skipped:n}){const[a,...l]=t,o=c=>e.jsx("span",{className:"muted",children:n.includes(c.id)?"skipped":c.required?"":"(optional)"});return e.jsxs(Xt,{name:"Getting set up",count:t.length,why:"What is left before the team works here; each step goes once it is done.",empty:"",children:[a?e.jsxs("div",{className:"setting-up-next",children:[e.jsxs("p",{children:[e.jsx("strong",{children:a.title})," ",o(a)]}),e.jsx("p",{className:"muted",children:a.detail}),e.jsx("div",{className:"actions",children:e.jsx("a",{className:"button secondary",href:a.to,children:a.action})})]}):null,l.length?e.jsx("ul",{className:"team-rows",children:l.map(c=>e.jsxs("li",{children:[c.title," ",o(c)]},c.id))}):null]})}function KS({people:t}){return t.length?e.jsx(Xt,{name:"Tasks by person",count:t.length,why:"Every repository, the last 30 days.",empty:"No task was started in the last 30 days; each person's tasks and how they ended land here.",children:e.jsx("ul",{className:"team-rows",children:t.map(n=>e.jsxs("li",{children:[n.name??n.email," ",e.jsx("span",{className:"muted",children:aj(n)})]},n.email))})}):null}function YS({personal:t}){const[n,a]=h.useState(!1),l=(t==null?void 0:t.mcpServers)??[],o=t?[...t.commands.map(u=>({key:`c:${u.name}`,name:u.name,what:"skill or command"})),...t.plugins.map(u=>({key:`p:${u.name}`,name:u.name,what:u.enabled?"plugin":"plugin, turned off"})),...l.map(u=>({key:`m:${u.name}`,name:u.name,what:"MCP server"})),...t.claudeMd?[{key:"claude-md",name:"CLAUDE.md",what:"your instructions"}]:[]]:[],c=[ia((t==null?void 0:t.commands.length)??0,"skill","skills"),ia(l.length,"MCP server","MCP servers"),...t!=null&&t.claudeMd?["a CLAUDE.md"]:[]],d=n?e.jsxs("span",{className:"team-share",children:[e.jsxs("span",{children:[e.jsx("strong",{children:"Start a team handbook"})," ",e.jsx(mt,{text:"/handbook:init"})]}),e.jsxs("span",{children:[e.jsx("strong",{children:"Join a team handbook"})," ",e.jsx(mt,{text:"/handbook:join"})]}),e.jsx("span",{className:"muted",children:"Type one in Claude Code on this computer."})]}):e.jsx("button",{type:"button",className:"secondary",onClick:()=>a(!0),children:"Share with a team"});return e.jsxs(Xt,{name:"Team handbook",count:o.length,why:o.length?`Your Claude Code loads ${c.join(", ")}; tasks here use ${o.length===1?"it":"them"}.`:"What your Claude Code loads shows here.",empty:e.jsxs(e.Fragment,{children:["Your Claude Code loads nothing of its own yet; a skill, plugin or MCP server you add there shows here. ",d]}),children:[e.jsxs("details",{className:"team-fold",children:[e.jsx("summary",{children:"Show them"}),e.jsx("ul",{className:"team-rows",children:o.map(u=>e.jsxs("li",{children:[e.jsx("span",{className:"mono",children:u.name})," ",e.jsxs("span",{className:"muted",children:[u.what,", from your Claude Code"]})]},u.key))})]}),e.jsx("p",{children:d})]})}function VS({me:t,org:n,repos:a}){var I,L,K;const l=t.mode==="local",o=Me(t),[c,d]=h.useState(null),[u,m]=h.useState(null),[f,g]=h.useState(null),[x,y]=h.useState(new Map),b=px(t),N=qS(!l),[v]=ah(!l&&o),k=hS(),S=WS(),$=zS(),E=Gx(l);h.useEffect(()=>{Ce.summary().then(d,()=>d(null)),Ce.onboarding().then(m,()=>m(null))},[]);const C=(I=a==null?void 0:a.find(B=>B.configured!==!1))==null?void 0:I.id,R=c&&u&&o&&!l?u.dismissed?[]:BS(cx(n,c,C,Mi(v)!==null),u.skipped):[],P=R.some(B=>B.required)?R:[],M=(a??[]).filter(B=>B.kind==="skills"&&B.configured!==!1),O=US({people:l?null:((L=b.users)==null?void 0:L.length)??null,shared:l?null:S,lessons:k.waiting??((K=k.rows)==null?void 0:K.length)??null}),_=o&&!l?e.jsx("button",{type:"button",onClick:()=>g({kind:"invite"}),children:"Invite members"}):null;return e.jsxs("div",{className:"page",children:[e.jsx(Yn,{title:"Team",...O?{summary:O}:{},..._?{actions:_}:{}}),e.jsx(Kx,{me:t,quiet:!0}),e.jsxs("div",{className:f?"with-rail":void 0,children:[e.jsxs("div",{children:[P.length?e.jsx(GS,{steps:P,skipped:(u==null?void 0:u.skipped)??[]}):null,P.length?null:$.map(B=>e.jsx(HS,{problem:B},`${B.repoId}:${B.title}`)),e.jsx(mS,{review:k,picked:(f==null?void 0:f.kind)==="lesson"?f.row.slug:null,onPick:B=>g({kind:"lesson",row:B})}),l?null:o?e.jsx(fx,{me:t,data:b,hideEmpty:!0,extra:{name:"Last 30 days",cell:B=>aj(N==null?void 0:N.get(B.email))}}):N?e.jsx(KS,{people:[...N.values()]}):e.jsx(he,{what:"tasks by person"}),l?e.jsx(Hx,{fallback:e.jsx(YS,{personal:E})}):a===null?e.jsx(he,{what:"the team handbook"}):M.length?e.jsx(oN,{me:t,repos:a,counts:S??{skills:[],mcpServers:[]},picked:(f==null?void 0:f.kind)==="handbook"?f.pick:null,proposed:x,onPick:B=>g({kind:"handbook",pick:B}),onProposed:(B,ne,Z)=>{const D=new Map(x);for(const te of ne.skills)D.set(_a(B,"skills",te),{...Z,what:"addition"});for(const te of ne.mcpServers)D.set(_a(B,"mcp",te),{...Z,what:"addition"});for(const te of ne.commands)D.set(_a(B,"commands",te),{...Z,what:"addition"});y(D)}}):null,l||!t.runners?null:e.jsx(QN,{me:t.id}),e.jsx(IS,{me:t})]}),f?e.jsx(nS,{label:f.kind==="invite"?"Invite members":f.kind==="handbook"?"The picked row":"The picked lesson",onClose:()=>g(null),children:f.kind==="invite"?e.jsx(oh,{me:t,teams:b.teams,onSent:(B,ne)=>{b.setSent({sent:B,skipped:ne}),b.reload(),g(null)},onCancel:()=>g(null)}):f.kind==="handbook"?e.jsx(iN,{pick:f.pick,onOpened:(B,ne)=>{y(new Map(x).set(_a(f.pick.repo.id,f.pick.tab,f.pick.name),{number:B.number,url:B.url,what:ne})),g(null)}},_a(f.pick.repo.id,f.pick.tab,f.pick.name)):e.jsx(pS,{row:f.row,onDecided:B=>{k.settled(B),g(null)}},f.row.slug)}):null]})]})}function QS({me:t,org:n,repos:a,page:l}){return l[0]==="policies"&&l[1]?e.jsx(_S,{me:t,page:l[1]}):e.jsx(VS,{me:t,org:n,repos:a})}const Rr={list:()=>U("GET","/api/work/automations"),turn:t=>U("PUT","/api/work/automations",{enabled:t}),add:t=>U("POST","/api/work/automations",t),change:(t,n)=>U("PUT",`/api/work/automations/${encodeURIComponent(t)}`,n),remove:t=>U("DELETE",`/api/work/automations/${encodeURIComponent(t)}`),deliveries:t=>U("GET",`/api/work/automations/${encodeURIComponent(t)}/deliveries`)},JS=t=>t.trigger.kind==="column"?`an issue of ${t.project} moves into ${t.trigger.column}`:`an issue of ${t.project} gets the label ${t.trigger.label}`,XS=t=>t.action==="start"?`start a task in ${t.by.name}'s name`:"draft a task for someone to start";function ZS({repos:t}){const[n,a]=h.useState(null),[l,o]=h.useState(null),[c,d]=h.useState(null),[u,m]=h.useState(!1),f=()=>Rr.list().then(a,x=>o(x.message));h.useEffect(()=>{f()},[]);const g=(x,y)=>{o(null),x.then(()=>{d(y),f()},b=>o(b.message))};return n?e.jsxs(e.Fragment,{children:[c?e.jsx("p",{role:"status",children:c}):null,l?e.jsx("p",{className:"error",role:"alert",children:l}):null,e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:n.enabled,onChange:x=>g(Rr.turn(x.target.checked),x.target.checked?"Automations run again.":"Every automation is off.")}),"Run automations"]}),n.enabled?null:e.jsx("p",{className:"muted",children:"Every automation is off: changes on the tracker are logged and set nothing going."}),n.automations.length?e.jsx("ul",{className:"automations","aria-label":"Automations",children:n.automations.map(x=>e.jsx(eC,{automation:x,run:g},x.id))}):e.jsx("p",{className:"muted",children:"No automation yet. Each one reads its board once a minute for an issue moving into its column or getting its label."}),u?e.jsx(tC,{repos:t,onAdded:x=>{m(!1),d(`${x.name} is set up.`),f()},onCancel:()=>m(!1)}):e.jsx("button",{type:"button",className:"secondary",onClick:()=>m(!0),children:"Add automation"})]}):l?e.jsx(be,{what:"automations",reason:l,onRetry:()=>{o(null),f()}}):e.jsx(he,{what:"automations"})}function eC({automation:t,run:n}){const[a,l]=h.useState(null),o=()=>a?l(null):Rr.deliveries(t.id).then(c=>l(c.deliveries),()=>l([]));return e.jsxs("li",{className:"panel",children:[e.jsx("h4",{children:t.name}),e.jsxs("p",{children:["When ",JS(t),", ",XS(t)," on ",t.repoId," with ",t.agent,".",t.filter.labels.length?` Only issues labelled ${t.filter.labels.join(", ")}.`:""]}),t.action==="start"?e.jsxs("p",{className:"warning",role:"note",children:["A task starts with nobody pressing Start, in ",t.by.name,"'s name and under every rule a start from the screen meets."]}):null,e.jsxs("div",{className:"row-actions",children:[e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:c=>n(Rr.change(t.id,{enabled:c.target.checked}),`${t.name} is ${c.target.checked?"on":"off"}.`)}),"On"]}),e.jsx("button",{type:"button",className:"secondary small","aria-expanded":!!a,onClick:o,children:"Deliveries"}),e.jsx(qe,{small:!0,trigger:"Remove",triggerLabel:`Remove ${t.name}`,consequence:"The automation and the drafts it made waiting are deleted. Its deliveries stay in the event log.",confirm:`Remove ${t.name}`,keep:"Keep it",onConfirm:()=>Rr.remove(t.id).then(()=>n(Promise.resolve(),`${t.name} is removed.`))})]}),a?a.length?e.jsx("ul",{"aria-label":`Deliveries of ${t.name}`,children:a.map(c=>e.jsxs("li",{children:[e.jsx("span",{className:"mono small-print",children:c.at.slice(0,16).replace("T"," ")})," ",c.detail]},`${c.at}${c.detail}`))}):e.jsx("p",{className:"muted",children:"No change has reached it yet."}):null]})}function tC({repos:t,onAdded:n,onCancel:a}){var v;const[l,o]=h.useState(null),[c,d]=h.useState([]),[u,m]=h.useState([]),[f,g]=h.useState({name:"",board:"",kind:"column",column:"",label:"",labels:"",repoId:((v=t[0])==null?void 0:v.id)??"",agent:"",action:"draft"}),[x,y]=h.useState(null);h.useEffect(()=>{U("GET","/api/work/boards?source=tracker").then(k=>o(k.boards),k=>y(k.message)),ge.options().then(k=>{d(k.agents),g(S=>{var $;return{...S,agent:S.agent||(($=k.agents[0])==null?void 0:$.id)||""}})},()=>{})},[]),h.useEffect(()=>{!f.repoId&&t[0]&&g(k=>({...k,repoId:t[0].id}))},[t]),h.useEffect(()=>{if(!f.board)return m([]);U("GET",`/api/work/boards/${encodeURIComponent(f.board)}/columns`).then(k=>m(k.columns),k=>y(k.message))},[f.board]);const b=k=>S=>g({...f,[k]:S.target.value}),N=k=>{k.preventDefault(),y(null);const S=f.kind==="column"?{kind:"column",column:f.column}:{kind:"label",label:f.label.trim()},$=f.labels.split(",").map(E=>E.trim()).filter(Boolean);Rr.add({name:f.name.trim(),board:f.board,trigger:S,filter:{labels:$},repoId:f.repoId,agent:f.agent,action:f.action}).then(E=>n(E.automation),E=>y(E.message))};return e.jsxs("form",{className:"form",onSubmit:N,"aria-label":"Add automation",children:[e.jsxs("label",{children:["Name",e.jsx("input",{value:f.name,onChange:b("name"),required:!0,maxLength:60})]}),e.jsxs("label",{children:["Board",e.jsxs("select",{value:f.board,onChange:b("board"),required:!0,children:[e.jsx("option",{value:"",children:"Pick a board"}),(l??[]).map(k=>e.jsx("option",{value:k.id,children:k.name},k.id))]})]}),e.jsxs("label",{children:["When",e.jsxs("select",{value:f.kind,onChange:b("kind"),children:[e.jsx("option",{value:"column",children:"An issue moves into a column"}),e.jsx("option",{value:"label",children:"An issue gets a label"})]})]}),f.kind==="column"?e.jsxs("label",{children:["Column",e.jsxs("select",{value:f.column,onChange:b("column"),required:!0,children:[e.jsx("option",{value:"",children:"Pick a column"}),u.map(k=>e.jsx("option",{value:k.name,children:k.name},k.name))]})]}):e.jsxs("label",{children:["Label",e.jsx("input",{value:f.label,onChange:b("label"),required:!0,maxLength:100})]}),e.jsxs("label",{children:["Only issues labelled (optional, separated by commas)",e.jsx("input",{value:f.labels,onChange:b("labels"),maxLength:400})]}),e.jsxs("label",{children:["Repository",e.jsx("select",{value:f.repoId,onChange:b("repoId"),required:!0,children:t.map(k=>e.jsx("option",{value:k.id,children:k.name},k.id))})]}),e.jsxs("label",{children:["Agent",e.jsx("select",{value:f.agent,onChange:b("agent"),required:!0,children:c.map(k=>e.jsx("option",{value:k.id,children:k.label},k.id))})]}),e.jsxs("fieldset",{children:[e.jsx("legend",{children:"Then"}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"radio",name:"action",value:"draft",checked:f.action==="draft",onChange:b("action")}),"Draft a task for someone to start"]}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"radio",name:"action",value:"start",checked:f.action==="start",onChange:b("action")}),"Start the task in my name"]})]}),f.action==="start"?e.jsx("p",{className:"warning",role:"note",children:"A task starts with nobody pressing Start, in your name and under every rule a start from the screen meets. Drafting is the safe choice."}):null,x?e.jsx("p",{className:"error",role:"alert",children:x}):null,e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",children:"Add automation"}),e.jsx("button",{type:"button",className:"secondary",onClick:a,children:"Cancel"})]})]})}function ca({id:t,name:n,about:a,connected:l,action:o,status:c,other:d,error:u,level:m=2}){const f=m===3?"h3":"h2";return e.jsxs("section",{id:`card-${t}`,className:m===3?"connect":"section connect","aria-labelledby":`${t}-h`,children:[e.jsxs("div",{className:"connect-head",children:[e.jsx(f,{id:`${t}-h`,children:n}),l?e.jsx("span",{className:"state ok",children:"Connected"}):null]}),e.jsx("p",{children:a}),c?e.jsx("div",{className:"connect-status",role:"status",children:c}):null,e.jsx("div",{className:"actions",children:o}),d?e.jsxs("details",{className:"other-ways",children:[e.jsx("summary",{children:"Other ways to connect"}),d]}):null,u?e.jsx("p",{className:"error",role:"alert",children:u}):null]})}const Pl={gitlab:{ownApplication:!0,visibilities:["private","internal","public"],namespace:!0},github:{ownApplication:!1,visibilities:["private","public"],namespace:!1}},rj=t=>t.slice(0,10);function nC({kind:t}){const[n,a]=h.useState(null);if(h.useEffect(()=>{Nt.hosts().then(o=>a(o.hosts.filter(c=>c.kind===t)),()=>a([]))},[t]),!(n!=null&&n.length))return null;const l=rt[t].label;return e.jsx("ul",{className:"forge-hosts","aria-label":`${l} hosts`,children:n.map(o=>{const c=o.repos.filter(u=>u.via==="token"),d=o.repos.filter(u=>u.via==="connection");return e.jsxs("li",{className:"panel",children:[e.jsxs("h4",{children:[l," at ",new URL(o.webUrl).host]}),o.connection?e.jsxs("p",{children:["Connected as ",o.connection.account,o.ownApplication?", through the organization's own application":"","."]}):o.ownApplication?e.jsx("p",{children:"The organization's own application is entered; nobody connected through it yet."}):null,o.repos.length?e.jsxs("p",{children:[[d.length?`${d.map(u=>u.id).join(", ")} through the connection`:"",c.length?`${c.map(u=>u.id).join(", ")} with a token`:""].filter(Boolean).join("; "),"."]}):e.jsx("p",{className:"muted",children:"No repository on it yet."}),c.length?e.jsxs("p",{children:["Make a token at ",e.jsx("a",{href:o.credentials.tokenPage,target:"_blank",rel:"noopener",children:new URL(o.credentials.tokenPage).host})," that allows: ",o.credentials.scopes.join(", "),"."]}):null]},o.apiUrl)})})}function Ad(){const t=new URLSearchParams(window.location.search),n=t.get("forge_connected");return{connected:Fl.includes(n)?n:null,problem:t.get("forge_problem")}}function sC({kind:t,repos:n,onChanged:a}){const l=rt[t].label,[o,c]=h.useState(null),[d,u]=h.useState(null),[m,f]=h.useState(null),g=()=>Nt.connection(t).then(c,v=>u(v.message));h.useEffect(()=>{g()},[t]);const x=Ad(),y=v=>{f(v),g(),a()};if(!o)return d?e.jsx(be,{what:`the ${l} connection`,reason:d,onRetry:()=>{u(null),g()}}):e.jsx(he,{what:`the ${l} connection`});if(!o.available)return Pl[t].ownApplication?e.jsx(qf,{onSaved:g}):null;const b=()=>{u(null),Nt.connect(t).then(v=>window.location.assign(v.authorizeUrl),v=>u(v.message))},N=o.connection;return e.jsxs("section",{className:"forge-connect","aria-label":`${l} connection`,children:[x.connected===t&&N?e.jsxs("p",{role:"status",children:["Connected to ",l," as ",N.account,"."]}):null,m?e.jsx("p",{role:"status",children:m}):null,d?e.jsx("p",{className:"error",role:"alert",children:d}):null,N?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Connected as ",N.account," by ",N.by," on ",rj(N.at),"."]}),N.problem?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"error",role:"alert",children:N.problem}),e.jsxs("button",{type:"button",onClick:b,children:["Reconnect with ",l]})]}):null,e.jsx(aC,{kind:t}),e.jsx(rC,{kind:t,repos:n,onConnected:y}),N.manageUrl?e.jsx("p",{children:e.jsxs("a",{href:N.manageUrl,target:"_blank",rel:"noopener",children:["Choose the repositories the ",l," app reaches"]})}):null,e.jsx(lC,{kind:t,repos:n,onMade:y}),e.jsx(qe,{trigger:`Disconnect ${l}`,consequence:`The orchestrator stops reaching ${l} through this connection. A repository still connected through it has to be removed first.`,confirm:"Disconnect",keep:"Keep connection",onConfirm:()=>Nt.disconnect(t).then(v=>y(v.note??`${l} is disconnected.`))})]}):Pl[t].ownApplication?e.jsx(qf,{onSaved:g,beside:!0}):null]})}function aC({kind:t}){const[n,a]=h.useState(null),[l,o]=h.useState(!1),[c,d]=h.useState(null),u=()=>{o(!0),d(null),Nt.check(t).then(m=>{o(!1),a(m.check)},m=>{o(!1),d(m.message)})};return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"secondary small",disabled:l,onClick:u,children:"Check connection"}),c?e.jsx("p",{className:"error",role:"alert",children:c}):null,n!=null&&n.ok?e.jsxs("p",{role:"status",children:["Works as ",n.account,n.version?`, on ${rt[t].label} ${n.version}`:"","."]}):null,n&&!n.ok?e.jsxs("div",{role:"alert",children:[e.jsx("p",{children:n.problem??`The connection does not allow everything the orchestrator needs on ${rt[t].label}.`}),n.missing.length?e.jsx("ul",{"aria-label":"What the connection lacks",children:n.missing.map(m=>e.jsx("li",{children:m},m))}):null]}):null]})}const lj=t=>[...new Set(t.map(n=>n.team))].sort();function oj({label:t,value:n,onChange:a,teams:l}){const o=h.useId();return e.jsxs("label",{children:[t,e.jsx("input",{list:o,value:n,onChange:c=>a(c.target.value),required:!0,maxLength:60}),e.jsx("datalist",{id:o,children:l.map(c=>e.jsx("option",{value:c},c))})]})}function rC({kind:t,repos:n,onConnected:a}){const l=rt[t].label,[o,c]=h.useState(null),[d,u]=h.useState({}),[m,f]=h.useState(null),g=()=>Nt.repos(t).then(b=>c(b.repos),b=>f(b.message));h.useEffect(()=>{g()},[t]);const x=lj(n),y=(b,N)=>{f(null),b.then(()=>{g(),a(N)},v=>f(v.message))};return o?e.jsxs(e.Fragment,{children:[m?e.jsx("p",{className:"error",role:"alert",children:m}):null,o.length?e.jsx("ul",{className:"forge-repos","aria-label":`${l} repositories`,children:o.map(b=>{const N=d[b.fullName]??"";return e.jsxs("li",{children:[e.jsx("span",{className:"mono",children:b.fullName}),b.connected?e.jsx("span",{className:"badge ok",children:"Connected"}):e.jsxs("span",{className:"actions",children:[e.jsx(oj,{label:`Team for ${b.fullName}`,value:N,onChange:v=>u({...d,[b.fullName]:v}),teams:x}),e.jsxs("button",{type:"button",className:"secondary small",disabled:!N.trim(),onClick:()=>y(Nt.connectRepo(t,{fullName:b.fullName,team:N.trim()}),`${b.fullName} is connected for ${N.trim()}.`),children:["Connect ",b.fullName]}),b.empty?e.jsxs("button",{type:"button",className:"secondary small",disabled:!N.trim(),onClick:()=>y(Nt.teamRepo(t,{existing:b.fullName,team:N.trim()}),`${b.fullName} is the team repository of ${N.trim()}.`),children:["Use ",b.fullName," as the team repository"]}):null]})]},b.fullName)})}):e.jsxs("p",{className:"muted",children:[l," lists no repository for this connection yet."]})]}):m?e.jsx(be,{what:`${l} repositories`,reason:m,onRetry:()=>{f(null),g()}}):e.jsx(he,{what:`${l} repositories`})}function lC({kind:t,repos:n,onMade:a}){const l=rt[t].label,[o,c]=h.useState(!1),[d,u]=h.useState({name:"",team:"",visibility:"private",namespace:""}),[m,f]=h.useState(!1),[g,x]=h.useState(null),[y,b]=h.useState(null),[N,v]=h.useState(null),k=S=>{S.preventDefault(),x(null),b(null),f(!0);const $={name:d.name.trim(),team:d.team.trim(),visibility:d.visibility,...Pl[t].namespace&&d.namespace.trim()?{namespace:d.namespace.trim()}:{}};Nt.teamRepo(t,$).then(E=>{f(!1);const C=E.repo.url.replace(/^https?:\/\/[^/]+\//,"").replace(/\.git$/,"");v(`Created ${C}.${E.webhook==="installed"?"":` The webhook is ${E.webhook}.`}`),c(!1),a(`The team repository for ${$.team} is on ${l}.`)},E=>{f(!1);const C=E instanceof ht&&Array.isArray(E.body.steps)?E.body.steps:null;C!=null&&C.length?b(C):x(E.message)})};return e.jsxs(e.Fragment,{children:[N?e.jsx("p",{role:"status",children:N}):null,y?e.jsxs("div",{role:"alert",children:[e.jsxs("p",{children:[l," does not let the orchestrator create this repository. Make it there, then come back:"]}),e.jsx("ol",{"aria-label":"Steps to make the team repository",children:y.map(S=>e.jsx("li",{children:S.url?e.jsx("a",{href:S.url,target:"_blank",rel:"noopener",children:S.text}):S.text},S.text))})]}):null,o?e.jsxs("form",{className:"form",onSubmit:k,"aria-label":"Create team repository",children:[e.jsxs("p",{className:"muted",children:["The orchestrator creates this repository on ",l," and writes its first commit straight to it, because the repository is new and you asked for it. Every later change opens as a request."]}),e.jsxs("label",{children:["Name",e.jsx("input",{value:d.name,onChange:S=>u({...d,name:S.target.value}),required:!0,maxLength:100})]}),e.jsx(oj,{label:"Team",value:d.team,onChange:S=>u({...d,team:S}),teams:lj(n)}),e.jsxs("label",{children:["Visibility",e.jsx("select",{value:d.visibility,onChange:S=>u({...d,visibility:S.target.value}),children:Pl[t].visibilities.map(S=>e.jsx("option",{value:S,children:S[0].toUpperCase()+S.slice(1)},S))})]}),Pl[t].namespace?e.jsxs("label",{children:["Group (optional)",e.jsx("input",{value:d.namespace,onChange:S=>u({...d,namespace:S.target.value}),maxLength:200})]}):null,g?e.jsx("p",{className:"error",role:"alert",children:g}):null,e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",disabled:m,children:"Create repository"}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>c(!1),children:"Cancel"})]})]}):e.jsx("button",{type:"button",className:"secondary",onClick:()=>c(!0),children:"Create team repository"})]})}function qf({onSaved:t,beside:n=!1}){const[a,l]=h.useState(null),[o,c]=h.useState({url:"",clientId:"",clientSecret:""}),[d,u]=h.useState(null),m=()=>Nt.gitlabApp().then(l,g=>u(g.message));if(h.useEffect(()=>{m()},[]),!a||a.operator)return d?e.jsx("p",{className:"error",role:"alert",children:d}):null;const f=g=>{g.preventDefault(),u(null),Nt.saveGitlabApp(o).then(()=>{c({url:"",clientId:"",clientSecret:""}),m(),t()},x=>u(x.message))};return e.jsxs("form",{className:"form",onSubmit:f,"aria-label":"Your GitLab application",children:[e.jsx("p",{children:"Use your own GitLab application to connect a GitLab of your own once for the organization. Create it in GitLab with the api scope and this redirect address."}),a.redirectUri?e.jsxs("p",{children:["Redirect URI: ",e.jsx("span",{className:"mono",children:a.redirectUri})]}):null,a.app?e.jsxs("p",{children:["The application at ",a.app.webUrl," was entered by ",a.app.by," on ",rj(a.app.at),"."]}):null,e.jsxs("label",{children:["GitLab address",e.jsx("input",{value:o.url,onChange:g=>c({...o,url:g.target.value}),placeholder:"https://gitlab.example.com",required:!0})]}),e.jsxs("label",{children:["Application ID",e.jsx("input",{value:o.clientId,onChange:g=>c({...o,clientId:g.target.value}),required:!0,autoComplete:"off"})]}),e.jsxs("label",{children:["Secret",e.jsx("input",{type:"password",value:o.clientSecret,onChange:g=>c({...o,clientSecret:g.target.value}),required:!0,autoComplete:"off"})]}),d?e.jsx("p",{className:"error",role:"alert",children:d}):null,e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",className:n?"secondary":void 0,children:"Save application"}),a.app?e.jsx(qe,{trigger:"Remove application",consequence:"GitLab can no longer be connected through this application until one is entered again.",confirm:"Remove",keep:"Keep application",onConfirm:()=>Nt.removeGitlabApp().then(()=>{m(),t()})}):null]})]})}function Wf({forge:t,code:n,url:a,note:l}){return e.jsxs(e.Fragment,{children:[n?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Enter this code on ",t,":"]}),e.jsx("div",{className:"sign-in-code",children:e.jsx(mt,{text:n,label:"Copy the code",well:!0})})]}):null,e.jsxs("p",{children:[a?e.jsxs(e.Fragment,{children:[e.jsxs("a",{href:a,target:"_blank",rel:"noopener",children:["Open ",t]}),n?"":" to sign in",". "]}):null,l?e.jsxs(e.Fragment,{children:[l,". "]}):null,"Waiting for ",t,"."]})]})}function oC({card:t,repos:n,other:a,onChanged:l}){var R,P;const o=t.id,c=mn[o],[d,u]=h.useState(null),[m,f]=h.useState(null),[g,x]=h.useState(!1),y=()=>Nt.signInState(o).then(u,M=>f(M.message));h.useEffect(()=>{y()},[o]);const b=(d==null?void 0:d.signIn.state)==="waiting"||((R=d==null?void 0:d.device)==null?void 0:R.signIn.state)==="waiting";h.useEffect(()=>{if(!b)return;const M=setInterval(()=>{Nt.signInState(o).then(O=>{var _;u(O),(O.signIn.state==="done"||((_=O.device)==null?void 0:_.signIn.state)==="done")&&l()},()=>{})},2e3);return()=>clearInterval(M)},[b,o]);const N=()=>{x(!0),f(null),Nt.signIn(o).then(u,M=>f(M.message)).finally(()=>x(!1))};if(!d)return e.jsx(ca,{id:o,name:c,level:3,connected:t.state==="connected",about:m?"":`Loading ${c}.`,action:null,other:a,error:m});if(!d.offered||!d.cli){const M=()=>{x(!0),f(null),Nt.connect(o).then(K=>window.location.assign(K.authorizeUrl),K=>{f(K.message),x(!1)})},O=t.connection,_=O?null:d.device;if(_!=null&&_.offered){const K=_.signIn,B=()=>{x(!0),f(null),Nt.deviceSignIn(o).then(()=>y(),Q=>f(Q.message)).finally(()=>x(!1))},ne=()=>{x(!0),f(null),Nt.deviceSignOut(o).then(()=>y(),Q=>f(Q.message)).finally(()=>x(!1))},Z=K.state==="done"?`Connected as ${K.account} on ${K.host}; the orchestrator opens the requests of the tasks you start as you, and nothing else.`:K.state==="failed"?da(K.error):`Open the requests of the tasks you start on ${c} as you. You sign in with a one-time code, nothing to install; the sign-in can write to the repositories you can, and is used only for those requests.`,D=K.state==="waiting"?e.jsx(Wf,{forge:c,code:K.code,url:K.url}):null,te=K.state==="done"?e.jsx("button",{type:"button",className:"secondary",disabled:g,onClick:ne,children:"Sign out"}):K.state==="waiting"?null:e.jsx("button",{type:"button",className:"secondary",disabled:g,onClick:B,children:K.state==="failed"?"Sign in again":`Sign in with ${c}`});return e.jsx(ca,{id:o,name:c,level:3,connected:K.state==="done",about:Z,status:D,action:te,other:a,error:m})}const I=O?`Connected as ${O.account}.`:d.org?d.org.available?`Work on the repositories you pick on ${c} and open their requests there, connected once for the organization.`:d.why?da(`${d.why}; connect with a token under Other ways to connect`):e.jsxs(e.Fragment,{children:[d.org.missing[0]," ",e.jsxs(Ie,{label:`connecting ${c} with one click`,children:["Its operator sets ORCHESTRATOR_FORGE_",o.toUpperCase(),"_*, ORCHESTRATOR_PUBLIC_URL and ORCHESTRATOR_SECRET_KEY, as the operator's guide to forge applications describes."]})]}):da(d.why??`An owner or an admin connects ${c}`),L=O||!((P=d.org)!=null&&P.available)?null:e.jsxs("button",{type:"button",className:"secondary",disabled:g,onClick:M,children:["Connect with ",c]});return e.jsx(ca,{id:o,name:c,level:3,connected:!!O||t.state==="connected",about:I,action:L,other:a,error:m})}const v=d.cli,k=d.signIn,S=k.state==="failed"?k.error:null,$=v.signedIn?`Connected as ${v.account??"you"} on ${v.host}.`:v.installed?`Open the requests of your tasks on ${c} as you, through your own ${v.tool}; its sign-in stays with ${v.tool}.`:`${v.name} is not on this machine. Install it, then check again.`,E=k.state==="waiting"?e.jsx(Wf,{forge:c,code:k.code,url:k.url,note:k.note}):null,C=v.signedIn?null:v.installed?k.state==="waiting"?null:e.jsxs("button",{type:"button",className:"secondary",disabled:g,onClick:N,children:["Sign in with ",c]}):e.jsxs(e.Fragment,{children:[d.installLine?e.jsx("span",{className:"mono",children:d.installLine}):e.jsxs("a",{href:v.install,target:"_blank",rel:"noopener",children:["Install ",v.tool]}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>y(),children:"Check again"})]});return e.jsx(ca,{id:o,name:c,level:3,connected:v.signedIn,about:$,status:E,action:C,other:a,error:m??S})}const zu={name:"",description:"",transport:"http",url:"",auth:"oauth"};function iC(t){var n,a;return t.auth==="none"?"No sign-in":t.auth==="token"?(n=t.credential)!=null&&n.set?"Token set":"No token":(a=t.credential)!=null&&a.set?t.credential.expiresAt?`Connected until ${t.credential.expiresAt.slice(0,16).replace("T"," ")}${t.credential.refreshable?", renewed for each task":""}`:"Connected":"Not connected"}function Hu(){const t=new URLSearchParams(window.location.search),n=new URLSearchParams(window.location.hash.split("?")[1]??"");return{connected:t.get("connected")??n.get("connected"),problem:t.get("problem")??n.get("problem")}}function cC({me:t,repos:n}){const[a,l]=h.useState(null),[o,c]=h.useState(zu),[d,u]=h.useState(""),[m,f]=h.useState(""),[g,x]=h.useState(Hu().problem),[y,b]=h.useState(Hu().connected?`${Hu().connected} is connected. Pick the tools a task may use.`:null),[N,v]=h.useState(!1),[k,S]=h.useState("me"),[$,E]=h.useState(null),C=h.useId(),R=n.filter(I=>I.configured!==!1&&I.head&&Mr(t,I.team)),P=()=>rs.list().then(l,I=>x(I.message));h.useEffect(()=>{P()},[]);const M=(I,L)=>{x(null),b(null),v(!0),I().then(()=>{v(!1),L&&b(L),P()},K=>{v(!1),x(K.message)})},O=I=>{x(null),b(I),P()},_=I=>{if(I.preventDefault(),k!=="me"){const K=R.find(ne=>ne.id===k),B=o.transport==="http"?{type:"http",url:o.url}:{command:o.command,args:d.split(`
|
|
78
|
+
`).map(ne=>ne.trim()).filter(Boolean)};E({repoId:K.id,head:K.head,config:B,name:o.name});return}const L=o.transport==="http"?{name:o.name,description:o.description,transport:"http",url:o.url,auth:o.auth,...o.auth==="token"?{token:m}:{}}:{name:o.name,description:o.description,transport:"stdio",command:o.command,args:d.split(`
|
|
79
|
+
`).map(K=>K.trim()).filter(Boolean),auth:"none"};M(async()=>{await rs.add(L),c(zu),u(""),f("")},`${L.name} is added.${L.auth==="oauth"?" Connect it to sign in.":" Pick the tools a task may use."}`)};return a?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"muted",children:"A server of your own reaches only the tasks you start, with your own access. One for a team goes in through a request someone reviews."}),g?e.jsx("p",{className:"error",role:"alert",id:C,children:g}):null,y?e.jsx("p",{role:"status",children:y}):null,a.servers.length?e.jsx("ul",{className:"plain my-servers",children:a.servers.map(I=>e.jsx(uC,{server:I,signIn:a.signIn,busy:N,run:M,done:O},I.name))}):e.jsx("p",{className:"muted",children:"You have added no server yet."}),e.jsxs("form",{className:"form editor",onSubmit:_,"aria-label":"Add an MCP server",children:[e.jsx("h4",{children:"Add an MCP server"}),e.jsx(Pe,{label:"For",value:k,onChange:S,disabled:$!==null,options:[{value:"me",label:"Only the tasks I start"},...R.map(I=>({value:I.id,label:`The ${I.team} team, through a request on ${I.name}`}))]}),e.jsxs("label",{children:["Name",e.jsx("input",{value:o.name,onChange:I=>c({...o,name:I.target.value}),required:!0,spellCheck:!1,"aria-describedby":g?C:void 0})]}),e.jsxs("label",{children:["Description",e.jsx("input",{value:o.description,onChange:I=>c({...o,description:I.target.value})})]}),e.jsx(Pe,{label:"Reached",value:o.transport,onChange:I=>c({...o,transport:I,auth:I==="http"?"oauth":"none"}),options:[{value:"http",label:"Over the network (URL)"},{value:"stdio",label:"As a command in the task"}]}),o.transport==="http"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:["URL",e.jsx("input",{type:"url",value:o.url??"",onChange:I=>c({...o,url:I.target.value}),required:!0,placeholder:"https://mcp.example.com/mcp","aria-describedby":g?C:void 0})]}),k==="me"?e.jsx(Pe,{label:"Sign-in",value:o.auth,onChange:I=>c({...o,auth:I}),options:[{value:"oauth",label:"Sign in through the browser (OAuth)"},{value:"token",label:"A token"},{value:"none",label:"None"}]}):e.jsx("p",{className:"muted",children:"A team server that needs a credential names a variable each teammate sets; edit it on the repository's page after this request."}),k==="me"&&o.auth==="token"?e.jsxs("label",{children:["Token",e.jsx("input",{type:"password",autoComplete:"off",value:m,onChange:I=>f(I.target.value),required:!0,disabled:!a.vault})]}):null,k==="me"&&o.auth!=="none"&&!a.vault?e.jsx("p",{className:"error",children:"Set ORCHESTRATOR_SECRET_KEY on the server to keep a token or a sign-in."}):null,k==="me"&&o.auth==="oauth"&&!a.signIn?e.jsx("p",{className:"error",children:"Set ORCHESTRATOR_PUBLIC_URL on the server: a sign-in returns to it."}):null]}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:["Command",e.jsx("input",{value:o.command??"",onChange:I=>c({...o,command:I.target.value}),required:!0,spellCheck:!1,placeholder:"npx"})]}),e.jsxs("label",{children:["Arguments, one per line",e.jsx("textarea",{className:"short",value:d,onChange:I=>u(I.target.value),spellCheck:!1})]})]}),$===null?e.jsx("div",{className:"actions",children:e.jsx("button",{type:"submit",disabled:N,children:k==="me"?"Add":"Review the request"})}):null]}),$?e.jsx(Vn,{repoId:$.repoId,head:$.head,build:()=>({kind:"mcp.add",name:$.name,config:$.config}),submitLabel:"Check the server",onOpened:I=>{E(null),c(zu),u(""),b(gh(I))},onCancel:()=>E(null),children:()=>e.jsxs("h4",{children:["Add ",$.name," for the team"]})}):null]}):g?e.jsx(be,{what:"your MCP servers",reason:g,onRetry:()=>{x(null),P()}}):e.jsx(he,{what:"your MCP servers"})}function Id(t,n){return n.length?[...n]:t.filter(a=>a.reads).map(a=>a.name)}function Od(t){return{reads:t.filter(n=>!n.writes),writes:t.filter(n=>n.writes)}}function uC({server:t,signIn:n,busy:a,run:l,done:o}){var E,C,R;const[c,d]=h.useState(null),[u,m]=h.useState(t.tools),[f,g]=h.useState(t.tools.join(", ")),x=c??t.tools.map(P=>{var M,O;return{name:P,description:"",writes:((O=(M=t.known)==null?void 0:M[P])==null?void 0:O.writes)??t.writing.includes(P)}}),y=P=>{var M;return((M=x.find(O=>O.name===P))==null?void 0:M.writes)??!1},b=P=>m(u.includes(P)?u.filter(M=>M!==P):[...u,P]),N=()=>l(async()=>{const P=await rs.tools(t.name);d(P),m(Id(P,t.tools))},null),v=()=>l(async()=>window.location.assign(await rs.connect(t.name)),null),k=t.transport==="http"&&(t.auth!=="oauth"||!!((E=t.credential)!=null&&E.set));h.useEffect(()=>{!k||t.tools.length||rs.tools(t.name).then(P=>{d(P),m(Id(P,t.tools))},()=>{})},[k]);const S=(P,M)=>M.length?e.jsxs("fieldset",{className:"teams",children:[e.jsx("legend",{children:P}),M.map(O=>e.jsxs("label",{className:"check",title:O.description||void 0,children:[e.jsx("input",{type:"checkbox",checked:u.includes(O.name),onChange:()=>b(O.name)}),O.name]},O.name))]}):null,$=t.transport==="http"?u.filter(y):t.writing;return e.jsxs("li",{className:"panel my-server",children:[e.jsxs("div",{className:"card-head",children:[e.jsx("h4",{children:t.name}),e.jsx("span",{className:`badge ${(C=t.credential)!=null&&C.set||t.auth==="none"?"ok":"warn"}`,children:iC(t)})]}),t.description?e.jsx("p",{children:t.description}):null,e.jsx("p",{className:"mono small-print",children:t.transport==="http"?t.url:[t.command,...t.args??[]].join(" ")}),e.jsx("p",{className:"small-print",children:t.tools.length?`Tasks may use: ${t.tools.join(", ")}`:"No tool is allowed yet, so tasks do not get this server."}),t.transport==="http"?x.length?e.jsxs(e.Fragment,{children:[S("Reads",Od(x).reads),S("Writes",Od(x).writes)]}):e.jsx("p",{className:"muted",children:"Load the server's tools to pick from them."}):e.jsxs("label",{className:"filter",children:["Tools a task may use, separated by commas",e.jsx("input",{value:f,onChange:P=>g(P.target.value),spellCheck:!1})]}),c&&!t.tools.length?e.jsxs("p",{role:"status",children:["Only tools that read are ticked; tick any other yourself. Save tools to let the tasks you start use ",t.name,"."]}):null,$.length?e.jsxs("p",{className:"warning",role:"note",children:["This lets a task change things in ",t.name," as you: ",$.join(", "),". What such a tool changes is not a request anyone reviews."]}):null,e.jsxs("div",{className:"row-actions",children:[t.auth==="oauth"?(R=t.credential)!=null&&R.set?e.jsx(qe,{small:!0,trigger:"Disconnect",triggerLabel:`Disconnect ${t.name}`,consequence:`Tasks you start stop getting ${t.name} until you connect it again, and its sign-in is deleted.`,confirm:`Disconnect ${t.name}`,keep:"Stay connected",onConfirm:()=>rs.disconnect(t.name).then(()=>o(`${t.name} is disconnected.`))}):e.jsx("button",{type:"button",className:"small",disabled:a||!n,onClick:v,children:"Connect"}):null,t.transport==="http"?e.jsx("button",{type:"button",className:"secondary small",disabled:a,onClick:N,children:"Load tools"}):null,e.jsx("button",{type:"button",className:"small",disabled:a,onClick:()=>l(()=>rs.update(t.name,{tools:t.transport==="http"?u:f.split(",").map(P=>P.trim()).filter(Boolean)}),`Saved the tools tasks may use of ${t.name}.`),children:"Save tools"}),e.jsx(qe,{small:!0,trigger:"Remove",triggerLabel:`Remove ${t.name}`,consequence:`This cannot be undone. Tasks you start stop getting ${t.name}, and its sign-in or token and the tools you picked are deleted.`,confirm:`Remove ${t.name}`,keep:`Keep ${t.name}`,onConfirm:()=>rs.remove(t.name).then(()=>o(`${t.name} and its sign-in are removed.`))})]})]})}function dC(){const[t,n]=h.useState(null),[a,l]=h.useState(null),[o,c]=h.useState(null),[d,u]=h.useState(!1),m=()=>Cl.list().then(n,g=>l(g.message));h.useEffect(()=>{m()},[]);const f=(g,x)=>{l(null),c(null),u(!0),g().then(()=>{u(!1),x&&c(x),m()},y=>{u(!1),l(y.message)})};return t?t.servers.length?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"muted",children:"A task reaches these with the sign-in of whoever started it, or else the organization's."}),a?e.jsx("p",{className:"error",role:"alert",children:a}):null,o?e.jsx("p",{role:"status",children:o}):null,e.jsx("ul",{className:"plain my-servers",children:t.servers.map(g=>e.jsx(hC,{server:g,canManage:t.canManage,busy:d,run:f,done:x=>{c(x),m()}},g.key))})]}):e.jsx("p",{className:"muted",children:"No team repository declares a server that signs people in."}):a?e.jsx(be,{what:"team MCP servers",reason:a,onRetry:()=>{l(null),m()}}):e.jsx(he,{what:"team MCP servers"})}function hC({server:t,canManage:n,busy:a,run:l,done:o}){var v;const[c,d]=h.useState(null),[u,m]=h.useState(t.tools),f=()=>l(async()=>{t.mine||await rs.add({name:t.name,description:`The team's ${t.name}`,transport:"http",url:t.url,auth:"oauth"}),window.location.assign(await rs.connect(t.name))},null),g=()=>l(async()=>window.location.assign(await Cl.connectForEveryone(t.key)),null),x=()=>l(async()=>{const k=await Cl.tools(t.key);d(k),m(Id(k,t.tools))},null),y=k=>m(u.includes(k)?u.filter(S=>S!==k):[...u,k]),b=c?Od(c):null,N=c?u.filter(k=>{var S;return(S=c.find($=>$.name===k))==null?void 0:S.writes}):((v=t.everyone)==null?void 0:v.writing)??[];return e.jsxs("li",{className:"panel my-server",children:[e.jsxs("div",{className:"card-head",children:[e.jsx("h4",{children:t.name}),e.jsx("span",{className:`badge ${t.everyone?"ok":"warn"}`,children:t.everyone?"Connected for everyone's tasks":"Needs a sign-in"})]}),e.jsx("p",{className:"mono small-print",children:t.url}),e.jsxs("p",{className:"small-print",children:["Declared by ",t.repos.map(k=>`${k.team} · ${k.name}`).join(", ")]}),t.everyone?e.jsxs("p",{children:["Acts as the account ",t.everyone.by," signed in with in every task whose starter has not connected it, since ",t.everyone.at.slice(0,10),"."]}):null,e.jsx("p",{className:"small-print",children:t.mine?"Your own sign-in is used in the tasks you start, once connected; manage it under Your MCP servers.":"Your tasks use the organization's sign-in, if there is one."}),e.jsxs("div",{className:"row-actions",children:[t.mine?null:e.jsx("button",{type:"button",className:"small",disabled:a,onClick:f,children:"Connect for my tasks"}),n?t.everyone?e.jsx(qe,{small:!0,trigger:"Disconnect for everyone",triggerLabel:`Disconnect ${t.name} for everyone's tasks`,consequence:`Tasks whose starter has not connected ${t.name} stop reaching it, and the organization's sign-in is deleted.`,confirm:`Disconnect ${t.name}`,keep:"Keep it connected",onConfirm:()=>Cl.disconnectForEveryone(t.key).then(()=>o(`${t.name} is disconnected from everyone's tasks.`))}):e.jsx("button",{type:"button",className:"secondary small",disabled:a,onClick:g,children:"Connect for everyone's tasks"}):null,n?e.jsx("button",{type:"button",className:"secondary small",disabled:a,onClick:x,children:"Load tools"}):null]}),n&&b?e.jsxs(e.Fragment,{children:[b.reads.length?e.jsxs("fieldset",{className:"teams",children:[e.jsx("legend",{children:"Reads"}),b.reads.map(k=>e.jsxs("label",{className:"check",title:k.description||void 0,children:[e.jsx("input",{type:"checkbox",checked:u.includes(k.name),onChange:()=>y(k.name)}),k.name]},k.name))]}):null,b.writes.length?e.jsxs("fieldset",{className:"teams",children:[e.jsx("legend",{children:"Writes"}),b.writes.map(k=>e.jsxs("label",{className:"check",title:k.description||void 0,children:[e.jsx("input",{type:"checkbox",checked:u.includes(k.name),onChange:()=>y(k.name)}),k.name]},k.name))]}):null,e.jsx("div",{className:"row-actions",children:e.jsx("button",{type:"button",className:"small",disabled:a,onClick:()=>l(()=>Cl.saveTools(t.key,u),`Saved the tools everyone's tasks may use of ${t.name}.`),children:"Save tools"})})]}):null,t.everyone&&N.length?e.jsxs("p",{className:"warning",role:"note",children:["This lets a task change things in ",t.name," as ",t.everyone.by,": ",N.join(", "),"."]}):null,n?e.jsxs("p",{className:"small-print muted",children:[t.tools.length?`Everyone's tasks may use: ${t.tools.join(", ")}`:"No tool is picked for everyone's tasks yet."," Tools a repository's mcpTools names in the orchestrator's configuration are allowed besides."]}):null]})}const xh={request:{term:"Request",means:"A proposed change to a team repository: a merge request on GitLab, a pull request on GitHub, or a branch on the orchestrator's own copy for a repository read by path. Nothing in it reaches teammates until a reviewer merges it."},mcpServer:{means:"A tool server Claude Code calls, started on the machine it runs on or reached over the network, such as a tracker or a database reader."}},ij="Give a team of agents any folder on this machine: say what needs doing, and review every change before you keep it.",mC="Give a team of agents any folder on your computer: say what needs doing, and review every change before you keep it.",la=t=>new URLSearchParams(Object.entries(t).filter(n=>!!n[1])).toString(),os={boards:t=>`/api/work/boards?${la({source:t})}`,sprints:t=>`/api/work/sprints?${la({board:t})}`,sprintItems:t=>`/api/work/items?${la({sprint:t})}`,backlog:t=>`/api/work/items?${la({backlog:t})}`,boardItems:t=>`/api/work/items?${la({board:t})}`},wl=(t,n=!1)=>U("GET",n?`${t}&fresh=1`:t).then(a=>Ir(t,a)),Al={boards:t=>Ss(os.boards(t)),sprints:t=>Ss(os.sprints(t)),sprintItems:t=>Ss(os.sprintItems(t)),backlog:t=>Ss(os.backlog(t)),boardItems:t=>Ss(os.boardItems(t))},fn={sources:()=>U("GET","/api/work/sources"),boards:t=>wl(os.boards(t)),sprints:t=>wl(os.sprints(t)),sprintItems:(t,n=!1)=>wl(os.sprintItems(t),n),backlog:(t,n=!1)=>wl(os.backlog(t),n),saveColumns:(t,n)=>U("PUT",`/api/work/boards/${encodeURIComponent(t)}/columns`,{columns:n}),boardItems:(t,n=!1)=>wl(os.boardItems(t),n),moves:t=>U("GET",`/api/work/moves?${la({board:t})}`),saveMoves:(t,n)=>U("PUT",`/api/work/moves?${la({board:t})}`,n),mapBoard:(t,n)=>U("PUT","/api/work/boards/teams",{boards:[{boardId:t,team:n}]}),starters:t=>U("GET",`/api/work/starters?${la({project:t})}`)},Ri={gitlab:{title:"GitLab",text:"Open each change as a merge request on the team's GitLab project, with its reviewers and labels."},github:{title:"GitHub",text:"Open each change as a pull request on the team's GitHub repository, with its reviewers and labels."},slack:{title:"Slack",text:"Tell a channel when a request opens, merges or closes, and when a task finishes or fails."},tracker:{title:"Issue tracker",text:"Name a task's issue by key; with a token the agent reads its text."},"orchestrator-mcp":{title:"Orchestrator MCP",text:"Reach the orchestrator from Claude Code, approved once in the browser: read teams, requests and tasks, and propose changes for review."}},pC={title:"Your MCP servers",text:"Add a remote server by its address or one run by a command, sign in once, and pick the tools a task gets."},fC={title:"Team MCP servers",text:"Connect one that signs people in, for your own tasks or, as an owner or an admin, for everyone's."},gC={title:"Automations",text:"When an issue moves into a column or gets a label on the tracker's board, draft a task for someone to start, or start it."};function xC(){const t=new URLSearchParams(window.location.search).get("open");return t!==null&&Object.hasOwn(Ri,t)?t:null}const Gu={"orchestrator-mcp":"From Claude Code to the orchestrator: teammates reach the orchestrator from their own sessions.",team:"For your team's tasks: the servers the team repositories declare.",mine:"For your own tasks: servers only the tasks you start get."},jC=[{id:"hosting",title:"Code hosting",text:"Where a repository's requests open, and where they are merged.",cards:["gitlab","github"]},{id:"notifications",title:"Notifications",text:"Where the team hears what happens.",cards:["slack"]},{id:"issues",title:"Issue tracking",text:"Where a task's issue comes from.",cards:["tracker","automations"]},{id:"mcp",title:"MCP servers",text:xh.mcpServer.means,cards:["orchestrator-mcp","team","mine"]}],ti={connected:{label:"Connected",tone:"ok"},requested:{label:"Requested",tone:"warn"},off:{label:"Not set up",tone:""}},Bi=t=>t.slice(0,10);function yC(){const t=new URLSearchParams(window.location.search);return{added:t.get("slack")==="added",problem:t.get("slackProblem")}}function vC({by:t,at:n,local:a}){return!t||!n||a?null:e.jsxs("p",{className:"muted small-print",children:["Enabled by ",t," on ",Bi(n)]})}const zf="/api/integrations";function kC({me:t,repos:n}){const[a,l]=h.useState(()=>Ss(zf)??null),[o,c]=h.useState(!1),[d,u]=h.useState(null),[m,f]=h.useState(""),g=yC(),[x,y]=h.useState(()=>Ad().connected??xC()??(g.added?"slack":null)),b=Ad().problem,[N,v]=h.useState(()=>/[?&](connected=(?!atlassian\b)|problem=)/.test(window.location.search+window.location.hash)),k=()=>{u(null),c(!0),Dt.list().then(D=>l(Ir(zf,D)),D=>u(D.message)).finally(()=>c(!1))};h.useEffect(()=>{k()},[]);const S=a!==null;h.useEffect(()=>{var D;S&&x&&((D=document.getElementById(`card-${x}`))==null||D.scrollIntoView({block:"start"}))},[S]);const $=m.trim().toLowerCase(),[E,C]=h.useState(!1),[R,P]=h.useState(!1),M=D=>D==="team"?fC:D==="mine"?pC:D==="automations"?gC:Ri[D],O=D=>!$||`${M(D).title} ${M(D).text} ${Gu[D]??""}`.toLowerCase().includes($),_=!!(a!=null&&a.local),I=!!(a!=null&&a.integrations.some(D=>D.id==="tracker"&&D.config)),L=D=>{var te;return(D!=="tracker"||I||!((te=a==null?void 0:a.jira.mcp)!=null&&te.connected)||x==="tracker")&&(D==="team"||D==="mine"||(D==="automations"?!!(a!=null&&a.canManage):!!(a!=null&&a.integrations.some(Q=>Q.id===D))))},K=!$||`jira atlassian ${bC}`.toLowerCase().includes($),B=((a==null?void 0:a.catalog)??[]).filter(D=>!$||`${D.name} ${D.about}`.toLowerCase().includes($)),ne=jC.map(D=>({...D,cards:D.cards.filter(te=>L(te)&&O(te))})).filter(D=>D.cards.length),Z=D=>{var A;const te=M(D).title,Q=Gu[D]?e.jsx("p",{className:"small-print muted",children:Gu[D]}):null;if(D==="team"||D==="mine"||D==="automations"){const H=D==="team"?E:D==="mine"?N:R,X=()=>D==="team"?C(!E):D==="mine"?v(!N):P(!R);return e.jsxs("li",{className:"panel card",children:[e.jsx("div",{className:"card-head",children:e.jsx("h3",{id:`card-${D}`,children:te})}),Q,e.jsx("p",{children:M(D).text}),e.jsx("button",{type:"button",className:"secondary","aria-expanded":H,"aria-controls":`body-${D}`,onClick:X,children:H?"Close":"Manage"}),H?e.jsx("div",{id:`body-${D}`,className:"card-body",role:"region","aria-labelledby":`card-${D}`,children:D==="team"?e.jsx(dC,{}):D==="mine"?e.jsx(cC,{me:t,repos:n}):e.jsx(ZS,{repos:n})}):null]},D)}const ee=a.integrations.find(H=>H.id===D);if(Ar(ee.id)){const H=ee;return e.jsx("li",{className:"panel card",children:e.jsx(oC,{card:H,repos:n,onChanged:k,other:e.jsx($C,{card:H,forges:a.integrations.filter(X=>Ar(X.id)),repos:n,canManage:a.canManage,local:_,onChanged:k})})},D)}if(ee.id==="slack"&&ee.state==="off"&&a.canManage&&ee.addable)return e.jsx("li",{className:"panel card",children:e.jsx(TC,{card:ee,read:a,onSaved:k,problem:g.problem})},D);const W=ee.id==="slack"&&ee.state==="off"&&a.canManage;return e.jsxs("li",{className:"panel card",children:[W?e.jsx(ca,{id:"slack",name:"Slack",level:3,connected:!1,about:Ri.slack.text,action:e.jsx("button",{type:"button",className:"secondary","aria-expanded":x===ee.id,"aria-controls":`body-${D}`,onClick:()=>y(x===ee.id?null:ee.id),children:x===ee.id?"Close":"Set up Slack"})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"card-head",children:[e.jsx("h3",{id:`card-${D}`,children:te}),ti[ee.state].tone?e.jsx("span",{className:`badge ${ti[ee.state].tone}`,children:ti[ee.state].label}):e.jsx("span",{className:"badge",children:ti[ee.state].label})]}),Q,e.jsx("p",{children:M(D).text}),e.jsx(vC,{by:ee.enabledBy,at:ee.enabledAt,local:_}),e.jsx("button",{type:"button",className:"secondary","aria-expanded":x===ee.id,"aria-controls":`body-${D}`,onClick:()=>y(x===ee.id?null:ee.id),children:x===ee.id?"Close":ee.state==="off"?"Set up":"Manage"})]}),x===ee.id?e.jsxs("div",{id:`body-${D}`,className:"card-body",role:"region","aria-labelledby":W?"slack-h":`card-${D}`,children:[ee.id==="slack"?e.jsx(dj,{card:ee,read:a,onSaved:k,added:g.added}):null,ee.id==="tracker"?e.jsx(RC,{card:ee,canManage:a.canManage,onSaved:k,repos:n,local:_}):null,ee.id==="orchestrator-mcp"?e.jsx(PC,{card:ee,repos:n,onOpened:k}):null,ee.id==="tracker"&&(((A=ee.config)==null?void 0:A.kind)??"jira")==="jira"?e.jsx(SC,{on:a.writes,canManage:a.canManage,local:_,onChanged:k}):null]}):null]},D)};return e.jsxs("section",{className:"integrations","aria-labelledby":"integrations-h",children:[e.jsxs("header",{className:"page-head",children:[e.jsx("h1",{id:"integrations-h",children:"Integrations"}),e.jsx("p",{className:"muted",children:"Services the orchestrator works with."}),a!=null&&a.claudeCodeServers?e.jsx("p",{className:"muted",children:a.claudeCodeServers===1?"Your tasks use the MCP server in your Claude Code.":`Your tasks use the ${a.claudeCodeServers} MCP servers in your Claude Code.`}):null]}),b?e.jsxs("p",{className:"error",role:"alert",children:["GitLab or GitHub did not connect: ",da(b)," Press Connect with GitLab or Connect with GitHub to try again."]}):null,a&&o?e.jsx(Kg,{what:"integrations"}):null,a?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"search",children:[e.jsx("span",{className:"visually-hidden",children:"Search integrations"}),e.jsx("input",{type:"search",placeholder:"Search integrations",value:m,onChange:D=>f(D.target.value)})]}),d?e.jsx(Oi,{what:"integrations",reason:d,onRetry:k}):null,K||B.length?e.jsxs("section",{className:"integration-group","aria-labelledby":"group-start",children:[e.jsx("h2",{id:"group-start",children:"Start here"}),e.jsx("p",{className:"muted",children:"Sign in once and the orchestrator reads it as you. Nothing there changes."}),a.signIn?null:e.jsx("p",{className:"warning",id:"start-no-return",children:"A sign-in returns to this orchestrator's own address, and none is set. Whoever runs it sets ORCHESTRATOR_PUBLIC_URL; until then these sign-ins are off."}),e.jsxs("ul",{className:"cards",children:[K?e.jsx("li",{className:"panel card",children:e.jsx(wC,{read:a,onToken:()=>{y("tracker"),requestAnimationFrame(()=>{var D;return(D=document.getElementById("card-tracker"))==null?void 0:D.scrollIntoView({block:"start"})})}})}):null,B.map(D=>e.jsx("li",{className:"panel card",children:e.jsx(NC,{service:D,signIn:a.signIn,onTools:()=>{v(!0),requestAnimationFrame(()=>{var te;return(te=document.getElementById("card-mine"))==null?void 0:te.scrollIntoView({block:"start"})})}})},D.id))]}),e.jsxs("p",{className:"muted small",children:["Another service with a remote MCP server is added by its address under ",e.jsx("button",{type:"button",className:"link",onClick:()=>{v(!0),requestAnimationFrame(()=>{var D;return(D=document.getElementById("card-mine"))==null?void 0:D.scrollIntoView({block:"start"})})},children:"Your MCP servers"}),"."]})]}):null,!ne.length&&!K&&!B.length?e.jsxs("p",{className:"muted",children:['No integration matches "',m,'".']}):ne.map(D=>e.jsxs("section",{className:"integration-group","aria-labelledby":`group-${D.id}`,children:[e.jsx("h2",{id:`group-${D.id}`,children:D.title}),e.jsx("p",{className:"muted",children:D.text}),e.jsx("ul",{className:"cards",children:D.cards.map(Z)})]},D.id))]}):d?e.jsx(be,{what:"integrations",reason:d,onRetry:k,panel:!0}):e.jsx(he,{what:"integrations",panel:!0})]})}const bC="See your Jira boards on Work and start agents on their issues. Nothing in Jira changes.";function wC({read:t,onToken:n}){var x,y;const a=t.integrations.find(b=>b.id==="tracker"),l=(x=t.jira.mcp)!=null&&x.connected?`mcp:${t.jira.mcp.name}`:((y=a==null?void 0:a.config)==null?void 0:y.kind)==="jira"&&a.token?"tracker":null,[o,c]=h.useState(null),[d,u]=h.useState(null),[m,f]=h.useState(!1);h.useEffect(()=>{l&&fn.boards(l).then(b=>c(b.boards.length),()=>c(null))},[l]);const g=()=>{f(!0),u(null),Dt.signInJira().then(b=>window.location.assign(b),b=>{u(b.message),f(!1)})};return e.jsx(ca,{id:"jira",name:"Jira",level:3,connected:!!l,about:l?`${l==="tracker"?"Read with an API token.":"Read through Atlassian as you."}${o===null?"":` ${o} ${o===1?"board":"boards"} on Work.`} Nothing in Jira changes.`:"See your Jira boards on Work and start agents on their issues. Nothing in Jira changes.",action:l?e.jsx("a",{className:"button",href:re("work"),children:"Open Work"}):e.jsx("button",{type:"button",disabled:m||!t.signIn,"aria-describedby":t.signIn?void 0:"start-no-return",onClick:g,children:"Sign in with Atlassian"}),other:!l&&t.canManage?e.jsxs("p",{children:["Read Jira, Linear or GitLab issues with an API token instead. ",e.jsx("button",{type:"button",className:"link",onClick:n,children:"Use an API token instead"})]}):void 0,error:d})}function NC({service:t,signIn:n,onTools:a}){var g,x;const[l,o]=h.useState(!1),[c,d]=h.useState(null),u=!!((g=t.server)!=null&&g.connected),m=()=>{o(!0),d(null),Dt.signInCatalog(t.id).then(y=>window.location.assign(y),y=>{d(`${y.message} Add it with a token under Your MCP servers instead.`),o(!1)})},f=((x=t.server)==null?void 0:x.tools)??0;return e.jsx(ca,{id:t.id,name:t.name,level:3,connected:u,about:u?`${f?`${f} ${f===1?"tool reads":"tools read"} ${t.name} as you in tasks you start.`:"No tool is allowed yet; load them under Your MCP servers."} Nothing in ${t.name} changes.`:t.about,action:u?e.jsx("button",{type:"button",className:"secondary",onClick:a,children:"Choose tools"}):e.jsxs("button",{type:"button",className:"secondary",disabled:l||!n,"aria-describedby":n?void 0:"start-no-return",onClick:m,children:["Sign in with ",t.name]}),error:c})}function SC({on:t,canManage:n,local:a,onChanged:l}){const o=h.useId(),[c,d]=h.useState(!1),[u,m]=h.useState(null),f=()=>{d(!0),m(null),Dt.saveWrites(!t).then(l,x=>m(x.message)).finally(()=>d(!1))},g=t?"On: moving a card on Work moves its issue in Jira.":"Off: the orchestrator reads Jira and changes nothing there.";return e.jsxs("div",{className:"moves-switch",children:[e.jsxs("button",{type:"button",role:"switch","aria-checked":t,"aria-describedby":o,disabled:c||!n,onClick:f,className:"switch",children:[e.jsx("span",{className:"switch-track","aria-hidden":"true",children:e.jsx("span",{className:"switch-knob"})}),"Move Jira issues when a card moves on Work"]}),e.jsxs("p",{id:o,className:"muted small",children:[g,!n&&!a?" An owner or an admin turns it on.":""]}),u?e.jsx("p",{className:"error",role:"alert",children:u}):null]})}function $l(t){return t.startsWith("file://")||t.startsWith("/")}function CC(t){if($l(t))return null;let n;try{n=new URL(t)}catch{return null}if(n.protocol!=="https:")return null;const a=n.pathname.replace(/^\/+|\/+$/g,"").replace(/\.git$/,"");return a.includes("/")?n.hostname==="github.com"?{kind:"github",apiUrl:"https://api.github.com",project:a}:{kind:"gitlab",apiUrl:`${n.origin}/api/v4`,project:a}:null}function $C({card:t,forges:n,repos:a,canManage:l,local:o,onChanged:c}){const d=rt[t.id].label,[u,m]=h.useState(null),f=a.filter(b=>b.configured!==!1),g=b=>{const N=n.flatMap(v=>v.repos.map(k=>({...k,kind:v.id}))).find(v=>v.repoId===b.id);return N?`${rt[N.kind].label}${N.project?`, ${N.project}`:""}`:$l(b.url)?"The orchestrator's own copy":"Nowhere yet: no token is set"},x=l&&!o?e.jsxs(e.Fragment,{children:[e.jsx(nC,{kind:t.id}),e.jsx(sC,{kind:t.id,repos:a,onChanged:c})]}):null;if(!f.length)return e.jsxs(e.Fragment,{children:[x,l?null:e.jsx("p",{className:"muted",children:"No repository is connected yet. An owner or an admin connects them on Repositories."})]});const y=f.filter(b=>$l(b.url));return e.jsxs(e.Fragment,{children:[x,e.jsxs("p",{children:["A request opens on ",d," when its repository is reached by its ",d," address and has a token here. Merging then happens on ",d,", with the team's reviewers and labels."]}),e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Repository"}),e.jsx("th",{scope:"col",children:"Read from"}),e.jsx("th",{scope:"col",children:"Requests open on"}),l?e.jsx("th",{scope:"col",children:e.jsx("span",{className:"visually-hidden",children:"Action"})}):null]})}),e.jsx("tbody",{children:f.map(b=>e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:b.name}),e.jsx("td",{children:$l(b.url)?o?"A path on this machine":"A path on the server":new URL(b.url).host}),e.jsx("td",{children:g(b)}),l?e.jsx("td",{children:$l(b.url)?null:e.jsx("button",{type:"button",className:"secondary small","aria-expanded":u===b.id,onClick:()=>m(u===b.id?null:b.id),"aria-label":`Set up ${d} for ${b.name}`,children:u===b.id?"Close":"Set up"})}):null]},b.id))})]}),u?(()=>{const b=f.find(v=>v.id===u),N=CC(b.url);return e.jsx(tN,{repo:b,...N?{suggest:N}:{}},b.id)})():null,l?null:e.jsx("p",{className:"muted",children:"An owner or admin sets where a repository's requests open."}),l&&y.length?e.jsxs("details",{children:[e.jsxs("summary",{children:["Open the requests of ",y.length===1?y[0].name:`${y.length} repositories read from a path`," on ",d]}),e.jsxs("p",{children:["The orchestrator reads ",y.map(b=>b.name).join(", ")," from a path on this machine, so their requests open on its own copy. To open them on ",d,", give each its ",d," address in the file ORCHESTRATOR_CONFIG names, restart the orchestrator, then press Set up here and enter a token:"]}),e.jsx("pre",{className:"pre mono",children:JSON.stringify({id:y[0].id,team:y[0].team,name:y[0].name,url:`https://${rt[t.id].homeHosts[0]}/<${rt[t.id].projectShape.replace("/",">/<")}>.git`},null,2)}),e.jsx("p",{className:"muted",children:"Only the url changes; the requests and tasks the orchestrator recorded stay with the repository. A private project is read with a token in that address, which the orchestrator masks wherever it shows it."})]}):null]})}function cj({error:t,id:n}){return t?e.jsx("p",{className:"error",role:"alert",id:n,children:t}):null}function uj(t){const[n,a]=h.useState(null),[l,o]=h.useState(null),[c,d]=h.useState(!1);return{error:n,notice:l,busy:c,run:(f,g)=>{a(null),o(null),d(!0),f().then(()=>{d(!1),o(g),t()},x=>{d(!1),a(x.message)})},done:f=>{a(null),o(f),t()},setNotice:o,setError:a}}function TC({card:t,read:n,onSaved:a,problem:l}){const[o,c]=h.useState(!1),[d,u]=h.useState(l),m=()=>{c(!0),u(null),Dt.addSlack().then(f=>window.location.assign(f),f=>{u(f.message),c(!1)})};return e.jsx(ca,{id:"slack",name:"Slack",level:3,connected:!1,about:Ri.slack.text,action:e.jsx("button",{type:"button",disabled:o,onClick:m,children:"Add to Slack"}),other:e.jsx(dj,{card:t,read:n,onSaved:a,added:!1}),error:d})}function dj({card:t,read:n,onSaved:a,added:l}){const[o,c]=h.useState(""),[d,u]=h.useState(t.events.length?t.events:n.slackEvents.map(y=>y.kind)),m=uj(a),f=h.useId();if(!n.canManage)return t.state==="off"?e.jsx("p",{className:"muted",children:"An admin connects a Slack channel."}):e.jsxs("p",{children:["Posting ",t.events.length," kinds of event to the channel."]});const g=y=>{y.preventDefault(),m.run(()=>Dt.saveSlack({...o?{webhookUrl:o}:{},events:d}).finally(()=>c("")),"Saved. The webhook address is sealed; the orchestrator never shows it again.")},x=y=>u(d.includes(y)?d.filter(b=>b!==y):[...d,y]);return e.jsxs("form",{className:"form",onSubmit:g,"aria-label":"Slack notifications",children:[l?e.jsx("p",{role:"status",children:"Slack added the channel. Pick the events to post below."}):null,t.state==="off"&&!t.addable&&t.redirectUri?e.jsxs("p",{className:"muted small",children:["To add Slack in one press, whoever runs this orchestrator registers a Slack app with the redirect address ",t.redirectUri," and sets ORCHESTRATOR_SLACK_CLIENT_ID and ORCHESTRATOR_SLACK_CLIENT_SECRET."]}):null,e.jsxs("label",{children:["Incoming webhook address",e.jsx("input",{type:"password",autoComplete:"off",value:o,onChange:y=>c(y.target.value),placeholder:t.state==="off"?"https://hooks.slack.com/services/...":"set; empty keeps it",required:t.state==="off","aria-describedby":m.error?f:void 0})]}),e.jsxs("fieldset",{className:"teams",children:[e.jsx("legend",{children:"Post when"}),n.slackEvents.map(y=>e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:d.includes(y.kind),onChange:()=>x(y.kind)}),y.label]},y.kind))]}),t.delivery?e.jsxs("p",{className:t.delivery.ok?"muted":"error",children:["Last message ",Bi(t.delivery.at),": ",t.delivery.detail]}):null,n.vault?null:e.jsx("p",{className:"error",children:"Set ORCHESTRATOR_SECRET_KEY on the server to store a webhook address."}),e.jsx(cj,{error:m.error,id:f}),m.notice?e.jsx("p",{role:"status",children:m.notice}):null,e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",disabled:m.busy||!n.vault,children:"Save"}),t.state!=="off"?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"secondary",disabled:m.busy,onClick:()=>m.run(Dt.testSlack,"Test message sent; the last message line says how it went."),children:"Send a test message"}),e.jsx(qe,{trigger:"Disconnect",triggerLabel:"Disconnect Slack",consequence:"The channel stops hearing about requests and tasks at once, and the webhook address is deleted; connecting again needs it pasted again.",confirm:"Disconnect Slack",keep:"Keep Slack",onConfirm:()=>Dt.removeSlack().then(()=>m.done("Slack is disconnected and its webhook address removed."))})]}):null]})]})}function EC({repos:t}){const[n,a]=h.useState(null),[l,o]=h.useState(null),[c,d]=h.useState(null),[u,m]=h.useState(null),f=()=>{m(null),U("GET","/api/work/boards/teams").then(y=>a(y.boards),y=>m(y.message))};h.useEffect(()=>{f()},[]);const g=[...new Set(t.map(y=>y.team))].sort(),x=(y,b)=>{o(null),U("PUT","/api/work/boards/teams",{boards:[{boardId:y.boardId,team:b||null}]}).then(N=>{a(N.boards),d(b?`${y.name} is shown to ${b}.`:`${y.name} is shown to owners and admins only.`)},N=>o(N.message))};return e.jsxs("section",{"aria-label":"Boards and teams",children:[e.jsx("h4",{children:"Boards and teams"}),e.jsx("p",{className:"muted",children:"A board shows to the team it is mapped to, and to owners and admins; one mapped to none shows to owners and admins only."}),c?e.jsx("p",{role:"status",children:c}):null,l?e.jsx("p",{className:"error",role:"alert",children:l}):null,n?n.length?e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Board"}),e.jsx("th",{scope:"col",children:"Shown to"})]})}),e.jsx("tbody",{children:n.map(y=>e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:y.name}),e.jsx("td",{children:e.jsxs("select",{"aria-label":`Team for ${y.name}`,value:y.team??"",onChange:b=>x(y,b.target.value),children:[e.jsx("option",{value:"",children:"None: owners and admins only"}),g.map(b=>e.jsx("option",{value:b,children:b},b))]})})]},y.boardId))})]}):e.jsx("p",{className:"muted",children:"The tracker lists no board for the organization yet."}):u?e.jsx(be,{what:"the boards",reason:u,onRetry:f}):e.jsx(he,{what:"the boards"})]})}function RC({card:t,canManage:n,onSaved:a,repos:l,local:o}){const[c,d]=h.useState(t.config??{kind:"jira",url:""}),[u,m]=h.useState(""),f=uj(a),g=h.useId(),x=t.token?e.jsxs("p",{children:[o?"Read with your API token":`Issues are read with a token set by ${t.token.setBy} on ${Bi(t.token.setAt)}`,": a task gets its issue's text, description, acceptance criteria, sub-tasks and latest comments."]}):e.jsx("p",{className:"muted",children:"No token is set, so a task gets its issue's link only."});if(!n)return e.jsxs(e.Fragment,{children:[t.config?e.jsxs("p",{children:["Tasks link to ",t.config.kind," issues at ",e.jsx("span",{className:"mono",children:t.config.url}),"."]}):e.jsx("p",{className:"muted",children:"An admin connects the issue tracker."}),t.config?x:null]});const y=b=>{b.preventDefault(),f.run(()=>Dt.saveTracker({...c,...u?{token:u}:{}}).finally(()=>m("")),"Saved. A task's issue can now be named by its key.")};return e.jsxs("form",{className:"form",onSubmit:y,"aria-label":"Issue tracker",children:[e.jsx(Pe,{label:"Tracker",value:c.kind,onChange:b=>d({kind:b,url:""}),options:[{value:"jira",label:"Jira"},{value:"linear",label:"Linear"},{value:"gitlab",label:"GitLab issues"},{value:"github",label:"GitHub issues"}]}),e.jsxs("label",{children:["Address",e.jsx("input",{value:c.url,onChange:b=>d({...c,url:b.target.value}),placeholder:c.kind==="jira"?"https://acme.atlassian.net":c.kind==="linear"?"https://linear.app/acme":`https://${rt[c.kind].homeHosts[0]}`,required:c.kind==="jira"||c.kind==="linear","aria-describedby":f.error?g:void 0})]}),c.kind==="jira"?e.jsxs("label",{children:["Account email",e.jsx("input",{type:"email",value:c.email??"",onChange:b=>d({...c,email:b.target.value}),placeholder:"the account the API token belongs to","aria-describedby":f.error?g:void 0})]}):null,c.kind!=="github"?e.jsxs("label",{children:[c.kind==="jira"?"API token":c.kind==="linear"?"API key":"Access token",e.jsx("input",{type:"password",autoComplete:"off",value:u,onChange:b=>m(b.target.value),placeholder:t.token?"set; empty keeps it while the site stays":"read-only; leave empty to link issues without reading them","aria-describedby":f.error?g:void 0})]}):null,t.config?x:null,t.config&&t.token&&!o?e.jsx(EC,{repos:l}):null,e.jsx(cj,{error:f.error,id:g}),f.notice?e.jsx("p",{role:"status",children:f.notice}):null,e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",className:"secondary",disabled:f.busy,children:"Save"}),t.state!=="off"?e.jsx(qe,{trigger:"Disconnect",triggerLabel:"Disconnect the issue tracker",consequence:"Tasks get an issue's link only from now on, issue keys stop becoming links, and the token is deleted.",confirm:"Disconnect tracker",keep:"Keep tracker",onConfirm:()=>Dt.removeTracker().then(()=>f.done("The issue tracker is disconnected and its token removed."))}):null]})]})}function PC({card:t,repos:n,onOpened:a}){var m;const[l,o]=h.useState(null),[c,d]=h.useState(null),u=f=>f.state==="connected"?"Connected":f.state==="requested"&&f.request?e.jsxs("a",{href:f.request.url,children:["Requested in #",f.request.number]}):"Not set up";return e.jsxs(e.Fragment,{children:[t.missing.length?e.jsx("ul",{className:"findings",children:t.missing.map(f=>e.jsx("li",{className:"error",children:f},f))}):null,t.endpoint?e.jsxs("p",{children:["Teammates reach it at ",e.jsx("span",{className:"mono",children:t.endpoint}),". Turning it on for a team opens a request that adds it to the team's ",e.jsx("code",{children:".mcp.json"}),"; once merged, each teammate's Claude Code asks them to approve it in the browser the first time, as themselves. An API key works too, for automation."]}):null,c?e.jsx("p",{role:"status",children:c}):null,e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Repository"}),e.jsx("th",{children:"State"}),e.jsx("th",{children:"Enabled"}),e.jsx("th",{children:e.jsx("span",{className:"visually-hidden",children:"Action"})})]})}),e.jsx("tbody",{children:t.repos.map(f=>{const g=n.find(x=>x.id===f.repoId);return e.jsxs("tr",{children:[e.jsx("td",{children:f.name}),e.jsx("td",{children:u(f)}),e.jsx("td",{children:f.enabledBy&&f.enabledAt?`${f.enabledBy}, ${Bi(f.enabledAt)}`:""}),e.jsx("td",{children:f.state==="off"&&f.canChange&&!t.missing.length&&(g!=null&&g.head)&&l!==f.repoId?e.jsx("button",{type:"button",className:"small",onClick:()=>o(f.repoId),children:"Set up"}):null})]},f.repoId)})})]}),l?e.jsx(Vn,{repoId:l,head:((m=n.find(f=>f.id===l))==null?void 0:m.head)??"",steps:{proposal:()=>Dt.mcpProposal(l),send:(f,g)=>{var x;return Dt.proposeMcp(l,((x=n.find(y=>y.id===l))==null?void 0:x.head)??"",f,g)}},submitLabel:"Review the request",onOpened:f=>{o(null),d(gh(f)),a()},onCancel:()=>o(null),children:()=>{var f;return e.jsxs(e.Fragment,{children:[e.jsxs("h4",{children:["Add the orchestrator's MCP server to ",(f=n.find(g=>g.id===l))==null?void 0:f.name]}),e.jsx("pre",{className:"pre mono",children:JSON.stringify({mcpServers:{"teamhandbook-orchestrator":t.entry}},null,2)})]})}}):null]})}const AC=["ArrowDown","ArrowUp","Home","End"];function Ld(t){var o;if(!AC.includes(t.key))return;const n=[...t.currentTarget.querySelectorAll('[role="option"]')];if(!n.length)return;t.preventDefault();const a=n.indexOf(document.activeElement),l=t.key==="Home"?0:t.key==="End"?n.length-1:Math.min(Math.max(a+(t.key==="ArrowDown"?1:-1),0),n.length-1);(o=n[l])==null||o.focus()}function hj(t,n){return(n>=0?t===n:t===0)?0:-1}const Fa=(t,n="")=>`/api/projects/${encodeURIComponent(t)}${n}`,ua={read:t=>U("GET",Fa(t,"/task-tools")),addSource:(t,n)=>U("POST",Fa(t,"/skill-sources"),n).then(a=>a.source),refresh:(t,n)=>U("POST",Fa(t,`/skill-sources/${encodeURIComponent(n)}/refresh`)).then(a=>a.source),removeSource:(t,n)=>U("DELETE",Fa(t,`/skill-sources/${encodeURIComponent(n)}`)),addServer:(t,n)=>U("POST",Fa(t,"/mcp-servers"),n).then(a=>a.server),removeServer:(t,n)=>U("DELETE",Fa(t,`/mcp-servers/${encodeURIComponent(n)}`)),skills:t=>U("GET",Fa(t,"/task-skills"))};function IC(t){return t.kind==="folder"?t.path:t.url}function OC(t){const n=t.trim();return/^(~|\/)/.test(n)?{folder:n}:{url:n}}function LC(t){const n={};for(const a of t.split(`
|
|
80
|
+
`)){const l=a.indexOf("="),o=(l<0?a:a.slice(0,l)).trim();o&&(n[o]=l<0?"":a.slice(l+1).trim())}return n}function mj({project:t,onAdded:n,onCancel:a}){const[l,o]=h.useState(""),[c,d]=h.useState(!1),[u,m]=h.useState(null),f=g=>{g.preventDefault(),d(!0),m(null),ua.addSource(t,OC(l)).then(x=>{o(""),n(x)},x=>m(x.message)).finally(()=>d(!1))};return e.jsxs("form",{className:"form inline-form",onSubmit:f,"aria-label":"Add a skill repository",children:[e.jsxs("label",{children:["Folder or git address",e.jsx("input",{value:l,onChange:g=>o(g.target.value),placeholder:"~/code/team-skills or https://github.com/team/skills",required:!0,autoComplete:"off",spellCheck:!1})]}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",className:"secondary",disabled:c||!l.trim(),children:c?"Reading…":"Add a skill repository"}),e.jsx("button",{type:"button",className:"ghost",onClick:a,disabled:c,children:"Cancel"})]}),u?e.jsx("p",{className:"error",role:"alert",children:u}):null]})}function FC({project:t,onAdded:n,onCancel:a}){const[l,o]=h.useState("command"),[c,d]=h.useState(""),[u,m]=h.useState(""),[f,g]=h.useState(""),[x,y]=h.useState(""),[b,N]=h.useState(""),[v,k]=h.useState(!1),[S,$]=h.useState(null),E=C=>{C.preventDefault(),k(!0),$(null);const R=LC(b),P=Object.keys(R).length?R:void 0,M=l==="command"?{name:c.trim(),command:u.trim(),...f.trim()?{args:f.trim().split(/\s+/)}:{},...P?{env:P}:{}}:{name:c.trim(),url:x.trim(),...P?{headers:P}:{}};ua.addServer(t,M).then(O=>{d(""),m(""),g(""),y(""),N(""),n(O)},O=>$(O.message)).finally(()=>k(!1))};return e.jsxs("form",{className:"form",onSubmit:E,"aria-label":"Add an MCP server",children:[e.jsxs("label",{children:["Name",e.jsx("input",{value:c,onChange:C=>d(C.target.value),placeholder:"docs",required:!0,autoComplete:"off",spellCheck:!1})]}),e.jsx(Pe,{label:"Runs as",value:l,onChange:C=>o(C),options:[{value:"command",label:"A command on this machine"},{value:"url",label:"An address"}]}),l==="command"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:["Command",e.jsx("input",{value:u,onChange:C=>m(C.target.value),placeholder:"npx",required:!0,autoComplete:"off",spellCheck:!1})]}),e.jsxs("label",{children:["Arguments",e.jsx("input",{value:f,onChange:C=>g(C.target.value),placeholder:"-y docs-server",autoComplete:"off",spellCheck:!1})]})]}):e.jsxs("label",{children:["Address",e.jsx("input",{value:x,onChange:C=>y(C.target.value),placeholder:"https://mcp.example.com/mcp",required:!0,autoComplete:"off",spellCheck:!1})]}),e.jsxs("label",{children:[l==="command"?"Environment, one NAME=value a line":"Headers, one NAME=value a line",e.jsx("textarea",{value:b,onChange:C=>N(C.target.value),rows:2,autoComplete:"off",spellCheck:!1})]}),S?e.jsx("p",{className:"error",role:"alert",children:S}):null,e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",className:"secondary",disabled:v,children:"Add the MCP server"}),e.jsx("button",{type:"button",className:"ghost",onClick:a,disabled:v,children:"Cancel"})]})]})}function jh({project:t,canChange:n}){const[a,l]=h.useState(null),[o,c]=h.useState(null),[d,u]=h.useState(null),[m,f]=h.useState(0),[g,x]=h.useState(!1),[y,b]=h.useState(null),[N,v]=h.useState(null),[k,S]=h.useState(null);h.useEffect(()=>{u(null),ua.read(t).then(I=>{l(I.skillSources),c(I.mcpServers)},I=>u(I.message))},[t,m]);const $=()=>f(I=>I+1),E=(N==null?void 0:N.kind)==="source"?(a==null?void 0:a.find(I=>I.id===N.id))??null:null,C=(N==null?void 0:N.kind)==="server"?(o==null?void 0:o.find(I=>I.id===N.id))??null:null,R=(I,L)=>v((N==null?void 0:N.kind)===I&&N.id===L?null:{kind:I,id:L}),P=(I,L,K,B)=>({className:"tool-row",role:"option",tabIndex:hj(K,(N==null?void 0:N.kind)===I?B.findIndex(ne=>ne.id===N.id):-1),"aria-selected":(N==null?void 0:N.kind)===I&&N.id===L,onClick:()=>R(I,L),onKeyDown:ne=>{ne.key!=="Enter"&&ne.key!==" "||(ne.preventDefault(),R(I,L))}}),M=()=>{v(null),$()},O=(a??[]).filter(I=>I.kind==="git"),_=()=>{x(!0),b(null),Promise.all(O.map(I=>ua.refresh(t,I.id))).then(()=>{b(`Read ${O.length===1?"the git repository":`${O.length} git repositories`} again.`),$()},I=>u(I.message)).finally(()=>x(!1))};return e.jsxs("section",{className:"section","aria-labelledby":"task-tools-h",children:[e.jsxs("h2",{id:"task-tools-h",children:["Skills and MCP servers for tasks here"," ",e.jsx(Ie,{label:"skills and MCP servers for tasks here",children:"A task here runs with the person's own Claude Code, its skills, plugins and MCP servers included, and with what is added here on top. These are kept by the orchestrator and given to each task; nobody's own settings are changed. An MCP server's values are sealed and only their names are shown again. Pick a row to remove it."}),n?E?e.jsx(qe,{small:!0,trigger:"Remove…",triggerLabel:`Remove ${E.name}`,consequence:`Tasks here stop reading the skills of ${E.name}. ${E.kind==="git"?"The orchestrator's copy of it is deleted; the repository is not touched.":"The folder is not touched."}`,confirm:"Remove repository",keep:"Keep it",onConfirm:()=>ua.removeSource(t,E.id).then(M)},E.id):C?e.jsx(qe,{small:!0,trigger:"Remove…",triggerLabel:`Remove ${C.name}`,consequence:`Tasks here start without ${C.name}, and its sealed values are deleted.`,confirm:"Remove server",keep:"Keep it",onConfirm:()=>ua.removeServer(t,C.id).then(M)},C.id):null:null]}),d?e.jsx(be,{what:"the skills and MCP servers",reason:d,onRetry:$}):!a||!o?e.jsx(he,{what:"the skills and MCP servers"}):e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:"Skill repositories"}),a.length?e.jsx("ul",{className:"tool-list",role:"listbox","aria-label":"Skill repositories",onKeyDown:Ld,children:a.map((I,L)=>e.jsxs("li",{...P("source",I.id,L,a),children:[I.name," ",e.jsx("span",{className:"mono",dir:"auto",children:IC(I)})," ",e.jsxs("span",{className:"muted",children:[I.skills.length," ",I.skills.length===1?"skill":"skills"]})]},I.id))}):e.jsx("p",{className:"muted",children:"No skill repository yet."}),n&&O.length?e.jsx("p",{children:e.jsx("button",{type:"button",className:"ghost small",disabled:g,onClick:_,children:g?"Reading…":"Read the git repositories again"})}):null,y?e.jsx("p",{className:"notice",role:"status",children:y}):null,n?k==="source"?e.jsx(mj,{project:t,onCancel:()=>S(null),onAdded:I=>{S(null),b(`Added ${I.name}: ${I.skills.length} ${I.skills.length===1?"skill":"skills"} for tasks here.`),$()}}):e.jsx("p",{children:e.jsx("button",{type:"button",className:"secondary small",onClick:()=>S("source"),children:"Add a skill repository"})}):null,e.jsx("h3",{children:"MCP servers"}),o.length?e.jsx("ul",{className:"tool-list",role:"listbox","aria-label":"MCP servers",onKeyDown:Ld,children:o.map((I,L)=>{const K=I.transport==="stdio"?I.env:I.headers;return e.jsxs("li",{...P("server",I.id,L,o),children:[I.name," ",e.jsx("span",{className:"mono",dir:"auto",children:I.transport==="stdio"?[I.command,...I.args].join(" "):I.url}),K.length?e.jsxs("span",{className:"muted",children:[" with ",K.join(", ")]}):null]},I.id)})}):e.jsx("p",{className:"muted",children:"No MCP server yet."}),n?k==="server"?e.jsx(FC,{project:t,onCancel:()=>S(null),onAdded:I=>{S(null),b(`Added ${I.name} for tasks here.`),$()}}):e.jsx("p",{children:e.jsx("button",{type:"button",className:"secondary small",onClick:()=>S("server"),children:"Add an MCP server"})}):null]})]})}function MC({repo:t,onRenamed:n}){const[a,l]=h.useState(t.name),[o,c]=h.useState(!1),[d,u]=h.useState(null),[m,f]=h.useState(null),g=x=>{x.preventDefault(),c(!0),u(null),f(null),Je.rename(t.id,a).then(({project:y})=>{l(y.name),f(`The project is now named ${y.name}.`),n()},y=>u(y.message)).finally(()=>c(!1))};return e.jsxs(e.Fragment,{children:[e.jsxs("form",{className:"form inline-form",onSubmit:g,"aria-label":"Project name",children:[e.jsxs("label",{children:["Name",e.jsx("input",{value:a,onChange:x=>l(x.target.value),maxLength:80,required:!0})]}),e.jsx("button",{type:"submit",className:"secondary",disabled:o||!a.trim()||a.trim()===t.name,children:"Rename"})]}),d?e.jsx("p",{className:"error",role:"alert",children:d}):null,m?e.jsx("p",{className:"notice",role:"status",children:m}):null]})}function _C({repo:t,onChanged:n}){const[a,l]=h.useState(null),[o,c]=h.useState(t.skillsFrom??""),[d,u]=h.useState(!1),[m,f]=h.useState(null),[g,x]=h.useState(null);h.useEffect(()=>{Ce.repos().then(b=>l(b.filter(N=>N.kind!=="code"&&N.id!==t.id&&N.configured!==!1)),b=>f(b.message))},[t.id]);const y=b=>{const N=o;c(b),u(!0),f(null),x(null),Je.readSkillsFrom(t.id,b||null).then(()=>{const v=a==null?void 0:a.find(k=>k.id===b);x(v?`Tasks in ${t.name} read the skills of ${v.name}.`:`Tasks in ${t.name} read no team's skills.`),n()},v=>{c(N),f(v.message)}).finally(()=>u(!1))};return e.jsxs(e.Fragment,{children:[a?e.jsx(Pe,{label:"Skills its tasks read",value:o,onChange:y,disabled:d,options:[{value:"",label:"None"},...a.map(b=>({value:b.id,label:b.name}))]}):m?null:e.jsx(he,{what:"the skills projects"}),m?e.jsx("p",{className:"error",role:"alert",children:m}):null,g?e.jsx("p",{className:"notice",role:"status",children:g}):null]})}function UC({repo:t,onMade:n}){const[a,l]=h.useState(!1),[o,c]=h.useState(null),d=()=>{l(!0),c(null),Je.gitInit(t.id).then(n,u=>{c(u.message),l(!1)})};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"actions",children:e.jsx("button",{type:"button",className:"secondary",disabled:a,onClick:d,children:"Make this a Git repository"})}),e.jsx("p",{className:"muted",children:"Starts Git in this folder so its history is kept. No file is added or committed; a task's review then offers to commit what it changed."}),o?e.jsx("p",{className:"error",role:"alert",children:o}):null]})}function pj({repo:t,me:n,git:a,onChanged:l}){const o=Me(n)&&t.configured!==!1;return e.jsxs("section",{className:"panel","aria-labelledby":"project-h",children:[e.jsxs("h2",{id:"project-h",children:["Project ",e.jsx(Ie,{label:"the project's name",children:t.source==="file"?"Its name is set in the orchestrator's configuration file, by whoever runs the orchestrator.":"Renaming changes only the name it shows under. Its address and its tasks stay as they are."})]}),t.source==="file"?e.jsx("p",{children:t.name}):o?e.jsx(MC,{repo:t,onRenamed:l}):e.jsx("p",{children:t.name}),t.kind==="code"&&t.source!=="file"&&o?e.jsx(_C,{repo:t,onChanged:l}):null,a==="none"&&o?e.jsx(UC,{repo:t,onMade:l}):null,a&&a!=="none"?e.jsx("p",{className:"muted",children:"This folder is a Git repository: a task's review offers to commit what it changed."}):null,Me(n)&&t.source==="orchestrator"?e.jsx("div",{className:"actions",children:e.jsx(qe,{danger:!0,trigger:"Remove project…",consequence:n.mode==="local"?`The orchestrator's copy of ${t.name} is deleted. ${t.name} itself is not touched, and its requests and tasks stay readable here.`:`The orchestrator's copy of ${t.name}, its forge access and sealed token are deleted. The team's repository is not touched, and the orchestrator's records of its requests, tasks and skill use stay.`,confirm:"Remove project",keep:"Keep project",onConfirm:()=>Ce.disconnect(t.id).then(()=>Ge(`${re("tasks")}?removed=${encodeURIComponent(t.name)}`))})}):null]})}function DC({repo:t,data:n,me:a,editable:l,onOpened:o,onRenamed:c}){const d=a.mode==="local",{inventory:u}=n,m=u.team,[f,g]=h.useState(null),x=N=>{g(null),o(N)},y=N=>{g(null),o(N,`Request #${N.number} opened on ${N.branch}. Nothing is reported until it is merged and each teammate agrees on their own machine.`)},b={repoId:t.id,head:u.head,onOpened:x,onCancel:()=>g(null)};return e.jsxs(e.Fragment,{children:[e.jsx(pj,{repo:t,me:a,onChanged:c}),e.jsx(jh,{project:t.id,canChange:l}),e.jsxs("section",{className:"panel","aria-labelledby":"team-h",children:[e.jsxs("h2",{id:"team-h",children:["Requests to this repository",l&&!(m!=null&&m.problem)?e.jsx("button",{type:"button",className:"secondary small",onClick:()=>g({type:"naming"}),children:"Edit naming"}):null,l&&!(m!=null&&m.problem)?e.jsx("button",{type:"button",className:"secondary small",onClick:()=>g({type:"team"}),children:"Edit reviewers and labels"}):null]}),(f==null?void 0:f.type)==="naming"?e.jsx(Qw,{...b,team:m}):null,(f==null?void 0:f.type)==="team"?e.jsx(Vw,{...b,team:m}):null,m?m.problem?e.jsx("p",{className:"error",children:m.problem}):e.jsxs("dl",{className:"facts wide",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Commit prefix"}),e.jsx("dd",{className:"mono",children:m.commitPrefixProblem?"not used, see Setup":m.commitPrefix||"none"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Branch example"}),e.jsx("dd",{className:"mono",children:m.branchExample||"none"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Reviewers"}),e.jsx("dd",{children:m.reviewers===void 0?"not recorded":m.reviewers.join(", ")||"none"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Labels"}),e.jsx("dd",{children:m.labels===void 0?"not recorded":m.labels.join(", ")||"none"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"TeamHandbook's files"}),e.jsx("dd",{children:m.scaffoldVersion?`written by TeamHandbook ${m.scaffoldVersion}`:"version not recorded"})]}),d?null:e.jsxs("div",{children:[e.jsx("dt",{children:"Skill use"}),e.jsx("dd",{children:m.usageEndpoint?"reported by teammates who agreed":"not reported"})]})]}):e.jsx("p",{className:"muted",children:"No .teamhandbook.json: set up before TeamHandbook recorded one."}),l&&(f==null?void 0:f.type)==="usage"?e.jsx(Yw,{repoId:t.id,head:u.head,action:f.action,onOpened:f.action==="ask"?y:x,onCancel:()=>g(null)},f.action):null,l&&!d&&(f==null?void 0:f.type)!=="usage"&&!(m!=null&&m.problem)?m!=null&&m.usageEndpoint?e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",className:"secondary",onClick:()=>g({type:"usage",action:"rotate"}),children:"Give the team a new usage address"}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>g({type:"usage",action:"stop"}),children:"Stop asking for skill use"})]}):e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",onClick:()=>g({type:"usage",action:"ask"}),children:"Ask this team to report skill use"}),e.jsx("span",{className:"muted",children:"Opens a request; each teammate still agrees on their own machine before anything is sent."})]}):null]}),Me(a)?e.jsxs("section",{className:"panel","aria-labelledby":"forge-h",children:[e.jsx("h2",{id:"forge-h",children:d?"Where requests open":"Forge access"}),e.jsxs("p",{children:["Where requests for ",t.name," open, and the token they open with, are set under ",e.jsx("a",{href:re("integrations",t.id),children:"Integrations"}),"."]})]}):null]})}const BC={google:"Google",github:"GitHub",microsoft:"Microsoft"},qC={owner:"You'll have full control of the organization: its members and roles, repositories, settings and every team's work.",admin:"You'll manage members, repositories and settings, and see every team's skills, MCP servers and commands.",member:"You'll see every team's skills, MCP servers and commands, and propose changes to them for the team to review.",viewer:"You'll see every team's skills, tasks and requests, without changing anything."};function WC(t){return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function zC({token:t,onJoined:n,cloud:a}){const[l,o]=h.useState(null),[c,d]=h.useState(null),[u,m]=h.useState({name:"",password:""}),[f,g]=h.useState(null),[x,y]=h.useState(!1),b=h.useId();h.useEffect(()=>{nf.read(t).then($=>o({...$.invite,org:$.org,sso:$.sso,signedIn:$.signedIn,emailMatches:$.emailMatches}),$=>d($.message))},[t]);const N=()=>{y(!0),g(null),ut.me().then($=>ut.join(t,$.csrf)).then($=>window.location.assign($.next),$=>{g($.message),y(!1)})},v=$=>{$.preventDefault(),y(!0),g(null),nf.accept(t,u).then(()=>{window.location.hash="/",n()},E=>{g(E.message),y(!1)})},k=f?{"aria-invalid":!0,"aria-describedby":b}:{},S=a?"section":"form";return e.jsx("main",{className:"gate",children:e.jsxs(S,{className:"panel form",onSubmit:a?void 0:v,"aria-labelledby":"join-h",children:[e.jsxs("div",{className:"brand",children:["TeamHandbook ",e.jsx("span",{children:"Orchestrator"})]}),e.jsx("h1",{id:"join-h",children:l?`Join ${l.org}`:"Join the organization"}),c?e.jsx("p",{className:"error",role:"alert",children:c}):null,c&&a?e.jsx(Ll,{config:a}):null,!l&&!c?e.jsx("p",{className:"muted",children:"Reading the invitation…"}):null,l?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:[l.invitedBy," invited ",l.email," to ",l.org," as ",za[l.role],l.teams.length?`, team owner of ${l.teams.join(", ")}`:"","."]}),e.jsxs("p",{children:[qC[l.role]," ",e.jsxs(Ie,{label:"this invitation",children:[l.teams.length?`As team owner of ${l.teams.join(", ")}, you also edit ${l.teams.length===1?"that team's":"those teams'"} skills, MCP servers and commands. `:"","The link works once, until ",WC(l.expiresAt),"."]})]}),a&&l.signedIn&&l.emailMatches?e.jsxs(e.Fragment,{children:[f?e.jsx("p",{className:"error",role:"alert",children:f}):null,e.jsxs("button",{type:"button",onClick:N,disabled:x,children:["Join ",l.org]}),e.jsx(Si,{privacyUrl:a.privacyUrl,termsUrl:a.termsUrl})]}):a?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"muted",children:l.signedIn?`You are signed in with another address; sign in with the account that has ${l.email}.`:`Sign in with the account that has ${l.email}.`}),a.providers.map($=>e.jsxs("form",{method:"post",action:`/api/auth/${$}/start`,children:[e.jsx("input",{type:"hidden",name:"invite",value:t}),e.jsxs("button",{type:"submit",children:["Sign in with ",BC[$]]})]},$)),e.jsx(Ll,{config:a}),e.jsx(Si,{privacyUrl:a.privacyUrl,termsUrl:a.termsUrl})]}):l.ssoRequired?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Addresses at ",l.email.slice(l.email.lastIndexOf("@")+1)," sign in with SSO, as ",l.email,"."]}),e.jsx("a",{className:"button",href:Pn("/api/auth/oidc/start"),children:"Sign in with SSO"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:["Name",e.jsx("input",{autoComplete:"name",value:u.name,onChange:$=>m({...u,name:$.target.value}),...k})]}),e.jsxs("label",{children:["Password",e.jsx("input",{type:"password",autoComplete:"new-password",minLength:12,value:u.password,onChange:$=>m({...u,password:$.target.value}),required:!0,...k})]}),f?e.jsx("p",{className:"error",role:"alert",id:b,children:f}):null,e.jsx("button",{type:"submit",disabled:x,children:"Join and sign in"}),l.sso?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"muted",children:["Or sign in through your identity provider with ",l.email,"; the invitation is used the same way."]}),e.jsx("a",{className:"button secondary",href:Pn("/api/auth/oidc/start"),children:"Sign in with SSO"})]}):null]})]}):null]})})}function _l({name:t,why:n,danger:a=!1,children:l}){const o=h.useId();return e.jsxs("section",{className:`turn${a?" turn-danger":""}`,"aria-labelledby":o,children:[e.jsxs("div",{className:"turn-side",children:[e.jsx("h2",{id:o,children:t}),n?e.jsx("p",{className:"turn-why",children:n}):null]}),e.jsx("div",{className:"turn-body",children:l})]})}const Hf={"task-folders":"task folders",copies:"backups",repositories:"repository copies",attachments:"attached files",database:"task records"},HC=3,GC=.1,Gf=5*1024**3;function Ku(t){if(t>=1024**3){const n=t/1073741824;return`${n<10?n.toFixed(1):Math.round(n)} GB`}return t>=1024**2?`${Math.round(t/1024**2)} MB`:`${Math.max(1,Math.round(t/1024))} KB`}const KC=t=>t.length<2?t.join(""):`${t.slice(0,-1).join(", ")} and ${t.at(-1)}`;function YC(t){const n=Object.keys(Hf).filter(o=>t.parts[o]>=t.total*GC&&t.parts[o]>0).sort((o,c)=>t.parts[c]-t.parts[o]).slice(0,HC),a=t.total-n.reduce((o,c)=>o+t.parts[c],0),l=[...n.map(o=>`${Ku(t.parts[o])} of ${Hf[o]}`),...a>0?[`${Ku(a)} of the rest`]:[]];return`It keeps ${t.partial?"at least ":""}${Ku(t.total)} here: ${KC(l)}.`}function VC(){const[t,n]=h.useState(null);return h.useEffect(()=>{let a=!0;return U("GET","/api/data/size").then(l=>a&&n(l),()=>{}),()=>{a=!1}},[]),t?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:t.total>=Gf?"waiting":void 0,children:YC(t)}),t.total>=Gf?e.jsx("p",{className:"muted",children:"Task folders of ended tasks go when the orchestrator starts, task logs after the days you set for them, and fewer backups are kept with ORCHESTRATOR_BACKUP_KEEP."}):null,t.parts.copies>0?e.jsxs("p",{className:"muted small",children:[e.jsx(mt,{text:`${t.path}/backups`})," the last ",t.keep," kept; ORCHESTRATOR_BACKUP_HOURS and ORCHESTRATOR_BACKUP_KEEP set how often and how many."]}):null]}):null}const fj="#/account-deleted";function QC(t){const[n,a]=h.useState(null);return h.useEffect(()=>{vi.orgs().then(l=>a({orgs:l.orgs.length?l.orgs:[{tenant:l.default,name:"this organization",role:t.role}],defaultOrg:l.default}),()=>a({orgs:[{tenant:"",name:"this organization",role:t.role}],defaultOrg:""}))},[t.id]),n}function JC({me:t,orgs:n,defaultOrg:a,onRenamed:l}){const[o,c]=h.useState(t.name),[d,u]=h.useState(null),[m,f]=h.useState(null),g=h.useId(),x=y=>{y.preventDefault(),u(null),f(null),Promise.all(n.map(b=>vi.rename(b.tenant,a,o))).then(()=>{f(n.length>1?`Your name is ${o.trim()} in each of your ${n.length} organizations.`:`Your name is ${o.trim()}.`),l()},b=>u(b.message))};return e.jsxs(_l,{name:"Name",why:"How every organization you belong to shows you.",children:[e.jsxs("form",{className:"form inline-form",onSubmit:x,"aria-label":"Your name",children:[e.jsxs("label",{children:["Name",e.jsx("input",{autoComplete:"name",value:o,onChange:y=>c(y.target.value),required:!0,maxLength:120,"aria-describedby":d?g:void 0})]}),e.jsx("button",{type:"submit",className:"secondary",children:"Save name"})]}),d?e.jsx("p",{className:"error",role:"alert",id:g,children:d}):null,m?e.jsx("p",{className:"notice",role:"status",children:m}):null]})}function XC({me:t,orgs:n,defaultOrg:a}){const[l,o]=h.useState(null),[c,d]=h.useState(""),[u,m]=h.useState(null),[f,g]=h.useState(!1),x=h.useId(),y=()=>{m(null),Promise.all(n.map(async v=>({org:v,summary:await vi.summary(v.tenant,a)}))).then(o,v=>m(`Couldn't read what deleting your account removes. ${v.message}`))},b=(l==null?void 0:l.filter(v=>v.summary.blocked))??[],N=v=>{v.preventDefault(),g(!0),m(null),[...n].sort((S,$)=>+(S.tenant===a)-+($.tenant===a)).reduce((S,$)=>S.then(()=>vi.remove($.tenant,a,c)),Promise.resolve()).then(()=>window.location.replace(`/${fj}`),S=>{m(S.message),g(!1)})};return e.jsxs(_l,{name:"Delete your account",why:"Ends your access everywhere at once; this cannot be undone.",danger:!0,children:[l?e.jsxs(e.Fragment,{children:[e.jsx("ul",{className:"plain",children:l.map(({org:v,summary:k})=>e.jsxs("li",{children:[e.jsx("strong",{children:v.name}),": ",za[k.role],k.ownedTeams.length?`, owns ${k.ownedTeams.join(", ")}`:"","; ",k.activeKeys," active API key",k.activeKeys===1?"":"s"," revoked; ",k.openRequests," open request",k.openRequests===1?"":"s"," stay for review",k.unfinishedTasks.length?`; ${k.unfinishedTasks.length} task${k.unfinishedTasks.length===1?"":"s"} still running (${k.unfinishedTasks.map(S=>S.title).join(", ")}) finish and open a request for review`:"",k.blocked?e.jsx("div",{className:"error",children:k.blocked}):null]},v.tenant||"this"))}),b.length?e.jsxs("p",{className:"error",children:["Your account cannot be deleted while you are the only owner of ",b.map(v=>v.org.name).join(", "),"."]}):e.jsxs("form",{className:"form",onSubmit:N,"aria-label":"Delete your account",children:[e.jsxs("label",{children:["Type ",t.email," to confirm",e.jsx("input",{autoComplete:"off",value:c,onChange:v=>d(v.target.value),required:!0,"aria-describedby":u?x:void 0})]}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",disabled:f||c.trim().toLowerCase()!==t.email,children:"Delete my account"}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>o(null),children:"Keep my account"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Your account is removed from ",n.length>1?`each of the ${n.length} organizations you are signed in to`:"this organization",", with its sessions and API keys. ",e.jsx(Ie,{label:"deleting your account",children:"The requests and tasks you started stay with their teams."})]}),e.jsx("button",{type:"button",className:"secondary",onClick:y,children:"Review what is deleted…"})]}),u?e.jsx("p",{className:"error",role:"alert",id:x,children:u}):null]})}const as={google:"Google",github:"GitHub",microsoft:"Microsoft"};function ZC(){const[t,n]=h.useState(null),[a,l]=h.useState(null),[o,c]=h.useState(null),[d,u]=h.useState(!1),[m,f]=h.useState(null),g=new URLSearchParams(window.location.search),x=g.get("linked"),y=g.get("link-problem"),b=g.get("link-confirm"),[N,v]=h.useState(null),[k,S]=h.useState(null),$=()=>ut.me().then(n,O=>c(O.message));h.useEffect(()=>{$(),b&&ut.awaitingLogin(b).then(v,O=>c(O.message)),ut.config().then(O=>l(O&&"providers"in O?O:null),()=>l(null))},[]);const E=O=>{O instanceof ht&&O.code==="reauth"?u(!0):c(O.message)},C=()=>{c(null),ut.confirmLogin(b,t.csrf).then(({provider:O})=>(v(null),S(O),window.history.replaceState(null,"",window.location.pathname),$()),E)},R=O=>{c(null),ut.addLogin(O,t.csrf).then(({url:_})=>window.location.assign(_),E)};if(!t)return o?e.jsx(_l,{name:"How you sign in",children:e.jsx(be,{what:"how you sign in",reason:o,onRetry:()=>{c(null),$()}})}):null;const P=new Set(t.logins.map(O=>O.provider)),M=((a==null?void 0:a.providers)??[]).filter(O=>!P.has(O));return e.jsxs(_l,{name:"How you sign in",why:"Only an account under your own address is added, and never one someone else signs in with.",children:[(k??x)&&as[k??x]?e.jsxs("p",{className:"notice",role:"status",children:["You can now sign in with ",as[k??x]," too."]}):null,N?e.jsxs("div",{className:"panel problem",role:"alert",children:[e.jsxs("p",{children:["Add the ",as[N.provider]," account ",e.jsx("strong",{children:N.email})," only if it is yours: whoever holds it reaches all of your organizations. ",e.jsxs(Ie,{label:"this account",children:["Its address is not ",t.identity.email,", the one you sign in with."]})]}),e.jsxs("div",{className:"actions",children:[e.jsxs("button",{type:"button",onClick:C,children:["Add ",N.email]}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>{v(null),window.history.replaceState(null,"",window.location.pathname)},children:"Do not add it"})]})]}):null,y?e.jsx("p",{className:"error",role:"alert",children:xd(y)}):null,o?e.jsx("p",{className:"error",role:"alert",children:o}):null,d?e.jsxs("p",{className:"error",role:"alert",children:["Changing how you sign in takes a recent sign-in. ",e.jsxs("a",{href:`/api/auth/${t.identity.signedInWith}/start`,children:["Sign in with ",as[t.identity.signedInWith]," again"]}),", then come back here."]}):null,e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Provider"}),e.jsx("th",{children:"Address"})]})}),e.jsx("tbody",{children:t.logins.map(O=>e.jsxs("tr",{children:[e.jsxs("td",{children:[as[O.provider],O.provider===t.identity.signedInWith?e.jsx("span",{className:"muted",children:" (this sign-in)"}):null]}),e.jsx("td",{children:O.email})]},O.provider))})]}),e.jsxs("div",{className:"actions",children:[M.map(O=>e.jsxs("button",{type:"button",className:"secondary",onClick:()=>R(O),children:["Add ",as[O]]},O)),t.logins.length>1?e.jsxs(e.Fragment,{children:[e.jsx(Pe,{label:"Stop signing in with",value:m??t.logins[0].provider,onChange:O=>f(O),options:t.logins.map(O=>({value:O.provider,label:as[O.provider]}))}),e.jsx(qe,{trigger:`Remove ${as[m??t.logins[0].provider]}…`,triggerLabel:`Remove ${as[m??t.logins[0].provider]} as a way to sign in`,consequence:`You no longer sign in with ${as[m??t.logins[0].provider]}.`,confirm:"Remove",keep:"Keep it",onConfirm:()=>ut.removeLogin(m??t.logins[0].provider,t.csrf).then(()=>(f(null),$()),E)})]}):null]})]})}function e$(t,n){if(t.mode==="local")return"This orchestrator is yours; nobody signs in to it.";const a=za[t.role].toLowerCase();return`Signed in as ${t.email}, ${/^[aeiou]/.test(a)?"an":"a"} ${a} here${n>1?` and in ${n-1} other organization${n===2?"":"s"}`:""}.`}function t$({me:t,nav:n,onChanged:a}){const l=QC(t);return e.jsxs(e.Fragment,{children:[e.jsx(Yn,{title:"Your account",summary:l?e$(t,l.orgs.length):void 0}),n,l?e.jsxs(e.Fragment,{children:[e.jsx(JC,{me:t,orgs:l.orgs,defaultOrg:l.defaultOrg,onRenamed:a}),t.mode==="cloud"?e.jsx(ZC,{}):null,t.mode==="local"?e.jsxs(_l,{name:"Your data",why:"It runs on this machine for you alone.",children:[e.jsx(VC,{}),e.jsx("p",{children:"Stopping the orchestrator and deleting its data directory removes all it keeps; your folders, repositories and their branches stay where they are."})]}):e.jsx(XC,{me:t,orgs:l.orgs,defaultOrg:l.defaultOrg})]}):e.jsx(he,{what:"your account"})]})}function n$(){return e.jsx("main",{className:"gate",children:e.jsxs("div",{className:"panel form",role:"status",children:[e.jsxs("div",{className:"brand",children:["TeamHandbook ",e.jsx("span",{children:"Orchestrator"})]}),e.jsx("h1",{children:"Your account is deleted"}),e.jsx("p",{children:"You are signed out of every organization it belonged to, and its API keys no longer work. An owner or admin invites you again if you need to come back."}),e.jsx("a",{className:"button secondary",href:"/",children:"Go to sign-in"})]})})}const s$={ok:"ok",warn:"warn",fail:"error",unknown:"warn"};function a$(){const[t,n]=h.useState(null),[a,l]=h.useState(!0),[o,c]=h.useState(null),d=u=>{l(!0),c(null),ge.readiness(u).then(n,m=>c(m.message)).finally(()=>l(!1))};return h.useEffect(()=>d(!1),[]),e.jsxs("section",{className:"panel","aria-label":"Agent readiness",children:[e.jsx("p",{className:"muted",children:"How each agent's CLI, version, credential and sign-in look to a task; a check never stops a task from starting."}),o?e.jsx("p",{className:"error",children:o}):null,t?e.jsxs("table",{className:"row-cards",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Agent"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Checks"})]})}),e.jsx("tbody",{children:t.agents.map(u=>e.jsxs("tr",{"data-agent":u.id,children:[e.jsx("td",{className:"rc-title",children:u.label}),e.jsx("td",{className:"rc-status",children:e.jsx("span",{className:`badge ${u.ready?"ok":"error"}`,children:u.ready?"ready":"not ready"})}),e.jsx("td",{className:"rc-wide",children:e.jsx("ul",{className:"checks",children:u.checks.map(m=>e.jsxs("li",{children:[e.jsx("span",{className:`badge ${s$[m.status]}`,children:m.status}),e.jsx("strong",{children:m.name})," ",m.detail,m.fix?e.jsxs(e.Fragment,{children:[" ",e.jsx(mt,{text:m.fix,label:"Copy the command"})]}):null]},m.name))})})]},u.id))})]}):e.jsx("p",{className:"muted",children:a?"Checking…":null}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",onClick:()=>d(!0),disabled:a,children:"Check again"}),t?e.jsxs("span",{className:"muted",children:["Checked at ",t.checkedAt.slice(11,19),"."]}):null]})]})}function Cr(t){return t?new Date(t).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"unknown"}function r$(){const[t,n]=h.useState(null),[a,l]=h.useState(null),[o,c]=h.useState(null),d=()=>xi.apps().then(n,u=>l(u.message));return h.useEffect(()=>{d()},[]),e.jsxs("section",{className:"panel","aria-labelledby":"apps-h",children:[e.jsxs("h2",{id:"apps-h",children:["Apps you approved ",t?e.jsx("span",{className:"count",children:t.length}):null]}),e.jsxs("p",{className:"muted",children:["MCP clients you let act as you through the orchestrator's MCP server. ",e.jsx(Ie,{label:"approved apps",children:"Taking one back ends its access at once; it asks you to approve it again."})]}),o?e.jsx("p",{className:"notice",role:"status",children:o}):null,a?e.jsx(be,{what:"the apps you approved",reason:a,onRetry:()=>{l(null),d()}}):t?t.length?e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"App"}),e.jsx("th",{children:"Can"}),e.jsx("th",{children:"Approved"}),e.jsx("th",{children:e.jsx("span",{className:"visually-hidden",children:"Take back"})})]})}),e.jsx("tbody",{children:t.map(u=>e.jsxs("tr",{children:[e.jsx("td",{children:u.clientName}),e.jsx("td",{children:u.scopes.join(", ")}),e.jsx("td",{children:Cr(u.createdAt)}),e.jsx("td",{children:e.jsx(qe,{small:!0,trigger:"Take back",triggerLabel:`Take back the access of ${u.clientName} approved ${Cr(u.createdAt)}`,consequence:`${u.clientName} stops reaching the orchestrator at its next call.`,confirm:"Take back access",keep:"Keep access",onConfirm:()=>xi.takeBack(u.id).then(()=>(c(`${u.clientName} no longer has access.`),d()))})})]},u.id))})]}):e.jsx("p",{className:"muted",children:"No app has been approved to act as you."}):e.jsx(he,{what:"the apps you approved"})]})}function l$({me:t}){const[n,a]=h.useState(null),[l,o]=h.useState(null),[c,d]=h.useState(null),u=()=>xi.sessions().then(a,m=>o(m.message));return h.useEffect(()=>{u()},[]),e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"panel","aria-labelledby":"sessions-h",children:[e.jsxs("h2",{id:"sessions-h",children:["Where you are signed in ",n?e.jsx("span",{className:"count",children:n.length}):null]}),e.jsxs("p",{className:"muted",children:["Each browser you signed in from. ",e.jsx(Ie,{label:"sessions",children:"Signing a browser out ends it at its next request, an open task stream included."})]}),c?e.jsx("p",{className:"notice",role:"status",children:c}):null,l?e.jsx(be,{what:"your sessions",reason:l,onRetry:()=>{o(null),u()}}):n?n.length?e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Browser"}),e.jsx("th",{children:"Signed in"}),e.jsx("th",{children:"Last seen"}),e.jsx("th",{children:"Ends"}),e.jsx("th",{children:e.jsx("span",{className:"visually-hidden",children:"End"})})]})}),e.jsx("tbody",{children:n.map(m=>e.jsxs("tr",{children:[e.jsxs("td",{children:[m.userAgent??"unknown",m.current?e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{className:"badge ok",children:"this browser"})]}):null]}),e.jsx("td",{children:Cr(m.createdAt)}),e.jsx("td",{children:Cr(m.lastSeenAt)}),e.jsx("td",{children:Cr(m.expiresAt)}),e.jsx("td",{children:e.jsx(qe,{small:!0,trigger:"Sign out there",triggerLabel:`Sign out ${m.userAgent??"an unknown browser"}, signed in ${Cr(m.createdAt)}`,consequence:m.current?"This signs you out of this browser.":"That browser is signed out at its next request.",confirm:"Sign out there",keep:"Stay signed in there",onConfirm:()=>xi.end(m.id).then(()=>(m.current&&window.location.assign("/"),d("The session is ended."),u()))})})]},m.id))})]}):e.jsx("p",{className:"muted",children:"No browser is signed in as you."}):e.jsx(he,{what:"your sessions"})]}),e.jsx(r$,{}),e.jsxs("section",{className:"panel","aria-labelledby":"tokens-h",children:[e.jsx("h2",{id:"tokens-h",children:"Keys"}),e.jsxs("p",{className:"muted",children:["Automation signs in with an API key: ",e.jsx("a",{href:re("settings","api-keys"),children:"see and revoke your API keys"}),"."]}),eh(t,"machines")?e.jsxs("p",{className:"muted",children:["Your machines run your tasks; see and remove them on ",e.jsx("a",{href:re("settings","machines"),children:"Your machines"}),"."]}):null]})]})}const o$=250,i$={none:"No Git: the agent changes its files in place, and you keep or undo each change.",git:"A Git repository: each task works on its own branch and ends in a request for review.",plain:"The agent changes a folder's files in place, and you keep or undo each change."},gj=t=>t===1?"1 repository":`${t} repositories`,c$=t=>`A folder of ${gj(t)}: each task works on its own branch of each one it changes and ends in a request for review.`;function u$({entry:t,home:n,selected:a,busy:l,withPath:o,withGit:c,onPick:d,onEnter:u,onBack:m,onFocus:f}){const g=x=>{x.key==="Enter"&&u?(x.preventDefault(),d()):x.key==="ArrowRight"&&u?(x.preventDefault(),u()):(x.key==="ArrowLeft"||x.key==="Backspace")&&m&&(x.preventDefault(),m())};return e.jsx("li",{children:e.jsxs("button",{type:"button",className:"folder-row","aria-selected":a,disabled:l,onClick:u??d,onKeyDown:g,onFocus:f,children:[e.jsxs("span",{children:[e.jsx("span",{className:"folder-name",dir:"auto",children:t.name}),o?e.jsx("span",{className:"folder-path",dir:"auto",children:Kn(t.path,n)}):null]}),c?e.jsx("span",{className:"folder-git",children:t.repos?gj(t.repos):t.git==="none"?"No Git":"Git"}):e.jsx("span",{}),u?e.jsx("span",{className:"folder-into","aria-hidden":"true"}):e.jsx("span",{})]})})}function d$({home:t,onOpened:n,onCancel:a}){const[l,o]=h.useState(""),[c,d]=h.useState(""),[u,m]=h.useState(!1),[f,g]=h.useState(null),x=qk(l),y=b=>{b.preventDefault(),m(!0),g(null),Je.clone(l.trim(),c.trim()?oa(c,t):void 0).then(({project:N})=>n(N,t),N=>{g(N.message),m(!1)})};return e.jsxs("form",{className:"form",onSubmit:y,"aria-label":"Clone a repository",children:[e.jsxs("label",{children:["Address",e.jsx("input",{value:l,onChange:b=>o(b.target.value),placeholder:"https://github.com/team/shop",autoComplete:"off",spellCheck:!1,required:!0})]}),e.jsxs("label",{children:["Place (optional)",e.jsx("input",{value:c,onChange:b=>d(b.target.value),placeholder:x?`~/code/${x}`:"~/code/<name>",autoComplete:"off",spellCheck:!1})]}),e.jsxs("p",{className:"muted small",children:["Clones into ",c.trim()||(x?`~/code/${x}`:"~/code")," with your own git sign-in. ",e.jsx(Ie,{label:"cloning",children:"An address over https or ssh. A folder already there is never written to."})]}),f?e.jsx("p",{className:"error",role:"alert",children:f}):null,e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",disabled:u||!l.trim(),children:u?"Cloning…":"Clone"}),e.jsx("button",{type:"button",className:"secondary",onClick:a,disabled:u,children:"Cancel"})]})]})}function yh({onOpened:t,lead:n,selected:a,machine:l,where:o="On this computer",from:c,verb:d="Open"}){var xe,ie;const[u,m]=h.useState(null),[f,g]=h.useState(null),[x,y]=h.useState((c==null?void 0:c.home)??null),[b,N]=h.useState(c==null?void 0:c.under),[v,k]=h.useState(""),[S,$]=h.useState(null),[E,C]=h.useState(null),[R,P]=h.useState(!1),[M,O]=h.useState(0),[_,I]=h.useState(!1),[L,K]=h.useState(null),[B,ne]=h.useState(null),Z=h.useRef(null),D=v.trim()&&!Au(v)?v.trim():"",te=Au(v)?v.trim():"";h.useEffect(()=>{let me=!0;$(null),ne(null);const Fe=setTimeout(()=>{Je.folders({...b?{under:b}:{},...D?{q:D}:{}},l).then(Ve=>{me&&(m(Ve),g(b),!b&&!D&&y(Ve.under))},Ve=>me&&$(Ve.message))},D?o$:0);return()=>{me=!1,clearTimeout(Fe)}},[b,D,M,l]);const Q=me=>{P(!0),C(null),Je.open(me,l).then(({project:Fe})=>t(Fe,x,{under:b,home:x}),Fe=>C(Fe.message)).finally(()=>P(!1))};h.useEffect(()=>{L===null||x===null||(K(null),Q(oa(L,x)))},[L,x]);const ee=me=>{var le,pe;if(me.key!=="ArrowDown"&&me.key!=="ArrowUp")return;const Fe=[...((le=Z.current)==null?void 0:le.querySelectorAll("button.folder-row"))??[]];if(!Fe.length)return;me.preventDefault();const Ve=Fe.indexOf(document.activeElement);(pe=Fe[Math.min(Math.max(Ve+(me.key==="ArrowDown"?1:-1),0),Fe.length-1)])==null||pe.focus()},W=u&&x?Bk(u.under,x):[],A=me=>{k(""),N(me===x?void 0:me)},H=W.length>1?()=>A(W[W.length-2].path):void 0,de=[...(u==null?void 0:u.suggestions)??[],...(u==null?void 0:u.folders)??[],...(u==null?void 0:u.matches)??[]].some(me=>me.git!=="none"||!!me.repos),Se=(me,Fe,Ve,le)=>Fe.length?e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"folder-group",children:me}),e.jsx("ul",{className:"folder-list",children:Fe.map(pe=>e.jsx(u$,{entry:pe,home:x,selected:pe.path===((B==null?void 0:B.path)??a),busy:R,withPath:le,withGit:de,onPick:()=>Q(pe.path),...Ve?{onEnter:()=>A(pe.path),onFocus:()=>ne(pe)}:{},...H?{onBack:H}:{}},pe.path))})]}):null,Ne=B??(u&&b&&f===b&&!D?{name:((xe=W[W.length-1])==null?void 0:xe.label)??u.under,path:u.under}:null);return _?e.jsx(d$,{home:x,onOpened:(me,Fe)=>t(me,Fe,{under:b,home:x}),onCancel:()=>I(!1)}):e.jsx("div",{className:"folder-picker",role:"group","aria-label":"Pick a folder",children:e.jsxs("div",{className:"folder-picker-main",children:[n,e.jsx("div",{className:"folder-picker-bar",children:e.jsxs("label",{children:["Folder name or path",e.jsx("input",{type:"text","data-page-search":!0,placeholder:"~/code/shop",value:v,onChange:me=>k(me.target.value),autoComplete:"off",spellCheck:!1,onKeyDown:me=>{me.key==="Enter"&&Au(v)?(me.preventDefault(),x===null&&v.trim().startsWith("~")?K(v):Q(oa(v,x))):ee(me)}})]})}),u&&!D&&!te?e.jsxs("p",{className:"folder-place",children:[e.jsx("span",{className:"folder-machine",children:o}),e.jsx("span",{className:"folder-at",dir:"auto",children:Kn(u.under,x)}),H?e.jsx("button",{type:"button",className:"ghost small folder-up",onClick:H,children:"Up one folder"}):null]}):null,E?e.jsx("p",{className:"error",role:"alert",children:E}):null,e.jsxs("div",{ref:Z,onKeyDown:ee,children:[te?e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"folder-group",children:"This folder"}),e.jsx("ul",{className:"folder-list",children:e.jsx("li",{children:e.jsxs("button",{type:"button",className:"folder-row",disabled:R,onClick:()=>x===null&&te.startsWith("~")?K(te):Q(oa(te,x)),children:[e.jsxs("span",{children:[e.jsx("span",{className:"folder-name",dir:"auto",children:te.replace(/\/+$/,"").split("/").pop()||te}),e.jsx("span",{className:"folder-path",dir:"auto",children:Kn(oa(te,x),x)})]}),e.jsx("span",{className:"muted small",children:d==="Add"?"Enter adds it":"Enter opens it"})]})})})]}):S?e.jsx(be,{what:"your folders",reason:S,onRetry:()=>O(me=>me+1)}):u?D?(ie=u.matches)!=null&&ie.length?Se(`Matching “${D}”`,u.matches,!0,!0):e.jsxs("p",{className:"muted",children:["No folder under home is named like “",D,"”. Paste its path instead."]}):u.folders.length||u.suggestions.length?e.jsxs(e.Fragment,{children:[b?null:Se("Suggested",u.suggestions.slice(0,3),!1,!0),Se("Folders",u.folders,!0,!1)]}):e.jsx("p",{className:"muted",children:"No folder here. Paste the path of the folder you work in."}):e.jsx(he,{what:"your folders"}),u!=null&&u.truncated?e.jsx("p",{className:"muted small",children:"Some folders were left out; search by name to find one."}):null]}),e.jsxs("div",{className:"folder-picker-foot",children:[Ne&&!te?e.jsxs(e.Fragment,{children:[Ne.git?e.jsx("p",{className:"muted",children:Ne.repos?c$(Ne.repos):i$[Ne.git!=="none"?"git":de?"none":"plain"]}):null,e.jsxs("button",{type:"button",disabled:R,onClick:()=>Q(Ne.path),children:[d," ",Ne.name]})]}):null,l?null:e.jsx("button",{type:"button",className:"link",onClick:()=>I(!0),children:"Clone from GitHub or GitLab"})]})]})})}const Kf=t=>({source:t.source,command:t.command,digest:t.digest}),$s={task:t=>U("GET",`/api/tasks/${encodeURIComponent(t)}/verification`).then(n=>n.verifications),project:t=>U("GET",`/api/projects/${encodeURIComponent(t)}/verification`),approve:(t,n,a)=>U("PUT",`/api/projects/${encodeURIComponent(t)}/verification`,{checks:n.map(Kf),setup:a?Kf(a):null}),forget:t=>U("DELETE",`/api/projects/${encodeURIComponent(t)}/verification`)};function h$(t,n){var c,d;if(t.configured)return{configured:t.configured,checks:[],setup:null,approve:null,canChange:!1};const a=((c=t.detected)==null?void 0:c.checks)??[];if(t.approved&&!t.changed.length&&n===null)return{configured:null,checks:t.approved.checks,setup:t.approved.setup,approve:null,canChange:a.length>0};const l=n===null?a.slice(0,1):a.filter(u=>n.includes(u.command)),o=l.length?((d=t.detected)==null?void 0:d.setup)??null:null;return{configured:null,checks:l,setup:o,approve:l.length?{checks:l,setup:o}:null,canChange:a.length>0}}const Yf=t=>t?t.timedOut?"timed out":t.code===0?"passed":"failed":"not run";function m$(t){const n=Math.max(0,t.after.length-1),a=`${Yf(t.after.at(-1))} after${n?` ${n} repair ${n===1?"round":"rounds"}`:""}`;return`${Yf(t.before)} before, ${a}`}function p$(t){return t.verdict==="broken"||t.verdict==="failing-before"}const f$=t=>t.length<2?t.join(""):`${t.slice(0,-1).join(", ")} and ${t.at(-1)}`;function g$(t){return`${f$(t)} ${t.length===1?"was":"were"} found for this folder; approve ${t.length===1?"it":"them"} to run after each task.`}function x$({project:t,canChange:n}){var N;const[a,l]=h.useState(null),[o,c]=h.useState(null),[d,u]=h.useState(!1),[m,f]=h.useState(null);if(h.useEffect(()=>{$s.project(t).then(l,()=>l(null))},[t]),!a||a.configured)return null;const g=((N=a.detected)==null?void 0:N.checks)??[],x=a.approved&&!a.changed.length?a.approved.checks:null;if(!x&&!g.length)return null;const y=v=>{var S;u(!0),f(null),(v.length?$s.approve(t,v,((S=a.detected)==null?void 0:S.setup)??null):$s.forget(t)).then($=>{l($),c(null)},$=>f($.message)).finally(()=>u(!1))},b=v=>v.map(k=>k.source?`${k.command} from ${k.source}`:k.command).join(", ");return e.jsxs("div",{className:"folder-checks small",children:[o?e.jsxs(e.Fragment,{children:[e.jsx("ul",{className:"plain",children:g.map(v=>e.jsx("li",{children:e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:o.includes(v.command),onChange:k=>c(k.target.checked?[...o,v.command]:o.filter(S=>S!==v.command))}),e.jsx("code",{children:v.command})," ",e.jsxs("span",{className:"muted",children:["from ",v.source]})]})},v.command))}),e.jsxs("p",{className:"actions",children:[e.jsx("button",{type:"button",disabled:d,onClick:()=>y(g.filter(v=>o.includes(v.command))),children:"Approve these"}),e.jsx("button",{type:"button",className:"secondary",disabled:d,onClick:()=>c(null),children:"Cancel"})]})]}):x?e.jsxs("p",{children:["Checks after each task: ",e.jsx("code",{children:x.map(v=>v.command).join(", ")}),n&&g.length?e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{type:"button",className:"link",onClick:()=>c(x.map(v=>v.command)),children:"Change…"})]}):null]}):e.jsxs("p",{children:["Found: ",b(g),n?e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{type:"button",disabled:d,onClick:()=>y(g),children:"Approve"})," ",e.jsx("button",{type:"button",className:"secondary",onClick:()=>c(g.map(v=>v.command)),children:"Not these…"})]}):null]}),m?e.jsx("p",{className:"error",role:"alert",children:m}):null]})}const j$={read:(t=null)=>U("GET",`/api/tasks/board${t?`?${new URLSearchParams({repo:t})}`:""}`)};function y$(t){const n=Ba({...t,request:t.request?{status:t.request.status}:null}),{word:a,tone:l}=Lr(n,t.forge);return{label:a,tone:l,state:n}}const v$={review:["review"],answer:["approval","answer"],retry:["failed"],continue:[],"follow-up":["follow-up"]};function k$(t,n){const a=t.next?v$[t.next]:[];return a.length>0&&!a.some(l=>n.has(`${t.id}:${l}`))}function b$(t){const n=t.sections.done.filter(d=>d.phase==="merged"),a=n.reduce((d,u)=>d+(u.cost.usd??0),0),l=[t.counts.yours?`${t.counts.yours} ${t.counts.yours===1?"waits":"wait"} on you`:null,t.counts.agents?`${t.counts.agents} ${t.counts.agents===1?"is":"are"} working`:null,t.counts.waiting?`${t.counts.waiting} ${t.counts.waiting===1?"waits":"wait"} for a computer`:null].filter(Boolean).join(", "),o=n.length?`${n.length} kept this week${a>0?` for $${a.toFixed(2)}`:""}`:null,c=[l||null,o].filter(Boolean).join("; ");return c?`${c.charAt(0).toUpperCase()}${c.slice(1)}.`:null}function Wl(t,n=new Date){const a=new Date(t),l=c=>new Date(c.getFullYear(),c.getMonth(),c.getDate()).getTime(),o=Math.round((l(n)-l(a))/864e5);return o<=0?a.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hourCycle:"h23"}):o===1?"Yesterday":o<7?a.toLocaleDateString(void 0,{weekday:"short"}):a.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function w$({me:t}){return t.mode==="local"?e.jsx(C$,{me:t}):e.jsxs(e.Fragment,{children:[e.jsx(S$,{}),e.jsx(N$,{})]})}function N$(){const[t,n]=h.useState(null);return h.useEffect(()=>{U("GET","/api/team/shared?days=30").then(n,()=>n({skills:[],mcpServers:[]}))},[]),t?e.jsxs("section",{className:"section","aria-labelledby":"code-tools-h",children:[e.jsx("h2",{id:"code-tools-h",children:"Skills and MCP servers for tasks"}),e.jsx("p",{className:"muted",children:"They change through a request to the repository that declares them."}),t.skills.length||t.mcpServers.length?e.jsxs("ul",{className:"plain code-tools",children:[t.skills.map(a=>e.jsxs("li",{children:[e.jsx("span",{className:"mono",dir:"auto",children:a.name||a.slug})," ",e.jsxs("span",{className:"muted",children:["skill, ",a.repoName]})]},`skill-${a.repoName}-${a.slug}`)),t.mcpServers.map(a=>e.jsxs("li",{children:[e.jsx("span",{className:"mono",dir:"auto",children:a.name})," ",e.jsxs("span",{className:"muted",children:["MCP server, ",a.repoName]})]},`mcp-${a.repoName}-${a.name}`))]}):e.jsx("p",{className:"muted",children:"Nothing is shared yet."})]}):e.jsx(he,{what:"the skills and MCP servers for tasks"})}function S$(){const[t,n]=h.useState(null),[a,l]=h.useState(null),o=()=>Ce.repos().then(c=>n(c.filter(d=>d.configured!==!1&&d.kind!=="skills")),c=>l(c.message));return h.useEffect(()=>{o()},[]),a?e.jsx(be,{what:"where your code lives",reason:a,onRetry:()=>{l(null),o()}}):t?e.jsxs("section",{className:"section","aria-labelledby":"code-folders-h",children:[e.jsx("h2",{id:"code-folders-h",children:"Repositories tasks work in"}),t.length?e.jsx("ul",{className:"plain code-folders",children:t.map(c=>e.jsxs("li",{children:[e.jsx("strong",{dir:"auto",children:c.name})," ",e.jsx("span",{className:"muted",children:c.team})," ",e.jsx("a",{href:re("repositories",c.id),children:"Repository settings"})]},c.id))}):e.jsxs("p",{className:"muted",children:["No repository is connected yet. Connect one on ",e.jsx("a",{href:re("integrations"),children:"Integrations"}),"."]})]}):e.jsx(he,{what:"where your code lives"})}function C$({me:t}){const[n,a]=h.useState(null),[l,o]=h.useState(null),[c,d]=h.useState(!1),u=()=>Promise.all([Je.workFolders(),Je.list()]).then(([{folders:m},{projects:f,last:g,home:x}])=>a({folders:m,last:g,home:x??null,projectOf:new Map(f.map(y=>[y.url,y.id]))}),m=>o(m.message));return h.useEffect(()=>{u()},[]),l?e.jsx(be,{what:"where your code lives",reason:l,onRetry:()=>{o(null),u()}}):n?e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"section","aria-labelledby":"code-folders-h",children:[e.jsx("h2",{id:"code-folders-h",children:"Folders tasks work in"}),n.folders.length?e.jsx("ul",{className:"plain code-folders",children:n.folders.map(m=>e.jsxs("li",{children:[e.jsx("strong",{dir:"auto",children:m.name})," ",e.jsx("span",{className:"mono",dir:"auto",children:Kn(m.path,n.home)}),m.usedAt?e.jsxs("span",{className:"muted",children:[" last used ",Wl(m.usedAt)]}):null,n.projectOf.has(m.path)?e.jsx(x$,{project:n.projectOf.get(m.path),canChange:Me(t)}):null]},m.path))}):e.jsx("p",{className:"muted",children:"No folder yet. A task works in a folder your Claude Code has worked in; add one below."}),c?e.jsxs(e.Fragment,{children:[e.jsx(yh,{verb:"Add",onOpened:()=>{d(!1),u()}}),e.jsx("p",{children:e.jsx("button",{type:"button",className:"secondary",onClick:()=>d(!1),children:"Cancel"})})]}):e.jsx("p",{children:e.jsx("button",{type:"button",className:"secondary",onClick:()=>d(!0),children:"Add a folder"})})]}),n.last?e.jsx(jh,{project:n.last,canChange:Me(t)},`tools-${n.last}`):e.jsxs("section",{className:"section","aria-labelledby":"code-tools-h",children:[e.jsx("h2",{id:"code-tools-h",children:"Skills and MCP servers for tasks"}),e.jsx("p",{className:"muted",children:"Once a task has worked in a folder, you add skills and MCP servers for it here."})]})]}):e.jsx(he,{what:"where your code lives"})}const xj={repositories:"Repositories",requests:"Requests",tasks:"Tasks",usage:"Usage",members:"Members",settings:"Settings",keys:"This account's API keys"},$$=[{label:"Never",days:null},{label:"1 day",days:1},{label:"7 days",days:7},{label:"30 days",days:30},{label:"90 days",days:90},{label:"365 days",days:365}];function Vf(t){return t?new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}):"never"}function T$(t){return Gg.filter(a=>t[a]!=="none").map(a=>`${xj[a]}: ${t[a]}`).join(", ")}function E$({secret:t,onDone:n}){return e.jsxs("section",{className:"notice","aria-label":"New API key",children:[e.jsxs("p",{children:["Copy this key now; it is shown once. ",e.jsx(Ie,{label:"the key",children:"The orchestrator keeps only its prefix and a hash."})]}),e.jsx(mt,{text:t,label:"Copy key"}),e.jsx("div",{className:"actions",children:e.jsx("button",{type:"button",className:"secondary small",onClick:n,children:"I copied it"})})]})}function R$({serviceAccountId:t,ceiling:n=Dv,onCreated:a}){const[l,o]=h.useState(""),[c,d]=h.useState(30),[u,m]=h.useState({repositories:"read",requests:"read"}),[f,g]=h.useState(null),[x,y]=h.useState(!1),b=h.useId(),N=v=>{v.preventDefault(),y(!0),g(null),Da.create({name:l,scopes:u,expiresInDays:c,...t?{serviceAccountId:t}:{}}).then(k=>{o(""),y(!1),a(k.secret)},k=>{g(k.message),y(!1)})};return e.jsxs("form",{className:"form",onSubmit:N,"aria-label":t?"New key for this service account":"New API key",children:[e.jsxs("label",{children:["Name",e.jsx("input",{value:l,onChange:v=>o(v.target.value),required:!0,maxLength:80,"aria-describedby":f?b:void 0})]}),e.jsx(Pe,{label:"Expires",value:c===null?"never":String(c),onChange:v=>d(v==="never"?null:Number(v)),options:$$.map(v=>({value:v.days===null?"never":String(v.days),label:v.label}))}),e.jsxs("fieldset",{className:"plain-fieldset scope-grid",children:[e.jsx("legend",{children:"Access"}),e.jsx("p",{className:"muted small",children:"What the key reads or changes, never more than you can."}),Gg.filter(v=>n[v]!=="none").map(v=>e.jsx(Pe,{label:xj[v],value:u[v]??"none",onChange:k=>m({...u,[v]:k}),options:["none","read","write"].filter(k=>k!=="write"||n[v]==="write").map(k=>({value:k,label:k==="none"?"None":k==="read"?"Read":"Write"}))},v))]}),e.jsxs("p",{className:"muted",children:["A key never manages members, settings or sign-in, nor merges a request. ",e.jsx(Ie,{label:"what a key never does",children:"Those take a person signed in here, so no automation approves what it opened itself."})]}),f?e.jsx("p",{className:"error",role:"alert",id:b,children:f}):null,e.jsx("div",{className:"actions",children:e.jsx("button",{type:"submit",disabled:x,children:"Create key"})})]})}function P$({keys:t,label:n,onChanged:a}){return t.length?e.jsx(e.Fragment,{children:e.jsxs("table",{"aria-label":n,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Key"}),e.jsx("th",{children:"Access"}),e.jsx("th",{children:"Expires"}),e.jsx("th",{children:"Last used"}),e.jsx("th",{children:e.jsx("span",{className:"visually-hidden",children:"Revoke"})})]})}),e.jsx("tbody",{children:t.map(l=>e.jsxs("tr",{children:[e.jsxs("td",{children:[l.name,e.jsxs("div",{className:"mono muted",children:[l.prefix,"_…"]})]}),e.jsx("td",{children:T$(l.scopes)}),e.jsx("td",{children:l.status==="active"?Vf(l.expiresAt):e.jsx("span",{className:"badge warn",children:l.status})}),e.jsx("td",{children:l.lastUsedAt?Vf(l.lastUsedAt):"not yet"}),e.jsx("td",{children:l.status==="active"?e.jsx(qe,{small:!0,trigger:"Revoke",triggerLabel:`Revoke ${l.name}`,consequence:"This cannot be undone. Anything using this key is turned away at once, and so is every key it minted.",confirm:"Revoke key",keep:"Keep key",onConfirm:()=>Da.revoke(l.id).then(a)}):null})]},l.id))})]})}):e.jsx("p",{className:"muted",children:"No key yet."})}function jj({serviceAccountId:t,label:n,ceiling:a}){const[l,o]=h.useState(null),[c,d]=h.useState(null),[u,m]=h.useState(null),f=()=>Da.list(t).then(o,g=>m(g.message));return h.useEffect(()=>{f()},[t]),e.jsxs(e.Fragment,{children:[l&&u?e.jsx("p",{className:"error",role:"alert",children:u}):null,c?e.jsx(E$,{secret:c,onDone:()=>d(null)}):null,l?e.jsx(P$,{keys:l,label:n,onChanged:f}):u?e.jsx(be,{what:"keys",reason:u,onRetry:()=>{m(null),f()}}):e.jsx(he,{what:"keys"}),e.jsx(R$,{serviceAccountId:t,ceiling:a,onCreated:g=>{d(g),f()}})]})}function A$({me:t}){return e.jsxs("section",{className:"panel","aria-labelledby":"keys-h",children:[e.jsx("h2",{id:"keys-h",children:"Your API keys"}),e.jsxs("p",{className:"muted",children:["A key acts as you, never further than your role. ",e.jsxs(Ie,{label:"using a key",children:["Send it as ",e.jsx("code",{children:"Authorization: Bearer th_sk_…"}),"; it reaches only the resources you give it."]})]}),e.jsx(jj,{label:"Your API keys",ceiling:t.keyCeiling})]})}function Yu(t){return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function I$({id:t,tags:n,editable:a}){const[l,o]=h.useState(n),[c,d]=h.useState(n.filter(g=>g.source==="manual").map(g=>g.tag).join(" ")),[u,m]=h.useState(null),f=g=>{g.preventDefault(),m(null),ji.setTags(t,c.split(/[\s,]+/).filter(Boolean)).then(o,x=>m(x.message))};return e.jsxs(e.Fragment,{children:[e.jsx("p",{children:l.length?l.map(g=>`${g.tag}${g.source==="directory"?" (from a group)":""}`).join(", "):e.jsx("span",{className:"muted",children:"no tag"})}),a?e.jsxs("form",{className:"form inline-form",onSubmit:f,"aria-label":"Tags added by hand",children:[e.jsxs("label",{children:["Tags added by hand",e.jsx("input",{value:c,onChange:g=>d(g.target.value),placeholder:"on-call backend"})]}),e.jsx("button",{type:"submit",className:"secondary",children:"Save tags"}),u?e.jsx("p",{className:"error",role:"alert",children:u}):null]}):null]})}function O$({id:t,me:n,nav:a}){const[l,o]=h.useState(null),[c,d]=h.useState(null),[u,m]=h.useState(0);h.useEffect(()=>{let N=!0;return d(null),Pr.page(t).then(v=>N&&o(v),v=>N&&d(v.message)),()=>{N=!1}},[t,u]);const f=N=>e.jsxs(e.Fragment,{children:[e.jsxs("header",{className:"page-head",children:[e.jsx("nav",{className:"crumbs","aria-label":"Breadcrumb",children:e.jsx("a",{href:re("settings","members"),children:"Members"})}),e.jsx("h1",{children:N})]}),a]});if(c&&!l)return e.jsxs(e.Fragment,{children:[f("Member"),e.jsx(be,{what:"the member",reason:c,panel:!0,onRetry:()=>m(u+1)})]});if(!l)return e.jsxs(e.Fragment,{children:[f("Member"),e.jsx(he,{what:"the member",panel:!0})]});const{member:g,requests:x,tasks:y,totals:b}=l;return e.jsxs(e.Fragment,{children:[f(g.name),e.jsxs("section",{className:"panel","aria-label":`${g.name}'s account`,children:[e.jsxs("dl",{className:"facts",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Email"}),e.jsx("dd",{children:g.email})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Joined"}),e.jsx("dd",{children:Yu(g.createdAt)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Signs in with"}),e.jsx("dd",{children:ux(g.signIn)})]})]}),e.jsx(Ib,{user:g,me:n,onChanged:()=>m(u+1),onRemoved:()=>Ge(re("settings","members"))}),e.jsx("h2",{children:"Tags"}),e.jsx(I$,{id:g.id,tags:l.tags,editable:Me(n)})]}),e.jsx(xS,{id:g.id}),e.jsxs("section",{className:"panel","aria-labelledby":"member-req-h",children:[e.jsxs("h2",{id:"member-req-h",children:["Requests opened ",e.jsx("span",{className:"count",children:b.requests})]}),x.length?e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Request"}),e.jsx("th",{children:"Repository"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Opened"})]})}),e.jsx("tbody",{children:x.map(N=>e.jsxs("tr",{children:[e.jsxs("td",{children:["#",N.number," ",N.title]}),e.jsx("td",{children:e.jsx("a",{href:re("repositories",N.repoId),children:N.repoId})}),e.jsx("td",{children:N.status}),e.jsx("td",{children:Yu(N.createdAt)})]},`${N.repoId}-${N.number}`))})]}):e.jsx("p",{className:"muted",children:"No request opened from the orchestrator yet."})]}),e.jsxs("section",{className:"panel","aria-labelledby":"member-task-h",children:[e.jsxs("h2",{id:"member-task-h",children:["Tasks started ",e.jsx("span",{className:"count",children:b.tasks})]}),y.length?e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Task"}),e.jsx("th",{children:"Repository"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Started"})]})}),e.jsx("tbody",{children:y.map(N=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("a",{href:re("tasks",N.id),children:N.title})}),e.jsx("td",{children:N.repoId}),e.jsx("td",{children:N.status}),e.jsx("td",{children:Yu(N.createdAt)})]},N.id))})]}):e.jsx("p",{className:"muted",children:"No task started yet."})]})]})}function yj(t){if(!t.installed)return`${t.label}: not installed`;const n=t.version?` ${t.version}`:"",a=t.supported==="update"?", update it":t.supported==="unsupported"?", too old to run tasks; update it":"";return t.signIn==="signed-in"?`${t.label}${n}: signed in${a}`:t.signIn==="signed-out"?`${t.label}${n}: signed out${a}`:`${t.label}${n}: sign-in not known${a}`}function L$({agentId:t}){const[n,a]=h.useState(null);if(h.useEffect(()=>{let o=!0;return a(null),ha.list().then(c=>{var d;return o&&a(((d=c.machines.find(u=>u.local))==null?void 0:d.agents.find(u=>u.id===t))??null)},()=>o&&a(null)),()=>{o=!1}},[t]),!n)return null;const l=n.signIn==="signed-out"&&n.signInCommand;return e.jsxs("p",{className:l?"error":"muted",role:l?"alert":"note","aria-label":`${n.label} sign-in`,children:[yj(n),".",l?e.jsxs(e.Fragment,{children:[" Run ",e.jsx(mt,{text:n.signInCommand,label:`Copy the sign-in command for ${n.label}`})," in a terminal, then start."]}):null]})}const F$=3e3;function Qf(t){return t?t.slice(0,16).replace("T"," "):"never"}function M$(){const[t,n]=h.useState(null),[a,l]=h.useState(null),[o,c]=h.useState(!1),[d,u]=h.useState(null),[m,f]=h.useState(null),g=h.useRef(),x=()=>ha.list().then(v=>(l(null),n(v.machines),v.machines),v=>(v instanceof Os?c(!0):l(v.message),null));h.useEffect(()=>(x(),()=>clearInterval(g.current)),[]);const y=()=>{f(null),ha.pair().then(v=>{u(v);const k=new Set((t??[]).map(S=>S.id));clearInterval(g.current),g.current=setInterval(()=>{x().then(S=>{(S!=null&&S.some($=>!k.has($.id))||Date.parse(v.expiresAt)<Date.now())&&(clearInterval(g.current),u(null))})},F$)},v=>f(v.message))};if(o)return e.jsx(be,{what:"your machines",reason:"This orchestrator does not answer for machines yet; it runs tasks itself.",next:e.jsx("a",{href:re("tasks"),children:"Start a task"}),panel:!0});if(a)return e.jsx(be,{what:"your machines",reason:a,onRetry:()=>void x(),panel:!0});if(!t)return e.jsx(he,{what:"your machines",panel:!0});const b=d?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Run this on the machine, once, before ",Qf(d.expiresAt),"; the code works one time and is not shown again."]}),e.jsx(mt,{text:d.command,label:"Copy the command"}),e.jsx("p",{className:"muted small",role:"status",children:"Waiting for the machine to connect…"})]}):null,N=m?e.jsx("p",{className:"error",role:"alert",children:m}):null;return t.length?e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"panel","aria-labelledby":"machines-h",children:[e.jsx("h2",{id:"machines-h",className:"visually-hidden",children:"Your machines"}),e.jsxs("p",{className:"muted",children:[t.length===1?"1 machine is connected.":`${t.length} machines are connected.`," Tasks you start run here, with the agent CLIs you are signed in to; nothing runs on anyone else's machine."]}),e.jsx("ul",{className:"plain machines",children:t.map(v=>e.jsxs("li",{className:"machine","aria-label":v.name,children:[e.jsxs("p",{className:"machine-head",children:[e.jsx("strong",{children:v.name}),e.jsxs("span",{className:"muted small",children:[" ",v.platform,v.owner?`, ${v.owner}`:""]}),v.paused?e.jsx("span",{className:"badge warn",children:"Paused"}):v.online?e.jsx("span",{className:"badge ok",children:"Online"}):e.jsxs("span",{className:"badge",children:["Offline, last seen ",Qf(v.lastSeenAt)]})]}),e.jsx("ul",{className:"plain machine-agents",children:v.agents.map(k=>e.jsxs("li",{children:[yj(k),k.signIn==="signed-out"&&k.signInCommand?e.jsxs("span",{className:"small",children:[" Run on ",v.name,": ",e.jsx(mt,{text:k.signInCommand,label:`Copy the sign-in command for ${k.label}`})]}):null]},k.id))}),e.jsx(qe,{small:!0,trigger:"Remove",triggerLabel:`Remove ${v.name}`,consequence:`${v.name} stops taking your tasks at once; a task it is running stops and waits for you to continue it.`,confirm:"Remove machine",keep:"Keep machine",onConfirm:()=>ha.remove(v.id).then(()=>x())})]},v.id))})]}),e.jsxs("section",{className:"panel","aria-labelledby":"connect-machine-h",children:[e.jsx("h2",{id:"connect-machine-h",children:"Connect a machine"}),b??e.jsx("div",{className:"actions",children:e.jsx("button",{type:"button",onClick:y,children:"Connect a machine"})}),N]})]}):e.jsxs("section",{className:"panel","aria-labelledby":"machines-h",children:[e.jsx("h2",{id:"machines-h",className:"visually-hidden",children:"Your machines"}),e.jsxs("div",{className:"empty-state",children:[e.jsx("p",{className:"empty-state-title",children:"No machine connected yet"}),e.jsx("p",{className:"muted",children:"Tasks you start run only on your machines."}),b??e.jsx("div",{className:"actions",children:e.jsx("button",{type:"button",onClick:y,children:"Connect a machine"})}),N]})]})}function _$({me:t}){const[n,a]=h.useState(null),[l,o]=h.useState(""),[c,d]=h.useState(null),[u,m]=h.useState(null),f=()=>ef.read().then(x=>{a(x),o(x.name)},x=>d(x.message));if(h.useEffect(()=>{f()},[]),!n)return c?e.jsx(be,{what:"the organization",reason:c,panel:!0,onRetry:()=>{d(null),f()}}):e.jsx(he,{what:"the organization",panel:!0});const g=x=>{x.preventDefault(),d(null),m(null),ef.rename(l).then(y=>{a(y),o(y.name),m(`The organization is now named ${y.name}.`)},y=>d(y.message))};return e.jsxs(e.Fragment,{children:[c?e.jsx("p",{className:"error",role:"alert",children:c}):null,u?e.jsx("p",{className:"notice",role:"status",children:u}):null,e.jsxs("section",{className:"panel","aria-labelledby":"org-h",children:[e.jsx("h2",{id:"org-h",children:"Organization"}),t.role==="owner"?e.jsxs("form",{className:"form inline-form",onSubmit:g,"aria-label":"Organization name",children:[e.jsxs("label",{children:["Name",e.jsx("input",{value:l,onChange:x=>o(x.target.value),maxLength:80,required:!0})]}),e.jsx("button",{type:"submit",className:"secondary",children:"Rename"})]}):e.jsx("p",{children:n.name}),e.jsxs("p",{className:"muted",children:["Its address stays /",n.tenant,". ",e.jsx(Ie,{label:"the organization's address",children:"Organizations are added and removed in the orchestrator's configuration file, by whoever runs the orchestrator."})]})]})]})}function U$({me:t}){const[n,a]=h.useState(null),[l,o]=h.useState(""),[c,d]=h.useState(""),[u,m]=h.useState(null),[f,g]=h.useState(null),x=h.useId(),y=h.useId(),b=Me(t),N=()=>tf.read().then($=>{a($),o(String($.privacy.taskLogDays)),d(String($.privacy.usageDays))},$=>m($.message));if(h.useEffect(()=>{b&&N()},[b]),!b)return e.jsx("section",{className:"panel",children:e.jsx("p",{children:"Only owners and admins see privacy settings."})});if(!n)return u?e.jsx(be,{what:"privacy settings",reason:u,panel:!0,onRetry:()=>{m(null),N()}}):e.jsx(he,{what:"privacy settings",panel:!0});const v=($,E)=>{m(null),g(null),tf.change($).then(C=>{a({...n,privacy:C}),g(E)},C=>m(C.message))},k=$=>{$.preventDefault(),v({taskLogDays:Number(l)},`Task logs are kept ${l} days; older lines are deleted now.`)},S=$=>{$.preventDefault(),v({usageDays:Number(c)},`Skill use is kept ${c} days; older counts are deleted now.`)};return e.jsxs(e.Fragment,{children:[u?e.jsx("p",{className:"error",role:"alert",children:u}):null,f?e.jsx("p",{className:"notice",role:"status",children:f}):null,t.mode!=="local"?e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"panel","aria-labelledby":"usage-h",children:[e.jsx("h2",{id:"usage-h",children:"Usage reporting"}),e.jsxs("p",{className:"muted",children:["A team reports skill use only once a request asking it to is merged into its repository. ",e.jsx(Ie,{label:"usage reporting",children:"It stops the same way. Counts arrive as totals per skill and hour; no session text leaves a teammate's machine."})]}),e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Repository"}),e.jsx("th",{children:"Team"}),e.jsx("th",{children:"Reports skill use"})]})}),e.jsx("tbody",{children:n.usage.map($=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("a",{href:re("repositories",$.repoId),children:$.name})}),e.jsx("td",{children:$.team}),e.jsx("td",{children:$.reporting===null?"not read yet":$.reporting?"yes":"no"})]},$.repoId))})]}),e.jsx("p",{className:"muted",children:"To ask a team or stop asking, open its repository and use the usage reporting request there."})]}),e.jsxs("section",{className:"panel","aria-labelledby":"board-h",children:[e.jsx("h2",{id:"board-h",children:"Leaderboard visibility"}),e.jsxs("fieldset",{className:"plain-fieldset",children:[e.jsx("legend",{className:"visually-hidden",children:"Who sees the usage leaderboard"}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"radio",name:"leaderboard",checked:n.privacy.leaderboard==="admins",onChange:()=>v({leaderboard:"admins"},"The leaderboard is visible to owners and admins.")}),"Owners and admins only"]}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"radio",name:"leaderboard",checked:n.privacy.leaderboard==="members",onChange:()=>v({leaderboard:"members"},"The leaderboard is visible to members.")}),"Leaderboard visible to members"]})]})]})]}):null,e.jsxs("section",{className:"panel","aria-labelledby":"logs-h",children:[e.jsx("h2",{id:"logs-h",children:"Task log retention"}),e.jsxs("form",{className:"form inline-form",onSubmit:k,"aria-label":"Task log retention",children:[e.jsxs("label",{children:["Days to keep task logs",e.jsx("input",{type:"number",min:1,max:365,value:l,onChange:$=>o($.target.value),required:!0,"aria-describedby":x})]}),e.jsx("button",{type:"submit",className:"secondary",children:"Save"})]}),e.jsx("p",{className:"muted",id:x,children:"The agent's output lines go after this many days; the task, its outcome and its request stay."})]}),e.jsxs("section",{className:"panel","aria-labelledby":"usage-days-h",children:[e.jsx("h2",{id:"usage-days-h",children:"Skill use retention"}),e.jsxs("form",{className:"form inline-form",onSubmit:S,"aria-label":"Skill use retention",children:[e.jsxs("label",{children:["Days to keep skill use",e.jsx("input",{type:"number",min:90,max:3650,value:c,onChange:$=>d($.target.value),required:!0,"aria-describedby":y})]}),e.jsx("button",{type:"submit",className:"secondary",children:"Save"})]}),e.jsxs("p",{className:"muted",id:y,children:["Counts older than this are deleted, not summed; the minimum is 90 days. ",e.jsx(Ie,{label:"skill use retention",children:"90 days is the longest range Usage shows and exports, so no chart or export loses a day it shows."})]})]})]})}function qi({topic:t,lead:n,children:a}){return e.jsxs("div",{className:"muted",children:[e.jsx("p",{children:n}),e.jsxs("details",{children:[e.jsxs("summary",{children:["More",e.jsxs("span",{className:"visually-hidden",children:[" about ",t]})]}),e.jsx("p",{children:a})]})]})}function Jf(t){return Object.entries(t).filter(([,n])=>n.trim()).map(([n,a])=>({group:n,tag:a.trim().toLowerCase()}))}function D$({me:t,view:n,onApplied:a}){var N;const[l,o]=h.useState(()=>Object.fromEntries(n.groups.map(v=>[v.group,v.tag??""]))),[c,d]=h.useState(null),[u,m]=h.useState(null),[f,g]=h.useState(null),x=(v,k)=>{o({...l,[v]:k}),d(null)},y=()=>{m(null),g(null),ji.preview(Jf(l)).then(d,v=>m(v.message))},b=()=>{c&&ji.apply(Jf(l),c.fingerprint).then(()=>{d(null),g("Applied. Members of each group have its tag, and lose it when a later sign-in no longer lists the group."),a()},v=>m(v.message))};return n.groups.length?e.jsxs(e.Fragment,{children:[e.jsx(qi,{topic:"directory sync",lead:"Members of each group get its tag and lose it when they leave the group.",children:"Tags added by hand stay. A group with no tag gives none. A change is previewed first, and only an owner applies it."}),e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Group"}),e.jsx("th",{children:"Members"}),e.jsx("th",{children:"Tag"})]})}),e.jsx("tbody",{children:n.groups.map(v=>e.jsxs("tr",{children:[e.jsx("td",{className:"mono",children:v.group}),e.jsx("td",{children:v.members}),e.jsx("td",{children:e.jsx("input",{"aria-label":`Tag for ${v.group}`,value:l[v.group]??"",onChange:k=>x(v.group,k.target.value),placeholder:"no tag"})})]},v.group))})]}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",className:"secondary",onClick:y,children:"Preview"}),t.role==="owner"?e.jsx("button",{type:"button",disabled:!c,onClick:b,children:"Apply tag changes"}):e.jsx("span",{className:"muted",children:"Only an owner applies a change."})]}),u?e.jsx("p",{className:"error",role:"alert",children:u}):null,f?e.jsx("p",{className:"notice",role:"status",children:f}):null,c?e.jsxs("section",{"aria-labelledby":"preview-h",children:[e.jsx("h3",{id:"preview-h",children:"Preview"}),c.changes.length?e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Member"}),e.jsx("th",{children:"Gains"}),e.jsx("th",{children:"Loses"})]})}),e.jsx("tbody",{children:c.changes.map(v=>e.jsxs("tr",{children:[e.jsxs("td",{children:[v.member.name,e.jsx("div",{className:"muted",children:v.member.email})]}),e.jsx("td",{children:v.gains.join(", ")||"none"}),e.jsx("td",{children:v.loses.join(", ")||"none"})]},v.member.id))})]}):e.jsx("p",{className:"muted",children:"Nobody's tags change."})]}):null]}):e.jsxs("p",{className:"muted",children:["No group yet. Groups appear here once members sign in through SSO and the ID token lists them in the ",((N=n.sso)==null?void 0:N.groupsClaim)??"groups"," claim."]})}function B$({me:t}){const[n,a]=h.useState(null),[l,o]=h.useState(!1),[c,d]=h.useState(""),[u,m]=h.useState(null),f=t.role==="owner",g=()=>Qo.list().then(b=>{a(b.domains),o(b.sso)},b=>m(b.message));h.useEffect(()=>{g()},[]);const x=(b,N)=>{m(null),b.then(g,v=>m(`${N} ${v.message}`))},y=b=>{b.preventDefault(),x(Qo.add(c).then(()=>d("")),"Failed to add the SSO domain.")};return n?e.jsxs(e.Fragment,{children:[e.jsx(qi,{topic:"SSO domains",lead:"Everyone at a verified domain signs in through SSO.",children:"They join as members when the identity provider lets them in, and a password no longer opens their account. Owners keep their password, so a broken provider locks nobody out. Once a domain is verified, only addresses at verified domains join without an invitation."}),u?e.jsx("p",{className:"error",role:"alert",children:u}):null,n.length?e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Domain"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:e.jsx("span",{className:"visually-hidden",children:"Actions"})})]})}),e.jsx("tbody",{children:n.map(b=>e.jsxs("tr",{children:[e.jsx("td",{className:"mono",children:b.domain}),e.jsx("td",{children:b.verified?"Verified; signs in with SSO":e.jsxs(e.Fragment,{children:["Add this TXT record, then verify:",e.jsx("div",{className:"mono",children:b.record.name}),e.jsx("code",{className:"link",children:b.record.value})]})}),e.jsxs("td",{className:"row-actions",children:[f&&!b.verified?e.jsx("button",{type:"button",className:"secondary small","aria-label":`Verify ${b.domain}`,onClick:()=>x(Qo.verify(b.domain),"Failed to verify the SSO domain."),children:"Verify"}):null,f?e.jsx("button",{type:"button",className:"secondary small","aria-label":`Remove ${b.domain}`,onClick:()=>x(Qo.remove(b.domain),"Failed to remove the SSO domain. Try again."),children:"Remove"}):null]})]},b.domain))})]}):e.jsx("p",{className:"muted",children:"No domain yet."}),f&&l?e.jsxs("form",{className:"form inline-form",onSubmit:y,"aria-label":"Add a domain",children:[e.jsxs("label",{children:["Domain",e.jsx("input",{value:c,onChange:b=>d(b.target.value),placeholder:"example.com",required:!0})]}),e.jsx("button",{type:"submit",className:"secondary",children:"Add domain"})]}):e.jsx("p",{className:"muted",children:f?"Set up single sign-on to add a domain.":"Only an owner adds, verifies and removes domains."})]}):u?e.jsx(be,{what:"SSO domains",reason:u,onRetry:()=>{m(null),g()}}):e.jsx(he,{what:"SSO domains"})}function q$({me:t}){const[n,a]=h.useState(null),[l,o]=h.useState(null),[c,d]=h.useState(null),u=t.role==="owner",m=()=>Cu.read().then(a,g=>d(g.message));h.useEffect(()=>{m()},[]);const f=()=>Cu.create().then(g=>(o(g.token),m()));return n?e.jsxs(e.Fragment,{children:[e.jsx(qi,{topic:"directory provisioning",lead:"Your identity provider adds, turns off and removes people here.",children:"It also keeps the groups directory sync maps to tags. Once it is on, single sign-on stops adding people nobody assigned, and someone the directory turns off loses their sessions, API keys and app tokens at once. The last owner is never turned off this way."}),e.jsxs("dl",{className:"facts",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"SCIM base URL"}),e.jsx("dd",{children:e.jsx(mt,{text:n.baseUrl,label:"Copy the SCIM base URL"})})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Token"}),e.jsx("dd",{children:n.token?e.jsxs(e.Fragment,{children:[n.token.prefix,"_… made by ",n.token.createdBy,"; ",n.token.lastUsedAt?`last used ${new Date(n.token.lastUsedAt).toLocaleString()}`:"not used yet"]}):"none; provisioning is off"})]})]}),l?e.jsxs("section",{className:"notice","aria-label":"New SCIM token",children:[e.jsx("p",{children:"Give this token to your identity provider now; it is shown once."}),e.jsx(mt,{text:l,label:"Copy the SCIM token"}),e.jsx("div",{className:"actions",children:e.jsx("button",{type:"button",className:"secondary small",onClick:()=>o(null),children:"I copied it"})})]}):null,c?e.jsx("p",{className:"error",role:"alert",children:c}):null,u?e.jsx("div",{className:"actions",children:n.token?e.jsxs(e.Fragment,{children:[e.jsx(qe,{trigger:"Replace token",consequence:"The token the identity provider uses now stops working at once; give it the new one.",confirm:"Make a new token",keep:"Keep the token",onConfirm:f}),e.jsx(qe,{trigger:"Turn off",consequence:"The identity provider no longer reaches this organization, and single sign-on adds people again. Nobody already here is removed.",confirm:"Turn off provisioning",keep:"Keep it on",onConfirm:()=>Cu.remove().then(m)})]}):e.jsx("button",{type:"button",onClick:()=>f().catch(g=>d(g.message)),children:"Make a SCIM token"})}):e.jsx("p",{className:"muted",children:"Only an owner turns provisioning on or off."})]}):c?e.jsx(be,{what:"directory provisioning",reason:c,onRetry:()=>{d(null),m()}}):e.jsx(he,{what:"directory provisioning"})}const Xf={google:"Google Workspace",microsoft:"Microsoft"};function W$({me:t}){const[n,a]=h.useState(null),[l,o]=h.useState("member"),[c,d]=h.useState(null),u=()=>Zp.read().then(a,g=>d(g.message));h.useEffect(()=>{u()},[]);const m=g=>{d(null),Zp.set(g,l).then(u,x=>d(x.message))},f=t.role==="owner";return e.jsxs("section",{className:"panel","aria-labelledby":"directory-join-h",children:[e.jsx("h2",{id:"directory-join-h",children:"Join without an invitation"}),e.jsx(qi,{topic:"joining by directory",lead:"People signed in with an account in your own Google Workspace or Microsoft directory see this organization and join it with one click.",children:"The directory is the one your own account is in, as Google or Microsoft says when you sign in, so nobody opens an organization to a directory they are not in. GitHub names no directory. Someone you remove comes back only through an invitation."}),n&&c?e.jsx("p",{className:"error",role:"alert",children:c}):null,n?n.join?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["People in the ",Xf[n.join.provider]," directory ",e.jsx("span",{className:"mono",children:n.join.directory})," join as ",n.join.role,"s."]}),f?e.jsx("div",{className:"actions",children:e.jsx("button",{type:"button",className:"secondary",onClick:()=>m(!1),children:"Stop letting them join"})}):null]}):f?n.yours?e.jsxs("div",{className:"form",children:[e.jsxs("p",{children:["Let people in your ",Xf[n.yours.provider]," directory ",e.jsx("span",{className:"mono",children:n.yours.directory})," join."]}),e.jsx(Pe,{label:"They join as",value:l,onChange:g=>o(g),options:[{value:"member",label:"Member"},{value:"viewer",label:"Viewer"}]}),e.jsx("div",{className:"actions",children:e.jsx("button",{type:"button",onClick:()=>m(!0),children:"Let them join"})})]}):e.jsx("p",{children:"Nobody joins without an invitation. To open it to your colleagues, sign in with your Google Workspace or Microsoft work account."}):e.jsx("p",{children:"Nobody joins without an invitation."}):c?e.jsx(be,{what:"who joins without an invitation",reason:c,onRetry:()=>{d(null),u()}}):e.jsx(he,{what:"who joins without an invitation"})]})}function z$({me:t}){const[n,a]=h.useState(null),[l,o]=h.useState(null),[c,d]=h.useState(0),u=Me(t);return h.useEffect(()=>{u&&ji.read().then(a,m=>o(m.message))},[u,c]),u?e.jsxs(e.Fragment,{children:[t.mode==="cloud"?e.jsx(W$,{me:t}):null,e.jsxs("section",{className:"panel","aria-labelledby":"sso-h",children:[e.jsx("h2",{id:"sso-h",children:"Single sign-on"}),l?e.jsx(be,{what:"single sign-on and directory settings",reason:l,onRetry:()=>{o(null),d(c+1)}}):null,n!=null&&n.sso?e.jsxs("dl",{className:"facts",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"OpenID Connect"}),e.jsx("dd",{className:"mono",children:n.sso.issuer})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Groups claim"}),e.jsx("dd",{className:"mono",children:n.sso.groupsClaim})]})]}):n?e.jsx("p",{children:"Single sign-on is off. It is set where the orchestrator runs, with ORCHESTRATOR_OIDC_ISSUER, ORCHESTRATOR_OIDC_CLIENT_ID and ORCHESTRATOR_OIDC_CLIENT_SECRET."}):null,e.jsxs("details",{className:"muted",children:[e.jsx("summary",{children:"Why not SAML?"}),e.jsx("p",{children:"SAML is not offered: checking a SAML response safely takes an XML signature library this orchestrator does not carry. Identity providers that speak SAML also speak OpenID Connect; connect that."})]})]}),e.jsxs("section",{className:"panel","aria-labelledby":"domains-h",children:[e.jsx("h2",{id:"domains-h",children:"SSO domains"}),e.jsx(B$,{me:t})]}),e.jsxs("section",{className:"panel","aria-labelledby":"scim-h",children:[e.jsx("h2",{id:"scim-h",children:"Directory provisioning (SCIM)"}),e.jsx(q$,{me:t})]}),e.jsxs("section",{className:"panel","aria-labelledby":"dir-h",children:[e.jsx("h2",{id:"dir-h",children:"Directory sync"}),n?e.jsx(D$,{me:t,view:n,onApplied:()=>d(c+1)}):l?null:e.jsx(he,{what:"directory sync"})]})]}):e.jsx("section",{className:"panel",children:e.jsx("p",{children:"Only owners and admins see security settings."})})}function H$(t){return t?new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}):"not yet"}function G$({teams:t,onCreated:n}){const[a,l]=h.useState(""),[o,c]=h.useState([]),[d,u]=h.useState(null),m=f=>{f.preventDefault(),u(null),Da.createServiceAccount({name:a,teams:o}).then(()=>{l(""),c([]),n()},g=>u(g.message))};return e.jsxs("form",{className:"form",onSubmit:m,"aria-labelledby":"new-sa-h",children:[e.jsx("h2",{id:"new-sa-h",children:"Add service account"}),e.jsxs("p",{className:"muted",children:["For CI and automations; it acts on the teams you pick. ",e.jsx(Ie,{label:"service accounts",children:"It is a member that owns those teams, so its keys open requests and start tasks there; it never merges."})]}),e.jsxs("label",{children:["Name",e.jsx("input",{value:a,onChange:f=>l(f.target.value),required:!0,maxLength:80})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Owns"}),e.jsx(_i,{teams:t,value:o,onChange:c,label:"Teams the service account owns"})]}),d?e.jsx("p",{className:"error",role:"alert",children:d}):null,e.jsx("div",{className:"actions",children:e.jsx("button",{type:"submit",children:"Add service account"})})]})}function K$({account:t,teams:n,onChanged:a}){const[l,o]=h.useState(!1),[c,d]=h.useState(null);return e.jsxs("section",{className:"panel","aria-labelledby":`sa-${t.id}`,children:[e.jsx("h2",{id:`sa-${t.id}`,children:t.name}),e.jsxs("dl",{className:"facts",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Active keys"}),e.jsx("dd",{children:t.activeKeys})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Last used"}),e.jsx("dd",{children:H$(t.lastUsedAt)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Added by"}),e.jsx("dd",{children:t.createdBy})]})]}),e.jsx(_i,{teams:n,value:t.ownedTeams,onChange:u=>Da.updateServiceAccount(t.id,{teams:u}).then(a,m=>d(m.message)),label:`Teams ${t.name} owns`}),c?e.jsx("p",{className:"error",role:"alert",children:c}):null,e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",className:"secondary small","aria-expanded":l,onClick:()=>o(!l),children:l?"Hide keys":"Show keys"}),e.jsx(qe,{small:!0,trigger:"Remove",triggerLabel:`Remove ${t.name}`,consequence:`This cannot be undone. Every key of ${t.name} stops working at once, and the teams it owns lose it as an owner.`,confirm:"Remove service account",keep:"Keep service account",onConfirm:()=>Da.removeServiceAccount(t.id).then(a)})]}),l?e.jsx(jj,{serviceAccountId:t.id,label:`Keys of ${t.name}`}):null]})}function Y$({me:t}){const[n,a]=h.useState(null),[l,o]=h.useState([]),[c,d]=h.useState(null),u=Me(t),m=()=>{u&&(Da.serviceAccounts().then(a,f=>d(f.message)),pn.teams().then(o,()=>o([])))};return h.useEffect(m,[u]),u?e.jsxs(e.Fragment,{children:[c?e.jsx("p",{className:"error",role:"alert",children:c}):null,n&&!n.length?e.jsx("section",{className:"panel",children:e.jsx("p",{className:"muted",children:"No service account yet."})}):null,(n??[]).map(f=>e.jsx(K$,{account:f,teams:l,onChanged:m},f.id)),e.jsx("section",{className:"panel",children:e.jsx(G$,{teams:l,onCreated:m})})]}):e.jsx("section",{className:"panel",children:e.jsx("p",{children:"Only owners and admins manage service accounts."})})}function V$({maxUsd:t,maxMinutes:n}){return t!==null&&n!==null?`A task now stops at $${t.toFixed(2)} or after ${n} minutes, whichever comes first.`:t!==null?`A task now stops at $${t.toFixed(2)}; how long it runs has no limit.`:n!==null?`A task now stops after ${n} minutes; what it spends has no limit.`:"A task now has no limit on what it spends or how long it runs."}function Zf({maxUsd:t,maxMinutes:n}){return t!==null&&n!==null?`A task stops at $${t.toFixed(2)} or after ${n} minutes, whichever comes first.`:t!==null?`A task stops at $${t.toFixed(2)}; how long it runs has no limit.`:n!==null?`A task stops after ${n} minutes; what it spends has no limit.`:"A task has no limit on what it spends or how long it runs."}function Q$({me:t}){const n=Me(t),[a,l]=h.useState(""),[o,c]=h.useState(""),[d,u]=h.useState(!1),[m,f]=h.useState(!1),[g,x]=h.useState(""),[y,b]=h.useState(""),[N,v]=h.useState(!1),[k,S]=h.useState(null),[$,E]=h.useState(null),[C,R]=h.useState(null),[P,M]=h.useState(!1),O=L=>{l(L.maxUsd===null?"":String(L.maxUsd)),c(L.maxMinutes===null?"":String(L.maxMinutes)),u(L.maxUsd===null),f(L.maxMinutes===null),x(L.secondSignIn??""),b(L.secondSignIn??""),v(!0)},_=()=>yi.read().then(O,L=>S(L.message));if(h.useEffect(()=>{_()},[]),k)return e.jsx(be,{what:"the task limits",reason:k,onRetry:()=>{S(null),_()}});if(!N)return e.jsx(he,{what:"the task limits"});const I=L=>{L.preventDefault(),M(!0),E(null),R(null),yi.change({maxUsd:d?null:Number(a),maxMinutes:m?null:Number(o),...g.trim()!==y?{secondSignIn:g.trim()||null}:{}}).then(K=>{O(K),R(V$(K))},K=>E(K.message)).finally(()=>M(!1))};return e.jsxs("section",{className:"section",children:[e.jsxs("p",{className:"muted",children:["A task stops at whichever comes first; the task form says both before Start.",n?"":" An owner or an admin changes them."]}),$?e.jsx("p",{className:"error",role:"alert",children:$}):null,C?e.jsx("p",{className:"notice",role:"status",children:C}):null,e.jsxs("form",{className:"form task-limits",onSubmit:I,"aria-label":"Task limits",children:[e.jsxs("div",{className:"task-limit",children:[e.jsxs("label",{children:["Most a task spends, in dollars",e.jsx("input",{type:"number",inputMode:"decimal",min:.01,max:1e3,step:.01,value:a,disabled:d||!n,required:!d,onChange:L=>l(L.target.value)})]}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:d,disabled:!n,onChange:L=>u(L.target.checked)}),"No limit"]})]}),e.jsxs("div",{className:"task-limit",children:[e.jsxs("label",{children:["Longest a task runs, in minutes",e.jsx("input",{type:"number",inputMode:"numeric",min:1,max:1440,step:1,value:o,disabled:m||!n,required:!m,onChange:L=>c(L.target.value)})]}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:m,disabled:!n,onChange:L=>f(L.target.checked)}),"No limit"]})]}),t.mode==="local"?e.jsxs("div",{className:"task-limit",children:[e.jsxs("label",{children:["Another Claude Code sign-in",e.jsx("input",{className:"mono",value:g,disabled:!n,onChange:L=>x(L.target.value),placeholder:"/home/ada/.claude-second",spellCheck:!1,autoComplete:"off","aria-describedby":"second-sign-in-note"})]}),e.jsx("p",{className:"muted small",id:"second-sign-in-note",children:"The full path of that Claude Code profile's folder, off until named. A task at your plan's usage limit can go on with it; the orchestrator starts Claude Code with that folder and reads nothing in it."})]}):null,n?e.jsx("div",{className:"actions",children:e.jsx("button",{type:"submit",disabled:P,children:"Save"})}):null]})]})}function J$(t){return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function Nl(t,n){return t.scope==="team"?n?"every repository":`team ${t.target}`:`repository ${t.target}`}function X$({repos:t,local:n,op:a,onSaved:l}){const o=[...new Set(t.map(_=>_.team))].sort(),[c,d]=h.useState("team"),[u,m]=h.useState(""),[f,g]=h.useState(""),[x,y]=h.useState(""),[b,N]=h.useState("typed"),[v,k]=h.useState(""),[S,$]=h.useState(null),E=b==="op"&&a!==null,C=h.useId(),R=c==="team"?o:t.map(_=>_.id),P=R.includes(u)?u:R[0]??"",M=_=>{_.preventDefault(),$(null),cd.set({scope:c,target:P,name:f.trim(),...E?{secret:{provider:"op",reference:v.trim()}}:{value:x}}).then(I=>{g(""),y(""),k(""),l(I)},I=>$(I.message))},O=S?{"aria-describedby":C}:{};return e.jsxs("form",{className:"form",onSubmit:M,"aria-labelledby":"new-secret-h",children:[e.jsx("h2",{id:"new-secret-h",children:"Add a secret"}),e.jsx(Pe,{label:"Applies to",value:c,onChange:_=>d(_),describedBy:O["aria-describedby"],options:[{value:"team",label:n?"Every repository":"Every repository of a team"},{value:"repo",label:"One repository"}]}),n&&c==="team"?null:e.jsx(Pe,{label:c==="team"?"Team":"Repository",value:P,onChange:m,describedBy:O["aria-describedby"],options:R.map(_=>({value:_,label:_}))}),e.jsxs("label",{children:["Name",e.jsx("input",{value:f,onChange:_=>g(_.target.value.toUpperCase()),placeholder:"NPM_TOKEN",required:!0,maxLength:64,autoComplete:"off",spellCheck:!1,...O})]}),a?e.jsx(Pe,{label:"Value",value:b,onChange:_=>N(_),describedBy:O["aria-describedby"],options:[{value:"typed",label:"Typed here"},{value:"op",label:"Read from 1Password"}]}):null,E?e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:["1Password reference",e.jsx("input",{value:v,onChange:_=>k(_.target.value),placeholder:`op://${a[0]??"vault"}/item/field`,required:!0,autoComplete:"off",spellCheck:!1,...O})]}),e.jsxs("p",{className:"muted",children:["Read when each task starts, from ",a.length===1?"the vault":"the vaults"," ",a.join(", "),"; nothing is copied here."]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:[a?"Typed value":"Value",e.jsx("input",{type:"password",value:x,onChange:_=>y(_.target.value),required:!0,autoComplete:"off",...O})]}),e.jsxs("p",{className:"muted",children:["A task's agent gets it as an environment variable; once saved it is never shown again. ",e.jsx(Ie,{label:"changing a value",children:"Save it again to change it."})]})]}),S?e.jsx("p",{className:"error",role:"alert",id:C,children:S}):null,e.jsx("div",{className:"actions",children:e.jsx("button",{type:"submit",disabled:!P,children:"Save secret"})})]})}function Z$({me:t}){const[n,a]=h.useState(null),[l,o]=h.useState(!0),[c,d]=h.useState(null),[u,m]=h.useState([]),[f,g]=h.useState(null),[x,y]=h.useState(null),b=Me(t),N=t.mode==="local",v=()=>cd.list().then(k=>{a(k.secrets),o(k.vault),d(k.op??null)},k=>g(`Couldn't load task secrets. ${k.message}`));return h.useEffect(()=>{b&&(v(),Ce.repos().then(m,()=>m([])))},[b]),b?e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"panel","aria-labelledby":"secrets-h",children:[e.jsxs("h2",{id:"secrets-h",children:["Task secrets ",e.jsx("span",{className:"count",children:(n==null?void 0:n.length)??0})]}),e.jsxs("p",{className:"muted",children:["Values a task's agent needs, masked in its log. ",e.jsx(Ie,{label:"which value applies",children:N?"A repository's own value replaces the one for every repository of the same name.":"A repository's value replaces its team's of the same name."})]}),f?e.jsx("p",{className:"error",role:"alert",children:f}):null,x?e.jsx("p",{className:"notice",role:"status",children:x}):null,l?null:e.jsx("p",{className:"error",children:N?"No secret is stored: the orchestrator has no key to seal them. Run handbook-orchestrator doctor for the step that fixes it.":"Set ORCHESTRATOR_SECRET_KEY where the orchestrator runs; without it no secret is stored."}),n?n.length?e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Name"}),e.jsx("th",{children:"Applies to"}),e.jsx("th",{children:"Changed"}),e.jsx("th",{children:e.jsx("span",{className:"visually-hidden",children:"Delete"})})]})}),e.jsx("tbody",{children:n.map(k=>e.jsxs("tr",{children:[e.jsxs("td",{children:[e.jsx("span",{className:"mono",children:k.name}),k.reference?e.jsx("div",{className:"muted mono small",children:k.reference}):null]}),e.jsx("td",{children:Nl(k,N)}),e.jsxs("td",{children:[J$(k.updatedAt),e.jsxs("div",{className:"muted",children:["by ",k.updatedBy]})]}),e.jsx("td",{children:e.jsx(qe,{small:!0,trigger:"Delete",triggerLabel:`Delete ${k.name} for ${Nl(k,N)}`,consequence:`This cannot be undone. The next task on ${Nl(k,N)} starts without ${k.name}.`,confirm:"Delete secret",keep:"Keep secret",onConfirm:()=>cd.remove(k).then(v)})})]},`${k.scope}:${k.target}:${k.name}`))})]}):e.jsx("p",{className:"muted",children:"No task secret yet."}):e.jsx("p",{className:"muted",children:"Loading task secrets..."})]}),l?e.jsx("section",{className:"panel",children:e.jsx(X$,{repos:u,local:N,op:c,onSaved:k=>{y(k.reference?`Saved ${k.name} for ${Nl(k,N)}; each task reads it from ${k.reference}.`:`Saved ${k.name} for ${Nl(k,N)}. The value is not shown again.`),v()}})}):null]}):e.jsx("section",{className:"panel",children:e.jsx("p",{children:"Only owners and admins manage task secrets."})})}const Sl={status:()=>U("GET","/api/update"),check:()=>U("POST","/api/update/check"),prepare:t=>U("POST","/api/update/prepare",{version:t}),apply:()=>U("POST","/api/update/apply"),restart:()=>U("POST","/api/update/restart")};function e0({status:t}){return t.from==="clone"?e.jsxs("p",{children:["This orchestrator runs from a clone. To update it, run ",e.jsx("code",{children:"git pull"}),t.folder?e.jsxs(e.Fragment,{children:[" in ",e.jsx("code",{children:t.folder})]}):null,", then ",e.jsx("code",{children:"npm start"}),"."]}):t.from==="npx"?e.jsxs("p",{children:["This orchestrator runs through npx; ",e.jsx("code",{children:"npx teamhandbook-orchestrator@latest"})," runs the newest release."]}):e.jsx("p",{children:"This orchestrator was not installed with install.sh, so it is updated the way it was installed."})}function t0(){const[t,n]=h.useState(null),[a,l]=h.useState(null),[o,c]=h.useState(0),[d,u]=h.useState(null),[m,f]=h.useState(null),[g,x]=h.useState([]),[y,b]=h.useState(null),[N,v]=h.useState(null),[k,S]=h.useState(!1);h.useEffect(()=>{l(null),Sl.status().then(n,O=>l(O.message))},[o]),h.useEffect(()=>{if(!k)return;let O=!1;const _=setInterval(()=>{fetch("/api/health").then(I=>{I.ok&&O&&window.location.reload(),I.ok||(O=!0)},()=>{O=!0})},2e3);return()=>clearInterval(_)},[k]);const $=(O,_,I)=>{b(O),v(null),_().then(I,L=>v(L.message)).finally(()=>b(null))};if(a)return e.jsx(be,{what:"the update state",reason:a,onRetry:()=>c(O=>O+1)});if(!t)return e.jsx(he,{what:"the update state"});if(!t.installed)return e.jsx("section",{className:"section",children:e.jsx(e0,{status:t})});if("refused"in t)return e.jsx("section",{className:"section",children:e.jsx("p",{className:"error",children:t.refused})});const E=d&&"newer"in d&&d.newer?d.newest:null,C=t.prepared,R=O=>{x(O.said),O.ok||v(O.said.at(-1)??"The step did not finish."),c(_=>_+1)};let P,M=null;return k?P="Starting again with the new version; this page answers once it is back.":m!=null&&m.ok?(P=m.restart==="service"?"Switched. The new version runs once the orchestrator starts again.":"Switched. Start the orchestrator again to run the new version.",m.restart==="service"&&(M={label:"Restart now",go:()=>$("restart",Sl.restart,()=>S(!0))})):C?(P=`${C} is prepared and checked.`,M={label:`Switch to ${C}`,go:()=>$("apply",Sl.apply,O=>{f(O),R(O)})}):E?(P=`${E} is out. Preparing downloads and checks it; this version keeps running.`,M={label:`Prepare ${E}`,go:()=>$("prepare",()=>Sl.prepare(E),R)}):(P=d&&"refused"in d?d.refused:d?`Running ${t.running}, the newest.`:`Running ${t.running}.`,M={label:"Check for updates",go:()=>$("check",Sl.check,u)}),e.jsxs("section",{className:"section","aria-labelledby":"updates-h",children:[e.jsx("h2",{id:"updates-h",children:"This orchestrator"}),e.jsx("p",{role:"status",children:P}),t.failed&&!C?e.jsxs("p",{className:"error",children:[t.failed.version," did not prepare: ",t.failed.reason]}):null,M?e.jsx("div",{className:"actions",children:e.jsx("button",{type:"button",disabled:y!==null,onClick:M.go,children:y?"Working…":M.label})}):null,N?e.jsx("p",{className:"error",role:"alert",children:N}):null,g.length?e.jsxs("details",{className:"section log-fold",children:[e.jsx("summary",{children:"What the update said"}),e.jsx("ol",{className:"task-log",children:g.map((O,_)=>e.jsx("li",{className:"mono",children:O},_))})]}):null]})}function n0({me:t,route:n,onLeft:a}){const[,l="account",o]=n.split("/").filter(Boolean),c=ui.find(f=>f.id===l&&eh(t,f.id));if(!c)return e.jsx(Sr,{org:Ts(window.location.pathname).org??"",path:window.location.pathname});const d=f=>re("settings",f),u=ex(t),m=e.jsx(Fi,{label:"Settings",current:d(c.id),links:u.map(f=>({to:d(f.id),label:f.label}))});return c.id==="members"&&o?e.jsx("div",{className:"page",children:e.jsx(O$,{id:o,me:t,nav:m})}):c.id==="members"?e.jsx("div",{className:"page",children:e.jsx(Mb,{me:t,nav:m,onLeft:a})}):c.id==="account"?e.jsx("div",{className:"page",children:e.jsx(t$,{me:t,nav:m,onChanged:a})}):e.jsxs("div",{className:"page",children:[e.jsx("header",{className:"page-head",children:e.jsx("h1",{children:c.label})}),m,c.id==="code"?e.jsx(w$,{me:t}):null,c.id==="task-limits"?e.jsx(Q$,{me:t}):null,c.id==="service-accounts"?e.jsx(Y$,{me:t}):null,c.id==="api-keys"?e.jsx(A$,{me:t}):null,c.id==="access"?e.jsx(l$,{me:t}):null,c.id==="task-secrets"?e.jsx(Z$,{me:t}):null,c.id==="agents"?e.jsx(a$,{}):null,c.id==="machines"?e.jsx(M$,{}):null,c.id==="security"?e.jsx(z$,{me:t}):null,c.id==="privacy"?e.jsx(U$,{me:t}):null,c.id==="organization"?e.jsx(_$,{me:t}):null,c.id==="updates"?e.jsx(t0,{}):null]})}function s0({repo:t,data:n,editable:a,onOpened:l,selected:o,onSelect:c}){const{inventory:d}=n,[u,m]=h.useState(null),f=x=>{m(null),l(x)},g={repoId:t.id,head:d.head,onOpened:f,onCancel:()=>m(null)};return e.jsxs("section",{className:"panel","aria-labelledby":"cmd-h",children:[e.jsxs("h2",{id:"cmd-h",children:["Slash commands ",e.jsx("span",{className:"count",children:d.commands.length}),a?e.jsx("button",{type:"button",className:"secondary small",onClick:()=>m({type:"command-add"}),children:"Add a command"}):null]}),(u==null?void 0:u.type)==="command-add"?e.jsx(Cd,{...g}):null,(u==null?void 0:u.type)==="command-edit"?e.jsx(Cd,{...g,name:u.name},u.name):null,(u==null?void 0:u.type)==="command-remove"?e.jsx(Ox,{...g,name:u.name},u.name):null,d.commands.length?e.jsx("ul",{className:"plain",children:d.commands.map(x=>e.jsxs("li",{children:[e.jsx("button",{type:"button",className:"link","aria-pressed":o===x.file,onClick:()=>c(x.file),children:e.jsxs("code",{children:["/",x.name]})})," ",e.jsx("span",{className:"muted",children:x.description}),a?e.jsxs("span",{className:"row-actions",children:[" ",e.jsx("button",{type:"button",className:"secondary small","aria-label":`Edit /${x.name}`,onClick:()=>m({type:"command-edit",name:x.name}),children:"Edit"}),e.jsx("button",{type:"button",className:"secondary small","aria-label":`Remove /${x.name}`,onClick:()=>m({type:"command-remove",name:x.name}),children:"Remove"})]}):null]},x.name))}):e.jsx("p",{className:"muted",children:"None shared yet. A command reaches this list when a request adds it under commands/."})]})}function a0({repoId:t,path:n,head:a}){const[l,o]=h.useState(null),[c,d]=h.useState(null),[u,m]=h.useState(0);return h.useEffect(()=>{let f=!0;return o(null),d(null),Ce.history(t,n).then(g=>f&&o(g),g=>f&&d(g.message)),()=>{f=!1}},[t,n,a,u]),c?e.jsx(be,{what:"the history",reason:c,onRetry:()=>m(f=>f+1)}):l?l.length?e.jsx("ol",{className:"history",children:l.map(f=>e.jsxs("li",{children:[e.jsx("code",{children:f.sha.slice(0,7)})," ",e.jsx("span",{children:f.subject}),e.jsxs("span",{className:"muted",children:[" by ",f.author," on ",f.date.slice(0,10)]})]},f.sha))}):e.jsx("p",{className:"muted",children:"No commits touch this path."}):e.jsx(he,{what:"the history"})}function r0({repo:t,data:n,me:a,editable:l,onOpened:o,selected:c,onSelect:d}){const u=a.mode==="local",{inventory:m}=n,[f,g]=h.useState(null),x=m.mcpServers.some(v=>v.inTasks),y=v=>{g(null),o(v)},b={repoId:t.id,head:m.head,onOpened:y,onCancel:()=>g(null)},N=v=>k=>{k.stopPropagation(),v()};return e.jsxs("section",{className:"panel","aria-labelledby":"mcp-h",children:[e.jsxs("h2",{id:"mcp-h",children:["MCP servers ",e.jsx("span",{className:"count",children:m.mcpServers.length}),l&&m.mcpServers.length?e.jsx("button",{type:"button",className:"secondary small",onClick:()=>g({type:"mcp"}),children:"Add a server"}):null]}),!m.mcpServers.length&&!f?e.jsxs("div",{className:"empty",children:[e.jsx("p",{children:u?"No MCP server here yet; the first one is in the repository, and in your tasks, once its request is merged.":l?"No MCP server is shared here yet; one added here starts on every teammate's machine once its request is merged.":`No MCP server is shared here yet; an owner of ${t.team} adds the first one.`}),l?e.jsx("p",{children:e.jsx("button",{type:"button",onClick:()=>g({type:"mcp"}),children:"Add a server"})}):null]}):null,(f==null?void 0:f.type)==="mcp"?e.jsx($d,{...b}):null,(f==null?void 0:f.type)==="mcp-edit"?e.jsx($d,{...b,name:f.name},f.name):null,(f==null?void 0:f.type)==="mcp-remove"?e.jsx(Fx,{...b,name:f.name},f.name):null,m.mcpServers.length?e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Server"}),e.jsx("th",{children:"What it runs"}),e.jsx("th",{children:"Status"}),l?e.jsx("th",{children:e.jsx("span",{className:"visually-hidden",children:"Changes"})}):null]})}),e.jsx("tbody",{children:m.mcpServers.map(v=>e.jsxs("tr",{className:c===".mcp.json"?"selected":void 0,onClick:()=>d(".mcp.json"),children:[e.jsx("td",{className:"mono",children:e.jsx("button",{type:"button",className:"link","aria-pressed":c===".mcp.json",onClick:()=>d(".mcp.json"),children:v.name})}),e.jsx("td",{className:"mono",children:v.target}),e.jsxs("td",{children:[v.shareable?e.jsx("span",{className:"badge ok",children:u?"shareable":"teammates get it"}):e.jsx("span",{className:"badge warn",children:"not shareable as written"}),e.jsxs("details",{onClick:k=>k.stopPropagation(),children:[e.jsx("summary",{children:"Details"}),e.jsxs("dl",{className:"facts",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Transport"}),e.jsx("dd",{children:v.transport})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Variables"}),e.jsx("dd",{className:"mono",children:v.envNames.join(", ")||"none"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Share rule"}),e.jsx("dd",{children:v.shareable?"passes":v.refusal})]}),x&&v.inTasks?e.jsxs("div",{children:[e.jsx("dt",{children:"In tasks"}),e.jsxs("dd",{children:[e.jsx("span",{className:`badge ${v.inTasks.usable&&!v.inTasks.signIn?"ok":"warn"}`,children:v.inTasks.usable?v.inTasks.signIn?"given, no sign-in":"given":"not given"})," ",e.jsx("span",{className:"muted",children:v.inTasks.detail})]})]}):null]})]})]}),l?e.jsxs("td",{className:"row-actions",children:[e.jsx("button",{type:"button",className:"secondary small",onClick:N(()=>g({type:"mcp-edit",name:v.name})),children:"Edit"}),e.jsx("button",{type:"button",className:"secondary small",onClick:N(()=>g({type:"mcp-remove",name:v.name})),children:"Remove"})]}):null]},v.name))})]}):null]})}const eg={ok:{badge:"ok",text:"fine"},attention:{badge:"warn",text:"attention"},problem:{badge:"error",text:"problem"},suggestion:{badge:"neutral",text:"suggestion"}};function l0({repoId:t,refresh:n}){const[a,l]=h.useState(!1),[o,c]=h.useState(null);if("problem"in n)return e.jsx("p",{className:"muted",children:n.problem});const d=()=>{l(!0),c(null),ge.start({title:"",description:"",issueUrl:"",repoId:t,agent:"",template:{kind:"scaffold.refresh",commitVersioning:!1}}).then(u=>Ge(re("tasks",u.id)),u=>{c(u.message),l(!1)})};return e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",disabled:a,onClick:d,children:"Update TeamHandbook's files"}),e.jsx("span",{className:"muted",children:"The orchestrator writes the files this release writes and opens them as a request; no agent runs."}),o?e.jsx("p",{className:"error",role:"alert",children:o}):null]})}function o0({findings:t,repoId:n,refresh:a,editable:l,local:o}){const c=t.filter(u=>u.level==="attention"||u.level==="problem").length,d=t.some(u=>u.level==="problem");return e.jsxs("section",{className:"panel","aria-labelledby":"setup-h",children:[e.jsx("h2",{id:"setup-h",children:"Setup"}),e.jsx("p",{children:d?e.jsx("span",{className:"badge error",children:o?"Something needs fixing":"Something stops teammates"}):c?e.jsxs("span",{className:"badge warn",children:[c===1?"One thing":`${c} things`," to look at"]}):e.jsx("span",{className:"badge ok",children:"All checks pass"})}),e.jsxs("details",{open:c>0,children:[e.jsx("summary",{children:c?"What to look at":"Every check"}),e.jsx("ul",{className:"findings",children:t.map(u=>e.jsxs("li",{children:[e.jsx("span",{className:`badge ${eg[u.level].badge}`,children:eg[u.level].text})," ",e.jsx("strong",{children:u.title}),u.detail?e.jsx("p",{className:"muted",children:u.detail}):null,u.next?e.jsxs("p",{children:["What to do: ",u.next]}):null,u.more?e.jsxs("details",{children:[e.jsx("summary",{children:"Details"}),e.jsx("p",{className:"muted",children:u.more})]}):null]},u.title))})]}),l&&t.some(u=>u.refresh)?e.jsx(l0,{repoId:n,refresh:a}):null]})}function tg({text:t}){const[n,a]=h.useState(null),l=()=>{if(!navigator.clipboard)return a("select it and copy");navigator.clipboard.writeText(t).then(()=>a("copied"),()=>a("select it and copy"))};return e.jsxs("li",{children:[e.jsx("code",{children:t})," ",e.jsx("button",{type:"button",className:"secondary small","aria-label":`Copy ${t}`,onClick:l,children:"Copy"}),n?e.jsxs("span",{className:"muted",role:"status",children:[" ",n]}):null]})}function i0({join:t}){return e.jsxs("section",{className:"panel","aria-labelledby":"join-h",children:[e.jsx("h2",{id:"join-h",children:"How teammates join"}),"problem"in t?e.jsx("p",{className:"muted",children:t.problem}):e.jsxs(e.Fragment,{children:[e.jsx("p",{children:"To use the team's skills, in Claude Code:"}),e.jsx("ul",{className:"plain",children:t.use.map(n=>e.jsx(tg,{text:n},n))}),e.jsx("p",{children:"To also share their own, with TeamHandbook installed:"}),e.jsx("ul",{className:"plain",children:e.jsx(tg,{text:t.contribute})}),e.jsx("p",{className:"muted",children:"A private repository also needs each teammate signed in to its forge on their own machine."})]})]})}function c0({data:t,editable:n,repo:a,me:l}){const{skills:o,mcpServers:c,commands:d}=t.inventory,u=(m,f)=>`${m} ${f}${m===1?"":"s"}`;return e.jsxs(e.Fragment,{children:[e.jsx(o0,{findings:t.inventory.setup,repoId:a.id,refresh:t.refresh,editable:n,local:l.mode==="local"}),e.jsxs("section",{className:"panel","aria-labelledby":"shares-h",children:[e.jsx("h2",{id:"shares-h",children:"What it shares"}),e.jsxs("p",{children:[e.jsx("a",{href:re("repositories",a.id,"skills"),children:u(o.length,"skill")}),", ",e.jsx("a",{href:re("repositories",a.id,"mcp"),children:u(c.length,"MCP server")}),", ",e.jsx("a",{href:re("repositories",a.id,"commands"),children:u(d.length,"slash command")})]})]}),l.mode==="local"?null:e.jsx(i0,{join:t.join})]})}const u0={clean:{badge:"ok",text:"nothing unusual"},attention:{badge:"warn",text:"to look at"},refused:{badge:"error",text:"would not be shared as written"},unread:{badge:"neutral",text:"not read yet"}};function d0({scan:t}){if(!t)return e.jsx("span",{className:"muted",children:"not read yet"});const n=u0[t.state],a=t.state==="attention"?`${t.findings.length} ${n.text}`:n.text;return e.jsxs("div",{className:"scan",children:[e.jsx("span",{className:`badge ${n.badge}`,children:a}),t.state==="unread"&&t.reason?e.jsx("p",{className:"muted small",children:t.reason}):null,t.findings.length?e.jsxs("details",{children:[e.jsx("summary",{children:"What was found"}),e.jsx("ul",{className:"plain scan-findings",children:t.findings.map((l,o)=>e.jsxs("li",{children:[e.jsxs("span",{className:"mono",children:[l.path,l.line?`:${l.line}`:""]}),l.risk?e.jsxs(e.Fragment,{children:[" ",e.jsxs("span",{className:`badge ${l.risk==="high"?"error":"warn"}`,children:[l.risk," risk"]})]}):null,l.level==="refused"?e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{className:"badge error",children:"not shared as written"})]}):null,e.jsx("p",{className:"muted small",children:l.detail}),l.evidence?e.jsx("code",{className:"scan-evidence",children:l.evidence}):null]},`${l.path}:${l.line??""}:${o}`))})]}):null]})}function h0({repoId:t,version:n}){var m,f;const[a,l]=h.useState(null),[o,c]=h.useState(null);h.useEffect(()=>{c(null),Ce.pending(t).then(l,g=>c(g.message))},[t,n]);const d=((m=a==null?void 0:a.pending)==null?void 0:m.filter(g=>!g.byOrchestrator))??[],u=(((f=a==null?void 0:a.pending)==null?void 0:f.length)??0)-d.length;return e.jsxs("section",{className:"panel","aria-labelledby":"pending-h",children:[e.jsxs("h2",{id:"pending-h",children:["Waiting to be merged ",e.jsx("span",{className:"count",children:a!=null&&a.pending?d.length:""})]}),a!=null&&a.pending&&u?e.jsxs("p",{className:"muted",children:[u," more, opened from the orchestrator, ",u===1?"is":"are"," under Requests from the orchestrator."]}):null,o?e.jsx("p",{className:"error",children:o}):a?a.pending?d.length?e.jsxs("table",{className:"row-cards",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Request"}),e.jsx("th",{children:"Branch"}),e.jsx("th",{children:"By"}),e.jsx("th",{children:"Updated"}),e.jsx("th",{children:"Read before merging"})]})}),e.jsx("tbody",{children:d.map(g=>{var x;return e.jsxs("tr",{children:[e.jsxs("td",{className:"rc-title",children:[g.url?e.jsxs("a",{href:g.url,target:"_blank",rel:"noreferrer noopener",children:[g.number!==null?`#${g.number} `:"",g.title]}):e.jsxs(e.Fragment,{children:[g.number!==null?`#${g.number} `:"",g.title]}),g.fromFork?e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{className:"badge warn",children:"from a fork"})]}):null,g.number!==null?e.jsx(Fr,{reads:Ui(t,g.number)}):null]}),e.jsx("td",{className:"mono rc-extra",children:g.branch}),e.jsx("td",{className:"rc-meta",children:g.author}),e.jsx("td",{className:"rc-meta",children:g.updatedAt.slice(0,16).replace("T"," ")}),e.jsxs("td",{className:"rc-wide",children:[e.jsx(d0,{scan:g.scan??null}),g.number!==null&&((x=g.url)!=null&&x.startsWith("http"))?e.jsx(hh,{request:{repoId:t,number:g.number,status:"open",provider:"hosted"}}):null]})]},`${g.number??""}:${g.fromFork?"fork":""}:${g.branch}`)})})]}):e.jsx("p",{className:"muted",children:"Nothing else waits to be merged."}):e.jsx("p",{className:"muted",children:a.reason}):e.jsx("p",{className:"muted",children:"Reading the forge…"})]})}function m0({repo:t,me:n,onChanged:a,requestsRead:l}){const[o,c]=h.useState(null);return e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"panel","aria-labelledby":"req-h",children:[e.jsxs("h2",{id:"req-h",children:["Requests from the orchestrator ",e.jsx("span",{className:"count",children:o??""})]}),e.jsxs("p",{className:"muted",children:["Nothing reaches teammates until a reviewer merges it. ",e.jsx(Ie,{label:"requests",children:xh.request.means})]}),e.jsx(eN,{repoId:t.id,repos:[t],me:n,version:l,onCounts:d=>c(d.counts.open+d.counts.merged+d.counts.closed),onChanged:a})]}),e.jsx(h0,{repoId:t.id,version:l})]})}function p0({repo:t,data:n,me:a,editable:l,usage:o,overlaps:c,onOpened:d,selected:u,onSelect:m}){const f=a.mode==="local",{inventory:g}=n,x=g.team,[y,b]=h.useState(null),[N,v]=h.useState(""),[k,S]=h.useState(1),$=new Map(((o==null?void 0:o.usage)??[]).map(_=>[_.skill,_])),E=N.trim().toLowerCase(),C=E?g.skills.filter(_=>_.slug.includes(E)||_.description.toLowerCase().includes(E)):g.skills,R=Jd(C,k),P=_=>{b(null),d(_)},M={repoId:t.id,head:g.head,onOpened:P,onCancel:()=>b(null)},O=_=>I=>{I.stopPropagation(),_()};return e.jsxs("section",{className:"panel","aria-labelledby":"skills-h",children:[e.jsxs("h2",{id:"skills-h",children:["Skills ",e.jsx("span",{className:"count",children:g.skills.length}),l&&g.skills.length?e.jsx("button",{type:"button",className:"secondary small",onClick:()=>b({type:"skill-add"}),children:"Add a skill"}):null]}),!g.skills.length&&!y?e.jsxs("div",{className:"empty",children:[e.jsx("p",{children:f?"No skill here yet; the first one is in the repository once its request is merged.":l?"No skill is shared here yet; the first one reaches teammates once its request is merged.":`No skill is shared here yet; an owner of ${t.team} adds the first one.`}),l?e.jsx("p",{children:e.jsx("button",{type:"button",onClick:()=>b({type:"skill-add"}),children:"Add a skill"})}):null]}):null,(y==null?void 0:y.type)==="skill-add"?e.jsx(Sd,{...M}):null,(y==null?void 0:y.type)==="skill-edit"?e.jsx(Sd,{...M,slug:y.slug},y.slug):null,(y==null?void 0:y.type)==="skill-remove"?e.jsx(Lx,{...M,slug:y.slug},y.slug):null,g.skills.length>Dl?e.jsxs("label",{className:"filter",children:["Find a skill",e.jsx("input",{type:"search",value:N,onChange:_=>{v(_.target.value),S(1)}})]}):null,E&&!C.length?e.jsxs("p",{className:"muted",children:["No skill matches “",N.trim(),"”."]}):null,g.skills.length?e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Skill"}),e.jsx("th",{children:"Description"}),e.jsx("th",{children:"Files"}),f?null:e.jsxs("th",{children:["Used, last ",(o==null?void 0:o.days)??30," days"]}),l?e.jsx("th",{children:e.jsx("span",{className:"visually-hidden",children:"Changes"})}):null]})}),e.jsx("tbody",{children:R.shown.map(_=>{var I,L;return e.jsxs("tr",{className:u===`skills/${_.slug}`?"selected":void 0,onClick:()=>m(`skills/${_.slug}`),children:[e.jsx("td",{className:"mono",children:e.jsx("button",{type:"button",className:"link","aria-pressed":u===`skills/${_.slug}`,onClick:()=>m(`skills/${_.slug}`),children:_.slug})}),e.jsxs("td",{children:[_.problem?e.jsx("span",{className:"error",children:_.problem}):_.description,(I=c==null?void 0:c[_.slug])!=null&&I.names.length?e.jsxs("p",{className:"muted",children:["Answers the same requests as ",c[_.slug].names.join(", "),c[_.slug].more?` and ${c[_.slug].more} more`:"",", so Claude can pick either."]}):null,_.format.length?e.jsxs("details",{onClick:K=>K.stopPropagation(),children:[e.jsxs("summary",{children:[_.format.length," ",_.format.length===1?"thing":"things"," the plugin's skill format asks for"]}),e.jsx("ul",{children:_.format.map(K=>e.jsx("li",{children:K},K))})]}):null]}),e.jsx("td",{children:_.files.join(", ")}),f?null:e.jsx("td",{children:x!=null&&x.usageEndpoint?(o==null?void 0:o.shown)===!1?e.jsx("span",{className:"muted",children:"shown to the team's owners"}):((L=$.get(_.slug))==null?void 0:L.count)??0:e.jsx("span",{className:"muted",children:"not reported"})}),l?e.jsxs("td",{className:"row-actions",children:[e.jsx("button",{type:"button",className:"secondary small",onClick:O(()=>b({type:"skill-edit",slug:_.slug})),children:"Edit"}),e.jsx("button",{type:"button",className:"secondary small",onClick:O(()=>b({type:"skill-remove",slug:_.slug})),children:"Remove"})]}):null]},_.slug)})})]}):null,e.jsx(Li,{page:R.page,total:C.length,onPage:S,label:"Pages of skills"})]})}function f0(t,n){return[`${t.name}: ${t.message}`,`at ${n}`,...t.stack?[t.stack]:[]].join(`
|
|
81
|
+
`)}function g0({error:t,path:n,home:a}){const l=h.useRef(null),o=f0(t,n);return e.jsxs("section",{className:"panel problem",role:"alert","aria-labelledby":"fault-h",children:[e.jsx("h2",{id:"fault-h",children:"Something went wrong on this page"}),e.jsx("p",{children:"The rest of the orchestrator still works. Go back, or copy the error for whoever runs this orchestrator."}),e.jsx("pre",{ref:l,className:"pre mono fault",children:o}),e.jsxs("div",{className:"actions",children:[e.jsx("a",{className:"button secondary",href:a,children:"Back to Tasks"}),e.jsx(sh,{text:o,target:l,label:"Copy error"})]})]})}class x0 extends h.Component{constructor(){super(...arguments);_p(this,"state",{error:null})}static getDerivedStateFromError(a){return{error:a}}componentDidCatch(a){console.error(a)}componentDidUpdate(a){this.state.error&&a.path!==this.props.path&&this.setState({error:null})}render(){return this.state.error?e.jsx(g0,{error:this.state.error,path:this.props.path,home:this.props.home}):this.props.children}}const ng=(t,n,a)=>`${t} ${t===1?n:a}`,j0=t=>new Date(t).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hourCycle:"h23"});function y0(t){const n=Xd(t.kind,t.number);if("unread"in t)return`Not read from ${rt[t.kind].label} for now: ${t.unread}`;const{status:a,checks:l,approvals:o,comments:c,mergedBy:d,readAt:u}=t.read,m=a==="merged"?[d?`merged by ${d}`:"merged"]:a==="closed"?["closed"]:[Sx({state:l,checks:[]}),ng(o,"approval","approvals"),ng(c,"comment","comments")];return`${n}: ${[...m,`read at ${j0(u)}`].join(", ")}`}function vj({load:t}){const[n,a]=h.useState(null),[l,o]=h.useState(!1),c=()=>{o(!0),t().then(a,()=>a(null)).finally(()=>o(!1))};return h.useEffect(c,[]),n?e.jsxs("p",{className:"muted small forge-state",children:[y0(n)," ",e.jsx("button",{type:"button",className:"link",disabled:l,onClick:c,children:"Read again"})]}):null}const kj={gitlab:{name:"GitLab",noun:"merge request",title:"Merge request",mark:"!"},github:{name:"GitHub",noun:"pull request",title:"Pull request",mark:"#"}};function bj(t,n){const[a,l]=h.useState(void 0),[o,c]=h.useState(!1),[d,u]=h.useState(null);if(h.useEffect(()=>{Ce.onForge(t,n).then(l,()=>l(null))},[t,n]),a===void 0)return{line:null,action:null,refusal:null};if(!(a!=null&&a.forge))return{line:e.jsx("p",{className:"muted",children:"Your checkout changes only when you keep this."}),action:null,refusal:null};const m=kj[a.forge];if(a.url){const g=a.number;return{line:e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:[g!==null?e.jsxs(e.Fragment,{children:[m.title," ",e.jsxs("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",children:[m.mark,g]})]}):e.jsxs("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",children:["A ",m.noun]})," is open on ",m.name,"."]}),e.jsx(vj,{load:()=>Nx(t,n).then(x=>x.onForge??null)})]}),action:null,refusal:null}}const f=()=>{c(!0),u(null),Ce.openOnForge(t,n).then(({url:g,number:x})=>l({forge:a.forge,url:g,number:x}),g=>{const x=g instanceof ht&&typeof g.body.createUrl=="string"?g.body.createUrl:null;u({message:g.message,createUrl:x})}).finally(()=>c(!1))};return{line:e.jsxs("p",{className:"muted",children:["Your checkout changes only when you keep this, and nothing reaches ",m.name," until you open a ",m.noun," there."]}),action:e.jsx("button",{type:"button",className:"secondary",disabled:o,onClick:f,children:o?`Opening a ${m.noun}…`:`Open a ${m.noun}`}),refusal:d?e.jsxs("p",{className:"error",role:"alert",children:[d.message,d.createUrl?e.jsxs(e.Fragment,{children:[" ",e.jsxs("a",{href:d.createUrl,target:"_blank",rel:"noopener noreferrer",children:["Open the filled-in page on ",m.name]})]}):null]}):null}}function v0({repoId:t,number:n}){const{line:a,action:l,refusal:o}=bj(t,n);return e.jsxs(e.Fragment,{children:[a,l?e.jsx("div",{className:"actions",children:l}):null,o]})}function wj({options:t,value:n,onChange:a}){return t!=null&&t.length?e.jsx(e.Fragment,{children:t.map(l=>e.jsx(Pe,{label:l.label,value:n[l.id]??"",onChange:o=>a({...n,[l.id]:o||void 0}),options:[{value:"",label:"The agent's default"},...l.choices]},l.id))}):null}function $r(t){const n=Object.fromEntries(Object.entries(t).filter(([,a])=>a));return Object.keys(n).length?n:void 0}const k0={"no-runner":{label:"See Agent readiness",to:()=>re("settings","agents")},"task-budget":{label:"See the task budgets",to:()=>re("team")},"repo-access":{label:"See where tasks are allowed to run",to:()=>re("team")},"agent-not-on-machine":{label:"See your machines",to:()=>re("settings","machines")}};function vh({code:t,status:n}){const a=t?k0[t]:void 0;return a?e.jsxs(e.Fragment,{children:[" ",e.jsx("a",{href:a.to(),children:a.label})]}):n===403?e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{className:"muted",children:"Ask an owner or an admin."})]}):null}const Pi=320,ni=420,sg="orchestrator.rail.width",ag=16,Nj=()=>Math.max(Pi,Math.floor(window.innerWidth/2)),si=(t,n=Nj())=>Math.min(Math.max(Math.round(t),Pi),Math.max(Pi,n));function Sj(){const[t,n]=h.useState(()=>{const m=Number(Es(sg));return si(Number.isFinite(m)&&m>0?m:ni)}),[a,l]=h.useState(!1),o=(m,f=!0)=>{const g=si(m);n(g),f&&Rs(sg,g===ni?null:String(g))};h.useEffect(()=>{const m=()=>n(f=>si(f));return window.addEventListener("resize",m),()=>window.removeEventListener("resize",m)},[]);const c=m=>{a&&n(si(window.innerWidth-m.clientX-32))},d=m=>{if(m.key==="ArrowLeft")o(t+ag);else if(m.key==="ArrowRight")o(t-ag);else if(m.key==="Home")o(ni);else return;m.preventDefault()},u=e.jsx("div",{className:`rail-handle${a?" dragging":""}`,role:"separator","aria-orientation":"vertical","aria-label":"Width of the side panel","aria-valuemin":Pi,"aria-valuemax":Nj(),"aria-valuenow":t,tabIndex:0,onPointerDown:m=>{m.currentTarget.setPointerCapture(m.pointerId),l(!0)},onPointerMove:c,onPointerUp:()=>{l(!1),o(t)},onDoubleClick:()=>o(ni),onKeyDown:d});return{style:{"--rail-width":`${t}px`},handle:u}}let b0=0;function w0(t,n){const a=[...t],l=[];for(const o of n){const c=_v(o,a.length);c?l.push(c):a.push({key:`file-${++b0}`,file:o,state:"waiting"})}return{files:a,problems:l}}const N0=t=>t>=1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${Math.max(1,Math.round(t/1024))} KB`;function Fd({files:t,onChange:n,onRetry:a,disabled:l=!1}){const[o,c]=h.useState([]),[d,u]=h.useState(!1),m=h.useRef(null),f=h.useId(),g=x=>{if(!x.length)return;const y=w0(t,x);c(y.problems),n(y.files)};return e.jsxs("div",{className:`file-chips${d?" dropping":""}`,"data-file-drop":"",onDragOver:x=>{x.preventDefault(),u(!0)},onDragLeave:()=>u(!1),onDrop:x=>{u(!1),x.dataTransfer.files.length&&(x.preventDefault(),g(Vp(x.dataTransfer)))},onPaste:x=>{const y=Vp(x.clipboardData);y.length&&(x.preventDefault(),g(y))},children:[e.jsx("input",{ref:m,id:f,type:"file",multiple:!0,accept:Fv,className:"visually-hidden",tabIndex:-1,"aria-label":"Choose files",onChange:x=>{g([...x.target.files??[]]),x.target.value=""}}),t.length?e.jsx("ul",{className:"plain chips","aria-label":"Files",children:t.map(x=>e.jsxs("li",{className:`chip-pick on${x.state==="failed"?" failed":""}`,children:[e.jsx("span",{className:"mono",dir:"auto",children:x.file.name})," ",e.jsxs("span",{className:"muted small",children:[N0(x.file.size),x.state==="sending"?", Sending…":""]}),x.state==="failed"?e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{className:"error small",children:"Not sent"}),a?e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{type:"button",className:"link small",onClick:()=>a(x.key),children:"Try again"})]}):null]}):null,x.state==="sending"||x.state==="sent"?null:e.jsx("button",{type:"button",className:"ghost small",disabled:l,"aria-label":`Remove ${x.file.name}`,onClick:()=>n(t.filter(y=>y.key!==x.key)),children:"×"})]},x.key))}):null,e.jsx("p",{className:"muted small",children:e.jsx("button",{type:"button",className:"link",disabled:l,onClick:()=>{var x;return(x=m.current)==null?void 0:x.click()},children:"Attach files"})}),d?e.jsx("p",{className:"muted small",children:"Drop to attach"}):null,o.map(x=>e.jsx("p",{className:"error small",role:"alert",children:x},x))]})}async function Cj(t,n,a){let l=t;const o=(d,u)=>{l=l.map(m=>m.key===d?{...m,...u}:m),a(l)},c=[];for(const d of t){if(d.state==="sent"&&d.id){c.push(d.id);continue}o(d.key,{state:"sending"});try{const u=await n(d.file);o(d.key,{state:"sent",id:u.id}),c.push(u.id)}catch(u){throw o(d.key,{state:"failed",error:u.message}),u}}return c}const S0=t=>t>=1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${Math.max(1,Math.round(t/1024))} KB`;function C0({id:t,reads:n}){const[a,l]=h.useState([]),[o,c]=h.useState(null);if(h.useEffect(()=>{let u=!0;return bi.list(t).then(m=>u&&l(m),()=>u&&l([])),()=>{u=!1}},[t,n]),!a.length)return null;const d=u=>{c(null),bi.url(t,u.id).then(m=>window.open(m,"_blank","noopener"),m=>c(m.message))};return e.jsxs("section",{"aria-labelledby":"task-files-h",children:[e.jsx("h2",{id:"task-files-h",children:"Files"}),e.jsx("ul",{className:"plain",children:a.map(u=>e.jsxs("li",{children:[e.jsx("button",{type:"button",className:"link mono",dir:"auto",onClick:()=>d(u),children:u.name})," ",e.jsx("span",{className:"muted small",children:S0(u.size)})]},u.id))}),e.jsx("p",{className:"muted small",children:"The agent reads them; they are not part of its change."}),o?e.jsx("p",{className:"error small",role:"alert",children:o}):null]})}function rg(t){var l;const n=(l=t instanceof Element?t:t==null?void 0:t.parentElement)==null?void 0:l.closest("[data-seq]"),a=Number(n==null?void 0:n.dataset.seq);return n&&Number.isInteger(a)?a:null}function $0(t){if(!t||t.isCollapsed||!t.anchorNode||!t.focusNode)return null;const n=f=>{var g;return(g=f instanceof Element?f:f.parentElement)==null?void 0:g.closest("[data-quotable]")},a=n(t.anchorNode);if(!a||a!==n(t.focusNode))return null;const[l,o]=[rg(t.anchorNode),rg(t.focusNode)];if(l===null||o===null)return null;const c=t.toString().trim().slice(0,Ix);if(!c)return null;const[d,u]=l<=o?[l,o]:[o,l],m=t.getRangeAt(0).getBoundingClientRect();return{quote:{path:Ax,lines:d===u?`${d}`:`${d}-${u}`,text:c},top:m.bottom+6,left:Math.max(8,m.left)}}function T0({onQuote:t}){const[n,a]=h.useState(null);return h.useEffect(()=>{const l=()=>a($0(window.getSelection()));return document.addEventListener("selectionchange",l),()=>document.removeEventListener("selectionchange",l)},[]),n?e.jsx("button",{type:"button",className:"secondary small quote-selection",style:{top:n.top,left:n.left},onMouseDown:l=>l.preventDefault(),onClick:()=>{var l;t(n.quote),(l=window.getSelection())==null||l.removeAllRanges()},children:"Quote in follow-up"}):null}const E0=3e3,R0=6,P0=3e4;function A0(t){return new Date(t).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"})}function I0({onConnected:t}){const[n,a]=h.useState(null),[l,o]=h.useState(null),[c,d]=h.useState(!1),[u,m]=h.useState(0),[f,g]=h.useState(!1);h.useEffect(()=>{if(g(!1),!n)return;const b=setTimeout(()=>g(!0),P0);return()=>clearTimeout(b)},[n==null?void 0:n.code]);const x=h.useRef(t);x.current=t,h.useEffect(()=>{let b=!0,N=null,v=R0,k;const S=()=>{b=!1,clearInterval(k)},$=()=>ha.pair().then(C=>{b&&(N=C,a(C))},C=>{b&&(S(),o(C.message))}),E=()=>ha.list().then(({machines:C})=>{if(!b)return!0;const R=C.find(P=>P.online);return R?(S(),x.current(R),!0):(N&&Date.parse(N.expiresAt)<=Date.now()&&(N=null,v-- >0?$():(S(),a(null),d(!0))),!1)},()=>!1);return E().then(C=>{C||!b||($(),k=setInterval(()=>void E(),E0))}),S},[u]);const y=()=>{o(null),d(!1),a(null),m(b=>b+1)};return e.jsxs("section",{className:"panel connect-computer","aria-labelledby":"connect-computer-h",children:[e.jsx("h2",{id:"connect-computer-h",children:"Connect this computer"}),e.jsx("p",{children:"Agents work in folders on your own computer. Run this once in a terminal there; it keeps running until you press Ctrl-C."}),l?e.jsx(be,{what:"the command",reason:l,onRetry:y}):c?e.jsx("div",{className:"actions",children:e.jsx("button",{type:"button",onClick:y,children:"Get a new command"})}):n?e.jsxs(e.Fragment,{children:[e.jsx(mt,{text:n.command,label:"Copy the command",primary:!0,well:!0}),e.jsxs("p",{className:"muted",children:["The code in it works once, until ",A0(n.expiresAt),"."]}),e.jsx("p",{className:"muted waiting-line",role:"status",children:f?"This computer has not connected yet; the terminal where you ran the command says why.":"Waiting for this computer…"})]}):e.jsx(he,{what:"the command"})]})}function $j(t,n){var a;return((a=t==null?void 0:t.agents.find(l=>l.id===n))==null?void 0:a.checks.find(l=>l.status==="fail"))??null}const O0={"claude-code":"claude",opencode:"opencode auth login"};function L0(t,n,a){return(a==null?void 0:a.name)==="Program"?e.jsxs(e.Fragment,{children:[t," is not on this machine. Install it, then press Check again."]}):(a==null?void 0:a.name)==="Version"?e.jsxs(e.Fragment,{children:[t," is older than this orchestrator works with. Update it, then press Check again."]}):a&&/^(Sign-in|Credential)/.test(a.name)?e.jsxs(e.Fragment,{children:[t," is not signed in. Open a terminal, type ",e.jsx("code",{children:O0[n]??t})," and sign in, then press Check again."]}):e.jsxs(e.Fragment,{children:[t," is not ready yet; ",e.jsx("a",{href:re("settings","agents"),children:"Agent readiness"})," shows each check."]})}function F0(t,n){return t.find(a=>{var l;return((l=$j(n,a.id))==null?void 0:l.name)!=="Program"})??t[0]}function M0(){const[t,n]=Eb(!0),[a,l]=h.useState(null),o=u=>{ge.readiness(u).then(l,()=>l(null))};if(h.useEffect(()=>o(!1),[]),!t||t.some(u=>{var m;return(m=u.readiness)==null?void 0:m.ready})||t.every(u=>!u.readiness))return null;const c=F0(t,a);if(!c)return null;const d=()=>{o(!0),n()};return e.jsxs("p",{role:"status",children:[L0(c.label,c.id,$j(a,c.id))," ",e.jsx("button",{type:"button",className:"secondary small",onClick:d,children:"Check again"})]})}function lg({step:t}){return e.jsxs("li",{children:[e.jsx("code",{children:t.command}),t.runs!==t.command?e.jsxs(e.Fragment,{children:[" ",e.jsxs("span",{className:"runs",children:["runs ",e.jsx("code",{children:t.runs})]})]}):null,t.network?e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{className:"state warn",children:"reaches the network"})]}):null,t.long?e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{className:"muted",children:"takes long"})]}):null]})}function og(t){var n;return!t.configured&&!!((n=t.detected)!=null&&n.checks.length)&&(!t.approved||t.changed.length>0)}function Tj(t,n,a=!0){const[l,o]=h.useState(null),[c,d]=h.useState(null),[u,m]=h.useState(!1),f=()=>t?$s.project(t).then(o,()=>o(null)):Promise.resolve();h.useEffect(()=>{o(null),d(null),m(!1),f()},[t]);const g=l?h$(l,c):null,x=!!(l&&(n==="always"||og(l)||c!==null)),y=x&&a,b=()=>{if(!y||!l||!g||!t)return Promise.resolve();const v=g.approve?$s.approve(t,g.approve.checks,g.approve.setup):c!==null&&!c.length&&l.approved?$s.forget(t):null;return v?v.then(()=>{},k=>{if(k.status!==403)throw k.code==="changed"&&f(),k}):Promise.resolve()};return!l||!g||!x?{view:null,consent:b}:a?{view:e.jsxs("div",{className:"task-box-checks",children:[g.configured?e.jsxs("p",{className:"muted small",children:["Checked with ",e.jsx("code",{children:g.configured}),"."]}):g.checks.length?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"muted small",children:l.approved&&l.changed.length?"Its files changed since its checks were approved; Start approves these again:":"Checked with"}),e.jsxs("ul",{className:"task-checks","aria-label":"Checks Start approves",children:[g.setup?e.jsx(lg,{step:g.setup}):null,g.checks.map(v=>e.jsx(lg,{step:v},v.command))]})]}):e.jsx("p",{className:"muted small",children:"No check runs: the task starts with none."}),g.canChange&&!u?e.jsx("p",{children:e.jsx("button",{type:"button",className:"link",onClick:()=>{d(g.checks.map(v=>v.command)),m(!0)},children:"Change"})}):null,u&&l.detected?e.jsxs("fieldset",{className:"plain-fieldset checks-pick",children:[e.jsx("legend",{className:"visually-hidden",children:"Checks to run before and after the agent's work"}),l.detected.checks.map(v=>e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:(c==null?void 0:c.includes(v.command))??!1,onChange:k=>d(S=>k.target.checked?[...S??[],v.command]:(S??[]).filter($=>$!==v.command))}),e.jsx("code",{children:v.command})]},v.command)),e.jsx("div",{className:"actions",children:e.jsx("button",{type:"button",className:"secondary small",onClick:()=>m(!1),children:"Done"})})]}):null]}),consent:b}:{view:og(l)?e.jsx("p",{className:"muted small task-checks-note",children:"An owner or an admin approves the checks this project's tasks run; until then a task here runs none."}):null,consent:b}}const _0=3e3;function U0(t){var n;return((n=t.find(a=>{var l;return(l=a.readiness)==null?void 0:l.ready})??t[0])==null?void 0:n.id)??null}function D0(t){var a;const n=t.filter(l=>l.installed&&l.supported!=="unsupported");return((a=n.find(l=>l.signIn==="signed-in")??n[0])==null?void 0:a.id)??null}function B0({project:t,home:n=null,onStarted:a,onChange:l,onCancel:o,machine:c}){var _,I;const[d,u]=h.useState(""),[m,f]=h.useState(null),[g,x]=h.useState(!1),[y,b]=h.useState(null),N=h.useId(),v=h.useId(),[k,S]=h.useState([]),$=Tj(t.id,"always");h.useEffect(()=>{ge.options().then(L=>f(L.agents),()=>f([])),fn.starters(t.id).then(L=>S(L.starters.slice(0,3)),()=>S([]))},[t.id]);const[E,C]=h.useState(null),R=E?D0(E):null;h.useEffect(()=>{if(!c||R)return;let L=!0;const K=()=>ha.list().then(({machines:ne})=>{var Z;L&&C(((Z=ne.find(D=>D.id===c))==null?void 0:Z.agents)??[])},()=>{});K();const B=window.setInterval(K,_0);return()=>{L=!1,window.clearInterval(B)}},[c,R]);const P=c?R:m?U0(m):null,M=((_=t.facts)==null?void 0:_.git)==="none"&&!t.facts.repos,O=L=>{L.preventDefault();const K=d.trim();if(!K||!P)return;x(!0),b(null);const{issue:B,notes:ne}=Bj(K),Z=te=>{b({message:te.message,...te.code?{code:te.code}:{},...te.status?{status:te.status}:{}}),x(!1)};$.consent().then(()=>ge.start({title:qj("",null,null,B?ne:K),description:B?ne:K,issueUrl:B,repoId:t.id,agent:P,template:null})).then(te=>a(te.id),Z)};return e.jsxs("form",{className:"task-box",onSubmit:O,"aria-label":"First task",children:[e.jsxs("p",{className:"task-box-where",children:[e.jsx("strong",{dir:"auto",children:((I=t.facts)==null?void 0:I.name)??t.name})," ",e.jsx("span",{className:"folder-at",dir:"auto",children:lx(t,n)}),l?e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{type:"button",className:"link",onClick:l,children:"Pick another folder"})]}):null]}),e.jsx("label",{htmlFor:N,children:"What should the agent do here?"}),e.jsx("textarea",{id:N,dir:"auto",value:d,onChange:L=>u(L.target.value),rows:3,maxLength:8500,...y?{"aria-describedby":v,"aria-invalid":!0}:{}}),k.length&&!d.trim()?e.jsxs("div",{className:"starters",children:[e.jsx("p",{className:"muted small",id:`${N}-starters`,children:"Or start with"}),e.jsx("ul",{className:"plain starter-list","aria-labelledby":`${N}-starters`,children:k.map(L=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"ghost",onClick:()=>u(`${L.title}
|
|
82
|
+
|
|
83
|
+
${L.description}`),children:[e.jsx("span",{dir:"auto",children:L.title})," ",e.jsx("span",{className:"mono muted small",dir:"auto",children:L.where})]})},`${L.kind}:${L.where}:${L.title}`))})]}):null,$.view,M?e.jsx("p",{className:"muted small",children:"The agent edits these files in place, and you can undo every change."}):null,c&&E&&!P?e.jsx("p",{className:"muted small",role:"status",children:"Your computer runs no agent for tasks yet: install Claude Code or OpenCode there and sign in."}):null,e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",disabled:g||!d.trim()||!P,children:"Start"}),o?e.jsx("button",{type:"button",className:"secondary",onClick:o,disabled:g,children:"Cancel"}):null,e.jsx(M0,{})]}),y?e.jsxs("p",{className:"error",role:"alert",id:v,children:[y.message,e.jsx(vh,{...y.code?{code:y.code}:{},...y.status?{status:y.status}:{}})]}):null]})}const ig="Personal";function q0(){return/mac/i.test(navigator.platform)?"/Users/you/code/<repository>":"/home/you/code/<repository>"}const Vu=[{id:"gitlab",label:"GitLab",example:"https://gitlab.com/<group>/<project>.git"},{id:"github",label:"GitHub",example:"https://github.com/<owner>/<repository>.git"},{id:"path",label:"A path on the server",example:"/srv/repositories/<repository>"}];function W0(t){try{return decodeURIComponent(new URL(t.trim()).pathname).replace(/^\/+|\/+$/g,"").replace(/\.git$/,"")}catch{return""}}function Ej({repos:t,forge:n,onConnected:a,onCancel:l,ownCli:o=!1,paths:c=!0,titled:d=!0}){var W;const[u,m]=h.useState(n??(o?"path":"gitlab")),[f,g]=h.useState(""),[x,y]=h.useState(""),[b,N]=h.useState(!1),v=[...new Set(t.map(A=>A.team))].sort(),[k,S]=h.useState(v[0]??ig),[$,E]=h.useState(!1),[C,R]=h.useState(""),[P,M]=h.useState(!1),[O,_]=h.useState(null),I=h.useId(),L=h.useId(),[K]=ah(!o),B=u!=="path",ne=B&&!(Ar(u)&&((W=K==null?void 0:K[u])!=null&&W.connection)),Z=W0(f),D=O?{"aria-describedby":I}:{},te=o?"Open a folder":"Add a repository",Q=A=>{A.preventDefault(),M(!0),_(null),Ce.connectRepo({forge:u,url:f.trim(),team:o?v[0]??ig:k,...B&&x.trim()?{project:x.trim()}:{},...B&&C.trim()?{token:C.trim()}:B&&!o?{token:""}:{}}).then(H=>{M(!1),g(""),y(""),R(""),a(H)},H=>{M(!1),_(H.message),B&&N(!0)})},ee=B?`The address its Clone button shows under HTTPS, read ${ne?"with the token":`through the organization's ${Vu.find(A=>A.id===u).label} connection`} before it is listed; its name and team are changed later in its Settings.`:o?"Any Git repository on this machine, by its full path; its name is changed later in its Settings.":"The orchestrator reads a path only under the folder ORCHESTRATOR_LOCAL_REPOS_ROOT names where it runs.";return e.jsxs("div",{className:"with-rail",children:[e.jsxs("form",{className:"form",onSubmit:Q,...d?{"aria-labelledby":"connect-h"}:{"aria-label":te},children:[d?e.jsx("h2",{id:"connect-h",children:te}):null,e.jsxs("fieldset",{children:[e.jsx("legend",{children:"Where it is"}),Vu.filter(A=>A.id!=="path"||o||c).map(A=>e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"radio",name:"forge",value:A.id,checked:u===A.id,onChange:()=>m(A.id)})," ",A.id==="path"&&o?"A path on this machine":A.label]},A.id))]}),e.jsxs("label",{children:[B?"Clone address (https)":"Full path",e.jsx("input",{className:B?void 0:"mono",value:f,onChange:A=>g(A.target.value),placeholder:o&&u==="path"?q0():Vu.find(A=>A.id===u).example,required:!0,autoComplete:"off",spellCheck:!1,...D})]}),B&&(b||f.trim()&&!Z)?e.jsxs("label",{children:["Project",e.jsx("input",{value:x,onChange:A=>y(A.target.value),placeholder:Z||(Ar(u)?rt[u].projectShape:void 0),maxLength:200,autoComplete:"off",spellCheck:!1,...D})]}):B&&Z?e.jsxs("p",{className:"muted small",children:["Project ",e.jsx("span",{className:"mono",children:Z})," ",e.jsx("button",{type:"button",className:"link",onClick:()=>N(!0),children:"Change project"})]}):null,o||v.length<2?null:$?e.jsx(Pe,{label:"Team",value:k,onChange:S,describedBy:D["aria-describedby"],options:v.map(A=>({value:A,label:A}))}):e.jsxs("p",{className:"muted small",children:["Team ",k," ",e.jsx("button",{type:"button",className:"link",onClick:()=>E(!0),children:"Change team"})]}),ne?e.jsxs("div",{className:"field",children:[e.jsxs("span",{className:"field-name",children:[e.jsxs("label",{htmlFor:L,children:["Token",o?" (optional)":""]}),e.jsxs(Ie,{label:"how it is kept",children:[o?"Left empty, your own gh or glab sign-in is used. ":"","It is sealed when you connect, not shown again, and sent only to this address's host."]})]}),e.jsx("input",{id:L,type:"password",value:C,onChange:A=>R(A.target.value),required:!o,autoComplete:"off",...D})]}):null,O?e.jsx("p",{className:"error",role:"alert",id:I,children:O}):null,e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",disabled:P,children:P?o?"Reading the folder…":"Reading the repository…":o?"Open folder":"Add repository"}),l?e.jsx("button",{type:"button",className:"secondary",onClick:l,children:"Cancel"}):null]})]}),e.jsx("aside",{className:"rail","aria-label":`About ${o?"the folder":"the project"}`,children:e.jsxs("section",{children:[e.jsx("h2",{children:B?"The address":"The path"}),e.jsx("p",{children:ee})]})})]})}const z0=/a personal account/;function H0({owner:t,onSaved:n}){const a=h.useId(),[l,o]=h.useState(null),[c,d]=h.useState(""),[u,m]=h.useState(""),[f,g]=h.useState(""),[x,y]=h.useState(null),[b,N]=h.useState(!1);if(h.useEffect(()=>{Cs.gitlabApp().then(o,()=>o(null))},[]),!l||l.operator)return null;if(l.app)return e.jsxs("p",{className:"muted",children:["GitLab signs in through your organization's own application at ",new URL(l.app.webUrl).host,", entered by ",l.app.by,"."]});const v=k=>{k.preventDefault(),N(!0),y(null),Cs.setGitlabApp({url:c.trim(),clientId:u.trim(),clientSecret:f}).then(()=>{g(""),N(!1),Cs.gitlabApp().then(o,()=>o(null)),n()},S=>{y(S.message),N(!1)})};return e.jsxs("details",{className:"welcome-own-gitlab",children:[e.jsx("summary",{children:"Use your own GitLab"}),e.jsx("p",{children:"On your GitLab, add an application with the api scope and this redirect URI:"}),l.redirectUri?e.jsx("p",{children:e.jsx("code",{children:l.redirectUri})}):e.jsx("p",{className:"error",children:"This orchestrator has no public address set, so GitLab has nowhere to send you back. Ask whoever runs it to set ORCHESTRATOR_PUBLIC_URL, then open this step again."}),t?e.jsxs("form",{className:"form",onSubmit:v,"aria-labelledby":`${a}-h`,children:[e.jsx("h3",{id:`${a}-h`,children:"Your GitLab application"}),e.jsxs("label",{children:["GitLab address",e.jsx("input",{value:c,onChange:k=>d(k.target.value),required:!0,autoComplete:"off",spellCheck:!1,placeholder:"https://gitlab.example.com"})]}),e.jsxs("label",{children:["Application ID",e.jsx("input",{value:u,onChange:k=>m(k.target.value),required:!0,autoComplete:"off",spellCheck:!1})]}),e.jsxs("label",{children:["Secret",e.jsx("input",{type:"password",value:f,onChange:k=>g(k.target.value),required:!0,autoComplete:"off"})]}),e.jsx("p",{className:"muted",children:"The secret is sealed and never shown again."}),x?e.jsx("p",{className:"error",role:"alert",children:x}):null,e.jsx("div",{className:"actions",children:e.jsx("button",{type:"submit",disabled:b,children:b?"Saving…":"Save the application"})})]}):e.jsx("p",{className:"muted",children:"Only an owner enters this application: every GitLab sign-in of the organization goes through it."})]})}function G0({forges:t,repos:n,problem:a,owner:l,paths:o,onChanged:c}){var y;const[d,u]=h.useState(null),[m,f]=h.useState(null),g=Fl.filter(b=>{var N;return(N=t[b])==null?void 0:N.available}),x=b=>{f(b),u(null),Cs.connect(b,"welcome").then(({authorizeUrl:N})=>window.location.assign(N),N=>{u(N.message),f(null)})};return e.jsxs(e.Fragment,{children:[a?e.jsxs("p",{className:"error",role:"alert",children:["GitLab or GitHub did not connect: ",a.replace(/[.\s]*$/,".")]}):null,Fl.map(b=>{var v;const N=(v=t[b])==null?void 0:v.connection;return N?e.jsx("p",{children:N.problem?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"error",children:[mn[b]," as ",N.account," needs reconnecting: ",N.problem]})," ",e.jsxs("button",{type:"button",className:"secondary small",disabled:m!==null,onClick:()=>x(b),children:["Reconnect ",mn[b]]})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"badge ok",children:"connected"})," ",mn[b]," as ",N.account]})},b):null}),g.length?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:[g.map(b=>mn[b]).join(" or ")," asks you to approve TeamHandbook Orchestrator, then brings you back here."]}),e.jsx("div",{className:"actions",children:g.filter(b=>{var N;return!((N=t[b])!=null&&N.connection)}).map((b,N)=>e.jsx("button",{type:"button",className:N?"secondary":void 0,disabled:m!==null,onClick:()=>x(b),children:m===b?`Opening ${mn[b]}…`:`Connect ${mn[b]}`},b))})]}):Mi(t)?null:e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Connect your team's repository with a token instead. ",e.jsx(Ie,{label:"connecting with a token",children:"This orchestrator has no one-click sign-in to GitLab or GitHub set up; connecting the repository connects its forge at the same time."})]}),e.jsx(Ej,{repos:n,forge:"gitlab",paths:o,titled:!1,onConnected:c})]}),(y=t.gitlab)!=null&&y.connection?null:e.jsx(H0,{owner:l,onSaved:c}),d?e.jsx("p",{className:"error",role:"alert",children:d}):null]})}function K0({kind:t,onMade:n}){const a=h.useId(),[l,o]=h.useState(""),[c,d]=h.useState(""),u=rt[t].group,[m,f]=h.useState("private"),[g,x]=h.useState(""),[y,b]=h.useState(null),[N,v]=h.useState(!1),k=S=>{S.preventDefault(),v(!0),b(null),Cs.teamRepo(t,{name:l.trim(),team:c.trim(),visibility:m,...u&&g.trim()?{namespace:g.trim()}:{}}).then(({repo:$,webhook:E})=>{v(!1),n(`${$.name} is set up on ${mn[t]} with the scaffold as its first commit.${E==="installed"?"":` The webhook is ${E}; the orchestrator reads the repository on its own schedule instead.`}`)},$=>{b($.message),v(!1)})};return e.jsxs("form",{className:"form",onSubmit:k,"aria-labelledby":`${a}-h`,children:[e.jsxs("h3",{id:`${a}-h`,children:["A new repository on ",mn[t]]}),e.jsxs("p",{className:"muted",children:["The orchestrator creates this repository on ",mn[t]," and writes its first commit straight to it. ",e.jsx(Ie,{label:"the first commit",children:"It writes straight to it because the repository is new and you asked for it; every later change opens as a request."})]}),e.jsxs("label",{children:["Repository name",e.jsx("input",{value:l,onChange:S=>o(S.target.value),required:!0,autoComplete:"off",spellCheck:!1,placeholder:"payments-skills"})]}),e.jsxs("label",{children:["Team",e.jsx("input",{value:c,onChange:S=>d(S.target.value),required:!0,autoComplete:"off",placeholder:"Payments"})]}),e.jsx(Pe,{label:"Visibility",value:m,onChange:S=>f(S),options:rt[t].visibilities.map(S=>({value:S,label:S.charAt(0).toUpperCase()+S.slice(1)}))}),u?e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:[u.label,e.jsx("input",{value:g,onChange:S=>x(S.target.value),autoComplete:"off",spellCheck:!1,placeholder:u.placeholder,"aria-describedby":`${a}-group`})]}),e.jsx("p",{className:"muted",id:`${a}-group`,children:u.meaning})]}):null,y&&z0.test(y)?e.jsxs("div",{role:"alert",children:[e.jsx("p",{children:"GitHub lets only a personal account's owner create its repositories. Set it up in three steps:"}),e.jsxs("ol",{children:[e.jsxs("li",{children:["On GitHub, create an empty repository named ",l.trim()||"for the team's skills",", without a README."]}),e.jsx("li",{children:"Add it to the TeamHandbook Orchestrator app's installation on that account."}),e.jsx("li",{children:"Come back and pick it under Pick an existing repository; the orchestrator writes the scaffold as its first commit."})]})]}):y?e.jsx("p",{className:"error",role:"alert",children:y}):null,e.jsx("div",{className:"actions",children:e.jsx("button",{type:"submit",disabled:N,children:N?"Setting it up…":"Create the repository"})})]})}function Y0({kind:t,manageUrl:n,onMade:a,onCreate:l}){const o=h.useId(),[c,d]=h.useState(null),[u,m]=h.useState(null),[f,g]=h.useState(""),[x,y]=h.useState(null),[b,N]=h.useState(!1),v=()=>{d(null),y(null),Cs.repos(t).then($=>d($.filter(E=>!E.connected)),$=>y($.message))};h.useEffect(v,[t]);const k=(c==null?void 0:c.find($=>$.fullName===u))??null,S=$=>{if($.preventDefault(),!k)return;N(!0),y(null),(k.empty?Cs.teamRepo(t,{existing:k.fullName,team:f.trim()}).then(({repo:C})=>`${C.name} had no commits, so the orchestrator wrote the scaffold as its first commit and connected it.`):Cs.connectRepo(t,{fullName:k.fullName,team:f.trim()}).then(({repo:C})=>`${C.name} is connected; every change to it opens as a request.`)).then(C=>{d(R=>(R==null?void 0:R.filter(P=>P.fullName!==k.fullName))??null),m(null),N(!1),a(C)},C=>{y(C.message),N(!1)})};return c?c.length?e.jsxs("form",{className:"form",onSubmit:S,"aria-labelledby":`${o}-h`,children:[e.jsxs("fieldset",{className:"plain-fieldset",children:[e.jsxs("legend",{id:`${o}-h`,children:["Your repositories on ",mn[t]]}),e.jsx("ul",{className:"plain welcome-repos",children:c.map($=>e.jsx("li",{children:e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"radio",name:`${o}-repo`,checked:u===$.fullName,onChange:()=>m($.fullName),required:!0})," ",$.fullName," ",$.empty?e.jsx("span",{className:"badge",children:"empty"}):null]})},$.fullName))})]}),k!=null&&k.empty?e.jsxs("p",{className:"muted",children:["This repository has no commits, so the orchestrator writes the scaffold straight to it as its first commit. ",e.jsx(Ie,{label:"the first commit",children:"A repository with even one commit is only ever changed through requests."})]}):null,e.jsxs("label",{children:["Team",e.jsx("input",{value:f,onChange:$=>g($.target.value),required:!0,autoComplete:"off",placeholder:"Payments"})]}),x?e.jsx("p",{className:"error",role:"alert",children:x}):null,e.jsx("div",{className:"actions",children:e.jsx("button",{type:"submit",disabled:b||!k,children:k!=null&&k.empty?"Set it up":"Connect it"})})]}):e.jsxs("div",{className:"welcome-step-empty",children:[e.jsxs("p",{children:[mn[t]," lists no repository this connection reaches that is not connected already."]}),e.jsx("p",{className:"muted",children:rt[t].emptyListHint}),e.jsxs("div",{className:"actions",children:[n?e.jsx("a",{className:"button secondary",href:n,target:"_blank",rel:"noreferrer",children:"Choose the repositories the GitHub app reaches"}):null,e.jsx("button",{type:"button",className:"secondary",onClick:v,children:"Read the list again"}),e.jsx("button",{type:"button",onClick:l,children:"Create a new one"})]})]}):x?e.jsx(be,{what:"your repositories",reason:x,onRetry:v}):e.jsx(he,{what:`your repositories on ${mn[t]}`})}function V0({forges:t,repos:n,paths:a,onChanged:l}){var g,x;const[o,c]=h.useState(!1),[d,u]=h.useState(null),m=Mi(t),f=y=>{u(y),l()};return e.jsxs(e.Fragment,{children:[e.jsxs("fieldset",{className:"plain-fieldset choice-row",children:[e.jsx("legend",{children:"Your team's skills repository"}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"radio",name:"repo-choice",checked:!o,onChange:()=>c(!1)})," Pick an existing repository"]}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"radio",name:"repo-choice",checked:o,onChange:()=>c(!0)})," Create a new one"]})]}),d?e.jsx("p",{role:"status",children:d}):null,m?o?e.jsx(K0,{kind:m,onMade:f}):e.jsx(Y0,{kind:m,manageUrl:((x=(g=t[m])==null?void 0:g.connection)==null?void 0:x.manageUrl)??null,onMade:f,onCreate:()=>c(!0)}):o?e.jsxs("p",{className:"muted",children:["Connect GitLab or GitHub first. ",e.jsx(Ie,{label:"creating the repository",children:"The orchestrator creates the repository through that connection and writes its first commit straight to it, because the repository is new and you asked for it; every later change opens as a request."})]}):e.jsx(Ej,{repos:n,forge:"gitlab",paths:a,titled:!1,onConnected:l})]})}const Q0=["forge","repo","members","start"];function J0(t){return["repo","members","start"].includes(t.id)||t.id==="forge"&&!t.done}function X0({step:t,me:n,org:a,repos:l,forges:o,problem:c,onChanged:d}){const[u,m]=h.useState([]),[f,g]=h.useState(null);return h.useEffect(()=>{t.id==="members"&&pn.teams().then(m,()=>m([]))},[t.id]),t.id==="forge"?e.jsx(G0,{forges:o,repos:l,problem:c,owner:n.role==="owner",paths:n.pathRepos!==!1,onChanged:d}):t.id==="repo"?e.jsx(V0,{forges:o,repos:l,paths:n.pathRepos!==!1,onChanged:d}):t.id==="members"?e.jsxs(e.Fragment,{children:[e.jsx(oh,{me:n,teams:u,onSent:(x,y)=>{g({invited:x,skipped:y}),d()}}),f?e.jsx(hx,{sent:f.invited,skipped:f.skipped}):null]}):t.id==="start"?e.jsxs("div",{className:"actions",children:[e.jsx("a",{className:"button",href:Te(a,"work"),children:"Open Work"}),e.jsx("a",{className:"button secondary",href:`${Te(a,"integrations")}?open=jira`,children:"Connect Jira"})]}):null}function cg({org:t,onRepos:n,computer:a=!1}){const[l,o]=h.useState(null),[c,d]=h.useState(void 0),[u,m]=h.useState(null),[f,g]=h.useState(null);h.useEffect(()=>{Je.list().then(({projects:y,last:b,home:N})=>{d(y.find(v=>v.id===b)??null),m(N??null)},()=>d(null))},[]);const x=(y,b,N)=>{d(y),m(b),g(N),n()};return e.jsxs("section",{className:"first-screen","aria-labelledby":"first-promise-h",children:[e.jsx("h1",{id:"first-promise-h",className:"first-promise",children:a?mC:ij}),a&&!l?e.jsx(I0,{onConnected:o}):c===void 0?e.jsx(he,{what:"where your code lives"}):c?e.jsx(B0,{project:c,home:u,onChange:()=>d(null),onStarted:y=>Ge(Te(t,"tasks",y)),...l?{machine:l.id}:{}}):e.jsxs(e.Fragment,{children:[l?e.jsxs("p",{className:"muted",role:"status",children:[l.name," is connected; pick a folder on it."]}):null,e.jsx(yh,{onOpened:x,lead:e.jsx(Z0,{}),...l?{machine:l.id,where:`On ${l.name}`}:{},...f?{from:f}:{}})]})]})}function Z0(){return e.jsxs("div",{className:"code-lives",children:[e.jsx("h2",{children:"Where your code lives"}),e.jsx("p",{className:"muted",children:"Pick the folder your code is in, even one that holds many."})]})}function Rj({me:t,org:n,repos:a,onRepos:l,onFinished:o}){const c=new URLSearchParams(Bl().search);if(t.mode==="local")return e.jsx(cg,{org:n,onRepos:l});const d=Me(t)&&["step","forge_connected","forge_problem"].some(u=>c.has(u));return t.runners&&t.tasksRunHere===!1&&!d?e.jsx(cg,{org:n,onRepos:l,computer:!0}):e.jsx(eT,{me:t,org:n,repos:a,onRepos:l,...o?{onFinished:o}:{}})}function eT({me:t,org:n,repos:a,onRepos:l,onFinished:o}){var L,K;const[c,d]=h.useState(null),[u,m]=h.useState(null),[f,g]=h.useState(null),[x,y]=h.useState(null),b=Bl(),N=new URLSearchParams(b.search).get("forge_problem"),[v,k]=ah(Me(t)),S=()=>{g(null),Promise.all([Ce.summary(),Ce.onboarding()]).then(([B,ne])=>{d(B),m(ne)},B=>g(B.message))};if(h.useEffect(S,[]),!Me(t))return e.jsx("div",{className:"page",children:e.jsx(Yn,{title:`Welcome to ${n}`,summary:e.jsxs(e.Fragment,{children:["An owner or an admin sets the organization up; your first task starts on ",e.jsx("a",{href:Te(n,"tasks"),children:"Tasks"}),"."]})})});if(f)return e.jsx(be,{what:"the welcome steps",reason:f,onRetry:S,panel:!0});if(!c||!u||!v)return e.jsx(he,{what:"the welcome steps",panel:!0});const $=(L=a.find(B=>B.configured!==!1))==null?void 0:L.id,E=cx(n,c,$,Mi(v)!==null).filter(B=>Q0.includes(B.id)),C=E.findIndex(B=>!B.done&&!u.skipped.includes(B.id)),R=E.findIndex(B=>B.id===new URLSearchParams(b.search).get("step")),P=x??(N?0:R!==-1?R:C===-1?E.length:C),M=E[P],O=()=>{S(),k(),l()},_=B=>Ce.changeOnboarding({skipped:[...u.skipped.filter(ne=>ne!==B),B]}).then(ne=>{m(ne),y(P+1)},ne=>g(ne.message)),I=E.filter(B=>!B.done);return e.jsxs("div",{className:"page welcome",children:[e.jsx(Yn,{title:`Welcome to ${n}`,summary:e.jsxs(e.Fragment,{children:[E.length," steps set your organization up. ",e.jsx(Ie,{label:"the welcome steps",children:"Any of them can wait; what is left stays under Getting set up on Team."})]})}),e.jsxs("div",{className:"welcome-layout",children:[e.jsx("nav",{"aria-label":"Welcome steps",children:e.jsx("ol",{className:"step-list nav",children:E.map((B,ne)=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"step-item","aria-current":ne===P?"step":void 0,onClick:()=>y(ne),children:[e.jsx("span",{className:`step-mark ${B.done?"done":""}`,"aria-hidden":"true",children:B.done?"✓":ne+1}),B.title,e.jsx("span",{className:"step-state",children:B.done?"done":u.skipped.includes(B.id)?"skipped":""})]})},B.id))})}),M?e.jsxs("section",{className:"panel welcome-step","aria-labelledby":"welcome-step-h",children:[e.jsxs("h2",{id:"welcome-step-h","aria-live":"polite",children:[M.title," ",M.done?e.jsx("span",{className:"badge ok",children:"done"}):null]}),e.jsx("p",{children:M.detail}),e.jsx(X0,{step:M,me:t,org:n,repos:a,forges:v??{gitlab:null,github:null},problem:N,onChanged:O},M.id),e.jsxs("div",{className:"actions",children:[P>0?e.jsxs("button",{type:"button",className:"secondary",onClick:()=>y(P-1),children:["Back to ",E[P-1].title]}):null,M.done?e.jsx("button",{type:"button",className:J0(M)?"secondary":void 0,onClick:()=>y(P+1),children:((K=E[P+1])==null?void 0:K.title)??"Finish"}):e.jsx("button",{type:"button",className:"secondary",onClick:()=>void _(M.id),children:"Skip for now"})]})]}):e.jsxs("section",{className:"panel welcome-step","aria-labelledby":"welcome-done-h",children:[e.jsx("h2",{id:"welcome-done-h",children:"You are set up"}),I.length?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["These wait under Getting set up on ",e.jsx("a",{href:Te(n,"team"),children:"Team"})," whenever you come back to them:"]}),e.jsx("ul",{className:"plain",children:I.map(B=>e.jsx("li",{children:B.title},B.id))})]}):e.jsx("p",{children:"Every step is done."}),e.jsx("div",{className:"actions",children:t.runners&&t.tasksRunHere===!1?e.jsx("a",{className:"button",href:Te(n,"welcome"),children:"Start the first task"}):e.jsx("a",{className:"button",href:Te(n,"tasks"),...o?{onClick:B=>{B.preventDefault(),o()}}:{},children:"Open Tasks"})})]})]})]})}function tT({message:t}){const[n,a]=h.useState(["",""]),l=h.useRef(!0),o=h.useRef(0);return h.useEffect(()=>{if(l.current){l.current=!1;return}o.current=1-o.current,a(o.current?["",t]:[t,""])},[t]),e.jsxs("div",{className:"visually-hidden",children:[e.jsx("span",{"aria-live":"polite",children:n[0]}),e.jsx("span",{"aria-live":"polite",children:n[1]})]})}const ug=20,nT=6e4,dg={jira:"Jira",confluence:"Confluence",github:"GitHub",gitlab:"GitLab",sentry:"Sentry",linear:"Linear",notion:"Notion",slack:"Slack"},sT={get:"Read",fetch:"Read",view:"Read",read:"Read",search:"Searched",query:"Searched",find:"Searched"},aT={issue:"an issue",issues:"issues",page:"a page",pages:"pages",comment:"a comment",comments:"comments",project:"a project",projects:"projects",message:"a message",messages:"messages",channel:"a channel"},ai=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[\s_\-]+/).filter(Boolean).map(n=>n.toLowerCase());function rT(t,n){const a=/^mcp__(.+?)__(.+)$/.exec(t),l=n?[t,n.server,n.tool]:a;if(!l)return{verb:iT[t]??`Used ${ai(t).join(" ")}`,source:null,object:null};const o=n?l[1]:l[1].replace(/^plugin_[^_]+_/,""),c=ai(l[2]),d=[...c,...ai(o)].find(g=>dg[g]),u=d?dg[d]:ai(o).join(" "),m=sT[c[0]??""];if(!m)return{verb:`Used ${c.filter(g=>g!==d).join(" ")}`,source:u,object:null};const f=c.slice(1).map(g=>aT[g]).find(Boolean)??null;return{verb:m,source:u,object:f}}const lT=new Set(["Read","Edit","MultiEdit","Write","NotebookEdit","Glob","Grep"]);function oT(t,{folder:n,home:a}){return t.startsWith("/")?n&&t.startsWith(`${n}/`)?t.slice(n.length+1):a&&t.startsWith(`${a}/`)?`~${t.slice(a.length)}`:t:t}const iT={Read:"Read",Edit:"Edited",MultiEdit:"Edited",Write:"Wrote",NotebookEdit:"Edited",Bash:"Ran",Grep:"Searched",Glob:"Searched",WebFetch:"Fetched",WebSearch:"Searched the web",Task:"Asked a helper"},Pj={Read:"files",Searched:"times",Fetched:"pages"},et=t=>typeof t=="string"?t:null,hg=t=>typeof t=="number"&&Number.isInteger(t)&&t>=0?t:null;function cT(t){if(!Array.isArray(t))return null;const n=[];for(const a of t){const l=a,o=et(l==null?void 0:l.text),c=l==null?void 0:l.state;if(!o||c!=="todo"&&c!=="doing"&&c!=="done")return null;n.push({text:o,state:c})}return n}function uT(t,n={folder:null,home:null}){var f,g,x,y,b;const a={plan:[],stream:[],changed:[],costUsd:null},l=new Map,o=new Map,c=new Map,d=new Map,u=new Map,m=N=>{const v=a.stream.at(-1);v&&new Date(N.at).getTime()-new Date(v.at).getTime()>nT&&a.stream.push({kind:"time",key:`time-${N.key}`,at:N.at}),a.stream.push(N)};for(const N of t){const v=N.data;if(!(!v||v.type!==N.kind)){if(N.kind==="message"){const k=(f=et(v.text))==null?void 0:f.trim();k&&m({kind:"say",key:`say-${N.seq}`,at:N.at,text:k})}else if(N.kind==="started-from"){const k=et(v.taskId);k&&m({kind:"started",key:`started-${N.seq}`,at:N.at,text:N.text,from:k})}else if(N.kind==="steer"){const k=(g=et(v.text))==null?void 0:g.trim();k&&m({kind:"you",key:`you-${N.seq}`,at:N.at,text:k,by:et(v.by),...et(v.byId)?{byId:et(v.byId)}:{}})}else if(N.kind==="todos"){const k=cT(v.items);k&&(a.plan=k)}else if(N.kind==="usage"){const k=(x=v.cost)==null?void 0:x.usd;typeof k=="number"&&Number.isFinite(k)&&(a.costUsd=(a.costUsd??0)+k)}else if(N.kind==="tool_call"){const k=et(v.tool),S=v.status;if(!k||S!=="started"&&S!=="done"&&S!=="failed"&&S!=="refused")continue;const $=et(v.id),E=$?l.get($):void 0;if(E){const K=o.get($);K&&(K.status=S,S==="refused"&&(K.reason=et((y=v.refusal)==null?void 0:y.reason))),E.status=S;continue}const C=v.mcp,R=rT(k,et(C==null?void 0:C.server)&&et(C==null?void 0:C.tool)?{server:et(C.server),tool:et(C.tool)}:null),P=S==="refused"?et((b=v.refusal)==null?void 0:b.reason):null,M=et(k==="Bash"?v.command:v.target),O={tool:k,target:M===k?null:M&&lT.has(k)?oT(M,n):M,status:S,reason:P},_=a.stream.at(-1);if((_==null?void 0:_.kind)==="tool"&&_.verb===R.verb&&_.source===R.source&&!_.output.length&&!_.change&&(S==="refused"?_.status==="refused"&&_.calls[0].tool===k&&_.calls[0].reason===P:S==="started"&&_.status!=="failed"&&_.status!=="refused"&&(Pj[R.verb]!==void 0||R.source!==null))&&(_==null?void 0:_.kind)==="tool"){_.calls.push(O),_.status=S,$&&(l.set($,_),o.set($,O));continue}const L={kind:"tool",key:`tool-${N.seq}`,at:N.at,...R,calls:[O],status:S,output:[],outputTotal:0,change:null};$&&(l.set($,L),o.set($,O)),m(L)}else if(N.kind==="tool_output"){const k=l.get(et(v.id)??""),S=Array.isArray(v.lines)?v.lines.filter($=>typeof $=="string"):[];k&&(k.outputTotal+=S.length,k.calls.every($=>$.tool==="Read")||(k.output=[...k.output,...S].slice(-2e3)))}else if(N.kind==="edit"){const k=et(v.path),S=hg(v.additions),$=hg(v.deletions);if(!k||S===null||$===null)continue;const E=l.get(et(v.id)??"");E&&(E.change={additions:S,deletions:$,patch:et(v.patch)});const C=u.get(k);u.set(k,{path:k,additions:((C==null?void 0:C.additions)??0)+S,deletions:((C==null?void 0:C.deletions)??0)+$})}else if(N.kind==="request"){const k=v.request,S=et(k==null?void 0:k.id),$=et(k==null?void 0:k.summary);if(S&&$&&c.set(S,(k==null?void 0:k.kind)==="question"?"the question":$),S&&(k==null?void 0:k.kind)==="file-change"){const E=[...l.values()].reverse().find(C=>C.status==="started"&&(C.verb==="Wrote"||C.verb==="Edited")&&C.calls.some(R=>R.target!==null&&$!==null&&$.includes(R.target)));E&&(E.asking=!0,d.set(S,E))}}else if(N.kind==="request_resolved"){const k=d.get(et(v.requestId)??"");k&&(k.asking=!1);const S=c.get(et(v.requestId)??""),$=S?dT(v.decision,S):null;$&&m({kind:"card",key:`card-${N.seq}`,at:N.at,text:$})}}}return a.changed=[...u.values()],a}function dT(t,n){return t==="allow-once"?`You allowed ${n} once`:t==="allow-for-task"?`You allowed ${n} for this task`:t==="deny"?`You denied ${n}`:null}const mg=(t,n,a)=>{const l=t.slice(0,t.length>n+1?n:t.length),o=t.length-l.length;return o?`${l.join(", ")} and ${o} more ${a}`:l.length===1?l[0]:`${l.slice(0,-1).join(", ")} and ${l.at(-1)}`};function hT(t){var c;if(t.asking)return{before:t.verb==="Wrote"?"Asks to write":"Asks to edit",target:((c=t.calls[0])==null?void 0:c.target)??null,after:""};const n=t.calls.map(d=>d.target).filter(d=>d!==null),a=t.verb==="Searched",l=d=>a?`"${d}"`:d;if(t.status==="refused"||t.calls.length===1){const d=n[0]??null;return t.source?a?{before:`Searched ${t.source}`,target:null,after:d?` for ${l(d)}`:""}:t.verb.startsWith("Used ")?{before:`${t.verb} in ${t.source}`,target:null,after:""}:{before:`${t.verb} ${d??t.object??"it"} in ${t.source}`,target:null,after:""}:d?{before:t.verb,target:a?null:d,after:a?` ${l(d)}`:""}:{before:t.verb,target:null,after:""}}if(a)return{before:`Searched${t.source?` ${t.source}`:""} ${t.calls.length} times`,target:null,after:n.length?`: ${mg(n.map(l),2,"")}`.trimEnd():""};const o=Pj[t.verb]??(t.source?"":"times");return{before:`${t.verb} ${mg(n.length===t.calls.length?n:n.concat(Array(t.calls.length-n.length).fill(t.object??"it")),2,o).trimEnd()}${t.source?` in ${t.source}`:""}`,target:null,after:""}}const pg=80;function mT(t){const n=t.trim().split(`
|
|
84
|
+
`)[0].replace(/\s+/g," ");return n.length>pg||t.trim().includes(`
|
|
85
|
+
`)?`${n.slice(0,pg).trimEnd()}…`:n}function Aj(t){var l;const n=t.calls.length===1?t.calls[0].target:null;if(!n||!/\.md$/i.test(n)||!((l=t.change)!=null&&l.patch)||t.change.deletions>0)return null;const a=t.change.patch.split(`
|
|
86
|
+
`).filter(o=>o.startsWith("+")&&!o.startsWith("+++"));return a.length?a.map(o=>o.slice(1)).join(`
|
|
87
|
+
`):null}function pT(t){for(const n of[...t].reverse()){if(n.kind!=="tool"||!n.calls.some(l=>{var o;return(o=l.target)==null?void 0:o.includes(".orchestrator-plans/")}))continue;const a=Aj(n);if(a!=null&&a.trim())return a}return null}function fg(t,n){return t==="started"?n?"running":"stopped":t}function fT(t){return t.status==="refused"?{word:t.calls.length>1?`refused ${t.calls.length} times`:"refused",tone:"error"}:t.status==="failed"?{word:"failed",tone:"error"}:t.verb==="Ran"&&t.status==="done"?{word:"passed",tone:"ok"}:null}const gT=(t,n,a)=>t.mode==="local"||(a?a===t.id:n===t.name),xT=t=>new Date(t).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),gg=t=>`${t.toLocaleString("en-US")} ${t===1?"line":"lines"}`,jT="This task does not allow this tool.";function yT({line:t,current:n,working:a}){var y,b;const{before:l,target:o,after:c}=hT(t),d=fT(t),[u,m]=h.useState(!1),f=t.calls.every(N=>N.tool==="Read"),g=u?t.output:t.output.slice(-ug),x=Aj(t);return e.jsx("li",{className:"run-line","data-kind":"tool","data-status":fg(t.status,a),...n?{"data-current":""}:{},children:e.jsxs("details",{children:[e.jsxs("summary",{children:[e.jsx("span",{className:"run-mark","data-status":fg(t.status,a),"aria-hidden":"true"}),l,o?e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{className:"mono",dir:"auto",children:t.verb==="Ran"?mT(o):o})]}):null,c,t.change?e.jsxs(e.Fragment,{children:[" ",e.jsx(Di,{added:t.change.additions,removed:t.change.deletions})," ",e.jsx("span",{className:"diff-stat",children:e.jsx(mh,{added:t.change.additions,removed:t.change.deletions})})]}):null,d?e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{className:`state ${d.tone}`,children:d.word})]}):null]}),f&&t.outputTotal?e.jsxs("p",{className:"muted small",children:[gg(t.outputTotal),t.calls.length===1&&t.calls[0].target?e.jsxs(e.Fragment,{children:[" of ",e.jsx("span",{className:"mono",dir:"auto",children:t.calls[0].target})]}):null]}):null,t.output.length?e.jsx("pre",{className:`pre mono${u?" run-output-all":""}`,children:g.join(`
|
|
88
|
+
`)}):null,t.outputTotal>ug&&!f?e.jsx("button",{type:"button",className:"link small","aria-expanded":u,onClick:()=>m(!u),children:u?"Show the last lines":`Show all ${gg(t.outputTotal)}`}):null,x!==null?e.jsx("div",{className:"plan-text",dir:"auto",children:e.jsx(Ha,{text:x})}):(y=t.change)!=null&&y.patch?e.jsx(ph,{patch:t.change.patch}):null,t.status==="refused"?e.jsx("p",{className:"muted small",children:((b=t.calls[0])==null?void 0:b.reason)??jT}):null,e.jsx("ul",{className:"plain muted small",children:t.calls.map((N,v)=>e.jsxs("li",{children:[e.jsx("span",{className:"mono",dir:"auto",children:N.tool}),N.target?e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{className:"mono run-command",dir:"auto",children:N.target})]}):null]},v))})]})})}const vT=5;function kT({plan:t}){const[n,a]=h.useState(!1),l=t.findIndex(u=>u.state==="doing"),o=t.findIndex(u=>u.state!=="done"),c=l>=0?l:o>=0?o:t.length-1,d=t.length>vT;return e.jsxs(e.Fragment,{children:[e.jsx("ol",{className:"run-plan","aria-label":"The agent's plan",...d?{"data-long":""}:{},...n?{"data-open":""}:{},children:t.map((u,m)=>e.jsx("li",{"data-state":u.state,dir:"auto",...m===c?{"data-at":""}:{},children:u.text},m))}),t.length>1?e.jsx("button",{type:"button",className:"link small run-plan-more","aria-expanded":n,onClick:()=>a(!n),...d?{"data-long":""}:{},children:n?"Show less":`${t.length-1} more`}):null]})}function xg({run:t,working:n=!1,withPlan:a=!0,first:l=null,isMine:o=()=>!1}){const c=t.stream.at(-1),d=n&&(c==null?void 0:c.kind)==="tool"&&c.status==="started"?c.key:null;return e.jsxs(e.Fragment,{children:[a&&t.plan.length?e.jsx("ol",{className:"run-plan","aria-label":"The agent's plan",children:t.plan.map((u,m)=>e.jsx("li",{"data-state":u.state,dir:"auto",children:u.text},m))}):null,e.jsxs("ol",{className:"run-stream","aria-label":"What the agent did","data-quotable":"",children:[l,t.stream.map(u=>u.kind==="tool"?e.jsx(yT,{line:u,current:u.key===d,working:n},u.key):u.kind==="time"?e.jsx("li",{className:"run-line","data-kind":"time",children:e.jsx("time",{dateTime:u.at,children:xT(u.at)})},u.key):u.kind==="you"?e.jsxs("li",{className:"run-line","data-kind":"you",dir:"auto",children:[e.jsx("strong",{children:u.by&&!o(u.by,u.byId)?u.by:"You"})," ",u.text]},u.key):u.kind==="started"?e.jsxs("li",{className:"run-line","data-kind":"started",dir:"auto",children:[u.text," ",e.jsx("a",{href:re("tasks",u.from),children:"Open it"})]},u.key):u.kind==="say"?e.jsx("li",{className:"run-line","data-kind":"say","data-seq":u.key.slice(4),children:e.jsx(Ha,{text:u.text})},u.key):e.jsx("li",{className:"run-line","data-kind":u.kind,dir:"auto",children:u.text},u.key)),n&&!d?e.jsx("li",{className:"run-line","data-kind":"now",children:"Thinking…"}):null]})]})}function Ij({label:t,read:n,value:a,onChange:l,local:o=!1}){const c=new Map(n.suggestions.map(u=>[u.skill,u.reason])),d=u=>l(a.includes(u)?a.filter(m=>m!==u):[...a,u]);return n.skills.length?e.jsxs("fieldset",{className:"skill-chips",children:[e.jsxs("legend",{children:[t," ",e.jsxs("span",{className:"count",children:[a.length," of ",ki]})]}),e.jsx("div",{className:"chips",children:n.skills.map(u=>{const m=a.includes(u.name);return e.jsxs("label",{className:`chip-pick${m?" on":""}`,title:u.description,children:[e.jsx("input",{type:"checkbox",checked:m,disabled:!m&&a.length>=ki,onChange:()=>d(u.name)}),e.jsx("span",{className:"mono",children:u.name}),c.has(u.name)?e.jsx("span",{className:"badge neutral",children:"suggested"}):null]},u.name)})}),n.suggestions.length?e.jsx("ul",{className:"plain reasons",children:n.suggestions.map(u=>e.jsxs("li",{className:"muted small",children:[e.jsx("span",{className:"mono",children:u.skill}),": ",u.reason]},u.skill))}):e.jsx("p",{className:"muted small",children:n.note??`The agent suggested none; it still has ${o?"every skill":"every team skill"}.`})]}):e.jsx("p",{className:"muted small",children:o?"There are no skills here yet.":"The team has no skills here yet."})}const bT={projectSkills:[],mcpServers:[],commands:[]};function wT(t,n){return{projectSkills:t.map(a=>({source:a.source,name:a.name})),mcpServers:n.filter(a=>a.transport==="http").map(a=>a.id),commands:[]}}function NT(t){return t.transport==="stdio"?`${t.name} runs ${[t.command,...t.args].join(" ")}`:t.name}const Qu=(t,n,a)=>t?`${t} ${t===1?n:a}`:null;function Md(t){const n=[Qu(t.commands,"skill or command","skills or commands"),Qu(t.plugins,"plugin","plugins"),Qu(t.mcpServers,"MCP server","MCP servers"),t.claudeMd?"CLAUDE.md":null].filter(a=>a!==null);return n.length?n.length===1?n[0]:`${n.slice(0,-1).join(", ")} and ${n[n.length-1]}`:null}function ST(t,n){var l;if(!n)return null;const a=Md({commands:n.commands.length,plugins:n.plugins.filter(o=>o.enabled).length,mcpServers:((l=n.mcpServers)==null?void 0:l.length)??0,claudeMd:!!n.claudeMd});return a?`${t} loads ${a}`:null}function CT({label:t,personal:n}){const a=ST(t,n);if(!a||!n)return null;const l=[...n.plugins.filter(o=>o.enabled).map(o=>o.name),...n.commands.map(o=>`/${o.name}`),...(n.mcpServers??[]).map(o=>o.name)];return e.jsxs("details",{className:"agent-loaded muted small",children:[e.jsxs("summary",{children:[a,"."]}),l.length?e.jsx("p",{className:"mono",children:l.join(", ")}):null]})}function $T({repoId:t,value:n,onChange:a,canAdd:l}){const[o,c]=h.useState([]),[d,u]=h.useState([]),[m,f]=h.useState(!1),[g,x]=h.useState(0);if(h.useEffect(()=>{let v=!0;return Promise.all([ua.skills(t).then(k=>k.project,()=>[]),ua.read(t).then(k=>k.mcpServers,()=>[])]).then(([k,S])=>{v&&(c(k),u(S),a(wT(k,S)))}),()=>{v=!1}},[t,g]),!o.length&&!d.length&&!l)return null;const y=v=>n.projectSkills.some(k=>k.source===v.source&&k.name===v.name),b=v=>a({...n,projectSkills:y(v)?n.projectSkills.filter(k=>!(k.source===v.source&&k.name===v.name)):[...n.projectSkills,{source:v.source,name:v.name}]}),N=v=>{const k=n.mcpServers.includes(v)?n.mcpServers.filter(S=>S!==v):[...n.mcpServers,v];a({...n,mcpServers:k,commands:k.filter(S=>{var $;return(($=d.find(E=>E.id===S))==null?void 0:$.transport)==="stdio"})})};return e.jsxs("fieldset",{className:"plain-fieldset task-tools",children:[e.jsx("legend",{children:"Skills and MCP servers for this task"}),o.length||d.length?e.jsxs("div",{className:"chips",role:"group","aria-label":"The project's skills and MCP servers",children:[o.map(v=>e.jsxs("label",{className:`chip-pick${y(v)?" on":""}`,title:v.description,children:[e.jsx("input",{type:"checkbox",checked:y(v),onChange:()=>b(v)}),e.jsx("span",{className:"mono",children:v.name})]},`${v.source}:${v.name}`)),d.map(v=>e.jsxs("label",{className:`chip-pick${n.mcpServers.includes(v.id)?" on":""}`,title:v.transport==="http"?v.url:void 0,children:[e.jsx("input",{type:"checkbox",checked:n.mcpServers.includes(v.id),onChange:()=>N(v.id)}),e.jsx("span",{className:"mono",children:NT(v)})," ",e.jsx("span",{className:"muted small",children:"MCP"})]},v.id))]}):null,l?m?e.jsx(mj,{project:t,onCancel:()=>f(!1),onAdded:()=>{f(!1),x(v=>v+1)}}):e.jsx("p",{children:e.jsx("button",{type:"button",className:"link",onClick:()=>f(!0),children:"Add a skill repository"})}):null]})}const Oj=4096;function TT(t){return Object.fromEntries(t.map(n=>[n.key,{chosen:[],other:null}]))}function jg(t,n,a){const l=t[n.key]??{chosen:[],other:null},o=n.choice==="one"?[a]:l.chosen.includes(a)?l.chosen.filter(c=>c!==a):[...l.chosen,a];return{...t,[n.key]:{...l,chosen:o}}}function ET(t,n,a){const l=t[n.key]??{chosen:[],other:null};return{...t,[n.key]:{...l,other:a.trim()?a.slice(0,Oj):null}}}function yg(t,n){return t.every(a=>{var o;const l=n[a.key];return!!(l&&(l.chosen.length||(o=l.other)!=null&&o.trim()))})}function RT(t,n){return n&&[n.chosen.map(l=>{var o,c;return((c=(o=t.options)==null?void 0:o.find(d=>d.value===l))==null?void 0:c.label)??l}).join(", "),n.other??""].filter(Boolean).join("; ")||"no answer"}const PT=2e4;function AT(t){return t.split(`
|
|
89
|
+
`).filter(n=>/^\s*(\d+[.)]|[-*])\s+\S/.test(n)).length}function IT({task:t,request:n,mine:a,onAnswered:l}){const o=n.payload.plan??"",[c,d]=h.useState(!1),[u,m]=h.useState(o),[f,g]=h.useState(!1),[x,y]=h.useState(null),b=h.useRef(null),N=n.status==="pending"&&n.responseCapability==="live",v=($,E)=>{g(!0),y(null),ge.answerPlan(t.id,n.id,$,E).then(l,C=>{y(C.message),g(!1),C instanceof ht&&C.status===409&&l()})},k=AT(o),S=n.status==="answered"&&n.answer&&"decision"in n.answer?n.answer.decision:null;return e.jsxs("li",{className:`approval plan${N?" pending":""}`,"aria-label":"The agent's plan",children:[S==="deny"?e.jsxs("p",{className:"muted small",children:[n.answeredBy??"Its starter"," declined the plan; nothing changed."]}):S?e.jsxs("p",{className:"muted small",children:[n.answeredBy===null||a?"You":n.answeredBy," started with the plan",k?`, ${k} ${k===1?"step":"steps"}`:"","."]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{children:e.jsx("strong",{children:"The agent made a plan before it changes anything"})}),c?e.jsxs("label",{children:["The plan",e.jsx("textarea",{dir:"auto",rows:12,maxLength:PT,value:u,onChange:$=>m($.target.value),disabled:f})]}):e.jsx("div",{ref:b,className:"plan-text",dir:"auto",children:e.jsx(Ha,{text:o})}),n.status==="withdrawn"?e.jsx("p",{className:"muted small",children:"The agent took this back; it needs no answer."}):N?a?e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",disabled:f||!u.trim(),onClick:()=>v("allow_once",c&&u.trim()!==o.trim()?u.trim():void 0),children:"Start with this plan"}),c?e.jsx("button",{type:"button",className:"secondary",disabled:f,onClick:()=>{d(!1),m(o)},children:"Keep the agent's plan"}):e.jsx("button",{type:"button",className:"secondary",disabled:f,onClick:()=>d(!0),children:"Change the plan"}),e.jsx(sh,{text:c?u:o,target:b,label:"Copy the plan",small:!1})]}):e.jsx("p",{className:"muted small",children:"Waiting for the person who started this task to answer."}):e.jsx("p",{className:"muted small",children:"The agent stopped before this was answered."})]}),x?e.jsx("p",{className:"error",role:"alert",children:x}):null]})}const wr={command:"run a command","file-read":"read a file","file-change":"change a file",mcp:"use an MCP tool",permission:"use a tool",plan:"start with a plan"},vg={allow_once:"allowed once",allow_for_task:"allowed for this task",deny:"denied"};function OT({task:t,request:n,mine:a,onAnswered:l}){const[o,c]=h.useState(""),[d,u]=h.useState(!1),[m,f]=h.useState(!1),[g,x]=h.useState(null),y=v=>{f(!0),x(null),ge.answer(t.id,n.id,v,o.trim()||void 0).then(l,k=>{x(k.message),f(!1),k instanceof ht&&k.status===409&&l()})},b=Wa(n),N=[n.payload.tool,n.payload.summary].filter(Boolean).join(": ");if(n.status==="answered"&&n.answer&&"decision"in n.answer){const v=a?"You":n.answeredBy??"Its starter",k=n.kind==="file-change"?n.payload.summary:void 0;if(k){const S=n.answer.decision;return e.jsx("li",{className:"approval settled","aria-label":`The agent asks to ${wr[n.kind]}`,children:e.jsxs("p",{className:"muted small",children:[v," ",S==="deny"?"denied":"allowed"," writing ",e.jsx("span",{className:"mono",children:k}),S==="allow_once"?" once":S==="allow_for_task"?" for this task":"",n.answer.note?`: ${n.answer.note}`:"","."]})})}return e.jsx("li",{className:"approval settled","aria-label":`The agent asks to ${wr[n.kind]}`,children:e.jsxs("p",{className:"muted small",children:["The agent asked to ",wr[n.kind],N?e.jsxs(e.Fragment,{children:[": ",e.jsx("span",{className:"mono",children:N})]}):null,". ",v," ",vg[n.answer.decision],n.answer.note?`: ${n.answer.note}`:"","."]})})}return e.jsxs("li",{className:`approval${b?" pending":""}`,"aria-label":`The agent asks to ${wr[n.kind]}`,children:[e.jsx("p",{children:e.jsxs("strong",{children:["The agent asks to ",wr[n.kind]]})}),N?e.jsx("pre",{className:"pre mono",children:N}):null,n.status==="answered"&&n.answer?"decision"in n.answer?e.jsxs("p",{className:"muted small",children:[n.answeredBy??"Its starter"," ",vg[n.answer.decision],n.answer.note?`: ${n.answer.note}`:"","."]}):null:n.status==="withdrawn"?e.jsx("p",{className:"muted small",children:"The agent took this back; it needs no answer."}):b?a?d?e.jsxs("div",{className:"form",children:[e.jsxs("label",{children:["A note for the agent (optional)",e.jsx("textarea",{className:"short",value:o,onChange:v=>c(v.target.value),rows:2,maxLength:2e3})]}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",disabled:m,onClick:()=>y("deny"),children:"Deny"}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>u(!1),children:"Don't deny"})]})]}):e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",disabled:m,onClick:()=>y("allow_once"),children:"Allow once"}),e.jsx("button",{type:"button",className:"secondary",disabled:m,onClick:()=>y("allow_for_task"),children:"Allow for this task"}),e.jsx("button",{type:"button",className:"secondary",disabled:m,onClick:()=>u(!0),children:"Deny…"})]}):e.jsx("p",{className:"muted small",children:"Waiting for the person who started this task to answer."}):e.jsx("p",{className:"muted small",children:"The agent stopped before this was answered."}),g?e.jsx("p",{className:"error",role:"alert",children:g}):null]})}const LT="Not sent: part of it looks like a password or key. Write it without that, then send.";function FT({task:t,request:n,mine:a,agent:l,onAnswered:o}){const c=Array.isArray(n.payload.questions)?n.payload.questions:[],[d,u]=h.useState(()=>TT(c)),[m,f]=h.useState(!1),[g,x]=h.useState(""),[y,b]=h.useState(!1),[N,v]=h.useState(null),k=Wa(n),S=l||"The agent",$=M=>{v(M instanceof ht&&M.code==="answer-looks-secret"?LT:M.message),b(!1),M instanceof ht&&M.status===409&&o()},E=M=>{if(M.preventDefault(),!yg(c,d))return;b(!0),v(null);const O=Object.fromEntries(Object.entries(d).map(([_,I])=>{var L;return[_,{chosen:I.chosen,other:((L=I.other)==null?void 0:L.trim())||null}]}));ge.answerQuestions(t.id,n.id,O).then(o,$)},C=()=>{b(!0),v(null),ge.answer(t.id,n.id,"deny",g.trim()||void 0).then(o,$)},R=M=>O=>{var I;if(O.target instanceof HTMLTextAreaElement||!/^[1-9]$/.test(O.key))return;const _=(I=M.options)==null?void 0:I[Number(O.key)-1];_&&(O.preventDefault(),u(jg(d,M,_.value)))},P=n.answer;return e.jsxs("li",{className:`approval${k?" pending":""}`,"aria-label":`${S} asks you`,children:[c.length?n.status==="answered"&&P?"answers"in P?e.jsxs("dl",{className:"facts",children:[c.map(M=>e.jsxs("div",{children:[e.jsx("dt",{dir:"auto",children:M.title}),e.jsx("dd",{dir:"auto",children:RT(M,P.answers[M.key])})]},M.key)),e.jsxs("div",{children:[e.jsx("dt",{children:"Answered by"}),e.jsx("dd",{children:a?"You":n.answeredBy??"its starter"})]})]}):e.jsxs("p",{className:"muted small",children:[n.answeredBy??"Its starter"," did not answer","note"in P&&P.note?`: ${P.note}`:"","."]}):n.status==="withdrawn"?e.jsx("p",{className:"muted small",children:"The agent took this back; it needs no answer."}):k?a?m?e.jsxs("div",{className:"form",children:[e.jsxs("label",{children:["A note for the agent (optional)",e.jsx("textarea",{className:"short",value:g,onChange:M=>x(M.target.value),rows:2,maxLength:2e3})]}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",disabled:y,onClick:C,children:"Don't answer"}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>f(!1),children:"Back to the question"})]})]}):e.jsxs("form",{className:`form${c.length>1?" questions":""}`,onSubmit:E,"aria-label":`Answer ${S}`,children:[c.map(M=>{var O;return e.jsxs("fieldset",{className:"plain-fieldset question",onKeyDown:R(M),children:[e.jsx("legend",{dir:"auto",children:M.title}),M.description?e.jsx("p",{className:"muted small",dir:"auto",children:M.description}):null,(M.options??[]).map((_,I)=>{var L;return e.jsxs("label",{className:"check",children:[e.jsx("input",{type:M.choice==="many"?"checkbox":"radio",name:`${n.id}-${M.key}`,checked:((L=d[M.key])==null?void 0:L.chosen.includes(_.value))??!1,onChange:()=>u(jg(d,M,_.value))}),e.jsxs("span",{children:[e.jsx("span",{dir:"auto",children:_.label}),I<9?e.jsxs(e.Fragment,{children:[" ",e.jsx("kbd",{"aria-label":`key ${I+1}`,children:I+1})]}):null,_.description?e.jsxs("span",{className:"muted small",dir:"auto",children:[" ",_.description]}):null]})]},_.value)}),M.choice==="text"||M.other?e.jsxs("label",{children:[M.choice==="text"?"Your answer":"Something else",e.jsx("textarea",{dir:"auto",className:"short",rows:2,maxLength:Oj,value:((O=d[M.key])==null?void 0:O.other)??"",onChange:_=>u(ET(d,M,_.target.value))})]}):null]},M.key)}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",disabled:y||!yg(c,d),children:"Send the answers"}),e.jsx("button",{type:"button",className:"secondary",disabled:y,onClick:()=>f(!0),children:"Don't answer…"})]})]}):e.jsxs(e.Fragment,{children:[c.map(M=>e.jsx("p",{dir:"auto",children:M.title},M.key)),e.jsx("p",{className:"muted small",children:"Waiting for the person who started this task to answer."})]}):e.jsx("p",{className:"muted small",children:"The agent stopped before this was answered."}):e.jsx("p",{className:"muted small",children:"The agent asked something this page cannot show."}),N?e.jsx("p",{className:"error",role:"alert",children:N}):null]})}function MT({task:t,request:n,mine:a,onAnswered:l}){var k;const[o,c]=h.useState(""),[d,u]=h.useState(!1),[m,f]=h.useState(null),g=n.payload.name??"a secret",x=Wa(n),y=S=>{c(""),f(S.message),u(!1),S instanceof ht&&S.status===409&&l()},b=S=>{if(S.preventDefault(),!o)return;u(!0),f(null);const $=o;c(""),ge.giveSecret(t.id,n.id,$).then(l,y)},N=()=>{u(!0),f(null),ge.declineSecret(t.id,n.id).then(l,y)},v=n.answer&&"provided"in n.answer?n.answer.provided:null;return n.status==="answered"&&v!==null?e.jsx("li",{className:"approval settled","aria-label":`The agent asks for ${g}`,children:e.jsxs("p",{className:"muted small",children:[a?"You":n.answeredBy??"Its starter"," ",v?"gave":"did not give"," ",e.jsx("span",{className:"mono",children:g}),"."]})}):n.status!=="pending"||!x?e.jsx("li",{className:"approval settled","aria-label":`The agent asks for ${g}`,children:e.jsxs("p",{className:"muted small",children:["The agent no longer waits for ",e.jsx("span",{className:"mono",children:g}),"."]})}):a?e.jsxs("li",{className:"approval pending","aria-label":`The agent asks for ${g}`,children:[e.jsx("p",{children:e.jsxs("strong",{children:["The agent asks for ",e.jsx("span",{className:"mono",children:g})]})}),n.payload.why?e.jsx("blockquote",{className:"pre",dir:"auto",children:n.payload.why}):null,e.jsxs("form",{className:"form",onSubmit:b,"aria-label":`Give ${g}`,children:[e.jsxs("label",{children:[g,e.jsx("input",{type:"password",autoComplete:"off",value:o,onChange:S=>c(S.target.value),disabled:d})]}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",disabled:d||!o,children:"Give it to the agent"}),e.jsx("button",{type:"button",className:"secondary",disabled:d,onClick:N,children:"Decline"})]})]}),e.jsx("p",{className:"muted small",children:"It is sealed for this task alone; the agent gets it by name, and the value is never in the chat or the log."}),m?e.jsx("p",{className:"error",role:"alert",children:m}):null]}):e.jsx("li",{className:"approval pending","aria-label":`The agent asks for ${g}`,children:e.jsxs("p",{className:"muted small",children:["Waiting for ",((k=t.startedBy)==null?void 0:k.name)??"the person who started this task"," to give ",e.jsx("span",{className:"mono",children:g}),"."]})})}const Wa=t=>t.status==="pending"&&t.responseCapability==="live";function Ju(t){return(t.requests??[]).some(Wa)}function _T(t){return[...t].reverse().sort((n,a)=>Number(Wa(a))-Number(Wa(n)))}function UT({task:t,me:n,agent:a,onAnswered:l}){const o=(t.requests??[]).filter(u=>wr[u.kind]||u.kind==="question"||u.kind==="secret");if(!o.length)return null;const c=t.createdBy===n.email,d=o.filter(Wa).length;return e.jsxs("section",{className:"section","aria-labelledby":"task-requests-h",children:[e.jsxs("h2",{id:"task-requests-h",children:[a||"The agent"," asks you ",e.jsx("span",{className:"count",children:d?`${d} waiting`:o.length})]}),e.jsx("ul",{className:"plain approvals",children:_T(o).map(u=>u.kind==="secret"?e.jsx(MT,{task:t,request:u,mine:c,onAnswered:l},u.id):u.kind==="plan"?e.jsx(IT,{task:t,request:u,mine:c,onAnswered:l},u.id):u.kind==="question"?e.jsx(FT,{task:t,request:u,mine:c,agent:a,onAnswered:l},u.id):e.jsx(OT,{task:t,request:u,mine:c,onAnswered:l},u.id))})]})}const DT=864e5;function BT(t,n=new Date){if(!t)return"Your plan's usage limit is reached; continue the task once it resets.";const a=new Date(t),l=a.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hourCycle:"h23"});return a.getTime()-n.getTime()>DT?`Your plan's usage limit is reached until ${a.toLocaleDateString(void 0,{month:"short",day:"numeric"})} at ${l}; continue the task then.`:`Your plan's usage limit is reached; the task goes on by itself at ${l}${a.toDateString()===n.toDateString()?"":" tomorrow"}.`}function Lj(t,n){return n.mode==="local"?null:t.waitingFor==="connect"?{badge:"waiting for your machine",line:"This task waits for your machine: none of yours is connected yet.",link:"Connect your machine"}:t.waitingFor==="machine"?{badge:"waiting for your machine",line:"This task waits for your machine to come online.",link:"Your machines"}:null}function qT({task:t,me:n,onContinued:a}){const[l,o]=h.useState(!1),[c,d]=h.useState(null),u=()=>{o(!0),d(null),ge.continue(t.id).then(a,k=>{d(k.message),o(!1)})},m=e.jsx("a",{href:re("settings","machines"),children:"Your machines"}),f=Lj(t,n),g=n.mode==="local"?e.jsx("a",{href:re("settings","agents"),children:"Agent readiness"}):m,[x,y]=h.useState(!1);h.useEffect(()=>{if(t.waitingFor!=="limit"||t.createdBy!==n.email)return y(!1);yi.read().then(k=>y(!!(k.secondSignIn||k.secondSignInSet)),()=>y(!1))},[t.waitingFor,t.id]);const b=()=>{o(!0),d(null),ge.continueWithSecondSignIn(t.id).then(a,k=>{d(k.message),o(!1)})},N=t.waitingFor==="limit"&&x?e.jsx("button",{type:"button",disabled:l,onClick:b,children:"Continue with your second sign-in"}):t.status==="interrupted"&&t.createdBy===n.email?e.jsx("button",{type:"button",disabled:l,onClick:u,children:"Pick up where it stopped"}):null,v=f?e.jsxs(e.Fragment,{children:[f.line," ",e.jsx("a",{href:re("settings","machines"),children:f.link})]}):t.waitingFor==="connect"||t.waitingFor==="machine"?null:t.waitingFor==="limit"?e.jsx(e.Fragment,{children:BT(t.resetAt??null)}):t.waitingFor==="sign-in"?e.jsxs(e.Fragment,{children:["The agent on your machine is signed out. Sign in there (",g," has the command), then continue."]}):t.status==="interrupted"?e.jsx(e.Fragment,{children:t.interruptedBy==="restart"?"Stopped when the orchestrator restarted.":t.interruptedBy==="machine"||!t.error?"Stopped when your machine went away.":t.error}):null;return v?e.jsxs("div",{className:"waiting",role:"status",children:[e.jsx("p",{children:v}),N,c?e.jsx("p",{className:"error",role:"alert",children:c}):null]}):null}const Xu=(t,n="")=>`/api/tasks/${encodeURIComponent(t)}/shares${n}`,Zu={list:t=>U("GET",Xu(t)).then(n=>n.shares),add:(t,n)=>U("POST",Xu(t),{email:n}),remove:(t,n)=>U("DELETE",Xu(t,`/${encodeURIComponent(n)}`))};function WT({task:t,canShare:n,manager:a,adding:l,onClose:o}){const[c,d]=h.useState(null),[u,m]=h.useState(0),[f,g]=h.useState(""),[x,y]=h.useState(!1),[b,N]=h.useState(null),[v,k]=h.useState(null);if(h.useEffect(()=>{Zu.list(t).then(d,()=>d([]))},[t,u]),!c||!c.length&&!l)return null;const S=C=>{C.preventDefault(),y(!0),N(null),Zu.add(t,f.trim()).then(()=>{g(""),m(R=>R+1),o()},R=>N({said:R.message,notMember:R instanceof ht&&R.code==="not-a-member"})).finally(()=>y(!1))},$=C=>k(v===C?null:C),E=c.find(C=>C.userId===v)??null;return e.jsxs("section",{"aria-labelledby":"task-shares-h",children:[e.jsxs("h2",{id:"task-shares-h",children:["Shared with"," ",n&&E?e.jsx(qe,{small:!0,trigger:"Remove…",triggerLabel:`Stop sharing with ${E.name}`,consequence:`${E.name} no longer reads this task.`,confirm:"Stop sharing",keep:"Keep sharing",onConfirm:()=>Zu.remove(t,E.userId).then(()=>{k(null),m(C=>C+1)})},E.userId):null]}),c.length&&n?e.jsx("ul",{className:"tool-list",role:"listbox","aria-label":"Shared with",onKeyDown:Ld,children:c.map((C,R)=>e.jsxs("li",{className:"tool-row",role:"option",tabIndex:hj(R,c.findIndex(P=>P.userId===v)),"aria-selected":v===C.userId,onClick:()=>$(C.userId),onKeyDown:P=>{P.key!=="Enter"&&P.key!==" "||(P.preventDefault(),$(C.userId))},children:[e.jsx("span",{dir:"auto",children:C.name}),C.email?e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{className:"muted small",children:C.email})]}):null]},C.userId))}):c.length?e.jsx("ul",{className:"plain","aria-label":"Shared with",children:c.map(C=>e.jsx("li",{dir:"auto",children:C.name},C.userId))}):null,l?e.jsxs("form",{className:"form",onSubmit:S,"aria-label":"Share this task",children:[e.jsxs("label",{children:["A teammate's email",e.jsx("input",{type:"email",value:f,onChange:C=>g(C.target.value),required:!0,autoComplete:"off",autoFocus:!0})]}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",disabled:x||!f.trim(),children:"Share"}),e.jsx("button",{type:"button",className:"secondary",disabled:x,onClick:o,children:"Cancel"})]}),b?e.jsxs("p",{className:"error",role:"alert",children:[b.said,b.notMember&&a?e.jsxs(e.Fragment,{children:[" ",e.jsx("a",{href:re("settings","members"),children:"Invite them on Members"})]}):null]}):null]}):null]})}const zT={added:"added",modified:"changed",deleted:"deleted",renamed:"renamed"};function HT(t,n){return t.first||!n.trim()?t.message:n.trim()}function GT({projectId:t,title:n,onCommitted:a,onCancel:l}){const[o,c]=h.useState(null),[d,u]=h.useState(null),[m,f]=h.useState(0),[g,x]=h.useState(""),[y,b]=h.useState(new Set),[N,v]=h.useState(!1),[k,S]=h.useState(null);if(h.useEffect(()=>{u(null),Je.commitPlan(t).then(R=>{c(R),x(HT(R,n)),b(new Set(R.files.filter(P=>P.secretLike).map(P=>P.path)))},R=>u(R.message))},[t,m]),d)return e.jsx(be,{what:"what the commit takes",reason:d,onRetry:()=>f(R=>R+1)});if(!o)return e.jsx(he,{what:"what the commit takes"});const $=R=>b(P=>{const M=new Set(P);return M.has(R)?M.delete(R):M.add(R),M}),E=o.files.length-y.size,C=R=>{R.preventDefault(),v(!0),S(null),Je.commit(t,g.trim(),[...y]).then(P=>a(P.headSha),P=>{S(P.message),v(!1)})};return e.jsxs("form",{className:"form",onSubmit:C,"aria-label":"Commit these changes",children:[e.jsxs("label",{children:["Message",e.jsx("input",{value:g,onChange:R=>x(R.target.value),maxLength:200,required:!0})]}),e.jsxs("fieldset",{className:"plain-fieldset",children:[e.jsxs("legend",{children:["Files in the commit ",e.jsxs("span",{className:"count",children:[E," of ",o.files.length]})]}),e.jsx("ul",{className:"checks",children:o.files.map(R=>e.jsx("li",{children:e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:!y.has(R.path),onChange:()=>$(R.path)}),e.jsx("span",{className:"mono",dir:"auto",children:R.path})," ",e.jsxs("span",{className:"muted",children:[zT[R.status],R.secretLike?", looks like it holds a secret, left out":""]})]})},R.path))}),o.omitted?e.jsxs("p",{className:"muted small",children:[o.omitted," more ",o.omitted===1?"file is":"files are"," not listed."]}):null]}),k?e.jsx("p",{className:"error",role:"alert",children:k}):null,e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",disabled:N||!g.trim()||!E,children:"Commit"}),e.jsx("button",{type:"button",className:"secondary",onClick:l,disabled:N,children:"Cancel"})]})]})}function KT(t){return t.length?`${t.length===1?"One file was":`${t.length} files were`} edited after the task and kept as you left ${t.length===1?"it":"them"}: ${t.join(", ")}.`:null}function YT({task:t,mine:n,onChanged:a}){var Q,ee,W;const l=(t==null?void 0:t.result)==="changes",[o,c]=h.useState(!1),d=h.useMemo(()=>{var A;return t?dw(uw(t.id),((A=t.changes)==null?void 0:A.files)??[],()=>c(!0)):null},[t==null?void 0:t.id]),[u,m]=h.useState(null),[f,g]=h.useState(!1),[x,y]=h.useState(null),[b,N]=h.useState(null),[v,k]=h.useState(!1),[S,$]=h.useState(null),[E,C]=h.useState(!1);if(h.useEffect(()=>{!l||!t||Je.list().then(({projects:A})=>{var H,X;return N(((X=(H=A.find(de=>de.id===t.repoId))==null?void 0:H.facts)==null?void 0:X.git)??null)},()=>N(null))},[t==null?void 0:t.repoId,l]),!l||!t||!d)return{actions:null,section:null};const R=((Q=t.changes)==null?void 0:Q.undone)??null,P=((ee=t.changes)==null?void 0:ee.kept)??null,M=t.status!=="queued"&&t.status!=="running",O=A=>{y(A.message),A instanceof ht&&A.status===409&&a()},_=A=>ge.undo(t.id,A?{reason:A}:{}).then(H=>{m(H.kept),a()},O),I=(A,H)=>ge.undo(t.id,{paths:[A],...H?{reason:H}:{}}).then(a),L=(((W=t.changes)==null?void 0:W.files)??[]).filter(A=>A.state==="undone").map(A=>A.path),K=()=>{g(!0),y(null),ge.keep(t.id).then(a,O).finally(()=>g(!1))},B=KT(u??(R==null?void 0:R.kept)??[]),ne=A=>A.slice(0,16).replace("T"," "),Z=n&&M&&!R,D=Z?e.jsxs(e.Fragment,{children:[P?null:e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",disabled:f||!E,onClick:K,title:E?void 0:"The changes are read first, then kept.",children:"Keep these changes"}),e.jsx(qe,{trigger:"Undo these changes…",consequence:"Each file goes back to how it was before the task.",confirm:"Undo changes",keep:"Not now",reason:fh,onConfirm:_})]}),b&&b!=="none"&&!S&&!v?e.jsx("button",{type:"button",className:"secondary",onClick:()=>k(!0),children:"Commit these changes"}):null]}):null,te=e.jsxs("section",{className:"section","aria-labelledby":"review-h",children:[e.jsxs("h2",{id:"review-h",children:["Changes ",t.changes?e.jsx("span",{className:"count",children:t.changes.files.length}):null," ",e.jsx(Ie,{label:"undoing changes",children:"Undo puts each file back as it was before the task. A file you edited since stays as you left it, and a file the orchestrator keeps no copy of, such as one that looks like it holds a secret, cannot be put back."})]}),R?e.jsxs("p",{className:"muted",children:["Undone by ",R.by," at ",ne(R.at),R.reason?`: ${R.reason}`:"",". ",B]}):P?e.jsxs("p",{className:"muted",children:["Kept by ",P.by," at ",ne(P.at),". The files stay as the agent left them."]}):null,x?e.jsx("p",{className:"error",role:"alert",children:x}):null,v?e.jsx(GT,{projectId:t.repoId,title:t.title,onCancel:()=>k(!1),onCommitted:A=>{k(!1),$(A)}}):null,S?e.jsxs("p",{className:"notice",role:"status",children:["Committed as ",e.jsx("span",{className:"mono",children:S.slice(0,7)}),"."]}):null,!R&&B?e.jsx("p",{className:"muted",children:B}):null,o?e.jsx("p",{className:"muted",children:"These files changed on the computer the task ran on; open the folder there to read them."}):null,e.jsx(Fr,{reads:d,bare:!0,onRead:C,undone:L,...Z&&!P&&t.runner!=="local"?{onUndo:I}:{}},t.id)]});return{actions:D,section:te}}const _d=8e3,ri={steer:{label:"Tell the agent while it works",note:"It reaches the agent now, in the middle of its work.",send:"Send"},queue:{label:"Message for the agent",note:"It waits until the agent's current step ends, then reaches it.",send:"Queue message"},continue:{label:"Continue with a follow-up",note:"A new run starts on the request's branch with your words, and the request gets its new changes.",send:"Start the next run"}},Ud=20;function VT(t,n){return t.length>=Ud||t.some(a=>a.path===n.path&&a.lines===n.lines)?t:[...t,n]}function kg({quotes:t,onQuotes:n}){return t.length?e.jsx("ul",{className:"plain chips","aria-label":"Quoted lines",children:t.map(a=>e.jsxs("li",{className:"chip-pick on",children:[e.jsx("span",{className:"mono",children:a.path===Ax?`log ${a.lines}`:`${a.path}:${a.lines}`})," ",e.jsx("button",{type:"button",className:"ghost small","aria-label":`Leave out ${a.path} lines ${a.lines}`,onClick:()=>n(t.filter(l=>l!==a)),children:"×"})]},`${a.path}:${a.lines}`))}):null}function bg({personal:t=!1,task:n,kind:a,jump:l=null,stop:o=null,suggestTo:c="",quotes:d,onQuotes:u,onSent:m}){var M,O;const[f,g]=h.useState(""),[x,y]=h.useState(!1),[b,N]=h.useState(null),[v,k]=h.useState(()=>crypto.randomUUID()),[S,$]=h.useState([]),E=a==="suggest",C=E?{label:`Suggest a follow-up to ${c}`,note:`${c} reads it first; the agent gets it only if they continue with it.`,send:"Suggest"}:a==="continue"&&(n.state==="kept"||(M=n.changes)!=null&&M.kept||((O=n.request)==null?void 0:O.status)==="merged")?{...ri.continue,note:"A new run starts from the kept change, with your words, and its new changes come to you for review."}:a==="continue"&&n.requestNumber===null?{...ri.continue,note:"A new run starts where this one left off, with your words, and its changes join this review."}:a==="continue"&&t?{...ri.continue,note:"A new run starts where this one left off, with your words, and its changes join this review."}:ri[a],R=E?!!f.trim():!!(f.trim()||d.length),P=_=>{_.preventDefault(),R&&(y(!0),N(null),(E?ge.suggest(n.id,{text:f.trim(),quotes:d},v):(S.length?Cj(S,I=>bi.upload(n.id,I),$):Promise.resolve([])).then(I=>ge.message(n.id,{text:f.trim(),quotes:d,attachments:I},v))).then(()=>{g(""),$([]),u([]),k(crypto.randomUUID()),m()},I=>{N(I.message),I instanceof ht&&(I.code==="follow-up-not-offered"||I.code==="use-messages")&&m()}).finally(()=>y(!1)))};return a==="steer"||a==="queue"?e.jsxs("form",{className:"run-steer",onSubmit:P,"aria-label":C.label,children:[l,e.jsx(kg,{quotes:d,onQuotes:u}),e.jsx("textarea",{dir:"auto","aria-label":"Tell the agent something while it works",placeholder:"Tell the agent something while it works",value:f,onChange:_=>g(_.target.value),onKeyDown:_=>{var I;_.key!=="Enter"||_.shiftKey||_.nativeEvent.isComposing||(_.preventDefault(),(I=_.currentTarget.form)==null||I.requestSubmit())},rows:1,maxLength:_d}),e.jsx(Fd,{files:S,onChange:$,disabled:x,onRetry:()=>{var _;return(_=document.querySelector("form.run-steer"))==null?void 0:_.requestSubmit()}}),e.jsx("button",{type:"submit",className:f.trim()?void 0:"secondary",disabled:x||!f.trim(),children:C.send}),o,e.jsx(Ie,{label:"what you tell the agent",children:C.note}),b?e.jsx("p",{className:"error",role:"alert",children:b}):null]}):e.jsxs("section",{className:"panel","aria-labelledby":"follow-up-h",children:[e.jsx("h2",{id:"follow-up-h",children:C.label}),e.jsxs("form",{className:"form follow-form",onSubmit:P,"aria-labelledby":"follow-up-h",children:[e.jsx(kg,{quotes:d,onQuotes:u}),e.jsxs("label",{children:["What the agent should do",e.jsx("textarea",{className:"follow-text",dir:"auto",value:f,onChange:_=>g(_.target.value),rows:3,maxLength:_d})]}),E?null:e.jsx(Fd,{files:S,onChange:$,disabled:x,onRetry:()=>{var _;return(_=document.querySelector("form.follow-form"))==null?void 0:_.requestSubmit()}}),e.jsxs("p",{className:"muted small",children:[C.note,d.length>=Ud?` A follow-up holds ${Ud} quotes; send these before quoting more.`:d.length?" Quoted lines go to the agent as they are in the request.":null,d.length?null:e.jsxs(e.Fragment,{children:[" ",e.jsx(Ie,{label:"quoting lines",children:"Select lines in the request's changes to quote them."})]})]}),e.jsx("div",{className:"actions",children:e.jsx("button",{type:"submit",className:"secondary",disabled:x||!R,children:C.send})}),b?e.jsx("p",{className:"error",role:"alert",children:b}):null]})]})}function QT({task:t,messages:n,onChanged:a}){const[l,o]=h.useState(null),[c,d]=h.useState(""),[u,m]=h.useState(!1),[f,g]=h.useState(null);if(!n.length)return null;const x=y=>{m(!0),g(null),y().then(()=>{o(null),a()},b=>{g(b.message),b instanceof ht&&b.code==="message-not-waiting"&&a()}).finally(()=>m(!1))};return e.jsxs("section",{className:"queued","aria-label":"Messages waiting for the agent",children:[e.jsx("p",{className:"muted small",children:"Waiting for the agent's next step:"}),e.jsx("ul",{className:"plain",children:n.map(y=>{var b;return e.jsx("li",{children:l===y.id?e.jsxs("form",{className:"form",onSubmit:N=>{N.preventDefault(),x(()=>{var v;return ge.editMessage(t,y.id,{text:c.trim(),...(v=y.quotes)!=null&&v.length?{quotes:y.quotes}:{}})})},children:[e.jsx("textarea",{className:"follow-text",dir:"auto","aria-label":"Change the message",value:c,onChange:N=>d(N.target.value),rows:2,maxLength:_d}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",className:"small",disabled:u||!c.trim(),children:"Save"}),e.jsx("button",{type:"button",className:"ghost small",onClick:()=>o(null),children:"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"pre",dir:"auto",children:y.text}),(b=y.quotes)!=null&&b.length?e.jsxs("span",{className:"muted small",children:[" with ",y.quotes.length," quoted ",y.quotes.length===1?"passage":"passages"]}):null," ",e.jsx("button",{type:"button",className:"ghost small",disabled:u,onClick:()=>{o(y.id),d(y.text)},children:"Edit"}),e.jsx("button",{type:"button",className:"ghost small",disabled:u,onClick:()=>x(()=>ge.removeMessage(t,y.id)),children:"Remove"})]})},y.id)})}),f?e.jsx("p",{className:"error",role:"alert",children:f}):null]})}const wg={jira:"Jira",confluence:"Confluence",github:"GitHub",gitlab:"GitLab",sentry:"Sentry",linear:"Linear",notion:"Notion",slack:"Slack"},JT=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[\s_\-.]+/).filter(Boolean),XT=t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase();function ZT(t){const n=/^plugin[:_]([^:_]+)[:_](.+)$/.exec(t);if(n)return{server:n[2],plugin:n[1],connector:!1};const a=/^claude[._ ]ai[._ ](.+)$/i.exec(t);return a?{server:a[1],plugin:null,connector:!0}:{server:t,plugin:null,connector:!1}}function Ng(t){const n=JT(t),a=n.find(l=>wg[l.toLowerCase()]);return a?wg[a.toLowerCase()]:n.map(XT).join(" ")||t}function eE(t){const n=new Map;for(const a of t){const{server:l,plugin:o,connector:c}=ZT(a),d=o?`${Ng(l)} (from ${o})`:Ng(l),u=n.get(d.toLowerCase());u?u.connector&&!c&&n.set(d.toLowerCase(),{name:a,label:d,connector:c}):n.set(d.toLowerCase(),{name:a,label:d,connector:c})}return[...n.values()].map(({name:a,label:l})=>({name:a,label:l}))}const tE=2e3,nE=18e4,Sg=t=>`/api/me/claude-mcp/${encodeURIComponent(t)}/sign-in`;function Fj({names:t,onePerson:n=!1}){const[a,l]=h.useState({}),[o,c]=h.useState([]),d=h.useRef(new Set);h.useEffect(()=>()=>d.current.forEach(clearTimeout),[]);const u=eE(t),m=u.filter(y=>!o.includes(y.name));if(!m.length&&!o.length)return null;const f=(y,b)=>l(N=>{const v={...N};return b?v[y]=b:delete v[y],v}),g=(y,b)=>{const N=setTimeout(()=>{d.current.delete(N),U("GET",Sg(y)).then(v=>{v.state==="signed-in"?(f(y,null),c(k=>[...k,y])):v.state==="failed"?f(y,{at:"failed",why:v.why??"The sign-in did not finish."}):Date.now()<b?g(y,b):f(y,{at:"failed",why:"The sign-in did not come back; try again, or sign in with claude and /mcp."})},v=>f(y,{at:"failed",why:v.message}))},tE);d.current.add(N)},x=y=>{f(y,{at:"starting"}),U("POST",Sg(y)).then(b=>{if("signedIn"in b){f(y,null),c(N=>[...N,y]);return}window.open(b.authorizeUrl,"_blank","noopener"),f(y,{at:"waiting"}),g(y,Date.now()+nE)},b=>f(y,{at:"failed",why:b.message}))};return e.jsxs("div",{className:"muted mcp-sign-in",role:"note",children:[m.length?e.jsxs("details",{children:[e.jsxs("summary",{children:[m.length===1?"1 MCP server needs":`${m.length} MCP servers need`," sign-in"]}),n?e.jsx("div",{className:"mcp-sign-in-buttons",children:m.map(({name:y,label:b})=>{const N=a[y];return e.jsxs("span",{className:"mcp-sign-in-row",children:[e.jsx("button",{type:"button",className:"secondary small",disabled:(N==null?void 0:N.at)==="starting"||(N==null?void 0:N.at)==="waiting",onClick:()=>x(y),children:`Sign in to ${b}`}),(N==null?void 0:N.at)==="waiting"?e.jsx("span",{role:"status",children:" Waiting for the sign-in in the other tab…"}):null,(N==null?void 0:N.at)==="failed"?e.jsxs("span",{className:"error",role:"alert",children:[" ",N.why]}):null]},y)})}):e.jsx("p",{dir:"auto",children:m.map(y=>y.label).join(", ")}),e.jsxs("p",{className:"small",children:["Or run ",e.jsx(mt,{text:"claude"}),", then ",e.jsx("span",{className:"mono",children:"/mcp"}),", in your terminal."]})]}):null,o.length?e.jsxs("p",{role:"status",children:["Signed in to ",u.filter(y=>o.includes(y.name)).map(y=>y.label).join(", "),"; the next task can use ",o.length===1?"it":"them","."]}):null]})}const sE=4e3,aE="Paste the issue text",rE=8e3;function lE({task:t,mine:n,agent:a,onAnswered:l}){const[o,c]=h.useState(""),[d,u]=h.useState(""),[m,f]=h.useState(""),[g,x]=h.useState(!1),[y,b]=h.useState(null),N=t.question;if(!N||N.answer)return null;const v=o===aE&&!d.trim(),k=v?m.trim():d.trim()||o,S=$=>{$.preventDefault(),k&&(x(!0),b(null),ge.answerStopped(t.id,k).then(l,E=>{b(E.message),x(!1)}))};return e.jsxs("section",{className:"section","aria-labelledby":"task-question-h",children:[e.jsxs("h2",{id:"task-question-h",children:[a||"The agent"," stopped to ask",n?" you":` ${t.createdBy}`]}),e.jsx("p",{dir:"auto",className:"pre",children:N.text}),n?e.jsxs("form",{className:"form",onSubmit:S,"aria-label":"Answer the agent",children:[N.options.length?e.jsxs("fieldset",{className:"plain-fieldset question",children:[e.jsx("legend",{className:"visually-hidden",children:"Options"}),N.options.map($=>e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"radio",name:"stopped-question",checked:!d.trim()&&o===$,onChange:()=>c($)}),e.jsx("span",{dir:"auto",children:$})]},$))]}):null,v?e.jsxs("label",{children:["The issue's text",e.jsx("textarea",{dir:"auto",rows:6,maxLength:rE,value:m,onChange:$=>f($.target.value),autoFocus:!0})]}):null,e.jsxs("label",{children:[N.options.length?"Something else":"Your answer",e.jsx("textarea",{dir:"auto",className:"short",rows:2,maxLength:sE,value:d,onChange:$=>u($.target.value)})]}),e.jsx("div",{className:"actions",children:e.jsx("button",{type:"submit",disabled:g||!k,children:"Send the answer"})}),y?e.jsx("p",{className:"error",role:"alert",children:y}):null]}):e.jsxs("p",{className:"muted",children:["The answer is ",t.createdBy,"'s to give."]})]})}const Dd="orchestrator:repeats",oE=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],iE={day:"day",weekday:"weekday",monday:"Monday",tuesday:"Tuesday",wednesday:"Wednesday",thursday:"Thursday",friday:"Friday",saturday:"Saturday",sunday:"Sunday"},Mj=t=>t.replace(/^0/,""),pi=(t,n)=>`every ${iE[t]} at ${Mj(n)}`,Bd=t=>{const n=new Date(t);return`${n.toLocaleDateString(void 0,{weekday:"short"})} ${Mj(n.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hourCycle:"h23"}))}`};function _j(){const[t,n]=h.useState([]),a=()=>{ge.repeats().then(n,()=>{})};return h.useEffect(()=>(a(),window.addEventListener(Dd,a),()=>window.removeEventListener(Dd,a)),[]),t.length?e.jsx(Xt,{name:"Repeats",count:t.length,why:"Each starts by itself; every run is an ordinary task in the list.",empty:"",children:e.jsx("ul",{className:"plain repeats",children:t.map(l=>e.jsxs("li",{children:[e.jsxs("p",{children:[e.jsx("strong",{dir:"auto",children:l.title})," ",e.jsxs("span",{className:"muted",children:[pi(l.every,l.at),", next ",Bd(l.next)]})]}),l.skipped?e.jsxs("p",{className:"muted small",children:["Skipped ",Bd(l.skipped.at),": ",l.skipped.reason,"."]}):null,e.jsx(qe,{small:!0,trigger:"Stop repeating…",triggerLabel:`Stop repeating ${l.title}`,consequence:"It stops starting by itself; the tasks it already ran stay in the list.",confirm:"Stop repeating",keep:"Keep repeating",onConfirm:()=>ge.stopRepeat(l.id).then(a)})]},l.id))})}):null}const Ul="all",Cg=40,cE=t=>`“${t.said.length>Cg?`${t.said.slice(0,Cg).trimEnd()}…`:t.said}” at ${Wl(t.at)}`;function uE(t,n){const a=t.find(c=>c.n===n),l=t.filter(c=>c.n>n&&!c.undone).length,o=l?`; the ${l===1?"turn":`${l} turns`} after it go${l===1?"es":""} too, and the conversation stays.`:"; the conversation stays.";return`The files go back to how they were before “${(a==null?void 0:a.said)??""}”${o}`}function dE({taskId:t,turn:n}){const[a,l]=h.useState(!1),[o,c]=h.useState(""),[d,u]=h.useState(!1),[m,f]=h.useState(null);if(!a)return e.jsx("button",{type:"button",className:"secondary small",onClick:()=>l(!0),children:"Start a new task from here…"});const g=()=>{u(!0),f(null),ge.newFromTurn(t,n.n,o.trim()).then(x=>Ge(re("tasks",x.id)),x=>{f(x.message),u(!1)})};return e.jsxs("form",{className:"form","aria-label":"Start a new task from here",onSubmit:x=>{x.preventDefault(),g()},children:[e.jsx("p",{children:"A new task starts from the files as this turn left them; this task and its branch stay as they are."}),e.jsxs("label",{children:["What should it do differently?",e.jsx("textarea",{className:"short",value:o,onChange:x=>c(x.target.value),rows:2,maxLength:2e3})]}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",disabled:d,children:"Start new task"}),e.jsx("button",{type:"button",className:"secondary",disabled:d,onClick:()=>l(!1),children:"Keep reading"})]}),m?e.jsx("p",{className:"error",role:"alert",children:m}):null]})}function hE(t){const[n,a]=h.useState([]),[l,o]=h.useState(Ul);return h.useEffect(()=>{let c=!0;return o(Ul),ge.turns(t).then(d=>c&&a(d),()=>{}),()=>{c=!1}},[t]),{turns:n,setTurns:a,picked:l,setPicked:o}}const Uj=t=>t.length>1;function mE({pick:t}){return Uj(t.turns)?e.jsx("div",{className:"turn-select",children:e.jsx(Pe,{label:"Show",labelHidden:!0,value:t.picked,onChange:t.setPicked,options:[{value:Ul,label:"All changes"},...t.turns.map(n=>({value:String(n.n),label:cE(n),...n.undone?{hint:"undone"}:{}}))]})}):null}function pE({taskId:t,pick:n,all:a,canUndo:l,onUndone:o,onQuote:c}){const{turns:d,setTurns:u,picked:m,setPicked:f}=n,g=m===Ul?null:Number(m),x=Uj(d)?d.find(b=>b.n===g):void 0,y=b=>ge.undoFromTurn(t,g,b).then(N=>{u(N),f(Ul),o()});return x?e.jsxs(e.Fragment,{children:[e.jsx(Fr,{reads:cw(t,x.n),bare:!0,...c?{onQuote:c}:{}},x.n),x.newTaskId?e.jsxs("p",{className:"muted small",children:["A new task started from here: ",e.jsx("a",{href:re("tasks",x.newTaskId),children:"open it"})]}):null,l&&!x.undone?e.jsxs("div",{className:"actions",children:[e.jsx(dE,{taskId:t,turn:x},x.n),e.jsx(qe,{small:!0,trigger:"Undo from this turn…",consequence:uE(d,x.n),confirm:"Undo these turns",keep:"Keep them",reason:fh,onConfirm:y})]}):null]}):e.jsx(e.Fragment,{children:a})}function fE({folder:t,off:n,onOff:a,onRead:l}){const o=$n.lastSources(t),[c,d]=h.useState("sources"in(o??{})?o.sources:null),[u,m]=h.useState($n.lastDefaults()??qa),[f,g]=h.useState(()=>window.matchMedia("(min-width: 1100px)").matches);if(h.useEffect(()=>{const v=window.matchMedia("(min-width: 1100px)"),k=()=>g(v.matches);return v.addEventListener("change",k),()=>v.removeEventListener("change",k)},[]),h.useEffect(()=>{let v=!0;return $n.lastDefaults()&&a($n.lastDefaults()),$n.defaults().then(k=>{v&&(m(k),a(k))},()=>{}),()=>{v=!1}},[]),h.useEffect(()=>{let v=!0;return c&&(l==null||l(!0)),$n.sources(t).then(k=>{if(!v)return;const S="sources"in k?k.sources:null;d(S),l==null||l(!!S)},()=>{v&&(d(null),l==null||l(!1))}),()=>{v=!1}},[t]),!c)return null;const x=TN(c,n,u),y=fa(c,u,"task"),b=y.filter(v=>v.on).length,N=e.jsx(qx,{sources:c,off:n,defaultOff:u,level:"task",onChange:a});return e.jsxs("section",{className:"task-setup","aria-labelledby":"task-setup-h",children:[e.jsx("h2",{id:"task-setup-h",children:"This task will use"}),e.jsxs("p",{children:[x?`${x} ${x===1?"change":"changes"} from your default`:`Your default setup: ${b} of ${y.length} on`,x?e.jsxs(e.Fragment,{children:[" · ",e.jsx("button",{type:"button",className:"link",onClick:()=>a(u),children:"Reset"})]}):null]}),e.jsx("p",{className:"muted small",children:"Turn anything off for this task only; your default stays the same."}),f?e.jsx("div",{className:"task-setup-list",children:N}):e.jsxs("details",{children:[e.jsx("summary",{children:"What it loads"}),N]}),e.jsx("p",{className:"small task-setup-link",children:e.jsx("a",{href:re("team"),children:"Change your default on Team"})}),e.jsx(zx,{sources:c,look:e.jsx("a",{href:re("team"),children:"Look"}),putAway:v=>$n.noticed(v.id)})]})}const $g=80,qd=t=>t.length>$g?`${t.slice(0,$g).trimEnd()}…`:t;function gE(t,n,a=null){const l=c=>c==null?void 0:c.find(d=>d.name===t.name&&d.source===t.source.id),o=t.kind==="Skill"?l(n==null?void 0:n.skills):t.kind==="Server"?l(n==null?void 0:n.mcpServers):void 0;return t.on?o?{word:"Used",danger:!1,...o.seq!==void 0?{seq:o.seq}:{}}:{word:"Loaded",danger:!1}:o?{word:"Loaded, though off",danger:!0}:{word:a!=null&&a.has(t.key)?"Off":"Off for this task",danger:!1}}function xE(t,n,a){var u;if(!a)return[];const l=(u=a.plugins)==null?void 0:u.map(m=>m.split("@")[0]),o=l?t.filter(m=>m.kind==="plugin"&&!Tn(n,m)&&!l.includes(m.name)).map(m=>m.name):[],c=a.mcpServers?new Map(a.mcpServers.map(m=>[m.name,m.state])):null,d=c?fa(t,n,"readonly").filter(m=>m.kind==="Server"&&m.on&&m.source.kind!=="plugin"&&(!c.has(m.name)||c.get(m.name)==="failed"||c.get(m.name)==="off")).map(m=>m.name):[];return[...o,...d]}const fi=(t,n,a)=>`${t} ${t===1?n:a}`,Wd="Nothing of your setup";function jE(t,n,a){const l=a.filter(m=>m.on),o=l.filter(m=>m.kind==="Skill").length,c=t.filter(m=>m.kind==="plugin"&&!Tn(n,m)).length,d=l.filter(m=>m.kind==="Server").length,u=[o?fi(o,"skill","skills"):null,c?fi(c,"plugin","plugins"):null,d?fi(d,"MCP server","MCP servers"):null,l.some(m=>m.kind==="Rules")?"CLAUDE.md":null].filter(m=>m!==null);return u.length?u.join(", "):Wd}function ed({e:t,state:n,word:a=!0}){const l=qd(t.name);return e.jsxs("li",{className:"started-line",children:[n.seq!==void 0?e.jsx("button",{type:"button",className:"link mono",onClick:()=>ix(n.seq),dir:"auto",children:l}):e.jsx("span",{className:"mono",dir:"auto",children:l})," ",e.jsxs("span",{className:"muted small",children:["from ",qd(t.source.kind==="yours"?"yours":$i(t.source))]}),a?e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{className:n.danger?"error small":"muted small",children:n.word})]}):null]})}function yE({setup:t,off:n=qa,used:a,report:l}){const[o,c]=h.useState(null);h.useEffect(()=>{let v=!0;return $n.defaults().then(k=>v&&c(k),()=>{}),()=>{v=!1}},[]);const d=t??vE(a);if(!d.length)return null;const u=fa(d,n,"readonly"),m=o?new Set(fa(d,o,"readonly").filter(v=>!v.on).map(v=>v.key)):null,f=u.map(v=>({e:v,state:gE(v,a,m)})),g=v=>f.filter(k=>k.state.word===v),x=g("Loaded, though off"),y=g("Used"),b=t?jE(d,n,u):null,N=(v,k)=>k.length?e.jsxs("details",{className:"small",children:[e.jsxs("summary",{children:[v," (",k.length,")"]}),e.jsx("ul",{className:"plain",children:k.map(S=>e.jsx(ed,{e:S.e,state:S.state},S.e.key))})]}):null;return e.jsxs("section",{"aria-labelledby":"task-started-h",className:"task-started",children:[e.jsx("h2",{id:"task-started-h",children:"Started with"}),t?xE(d,n,l).map(v=>e.jsxs("p",{className:"error small",children:[qd(v)," was on and did not load."]},v)):null,t&&!x.length&&!y.length&&b===Wd?e.jsx("p",{children:"Nothing of your setup was used."}):e.jsx("p",{children:t?b:fi(y.length,"item used","items used")}),x.length||y.length?e.jsxs("ul",{className:"plain",children:[x.map(v=>e.jsx(ed,{e:v.e,state:v.state},v.e.key)),y.map(v=>e.jsx(ed,{e:v.e,state:v.state,word:!1},v.e.key))]}):b===Wd&&t?null:e.jsx("p",{className:"muted small",children:"The agent called no skill or server."}),N("Loaded",g("Loaded")),N("Off",g("Off")),N("Off for this task",g("Off for this task"))]})}function vE(t){if(!t)return[];const n=new Map,a=(l,o)=>{const c=l==="yours"?"yours":l.startsWith("folder:")?"folder":l.startsWith("team:")?"team-repo":"plugin",d=c==="team-repo"?o.replace(/^the team's /,""):c==="folder"?o.replace(/^this folder \((.*)\)$/i,"$1"):o;return n.has(l)||n.set(l,{id:l,kind:c,name:d,enabled:!0,skills:[],commands:[],mcpServers:[],hooks:[]}),n.get(l)};for(const l of t.skills)a(l.source,l.sourceLabel).skills.push({name:l.name});for(const l of t.mcpServers)a(l.source,l.sourceLabel).mcpServers.push({name:l.name});return[...n.values()]}function kE(t){var n,a;return(n=t.changes)!=null&&n.undone?"its change was undone":(a=t.requests)!=null&&a.some(l=>l.answer&&"decision"in l.answer&&l.answer.decision==="deny")?"a request it made was denied":null}async function bE(t,n){const a=await $n.skill(t,n);await U("PUT","/api/handbook/file",{source:"yours",kind:"skill",name:n,content:a,expectedDigest:null})}function wE({source:t,name:n}){const[a,l]=h.useState(!1),[o,c]=h.useState(!1),[d,u]=h.useState(null);return a?e.jsx("span",{className:"muted",children:"Copied to yours."}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"link",disabled:o,onClick:()=>{c(!0),u(null),bE(t,n).then(()=>l(!0),m=>u(m.message)).finally(()=>c(!1))},children:"Copy to Yours"}),d?e.jsxs("span",{className:"error small",role:"alert",children:[" ",d]}):null]})}async function NE(t,n,a){var d;const o=(d=(await ge.options()).agents[0])==null?void 0:d.id;if(!o)throw new Error("No agent is set up on this orchestrator yet.");const c=await ge.start({title:`Improve the ${n} skill`,description:`${n} was used in "${t.title}", and that task was corrected.`,issueUrl:"",repoId:a,agent:o,template:{kind:"skill.improve",skill:n}});Ge(re("tasks",c.id))}async function SE(t,n){var o,c,d,u;const a=(c=(o=t.used)==null?void 0:o.skills.find(m=>m.name===n&&m.source.startsWith("team:")))==null?void 0:c.source.slice(5);if(a)return a;const l=await ge.options();return((d=l.repos.find(m=>m.kind==="skills"&&m.team===t.team))==null?void 0:d.id)??((u=l.repos.find(m=>m.kind==="skills"))==null?void 0:u.id)??null}function CE({task:t}){var c;const[n,a]=h.useState([]);h.useEffect(()=>{let d=!0;return Tr.ofTask(t.id).then(u=>d&&a(u.improvable??[]),()=>{}),()=>{d=!1}},[t.id]);const l=kE(t),o=l?(((c=t.used)==null?void 0:c.skills)??[]).filter(d=>!d.source.startsWith("team:")):[];return!n.length&&!o.length?null:e.jsxs("ul",{className:"plain used-corrected",children:[n.map(d=>e.jsxs("li",{className:"small",children:[e.jsx("span",{className:"mono",children:d})," was used",l?`, and ${l}`:" in a task you corrected","."," ",e.jsx(qe,{small:!0,trigger:"Improve this skill…",consequence:`This starts a task that improves ${d} in the team's skills; nothing changes until its change is kept.`,confirm:"Start the task",keep:"Not now",onConfirm:async()=>{const u=await SE(t,d);if(!u)throw new Error("No team skills repository is connected here.");await NE(t,d,u)}})]},`team
|
|
90
|
+
${d}`)),o.map(d=>e.jsxs("li",{className:"small",children:[e.jsx("span",{className:"mono",children:d.name})," was used, and ",l,"."," ",d.source.startsWith("plugin:")?e.jsx(wE,{source:d.source,name:d.name}):e.jsx("a",{href:re("team"),children:"Improve this skill…"})]},`${d.source}
|
|
91
|
+
${d.name}`))]})}function $E(t,n){return t.fallback?", the folder you use most":n?`, which its CLAUDE.md calls ${n}`:""}function TE(t,n){const a=[t.skills?`${t.skills} ${t.skills===1?"skill":"skills"}`:"",t.claudeMd?"CLAUDE.md":"",t.memory?"memory":""].filter(Boolean);return a.length?`Loaded: ${a.join(", ")} from ${n}.`:`Nothing of ${n}'s own is loaded: it has no CLAUDE.md, skills or memory.`}function EE(t){return t.length?`, checked with ${t.join(" and ")}`:""}function RE({task:t,routing:n,canMove:a,checked:l=[],onChecksOff:o}){var I;const[c,d]=h.useState(!1),[u,m]=h.useState(""),[f,g]=h.useState(null),[x,y]=h.useState(null),[b,N]=h.useState(null),[v,k]=h.useState(!1),[S,$]=h.useState(!1),[E,C]=h.useState(null);h.useEffect(()=>{Je.workFolders().then(L=>g(L.folders),()=>g([])),Je.list().then(L=>y(L.home??null),()=>y(null))},[]);const R=L=>Kn(L,x),P=((I=f==null?void 0:f.find(L=>L.path===n.path))==null?void 0:I.about)??null,M=(f??[]).filter(L=>L.path!==n.path),O=()=>{b&&($(!0),C(null),ge.move(t.id,b).then(({task:L})=>Ge(re("tasks",L.id)),L=>{C(L.message),$(!1)}))},_=()=>{$(!0),C(null),$s.forget(t.repoId).then(()=>{d(!1),$(!1),o==null||o()},L=>{C(L.message),$(!1)})};return e.jsxs("li",{className:"run-line","data-kind":"where",children:[f===null?null:e.jsxs(e.Fragment,{children:["Working in ",e.jsx("span",{className:"mono",dir:"auto",children:R(n.path)}),$E(n,P),EE(l)]}),a&&f!==null&&!b&&!v&&!c?e.jsxs(e.Fragment,{children:[" ",e.jsx(ql,{label:"Change where the task works",summary:"Change",className:"run-where-change",children:L=>e.jsxs("ul",{className:"plain run-where-folders",children:[e.jsx("li",{children:e.jsx("form",{onSubmit:K=>{K.preventDefault(),u.trim()&&(N(oa(u,x)),m(""),L())},children:e.jsxs("label",{children:["A folder's path",e.jsx("input",{type:"text",value:u,onChange:K=>m(K.target.value),placeholder:"~/code",dir:"auto"})]})})}),M.map(K=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"ghost",onClick:()=>{N(K.path),L()},children:[e.jsx("span",{dir:"auto",children:K.name})," ",e.jsx("span",{className:"mono muted",dir:"auto",children:R(K.path)})]})},K.path)),e.jsx("li",{children:e.jsx("button",{type:"button",className:"ghost",onClick:()=>{k(!0),L()},children:"Another folder…"})}),l.length?e.jsx("li",{children:e.jsx("button",{type:"button",className:"ghost",onClick:()=>{d(!0),L()},children:"Run without checks"})}):null]})})]}):null,f!==null&&n.loaded?e.jsx("span",{className:"muted small run-loaded",children:TE(n.loaded,R(n.path))}):null,v?e.jsxs(e.Fragment,{children:[e.jsx(yh,{onOpened:L=>{var K;k(!1),N(((K=L.machine)==null?void 0:K.path)??L.url.replace(/^file:\/\//,""))}}),e.jsx("p",{children:e.jsx("button",{type:"button",className:"secondary small",onClick:()=>k(!1),children:"Keep it here"})})]}):null,c?e.jsxs("div",{className:"confirm",role:"group","aria-label":"Run without checks",children:[e.jsxs("p",{children:["The checks for ",e.jsx("span",{className:"mono",dir:"auto",children:R(n.path)})," are taken back; tasks there run none until you approve them again."]}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",className:"confirm-go small",onClick:_,disabled:S,children:S?"Take them back…":"Take them back"}),e.jsx("button",{type:"button",className:"secondary small",onClick:()=>{d(!1),C(null)},disabled:S,children:"Keep the checks"})]}),E?e.jsx("p",{className:"error",role:"alert",children:E}):null]}):null,b?e.jsxs("div",{className:"confirm",role:"group","aria-label":"Start it there",children:[e.jsxs("p",{children:["The task starts again in ",e.jsx("span",{className:"mono",dir:"auto",children:R(b)}),"; what it did so far is dropped."]}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",className:"confirm-go small",onClick:O,disabled:S,children:S?"Start it there…":"Start it there"}),e.jsx("button",{type:"button",className:"secondary small",onClick:()=>{N(null),C(null)},disabled:S,children:"Keep it here"})]}),E?e.jsx("p",{className:"error",role:"alert",children:E}):null]}):null]})}function PE(t,n,a){return t.status==="continued"?a?"You continued with it.":`${n} continued with it.`:t.status==="dismissed"?a?"You dismissed it.":`${n} dismissed it.`:t.status==="expired"?"The request ended before it was answered.":`Waiting for ${n} to continue with it or dismiss it.`}function AE({task:t,suggestion:n,starter:a,mine:l,onAnswered:o}){var x;const[c,d]=h.useState(!1),[u,m]=h.useState(null),f=y=>{d(!0),m(null),ge.answerSuggestion(t.id,n.id,y).then(()=>o(y==="continue"),b=>{m(b.message),d(!1)})},g=n.status==="waiting";return e.jsxs("li",{className:`approval${g?" pending":""}`,"aria-label":`${n.by.name} suggests a follow-up`,children:[e.jsxs("p",{children:[e.jsxs("strong",{dir:"auto",children:[n.by.name," suggests:"]})," ",e.jsx("span",{className:"pre",dir:"auto",children:n.text})]}),(x=n.quotes)!=null&&x.length?e.jsx("ul",{className:"plain","aria-label":"Quoted lines",children:n.quotes.map(y=>e.jsxs("li",{className:"mono small",children:[y.path,":",y.lines]},`${y.path}:${y.lines}`))}):null,n.canAnswer?e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",disabled:c,onClick:()=>f("continue"),children:"Continue with it"}),e.jsx("button",{type:"button",className:"secondary",disabled:c,onClick:()=>f("dismiss"),children:"Dismiss"})]}):e.jsx("p",{className:"muted small",children:PE(n,a,l)}),u?e.jsx("p",{className:"error",role:"alert",children:u}):null]})}function IE({task:t,me:n,onAnswered:a}){var m;const l=t.suggestions??[];if(!l.length)return null;const o=t.createdBy===n.email,c=((m=t.startedBy)==null?void 0:m.name)??"the person who started this task",d=l.filter(f=>f.status==="waiting").length,u=[...l].reverse().sort((f,g)=>+(g.status==="waiting")-+(f.status==="waiting"));return e.jsxs("section",{className:"section","aria-labelledby":"task-suggestions-h",children:[e.jsxs("h2",{id:"task-suggestions-h",children:["Suggested follow-ups ",e.jsx("span",{className:"count",children:d?`${d} waiting`:l.length})]}),e.jsx("ul",{className:"plain approvals",children:u.map(f=>e.jsx(AE,{task:t,suggestion:f,starter:c,mine:o,onAnswered:a},f.id))})]})}const dn=["queued","running"],OE=["failed","cancelled"];function Dj(t,n,a){const l=typeof t=="string"?t:t==null?void 0:t.kind;return`${l&&Ar(l)?Xd(l,typeof t=="object"&&t?t.number:n):"The change"} ${LE[a]}.`}const LE={open:"waits for a person to review and merge it",merged:"was merged",closed:"was closed without being merged"};function FE(t){var n,a,l,o;return{title:t.title,description:t.description,issueUrl:t.issueUrl??"",repoId:t.repoId,agent:t.agent,template:t.template,...t.targetMode==="orchestrator"?{targets:"orchestrator"}:(n=t.targets)!=null&&n.length?{targets:t.targets.map(c=>c.repoId)}:{},...(a=t.skills)!=null&&a.length?{skills:t.skills}:{},...t.choices&&Object.keys(t.choices).length?{choices:t.choices}:{},...t.mode?{mode:t.mode}:{},...(l=t.tools)!=null&&l.skills.length?{projectSkills:t.tools.skills.map(c=>({source:c.source,name:c.name}))}:{},...(o=t.tools)!=null&&o.mcpServers.length?{mcpServers:t.tools.mcpServers}:{}}}function ME(t){var a;const n=tx(t);return n||(t.status==="needs-review"&&((a=t.request)==null?void 0:a.status)==="merged"?"merged":t.status)}function _E({task:t}){const n=Ba(t),a=Lr(n,t.forge);return e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`state ${a.tone}`,"data-status":n,children:a.word}),t.queuePosition!==null?e.jsxs("span",{className:"muted","data-queue":t.queuePosition,children:[" #",t.queuePosition," in line"]}):null]})}function zd(t){if(!t.startedAt)return 0;const n=new Date(t.finishedAt??Date.now()).getTime(),a=(t.requests??[]).flatMap(c=>{if(c.status==="withdrawn")return[];const d=new Date(c.createdAt).getTime(),u=c.answeredAt??(c.status==="expired"?c.expiresAt:null);return[[d,Math.min(n,u?new Date(u).getTime():n)]]}).filter(([c,d])=>d>c).sort((c,d)=>c[0]-d[0]);let l=0,o=-1/0;for(const[c,d]of a)d<=o||(l+=d-Math.max(c,o),o=d);return Math.max(0,l)}function Hd(t){return t?"This drops this run's change; what you kept before stays, and your checkout stays as it is.":"This drops the agent's change; your checkout stays as it is."}const li=t=>t>=1e3?`${Math.round(t/1e3)}k`:`${t}`;function UE(t,n,a){const l=n&&n.window?Math.round(n.tokens/n.window*100):null,o=n?l!==null?`${l}% used`:`${li(n.tokens)} tokens`:null;if(!a&&o)return o;const c=t?`${li(t)} tokens at its start`:null,d=n?l!==null?`${l}% at its end`:`${li(n.tokens)} tokens at its end`:null;return d?[t?`${li(t)} at its start`:null,d].filter(Boolean).join(", "):c}function DE(t){const n=Math.max(1,Math.round(t/6e4));return n<60?`${n}m`:`${Math.floor(n/60)}h${n%60?` ${n%60}m`:""}`}function Gd(t){const n=Math.max(0,Math.round(t/1e3));return n<60?`${n}s`:`${Math.floor(n/60)}m${n%60?` ${n%60}s`:""}`}function Is(t){return t.startedAt?t.finishedAt&&t.ranMs!==void 0?Gd(t.ranMs):Gd(new Date(t.finishedAt??Date.now()).getTime()-new Date(t.startedAt).getTime()-zd(t)):"not started"}function Tg(t){const{usd:n,inputTokens:a,outputTokens:l}=t.cost;if(n===null&&a===null&&l===null)return"unknown";const o=[n!==null?`$${n.toFixed(4)}`:"cost unknown"];return(a!==null||l!==null)&&o.push(`${a??"?"} in / ${l??"?"} out tokens`),`${o.join(", ")}${t.costPartial?", some parts unreported":""}`}const BE={ready:{text:"Ready",tone:"ok"},warnings:{text:"Ready with warnings",tone:"warn"},"not-ready":{text:"Not ready",tone:"error"}};function qE({agent:t,details:n}){const a=t==null?void 0:t.readiness;if(!t)return null;if(!a)return e.jsxs("p",{className:"muted",role:"status","aria-label":`${t.label} readiness`,children:[e.jsx("span",{className:"state neutral",children:"Checking"})," whether ",t.label," can run here…"]});const l=a.state==="not-ready",{text:o,tone:c}=BE[a.state];return e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"muted",role:l?"alert":"note","aria-label":`${t.label} readiness`,children:[e.jsx("span",{className:`state ${c}`,children:o}),a.first?e.jsxs(e.Fragment,{children:[" ",da(a.first)]}):l?" A task started now fails.":null,n&&a.state!=="ready"?e.jsxs(e.Fragment,{children:[" ",e.jsx("a",{href:re("settings","agents"),children:"See details"})]}):l?e.jsxs(e.Fragment,{children:[" ",e.jsx(Ie,{label:`why ${t.label} is not ready`,children:"A task started now fails. An admin sees why on Agent readiness."})]}):null]}),a.fix?e.jsx(mt,{text:a.fix,label:"Copy the command"}):null]})}function WE({id:t,onStopped:n}){const[a,l]=h.useState(!1),[o,c]=h.useState(null),d=()=>{l(!0),c(null),ge.stopStep(t).then(n,u=>c(u.message)).finally(()=>l(!1))};return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"secondary",disabled:a,onClick:d,children:"Stop this step"}),o?e.jsx("span",{className:"error small",role:"alert",children:o}):null]})}function zE(t){var a;const n=(a=t==null?void 0:t.trim().split(`
|
|
92
|
+
`)[0])==null?void 0:a.trim().replace(/[.\s]+$/,"");return n?`: ${n}.`:"."}function oi(t){return`$${t.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`}function HE(t){const[n,a]=t.split("-").map(Number);return new Date(Date.UTC(n,a,1)).toLocaleDateString("en-US",{month:"long",day:"numeric",timeZone:"UTC"})}function GE(t){if(!t||t.lowUsd===null||t.highUsd===null)return null;const n=a=>`$${a.toFixed(2)}`;return`Tasks like this have cost ${n(t.lowUsd)} to ${n(t.highUsd)}.`}function KE(t){const n=t.find(l=>l.window==="seven_day"&&l.used!==null);if(!n)return null;const a=Math.max(0,Math.round((1-n.used)*100));return a<10?{text:`${a}% of this week's Claude limit is left; a task stops when it is reached.`,low:!0}:{text:`${a}% of this week's Claude limit is left.`,low:!1}}function Eg({budgets:t}){return t.budgets.length?e.jsx("ul",{className:"plain budgets","aria-label":"Task budgets",children:t.budgets.map(n=>e.jsxs("li",{children:[n.reached?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"badge error",children:"Budget reached"})," Tasks start again on ",HE(t.month),"."]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"badge ok",children:"Monthly budget left"})," ",oi(n.leftUsd)," of ",oi(n.monthlyUsd),n.per==="member"?" for you":", shared","."]})," ",e.jsxs(Ie,{label:`the budget ${n.policy}`,children:[n.reached?`${oi(n.spentUsd)} of ${oi(n.monthlyUsd)} spent this month${n.per==="member"?" by you":""} under ${n.policy}.`:`Under ${n.policy}.`,n.unknownCost?` ${n.unknownCost} ${n.unknownCost===1?"task":"tasks"} this month reported no cost and ${n.unknownCost===1?"is":"are"} not counted.`:""]})]},`${n.policyId??n.policy}:${n.per}`))}):null}function Bj(t){const[n="",...a]=t.trim().split(`
|
|
93
|
+
`),[l="",...o]=n.trim().split(/\s+/),c=/^https:\/\/\S+$/.test(l)||/^[A-Z][A-Z0-9_]+-\d+$/.test(l)||/^[\w.-]+(\/[\w.-]+)+#\d+$/.test(l)?l:"";return c?{issue:c,notes:[o.join(" "),...a].join(`
|
|
94
|
+
`).trim()}:{issue:"",notes:t.trim()}}const td=/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u180e\u200b-\u200f\u202a-\u202e\u2060-\u2064\u2066-\u2069\ufeff]/g,YE="orchestrator.task.log";function VE(t){return new Date(t).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hourCycle:"h23"})}function QE(t,n,a,l,o=null){var m,f,g;const c=[{term:a.mode==="local"?"Folder":"Repository",value:o??t.repoId}];a.mode!=="local"&&c.push({term:"Team",value:t.team});const d=[{term:"Agent",value:n||"The agent"},{term:"Started",value:`${l(t.createdAt)} by ${t.createdBy===a.email?"you":t.createdBy}`}];(t.tests==="passed"||t.tests==="failed")&&d.push({term:"Tests",value:t.tests}),t.startedAt&&t.finishedAt&&d.push({term:"Ran",value:Is(t)}),zd(t)>=6e4&&d.push({term:"Waited",value:`${DE(zd(t))} for you`}),t.cost.usd!==null?d.push({term:"Cost",value:`$${t.cost.usd.toFixed(t.cost.usd<.01?4:2)}${t.costPartial?", some parts unreported":""}`}):t.startedAt&&t.finishedAt&&t.cost.inputTokens===null&&t.cost.outputTokens===null&&d.push({term:"Cost",value:"Not reported"});const u=UE(((m=t.context)==null?void 0:m.tokens)??null,t.contextUsed??null,!!t.finishedAt);return u&&d.push({term:"Context",value:u}),!t.setup&&t.loaded&&Md(t.loaded)&&d.push({term:"Loaded",value:Md(t.loaded)}),((f=t.template)==null?void 0:f.kind)==="scaffold.refresh"?d.push({term:"Does",value:t.template.commitVersioning?"Refreshes the scaffold and switches to versioning by commit":"Refreshes the scaffold"}):t.template&&d.push({term:"Does",value:`${t.template.kind==="skill.write"?"Writes":"Improves"} the skill ${t.template.skill}`}),(g=t.skills)!=null&&g.length&&d.push({term:"Reads first",value:t.skills.join(", ")}),{where:c,run:d}}const JE=/[\u0000-\u0008\u000b-\u001f\u007f-\u009f\u00ad\u061c\u180e\u200b-\u200f\u202a-\u202e\u2060-\u2064\u2066-\u2069\ufeff]/g;function Rg(t){const n=new URLSearchParams(t);let a=!1;const l=(c,d)=>{const u=(c??"").trim(),m=u.replace(d,"").trim();return m!==u&&(a=!0),m};return{...{issue:l(n.get("issue"),td),repo:l(n.get("repo"),td),title:l(n.get("title"),td),description:l(n.get("description")??n.get("prompt"),JE)},stripped:a}}function XE(t,n){if(t&&(t.issue||t.title||t.description))return t.issue?{work:t.issue,title:t.title,notes:t.description}:{work:t.description,title:t.title,notes:""};try{const a=JSON.parse(n??"null"),l=o=>typeof(a==null?void 0:a[o])=="string"?a[o]:"";return{work:l("work"),title:l("title"),notes:l("notes")}}catch{return{work:"",title:"",notes:""}}}const ZE="orchestrator.task.draft";function qj(t,n,a,l){return(t.trim()||n||a||l.split(`
|
|
95
|
+
`,1)[0]||"").trim().slice(0,120)}function e1(t){const n=t.issueKey?`${t.reads?"Reads":"Works from"} ${t.issueKey}, `:"";if(t.routed)return`${n}changes your files; you review before keeping.`.replace(/^./,d=>d.toUpperCase());if(t.byOrchestrator)return`The orchestrator updates ${t.repos[0]??"the repository"} itself and a reviewer merges it; no agent runs.`;if(t.mode==="code"&&t.spread==="orchestrator")return`${n}picks the repositories; a reviewer merges each change.`;const a=t.repos.length>1?`${t.repos.slice(0,-1).join(", ")} and ${t.repos.at(-1)}${t.mode==="code"?" in that order":""}`:t.repos[0]??"the repository",l=t.forge?` on ${rt[t.forge].label}`:"",o=t.repos.length>1?"a reviewer merges each change.":`a reviewer merges it${l}.`,c=`${n}changes ${a}; ${o}`;return c.charAt(0).toUpperCase()+c.slice(1)}const t1=[{value:"any",label:"Any change"},{value:"skill.write",label:"Write a new skill"},{value:"skill.improve",label:"Improve a skill"},{value:"scaffold.refresh",label:"Refresh the TeamHandbook scaffold"},{value:"scaffold.switch",label:"Switch the plugin to versioning by commit"}];let nd=null;function n1(){return nd??(nd=ge.options().then(t=>new Map(t.agents.map(n=>[n.id,n.label])),()=>(nd=null,new Map))),nd}const kh="an agent no longer offered";function Wj(t){const[n,a]=h.useState(null);return h.useEffect(()=>{let l=!0;return n1().then(o=>l&&a(o)),()=>{l=!1}},[]),n===null?"":n.get(t)??kh}function s1({id:t,known:n}){var l;const a=Wj(t);return n?e.jsx(e.Fragment,{children:((l=n.find(o=>o.id===t))==null?void 0:l.label)??kh}):e.jsx(e.Fragment,{children:a})}function a1({options:t,budgets:n,limits:a=null,start:l,local:o,approver:c,defaultRepo:d=null,onStarted:u,onCancel:m,focus:f=!1,first:g=!1}){var qr,Xa,Wr,zr,Hr,Za,ba,_n,Un,Dn;const x=t.repos.filter(V=>V.kind==="code"),y=t.repos.filter(V=>V.kind!=="code"),b=x.some(V=>V.id===(l==null?void 0:l.repo)),N=y.some(V=>V.id===(l==null?void 0:l.repo)),v=!(l!=null&&l.repo)&&x.some(V=>V.id===d)?d:null,k=`${ZE}:${Ts(window.location.pathname).org??""}`,[S]=h.useState(()=>XE(l,Es(k))),$=!(l!=null&&l.issue)&&!(l!=null&&l.title)&&!(l!=null&&l.description)&&!!(S.work||S.title||S.notes),[E,C]=h.useState(S.work),[R,P]=h.useState(N||!o&&!x.length?"skills":"code"),[M,O]=h.useState(t.multiRepo&&!b&&!v?"orchestrator":"chosen"),[_,I]=h.useState(b?[l.repo]:v?[v]:x.length===1?[x[0].id]:[]),[L,K]=h.useState(N?l.repo:((qr=y[0])==null?void 0:qr.id)??""),[B,ne]=h.useState("any"),[Z,D]=h.useState(""),[te,Q]=h.useState(null),[ee,W]=h.useState(S.title),[A,H]=h.useState(S.notes),[X,de]=h.useState(((Xa=g?t.agents.find(V=>{var $e;return(($e=V.readiness)==null?void 0:$e.ready)!==!1}):void 0)==null?void 0:Xa.id)??((Wr=t.agents[0])==null?void 0:Wr.id)??""),[Se,Ne]=h.useState({}),[xe,ie]=h.useState(null),[me,Fe]=h.useState(null),[Ve,le]=h.useState(null),[pe,Be]=h.useState(!1),[We,St]=h.useState({}),[gt,Lt]=h.useState(null),[Zt,Qn]=h.useState(!1),[Oe,is]=h.useState(null),[Bt,cs]=h.useState([]),[yt,Ls]=h.useState(bT),Ct=h.useId(),tt=h.useId(),us=Bj(E),nt=us.issue,qt=!!(n!=null&&n.budgets.some(V=>V.reached)),ds=E!==S.work||ee!==S.title||A!==S.notes,An=!E.trim()&&!ee.trim()&&!A.trim();h.useEffect(()=>{ds&&Rs(k,An?null:JSON.stringify({work:E,title:ee,notes:A}))},[E,ee,A]),h.useEffect(()=>{if(!ds)return;const V=$e=>{$e.preventDefault(),$e.returnValue=""};return window.addEventListener("beforeunload",V),()=>window.removeEventListener("beforeunload",V)},[ds]),h.useEffect(()=>{if(ie(null),Fe(null),!nt)return;let V=!0;const $e=setTimeout(()=>{Gv.preview(nt).then(Ue=>V&&ie(Ue),Ue=>V&&Fe(Ue.message))},400);return()=>{V=!1,clearTimeout($e)}},[nt]),h.useEffect(()=>{R!=="skills"||B!=="skill.improve"||!L||(Q(null),Ce.inventory(L).then(({inventory:V})=>{const $e=V.skills.map(Ue=>Ue.slug);Q($e),D($e[0]??"")},()=>Q([])))},[R,B,L]);const st=R==="code"||B==="any"?null:B==="scaffold.refresh"||B==="scaffold.switch"?{kind:"scaffold.refresh",commitVersioning:B==="scaffold.switch"}:{kind:B,skill:Z.trim()},Wt=(st==null?void 0:st.kind)==="scaffold.refresh",hs=st?st.kind==="scaffold.refresh"?st.commitVersioning?"chore: switch the plugin to versioning by commit":"chore: refresh the team handbook scaffold":st.skill?`${st.kind==="skill.write"?"Write":"Improve"} the skill ${st.skill}`:null:null,Ft=o&&R==="code",gn=o&&!g,[en,xn]=h.useState([]);h.useEffect(()=>{!g||!o||Je.list().then(({last:V})=>V?fn.starters(V).then($e=>xn($e.starters.slice(0,3))):void 0,()=>xn([]))},[g,o]);const[In,jn]=h.useState([]);h.useEffect(()=>{o&&ge.page(null).then(V=>{var $e;return jn((($e=V.tasks[0])==null?void 0:$e.mcpNeedsSignIn)??[])},()=>jn([]))},[o]);const tn=!Ft&&R==="code"&&(M==="orchestrator"||_.length>1),nn=!Ft&&R==="code"&&t.multiRepo&&nt&&(M==="orchestrator"||_.length>1)?M==="orchestrator"?"orchestrator":_:void 0,lt=Ft?"":R==="skills"?L:M==="chosen"?_[0]??"":((zr=x[0])==null?void 0:zr.id)??"",Le=t.repos.find(V=>V.id===lt),[ga,ms]=h.useState(null);h.useEffect(()=>{if(ms(null),!lt||!X)return;let V=!0;return Wv.range(lt,X).then($e=>V&&ms($e),()=>{}),()=>{V=!1}},[lt,X]);const[sn,On]=h.useState(null),[Jn,Ln]=h.useState(""),[an,Fn]=h.useState(""),[Xn,ps]=h.useState(qa),[fs,Ga]=h.useState(!1),xa=Sj(),[Zn,yn]=h.useState("09:00");h.useEffect(()=>{if(On(null),Ln(""),!lt||M!=="chosen")return;let V=!0;return Bv.of(lt).then($e=>V&&On($e),()=>{}),()=>{V=!1}},[lt,M]);const[ja,ue]=h.useState([]);h.useEffect(()=>{if(ue([]),!X)return;let V=!0;return qv.windows(X).then($e=>V&&ue($e),()=>{}),()=>{V=!1}},[X]);const ze=KE(ja),Rt=[(Hr=GE(ga))==null?void 0:Hr.replace(/\.$/,""),ze&&!ze.low?ze.text.replace(/\.$/,""):null].filter(Boolean).join("; "),vn=Tj(R==="code"&&!tn&&(Le==null?void 0:Le.kind)==="code"?lt:null,"needed",c||!!(Le!=null&&Le.machine)),rn=(Le==null?void 0:Le.ticketExample)!=null&&!nt,pt=nt?[us.notes,A].filter(Boolean).join(`
|
|
96
|
+
|
|
97
|
+
`):us.notes,Ka=qj(ee,(xe==null?void 0:xe.title)??null,hs,pt),vt=!E.trim()&&!hs,_e=vt?null:tn&&!nt?"Paste an issue link to let the agent pick the repositories or to change several.":!Ft&&R==="code"&&M==="chosen"&&!_.length?"Pick a repository.":rn?`${Le.name} names branches after a ticket (its example is ${Le.ticketExample}); paste its issue link.`:st&&st.kind!=="scaffold.refresh"&&!st.skill?"Name the skill.":!Ka&&!nt?"Describe the work.":null,Fs=Ve?{"aria-invalid":!0,"aria-describedby":Ct}:{},Mn=(R==="skills"?[L]:_).map(V=>{var $e;return(($e=t.repos.find(Ue=>Ue.id===V))==null?void 0:$e.name)??V}),Ms=e1({issueKey:(xe==null?void 0:xe.key)??(nt&&!nt.startsWith("https://")?nt:null),reads:!!(xe!=null&&xe.title),mode:R,spread:R==="code"&&t.multiRepo?M:"chosen",repos:Mn,byOrchestrator:Wt,routed:Ft,forge:(Le==null?void 0:Le.forge)??null}),[gs,Wi]=h.useState(!1),[Ya,_s]=h.useState([]),[Mt,zl]=h.useState(null),[zt,Ur]=h.useState(null),[zi,Hl]=h.useState(!1),[Us,Va]=h.useState(""),[Ds,ya]=h.useState(null);h.useEffect(()=>{o&&Je.list().then(V=>ya(V.home??null),()=>ya(null))},[o]),h.useEffect(()=>{zl(null),Ur(null),Hl(!1)},[E]);const Gl=Wt||g?null:e.jsx(Pe,{label:"Agent",value:X,onChange:V=>{de(V),Ne({})},describedBy:Ve?Ct:void 0,invalid:!!Ve,options:t.agents.map(V=>({value:V.id,label:V.label,hint:V.readiness&&!V.readiness.ready?"not ready":void 0}))}),Hi=V=>{V.preventDefault(),Ja()},Qa=V=>{le(null),Dt.signInService(V).then($e=>window.location.assign($e),$e=>le($e.message))},[va,Dr]=h.useState(null),ka=V=>V.repeat?ge.startRepeating(V).then($e=>(Dr($e),Fn(""),window.dispatchEvent(new Event(Dd)),null)):ge.start(V),Ja=(V,$e=!1)=>{_e||(Be(!0),le(null),vn.consent().then(()=>Ya.length?Cj(Ya,Ue=>bi.uploadFree(Ue),_s):Promise.resolve([])).then(Ue=>{var Bs;return ka({...fs?{off:Xn}:{},...an&&Zn?{repeat:{every:an,at:Zn}}:{},...Ue.length?{attachments:Ue}:{},...Jn?{baseBranch:Jn}:{},title:Ka,description:pt,issueUrl:nt,...lt?{repoId:lt}:{},...V?{path:V}:{},...zi||$e?{withoutIssueText:!0}:{},...gs&&((Bs=t.agents.find(Yl=>Yl.id===X))!=null&&Bs.plan)?{planFirst:!0}:{},agent:X,template:st,...nn?{targets:nn}:{},...Bt.length?{skills:Bt}:{},...$r(Se)?{choices:$r(Se)}:{},...yt.projectSkills.length?{projectSkills:yt.projectSkills}:{},mcpServers:yt.mcpServers,...!o&&yt.commands.length?{mcpConfirmed:yt.commands}:{}})}).then(Ue=>{Rs(k,null),_s([]),C(""),W(""),H(""),Ue&&u(Ue)},Ue=>{if(Ue instanceof ht&&Ue.code==="issue-unread"){Ur(Ue.message);return}if(Ue instanceof ht&&Ue.code==="pick-folder"){Je.workFolders().then(Bs=>Bs.folders,()=>[]).then(Bs=>zl({question:Ue.message,folders:Bs}));return}le(Ue.message),St(Ue instanceof ht?{code:Ue.code,status:Ue.status}:{})}).finally(()=>Be(!1)))};h.useEffect(()=>{Lt(null),is(null),cs([])},[lt,R,M,_.join(",")]);const Br=()=>{Qn(!0),is(null),ge.suggestSkills({agent:X,repoId:lt,...nt?{issueUrl:nt}:{description:us.notes||E},...nn?{targets:nn}:{}}).then(V=>{Lt(V),cs(V.suggestions.map($e=>$e.skill).slice(0,ki))},V=>is(V.message)).finally(()=>Qn(!1))},Ye=V=>I(_.includes(V)?_.filter($e=>$e!==V):[..._,V]),Kl=((Za=t.multiRepo)==null?void 0:Za.maxTargets)??1;return!t.repos.length&&!o?e.jsx("p",{className:"muted",role:"note",children:"You cannot start tasks: starting one takes the admin role or ownership of the team whose project it changes."}):e.jsxs("div",{className:"with-rail new-task",style:xa.style,children:[xa.handle,e.jsxs("form",{className:"task-form",onSubmit:Hi,"aria-label":"New task",children:[t.profile.personal?e.jsx("p",{className:t.profile.refused?"error":"muted",role:"note",children:t.profile.refused?`Tasks do not run: ${t.profile.refused}.`:t.profile.note}):null,l!=null&&l.stripped?e.jsx("p",{className:"muted",role:"note",children:"The link carried hidden characters; they were taken out."}):null,l!=null&&l.repo&&!b&&!N?e.jsx("p",{className:"muted",role:"note",children:"The link names a repository you do not start tasks in here; pick one below."}):null,$&&!An?e.jsxs("p",{className:"muted small",role:"note",children:["The words you had not started are back."," ",e.jsx("button",{type:"button",className:"link",onClick:()=>{C(""),W(""),H("")},children:"Clear them"})]}):null,e.jsx("label",{htmlFor:tt,className:"work-label",children:"What needs doing?"}),e.jsx("textarea",{id:tt,className:g?"work":"work compact",value:E,onChange:V=>C(V.target.value),rows:g?3:2,maxLength:8500,placeholder:"https://… or what needs to change",autoFocus:f,...Fs}),e.jsx(Fd,{files:Ya,onChange:_s,disabled:pe,onRetry:()=>{var V;return(V=document.querySelector("form.task-form"))==null?void 0:V.requestSubmit()}}),(ba=t.agents.find(V=>V.id===X))!=null&&ba.plan?e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:gs,onChange:V=>Wi(V.target.checked)}),"Show me the plan before it changes anything"]}):null,g&&en.length&&!E.trim()?e.jsxs("div",{className:"starters",children:[e.jsx("p",{className:"muted small",id:`${tt}-starters`,children:"Or start with"}),e.jsx("ul",{className:"plain starter-list","aria-labelledby":`${tt}-starters`,children:en.map(V=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"ghost",onClick:()=>C(`${V.title}
|
|
98
|
+
|
|
99
|
+
${V.description}`),children:[e.jsx("span",{dir:"auto",children:V.title})," ",e.jsx("span",{className:"mono muted small",dir:"auto",children:V.where})]})},`${V.kind}:${V.where}:${V.title}`))})]}):null,o?e.jsx(Fj,{names:In,onePerson:!0}):null,nt?e.jsx("div",{className:"issue-card",role:"status","aria-label":"Issue",children:me?e.jsx("p",{className:"error",children:me}):xe?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:[e.jsx("a",{href:xe.url,target:"_blank",rel:"noopener noreferrer",className:"mono",children:xe.key??xe.url}),xe.title?e.jsxs(e.Fragment,{children:[" ",e.jsx("strong",{children:xe.title})]}):null,xe.status?e.jsx("span",{className:"badge neutral",children:xe.status}):null]}),e.jsx("p",{className:"muted",children:xe.reach}),xe.connect?e.jsxs("p",{children:[e.jsxs("button",{type:"button",className:"secondary small",onClick:()=>Qa(xe.connect.id),children:["Sign in with ",xe.connect.name]})," ",e.jsxs("span",{className:"muted small",children:["to let the agent read ",xe.key??"it"]})]}):null]}):e.jsx("p",{className:"muted",children:"Reading the issue…"})}):null,!g&&!gn&&(x.length||o)&&y.length?e.jsxs("div",{className:"segmented wide",role:"group","aria-label":"What changes",children:[e.jsx("button",{type:"button",className:"secondary","aria-pressed":R==="code",onClick:()=>P("code"),children:"Code"}),e.jsx("button",{type:"button",className:"secondary","aria-pressed":R==="skills",onClick:()=>P("skills"),children:o?"Skills":"Team skills"})]}):null,e.jsxs("div",{className:"row task-where",children:[R==="code"?!Ft&&x.length>1?e.jsxs("fieldset",{className:"plain-fieldset repos-pick",children:[e.jsxs("legend",{children:["Repositories ",e.jsx(Ie,{label:"repositories",children:"Each repository runs in turn with its own checkout, tests and request; the first one that fails stops the rest."})]}),t.multiRepo?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"radio",name:"spread",checked:M==="orchestrator",onChange:()=>O("orchestrator")}),"Let the agent decide (recommended)"]}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"radio",name:"spread",checked:M==="chosen",onChange:()=>O("chosen")}),"Pick repositories"]})]}):null,M==="chosen"?e.jsx("div",{className:"chips",role:"group","aria-label":"Repositories, in the order they run",children:x.map(V=>{const $e=_.indexOf(V.id);return e.jsxs("label",{className:`chip-pick${$e>=0?" on":""}`,children:[e.jsx("input",{type:"checkbox",checked:$e>=0,disabled:$e<0&&_.length>=Kl,onChange:()=>Ye(V.id)}),$e>=0?e.jsx("span",{className:"order","aria-hidden":"true",children:$e+1}):null,e.jsxs("span",{children:[V.name,V.machine?e.jsxs("span",{className:"muted",children:[" on ",V.machine]}):null]})]},V.id)})}):null]}):null:e.jsxs("div",{className:"row",children:[y.length>1?e.jsx(Pe,{label:"Repository",value:L,onChange:K,options:y.map(V=>({value:V.id,label:V.name,hint:V.team})),describedBy:Ve?Ct:void 0,invalid:!!Ve}):null,B==="skill.write"?e.jsxs("label",{children:["Skill name",e.jsx("input",{value:Z,onChange:V=>D(V.target.value),maxLength:63,pattern:"[a-z0-9][a-z0-9-]*",placeholder:"on-call-handover",required:!0})]}):null,B==="skill.improve"?e.jsx(Pe,{label:"Skill",value:Z,onChange:D,disabled:!(te!=null&&te.length),placeholder:te===null?"Loading the repository's skills…":"This repository has no skill yet",options:(te??[]).map(V=>({value:V,label:V}))}):null]}),gn?null:Gl]}),e.jsxs("div",{className:"agent-lines",children:[Wt?null:e.jsx(qE,{agent:t.agents.find(V=>V.id===X),details:t.readinessReport}),Wt||(Le==null?void 0:Le.ownSetup)===!1?null:e.jsx(e.Fragment,{children:fs?null:e.jsx(CT,{label:((_n=t.agents.find(V=>V.id===X))==null?void 0:_n.label)??"",personal:(Un=t.agents.find(V=>V.id===X))==null?void 0:Un.personal})}),Wt||!o||!X?null:e.jsx(L$,{agentId:X})]}),!st&&E.trim()&<&&X?e.jsxs("div",{className:"suggest-skills",children:[gt?e.jsx(Ij,{label:"Skills to use first",read:gt,value:Bt,onChange:cs,local:o}):e.jsxs("p",{children:[e.jsx("button",{type:"button",className:"secondary small",disabled:Zt,onClick:Br,children:Zt?"Asking the agent…":"Suggest skills"})," ",e.jsxs(Ie,{label:"suggested skills",children:["The agent reads the work and names the ",o?"":"team ","skills to use first; it still has every one."]})]}),Oe?e.jsxs("p",{className:"muted small",role:"status",children:["No suggestion: ",Oe]}):null]}):null,g?null:e.jsxs("details",{className:"more",children:[e.jsx("summary",{children:"More options"}),e.jsxs("div",{className:"task-form",children:[gn?Gl:null,sn&&sn.branches.length>1?e.jsx(Pe,{label:"Start from branch",value:Jn||sn.default||"",onChange:V=>Ln(V===sn.default?"":V),options:sn.branches.map(V=>({value:V,label:V,...V===sn.default?{hint:"default"}:{}}))}):null,o?e.jsx(Pe,{label:"Repeat",value:an,onChange:V=>Fn(V),options:[{value:"",label:"Once"},{value:"day",label:"Every day"},{value:"weekday",label:"Every weekday"},...oE.map(V=>({value:V,label:`Every ${V.charAt(0).toUpperCase()}${V.slice(1)}`}))]}):null,an?e.jsxs("label",{children:["Time of day",e.jsx("input",{type:"time",value:Zn,onChange:V=>yn(V.target.value),required:!0})]}):null,R==="skills"?e.jsx(Pe,{label:"Kind of task",value:B,onChange:V=>{ne(V),D("")},options:t1}):null,e.jsxs("label",{children:["Title",e.jsx("input",{value:ee,onChange:V=>W(V.target.value),maxLength:120,placeholder:Ka||"From the issue",...Fs})]}),nt?e.jsxs("label",{children:["Notes for the agent",e.jsx("textarea",{className:"short",value:A,onChange:V=>H(V.target.value),rows:3,maxLength:8e3})]}):null,Wt?null:e.jsx(wj,{options:(Dn=t.agents.find(V=>V.id===X))==null?void 0:Dn.options,value:Se,onChange:Ne}),lt&&!nn?e.jsx($T,{repoId:lt,value:yt,onChange:Ls,canAdd:o},lt):null]})]}),zt?e.jsxs("div",{className:"issue-unread",role:"group","aria-label":"The issue is not read",children:[e.jsx("p",{dir:"auto",children:zt}),e.jsxs("div",{className:"actions",children:[xe!=null&&xe.connect?e.jsxs("button",{type:"button",className:"secondary small",onClick:()=>Qa(xe.connect.id),children:["Sign in with ",xe.connect.name]}):e.jsx("a",{className:"button secondary small",href:re("integrations"),children:"Connect"}),e.jsx("button",{type:"button",className:"secondary small",disabled:pe,onClick:()=>{Hl(!0),Ur(null),Ja(void 0,!0)},children:"Start on the link alone"})]})]}):null,Mt?e.jsxs("div",{className:"pick-folder",role:"group","aria-label":"Which folder",children:[e.jsx("p",{dir:"auto",children:Mt.question}),Mt.folders.length?e.jsx("ul",{className:"plain",children:Mt.folders.map(V=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"ghost",disabled:pe,onClick:()=>Ja(V.path),children:[e.jsx("span",{dir:"auto",children:V.name})," ",e.jsx("span",{className:"mono muted",dir:"auto",children:Kn(V.path,Ds)})]})},V.path))}):null,e.jsxs("label",{children:["A folder's path",e.jsx("input",{type:"text",value:Us,onChange:V=>Va(V.target.value),placeholder:"~/code",dir:"auto",onKeyDown:V=>{V.key!=="Enter"||!Us.trim()||(V.preventDefault(),Ja(oa(Us,Ds)))}})]})]}):null,vn.view,e.jsxs("div",{className:"actions start",children:[va?e.jsxs("p",{className:"muted",role:"status",children:["It repeats ",pi(va.every,va.at),"; the first run is ",Bd(va.next),". It is listed under Repeats."]}):null,e.jsx("button",{type:"submit",disabled:pe||qt||vt||!!_e,children:"Start task"}),m?e.jsx("button",{type:"button",className:"secondary",onClick:m,disabled:pe,children:"Cancel"}):null,e.jsx("span",{className:"muted","aria-live":"polite",children:_e??Ms})]}),ze!=null&&ze.low?e.jsx("p",{className:"warn-note small",children:ze.text}):Rt?e.jsxs("p",{className:"muted small",children:[Rt,"."]}):null,Ve?e.jsxs("p",{className:"error",role:"alert",id:Ct,children:[Ve,e.jsx(vh,{...We})]}):null]}),Wt||(Le==null?void 0:Le.ownSetup)===!1?null:e.jsx(fE,{off:Xn,onOff:ps,onRead:Ga}),g?e.jsxs("aside",{className:"rail","aria-label":"Before it starts",children:[e.jsxs("section",{"aria-labelledby":`${tt}-where`,children:[e.jsx("h2",{id:`${tt}-where`,children:"Where it works"}),e.jsx("p",{dir:"auto",children:Ft?"The folder the orchestrator picks from what you ask; the run's first line says which, and Change moves it.":nn==="orchestrator"?"The repositories the orchestrator picks from the issue":tn?_.map(V=>{var $e;return(($e=t.repos.find(Ue=>Ue.id===V))==null?void 0:$e.name)??V}).join(", "):Le?`${Le.name}${Le.machine?`, on ${Le.machine}`:o?"":`, ${Le.team}`}`:"No repository picked yet"}),Le!=null&&Le.result&&!tn?e.jsx("p",{className:"muted",children:Le.result==="changes"?"The agent edits its files in place; Undo puts every file back.":"Nothing lands until a reviewer merges the change."}):null]}),an?e.jsxs("section",{"aria-labelledby":`${tt}-repeat`,children:[e.jsx("h2",{id:`${tt}-repeat`,children:"Repeats"}),e.jsxs("p",{children:["Runs ",pi(an,Zn)," on this machine, under the same limits; a run this machine is off for is skipped and said."]})]}):null,n!=null&&n.budgets.length||a?e.jsxs("section",{"aria-labelledby":`${tt}-limits`,children:[e.jsx("h2",{id:`${tt}-limits`,children:"Limits"}),a?e.jsxs("p",{children:[Zf(a)," ",e.jsx("a",{href:re("settings","task-limits"),children:"Change"})]}):null,n!=null&&n.budgets.length?e.jsx(Eg,{budgets:n}):null]}):null]}):e.jsxs("details",{className:"rail-fold",open:!window.matchMedia("(max-width: 1023px)").matches,children:[e.jsx("summary",{children:"Where it works and what limits it"}),e.jsxs("aside",{className:"rail","aria-label":"Before it starts",children:[e.jsxs("section",{"aria-labelledby":`${tt}-where`,children:[e.jsx("h2",{id:`${tt}-where`,children:"Where it works"}),e.jsx("p",{dir:"auto",children:Ft?"The folder the orchestrator picks from what you ask; the run's first line says which, and Change moves it.":nn==="orchestrator"?"The repositories the orchestrator picks from the issue":tn?_.map(V=>{var $e;return(($e=t.repos.find(Ue=>Ue.id===V))==null?void 0:$e.name)??V}).join(", "):Le?`${Le.name}${Le.machine?`, on ${Le.machine}`:o?"":`, ${Le.team}`}`:"No repository picked yet"}),Le!=null&&Le.result&&!tn?e.jsx("p",{className:"muted",children:Le.result==="changes"?"The agent edits its files in place; Undo puts every file back.":"Nothing lands until a reviewer merges the change."}):null]}),an?e.jsxs("section",{"aria-labelledby":`${tt}-repeat`,children:[e.jsx("h2",{id:`${tt}-repeat`,children:"Repeats"}),e.jsxs("p",{children:["Runs ",pi(an,Zn)," on this machine, under the same limits; a run this machine is off for is skipped and said."]})]}):null,n!=null&&n.budgets.length||a?e.jsxs("section",{"aria-labelledby":`${tt}-limits`,children:[e.jsx("h2",{id:`${tt}-limits`,children:"Limits"}),a?e.jsxs("p",{children:[Zf(a)," ",e.jsx("a",{href:re("settings","task-limits"),children:"Change"})]}):null,n!=null&&n.budgets.length?e.jsx(Eg,{budgets:n}):null]}):null]})]})]})}const sd={planned:{text:"waiting its turn",tone:"neutral"},working:{text:"working",tone:"warn"},tests:{text:"running tests",tone:"warn"},request:{text:"in review",tone:"ok"},failed:{text:"failed",tone:"error"},skipped:{text:"skipped",tone:"neutral"},local:{text:"kept on this machine",tone:"neutral"}},r1=t=>{var n;return!!((n=t.targets)!=null&&n.length)&&t.targets.every(a=>a.repoId===t.repoId||a.repoId.startsWith(`${t.repoId}--`))};function l1({task:t,local:n,starter:a,onChanged:l,onQuote:o}){const c=(t.targets??[]).filter(u=>u.status==="request"||u.status==="failed"||u.status==="local"),d=c.filter(u=>{var m;return((m=u.request)==null?void 0:m.status)==="open"}).length;return e.jsxs("section",{className:"section","aria-labelledby":"task-folder-h",children:[e.jsx("h2",{id:"task-folder-h",children:"Changes"}),c.map(u=>e.jsxs("section",{className:"repo-group","aria-label":Ai(u),children:[e.jsx("h3",{className:"mono",children:Ai(u)}),u.request?e.jsxs(e.Fragment,{children:[n?null:e.jsxs("p",{className:"muted",children:["Its work reaches ",u.name," only through a review, which a person merges."]}),n?null:e.jsx("p",{children:Dj(u.forge,u.request.number,u.request.status)}),a&&u.forge&&u.request.url.startsWith("http")?e.jsx(vj,{load:()=>ge.targetOnForge(t.id,t.targets.indexOf(u))}):null,n&&u.request.status==="open"&&!dn.includes(t.status)?e.jsx(o1,{repoId:u.repoId,number:u.request.number,starter:a,only:d===1,keptBefore:t.keptBefore===!0,onAnswered:l}):null,e.jsx(Fr,{reads:Ui(u.repoId,u.request.number),bare:!0,...o?{onQuote:o}:{}})]}):u.status==="local"&&u.branch?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"muted",children:c1(u.reason,u.branch,t.ranOn??null)}),(u.reason==="unpushed"||u.reason==="not-connected")&&u.forge&&a?e.jsx(i1,{taskId:t.id,position:t.targets.indexOf(u),forge:u.forge,onOpened:l}):e.jsx(mt,{text:`git switch ${u.branch}`,label:"Copy the command"})]}):null,u.error?e.jsx("p",{className:"error",children:u.error}):null]},`${u.repoId}:${u.path??""}`))]})}function o1({repoId:t,number:n,starter:a,only:l,keptBefore:o=!1,onAnswered:c}){const d=bj(t,n),[u,m]=h.useState(!1),[f,g]=h.useState(null),x=N=>Ce.requestAction(t,n,N).then(c),y=()=>{m(!0),g(null),x("merge").catch(N=>g(N.message)).finally(()=>m(!1))},b=f?Tl(f):null;return e.jsxs(e.Fragment,{children:[d.line,a||d.action?e.jsxs("div",{className:"actions",children:[a?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:l?void 0:"secondary",disabled:u,onClick:y,children:"Keep these changes"}),e.jsx(qe,{trigger:"Discard these changes…",consequence:Hd(o),confirm:"Discard changes",keep:"Keep them for now",onConfirm:()=>x("close")})]}):null,d.action]}):null,f?e.jsx("p",{className:"error",role:"alert",children:b?e.jsxs(e.Fragment,{children:[b.said,": ",e.jsx(mt,{text:b.command})]}):f}):null,d.refusal]})}function i1({taskId:t,position:n,forge:a,onOpened:l}){const[o,c]=h.useState(!1),[d,u]=h.useState(null),m=kj[a].noun,f=()=>{c(!0),u(null),ge.openKept(t,n).then(l,g=>u(g.message)).finally(()=>c(!1))};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"actions",children:e.jsx("button",{type:"button",className:"secondary",disabled:o,onClick:f,children:o?`Opening a ${m}…`:`Open a ${m}`})}),d?e.jsx("p",{className:"error",role:"alert",children:d}):null]})}const Ai=t=>t.status==="local"&&t.path?t.path:t.name;function c1(t,n,a){const l=`on the branch ${n} in this repository${a?` on ${a}`:""}`;return t==="no-remote"?`With no remote to push to, its change stays ${l}.`:t==="not-connected"?`Its remote is not one of this organization's connected repositories, so its change stays ${l}.`:`Nothing is pushed to its remote yet, so its change stays ${l}.`}function u1({task:t}){const n=t.targets??[];return e.jsxs("section",{className:"section","aria-labelledby":"task-targets-h",children:[e.jsxs("h2",{id:"task-targets-h",children:["Repositories ",e.jsx("span",{className:"count",children:n.length||""})]}),n.length?e.jsx("ol",{className:"target-cards",children:n.map((a,l)=>e.jsxs("li",{className:"target-card","aria-label":`${a.name}, ${sd[a.status].text}`,children:[e.jsxs("div",{className:"card-head",children:[e.jsxs("h3",{children:[e.jsxs("span",{className:"muted",children:[l+1,"."]})," ",e.jsx("a",{href:re("repositories",a.repoId),children:a.name})]}),e.jsx("span",{className:`badge ${sd[a.status].tone}`,children:sd[a.status].text})]}),e.jsx("p",{className:"muted",children:a.reason}),e.jsxs("dl",{className:"facts",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Tests"}),e.jsx("dd",{children:a.tests??(dn.includes(t.status)?"not run yet":"none ran")})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Change"}),e.jsx("dd",{children:a.request?a.request.url.startsWith("http")?e.jsxs(e.Fragment,{children:[e.jsx("a",{href:a.request.url,target:"_blank",rel:"noopener noreferrer",children:a.forge?Xd(a.forge,a.request.number):"See it on the forge"}),e.jsxs("span",{className:"muted",children:[", ",Pg[a.request.status]]})]}):Pg[a.request.status]:"none yet"})]})]}),a.error?e.jsx("p",{className:"error",children:a.error}):null]},a.repoId))}):e.jsx("p",{className:"muted",role:"status",children:dn.includes(t.status)?"Planning which repositories the change needs…":"No repository was planned."})]})}const Pg={open:"in review",merged:"merged",closed:"closed"};function d1(t){return t.targets?t.targets.length?t.targets.map(n=>n.name).join(", "):"planning…":t.repoId}const Ag=[{id:"yours",name:"Your turn",why:"Each one waits for you to read, answer or continue it.",empty:"Nothing waits on you. A task lands here when its change is ready or its agent asks you something."},{id:"agents",name:"The agents' turn",why:"Running or in line; nothing to do yet.",empty:"No agent is at work. A task you start runs here until it needs you."},{id:"done",name:"Done this week",why:"Kept, undone or failed. A failed task says why on its page.",empty:"Nothing has finished this week."},{id:"waiting",name:"Waiting for a computer",why:"Each starts by itself when its computer is back.",empty:"No task waits for a computer. A task started while its computer sleeps lands here."}];function h1(t){const n=t.findIndex(l=>l.key==="done"),a=e.jsx(_j,{},"repeats");return n<0?[...t,a]:[...t.slice(0,n),a,...t.slice(n)]}function m1({cards:t,me:n,agents:a}){const l=nh();return e.jsx("table",{className:"row-cards turn-rows",children:e.jsx("tbody",{children:t.map(o=>{var f;const c=y$(o),d=k$(o,l),u=a&&o.agent?((f=a.find(g=>g.id===o.agent))==null?void 0:f.label)??kh:null,m=[o.repoId,u,`started by ${o.createdBy===n.email?"you":o.createdBy}`].filter(Boolean).join(", ");return e.jsxs("tr",{onClick:()=>Ge(re("tasks",o.id)),children:[e.jsx("td",{className:"rc-status",children:e.jsx("span",{className:`state ${c.tone}`,children:c.label})}),e.jsxs("td",{className:"rc-title",children:[e.jsx("a",{className:"row-link",href:re("tasks",o.id),dir:"auto",children:d?e.jsx("strong",{children:o.title}):o.title}),d?e.jsx("span",{className:"visually-hidden",children:" (new)"}):null,o.issueKey?e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{className:"muted mono",children:o.issueKey})]}):null,o.reason&&(o.next==="retry"||o.next==="continue")?e.jsxs("div",{className:"small",dir:"auto",children:[e.jsx("span",{className:"error",children:o.reason})," ",e.jsx("a",{href:re("tasks",o.id),children:o.next==="retry"?"Run again":"Continue"})]}):null,o.waitingBehind?e.jsxs("div",{className:"small",dir:"auto",children:["Starts once you answer ",e.jsx("a",{href:re("tasks",o.waitingBehind.id),children:o.waitingBehind.title}),", which works in the same folder."]}):null,e.jsx("div",{className:"muted small",dir:"auto",children:m})]}),e.jsx("td",{className:"rc-extra rc-weight",children:o.changes?e.jsxs(e.Fragment,{children:[e.jsx(Di,{added:o.changes.additions,removed:o.changes.deletions})," ",e.jsx("span",{className:"diff-stat",children:e.jsx(mh,{added:o.changes.additions,removed:o.changes.deletions})})]}):null}),e.jsx("td",{className:"rc-extra num",children:o.startedAt?o.finishedAt?o.ranMs!==void 0?Is(o):"—":`${o.ranMs!==void 0?Gd(o.ranMs):Is(o)} so far`:null}),e.jsx("td",{className:"rc-extra num",children:o.cost.usd!==null?`$${o.cost.usd.toFixed(2)}`:null}),e.jsx("td",{className:"rc-extra num",children:Wl(o.finishedAt??o.createdAt)})]},o.id)})})})}function p1({me:t,agents:n,picked:a=null}){const[l,o]=h.useState(!1),[c,d]=h.useState(null),[u,m]=h.useState(null),[f,g]=h.useState(null),[x,y]=h.useState(!1),b=S=>{y(!0),ge.page(S).then($=>{d(E=>S&&E?[...E,...$.tasks.filter(C=>!E.some(R=>R.id===C.id))]:$.tasks),m($.next),g(null)},$=>g($.message)).finally(()=>y(!1))};h.useEffect(()=>{l&&!c&&b(null)},[l]);const N=S=>!a||S.repoId===a||Array.isArray(S.targets)&&S.targets.some($=>$.repoId===a),v=(c?Sk(c.filter(N),t.email,nh(),"all"):[]).map(S=>({...S,wait:Lj(S.task,t)})),k=v.some(({task:S})=>S.cost.usd!==null||S.cost.inputTokens!==null||S.cost.outputTokens!==null);return e.jsxs("details",{className:"section log-fold",onToggle:S=>o(S.currentTarget.open),children:[e.jsxs("summary",{children:["All tasks ",c?e.jsx("span",{className:"count",children:`${c.length}${u?"+":""}`}):null]}),f?e.jsx(be,{what:"tasks",reason:f,onRetry:()=>b(null)}):c?v.length?e.jsxs("table",{className:"row-cards",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Task"}),e.jsx("th",{children:"Project"}),e.jsx("th",{children:"Agent"}),e.jsx("th",{children:"Status"}),e.jsx("th",{className:"num",children:"Duration"}),k?e.jsx("th",{className:"num",children:"Cost"}):null]})}),e.jsx("tbody",{children:v.map(({task:S,call:$,unread:E,wait:C})=>{var R;return e.jsxs("tr",{onClick:()=>Ge(re("tasks",S.id)),children:[e.jsxs("td",{className:"rc-title",children:[e.jsx("a",{className:"row-link",href:re("tasks",S.id),dir:"auto",children:E?e.jsx("strong",{children:S.title}):S.title}),E?e.jsx("span",{className:"visually-hidden",children:" (new)"}):null,(R=S.sharedWith)!=null&&R.includes(t.id)&&S.createdBy!==t.email?e.jsx("span",{className:"muted small",children:" shared with you"}):null,S.issueKey?e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{className:"muted mono",children:S.issueKey})]}):null]}),e.jsx("td",{className:"mono rc-meta",children:d1(S)}),e.jsx("td",{className:"rc-meta",children:e.jsx(s1,{id:S.agent,known:n})}),e.jsx("td",{className:"rc-status",children:$?e.jsx("span",{className:`state ${dd[$].tone}`,children:dd[$].label}):C?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"state warn",children:C.badge})," ",e.jsx("a",{href:re("settings","machines"),onClick:P=>P.stopPropagation(),children:C.link})]}):e.jsx(_E,{task:S})}),e.jsx("td",{className:"rc-extra num",children:S.startedAt?S.finishedAt&&S.ranMs===void 0?"—":Is(S):null}),k?e.jsx("td",{className:"rc-extra num",children:Tg(S)==="unknown"?null:Tg(S)}):null]},S.id)})})]}):e.jsx("p",{className:"muted",children:"No task has run yet."}):l?e.jsx(he,{what:"tasks"}):null,u?e.jsx("button",{type:"button",className:"secondary",onClick:()=>b(u),disabled:x,children:x?"Loading older tasks…":"Show older tasks"}):null]})}const f1=t=>`${t.charAt(0).toLowerCase()}${t.slice(1)}`;function ad({me:t,start:n,repos:a=null,picked:l=null,onRepos:o}){var xe;const[c,d]=h.useState(null),[u,m]=h.useState(null),[f,g]=h.useState(null),[x,y]=h.useState(null),[b,N]=h.useState(null),v=()=>ge.budgets().then(N,()=>N(null)).finally(()=>E(ie=>ie+1)),[k,S]=h.useState(null),[$,E]=h.useState(0),[C,R]=h.useState(null),[P,M]=h.useState(null),O=new URLSearchParams(window.location.search).get("removed"),[_,I]=h.useState(O?`${O} is removed.`:null);h.useEffect(()=>{O&&(o==null||o())},[O]),h.useEffect(()=>{Je.list().then(ie=>R(ie.last),()=>R(null))},[]);const L=()=>j$.read(l).then(ie=>{m(ie),g(null)},ie=>g(ie.message)),K=()=>ge.options().then(ie=>{d(ie),y(null)},ie=>y(ie.message));h.useEffect(()=>{K(),v(),yi.read().then(S,()=>S(null)).finally(()=>E(ie=>ie+1))},[]);const B=(a==null?void 0:a.map(ie=>ie.id).join(","))??null,ne=h.useRef(B);h.useEffect(()=>{ne.current!==null&&ne.current!==B&&K(),ne.current=B},[B]),h.useEffect(()=>{L()},[l]),h.useEffect(()=>{if(!(c!=null&&c.agents.some(me=>!me.readiness)))return;const ie=setTimeout(K,2e3);return()=>clearTimeout(ie)},[c]),h.useEffect(()=>{if(!u||!u.counts.agents&&!u.counts.waiting)return;const ie=setInterval(()=>{document.hidden||L()},1500),me=()=>{document.hidden||L()};return document.addEventListener("visibilitychange",me),()=>{clearInterval(ie),document.removeEventListener("visibilitychange",me)}},[u]);const Z=!!(u&&(c&&$>=2||x)),D=!!(u&&Ag.every(ie=>!u.counts[ie.id])),te=Ag.filter(ie=>ie.id!=="waiting"||t.tasksRunHere===!1),Q=a??[],ee=l?((xe=Q.find(ie=>ie.id===l))==null?void 0:xe.name)??l:null,W=u?b$(u):null,A=ee?`In ${ee}, ${W?f1(W):"nothing waits on you and no agent is at work."}`:W,H=t.mode==="local",X=Q.filter(ie=>ie.configured!==!1),de=e.jsxs(e.Fragment,{children:[_?e.jsx("p",{className:"notice",role:"status",children:_}):null,!H&&a!==null&&!Q.some(ie=>ie.configured!==!1)?e.jsxs("div",{className:"empty-state",children:[e.jsx("p",{className:"empty-state-title",children:"No repository is connected yet."}),e.jsx("p",{className:"muted",children:Me(t)?e.jsxs(e.Fragment,{children:["Connect GitLab or GitHub and pick a repository in the ",e.jsx("a",{href:re("welcome"),children:"welcome steps"}),"."]}):"An owner or an admin connects them."})]}):null,e.jsxs("section",{className:"section","aria-labelledby":"new-task-h",children:[e.jsx("h2",{id:"new-task-h",className:D?void 0:"visually-hidden",children:"New task"}),c&&$>=2?e.jsx(a1,{options:t.tasksRunHere===!1?{...c,multiRepo:null}:c,budgets:b,limits:k,...n?{start:n}:{},local:t.mode==="local",approver:Me(t),defaultRepo:l??C,first:H&&D&&!n,onStarted:ie=>Ge(re("tasks",ie.id))},c.repos.map(ie=>ie.id).join(",")):x?e.jsx(be,{what:"the task form",reason:x,onRetry:K}):e.jsx(he,{what:"the task form"})]}),Z&&!(H&&D)&&A?e.jsx("p",{className:"muted day-sentence",role:"status",children:A}):null,Z&&!H&&(X.length>1||l)?e.jsx("div",{className:"list-filter",children:e.jsx(Pe,{label:"Show tasks in",labelHidden:!0,value:l??"",onChange:ie=>Ge(ie?`${re("tasks")}?${new URLSearchParams({repo:ie})}`:re("tasks")),options:[{value:"",label:"All repositories"},...X.map(ie=>({value:ie.id,label:ie.name}))]})}):null,Z&&!D?e.jsxs("div",{className:"turn-columns","aria-hidden":"true",children:[e.jsx("span",{}),e.jsx("table",{className:"row-cards turn-rows",children:e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"rc-status"}),e.jsx("th",{className:"rc-title"}),e.jsx("th",{className:"rc-weight",children:"Changes"}),e.jsx("th",{className:"rc-extra num",children:"Ran"}),e.jsx("th",{className:"rc-extra num",children:"Cost"}),e.jsx("th",{className:"rc-extra num",children:"When"})]})})})]}):null,f&&u?e.jsx(Oi,{what:"tasks",reason:f,onRetry:L}):null,f&&!u?e.jsx(be,{what:"tasks",reason:f,onRetry:L}):Z?D?e.jsx(_j,{}):h1(te.filter(ie=>u.counts[ie.id]>0).map(ie=>{const me=u.sections[ie.id],Fe=u.counts[ie.id]-me.length;return e.jsxs(Xt,{name:ie.name,count:u.counts[ie.id],why:ie.why,empty:ie.empty,children:[e.jsx(m1,{cards:me,me:t,agents:(c==null?void 0:c.agents)??null}),Fe>0?e.jsxs("p",{className:"muted small",children:[Fe," more; All tasks below holds them."]}):null]},ie.id)})):c&&$>=2||x?e.jsx(he,{what:"tasks"}):null,H&&D||!(c&&$>=2||x)?null:e.jsx(p1,{me:t,agents:(c==null?void 0:c.agents)??null,picked:l})]}),Se=!H&&a!==null&&!Q.some(ie=>ie.configured!==!1),Ne=!!(t.runners&&t.tasksRunHere===!1)||Me(t);return Se&&Ne&&P===null&&M("open"),P==="open"?e.jsx(Rj,{me:t,org:Ts(window.location.pathname).org??"",repos:a??[],onRepos:o??(()=>Promise.resolve()),onFinished:()=>M("left")}):e.jsxs("div",{className:"page",children:[e.jsx(Yn,{title:H&&D?ij:"Tasks"}),de,H&&D?e.jsx(Kx,{me:t,quiet:!0}):null]})}function g1(t,n){const a=n.trim().toLowerCase();return a?t.filter(l=>l.text.toLowerCase().includes(a)).map(l=>l.seq):[]}function x1(t,n){const a=n.trim().toLowerCase();if(!a)return t;const l=[];let o=0;for(let c=t.toLowerCase().indexOf(a);c!==-1;c=t.toLowerCase().indexOf(a,o))l.push(t.slice(o,c),e.jsx("mark",{children:t.slice(c,c+a.length)},c)),o=c+a.length;return l.push(t.slice(o)),l}const j1=1500,y1=15e3,v1=48,Ig=new Map;function k1(t,n,a){const l=Math.max(0,t-j1*(1+n));return a!==null&&a>=0&&a<l?a:l}const b1=()=>window.innerHeight+window.scrollY>=document.documentElement.scrollHeight-v1;function w1({id:t,log:n,outputCut:a,live:l}){const[o,c]=h.useState(""),[d,u]=h.useState(0),[m,f]=h.useState(0),[g,x]=h.useState(0),y=h.useRef(!1),b=h.useRef(0),N=h.useRef(!1),v=g1(n,o),k=v.length?v[Math.min(d,v.length-1)]:null,S=k1(n.length,m,k===null?null:n.findIndex(C=>C.seq===k));h.useEffect(()=>{const C=()=>{y.current=b1(),Ig.set(t,window.scrollY),y.current&&x(0)};return window.addEventListener("scroll",C,{passive:!0}),()=>window.removeEventListener("scroll",C)},[t]),h.useEffect(()=>{const C=n.length-b.current;if(b.current=n.length,!!n.length){if(!N.current){N.current=!0;const R=Ig.get(t);R!==void 0&&window.scrollTo(0,R);return}!l||C<=0||(y.current?window.scrollTo(0,document.documentElement.scrollHeight):x(R=>R+C))}},[n.length]),h.useEffect(()=>{var C;k!==null&&((C=document.getElementById(`log-line-${k}`))==null||C.scrollIntoView({block:"nearest"}))},[k]);const $=C=>v.length&&u((Math.min(d,v.length-1)+C+v.length)%v.length),E=()=>{x(0),y.current=!0,window.scrollTo(0,document.documentElement.scrollHeight)};return e.jsxs(e.Fragment,{children:[a?e.jsxs("p",{className:"muted",role:"note",children:["Part of the output was left out; the log marks where. ",e.jsx(Ie,{label:"what the log keeps",children:"The log holds the start and the end of the agent's and the tests' output, and every line the orchestrator wrote."})]}):null,n.length?e.jsxs("div",{className:"log-find",role:"search","aria-label":"Find in the log",children:[e.jsxs("label",{className:"filter",children:["Find in the log",e.jsx("input",{type:"search","data-page-search":!0,value:o,onChange:C=>{c(C.target.value),u(0)},onKeyDown:C=>{C.key==="Enter"&&(C.preventDefault(),$(C.shiftKey?-1:1))}})]}),o.trim()?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"muted small",role:"status",children:v.length?`${v.indexOf(k)+1} of ${v.length}`:"No line matches."}),v.length>1?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"secondary small",onClick:()=>$(-1),children:"Previous"})," ",e.jsx("button",{type:"button",className:"secondary small",onClick:()=>$(1),children:"Next"})]}):null,e.jsx("button",{type:"button",className:"ghost small","aria-label":"Close find",onClick:()=>{c(""),u(0)},children:"×"})]}):null]}):null,S>0?e.jsx("p",{children:e.jsxs("button",{type:"button",className:"secondary small",onClick:()=>f(m+1),children:["Show earlier lines (",S,")"]})}):null,e.jsx("div",{role:"log","aria-label":"Task log","aria-live":"off",children:e.jsx("ol",{className:`task-log${l?"":" task-log-ended"}`,"data-quotable":"",children:n.slice(S).map(C=>e.jsxs("li",{id:`log-line-${C.seq}`,"data-seq":C.seq,"aria-current":C.seq===k?"true":void 0,children:[e.jsx("span",{className:"muted mono",children:VE(C.at)})," ",e.jsx("span",{dir:"auto",children:x1(C.text,o)})]},C.seq))})}),n.length?null:e.jsx("p",{className:"muted",children:l?"Nothing logged yet; lines show here as the agent writes them.":"Nothing was logged."}),g?e.jsxs("button",{type:"button",className:"secondary small log-new",onClick:E,children:[g," new ",g===1?"line":"lines"]}):null]})}function N1({id:t,me:n}){var Ln,an,Fn,Xn,ps,fs,Ga,xa,Zn,yn,ja;const[a,l]=h.useState(null),[o,c]=h.useState([]),[d,u]=h.useState(null),[m,f]=h.useState(null),[g,x]=h.useState(!1),[y,b]=h.useState(!1),[N,v]=h.useState(null),[k,S]=h.useState(0),[$,E]=h.useState(0),[C,R]=h.useState(null),P=Wj((a==null?void 0:a.agent)??""),[M,O]=Ps(YE),_=hE(t),I=Sj();h.useEffect(()=>{const ue=()=>{O(`open:${t}`),setTimeout(()=>{var Rt;return(Rt=document.querySelector("main [data-page-search]"))==null?void 0:Rt.focus()},50)},ze=Rt=>{const vn=Rt.detail,rn=document.querySelector(`main [data-seq="${vn}"]`);if(rn)return rn.scrollIntoView({block:"center"});O(`open:${t}`),setTimeout(()=>{var pt;return(pt=document.getElementById(`log-line-${vn}`))==null?void 0:pt.scrollIntoView({block:"center"})},50)};return window.addEventListener(Ni,ue),window.addEventListener(fd,ze),()=>{window.removeEventListener(Ni,ue),window.removeEventListener(fd,ze)}},[t]);const[L,K]=h.useState([]),B=h.useRef(0),ne=h.useRef(!1),Z=h.useRef(null),[D,te]=h.useState(!1);h.useEffect(()=>{if(!ne.current||!Z.current)return;const ue=Z.current;Z.current=null,ue()}),h.useEffect(()=>{B.current=0,c([]),l(null),u(null),v(null),b(!1),f(null),Z.current=null;let ue=!1,ze=!1,Rt=0,vn;const rn=()=>ge.get(t,B.current).then(({task:vt,log:_e,outputCut:Fs,next:Mn})=>{if(ue)return;ze=!0,Rt=0,v(null),l(vt),Fs&&b(!0),_e.length&&(B.current=Mn??_e[_e.length-1].seq,c(gs=>[...gs,..._e]));const Ms=Mn!=null;if(Ms&&!dn.includes(vt.status)&&!ne.current){Z.current=rn;return}(Ms||dn.includes(vt.status))&&(vn=setTimeout(rn,Ms?0:document.hidden?y1:1e3))},vt=>{if(ue)return;if(!ze)return u(vt.message);Rt++;const _e=Math.min(15e3,1e3*2**Rt);v({line:`The task did not refresh; trying again in ${_e/1e3} s.`,reason:vt.message}),vn=setTimeout(rn,_e)});let pt=null;return(()=>{if(typeof EventSource>"u")return rn();pt=new EventSource(ge.eventsUrl(t,B.current)),pt.addEventListener("task",vt=>{ze=!0,v(null),l(JSON.parse(vt.data))}),pt.addEventListener("log",vt=>{const{log:_e,outputCut:Fs}=JSON.parse(vt.data);Fs&&b(!0),_e.length&&(B.current=_e[_e.length-1].seq,c(Mn=>[...Mn,..._e]))}),pt.onerror=()=>{pt==null||pt.close(),pt=null,ue||rn()}})(),ge.options().then(vt=>R({editable:vt.repos.map(_e=>_e.id),agents:vt.agents}),()=>R({editable:[],agents:[]})),()=>{ue=!0,pt==null||pt.close(),clearTimeout(vn)}},[t,k]);const Q=()=>ge.get(t,B.current).then(ue=>l(ue.task),ue=>v({line:"The task did not refresh.",reason:ue.message})),ee=YT({task:a,mine:(a==null?void 0:a.createdBy)===n.email,onChanged:()=>void Q()}),[W,A]=h.useState(null);h.useEffect(()=>{Je.list().then(ue=>A(ue.home??null),()=>A(null))},[]);const H=((Ln=a==null?void 0:a.routing)==null?void 0:Ln.path)??null,X=h.useMemo(()=>uT(o,{folder:H,home:W}),[o,H,W]),[de,Se]=h.useState(!0);h.useEffect(()=>{const ue=()=>Se(window.innerHeight+window.scrollY>=document.documentElement.scrollHeight-48);return window.addEventListener("scroll",ue,{passive:!0}),()=>window.removeEventListener("scroll",ue)},[]),h.useEffect(()=>{de&&a&&dn.includes(a.status)&&window.scrollTo(0,document.documentElement.scrollHeight)},[X.stream.length,!!C]);const[Ne,xe]=h.useState(!1),[ie,me]=h.useState([]),Fe=a?!dn.includes(a.status):!1,Ve=!!(a!=null&&a.routing);if(h.useEffect(()=>{!Fe&&!Ve||$s.task(t).then(me,()=>me([]))},[t,Fe,Ve,a==null?void 0:a.finishedAt]),d)return e.jsx(be,{what:"the task",reason:d,onRetry:()=>S(ue=>ue+1),panel:!0});if(!a||!C)return e.jsx(he,{what:"the task",panel:!0});const le=dn.includes(a.status),pe=((an=C.agents.find(ue=>ue.id===a.agent))==null?void 0:an.label)??P,Be=C.editable,We=ue=>{x(!0),f(null),ue().catch(ze=>f(ze.message)).finally(()=>x(!1))},St=()=>We(()=>ge.start(FE(a)).then(ue=>Ge(re("tasks",ue.id)))),gt=(a.requests??[]).some(ue=>ue.kind==="plan"&&ue.status!=="answered"&&!!ue.payload.plan),Lt=gt?null:pT(X.stream),Zt=["interrupted","failed","cancelled"].includes(a.status)&&(a.planToApprove===!0||gt||Lt!==null),Qn=()=>We(()=>ge.continueWithPlan(a.id,Lt??void 0).then(()=>S(ue=>ue+1))),Oe=a.request,is=()=>We(()=>Ce.requestAction(a.repoId,a.requestNumber,"refresh").then(ue=>Oe&&l({...a,request:{...Oe,status:ue.status}}))),Bt=Be.includes(a.repoId),cs=a.createdBy===n.email||a.createdBy===n.id||Me(n)||n.role!=="viewer"&&n.ownedTeams.includes(a.team),yt=a.followUp&&a.createdBy===n.email?a.followUp:null,Ls=!yt&&a.suggests?((Fn=a.startedBy)==null?void 0:Fn.name)??"the person who started this task":null,Ct=yt||Ls?ue=>K(VT(L,ue)):void 0,tt=(a.createdBy===n.email||Me(n)||n.ownedTeams.includes(a.team))&&(Oe==null?void 0:Oe.status)==="open"&&!dn.includes(a.status),us=ue=>ge.dropFromRequest(a.id,ue).then(()=>{E(ze=>ze+1),Q()}),nt=ME(a),qt=Ba(a),ds=Lr(qt,a.forge),An=a.requestNumber!==null&&!a.targets,st=n.mode==="local"&&An&&(Oe==null?void 0:Oe.provider)==="local",Wt=ue=>Ce.requestAction(a.repoId,a.requestNumber,ue).then(ze=>{Oe&&l({...a,request:{...Oe,status:ze.status}}),Q()}),hs=ie.map(ue=>ue.verification).find(ue=>ue.verdict==="broken"||ue.verdict==="failing-before")??null,Ft=a.requestNumber===null&&!((Xn=a.changes)!=null&&Xn.files.length)&&!((ps=a.targets)!=null&&ps.length),gn=a.status==="failed"&&Ft,en=!!(a.question&&!a.question.answer&&!le),xn=X.stream.length>0||X.plan.length>0||!!a.routing,In=ue=>a.routing?e.jsx(RE,{task:a,routing:a.routing,canMove:ue&&a.createdBy===n.email,checked:[...new Set(ie.flatMap(ze=>ze.verification.checks.map(Rt=>Rt.command)))],onChecksOff:()=>void $s.task(t).then(me,()=>me([]))}):null,jn=(ue,ze)=>gT(n,ue,ze),tn=X.costUsd??a.cost.usd,nn=((fs=[...X.stream].reverse().find(ue=>ue.kind==="say"))==null?void 0:fs.text)??"",lt=M===`open:${t}`||M!=="closed"&&!en&&(!xn&&(le||a.status==="failed"||a.status==="interrupted")||a.status==="needs-review"&&Ft),Le=!!(!le&&xn&&gn&&!en);ne.current=lt||Le||D;const ga=dn.includes(a.status)&&Bt?e.jsx(qe,{danger:!0,trigger:"Stop…",consequence:a.status==="queued"?"The task leaves the line before it starts. This cannot be undone; starting it again is a new task.":"The agent stops now; what it changed so far waits for your review.",confirm:"Stop task",keep:a.status==="queued"?"Keep it in line":"Keep it running",onConfirm:()=>ge.cancel(t).then(l)}):null,ms=a.status==="running"&&Bt&&a.stage!=="stopped"&&!Ju(a)?e.jsx(WE,{id:t,onStopped:l}):null,sn=ms||ga?e.jsxs(e.Fragment,{children:[ms,ga]}):null,On=le&&xn&&!de?e.jsx("button",{type:"button",className:"run-jump secondary small",onClick:()=>{Se(!0),window.scrollTo(0,document.documentElement.scrollHeight)},children:"Jump to latest"}):null,Jn=QE(a,pe,n,ue=>new Date(ue).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),a.routing?Kn(a.routing.path,W):null);return e.jsxs("div",{className:"page task-page",children:[e.jsx(tT,{message:`${ds.word}${Ju(a)?`; ${pe||"the agent"} asks you`:""}${le&&nn?`. ${nn}`:""}`}),e.jsx(Yn,{sticky:!0,mainAtFoot:a.status==="needs-review"&&(st||An),title:a.title,below:le&&X.plan.length?e.jsx(kT,{plan:X.plan}):null,...en?{summary:`The agent stopped to ask ${a.createdBy===n.email?"you":a.createdBy}.`}:le&&a.startedAt&&a.waitingFor?tn!==null?{summary:`The agent has spent $${tn.toFixed(2)} so far.`}:{}:le&&a.startedAt?{summary:e.jsx(T1,{task:a,spent:tn})}:hs?{summary:e.jsx("span",{className:"error",children:hs.reason})}:nt==="needs-review"?{summary:C1(a)}:qt==="finished-nothing-changed"&&a.startedAt?{summary:`The agent finished in ${Is(a)} without changing a file.`}:gn&&a.startedAt?{summary:`The agent stopped after ${Is(a)}${zE(a.error)}`}:{},actions:e.jsxs(e.Fragment,{children:[ee.actions,st?(Oe==null?void 0:Oe.status)==="open"&&Bt&&!dn.includes(a.status)?e.jsxs(e.Fragment,{children:[Oe.heldReason===void 0?e.jsx("button",{type:"button",disabled:g,onClick:()=>We(()=>Wt("merge")),children:"Keep these changes"}):null,e.jsx(qe,{trigger:"Discard these changes…",consequence:Hd(a.keptBefore===!0),confirm:"Discard changes",keep:"Keep them for now",onConfirm:()=>Wt("close")})]}):null:An?e.jsx("a",{className:`button${a.status==="needs-review"?"":" secondary"}`,href:re("repositories",a.repoId,"requests"),children:"Open the request"}):null,Zt&&Bt&&!en?e.jsx("button",{type:"button",onClick:Qn,disabled:g,title:"The task goes on from the plan the agent made, which nobody had answered yet.",children:"Approve the plan and continue"}):null,(OE.includes(a.status)||qt==="finished-nothing-changed")&&Bt&&!en?e.jsx("button",{type:"button",className:Zt||qt==="finished-nothing-changed"?"secondary":void 0,onClick:St,disabled:g,title:"Starts a new task with the same work, project, agent and options; this one stays as it is.",children:"Run again"}):null]}),also:cs&&!Ne?e.jsx("button",{type:"button",className:"secondary",onClick:()=>xe(!0),children:"Share…"}):null,children:e.jsxs("span",{className:`state ${ds.tone}`,"data-status":qt,children:[ds.word,a.queuePosition!==null?`, #${a.queuePosition} in line`:""]})}),a.waitingBehind?e.jsxs("p",{role:"note",children:["Starts once you answer ",e.jsx("a",{href:re("tasks",a.waitingBehind.id),children:a.waitingBehind.title}),", which works in the same folder."]}):null,dn.includes(a.status)&&a.createdBy===n.email?e.jsx(Lk,{}):null,Ct?e.jsx(T0,{onQuote:Ct}):null,e.jsxs("div",{className:"with-rail",style:I.style,children:[I.handle,e.jsxs("div",{className:"task-main",children:[N?e.jsxs("p",{className:"error",role:"status",children:[N.line," ",e.jsx(Ie,{label:"why the task did not refresh",children:N.reason})]}):null,a.error&&!(a.question&&!a.question.answer)&&!(gn&&a.startedAt)?a.status==="needs-review"?e.jsx("p",{className:"muted",role:"note",children:a.error}):e.jsx("p",{className:"error",role:"alert",children:a.error}):null,e.jsx(lE,{task:a,mine:a.createdBy===n.email,agent:pe,onAnswered:ue=>{l(ue),S(ze=>ze+1)}}),m?e.jsx("p",{className:"error",role:"alert",children:Tl(m)?e.jsxs(e.Fragment,{children:[Tl(m).said,": ",e.jsx(mt,{text:Tl(m).command})]}):m}):null,e.jsx(qT,{task:a,me:n,onContinued:()=>S(ue=>ue+1)}),e.jsx(Fj,{names:a.mcpNeedsSignIn??[],onePerson:n.mode==="local"&&Me(n)}),le&&xn?e.jsx("section",{className:"section","aria-label":"The agent at work",children:e.jsx(xg,{run:X,withPlan:!1,isMine:jn,first:In(!0),working:a.status==="running"&&!a.waitingFor&&a.stage!=="stopped"})}):null,a.stage==="stopped"?e.jsx("p",{className:"waiting",role:"status",children:"You stopped the agent's step; tell it what to do next."}):null,e.jsx(UT,{task:a,me:n,agent:pe,onAnswered:Q}),a.targets?r1(a)?e.jsx(l1,{task:a,local:n.mode==="local",starter:a.createdBy===n.email,onChanged:()=>void Q(),...Ct?{onQuote:Ct}:{}}):e.jsx(u1,{task:a}):null,(Ga=a.checksFound)!=null&&Ga.length?e.jsxs("p",{className:"muted",children:[g$(a.checksFound.map(ue=>ue.command))," ",e.jsx("a",{href:re("settings","code"),children:"Review them"})]}):null,ee.section,e.jsx(CE,{task:a}),An?e.jsxs("section",{className:"section","aria-labelledby":"task-req-h",children:[e.jsxs("div",{className:"heading-row",children:[e.jsx("h2",{id:"task-req-h",children:"Changes"}),e.jsx(mE,{pick:_})]}),st?null:e.jsxs("div",{className:"request-state",children:[e.jsx("p",{children:Oe?Dj(a.forge,a.requestNumber,Oe.status):"The change was opened."}),Oe?e.jsx(hh,{request:{repoId:a.repoId,number:a.requestNumber,status:Oe.status,provider:Oe.provider,...Oe.heldReason!==void 0?{heldReason:Oe.heldReason}:{}}}):null]}),(Oe==null?void 0:Oe.status)==="open"&&Oe.provider!=="local"&&Bt?e.jsx("p",{children:e.jsxs("button",{type:"button",className:"secondary small",onClick:is,disabled:g,children:["Refresh from ",Oe.provider]})}):null,n.mode==="local"&&(Oe==null?void 0:Oe.status)==="open"&&Oe.provider==="local"?e.jsx(v0,{repoId:a.repoId,number:a.requestNumber}):null,e.jsx(pE,{taskId:a.id,pick:_,canUndo:tt,onUndone:()=>{E(ue=>ue+1),Q()},...Ct?{onQuote:Ct}:{},all:e.jsx(Fr,{reads:Ui(a.repoId,a.requestNumber),bare:!0,...Ct?{onQuote:Ct}:{},...tt?{onDrop:us}:{},ownCopy:st},`${a.id}:${$}`)})]}):null,qt==="finished-nothing-changed"&&a.lastSaid?e.jsxs("section",{className:"section","aria-labelledby":"task-answer-h",children:[a.description&&a.description!==a.title?e.jsxs("p",{className:"small",dir:"auto",children:[e.jsx("strong",{children:"You asked:"})," ",a.description]}):null,e.jsx("h2",{id:"task-answer-h",children:"The agent's answer"}),e.jsx(Ha,{text:a.lastSaid})]}):null,e.jsx(IE,{task:a,me:n,onAnswered:ue=>{ue&&yt==="continue"?S(ze=>ze+1):Q()}}),yt&&((xa=a.messages)!=null&&xa.length)?e.jsx(QT,{task:a.id,messages:a.messages,onChanged:()=>void Q()}):null,yt&&!((Zn=a.changes)!=null&&Zn.undone)&&!(yt!=="continue"&&Ju(a))?e.jsx(bg,{personal:n.mode==="local",task:a,kind:yt,jump:On,stop:sn,quotes:L,onQuotes:K,onSent:()=>{yt==="continue"?S(ue=>ue+1):Q()}}):Ls?e.jsx(bg,{task:a,kind:"suggest",suggestTo:Ls,quotes:L,onQuotes:K,onSent:()=>void Q()}):sn?e.jsxs("form",{className:"run-steer","aria-label":"Stop the task",onSubmit:ue=>ue.preventDefault(),children:[On,sn]}):null,a.status==="needs-review"&&(st||An)?e.jsx("div",{className:"foot-actions",children:st?(Oe==null?void 0:Oe.status)==="open"&&Bt?e.jsxs(e.Fragment,{children:[Oe.heldReason===void 0?e.jsx("button",{type:"button",disabled:g,onClick:()=>We(()=>Wt("merge")),children:"Keep these changes"}):null,e.jsx(qe,{trigger:"Discard these changes…",consequence:Hd(a.keptBefore===!0),confirm:"Discard changes",keep:"Keep them for now",onConfirm:()=>Wt("close")})]}):null:e.jsx("a",{className:"button",href:re("repositories",a.repoId,"requests"),children:"Open the request"})}):null,!le&&xn?e.jsxs("details",{className:"section log-fold",open:gn&&!en,onToggle:ue=>{ue.currentTarget.open&&te(!0)},children:[e.jsx("summary",{children:"How the agent got here"}),e.jsx(xg,{run:X,isMine:jn,first:In(!1)})]}):null,e.jsxs("details",{className:"section log-fold",open:lt,onToggle:ue=>{const ze=ue.currentTarget.open;ze!==lt&&O(ze?`open:${t}`:"closed")},children:[e.jsxs("summary",{children:["Log ",o.length?e.jsx("span",{className:"count",children:o.length}):null]}),e.jsx(w1,{id:t,log:o,outputCut:y,live:dn.includes(a.status)},t)]})]}),e.jsxs("aside",{className:"rail","aria-label":"About this task",children:[ie.some(ue=>ue.verification.checks.length)?e.jsx($1,{checks:ie,machineOf:a.runner==="local"?a.createdBy===n.email?"you":a.createdBy:null}):null,a.description&&a.description!==a.title?e.jsxs("section",{"aria-labelledby":"task-ask-h",children:[e.jsx("h2",{id:"task-ask-h",children:"The ask"}),e.jsx("p",{className:"pre",dir:"auto",children:a.description})]}):null,e.jsx(C0,{id:a.id,reads:k}),e.jsxs("section",{"aria-labelledby":"task-where-h",children:[e.jsx("h2",{id:"task-where-h",children:"Where"}),e.jsx(Lg,{facts:Jn.where}),(yn=a.issueUrl)!=null&&yn.startsWith("https://")?e.jsxs("p",{children:["Works on ",e.jsx("a",{href:a.issueUrl,target:"_blank",rel:"noopener noreferrer",children:a.issueKey??a.issueUrl}),", read through ",n.mode==="local"?"your":"the team's"," MCP servers."]}):null]}),a.folderTrust==="unasked"&&a.createdBy===n.email?e.jsx(S1,{task:a,onAnswered:Q}):null,e.jsx(WT,{task:a.id,canShare:cs,manager:Me(n),adding:Ne,onClose:()=>xe(!1)}),le&&X.changed.length?e.jsxs("section",{"aria-labelledby":"task-changed-h",children:[e.jsx("h2",{id:"task-changed-h",children:"Changed so far"}),e.jsx("ul",{className:"run-changed",children:X.changed.map(ue=>e.jsxs("li",{children:[e.jsx("span",{className:"mono",dir:"auto",children:ue.path})," ",e.jsx(Di,{added:ue.additions,removed:ue.deletions})]},ue.path))})]}):null,e.jsxs("section",{"aria-labelledby":"task-run-h",children:[e.jsx("h2",{id:"task-run-h",children:"Run"}),e.jsx(Lg,{facts:Jn.run})]}),a.setup||a.used?e.jsx(yE,{...a.setup?{setup:a.setup}:{},off:{...qa,...a.off},...a.used?{used:a.used}:{},...a.startedWith?{report:a.startedWith}:{}}):null,le?null:e.jsx(oS,{task:a.id,finishedAt:a.finishedAt,usedShown:!!(a.setup||a.used),folder:n.mode==="local"?((ja=a.routing)==null?void 0:ja.path.split("/").filter(Boolean).pop())??a.repoId:null},a.id)]})]})]})}function S1({task:t,onAnswered:n}){const[a,l]=h.useState(!1),[o,c]=h.useState(null),d=u=>{l(!0),c(null),Je.trust(t.repoId,u).then(n,m=>c(m.message)).finally(()=>l(!1))};return e.jsxs("section",{"aria-labelledby":"task-trust-h",children:[e.jsx("h2",{id:"task-trust-h",children:"This folder's settings"}),e.jsxs("p",{children:["Use this folder's own Claude Code settings for the next tasks here? ",e.jsx(Ie,{label:"the folder's own settings",children:"They can run programs and change where the model is reached. This task runs without them."})]}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",className:"secondary small",disabled:a,onClick:()=>d(!0),children:"Use them"}),e.jsx("button",{type:"button",className:"ghost small",disabled:a,onClick:()=>d(!1),children:"Keep them off"})]}),o?e.jsx("p",{className:"error",role:"alert",children:o}):null]})}function C1(t){var o;const n=t.startedAt&&t.finishedAt?` in ${Is(t)}`:"",a=(t.targets??[]).filter(c=>c.status==="request"||c.status==="failed"||c.status==="local");if(a.length&&a.every(c=>c.status==="local")){const c=t.ranOn?` on ${t.ranOn}`:"";return`The agent finished${n}, changing ${Og(a.map(Ai))}; ${a.length===1?`the change stays on its branch${c}`:`the changes stay on their branches${c}`}.`}if(a.length)return`The agent finished${n}, changing ${Og(a.map(Ai))}; ${a.length===1?"the change waits":"each change waits"} for your review.`;const l=((o=t.changes)==null?void 0:o.files.length)??0;return`The agent finished${n}${l?`, changing ${l} ${l===1?"file":"files"}`:""}; the change waits for your review.`}const Og=t=>t.length===1?t[0]:`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`;function $1({checks:t,machineOf:n}){const a=t.length>1,l=n!==null&&t.some(o=>o.verification.verdict!=="not-run");return e.jsxs("section",{"aria-labelledby":"task-checks-h",children:[e.jsx("h2",{id:"task-checks-h",children:"Checks"}),l?e.jsxs("p",{className:"muted small",children:["These checks ran on ",n==="you"?"your":`${n}'s`," machine, not on the orchestrator."]}):null,e.jsx("ul",{className:"plain run-checks",children:t.flatMap(({repoId:o,verification:c})=>c.checks.map(d=>{const u=d.after.at(-1)??d.before;return e.jsx("li",{className:p$(d)?"error":void 0,children:e.jsxs("details",{children:[e.jsxs("summary",{children:[e.jsx("span",{className:"mono",children:d.command}),a?e.jsxs("span",{className:"muted",children:[" in ",o]}):null," ",m$(d)]}),u!=null&&u.output?e.jsxs("pre",{className:"pre mono",children:[u.cut?`${u.cut} lines left out
|
|
100
|
+
`:"",u.output]}):e.jsx("p",{className:"muted small",children:"No output."})]})},`${o}:${d.command}`)}))})]})}function T1({task:t,spent:n}){const[,a]=h.useState(0);h.useEffect(()=>{const c=setInterval(()=>a(d=>d+1),1e3);return()=>clearInterval(c)},[]);const l=(t.requests??[]).some(c=>c.status==="pending"&&c.responseCapability==="live"),o=n!==null?`; $${n.toFixed(2)} so far`:"";return l?e.jsxs(e.Fragment,{children:["Waiting for you. The agent has worked ",Is(t)," so far",o,"."]}):e.jsxs(e.Fragment,{children:["The agent has worked ",Is(t),o,"."]})}function Lg({facts:t}){return e.jsx("dl",{children:t.map(n=>e.jsxs(h.Fragment,{children:[e.jsx("dt",{children:n.term}),e.jsx("dd",{dir:"auto",children:n.value})]},n.term))})}const _r=(t,n="")=>`orchestrator.work.${t}${n?`.${n}`:""}`,E1=()=>Es(_r("source")),R1=t=>Es(_r("board",t)),P1=t=>Es(_r("sprint",t)),A1=t=>Rs(_r("source"),t),I1=(t,n)=>n&&Rs(_r("board",t),n),O1=(t,n)=>n&&Rs(_r("sprint",t),n);function Kd(t,n,a){return t.find(l=>l.id===n)??t.find(l=>l.id===a)}const L1=[{name:"To do",category:"todo"},{name:"In progress",category:"doing"},{name:"Done",category:"done"}];function F1(t,n){var o;if(!t.length)return L1.map(c=>({name:c.name,items:n.filter(d=>d.status.category===c.category)}));const a=t.map(c=>({name:c.name,items:[]})),l=[];for(const c of n)(((o=a.find(d=>d.name===c.column))==null?void 0:o.items)??l).push(c);return[...a,...l.length?[{name:"Other",items:l}]:[]]}function zj(t){var m;const n=new Set,a=new Set;let l=null,o=!1;for(const f of t.items)for(const g of f.tasks){for(const x of g.requests)x.status==="open"&&(n.add(`${x.repoId}#${x.number}`),a.add(x.url?((m=/ on (GitLab|GitHub)$/.exec(x.name))==null?void 0:m[1])??"":""));g.costUsd===null?o=!0:l=(l??0)+g.costUsd}const{todo:c,doing:d,done:u}=t.progress;return{done:u,total:c+d+u,openRequests:n.size,blocked:t.items.filter(f=>f.blocked).length,costUsd:l,costPartial:o&&l!==null,reviewOn:a.size===1&&[...a][0]?[...a][0]:null}}function Yd(t){const n=t.requests[0],a=n==null?void 0:n.name.match(/ on (GitLab|GitHub)$/),l=n!=null&&n.url&&a?{kind:a[1].toLowerCase(),number:n.number,url:n.url}:null,o=Ba({status:t.status,...t.phase?{phase:t.phase}:{},result:t.result??null,request:n?{status:n.status,provider:n.url?"forge":"local"}:null}),{word:c,tone:d}=Lr(o,l);return{label:c,tone:d}}function Ii(t,n){var o;return(((o=t.assignee)==null?void 0:o.you)??(t.assignee!==null&&t.assignee.name.trim().toLowerCase()===n.name.trim().toLowerCase()))||t.tasks.some(c=>c.startedBy===n.email)}const Fg=["highest","critical","blocker","high","medium","low","lowest"];function Hj(t,n){const a=t.items.filter(o=>o.status.category==="todo"&&!o.tasks.length&&!o.blocked),l=o=>{const c=Fg.indexOf((o.priority??"").toLowerCase());return c<0?Fg.length:c};return[...a].sort((o,c)=>Number(Ii(c,n))-Number(Ii(o,n))||l(o)-l(c))[0]??null}function M1(t,n,a){const l=g=>`- ${g.key} ${g.summary}`,o=zj(n),c=n.progress,d=n.items.filter(g=>{var x;return(x=g.tasks[0])==null?void 0:x.requests.some(y=>y.status==="open")}),u=n.items.filter(g=>g.tasks[0]&&["queued","running"].includes(g.tasks[0].status)),m=n.items.filter(g=>g.blocked),f=Hj(n,a);return[`${t}: ${c.done} of ${o.total} done${c.points?`, ${c.points.done} of ${c.points.total} points`:""}, ${c.doing} in progress, ${c.todo} to do.`,...d.length?["","In review:",...d.map(l)]:[],...u.length?["","Agents at work on:",...u.map(l)]:[],...m.length?["","Blocked:",...m.map(l)]:[],...f?["","Next up:",l(f)]:[]].join(`
|
|
101
|
+
`)}function _1({board:t,onMapped:n}){const[a,l]=h.useState(null),[o,c]=h.useState(t.team??""),[d,u]=h.useState(!t.team),[m,f]=h.useState(!1),[g,x]=h.useState(null),[y,b]=h.useState(null),N=()=>{b(null),pn.teams().then(k=>l(k.map(S=>S.team)),k=>b(k.message))};h.useEffect(N,[]);const v=()=>{f(!0),x(null),fn.mapBoard(t.id,o||null).then(()=>{u(!1),n(o||null)},k=>x(k.message)).finally(()=>f(!1))};return d?e.jsxs("div",{className:t.team?"board-team":"panel board-team",role:"group","aria-label":"Who works on this board",children:[t.team?null:e.jsx("p",{children:"Pick the team that works on this board; its members see it from then on."}),e.jsxs("div",{className:"actions",children:[e.jsx(Pe,{label:"Team",value:o,onChange:c,placeholder:a===null?"Loading the teams…":"Pick a team",options:(a??[]).map(k=>({value:k,label:k})),disabled:!(a!=null&&a.length)}),e.jsx("button",{type:"button",disabled:m||!o,onClick:v,children:"Save"}),t.team?e.jsx("button",{type:"button",className:"secondary",onClick:()=>u(!1),children:"Cancel"}):null]}),y?e.jsx(be,{what:"the teams",reason:y,onRetry:N}):null,a!==null&&!a.length?e.jsx("p",{className:"muted small",children:"A team appears here once one of its repositories is connected under Repositories."}):null,g?e.jsx("p",{className:"error",role:"alert",children:g}):null]}):e.jsxs("p",{className:"muted small board-team",children:["Shown to the ",t.team," team. ",e.jsx("button",{type:"button",className:"link small",onClick:()=>u(!0),children:"Change"})]})}const Gj=[{id:"started",label:"When its agent starts"},{id:"requestOpened",label:"When its request opens"},{id:"merged",label:"When its request is merged"}],U1=()=>`${re("integrations")}?allow=transitionJiraIssue`;function D1({board:t,columns:n}){const[a,l]=h.useState(void 0),[o,c]=h.useState(null),[d,u]=h.useState(!1),[m,f]=h.useState(!1),[g,x]=Ps(`orchestrator.work.moves.offered.${t.id}`),y=()=>{c(null),fn.moves(t.id).then(l,S=>S instanceof Os?l(null):c(S.message))};if(h.useEffect(y,[t.id]),a===void 0)return o?e.jsx(be,{what:"the issue moves",reason:o,onRetry:y}):e.jsx(he,{what:"the issue moves"});if(!a)return null;const b=S=>{u(!0),c(null),fn.saveMoves(t.id,S).then($=>{l($),f(!1)},$=>c($.message)).finally(()=>u(!1))},N=a.write.allowed?a.canChange?null:"Only an owner or an admin changes this for the organization's tracker.":a.write.reason??"The orchestrator cannot move this tracker's issues.",v=Gj.filter(S=>a.moves[S.id]).map(S=>`${S.label.toLowerCase()}, to ${a.moves[S.id]}`).join("; "),k=a.guessed&&!a.enabled&&!N&&g!=="yes"&&v;return e.jsxs("div",{className:"moves",children:[k?e.jsxs("section",{className:"panel moves-offer","aria-labelledby":"moves-offer-h",children:[e.jsx("h2",{id:"moves-offer-h",children:"Move issues as the agent works?"}),e.jsxs("p",{children:["Each issue moves on this board ",v,". Every move is in the audit log."]}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",disabled:d,onClick:()=>b({enabled:!0,moves:a.moves}),children:"Turn on"}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>f(!0),children:"Change the columns"}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>x("yes"),children:"Not now"})]})]}):null,e.jsxs("div",{className:"moves-switch",children:[e.jsxs("button",{type:"button",role:"switch","aria-checked":a.enabled,"aria-describedby":N?"moves-why":void 0,disabled:d||!!N,onClick:()=>b({enabled:!a.enabled,moves:a.moves}),className:"switch",children:[e.jsx("span",{className:"switch-track","aria-hidden":"true",children:e.jsx("span",{className:"switch-knob"})}),"Move issues as the agent works"]}),N?null:e.jsx("button",{type:"button",className:"link small","aria-expanded":m,onClick:()=>f(!m),children:"Columns"}),N?e.jsxs("p",{id:"moves-why",className:"muted small",children:[N,a.write.off?e.jsxs(e.Fragment,{children:[" ",e.jsx("a",{href:`${re("integrations")}?open=tracker`,children:"Open the issue tracker card"})]}):a.write.allowed?null:e.jsxs(e.Fragment,{children:[" ",e.jsx("a",{href:U1(),children:"Allow Jira writes"})]})]}):null]}),m?e.jsx(B1,{moves:a,columns:n,busy:d,onSave:S=>b({enabled:a.enabled||!!k,moves:S}),onCancel:()=>f(!1)},JSON.stringify(a.moves)):null,o?e.jsx("p",{className:"error",role:"alert",children:o}):null]})}function B1({moves:t,columns:n,busy:a,onSave:l,onCancel:o}){const[c,d]=h.useState(t.moves),u=[{value:"",label:"Don't move it"},...n.map(m=>({value:m.name,label:m.name}))];return e.jsxs("form",{className:"form inline-form","aria-label":"Where issues move",onSubmit:m=>{m.preventDefault(),l(c)},children:[Gj.map(m=>e.jsx(Pe,{label:m.label,value:c[m.id]??"",options:u,onChange:f=>d({...c,[m.id]:f||void 0})},m.id)),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",disabled:a,children:"Save"}),e.jsx("button",{type:"button",className:"secondary",onClick:o,children:"Cancel"})]})]})}function q1({board:t,columns:n,onSaved:a}){const l=n.flatMap(N=>N.statuses.map(v=>({status:v,column:N.name}))),[o,c]=h.useState(()=>Object.fromEntries(l.map(N=>[N.status,N.column]))),[d,u]=h.useState(!1),[m,f]=h.useState(null),[g,x]=h.useState(null),y=N=>{u(!0),x(null),fn.saveColumns(t,N).then(()=>{f(N?"Your columns are saved. Only you see them; Jira is not changed.":"The board shows a column per status again."),a()},v=>x(v.message)).finally(()=>u(!1))},b=()=>{const N=[],v=new Map;for(const{status:k}of l){const S=(o[k]??k).trim()||k;v.has(S)||(v.set(S,[]),N.push(S)),v.get(S).push(k)}return N.map(k=>({name:k,statuses:v.get(k)}))};return e.jsxs("details",{className:"arrange-columns",children:[e.jsx("summary",{children:"Arrange columns"}),e.jsx("p",{className:"muted small",children:"Your server reads no board configuration, so the board shows a column per status. Name the column each status sits in; statuses with the same name share one."}),e.jsx("ul",{className:"plain",children:l.map(({status:N})=>e.jsx("li",{children:e.jsxs("label",{children:[N,e.jsx("input",{value:o[N]??"",maxLength:60,onChange:v=>c({...o,[N]:v.target.value}),"aria-label":`Column for ${N}`})]})},N))}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",className:"secondary",disabled:d,onClick:()=>y(b()),children:"Save the columns"}),e.jsx("button",{type:"button",className:"ghost",disabled:d,onClick:()=>y(null),children:"A column per status"})]}),m?e.jsx("p",{role:"status",children:m}):null,g?e.jsx("p",{className:"error",role:"alert",children:g}):null]})}const W1=20;function z1({items:t,local:n=!1,onStarted:a,onCancel:l}){var Fe,Ve;const o=n?"every skill":"every team skill",[c,d]=h.useState(null),[u,m]=h.useState(null),[f,g]=h.useState(""),[x,y]=h.useState({}),[b,N]=h.useState("orchestrator"),[v,k]=h.useState(""),[S,$]=h.useState(!1),[E,C]=h.useState(null),[R,P]=h.useState(null),[M,O]=h.useState(null),[_,I]=h.useState({}),[L,K]=h.useState([]),[B,ne]=h.useState(null),[Z,D]=h.useState({}),[te,Q]=h.useState({}),ee=()=>{m(null),ge.options().then(le=>{var Be,We;const pe=le.repos.filter(St=>St.kind==="code");d(le),g(((Be=le.agents[0])==null?void 0:Be.id)??""),k(((We=pe[0]??le.repos[0])==null?void 0:We.id)??""),N(le.multiRepo?"orchestrator":"chosen")},le=>m(le.message))};h.useEffect(ee,[]),h.useEffect(()=>{if(!n||!c||!f)return;let le=!0;Je.workFolders().then(pe=>le&&K(pe.folders),()=>{}),Je.folders().then(pe=>le&&ne(pe.under),()=>{});for(const pe of t)ge.where({title:pe.summary,description:"",issueUrl:pe.url,agent:f}).then(Be=>{le&&D(We=>{var St,gt;return{...We,[pe.key]:{path:((St=Be.folder)==null?void 0:St.path)??null,reason:((gt=Be.folder)==null?void 0:gt.reason)??""}}})},()=>le&&D(Be=>({...Be,[pe.key]:{path:null,reason:""}})));return()=>{le=!1}},[n,c,f,t.map(le=>le.key).join(",")]);const W=le=>{var pe;return te[le]??((pe=Z[le])==null?void 0:pe.path)??null},A=(c==null?void 0:c.repos.filter(le=>le.kind==="code"))??[],H=!!(c!=null&&c.multiRepo)&&b==="orchestrator",X=H?((Fe=A[0])==null?void 0:Fe.id)??"":v,de=H?"orchestrator":void 0;h.useEffect(()=>{if(n||!c||!f||!X)return;let le=!0;P(null),O(null);const pe=setTimeout(()=>{ge.suggestSkillsFor({agent:f,items:t.map(Be=>({repoId:X,issueUrl:Be.url,...de?{targets:de}:{}}))}).then(Be=>{if(!le)return;const We={},St={};for(const gt of Be.results){const Lt=t[gt.index].key;We[Lt]=gt,"suggestions"in gt&&(St[Lt]=gt.suggestions.map(Zt=>Zt.skill).slice(0,ki))}P(We),I(St)},Be=>le&&O(Be.message))},300);return()=>{le=!1,clearTimeout(pe)}},[c,f,X,b]);const Se=le=>e.jsxs("section",{className:"panel start-agents","aria-labelledby":"start-agents-h",children:[e.jsxs("h2",{id:"start-agents-h",children:["Start agents ",e.jsxs("span",{className:"count",children:[t.length," ",t.length===1?"issue":"issues"]})]}),le]});if(u)return Se(e.jsx(be,{what:"the task options",reason:u,onRetry:ee}));if(!c)return Se(e.jsx(he,{what:"the task options"}));if(E){const le=E.filter(pe=>"task"in pe).length;return Se(e.jsxs(e.Fragment,{children:[e.jsxs("p",{role:"status",children:[le===E.length?`${le} ${le===1?"agent":"agents"} started.`:`${le} of ${E.length} agents started.`," ",E.length===1?"Its card shows where it stands.":"Their cards show where each stands."]}),e.jsx("ul",{className:"plain outcomes",children:E.map(pe=>e.jsxs("li",{children:[e.jsx("span",{className:"mono",children:pe.key})," ","task"in pe?e.jsx("a",{href:re("tasks",pe.task.id),children:"started"}):e.jsxs("span",{className:"error",children:["not started: ",pe.error]}),"error"in pe?e.jsx(vh,{code:pe.code}):null]},pe.key))}),e.jsx("button",{type:"button",className:"secondary",onClick:l,children:"Done picking"})]}))}const Ne=(Ve=c.agents.find(le=>le.id===f))==null?void 0:Ve.options,xe=A.length?A:c.repos;if(!n&&!xe.length)return Se(e.jsxs("p",{children:["No repository is connected for agents to work in yet. ",e.jsx("a",{href:re("repositories"),children:"Connect a repository"})]}));if(!c.agents.length)return Se(e.jsxs("p",{children:["No agent is set up on this orchestrator yet. ",e.jsx("a",{href:re("settings","agents"),children:"See Agent readiness"})]}));const ie=async()=>{const le=[];for(const pe of t)try{const Be=W(pe.key),We=await ge.start({title:pe.summary,description:"",issueUrl:pe.url,agent:f,template:null,...Be?{path:Be}:{},...$r(x)?{choices:$r(x)}:{}});le.push({key:pe.key,task:We})}catch(Be){le.push({key:pe.key,error:Be.message,...Be instanceof ht?{code:Be.code}:{}})}C(le),a()},me=le=>{if(le.preventDefault(),$(!0),n){ie().finally(()=>$(!1));return}ge.startMany({agent:f,items:t.map(pe=>{var Be;return{issueUrl:pe.url,repoId:X,...de?{targets:de}:{},...(Be=_[pe.key])!=null&&Be.length?{skills:_[pe.key]}:{},...$r(x)?{choices:$r(x)}:{}}})}).then(({started:pe,refused:Be})=>{const We=[...pe];C(t.map((St,gt)=>{const Lt=Be.find(Zt=>Zt.index===gt);return Lt?{key:St.key,error:Lt.error,code:Lt.code}:{key:St.key,task:We.shift()}})),a()},pe=>m(pe.message)).finally(()=>$(!1))};return Se(e.jsxs("form",{className:"form","aria-label":"Start agents",onSubmit:me,children:[e.jsx("ul",{className:"plain picked",children:t.map(le=>{var Be;const pe=R==null?void 0:R[le.key];return e.jsxs("li",{className:"picked-issue","aria-label":`${le.key} ${le.summary}`,children:[e.jsxs("p",{children:[e.jsx("span",{className:"mono",children:le.key})," ",le.summary]}),n?e.jsxs(e.Fragment,{children:[Z[le.key]===void 0?e.jsx("p",{className:"muted small",children:"Finding its folder…"}):e.jsx(Pe,{label:`Folder for ${le.key}`,value:W(le.key)??"",placeholder:"Pick a folder",onChange:We=>Q({...te,[le.key]:We}),options:[...W(le.key)&&!L.some(We=>We.path===W(le.key))?[{value:W(le.key),label:Kn(W(le.key),B)}]:[],...L.map(We=>({value:We.path,label:Kn(We.path,B),...We.about?{hint:We.about}:{}}))]}),(Be=Z[le.key])!=null&&Be.path&&!te[le.key]&&Z[le.key].reason?e.jsx("p",{className:"muted small",children:Z[le.key].reason}):null]}):null,n||M?null:R?pe?"error"in pe?e.jsxs("p",{className:"muted small",children:["No suggestion: ",pe.error," The agent still has ",o,"."]}):e.jsx(Ij,{label:"Skills to use first",read:pe,value:_[le.key]??[],onChange:We=>I({..._,[le.key]:We}),local:n}):null:e.jsx("p",{className:"muted small",children:"Asking the agent which skills fit…"})]},le.key)})}),!n&&M?e.jsxs("p",{className:"muted small",children:["The agent did not suggest skills: ",M," Each agent still has ",o,"."]}):null,!n&&c.multiRepo?e.jsxs("fieldset",{className:"teams",children:[e.jsx("legend",{children:"Repositories"}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"radio",name:"spread",checked:b==="orchestrator",onChange:()=>N("orchestrator")}),"Let each agent find the repositories its issue changes (recommended)"]}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"radio",name:"spread",checked:b==="chosen",onChange:()=>N("chosen")}),"Work in one repository"]})]}):null,!n&&!H?e.jsx(Pe,{label:"Repository",value:v,onChange:k,options:xe.map(le=>({value:le.id,label:le.name,...n?{}:{hint:le.team}}))}):null,c.agents.length>1?e.jsx(Pe,{label:"Agent",value:f,onChange:le=>{g(le),y({})},options:c.agents.map(le=>({value:le.id,label:le.label}))}):null,Ne!=null&&Ne.length?e.jsxs("details",{className:"more",children:[e.jsx("summary",{children:"More options"}),e.jsx("div",{className:"form",children:e.jsx(wj,{options:Ne,value:x,onChange:y})})]}):null,e.jsx("p",{className:"muted",children:n?"Each agent works in the folder picked from its issue; you review every change before you keep it.":"Each agent opens its own request for review; nothing merges on its own."}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",disabled:S||!n&&!X||!f||n&&t.some(le=>!W(le.key)),children:t.length===1?"Start 1 agent":`Start ${t.length} agents`}),e.jsx("button",{type:"button",className:"secondary",onClick:l,children:"Cancel"})]})]}))}const H1="How big is this, and which files would it touch?";function G1({asked:t}){return e.jsx("a",{href:re("tasks",t.taskId),children:J1(t.at)})}const K1=2,Mg=160;function Y1(t){return t.replace(/^\s{0,3}(#{1,6}\s+|>\s?|[-*+]\s+|\d+[.)]\s+)+/,"").replace(/!?\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/(\*\*|__|\*|_|`)/g,"").replace(/\s*\|\s*/g," ").trim()}function V1(t){return t.split(`
|
|
102
|
+
`).filter(n=>!/^\s{0,3}(```|~~~)/.test(n)&&!/^\s*\|?\s*:?-{2,}/.test(n)).map(n=>Y1(n)).filter(Boolean).slice(0,K1).map(n=>n.length>Mg?`${n.slice(0,Mg).trimEnd()}…`:n)}function Q1({asked:t}){const[n,a]=h.useState(void 0),[l,o]=h.useState(null);h.useEffect(()=>{let d=!0;return a(void 0),ge.get(t.taskId,0).then(u=>{d&&(a(u.task.lastSaid??null),o(u.task.description||null))},()=>d&&a(null)),()=>{d=!1}},[t.taskId]);const c=n?V1(n):[];return e.jsxs("section",{"aria-labelledby":"asked-answer-h",children:[l?e.jsxs("p",{className:"small asked-question",dir:"auto",children:[e.jsx("strong",{children:"You asked:"})," ",l.length>300?`${l.slice(0,300).trimEnd()}…`:l]}):null,e.jsxs("h2",{id:"asked-answer-h",children:["The agent's answer, ",Wl(t.at)]}),n===void 0?e.jsx("p",{className:"muted small",children:"Reading it…"}):c.length?c.map(d=>e.jsx("p",{dir:"auto",children:d},d)):e.jsx("p",{className:"muted small",children:"The agent has not answered yet."}),e.jsx("p",{className:"small",children:e.jsx("a",{href:re("tasks",t.taskId),children:c.length?"Read it":"Open the question"})})]})}function J1(t,n=new Date){const a=Wl(t,n);return/^\d/.test(a)?`Asked at ${a}`:`Asked ${a==="Yesterday"?"yesterday":a}`}function X1({item:t,local:n}){const[a,l]=h.useState(!1),[o,c]=h.useState(H1),[d,u]=h.useState(!1),[m,f]=h.useState(null),[g,x]=h.useState(null),y=h.useId(),b=async()=>{var N,v,k;u(!0),f(null);try{const S=await ge.options(),$=(N=S.agents[0])==null?void 0:N.id;if(!$)throw new Error("No agent is set up on this orchestrator yet.");const E=(v=S.repos.find(P=>P.kind==="code")??S.repos[0])==null?void 0:v.id,C=n?(k=(await ge.where({title:t.summary,description:"",issueUrl:t.url,agent:$})).folder)==null?void 0:k.path:null,R=await ge.start({title:`Question about ${t.key}`,description:o.trim(),issueUrl:t.url,agent:$,template:null,readOnly:!0,...C?{path:C}:E?{repoId:E}:{}});x(R.id)}catch(S){f(S.message)}finally{u(!1)}};return a?e.jsxs("form",{className:"form","aria-label":`Ask about ${t.key}`,onSubmit:N=>{N.preventDefault(),b()},children:[e.jsxs("label",{children:["Your question",e.jsx("textarea",{className:"short",value:o,onChange:N=>c(N.target.value),rows:3,maxLength:2e3,"aria-describedby":y})]}),e.jsx("p",{className:"muted small",id:y,children:"It reads; nothing in your folder changes."}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",disabled:d||!o.trim(),children:d?"Asking…":"Ask"}),g?e.jsx("a",{href:re("tasks",g),children:"See the answer"}):null]}),m?e.jsx("p",{className:"error",role:"alert",children:m}):null]}):e.jsx("button",{type:"button",className:"secondary",onClick:()=>l(!0),children:"Ask about it…"})}const Z1=1e4,eR=t=>`$${t.toFixed(2)}`,ii=t=>t?t.slice(0,10):null;function tR({me:t,sources:n,backlog:a}){const l=Bl();if(n===null)return e.jsx(he,{what:"the issue trackers",panel:!0});if(!n.length)return e.jsx(sR,{me:t});const o=new URLSearchParams(l.search),c=Kd(n,o.get("source"),E1())??n.find(d=>!d.problem)??n[0];return e.jsx(aR,{me:t,sources:n,source:c,params:o,backlog:a},c.id)}function Il(t){const n=new URLSearchParams(window.location.search);for(const[a,l]of Object.entries(t))l?n.set(a,l):n.delete(a);Ge(`${window.location.pathname}?${n.toString()}`,!0)}const nR={scrum:"Scrum",kanban:"Kanban",project:"whole project"};function sR({me:t}){const n=`${re("integrations")}?open=jira`;return e.jsxs("div",{className:"page",children:[e.jsx("header",{className:"page-head",children:e.jsx("h1",{children:"Work"})}),e.jsx("p",{className:"muted",children:Me(t)?e.jsxs(e.Fragment,{children:[e.jsx("a",{href:n,children:"Connect Jira, Linear or GitLab issues"})," to see your sprint here and start agents on its issues."]}):e.jsxs(e.Fragment,{children:[e.jsx("a",{href:n,children:"Connect your own Atlassian MCP server"})," to see your team's Jira sprint here, or ask an owner or an admin to connect the team's tracker."]})})]})}function aR({me:t,sources:n,source:a,params:l,backlog:o}){var R;const[c,d]=h.useState(((R=Al.boards(a.id))==null?void 0:R.boards)??null),[u,m]=h.useState(null),[f,g]=h.useState(null),x=(c&&Kd(c,l.get("board"),R1(a.id)))??(c==null?void 0:c[0])??null,y=(u&&x&&Kd(u,l.get("sprint"),P1(x.id)))??(u==null?void 0:u.find(P=>P.state==="active"))??(u==null?void 0:u.find(P=>P.state==="future"))??null,b=()=>{g(null),fn.boards(a.id).then(P=>d(P.boards),P=>g(P.message))};h.useEffect(()=>{a.problem||b()},[a.id]),h.useEffect(()=>{var P;if(m(x?((P=Al.sprints(x.id))==null?void 0:P.sprints)??null:null),!!x){if(!a.can.sprints)return m([]);fn.sprints(x.id).then(M=>m(M.sprints),M=>g(M.message))}},[x==null?void 0:x.id]);const N=e.jsxs("div",{className:"work-picker",children:[n.length>1?e.jsx(Pe,{label:"Source",value:a.id,onChange:P=>{A1(P),Il({source:P,board:null,sprint:null})},options:n.map(P=>({value:P.id,label:P.name,hint:P.as==="you"?"as you":void 0}))}):null,c&&c.length>1?e.jsx(Pe,{label:"Board",value:(x==null?void 0:x.id)??"",onChange:P=>{I1(a.id,P),Il({board:P,sprint:null})},options:c.map(P=>({value:P.id,label:P.name,hint:[nR[P.type],P.project].filter(Boolean).join(", ")||void 0}))}):null,u&&u.length?e.jsx(Pe,{label:"Sprint",value:(y==null?void 0:y.id)??"",onChange:P=>{O1(x.id,P),Il({sprint:P})},options:u.map(P=>({value:P.id,label:P.name,hint:P.state==="active"?"active":P.state==="future"?"next":"closed"}))}):null]}),v=a.kind==="jira"?"Jira":a.kind==="linear"?"Linear":a.kind==="gitlab"?"GitLab":"GitHub",k=(P,M)=>e.jsxs(e.Fragment,{children:[e.jsx(Yn,{title:P,crumb:x&&x.name!==P?x.name:a.name,summary:M??void 0,actions:x?e.jsxs("a",{className:"button secondary",href:x.url,target:"_blank",rel:"noopener noreferrer",children:["Open in ",v]}):void 0}),N]});if(a.problem)return e.jsxs("div",{className:"page",children:[k("Work"),e.jsx(be,{what:a.name,reason:a.problem,next:e.jsx("a",{href:re("integrations"),children:"Fix the connection under Integrations"}),panel:!0})]});if(f)return e.jsxs("div",{className:"page",children:[k("Work"),e.jsx(be,{what:"the board",reason:f,onRetry:b,panel:!0})]});if(!c)return e.jsxs("div",{className:"page",children:[k("Work"),e.jsx(he,{what:"the boards",panel:!0})]});if(!x)return e.jsxs("div",{className:"page",children:[k("Work"),e.jsx("div",{className:"panel",children:e.jsx("p",{className:"muted",children:Me(t)?`No board is read from ${a.name} yet.`:"No board is mapped to your team yet. Ask an owner or an admin to map your team's board."})})]});if(u===null)return e.jsxs("div",{className:"page",children:[k(x.name),e.jsx(he,{what:"the sprints",panel:!0})]});const S=t.mode!=="local"&&Me(t)&&a.as==="organization"?e.jsx(_1,{board:x,onMapped:P=>d(c.map(M=>M.id===x.id?{...M,team:P}:M))},x.id):null,$=y&&(ii(y.startsAt)||ii(y.endsAt))?`${ii(y.startsAt)??"?"} to ${ii(y.endsAt)??"?"}`:null,E=l.toString()?`?${l.toString()}`:"",C=e.jsx(Fi,{label:"Work",current:o?re("work","backlog")+E:re("work")+E,links:[{to:re("work")+E,label:"Board"},...a.can.backlog?[{to:re("work","backlog")+E,label:"Backlog"}]:[]]});return o?e.jsxs("div",{className:"page",children:[k("Backlog",`The issues on ${x.name} in no sprint, in the tracker's order.`),S,C,a.can.backlog?e.jsx(rd,{me:t,board:x,sprint:null,backlog:!0,mine:l.get("mine")==="1",moves:a.kind==="jira"},`${x.id}:backlog`):e.jsx("div",{className:"panel",children:e.jsxs("p",{className:"muted",children:[a.name," keeps no backlog the orchestrator reads."]})})]}):!y&&(a.kind==="jira"||a.kind==="linear")&&(x.type==="kanban"||x.type==="project")?e.jsxs("div",{className:"page",children:[k(x.name,x.type==="project"?"The whole project, as your server reads it: every issue but its epics, the done ones from the last two weeks.":"Every issue on this board but its epics, the done ones from the last two weeks."),S,e.jsx(rd,{me:t,board:x,sprint:null,backlog:!1,whole:!0,mine:l.get("mine")==="1",moves:a.kind==="jira"},`${x.id}:board`)]}):e.jsxs("div",{className:"page",children:[k((y==null?void 0:y.name)??x.name,y?oR($,y):a.can.sprints?"This board has no active or next sprint. The Backlog lists what is waiting.":null),S,C,e.jsx(rd,{me:t,board:x,sprint:y,backlog:!y,mine:l.get("mine")==="1",moves:a.kind==="jira"},`${x.id}:${(y==null?void 0:y.id)??""}`)]})}function rd({me:t,board:n,sprint:a,backlog:l,mine:o,moves:c,whole:d=!1}){const[u,m]=h.useState(()=>(d?Al.boardItems(n.id):a&&!l?Al.sprintItems(a.id):Al.backlog(n.id))??null),[f,g]=h.useState([]),[x,y]=h.useState(!1),[b,N]=h.useState(null),[v,k]=h.useState(null),[S,$]=h.useState(0),[E,C]=h.useState(null),[R,P]=h.useState(null),M=h.useRef(),O=(X=!1)=>{clearTimeout(M.current),(d?fn.boardItems(n.id,X):a&&!l?fn.sprintItems(a.id,X):fn.backlog(n.id,X)).then(de=>{m(de),N(null),k(null)},de=>u?k(de.message):N(de instanceof Os?"This board or sprint is not one you can see.":de.message)).finally(()=>{M.current=setTimeout(()=>O(),Z1)})};if(h.useEffect(()=>(O(),()=>clearTimeout(M.current)),[]),b)return e.jsx(be,{what:"the issues",reason:b,onRetry:()=>O(!0),panel:!0});if(!u)return e.jsx(he,{what:"the issues",panel:!0});const _=X=>g(f.includes(X)?f.filter(de=>de!==X):[...f,X]),I=f.length>=W1,L=X=>e.jsx(rR,{item:X,me:t,picked:f.includes(X.key),canPick:!I||f.includes(X.key),onPick:()=>_(X.key),chosen:E===X.key,onChoose:()=>C(X.key)},X.key),K=u.items.find(X=>X.key===E)??null,B=K?e.jsx("aside",{className:"rail","aria-label":"The picked issue",children:e.jsx(lR,{item:K,me:t,local:t.mode==="local",onStart:()=>{g([K.key]),y(!0)}})}):null,ne=o?u.items.filter(X=>Ii(X,t)):u.items,Z=e.jsxs("div",{className:"segmented wide",role:"group","aria-label":"Whose work",children:[e.jsxs("button",{type:"button",className:"secondary","aria-pressed":!o,onClick:()=>Il({mine:null}),children:["All issues ",e.jsx("span",{className:"count",children:u.items.length})]}),e.jsxs("button",{type:"button",className:"secondary","aria-pressed":o,onClick:()=>Il({mine:"1"}),children:["My work ",e.jsx("span",{className:"count",children:u.items.filter(X=>Ii(X,t)).length})]})]}),D=f.length&&!x?e.jsxs("div",{className:"pick-bar",role:"region","aria-label":"Picked issues",children:[e.jsxs("p",{children:[f.length," ",f.length===1?"issue":"issues"," picked",I?", as many as start at once":""]}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",onClick:()=>y(!0),disabled:x,children:"Start agents"}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>{g([]),y(!1)},children:"Clear"})]})]}):null,te=x?e.jsx(z1,{local:t.mode==="local",items:u.items.filter(X=>f.includes(X.key)),onStarted:()=>O(),onCancel:()=>{y(!1),g([])}}):null,Q=e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"muted small read-at",role:"status",children:["Read from the tracker at ",new Date(u.fetchedAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),u.stale?e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{className:"badge neutral",children:"refreshing"})," The tracker is being read again; the board catches up on its next look."]}):null]}),v?e.jsx(Oi,{what:"issues",reason:v,onRetry:()=>O(!0)}):null,u.truncated?e.jsx("p",{className:"muted",children:"The tracker returned more issues than the board shows; the first 500 are here."}):null]});if(l)return e.jsxs(e.Fragment,{children:[Q,te,e.jsxs("section",{className:"panel","aria-labelledby":"backlog-h",children:[e.jsxs("h2",{id:"backlog-h",children:["Waiting ",e.jsx("span",{className:"count",children:ne.length})]}),Z,ne.length?e.jsx("ul",{className:"plain cards backlog-list",children:ne.map(L)}):e.jsx("p",{className:"muted",children:o?"Nothing waiting is assigned to you or started by you.":"Nothing is waiting outside a sprint."})]}),D]});const ee=zj(u),W=Hj(u,t),A=F1(u.columns,ne),H=Math.min(S,A.length-1);return e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"work-progress","aria-label":"Sprint progress",children:[e.jsx("p",{children:iR(u,ee)}),e.jsx("ol",{className:"progress-line","aria-hidden":"true",children:["done","doing","todo"].map(X=>u.progress[X]?e.jsx("li",{className:`progress-${X}`,style:{flexGrow:u.progress[X]}},X):null)}),W?e.jsxs("p",{children:["Next up: ",e.jsxs("button",{type:"button",className:"link",onClick:()=>C(W.key),children:[e.jsx("span",{className:"mono",children:W.key})," ",W.summary]})]}):null,e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",className:"secondary small",onClick:()=>{navigator.clipboard.writeText(M1((a==null?void 0:a.name)??n.name,u,t)).then(()=>P("The morning summary is copied; paste it where your team reads it."),()=>P("The browser kept the summary from the clipboard; select the board's text instead."))},children:"Copy the morning summary"}),e.jsx("button",{type:"button",className:"ghost small",onClick:()=>O(!0),children:"Read the tracker again"})]}),R?e.jsx("p",{role:"status",className:"muted small",children:R}):null]}),c?e.jsx(D1,{board:n,columns:u.columns}):null,n.id.startsWith("mcp:")?e.jsx(q1,{board:n.id,columns:u.columns,onSaved:()=>O(!0)},u.columns.map(X=>X.name).join("|")):null,Q,te,Z,o&&!ne.length?e.jsx("p",{className:"muted",children:"No issue in this sprint is assigned to you or carries a task you started."}):null,e.jsx("div",{className:"segmented wide board-switch",role:"group","aria-label":"Columns",children:A.map((X,de)=>e.jsxs("button",{type:"button",className:"secondary","aria-pressed":de===H,onClick:()=>$(de),children:[X.name,e.jsx("span",{className:"visually-hidden",children:" column,"})," ",e.jsx("span",{className:"count",children:X.items.length})]},X.name))}),e.jsxs("div",{className:B?"with-rail":"board-alone",children:[e.jsx("div",{className:"board",role:"group","aria-label":`${(a==null?void 0:a.name)??n.name} board`,children:A.map((X,de)=>e.jsxs("section",{className:`board-col${de===H?" chosen":""}`,"aria-labelledby":`col-${de}`,children:[e.jsxs("h2",{id:`col-${de}`,children:[X.name," ",e.jsx("span",{className:"count",children:X.items.length}),_g(X.items)?e.jsxs("span",{className:"muted small",children:[", ",_g(X.items)," points"]}):null]}),e.jsx("ul",{className:"plain cards",children:X.items.map(L)})]},X.name))}),B]}),D]})}function Kj(t){var n;return[t.type,t.priority?`${t.priority} priority`:null,t.storyPoints!==null?`${t.storyPoints} ${t.storyPoints===1?"point":"points"}`:null,((n=t.assignee)==null?void 0:n.name)??"Unassigned"].filter(Boolean).join(", ")}function rR({item:t,me:n,picked:a,canPick:l,onPick:o,chosen:c,onChoose:d}){const u=t.tasks[0],m=u?Yd(u):null;return e.jsxs("li",{className:`work-card${a?" picked":""}${c?" chosen":""}${t.blocked?" flagged":""}`,"aria-label":`${t.key} ${t.summary}`,children:[e.jsxs("p",{className:"work-card-title",children:[e.jsx("input",{type:"checkbox",checked:a,disabled:!l,onChange:o,"aria-label":`Pick ${t.key}`}),e.jsx("button",{type:"button",className:"link","aria-pressed":c,onClick:d,children:t.summary})]}),t.epic?e.jsx("p",{className:"muted small",children:t.epic.summary}):null,e.jsxs("p",{className:"muted small",children:[e.jsx("a",{className:"mono",href:t.url,target:"_blank",rel:"noopener noreferrer",children:t.key})," ",Kj(t)]}),t.blocked?e.jsxs("p",{className:"small",children:[e.jsx("span",{className:"state warn",children:"Blocked"})," waiting on something else"]}):null,u&&m?e.jsxs("p",{className:"work-card-agent small",children:[e.jsx("a",{className:`state ${m.tone}`,href:re("tasks",u.taskId),children:m.label}),u.requests.flatMap(f=>f.url?[e.jsxs("a",{href:f.url,target:"_blank",rel:"noopener noreferrer",children:[" ",f.name]},`${f.repoId}#${f.number}`)]:[]),e.jsxs("span",{className:"muted",children:[" started by ",u.startedBy===n.email?"you":u.startedBy,t.tasks.length>1?`, ${t.tasks.length-1} earlier`:""]})]}):null,t.asked?e.jsx("p",{className:"small",children:e.jsx(G1,{asked:t.asked})}):null]})}function lR({item:t,me:n,local:a,onStart:l}){return e.jsxs(e.Fragment,{children:[e.jsxs("section",{children:[e.jsxs("h2",{children:[e.jsx("span",{className:"mono",children:t.key})," ",t.summary]}),e.jsxs("p",{className:"muted",children:[Kj(t),". ",t.status.name,t.epic?`, in ${t.epic.summary}`:"",t.labels.length?`; labels ${t.labels.join(", ")}`:"","."]}),t.blocked?e.jsxs("p",{children:[e.jsx("span",{className:"state warn",children:"Blocked"})," waiting on something else."]}):null]}),e.jsxs("section",{children:[e.jsx("h2",{children:"Agents on it"}),t.tasks.length?e.jsx("ul",{className:"plain",children:t.tasks.map(o=>e.jsxs("li",{children:[e.jsx("a",{className:`state ${Yd(o).tone}`,href:re("tasks",o.taskId),children:Yd(o).label}),o.reason?e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{className:"error",children:o.reason})]}):null," ",e.jsxs("span",{className:"muted",children:["started by ",o.startedBy===n.email?"you":o.startedBy]})]},o.taskId))}):e.jsx("p",{className:"muted",children:"No agent has worked on it yet."})]}),e.jsx("section",{children:e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",onClick:l,children:"Start an agent"}),e.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",children:"Open the issue"})]})}),e.jsx("section",{children:e.jsx(X1,{item:t,local:a},t.key)}),t.asked?e.jsx(Q1,{asked:t.asked}):null]})}function oR(t,n){const a=n.endsAt?Date.parse(n.endsAt):NaN,l=Number.isNaN(a)?null:Math.ceil((a-Date.now())/864e5),o=[t,l===null?null:l>0?`${l} ${l===1?"day":"days"} left`:"ended"].filter(Boolean).join(", ");return[o?`${o}.`:null,n.goal?`Goal: ${n.goal}.`:null].filter(Boolean).join(" ")||null}function _g(t){const n=t.filter(a=>a.storyPoints!==null);return n.length?n.reduce((a,l)=>a+(l.storyPoints??0),0):null}function iR(t,n){const a=t.progress,l=t.items.filter(c=>c.tasks.length).length,o=n.costUsd===null?"":` for ${eR(n.costUsd)}${n.costPartial?", some unreported":""}`;return[`${a.done} of ${n.total} done, ${a.doing} in progress, ${a.todo} to do${a.points?`; ${a.points.done} of ${a.points.total} points done`:""}.`,l?`Agents worked on ${l} ${l===1?"issue":"issues"}${o}${n.openRequests?`, ${n.openRequests} in review${n.reviewOn?` on ${n.reviewOn}`:""}`:""}.`:"No agent has worked on these yet.",n.blocked?`${n.blocked} flagged.`:""].filter(Boolean).join(" ")}const cR=["signed up","created an organization","connected a forge","started a first task","merged a first request"],uR={google:"Google",github:"GitHub",microsoft:"Microsoft"},Ug=t=>t.slice(0,10);function dR(){const[t,n]=h.useState(30),[a,l]=h.useState(null),[o,c]=h.useState(null),[d,u]=h.useState(!1),m=()=>{c(null),l(null),ut.operatorFunnel(t).then(l,g=>g instanceof Os?u(!0):c(g.message))};if(h.useEffect(m,[t]),d)return e.jsxs("main",{className:"page",id:"content",children:[e.jsx("div",{className:"page-head",children:e.jsx("h1",{children:"Page not found"})}),e.jsx("p",{children:"There is no page at this address."})]});const f=[7,30,90].filter(g=>!a||g<=a.keptDays);return e.jsxs("main",{className:"page operator",id:"content",children:[e.jsxs("div",{className:"page-head",children:[e.jsx("h1",{children:"Signups"}),e.jsx("p",{className:"muted",children:"Everyone who signed up to this orchestrator, and how far each got. Addresses show by their domain; each visit here is recorded."})]}),e.jsx(Pe,{label:"Signed up in the last",value:String(t),onChange:g=>n(Number(g)),options:f.map(g=>({value:String(g),label:`${g} days`}))}),o?e.jsx(be,{what:"the signups",reason:o,onRetry:m,panel:!0}):a?e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"panel","aria-labelledby":"funnel-h",children:[e.jsx("h2",{id:"funnel-h",children:"How far they got"}),e.jsx("dl",{className:"facts",children:cR.map(g=>e.jsxs("div",{children:[e.jsx("dt",{children:g}),e.jsx("dd",{children:a.counts[g].toLocaleString("en-US")})]},g))})]}),e.jsxs("section",{className:"panel","aria-labelledby":"people-h",children:[e.jsxs("h2",{id:"people-h",children:["Signups ",e.jsx("span",{className:"count",children:a.people.length})]}),a.people.length?e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Signed up"}),e.jsx("th",{scope:"col",children:"With"}),e.jsx("th",{scope:"col",children:"Domain"}),e.jsx("th",{scope:"col",children:"Organization"}),e.jsx("th",{scope:"col",children:"Furthest step"})]})}),e.jsx("tbody",{children:a.people.map(g=>e.jsxs("tr",{children:[e.jsx("td",{children:Ug(g.signedUpAt)}),e.jsx("td",{children:uR[g.provider]??g.provider}),e.jsx("td",{children:g.emailDomain}),e.jsx("td",{children:g.orgCreated?`/${g.orgCreated.tenant}, created ${Ug(g.orgCreated.at)}`:g.viaInvite?"joined by invitation":e.jsx("span",{className:"muted",children:"none yet"})}),e.jsx("td",{children:g.lastStep})]},g.identityId))})]}):e.jsxs("p",{className:"muted",children:["Nobody signed up in the last ",a.days," days."]})]})]}):e.jsx(he,{what:"the signups",panel:!0})]})}function Dg({repo:t,me:n,error:a,onSynced:l}){const[o,c]=h.useState(!1),[d,u]=h.useState(null),m=()=>{c(!0),u(null),Ce.sync(t.id).then(l,f=>{u(f.message),c(!1)})};return e.jsxs("div",{className:"panel problem",role:"alert",children:[e.jsxs("p",{className:"error",children:[t.head?"The last sync failed; this page shows the project as the orchestrator last read it.":"The orchestrator has not read this repository yet."," ",a]}),Mr(n,t.team)?e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",onClick:m,disabled:o,children:o?"Syncing…":"Sync again"}),d?e.jsx("span",{className:"error",children:d}):e.jsx("span",{className:"muted",children:"Check the repository's address and the orchestrator's access to it first when it fails again."})]}):e.jsxs("p",{className:"muted",children:["An admin or an owner of ",t.team," can sync it again."]})]})}function hR({repo:t,me:n,onDisconnected:a}){const[l,o]=h.useState(!1),[c,d]=h.useState(!1),[u,m]=h.useState(null),f=()=>{d(!0),m(null),Ce.disconnect(t.id).then(()=>{Ge(re("tasks")),a()},g=>{m(g.message),d(!1)})};return e.jsxs("section",{className:"panel problem","aria-labelledby":"out-h",children:[e.jsx("h2",{id:"out-h",children:"Not in the configuration"}),e.jsxs("p",{children:["The orchestrator's configuration no longer lists this repository, so it is not synced or changed. ",e.jsx(Ie,{label:"a repository out of the configuration",children:"Its requests, tasks and history stay readable, and open requests can still be merged or closed. Put it back in ORCHESTRATOR_CONFIG to sync it again."})]}),Me(n)?l?e.jsxs("div",{className:"problem",children:[e.jsxs("p",{children:["Disconnecting deletes the orchestrator's copy of ",t.name,", its forge access and sealed token, and the id its usage endpoint carries. The team's repository is not touched, and the orchestrator's records of its requests, tasks and skill use stay."]}),e.jsxs("div",{className:"actions",children:[e.jsxs("button",{type:"button",onClick:f,disabled:c,children:["Disconnect ",t.name]}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>o(!1),disabled:c,children:"Cancel"})]})]}):e.jsx("div",{className:"actions",children:e.jsx("button",{type:"button",className:"secondary",onClick:()=>o(!0),children:"Disconnect project"})}):e.jsx("p",{className:"muted",children:"An admin can disconnect it."}),u?e.jsx("p",{className:"error",role:"alert",children:u}):null]})}const Yj=[{id:"overview",label:"Overview"},{id:"skills",label:"Skills"},{id:"mcp",label:"MCP servers"},{id:"commands",label:"Commands"},{id:"requests",label:`${xh.request.term}s`},{id:"settings",label:"Settings"}],Bg=(t,n)=>n==="overview"?re("repositories",t):re("repositories",t,n);function mR({repoId:t,tab:n,me:a,known:l,onSynced:o}){var ee;const[c,d]=h.useState(null),[u,m]=h.useState(null),[f,g]=h.useState(void 0),[x,y]=h.useState(null),[b,N]=h.useState(null),[v,k]=h.useState(0),[S,$]=h.useState(null),E=h.useRef(t);E.current=t;const C=W=>A=>{E.current===t&&W(A)},[R,P]=h.useState(null),[M,O]=h.useState(0);h.useEffect(()=>{l!=null&&l.head||Je.list().then(({projects:W,home:A})=>{const H=W.find(X=>X.id===t);E.current===t&&P(H!=null&&H.facts&&(H.facts.git==="none"||H.facts.empty)?{project:H,home:A??null}:null)},()=>{})},[t,l==null?void 0:l.head,M]);const _=()=>{Ce.usage(t).then(C(y),C(()=>y(null))),k(W=>W+1)},I=()=>{m(null),Ce.inventory(t).then(C(d),C(W=>m(W.message))),Ce.overlaps(t).then(C(W=>N(W.overlaps)),C(()=>N(null))),_()},L=()=>void o().then(I);h.useEffect(()=>{d(null),P(null),N(null),m(null),g(void 0),$(null),I()},[t]);const K=!R&&!!(u&&l&&!l.head&&!l.error);if(h.useEffect(()=>{if(!K)return;const W=setTimeout(L,2e3);return()=>clearTimeout(W)},[K,u]),R&&!c)return e.jsx(pR,{project:R.project,home:R.home,me:a,onChanged:()=>{O(W=>W+1),o()}});if(K)return e.jsx("div",{className:"panel",role:"status",children:e.jsxs("p",{children:["The orchestrator is reading ",l.name," for the first time; this page fills in once it has."]})});if(u)return l&&!l.head&&l.error?e.jsx(Dg,{repo:l,me:a,error:u,onSynced:L}):e.jsx(be,{what:t,reason:u,onRetry:I,panel:!0});if(!c)return e.jsx(he,{what:t,panel:!0});const{repo:B,inventory:ne}=c,Z=B.configured!==!1,D=Z&&Mr(a,B.team),Q={repo:B,data:c,me:a,editable:D,usage:x,overlaps:b,onChanged:I,onOpened:(W,A)=>{$(A??gh(W)),_()},selected:f,onSelect:g,requestsRead:v};return e.jsxs("div",{className:"repo",children:[e.jsxs("header",{className:"repo-head",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:B.team}),e.jsx("h1",{children:B.name}),e.jsx("p",{className:"muted mono",children:B.url})]}),e.jsxs("dl",{className:"facts",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Updates"}),e.jsx("dd",{children:ne.plugin.versionedByCommit?"every merge":`version ${ne.plugin.version}`})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Latest commit"}),e.jsx("dd",{className:"mono",children:ne.head.slice(0,7)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Synced"}),e.jsx("dd",{children:((ee=B.syncedAt)==null?void 0:ee.slice(0,16).replace("T"," "))??"never"})]})]})]}),Z?B.error?e.jsx(Dg,{repo:B,me:a,error:B.error,onSynced:L}):null:e.jsx(hR,{repo:B,me:a,onDisconnected:o}),S?e.jsx("p",{className:"panel notice",role:"status",children:S}):null,D?null:e.jsxs("p",{className:"muted",children:["An admin or an owner of ",B.team," proposes changes here."]}),e.jsx(Fi,{label:`${B.name} sections`,current:Bg(t,n),links:Yj.map(W=>({to:Bg(t,W.id),label:W.label}))}),n==="overview"?e.jsx(c0,{...Q}):null,n==="skills"?e.jsx(p0,{...Q}):null,n==="mcp"?e.jsx(r0,{...Q}):null,n==="commands"?e.jsx(s0,{...Q}):null,n==="requests"?e.jsx(m0,{...Q}):null,n==="settings"?e.jsx(DC,{...Q,onRenamed:L}):null,n==="skills"||n==="mcp"||n==="commands"?e.jsxs("section",{className:"panel","aria-labelledby":"hist-h",children:[e.jsxs("h2",{id:"hist-h",children:["History ",f?e.jsx("code",{children:f}):null]}),e.jsx(a0,{repoId:t,path:f,head:ne.head})]}):null]})}function qg(t){var n;return t.length===1?"overview":t.length!==2?null:((n=Yj.find(a=>a.id===t[1]&&a.id!=="overview"))==null?void 0:n.id)??null}function pR({project:t,home:n,me:a,onChanged:l}){var o;return e.jsxs("div",{className:"repo",children:[e.jsx("header",{className:"repo-head",children:e.jsxs("div",{children:[e.jsx("h1",{children:t.name}),e.jsx("p",{className:"muted mono",children:lx(t,n)})]})}),e.jsx(pj,{repo:t,me:a,git:((o=t.facts)==null?void 0:o.git)??null,onChanged:l}),e.jsx(jh,{project:t.id,canChange:Me(a)})]})}function ci({children:t}){return e.jsx("main",{className:"gate",children:t})}function fR(){var ne,Z;const t=Bl(),[n,a]=h.useState(null),[l,o]=h.useState(null),[c,d]=h.useState(null),[u,m]=h.useState(null),[f,g]=h.useState(null),[x,y]=h.useState(null),[b,N]=h.useState(null),[v,k]=h.useState(null),[S,$]=h.useState(void 0),[E,C]=h.useState(!1),R=Ts(t.pathname),P=!!S&&/^\/signup(\/|$)/.test(t.pathname),M=!!S&&/^\/operator\/?$/.test(t.pathname),O=()=>Ce.repos().then(y,D=>k(D.message)),_=()=>{const D=Ts(window.location.pathname).org;if(k(null),m(null),!(S===void 0||P||M)&&!(S&&/^#\/join\//.test(window.location.hash))){if(S&&!D){ut.me().then(te=>{const Q=te.memberships.find(ee=>ee.reachable);Ge(Q?Te(Q.tenant,"tasks"):"/signup/organization",!0)},()=>Ge("/signup",!0));return}Ce.orgs().then(te=>{d(te),Uv(te?D:null,(te==null?void 0:te.default)??null),Ol.me().then(Q=>{a(Q),o(null),O(),fn.sources().then(ee=>N(ee.sources),()=>N([]))},Q=>{a(null),Q instanceof Ua&&g(Q.code==="signed-out"?null:Q.message),Q instanceof Ua&&S?ut.me().then(()=>m(D),()=>Ge("/signup",!0)):Q instanceof Ua?Ol.config().then(o,ee=>k(ee.message)):Q instanceof Os&&D?m(D):k(Q.message)})},te=>k(te.message))}};h.useEffect(()=>{ut.config().then(D=>{C((D==null?void 0:D.mode)==="local"),$((D==null?void 0:D.mode)==="local"?null:D)},()=>$(null))},[]),h.useEffect(_,[R.org,S,P]),h.useEffect(()=>(document.addEventListener("click",af),()=>document.removeEventListener("click",af)),[]);const I=(ne=t.hash.match(/^#\/join\/([\w-]+)$/))==null?void 0:ne[1];if(h.useEffect(()=>{var ee;if(!n||!c||I)return;const D=R.org??c.default??((ee=c.orgs[0])==null?void 0:ee.tenant);if(!D)return Ge("/signup/organization",!0);const te=window.location.hash.startsWith("#/")?uk(window.location.hash,D):null,Q=R.org?ck(R.org,R.section,R.rest):null;te?Ge(te,!0):R.org?Q?Ge(`${Q}${t.search}`,!0):!R.section&&!R.named&&Ge(Te(D,"tasks"),!0):Ge(ik(t.search,D),!0)},[n,c,t.pathname,t.hash]),P)return e.jsx(wb,{config:S});if(M)return e.jsx(dR,{});if(I)return e.jsx(zC,{token:I,onJoined:_,cloud:S});if(t.hash===fj)return e.jsx(n$,{});if(u){const D=(c==null?void 0:c.default)??((Z=c==null?void 0:c.orgs.find(te=>te.tenant!==u))==null?void 0:Z.tenant);return e.jsx(ci,{children:e.jsxs("div",{className:"panel form",role:"alert",children:[e.jsxs("div",{className:"brand",children:["TeamHandbook ",e.jsx("span",{children:"Orchestrator"})]}),e.jsx("p",{children:f??`You are not a member of ${u}.`}),D?e.jsx("p",{children:e.jsxs("a",{href:Te(D,R.section??"tasks"),children:["Go to ",D]})}):null]})})}if(!n)return E&&l?e.jsx(ci,{children:e.jsxs("div",{className:"panel form",role:"alert",children:[e.jsxs("div",{className:"brand",children:["TeamHandbook ",e.jsx("span",{children:"Orchestrator"})]}),e.jsx("p",{children:"This orchestrator runs on your machine and signs you in from the address its command prints. Run the command again for a new one."})]})}):l!=null&&l.setupNeeded?e.jsx(Cb,{onSignedIn:_}):l?e.jsx(Sb,{config:l,org:R.org!==(c==null?void 0:c.default)?R.org:null,ended:f,onSignedIn:_}):e.jsx(ci,{children:v?e.jsxs("div",{className:"panel form",role:"alert",children:[e.jsxs("div",{className:"brand",children:["TeamHandbook ",e.jsx("span",{children:"Orchestrator"})]}),e.jsx("p",{className:"error",children:v}),e.jsx("button",{type:"button",onClick:_,children:"Retry connecting"})]}):e.jsx("p",{className:"muted",children:"Loading the orchestrator…"})});if(!c||!R.org||!R.section&&!R.named)return e.jsx(ci,{children:v?e.jsxs("div",{className:"panel",role:"alert",children:[e.jsx("p",{className:"error",children:v}),e.jsx("button",{type:"button",onClick:_,children:"Retry connecting"})]}):e.jsx("p",{className:"muted",children:"Loading the orchestrator…"})});const L=R.org,[K]=R.rest,B=c.orgs.some(D=>D.tenant===L)?c.orgs:[...c.orgs,{tenant:L,name:L,role:n.role}];return e.jsxs(mb,{me:n,orgs:B,org:L,section:R.section,repos:x??[],onSignedOut:_,children:[v?e.jsxs("div",{className:"panel",role:"alert",children:[e.jsx("p",{className:"error",children:v}),e.jsx("button",{type:"button",className:"secondary",onClick:_,children:"Retry the organization"})]}):null,e.jsxs(x0,{path:t.pathname,home:Te(L,"tasks"),children:[R.section?null:e.jsx(Sr,{org:L,path:t.pathname}),R.section==="activity"?e.jsx(gb,{me:n,repos:x,page:K,entry:R.rest[1]}):null,R.section==="work"?K==="new"&&R.rest.length===1?e.jsx(ad,{me:n,start:Rg(t.search)}):K&&K!=="backlog"||R.rest.length>1?e.jsx(Sr,{org:L,path:t.pathname}):e.jsx(tR,{me:n,sources:b,backlog:K==="backlog"}):null,R.section==="repositories"&&K?qg(R.rest)?e.jsx(mR,{repoId:K,tab:qg(R.rest),me:n,known:x==null?void 0:x.find(D=>D.id===K),onSynced:O}):e.jsx(Sr,{org:L,path:t.pathname}):null,R.section==="tasks"?K==="new"?e.jsx(ad,{me:n,start:Rg(t.search),repos:x,onRepos:O}):K?e.jsx(N1,{id:K,me:n}):e.jsx(ad,{me:n,repos:x,picked:new URLSearchParams(t.search).get("repo"),onRepos:O}):null,R.section==="team"?e.jsx(QS,{me:n,org:L,repos:x,page:R.rest}):null,R.section==="integrations"?e.jsx(kC,{me:n,repos:x??[]}):null,R.section==="settings"?e.jsx(n0,{me:n,route:`/settings/${R.rest.join("/")}`,onLeft:_}):null,R.section==="welcome"?R.rest.length?e.jsx(Sr,{org:L,path:t.pathname}):e.jsx(Rj,{me:n,org:L,repos:x??[],onRepos:O}):null]})]})}sx(Es(nx));Lv.createRoot(document.getElementById("root")).render(e.jsx(h.StrictMode,{children:e.jsx(fR,{})}));
|