teamhandbook-orchestrator 0.2.0 → 0.3.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 +4048 -2471
- package/dist/server.js +34905 -30828
- package/dist/web/assets/index-DGyx1lK4.js +102 -0
- package/dist/web/assets/index-DKRnR_RT.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
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
var $j=Object.defineProperty;var Tj=(t,s,r)=>s in t?$j(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r;var Cm=(t,s,r)=>Tj(t,typeof s!="symbol"?s+"":s,r);(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))l(i);new MutationObserver(i=>{for(const c of i)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 r(i){const c={};return i.integrity&&(c.integrity=i.integrity),i.referrerPolicy&&(c.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?c.credentials="include":i.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function l(i){if(i.ep)return;i.ep=!0;const c=r(i);fetch(i.href,c)}})();var Nc={exports:{}},_a={},Sc={exports:{}},Oe={};/**
|
|
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 $m;function Ej(){if($m)return Oe;$m=1;var t=Symbol.for("react.element"),s=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),d=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),j=Symbol.iterator;function y(P){return P===null||typeof P!="object"?null:(P=j&&P[j]||P["@@iterator"],typeof P=="function"?P:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,w={};function b(P,_,V){this.props=P,this.context=_,this.refs=w,this.updater=V||k}b.prototype.isReactComponent={},b.prototype.setState=function(P,_){if(typeof P!="object"&&typeof P!="function"&&P!=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,P,_,"setState")},b.prototype.forceUpdate=function(P){this.updater.enqueueForceUpdate(this,P,"forceUpdate")};function $(){}$.prototype=b.prototype;function R(P,_,V){this.props=P,this.context=_,this.refs=w,this.updater=V||k}var T=R.prototype=new $;T.constructor=R,N(T,b.prototype),T.isPureReactComponent=!0;var C=Array.isArray,E=Object.prototype.hasOwnProperty,O={current:null},F={key:!0,ref:!0,__self:!0,__source:!0};function L(P,_,V){var le,be={},pe=null,de=null;if(_!=null)for(le in _.ref!==void 0&&(de=_.ref),_.key!==void 0&&(pe=""+_.key),_)E.call(_,le)&&!F.hasOwnProperty(le)&&(be[le]=_[le]);var se=arguments.length-2;if(se===1)be.children=V;else if(1<se){for(var he=Array(se),Le=0;Le<se;Le++)he[Le]=arguments[Le+2];be.children=he}if(P&&P.defaultProps)for(le in se=P.defaultProps,se)be[le]===void 0&&(be[le]=se[le]);return{$$typeof:t,type:P,key:pe,ref:de,props:be,_owner:O.current}}function W(P,_){return{$$typeof:t,type:P.type,key:_,ref:P.ref,props:P.props,_owner:P._owner}}function A(P){return typeof P=="object"&&P!==null&&P.$$typeof===t}function M(P){var _={"=":"=0",":":"=2"};return"$"+P.replace(/[=:]/g,function(V){return _[V]})}var Q=/\/+/g;function H(P,_){return typeof P=="object"&&P!==null&&P.key!=null?M(""+P.key):_.toString(36)}function U(P,_,V,le,be){var pe=typeof P;(pe==="undefined"||pe==="boolean")&&(P=null);var de=!1;if(P===null)de=!0;else switch(pe){case"string":case"number":de=!0;break;case"object":switch(P.$$typeof){case t:case s:de=!0}}if(de)return de=P,be=be(de),P=le===""?"."+H(de,0):le,C(be)?(V="",P!=null&&(V=P.replace(Q,"$&/")+"/"),U(be,_,V,"",function(Le){return Le})):be!=null&&(A(be)&&(be=W(be,V+(!be.key||de&&de.key===be.key?"":(""+be.key).replace(Q,"$&/")+"/")+P)),_.push(be)),1;if(de=0,le=le===""?".":le+":",C(P))for(var se=0;se<P.length;se++){pe=P[se];var he=le+H(pe,se);de+=U(pe,_,V,he,be)}else if(he=y(P),typeof he=="function")for(P=he.call(P),se=0;!(pe=P.next()).done;)pe=pe.value,he=le+H(pe,se++),de+=U(pe,_,V,he,be);else if(pe==="object")throw _=String(P),Error("Objects are not valid as a React child (found: "+(_==="[object Object]"?"object with keys {"+Object.keys(P).join(", ")+"}":_)+"). If you meant to render a collection of children, use an array instead.");return de}function ie(P,_,V){if(P==null)return P;var le=[],be=0;return U(P,le,"","",function(pe){return _.call(V,pe,be++)}),le}function X(P){if(P._status===-1){var _=P._result;_=_(),_.then(function(V){(P._status===0||P._status===-1)&&(P._status=1,P._result=V)},function(V){(P._status===0||P._status===-1)&&(P._status=2,P._result=V)}),P._status===-1&&(P._status=0,P._result=_)}if(P._status===1)return P._result.default;throw P._result}var J={current:null},Z={transition:null},ae={ReactCurrentDispatcher:J,ReactCurrentBatchConfig:Z,ReactCurrentOwner:O};function z(){throw Error("act(...) is not supported in production builds of React.")}return Oe.Children={map:ie,forEach:function(P,_,V){ie(P,function(){_.apply(this,arguments)},V)},count:function(P){var _=0;return ie(P,function(){_++}),_},toArray:function(P){return ie(P,function(_){return _})||[]},only:function(P){if(!A(P))throw Error("React.Children.only expected to receive a single React element child.");return P}},Oe.Component=b,Oe.Fragment=r,Oe.Profiler=i,Oe.PureComponent=R,Oe.StrictMode=l,Oe.Suspense=p,Oe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ae,Oe.act=z,Oe.cloneElement=function(P,_,V){if(P==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+P+".");var le=N({},P.props),be=P.key,pe=P.ref,de=P._owner;if(_!=null){if(_.ref!==void 0&&(pe=_.ref,de=O.current),_.key!==void 0&&(be=""+_.key),P.type&&P.type.defaultProps)var se=P.type.defaultProps;for(he in _)E.call(_,he)&&!F.hasOwnProperty(he)&&(le[he]=_[he]===void 0&&se!==void 0?se[he]:_[he])}var he=arguments.length-2;if(he===1)le.children=V;else if(1<he){se=Array(he);for(var Le=0;Le<he;Le++)se[Le]=arguments[Le+2];le.children=se}return{$$typeof:t,type:P.type,key:be,ref:pe,props:le,_owner:de}},Oe.createContext=function(P){return P={$$typeof:d,_currentValue:P,_currentValue2:P,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},P.Provider={$$typeof:c,_context:P},P.Consumer=P},Oe.createElement=L,Oe.createFactory=function(P){var _=L.bind(null,P);return _.type=P,_},Oe.createRef=function(){return{current:null}},Oe.forwardRef=function(P){return{$$typeof:u,render:P}},Oe.isValidElement=A,Oe.lazy=function(P){return{$$typeof:g,_payload:{_status:-1,_result:P},_init:X}},Oe.memo=function(P,_){return{$$typeof:f,type:P,compare:_===void 0?null:_}},Oe.startTransition=function(P){var _=Z.transition;Z.transition={};try{P()}finally{Z.transition=_}},Oe.unstable_act=z,Oe.useCallback=function(P,_){return J.current.useCallback(P,_)},Oe.useContext=function(P){return J.current.useContext(P)},Oe.useDebugValue=function(){},Oe.useDeferredValue=function(P){return J.current.useDeferredValue(P)},Oe.useEffect=function(P,_){return J.current.useEffect(P,_)},Oe.useId=function(){return J.current.useId()},Oe.useImperativeHandle=function(P,_,V){return J.current.useImperativeHandle(P,_,V)},Oe.useInsertionEffect=function(P,_){return J.current.useInsertionEffect(P,_)},Oe.useLayoutEffect=function(P,_){return J.current.useLayoutEffect(P,_)},Oe.useMemo=function(P,_){return J.current.useMemo(P,_)},Oe.useReducer=function(P,_,V){return J.current.useReducer(P,_,V)},Oe.useRef=function(P){return J.current.useRef(P)},Oe.useState=function(P){return J.current.useState(P)},Oe.useSyncExternalStore=function(P,_,V){return J.current.useSyncExternalStore(P,_,V)},Oe.useTransition=function(){return J.current.useTransition()},Oe.version="18.3.1",Oe}var Tm;function Iu(){return Tm||(Tm=1,Sc.exports=Ej()),Sc.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 Em;function Rj(){if(Em)return _a;Em=1;var t=Iu(),s=Symbol.for("react.element"),r=Symbol.for("react.fragment"),l=Object.prototype.hasOwnProperty,i=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function d(u,p,f){var g,j={},y=null,k=null;f!==void 0&&(y=""+f),p.key!==void 0&&(y=""+p.key),p.ref!==void 0&&(k=p.ref);for(g in p)l.call(p,g)&&!c.hasOwnProperty(g)&&(j[g]=p[g]);if(u&&u.defaultProps)for(g in p=u.defaultProps,p)j[g]===void 0&&(j[g]=p[g]);return{$$typeof:s,type:u,key:y,ref:k,props:j,_owner:i.current}}return _a.Fragment=r,_a.jsx=d,_a.jsxs=d,_a}var Rm;function Pj(){return Rm||(Rm=1,Nc.exports=Rj()),Nc.exports}var e=Pj(),m=Iu(),mo={},Cc={exports:{}},zt={},$c={exports:{}},Tc={};/**
|
|
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 Pm;function Aj(){return Pm||(Pm=1,(function(t){function s(Z,ae){var z=Z.length;Z.push(ae);e:for(;0<z;){var P=z-1>>>1,_=Z[P];if(0<i(_,ae))Z[P]=ae,Z[z]=_,z=P;else break e}}function r(Z){return Z.length===0?null:Z[0]}function l(Z){if(Z.length===0)return null;var ae=Z[0],z=Z.pop();if(z!==ae){Z[0]=z;e:for(var P=0,_=Z.length,V=_>>>1;P<V;){var le=2*(P+1)-1,be=Z[le],pe=le+1,de=Z[pe];if(0>i(be,z))pe<_&&0>i(de,be)?(Z[P]=de,Z[pe]=z,P=pe):(Z[P]=be,Z[le]=z,P=le);else if(pe<_&&0>i(de,z))Z[P]=de,Z[pe]=z,P=pe;else break e}}return ae}function i(Z,ae){var z=Z.sortIndex-ae.sortIndex;return z!==0?z:Z.id-ae.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 p=[],f=[],g=1,j=null,y=3,k=!1,N=!1,w=!1,b=typeof setTimeout=="function"?setTimeout:null,$=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function T(Z){for(var ae=r(f);ae!==null;){if(ae.callback===null)l(f);else if(ae.startTime<=Z)l(f),ae.sortIndex=ae.expirationTime,s(p,ae);else break;ae=r(f)}}function C(Z){if(w=!1,T(Z),!N)if(r(p)!==null)N=!0,X(E);else{var ae=r(f);ae!==null&&J(C,ae.startTime-Z)}}function E(Z,ae){N=!1,w&&(w=!1,$(L),L=-1),k=!0;var z=y;try{for(T(ae),j=r(p);j!==null&&(!(j.expirationTime>ae)||Z&&!M());){var P=j.callback;if(typeof P=="function"){j.callback=null,y=j.priorityLevel;var _=P(j.expirationTime<=ae);ae=t.unstable_now(),typeof _=="function"?j.callback=_:j===r(p)&&l(p),T(ae)}else l(p);j=r(p)}if(j!==null)var V=!0;else{var le=r(f);le!==null&&J(C,le.startTime-ae),V=!1}return V}finally{j=null,y=z,k=!1}}var O=!1,F=null,L=-1,W=5,A=-1;function M(){return!(t.unstable_now()-A<W)}function Q(){if(F!==null){var Z=t.unstable_now();A=Z;var ae=!0;try{ae=F(!0,Z)}finally{ae?H():(O=!1,F=null)}}else O=!1}var H;if(typeof R=="function")H=function(){R(Q)};else if(typeof MessageChannel<"u"){var U=new MessageChannel,ie=U.port2;U.port1.onmessage=Q,H=function(){ie.postMessage(null)}}else H=function(){b(Q,0)};function X(Z){F=Z,O||(O=!0,H())}function J(Z,ae){L=b(function(){Z(t.unstable_now())},ae)}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(Z){Z.callback=null},t.unstable_continueExecution=function(){N||k||(N=!0,X(E))},t.unstable_forceFrameRate=function(Z){0>Z||125<Z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):W=0<Z?Math.floor(1e3/Z):5},t.unstable_getCurrentPriorityLevel=function(){return y},t.unstable_getFirstCallbackNode=function(){return r(p)},t.unstable_next=function(Z){switch(y){case 1:case 2:case 3:var ae=3;break;default:ae=y}var z=y;y=ae;try{return Z()}finally{y=z}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(Z,ae){switch(Z){case 1:case 2:case 3:case 4:case 5:break;default:Z=3}var z=y;y=Z;try{return ae()}finally{y=z}},t.unstable_scheduleCallback=function(Z,ae,z){var P=t.unstable_now();switch(typeof z=="object"&&z!==null?(z=z.delay,z=typeof z=="number"&&0<z?P+z:P):z=P,Z){case 1:var _=-1;break;case 2:_=250;break;case 5:_=1073741823;break;case 4:_=1e4;break;default:_=5e3}return _=z+_,Z={id:g++,callback:ae,priorityLevel:Z,startTime:z,expirationTime:_,sortIndex:-1},z>P?(Z.sortIndex=z,s(f,Z),r(p)===null&&Z===r(f)&&(w?($(L),L=-1):w=!0,J(C,z-P))):(Z.sortIndex=_,s(p,Z),N||k||(N=!0,X(E))),Z},t.unstable_shouldYield=M,t.unstable_wrapCallback=function(Z){var ae=y;return function(){var z=y;y=ae;try{return Z.apply(this,arguments)}finally{y=z}}}})(Tc)),Tc}var Am;function Ij(){return Am||(Am=1,$c.exports=Aj()),$c.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 Im;function Oj(){if(Im)return zt;Im=1;var t=Iu(),s=Ij();function r(n){for(var a="https://reactjs.org/docs/error-decoder.html?invariant="+n,o=1;o<arguments.length;o++)a+="&args[]="+encodeURIComponent(arguments[o]);return"Minified React error #"+n+"; visit "+a+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var l=new Set,i={};function c(n,a){d(n,a),d(n+"Capture",a)}function d(n,a){for(i[n]=a,n=0;n<a.length;n++)l.add(a[n])}var u=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=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={},j={};function y(n){return p.call(j,n)?!0:p.call(g,n)?!1:f.test(n)?j[n]=!0:(g[n]=!0,!1)}function k(n,a,o,h){if(o!==null&&o.type===0)return!1;switch(typeof a){case"function":case"symbol":return!0;case"boolean":return h?!1:o!==null?!o.acceptsBooleans:(n=n.toLowerCase().slice(0,5),n!=="data-"&&n!=="aria-");default:return!1}}function N(n,a,o,h){if(a===null||typeof a>"u"||k(n,a,o,h))return!0;if(h)return!1;if(o!==null)switch(o.type){case 3:return!a;case 4:return a===!1;case 5:return isNaN(a);case 6:return isNaN(a)||1>a}return!1}function w(n,a,o,h,x,v,S){this.acceptsBooleans=a===2||a===3||a===4,this.attributeName=h,this.attributeNamespace=x,this.mustUseProperty=o,this.propertyName=n,this.type=a,this.sanitizeURL=v,this.removeEmptyString=S}var b={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(n){b[n]=new w(n,0,!1,n,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(n){var a=n[0];b[a]=new w(a,1,!1,n[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(n){b[n]=new w(n,2,!1,n.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(n){b[n]=new w(n,2,!1,n,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(n){b[n]=new w(n,3,!1,n.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(n){b[n]=new w(n,3,!0,n,null,!1,!1)}),["capture","download"].forEach(function(n){b[n]=new w(n,4,!1,n,null,!1,!1)}),["cols","rows","size","span"].forEach(function(n){b[n]=new w(n,6,!1,n,null,!1,!1)}),["rowSpan","start"].forEach(function(n){b[n]=new w(n,5,!1,n.toLowerCase(),null,!1,!1)});var $=/[\-:]([a-z])/g;function R(n){return n[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(n){var a=n.replace($,R);b[a]=new w(a,1,!1,n,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(n){var a=n.replace($,R);b[a]=new w(a,1,!1,n,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(n){var a=n.replace($,R);b[a]=new w(a,1,!1,n,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(n){b[n]=new w(n,1,!1,n.toLowerCase(),null,!1,!1)}),b.xlinkHref=new w("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(n){b[n]=new w(n,1,!1,n.toLowerCase(),null,!0,!0)});function T(n,a,o,h){var x=b.hasOwnProperty(a)?b[a]:null;(x!==null?x.type!==0:h||!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(N(a,o,x,h)&&(o=null),h||x===null?y(a)&&(o===null?n.removeAttribute(a):n.setAttribute(a,""+o)):x.mustUseProperty?n[x.propertyName]=o===null?x.type===3?!1:"":o:(a=x.attributeName,h=x.attributeNamespace,o===null?n.removeAttribute(a):(x=x.type,o=x===3||x===4&&o===!0?"":""+o,h?n.setAttributeNS(h,a,o):n.setAttribute(a,o))))}var C=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,E=Symbol.for("react.element"),O=Symbol.for("react.portal"),F=Symbol.for("react.fragment"),L=Symbol.for("react.strict_mode"),W=Symbol.for("react.profiler"),A=Symbol.for("react.provider"),M=Symbol.for("react.context"),Q=Symbol.for("react.forward_ref"),H=Symbol.for("react.suspense"),U=Symbol.for("react.suspense_list"),ie=Symbol.for("react.memo"),X=Symbol.for("react.lazy"),J=Symbol.for("react.offscreen"),Z=Symbol.iterator;function ae(n){return n===null||typeof n!="object"?null:(n=Z&&n[Z]||n["@@iterator"],typeof n=="function"?n:null)}var z=Object.assign,P;function _(n){if(P===void 0)try{throw Error()}catch(o){var a=o.stack.trim().match(/\n( *(at )?)/);P=a&&a[1]||""}return`
|
|
34
|
-
`+P+n}var V=!1;function le(n,a){if(!n||V)return"";V=!0;var o=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(a)if(a=function(){throw Error()},Object.defineProperty(a.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(a,[])}catch(Y){var h=Y}Reflect.construct(n,[],a)}else{try{a.call()}catch(Y){h=Y}n.call(a.prototype)}else{try{throw Error()}catch(Y){h=Y}n()}}catch(Y){if(Y&&h&&typeof Y.stack=="string"){for(var x=Y.stack.split(`
|
|
35
|
-
`),v=h.stack.split(`
|
|
36
|
-
`),S=x.length-1,I=v.length-1;1<=S&&0<=I&&x[S]!==v[I];)I--;for(;1<=S&&0<=I;S--,I--)if(x[S]!==v[I]){if(S!==1||I!==1)do if(S--,I--,0>I||x[S]!==v[I]){var D=`
|
|
37
|
-
`+x[S].replace(" at new "," at ");return n.displayName&&D.includes("<anonymous>")&&(D=D.replace("<anonymous>",n.displayName)),D}while(1<=S&&0<=I);break}}}finally{V=!1,Error.prepareStackTrace=o}return(n=n?n.displayName||n.name:"")?_(n):""}function be(n){switch(n.tag){case 5:return _(n.type);case 16:return _("Lazy");case 13:return _("Suspense");case 19:return _("SuspenseList");case 0:case 2:case 15:return n=le(n.type,!1),n;case 11:return n=le(n.type.render,!1),n;case 1:return n=le(n.type,!0),n;default:return""}}function pe(n){if(n==null)return null;if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case F:return"Fragment";case O:return"Portal";case W:return"Profiler";case L:return"StrictMode";case H:return"Suspense";case U:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case M:return(n.displayName||"Context")+".Consumer";case A:return(n._context.displayName||"Context")+".Provider";case Q:var a=n.render;return n=n.displayName,n||(n=a.displayName||a.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case ie:return a=n.displayName||null,a!==null?a:pe(n.type)||"Memo";case X:a=n._payload,n=n._init;try{return pe(n(a))}catch{}}return null}function de(n){var a=n.type;switch(n.tag){case 24:return"Cache";case 9:return(a.displayName||"Context")+".Consumer";case 10:return(a._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return n=a.render,n=n.displayName||n.name||"",a.displayName||(n!==""?"ForwardRef("+n+")":"ForwardRef");case 7:return"Fragment";case 5:return a;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return pe(a);case 8:return a===L?"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 a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a}return null}function se(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function he(n){var a=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function Le(n){var a=he(n)?"checked":"value",o=Object.getOwnPropertyDescriptor(n.constructor.prototype,a),h=""+n[a];if(!n.hasOwnProperty(a)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var x=o.get,v=o.set;return Object.defineProperty(n,a,{configurable:!0,get:function(){return x.call(this)},set:function(S){h=""+S,v.call(this,S)}}),Object.defineProperty(n,a,{enumerable:o.enumerable}),{getValue:function(){return h},setValue:function(S){h=""+S},stopTracking:function(){n._valueTracker=null,delete n[a]}}}}function Ye(n){n._valueTracker||(n._valueTracker=Le(n))}function Tt(n){if(!n)return!1;var a=n._valueTracker;if(!a)return!0;var o=a.getValue(),h="";return n&&(h=he(n)?n.checked?"true":"false":n.value),n=h,n!==o?(a.setValue(n),!0):!1}function tt(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}function rs(n,a){var o=a.checked;return z({},a,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:o??n._wrapperState.initialChecked})}function Fe(n,a){var o=a.defaultValue==null?"":a.defaultValue,h=a.checked!=null?a.checked:a.defaultChecked;o=se(a.value!=null?a.value:o),n._wrapperState={initialChecked:h,initialValue:o,controlled:a.type==="checkbox"||a.type==="radio"?a.checked!=null:a.value!=null}}function mr(n,a){a=a.checked,a!=null&&T(n,"checked",a,!1)}function en(n,a){mr(n,a);var o=se(a.value),h=a.type;if(o!=null)h==="number"?(o===0&&n.value===""||n.value!=o)&&(n.value=""+o):n.value!==""+o&&(n.value=""+o);else if(h==="submit"||h==="reset"){n.removeAttribute("value");return}a.hasOwnProperty("value")?Et(n,a.type,o):a.hasOwnProperty("defaultValue")&&Et(n,a.type,se(a.defaultValue)),a.checked==null&&a.defaultChecked!=null&&(n.defaultChecked=!!a.defaultChecked)}function as(n,a,o){if(a.hasOwnProperty("value")||a.hasOwnProperty("defaultValue")){var h=a.type;if(!(h!=="submit"&&h!=="reset"||a.value!==void 0&&a.value!==null))return;a=""+n._wrapperState.initialValue,o||a===n.value||(n.value=a),n.defaultValue=a}o=n.name,o!==""&&(n.name=""),n.defaultChecked=!!n._wrapperState.initialChecked,o!==""&&(n.name=o)}function Et(n,a,o){(a!=="number"||tt(n.ownerDocument)!==n)&&(o==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+o&&(n.defaultValue=""+o))}var tn=Array.isArray;function wt(n,a,o,h){if(n=n.options,a){a={};for(var x=0;x<o.length;x++)a["$"+o[x]]=!0;for(o=0;o<n.length;o++)x=a.hasOwnProperty("$"+n[o].value),n[o].selected!==x&&(n[o].selected=x),x&&h&&(n[o].defaultSelected=!0)}else{for(o=""+se(o),a=null,x=0;x<n.length;x++){if(n[x].value===o){n[x].selected=!0,h&&(n[x].defaultSelected=!0);return}a!==null||n[x].disabled||(a=n[x])}a!==null&&(a.selected=!0)}}function Bn(n,a){if(a.dangerouslySetInnerHTML!=null)throw Error(r(91));return z({},a,{value:void 0,defaultValue:void 0,children:""+n._wrapperState.initialValue})}function ls(n,a){var o=a.value;if(o==null){if(o=a.children,a=a.defaultValue,o!=null){if(a!=null)throw Error(r(92));if(tn(o)){if(1<o.length)throw Error(r(93));o=o[0]}a=o}a==null&&(a=""),o=a}n._wrapperState={initialValue:se(o)}}function os(n,a){var o=se(a.value),h=se(a.defaultValue);o!=null&&(o=""+o,o!==n.value&&(n.value=o),a.defaultValue==null&&n.defaultValue!==o&&(n.defaultValue=o)),h!=null&&(n.defaultValue=""+h)}function nn(n){var a=n.textContent;a===n._wrapperState.initialValue&&a!==""&&a!==null&&(n.value=a)}function is(n){switch(n){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 sn(n,a){return n==null||n==="http://www.w3.org/1999/xhtml"?is(a):n==="http://www.w3.org/2000/svg"&&a==="foreignObject"?"http://www.w3.org/1999/xhtml":n}var at,En=(function(n){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(a,o,h,x){MSApp.execUnsafeLocalFunction(function(){return n(a,o,h,x)})}:n})(function(n,a){if(n.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in n)n.innerHTML=a;else{for(at=at||document.createElement("div"),at.innerHTML="<svg>"+a.valueOf().toString()+"</svg>",a=at.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;a.firstChild;)n.appendChild(a.firstChild)}});function He(n,a){if(a){var o=n.firstChild;if(o&&o===n.lastChild&&o.nodeType===3){o.nodeValue=a;return}}n.textContent=a}var Rn={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},zn=["Webkit","ms","Moz","O"];Object.keys(Rn).forEach(function(n){zn.forEach(function(a){a=a+n.charAt(0).toUpperCase()+n.substring(1),Rn[a]=Rn[n]})});function gn(n,a,o){return a==null||typeof a=="boolean"||a===""?"":o||typeof a!="number"||a===0||Rn.hasOwnProperty(n)&&Rn[n]?(""+a).trim():a+"px"}function nt(n,a){n=n.style;for(var o in a)if(a.hasOwnProperty(o)){var h=o.indexOf("--")===0,x=gn(o,a[o],h);o==="float"&&(o="cssFloat"),h?n.setProperty(o,x):n[o]=x}}var xn=z({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 Pn(n,a){if(a){if(xn[n]&&(a.children!=null||a.dangerouslySetInnerHTML!=null))throw Error(r(137,n));if(a.dangerouslySetInnerHTML!=null){if(a.children!=null)throw Error(r(60));if(typeof a.dangerouslySetInnerHTML!="object"||!("__html"in a.dangerouslySetInnerHTML))throw Error(r(61))}if(a.style!=null&&typeof a.style!="object")throw Error(r(62))}}function Rt(n,a){if(n.indexOf("-")===-1)return typeof a.is=="string";switch(n){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 An=null;function In(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var Wn=null,jn=null,rn=null;function an(n){if(n=ba(n)){if(typeof Wn!="function")throw Error(r(280));var a=n.stateNode;a&&(a=$l(a),Wn(n.stateNode,n.type,a))}}function Wt(n){jn?rn?rn.push(n):rn=[n]:jn=n}function bt(){if(jn){var n=jn,a=rn;if(rn=jn=null,an(n),a)for(n=0;n<a.length;n++)an(a[n])}}function Ae(n,a){return n(a)}function cs(){}var us=!1;function ds(n,a,o){if(us)return n(a,o);us=!0;try{return Ae(n,a,o)}finally{us=!1,(jn!==null||rn!==null)&&(cs(),bt())}}function ue(n,a){var o=n.stateNode;if(o===null)return null;var h=$l(o);if(h===null)return null;o=h[a];e:switch(a){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(h=!h.disabled)||(n=n.type,h=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!h;break e;default:n=!1}if(n)return null;if(o&&typeof o!="function")throw Error(r(231,a,typeof o));return o}var Ge=!1;if(u)try{var Pt={};Object.defineProperty(Pt,"passive",{get:function(){Ge=!0}}),window.addEventListener("test",Pt,Pt),window.removeEventListener("test",Pt,Pt)}catch{Ge=!1}function hs(n,a,o,h,x,v,S,I,D){var Y=Array.prototype.slice.call(arguments,3);try{a.apply(o,Y)}catch(ne){this.onError(ne)}}var ln=!1,mt=null,ms=!1,pt=null,lt={onError:function(n){ln=!0,mt=n}};function ps(n,a,o,h,x,v,S,I,D){ln=!1,mt=null,hs.apply(lt,arguments)}function On(n,a,o,h,x,v,S,I,D){if(ps.apply(this,arguments),ln){if(ln){var Y=mt;ln=!1,mt=null}else throw Error(r(198));ms||(ms=!0,pt=Y)}}function Ft(n){var a=n,o=n;if(n.alternate)for(;a.return;)a=a.return;else{n=a;do a=n,(a.flags&4098)!==0&&(o=a.return),n=a.return;while(n)}return a.tag===3?o:null}function pr(n){if(n.tag===13){var a=n.memoizedState;if(a===null&&(n=n.alternate,n!==null&&(a=n.memoizedState)),a!==null)return a.dehydrated}return null}function Zr(n){if(Ft(n)!==n)throw Error(r(188))}function ea(n){var a=n.alternate;if(!a){if(a=Ft(n),a===null)throw Error(r(188));return a!==n?null:n}for(var o=n,h=a;;){var x=o.return;if(x===null)break;var v=x.alternate;if(v===null){if(h=x.return,h!==null){o=h;continue}break}if(x.child===v.child){for(v=x.child;v;){if(v===o)return Zr(x),n;if(v===h)return Zr(x),a;v=v.sibling}throw Error(r(188))}if(o.return!==h.return)o=x,h=v;else{for(var S=!1,I=x.child;I;){if(I===o){S=!0,o=x,h=v;break}if(I===h){S=!0,h=x,o=v;break}I=I.sibling}if(!S){for(I=v.child;I;){if(I===o){S=!0,o=v,h=x;break}if(I===h){S=!0,h=v,o=x;break}I=I.sibling}if(!S)throw Error(r(189))}}if(o.alternate!==h)throw Error(r(190))}if(o.tag!==3)throw Error(r(188));return o.stateNode.current===o?n:a}function rl(n){return n=ea(n),n!==null?ta(n):null}function ta(n){if(n.tag===5||n.tag===6)return n;for(n=n.child;n!==null;){var a=ta(n);if(a!==null)return a;n=n.sibling}return null}var na=s.unstable_scheduleCallback,sa=s.unstable_cancelCallback,zo=s.unstable_shouldYield,al=s.unstable_requestPaint,ze=s.unstable_now,Wo=s.unstable_getCurrentPriorityLevel,ra=s.unstable_ImmediatePriority,ll=s.unstable_UserBlockingPriority,qs=s.unstable_NormalPriority,ol=s.unstable_LowPriority,aa=s.unstable_IdlePriority,Bs=null,Ht=null;function il(n){if(Ht&&typeof Ht.onCommitFiberRoot=="function")try{Ht.onCommitFiberRoot(Bs,n,void 0,(n.current.flags&128)===128)}catch{}}var Mt=Math.clz32?Math.clz32:ee,cl=Math.log,ul=Math.LN2;function ee(n){return n>>>=0,n===0?32:31-(cl(n)/ul|0)|0}var Re=64,_e=4194304;function yn(n){switch(n&-n){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 n&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return n&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return n}}function dl(n,a){var o=n.pendingLanes;if(o===0)return 0;var h=0,x=n.suspendedLanes,v=n.pingedLanes,S=o&268435455;if(S!==0){var I=S&~x;I!==0?h=yn(I):(v&=S,v!==0&&(h=yn(v)))}else S=o&~x,S!==0?h=yn(S):v!==0&&(h=yn(v));if(h===0)return 0;if(a!==0&&a!==h&&(a&x)===0&&(x=h&-h,v=a&-a,x>=v||x===16&&(v&4194240)!==0))return a;if((h&4)!==0&&(h|=o&16),a=n.entangledLanes,a!==0)for(n=n.entanglements,a&=h;0<a;)o=31-Mt(a),x=1<<o,h|=n[o],a&=~x;return h}function Gg(n,a){switch(n){case 1:case 2:case 4:return a+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 a+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 Kg(n,a){for(var o=n.suspendedLanes,h=n.pingedLanes,x=n.expirationTimes,v=n.pendingLanes;0<v;){var S=31-Mt(v),I=1<<S,D=x[S];D===-1?((I&o)===0||(I&h)!==0)&&(x[S]=Gg(I,a)):D<=a&&(n.expiredLanes|=I),v&=~I}}function Ho(n){return n=n.pendingLanes&-1073741825,n!==0?n:n&1073741824?1073741824:0}function sd(){var n=Re;return Re<<=1,(Re&4194240)===0&&(Re=64),n}function Go(n){for(var a=[],o=0;31>o;o++)a.push(n);return a}function la(n,a,o){n.pendingLanes|=a,a!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,a=31-Mt(a),n[a]=o}function Vg(n,a){var o=n.pendingLanes&~a;n.pendingLanes=a,n.suspendedLanes=0,n.pingedLanes=0,n.expiredLanes&=a,n.mutableReadLanes&=a,n.entangledLanes&=a,a=n.entanglements;var h=n.eventTimes;for(n=n.expirationTimes;0<o;){var x=31-Mt(o),v=1<<x;a[x]=0,h[x]=-1,n[x]=-1,o&=~v}}function Ko(n,a){var o=n.entangledLanes|=a;for(n=n.entanglements;o;){var h=31-Mt(o),x=1<<h;x&a|n[h]&a&&(n[h]|=a),o&=~x}}var Be=0;function rd(n){return n&=-n,1<n?4<n?(n&268435455)!==0?16:536870912:4:1}var ad,Vo,ld,od,id,Yo=!1,hl=[],fs=null,gs=null,xs=null,oa=new Map,ia=new Map,js=[],Yg="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 cd(n,a){switch(n){case"focusin":case"focusout":fs=null;break;case"dragenter":case"dragleave":gs=null;break;case"mouseover":case"mouseout":xs=null;break;case"pointerover":case"pointerout":oa.delete(a.pointerId);break;case"gotpointercapture":case"lostpointercapture":ia.delete(a.pointerId)}}function ca(n,a,o,h,x,v){return n===null||n.nativeEvent!==v?(n={blockedOn:a,domEventName:o,eventSystemFlags:h,nativeEvent:v,targetContainers:[x]},a!==null&&(a=ba(a),a!==null&&Vo(a)),n):(n.eventSystemFlags|=h,a=n.targetContainers,x!==null&&a.indexOf(x)===-1&&a.push(x),n)}function Qg(n,a,o,h,x){switch(a){case"focusin":return fs=ca(fs,n,a,o,h,x),!0;case"dragenter":return gs=ca(gs,n,a,o,h,x),!0;case"mouseover":return xs=ca(xs,n,a,o,h,x),!0;case"pointerover":var v=x.pointerId;return oa.set(v,ca(oa.get(v)||null,n,a,o,h,x)),!0;case"gotpointercapture":return v=x.pointerId,ia.set(v,ca(ia.get(v)||null,n,a,o,h,x)),!0}return!1}function ud(n){var a=zs(n.target);if(a!==null){var o=Ft(a);if(o!==null){if(a=o.tag,a===13){if(a=pr(o),a!==null){n.blockedOn=a,id(n.priority,function(){ld(o)});return}}else if(a===3&&o.stateNode.current.memoizedState.isDehydrated){n.blockedOn=o.tag===3?o.stateNode.containerInfo:null;return}}}n.blockedOn=null}function ml(n){if(n.blockedOn!==null)return!1;for(var a=n.targetContainers;0<a.length;){var o=Jo(n.domEventName,n.eventSystemFlags,a[0],n.nativeEvent);if(o===null){o=n.nativeEvent;var h=new o.constructor(o.type,o);An=h,o.target.dispatchEvent(h),An=null}else return a=ba(o),a!==null&&Vo(a),n.blockedOn=o,!1;a.shift()}return!0}function dd(n,a,o){ml(n)&&o.delete(a)}function Jg(){Yo=!1,fs!==null&&ml(fs)&&(fs=null),gs!==null&&ml(gs)&&(gs=null),xs!==null&&ml(xs)&&(xs=null),oa.forEach(dd),ia.forEach(dd)}function ua(n,a){n.blockedOn===a&&(n.blockedOn=null,Yo||(Yo=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,Jg)))}function da(n){function a(x){return ua(x,n)}if(0<hl.length){ua(hl[0],n);for(var o=1;o<hl.length;o++){var h=hl[o];h.blockedOn===n&&(h.blockedOn=null)}}for(fs!==null&&ua(fs,n),gs!==null&&ua(gs,n),xs!==null&&ua(xs,n),oa.forEach(a),ia.forEach(a),o=0;o<js.length;o++)h=js[o],h.blockedOn===n&&(h.blockedOn=null);for(;0<js.length&&(o=js[0],o.blockedOn===null);)ud(o),o.blockedOn===null&&js.shift()}var fr=C.ReactCurrentBatchConfig,pl=!0;function Xg(n,a,o,h){var x=Be,v=fr.transition;fr.transition=null;try{Be=1,Qo(n,a,o,h)}finally{Be=x,fr.transition=v}}function Zg(n,a,o,h){var x=Be,v=fr.transition;fr.transition=null;try{Be=4,Qo(n,a,o,h)}finally{Be=x,fr.transition=v}}function Qo(n,a,o,h){if(pl){var x=Jo(n,a,o,h);if(x===null)pi(n,a,h,fl,o),cd(n,h);else if(Qg(x,n,a,o,h))h.stopPropagation();else if(cd(n,h),a&4&&-1<Yg.indexOf(n)){for(;x!==null;){var v=ba(x);if(v!==null&&ad(v),v=Jo(n,a,o,h),v===null&&pi(n,a,h,fl,o),v===x)break;x=v}x!==null&&h.stopPropagation()}else pi(n,a,h,null,o)}}var fl=null;function Jo(n,a,o,h){if(fl=null,n=In(h),n=zs(n),n!==null)if(a=Ft(n),a===null)n=null;else if(o=a.tag,o===13){if(n=pr(a),n!==null)return n;n=null}else if(o===3){if(a.stateNode.current.memoizedState.isDehydrated)return a.tag===3?a.stateNode.containerInfo:null;n=null}else a!==n&&(n=null);return fl=n,null}function hd(n){switch(n){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(Wo()){case ra:return 1;case ll:return 4;case qs:case ol:return 16;case aa:return 536870912;default:return 16}default:return 16}}var ys=null,Xo=null,gl=null;function md(){if(gl)return gl;var n,a=Xo,o=a.length,h,x="value"in ys?ys.value:ys.textContent,v=x.length;for(n=0;n<o&&a[n]===x[n];n++);var S=o-n;for(h=1;h<=S&&a[o-h]===x[v-h];h++);return gl=x.slice(n,1<h?1-h:void 0)}function xl(n){var a=n.keyCode;return"charCode"in n?(n=n.charCode,n===0&&a===13&&(n=13)):n=a,n===10&&(n=13),32<=n||n===13?n:0}function jl(){return!0}function pd(){return!1}function Gt(n){function a(o,h,x,v,S){this._reactName=o,this._targetInst=x,this.type=h,this.nativeEvent=v,this.target=S,this.currentTarget=null;for(var I in n)n.hasOwnProperty(I)&&(o=n[I],this[I]=o?o(v):v[I]);return this.isDefaultPrevented=(v.defaultPrevented!=null?v.defaultPrevented:v.returnValue===!1)?jl:pd,this.isPropagationStopped=pd,this}return z(a.prototype,{preventDefault:function(){this.defaultPrevented=!0;var o=this.nativeEvent;o&&(o.preventDefault?o.preventDefault():typeof o.returnValue!="unknown"&&(o.returnValue=!1),this.isDefaultPrevented=jl)},stopPropagation:function(){var o=this.nativeEvent;o&&(o.stopPropagation?o.stopPropagation():typeof o.cancelBubble!="unknown"&&(o.cancelBubble=!0),this.isPropagationStopped=jl)},persist:function(){},isPersistent:jl}),a}var gr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Zo=Gt(gr),ha=z({},gr,{view:0,detail:0}),ex=Gt(ha),ei,ti,ma,yl=z({},ha,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:si,button:0,buttons:0,relatedTarget:function(n){return n.relatedTarget===void 0?n.fromElement===n.srcElement?n.toElement:n.fromElement:n.relatedTarget},movementX:function(n){return"movementX"in n?n.movementX:(n!==ma&&(ma&&n.type==="mousemove"?(ei=n.screenX-ma.screenX,ti=n.screenY-ma.screenY):ti=ei=0,ma=n),ei)},movementY:function(n){return"movementY"in n?n.movementY:ti}}),fd=Gt(yl),tx=z({},yl,{dataTransfer:0}),nx=Gt(tx),sx=z({},ha,{relatedTarget:0}),ni=Gt(sx),rx=z({},gr,{animationName:0,elapsedTime:0,pseudoElement:0}),ax=Gt(rx),lx=z({},gr,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),ox=Gt(lx),ix=z({},gr,{data:0}),gd=Gt(ix),cx={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},ux={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"},dx={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function hx(n){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(n):(n=dx[n])?!!a[n]:!1}function si(){return hx}var mx=z({},ha,{key:function(n){if(n.key){var a=cx[n.key]||n.key;if(a!=="Unidentified")return a}return n.type==="keypress"?(n=xl(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?ux[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:si,charCode:function(n){return n.type==="keypress"?xl(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?xl(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),px=Gt(mx),fx=z({},yl,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),xd=Gt(fx),gx=z({},ha,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:si}),xx=Gt(gx),jx=z({},gr,{propertyName:0,elapsedTime:0,pseudoElement:0}),yx=Gt(jx),vx=z({},yl,{deltaX:function(n){return"deltaX"in n?n.deltaX:"wheelDeltaX"in n?-n.wheelDeltaX:0},deltaY:function(n){return"deltaY"in n?n.deltaY:"wheelDeltaY"in n?-n.wheelDeltaY:"wheelDelta"in n?-n.wheelDelta:0},deltaZ:0,deltaMode:0}),kx=Gt(vx),wx=[9,13,27,32],ri=u&&"CompositionEvent"in window,pa=null;u&&"documentMode"in document&&(pa=document.documentMode);var bx=u&&"TextEvent"in window&&!pa,jd=u&&(!ri||pa&&8<pa&&11>=pa),yd=" ",vd=!1;function kd(n,a){switch(n){case"keyup":return wx.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function wd(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var xr=!1;function Nx(n,a){switch(n){case"compositionend":return wd(a);case"keypress":return a.which!==32?null:(vd=!0,yd);case"textInput":return n=a.data,n===yd&&vd?null:n;default:return null}}function Sx(n,a){if(xr)return n==="compositionend"||!ri&&kd(n,a)?(n=md(),gl=Xo=ys=null,xr=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(a.ctrlKey||a.altKey||a.metaKey)||a.ctrlKey&&a.altKey){if(a.char&&1<a.char.length)return a.char;if(a.which)return String.fromCharCode(a.which)}return null;case"compositionend":return jd&&a.locale!=="ko"?null:a.data;default:return null}}var Cx={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 bd(n){var a=n&&n.nodeName&&n.nodeName.toLowerCase();return a==="input"?!!Cx[n.type]:a==="textarea"}function Nd(n,a,o,h){Wt(h),a=Nl(a,"onChange"),0<a.length&&(o=new Zo("onChange","change",null,o,h),n.push({event:o,listeners:a}))}var fa=null,ga=null;function $x(n){Bd(n,0)}function vl(n){var a=wr(n);if(Tt(a))return n}function Tx(n,a){if(n==="change")return a}var Sd=!1;if(u){var ai;if(u){var li="oninput"in document;if(!li){var Cd=document.createElement("div");Cd.setAttribute("oninput","return;"),li=typeof Cd.oninput=="function"}ai=li}else ai=!1;Sd=ai&&(!document.documentMode||9<document.documentMode)}function $d(){fa&&(fa.detachEvent("onpropertychange",Td),ga=fa=null)}function Td(n){if(n.propertyName==="value"&&vl(ga)){var a=[];Nd(a,ga,n,In(n)),ds($x,a)}}function Ex(n,a,o){n==="focusin"?($d(),fa=a,ga=o,fa.attachEvent("onpropertychange",Td)):n==="focusout"&&$d()}function Rx(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return vl(ga)}function Px(n,a){if(n==="click")return vl(a)}function Ax(n,a){if(n==="input"||n==="change")return vl(a)}function Ix(n,a){return n===a&&(n!==0||1/n===1/a)||n!==n&&a!==a}var vn=typeof Object.is=="function"?Object.is:Ix;function xa(n,a){if(vn(n,a))return!0;if(typeof n!="object"||n===null||typeof a!="object"||a===null)return!1;var o=Object.keys(n),h=Object.keys(a);if(o.length!==h.length)return!1;for(h=0;h<o.length;h++){var x=o[h];if(!p.call(a,x)||!vn(n[x],a[x]))return!1}return!0}function Ed(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function Rd(n,a){var o=Ed(n);n=0;for(var h;o;){if(o.nodeType===3){if(h=n+o.textContent.length,n<=a&&h>=a)return{node:o,offset:a-n};n=h}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=Ed(o)}}function Pd(n,a){return n&&a?n===a?!0:n&&n.nodeType===3?!1:a&&a.nodeType===3?Pd(n,a.parentNode):"contains"in n?n.contains(a):n.compareDocumentPosition?!!(n.compareDocumentPosition(a)&16):!1:!1}function Ad(){for(var n=window,a=tt();a instanceof n.HTMLIFrameElement;){try{var o=typeof a.contentWindow.location.href=="string"}catch{o=!1}if(o)n=a.contentWindow;else break;a=tt(n.document)}return a}function oi(n){var a=n&&n.nodeName&&n.nodeName.toLowerCase();return a&&(a==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||a==="textarea"||n.contentEditable==="true")}function Ox(n){var a=Ad(),o=n.focusedElem,h=n.selectionRange;if(a!==o&&o&&o.ownerDocument&&Pd(o.ownerDocument.documentElement,o)){if(h!==null&&oi(o)){if(a=h.start,n=h.end,n===void 0&&(n=a),"selectionStart"in o)o.selectionStart=a,o.selectionEnd=Math.min(n,o.value.length);else if(n=(a=o.ownerDocument||document)&&a.defaultView||window,n.getSelection){n=n.getSelection();var x=o.textContent.length,v=Math.min(h.start,x);h=h.end===void 0?v:Math.min(h.end,x),!n.extend&&v>h&&(x=h,h=v,v=x),x=Rd(o,v);var S=Rd(o,h);x&&S&&(n.rangeCount!==1||n.anchorNode!==x.node||n.anchorOffset!==x.offset||n.focusNode!==S.node||n.focusOffset!==S.offset)&&(a=a.createRange(),a.setStart(x.node,x.offset),n.removeAllRanges(),v>h?(n.addRange(a),n.extend(S.node,S.offset)):(a.setEnd(S.node,S.offset),n.addRange(a)))}}for(a=[],n=o;n=n.parentNode;)n.nodeType===1&&a.push({element:n,left:n.scrollLeft,top:n.scrollTop});for(typeof o.focus=="function"&&o.focus(),o=0;o<a.length;o++)n=a[o],n.element.scrollLeft=n.left,n.element.scrollTop=n.top}}var Lx=u&&"documentMode"in document&&11>=document.documentMode,jr=null,ii=null,ja=null,ci=!1;function Id(n,a,o){var h=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;ci||jr==null||jr!==tt(h)||(h=jr,"selectionStart"in h&&oi(h)?h={start:h.selectionStart,end:h.selectionEnd}:(h=(h.ownerDocument&&h.ownerDocument.defaultView||window).getSelection(),h={anchorNode:h.anchorNode,anchorOffset:h.anchorOffset,focusNode:h.focusNode,focusOffset:h.focusOffset}),ja&&xa(ja,h)||(ja=h,h=Nl(ii,"onSelect"),0<h.length&&(a=new Zo("onSelect","select",null,a,o),n.push({event:a,listeners:h}),a.target=jr)))}function kl(n,a){var o={};return o[n.toLowerCase()]=a.toLowerCase(),o["Webkit"+n]="webkit"+a,o["Moz"+n]="moz"+a,o}var yr={animationend:kl("Animation","AnimationEnd"),animationiteration:kl("Animation","AnimationIteration"),animationstart:kl("Animation","AnimationStart"),transitionend:kl("Transition","TransitionEnd")},ui={},Od={};u&&(Od=document.createElement("div").style,"AnimationEvent"in window||(delete yr.animationend.animation,delete yr.animationiteration.animation,delete yr.animationstart.animation),"TransitionEvent"in window||delete yr.transitionend.transition);function wl(n){if(ui[n])return ui[n];if(!yr[n])return n;var a=yr[n],o;for(o in a)if(a.hasOwnProperty(o)&&o in Od)return ui[n]=a[o];return n}var Ld=wl("animationend"),Fd=wl("animationiteration"),Md=wl("animationstart"),_d=wl("transitionend"),Dd=new Map,Ud="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 vs(n,a){Dd.set(n,a),c(a,[n])}for(var di=0;di<Ud.length;di++){var hi=Ud[di],Fx=hi.toLowerCase(),Mx=hi[0].toUpperCase()+hi.slice(1);vs(Fx,"on"+Mx)}vs(Ld,"onAnimationEnd"),vs(Fd,"onAnimationIteration"),vs(Md,"onAnimationStart"),vs("dblclick","onDoubleClick"),vs("focusin","onFocus"),vs("focusout","onBlur"),vs(_d,"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 ya="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(" "),_x=new Set("cancel close invalid load scroll toggle".split(" ").concat(ya));function qd(n,a,o){var h=n.type||"unknown-event";n.currentTarget=o,On(h,a,void 0,n),n.currentTarget=null}function Bd(n,a){a=(a&4)!==0;for(var o=0;o<n.length;o++){var h=n[o],x=h.event;h=h.listeners;e:{var v=void 0;if(a)for(var S=h.length-1;0<=S;S--){var I=h[S],D=I.instance,Y=I.currentTarget;if(I=I.listener,D!==v&&x.isPropagationStopped())break e;qd(x,I,Y),v=D}else for(S=0;S<h.length;S++){if(I=h[S],D=I.instance,Y=I.currentTarget,I=I.listener,D!==v&&x.isPropagationStopped())break e;qd(x,I,Y),v=D}}}if(ms)throw n=pt,ms=!1,pt=null,n}function Ke(n,a){var o=a[vi];o===void 0&&(o=a[vi]=new Set);var h=n+"__bubble";o.has(h)||(zd(a,n,2,!1),o.add(h))}function mi(n,a,o){var h=0;a&&(h|=4),zd(o,n,h,a)}var bl="_reactListening"+Math.random().toString(36).slice(2);function va(n){if(!n[bl]){n[bl]=!0,l.forEach(function(o){o!=="selectionchange"&&(_x.has(o)||mi(o,!1,n),mi(o,!0,n))});var a=n.nodeType===9?n:n.ownerDocument;a===null||a[bl]||(a[bl]=!0,mi("selectionchange",!1,a))}}function zd(n,a,o,h){switch(hd(a)){case 1:var x=Xg;break;case 4:x=Zg;break;default:x=Qo}o=x.bind(null,a,o,n),x=void 0,!Ge||a!=="touchstart"&&a!=="touchmove"&&a!=="wheel"||(x=!0),h?x!==void 0?n.addEventListener(a,o,{capture:!0,passive:x}):n.addEventListener(a,o,!0):x!==void 0?n.addEventListener(a,o,{passive:x}):n.addEventListener(a,o,!1)}function pi(n,a,o,h,x){var v=h;if((a&1)===0&&(a&2)===0&&h!==null)e:for(;;){if(h===null)return;var S=h.tag;if(S===3||S===4){var I=h.stateNode.containerInfo;if(I===x||I.nodeType===8&&I.parentNode===x)break;if(S===4)for(S=h.return;S!==null;){var D=S.tag;if((D===3||D===4)&&(D=S.stateNode.containerInfo,D===x||D.nodeType===8&&D.parentNode===x))return;S=S.return}for(;I!==null;){if(S=zs(I),S===null)return;if(D=S.tag,D===5||D===6){h=v=S;continue e}I=I.parentNode}}h=h.return}ds(function(){var Y=v,ne=In(o),re=[];e:{var te=Dd.get(n);if(te!==void 0){var me=Zo,xe=n;switch(n){case"keypress":if(xl(o)===0)break e;case"keydown":case"keyup":me=px;break;case"focusin":xe="focus",me=ni;break;case"focusout":xe="blur",me=ni;break;case"beforeblur":case"afterblur":me=ni;break;case"click":if(o.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":me=fd;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":me=nx;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":me=xx;break;case Ld:case Fd:case Md:me=ax;break;case _d:me=yx;break;case"scroll":me=ex;break;case"wheel":me=kx;break;case"copy":case"cut":case"paste":me=ox;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":me=xd}var je=(a&4)!==0,ot=!je&&n==="scroll",G=je?te!==null?te+"Capture":null:te;je=[];for(var q=Y,K;q!==null;){K=q;var oe=K.stateNode;if(K.tag===5&&oe!==null&&(K=oe,G!==null&&(oe=ue(q,G),oe!=null&&je.push(ka(q,oe,K)))),ot)break;q=q.return}0<je.length&&(te=new me(te,xe,null,o,ne),re.push({event:te,listeners:je}))}}if((a&7)===0){e:{if(te=n==="mouseover"||n==="pointerover",me=n==="mouseout"||n==="pointerout",te&&o!==An&&(xe=o.relatedTarget||o.fromElement)&&(zs(xe)||xe[Hn]))break e;if((me||te)&&(te=ne.window===ne?ne:(te=ne.ownerDocument)?te.defaultView||te.parentWindow:window,me?(xe=o.relatedTarget||o.toElement,me=Y,xe=xe?zs(xe):null,xe!==null&&(ot=Ft(xe),xe!==ot||xe.tag!==5&&xe.tag!==6)&&(xe=null)):(me=null,xe=Y),me!==xe)){if(je=fd,oe="onMouseLeave",G="onMouseEnter",q="mouse",(n==="pointerout"||n==="pointerover")&&(je=xd,oe="onPointerLeave",G="onPointerEnter",q="pointer"),ot=me==null?te:wr(me),K=xe==null?te:wr(xe),te=new je(oe,q+"leave",me,o,ne),te.target=ot,te.relatedTarget=K,oe=null,zs(ne)===Y&&(je=new je(G,q+"enter",xe,o,ne),je.target=K,je.relatedTarget=ot,oe=je),ot=oe,me&&xe)t:{for(je=me,G=xe,q=0,K=je;K;K=vr(K))q++;for(K=0,oe=G;oe;oe=vr(oe))K++;for(;0<q-K;)je=vr(je),q--;for(;0<K-q;)G=vr(G),K--;for(;q--;){if(je===G||G!==null&&je===G.alternate)break t;je=vr(je),G=vr(G)}je=null}else je=null;me!==null&&Wd(re,te,me,je,!1),xe!==null&&ot!==null&&Wd(re,ot,xe,je,!0)}}e:{if(te=Y?wr(Y):window,me=te.nodeName&&te.nodeName.toLowerCase(),me==="select"||me==="input"&&te.type==="file")var ye=Tx;else if(bd(te))if(Sd)ye=Ax;else{ye=Rx;var Se=Ex}else(me=te.nodeName)&&me.toLowerCase()==="input"&&(te.type==="checkbox"||te.type==="radio")&&(ye=Px);if(ye&&(ye=ye(n,Y))){Nd(re,ye,o,ne);break e}Se&&Se(n,te,Y),n==="focusout"&&(Se=te._wrapperState)&&Se.controlled&&te.type==="number"&&Et(te,"number",te.value)}switch(Se=Y?wr(Y):window,n){case"focusin":(bd(Se)||Se.contentEditable==="true")&&(jr=Se,ii=Y,ja=null);break;case"focusout":ja=ii=jr=null;break;case"mousedown":ci=!0;break;case"contextmenu":case"mouseup":case"dragend":ci=!1,Id(re,o,ne);break;case"selectionchange":if(Lx)break;case"keydown":case"keyup":Id(re,o,ne)}var Ce;if(ri)e:{switch(n){case"compositionstart":var Te="onCompositionStart";break e;case"compositionend":Te="onCompositionEnd";break e;case"compositionupdate":Te="onCompositionUpdate";break e}Te=void 0}else xr?kd(n,o)&&(Te="onCompositionEnd"):n==="keydown"&&o.keyCode===229&&(Te="onCompositionStart");Te&&(jd&&o.locale!=="ko"&&(xr||Te!=="onCompositionStart"?Te==="onCompositionEnd"&&xr&&(Ce=md()):(ys=ne,Xo="value"in ys?ys.value:ys.textContent,xr=!0)),Se=Nl(Y,Te),0<Se.length&&(Te=new gd(Te,n,null,o,ne),re.push({event:Te,listeners:Se}),Ce?Te.data=Ce:(Ce=wd(o),Ce!==null&&(Te.data=Ce)))),(Ce=bx?Nx(n,o):Sx(n,o))&&(Y=Nl(Y,"onBeforeInput"),0<Y.length&&(ne=new gd("onBeforeInput","beforeinput",null,o,ne),re.push({event:ne,listeners:Y}),ne.data=Ce))}Bd(re,a)})}function ka(n,a,o){return{instance:n,listener:a,currentTarget:o}}function Nl(n,a){for(var o=a+"Capture",h=[];n!==null;){var x=n,v=x.stateNode;x.tag===5&&v!==null&&(x=v,v=ue(n,o),v!=null&&h.unshift(ka(n,v,x)),v=ue(n,a),v!=null&&h.push(ka(n,v,x))),n=n.return}return h}function vr(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5);return n||null}function Wd(n,a,o,h,x){for(var v=a._reactName,S=[];o!==null&&o!==h;){var I=o,D=I.alternate,Y=I.stateNode;if(D!==null&&D===h)break;I.tag===5&&Y!==null&&(I=Y,x?(D=ue(o,v),D!=null&&S.unshift(ka(o,D,I))):x||(D=ue(o,v),D!=null&&S.push(ka(o,D,I)))),o=o.return}S.length!==0&&n.push({event:a,listeners:S})}var Dx=/\r\n?/g,Ux=/\u0000|\uFFFD/g;function Hd(n){return(typeof n=="string"?n:""+n).replace(Dx,`
|
|
38
|
-
`).replace(Ux,"")}function Sl(n,a,o){if(a=Hd(a),Hd(n)!==a&&o)throw Error(r(425))}function Cl(){}var fi=null,gi=null;function xi(n,a){return n==="textarea"||n==="noscript"||typeof a.children=="string"||typeof a.children=="number"||typeof a.dangerouslySetInnerHTML=="object"&&a.dangerouslySetInnerHTML!==null&&a.dangerouslySetInnerHTML.__html!=null}var ji=typeof setTimeout=="function"?setTimeout:void 0,qx=typeof clearTimeout=="function"?clearTimeout:void 0,Gd=typeof Promise=="function"?Promise:void 0,Bx=typeof queueMicrotask=="function"?queueMicrotask:typeof Gd<"u"?function(n){return Gd.resolve(null).then(n).catch(zx)}:ji;function zx(n){setTimeout(function(){throw n})}function yi(n,a){var o=a,h=0;do{var x=o.nextSibling;if(n.removeChild(o),x&&x.nodeType===8)if(o=x.data,o==="/$"){if(h===0){n.removeChild(x),da(a);return}h--}else o!=="$"&&o!=="$?"&&o!=="$!"||h++;o=x}while(o);da(a)}function ks(n){for(;n!=null;n=n.nextSibling){var a=n.nodeType;if(a===1||a===3)break;if(a===8){if(a=n.data,a==="$"||a==="$!"||a==="$?")break;if(a==="/$")return null}}return n}function Kd(n){n=n.previousSibling;for(var a=0;n;){if(n.nodeType===8){var o=n.data;if(o==="$"||o==="$!"||o==="$?"){if(a===0)return n;a--}else o==="/$"&&a++}n=n.previousSibling}return null}var kr=Math.random().toString(36).slice(2),Ln="__reactFiber$"+kr,wa="__reactProps$"+kr,Hn="__reactContainer$"+kr,vi="__reactEvents$"+kr,Wx="__reactListeners$"+kr,Hx="__reactHandles$"+kr;function zs(n){var a=n[Ln];if(a)return a;for(var o=n.parentNode;o;){if(a=o[Hn]||o[Ln]){if(o=a.alternate,a.child!==null||o!==null&&o.child!==null)for(n=Kd(n);n!==null;){if(o=n[Ln])return o;n=Kd(n)}return a}n=o,o=n.parentNode}return null}function ba(n){return n=n[Ln]||n[Hn],!n||n.tag!==5&&n.tag!==6&&n.tag!==13&&n.tag!==3?null:n}function wr(n){if(n.tag===5||n.tag===6)return n.stateNode;throw Error(r(33))}function $l(n){return n[wa]||null}var ki=[],br=-1;function ws(n){return{current:n}}function Ve(n){0>br||(n.current=ki[br],ki[br]=null,br--)}function We(n,a){br++,ki[br]=n.current,n.current=a}var bs={},Nt=ws(bs),_t=ws(!1),Ws=bs;function Nr(n,a){var o=n.type.contextTypes;if(!o)return bs;var h=n.stateNode;if(h&&h.__reactInternalMemoizedUnmaskedChildContext===a)return h.__reactInternalMemoizedMaskedChildContext;var x={},v;for(v in o)x[v]=a[v];return h&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=a,n.__reactInternalMemoizedMaskedChildContext=x),x}function Dt(n){return n=n.childContextTypes,n!=null}function Tl(){Ve(_t),Ve(Nt)}function Vd(n,a,o){if(Nt.current!==bs)throw Error(r(168));We(Nt,a),We(_t,o)}function Yd(n,a,o){var h=n.stateNode;if(a=a.childContextTypes,typeof h.getChildContext!="function")return o;h=h.getChildContext();for(var x in h)if(!(x in a))throw Error(r(108,de(n)||"Unknown",x));return z({},o,h)}function El(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||bs,Ws=Nt.current,We(Nt,n),We(_t,_t.current),!0}function Qd(n,a,o){var h=n.stateNode;if(!h)throw Error(r(169));o?(n=Yd(n,a,Ws),h.__reactInternalMemoizedMergedChildContext=n,Ve(_t),Ve(Nt),We(Nt,n)):Ve(_t),We(_t,o)}var Gn=null,Rl=!1,wi=!1;function Jd(n){Gn===null?Gn=[n]:Gn.push(n)}function Gx(n){Rl=!0,Jd(n)}function Ns(){if(!wi&&Gn!==null){wi=!0;var n=0,a=Be;try{var o=Gn;for(Be=1;n<o.length;n++){var h=o[n];do h=h(!0);while(h!==null)}Gn=null,Rl=!1}catch(x){throw Gn!==null&&(Gn=Gn.slice(n+1)),na(ra,Ns),x}finally{Be=a,wi=!1}}return null}var Sr=[],Cr=0,Pl=null,Al=0,on=[],cn=0,Hs=null,Kn=1,Vn="";function Gs(n,a){Sr[Cr++]=Al,Sr[Cr++]=Pl,Pl=n,Al=a}function Xd(n,a,o){on[cn++]=Kn,on[cn++]=Vn,on[cn++]=Hs,Hs=n;var h=Kn;n=Vn;var x=32-Mt(h)-1;h&=~(1<<x),o+=1;var v=32-Mt(a)+x;if(30<v){var S=x-x%5;v=(h&(1<<S)-1).toString(32),h>>=S,x-=S,Kn=1<<32-Mt(a)+x|o<<x|h,Vn=v+n}else Kn=1<<v|o<<x|h,Vn=n}function bi(n){n.return!==null&&(Gs(n,1),Xd(n,1,0))}function Ni(n){for(;n===Pl;)Pl=Sr[--Cr],Sr[Cr]=null,Al=Sr[--Cr],Sr[Cr]=null;for(;n===Hs;)Hs=on[--cn],on[cn]=null,Vn=on[--cn],on[cn]=null,Kn=on[--cn],on[cn]=null}var Kt=null,Vt=null,Qe=!1,kn=null;function Zd(n,a){var o=mn(5,null,null,0);o.elementType="DELETED",o.stateNode=a,o.return=n,a=n.deletions,a===null?(n.deletions=[o],n.flags|=16):a.push(o)}function eh(n,a){switch(n.tag){case 5:var o=n.type;return a=a.nodeType!==1||o.toLowerCase()!==a.nodeName.toLowerCase()?null:a,a!==null?(n.stateNode=a,Kt=n,Vt=ks(a.firstChild),!0):!1;case 6:return a=n.pendingProps===""||a.nodeType!==3?null:a,a!==null?(n.stateNode=a,Kt=n,Vt=null,!0):!1;case 13:return a=a.nodeType!==8?null:a,a!==null?(o=Hs!==null?{id:Kn,overflow:Vn}:null,n.memoizedState={dehydrated:a,treeContext:o,retryLane:1073741824},o=mn(18,null,null,0),o.stateNode=a,o.return=n,n.child=o,Kt=n,Vt=null,!0):!1;default:return!1}}function Si(n){return(n.mode&1)!==0&&(n.flags&128)===0}function Ci(n){if(Qe){var a=Vt;if(a){var o=a;if(!eh(n,a)){if(Si(n))throw Error(r(418));a=ks(o.nextSibling);var h=Kt;a&&eh(n,a)?Zd(h,o):(n.flags=n.flags&-4097|2,Qe=!1,Kt=n)}}else{if(Si(n))throw Error(r(418));n.flags=n.flags&-4097|2,Qe=!1,Kt=n}}}function th(n){for(n=n.return;n!==null&&n.tag!==5&&n.tag!==3&&n.tag!==13;)n=n.return;Kt=n}function Il(n){if(n!==Kt)return!1;if(!Qe)return th(n),Qe=!0,!1;var a;if((a=n.tag!==3)&&!(a=n.tag!==5)&&(a=n.type,a=a!=="head"&&a!=="body"&&!xi(n.type,n.memoizedProps)),a&&(a=Vt)){if(Si(n))throw nh(),Error(r(418));for(;a;)Zd(n,a),a=ks(a.nextSibling)}if(th(n),n.tag===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(r(317));e:{for(n=n.nextSibling,a=0;n;){if(n.nodeType===8){var o=n.data;if(o==="/$"){if(a===0){Vt=ks(n.nextSibling);break e}a--}else o!=="$"&&o!=="$!"&&o!=="$?"||a++}n=n.nextSibling}Vt=null}}else Vt=Kt?ks(n.stateNode.nextSibling):null;return!0}function nh(){for(var n=Vt;n;)n=ks(n.nextSibling)}function $r(){Vt=Kt=null,Qe=!1}function $i(n){kn===null?kn=[n]:kn.push(n)}var Kx=C.ReactCurrentBatchConfig;function Na(n,a,o){if(n=o.ref,n!==null&&typeof n!="function"&&typeof n!="object"){if(o._owner){if(o=o._owner,o){if(o.tag!==1)throw Error(r(309));var h=o.stateNode}if(!h)throw Error(r(147,n));var x=h,v=""+n;return a!==null&&a.ref!==null&&typeof a.ref=="function"&&a.ref._stringRef===v?a.ref:(a=function(S){var I=x.refs;S===null?delete I[v]:I[v]=S},a._stringRef=v,a)}if(typeof n!="string")throw Error(r(284));if(!o._owner)throw Error(r(290,n))}return n}function Ol(n,a){throw n=Object.prototype.toString.call(a),Error(r(31,n==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":n))}function sh(n){var a=n._init;return a(n._payload)}function rh(n){function a(G,q){if(n){var K=G.deletions;K===null?(G.deletions=[q],G.flags|=16):K.push(q)}}function o(G,q){if(!n)return null;for(;q!==null;)a(G,q),q=q.sibling;return null}function h(G,q){for(G=new Map;q!==null;)q.key!==null?G.set(q.key,q):G.set(q.index,q),q=q.sibling;return G}function x(G,q){return G=As(G,q),G.index=0,G.sibling=null,G}function v(G,q,K){return G.index=K,n?(K=G.alternate,K!==null?(K=K.index,K<q?(G.flags|=2,q):K):(G.flags|=2,q)):(G.flags|=1048576,q)}function S(G){return n&&G.alternate===null&&(G.flags|=2),G}function I(G,q,K,oe){return q===null||q.tag!==6?(q=jc(K,G.mode,oe),q.return=G,q):(q=x(q,K),q.return=G,q)}function D(G,q,K,oe){var ye=K.type;return ye===F?ne(G,q,K.props.children,oe,K.key):q!==null&&(q.elementType===ye||typeof ye=="object"&&ye!==null&&ye.$$typeof===X&&sh(ye)===q.type)?(oe=x(q,K.props),oe.ref=Na(G,q,K),oe.return=G,oe):(oe=ro(K.type,K.key,K.props,null,G.mode,oe),oe.ref=Na(G,q,K),oe.return=G,oe)}function Y(G,q,K,oe){return q===null||q.tag!==4||q.stateNode.containerInfo!==K.containerInfo||q.stateNode.implementation!==K.implementation?(q=yc(K,G.mode,oe),q.return=G,q):(q=x(q,K.children||[]),q.return=G,q)}function ne(G,q,K,oe,ye){return q===null||q.tag!==7?(q=er(K,G.mode,oe,ye),q.return=G,q):(q=x(q,K),q.return=G,q)}function re(G,q,K){if(typeof q=="string"&&q!==""||typeof q=="number")return q=jc(""+q,G.mode,K),q.return=G,q;if(typeof q=="object"&&q!==null){switch(q.$$typeof){case E:return K=ro(q.type,q.key,q.props,null,G.mode,K),K.ref=Na(G,null,q),K.return=G,K;case O:return q=yc(q,G.mode,K),q.return=G,q;case X:var oe=q._init;return re(G,oe(q._payload),K)}if(tn(q)||ae(q))return q=er(q,G.mode,K,null),q.return=G,q;Ol(G,q)}return null}function te(G,q,K,oe){var ye=q!==null?q.key:null;if(typeof K=="string"&&K!==""||typeof K=="number")return ye!==null?null:I(G,q,""+K,oe);if(typeof K=="object"&&K!==null){switch(K.$$typeof){case E:return K.key===ye?D(G,q,K,oe):null;case O:return K.key===ye?Y(G,q,K,oe):null;case X:return ye=K._init,te(G,q,ye(K._payload),oe)}if(tn(K)||ae(K))return ye!==null?null:ne(G,q,K,oe,null);Ol(G,K)}return null}function me(G,q,K,oe,ye){if(typeof oe=="string"&&oe!==""||typeof oe=="number")return G=G.get(K)||null,I(q,G,""+oe,ye);if(typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case E:return G=G.get(oe.key===null?K:oe.key)||null,D(q,G,oe,ye);case O:return G=G.get(oe.key===null?K:oe.key)||null,Y(q,G,oe,ye);case X:var Se=oe._init;return me(G,q,K,Se(oe._payload),ye)}if(tn(oe)||ae(oe))return G=G.get(K)||null,ne(q,G,oe,ye,null);Ol(q,oe)}return null}function xe(G,q,K,oe){for(var ye=null,Se=null,Ce=q,Te=q=0,xt=null;Ce!==null&&Te<K.length;Te++){Ce.index>Te?(xt=Ce,Ce=null):xt=Ce.sibling;var De=te(G,Ce,K[Te],oe);if(De===null){Ce===null&&(Ce=xt);break}n&&Ce&&De.alternate===null&&a(G,Ce),q=v(De,q,Te),Se===null?ye=De:Se.sibling=De,Se=De,Ce=xt}if(Te===K.length)return o(G,Ce),Qe&&Gs(G,Te),ye;if(Ce===null){for(;Te<K.length;Te++)Ce=re(G,K[Te],oe),Ce!==null&&(q=v(Ce,q,Te),Se===null?ye=Ce:Se.sibling=Ce,Se=Ce);return Qe&&Gs(G,Te),ye}for(Ce=h(G,Ce);Te<K.length;Te++)xt=me(Ce,G,Te,K[Te],oe),xt!==null&&(n&&xt.alternate!==null&&Ce.delete(xt.key===null?Te:xt.key),q=v(xt,q,Te),Se===null?ye=xt:Se.sibling=xt,Se=xt);return n&&Ce.forEach(function(Is){return a(G,Is)}),Qe&&Gs(G,Te),ye}function je(G,q,K,oe){var ye=ae(K);if(typeof ye!="function")throw Error(r(150));if(K=ye.call(K),K==null)throw Error(r(151));for(var Se=ye=null,Ce=q,Te=q=0,xt=null,De=K.next();Ce!==null&&!De.done;Te++,De=K.next()){Ce.index>Te?(xt=Ce,Ce=null):xt=Ce.sibling;var Is=te(G,Ce,De.value,oe);if(Is===null){Ce===null&&(Ce=xt);break}n&&Ce&&Is.alternate===null&&a(G,Ce),q=v(Is,q,Te),Se===null?ye=Is:Se.sibling=Is,Se=Is,Ce=xt}if(De.done)return o(G,Ce),Qe&&Gs(G,Te),ye;if(Ce===null){for(;!De.done;Te++,De=K.next())De=re(G,De.value,oe),De!==null&&(q=v(De,q,Te),Se===null?ye=De:Se.sibling=De,Se=De);return Qe&&Gs(G,Te),ye}for(Ce=h(G,Ce);!De.done;Te++,De=K.next())De=me(Ce,G,Te,De.value,oe),De!==null&&(n&&De.alternate!==null&&Ce.delete(De.key===null?Te:De.key),q=v(De,q,Te),Se===null?ye=De:Se.sibling=De,Se=De);return n&&Ce.forEach(function(Cj){return a(G,Cj)}),Qe&&Gs(G,Te),ye}function ot(G,q,K,oe){if(typeof K=="object"&&K!==null&&K.type===F&&K.key===null&&(K=K.props.children),typeof K=="object"&&K!==null){switch(K.$$typeof){case E:e:{for(var ye=K.key,Se=q;Se!==null;){if(Se.key===ye){if(ye=K.type,ye===F){if(Se.tag===7){o(G,Se.sibling),q=x(Se,K.props.children),q.return=G,G=q;break e}}else if(Se.elementType===ye||typeof ye=="object"&&ye!==null&&ye.$$typeof===X&&sh(ye)===Se.type){o(G,Se.sibling),q=x(Se,K.props),q.ref=Na(G,Se,K),q.return=G,G=q;break e}o(G,Se);break}else a(G,Se);Se=Se.sibling}K.type===F?(q=er(K.props.children,G.mode,oe,K.key),q.return=G,G=q):(oe=ro(K.type,K.key,K.props,null,G.mode,oe),oe.ref=Na(G,q,K),oe.return=G,G=oe)}return S(G);case O:e:{for(Se=K.key;q!==null;){if(q.key===Se)if(q.tag===4&&q.stateNode.containerInfo===K.containerInfo&&q.stateNode.implementation===K.implementation){o(G,q.sibling),q=x(q,K.children||[]),q.return=G,G=q;break e}else{o(G,q);break}else a(G,q);q=q.sibling}q=yc(K,G.mode,oe),q.return=G,G=q}return S(G);case X:return Se=K._init,ot(G,q,Se(K._payload),oe)}if(tn(K))return xe(G,q,K,oe);if(ae(K))return je(G,q,K,oe);Ol(G,K)}return typeof K=="string"&&K!==""||typeof K=="number"?(K=""+K,q!==null&&q.tag===6?(o(G,q.sibling),q=x(q,K),q.return=G,G=q):(o(G,q),q=jc(K,G.mode,oe),q.return=G,G=q),S(G)):o(G,q)}return ot}var Tr=rh(!0),ah=rh(!1),Ll=ws(null),Fl=null,Er=null,Ti=null;function Ei(){Ti=Er=Fl=null}function Ri(n){var a=Ll.current;Ve(Ll),n._currentValue=a}function Pi(n,a,o){for(;n!==null;){var h=n.alternate;if((n.childLanes&a)!==a?(n.childLanes|=a,h!==null&&(h.childLanes|=a)):h!==null&&(h.childLanes&a)!==a&&(h.childLanes|=a),n===o)break;n=n.return}}function Rr(n,a){Fl=n,Ti=Er=null,n=n.dependencies,n!==null&&n.firstContext!==null&&((n.lanes&a)!==0&&(Ut=!0),n.firstContext=null)}function un(n){var a=n._currentValue;if(Ti!==n)if(n={context:n,memoizedValue:a,next:null},Er===null){if(Fl===null)throw Error(r(308));Er=n,Fl.dependencies={lanes:0,firstContext:n}}else Er=Er.next=n;return a}var Ks=null;function Ai(n){Ks===null?Ks=[n]:Ks.push(n)}function lh(n,a,o,h){var x=a.interleaved;return x===null?(o.next=o,Ai(a)):(o.next=x.next,x.next=o),a.interleaved=o,Yn(n,h)}function Yn(n,a){n.lanes|=a;var o=n.alternate;for(o!==null&&(o.lanes|=a),o=n,n=n.return;n!==null;)n.childLanes|=a,o=n.alternate,o!==null&&(o.childLanes|=a),o=n,n=n.return;return o.tag===3?o.stateNode:null}var Ss=!1;function Ii(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function oh(n,a){n=n.updateQueue,a.updateQueue===n&&(a.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,effects:n.effects})}function Qn(n,a){return{eventTime:n,lane:a,tag:0,payload:null,callback:null,next:null}}function Cs(n,a,o){var h=n.updateQueue;if(h===null)return null;if(h=h.shared,(Me&2)!==0){var x=h.pending;return x===null?a.next=a:(a.next=x.next,x.next=a),h.pending=a,Yn(n,o)}return x=h.interleaved,x===null?(a.next=a,Ai(h)):(a.next=x.next,x.next=a),h.interleaved=a,Yn(n,o)}function Ml(n,a,o){if(a=a.updateQueue,a!==null&&(a=a.shared,(o&4194240)!==0)){var h=a.lanes;h&=n.pendingLanes,o|=h,a.lanes=o,Ko(n,o)}}function ih(n,a){var o=n.updateQueue,h=n.alternate;if(h!==null&&(h=h.updateQueue,o===h)){var x=null,v=null;if(o=o.firstBaseUpdate,o!==null){do{var S={eventTime:o.eventTime,lane:o.lane,tag:o.tag,payload:o.payload,callback:o.callback,next:null};v===null?x=v=S:v=v.next=S,o=o.next}while(o!==null);v===null?x=v=a:v=v.next=a}else x=v=a;o={baseState:h.baseState,firstBaseUpdate:x,lastBaseUpdate:v,shared:h.shared,effects:h.effects},n.updateQueue=o;return}n=o.lastBaseUpdate,n===null?o.firstBaseUpdate=a:n.next=a,o.lastBaseUpdate=a}function _l(n,a,o,h){var x=n.updateQueue;Ss=!1;var v=x.firstBaseUpdate,S=x.lastBaseUpdate,I=x.shared.pending;if(I!==null){x.shared.pending=null;var D=I,Y=D.next;D.next=null,S===null?v=Y:S.next=Y,S=D;var ne=n.alternate;ne!==null&&(ne=ne.updateQueue,I=ne.lastBaseUpdate,I!==S&&(I===null?ne.firstBaseUpdate=Y:I.next=Y,ne.lastBaseUpdate=D))}if(v!==null){var re=x.baseState;S=0,ne=Y=D=null,I=v;do{var te=I.lane,me=I.eventTime;if((h&te)===te){ne!==null&&(ne=ne.next={eventTime:me,lane:0,tag:I.tag,payload:I.payload,callback:I.callback,next:null});e:{var xe=n,je=I;switch(te=a,me=o,je.tag){case 1:if(xe=je.payload,typeof xe=="function"){re=xe.call(me,re,te);break e}re=xe;break e;case 3:xe.flags=xe.flags&-65537|128;case 0:if(xe=je.payload,te=typeof xe=="function"?xe.call(me,re,te):xe,te==null)break e;re=z({},re,te);break e;case 2:Ss=!0}}I.callback!==null&&I.lane!==0&&(n.flags|=64,te=x.effects,te===null?x.effects=[I]:te.push(I))}else me={eventTime:me,lane:te,tag:I.tag,payload:I.payload,callback:I.callback,next:null},ne===null?(Y=ne=me,D=re):ne=ne.next=me,S|=te;if(I=I.next,I===null){if(I=x.shared.pending,I===null)break;te=I,I=te.next,te.next=null,x.lastBaseUpdate=te,x.shared.pending=null}}while(!0);if(ne===null&&(D=re),x.baseState=D,x.firstBaseUpdate=Y,x.lastBaseUpdate=ne,a=x.shared.interleaved,a!==null){x=a;do S|=x.lane,x=x.next;while(x!==a)}else v===null&&(x.shared.lanes=0);Qs|=S,n.lanes=S,n.memoizedState=re}}function ch(n,a,o){if(n=a.effects,a.effects=null,n!==null)for(a=0;a<n.length;a++){var h=n[a],x=h.callback;if(x!==null){if(h.callback=null,h=o,typeof x!="function")throw Error(r(191,x));x.call(h)}}}var Sa={},Fn=ws(Sa),Ca=ws(Sa),$a=ws(Sa);function Vs(n){if(n===Sa)throw Error(r(174));return n}function Oi(n,a){switch(We($a,a),We(Ca,n),We(Fn,Sa),n=a.nodeType,n){case 9:case 11:a=(a=a.documentElement)?a.namespaceURI:sn(null,"");break;default:n=n===8?a.parentNode:a,a=n.namespaceURI||null,n=n.tagName,a=sn(a,n)}Ve(Fn),We(Fn,a)}function Pr(){Ve(Fn),Ve(Ca),Ve($a)}function uh(n){Vs($a.current);var a=Vs(Fn.current),o=sn(a,n.type);a!==o&&(We(Ca,n),We(Fn,o))}function Li(n){Ca.current===n&&(Ve(Fn),Ve(Ca))}var Xe=ws(0);function Dl(n){for(var a=n;a!==null;){if(a.tag===13){var o=a.memoizedState;if(o!==null&&(o=o.dehydrated,o===null||o.data==="$?"||o.data==="$!"))return a}else if(a.tag===19&&a.memoizedProps.revealOrder!==void 0){if((a.flags&128)!==0)return a}else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===n)break;for(;a.sibling===null;){if(a.return===null||a.return===n)return null;a=a.return}a.sibling.return=a.return,a=a.sibling}return null}var Fi=[];function Mi(){for(var n=0;n<Fi.length;n++)Fi[n]._workInProgressVersionPrimary=null;Fi.length=0}var Ul=C.ReactCurrentDispatcher,_i=C.ReactCurrentBatchConfig,Ys=0,Ze=null,dt=null,ft=null,ql=!1,Ta=!1,Ea=0,Vx=0;function St(){throw Error(r(321))}function Di(n,a){if(a===null)return!1;for(var o=0;o<a.length&&o<n.length;o++)if(!vn(n[o],a[o]))return!1;return!0}function Ui(n,a,o,h,x,v){if(Ys=v,Ze=a,a.memoizedState=null,a.updateQueue=null,a.lanes=0,Ul.current=n===null||n.memoizedState===null?Xx:Zx,n=o(h,x),Ta){v=0;do{if(Ta=!1,Ea=0,25<=v)throw Error(r(301));v+=1,ft=dt=null,a.updateQueue=null,Ul.current=ej,n=o(h,x)}while(Ta)}if(Ul.current=Wl,a=dt!==null&&dt.next!==null,Ys=0,ft=dt=Ze=null,ql=!1,a)throw Error(r(300));return n}function qi(){var n=Ea!==0;return Ea=0,n}function Mn(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ft===null?Ze.memoizedState=ft=n:ft=ft.next=n,ft}function dn(){if(dt===null){var n=Ze.alternate;n=n!==null?n.memoizedState:null}else n=dt.next;var a=ft===null?Ze.memoizedState:ft.next;if(a!==null)ft=a,dt=n;else{if(n===null)throw Error(r(310));dt=n,n={memoizedState:dt.memoizedState,baseState:dt.baseState,baseQueue:dt.baseQueue,queue:dt.queue,next:null},ft===null?Ze.memoizedState=ft=n:ft=ft.next=n}return ft}function Ra(n,a){return typeof a=="function"?a(n):a}function Bi(n){var a=dn(),o=a.queue;if(o===null)throw Error(r(311));o.lastRenderedReducer=n;var h=dt,x=h.baseQueue,v=o.pending;if(v!==null){if(x!==null){var S=x.next;x.next=v.next,v.next=S}h.baseQueue=x=v,o.pending=null}if(x!==null){v=x.next,h=h.baseState;var I=S=null,D=null,Y=v;do{var ne=Y.lane;if((Ys&ne)===ne)D!==null&&(D=D.next={lane:0,action:Y.action,hasEagerState:Y.hasEagerState,eagerState:Y.eagerState,next:null}),h=Y.hasEagerState?Y.eagerState:n(h,Y.action);else{var re={lane:ne,action:Y.action,hasEagerState:Y.hasEagerState,eagerState:Y.eagerState,next:null};D===null?(I=D=re,S=h):D=D.next=re,Ze.lanes|=ne,Qs|=ne}Y=Y.next}while(Y!==null&&Y!==v);D===null?S=h:D.next=I,vn(h,a.memoizedState)||(Ut=!0),a.memoizedState=h,a.baseState=S,a.baseQueue=D,o.lastRenderedState=h}if(n=o.interleaved,n!==null){x=n;do v=x.lane,Ze.lanes|=v,Qs|=v,x=x.next;while(x!==n)}else x===null&&(o.lanes=0);return[a.memoizedState,o.dispatch]}function zi(n){var a=dn(),o=a.queue;if(o===null)throw Error(r(311));o.lastRenderedReducer=n;var h=o.dispatch,x=o.pending,v=a.memoizedState;if(x!==null){o.pending=null;var S=x=x.next;do v=n(v,S.action),S=S.next;while(S!==x);vn(v,a.memoizedState)||(Ut=!0),a.memoizedState=v,a.baseQueue===null&&(a.baseState=v),o.lastRenderedState=v}return[v,h]}function dh(){}function hh(n,a){var o=Ze,h=dn(),x=a(),v=!vn(h.memoizedState,x);if(v&&(h.memoizedState=x,Ut=!0),h=h.queue,Wi(fh.bind(null,o,h,n),[n]),h.getSnapshot!==a||v||ft!==null&&ft.memoizedState.tag&1){if(o.flags|=2048,Pa(9,ph.bind(null,o,h,x,a),void 0,null),gt===null)throw Error(r(349));(Ys&30)!==0||mh(o,a,x)}return x}function mh(n,a,o){n.flags|=16384,n={getSnapshot:a,value:o},a=Ze.updateQueue,a===null?(a={lastEffect:null,stores:null},Ze.updateQueue=a,a.stores=[n]):(o=a.stores,o===null?a.stores=[n]:o.push(n))}function ph(n,a,o,h){a.value=o,a.getSnapshot=h,gh(a)&&xh(n)}function fh(n,a,o){return o(function(){gh(a)&&xh(n)})}function gh(n){var a=n.getSnapshot;n=n.value;try{var o=a();return!vn(n,o)}catch{return!0}}function xh(n){var a=Yn(n,1);a!==null&&Sn(a,n,1,-1)}function jh(n){var a=Mn();return typeof n=="function"&&(n=n()),a.memoizedState=a.baseState=n,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ra,lastRenderedState:n},a.queue=n,n=n.dispatch=Jx.bind(null,Ze,n),[a.memoizedState,n]}function Pa(n,a,o,h){return n={tag:n,create:a,destroy:o,deps:h,next:null},a=Ze.updateQueue,a===null?(a={lastEffect:null,stores:null},Ze.updateQueue=a,a.lastEffect=n.next=n):(o=a.lastEffect,o===null?a.lastEffect=n.next=n:(h=o.next,o.next=n,n.next=h,a.lastEffect=n)),n}function yh(){return dn().memoizedState}function Bl(n,a,o,h){var x=Mn();Ze.flags|=n,x.memoizedState=Pa(1|a,o,void 0,h===void 0?null:h)}function zl(n,a,o,h){var x=dn();h=h===void 0?null:h;var v=void 0;if(dt!==null){var S=dt.memoizedState;if(v=S.destroy,h!==null&&Di(h,S.deps)){x.memoizedState=Pa(a,o,v,h);return}}Ze.flags|=n,x.memoizedState=Pa(1|a,o,v,h)}function vh(n,a){return Bl(8390656,8,n,a)}function Wi(n,a){return zl(2048,8,n,a)}function kh(n,a){return zl(4,2,n,a)}function wh(n,a){return zl(4,4,n,a)}function bh(n,a){if(typeof a=="function")return n=n(),a(n),function(){a(null)};if(a!=null)return n=n(),a.current=n,function(){a.current=null}}function Nh(n,a,o){return o=o!=null?o.concat([n]):null,zl(4,4,bh.bind(null,a,n),o)}function Hi(){}function Sh(n,a){var o=dn();a=a===void 0?null:a;var h=o.memoizedState;return h!==null&&a!==null&&Di(a,h[1])?h[0]:(o.memoizedState=[n,a],n)}function Ch(n,a){var o=dn();a=a===void 0?null:a;var h=o.memoizedState;return h!==null&&a!==null&&Di(a,h[1])?h[0]:(n=n(),o.memoizedState=[n,a],n)}function $h(n,a,o){return(Ys&21)===0?(n.baseState&&(n.baseState=!1,Ut=!0),n.memoizedState=o):(vn(o,a)||(o=sd(),Ze.lanes|=o,Qs|=o,n.baseState=!0),a)}function Yx(n,a){var o=Be;Be=o!==0&&4>o?o:4,n(!0);var h=_i.transition;_i.transition={};try{n(!1),a()}finally{Be=o,_i.transition=h}}function Th(){return dn().memoizedState}function Qx(n,a,o){var h=Rs(n);if(o={lane:h,action:o,hasEagerState:!1,eagerState:null,next:null},Eh(n))Rh(a,o);else if(o=lh(n,a,o,h),o!==null){var x=It();Sn(o,n,h,x),Ph(o,a,h)}}function Jx(n,a,o){var h=Rs(n),x={lane:h,action:o,hasEagerState:!1,eagerState:null,next:null};if(Eh(n))Rh(a,x);else{var v=n.alternate;if(n.lanes===0&&(v===null||v.lanes===0)&&(v=a.lastRenderedReducer,v!==null))try{var S=a.lastRenderedState,I=v(S,o);if(x.hasEagerState=!0,x.eagerState=I,vn(I,S)){var D=a.interleaved;D===null?(x.next=x,Ai(a)):(x.next=D.next,D.next=x),a.interleaved=x;return}}catch{}finally{}o=lh(n,a,x,h),o!==null&&(x=It(),Sn(o,n,h,x),Ph(o,a,h))}}function Eh(n){var a=n.alternate;return n===Ze||a!==null&&a===Ze}function Rh(n,a){Ta=ql=!0;var o=n.pending;o===null?a.next=a:(a.next=o.next,o.next=a),n.pending=a}function Ph(n,a,o){if((o&4194240)!==0){var h=a.lanes;h&=n.pendingLanes,o|=h,a.lanes=o,Ko(n,o)}}var Wl={readContext:un,useCallback:St,useContext:St,useEffect:St,useImperativeHandle:St,useInsertionEffect:St,useLayoutEffect:St,useMemo:St,useReducer:St,useRef:St,useState:St,useDebugValue:St,useDeferredValue:St,useTransition:St,useMutableSource:St,useSyncExternalStore:St,useId:St,unstable_isNewReconciler:!1},Xx={readContext:un,useCallback:function(n,a){return Mn().memoizedState=[n,a===void 0?null:a],n},useContext:un,useEffect:vh,useImperativeHandle:function(n,a,o){return o=o!=null?o.concat([n]):null,Bl(4194308,4,bh.bind(null,a,n),o)},useLayoutEffect:function(n,a){return Bl(4194308,4,n,a)},useInsertionEffect:function(n,a){return Bl(4,2,n,a)},useMemo:function(n,a){var o=Mn();return a=a===void 0?null:a,n=n(),o.memoizedState=[n,a],n},useReducer:function(n,a,o){var h=Mn();return a=o!==void 0?o(a):a,h.memoizedState=h.baseState=a,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:a},h.queue=n,n=n.dispatch=Qx.bind(null,Ze,n),[h.memoizedState,n]},useRef:function(n){var a=Mn();return n={current:n},a.memoizedState=n},useState:jh,useDebugValue:Hi,useDeferredValue:function(n){return Mn().memoizedState=n},useTransition:function(){var n=jh(!1),a=n[0];return n=Yx.bind(null,n[1]),Mn().memoizedState=n,[a,n]},useMutableSource:function(){},useSyncExternalStore:function(n,a,o){var h=Ze,x=Mn();if(Qe){if(o===void 0)throw Error(r(407));o=o()}else{if(o=a(),gt===null)throw Error(r(349));(Ys&30)!==0||mh(h,a,o)}x.memoizedState=o;var v={value:o,getSnapshot:a};return x.queue=v,vh(fh.bind(null,h,v,n),[n]),h.flags|=2048,Pa(9,ph.bind(null,h,v,o,a),void 0,null),o},useId:function(){var n=Mn(),a=gt.identifierPrefix;if(Qe){var o=Vn,h=Kn;o=(h&~(1<<32-Mt(h)-1)).toString(32)+o,a=":"+a+"R"+o,o=Ea++,0<o&&(a+="H"+o.toString(32)),a+=":"}else o=Vx++,a=":"+a+"r"+o.toString(32)+":";return n.memoizedState=a},unstable_isNewReconciler:!1},Zx={readContext:un,useCallback:Sh,useContext:un,useEffect:Wi,useImperativeHandle:Nh,useInsertionEffect:kh,useLayoutEffect:wh,useMemo:Ch,useReducer:Bi,useRef:yh,useState:function(){return Bi(Ra)},useDebugValue:Hi,useDeferredValue:function(n){var a=dn();return $h(a,dt.memoizedState,n)},useTransition:function(){var n=Bi(Ra)[0],a=dn().memoizedState;return[n,a]},useMutableSource:dh,useSyncExternalStore:hh,useId:Th,unstable_isNewReconciler:!1},ej={readContext:un,useCallback:Sh,useContext:un,useEffect:Wi,useImperativeHandle:Nh,useInsertionEffect:kh,useLayoutEffect:wh,useMemo:Ch,useReducer:zi,useRef:yh,useState:function(){return zi(Ra)},useDebugValue:Hi,useDeferredValue:function(n){var a=dn();return dt===null?a.memoizedState=n:$h(a,dt.memoizedState,n)},useTransition:function(){var n=zi(Ra)[0],a=dn().memoizedState;return[n,a]},useMutableSource:dh,useSyncExternalStore:hh,useId:Th,unstable_isNewReconciler:!1};function wn(n,a){if(n&&n.defaultProps){a=z({},a),n=n.defaultProps;for(var o in n)a[o]===void 0&&(a[o]=n[o]);return a}return a}function Gi(n,a,o,h){a=n.memoizedState,o=o(h,a),o=o==null?a:z({},a,o),n.memoizedState=o,n.lanes===0&&(n.updateQueue.baseState=o)}var Hl={isMounted:function(n){return(n=n._reactInternals)?Ft(n)===n:!1},enqueueSetState:function(n,a,o){n=n._reactInternals;var h=It(),x=Rs(n),v=Qn(h,x);v.payload=a,o!=null&&(v.callback=o),a=Cs(n,v,x),a!==null&&(Sn(a,n,x,h),Ml(a,n,x))},enqueueReplaceState:function(n,a,o){n=n._reactInternals;var h=It(),x=Rs(n),v=Qn(h,x);v.tag=1,v.payload=a,o!=null&&(v.callback=o),a=Cs(n,v,x),a!==null&&(Sn(a,n,x,h),Ml(a,n,x))},enqueueForceUpdate:function(n,a){n=n._reactInternals;var o=It(),h=Rs(n),x=Qn(o,h);x.tag=2,a!=null&&(x.callback=a),a=Cs(n,x,h),a!==null&&(Sn(a,n,h,o),Ml(a,n,h))}};function Ah(n,a,o,h,x,v,S){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(h,v,S):a.prototype&&a.prototype.isPureReactComponent?!xa(o,h)||!xa(x,v):!0}function Ih(n,a,o){var h=!1,x=bs,v=a.contextType;return typeof v=="object"&&v!==null?v=un(v):(x=Dt(a)?Ws:Nt.current,h=a.contextTypes,v=(h=h!=null)?Nr(n,x):bs),a=new a(o,v),n.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Hl,n.stateNode=a,a._reactInternals=n,h&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=x,n.__reactInternalMemoizedMaskedChildContext=v),a}function Oh(n,a,o,h){n=a.state,typeof a.componentWillReceiveProps=="function"&&a.componentWillReceiveProps(o,h),typeof a.UNSAFE_componentWillReceiveProps=="function"&&a.UNSAFE_componentWillReceiveProps(o,h),a.state!==n&&Hl.enqueueReplaceState(a,a.state,null)}function Ki(n,a,o,h){var x=n.stateNode;x.props=o,x.state=n.memoizedState,x.refs={},Ii(n);var v=a.contextType;typeof v=="object"&&v!==null?x.context=un(v):(v=Dt(a)?Ws:Nt.current,x.context=Nr(n,v)),x.state=n.memoizedState,v=a.getDerivedStateFromProps,typeof v=="function"&&(Gi(n,a,v,o),x.state=n.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof x.getSnapshotBeforeUpdate=="function"||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(a=x.state,typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount(),a!==x.state&&Hl.enqueueReplaceState(x,x.state,null),_l(n,o,x,h),x.state=n.memoizedState),typeof x.componentDidMount=="function"&&(n.flags|=4194308)}function Ar(n,a){try{var o="",h=a;do o+=be(h),h=h.return;while(h);var x=o}catch(v){x=`
|
|
39
|
-
Error generating stack: `+v.message+`
|
|
40
|
-
`+v.stack}return{value:n,source:a,stack:x,digest:null}}function Vi(n,a,o){return{value:n,source:null,stack:o??null,digest:a??null}}function Yi(n,a){try{console.error(a.value)}catch(o){setTimeout(function(){throw o})}}var tj=typeof WeakMap=="function"?WeakMap:Map;function Lh(n,a,o){o=Qn(-1,o),o.tag=3,o.payload={element:null};var h=a.value;return o.callback=function(){Xl||(Xl=!0,uc=h),Yi(n,a)},o}function Fh(n,a,o){o=Qn(-1,o),o.tag=3;var h=n.type.getDerivedStateFromError;if(typeof h=="function"){var x=a.value;o.payload=function(){return h(x)},o.callback=function(){Yi(n,a)}}var v=n.stateNode;return v!==null&&typeof v.componentDidCatch=="function"&&(o.callback=function(){Yi(n,a),typeof h!="function"&&(Ts===null?Ts=new Set([this]):Ts.add(this));var S=a.stack;this.componentDidCatch(a.value,{componentStack:S!==null?S:""})}),o}function Mh(n,a,o){var h=n.pingCache;if(h===null){h=n.pingCache=new tj;var x=new Set;h.set(a,x)}else x=h.get(a),x===void 0&&(x=new Set,h.set(a,x));x.has(o)||(x.add(o),n=fj.bind(null,n,a,o),a.then(n,n))}function _h(n){do{var a;if((a=n.tag===13)&&(a=n.memoizedState,a=a!==null?a.dehydrated!==null:!0),a)return n;n=n.return}while(n!==null);return null}function Dh(n,a,o,h,x){return(n.mode&1)===0?(n===a?n.flags|=65536:(n.flags|=128,o.flags|=131072,o.flags&=-52805,o.tag===1&&(o.alternate===null?o.tag=17:(a=Qn(-1,1),a.tag=2,Cs(o,a,1))),o.lanes|=1),n):(n.flags|=65536,n.lanes=x,n)}var nj=C.ReactCurrentOwner,Ut=!1;function At(n,a,o,h){a.child=n===null?ah(a,null,o,h):Tr(a,n.child,o,h)}function Uh(n,a,o,h,x){o=o.render;var v=a.ref;return Rr(a,x),h=Ui(n,a,o,h,v,x),o=qi(),n!==null&&!Ut?(a.updateQueue=n.updateQueue,a.flags&=-2053,n.lanes&=~x,Jn(n,a,x)):(Qe&&o&&bi(a),a.flags|=1,At(n,a,h,x),a.child)}function qh(n,a,o,h,x){if(n===null){var v=o.type;return typeof v=="function"&&!xc(v)&&v.defaultProps===void 0&&o.compare===null&&o.defaultProps===void 0?(a.tag=15,a.type=v,Bh(n,a,v,h,x)):(n=ro(o.type,null,h,a,a.mode,x),n.ref=a.ref,n.return=a,a.child=n)}if(v=n.child,(n.lanes&x)===0){var S=v.memoizedProps;if(o=o.compare,o=o!==null?o:xa,o(S,h)&&n.ref===a.ref)return Jn(n,a,x)}return a.flags|=1,n=As(v,h),n.ref=a.ref,n.return=a,a.child=n}function Bh(n,a,o,h,x){if(n!==null){var v=n.memoizedProps;if(xa(v,h)&&n.ref===a.ref)if(Ut=!1,a.pendingProps=h=v,(n.lanes&x)!==0)(n.flags&131072)!==0&&(Ut=!0);else return a.lanes=n.lanes,Jn(n,a,x)}return Qi(n,a,o,h,x)}function zh(n,a,o){var h=a.pendingProps,x=h.children,v=n!==null?n.memoizedState:null;if(h.mode==="hidden")if((a.mode&1)===0)a.memoizedState={baseLanes:0,cachePool:null,transitions:null},We(Or,Yt),Yt|=o;else{if((o&1073741824)===0)return n=v!==null?v.baseLanes|o:o,a.lanes=a.childLanes=1073741824,a.memoizedState={baseLanes:n,cachePool:null,transitions:null},a.updateQueue=null,We(Or,Yt),Yt|=n,null;a.memoizedState={baseLanes:0,cachePool:null,transitions:null},h=v!==null?v.baseLanes:o,We(Or,Yt),Yt|=h}else v!==null?(h=v.baseLanes|o,a.memoizedState=null):h=o,We(Or,Yt),Yt|=h;return At(n,a,x,o),a.child}function Wh(n,a){var o=a.ref;(n===null&&o!==null||n!==null&&n.ref!==o)&&(a.flags|=512,a.flags|=2097152)}function Qi(n,a,o,h,x){var v=Dt(o)?Ws:Nt.current;return v=Nr(a,v),Rr(a,x),o=Ui(n,a,o,h,v,x),h=qi(),n!==null&&!Ut?(a.updateQueue=n.updateQueue,a.flags&=-2053,n.lanes&=~x,Jn(n,a,x)):(Qe&&h&&bi(a),a.flags|=1,At(n,a,o,x),a.child)}function Hh(n,a,o,h,x){if(Dt(o)){var v=!0;El(a)}else v=!1;if(Rr(a,x),a.stateNode===null)Kl(n,a),Ih(a,o,h),Ki(a,o,h,x),h=!0;else if(n===null){var S=a.stateNode,I=a.memoizedProps;S.props=I;var D=S.context,Y=o.contextType;typeof Y=="object"&&Y!==null?Y=un(Y):(Y=Dt(o)?Ws:Nt.current,Y=Nr(a,Y));var ne=o.getDerivedStateFromProps,re=typeof ne=="function"||typeof S.getSnapshotBeforeUpdate=="function";re||typeof S.UNSAFE_componentWillReceiveProps!="function"&&typeof S.componentWillReceiveProps!="function"||(I!==h||D!==Y)&&Oh(a,S,h,Y),Ss=!1;var te=a.memoizedState;S.state=te,_l(a,h,S,x),D=a.memoizedState,I!==h||te!==D||_t.current||Ss?(typeof ne=="function"&&(Gi(a,o,ne,h),D=a.memoizedState),(I=Ss||Ah(a,o,I,h,te,D,Y))?(re||typeof S.UNSAFE_componentWillMount!="function"&&typeof S.componentWillMount!="function"||(typeof S.componentWillMount=="function"&&S.componentWillMount(),typeof S.UNSAFE_componentWillMount=="function"&&S.UNSAFE_componentWillMount()),typeof S.componentDidMount=="function"&&(a.flags|=4194308)):(typeof S.componentDidMount=="function"&&(a.flags|=4194308),a.memoizedProps=h,a.memoizedState=D),S.props=h,S.state=D,S.context=Y,h=I):(typeof S.componentDidMount=="function"&&(a.flags|=4194308),h=!1)}else{S=a.stateNode,oh(n,a),I=a.memoizedProps,Y=a.type===a.elementType?I:wn(a.type,I),S.props=Y,re=a.pendingProps,te=S.context,D=o.contextType,typeof D=="object"&&D!==null?D=un(D):(D=Dt(o)?Ws:Nt.current,D=Nr(a,D));var me=o.getDerivedStateFromProps;(ne=typeof me=="function"||typeof S.getSnapshotBeforeUpdate=="function")||typeof S.UNSAFE_componentWillReceiveProps!="function"&&typeof S.componentWillReceiveProps!="function"||(I!==re||te!==D)&&Oh(a,S,h,D),Ss=!1,te=a.memoizedState,S.state=te,_l(a,h,S,x);var xe=a.memoizedState;I!==re||te!==xe||_t.current||Ss?(typeof me=="function"&&(Gi(a,o,me,h),xe=a.memoizedState),(Y=Ss||Ah(a,o,Y,h,te,xe,D)||!1)?(ne||typeof S.UNSAFE_componentWillUpdate!="function"&&typeof S.componentWillUpdate!="function"||(typeof S.componentWillUpdate=="function"&&S.componentWillUpdate(h,xe,D),typeof S.UNSAFE_componentWillUpdate=="function"&&S.UNSAFE_componentWillUpdate(h,xe,D)),typeof S.componentDidUpdate=="function"&&(a.flags|=4),typeof S.getSnapshotBeforeUpdate=="function"&&(a.flags|=1024)):(typeof S.componentDidUpdate!="function"||I===n.memoizedProps&&te===n.memoizedState||(a.flags|=4),typeof S.getSnapshotBeforeUpdate!="function"||I===n.memoizedProps&&te===n.memoizedState||(a.flags|=1024),a.memoizedProps=h,a.memoizedState=xe),S.props=h,S.state=xe,S.context=D,h=Y):(typeof S.componentDidUpdate!="function"||I===n.memoizedProps&&te===n.memoizedState||(a.flags|=4),typeof S.getSnapshotBeforeUpdate!="function"||I===n.memoizedProps&&te===n.memoizedState||(a.flags|=1024),h=!1)}return Ji(n,a,o,h,v,x)}function Ji(n,a,o,h,x,v){Wh(n,a);var S=(a.flags&128)!==0;if(!h&&!S)return x&&Qd(a,o,!1),Jn(n,a,v);h=a.stateNode,nj.current=a;var I=S&&typeof o.getDerivedStateFromError!="function"?null:h.render();return a.flags|=1,n!==null&&S?(a.child=Tr(a,n.child,null,v),a.child=Tr(a,null,I,v)):At(n,a,I,v),a.memoizedState=h.state,x&&Qd(a,o,!0),a.child}function Gh(n){var a=n.stateNode;a.pendingContext?Vd(n,a.pendingContext,a.pendingContext!==a.context):a.context&&Vd(n,a.context,!1),Oi(n,a.containerInfo)}function Kh(n,a,o,h,x){return $r(),$i(x),a.flags|=256,At(n,a,o,h),a.child}var Xi={dehydrated:null,treeContext:null,retryLane:0};function Zi(n){return{baseLanes:n,cachePool:null,transitions:null}}function Vh(n,a,o){var h=a.pendingProps,x=Xe.current,v=!1,S=(a.flags&128)!==0,I;if((I=S)||(I=n!==null&&n.memoizedState===null?!1:(x&2)!==0),I?(v=!0,a.flags&=-129):(n===null||n.memoizedState!==null)&&(x|=1),We(Xe,x&1),n===null)return Ci(a),n=a.memoizedState,n!==null&&(n=n.dehydrated,n!==null)?((a.mode&1)===0?a.lanes=1:n.data==="$!"?a.lanes=8:a.lanes=1073741824,null):(S=h.children,n=h.fallback,v?(h=a.mode,v=a.child,S={mode:"hidden",children:S},(h&1)===0&&v!==null?(v.childLanes=0,v.pendingProps=S):v=ao(S,h,0,null),n=er(n,h,o,null),v.return=a,n.return=a,v.sibling=n,a.child=v,a.child.memoizedState=Zi(o),a.memoizedState=Xi,n):ec(a,S));if(x=n.memoizedState,x!==null&&(I=x.dehydrated,I!==null))return sj(n,a,S,h,I,x,o);if(v){v=h.fallback,S=a.mode,x=n.child,I=x.sibling;var D={mode:"hidden",children:h.children};return(S&1)===0&&a.child!==x?(h=a.child,h.childLanes=0,h.pendingProps=D,a.deletions=null):(h=As(x,D),h.subtreeFlags=x.subtreeFlags&14680064),I!==null?v=As(I,v):(v=er(v,S,o,null),v.flags|=2),v.return=a,h.return=a,h.sibling=v,a.child=h,h=v,v=a.child,S=n.child.memoizedState,S=S===null?Zi(o):{baseLanes:S.baseLanes|o,cachePool:null,transitions:S.transitions},v.memoizedState=S,v.childLanes=n.childLanes&~o,a.memoizedState=Xi,h}return v=n.child,n=v.sibling,h=As(v,{mode:"visible",children:h.children}),(a.mode&1)===0&&(h.lanes=o),h.return=a,h.sibling=null,n!==null&&(o=a.deletions,o===null?(a.deletions=[n],a.flags|=16):o.push(n)),a.child=h,a.memoizedState=null,h}function ec(n,a){return a=ao({mode:"visible",children:a},n.mode,0,null),a.return=n,n.child=a}function Gl(n,a,o,h){return h!==null&&$i(h),Tr(a,n.child,null,o),n=ec(a,a.pendingProps.children),n.flags|=2,a.memoizedState=null,n}function sj(n,a,o,h,x,v,S){if(o)return a.flags&256?(a.flags&=-257,h=Vi(Error(r(422))),Gl(n,a,S,h)):a.memoizedState!==null?(a.child=n.child,a.flags|=128,null):(v=h.fallback,x=a.mode,h=ao({mode:"visible",children:h.children},x,0,null),v=er(v,x,S,null),v.flags|=2,h.return=a,v.return=a,h.sibling=v,a.child=h,(a.mode&1)!==0&&Tr(a,n.child,null,S),a.child.memoizedState=Zi(S),a.memoizedState=Xi,v);if((a.mode&1)===0)return Gl(n,a,S,null);if(x.data==="$!"){if(h=x.nextSibling&&x.nextSibling.dataset,h)var I=h.dgst;return h=I,v=Error(r(419)),h=Vi(v,h,void 0),Gl(n,a,S,h)}if(I=(S&n.childLanes)!==0,Ut||I){if(h=gt,h!==null){switch(S&-S){case 4:x=2;break;case 16:x=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:x=32;break;case 536870912:x=268435456;break;default:x=0}x=(x&(h.suspendedLanes|S))!==0?0:x,x!==0&&x!==v.retryLane&&(v.retryLane=x,Yn(n,x),Sn(h,n,x,-1))}return gc(),h=Vi(Error(r(421))),Gl(n,a,S,h)}return x.data==="$?"?(a.flags|=128,a.child=n.child,a=gj.bind(null,n),x._reactRetry=a,null):(n=v.treeContext,Vt=ks(x.nextSibling),Kt=a,Qe=!0,kn=null,n!==null&&(on[cn++]=Kn,on[cn++]=Vn,on[cn++]=Hs,Kn=n.id,Vn=n.overflow,Hs=a),a=ec(a,h.children),a.flags|=4096,a)}function Yh(n,a,o){n.lanes|=a;var h=n.alternate;h!==null&&(h.lanes|=a),Pi(n.return,a,o)}function tc(n,a,o,h,x){var v=n.memoizedState;v===null?n.memoizedState={isBackwards:a,rendering:null,renderingStartTime:0,last:h,tail:o,tailMode:x}:(v.isBackwards=a,v.rendering=null,v.renderingStartTime=0,v.last=h,v.tail=o,v.tailMode=x)}function Qh(n,a,o){var h=a.pendingProps,x=h.revealOrder,v=h.tail;if(At(n,a,h.children,o),h=Xe.current,(h&2)!==0)h=h&1|2,a.flags|=128;else{if(n!==null&&(n.flags&128)!==0)e:for(n=a.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&Yh(n,o,a);else if(n.tag===19)Yh(n,o,a);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===a)break e;for(;n.sibling===null;){if(n.return===null||n.return===a)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}h&=1}if(We(Xe,h),(a.mode&1)===0)a.memoizedState=null;else switch(x){case"forwards":for(o=a.child,x=null;o!==null;)n=o.alternate,n!==null&&Dl(n)===null&&(x=o),o=o.sibling;o=x,o===null?(x=a.child,a.child=null):(x=o.sibling,o.sibling=null),tc(a,!1,x,o,v);break;case"backwards":for(o=null,x=a.child,a.child=null;x!==null;){if(n=x.alternate,n!==null&&Dl(n)===null){a.child=x;break}n=x.sibling,x.sibling=o,o=x,x=n}tc(a,!0,o,null,v);break;case"together":tc(a,!1,null,null,void 0);break;default:a.memoizedState=null}return a.child}function Kl(n,a){(a.mode&1)===0&&n!==null&&(n.alternate=null,a.alternate=null,a.flags|=2)}function Jn(n,a,o){if(n!==null&&(a.dependencies=n.dependencies),Qs|=a.lanes,(o&a.childLanes)===0)return null;if(n!==null&&a.child!==n.child)throw Error(r(153));if(a.child!==null){for(n=a.child,o=As(n,n.pendingProps),a.child=o,o.return=a;n.sibling!==null;)n=n.sibling,o=o.sibling=As(n,n.pendingProps),o.return=a;o.sibling=null}return a.child}function rj(n,a,o){switch(a.tag){case 3:Gh(a),$r();break;case 5:uh(a);break;case 1:Dt(a.type)&&El(a);break;case 4:Oi(a,a.stateNode.containerInfo);break;case 10:var h=a.type._context,x=a.memoizedProps.value;We(Ll,h._currentValue),h._currentValue=x;break;case 13:if(h=a.memoizedState,h!==null)return h.dehydrated!==null?(We(Xe,Xe.current&1),a.flags|=128,null):(o&a.child.childLanes)!==0?Vh(n,a,o):(We(Xe,Xe.current&1),n=Jn(n,a,o),n!==null?n.sibling:null);We(Xe,Xe.current&1);break;case 19:if(h=(o&a.childLanes)!==0,(n.flags&128)!==0){if(h)return Qh(n,a,o);a.flags|=128}if(x=a.memoizedState,x!==null&&(x.rendering=null,x.tail=null,x.lastEffect=null),We(Xe,Xe.current),h)break;return null;case 22:case 23:return a.lanes=0,zh(n,a,o)}return Jn(n,a,o)}var Jh,nc,Xh,Zh;Jh=function(n,a){for(var o=a.child;o!==null;){if(o.tag===5||o.tag===6)n.appendChild(o.stateNode);else if(o.tag!==4&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===a)break;for(;o.sibling===null;){if(o.return===null||o.return===a)return;o=o.return}o.sibling.return=o.return,o=o.sibling}},nc=function(){},Xh=function(n,a,o,h){var x=n.memoizedProps;if(x!==h){n=a.stateNode,Vs(Fn.current);var v=null;switch(o){case"input":x=rs(n,x),h=rs(n,h),v=[];break;case"select":x=z({},x,{value:void 0}),h=z({},h,{value:void 0}),v=[];break;case"textarea":x=Bn(n,x),h=Bn(n,h),v=[];break;default:typeof x.onClick!="function"&&typeof h.onClick=="function"&&(n.onclick=Cl)}Pn(o,h);var S;o=null;for(Y in x)if(!h.hasOwnProperty(Y)&&x.hasOwnProperty(Y)&&x[Y]!=null)if(Y==="style"){var I=x[Y];for(S in I)I.hasOwnProperty(S)&&(o||(o={}),o[S]="")}else Y!=="dangerouslySetInnerHTML"&&Y!=="children"&&Y!=="suppressContentEditableWarning"&&Y!=="suppressHydrationWarning"&&Y!=="autoFocus"&&(i.hasOwnProperty(Y)?v||(v=[]):(v=v||[]).push(Y,null));for(Y in h){var D=h[Y];if(I=x!=null?x[Y]:void 0,h.hasOwnProperty(Y)&&D!==I&&(D!=null||I!=null))if(Y==="style")if(I){for(S in I)!I.hasOwnProperty(S)||D&&D.hasOwnProperty(S)||(o||(o={}),o[S]="");for(S in D)D.hasOwnProperty(S)&&I[S]!==D[S]&&(o||(o={}),o[S]=D[S])}else o||(v||(v=[]),v.push(Y,o)),o=D;else Y==="dangerouslySetInnerHTML"?(D=D?D.__html:void 0,I=I?I.__html:void 0,D!=null&&I!==D&&(v=v||[]).push(Y,D)):Y==="children"?typeof D!="string"&&typeof D!="number"||(v=v||[]).push(Y,""+D):Y!=="suppressContentEditableWarning"&&Y!=="suppressHydrationWarning"&&(i.hasOwnProperty(Y)?(D!=null&&Y==="onScroll"&&Ke("scroll",n),v||I===D||(v=[])):(v=v||[]).push(Y,D))}o&&(v=v||[]).push("style",o);var Y=v;(a.updateQueue=Y)&&(a.flags|=4)}},Zh=function(n,a,o,h){o!==h&&(a.flags|=4)};function Aa(n,a){if(!Qe)switch(n.tailMode){case"hidden":a=n.tail;for(var o=null;a!==null;)a.alternate!==null&&(o=a),a=a.sibling;o===null?n.tail=null:o.sibling=null;break;case"collapsed":o=n.tail;for(var h=null;o!==null;)o.alternate!==null&&(h=o),o=o.sibling;h===null?a||n.tail===null?n.tail=null:n.tail.sibling=null:h.sibling=null}}function Ct(n){var a=n.alternate!==null&&n.alternate.child===n.child,o=0,h=0;if(a)for(var x=n.child;x!==null;)o|=x.lanes|x.childLanes,h|=x.subtreeFlags&14680064,h|=x.flags&14680064,x.return=n,x=x.sibling;else for(x=n.child;x!==null;)o|=x.lanes|x.childLanes,h|=x.subtreeFlags,h|=x.flags,x.return=n,x=x.sibling;return n.subtreeFlags|=h,n.childLanes=o,a}function aj(n,a,o){var h=a.pendingProps;switch(Ni(a),a.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ct(a),null;case 1:return Dt(a.type)&&Tl(),Ct(a),null;case 3:return h=a.stateNode,Pr(),Ve(_t),Ve(Nt),Mi(),h.pendingContext&&(h.context=h.pendingContext,h.pendingContext=null),(n===null||n.child===null)&&(Il(a)?a.flags|=4:n===null||n.memoizedState.isDehydrated&&(a.flags&256)===0||(a.flags|=1024,kn!==null&&(mc(kn),kn=null))),nc(n,a),Ct(a),null;case 5:Li(a);var x=Vs($a.current);if(o=a.type,n!==null&&a.stateNode!=null)Xh(n,a,o,h,x),n.ref!==a.ref&&(a.flags|=512,a.flags|=2097152);else{if(!h){if(a.stateNode===null)throw Error(r(166));return Ct(a),null}if(n=Vs(Fn.current),Il(a)){h=a.stateNode,o=a.type;var v=a.memoizedProps;switch(h[Ln]=a,h[wa]=v,n=(a.mode&1)!==0,o){case"dialog":Ke("cancel",h),Ke("close",h);break;case"iframe":case"object":case"embed":Ke("load",h);break;case"video":case"audio":for(x=0;x<ya.length;x++)Ke(ya[x],h);break;case"source":Ke("error",h);break;case"img":case"image":case"link":Ke("error",h),Ke("load",h);break;case"details":Ke("toggle",h);break;case"input":Fe(h,v),Ke("invalid",h);break;case"select":h._wrapperState={wasMultiple:!!v.multiple},Ke("invalid",h);break;case"textarea":ls(h,v),Ke("invalid",h)}Pn(o,v),x=null;for(var S in v)if(v.hasOwnProperty(S)){var I=v[S];S==="children"?typeof I=="string"?h.textContent!==I&&(v.suppressHydrationWarning!==!0&&Sl(h.textContent,I,n),x=["children",I]):typeof I=="number"&&h.textContent!==""+I&&(v.suppressHydrationWarning!==!0&&Sl(h.textContent,I,n),x=["children",""+I]):i.hasOwnProperty(S)&&I!=null&&S==="onScroll"&&Ke("scroll",h)}switch(o){case"input":Ye(h),as(h,v,!0);break;case"textarea":Ye(h),nn(h);break;case"select":case"option":break;default:typeof v.onClick=="function"&&(h.onclick=Cl)}h=x,a.updateQueue=h,h!==null&&(a.flags|=4)}else{S=x.nodeType===9?x:x.ownerDocument,n==="http://www.w3.org/1999/xhtml"&&(n=is(o)),n==="http://www.w3.org/1999/xhtml"?o==="script"?(n=S.createElement("div"),n.innerHTML="<script><\/script>",n=n.removeChild(n.firstChild)):typeof h.is=="string"?n=S.createElement(o,{is:h.is}):(n=S.createElement(o),o==="select"&&(S=n,h.multiple?S.multiple=!0:h.size&&(S.size=h.size))):n=S.createElementNS(n,o),n[Ln]=a,n[wa]=h,Jh(n,a,!1,!1),a.stateNode=n;e:{switch(S=Rt(o,h),o){case"dialog":Ke("cancel",n),Ke("close",n),x=h;break;case"iframe":case"object":case"embed":Ke("load",n),x=h;break;case"video":case"audio":for(x=0;x<ya.length;x++)Ke(ya[x],n);x=h;break;case"source":Ke("error",n),x=h;break;case"img":case"image":case"link":Ke("error",n),Ke("load",n),x=h;break;case"details":Ke("toggle",n),x=h;break;case"input":Fe(n,h),x=rs(n,h),Ke("invalid",n);break;case"option":x=h;break;case"select":n._wrapperState={wasMultiple:!!h.multiple},x=z({},h,{value:void 0}),Ke("invalid",n);break;case"textarea":ls(n,h),x=Bn(n,h),Ke("invalid",n);break;default:x=h}Pn(o,x),I=x;for(v in I)if(I.hasOwnProperty(v)){var D=I[v];v==="style"?nt(n,D):v==="dangerouslySetInnerHTML"?(D=D?D.__html:void 0,D!=null&&En(n,D)):v==="children"?typeof D=="string"?(o!=="textarea"||D!=="")&&He(n,D):typeof D=="number"&&He(n,""+D):v!=="suppressContentEditableWarning"&&v!=="suppressHydrationWarning"&&v!=="autoFocus"&&(i.hasOwnProperty(v)?D!=null&&v==="onScroll"&&Ke("scroll",n):D!=null&&T(n,v,D,S))}switch(o){case"input":Ye(n),as(n,h,!1);break;case"textarea":Ye(n),nn(n);break;case"option":h.value!=null&&n.setAttribute("value",""+se(h.value));break;case"select":n.multiple=!!h.multiple,v=h.value,v!=null?wt(n,!!h.multiple,v,!1):h.defaultValue!=null&&wt(n,!!h.multiple,h.defaultValue,!0);break;default:typeof x.onClick=="function"&&(n.onclick=Cl)}switch(o){case"button":case"input":case"select":case"textarea":h=!!h.autoFocus;break e;case"img":h=!0;break e;default:h=!1}}h&&(a.flags|=4)}a.ref!==null&&(a.flags|=512,a.flags|=2097152)}return Ct(a),null;case 6:if(n&&a.stateNode!=null)Zh(n,a,n.memoizedProps,h);else{if(typeof h!="string"&&a.stateNode===null)throw Error(r(166));if(o=Vs($a.current),Vs(Fn.current),Il(a)){if(h=a.stateNode,o=a.memoizedProps,h[Ln]=a,(v=h.nodeValue!==o)&&(n=Kt,n!==null))switch(n.tag){case 3:Sl(h.nodeValue,o,(n.mode&1)!==0);break;case 5:n.memoizedProps.suppressHydrationWarning!==!0&&Sl(h.nodeValue,o,(n.mode&1)!==0)}v&&(a.flags|=4)}else h=(o.nodeType===9?o:o.ownerDocument).createTextNode(h),h[Ln]=a,a.stateNode=h}return Ct(a),null;case 13:if(Ve(Xe),h=a.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(Qe&&Vt!==null&&(a.mode&1)!==0&&(a.flags&128)===0)nh(),$r(),a.flags|=98560,v=!1;else if(v=Il(a),h!==null&&h.dehydrated!==null){if(n===null){if(!v)throw Error(r(318));if(v=a.memoizedState,v=v!==null?v.dehydrated:null,!v)throw Error(r(317));v[Ln]=a}else $r(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;Ct(a),v=!1}else kn!==null&&(mc(kn),kn=null),v=!0;if(!v)return a.flags&65536?a:null}return(a.flags&128)!==0?(a.lanes=o,a):(h=h!==null,h!==(n!==null&&n.memoizedState!==null)&&h&&(a.child.flags|=8192,(a.mode&1)!==0&&(n===null||(Xe.current&1)!==0?ht===0&&(ht=3):gc())),a.updateQueue!==null&&(a.flags|=4),Ct(a),null);case 4:return Pr(),nc(n,a),n===null&&va(a.stateNode.containerInfo),Ct(a),null;case 10:return Ri(a.type._context),Ct(a),null;case 17:return Dt(a.type)&&Tl(),Ct(a),null;case 19:if(Ve(Xe),v=a.memoizedState,v===null)return Ct(a),null;if(h=(a.flags&128)!==0,S=v.rendering,S===null)if(h)Aa(v,!1);else{if(ht!==0||n!==null&&(n.flags&128)!==0)for(n=a.child;n!==null;){if(S=Dl(n),S!==null){for(a.flags|=128,Aa(v,!1),h=S.updateQueue,h!==null&&(a.updateQueue=h,a.flags|=4),a.subtreeFlags=0,h=o,o=a.child;o!==null;)v=o,n=h,v.flags&=14680066,S=v.alternate,S===null?(v.childLanes=0,v.lanes=n,v.child=null,v.subtreeFlags=0,v.memoizedProps=null,v.memoizedState=null,v.updateQueue=null,v.dependencies=null,v.stateNode=null):(v.childLanes=S.childLanes,v.lanes=S.lanes,v.child=S.child,v.subtreeFlags=0,v.deletions=null,v.memoizedProps=S.memoizedProps,v.memoizedState=S.memoizedState,v.updateQueue=S.updateQueue,v.type=S.type,n=S.dependencies,v.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),o=o.sibling;return We(Xe,Xe.current&1|2),a.child}n=n.sibling}v.tail!==null&&ze()>Lr&&(a.flags|=128,h=!0,Aa(v,!1),a.lanes=4194304)}else{if(!h)if(n=Dl(S),n!==null){if(a.flags|=128,h=!0,o=n.updateQueue,o!==null&&(a.updateQueue=o,a.flags|=4),Aa(v,!0),v.tail===null&&v.tailMode==="hidden"&&!S.alternate&&!Qe)return Ct(a),null}else 2*ze()-v.renderingStartTime>Lr&&o!==1073741824&&(a.flags|=128,h=!0,Aa(v,!1),a.lanes=4194304);v.isBackwards?(S.sibling=a.child,a.child=S):(o=v.last,o!==null?o.sibling=S:a.child=S,v.last=S)}return v.tail!==null?(a=v.tail,v.rendering=a,v.tail=a.sibling,v.renderingStartTime=ze(),a.sibling=null,o=Xe.current,We(Xe,h?o&1|2:o&1),a):(Ct(a),null);case 22:case 23:return fc(),h=a.memoizedState!==null,n!==null&&n.memoizedState!==null!==h&&(a.flags|=8192),h&&(a.mode&1)!==0?(Yt&1073741824)!==0&&(Ct(a),a.subtreeFlags&6&&(a.flags|=8192)):Ct(a),null;case 24:return null;case 25:return null}throw Error(r(156,a.tag))}function lj(n,a){switch(Ni(a),a.tag){case 1:return Dt(a.type)&&Tl(),n=a.flags,n&65536?(a.flags=n&-65537|128,a):null;case 3:return Pr(),Ve(_t),Ve(Nt),Mi(),n=a.flags,(n&65536)!==0&&(n&128)===0?(a.flags=n&-65537|128,a):null;case 5:return Li(a),null;case 13:if(Ve(Xe),n=a.memoizedState,n!==null&&n.dehydrated!==null){if(a.alternate===null)throw Error(r(340));$r()}return n=a.flags,n&65536?(a.flags=n&-65537|128,a):null;case 19:return Ve(Xe),null;case 4:return Pr(),null;case 10:return Ri(a.type._context),null;case 22:case 23:return fc(),null;case 24:return null;default:return null}}var Vl=!1,$t=!1,oj=typeof WeakSet=="function"?WeakSet:Set,ge=null;function Ir(n,a){var o=n.ref;if(o!==null)if(typeof o=="function")try{o(null)}catch(h){st(n,a,h)}else o.current=null}function sc(n,a,o){try{o()}catch(h){st(n,a,h)}}var em=!1;function ij(n,a){if(fi=pl,n=Ad(),oi(n)){if("selectionStart"in n)var o={start:n.selectionStart,end:n.selectionEnd};else e:{o=(o=n.ownerDocument)&&o.defaultView||window;var h=o.getSelection&&o.getSelection();if(h&&h.rangeCount!==0){o=h.anchorNode;var x=h.anchorOffset,v=h.focusNode;h=h.focusOffset;try{o.nodeType,v.nodeType}catch{o=null;break e}var S=0,I=-1,D=-1,Y=0,ne=0,re=n,te=null;t:for(;;){for(var me;re!==o||x!==0&&re.nodeType!==3||(I=S+x),re!==v||h!==0&&re.nodeType!==3||(D=S+h),re.nodeType===3&&(S+=re.nodeValue.length),(me=re.firstChild)!==null;)te=re,re=me;for(;;){if(re===n)break t;if(te===o&&++Y===x&&(I=S),te===v&&++ne===h&&(D=S),(me=re.nextSibling)!==null)break;re=te,te=re.parentNode}re=me}o=I===-1||D===-1?null:{start:I,end:D}}else o=null}o=o||{start:0,end:0}}else o=null;for(gi={focusedElem:n,selectionRange:o},pl=!1,ge=a;ge!==null;)if(a=ge,n=a.child,(a.subtreeFlags&1028)!==0&&n!==null)n.return=a,ge=n;else for(;ge!==null;){a=ge;try{var xe=a.alternate;if((a.flags&1024)!==0)switch(a.tag){case 0:case 11:case 15:break;case 1:if(xe!==null){var je=xe.memoizedProps,ot=xe.memoizedState,G=a.stateNode,q=G.getSnapshotBeforeUpdate(a.elementType===a.type?je:wn(a.type,je),ot);G.__reactInternalSnapshotBeforeUpdate=q}break;case 3:var K=a.stateNode.containerInfo;K.nodeType===1?K.textContent="":K.nodeType===9&&K.documentElement&&K.removeChild(K.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(oe){st(a,a.return,oe)}if(n=a.sibling,n!==null){n.return=a.return,ge=n;break}ge=a.return}return xe=em,em=!1,xe}function Ia(n,a,o){var h=a.updateQueue;if(h=h!==null?h.lastEffect:null,h!==null){var x=h=h.next;do{if((x.tag&n)===n){var v=x.destroy;x.destroy=void 0,v!==void 0&&sc(a,o,v)}x=x.next}while(x!==h)}}function Yl(n,a){if(a=a.updateQueue,a=a!==null?a.lastEffect:null,a!==null){var o=a=a.next;do{if((o.tag&n)===n){var h=o.create;o.destroy=h()}o=o.next}while(o!==a)}}function rc(n){var a=n.ref;if(a!==null){var o=n.stateNode;switch(n.tag){case 5:n=o;break;default:n=o}typeof a=="function"?a(n):a.current=n}}function tm(n){var a=n.alternate;a!==null&&(n.alternate=null,tm(a)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(a=n.stateNode,a!==null&&(delete a[Ln],delete a[wa],delete a[vi],delete a[Wx],delete a[Hx])),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}function nm(n){return n.tag===5||n.tag===3||n.tag===4}function sm(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||nm(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function ac(n,a,o){var h=n.tag;if(h===5||h===6)n=n.stateNode,a?o.nodeType===8?o.parentNode.insertBefore(n,a):o.insertBefore(n,a):(o.nodeType===8?(a=o.parentNode,a.insertBefore(n,o)):(a=o,a.appendChild(n)),o=o._reactRootContainer,o!=null||a.onclick!==null||(a.onclick=Cl));else if(h!==4&&(n=n.child,n!==null))for(ac(n,a,o),n=n.sibling;n!==null;)ac(n,a,o),n=n.sibling}function lc(n,a,o){var h=n.tag;if(h===5||h===6)n=n.stateNode,a?o.insertBefore(n,a):o.appendChild(n);else if(h!==4&&(n=n.child,n!==null))for(lc(n,a,o),n=n.sibling;n!==null;)lc(n,a,o),n=n.sibling}var vt=null,bn=!1;function $s(n,a,o){for(o=o.child;o!==null;)rm(n,a,o),o=o.sibling}function rm(n,a,o){if(Ht&&typeof Ht.onCommitFiberUnmount=="function")try{Ht.onCommitFiberUnmount(Bs,o)}catch{}switch(o.tag){case 5:$t||Ir(o,a);case 6:var h=vt,x=bn;vt=null,$s(n,a,o),vt=h,bn=x,vt!==null&&(bn?(n=vt,o=o.stateNode,n.nodeType===8?n.parentNode.removeChild(o):n.removeChild(o)):vt.removeChild(o.stateNode));break;case 18:vt!==null&&(bn?(n=vt,o=o.stateNode,n.nodeType===8?yi(n.parentNode,o):n.nodeType===1&&yi(n,o),da(n)):yi(vt,o.stateNode));break;case 4:h=vt,x=bn,vt=o.stateNode.containerInfo,bn=!0,$s(n,a,o),vt=h,bn=x;break;case 0:case 11:case 14:case 15:if(!$t&&(h=o.updateQueue,h!==null&&(h=h.lastEffect,h!==null))){x=h=h.next;do{var v=x,S=v.destroy;v=v.tag,S!==void 0&&((v&2)!==0||(v&4)!==0)&&sc(o,a,S),x=x.next}while(x!==h)}$s(n,a,o);break;case 1:if(!$t&&(Ir(o,a),h=o.stateNode,typeof h.componentWillUnmount=="function"))try{h.props=o.memoizedProps,h.state=o.memoizedState,h.componentWillUnmount()}catch(I){st(o,a,I)}$s(n,a,o);break;case 21:$s(n,a,o);break;case 22:o.mode&1?($t=(h=$t)||o.memoizedState!==null,$s(n,a,o),$t=h):$s(n,a,o);break;default:$s(n,a,o)}}function am(n){var a=n.updateQueue;if(a!==null){n.updateQueue=null;var o=n.stateNode;o===null&&(o=n.stateNode=new oj),a.forEach(function(h){var x=xj.bind(null,n,h);o.has(h)||(o.add(h),h.then(x,x))})}}function Nn(n,a){var o=a.deletions;if(o!==null)for(var h=0;h<o.length;h++){var x=o[h];try{var v=n,S=a,I=S;e:for(;I!==null;){switch(I.tag){case 5:vt=I.stateNode,bn=!1;break e;case 3:vt=I.stateNode.containerInfo,bn=!0;break e;case 4:vt=I.stateNode.containerInfo,bn=!0;break e}I=I.return}if(vt===null)throw Error(r(160));rm(v,S,x),vt=null,bn=!1;var D=x.alternate;D!==null&&(D.return=null),x.return=null}catch(Y){st(x,a,Y)}}if(a.subtreeFlags&12854)for(a=a.child;a!==null;)lm(a,n),a=a.sibling}function lm(n,a){var o=n.alternate,h=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:if(Nn(a,n),_n(n),h&4){try{Ia(3,n,n.return),Yl(3,n)}catch(je){st(n,n.return,je)}try{Ia(5,n,n.return)}catch(je){st(n,n.return,je)}}break;case 1:Nn(a,n),_n(n),h&512&&o!==null&&Ir(o,o.return);break;case 5:if(Nn(a,n),_n(n),h&512&&o!==null&&Ir(o,o.return),n.flags&32){var x=n.stateNode;try{He(x,"")}catch(je){st(n,n.return,je)}}if(h&4&&(x=n.stateNode,x!=null)){var v=n.memoizedProps,S=o!==null?o.memoizedProps:v,I=n.type,D=n.updateQueue;if(n.updateQueue=null,D!==null)try{I==="input"&&v.type==="radio"&&v.name!=null&&mr(x,v),Rt(I,S);var Y=Rt(I,v);for(S=0;S<D.length;S+=2){var ne=D[S],re=D[S+1];ne==="style"?nt(x,re):ne==="dangerouslySetInnerHTML"?En(x,re):ne==="children"?He(x,re):T(x,ne,re,Y)}switch(I){case"input":en(x,v);break;case"textarea":os(x,v);break;case"select":var te=x._wrapperState.wasMultiple;x._wrapperState.wasMultiple=!!v.multiple;var me=v.value;me!=null?wt(x,!!v.multiple,me,!1):te!==!!v.multiple&&(v.defaultValue!=null?wt(x,!!v.multiple,v.defaultValue,!0):wt(x,!!v.multiple,v.multiple?[]:"",!1))}x[wa]=v}catch(je){st(n,n.return,je)}}break;case 6:if(Nn(a,n),_n(n),h&4){if(n.stateNode===null)throw Error(r(162));x=n.stateNode,v=n.memoizedProps;try{x.nodeValue=v}catch(je){st(n,n.return,je)}}break;case 3:if(Nn(a,n),_n(n),h&4&&o!==null&&o.memoizedState.isDehydrated)try{da(a.containerInfo)}catch(je){st(n,n.return,je)}break;case 4:Nn(a,n),_n(n);break;case 13:Nn(a,n),_n(n),x=n.child,x.flags&8192&&(v=x.memoizedState!==null,x.stateNode.isHidden=v,!v||x.alternate!==null&&x.alternate.memoizedState!==null||(cc=ze())),h&4&&am(n);break;case 22:if(ne=o!==null&&o.memoizedState!==null,n.mode&1?($t=(Y=$t)||ne,Nn(a,n),$t=Y):Nn(a,n),_n(n),h&8192){if(Y=n.memoizedState!==null,(n.stateNode.isHidden=Y)&&!ne&&(n.mode&1)!==0)for(ge=n,ne=n.child;ne!==null;){for(re=ge=ne;ge!==null;){switch(te=ge,me=te.child,te.tag){case 0:case 11:case 14:case 15:Ia(4,te,te.return);break;case 1:Ir(te,te.return);var xe=te.stateNode;if(typeof xe.componentWillUnmount=="function"){h=te,o=te.return;try{a=h,xe.props=a.memoizedProps,xe.state=a.memoizedState,xe.componentWillUnmount()}catch(je){st(h,o,je)}}break;case 5:Ir(te,te.return);break;case 22:if(te.memoizedState!==null){cm(re);continue}}me!==null?(me.return=te,ge=me):cm(re)}ne=ne.sibling}e:for(ne=null,re=n;;){if(re.tag===5){if(ne===null){ne=re;try{x=re.stateNode,Y?(v=x.style,typeof v.setProperty=="function"?v.setProperty("display","none","important"):v.display="none"):(I=re.stateNode,D=re.memoizedProps.style,S=D!=null&&D.hasOwnProperty("display")?D.display:null,I.style.display=gn("display",S))}catch(je){st(n,n.return,je)}}}else if(re.tag===6){if(ne===null)try{re.stateNode.nodeValue=Y?"":re.memoizedProps}catch(je){st(n,n.return,je)}}else if((re.tag!==22&&re.tag!==23||re.memoizedState===null||re===n)&&re.child!==null){re.child.return=re,re=re.child;continue}if(re===n)break e;for(;re.sibling===null;){if(re.return===null||re.return===n)break e;ne===re&&(ne=null),re=re.return}ne===re&&(ne=null),re.sibling.return=re.return,re=re.sibling}}break;case 19:Nn(a,n),_n(n),h&4&&am(n);break;case 21:break;default:Nn(a,n),_n(n)}}function _n(n){var a=n.flags;if(a&2){try{e:{for(var o=n.return;o!==null;){if(nm(o)){var h=o;break e}o=o.return}throw Error(r(160))}switch(h.tag){case 5:var x=h.stateNode;h.flags&32&&(He(x,""),h.flags&=-33);var v=sm(n);lc(n,v,x);break;case 3:case 4:var S=h.stateNode.containerInfo,I=sm(n);ac(n,I,S);break;default:throw Error(r(161))}}catch(D){st(n,n.return,D)}n.flags&=-3}a&4096&&(n.flags&=-4097)}function cj(n,a,o){ge=n,om(n)}function om(n,a,o){for(var h=(n.mode&1)!==0;ge!==null;){var x=ge,v=x.child;if(x.tag===22&&h){var S=x.memoizedState!==null||Vl;if(!S){var I=x.alternate,D=I!==null&&I.memoizedState!==null||$t;I=Vl;var Y=$t;if(Vl=S,($t=D)&&!Y)for(ge=x;ge!==null;)S=ge,D=S.child,S.tag===22&&S.memoizedState!==null?um(x):D!==null?(D.return=S,ge=D):um(x);for(;v!==null;)ge=v,om(v),v=v.sibling;ge=x,Vl=I,$t=Y}im(n)}else(x.subtreeFlags&8772)!==0&&v!==null?(v.return=x,ge=v):im(n)}}function im(n){for(;ge!==null;){var a=ge;if((a.flags&8772)!==0){var o=a.alternate;try{if((a.flags&8772)!==0)switch(a.tag){case 0:case 11:case 15:$t||Yl(5,a);break;case 1:var h=a.stateNode;if(a.flags&4&&!$t)if(o===null)h.componentDidMount();else{var x=a.elementType===a.type?o.memoizedProps:wn(a.type,o.memoizedProps);h.componentDidUpdate(x,o.memoizedState,h.__reactInternalSnapshotBeforeUpdate)}var v=a.updateQueue;v!==null&&ch(a,v,h);break;case 3:var S=a.updateQueue;if(S!==null){if(o=null,a.child!==null)switch(a.child.tag){case 5:o=a.child.stateNode;break;case 1:o=a.child.stateNode}ch(a,S,o)}break;case 5:var I=a.stateNode;if(o===null&&a.flags&4){o=I;var D=a.memoizedProps;switch(a.type){case"button":case"input":case"select":case"textarea":D.autoFocus&&o.focus();break;case"img":D.src&&(o.src=D.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(a.memoizedState===null){var Y=a.alternate;if(Y!==null){var ne=Y.memoizedState;if(ne!==null){var re=ne.dehydrated;re!==null&&da(re)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(r(163))}$t||a.flags&512&&rc(a)}catch(te){st(a,a.return,te)}}if(a===n){ge=null;break}if(o=a.sibling,o!==null){o.return=a.return,ge=o;break}ge=a.return}}function cm(n){for(;ge!==null;){var a=ge;if(a===n){ge=null;break}var o=a.sibling;if(o!==null){o.return=a.return,ge=o;break}ge=a.return}}function um(n){for(;ge!==null;){var a=ge;try{switch(a.tag){case 0:case 11:case 15:var o=a.return;try{Yl(4,a)}catch(D){st(a,o,D)}break;case 1:var h=a.stateNode;if(typeof h.componentDidMount=="function"){var x=a.return;try{h.componentDidMount()}catch(D){st(a,x,D)}}var v=a.return;try{rc(a)}catch(D){st(a,v,D)}break;case 5:var S=a.return;try{rc(a)}catch(D){st(a,S,D)}}}catch(D){st(a,a.return,D)}if(a===n){ge=null;break}var I=a.sibling;if(I!==null){I.return=a.return,ge=I;break}ge=a.return}}var uj=Math.ceil,Ql=C.ReactCurrentDispatcher,oc=C.ReactCurrentOwner,hn=C.ReactCurrentBatchConfig,Me=0,gt=null,ct=null,kt=0,Yt=0,Or=ws(0),ht=0,Oa=null,Qs=0,Jl=0,ic=0,La=null,qt=null,cc=0,Lr=1/0,Xn=null,Xl=!1,uc=null,Ts=null,Zl=!1,Es=null,eo=0,Fa=0,dc=null,to=-1,no=0;function It(){return(Me&6)!==0?ze():to!==-1?to:to=ze()}function Rs(n){return(n.mode&1)===0?1:(Me&2)!==0&&kt!==0?kt&-kt:Kx.transition!==null?(no===0&&(no=sd()),no):(n=Be,n!==0||(n=window.event,n=n===void 0?16:hd(n.type)),n)}function Sn(n,a,o,h){if(50<Fa)throw Fa=0,dc=null,Error(r(185));la(n,o,h),((Me&2)===0||n!==gt)&&(n===gt&&((Me&2)===0&&(Jl|=o),ht===4&&Ps(n,kt)),Bt(n,h),o===1&&Me===0&&(a.mode&1)===0&&(Lr=ze()+500,Rl&&Ns()))}function Bt(n,a){var o=n.callbackNode;Kg(n,a);var h=dl(n,n===gt?kt:0);if(h===0)o!==null&&sa(o),n.callbackNode=null,n.callbackPriority=0;else if(a=h&-h,n.callbackPriority!==a){if(o!=null&&sa(o),a===1)n.tag===0?Gx(hm.bind(null,n)):Jd(hm.bind(null,n)),Bx(function(){(Me&6)===0&&Ns()}),o=null;else{switch(rd(h)){case 1:o=ra;break;case 4:o=ll;break;case 16:o=qs;break;case 536870912:o=aa;break;default:o=qs}o=vm(o,dm.bind(null,n))}n.callbackPriority=a,n.callbackNode=o}}function dm(n,a){if(to=-1,no=0,(Me&6)!==0)throw Error(r(327));var o=n.callbackNode;if(Fr()&&n.callbackNode!==o)return null;var h=dl(n,n===gt?kt:0);if(h===0)return null;if((h&30)!==0||(h&n.expiredLanes)!==0||a)a=so(n,h);else{a=h;var x=Me;Me|=2;var v=pm();(gt!==n||kt!==a)&&(Xn=null,Lr=ze()+500,Xs(n,a));do try{mj();break}catch(I){mm(n,I)}while(!0);Ei(),Ql.current=v,Me=x,ct!==null?a=0:(gt=null,kt=0,a=ht)}if(a!==0){if(a===2&&(x=Ho(n),x!==0&&(h=x,a=hc(n,x))),a===1)throw o=Oa,Xs(n,0),Ps(n,h),Bt(n,ze()),o;if(a===6)Ps(n,h);else{if(x=n.current.alternate,(h&30)===0&&!dj(x)&&(a=so(n,h),a===2&&(v=Ho(n),v!==0&&(h=v,a=hc(n,v))),a===1))throw o=Oa,Xs(n,0),Ps(n,h),Bt(n,ze()),o;switch(n.finishedWork=x,n.finishedLanes=h,a){case 0:case 1:throw Error(r(345));case 2:Zs(n,qt,Xn);break;case 3:if(Ps(n,h),(h&130023424)===h&&(a=cc+500-ze(),10<a)){if(dl(n,0)!==0)break;if(x=n.suspendedLanes,(x&h)!==h){It(),n.pingedLanes|=n.suspendedLanes&x;break}n.timeoutHandle=ji(Zs.bind(null,n,qt,Xn),a);break}Zs(n,qt,Xn);break;case 4:if(Ps(n,h),(h&4194240)===h)break;for(a=n.eventTimes,x=-1;0<h;){var S=31-Mt(h);v=1<<S,S=a[S],S>x&&(x=S),h&=~v}if(h=x,h=ze()-h,h=(120>h?120:480>h?480:1080>h?1080:1920>h?1920:3e3>h?3e3:4320>h?4320:1960*uj(h/1960))-h,10<h){n.timeoutHandle=ji(Zs.bind(null,n,qt,Xn),h);break}Zs(n,qt,Xn);break;case 5:Zs(n,qt,Xn);break;default:throw Error(r(329))}}}return Bt(n,ze()),n.callbackNode===o?dm.bind(null,n):null}function hc(n,a){var o=La;return n.current.memoizedState.isDehydrated&&(Xs(n,a).flags|=256),n=so(n,a),n!==2&&(a=qt,qt=o,a!==null&&mc(a)),n}function mc(n){qt===null?qt=n:qt.push.apply(qt,n)}function dj(n){for(var a=n;;){if(a.flags&16384){var o=a.updateQueue;if(o!==null&&(o=o.stores,o!==null))for(var h=0;h<o.length;h++){var x=o[h],v=x.getSnapshot;x=x.value;try{if(!vn(v(),x))return!1}catch{return!1}}}if(o=a.child,a.subtreeFlags&16384&&o!==null)o.return=a,a=o;else{if(a===n)break;for(;a.sibling===null;){if(a.return===null||a.return===n)return!0;a=a.return}a.sibling.return=a.return,a=a.sibling}}return!0}function Ps(n,a){for(a&=~ic,a&=~Jl,n.suspendedLanes|=a,n.pingedLanes&=~a,n=n.expirationTimes;0<a;){var o=31-Mt(a),h=1<<o;n[o]=-1,a&=~h}}function hm(n){if((Me&6)!==0)throw Error(r(327));Fr();var a=dl(n,0);if((a&1)===0)return Bt(n,ze()),null;var o=so(n,a);if(n.tag!==0&&o===2){var h=Ho(n);h!==0&&(a=h,o=hc(n,h))}if(o===1)throw o=Oa,Xs(n,0),Ps(n,a),Bt(n,ze()),o;if(o===6)throw Error(r(345));return n.finishedWork=n.current.alternate,n.finishedLanes=a,Zs(n,qt,Xn),Bt(n,ze()),null}function pc(n,a){var o=Me;Me|=1;try{return n(a)}finally{Me=o,Me===0&&(Lr=ze()+500,Rl&&Ns())}}function Js(n){Es!==null&&Es.tag===0&&(Me&6)===0&&Fr();var a=Me;Me|=1;var o=hn.transition,h=Be;try{if(hn.transition=null,Be=1,n)return n()}finally{Be=h,hn.transition=o,Me=a,(Me&6)===0&&Ns()}}function fc(){Yt=Or.current,Ve(Or)}function Xs(n,a){n.finishedWork=null,n.finishedLanes=0;var o=n.timeoutHandle;if(o!==-1&&(n.timeoutHandle=-1,qx(o)),ct!==null)for(o=ct.return;o!==null;){var h=o;switch(Ni(h),h.tag){case 1:h=h.type.childContextTypes,h!=null&&Tl();break;case 3:Pr(),Ve(_t),Ve(Nt),Mi();break;case 5:Li(h);break;case 4:Pr();break;case 13:Ve(Xe);break;case 19:Ve(Xe);break;case 10:Ri(h.type._context);break;case 22:case 23:fc()}o=o.return}if(gt=n,ct=n=As(n.current,null),kt=Yt=a,ht=0,Oa=null,ic=Jl=Qs=0,qt=La=null,Ks!==null){for(a=0;a<Ks.length;a++)if(o=Ks[a],h=o.interleaved,h!==null){o.interleaved=null;var x=h.next,v=o.pending;if(v!==null){var S=v.next;v.next=x,h.next=S}o.pending=h}Ks=null}return n}function mm(n,a){do{var o=ct;try{if(Ei(),Ul.current=Wl,ql){for(var h=Ze.memoizedState;h!==null;){var x=h.queue;x!==null&&(x.pending=null),h=h.next}ql=!1}if(Ys=0,ft=dt=Ze=null,Ta=!1,Ea=0,oc.current=null,o===null||o.return===null){ht=1,Oa=a,ct=null;break}e:{var v=n,S=o.return,I=o,D=a;if(a=kt,I.flags|=32768,D!==null&&typeof D=="object"&&typeof D.then=="function"){var Y=D,ne=I,re=ne.tag;if((ne.mode&1)===0&&(re===0||re===11||re===15)){var te=ne.alternate;te?(ne.updateQueue=te.updateQueue,ne.memoizedState=te.memoizedState,ne.lanes=te.lanes):(ne.updateQueue=null,ne.memoizedState=null)}var me=_h(S);if(me!==null){me.flags&=-257,Dh(me,S,I,v,a),me.mode&1&&Mh(v,Y,a),a=me,D=Y;var xe=a.updateQueue;if(xe===null){var je=new Set;je.add(D),a.updateQueue=je}else xe.add(D);break e}else{if((a&1)===0){Mh(v,Y,a),gc();break e}D=Error(r(426))}}else if(Qe&&I.mode&1){var ot=_h(S);if(ot!==null){(ot.flags&65536)===0&&(ot.flags|=256),Dh(ot,S,I,v,a),$i(Ar(D,I));break e}}v=D=Ar(D,I),ht!==4&&(ht=2),La===null?La=[v]:La.push(v),v=S;do{switch(v.tag){case 3:v.flags|=65536,a&=-a,v.lanes|=a;var G=Lh(v,D,a);ih(v,G);break e;case 1:I=D;var q=v.type,K=v.stateNode;if((v.flags&128)===0&&(typeof q.getDerivedStateFromError=="function"||K!==null&&typeof K.componentDidCatch=="function"&&(Ts===null||!Ts.has(K)))){v.flags|=65536,a&=-a,v.lanes|=a;var oe=Fh(v,I,a);ih(v,oe);break e}}v=v.return}while(v!==null)}gm(o)}catch(ye){a=ye,ct===o&&o!==null&&(ct=o=o.return);continue}break}while(!0)}function pm(){var n=Ql.current;return Ql.current=Wl,n===null?Wl:n}function gc(){(ht===0||ht===3||ht===2)&&(ht=4),gt===null||(Qs&268435455)===0&&(Jl&268435455)===0||Ps(gt,kt)}function so(n,a){var o=Me;Me|=2;var h=pm();(gt!==n||kt!==a)&&(Xn=null,Xs(n,a));do try{hj();break}catch(x){mm(n,x)}while(!0);if(Ei(),Me=o,Ql.current=h,ct!==null)throw Error(r(261));return gt=null,kt=0,ht}function hj(){for(;ct!==null;)fm(ct)}function mj(){for(;ct!==null&&!zo();)fm(ct)}function fm(n){var a=ym(n.alternate,n,Yt);n.memoizedProps=n.pendingProps,a===null?gm(n):ct=a,oc.current=null}function gm(n){var a=n;do{var o=a.alternate;if(n=a.return,(a.flags&32768)===0){if(o=aj(o,a,Yt),o!==null){ct=o;return}}else{if(o=lj(o,a),o!==null){o.flags&=32767,ct=o;return}if(n!==null)n.flags|=32768,n.subtreeFlags=0,n.deletions=null;else{ht=6,ct=null;return}}if(a=a.sibling,a!==null){ct=a;return}ct=a=n}while(a!==null);ht===0&&(ht=5)}function Zs(n,a,o){var h=Be,x=hn.transition;try{hn.transition=null,Be=1,pj(n,a,o,h)}finally{hn.transition=x,Be=h}return null}function pj(n,a,o,h){do Fr();while(Es!==null);if((Me&6)!==0)throw Error(r(327));o=n.finishedWork;var x=n.finishedLanes;if(o===null)return null;if(n.finishedWork=null,n.finishedLanes=0,o===n.current)throw Error(r(177));n.callbackNode=null,n.callbackPriority=0;var v=o.lanes|o.childLanes;if(Vg(n,v),n===gt&&(ct=gt=null,kt=0),(o.subtreeFlags&2064)===0&&(o.flags&2064)===0||Zl||(Zl=!0,vm(qs,function(){return Fr(),null})),v=(o.flags&15990)!==0,(o.subtreeFlags&15990)!==0||v){v=hn.transition,hn.transition=null;var S=Be;Be=1;var I=Me;Me|=4,oc.current=null,ij(n,o),lm(o,n),Ox(gi),pl=!!fi,gi=fi=null,n.current=o,cj(o),al(),Me=I,Be=S,hn.transition=v}else n.current=o;if(Zl&&(Zl=!1,Es=n,eo=x),v=n.pendingLanes,v===0&&(Ts=null),il(o.stateNode),Bt(n,ze()),a!==null)for(h=n.onRecoverableError,o=0;o<a.length;o++)x=a[o],h(x.value,{componentStack:x.stack,digest:x.digest});if(Xl)throw Xl=!1,n=uc,uc=null,n;return(eo&1)!==0&&n.tag!==0&&Fr(),v=n.pendingLanes,(v&1)!==0?n===dc?Fa++:(Fa=0,dc=n):Fa=0,Ns(),null}function Fr(){if(Es!==null){var n=rd(eo),a=hn.transition,o=Be;try{if(hn.transition=null,Be=16>n?16:n,Es===null)var h=!1;else{if(n=Es,Es=null,eo=0,(Me&6)!==0)throw Error(r(331));var x=Me;for(Me|=4,ge=n.current;ge!==null;){var v=ge,S=v.child;if((ge.flags&16)!==0){var I=v.deletions;if(I!==null){for(var D=0;D<I.length;D++){var Y=I[D];for(ge=Y;ge!==null;){var ne=ge;switch(ne.tag){case 0:case 11:case 15:Ia(8,ne,v)}var re=ne.child;if(re!==null)re.return=ne,ge=re;else for(;ge!==null;){ne=ge;var te=ne.sibling,me=ne.return;if(tm(ne),ne===Y){ge=null;break}if(te!==null){te.return=me,ge=te;break}ge=me}}}var xe=v.alternate;if(xe!==null){var je=xe.child;if(je!==null){xe.child=null;do{var ot=je.sibling;je.sibling=null,je=ot}while(je!==null)}}ge=v}}if((v.subtreeFlags&2064)!==0&&S!==null)S.return=v,ge=S;else e:for(;ge!==null;){if(v=ge,(v.flags&2048)!==0)switch(v.tag){case 0:case 11:case 15:Ia(9,v,v.return)}var G=v.sibling;if(G!==null){G.return=v.return,ge=G;break e}ge=v.return}}var q=n.current;for(ge=q;ge!==null;){S=ge;var K=S.child;if((S.subtreeFlags&2064)!==0&&K!==null)K.return=S,ge=K;else e:for(S=q;ge!==null;){if(I=ge,(I.flags&2048)!==0)try{switch(I.tag){case 0:case 11:case 15:Yl(9,I)}}catch(ye){st(I,I.return,ye)}if(I===S){ge=null;break e}var oe=I.sibling;if(oe!==null){oe.return=I.return,ge=oe;break e}ge=I.return}}if(Me=x,Ns(),Ht&&typeof Ht.onPostCommitFiberRoot=="function")try{Ht.onPostCommitFiberRoot(Bs,n)}catch{}h=!0}return h}finally{Be=o,hn.transition=a}}return!1}function xm(n,a,o){a=Ar(o,a),a=Lh(n,a,1),n=Cs(n,a,1),a=It(),n!==null&&(la(n,1,a),Bt(n,a))}function st(n,a,o){if(n.tag===3)xm(n,n,o);else for(;a!==null;){if(a.tag===3){xm(a,n,o);break}else if(a.tag===1){var h=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof h.componentDidCatch=="function"&&(Ts===null||!Ts.has(h))){n=Ar(o,n),n=Fh(a,n,1),a=Cs(a,n,1),n=It(),a!==null&&(la(a,1,n),Bt(a,n));break}}a=a.return}}function fj(n,a,o){var h=n.pingCache;h!==null&&h.delete(a),a=It(),n.pingedLanes|=n.suspendedLanes&o,gt===n&&(kt&o)===o&&(ht===4||ht===3&&(kt&130023424)===kt&&500>ze()-cc?Xs(n,0):ic|=o),Bt(n,a)}function jm(n,a){a===0&&((n.mode&1)===0?a=1:(a=_e,_e<<=1,(_e&130023424)===0&&(_e=4194304)));var o=It();n=Yn(n,a),n!==null&&(la(n,a,o),Bt(n,o))}function gj(n){var a=n.memoizedState,o=0;a!==null&&(o=a.retryLane),jm(n,o)}function xj(n,a){var o=0;switch(n.tag){case 13:var h=n.stateNode,x=n.memoizedState;x!==null&&(o=x.retryLane);break;case 19:h=n.stateNode;break;default:throw Error(r(314))}h!==null&&h.delete(a),jm(n,o)}var ym;ym=function(n,a,o){if(n!==null)if(n.memoizedProps!==a.pendingProps||_t.current)Ut=!0;else{if((n.lanes&o)===0&&(a.flags&128)===0)return Ut=!1,rj(n,a,o);Ut=(n.flags&131072)!==0}else Ut=!1,Qe&&(a.flags&1048576)!==0&&Xd(a,Al,a.index);switch(a.lanes=0,a.tag){case 2:var h=a.type;Kl(n,a),n=a.pendingProps;var x=Nr(a,Nt.current);Rr(a,o),x=Ui(null,a,h,n,x,o);var v=qi();return a.flags|=1,typeof x=="object"&&x!==null&&typeof x.render=="function"&&x.$$typeof===void 0?(a.tag=1,a.memoizedState=null,a.updateQueue=null,Dt(h)?(v=!0,El(a)):v=!1,a.memoizedState=x.state!==null&&x.state!==void 0?x.state:null,Ii(a),x.updater=Hl,a.stateNode=x,x._reactInternals=a,Ki(a,h,n,o),a=Ji(null,a,h,!0,v,o)):(a.tag=0,Qe&&v&&bi(a),At(null,a,x,o),a=a.child),a;case 16:h=a.elementType;e:{switch(Kl(n,a),n=a.pendingProps,x=h._init,h=x(h._payload),a.type=h,x=a.tag=yj(h),n=wn(h,n),x){case 0:a=Qi(null,a,h,n,o);break e;case 1:a=Hh(null,a,h,n,o);break e;case 11:a=Uh(null,a,h,n,o);break e;case 14:a=qh(null,a,h,wn(h.type,n),o);break e}throw Error(r(306,h,""))}return a;case 0:return h=a.type,x=a.pendingProps,x=a.elementType===h?x:wn(h,x),Qi(n,a,h,x,o);case 1:return h=a.type,x=a.pendingProps,x=a.elementType===h?x:wn(h,x),Hh(n,a,h,x,o);case 3:e:{if(Gh(a),n===null)throw Error(r(387));h=a.pendingProps,v=a.memoizedState,x=v.element,oh(n,a),_l(a,h,null,o);var S=a.memoizedState;if(h=S.element,v.isDehydrated)if(v={element:h,isDehydrated:!1,cache:S.cache,pendingSuspenseBoundaries:S.pendingSuspenseBoundaries,transitions:S.transitions},a.updateQueue.baseState=v,a.memoizedState=v,a.flags&256){x=Ar(Error(r(423)),a),a=Kh(n,a,h,o,x);break e}else if(h!==x){x=Ar(Error(r(424)),a),a=Kh(n,a,h,o,x);break e}else for(Vt=ks(a.stateNode.containerInfo.firstChild),Kt=a,Qe=!0,kn=null,o=ah(a,null,h,o),a.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling;else{if($r(),h===x){a=Jn(n,a,o);break e}At(n,a,h,o)}a=a.child}return a;case 5:return uh(a),n===null&&Ci(a),h=a.type,x=a.pendingProps,v=n!==null?n.memoizedProps:null,S=x.children,xi(h,x)?S=null:v!==null&&xi(h,v)&&(a.flags|=32),Wh(n,a),At(n,a,S,o),a.child;case 6:return n===null&&Ci(a),null;case 13:return Vh(n,a,o);case 4:return Oi(a,a.stateNode.containerInfo),h=a.pendingProps,n===null?a.child=Tr(a,null,h,o):At(n,a,h,o),a.child;case 11:return h=a.type,x=a.pendingProps,x=a.elementType===h?x:wn(h,x),Uh(n,a,h,x,o);case 7:return At(n,a,a.pendingProps,o),a.child;case 8:return At(n,a,a.pendingProps.children,o),a.child;case 12:return At(n,a,a.pendingProps.children,o),a.child;case 10:e:{if(h=a.type._context,x=a.pendingProps,v=a.memoizedProps,S=x.value,We(Ll,h._currentValue),h._currentValue=S,v!==null)if(vn(v.value,S)){if(v.children===x.children&&!_t.current){a=Jn(n,a,o);break e}}else for(v=a.child,v!==null&&(v.return=a);v!==null;){var I=v.dependencies;if(I!==null){S=v.child;for(var D=I.firstContext;D!==null;){if(D.context===h){if(v.tag===1){D=Qn(-1,o&-o),D.tag=2;var Y=v.updateQueue;if(Y!==null){Y=Y.shared;var ne=Y.pending;ne===null?D.next=D:(D.next=ne.next,ne.next=D),Y.pending=D}}v.lanes|=o,D=v.alternate,D!==null&&(D.lanes|=o),Pi(v.return,o,a),I.lanes|=o;break}D=D.next}}else if(v.tag===10)S=v.type===a.type?null:v.child;else if(v.tag===18){if(S=v.return,S===null)throw Error(r(341));S.lanes|=o,I=S.alternate,I!==null&&(I.lanes|=o),Pi(S,o,a),S=v.sibling}else S=v.child;if(S!==null)S.return=v;else for(S=v;S!==null;){if(S===a){S=null;break}if(v=S.sibling,v!==null){v.return=S.return,S=v;break}S=S.return}v=S}At(n,a,x.children,o),a=a.child}return a;case 9:return x=a.type,h=a.pendingProps.children,Rr(a,o),x=un(x),h=h(x),a.flags|=1,At(n,a,h,o),a.child;case 14:return h=a.type,x=wn(h,a.pendingProps),x=wn(h.type,x),qh(n,a,h,x,o);case 15:return Bh(n,a,a.type,a.pendingProps,o);case 17:return h=a.type,x=a.pendingProps,x=a.elementType===h?x:wn(h,x),Kl(n,a),a.tag=1,Dt(h)?(n=!0,El(a)):n=!1,Rr(a,o),Ih(a,h,x),Ki(a,h,x,o),Ji(null,a,h,!0,n,o);case 19:return Qh(n,a,o);case 22:return zh(n,a,o)}throw Error(r(156,a.tag))};function vm(n,a){return na(n,a)}function jj(n,a,o,h){this.tag=n,this.key=o,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=a,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=h,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function mn(n,a,o,h){return new jj(n,a,o,h)}function xc(n){return n=n.prototype,!(!n||!n.isReactComponent)}function yj(n){if(typeof n=="function")return xc(n)?1:0;if(n!=null){if(n=n.$$typeof,n===Q)return 11;if(n===ie)return 14}return 2}function As(n,a){var o=n.alternate;return o===null?(o=mn(n.tag,a,n.key,n.mode),o.elementType=n.elementType,o.type=n.type,o.stateNode=n.stateNode,o.alternate=n,n.alternate=o):(o.pendingProps=a,o.type=n.type,o.flags=0,o.subtreeFlags=0,o.deletions=null),o.flags=n.flags&14680064,o.childLanes=n.childLanes,o.lanes=n.lanes,o.child=n.child,o.memoizedProps=n.memoizedProps,o.memoizedState=n.memoizedState,o.updateQueue=n.updateQueue,a=n.dependencies,o.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext},o.sibling=n.sibling,o.index=n.index,o.ref=n.ref,o}function ro(n,a,o,h,x,v){var S=2;if(h=n,typeof n=="function")xc(n)&&(S=1);else if(typeof n=="string")S=5;else e:switch(n){case F:return er(o.children,x,v,a);case L:S=8,x|=8;break;case W:return n=mn(12,o,a,x|2),n.elementType=W,n.lanes=v,n;case H:return n=mn(13,o,a,x),n.elementType=H,n.lanes=v,n;case U:return n=mn(19,o,a,x),n.elementType=U,n.lanes=v,n;case J:return ao(o,x,v,a);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case A:S=10;break e;case M:S=9;break e;case Q:S=11;break e;case ie:S=14;break e;case X:S=16,h=null;break e}throw Error(r(130,n==null?n:typeof n,""))}return a=mn(S,o,a,x),a.elementType=n,a.type=h,a.lanes=v,a}function er(n,a,o,h){return n=mn(7,n,h,a),n.lanes=o,n}function ao(n,a,o,h){return n=mn(22,n,h,a),n.elementType=J,n.lanes=o,n.stateNode={isHidden:!1},n}function jc(n,a,o){return n=mn(6,n,null,a),n.lanes=o,n}function yc(n,a,o){return a=mn(4,n.children!==null?n.children:[],n.key,a),a.lanes=o,a.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},a}function vj(n,a,o,h,x){this.tag=a,this.containerInfo=n,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Go(0),this.expirationTimes=Go(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Go(0),this.identifierPrefix=h,this.onRecoverableError=x,this.mutableSourceEagerHydrationData=null}function vc(n,a,o,h,x,v,S,I,D){return n=new vj(n,a,o,I,D),a===1?(a=1,v===!0&&(a|=8)):a=0,v=mn(3,null,null,a),n.current=v,v.stateNode=n,v.memoizedState={element:h,isDehydrated:o,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ii(v),n}function kj(n,a,o){var h=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:O,key:h==null?null:""+h,children:n,containerInfo:a,implementation:o}}function km(n){if(!n)return bs;n=n._reactInternals;e:{if(Ft(n)!==n||n.tag!==1)throw Error(r(170));var a=n;do{switch(a.tag){case 3:a=a.stateNode.context;break e;case 1:if(Dt(a.type)){a=a.stateNode.__reactInternalMemoizedMergedChildContext;break e}}a=a.return}while(a!==null);throw Error(r(171))}if(n.tag===1){var o=n.type;if(Dt(o))return Yd(n,o,a)}return a}function wm(n,a,o,h,x,v,S,I,D){return n=vc(o,h,!0,n,x,v,S,I,D),n.context=km(null),o=n.current,h=It(),x=Rs(o),v=Qn(h,x),v.callback=a??null,Cs(o,v,x),n.current.lanes=x,la(n,x,h),Bt(n,h),n}function lo(n,a,o,h){var x=a.current,v=It(),S=Rs(x);return o=km(o),a.context===null?a.context=o:a.pendingContext=o,a=Qn(v,S),a.payload={element:n},h=h===void 0?null:h,h!==null&&(a.callback=h),n=Cs(x,a,S),n!==null&&(Sn(n,x,S,v),Ml(n,x,S)),S}function oo(n){if(n=n.current,!n.child)return null;switch(n.child.tag){case 5:return n.child.stateNode;default:return n.child.stateNode}}function bm(n,a){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var o=n.retryLane;n.retryLane=o!==0&&o<a?o:a}}function kc(n,a){bm(n,a),(n=n.alternate)&&bm(n,a)}function wj(){return null}var Nm=typeof reportError=="function"?reportError:function(n){console.error(n)};function wc(n){this._internalRoot=n}io.prototype.render=wc.prototype.render=function(n){var a=this._internalRoot;if(a===null)throw Error(r(409));lo(n,a,null,null)},io.prototype.unmount=wc.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var a=n.containerInfo;Js(function(){lo(null,n,null,null)}),a[Hn]=null}};function io(n){this._internalRoot=n}io.prototype.unstable_scheduleHydration=function(n){if(n){var a=od();n={blockedOn:null,target:n,priority:a};for(var o=0;o<js.length&&a!==0&&a<js[o].priority;o++);js.splice(o,0,n),o===0&&ud(n)}};function bc(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function co(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11&&(n.nodeType!==8||n.nodeValue!==" react-mount-point-unstable "))}function Sm(){}function bj(n,a,o,h,x){if(x){if(typeof h=="function"){var v=h;h=function(){var Y=oo(S);v.call(Y)}}var S=wm(a,h,n,0,null,!1,!1,"",Sm);return n._reactRootContainer=S,n[Hn]=S.current,va(n.nodeType===8?n.parentNode:n),Js(),S}for(;x=n.lastChild;)n.removeChild(x);if(typeof h=="function"){var I=h;h=function(){var Y=oo(D);I.call(Y)}}var D=vc(n,0,!1,null,null,!1,!1,"",Sm);return n._reactRootContainer=D,n[Hn]=D.current,va(n.nodeType===8?n.parentNode:n),Js(function(){lo(a,D,o,h)}),D}function uo(n,a,o,h,x){var v=o._reactRootContainer;if(v){var S=v;if(typeof x=="function"){var I=x;x=function(){var D=oo(S);I.call(D)}}lo(a,S,n,x)}else S=bj(o,a,n,x,h);return oo(S)}ad=function(n){switch(n.tag){case 3:var a=n.stateNode;if(a.current.memoizedState.isDehydrated){var o=yn(a.pendingLanes);o!==0&&(Ko(a,o|1),Bt(a,ze()),(Me&6)===0&&(Lr=ze()+500,Ns()))}break;case 13:Js(function(){var h=Yn(n,1);if(h!==null){var x=It();Sn(h,n,1,x)}}),kc(n,1)}},Vo=function(n){if(n.tag===13){var a=Yn(n,134217728);if(a!==null){var o=It();Sn(a,n,134217728,o)}kc(n,134217728)}},ld=function(n){if(n.tag===13){var a=Rs(n),o=Yn(n,a);if(o!==null){var h=It();Sn(o,n,a,h)}kc(n,a)}},od=function(){return Be},id=function(n,a){var o=Be;try{return Be=n,a()}finally{Be=o}},Wn=function(n,a,o){switch(a){case"input":if(en(n,o),a=o.name,o.type==="radio"&&a!=null){for(o=n;o.parentNode;)o=o.parentNode;for(o=o.querySelectorAll("input[name="+JSON.stringify(""+a)+'][type="radio"]'),a=0;a<o.length;a++){var h=o[a];if(h!==n&&h.form===n.form){var x=$l(h);if(!x)throw Error(r(90));Tt(h),en(h,x)}}}break;case"textarea":os(n,o);break;case"select":a=o.value,a!=null&&wt(n,!!o.multiple,a,!1)}},Ae=pc,cs=Js;var Nj={usingClientEntryPoint:!1,Events:[ba,wr,$l,Wt,bt,pc]},Ma={findFiberByHostInstance:zs,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Sj={bundleType:Ma.bundleType,version:Ma.version,rendererPackageName:Ma.rendererPackageName,rendererConfig:Ma.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:C.ReactCurrentDispatcher,findHostInstanceByFiber:function(n){return n=rl(n),n===null?null:n.stateNode},findFiberByHostInstance:Ma.findFiberByHostInstance||wj,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 ho=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ho.isDisabled&&ho.supportsFiber)try{Bs=ho.inject(Sj),Ht=ho}catch{}}return zt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Nj,zt.createPortal=function(n,a){var o=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!bc(a))throw Error(r(200));return kj(n,a,null,o)},zt.createRoot=function(n,a){if(!bc(n))throw Error(r(299));var o=!1,h="",x=Nm;return a!=null&&(a.unstable_strictMode===!0&&(o=!0),a.identifierPrefix!==void 0&&(h=a.identifierPrefix),a.onRecoverableError!==void 0&&(x=a.onRecoverableError)),a=vc(n,1,!1,null,null,o,!1,h,x),n[Hn]=a.current,va(n.nodeType===8?n.parentNode:n),new wc(a)},zt.findDOMNode=function(n){if(n==null)return null;if(n.nodeType===1)return n;var a=n._reactInternals;if(a===void 0)throw typeof n.render=="function"?Error(r(188)):(n=Object.keys(n).join(","),Error(r(268,n)));return n=rl(a),n=n===null?null:n.stateNode,n},zt.flushSync=function(n){return Js(n)},zt.hydrate=function(n,a,o){if(!co(a))throw Error(r(200));return uo(null,n,a,!0,o)},zt.hydrateRoot=function(n,a,o){if(!bc(n))throw Error(r(405));var h=o!=null&&o.hydratedSources||null,x=!1,v="",S=Nm;if(o!=null&&(o.unstable_strictMode===!0&&(x=!0),o.identifierPrefix!==void 0&&(v=o.identifierPrefix),o.onRecoverableError!==void 0&&(S=o.onRecoverableError)),a=wm(a,null,n,1,o??null,x,!1,v,S),n[Hn]=a.current,va(n),h)for(n=0;n<h.length;n++)o=h[n],x=o._getVersion,x=x(o._source),a.mutableSourceEagerHydrationData==null?a.mutableSourceEagerHydrationData=[o,x]:a.mutableSourceEagerHydrationData.push(o,x);return new io(a)},zt.render=function(n,a,o){if(!co(a))throw Error(r(200));return uo(null,n,a,!1,o)},zt.unmountComponentAtNode=function(n){if(!co(n))throw Error(r(40));return n._reactRootContainer?(Js(function(){uo(null,null,n,!1,function(){n._reactRootContainer=null,n[Hn]=null})}),!0):!1},zt.unstable_batchedUpdates=pc,zt.unstable_renderSubtreeIntoContainer=function(n,a,o,h){if(!co(o))throw Error(r(200));if(n==null||n._reactInternals===void 0)throw Error(r(38));return uo(n,a,o,!1,h)},zt.version="18.3.1-next-f1338f8080-20240426",zt}var Om;function rf(){if(Om)return Cc.exports;Om=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(s){console.error(s)}}return t(),Cc.exports=Oj(),Cc.exports}var Lm;function Lj(){if(Lm)return mo;Lm=1;var t=rf();return mo.createRoot=t.createRoot,mo.hydrateRoot=t.hydrateRoot,mo}var Fj=Lj();function lr(t){const s=t.trim();if(!s)return s;const r=/^[a-z]+ /.test(s)?`${s.charAt(0).toUpperCase()}${s.slice(1)}`:s;return/[.!?]$/.test(r)?r:`${r}.`}const Fm=": git merge ";function Wa(t){const s=t.lastIndexOf(Fm);if(s<0)return null;const r=t.slice(s+2).replace(/\.$/,"").trim();return r.length>Fm.length-2?{said:t.slice(0,s),command:r}:null}function Ie(t){return t.role==="owner"||t.role==="admin"}class ut extends Error{constructor(s,r,l,i={}){super(s),this.code=r,this.status=l,this.body=i}}class Gr extends ut{constructor(s){super(s,"signed-out",401)}}class ss extends ut{constructor(s,r="not-found"){super(s,r,404)}}function Mm(t,s){const r=new URLSearchParams;for(const[l,i]of Object.entries(t))i&&r.set(l,i);return s&&r.set("after",s),r}let af="",lf="/api";const nu="orchestrator:onboarding";function Mj(t,s){lf=!t||t===s?"/api":`/api/orgs/${encodeURIComponent(t)}`}function ir(t){return t==="/api/orgs"?t:`${lf}${t.slice(4)}`}function B(t,s,r){return Ot(t,ir(s),r,af)}async function Ot(t,s,r,l){const i={};r!==void 0&&(i["content-type"]="application/json"),t!=="GET"&&(i["x-csrf-token"]=l);const c=await fetch(s,{method:t,headers:i,body:r===void 0?void 0:JSON.stringify(r)}).catch(()=>{throw new Error("The orchestrator did not answer. Check that it is running and reachable from here, then try again.")}),d=await c.json().catch(()=>({})),u=typeof d.error=="string"&&d.error.trim()?lr(d.error):null;if(c.status===401)throw new Gr(u??"Sign in first.");const p=typeof d.code=="string"?d.code:"error";if(c.status===404)throw new ss(u??"Not found.",p==="error"?"not-found":p);if(!c.ok)throw new ut(u??`The orchestrator failed to answer (${c.status} ${c.statusText}). Try again; when it keeps failing, the orchestrator's log says why.`,p,c.status,d);return d}function ke(t){return B("GET",t)}const rt={config:()=>Ot("GET","/api/identity/config",void 0,"").then(t=>t.mode==="self-hosted"?null:t,t=>{if(t instanceof ss)return null;throw t}),me:()=>Ot("GET","/api/identity",void 0,""),addLogin:(t,s)=>Ot("POST",`/api/identity/logins/${t}`,void 0,s),removeLogin:(t,s)=>Ot("DELETE",`/api/identity/logins/${t}`,void 0,s),awaitingLogin:t=>Ot("GET",`/api/identity/logins/confirm/${encodeURIComponent(t)}`,void 0,""),confirmLogin:(t,s)=>Ot("POST",`/api/identity/logins/confirm/${encodeURIComponent(t)}`,void 0,s),createOrganization:(t,s)=>Ot("POST","/api/signup/organization",t,s),signOut:t=>Ot("POST","/api/identity/logout",void 0,t),operatorFunnel:t=>Ot("GET",`/api/operator/funnel?days=${t}`,void 0,""),join:(t,s)=>Ot("POST","/api/identity/join",{token:t},s),orgs:()=>Ot("GET","/api/me/orgs",void 0,""),joinByDirectory:(t,s)=>Ot("POST",`/api/me/joinable/${encodeURIComponent(t)}`,void 0,s),acceptInvitation:(t,s)=>Ot("POST",`/api/me/invitations/${encodeURIComponent(t)}/accept`,void 0,s),declineInvitation:(t,s)=>Ot("DELETE",`/api/me/invitations/${encodeURIComponent(t)}`,void 0,s)},bo={sessions:()=>ke("/api/me/sessions").then(t=>t.sessions),end:t=>B("DELETE",`/api/me/sessions/${encodeURIComponent(t)}`),apps:()=>ke("/api/me/apps").then(t=>t.apps),takeBack:t=>B("DELETE",`/api/me/apps/${encodeURIComponent(t)}`)},Ya={config:()=>ke("/api/auth/config"),me:async()=>{const t=await ke("/api/me");return af=t.csrf,t.user},login:(t,s)=>B("POST","/api/auth/login",{email:t,password:s}),setup:t=>B("POST","/api/auth/setup",t),logout:()=>B("POST","/api/auth/logout"),changePassword:(t,s)=>B("POST","/api/me/password",{current:t,next:s})},Xt={users:()=>ke("/api/users").then(t=>t.users),teams:()=>ke("/api/teams").then(t=>t.teams),create:t=>B("POST","/api/users",t).then(s=>s.user),update:(t,s)=>B("PATCH",`/api/users/${t}`,s).then(r=>r.user),remove:t=>B("DELETE",`/api/users/${t}`)},Kr={page:t=>ke(`/api/members/${t}`),invites:()=>ke("/api/invites").then(t=>t.invites),invite:t=>B("POST","/api/invites",t),resend:t=>B("POST",`/api/invites/${t}/resend`).then(s=>s.invite),revoke:t=>B("DELETE",`/api/invites/${t}`),leave:()=>B("POST","/api/me/leave")},of=["repositories","requests","tasks","usage","members","settings","keys"],_j={repositories:"write",requests:"write",tasks:"write",usage:"read",members:"read",settings:"read",keys:"write"},cr={list:t=>ke(`/api/keys${t?`?serviceAccount=${t}`:""}`).then(s=>s.keys),create:t=>B("POST","/api/keys",t),revoke:t=>B("DELETE",`/api/keys/${t}`),serviceAccounts:()=>ke("/api/service-accounts").then(t=>t.serviceAccounts),createServiceAccount:t=>B("POST","/api/service-accounts",t).then(s=>s.serviceAccount),updateServiceAccount:(t,s)=>B("PATCH",`/api/service-accounts/${t}`,s),removeServiceAccount:t=>B("DELETE",`/api/service-accounts/${t}`)},_m={read:()=>ke("/api/directory-join"),set:(t,s="member")=>B("PUT","/api/directory-join",{on:t,role:s}).then(r=>r.join)},po={list:()=>ke("/api/sso/domains"),add:t=>B("POST","/api/sso/domains",{domain:t}).then(s=>s.domain),verify:t=>B("POST",`/api/sso/domains/${encodeURIComponent(t)}/verify`).then(s=>s.domain),remove:t=>B("DELETE",`/api/sso/domains/${encodeURIComponent(t)}`)},No={read:()=>ke("/api/directory"),preview:t=>B("POST","/api/directory/preview",{mapping:t}),apply:(t,s)=>B("PUT","/api/directory",{mapping:t,fingerprint:s}),setTags:(t,s)=>B("PUT",`/api/members/${t}/tags`,{tags:s}).then(r=>r.tags)},Dm={read:()=>ke("/api/org"),rename:t=>B("PUT","/api/org",{name:t})},su={read:()=>ke("/api/settings/task-limits"),change:t=>B("PUT","/api/settings/task-limits",t)},Um={read:()=>ke("/api/privacy"),change:t=>B("PUT","/api/privacy",t).then(s=>s.privacy)};async function Ec(t,s,r,l,i){const c=t===s?"/api":`/api/orgs/${encodeURIComponent(t)}`,d=async(p,f,g,j)=>{const y=await fetch(`${c}${f}`,{method:p,headers:{...g===void 0?{}:{"content-type":"application/json"},...j?{"x-csrf-token":j}:{}},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.")}),k=await y.json().catch(()=>({}));if(y.status===401)throw new Gr(k.error??"sign in first");if(!y.ok)throw new ut(k.error??`The orchestrator failed to answer (${y.status} ${y.statusText}).`,typeof k.code=="string"?k.code:"error",y.status);return k};if(r==="GET")return d(r,l);const{csrf:u}=await d("GET","/me");return d(r,l,i,u)}const So={orgs:async()=>await Ne.orgs()??{default:"",orgs:[]},rename:(t,s,r)=>Ec(t,s,"PATCH","/me",{name:r}),summary:(t,s)=>Ec(t,s,"GET","/me/deletion").then(r=>r.summary),remove:(t,s,r)=>Ec(t,s,"POST","/me/deletion",{confirm:r})},ru={list:()=>ke("/api/task-secrets"),set:t=>B("PUT","/api/task-secrets",t).then(s=>s.secret),remove:t=>B("DELETE","/api/task-secrets",t)},Rc={read:()=>ke("/api/scim"),create:()=>B("POST","/api/scim/token"),remove:()=>B("DELETE","/api/scim/token")},qm={read:t=>B("POST","/api/join/read",{token:t}),accept:(t,s)=>B("POST","/api/join",{token:t,...s})},Ne={summary:()=>ke("/api/activity/summary"),onboarding:()=>ke("/api/activity/onboarding"),changeOnboarding:t=>B("PUT","/api/activity/onboarding",t).then(s=>(window.dispatchEvent(new Event(nu)),s)),usageReport:(t,s)=>ke(`/api/activity/usage?${new URLSearchParams({days:String(t),...s?{repo:s}:{}})}`),usageExport:(t,s,r)=>ir(`/api/activity/usage/export?${new URLSearchParams({days:String(t),format:s,...r?{repo:r}:{}})}`),leaderboard:t=>ke(`/api/activity/leaderboard?days=${t}`),audit:(t,s)=>ke(`/api/events?${Mm(t,s)}`).catch(r=>{if(r instanceof ss)return null;throw r}),event:t=>ke(`/api/events/${encodeURIComponent(t)}`),auditExport:(t,s)=>ir(`/api/events/export?${Mm(t,null)}&format=${s}`),orgs:()=>ke("/api/orgs").catch(t=>{if(t instanceof Gr)return null;throw t}),repos:()=>ke("/api/repos").then(t=>t.repos),inventory:t=>ke(`/api/repos/${t}/inventory`),history:(t,s)=>ke(`/api/repos/${t}/history${s?`?path=${encodeURIComponent(s)}`:""}`).then(r=>r.history),sync:t=>B("POST",`/api/repos/${t}/sync`),disconnect:t=>B("DELETE",`/api/repos/${t}`),connectRepo:t=>B("POST","/api/repos",t).then(s=>s.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 s=new URLSearchParams({...t.after?{after:t.after}:{},...t.repoId?{repo:t.repoId}:{},...t.status?{status:t.status}:{}});return ke(`/api/requests?${s}`)},skill:(t,s)=>ke(`/api/repos/${t}/skills/${s}`),command:(t,s)=>ke(`/api/repos/${t}/commands/${encodeURIComponent(s)}`),mcpServer:(t,s)=>ke(`/api/repos/${t}/mcp-servers/${encodeURIComponent(s)}`),proposal:(t,s)=>B("POST",`/api/repos/${t}/changes/proposal`,{change:s}),propose:(t,s,r,l,i)=>B("POST",`/api/repos/${t}/changes`,{baseSha:s,change:r,message:l,branch:i}).then(c=>c.request),requestDescription:(t,s)=>ke(`/api/repos/${t}/requests/${s}/description`),requestAction:(t,s,r)=>B("POST",`/api/repos/${t}/requests/${s}/${r}`).then(l=>l.request),onForge:(t,s)=>ke(`/api/repos/${t}/requests/${s}/on-forge`),openOnForge:(t,s)=>B("POST",`/api/repos/${t}/requests/${s}/on-forge`),forge:t=>ke(`/api/repos/${t}/forge`),saveForge:(t,s)=>B("PUT",`/api/repos/${t}/forge`,s),removeForge:t=>B("DELETE",`/api/repos/${t}/forge`),usageProposal:(t,s)=>B("POST",`/api/repos/${t}/usage/proposal`,{action:s}),proposeUsage:(t,s,r,l,i)=>B("POST",`/api/repos/${t}/usage/propose`,{action:i,baseSha:s,message:r,branch:l}).then(c=>c.request)},Co=5,Dj={tasks:t=>ke(`/api/search?${new URLSearchParams({q:t})}`)},$e={budgets:()=>ke("/api/policies/current-budgets"),options:()=>ke("/api/tasks/options"),page:(t,s)=>{const r=new URLSearchParams({...t?{after:t}:{},...s?{since:s}:{}}).toString();return ke(r?`/api/tasks?${r}`:"/api/tasks")},since:async t=>{const s=[];for(let r=null;;){const l=await $e.page(r,t);if(s.push(...l.tasks),!l.next)return s;r=l.next}},get:(t,s)=>ke(`/api/tasks/${t}?after=${s}`),eventsUrl:(t,s)=>`/api/tasks/${t}/events?after=${s}`,start:t=>B("POST","/api/tasks",t).then(s=>s.task),cancel:t=>B("POST",`/api/tasks/${t}/cancel`).then(s=>s.task),answerStopped:(t,s)=>B("POST",`/api/tasks/${encodeURIComponent(t)}/answer`,{answer:s}).then(r=>r.task),move:(t,s)=>B("POST",`/api/tasks/${encodeURIComponent(t)}/move`,{path:s}),answerQuestions:(t,s,r)=>B("POST",`/api/tasks/${t}/requests/${encodeURIComponent(s)}`,{answer:{answers:r},commandId:crypto.randomUUID()}),answerPlan:(t,s,r,l)=>B("POST",`/api/tasks/${t}/requests/${encodeURIComponent(s)}`,{answer:{decision:r,...l?{plan:l}:{}},commandId:crypto.randomUUID()}),answer:(t,s,r,l)=>B("POST",`/api/tasks/${t}/requests/${encodeURIComponent(s)}`,{answer:{decision:r,...r==="deny"&&l?{note:l}:{}},commandId:crypto.randomUUID()}),message:(t,s,r)=>B("POST",`/api/tasks/${t}/messages`,{text:s.text,...s.quotes.length?{quotes:s.quotes}:{},commandId:r}).then(l=>l.followUp),editMessage:(t,s,r)=>B("PATCH",`/api/tasks/${t}/messages/${encodeURIComponent(s)}`,r).then(l=>l.message),removeMessage:(t,s)=>B("DELETE",`/api/tasks/${t}/messages/${encodeURIComponent(s)}`),suggest:(t,s,r)=>B("POST",`/api/tasks/${t}/suggestions`,{text:s.text,...s.quotes.length?{quotes:s.quotes}:{},commandId:r}),answerSuggestion:(t,s,r)=>B("POST",`/api/tasks/${t}/suggestions/${encodeURIComponent(s)}/${r}`),dropFromRequest:(t,s)=>B("POST",`/api/tasks/${t}/request/drop`,{path:s}),undo:(t,s={})=>B("POST",`/api/tasks/${t}/undo`,{commandId:crypto.randomUUID(),...s}),keep:t=>B("POST",`/api/tasks/${t}/keep`,{commandId:crypto.randomUUID()}).then(s=>s.task),openKept:(t,s)=>B("POST",`/api/tasks/${t}/targets/${s}/on-forge`),continue:t=>B("POST",`/api/tasks/${t}/continue`,{commandId:crypto.randomUUID()}).then(s=>s.task),continueWithPlan:(t,s)=>B("POST",`/api/tasks/${t}/continue`,{commandId:crypto.randomUUID(),approvePlan:!0,...s?{plan:s}:{}}).then(r=>r.task),suggestSkills:t=>B("POST","/api/tasks/skill-suggestions",t),suggestSkillsFor:t=>B("POST","/api/tasks/skill-suggestions",t),startMany:t=>B("POST","/api/tasks/batch",t),readiness:t=>ke(`/api/agents/readiness${t?"?fresh=1":""}`)},jt={signInState:t=>ke(`/api/forge/${t}/sign-in`),signIn:t=>B("POST",`/api/forge/${t}/sign-in`,{}),deviceSignIn:t=>B("POST",`/api/forge/${t}/device`,{}),deviceSignOut:t=>B("DELETE",`/api/forge/${t}/device`),connection:t=>ke(`/api/forge/${t}/connection`),connect:t=>B("POST",`/api/forge/${t}/connect`,{}),disconnect:t=>B("DELETE",`/api/forge/${t}/connection`),repos:t=>ke(`/api/forge/${t}/repos`),connectRepo:(t,s)=>B("POST",`/api/forge/${t}/repos/connect`,s),teamRepo:(t,s)=>B("POST",`/api/forge/${t}/team-repo`,s),gitlabApp:()=>ke("/api/forge/gitlab/app"),saveGitlabApp:t=>B("PUT","/api/forge/gitlab/app",t),removeGitlabApp:()=>B("DELETE","/api/forge/gitlab/app"),hosts:()=>ke("/api/forge/hosts"),check:t=>ke(`/api/forge/${t}/connection/check`)},Lt={list:()=>ke("/api/integrations"),saveSlack:t=>B("PUT","/api/integrations/slack",t),testSlack:()=>B("POST","/api/integrations/slack/test").then(t=>t.delivery),removeSlack:()=>B("DELETE","/api/integrations/slack"),saveTracker:t=>B("PUT","/api/integrations/tracker",t),saveWrites:t=>B("PUT","/api/integrations/writes",{on:t}),addSlack:()=>B("POST","/api/integrations/slack/add").then(t=>t.authorizeUrl),signInJira:()=>B("POST","/api/integrations/jira/sign-in").then(t=>t.authorizeUrl),signInService:t=>t==="jira"?Lt.signInJira():t==="gitlab"?B("POST","/api/integrations/gitlab/sign-in").then(s=>s.authorizeUrl):Lt.signInCatalog(t),signInCatalog:t=>B("POST",`/api/integrations/catalog/${encodeURIComponent(t)}/sign-in`).then(s=>s.authorizeUrl),removeTracker:()=>B("DELETE","/api/integrations/tracker"),mcpProposal:t=>B("POST",`/api/integrations/orchestrator-mcp/${t}/proposal`),proposeMcp:(t,s,r,l)=>B("POST",`/api/integrations/orchestrator-mcp/${t}/propose`,{baseSha:s,message:r,branch:l}).then(i=>i.request)},qn={list:()=>ke("/api/me/mcp-servers"),add:t=>B("POST","/api/me/mcp-servers",t),update:(t,s)=>B("PATCH",`/api/me/mcp-servers/${encodeURIComponent(t)}`,s),remove:t=>B("DELETE",`/api/me/mcp-servers/${encodeURIComponent(t)}`),connect:t=>B("POST",`/api/me/mcp-servers/${encodeURIComponent(t)}/connect`).then(s=>s.authorizeUrl),disconnect:t=>B("POST",`/api/me/mcp-servers/${encodeURIComponent(t)}/disconnect`),tools:t=>ke(`/api/me/mcp-servers/${encodeURIComponent(t)}/tools`).then(s=>s.tools)},Uj={read:t=>ke(`/api/analytics/ai-requests?days=${t}`)},qa={list:()=>ke("/api/team-mcp-servers"),connectForEveryone:t=>B("POST",`/api/team-mcp-servers/${t}/connect`).then(s=>s.authorizeUrl),disconnectForEveryone:t=>B("DELETE",`/api/team-mcp-servers/${t}/connection`),tools:t=>ke(`/api/team-mcp-servers/${t}/tools`).then(s=>s.tools),saveTools:(t,s)=>B("PATCH",`/api/team-mcp-servers/${t}`,{tools:s})},qj={preview:t=>ke(`/api/issues/preview?url=${encodeURIComponent(t)}`)};function fe({what:t,panel:s=!1}){return e.jsxs("div",{className:s?"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 ve({what:t,reason:s,panel:r=!1,...l}){const i=e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"error",children:["Couldn't load ",t,". ",s]}),l.onRetry?e.jsxs("button",{type:"button",className:"secondary small",onClick:l.onRetry,children:["Retry ",t]}):e.jsx("p",{children:l.next})]});return r?e.jsx("div",{className:"panel problem",role:"alert",children:i}):e.jsx("div",{className:"problem",role:"alert",children:i})}function Oo({what:t,reason:s,onRetry:r}){return e.jsxs("div",{className:"problem stale",role:"alert",children:[e.jsxs("p",{className:"error",children:["Refresh failed. Showing the last loaded ",t,". ",s]}),e.jsxs("button",{type:"button",className:"secondary small",onClick:r,children:["Retry ",t]})]})}const Bj=[7,30,90];function zj(t){const s=t.merged+t.kept,r=s+t.closed+t.undone;return r?Math.round(s/r*100):null}function Wj({days:t}){const[s,r]=m.useState(null),[l,i]=m.useState(null),[c,d]=m.useState(0);return m.useEffect(()=>{let u=!0;return r(null),i(null),B("GET",`/api/analytics/people?days=${t}`).then(p=>u&&r(p.people),p=>u&&i(p.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(ve,{what:"tasks by person",reason:l,onRetry:()=>d(u=>u+1)}):s?s.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:s.map(u=>{const p=zj(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:p===null?e.jsx("span",{className:"muted",children:"none decided"}):`${p}%`})]},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(fe,{what:"tasks by person"})]})}var Hj=rf();const Gj=8;function Pe({label:t,labelHidden:s=!1,value:r,onChange:l,options:i,disabled:c=!1,describedBy:d,invalid:u=!1,placeholder:p="Choose…"}){var ae;const f=m.useId(),[g,j]=m.useState(!1),[y,k]=m.useState(0),[N,w]=m.useState(""),[b,$]=m.useState(null),R=m.useRef(null),T=m.useRef(null),C=m.useRef({text:"",at:0}),E=i.length>Gj,O=N.trim().toLowerCase(),F=O?i.filter(z=>`${z.label} ${z.hint??""}`.toLowerCase().includes(O)):i,L=i.find(z=>z.value===r),W=()=>{var _;const z=(_=R.current)==null?void 0:_.getBoundingClientRect();if(!z)return;const P=window.innerHeight-z.bottom;$({left:z.left,top:z.bottom,width:z.width,up:P<240&&z.top>P})},A=()=>{c||(W(),w(""),k(Math.max(0,i.findIndex(z=>z.value===r))),j(!0))},M=(z=!0)=>{var P;j(!1),z&&((P=R.current)==null||P.focus())},Q=z=>{!z||z.disabled||(z.value!==r&&l(z.value),M())},H=(z,P)=>{for(let _=z+P;_>=0&&_<F.length;_+=P)if(!F[_].disabled)return k(_)};m.useLayoutEffect(()=>{if(!g)return;const z=_=>{var V;(V=T.current)!=null&&V.contains(_.target)||W()},P=_=>{var le,be,pe;const V=_.target;(le=R.current)!=null&&le.contains(V)||(pe=(be=T.current)==null?void 0:be.parentElement)!=null&&pe.contains(V)||M(!1)};return window.addEventListener("resize",z),window.addEventListener("scroll",z,!0),document.addEventListener("mousedown",P),()=>{window.removeEventListener("resize",z),window.removeEventListener("scroll",z,!0),document.removeEventListener("mousedown",P)}},[g]),m.useEffect(()=>{const z=T.current,P=z==null?void 0:z.querySelector(`[data-index="${y}"]`);!g||!z||!P||(P.offsetTop<z.scrollTop?z.scrollTop=P.offsetTop:P.offsetTop+P.offsetHeight>z.scrollTop+z.clientHeight&&(z.scrollTop=P.offsetTop+P.offsetHeight-z.clientHeight))},[g,y]);const U=z=>{if(!g){["ArrowDown","ArrowUp","Enter"," "].includes(z.key)&&(z.preventDefault(),A());return}if(z.key==="ArrowDown")z.preventDefault(),H(y,1);else if(z.key==="ArrowUp")z.preventDefault(),H(y,-1);else if(z.key==="Home")z.preventDefault(),H(-1,1);else if(z.key==="End")z.preventDefault(),H(F.length,-1);else if(z.key==="Enter")z.preventDefault(),Q(F[y]);else if(z.key==="Escape")z.preventDefault(),z.stopPropagation(),M();else if(z.key==="Tab")M(!1);else if(!E&&z.key.length===1){const P=Date.now();C.current={text:(P-C.current.at<700?C.current.text:"")+z.key.toLowerCase(),at:P};const _=F.findIndex(V=>!V.disabled&&V.label.toLowerCase().startsWith(C.current.text));_>=0&&k(_)}},ie=`${f}-label`,X=`${f}-list`,J=z=>`${f}-option-${z}`,Z=g&&b?e.jsxs("div",{className:"select-layer",style:{left:b.left,width:Math.max(b.width,200),...b.up?{bottom:window.innerHeight-b.top+(((ae=R.current)==null?void 0:ae.offsetHeight)??0)+4}:{top:b.top+4}},children:[E?e.jsx("input",{className:"select-filter","aria-label":`Filter ${t}`,"aria-controls":X,"aria-activedescendant":F[y]?J(y):void 0,autoFocus:!0,value:N,onChange:z=>{w(z.target.value),k(0)},onKeyDown:U,placeholder:"Type to filter"}):null,e.jsxs("ul",{ref:T,id:X,role:"listbox","aria-labelledby":ie,className:"select-list",children:[F.map((z,P)=>e.jsxs("li",{id:J(P),"data-index":P,role:"option","aria-selected":z.value===r,"aria-disabled":z.disabled||void 0,className:P===y?"active":void 0,onMouseEnter:()=>k(P),onMouseDown:_=>_.preventDefault(),onClick:()=>Q(z),children:[e.jsx("span",{children:z.label}),z.hint?e.jsxs("span",{className:"muted",children:[" ",z.hint]}):null]},z.value)),F.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:ie,className:s?"visually-hidden":"select-label",children:t}),e.jsxs("button",{ref:R,type:"button",role:"combobox",className:"select-button","aria-labelledby":ie,"aria-haspopup":"listbox","aria-expanded":g,"aria-controls":g?X:void 0,"aria-activedescendant":g&&!E&&F[y]?J(y):void 0,"aria-describedby":d,"aria-invalid":u||void 0,disabled:c,onClick:()=>g?M():A(),onKeyDown:U,children:[e.jsx("span",{className:L?void 0:"muted",children:(L==null?void 0:L.label)??p}),e.jsx("span",{className:"select-chevron","aria-hidden":"true"})]}),Z?Hj.createPortal(Z,document.body):null]})}const Pc=720,Ac=180,Kj=22;function Bm(t){return new Date(`${t}T00:00:00Z`).toLocaleDateString("en-US",{month:"short",day:"numeric",timeZone:"UTC"})}function Vj(t,s,r,l){const i=Math.min(4,r/2,l),c=s-l;return`M${t},${s}V${c+i}Q${t},${c} ${t+i},${c}H${t+r-i}Q${t+r},${c} ${t+r},${c+i}V${s}Z`}function Yj({series:t}){const[s,r]=m.useState(null),l=Math.max(1,...t.map(f=>f.count)),i=Pc/t.length,c=Math.max(2,Math.min(28,i-2)),d=Ac-Kj,u=[0,Math.round(t.length/2),t.length-1].filter((f,g,j)=>j.indexOf(f)===g),p=s===null?null:t[s];return e.jsxs("figure",{className:"chart",children:[e.jsxs("svg",{viewBox:`0 0 ${Pc} ${Ac}`,role:"img","aria-label":`Skill use per day, ${t.length} days, highest ${l}`,onMouseLeave:()=>r(null),children:[e.jsx("line",{x1:0,x2:Pc,y1:d,y2:d,className:"chart-axis"}),t.map((f,g)=>{const j=f.count?Math.max(2,f.count/l*(d-8)):0,y=g*i+(i-c)/2;return e.jsxs("g",{onMouseEnter:()=>r(g),children:[e.jsx("rect",{x:g*i,y:0,width:i,height:d,className:"chart-hit"}),j?e.jsx("path",{className:`chart-bar ${s===g?"active":""}`,d:Vj(y,d,c,j)}):null]},f.day)}),u.map(f=>e.jsx("text",{x:f*i+i/2,y:Ac-6,textAnchor:f===0?"start":f===t.length-1?"end":"middle",className:"chart-label",children:Bm(t[f].day)},f))]}),e.jsx("figcaption",{className:"muted",children:p?`${Bm(p.day)}: ${p.count.toLocaleString("en-US")} ${p.count===1?"use":"uses"}`:"Point at a day to read its count."})]})}function Ou({days:t,onDays:s}){return e.jsx("div",{className:"segmented",role:"group","aria-label":"Time range",children:Bj.map(r=>e.jsxs("button",{type:"button",className:"secondary small","aria-pressed":r===t,onClick:()=>s(r),children:[r," days"]},r))})}function Qj({me:t,repos:s}){const[r,l]=m.useState(30),[i,c]=m.useState(""),[d,u]=m.useState(null),[p,f]=m.useState(0),[g,j]=m.useState(null);return m.useEffect(()=>{let y=!0;return u(null),j(null),Ne.usageReport(r,i||void 0).then(k=>y&&u(k),k=>y&&j(k.message)),()=>{y=!1}},[r,i,p]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"toolbar",children:[e.jsx(Ou,{days:r,onDays:l}),e.jsx(Pe,{label:"Repository",value:i,onChange:c,options:[{value:"",label:"Every repository"},...(s??[]).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:Ne.usageExport(r,"csv",i||void 0),download:!0,children:"Export CSV"}),e.jsx("a",{className:"button secondary small",href:Ne.usageExport(r,"json",i||void 0),download:!0,children:"Export JSON"})]}):null]}),g?e.jsx(ve,{what:"skill use",reason:g,onRetry:()=>f(p+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(Yj,{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(Jj,{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(fe,{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(Wj,{days:r})]})}function Jj({count:t,total:s}){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/s*100)}%`}})}),t.toLocaleString("en-US")]})}function Xj({me:t}){const[s,r]=m.useState(30),[l,i]=m.useState(null),[c,d]=m.useState(null),[u,p]=m.useState(0);return m.useEffect(()=>{let f=!0;return i(null),d(null),Ne.leaderboard(s).then(g=>f&&i(g),g=>f&&d(g.message)),()=>{f=!1}},[s,u]),!Ie(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(Ou,{days:s,onDays:r})}),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(ve,{what:"the leaderboard",reason:c,onRetry:()=>p(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(fe,{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 cf=t=>t===null?"—":`${Math.round(t*100)}%`,$o=t=>t?`${t.median} h (p90 ${t.p90} h)`:"—";function Ic({rows:t,first:s}){return e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:s}),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(r=>e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:r.label}),e.jsx("td",{children:r.merged}),e.jsx("td",{children:r.aiAssisted}),e.jsx("td",{children:cf(r.share)}),e.jsx("td",{children:$o(r.hoursToMerge.ai)}),e.jsx("td",{children:$o(r.hoursToMerge.other)})]},r.key))})]})}function Zj(){const[t,s]=m.useState(30),[r,l]=m.useState(null),[i,c]=m.useState(0),[d,u]=m.useState(null);return m.useEffect(()=>{let p=!0;return l(null),u(null),Uj.read(t).then(f=>p&&l(f),f=>p&&u(f.message)),()=>{p=!1}},[t,i]),e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"toolbar",children:e.jsx(Ou,{days:t,onDays:s})}),d?e.jsx(ve,{what:"AI-assisted requests",reason:d,onRetry:()=>c(i+1),panel:!0}):r?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 ",r.days," days"]})]}),e.jsxs("dl",{className:"facts wide",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Merged"}),e.jsx("dd",{children:r.total.merged})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"AI-assisted"}),e.jsxs("dd",{children:[r.total.aiAssisted," (",cf(r.total.share),")"]})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Time to merge, AI-assisted"}),e.jsx("dd",{children:$o(r.total.hoursToMerge.ai)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Time to merge, others"}),e.jsx("dd",{children:$o(r.total.hoursToMerge.other)})]})]}),r.byAgent.some(p=>p.requests)?e.jsx("p",{children:r.byAgent.filter(p=>p.requests).map(p=>`${p.label}: ${p.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."}),r.truncated.length?e.jsxs("p",{className:"muted",children:["Only the latest requests were read in ",r.truncated.join(", "),"; pick a shorter range for all of them."]}):null]}),r.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(Ic,{first:"Team",rows:r.byTeam.map(p=>({key:p.team,label:p.team,...p}))})]}),e.jsxs("section",{className:"panel","aria-labelledby":"ai-repos-h",children:[e.jsx("h2",{id:"ai-repos-h",children:"By repository"}),e.jsx(Ic,{first:"Repository",rows:r.byRepo.map(p=>({key:p.repoId,label:`${p.team} · ${p.repoId}`,...p}))})]}),r.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(Ic,{first:"Person",rows:r.byPerson.map(p=>({key:p.email,label:`${p.name} (${p.email})`,...p}))})]}):null]}):e.jsx("p",{className:"muted panel",children:"No request was merged in this range."})]}):e.jsx(fe,{what:"AI-assisted requests",panel:!0})]})}function ey(t){let s=t===null?"":String(t);return/^[=+\-@\t\r]/.test(s)&&(s=`'${s}`),/[",\r\n]/.test(s)?`"${s.replaceAll('"','""')}"`:s}function ty(t,s){return`${[t,...s].map(r=>r.map(ey).join(",")).join(`\r
|
|
41
|
-
`)}\r
|
|
42
|
-
`}const el=50;function Lo({page:t,total:s,pageSize:r=el,more:l,onPage:i,label:c}){const d=Math.max(t,Math.ceil(s/r));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:()=>i(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:()=>i(t+1),children:"Next"})]})}function Lu(t,s,r=el){const l=Math.max(1,Math.ceil(t.length/r)),i=Math.min(s,l);return{shown:t.slice((i-1)*r,i*r),page:i}}const ny=["activity","work","repositories","tasks","team","controls","integrations","settings","welcome"];function Ds(t){const[s,r,...l]=t.split("/").filter(Boolean).map(decodeURIComponent);return{org:s??null,section:ny.includes(r??"")?r:null,named:r!==void 0,rest:l}}function we(t,...s){return`/${[t,...s].map(encodeURIComponent).join("/")}`}function sy(t,s){var i,c;const r=new URLSearchParams(t),l=((i=r.get("url"))==null?void 0:i.trim())||((c=r.get("text"))==null?void 0:c.trim());return l?`${we(s,"work","new")}?${new URLSearchParams({issue:l})}`:r.get("go")==="tasks"?we(s,"tasks"):r.get("go")==="my-work"?`${we(s,"work")}?mine=1`:we(s,"tasks")}function ry(t,s,r){return s==="activity"&&!r.length||s==="repositories"&&(!r.length||r.length===1&&r[0]==="requests")?we(t,"tasks"):s==="controls"?r.length?we(t,"team","policies",...r):we(t,"team"):null}function ce(...t){return we(Ds(window.location.pathname).org??"",...t)}function ay(t,s){const[r]=t.replace(/^#/,"").split("?"),[l,i]=(r??"").split("/").filter(Boolean);return r===void 0||!r.startsWith("/")||l==="join"?null:l==="repo"&&i?we(s,"repositories",i):l==="tasks"?i?we(s,"tasks",i):we(s,"tasks"):l==="requests"?we(s,"tasks"):l==="people"?we(s,"settings","members"):!l||l==="login"?we(s,"tasks"):we(s,...r.split("/").filter(Boolean))}const au="orchestrator:navigate";function Ue(t,s=!1){s?window.history.replaceState(null,"",t):window.history.pushState(null,"",t),window.dispatchEvent(new Event(au))}function tl(){const t=()=>({pathname:window.location.pathname,search:window.location.search,hash:window.location.hash}),[s,r]=m.useState(t);return m.useEffect(()=>{const l=()=>r(t());return window.addEventListener("popstate",l),window.addEventListener("hashchange",l),window.addEventListener(au,l),()=>{window.removeEventListener("popstate",l),window.removeEventListener("hashchange",l),window.removeEventListener(au,l)}},[]),s}function zm(t){var l,i;if(t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return;const s=(i=(l=t.target)==null?void 0:l.closest)==null?void 0:i.call(l,"a");if(!s||s.target||s.hasAttribute("download"))return;const r=new URL(s.href,window.location.href);r.origin!==window.location.origin||r.pathname.startsWith("/api/")||r.hash&&r.pathname===window.location.pathname&&r.search===window.location.search||(t.preventDefault(),Ue(r.pathname+r.search+r.hash))}const uf=["gitlab","github","gitea"],tr=t=>t.split("/").map(encodeURIComponent).join("/"),Wm=new Set(["127.0.0.1","localhost","[::1]"]),et={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,s,r,l)=>`${t.replace(/\/+$/,"")}/${tr(s)}/-/merge_requests/new?${new URLSearchParams({"merge_request[source_branch]":r,"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"||Wm.has(t),apiUrlFor:t=>Wm.has(t.hostname)?`${t.origin}/api`:"https://api.github.com",requestRef:t=>`refs/pull/${t}/head`,newRequestUrl:(t,s,r,l)=>`${t.replace(/\/+$/,"")}/${tr(s)}/compare/${tr(l)}...${tr(r)}?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,s,r,l)=>`${t.replace(/\/+$/,"")}/${tr(s)}/compare/${tr(l)}...${tr(r)}`,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 df(t,s){const{term:r}=et[t].capabilities;return`${r.charAt(0).toUpperCase()}${r.slice(1)} ${t==="gitlab"?"!":"#"}${s} on ${et[t].label}`}function Vr(t){return typeof t=="string"&&uf.includes(t)}const ly={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"},oy={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"};function Qr(t,s){const r=t==="in-review"&&s&&Vr(s.kind)?` on ${et[s.kind].label}`:"";return{word:`${ly[t]}${r}`,tone:oy[t]}}function ur(t){var r,l,i,c;if(t.state)return t.state;if(t.next==="answer"||t.next==="review"||t.next==="follow-up"||t.attention||t.status==="failed"&&t.question&&!t.question.answer||(r=t.requests)!=null&&r.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 s=t.changes;return s!=null&&s.undone||((l=t.request)==null?void 0:l.status)==="closed"?"undone":((i=t.request)==null?void 0:i.status)==="merged"?t.request.provider==="local"?"kept":"merged":s!=null&&s.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 Oc=30,iy=["waiting","working","usage-limit","waiting-machine","needs-you","kept","in-review","merged","undone","failed","stopped"];function cy(t,s,r,l){return s.map(i=>({at:i.createdAt,title:i.title,repoId:i.repoId,team:i.team,state:ur(i),status:Qr(ur(i),i.forge).word,by:l&&i.createdBy===l?"you":i.createdBy,to:we(t,"tasks",i.id)})).filter(i=>i.at>=r).sort((i,c)=>c.at.localeCompare(i.at))}function uy(t){return ty(["time","title","repository","team","status","by"],t.map(s=>[s.at,s.title,s.repoId,s.team,s.status,s.by]))}function Hm(t,s,r){const l=URL.createObjectURL(new Blob([r],{type:s})),i=document.createElement("a");i.href=l,i.download=t,i.click(),URL.revokeObjectURL(l)}function dy({repos:t,me:s}){const[r,l]=m.useState(null),[i,c]=m.useState(null),[d,u]=m.useState(""),[p,f]=m.useState(""),[g,j]=m.useState(""),[y,k]=m.useState(1),N=()=>{const C=new Date(Date.now()-Oc*864e5).toISOString();c(null),$e.since(C).then(E=>l(cy(Ds(window.location.pathname).org??"",E,C,s)),E=>c(E.message))};m.useEffect(N,[t,s]);const w=g.trim().toLowerCase(),b=(r??[]).filter(C=>(!d||C.state===d)&&(!p||C.repoId===p)&&(!w||`${C.title} ${C.by} ${C.status}`.toLowerCase().includes(w))),$=Lu(b,y),R=C=>E=>{C(E.target.value),k(1)},T=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=>R(u)({target:{value:C}}),options:[{value:"",label:"Every state"},...iy.map(C=>({value:C,label:Qr(C,null).word}))]}),e.jsx(Pe,{label:"Repository",value:p,onChange:C=>R(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:R(j)})]}),e.jsxs("span",{className:"toolbar-end",children:[e.jsx("button",{type:"button",className:"secondary small",disabled:!b.length,onClick:()=>Hm(`logs-${T}.csv`,"text/csv",uy(b)),children:"Export CSV"}),e.jsx("button",{type:"button",className:"secondary small",disabled:!b.length,onClick:()=>Hm(`logs-${T}.json`,"application/json",JSON.stringify(b,null,2)),children:"Export JSON"})]})]}),e.jsxs("section",{className:"panel","aria-labelledby":"logs-h",children:[e.jsxs("h2",{id:"logs-h",children:["Tasks, last ",Oc," days ",e.jsx("span",{className:"count",children:r?b.length:""})]}),i?e.jsx(ve,{what:"the tasks",reason:i,onRetry:N}):r?b.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:$.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:r.length?"Nothing matches these filters.":`Nothing ran or was proposed in the last ${Oc} days.`}):e.jsx(fe,{what:"the tasks"}),e.jsx(Lo,{page:$.page,total:b.length,pageSize:el,onPage:k,label:"Pages of the log"})]})]})}function hf(t){return t.actor.kind==="orchestrator"?"System":t.actor.name||t.actor.email||"someone removed since"}function hy(t){const[s,...r]=t.changes??[];if(!s)return t.detail;const l=i=>i===null?"none":i;return`${s.field}: ${l(s.from)} → ${l(s.to)}${r.length?` +${r.length}`:""}`}function my({me:t,repos:s}){var R,T;const[r,l]=m.useState({}),[i,c]=m.useState(""),[d,u]=m.useState(null),[p,f]=m.useState(!1),[g,j]=m.useState(null),[y,k]=m.useState(!1);if(m.useEffect(()=>{if(!Ie(t))return;let C=!0;return u(null),j(null),Ne.audit(r,null).then(E=>{C&&(E===null?f(!0):u([E]))},E=>C&&j(E.message)),()=>{C=!1}},[r]),!Ie(t))return e.jsx("div",{className:"panel",children:e.jsx("p",{className:"muted",children:"Owners and admins read the audit log."})});if(p)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 E;const C=(E=d==null?void 0:d.at(-1))==null?void 0:E.next;C&&(k(!0),Ne.audit(r,C).then(O=>{O&&u([...d??[],O]),k(!1)},O=>{j(O.message),k(!1)}))},w=(d==null?void 0:d.flatMap(C=>C.events))??[],b=(R=d==null?void 0:d[0])==null?void 0:R.retentionDays,$=C=>{C.preventDefault();const E=new FormData(C.currentTarget),O=F=>String(E.get(F)??"").trim()||void 0;l({repo:i||void 0,kind:O("kind"),since:O("since"),until:O("until")})};return e.jsxs(e.Fragment,{children:[e.jsxs("form",{className:"toolbar",onSubmit:$,"aria-label":"Filter the audit log",children:[e.jsx(Pe,{label:"Repository",value:i,onChange:c,options:[{value:"",label:"Every repository"},...(s??[]).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:r.kind??"",placeholder:"request"})]}),e.jsxs("label",{className:"inline-label",children:["From",e.jsx("input",{name:"since",type:"date",defaultValue:r.since??""})]}),e.jsxs("label",{className:"inline-label",children:["To",e.jsx("input",{name:"until",type:"date",defaultValue:r.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:Ne.auditExport(r,"csv"),download:!0,children:"Export CSV"}),e.jsx("a",{className:"button secondary small",href:Ne.auditExport(r,"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 ",b?e.jsxs("span",{className:"count",children:["kept ",b," days"]}):null]}),g?e.jsx(ve,{what:"changes",reason:g,onRetry:()=>l({...r})}):d?w.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:w.map(C=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("a",{href:ce("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:hy(C)}),e.jsx("td",{children:hf(C)})]},C.id))})]}):e.jsx("p",{className:"muted",children:"No change matches these filters."}):e.jsx(fe,{what:"changes"}),(T=d==null?void 0:d.at(-1))!=null&&T.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 py={user:"Person",service:"Service account",orchestrator:"The orchestrator itself"};function fy({me:t,id:s}){var y;const[r,l]=m.useState(null),[i,c]=m.useState(null),[d,u]=m.useState(null);m.useEffect(()=>{Ie(t)&&(l(null),c(null),Ne.event(s).then(l,k=>c(k instanceof ss?"This organization's audit log has no such change; it is from another organization, or older than the log keeps.":k.message)))},[s]);const p=e.jsx("p",{children:e.jsx("a",{href:ce("activity","audit"),children:"All changes"})});if(!Ie(t))return e.jsx("div",{className:"panel",children:e.jsx("p",{className:"muted",children:"Owners and admins read the audit log."})});if(i)return e.jsxs("div",{className:"panel",role:"alert",children:[e.jsx("p",{className:"error",children:i}),p]});if(!r)return e.jsx(fe,{what:"the change",panel:!0});const{event:f,link:g}=r,j=()=>{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:[p,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:[hf(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:py[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(k=>e.jsxs("tr",{children:[e.jsx("td",{children:k.field}),e.jsx("td",{className:"mono",children:k.from??"none"}),e.jsx("td",{className:"mono",children:k.to??"none"})]},k.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:j,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 mf=[{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"}],ko=[{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"}],gy=["account","members","api-keys","access","machines"],pf=["account","code","task-limits","agents","task-secrets","privacy","updates"],xy=["usage","leaderboard","audit","ai"];function Fu(t,s){return t.mode!=="local"||!xy.includes(s)}function ff(t){return mf.filter(s=>Fu(t,s.id)&&(!("for"in s)||Ie(t)||s.for==="team owners"&&t.ownedTeams.length>0))}function Mu(t,s){return t.mode==="local"?pf.includes(s):s!=="updates"&&(s!=="machines"||t.runners===!0)}function gf(t){return t.mode==="local"?ko.filter(r=>pf.includes(r.id)):(Ie(t)?[...ko]:ko.filter(r=>gy.includes(r.id))).filter(r=>Mu(t,r.id))}function _r({org:t,path:s}){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:s}),". The link is mistyped, or it is from a page that has moved."]}),e.jsx("p",{children:e.jsxs("a",{className:"button secondary",href:we(t,"tasks"),children:["Back to ",t]})})]})]})}const lu={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`}},Gm=["approval","answer","limited","follow-up","review","failed"];function xf(t){var r,l,i,c;if(t.status!=="needs-review")return null;const s=t.result==="changes";return(r=t.changes)!=null&&r.undone||s&&t.phase==="failed"?"undone":(l=t.changes)!=null&&l.kept||s&&t.phase==="merged"?"kept":s?null:((i=t.request)==null?void 0:i.status)==="closed"||(c=t.requests)!=null&&c.length&&t.requests.every(d=>d.status==="closed")||t.phase==="failed"?"closed":null}function Ha(t){var s;return t.attention?t.attention:t.status==="running"&&ur(t)==="needs-you"?"approval":t.status==="failed"&&t.question&&!t.question.answer?"answer":(s=t.suggestions)!=null&&s.some(r=>r.canAnswer)?"follow-up":xf(t)?null:t.phase==="review"||!t.phase&&t.status==="needs-review"?"review":t.phase==="failed"||t.status==="failed"?"failed":null}function jy(t,s){return Gm.indexOf(t)-Gm.indexOf(s)}function yy(t,s,r,l){if(!t)return[];const i=[];for(const c of s){const d=Ha(c);!d||t.get(c.id)===d||r.has(`${c.id}:${d}`)||c.id===l||i.push({id:c.id,attention:d})}return i}function vy(t,s,r,l){return t.map(d=>{const u=d.createdBy===s?Ha(d):null;return{task:d,call:u,unread:u!==null&&!r.has(`${d.id}:${u}`)}}).filter(d=>l==="all").map((d,u)=>({row:d,at:u})).sort((d,u)=>(d.row.call&&u.row.call?jy(d.row.call,u.row.call):d.row.call?-1:u.row.call?1:0)||d.at-u.at).map(({row:d})=>d)}const ou=new Map,iu="orchestrator:pref";function To(t){if(ou.has(t))return ou.get(t);try{return window.localStorage.getItem(t)}catch{return null}}function cu(t,s){ou.set(t,s);try{s===null?window.localStorage.removeItem(t):window.localStorage.setItem(t,s)}catch{}window.dispatchEvent(new Event(iu))}function es(t){const[s,r]=m.useState(()=>To(t));return m.useEffect(()=>{const l=()=>r(To(t));return window.addEventListener(iu,l),()=>window.removeEventListener(iu,l)},[t]),[s,l=>cu(t,l)]}const jf="orchestrator.theme";function yf(t){t==="light"||t==="dark"?document.documentElement.dataset.theme=t:delete document.documentElement.dataset.theme}const _u="orchestrator.attention.notify",vf="orchestrator.attention.seen",ky=500,wy=15e3,by=6e4,Ny=1440*60*1e3;function Du(){try{return new Set(JSON.parse(localStorage.getItem(vf)??"[]"))}catch{return new Set}}function Sy(t){try{localStorage.setItem(vf,JSON.stringify([...t].slice(-ky)))}catch{}}function Cy(){var t;return((t=/\/tasks\/([^/]+)$/.exec(window.location.pathname))==null?void 0:t[1])??null}let Lc=null;function $y(t){const s=document.createElement("canvas");s.width=s.height=64;const r=s.getContext("2d");if(!r)return;r.fillStyle="#2856d8",r.beginPath(),r.roundRect(0,0,64,64,14),r.fill(),r.fillStyle="#ffffff",r.fillRect(18,18,28,7),r.fillRect(28.5,25,7,21),r.textAlign="center",r.textBaseline="middle",t>0&&(r.fillStyle="#b42318",r.beginPath(),r.arc(46,18,16,0,Math.PI*2),r.fill(),r.fillStyle="#ffffff",r.font="bold 22px sans-serif",r.fillText(t>9?"9+":String(t),46,19));const l=s.toDataURL("image/png");t===0&&(Lc=l);let i=document.querySelector('link[rel="icon"]');i||(i=document.createElement("link"),i.rel="icon",document.head.append(i)),i.href=t===0&&Lc?Lc:l}function Ty({me:t}){const[s]=es(_u),r=m.useRef(null),l=m.useRef(document.title.replace(/^\(\d+\+?\) /,""));return m.useEffect(()=>{let i,c=!1;const d=async()=>{var u,p,f;try{const g=(await $e.since(new Date(Date.now()-Ny).toISOString())).filter(b=>b.createdBy===t.email),j=Du(),y=document.hidden?null:Cy();for(const b of g){const $=Ha(b);$&&b.id===y&&j.add(`${b.id}:${$}`)}const k=yy(r.current,g,j,y);if(s==="yes"&&"Notification"in window&&Notification.permission==="granted")for(const b of k){const $=g.find(T=>T.id===b.id),R=new Notification(lu[b.attention].title($.title),{tag:`${b.id}:${b.attention}`,body:"TeamHandbook Orchestrator"});R.onclick=()=>{window.focus(),Ue(ce("tasks",b.id))}}r.current=new Map(g.map(b=>[b.id,Ha(b)])),Sy(j);const N=g.filter(b=>{const $=Ha(b);return $&&!j.has(`${b.id}:${$}`)}).length;$y(N);const w=navigator;(f=N?(u=w.setAppBadge)==null?void 0:u.call(w,N):(p=w.clearAppBadge)==null?void 0:p.call(w))==null||f.catch(()=>{}),document.title=N?`(${N>9?"9+":N}) ${l.current}`:l.current}catch{}c||(i=setTimeout(d,document.hidden?by:wy))};return d(),()=>{c=!0,clearTimeout(i)}},[t.email,s]),null}const Ey="orchestrator.attention.asked";function Ry(){const[t,s]=es(_u),[r,l]=es(Ey),[i,c]=m.useState(()=>"Notification"in window?Notification.permission:"denied");if(i==="denied"||r||t==="yes"&&i==="granted")return null;const d=()=>{Notification.requestPermission().then(u=>{c(u),u==="granted"?s("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 Py=["Actions","Pages","Repositories","Folders","Tasks"],kf=5;function Ay(t,s){const r=s.trim().toLowerCase();if(!r)return[];const l=i=>{if(i.group==="Folders"||i.asked)return 0;const c=i.label.toLowerCase();return c.startsWith(r)?0:c.includes(r)?1:i.detail.toLowerCase().includes(r)?2:null};return Py.flatMap(i=>t.filter(c=>c.group===i).flatMap(c=>{const d=l(c);return d===null?[]:[{j:c,s:d}]}).sort((c,d)=>c.s-d.s).slice(0,kf).map(c=>c.j))}function Iy(t){const s=t.trim();if(!s)return null;if(!/^(~|\/)/.test(s))return{q:s};if(s==="~"||s.endsWith("/"))return{under:s==="~"?"~":s.replace(/\/+$/,"")||"/"};const r=s.lastIndexOf("/");return{under:s.slice(0,r)||(s.startsWith("~")?"~":"/"),prefix:s.slice(r+1)}}function Km(t){if(!/^(~|\/).*\/$/.test(t)||t==="/"||t==="~/")return null;const s=t.replace(/[^/]+\/$/,"");return s==="~"?"~/":s}const Oy=t=>[...new Set(t.map(s=>s.group))].map(s=>[s,t.filter(r=>r.group===s)]),Vm=150;function Ly({open:t,onClose:s,jumps:r,more:l,folders:i,finds:c}){const d=m.useRef(null),[u,p]=m.useState(""),[f,g]=m.useState([]),[j,y]=m.useState(0),[k,N]=m.useState([]),[w,b]=m.useState([]),[$,R]=m.useState(null),T=m.useId();m.useEffect(()=>{if(R(null),!t||!i||!u.trim())return N([]);let M=!0;const Q=setTimeout(()=>void i(u).then(H=>M&&N(H),()=>M&&N([])),Vm);return()=>{M=!1,clearTimeout(Q)}},[t,i,u]),m.useEffect(()=>{if(!t||!c||!u.trim())return b([]);let M=!0;const Q=setTimeout(()=>void c(u).then(H=>M&&b(H),()=>M&&b([])),Vm);return()=>{M=!1,clearTimeout(Q)}},[t,c,u]),m.useEffect(()=>{const M=d.current;M&&(t&&!M.open?(p(""),y(0),M.showModal(),l==null||l().then(g,()=>g([]))):!t&&M.open&&M.close())},[t,l]);const C=Ay([...r,...f,...k,...w.filter(M=>!f.some(Q=>Q.to===M.to))],u),E=C[Math.min(j,C.length-1)],O=M=>{if(M.open){M.open().then(Q=>{s(),Ue(Q)},Q=>R(Q.message));return}s(),Ue(M.to)},F=M=>M.currentTarget.selectionStart===M.currentTarget.value.length&&M.currentTarget.selectionEnd===M.currentTarget.value.length,L=M=>{p(M),y(0)},W=M=>{M.key==="ArrowDown"||M.key==="ArrowUp"?(M.preventDefault(),y(Q=>Math.min(Math.max(Q+(M.key==="ArrowDown"?1:-1),0),Math.max(C.length-1,0)))):M.key==="ArrowRight"&&(E!=null&&E.inside)&&F(M)?(M.preventDefault(),L(E.inside)):M.key==="Backspace"&&F(M)&&i&&Km(u)?(M.preventDefault(),L(Km(u))):M.key==="Enter"&&E?(M.preventDefault(),O(E)):M.key==="Escape"&&(M.preventDefault(),s())},A=M=>`${T}-${M}`;return e.jsx("dialog",{ref:d,className:"palette","aria-label":"Search",onClose:s,onClick:M=>{M.target===d.current&&s()},children:t?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"search","aria-label":i?"Search pages, projects, folders and tasks":"Search pages, projects and tasks",placeholder:i?"Search pages, projects, folders and tasks":"Search pages, projects and tasks",autoComplete:"off",value:u,"aria-controls":T,"aria-activedescendant":E?A(C.indexOf(E)):void 0,onChange:M=>L(M.target.value),onKeyDown:W}),e.jsx("p",{className:"visually-hidden",role:"status",children:u.trim()?C.length?`${C.length} found`:"Nothing found":""}),C.length?e.jsx("div",{id:T,role:"listbox","aria-label":"Found",className:"palette-list",children:Oy(C).map(([M,Q])=>e.jsxs("div",{role:"group","aria-labelledby":`${T}-${M}`,children:[e.jsx("p",{id:`${T}-${M}`,className:"palette-group",children:M}),Q.map(H=>e.jsxs("div",{id:A(C.indexOf(H)),role:"option","aria-selected":H===E,className:"palette-option",onMouseDown:U=>U.preventDefault(),onClick:()=>O(H),children:[e.jsx("span",{className:H.group==="Folders"?"palette-label mono":"palette-label",children:H.label}),H.detail?e.jsx("span",{className:"palette-detail",children:H.detail}):null]},H.to))]},M))}):e.jsx("p",{className:"palette-note",children:u.trim()?`Nothing matches “${u.trim()}”.`:i?"Type a page, a project, a task, or a folder's path from ~/.":"Type a page, a project or a task."}),$?e.jsx("p",{className:"error",role:"alert",children:$}):null]}):null})}const Je={folders:(t={},s)=>{const r=new URLSearchParams(Object.entries(t).filter(i=>!!i[1])).toString(),l=s?`/api/machines/${encodeURIComponent(s)}/folders`:"/api/local/folders";return B("GET",r?`${l}?${r}`:l)},open:(t,s)=>B("POST","/api/projects",{path:t,...s?{machineId:s}:{}}),workFolders:()=>B("GET","/api/work-folders"),list:()=>B("GET","/api/projects"),gitInit:t=>B("POST",`/api/projects/${encodeURIComponent(t)}/git/init`,{commandId:crypto.randomUUID()}),commitPlan:t=>B("GET",`/api/projects/${encodeURIComponent(t)}/git/commit`),commit:(t,s,r)=>B("POST",`/api/projects/${encodeURIComponent(t)}/git/commit`,{commandId:crypto.randomUUID(),message:s,exclude:r}),clone:(t,s)=>B("POST","/api/projects/clone",{commandId:crypto.randomUUID(),url:t,...s?{into:s}:{}}),rename:(t,s)=>B("PATCH",`/api/projects/${encodeURIComponent(t)}`,{name:s}),readSkillsFrom:(t,s)=>B("PATCH",`/api/projects/${encodeURIComponent(t)}`,{skillsFrom:s}),repositories:t=>B("GET",`/api/projects/${encodeURIComponent(t)}/repositories`),trust:(t,s)=>B("PUT",`/api/projects/${encodeURIComponent(t)}/trust`,{trusted:s})};function Ls(t,s){const r=t.trim();return s&&(r==="~"||r.startsWith("~/"))?`${s}${r.slice(1)}`:r}function ts(t,s){return s?t===s?"~":t.startsWith(`${s}/`)?`~${t.slice(s.length)}`:t:t}function wf(t,s){var r;return((r=t.machine)==null?void 0:r.path)??ts(t.url.replace(/^file:\/\//,""),s)}function Fc(t){return/^(~|\/)/.test(t.trim())}function Fy(t,s){if(t!==s&&!t.startsWith(`${s}/`))return[{label:t,path:t}];const r=t.slice(s.length).split("/").filter(Boolean);return[{label:"~",path:s},...r.map((l,i)=>({label:l,path:`${s}/${r.slice(0,i+1).join("/")}`}))]}function My(t){var r;const s=((r=t.trim().replace(/\/+$/,"").split(/[/:]/).pop())==null?void 0:r.replace(/\.git$/,""))??"";return/^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/.test(s)?s:null}function bf(t){return t.label.slice(0,1).toLowerCase()}function _y(t,s,r,l=!1){if(l)return t.toLowerCase()==="k"?{kind:"search",anywhere:!0}:null;if(s){const i=r.find(c=>bf(c)===t.toLowerCase());return i?{kind:"go",section:i.section}:null}return t==="?"?{kind:"help"}:t==="/"?{kind:"search",anywhere:!1}:t==="g"?{kind:"then"}:null}function Dy(t){return t instanceof HTMLElement?t.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(t.tagName)||t.closest("[role='listbox'], [role='menu']")!==null:!1}const Uy=1500,qy=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)?"⌘":"Ctrl";function By({org:t,tabs:s,onSearch:r}){const l=m.useRef(null),[i,c]=m.useState(!1);return m.useEffect(()=>{let d=!1,u;const p=f=>{var y;const g=f.metaKey||f.ctrlKey;if(f.defaultPrevented||f.altKey||!g&&Dy(f.target)||(y=l.current)!=null&&y.open)return;const j=_y(f.key,d,s,g);d=!1,clearTimeout(u),j&&(f.preventDefault(),j.kind==="then"?(d=!0,u=setTimeout(()=>{d=!1},Uy)):j.kind==="help"?c(!0):j.kind==="search"?r(j.anywhere):Ue(we(t,j.section)))};return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p),clearTimeout(u)}},[t,s,r]),m.useEffect(()=>{var d,u;i&&!((d=l.current)!=null&&d.open)&&((u=l.current)==null||u.showModal())},[i]),e.jsx("dialog",{ref:l,className:"dialog","aria-labelledby":"shortcuts-h",onClose:()=>c(!1),children:i?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:qy})," ",e.jsx("kbd",{children:"K"})]}),e.jsx("dd",{children:"Search pages, projects and tasks from anywhere, a field included"})]}),s.map(d=>e.jsxs("div",{children:[e.jsxs("dt",{children:[e.jsx("kbd",{children:"g"})," ",e.jsx("kbd",{children:bf(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 fo=[{section:"work",label:"Work"},{section:"tasks",label:"Tasks"},{section:"team",label:"Team"},{section:"integrations",label:"Integrations"}];function nl({label:t,summary:s,className:r,children:l}){const[i,c]=m.useState(!1),d=m.useId(),u=m.useRef(null),p=m.useRef(null);m.useEffect(()=>{if(!i)return;const j=y=>{var k;(k=u.current)!=null&&k.contains(y.target)||c(!1)};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[i]);const f=()=>{var j;c(!1),(j=p.current)==null||j.focus()},g=j=>{j.key==="Escape"&&i&&(j.stopPropagation(),f())};return e.jsxs("div",{className:`disclosure ${r??""}`,ref:u,onKeyDown:g,children:[e.jsx("button",{ref:p,type:"button",className:"ghost","aria-expanded":i,"aria-controls":d,"aria-label":t,onClick:()=>c(!i),children:s}),e.jsx("div",{id:d,className:"popover",hidden:!i,children:i?l(()=>c(!1)):null})]})}function zy({onJoined:t}){const[s,r]=m.useState(null),[l,i]=m.useState(null),c=()=>rt.orgs().then(u=>r(u.invitations),u=>i(u.message));m.useEffect(()=>{c()},[]);const d=(u,p)=>{i(null),rt.me().then(f=>p?rt.acceptInvitation(u,f.csrf).then(g=>{t(),Ue(g.next)}):rt.declineInvitation(u,f.csrf).then(c)).catch(f=>i(f.message))};return l?e.jsx("p",{className:"error small",role:"alert",children:l}):s!=null&&s.length?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"popover-title",children:"Invitations"}),e.jsx("ul",{className:"plain invitations",children:s.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 Wy({me:t,orgs:s,org:r,section:l}){const[i,c]=m.useState(""),d=m.useId(),u=t.mode==="cloud";if(t.mode==="local"||s.length<2&&!u)return null;const p=j=>j.orgName??j.tenant,f=s.find(j=>j.tenant===r),g=f?p(f):r;return e.jsx(nl,{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:j=>e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"popover-title",children:"Organizations"}),e.jsx("ul",{className:"plain",children:s.map(y=>e.jsx("li",{children:e.jsxs("a",{href:we(y.tenant,l??"tasks"),"aria-current":y.tenant===r?"true":void 0,onClick:j,children:[p(y)," ",e.jsxs("span",{className:"muted",children:["· ",y.role]})]})},y.tenant))}),u?e.jsxs(e.Fragment,{children:[e.jsx(zy,{onJoined:j}),e.jsx("p",{children:e.jsx("a",{href:"/signup/organization",onClick:j,children:"New organization"})})]}):e.jsxs("form",{className:"form",onSubmit:y=>{y.preventDefault(),i.trim()&&(j(),Ue(we(i.trim(),"tasks")))},children:[e.jsx("label",{htmlFor:d,children:"Sign in to another organization"}),e.jsx("input",{id:d,value:i,onChange:y=>c(y.target.value),placeholder:"Its name",autoComplete:"off"})]})]})})}function Hy(t,s,r){const l=(c,d,u)=>({label:c,detail:d,to:u,group:"Pages"}),i=(c,d,u)=>({label:c,detail:d,to:u,group:"Actions"});return[i("New task","Say what needs doing",we(t,"tasks","new")),i("Start agents","On the issues of the Work board",we(t,"work")),l("Work","Sprint board and backlog",we(t,"work")),l("Tasks",r.mode==="local"?"Agent tasks and your folders":"Agent tasks and the repositories they run in",we(t,"tasks")),l("Team",r.mode==="local"?"Lessons and what your Claude Code loads":"People, policies and what the team shares",we(t,"team")),l("Integrations","Forges",we(t,"integrations")),...ff(r).map(c=>l(c.label,"Account menu",we(t,"activity",c.id))),l("Settings",Ie(r)&&r.mode!=="local"?"Organization":"Your account",we(t,"settings")),...gf(r).map(c=>l(c.label,"Settings",we(t,"settings",c.id))),...s.map(c=>({label:c.name,detail:r.mode==="local"?"":c.team,to:`${we(t,"tasks")}?${new URLSearchParams({repo:c.id})}`,group:r.mode==="local"?"Folders":"Repositories"}))]}function Gy(t){let s=null;return async r=>{var p;const l=Iy(r);if(!l)return[];s??(s=(await Je.folders()).under);const i=l.under===void 0?void 0:Ls(l.under,s),c=await Je.folders({...i?{under:i}:{},...l.q?{q:l.q}:{}}),d=((p=l.prefix)==null?void 0:p.toLowerCase())??"";return(l.q?c.matches??[]:c.folders.filter(f=>f.name.toLowerCase().startsWith(d))).slice(0,kf).map(f=>{const g=ts(f.path,s);return{label:g,detail:f.git==="none"?"":"Git",to:`folder:${f.path}`,group:"Folders",inside:`${g}/`,open:()=>Je.open(f.path).then(({project:j})=>we(t,"repositories",j.id))}})}}function Ky(t,s){const r=new Map(s.map(l=>[l.id,l.name]));return async l=>{const i=await Dj.tasks(l.trim()),c=(d,u)=>({label:d.title,detail:[r.get(d.repoId),u].filter(Boolean).join(", "),to:we(t,"tasks",d.id),group:"Tasks",asked:!0});return[...i.tasks.map(d=>c(d,"")),...i.inLog.map(d=>c(d,"in its log"))]}}function Vy(t,s){const r=new Map(s.map(l=>[l.id,l.name]));return $e.page(null).then(l=>l.tasks.map(i=>({label:i.title,detail:[i.issueKey,r.get(i.repoId)].filter(Boolean).join(", "),to:we(t,"tasks",i.id),group:"Tasks"})))}function Yy(){return document.querySelector("main [data-page-search]")}function Qy(t){return t.mode==="cloud"?rt.me().then(s=>rt.signOut(s.csrf)):Ya.logout()}function Jy(){const[t,s]=es(_u),[r,l]=m.useState(()=>"Notification"in window&&Notification.permission==="denied");if(!("Notification"in window))return null;const i=t==="yes"&&Notification.permission==="granted",c=()=>{if(i)return s(null);Notification.requestPermission().then(d=>{d==="granted"&&s("yes"),l(d==="denied")})};return e.jsxs("div",{className:"notify-switch",children:[e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:c}),"Notify me when my tasks need me"]}),r?e.jsx("p",{className:"muted small",children:"This browser blocks notifications from this page; allow them in its site settings."}):null]})}function Xy({me:t,org:s,onSignedOut:r}){const[l,i]=es(jf),[c,d]=m.useState(!1);m.useEffect(()=>{if(!Ie(t))return;const f=()=>Ne.onboarding().then(g=>d(g.dismissed),()=>d(!1));return f(),window.addEventListener(nu,f),()=>window.removeEventListener(nu,f)},[]);const u=f=>{i(f==="system"?null:f),yf(f)},p=`${t.role==="owner"?"Owner":t.role==="admin"?"Admin":"Member"}${t.ownedTeams.length?`, owns ${t.ownedTeams.join(", ")}`:""}`;return e.jsx(nl,{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:p})]}),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(Jy,{}),e.jsxs("nav",{className:"account-links","aria-label":"Account",children:[e.jsx("a",{href:we(s,"settings"),onClick:f,children:"Settings"}),e.jsx("a",{href:we(s,"activity","news"),onClick:f,children:"What's new"}),Fu(t,"usage")?e.jsx("a",{href:we(s,"activity","usage"),onClick:f,children:"Skill use over time"}):null]}),c?e.jsx("button",{type:"button",className:"link",onClick:()=>{Ne.changeOnboarding({dismissed:!1}),f()},children:"Show the getting started guide"}):null,e.jsx("button",{type:"button",className:"secondary",onClick:()=>Qy(t).finally(r),children:"Sign out"})]})})}function Zy({me:t,orgs:s,org:r,section:l,repos:i,onSignedOut:c,children:d}){var w;const u=((w=fo.find(b=>b.section===l))==null?void 0:w.label)??"Sections",[p,f]=m.useState(!1),g=m.useMemo(()=>Hy(r,i,t),[r,i,t]),j=m.useCallback(()=>Vy(r,i),[r,i]),y=m.useMemo(()=>t.mode==="local"?Gy(r):void 0,[r,t.mode]),k=m.useMemo(()=>Ky(r,i??[]),[r,i]),N=m.useCallback(b=>{const $=b?null:Yy();$?$.focus():f(!0)},[]);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:we(r,"tasks"),children:["TeamHandbook ",e.jsx("span",{children:"Orchestrator"})]}),e.jsx(Wy,{me:t,orgs:s,org:r,section:l}),e.jsx(nl,{label:`Sections: ${u}`,summary:e.jsxs(e.Fragment,{children:[u," ",e.jsx("span",{className:"select-chevron","aria-hidden":"true"})]}),className:"section-menu",children:b=>e.jsx("ul",{className:"plain",children:fo.map($=>e.jsx("li",{children:e.jsx("a",{href:we(r,$.section),"aria-current":$.section===l?"page":void 0,onClick:b,children:$.label})},$.section))})}),e.jsx("nav",{className:"tabs","aria-label":"Orchestrator",children:fo.map(b=>e.jsx("a",{href:we(r,b.section),"aria-current":b.section===l?"page":void 0,children:b.label},b.section))}),e.jsxs("div",{className:"topbar-end",children:[e.jsxs("button",{type:"button",className:"ghost search-button",onClick:()=>N(!1),title:"Search pages, projects and tasks (/ or Cmd/Ctrl+K)",children:["Search ",e.jsx("kbd",{children:"/"})]}),e.jsx(Xy,{me:t,org:r,onSignedOut:c})]})]}),e.jsx(Ty,{me:t}),e.jsx(By,{org:r,tabs:fo,onSearch:N}),e.jsx(Ly,{open:p,onClose:()=>f(!1),jumps:g,more:j,finds:k,...y?{folders:y}:{}}),e.jsx("main",{id:"content",tabIndex:-1,children:d})]})}function Fo({label:t,links:s,current:r}){var d;const l=s.length>5,i=e.jsx("nav",{className:l?"subnav subnav-gathers":"subnav","aria-label":t,children:s.map(u=>e.jsx("a",{href:u.to,"aria-current":u.to===r?"page":void 0,children:u.label},u.to))});if(!l)return i;const c=((d=s.find(u=>u.to===r))==null?void 0:d.label)??t;return e.jsxs(e.Fragment,{children:[e.jsx(nl,{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:s.map(p=>e.jsx("li",{children:e.jsx("a",{href:p.to,"aria-current":p.to===r?"page":void 0,onClick:u,children:p.label})},p.to))})}),i]})}function Cn({title:t,summary:s,actions:r,crumb:l,sticky:i=!1,below:c,children:d}){return e.jsxs("header",{className:`page-head${i?" sticky":""}`,children:[l?e.jsx("p",{className:"page-crumb",children:l}):null,e.jsxs("div",{className:"page-head-line",children:[e.jsx("h1",{dir:"auto",children:t}),d]}),s?e.jsx("p",{className:"page-summary",children:s}):null,r?e.jsx("div",{className:"actions",children:r}):null,c]})}const ev=[{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 tv(){return e.jsx("ul",{className:"plain news-list",children:ev.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?ce(t.link.section,t.link.page):ce(t.link.section),children:t.link.label})}):null]},t.id))})}function nv({me:t,repos:s,page:r,entry:l}){const i=mf.find(u=>u.id===r&&Fu(t,u.id));if(!i)return e.jsx(_r,{org:Ds(window.location.pathname).org??"",path:window.location.pathname});const c=u=>ce("activity",u),d=e.jsx(Fo,{label:"Activity",current:c(i.id),links:ff(t).map(u=>({to:c(u.id),label:u.label}))});return e.jsxs("div",{className:"page",children:[e.jsx(Cn,{title:i.label}),d,i.id==="news"?e.jsx(tv,{}):null,i.id==="usage"?e.jsx(Qj,{me:t,repos:s}):null,i.id==="leaderboard"?e.jsx(Xj,{me:t}):null,i.id==="ai"?e.jsx(Zj,{}):null,i.id==="logs"?e.jsx(dy,{repos:s,me:t.email}):null,i.id==="audit"?l?e.jsx(fy,{me:t,id:l}):e.jsx(my,{me:t,repos:s}):null]})}function qe({trigger:t,triggerLabel:s,consequence:r,confirm:l,keep:i,onConfirm:c,reason:d,small:u=!1,primary:p=!1,danger:f=!1}){const[g,j]=m.useState(!1),[y,k]=m.useState(!1),[N,w]=m.useState(null),[b,$]=m.useState(""),R=m.useRef(null),T=m.useRef(null),C=m.useRef(!1);m.useEffect(()=>{var L,W;g?(L=T.current)==null||L.focus():C.current&&((W=R.current)==null||W.focus())},[g]);const E=u?" small":"";if(!g)return e.jsx("button",{ref:R,type:"button",className:`${f?"danger":p?"":"secondary"}${E}`.trim()||void 0,"aria-label":s,onClick:()=>j(!0),children:t});const O=()=>{k(!0),w(null),c(b.trim()).then(()=>{k(!1),$(""),C.current=!1,j(!1)},L=>{w(L.message),k(!1)})},F=()=>{C.current=!0,w(null),j(!1)};return e.jsxs("div",{className:"confirm",role:"group","aria-label":l,children:[e.jsx("p",{children:r}),d?e.jsxs("label",{children:[d.label,e.jsx("input",{type:"text",value:b,onChange:L=>$(L.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${E}`,onClick:O,disabled:y,children:y?`${l}…`:l}),e.jsx("button",{ref:T,type:"button",className:`secondary${E}`,onClick:F,disabled:y,children:i})]}),N?e.jsx("p",{className:"error",role:"alert",children:N}):null]})}function sv(t){const s=window.getSelection();if(!t||!s)return;const r=document.createRange();r.selectNodeContents(t),s.removeAllRanges(),s.addRange(r)}function Uu({text:t,target:s,label:r="Copy",primary:l=!1,small:i=!0}){const[c,d]=m.useState(null),u=()=>{sv(s.current),d("Copy failed; it is selected, so copy it with the keyboard.")},p=()=>{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"}${i?" small":""}`.trim()||void 0,"aria-label":r==="Copy"?`Copy ${t}`:r,onClick:p,children:r}),c?e.jsxs("span",{className:"muted",role:"status",children:[" ",c]}):null]})}function yt({text:t,label:s,primary:r=!1,well:l=!1}){const i=m.useRef(null);return e.jsxs("span",{className:l?"copy-text well":"copy-text",children:[e.jsx("code",{ref:i,className:"link",children:t})," ",e.jsx(Uu,{text:t,target:i,label:s,primary:r})]})}function Ee({label:t,children:s}){return e.jsxs("details",{className:"hint",children:[e.jsx("summary",{"aria-label":`About ${t}`,children:"i"}),e.jsx("p",{children:s})]})}const uu={google:"Google",github:"GitHub",microsoft:"Microsoft"},Ym={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 is not valid any more. Ask 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."},rv="That sign-in did not finish. Try again.";function du(t,s=null){const r=(s??"").split(",").filter(l=>Object.hasOwn(uu,l)).map(l=>uu[l]);return t==="address-taken"&&r.length?`This email address already signs in with ${r.join(" or ")}. Sign in with ${r.length>1?"one of those":r[0]}, then add this provider under Your account.`:Object.hasOwn(Ym,t)?Ym[t]:rv}function Eo({privacyUrl:t,termsUrl:s}){return!t&&!s?null:e.jsxs("p",{className:"muted legal",children:[s?e.jsx("a",{href:s,children:"Terms of use"}):null,s&&t?" · ":null,t?e.jsx("a",{href:t,children:"Privacy policy"}):null]})}function av(t){return t.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,39)}function Qa({config:t}){return t.helpUrl?e.jsx("p",{className:"muted",children:e.jsx("a",{href:t.helpUrl,children:"Stuck? Get help"})}):null}function lv({config:t}){return t.providers.length?e.jsx("div",{className:"stack",children:t.providers.map(s=>e.jsxs("a",{className:"button",href:`/api/auth/${s}/start`,children:["Sign in with ",uu[s]]},s))}):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 ov({config:t}){const[s,r]=m.useState(void 0),l=new URLSearchParams(window.location.search).get("problem");if(m.useEffect(()=>{rt.me().then(r,()=>r(null))},[]),s===void 0)return e.jsx(fe,{what:"your sign-in"});if(s){const i=s.memberships.filter(c=>c.reachable);return e.jsxs(e.Fragment,{children:[e.jsxs("h1",{id:"signup-h",children:["Signed in as ",s.identity.email]}),l?e.jsx("p",{className:"error",role:"alert",children:du(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:()=>rt.signOut(s.csrf).then(()=>r(null),()=>r(null)),children:"Use another account"})]}),i.length?e.jsx("ul",{className:"plain",children:i.map(c=>e.jsx("li",{children:e.jsxs("a",{href:we(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 ",s.identity.email,"."]}),t.signupOpen?e.jsx("a",{className:"button",href:"/signup/organization",children:"Create an organization"}):null,e.jsx(Qa,{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:du(l,new URLSearchParams(window.location.search).get("with"))}):null,e.jsx(lv,{config:t}),e.jsx(Qa,{config:t}),e.jsxs("p",{className:"muted",children:["An organization you create is yours: nobody joins without an invitation. ",e.jsx(Ee,{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 iv({config:t}){const[s,r]=m.useState(null),[l,i]=m.useState(""),[c,d]=m.useState(""),[u,p]=m.useState(!1),[f,g]=m.useState(!1),[j,y]=m.useState(!1),[k,N]=m.useState(null),w=m.useId(),b=m.useId(),$=()=>rt.me().then(r,C=>C instanceof Gr?Ue("/signup",!0):N(C.message));if(m.useEffect(()=>{$()},[]),!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(!s)return k?e.jsx(ve,{what:"your sign-in",reason:k,onRetry:()=>{N(null),$()}}):e.jsx(fe,{what:"your sign-in"});const R=k?{"aria-describedby":w}:{},T=C=>{C.preventDefault(),y(!0),N(null),rt.createOrganization({name:l.trim(),slug:c,acceptTerms:f},s.csrf).then(E=>window.location.assign(E.next),E=>{N(E.message),y(!1)})};return e.jsxs("form",{className:"form",onSubmit:T,"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 ",s.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=>{i(C.target.value),u||d(av(C.target.value))},required:!0,maxLength:80,autoComplete:"organization",...R})]}),e.jsxs("label",{children:["Web address",e.jsx("input",{value:c,onChange:C=>{p(!0),d(C.target.value.toLowerCase())},required:!0,pattern:"[a-z0-9][a-z0-9\\-]{1,38}",autoComplete:"off",spellCheck:!1,"aria-describedby":k?`${b} ${w}`:b})]}),e.jsxs("p",{className:"muted",id:b,children:["Your organization is at /",c||"your-address",", in lowercase letters, digits and dashes. ",e.jsx(Ee,{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,...R})," 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"}),"."]}),k?e.jsx("p",{className:"error",role:"alert",id:w,children:k}):null,e.jsx("div",{className:"actions",children:e.jsx("button",{type:"submit",disabled:j,children:j?"Creating…":"Create organization"})}),e.jsx(Qa,{config:t})]})}function cv({config:t}){const s=window.location.pathname.replace(/\/+$/,"")==="/signup/organization";return e.jsx("main",{className:"gate",children:e.jsxs("section",{className:"panel form","aria-labelledby":s?"create-org-h":"signup-h",children:[e.jsxs("div",{className:"brand",children:["TeamHandbook ",e.jsx("span",{children:"Orchestrator"})]}),s?e.jsx(iv,{config:t}):e.jsx(ov,{config:t}),e.jsx(Eo,{privacyUrl:t.privacyUrl,termsUrl:t.termsUrl})]})})}function uv(){const t=window.location.hash.split("?")[1];return t?new URLSearchParams(t).get("problem"):null}function dv({config:t,org:s=null,onSignedIn:r}){const[l,i]=m.useState(""),[c,d]=m.useState(""),[u,p]=m.useState(uv()),[f,g]=m.useState(!1),j=m.useId(),y=u?{"aria-invalid":!0,"aria-describedby":j}:{},k=N=>{N.preventDefault(),g(!0),p(null),Ya.login(l,c).then(r,w=>{p(w.message),g(!1)})};return e.jsx("main",{className:"gate",children:e.jsxs("form",{className:"panel form",onSubmit:k,"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"}),s?e.jsxs("p",{className:"muted",children:["to ",s]}):null,e.jsxs("label",{children:["Email",e.jsx("input",{type:"email",autoComplete:"username",value:l,onChange:N=>i(N.target.value),required:!0,...y})]}),e.jsxs("label",{children:["Password",e.jsx("input",{type:"password",autoComplete:"current-password",value:c,onChange:N=>d(N.target.value),required:!0,...y})]}),u?e.jsx("p",{className:"error",role:"alert",id:j,children:u}):null,e.jsx("button",{type:"submit",disabled:f,children:"Sign in"}),t.sso?e.jsx("a",{className:"button secondary",href:ir("/api/auth/oidc/start"),children:"Sign in with SSO"}):null,e.jsx(Eo,{privacyUrl:t.privacyUrl,termsUrl:t.termsUrl})]})})}function hv({onSignedIn:t}){const[s,r]=m.useState({code:"",name:"",email:"",password:""}),[l,i]=m.useState(null),[c,d]=m.useState(!1),u=m.useId(),p=g=>({value:s[g],onChange:j=>r({...s,[g]:j.target.value}),...l?{"aria-invalid":!0,"aria-describedby":u}:{}}),f=g=>{g.preventDefault(),d(!0),i(null),Ya.setup(s).then(t,j=>{i(j.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(Ee,{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(yt,{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",...p("code"),required:!0})]}),e.jsxs("label",{children:["Name",e.jsx("input",{autoComplete:"name",...p("name")})]}),e.jsxs("label",{children:["Email",e.jsx("input",{type:"email",autoComplete:"username",...p("email"),required:!0})]}),e.jsxs("label",{children:["Password",e.jsx("input",{type:"password",autoComplete:"new-password",minLength:12,...p("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 Nf(t,s,r,l=!1){const i=(...g)=>we(t,...g),c=r?i("repositories",r):i("repositories"),d=i("welcome"),{open:u,merged:p,closed:f}=s.requests;return[{id:"forge",required:!0,done:l||s.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:s.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:s.members>1,to:i("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:s.tasks.total>0||s.tracker,to:i("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+p+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:p>0,to:i("repositories","requests"),action:"Open requests",title:"Merge your first request",detail:"A request reaches teammates once a reviewer merges it."}]}function mv(t){const s=t.filter(d=>d.id==="github"||d.id==="gitlab"),r=s.flatMap(d=>d.ownCli?[d.ownCli]:[]),l=r.find(d=>d.signedIn)??r.find(d=>d.installed)??r[0],i=s.some(d=>{var u;return d.state==="connected"||((u=d.ownCli)==null?void 0:u.signedIn)===!0}),c=l?l.signedIn?l.account?`Signed in as ${l.account} with ${l.tool}.`:`Signed in with ${l.tool}.`:l.installed?`Run ${l.login} in a terminal on this machine.`:`Install ${l.tool}, then run ${l.login}.`:"Sign in once with gh or glab on this machine; from a task's review you then open its change on GitHub or GitLab under your own name.";return{done:i,detail:c}}function pv(t,s,r,l,i){const c=we(t,"welcome");return[{id:"repo",required:!0,done:s.repos>0,to:c,action:"Pick the folder",title:"Where your code lives",detail:"Pick the folder your code lives in; it needs nothing set up first."},{id:"task",required:!0,done:s.tasks.total>0,to:c,action:"Start a task",title:"First task",detail:"Say what the agent should do there, then review every change it made before you keep it."},{id:"team-skills",required:!1,done:r.some(d=>d.kind==="skills"&&d.configured!==!1),to:`${we(t,"repositories")}?connect=path`,action:"Open their folder",title:"Add your team skills",detail:"Open the folder of the skills, MCP servers and commands your team shares; it is recognised as team skills on its own."},{id:"forge",required:!1,done:l.done,to:`${we(t,"integrations")}?open=github`,action:"Connect",title:"Connect GitHub or GitLab",detail:l.detail},{id:"tracker",required:!1,done:s.tracker||i,to:`${we(t,"integrations")}?open=jira`,action:"Connect Jira",title:"Connect Jira",detail:"Bring your Jira sprint onto Work; an agent takes an issue from there, and you review what it changed."}]}const fv=3e3,gv=10;function xv(t){const[s,r]=m.useState(null),[l,i]=m.useState(0);return m.useEffect(()=>{let c=!0,d;const u=p=>$e.options().then(f=>{c&&(r(f.agents),p>0&&f.agents.length&&f.agents.every(g=>!g.readiness)&&(d=setTimeout(()=>u(p-1),fv)))},()=>c&&r([]));return u(gv),()=>{c=!1,clearTimeout(d)}},[t,l]),[s,()=>{r(null),i(c=>c+1)}]}function $n({name:t,count:s,why:r,empty:l,children:i}){const c=m.useId();return e.jsxs("section",{className:"turn","aria-labelledby":c,children:[e.jsxs("div",{className:"turn-side",children:[e.jsxs("h2",{id:c,children:[t," ",e.jsx("span",{className:"count",children:s})]}),r?e.jsx("p",{className:"turn-why",children:r}):null]}),e.jsx("div",{className:"turn-body",children:s===0?e.jsx("p",{className:"turn-empty",children:l}):i})]})}const Ja=["gitlab","github"],Jt={gitlab:"GitLab",github:"GitHub"},Zn={connection:t=>B("GET",`/api/forge/${t}/connection`),connect:(t,s)=>B("POST",`/api/forge/${t}/connect`,s?{return:s}:{}),repos:t=>B("GET",`/api/forge/${t}/repos`).then(s=>s.repos),connectRepo:(t,s)=>B("POST",`/api/forge/${t}/repos/connect`,s),gitlabApp:()=>B("GET","/api/forge/gitlab/app"),setGitlabApp:t=>B("PUT","/api/forge/gitlab/app",t),teamRepo:(t,s)=>B("POST",`/api/forge/${t}/team-repo`,s)};function qu(t){const[s,r]=m.useState(null),l=()=>{t&&Promise.all(Ja.map(i=>Zn.connection(i).catch(()=>null))).then(([i,c])=>r({gitlab:i??null,github:c??null}))};return m.useEffect(l,[t]),[s,l]}function Mo(t){return Ja.find(s=>{var r;return(r=t==null?void 0:t[s])==null?void 0:r.connection})??null}function Sf(t){try{const s=new URL(t);return s.protocol==="https:"||s.protocol==="http:"?s.href:null}catch{return null}}const jv=/`([^`]+)`|\*\*([^*]+)\*\*|__([^_]+)__|\*([^*\s][^*]*)\*|_([^_\s][^_]*)_|!?\[([^\]]*)\]\(([^)\s]+)\)/g;function qr(t){const s=[];let r=0;for(const l of t.matchAll(jv)){l.index>r&&s.push({kind:"text",text:t.slice(r,l.index)});const[i,c,d,u,p,f,g,j]=l;if(c!==void 0)s.push({kind:"code",text:c});else if(d!==void 0||u!==void 0)s.push({kind:"strong",children:qr(d??u)});else if(p!==void 0||f!==void 0)s.push({kind:"em",children:qr(p??f)});else if(i.startsWith("!"))s.push({kind:"image",src:j,alt:g??""});else{const y=Sf(j);s.push(y?{kind:"link",href:y,children:qr(g||j)}:{kind:"text",text:i})}r=l.index+i.length}return r<t.length&&s.push({kind:"text",text:t.slice(r)}),s}const Qm=/^\s{0,3}(?:([-*+])|(\d{1,9})[.)])\s+(.*)$/,yv=8;function Cf(t,s=0){const r=t.replace(/\r\n?/g,`
|
|
43
|
-
`).split(`
|
|
44
|
-
`),l=[];let i=[];const c=()=>{i.length&&l.push({kind:"paragraph",children:qr(i.join(" "))}),i=[]};for(let d=0;d<r.length;d++){const u=r[d],p=/^\s{0,3}(`{3,}|~{3,})\s*([\w+-]*)\s*$/.exec(u);if(p){c();const j=p[1],y=new RegExp(`^\\s{0,3}${j[0]==="`"?"`":"~"}{${j.length},}\\s*$`),k=[];for(;++d<r.length&&!y.test(r[d]);)k.push(r[d]);l.push({kind:"code",lang:p[2]??"",text:k.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:qr(f[2])});continue}if(/^\s{0,3}([-*_])(\s*\1){2,}\s*$/.test(u)){c(),l.push({kind:"rule"});continue}if(s<yv&&/^\s{0,3}>/.test(u)){c();const j=[];for(;d<r.length&&/^\s{0,3}>/.test(r[d]);d++)j.push(r[d].replace(/^\s{0,3}>\s?/,""));d--,l.push({kind:"quote",children:Cf(j.join(`
|
|
46
|
-
`),s+1)});continue}const g=Qm.exec(u);if(g){c();const j=g[2]!==void 0,y=[];for(;d<r.length;d++){const k=Qm.exec(r[d]);if(k&&k[2]!==void 0===j)y.push(qr(k[3]));else if(r[d].trim()&&/^\s{2,}/.test(r[d])&&y.length)y[y.length-1].push({kind:"text",text:` ${r[d].trim()}`});else break}d--,l.push({kind:"list",ordered:j,items:y});continue}u.trim()?i.push(u.trim()):c()}return c(),l}function vv({src:t,alt:s,media:r}){const[l,i]=m.useState(!1),c=r==null?void 0:r(t);if(c&&!l)return e.jsx("img",{src:c,alt:s,loading:"lazy",onError:()=>i(!0)});const d=`image: ${s||t}`,u=Sf(t);return u?e.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer nofollow",children:d}):e.jsx(e.Fragment,{children:d})}function Br(t,s){return t.map((r,l)=>r.kind==="text"?r.text:r.kind==="code"?e.jsx("code",{children:r.text},l):r.kind==="strong"?e.jsx("strong",{children:Br(r.children,s)},l):r.kind==="em"?e.jsx("em",{children:Br(r.children,s)},l):r.kind==="image"?e.jsx(vv,{src:r.src,alt:r.alt,media:s},l):e.jsx("a",{href:r.href,target:"_blank",rel:"noopener noreferrer nofollow",children:Br(r.children,s)},l))}const kv=["h3","h3","h4","h5","h6","h6"];function $f(t,s,r){if(t.kind==="heading"){const l=kv[t.level-1];return e.jsx(l,{children:Br(t.children,r)},s)}if(t.kind==="paragraph")return e.jsx("p",{children:Br(t.children,r)},s);if(t.kind==="code")return e.jsx("pre",{className:"pre mono",children:e.jsx("code",{children:t.text})},s);if(t.kind==="quote")return e.jsx("blockquote",{children:t.children.map((l,i)=>$f(l,i,r))},s);if(t.kind==="list"){const l=t.items.map((i,c)=>e.jsx("li",{children:Br(i,r)},c));return t.ordered?e.jsx("ol",{children:l},s):e.jsx("ul",{children:l},s)}return e.jsx("hr",{},s)}function Jr({text:t,media:s}){const r=m.useMemo(()=>Cf(t),[t]);return e.jsx("div",{className:"markdown",dir:"auto",children:r.map((l,i)=>$f(l,i,s))})}const hr={owner:"Owner",admin:"Admin",member:"Member",viewer:"Viewer"},wv={password:"Password",sso:"SSO",google:"Google",github:"GitHub",microsoft:"Microsoft"},Tf=t=>t.map(s=>wv[s]??s).join(", ")||"none",Bu={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."},Us={owner:2,admin:1,member:0,viewer:-1};function zu(t){return["owner","admin","member","viewer"].filter(s=>Us[s]<=Us[t.role])}function Ef(t){return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function _o({teams:t,value:s,onChange:r,label:l,disabled:i}){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:s.includes(c.team),disabled:i,onChange:d=>r(d.target.checked?[...s,c.team]:s.filter(u=>u!==c.team))}),c.team]},c.team))]}):e.jsx("span",{className:"muted",children:"No team yet"})}function Rf({sent:t,skipped:s}){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(Ee,{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(r=>e.jsxs("li",{children:[r.email,": ",e.jsx(yt,{text:r.link,label:`Copy the link for ${r.email}`})]},r.id))})]}):null,s.map(r=>e.jsxs("p",{className:"muted",children:[r.email,": ",r.reason]},r.email))]})}const Jm=/[\s,;]+/;function Wu({me:t,teams:s,onSent:r,onCancel:l}){const[i,c]=m.useState([]),[d,u]=m.useState(""),[p,f]=m.useState("member"),[g,j]=m.useState([]),[y,k]=m.useState(null),[N,w]=m.useState(!1),b=m.useId(),$=m.useId(),R=O=>c(F=>[...F,...O.filter((L,W)=>L&&!F.includes(L)&&O.indexOf(L)===W)]),T=O=>{const F=O.split(Jm);u(F.pop()??""),R(F)},C=O=>{O.preventDefault();const F=[...i,...d.split(Jm).filter(L=>L&&!i.includes(L))];w(!0),k(null),Kr.invite({emails:F.join(" "),role:p,teams:p==="viewer"?[]:g}).then(L=>{c([]),u(""),j([]),w(!1),r(L.invited,L.skipped)},L=>{k(L.message),w(!1)})},E=y?{"aria-describedby":b}:{};return e.jsxs("form",{className:"form",onSubmit:C,"aria-labelledby":"invite-h",children:[e.jsx("h2",{id:"invite-h",children:"Invite members"}),i.length?e.jsx("ul",{className:"plain actions","aria-label":"Addresses to invite",children:i.map(O=>e.jsxs("li",{className:"badge",children:[O," ",e.jsx("button",{type:"button",className:"ghost small","aria-label":`Leave out ${O}`,onClick:()=>c(i.filter(F=>F!==O)),children:"×"})]},O))}):null,e.jsxs("label",{children:["Emails",e.jsx("input",{value:d,onChange:O=>T(O.target.value),onKeyDown:O=>{O.key==="Enter"&&d.trim()?(O.preventDefault(),T(`${d} `)):O.key==="Backspace"&&!d&&i.length&&c(i.slice(0,-1))},required:!i.length,autoComplete:"off",spellCheck:!1,"aria-describedby":y?`${$} ${b}`:$})]}),e.jsx("p",{className:"muted",id:$,children:"Separate addresses with spaces, commas or new lines."}),e.jsxs("fieldset",{children:[e.jsx("legend",{children:"Role"}),zu(t).map(O=>e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"radio",name:"invite-role",value:O,checked:p===O,onChange:()=>f(O),...E})," ",hr[O]]},O))]}),e.jsx("p",{className:"muted",children:Bu[p]}),p==="viewer"?null:e.jsxs("div",{children:[e.jsx("span",{children:"Team owner of"}),e.jsx(_o,{teams:s,value:g,onChange:j,label:"Teams they will own"})]}),y?e.jsx("p",{className:"error",role:"alert",id:b,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 bv({invites:t,me:s,hideEmpty:r=!1,onChanged:l,onLink:i}){const[c,d]=m.useState(null),[u,p]=m.useState(null);if(r&&!t.length)return null;const f=t.find(j=>j.id===c)??null,g=j=>j.then(l,y=>p(y.message));return e.jsxs($n,{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(j=>e.jsxs("tr",{className:j.id===c?"picked":void 0,onClick:()=>d(j.id),children:[e.jsx("td",{className:"rc-title",children:e.jsx("button",{type:"button",className:"row-pick","aria-pressed":j.id===c,onClick:()=>d(j.id),children:j.email})}),e.jsx("td",{className:"rc-status",children:hr[j.role]}),e.jsx("td",{className:j.teams.length?"rc-meta":"rc-meta muted member-wide-only",children:j.teams.length?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"member-cell-label",children:"Owns "}),e.jsx("span",{children:j.teams.join(", ")})]}):"none"}),e.jsx("td",{className:"rc-meta",children:j.expired?e.jsx("span",{className:"badge warn",children:"expired"}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"member-cell-label",children:"Expires "}),Ef(j.expiresAt)]})}),e.jsx("td",{className:"rc-extra muted",children:j.invitedBy})]},j.id))})]}),f&&Us[f.role]<=Us[s.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(Kr.resend(f.id).then(i)),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:()=>Kr.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 Nv({user:t,teams:s,editable:r,onSave:l}){const[i,c]=m.useState(null);return i?e.jsxs(e.Fragment,{children:[e.jsx(_o,{teams:s,value:i,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(i).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"})}),r&&s.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 Sv({user:t,me:s,onChanged:r,onRemoved:l}){const[i,c]=m.useState([]),[d,u]=m.useState(null),p=m.useId();m.useEffect(()=>{Xt.teams().then(c,()=>c([]))},[]);const f=y=>Xt.update(t.id,y).then(r,k=>{throw u(k.message),k}),g=Ie(s)&&Us[t.role]<=Us[s.role],j=t.id===s.id||!g;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx(Pe,{label:`Role of ${t.email}`,describedBy:d?p:void 0,value:t.role,disabled:j,onChange:y=>void f({role:y}).catch(()=>{}),options:["owner","admin","member","viewer"].filter(y=>y===t.role||zu(s).includes(y)).map(y=>({value:y,label:hr[y]}))}),e.jsx("p",{className:"muted",children:t.id===s.id?"Nobody changes their own role.":Bu[t.role]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"label",children:"Team owner of"}),e.jsx(Nv,{user:t,teams:i,editable:g,onSave:y=>f({teams:y})})]}),d?e.jsx("p",{className:"error",role:"alert",id:p,children:d}):null,t.id!==s.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:()=>Xt.remove(t.id).then(l)}):null]})}function Cv({user:t,me:s,onChanged:r,extra:l}){const[i,c]=m.useState(null),d=m.useId(),u=t.id===s.id||Us[t.role]>Us[s.role];return e.jsxs("tr",{children:[e.jsxs("td",{className:"rc-title",children:[e.jsx("a",{href:ce("settings","members",t.id),children:t.name}),t.id===s.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:i?d:void 0,value:t.role,disabled:u,onChange:p=>Xt.update(t.id,{role:p}).then(r,f=>c(f.message)),options:["owner","admin","member","viewer"].filter(p=>p===t.role||zu(s).includes(p)).map(p=>({value:p,label:hr[p]}))}),i?e.jsx("p",{className:"error",role:"alert",id:d,children:i}):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 "}),Ef(t.createdAt)]}),e.jsx("td",{className:"rc-meta",children:Tf(t.signIn)}),l?e.jsxs("td",{className:"rc-meta",children:[e.jsxs("span",{className:"member-cell-label",children:[l.name,": "]}),l.cell]}):null]})}function $v({me:t,onLeft:s}){const[r,l]=m.useState(null),[i,c]=m.useState(null),d=()=>Xt.teams().then(l,u=>c(u.message));return m.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 ",r?e.jsx("span",{className:"count",children:r.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:ce("settings","members",t.id),children:"open your own member page"}),". ",e.jsx(Ee,{label:"teams",children:"A team's owners edit its skills, MCP servers and commands; an owner or an admin manages members."})]}),i?e.jsx(ve,{what:"teams",reason:i,onRetry:()=>{c(null),d()}}):r?r.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:r.map(u=>e.jsxs("tr",{children:[e.jsx("td",{children:u.team}),e.jsx("td",{children:u.owners.map(p=>p.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(fe,{what:"teams"})]}),e.jsx(Pf,{me:t,onLeft:s})]})}function Pf({me:t,onLeft:s}){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:()=>Kr.leave().then(s)})]})}const Tv=[{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."}],Xm=(t,s,r)=>`${t} ${t===1?s:r}`;function Af(t){const[s,r]=m.useState(null),[l,i]=m.useState([]),[c,d]=m.useState([]),[u,p]=m.useState(null),[f,g]=m.useState(null),[j,y]=m.useState(null),k=Ie(t),N=()=>{k&&(g(null),y(null),Xt.users().then(r,w=>g(w.message)),Xt.teams().then(i,()=>i([])),Kr.invites().then(d,w=>y(w.message)))};return m.useEffect(N,[k]),{users:s,teams:l,invites:c,sent:u,setSent:p,error:f,invitesError:j,reload:N}}function If({me:t,data:s,extra:r,hideEmpty:l=!1}){const[i,c]=m.useState(""),[d,u]=m.useState(1),{users:p,invites:f,sent:g,setSent:j,error:y,invitesError:k,reload:N}=s,w=i.trim().toLowerCase(),b=(p??[]).filter(C=>!w||C.name.toLowerCase().includes(w)||C.email.toLowerCase().includes(w)),$=Lu(b,d),R=["Member","Role","Team owner of","Joined","Signs in with",...r?[r.name]:[]],T=r?" with-extra":"";return e.jsxs(e.Fragment,{children:[g?e.jsx(Rf,{sent:g.sent,skipped:g.skipped}):null,y?e.jsx(ve,{what:"members",reason:y,onRetry:N}):p?e.jsxs(e.Fragment,{children:[p.length>el?e.jsxs("label",{className:"filter",children:["Find a member",e.jsx("input",{type:"search","data-page-search":!0,value:i,onChange:C=>{c(C.target.value),u(1)}})]}):null,w&&!b.length?e.jsxs("p",{className:"muted",children:["No one matches “",i.trim(),"”."]}):null,e.jsxs("div",{className:"turn-columns member-head","aria-hidden":"true",children:[e.jsx("span",{}),e.jsx("span",{className:`member-columns${T}`,children:R.map(C=>e.jsx("span",{children:C},C))})]}),Tv.map(({role:C,name:E,empty:O})=>{const F=$.shown.filter(L=>L.role===C);return l&&!w&&!b.some(L=>L.role===C)?null:e.jsx($n,{name:E,count:b.filter(L=>L.role===C).length,why:Bu[C],empty:w?`No one here matches “${i.trim()}”.`:O,children:F.length?e.jsxs("table",{className:`member-table row-cards${T}`,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"}),r?e.jsx("col",{className:"c-extra"}):null]}),e.jsx("thead",{className:"visually-hidden",children:e.jsx("tr",{children:R.map(L=>e.jsx("th",{children:L},L))})}),e.jsx("tbody",{children:F.map(L=>e.jsx(Cv,{user:L,me:t,onChanged:N,extra:r?{name:r.name,cell:r.cell(L)}:void 0},L.id))})]}):e.jsx("p",{className:"turn-empty",children:"On another page of this list."})},C)}),e.jsx(Lo,{page:$.page,total:b.length,onPage:u,label:"Pages of members"})]}):e.jsx(fe,{what:"members"}),k?e.jsx(ve,{what:"invitations",reason:k,onRetry:N}):e.jsx(bv,{invites:f,me:t,hideEmpty:l,onChanged:N,onLink:C=>j({sent:[C],skipped:[]})})]})}function Ev({me:t,nav:s,onLeft:r}){const l=Af(t),[i,c]=m.useState(!1);if(!Ie(t))return e.jsxs(e.Fragment,{children:[e.jsx(Cn,{title:"Members",summary:"Who owns each team, so you know whom to ask."}),s,e.jsx($v,{me:t,onLeft:r})]});const{users:d,invites:u}=l,p=d?`${Xm(d.length,"person","people")} in this organization${u.length?`; ${Xm(u.length,"invitation waits","invitations wait")} to be taken up`:""}.`:void 0;return e.jsxs(e.Fragment,{children:[e.jsx(Cn,{title:"Members",summary:p,actions:i?null:e.jsx("button",{type:"button",onClick:()=>c(!0),children:"Invite members"})}),s,i?e.jsx("section",{className:"panel",children:e.jsx(Wu,{me:t,teams:l.teams,onCancel:()=>c(!1),onSent:(f,g)=>{l.setSent({sent:f,skipped:g}),c(!1),l.reload()}})}):null,e.jsx(If,{me:t,data:l}),e.jsx(Pf,{me:t,onLeft:r})]})}const Rv={catalog:()=>B("GET","/api/tags").then(t=>t.tags.map(s=>({tag:s.tag,members:s.members.length})))},Of={get:t=>B("GET",`/api/members/${encodeURIComponent(t)}/config`),preview:(t,s,r)=>B("POST",`/api/members/${encodeURIComponent(t)}/config/preview`,{audience:s,rules:r})},Qt={list:()=>B("GET","/api/policies"),preview:(t,s)=>B("POST","/api/policies/preview",{audience:t,rules:s}),proposal:(t,s)=>B("POST","/api/policies/proposal",s?{...t?{id:t}:{},policy:s}:{id:t,remove:!0}),save:(t,s,r)=>t?B("PUT",`/api/policies/${encodeURIComponent(t)}`,{policy:s,...r}):B("POST","/api/policies",{policy:s,...r}),remove:(t,s)=>B("DELETE",`/api/policies/${encodeURIComponent(t)}`,s??{})},ns=t=>t.role==="admin"||t.role==="owner",Zm=t=>t.startsWith("service:");function Pv(t,s){const r=t.split("*").map(l=>l.replace(/[.+?^${}()|[\]\\]/g,"\\$&"));return new RegExp(`^${r.join(".*")}$`).test(s)}function Av(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 Iv(t,s,r){const l=Av(s);if(!l)return null;const i=r.teams.find(u=>u.repos.includes(t))??null,c=l.skill?r.usage.filter(u=>u.repoId===t&&u.skill===l.skill):[],d=l.resource?r.policies.filter(u=>(!u.repos||u.repos.includes(t))&&u.rules.some(p=>"resources"in p&&p.resources.some(f=>Pv(f,l.resource)||f.startsWith(`${l.resource}/`)))):[];return{subject:l.subject,removing:l.removing,team:(i==null?void 0:i.team)??null,overlap:l.skill?r.overlaps[l.skill]??null:null,usage:l.skill?{count:c.reduce((u,p)=>u+p.count,0),days:r.usageDays,lastHour:c.map(u=>u.lastHour).sort().at(-1)??null}:null,policies:d.map(u=>({id:u.id,name:u.name}))}}const Lf=["approval-required","auto-accept-edits","auto","full-access"],hu={"approval-required":"Approval required","auto-accept-edits":"Auto-accept edits",auto:"Auto","full-access":"Full access"},Ov={"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"},Lv="auto",ep=t=>Lf.indexOf(t),Fv=["workspace","teams","members","except-members","tags","except-tags","service-accounts"],Mv=["skill-access","mcp-access","tool-access"],Ro=20,tp=20,mu=100,pu=200,fu=1e6,np=["Bash","Read","Edit","Glob","Grep","WebFetch","WebSearch"],Xa=t=>Mv.includes(t);function pn(t){return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t.at(-1)}`}function gu(t,s,r){return t===1?s:r}function Hu(t){return`$${t.toLocaleString("en-US",{maximumFractionDigits:2})}`}const _v={"skill-access":"skill:","mcp-access":"mcp:","tool-access":"tool:"};function Gu(t,s){return`${_v[t]}${s.trim()}`}function xu(t){const[s,...r]=t.split(":");if(s==="tool"){const[l,...i]=r,c=i.join(":");return c==="*"||!c?`${l}`:`${l} (${c})`}if(s==="mcp"){const[l,i]=r.join(":").split("/");return i?`${i} on ${l}`:`${l}`}return r.join(":")||t}function sp(t,s=r=>r){if(t.kind==="workspace")return"Everyone in the organization";const r=pn(t.ids.map(s));switch(t.kind){case"teams":return r?`Members of ${r}`:"Members of the chosen teams";case"members":return r||"The chosen members";case"except-members":return r?`Everyone except ${r}`:"Everyone except the chosen members";case"tags":return r?`Members tagged ${r}`:"Members with the chosen tags";case"except-tags":return r?`Everyone except members tagged ${r}`:"Everyone except members with the chosen tags";case"service-accounts":return r?`The service ${gu(t.ids.length,"account","accounts")} ${r}`:"The chosen service accounts"}}function Dv(t){switch(t.kind){case"skill-access":case"mcp-access":case"tool-access":{const s=pn(t.resources.map(xu));return t.kind==="skill-access"?s?`cannot use the ${gu(t.resources.length,"skill","skills")} ${s}`:"cannot use the chosen skills":t.kind==="mcp-access"?s?`cannot use the MCP ${gu(t.resources.length,"server","servers")} ${s}`:"cannot use the chosen MCP servers":s?`cannot use ${s} in Claude Code`:"cannot use the chosen tools in Claude Code"}case"task-budget":{const s=t.monthlyUsd===null?"a monthly limit":Hu(t.monthlyUsd);return t.per==="member"?`can each spend up to ${s} a month on tasks`:`can spend up to ${s} a month on tasks, together`}case"repo-access":{const s=pn(t.repos)||"the chosen repositories";return t.effect==="allow"?`can start tasks on ${s}`:`cannot start tasks on ${s}`}case"task-mode":return`can run tasks on ${t.repos.includes("*")?"every repository":pn(t.repos)||"the chosen repositories"} in ${hu[t.ceiling]} mode at most`;case"own-setup":{const s=t.repos.includes("*")?"every repository":pn(t.repos)||"the chosen repositories";return t.allowed?`can run tasks on ${s} with their own Claude Code setup`:`can run tasks on ${s} only with their sign-in and the team's skills`}}}function Ku(t,s){return t.rules.length?`${sp(t.audience,s)} ${pn(t.rules.map(Dv))}.`:`${sp(t.audience,s)}: add a rule to say what this policy does.`}const Uv={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"},qv={"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"},Bv="Rules that reach teammates' sessions are saved as a request and the orchestrator's own rules apply at once; put them in two policies.",Ff="Rules that reach teammates' sessions apply to whole teams: a teammate's machine does not say who is at it.";function Mf(t){if(t.audience.kind!=="workspace"&&!t.audience.ids.length)return`${Uv[t.audience.kind]} to continue.`;if(!t.rules.length)return"Add a rule to continue.";if(t.rules.length>Ro)return`A policy holds at most ${Ro} rules; split it in two.`;for(const r of t.rules)if(r.kind==="task-budget"){if(r.monthlyUsd===null||!Number.isFinite(r.monthlyUsd))return"Enter a monthly limit to continue.";if(r.monthlyUsd<=0||r.monthlyUsd>fu)return`Enter a monthly limit above $0 and at most ${Hu(fu)}.`}else if(r.kind==="repo-access"||r.kind==="task-mode"||r.kind==="own-setup"){if(!r.repos.length)return"Choose repositories to continue."}else{if(!r.resources.length)return`${qv[r.kind]} to continue.`;if(r.resources.length>tp)return`A rule names at most ${tp} entries; add another rule for the rest.`;if(!r.reason.trim())return"Say why this is blocked; teammates read it when a call is stopped.";if(r.reason.length>pu)return`Keep the reason to ${pu} characters.`}const s=t.rules.filter(r=>Xa(r.kind)).length;return s&&s<t.rules.length?Bv:s&&t.audience.kind!=="workspace"&&t.audience.kind!=="teams"?Ff:null}function zv(t){const s=t.name.trim();return s?s.length>mu?`Keep the name to ${mu} characters.`:Mf(t):"Name the policy to continue."}function fn(t){return t.rules.some(s=>Xa(s.kind))}function Wv(t){return fn(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 Hv(t){const s=t.rules.flatMap(r=>r.kind==="task-budget"?[`tasks stop counting against its ${r.monthlyUsd===null?"monthly":`${Hu(r.monthlyUsd)} monthly`} budget`]:r.kind==="repo-access"?["its rules on where tasks start stop holding"]:r.kind==="task-mode"?["its ceiling on how much agents do without asking stops holding"]:r.kind==="own-setup"&&!r.allowed?["tasks use their starter's own Claude Code setup again"]:[]);return`Deleting it applies at once: ${pn([...new Set(s)])||"its rules stop holding"}. The deletion is recorded in the audit log.`}function Gv(t,s){if(s.rules.length>=Ro)return`A policy holds at most ${Ro} rules.`;const r=Xa(t);return s.rules.some(l=>Xa(l.kind)!==r)?r?"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.":!r&&!s.isAdmin?"Only an admin sets the orchestrator's own rules.":!r&&!s.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 rp(t,s){return fn({rules:s})&&t!=="workspace"&&t!=="teams"?Ff:null}function Kv(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 ju=[{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"}],Mc=[{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(s=>Gu("tool-access",`Bash:${s}`)),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 _f(t,s,r=!1){return r?t?Mc.filter(l=>!fn(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:i=>({...l.draft(i),audience:{kind:"workspace"}})})):[]:t?Mc:s?Mc.filter(l=>fn(l.draft({teams:[],everyone:!1}))):[]}function Vv(t){if(t.length<=1)return t[0]??"";let s=t[0];for(const r of t.slice(1)){let l=0;for(;l<s.length&&l<r.length&&s[s.length-1-l]===r[r.length-1-l];)l++;s=s.slice(s.length-l)}return s.trimStart()}function Yv(t){return t?`${t.toLocaleString("en-US")} policies hold groups to rules.`:"No policy holds anyone to a rule yet."}function Qv({repoId:t,change:s}){const[r,l]=m.useState(void 0),i=JSON.stringify(s);if(m.useEffect(()=>{let d=!0;const u=s.kind.startsWith("skill.");return Promise.all([Xt.teams().catch(()=>[]),u?Ne.usage(t).catch(()=>({days:30,usage:[]})):Promise.resolve({days:30,usage:[]}),u?Ne.overlaps(t).then(p=>p.overlaps).catch(()=>({})):Promise.resolve({}),Qt.list().then(p=>p.policies).catch(()=>[])]).then(([p,f,g,j])=>{d&&l(Iv(t,s,{teams:p,usage:f.usage,usageDays:f.days,overlaps:g,policies:j}))}),()=>{d=!1}},[t,i]),r===null)return null;if(r===void 0)return e.jsx("p",{className:"muted change-preview","aria-busy":"true",children:"Checking what this change touches…"});const c=r.team?`teammates on ${r.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:r.removing?`Once merged, ${c} lose ${r.subject}.`:`Once merged, ${c} get this version of ${r.subject}.`}),r.usage?e.jsx("li",{children:r.usage.count?`Used ${r.usage.count.toLocaleString("en-US")} ${r.usage.count===1?"time":"times"} in the last ${r.usage.days} days${r.usage.lastHour?`, last on ${r.usage.lastHour.slice(0,10)}`:""}.`:`No reported use in the last ${r.usage.days} days.`}):null,r.overlap&&!r.removing?e.jsxs("li",{children:["Answers the same requests as ",pn(r.overlap.names),r.overlap.more?` and ${r.overlap.more} more`:"","; a session picks one of them."]}):null,r.policies.map(d=>e.jsxs("li",{children:["The policy ",e.jsx("a",{href:ce("team","policies",d.id),children:d.name})," ",r.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 Jv={impact:(t,s,r)=>B("GET",`/api/repos/${encodeURIComponent(t)}/removal?${new URLSearchParams({[s]:r})}`)};function Xv(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 s=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${s}.`}const Zv={add:"adds the policy",change:"changes the policy",remove:"removes the policy"};function Df({plan:t,action:s,onConfirm:r,onCancel:l}){const i=m.useId(),[c,d]=m.useState(()=>Vv(t.repos.map(w=>w.proposal))),[u,p]=m.useState(()=>Object.fromEntries(t.repos.map(w=>[w.repoId,w.branch]))),[f,g]=m.useState(!1),[j,y]=m.useState(null),k=async()=>{g(!0),y(null),await r({message:c,branches:u,baseShas:Object.fromEntries(t.repos.map(w=>[w.repoId,w.head]))}).catch(w=>y(w.message)),g(!1)},N=t.repos.length;return e.jsxs("section",{className:"panel confirm","aria-labelledby":`${i}-h`,onKeyDown:w=>w.key==="Enter"&&w.target instanceof HTMLInputElement&&w.preventDefault(),children:[e.jsxs("h2",{id:`${i}-h`,children:[s," 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:`${i}-msg`,children:"Commit message"}),e.jsx("input",{id:`${i}-msg`,value:c,onChange:w=>d(w.target.value)})]}),e.jsx("ul",{className:"plain confirm-repos",children:t.repos.map(w=>e.jsxs("li",{children:[e.jsxs("p",{children:[e.jsx("strong",{children:w.name})," ",e.jsxs("span",{className:"muted",children:["(",Zv[w.change],")"]})]}),e.jsxs("p",{className:"muted small-print",children:["Proposed: ",e.jsx("span",{className:"mono",children:w.proposal})]}),e.jsx("label",{className:"inline-label",htmlFor:`${i}-b-${w.repoId}`,children:"Branch"}),e.jsx("input",{id:`${i}-b-${w.repoId}`,className:"mono",value:u[w.repoId]??"",onChange:b=>p({...u,[w.repoId]:b.target.value})})]},w.repoId))}),j?e.jsx("p",{className:"error",role:"alert",children:j}):null,e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",onClick:k,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 Uf({saved:t,repoName:s,back:r}){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:[s(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:s(l.repoId)}),": ",l.error]},l.repoId))})]}):null,e.jsx("p",{children:e.jsx("a",{href:r,children:"Back to policies"})})]})}function qf({repoId:t,kind:s,name:r}){const[l,i]=m.useState(void 0),[c,d]=m.useState({at:"offer"}),[u,p]=m.useState(!1),[f,g]=m.useState(null);if(m.useEffect(()=>{let w=!0;return Jv.impact(t,s,r).then(b=>w&&i(b),()=>w&&i(null)),()=>{w=!1}},[t,s,r]),l===null)return null;if(l===void 0)return e.jsxs("p",{className:"muted removal-impact","aria-busy":"true",children:["Checking what removing ",r," takes away…"]});const j=l.disable,y=j&&j.audience.kind==="teams"?pn(j.audience.ids):null,k=async()=>{j&&(p(!0),g(null),await Qt.proposal(null,j).then(w=>w.applies==="request"?d({at:"confirm",plan:w}):g("This policy would not open a request; disable it from Controls."),w=>g(w.message)),p(!1))},N=async w=>{if(!j)return;const b=await Qt.save(null,j,w);b.saved==="request"&&d({at:"opened",saved:b})};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 ",r," once the request is merged."]}),l.usage?e.jsx("li",{children:Xv(l.usage)}):null]}),l.blockedBy.length?e.jsxs("p",{className:"muted",children:["Already blocked by ",l.blockedBy.map((w,b)=>e.jsxs("span",{children:[b?", ":"",e.jsx("a",{href:ce("team","policies",w.id),children:w.name})]},w.id)),"; removing it also deletes its files."]}):null,j&&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(Ee,{label:"disabling instead",children:["It is written to every repository of ",y??"the team"," and reviewed there; deleting the policy later turns ",r," back on."]})]}),f?e.jsx("p",{className:"error",role:"alert",children:f}):null,e.jsx("button",{type:"button",className:"secondary small",onClick:k,disabled:u,children:u?"Preparing…":"Disable instead"})]}):null,c.at==="confirm"?e.jsx(Df,{plan:c.plan,action:`Disable ${r}`,onConfirm:N,onCancel:()=>d({at:"offer"})}):null,c.at==="opened"?e.jsx(Uf,{saved:c.saved,repoName:w=>w,back:ce("team")}):null]})}const ek=t=>t.split("/").map(encodeURIComponent).join("/");function Bf(t){return{changes:()=>B("GET",t).then(s=>s.changes),file:s=>B("GET",`${t}/${ek(s)}`).then(r=>r.file)}}function Do(t,s){return Bf(`/api/repos/${encodeURIComponent(t)}/requests/${s}/changes`)}function tk(t){return Bf(`/api/tasks/${encodeURIComponent(t)}/changes`)}function nk(t,s,r){let l=!1;return{changes:()=>t.changes().catch(i=>{if(!(i instanceof ut&&i.code==="changes-on-machine"))throw i;return l=!0,r(),{files:s,omitted:0}}),file:i=>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(i)}}function sk(t,s){return B("GET",`/api/repos/${encodeURIComponent(t)}/requests/${s}/status`).then(r=>r.status)}const rk=3;let _c=0;const ap=[];async function ak(t){var s;_c>=rk&&await new Promise(r=>ap.push(r)),_c+=1;try{return await t()}finally{_c-=1,(s=ap.shift())==null||s()}}function lk(t){const s=t.checks.filter(r=>r.state==="failure").length;return t.state==="failing"?`${s||"some"} ${s===1?"check":"checks"} failing`:{passing:"checks passing",pending:"checks running","no-ci":"no CI",unknown:"no check reported yet"}[t.state]}function ok(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 ik(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 ck(t){const s=t.filter(r=>r.kind!=="bot");return s.length?`${s.length} ${s.length===1?"comment":"comments"}, the newest from ${s[0].author}`:null}function uk(t){const{detail:s}=t,r=ik(s.mergeability),l=s.checks.state==="failing",i=s.mergeability.state==="mergeable"&&!l?"ok":s.mergeability.state==="conflict"||s.mergeability.state==="blocked"||l?"warn":"neutral",c=t.source==="local"?[]:[lk(s.checks),ok(s.review),ck(t.comments)];return{merge:r,tone:i,rest:c.filter(Boolean).join(", ")}}function Vu({request:t}){const[s,r]=m.useState(null),[l,i]=m.useState(null),c=t.status==="open",d=t.provider==="local";if(m.useEffect(()=>{if(!c)return;let p=!0;return ak(()=>sk(t.repoId,t.number)).then(f=>p&&r(f),f=>p&&i(f.message)),()=>{p=!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(!s)return d?null:e.jsx("p",{className:"muted small forge-state",children:"Reading the forge…"});const u=uk(s);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 Yu({added:t,removed:s}){return e.jsxs(e.Fragment,{children:[t?e.jsxs("span",{className:"diff-add",children:["+",t]}):null,t&&s?" ":null,s?e.jsxs("span",{className:"diff-del",children:["−",s]}):null]})}const wo=5,dk=6;function hk(t,s){const r=t+s;if(r<=0)return{added:0,removed:0,empty:wo};const l=Math.min(wo,Math.ceil(r/dk)),i=Math.round(t/r*l);return{added:i,removed:l-i,empty:wo-l}}function Uo({added:t,removed:s}){const r=hk(t,s),l=[...Array(r.added).fill("add"),...Array(r.removed).fill("del"),...Array(r.empty).fill("none")];return e.jsx("span",{className:"change-weight",role:"img","aria-label":`${t} ${t===1?"line":"lines"} added, ${s} removed`,children:l.slice(0,wo).map((i,c)=>e.jsx("i",{className:i},c))})}function mk(t){let s=!1;return t.split(`
|
|
47
|
-
`).map(r=>r.startsWith("diff --git ")?(s=!1,"meta"):r.startsWith("@@")?(s=!0,"hunk"):s?r.startsWith("+")?"add":r.startsWith("-")?"del":r.startsWith("\\")?"meta":"context":r.startsWith("--- ")||r.startsWith("+++ ")||r.startsWith("index ")?"meta":"context")}function pk(t){const s=t.indexOf("hunk");return s<0?0:s}function zf(t){const s=t.endsWith(`
|
|
48
|
-
`)?t.slice(0,-1):t,r=mk(s);let l=0,i=0;return s.split(`
|
|
49
|
-
`).map((c,d)=>{const u=r[d];if(u==="hunk"){const p=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(c);return l=p?Number(p[1]):l,i=p?Number(p[2]):i,{kind:u,text:c,old:null,new:null}}return u==="add"?{kind:u,text:c,old:null,new:i++}:u==="del"?{kind:u,text:c,old:l++,new:null}:u==="context"&&(l||i)?{kind:u,text:c,old:l++,new:i++}:{kind:u,text:c,old:null,new:null}})}function Wf({patch:t}){const s=zf(t),r=pk(s.map(l=>l.kind));return e.jsx(e.Fragment,{children:s.map((l,i)=>i<r?null:e.jsxs("span",{"data-i":i,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||" "]},i))})}function Hf(){const t=m.useRef(null),[s,r]=m.useState(!1);return m.useEffect(()=>{const l=t.current;if(!l)return;const i=()=>r(l.scrollLeft+l.clientWidth<l.scrollWidth-1);i(),l.addEventListener("scroll",i,{passive:!0});const c=new ResizeObserver(i);return c.observe(l),()=>{l.removeEventListener("scroll",i),c.disconnect()}},[]),[t,s]}function Gf({patch:t}){const[s,r]=Hf();return e.jsx("div",{className:"patch-scroll","data-more-right":r||void 0,children:e.jsx("pre",{ref:s,className:"pre mono diff-patch",children:e.jsx(Wf,{patch:t})})})}const Kf="the agent's log",fk=40,Vf=4e3,lp=t=>t.length===1||t[0]===t.at(-1)?`${t[0]}`:`${t[0]}-${t.at(-1)}`;function gk(t,s,r,l){const[i,c]=r<=l?[r,l]:[l,r],d=zf(s).slice(i,c+1).filter(j=>j.kind==="add"||j.kind==="del"||j.kind==="context"&&j.new!==null).slice(0,fk);let u=0;const p=d.filter(j=>(u+=j.text.length+1)<=Vf+1);if(!p.length)return null;const f=p.flatMap(j=>j.new===null?[]:[j.new]),g=p.flatMap(j=>j.old===null?[]:[j.old]);return{path:t,lines:f.length?lp(f):`${lp(g)} before the change`,text:p.map(j=>j.text).join(`
|
|
50
|
-
`)}}const xk="orchestrator.diff.hide-tests",jk={added:"added",modified:"changed",deleted:"deleted",renamed:"renamed"};function yk(t){return t.split("/").flatMap((s,r,l)=>r<l.length-1?[s,"/",e.jsx("wbr",{},r)]:[s])}function vk({path:t,patch:s,onQuote:r}){const[l,i]=Hf(),[c,d]=m.useState(null),u=f=>{var j,y;const g=(j=f instanceof Element?f:f==null?void 0:f.parentElement)==null?void 0:j.closest("[data-i]");return g&&((y=l.current)!=null&&y.contains(g))?Number(g.dataset.i):null},p=()=>{const f=window.getSelection(),g=f&&!f.isCollapsed?u(f.anchorNode):null,j=f&&!f.isCollapsed?u(f.focusNode):null;d(g===null||j===null?null:gk(t,s,g,j))};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"patch-scroll","data-more-right":i||void 0,children:e.jsx("pre",{ref:l,className:"pre mono diff-patch",onMouseUp:p,onKeyUp:p,children:e.jsx(Wf,{patch:s})})}),c?e.jsx("div",{className:"actions",children:e.jsxs("button",{type:"button",className:"secondary small",onClick:()=>{var f;r(c),d(null),(f=window.getSelection())==null||f.removeAllRanges()},children:["Quote lines ",c.lines," in a follow-up"]})}):null]})}const Yf={label:"Why",note:"Goes in the task's log"};function kk({file:t,read:s,onQuote:r,onDrop:l,onUndo:i,undone:c=!1,ownCopy:d=!1,opened:u=!1}){const[p,f]=m.useState(null),[g,j]=m.useState(null),y=N=>{N&&!p&&!g&&!t.binary&&s(t.path).then(f,w=>j(w.message))};m.useEffect(()=>y(u),[]);const k=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:yk(t.previousPath&&t.status==="renamed"?`${t.previousPath} → ${t.path}`:t.path)})," ",e.jsxs("span",{className:"muted small",children:[c?"undone":jk[t.status],t.binary?", binary":null]}),t.binary||c?null:e.jsxs(e.Fragment,{children:[" ",e.jsxs("span",{className:"diff-stat",children:[e.jsx(Uo,{added:t.additions??0,removed:t.deletions??0})," ",e.jsx(Yu,{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}):p?p.patch===null?null:r?e.jsx(vk,{path:t.path,patch:p.patch,onQuote:r}):e.jsx(Gf,{patch:p.patch}):e.jsx(fe,{what:"the patch"}),p!=null&&p.note?e.jsx("p",{className:"muted small",children:lr(p.note)}):null,i&&!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:Yf,onConfirm:N=>i(t.path,N)})}):null,l?e.jsx("div",{className:"actions",children:e.jsx(qe,{small:!0,...k,onConfirm:()=>l(t.path)})}):null]})})}const wk=10;function sl({reads:t,open:s=!1,bare:r=!1,onClosed:l,onQuote:i,onDrop:c,onUndo:d,undone:u=[],ownCopy:p=!1,onRead:f}){var E;const[g]=m.useState(()=>t),[j,y]=m.useState(null),[k,N]=m.useState(null),[w,b]=es(xk),$=(O,F=!1)=>{!O||j||k&&!F||(N(null),g.changes().then(L=>{y(L),f==null||f(!0)},L=>{N(L.message),f==null||f(!1)}))};m.useEffect(()=>$(s||r),[s,r]);const R=j?w==="yes"?j.files.filter(O=>!O.test):j.files:[],T=j?j.files.filter(O=>O.test).length:0,C=k?e.jsx(ve,{what:"the changes",reason:k,onRetry:()=>$(!0,!0)}):j?e.jsxs(e.Fragment,{children:[r?j.omitted?e.jsxs("p",{className:"muted small",children:[j.omitted," more not shown."]}):null:e.jsxs("p",{className:"muted small",children:[j.files.length," ",j.files.length===1?"file":"files",", +",j.files.reduce((O,F)=>O+(F.additions??0),0)," −",j.files.reduce((O,F)=>O+(F.deletions??0),0),j.omitted?`; ${j.omitted} more not shown`:""]}),T?e.jsxs("label",{className:"check small",children:[e.jsx("input",{type:"checkbox",checked:w==="yes",onChange:O=>b(O.target.checked?"yes":null)}),"Hide test files (",T,")"]}):null,e.jsx("ul",{className:"plain diff-files",children:R.map(O=>e.jsx(kk,{file:O,read:g.file,onQuote:i,...c?{onDrop:c}:{},...d?{onUndo:d}:{},undone:u.includes(O.path),ownCopy:p,opened:r&&R.length<=wk&&!u.includes(O.path)},O.path))}),(E=j.untracked)!=null&&E.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:j.untracked.map(O=>e.jsx("li",{className:"mono small",children:O.path},O.path))})]}):null]}):e.jsx(fe,{what:"the changes"});return r?e.jsx("div",{className:"request-diff",children:C}):e.jsxs("details",{className:"request-diff",open:s,onToggle:O=>{const F=O.currentTarget.open;$(F),F||l==null||l()},children:[e.jsx("summary",{children:"Changes"}),C]})}const bk={"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 Nk(t){return bk[t]??"neutral"}function Xr(t,s){return Ie(t)||t.ownedTeams.includes(s)}function Qu(t){var r;const s=(r=t.notes)!=null&&r.length?` ${t.notes.join(" ")}`:"";return`Request #${t.number} opened on ${t.branch}. It changes nothing until someone merges it.${s}`}function Tn({repoId:t,head:s,build:r,steps:l,children:i,submitLabel:c,onOpened:d,onCancel:u,onRefused:p}){const[f,g]=m.useState(null),[j,y]=m.useState(""),[k,N]=m.useState(null),[w,b]=m.useState(!1),$=m.useId(),R=k?{"aria-invalid":!0,"aria-describedby":$}:{},T=E=>{E.preventDefault(),N(null),b(!0),(l?l.proposal():Ne.proposal(t,r())).then(O=>{g(O.proposal),y(O.branch),b(!1)},O=>{N(O.message),b(!1),p==null||p()})},C=E=>{E.preventDefault(),N(null),b(!0),(l?l.send(f??"",j):Ne.propose(t,s,r(),f??"",j)).then(d,O=>{N(O.message),b(!1)})};return e.jsxs("form",{className:"form editor",onSubmit:f===null?T:C,children:[e.jsx("fieldset",{disabled:f!==null,className:"plain-fieldset",children:i==null?void 0:i(f===null?R:{})}),f!==null?e.jsxs(e.Fragment,{children:[r?e.jsx(Qv,{repoId:t,change:r()}):null,e.jsxs("label",{children:["Commit message",e.jsx("input",{value:f,onChange:E=>g(E.target.value),required:!0,...R})]}),e.jsxs("label",{children:["Branch",e.jsx("input",{value:j,onChange:E=>y(E.target.value),required:!0,spellCheck:!1,...R})]}),j.includes("<TICKET>")?e.jsx("p",{className:"muted",children:"This team's branches start with a ticket: put it in place of <TICKET>."}):null]}):null,k?e.jsx("p",{className:"error",role:"alert",id:$,children:k}):null,e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",disabled:w,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 Sk=`---
|
|
51
|
-
name:
|
|
52
|
-
description: Use when
|
|
53
|
-
---
|
|
54
|
-
|
|
55
|
-
`;function yu({repoId:t,head:s,slug:r,onOpened:l,onCancel:i}){const[c,d]=m.useState(r??""),[u,p]=m.useState(r?null:Sk),[f,g]=m.useState(null);return m.useEffect(()=>{r&&Ne.skill(t,r).then(j=>p(j.content),j=>g(j.message))},[t,r]),f?e.jsxs("div",{className:"editor",role:"alert",children:[e.jsxs("p",{className:"error",children:[r," did not load, so it cannot be edited now. ",f]}),e.jsx("button",{type:"button",className:"secondary",onClick:i,children:"Close"})]}):u===null?e.jsx("p",{className:"muted",children:"Loading the skill…"}):e.jsx(Tn,{repoId:t,head:s,submitLabel:r?"Review the edit":"Review the new skill",build:()=>({kind:r?"skill.edit":"skill.add",slug:c,content:u}),onOpened:l,onCancel:i,children:j=>e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:r?`Edit ${r}`:"Add a skill"}),r?null:e.jsxs("label",{children:["Skill name",e.jsx("input",{value:c,onChange:y=>d(y.target.value),placeholder:"on-call-handover",required:!0,...j})]}),e.jsxs("label",{children:["SKILL.md",e.jsx("textarea",{"aria-label":"SKILL.md",value:u,onChange:y=>p(y.target.value),spellCheck:!1,...j})]})]})})}const Ck=`---
|
|
56
|
-
description: What the command does, in one line.
|
|
57
|
-
---
|
|
58
|
-
|
|
59
|
-
The steps Claude follows when someone types the command.
|
|
60
|
-
`;function vu({repoId:t,head:s,name:r,onOpened:l,onCancel:i}){const[c,d]=m.useState(r??""),[u,p]=m.useState(r?null:Ck),[f,g]=m.useState(null);return m.useEffect(()=>{r&&Ne.command(t,r).then(j=>p(j.content),j=>g(j.message))},[t,r]),f?e.jsxs("div",{className:"editor",role:"alert",children:[e.jsxs("p",{className:"error",children:["/",r," did not load, so it cannot be edited here. ",f]}),e.jsx("button",{type:"button",className:"secondary",onClick:i,children:"Close"})]}):u===null?e.jsx("p",{className:"muted",children:"Loading the command…"}):e.jsx(Tn,{repoId:t,head:s,submitLabel:r?"Review the edit":"Review the new command",build:()=>({kind:r?"command.edit":"command.add",name:c,content:u}),onOpened:l,onCancel:i,children:j=>e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:r?`Edit /${r}`:"Add a slash command"}),r?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,...j})]}),e.jsxs("label",{children:["Command text",e.jsx("textarea",{"aria-label":"Command text",value:u,onChange:y=>p(y.target.value),spellCheck:!1,...j})]})]})})}function Qf({repoId:t,head:s,name:r,onOpened:l,onCancel:i}){return e.jsx(Tn,{repoId:t,head:s,submitLabel:`Review removing /${r}`,build:()=>({kind:"command.delete",name:r}),onOpened:l,onCancel:i,children:()=>e.jsxs(e.Fragment,{children:[e.jsxs("h3",{children:["Remove /",r]}),e.jsx("p",{className:"muted",children:"The request deletes its file under commands/. Teammates lose the command once the request is merged."})]})})}function Jf({repoId:t,head:s,slug:r,onOpened:l,onCancel:i}){return e.jsx(Tn,{repoId:t,head:s,submitLabel:`Review removing ${r}`,build:()=>({kind:"skill.delete",slug:r}),onOpened:l,onCancel:i,children:()=>e.jsxs(e.Fragment,{children:[e.jsxs("h3",{children:["Remove ",r]}),e.jsx("p",{className:"muted",children:"The request deletes every file the skill ships. Teammates lose it once the request is merged."}),e.jsx(qf,{repoId:t,kind:"skill",name:r})]})})}function op(t){const s=t.split(`
|
|
61
|
-
`).map(r=>r.trim()).filter(Boolean).map(r=>{const l=r.indexOf("=");return l<0?[r,""]:[r.slice(0,l).trim(),r.slice(l+1).trim()]});return s.length?Object.fromEntries(s):void 0}const $k=new Set(["command","args","env","type","url","headers"]),ip=t=>t&&typeof t=="object"?Object.entries(t).map(([s,r])=>`${s}=${String(r)}`).join(`
|
|
62
|
-
`):"";function Tk(t,s){const r=typeof s.command=="string";return{form:{name:t,transport:r?"stdio":String(s.type??"http"),command:r?String(s.command):"",args:Array.isArray(s.args)?s.args.map(String).join(`
|
|
63
|
-
`):"",url:typeof s.url=="string"?s.url:"",env:ip(s.env),headers:ip(s.headers)},kept:Object.fromEntries(Object.entries(s).filter(([l])=>!$k.has(l)))}}function ku({repoId:t,head:s,name:r,onOpened:l,onCancel:i}){const[c,d]=m.useState({name:r??"",transport:"stdio",command:"",args:"",url:"",env:"",headers:""}),[u,p]=m.useState({}),[f,g]=m.useState(!r),[j,y]=m.useState(null);m.useEffect(()=>{r&&Ne.mcpServer(t,r).then(b=>{const $=Tk(r,b.config);d($.form),p($.kept),g(!0)},b=>{y(b.message),g(!0)})},[t,r]);const k=b=>$=>d({...c,[b]:$.target.value}),N=()=>{const b=op(c.env),$=op(c.headers),R=c.args.split(`
|
|
64
|
-
`).map(C=>C.trim()).filter(Boolean),T=c.transport==="stdio"?{...u,command:c.command,...R.length?{args:R}:{},...b?{env:b}:{}}:{...u,type:c.transport,url:c.url,...$?{headers:$}:{}};return r?{kind:"mcp.edit",name:r,config:T}:{kind:"mcp.add",name:c.name,config:T}},w=()=>d(b=>({...b,args:"",url:"",env:"",headers:""}));return f?e.jsx(Tn,{repoId:t,head:s,submitLabel:"Review the server",build:N,onOpened:l,onCancel:i,onRefused:w,children:b=>e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:r?`Edit ${r}`:"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."]}),j?e.jsxs("p",{className:"muted",children:[r,": ",j,". 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,r?null:e.jsxs("label",{children:["Server name",e.jsx("input",{value:c.name,onChange:k("name"),required:!0,...b})]}),e.jsx(Pe,{label:"Transport",value:c.transport,onChange:$=>d({...c,transport:$}),describedBy:b["aria-describedby"],invalid:!!b["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:k("command"),required:!0,...b})]}),e.jsxs("label",{children:["Arguments, one per line",e.jsx("textarea",{className:"short",value:c.args,onChange:k("args"),...b})]}),e.jsxs("label",{children:["Environment, NAME=$","{","VAR","}"," per line",e.jsx("textarea",{className:"short","aria-label":"Environment",value:c.env,onChange:k("env"),...b})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:["URL",e.jsx("input",{value:c.url,onChange:k("url"),required:!0,...b})]}),e.jsxs("label",{children:["Headers, Name=$","{","VAR","}"," per line",e.jsx("textarea",{className:"short","aria-label":"Headers",value:c.headers,onChange:k("headers"),...b})]})]})]})}):e.jsx("p",{className:"muted",children:"Loading the server…"})}function Xf({repoId:t,head:s,name:r,onOpened:l,onCancel:i}){return e.jsx(Tn,{repoId:t,head:s,submitLabel:`Review removing ${r}`,build:()=>({kind:"mcp.remove",name:r}),onOpened:l,onCancel:i,children:()=>e.jsxs(e.Fragment,{children:[e.jsxs("h3",{children:["Remove ",r]}),e.jsxs("p",{className:"muted",children:["The request takes ",r," out of .mcp.json and keeps every other entry. Teammates' Claude Code stops starting it once the request is merged."]}),e.jsx(qf,{repoId:t,kind:"mcp",name:r})]})})}const cp={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 Ek({repoId:t,head:s,action:r="ask",onOpened:l,onCancel:i}){return e.jsx(Tn,{repoId:t,head:s,steps:{proposal:()=>Ne.usageProposal(t,r),send:(c,d)=>Ne.proposeUsage(t,s,c,d,r)},submitLabel:"Review the request",onOpened:l,onCancel:i,children:()=>e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:cp[r].title}),e.jsx("p",{className:"muted",children:cp[r].text})]})})}const up=t=>t.split(",").map(s=>s.trim()).filter(Boolean);function Rk({repoId:t,head:s,team:r,onOpened:l,onCancel:i}){const[c,d]=m.useState(((r==null?void 0:r.reviewers)??[]).join(", ")),[u,p]=m.useState(((r==null?void 0:r.labels)??[]).join(", "));return e.jsx(Tn,{repoId:t,head:s,submitLabel:"Review the change",build:()=>({kind:"team.settings",reviewers:up(c),labels:up(u)}),onOpened:l,onCancel:i,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=>p(g.target.value),...f})]})]})})}function Pk({repoId:t,head:s,team:r,onOpened:l,onCancel:i}){const[c,d]=m.useState((r==null?void 0:r.commitPrefix)??""),[u,p]=m.useState((r==null?void 0:r.branchExample)??"");return e.jsx(Tn,{repoId:t,head:s,submitLabel:"Review the change",build:()=>({kind:"team.naming",commitPrefix:c,branchExample:u}),onOpened:l,onCancel:i,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=>p(g.target.value),...f})]})]})})}function Ak({request:t,repo:s,me:r,onChanged:l}){const[i,c]=m.useState(null);if(!s||!Xr(r,s.team))return null;const d=p=>{c(null),Ne.requestAction(s.id,t.number,p).then(l,f=>c(f.message))},u=i?Wa(i):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,i?e.jsx("p",{className:"error",role:"alert",children:u?e.jsxs(e.Fragment,{children:[u.said,": ",e.jsx(yt,{text:u.command})]}):i}):null]})}function Ik({request:t}){const[s,r]=m.useState(null),l=t.provider==="local"?void 0:c=>ir(`/api/repos/${encodeURIComponent(t.repoId)}/media?${new URLSearchParams({request:String(t.number),src:c})}`),i=c=>{!c||s!==null||Ne.requestDescription(t.repoId,t.number).then(d=>r(d.description??"This request's description is where the request is; open it there."),d=>r(d.message))};return e.jsxs("details",{onToggle:c=>i(c.currentTarget.open),children:[e.jsx("summary",{children:"Description"}),s===null?e.jsx(fe,{what:"the description"}):e.jsx(Jr,{text:s,...l?{media:l}:{}})]})}function Ok({requests:t,repos:s,me:r,showRepo:l,onChanged:i}){if(!t.length){const c=l?s.find(d=>d.configured!==!1&&Xr(r,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:ce("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(Ik,{request:c}),e.jsx(sl,{reads:Do(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 ${Nk(c.status)}`,children:c.status==="open"?"awaiting review":c.status}),e.jsx(Vu,{request:c})]}),e.jsx("td",{className:"rc-meta",children:c.createdBy}),e.jsx("td",{className:"rc-wide",children:e.jsx(Ak,{request:c,repo:s.find(d=>d.id===c.repoId),me:r,onChanged:i})})]},`${c.repoId}-${c.number}`))})]})}const dp=[{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 Lk({repoId:t,repos:s,me:r,showRepo:l,version:i=0,onCounts:c,onChanged:d}){const[u,p]=m.useState(""),[f,g]=m.useState([]),[j,y]=m.useState(null),[k,N]=m.useState(null),[w,b]=m.useState(0);m.useEffect(()=>{let T=!0;return N(null),Ne.requests({repoId:t,status:u||null,after:f.at(-1)??null}).then(C=>{if(T){if(!C.requests.length&&f.length)return g(f.slice(0,-1));y(C),c==null||c(C)}},C=>T&&N(C.message)),()=>{T=!1}},[t,u,f,i,w]);const $=()=>b(T=>T+1),R=dp.find(T=>T.value===u);return e.jsxs("div",{className:"request-list",children:[u||j!=null&&j.total?e.jsx("div",{className:"filter",children:e.jsx(Pe,{label:"Show",value:u,onChange:T=>{p(T),g([])},options:dp.map(T=>({value:T.value,label:T.label}))})}):null,k?e.jsx(ve,{what:"requests",reason:k,onRetry:$}):j?u&&!j.requests.length?e.jsx("p",{className:"muted",children:R.none}):e.jsxs(e.Fragment,{children:[e.jsx(Ok,{requests:j.requests,repos:s,me:r,showRepo:l,onChanged:d??$}),e.jsx(Lo,{page:f.length+1,total:j.total,pageSize:j.pageSize,more:j.next!==null,onPage:T=>g(T>f.length+1?[...f,j.next]:f.slice(0,-1)),label:"Pages of requests"})]}):e.jsx(fe,{what:"requests"})]})}function Fk({repo:t,suggest:s}){const[r,l]=m.useState(null),[i,c]=m.useState({kind:"gitlab",apiUrl:"https://gitlab.com/api/v4",project:"",token:"",...s}),[d,u]=m.useState(null),[p,f]=m.useState(null),g=m.useId(),j=p?{"aria-invalid":!0,"aria-describedby":g}:{},y=()=>Ne.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(m.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(!r)return p?e.jsx(ve,{what:"the forge access",reason:p,onRetry:()=>{f(null),y()}}):e.jsx(fe,{what:"the forge access"});const k=N=>{N.preventDefault(),u(null),f(null),Ne.saveForge(t.id,{kind:i.kind,apiUrl:i.apiUrl,project:i.project,...i.token?{token:i.token}:{}}).then(()=>{c({...i,token:""}),u("Saved. The token is sealed; the orchestrator never shows it again."),y()},w=>{c({...i,token:""}),f(w.message)})};return e.jsxs("form",{className:"form inline-form",onSubmit:k,"aria-label":"Forge access",children:[e.jsx(Pe,{label:"Forge",value:i.kind,onChange:N=>c({...i,kind:N,apiUrl:et[N].apiUrlFor(new URL(`https://${et[N].homeHosts[0]}`))}),describedBy:j["aria-describedby"],invalid:!!j["aria-invalid"],options:uf.filter(N=>{var w;return N!=="gitea"||i.kind==="gitea"||((w=r.forges)==null?void 0:w.includes(N))}).map(N=>({value:N,label:et[N].label}))}),e.jsxs("label",{children:["API address",e.jsx("input",{value:i.apiUrl,onChange:N=>c({...i,apiUrl:N.target.value}),required:!0,...j})]}),e.jsxs("label",{children:["Project",e.jsx("input",{value:i.project,onChange:N=>c({...i,project:N.target.value}),placeholder:et[i.kind].projectShape,required:!0,...j})]}),e.jsxs("label",{children:["Token",e.jsx("input",{type:"password",autoComplete:"off",value:i.token,onChange:N=>c({...i,token:N.target.value}),...j,placeholder:r.token.set?`set${r.token.updatedAt?` ${r.token.updatedAt.slice(0,10)}`:""}; empty keeps it while forge, address and project stay`:"a project access token"})]}),e.jsx("button",{type:"submit",disabled:!r.vault,children:"Save"}),r.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."}),p?e.jsx("p",{className:"error",role:"alert",id:g,children:p}):null,d?e.jsx("p",{role:"status",children:d}):null]})}const Dc={own:t=>B("GET",`/api/handbook/own?repo=${encodeURIComponent(t)}`),proposal:(t,s)=>B("POST",`/api/repos/${encodeURIComponent(t)}/handbook/proposal`,s),propose:(t,s,r,l,i)=>B("POST",`/api/repos/${encodeURIComponent(t)}/handbook`,{...s,message:r,branch:l,baseSha:i}).then(c=>c.request)},Ga=[{id:"skills",label:"Skills"},{id:"mcp",label:"MCP servers"},{id:"commands",label:"Commands"}],Uc=(t,s,r)=>`${t} ${t===1?s:r}`,Mk={skills:"skills",mcp:"mcpServers",commands:"commands"},qc=(t,s)=>`${t}/${s}`;function _k(t){return[Uc(t.skills.length,"skill","skills"),Uc(t.mcpServers.length,"MCP server","MCP servers"),Uc(t.commands.length,"command","commands")].filter((s,r)=>[t.skills,t.mcpServers,t.commands][r].length).join(" and ")}function Dk({repoId:t,head:s,onProposed:r,onCancel:l}){const[i,c]=m.useState(null),[d,u]=m.useState(null),[p,f]=m.useState("skills"),[g,j]=m.useState(new Set),[y,k]=m.useState(null),[N,w]=m.useState(null),[b,$]=m.useState(!1),R=()=>{u(null),Dc.own(t).then(c,A=>u(A.message))};if(m.useEffect(R,[t]),d)return e.jsx(ve,{what:"your Claude Code",reason:d,onRetry:R});if(!i)return e.jsx(fe,{what:"your Claude Code"});if(!i.available)return e.jsxs("div",{role:"status",children:[e.jsx("p",{className:"muted",children:i.why}),e.jsx("p",{children:e.jsx("button",{type:"button",className:"secondary",onClick:l,children:"Close"})})]});const T=A=>A==="skills"?i.skills:A==="mcp"?i.mcpServers:i.commands,C={skills:[],mcpServers:[],commands:[]};for(const A of Ga)for(const M of T(A.id))g.has(qc(A.id,M.name))&&C[Mk[A.id]].push(M.name);const E=C.skills.length+C.mcpServers.length+C.commands.length,O=A=>{const M=new Set(g);M.delete(A)||M.add(A),j(M)},F=()=>{w(null),$(!0),Dc.proposal(t,C).then(A=>{k({message:A.proposal,branch:A.branch}),$(!1)},A=>{w(A.message),$(!1)})},L=A=>{A.preventDefault(),y&&(w(null),$(!0),Dc.propose(t,C,y.message,y.branch,s).then(M=>r(C,M),M=>{w(M.message),$(!1)}))};if(y)return e.jsxs("form",{className:"form editor",onSubmit:L,children:[e.jsxs("p",{children:[_k(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:A=>k({...y,message:A.target.value}),required:!0})]}),e.jsxs("label",{children:["Branch",e.jsx("input",{value:y.branch,onChange:A=>k({...y,branch:A.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:b,children:"Open request"}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>k(null),children:"Back"}),e.jsx("button",{type:"button",className:"secondary",onClick:l,children:"Cancel"})]})]});const W=T(p);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"segmented",role:"tablist","aria-label":"Your Claude Code",children:Ga.map(A=>e.jsx("button",{type:"button",role:"tab",className:"secondary","aria-selected":p===A.id,onClick:()=>f(A.id),children:A.label},A.id))}),W.length?e.jsx("ul",{className:"team-rows","aria-label":`Your ${Ga.find(A=>A.id===p).label}`,children:W.map(A=>e.jsxs("li",{children:[e.jsxs("label",{className:"team-pick",children:[e.jsx("input",{type:"checkbox",checked:g.has(qc(p,A.name)),disabled:!A.addable,onChange:()=>O(qc(p,A.name))}),e.jsx("span",{className:"mono",children:A.name})]}),A.description?e.jsxs("span",{className:"muted",children:[" ",A.description]}):null,e.jsxs("span",{className:"muted",children:[" ",A.addable?A.inTeam?"in the team; ticking updates it from yours":"from your Claude Code":A.why??"cannot be shared"]})]},A.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:!E||b,onClick:F,children:E?`Propose ${E} to the team`:"Tick what to propose"}),e.jsx("button",{type:"button",className:"secondary",onClick:l,children:"Cancel"})]})]})}const rr=(t,s,r)=>`${t}/${s}/${r}`,Uk=t=>t==null?"":t?`, ${t} ${t===1?"task":"tasks"} this month`:", no task this month";function qk(t,s,r){return s==="skills"?t.skills.map(l=>{var i;return{name:l.slug,sentence:l.description,tasks:(i=r.skills.find(c=>c.name===l.slug||c.name===l.name))==null?void 0:i.tasks}}):s==="mcp"?t.mcpServers.map(l=>{var i;return{name:l.name,sentence:`${l.transport} server, ${l.target}`,tasks:(i=r.mcpServers.find(c=>c.name===l.name))==null?void 0:i.tasks}}):t.commands.map(l=>({name:l.name,sentence:l.description,tasks:void 0}))}function Bk({me:t,repos:s,counts:r,picked:l,proposed:i,onPick:c,onProposed:d}){const u=s.filter(X=>X.kind==="skills"&&X.configured!==!1),[p,f]=m.useState(null),[g,j]=m.useState("skills"),[y,k]=m.useState(null),[N,w]=m.useState(null),[b,$]=m.useState(null),[R,T]=m.useState(!1),C=u.find(X=>X.id===p)??u[0],E=X=>{$(null),Ne.inventory(X).then(J=>{k(J.inventory),w(J.join)},J=>$(J.message))};m.useEffect(()=>{k(null),T(!1),C&&E(C.id)},[C==null?void 0:C.id]);const O=t.mode==="local"?"handbook repository":"team repository",F=`Nothing is shared yet. A skill, MCP server or command added to the ${O} lands here once it is merged.`;if(!C)return e.jsx($n,{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:F});if(b)return e.jsx(ve,{what:"the team handbook",reason:b,onRetry:()=>E(C.id)});if(!y)return e.jsx(fe,{what:"the team handbook"});const L=y.skills.length+y.mcpServers.length+y.commands.length,W=Xr(t,C.team),A=qk(y,g,r),M=rr(C.id,g,""),Q=[...i.keys()].filter(X=>X.startsWith(M)&&!A.some(J=>J.name===X.slice(M.length))).map(X=>({name:X.slice(M.length),sentence:"",tasks:void 0})),H=[...A,...Q],U=Ga.find(X=>X.id===g).label,ie=H.length?e.jsx("ul",{className:"team-rows","aria-label":U,children:H.map(X=>{const J=i.get(rr(C.id,g,X.name)),Z=(l==null?void 0:l.repo.id)===C.id&&l.tab===g&&l.name===X.name;return e.jsxs("li",{className:Z?"picked":void 0,children:[e.jsx("button",{type:"button",className:"row-pick","aria-pressed":Z,onClick:()=>c({repo:C,head:y.head,tab:g,name:X.name,sentence:X.sentence,editable:W}),children:e.jsx("span",{className:"mono",children:X.name})}),X.sentence?e.jsxs("span",{className:"muted",children:[" ",X.sentence]}):null,e.jsxs("span",{className:"muted",children:[" from ",e.jsx("span",{className:"mono",children:C.name}),Uk(X.tasks)]}),J?e.jsxs("span",{className:"muted",children:[" ",J.url&&/^https?:\/\//.test(J.url)?e.jsxs("a",{href:J.url,children:["Proposed in !",J.number]}):e.jsxs(e.Fragment,{children:["Proposed in !",J.number]}),", lands once merged"]}):null]},X.name)})}):e.jsxs("p",{className:"muted",children:[U," is empty in the ",O,"."]});return e.jsxs($n,{name:"Team handbook",count:L,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:F,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(X=>({value:X.id,label:X.name}))})}):null,R?e.jsx(Dk,{repoId:C.id,head:y.head,onCancel:()=>T(!1),onProposed:(X,J)=>{T(!1),d(C.id,X,J)}}):e.jsxs(e.Fragment,{children:[W?e.jsx("p",{children:e.jsx("button",{type:"button",className:"secondary",onClick:()=>T(!0),children:"Add from your Claude Code"})}):null,e.jsx("div",{className:"segmented",role:"tablist","aria-label":"Team handbook",children:Ga.map(X=>e.jsx("button",{type:"button",role:"tab",className:"secondary","aria-selected":g===X.id,onClick:()=>j(X.id),children:X.label},X.id))}),ie,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(X=>e.jsx(yt,{text:X},X))]}):null]})]})}function zk({pick:t,onOpened:s}){const{repo:r,head:l,tab:i,name:c}=t,[d,u]=m.useState(null),[p,f]=m.useState(null),[g,j]=m.useState(null);m.useEffect(()=>{u(null),f(null),j(null),i!=="mcp"&&(i==="skills"?Ne.skill(r.id,c):Ne.command(r.id,c)).then(k=>u(k.content),k=>f(k.message))},[r.id,i,c]);const y={repoId:r.id,head:l,onOpened:s,onCancel:()=>j(null)};return e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"mono",children:c}),i==="mcp"?e.jsxs("p",{className:"muted",children:[t.sentence,". Its values stay sealed; the repository holds only the names it needs."]}):p?e.jsx("p",{className:"error",role:"alert",children:p}):d===null?e.jsxs("p",{className:"muted",children:["Reading ",c,"…"]}):e.jsx("pre",{className:"handbook-text",children:d}),t.editable&&!g?e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",className:"secondary",onClick:()=>j("update"),children:"Update…"}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>j("remove"),children:"Remove…"})]}):null,g==="update"&&i==="skills"?e.jsx(yu,{...y,slug:c},`u-${c}`):null,g==="update"&&i==="commands"?e.jsx(vu,{...y,name:c},`u-${c}`):null,g==="update"&&i==="mcp"?e.jsx(ku,{...y,name:c},`u-${c}`):null,g==="remove"&&i==="skills"?e.jsx(Jf,{...y,slug:c},`r-${c}`):null,g==="remove"&&i==="commands"?e.jsx(Qf,{...y,name:c},`r-${c}`):null,g==="remove"&&i==="mcp"?e.jsx(Xf,{...y,name:c},`r-${c}`):null]})}const Wk="handbook",Hk="teamhandbook",Gk=1500,Kk=8;function Zf(t){const[s,r]=m.useState(null);return m.useEffect(()=>{if(!t)return;let l=!0,i;const c=d=>{$e.options().then(u=>{var f;if(!l)return;const p=((f=u.agents.find(g=>g.id==="claude-code"))==null?void 0:f.personal)??null;p?r(p):d>1&&(i=setTimeout(()=>c(d-1),Gk))},()=>{})};return c(Kk),()=>{l=!1,clearTimeout(i)}},[t]),s}const Vk="orchestrator.handbook-plugin.dismissed";function eg({me:t,quiet:s=!1}){const[r,l]=m.useState({at:"offer"}),[i,c]=es(Vk),d=t.mode==="local"&&Ie(t),u=Zf(d),p=!!u&&!u.plugins.some(g=>g.name===Wk&&g.marketplace===Hk);if(!d||!p&&r.at!=="done"||i&&r.at==="offer")return null;const f=()=>{l({at:"busy"}),B("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:"plugin-card",role:"status",children:r.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."})," It turns what your sessions teach into skills you keep or share."]}),r.at==="asking"||r.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,r.at==="failed"?e.jsx("p",{className:"error",role:"alert",children:r.why}):null,e.jsxs("div",{className:"actions",children:[r.at==="offer"||r.at==="failed"?e.jsx("button",{type:"button",className:s?"secondary":void 0,onClick:()=>l({at:"asking"}),children:"Install the plugin…"}):null,r.at==="asking"||r.at==="busy"?e.jsx("button",{type:"button",disabled:r.at==="busy",onClick:f,children:r.at==="busy"?"Installing…":"Install"}):null,e.jsx("button",{type:"button",className:"secondary",disabled:r.at==="busy",onClick:()=>r.at==="offer"?c("yes"):l({at:"offer"}),children:r.at==="offer"?"Not now":"Cancel"})]})]})})}const Bc=(t,s,r="")=>`/api/tasks/${encodeURIComponent(t)}/lessons/${encodeURIComponent(s)}${r}`,_s={ofTask:t=>B("GET",`/api/tasks/${encodeURIComponent(t)}/lessons`),read:(t,s)=>B("GET",Bc(t,s)).then(r=>r.lesson),keep:(t,s)=>B("POST",Bc(t,s,"/keep")),reject:(t,s,r)=>B("POST",Bc(t,s,"/reject"),{never:r}),outcomes:t=>B("GET",`/api/skills/${encodeURIComponent(t)}/outcomes?days=30`)},sr=(t,s)=>`${t} ${s}${t===1?"":"s"}`;function Yk({skills:t,candidates:s}){var g,j;const r=[t.team.length?sr(t.team.length,"team skill"):"",t.project.length?sr(t.project.length,"project skill"):""].filter(Boolean),l=s??[],i=l.filter(y=>y.status==="pending").length,c=l.filter(y=>y.status==="approved").length,d=l.filter(y=>y.status==="sent"),u=[...new Set(d.map(y=>y.machine).filter(y=>!!y))],p=[r.length?`Started with ${r.join(" and ")}${(g=t.used)!=null&&g.length?`, the agent called ${t.used.length}`:""}`:(j=t.used)!=null&&j.length?`The agent called ${sr(t.used.length,"skill")}`:"",i?`${sr(i,"lesson")} ${i===1?"waits":"wait"} for your review`:"",c?`${sr(c,"lesson")} kept as your skill${c===1?"":"s"}`:"",d.length?`${sr(d.length,"lesson")} ${d.length===1?"waits":"wait"} in your review queue${u.length===1?` on ${u[0]}`:""}`:""].filter(Boolean);if(!p.length)return null;const f=p.join("; ");return`${f[0].toUpperCase()}${f.slice(1)}.`}const Qk=2e4,Jk=5*6e4,tg=t=>t.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n/,""),Mr=(t,s)=>`${t} of ${s}`;function Xk(t){if(!t.pivot)return null;if(t.with.tasks<t.minimum)return{phrase:`${sr(t.with.tasks,"task")} decided since, compared from ${t.minimum}`,facts:[]};const s=t.before.tasks>=t.minimum,r=(l,i)=>s?`${l}; before, ${i}`:l;return{phrase:`kept without a follow-up in ${Mr(t.with.acceptedWithoutRevision,t.with.tasks)} tasks since${s?`, ${Mr(t.before.acceptedWithoutRevision,t.before.tasks)} before`:""}`,facts:[{term:"Kept without a follow-up",value:r(Mr(t.with.acceptedWithoutRevision,t.with.tasks),Mr(t.before.acceptedWithoutRevision,t.before.tasks))},{term:"Follow-ups, median",value:r(String(t.with.revisionRoundsMedian??0),String(t.before.revisionRoundsMedian??0))},{term:"Undone or closed",value:r(Mr(t.with.rejected,t.with.tasks),Mr(t.before.rejected,t.before.tasks))}]}}function Zk({task:t,finishedAt:s}){const[r,l]=m.useState(null),[i,c]=m.useState(0);m.useEffect(()=>{let g=!0;return _s.ofTask(t).then(j=>g&&l(j),()=>g&&l(null)),()=>{g=!1}},[t,i]);const u=!!s&&Date.now()-Date.parse(s)<Jk&&!!(r!=null&&r.candidates)&&r.candidates.length===0;m.useEffect(()=>{if(!u)return;const g=setTimeout(()=>c(j=>j+1),Qk);return()=>clearTimeout(g)},[u,i]);const p=r?Yk(r):null;if(!r||!p)return null;const f=(r.candidates??[]).filter(g=>g.status==="pending"||g.status==="sent"||g.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:p}),f.length?e.jsx("ul",{className:"plain",children:f.map(g=>e.jsx("li",{children:g.status==="approved"?e.jsx(ew,{slug:g.slug}):e.jsx(tw,{task:t,lesson:g,onDecided:()=>c(j=>j+1)})},g.slug))}):null]})}function ew({slug:t}){const[s,r]=m.useState(null);m.useEffect(()=>{let i=!0;return _s.outcomes(t).then(c=>i&&r(Xk(c)),()=>i&&r(null)),()=>{i=!1}},[t]);const l=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mono",children:t})," kept as your skill",s?`; ${s.phrase}`:""]});return s!=null&&s.facts.length?e.jsxs("details",{children:[e.jsx("summary",{children:l}),e.jsx("dl",{children:s.facts.map(i=>e.jsxs(m.Fragment,{children:[e.jsx("dt",{children:i.term}),e.jsx("dd",{children:i.value})]},i.term))})]}):l}function tw({task:t,lesson:s,onDecided:r}){const[l,i]=m.useState(null),[c,d]=m.useState(null),[u,p]=m.useState(!1),[f,g]=m.useState(!1),j=()=>{l||(d(null),_s.read(t,s.slug).then(i,k=>d(k.message)))},y=k=>{g(!0),d(null),k.then(r,N=>d(N.message)).finally(()=>g(!1))};return e.jsxs("details",{onToggle:k=>k.currentTarget.open?j():void 0,children:[e.jsx("summary",{dir:"auto",children:s.description??e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mono",children:s.slug}),s.machine?`, on ${s.machine}`:""]})}),l?e.jsxs(e.Fragment,{children:[l.quote?e.jsxs("p",{dir:"auto",children:["You said: “",l.quote,"”"]}):null,e.jsx(Jr,{text:tg(l.skillMd)}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",className:"small",disabled:f,onClick:()=>y(_s.keep(t,s.slug)),children:"Keep"}),e.jsx("button",{type:"button",className:"secondary small",disabled:f,onClick:()=>y(_s.reject(t,s.slug,u)),children:"Reject"}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:u,onChange:k=>p(k.target.checked)}),"Never suggest it again"]})]})]}):c?null:e.jsx("p",{className:"muted small",children:"Loading the lesson…"}),c?e.jsx("p",{className:"error",role:"alert",children:c}):null]})}function zr({label:t,values:s,onChange:r,choices:l=[],free:i=!0,placeholder:c,show:d=u=>{var p;return((p=l.find(f=>f.id===u))==null?void 0:p.label)??u}}){const u=m.useId(),[p,f]=m.useState(""),[g,j]=m.useState(null),y=()=>{const k=p.trim();if(!k)return;const N=l.find(b=>b.id===k||b.label.toLowerCase()===k.toLowerCase());if(!N&&!i){j(`${k} is not one of the choices.`);return}const w=(N==null?void 0:N.id)??k;s.includes(w)||r([...s,w]),f(""),j(null)};return e.jsxs("div",{className:"chip-field",children:[e.jsx("label",{htmlFor:`${u}-in`,children:t}),s.length?e.jsx("ul",{className:"chips","aria-label":t,children:s.map(k=>e.jsxs("li",{className:"chip",children:[e.jsx("span",{children:d(k)}),e.jsx("button",{type:"button",className:"chip-remove","aria-label":`Remove ${d(k)}`,onClick:()=>r(s.filter(N=>N!==k)),children:"×"})]},k))}):null,e.jsxs("div",{className:"chip-add",children:[e.jsx("input",{id:`${u}-in`,value:p,list:l.length?`${u}-list`:void 0,placeholder:c,"aria-describedby":g?`${u}-problem`:void 0,onChange:k=>f(k.target.value),onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),y())}}),e.jsx("button",{type:"button",className:"secondary small",onClick:y,disabled:!p.trim(),children:"Add"})]}),l.length?e.jsx("datalist",{id:`${u}-list`,children:l.filter(k=>!s.includes(k.id)).map(k=>e.jsx("option",{value:k.id,children:k.label},k.id))}):null,g?e.jsx("p",{id:`${u}-problem`,className:"error",children:g}):null]})}function nw(t,s){var l,i;const r=[];for(const c of s.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(p=>p.slug===u.slug))!=null&&l.removedBy)&&r.push({what:`The skill ${u.slug} in ${c.name}`,reason:u.removedBy.reason});for(const u of c.mcpServers){const p=d==null?void 0:d.mcpServers.find(f=>f.name===u.name);u.removedBy&&!(p!=null&&p.removedBy)&&r.push({what:`The MCP server ${u.name} in ${c.name}`,reason:u.removedBy.reason});for(const f of u.tools)p!=null&&p.tools.some(g=>g.resource===f.resource)||r.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(p=>p.resource===u.resource)||r.push({what:`${u.resource.replace(/^tool:/,"")} in ${c.name}`,reason:u.reason})}for(const c of s.tasks)c.refusal&&!((i=t.tasks.find(d=>d.repoId===c.repoId))!=null&&i.refusal)&&r.push({what:`Starting a task on ${c.name}`,reason:c.refusal});return r}function go({reason:t}){return e.jsxs("span",{className:"held",children:[" Blocked: ",t]})}function sw({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:ce("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(s=>e.jsxs("li",{children:[e.jsx("span",{className:"mono",children:s.slug}),s.removedBy?e.jsx(go,{reason:s.removedBy.reason}):null]},s.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(s=>e.jsxs("li",{children:[e.jsx("span",{className:"mono",children:s.name}),s.removedBy?e.jsx(go,{reason:s.removedBy.reason}):null,s.tools.length?e.jsx("ul",{className:"plain nested",children:s.tools.map(r=>e.jsxs("li",{children:["tool ",e.jsx("span",{className:"mono",children:r.tool}),e.jsx(go,{reason:r.reason})]},r.resource))}):null]},s.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(s=>`/${s}`).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(s=>e.jsxs("li",{children:[e.jsx("span",{className:"mono",children:s.resource.replace(/^tool:/,"")}),e.jsx(go,{reason:s.reason})]},s.resource))})]}):null]})}function rw({id:t}){const[s,r]=m.useState(null),[l,i]=m.useState(null),[c,d]=m.useState(0);m.useEffect(()=>{let p=!0;return r(null),i(null),Of.get(t).then(f=>p&&r(f),f=>p&&i(f.message)),()=>{p=!1}},[t,c]);const u=(s==null?void 0:s.tasks.filter(p=>p.refusal))??[];return e.jsxs("section",{className:"panel member-config","aria-labelledby":"member-config-h","aria-busy":!s&&!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(p=>p+1),children:"Retry"})]}):null,!s&&!l?e.jsx("p",{className:"muted",children:"Reading their teams' repositories…"}):null,s?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"muted",children:s.teams.length?`Through ${s.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."}),s.repos.map(p=>e.jsx(sw,{repo:p},p.repoId)),e.jsx("h3",{children:"Starting tasks"}),u.length?e.jsx("ul",{className:"plain",children:u.map(p=>e.jsxs("li",{children:[e.jsx("strong",{children:p.name}),": ",p.refusal]},p.repoId))}):e.jsx("p",{className:"muted",children:"No orchestrator rule keeps them from starting a task."})]}):null]})}function aw({members:t,audience:s,rules:r,ready:l}){var j;m.useId();const[i,c]=m.useState(""),[d,u]=m.useState(null),p=l&&i?JSON.stringify({member:i,audience:s,rules:r}):null;if(m.useEffect(()=>{if(!p)return;let y=!0;const k=setTimeout(()=>{Of.preview(i,s,r).then(N=>y&&u({key:p,effects:nw(N.before,N.after),error:null}),N=>y&&u({key:p,effects:null,error:N.message}))},350);return()=>{y=!1,clearTimeout(k)}},[p]),!t.length)return null;const f=((j=t.find(y=>y.id===i))==null?void 0:j.label)??"",g=d&&d.key===p?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:i,onChange:c,options:[{value:"",label:"Choose a member"},...t.map(y=>({value:y.id,label:y.label}))]}),i?e.jsx("button",{type:"button",className:"secondary small",onClick:()=>c(""),children:"Close member preview"}):null]}),i?null:e.jsx("p",{className:"muted small-print",children:"Choose members to preview this policy."}),i&&!l?e.jsxs("p",{className:"muted small-print",children:["Complete this policy to preview it for ",f,"."]}):null,i&&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 hp=12;function ng(t,s,r){return`${t.toLocaleString("en-US")} ${t===1?s:r}`}function mp({title:t,people:s}){if(!s.length)return null;const r=s.length-hp;return e.jsxs("div",{children:[e.jsx("p",{className:"field-label",children:t}),e.jsx("ul",{className:"chips",children:s.slice(0,hp).map(l=>e.jsx("li",{className:"chip chip-plain",children:l.name},l.id))}),r>0?e.jsxs("p",{className:"muted small-print",children:["and ",ng(r,"more","more")]}):null]})}function lw({draft:t,repoName:s,members:r,exportable:l}){const i=Mf(t),c=i?null:JSON.stringify({audience:t.audience,rules:t.rules}),[d,u]=m.useState(null),[p,f]=m.useState(0);m.useEffect(()=>{if(!c)return;let y=!0;const k=setTimeout(()=>{Qt.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(k)}},[c,p]);const g=fn(t),j=d&&d.key===c?d:null;return e.jsxs("section",{className:"panel preview","aria-labelledby":"preview-h","aria-busy":c!==null&&!j,children:[e.jsxs("h2",{id:"preview-h",children:["Preview ",e.jsx("span",{className:"count",children:"who this covers and what they ran"})]}),i?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."}):j!=null&&j.error?e.jsxs("div",{role:"alert",children:[e.jsxs("p",{className:"error",children:["Couldn't preview this policy. ",j.error]}),e.jsx("button",{type:"button",className:"secondary small",onClick:()=>{u(null),f(y=>y+1)},children:"Retry the preview"})]}):j!=null&&j.preview?e.jsx(iw,{preview:j.preview,request:g,repoName:s,exportable:l}):e.jsx("p",{className:"muted",children:"Working out who this covers…"}),e.jsx(aw,{members:r,audience:t.audience,rules:t.rules,ready:!i})]})}const sg="Where an organization allows only managed hooks, policies reach teammates through the managed-settings export.";function ow({exportable:t,repos:s=[]}){return t?e.jsxs("p",{className:"muted small-print managed-hooks",children:[(s.length?s:[null]).map((r,l)=>e.jsxs("span",{children:[l?", ":"",e.jsx("a",{href:`/api/policies/export?${r?`repo=${encodeURIComponent(r.id)}&`:""}download=1`,download:!0,children:r?`Export the saved policies for ${r.name}`:"Export the saved policies"})]},(r==null?void 0:r.id)??"workspace"))," ",e.jsx(Ee,{label:"the managed-settings export",children:sg})]}):null}function iw({preview:t,request:s,repoName:r,exportable:l}){const i=t.members.filter(g=>!Zm(g.id)),c=t.members.filter(g=>Zm(g.id)),{tasks:d,usd:u,unknownCost:p}=t.usage30d,f=t.repos.map(r);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:i.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})}`]})]})]}),p?e.jsxs("p",{className:"muted small-print",children:[ng(p,"task","tasks")," reported no cost and ",p===1?"is":"are"," not in the total."]}):null,t.members.length?null:e.jsx("p",{className:"muted",children:"Nobody is covered yet."}),e.jsx(mp,{title:"Members",people:i}),e.jsx(mp,{title:"Service accounts",people:c}),t.teams.length?e.jsxs("p",{children:[e.jsx("span",{className:"field-label",children:"Teams"}),e.jsx("br",{}),pn(t.teams)]}):null,s?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 ${pn(f)}.`:"No covered team has a connected repository."}),e.jsx(ow,{exportable:l,repos:t.repos.map(g=>({id:g,name:r(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 ${pn(f)}, from the moment you save.`:"Holds the tasks this orchestrator starts, from the moment you save. Nothing changes on teammates' machines."})]})]})}const cw={"skill-access":"skill:","mcp-access":"mcp:","tool-access":"tool:"};function uw({rule:t,onChange:s}){const r=m.useId(),[l,i]=m.useState(np[0]),[c,d]=m.useState(""),u=()=>{const p=Gu("tool-access",`${l}:${c.trim()||"*"}`);t.resources.includes(p)||s({...t,resources:[...t.resources,p]}),d("")};return e.jsxs("div",{className:"chip-field",children:[e.jsx("span",{className:"field-label",id:`${r}-l`,children:"Tools and what they are held to"}),t.resources.length?e.jsx("ul",{className:"chips","aria-labelledby":`${r}-l`,children:t.resources.map(p=>e.jsxs("li",{className:"chip",children:[e.jsx("span",{children:xu(p)}),e.jsx("button",{type:"button",className:"chip-remove","aria-label":`Remove ${xu(p)}`,onClick:()=>s({...t,resources:t.resources.filter(f=>f!==p)}),children:"×"})]},p))}):null,e.jsxs("div",{className:"chip-add",children:[e.jsx(Pe,{label:"Tool",labelHidden:!0,value:l,onChange:i,options:np.map(p=>({value:p,label:p}))}),e.jsx("label",{className:"visually-hidden",htmlFor:`${r}-pattern`,children:"Pattern"}),e.jsx("input",{id:`${r}-pattern`,value:c,placeholder:l==="Bash"?"rm *":l==="WebFetch"?"https://example.com/*":"*.env",onChange:p=>d(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.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(Ee,{label:"tool patterns",children:"Edit covers every tool that changes a file."})]})]})}function dw({rule:t,onChange:s}){const r=m.useId(),l=cw[t.kind];return e.jsxs(e.Fragment,{children:[t.kind==="tool-access"?e.jsx(uw,{rule:t,onChange:s}):e.jsx(zr,{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(i=>i.slice(l.length)),onChange:i=>s({...t,resources:i.map(c=>Gu(t.kind,c))})}),e.jsxs("div",{className:"field",children:[e.jsx("label",{htmlFor:`${r}-reason`,children:"Reason teammates see"}),e.jsx("input",{id:`${r}-reason`,value:t.reason,maxLength:pu,placeholder:"Say why, in a sentence",onChange:i=>s({...t,reason:i.target.value})})]})]})}function hw({rule:t,index:s,onChange:r,onRemove:l,repos:i}){var u;const c=m.useId(),d=((u=ju.find(p=>p.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 ",s+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:fu,step:"any",value:t.monthlyUsd??"",onChange:p=>r({...t,monthlyUsd:p.target.value===""?null:Number(p.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:()=>r({...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:()=>r({...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(Ee,{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:()=>r({...t,effect:"allow"})})," allowed"]}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"radio",name:`${c}-effect`,checked:t.effect==="deny",onChange:()=>r({...t,effect:"deny"})})," blocked"]})]}),e.jsx(zr,{label:"Repositories",placeholder:"repository id, or * for every one",values:t.repos,choices:i,onChange:p=>r({...t,repos:p})}),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:p=>r({...t,ceiling:p}),options:Lf.map(p=>({value:p,label:`${hu[p]}: ${Ov[p]}`}))}),e.jsx(zr,{label:"Repositories",placeholder:"repository id, or * for every one",values:t.repos,choices:i,onChange:p=>r({...t,repos:p})}),e.jsx("p",{className:"muted small-print",children:ep(t.ceiling)<ep(Lv)?`A task that names no mode starts in the most its agent offers up to ${hu[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:p=>r({...t,allowed:p.target.checked})})," Tasks use the starter's own Claude Code setup"]}),e.jsx(zr,{label:"Repositories",placeholder:"repository id, or * for every one",values:t.repos,choices:i,onChange:p=>r({...t,repos:p})}),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(dw,{rule:t,onChange:r})]})}const mw={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 pw({audience:t,rules:s,sources:r,onChange:l}){m.useId();const i=rp(t.kind,s),c=t.kind==="teams"?r.teams:t.kind==="members"||t.kind==="except-members"?r.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:Fv.map(d=>({value:d,label:mw[d],disabled:d!==t.kind&&rp(d,s)!==null}))}),fn({rules:s})?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,i?e.jsx("p",{className:"error",children:i}):null,t.kind==="tags"||t.kind==="except-tags"?e.jsx(fw,{tags:r.tags,ids:t.ids,onChange:d=>l({kind:t.kind,ids:d})}):t.kind==="workspace"?null:e.jsx(zr,{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 fw({tags:t,ids:s,onChange:r}){return t===null?e.jsx("p",{className:"muted",children:"Only an owner or an admin sees members' tags."}):!t.length&&!s.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:ce("settings","members"),children:"Settings"}),"."]}):e.jsx(zr,{label:"Tags",placeholder:"pick a tag",values:s,choices:t,free:!1,show:l=>l,onChange:r})}function gw({rules:t,me:s,orchestratorRulesStored:r,onAdd:l}){const c=(s.mode==="local"?ju.filter(u=>!Xa(u.kind)):ju).map(u=>({...u,refusal:Gv(u.kind,{rules:t,isAdmin:ns(s),orchestratorRulesStored:r})})),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 p=`add-${u.kind}-hint`;return e.jsxs("li",{children:[e.jsxs("button",{type:"button",className:"block-button",disabled:u.refusal!==null,"aria-describedby":p,onClick:()=>l(Kv(u.kind)),children:[e.jsx("span",{"aria-hidden":"true",children:"+ "}),u.label]}),e.jsx("p",{id:p,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 xw({me:t,initial:s,existing:r,sources:l,back:i,repoName:c}){const[d,u]=m.useState(s),[p,f]=m.useState(()=>s.rules.map((A,M)=>M)),g=m.useRef(s.rules.length),[j,y]=m.useState({at:"edit"}),[k,N]=m.useState(!1),[w,b]=m.useState(null),$=(r==null?void 0:r.id)??null,R=A=>{var M,Q;return((M=l.teams.find(H=>H.id===A))==null?void 0:M.label)??((Q=l.members.find(H=>H.id===A))==null?void 0:Q.label)??A},T=zv(d),C=(A,M)=>u({...d,rules:d.rules.map((Q,H)=>H===A?M:Q)}),E=A=>{A.saved==="request"?y({at:"opened",saved:A}):Ue(i)},O=async A=>{N(!0),b(null),await A().catch(M=>b(M.message)),N(!1)},F=()=>O(async()=>{if(!fn(d))return E(await Qt.save($,d));const A=await Qt.proposal($,d);if(A.applies==="now")return E(await Qt.save($,d));y({at:"confirm",plan:A,removing:!1})}),L=()=>O(async()=>{if(!$)return;const A=await Qt.proposal($,null);if(A.applies==="now")return E(await Qt.remove($));y({at:"confirm",plan:A,removing:!0})}),W=async A=>{j.at==="confirm"&&E(j.removing&&$?await Qt.remove($,A):await Qt.save($,d,A))};return j.at==="opened"?e.jsx(Uf,{saved:j.saved,repoName:c,back:i}):j.at==="confirm"?e.jsx(Df,{plan:j.plan,action:j.removing?"Remove this policy":"Save this policy",onConfirm:W,onCancel:()=>y({at:"edit"})}):e.jsxs("div",{className:"policy-editor",children:[e.jsx("p",{className:"policy-summary",role:"status","aria-live":"polite",children:Ku(d,R)}),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:mu,onChange:A=>u({...d,name:A.target.value})})]}),e.jsx(pw,{audience:d.audience,rules:d.rules,sources:l,onChange:A=>u({...d,audience:A})})]}),e.jsx("div",{className:"policy-rules",children:d.rules.length?d.rules.map((A,M)=>e.jsx(hw,{rule:A,index:M,repos:l.repos,onChange:Q=>C(M,Q),onRemove:()=>{u({...d,rules:d.rules.filter((Q,H)=>H!==M)}),f(p.filter((Q,H)=>H!==M))}},p[M])):e.jsx("div",{className:"panel",children:e.jsx("p",{className:"muted",children:"No rules yet."})})}),e.jsx(gw,{rules:d.rules,me:t,orchestratorRulesStored:l.orchestratorRulesStored,onAdd:A=>{u({...d,rules:[...d.rules,A]}),f([...p,g.current++])}}),e.jsx(lw,{draft:d,repoName:c,members:l.members,exportable:ns(t)}),e.jsxs("section",{className:"panel save-bar","aria-label":"Save",children:[e.jsx("p",{className:"muted",children:Wv(d)}),T?e.jsx("p",{id:"locked-reason",className:"locked",children:T}):null,w?e.jsx("p",{className:"error",role:"alert",children:w}):null,e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",onClick:F,disabled:k||T!==null,"aria-describedby":T?"locked-reason":void 0,children:k?"Saving…":"Save policy"}),e.jsx("a",{className:"button secondary",href:i,children:"Cancel"}),r&&fn(r)?e.jsx("button",{type:"button",className:"secondary danger",onClick:L,disabled:k,children:"Delete this policy"}):null,r&&!fn(r)?e.jsx(qe,{trigger:"Delete this policy",consequence:Hv(r),confirm:"Delete policy",keep:"Keep policy",onConfirm:()=>Qt.remove(r.id).then(()=>Ue(i))}):null]})]})]})]})}function rg(t,s){return ns(t)?{teams:s.teams.map(r=>r.team),everyone:!0}:{teams:[...t.ownedTeams],everyone:!1}}const ag=t=>ns(t)||t.ownedTeams.length>0;function lg(t){const[s,r]=m.useState(null),[l,i]=m.useState(null),c=()=>{i(null);const d=ns(t)?Xt.users().catch(()=>[]):Promise.resolve([]),u=ns(t)?Rv.catalog().catch(()=>null):Promise.resolve(null);Promise.all([Qt.list(),Xt.teams(),Ne.repos(),d,u]).then(([p,f,g,j,y])=>r({list:p,teams:f,repos:g,users:j,tags:y}),p=>i(p.message))};return m.useEffect(c,[t.id]),{data:s,error:l,reload:c}}function jw({templates:t,reach:s,blank:r}){const l=t.some(i=>!fn(i.draft(s)));return e.jsx($n,{name:"Control templates",count:t.length,why:e.jsxs(e.Fragment,{children:["Start from one; each opens as a draft",r?e.jsxs(e.Fragment,{children:[", or ",r]}):null,". ",e.jsxs(Ee,{label:"templates",children:[s.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":"",".",s.everyone?"":" Monthly task budgets and where tasks run are rules on this orchestrator's own tasks; an owner or admin sets these."," ",sg,s.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(i=>e.jsx("li",{children:e.jsxs("a",{className:"template",href:`${ce("team","policies","new")}?template=${i.id}`,children:[e.jsx("span",{className:"template-name",children:i.name})," ",e.jsxs("span",{className:"muted",children:[i.description," ",fn(i.draft(s))?"Saved as a request.":"Applies now."]})]})},i.id))})})}function yw({policy:t,names:s}){const r=fn(t);return e.jsxs("li",{className:"policy-row",children:[e.jsxs("div",{children:[e.jsx("p",{className:"policy-name",children:e.jsx("a",{href:ce("team","policies",t.id),children:t.name})}),e.jsx("p",{className:"muted",children:Ku(t,s)})]}),e.jsxs("div",{className:"policy-facts",children:[e.jsx("span",{className:`badge ${r?"badge-request":"badge-now"}`,children:r?"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 vw({me:t}){const{data:s,error:r,reload:l}=lg(t);if(!ag(t))return null;if(r&&!s)return e.jsx(ve,{what:"policies",reason:r,onRetry:l});if(!s)return e.jsx(fe,{what:"policies"});const i=wu(s),{policies:c,problems:d}=s.list,u=e.jsx("a",{href:ce("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(p=>e.jsxs("li",{children:[e.jsx("strong",{children:i(p.repoId)}),": ",p.problem]},p.repoId))})]}):null,c.length?e.jsx($n,{name:"Policies",count:c.length,why:e.jsxs(e.Fragment,{children:["The rules the team is held to. ",e.jsx(Ee,{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:[Yv(0)," Start from a template below, or ",u,"."]}),children:e.jsx("ul",{className:"plain policy-rows",children:c.map(p=>e.jsx(yw,{policy:p,names:i},p.id))})}):null,e.jsx(jw,{blank:c.length?void 0:u,templates:_f(ns(t),t.ownedTeams.length>0,t.mode==="local"),reach:rg(t,s)}),ns(t)&&t.mode!=="local"?e.jsx(kw,{}):null]})}function kw(){const[t,s]=m.useState(null),[r,l]=m.useState(null);m.useEffect(()=>{B("GET","/api/work/automations").then(c=>s(c.enabled),()=>s(null))},[]);const i=c=>{l(null),s(c),B("PUT","/api/work/automations",{enabled:c}).then(d=>s(d.enabled),d=>{s(!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=>i(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:ce("integrations"),children:"Manage automations"})]}),r?e.jsx("p",{className:"error",role:"alert",children:r}):null]})}function ww({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 wu(t){return s=>{var r,l;return((r=t.repos.find(i=>i.id===s))==null?void 0:r.name)??((l=t.users.find(i=>i.id===s))==null?void 0:l.name)??s}}function bw(t){var s;return{teams:t.teams.map(r=>({id:r.team,label:r.team})),members:t.users.map(r=>({id:r.id,label:`${r.name} (${r.email})`})),repos:t.repos.filter(r=>r.configured!==!1).map(r=>({id:r.id,label:r.name})),tags:((s=t.tags)==null?void 0:s.map(r=>({id:r.tag,label:`${r.tag} (${r.members.toLocaleString("en-US")} ${r.members===1?"member":"members"})`})))??null,orchestratorRulesStored:t.list.orchestratorRulesStored}}const Nw={name:"",audience:{kind:"workspace"},rules:[]};function Sw({me:t,page:s}){const{data:r,error:l,reload:i}=lg(t),{search:c}=tl(),d=s!=="new"?(r==null?void 0:r.list.policies.find(f=>f.id===s))??null:null,u=s==="new"?"Add policy":(d==null?void 0:d.name)??"Policy";let p;if(l&&!r)p=e.jsx(ve,{what:"policies",reason:l,onRetry:i,panel:!0});else if(!r)p=e.jsx(fe,{what:"policies",panel:!0});else if(s!=="new"&&!d)p=e.jsx("div",{className:"panel",role:"alert",children:e.jsxs("p",{children:["No policy with this address. ",e.jsx("a",{href:ce("team"),children:"Back to policies"})]})});else if(!ag(t))p=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:Ku(d,wu(r))})]}):null,e.jsx(ww,{then:e.jsx("a",{href:ce("team"),children:"back to the policies in force"})})]});else{const f=_f(ns(t),t.ownedTeams.length>0,t.mode==="local").find(j=>j.id===new URLSearchParams(c).get("template")),g=d??(f==null?void 0:f.draft(rg(t,r)))??Nw;p=e.jsx(xw,{me:t,initial:g,existing:d,sources:bw(r),back:ce("team"),repoName:wu(r)},`${s}:${(f==null?void 0:f.id)??""}`)}return e.jsxs("div",{className:"page",children:[e.jsx(Cn,{title:u,crumb:e.jsx("a",{href:ce("team"),children:"Team"})}),l&&r?e.jsx(Oo,{what:"policies",reason:l,onRetry:i}):null,p]})}const Fs=(t,s,r)=>`${t.toLocaleString("en-US")} ${t===1?s:r}`;function Cw({people:t,shared:s,lessons:r}){const i=[t===null?"":Fs(t,"person","people"),s===null?"":s.skills.length||s.mcpServers.length?`${Fs(s.skills.length,"skill","skills")} and ${Fs(s.mcpServers.length,"MCP server","MCP servers")} shared`:"nothing shared yet",r?`${Fs(r,"lesson waits","lessons wait")} for review`:""].filter(Boolean).join("; ");return i?`${i[0].toUpperCase()}${i.slice(1)}.`:""}const $w=new Set(["forge","repo","members","join","start","task"]);function Tw(t,s){const r=t.filter(i=>!i.done&&$w.has(i.id)),l=i=>s.includes(i.id)?2:i.required?0:1;return[...r].sort((i,c)=>l(i)-l(c))}function og(t){if(!t||!t.tasks)return"no task";const s=t.unknownCost?`${Fs(t.unknownCost,"task","tasks")} with no cost`:"",r=t.usd>0?`$${t.usd.toFixed(2)}${s?` and ${s}`:""}`:s,l=[t.kept?`${t.kept} kept`:"",t.undone?`${t.undone} undone`:"",t.merged?`${t.merged} merged`:"",r].filter(Boolean);return l.length?l.join(", "):`${Fs(t.tasks,"task","tasks")}, none kept or merged yet`}function Ew(t){const[s,r]=m.useState(null);return m.useEffect(()=>{t&&B("GET","/api/analytics/people?days=30").then(l=>r(new Map(l.people.map(i=>[i.email,i]))),()=>r(new Map))},[t]),s}function Rw(){const[t,s]=m.useState(null);return m.useEffect(()=>{B("GET","/api/team/shared?days=30").then(r=>s({skills:r.skills.map(l=>({name:l.name||l.slug,repo:l.repoName,tasks:l.tasks})),mcpServers:r.mcpServers.map(l=>({name:l.name,repo:l.repoName,tasks:l.tasks}))}),()=>s({skills:[],mcpServers:[]}))},[]),t}function Pw(){const[t,s]=m.useState([]);return m.useEffect(()=>{B("GET","/api/team/setup").then(r=>s(r.problems),()=>s([]))},[]),t}function Aw({problem:t}){const[s,r]=m.useState(!1),[l,i]=m.useState(null),c=()=>{r(!0),i(null),$e.start({title:"",description:"",issueUrl:"",repoId:t.repoId,agent:"",template:{kind:"scaffold.refresh",commitVersioning:!1}}).then(d=>Ue(ce("tasks",d.id)),d=>{i(d.message),r(!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:s,onClick:c,children:"Update TeamHandbook's files"}):null,l?e.jsx("p",{className:"error",role:"alert",children:l}):null]})}const Iw=t=>t.status==="pending"||t.status==="sent";function Ow(){const[t,s]=m.useState(null),[r,l]=m.useState(0);return m.useEffect(()=>{B("GET","/api/lessons").then(i=>s(i.candidates.filter(Iw)),()=>s(null))},[r]),[t,()=>l(i=>i+1)]}function Lw({steps:t,skipped:s}){const[r,...l]=t,i=c=>e.jsx("span",{className:"muted",children:s.includes(c.id)?"skipped":c.required?"":"(optional)"});return e.jsxs($n,{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:[r?e.jsxs("div",{className:"setting-up-next",children:[e.jsxs("p",{children:[e.jsx("strong",{children:r.title})," ",i(r)]}),e.jsx("p",{className:"muted",children:r.detail}),e.jsx("div",{className:"actions",children:e.jsx("a",{className:"button secondary",href:r.to,children:r.action})})]}):null,l.length?e.jsx("ul",{className:"team-rows",children:l.map(c=>e.jsxs("li",{children:[c.title," ",i(c)]},c.id))}):null]})}function Fw({people:t}){return t.length?e.jsx($n,{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(s=>e.jsxs("li",{children:[s.name??s.email," ",e.jsx("span",{className:"muted",children:og(s)})]},s.email))})}):null}function Mw({lessons:t,picked:s,onPick:r}){return t.length?e.jsx($n,{name:"Lessons to review",count:t.length,why:"What a task 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:e.jsx("ul",{className:"team-rows",children:t.map(l=>e.jsxs("li",{className:l.slug===s?"picked":void 0,children:[e.jsx("button",{type:"button",className:"row-pick","aria-pressed":l.slug===s,onClick:()=>r(l),children:e.jsx("span",{className:"mono",children:l.slug})}),l.description?e.jsxs("span",{className:"muted",children:[" ",l.description]}):null,l.status==="sent"&&l.machine?e.jsxs("span",{className:"muted",children:[" waits on ",l.machine]}):null]},l.slug))})}):null}function _w({task:t,slug:s,onDecided:r}){const[l,i]=m.useState(null),[c,d]=m.useState(null),[u,p]=m.useState(!1),[f,g]=m.useState(!1);m.useEffect(()=>{i(null),d(null),_s.read(t,s).then(i,y=>d(y.message))},[t,s]);const j=y=>{g(!0),d(null),y.then(r,k=>d(k.message)).finally(()=>g(!1))};return e.jsxs("section",{"aria-labelledby":"lesson-h",children:[e.jsx("h2",{id:"lesson-h",className:"mono",children:s}),c?e.jsx("p",{className:"error",role:"alert",children:c}):l?e.jsxs(e.Fragment,{children:[l.quote?e.jsxs("p",{dir:"auto",children:["You said: “",l.quote,"”"]}):null,e.jsx(Jr,{text:tg(l.skillMd)}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",disabled:f,onClick:()=>j(_s.keep(t,s)),children:"Keep"}),e.jsx("button",{type:"button",className:"secondary",disabled:f,onClick:()=>j(_s.reject(t,s,u)),children:"Discard"})]}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:u,onChange:y=>p(y.target.checked)})," Never suggest it again"]})]}):e.jsx(fe,{what:"the lesson"})]})}function Dw({personal:t}){const[s,r]=m.useState(!1),l=(t==null?void 0:t.mcpServers)??[],i=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=[Fs((t==null?void 0:t.commands.length)??0,"skill","skills"),Fs(l.length,"MCP server","MCP servers"),...t!=null&&t.claudeMd?["a CLAUDE.md"]:[]],d=s?e.jsxs("span",{className:"team-share",children:[e.jsxs("span",{children:[e.jsx("strong",{children:"Start a team handbook"})," ",e.jsx(yt,{text:"/handbook:init"})]}),e.jsxs("span",{children:[e.jsx("strong",{children:"Join a team handbook"})," ",e.jsx(yt,{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:()=>r(!0),children:"Share with a team"});return e.jsxs($n,{name:"Team handbook",count:i.length,why:i.length?`Your Claude Code loads ${c.join(", ")}; tasks here use ${i.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:i.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 Uw({me:t,org:s,repos:r}){var M,Q;const l=t.mode==="local",i=Ie(t),[c,d]=m.useState(null),[u,p]=m.useState(null),[f,g]=m.useState(null),[j,y]=m.useState(new Map),k=Af(t),N=Ew(!l),[w]=qu(!l&&i),[b,$]=Ow(),R=Rw(),T=Pw(),C=Zf(l);m.useEffect(()=>{Ne.summary().then(d,()=>d(null)),Ne.onboarding().then(p,()=>p(null))},[]);const E=(M=r==null?void 0:r.find(H=>H.configured!==!1))==null?void 0:M.id,O=c&&u&&i?u.dismissed?[]:Tw(l?pv(s,c,r??[],mv([]),!1):Nf(s,c,E,Mo(w)!==null),u.skipped):[],F=O.some(H=>H.required)?O:[],L=(r??[]).filter(H=>H.kind==="skills"&&H.configured!==!1),W=Cw({people:l?null:((Q=k.users)==null?void 0:Q.length)??null,shared:l?null:R,lessons:(b==null?void 0:b.length)??null}),A=i&&!l?e.jsx("button",{type:"button",onClick:()=>g({kind:"invite"}),children:"Invite members"}):null;return e.jsxs("div",{className:"page",children:[e.jsx(Cn,{title:"Team",...W?{summary:W}:{},...A?{actions:A}:{}}),e.jsx(eg,{me:t}),e.jsxs("div",{className:f?"with-rail":void 0,children:[e.jsxs("div",{children:[F.length?e.jsx(Lw,{steps:F,skipped:(u==null?void 0:u.skipped)??[]}):null,F.length?null:T.map(H=>e.jsx(Aw,{problem:H},`${H.repoId}:${H.title}`)),b?e.jsx(Mw,{lessons:b,picked:(f==null?void 0:f.kind)==="lesson"?f.slug:null,onPick:H=>g({kind:"lesson",slug:H.slug,task:H.taskId})}):null,l?null:i?e.jsx(If,{me:t,data:k,hideEmpty:!0,extra:{name:"Last 30 days",cell:H=>og(N==null?void 0:N.get(H.email))}}):N?e.jsx(Fw,{people:[...N.values()]}):e.jsx(fe,{what:"tasks by person"}),r===null?e.jsx(fe,{what:"the team handbook"}):L.length?e.jsx(Bk,{me:t,repos:r,counts:R??{skills:[],mcpServers:[]},picked:(f==null?void 0:f.kind)==="handbook"?f.pick:null,proposed:j,onPick:H=>g({kind:"handbook",pick:H}),onProposed:(H,U,ie)=>{const X=new Map(j);for(const J of U.skills)X.set(rr(H,"skills",J),ie);for(const J of U.mcpServers)X.set(rr(H,"mcp",J),ie);for(const J of U.commands)X.set(rr(H,"commands",J),ie);y(X)}}):l?e.jsx(Dw,{personal:C}):null,e.jsx(vw,{me:t})]}),f?e.jsx("aside",{className:"rail","aria-label":f.kind==="invite"?"Invite members":f.kind==="handbook"?"The picked row":"The picked lesson",children:f.kind==="invite"?e.jsx(Wu,{me:t,teams:k.teams,onSent:(H,U)=>{k.setSent({sent:H,skipped:U}),k.reload(),g(null)},onCancel:()=>g(null)}):f.kind==="handbook"?e.jsx(zk,{pick:f.pick,onOpened:H=>{y(new Map(j).set(rr(f.pick.repo.id,f.pick.tab,f.pick.name),H)),g(null)}},rr(f.pick.repo.id,f.pick.tab,f.pick.name)):e.jsx(_w,{task:f.task,slug:f.slug,onDecided:()=>{g(null),$()}},`${f.task}/${f.slug}`)}):null]})]})}function qw({me:t,org:s,repos:r,page:l}){return l[0]==="policies"&&l[1]?e.jsx(Sw,{me:t,page:l[1]}):e.jsx(Uw,{me:t,org:s,repos:r})}const Wr={list:()=>B("GET","/api/work/automations"),turn:t=>B("PUT","/api/work/automations",{enabled:t}),add:t=>B("POST","/api/work/automations",t),change:(t,s)=>B("PUT",`/api/work/automations/${encodeURIComponent(t)}`,s),remove:t=>B("DELETE",`/api/work/automations/${encodeURIComponent(t)}`),deliveries:t=>B("GET",`/api/work/automations/${encodeURIComponent(t)}/deliveries`)},Bw=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}`,zw=t=>t.action==="start"?`start a task in ${t.by.name}'s name`:"draft a task for someone to start";function Ww({repos:t}){const[s,r]=m.useState(null),[l,i]=m.useState(null),[c,d]=m.useState(null),[u,p]=m.useState(!1),f=()=>Wr.list().then(r,j=>i(j.message));m.useEffect(()=>{f()},[]);const g=(j,y)=>{i(null),j.then(()=>{d(y),f()},k=>i(k.message))};return s?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:s.enabled,onChange:j=>g(Wr.turn(j.target.checked),j.target.checked?"Automations run again.":"Every automation is off.")}),"Run automations"]}),s.enabled?null:e.jsx("p",{className:"muted",children:"Every automation is off: changes on the tracker are logged and set nothing going."}),s.automations.length?e.jsx("ul",{className:"automations","aria-label":"Automations",children:s.automations.map(j=>e.jsx(Hw,{automation:j,run:g},j.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(Gw,{repos:t,onAdded:j=>{p(!1),d(`${j.name} is set up.`),f()},onCancel:()=>p(!1)}):e.jsx("button",{type:"button",className:"secondary",onClick:()=>p(!0),children:"Add automation"})]}):l?e.jsx(ve,{what:"automations",reason:l,onRetry:()=>{i(null),f()}}):e.jsx(fe,{what:"automations"})}function Hw({automation:t,run:s}){const[r,l]=m.useState(null),i=()=>r?l(null):Wr.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 ",Bw(t),", ",zw(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=>s(Wr.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":!!r,onClick:i,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:()=>Wr.remove(t.id).then(()=>s(Promise.resolve(),`${t.name} is removed.`))})]}),r?r.length?e.jsx("ul",{"aria-label":`Deliveries of ${t.name}`,children:r.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 Gw({repos:t,onAdded:s,onCancel:r}){var w;const[l,i]=m.useState(null),[c,d]=m.useState([]),[u,p]=m.useState([]),[f,g]=m.useState({name:"",board:"",kind:"column",column:"",label:"",labels:"",repoId:((w=t[0])==null?void 0:w.id)??"",agent:"",action:"draft"}),[j,y]=m.useState(null);m.useEffect(()=>{B("GET","/api/work/boards?source=tracker").then(b=>i(b.boards),b=>y(b.message)),$e.options().then(b=>{d(b.agents),g($=>{var R;return{...$,agent:$.agent||((R=b.agents[0])==null?void 0:R.id)||""}})},()=>{})},[]),m.useEffect(()=>{!f.repoId&&t[0]&&g(b=>({...b,repoId:t[0].id}))},[t]),m.useEffect(()=>{if(!f.board)return p([]);B("GET",`/api/work/boards/${encodeURIComponent(f.board)}/columns`).then(b=>p(b.columns),b=>y(b.message))},[f.board]);const k=b=>$=>g({...f,[b]:$.target.value}),N=b=>{b.preventDefault(),y(null);const $=f.kind==="column"?{kind:"column",column:f.column}:{kind:"label",label:f.label.trim()},R=f.labels.split(",").map(T=>T.trim()).filter(Boolean);Wr.add({name:f.name.trim(),board:f.board,trigger:$,filter:{labels:R},repoId:f.repoId,agent:f.agent,action:f.action}).then(T=>s(T.automation),T=>y(T.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:k("name"),required:!0,maxLength:60})]}),e.jsxs("label",{children:["Board",e.jsxs("select",{value:f.board,onChange:k("board"),required:!0,children:[e.jsx("option",{value:"",children:"Pick a board"}),(l??[]).map(b=>e.jsx("option",{value:b.id,children:b.name},b.id))]})]}),e.jsxs("label",{children:["When",e.jsxs("select",{value:f.kind,onChange:k("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:k("column"),required:!0,children:[e.jsx("option",{value:"",children:"Pick a column"}),u.map(b=>e.jsx("option",{value:b.name,children:b.name},b.name))]})]}):e.jsxs("label",{children:["Label",e.jsx("input",{value:f.label,onChange:k("label"),required:!0,maxLength:100})]}),e.jsxs("label",{children:["Only issues labelled (optional, separated by commas)",e.jsx("input",{value:f.labels,onChange:k("labels"),maxLength:400})]}),e.jsxs("label",{children:["Repository",e.jsx("select",{value:f.repoId,onChange:k("repoId"),required:!0,children:t.map(b=>e.jsx("option",{value:b.id,children:b.name},b.id))})]}),e.jsxs("label",{children:["Agent",e.jsx("select",{value:f.agent,onChange:k("agent"),required:!0,children:c.map(b=>e.jsx("option",{value:b.id,children:b.label},b.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:k("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:k("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,j?e.jsx("p",{className:"error",role:"alert",children:j}):null,e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",children:"Add automation"}),e.jsx("button",{type:"button",className:"secondary",onClick:r,children:"Cancel"})]})]})}function ar({id:t,name:s,about:r,connected:l,action:i,status:c,other:d,error:u,level:p=2}){const f=p===3?"h3":"h2";return e.jsxs("section",{id:`card-${t}`,className:p===3?"connect":"section connect","aria-labelledby":`${t}-h`,children:[e.jsxs("div",{className:"connect-head",children:[e.jsx(f,{id:`${t}-h`,children:s}),l?e.jsx("span",{className:"state ok",children:"Connected"}):null]}),e.jsx("p",{children:r}),c?e.jsx("div",{className:"connect-status",role:"status",children:c}):null,e.jsx("div",{className:"actions",children:i}),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 Ka={gitlab:{ownApplication:!0,visibilities:["private","internal","public"],namespace:!0},github:{ownApplication:!1,visibilities:["private","public"],namespace:!1}},ig=t=>t.slice(0,10);function Kw({kind:t}){const[s,r]=m.useState(null);if(m.useEffect(()=>{jt.hosts().then(i=>r(i.hosts.filter(c=>c.kind===t)),()=>r([]))},[t]),!(s!=null&&s.length))return null;const l=et[t].label;return e.jsx("ul",{className:"forge-hosts","aria-label":`${l} hosts`,children:s.map(i=>{const c=i.repos.filter(u=>u.via==="token"),d=i.repos.filter(u=>u.via==="connection");return e.jsxs("li",{className:"panel",children:[e.jsxs("h4",{children:[l," at ",new URL(i.webUrl).host]}),i.connection?e.jsxs("p",{children:["Connected as ",i.connection.account,i.ownApplication?", through the organization's own application":"","."]}):i.ownApplication?e.jsx("p",{children:"The organization's own application is entered; nobody connected through it yet."}):null,i.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:i.credentials.tokenPage,target:"_blank",rel:"noopener",children:new URL(i.credentials.tokenPage).host})," that allows: ",i.credentials.scopes.join(", "),"."]}):null]},i.apiUrl)})})}function bu(){const t=new URLSearchParams(window.location.search),s=t.get("forge_connected");return{connected:Ja.includes(s)?s:null,problem:t.get("forge_problem")}}function Vw({kind:t,repos:s,onChanged:r}){const l=et[t].label,[i,c]=m.useState(null),[d,u]=m.useState(null),[p,f]=m.useState(null),g=()=>jt.connection(t).then(c,w=>u(w.message));m.useEffect(()=>{g()},[t]);const j=bu(),y=w=>{f(w),g(),r()};if(!i)return d?e.jsx(ve,{what:`the ${l} connection`,reason:d,onRetry:()=>{u(null),g()}}):e.jsx(fe,{what:`the ${l} connection`});if(!i.available)return Ka[t].ownApplication?e.jsx(pp,{onSaved:g}):null;const k=()=>{u(null),jt.connect(t).then(w=>window.location.assign(w.authorizeUrl),w=>u(w.message))},N=i.connection;return e.jsxs("section",{className:"forge-connect","aria-label":`${l} connection`,children:[j.connected===t&&N?e.jsxs("p",{role:"status",children:["Connected to ",l," as ",N.account,"."]}):null,p?e.jsx("p",{role:"status",children:p}):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 ",ig(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:k,children:["Reconnect with ",l]})]}):null,e.jsx(Yw,{kind:t}),e.jsx(Qw,{kind:t,repos:s,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(Jw,{kind:t,repos:s,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:()=>jt.disconnect(t).then(w=>y(w.note??`${l} is disconnected.`))})]}):Ka[t].ownApplication?e.jsx(pp,{onSaved:g,beside:!0}):null]})}function Yw({kind:t}){const[s,r]=m.useState(null),[l,i]=m.useState(!1),[c,d]=m.useState(null),u=()=>{i(!0),d(null),jt.check(t).then(p=>{i(!1),r(p.check)},p=>{i(!1),d(p.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,s!=null&&s.ok?e.jsxs("p",{role:"status",children:["Works as ",s.account,s.version?`, on ${et[t].label} ${s.version}`:"","."]}):null,s&&!s.ok?e.jsxs("div",{role:"alert",children:[e.jsx("p",{children:s.problem??`The connection does not allow everything the orchestrator needs on ${et[t].label}.`}),s.missing.length?e.jsx("ul",{"aria-label":"What the connection lacks",children:s.missing.map(p=>e.jsx("li",{children:p},p))}):null]}):null]})}const cg=t=>[...new Set(t.map(s=>s.team))].sort();function ug({label:t,value:s,onChange:r,teams:l}){const i=m.useId();return e.jsxs("label",{children:[t,e.jsx("input",{list:i,value:s,onChange:c=>r(c.target.value),required:!0,maxLength:60}),e.jsx("datalist",{id:i,children:l.map(c=>e.jsx("option",{value:c},c))})]})}function Qw({kind:t,repos:s,onConnected:r}){const l=et[t].label,[i,c]=m.useState(null),[d,u]=m.useState({}),[p,f]=m.useState(null),g=()=>jt.repos(t).then(k=>c(k.repos),k=>f(k.message));m.useEffect(()=>{g()},[t]);const j=cg(s),y=(k,N)=>{f(null),k.then(()=>{g(),r(N)},w=>f(w.message))};return i?e.jsxs(e.Fragment,{children:[p?e.jsx("p",{className:"error",role:"alert",children:p}):null,i.length?e.jsx("ul",{className:"forge-repos","aria-label":`${l} repositories`,children:i.map(k=>{const N=d[k.fullName]??"";return e.jsxs("li",{children:[e.jsx("span",{className:"mono",children:k.fullName}),k.connected?e.jsx("span",{className:"badge ok",children:"Connected"}):e.jsxs("span",{className:"actions",children:[e.jsx(ug,{label:`Team for ${k.fullName}`,value:N,onChange:w=>u({...d,[k.fullName]:w}),teams:j}),e.jsxs("button",{type:"button",className:"secondary small",disabled:!N.trim(),onClick:()=>y(jt.connectRepo(t,{fullName:k.fullName,team:N.trim()}),`${k.fullName} is connected for ${N.trim()}.`),children:["Connect ",k.fullName]}),k.empty?e.jsxs("button",{type:"button",className:"secondary small",disabled:!N.trim(),onClick:()=>y(jt.teamRepo(t,{existing:k.fullName,team:N.trim()}),`${k.fullName} is the team repository of ${N.trim()}.`),children:["Use ",k.fullName," as the team repository"]}):null]})]},k.fullName)})}):e.jsxs("p",{className:"muted",children:[l," lists no repository for this connection yet."]})]}):p?e.jsx(ve,{what:`${l} repositories`,reason:p,onRetry:()=>{f(null),g()}}):e.jsx(fe,{what:`${l} repositories`})}function Jw({kind:t,repos:s,onMade:r}){const l=et[t].label,[i,c]=m.useState(!1),[d,u]=m.useState({name:"",team:"",visibility:"private",namespace:""}),[p,f]=m.useState(!1),[g,j]=m.useState(null),[y,k]=m.useState(null),[N,w]=m.useState(null),b=$=>{$.preventDefault(),j(null),k(null),f(!0);const R={name:d.name.trim(),team:d.team.trim(),visibility:d.visibility,...Ka[t].namespace&&d.namespace.trim()?{namespace:d.namespace.trim()}:{}};jt.teamRepo(t,R).then(T=>{f(!1);const C=T.repo.url.replace(/^https?:\/\/[^/]+\//,"").replace(/\.git$/,"");w(`Created ${C}.${T.webhook==="installed"?"":` The webhook is ${T.webhook}.`}`),c(!1),r(`The team repository for ${R.team} is on ${l}.`)},T=>{f(!1);const C=T instanceof ut&&Array.isArray(T.body.steps)?T.body.steps:null;C!=null&&C.length?k(C):j(T.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($=>e.jsx("li",{children:$.url?e.jsx("a",{href:$.url,target:"_blank",rel:"noopener",children:$.text}):$.text},$.text))})]}):null,i?e.jsxs("form",{className:"form",onSubmit:b,"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:$=>u({...d,name:$.target.value}),required:!0,maxLength:100})]}),e.jsx(ug,{label:"Team",value:d.team,onChange:$=>u({...d,team:$}),teams:cg(s)}),e.jsxs("label",{children:["Visibility",e.jsx("select",{value:d.visibility,onChange:$=>u({...d,visibility:$.target.value}),children:Ka[t].visibilities.map($=>e.jsx("option",{value:$,children:$[0].toUpperCase()+$.slice(1)},$))})]}),Ka[t].namespace?e.jsxs("label",{children:["Group (optional)",e.jsx("input",{value:d.namespace,onChange:$=>u({...d,namespace:$.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:p,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 pp({onSaved:t,beside:s=!1}){const[r,l]=m.useState(null),[i,c]=m.useState({url:"",clientId:"",clientSecret:""}),[d,u]=m.useState(null),p=()=>jt.gitlabApp().then(l,g=>u(g.message));if(m.useEffect(()=>{p()},[]),!r||r.operator)return d?e.jsx("p",{className:"error",role:"alert",children:d}):null;const f=g=>{g.preventDefault(),u(null),jt.saveGitlabApp(i).then(()=>{c({url:"",clientId:"",clientSecret:""}),p(),t()},j=>u(j.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."}),r.redirectUri?e.jsxs("p",{children:["Redirect URI: ",e.jsx("span",{className:"mono",children:r.redirectUri})]}):null,r.app?e.jsxs("p",{children:["The application at ",r.app.webUrl," was entered by ",r.app.by," on ",ig(r.app.at),"."]}):null,e.jsxs("label",{children:["GitLab address",e.jsx("input",{value:i.url,onChange:g=>c({...i,url:g.target.value}),placeholder:"https://gitlab.example.com",required:!0})]}),e.jsxs("label",{children:["Application ID",e.jsx("input",{value:i.clientId,onChange:g=>c({...i,clientId:g.target.value}),required:!0,autoComplete:"off"})]}),e.jsxs("label",{children:["Secret",e.jsx("input",{type:"password",value:i.clientSecret,onChange:g=>c({...i,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:s?"secondary":void 0,children:"Save application"}),r.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:()=>jt.removeGitlabApp().then(()=>{p(),t()})}):null]})]})}function fp({forge:t,code:s,url:r,note:l}){return e.jsxs(e.Fragment,{children:[s?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Enter this code on ",t,":"]}),e.jsx("div",{className:"sign-in-code",children:e.jsx(yt,{text:s,label:"Copy the code",well:!0})})]}):null,e.jsxs("p",{children:[r?e.jsxs(e.Fragment,{children:[e.jsxs("a",{href:r,target:"_blank",rel:"noopener",children:["Open ",t]}),s?"":" to sign in",". "]}):null,l?e.jsxs(e.Fragment,{children:[l,". "]}):null,"Waiting for ",t,"."]})]})}function Xw({card:t,repos:s,other:r,onChanged:l}){var E,O;const i=t.id,c=Jt[i],[d,u]=m.useState(null),[p,f]=m.useState(null),[g,j]=m.useState(!1),y=()=>jt.signInState(i).then(u,F=>f(F.message));m.useEffect(()=>{y()},[i]);const k=(d==null?void 0:d.signIn.state)==="waiting"||((E=d==null?void 0:d.device)==null?void 0:E.signIn.state)==="waiting";m.useEffect(()=>{if(!k)return;const F=setInterval(()=>{jt.signInState(i).then(L=>{var W;u(L),(L.signIn.state==="done"||((W=L.device)==null?void 0:W.signIn.state)==="done")&&l()},()=>{})},2e3);return()=>clearInterval(F)},[k,i]);const N=()=>{j(!0),f(null),jt.signIn(i).then(u,F=>f(F.message)).finally(()=>j(!1))};if(!d)return e.jsx(ar,{id:i,name:c,level:3,connected:t.state==="connected",about:p?"":`Loading ${c}.`,action:null,other:r,error:p});if(!d.offered||!d.cli){const F=()=>{j(!0),f(null),jt.connect(i).then(Q=>window.location.assign(Q.authorizeUrl),Q=>{f(Q.message),j(!1)})},L=t.connection,W=L?null:d.device;if(W!=null&&W.offered){const Q=W.signIn,H=()=>{j(!0),f(null),jt.deviceSignIn(i).then(()=>y(),Z=>f(Z.message)).finally(()=>j(!1))},U=()=>{j(!0),f(null),jt.deviceSignOut(i).then(()=>y(),Z=>f(Z.message)).finally(()=>j(!1))},ie=Q.state==="done"?`Connected as ${Q.account} on ${Q.host}; the orchestrator opens the requests of the tasks you start as you, and nothing else.`:Q.state==="failed"?lr(Q.error):`Sign in to ${c} with a one-time code, nothing to install; it lets the orchestrator write to the repositories you can, which it uses only for the requests of the tasks you start.`,X=Q.state==="waiting"?e.jsx(fp,{forge:c,code:Q.code,url:Q.url}):null,J=Q.state==="done"?e.jsx("button",{type:"button",className:"secondary",disabled:g,onClick:U,children:"Sign out"}):Q.state==="waiting"?null:e.jsxs("button",{type:"button",className:"secondary",disabled:g,onClick:H,children:["Sign in with ",c]});return e.jsx(ar,{id:i,name:c,level:3,connected:Q.state==="done",about:ie,status:X,action:J,other:r,error:p})}const A=L?`Connected as ${L.account}.`:d.org?d.org.available?`Connect ${c} once for the organization: the orchestrator reads the repositories you pick and opens their requests there.`:d.why?lr(`${d.why}; connect with a token under Other ways to connect`):e.jsxs(e.Fragment,{children:[d.org.missing[0]," ",e.jsxs(Ee,{label:`connecting ${c} with one click`,children:["Its operator sets ORCHESTRATOR_FORGE_",i.toUpperCase(),"_*, ORCHESTRATOR_PUBLIC_URL and ORCHESTRATOR_SECRET_KEY, as the operator's guide to forge applications describes."]})]}):lr(d.why??`An owner or an admin connects ${c}`),M=L||!((O=d.org)!=null&&O.available)?null:e.jsxs("button",{type:"button",className:"secondary",disabled:g,onClick:F,children:["Connect with ",c]});return e.jsx(ar,{id:i,name:c,level:3,connected:!!L||t.state==="connected",about:A,action:M,other:r,error:p})}const w=d.cli,b=d.signIn,$=b.state==="failed"?b.error:null,R=w.signedIn?`Connected as ${w.account??"you"} on ${w.host}.`:w.installed?`Sign in with your own ${w.tool} through the browser; its sign-in stays with ${w.tool}, and requests open on ${c} as you.`:`${w.name} is not on this machine. Install it, then check again.`,T=b.state==="waiting"?e.jsx(fp,{forge:c,code:b.code,url:b.url,note:b.note}):null,C=w.signedIn?null:w.installed?b.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:w.install,target:"_blank",rel:"noopener",children:["Install ",w.tool]}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>y(),children:"Check again"})]});return e.jsx(ar,{id:i,name:c,level:3,connected:w.signedIn,about:R,status:T,action:C,other:r,error:p??$})}const zc={name:"",description:"",transport:"http",url:"",auth:"oauth"};function Zw(t){var s,r;return t.auth==="none"?"No sign-in":t.auth==="token"?(s=t.credential)!=null&&s.set?"Token set":"No token":(r=t.credential)!=null&&r.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 Wc(){const t=new URLSearchParams(window.location.search),s=new URLSearchParams(window.location.hash.split("?")[1]??"");return{connected:t.get("connected")??s.get("connected"),problem:t.get("problem")??s.get("problem")}}function eb({me:t,repos:s}){const[r,l]=m.useState(null),[i,c]=m.useState(zc),[d,u]=m.useState(""),[p,f]=m.useState(""),[g,j]=m.useState(Wc().problem),[y,k]=m.useState(Wc().connected?`${Wc().connected} is connected. Pick the tools a task may use.`:null),[N,w]=m.useState(!1),[b,$]=m.useState("me"),[R,T]=m.useState(null),C=m.useId(),E=s.filter(A=>A.configured!==!1&&A.head&&Xr(t,A.team)),O=()=>qn.list().then(l,A=>j(A.message));m.useEffect(()=>{O()},[]);const F=(A,M)=>{j(null),k(null),w(!0),A().then(()=>{w(!1),M&&k(M),O()},Q=>{w(!1),j(Q.message)})},L=A=>{j(null),k(A),O()},W=A=>{if(A.preventDefault(),b!=="me"){const Q=E.find(U=>U.id===b),H=i.transport==="http"?{type:"http",url:i.url}:{command:i.command,args:d.split(`
|
|
65
|
-
`).map(U=>U.trim()).filter(Boolean)};T({repoId:Q.id,head:Q.head,config:H,name:i.name});return}const M=i.transport==="http"?{name:i.name,description:i.description,transport:"http",url:i.url,auth:i.auth,...i.auth==="token"?{token:p}:{}}:{name:i.name,description:i.description,transport:"stdio",command:i.command,args:d.split(`
|
|
66
|
-
`).map(Q=>Q.trim()).filter(Boolean),auth:"none"};F(async()=>{await qn.add(M),c(zc),u(""),f("")},`${M.name} is added.${M.auth==="oauth"?" Connect it to sign in.":" Pick the tools a task may use."}`)};return r?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,r.servers.length?e.jsx("ul",{className:"plain my-servers",children:r.servers.map(A=>e.jsx(tb,{server:A,signIn:r.signIn,busy:N,run:F,done:L},A.name))}):e.jsx("p",{className:"muted",children:"You have added no server yet."}),e.jsxs("form",{className:"form editor",onSubmit:W,"aria-label":"Add an MCP server",children:[e.jsx("h4",{children:"Add an MCP server"}),e.jsx(Pe,{label:"For",value:b,onChange:$,disabled:R!==null,options:[{value:"me",label:"Only the tasks I start"},...E.map(A=>({value:A.id,label:`The ${A.team} team, through a request on ${A.name}`}))]}),e.jsxs("label",{children:["Name",e.jsx("input",{value:i.name,onChange:A=>c({...i,name:A.target.value}),required:!0,spellCheck:!1,"aria-describedby":g?C:void 0})]}),e.jsxs("label",{children:["Description",e.jsx("input",{value:i.description,onChange:A=>c({...i,description:A.target.value})})]}),e.jsx(Pe,{label:"Reached",value:i.transport,onChange:A=>c({...i,transport:A,auth:A==="http"?"oauth":"none"}),options:[{value:"http",label:"Over the network (URL)"},{value:"stdio",label:"As a command in the task"}]}),i.transport==="http"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:["URL",e.jsx("input",{type:"url",value:i.url??"",onChange:A=>c({...i,url:A.target.value}),required:!0,placeholder:"https://mcp.example.com/mcp","aria-describedby":g?C:void 0})]}),b==="me"?e.jsx(Pe,{label:"Sign-in",value:i.auth,onChange:A=>c({...i,auth:A}),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."}),b==="me"&&i.auth==="token"?e.jsxs("label",{children:["Token",e.jsx("input",{type:"password",autoComplete:"off",value:p,onChange:A=>f(A.target.value),required:!0,disabled:!r.vault})]}):null,b==="me"&&i.auth!=="none"&&!r.vault?e.jsx("p",{className:"error",children:"Set ORCHESTRATOR_SECRET_KEY on the server to keep a token or a sign-in."}):null,b==="me"&&i.auth==="oauth"&&!r.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:i.command??"",onChange:A=>c({...i,command:A.target.value}),required:!0,spellCheck:!1,placeholder:"npx"})]}),e.jsxs("label",{children:["Arguments, one per line",e.jsx("textarea",{className:"short",value:d,onChange:A=>u(A.target.value),spellCheck:!1})]})]}),R===null?e.jsx("div",{className:"actions",children:e.jsx("button",{type:"submit",disabled:N,children:b==="me"?"Add":"Review the request"})}):null]}),R?e.jsx(Tn,{repoId:R.repoId,head:R.head,build:()=>({kind:"mcp.add",name:R.name,config:R.config}),submitLabel:"Check the server",onOpened:A=>{T(null),c(zc),u(""),k(Qu(A))},onCancel:()=>T(null),children:()=>e.jsxs("h4",{children:["Add ",R.name," for the team"]})}):null]}):g?e.jsx(ve,{what:"your MCP servers",reason:g,onRetry:()=>{j(null),O()}}):e.jsx(fe,{what:"your MCP servers"})}function Nu(t,s){return s.length?[...s]:t.filter(r=>r.reads).map(r=>r.name)}function Su(t){return{reads:t.filter(s=>!s.writes),writes:t.filter(s=>s.writes)}}function tb({server:t,signIn:s,busy:r,run:l,done:i}){var T,C,E;const[c,d]=m.useState(null),[u,p]=m.useState(t.tools),[f,g]=m.useState(t.tools.join(", ")),j=c??t.tools.map(O=>{var F,L;return{name:O,description:"",writes:((L=(F=t.known)==null?void 0:F[O])==null?void 0:L.writes)??t.writing.includes(O)}}),y=O=>{var F;return((F=j.find(L=>L.name===O))==null?void 0:F.writes)??!1},k=O=>p(u.includes(O)?u.filter(F=>F!==O):[...u,O]),N=()=>l(async()=>{const O=await qn.tools(t.name);d(O),p(Nu(O,t.tools))},null),w=()=>l(async()=>window.location.assign(await qn.connect(t.name)),null),b=t.transport==="http"&&(t.auth!=="oauth"||!!((T=t.credential)!=null&&T.set));m.useEffect(()=>{!b||t.tools.length||qn.tools(t.name).then(O=>{d(O),p(Nu(O,t.tools))},()=>{})},[b]);const $=(O,F)=>F.length?e.jsxs("fieldset",{className:"teams",children:[e.jsx("legend",{children:O}),F.map(L=>e.jsxs("label",{className:"check",title:L.description||void 0,children:[e.jsx("input",{type:"checkbox",checked:u.includes(L.name),onChange:()=>k(L.name)}),L.name]},L.name))]}):null,R=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:Zw(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"?j.length?e.jsxs(e.Fragment,{children:[$("Reads",Su(j).reads),$("Writes",Su(j).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:O=>g(O.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,R.length?e.jsxs("p",{className:"warning",role:"note",children:["This lets a task change things in ",t.name," as you: ",R.join(", "),". What such a tool changes is not a request anyone reviews."]}):null,e.jsxs("div",{className:"row-actions",children:[t.auth==="oauth"?(E=t.credential)!=null&&E.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:()=>qn.disconnect(t.name).then(()=>i(`${t.name} is disconnected.`))}):e.jsx("button",{type:"button",className:"small",disabled:r||!s,onClick:w,children:"Connect"}):null,t.transport==="http"?e.jsx("button",{type:"button",className:"secondary small",disabled:r,onClick:N,children:"Load tools"}):null,e.jsx("button",{type:"button",className:"small",disabled:r,onClick:()=>l(()=>qn.update(t.name,{tools:t.transport==="http"?u:f.split(",").map(O=>O.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:()=>qn.remove(t.name).then(()=>i(`${t.name} and its sign-in are removed.`))})]})]})}function nb(){const[t,s]=m.useState(null),[r,l]=m.useState(null),[i,c]=m.useState(null),[d,u]=m.useState(!1),p=()=>qa.list().then(s,g=>l(g.message));m.useEffect(()=>{p()},[]);const f=(g,j)=>{l(null),c(null),u(!0),g().then(()=>{u(!1),j&&c(j),p()},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."}),r?e.jsx("p",{className:"error",role:"alert",children:r}):null,i?e.jsx("p",{role:"status",children:i}):null,e.jsx("ul",{className:"plain my-servers",children:t.servers.map(g=>e.jsx(sb,{server:g,canManage:t.canManage,busy:d,run:f,done:j=>{c(j),p()}},g.key))})]}):e.jsx("p",{className:"muted",children:"No team repository declares a server that signs people in."}):r?e.jsx(ve,{what:"team MCP servers",reason:r,onRetry:()=>{l(null),p()}}):e.jsx(fe,{what:"team MCP servers"})}function sb({server:t,canManage:s,busy:r,run:l,done:i}){var w;const[c,d]=m.useState(null),[u,p]=m.useState(t.tools),f=()=>l(async()=>{t.mine||await qn.add({name:t.name,description:`The team's ${t.name}`,transport:"http",url:t.url,auth:"oauth"}),window.location.assign(await qn.connect(t.name))},null),g=()=>l(async()=>window.location.assign(await qa.connectForEveryone(t.key)),null),j=()=>l(async()=>{const b=await qa.tools(t.key);d(b),p(Nu(b,t.tools))},null),y=b=>p(u.includes(b)?u.filter($=>$!==b):[...u,b]),k=c?Su(c):null,N=c?u.filter(b=>{var $;return($=c.find(R=>R.name===b))==null?void 0:$.writes}):((w=t.everyone)==null?void 0:w.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(b=>`${b.team} · ${b.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:r,onClick:f,children:"Connect for my tasks"}),s?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:()=>qa.disconnectForEveryone(t.key).then(()=>i(`${t.name} is disconnected from everyone's tasks.`))}):e.jsx("button",{type:"button",className:"secondary small",disabled:r,onClick:g,children:"Connect for everyone's tasks"}):null,s?e.jsx("button",{type:"button",className:"secondary small",disabled:r,onClick:j,children:"Load tools"}):null]}),s&&k?e.jsxs(e.Fragment,{children:[k.reads.length?e.jsxs("fieldset",{className:"teams",children:[e.jsx("legend",{children:"Reads"}),k.reads.map(b=>e.jsxs("label",{className:"check",title:b.description||void 0,children:[e.jsx("input",{type:"checkbox",checked:u.includes(b.name),onChange:()=>y(b.name)}),b.name]},b.name))]}):null,k.writes.length?e.jsxs("fieldset",{className:"teams",children:[e.jsx("legend",{children:"Writes"}),k.writes.map(b=>e.jsxs("label",{className:"check",title:b.description||void 0,children:[e.jsx("input",{type:"checkbox",checked:u.includes(b.name),onChange:()=>y(b.name)}),b.name]},b.name))]}):null,e.jsx("div",{className:"row-actions",children:e.jsx("button",{type:"button",className:"small",disabled:r,onClick:()=>l(()=>qa.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,s?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 Ju={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."}},dg="Give a team of agents any folder on this machine: say what needs doing, and review every change before you keep it.",rb="Give a team of agents any folder on your computer: say what needs doing, and review every change before you keep it.",Os=t=>new URLSearchParams(Object.entries(t).filter(s=>!!s[1])).toString(),Zt={sources:()=>B("GET","/api/work/sources"),boards:t=>B("GET",`/api/work/boards?${Os({source:t})}`),sprints:t=>B("GET",`/api/work/sprints?${Os({board:t})}`),sprintItems:(t,s=!1)=>B("GET",`/api/work/items?${Os({sprint:t,fresh:s?"1":void 0})}`),backlog:(t,s=!1)=>B("GET",`/api/work/items?${Os({backlog:t,fresh:s?"1":void 0})}`),saveColumns:(t,s)=>B("PUT",`/api/work/boards/${encodeURIComponent(t)}/columns`,{columns:s}),boardItems:(t,s=!1)=>B("GET",`/api/work/items?${Os({board:t,fresh:s?"1":void 0})}`),moves:t=>B("GET",`/api/work/moves?${Os({board:t})}`),saveMoves:(t,s)=>B("PUT",`/api/work/moves?${Os({board:t})}`,s),mapBoard:(t,s)=>B("PUT","/api/work/boards/teams",{boards:[{boardId:t,team:s}]}),starters:t=>B("GET",`/api/work/starters?${Os({project:t})}`)},Xu={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."}},ab={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."},lb={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."},ob={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 ib(){const t=new URLSearchParams(window.location.search).get("open");return t!==null&&Object.hasOwn(Xu,t)?t:null}const Hc={"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."},cb=[{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:Ju.mcpServer.means,cards:["orchestrator-mcp","team","mine"]}],xo={connected:{label:"Connected",tone:"ok"},requested:{label:"Requested",tone:"warn"},off:{label:"Not set up",tone:""}},qo=t=>t.slice(0,10);function ub(){const t=new URLSearchParams(window.location.search);return{added:t.get("slack")==="added",problem:t.get("slackProblem")}}function db({by:t,at:s}){return!t||!s?null:e.jsxs("p",{className:"muted small-print",children:["Enabled by ",t," on ",qo(s)]})}function hb({me:t,repos:s}){const[r,l]=m.useState(null),[i,c]=m.useState(null),[d,u]=m.useState(""),p=ub(),[f,g]=m.useState(()=>bu().connected??ib()??(p.added?"slack":null)),j=bu().problem,[y,k]=m.useState(()=>/[?&](connected=(?!atlassian\b)|problem=)/.test(window.location.search+window.location.hash)),N=()=>{c(null),Lt.list().then(l,U=>c(U.message))};m.useEffect(()=>{N()},[]);const w=r!==null;m.useEffect(()=>{var U;w&&f&&((U=document.getElementById(`card-${f}`))==null||U.scrollIntoView({block:"start"}))},[w]);const b=d.trim().toLowerCase(),[$,R]=m.useState(!1),[T,C]=m.useState(!1),E=U=>U==="team"?lb:U==="mine"?ab:U==="automations"?ob:Xu[U],O=U=>!b||`${E(U).title} ${E(U).text} ${Hc[U]??""}`.toLowerCase().includes(b),F=!!(r!=null&&r.local),L=!!(r!=null&&r.integrations.some(U=>U.id==="tracker"&&U.config)),W=U=>{var ie;return(U!=="tracker"||L||!((ie=r==null?void 0:r.jira.mcp)!=null&&ie.connected)||f==="tracker")&&(U==="team"||U==="mine"||(U==="automations"?!!(r!=null&&r.canManage):!!(r!=null&&r.integrations.some(X=>X.id===U))))},A=!b||`jira atlassian ${mb}`.toLowerCase().includes(b),M=((r==null?void 0:r.catalog)??[]).filter(U=>!b||`${U.name} ${U.about}`.toLowerCase().includes(b)),Q=cb.map(U=>({...U,cards:U.cards.filter(ie=>W(ie)&&O(ie))})).filter(U=>U.cards.length),H=U=>{var Z;const ie=E(U).title,X=Hc[U]?e.jsx("p",{className:"small-print muted",children:Hc[U]}):null;if(U==="team"||U==="mine"||U==="automations"){const ae=U==="team"?$:U==="mine"?y:T,z=()=>U==="team"?R(!$):U==="mine"?k(!y):C(!T);return e.jsxs("li",{className:"panel card",children:[e.jsx("div",{className:"card-head",children:e.jsx("h3",{id:`card-${U}`,children:ie})}),X,e.jsx("p",{children:E(U).text}),e.jsx("button",{type:"button",className:"secondary","aria-expanded":ae,"aria-controls":`body-${U}`,onClick:z,children:ae?"Close":"Manage"}),ae?e.jsx("div",{id:`body-${U}`,className:"card-body",role:"region","aria-labelledby":`card-${U}`,children:U==="team"?e.jsx(nb,{}):U==="mine"?e.jsx(eb,{me:t,repos:s}):e.jsx(Ww,{repos:s})}):null]},U)}const J=r.integrations.find(ae=>ae.id===U);if(Vr(J.id)){const ae=J;return e.jsx("li",{className:"panel card",children:e.jsx(Xw,{card:ae,repos:s,onChanged:N,other:e.jsx(jb,{card:ae,forges:r.integrations.filter(z=>Vr(z.id)),repos:s,canManage:r.canManage,local:F,onChanged:N})})},U)}return J.id==="slack"&&J.state==="off"&&r.canManage&&J.addable?e.jsx("li",{className:"panel card",children:e.jsx(yb,{card:J,read:r,onSaved:N,problem:p.problem})},U):e.jsxs("li",{className:"panel card",children:[e.jsxs("div",{className:"card-head",children:[e.jsx("h3",{id:`card-${U}`,children:ie}),xo[J.state].tone?e.jsx("span",{className:`badge ${xo[J.state].tone}`,children:xo[J.state].label}):e.jsx("span",{className:"badge",children:xo[J.state].label})]}),X,e.jsx("p",{children:E(U).text}),e.jsx(db,{by:J.enabledBy,at:J.enabledAt}),e.jsx("button",{type:"button",className:"secondary","aria-expanded":f===J.id,"aria-controls":`body-${U}`,onClick:()=>g(f===J.id?null:J.id),children:f===J.id?"Close":J.state==="off"?"Set up":"Manage"}),f===J.id?e.jsxs("div",{id:`body-${U}`,className:"card-body",role:"region","aria-labelledby":`card-${U}`,children:[J.id==="slack"?e.jsx(pg,{card:J,read:r,onSaved:N,added:p.added}):null,J.id==="tracker"?e.jsx(kb,{card:J,canManage:r.canManage,onSaved:N,repos:s,local:F}):null,J.id==="orchestrator-mcp"?e.jsx(wb,{card:J,repos:s,onOpened:N}):null,J.id==="tracker"&&(((Z=J.config)==null?void 0:Z.kind)??"jira")==="jira"?e.jsx(gb,{on:r.writes,canManage:r.canManage,onChanged:N}):null]}):null]},U)};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."}),r!=null&&r.claudeCodeServers?e.jsx("p",{className:"muted",children:r.claudeCodeServers===1?"Your tasks use the MCP server in your Claude Code.":`Your tasks use the ${r.claudeCodeServers} MCP servers in your Claude Code.`}):null]}),j?e.jsxs("p",{className:"error",role:"alert",children:["GitLab or GitHub did not connect: ",lr(j)," Press Connect with GitLab or Connect with GitHub to try again."]}):null,r?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:d,onChange:U=>u(U.target.value)})]}),i?e.jsx(Oo,{what:"integrations",reason:i,onRetry:N}):null,A||M.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."}),r.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:[A?e.jsx("li",{className:"panel card",children:e.jsx(pb,{read:r,onToken:()=>{g("tracker"),requestAnimationFrame(()=>{var U;return(U=document.getElementById("card-tracker"))==null?void 0:U.scrollIntoView({block:"start"})})}})}):null,M.map(U=>e.jsx("li",{className:"panel card",children:e.jsx(fb,{service:U,signIn:r.signIn,onTools:()=>{k(!0),requestAnimationFrame(()=>{var ie;return(ie=document.getElementById("card-mine"))==null?void 0:ie.scrollIntoView({block:"start"})})}})},U.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:()=>{k(!0),requestAnimationFrame(()=>{var U;return(U=document.getElementById("card-mine"))==null?void 0:U.scrollIntoView({block:"start"})})},children:"Your MCP servers"}),"."]})]}):null,!Q.length&&!A&&!M.length?e.jsxs("p",{className:"muted",children:['No integration matches "',d,'".']}):Q.map(U=>e.jsxs("section",{className:"integration-group","aria-labelledby":`group-${U.id}`,children:[e.jsx("h2",{id:`group-${U.id}`,children:U.title}),e.jsx("p",{className:"muted",children:U.text}),e.jsx("ul",{className:"cards",children:U.cards.map(H)})]},U.id))]}):i?e.jsx(ve,{what:"integrations",reason:i,onRetry:N,panel:!0}):e.jsx(fe,{what:"integrations",panel:!0})]})}const mb="See your Jira boards on Work and start agents on their issues. Nothing in Jira changes.";function pb({read:t,onToken:s}){var j,y;const r=t.integrations.find(k=>k.id==="tracker"),l=(j=t.jira.mcp)!=null&&j.connected?`mcp:${t.jira.mcp.name}`:((y=r==null?void 0:r.config)==null?void 0:y.kind)==="jira"&&r.token?"tracker":null,[i,c]=m.useState(null),[d,u]=m.useState(null),[p,f]=m.useState(!1);m.useEffect(()=>{l&&Zt.boards(l).then(k=>c(k.boards.length),()=>c(null))},[l]);const g=()=>{f(!0),u(null),Lt.signInJira().then(k=>window.location.assign(k),k=>{u(k.message),f(!1)})};return e.jsx(ar,{id:"jira",name:"Jira",level:3,connected:!!l,about:l?`${l==="tracker"?"Read with an API token.":"Read through Atlassian as you."}${i===null?"":` ${i} ${i===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:ce("work"),children:"Open Work"}):e.jsx("button",{type:"button",disabled:p||!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:s,children:"Use an API token instead"})]}):void 0,error:d})}function fb({service:t,signIn:s,onTools:r}){var g,j;const[l,i]=m.useState(!1),[c,d]=m.useState(null),u=!!((g=t.server)!=null&&g.connected),p=()=>{i(!0),d(null),Lt.signInCatalog(t.id).then(y=>window.location.assign(y),y=>{d(`${y.message} Add it with a token under Your MCP servers instead.`),i(!1)})},f=((j=t.server)==null?void 0:j.tools)??0;return e.jsx(ar,{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:r,children:"Choose tools"}):e.jsxs("button",{type:"button",className:"secondary",disabled:l||!s,"aria-describedby":s?void 0:"start-no-return",onClick:p,children:["Sign in with ",t.name]}),error:c})}function gb({on:t,canManage:s,onChanged:r}){const l=m.useId(),[i,c]=m.useState(!1),[d,u]=m.useState(null),p=()=>{c(!0),u(null),Lt.saveWrites(!t).then(r,g=>u(g.message)).finally(()=>c(!1))},f=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":l,disabled:i||!s,onClick:p,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:l,className:"muted small",children:[f,s?"":" An owner or an admin turns it on."]}),d?e.jsx("p",{className:"error",role:"alert",children:d}):null]})}function Ba(t){return t.startsWith("file://")||t.startsWith("/")}function xb(t){if(Ba(t))return null;let s;try{s=new URL(t)}catch{return null}if(s.protocol!=="https:")return null;const r=s.pathname.replace(/^\/+|\/+$/g,"").replace(/\.git$/,"");return r.includes("/")?s.hostname==="github.com"?{kind:"github",apiUrl:"https://api.github.com",project:r}:{kind:"gitlab",apiUrl:`${s.origin}/api/v4`,project:r}:null}function jb({card:t,forges:s,repos:r,canManage:l,local:i,onChanged:c}){const d=et[t.id].label,[u,p]=m.useState(null),f=r.filter(k=>k.configured!==!1),g=k=>{const N=s.flatMap(w=>w.repos.map(b=>({...b,kind:w.id}))).find(w=>w.repoId===k.id);return N?`${et[N.kind].label}${N.project?`, ${N.project}`:""}`:Ba(k.url)?"The orchestrator's own copy":"Nowhere yet: no token is set"},j=l&&!i?e.jsxs(e.Fragment,{children:[e.jsx(Kw,{kind:t.id}),e.jsx(Vw,{kind:t.id,repos:r,onChanged:c})]}):null;if(!f.length)return e.jsxs(e.Fragment,{children:[j,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(k=>Ba(k.url));return e.jsxs(e.Fragment,{children:[j,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(k=>e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:k.name}),e.jsx("td",{children:Ba(k.url)?i?"A path on this machine":"A path on the server":new URL(k.url).host}),e.jsx("td",{children:g(k)}),l?e.jsx("td",{children:Ba(k.url)?null:e.jsx("button",{type:"button",className:"secondary small","aria-expanded":u===k.id,onClick:()=>p(u===k.id?null:k.id),"aria-label":`Set up ${d} for ${k.name}`,children:u===k.id?"Close":"Set up"})}):null]},k.id))})]}),u?(()=>{const k=f.find(w=>w.id===u),N=xb(k.url);return e.jsx(Fk,{repo:k,...N?{suggest:N}:{}},k.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(k=>k.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://${et[t.id].homeHosts[0]}/<${et[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 hg({error:t,id:s}){return t?e.jsx("p",{className:"error",role:"alert",id:s,children:t}):null}function mg(t){const[s,r]=m.useState(null),[l,i]=m.useState(null),[c,d]=m.useState(!1);return{error:s,notice:l,busy:c,run:(f,g)=>{r(null),i(null),d(!0),f().then(()=>{d(!1),i(g),t()},j=>{d(!1),r(j.message)})},done:f=>{r(null),i(f),t()},setNotice:i,setError:r}}function yb({card:t,read:s,onSaved:r,problem:l}){const[i,c]=m.useState(!1),[d,u]=m.useState(l),p=()=>{c(!0),u(null),Lt.addSlack().then(f=>window.location.assign(f),f=>{u(f.message),c(!1)})};return e.jsx(ar,{id:"slack",name:"Slack",level:3,connected:!1,about:Xu.slack.text,action:e.jsx("button",{type:"button",disabled:i,onClick:p,children:"Add to Slack"}),other:e.jsx(pg,{card:t,read:s,onSaved:r,added:!1}),error:d})}function pg({card:t,read:s,onSaved:r,added:l}){const[i,c]=m.useState(""),[d,u]=m.useState(t.events.length?t.events:s.slackEvents.map(y=>y.kind)),p=mg(r),f=m.useId();if(!s.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(),p.run(()=>Lt.saveSlack({...i?{webhookUrl:i}:{},events:d}).finally(()=>c("")),"Saved. The webhook address is sealed; the orchestrator never shows it again.")},j=y=>u(d.includes(y)?d.filter(k=>k!==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:i,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":p.error?f:void 0})]}),e.jsxs("fieldset",{className:"teams",children:[e.jsx("legend",{children:"Post when"}),s.slackEvents.map(y=>e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:d.includes(y.kind),onChange:()=>j(y.kind)}),y.label]},y.kind))]}),t.delivery?e.jsxs("p",{className:t.delivery.ok?"muted":"error",children:["Last message ",qo(t.delivery.at),": ",t.delivery.detail]}):null,s.vault?null:e.jsx("p",{className:"error",children:"Set ORCHESTRATOR_SECRET_KEY on the server to store a webhook address."}),e.jsx(hg,{error:p.error,id:f}),p.notice?e.jsx("p",{role:"status",children:p.notice}):null,e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",disabled:p.busy||!s.vault,children:"Save"}),t.state!=="off"?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"secondary",disabled:p.busy,onClick:()=>p.run(Lt.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:()=>Lt.removeSlack().then(()=>p.done("Slack is disconnected and its webhook address removed."))})]}):null]})]})}function vb({repos:t}){const[s,r]=m.useState(null),[l,i]=m.useState(null),[c,d]=m.useState(null),[u,p]=m.useState(null),f=()=>{p(null),B("GET","/api/work/boards/teams").then(y=>r(y.boards),y=>p(y.message))};m.useEffect(()=>{f()},[]);const g=[...new Set(t.map(y=>y.team))].sort(),j=(y,k)=>{i(null),B("PUT","/api/work/boards/teams",{boards:[{boardId:y.boardId,team:k||null}]}).then(N=>{r(N.boards),d(k?`${y.name} is shown to ${k}.`:`${y.name} is shown to owners and admins only.`)},N=>i(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,s?s.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:s.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:k=>j(y,k.target.value),children:[e.jsx("option",{value:"",children:"None: owners and admins only"}),g.map(k=>e.jsx("option",{value:k,children:k},k))]})})]},y.boardId))})]}):e.jsx("p",{className:"muted",children:"The tracker lists no board for the organization yet."}):u?e.jsx(ve,{what:"the boards",reason:u,onRetry:f}):e.jsx(fe,{what:"the boards"})]})}function kb({card:t,canManage:s,onSaved:r,repos:l,local:i}){const[c,d]=m.useState(t.config??{kind:"jira",url:""}),[u,p]=m.useState(""),f=mg(r),g=m.useId(),j=t.token?e.jsxs("p",{children:["Issues are read with a token set by ",t.token.setBy," on ",qo(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(!s)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?j:null]});const y=k=>{k.preventDefault(),f.run(()=>Lt.saveTracker({...c,...u?{token:u}:{}}).finally(()=>p("")),"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:k=>d({kind:k,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:k=>d({...c,url:k.target.value}),placeholder:c.kind==="jira"?"https://acme.atlassian.net":c.kind==="linear"?"https://linear.app/acme":`https://${et[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:k=>d({...c,email:k.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:k=>p(k.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?j:null,t.config&&t.token&&!i?e.jsx(vb,{repos:l}):null,e.jsx(hg,{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",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:()=>Lt.removeTracker().then(()=>f.done("The issue tracker is disconnected and its token removed."))}):null]})]})}function wb({card:t,repos:s,onOpened:r}){var p;const[l,i]=m.useState(null),[c,d]=m.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=s.find(j=>j.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}, ${qo(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:()=>i(f.repoId),children:"Set up"}):null})]},f.repoId)})})]}),l?e.jsx(Tn,{repoId:l,head:((p=s.find(f=>f.id===l))==null?void 0:p.head)??"",steps:{proposal:()=>Lt.mcpProposal(l),send:(f,g)=>{var j;return Lt.proposeMcp(l,((j=s.find(y=>y.id===l))==null?void 0:j.head)??"",f,g)}},submitLabel:"Review the request",onOpened:f=>{i(null),d(Qu(f)),r()},onCancel:()=>i(null),children:()=>{var f;return e.jsxs(e.Fragment,{children:[e.jsxs("h4",{children:["Add the orchestrator's MCP server to ",(f=s.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 bb=["ArrowDown","ArrowUp","Home","End"];function Cu(t){var i;if(!bb.includes(t.key))return;const s=[...t.currentTarget.querySelectorAll('[role="option"]')];if(!s.length)return;t.preventDefault();const r=s.indexOf(document.activeElement),l=t.key==="Home"?0:t.key==="End"?s.length-1:Math.min(Math.max(r+(t.key==="ArrowDown"?1:-1),0),s.length-1);(i=s[l])==null||i.focus()}function fg(t,s){return(s>=0?t===s:t===0)?0:-1}const nr=(t,s="")=>`/api/projects/${encodeURIComponent(t)}${s}`,Ms={read:t=>B("GET",nr(t,"/task-tools")),addSource:(t,s)=>B("POST",nr(t,"/skill-sources"),s).then(r=>r.source),refresh:(t,s)=>B("POST",nr(t,`/skill-sources/${encodeURIComponent(s)}/refresh`)).then(r=>r.source),removeSource:(t,s)=>B("DELETE",nr(t,`/skill-sources/${encodeURIComponent(s)}`)),addServer:(t,s)=>B("POST",nr(t,"/mcp-servers"),s).then(r=>r.server),removeServer:(t,s)=>B("DELETE",nr(t,`/mcp-servers/${encodeURIComponent(s)}`)),skills:t=>B("GET",nr(t,"/task-skills"))};function Nb(t){return t.kind==="folder"?t.path:t.url}function Sb(t){const s=t.trim();return/^(~|\/)/.test(s)?{folder:s}:{url:s}}function Cb(t){const s={};for(const r of t.split(`
|
|
67
|
-
`)){const l=r.indexOf("="),i=(l<0?r:r.slice(0,l)).trim();i&&(s[i]=l<0?"":r.slice(l+1).trim())}return s}function gg({project:t,onAdded:s,onCancel:r}){const[l,i]=m.useState(""),[c,d]=m.useState(!1),[u,p]=m.useState(null),f=g=>{g.preventDefault(),d(!0),p(null),Ms.addSource(t,Sb(l)).then(j=>{i(""),s(j)},j=>p(j.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=>i(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:r,disabled:c,children:"Cancel"})]}),u?e.jsx("p",{className:"error",role:"alert",children:u}):null]})}function $b({project:t,onAdded:s,onCancel:r}){const[l,i]=m.useState("command"),[c,d]=m.useState(""),[u,p]=m.useState(""),[f,g]=m.useState(""),[j,y]=m.useState(""),[k,N]=m.useState(""),[w,b]=m.useState(!1),[$,R]=m.useState(null),T=C=>{C.preventDefault(),b(!0),R(null);const E=Cb(k),O=Object.keys(E).length?E:void 0,F=l==="command"?{name:c.trim(),command:u.trim(),...f.trim()?{args:f.trim().split(/\s+/)}:{},...O?{env:O}:{}}:{name:c.trim(),url:j.trim(),...O?{headers:O}:{}};Ms.addServer(t,F).then(L=>{d(""),p(""),g(""),y(""),N(""),s(L)},L=>R(L.message)).finally(()=>b(!1))};return e.jsxs("form",{className:"form",onSubmit:T,"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=>i(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=>p(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:j,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:k,onChange:C=>N(C.target.value),rows:2,autoComplete:"off",spellCheck:!1})]}),$?e.jsx("p",{className:"error",role:"alert",children:$}):null,e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",className:"secondary",disabled:w,children:"Add the MCP server"}),e.jsx("button",{type:"button",className:"ghost",onClick:r,disabled:w,children:"Cancel"})]})]})}function Zu({project:t,canChange:s}){const[r,l]=m.useState(null),[i,c]=m.useState(null),[d,u]=m.useState(null),[p,f]=m.useState(0),[g,j]=m.useState(!1),[y,k]=m.useState(null),[N,w]=m.useState(null),[b,$]=m.useState(null);m.useEffect(()=>{u(null),Ms.read(t).then(A=>{l(A.skillSources),c(A.mcpServers)},A=>u(A.message))},[t,p]);const R=()=>f(A=>A+1),T=(N==null?void 0:N.kind)==="source"?(r==null?void 0:r.find(A=>A.id===N.id))??null:null,C=(N==null?void 0:N.kind)==="server"?(i==null?void 0:i.find(A=>A.id===N.id))??null:null,E=(A,M)=>w((N==null?void 0:N.kind)===A&&N.id===M?null:{kind:A,id:M}),O=(A,M,Q,H)=>({className:"tool-row",role:"option",tabIndex:fg(Q,(N==null?void 0:N.kind)===A?H.findIndex(U=>U.id===N.id):-1),"aria-selected":(N==null?void 0:N.kind)===A&&N.id===M,onClick:()=>E(A,M),onKeyDown:U=>{U.key!=="Enter"&&U.key!==" "||(U.preventDefault(),E(A,M))}}),F=()=>{w(null),R()},L=(r??[]).filter(A=>A.kind==="git"),W=()=>{j(!0),k(null),Promise.all(L.map(A=>Ms.refresh(t,A.id))).then(()=>{k(`Read ${L.length===1?"the git repository":`${L.length} git repositories`} again.`),R()},A=>u(A.message)).finally(()=>j(!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(Ee,{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."}),s?T?e.jsx(qe,{small:!0,trigger:"Remove…",triggerLabel:`Remove ${T.name}`,consequence:`Tasks here stop reading the skills of ${T.name}. ${T.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:()=>Ms.removeSource(t,T.id).then(F)},T.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:()=>Ms.removeServer(t,C.id).then(F)},C.id):null:null]}),d?e.jsx(ve,{what:"the skills and MCP servers",reason:d,onRetry:R}):!r||!i?e.jsx(fe,{what:"the skills and MCP servers"}):e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:"Skill repositories"}),r.length?e.jsx("ul",{className:"tool-list",role:"listbox","aria-label":"Skill repositories",onKeyDown:Cu,children:r.map((A,M)=>e.jsxs("li",{...O("source",A.id,M,r),children:[A.name," ",e.jsx("span",{className:"mono",dir:"auto",children:Nb(A)})," ",e.jsxs("span",{className:"muted",children:[A.skills.length," ",A.skills.length===1?"skill":"skills"]})]},A.id))}):e.jsx("p",{className:"muted",children:"No skill repository yet."}),s&&L.length?e.jsx("p",{children:e.jsx("button",{type:"button",className:"ghost small",disabled:g,onClick:W,children:g?"Reading…":"Read the git repositories again"})}):null,y?e.jsx("p",{className:"notice",role:"status",children:y}):null,s?b==="source"?e.jsx(gg,{project:t,onCancel:()=>$(null),onAdded:A=>{$(null),k(`Added ${A.name}: ${A.skills.length} ${A.skills.length===1?"skill":"skills"} for tasks here.`),R()}}):e.jsx("p",{children:e.jsx("button",{type:"button",className:"secondary small",onClick:()=>$("source"),children:"Add a skill repository"})}):null,e.jsx("h3",{children:"MCP servers"}),i.length?e.jsx("ul",{className:"tool-list",role:"listbox","aria-label":"MCP servers",onKeyDown:Cu,children:i.map((A,M)=>{const Q=A.transport==="stdio"?A.env:A.headers;return e.jsxs("li",{...O("server",A.id,M,i),children:[A.name," ",e.jsx("span",{className:"mono",dir:"auto",children:A.transport==="stdio"?[A.command,...A.args].join(" "):A.url}),Q.length?e.jsxs("span",{className:"muted",children:[" with ",Q.join(", ")]}):null]},A.id)})}):e.jsx("p",{className:"muted",children:"No MCP server yet."}),s?b==="server"?e.jsx($b,{project:t,onCancel:()=>$(null),onAdded:A=>{$(null),k(`Added ${A.name} for tasks here.`),R()}}):e.jsx("p",{children:e.jsx("button",{type:"button",className:"secondary small",onClick:()=>$("server"),children:"Add an MCP server"})}):null]})]})}function Tb({repo:t,onRenamed:s}){const[r,l]=m.useState(t.name),[i,c]=m.useState(!1),[d,u]=m.useState(null),[p,f]=m.useState(null),g=j=>{j.preventDefault(),c(!0),u(null),f(null),Je.rename(t.id,r).then(({project:y})=>{l(y.name),f(`The project is now named ${y.name}.`),s()},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:r,onChange:j=>l(j.target.value),maxLength:80,required:!0})]}),e.jsx("button",{type:"submit",className:"secondary",disabled:i||!r.trim()||r.trim()===t.name,children:"Rename"})]}),d?e.jsx("p",{className:"error",role:"alert",children:d}):null,p?e.jsx("p",{className:"notice",role:"status",children:p}):null]})}function Eb({repo:t,onChanged:s}){const[r,l]=m.useState(null),[i,c]=m.useState(t.skillsFrom??""),[d,u]=m.useState(!1),[p,f]=m.useState(null),[g,j]=m.useState(null);m.useEffect(()=>{Ne.repos().then(k=>l(k.filter(N=>N.kind!=="code"&&N.id!==t.id&&N.configured!==!1)),k=>f(k.message))},[t.id]);const y=k=>{const N=i;c(k),u(!0),f(null),j(null),Je.readSkillsFrom(t.id,k||null).then(()=>{const w=r==null?void 0:r.find(b=>b.id===k);j(w?`Tasks in ${t.name} read the skills of ${w.name}.`:`Tasks in ${t.name} read no team's skills.`),s()},w=>{c(N),f(w.message)}).finally(()=>u(!1))};return e.jsxs(e.Fragment,{children:[r?e.jsx(Pe,{label:"Skills its tasks read",value:i,onChange:y,disabled:d,options:[{value:"",label:"None"},...r.map(k=>({value:k.id,label:k.name}))]}):p?null:e.jsx(fe,{what:"the skills projects"}),p?e.jsx("p",{className:"error",role:"alert",children:p}):null,g?e.jsx("p",{className:"notice",role:"status",children:g}):null]})}function Rb({repo:t,onMade:s}){const[r,l]=m.useState(!1),[i,c]=m.useState(null),d=()=>{l(!0),c(null),Je.gitInit(t.id).then(s,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:r,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."}),i?e.jsx("p",{className:"error",role:"alert",children:i}):null]})}function xg({repo:t,me:s,git:r,onChanged:l}){const i=Ie(s)&&t.configured!==!1;return e.jsxs("section",{className:"panel","aria-labelledby":"project-h",children:[e.jsxs("h2",{id:"project-h",children:["Project ",e.jsx(Ee,{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}):i?e.jsx(Tb,{repo:t,onRenamed:l}):e.jsx("p",{children:t.name}),t.kind==="code"&&t.source!=="file"&&i?e.jsx(Eb,{repo:t,onChanged:l}):null,r==="none"&&i?e.jsx(Rb,{repo:t,onMade:l}):null,r&&r!=="none"?e.jsx("p",{className:"muted",children:"This folder is a Git repository: a task's review offers to commit what it changed."}):null,Ie(s)&&t.source==="orchestrator"?e.jsx("div",{className:"actions",children:e.jsx(qe,{danger:!0,trigger:"Remove project…",consequence:s.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:()=>Ne.disconnect(t.id).then(()=>Ue(`${ce("tasks")}?removed=${encodeURIComponent(t.name)}`))})}):null]})}function Pb({repo:t,data:s,me:r,editable:l,onOpened:i,onRenamed:c}){const d=r.mode==="local",{inventory:u}=s,p=u.team,[f,g]=m.useState(null),j=N=>{g(null),i(N)},y=N=>{g(null),i(N,`Request #${N.number} opened on ${N.branch}. Nothing is reported until it is merged and each teammate agrees on their own machine.`)},k={repoId:t.id,head:u.head,onOpened:j,onCancel:()=>g(null)};return e.jsxs(e.Fragment,{children:[e.jsx(xg,{repo:t,me:r,onChanged:c}),e.jsx(Zu,{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&&!(p!=null&&p.problem)?e.jsx("button",{type:"button",className:"secondary small",onClick:()=>g({type:"naming"}),children:"Edit naming"}):null,l&&!(p!=null&&p.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(Pk,{...k,team:p}):null,(f==null?void 0:f.type)==="team"?e.jsx(Rk,{...k,team:p}):null,p?p.problem?e.jsx("p",{className:"error",children:p.problem}):e.jsxs("dl",{className:"facts wide",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Commit prefix"}),e.jsx("dd",{className:"mono",children:p.commitPrefixProblem?"not used, see Setup":p.commitPrefix||"none"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Branch example"}),e.jsx("dd",{className:"mono",children:p.branchExample||"none"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Reviewers"}),e.jsx("dd",{children:p.reviewers===void 0?"not recorded":p.reviewers.join(", ")||"none"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Labels"}),e.jsx("dd",{children:p.labels===void 0?"not recorded":p.labels.join(", ")||"none"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"TeamHandbook's files"}),e.jsx("dd",{children:p.scaffoldVersion?`written by TeamHandbook ${p.scaffoldVersion}`:"version not recorded"})]}),d?null:e.jsxs("div",{children:[e.jsx("dt",{children:"Skill use"}),e.jsx("dd",{children:p.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(Ek,{repoId:t.id,head:u.head,action:f.action,onOpened:f.action==="ask"?y:j,onCancel:()=>g(null)},f.action):null,l&&!d&&(f==null?void 0:f.type)!=="usage"&&!(p!=null&&p.problem)?p!=null&&p.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]}),Ie(r)?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:ce("integrations",t.id),children:"Integrations"}),"."]})]}):null]})}const Ab={google:"Google",github:"GitHub",microsoft:"Microsoft"},Ib={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 Ob(t){return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function Lb({token:t,onJoined:s,cloud:r}){const[l,i]=m.useState(null),[c,d]=m.useState(null),[u,p]=m.useState({name:"",password:""}),[f,g]=m.useState(null),[j,y]=m.useState(!1),k=m.useId();m.useEffect(()=>{qm.read(t).then(R=>i({...R.invite,org:R.org,sso:R.sso,signedIn:R.signedIn,emailMatches:R.emailMatches}),R=>d(R.message))},[t]);const N=()=>{y(!0),g(null),rt.me().then(R=>rt.join(t,R.csrf)).then(R=>window.location.assign(R.next),R=>{g(R.message),y(!1)})},w=R=>{R.preventDefault(),y(!0),g(null),qm.accept(t,u).then(()=>{window.location.hash="/",s()},T=>{g(T.message),y(!1)})},b=f?{"aria-invalid":!0,"aria-describedby":k}:{},$=r?"section":"form";return e.jsx("main",{className:"gate",children:e.jsxs($,{className:"panel form",onSubmit:r?void 0:w,"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&&r?e.jsx(Qa,{config:r}):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 ",hr[l.role],l.teams.length?`, team owner of ${l.teams.join(", ")}`:"","."]}),e.jsxs("p",{children:[Ib[l.role]," ",e.jsxs(Ee,{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 ",Ob(l.expiresAt),"."]})]}),r&&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:j,children:["Join ",l.org]}),e.jsx(Eo,{privacyUrl:r.privacyUrl,termsUrl:r.termsUrl})]}):r?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}.`}),r.providers.map(R=>e.jsxs("form",{method:"post",action:`/api/auth/${R}/start`,children:[e.jsx("input",{type:"hidden",name:"invite",value:t}),e.jsxs("button",{type:"submit",children:["Sign in with ",Ab[R]]})]},R)),e.jsx(Qa,{config:r}),e.jsx(Eo,{privacyUrl:r.privacyUrl,termsUrl:r.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:ir("/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:R=>p({...u,name:R.target.value}),...b})]}),e.jsxs("label",{children:["Password",e.jsx("input",{type:"password",autoComplete:"new-password",minLength:12,value:u.password,onChange:R=>p({...u,password:R.target.value}),required:!0,...b})]}),f?e.jsx("p",{className:"error",role:"alert",id:k,children:f}):null,e.jsx("button",{type:"submit",disabled:j,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:ir("/api/auth/oidc/start"),children:"Sign in with SSO"})]}):null]})]}):null]})})}function Za({name:t,why:s,danger:r=!1,children:l}){const i=m.useId();return e.jsxs("section",{className:`turn${r?" turn-danger":""}`,"aria-labelledby":i,children:[e.jsxs("div",{className:"turn-side",children:[e.jsx("h2",{id:i,children:t}),s?e.jsx("p",{className:"turn-why",children:s}):null]}),e.jsx("div",{className:"turn-body",children:l})]})}const jg="#/account-deleted";function Fb(t){const[s,r]=m.useState(null);return m.useEffect(()=>{So.orgs().then(l=>r({orgs:l.orgs.length?l.orgs:[{tenant:l.default,name:"this organization",role:t.role}],defaultOrg:l.default}),()=>r({orgs:[{tenant:"",name:"this organization",role:t.role}],defaultOrg:""}))},[t.id]),s}function Mb({me:t,orgs:s,defaultOrg:r,onRenamed:l}){const[i,c]=m.useState(t.name),[d,u]=m.useState(null),[p,f]=m.useState(null),g=m.useId(),j=y=>{y.preventDefault(),u(null),f(null),Promise.all(s.map(k=>So.rename(k.tenant,r,i))).then(()=>{f(s.length>1?`Your name is ${i.trim()} in each of your ${s.length} organizations.`:`Your name is ${i.trim()}.`),l()},k=>u(k.message))};return e.jsxs(Za,{name:"Name",why:"How every organization you belong to shows you.",children:[e.jsxs("form",{className:"form inline-form",onSubmit:j,"aria-label":"Your name",children:[e.jsxs("label",{children:["Name",e.jsx("input",{autoComplete:"name",value:i,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,p?e.jsx("p",{className:"notice",role:"status",children:p}):null]})}function _b({me:t,orgs:s,defaultOrg:r}){const[l,i]=m.useState(null),[c,d]=m.useState(""),[u,p]=m.useState(null),[f,g]=m.useState(!1),j=m.useId(),y=()=>{p(null),Promise.all(s.map(async w=>({org:w,summary:await So.summary(w.tenant,r)}))).then(i,w=>p(`Couldn't read what deleting your account removes. ${w.message}`))},k=(l==null?void 0:l.filter(w=>w.summary.blocked))??[],N=w=>{w.preventDefault(),g(!0),p(null),[...s].sort(($,R)=>+($.tenant===r)-+(R.tenant===r)).reduce(($,R)=>$.then(()=>So.remove(R.tenant,r,c)),Promise.resolve()).then(()=>window.location.replace(`/${jg}`),$=>{p($.message),g(!1)})};return e.jsxs(Za,{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:w,summary:b})=>e.jsxs("li",{children:[e.jsx("strong",{children:w.name}),": ",hr[b.role],b.ownedTeams.length?`, owns ${b.ownedTeams.join(", ")}`:"","; ",b.activeKeys," active API key",b.activeKeys===1?"":"s"," revoked; ",b.openRequests," open request",b.openRequests===1?"":"s"," stay for review",b.unfinishedTasks.length?`; ${b.unfinishedTasks.length} task${b.unfinishedTasks.length===1?"":"s"} still running (${b.unfinishedTasks.map($=>$.title).join(", ")}) finish and open a request for review`:"",b.blocked?e.jsx("div",{className:"error",children:b.blocked}):null]},w.tenant||"this"))}),k.length?e.jsxs("p",{className:"error",children:["Your account cannot be deleted while you are the only owner of ",k.map(w=>w.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:w=>d(w.target.value),required:!0,"aria-describedby":u?j: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:()=>i(null),children:"Keep my account"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Your account is removed from ",s.length>1?`each of the ${s.length} organizations you are signed in to`:"this organization",", with its sessions and API keys. ",e.jsx(Ee,{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:j,children:u}):null]})}const Dn={google:"Google",github:"GitHub",microsoft:"Microsoft"};function Db(){const[t,s]=m.useState(null),[r,l]=m.useState(null),[i,c]=m.useState(null),[d,u]=m.useState(!1),[p,f]=m.useState(null),g=new URLSearchParams(window.location.search),j=g.get("linked"),y=g.get("link-problem"),k=g.get("link-confirm"),[N,w]=m.useState(null),[b,$]=m.useState(null),R=()=>rt.me().then(s,L=>c(L.message));m.useEffect(()=>{R(),k&&rt.awaitingLogin(k).then(w,L=>c(L.message)),rt.config().then(L=>l(L&&"providers"in L?L:null),()=>l(null))},[]);const T=L=>{L instanceof ut&&L.code==="reauth"?u(!0):c(L.message)},C=()=>{c(null),rt.confirmLogin(k,t.csrf).then(({provider:L})=>(w(null),$(L),window.history.replaceState(null,"",window.location.pathname),R()),T)},E=L=>{c(null),rt.addLogin(L,t.csrf).then(({url:W})=>window.location.assign(W),T)};if(!t)return i?e.jsx(Za,{name:"How you sign in",children:e.jsx(ve,{what:"how you sign in",reason:i,onRetry:()=>{c(null),R()}})}):null;const O=new Set(t.logins.map(L=>L.provider)),F=((r==null?void 0:r.providers)??[]).filter(L=>!O.has(L));return e.jsxs(Za,{name:"How you sign in",why:"Only an account under your own address is added, and never one someone else signs in with.",children:[(b??j)&&Dn[b??j]?e.jsxs("p",{className:"notice",role:"status",children:["You can now sign in with ",Dn[b??j]," too."]}):null,N?e.jsxs("div",{className:"panel problem",role:"alert",children:[e.jsxs("p",{children:["Add the ",Dn[N.provider]," account ",e.jsx("strong",{children:N.email})," only if it is yours: whoever holds it reaches all of your organizations. ",e.jsxs(Ee,{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:()=>{w(null),window.history.replaceState(null,"",window.location.pathname)},children:"Do not add it"})]})]}):null,y?e.jsx("p",{className:"error",role:"alert",children:du(y)}):null,i?e.jsx("p",{className:"error",role:"alert",children:i}):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 ",Dn[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(L=>e.jsxs("tr",{children:[e.jsxs("td",{children:[Dn[L.provider],L.provider===t.identity.signedInWith?e.jsx("span",{className:"muted",children:" (this sign-in)"}):null]}),e.jsx("td",{children:L.email})]},L.provider))})]}),e.jsxs("div",{className:"actions",children:[F.map(L=>e.jsxs("button",{type:"button",className:"secondary",onClick:()=>E(L),children:["Add ",Dn[L]]},L)),t.logins.length>1?e.jsxs(e.Fragment,{children:[e.jsx(Pe,{label:"Stop signing in with",value:p??t.logins[0].provider,onChange:L=>f(L),options:t.logins.map(L=>({value:L.provider,label:Dn[L.provider]}))}),e.jsx(qe,{trigger:`Remove ${Dn[p??t.logins[0].provider]}…`,triggerLabel:`Remove ${Dn[p??t.logins[0].provider]} as a way to sign in`,consequence:`You no longer sign in with ${Dn[p??t.logins[0].provider]}.`,confirm:"Remove",keep:"Keep it",onConfirm:()=>rt.removeLogin(p??t.logins[0].provider,t.csrf).then(()=>(f(null),R()),T)})]}):null]})]})}function Ub(t,s){if(t.mode==="local")return"This orchestrator is yours; nobody signs in to it.";const r=hr[t.role].toLowerCase();return`Signed in as ${t.email}, ${/^[aeiou]/.test(r)?"an":"a"} ${r} here${s>1?` and in ${s-1} other organization${s===2?"":"s"}`:""}.`}function qb({me:t,nav:s,onChanged:r}){const l=Fb(t);return e.jsxs(e.Fragment,{children:[e.jsx(Cn,{title:"Your account",summary:l?Ub(t,l.orgs.length):void 0}),s,l?e.jsxs(e.Fragment,{children:[e.jsx(Mb,{me:t,orgs:l.orgs,defaultOrg:l.defaultOrg,onRenamed:r}),t.mode==="cloud"?e.jsx(Db,{}):null,t.mode==="local"?e.jsx(Za,{name:"Your data",why:"It runs on this machine for you alone.",children: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(_b,{me:t,orgs:l.orgs,defaultOrg:l.defaultOrg})]}):e.jsx(fe,{what:"your account"})]})}function Bb(){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 zb={ok:"ok",warn:"warn",fail:"error",unknown:"warn"};function Wb(){const[t,s]=m.useState(null),[r,l]=m.useState(!0),[i,c]=m.useState(null),d=u=>{l(!0),c(null),$e.readiness(u).then(s,p=>c(p.message)).finally(()=>l(!1))};return m.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."}),i?e.jsx("p",{className:"error",children:i}):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(p=>e.jsxs("li",{children:[e.jsx("span",{className:`badge ${zb[p.status]}`,children:p.status}),e.jsx("strong",{children:p.name})," ",p.detail]},p.name))})})]},u.id))})]}):e.jsx("p",{className:"muted",children:r?"Checking…":null}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",onClick:()=>d(!0),disabled:r,children:"Check again"}),t?e.jsxs("span",{className:"muted",children:["Checked at ",t.checkedAt.slice(11,19),"."]}):null]})]})}function Dr(t){return t?new Date(t).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"unknown"}function Hb(){const[t,s]=m.useState(null),[r,l]=m.useState(null),[i,c]=m.useState(null),d=()=>bo.apps().then(s,u=>l(u.message));return m.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(Ee,{label:"approved apps",children:"Taking one back ends its access at once; it asks you to approve it again."})]}),i?e.jsx("p",{className:"notice",role:"status",children:i}):null,r?e.jsx(ve,{what:"the apps you approved",reason:r,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:Dr(u.createdAt)}),e.jsx("td",{children:e.jsx(qe,{small:!0,trigger:"Take back",triggerLabel:`Take back the access of ${u.clientName} approved ${Dr(u.createdAt)}`,consequence:`${u.clientName} stops reaching the orchestrator at its next call.`,confirm:"Take back access",keep:"Keep access",onConfirm:()=>bo.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(fe,{what:"the apps you approved"})]})}function Gb({me:t}){const[s,r]=m.useState(null),[l,i]=m.useState(null),[c,d]=m.useState(null),u=()=>bo.sessions().then(r,p=>i(p.message));return m.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 ",s?e.jsx("span",{className:"count",children:s.length}):null]}),e.jsxs("p",{className:"muted",children:["Each browser you signed in from. ",e.jsx(Ee,{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(ve,{what:"your sessions",reason:l,onRetry:()=>{i(null),u()}}):s?s.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:s.map(p=>e.jsxs("tr",{children:[e.jsxs("td",{children:[p.userAgent??"unknown",p.current?e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{className:"badge ok",children:"this browser"})]}):null]}),e.jsx("td",{children:Dr(p.createdAt)}),e.jsx("td",{children:Dr(p.lastSeenAt)}),e.jsx("td",{children:Dr(p.expiresAt)}),e.jsx("td",{children:e.jsx(qe,{small:!0,trigger:"Sign out there",triggerLabel:`Sign out ${p.userAgent??"an unknown browser"}, signed in ${Dr(p.createdAt)}`,consequence:p.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:()=>bo.end(p.id).then(()=>(p.current&&window.location.assign("/"),d("The session is ended."),u()))})})]},p.id))})]}):e.jsx("p",{className:"muted",children:"No browser is signed in as you."}):e.jsx(fe,{what:"your sessions"})]}),e.jsx(Hb,{}),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:ce("settings","api-keys"),children:"see and revoke your API keys"}),"."]}),Mu(t,"machines")?e.jsxs("p",{className:"muted",children:["Your machines run your tasks; see and remove them on ",e.jsx("a",{href:ce("settings","machines"),children:"Your machines"}),"."]}):null]})]})}const Kb=250,Vb={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."},yg=t=>t===1?"1 repository":`${t} repositories`,Yb=t=>`A folder of ${yg(t)}: each task works on its own branch of each one it changes and ends in a request for review.`;function Qb({entry:t,home:s,selected:r,busy:l,withPath:i,withGit:c,onPick:d,onEnter:u,onBack:p,onFocus:f}){const g=j=>{j.key==="Enter"&&u?(j.preventDefault(),d()):j.key==="ArrowRight"&&u?(j.preventDefault(),u()):(j.key==="ArrowLeft"||j.key==="Backspace")&&p&&(j.preventDefault(),p())};return e.jsx("li",{children:e.jsxs("button",{type:"button",className:"folder-row","aria-selected":r,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}),i?e.jsx("span",{className:"folder-path",dir:"auto",children:ts(t.path,s)}):null]}),c?e.jsx("span",{className:"folder-git",children:t.repos?yg(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 Jb({home:t,onOpened:s,onCancel:r}){const[l,i]=m.useState(""),[c,d]=m.useState(""),[u,p]=m.useState(!1),[f,g]=m.useState(null),j=My(l),y=k=>{k.preventDefault(),p(!0),g(null),Je.clone(l.trim(),c.trim()?Ls(c,t):void 0).then(({project:N})=>s(N,t),N=>{g(N.message),p(!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:k=>i(k.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:k=>d(k.target.value),placeholder:j?`~/code/${j}`:"~/code/<name>",autoComplete:"off",spellCheck:!1})]}),e.jsxs("p",{className:"muted small",children:["Clones into ",c.trim()||(j?`~/code/${j}`:"~/code")," with your own git sign-in. ",e.jsx(Ee,{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:r,disabled:u,children:"Cancel"})]})]})}function ed({onOpened:t,lead:s,selected:r,machine:l,where:i="On this computer",from:c,verb:d="Open"}){var de,se;const[u,p]=m.useState(null),[f,g]=m.useState(null),[j,y]=m.useState((c==null?void 0:c.home)??null),[k,N]=m.useState(c==null?void 0:c.under),[w,b]=m.useState(""),[$,R]=m.useState(null),[T,C]=m.useState(null),[E,O]=m.useState(!1),[F,L]=m.useState(0),[W,A]=m.useState(!1),[M,Q]=m.useState(null),[H,U]=m.useState(null),ie=m.useRef(null),X=w.trim()&&!Fc(w)?w.trim():"",J=Fc(w)?w.trim():"";m.useEffect(()=>{let he=!0;R(null),U(null);const Le=setTimeout(()=>{Je.folders({...k?{under:k}:{},...X?{q:X}:{}},l).then(Ye=>{he&&(p(Ye),g(k),!k&&!X&&y(Ye.under))},Ye=>he&&R(Ye.message))},X?Kb:0);return()=>{he=!1,clearTimeout(Le)}},[k,X,F,l]);const Z=he=>{O(!0),C(null),Je.open(he,l).then(({project:Le})=>t(Le,j,{under:k,home:j}),Le=>C(Le.message)).finally(()=>O(!1))};m.useEffect(()=>{M===null||j===null||(Q(null),Z(Ls(M,j)))},[M,j]);const ae=he=>{var Tt,tt;if(he.key!=="ArrowDown"&&he.key!=="ArrowUp")return;const Le=[...((Tt=ie.current)==null?void 0:Tt.querySelectorAll("button.folder-row"))??[]];if(!Le.length)return;he.preventDefault();const Ye=Le.indexOf(document.activeElement);(tt=Le[Math.min(Math.max(Ye+(he.key==="ArrowDown"?1:-1),0),Le.length-1)])==null||tt.focus()},z=u&&j?Fy(u.under,j):[],P=he=>{b(""),N(he===j?void 0:he)},_=z.length>1?()=>P(z[z.length-2].path):void 0,le=[...(u==null?void 0:u.suggestions)??[],...(u==null?void 0:u.folders)??[],...(u==null?void 0:u.matches)??[]].some(he=>he.git!=="none"||!!he.repos),be=(he,Le,Ye,Tt)=>Le.length?e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"folder-group",children:he}),e.jsx("ul",{className:"folder-list",children:Le.map(tt=>e.jsx(Qb,{entry:tt,home:j,selected:tt.path===((H==null?void 0:H.path)??r),busy:E,withPath:Tt,withGit:le,onPick:()=>Z(tt.path),...Ye?{onEnter:()=>P(tt.path),onFocus:()=>U(tt)}:{},..._?{onBack:_}:{}},tt.path))})]}):null,pe=H??(u&&k&&f===k&&!X?{name:((de=z[z.length-1])==null?void 0:de.label)??u.under,path:u.under}:null);return W?e.jsx(Jb,{home:j,onOpened:(he,Le)=>t(he,Le,{under:k,home:j}),onCancel:()=>A(!1)}):e.jsx("div",{className:"folder-picker",role:"group","aria-label":"Pick a folder",children:e.jsxs("div",{className:"folder-picker-main",children:[s,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:w,onChange:he=>b(he.target.value),autoComplete:"off",spellCheck:!1,onKeyDown:he=>{he.key==="Enter"&&Fc(w)?(he.preventDefault(),j===null&&w.trim().startsWith("~")?Q(w):Z(Ls(w,j))):ae(he)}})]})}),u&&!X&&!J?e.jsxs("p",{className:"folder-place",children:[e.jsx("span",{className:"folder-machine",children:i}),e.jsx("span",{className:"folder-at",dir:"auto",children:ts(u.under,j)}),_?e.jsx("button",{type:"button",className:"ghost small folder-up",onClick:_,children:"Up one folder"}):null]}):null,T?e.jsx("p",{className:"error",role:"alert",children:T}):null,e.jsxs("div",{ref:ie,onKeyDown:ae,children:[J?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:E,onClick:()=>j===null&&J.startsWith("~")?Q(J):Z(Ls(J,j)),children:[e.jsxs("span",{children:[e.jsx("span",{className:"folder-name",dir:"auto",children:J.replace(/\/+$/,"").split("/").pop()||J}),e.jsx("span",{className:"folder-path",dir:"auto",children:ts(Ls(J,j),j)})]}),e.jsx("span",{className:"muted small",children:d==="Add"?"Enter adds it":"Enter opens it"})]})})})]}):$?e.jsx(ve,{what:"your folders",reason:$,onRetry:()=>L(he=>he+1)}):u?X?(se=u.matches)!=null&&se.length?be(`Matching “${X}”`,u.matches,!0,!0):e.jsxs("p",{className:"muted",children:["No folder under home is named like “",X,"”. Paste its path instead."]}):u.folders.length||u.suggestions.length?e.jsxs(e.Fragment,{children:[k?null:be("Suggested",u.suggestions.slice(0,3),!1,!0),be("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(fe,{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:[pe&&!J?e.jsxs(e.Fragment,{children:[pe.git?e.jsx("p",{className:"muted",children:pe.repos?Yb(pe.repos):Vb[pe.git!=="none"?"git":le?"none":"plain"]}):null,e.jsxs("button",{type:"button",disabled:E,onClick:()=>Z(pe.path),children:[d," ",pe.name]})]}):null,l?null:e.jsx("button",{type:"button",className:"link",onClick:()=>A(!0),children:"Clone from GitHub or GitLab"})]})]})})}const Xb={read:(t=null)=>B("GET",`/api/tasks/board${t?`?${new URLSearchParams({repo:t})}`:""}`)};function Zb(t){const s=ur({...t,request:t.request?{status:t.request.status}:null}),{word:r,tone:l}=Qr(s,t.forge);return{label:r,tone:l,state:s}}const eN={review:["review"],answer:["approval","answer"],retry:["failed"],continue:[],"follow-up":["follow-up"]};function tN(t,s){const r=t.next?eN[t.next]:[];return r.length>0&&!r.some(l=>s.has(`${t.id}:${l}`))}function nN(t){const s=t.sections.done.filter(d=>d.phase==="merged"),r=s.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(", "),i=s.length?`${s.length} kept this week${r>0?` for $${r.toFixed(2)}`:""}`:null,c=[l||null,i].filter(Boolean).join("; ");return c?`${c.charAt(0).toUpperCase()}${c.slice(1)}.`:null}function vg(t,s=new Date){const r=new Date(t),l=c=>new Date(c.getFullYear(),c.getMonth(),c.getDate()).getTime(),i=Math.round((l(s)-l(r))/864e5);return i<=0?r.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hourCycle:"h23"}):i===1?"Yesterday":i<7?r.toLocaleDateString(void 0,{weekday:"short"}):r.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function sN({me:t}){return t.mode==="local"?e.jsx(lN,{me:t}):e.jsxs(e.Fragment,{children:[e.jsx(aN,{}),e.jsx(rN,{})]})}function rN(){const[t,s]=m.useState(null);return m.useEffect(()=>{B("GET","/api/team/shared?days=30").then(s,()=>s({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(r=>e.jsxs("li",{children:[e.jsx("span",{className:"mono",dir:"auto",children:r.name||r.slug})," ",e.jsxs("span",{className:"muted",children:["skill, ",r.repoName]})]},`skill-${r.repoName}-${r.slug}`)),t.mcpServers.map(r=>e.jsxs("li",{children:[e.jsx("span",{className:"mono",dir:"auto",children:r.name})," ",e.jsxs("span",{className:"muted",children:["MCP server, ",r.repoName]})]},`mcp-${r.repoName}-${r.name}`))]}):e.jsx("p",{className:"muted",children:"Nothing is shared yet."})]}):e.jsx(fe,{what:"the skills and MCP servers for tasks"})}function aN(){const[t,s]=m.useState(null),[r,l]=m.useState(null),i=()=>Ne.repos().then(c=>s(c.filter(d=>d.configured!==!1&&d.kind!=="skills")),c=>l(c.message));return m.useEffect(()=>{i()},[]),r?e.jsx(ve,{what:"where your code lives",reason:r,onRetry:()=>{l(null),i()}}):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:ce("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:ce("integrations"),children:"Integrations"}),"."]})]}):e.jsx(fe,{what:"where your code lives"})}function lN({me:t}){const[s,r]=m.useState(null),[l,i]=m.useState(null),[c,d]=m.useState(!1),u=()=>Promise.all([Je.workFolders(),Je.list()]).then(([{folders:p},{last:f,home:g}])=>r({folders:p,last:f,home:g??null}),p=>i(p.message));return m.useEffect(()=>{u()},[]),l?e.jsx(ve,{what:"where your code lives",reason:l,onRetry:()=>{i(null),u()}}):s?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"}),s.folders.length?e.jsx("ul",{className:"plain code-folders",children:s.folders.map(p=>e.jsxs("li",{children:[e.jsx("strong",{dir:"auto",children:p.name})," ",e.jsx("span",{className:"mono",dir:"auto",children:ts(p.path,s.home)}),p.usedAt?e.jsxs("span",{className:"muted",children:[" last used ",vg(p.usedAt)]}):null]},p.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(ed,{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"})})]}),s.last?e.jsx(Zu,{project:s.last,canChange:Ie(t)},`tools-${s.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(fe,{what:"where your code lives"})}const kg={repositories:"Repositories",requests:"Requests",tasks:"Tasks",usage:"Usage",members:"Members",settings:"Settings",keys:"This account's API keys"},oN=[{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 gp(t){return t?new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}):"never"}function iN(t){return of.filter(r=>t[r]!=="none").map(r=>`${kg[r]}: ${t[r]}`).join(", ")}function cN({secret:t,onDone:s}){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(Ee,{label:"the key",children:"The orchestrator keeps only its prefix and a hash."})]}),e.jsx(yt,{text:t,label:"Copy key"}),e.jsx("div",{className:"actions",children:e.jsx("button",{type:"button",className:"secondary small",onClick:s,children:"I copied it"})})]})}function uN({serviceAccountId:t,ceiling:s=_j,onCreated:r}){const[l,i]=m.useState(""),[c,d]=m.useState(30),[u,p]=m.useState({repositories:"read",requests:"read"}),[f,g]=m.useState(null),[j,y]=m.useState(!1),k=m.useId(),N=w=>{w.preventDefault(),y(!0),g(null),cr.create({name:l,scopes:u,expiresInDays:c,...t?{serviceAccountId:t}:{}}).then(b=>{i(""),y(!1),r(b.secret)},b=>{g(b.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:w=>i(w.target.value),required:!0,maxLength:80,"aria-describedby":f?k:void 0})]}),e.jsx(Pe,{label:"Expires",value:c===null?"never":String(c),onChange:w=>d(w==="never"?null:Number(w)),options:oN.map(w=>({value:w.days===null?"never":String(w.days),label:w.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."}),of.filter(w=>s[w]!=="none").map(w=>e.jsx(Pe,{label:kg[w],value:u[w]??"none",onChange:b=>p({...u,[w]:b}),options:["none","read","write"].filter(b=>b!=="write"||s[w]==="write").map(b=>({value:b,label:b==="none"?"None":b==="read"?"Read":"Write"}))},w))]}),e.jsxs("p",{className:"muted",children:["A key never manages members, settings or sign-in, nor merges a request. ",e.jsx(Ee,{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:k,children:f}):null,e.jsx("div",{className:"actions",children:e.jsx("button",{type:"submit",disabled:j,children:"Create key"})})]})}function dN({keys:t,label:s,onChanged:r}){return t.length?e.jsx(e.Fragment,{children:e.jsxs("table",{"aria-label":s,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:iN(l.scopes)}),e.jsx("td",{children:l.status==="active"?gp(l.expiresAt):e.jsx("span",{className:"badge warn",children:l.status})}),e.jsx("td",{children:l.lastUsedAt?gp(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:()=>cr.revoke(l.id).then(r)}):null})]},l.id))})]})}):e.jsx("p",{className:"muted",children:"No key yet."})}function wg({serviceAccountId:t,label:s,ceiling:r}){const[l,i]=m.useState(null),[c,d]=m.useState(null),[u,p]=m.useState(null),f=()=>cr.list(t).then(i,g=>p(g.message));return m.useEffect(()=>{f()},[t]),e.jsxs(e.Fragment,{children:[l&&u?e.jsx("p",{className:"error",role:"alert",children:u}):null,c?e.jsx(cN,{secret:c,onDone:()=>d(null)}):null,l?e.jsx(dN,{keys:l,label:s,onChanged:f}):u?e.jsx(ve,{what:"keys",reason:u,onRetry:()=>{p(null),f()}}):e.jsx(fe,{what:"keys"}),e.jsx(uN,{serviceAccountId:t,ceiling:r,onCreated:g=>{d(g),f()}})]})}function hN({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(Ee,{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(wg,{label:"Your API keys",ceiling:t.keyCeiling})]})}function Gc(t){return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function mN({id:t,tags:s,editable:r}){const[l,i]=m.useState(s),[c,d]=m.useState(s.filter(g=>g.source==="manual").map(g=>g.tag).join(" ")),[u,p]=m.useState(null),f=g=>{g.preventDefault(),p(null),No.setTags(t,c.split(/[\s,]+/).filter(Boolean)).then(i,j=>p(j.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"})}),r?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 pN({id:t,me:s,nav:r}){const[l,i]=m.useState(null),[c,d]=m.useState(null),[u,p]=m.useState(0);m.useEffect(()=>{let N=!0;return d(null),Kr.page(t).then(w=>N&&i(w),w=>N&&d(w.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:ce("settings","members"),children:"Members"})}),e.jsx("h1",{children:N})]}),r]});if(c&&!l)return e.jsxs(e.Fragment,{children:[f("Member"),e.jsx(ve,{what:"the member",reason:c,panel:!0,onRetry:()=>p(u+1)})]});if(!l)return e.jsxs(e.Fragment,{children:[f("Member"),e.jsx(fe,{what:"the member",panel:!0})]});const{member:g,requests:j,tasks:y,totals:k}=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:Gc(g.createdAt)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Signs in with"}),e.jsx("dd",{children:Tf(g.signIn)})]})]}),e.jsx(Sv,{user:g,me:s,onChanged:()=>p(u+1),onRemoved:()=>Ue(ce("settings","members"))}),e.jsx("h2",{children:"Tags"}),e.jsx(mN,{id:g.id,tags:l.tags,editable:Ie(s)})]}),e.jsx(rw,{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:k.requests})]}),j.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:j.map(N=>e.jsxs("tr",{children:[e.jsxs("td",{children:["#",N.number," ",N.title]}),e.jsx("td",{children:e.jsx("a",{href:ce("repositories",N.repoId),children:N.repoId})}),e.jsx("td",{children:N.status}),e.jsx("td",{children:Gc(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:k.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:ce("tasks",N.id),children:N.title})}),e.jsx("td",{children:N.repoId}),e.jsx("td",{children:N.status}),e.jsx("td",{children:Gc(N.createdAt)})]},N.id))})]}):e.jsx("p",{className:"muted",children:"No task started yet."})]})]})}const or={list:()=>B("GET","/api/machines"),pair:()=>B("POST","/api/machines/pair"),remove:t=>B("DELETE",`/api/machines/${encodeURIComponent(t)}`)};function bg(t){if(!t.installed)return`${t.label}: not installed`;const s=t.version?` ${t.version}`:"",r=t.supported==="update"?", update it":t.supported==="unsupported"?", too old to run tasks; update it":"";return t.signIn==="signed-in"?`${t.label}${s}: signed in${r}`:t.signIn==="signed-out"?`${t.label}${s}: signed out${r}`:`${t.label}${s}: sign-in not known${r}`}function fN({agentId:t}){const[s,r]=m.useState(null);if(m.useEffect(()=>{let i=!0;return r(null),or.list().then(c=>{var d;return i&&r(((d=c.machines.find(u=>u.local))==null?void 0:d.agents.find(u=>u.id===t))??null)},()=>i&&r(null)),()=>{i=!1}},[t]),!s)return null;const l=s.signIn==="signed-out"&&s.signInCommand;return e.jsxs("p",{className:l?"error":"muted",role:l?"alert":"note","aria-label":`${s.label} sign-in`,children:[bg(s),".",l?e.jsxs(e.Fragment,{children:[" Run ",e.jsx(yt,{text:s.signInCommand,label:`Copy the sign-in command for ${s.label}`})," in a terminal, then start."]}):null]})}const gN=3e3;function xp(t){return t?t.slice(0,16).replace("T"," "):"never"}function xN(){const[t,s]=m.useState(null),[r,l]=m.useState(null),[i,c]=m.useState(!1),[d,u]=m.useState(null),[p,f]=m.useState(null),g=m.useRef(),j=()=>or.list().then(w=>(l(null),s(w.machines),w.machines),w=>(w instanceof ss?c(!0):l(w.message),null));m.useEffect(()=>(j(),()=>clearInterval(g.current)),[]);const y=()=>{f(null),or.pair().then(w=>{u(w);const b=new Set((t??[]).map($=>$.id));clearInterval(g.current),g.current=setInterval(()=>{j().then($=>{($!=null&&$.some(R=>!b.has(R.id))||Date.parse(w.expiresAt)<Date.now())&&(clearInterval(g.current),u(null))})},gN)},w=>f(w.message))};if(i)return e.jsx(ve,{what:"your machines",reason:"This orchestrator does not answer for machines yet; it runs tasks itself.",next:e.jsx("a",{href:ce("tasks"),children:"Start a task"}),panel:!0});if(r)return e.jsx(ve,{what:"your machines",reason:r,onRetry:()=>void j(),panel:!0});if(!t)return e.jsx(fe,{what:"your machines",panel:!0});const k=d?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Run this on the machine, once, before ",xp(d.expiresAt),"; the code works one time and is not shown again."]}),e.jsx(yt,{text:d.command,label:"Copy the command"}),e.jsx("p",{className:"muted small",role:"status",children:"Waiting for the machine to connect…"})]}):null,N=p?e.jsx("p",{className:"error",role:"alert",children:p}):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(w=>e.jsxs("li",{className:"machine","aria-label":w.name,children:[e.jsxs("p",{className:"machine-head",children:[e.jsx("strong",{children:w.name}),e.jsxs("span",{className:"muted small",children:[" ",w.platform,w.owner?`, ${w.owner}`:""]}),w.paused?e.jsx("span",{className:"badge warn",children:"Paused"}):w.online?e.jsx("span",{className:"badge ok",children:"Online"}):e.jsxs("span",{className:"badge",children:["Offline, last seen ",xp(w.lastSeenAt)]})]}),e.jsx("ul",{className:"plain machine-agents",children:w.agents.map(b=>e.jsxs("li",{children:[bg(b),b.signIn==="signed-out"&&b.signInCommand?e.jsxs("span",{className:"small",children:[" Run on ",w.name,": ",e.jsx(yt,{text:b.signInCommand,label:`Copy the sign-in command for ${b.label}`})]}):null]},b.id))}),e.jsx(qe,{small:!0,trigger:"Remove",triggerLabel:`Remove ${w.name}`,consequence:`${w.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:()=>or.remove(w.id).then(()=>j())})]},w.id))})]}),e.jsxs("section",{className:"panel","aria-labelledby":"connect-machine-h",children:[e.jsx("h2",{id:"connect-machine-h",children:"Connect a machine"}),k??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."}),k??e.jsx("div",{className:"actions",children:e.jsx("button",{type:"button",onClick:y,children:"Connect a machine"})}),N]})]})}function jN({me:t}){const[s,r]=m.useState(null),[l,i]=m.useState(""),[c,d]=m.useState(null),[u,p]=m.useState(null),f=()=>Dm.read().then(j=>{r(j),i(j.name)},j=>d(j.message));if(m.useEffect(()=>{f()},[]),!s)return c?e.jsx(ve,{what:"the organization",reason:c,panel:!0,onRetry:()=>{d(null),f()}}):e.jsx(fe,{what:"the organization",panel:!0});const g=j=>{j.preventDefault(),d(null),p(null),Dm.rename(l).then(y=>{r(y),i(y.name),p(`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:j=>i(j.target.value),maxLength:80,required:!0})]}),e.jsx("button",{type:"submit",className:"secondary",children:"Rename"})]}):e.jsx("p",{children:s.name}),e.jsxs("p",{className:"muted",children:["Its address stays /",s.tenant,". ",e.jsx(Ee,{label:"the organization's address",children:"Organizations are added and removed in the orchestrator's configuration file, by whoever runs the orchestrator."})]})]})]})}function yN({me:t}){const[s,r]=m.useState(null),[l,i]=m.useState(""),[c,d]=m.useState(""),[u,p]=m.useState(null),[f,g]=m.useState(null),j=m.useId(),y=m.useId(),k=Ie(t),N=()=>Um.read().then(R=>{r(R),i(String(R.privacy.taskLogDays)),d(String(R.privacy.usageDays))},R=>p(R.message));if(m.useEffect(()=>{k&&N()},[k]),!k)return e.jsx("section",{className:"panel",children:e.jsx("p",{children:"Only owners and admins see privacy settings."})});if(!s)return u?e.jsx(ve,{what:"privacy settings",reason:u,panel:!0,onRetry:()=>{p(null),N()}}):e.jsx(fe,{what:"privacy settings",panel:!0});const w=(R,T)=>{p(null),g(null),Um.change(R).then(C=>{r({...s,privacy:C}),g(T)},C=>p(C.message))},b=R=>{R.preventDefault(),w({taskLogDays:Number(l)},`Task logs are kept ${l} days; older lines are deleted now.`)},$=R=>{R.preventDefault(),w({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(Ee,{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:s.usage.map(R=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("a",{href:ce("repositories",R.repoId),children:R.name})}),e.jsx("td",{children:R.team}),e.jsx("td",{children:R.reporting===null?"not read yet":R.reporting?"yes":"no"})]},R.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:s.privacy.leaderboard==="admins",onChange:()=>w({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:s.privacy.leaderboard==="members",onChange:()=>w({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:b,"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:R=>i(R.target.value),required:!0,"aria-describedby":j})]}),e.jsx("button",{type:"submit",className:"secondary",children:"Save"})]}),e.jsx("p",{className:"muted",id:j,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:$,"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:R=>d(R.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(Ee,{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 Bo({topic:t,lead:s,children:r}){return e.jsxs("div",{className:"muted",children:[e.jsx("p",{children:s}),e.jsxs("details",{children:[e.jsxs("summary",{children:["More",e.jsxs("span",{className:"visually-hidden",children:[" about ",t]})]}),e.jsx("p",{children:r})]})]})}function jp(t){return Object.entries(t).filter(([,s])=>s.trim()).map(([s,r])=>({group:s,tag:r.trim().toLowerCase()}))}function vN({me:t,view:s,onApplied:r}){var N;const[l,i]=m.useState(()=>Object.fromEntries(s.groups.map(w=>[w.group,w.tag??""]))),[c,d]=m.useState(null),[u,p]=m.useState(null),[f,g]=m.useState(null),j=(w,b)=>{i({...l,[w]:b}),d(null)},y=()=>{p(null),g(null),No.preview(jp(l)).then(d,w=>p(w.message))},k=()=>{c&&No.apply(jp(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."),r()},w=>p(w.message))};return s.groups.length?e.jsxs(e.Fragment,{children:[e.jsx(Bo,{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:s.groups.map(w=>e.jsxs("tr",{children:[e.jsx("td",{className:"mono",children:w.group}),e.jsx("td",{children:w.members}),e.jsx("td",{children:e.jsx("input",{"aria-label":`Tag for ${w.group}`,value:l[w.group]??"",onChange:b=>j(w.group,b.target.value),placeholder:"no tag"})})]},w.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:k,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(w=>e.jsxs("tr",{children:[e.jsxs("td",{children:[w.member.name,e.jsx("div",{className:"muted",children:w.member.email})]}),e.jsx("td",{children:w.gains.join(", ")||"none"}),e.jsx("td",{children:w.loses.join(", ")||"none"})]},w.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=s.sso)==null?void 0:N.groupsClaim)??"groups"," claim."]})}function kN({me:t}){const[s,r]=m.useState(null),[l,i]=m.useState(!1),[c,d]=m.useState(""),[u,p]=m.useState(null),f=t.role==="owner",g=()=>po.list().then(k=>{r(k.domains),i(k.sso)},k=>p(k.message));m.useEffect(()=>{g()},[]);const j=(k,N)=>{p(null),k.then(g,w=>p(`${N} ${w.message}`))},y=k=>{k.preventDefault(),j(po.add(c).then(()=>d("")),"Failed to add the SSO domain.")};return s?e.jsxs(e.Fragment,{children:[e.jsx(Bo,{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,s.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:s.map(k=>e.jsxs("tr",{children:[e.jsx("td",{className:"mono",children:k.domain}),e.jsx("td",{children:k.verified?"Verified; signs in with SSO":e.jsxs(e.Fragment,{children:["Add this TXT record, then verify:",e.jsx("div",{className:"mono",children:k.record.name}),e.jsx("code",{className:"link",children:k.record.value})]})}),e.jsxs("td",{className:"row-actions",children:[f&&!k.verified?e.jsx("button",{type:"button",className:"secondary small","aria-label":`Verify ${k.domain}`,onClick:()=>j(po.verify(k.domain),"Failed to verify the SSO domain."),children:"Verify"}):null,f?e.jsx("button",{type:"button",className:"secondary small","aria-label":`Remove ${k.domain}`,onClick:()=>j(po.remove(k.domain),"Failed to remove the SSO domain. Try again."),children:"Remove"}):null]})]},k.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:k=>d(k.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(ve,{what:"SSO domains",reason:u,onRetry:()=>{p(null),g()}}):e.jsx(fe,{what:"SSO domains"})}function wN({me:t}){const[s,r]=m.useState(null),[l,i]=m.useState(null),[c,d]=m.useState(null),u=t.role==="owner",p=()=>Rc.read().then(r,g=>d(g.message));m.useEffect(()=>{p()},[]);const f=()=>Rc.create().then(g=>(i(g.token),p()));return s?e.jsxs(e.Fragment,{children:[e.jsx(Bo,{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(yt,{text:s.baseUrl,label:"Copy the SCIM base URL"})})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Token"}),e.jsx("dd",{children:s.token?e.jsxs(e.Fragment,{children:[s.token.prefix,"_… made by ",s.token.createdBy,"; ",s.token.lastUsedAt?`last used ${new Date(s.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(yt,{text:l,label:"Copy the SCIM token"}),e.jsx("div",{className:"actions",children:e.jsx("button",{type:"button",className:"secondary small",onClick:()=>i(null),children:"I copied it"})})]}):null,c?e.jsx("p",{className:"error",role:"alert",children:c}):null,u?e.jsx("div",{className:"actions",children:s.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:()=>Rc.remove().then(p)})]}):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(ve,{what:"directory provisioning",reason:c,onRetry:()=>{d(null),p()}}):e.jsx(fe,{what:"directory provisioning"})}const yp={google:"Google Workspace",microsoft:"Microsoft"};function bN({me:t}){const[s,r]=m.useState(null),[l,i]=m.useState("member"),[c,d]=m.useState(null),u=()=>_m.read().then(r,g=>d(g.message));m.useEffect(()=>{u()},[]);const p=g=>{d(null),_m.set(g,l).then(u,j=>d(j.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(Bo,{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."}),s&&c?e.jsx("p",{className:"error",role:"alert",children:c}):null,s?s.join?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["People in the ",yp[s.join.provider]," directory ",e.jsx("span",{className:"mono",children:s.join.directory})," join as ",s.join.role,"s."]}),f?e.jsx("div",{className:"actions",children:e.jsx("button",{type:"button",className:"secondary",onClick:()=>p(!1),children:"Stop letting them join"})}):null]}):f?s.yours?e.jsxs("div",{className:"form",children:[e.jsxs("p",{children:["Let people in your ",yp[s.yours.provider]," directory ",e.jsx("span",{className:"mono",children:s.yours.directory})," join."]}),e.jsx(Pe,{label:"They join as",value:l,onChange:g=>i(g),options:[{value:"member",label:"Member"},{value:"viewer",label:"Viewer"}]}),e.jsx("div",{className:"actions",children:e.jsx("button",{type:"button",onClick:()=>p(!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(ve,{what:"who joins without an invitation",reason:c,onRetry:()=>{d(null),u()}}):e.jsx(fe,{what:"who joins without an invitation"})]})}function NN({me:t}){const[s,r]=m.useState(null),[l,i]=m.useState(null),[c,d]=m.useState(0),u=Ie(t);return m.useEffect(()=>{u&&No.read().then(r,p=>i(p.message))},[u,c]),u?e.jsxs(e.Fragment,{children:[t.mode==="cloud"?e.jsx(bN,{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(ve,{what:"single sign-on and directory settings",reason:l,onRetry:()=>{i(null),d(c+1)}}):null,s!=null&&s.sso?e.jsxs("dl",{className:"facts",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"OpenID Connect"}),e.jsx("dd",{className:"mono",children:s.sso.issuer})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Groups claim"}),e.jsx("dd",{className:"mono",children:s.sso.groupsClaim})]})]}):s?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(kN,{me:t})]}),e.jsxs("section",{className:"panel","aria-labelledby":"scim-h",children:[e.jsx("h2",{id:"scim-h",children:"Directory provisioning (SCIM)"}),e.jsx(wN,{me:t})]}),e.jsxs("section",{className:"panel","aria-labelledby":"dir-h",children:[e.jsx("h2",{id:"dir-h",children:"Directory sync"}),s?e.jsx(vN,{me:t,view:s,onApplied:()=>d(c+1)}):l?null:e.jsx(fe,{what:"directory sync"})]})]}):e.jsx("section",{className:"panel",children:e.jsx("p",{children:"Only owners and admins see security settings."})})}function SN(t){return t?new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}):"not yet"}function CN({teams:t,onCreated:s}){const[r,l]=m.useState(""),[i,c]=m.useState([]),[d,u]=m.useState(null),p=f=>{f.preventDefault(),u(null),cr.createServiceAccount({name:r,teams:i}).then(()=>{l(""),c([]),s()},g=>u(g.message))};return e.jsxs("form",{className:"form",onSubmit:p,"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(Ee,{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:r,onChange:f=>l(f.target.value),required:!0,maxLength:80})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Owns"}),e.jsx(_o,{teams:t,value:i,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 $N({account:t,teams:s,onChanged:r}){const[l,i]=m.useState(!1),[c,d]=m.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:SN(t.lastUsedAt)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Added by"}),e.jsx("dd",{children:t.createdBy})]})]}),e.jsx(_o,{teams:s,value:t.ownedTeams,onChange:u=>cr.updateServiceAccount(t.id,{teams:u}).then(r,p=>d(p.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:()=>i(!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:()=>cr.removeServiceAccount(t.id).then(r)})]}),l?e.jsx(wg,{serviceAccountId:t.id,label:`Keys of ${t.name}`}):null]})}function TN({me:t}){const[s,r]=m.useState(null),[l,i]=m.useState([]),[c,d]=m.useState(null),u=Ie(t),p=()=>{u&&(cr.serviceAccounts().then(r,f=>d(f.message)),Xt.teams().then(i,()=>i([])))};return m.useEffect(p,[u]),u?e.jsxs(e.Fragment,{children:[c?e.jsx("p",{className:"error",role:"alert",children:c}):null,s&&!s.length?e.jsx("section",{className:"panel",children:e.jsx("p",{className:"muted",children:"No service account yet."})}):null,(s??[]).map(f=>e.jsx($N,{account:f,teams:l,onChanged:p},f.id)),e.jsx("section",{className:"panel",children:e.jsx(CN,{teams:l,onCreated:p})})]}):e.jsx("section",{className:"panel",children:e.jsx("p",{children:"Only owners and admins manage service accounts."})})}function EN({maxUsd:t,maxMinutes:s}){return t!==null&&s!==null?`A task now stops at $${t.toFixed(2)} or after ${s} minutes, whichever comes first.`:t!==null?`A task now stops at $${t.toFixed(2)}; how long it runs has no limit.`:s!==null?`A task now stops after ${s} minutes; what it spends has no limit.`:"A task now has no limit on what it spends or how long it runs."}function vp({maxUsd:t,maxMinutes:s}){return t!==null&&s!==null?`A task stops at $${t.toFixed(2)} or after ${s} minutes, whichever comes first.`:t!==null?`A task stops at $${t.toFixed(2)}; how long it runs has no limit.`:s!==null?`A task stops after ${s} minutes; what it spends has no limit.`:"A task has no limit on what it spends or how long it runs."}function RN({me:t}){const s=Ie(t),[r,l]=m.useState(""),[i,c]=m.useState(""),[d,u]=m.useState(!1),[p,f]=m.useState(!1),[g,j]=m.useState(!1),[y,k]=m.useState(null),[N,w]=m.useState(null),[b,$]=m.useState(null),[R,T]=m.useState(!1),C=F=>{l(F.maxUsd===null?"":String(F.maxUsd)),c(F.maxMinutes===null?"":String(F.maxMinutes)),u(F.maxUsd===null),f(F.maxMinutes===null),j(!0)},E=()=>su.read().then(C,F=>k(F.message));if(m.useEffect(()=>{E()},[]),y)return e.jsx(ve,{what:"the task limits",reason:y,onRetry:()=>{k(null),E()}});if(!g)return e.jsx(fe,{what:"the task limits"});const O=F=>{F.preventDefault(),T(!0),w(null),$(null),su.change({maxUsd:d?null:Number(r),maxMinutes:p?null:Number(i)}).then(L=>{C(L),$(EN(L))},L=>w(L.message)).finally(()=>T(!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.",s?"":" An owner or an admin changes them."]}),N?e.jsx("p",{className:"error",role:"alert",children:N}):null,b?e.jsx("p",{className:"notice",role:"status",children:b}):null,e.jsxs("form",{className:"form task-limits",onSubmit:O,"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:r,disabled:d||!s,required:!d,onChange:F=>l(F.target.value)})]}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:d,disabled:!s,onChange:F=>u(F.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:i,disabled:p||!s,required:!p,onChange:F=>c(F.target.value)})]}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:p,disabled:!s,onChange:F=>f(F.target.checked)}),"No limit"]})]}),s?e.jsx("div",{className:"actions",children:e.jsx("button",{type:"submit",disabled:R,children:"Save"})}):null]})]})}function PN(t){return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function Da(t,s){return t.scope==="team"?s?"every repository":`team ${t.target}`:`repository ${t.target}`}function AN({repos:t,local:s,op:r,onSaved:l}){const i=[...new Set(t.map(W=>W.team))].sort(),[c,d]=m.useState("team"),[u,p]=m.useState(""),[f,g]=m.useState(""),[j,y]=m.useState(""),[k,N]=m.useState("typed"),[w,b]=m.useState(""),[$,R]=m.useState(null),T=k==="op"&&r!==null,C=m.useId(),E=c==="team"?i:t.map(W=>W.id),O=E.includes(u)?u:E[0]??"",F=W=>{W.preventDefault(),R(null),ru.set({scope:c,target:O,name:f.trim(),...T?{secret:{provider:"op",reference:w.trim()}}:{value:j}}).then(A=>{g(""),y(""),b(""),l(A)},A=>R(A.message))},L=$?{"aria-describedby":C}:{};return e.jsxs("form",{className:"form",onSubmit:F,"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:W=>d(W),describedBy:L["aria-describedby"],options:[{value:"team",label:s?"Every repository":"Every repository of a team"},{value:"repo",label:"One repository"}]}),s&&c==="team"?null:e.jsx(Pe,{label:c==="team"?"Team":"Repository",value:O,onChange:p,describedBy:L["aria-describedby"],options:E.map(W=>({value:W,label:W}))}),e.jsxs("label",{children:["Name",e.jsx("input",{value:f,onChange:W=>g(W.target.value.toUpperCase()),placeholder:"NPM_TOKEN",required:!0,maxLength:64,autoComplete:"off",spellCheck:!1,...L})]}),r?e.jsx(Pe,{label:"Value",value:k,onChange:W=>N(W),describedBy:L["aria-describedby"],options:[{value:"typed",label:"Typed here"},{value:"op",label:"Read from 1Password"}]}):null,T?e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:["1Password reference",e.jsx("input",{value:w,onChange:W=>b(W.target.value),placeholder:`op://${r[0]??"vault"}/item/field`,required:!0,autoComplete:"off",spellCheck:!1,...L})]}),e.jsxs("p",{className:"muted",children:["Read when each task starts, from ",r.length===1?"the vault":"the vaults"," ",r.join(", "),"; nothing is copied here."]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:[r?"Typed value":"Value",e.jsx("input",{type:"password",value:j,onChange:W=>y(W.target.value),required:!0,autoComplete:"off",...L})]}),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(Ee,{label:"changing a value",children:"Save it again to change it."})]})]}),$?e.jsx("p",{className:"error",role:"alert",id:C,children:$}):null,e.jsx("div",{className:"actions",children:e.jsx("button",{type:"submit",disabled:!O,children:"Save secret"})})]})}function IN({me:t}){const[s,r]=m.useState(null),[l,i]=m.useState(!0),[c,d]=m.useState(null),[u,p]=m.useState([]),[f,g]=m.useState(null),[j,y]=m.useState(null),k=Ie(t),N=t.mode==="local",w=()=>ru.list().then(b=>{r(b.secrets),i(b.vault),d(b.op??null)},b=>g(`Couldn't load task secrets. ${b.message}`));return m.useEffect(()=>{k&&(w(),Ne.repos().then(p,()=>p([])))},[k]),k?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:(s==null?void 0:s.length)??0})]}),e.jsxs("p",{className:"muted",children:["Values a task's agent needs, masked in its log. ",e.jsx(Ee,{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,j?e.jsx("p",{className:"notice",role:"status",children:j}):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."}),s?s.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:s.map(b=>e.jsxs("tr",{children:[e.jsxs("td",{children:[e.jsx("span",{className:"mono",children:b.name}),b.reference?e.jsx("div",{className:"muted mono small",children:b.reference}):null]}),e.jsx("td",{children:Da(b,N)}),e.jsxs("td",{children:[PN(b.updatedAt),e.jsxs("div",{className:"muted",children:["by ",b.updatedBy]})]}),e.jsx("td",{children:e.jsx(qe,{small:!0,trigger:"Delete",triggerLabel:`Delete ${b.name} for ${Da(b,N)}`,consequence:`This cannot be undone. The next task on ${Da(b,N)} starts without ${b.name}.`,confirm:"Delete secret",keep:"Keep secret",onConfirm:()=>ru.remove(b).then(w)})})]},`${b.scope}:${b.target}:${b.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(AN,{repos:u,local:N,op:c,onSaved:b=>{y(b.reference?`Saved ${b.name} for ${Da(b,N)}; each task reads it from ${b.reference}.`:`Saved ${b.name} for ${Da(b,N)}. The value is not shown again.`),w()}})}):null]}):e.jsx("section",{className:"panel",children:e.jsx("p",{children:"Only owners and admins manage task secrets."})})}const Ua={status:()=>B("GET","/api/update"),check:()=>B("POST","/api/update/check"),prepare:t=>B("POST","/api/update/prepare",{version:t}),apply:()=>B("POST","/api/update/apply"),restart:()=>B("POST","/api/update/restart")};function ON({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 LN(){const[t,s]=m.useState(null),[r,l]=m.useState(null),[i,c]=m.useState(0),[d,u]=m.useState(null),[p,f]=m.useState(null),[g,j]=m.useState([]),[y,k]=m.useState(null),[N,w]=m.useState(null),[b,$]=m.useState(!1);m.useEffect(()=>{l(null),Ua.status().then(s,L=>l(L.message))},[i]),m.useEffect(()=>{if(!b)return;let L=!1;const W=setInterval(()=>{fetch("/api/health").then(A=>{A.ok&&L&&window.location.reload(),A.ok||(L=!0)},()=>{L=!0})},2e3);return()=>clearInterval(W)},[b]);const R=(L,W,A)=>{k(L),w(null),W().then(A,M=>w(M.message)).finally(()=>k(null))};if(r)return e.jsx(ve,{what:"the update state",reason:r,onRetry:()=>c(L=>L+1)});if(!t)return e.jsx(fe,{what:"the update state"});if(!t.installed)return e.jsx("section",{className:"section",children:e.jsx(ON,{status:t})});if("refused"in t)return e.jsx("section",{className:"section",children:e.jsx("p",{className:"error",children:t.refused})});const T=d&&"newer"in d&&d.newer?d.newest:null,C=t.prepared,E=L=>{j(L.said),L.ok||w(L.said.at(-1)??"The step did not finish."),c(W=>W+1)};let O,F=null;return b?O="Starting again with the new version; this page answers once it is back.":p!=null&&p.ok?(O=p.restart==="service"?"Switched. The new version runs once the orchestrator starts again.":"Switched. Start the orchestrator again to run the new version.",p.restart==="service"&&(F={label:"Restart now",go:()=>R("restart",Ua.restart,()=>$(!0))})):C?(O=`${C} is prepared and checked.`,F={label:`Switch to ${C}`,go:()=>R("apply",Ua.apply,L=>{f(L),E(L)})}):T?(O=`${T} is out. Preparing downloads and checks it; this version keeps running.`,F={label:`Prepare ${T}`,go:()=>R("prepare",()=>Ua.prepare(T),E)}):(O=d&&"refused"in d?d.refused:d?`Running ${t.running}, the newest.`:`Running ${t.running}.`,F={label:"Check for updates",go:()=>R("check",Ua.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:O}),t.failed&&!C?e.jsxs("p",{className:"error",children:[t.failed.version," did not prepare: ",t.failed.reason]}):null,F?e.jsx("div",{className:"actions",children:e.jsx("button",{type:"button",disabled:y!==null,onClick:F.go,children:y?"Working…":F.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((L,W)=>e.jsx("li",{className:"mono",children:L},W))})]}):null]})}function FN({me:t,route:s,onLeft:r}){const[,l="account",i]=s.split("/").filter(Boolean),c=ko.find(f=>f.id===l&&Mu(t,f.id));if(!c)return e.jsx(_r,{org:Ds(window.location.pathname).org??"",path:window.location.pathname});const d=f=>ce("settings",f),u=gf(t),p=e.jsx(Fo,{label:"Settings",current:d(c.id),links:u.map(f=>({to:d(f.id),label:f.label}))});return c.id==="members"&&i?e.jsx("div",{className:"page",children:e.jsx(pN,{id:i,me:t,nav:p})}):c.id==="members"?e.jsx("div",{className:"page",children:e.jsx(Ev,{me:t,nav:p,onLeft:r})}):c.id==="account"?e.jsx("div",{className:"page",children:e.jsx(qb,{me:t,nav:p,onChanged:r})}):e.jsxs("div",{className:"page",children:[e.jsx("header",{className:"page-head",children:e.jsx("h1",{children:c.label})}),p,c.id==="code"?e.jsx(sN,{me:t}):null,c.id==="task-limits"?e.jsx(RN,{me:t}):null,c.id==="service-accounts"?e.jsx(TN,{me:t}):null,c.id==="api-keys"?e.jsx(hN,{me:t}):null,c.id==="access"?e.jsx(Gb,{me:t}):null,c.id==="task-secrets"?e.jsx(IN,{me:t}):null,c.id==="agents"?e.jsx(Wb,{}):null,c.id==="machines"?e.jsx(xN,{}):null,c.id==="security"?e.jsx(NN,{me:t}):null,c.id==="privacy"?e.jsx(yN,{me:t}):null,c.id==="organization"?e.jsx(jN,{me:t}):null,c.id==="updates"?e.jsx(LN,{}):null]})}function MN({repo:t,data:s,editable:r,onOpened:l,selected:i,onSelect:c}){const{inventory:d}=s,[u,p]=m.useState(null),f=j=>{p(null),l(j)},g={repoId:t.id,head:d.head,onOpened:f,onCancel:()=>p(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}),r?e.jsx("button",{type:"button",className:"secondary small",onClick:()=>p({type:"command-add"}),children:"Add a command"}):null]}),(u==null?void 0:u.type)==="command-add"?e.jsx(vu,{...g}):null,(u==null?void 0:u.type)==="command-edit"?e.jsx(vu,{...g,name:u.name},u.name):null,(u==null?void 0:u.type)==="command-remove"?e.jsx(Qf,{...g,name:u.name},u.name):null,d.commands.length?e.jsx("ul",{className:"plain",children:d.commands.map(j=>e.jsxs("li",{children:[e.jsx("button",{type:"button",className:"link","aria-pressed":i===j.file,onClick:()=>c(j.file),children:e.jsxs("code",{children:["/",j.name]})})," ",e.jsx("span",{className:"muted",children:j.description}),r?e.jsxs("span",{className:"row-actions",children:[" ",e.jsx("button",{type:"button",className:"secondary small","aria-label":`Edit /${j.name}`,onClick:()=>p({type:"command-edit",name:j.name}),children:"Edit"}),e.jsx("button",{type:"button",className:"secondary small","aria-label":`Remove /${j.name}`,onClick:()=>p({type:"command-remove",name:j.name}),children:"Remove"})]}):null]},j.name))}):e.jsx("p",{className:"muted",children:"None shared yet. A command reaches this list when a request adds it under commands/."})]})}function _N({repoId:t,path:s,head:r}){const[l,i]=m.useState(null),[c,d]=m.useState(null),[u,p]=m.useState(0);return m.useEffect(()=>{let f=!0;return i(null),d(null),Ne.history(t,s).then(g=>f&&i(g),g=>f&&d(g.message)),()=>{f=!1}},[t,s,r,u]),c?e.jsx(ve,{what:"the history",reason:c,onRetry:()=>p(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(fe,{what:"the history"})}function DN({repo:t,data:s,me:r,editable:l,onOpened:i,selected:c,onSelect:d}){const u=r.mode==="local",{inventory:p}=s,[f,g]=m.useState(null),j=p.mcpServers.some(w=>w.inTasks),y=w=>{g(null),i(w)},k={repoId:t.id,head:p.head,onOpened:y,onCancel:()=>g(null)},N=w=>b=>{b.stopPropagation(),w()};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:p.mcpServers.length}),l&&p.mcpServers.length?e.jsx("button",{type:"button",className:"secondary small",onClick:()=>g({type:"mcp"}),children:"Add a server"}):null]}),!p.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(ku,{...k}):null,(f==null?void 0:f.type)==="mcp-edit"?e.jsx(ku,{...k,name:f.name},f.name):null,(f==null?void 0:f.type)==="mcp-remove"?e.jsx(Xf,{...k,name:f.name},f.name):null,p.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:p.mcpServers.map(w=>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:w.name})}),e.jsx("td",{className:"mono",children:w.target}),e.jsxs("td",{children:[w.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:b=>b.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:w.transport})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Variables"}),e.jsx("dd",{className:"mono",children:w.envNames.join(", ")||"none"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Share rule"}),e.jsx("dd",{children:w.shareable?"passes":w.refusal})]}),j&&w.inTasks?e.jsxs("div",{children:[e.jsx("dt",{children:"In tasks"}),e.jsxs("dd",{children:[e.jsx("span",{className:`badge ${w.inTasks.usable&&!w.inTasks.signIn?"ok":"warn"}`,children:w.inTasks.usable?w.inTasks.signIn?"given, no sign-in":"given":"not given"})," ",e.jsx("span",{className:"muted",children:w.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:w.name})),children:"Edit"}),e.jsx("button",{type:"button",className:"secondary small",onClick:N(()=>g({type:"mcp-remove",name:w.name})),children:"Remove"})]}):null]},w.name))})]}):null]})}const kp={ok:{badge:"ok",text:"fine"},attention:{badge:"warn",text:"attention"},problem:{badge:"error",text:"problem"},suggestion:{badge:"neutral",text:"suggestion"}};function UN({repoId:t,refresh:s}){const[r,l]=m.useState(!1),[i,c]=m.useState(null);if("problem"in s)return e.jsx("p",{className:"muted",children:s.problem});const d=()=>{l(!0),c(null),$e.start({title:"",description:"",issueUrl:"",repoId:t,agent:"",template:{kind:"scaffold.refresh",commitVersioning:!1}}).then(u=>Ue(ce("tasks",u.id)),u=>{c(u.message),l(!1)})};return e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",disabled:r,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."}),i?e.jsx("p",{className:"error",role:"alert",children:i}):null]})}function qN({findings:t,repoId:s,refresh:r,editable:l,local:i}){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:i?"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 ${kp[u.level].badge}`,children:kp[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(UN,{repoId:s,refresh:r}):null]})}function wp({text:t}){const[s,r]=m.useState(null),l=()=>{if(!navigator.clipboard)return r("select it and copy");navigator.clipboard.writeText(t).then(()=>r("copied"),()=>r("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"}),s?e.jsxs("span",{className:"muted",role:"status",children:[" ",s]}):null]})}function BN({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(s=>e.jsx(wp,{text:s},s))}),e.jsx("p",{children:"To also share their own, with TeamHandbook installed:"}),e.jsx("ul",{className:"plain",children:e.jsx(wp,{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 zN({data:t,editable:s,repo:r,me:l}){const{skills:i,mcpServers:c,commands:d}=t.inventory,u=(p,f)=>`${p} ${f}${p===1?"":"s"}`;return e.jsxs(e.Fragment,{children:[e.jsx(qN,{findings:t.inventory.setup,repoId:r.id,refresh:t.refresh,editable:s,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:ce("repositories",r.id,"skills"),children:u(i.length,"skill")}),", ",e.jsx("a",{href:ce("repositories",r.id,"mcp"),children:u(c.length,"MCP server")}),", ",e.jsx("a",{href:ce("repositories",r.id,"commands"),children:u(d.length,"slash command")})]})]}),l.mode==="local"?null:e.jsx(BN,{join:t.join})]})}const WN={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 HN({scan:t}){if(!t)return e.jsx("span",{className:"muted",children:"not read yet"});const s=WN[t.state],r=t.state==="attention"?`${t.findings.length} ${s.text}`:s.text;return e.jsxs("div",{className:"scan",children:[e.jsx("span",{className:`badge ${s.badge}`,children:r}),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,i)=>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??""}:${i}`))})]}):null]})}function GN({repoId:t,version:s}){var p,f;const[r,l]=m.useState(null),[i,c]=m.useState(null);m.useEffect(()=>{c(null),Ne.pending(t).then(l,g=>c(g.message))},[t,s]);const d=((p=r==null?void 0:r.pending)==null?void 0:p.filter(g=>!g.byOrchestrator))??[],u=(((f=r==null?void 0:r.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:r!=null&&r.pending?d.length:""})]}),r!=null&&r.pending&&u?e.jsxs("p",{className:"muted",children:[u," more, opened from the orchestrator, ",u===1?"is":"are"," under Requests from the orchestrator."]}):null,i?e.jsx("p",{className:"error",children:i}):r?r.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 j;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(sl,{reads:Do(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(HN,{scan:g.scan??null}),g.number!==null&&((j=g.url)!=null&&j.startsWith("http"))?e.jsx(Vu,{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:r.reason}):e.jsx("p",{className:"muted",children:"Reading the forge…"})]})}function KN({repo:t,me:s,onChanged:r,requestsRead:l}){const[i,c]=m.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:i??""})]}),e.jsxs("p",{className:"muted",children:["Nothing reaches teammates until a reviewer merges it. ",e.jsx(Ee,{label:"requests",children:Ju.request.means})]}),e.jsx(Lk,{repoId:t.id,repos:[t],me:s,version:l,onCounts:d=>c(d.counts.open+d.counts.merged+d.counts.closed),onChanged:r})]}),e.jsx(GN,{repoId:t.id,version:l})]})}function VN({repo:t,data:s,me:r,editable:l,usage:i,overlaps:c,onOpened:d,selected:u,onSelect:p}){const f=r.mode==="local",{inventory:g}=s,j=g.team,[y,k]=m.useState(null),[N,w]=m.useState(""),[b,$]=m.useState(1),R=new Map(((i==null?void 0:i.usage)??[]).map(W=>[W.skill,W])),T=N.trim().toLowerCase(),C=T?g.skills.filter(W=>W.slug.includes(T)||W.description.toLowerCase().includes(T)):g.skills,E=Lu(C,b),O=W=>{k(null),d(W)},F={repoId:t.id,head:g.head,onOpened:O,onCancel:()=>k(null)},L=W=>A=>{A.stopPropagation(),W()};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:()=>k({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:()=>k({type:"skill-add"}),children:"Add a skill"})}):null]}):null,(y==null?void 0:y.type)==="skill-add"?e.jsx(yu,{...F}):null,(y==null?void 0:y.type)==="skill-edit"?e.jsx(yu,{...F,slug:y.slug},y.slug):null,(y==null?void 0:y.type)==="skill-remove"?e.jsx(Jf,{...F,slug:y.slug},y.slug):null,g.skills.length>el?e.jsxs("label",{className:"filter",children:["Find a skill",e.jsx("input",{type:"search",value:N,onChange:W=>{w(W.target.value),$(1)}})]}):null,T&&!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 ",(i==null?void 0:i.days)??30," days"]}),l?e.jsx("th",{children:e.jsx("span",{className:"visually-hidden",children:"Changes"})}):null]})}),e.jsx("tbody",{children:E.shown.map(W=>{var A,M;return e.jsxs("tr",{className:u===`skills/${W.slug}`?"selected":void 0,onClick:()=>p(`skills/${W.slug}`),children:[e.jsx("td",{className:"mono",children:e.jsx("button",{type:"button",className:"link","aria-pressed":u===`skills/${W.slug}`,onClick:()=>p(`skills/${W.slug}`),children:W.slug})}),e.jsxs("td",{children:[W.problem?e.jsx("span",{className:"error",children:W.problem}):W.description,(A=c==null?void 0:c[W.slug])!=null&&A.names.length?e.jsxs("p",{className:"muted",children:["Answers the same requests as ",c[W.slug].names.join(", "),c[W.slug].more?` and ${c[W.slug].more} more`:"",", so Claude can pick either."]}):null,W.format.length?e.jsxs("details",{onClick:Q=>Q.stopPropagation(),children:[e.jsxs("summary",{children:[W.format.length," ",W.format.length===1?"thing":"things"," the plugin's skill format asks for"]}),e.jsx("ul",{children:W.format.map(Q=>e.jsx("li",{children:Q},Q))})]}):null]}),e.jsx("td",{children:W.files.join(", ")}),f?null:e.jsx("td",{children:j!=null&&j.usageEndpoint?(i==null?void 0:i.shown)===!1?e.jsx("span",{className:"muted",children:"shown to the team's owners"}):((M=R.get(W.slug))==null?void 0:M.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:L(()=>k({type:"skill-edit",slug:W.slug})),children:"Edit"}),e.jsx("button",{type:"button",className:"secondary small",onClick:L(()=>k({type:"skill-remove",slug:W.slug})),children:"Remove"})]}):null]},W.slug)})})]}):null,e.jsx(Lo,{page:E.page,total:C.length,onPage:$,label:"Pages of skills"})]})}function YN(t,s){return[`${t.name}: ${t.message}`,`at ${s}`,...t.stack?[t.stack]:[]].join(`
|
|
68
|
-
`)}function QN({error:t,path:s,home:r}){const l=m.useRef(null),i=YN(t,s);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:i}),e.jsxs("div",{className:"actions",children:[e.jsx("a",{className:"button secondary",href:r,children:"Back to Tasks"}),e.jsx(Uu,{text:i,target:l,label:"Copy error"})]})]})}class JN extends m.Component{constructor(){super(...arguments);Cm(this,"state",{error:null})}static getDerivedStateFromError(r){return{error:r}}componentDidCatch(r){console.error(r)}componentDidUpdate(r){this.state.error&&r.path!==this.props.path&&this.setState({error:null})}render(){return this.state.error?e.jsx(QN,{error:this.state.error,path:this.props.path,home:this.props.home}):this.props.children}}const Ng={gitlab:{name:"GitLab",noun:"merge request",title:"Merge request",mark:"!"},github:{name:"GitHub",noun:"pull request",title:"Pull request",mark:"#"}};function Sg(t,s){const[r,l]=m.useState(void 0),[i,c]=m.useState(!1),[d,u]=m.useState(null);if(m.useEffect(()=>{Ne.onForge(t,s).then(l,()=>l(null))},[t,s]),r===void 0)return{line:null,action:null,refusal:null};if(!(r!=null&&r.forge))return{line:e.jsx("p",{className:"muted",children:"Your checkout changes only when you keep this."}),action:null,refusal:null};const p=Ng[r.forge];if(r.url){const g=r.number;return{line:e.jsxs("p",{children:[g!==null?e.jsxs(e.Fragment,{children:[p.title," ",e.jsxs("a",{href:r.url,target:"_blank",rel:"noopener noreferrer",children:[p.mark,g]})]}):e.jsxs("a",{href:r.url,target:"_blank",rel:"noopener noreferrer",children:["A ",p.noun]})," is open on ",p.name,"."]}),action:null,refusal:null}}const f=()=>{c(!0),u(null),Ne.openOnForge(t,s).then(({url:g,number:j})=>l({forge:r.forge,url:g,number:j}),g=>{const j=g instanceof ut&&typeof g.body.createUrl=="string"?g.body.createUrl:null;u({message:g.message,createUrl:j})}).finally(()=>c(!1))};return{line:e.jsxs("p",{className:"muted",children:["Your checkout changes only when you keep this, and nothing reaches ",p.name," until you open a ",p.noun," there."]}),action:e.jsx("button",{type:"button",className:"secondary",disabled:i,onClick:f,children:i?`Opening a ${p.noun}…`:`Open a ${p.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 ",p.name]})]}):null]}):null}}function XN({repoId:t,number:s}){const{line:r,action:l,refusal:i}=Sg(t,s);return e.jsxs(e.Fragment,{children:[r,l?e.jsx("div",{className:"actions",children:l}):null,i]})}function Cg({options:t,value:s,onChange:r}){return t!=null&&t.length?e.jsx(e.Fragment,{children:t.map(l=>e.jsx(Pe,{label:l.label,value:s[l.id]??"",onChange:i=>r({...s,[l.id]:i||void 0}),options:[{value:"",label:"The agent's default"},...l.choices]},l.id))}):null}function Ur(t){const s=Object.fromEntries(Object.entries(t).filter(([,r])=>r));return Object.keys(s).length?s:void 0}const ZN={"no-runner":{label:"See Agent readiness",to:()=>ce("settings","agents")},"task-budget":{label:"See the task budgets",to:()=>ce("team")},"repo-access":{label:"See where tasks are allowed to run",to:()=>ce("team")},"agent-not-on-machine":{label:"See your machines",to:()=>ce("settings","machines")}};function td({code:t,status:s}){const r=t?ZN[t]:void 0;return r?e.jsxs(e.Fragment,{children:[" ",e.jsx("a",{href:r.to(),children:r.label})]}):s===403?e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{className:"muted",children:"Ask an owner or an admin."})]}):null}function bp(t){var l;const s=(l=t instanceof Element?t:t==null?void 0:t.parentElement)==null?void 0:l.closest("[data-seq]"),r=Number(s==null?void 0:s.dataset.seq);return s&&Number.isInteger(r)?r:null}function eS(t){if(!t||t.isCollapsed||!t.anchorNode||!t.focusNode)return null;const s=f=>{var g;return(g=f instanceof Element?f:f.parentElement)==null?void 0:g.closest("[data-quotable]")},r=s(t.anchorNode);if(!r||r!==s(t.focusNode))return null;const[l,i]=[bp(t.anchorNode),bp(t.focusNode)];if(l===null||i===null)return null;const c=t.toString().trim().slice(0,Vf);if(!c)return null;const[d,u]=l<=i?[l,i]:[i,l],p=t.getRangeAt(0).getBoundingClientRect();return{quote:{path:Kf,lines:d===u?`${d}`:`${d}-${u}`,text:c},top:p.bottom+6,left:Math.max(8,p.left)}}function tS({onQuote:t}){const[s,r]=m.useState(null);return m.useEffect(()=>{const l=()=>r(eS(window.getSelection()));return document.addEventListener("selectionchange",l),()=>document.removeEventListener("selectionchange",l)},[]),s?e.jsx("button",{type:"button",className:"secondary small quote-selection",style:{top:s.top,left:s.left},onMouseDown:l=>l.preventDefault(),onClick:()=>{var l;t(s.quote),(l=window.getSelection())==null||l.removeAllRanges()},children:"Quote in follow-up"}):null}const nS=3e3,sS=6,rS=3e4;function aS(t){return new Date(t).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"})}function lS({onConnected:t}){const[s,r]=m.useState(null),[l,i]=m.useState(null),[c,d]=m.useState(!1),[u,p]=m.useState(0),[f,g]=m.useState(!1);m.useEffect(()=>{if(g(!1),!s)return;const k=setTimeout(()=>g(!0),rS);return()=>clearTimeout(k)},[s==null?void 0:s.code]);const j=m.useRef(t);j.current=t,m.useEffect(()=>{let k=!0,N=null,w=sS,b;const $=()=>{k=!1,clearInterval(b)},R=()=>or.pair().then(C=>{k&&(N=C,r(C))},C=>{k&&($(),i(C.message))}),T=()=>or.list().then(({machines:C})=>{if(!k)return!0;const E=C.find(O=>O.online);return E?($(),j.current(E),!0):(N&&Date.parse(N.expiresAt)<=Date.now()&&(N=null,w-- >0?R():($(),r(null),d(!0))),!1)},()=>!1);return T().then(C=>{C||!k||(R(),b=setInterval(()=>void T(),nS))}),$},[u]);const y=()=>{i(null),d(!1),r(null),p(k=>k+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(ve,{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"})}):s?e.jsxs(e.Fragment,{children:[e.jsx(yt,{text:s.command,label:"Copy the command",primary:!0,well:!0}),e.jsxs("p",{className:"muted",children:["The code in it works once, until ",aS(s.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(fe,{what:"the command"})]})}function $g(t,s){var r;return((r=t==null?void 0:t.agents.find(l=>l.id===s))==null?void 0:r.checks.find(l=>l.status==="fail"))??null}const oS={"claude-code":"claude",opencode:"opencode auth login"};function iS(t,s,r){return(r==null?void 0:r.name)==="Program"?e.jsxs(e.Fragment,{children:[t," is not on this machine. Install it, then press Check again."]}):(r==null?void 0:r.name)==="Version"?e.jsxs(e.Fragment,{children:[t," is older than this orchestrator works with. Update it, then press Check again."]}):r&&/^(Sign-in|Credential)/.test(r.name)?e.jsxs(e.Fragment,{children:[t," is not signed in. Open a terminal, type ",e.jsx("code",{children:oS[s]??t})," and sign in, then press Check again."]}):e.jsxs(e.Fragment,{children:[t," is not ready yet; ",e.jsx("a",{href:ce("settings","agents"),children:"Agent readiness"})," shows each check."]})}function cS(t,s){return t.find(r=>{var l;return((l=$g(s,r.id))==null?void 0:l.name)!=="Program"})??t[0]}function uS(){const[t,s]=xv(!0),[r,l]=m.useState(null),i=u=>{$e.readiness(u).then(l,()=>l(null))};if(m.useEffect(()=>i(!1),[]),!t||t.some(u=>{var p;return(p=u.readiness)==null?void 0:p.ready})||t.every(u=>!u.readiness))return null;const c=cS(t,r);if(!c)return null;const d=()=>{i(!0),s()};return e.jsxs("p",{role:"status",children:[iS(c.label,c.id,$g(r,c.id))," ",e.jsx("button",{type:"button",className:"secondary small",onClick:d,children:"Check again"})]})}const Np=t=>({source:t.source,command:t.command,digest:t.digest}),Hr={task:t=>B("GET",`/api/tasks/${encodeURIComponent(t)}/verification`).then(s=>s.verifications),project:t=>B("GET",`/api/projects/${encodeURIComponent(t)}/verification`),approve:(t,s,r)=>B("PUT",`/api/projects/${encodeURIComponent(t)}/verification`,{checks:s.map(Np),setup:r?Np(r):null}),forget:t=>B("DELETE",`/api/projects/${encodeURIComponent(t)}/verification`)};function dS(t,s){var c,d;if(t.configured)return{configured:t.configured,checks:[],setup:null,approve:null,canChange:!1};const r=((c=t.detected)==null?void 0:c.checks)??[];if(t.approved&&!t.changed.length&&s===null)return{configured:null,checks:t.approved.checks,setup:t.approved.setup,approve:null,canChange:r.length>0};const l=s===null?r.slice(0,1):r.filter(u=>s.includes(u.command)),i=l.length?((d=t.detected)==null?void 0:d.setup)??null:null;return{configured:null,checks:l,setup:i,approve:l.length?{checks:l,setup:i}:null,canChange:r.length>0}}const Sp=t=>t?t.timedOut?"timed out":t.code===0?"passed":"failed":"not run";function hS(t){const s=Math.max(0,t.after.length-1),r=`${Sp(t.after.at(-1))} after${s?` ${s} repair ${s===1?"round":"rounds"}`:""}`;return`${Sp(t.before)} before, ${r}`}function mS(t){return t.verdict==="broken"||t.verdict==="failing-before"}function Cp({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 $p(t){var s;return!t.configured&&!!((s=t.detected)!=null&&s.checks.length)&&(!t.approved||t.changed.length>0)}function Tg(t,s,r=!0){const[l,i]=m.useState(null),[c,d]=m.useState(null),[u,p]=m.useState(!1),f=()=>t?Hr.project(t).then(i,()=>i(null)):Promise.resolve();m.useEffect(()=>{i(null),d(null),p(!1),f()},[t]);const g=l?dS(l,c):null,j=!!(l&&(s==="always"||$p(l)||c!==null)),y=j&&r,k=()=>{if(!y||!l||!g||!t)return Promise.resolve();const w=g.approve?Hr.approve(t,g.approve.checks,g.approve.setup):c!==null&&!c.length&&l.approved?Hr.forget(t):null;return w?w.then(()=>{},b=>{if(b.status!==403)throw b.code==="changed"&&f(),b}):Promise.resolve()};return!l||!g||!j?{view:null,consent:k}:r?{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(Cp,{step:g.setup}):null,g.checks.map(w=>e.jsx(Cp,{step:w},w.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(w=>w.command)),p(!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(w=>e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:(c==null?void 0:c.includes(w.command))??!1,onChange:b=>d($=>b.target.checked?[...$??[],w.command]:($??[]).filter(R=>R!==w.command))}),e.jsx("code",{children:w.command})]},w.command)),e.jsx("div",{className:"actions",children:e.jsx("button",{type:"button",className:"secondary small",onClick:()=>p(!1),children:"Done"})})]}):null]}),consent:k}:{view:$p(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:k}}const pS=3e3;function fS(t){var s;return((s=t.find(r=>{var l;return(l=r.readiness)==null?void 0:l.ready})??t[0])==null?void 0:s.id)??null}function gS(t){var r;const s=t.filter(l=>l.installed&&l.supported!=="unsupported");return((r=s.find(l=>l.signIn==="signed-in")??s[0])==null?void 0:r.id)??null}function xS({project:t,home:s=null,onStarted:r,onChange:l,onCancel:i,machine:c}){var W,A;const[d,u]=m.useState(""),[p,f]=m.useState(null),[g,j]=m.useState(!1),[y,k]=m.useState(null),N=m.useId(),w=m.useId(),[b,$]=m.useState([]),R=Tg(t.id,"always");m.useEffect(()=>{$e.options().then(M=>f(M.agents),()=>f([])),Zt.starters(t.id).then(M=>$(M.starters.slice(0,3)),()=>$([]))},[t.id]);const[T,C]=m.useState(null),E=T?gS(T):null;m.useEffect(()=>{if(!c||E)return;let M=!0;const Q=()=>or.list().then(({machines:U})=>{var ie;M&&C(((ie=U.find(X=>X.id===c))==null?void 0:ie.agents)??[])},()=>{});Q();const H=window.setInterval(Q,pS);return()=>{M=!1,window.clearInterval(H)}},[c,E]);const O=c?E:p?fS(p):null,F=((W=t.facts)==null?void 0:W.git)==="none"&&!t.facts.repos,L=M=>{M.preventDefault();const Q=d.trim();if(!Q||!O)return;j(!0),k(null);const{issue:H,notes:U}=_g(Q),ie=J=>{k({message:J.message,...J.code?{code:J.code}:{},...J.status?{status:J.status}:{}}),j(!1)};R.consent().then(()=>$e.start({title:Dg("",null,null,H?U:Q),description:H?U:Q,issueUrl:H,repoId:t.id,agent:O,template:null})).then(J=>r(J.id),ie)};return e.jsxs("form",{className:"task-box",onSubmit:L,"aria-label":"First task",children:[e.jsxs("p",{className:"task-box-where",children:[e.jsx("strong",{dir:"auto",children:((A=t.facts)==null?void 0:A.name)??t.name})," ",e.jsx("span",{className:"folder-at",dir:"auto",children:wf(t,s)}),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:M=>u(M.target.value),rows:3,maxLength:8500,...y?{"aria-describedby":w,"aria-invalid":!0}:{}}),b.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:b.map(M=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"ghost",onClick:()=>u(`${M.title}
|
|
69
|
-
|
|
70
|
-
${M.description}`),children:[e.jsx("span",{dir:"auto",children:M.title})," ",e.jsx("span",{className:"mono muted small",dir:"auto",children:M.where})]})},`${M.kind}:${M.where}:${M.title}`))})]}):null,R.view,F?e.jsx("p",{className:"muted small",children:"The agent edits these files in place, and you can undo every change."}):null,c&&T&&!O?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()||!O,children:"Start"}),i?e.jsx("button",{type:"button",className:"secondary",onClick:i,disabled:g,children:"Cancel"}):null,e.jsx(uS,{})]}),y?e.jsxs("p",{className:"error",role:"alert",id:w,children:[y.message,e.jsx(td,{...y.code?{code:y.code}:{},...y.status?{status:y.status}:{}})]}):null]})}const Tp="Personal";function jS(){return/mac/i.test(navigator.platform)?"/Users/you/code/<repository>":"/home/you/code/<repository>"}const Kc=[{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 yS(t){try{return decodeURIComponent(new URL(t.trim()).pathname).replace(/^\/+|\/+$/g,"").replace(/\.git$/,"")}catch{return""}}function Eg({repos:t,forge:s,onConnected:r,onCancel:l,ownCli:i=!1,paths:c=!0,titled:d=!0}){var z;const[u,p]=m.useState(s??(i?"path":"gitlab")),[f,g]=m.useState(""),[j,y]=m.useState(""),[k,N]=m.useState(!1),w=[...new Set(t.map(P=>P.team))].sort(),[b,$]=m.useState(w[0]??Tp),[R,T]=m.useState(!1),[C,E]=m.useState(""),[O,F]=m.useState(!1),[L,W]=m.useState(null),A=m.useId(),M=m.useId(),[Q]=qu(!i),H=u!=="path",U=H&&!(Vr(u)&&((z=Q==null?void 0:Q[u])!=null&&z.connection)),ie=yS(f),X=L?{"aria-describedby":A}:{},J=i?"Open a folder":"Add a repository",Z=P=>{P.preventDefault(),F(!0),W(null),Ne.connectRepo({forge:u,url:f.trim(),team:i?w[0]??Tp:b,...H&&j.trim()?{project:j.trim()}:{},...H&&C.trim()?{token:C.trim()}:H&&!i?{token:""}:{}}).then(_=>{F(!1),g(""),y(""),E(""),r(_)},_=>{F(!1),W(_.message),H&&N(!0)})},ae=H?`The address its Clone button shows under HTTPS, read ${U?"with the token":`through the organization's ${Kc.find(P=>P.id===u).label} connection`} before it is listed; its name and team are changed later in its Settings.`:i?"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:Z,...d?{"aria-labelledby":"connect-h"}:{"aria-label":J},children:[d?e.jsx("h2",{id:"connect-h",children:J}):null,e.jsxs("fieldset",{children:[e.jsx("legend",{children:"Where it is"}),Kc.filter(P=>P.id!=="path"||i||c).map(P=>e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"radio",name:"forge",value:P.id,checked:u===P.id,onChange:()=>p(P.id)})," ",P.id==="path"&&i?"A path on this machine":P.label]},P.id))]}),e.jsxs("label",{children:[H?"Clone address (https)":"Full path",e.jsx("input",{className:H?void 0:"mono",value:f,onChange:P=>g(P.target.value),placeholder:i&&u==="path"?jS():Kc.find(P=>P.id===u).example,required:!0,autoComplete:"off",spellCheck:!1,...X})]}),H&&(k||f.trim()&&!ie)?e.jsxs("label",{children:["Project",e.jsx("input",{value:j,onChange:P=>y(P.target.value),placeholder:ie||(Vr(u)?et[u].projectShape:void 0),maxLength:200,autoComplete:"off",spellCheck:!1,...X})]}):H&&ie?e.jsxs("p",{className:"muted small",children:["Project ",e.jsx("span",{className:"mono",children:ie})," ",e.jsx("button",{type:"button",className:"link",onClick:()=>N(!0),children:"Change project"})]}):null,i||w.length<2?null:R?e.jsx(Pe,{label:"Team",value:b,onChange:$,describedBy:X["aria-describedby"],options:w.map(P=>({value:P,label:P}))}):e.jsxs("p",{className:"muted small",children:["Team ",b," ",e.jsx("button",{type:"button",className:"link",onClick:()=>T(!0),children:"Change team"})]}),U?e.jsxs("div",{className:"field",children:[e.jsxs("span",{className:"field-name",children:[e.jsxs("label",{htmlFor:M,children:["Token",i?" (optional)":""]}),e.jsxs(Ee,{label:"how it is kept",children:[i?"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:M,type:"password",value:C,onChange:P=>E(P.target.value),required:!i,autoComplete:"off",...X})]}):null,L?e.jsx("p",{className:"error",role:"alert",id:A,children:L}):null,e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",disabled:O,children:O?i?"Reading the folder…":"Reading the repository…":i?"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 ${i?"the folder":"the project"}`,children:e.jsxs("section",{children:[e.jsx("h2",{children:H?"The address":"The path"}),e.jsx("p",{children:ae})]})})]})}const vS=/a personal account/;function kS({owner:t,onSaved:s}){const r=m.useId(),[l,i]=m.useState(null),[c,d]=m.useState(""),[u,p]=m.useState(""),[f,g]=m.useState(""),[j,y]=m.useState(null),[k,N]=m.useState(!1);if(m.useEffect(()=>{Zn.gitlabApp().then(i,()=>i(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 w=b=>{b.preventDefault(),N(!0),y(null),Zn.setGitlabApp({url:c.trim(),clientId:u.trim(),clientSecret:f}).then(()=>{g(""),N(!1),Zn.gitlabApp().then(i,()=>i(null)),s()},$=>{y($.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:w,"aria-labelledby":`${r}-h`,children:[e.jsx("h3",{id:`${r}-h`,children:"Your GitLab application"}),e.jsxs("label",{children:["GitLab address",e.jsx("input",{value:c,onChange:b=>d(b.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:b=>p(b.target.value),required:!0,autoComplete:"off",spellCheck:!1})]}),e.jsxs("label",{children:["Secret",e.jsx("input",{type:"password",value:f,onChange:b=>g(b.target.value),required:!0,autoComplete:"off"})]}),e.jsx("p",{className:"muted",children:"The secret is sealed and never shown again."}),j?e.jsx("p",{className:"error",role:"alert",children:j}):null,e.jsx("div",{className:"actions",children:e.jsx("button",{type:"submit",disabled:k,children:k?"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 wS({forges:t,repos:s,problem:r,owner:l,paths:i,onChanged:c}){var y;const[d,u]=m.useState(null),[p,f]=m.useState(null),g=Ja.filter(k=>{var N;return(N=t[k])==null?void 0:N.available}),j=k=>{f(k),u(null),Zn.connect(k,"welcome").then(({authorizeUrl:N})=>window.location.assign(N),N=>{u(N.message),f(null)})};return e.jsxs(e.Fragment,{children:[r?e.jsxs("p",{className:"error",role:"alert",children:["GitLab or GitHub did not connect: ",r.replace(/[.\s]*$/,".")]}):null,Ja.map(k=>{var w;const N=(w=t[k])==null?void 0:w.connection;return N?e.jsx("p",{children:N.problem?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"error",children:[Jt[k]," as ",N.account," needs reconnecting: ",N.problem]})," ",e.jsxs("button",{type:"button",className:"secondary small",disabled:p!==null,onClick:()=>j(k),children:["Reconnect ",Jt[k]]})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"badge ok",children:"connected"})," ",Jt[k]," as ",N.account]})},k):null}),g.length?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:[g.map(k=>Jt[k]).join(" or ")," asks you to approve TeamHandbook Orchestrator, then brings you back here."]}),e.jsx("div",{className:"actions",children:g.filter(k=>{var N;return!((N=t[k])!=null&&N.connection)}).map((k,N)=>e.jsx("button",{type:"button",className:N?"secondary":void 0,disabled:p!==null,onClick:()=>j(k),children:p===k?`Opening ${Jt[k]}…`:`Connect ${Jt[k]}`},k))})]}):Mo(t)?null:e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Connect your team's repository with a token instead. ",e.jsx(Ee,{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(Eg,{repos:s,forge:"gitlab",paths:i,titled:!1,onConnected:c})]}),(y=t.gitlab)!=null&&y.connection?null:e.jsx(kS,{owner:l,onSaved:c}),d?e.jsx("p",{className:"error",role:"alert",children:d}):null]})}function bS({kind:t,onMade:s}){const r=m.useId(),[l,i]=m.useState(""),[c,d]=m.useState(""),u=et[t].group,[p,f]=m.useState("private"),[g,j]=m.useState(""),[y,k]=m.useState(null),[N,w]=m.useState(!1),b=$=>{$.preventDefault(),w(!0),k(null),Zn.teamRepo(t,{name:l.trim(),team:c.trim(),visibility:p,...u&&g.trim()?{namespace:g.trim()}:{}}).then(({repo:R,webhook:T})=>{w(!1),s(`${R.name} is set up on ${Jt[t]} with the scaffold as its first commit.${T==="installed"?"":` The webhook is ${T}; the orchestrator reads the repository on its own schedule instead.`}`)},R=>{k(R.message),w(!1)})};return e.jsxs("form",{className:"form",onSubmit:b,"aria-labelledby":`${r}-h`,children:[e.jsxs("h3",{id:`${r}-h`,children:["A new repository on ",Jt[t]]}),e.jsxs("p",{className:"muted",children:["The orchestrator creates this repository on ",Jt[t]," and writes its first commit straight to it. ",e.jsx(Ee,{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:$=>i($.target.value),required:!0,autoComplete:"off",spellCheck:!1,placeholder:"payments-skills"})]}),e.jsxs("label",{children:["Team",e.jsx("input",{value:c,onChange:$=>d($.target.value),required:!0,autoComplete:"off",placeholder:"Payments"})]}),e.jsx(Pe,{label:"Visibility",value:p,onChange:$=>f($),options:et[t].visibilities.map($=>({value:$,label:$.charAt(0).toUpperCase()+$.slice(1)}))}),u?e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:[u.label,e.jsx("input",{value:g,onChange:$=>j($.target.value),autoComplete:"off",spellCheck:!1,placeholder:u.placeholder,"aria-describedby":`${r}-group`})]}),e.jsx("p",{className:"muted",id:`${r}-group`,children:u.meaning})]}):null,y&&vS.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 NS({kind:t,manageUrl:s,onMade:r,onCreate:l}){const i=m.useId(),[c,d]=m.useState(null),[u,p]=m.useState(null),[f,g]=m.useState(""),[j,y]=m.useState(null),[k,N]=m.useState(!1),w=()=>{d(null),y(null),Zn.repos(t).then(R=>d(R.filter(T=>!T.connected)),R=>y(R.message))};m.useEffect(w,[t]);const b=(c==null?void 0:c.find(R=>R.fullName===u))??null,$=R=>{if(R.preventDefault(),!b)return;N(!0),y(null),(b.empty?Zn.teamRepo(t,{existing:b.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.`):Zn.connectRepo(t,{fullName:b.fullName,team:f.trim()}).then(({repo:C})=>`${C.name} is connected; every change to it opens as a request.`)).then(C=>{d(E=>(E==null?void 0:E.filter(O=>O.fullName!==b.fullName))??null),p(null),N(!1),r(C)},C=>{y(C.message),N(!1)})};return c?c.length?e.jsxs("form",{className:"form",onSubmit:$,"aria-labelledby":`${i}-h`,children:[e.jsxs("fieldset",{className:"plain-fieldset",children:[e.jsxs("legend",{id:`${i}-h`,children:["Your repositories on ",Jt[t]]}),e.jsx("ul",{className:"plain welcome-repos",children:c.map(R=>e.jsx("li",{children:e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"radio",name:`${i}-repo`,checked:u===R.fullName,onChange:()=>p(R.fullName),required:!0})," ",R.fullName," ",R.empty?e.jsx("span",{className:"badge",children:"empty"}):null]})},R.fullName))})]}),b!=null&&b.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(Ee,{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:R=>g(R.target.value),required:!0,autoComplete:"off",placeholder:"Payments"})]}),j?e.jsx("p",{className:"error",role:"alert",children:j}):null,e.jsx("div",{className:"actions",children:e.jsx("button",{type:"submit",disabled:k||!b,children:b!=null&&b.empty?"Set it up":"Connect it"})})]}):e.jsxs("div",{className:"welcome-step-empty",children:[e.jsxs("p",{children:[Jt[t]," lists no repository this connection reaches that is not connected already."]}),e.jsx("p",{className:"muted",children:et[t].emptyListHint}),e.jsxs("div",{className:"actions",children:[s?e.jsx("a",{className:"button secondary",href:s,target:"_blank",rel:"noreferrer",children:"Choose the repositories the GitHub app reaches"}):null,e.jsx("button",{type:"button",className:"secondary",onClick:w,children:"Read the list again"}),e.jsx("button",{type:"button",onClick:l,children:"Create a new one"})]})]}):j?e.jsx(ve,{what:"your repositories",reason:j,onRetry:w}):e.jsx(fe,{what:`your repositories on ${Jt[t]}`})}function SS({forges:t,repos:s,paths:r,onChanged:l}){var g,j;const[i,c]=m.useState(!1),[d,u]=m.useState(null),p=Mo(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:!i,onChange:()=>c(!1)})," Pick an existing repository"]}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"radio",name:"repo-choice",checked:i,onChange:()=>c(!0)})," Create a new one"]})]}),d?e.jsx("p",{role:"status",children:d}):null,p?i?e.jsx(bS,{kind:p,onMade:f}):e.jsx(NS,{kind:p,manageUrl:((j=(g=t[p])==null?void 0:g.connection)==null?void 0:j.manageUrl)??null,onMade:f,onCreate:()=>c(!0)}):i?e.jsxs("p",{className:"muted",children:["Connect GitLab or GitHub first. ",e.jsx(Ee,{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(Eg,{repos:s,forge:"gitlab",paths:r,titled:!1,onConnected:l})]})}const CS=["forge","repo","members","start"];function $S(t){return["repo","members","start"].includes(t.id)||t.id==="forge"&&!t.done}function TS({step:t,me:s,org:r,repos:l,forges:i,problem:c,onChanged:d}){const[u,p]=m.useState([]),[f,g]=m.useState(null);return m.useEffect(()=>{t.id==="members"&&Xt.teams().then(p,()=>p([]))},[t.id]),t.id==="forge"?e.jsx(wS,{forges:i,repos:l,problem:c,owner:s.role==="owner",paths:s.pathRepos!==!1,onChanged:d}):t.id==="repo"?e.jsx(SS,{forges:i,repos:l,paths:s.pathRepos!==!1,onChanged:d}):t.id==="members"?e.jsxs(e.Fragment,{children:[e.jsx(Wu,{me:s,teams:u,onSent:(j,y)=>{g({invited:j,skipped:y}),d()}}),f?e.jsx(Rf,{sent:f.invited,skipped:f.skipped}):null]}):t.id==="start"?e.jsxs("div",{className:"actions",children:[e.jsx("a",{className:"button",href:we(r,"work"),children:"Open Work"}),e.jsx("a",{className:"button secondary",href:`${we(r,"integrations")}?open=jira`,children:"Connect Jira"})]}):null}function Ep({org:t,onRepos:s,computer:r=!1}){const[l,i]=m.useState(null),[c,d]=m.useState(void 0),[u,p]=m.useState(null),[f,g]=m.useState(null);m.useEffect(()=>{Je.list().then(({projects:y,last:k,home:N})=>{d(y.find(w=>w.id===k)??null),p(N??null)},()=>d(null))},[]);const j=(y,k,N)=>{d(y),p(k),g(N),s()};return e.jsxs("section",{className:"first-screen","aria-labelledby":"first-promise-h",children:[e.jsx("h1",{id:"first-promise-h",className:"first-promise",children:r?rb:dg}),r&&!l?e.jsx(lS,{onConnected:i}):c===void 0?e.jsx(fe,{what:"where your code lives"}):c?e.jsx(xS,{project:c,home:u,onChange:()=>d(null),onStarted:y=>Ue(we(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(ed,{onOpened:j,lead:e.jsx(ES,{}),...l?{machine:l.id,where:`On ${l.name}`}:{},...f?{from:f}:{}})]})]})}function ES(){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 Rg({me:t,org:s,repos:r,onRepos:l,onFinished:i}){const c=new URLSearchParams(tl().search);if(t.mode==="local")return e.jsx(Ep,{org:s,onRepos:l});const d=Ie(t)&&["step","forge_connected","forge_problem"].some(u=>c.has(u));return t.runners&&t.tasksRunHere===!1&&!d?e.jsx(Ep,{org:s,onRepos:l,computer:!0}):e.jsx(RS,{me:t,org:s,repos:r,onRepos:l,...i?{onFinished:i}:{}})}function RS({me:t,org:s,repos:r,onRepos:l,onFinished:i}){var M,Q;const[c,d]=m.useState(null),[u,p]=m.useState(null),[f,g]=m.useState(null),[j,y]=m.useState(null),k=tl(),N=new URLSearchParams(k.search).get("forge_problem"),[w,b]=qu(Ie(t)),$=()=>{g(null),Promise.all([Ne.summary(),Ne.onboarding()]).then(([H,U])=>{d(H),p(U)},H=>g(H.message))};if(m.useEffect($,[]),!Ie(t))return e.jsx("div",{className:"page",children:e.jsx(Cn,{title:`Welcome to ${s}`,summary:e.jsxs(e.Fragment,{children:["An owner or an admin sets the organization up; your first task starts on ",e.jsx("a",{href:we(s,"tasks"),children:"Tasks"}),"."]})})});if(f)return e.jsx(ve,{what:"the welcome steps",reason:f,onRetry:$,panel:!0});if(!c||!u||!w)return e.jsx(fe,{what:"the welcome steps",panel:!0});const R=(M=r.find(H=>H.configured!==!1))==null?void 0:M.id,T=Nf(s,c,R,Mo(w)!==null).filter(H=>CS.includes(H.id)),C=T.findIndex(H=>!H.done&&!u.skipped.includes(H.id)),E=T.findIndex(H=>H.id===new URLSearchParams(k.search).get("step")),O=j??(N?0:E!==-1?E:C===-1?T.length:C),F=T[O],L=()=>{$(),b(),l()},W=H=>Ne.changeOnboarding({skipped:[...u.skipped.filter(U=>U!==H),H]}).then(U=>{p(U),y(O+1)},U=>g(U.message)),A=T.filter(H=>!H.done);return e.jsxs("div",{className:"page welcome",children:[e.jsx(Cn,{title:`Welcome to ${s}`,summary:e.jsxs(e.Fragment,{children:[T.length," steps set your organization up. ",e.jsx(Ee,{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:T.map((H,U)=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"step-item","aria-current":U===O?"step":void 0,onClick:()=>y(U),children:[e.jsx("span",{className:`step-mark ${H.done?"done":""}`,"aria-hidden":"true",children:H.done?"✓":U+1}),H.title,e.jsx("span",{className:"step-state",children:H.done?"done":u.skipped.includes(H.id)?"skipped":""})]})},H.id))})}),F?e.jsxs("section",{className:"panel welcome-step","aria-labelledby":"welcome-step-h",children:[e.jsxs("h2",{id:"welcome-step-h","aria-live":"polite",children:[F.title," ",F.done?e.jsx("span",{className:"badge ok",children:"done"}):null]}),e.jsx("p",{children:F.detail}),e.jsx(TS,{step:F,me:t,org:s,repos:r,forges:w??{gitlab:null,github:null},problem:N,onChanged:L},F.id),e.jsxs("div",{className:"actions",children:[O>0?e.jsxs("button",{type:"button",className:"secondary",onClick:()=>y(O-1),children:["Back to ",T[O-1].title]}):null,F.done?e.jsx("button",{type:"button",className:$S(F)?"secondary":void 0,onClick:()=>y(O+1),children:((Q=T[O+1])==null?void 0:Q.title)??"Finish"}):e.jsx("button",{type:"button",className:"secondary",onClick:()=>void W(F.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"}),A.length?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["These wait under Getting set up on ",e.jsx("a",{href:we(s,"team"),children:"Team"})," whenever you come back to them:"]}),e.jsx("ul",{className:"plain",children:A.map(H=>e.jsx("li",{children:H.title},H.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:we(s,"welcome"),children:"Start the first task"}):e.jsx("a",{className:"button",href:we(s,"tasks"),...i?{onClick:H=>{H.preventDefault(),i()}}:{},children:"Open Tasks"})})]})]})]})}function PS({message:t}){const[s,r]=m.useState(["",""]),l=m.useRef(!0),i=m.useRef(0);return m.useEffect(()=>{if(l.current){l.current=!1;return}i.current=1-i.current,r(i.current?["",t]:[t,""])},[t]),e.jsxs("div",{className:"visually-hidden",children:[e.jsx("span",{"aria-live":"polite",children:s[0]}),e.jsx("span",{"aria-live":"polite",children:s[1]})]})}const Rp=20,AS=6e4,Po={jira:"Jira",confluence:"Confluence",github:"GitHub",gitlab:"GitLab",sentry:"Sentry",linear:"Linear",notion:"Notion",slack:"Slack"},IS={get:"Read",fetch:"Read",view:"Read",read:"Read",search:"Searched",query:"Searched",find:"Searched"},OS={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"},za=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[\s_\-]+/).filter(Boolean).map(s=>s.toLowerCase());function LS(t){const s=za(t).find(r=>Po[r]);return s?Po[s]:t}function FS(t,s){const r=/^mcp__(.+?)__(.+)$/.exec(t),l=s?[t,s.server,s.tool]:r;if(!l)return{verb:DS[t]??`Used ${za(t).join(" ")}`,source:null,object:null};const i=s?l[1]:l[1].replace(/^plugin_[^_]+_/,""),c=za(l[2]),d=[...c,...za(i)].find(g=>Po[g]),u=d?Po[d]:za(i).join(" "),p=IS[c[0]??""];if(!p)return{verb:`Used ${c.filter(g=>g!==d).join(" ")}`,source:u,object:null};const f=c.slice(1).map(g=>OS[g]).find(Boolean)??null;return{verb:p,source:u,object:f}}const MS=new Set(["Read","Edit","MultiEdit","Write","NotebookEdit","Glob","Grep"]);function _S(t,{folder:s,home:r}){return t.startsWith("/")?s&&t.startsWith(`${s}/`)?t.slice(s.length+1):r&&t.startsWith(`${r}/`)?`~${t.slice(r.length)}`:t:t}const DS={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"},Pg={Read:"files",Searched:"times",Fetched:"pages"},it=t=>typeof t=="string"?t:null,Pp=t=>typeof t=="number"&&Number.isInteger(t)&&t>=0?t:null;function US(t){if(!Array.isArray(t))return null;const s=[];for(const r of t){const l=r,i=it(l==null?void 0:l.text),c=l==null?void 0:l.state;if(!i||c!=="todo"&&c!=="doing"&&c!=="done")return null;s.push({text:i,state:c})}return s}function qS(t,s={folder:null,home:null}){var p,f,g,j,y;const r={plan:[],stream:[],changed:[],costUsd:null},l=new Map,i=new Map,c=new Map,d=new Map,u=k=>{const N=r.stream.at(-1);N&&new Date(k.at).getTime()-new Date(N.at).getTime()>AS&&r.stream.push({kind:"time",key:`time-${k.key}`,at:k.at}),r.stream.push(k)};for(const k of t){const N=k.data;if(!(!N||N.type!==k.kind)){if(k.kind==="message"){const w=(p=it(N.text))==null?void 0:p.trim();w&&u({kind:"say",key:`say-${k.seq}`,at:k.at,text:w})}else if(k.kind==="steer"){const w=(f=it(N.text))==null?void 0:f.trim();w&&u({kind:"you",key:`you-${k.seq}`,at:k.at,text:w,by:it(N.by)})}else if(k.kind==="todos"){const w=US(N.items);w&&(r.plan=w)}else if(k.kind==="usage"){const w=(g=N.cost)==null?void 0:g.usd;typeof w=="number"&&Number.isFinite(w)&&(r.costUsd=(r.costUsd??0)+w)}else if(k.kind==="tool_call"){const w=it(N.tool),b=N.status;if(!w||b!=="started"&&b!=="done"&&b!=="failed"&&b!=="refused")continue;const $=it(N.id),R=$?l.get($):void 0;if(R){const M=i.get($);M&&(M.status=b,b==="refused"&&(M.reason=it((j=N.refusal)==null?void 0:j.reason))),R.status=b;continue}const T=N.mcp,C=FS(w,it(T==null?void 0:T.server)&&it(T==null?void 0:T.tool)?{server:it(T.server),tool:it(T.tool)}:null),E=b==="refused"?it((y=N.refusal)==null?void 0:y.reason):null,O=it(w==="Bash"?N.command:N.target),F={tool:w,target:O===w?null:O&&MS.has(w)?_S(O,s):O,status:b,reason:E},L=r.stream.at(-1);if((L==null?void 0:L.kind)==="tool"&&L.verb===C.verb&&L.source===C.source&&!L.output.length&&!L.change&&(b==="refused"?L.status==="refused"&&L.calls[0].tool===w&&L.calls[0].reason===E:b==="started"&&L.status!=="failed"&&L.status!=="refused"&&(Pg[C.verb]!==void 0||C.source!==null))&&(L==null?void 0:L.kind)==="tool"){L.calls.push(F),L.status=b,$&&(l.set($,L),i.set($,F));continue}const A={kind:"tool",key:`tool-${k.seq}`,at:k.at,...C,calls:[F],status:b,output:[],outputTotal:0,change:null};$&&(l.set($,A),i.set($,F)),u(A)}else if(k.kind==="tool_output"){const w=l.get(it(N.id)??""),b=Array.isArray(N.lines)?N.lines.filter($=>typeof $=="string"):[];w&&(w.outputTotal+=b.length,w.calls.every($=>$.tool==="Read")||(w.output=[...w.output,...b].slice(-2e3)))}else if(k.kind==="edit"){const w=it(N.path),b=Pp(N.additions),$=Pp(N.deletions);if(!w||b===null||$===null)continue;const R=l.get(it(N.id)??"");R&&(R.change={additions:b,deletions:$,patch:it(N.patch)});const T=d.get(w);d.set(w,{path:w,additions:((T==null?void 0:T.additions)??0)+b,deletions:((T==null?void 0:T.deletions)??0)+$})}else if(k.kind==="request"){const w=N.request,b=it(w==null?void 0:w.id),$=it(w==null?void 0:w.summary);b&&$&&c.set(b,(w==null?void 0:w.kind)==="question"?"the question":$)}else if(k.kind==="request_resolved"){const w=c.get(it(N.requestId)??""),b=w?BS(N.decision,w):null;b&&u({kind:"card",key:`card-${k.seq}`,at:k.at,text:b})}}}return r.changed=[...d.values()],r}function BS(t,s){return t==="allow-once"?`You allowed ${s} once`:t==="allow-for-task"?`You allowed ${s} for this task`:t==="deny"?`You denied ${s}`:null}const Ap=(t,s,r)=>{const l=t.slice(0,t.length>s+1?s:t.length),i=t.length-l.length;return i?`${l.join(", ")} and ${i} more ${r}`:l.length===1?l[0]:`${l.slice(0,-1).join(", ")} and ${l.at(-1)}`};function zS(t){const s=t.calls.map(c=>c.target).filter(c=>c!==null),r=t.verb==="Searched",l=c=>r?`"${c}"`:c;if(t.status==="refused"||t.calls.length===1){const c=s[0]??null;return t.source?r?{before:`Searched ${t.source}`,target:null,after:c?` for ${l(c)}`:""}:t.verb.startsWith("Used ")?{before:`${t.verb} in ${t.source}`,target:null,after:""}:{before:`${t.verb} ${c??t.object??"it"} in ${t.source}`,target:null,after:""}:c?{before:t.verb,target:r?null:c,after:r?` ${l(c)}`:""}:{before:t.verb,target:null,after:""}}if(r)return{before:`Searched${t.source?` ${t.source}`:""} ${t.calls.length} times`,target:null,after:s.length?`: ${Ap(s.map(l),2,"")}`.trimEnd():""};const i=Pg[t.verb]??(t.source?"":"times");return{before:`${t.verb} ${Ap(s.length===t.calls.length?s:s.concat(Array(t.calls.length-s.length).fill(t.object??"it")),2,i).trimEnd()}${t.source?` in ${t.source}`:""}`,target:null,after:""}}const Ip=80;function WS(t){const s=t.trim().split(`
|
|
71
|
-
`)[0].replace(/\s+/g," ");return s.length>Ip||t.trim().includes(`
|
|
72
|
-
`)?`${s.slice(0,Ip).trimEnd()}…`:s}function Ag(t){var l;const s=t.calls.length===1?t.calls[0].target:null;if(!s||!/\.md$/i.test(s)||!((l=t.change)!=null&&l.patch)||t.change.deletions>0)return null;const r=t.change.patch.split(`
|
|
73
|
-
`).filter(i=>i.startsWith("+")&&!i.startsWith("+++"));return r.length?r.map(i=>i.slice(1)).join(`
|
|
74
|
-
`):null}function HS(t){for(const s of[...t].reverse()){if(s.kind!=="tool"||!s.calls.some(l=>{var i;return(i=l.target)==null?void 0:i.includes(".orchestrator-plans/")}))continue;const r=Ag(s);if(r!=null&&r.trim())return r}return null}function GS(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 KS=t=>new Date(t).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),Op=t=>`${t.toLocaleString("en-US")} ${t===1?"line":"lines"}`,Lp={started:"running",done:"done",failed:"failed",refused:"refused"},VS="This task does not allow this tool.";function YS({line:t,current:s}){var j,y;const{before:r,target:l,after:i}=zS(t),c=GS(t),[d,u]=m.useState(!1),p=t.calls.every(k=>k.tool==="Read"),f=d?t.output:t.output.slice(-Rp),g=Ag(t);return e.jsx("li",{className:"run-line","data-kind":"tool","data-status":Lp[t.status],...s?{"data-current":""}:{},children:e.jsxs("details",{children:[e.jsxs("summary",{children:[e.jsx("span",{className:"run-mark","data-status":Lp[t.status],"aria-hidden":"true"}),r,l?e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{className:"mono",dir:"auto",children:t.verb==="Ran"?WS(l):l})]}):null,i,t.change?e.jsxs(e.Fragment,{children:[" ",e.jsx(Uo,{added:t.change.additions,removed:t.change.deletions})," ",e.jsx("span",{className:"diff-stat",children:e.jsx(Yu,{added:t.change.additions,removed:t.change.deletions})})]}):null,c?e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{className:`state ${c.tone}`,children:c.word})]}):null]}),p&&t.outputTotal?e.jsxs("p",{className:"muted small",children:[Op(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${d?" run-output-all":""}`,children:f.join(`
|
|
75
|
-
`)}):null,t.outputTotal>Rp&&!p?e.jsx("button",{type:"button",className:"link small","aria-expanded":d,onClick:()=>u(!d),children:d?"Show the last lines":`Show all ${Op(t.outputTotal)}`}):null,g!==null?e.jsx("div",{className:"plan-text",dir:"auto",children:e.jsx(Jr,{text:g})}):(j=t.change)!=null&&j.patch?e.jsx(Gf,{patch:t.change.patch}):null,t.status==="refused"?e.jsx("p",{className:"muted small",children:((y=t.calls[0])==null?void 0:y.reason)??VS}):null,e.jsx("ul",{className:"plain muted small",children:t.calls.map((k,N)=>e.jsxs("li",{children:[e.jsx("span",{className:"mono",dir:"auto",children:k.tool}),k.target?e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{className:"mono run-command",dir:"auto",children:k.target})]}):null]},N))})]})})}const QS=5;function JS({plan:t}){const[s,r]=m.useState(!1),l=t.findIndex(u=>u.state==="doing"),i=t.findIndex(u=>u.state!=="done"),c=l>=0?l:i>=0?i:t.length-1,d=t.length>QS;return e.jsxs(e.Fragment,{children:[e.jsx("ol",{className:"run-plan","aria-label":"The agent's plan",...d?{"data-long":""}:{},...s?{"data-open":""}:{},children:t.map((u,p)=>e.jsx("li",{"data-state":u.state,dir:"auto",...p===c?{"data-at":""}:{},children:u.text},p))}),t.length>1?e.jsx("button",{type:"button",className:"link small run-plan-more","aria-expanded":s,onClick:()=>r(!s),...d?{"data-long":""}:{},children:s?"Show less":`${t.length-1} more`}):null]})}function Fp({run:t,working:s=!1,withPlan:r=!0,first:l=null}){const i=t.stream.at(-1),c=s&&(i==null?void 0:i.kind)==="tool"&&i.status==="started"?i.key:null;return e.jsxs(e.Fragment,{children:[r&&t.plan.length?e.jsx("ol",{className:"run-plan","aria-label":"The agent's plan",children:t.plan.map((d,u)=>e.jsx("li",{"data-state":d.state,dir:"auto",children:d.text},u))}):null,e.jsxs("ol",{className:"run-stream","aria-label":"What the agent did","data-quotable":"",children:[l,t.stream.map(d=>d.kind==="tool"?e.jsx(YS,{line:d,current:d.key===c},d.key):d.kind==="time"?e.jsx("li",{className:"run-line","data-kind":"time",children:e.jsx("time",{dateTime:d.at,children:KS(d.at)})},d.key):d.kind==="you"?e.jsxs("li",{className:"run-line","data-kind":"you",dir:"auto",children:[e.jsx("strong",{children:d.by??"You"})," ",d.text]},d.key):d.kind==="say"?e.jsx("li",{className:"run-line","data-kind":"say","data-seq":d.key.slice(4),children:e.jsx(Jr,{text:d.text})},d.key):e.jsx("li",{className:"run-line","data-kind":d.kind,dir:"auto",children:d.text},d.key)),s&&!c?e.jsx("li",{className:"run-line","data-kind":"now",children:"Thinking…"}):null]})]})}function Ig({label:t,read:s,value:r,onChange:l,local:i=!1}){const c=new Map(s.suggestions.map(u=>[u.skill,u.reason])),d=u=>l(r.includes(u)?r.filter(p=>p!==u):[...r,u]);return s.skills.length?e.jsxs("fieldset",{className:"skill-chips",children:[e.jsxs("legend",{children:[t," ",e.jsxs("span",{className:"count",children:[r.length," of ",Co]})]}),e.jsx("div",{className:"chips",children:s.skills.map(u=>{const p=r.includes(u.name);return e.jsxs("label",{className:`chip-pick${p?" on":""}`,title:u.description,children:[e.jsx("input",{type:"checkbox",checked:p,disabled:!p&&r.length>=Co,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)})}),s.suggestions.length?e.jsx("ul",{className:"plain reasons",children:s.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:s.note??`The agent suggested none; it still has ${i?"every skill":"every team skill"}.`})]}):e.jsx("p",{className:"muted small",children:i?"There are no skills here yet.":"The team has no skills here yet."})}const XS={projectSkills:[],mcpServers:[],commands:[]};function ZS(t,s){return{projectSkills:t.map(r=>({source:r.source,name:r.name})),mcpServers:s.filter(r=>r.transport==="http").map(r=>r.id),commands:[]}}function eC(t){return t.transport==="stdio"?`${t.name} runs ${[t.command,...t.args].join(" ")}`:t.name}const Vc=(t,s,r)=>t?`${t} ${t===1?s:r}`:null;function $u(t){const s=[Vc(t.commands,"skill or command","skills or commands"),Vc(t.plugins,"plugin","plugins"),Vc(t.mcpServers,"MCP server","MCP servers"),t.claudeMd?"CLAUDE.md":null].filter(r=>r!==null);return s.length?s.length===1?s[0]:`${s.slice(0,-1).join(", ")} and ${s[s.length-1]}`:null}function tC(t,s){var l;if(!s)return null;const r=$u({commands:s.commands.length,plugins:s.plugins.filter(i=>i.enabled).length,mcpServers:((l=s.mcpServers)==null?void 0:l.length)??0,claudeMd:!!s.claudeMd});return r?`${t} loads ${r}`:null}function nC({label:t,personal:s}){const r=tC(t,s);if(!r||!s)return null;const l=[...s.plugins.filter(i=>i.enabled).map(i=>i.name),...s.commands.map(i=>`/${i.name}`),...(s.mcpServers??[]).map(i=>i.name)];return e.jsxs("details",{className:"agent-loaded muted small",children:[e.jsxs("summary",{children:[r,"."]}),l.length?e.jsx("p",{className:"mono",children:l.join(", ")}):null]})}function sC({repoId:t,value:s,onChange:r,canAdd:l}){const[i,c]=m.useState([]),[d,u]=m.useState([]),[p,f]=m.useState(!1),[g,j]=m.useState(0);if(m.useEffect(()=>{let w=!0;return Promise.all([Ms.skills(t).then(b=>b.project,()=>[]),Ms.read(t).then(b=>b.mcpServers,()=>[])]).then(([b,$])=>{w&&(c(b),u($),r(ZS(b,$)))}),()=>{w=!1}},[t,g]),!i.length&&!d.length&&!l)return null;const y=w=>s.projectSkills.some(b=>b.source===w.source&&b.name===w.name),k=w=>r({...s,projectSkills:y(w)?s.projectSkills.filter(b=>!(b.source===w.source&&b.name===w.name)):[...s.projectSkills,{source:w.source,name:w.name}]}),N=w=>{const b=s.mcpServers.includes(w)?s.mcpServers.filter($=>$!==w):[...s.mcpServers,w];r({...s,mcpServers:b,commands:b.filter($=>{var R;return((R=d.find(T=>T.id===$))==null?void 0:R.transport)==="stdio"})})};return e.jsxs("fieldset",{className:"plain-fieldset task-tools",children:[e.jsx("legend",{children:"Skills and MCP servers for this task"}),i.length||d.length?e.jsxs("div",{className:"chips",role:"group","aria-label":"The project's skills and MCP servers",children:[i.map(w=>e.jsxs("label",{className:`chip-pick${y(w)?" on":""}`,title:w.description,children:[e.jsx("input",{type:"checkbox",checked:y(w),onChange:()=>k(w)}),e.jsx("span",{className:"mono",children:w.name})]},`${w.source}:${w.name}`)),d.map(w=>e.jsxs("label",{className:`chip-pick${s.mcpServers.includes(w.id)?" on":""}`,title:w.transport==="http"?w.url:void 0,children:[e.jsx("input",{type:"checkbox",checked:s.mcpServers.includes(w.id),onChange:()=>N(w.id)}),e.jsx("span",{className:"mono",children:eC(w)})," ",e.jsx("span",{className:"muted small",children:"MCP"})]},w.id))]}):null,l?p?e.jsx(gg,{project:t,onCancel:()=>f(!1),onAdded:()=>{f(!1),j(w=>w+1)}}):e.jsx("p",{children:e.jsx("button",{type:"button",className:"link",onClick:()=>f(!0),children:"Add a skill repository"})}):null]})}const Og=4096;function rC(t){return Object.fromEntries(t.map(s=>[s.key,{chosen:[],other:null}]))}function Mp(t,s,r){const l=t[s.key]??{chosen:[],other:null},i=s.choice==="one"?[r]:l.chosen.includes(r)?l.chosen.filter(c=>c!==r):[...l.chosen,r];return{...t,[s.key]:{...l,chosen:i}}}function aC(t,s,r){const l=t[s.key]??{chosen:[],other:null};return{...t,[s.key]:{...l,other:r.trim()?r.slice(0,Og):null}}}function _p(t,s){return t.every(r=>{var i;const l=s[r.key];return!!(l&&(l.chosen.length||(i=l.other)!=null&&i.trim()))})}function lC(t,s){return s&&[s.chosen.map(l=>{var i,c;return((c=(i=t.options)==null?void 0:i.find(d=>d.value===l))==null?void 0:c.label)??l}).join(", "),s.other??""].filter(Boolean).join("; ")||"no answer"}const oC=2e4;function iC(t){return t.split(`
|
|
76
|
-
`).filter(s=>/^\s*(\d+[.)]|[-*])\s+\S/.test(s)).length}function cC({task:t,request:s,mine:r,onAnswered:l}){const i=s.payload.plan??"",[c,d]=m.useState(!1),[u,p]=m.useState(i),[f,g]=m.useState(!1),[j,y]=m.useState(null),k=m.useRef(null),N=s.status==="pending"&&s.responseCapability==="live",w=(R,T)=>{g(!0),y(null),$e.answerPlan(t.id,s.id,R,T).then(l,C=>{y(C.message),g(!1),C instanceof ut&&C.status===409&&l()})},b=iC(i),$=s.status==="answered"&&s.answer&&"decision"in s.answer?s.answer.decision:null;return e.jsxs("li",{className:`approval plan${N?" pending":""}`,"aria-label":"The agent's plan",children:[$==="deny"?e.jsxs("p",{className:"muted small",children:[s.answeredBy??"Its starter"," declined the plan; nothing changed."]}):$?e.jsxs("p",{className:"muted small",children:[s.answeredBy===null||r?"You":s.answeredBy," started with the plan",b?`, ${b} ${b===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:oC,value:u,onChange:R=>p(R.target.value),disabled:f})]}):e.jsx("div",{ref:k,className:"plan-text",dir:"auto",children:e.jsx(Jr,{text:i})}),s.status==="withdrawn"?e.jsx("p",{className:"muted small",children:"The agent took this back; it needs no answer."}):N?r?e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",disabled:f||!u.trim(),onClick:()=>w("allow_once",c&&u.trim()!==i.trim()?u.trim():void 0),children:"Start with this plan"}),c?e.jsx("button",{type:"button",className:"secondary",disabled:f,onClick:()=>{d(!1),p(i)},children:"Keep the agent's plan"}):e.jsx("button",{type:"button",className:"secondary",disabled:f,onClick:()=>d(!0),children:"Change the plan"}),e.jsx(Uu,{text:c?u:i,target:k,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."})]}),j?e.jsx("p",{className:"error",role:"alert",children:j}):null]})}const Tu={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"},uC={allow_once:"allowed once",allow_for_task:"allowed for this task",deny:"denied"};function dC({task:t,request:s,mine:r,onAnswered:l}){const[i,c]=m.useState(""),[d,u]=m.useState(!1),[p,f]=m.useState(!1),[g,j]=m.useState(null),y=w=>{f(!0),j(null),$e.answer(t.id,s.id,w,i.trim()||void 0).then(l,b=>{j(b.message),f(!1),b instanceof ut&&b.status===409&&l()})},k=Yr(s),N=[s.payload.tool,s.payload.summary].filter(Boolean).join(": ");return e.jsxs("li",{className:`approval${k?" pending":""}`,"aria-label":`The agent asks to ${Tu[s.kind]}`,children:[e.jsx("p",{children:e.jsxs("strong",{children:["The agent asks to ",Tu[s.kind]]})}),N?e.jsx("pre",{className:"pre mono",children:N}):null,s.status==="answered"&&s.answer?"decision"in s.answer?e.jsxs("p",{className:"muted small",children:[s.answeredBy??"Its starter"," ",uC[s.answer.decision],s.answer.note?`: ${s.answer.note}`:"","."]}):null:s.status==="withdrawn"?e.jsx("p",{className:"muted small",children:"The agent took this back; it needs no answer."}):k?r?d?e.jsxs("div",{className:"form",children:[e.jsxs("label",{children:["A note for the agent (optional)",e.jsx("textarea",{className:"short",value:i,onChange:w=>c(w.target.value),rows:2,maxLength:2e3})]}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",disabled:p,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:p,onClick:()=>y("allow_once"),children:"Allow once"}),e.jsx("button",{type:"button",className:"secondary",disabled:p,onClick:()=>y("allow_for_task"),children:"Allow for this task"}),e.jsx("button",{type:"button",className:"secondary",disabled:p,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 hC="Not sent: part of it looks like a password or key. Write it without that, then send.";function mC({task:t,request:s,mine:r,agent:l,onAnswered:i}){const c=Array.isArray(s.payload.questions)?s.payload.questions:[],[d,u]=m.useState(()=>rC(c)),[p,f]=m.useState(!1),[g,j]=m.useState(""),[y,k]=m.useState(!1),[N,w]=m.useState(null),b=Yr(s),$=l||"The agent",R=F=>{w(F instanceof ut&&F.code==="answer-looks-secret"?hC:F.message),k(!1),F instanceof ut&&F.status===409&&i()},T=F=>{if(F.preventDefault(),!_p(c,d))return;k(!0),w(null);const L=Object.fromEntries(Object.entries(d).map(([W,A])=>{var M;return[W,{chosen:A.chosen,other:((M=A.other)==null?void 0:M.trim())||null}]}));$e.answerQuestions(t.id,s.id,L).then(i,R)},C=()=>{k(!0),w(null),$e.answer(t.id,s.id,"deny",g.trim()||void 0).then(i,R)},E=F=>L=>{var A;if(L.target instanceof HTMLTextAreaElement||!/^[1-9]$/.test(L.key))return;const W=(A=F.options)==null?void 0:A[Number(L.key)-1];W&&(L.preventDefault(),u(Mp(d,F,W.value)))},O=s.answer;return e.jsxs("li",{className:`approval${b?" pending":""}`,"aria-label":`${$} asks you`,children:[c.length?s.status==="answered"&&O?"answers"in O?e.jsxs("dl",{className:"facts",children:[c.map(F=>e.jsxs("div",{children:[e.jsx("dt",{dir:"auto",children:F.title}),e.jsx("dd",{dir:"auto",children:lC(F,O.answers[F.key])})]},F.key)),e.jsxs("div",{children:[e.jsx("dt",{children:"Answered by"}),e.jsx("dd",{children:s.answeredBy??"its starter"})]})]}):e.jsxs("p",{className:"muted small",children:[s.answeredBy??"Its starter"," did not answer",O.note?`: ${O.note}`:"","."]}):s.status==="withdrawn"?e.jsx("p",{className:"muted small",children:"The agent took this back; it needs no answer."}):b?r?p?e.jsxs("div",{className:"form",children:[e.jsxs("label",{children:["A note for the agent (optional)",e.jsx("textarea",{className:"short",value:g,onChange:F=>j(F.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:T,"aria-label":`Answer ${$}`,children:[c.map(F=>{var L;return e.jsxs("fieldset",{className:"plain-fieldset question",onKeyDown:E(F),children:[e.jsx("legend",{dir:"auto",children:F.title}),F.description?e.jsx("p",{className:"muted small",dir:"auto",children:F.description}):null,(F.options??[]).map((W,A)=>{var M;return e.jsxs("label",{className:"check",children:[e.jsx("input",{type:F.choice==="many"?"checkbox":"radio",name:`${s.id}-${F.key}`,checked:((M=d[F.key])==null?void 0:M.chosen.includes(W.value))??!1,onChange:()=>u(Mp(d,F,W.value))}),e.jsxs("span",{children:[e.jsx("span",{dir:"auto",children:W.label}),A<9?e.jsxs(e.Fragment,{children:[" ",e.jsx("kbd",{"aria-label":`key ${A+1}`,children:A+1})]}):null,W.description?e.jsxs("span",{className:"muted small",dir:"auto",children:[" ",W.description]}):null]})]},W.value)}),F.choice==="text"||F.other?e.jsxs("label",{children:[F.choice==="text"?"Your answer":"Something else",e.jsx("textarea",{dir:"auto",className:"short",rows:2,maxLength:Og,value:((L=d[F.key])==null?void 0:L.other)??"",onChange:W=>u(aC(d,F,W.target.value))})]}):null]},F.key)}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",disabled:y||!_p(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(F=>e.jsx("p",{dir:"auto",children:F.title},F.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]})}const Yr=t=>t.status==="pending"&&t.responseCapability==="live";function Dp(t){return(t.requests??[]).some(Yr)}function pC(t){return[...t].reverse().sort((s,r)=>Number(Yr(r))-Number(Yr(s)))}function fC({task:t,me:s,agent:r,onAnswered:l}){const i=(t.requests??[]).filter(u=>Tu[u.kind]||u.kind==="question");if(!i.length)return null;const c=t.createdBy===s.email,d=i.filter(Yr).length;return e.jsxs("section",{className:"section","aria-labelledby":"task-requests-h",children:[e.jsxs("h2",{id:"task-requests-h",children:[r||"The agent"," asks you ",e.jsx("span",{className:"count",children:d?`${d} waiting`:i.length})]}),e.jsx("ul",{className:"plain approvals",children:pC(i).map(u=>u.kind==="plan"?e.jsx(cC,{task:t,request:u,mine:c,onAnswered:l},u.id):u.kind==="question"?e.jsx(mC,{task:t,request:u,mine:c,agent:r,onAnswered:l},u.id):e.jsx(dC,{task:t,request:u,mine:c,onAnswered:l},u.id))})]})}const gC=864e5;function xC(t,s=new Date){if(!t)return"Your plan's usage limit is reached; continue the task once it resets.";const r=new Date(t),l=r.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hourCycle:"h23"});return r.getTime()-s.getTime()>gC?`Your plan's usage limit is reached until ${r.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}${r.toDateString()===s.toDateString()?"":" tomorrow"}.`}function Lg(t,s){return s.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 jC({task:t,me:s,onContinued:r}){const[l,i]=m.useState(!1),[c,d]=m.useState(null),u=()=>{i(!0),d(null),$e.continue(t.id).then(r,k=>{d(k.message),i(!1)})},p=e.jsx("a",{href:ce("settings","machines"),children:"Your machines"}),f=Lg(t,s),g=s.mode==="local"?e.jsx("a",{href:ce("settings","agents"),children:"Agent readiness"}):p,j=t.status==="interrupted"&&t.createdBy===s.email?e.jsx("button",{type:"button",disabled:l,onClick:u,children:"Pick up where it stopped"}):null,y=f?e.jsxs(e.Fragment,{children:[f.line," ",e.jsx("a",{href:ce("settings","machines"),children:f.link})]}):t.waitingFor==="connect"||t.waitingFor==="machine"?null:t.waitingFor==="limit"?e.jsx(e.Fragment,{children:xC(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.":"Stopped when your machine went away."}):null;return y?e.jsxs("div",{className:"waiting",role:"status",children:[e.jsx("p",{children:y}),j,c?e.jsx("p",{className:"error",role:"alert",children:c}):null]}):null}const Yc=(t,s="")=>`/api/tasks/${encodeURIComponent(t)}/shares${s}`,Qc={list:t=>B("GET",Yc(t)).then(s=>s.shares),add:(t,s)=>B("POST",Yc(t),{email:s}),remove:(t,s)=>B("DELETE",Yc(t,`/${encodeURIComponent(s)}`))};function yC({task:t,canShare:s,manager:r,adding:l,onClose:i}){const[c,d]=m.useState(null),[u,p]=m.useState(0),[f,g]=m.useState(""),[j,y]=m.useState(!1),[k,N]=m.useState(null),[w,b]=m.useState(null);if(m.useEffect(()=>{Qc.list(t).then(d,()=>d([]))},[t,u]),!c||!c.length&&!l)return null;const $=C=>{C.preventDefault(),y(!0),N(null),Qc.add(t,f.trim()).then(()=>{g(""),p(E=>E+1),i()},E=>N({said:E.message,notMember:E instanceof ut&&E.code==="not-a-member"})).finally(()=>y(!1))},R=C=>b(w===C?null:C),T=c.find(C=>C.userId===w)??null;return e.jsxs("section",{"aria-labelledby":"task-shares-h",children:[e.jsxs("h2",{id:"task-shares-h",children:["Shared with"," ",s&&T?e.jsx(qe,{small:!0,trigger:"Remove…",triggerLabel:`Stop sharing with ${T.name}`,consequence:`${T.name} no longer reads this task.`,confirm:"Stop sharing",keep:"Keep sharing",onConfirm:()=>Qc.remove(t,T.userId).then(()=>{b(null),p(C=>C+1)})},T.userId):null]}),c.length&&s?e.jsx("ul",{className:"tool-list",role:"listbox","aria-label":"Shared with",onKeyDown:Cu,children:c.map((C,E)=>e.jsxs("li",{className:"tool-row",role:"option",tabIndex:fg(E,c.findIndex(O=>O.userId===w)),"aria-selected":w===C.userId,onClick:()=>R(C.userId),onKeyDown:O=>{O.key!=="Enter"&&O.key!==" "||(O.preventDefault(),R(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:$,"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:j||!f.trim(),children:"Share"}),e.jsx("button",{type:"button",className:"secondary",disabled:j,onClick:i,children:"Cancel"})]}),k?e.jsxs("p",{className:"error",role:"alert",children:[k.said,k.notMember&&r?e.jsxs(e.Fragment,{children:[" ",e.jsx("a",{href:ce("settings","members"),children:"Invite them on Members"})]}):null]}):null]}):null]})}const vC={added:"added",modified:"changed",deleted:"deleted",renamed:"renamed"};function kC(t,s){return t.first||!s.trim()?t.message:s.trim()}function wC({projectId:t,title:s,onCommitted:r,onCancel:l}){const[i,c]=m.useState(null),[d,u]=m.useState(null),[p,f]=m.useState(0),[g,j]=m.useState(""),[y,k]=m.useState(new Set),[N,w]=m.useState(!1),[b,$]=m.useState(null);if(m.useEffect(()=>{u(null),Je.commitPlan(t).then(E=>{c(E),j(kC(E,s)),k(new Set(E.files.filter(O=>O.secretLike).map(O=>O.path)))},E=>u(E.message))},[t,p]),d)return e.jsx(ve,{what:"what the commit takes",reason:d,onRetry:()=>f(E=>E+1)});if(!i)return e.jsx(fe,{what:"what the commit takes"});const R=E=>k(O=>{const F=new Set(O);return F.has(E)?F.delete(E):F.add(E),F}),T=i.files.length-y.size,C=E=>{E.preventDefault(),w(!0),$(null),Je.commit(t,g.trim(),[...y]).then(O=>r(O.headSha),O=>{$(O.message),w(!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:E=>j(E.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:[T," of ",i.files.length]})]}),e.jsx("ul",{className:"checks",children:i.files.map(E=>e.jsx("li",{children:e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:!y.has(E.path),onChange:()=>R(E.path)}),e.jsx("span",{className:"mono",dir:"auto",children:E.path})," ",e.jsxs("span",{className:"muted",children:[vC[E.status],E.secretLike?", looks like it holds a secret, left out":""]})]})},E.path))}),i.omitted?e.jsxs("p",{className:"muted small",children:[i.omitted," more ",i.omitted===1?"file is":"files are"," not listed."]}):null]}),b?e.jsx("p",{className:"error",role:"alert",children:b}):null,e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",disabled:N||!g.trim()||!T,children:"Commit"}),e.jsx("button",{type:"button",className:"secondary",onClick:l,disabled:N,children:"Cancel"})]})]})}function bC(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 NC({task:t,mine:s,onChanged:r}){var Z,ae,z;const l=(t==null?void 0:t.result)==="changes",[i,c]=m.useState(!1),d=m.useMemo(()=>{var P;return t?nk(tk(t.id),((P=t.changes)==null?void 0:P.files)??[],()=>c(!0)):null},[t==null?void 0:t.id]),[u,p]=m.useState(null),[f,g]=m.useState(!1),[j,y]=m.useState(null),[k,N]=m.useState(null),[w,b]=m.useState(!1),[$,R]=m.useState(null),[T,C]=m.useState(!1);if(m.useEffect(()=>{!l||!t||Je.list().then(({projects:P})=>{var _,V;return N(((V=(_=P.find(le=>le.id===t.repoId))==null?void 0:_.facts)==null?void 0:V.git)??null)},()=>N(null))},[t==null?void 0:t.repoId,l]),!l||!t||!d)return{actions:null,section:null};const E=((Z=t.changes)==null?void 0:Z.undone)??null,O=((ae=t.changes)==null?void 0:ae.kept)??null,F=t.status!=="queued"&&t.status!=="running",L=P=>{y(P.message),P instanceof ut&&P.status===409&&r()},W=P=>$e.undo(t.id,P?{reason:P}:{}).then(_=>{p(_.kept),r()},L),A=(P,_)=>$e.undo(t.id,{paths:[P],..._?{reason:_}:{}}).then(r),M=(((z=t.changes)==null?void 0:z.files)??[]).filter(P=>P.state==="undone").map(P=>P.path),Q=()=>{g(!0),y(null),$e.keep(t.id).then(r,L).finally(()=>g(!1))},H=bC(u??(E==null?void 0:E.kept)??[]),U=P=>P.slice(0,16).replace("T"," "),ie=s&&F&&!E,X=ie?e.jsxs(e.Fragment,{children:[O?null:e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",disabled:f||!T,onClick:Q,title:T?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:Yf,onConfirm:W})]}),k&&k!=="none"&&!$&&!w?e.jsx("button",{type:"button",className:"secondary",onClick:()=>b(!0),children:"Commit these changes"}):null]}):null,J=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(Ee,{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."})]}),E?e.jsxs("p",{className:"muted",children:["Undone by ",E.by," at ",U(E.at),E.reason?`: ${E.reason}`:"",". ",H]}):O?e.jsxs("p",{className:"muted",children:["Kept by ",O.by," at ",U(O.at),". The files stay as the agent left them."]}):null,j?e.jsx("p",{className:"error",role:"alert",children:j}):null,w?e.jsx(wC,{projectId:t.repoId,title:t.title,onCancel:()=>b(!1),onCommitted:P=>{b(!1),R(P)}}):null,$?e.jsxs("p",{className:"notice",role:"status",children:["Committed as ",e.jsx("span",{className:"mono",children:$.slice(0,7)}),"."]}):null,!E&&H?e.jsx("p",{className:"muted",children:H}):null,i?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(sl,{reads:d,bare:!0,onRead:C,undone:M,...ie&&!O&&t.runner!=="local"?{onUndo:A}:{}},t.id)]});return{actions:X,section:J}}const Eu=8e3,Up={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"}},Ru=20;function SC(t,s){return t.length>=Ru||t.some(r=>r.path===s.path&&r.lines===s.lines)?t:[...t,s]}function qp({quotes:t,onQuotes:s}){return t.length?e.jsx("ul",{className:"plain chips","aria-label":"Quoted lines",children:t.map(r=>e.jsxs("li",{className:"chip-pick on",children:[e.jsx("span",{className:"mono",children:r.path===Kf?`log ${r.lines}`:`${r.path}:${r.lines}`})," ",e.jsx("button",{type:"button",className:"ghost small","aria-label":`Leave out ${r.path} lines ${r.lines}`,onClick:()=>s(t.filter(l=>l!==r)),children:"×"})]},`${r.path}:${r.lines}`))}):null}function Bp({task:t,kind:s,jump:r=null,stop:l=null,suggestTo:i="",quotes:c,onQuotes:d,onSent:u}){const[p,f]=m.useState(""),[g,j]=m.useState(!1),[y,k]=m.useState(null),[N,w]=m.useState(()=>crypto.randomUUID()),b=s==="suggest",$=b?{label:`Suggest a follow-up to ${i}`,note:`${i} reads it first; the agent gets it only if they continue with it.`,send:"Suggest"}:s==="continue"&&t.requestNumber===null?{...Up.continue,note:"A new run starts where this one left off, with your words, and its changes join this review."}:Up[s],R=b?!!p.trim():!!(p.trim()||c.length),T=C=>{C.preventDefault(),R&&(j(!0),k(null),(b?$e.suggest(t.id,{text:p.trim(),quotes:c},N):$e.message(t.id,{text:p.trim(),quotes:c},N)).then(()=>{f(""),d([]),w(crypto.randomUUID()),u()},E=>{k(E.message),E instanceof ut&&(E.code==="follow-up-not-offered"||E.code==="use-messages")&&u()}).finally(()=>j(!1)))};return s==="steer"||s==="queue"?e.jsxs("form",{className:"run-steer",onSubmit:T,"aria-label":$.label,children:[r,e.jsx(qp,{quotes:c,onQuotes:d}),e.jsx("textarea",{dir:"auto","aria-label":"Tell the agent something while it works",placeholder:"Tell the agent something while it works",value:p,onChange:C=>f(C.target.value),onKeyDown:C=>{var E;C.key!=="Enter"||C.shiftKey||C.nativeEvent.isComposing||(C.preventDefault(),(E=C.currentTarget.form)==null||E.requestSubmit())},rows:1,maxLength:Eu}),e.jsx("button",{type:"submit",className:p.trim()?void 0:"secondary",disabled:g||!p.trim(),children:$.send}),l,e.jsx(Ee,{label:"what you tell the agent",children:$.note}),y?e.jsx("p",{className:"error",role:"alert",children:y}):null]}):e.jsxs("section",{className:"panel","aria-labelledby":"follow-up-h",children:[e.jsx("h2",{id:"follow-up-h",children:$.label}),e.jsxs("form",{className:"form follow-form",onSubmit:T,"aria-labelledby":"follow-up-h",children:[e.jsx(qp,{quotes:c,onQuotes:d}),e.jsxs("label",{children:["What the agent should do",e.jsx("textarea",{className:"follow-text",dir:"auto",value:p,onChange:C=>f(C.target.value),rows:3,maxLength:Eu})]}),e.jsxs("p",{className:"muted small",children:[$.note,c.length>=Ru?` A follow-up holds ${Ru} quotes; send these before quoting more.`:c.length?" Quoted lines go to the agent as they are in the request.":null,c.length?null:e.jsxs(e.Fragment,{children:[" ",e.jsx(Ee,{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:g||!R,children:$.send})}),y?e.jsx("p",{className:"error",role:"alert",children:y}):null]})]})}function CC({task:t,messages:s,onChanged:r}){const[l,i]=m.useState(null),[c,d]=m.useState(""),[u,p]=m.useState(!1),[f,g]=m.useState(null);if(!s.length)return null;const j=y=>{p(!0),g(null),y().then(()=>{i(null),r()},k=>{g(k.message),k instanceof ut&&k.code==="message-not-waiting"&&r()}).finally(()=>p(!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:s.map(y=>{var k;return e.jsx("li",{children:l===y.id?e.jsxs("form",{className:"form",onSubmit:N=>{N.preventDefault(),j(()=>{var w;return $e.editMessage(t,y.id,{text:c.trim(),...(w=y.quotes)!=null&&w.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:Eu}),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:()=>i(null),children:"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"pre",dir:"auto",children:y.text}),(k=y.quotes)!=null&&k.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:()=>{i(y.id),d(y.text)},children:"Edit"}),e.jsx("button",{type:"button",className:"ghost small",disabled:u,onClick:()=>j(()=>$e.removeMessage(t,y.id)),children:"Remove"})]})},y.id)})}),f?e.jsx("p",{className:"error",role:"alert",children:f}):null]})}function Fg({names:t}){if(!t.length)return null;const s=[...new Set(t.map(LS))];return e.jsxs("details",{className:"muted mcp-sign-in",role:"note",children:[e.jsxs("summary",{children:[t.length===1?"1 MCP server needs":`${t.length} MCP servers need`," sign-in"]}),e.jsxs("p",{children:[e.jsx("span",{dir:"auto",children:s.join(", ")}),". To sign in, run ",e.jsx(yt,{text:"claude"}),", then ",e.jsx("span",{className:"mono",children:"/mcp"}),"; the next task can use ",t.length===1?"it":"them","."]})]})}const $C=4e3,TC="Paste the issue text",EC=8e3;function RC({task:t,mine:s,agent:r,onAnswered:l}){const[i,c]=m.useState(""),[d,u]=m.useState(""),[p,f]=m.useState(""),[g,j]=m.useState(!1),[y,k]=m.useState(null),N=t.question;if(!N||N.answer)return null;const w=i===TC&&!d.trim(),b=w?p.trim():d.trim()||i,$=R=>{R.preventDefault(),b&&(j(!0),k(null),$e.answerStopped(t.id,b).then(l,T=>{k(T.message),j(!1)}))};return e.jsxs("section",{className:"section","aria-labelledby":"task-question-h",children:[e.jsxs("h2",{id:"task-question-h",children:[r||"The agent"," stopped to ask",s?" you":` ${t.createdBy}`]}),e.jsx("p",{dir:"auto",className:"pre",children:N.text}),s?e.jsxs("form",{className:"form",onSubmit:$,"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(R=>e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"radio",name:"stopped-question",checked:!d.trim()&&i===R,onChange:()=>c(R)}),e.jsx("span",{dir:"auto",children:R})]},R))]}):null,w?e.jsxs("label",{children:["The issue's text",e.jsx("textarea",{dir:"auto",rows:6,maxLength:EC,value:p,onChange:R=>f(R.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:$C,value:d,onChange:R=>u(R.target.value)})]}),e.jsx("div",{className:"actions",children:e.jsx("button",{type:"submit",disabled:g||!b,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."]})]})}function PC(t,s){return t.fallback?", the folder you use most":s?`, which its CLAUDE.md calls ${s}`:""}function AC(t,s){const r=[t.skills?`${t.skills} ${t.skills===1?"skill":"skills"}`:"",t.claudeMd?"CLAUDE.md":"",t.memory?"memory":""].filter(Boolean);return r.length?`Loaded: ${r.join(", ")} from ${s}.`:`Nothing of ${s}'s own is loaded: it has no CLAUDE.md, skills or memory.`}function IC(t){return t.length?`, checked with ${t.join(" and ")}`:""}function OC({task:t,routing:s,canMove:r,checked:l=[],onChecksOff:i}){var A;const[c,d]=m.useState(!1),[u,p]=m.useState(""),[f,g]=m.useState(null),[j,y]=m.useState(null),[k,N]=m.useState(null),[w,b]=m.useState(!1),[$,R]=m.useState(!1),[T,C]=m.useState(null);m.useEffect(()=>{Je.workFolders().then(M=>g(M.folders),()=>g([])),Je.list().then(M=>y(M.home??null),()=>y(null))},[]);const E=M=>ts(M,j),O=((A=f==null?void 0:f.find(M=>M.path===s.path))==null?void 0:A.about)??null,F=(f??[]).filter(M=>M.path!==s.path),L=()=>{k&&(R(!0),C(null),$e.move(t.id,k).then(({task:M})=>Ue(ce("tasks",M.id)),M=>{C(M.message),R(!1)}))},W=()=>{R(!0),C(null),Hr.forget(t.repoId).then(()=>{d(!1),R(!1),i==null||i()},M=>{C(M.message),R(!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:E(s.path)}),PC(s,O),IC(l)]}),r&&f!==null&&!k&&!w&&!c?e.jsxs(e.Fragment,{children:[" ",e.jsx(nl,{label:"Change where the task works",summary:"Change",className:"run-where-change",children:M=>e.jsxs("ul",{className:"plain run-where-folders",children:[e.jsx("li",{children:e.jsx("form",{onSubmit:Q=>{Q.preventDefault(),u.trim()&&(N(Ls(u,j)),p(""),M())},children:e.jsxs("label",{children:["A folder's path",e.jsx("input",{type:"text",value:u,onChange:Q=>p(Q.target.value),placeholder:"~/code",dir:"auto"})]})})}),F.map(Q=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"ghost",onClick:()=>{N(Q.path),M()},children:[e.jsx("span",{dir:"auto",children:Q.name})," ",e.jsx("span",{className:"mono muted",dir:"auto",children:E(Q.path)})]})},Q.path)),e.jsx("li",{children:e.jsx("button",{type:"button",className:"ghost",onClick:()=>{b(!0),M()},children:"Another folder…"})}),l.length?e.jsx("li",{children:e.jsx("button",{type:"button",className:"ghost",onClick:()=>{d(!0),M()},children:"Run without checks"})}):null]})})]}):null,f!==null&&s.loaded?e.jsx("span",{className:"muted small run-loaded",children:AC(s.loaded,E(s.path))}):null,w?e.jsxs(e.Fragment,{children:[e.jsx(ed,{onOpened:M=>{var Q;b(!1),N(((Q=M.machine)==null?void 0:Q.path)??M.url.replace(/^file:\/\//,""))}}),e.jsx("p",{children:e.jsx("button",{type:"button",className:"secondary small",onClick:()=>b(!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:E(s.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:W,disabled:$,children:$?"Take them back…":"Take them back"}),e.jsx("button",{type:"button",className:"secondary small",onClick:()=>{d(!1),C(null)},disabled:$,children:"Keep the checks"})]}),T?e.jsx("p",{className:"error",role:"alert",children:T}):null]}):null,k?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:E(k)}),"; what it did so far is dropped."]}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",className:"confirm-go small",onClick:L,disabled:$,children:$?"Start it there…":"Start it there"}),e.jsx("button",{type:"button",className:"secondary small",onClick:()=>{N(null),C(null)},disabled:$,children:"Keep it here"})]}),T?e.jsx("p",{className:"error",role:"alert",children:T}):null]}):null]})}function LC(t,s,r){return t.status==="continued"?r?"You continued with it.":`${s} continued with it.`:t.status==="dismissed"?r?"You dismissed it.":`${s} dismissed it.`:t.status==="expired"?"The request ended before it was answered.":`Waiting for ${s} to continue with it or dismiss it.`}function FC({task:t,suggestion:s,starter:r,mine:l,onAnswered:i}){var j;const[c,d]=m.useState(!1),[u,p]=m.useState(null),f=y=>{d(!0),p(null),$e.answerSuggestion(t.id,s.id,y).then(()=>i(y==="continue"),k=>{p(k.message),d(!1)})},g=s.status==="waiting";return e.jsxs("li",{className:`approval${g?" pending":""}`,"aria-label":`${s.by.name} suggests a follow-up`,children:[e.jsxs("p",{children:[e.jsxs("strong",{dir:"auto",children:[s.by.name," suggests:"]})," ",e.jsx("span",{className:"pre",dir:"auto",children:s.text})]}),(j=s.quotes)!=null&&j.length?e.jsx("ul",{className:"plain","aria-label":"Quoted lines",children:s.quotes.map(y=>e.jsxs("li",{className:"mono small",children:[y.path,":",y.lines]},`${y.path}:${y.lines}`))}):null,s.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:LC(s,r,l)}),u?e.jsx("p",{className:"error",role:"alert",children:u}):null]})}function MC({task:t,me:s,onAnswered:r}){var p;const l=t.suggestions??[];if(!l.length)return null;const i=t.createdBy===s.email,c=((p=t.startedBy)==null?void 0:p.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(FC,{task:t,suggestion:f,starter:c,mine:i,onAnswered:r},f.id))})]})}const Un=["queued","running"],_C=["failed","cancelled"];function Mg(t,s,r){const l=typeof t=="string"?t:t==null?void 0:t.kind;return`${l&&Vr(l)?df(l,typeof t=="object"&&t?t.number:s):"The change"} ${DC[r]}.`}const DC={open:"waits for a person to review and merge it",merged:"was merged",closed:"was closed without being merged"};function UC(t){var s,r,l,i;return{title:t.title,description:t.description,issueUrl:t.issueUrl??"",repoId:t.repoId,agent:t.agent,template:t.template,...t.targetMode==="orchestrator"?{targets:"orchestrator"}:(s=t.targets)!=null&&s.length?{targets:t.targets.map(c=>c.repoId)}:{},...(r=t.skills)!=null&&r.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}))}:{},...(i=t.tools)!=null&&i.mcpServers.length?{mcpServers:t.tools.mcpServers}:{}}}function qC(t){var r;const s=xf(t);return s||(t.status==="needs-review"&&((r=t.request)==null?void 0:r.status)==="merged"?"merged":t.status)}function BC({task:t}){const s=ur(t),r=Qr(s,t.forge);return e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`state ${r.tone}`,"data-status":s,children:r.word}),t.queuePosition!==null?e.jsxs("span",{className:"muted","data-queue":t.queuePosition,children:[" #",t.queuePosition," in line"]}):null]})}function Pu(t){if(!t.startedAt)return 0;const s=new Date(t.finishedAt??Date.now()).getTime(),r=(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(s,u?new Date(u).getTime():s)]]}).filter(([c,d])=>d>c).sort((c,d)=>c[0]-d[0]);let l=0,i=-1/0;for(const[c,d]of r)d<=i||(l+=d-Math.max(c,i),i=d);return Math.max(0,l)}function zC(t){const s=Math.max(1,Math.round(t/6e4));return s<60?`${s}m`:`${Math.floor(s/60)}h${s%60?` ${s%60}m`:""}`}function zp(t){const s=Math.max(0,Math.round(t/1e3));return s<60?`${s}s`:`${Math.floor(s/60)}m${s%60?` ${s%60}s`:""}`}function dr(t){return t.startedAt?t.finishedAt&&t.ranMs!==void 0?zp(t.ranMs):zp(new Date(t.finishedAt??Date.now()).getTime()-new Date(t.startedAt).getTime()-Pu(t)):"not started"}function Wp(t){const{usd:s,inputTokens:r,outputTokens:l}=t.cost;if(s===null&&r===null&&l===null)return"unknown";const i=[s!==null?`$${s.toFixed(4)}`:"cost unknown"];return(r!==null||l!==null)&&i.push(`${r??"?"} in / ${l??"?"} out tokens`),`${i.join(", ")}${t.costPartial?", some parts unreported":""}`}const WC={ready:{text:"Ready",tone:"ok"},warnings:{text:"Ready with warnings",tone:"warn"},"not-ready":{text:"Not ready",tone:"error"}};function HC({agent:t,details:s}){const r=t==null?void 0:t.readiness;if(!t)return null;if(!r)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=r.state==="not-ready",{text:i,tone:c}=WC[r.state];return e.jsxs("p",{className:"muted",role:l?"alert":"note","aria-label":`${t.label} readiness`,children:[e.jsx("span",{className:`state ${c}`,children:i}),r.first?e.jsxs(e.Fragment,{children:[" ",lr(r.first)]}):l?" A task started now fails.":null,s&&r.state!=="ready"?e.jsxs(e.Fragment,{children:[" ",e.jsx("a",{href:ce("settings","agents"),children:"See details"})]}):l?e.jsxs(e.Fragment,{children:[" ",e.jsx(Ee,{label:`why ${t.label} is not ready`,children:"A task started now fails. An admin sees why on Agent readiness."})]}):null]})}function GC(t){var r;const s=(r=t==null?void 0:t.trim().split(`
|
|
77
|
-
`)[0])==null?void 0:r.trim().replace(/[.\s]+$/,"");return s?`: ${s}.`:"."}function jo(t){return`$${t.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`}function KC(t){const[s,r]=t.split("-").map(Number);return new Date(Date.UTC(s,r,1)).toLocaleDateString("en-US",{month:"long",day:"numeric",timeZone:"UTC"})}function Hp({budgets:t}){return t.budgets.length?e.jsx("ul",{className:"plain budgets","aria-label":"Task budgets",children:t.budgets.map(s=>e.jsxs("li",{children:[s.reached?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"badge error",children:"Budget reached"})," Tasks start again on ",KC(t.month),"."]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"badge ok",children:"Monthly budget left"})," ",jo(s.leftUsd)," of ",jo(s.monthlyUsd),s.per==="member"?" for you":", shared","."]})," ",e.jsxs(Ee,{label:`the budget ${s.policy}`,children:[s.reached?`${jo(s.spentUsd)} of ${jo(s.monthlyUsd)} spent this month${s.per==="member"?" by you":""} under ${s.policy}.`:`Under ${s.policy}.`,s.unknownCost?` ${s.unknownCost} ${s.unknownCost===1?"task":"tasks"} this month reported no cost and ${s.unknownCost===1?"is":"are"} not counted.`:""]})]},`${s.policyId??s.policy}:${s.per}`))}):null}function _g(t){const[s="",...r]=t.trim().split(`
|
|
78
|
-
`),[l="",...i]=s.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:[i.join(" "),...r].join(`
|
|
79
|
-
`).trim()}:{issue:"",notes:t.trim()}}const Jc=/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u180e\u200b-\u200f\u202a-\u202e\u2060-\u2064\u2066-\u2069\ufeff]/g,VC="orchestrator.task.log";function YC(t){return new Date(t).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hourCycle:"h23"})}function QC(t,s,r,l,i=null){var u,p,f;const c=[{term:r.mode==="local"?"Folder":"Repository",value:i??t.repoId}];r.mode!=="local"&&c.push({term:"Team",value:t.team});const d=[{term:"Agent",value:s||"The agent"},{term:"Started",value:`${l(t.createdAt)} by ${t.createdBy===r.email?"you":t.createdBy}`}];return(t.tests==="passed"||t.tests==="failed")&&d.push({term:"Tests",value:t.tests}),t.startedAt&&t.finishedAt&&d.push({term:"Ran",value:dr(t)}),Pu(t)>=6e4&&d.push({term:"Waited",value:`${zC(Pu(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"}),(u=t.context)!=null&&u.tokens&&d.push({term:"Context",value:`${t.context.tokens>=1e3?`${Math.round(t.context.tokens/1e3)}k`:t.context.tokens} tokens at its start`}),t.loaded&&$u(t.loaded)&&d.push({term:"Loaded",value:$u(t.loaded)}),((p=t.template)==null?void 0:p.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}`}),(f=t.skills)!=null&&f.length&&d.push({term:"Reads first",value:t.skills.join(", ")}),{where:c,run:d}}const JC=/[\u0000-\u0008\u000b-\u001f\u007f-\u009f\u00ad\u061c\u180e\u200b-\u200f\u202a-\u202e\u2060-\u2064\u2066-\u2069\ufeff]/g;function Gp(t){const s=new URLSearchParams(t);let r=!1;const l=(c,d)=>{const u=(c??"").trim(),p=u.replace(d,"").trim();return p!==u&&(r=!0),p};return{...{issue:l(s.get("issue"),Jc),repo:l(s.get("repo"),Jc),title:l(s.get("title"),Jc),description:l(s.get("description")??s.get("prompt"),JC)},stripped:r}}function XC(t,s){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 r=JSON.parse(s??"null"),l=i=>typeof(r==null?void 0:r[i])=="string"?r[i]:"";return{work:l("work"),title:l("title"),notes:l("notes")}}catch{return{work:"",title:"",notes:""}}}const ZC="orchestrator.task.draft";function Dg(t,s,r,l){return(t.trim()||s||r||l.split(`
|
|
80
|
-
`,1)[0]||"").trim().slice(0,120)}function e0(t){const s=t.issueKey?`${t.reads?"Reads":"Works from"} ${t.issueKey}, `:"";if(t.routed)return`${s}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`${s}picks the repositories; a reviewer merges each change.`;const r=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 ${et[t.forge].label}`:"",i=t.repos.length>1?"a reviewer merges each change.":`a reviewer merges it${l}.`,c=`${s}changes ${r}; ${i}`;return c.charAt(0).toUpperCase()+c.slice(1)}const t0=[{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 Xc=null;function n0(){return Xc??(Xc=$e.options().then(t=>new Map(t.agents.map(s=>[s.id,s.label])),()=>(Xc=null,new Map))),Xc}const nd="an agent no longer offered";function Ug(t){const[s,r]=m.useState(null);return m.useEffect(()=>{let l=!0;return n0().then(i=>l&&r(i)),()=>{l=!1}},[]),s===null?"":s.get(t)??nd}function s0({id:t,known:s}){var l;const r=Ug(t);return s?e.jsx(e.Fragment,{children:((l=s.find(i=>i.id===t))==null?void 0:l.label)??nd}):e.jsx(e.Fragment,{children:r})}function r0({options:t,budgets:s,limits:r=null,start:l,local:i,approver:c,defaultRepo:d=null,onStarted:u,onCancel:p,focus:f=!1,first:g=!1}){var qs,ol,aa,Bs,Ht,il,Mt,cl,ul;const j=t.repos.filter(ee=>ee.kind==="code"),y=t.repos.filter(ee=>ee.kind!=="code"),k=j.some(ee=>ee.id===(l==null?void 0:l.repo)),N=y.some(ee=>ee.id===(l==null?void 0:l.repo)),w=!(l!=null&&l.repo)&&j.some(ee=>ee.id===d)?d:null,b=`${ZC}:${Ds(window.location.pathname).org??""}`,[$]=m.useState(()=>XC(l,To(b))),R=!(l!=null&&l.issue)&&!(l!=null&&l.title)&&!(l!=null&&l.description)&&!!($.work||$.title||$.notes),[T,C]=m.useState($.work),[E,O]=m.useState(N||!i&&!j.length?"skills":"code"),[F,L]=m.useState(t.multiRepo&&!k&&!w?"orchestrator":"chosen"),[W,A]=m.useState(k?[l.repo]:w?[w]:j.length===1?[j[0].id]:[]),[M,Q]=m.useState(N?l.repo:((qs=y[0])==null?void 0:qs.id)??""),[H,U]=m.useState("any"),[ie,X]=m.useState(""),[J,Z]=m.useState(null),[ae,z]=m.useState($.title),[P,_]=m.useState($.notes),[V,le]=m.useState(((ol=g?t.agents.find(ee=>{var Re;return((Re=ee.readiness)==null?void 0:Re.ready)!==!1}):void 0)==null?void 0:ol.id)??((aa=t.agents[0])==null?void 0:aa.id)??""),[be,pe]=m.useState({}),[de,se]=m.useState(null),[he,Le]=m.useState(null),[Ye,Tt]=m.useState(null),[tt,rs]=m.useState(!1),[Fe,mr]=m.useState({}),[en,as]=m.useState(null),[Et,tn]=m.useState(!1),[wt,Bn]=m.useState(null),[ls,os]=m.useState([]),[nn,is]=m.useState(XS),sn=m.useId(),at=m.useId(),En=_g(T),He=En.issue,Rn=!!(s!=null&&s.budgets.some(ee=>ee.reached)),zn=T!==$.work||ae!==$.title||P!==$.notes,gn=!T.trim()&&!ae.trim()&&!P.trim();m.useEffect(()=>{zn&&cu(b,gn?null:JSON.stringify({work:T,title:ae,notes:P}))},[T,ae,P]),m.useEffect(()=>{if(!zn)return;const ee=Re=>{Re.preventDefault(),Re.returnValue=""};return window.addEventListener("beforeunload",ee),()=>window.removeEventListener("beforeunload",ee)},[zn]),m.useEffect(()=>{if(se(null),Le(null),!He)return;let ee=!0;const Re=setTimeout(()=>{qj.preview(He).then(_e=>ee&&se(_e),_e=>ee&&Le(_e.message))},400);return()=>{ee=!1,clearTimeout(Re)}},[He]),m.useEffect(()=>{E!=="skills"||H!=="skill.improve"||!M||(Z(null),Ne.inventory(M).then(({inventory:ee})=>{const Re=ee.skills.map(_e=>_e.slug);Z(Re),X(Re[0]??"")},()=>Z([])))},[E,H,M]);const nt=E==="code"||H==="any"?null:H==="scaffold.refresh"||H==="scaffold.switch"?{kind:"scaffold.refresh",commitVersioning:H==="scaffold.switch"}:{kind:H,skill:ie.trim()},xn=(nt==null?void 0:nt.kind)==="scaffold.refresh",Pn=nt?nt.kind==="scaffold.refresh"?nt.commitVersioning?"chore: switch the plugin to versioning by commit":"chore: refresh the team handbook scaffold":nt.skill?`${nt.kind==="skill.write"?"Write":"Improve"} the skill ${nt.skill}`:null:null,Rt=i&&E==="code",An=i&&!g,[In,Wn]=m.useState([]);m.useEffect(()=>{!g||!i||Je.list().then(({last:ee})=>ee?Zt.starters(ee).then(Re=>Wn(Re.starters.slice(0,3))):void 0,()=>Wn([]))},[g,i]);const[jn,rn]=m.useState([]);m.useEffect(()=>{i&&$e.page(null).then(ee=>{var Re;return rn(((Re=ee.tasks[0])==null?void 0:Re.mcpNeedsSignIn)??[])},()=>rn([]))},[i]);const an=!Rt&&E==="code"&&(F==="orchestrator"||W.length>1),Wt=!Rt&&E==="code"&&t.multiRepo&&He&&(F==="orchestrator"||W.length>1)?F==="orchestrator"?"orchestrator":W:void 0,bt=Rt?"":E==="skills"?M:F==="chosen"?W[0]??"":((Bs=j[0])==null?void 0:Bs.id)??"",Ae=t.repos.find(ee=>ee.id===bt),cs=Tg(E==="code"&&!an&&(Ae==null?void 0:Ae.kind)==="code"?bt:null,"needed",c||!!(Ae!=null&&Ae.machine)),us=(Ae==null?void 0:Ae.ticketExample)!=null&&!He,ds=He?[En.notes,P].filter(Boolean).join(`
|
|
81
|
-
|
|
82
|
-
`):En.notes,ue=Dg(ae,(de==null?void 0:de.title)??null,Pn,ds),Ge=!T.trim()&&!Pn,Pt=Ge?null:an&&!He?"Paste an issue link to let the agent pick the repositories or to change several.":!Rt&&E==="code"&&F==="chosen"&&!W.length?"Pick a repository.":us?`${Ae.name} names branches after a ticket (its example is ${Ae.ticketExample}); paste its issue link.`:nt&&nt.kind!=="scaffold.refresh"&&!nt.skill?"Name the skill.":!ue&&!He?"Describe the work.":null,hs=Ye?{"aria-invalid":!0,"aria-describedby":sn}:{},ln=(E==="skills"?[M]:W).map(ee=>{var Re;return((Re=t.repos.find(_e=>_e.id===ee))==null?void 0:Re.name)??ee}),mt=e0({issueKey:(de==null?void 0:de.key)??(He&&!He.startsWith("https://")?He:null),reads:!!(de!=null&&de.title),mode:E,spread:E==="code"&&t.multiRepo?F:"chosen",repos:ln,byOrchestrator:xn,routed:Rt,forge:(Ae==null?void 0:Ae.forge)??null}),[ms,pt]=m.useState(!1),[lt,ps]=m.useState(null),[On,Ft]=m.useState(null),[pr,Zr]=m.useState(!1),[ea,rl]=m.useState(""),[ta,na]=m.useState(null);m.useEffect(()=>{i&&Je.list().then(ee=>na(ee.home??null),()=>na(null))},[i]),m.useEffect(()=>{ps(null),Ft(null),Zr(!1)},[T]);const sa=xn||g?null:e.jsx(Pe,{label:"Agent",value:V,onChange:ee=>{le(ee),pe({})},describedBy:Ye?sn:void 0,invalid:!!Ye,options:t.agents.map(ee=>({value:ee.id,label:ee.label,hint:ee.readiness&&!ee.readiness.ready?"not ready":void 0}))}),zo=ee=>{ee.preventDefault(),ze()},al=ee=>{Tt(null),Lt.signInService(ee).then(Re=>window.location.assign(Re),Re=>Tt(Re.message))},ze=(ee,Re=!1)=>{Pt||(rs(!0),Tt(null),cs.consent().then(()=>{var _e;return $e.start({title:ue,description:ds,issueUrl:He,...bt?{repoId:bt}:{},...ee?{path:ee}:{},...pr||Re?{withoutIssueText:!0}:{},...ms&&((_e=t.agents.find(yn=>yn.id===V))!=null&&_e.plan)?{planFirst:!0}:{},agent:V,template:nt,...Wt?{targets:Wt}:{},...ls.length?{skills:ls}:{},...Ur(be)?{choices:Ur(be)}:{},...nn.projectSkills.length?{projectSkills:nn.projectSkills}:{},mcpServers:nn.mcpServers,...!i&&nn.commands.length?{mcpConfirmed:nn.commands}:{}})}).then(_e=>{cu(b,null),C(""),z(""),_(""),u(_e)},_e=>{if(_e instanceof ut&&_e.code==="issue-unread"){Ft(_e.message);return}if(_e instanceof ut&&_e.code==="pick-folder"){Je.workFolders().then(yn=>yn.folders,()=>[]).then(yn=>ps({question:_e.message,folders:yn}));return}Tt(_e.message),mr(_e instanceof ut?{code:_e.code,status:_e.status}:{})}).finally(()=>rs(!1)))};m.useEffect(()=>{as(null),Bn(null),os([])},[bt,E,F,W.join(",")]);const Wo=()=>{tn(!0),Bn(null),$e.suggestSkills({agent:V,repoId:bt,...He?{issueUrl:He}:{description:En.notes||T},...Wt?{targets:Wt}:{}}).then(ee=>{as(ee),os(ee.suggestions.map(Re=>Re.skill).slice(0,Co))},ee=>Bn(ee.message)).finally(()=>tn(!1))},ra=ee=>A(W.includes(ee)?W.filter(Re=>Re!==ee):[...W,ee]),ll=((Ht=t.multiRepo)==null?void 0:Ht.maxTargets)??1;return!t.repos.length&&!i?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",children:[e.jsxs("form",{className:"task-form",onSubmit:zo,"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&&!k&&!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,R&&!gn?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(""),z(""),_("")},children:"Clear them"})]}):null,e.jsx("label",{htmlFor:at,className:"work-label",children:"What needs doing?"}),e.jsx("textarea",{id:at,className:g?"work":"work compact",value:T,onChange:ee=>C(ee.target.value),rows:g?3:2,maxLength:8500,placeholder:"https://… or what needs to change",autoFocus:f,...hs}),(il=t.agents.find(ee=>ee.id===V))!=null&&il.plan?e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:ms,onChange:ee=>pt(ee.target.checked)}),"Show me the plan before it changes anything"]}):null,g&&In.length&&!T.trim()?e.jsxs("div",{className:"starters",children:[e.jsx("p",{className:"muted small",id:`${at}-starters`,children:"Or start with"}),e.jsx("ul",{className:"plain starter-list","aria-labelledby":`${at}-starters`,children:In.map(ee=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"ghost",onClick:()=>C(`${ee.title}
|
|
83
|
-
|
|
84
|
-
${ee.description}`),children:[e.jsx("span",{dir:"auto",children:ee.title})," ",e.jsx("span",{className:"mono muted small",dir:"auto",children:ee.where})]})},`${ee.kind}:${ee.where}:${ee.title}`))})]}):null,i?e.jsx(Fg,{names:jn}):null,He?e.jsx("div",{className:"issue-card",role:"status","aria-label":"Issue",children:he?e.jsx("p",{className:"error",children:he}):de?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:[e.jsx("a",{href:de.url,target:"_blank",rel:"noopener noreferrer",className:"mono",children:de.key??de.url}),de.title?e.jsxs(e.Fragment,{children:[" ",e.jsx("strong",{children:de.title})]}):null,de.status?e.jsx("span",{className:"badge neutral",children:de.status}):null]}),e.jsx("p",{className:"muted",children:de.reach}),de.connect?e.jsxs("p",{children:[e.jsxs("button",{type:"button",className:"secondary small",onClick:()=>al(de.connect.id),children:["Sign in with ",de.connect.name]})," ",e.jsxs("span",{className:"muted small",children:["to let the agent read ",de.key??"it"]})]}):null]}):e.jsx("p",{className:"muted",children:"Reading the issue…"})}):null,!g&&!An&&(j.length||i)&&y.length?e.jsxs("div",{className:"segmented wide",role:"group","aria-label":"What changes",children:[e.jsx("button",{type:"button",className:"secondary","aria-pressed":E==="code",onClick:()=>O("code"),children:"Code"}),e.jsx("button",{type:"button",className:"secondary","aria-pressed":E==="skills",onClick:()=>O("skills"),children:i?"Skills":"Team skills"})]}):null,e.jsxs("div",{className:"row task-where",children:[E==="code"?!Rt&&j.length>1?e.jsxs("fieldset",{className:"plain-fieldset repos-pick",children:[e.jsxs("legend",{children:["Repositories ",e.jsx(Ee,{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:F==="orchestrator",onChange:()=>L("orchestrator")}),"Let the agent decide (recommended)"]}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"radio",name:"spread",checked:F==="chosen",onChange:()=>L("chosen")}),"Pick repositories"]})]}):null,F==="chosen"?e.jsx("div",{className:"chips",role:"group","aria-label":"Repositories, in the order they run",children:j.map(ee=>{const Re=W.indexOf(ee.id);return e.jsxs("label",{className:`chip-pick${Re>=0?" on":""}`,children:[e.jsx("input",{type:"checkbox",checked:Re>=0,disabled:Re<0&&W.length>=ll,onChange:()=>ra(ee.id)}),Re>=0?e.jsx("span",{className:"order","aria-hidden":"true",children:Re+1}):null,e.jsxs("span",{children:[ee.name,ee.machine?e.jsxs("span",{className:"muted",children:[" on ",ee.machine]}):null]})]},ee.id)})}):null]}):null:e.jsxs("div",{className:"row",children:[y.length>1?e.jsx(Pe,{label:"Repository",value:M,onChange:Q,options:y.map(ee=>({value:ee.id,label:ee.name,hint:ee.team})),describedBy:Ye?sn:void 0,invalid:!!Ye}):null,H==="skill.write"?e.jsxs("label",{children:["Skill name",e.jsx("input",{value:ie,onChange:ee=>X(ee.target.value),maxLength:63,pattern:"[a-z0-9][a-z0-9-]*",placeholder:"on-call-handover",required:!0})]}):null,H==="skill.improve"?e.jsx(Pe,{label:"Skill",value:ie,onChange:X,disabled:!(J!=null&&J.length),placeholder:J===null?"Loading the repository's skills…":"This repository has no skill yet",options:(J??[]).map(ee=>({value:ee,label:ee}))}):null]}),An?null:sa]}),e.jsxs("div",{className:"agent-lines",children:[xn?null:e.jsx(HC,{agent:t.agents.find(ee=>ee.id===V),details:t.readinessReport}),xn||(Ae==null?void 0:Ae.ownSetup)===!1?null:e.jsx(nC,{label:((Mt=t.agents.find(ee=>ee.id===V))==null?void 0:Mt.label)??"",personal:(cl=t.agents.find(ee=>ee.id===V))==null?void 0:cl.personal}),xn||!i||!V?null:e.jsx(fN,{agentId:V})]}),!nt&&T.trim()&&bt&&V?e.jsxs("div",{className:"suggest-skills",children:[en?e.jsx(Ig,{label:"Skills to use first",read:en,value:ls,onChange:os,local:i}):e.jsxs("p",{children:[e.jsx("button",{type:"button",className:"secondary small",disabled:Et,onClick:Wo,children:Et?"Asking the agent…":"Suggest skills"})," ",e.jsxs(Ee,{label:"suggested skills",children:["The agent reads the work and names the ",i?"":"team ","skills to use first; it still has every one."]})]}),wt?e.jsxs("p",{className:"muted small",role:"status",children:["No suggestion: ",wt]}):null]}):null,g?null:e.jsxs("details",{className:"more",children:[e.jsx("summary",{children:"More options"}),e.jsxs("div",{className:"task-form",children:[An?sa:null,E==="skills"?e.jsx(Pe,{label:"Kind of task",value:H,onChange:ee=>{U(ee),X("")},options:t0}):null,e.jsxs("label",{children:["Title",e.jsx("input",{value:ae,onChange:ee=>z(ee.target.value),maxLength:120,placeholder:ue||"From the issue",...hs})]}),He?e.jsxs("label",{children:["Notes for the agent",e.jsx("textarea",{className:"short",value:P,onChange:ee=>_(ee.target.value),rows:3,maxLength:8e3})]}):null,xn?null:e.jsx(Cg,{options:(ul=t.agents.find(ee=>ee.id===V))==null?void 0:ul.options,value:be,onChange:pe}),bt&&!Wt?e.jsx(sC,{repoId:bt,value:nn,onChange:is,canAdd:i},bt):null]})]}),On?e.jsxs("div",{className:"issue-unread",role:"group","aria-label":"The issue is not read",children:[e.jsx("p",{dir:"auto",children:On}),e.jsxs("div",{className:"actions",children:[de!=null&&de.connect?e.jsxs("button",{type:"button",className:"secondary small",onClick:()=>al(de.connect.id),children:["Sign in with ",de.connect.name]}):e.jsx("a",{className:"button secondary small",href:ce("integrations"),children:"Connect"}),e.jsx("button",{type:"button",className:"secondary small",disabled:tt,onClick:()=>{Zr(!0),Ft(null),ze(void 0,!0)},children:"Start on the link alone"})]})]}):null,lt?e.jsxs("div",{className:"pick-folder",role:"group","aria-label":"Which folder",children:[e.jsx("p",{dir:"auto",children:lt.question}),lt.folders.length?e.jsx("ul",{className:"plain",children:lt.folders.map(ee=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"ghost",disabled:tt,onClick:()=>ze(ee.path),children:[e.jsx("span",{dir:"auto",children:ee.name})," ",e.jsx("span",{className:"mono muted",dir:"auto",children:ts(ee.path,ta)})]})},ee.path))}):null,e.jsxs("label",{children:["A folder's path",e.jsx("input",{type:"text",value:ea,onChange:ee=>rl(ee.target.value),placeholder:"~/code",dir:"auto",onKeyDown:ee=>{ee.key!=="Enter"||!ea.trim()||(ee.preventDefault(),ze(Ls(ea,ta)))}})]})]}):null,cs.view,e.jsxs("div",{className:"actions start",children:[e.jsx("button",{type:"submit",disabled:tt||Rn||Ge||!!Pt,children:"Start task"}),p?e.jsx("button",{type:"button",className:"secondary",onClick:p,disabled:tt,children:"Cancel"}):null,e.jsx("span",{className:"muted","aria-live":"polite",children:Pt??mt})]}),Ye?e.jsxs("p",{className:"error",role:"alert",id:sn,children:[Ye,e.jsx(td,{...Fe})]}):null]}),g?e.jsxs("aside",{className:"rail","aria-label":"Before it starts",children:[e.jsxs("section",{"aria-labelledby":`${at}-where`,children:[e.jsx("h2",{id:`${at}-where`,children:"Where it works"}),e.jsx("p",{dir:"auto",children:Rt?"The folder the orchestrator picks from what you ask; the run's first line says which, and Change moves it.":Wt==="orchestrator"?"The repositories the orchestrator picks from the issue":an?W.map(ee=>{var Re;return((Re=t.repos.find(_e=>_e.id===ee))==null?void 0:Re.name)??ee}).join(", "):Ae?`${Ae.name}${Ae.machine?`, on ${Ae.machine}`:i?"":`, ${Ae.team}`}`:"No repository picked yet"}),Ae!=null&&Ae.result&&!an?e.jsx("p",{className:"muted",children:Ae.result==="changes"?"The agent edits its files in place; Undo puts every file back.":"Nothing lands until a reviewer merges the change."}):null]}),s!=null&&s.budgets.length||r?e.jsxs("section",{"aria-labelledby":`${at}-limits`,children:[e.jsx("h2",{id:`${at}-limits`,children:"Limits"}),r?e.jsxs("p",{children:[vp(r)," ",e.jsx("a",{href:ce("settings","task-limits"),children:"Change"})]}):null,s!=null&&s.budgets.length?e.jsx(Hp,{budgets:s}):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":`${at}-where`,children:[e.jsx("h2",{id:`${at}-where`,children:"Where it works"}),e.jsx("p",{dir:"auto",children:Rt?"The folder the orchestrator picks from what you ask; the run's first line says which, and Change moves it.":Wt==="orchestrator"?"The repositories the orchestrator picks from the issue":an?W.map(ee=>{var Re;return((Re=t.repos.find(_e=>_e.id===ee))==null?void 0:Re.name)??ee}).join(", "):Ae?`${Ae.name}${Ae.machine?`, on ${Ae.machine}`:i?"":`, ${Ae.team}`}`:"No repository picked yet"}),Ae!=null&&Ae.result&&!an?e.jsx("p",{className:"muted",children:Ae.result==="changes"?"The agent edits its files in place; Undo puts every file back.":"Nothing lands until a reviewer merges the change."}):null]}),s!=null&&s.budgets.length||r?e.jsxs("section",{"aria-labelledby":`${at}-limits`,children:[e.jsx("h2",{id:`${at}-limits`,children:"Limits"}),r?e.jsxs("p",{children:[vp(r)," ",e.jsx("a",{href:ce("settings","task-limits"),children:"Change"})]}):null,s!=null&&s.budgets.length?e.jsx(Hp,{budgets:s}):null]}):null]})]})]})}const Zc={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"}},a0=t=>{var s;return!!((s=t.targets)!=null&&s.length)&&t.targets.every(r=>r.repoId===t.repoId||r.repoId.startsWith(`${t.repoId}--`))};function l0({task:t,local:s,starter:r,onChanged:l,onQuote:i}){const c=(t.targets??[]).filter(u=>u.status==="request"||u.status==="failed"||u.status==="local"),d=c.filter(u=>{var p;return((p=u.request)==null?void 0:p.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":Ao(u),children:[e.jsx("h3",{className:"mono",children:Ao(u)}),u.request?e.jsxs(e.Fragment,{children:[s?null:e.jsxs("p",{className:"muted",children:["Its work reaches ",u.name," only through a review, which a person merges."]}),s?null:e.jsx("p",{children:Mg(u.forge,u.request.number,u.request.status)}),s&&u.request.status==="open"?e.jsx(o0,{repoId:u.repoId,number:u.request.number,starter:r,only:d===1,onAnswered:l}):null,e.jsx(sl,{reads:Do(u.repoId,u.request.number),bare:!0,...i?{onQuote:i}:{}})]}):u.status==="local"&&u.branch?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"muted",children:c0(u.reason,u.branch,t.ranOn??null)}),(u.reason==="unpushed"||u.reason==="not-connected")&&u.forge&&r?e.jsx(i0,{taskId:t.id,position:t.targets.indexOf(u),forge:u.forge,onOpened:l}):e.jsx(yt,{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 o0({repoId:t,number:s,starter:r,only:l,onAnswered:i}){const c=Sg(t,s),[d,u]=m.useState(!1),[p,f]=m.useState(null),g=k=>Ne.requestAction(t,s,k).then(i),j=()=>{u(!0),f(null),g("merge").catch(k=>f(k.message)).finally(()=>u(!1))},y=p?Wa(p):null;return e.jsxs(e.Fragment,{children:[c.line,r||c.action?e.jsxs("div",{className:"actions",children:[r?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:l?void 0:"secondary",disabled:d,onClick:j,children:"Keep these changes"}),e.jsx(qe,{trigger:"Discard these changes…",consequence:"The task's branch is dropped; your checkout does not change.",confirm:"Discard changes",keep:"Keep them for now",onConfirm:()=>g("close")})]}):null,c.action]}):null,p?e.jsx("p",{className:"error",role:"alert",children:y?e.jsxs(e.Fragment,{children:[y.said,": ",e.jsx(yt,{text:y.command})]}):p}):null,c.refusal]})}function i0({taskId:t,position:s,forge:r,onOpened:l}){const[i,c]=m.useState(!1),[d,u]=m.useState(null),p=Ng[r].noun,f=()=>{c(!0),u(null),$e.openKept(t,s).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:i,onClick:f,children:i?`Opening a ${p}…`:`Open a ${p}`})}),d?e.jsx("p",{className:"error",role:"alert",children:d}):null]})}const Ao=t=>t.status==="local"&&t.path?t.path:t.name;function c0(t,s,r){const l=`on the branch ${s} in this repository${r?` on ${r}`:""}`;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 u0({task:t}){const s=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:s.length||""})]}),s.length?e.jsx("ol",{className:"target-cards",children:s.map((r,l)=>e.jsxs("li",{className:"target-card","aria-label":`${r.name}, ${Zc[r.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:ce("repositories",r.repoId),children:r.name})]}),e.jsx("span",{className:`badge ${Zc[r.status].tone}`,children:Zc[r.status].text})]}),e.jsx("p",{className:"muted",children:r.reason}),e.jsxs("dl",{className:"facts",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Tests"}),e.jsx("dd",{children:r.tests??(Un.includes(t.status)?"not run yet":"none ran")})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Change"}),e.jsx("dd",{children:r.request?r.request.url.startsWith("http")?e.jsxs(e.Fragment,{children:[e.jsx("a",{href:r.request.url,target:"_blank",rel:"noopener noreferrer",children:r.forge?df(r.forge,r.request.number):"See it on the forge"}),e.jsxs("span",{className:"muted",children:[", ",Kp[r.request.status]]})]}):Kp[r.request.status]:"none yet"})]})]}),r.error?e.jsx("p",{className:"error",children:r.error}):null]},r.repoId))}):e.jsx("p",{className:"muted",role:"status",children:Un.includes(t.status)?"Planning which repositories the change needs…":"No repository was planned."})]})}const Kp={open:"in review",merged:"merged",closed:"closed"};function d0(t){return t.targets?t.targets.length?t.targets.map(s=>s.name).join(", "):"planning…":t.repoId}const Vp=[{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 h0({cards:t,me:s,agents:r}){const l=Du();return e.jsx("table",{className:"row-cards turn-rows",children:e.jsx("tbody",{children:t.map(i=>{var f;const c=Zb(i),d=tN(i,l),u=r&&i.agent?((f=r.find(g=>g.id===i.agent))==null?void 0:f.label)??nd:null,p=[i.repoId,u,`started by ${i.createdBy===s.email?"you":i.createdBy}`].filter(Boolean).join(", ");return e.jsxs("tr",{onClick:()=>Ue(ce("tasks",i.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:ce("tasks",i.id),dir:"auto",children:d?e.jsx("strong",{children:i.title}):i.title}),d?e.jsx("span",{className:"visually-hidden",children:" (new)"}):null,i.issueKey?e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{className:"muted mono",children:i.issueKey})]}):null,i.reason&&(i.next==="retry"||i.next==="continue")?e.jsxs("div",{className:"small",dir:"auto",children:[e.jsx("span",{className:"error",children:i.reason})," ",e.jsx("a",{href:ce("tasks",i.id),children:i.next==="retry"?"Run again":"Continue"})]}):null,e.jsx("div",{className:"muted small",dir:"auto",children:p})]}),e.jsx("td",{className:"rc-extra rc-weight",children:i.changes?e.jsxs(e.Fragment,{children:[e.jsx(Uo,{added:i.changes.additions,removed:i.changes.deletions})," ",e.jsx("span",{className:"diff-stat",children:e.jsx(Yu,{added:i.changes.additions,removed:i.changes.deletions})})]}):null}),e.jsx("td",{className:"rc-extra num",children:i.startedAt?i.finishedAt?dr(i):`${dr(i)} so far`:null}),e.jsx("td",{className:"rc-extra num",children:i.cost.usd!==null?`$${i.cost.usd.toFixed(2)}`:null}),e.jsx("td",{className:"rc-extra num",children:vg(i.finishedAt??i.createdAt)})]},i.id)})})})}function m0({me:t,agents:s,picked:r=null}){const[l,i]=m.useState(!1),[c,d]=m.useState(null),[u,p]=m.useState(null),[f,g]=m.useState(null),[j,y]=m.useState(!1),k=$=>{y(!0),$e.page($).then(R=>{d(T=>$&&T?[...T,...R.tasks.filter(C=>!T.some(E=>E.id===C.id))]:R.tasks),p(R.next),g(null)},R=>g(R.message)).finally(()=>y(!1))};m.useEffect(()=>{l&&!c&&k(null)},[l]);const N=$=>!r||$.repoId===r||Array.isArray($.targets)&&$.targets.some(R=>R.repoId===r),w=(c?vy(c.filter(N),t.email,Du(),"all"):[]).map($=>({...$,wait:Lg($.task,t)})),b=w.some(({task:$})=>$.cost.usd!==null||$.cost.inputTokens!==null||$.cost.outputTokens!==null);return e.jsxs("details",{className:"section log-fold",onToggle:$=>i($.currentTarget.open),children:[e.jsxs("summary",{children:["All tasks ",c?e.jsx("span",{className:"count",children:`${c.length}${u?"+":""}`}):null]}),f?e.jsx(ve,{what:"tasks",reason:f,onRetry:()=>k(null)}):c?w.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"}),b?e.jsx("th",{className:"num",children:"Cost"}):null]})}),e.jsx("tbody",{children:w.map(({task:$,call:R,unread:T,wait:C})=>{var E;return e.jsxs("tr",{onClick:()=>Ue(ce("tasks",$.id)),children:[e.jsxs("td",{className:"rc-title",children:[e.jsx("a",{className:"row-link",href:ce("tasks",$.id),dir:"auto",children:T?e.jsx("strong",{children:$.title}):$.title}),T?e.jsx("span",{className:"visually-hidden",children:" (new)"}):null,(E=$.sharedWith)!=null&&E.includes(t.id)&&$.createdBy!==t.email?e.jsx("span",{className:"muted small",children:" shared with you"}):null,$.issueKey?e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{className:"muted mono",children:$.issueKey})]}):null]}),e.jsx("td",{className:"mono rc-meta",children:d0($)}),e.jsx("td",{className:"rc-meta",children:e.jsx(s0,{id:$.agent,known:s})}),e.jsx("td",{className:"rc-status",children:R?e.jsx("span",{className:`state ${lu[R].tone}`,children:lu[R].label}):C?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"state warn",children:C.badge})," ",e.jsx("a",{href:ce("settings","machines"),onClick:O=>O.stopPropagation(),children:C.link})]}):e.jsx(BC,{task:$})}),e.jsx("td",{className:"rc-extra num",children:$.startedAt?dr($):null}),b?e.jsx("td",{className:"rc-extra num",children:Wp($)==="unknown"?null:Wp($)}):null]},$.id)})})]}):e.jsx("p",{className:"muted",children:"No task has run yet."}):l?e.jsx(fe,{what:"tasks"}):null,u?e.jsx("button",{type:"button",className:"secondary",onClick:()=>k(u),disabled:j,children:j?"Loading older tasks…":"Show older tasks"}):null]})}const p0=t=>`${t.charAt(0).toLowerCase()}${t.slice(1)}`;function eu({me:t,start:s,repos:r=null,picked:l=null,onRepos:i}){var de;const[c,d]=m.useState(null),[u,p]=m.useState(null),[f,g]=m.useState(null),[j,y]=m.useState(null),[k,N]=m.useState(null),w=()=>$e.budgets().then(N,()=>N(null)).finally(()=>T(se=>se+1)),[b,$]=m.useState(null),[R,T]=m.useState(0),[C,E]=m.useState(null),[O,F]=m.useState(null),L=new URLSearchParams(window.location.search).get("removed"),[W,A]=m.useState(L?`${L} is removed.`:null);m.useEffect(()=>{L&&(i==null||i())},[L]),m.useEffect(()=>{Je.list().then(se=>E(se.last),()=>E(null))},[]);const M=()=>Xb.read(l).then(se=>{p(se),g(null)},se=>g(se.message)),Q=()=>$e.options().then(se=>{d(se),y(null)},se=>y(se.message));m.useEffect(()=>{Q(),w(),su.read().then($,()=>$(null)).finally(()=>T(se=>se+1))},[]);const H=(r==null?void 0:r.map(se=>se.id).join(","))??null,U=m.useRef(H);m.useEffect(()=>{U.current!==null&&U.current!==H&&Q(),U.current=H},[H]),m.useEffect(()=>{M()},[l]),m.useEffect(()=>{if(!(c!=null&&c.agents.some(he=>!he.readiness)))return;const se=setTimeout(Q,2e3);return()=>clearTimeout(se)},[c]),m.useEffect(()=>{if(!u||!u.counts.agents&&!u.counts.waiting)return;const se=setInterval(M,1500);return()=>clearInterval(se)},[u]);const ie=!!(u&&(c&&R>=2||j)),X=!!(u&&Vp.every(se=>!u.counts[se.id])),J=Vp.filter(se=>se.id!=="waiting"||t.tasksRunHere===!1),Z=r??[],ae=l?((de=Z.find(se=>se.id===l))==null?void 0:de.name)??l:null,z=u?nN(u):null,P=ae?`In ${ae}, ${z?p0(z):"nothing waits on you and no agent is at work."}`:z,_=t.mode==="local",V=Z.filter(se=>se.configured!==!1),le=e.jsxs(e.Fragment,{children:[W?e.jsx("p",{className:"notice",role:"status",children:W}):null,!_&&r!==null&&!Z.some(se=>se.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:Ie(t)?e.jsxs(e.Fragment,{children:["Connect GitLab or GitHub and pick a repository in the ",e.jsx("a",{href:ce("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:X?void 0:"visually-hidden",children:"New task"}),c&&R>=2?e.jsx(r0,{options:t.tasksRunHere===!1?{...c,multiRepo:null}:c,budgets:k,limits:b,...s?{start:s}:{},local:t.mode==="local",approver:Ie(t),defaultRepo:l??C,first:_&&X&&!s,onStarted:se=>Ue(ce("tasks",se.id))},c.repos.map(se=>se.id).join(",")):j?e.jsx(ve,{what:"the task form",reason:j,onRetry:Q}):e.jsx(fe,{what:"the task form"})]}),ie&&!(_&&X)&&P?e.jsx("p",{className:"muted day-sentence",role:"status",children:P}):null,ie&&!_&&(V.length>1||l)?e.jsx("div",{className:"list-filter",children:e.jsx(Pe,{label:"Show tasks in",labelHidden:!0,value:l??"",onChange:se=>Ue(se?`${ce("tasks")}?${new URLSearchParams({repo:se})}`:ce("tasks")),options:[{value:"",label:"All repositories"},...V.map(se=>({value:se.id,label:se.name}))]})}):null,ie&&!X?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(Oo,{what:"tasks",reason:f,onRetry:M}):null,f&&!u?e.jsx(ve,{what:"tasks",reason:f,onRetry:M}):ie?X?null:J.filter(se=>u.counts[se.id]>0).map(se=>{const he=u.sections[se.id],Le=u.counts[se.id]-he.length;return e.jsxs($n,{name:se.name,count:u.counts[se.id],why:se.why,empty:se.empty,children:[e.jsx(h0,{cards:he,me:t,agents:(c==null?void 0:c.agents)??null}),Le>0?e.jsxs("p",{className:"muted small",children:[Le," more; All tasks below holds them."]}):null]},se.id)}):c&&R>=2||j?e.jsx(fe,{what:"tasks"}):null,_&&X||!(c&&R>=2||j)?null:e.jsx(m0,{me:t,agents:(c==null?void 0:c.agents)??null,picked:l})]}),be=!_&&r!==null&&!Z.some(se=>se.configured!==!1),pe=!!(t.runners&&t.tasksRunHere===!1)||Ie(t);return be&&pe&&O===null&&F("open"),O==="open"?e.jsx(Rg,{me:t,org:Ds(window.location.pathname).org??"",repos:r??[],onRepos:i??(()=>Promise.resolve()),onFinished:()=>F("left")}):e.jsxs("div",{className:"page",children:[e.jsx(Cn,{title:_&&X?dg:"Tasks"}),le,_&&X?e.jsx(eg,{me:t,quiet:!0}):null]})}function f0(t,s){const r=s.trim().toLowerCase();return r?t.filter(l=>l.text.toLowerCase().includes(r)).map(l=>l.seq):[]}function g0(t,s){const r=s.trim().toLowerCase();if(!r)return t;const l=[];let i=0;for(let c=t.toLowerCase().indexOf(r);c!==-1;c=t.toLowerCase().indexOf(r,i))l.push(t.slice(i,c),e.jsx("mark",{children:t.slice(c,c+r.length)},c)),i=c+r.length;return l.push(t.slice(i)),l}const x0=1500,j0=48,Yp=new Map;function y0(t,s,r){const l=Math.max(0,t-x0*(1+s));return r!==null&&r>=0&&r<l?r:l}const v0=()=>window.innerHeight+window.scrollY>=document.documentElement.scrollHeight-j0;function k0({id:t,log:s,outputCut:r,live:l}){const[i,c]=m.useState(""),[d,u]=m.useState(0),[p,f]=m.useState(0),[g,j]=m.useState(0),y=m.useRef(!1),k=m.useRef(0),N=m.useRef(!1),w=f0(s,i),b=w.length?w[Math.min(d,w.length-1)]:null,$=y0(s.length,p,b===null?null:s.findIndex(C=>C.seq===b));m.useEffect(()=>{const C=()=>{y.current=v0(),Yp.set(t,window.scrollY),y.current&&j(0)};return window.addEventListener("scroll",C,{passive:!0}),()=>window.removeEventListener("scroll",C)},[t]),m.useEffect(()=>{const C=s.length-k.current;if(k.current=s.length,!!s.length){if(!N.current){N.current=!0;const E=Yp.get(t);E!==void 0&&window.scrollTo(0,E);return}!l||C<=0||(y.current?window.scrollTo(0,document.documentElement.scrollHeight):j(E=>E+C))}},[s.length]),m.useEffect(()=>{var C;b!==null&&((C=document.getElementById(`log-line-${b}`))==null||C.scrollIntoView({block:"nearest"}))},[b]);const R=C=>w.length&&u((Math.min(d,w.length-1)+C+w.length)%w.length),T=()=>{j(0),y.current=!0,window.scrollTo(0,document.documentElement.scrollHeight)};return e.jsxs(e.Fragment,{children:[r?e.jsxs("p",{className:"muted",role:"note",children:["Part of the output was left out; the log marks where. ",e.jsx(Ee,{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,s.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:i,onChange:C=>{c(C.target.value),u(0)},onKeyDown:C=>{C.key==="Enter"&&(C.preventDefault(),R(C.shiftKey?-1:1))}})]}),i.trim()?e.jsx("span",{className:"muted small",role:"status",children:w.length?`${w.indexOf(b)+1} of ${w.length}`:"No line matches."}):null]}):null,$>0?e.jsx("p",{children:e.jsxs("button",{type:"button",className:"secondary small",onClick:()=>f(p+1),children:["Show earlier lines (",$,")"]})}):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:s.slice($).map(C=>e.jsxs("li",{id:`log-line-${C.seq}`,"data-seq":C.seq,"aria-current":C.seq===b?"true":void 0,children:[e.jsx("span",{className:"muted mono",children:YC(C.at)})," ",e.jsx("span",{dir:"auto",children:g0(C.text,i)})]},C.seq))})}),s.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:T,children:[g," new ",g===1?"line":"lines"]}):null]})}function w0({id:t,me:s}){var rn,an,Wt,bt,Ae,cs,us,ds;const[r,l]=m.useState(null),[i,c]=m.useState([]),[d,u]=m.useState(null),[p,f]=m.useState(null),[g,j]=m.useState(!1),[y,k]=m.useState(!1),[N,w]=m.useState(null),[b,$]=m.useState(0),[R,T]=m.useState(0),[C,E]=m.useState(null),O=Ug((r==null?void 0:r.agent)??""),[F,L]=es(VC),[W,A]=m.useState([]),M=m.useRef(0);m.useEffect(()=>{M.current=0,c([]),l(null),u(null),w(null),k(!1),f(null);let ue=!1,Ge=!1,Pt=0,hs;const ln=()=>$e.get(t,M.current).then(({task:pt,log:lt,outputCut:ps,next:On})=>{if(ue)return;Ge=!0,Pt=0,w(null),l(pt),ps&&k(!0),lt.length&&(M.current=On??lt[lt.length-1].seq,c(pr=>[...pr,...lt]));const Ft=On!=null;(Ft||Un.includes(pt.status))&&(hs=setTimeout(ln,Ft?0:1e3))},pt=>{if(ue)return;if(!Ge)return u(pt.message);Pt++;const lt=Math.min(15e3,1e3*2**Pt);w({line:`The task did not refresh; trying again in ${lt/1e3} s.`,reason:pt.message}),hs=setTimeout(ln,lt)});let mt=null;return(()=>{if(typeof EventSource>"u")return ln();mt=new EventSource($e.eventsUrl(t,M.current)),mt.addEventListener("task",pt=>{Ge=!0,w(null),l(JSON.parse(pt.data))}),mt.addEventListener("log",pt=>{const{log:lt,outputCut:ps}=JSON.parse(pt.data);ps&&k(!0),lt.length&&(M.current=lt[lt.length-1].seq,c(On=>[...On,...lt]))}),mt.onerror=()=>{mt==null||mt.close(),mt=null,ue||ln()}})(),$e.options().then(pt=>E({editable:pt.repos.map(lt=>lt.id),agents:pt.agents}),()=>E({editable:[],agents:[]})),()=>{ue=!0,mt==null||mt.close(),clearTimeout(hs)}},[t,b]);const Q=()=>$e.get(t,M.current).then(ue=>l(ue.task),ue=>w({line:"The task did not refresh.",reason:ue.message})),H=NC({task:r,mine:(r==null?void 0:r.createdBy)===s.email,onChanged:()=>void Q()}),[U,ie]=m.useState(null);m.useEffect(()=>{Je.list().then(ue=>ie(ue.home??null),()=>ie(null))},[]);const X=((rn=r==null?void 0:r.routing)==null?void 0:rn.path)??null,J=m.useMemo(()=>qS(i,{folder:X,home:U}),[i,X,U]),[Z,ae]=m.useState(!0);m.useEffect(()=>{const ue=()=>ae(window.innerHeight+window.scrollY>=document.documentElement.scrollHeight-48);return window.addEventListener("scroll",ue,{passive:!0}),()=>window.removeEventListener("scroll",ue)},[]),m.useEffect(()=>{Z&&r&&Un.includes(r.status)&&window.scrollTo(0,document.documentElement.scrollHeight)},[J.stream.length,!!C]);const[z,P]=m.useState(!1),[_,V]=m.useState([]),le=r?!Un.includes(r.status):!1,be=!!(r!=null&&r.routing);if(m.useEffect(()=>{!le&&!be||Hr.task(t).then(V,()=>V([]))},[t,le,be,r==null?void 0:r.finishedAt]),d)return e.jsx(ve,{what:"the task",reason:d,onRetry:()=>$(ue=>ue+1),panel:!0});if(!r||!C)return e.jsx(fe,{what:"the task",panel:!0});const pe=Un.includes(r.status),de=((an=C.agents.find(ue=>ue.id===r.agent))==null?void 0:an.label)??O,se=C.editable,he=ue=>{j(!0),f(null),ue().catch(Ge=>f(Ge.message)).finally(()=>j(!1))},Le=()=>he(()=>$e.start(UC(r)).then(ue=>Ue(ce("tasks",ue.id)))),Ye=(r.requests??[]).some(ue=>ue.kind==="plan"&&ue.status!=="answered"&&!!ue.payload.plan),Tt=Ye?null:HS(J.stream),tt=["interrupted","failed","cancelled"].includes(r.status)&&(r.planToApprove===!0||Ye||Tt!==null),rs=()=>he(()=>$e.continueWithPlan(r.id,Tt??void 0).then(()=>$(ue=>ue+1))),Fe=r.request,mr=()=>he(()=>Ne.requestAction(r.repoId,r.requestNumber,"refresh").then(ue=>Fe&&l({...r,request:{...Fe,status:ue.status}}))),en=se.includes(r.repoId),as=r.createdBy===s.email||r.createdBy===s.id||Ie(s)||s.role!=="viewer"&&s.ownedTeams.includes(r.team),Et=r.followUp&&r.createdBy===s.email?r.followUp:null,tn=!Et&&r.suggests?((Wt=r.startedBy)==null?void 0:Wt.name)??"the person who started this task":null,wt=Et||tn?ue=>A(SC(W,ue)):void 0,Bn=(r.createdBy===s.email||Ie(s)||s.ownedTeams.includes(r.team))&&(Fe==null?void 0:Fe.status)==="open"&&!Un.includes(r.status),ls=ue=>$e.dropFromRequest(r.id,ue).then(()=>{T(Ge=>Ge+1),Q()}),os=qC(r),nn=ur(r),is=Qr(nn,r.forge),sn=r.requestNumber!==null&&!r.targets,at=s.mode==="local"&&sn&&(Fe==null?void 0:Fe.provider)==="local",En=ue=>Ne.requestAction(r.repoId,r.requestNumber,ue).then(Ge=>Fe&&l({...r,request:{...Fe,status:Ge.status}})),He=_.map(ue=>ue.verification).find(ue=>ue.verdict==="broken"||ue.verdict==="failing-before")??null,Rn=r.requestNumber===null&&!((bt=r.changes)!=null&&bt.files.length)&&!((Ae=r.targets)!=null&&Ae.length),zn=r.status==="failed"&&Rn,gn=!!(r.question&&!r.question.answer&&!pe),nt=J.stream.length>0||J.plan.length>0||!!r.routing,xn=ue=>r.routing?e.jsx(OC,{task:r,routing:r.routing,canMove:ue&&r.createdBy===s.email,checked:[...new Set(_.flatMap(Ge=>Ge.verification.checks.map(Pt=>Pt.command)))],onChecksOff:()=>void Hr.task(t).then(V,()=>V([]))}):null,Pn=J.costUsd??r.cost.usd,Rt=((cs=[...J.stream].reverse().find(ue=>ue.kind==="say"))==null?void 0:cs.text)??"",An=F===`open:${t}`||F!=="closed"&&!gn&&(!nt&&(pe||r.status==="failed"||r.status==="interrupted")||r.status==="needs-review"&&Rn),In=Un.includes(r.status)&&en?e.jsx(qe,{danger:!0,trigger:"Stop…",consequence:r.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:r.status==="queued"?"Keep it in line":"Keep it running",onConfirm:()=>$e.cancel(t).then(l)}):null,Wn=pe&&nt&&!Z?e.jsx("button",{type:"button",className:"run-jump secondary small",onClick:()=>{ae(!0),window.scrollTo(0,document.documentElement.scrollHeight)},children:"Jump to latest"}):null,jn=QC(r,de,s,ue=>new Date(ue).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),r.routing?ts(r.routing.path,U):null);return e.jsxs("div",{className:"page task-page",children:[e.jsx(PS,{message:`${is.word}${Dp(r)?`; ${de||"the agent"} asks you`:""}${pe&&Rt?`. ${Rt}`:""}`}),e.jsx(Cn,{sticky:!0,title:r.title,below:pe&&J.plan.length?e.jsx(JS,{plan:J.plan}):null,...gn?{summary:`The agent stopped to ask ${r.createdBy===s.email?"you":r.createdBy}.`}:pe&&r.startedAt&&r.waitingFor?Pn!==null?{summary:`The agent has spent $${Pn.toFixed(2)} so far.`}:{}:pe&&r.startedAt?{summary:e.jsx(C0,{task:r,spent:Pn})}:He?{summary:e.jsx("span",{className:"error",children:He.reason})}:os==="needs-review"?{summary:N0(r)}:zn&&r.startedAt?{summary:`The agent stopped after ${dr(r)}${GC(r.error)}`}:{},actions:e.jsxs(e.Fragment,{children:[H.actions,at?(Fe==null?void 0:Fe.status)==="open"&&en?e.jsxs(e.Fragment,{children:[Fe.heldReason===void 0?e.jsx("button",{type:"button",disabled:g,onClick:()=>he(()=>En("merge")),children:"Keep these changes"}):null,e.jsx(qe,{trigger:"Discard these changes…",consequence:"The task's branch is dropped; your checkout does not change.",confirm:"Discard changes",keep:"Keep them for now",onConfirm:()=>En("close")})]}):null:sn?e.jsx("a",{className:`button${r.status==="needs-review"?"":" secondary"}`,href:ce("repositories",r.repoId,"requests"),children:"Open the request"}):null,tt&&en&&!gn?e.jsx("button",{type:"button",onClick:rs,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,_C.includes(r.status)&&en&&!gn?e.jsx("button",{type:"button",className:tt?"secondary":void 0,onClick:Le,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,as&&!z?e.jsx("button",{type:"button",className:"secondary",onClick:()=>P(!0),children:"Share…"}):null]}),children:e.jsxs("span",{className:`state ${is.tone}`,"data-status":nn,children:[is.word,r.queuePosition!==null?`, #${r.queuePosition} in line`:""]})}),Un.includes(r.status)&&r.createdBy===s.email?e.jsx(Ry,{}):null,wt?e.jsx(tS,{onQuote:wt}):null,e.jsxs("div",{className:"with-rail",children:[e.jsxs("div",{className:"task-main",children:[N?e.jsxs("p",{className:"error",role:"status",children:[N.line," ",e.jsx(Ee,{label:"why the task did not refresh",children:N.reason})]}):null,r.error&&!(r.question&&!r.question.answer)&&!(zn&&r.startedAt)?r.status==="needs-review"?e.jsx("p",{className:"muted",role:"note",children:r.error}):e.jsx("p",{className:"error",role:"alert",children:r.error}):null,e.jsx(RC,{task:r,mine:r.createdBy===s.email,agent:de,onAnswered:ue=>{l(ue),$(Ge=>Ge+1)}}),p?e.jsx("p",{className:"error",role:"alert",children:Wa(p)?e.jsxs(e.Fragment,{children:[Wa(p).said,": ",e.jsx(yt,{text:Wa(p).command})]}):p}):null,e.jsx(jC,{task:r,me:s,onContinued:()=>$(ue=>ue+1)}),e.jsx(Fg,{names:r.mcpNeedsSignIn??[]}),pe&&nt?e.jsx("section",{className:"section","aria-label":"The agent at work",children:e.jsx(Fp,{run:J,withPlan:!1,first:xn(!0),working:r.status==="running"&&!r.waitingFor})}):null,e.jsx(fC,{task:r,me:s,agent:de,onAnswered:Q}),r.targets?a0(r)?e.jsx(l0,{task:r,local:s.mode==="local",starter:r.createdBy===s.email,onChanged:()=>void Q(),...wt?{onQuote:wt}:{}}):e.jsx(u0,{task:r}):null,H.section,sn?e.jsxs("section",{className:"section","aria-labelledby":"task-req-h",children:[e.jsx("h2",{id:"task-req-h",children:"Changes"}),at?null:e.jsxs("div",{className:"request-state",children:[e.jsx("p",{children:Fe?Mg(r.forge,r.requestNumber,Fe.status):"The change was opened."}),Fe?e.jsx(Vu,{request:{repoId:r.repoId,number:r.requestNumber,status:Fe.status,provider:Fe.provider,...Fe.heldReason!==void 0?{heldReason:Fe.heldReason}:{}}}):null]}),(Fe==null?void 0:Fe.status)==="open"&&Fe.provider!=="local"&&en?e.jsx("p",{children:e.jsxs("button",{type:"button",className:"secondary small",onClick:mr,disabled:g,children:["Refresh from ",Fe.provider]})}):null,s.mode==="local"&&(Fe==null?void 0:Fe.status)==="open"&&Fe.provider==="local"?e.jsx(XN,{repoId:r.repoId,number:r.requestNumber}):null,e.jsx(sl,{reads:Do(r.repoId,r.requestNumber),bare:!0,...wt?{onQuote:wt}:{},...Bn?{onDrop:ls}:{},ownCopy:at},`${r.id}:${R}`)]}):null,e.jsx(MC,{task:r,me:s,onAnswered:ue=>{ue&&Et==="continue"?$(Ge=>Ge+1):Q()}}),Et&&((us=r.messages)!=null&&us.length)?e.jsx(CC,{task:r.id,messages:r.messages,onChanged:()=>void Q()}):null,Et&&!(Et!=="continue"&&Dp(r))?e.jsx(Bp,{task:r,kind:Et,jump:Wn,stop:In,quotes:W,onQuotes:A,onSent:()=>{Et==="continue"?$(ue=>ue+1):Q()}}):tn?e.jsx(Bp,{task:r,kind:"suggest",suggestTo:tn,quotes:W,onQuotes:A,onSent:()=>void Q()}):In?e.jsxs("form",{className:"run-steer","aria-label":"Stop the task",onSubmit:ue=>ue.preventDefault(),children:[Wn,In]}):null,!pe&&nt?e.jsxs("details",{className:"section log-fold",open:zn&&!gn,children:[e.jsx("summary",{children:"How the agent got here"}),e.jsx(Fp,{run:J,first:xn(!1)})]}):null,e.jsxs("details",{className:"section log-fold",open:An,onToggle:ue=>{const Ge=ue.currentTarget.open;Ge!==An&&L(Ge?`open:${t}`:"closed")},children:[e.jsxs("summary",{children:["Log ",i.length?e.jsx("span",{className:"count",children:i.length}):null]}),e.jsx(k0,{id:t,log:i,outputCut:y,live:Un.includes(r.status)},t)]})]}),e.jsxs("aside",{className:"rail","aria-label":"About this task",children:[_.some(ue=>ue.verification.checks.length)?e.jsx(S0,{checks:_,machineOf:r.runner==="local"?r.createdBy===s.email?"you":r.createdBy:null}):null,r.description&&r.description!==r.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:r.description})]}):null,e.jsxs("section",{"aria-labelledby":"task-where-h",children:[e.jsx("h2",{id:"task-where-h",children:"Where"}),e.jsx(Jp,{facts:jn.where}),(ds=r.issueUrl)!=null&&ds.startsWith("https://")?e.jsxs("p",{children:["Works on ",e.jsx("a",{href:r.issueUrl,target:"_blank",rel:"noopener noreferrer",children:r.issueKey??r.issueUrl}),", read through ",s.mode==="local"?"your":"the team's"," MCP servers."]}):null]}),r.folderTrust==="unasked"&&r.createdBy===s.email?e.jsx(b0,{task:r,onAnswered:Q}):null,e.jsx(yC,{task:r.id,canShare:as,manager:Ie(s),adding:z,onClose:()=>P(!1)}),pe&&J.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:J.changed.map(ue=>e.jsxs("li",{children:[e.jsx("span",{className:"mono",dir:"auto",children:ue.path})," ",e.jsx(Uo,{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(Jp,{facts:jn.run})]}),pe?null:e.jsx(Zk,{task:r.id,finishedAt:r.finishedAt},r.id)]})]})]})}function b0({task:t,onAnswered:s}){const[r,l]=m.useState(!1),[i,c]=m.useState(null),d=u=>{l(!0),c(null),Je.trust(t.repoId,u).then(s,p=>c(p.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(Ee,{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:r,onClick:()=>d(!0),children:"Use them"}),e.jsx("button",{type:"button",className:"ghost small",disabled:r,onClick:()=>d(!1),children:"Keep them off"})]}),i?e.jsx("p",{className:"error",role:"alert",children:i}):null]})}function N0(t){var i;const s=t.startedAt&&t.finishedAt?` in ${dr(t)}`:"",r=(t.targets??[]).filter(c=>c.status==="request"||c.status==="failed"||c.status==="local");if(r.length&&r.every(c=>c.status==="local")){const c=t.ranOn?` on ${t.ranOn}`:"";return`The agent finished${s}, changing ${Qp(r.map(Ao))}; ${r.length===1?`the change stays on its branch${c}`:`the changes stay on their branches${c}`}.`}if(r.length)return`The agent finished${s}, changing ${Qp(r.map(Ao))}; ${r.length===1?"the change waits":"each change waits"} for your review.`;const l=((i=t.changes)==null?void 0:i.files.length)??0;return`The agent finished${s}${l?`, changing ${l} ${l===1?"file":"files"}`:""}; the change waits for your review.`}const Qp=t=>t.length===1?t[0]:`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`;function S0({checks:t,machineOf:s}){const r=t.length>1,l=s!==null&&t.some(i=>i.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 ",s==="you"?"your":`${s}'s`," machine, not on the orchestrator."]}):null,e.jsx("ul",{className:"plain run-checks",children:t.flatMap(({repoId:i,verification:c})=>c.checks.map(d=>{const u=d.after.at(-1)??d.before;return e.jsx("li",{className:mS(d)?"error":void 0,children:e.jsxs("details",{children:[e.jsxs("summary",{children:[e.jsx("span",{className:"mono",children:d.command}),r?e.jsxs("span",{className:"muted",children:[" in ",i]}):null," ",hS(d)]}),u!=null&&u.output?e.jsxs("pre",{className:"pre mono",children:[u.cut?`${u.cut} lines left out
|
|
85
|
-
`:"",u.output]}):e.jsx("p",{className:"muted small",children:"No output."})]})},`${i}:${d.command}`)}))})]})}function C0({task:t,spent:s}){const[,r]=m.useState(0);return m.useEffect(()=>{const l=setInterval(()=>r(i=>i+1),1e3);return()=>clearInterval(l)},[]),e.jsxs(e.Fragment,{children:["The agent has worked ",dr(t),s!==null?`; $${s.toFixed(2)} so far`:"","."]})}function Jp({facts:t}){return e.jsx("dl",{children:t.map(s=>e.jsxs(m.Fragment,{children:[e.jsx("dt",{children:s.term}),e.jsx("dd",{dir:"auto",children:s.value})]},s.term))})}const $0=[{name:"To do",category:"todo"},{name:"In progress",category:"doing"},{name:"Done",category:"done"}];function T0(t,s){var i;if(!t.length)return $0.map(c=>({name:c.name,items:s.filter(d=>d.status.category===c.category)}));const r=t.map(c=>({name:c.name,items:[]})),l=[];for(const c of s)(((i=r.find(d=>d.name===c.column))==null?void 0:i.items)??l).push(c);return[...r,...l.length?[{name:"Other",items:l}]:[]]}function qg(t){var p;const s=new Set,r=new Set;let l=null,i=!1;for(const f of t.items)for(const g of f.tasks){for(const j of g.requests)j.status==="open"&&(s.add(`${j.repoId}#${j.number}`),r.add(j.url?((p=/ on (GitLab|GitHub)$/.exec(j.name))==null?void 0:p[1])??"":""));g.costUsd===null?i=!0:l=(l??0)+g.costUsd}const{todo:c,doing:d,done:u}=t.progress;return{done:u,total:c+d+u,openRequests:s.size,blocked:t.items.filter(f=>f.blocked).length,costUsd:l,costPartial:i&&l!==null,reviewOn:r.size===1&&[...r][0]?[...r][0]:null}}function Au(t){const s=t.requests[0],r=s==null?void 0:s.name.match(/ on (GitLab|GitHub)$/),l=s!=null&&s.url&&r?{kind:r[1].toLowerCase(),number:s.number,url:s.url}:null,i=ur({status:t.status,...t.phase?{phase:t.phase}:{},result:t.result??null,request:s?{status:s.status,provider:s.url?"forge":"local"}:null}),{word:c,tone:d}=Qr(i,l);return{label:c,tone:d}}function Io(t,s){var i;return(((i=t.assignee)==null?void 0:i.you)??(t.assignee!==null&&t.assignee.name.trim().toLowerCase()===s.name.trim().toLowerCase()))||t.tasks.some(c=>c.startedBy===s.email)}const Xp=["highest","critical","blocker","high","medium","low","lowest"];function Bg(t,s){const r=t.items.filter(i=>i.status.category==="todo"&&!i.tasks.length&&!i.blocked),l=i=>{const c=Xp.indexOf((i.priority??"").toLowerCase());return c<0?Xp.length:c};return[...r].sort((i,c)=>Number(Io(c,s))-Number(Io(i,s))||l(i)-l(c))[0]??null}function E0(t,s,r){const l=g=>`- ${g.key} ${g.summary}`,i=qg(s),c=s.progress,d=s.items.filter(g=>{var j;return(j=g.tasks[0])==null?void 0:j.requests.some(y=>y.status==="open")}),u=s.items.filter(g=>g.tasks[0]&&["queued","running"].includes(g.tasks[0].status)),p=s.items.filter(g=>g.blocked),f=Bg(s,r);return[`${t}: ${c.done} of ${i.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)]:[],...p.length?["","Blocked:",...p.map(l)]:[],...f?["","Next up:",l(f)]:[]].join(`
|
|
86
|
-
`)}function R0({board:t,onMapped:s}){const[r,l]=m.useState(null),[i,c]=m.useState(t.team??""),[d,u]=m.useState(!t.team),[p,f]=m.useState(!1),[g,j]=m.useState(null),[y,k]=m.useState(null),N=()=>{k(null),Xt.teams().then(b=>l(b.map($=>$.team)),b=>k(b.message))};m.useEffect(N,[]);const w=()=>{f(!0),j(null),Zt.mapBoard(t.id,i||null).then(()=>{u(!1),s(i||null)},b=>j(b.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:i,onChange:c,placeholder:r===null?"Loading the teams…":"Pick a team",options:(r??[]).map(b=>({value:b,label:b})),disabled:!(r!=null&&r.length)}),e.jsx("button",{type:"button",disabled:p||!i,onClick:w,children:"Save"}),t.team?e.jsx("button",{type:"button",className:"secondary",onClick:()=>u(!1),children:"Cancel"}):null]}),y?e.jsx(ve,{what:"the teams",reason:y,onRetry:N}):null,r!==null&&!r.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 zg=[{id:"started",label:"When its agent starts"},{id:"requestOpened",label:"When its request opens"},{id:"merged",label:"When its request is merged"}],P0=()=>`${ce("integrations")}?allow=transitionJiraIssue`;function A0({board:t,columns:s}){const[r,l]=m.useState(void 0),[i,c]=m.useState(null),[d,u]=m.useState(!1),[p,f]=m.useState(!1),[g,j]=es(`orchestrator.work.moves.offered.${t.id}`),y=()=>{c(null),Zt.moves(t.id).then(l,$=>$ instanceof ss?l(null):c($.message))};if(m.useEffect(y,[t.id]),r===void 0)return i?e.jsx(ve,{what:"the issue moves",reason:i,onRetry:y}):e.jsx(fe,{what:"the issue moves"});if(!r)return null;const k=$=>{u(!0),c(null),Zt.saveMoves(t.id,$).then(R=>{l(R),f(!1)},R=>c(R.message)).finally(()=>u(!1))},N=r.write.allowed?r.canChange?null:"Only an owner or an admin changes this for the organization's tracker.":r.write.reason??"The orchestrator cannot move this tracker's issues.",w=zg.filter($=>r.moves[$.id]).map($=>`${$.label.toLowerCase()}, to ${r.moves[$.id]}`).join("; "),b=r.guessed&&!r.enabled&&!N&&g!=="yes"&&w;return e.jsxs("div",{className:"moves",children:[b?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 ",w,". Every move is in the audit log."]}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",disabled:d,onClick:()=>k({enabled:!0,moves:r.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:()=>j("yes"),children:"Not now"})]})]}):null,e.jsxs("div",{className:"moves-switch",children:[e.jsxs("button",{type:"button",role:"switch","aria-checked":r.enabled,"aria-describedby":N?"moves-why":void 0,disabled:d||!!N,onClick:()=>k({enabled:!r.enabled,moves:r.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":p,onClick:()=>f(!p),children:"Columns"}),N?e.jsxs("p",{id:"moves-why",className:"muted small",children:[N,r.write.off?e.jsxs(e.Fragment,{children:[" ",e.jsx("a",{href:`${ce("integrations")}?open=tracker`,children:"Open the issue tracker card"})]}):r.write.allowed?null:e.jsxs(e.Fragment,{children:[" ",e.jsx("a",{href:P0(),children:"Allow Jira writes"})]})]}):null]}),p?e.jsx(I0,{moves:r,columns:s,busy:d,onSave:$=>k({enabled:r.enabled||!!b,moves:$}),onCancel:()=>f(!1)},JSON.stringify(r.moves)):null,i?e.jsx("p",{className:"error",role:"alert",children:i}):null]})}function I0({moves:t,columns:s,busy:r,onSave:l,onCancel:i}){const[c,d]=m.useState(t.moves),u=[{value:"",label:"Don't move it"},...s.map(p=>({value:p.name,label:p.name}))];return e.jsxs("form",{className:"form inline-form","aria-label":"Where issues move",onSubmit:p=>{p.preventDefault(),l(c)},children:[zg.map(p=>e.jsx(Pe,{label:p.label,value:c[p.id]??"",options:u,onChange:f=>d({...c,[p.id]:f||void 0})},p.id)),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"submit",disabled:r,children:"Save"}),e.jsx("button",{type:"button",className:"secondary",onClick:i,children:"Cancel"})]})]})}function O0({board:t,columns:s,onSaved:r}){const l=s.flatMap(N=>N.statuses.map(w=>({status:w,column:N.name}))),[i,c]=m.useState(()=>Object.fromEntries(l.map(N=>[N.status,N.column]))),[d,u]=m.useState(!1),[p,f]=m.useState(null),[g,j]=m.useState(null),y=N=>{u(!0),j(null),Zt.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."),r()},w=>j(w.message)).finally(()=>u(!1))},k=()=>{const N=[],w=new Map;for(const{status:b}of l){const $=(i[b]??b).trim()||b;w.has($)||(w.set($,[]),N.push($)),w.get($).push(b)}return N.map(b=>({name:b,statuses:w.get(b)}))};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:i[N]??"",maxLength:60,onChange:w=>c({...i,[N]:w.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(k()),children:"Save the columns"}),e.jsx("button",{type:"button",className:"ghost",disabled:d,onClick:()=>y(null),children:"A column per status"})]}),p?e.jsx("p",{role:"status",children:p}):null,g?e.jsx("p",{className:"error",role:"alert",children:g}):null]})}const L0=20;function F0({items:t,local:s=!1,onStarted:r,onCancel:l}){var z,P;const i=s?"every skill":"every team skill",[c,d]=m.useState(null),[u,p]=m.useState(null),[f,g]=m.useState(""),[j,y]=m.useState({}),[k,N]=m.useState("orchestrator"),[w,b]=m.useState(""),[$,R]=m.useState(!1),[T,C]=m.useState(null),[E,O]=m.useState(null),[F,L]=m.useState(null),[W,A]=m.useState({}),M=()=>{p(null),$e.options().then(_=>{var le,be;const V=_.repos.filter(pe=>pe.kind==="code");d(_),g(((le=_.agents[0])==null?void 0:le.id)??""),b(((be=V[0]??_.repos[0])==null?void 0:be.id)??""),N(_.multiRepo?"orchestrator":"chosen")},_=>p(_.message))};m.useEffect(M,[]);const Q=(c==null?void 0:c.repos.filter(_=>_.kind==="code"))??[],H=!!(c!=null&&c.multiRepo)&&k==="orchestrator",U=H?((z=Q[0])==null?void 0:z.id)??"":w,ie=H?"orchestrator":void 0;m.useEffect(()=>{if(s||!c||!f||!U)return;let _=!0;O(null),L(null);const V=setTimeout(()=>{$e.suggestSkillsFor({agent:f,items:t.map(le=>({repoId:U,issueUrl:le.url,...ie?{targets:ie}:{}}))}).then(le=>{if(!_)return;const be={},pe={};for(const de of le.results){const se=t[de.index].key;be[se]=de,"suggestions"in de&&(pe[se]=de.suggestions.map(he=>he.skill).slice(0,Co))}O(be),A(pe)},le=>_&&L(le.message))},300);return()=>{_=!1,clearTimeout(V)}},[c,f,U,k]);const X=_=>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"]})]}),_]});if(u)return X(e.jsx(ve,{what:"the task options",reason:u,onRetry:M}));if(!c)return X(e.jsx(fe,{what:"the task options"}));if(T){const _=T.filter(V=>"task"in V).length;return X(e.jsxs(e.Fragment,{children:[e.jsxs("p",{role:"status",children:[_===T.length?`${_} ${_===1?"agent":"agents"} started.`:`${_} of ${T.length} agents started.`," ",T.length===1?"Its card shows where it stands.":"Their cards show where each stands."]}),e.jsx("ul",{className:"plain outcomes",children:T.map(V=>e.jsxs("li",{children:[e.jsx("span",{className:"mono",children:V.key})," ","task"in V?e.jsx("a",{href:ce("tasks",V.task.id),children:"started"}):e.jsxs("span",{className:"error",children:["not started: ",V.error]}),"error"in V?e.jsx(td,{code:V.code}):null]},V.key))}),e.jsx("button",{type:"button",className:"secondary",onClick:l,children:"Done picking"})]}))}const J=Q.length?Q:c.repos;if(!s&&!J.length)return X(e.jsxs("p",{children:["No repository is connected for agents to work in yet. ",e.jsx("a",{href:ce("repositories"),children:"Connect a repository"})]}));if(!c.agents.length)return X(e.jsxs("p",{children:["No agent is set up on this orchestrator yet. ",e.jsx("a",{href:ce("settings","agents"),children:"See Agent readiness"})]}));const Z=async()=>{const _=[];for(const V of t)try{const le=await $e.start({title:V.summary,description:"",issueUrl:V.url,agent:f,template:null,...Ur(j)?{choices:Ur(j)}:{}});_.push({key:V.key,task:le})}catch(le){_.push({key:V.key,error:le.message,...le instanceof ut?{code:le.code}:{}})}C(_),r()},ae=_=>{if(_.preventDefault(),R(!0),s){Z().finally(()=>R(!1));return}$e.startMany({agent:f,items:t.map(V=>{var le;return{issueUrl:V.url,repoId:U,...ie?{targets:ie}:{},...(le=W[V.key])!=null&&le.length?{skills:W[V.key]}:{},...Ur(j)?{choices:Ur(j)}:{}}})}).then(({started:V,refused:le})=>{const be=[...V];C(t.map((pe,de)=>{const se=le.find(he=>he.index===de);return se?{key:pe.key,error:se.error,code:se.code}:{key:pe.key,task:be.shift()}})),r()},V=>p(V.message)).finally(()=>R(!1))};return X(e.jsxs("form",{className:"form","aria-label":"Start agents",onSubmit:ae,children:[e.jsx("ul",{className:"plain picked",children:t.map(_=>{const V=E==null?void 0:E[_.key];return e.jsxs("li",{className:"picked-issue","aria-label":`${_.key} ${_.summary}`,children:[e.jsxs("p",{children:[e.jsx("span",{className:"mono",children:_.key})," ",_.summary]}),s||F?null:E?V?"error"in V?e.jsxs("p",{className:"muted small",children:["No suggestion: ",V.error," The agent still has ",i,"."]}):e.jsx(Ig,{label:"Skills to use first",read:V,value:W[_.key]??[],onChange:le=>A({...W,[_.key]:le}),local:s}):null:e.jsx("p",{className:"muted small",children:"Asking the agent which skills fit…"})]},_.key)})}),!s&&F?e.jsxs("p",{className:"muted small",children:["The agent did not suggest skills: ",F," Each agent still has ",i,"."]}):null,!s&&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:k==="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:k==="chosen",onChange:()=>N("chosen")}),"Work in one repository"]})]}):null,!s&&!H?e.jsx(Pe,{label:"Repository",value:w,onChange:b,options:J.map(_=>({value:_.id,label:_.name,...s?{}:{hint:_.team}}))}):null,c.agents.length>1?e.jsx(Pe,{label:"Agent",value:f,onChange:_=>{g(_),y({})},options:c.agents.map(_=>({value:_.id,label:_.label}))}):null,e.jsx(Cg,{options:(P=c.agents.find(_=>_.id===f))==null?void 0:P.options,value:j,onChange:y}),e.jsx("p",{className:"muted",children:s?"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&&!U||!f,children:t.length===1?"Start 1 agent":`Start ${t.length} agents`}),e.jsx("button",{type:"button",className:"secondary",onClick:l,children:"Cancel"})]})]}))}const M0=1e4,_0=t=>`$${t.toFixed(2)}`,yo=t=>t?t.slice(0,10):null;function D0({me:t,sources:s,backlog:r}){const l=tl();if(s===null)return e.jsx(fe,{what:"the issue trackers",panel:!0});if(!s.length)return e.jsx(q0,{me:t});const i=new URLSearchParams(l.search),c=s.find(d=>d.id===i.get("source"))??s.find(d=>!d.problem)??s[0];return e.jsx(B0,{me:t,sources:s,source:c,params:i,backlog:r},c.id)}function Va(t){const s=new URLSearchParams(window.location.search);for(const[r,l]of Object.entries(t))l?s.set(r,l):s.delete(r);Ue(`${window.location.pathname}?${s.toString()}`,!0)}const U0={scrum:"Scrum",kanban:"Kanban",project:"whole project"};function q0({me:t}){const s=`${ce("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:Ie(t)?e.jsxs(e.Fragment,{children:[e.jsx("a",{href:s,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:s,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 B0({me:t,sources:s,source:r,params:l,backlog:i}){const[c,d]=m.useState(null),[u,p]=m.useState(null),[f,g]=m.useState(null),j=(c==null?void 0:c.find(E=>E.id===l.get("board")))??(c==null?void 0:c[0])??null,y=(u==null?void 0:u.find(E=>E.id===l.get("sprint")))??(u==null?void 0:u.find(E=>E.state==="active"))??(u==null?void 0:u.find(E=>E.state==="future"))??null,k=()=>{g(null),Zt.boards(r.id).then(E=>d(E.boards),E=>g(E.message))};m.useEffect(()=>{r.problem||k()},[r.id]),m.useEffect(()=>{if(p(null),!!j){if(!r.can.sprints)return p([]);Zt.sprints(j.id).then(E=>p(E.sprints),E=>g(E.message))}},[j==null?void 0:j.id]);const N=e.jsxs("div",{className:"work-picker",children:[s.length>1?e.jsx(Pe,{label:"Source",value:r.id,onChange:E=>Va({source:E,board:null,sprint:null}),options:s.map(E=>({value:E.id,label:E.name,hint:E.as==="you"?"as you":void 0}))}):null,c&&c.length>1?e.jsx(Pe,{label:"Board",value:(j==null?void 0:j.id)??"",onChange:E=>Va({board:E,sprint:null}),options:c.map(E=>({value:E.id,label:E.name,hint:[U0[E.type],E.project].filter(Boolean).join(", ")||void 0}))}):null,u&&u.length?e.jsx(Pe,{label:"Sprint",value:(y==null?void 0:y.id)??"",onChange:E=>Va({sprint:E}),options:u.map(E=>({value:E.id,label:E.name,hint:E.state==="active"?"active":E.state==="future"?"next":"closed"}))}):null]}),w=r.kind==="jira"?"Jira":r.kind==="linear"?"Linear":r.kind==="gitlab"?"GitLab":"GitHub",b=(E,O)=>e.jsxs(e.Fragment,{children:[e.jsx(Cn,{title:E,crumb:j&&j.name!==E?j.name:r.name,summary:O??void 0,actions:j?e.jsxs("a",{className:"button secondary",href:j.url,target:"_blank",rel:"noopener noreferrer",children:["Open in ",w]}):void 0}),N]});if(r.problem)return e.jsxs("div",{className:"page",children:[b("Work"),e.jsx(ve,{what:r.name,reason:r.problem,next:e.jsx("a",{href:ce("integrations"),children:"Fix the connection under Integrations"}),panel:!0})]});if(f)return e.jsxs("div",{className:"page",children:[b("Work"),e.jsx(ve,{what:"the board",reason:f,onRetry:k,panel:!0})]});if(!c)return e.jsxs("div",{className:"page",children:[b("Work"),e.jsx(fe,{what:"the boards",panel:!0})]});if(!j)return e.jsxs("div",{className:"page",children:[b("Work"),e.jsx("div",{className:"panel",children:e.jsx("p",{className:"muted",children:Ie(t)?`No board is read from ${r.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:[b(j.name),e.jsx(fe,{what:"the sprints",panel:!0})]});const $=t.mode!=="local"&&Ie(t)&&r.as==="organization"?e.jsx(R0,{board:j,onMapped:E=>d(c.map(O=>O.id===j.id?{...O,team:E}:O))},j.id):null,R=y&&(yo(y.startsAt)||yo(y.endsAt))?`${yo(y.startsAt)??"?"} to ${yo(y.endsAt)??"?"}`:null,T=l.toString()?`?${l.toString()}`:"",C=e.jsx(Fo,{label:"Work",current:i?ce("work","backlog")+T:ce("work")+T,links:[{to:ce("work")+T,label:"Board"},...r.can.backlog?[{to:ce("work","backlog")+T,label:"Backlog"}]:[]]});return i?e.jsxs("div",{className:"page",children:[b("Backlog",`The issues on ${j.name} in no sprint, in the tracker's order.`),$,C,r.can.backlog?e.jsx(tu,{me:t,board:j,sprint:null,backlog:!0,mine:l.get("mine")==="1",moves:r.kind==="jira"},`${j.id}:backlog`):e.jsx("div",{className:"panel",children:e.jsxs("p",{className:"muted",children:[r.name," keeps no backlog the orchestrator reads."]})})]}):!y&&(r.kind==="jira"||r.kind==="linear")&&(j.type==="kanban"||j.type==="project")?e.jsxs("div",{className:"page",children:[b(j.name,j.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."),$,e.jsx(tu,{me:t,board:j,sprint:null,backlog:!1,whole:!0,mine:l.get("mine")==="1",moves:r.kind==="jira"},`${j.id}:board`)]}):e.jsxs("div",{className:"page",children:[b((y==null?void 0:y.name)??j.name,y?H0(R,y):r.can.sprints?"This board has no active or next sprint. The Backlog lists what is waiting.":null),$,C,e.jsx(tu,{me:t,board:j,sprint:y,backlog:!y,mine:l.get("mine")==="1",moves:r.kind==="jira"},`${j.id}:${(y==null?void 0:y.id)??""}`)]})}function tu({me:t,board:s,sprint:r,backlog:l,mine:i,moves:c,whole:d=!1}){const[u,p]=m.useState(null),[f,g]=m.useState([]),[j,y]=m.useState(!1),[k,N]=m.useState(null),[w,b]=m.useState(null),[$,R]=m.useState(0),[T,C]=m.useState(null),[E,O]=m.useState(null),F=m.useRef(),L=(V=!1)=>{clearTimeout(F.current),(d?Zt.boardItems(s.id,V):r&&!l?Zt.sprintItems(r.id,V):Zt.backlog(s.id,V)).then(le=>{p(le),N(null),b(null)},le=>u?b(le.message):N(le instanceof ss?"This board or sprint is not one you can see.":le.message)).finally(()=>{F.current=setTimeout(()=>L(),M0)})};if(m.useEffect(()=>(L(),()=>clearTimeout(F.current)),[]),k)return e.jsx(ve,{what:"the issues",reason:k,onRetry:()=>L(!0),panel:!0});if(!u)return e.jsx(fe,{what:"the issues",panel:!0});const W=V=>g(f.includes(V)?f.filter(le=>le!==V):[...f,V]),A=f.length>=L0,M=V=>e.jsx(z0,{item:V,me:t,picked:f.includes(V.key),canPick:!A||f.includes(V.key),onPick:()=>W(V.key),chosen:T===V.key,onChoose:()=>C(V.key)},V.key),Q=u.items.find(V=>V.key===T)??null,H=e.jsx("aside",{className:"rail","aria-label":"The picked issue",children:Q?e.jsx(W0,{item:Q,me:t,onStart:()=>{g([Q.key]),y(!0)}}):e.jsxs("section",{children:[e.jsx("h2",{children:"No issue picked"}),e.jsx("p",{className:"muted",children:"Press an issue to read it here and start an agent on it."})]})}),U=i?u.items.filter(V=>Io(V,t)):u.items,ie=e.jsxs("div",{className:"segmented wide",role:"group","aria-label":"Whose work",children:[e.jsxs("button",{type:"button",className:"secondary","aria-pressed":!i,onClick:()=>Va({mine:null}),children:["All issues ",e.jsx("span",{className:"count",children:u.items.length})]}),e.jsxs("button",{type:"button",className:"secondary","aria-pressed":i,onClick:()=>Va({mine:"1"}),children:["My work ",e.jsx("span",{className:"count",children:u.items.filter(V=>Io(V,t)).length})]})]}),X=f.length?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",A?", as many as start at once":""]}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",onClick:()=>y(!0),disabled:j,children:"Start agents"}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>{g([]),y(!1)},children:"Clear"})]})]}):null,J=j?e.jsx(F0,{local:t.mode==="local",items:u.items.filter(V=>f.includes(V.key)),onStarted:()=>L(),onCancel:()=>{y(!1),g([])}}):null,Z=e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"muted small read-at",role:"status",children:["Read from the tracker at ",u.fetchedAt.slice(11,16)," UTC",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]}),w?e.jsx(Oo,{what:"issues",reason:w,onRetry:()=>L(!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:[Z,J,e.jsxs("section",{className:"panel","aria-labelledby":"backlog-h",children:[e.jsxs("h2",{id:"backlog-h",children:["Waiting ",e.jsx("span",{className:"count",children:U.length})]}),ie,U.length?e.jsx("ul",{className:"plain cards backlog-list",children:U.map(M)}):e.jsx("p",{className:"muted",children:i?"Nothing waiting is assigned to you or started by you.":"Nothing is waiting outside a sprint."})]}),X]});const ae=qg(u),z=Bg(u,t),P=T0(u.columns,U),_=Math.min($,P.length-1);return e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"work-progress","aria-label":"Sprint progress",children:[e.jsx("p",{children:G0(u,ae)}),e.jsx("ol",{className:"progress-line","aria-hidden":"true",children:["done","doing","todo"].map(V=>u.progress[V]?e.jsx("li",{className:`progress-${V}`,style:{flexGrow:u.progress[V]}},V):null)}),z?e.jsxs("p",{children:["Next up: ",e.jsxs("button",{type:"button",className:"link",onClick:()=>C(z.key),children:[e.jsx("span",{className:"mono",children:z.key})," ",z.summary]})]}):null,e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",className:"secondary small",onClick:()=>{navigator.clipboard.writeText(E0((r==null?void 0:r.name)??s.name,u,t)).then(()=>O("The morning summary is copied; paste it where your team reads it."),()=>O("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:()=>L(!0),children:"Read the tracker again"})]}),E?e.jsx("p",{role:"status",className:"muted small",children:E}):null]}),c?e.jsx(A0,{board:s,columns:u.columns}):null,s.id.startsWith("mcp:")?e.jsx(O0,{board:s.id,columns:u.columns,onSaved:()=>L(!0)},u.columns.map(V=>V.name).join("|")):null,Z,J,ie,i&&!U.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:P.map((V,le)=>e.jsxs("button",{type:"button",className:"secondary","aria-pressed":le===_,onClick:()=>R(le),children:[V.name,e.jsx("span",{className:"visually-hidden",children:" column,"})," ",e.jsx("span",{className:"count",children:V.items.length})]},V.name))}),e.jsxs("div",{className:"with-rail",children:[e.jsx("div",{className:"board",role:"group","aria-label":`${(r==null?void 0:r.name)??s.name} board`,children:P.map((V,le)=>e.jsxs("section",{className:`board-col${le===_?" chosen":""}`,"aria-labelledby":`col-${le}`,children:[e.jsxs("h2",{id:`col-${le}`,children:[V.name," ",e.jsx("span",{className:"count",children:V.items.length}),Zp(V.items)?e.jsxs("span",{className:"muted small",children:[", ",Zp(V.items)," points"]}):null]}),e.jsx("ul",{className:"plain cards",children:V.items.map(M)})]},V.name))}),H]}),X]})}function Wg(t){var s;return[t.type,t.priority?`${t.priority} priority`:null,t.storyPoints!==null?`${t.storyPoints} ${t.storyPoints===1?"point":"points"}`:null,((s=t.assignee)==null?void 0:s.name)??"Unassigned"].filter(Boolean).join(", ")}function z0({item:t,me:s,picked:r,canPick:l,onPick:i,chosen:c,onChoose:d}){const u=t.tasks[0],p=u?Au(u):null;return e.jsxs("li",{className:`work-card${r?" 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:r,disabled:!l,onChange:i,"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})," ",Wg(t)]}),t.blocked?e.jsxs("p",{className:"small",children:[e.jsx("span",{className:"state warn",children:"Blocked"})," waiting on something else"]}):null,u&&p?e.jsxs("p",{className:"work-card-agent small",children:[e.jsx("a",{className:`state ${p.tone}`,href:ce("tasks",u.taskId),children:p.label}),u.requests.map(f=>e.jsxs("a",{href:f.url??ce("tasks",u.taskId),...f.url?{target:"_blank",rel:"noopener noreferrer"}:{},children:[" ",f.name]},`${f.repoId}#${f.number}`)),e.jsxs("span",{className:"muted",children:[" started by ",u.startedBy===s.email?"you":u.startedBy,t.tasks.length>1?`, ${t.tasks.length-1} earlier`:""]})]}):null]})}function W0({item:t,me:s,onStart:r}){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:[Wg(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(l=>e.jsxs("li",{children:[e.jsx("a",{className:`state ${Au(l).tone}`,href:ce("tasks",l.taskId),children:Au(l).label}),l.reason?e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{className:"error",children:l.reason})]}):null," ",e.jsxs("span",{className:"muted",children:["started by ",l.startedBy===s.email?"you":l.startedBy]})]},l.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:r,children:"Start an agent"}),e.jsx("a",{className:"button ghost",href:t.url,target:"_blank",rel:"noopener noreferrer",children:"Open the issue"})]})})]})}function H0(t,s){const r=s.endsAt?Date.parse(s.endsAt):NaN,l=Number.isNaN(r)?null:Math.ceil((r-Date.now())/864e5),i=[t,l===null?null:l>0?`${l} ${l===1?"day":"days"} left`:"ended"].filter(Boolean).join(", ");return[i?`${i}.`:null,s.goal?`Goal: ${s.goal}.`:null].filter(Boolean).join(" ")||null}function Zp(t){const s=t.filter(r=>r.storyPoints!==null);return s.length?s.reduce((r,l)=>r+(l.storyPoints??0),0):null}function G0(t,s){const r=t.progress,l=t.items.filter(c=>c.tasks.length).length,i=s.costUsd===null?"":` for ${_0(s.costUsd)}${s.costPartial?", some unreported":""}`;return[`${r.done} of ${s.total} done, ${r.doing} in progress, ${r.todo} to do${r.points?`; ${r.points.done} of ${r.points.total} points done`:""}.`,l?`Agents worked on ${l} ${l===1?"issue":"issues"}${i}${s.openRequests?`, ${s.openRequests} in review${s.reviewOn?` on ${s.reviewOn}`:""}`:""}.`:"No agent has worked on these yet.",s.blocked?`${s.blocked} flagged.`:""].filter(Boolean).join(" ")}const K0=["signed up","created an organization","connected a forge","started a first task","merged a first request"],V0={google:"Google",github:"GitHub",microsoft:"Microsoft"},ef=t=>t.slice(0,10);function Y0(){const[t,s]=m.useState(30),[r,l]=m.useState(null),[i,c]=m.useState(null),[d,u]=m.useState(!1),p=()=>{c(null),l(null),rt.operatorFunnel(t).then(l,g=>g instanceof ss?u(!0):c(g.message))};if(m.useEffect(p,[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=>!r||g<=r.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=>s(Number(g)),options:f.map(g=>({value:String(g),label:`${g} days`}))}),i?e.jsx(ve,{what:"the signups",reason:i,onRetry:p,panel:!0}):r?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:K0.map(g=>e.jsxs("div",{children:[e.jsx("dt",{children:g}),e.jsx("dd",{children:r.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:r.people.length})]}),r.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:r.people.map(g=>e.jsxs("tr",{children:[e.jsx("td",{children:ef(g.signedUpAt)}),e.jsx("td",{children:V0[g.provider]??g.provider}),e.jsx("td",{children:g.emailDomain}),e.jsx("td",{children:g.orgCreated?`/${g.orgCreated.tenant}, created ${ef(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 ",r.days," days."]})]})]}):e.jsx(fe,{what:"the signups",panel:!0})]})}function tf({repo:t,me:s,error:r,onSynced:l}){const[i,c]=m.useState(!1),[d,u]=m.useState(null),p=()=>{c(!0),u(null),Ne.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."," ",r]}),Xr(s,t.team)?e.jsxs("div",{className:"actions",children:[e.jsx("button",{type:"button",onClick:p,disabled:i,children:i?"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 Q0({repo:t,me:s,onDisconnected:r}){const[l,i]=m.useState(!1),[c,d]=m.useState(!1),[u,p]=m.useState(null),f=()=>{d(!0),p(null),Ne.disconnect(t.id).then(()=>{Ue(ce("tasks")),r()},g=>{p(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(Ee,{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."})]}),Ie(s)?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:()=>i(!1),disabled:c,children:"Cancel"})]})]}):e.jsx("div",{className:"actions",children:e.jsx("button",{type:"button",className:"secondary",onClick:()=>i(!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 Hg=[{id:"overview",label:"Overview"},{id:"skills",label:"Skills"},{id:"mcp",label:"MCP servers"},{id:"commands",label:"Commands"},{id:"requests",label:`${Ju.request.term}s`},{id:"settings",label:"Settings"}],nf=(t,s)=>s==="overview"?ce("repositories",t):ce("repositories",t,s);function J0({repoId:t,tab:s,me:r,known:l,onSynced:i}){var ae;const[c,d]=m.useState(null),[u,p]=m.useState(null),[f,g]=m.useState(void 0),[j,y]=m.useState(null),[k,N]=m.useState(null),[w,b]=m.useState(0),[$,R]=m.useState(null),T=m.useRef(t);T.current=t;const C=z=>P=>{T.current===t&&z(P)},[E,O]=m.useState(null),[F,L]=m.useState(0);m.useEffect(()=>{l!=null&&l.head||Je.list().then(({projects:z,home:P})=>{const _=z.find(V=>V.id===t);T.current===t&&O(_!=null&&_.facts&&(_.facts.git==="none"||_.facts.empty)?{project:_,home:P??null}:null)},()=>{})},[t,l==null?void 0:l.head,F]);const W=()=>{Ne.usage(t).then(C(y),C(()=>y(null))),b(z=>z+1)},A=()=>{p(null),Ne.inventory(t).then(C(d),C(z=>p(z.message))),Ne.overlaps(t).then(C(z=>N(z.overlaps)),C(()=>N(null))),W()},M=()=>void i().then(A);m.useEffect(()=>{d(null),O(null),N(null),p(null),g(void 0),R(null),A()},[t]);const Q=!E&&!!(u&&l&&!l.head&&!l.error);if(m.useEffect(()=>{if(!Q)return;const z=setTimeout(M,2e3);return()=>clearTimeout(z)},[Q,u]),E&&!c)return e.jsx(X0,{project:E.project,home:E.home,me:r,onChanged:()=>{L(z=>z+1),i()}});if(Q)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(tf,{repo:l,me:r,error:u,onSynced:M}):e.jsx(ve,{what:t,reason:u,onRetry:A,panel:!0});if(!c)return e.jsx(fe,{what:t,panel:!0});const{repo:H,inventory:U}=c,ie=H.configured!==!1,X=ie&&Xr(r,H.team),Z={repo:H,data:c,me:r,editable:X,usage:j,overlaps:k,onChanged:A,onOpened:(z,P)=>{R(P??Qu(z)),W()},selected:f,onSelect:g,requestsRead:w};return e.jsxs("div",{className:"repo",children:[e.jsxs("header",{className:"repo-head",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:H.team}),e.jsx("h1",{children:H.name}),e.jsx("p",{className:"muted mono",children:H.url})]}),e.jsxs("dl",{className:"facts",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Updates"}),e.jsx("dd",{children:U.plugin.versionedByCommit?"every merge":`version ${U.plugin.version}`})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Latest commit"}),e.jsx("dd",{className:"mono",children:U.head.slice(0,7)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Synced"}),e.jsx("dd",{children:((ae=H.syncedAt)==null?void 0:ae.slice(0,16).replace("T"," "))??"never"})]})]})]}),ie?H.error?e.jsx(tf,{repo:H,me:r,error:H.error,onSynced:M}):null:e.jsx(Q0,{repo:H,me:r,onDisconnected:i}),$?e.jsx("p",{className:"panel notice",role:"status",children:$}):null,X?null:e.jsxs("p",{className:"muted",children:["An admin or an owner of ",H.team," proposes changes here."]}),e.jsx(Fo,{label:`${H.name} sections`,current:nf(t,s),links:Hg.map(z=>({to:nf(t,z.id),label:z.label}))}),s==="overview"?e.jsx(zN,{...Z}):null,s==="skills"?e.jsx(VN,{...Z}):null,s==="mcp"?e.jsx(DN,{...Z}):null,s==="commands"?e.jsx(MN,{...Z}):null,s==="requests"?e.jsx(KN,{...Z}):null,s==="settings"?e.jsx(Pb,{...Z,onRenamed:M}):null,s==="skills"||s==="mcp"||s==="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(_N,{repoId:t,path:f,head:U.head})]}):null]})}function sf(t){var s;return t.length===1?"overview":t.length!==2?null:((s=Hg.find(r=>r.id===t[1]&&r.id!=="overview"))==null?void 0:s.id)??null}function X0({project:t,home:s,me:r,onChanged:l}){var i;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:wf(t,s)})]})}),e.jsx(xg,{repo:t,me:r,git:((i=t.facts)==null?void 0:i.git)??null,onChanged:l}),e.jsx(Zu,{project:t.id,canChange:Ie(r)})]})}function vo({children:t}){return e.jsx("main",{className:"gate",children:t})}function Z0(){var Q,H;const t=tl(),[s,r]=m.useState(null),[l,i]=m.useState(null),[c,d]=m.useState(null),[u,p]=m.useState(null),[f,g]=m.useState(null),[j,y]=m.useState(null),[k,N]=m.useState(null),[w,b]=m.useState(void 0),[$,R]=m.useState(!1),T=Ds(t.pathname),C=!!w&&/^\/signup(\/|$)/.test(t.pathname),E=!!w&&/^\/operator\/?$/.test(t.pathname),O=()=>Ne.repos().then(g,U=>N(U.message)),F=()=>{const U=Ds(window.location.pathname).org;if(N(null),p(null),!(w===void 0||C||E)&&!(w&&/^#\/join\//.test(window.location.hash))){if(w&&!U){rt.me().then(ie=>{const X=ie.memberships.find(J=>J.reachable);Ue(X?we(X.tenant,"tasks"):"/signup/organization",!0)},()=>Ue("/signup",!0));return}Ne.orgs().then(ie=>{d(ie),Mj(ie?U:null,(ie==null?void 0:ie.default)??null),Ya.me().then(X=>{r(X),i(null),O(),Zt.sources().then(J=>y(J.sources),()=>y([]))},X=>{r(null),X instanceof Gr&&w?rt.me().then(()=>p(U),()=>Ue("/signup",!0)):X instanceof Gr?Ya.config().then(i,J=>N(J.message)):X instanceof ss&&U?p(U):N(X.message)})},ie=>N(ie.message))}};m.useEffect(()=>{rt.config().then(U=>{R((U==null?void 0:U.mode)==="local"),b((U==null?void 0:U.mode)==="local"?null:U)},()=>b(null))},[]),m.useEffect(F,[T.org,w,C]),m.useEffect(()=>(document.addEventListener("click",zm),()=>document.removeEventListener("click",zm)),[]);const L=(Q=t.hash.match(/^#\/join\/([\w-]+)$/))==null?void 0:Q[1];if(m.useEffect(()=>{var J;if(!s||!c||L)return;const U=T.org??c.default??((J=c.orgs[0])==null?void 0:J.tenant);if(!U)return Ue("/signup/organization",!0);const ie=window.location.hash.startsWith("#/")?ay(window.location.hash,U):null,X=T.org?ry(T.org,T.section,T.rest):null;ie?Ue(ie,!0):T.org?X?Ue(`${X}${t.search}`,!0):!T.section&&!T.named&&Ue(we(U,"tasks"),!0):Ue(sy(t.search,U),!0)},[s,c,t.pathname,t.hash]),C)return e.jsx(cv,{config:w});if(E)return e.jsx(Y0,{});if(L)return e.jsx(Lb,{token:L,onJoined:F,cloud:w});if(t.hash===jg)return e.jsx(Bb,{});if(u){const U=(c==null?void 0:c.default)??((H=c==null?void 0:c.orgs.find(ie=>ie.tenant!==u))==null?void 0:H.tenant);return e.jsx(vo,{children:e.jsxs("div",{className:"panel form",role:"alert",children:[e.jsxs("div",{className:"brand",children:["TeamHandbook ",e.jsx("span",{children:"Orchestrator"})]}),e.jsxs("p",{children:["You are not a member of ",u,"."]}),U?e.jsx("p",{children:e.jsxs("a",{href:we(U,T.section??"tasks"),children:["Go to ",U]})}):null]})})}if(!s)return $&&l?e.jsx(vo,{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(hv,{onSignedIn:F}):l?e.jsx(dv,{config:l,org:T.org!==(c==null?void 0:c.default)?T.org:null,onSignedIn:F}):e.jsx(vo,{children:k?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:k}),e.jsx("button",{type:"button",onClick:F,children:"Retry connecting"})]}):e.jsx("p",{className:"muted",children:"Loading the orchestrator…"})});if(!c||!T.org||!T.section&&!T.named)return e.jsx(vo,{children:k?e.jsxs("div",{className:"panel",role:"alert",children:[e.jsx("p",{className:"error",children:k}),e.jsx("button",{type:"button",onClick:F,children:"Retry connecting"})]}):e.jsx("p",{className:"muted",children:"Loading the orchestrator…"})});const W=T.org,[A]=T.rest,M=c.orgs.some(U=>U.tenant===W)?c.orgs:[...c.orgs,{tenant:W,name:W,role:s.role}];return e.jsxs(Zy,{me:s,orgs:M,org:W,section:T.section,repos:f??[],onSignedOut:F,children:[k?e.jsxs("div",{className:"panel",role:"alert",children:[e.jsx("p",{className:"error",children:k}),e.jsx("button",{type:"button",className:"secondary",onClick:F,children:"Retry the organization"})]}):null,e.jsxs(JN,{path:t.pathname,home:we(W,"tasks"),children:[T.section?null:e.jsx(_r,{org:W,path:t.pathname}),T.section==="activity"?e.jsx(nv,{me:s,repos:f,page:A,entry:T.rest[1]}):null,T.section==="work"?A==="new"&&T.rest.length===1?e.jsx(eu,{me:s,start:Gp(t.search)}):A&&A!=="backlog"||T.rest.length>1?e.jsx(_r,{org:W,path:t.pathname}):e.jsx(D0,{me:s,sources:j,backlog:A==="backlog"}):null,T.section==="repositories"&&A?sf(T.rest)?e.jsx(J0,{repoId:A,tab:sf(T.rest),me:s,known:f==null?void 0:f.find(U=>U.id===A),onSynced:O}):e.jsx(_r,{org:W,path:t.pathname}):null,T.section==="tasks"?A==="new"?e.jsx(eu,{me:s,start:Gp(t.search),repos:f,onRepos:O}):A?e.jsx(w0,{id:A,me:s}):e.jsx(eu,{me:s,repos:f,picked:new URLSearchParams(t.search).get("repo"),onRepos:O}):null,T.section==="team"?e.jsx(qw,{me:s,org:W,repos:f,page:T.rest}):null,T.section==="integrations"?e.jsx(hb,{me:s,repos:f??[]}):null,T.section==="settings"?e.jsx(FN,{me:s,route:`/settings/${T.rest.join("/")}`,onLeft:F}):null,T.section==="welcome"?T.rest.length?e.jsx(_r,{org:W,path:t.pathname}):e.jsx(Rg,{me:s,org:W,repos:f??[],onRepos:O}):null]})]})}yf(To(jf));Fj.createRoot(document.getElementById("root")).render(e.jsx(m.StrictMode,{children:e.jsx(Z0,{})}));
|