teamtrail 0.52.1 → 0.53.1
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/README.md +33 -105
- package/dist/app/assets/index-CLAgl0xP.js +167 -0
- package/dist/app/assets/index-DLI0rMGs.css +1 -0
- package/dist/app/index.html +2 -2
- package/dist/cli.js +10 -10
- package/package.json +1 -1
- package/dist/app/assets/index-B8Bp4gma.js +0 -167
- package/dist/app/assets/index-CCvfI-Yv.css +0 -1
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
var gw=Object.defineProperty;var vw=(e,t,n)=>t in e?gw(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var le=(e,t,n)=>vw(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))o(a);new MutationObserver(a=>{for(const l of a)if(l.type==="childList")for(const d of l.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&o(d)}).observe(document,{childList:!0,subtree:!0});function n(a){const l={};return a.integrity&&(l.integrity=a.integrity),a.referrerPolicy&&(l.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?l.credentials="include":a.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function o(a){if(a.ep)return;a.ep=!0;const l=n(a);fetch(a.href,l)}})();var xc={exports:{}},qi={},jc={exports:{}},xe={};/**
|
|
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 Gf;function kw(){if(Gf)return xe;Gf=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),d=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),k=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=k&&T[k]||T["@@iterator"],typeof T=="function"?T:null)}var j={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,S={};function I(T,P,de){this.props=T,this.context=P,this.refs=S,this.updater=de||j}I.prototype.isReactComponent={},I.prototype.setState=function(T,P){if(typeof T!="object"&&typeof T!="function"&&T!=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,T,P,"setState")},I.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function $(){}$.prototype=I.prototype;function _(T,P,de){this.props=T,this.context=P,this.refs=S,this.updater=de||j}var O=_.prototype=new $;O.constructor=_,N(O,I.prototype),O.isPureReactComponent=!0;var D=Array.isArray,q=Object.prototype.hasOwnProperty,H={current:null},G={key:!0,ref:!0,__self:!0,__source:!0};function oe(T,P,de){var me,we={},je=null,ge=null;if(P!=null)for(me in P.ref!==void 0&&(ge=P.ref),P.key!==void 0&&(je=""+P.key),P)q.call(P,me)&&!G.hasOwnProperty(me)&&(we[me]=P[me]);var Se=arguments.length-2;if(Se===1)we.children=de;else if(1<Se){for(var ve=Array(Se),Fe=0;Fe<Se;Fe++)ve[Fe]=arguments[Fe+2];we.children=ve}if(T&&T.defaultProps)for(me in Se=T.defaultProps,Se)we[me]===void 0&&(we[me]=Se[me]);return{$$typeof:e,type:T,key:je,ref:ge,props:we,_owner:H.current}}function Q(T,P){return{$$typeof:e,type:T.type,key:P,ref:T.ref,props:T.props,_owner:T._owner}}function ke(T){return typeof T=="object"&&T!==null&&T.$$typeof===e}function Oe(T){var P={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(de){return P[de]})}var Te=/\/+/g;function ne(T,P){return typeof T=="object"&&T!==null&&T.key!=null?Oe(""+T.key):P.toString(36)}function ce(T,P,de,me,we){var je=typeof T;(je==="undefined"||je==="boolean")&&(T=null);var ge=!1;if(T===null)ge=!0;else switch(je){case"string":case"number":ge=!0;break;case"object":switch(T.$$typeof){case e:case t:ge=!0}}if(ge)return ge=T,we=we(ge),T=me===""?"."+ne(ge,0):me,D(we)?(de="",T!=null&&(de=T.replace(Te,"$&/")+"/"),ce(we,P,de,"",function(Fe){return Fe})):we!=null&&(ke(we)&&(we=Q(we,de+(!we.key||ge&&ge.key===we.key?"":(""+we.key).replace(Te,"$&/")+"/")+T)),P.push(we)),1;if(ge=0,me=me===""?".":me+":",D(T))for(var Se=0;Se<T.length;Se++){je=T[Se];var ve=me+ne(je,Se);ge+=ce(je,P,de,ve,we)}else if(ve=w(T),typeof ve=="function")for(T=ve.call(T),Se=0;!(je=T.next()).done;)je=je.value,ve=me+ne(je,Se++),ge+=ce(je,P,de,ve,we);else if(je==="object")throw P=String(T),Error("Objects are not valid as a React child (found: "+(P==="[object Object]"?"object with keys {"+Object.keys(T).join(", ")+"}":P)+"). If you meant to render a collection of children, use an array instead.");return ge}function F(T,P,de){if(T==null)return T;var me=[],we=0;return ce(T,me,"","",function(je){return P.call(de,je,we++)}),me}function J(T){if(T._status===-1){var P=T._result;P=P(),P.then(function(de){(T._status===0||T._status===-1)&&(T._status=1,T._result=de)},function(de){(T._status===0||T._status===-1)&&(T._status=2,T._result=de)}),T._status===-1&&(T._status=0,T._result=P)}if(T._status===1)return T._result.default;throw T._result}var ie={current:null},W={transition:null},X={ReactCurrentDispatcher:ie,ReactCurrentBatchConfig:W,ReactCurrentOwner:H};function z(){throw Error("act(...) is not supported in production builds of React.")}return xe.Children={map:F,forEach:function(T,P,de){F(T,function(){P.apply(this,arguments)},de)},count:function(T){var P=0;return F(T,function(){P++}),P},toArray:function(T){return F(T,function(P){return P})||[]},only:function(T){if(!ke(T))throw Error("React.Children.only expected to receive a single React element child.");return T}},xe.Component=I,xe.Fragment=n,xe.Profiler=a,xe.PureComponent=_,xe.StrictMode=o,xe.Suspense=f,xe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=X,xe.act=z,xe.cloneElement=function(T,P,de){if(T==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+T+".");var me=N({},T.props),we=T.key,je=T.ref,ge=T._owner;if(P!=null){if(P.ref!==void 0&&(je=P.ref,ge=H.current),P.key!==void 0&&(we=""+P.key),T.type&&T.type.defaultProps)var Se=T.type.defaultProps;for(ve in P)q.call(P,ve)&&!G.hasOwnProperty(ve)&&(me[ve]=P[ve]===void 0&&Se!==void 0?Se[ve]:P[ve])}var ve=arguments.length-2;if(ve===1)me.children=de;else if(1<ve){Se=Array(ve);for(var Fe=0;Fe<ve;Fe++)Se[Fe]=arguments[Fe+2];me.children=Se}return{$$typeof:e,type:T.type,key:we,ref:je,props:me,_owner:ge}},xe.createContext=function(T){return T={$$typeof:d,_currentValue:T,_currentValue2:T,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},T.Provider={$$typeof:l,_context:T},T.Consumer=T},xe.createElement=oe,xe.createFactory=function(T){var P=oe.bind(null,T);return P.type=T,P},xe.createRef=function(){return{current:null}},xe.forwardRef=function(T){return{$$typeof:h,render:T}},xe.isValidElement=ke,xe.lazy=function(T){return{$$typeof:v,_payload:{_status:-1,_result:T},_init:J}},xe.memo=function(T,P){return{$$typeof:p,type:T,compare:P===void 0?null:P}},xe.startTransition=function(T){var P=W.transition;W.transition={};try{T()}finally{W.transition=P}},xe.unstable_act=z,xe.useCallback=function(T,P){return ie.current.useCallback(T,P)},xe.useContext=function(T){return ie.current.useContext(T)},xe.useDebugValue=function(){},xe.useDeferredValue=function(T){return ie.current.useDeferredValue(T)},xe.useEffect=function(T,P){return ie.current.useEffect(T,P)},xe.useId=function(){return ie.current.useId()},xe.useImperativeHandle=function(T,P,de){return ie.current.useImperativeHandle(T,P,de)},xe.useInsertionEffect=function(T,P){return ie.current.useInsertionEffect(T,P)},xe.useLayoutEffect=function(T,P){return ie.current.useLayoutEffect(T,P)},xe.useMemo=function(T,P){return ie.current.useMemo(T,P)},xe.useReducer=function(T,P,de){return ie.current.useReducer(T,P,de)},xe.useRef=function(T){return ie.current.useRef(T)},xe.useState=function(T){return ie.current.useState(T)},xe.useSyncExternalStore=function(T,P,de){return ie.current.useSyncExternalStore(T,P,de)},xe.useTransition=function(){return ie.current.useTransition()},xe.version="18.3.1",xe}var qf;function xd(){return qf||(qf=1,jc.exports=kw()),jc.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 Qf;function yw(){if(Qf)return qi;Qf=1;var e=xd(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,a=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function d(h,f,p){var v,k={},w=null,j=null;p!==void 0&&(w=""+p),f.key!==void 0&&(w=""+f.key),f.ref!==void 0&&(j=f.ref);for(v in f)o.call(f,v)&&!l.hasOwnProperty(v)&&(k[v]=f[v]);if(h&&h.defaultProps)for(v in f=h.defaultProps,f)k[v]===void 0&&(k[v]=f[v]);return{$$typeof:t,type:h,key:w,ref:j,props:k,_owner:a.current}}return qi.Fragment=n,qi.jsx=d,qi.jsxs=d,qi}var Yf;function ww(){return Yf||(Yf=1,xc.exports=yw()),xc.exports}var i=ww(),No={},Sc={exports:{}},xt={},Nc={exports:{}},bc={};/**
|
|
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 Jf;function xw(){return Jf||(Jf=1,(function(e){function t(W,X){var z=W.length;W.push(X);e:for(;0<z;){var T=z-1>>>1,P=W[T];if(0<a(P,X))W[T]=X,W[z]=P,z=T;else break e}}function n(W){return W.length===0?null:W[0]}function o(W){if(W.length===0)return null;var X=W[0],z=W.pop();if(z!==X){W[0]=z;e:for(var T=0,P=W.length,de=P>>>1;T<de;){var me=2*(T+1)-1,we=W[me],je=me+1,ge=W[je];if(0>a(we,z))je<P&&0>a(ge,we)?(W[T]=ge,W[je]=z,T=je):(W[T]=we,W[me]=z,T=me);else if(je<P&&0>a(ge,z))W[T]=ge,W[je]=z,T=je;else break e}}return X}function a(W,X){var z=W.sortIndex-X.sortIndex;return z!==0?z:W.id-X.id}if(typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var d=Date,h=d.now();e.unstable_now=function(){return d.now()-h}}var f=[],p=[],v=1,k=null,w=3,j=!1,N=!1,S=!1,I=typeof setTimeout=="function"?setTimeout:null,$=typeof clearTimeout=="function"?clearTimeout:null,_=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function O(W){for(var X=n(p);X!==null;){if(X.callback===null)o(p);else if(X.startTime<=W)o(p),X.sortIndex=X.expirationTime,t(f,X);else break;X=n(p)}}function D(W){if(S=!1,O(W),!N)if(n(f)!==null)N=!0,J(q);else{var X=n(p);X!==null&&ie(D,X.startTime-W)}}function q(W,X){N=!1,S&&(S=!1,$(oe),oe=-1),j=!0;var z=w;try{for(O(X),k=n(f);k!==null&&(!(k.expirationTime>X)||W&&!Oe());){var T=k.callback;if(typeof T=="function"){k.callback=null,w=k.priorityLevel;var P=T(k.expirationTime<=X);X=e.unstable_now(),typeof P=="function"?k.callback=P:k===n(f)&&o(f),O(X)}else o(f);k=n(f)}if(k!==null)var de=!0;else{var me=n(p);me!==null&&ie(D,me.startTime-X),de=!1}return de}finally{k=null,w=z,j=!1}}var H=!1,G=null,oe=-1,Q=5,ke=-1;function Oe(){return!(e.unstable_now()-ke<Q)}function Te(){if(G!==null){var W=e.unstable_now();ke=W;var X=!0;try{X=G(!0,W)}finally{X?ne():(H=!1,G=null)}}else H=!1}var ne;if(typeof _=="function")ne=function(){_(Te)};else if(typeof MessageChannel<"u"){var ce=new MessageChannel,F=ce.port2;ce.port1.onmessage=Te,ne=function(){F.postMessage(null)}}else ne=function(){I(Te,0)};function J(W){G=W,H||(H=!0,ne())}function ie(W,X){oe=I(function(){W(e.unstable_now())},X)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(W){W.callback=null},e.unstable_continueExecution=function(){N||j||(N=!0,J(q))},e.unstable_forceFrameRate=function(W){0>W||125<W?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Q=0<W?Math.floor(1e3/W):5},e.unstable_getCurrentPriorityLevel=function(){return w},e.unstable_getFirstCallbackNode=function(){return n(f)},e.unstable_next=function(W){switch(w){case 1:case 2:case 3:var X=3;break;default:X=w}var z=w;w=X;try{return W()}finally{w=z}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(W,X){switch(W){case 1:case 2:case 3:case 4:case 5:break;default:W=3}var z=w;w=W;try{return X()}finally{w=z}},e.unstable_scheduleCallback=function(W,X,z){var T=e.unstable_now();switch(typeof z=="object"&&z!==null?(z=z.delay,z=typeof z=="number"&&0<z?T+z:T):z=T,W){case 1:var P=-1;break;case 2:P=250;break;case 5:P=1073741823;break;case 4:P=1e4;break;default:P=5e3}return P=z+P,W={id:v++,callback:X,priorityLevel:W,startTime:z,expirationTime:P,sortIndex:-1},z>T?(W.sortIndex=z,t(p,W),n(f)===null&&W===n(p)&&(S?($(oe),oe=-1):S=!0,ie(D,z-T))):(W.sortIndex=P,t(f,W),N||j||(N=!0,J(q))),W},e.unstable_shouldYield=Oe,e.unstable_wrapCallback=function(W){var X=w;return function(){var z=w;w=X;try{return W.apply(this,arguments)}finally{w=z}}}})(bc)),bc}var Xf;function jw(){return Xf||(Xf=1,Nc.exports=xw()),Nc.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 Zf;function Sw(){if(Zf)return xt;Zf=1;var e=xd(),t=jw();function n(s){for(var r="https://reactjs.org/docs/error-decoder.html?invariant="+s,c=1;c<arguments.length;c++)r+="&args[]="+encodeURIComponent(arguments[c]);return"Minified React error #"+s+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var o=new Set,a={};function l(s,r){d(s,r),d(s+"Capture",r)}function d(s,r){for(a[s]=r,s=0;s<r.length;s++)o.add(r[s])}var h=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),f=Object.prototype.hasOwnProperty,p=/^[: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]*$/,v={},k={};function w(s){return f.call(k,s)?!0:f.call(v,s)?!1:p.test(s)?k[s]=!0:(v[s]=!0,!1)}function j(s,r,c,u){if(c!==null&&c.type===0)return!1;switch(typeof r){case"function":case"symbol":return!0;case"boolean":return u?!1:c!==null?!c.acceptsBooleans:(s=s.toLowerCase().slice(0,5),s!=="data-"&&s!=="aria-");default:return!1}}function N(s,r,c,u){if(r===null||typeof r>"u"||j(s,r,c,u))return!0;if(u)return!1;if(c!==null)switch(c.type){case 3:return!r;case 4:return r===!1;case 5:return isNaN(r);case 6:return isNaN(r)||1>r}return!1}function S(s,r,c,u,m,g,x){this.acceptsBooleans=r===2||r===3||r===4,this.attributeName=u,this.attributeNamespace=m,this.mustUseProperty=c,this.propertyName=s,this.type=r,this.sanitizeURL=g,this.removeEmptyString=x}var I={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(s){I[s]=new S(s,0,!1,s,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(s){var r=s[0];I[r]=new S(r,1,!1,s[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(s){I[s]=new S(s,2,!1,s.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(s){I[s]=new S(s,2,!1,s,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(s){I[s]=new S(s,3,!1,s.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(s){I[s]=new S(s,3,!0,s,null,!1,!1)}),["capture","download"].forEach(function(s){I[s]=new S(s,4,!1,s,null,!1,!1)}),["cols","rows","size","span"].forEach(function(s){I[s]=new S(s,6,!1,s,null,!1,!1)}),["rowSpan","start"].forEach(function(s){I[s]=new S(s,5,!1,s.toLowerCase(),null,!1,!1)});var $=/[\-:]([a-z])/g;function _(s){return s[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(s){var r=s.replace($,_);I[r]=new S(r,1,!1,s,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(s){var r=s.replace($,_);I[r]=new S(r,1,!1,s,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(s){var r=s.replace($,_);I[r]=new S(r,1,!1,s,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(s){I[s]=new S(s,1,!1,s.toLowerCase(),null,!1,!1)}),I.xlinkHref=new S("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(s){I[s]=new S(s,1,!1,s.toLowerCase(),null,!0,!0)});function O(s,r,c,u){var m=I.hasOwnProperty(r)?I[r]:null;(m!==null?m.type!==0:u||!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(N(r,c,m,u)&&(c=null),u||m===null?w(r)&&(c===null?s.removeAttribute(r):s.setAttribute(r,""+c)):m.mustUseProperty?s[m.propertyName]=c===null?m.type===3?!1:"":c:(r=m.attributeName,u=m.attributeNamespace,c===null?s.removeAttribute(r):(m=m.type,c=m===3||m===4&&c===!0?"":""+c,u?s.setAttributeNS(u,r,c):s.setAttribute(r,c))))}var D=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,q=Symbol.for("react.element"),H=Symbol.for("react.portal"),G=Symbol.for("react.fragment"),oe=Symbol.for("react.strict_mode"),Q=Symbol.for("react.profiler"),ke=Symbol.for("react.provider"),Oe=Symbol.for("react.context"),Te=Symbol.for("react.forward_ref"),ne=Symbol.for("react.suspense"),ce=Symbol.for("react.suspense_list"),F=Symbol.for("react.memo"),J=Symbol.for("react.lazy"),ie=Symbol.for("react.offscreen"),W=Symbol.iterator;function X(s){return s===null||typeof s!="object"?null:(s=W&&s[W]||s["@@iterator"],typeof s=="function"?s:null)}var z=Object.assign,T;function P(s){if(T===void 0)try{throw Error()}catch(c){var r=c.stack.trim().match(/\n( *(at )?)/);T=r&&r[1]||""}return`
|
|
34
|
+
`+T+s}var de=!1;function me(s,r){if(!s||de)return"";de=!0;var c=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(r)if(r=function(){throw Error()},Object.defineProperty(r.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(r,[])}catch(L){var u=L}Reflect.construct(s,[],r)}else{try{r.call()}catch(L){u=L}s.call(r.prototype)}else{try{throw Error()}catch(L){u=L}s()}}catch(L){if(L&&u&&typeof L.stack=="string"){for(var m=L.stack.split(`
|
|
35
|
+
`),g=u.stack.split(`
|
|
36
|
+
`),x=m.length-1,b=g.length-1;1<=x&&0<=b&&m[x]!==g[b];)b--;for(;1<=x&&0<=b;x--,b--)if(m[x]!==g[b]){if(x!==1||b!==1)do if(x--,b--,0>b||m[x]!==g[b]){var C=`
|
|
37
|
+
`+m[x].replace(" at new "," at ");return s.displayName&&C.includes("<anonymous>")&&(C=C.replace("<anonymous>",s.displayName)),C}while(1<=x&&0<=b);break}}}finally{de=!1,Error.prepareStackTrace=c}return(s=s?s.displayName||s.name:"")?P(s):""}function we(s){switch(s.tag){case 5:return P(s.type);case 16:return P("Lazy");case 13:return P("Suspense");case 19:return P("SuspenseList");case 0:case 2:case 15:return s=me(s.type,!1),s;case 11:return s=me(s.type.render,!1),s;case 1:return s=me(s.type,!0),s;default:return""}}function je(s){if(s==null)return null;if(typeof s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case G:return"Fragment";case H:return"Portal";case Q:return"Profiler";case oe:return"StrictMode";case ne:return"Suspense";case ce:return"SuspenseList"}if(typeof s=="object")switch(s.$$typeof){case Oe:return(s.displayName||"Context")+".Consumer";case ke:return(s._context.displayName||"Context")+".Provider";case Te:var r=s.render;return s=s.displayName,s||(s=r.displayName||r.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case F:return r=s.displayName||null,r!==null?r:je(s.type)||"Memo";case J:r=s._payload,s=s._init;try{return je(s(r))}catch{}}return null}function ge(s){var r=s.type;switch(s.tag){case 24:return"Cache";case 9:return(r.displayName||"Context")+".Consumer";case 10:return(r._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return s=r.render,s=s.displayName||s.name||"",r.displayName||(s!==""?"ForwardRef("+s+")":"ForwardRef");case 7:return"Fragment";case 5:return r;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return je(r);case 8:return r===oe?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r}return null}function Se(s){switch(typeof s){case"boolean":case"number":case"string":case"undefined":return s;case"object":return s;default:return""}}function ve(s){var r=s.type;return(s=s.nodeName)&&s.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function Fe(s){var r=ve(s)?"checked":"value",c=Object.getOwnPropertyDescriptor(s.constructor.prototype,r),u=""+s[r];if(!s.hasOwnProperty(r)&&typeof c<"u"&&typeof c.get=="function"&&typeof c.set=="function"){var m=c.get,g=c.set;return Object.defineProperty(s,r,{configurable:!0,get:function(){return m.call(this)},set:function(x){u=""+x,g.call(this,x)}}),Object.defineProperty(s,r,{enumerable:c.enumerable}),{getValue:function(){return u},setValue:function(x){u=""+x},stopTracking:function(){s._valueTracker=null,delete s[r]}}}}function Cn(s){s._valueTracker||(s._valueTracker=Fe(s))}function mr(s){if(!s)return!1;var r=s._valueTracker;if(!r)return!0;var c=r.getValue(),u="";return s&&(u=ve(s)?s.checked?"true":"false":s.value),s=u,s!==c?(r.setValue(s),!0):!1}function ks(s){if(s=s||(typeof document<"u"?document:void 0),typeof s>"u")return null;try{return s.activeElement||s.body}catch{return s.body}}function Ta(s,r){var c=r.checked;return z({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:c??s._wrapperState.initialChecked})}function Zd(s,r){var c=r.defaultValue==null?"":r.defaultValue,u=r.checked!=null?r.checked:r.defaultChecked;c=Se(r.value!=null?r.value:c),s._wrapperState={initialChecked:u,initialValue:c,controlled:r.type==="checkbox"||r.type==="radio"?r.checked!=null:r.value!=null}}function eu(s,r){r=r.checked,r!=null&&O(s,"checked",r,!1)}function Ea(s,r){eu(s,r);var c=Se(r.value),u=r.type;if(c!=null)u==="number"?(c===0&&s.value===""||s.value!=c)&&(s.value=""+c):s.value!==""+c&&(s.value=""+c);else if(u==="submit"||u==="reset"){s.removeAttribute("value");return}r.hasOwnProperty("value")?Aa(s,r.type,c):r.hasOwnProperty("defaultValue")&&Aa(s,r.type,Se(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(s.defaultChecked=!!r.defaultChecked)}function tu(s,r,c){if(r.hasOwnProperty("value")||r.hasOwnProperty("defaultValue")){var u=r.type;if(!(u!=="submit"&&u!=="reset"||r.value!==void 0&&r.value!==null))return;r=""+s._wrapperState.initialValue,c||r===s.value||(s.value=r),s.defaultValue=r}c=s.name,c!==""&&(s.name=""),s.defaultChecked=!!s._wrapperState.initialChecked,c!==""&&(s.name=c)}function Aa(s,r,c){(r!=="number"||ks(s.ownerDocument)!==s)&&(c==null?s.defaultValue=""+s._wrapperState.initialValue:s.defaultValue!==""+c&&(s.defaultValue=""+c))}var ci=Array.isArray;function ys(s,r,c,u){if(s=s.options,r){r={};for(var m=0;m<c.length;m++)r["$"+c[m]]=!0;for(c=0;c<s.length;c++)m=r.hasOwnProperty("$"+s[c].value),s[c].selected!==m&&(s[c].selected=m),m&&u&&(s[c].defaultSelected=!0)}else{for(c=""+Se(c),r=null,m=0;m<s.length;m++){if(s[m].value===c){s[m].selected=!0,u&&(s[m].defaultSelected=!0);return}r!==null||s[m].disabled||(r=s[m])}r!==null&&(r.selected=!0)}}function Ia(s,r){if(r.dangerouslySetInnerHTML!=null)throw Error(n(91));return z({},r,{value:void 0,defaultValue:void 0,children:""+s._wrapperState.initialValue})}function nu(s,r){var c=r.value;if(c==null){if(c=r.children,r=r.defaultValue,c!=null){if(r!=null)throw Error(n(92));if(ci(c)){if(1<c.length)throw Error(n(93));c=c[0]}r=c}r==null&&(r=""),c=r}s._wrapperState={initialValue:Se(c)}}function su(s,r){var c=Se(r.value),u=Se(r.defaultValue);c!=null&&(c=""+c,c!==s.value&&(s.value=c),r.defaultValue==null&&s.defaultValue!==c&&(s.defaultValue=c)),u!=null&&(s.defaultValue=""+u)}function iu(s){var r=s.textContent;r===s._wrapperState.initialValue&&r!==""&&r!==null&&(s.value=r)}function ru(s){switch(s){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Ra(s,r){return s==null||s==="http://www.w3.org/1999/xhtml"?ru(r):s==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":s}var pr,ou=(function(s){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(r,c,u,m){MSApp.execUnsafeLocalFunction(function(){return s(r,c,u,m)})}:s})(function(s,r){if(s.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in s)s.innerHTML=r;else{for(pr=pr||document.createElement("div"),pr.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=pr.firstChild;s.firstChild;)s.removeChild(s.firstChild);for(;r.firstChild;)s.appendChild(r.firstChild)}});function di(s,r){if(r){var c=s.firstChild;if(c&&c===s.lastChild&&c.nodeType===3){c.nodeValue=r;return}}s.textContent=r}var ui={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},wk=["Webkit","ms","Moz","O"];Object.keys(ui).forEach(function(s){wk.forEach(function(r){r=r+s.charAt(0).toUpperCase()+s.substring(1),ui[r]=ui[s]})});function au(s,r,c){return r==null||typeof r=="boolean"||r===""?"":c||typeof r!="number"||r===0||ui.hasOwnProperty(s)&&ui[s]?(""+r).trim():r+"px"}function lu(s,r){s=s.style;for(var c in r)if(r.hasOwnProperty(c)){var u=c.indexOf("--")===0,m=au(c,r[c],u);c==="float"&&(c="cssFloat"),u?s.setProperty(c,m):s[c]=m}}var xk=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 Ma(s,r){if(r){if(xk[s]&&(r.children!=null||r.dangerouslySetInnerHTML!=null))throw Error(n(137,s));if(r.dangerouslySetInnerHTML!=null){if(r.children!=null)throw Error(n(60));if(typeof r.dangerouslySetInnerHTML!="object"||!("__html"in r.dangerouslySetInnerHTML))throw Error(n(61))}if(r.style!=null&&typeof r.style!="object")throw Error(n(62))}}function La(s,r){if(s.indexOf("-")===-1)return typeof r.is=="string";switch(s){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Oa=null;function Pa(s){return s=s.target||s.srcElement||window,s.correspondingUseElement&&(s=s.correspondingUseElement),s.nodeType===3?s.parentNode:s}var _a=null,ws=null,xs=null;function cu(s){if(s=Mi(s)){if(typeof _a!="function")throw Error(n(280));var r=s.stateNode;r&&(r=Dr(r),_a(s.stateNode,s.type,r))}}function du(s){ws?xs?xs.push(s):xs=[s]:ws=s}function uu(){if(ws){var s=ws,r=xs;if(xs=ws=null,cu(s),r)for(s=0;s<r.length;s++)cu(r[s])}}function hu(s,r){return s(r)}function fu(){}var Da=!1;function mu(s,r,c){if(Da)return s(r,c);Da=!0;try{return hu(s,r,c)}finally{Da=!1,(ws!==null||xs!==null)&&(fu(),uu())}}function hi(s,r){var c=s.stateNode;if(c===null)return null;var u=Dr(c);if(u===null)return null;c=u[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(u=!u.disabled)||(s=s.type,u=!(s==="button"||s==="input"||s==="select"||s==="textarea")),s=!u;break e;default:s=!1}if(s)return null;if(c&&typeof c!="function")throw Error(n(231,r,typeof c));return c}var za=!1;if(h)try{var fi={};Object.defineProperty(fi,"passive",{get:function(){za=!0}}),window.addEventListener("test",fi,fi),window.removeEventListener("test",fi,fi)}catch{za=!1}function jk(s,r,c,u,m,g,x,b,C){var L=Array.prototype.slice.call(arguments,3);try{r.apply(c,L)}catch(U){this.onError(U)}}var mi=!1,gr=null,vr=!1,Ba=null,Sk={onError:function(s){mi=!0,gr=s}};function Nk(s,r,c,u,m,g,x,b,C){mi=!1,gr=null,jk.apply(Sk,arguments)}function bk(s,r,c,u,m,g,x,b,C){if(Nk.apply(this,arguments),mi){if(mi){var L=gr;mi=!1,gr=null}else throw Error(n(198));vr||(vr=!0,Ba=L)}}function Xn(s){var r=s,c=s;if(s.alternate)for(;r.return;)r=r.return;else{s=r;do r=s,(r.flags&4098)!==0&&(c=r.return),s=r.return;while(s)}return r.tag===3?c:null}function pu(s){if(s.tag===13){var r=s.memoizedState;if(r===null&&(s=s.alternate,s!==null&&(r=s.memoizedState)),r!==null)return r.dehydrated}return null}function gu(s){if(Xn(s)!==s)throw Error(n(188))}function $k(s){var r=s.alternate;if(!r){if(r=Xn(s),r===null)throw Error(n(188));return r!==s?null:s}for(var c=s,u=r;;){var m=c.return;if(m===null)break;var g=m.alternate;if(g===null){if(u=m.return,u!==null){c=u;continue}break}if(m.child===g.child){for(g=m.child;g;){if(g===c)return gu(m),s;if(g===u)return gu(m),r;g=g.sibling}throw Error(n(188))}if(c.return!==u.return)c=m,u=g;else{for(var x=!1,b=m.child;b;){if(b===c){x=!0,c=m,u=g;break}if(b===u){x=!0,u=m,c=g;break}b=b.sibling}if(!x){for(b=g.child;b;){if(b===c){x=!0,c=g,u=m;break}if(b===u){x=!0,u=g,c=m;break}b=b.sibling}if(!x)throw Error(n(189))}}if(c.alternate!==u)throw Error(n(190))}if(c.tag!==3)throw Error(n(188));return c.stateNode.current===c?s:r}function vu(s){return s=$k(s),s!==null?ku(s):null}function ku(s){if(s.tag===5||s.tag===6)return s;for(s=s.child;s!==null;){var r=ku(s);if(r!==null)return r;s=s.sibling}return null}var yu=t.unstable_scheduleCallback,wu=t.unstable_cancelCallback,Ck=t.unstable_shouldYield,Tk=t.unstable_requestPaint,We=t.unstable_now,Ek=t.unstable_getCurrentPriorityLevel,Fa=t.unstable_ImmediatePriority,xu=t.unstable_UserBlockingPriority,kr=t.unstable_NormalPriority,Ak=t.unstable_LowPriority,ju=t.unstable_IdlePriority,yr=null,Zt=null;function Ik(s){if(Zt&&typeof Zt.onCommitFiberRoot=="function")try{Zt.onCommitFiberRoot(yr,s,void 0,(s.current.flags&128)===128)}catch{}}var Ft=Math.clz32?Math.clz32:Lk,Rk=Math.log,Mk=Math.LN2;function Lk(s){return s>>>=0,s===0?32:31-(Rk(s)/Mk|0)|0}var wr=64,xr=4194304;function pi(s){switch(s&-s){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return s&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return s&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return s}}function jr(s,r){var c=s.pendingLanes;if(c===0)return 0;var u=0,m=s.suspendedLanes,g=s.pingedLanes,x=c&268435455;if(x!==0){var b=x&~m;b!==0?u=pi(b):(g&=x,g!==0&&(u=pi(g)))}else x=c&~m,x!==0?u=pi(x):g!==0&&(u=pi(g));if(u===0)return 0;if(r!==0&&r!==u&&(r&m)===0&&(m=u&-u,g=r&-r,m>=g||m===16&&(g&4194240)!==0))return r;if((u&4)!==0&&(u|=c&16),r=s.entangledLanes,r!==0)for(s=s.entanglements,r&=u;0<r;)c=31-Ft(r),m=1<<c,u|=s[c],r&=~m;return u}function Ok(s,r){switch(s){case 1:case 2:case 4:return r+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Pk(s,r){for(var c=s.suspendedLanes,u=s.pingedLanes,m=s.expirationTimes,g=s.pendingLanes;0<g;){var x=31-Ft(g),b=1<<x,C=m[x];C===-1?((b&c)===0||(b&u)!==0)&&(m[x]=Ok(b,r)):C<=r&&(s.expiredLanes|=b),g&=~b}}function Ua(s){return s=s.pendingLanes&-1073741825,s!==0?s:s&1073741824?1073741824:0}function Su(){var s=wr;return wr<<=1,(wr&4194240)===0&&(wr=64),s}function Wa(s){for(var r=[],c=0;31>c;c++)r.push(s);return r}function gi(s,r,c){s.pendingLanes|=r,r!==536870912&&(s.suspendedLanes=0,s.pingedLanes=0),s=s.eventTimes,r=31-Ft(r),s[r]=c}function _k(s,r){var c=s.pendingLanes&~r;s.pendingLanes=r,s.suspendedLanes=0,s.pingedLanes=0,s.expiredLanes&=r,s.mutableReadLanes&=r,s.entangledLanes&=r,r=s.entanglements;var u=s.eventTimes;for(s=s.expirationTimes;0<c;){var m=31-Ft(c),g=1<<m;r[m]=0,u[m]=-1,s[m]=-1,c&=~g}}function Ha(s,r){var c=s.entangledLanes|=r;for(s=s.entanglements;c;){var u=31-Ft(c),m=1<<u;m&r|s[u]&r&&(s[u]|=r),c&=~m}}var Ce=0;function Nu(s){return s&=-s,1<s?4<s?(s&268435455)!==0?16:536870912:4:1}var bu,Ka,$u,Cu,Tu,Va=!1,Sr=[],Tn=null,En=null,An=null,vi=new Map,ki=new Map,In=[],Dk="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 Eu(s,r){switch(s){case"focusin":case"focusout":Tn=null;break;case"dragenter":case"dragleave":En=null;break;case"mouseover":case"mouseout":An=null;break;case"pointerover":case"pointerout":vi.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":ki.delete(r.pointerId)}}function yi(s,r,c,u,m,g){return s===null||s.nativeEvent!==g?(s={blockedOn:r,domEventName:c,eventSystemFlags:u,nativeEvent:g,targetContainers:[m]},r!==null&&(r=Mi(r),r!==null&&Ka(r)),s):(s.eventSystemFlags|=u,r=s.targetContainers,m!==null&&r.indexOf(m)===-1&&r.push(m),s)}function zk(s,r,c,u,m){switch(r){case"focusin":return Tn=yi(Tn,s,r,c,u,m),!0;case"dragenter":return En=yi(En,s,r,c,u,m),!0;case"mouseover":return An=yi(An,s,r,c,u,m),!0;case"pointerover":var g=m.pointerId;return vi.set(g,yi(vi.get(g)||null,s,r,c,u,m)),!0;case"gotpointercapture":return g=m.pointerId,ki.set(g,yi(ki.get(g)||null,s,r,c,u,m)),!0}return!1}function Au(s){var r=Zn(s.target);if(r!==null){var c=Xn(r);if(c!==null){if(r=c.tag,r===13){if(r=pu(c),r!==null){s.blockedOn=r,Tu(s.priority,function(){$u(c)});return}}else if(r===3&&c.stateNode.current.memoizedState.isDehydrated){s.blockedOn=c.tag===3?c.stateNode.containerInfo:null;return}}}s.blockedOn=null}function Nr(s){if(s.blockedOn!==null)return!1;for(var r=s.targetContainers;0<r.length;){var c=qa(s.domEventName,s.eventSystemFlags,r[0],s.nativeEvent);if(c===null){c=s.nativeEvent;var u=new c.constructor(c.type,c);Oa=u,c.target.dispatchEvent(u),Oa=null}else return r=Mi(c),r!==null&&Ka(r),s.blockedOn=c,!1;r.shift()}return!0}function Iu(s,r,c){Nr(s)&&c.delete(r)}function Bk(){Va=!1,Tn!==null&&Nr(Tn)&&(Tn=null),En!==null&&Nr(En)&&(En=null),An!==null&&Nr(An)&&(An=null),vi.forEach(Iu),ki.forEach(Iu)}function wi(s,r){s.blockedOn===r&&(s.blockedOn=null,Va||(Va=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Bk)))}function xi(s){function r(m){return wi(m,s)}if(0<Sr.length){wi(Sr[0],s);for(var c=1;c<Sr.length;c++){var u=Sr[c];u.blockedOn===s&&(u.blockedOn=null)}}for(Tn!==null&&wi(Tn,s),En!==null&&wi(En,s),An!==null&&wi(An,s),vi.forEach(r),ki.forEach(r),c=0;c<In.length;c++)u=In[c],u.blockedOn===s&&(u.blockedOn=null);for(;0<In.length&&(c=In[0],c.blockedOn===null);)Au(c),c.blockedOn===null&&In.shift()}var js=D.ReactCurrentBatchConfig,br=!0;function Fk(s,r,c,u){var m=Ce,g=js.transition;js.transition=null;try{Ce=1,Ga(s,r,c,u)}finally{Ce=m,js.transition=g}}function Uk(s,r,c,u){var m=Ce,g=js.transition;js.transition=null;try{Ce=4,Ga(s,r,c,u)}finally{Ce=m,js.transition=g}}function Ga(s,r,c,u){if(br){var m=qa(s,r,c,u);if(m===null)ul(s,r,u,$r,c),Eu(s,u);else if(zk(m,s,r,c,u))u.stopPropagation();else if(Eu(s,u),r&4&&-1<Dk.indexOf(s)){for(;m!==null;){var g=Mi(m);if(g!==null&&bu(g),g=qa(s,r,c,u),g===null&&ul(s,r,u,$r,c),g===m)break;m=g}m!==null&&u.stopPropagation()}else ul(s,r,u,null,c)}}var $r=null;function qa(s,r,c,u){if($r=null,s=Pa(u),s=Zn(s),s!==null)if(r=Xn(s),r===null)s=null;else if(c=r.tag,c===13){if(s=pu(r),s!==null)return s;s=null}else if(c===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;s=null}else r!==s&&(s=null);return $r=s,null}function Ru(s){switch(s){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Ek()){case Fa:return 1;case xu:return 4;case kr:case Ak:return 16;case ju:return 536870912;default:return 16}default:return 16}}var Rn=null,Qa=null,Cr=null;function Mu(){if(Cr)return Cr;var s,r=Qa,c=r.length,u,m="value"in Rn?Rn.value:Rn.textContent,g=m.length;for(s=0;s<c&&r[s]===m[s];s++);var x=c-s;for(u=1;u<=x&&r[c-u]===m[g-u];u++);return Cr=m.slice(s,1<u?1-u:void 0)}function Tr(s){var r=s.keyCode;return"charCode"in s?(s=s.charCode,s===0&&r===13&&(s=13)):s=r,s===10&&(s=13),32<=s||s===13?s:0}function Er(){return!0}function Lu(){return!1}function bt(s){function r(c,u,m,g,x){this._reactName=c,this._targetInst=m,this.type=u,this.nativeEvent=g,this.target=x,this.currentTarget=null;for(var b in s)s.hasOwnProperty(b)&&(c=s[b],this[b]=c?c(g):g[b]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?Er:Lu,this.isPropagationStopped=Lu,this}return z(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var c=this.nativeEvent;c&&(c.preventDefault?c.preventDefault():typeof c.returnValue!="unknown"&&(c.returnValue=!1),this.isDefaultPrevented=Er)},stopPropagation:function(){var c=this.nativeEvent;c&&(c.stopPropagation?c.stopPropagation():typeof c.cancelBubble!="unknown"&&(c.cancelBubble=!0),this.isPropagationStopped=Er)},persist:function(){},isPersistent:Er}),r}var Ss={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(s){return s.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ya=bt(Ss),ji=z({},Ss,{view:0,detail:0}),Wk=bt(ji),Ja,Xa,Si,Ar=z({},ji,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:el,button:0,buttons:0,relatedTarget:function(s){return s.relatedTarget===void 0?s.fromElement===s.srcElement?s.toElement:s.fromElement:s.relatedTarget},movementX:function(s){return"movementX"in s?s.movementX:(s!==Si&&(Si&&s.type==="mousemove"?(Ja=s.screenX-Si.screenX,Xa=s.screenY-Si.screenY):Xa=Ja=0,Si=s),Ja)},movementY:function(s){return"movementY"in s?s.movementY:Xa}}),Ou=bt(Ar),Hk=z({},Ar,{dataTransfer:0}),Kk=bt(Hk),Vk=z({},ji,{relatedTarget:0}),Za=bt(Vk),Gk=z({},Ss,{animationName:0,elapsedTime:0,pseudoElement:0}),qk=bt(Gk),Qk=z({},Ss,{clipboardData:function(s){return"clipboardData"in s?s.clipboardData:window.clipboardData}}),Yk=bt(Qk),Jk=z({},Ss,{data:0}),Pu=bt(Jk),Xk={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Zk={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"},ey={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function ty(s){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(s):(s=ey[s])?!!r[s]:!1}function el(){return ty}var ny=z({},ji,{key:function(s){if(s.key){var r=Xk[s.key]||s.key;if(r!=="Unidentified")return r}return s.type==="keypress"?(s=Tr(s),s===13?"Enter":String.fromCharCode(s)):s.type==="keydown"||s.type==="keyup"?Zk[s.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:el,charCode:function(s){return s.type==="keypress"?Tr(s):0},keyCode:function(s){return s.type==="keydown"||s.type==="keyup"?s.keyCode:0},which:function(s){return s.type==="keypress"?Tr(s):s.type==="keydown"||s.type==="keyup"?s.keyCode:0}}),sy=bt(ny),iy=z({},Ar,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),_u=bt(iy),ry=z({},ji,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:el}),oy=bt(ry),ay=z({},Ss,{propertyName:0,elapsedTime:0,pseudoElement:0}),ly=bt(ay),cy=z({},Ar,{deltaX:function(s){return"deltaX"in s?s.deltaX:"wheelDeltaX"in s?-s.wheelDeltaX:0},deltaY:function(s){return"deltaY"in s?s.deltaY:"wheelDeltaY"in s?-s.wheelDeltaY:"wheelDelta"in s?-s.wheelDelta:0},deltaZ:0,deltaMode:0}),dy=bt(cy),uy=[9,13,27,32],tl=h&&"CompositionEvent"in window,Ni=null;h&&"documentMode"in document&&(Ni=document.documentMode);var hy=h&&"TextEvent"in window&&!Ni,Du=h&&(!tl||Ni&&8<Ni&&11>=Ni),zu=" ",Bu=!1;function Fu(s,r){switch(s){case"keyup":return uy.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Uu(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var Ns=!1;function fy(s,r){switch(s){case"compositionend":return Uu(r);case"keypress":return r.which!==32?null:(Bu=!0,zu);case"textInput":return s=r.data,s===zu&&Bu?null:s;default:return null}}function my(s,r){if(Ns)return s==="compositionend"||!tl&&Fu(s,r)?(s=Mu(),Cr=Qa=Rn=null,Ns=!1,s):null;switch(s){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return Du&&r.locale!=="ko"?null:r.data;default:return null}}var py={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 Wu(s){var r=s&&s.nodeName&&s.nodeName.toLowerCase();return r==="input"?!!py[s.type]:r==="textarea"}function Hu(s,r,c,u){du(u),r=Or(r,"onChange"),0<r.length&&(c=new Ya("onChange","change",null,c,u),s.push({event:c,listeners:r}))}var bi=null,$i=null;function gy(s){lh(s,0)}function Ir(s){var r=Es(s);if(mr(r))return s}function vy(s,r){if(s==="change")return r}var Ku=!1;if(h){var nl;if(h){var sl="oninput"in document;if(!sl){var Vu=document.createElement("div");Vu.setAttribute("oninput","return;"),sl=typeof Vu.oninput=="function"}nl=sl}else nl=!1;Ku=nl&&(!document.documentMode||9<document.documentMode)}function Gu(){bi&&(bi.detachEvent("onpropertychange",qu),$i=bi=null)}function qu(s){if(s.propertyName==="value"&&Ir($i)){var r=[];Hu(r,$i,s,Pa(s)),mu(gy,r)}}function ky(s,r,c){s==="focusin"?(Gu(),bi=r,$i=c,bi.attachEvent("onpropertychange",qu)):s==="focusout"&&Gu()}function yy(s){if(s==="selectionchange"||s==="keyup"||s==="keydown")return Ir($i)}function wy(s,r){if(s==="click")return Ir(r)}function xy(s,r){if(s==="input"||s==="change")return Ir(r)}function jy(s,r){return s===r&&(s!==0||1/s===1/r)||s!==s&&r!==r}var Ut=typeof Object.is=="function"?Object.is:jy;function Ci(s,r){if(Ut(s,r))return!0;if(typeof s!="object"||s===null||typeof r!="object"||r===null)return!1;var c=Object.keys(s),u=Object.keys(r);if(c.length!==u.length)return!1;for(u=0;u<c.length;u++){var m=c[u];if(!f.call(r,m)||!Ut(s[m],r[m]))return!1}return!0}function Qu(s){for(;s&&s.firstChild;)s=s.firstChild;return s}function Yu(s,r){var c=Qu(s);s=0;for(var u;c;){if(c.nodeType===3){if(u=s+c.textContent.length,s<=r&&u>=r)return{node:c,offset:r-s};s=u}e:{for(;c;){if(c.nextSibling){c=c.nextSibling;break e}c=c.parentNode}c=void 0}c=Qu(c)}}function Ju(s,r){return s&&r?s===r?!0:s&&s.nodeType===3?!1:r&&r.nodeType===3?Ju(s,r.parentNode):"contains"in s?s.contains(r):s.compareDocumentPosition?!!(s.compareDocumentPosition(r)&16):!1:!1}function Xu(){for(var s=window,r=ks();r instanceof s.HTMLIFrameElement;){try{var c=typeof r.contentWindow.location.href=="string"}catch{c=!1}if(c)s=r.contentWindow;else break;r=ks(s.document)}return r}function il(s){var r=s&&s.nodeName&&s.nodeName.toLowerCase();return r&&(r==="input"&&(s.type==="text"||s.type==="search"||s.type==="tel"||s.type==="url"||s.type==="password")||r==="textarea"||s.contentEditable==="true")}function Sy(s){var r=Xu(),c=s.focusedElem,u=s.selectionRange;if(r!==c&&c&&c.ownerDocument&&Ju(c.ownerDocument.documentElement,c)){if(u!==null&&il(c)){if(r=u.start,s=u.end,s===void 0&&(s=r),"selectionStart"in c)c.selectionStart=r,c.selectionEnd=Math.min(s,c.value.length);else if(s=(r=c.ownerDocument||document)&&r.defaultView||window,s.getSelection){s=s.getSelection();var m=c.textContent.length,g=Math.min(u.start,m);u=u.end===void 0?g:Math.min(u.end,m),!s.extend&&g>u&&(m=u,u=g,g=m),m=Yu(c,g);var x=Yu(c,u);m&&x&&(s.rangeCount!==1||s.anchorNode!==m.node||s.anchorOffset!==m.offset||s.focusNode!==x.node||s.focusOffset!==x.offset)&&(r=r.createRange(),r.setStart(m.node,m.offset),s.removeAllRanges(),g>u?(s.addRange(r),s.extend(x.node,x.offset)):(r.setEnd(x.node,x.offset),s.addRange(r)))}}for(r=[],s=c;s=s.parentNode;)s.nodeType===1&&r.push({element:s,left:s.scrollLeft,top:s.scrollTop});for(typeof c.focus=="function"&&c.focus(),c=0;c<r.length;c++)s=r[c],s.element.scrollLeft=s.left,s.element.scrollTop=s.top}}var Ny=h&&"documentMode"in document&&11>=document.documentMode,bs=null,rl=null,Ti=null,ol=!1;function Zu(s,r,c){var u=c.window===c?c.document:c.nodeType===9?c:c.ownerDocument;ol||bs==null||bs!==ks(u)||(u=bs,"selectionStart"in u&&il(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),Ti&&Ci(Ti,u)||(Ti=u,u=Or(rl,"onSelect"),0<u.length&&(r=new Ya("onSelect","select",null,r,c),s.push({event:r,listeners:u}),r.target=bs)))}function Rr(s,r){var c={};return c[s.toLowerCase()]=r.toLowerCase(),c["Webkit"+s]="webkit"+r,c["Moz"+s]="moz"+r,c}var $s={animationend:Rr("Animation","AnimationEnd"),animationiteration:Rr("Animation","AnimationIteration"),animationstart:Rr("Animation","AnimationStart"),transitionend:Rr("Transition","TransitionEnd")},al={},eh={};h&&(eh=document.createElement("div").style,"AnimationEvent"in window||(delete $s.animationend.animation,delete $s.animationiteration.animation,delete $s.animationstart.animation),"TransitionEvent"in window||delete $s.transitionend.transition);function Mr(s){if(al[s])return al[s];if(!$s[s])return s;var r=$s[s],c;for(c in r)if(r.hasOwnProperty(c)&&c in eh)return al[s]=r[c];return s}var th=Mr("animationend"),nh=Mr("animationiteration"),sh=Mr("animationstart"),ih=Mr("transitionend"),rh=new Map,oh="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 Mn(s,r){rh.set(s,r),l(r,[s])}for(var ll=0;ll<oh.length;ll++){var cl=oh[ll],by=cl.toLowerCase(),$y=cl[0].toUpperCase()+cl.slice(1);Mn(by,"on"+$y)}Mn(th,"onAnimationEnd"),Mn(nh,"onAnimationIteration"),Mn(sh,"onAnimationStart"),Mn("dblclick","onDoubleClick"),Mn("focusin","onFocus"),Mn("focusout","onBlur"),Mn(ih,"onTransitionEnd"),d("onMouseEnter",["mouseout","mouseover"]),d("onMouseLeave",["mouseout","mouseover"]),d("onPointerEnter",["pointerout","pointerover"]),d("onPointerLeave",["pointerout","pointerover"]),l("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),l("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),l("onBeforeInput",["compositionend","keypress","textInput","paste"]),l("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ei="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(" "),Cy=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ei));function ah(s,r,c){var u=s.type||"unknown-event";s.currentTarget=c,bk(u,r,void 0,s),s.currentTarget=null}function lh(s,r){r=(r&4)!==0;for(var c=0;c<s.length;c++){var u=s[c],m=u.event;u=u.listeners;e:{var g=void 0;if(r)for(var x=u.length-1;0<=x;x--){var b=u[x],C=b.instance,L=b.currentTarget;if(b=b.listener,C!==g&&m.isPropagationStopped())break e;ah(m,b,L),g=C}else for(x=0;x<u.length;x++){if(b=u[x],C=b.instance,L=b.currentTarget,b=b.listener,C!==g&&m.isPropagationStopped())break e;ah(m,b,L),g=C}}}if(vr)throw s=Ba,vr=!1,Ba=null,s}function Me(s,r){var c=r[vl];c===void 0&&(c=r[vl]=new Set);var u=s+"__bubble";c.has(u)||(ch(r,s,2,!1),c.add(u))}function dl(s,r,c){var u=0;r&&(u|=4),ch(c,s,u,r)}var Lr="_reactListening"+Math.random().toString(36).slice(2);function Ai(s){if(!s[Lr]){s[Lr]=!0,o.forEach(function(c){c!=="selectionchange"&&(Cy.has(c)||dl(c,!1,s),dl(c,!0,s))});var r=s.nodeType===9?s:s.ownerDocument;r===null||r[Lr]||(r[Lr]=!0,dl("selectionchange",!1,r))}}function ch(s,r,c,u){switch(Ru(r)){case 1:var m=Fk;break;case 4:m=Uk;break;default:m=Ga}c=m.bind(null,r,c,s),m=void 0,!za||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(m=!0),u?m!==void 0?s.addEventListener(r,c,{capture:!0,passive:m}):s.addEventListener(r,c,!0):m!==void 0?s.addEventListener(r,c,{passive:m}):s.addEventListener(r,c,!1)}function ul(s,r,c,u,m){var g=u;if((r&1)===0&&(r&2)===0&&u!==null)e:for(;;){if(u===null)return;var x=u.tag;if(x===3||x===4){var b=u.stateNode.containerInfo;if(b===m||b.nodeType===8&&b.parentNode===m)break;if(x===4)for(x=u.return;x!==null;){var C=x.tag;if((C===3||C===4)&&(C=x.stateNode.containerInfo,C===m||C.nodeType===8&&C.parentNode===m))return;x=x.return}for(;b!==null;){if(x=Zn(b),x===null)return;if(C=x.tag,C===5||C===6){u=g=x;continue e}b=b.parentNode}}u=u.return}mu(function(){var L=g,U=Pa(c),K=[];e:{var B=rh.get(s);if(B!==void 0){var ee=Ya,se=s;switch(s){case"keypress":if(Tr(c)===0)break e;case"keydown":case"keyup":ee=sy;break;case"focusin":se="focus",ee=Za;break;case"focusout":se="blur",ee=Za;break;case"beforeblur":case"afterblur":ee=Za;break;case"click":if(c.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ee=Ou;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ee=Kk;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ee=oy;break;case th:case nh:case sh:ee=qk;break;case ih:ee=ly;break;case"scroll":ee=Wk;break;case"wheel":ee=dy;break;case"copy":case"cut":case"paste":ee=Yk;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ee=_u}var re=(r&4)!==0,He=!re&&s==="scroll",A=re?B!==null?B+"Capture":null:B;re=[];for(var E=L,R;E!==null;){R=E;var Y=R.stateNode;if(R.tag===5&&Y!==null&&(R=Y,A!==null&&(Y=hi(E,A),Y!=null&&re.push(Ii(E,Y,R)))),He)break;E=E.return}0<re.length&&(B=new ee(B,se,null,c,U),K.push({event:B,listeners:re}))}}if((r&7)===0){e:{if(B=s==="mouseover"||s==="pointerover",ee=s==="mouseout"||s==="pointerout",B&&c!==Oa&&(se=c.relatedTarget||c.fromElement)&&(Zn(se)||se[fn]))break e;if((ee||B)&&(B=U.window===U?U:(B=U.ownerDocument)?B.defaultView||B.parentWindow:window,ee?(se=c.relatedTarget||c.toElement,ee=L,se=se?Zn(se):null,se!==null&&(He=Xn(se),se!==He||se.tag!==5&&se.tag!==6)&&(se=null)):(ee=null,se=L),ee!==se)){if(re=Ou,Y="onMouseLeave",A="onMouseEnter",E="mouse",(s==="pointerout"||s==="pointerover")&&(re=_u,Y="onPointerLeave",A="onPointerEnter",E="pointer"),He=ee==null?B:Es(ee),R=se==null?B:Es(se),B=new re(Y,E+"leave",ee,c,U),B.target=He,B.relatedTarget=R,Y=null,Zn(U)===L&&(re=new re(A,E+"enter",se,c,U),re.target=R,re.relatedTarget=He,Y=re),He=Y,ee&&se)t:{for(re=ee,A=se,E=0,R=re;R;R=Cs(R))E++;for(R=0,Y=A;Y;Y=Cs(Y))R++;for(;0<E-R;)re=Cs(re),E--;for(;0<R-E;)A=Cs(A),R--;for(;E--;){if(re===A||A!==null&&re===A.alternate)break t;re=Cs(re),A=Cs(A)}re=null}else re=null;ee!==null&&dh(K,B,ee,re,!1),se!==null&&He!==null&&dh(K,He,se,re,!0)}}e:{if(B=L?Es(L):window,ee=B.nodeName&&B.nodeName.toLowerCase(),ee==="select"||ee==="input"&&B.type==="file")var ae=vy;else if(Wu(B))if(Ku)ae=xy;else{ae=yy;var ue=ky}else(ee=B.nodeName)&&ee.toLowerCase()==="input"&&(B.type==="checkbox"||B.type==="radio")&&(ae=wy);if(ae&&(ae=ae(s,L))){Hu(K,ae,c,U);break e}ue&&ue(s,B,L),s==="focusout"&&(ue=B._wrapperState)&&ue.controlled&&B.type==="number"&&Aa(B,"number",B.value)}switch(ue=L?Es(L):window,s){case"focusin":(Wu(ue)||ue.contentEditable==="true")&&(bs=ue,rl=L,Ti=null);break;case"focusout":Ti=rl=bs=null;break;case"mousedown":ol=!0;break;case"contextmenu":case"mouseup":case"dragend":ol=!1,Zu(K,c,U);break;case"selectionchange":if(Ny)break;case"keydown":case"keyup":Zu(K,c,U)}var he;if(tl)e:{switch(s){case"compositionstart":var fe="onCompositionStart";break e;case"compositionend":fe="onCompositionEnd";break e;case"compositionupdate":fe="onCompositionUpdate";break e}fe=void 0}else Ns?Fu(s,c)&&(fe="onCompositionEnd"):s==="keydown"&&c.keyCode===229&&(fe="onCompositionStart");fe&&(Du&&c.locale!=="ko"&&(Ns||fe!=="onCompositionStart"?fe==="onCompositionEnd"&&Ns&&(he=Mu()):(Rn=U,Qa="value"in Rn?Rn.value:Rn.textContent,Ns=!0)),ue=Or(L,fe),0<ue.length&&(fe=new Pu(fe,s,null,c,U),K.push({event:fe,listeners:ue}),he?fe.data=he:(he=Uu(c),he!==null&&(fe.data=he)))),(he=hy?fy(s,c):my(s,c))&&(L=Or(L,"onBeforeInput"),0<L.length&&(U=new Pu("onBeforeInput","beforeinput",null,c,U),K.push({event:U,listeners:L}),U.data=he))}lh(K,r)})}function Ii(s,r,c){return{instance:s,listener:r,currentTarget:c}}function Or(s,r){for(var c=r+"Capture",u=[];s!==null;){var m=s,g=m.stateNode;m.tag===5&&g!==null&&(m=g,g=hi(s,c),g!=null&&u.unshift(Ii(s,g,m)),g=hi(s,r),g!=null&&u.push(Ii(s,g,m))),s=s.return}return u}function Cs(s){if(s===null)return null;do s=s.return;while(s&&s.tag!==5);return s||null}function dh(s,r,c,u,m){for(var g=r._reactName,x=[];c!==null&&c!==u;){var b=c,C=b.alternate,L=b.stateNode;if(C!==null&&C===u)break;b.tag===5&&L!==null&&(b=L,m?(C=hi(c,g),C!=null&&x.unshift(Ii(c,C,b))):m||(C=hi(c,g),C!=null&&x.push(Ii(c,C,b)))),c=c.return}x.length!==0&&s.push({event:r,listeners:x})}var Ty=/\r\n?/g,Ey=/\u0000|\uFFFD/g;function uh(s){return(typeof s=="string"?s:""+s).replace(Ty,`
|
|
38
|
+
`).replace(Ey,"")}function Pr(s,r,c){if(r=uh(r),uh(s)!==r&&c)throw Error(n(425))}function _r(){}var hl=null,fl=null;function ml(s,r){return s==="textarea"||s==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var pl=typeof setTimeout=="function"?setTimeout:void 0,Ay=typeof clearTimeout=="function"?clearTimeout:void 0,hh=typeof Promise=="function"?Promise:void 0,Iy=typeof queueMicrotask=="function"?queueMicrotask:typeof hh<"u"?function(s){return hh.resolve(null).then(s).catch(Ry)}:pl;function Ry(s){setTimeout(function(){throw s})}function gl(s,r){var c=r,u=0;do{var m=c.nextSibling;if(s.removeChild(c),m&&m.nodeType===8)if(c=m.data,c==="/$"){if(u===0){s.removeChild(m),xi(r);return}u--}else c!=="$"&&c!=="$?"&&c!=="$!"||u++;c=m}while(c);xi(r)}function Ln(s){for(;s!=null;s=s.nextSibling){var r=s.nodeType;if(r===1||r===3)break;if(r===8){if(r=s.data,r==="$"||r==="$!"||r==="$?")break;if(r==="/$")return null}}return s}function fh(s){s=s.previousSibling;for(var r=0;s;){if(s.nodeType===8){var c=s.data;if(c==="$"||c==="$!"||c==="$?"){if(r===0)return s;r--}else c==="/$"&&r++}s=s.previousSibling}return null}var Ts=Math.random().toString(36).slice(2),en="__reactFiber$"+Ts,Ri="__reactProps$"+Ts,fn="__reactContainer$"+Ts,vl="__reactEvents$"+Ts,My="__reactListeners$"+Ts,Ly="__reactHandles$"+Ts;function Zn(s){var r=s[en];if(r)return r;for(var c=s.parentNode;c;){if(r=c[fn]||c[en]){if(c=r.alternate,r.child!==null||c!==null&&c.child!==null)for(s=fh(s);s!==null;){if(c=s[en])return c;s=fh(s)}return r}s=c,c=s.parentNode}return null}function Mi(s){return s=s[en]||s[fn],!s||s.tag!==5&&s.tag!==6&&s.tag!==13&&s.tag!==3?null:s}function Es(s){if(s.tag===5||s.tag===6)return s.stateNode;throw Error(n(33))}function Dr(s){return s[Ri]||null}var kl=[],As=-1;function On(s){return{current:s}}function Le(s){0>As||(s.current=kl[As],kl[As]=null,As--)}function Re(s,r){As++,kl[As]=s.current,s.current=r}var Pn={},lt=On(Pn),gt=On(!1),es=Pn;function Is(s,r){var c=s.type.contextTypes;if(!c)return Pn;var u=s.stateNode;if(u&&u.__reactInternalMemoizedUnmaskedChildContext===r)return u.__reactInternalMemoizedMaskedChildContext;var m={},g;for(g in c)m[g]=r[g];return u&&(s=s.stateNode,s.__reactInternalMemoizedUnmaskedChildContext=r,s.__reactInternalMemoizedMaskedChildContext=m),m}function vt(s){return s=s.childContextTypes,s!=null}function zr(){Le(gt),Le(lt)}function mh(s,r,c){if(lt.current!==Pn)throw Error(n(168));Re(lt,r),Re(gt,c)}function ph(s,r,c){var u=s.stateNode;if(r=r.childContextTypes,typeof u.getChildContext!="function")return c;u=u.getChildContext();for(var m in u)if(!(m in r))throw Error(n(108,ge(s)||"Unknown",m));return z({},c,u)}function Br(s){return s=(s=s.stateNode)&&s.__reactInternalMemoizedMergedChildContext||Pn,es=lt.current,Re(lt,s),Re(gt,gt.current),!0}function gh(s,r,c){var u=s.stateNode;if(!u)throw Error(n(169));c?(s=ph(s,r,es),u.__reactInternalMemoizedMergedChildContext=s,Le(gt),Le(lt),Re(lt,s)):Le(gt),Re(gt,c)}var mn=null,Fr=!1,yl=!1;function vh(s){mn===null?mn=[s]:mn.push(s)}function Oy(s){Fr=!0,vh(s)}function _n(){if(!yl&&mn!==null){yl=!0;var s=0,r=Ce;try{var c=mn;for(Ce=1;s<c.length;s++){var u=c[s];do u=u(!0);while(u!==null)}mn=null,Fr=!1}catch(m){throw mn!==null&&(mn=mn.slice(s+1)),yu(Fa,_n),m}finally{Ce=r,yl=!1}}return null}var Rs=[],Ms=0,Ur=null,Wr=0,It=[],Rt=0,ts=null,pn=1,gn="";function ns(s,r){Rs[Ms++]=Wr,Rs[Ms++]=Ur,Ur=s,Wr=r}function kh(s,r,c){It[Rt++]=pn,It[Rt++]=gn,It[Rt++]=ts,ts=s;var u=pn;s=gn;var m=32-Ft(u)-1;u&=~(1<<m),c+=1;var g=32-Ft(r)+m;if(30<g){var x=m-m%5;g=(u&(1<<x)-1).toString(32),u>>=x,m-=x,pn=1<<32-Ft(r)+m|c<<m|u,gn=g+s}else pn=1<<g|c<<m|u,gn=s}function wl(s){s.return!==null&&(ns(s,1),kh(s,1,0))}function xl(s){for(;s===Ur;)Ur=Rs[--Ms],Rs[Ms]=null,Wr=Rs[--Ms],Rs[Ms]=null;for(;s===ts;)ts=It[--Rt],It[Rt]=null,gn=It[--Rt],It[Rt]=null,pn=It[--Rt],It[Rt]=null}var $t=null,Ct=null,Pe=!1,Wt=null;function yh(s,r){var c=Pt(5,null,null,0);c.elementType="DELETED",c.stateNode=r,c.return=s,r=s.deletions,r===null?(s.deletions=[c],s.flags|=16):r.push(c)}function wh(s,r){switch(s.tag){case 5:var c=s.type;return r=r.nodeType!==1||c.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(s.stateNode=r,$t=s,Ct=Ln(r.firstChild),!0):!1;case 6:return r=s.pendingProps===""||r.nodeType!==3?null:r,r!==null?(s.stateNode=r,$t=s,Ct=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(c=ts!==null?{id:pn,overflow:gn}:null,s.memoizedState={dehydrated:r,treeContext:c,retryLane:1073741824},c=Pt(18,null,null,0),c.stateNode=r,c.return=s,s.child=c,$t=s,Ct=null,!0):!1;default:return!1}}function jl(s){return(s.mode&1)!==0&&(s.flags&128)===0}function Sl(s){if(Pe){var r=Ct;if(r){var c=r;if(!wh(s,r)){if(jl(s))throw Error(n(418));r=Ln(c.nextSibling);var u=$t;r&&wh(s,r)?yh(u,c):(s.flags=s.flags&-4097|2,Pe=!1,$t=s)}}else{if(jl(s))throw Error(n(418));s.flags=s.flags&-4097|2,Pe=!1,$t=s}}}function xh(s){for(s=s.return;s!==null&&s.tag!==5&&s.tag!==3&&s.tag!==13;)s=s.return;$t=s}function Hr(s){if(s!==$t)return!1;if(!Pe)return xh(s),Pe=!0,!1;var r;if((r=s.tag!==3)&&!(r=s.tag!==5)&&(r=s.type,r=r!=="head"&&r!=="body"&&!ml(s.type,s.memoizedProps)),r&&(r=Ct)){if(jl(s))throw jh(),Error(n(418));for(;r;)yh(s,r),r=Ln(r.nextSibling)}if(xh(s),s.tag===13){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(n(317));e:{for(s=s.nextSibling,r=0;s;){if(s.nodeType===8){var c=s.data;if(c==="/$"){if(r===0){Ct=Ln(s.nextSibling);break e}r--}else c!=="$"&&c!=="$!"&&c!=="$?"||r++}s=s.nextSibling}Ct=null}}else Ct=$t?Ln(s.stateNode.nextSibling):null;return!0}function jh(){for(var s=Ct;s;)s=Ln(s.nextSibling)}function Ls(){Ct=$t=null,Pe=!1}function Nl(s){Wt===null?Wt=[s]:Wt.push(s)}var Py=D.ReactCurrentBatchConfig;function Li(s,r,c){if(s=c.ref,s!==null&&typeof s!="function"&&typeof s!="object"){if(c._owner){if(c=c._owner,c){if(c.tag!==1)throw Error(n(309));var u=c.stateNode}if(!u)throw Error(n(147,s));var m=u,g=""+s;return r!==null&&r.ref!==null&&typeof r.ref=="function"&&r.ref._stringRef===g?r.ref:(r=function(x){var b=m.refs;x===null?delete b[g]:b[g]=x},r._stringRef=g,r)}if(typeof s!="string")throw Error(n(284));if(!c._owner)throw Error(n(290,s))}return s}function Kr(s,r){throw s=Object.prototype.toString.call(r),Error(n(31,s==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":s))}function Sh(s){var r=s._init;return r(s._payload)}function Nh(s){function r(A,E){if(s){var R=A.deletions;R===null?(A.deletions=[E],A.flags|=16):R.push(E)}}function c(A,E){if(!s)return null;for(;E!==null;)r(A,E),E=E.sibling;return null}function u(A,E){for(A=new Map;E!==null;)E.key!==null?A.set(E.key,E):A.set(E.index,E),E=E.sibling;return A}function m(A,E){return A=Kn(A,E),A.index=0,A.sibling=null,A}function g(A,E,R){return A.index=R,s?(R=A.alternate,R!==null?(R=R.index,R<E?(A.flags|=2,E):R):(A.flags|=2,E)):(A.flags|=1048576,E)}function x(A){return s&&A.alternate===null&&(A.flags|=2),A}function b(A,E,R,Y){return E===null||E.tag!==6?(E=pc(R,A.mode,Y),E.return=A,E):(E=m(E,R),E.return=A,E)}function C(A,E,R,Y){var ae=R.type;return ae===G?U(A,E,R.props.children,Y,R.key):E!==null&&(E.elementType===ae||typeof ae=="object"&&ae!==null&&ae.$$typeof===J&&Sh(ae)===E.type)?(Y=m(E,R.props),Y.ref=Li(A,E,R),Y.return=A,Y):(Y=go(R.type,R.key,R.props,null,A.mode,Y),Y.ref=Li(A,E,R),Y.return=A,Y)}function L(A,E,R,Y){return E===null||E.tag!==4||E.stateNode.containerInfo!==R.containerInfo||E.stateNode.implementation!==R.implementation?(E=gc(R,A.mode,Y),E.return=A,E):(E=m(E,R.children||[]),E.return=A,E)}function U(A,E,R,Y,ae){return E===null||E.tag!==7?(E=ds(R,A.mode,Y,ae),E.return=A,E):(E=m(E,R),E.return=A,E)}function K(A,E,R){if(typeof E=="string"&&E!==""||typeof E=="number")return E=pc(""+E,A.mode,R),E.return=A,E;if(typeof E=="object"&&E!==null){switch(E.$$typeof){case q:return R=go(E.type,E.key,E.props,null,A.mode,R),R.ref=Li(A,null,E),R.return=A,R;case H:return E=gc(E,A.mode,R),E.return=A,E;case J:var Y=E._init;return K(A,Y(E._payload),R)}if(ci(E)||X(E))return E=ds(E,A.mode,R,null),E.return=A,E;Kr(A,E)}return null}function B(A,E,R,Y){var ae=E!==null?E.key:null;if(typeof R=="string"&&R!==""||typeof R=="number")return ae!==null?null:b(A,E,""+R,Y);if(typeof R=="object"&&R!==null){switch(R.$$typeof){case q:return R.key===ae?C(A,E,R,Y):null;case H:return R.key===ae?L(A,E,R,Y):null;case J:return ae=R._init,B(A,E,ae(R._payload),Y)}if(ci(R)||X(R))return ae!==null?null:U(A,E,R,Y,null);Kr(A,R)}return null}function ee(A,E,R,Y,ae){if(typeof Y=="string"&&Y!==""||typeof Y=="number")return A=A.get(R)||null,b(E,A,""+Y,ae);if(typeof Y=="object"&&Y!==null){switch(Y.$$typeof){case q:return A=A.get(Y.key===null?R:Y.key)||null,C(E,A,Y,ae);case H:return A=A.get(Y.key===null?R:Y.key)||null,L(E,A,Y,ae);case J:var ue=Y._init;return ee(A,E,R,ue(Y._payload),ae)}if(ci(Y)||X(Y))return A=A.get(R)||null,U(E,A,Y,ae,null);Kr(E,Y)}return null}function se(A,E,R,Y){for(var ae=null,ue=null,he=E,fe=E=0,nt=null;he!==null&&fe<R.length;fe++){he.index>fe?(nt=he,he=null):nt=he.sibling;var $e=B(A,he,R[fe],Y);if($e===null){he===null&&(he=nt);break}s&&he&&$e.alternate===null&&r(A,he),E=g($e,E,fe),ue===null?ae=$e:ue.sibling=$e,ue=$e,he=nt}if(fe===R.length)return c(A,he),Pe&&ns(A,fe),ae;if(he===null){for(;fe<R.length;fe++)he=K(A,R[fe],Y),he!==null&&(E=g(he,E,fe),ue===null?ae=he:ue.sibling=he,ue=he);return Pe&&ns(A,fe),ae}for(he=u(A,he);fe<R.length;fe++)nt=ee(he,A,fe,R[fe],Y),nt!==null&&(s&&nt.alternate!==null&&he.delete(nt.key===null?fe:nt.key),E=g(nt,E,fe),ue===null?ae=nt:ue.sibling=nt,ue=nt);return s&&he.forEach(function(Vn){return r(A,Vn)}),Pe&&ns(A,fe),ae}function re(A,E,R,Y){var ae=X(R);if(typeof ae!="function")throw Error(n(150));if(R=ae.call(R),R==null)throw Error(n(151));for(var ue=ae=null,he=E,fe=E=0,nt=null,$e=R.next();he!==null&&!$e.done;fe++,$e=R.next()){he.index>fe?(nt=he,he=null):nt=he.sibling;var Vn=B(A,he,$e.value,Y);if(Vn===null){he===null&&(he=nt);break}s&&he&&Vn.alternate===null&&r(A,he),E=g(Vn,E,fe),ue===null?ae=Vn:ue.sibling=Vn,ue=Vn,he=nt}if($e.done)return c(A,he),Pe&&ns(A,fe),ae;if(he===null){for(;!$e.done;fe++,$e=R.next())$e=K(A,$e.value,Y),$e!==null&&(E=g($e,E,fe),ue===null?ae=$e:ue.sibling=$e,ue=$e);return Pe&&ns(A,fe),ae}for(he=u(A,he);!$e.done;fe++,$e=R.next())$e=ee(he,A,fe,$e.value,Y),$e!==null&&(s&&$e.alternate!==null&&he.delete($e.key===null?fe:$e.key),E=g($e,E,fe),ue===null?ae=$e:ue.sibling=$e,ue=$e);return s&&he.forEach(function(pw){return r(A,pw)}),Pe&&ns(A,fe),ae}function He(A,E,R,Y){if(typeof R=="object"&&R!==null&&R.type===G&&R.key===null&&(R=R.props.children),typeof R=="object"&&R!==null){switch(R.$$typeof){case q:e:{for(var ae=R.key,ue=E;ue!==null;){if(ue.key===ae){if(ae=R.type,ae===G){if(ue.tag===7){c(A,ue.sibling),E=m(ue,R.props.children),E.return=A,A=E;break e}}else if(ue.elementType===ae||typeof ae=="object"&&ae!==null&&ae.$$typeof===J&&Sh(ae)===ue.type){c(A,ue.sibling),E=m(ue,R.props),E.ref=Li(A,ue,R),E.return=A,A=E;break e}c(A,ue);break}else r(A,ue);ue=ue.sibling}R.type===G?(E=ds(R.props.children,A.mode,Y,R.key),E.return=A,A=E):(Y=go(R.type,R.key,R.props,null,A.mode,Y),Y.ref=Li(A,E,R),Y.return=A,A=Y)}return x(A);case H:e:{for(ue=R.key;E!==null;){if(E.key===ue)if(E.tag===4&&E.stateNode.containerInfo===R.containerInfo&&E.stateNode.implementation===R.implementation){c(A,E.sibling),E=m(E,R.children||[]),E.return=A,A=E;break e}else{c(A,E);break}else r(A,E);E=E.sibling}E=gc(R,A.mode,Y),E.return=A,A=E}return x(A);case J:return ue=R._init,He(A,E,ue(R._payload),Y)}if(ci(R))return se(A,E,R,Y);if(X(R))return re(A,E,R,Y);Kr(A,R)}return typeof R=="string"&&R!==""||typeof R=="number"?(R=""+R,E!==null&&E.tag===6?(c(A,E.sibling),E=m(E,R),E.return=A,A=E):(c(A,E),E=pc(R,A.mode,Y),E.return=A,A=E),x(A)):c(A,E)}return He}var Os=Nh(!0),bh=Nh(!1),Vr=On(null),Gr=null,Ps=null,bl=null;function $l(){bl=Ps=Gr=null}function Cl(s){var r=Vr.current;Le(Vr),s._currentValue=r}function Tl(s,r,c){for(;s!==null;){var u=s.alternate;if((s.childLanes&r)!==r?(s.childLanes|=r,u!==null&&(u.childLanes|=r)):u!==null&&(u.childLanes&r)!==r&&(u.childLanes|=r),s===c)break;s=s.return}}function _s(s,r){Gr=s,bl=Ps=null,s=s.dependencies,s!==null&&s.firstContext!==null&&((s.lanes&r)!==0&&(kt=!0),s.firstContext=null)}function Mt(s){var r=s._currentValue;if(bl!==s)if(s={context:s,memoizedValue:r,next:null},Ps===null){if(Gr===null)throw Error(n(308));Ps=s,Gr.dependencies={lanes:0,firstContext:s}}else Ps=Ps.next=s;return r}var ss=null;function El(s){ss===null?ss=[s]:ss.push(s)}function $h(s,r,c,u){var m=r.interleaved;return m===null?(c.next=c,El(r)):(c.next=m.next,m.next=c),r.interleaved=c,vn(s,u)}function vn(s,r){s.lanes|=r;var c=s.alternate;for(c!==null&&(c.lanes|=r),c=s,s=s.return;s!==null;)s.childLanes|=r,c=s.alternate,c!==null&&(c.childLanes|=r),c=s,s=s.return;return c.tag===3?c.stateNode:null}var Dn=!1;function Al(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ch(s,r){s=s.updateQueue,r.updateQueue===s&&(r.updateQueue={baseState:s.baseState,firstBaseUpdate:s.firstBaseUpdate,lastBaseUpdate:s.lastBaseUpdate,shared:s.shared,effects:s.effects})}function kn(s,r){return{eventTime:s,lane:r,tag:0,payload:null,callback:null,next:null}}function zn(s,r,c){var u=s.updateQueue;if(u===null)return null;if(u=u.shared,(Ne&2)!==0){var m=u.pending;return m===null?r.next=r:(r.next=m.next,m.next=r),u.pending=r,vn(s,c)}return m=u.interleaved,m===null?(r.next=r,El(u)):(r.next=m.next,m.next=r),u.interleaved=r,vn(s,c)}function qr(s,r,c){if(r=r.updateQueue,r!==null&&(r=r.shared,(c&4194240)!==0)){var u=r.lanes;u&=s.pendingLanes,c|=u,r.lanes=c,Ha(s,c)}}function Th(s,r){var c=s.updateQueue,u=s.alternate;if(u!==null&&(u=u.updateQueue,c===u)){var m=null,g=null;if(c=c.firstBaseUpdate,c!==null){do{var x={eventTime:c.eventTime,lane:c.lane,tag:c.tag,payload:c.payload,callback:c.callback,next:null};g===null?m=g=x:g=g.next=x,c=c.next}while(c!==null);g===null?m=g=r:g=g.next=r}else m=g=r;c={baseState:u.baseState,firstBaseUpdate:m,lastBaseUpdate:g,shared:u.shared,effects:u.effects},s.updateQueue=c;return}s=c.lastBaseUpdate,s===null?c.firstBaseUpdate=r:s.next=r,c.lastBaseUpdate=r}function Qr(s,r,c,u){var m=s.updateQueue;Dn=!1;var g=m.firstBaseUpdate,x=m.lastBaseUpdate,b=m.shared.pending;if(b!==null){m.shared.pending=null;var C=b,L=C.next;C.next=null,x===null?g=L:x.next=L,x=C;var U=s.alternate;U!==null&&(U=U.updateQueue,b=U.lastBaseUpdate,b!==x&&(b===null?U.firstBaseUpdate=L:b.next=L,U.lastBaseUpdate=C))}if(g!==null){var K=m.baseState;x=0,U=L=C=null,b=g;do{var B=b.lane,ee=b.eventTime;if((u&B)===B){U!==null&&(U=U.next={eventTime:ee,lane:0,tag:b.tag,payload:b.payload,callback:b.callback,next:null});e:{var se=s,re=b;switch(B=r,ee=c,re.tag){case 1:if(se=re.payload,typeof se=="function"){K=se.call(ee,K,B);break e}K=se;break e;case 3:se.flags=se.flags&-65537|128;case 0:if(se=re.payload,B=typeof se=="function"?se.call(ee,K,B):se,B==null)break e;K=z({},K,B);break e;case 2:Dn=!0}}b.callback!==null&&b.lane!==0&&(s.flags|=64,B=m.effects,B===null?m.effects=[b]:B.push(b))}else ee={eventTime:ee,lane:B,tag:b.tag,payload:b.payload,callback:b.callback,next:null},U===null?(L=U=ee,C=K):U=U.next=ee,x|=B;if(b=b.next,b===null){if(b=m.shared.pending,b===null)break;B=b,b=B.next,B.next=null,m.lastBaseUpdate=B,m.shared.pending=null}}while(!0);if(U===null&&(C=K),m.baseState=C,m.firstBaseUpdate=L,m.lastBaseUpdate=U,r=m.shared.interleaved,r!==null){m=r;do x|=m.lane,m=m.next;while(m!==r)}else g===null&&(m.shared.lanes=0);os|=x,s.lanes=x,s.memoizedState=K}}function Eh(s,r,c){if(s=r.effects,r.effects=null,s!==null)for(r=0;r<s.length;r++){var u=s[r],m=u.callback;if(m!==null){if(u.callback=null,u=c,typeof m!="function")throw Error(n(191,m));m.call(u)}}}var Oi={},tn=On(Oi),Pi=On(Oi),_i=On(Oi);function is(s){if(s===Oi)throw Error(n(174));return s}function Il(s,r){switch(Re(_i,r),Re(Pi,s),Re(tn,Oi),s=r.nodeType,s){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:Ra(null,"");break;default:s=s===8?r.parentNode:r,r=s.namespaceURI||null,s=s.tagName,r=Ra(r,s)}Le(tn),Re(tn,r)}function Ds(){Le(tn),Le(Pi),Le(_i)}function Ah(s){is(_i.current);var r=is(tn.current),c=Ra(r,s.type);r!==c&&(Re(Pi,s),Re(tn,c))}function Rl(s){Pi.current===s&&(Le(tn),Le(Pi))}var _e=On(0);function Yr(s){for(var r=s;r!==null;){if(r.tag===13){var c=r.memoizedState;if(c!==null&&(c=c.dehydrated,c===null||c.data==="$?"||c.data==="$!"))return r}else if(r.tag===19&&r.memoizedProps.revealOrder!==void 0){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===s)break;for(;r.sibling===null;){if(r.return===null||r.return===s)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var Ml=[];function Ll(){for(var s=0;s<Ml.length;s++)Ml[s]._workInProgressVersionPrimary=null;Ml.length=0}var Jr=D.ReactCurrentDispatcher,Ol=D.ReactCurrentBatchConfig,rs=0,De=null,Je=null,et=null,Xr=!1,Di=!1,zi=0,_y=0;function ct(){throw Error(n(321))}function Pl(s,r){if(r===null)return!1;for(var c=0;c<r.length&&c<s.length;c++)if(!Ut(s[c],r[c]))return!1;return!0}function _l(s,r,c,u,m,g){if(rs=g,De=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,Jr.current=s===null||s.memoizedState===null?Fy:Uy,s=c(u,m),Di){g=0;do{if(Di=!1,zi=0,25<=g)throw Error(n(301));g+=1,et=Je=null,r.updateQueue=null,Jr.current=Wy,s=c(u,m)}while(Di)}if(Jr.current=to,r=Je!==null&&Je.next!==null,rs=0,et=Je=De=null,Xr=!1,r)throw Error(n(300));return s}function Dl(){var s=zi!==0;return zi=0,s}function nn(){var s={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return et===null?De.memoizedState=et=s:et=et.next=s,et}function Lt(){if(Je===null){var s=De.alternate;s=s!==null?s.memoizedState:null}else s=Je.next;var r=et===null?De.memoizedState:et.next;if(r!==null)et=r,Je=s;else{if(s===null)throw Error(n(310));Je=s,s={memoizedState:Je.memoizedState,baseState:Je.baseState,baseQueue:Je.baseQueue,queue:Je.queue,next:null},et===null?De.memoizedState=et=s:et=et.next=s}return et}function Bi(s,r){return typeof r=="function"?r(s):r}function zl(s){var r=Lt(),c=r.queue;if(c===null)throw Error(n(311));c.lastRenderedReducer=s;var u=Je,m=u.baseQueue,g=c.pending;if(g!==null){if(m!==null){var x=m.next;m.next=g.next,g.next=x}u.baseQueue=m=g,c.pending=null}if(m!==null){g=m.next,u=u.baseState;var b=x=null,C=null,L=g;do{var U=L.lane;if((rs&U)===U)C!==null&&(C=C.next={lane:0,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null}),u=L.hasEagerState?L.eagerState:s(u,L.action);else{var K={lane:U,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null};C===null?(b=C=K,x=u):C=C.next=K,De.lanes|=U,os|=U}L=L.next}while(L!==null&&L!==g);C===null?x=u:C.next=b,Ut(u,r.memoizedState)||(kt=!0),r.memoizedState=u,r.baseState=x,r.baseQueue=C,c.lastRenderedState=u}if(s=c.interleaved,s!==null){m=s;do g=m.lane,De.lanes|=g,os|=g,m=m.next;while(m!==s)}else m===null&&(c.lanes=0);return[r.memoizedState,c.dispatch]}function Bl(s){var r=Lt(),c=r.queue;if(c===null)throw Error(n(311));c.lastRenderedReducer=s;var u=c.dispatch,m=c.pending,g=r.memoizedState;if(m!==null){c.pending=null;var x=m=m.next;do g=s(g,x.action),x=x.next;while(x!==m);Ut(g,r.memoizedState)||(kt=!0),r.memoizedState=g,r.baseQueue===null&&(r.baseState=g),c.lastRenderedState=g}return[g,u]}function Ih(){}function Rh(s,r){var c=De,u=Lt(),m=r(),g=!Ut(u.memoizedState,m);if(g&&(u.memoizedState=m,kt=!0),u=u.queue,Fl(Oh.bind(null,c,u,s),[s]),u.getSnapshot!==r||g||et!==null&&et.memoizedState.tag&1){if(c.flags|=2048,Fi(9,Lh.bind(null,c,u,m,r),void 0,null),tt===null)throw Error(n(349));(rs&30)!==0||Mh(c,r,m)}return m}function Mh(s,r,c){s.flags|=16384,s={getSnapshot:r,value:c},r=De.updateQueue,r===null?(r={lastEffect:null,stores:null},De.updateQueue=r,r.stores=[s]):(c=r.stores,c===null?r.stores=[s]:c.push(s))}function Lh(s,r,c,u){r.value=c,r.getSnapshot=u,Ph(r)&&_h(s)}function Oh(s,r,c){return c(function(){Ph(r)&&_h(s)})}function Ph(s){var r=s.getSnapshot;s=s.value;try{var c=r();return!Ut(s,c)}catch{return!0}}function _h(s){var r=vn(s,1);r!==null&&Gt(r,s,1,-1)}function Dh(s){var r=nn();return typeof s=="function"&&(s=s()),r.memoizedState=r.baseState=s,s={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Bi,lastRenderedState:s},r.queue=s,s=s.dispatch=By.bind(null,De,s),[r.memoizedState,s]}function Fi(s,r,c,u){return s={tag:s,create:r,destroy:c,deps:u,next:null},r=De.updateQueue,r===null?(r={lastEffect:null,stores:null},De.updateQueue=r,r.lastEffect=s.next=s):(c=r.lastEffect,c===null?r.lastEffect=s.next=s:(u=c.next,c.next=s,s.next=u,r.lastEffect=s)),s}function zh(){return Lt().memoizedState}function Zr(s,r,c,u){var m=nn();De.flags|=s,m.memoizedState=Fi(1|r,c,void 0,u===void 0?null:u)}function eo(s,r,c,u){var m=Lt();u=u===void 0?null:u;var g=void 0;if(Je!==null){var x=Je.memoizedState;if(g=x.destroy,u!==null&&Pl(u,x.deps)){m.memoizedState=Fi(r,c,g,u);return}}De.flags|=s,m.memoizedState=Fi(1|r,c,g,u)}function Bh(s,r){return Zr(8390656,8,s,r)}function Fl(s,r){return eo(2048,8,s,r)}function Fh(s,r){return eo(4,2,s,r)}function Uh(s,r){return eo(4,4,s,r)}function Wh(s,r){if(typeof r=="function")return s=s(),r(s),function(){r(null)};if(r!=null)return s=s(),r.current=s,function(){r.current=null}}function Hh(s,r,c){return c=c!=null?c.concat([s]):null,eo(4,4,Wh.bind(null,r,s),c)}function Ul(){}function Kh(s,r){var c=Lt();r=r===void 0?null:r;var u=c.memoizedState;return u!==null&&r!==null&&Pl(r,u[1])?u[0]:(c.memoizedState=[s,r],s)}function Vh(s,r){var c=Lt();r=r===void 0?null:r;var u=c.memoizedState;return u!==null&&r!==null&&Pl(r,u[1])?u[0]:(s=s(),c.memoizedState=[s,r],s)}function Gh(s,r,c){return(rs&21)===0?(s.baseState&&(s.baseState=!1,kt=!0),s.memoizedState=c):(Ut(c,r)||(c=Su(),De.lanes|=c,os|=c,s.baseState=!0),r)}function Dy(s,r){var c=Ce;Ce=c!==0&&4>c?c:4,s(!0);var u=Ol.transition;Ol.transition={};try{s(!1),r()}finally{Ce=c,Ol.transition=u}}function qh(){return Lt().memoizedState}function zy(s,r,c){var u=Wn(s);if(c={lane:u,action:c,hasEagerState:!1,eagerState:null,next:null},Qh(s))Yh(r,c);else if(c=$h(s,r,c,u),c!==null){var m=pt();Gt(c,s,u,m),Jh(c,r,u)}}function By(s,r,c){var u=Wn(s),m={lane:u,action:c,hasEagerState:!1,eagerState:null,next:null};if(Qh(s))Yh(r,m);else{var g=s.alternate;if(s.lanes===0&&(g===null||g.lanes===0)&&(g=r.lastRenderedReducer,g!==null))try{var x=r.lastRenderedState,b=g(x,c);if(m.hasEagerState=!0,m.eagerState=b,Ut(b,x)){var C=r.interleaved;C===null?(m.next=m,El(r)):(m.next=C.next,C.next=m),r.interleaved=m;return}}catch{}finally{}c=$h(s,r,m,u),c!==null&&(m=pt(),Gt(c,s,u,m),Jh(c,r,u))}}function Qh(s){var r=s.alternate;return s===De||r!==null&&r===De}function Yh(s,r){Di=Xr=!0;var c=s.pending;c===null?r.next=r:(r.next=c.next,c.next=r),s.pending=r}function Jh(s,r,c){if((c&4194240)!==0){var u=r.lanes;u&=s.pendingLanes,c|=u,r.lanes=c,Ha(s,c)}}var to={readContext:Mt,useCallback:ct,useContext:ct,useEffect:ct,useImperativeHandle:ct,useInsertionEffect:ct,useLayoutEffect:ct,useMemo:ct,useReducer:ct,useRef:ct,useState:ct,useDebugValue:ct,useDeferredValue:ct,useTransition:ct,useMutableSource:ct,useSyncExternalStore:ct,useId:ct,unstable_isNewReconciler:!1},Fy={readContext:Mt,useCallback:function(s,r){return nn().memoizedState=[s,r===void 0?null:r],s},useContext:Mt,useEffect:Bh,useImperativeHandle:function(s,r,c){return c=c!=null?c.concat([s]):null,Zr(4194308,4,Wh.bind(null,r,s),c)},useLayoutEffect:function(s,r){return Zr(4194308,4,s,r)},useInsertionEffect:function(s,r){return Zr(4,2,s,r)},useMemo:function(s,r){var c=nn();return r=r===void 0?null:r,s=s(),c.memoizedState=[s,r],s},useReducer:function(s,r,c){var u=nn();return r=c!==void 0?c(r):r,u.memoizedState=u.baseState=r,s={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:r},u.queue=s,s=s.dispatch=zy.bind(null,De,s),[u.memoizedState,s]},useRef:function(s){var r=nn();return s={current:s},r.memoizedState=s},useState:Dh,useDebugValue:Ul,useDeferredValue:function(s){return nn().memoizedState=s},useTransition:function(){var s=Dh(!1),r=s[0];return s=Dy.bind(null,s[1]),nn().memoizedState=s,[r,s]},useMutableSource:function(){},useSyncExternalStore:function(s,r,c){var u=De,m=nn();if(Pe){if(c===void 0)throw Error(n(407));c=c()}else{if(c=r(),tt===null)throw Error(n(349));(rs&30)!==0||Mh(u,r,c)}m.memoizedState=c;var g={value:c,getSnapshot:r};return m.queue=g,Bh(Oh.bind(null,u,g,s),[s]),u.flags|=2048,Fi(9,Lh.bind(null,u,g,c,r),void 0,null),c},useId:function(){var s=nn(),r=tt.identifierPrefix;if(Pe){var c=gn,u=pn;c=(u&~(1<<32-Ft(u)-1)).toString(32)+c,r=":"+r+"R"+c,c=zi++,0<c&&(r+="H"+c.toString(32)),r+=":"}else c=_y++,r=":"+r+"r"+c.toString(32)+":";return s.memoizedState=r},unstable_isNewReconciler:!1},Uy={readContext:Mt,useCallback:Kh,useContext:Mt,useEffect:Fl,useImperativeHandle:Hh,useInsertionEffect:Fh,useLayoutEffect:Uh,useMemo:Vh,useReducer:zl,useRef:zh,useState:function(){return zl(Bi)},useDebugValue:Ul,useDeferredValue:function(s){var r=Lt();return Gh(r,Je.memoizedState,s)},useTransition:function(){var s=zl(Bi)[0],r=Lt().memoizedState;return[s,r]},useMutableSource:Ih,useSyncExternalStore:Rh,useId:qh,unstable_isNewReconciler:!1},Wy={readContext:Mt,useCallback:Kh,useContext:Mt,useEffect:Fl,useImperativeHandle:Hh,useInsertionEffect:Fh,useLayoutEffect:Uh,useMemo:Vh,useReducer:Bl,useRef:zh,useState:function(){return Bl(Bi)},useDebugValue:Ul,useDeferredValue:function(s){var r=Lt();return Je===null?r.memoizedState=s:Gh(r,Je.memoizedState,s)},useTransition:function(){var s=Bl(Bi)[0],r=Lt().memoizedState;return[s,r]},useMutableSource:Ih,useSyncExternalStore:Rh,useId:qh,unstable_isNewReconciler:!1};function Ht(s,r){if(s&&s.defaultProps){r=z({},r),s=s.defaultProps;for(var c in s)r[c]===void 0&&(r[c]=s[c]);return r}return r}function Wl(s,r,c,u){r=s.memoizedState,c=c(u,r),c=c==null?r:z({},r,c),s.memoizedState=c,s.lanes===0&&(s.updateQueue.baseState=c)}var no={isMounted:function(s){return(s=s._reactInternals)?Xn(s)===s:!1},enqueueSetState:function(s,r,c){s=s._reactInternals;var u=pt(),m=Wn(s),g=kn(u,m);g.payload=r,c!=null&&(g.callback=c),r=zn(s,g,m),r!==null&&(Gt(r,s,m,u),qr(r,s,m))},enqueueReplaceState:function(s,r,c){s=s._reactInternals;var u=pt(),m=Wn(s),g=kn(u,m);g.tag=1,g.payload=r,c!=null&&(g.callback=c),r=zn(s,g,m),r!==null&&(Gt(r,s,m,u),qr(r,s,m))},enqueueForceUpdate:function(s,r){s=s._reactInternals;var c=pt(),u=Wn(s),m=kn(c,u);m.tag=2,r!=null&&(m.callback=r),r=zn(s,m,u),r!==null&&(Gt(r,s,u,c),qr(r,s,u))}};function Xh(s,r,c,u,m,g,x){return s=s.stateNode,typeof s.shouldComponentUpdate=="function"?s.shouldComponentUpdate(u,g,x):r.prototype&&r.prototype.isPureReactComponent?!Ci(c,u)||!Ci(m,g):!0}function Zh(s,r,c){var u=!1,m=Pn,g=r.contextType;return typeof g=="object"&&g!==null?g=Mt(g):(m=vt(r)?es:lt.current,u=r.contextTypes,g=(u=u!=null)?Is(s,m):Pn),r=new r(c,g),s.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=no,s.stateNode=r,r._reactInternals=s,u&&(s=s.stateNode,s.__reactInternalMemoizedUnmaskedChildContext=m,s.__reactInternalMemoizedMaskedChildContext=g),r}function ef(s,r,c,u){s=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(c,u),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(c,u),r.state!==s&&no.enqueueReplaceState(r,r.state,null)}function Hl(s,r,c,u){var m=s.stateNode;m.props=c,m.state=s.memoizedState,m.refs={},Al(s);var g=r.contextType;typeof g=="object"&&g!==null?m.context=Mt(g):(g=vt(r)?es:lt.current,m.context=Is(s,g)),m.state=s.memoizedState,g=r.getDerivedStateFromProps,typeof g=="function"&&(Wl(s,r,g,c),m.state=s.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof m.getSnapshotBeforeUpdate=="function"||typeof m.UNSAFE_componentWillMount!="function"&&typeof m.componentWillMount!="function"||(r=m.state,typeof m.componentWillMount=="function"&&m.componentWillMount(),typeof m.UNSAFE_componentWillMount=="function"&&m.UNSAFE_componentWillMount(),r!==m.state&&no.enqueueReplaceState(m,m.state,null),Qr(s,c,m,u),m.state=s.memoizedState),typeof m.componentDidMount=="function"&&(s.flags|=4194308)}function zs(s,r){try{var c="",u=r;do c+=we(u),u=u.return;while(u);var m=c}catch(g){m=`
|
|
39
|
+
Error generating stack: `+g.message+`
|
|
40
|
+
`+g.stack}return{value:s,source:r,stack:m,digest:null}}function Kl(s,r,c){return{value:s,source:null,stack:c??null,digest:r??null}}function Vl(s,r){try{console.error(r.value)}catch(c){setTimeout(function(){throw c})}}var Hy=typeof WeakMap=="function"?WeakMap:Map;function tf(s,r,c){c=kn(-1,c),c.tag=3,c.payload={element:null};var u=r.value;return c.callback=function(){co||(co=!0,ac=u),Vl(s,r)},c}function nf(s,r,c){c=kn(-1,c),c.tag=3;var u=s.type.getDerivedStateFromError;if(typeof u=="function"){var m=r.value;c.payload=function(){return u(m)},c.callback=function(){Vl(s,r)}}var g=s.stateNode;return g!==null&&typeof g.componentDidCatch=="function"&&(c.callback=function(){Vl(s,r),typeof u!="function"&&(Fn===null?Fn=new Set([this]):Fn.add(this));var x=r.stack;this.componentDidCatch(r.value,{componentStack:x!==null?x:""})}),c}function sf(s,r,c){var u=s.pingCache;if(u===null){u=s.pingCache=new Hy;var m=new Set;u.set(r,m)}else m=u.get(r),m===void 0&&(m=new Set,u.set(r,m));m.has(c)||(m.add(c),s=iw.bind(null,s,r,c),r.then(s,s))}function rf(s){do{var r;if((r=s.tag===13)&&(r=s.memoizedState,r=r!==null?r.dehydrated!==null:!0),r)return s;s=s.return}while(s!==null);return null}function of(s,r,c,u,m){return(s.mode&1)===0?(s===r?s.flags|=65536:(s.flags|=128,c.flags|=131072,c.flags&=-52805,c.tag===1&&(c.alternate===null?c.tag=17:(r=kn(-1,1),r.tag=2,zn(c,r,1))),c.lanes|=1),s):(s.flags|=65536,s.lanes=m,s)}var Ky=D.ReactCurrentOwner,kt=!1;function mt(s,r,c,u){r.child=s===null?bh(r,null,c,u):Os(r,s.child,c,u)}function af(s,r,c,u,m){c=c.render;var g=r.ref;return _s(r,m),u=_l(s,r,c,u,g,m),c=Dl(),s!==null&&!kt?(r.updateQueue=s.updateQueue,r.flags&=-2053,s.lanes&=~m,yn(s,r,m)):(Pe&&c&&wl(r),r.flags|=1,mt(s,r,u,m),r.child)}function lf(s,r,c,u,m){if(s===null){var g=c.type;return typeof g=="function"&&!mc(g)&&g.defaultProps===void 0&&c.compare===null&&c.defaultProps===void 0?(r.tag=15,r.type=g,cf(s,r,g,u,m)):(s=go(c.type,null,u,r,r.mode,m),s.ref=r.ref,s.return=r,r.child=s)}if(g=s.child,(s.lanes&m)===0){var x=g.memoizedProps;if(c=c.compare,c=c!==null?c:Ci,c(x,u)&&s.ref===r.ref)return yn(s,r,m)}return r.flags|=1,s=Kn(g,u),s.ref=r.ref,s.return=r,r.child=s}function cf(s,r,c,u,m){if(s!==null){var g=s.memoizedProps;if(Ci(g,u)&&s.ref===r.ref)if(kt=!1,r.pendingProps=u=g,(s.lanes&m)!==0)(s.flags&131072)!==0&&(kt=!0);else return r.lanes=s.lanes,yn(s,r,m)}return Gl(s,r,c,u,m)}function df(s,r,c){var u=r.pendingProps,m=u.children,g=s!==null?s.memoizedState:null;if(u.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},Re(Fs,Tt),Tt|=c;else{if((c&1073741824)===0)return s=g!==null?g.baseLanes|c:c,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:s,cachePool:null,transitions:null},r.updateQueue=null,Re(Fs,Tt),Tt|=s,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},u=g!==null?g.baseLanes:c,Re(Fs,Tt),Tt|=u}else g!==null?(u=g.baseLanes|c,r.memoizedState=null):u=c,Re(Fs,Tt),Tt|=u;return mt(s,r,m,c),r.child}function uf(s,r){var c=r.ref;(s===null&&c!==null||s!==null&&s.ref!==c)&&(r.flags|=512,r.flags|=2097152)}function Gl(s,r,c,u,m){var g=vt(c)?es:lt.current;return g=Is(r,g),_s(r,m),c=_l(s,r,c,u,g,m),u=Dl(),s!==null&&!kt?(r.updateQueue=s.updateQueue,r.flags&=-2053,s.lanes&=~m,yn(s,r,m)):(Pe&&u&&wl(r),r.flags|=1,mt(s,r,c,m),r.child)}function hf(s,r,c,u,m){if(vt(c)){var g=!0;Br(r)}else g=!1;if(_s(r,m),r.stateNode===null)io(s,r),Zh(r,c,u),Hl(r,c,u,m),u=!0;else if(s===null){var x=r.stateNode,b=r.memoizedProps;x.props=b;var C=x.context,L=c.contextType;typeof L=="object"&&L!==null?L=Mt(L):(L=vt(c)?es:lt.current,L=Is(r,L));var U=c.getDerivedStateFromProps,K=typeof U=="function"||typeof x.getSnapshotBeforeUpdate=="function";K||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(b!==u||C!==L)&&ef(r,x,u,L),Dn=!1;var B=r.memoizedState;x.state=B,Qr(r,u,x,m),C=r.memoizedState,b!==u||B!==C||gt.current||Dn?(typeof U=="function"&&(Wl(r,c,U,u),C=r.memoizedState),(b=Dn||Xh(r,c,b,u,B,C,L))?(K||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount()),typeof x.componentDidMount=="function"&&(r.flags|=4194308)):(typeof x.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=u,r.memoizedState=C),x.props=u,x.state=C,x.context=L,u=b):(typeof x.componentDidMount=="function"&&(r.flags|=4194308),u=!1)}else{x=r.stateNode,Ch(s,r),b=r.memoizedProps,L=r.type===r.elementType?b:Ht(r.type,b),x.props=L,K=r.pendingProps,B=x.context,C=c.contextType,typeof C=="object"&&C!==null?C=Mt(C):(C=vt(c)?es:lt.current,C=Is(r,C));var ee=c.getDerivedStateFromProps;(U=typeof ee=="function"||typeof x.getSnapshotBeforeUpdate=="function")||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(b!==K||B!==C)&&ef(r,x,u,C),Dn=!1,B=r.memoizedState,x.state=B,Qr(r,u,x,m);var se=r.memoizedState;b!==K||B!==se||gt.current||Dn?(typeof ee=="function"&&(Wl(r,c,ee,u),se=r.memoizedState),(L=Dn||Xh(r,c,L,u,B,se,C)||!1)?(U||typeof x.UNSAFE_componentWillUpdate!="function"&&typeof x.componentWillUpdate!="function"||(typeof x.componentWillUpdate=="function"&&x.componentWillUpdate(u,se,C),typeof x.UNSAFE_componentWillUpdate=="function"&&x.UNSAFE_componentWillUpdate(u,se,C)),typeof x.componentDidUpdate=="function"&&(r.flags|=4),typeof x.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof x.componentDidUpdate!="function"||b===s.memoizedProps&&B===s.memoizedState||(r.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||b===s.memoizedProps&&B===s.memoizedState||(r.flags|=1024),r.memoizedProps=u,r.memoizedState=se),x.props=u,x.state=se,x.context=C,u=L):(typeof x.componentDidUpdate!="function"||b===s.memoizedProps&&B===s.memoizedState||(r.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||b===s.memoizedProps&&B===s.memoizedState||(r.flags|=1024),u=!1)}return ql(s,r,c,u,g,m)}function ql(s,r,c,u,m,g){uf(s,r);var x=(r.flags&128)!==0;if(!u&&!x)return m&&gh(r,c,!1),yn(s,r,g);u=r.stateNode,Ky.current=r;var b=x&&typeof c.getDerivedStateFromError!="function"?null:u.render();return r.flags|=1,s!==null&&x?(r.child=Os(r,s.child,null,g),r.child=Os(r,null,b,g)):mt(s,r,b,g),r.memoizedState=u.state,m&&gh(r,c,!0),r.child}function ff(s){var r=s.stateNode;r.pendingContext?mh(s,r.pendingContext,r.pendingContext!==r.context):r.context&&mh(s,r.context,!1),Il(s,r.containerInfo)}function mf(s,r,c,u,m){return Ls(),Nl(m),r.flags|=256,mt(s,r,c,u),r.child}var Ql={dehydrated:null,treeContext:null,retryLane:0};function Yl(s){return{baseLanes:s,cachePool:null,transitions:null}}function pf(s,r,c){var u=r.pendingProps,m=_e.current,g=!1,x=(r.flags&128)!==0,b;if((b=x)||(b=s!==null&&s.memoizedState===null?!1:(m&2)!==0),b?(g=!0,r.flags&=-129):(s===null||s.memoizedState!==null)&&(m|=1),Re(_e,m&1),s===null)return Sl(r),s=r.memoizedState,s!==null&&(s=s.dehydrated,s!==null)?((r.mode&1)===0?r.lanes=1:s.data==="$!"?r.lanes=8:r.lanes=1073741824,null):(x=u.children,s=u.fallback,g?(u=r.mode,g=r.child,x={mode:"hidden",children:x},(u&1)===0&&g!==null?(g.childLanes=0,g.pendingProps=x):g=vo(x,u,0,null),s=ds(s,u,c,null),g.return=r,s.return=r,g.sibling=s,r.child=g,r.child.memoizedState=Yl(c),r.memoizedState=Ql,s):Jl(r,x));if(m=s.memoizedState,m!==null&&(b=m.dehydrated,b!==null))return Vy(s,r,x,u,b,m,c);if(g){g=u.fallback,x=r.mode,m=s.child,b=m.sibling;var C={mode:"hidden",children:u.children};return(x&1)===0&&r.child!==m?(u=r.child,u.childLanes=0,u.pendingProps=C,r.deletions=null):(u=Kn(m,C),u.subtreeFlags=m.subtreeFlags&14680064),b!==null?g=Kn(b,g):(g=ds(g,x,c,null),g.flags|=2),g.return=r,u.return=r,u.sibling=g,r.child=u,u=g,g=r.child,x=s.child.memoizedState,x=x===null?Yl(c):{baseLanes:x.baseLanes|c,cachePool:null,transitions:x.transitions},g.memoizedState=x,g.childLanes=s.childLanes&~c,r.memoizedState=Ql,u}return g=s.child,s=g.sibling,u=Kn(g,{mode:"visible",children:u.children}),(r.mode&1)===0&&(u.lanes=c),u.return=r,u.sibling=null,s!==null&&(c=r.deletions,c===null?(r.deletions=[s],r.flags|=16):c.push(s)),r.child=u,r.memoizedState=null,u}function Jl(s,r){return r=vo({mode:"visible",children:r},s.mode,0,null),r.return=s,s.child=r}function so(s,r,c,u){return u!==null&&Nl(u),Os(r,s.child,null,c),s=Jl(r,r.pendingProps.children),s.flags|=2,r.memoizedState=null,s}function Vy(s,r,c,u,m,g,x){if(c)return r.flags&256?(r.flags&=-257,u=Kl(Error(n(422))),so(s,r,x,u)):r.memoizedState!==null?(r.child=s.child,r.flags|=128,null):(g=u.fallback,m=r.mode,u=vo({mode:"visible",children:u.children},m,0,null),g=ds(g,m,x,null),g.flags|=2,u.return=r,g.return=r,u.sibling=g,r.child=u,(r.mode&1)!==0&&Os(r,s.child,null,x),r.child.memoizedState=Yl(x),r.memoizedState=Ql,g);if((r.mode&1)===0)return so(s,r,x,null);if(m.data==="$!"){if(u=m.nextSibling&&m.nextSibling.dataset,u)var b=u.dgst;return u=b,g=Error(n(419)),u=Kl(g,u,void 0),so(s,r,x,u)}if(b=(x&s.childLanes)!==0,kt||b){if(u=tt,u!==null){switch(x&-x){case 4:m=2;break;case 16:m=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:m=32;break;case 536870912:m=268435456;break;default:m=0}m=(m&(u.suspendedLanes|x))!==0?0:m,m!==0&&m!==g.retryLane&&(g.retryLane=m,vn(s,m),Gt(u,s,m,-1))}return fc(),u=Kl(Error(n(421))),so(s,r,x,u)}return m.data==="$?"?(r.flags|=128,r.child=s.child,r=rw.bind(null,s),m._reactRetry=r,null):(s=g.treeContext,Ct=Ln(m.nextSibling),$t=r,Pe=!0,Wt=null,s!==null&&(It[Rt++]=pn,It[Rt++]=gn,It[Rt++]=ts,pn=s.id,gn=s.overflow,ts=r),r=Jl(r,u.children),r.flags|=4096,r)}function gf(s,r,c){s.lanes|=r;var u=s.alternate;u!==null&&(u.lanes|=r),Tl(s.return,r,c)}function Xl(s,r,c,u,m){var g=s.memoizedState;g===null?s.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:u,tail:c,tailMode:m}:(g.isBackwards=r,g.rendering=null,g.renderingStartTime=0,g.last=u,g.tail=c,g.tailMode=m)}function vf(s,r,c){var u=r.pendingProps,m=u.revealOrder,g=u.tail;if(mt(s,r,u.children,c),u=_e.current,(u&2)!==0)u=u&1|2,r.flags|=128;else{if(s!==null&&(s.flags&128)!==0)e:for(s=r.child;s!==null;){if(s.tag===13)s.memoizedState!==null&&gf(s,c,r);else if(s.tag===19)gf(s,c,r);else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===r)break e;for(;s.sibling===null;){if(s.return===null||s.return===r)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}u&=1}if(Re(_e,u),(r.mode&1)===0)r.memoizedState=null;else switch(m){case"forwards":for(c=r.child,m=null;c!==null;)s=c.alternate,s!==null&&Yr(s)===null&&(m=c),c=c.sibling;c=m,c===null?(m=r.child,r.child=null):(m=c.sibling,c.sibling=null),Xl(r,!1,m,c,g);break;case"backwards":for(c=null,m=r.child,r.child=null;m!==null;){if(s=m.alternate,s!==null&&Yr(s)===null){r.child=m;break}s=m.sibling,m.sibling=c,c=m,m=s}Xl(r,!0,c,null,g);break;case"together":Xl(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function io(s,r){(r.mode&1)===0&&s!==null&&(s.alternate=null,r.alternate=null,r.flags|=2)}function yn(s,r,c){if(s!==null&&(r.dependencies=s.dependencies),os|=r.lanes,(c&r.childLanes)===0)return null;if(s!==null&&r.child!==s.child)throw Error(n(153));if(r.child!==null){for(s=r.child,c=Kn(s,s.pendingProps),r.child=c,c.return=r;s.sibling!==null;)s=s.sibling,c=c.sibling=Kn(s,s.pendingProps),c.return=r;c.sibling=null}return r.child}function Gy(s,r,c){switch(r.tag){case 3:ff(r),Ls();break;case 5:Ah(r);break;case 1:vt(r.type)&&Br(r);break;case 4:Il(r,r.stateNode.containerInfo);break;case 10:var u=r.type._context,m=r.memoizedProps.value;Re(Vr,u._currentValue),u._currentValue=m;break;case 13:if(u=r.memoizedState,u!==null)return u.dehydrated!==null?(Re(_e,_e.current&1),r.flags|=128,null):(c&r.child.childLanes)!==0?pf(s,r,c):(Re(_e,_e.current&1),s=yn(s,r,c),s!==null?s.sibling:null);Re(_e,_e.current&1);break;case 19:if(u=(c&r.childLanes)!==0,(s.flags&128)!==0){if(u)return vf(s,r,c);r.flags|=128}if(m=r.memoizedState,m!==null&&(m.rendering=null,m.tail=null,m.lastEffect=null),Re(_e,_e.current),u)break;return null;case 22:case 23:return r.lanes=0,df(s,r,c)}return yn(s,r,c)}var kf,Zl,yf,wf;kf=function(s,r){for(var c=r.child;c!==null;){if(c.tag===5||c.tag===6)s.appendChild(c.stateNode);else if(c.tag!==4&&c.child!==null){c.child.return=c,c=c.child;continue}if(c===r)break;for(;c.sibling===null;){if(c.return===null||c.return===r)return;c=c.return}c.sibling.return=c.return,c=c.sibling}},Zl=function(){},yf=function(s,r,c,u){var m=s.memoizedProps;if(m!==u){s=r.stateNode,is(tn.current);var g=null;switch(c){case"input":m=Ta(s,m),u=Ta(s,u),g=[];break;case"select":m=z({},m,{value:void 0}),u=z({},u,{value:void 0}),g=[];break;case"textarea":m=Ia(s,m),u=Ia(s,u),g=[];break;default:typeof m.onClick!="function"&&typeof u.onClick=="function"&&(s.onclick=_r)}Ma(c,u);var x;c=null;for(L in m)if(!u.hasOwnProperty(L)&&m.hasOwnProperty(L)&&m[L]!=null)if(L==="style"){var b=m[L];for(x in b)b.hasOwnProperty(x)&&(c||(c={}),c[x]="")}else L!=="dangerouslySetInnerHTML"&&L!=="children"&&L!=="suppressContentEditableWarning"&&L!=="suppressHydrationWarning"&&L!=="autoFocus"&&(a.hasOwnProperty(L)?g||(g=[]):(g=g||[]).push(L,null));for(L in u){var C=u[L];if(b=m!=null?m[L]:void 0,u.hasOwnProperty(L)&&C!==b&&(C!=null||b!=null))if(L==="style")if(b){for(x in b)!b.hasOwnProperty(x)||C&&C.hasOwnProperty(x)||(c||(c={}),c[x]="");for(x in C)C.hasOwnProperty(x)&&b[x]!==C[x]&&(c||(c={}),c[x]=C[x])}else c||(g||(g=[]),g.push(L,c)),c=C;else L==="dangerouslySetInnerHTML"?(C=C?C.__html:void 0,b=b?b.__html:void 0,C!=null&&b!==C&&(g=g||[]).push(L,C)):L==="children"?typeof C!="string"&&typeof C!="number"||(g=g||[]).push(L,""+C):L!=="suppressContentEditableWarning"&&L!=="suppressHydrationWarning"&&(a.hasOwnProperty(L)?(C!=null&&L==="onScroll"&&Me("scroll",s),g||b===C||(g=[])):(g=g||[]).push(L,C))}c&&(g=g||[]).push("style",c);var L=g;(r.updateQueue=L)&&(r.flags|=4)}},wf=function(s,r,c,u){c!==u&&(r.flags|=4)};function Ui(s,r){if(!Pe)switch(s.tailMode){case"hidden":r=s.tail;for(var c=null;r!==null;)r.alternate!==null&&(c=r),r=r.sibling;c===null?s.tail=null:c.sibling=null;break;case"collapsed":c=s.tail;for(var u=null;c!==null;)c.alternate!==null&&(u=c),c=c.sibling;u===null?r||s.tail===null?s.tail=null:s.tail.sibling=null:u.sibling=null}}function dt(s){var r=s.alternate!==null&&s.alternate.child===s.child,c=0,u=0;if(r)for(var m=s.child;m!==null;)c|=m.lanes|m.childLanes,u|=m.subtreeFlags&14680064,u|=m.flags&14680064,m.return=s,m=m.sibling;else for(m=s.child;m!==null;)c|=m.lanes|m.childLanes,u|=m.subtreeFlags,u|=m.flags,m.return=s,m=m.sibling;return s.subtreeFlags|=u,s.childLanes=c,r}function qy(s,r,c){var u=r.pendingProps;switch(xl(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return dt(r),null;case 1:return vt(r.type)&&zr(),dt(r),null;case 3:return u=r.stateNode,Ds(),Le(gt),Le(lt),Ll(),u.pendingContext&&(u.context=u.pendingContext,u.pendingContext=null),(s===null||s.child===null)&&(Hr(r)?r.flags|=4:s===null||s.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,Wt!==null&&(dc(Wt),Wt=null))),Zl(s,r),dt(r),null;case 5:Rl(r);var m=is(_i.current);if(c=r.type,s!==null&&r.stateNode!=null)yf(s,r,c,u,m),s.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!u){if(r.stateNode===null)throw Error(n(166));return dt(r),null}if(s=is(tn.current),Hr(r)){u=r.stateNode,c=r.type;var g=r.memoizedProps;switch(u[en]=r,u[Ri]=g,s=(r.mode&1)!==0,c){case"dialog":Me("cancel",u),Me("close",u);break;case"iframe":case"object":case"embed":Me("load",u);break;case"video":case"audio":for(m=0;m<Ei.length;m++)Me(Ei[m],u);break;case"source":Me("error",u);break;case"img":case"image":case"link":Me("error",u),Me("load",u);break;case"details":Me("toggle",u);break;case"input":Zd(u,g),Me("invalid",u);break;case"select":u._wrapperState={wasMultiple:!!g.multiple},Me("invalid",u);break;case"textarea":nu(u,g),Me("invalid",u)}Ma(c,g),m=null;for(var x in g)if(g.hasOwnProperty(x)){var b=g[x];x==="children"?typeof b=="string"?u.textContent!==b&&(g.suppressHydrationWarning!==!0&&Pr(u.textContent,b,s),m=["children",b]):typeof b=="number"&&u.textContent!==""+b&&(g.suppressHydrationWarning!==!0&&Pr(u.textContent,b,s),m=["children",""+b]):a.hasOwnProperty(x)&&b!=null&&x==="onScroll"&&Me("scroll",u)}switch(c){case"input":Cn(u),tu(u,g,!0);break;case"textarea":Cn(u),iu(u);break;case"select":case"option":break;default:typeof g.onClick=="function"&&(u.onclick=_r)}u=m,r.updateQueue=u,u!==null&&(r.flags|=4)}else{x=m.nodeType===9?m:m.ownerDocument,s==="http://www.w3.org/1999/xhtml"&&(s=ru(c)),s==="http://www.w3.org/1999/xhtml"?c==="script"?(s=x.createElement("div"),s.innerHTML="<script><\/script>",s=s.removeChild(s.firstChild)):typeof u.is=="string"?s=x.createElement(c,{is:u.is}):(s=x.createElement(c),c==="select"&&(x=s,u.multiple?x.multiple=!0:u.size&&(x.size=u.size))):s=x.createElementNS(s,c),s[en]=r,s[Ri]=u,kf(s,r,!1,!1),r.stateNode=s;e:{switch(x=La(c,u),c){case"dialog":Me("cancel",s),Me("close",s),m=u;break;case"iframe":case"object":case"embed":Me("load",s),m=u;break;case"video":case"audio":for(m=0;m<Ei.length;m++)Me(Ei[m],s);m=u;break;case"source":Me("error",s),m=u;break;case"img":case"image":case"link":Me("error",s),Me("load",s),m=u;break;case"details":Me("toggle",s),m=u;break;case"input":Zd(s,u),m=Ta(s,u),Me("invalid",s);break;case"option":m=u;break;case"select":s._wrapperState={wasMultiple:!!u.multiple},m=z({},u,{value:void 0}),Me("invalid",s);break;case"textarea":nu(s,u),m=Ia(s,u),Me("invalid",s);break;default:m=u}Ma(c,m),b=m;for(g in b)if(b.hasOwnProperty(g)){var C=b[g];g==="style"?lu(s,C):g==="dangerouslySetInnerHTML"?(C=C?C.__html:void 0,C!=null&&ou(s,C)):g==="children"?typeof C=="string"?(c!=="textarea"||C!=="")&&di(s,C):typeof C=="number"&&di(s,""+C):g!=="suppressContentEditableWarning"&&g!=="suppressHydrationWarning"&&g!=="autoFocus"&&(a.hasOwnProperty(g)?C!=null&&g==="onScroll"&&Me("scroll",s):C!=null&&O(s,g,C,x))}switch(c){case"input":Cn(s),tu(s,u,!1);break;case"textarea":Cn(s),iu(s);break;case"option":u.value!=null&&s.setAttribute("value",""+Se(u.value));break;case"select":s.multiple=!!u.multiple,g=u.value,g!=null?ys(s,!!u.multiple,g,!1):u.defaultValue!=null&&ys(s,!!u.multiple,u.defaultValue,!0);break;default:typeof m.onClick=="function"&&(s.onclick=_r)}switch(c){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}}u&&(r.flags|=4)}r.ref!==null&&(r.flags|=512,r.flags|=2097152)}return dt(r),null;case 6:if(s&&r.stateNode!=null)wf(s,r,s.memoizedProps,u);else{if(typeof u!="string"&&r.stateNode===null)throw Error(n(166));if(c=is(_i.current),is(tn.current),Hr(r)){if(u=r.stateNode,c=r.memoizedProps,u[en]=r,(g=u.nodeValue!==c)&&(s=$t,s!==null))switch(s.tag){case 3:Pr(u.nodeValue,c,(s.mode&1)!==0);break;case 5:s.memoizedProps.suppressHydrationWarning!==!0&&Pr(u.nodeValue,c,(s.mode&1)!==0)}g&&(r.flags|=4)}else u=(c.nodeType===9?c:c.ownerDocument).createTextNode(u),u[en]=r,r.stateNode=u}return dt(r),null;case 13:if(Le(_e),u=r.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(Pe&&Ct!==null&&(r.mode&1)!==0&&(r.flags&128)===0)jh(),Ls(),r.flags|=98560,g=!1;else if(g=Hr(r),u!==null&&u.dehydrated!==null){if(s===null){if(!g)throw Error(n(318));if(g=r.memoizedState,g=g!==null?g.dehydrated:null,!g)throw Error(n(317));g[en]=r}else Ls(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;dt(r),g=!1}else Wt!==null&&(dc(Wt),Wt=null),g=!0;if(!g)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=c,r):(u=u!==null,u!==(s!==null&&s.memoizedState!==null)&&u&&(r.child.flags|=8192,(r.mode&1)!==0&&(s===null||(_e.current&1)!==0?Xe===0&&(Xe=3):fc())),r.updateQueue!==null&&(r.flags|=4),dt(r),null);case 4:return Ds(),Zl(s,r),s===null&&Ai(r.stateNode.containerInfo),dt(r),null;case 10:return Cl(r.type._context),dt(r),null;case 17:return vt(r.type)&&zr(),dt(r),null;case 19:if(Le(_e),g=r.memoizedState,g===null)return dt(r),null;if(u=(r.flags&128)!==0,x=g.rendering,x===null)if(u)Ui(g,!1);else{if(Xe!==0||s!==null&&(s.flags&128)!==0)for(s=r.child;s!==null;){if(x=Yr(s),x!==null){for(r.flags|=128,Ui(g,!1),u=x.updateQueue,u!==null&&(r.updateQueue=u,r.flags|=4),r.subtreeFlags=0,u=c,c=r.child;c!==null;)g=c,s=u,g.flags&=14680066,x=g.alternate,x===null?(g.childLanes=0,g.lanes=s,g.child=null,g.subtreeFlags=0,g.memoizedProps=null,g.memoizedState=null,g.updateQueue=null,g.dependencies=null,g.stateNode=null):(g.childLanes=x.childLanes,g.lanes=x.lanes,g.child=x.child,g.subtreeFlags=0,g.deletions=null,g.memoizedProps=x.memoizedProps,g.memoizedState=x.memoizedState,g.updateQueue=x.updateQueue,g.type=x.type,s=x.dependencies,g.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext}),c=c.sibling;return Re(_e,_e.current&1|2),r.child}s=s.sibling}g.tail!==null&&We()>Us&&(r.flags|=128,u=!0,Ui(g,!1),r.lanes=4194304)}else{if(!u)if(s=Yr(x),s!==null){if(r.flags|=128,u=!0,c=s.updateQueue,c!==null&&(r.updateQueue=c,r.flags|=4),Ui(g,!0),g.tail===null&&g.tailMode==="hidden"&&!x.alternate&&!Pe)return dt(r),null}else 2*We()-g.renderingStartTime>Us&&c!==1073741824&&(r.flags|=128,u=!0,Ui(g,!1),r.lanes=4194304);g.isBackwards?(x.sibling=r.child,r.child=x):(c=g.last,c!==null?c.sibling=x:r.child=x,g.last=x)}return g.tail!==null?(r=g.tail,g.rendering=r,g.tail=r.sibling,g.renderingStartTime=We(),r.sibling=null,c=_e.current,Re(_e,u?c&1|2:c&1),r):(dt(r),null);case 22:case 23:return hc(),u=r.memoizedState!==null,s!==null&&s.memoizedState!==null!==u&&(r.flags|=8192),u&&(r.mode&1)!==0?(Tt&1073741824)!==0&&(dt(r),r.subtreeFlags&6&&(r.flags|=8192)):dt(r),null;case 24:return null;case 25:return null}throw Error(n(156,r.tag))}function Qy(s,r){switch(xl(r),r.tag){case 1:return vt(r.type)&&zr(),s=r.flags,s&65536?(r.flags=s&-65537|128,r):null;case 3:return Ds(),Le(gt),Le(lt),Ll(),s=r.flags,(s&65536)!==0&&(s&128)===0?(r.flags=s&-65537|128,r):null;case 5:return Rl(r),null;case 13:if(Le(_e),s=r.memoizedState,s!==null&&s.dehydrated!==null){if(r.alternate===null)throw Error(n(340));Ls()}return s=r.flags,s&65536?(r.flags=s&-65537|128,r):null;case 19:return Le(_e),null;case 4:return Ds(),null;case 10:return Cl(r.type._context),null;case 22:case 23:return hc(),null;case 24:return null;default:return null}}var ro=!1,ut=!1,Yy=typeof WeakSet=="function"?WeakSet:Set,te=null;function Bs(s,r){var c=s.ref;if(c!==null)if(typeof c=="function")try{c(null)}catch(u){Ue(s,r,u)}else c.current=null}function ec(s,r,c){try{c()}catch(u){Ue(s,r,u)}}var xf=!1;function Jy(s,r){if(hl=br,s=Xu(),il(s)){if("selectionStart"in s)var c={start:s.selectionStart,end:s.selectionEnd};else e:{c=(c=s.ownerDocument)&&c.defaultView||window;var u=c.getSelection&&c.getSelection();if(u&&u.rangeCount!==0){c=u.anchorNode;var m=u.anchorOffset,g=u.focusNode;u=u.focusOffset;try{c.nodeType,g.nodeType}catch{c=null;break e}var x=0,b=-1,C=-1,L=0,U=0,K=s,B=null;t:for(;;){for(var ee;K!==c||m!==0&&K.nodeType!==3||(b=x+m),K!==g||u!==0&&K.nodeType!==3||(C=x+u),K.nodeType===3&&(x+=K.nodeValue.length),(ee=K.firstChild)!==null;)B=K,K=ee;for(;;){if(K===s)break t;if(B===c&&++L===m&&(b=x),B===g&&++U===u&&(C=x),(ee=K.nextSibling)!==null)break;K=B,B=K.parentNode}K=ee}c=b===-1||C===-1?null:{start:b,end:C}}else c=null}c=c||{start:0,end:0}}else c=null;for(fl={focusedElem:s,selectionRange:c},br=!1,te=r;te!==null;)if(r=te,s=r.child,(r.subtreeFlags&1028)!==0&&s!==null)s.return=r,te=s;else for(;te!==null;){r=te;try{var se=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(se!==null){var re=se.memoizedProps,He=se.memoizedState,A=r.stateNode,E=A.getSnapshotBeforeUpdate(r.elementType===r.type?re:Ht(r.type,re),He);A.__reactInternalSnapshotBeforeUpdate=E}break;case 3:var R=r.stateNode.containerInfo;R.nodeType===1?R.textContent="":R.nodeType===9&&R.documentElement&&R.removeChild(R.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Y){Ue(r,r.return,Y)}if(s=r.sibling,s!==null){s.return=r.return,te=s;break}te=r.return}return se=xf,xf=!1,se}function Wi(s,r,c){var u=r.updateQueue;if(u=u!==null?u.lastEffect:null,u!==null){var m=u=u.next;do{if((m.tag&s)===s){var g=m.destroy;m.destroy=void 0,g!==void 0&&ec(r,c,g)}m=m.next}while(m!==u)}}function oo(s,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var c=r=r.next;do{if((c.tag&s)===s){var u=c.create;c.destroy=u()}c=c.next}while(c!==r)}}function tc(s){var r=s.ref;if(r!==null){var c=s.stateNode;switch(s.tag){case 5:s=c;break;default:s=c}typeof r=="function"?r(s):r.current=s}}function jf(s){var r=s.alternate;r!==null&&(s.alternate=null,jf(r)),s.child=null,s.deletions=null,s.sibling=null,s.tag===5&&(r=s.stateNode,r!==null&&(delete r[en],delete r[Ri],delete r[vl],delete r[My],delete r[Ly])),s.stateNode=null,s.return=null,s.dependencies=null,s.memoizedProps=null,s.memoizedState=null,s.pendingProps=null,s.stateNode=null,s.updateQueue=null}function Sf(s){return s.tag===5||s.tag===3||s.tag===4}function Nf(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||Sf(s.return))return null;s=s.return}for(s.sibling.return=s.return,s=s.sibling;s.tag!==5&&s.tag!==6&&s.tag!==18;){if(s.flags&2||s.child===null||s.tag===4)continue e;s.child.return=s,s=s.child}if(!(s.flags&2))return s.stateNode}}function nc(s,r,c){var u=s.tag;if(u===5||u===6)s=s.stateNode,r?c.nodeType===8?c.parentNode.insertBefore(s,r):c.insertBefore(s,r):(c.nodeType===8?(r=c.parentNode,r.insertBefore(s,c)):(r=c,r.appendChild(s)),c=c._reactRootContainer,c!=null||r.onclick!==null||(r.onclick=_r));else if(u!==4&&(s=s.child,s!==null))for(nc(s,r,c),s=s.sibling;s!==null;)nc(s,r,c),s=s.sibling}function sc(s,r,c){var u=s.tag;if(u===5||u===6)s=s.stateNode,r?c.insertBefore(s,r):c.appendChild(s);else if(u!==4&&(s=s.child,s!==null))for(sc(s,r,c),s=s.sibling;s!==null;)sc(s,r,c),s=s.sibling}var it=null,Kt=!1;function Bn(s,r,c){for(c=c.child;c!==null;)bf(s,r,c),c=c.sibling}function bf(s,r,c){if(Zt&&typeof Zt.onCommitFiberUnmount=="function")try{Zt.onCommitFiberUnmount(yr,c)}catch{}switch(c.tag){case 5:ut||Bs(c,r);case 6:var u=it,m=Kt;it=null,Bn(s,r,c),it=u,Kt=m,it!==null&&(Kt?(s=it,c=c.stateNode,s.nodeType===8?s.parentNode.removeChild(c):s.removeChild(c)):it.removeChild(c.stateNode));break;case 18:it!==null&&(Kt?(s=it,c=c.stateNode,s.nodeType===8?gl(s.parentNode,c):s.nodeType===1&&gl(s,c),xi(s)):gl(it,c.stateNode));break;case 4:u=it,m=Kt,it=c.stateNode.containerInfo,Kt=!0,Bn(s,r,c),it=u,Kt=m;break;case 0:case 11:case 14:case 15:if(!ut&&(u=c.updateQueue,u!==null&&(u=u.lastEffect,u!==null))){m=u=u.next;do{var g=m,x=g.destroy;g=g.tag,x!==void 0&&((g&2)!==0||(g&4)!==0)&&ec(c,r,x),m=m.next}while(m!==u)}Bn(s,r,c);break;case 1:if(!ut&&(Bs(c,r),u=c.stateNode,typeof u.componentWillUnmount=="function"))try{u.props=c.memoizedProps,u.state=c.memoizedState,u.componentWillUnmount()}catch(b){Ue(c,r,b)}Bn(s,r,c);break;case 21:Bn(s,r,c);break;case 22:c.mode&1?(ut=(u=ut)||c.memoizedState!==null,Bn(s,r,c),ut=u):Bn(s,r,c);break;default:Bn(s,r,c)}}function $f(s){var r=s.updateQueue;if(r!==null){s.updateQueue=null;var c=s.stateNode;c===null&&(c=s.stateNode=new Yy),r.forEach(function(u){var m=ow.bind(null,s,u);c.has(u)||(c.add(u),u.then(m,m))})}}function Vt(s,r){var c=r.deletions;if(c!==null)for(var u=0;u<c.length;u++){var m=c[u];try{var g=s,x=r,b=x;e:for(;b!==null;){switch(b.tag){case 5:it=b.stateNode,Kt=!1;break e;case 3:it=b.stateNode.containerInfo,Kt=!0;break e;case 4:it=b.stateNode.containerInfo,Kt=!0;break e}b=b.return}if(it===null)throw Error(n(160));bf(g,x,m),it=null,Kt=!1;var C=m.alternate;C!==null&&(C.return=null),m.return=null}catch(L){Ue(m,r,L)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)Cf(r,s),r=r.sibling}function Cf(s,r){var c=s.alternate,u=s.flags;switch(s.tag){case 0:case 11:case 14:case 15:if(Vt(r,s),sn(s),u&4){try{Wi(3,s,s.return),oo(3,s)}catch(re){Ue(s,s.return,re)}try{Wi(5,s,s.return)}catch(re){Ue(s,s.return,re)}}break;case 1:Vt(r,s),sn(s),u&512&&c!==null&&Bs(c,c.return);break;case 5:if(Vt(r,s),sn(s),u&512&&c!==null&&Bs(c,c.return),s.flags&32){var m=s.stateNode;try{di(m,"")}catch(re){Ue(s,s.return,re)}}if(u&4&&(m=s.stateNode,m!=null)){var g=s.memoizedProps,x=c!==null?c.memoizedProps:g,b=s.type,C=s.updateQueue;if(s.updateQueue=null,C!==null)try{b==="input"&&g.type==="radio"&&g.name!=null&&eu(m,g),La(b,x);var L=La(b,g);for(x=0;x<C.length;x+=2){var U=C[x],K=C[x+1];U==="style"?lu(m,K):U==="dangerouslySetInnerHTML"?ou(m,K):U==="children"?di(m,K):O(m,U,K,L)}switch(b){case"input":Ea(m,g);break;case"textarea":su(m,g);break;case"select":var B=m._wrapperState.wasMultiple;m._wrapperState.wasMultiple=!!g.multiple;var ee=g.value;ee!=null?ys(m,!!g.multiple,ee,!1):B!==!!g.multiple&&(g.defaultValue!=null?ys(m,!!g.multiple,g.defaultValue,!0):ys(m,!!g.multiple,g.multiple?[]:"",!1))}m[Ri]=g}catch(re){Ue(s,s.return,re)}}break;case 6:if(Vt(r,s),sn(s),u&4){if(s.stateNode===null)throw Error(n(162));m=s.stateNode,g=s.memoizedProps;try{m.nodeValue=g}catch(re){Ue(s,s.return,re)}}break;case 3:if(Vt(r,s),sn(s),u&4&&c!==null&&c.memoizedState.isDehydrated)try{xi(r.containerInfo)}catch(re){Ue(s,s.return,re)}break;case 4:Vt(r,s),sn(s);break;case 13:Vt(r,s),sn(s),m=s.child,m.flags&8192&&(g=m.memoizedState!==null,m.stateNode.isHidden=g,!g||m.alternate!==null&&m.alternate.memoizedState!==null||(oc=We())),u&4&&$f(s);break;case 22:if(U=c!==null&&c.memoizedState!==null,s.mode&1?(ut=(L=ut)||U,Vt(r,s),ut=L):Vt(r,s),sn(s),u&8192){if(L=s.memoizedState!==null,(s.stateNode.isHidden=L)&&!U&&(s.mode&1)!==0)for(te=s,U=s.child;U!==null;){for(K=te=U;te!==null;){switch(B=te,ee=B.child,B.tag){case 0:case 11:case 14:case 15:Wi(4,B,B.return);break;case 1:Bs(B,B.return);var se=B.stateNode;if(typeof se.componentWillUnmount=="function"){u=B,c=B.return;try{r=u,se.props=r.memoizedProps,se.state=r.memoizedState,se.componentWillUnmount()}catch(re){Ue(u,c,re)}}break;case 5:Bs(B,B.return);break;case 22:if(B.memoizedState!==null){Af(K);continue}}ee!==null?(ee.return=B,te=ee):Af(K)}U=U.sibling}e:for(U=null,K=s;;){if(K.tag===5){if(U===null){U=K;try{m=K.stateNode,L?(g=m.style,typeof g.setProperty=="function"?g.setProperty("display","none","important"):g.display="none"):(b=K.stateNode,C=K.memoizedProps.style,x=C!=null&&C.hasOwnProperty("display")?C.display:null,b.style.display=au("display",x))}catch(re){Ue(s,s.return,re)}}}else if(K.tag===6){if(U===null)try{K.stateNode.nodeValue=L?"":K.memoizedProps}catch(re){Ue(s,s.return,re)}}else if((K.tag!==22&&K.tag!==23||K.memoizedState===null||K===s)&&K.child!==null){K.child.return=K,K=K.child;continue}if(K===s)break e;for(;K.sibling===null;){if(K.return===null||K.return===s)break e;U===K&&(U=null),K=K.return}U===K&&(U=null),K.sibling.return=K.return,K=K.sibling}}break;case 19:Vt(r,s),sn(s),u&4&&$f(s);break;case 21:break;default:Vt(r,s),sn(s)}}function sn(s){var r=s.flags;if(r&2){try{e:{for(var c=s.return;c!==null;){if(Sf(c)){var u=c;break e}c=c.return}throw Error(n(160))}switch(u.tag){case 5:var m=u.stateNode;u.flags&32&&(di(m,""),u.flags&=-33);var g=Nf(s);sc(s,g,m);break;case 3:case 4:var x=u.stateNode.containerInfo,b=Nf(s);nc(s,b,x);break;default:throw Error(n(161))}}catch(C){Ue(s,s.return,C)}s.flags&=-3}r&4096&&(s.flags&=-4097)}function Xy(s,r,c){te=s,Tf(s)}function Tf(s,r,c){for(var u=(s.mode&1)!==0;te!==null;){var m=te,g=m.child;if(m.tag===22&&u){var x=m.memoizedState!==null||ro;if(!x){var b=m.alternate,C=b!==null&&b.memoizedState!==null||ut;b=ro;var L=ut;if(ro=x,(ut=C)&&!L)for(te=m;te!==null;)x=te,C=x.child,x.tag===22&&x.memoizedState!==null?If(m):C!==null?(C.return=x,te=C):If(m);for(;g!==null;)te=g,Tf(g),g=g.sibling;te=m,ro=b,ut=L}Ef(s)}else(m.subtreeFlags&8772)!==0&&g!==null?(g.return=m,te=g):Ef(s)}}function Ef(s){for(;te!==null;){var r=te;if((r.flags&8772)!==0){var c=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:ut||oo(5,r);break;case 1:var u=r.stateNode;if(r.flags&4&&!ut)if(c===null)u.componentDidMount();else{var m=r.elementType===r.type?c.memoizedProps:Ht(r.type,c.memoizedProps);u.componentDidUpdate(m,c.memoizedState,u.__reactInternalSnapshotBeforeUpdate)}var g=r.updateQueue;g!==null&&Eh(r,g,u);break;case 3:var x=r.updateQueue;if(x!==null){if(c=null,r.child!==null)switch(r.child.tag){case 5:c=r.child.stateNode;break;case 1:c=r.child.stateNode}Eh(r,x,c)}break;case 5:var b=r.stateNode;if(c===null&&r.flags&4){c=b;var C=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":C.autoFocus&&c.focus();break;case"img":C.src&&(c.src=C.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(r.memoizedState===null){var L=r.alternate;if(L!==null){var U=L.memoizedState;if(U!==null){var K=U.dehydrated;K!==null&&xi(K)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}ut||r.flags&512&&tc(r)}catch(B){Ue(r,r.return,B)}}if(r===s){te=null;break}if(c=r.sibling,c!==null){c.return=r.return,te=c;break}te=r.return}}function Af(s){for(;te!==null;){var r=te;if(r===s){te=null;break}var c=r.sibling;if(c!==null){c.return=r.return,te=c;break}te=r.return}}function If(s){for(;te!==null;){var r=te;try{switch(r.tag){case 0:case 11:case 15:var c=r.return;try{oo(4,r)}catch(C){Ue(r,c,C)}break;case 1:var u=r.stateNode;if(typeof u.componentDidMount=="function"){var m=r.return;try{u.componentDidMount()}catch(C){Ue(r,m,C)}}var g=r.return;try{tc(r)}catch(C){Ue(r,g,C)}break;case 5:var x=r.return;try{tc(r)}catch(C){Ue(r,x,C)}}}catch(C){Ue(r,r.return,C)}if(r===s){te=null;break}var b=r.sibling;if(b!==null){b.return=r.return,te=b;break}te=r.return}}var Zy=Math.ceil,ao=D.ReactCurrentDispatcher,ic=D.ReactCurrentOwner,Ot=D.ReactCurrentBatchConfig,Ne=0,tt=null,qe=null,rt=0,Tt=0,Fs=On(0),Xe=0,Hi=null,os=0,lo=0,rc=0,Ki=null,yt=null,oc=0,Us=1/0,wn=null,co=!1,ac=null,Fn=null,uo=!1,Un=null,ho=0,Vi=0,lc=null,fo=-1,mo=0;function pt(){return(Ne&6)!==0?We():fo!==-1?fo:fo=We()}function Wn(s){return(s.mode&1)===0?1:(Ne&2)!==0&&rt!==0?rt&-rt:Py.transition!==null?(mo===0&&(mo=Su()),mo):(s=Ce,s!==0||(s=window.event,s=s===void 0?16:Ru(s.type)),s)}function Gt(s,r,c,u){if(50<Vi)throw Vi=0,lc=null,Error(n(185));gi(s,c,u),((Ne&2)===0||s!==tt)&&(s===tt&&((Ne&2)===0&&(lo|=c),Xe===4&&Hn(s,rt)),wt(s,u),c===1&&Ne===0&&(r.mode&1)===0&&(Us=We()+500,Fr&&_n()))}function wt(s,r){var c=s.callbackNode;Pk(s,r);var u=jr(s,s===tt?rt:0);if(u===0)c!==null&&wu(c),s.callbackNode=null,s.callbackPriority=0;else if(r=u&-u,s.callbackPriority!==r){if(c!=null&&wu(c),r===1)s.tag===0?Oy(Mf.bind(null,s)):vh(Mf.bind(null,s)),Iy(function(){(Ne&6)===0&&_n()}),c=null;else{switch(Nu(u)){case 1:c=Fa;break;case 4:c=xu;break;case 16:c=kr;break;case 536870912:c=ju;break;default:c=kr}c=Ff(c,Rf.bind(null,s))}s.callbackPriority=r,s.callbackNode=c}}function Rf(s,r){if(fo=-1,mo=0,(Ne&6)!==0)throw Error(n(327));var c=s.callbackNode;if(Ws()&&s.callbackNode!==c)return null;var u=jr(s,s===tt?rt:0);if(u===0)return null;if((u&30)!==0||(u&s.expiredLanes)!==0||r)r=po(s,u);else{r=u;var m=Ne;Ne|=2;var g=Of();(tt!==s||rt!==r)&&(wn=null,Us=We()+500,ls(s,r));do try{nw();break}catch(b){Lf(s,b)}while(!0);$l(),ao.current=g,Ne=m,qe!==null?r=0:(tt=null,rt=0,r=Xe)}if(r!==0){if(r===2&&(m=Ua(s),m!==0&&(u=m,r=cc(s,m))),r===1)throw c=Hi,ls(s,0),Hn(s,u),wt(s,We()),c;if(r===6)Hn(s,u);else{if(m=s.current.alternate,(u&30)===0&&!ew(m)&&(r=po(s,u),r===2&&(g=Ua(s),g!==0&&(u=g,r=cc(s,g))),r===1))throw c=Hi,ls(s,0),Hn(s,u),wt(s,We()),c;switch(s.finishedWork=m,s.finishedLanes=u,r){case 0:case 1:throw Error(n(345));case 2:cs(s,yt,wn);break;case 3:if(Hn(s,u),(u&130023424)===u&&(r=oc+500-We(),10<r)){if(jr(s,0)!==0)break;if(m=s.suspendedLanes,(m&u)!==u){pt(),s.pingedLanes|=s.suspendedLanes&m;break}s.timeoutHandle=pl(cs.bind(null,s,yt,wn),r);break}cs(s,yt,wn);break;case 4:if(Hn(s,u),(u&4194240)===u)break;for(r=s.eventTimes,m=-1;0<u;){var x=31-Ft(u);g=1<<x,x=r[x],x>m&&(m=x),u&=~g}if(u=m,u=We()-u,u=(120>u?120:480>u?480:1080>u?1080:1920>u?1920:3e3>u?3e3:4320>u?4320:1960*Zy(u/1960))-u,10<u){s.timeoutHandle=pl(cs.bind(null,s,yt,wn),u);break}cs(s,yt,wn);break;case 5:cs(s,yt,wn);break;default:throw Error(n(329))}}}return wt(s,We()),s.callbackNode===c?Rf.bind(null,s):null}function cc(s,r){var c=Ki;return s.current.memoizedState.isDehydrated&&(ls(s,r).flags|=256),s=po(s,r),s!==2&&(r=yt,yt=c,r!==null&&dc(r)),s}function dc(s){yt===null?yt=s:yt.push.apply(yt,s)}function ew(s){for(var r=s;;){if(r.flags&16384){var c=r.updateQueue;if(c!==null&&(c=c.stores,c!==null))for(var u=0;u<c.length;u++){var m=c[u],g=m.getSnapshot;m=m.value;try{if(!Ut(g(),m))return!1}catch{return!1}}}if(c=r.child,r.subtreeFlags&16384&&c!==null)c.return=r,r=c;else{if(r===s)break;for(;r.sibling===null;){if(r.return===null||r.return===s)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function Hn(s,r){for(r&=~rc,r&=~lo,s.suspendedLanes|=r,s.pingedLanes&=~r,s=s.expirationTimes;0<r;){var c=31-Ft(r),u=1<<c;s[c]=-1,r&=~u}}function Mf(s){if((Ne&6)!==0)throw Error(n(327));Ws();var r=jr(s,0);if((r&1)===0)return wt(s,We()),null;var c=po(s,r);if(s.tag!==0&&c===2){var u=Ua(s);u!==0&&(r=u,c=cc(s,u))}if(c===1)throw c=Hi,ls(s,0),Hn(s,r),wt(s,We()),c;if(c===6)throw Error(n(345));return s.finishedWork=s.current.alternate,s.finishedLanes=r,cs(s,yt,wn),wt(s,We()),null}function uc(s,r){var c=Ne;Ne|=1;try{return s(r)}finally{Ne=c,Ne===0&&(Us=We()+500,Fr&&_n())}}function as(s){Un!==null&&Un.tag===0&&(Ne&6)===0&&Ws();var r=Ne;Ne|=1;var c=Ot.transition,u=Ce;try{if(Ot.transition=null,Ce=1,s)return s()}finally{Ce=u,Ot.transition=c,Ne=r,(Ne&6)===0&&_n()}}function hc(){Tt=Fs.current,Le(Fs)}function ls(s,r){s.finishedWork=null,s.finishedLanes=0;var c=s.timeoutHandle;if(c!==-1&&(s.timeoutHandle=-1,Ay(c)),qe!==null)for(c=qe.return;c!==null;){var u=c;switch(xl(u),u.tag){case 1:u=u.type.childContextTypes,u!=null&&zr();break;case 3:Ds(),Le(gt),Le(lt),Ll();break;case 5:Rl(u);break;case 4:Ds();break;case 13:Le(_e);break;case 19:Le(_e);break;case 10:Cl(u.type._context);break;case 22:case 23:hc()}c=c.return}if(tt=s,qe=s=Kn(s.current,null),rt=Tt=r,Xe=0,Hi=null,rc=lo=os=0,yt=Ki=null,ss!==null){for(r=0;r<ss.length;r++)if(c=ss[r],u=c.interleaved,u!==null){c.interleaved=null;var m=u.next,g=c.pending;if(g!==null){var x=g.next;g.next=m,u.next=x}c.pending=u}ss=null}return s}function Lf(s,r){do{var c=qe;try{if($l(),Jr.current=to,Xr){for(var u=De.memoizedState;u!==null;){var m=u.queue;m!==null&&(m.pending=null),u=u.next}Xr=!1}if(rs=0,et=Je=De=null,Di=!1,zi=0,ic.current=null,c===null||c.return===null){Xe=1,Hi=r,qe=null;break}e:{var g=s,x=c.return,b=c,C=r;if(r=rt,b.flags|=32768,C!==null&&typeof C=="object"&&typeof C.then=="function"){var L=C,U=b,K=U.tag;if((U.mode&1)===0&&(K===0||K===11||K===15)){var B=U.alternate;B?(U.updateQueue=B.updateQueue,U.memoizedState=B.memoizedState,U.lanes=B.lanes):(U.updateQueue=null,U.memoizedState=null)}var ee=rf(x);if(ee!==null){ee.flags&=-257,of(ee,x,b,g,r),ee.mode&1&&sf(g,L,r),r=ee,C=L;var se=r.updateQueue;if(se===null){var re=new Set;re.add(C),r.updateQueue=re}else se.add(C);break e}else{if((r&1)===0){sf(g,L,r),fc();break e}C=Error(n(426))}}else if(Pe&&b.mode&1){var He=rf(x);if(He!==null){(He.flags&65536)===0&&(He.flags|=256),of(He,x,b,g,r),Nl(zs(C,b));break e}}g=C=zs(C,b),Xe!==4&&(Xe=2),Ki===null?Ki=[g]:Ki.push(g),g=x;do{switch(g.tag){case 3:g.flags|=65536,r&=-r,g.lanes|=r;var A=tf(g,C,r);Th(g,A);break e;case 1:b=C;var E=g.type,R=g.stateNode;if((g.flags&128)===0&&(typeof E.getDerivedStateFromError=="function"||R!==null&&typeof R.componentDidCatch=="function"&&(Fn===null||!Fn.has(R)))){g.flags|=65536,r&=-r,g.lanes|=r;var Y=nf(g,b,r);Th(g,Y);break e}}g=g.return}while(g!==null)}_f(c)}catch(ae){r=ae,qe===c&&c!==null&&(qe=c=c.return);continue}break}while(!0)}function Of(){var s=ao.current;return ao.current=to,s===null?to:s}function fc(){(Xe===0||Xe===3||Xe===2)&&(Xe=4),tt===null||(os&268435455)===0&&(lo&268435455)===0||Hn(tt,rt)}function po(s,r){var c=Ne;Ne|=2;var u=Of();(tt!==s||rt!==r)&&(wn=null,ls(s,r));do try{tw();break}catch(m){Lf(s,m)}while(!0);if($l(),Ne=c,ao.current=u,qe!==null)throw Error(n(261));return tt=null,rt=0,Xe}function tw(){for(;qe!==null;)Pf(qe)}function nw(){for(;qe!==null&&!Ck();)Pf(qe)}function Pf(s){var r=Bf(s.alternate,s,Tt);s.memoizedProps=s.pendingProps,r===null?_f(s):qe=r,ic.current=null}function _f(s){var r=s;do{var c=r.alternate;if(s=r.return,(r.flags&32768)===0){if(c=qy(c,r,Tt),c!==null){qe=c;return}}else{if(c=Qy(c,r),c!==null){c.flags&=32767,qe=c;return}if(s!==null)s.flags|=32768,s.subtreeFlags=0,s.deletions=null;else{Xe=6,qe=null;return}}if(r=r.sibling,r!==null){qe=r;return}qe=r=s}while(r!==null);Xe===0&&(Xe=5)}function cs(s,r,c){var u=Ce,m=Ot.transition;try{Ot.transition=null,Ce=1,sw(s,r,c,u)}finally{Ot.transition=m,Ce=u}return null}function sw(s,r,c,u){do Ws();while(Un!==null);if((Ne&6)!==0)throw Error(n(327));c=s.finishedWork;var m=s.finishedLanes;if(c===null)return null;if(s.finishedWork=null,s.finishedLanes=0,c===s.current)throw Error(n(177));s.callbackNode=null,s.callbackPriority=0;var g=c.lanes|c.childLanes;if(_k(s,g),s===tt&&(qe=tt=null,rt=0),(c.subtreeFlags&2064)===0&&(c.flags&2064)===0||uo||(uo=!0,Ff(kr,function(){return Ws(),null})),g=(c.flags&15990)!==0,(c.subtreeFlags&15990)!==0||g){g=Ot.transition,Ot.transition=null;var x=Ce;Ce=1;var b=Ne;Ne|=4,ic.current=null,Jy(s,c),Cf(c,s),Sy(fl),br=!!hl,fl=hl=null,s.current=c,Xy(c),Tk(),Ne=b,Ce=x,Ot.transition=g}else s.current=c;if(uo&&(uo=!1,Un=s,ho=m),g=s.pendingLanes,g===0&&(Fn=null),Ik(c.stateNode),wt(s,We()),r!==null)for(u=s.onRecoverableError,c=0;c<r.length;c++)m=r[c],u(m.value,{componentStack:m.stack,digest:m.digest});if(co)throw co=!1,s=ac,ac=null,s;return(ho&1)!==0&&s.tag!==0&&Ws(),g=s.pendingLanes,(g&1)!==0?s===lc?Vi++:(Vi=0,lc=s):Vi=0,_n(),null}function Ws(){if(Un!==null){var s=Nu(ho),r=Ot.transition,c=Ce;try{if(Ot.transition=null,Ce=16>s?16:s,Un===null)var u=!1;else{if(s=Un,Un=null,ho=0,(Ne&6)!==0)throw Error(n(331));var m=Ne;for(Ne|=4,te=s.current;te!==null;){var g=te,x=g.child;if((te.flags&16)!==0){var b=g.deletions;if(b!==null){for(var C=0;C<b.length;C++){var L=b[C];for(te=L;te!==null;){var U=te;switch(U.tag){case 0:case 11:case 15:Wi(8,U,g)}var K=U.child;if(K!==null)K.return=U,te=K;else for(;te!==null;){U=te;var B=U.sibling,ee=U.return;if(jf(U),U===L){te=null;break}if(B!==null){B.return=ee,te=B;break}te=ee}}}var se=g.alternate;if(se!==null){var re=se.child;if(re!==null){se.child=null;do{var He=re.sibling;re.sibling=null,re=He}while(re!==null)}}te=g}}if((g.subtreeFlags&2064)!==0&&x!==null)x.return=g,te=x;else e:for(;te!==null;){if(g=te,(g.flags&2048)!==0)switch(g.tag){case 0:case 11:case 15:Wi(9,g,g.return)}var A=g.sibling;if(A!==null){A.return=g.return,te=A;break e}te=g.return}}var E=s.current;for(te=E;te!==null;){x=te;var R=x.child;if((x.subtreeFlags&2064)!==0&&R!==null)R.return=x,te=R;else e:for(x=E;te!==null;){if(b=te,(b.flags&2048)!==0)try{switch(b.tag){case 0:case 11:case 15:oo(9,b)}}catch(ae){Ue(b,b.return,ae)}if(b===x){te=null;break e}var Y=b.sibling;if(Y!==null){Y.return=b.return,te=Y;break e}te=b.return}}if(Ne=m,_n(),Zt&&typeof Zt.onPostCommitFiberRoot=="function")try{Zt.onPostCommitFiberRoot(yr,s)}catch{}u=!0}return u}finally{Ce=c,Ot.transition=r}}return!1}function Df(s,r,c){r=zs(c,r),r=tf(s,r,1),s=zn(s,r,1),r=pt(),s!==null&&(gi(s,1,r),wt(s,r))}function Ue(s,r,c){if(s.tag===3)Df(s,s,c);else for(;r!==null;){if(r.tag===3){Df(r,s,c);break}else if(r.tag===1){var u=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(Fn===null||!Fn.has(u))){s=zs(c,s),s=nf(r,s,1),r=zn(r,s,1),s=pt(),r!==null&&(gi(r,1,s),wt(r,s));break}}r=r.return}}function iw(s,r,c){var u=s.pingCache;u!==null&&u.delete(r),r=pt(),s.pingedLanes|=s.suspendedLanes&c,tt===s&&(rt&c)===c&&(Xe===4||Xe===3&&(rt&130023424)===rt&&500>We()-oc?ls(s,0):rc|=c),wt(s,r)}function zf(s,r){r===0&&((s.mode&1)===0?r=1:(r=xr,xr<<=1,(xr&130023424)===0&&(xr=4194304)));var c=pt();s=vn(s,r),s!==null&&(gi(s,r,c),wt(s,c))}function rw(s){var r=s.memoizedState,c=0;r!==null&&(c=r.retryLane),zf(s,c)}function ow(s,r){var c=0;switch(s.tag){case 13:var u=s.stateNode,m=s.memoizedState;m!==null&&(c=m.retryLane);break;case 19:u=s.stateNode;break;default:throw Error(n(314))}u!==null&&u.delete(r),zf(s,c)}var Bf;Bf=function(s,r,c){if(s!==null)if(s.memoizedProps!==r.pendingProps||gt.current)kt=!0;else{if((s.lanes&c)===0&&(r.flags&128)===0)return kt=!1,Gy(s,r,c);kt=(s.flags&131072)!==0}else kt=!1,Pe&&(r.flags&1048576)!==0&&kh(r,Wr,r.index);switch(r.lanes=0,r.tag){case 2:var u=r.type;io(s,r),s=r.pendingProps;var m=Is(r,lt.current);_s(r,c),m=_l(null,r,u,s,m,c);var g=Dl();return r.flags|=1,typeof m=="object"&&m!==null&&typeof m.render=="function"&&m.$$typeof===void 0?(r.tag=1,r.memoizedState=null,r.updateQueue=null,vt(u)?(g=!0,Br(r)):g=!1,r.memoizedState=m.state!==null&&m.state!==void 0?m.state:null,Al(r),m.updater=no,r.stateNode=m,m._reactInternals=r,Hl(r,u,s,c),r=ql(null,r,u,!0,g,c)):(r.tag=0,Pe&&g&&wl(r),mt(null,r,m,c),r=r.child),r;case 16:u=r.elementType;e:{switch(io(s,r),s=r.pendingProps,m=u._init,u=m(u._payload),r.type=u,m=r.tag=lw(u),s=Ht(u,s),m){case 0:r=Gl(null,r,u,s,c);break e;case 1:r=hf(null,r,u,s,c);break e;case 11:r=af(null,r,u,s,c);break e;case 14:r=lf(null,r,u,Ht(u.type,s),c);break e}throw Error(n(306,u,""))}return r;case 0:return u=r.type,m=r.pendingProps,m=r.elementType===u?m:Ht(u,m),Gl(s,r,u,m,c);case 1:return u=r.type,m=r.pendingProps,m=r.elementType===u?m:Ht(u,m),hf(s,r,u,m,c);case 3:e:{if(ff(r),s===null)throw Error(n(387));u=r.pendingProps,g=r.memoizedState,m=g.element,Ch(s,r),Qr(r,u,null,c);var x=r.memoizedState;if(u=x.element,g.isDehydrated)if(g={element:u,isDehydrated:!1,cache:x.cache,pendingSuspenseBoundaries:x.pendingSuspenseBoundaries,transitions:x.transitions},r.updateQueue.baseState=g,r.memoizedState=g,r.flags&256){m=zs(Error(n(423)),r),r=mf(s,r,u,c,m);break e}else if(u!==m){m=zs(Error(n(424)),r),r=mf(s,r,u,c,m);break e}else for(Ct=Ln(r.stateNode.containerInfo.firstChild),$t=r,Pe=!0,Wt=null,c=bh(r,null,u,c),r.child=c;c;)c.flags=c.flags&-3|4096,c=c.sibling;else{if(Ls(),u===m){r=yn(s,r,c);break e}mt(s,r,u,c)}r=r.child}return r;case 5:return Ah(r),s===null&&Sl(r),u=r.type,m=r.pendingProps,g=s!==null?s.memoizedProps:null,x=m.children,ml(u,m)?x=null:g!==null&&ml(u,g)&&(r.flags|=32),uf(s,r),mt(s,r,x,c),r.child;case 6:return s===null&&Sl(r),null;case 13:return pf(s,r,c);case 4:return Il(r,r.stateNode.containerInfo),u=r.pendingProps,s===null?r.child=Os(r,null,u,c):mt(s,r,u,c),r.child;case 11:return u=r.type,m=r.pendingProps,m=r.elementType===u?m:Ht(u,m),af(s,r,u,m,c);case 7:return mt(s,r,r.pendingProps,c),r.child;case 8:return mt(s,r,r.pendingProps.children,c),r.child;case 12:return mt(s,r,r.pendingProps.children,c),r.child;case 10:e:{if(u=r.type._context,m=r.pendingProps,g=r.memoizedProps,x=m.value,Re(Vr,u._currentValue),u._currentValue=x,g!==null)if(Ut(g.value,x)){if(g.children===m.children&&!gt.current){r=yn(s,r,c);break e}}else for(g=r.child,g!==null&&(g.return=r);g!==null;){var b=g.dependencies;if(b!==null){x=g.child;for(var C=b.firstContext;C!==null;){if(C.context===u){if(g.tag===1){C=kn(-1,c&-c),C.tag=2;var L=g.updateQueue;if(L!==null){L=L.shared;var U=L.pending;U===null?C.next=C:(C.next=U.next,U.next=C),L.pending=C}}g.lanes|=c,C=g.alternate,C!==null&&(C.lanes|=c),Tl(g.return,c,r),b.lanes|=c;break}C=C.next}}else if(g.tag===10)x=g.type===r.type?null:g.child;else if(g.tag===18){if(x=g.return,x===null)throw Error(n(341));x.lanes|=c,b=x.alternate,b!==null&&(b.lanes|=c),Tl(x,c,r),x=g.sibling}else x=g.child;if(x!==null)x.return=g;else for(x=g;x!==null;){if(x===r){x=null;break}if(g=x.sibling,g!==null){g.return=x.return,x=g;break}x=x.return}g=x}mt(s,r,m.children,c),r=r.child}return r;case 9:return m=r.type,u=r.pendingProps.children,_s(r,c),m=Mt(m),u=u(m),r.flags|=1,mt(s,r,u,c),r.child;case 14:return u=r.type,m=Ht(u,r.pendingProps),m=Ht(u.type,m),lf(s,r,u,m,c);case 15:return cf(s,r,r.type,r.pendingProps,c);case 17:return u=r.type,m=r.pendingProps,m=r.elementType===u?m:Ht(u,m),io(s,r),r.tag=1,vt(u)?(s=!0,Br(r)):s=!1,_s(r,c),Zh(r,u,m),Hl(r,u,m,c),ql(null,r,u,!0,s,c);case 19:return vf(s,r,c);case 22:return df(s,r,c)}throw Error(n(156,r.tag))};function Ff(s,r){return yu(s,r)}function aw(s,r,c,u){this.tag=s,this.key=c,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=u,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Pt(s,r,c,u){return new aw(s,r,c,u)}function mc(s){return s=s.prototype,!(!s||!s.isReactComponent)}function lw(s){if(typeof s=="function")return mc(s)?1:0;if(s!=null){if(s=s.$$typeof,s===Te)return 11;if(s===F)return 14}return 2}function Kn(s,r){var c=s.alternate;return c===null?(c=Pt(s.tag,r,s.key,s.mode),c.elementType=s.elementType,c.type=s.type,c.stateNode=s.stateNode,c.alternate=s,s.alternate=c):(c.pendingProps=r,c.type=s.type,c.flags=0,c.subtreeFlags=0,c.deletions=null),c.flags=s.flags&14680064,c.childLanes=s.childLanes,c.lanes=s.lanes,c.child=s.child,c.memoizedProps=s.memoizedProps,c.memoizedState=s.memoizedState,c.updateQueue=s.updateQueue,r=s.dependencies,c.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},c.sibling=s.sibling,c.index=s.index,c.ref=s.ref,c}function go(s,r,c,u,m,g){var x=2;if(u=s,typeof s=="function")mc(s)&&(x=1);else if(typeof s=="string")x=5;else e:switch(s){case G:return ds(c.children,m,g,r);case oe:x=8,m|=8;break;case Q:return s=Pt(12,c,r,m|2),s.elementType=Q,s.lanes=g,s;case ne:return s=Pt(13,c,r,m),s.elementType=ne,s.lanes=g,s;case ce:return s=Pt(19,c,r,m),s.elementType=ce,s.lanes=g,s;case ie:return vo(c,m,g,r);default:if(typeof s=="object"&&s!==null)switch(s.$$typeof){case ke:x=10;break e;case Oe:x=9;break e;case Te:x=11;break e;case F:x=14;break e;case J:x=16,u=null;break e}throw Error(n(130,s==null?s:typeof s,""))}return r=Pt(x,c,r,m),r.elementType=s,r.type=u,r.lanes=g,r}function ds(s,r,c,u){return s=Pt(7,s,u,r),s.lanes=c,s}function vo(s,r,c,u){return s=Pt(22,s,u,r),s.elementType=ie,s.lanes=c,s.stateNode={isHidden:!1},s}function pc(s,r,c){return s=Pt(6,s,null,r),s.lanes=c,s}function gc(s,r,c){return r=Pt(4,s.children!==null?s.children:[],s.key,r),r.lanes=c,r.stateNode={containerInfo:s.containerInfo,pendingChildren:null,implementation:s.implementation},r}function cw(s,r,c,u,m){this.tag=r,this.containerInfo=s,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Wa(0),this.expirationTimes=Wa(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Wa(0),this.identifierPrefix=u,this.onRecoverableError=m,this.mutableSourceEagerHydrationData=null}function vc(s,r,c,u,m,g,x,b,C){return s=new cw(s,r,c,b,C),r===1?(r=1,g===!0&&(r|=8)):r=0,g=Pt(3,null,null,r),s.current=g,g.stateNode=s,g.memoizedState={element:u,isDehydrated:c,cache:null,transitions:null,pendingSuspenseBoundaries:null},Al(g),s}function dw(s,r,c){var u=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:H,key:u==null?null:""+u,children:s,containerInfo:r,implementation:c}}function Uf(s){if(!s)return Pn;s=s._reactInternals;e:{if(Xn(s)!==s||s.tag!==1)throw Error(n(170));var r=s;do{switch(r.tag){case 3:r=r.stateNode.context;break e;case 1:if(vt(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}}r=r.return}while(r!==null);throw Error(n(171))}if(s.tag===1){var c=s.type;if(vt(c))return ph(s,c,r)}return r}function Wf(s,r,c,u,m,g,x,b,C){return s=vc(c,u,!0,s,m,g,x,b,C),s.context=Uf(null),c=s.current,u=pt(),m=Wn(c),g=kn(u,m),g.callback=r??null,zn(c,g,m),s.current.lanes=m,gi(s,m,u),wt(s,u),s}function ko(s,r,c,u){var m=r.current,g=pt(),x=Wn(m);return c=Uf(c),r.context===null?r.context=c:r.pendingContext=c,r=kn(g,x),r.payload={element:s},u=u===void 0?null:u,u!==null&&(r.callback=u),s=zn(m,r,x),s!==null&&(Gt(s,m,x,g),qr(s,m,x)),x}function yo(s){if(s=s.current,!s.child)return null;switch(s.child.tag){case 5:return s.child.stateNode;default:return s.child.stateNode}}function Hf(s,r){if(s=s.memoizedState,s!==null&&s.dehydrated!==null){var c=s.retryLane;s.retryLane=c!==0&&c<r?c:r}}function kc(s,r){Hf(s,r),(s=s.alternate)&&Hf(s,r)}function uw(){return null}var Kf=typeof reportError=="function"?reportError:function(s){console.error(s)};function yc(s){this._internalRoot=s}wo.prototype.render=yc.prototype.render=function(s){var r=this._internalRoot;if(r===null)throw Error(n(409));ko(s,r,null,null)},wo.prototype.unmount=yc.prototype.unmount=function(){var s=this._internalRoot;if(s!==null){this._internalRoot=null;var r=s.containerInfo;as(function(){ko(null,s,null,null)}),r[fn]=null}};function wo(s){this._internalRoot=s}wo.prototype.unstable_scheduleHydration=function(s){if(s){var r=Cu();s={blockedOn:null,target:s,priority:r};for(var c=0;c<In.length&&r!==0&&r<In[c].priority;c++);In.splice(c,0,s),c===0&&Au(s)}};function wc(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11)}function xo(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11&&(s.nodeType!==8||s.nodeValue!==" react-mount-point-unstable "))}function Vf(){}function hw(s,r,c,u,m){if(m){if(typeof u=="function"){var g=u;u=function(){var L=yo(x);g.call(L)}}var x=Wf(r,u,s,0,null,!1,!1,"",Vf);return s._reactRootContainer=x,s[fn]=x.current,Ai(s.nodeType===8?s.parentNode:s),as(),x}for(;m=s.lastChild;)s.removeChild(m);if(typeof u=="function"){var b=u;u=function(){var L=yo(C);b.call(L)}}var C=vc(s,0,!1,null,null,!1,!1,"",Vf);return s._reactRootContainer=C,s[fn]=C.current,Ai(s.nodeType===8?s.parentNode:s),as(function(){ko(r,C,c,u)}),C}function jo(s,r,c,u,m){var g=c._reactRootContainer;if(g){var x=g;if(typeof m=="function"){var b=m;m=function(){var C=yo(x);b.call(C)}}ko(r,x,s,m)}else x=hw(c,r,s,m,u);return yo(x)}bu=function(s){switch(s.tag){case 3:var r=s.stateNode;if(r.current.memoizedState.isDehydrated){var c=pi(r.pendingLanes);c!==0&&(Ha(r,c|1),wt(r,We()),(Ne&6)===0&&(Us=We()+500,_n()))}break;case 13:as(function(){var u=vn(s,1);if(u!==null){var m=pt();Gt(u,s,1,m)}}),kc(s,1)}},Ka=function(s){if(s.tag===13){var r=vn(s,134217728);if(r!==null){var c=pt();Gt(r,s,134217728,c)}kc(s,134217728)}},$u=function(s){if(s.tag===13){var r=Wn(s),c=vn(s,r);if(c!==null){var u=pt();Gt(c,s,r,u)}kc(s,r)}},Cu=function(){return Ce},Tu=function(s,r){var c=Ce;try{return Ce=s,r()}finally{Ce=c}},_a=function(s,r,c){switch(r){case"input":if(Ea(s,c),r=c.name,c.type==="radio"&&r!=null){for(c=s;c.parentNode;)c=c.parentNode;for(c=c.querySelectorAll("input[name="+JSON.stringify(""+r)+'][type="radio"]'),r=0;r<c.length;r++){var u=c[r];if(u!==s&&u.form===s.form){var m=Dr(u);if(!m)throw Error(n(90));mr(u),Ea(u,m)}}}break;case"textarea":su(s,c);break;case"select":r=c.value,r!=null&&ys(s,!!c.multiple,r,!1)}},hu=uc,fu=as;var fw={usingClientEntryPoint:!1,Events:[Mi,Es,Dr,du,uu,uc]},Gi={findFiberByHostInstance:Zn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},mw={bundleType:Gi.bundleType,version:Gi.version,rendererPackageName:Gi.rendererPackageName,rendererConfig:Gi.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:D.ReactCurrentDispatcher,findHostInstanceByFiber:function(s){return s=vu(s),s===null?null:s.stateNode},findFiberByHostInstance:Gi.findFiberByHostInstance||uw,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 So=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!So.isDisabled&&So.supportsFiber)try{yr=So.inject(mw),Zt=So}catch{}}return xt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=fw,xt.createPortal=function(s,r){var c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!wc(r))throw Error(n(200));return dw(s,r,null,c)},xt.createRoot=function(s,r){if(!wc(s))throw Error(n(299));var c=!1,u="",m=Kf;return r!=null&&(r.unstable_strictMode===!0&&(c=!0),r.identifierPrefix!==void 0&&(u=r.identifierPrefix),r.onRecoverableError!==void 0&&(m=r.onRecoverableError)),r=vc(s,1,!1,null,null,c,!1,u,m),s[fn]=r.current,Ai(s.nodeType===8?s.parentNode:s),new yc(r)},xt.findDOMNode=function(s){if(s==null)return null;if(s.nodeType===1)return s;var r=s._reactInternals;if(r===void 0)throw typeof s.render=="function"?Error(n(188)):(s=Object.keys(s).join(","),Error(n(268,s)));return s=vu(r),s=s===null?null:s.stateNode,s},xt.flushSync=function(s){return as(s)},xt.hydrate=function(s,r,c){if(!xo(r))throw Error(n(200));return jo(null,s,r,!0,c)},xt.hydrateRoot=function(s,r,c){if(!wc(s))throw Error(n(405));var u=c!=null&&c.hydratedSources||null,m=!1,g="",x=Kf;if(c!=null&&(c.unstable_strictMode===!0&&(m=!0),c.identifierPrefix!==void 0&&(g=c.identifierPrefix),c.onRecoverableError!==void 0&&(x=c.onRecoverableError)),r=Wf(r,null,s,1,c??null,m,!1,g,x),s[fn]=r.current,Ai(s),u)for(s=0;s<u.length;s++)c=u[s],m=c._getVersion,m=m(c._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[c,m]:r.mutableSourceEagerHydrationData.push(c,m);return new wo(r)},xt.render=function(s,r,c){if(!xo(r))throw Error(n(200));return jo(null,s,r,!1,c)},xt.unmountComponentAtNode=function(s){if(!xo(s))throw Error(n(40));return s._reactRootContainer?(as(function(){jo(null,null,s,!1,function(){s._reactRootContainer=null,s[fn]=null})}),!0):!1},xt.unstable_batchedUpdates=uc,xt.unstable_renderSubtreeIntoContainer=function(s,r,c,u){if(!xo(c))throw Error(n(200));if(s==null||s._reactInternals===void 0)throw Error(n(38));return jo(s,r,c,!1,u)},xt.version="18.3.1-next-f1338f8080-20240426",xt}var em;function _p(){if(em)return Sc.exports;em=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Sc.exports=Sw(),Sc.exports}var tm;function Nw(){if(tm)return No;tm=1;var e=_p();return No.createRoot=e.createRoot,No.hydrateRoot=e.hydrateRoot,No}var bw=Nw(),y=xd();const Qn="teamtrail",Z={slug:Qn,npm:"teamtrail",name:"Teamtrail",category:"The trail map for AI coding agents",tagline:"You pick the destination. Your agents walk the trail.",assistant:{name:"Scout"},labelPrefix:Qn,dataDir:`.${Qn}`,apiPrefix:`/__${Qn}`,dataDirEnv:`${Qn.toUpperCase()}_DIR`,noRegisterEnv:`${Qn.toUpperCase()}_NO_REGISTER`,tokenEnv:`${Qn.toUpperCase()}_TOKEN`},ea=`${Qn}.prefs`,ta=e=>`${Z.labelPrefix}:${e}`,jd=ta("map"),Sd=ta("hitl"),$w=e=>e==="task"||e==="execute",Nd=ta("plan-only");function Dp(e){return/^[A-Za-z0-9_@%+=:,./-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}const Cw=e=>e.map(Dp).join(" "),Tw=/^\d+\.\d+\.\d+(-[0-9A-Za-z][0-9A-Za-z.-]*)?$/;function Ew(e){return Tw.test(e)?`${Z.npm}@${e}`:Z.npm}function zp(e,t){return Cw(["npx","-y",Ew(e),...t])}const _o=["research","prototype","junction","task","execute"],na=[..._o,"review"],gs="plan+execute",Aw=e=>e.filter(t=>!t.archived),Iw=["verifying","rework","blocked"],bd=["off","checks","checks+review","checks+review+human"],Bp=e=>bd.find(t=>t===e);function cr(e){return e.type==="junction"||e.type==="prototype"?"hitl":e.type==="research"?"afk":e.hitl?"hitl":"afk"}const Rw=["task","execute"];function Fp(e,t,n=gs){return e.state==="closed"?e.closeReason==="not_planned"?"out-of-scope":"decided":e.status==="verifying"?"verifying":e.status==="blocked"?"held":e.assignee?"claimed":e.status==="rework"?"rework":n==="plan-only"&&e.type==="execute"?"parked":e.blockedBy.some(a=>{var l;return((l=t.get(a))==null?void 0:l.state)==="open"})?"blocked":"frontier"}function ti(e,t=gs){const n=new Map(e.map(o=>[o.id,o]));return new Map(e.map(o=>[o.id,Fp(o,n,t)]))}const Ve=200,Qe=56;function nm(e,t="LR",n=gs){var Te;const o=t==="LR"?330:124,a=t==="LR"?112:262,l=ti(e,n),d=new Map(e.map(ne=>[ne.id,ne])),h=new Map,f=new Set,p=ne=>{if(h.has(ne))return h.get(ne);if(f.has(ne))return 0;f.add(ne);const ce=d.get(ne),F=ce&&ce.blockedBy.length?1+Math.max(...ce.blockedBy.filter(J=>d.has(J)).map(p),-1):0;return f.delete(ne),h.set(ne,F),F},v=e.filter(ne=>l.get(ne.id)!=="out-of-scope"),k=e.filter(ne=>l.get(ne.id)==="out-of-scope"),w=[];for(const ne of v)(w[Te=p(ne.id)]??(w[Te]=[])).push(ne);const j=[],N=new Map;let S=0;w.forEach(ne=>{ne&&(ne.sort((ce,F)=>{const J=ie=>{const W=ie.blockedBy.map(X=>N.get(X)).filter(X=>X!==void 0);return W.length?W.reduce((X,z)=>X+z,0)/W.length:ie.createdAt/1e12};return J(ce)-J(F)||ce.createdAt-F.createdAt}),S=Math.max(S,ne.length),ne.forEach((ce,F)=>N.set(ce.id,F)))}),w.forEach((ne,ce)=>{if(!ne)return;const F=(S-ne.length)*a/2;ne.forEach((J,ie)=>{const W=ce*o,X=F+ie*a;j.push({ticket:J,state:l.get(J.id),layer:ce,x:t==="LR"?W:X,y:t==="LR"?X:W})})});const $=Math.max(w.length,1)*o-(o-(t==="LR"?Ve:Qe)),_=Math.max(S,1)*a-(a-(t==="LR"?Qe:Ve)),O=t==="LR"?$:_,D=t==="LR"?_:$,q=D+54,H=Math.max(1,Math.floor((O+24)/(Ve+24)));k.forEach((ne,ce)=>{j.push({ticket:ne,state:"out-of-scope",layer:-1,x:ce%H*(Ve+24),y:q+Math.floor(ce/H)*(Qe+16)})});const G=[],oe=new Map(j.map(ne=>[ne.ticket.id,ne]));for(const ne of j)for(const ce of ne.ticket.blockedBy){const F=oe.get(ce);F&&G.push({from:F,to:ne})}const Q=Math.ceil(k.length/H),ke=Math.max(O,Math.min(k.length,H)*(Ve+24)-24),Oe=k.length?q+Q*(Qe+16)-16:D;return{direction:t,nodes:j,edges:G,width:ke,graphH:D,quarantineY:q,height:Oe,quarantineH:Q*(Qe+16)+24}}const Do=["fast","balanced","strongest"],sm="balanced",Mw=[["*-mini","fast"],["*-mini-*","fast"],["*-nano","fast"],["*-nano-*","fast"],["*claude-haiku-*","fast"],["*claude-3*-haiku*","fast"],["*claude-opus-*","strongest"],["*claude-3*-opus*","strongest"],["*claude-fable-*","strongest"],["*claude-sonnet-*","balanced"],["*claude-3*-sonnet*","balanced"],["gpt-5*","strongest"],["o1","strongest"],["o1-*","strongest"],["o3","strongest"],["o3-*","strongest"],["o4-*","strongest"],["gpt-4*","balanced"]],Up=e=>Do.includes(e),$d={research:"fast",task:"balanced",execute:"balanced",junction:"strongest",prototype:"strongest",review:"strongest"};function Lw(e,t){var a,l;const n=(l=(a=t.modelMatching)==null?void 0:a.tiers)==null?void 0:l[e.type],o=$d[e.type];return t.settingsUnconfirmed&&n?Do.indexOf(n)>=Do.indexOf(o)?n:o:n??o}function im(e){return Object.fromEntries(na.map(t=>[t,Lw({type:t},e)]))}const Ow=e=>e!=="__proto__"&&e!=="constructor"&&e!=="prototype",Pw=64;function _w(e,t){const n=[];for(let o=0;o<e.length;o++){const a=e[o];if(a!=="*"&&!(a==="?"&&t))n.push({kind:"char",c:a});else if(a==="?")n.push({kind:"one"});else if(!t||e[o+1]!=="*")n.push({kind:t?"star":"deep"});else{const l=e[o+2]==="/";o+=l?2:1,n.push({kind:l?"dirs":"deep"})}}return Dw(n)}function Dw(e){const t=[];for(const n of e){const o=t.at(-1);(o==null?void 0:o.kind)==="dirs"&&n.kind==="dirs"||(o==null?void 0:o.kind)==="deep"&&(n.kind==="deep"||n.kind==="dirs")||((o==null?void 0:o.kind)==="dirs"&&n.kind==="deep"?t[t.length-1]=n:t.push(n))}return t}function zw({t:e,c:t,inText:n,next:o,cur:a,j:l}){switch(e.kind){case"char":return n&&t===e.c?o[l+1]:0;case"one":return n&&t!=="/"?o[l+1]:0;case"star":return o[l]||(n&&t!=="/"?a[l+1]:0);case"deep":return o[l]||(n?a[l+1]:0);case"dirs":return 0;default:return e}}function Bw(e,t,n){const o=n.length,a=new Uint8Array(o+1);let l=0;for(let d=o;d>=0;d--){const h=d<o,f=h?n[d]:"";if(e.kind!=="dirs"){a[d]=zw({t:e,c:f,inText:h,next:t,cur:a,j:d});continue}f==="/"&&t[d+1]&&(l=1),a[d]=t[d]||l}return a}function Wp(e,t,n){const o=_w(e,n.segments);if(o.filter(l=>l.kind!=="char").length>Pw)return!1;let a=new Uint8Array(t.length+1);a[t.length]=1;for(let l=o.length-1;l>=0;l--)a=Bw(o[l],a,t);return a[0]===1}function rm(e,t){return Wp(e.trim().toLowerCase(),t.trim().toLowerCase(),{segments:!1})}function Fw(e,t={}){const n=e==null?void 0:e.trim();if(!n)return{tier:sm,source:"unknown",reason:"no model reported, so it counts as balanced"};const a=Object.entries(t).find(([d])=>d.trim().toLowerCase()===n.toLowerCase())??Object.entries(t).find(([d])=>rm(d,n));if(a)return{tier:a[1],model:n,source:"project",reason:`${n} is ${a[1]} in models.json`};const l=Mw.find(([d])=>rm(d,n));return l?{tier:l[1],model:n,source:"built-in",reason:`${n} is a ${l[1]} model`}:{tier:sm,model:n,source:"unknown",reason:`${n} is not a known model, so it counts as balanced`}}const Uw=["holding","challenged","invalidated","confirmed"],Ww=e=>Uw.includes(e),Hw=Z.labelPrefix,Xc=" -->",Kw=7e4,Hp=e=>`<!-- ${Hw}:${e} `,Vw=e=>JSON.stringify(e).replace(/--/g,"-\\u002d"),Gw=(e,t)=>`${Hp(e)}${t}${Xc}`;function qw(e,t){const n=e.trimEnd();if(!n.endsWith(Xc))return;const o=Hp(t),a=n.lastIndexOf(o);if(!(a===-1||n.length-a>Kw))return{before:n.slice(0,a),payload:n.slice(a+o.length,-Xc.length)}}const Qw=/[\u0000-\u001f\u007f-\u009f\u2028\u2029\u200b\u2060\ufeff\u202a-\u202e\u2066-\u2069]/,Yw=/[\u0000-\u001f\u007f-\u009f\u2028\u2029\u200b\u2060\ufeff\u202a-\u202e\u2066-\u2069]+/g,Jw=/\r\n|[\r\u0085\u2028\u2029]/g,Xw=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u0084\u0086-\u009f\u200b\u2060\ufeff\u202a-\u202e\u2066-\u2069]/g,Zw=e=>Qw.test(e),hs=e=>e.replace(Yw," ").trim(),ex=e=>e.replace(Jw,`
|
|
41
|
+
`).replace(Xw,"");function sa(e,t){const n=new RegExp(`^\\\\*(?:${t})`);return ex(e).trim().split(`
|
|
42
|
+
`).map(o=>n.test(o)?`\\${o}`:o).join(`
|
|
43
|
+
`)}function zo(e,t){const n=new RegExp(`^\\\\+(?:${t})`);return e.split(`
|
|
44
|
+
`).map(o=>n.test(o)?o.slice(1):o).join(`
|
|
45
|
+
`)}const Kp=Z.labelPrefix,tx=new RegExp(`<(\\\\*)!--(?=\\s*${Kp}:)`,"g"),nx=new RegExp(`<\\\\(\\\\*)!--(?=\\s*${Kp}:)`,"g"),ia=e=>e.replace(tx,"<\\$1!--"),Gs=e=>e.replace(nx,"<$1!--"),Vp="asm",sx=/^-\s+(?:\[([a-z]+)\]\s+)?/,ix=1e3;function rx(e){const t={id:e.id,tickets:e.tickets,...e.source?{source:e.source}:{},...e.challenge?{challenge:{...e.challenge,evidence:e.challenge.evidence.slice(0,ix)}}:{},...e.decidedBy?{decidedBy:e.decidedBy}:{}};return`- [${e.status}] ${ia(hs(e.text))} ${Gw(Vp,Vw(t))}`}function ox(e){const t=e.map(ax);let n=Math.max(0,...t.map(o=>cx(o.id)))+1;return t.map(o=>o.id?o:{...o,id:`S-${n++}`})}function ax(e){const t=qw(e,Vp),n=t?t.before:e,o=n.match(sx),a=o==null?void 0:o[1],l=Gs(n.slice(o?o[0].length:0).trim()),d=lx(t==null?void 0:t.payload);return{id:d.id??"",text:l,status:Ww(a)?a:"holding",tickets:Array.isArray(d.tickets)?d.tickets.map(String):[],...d.source?{source:d.source}:{},...d.challenge?{challenge:d.challenge}:{},...d.decidedBy?{decidedBy:d.decidedBy}:{}}}function lx(e){if(!e)return{};try{const t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}function cx(e){const t=e==null?void 0:e.match(/^S-(\d+)$/);return t?Number(t[1]):0}const Gp=[["destination","Destination"],["notes","Notes"],["assumptions","Assumptions"],["decisions","Decisions so far"],["unspecified","Not yet specified"],["outOfScope","Out of scope"]],dx=Object.fromEntries(Gp),qp="##\\s",om=e=>ia(sa(e.trim(),qp)),am=e=>zo(Gs(e),qp),lm=e=>ia(hs(e)),ux=/^-\s+(?:\[?([#A-Z0-9-]+)\]?:?\s+)?(.*)$/;function hx(e){var o;const t=a=>a.length?a.map(l=>`- ${lm(l)}`).join(`
|
|
46
|
+
`):"_None yet._",n=a=>a.length?a.map(l=>`- ${l.ticketKey?`${hs(l.ticketKey)}: `:""}${lm(l.text)}`).join(`
|
|
47
|
+
`):"_None yet._";return[`## Destination
|
|
48
|
+
|
|
49
|
+
${om(e.destination)}`,`## Notes
|
|
50
|
+
|
|
51
|
+
${om(e.notes)||"_None yet._"}`,...(o=e.assumptions)!=null&&o.length?[`## Assumptions
|
|
52
|
+
|
|
53
|
+
${e.assumptions.map(rx).join(`
|
|
54
|
+
`)}`]:[],`## Decisions so far
|
|
55
|
+
|
|
56
|
+
${n(e.decisions)}`,`## Not yet specified
|
|
57
|
+
|
|
58
|
+
${t(e.unspecified)}`,`## Out of scope
|
|
59
|
+
|
|
60
|
+
${t(e.outOfScope)}`].join(`
|
|
61
|
+
|
|
62
|
+
`)+`
|
|
63
|
+
`}function fx(e){var o;const t={destination:"",notes:"",decisions:[],unspecified:[],outOfScope:[]},n=e.split(/^##\s+/m).slice(1);for(const a of n){const l=a.indexOf(`
|
|
64
|
+
`),d=a.slice(0,l===-1?void 0:l).trim().toLowerCase(),h=(l===-1?"":a.slice(l+1)).trim(),f=(o=Gp.find(([,k])=>k.toLowerCase()===d))==null?void 0:o[0];if(!f)continue;const p=/^_none yet\._$/i.test(h),v=p?[]:h.split(`
|
|
65
|
+
`).map(k=>k.trim()).filter(k=>k.startsWith("- "));f==="destination"?t.destination=am(h):f==="notes"?t.notes=p?"":am(h):f==="assumptions"?t.assumptions=ox(v):f==="decisions"?t.decisions=v.map(k=>{const w=k.match(ux);return w&&w[1]&&/\d/.test(w[1])?{ticketKey:w[1],text:Gs(w[2])}:{text:Gs(k.slice(2))}}):t[f]=v.map(k=>Gs(k.slice(2)))}return t}const ra={chart:["Name destination","Find frontier","Create trail","Create tickets + wire blocking","Fire research"],work:["Load trail","Claim","Resolve","Record","Update plan"],research:["Claim","Investigate","Record"]},mx=(e,t)=>`${e[0].toUpperCase()}${e.slice(1)} ${t}/${ra[e].length}`;async function px(e,t,n={}){var d,h,f;const o=gx(t,t.mode??gs),a=await e.createMap({title:o.title,mode:o.mode,sections:o.sections,...o.verification?{verification:o.verification}:{}});await((d=n.onMapCreated)==null?void 0:d.call(n,a));const l=new Map;for(const p of o.tickets){const v=await e.createTicket(a.id,{title:p.title,type:p.type,hitl:p.hitl,body:`${p.body}
|
|
66
|
+
|
|
67
|
+
Part of trail ${a.key}.`});l.set(p.ref,v),await((h=n.onTicketCreated)==null?void 0:h.call(n,v,p.ref))}for(const p of o.tickets)for(const v of p.blockedBy??[]){const k=l.get(v),w=l.get(p.ref);k&&(await e.addBlocking(a.id,k.id,w.id),await((f=n.onEdgeWired)==null?void 0:f.call(n,k,w)))}return{map:a,tickets:[...l.values()]}}function gx(e,t){if(t==="plan+execute")return{...e,mode:t};const n=new Map(e.tickets.filter(a=>a.type==="execute").map(a=>[a.ref,a.blockedBy??[]])),o=a=>a.flatMap(l=>n.has(l)?o(n.get(l)):[l]);return{...e,mode:t,tickets:e.tickets.filter(a=>!n.has(a.ref)).map(a=>({...a,blockedBy:[...new Set(o(a.blockedBy??[]))]}))}}class Ae extends Error{}function Qp(e){if(e.archived)throw new Ae(`Trail ${e.key} "${e.title}" is archived: no work is taken from it. Only the trail lead can restore it in the Lookout.`)}class vx{constructor(){le(this,"tails",new Map)}run(t,n){const a=(this.tails.get(t)??Promise.resolve()).catch(()=>{}).then(n);return this.tails.set(t,a),a.finally(()=>this.tails.get(t)===a&&this.tails.delete(t)).catch(()=>{}),a}}const kx={frontier:"ready",blocked:"backlog",parked:"backlog",claimed:"working",verifying:"verifying",rework:"rework",held:"blocked",decided:"done","out-of-scope":"cancelled"};function yx(e,t,n=gs){return kx[Fp(e,t,n)]}const wx=["backlog","ready","working","verifying","rework","blocked"],Qi=["agent","trail lead"],xx=[{event:"claim",from:["ready","rework"],to:["working"],actors:Qi},{event:"release",from:["working"],to:["ready","rework"],actors:Qi},{event:"expire",from:["working"],to:["ready","rework"],actors:["engine","trail lead"]},{event:"complete",from:["backlog","ready","working","rework"],to:["done"],actors:Qi},{event:"submit",from:["working"],to:["verifying"],actors:Qi},{event:"checks.pass",from:["verifying"],to:["verifying","done"],actors:["engine"]},{event:"checks.fail",from:["verifying"],to:["rework","blocked"],actors:["engine"]},{event:"checks.error",from:["verifying"],to:["blocked"],actors:["engine"]},{event:"reverify",from:["verifying"],to:["verifying"],actors:["engine","trail lead"]},{event:"review.pass",from:["verifying"],to:["verifying","done"],actors:["engine"]},{event:"review.fail",from:["verifying"],to:["rework"],actors:["engine"]},{event:"review.needs_human",from:["verifying"],to:["blocked"],actors:["engine"]},{event:"approve",from:["verifying"],to:["done"],actors:["trail lead"]},{event:"reject",from:["verifying","blocked"],to:["rework"],actors:["trail lead"]},{event:"accept",from:["verifying","blocked"],to:["done"],actors:["trail lead"]},{event:"unblock",from:["blocked"],to:["ready","rework","verifying"],actors:["trail lead"]},{event:"cancel",from:wx,to:["cancelled"],actors:[...Qi,"engine"]},{event:"reopen",from:["done","cancelled"],to:["ready"],actors:["trail lead"]}],jx=e=>xx.find(t=>t.event===e),Sx=new vx;function Nx(e,t,n){if(n){if(!e.to.includes(n))throw new Ae(`${e.event} cannot lead to ${n}`);return n}if(e.to.length===1)return e.to[0];if(e.event==="release"||e.event==="expire")return t.status==="rework"?"rework":"ready";throw new Ae(`${e.event} needs a target: ${e.to.join(" or ")}`)}async function bx(e,t,n,o){const{to:a,actor:l}=o,d=async h=>{(n.status??null)!==h&&await e.setMeta(t,n.id,{status:h})};switch(a){case"working":n.assignee!==l&&await e.assign(t,n.id,l);return;case"ready":case"rework":n.state==="closed"&&await e.reopen(t,n.id),await d(a==="rework"?"rework":null),n.assignee&&await e.assign(t,n.id,null);return;case"verifying":case"blocked":await d(a);return;case"done":case"cancelled":await d(null),await e.close(t,n.id,a==="done"?"completed":"not_planned");return;case"backlog":throw new Ae("backlog follows from blockers; no transition leads there")}}function oa(e,t,n,o){return Sx.run(`${t}/${n}`,async()=>{var p;const a=await e.loadMap(t),l=a.tickets.find(v=>v.id===n);if(!l)throw new Ae(`ticket ${n} not found`);const d=yx(l,new Map(a.tickets.map(v=>[v.id,v])),a.map.mode);if(o.expect&&d!==o.expect)throw new Ae(`${l.key} changed: it is ${d} now`);const h=jx(o.event);if(!h.from.includes(d))throw new Ae(`${l.key} is ${d}; ${o.event} needs ${h.from.join(" or ")}`);if(!h.actors.includes(o.actorKind))throw new Ae(`${o.event} is not for ${o.actorKind}s`);const f=Nx(h,l,o.to);await bx(e,t,l,{to:f,actor:o.actor});try{await((p=o.journal)==null?void 0:p.append({v:1,kind:"transition",at:Date.now(),mapId:t,ticketId:n,ticketKey:l.key,event:o.event,from:d,to:f,actor:o.actor,actorKind:o.actorKind,...o.reason?{reason:o.reason}:{},...o.sessionId?{sessionId:o.sessionId}:{}}))}catch{}return{ticket:l,from:d,to:f}})}async function cm(e,t,n,o){const{assignee:a}=o,l=await e.loadMap(t),d=l.tickets.find(v=>v.id===n);if(!d)throw new Ae(`ticket ${n} not found`);Qp(l.map);const h=ti(l.tickets,l.map.mode).get(n);if(h!=="frontier"&&h!=="rework")throw new Ae(`${d.key} is ${h}, not on the frontier`);await oa(e,t,n,{event:"claim",actor:a,actorKind:o.actorKind??"agent",reason:o.reason,sessionId:o.sessionId,journal:o.journal});const p=(await e.loadMap(t)).tickets.find(v=>v.id===n);if(p.assignee!==a)throw new Ae(`${d.key} was claimed by ${p.assignee}`);return p}async function $x(e,t,n,o={}){const l=(await e.loadMap(t)).tickets.find(d=>d.id===n);if(!l)throw new Ae(`ticket ${n} not found`);await oa(e,t,n,{event:"release",actor:o.actor??l.assignee??"trail lead",actorKind:o.actorKind??"agent",reason:o.reason,sessionId:o.sessionId,journal:o.journal})}const Yp=e=>e==="lookout",Cx=e=>e.via==="chat"?`in ${e.chatOf??"an agent"}'s chat`:void 0;function Tx(e){return e.via?e.via==="chat"&&e.chatOf?{via:e.via,chatOf:e.chatOf}:{via:e.via}:{}}function Jp(e,t){return t==="lookout-limited"?`${e} is high risk: ask someone allowed to make high-risk calls.`:`${e} is high risk: decide it in the Lookout. Answers given in Slack don't count for it.`}async function Bo(e,t){const n=e.via??(e.sourceKind==="slack"?"slack":void 0);if(!n||Yp(n)||!t.ticketId)return;const o=t.key??t.ticketId,a=n==="lookout-limited"?"ask someone allowed to make high-risk calls":"decide it in the Lookout";if(!e.highRisk)throw new Ae(`Can't tell whether ${o} is high risk: ${a}.`);if(await e.highRisk(t.mapId,t.ticketId))throw new Ae(Jp(o,n))}async function Ex(e,t){var d;const{mapId:n,old:o,next:a}=t;await Bo(e,{mapId:n,ticketId:o.ticketId,key:o.ticketKey??o.id}),a.ticketId&&a.ticketId!==o.ticketId&&await Bo(e,{mapId:n,ticketId:a.ticketId,key:a.ticketKey});const l=e.via??(e.sourceKind==="slack"?"slack":void 0);if(l&&!Yp(l)&&((d=o.risk)==null?void 0:d.level)==="high")throw new Ae(Jp(o.id,l))}async function Cd(e,t,n,o={}){if(await Bo({...o.guard,sourceKind:n.source.kind},{mapId:t,ticketId:n.ticketId,key:n.ticketKey}),n.source.ref){const l=(await e.listDecisions(t)).find(d=>!d.postedBy&&d.source.kind===n.source.kind&&d.source.ref===n.source.ref);if(l)return l}const a=await e.createDecision(t,n);if(o.appendToTrail??!0){const l=await e.loadMap(t);await e.updateMapSections(t,{decisions:[...l.map.sections.decisions,{ticketId:a.ticketId,ticketKey:a.ticketKey,text:o.trailLine??a.summary}]})}return a}async function Ax(e,t,n,{guard:o,...a}){const d=(await e.listDecisions(t)).find(j=>j.id===n);if(!d)throw new Ae(`decision ${n} not found`);if(d.postedBy)throw new Ae(`${d.id} is ${d.postedBy}'s decision; record your own instead`);if(d.supersededBy)throw new Ae(`${d.id} is already superseded by ${d.supersededBy}`);const h={ticketId:d.ticketId,ticketKey:d.ticketKey,...a,question:a.question??d.question,supersedes:d.id};await Ex({...o,sourceKind:a.source.kind},{mapId:t,old:d,next:h});const f=await e.createDecision(t,h);await e.markSuperseded(t,d.id,f.id);const v=(await e.loadMap(t)).map.sections.decisions,k=v.findIndex(j=>j.text===d.summary||!!d.ticketId&&j.ticketId===d.ticketId||!!d.ticketKey&&j.ticketKey===d.ticketKey),w={ticketId:f.ticketId,ticketKey:f.ticketKey,text:f.summary};return await e.updateMapSections(t,{decisions:k<0?[...v,w]:v.map((j,N)=>N===k?w:j)}),f}async function Ix(e,t,n){await e.setMapMode(t,n)}function Xp(e){return e==="plan-only"?_o.filter(t=>t!=="execute"):_o}function Rx(e,t){if(!Xp(e).includes(t))throw new Ae(`${t} tickets are disabled on plan-only maps`)}const Jn={lookout:{label:"Lookout",code:"CMD"},agent:{label:"Agent",code:"AGT"},slack:{label:"Slack",code:"SLK"},tracker:{label:"Tracker",code:"TRK"}},Fo=Object.keys(Jn),Mx=e=>e in Jn,Zp=" (unverified, from text)";function rr(e){return e.derived||e.decidedBy.endsWith(Zp)?"unverified":e.postedBy?"teammate":e.source.kind==="agent"&&e.decidedBy!=="trail lead"&&!e.decidedBy.startsWith("slack:")?"agent":"human"}const eg=e=>e.postedBy?`posted by ${e.postedBy} in ${e.postedIn??"the tracker"}`:void 0,dr=e=>e.supersededBy?"superseded":"active";function aa(e){const t=e.replace(/\s+/g," ").trim(),n=t.match(/^(.{20,180}?[.!?])(\s|$)/);return n?n[1]:t.slice(0,180)}function Lx(e,t,n){var o;return{...n,id:e,mapId:t,decidedAt:n.decidedAt??Date.now(),summary:((o=n.summary)==null?void 0:o.trim())||aa(n.answer),alternatives:n.alternatives??[],rationale:n.rationale??"",participants:n.participants??[{id:n.decidedBy}],transcript:n.transcript??[]}}const Ox=e=>Number(e.replace(/\D/g,""))||0;function Px(e,t){const n=new Map(e.map(d=>[d.id,d])),o=new Set;let a=n.get(t);for(;a!=null&&a.supersedes&&n.has(a.supersedes)&&!o.has(a.id);)o.add(a.id),a=n.get(a.supersedes);const l=[];o.clear();for(let d=a;d&&!o.has(d.id);d=d.supersededBy?n.get(d.supersededBy):void 0)o.add(d.id),l.push(d);return l}async function _x(e,t,n,o){var d,h;const l=(await e.loadMap(t)).tickets.find(f=>f.id===n);if(!l)throw new Ae(`ticket ${n} not found`);if(l.state==="closed")throw new Ae(`${l.key} is already closed`);return await Bo({...o.guard,sourceKind:(h=(d=o.decision)==null?void 0:d.source)==null?void 0:h.kind},{mapId:t,ticketId:l.id,key:l.key}),o.transcript&&await e.comment(t,n,o.author,`**HITL transcript**
|
|
68
|
+
|
|
69
|
+
${o.transcript}`),await e.comment(t,n,o.author,`**Resolution**
|
|
70
|
+
|
|
71
|
+
${o.answer}`),await oa(e,t,n,{event:o.event??"complete",actor:o.actor??o.author,actorKind:o.actorKind??"agent",sessionId:o.sessionId,reason:o.reason,journal:o.journal,...o.event&&o.event!=="complete"?{to:"done"}:{}}),await Cd(e,t,Dx(l,o),{trailLine:o.trailLine,guard:o.guard}),l}function Dx(e,t){var o;const n=t.decision??{};return{ticketId:e.id,ticketKey:e.key,question:n.question??e.title,answer:n.answer??t.answer,summary:n.summary??t.summary??aa(t.answer),alternatives:n.alternatives,rationale:n.rationale,decidedBy:n.decidedBy??t.author,...n.decidedByName?{decidedByName:n.decidedByName}:{},participants:n.participants,source:n.source??{kind:"agent",label:t.author},transcript:n.transcript,...n.risk?{risk:n.risk}:{},...(o=n.assumes)!=null&&o.length?{assumes:n.assumes}:{}}}async function zx(e,t,n,o){const a=await e.loadMap(t);if(Qp(a.map),!a.map.sections.unspecified.includes(n))throw new Ae(`"${n}" is not in Not yet specified`);Rx(a.map.mode,o.type);const l=await e.createTicket(t,{title:o.title??n,type:o.type,hitl:o.hitl,body:`${o.body??`Promoted from Not yet specified: ${n}`}
|
|
72
|
+
|
|
73
|
+
Part of trail ${a.map.key}.`});for(const h of o.blockedBy??[])await e.addBlocking(t,h,l.id);const d=await e.loadMap(t);return await e.updateMapSections(t,{unspecified:d.map.sections.unspecified.filter(h=>h!==n)}),l}async function Bx(e,t,n,o){const a=await e.loadMap(t),{unspecified:l,outOfScope:d}=a.map.sections;if("unspecified"in n){if(!l.includes(n.unspecified))throw new Ae(`"${n.unspecified}" is not in Not yet specified`);await e.updateMapSections(t,{unspecified:l.filter(p=>p!==n.unspecified),outOfScope:[...d,`${n.unspecified} — ${o.reason}`]});return}const h=a.tickets.find(p=>p.id===n.ticketId);if(!h)throw new Ae(`ticket ${n.ticketId} not found`);await e.comment(t,h.id,o.author,`**Ruled out of scope**
|
|
74
|
+
|
|
75
|
+
${o.reason}`),await oa(e,t,h.id,{event:"cancel",actor:o.author,actorKind:o.actorKind??"agent",reason:o.reason,sessionId:o.sessionId,journal:o.journal}),await Cd(e,t,{ticketId:h.id,ticketKey:h.key,question:h.title,answer:`Out of scope: ${o.reason}`,decidedBy:o.author,source:o.source??{kind:"agent",label:o.author}},{appendToTrail:!1});const f=await e.loadMap(t);await e.updateMapSections(t,{outOfScope:[...f.map.sections.outOfScope,`${h.key} ${h.title} — ${o.reason}`]})}async function Fx(e,t,n,o){n&&Ux(n),await e.setMapMeta(t,{modelMatching:n&&Wx(n),confirm:!0})}function Ux(e){if(typeof e.enabled!="boolean")throw new Ae('"enabled" must be true or false');for(const[t,n]of Object.entries(e.tiers??{})){if(!na.includes(t))throw new Ae(`unknown ticket type "${t}"`);if(!Up(n))throw new Ae(`"${t}" must be fast, balanced or strongest`)}}function Wx(e){const t=Object.fromEntries(Object.entries(e.tiers??{}).filter(([,n])=>n));return Object.keys(t).length?{enabled:e.enabled,tiers:t}:{enabled:e.enabled}}async function Hx(e,t,n,o){await e.setMapArchived(t,n)}function Kx(e){return{async append(t){await fetch(`${e}/journal`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}}}const tg={v:1,default:"checks",appliesTo:["execute","task"],checks:{},run:[],failFast:!0,maxAttempts:3,totalTimeoutSec:1800,noChanges:{allow:["research","junction","prototype"],else:"flag"},scope:"flag",stale:"reverify",github:{enabled:"auto",requiredChecks:[],pollSec:60}};new Set(Object.keys(tg));const Vx=2*6e4,$c=e=>e<6e4?`${Math.round(e/1e3)}s`:`${Math.round(e/6e4)}m`;function Gx(e,t){if(!e)return{tone:"unknown",label:"PR sync ?",title:"PR/CI sync state unavailable"};const n=e.repo?` · ${e.repo}`:"",o=e.lastOkAt?`last ok ${$c(t-e.lastOkAt)} ago`:"never synced";return e.state==="off"?{tone:"off",label:"PR sync off",title:`PR/CI sync off: ${e.reason??"disabled"}`}:e.state==="failed"?{tone:"failed",label:"PR sync failed",title:`${e.reason??"sync failed"}${n}
|
|
76
|
+
${o}`}:e.state==="rate-limited"?{tone:"failed",label:"PR sync paused",title:`Rate limited${n}; retrying ${e.nextAt?`in ${$c(Math.max(0,e.nextAt-t))}`:"later"}
|
|
77
|
+
${o}`}:!e.lastOkAt||e.lastOkAt!==e.lastAttemptAt||e.nextAt!==void 0&&t>e.nextAt+Vx?{tone:"stale",label:"PR sync stale",title:`No recent sync${n}
|
|
78
|
+
${o}`}:{tone:"ok",label:`PR sync ${$c(t-e.lastOkAt)}`,title:`PR/CI synced${n}, ${o}`}}class Qs{constructor(){le(this,"listeners",new Set)}on(t){return this.listeners.add(t),()=>this.listeners.delete(t)}emit(t){for(const n of[...this.listeners])n(t)}}let qx=0;const Oo=(e="id")=>`${e}_${Date.now().toString(36)}${(qx++).toString(36)}`,Zc=(e,t)=>({inputTokens:((e==null?void 0:e.inputTokens)??0)+t.inputTokens,outputTokens:((e==null?void 0:e.outputTokens)??0)+t.outputTokens,costUsd:((e==null?void 0:e.costUsd)??0)+t.costUsd,...e!=null&&e.cachedInputTokens||t.cachedInputTokens?{cachedInputTokens:((e==null?void 0:e.cachedInputTokens)??0)+(t.cachedInputTokens??0)}:{}}),ng=(e,t)=>({inputTokens:e.inputTokens-((t==null?void 0:t.inputTokens)??0),outputTokens:e.outputTokens-((t==null?void 0:t.outputTokens)??0),costUsd:e.costUsd-((t==null?void 0:t.costUsd)??0),...e.cachedInputTokens||t!=null&&t.cachedInputTokens?{cachedInputTokens:(e.cachedInputTokens??0)-((t==null?void 0:t.cachedInputTokens)??0)}:{}});function Qx(e,t,n){const o=()=>e.find(t.id)??t,a=l=>e.push({source:"session",sessionId:t.id,agent:t.agent,...l});return{id:t.id,get info(){return o()},step(l,d,h){const f=ra[n][l-1];e.patchSession(t.id,{step:l,stepLabel:f,...h?{ticketId:h}:{}}),a({tag:mx(n,l),level:"step",text:d?`${f}: ${d}`:f,ticketId:h??o().ticketId})},log(l,d="info",h){a({level:d,text:l,ticketId:o().ticketId,...h?{kind:h}:{}})},say(l){e.chat({sessionId:t.id,ticketId:o().ticketId,from:"agent",author:t.agent,text:l})},ask(l,d,h){var p;const f={id:Oo("q"),sessionId:t.id,mapId:t.mapId,ticketId:o().ticketId,agent:t.agent,text:l,suggestions:d,at:Date.now(),...h!=null&&h.urgency?{urgency:h.urgency}:{},...(p=h==null?void 0:h.blocks)!=null&&p.length?{blocks:h.blocks}:{}};return e.chat({sessionId:t.id,ticketId:f.ticketId,from:"agent",author:t.agent,text:l,questionId:f.id}),e.addPending(f),e.patchSession(t.id,{waitingOn:f.id}),a({level:"alert",kind:"asks-you",ticketId:f.ticketId,text:"Decision request · waiting on you",signal:!0}),e.awaitAnswer(f.id)},done(l=!0,d,h){e.patchSession(t.id,{status:l?"done":"failed",endedAt:Date.now(),waitingOn:void 0}),e.dropPending(t.id),a({level:l?"ok":"alert",text:d??(l?"Session closed":"Session aborted"),signal:h==null?void 0:h.signal,...h!=null&&h.kind?{kind:h.kind}:{}})},bindMap(l){var h;const d=o().usage;d&&(e.addMapUsage(l,d),(h=e.ledger())==null||h.add(l,d,t.id)),e.patchSession(t.id,{mapId:l})},usage(l){var f;const d=o().mapId;(f=e.ledger())==null||f.add(d,l,t.id),e.addMapUsage(d,l);const h=o().usage;e.patchSession(t.id,{usage:{...Zc(h,l),source:l.source??(h==null?void 0:h.source)}})},setUsage(l){var v;const d=o().usage,h=ng(l,d);if(!h.inputTokens&&!h.outputTokens&&!h.costUsd&&!h.cachedInputTokens&&(d==null?void 0:d.source)===l.source&&`${d==null?void 0:d.models}`==`${l.models}`)return;const p=o().mapId;(h.inputTokens>0||h.outputTokens>0||h.costUsd>0)&&((v=e.ledger())==null||v.add(p,h,t.id)),e.addMapUsage(p,h),e.patchSession(t.id,{usage:l})},setModel(l,d){const h=o();h.model===l&&h.tier===d||e.patchSession(t.id,{model:l,tier:d})}}}class Yx{constructor(t=400,n){le(this,"state",{sessions:[],feed:[],chats:[],pending:[],answered:[],usageByMap:{}});le(this,"changes",new Qs);le(this,"resolvers",new Map);le(this,"remote",new Map);le(this,"remoteAnswer");le(this,"host",{find:t=>this.state.sessions.find(n=>n.id===t),patchSession:(t,n)=>this.patchSession(t,n),push:t=>void this.push(t),chat:t=>this.chat(t),addPending:t=>this.set({pending:[...this.state.pending,t]}),dropPending:t=>{this.state.pending.filter(o=>o.sessionId===t).length&&this.set({pending:this.state.pending.filter(o=>o.sessionId!==t)})},awaitAnswer:t=>new Promise(n=>this.resolvers.set(t,n)),addMapUsage:(t,n)=>{this.state={...this.state,usageByMap:{...this.state.usageByMap,[t]:Zc(this.state.usageByMap[t],n)}}},ledger:()=>this.ledger});this.maxFeed=t,this.ledger=n}get snapshot(){return this.state}subscribe(t){return this.changes.on(t)}set(t){this.state={...this.state,...t},this.changes.emit(this.state)}push(t){const n={id:Oo("f"),at:t.at??Date.now(),...t};return n.source==="system"&&!n.agent&&(n.agent=Z.assistant.name),this.set({feed:[...this.state.feed,n].slice(-this.maxFeed)}),n}patchSession(t,n){this.set({sessions:this.state.sessions.map(o=>o.id===t?{...o,...n}:o)})}chat(t){this.set({chats:[...this.state.chats,{id:Oo("m"),at:Date.now(),...t}].slice(-600)})}answer(t,n,o,a){var v;const l=this.state.pending.find(k=>k.id===t),d=this.resolvers.get(t),h=!!l&&this.remote.has(l.sessionId)&&!!this.remoteAnswer;if(!l||!d&&!h)return!1;this.resolvers.delete(t);const f=Tx(a),p=a.by?{by:a.by}:{};return this.chat({sessionId:l.sessionId,ticketId:l.ticketId,from:"human",author:o,text:n,...f,...p}),this.set({pending:this.state.pending.filter(k=>k.id!==t),answered:[...this.state.answered,{id:l.id,mapId:l.mapId,sessionId:l.sessionId,agent:l.agent,askedAt:l.at,answeredAt:Date.now(),...l.ticketId?{ticketId:l.ticketId}:{},...l.category?{category:l.category}:{},...(v=l.categories)!=null&&v.length?{categories:l.categories}:{},...l.urgency?{urgency:l.urgency}:{},...f,...p}].slice(-200)}),this.patchSession(l.sessionId,{waitingOn:void 0}),this.push({source:"trail lead",agent:o,level:"ok",kind:"answered",ticketId:l.ticketId,sessionId:l.sessionId,text:`Answered ${l.agent}`}),d?d(n):this.remoteAnswer(l,n,o),!0}syncRemote(t){var p;const{session:n}=t,o=n.id;if(!this.remote.has(o)&&this.state.sessions.some(v=>v.id===o))return;const a=this.remote.get(o);this.remote.set(o,n.mapId?n.usage:a);let l=this.state.usageByMap;if(n.usage&&n.mapId){const v=ng(n.usage,a);(v.inputTokens||v.outputTokens||v.costUsd)&&(l={...l,[n.mapId]:Zc(l[n.mapId],v)}),(p=this.ledger)==null||p.addTotal(n.mapId,o,n.usage)}const d=v=>v.filter(k=>k.sessionId!==o),h=new Set(this.state.answered.map(v=>v.id)),f=this.state.sessions.some(v=>v.id===o)?this.state.sessions.map(v=>v.id===o?n:v):[...this.state.sessions,n].slice(-24);this.set({sessions:f,chats:[...d(this.state.chats),...t.chats].sort((v,k)=>v.at-k.at).slice(-600),pending:[...d(this.state.pending),...t.pending],answered:[...this.state.answered,...t.answered.filter(v=>!h.has(v.id))].sort((v,k)=>v.answeredAt-k.answeredAt).slice(-200),feed:[...this.state.feed.filter(v=>v.sessionId!==o),...t.feed].sort((v,k)=>v.at-k.at).slice(-this.maxFeed),usageByMap:l})}isRemote(t){return this.remote.has(t)}startSession(t){const n={...t,id:t.id??Oo("s"),step:0,total:ra[t.mode].length,stepLabel:"BOOT",status:"running",startedAt:Date.now()};this.set({sessions:[...this.state.sessions,n].slice(-24)});const o=Qx(this.host,n,t.mode);return this.push({source:"session",sessionId:n.id,agent:n.agent,level:"info",text:`Session opened · ${t.mode}`}),o}}function Jx(e,t){const n=o=>{var a;return((a=t(o))==null?void 0:a.key)??o};switch(e.kind){case"map.created":return{source:"tracker",level:"ok",text:`Trail created · label ${jd}`};case"map.updated":return{source:"tracker",level:"info",text:`Trail updated${e.section?` · ${dx[e.section].toLowerCase()}`:""}`};case"map.mode":return{source:"tracker",level:"warn",text:`Trail mode · ${e.mode}`};case"ticket.created":return{source:"tracker",level:"info",ticketId:e.ticketId,text:`Opened ${n(e.ticketId)}`};case"ticket.claimed":return{source:"tracker",level:"warn",ticketId:e.ticketId,text:`Assigned ${n(e.ticketId)} to ${e.assignee}`};case"ticket.released":return{source:"tracker",level:"info",ticketId:e.ticketId,text:`Unassigned ${n(e.ticketId)}`};case"ticket.closed":return{source:"tracker",level:e.reason==="completed"?"ok":"alert",...e.reason==="completed"?{kind:"done"}:{},ticketId:e.ticketId,text:`Closed ${n(e.ticketId)} · ${e.reason==="completed"?"completed":"not planned"}`};case"ticket.commented":return{source:"tracker",level:"info",ticketId:e.ticketId,text:`Comment on ${n(e.ticketId)}`};case"edge.added":return{source:"tracker",level:"info",ticketId:e.blockedId,text:`${n(e.blockerId)} blocks ${n(e.blockedId)}`};case"edge.removed":return{source:"tracker",level:"info",ticketId:e.blockedId,text:`${n(e.blockerId)} no longer blocks ${n(e.blockedId)}`};case"decision.recorded":return{source:"tracker",level:"ok",ticketId:e.ticketId,text:`Decision ${e.decisionId} recorded${e.ticketId?` · ${n(e.ticketId)}`:""}`};case"decision.superseded":return{source:"tracker",level:"warn",text:`Decision ${e.decisionId} superseded by ${e.supersededBy}`};case"external.changed":return{source:"tracker",level:"warn",text:"External change detected · resynced"};default:return null}}const Xx=new Set(["createMap","setMapMode","setMapArchived","setMapMeta","updateMapSections","createTicket","addBlocking","removeBlocking","editTicket","reopen","assign","comment","close","setMeta","createDecision","markSuperseded"]),Zx=5*6e4;function ej(e){let t={status:"idle",inflight:0,writes:0,errors:0,events:[]};const n=new Qs,o=l=>{t={...t,...l},n.emit(t)};return e.subscribe(l=>{const d=l.at-Zx;o({events:[...t.events.filter(h=>h.at>=d),{at:l.at,external:l.kind==="external.changed"||"external"in l&&!!l.external}]})}),{adapter:new Proxy(e,{get(l,d,h){const f=Reflect.get(l,d,h);return typeof f!="function"?f:Xx.has(d)?async(...p)=>{const v=Date.now();o({inflight:t.inflight+1,status:"syncing"});try{const k=await f.apply(l,p),w=t.inflight-1;return o({inflight:w,writes:t.writes+1,lastWriteMs:Date.now()-v,lastWriteAt:Date.now(),status:w?"syncing":"ok",lastError:void 0}),k}catch(k){const w=t.inflight-1;throw o({inflight:w,errors:t.errors+1,status:"error",lastError:String(k.message??k)}),k}}:f.bind(l)}}),get health(){return t},subscribe:l=>n.on(l)}}function sg(e){const t={decided:0,claimed:0,frontier:0,blocked:0,parked:0,"out-of-scope":0,verifying:0,rework:0,held:0,total:e.tickets.length,resolvedPct:0};for(const n of ti(e.tickets,e.map.mode).values())t[n]++;return t.resolvedPct=t.total?Math.round((t.decided+t["out-of-scope"])/t.total*100):0,t}function ig(e){const t=sg(e);return{decided:t.decided,total:t.total-t["out-of-scope"]}}function tj(e){const t=new Map(e.tickets.filter(d=>d.state==="open").map(d=>[d.id,d])),n=new Map,o=new Set,a=d=>{if(n.has(d))return n.get(d);if(o.has(d))return[];o.add(d);const h=t.get(d);let f=[];for(const v of h.blockedBy)if(t.has(v)){const k=a(v);k.length>f.length&&(f=k)}o.delete(d);const p=[...f,h];return n.set(d,p),p};let l=[];for(const d of t.keys()){const h=a(d);h.length>l.length&&(l=h)}return l}function nj(e){return _o.map(t=>{const n=e.tickets.filter(o=>o.type===t);return{type:t,open:n.filter(o=>o.state==="open").length,closed:n.filter(o=>o.state==="closed").length}}).filter(t=>t.open+t.closed>0)}function sj(e,t){const n=e.pending.filter(a=>!0),o=e.answered.filter(a=>!0);return{open:n.length,oldestAt:n.length?Math.min(...n.map(a=>a.at)):void 0,answered:o.length,avgWaitMs:o.length?o.reduce((a,l)=>a+(l.answeredAt-l.askedAt),0)/o.length:void 0}}function rg(e,t){return t&&e.usageByMap[t]||{inputTokens:0,outputTokens:0,costUsd:0}}const ij=e=>e.usage?e.usage.inputTokens+e.usage.outputTokens:0,og={"claude-code":{tag:"LOG",text:"Measured from the Claude Code session transcript; cost at list price"},codex:{tag:"LOG",text:"Measured from the Codex session log; cost at list price"},reported:{tag:"SELF",text:"Self-reported by the agent (report_progress)"}};function ag(e,t){var o;const n=new Set;for(const a of e.sessions)t&&a.mapId===t&&((o=a.usage)!=null&&o.source)&&n.add(a.usage.source);return[...n].sort()}function rj(e,t){return e.replace(/^\*\*HITL transcript\*\*\s*/,"").split(/\n\n(?=\*\*[^*]+:\*\* )/).map(n=>n.match(/^\*\*([^*]+):\*\* ([\s\S]*)$/)).filter(n=>!!n).map(n=>({from:"agent",author:n[1],text:n[2].trim(),at:t}))}function oj(e,t){const n=new Set(t.map(a=>a.ticketId).filter(Boolean)),o=e.tickets.filter(a=>a.state==="closed"&&a.closeReason==="completed"&&!n.has(a.id)).map(a=>{var v;const l=[...a.comments].reverse().find(k=>k.body.startsWith("**Resolution**")),d=l?l.body.replace(/^\*\*Resolution\*\*\s*/,""):((v=e.map.sections.decisions.find(k=>k.ticketId===a.id||k.ticketKey===a.key))==null?void 0:v.text)??"",h=(l==null?void 0:l.author)??a.assignee??"unknown",f=a.comments.find(k=>k.body.startsWith("**HITL transcript**")),p=f?rj(f.body,f.createdAt):[];return{id:`T${a.key}`,mapId:e.map.id,ticketId:a.id,ticketKey:a.key,question:a.title,answer:d,summary:aa(d),alternatives:[],rationale:"",decidedBy:`${h}${Zp}`,decidedAt:a.closedAt??(l==null?void 0:l.createdAt)??a.updatedAt,participants:[...new Set([h,...p.map(k=>k.author)])].map(k=>({id:k})),source:{kind:"tracker",ref:`${e.map.id}/tickets/${a.id}`,label:`unverified, from text: ${l?`${a.key} resolution comment`:"the map’s Decisions so far"}`},transcript:p,derived:!0}});return[...t,...o].sort((a,l)=>l.decidedAt-a.decidedAt)}function aj(e,t){var o;const n=(o=t.query)==null?void 0:o.trim().toLowerCase();return e.filter(a=>(!t.mapId||a.mapId===t.mapId)&&(!t.source||a.source.kind===t.source)&&(!t.decidedBy||a.decidedBy===t.decidedBy)&&(!t.madeBy||rr(a)===t.madeBy)&&(!t.status||dr(a)===t.status)&&(!n||[a.id,a.ticketKey,a.question,a.answer,a.summary,a.rationale,a.decidedBy,...a.alternatives,...a.transcript.map(l=>l.text)].join(`
|
|
79
|
+
`).toLowerCase().includes(n)))}function lj(e,t=Date.now()){const n=Object.fromEntries(Fo.map(d=>[d,0]));let o=0,a=0,l=0;for(const d of e){n[d.source.kind]++,d.supersededBy&&o++,t-d.decidedAt<864e5&&a++;const h=rr(d);(h==="human"||h==="agent"&&d.transcript.some(f=>f.from==="human"))&&l++}return{total:e.length,active:e.length-o,superseded:o,last24h:a,human:l,bySource:n}}function la(e){const t=e.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);if(!t)return{front:{},body:e};const n={};for(const o of t[1].split(`
|
|
80
|
+
`)){const a=o.indexOf(":");if(a<0)continue;const l=o.slice(0,a).trim(),d=o.slice(a+1).trim();Ow(l)&&(n[l]=d.startsWith("[")?uj(d.slice(1,-1)).map(um).filter(Boolean):um(d))}return{front:n,body:t[2]}}const cj=e=>e===""||/^[\s#&*!|>'"%@`[\]{},?:-]|[:#]\s|\s$|,|["\\[\]]/.test(e)||Zw(e)||/^(true|false|null|~|\d[\d.e+-]*)$/i.test(e),dj=e=>JSON.stringify(e).replace(/[\u007f\u0085\u2028\u2029]/g,t=>`\\u${t.charCodeAt(0).toString(16).padStart(4,"0")}`),dm=e=>cj(e)?dj(e):e;function um(e){if(e.startsWith('"'))try{return JSON.parse(e)}catch{return e.slice(1,-1)}return e.startsWith("'")?e.slice(1,-1).replace(/''/g,"'"):e}function uj(e){const t=[];let n="",o=!1,a=!1;for(const l of e)l==='"'&&!a&&(o=!o),a=o&&l==="\\"&&!a,l===","&&!o?(t.push(n.trim()),n=""):n+=l;return n.trim()&&t.push(n.trim()),t}function hj(e){if(!/^[\w-]+$/.test(e))throw new Error(`invalid frontmatter key: ${JSON.stringify(e)}`);return e}function Td(e,t){return`---
|
|
81
|
+
${Object.entries(e).map(([o,a])=>`${hj(o)}: ${Array.isArray(a)?`[${a.map(dm).join(", ")}]`:dm(a)}`).join(`
|
|
82
|
+
`)}
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
${t.trim()}
|
|
86
|
+
`}const ye=e=>Array.isArray(e)?e.join(","):e??"";function qt(e){return Array.isArray(e)?e:e?[e]:[]}const qs=e=>Date.parse(ye(e))||0,cn=e=>new Date(e).toISOString(),lg=["schema","breaking-api","auth-permissions","billing","data-deletion","product-behaviour","dependencies"],cg=["low","medium","high"],fj=e=>lg.includes(e),mj=e=>cg.includes(e);function pj(e){return e?{risk:e.level,...e.category?{risk_category:e.category}:{},risk_reason:e.reason}:{}}function gj(e){const t=ye(e.risk);if(!mj(t))return{};const n=ye(e.risk_category);return{risk:{level:t,...fj(n)?{category:n}:{},reason:ye(e.risk_reason)}}}const dg=["Question","Decision","Summary","Alternatives","Rationale","Transcript"],Ed=`## (?:${dg.join("|")})\\s*$`,ug=`${Ed}|### `,bo=e=>sa(e.trim(),Ed),vj=e=>e.name?`${e.id}|${e.name}`:e.id,kj=e=>{const t=e.indexOf("|");return t<0?{id:e}:{id:e.slice(0,t),name:e.slice(t+1)}};function hg(e){var l;const t={id:e.id,trail:e.mapId,...e.ticketId?{ticket:e.ticketId,ticket_key:e.ticketKey??""}:{},decided_by:e.decidedBy,...e.decidedByName?{decided_by_name:hs(e.decidedByName).slice(0,100)}:{},decided_at:cn(e.decidedAt),participants:e.participants.map(vj),source:e.source.kind,...e.source.ref?{source_ref:e.source.ref}:{},...e.source.url?{source_url:e.source.url}:{},...e.source.label?{source_label:e.source.label}:{},...e.source.meta?{source_meta:Object.entries(e.source.meta).map(([d,h])=>`${d}=${h}`)}:{},...e.supersedes?{supersedes:e.supersedes}:{},...e.supersededBy?{superseded_by:e.supersededBy}:{},...pj(e.risk),...(l=e.assumes)!=null&&l.length?{assumes:e.assumes}:{}},n=d=>d.length?d.map(h=>`- ${hs(h)}`).join(`
|
|
87
|
+
`):"_None._",o=e.transcript.length?e.transcript.map(d=>`### ${hs(d.author)} · ${d.from} @ ${cn(d.at)}
|
|
88
|
+
|
|
89
|
+
${sa(d.text.trim(),ug)}`).join(`
|
|
90
|
+
|
|
91
|
+
`):"_None._",a=[`## Question
|
|
92
|
+
|
|
93
|
+
${bo(e.question)}`,`## Decision
|
|
94
|
+
|
|
95
|
+
${bo(e.answer)}`,`## Summary
|
|
96
|
+
|
|
97
|
+
${bo(e.summary)}`,`## Alternatives
|
|
98
|
+
|
|
99
|
+
${n(e.alternatives)}`,`## Rationale
|
|
100
|
+
|
|
101
|
+
${bo(e.rationale)||"_None._"}`,`## Transcript
|
|
102
|
+
|
|
103
|
+
${o}`].join(`
|
|
104
|
+
|
|
105
|
+
`);return Td(t,a)}function ed(e){const{front:t,body:n}=la(e),o={},a=new RegExp(`^## (${dg.join("|")})\\s*$`,"gm"),l=[...n.matchAll(a)];l.forEach((k,w)=>{var I;const j=n.slice(k.index+k[0].length,((I=l[w+1])==null?void 0:I.index)??n.length).trim(),N=k[1],S=N==="Transcript"?j:zo(j,Ed);o[N]=/^_none\._$/i.test(j)?"":S});const d=(o.Transcript??"").split(/^### /m).slice(1).map(k=>{const w=k.indexOf(`
|
|
106
|
+
`),j=w<0?k:k.slice(0,w),N=j.lastIndexOf(" @ "),S=N<0?j:j.slice(0,N),I=N<0?"":j.slice(N+3),$=S.lastIndexOf(" · "),_=$<0?S:S.slice(0,$),O=$<0?"agent":S.slice($+3);return{author:_.trim(),from:["agent","human","system"].includes(O.trim())?O.trim():"agent",at:Date.parse(I)||0,text:w<0?"":zo(k.slice(w+1).trim(),ug)}}),h=ye(t.source),f=qt(t.source_meta),p={kind:Mx(h)?h:"tracker",...ye(t.source_ref)?{ref:ye(t.source_ref)}:{},...ye(t.source_url)?{url:ye(t.source_url)}:{},...ye(t.source_label)?{label:ye(t.source_label)}:{},...f.length?{meta:Object.fromEntries(f.map(k=>[k.slice(0,k.indexOf("=")),k.slice(k.indexOf("=")+1)]))}:{}},v=o.Decision??"";return{id:ye(t.id),mapId:ye(t.trail),ticketId:ye(t.ticket)||void 0,ticketKey:ye(t.ticket_key)||void 0,question:o.Question??"",answer:v,summary:o.Summary||aa(v),alternatives:(o.Alternatives??"").split(`
|
|
107
|
+
`).map(k=>k.trim()).filter(k=>k.startsWith("- ")).map(k=>k.slice(2)),rationale:o.Rationale??"",decidedBy:ye(t.decided_by),...ye(t.decided_by_name)?{decidedByName:ye(t.decided_by_name)}:{},decidedAt:qs(t.decided_at),participants:qt(t.participants).map(kj),source:p,supersedes:ye(t.supersedes)||void 0,supersededBy:ye(t.superseded_by)||void 0,...qt(t.assumes).length?{assumes:qt(t.assumes)}:{},transcript:d,...gj(t)}}function yj(e){return e.url?` · [${e.label??"link"}](${e.url})`:e.label?` · ${e.label}`:""}function wj(e,t,n={}){const o=[`# ${n.title??"Decisions"}`,"",`Exported ${cn(n.now??Date.now())} · ${e.length} decisions`],a=new Map;for(const l of e)a.set(l.mapId,[...a.get(l.mapId)??[],l]);for(const[l,d]of a){const h=t[l];o.push("",`## Trail ${h?`${h.key} ${h.title}`:l}`);for(const f of d){const p=Jn[f.source.kind].label;o.push("",`### ${f.id}${f.ticketKey?` · ${f.ticketKey}`:""} · ${f.question}`,"",`- **Status:** ${dr(f)}${f.supersededBy?` (superseded by ${f.supersededBy})`:""}${f.supersedes?` · supersedes ${f.supersedes}`:""}`,`- **Decided by:** ${f.decidedBy} · ${cn(f.decidedAt)}`,`- **Source:** ${p}${yj(f.source)}`,...f.participants.length?[`- **Participants:** ${f.participants.map(v=>v.name??v.id).join(", ")}`]:[],"",`**Decision:** ${f.answer}`,...f.alternatives.length?["","**Alternatives:**",...f.alternatives.map(v=>`- ${v}`)]:[],...f.rationale?["",`**Rationale:** ${f.rationale}`]:[],...f.transcript.length?["","<details><summary>Transcript</summary>","",...f.transcript.map(v=>`> **${v.author}:** ${v.text.replace(/\n/g,`
|
|
108
|
+
> `)}
|
|
109
|
+
>`),"","</details>"]:[])}}return o.join(`
|
|
110
|
+
`)+`
|
|
111
|
+
`}function td(e,t,n){try{const o=e.get(t);return o?JSON.parse(o):n}catch{return n}}class hm{constructor(t,n="presence"){le(this,"seen");this.store=t,this.key=n,this.seen=td(t,n,{})}snapshot(){return{...this.seen}}lastSeen(t){return this.seen[t]}lastSeenAny(){const t=Object.values(this.seen);return t.length?Math.max(...t):void 0}markSeen(t,n=Date.now()){let o=!1;for(const a of t)(this.seen[a]??0)>=n||(this.seen[a]=n,o=!0);o&&this.store.set(this.key,JSON.stringify(this.seen))}}const Cc=5*6e4,xj=14*864e5;class fm{constructor(t,n="usage"){le(this,"buckets");le(this,"dirty",!1);le(this,"timer");le(this,"totals");this.store=t,this.key=n,this.buckets=td(t,n,{}),this.totals=td(t,`${n}.totals`,{})}addTotal(t,n,o,a=Date.now()){const l=this.totals[n],d={inputTokens:o.inputTokens-((l==null?void 0:l.inputTokens)??0),outputTokens:o.outputTokens-((l==null?void 0:l.outputTokens)??0),costUsd:o.costUsd-((l==null?void 0:l.costUsd)??0)};this.totals[n]={...o,at:a},d.inputTokens>0||d.outputTokens>0||d.costUsd>0?this.add(t,d,n,a):this.save()}add(t,n,o,a=Date.now()){var f;if(!t)return;const l=Math.floor(a/Cc)*Cc,d=(f=this.buckets)[t]??(f[t]=[]);let h=d.find(p=>p.at===l);h||(h={at:l,i:0,o:0,c:0,s:[]},d.push(h),d.sort((p,v)=>p.at-v.at)),h.i+=n.inputTokens,h.o+=n.outputTokens,h.c+=n.costUsd,h.s.includes(o)||h.s.push(o),this.save()}since(t,n){const o={inputTokens:0,outputTokens:0,costUsd:0,sessions:0},a=new Set;for(const l of this.buckets[t]??[])l.at+Cc<=n||(o.inputTokens+=l.i,o.outputTokens+=l.o,o.costUsd+=l.c,l.s.forEach(d=>a.add(d)));return o.sessions=a.size,o}save(){this.dirty=!0,!this.timer&&(this.timer=setTimeout(()=>{if(this.timer=void 0,!this.dirty)return;this.dirty=!1;const t=Date.now()-xj;for(const n of Object.keys(this.buckets))this.buckets[n]=this.buckets[n].filter(o=>o.at>=t);for(const[n,o]of Object.entries(this.totals))o.at<t&&delete this.totals[n];this.store.set(this.key,JSON.stringify(this.buckets)),this.store.set(`${this.key}.totals`,JSON.stringify(this.totals))},2e3))}}function jj(e){const t=e.now??Date.now(),n=e.snaps.map(d=>{var oe;const h=d.map.id,f=e.since(h),p=Q=>!!Q&&Q>=f,v=ti(d.tickets,d.map.mode),k=new Map(d.tickets.map(Q=>[Q.id,Q])),w=(e.attention??[]).filter(Q=>Q.mapId===h),j=Sj(e.activity.pending.filter(Q=>Q.mapId===h),w),N=new Set(j.map(Q=>Q.ticketId)),S=Q=>Q.state==="open"&&(N.has(Q.id)||cr(Q)==="hitl"),I=d.tickets.filter(Q=>v.get(Q.id)==="blocked").map(Q=>({ticket:Q,on:Q.blockedBy.map(ke=>k.get(ke)).filter(ke=>!!ke&&S(ke))})).filter(Q=>Q.on.length),$=e.decisions.filter(Q=>Q.mapId===h&&p(Q.decidedAt)).sort((Q,ke)=>ke.decidedAt-Q.decidedAt),_=d.tickets.filter(Q=>Q.state==="closed"&&p(Q.closedAt)).sort((Q,ke)=>(Q.closedAt??0)-(ke.closedAt??0)),O=_.filter(Q=>Q.closeReason==="completed"),D=_.filter(Q=>Q.closeReason==="not_planned"),q=d.tickets.filter(Q=>p(Q.createdAt)),H=((oe=e.ledger)==null?void 0:oe.since(h,f))??{inputTokens:0,outputTokens:0,costUsd:0,sessions:0},G=e.activity.sessions.filter(Q=>Q.mapId===h&&Q.status==="running");return{mapId:h,key:d.map.key,title:d.map.title,since:f,done:O,ruledOut:D,opened:q,blocked:I,waiting:j,needsYou:w,decisions:$,agentDecisions:$.filter(Q=>rr(Q)==="agent"),usage:H,active:G,changed:!!(_.length||q.length||$.length||j.some(Q=>p(Q.at))||H.costUsd>0)}}),o=n.filter(d=>d.changed||d.waiting.length).sort((d,h)=>+(h.mapId===e.currentMapId)-+(d.mapId===e.currentMapId)),a=d=>o.reduce((h,f)=>h+f[d].length,0),l=o.flatMap(d=>d.waiting).reduce((d,h)=>d===void 0||h.at<d?h.at:d,void 0);return{since:o.length?Math.min(...o.map(d=>d.since)):t,now:t,trails:o,totals:{done:a("done"),ruledOut:a("ruledOut"),blocked:a("blocked"),waiting:a("waiting"),oldestWaitMs:l===void 0?void 0:t-l,agentDecisions:a("agentDecisions"),usage:o.reduce((d,h)=>({inputTokens:d.inputTokens+h.usage.inputTokens,outputTokens:d.outputTokens+h.usage.outputTokens,costUsd:d.costUsd+h.usage.costUsd,sessions:d.sessions+h.usage.sessions}),{inputTokens:0,outputTokens:0,costUsd:0,sessions:0}),active:a("active")},changed:n.some(d=>d.changed)}}function Sj(e,t){const n=new Map(t.filter(a=>a.kind==="question").map((a,l)=>[a.ref,l])),o=a=>n.get(a.id)??Number.MAX_SAFE_INTEGER;return[...e].sort((a,l)=>o(a)-o(l)||a.at-l.at)}const er=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`;function Nj(e){return e.trails.flatMap(t=>{const n=new Set(t.waiting.map(o=>o.ticketId));return t.blocked.filter(o=>o.on.some(a=>n.has(a.id)))})}function bj(e){return e.length===1?`, and it holds up ${e[0].ticket.title.replace(/^./,t=>t.toLowerCase())}`:e.length>1?`, holding up ${er(e.length,"ticket")}`:""}function $j(e,t=new Date(e.now).getHours()){const n=e.totals,a=e.now-e.since>=6*36e5&&t>=5&&t<12?"Good morning.":"Welcome back.",l=[];if(n.done&&l.push(`${er(n.done,"ticket")} ${n.done===1?"is":"are"} done.`),n.agentDecisions&&l.push(`Agents made ${er(n.agentDecisions,"decision")}.`),n.waiting){const d=bj(Nj(e));l.push(`${er(n.waiting,"decision")} ${n.waiting===1?"is":"are"} waiting on you${d}.`)}else l.push("Nothing is waiting on you.");return!n.done&&!n.agentDecisions&&n.ruledOut&&l.unshift(`${er(n.ruledOut,"ticket")} ruled out of scope.`),[a,...l].join(" ")}const Cj=e=>{if(!e.length)return;const t=[...e].sort((o,a)=>o-a),n=Math.floor(t.length/2);return t.length%2?t[n]:Math.round((t[n-1]+t[n])/2)};function Tj(e){return e.state==="open"?"open":e.closeReason==="not_planned"?"cancelled":"done"}function fg({snap:e,journal:t,answered:n,usage:o}){const a=e.map.id,l=t.filter(S=>S.mapId===a).sort((S,I)=>S.at-I.at),d=new Map;for(const S of l)d.set(S.ticketId,[...d.get(S.ticketId)??[],S]);const h=e.tickets.filter(S=>S.type!=="review").map(S=>{var D;const I=d.get(S.id)??[],$=Tj(S),_=(D=I.find(q=>q.event==="claim"))==null?void 0:D.at,O=$==="done"?S.closedAt:void 0;return{id:S.id,key:S.key,title:S.title,type:S.type,outcome:$,claimedAt:_,doneAt:O,leadMs:O&&_&&O>=_?O-_:void 0,reworks:I.filter(q=>q.to==="rework").length,reviews:{passed:I.filter(q=>q.event==="review.pass").length,failed:I.filter(q=>q.event==="review.fail").length,needsHuman:I.filter(q=>q.event==="review.needs_human").length},operatorActions:I.filter(q=>q.actorKind==="trail lead").length}}),f=h.filter(S=>S.outcome==="done"),p=Math.max(0,...f.map(S=>S.doneAt??0)),v=l.filter(S=>S.actorKind==="trail lead"),k=new Set(n.filter(S=>S.mapId===a).map(S=>S.id)).size,w=v.length,j=S=>h.reduce((I,$)=>I+S($),0),N=(o==null?void 0:o.costUsd)??0;return{mapId:a,tickets:h,done:f.length,cancelled:h.filter(S=>S.outcome==="cancelled").length,open:h.filter(S=>S.outcome==="open").length,trailLeadMs:p&&p>=e.map.createdAt?p-e.map.createdAt:void 0,medianLeadMs:Cj(f.flatMap(S=>S.leadMs===void 0?[]:[S.leadMs])),interventions:{answers:k,operatorActions:w,reworkRequested:v.filter(S=>S.event==="reject").length,total:k+w},rework:{tickets:h.filter(S=>S.reworks>0).length,cycles:j(S=>S.reworks)},reviews:{passed:j(S=>S.reviews.passed),failed:j(S=>S.reviews.failed),needsHuman:j(S=>S.reviews.needsHuman)},spend:{costUsd:Math.round(N*1e4)/1e4,tokens:((o==null?void 0:o.inputTokens)??0)+((o==null?void 0:o.outputTokens)??0),perVerifiedTicketUsd:f.length&&N?Math.round(N/f.length*1e4)/1e4:void 0}}}const Tc=e=>e.split("-")[0];function Qt(e){if(e===void 0)return"—";const t=Math.round(e/6e4);if(t<90)return`${t} min`;const n=e/36e5;return n<48?`${Math.round(n*10)/10} h`:`${Math.round(n/24*10)/10} d`}const mm=e=>e===void 0?"—":`$${e.toFixed(e<1?4:2)}`;function Ej(e,t,n=Date.now()){const o=e.interventions;return[`# Trail report: ${t}`,"",`_Generated ${new Date(n).toISOString()} by Teamtrail._`,"","| Measure | Value |","| --- | --- |",`| Tickets done / cancelled / open | ${e.done} / ${e.cancelled} / ${e.open} |`,`| Trail lead time (created → last done) | ${Qt(e.trailLeadMs)} |`,`| Median ticket lead time (claim → done) | ${Qt(e.medianLeadMs)} |`,`| Human interventions | ${o.total} (${o.answers} answers, ${o.operatorActions} operator actions, ${o.reworkRequested} sent back) |`,`| Rework | ${e.rework.cycles} cycles on ${e.rework.tickets} tickets |`,`| Reviews | ${e.reviews.passed} passed, ${e.reviews.failed} failed, ${e.reviews.needsHuman} needed a human |`,`| Spend | ${mm(e.spend.costUsd)} · ${e.spend.tokens.toLocaleString("en-US")} tokens |`,`| Cost per verified ticket | ${mm(e.spend.perVerifiedTicketUsd)} |`,"","## Tickets","","| Ticket | Type | Outcome | Lead time | Rework | Reviews (pass/fail) | Operator actions |","| --- | --- | --- | --- | --- | --- | --- |",...e.tickets.map(l=>`| ${l.key} ${l.title.replace(/\|/g,"\\|")} | ${l.type} | ${l.outcome} | ${Qt(l.leadMs)} | ${l.reworks} | ${l.reviews.passed}/${l.reviews.failed} | ${l.operatorActions} |`),""].join(`
|
|
112
|
+
`)}const Ad=5,mg=1.5,Aj=15,$o=e=>Math.round(e*100);function Ij(e){const t=e.filter(d=>d.findings.raised>=Ad).sort((d,h)=>h.findings.upheld/h.findings.raised-d.findings.upheld/d.findings.raised||d.key.localeCompare(h.key));if(t.length<2)return[];const[n,o]=[t[0],t[t.length-1]],[a,l]=[n.findings.upheld/n.findings.raised,o.findings.upheld/o.findings.raised];return $o(a)-$o(l)<Aj?[]:[{id:"review-findings",text:`${n.key} review findings upheld ${$o(a)}% vs ${o.key} ${$o(l)}%`,because:`${n.findings.upheld} of ${n.findings.raised} and ${o.findings.upheld} of ${o.findings.raised} failed reviews stood; a finding is overruled when you accept the work anyway`}]}function Rj(e){const t=l=>l.reworkCycles/l.tickets,n=e.filter(l=>l.tickets>=Ad).sort((l,d)=>t(l)-t(d)||l.key.localeCompare(d.key));if(n.length<2)return[];const[o,a]=[n[0],n[n.length-1]];return t(a)-t(o)<.2||t(a)<t(o)*mg?[]:[{id:"rework",text:`${a.key} work goes back to rework more: ${t(a).toFixed(1)} times per ticket vs ${o.key} ${t(o).toFixed(1)}`,because:`${a.reworkCycles} cycles on ${a.tickets} tickets, and ${o.reworkCycles} on ${o.tickets}`}]}function Mj(e,t){const n=d=>d.medianLeadMs??0,o=t.filter(d=>d.done>=Ad&&d.medianLeadMs!==void 0).sort((d,h)=>n(d)-n(h)||d.key.localeCompare(h.key));if(o.length<2)return[];const[a,l]=[o[0],o[o.length-1]];return n(l)<n(a)*mg?[]:[{id:`speed-${e}`,text:`${e} tickets: ${a.key} is faster, ${Qt(a.medianLeadMs)} vs ${l.key} ${Qt(l.medianLeadMs)}`,because:`Median first claim to done, over ${a.done} and ${l.done} done tickets`}]}function Lj(e){const t=Object.keys(e.byTypeAndVendor).sort();return[...Ij(e.byVendor),...Rj(e.byVendor),...t.flatMap(n=>Mj(n,e.byTypeAndVendor[n]))]}const Oj=e=>{if(!e.length)return;const t=[...e].sort((o,a)=>o-a),n=Math.floor(t.length/2);return t.length%2?t[n]:Math.round((t[n-1]+t[n])/2)},pg=e=>{var t;return(t=e.filter(n=>n.event==="claim"&&n.actorKind==="agent").at(-1))==null?void 0:t.actor},nd=(e,t,n)=>e.filter(o=>o.mapId===t&&o.ticketId===n).sort((o,a)=>o.at-a.at);function Pj(e,t){return e.tickets.flatMap(n=>{var k;if(n.type!=="review"||!n.reviewOf)return[];const o=nd(t,e.map.id,n.id),a=pg(o);if(!a)return[];const l=((k=o.filter(w=>w.event==="claim").at(-1))==null?void 0:k.at)??0,d=nd(t,e.map.id,n.reviewOf),h=d.findIndex(w=>w.at>=l&&w.event.startsWith("review."));if(h<0||d[h].event!=="review.fail")return[];const f=d.slice(h+1),p=f.findIndex(w=>w.event.startsWith("review.")),v=p<0?f:f.slice(0,p);return[{reviewer:a,upheld:!v.some(w=>w.event==="accept"&&w.actorKind==="trail lead")}]})}function _j(e,t){var o;const n=(o=e.tickets.find(a=>a.id===t))==null?void 0:o.assignee;return n&&/^[a-z]+-\d+$/.test(n)?n:void 0}function gg(e,t){const n=a=>t.reduce((l,{ticket:d})=>l+a(d),0),o=a=>t.filter(l=>l.ticket.outcome===a).length;return{key:e,tickets:t.length,done:o("done"),cancelled:o("cancelled"),open:o("open"),medianLeadMs:Oj(t.flatMap(({ticket:a})=>a.leadMs===void 0?[]:[a.leadMs])),reworkCycles:n(a=>a.reworks),reviews:{passed:n(a=>a.reviews.passed),failed:n(a=>a.reviews.failed),needsHuman:n(a=>a.reviews.needsHuman)},answers:0,findings:{raised:0,upheld:0}}}function Co(e,t){const n=new Map;for(const o of e){const a=t(o);a&&n.set(a,[...n.get(a)??[],o])}return new Map([...n].map(([o,a])=>[o,gg(o,a)]))}const sd=(e,t)=>{const n=e.get(t)??gg(t,[]);return e.set(t,n),n};function pm(e,t,n){const o=sd(e,t);o.findings.raised+=1,n&&(o.findings.upheld+=1)}const To=e=>[...e.values()].sort((t,n)=>n.tickets-t.tickets||t.key.localeCompare(n.key));function vg(e){const t=e.flatMap(({snap:p,journal:v,answered:k,usage:w})=>fg({snap:p,journal:v,answered:k,usage:w}).tickets.map(j=>({ticket:j,agent:pg(nd(v,p.map.id,j.id))??_j(p,j.id)}))),n=p=>p.agent?Tc(p.agent):void 0,o=Co(t,p=>p.agent),a=Co(t,n),l=Co(t,p=>p.ticket.type),d=new Set;for(const{snap:p,journal:v,answered:k}of e){for(const w of k){const j=`${w.mapId}/${w.id}`;w.mapId!==p.map.id||d.has(j)||(d.add(j),sd(o,w.agent).answers+=1,sd(a,Tc(w.agent)).answers+=1)}for(const w of Pj(p,v))pm(o,w.reviewer,w.upheld),pm(a,Tc(w.reviewer),w.upheld)}const h=Object.fromEntries([...l.keys()].map(p=>[p,To(Co(t.filter(v=>v.ticket.type===p),n))])),f={trails:e.length,tickets:t.length,byAgent:To(o),byVendor:To(a),byType:To(l),byTypeAndVendor:h};return{...f,recommendations:Lj(f)}}const Dj={title:"Discovery brief: map the existing system",type:"research",body:["Investigate before anything is built, then call `submit_brief`. Cite real paths; never guess.","","- **Summary**: what this trail changes, in a few lines.","- **Product context**: who it affects, the business rules and UX principles that apply, plan or pricing constraints. Ask the human with `ask_human` when the repo doesn't tell you.","- **Existing implementation**: the files, services and modules involved, each with its path and one line.","- **Conventions and abstractions** to follow.","- **Data model impact** and **API impact**.","- **Risks and possible regressions**.","- **Assumptions** you rely on, and **open questions**.","","Implementation tickets (task, execute, prototype) can be claimed once the human accepts the brief. Afterwards, revise the planned tickets with `add_ticket` and `update_trail` if the brief changed the picture."].join(`
|
|
113
|
+
`)},zj=[["summary","Summary"],["productContext","Product context"],["existing","Existing implementation"],["conventions","Conventions and abstractions"],["dataModel","Data model impact"],["api","API impact"],["risks","Risks and possible regressions"],["assumptions","Assumptions"],["openQuestions","Open questions"]],Yi=Object.fromEntries(zj);function Bj(e,t){const n=new Set(e.map(o=>o.source).filter(Boolean));return t.filter(o=>!n.has(o))}const Fj=["architecture","convention","gotcha","dead-end","glossary","fact"],kg=["business-rule","product-decision","persona","ux-principle","pricing"],Uj=[...Fj,...kg],Wj=e=>e.status==="confirmed"||e.status==="assumption";function Hj(e,t){return Wp(e,t.replace(/^\.\//,""),{segments:!0})}const Kj={"business-rule":3,convention:3,"product-decision":2,architecture:2,gotcha:2,"dead-end":2,"ux-principle":2},Vj=["business-rule","ux-principle","convention"],gm=600,Gj=e=>`flagged as possibly outdated by ${e}; the human is reviewing it`,qj=new Set("the and for with from into onto that this these those than then through use uses using via all any are was were will can should must not only also each when what where which who how per our your their its".split(" ")),vm=e=>new Set((e.toLowerCase().match(/[a-z0-9][a-z0-9_-]{2,}/g)??[]).filter(t=>!qj.has(t)));function yg(e,t,n=4e3,o=()=>[]){const a=t.ticket?vm(`${t.ticket.title} ${t.ticket.body}`):new Set,l=new Set((t.tags??[]).map(p=>p.toLowerCase())),d=e.filter(Wj).map(p=>{const v=[];let k=Kj[p.kind]??1;for(const N of p.scope){const S=t.paths.find(I=>Hj(N,I));if(S){k+=6,v.push(`path match ${N} (${S})`);break}}const w=p.tags.filter(N=>l.has(N.toLowerCase())||a.has(N.toLowerCase()));w.length&&(k+=3*w.length,v.push(`tag ${w.join(", ")}`));const j=[...vm(p.title)].filter(N=>a.has(N));return j.length&&(k+=j.length,v.push(`mentions ${j.slice(0,3).join(", ")}`)),t.trailKey&&p.sources.includes(`trail:${t.trailKey}`)&&(k+=3,v.push("same trail")),t.discovery&&kg.includes(p.kind)&&(k+=8,v.push("product context for discovery")),!v.length&&Vj.includes(p.kind)&&!p.scope.length&&v.push(`${p.kind.replace("-"," ")} for the whole project`),{e:p,score:k,why:v}}).filter(p=>p.why.length>0).sort((p,v)=>v.score-p.score||p.e.id.localeCompare(v.e.id,void 0,{numeric:!0})),h=[];let f=0;for(const{e:p,why:v}of d){const k=p.body.length>gm?`${p.body.slice(0,gm)}…`:p.body;if(f+k.length>n&&h.length)break;f+=k.length;const w=o(p);h.push({id:p.id,title:p.title,kind:p.kind,status:p.status,body:k,why:v,...w.length?{mayBeOutdated:w}:{},...p.flag?{flagged:Gj(p.flag.by)}:{}})}return h}const Qj=new RegExp("`([^`\\s]+/[^`\\s]+)`|(?:^|[\\s(])/?((?:[\\w.-]+/)+[\\w.-]+)","gm");function wg(e){const t=new Set;for(const n of e.matchAll(Qj))t.add((n[1]??n[2]).replace(/^\.?\//,"").replace(/[.,;:]+$/,""));return[...t]}const Yj=[{level:"high",label:"High risk"},{level:"medium",label:"Medium risk"},{level:"low",label:"Low risk"},{level:"none",label:"No category"}];function Jj(e){return Yj.map(t=>({...t,decisions:e.filter(n=>{var o;return(((o=n.risk)==null?void 0:o.level)??"none")===t.level})})).filter(t=>t.decisions.length)}const Xj=1/3;function ca(e,t=Date.now()){const n=e.expiresAt-t;return n<=0?"expired":n<=e.ttlMs*Xj?"stalled":"live"}function Zj(e){var t;return((t=e.returned)==null?void 0:t.reason)==="trail lead"?`${e.ticketKey} returned to queue · claim of ${e.agent} released by ${e.returned.by}`:`${e.ticketKey} returned to queue after ${e.agent} went silent`}const e0=e=>e.urgency==="fyi"||e.kind==="policy";function t0(e){const t=e.filter(([n,o])=>na.includes(n)&&Up(o));return Object.fromEntries(t)}const km=e=>Number(e.slice(0,2))*60+Number(e.slice(3,5));function n0(e,t){const n=new Date(t),o=n.getHours()*60+n.getMinutes(),a=km(e.from),l=km(e.to),d=l<=a;if(!(d?o>=a||o<l:o>=a&&o<l))return!1;if(!e.days)return!0;const f=d&&o<l,p=(n.getDay()+(f?6:0))%7;return e.days.includes(p)}function s0(e,t){const n=new Date(t);return n.setHours(Number(e.to.slice(0,2)),Number(e.to.slice(3,5)),0,0),n.getTime()<=t&&n.setDate(n.getDate()+1),n.getTime()}function i0(e,t){const n=e.focusUntil??0;if(n>t)return{kind:"manual",until:n};if(!e.focus||!n0(e.focus,t))return{kind:"off"};const o=s0(e.focus,t);return(e.focusOffUntil??0)>t?{kind:"paused",until:o}:{kind:"hours",until:o}}function r0(e,t,n){const o={...e};switch(delete o.focusUntil,delete o.focusOffUntil,t.kind){case"for":return{...o,focusUntil:n+t.minutes*6e4};case"resume":return o;case"end":{const a=i0(o,n);return a.kind==="hours"?{...o,focusOffUntil:a.until}:o}default:return t}}const o0=e=>({id:e.id,key:e.key,title:e.title,...e.archived?{archived:!0}:{}});function a0(e,t){var o;const n={...e};return t.verification===null?delete n.verification:t.verification&&(n.verification=t.verification),t.guides===null||((o=t.guides)==null?void 0:o.length)===0?delete n.guides:t.guides&&(n.guides=t.guides),t.modelMatching===null?delete n.modelMatching:t.modelMatching&&(n.modelMatching=t.modelMatching),t.confirm&&delete n.settingsUnconfirmed,n}function l0(e,t,n){const o=Date.now();return{id:e,key:t,...n,state:"open",blockedBy:[],comments:[],createdAt:o,updatedAt:o}}const c0=(e,t)=>({...e,blockedBy:e.blockedBy.filter(n=>n!==t)}),d0=(e,t)=>{var n;return{...e,...(n=t.title)!=null&&n.trim()?{title:t.title.trim()}:{},...t.body!==void 0?{body:t.body}:{}}};function u0(e){const{closeReason:t,closedAt:n,...o}=e;return{...o,state:"open"}}const h0=["status","verification","checks","reviewOf","guide"];function f0(e,t){const n={...e};for(const o of h0)t[o]!==void 0&&(t[o]===null?delete n[o]:n[o]=t[o]);return t.confirm&&delete n.settingsUnconfirmed,n}function m0(e,t){const n={...e};return t?n.archived=!0:delete n.archived,n}async function xg(e){const t=await e.list(),n=t.filter(a=>!a.includes("/decisions/")).map(a=>{var l;return Number(((l=a.match(/(\d+)\.md$/))==null?void 0:l[1])??0)}),o=await Promise.all(t.filter(a=>a.endsWith("/map.md")).map(async a=>Number(ye(la(await e.read(a)).front.key).replace(/\D/g,""))||0));return Math.max(0,...n,...o)+1}const jg="### [^\\n]* @ \\d{4}-\\d\\d-\\d\\dT",Sg=`## Comments\\s*$|${jg}`,Ng=`<!-- ${Z.labelPrefix}:comments -->`,p0=new RegExp(`^## Comments[ \\t]*\\n${Ng}[ \\t]*$`,"m"),g0=new RegExp(`^(?=${jg})### `,"m"),Id=2,bg=e=>ia(sa(e,Sg)),ym=e=>zo(Gs(e),Sg);function v0(e,t){const n=(t>=Id?p0:/^## Comments\s*$/m).exec(e);return n?[e.slice(0,n.index),e.slice(n.index+n[0].length)]:[e,""]}function wm(e){const{front:t,body:n}=la(e),o=Number(ye(t.format))||1,[a,l]=v0(n,o),d=l.split(o>=Id?g0:/^### /m).slice(1).map((v,k)=>{const w=v.indexOf(`
|
|
114
|
+
`),j=v.slice(0,w),N=j.lastIndexOf(" @ ");return{id:`c${k}`,author:j.slice(0,N<0?void 0:N).trim(),createdAt:N>=0&&Date.parse(j.slice(N+3))||0,body:ym(v.slice(w+1).trim())}}),h=ye(t.close_reason),f=Iw.find(v=>v===ye(t.status)),p=Bp(ye(t.verification));return{id:ye(t.id),key:`#${ye(t.id)}`,title:ye(t.title),type:ye(t.type)||"task",hitl:qt(t.labels).includes(Sd)||void 0,state:ye(t.state)==="closed"?"closed":"open",closeReason:h==="completed"||h==="not_planned"?h:void 0,assignee:ye(t.assignee)||void 0,...f?{status:f}:{},...p?{verification:p}:{},...t.checks!==void 0?{checks:qt(t.checks)}:{},...ye(t.review_of)?{reviewOf:ye(t.review_of)}:{},...ye(t.guide)?{guide:ye(t.guide)}:{},blockedBy:qt(t.blocked_by),body:ym(a.trim()),comments:d,createdAt:qs(t.created),updatedAt:qs(t.updated),closedAt:qs(t.closed)||void 0}}function $g(e){const t={id:e.id,format:String(Id),title:e.title,type:e.type,labels:[ta(e.type),...$w(e.type)&&e.hitl?[Sd]:[]],state:e.state,close_reason:e.closeReason??"",assignee:e.assignee??"",...e.status?{status:e.status}:{},...e.verification?{verification:e.verification}:{},...e.checks?{checks:e.checks}:{},...e.reviewOf?{review_of:e.reviewOf}:{},...e.guide?{guide:e.guide}:{},blocked_by:e.blockedBy,created:cn(e.createdAt),updated:cn(e.updatedAt),...e.closedAt?{closed:cn(e.closedAt)}:{}},n=e.comments.length?`
|
|
115
|
+
|
|
116
|
+
## Comments
|
|
117
|
+
${Ng}
|
|
118
|
+
|
|
119
|
+
${e.comments.map(k0).join(`
|
|
120
|
+
|
|
121
|
+
`)}`:"";return Td(t,bg(e.body)+n)}function k0(e){return`### ${hs(e.author)} @ ${cn(e.createdAt)}
|
|
122
|
+
|
|
123
|
+
${bg(e.body)}`}async function y0(e,t,n){for(let o=0;;o++){const a=await t();if(n(a.path),!e.create)return await e.write(a.path,a.text),a.value;if(await e.create(a.path,a.text))return a.value;if(o>=50)throw new Error(`could not allocate ${a.path}`)}}async function w0(e,t,n){const o=await xg(e),a=l0(String(o),`#${o}`,n);return{path:`${t}/tickets/${a.id}.md`,text:$g({...a,updatedAt:Date.now()}),value:a}}async function x0(e,t,n){const o=(await e.list()).filter(d=>d.includes("/decisions/")),a=Math.max(0,...o.map(d=>Ox(d.split("/").pop())))+1,l=Lx(`D-${a}`,t,n);return{path:`${t}/decisions/${l.id}.md`,text:hg(l),value:l}}const j0=/^([^/]+)\/decisions\/([^/]+)\.md$/,S0=(e,t)=>e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,40)||`map-${t}`,Cg=/^[A-Za-z0-9][A-Za-z0-9_-]*(?:\.[A-Za-z0-9_-]+)*$/;function us(e){if(typeof e!="string"||e.length>128||!Cg.test(e))throw new Error(`not a valid id: ${JSON.stringify(e)}`);return e}const N0=e=>{const t=e.match(/^[^/]+\/tickets\/([^/]+)\.md$/);return!!t&&Cg.test(t[1])};class b0{constructor(t,n){le(this,"seen",new Map);le(this,"pending",new Map);this.read=t,this.emit=n}knows(t){return this.seen.has(t)}remember(t,n,o){this.seen.set(t,{text:n,supersededBy:o})}queue(t){const n=t.split("/")[0],o=this.pending.get(n)??{paths:new Set,timer:setTimeout(()=>void this.flush(n),250)};o.paths.add(t),this.pending.set(n,o)}async flush(t){const n=this.pending.get(t);if(this.pending.delete(t),!n)return;const o=[...n.paths].filter(d=>j0.test(d)),a=[];for(const d of o){const h=await this.read(d).catch(()=>""),f=this.seen.get(d);if(!h||(f==null?void 0:f.text)===h)continue;const p=ed(h);this.seen.set(d,{text:h,supersededBy:p.supersededBy}),f?p.supersededBy&&p.supersededBy!==f.supersededBy&&a.push({kind:"decision.superseded",mapId:t,decisionId:p.id,supersededBy:p.supersededBy,external:!0,at:Date.now()}):a.push({kind:"decision.recorded",mapId:t,decisionId:p.id,ticketId:p.ticketId,external:!0,at:Date.now()})}o.length?!a.length&&o.length<n.paths.size&&a.push({kind:"external.changed",mapId:t,at:Date.now()}):a.push({kind:"external.changed",mapId:t,at:Date.now()});const l=d=>d.kind==="decision.recorded"?0:1;a.sort((d,h)=>l(d)-l(h));for(const d of a)this.emit(d)}}function $0(e){const t=ye(e["model-matching"]);if(t!=="on"&&t!=="off")return;const n=t0(qt(e["model-tiers"]).map(o=>o.split("=").map(a=>a.trim())));return Object.keys(n).length?{enabled:t==="on",tiers:n}:{enabled:t==="on"}}function C0(e){if(!e)return{};const t=Object.entries(e.tiers??{}).map(([n,o])=>`${n}=${o}`);return{"model-matching":e.enabled?"on":"off",...t.length?{"model-tiers":t}:{}}}function xm(e,t){const{front:n,body:o}=la(t),a=Bp(ye(n.verification)),l=$0(n);return{id:e,key:ye(n.key)||e,title:ye(n.title)||e,mode:ye(n.mode)==="plan-only"||qt(n.labels).includes(Nd)?"plan-only":gs,...a?{verification:a}:{},...qt(n.guides).length?{guides:qt(n.guides)}:{},...l?{modelMatching:l}:{},...ye(n.archived)==="true"?{archived:!0}:{},sections:fx(o),createdAt:qs(n.created),updatedAt:qs(n.updated)}}function T0(e){var t;return Td({key:e.key,title:e.title,mode:e.mode,...e.verification?{verification:e.verification}:{},...(t=e.guides)!=null&&t.length?{guides:e.guides}:{},...C0(e.modelMatching),...e.archived?{archived:"true"}:{},labels:[jd,...e.mode==="plan-only"?[Nd]:[]],created:cn(e.createdAt),updated:cn(e.updatedAt)},hx(e.sections))}function E0(e,t){t.code!=="ENOENT"&&console.warn(`Teamtrail: decision ${e} can't be read: ${t.message}`)}class A0{constructor(t,n=`./${Z.dataDir}`){le(this,"kind","markdown");le(this,"label","Local markdown");le(this,"events",new Qs);le(this,"selfWrites",new Map);le(this,"external",new b0(t=>this.fs.read(t),t=>this.events.emit(t)));le(this,"ticketPath",(t,n)=>`${us(t)}/tickets/${us(n)}.md`);le(this,"setMapArchived",(t,n)=>this.editMap(t,o=>m0(o,n),{kind:"map.updated",mapId:t,at:Date.now()}));var o;this.fs=t,this.location=n,(o=t.watch)==null||o.call(t,a=>{const l=this.selfWrites.get(a);l&&Date.now()-l<1500||this.external.queue(a)})}async put(t,n,o){this.selfWrites.set(t,Date.now()),await this.fs.write(t,n,o===void 0?void 0:{base:o})}putNew(t){return y0(this.fs,t,n=>this.selfWrites.set(n,Date.now()))}async readMap(t){return xm(t,await this.fs.read(`${us(t)}/map.md`))}async writeMap(t,n){await this.put(`${us(t.id)}/map.md`,T0(t),n)}async listMaps(){const n=(await this.fs.list()).filter(o=>/^[^/]+\/map\.md$/.test(o)).map(o=>o.split("/")[0]);return Promise.all(n.map(async o=>o0(await this.readMap(o))))}async loadMap(t){const n=await this.fs.list(),o=await this.readMap(t),a=n.filter(d=>d.startsWith(`${t}/tickets/`)&&N0(d)),l=await Promise.all(a.map(async d=>wm(await this.fs.read(d))));return{map:o,tickets:l.sort((d,h)=>d.createdAt-h.createdAt)}}async createMap(t){const n=await xg(this.fs),o=S0(t.title,n),a={id:o,key:`#${n}`,title:t.title,mode:t.mode??gs,...t.verification?{verification:t.verification}:{},sections:t.sections,createdAt:Date.now(),updatedAt:Date.now()};return await this.writeMap(a),this.events.emit({kind:"map.created",mapId:o,at:Date.now()}),a}async editMap(t,n,o){const a=await this.fs.read(`${us(t)}/map.md`);await this.writeMap({...n(xm(t,a)),updatedAt:Date.now()},a),this.events.emit(o)}setMapMode(t,n){return this.editMap(t,o=>({...o,mode:n}),{kind:"map.mode",mapId:t,mode:n,at:Date.now()})}setMapMeta(t,n){return this.editMap(t,o=>a0(o,n),{kind:"map.updated",mapId:t,at:Date.now()})}updateMapSections(t,n){const o=Object.keys(n)[0];return this.editMap(t,a=>({...a,sections:{...a.sections,...n}}),{kind:"map.updated",mapId:t,section:o,at:Date.now()})}async createTicket(t,n){const o=await this.putNew(()=>w0(this.fs,t,n));return this.events.emit({kind:"ticket.created",mapId:t,ticketId:o.id,at:Date.now()}),o}async addBlocking(t,n,o){await this.update(t,o,a=>a.blockedBy.includes(n)?a:{...a,blockedBy:[...a.blockedBy,n]}),this.events.emit({kind:"edge.added",mapId:t,blockerId:n,blockedId:o,at:Date.now()})}async update(t,n,o){const a=await this.fs.read(this.ticketPath(t,n)),l=wm(a),d=o(l);d!==l&&await this.put(this.ticketPath(t,l.id),$g({...d,updatedAt:Date.now()}),a)}async removeBlocking(t,n,o){await this.update(t,o,a=>c0(a,n)),this.events.emit({kind:"edge.removed",mapId:t,blockerId:n,blockedId:o,at:Date.now()})}async editTicket(t,n,o){await this.update(t,n,a=>d0(a,o)),this.events.emit({kind:"ticket.updated",mapId:t,ticketId:n,at:Date.now()})}async reopen(t,n){await this.update(t,n,u0),this.events.emit({kind:"ticket.updated",mapId:t,ticketId:n,at:Date.now()})}async assign(t,n,o){await this.update(t,n,a=>({...a,assignee:o??void 0})),this.events.emit(o?{kind:"ticket.claimed",mapId:t,ticketId:n,assignee:o,at:Date.now()}:{kind:"ticket.released",mapId:t,ticketId:n,at:Date.now()})}async comment(t,n,o,a){await this.update(t,n,l=>({...l,comments:[...l.comments,{id:`c${l.comments.length}`,author:o,body:a,createdAt:Date.now()}]})),this.events.emit({kind:"ticket.commented",mapId:t,ticketId:n,at:Date.now()})}async close(t,n,o){await this.update(t,n,a=>({...a,state:"closed",closeReason:o,closedAt:Date.now()})),this.events.emit({kind:"ticket.closed",mapId:t,ticketId:n,reason:o,at:Date.now()})}async setMeta(t,n,o){await this.update(t,n,a=>f0(a,o)),this.events.emit({kind:"ticket.updated",mapId:t,ticketId:n,at:Date.now()})}async listDecisions(t){const o=(await this.fs.list()).filter(a=>a.startsWith(`${t}/decisions/`)).map(async a=>{const l=await this.fs.read(a).catch(h=>E0(a,h));if(!l)return;const d={...ed(l),mapId:t};return this.external.knows(a)||this.external.remember(a,l,d.supersededBy),d});return(await Promise.all(o)).filter(a=>!!a)}async createDecision(t,n){const o=await this.putNew(async()=>{const a=await x0(this.fs,t,n);return this.external.remember(a.path,a.text),a});return this.events.emit({kind:"decision.recorded",mapId:t,decisionId:o.id,ticketId:o.ticketId,at:Date.now()}),o}async markSuperseded(t,n,o){const a=`${us(t)}/decisions/${us(n)}.md`,l=await this.fs.read(a),d=hg({...ed(l),mapId:t,supersededBy:o});this.external.remember(a,d,o),await this.put(a,d,l),this.events.emit({kind:"decision.superseded",mapId:t,decisionId:n,supersededBy:o,at:Date.now()})}subscribe(t){return this.events.on(t)}}function Nn(e,t=[]){if(e)try{const{protocol:n}=new URL(e);return["http:","https:",...t].includes(n)?e:void 0}catch{return}}class jm extends Error{constructor(t,n,o,a){super(n),this.code=t,this.status=o,this.resetAt=a,this.name="TrackerError"}}const I0={github:"GitHub Issues",linear:"Linear"};async function jt(e,t,n){let o;try{o=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:n===void 0?void 0:JSON.stringify(n)})}catch{throw new jm("offline","Lookout server unreachable; is `teamtrail` still running?")}const a=await o.json().catch(()=>({}));if(!o.ok)throw new jm(a.code??"http",a.error??`request failed (${o.status})`,o.status,a.resetAt);return a}class R0{constructor(t,n,o=""){le(this,"label");le(this,"location");le(this,"status",{state:"connecting",queued:0});le(this,"events",new Qs);le(this,"statusEvents",new Qs);le(this,"source");le(this,"listeners",0);le(this,"openEvents",t=>new EventSource(`${this.base}${t}`));le(this,"listMaps",()=>this.call("listMaps"));le(this,"loadMap",t=>this.call("loadMap",t));le(this,"createMap",t=>this.call("createMap",t));le(this,"setMapMode",(t,n)=>this.call("setMapMode",t,n));le(this,"setMapArchived",(t,n)=>this.call("setMapArchived",t,n));le(this,"setMapMeta",(t,n)=>this.call("setMapMeta",t,n));le(this,"updateMapSections",(t,n)=>this.call("updateMapSections",t,n));le(this,"createTicket",(t,n)=>this.call("createTicket",t,n));le(this,"addBlocking",(t,n,o)=>this.call("addBlocking",t,n,o));le(this,"removeBlocking",(t,n,o)=>this.call("removeBlocking",t,n,o));le(this,"editTicket",(t,n,o)=>this.call("editTicket",t,n,o));le(this,"reopen",(t,n)=>this.call("reopen",t,n));le(this,"assign",(t,n,o)=>this.call("assign",t,n,o));le(this,"comment",(t,n,o,a)=>this.call("comment",t,n,o,a));le(this,"close",(t,n,o)=>this.call("close",t,n,o));le(this,"setMeta",(t,n,o)=>this.call("setMeta",t,n,o));le(this,"listDecisions",t=>this.call("listDecisions",t));le(this,"createDecision",(t,n)=>this.call("createDecision",t,n));le(this,"markSuperseded",(t,n,o)=>this.call("markSuperseded",t,n,o));this.kind=t,this.base=n,this.label=I0[t],this.location=o}async call(t,...n){return(await jt(`${this.base}/tracker/${this.kind}/call`,"POST",{method:t,args:n})).result}open(){const t=this.openEvents(`/tracker/${this.kind}/events`);t.addEventListener("message",n=>this.events.emit(JSON.parse(n.data))),t.addEventListener("status",n=>{const o=JSON.parse(n.data);o.location&&(this.location=o.location),this.status=o,this.statusEvents.emit(o)}),t.addEventListener("error",()=>{this.status.state!=="offline"&&(this.status={...this.status,state:"offline",error:"Lookout server unreachable"},this.statusEvents.emit(this.status))}),this.source=t}subscribe(t){const n=this.events.on(t);return++this.listeners===1&&this.open(),()=>{var o;n(),--this.listeners===0&&((o=this.source)==null||o.close(),this.source=void 0)}}onStatus(t){return this.statusEvents.on(t)}}function M0(e){return{get:()=>jt(`${e}/trackers`,"GET"),test:t=>jt(`${e}/trackers/test`,"POST",t),connect:t=>jt(`${e}/trackers`,"PUT",t),forget:t=>jt(`${e}/trackers/credentials/${t}`,"DELETE"),githubRepos:()=>jt(`${e}/trackers/github/repos`,"GET"),githubSignIn:{start:()=>jt(`${e}/trackers/github/sign-in/start`,"POST"),poll:()=>jt(`${e}/trackers/github/sign-in/poll`,"POST"),cancel:()=>jt(`${e}/trackers/github/sign-in/cancel`,"POST"),signOut:()=>jt(`${e}/trackers/github/sign-in`,"DELETE")},linearTeams:t=>t?jt(`${e}/trackers/linear/teams`,"POST",{apiKey:t}):jt(`${e}/trackers/linear/teams`,"GET"),linearProjects:(t,n)=>n?jt(`${e}/trackers/linear/projects`,"POST",{apiKey:n,teamId:t}):jt(`${e}/trackers/linear/projects?team=${encodeURIComponent(t)}`,"GET")}}const L0=[{id:"markdown",name:"Local markdown",status:"available"},{id:"github",name:"GitHub Issues",status:"available"},{id:"linear",name:"Linear",status:"available"}],Tg=[{id:"claude-code",name:"Claude Code",status:"primary",trailName:"claude"},{id:"codex",name:"Codex",status:"primary",trailName:"codex"},{id:"cursor",name:"Cursor",status:"planned",trailName:"cursor"}],O0=Tg[0],P0="https://github.com/teamtrailhq/teamtrail-guides",_0="https://raw.githubusercontent.com/teamtrailhq/teamtrail-guides/main",D0=`${P0}/blob/main/CONTRIBUTING.md`,z0=e=>e.slice(0,9),B0=/[a-z][\w+.-]*:\/\/(?!(localhost|127\.0\.0\.1)(:\d+)?(\/|$|\s))/i,F0=/^[\w.-]+@[\w.-]+:/,U0=/^(@[\w.-]+\/)?[\w./-]+@[\w^~<>=*.-]+$/,W0=/(^|=)(npm|jsr|github|gitlab|bitbucket|git\+[a-z]+|https?):/i,H0=/^--?(node-options|script-shell|shell|exec|toolexec|vettool|overlay)(=|$)|^--(to-command|checkpoint-action|use-compress-program|info-script|new-volume-script|unzip-command|open-files-in-pager|upload-pack|receive-pack|exec|ext-diff|eval|eval-command)(=|$)/i,K0={tar:/^-[A-Za-z]*[IF]/,zip:/^-TT|^--unzip-command/,make:/^-E|^--eval/,perl:/^-[A-Za-z]*M/};function V0(e,t){var n;if(B0.test(t)||F0.test(t))return"names a remote address, so it reaches the network";if(U0.test(t)&&!t.startsWith("-"))return`names a package to download (${t})`;if(W0.test(t))return`names a package from a registry (${t})`;if(H0.test(t))return`runs a command it's given (${t.split("=")[0]})`;if((n=K0[e])!=null&&n.test(t))return`runs a command or code it's given (${t})`;if(/^(SHELL|\.SHELLFLAGS|MAKESHELL|MAKEFLAGS|MFLAGS|MAKE|GNUMAKEFLAGS)=/.test(t))return`sets what make runs (${t.split("=")[0]})`;if(G0.test(t))return"carries a shell command (a pipe to a shell, $(…), backticks, ; or &&)";if(e==="git"&&/^(--output(=|$)|-o)/.test(t))return"writes git output to a file it names"}const G0=/\|\s*(sh|bash|zsh|dash|ksh|fish|pwsh|node|python\d*|perl|ruby)\b|\$\(|`|;|&&|\|\||\b(curl|wget)\s/;function q0(e,t){var n;if(e==="cargo")for(let o=0;o<t.length;o++){const a=t[o]==="--config"?t[o+1]:(n=/^--config=(.*)$/s.exec(t[o]))==null?void 0:n[1];if(a!==void 0&&!/^[\w./-]+\.toml$/.test(a))return"sets cargo configuration inline (--config)"}}function Q0(e,t){const n=q0(e,t);if(n)return n;for(const o of t){const a=V0(e,o);if(a)return a}}const Y0=/^(-c|-e|-E|-ex|-x|-r|-command|-Command|-EncodedCommand)$|^--(eval|exec|command|expr|execute|run)(=|$)/,J0=/(^|[\s|'"=])[a-z0-9-]+(\.[a-z0-9-]+)*\.[a-z]{2,}(:\d+)?\/\S*/i;function X0(e,t){const n=e.find(o=>{var a;return Y0.test(o)&&!((a=t==null?void 0:t.exempt)!=null&&a.includes(o.split("=")[0]))});if(n)return`passes ${n.split("=")[0]}, which usually means "run this code"; point at a script in the repo`;if(!t&&e.some(o=>J0.test(o)))return"names an address, so it may reach the network"}const Z0=new Set(["push","fetch","pull","clone","remote","submodule","config","ls-remote","send-email","request-pull","daemon","http-fetch","http-push","credential","archive","bundle","svn","p4","lfs","filter-branch","bisect","difftool","mergetool","upload-pack","upload-archive","fetch-pack","send-pack","receive-pack","instaweb","rebase","http-backend","shell","web--browse","imap-send"]),eS=new Set(["-C","--git-dir","--work-tree","--namespace","--super-prefix"]);function tS(e){for(let t=0;t<e.length;t++){const n=e[t],o=n.split("=")[0];if(o==="-c"||o.startsWith("-c")||o==="--config-env"||o==="--exec-path")return`sets git's configuration or programs inline (${o})`;if(eS.has(o)){n.includes("=")||t++;continue}if(n.startsWith("-"))continue;const a=n.toLowerCase();return Z0.has(a)||a.startsWith("remote-")?`runs git ${a}, which reaches a remote, runs commands or changes git's configuration`:a==="grep"&&e.slice(t+1).some(l=>/^-[A-Za-z]*O|^--open-files-in-pager/.test(l))?"runs git grep with a pager command (-O)":void 0}}const nS=["--require","--import","--loader","--experimental-loader","--env-file","--input-type"],Sm={inline:"ep",value:"rC",long:["--eval","--print"],longValue:nS},sS={node:Sm,nodejs:Sm,bun:{inline:"e",value:"r",long:["--eval","--print"]},python:{inline:"c",value:"mWXQ",long:["--command"],stop:"-m"},pypy:{inline:"c",value:"mWXQ",long:[],stop:"-m"},ruby:{inline:"e",value:"rICEx",long:[]},perl:{inline:"eEMm",value:"IxCd",long:[]},php:{inline:"rBRFE",value:"dcfz",long:[]},lua:{inline:"e",value:"l",long:[]},luajit:{inline:"e",value:"lbj",long:[]},rscript:{inline:"e",value:"",long:["--expr"]},osascript:{inline:"e",value:"sl",long:[]}};function iS(e,t){const n=e.slice(1);for(let o=0;o<n.length;o++){if(t.inline.includes(n[o]))return"code";if(t.value.includes(n[o]))return o===n.length-1?"takes-next":"plain"}return"plain"}function rS(e,t){var a;if(/^data:|=data:/i.test(e))return"code";if(!e.startsWith("--"))return iS(e,t);const[n,o]=e.toLowerCase().split(/=(.*)/s,2);return t.long.includes(n)?"code":o===void 0&&((a=t.longValue)!=null&&a.includes(n))?"takes-next":"plain"}function oS(e,t){const n=sS[e];if(n)for(let o=0;o<t.length;o++){const a=t[o];if(a==="--"||!a.startsWith("-")||a===n.stop)return;const l=rS(a,n);if(l==="code")return"runs code given inline; point at a script in the repo instead";if(l==="takes-next"&&/^data:/i.test(t[o+1]??""))return"runs code given inline";l==="takes-next"&&o++}}const Nm=e=>new RegExp(`^(?![-/~\\\\])(?!.*\\.\\.)(?![a-zA-Z]:)[\\w./-]+\\.(${e})$`),_t={},ht=e=>e.split(/\s+/).filter(Boolean),aS={npm:{sub:ht("test t run run-script")},pnpm:{sub:ht("test t run")},yarn:{sub:ht("test run")},bun:{sub:ht("test run")},make:_t,cargo:{sub:ht("test check clippy build fmt")},go:{sub:ht("test vet build")},deno:{sub:ht("test lint check")},node:{script:Nm("[cm]?[jt]s"),sub:["--test"]},python:{script:Nm("py"),modules:ht("pytest unittest mypy ruff black flake8 pylint"),exempt:["-c"]},pytest:{exempt:["-c"]},ruff:{sub:ht("check format")},mypy:_t,pyright:_t,black:{needs:["--check"]},flake8:_t,pylint:_t,tsc:_t,eslint:{exempt:["-c"]},"pa11y-ci":_t,prettier:{needs:ht("--check -c --list-different -l")},biome:{sub:ht("check lint ci")},jest:{exempt:["-c"]},vitest:_t,mocha:_t,playwright:{sub:["test"]},rubocop:_t,rspec:{exempt:["-e"]},phpunit:_t,phpstan:_t,"golangci-lint":{sub:["run"]},swift:{sub:ht("test build")},dotnet:{sub:ht("test build")},mvn:{sub:ht("test verify compile")},gradle:{sub:ht("test check build")},gradlew:{sub:ht("test check build")},git:{sub:["diff"]}},lS=/^(\.\/)?node_modules\/\.bin\/([\w.-]+)$/;function cS(e,t){var o;const n=t[0]??"";return e.needs&&!t.some(a=>e.needs.includes(a))?!1:(o=e.script)!=null&&o.test(n)?!0:e.modules?n==="-m"&&e.modules.includes(t[1]??""):e.sub?e.sub.includes(n):!0}function Eg(e){var o;const t=(o=lS.exec(e.argv0))==null?void 0:o[2],n=aS[t??e.program];return n&&cS(n,e.args)?n:void 0}const dS=e=>!!Eg(e),da=e=>new Set(e.split(/\s+/).filter(Boolean)),uS=da(`
|
|
124
|
+
sh bash zsh fish dash ksh mksh pdksh csh tcsh ash yash nu nushell xonsh elvish osh oil rc es ion
|
|
125
|
+
cmd powershell pwsh
|
|
126
|
+
`),hS=da(`
|
|
127
|
+
curl wget nc ncat netcat socat telnet scp sftp ssh ssh-keyscan rsync ftp tftp aria2c websocat
|
|
128
|
+
openssl dig nslookup host ping ping6 traceroute whois nmap gh aws gcloud az kubectl
|
|
129
|
+
`),fS=da("npx pnpx bunx uvx uv pipx docker podman nix nix-shell nix-env flatpak snap"),mS=da(`
|
|
130
|
+
env xargs sudo doas su nohup nice ionice time timeout watch stdbuf chroot setsid caffeinate arch flock unbuffer
|
|
131
|
+
chronic firejail systemd-run strace ltrace gdb lldb exec eval command busybox toybox parallel script
|
|
132
|
+
awk gawk mawk nawk sed gsed vim nvim vi ex emacs expect
|
|
133
|
+
`),Eo=["exec","x","dlx","install","i","add","ci","create","init","update","upgrade"],pS={npm:new Set(Eo),pnpm:new Set(Eo),yarn:new Set(Eo),bun:new Set(Eo),pip:new Set(["install","download","wheel"]),gem:new Set(["install","exec"]),cargo:new Set(["install","binstall"]),go:new Set(["install","get"]),deno:new Set(["eval","install"]),bundle:new Set(["install","exec"]),composer:new Set(["install","require","global","exec"])};function gS(e){const t=(e.split(/[\\/]/).pop()??"").toLowerCase().replace(/\.(exe|cmd|bat|com)$/,"");return t.replace(new RegExp("(?<=[a-z])[\\d.-]+$"),"")||t}const vS=e=>{var t;return((t=e.find(n=>!n.startsWith("-")))==null?void 0:t.toLowerCase())??""};function bm(e){const t=e.findIndex(n=>n.startsWith("-m"));if(!(t<0))return e[t]==="-m"?e[t+1]:e[t].slice(2)}const kS=new Set(["pip","ensurepip","pipx","uv","venv","http.server","webbrowser"]);function yS(e,t){var o;if(uS.has(e))return`runs a shell (${e}); name the program and its arguments instead`;if(hS.has(e))return`runs ${e}, which reaches the network`;if(fS.has(e))return`runs ${e}, which downloads and runs a package; use one installed in the repo`;if(mS.has(e))return`runs ${e}, which runs another program or commands; name that program instead`;if(e.startsWith("git-"))return`runs a git program directly (${e})`;const n=vS(t);if((o=pS[e])!=null&&o.has(n))return`runs ${e} ${n}, which downloads packages; use one installed in the repo`;if(e==="python"&&kS.has(bm(t)??""))return`runs python -m ${bm(t)}, which downloads or serves`;if(e==="find"&&t.some(a=>/^-(exec|execdir|ok|okdir|delete)$/.test(a)))return"runs find with -exec or -delete, which runs or removes other things"}function Ag(e){const t=e.run[0]??"";return{argv0:t,program:gS(t),args:e.run.slice(1)}}function wS(e){const{argv0:t,program:n,args:o}=Ag(e),a=Eg({argv0:t,program:n,args:o}),l=[yS(n,o),oS(n,o),n==="git"?tS(o):void 0,Q0(n,o),X0(o,a)].filter(d=>!!d);return e.cwd&&(e.cwd.startsWith("/")||e.cwd.split(/[\\/]/).includes(".."))&&l.push("cwd must stay inside the repo"),l}const xS="unknown program: Teamtrail can't tell what this runs";function jS(e){if(wS(e).length)return;const{argv0:t,program:n,args:o}=Ag(e);return dS({argv0:t,program:n,args:o})?void 0:xS}function SS(e,t={}){const n=(t.query??"").toLowerCase().split(/\s+/).filter(Boolean);return e.guides.filter(o=>{if(t.verifiedOnly&&!o.verified&&!o.builtin)return!1;const a=[o.id,o.name??"",o.summary,o.author].join(" ").toLowerCase();return n.every(l=>a.includes(l))})}const NS="unknown model",bS=e=>`${Math.round(e.firstTimeRate*100)}%`,$m=(e,t)=>`${e.model} passes ${bS(e)} of your ${t} tickets first time (${e.tickets} tickets)`;function $S(e,t){return t.firstTimeRate-e.firstTimeRate||(e.costPerVerifiedUsd??1/0)-(t.costPerVerifiedUsd??1/0)||e.key.localeCompare(t.key)}function CS(e){return[...new Set(e.scorecard.byTypeAndModel.map(n=>n.type??""))].filter(Boolean).sort().flatMap(n=>{const o=e.scorecard.byTypeAndModel.filter(f=>f.type===n&&f.enough&&f.model!==NS).sort($S);if(o.length<2||o[0].firstTimeRate===o[1].firstTimeRate)return[];const a=o[0],l=Fw(a.model,e.models).tier,d=e.tiers[n];if(!d||l===d)return[];const h=`${$m(a,n)}; ${$m(o[1],n)}`;return[{type:n,current:d,tier:l,model:a.model??"",because:h}]})}const Cm=e=>`${Math.round(e*100)}%`,TS=e=>e===void 0?"–":`$${e.toFixed(2)}`,Ig=e=>e.replace(/[^\w .@/·-]/g,"").slice(0,60);function Tm(e,t){return[`| ${t} | Tickets | Verified first time | Rework | Attempts per verified | Cost per verified |`,"| --- | ---: | ---: | ---: | ---: | ---: |",...e.map(n=>[`| ${Ig(n.key)}${n.enough?"":" (too few)"}`,n.tickets,Cm(n.firstTimeRate),Cm(n.reworkRate),n.attemptsPerVerified??"–",`${TS(n.costPerVerifiedUsd)} |`].join(" | "))]}function ES(e,t="Agent scorecard"){return[`## ${Ig(t)}`,"",`${e.tickets} tickets with a completion, measured by Teamtrail on this repo. Groups under ${e.minSample} tickets are marked too few and aren't compared.`,"",...Tm(e.byTypeAndModel,"Ticket type · model"),"",...Tm(e.byVendor,"Vendor")].join(`
|
|
134
|
+
`)}const Ec="No area yet";function AS(e){return[`<path d="M24 210Q26 162 72 152H150Q190 158 192 210Z" fill="${e.shell}"/>`,`<path d="M24 210Q26 162 72 152H84Q58 166 58 210Z" fill="${e.shade}"/>`,`<path d="M66 154Q108 160 160 154L156 162Q108 168 70 162Z" fill="${e.side}"/>`,`<path d="M88 152L122 196L156 152Z" fill="${e.orange}"/>`,`<path d="M88 152L122 196L112 152Z" fill="${e.orangeDark}"/>`,`<circle cx="122" cy="161" r="8" fill="${e.orangeDark}"/><circle cx="124" cy="159" r="3" fill="${e.orange}"/>`].join("")}const Ac={x:112,w:15},Ic={x:136,w:10};function Em({x:e,w:t},n,o,a){const l=e+n;return[`<rect x="${l}" y="${94+o}" width="${t}" height="12" rx="${t>12?5:4}" fill="${a.glowLight}"/>`,`<rect x="${l}" y="${100+o}" width="${t}" height="6" rx="3" fill="${a.glow}"/>`,`<rect x="${l+t-6}" y="${96+o}" width="${t>12?3.5:2.5}" height="3.5" rx="1" fill="#fff"/>`].join("")}function Am({x:e,w:t},n){const o=t+3,a=t>12?6:5;return`<rect x="${e-2}" y="90" width="${o}" height="18" rx="${o/2.6}" fill="${n.glowLight}"/><rect x="${e-2+(o-a)/2}" y="96" width="${a}" height="6" rx="2" fill="${n.glass}"/>`}function IS(e,t){if(e==="closed")return[Ac,Ic].map(({x:a,w:l})=>`<rect x="${a}" y="100" width="${l}" height="4" rx="2" fill="${t.glow}"/>`).join("");if(e==="wide")return Am(Ac,t)+Am(Ic,t);const[n,o]=e==="aside"?[4,-5]:[0,0];return Em(Ac,n,o,t)+Em(Ic,n,o,t)}function RS(e,t){return e==="open"?`<rect x="124" y="114" width="16" height="9" rx="4.5" fill="${t.glowLight}"/><rect x="127" y="119" width="10" height="4" rx="2" fill="${t.glow}"/>`:e==="mid"?`<rect x="126" y="115" width="12" height="5" rx="2.5" fill="${t.glowLight}"/>`:e==="aside"?[0,1,2].map(n=>`<circle cx="${124+n*7}" cy="118" r="2.6" fill="${t.glow}"/>`).join(""):`<path d="M125 116q6 5 12 0" fill="none" stroke="${t.glow}" stroke-width="4" stroke-linecap="round"/>`}function MS({eyes:e,mouth:t},n){return IS(e,n)+RS(t,n)}function LS(e){return{shine:'<path d="M92 82h22l-14 20h-8z" fill="#fff" opacity=".08"/>',chin:[`<circle cx="100" cy="142" r="3" fill="${e.orange}"/>`,`<circle cx="109" cy="142" r="3" fill="${e.orangeDark}"/>`,[132,141,150].map(t=>`<rect x="${t}" y="139" width="5" height="7" rx="1.5" fill="${e.shellLight}"/>`).join("")].join(""),pine:`<path d="M125 42l8 11h-4l7 10h-22l7-10h-4z" fill="${e.hat}"/>`}}function OS(e,t,n,o){return[`<path d="M86 34L80 16" stroke="${o.band}" stroke-width="${n?6:4}" stroke-linecap="round"/>`,t?`<circle cx="79" cy="14" r="11" fill="${e}" opacity=".3"/>`:"",`<circle cx="79" cy="14" r="${n?8:6}" fill="${e}"/>`,t?'<circle cx="77" cy="12" r="2" fill="#fff3c4"/>':""].join("")}function PS({face:e,lamp:t,lit:n,simple:o,c:a}){const l=LS(a);return['<rect x="36" y="66" width="118" height="94" rx="22" fill="#000" opacity=".12"/>',`<path d="M50 96Q46 52 96 46" fill="none" stroke="${a.band}" stroke-width="8" stroke-linecap="round"/>`,`<path d="M44 78Q44 62 60 60L74 58V152L60 150Q44 148 44 132Z" fill="${a.side}"/>`,`<rect x="68" y="56" width="98" height="96" rx="20" fill="${a.shell}"/>`,`<rect x="72" y="60" width="8" height="84" rx="4" fill="${a.shellLight}"/>`,`<path d="M68 132H166V140Q166 152 152 152H82Q68 152 68 140Z" fill="${a.shade}"/>`,`<rect x="82" y="72" width="76" height="62" rx="16" fill="${a.frame}"/>`,`<rect x="86" y="76" width="70" height="55" rx="13" fill="${a.glass}"/>`,o?"":l.shine,e,o?"":l.chin,`<ellipse cx="50" cy="108" rx="13" ry="21" fill="${a.orangeDark}"/>`,`<ellipse cx="56" cy="108" rx="12" ry="20" fill="${a.orange}"/>`,`<ellipse cx="53" cy="104" rx="4" ry="11" fill="${a.orangeLight}"/>`,`<path d="M60 122Q64 146 88 148" fill="none" stroke="${a.band}" stroke-width="5" stroke-linecap="round"/>`,`<circle cx="90" cy="148" r="6" fill="${a.band}"/><circle cx="91.5" cy="146.5" r="2" fill="${a.orange}"/>`,OS(t,n,o,a),`<path d="M48 76Q46 30 104 28Q158 30 162 70Z" fill="${a.hat}"/>`,`<path d="M48 76Q46 34 88 29Q66 42 66 74Z" fill="${a.hatDark}"/>`,`<path d="M96 70Q96 40 126 36Q152 40 154 68Z" fill="${a.panel}"/>`,o?"":l.pine,`<path d="M150 82Q120 76 66 84L58 80Q56 72 64 70Q122 62 180 70Q190 76 182 84Z" fill="${a.brim}"/>`,'<path d="M70 84Q120 78 166 84L166 90Q120 84 70 90Z" fill="#000" opacity=".22"/>'].join("")}const _S={ground:"#4f8a48",groundLight:"#5d9a55",shell:"#eee7d3",shellLight:"#faf6ea",shade:"#c9bfa2",side:"#b3a98c",frame:"#a99f83",glass:"#13231e",glow:"#6fd197",glowLight:"#c2f2cf",orange:"#e07a2f",orangeLight:"#f29a55",orangeDark:"#a8481c",hat:"#8a5a38",hatDark:"#6b4630",brim:"#5a3a26",panel:"#ece2c6",band:"#3a4a43"},Rg={on:"#ffb347",dim:"#a8501c",alert:"#ff5a48"},DS={on:"#ffd166",dim:"#a8501c",alert:"#ff5a48"},zS={circle:100,rounded:46,square:0},BS=.94;let FS=0;function US(e,{lamp:t=Rg,simple:n=!1,shape:o="circle",colors:a=_S}={}){const l=a,d=e.light??"on",h=o==="circle"?BS:1,f=100*(1-h),p=`scout-clip-${++FS}`,v=PS({face:MS(e,l),lamp:t[d],lit:d!=="dim",simple:n,c:l});return[`<defs><clipPath id="${p}"><rect width="200" height="200" rx="${zS[o]}"/></clipPath></defs>`,`<g clip-path="url(#${p})">`,`<rect width="200" height="200" fill="${l.ground}"/>`,`<circle cx="120" cy="88" r="74" fill="${l.groundLight}"/>`,`<g transform="translate(${f} ${f}) scale(${h})">${AS(l)}${v}</g>`,"</g>"].join("")}const Mg={crt:{id:"crt",name:"Day",blurb:"Scout looking to the side: a cap, a headset with a mic, an antenna lamp and a neckerchief.",lamp:Rg,wave:{bar:"#6f8a78",lead:"#c8581e"}},night:{id:"night",name:"Night",blurb:"The same Scout, with the antenna lamp burning brighter, for the night theme.",lamp:DS,wave:{bar:"#66828d",lead:"#e8833a"}}},WS="crt",HS={idle:{eyes:"open",mouth:"rest",light:"on"},speaking:{eyes:"open",mouth:"rest",light:"on"},thinking:{eyes:"aside",mouth:"aside",light:"dim"},alert:{eyes:"wide",mouth:"rest",light:"alert"}},KS={idle:"WATCHING",speaking:"TALKING",alert:"NEEDS YOU",thinking:"THINKING"},xn={msPerChar:55,mouthHoldMs:110,blinkEveryMs:5600,blinkMs:140,thinkingStepMs:520};function VS(e){return e?/[aeiouy]/i.test(e)?"open":/[a-z0-9]/i.test(e)?"mid":"rest":"rest"}function GS(e,t){return!e||!/[a-z0-9]/i.test(e)?0:/[aeiou]/i.test(e)?2+(e.charCodeAt(0)+t)%2:1+(e.charCodeAt(0)*7+t)%2}function qS(e,t,n){return Array.from({length:n},(o,a)=>{const l=t-(n-1-a);return l>=0&&l<e.length?GS(e[l],l):0})}function Lg({face:e={eyes:"open",mouth:"rest"},variant:t="crt",size:n,simple:o,shape:a="circle",className:l}){const{eyes:d,mouth:h,light:f}=e,p=y.useMemo(()=>US({eyes:d,mouth:h,light:f},{lamp:Mg[t].lamp,simple:o??n<40,shape:a}),[d,h,f,t,o,n,a]);return i.jsx("svg",{className:l,width:n,height:n,viewBox:"0 0 200 200","aria-hidden":"true",dangerouslySetInnerHTML:{__html:p}})}function QS(e){const[t,n]=y.useState(!1);return y.useEffect(()=>{if(!e){n(!1);return}let o;const a=setInterval(()=>{n(!0),o=setTimeout(()=>n(!1),xn.blinkMs)},xn.blinkEveryMs);return()=>{clearInterval(a),o&&clearTimeout(o)}},[e]),t}const YS={xs:.8,sm:2,md:4,lg:6},JS=40,Im=20,Rm="(prefers-reduced-motion: reduce)",XS=40,ZS=350;function e1(e,t){var h;const n=e.size??"md",o=e.state??"idle",a=((h=e.speaking)==null?void 0:h.trim())??"",l=a&&(o==="idle"||o==="speaking")?"speaking":o,d=n==="xs";return{size:n,text:a,effective:l,talking:l==="speaking"&&a.length>0,mini:d,framed:e.framed??!d,reduced:t||d}}const t1=e=>e.length*xn.msPerChar,n1=(e,t)=>t&&(e.effective==="idle"||e.effective==="speaking"||e.effective==="alert");function s1(e,t,n,o){const a=HS[e.effective],l=n?"closed":a.eyes;let d=a.mouth,h=e.text.length-1;if(o)if(e.reduced)d="open";else{h=Math.min(e.text.length-1,Math.floor(t/xn.msPerChar));const p=Math.floor(t/xn.mouthHoldMs)*Math.round(xn.mouthHoldMs/xn.msPerChar);d=VS(e.text[Math.min(e.text.length-1,p)])}let f=a.light;return e.effective==="thinking"&&!e.reduced&&Math.floor(t/xn.thinkingStepMs)%2===1&&(f="on"),{eyes:l,mouth:d,light:f,cursor:h}}function i1(e,t){const n=typeof e.size=="number"?e.size:YS[e.size],o=e.reduced?Math.min(e.text.length-1,Im-1):t;return{base:n,px:JS*n,bars:Im,waveCursor:o}}function r1(e,{label:t,speechDone:n,cursor:o,caption:a}){const l=e.talking&&n?"idle":e.effective,d=KS[l],h=e.size==="md"||e.size==="lg"||typeof e.size=="number"&&e.size>=4;return{shownState:l,status:d,ariaLabel:`${t}, ${d.toLowerCase()}`,showCaption:a??h,shown:o1(e,n,o)}}function o1(e,t,n){return e.talking?e.reduced||t?e.text:e.text.slice(0,n+1):""}function a1(){const[e,t]=y.useState(()=>{var n;return typeof window<"u"&&!!((n=window.matchMedia)!=null&&n.call(window,Rm).matches)});return y.useEffect(()=>{var a;const n=(a=window.matchMedia)==null?void 0:a.call(window,Rm);if(!n)return;const o=()=>t(n.matches);return o(),n.addEventListener("change",o),()=>n.removeEventListener("change",o)},[]),e}function l1(e,t,n){const[o,a]=y.useState(0);return y.useEffect(()=>{if(a(0),!t)return;const l=performance.now(),d=setInterval(()=>a(performance.now()-l),n);return()=>clearInterval(d)},[e,t,n]),o}function c1(e){const{key:t,talking:n,at:o}=e,a=o!==void 0,l=t1(e.text),[d,h]=y.useState(""),f=y.useRef(e.onSpeakEnd);f.current=e.onSpeakEnd,y.useEffect(()=>{if(!n||a)return;const j=setTimeout(()=>{var N;h(t),(N=f.current)==null||N.call(f)},l+ZS);return()=>clearTimeout(j)},[n,t,l,a]);const p=n&&d!==t,v=l1(t,e.animate&&(p||e.thinking),p?XS:xn.thinkingStepMs),k=o??v,w=n&&(a?k>=l:d===t);return{t:k,speechDone:w}}const d1=e=>e*2,id=3.5;function u1(e,t,n){return(e??[]).map((o,a)=>{const l=(1+2*o)*.5;return{x:a*2,y:(id-l)/2,width:1,height:l,fill:a>=t-2&&o>0?n.lead:n.bar}})}function h1({heights:e,bars:t,unit:n,colors:o}){const a=d1(t);return i.jsx("svg",{className:`scout-wave${e?" on":""}`,width:a*n,height:id*n,viewBox:`0 0 ${a} ${id}`,"aria-hidden":"true",children:u1(e,t,o).map((l,d)=>i.jsx("rect",{...l},d))})}function ua({state:e="idle",size:t="md",speaking:n,variant:o=WS,framed:a,caption:l,label:d="Scout",onSpeakEnd:h,at:f,className:p,style:v}){const k=e1({state:e,size:t,speaking:n,framed:a},a1()),{text:w,effective:j,talking:N,reduced:S}=k,I=Mg[o],_=!S&&!(f!==void 0),O=`${j}|${o}|${w}`,{t:D,speechDone:q}=c1({key:O,text:w,talking:N,thinking:j==="thinking",animate:_,at:f,onSpeakEnd:h}),H=QS(n1(k,_)),G=N&&!q,{eyes:oe,mouth:Q,light:ke,cursor:Oe}=s1(k,D,H,G),{base:Te,px:ne,bars:ce,waveCursor:F}=i1(k,Oe),J=y.useMemo(()=>G?qS(w,F,ce):null,[G,w,F,ce]),{shownState:ie,status:W,ariaLabel:X,showCaption:z,shown:T}=r1(k,{label:d,speechDone:q,cursor:Oe,caption:l}),P={...v,"--scout-u":`${Te}px`},de=i.jsx("span",{className:"scout-sprite",children:i.jsx(Lg,{face:{eyes:oe,mouth:Q,light:ke},variant:o,size:ne,simple:k.mini})});return k.framed?i.jsxs("figure",{className:`scout scout-panel scout-${ie} scout-v-${o} ${p??""}`,style:P,"data-state":ie,children:[i.jsxs("figcaption",{className:"scout-head",children:[i.jsx("span",{className:"scout-name",children:d}),i.jsx("span",{className:"scout-sep",children:"//"}),i.jsx("span",{className:"scout-status",children:W})]}),i.jsxs("div",{className:"scout-feed",role:"img","aria-label":X,children:[de,i.jsx(h1,{heights:J,bars:ce,unit:Te,colors:I.wave})]}),z&&i.jsxs("p",{className:"scout-caption","aria-hidden":"true",children:[T,N&&!q&&!S&&i.jsx("span",{className:"scout-caret",children:"_"})]}),w&&i.jsx("span",{className:"scout-sr","aria-live":"polite",children:w})]}):i.jsx("span",{className:`scout scout-bare scout-${ie} ${p??""}`,style:P,role:"img","aria-label":X,children:de})}const St="trail lead";function f1({rt:e,guard:t,setMapId:n,mapIdRef:o,snapRef:a,setChatSession:l,setSelection:d}){const h={actorKind:"trail lead",journal:e.journal};return{selectMap:f=>n(f),openChat:f=>l(f),answer:(f,p)=>e.activity.answer(f,p,St,{via:"lookout"}),claim:f=>t("Claim",()=>cm(e.adapter,o.current,f,{...h,assignee:St})),release:f=>t("Release claim",()=>$x(e.adapter,o.current,f,{...h,actor:St})),releaseLease:f=>t("Release to queue",()=>e.leases.release(o.current,f,St)),resolve:(f,p,v={})=>t("Resolve · record answer",async()=>{var w;const k=(w=a.current)==null?void 0:w.tickets.find(j=>j.id===f);k&&!k.assignee&&await cm(e.adapter,o.current,f,{...h,assignee:St}),await _x(e.adapter,o.current,f,{...h,answer:p,author:St,decision:{...v,source:{kind:"lookout",label:"Ticket inspector"}}})}),supersede:(f,p)=>t(`Supersede ${f.id}`,async()=>{let v=f.id;if(f.derived){const{id:k,mapId:w,derived:j,supersededBy:N,...S}=f;v=(await Cd(e.adapter,f.mapId,S,{appendToTrail:!1})).id}await Ax(e.adapter,f.mapId,v,{...p,decidedBy:St,participants:[{id:St}],source:{kind:"lookout",label:"Logbook"}})}),graduate:({unspecified:f,...p})=>t(`Promote to ticket · ${f}`,async()=>{const v=await zx(e.adapter,o.current,f,p);d({kind:"ticket",id:v.id})}),ruleOut:(f,p)=>t("Rule out of scope",async()=>{await Bx(e.adapter,o.current,f,{...h,reason:p,author:St,source:{kind:"lookout",label:"Ticket inspector"}}),d(null)}),setArchived:f=>t(f?"Archive trail":"Restore trail",async()=>{await Hx(e.adapter,o.current,f),f&&n(void 0)}),setMode:f=>t(`Trail mode · ${f}`,()=>Ix(e.adapter,o.current,f)),setModelMatching:f=>t(`Model matching · ${f.enabled?"on":"off"}`,()=>Fx(e.adapter,o.current,f))}}const Ge=(...e)=>e.filter(Boolean).join(" "),Ys="item",m1=/^[0-9a-f]{6,64}$/;function ur(){const e=new URLSearchParams(location.search).get("project")??void 0;return e&&m1.test(e)?e:void 0}function pe(e=ur()){return e?`${Z.apiPrefix}/p/${e}`:Z.apiPrefix}function p1(e){const t=new URLSearchParams(location.search);for(const o of["projects","project","tracker",Ys])t.delete(o);e.item&&t.set(Ys,e.item),e.id&&e.id!==e.home&&t.set("project",e.id),e.id&&e.id!==e.home&&e.tracker&&t.set("tracker",e.tracker);const n=t.toString();return`${location.pathname}${n?`?${n}`:""}`}async function g1(){var n,o;const e=await fetch(`${pe()}/verification/config`).then(a=>a.ok?a.json():void 0).catch(()=>{}),t=((n=e==null?void 0:e.approval)==null?void 0:n.state)==="approved"?(o=e.config)==null?void 0:o.default:void 0;return t&&t!=="off"?t:void 0}async function v1(e,t){var d;const n=(t.assumptions??[]).map((h,f)=>({id:`S-${f+1}`,text:h,status:"holding",tickets:[]})),o=await g1(),{map:a,tickets:l}=await px(e,{title:t.title,...o?{verification:o}:{},sections:{destination:t.destination,notes:t.notes,decisions:[],unspecified:[],outOfScope:[],...n.length?{assumptions:n}:{}},tickets:[{ref:"discovery",...Dj}]});return await fetch(`${pe()}/briefs/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:a.id,ticketId:(d=l[0])==null?void 0:d.id})}),a}function Og(e,t){const n=URL.createObjectURL(new Blob([t],{type:"text/markdown;charset=utf-8"}));Object.assign(document.createElement("a"),{href:n,download:e}).click(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}function hn(e){const t=Math.max(0,Math.floor(e/1e3));return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:`${Math.floor(t/3600)}h`}function Pg(e){const t=Math.max(0,Math.floor(e/1e3)),n=o=>String(o).padStart(2,"0");return`${n(Math.floor(t/3600))}:${n(Math.floor(t%3600/60))}:${n(t%60)}`}const ha=e=>new Date(e).toTimeString().slice(0,8);function Jt(e){if(e<1e3)return`${Math.round(e)}ms`;const t=Math.round(e/1e3);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m ${String(t%60).padStart(2,"0")}s`:`${Math.floor(t/3600)}h ${String(Math.floor(t%3600/60)).padStart(2,"0")}m`}function fa(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}const Js=e=>`$${e<10?e.toFixed(2):e.toFixed(1)}`,Xs=e=>new Date(e).toISOString().slice(0,10),Rd=e=>new Date(e).toTimeString().slice(0,5),k1=e=>`${Xs(e)} ${Rd(e)}`,_g=e=>{if(!e)return"";const t=Math.max(0,Math.round((Date.now()-e)/1e3));return t<60?`${t}s ago`:`${Math.round(t/60)}m ago`},hr=e=>e?new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",Zs={research:"Research",prototype:"Prototype",junction:"Junction",task:"Task",execute:"Execute",review:"Review"},Dg={decided:"Done",claimed:"Working",frontier:"Ready",blocked:"Backlog",parked:"Parked (plan-only)","out-of-scope":"Cancelled",verifying:"Verifying",rework:"Rework",held:"Blocked"},y1={decided:"done",claimed:"working",frontier:"ready",blocked:"backlog",parked:"parked","out-of-scope":"cancelled",verifying:"verifying",rework:"rework",held:"blocked"};function Md(e,t){return new Map((e??[]).filter(n=>n.mapId===t&&!n.returned).map(n=>[n.ticketId,n]))}function ni(){let e=0,t=0;return{start(){const n=++e;return()=>n<=t?!1:(t=n,!0)},pushed(){t=++e}}}const w1=8,x1=40;function j1(e,t){try{return new URL(e,t).origin===t}catch{return!1}}function zg(e,t){if(!Array.isArray(e))return[];const n=[];for(const o of e.slice(0,w1)){const{label:a,href:l}=o??{};if(typeof a!="string"||typeof l!="string")continue;const d=a.trim();!d||d.length>x1||!j1(l,t)||n.push({label:d,href:l})}return n}function ma(e){e==="auto"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e}const S1=["auto","day","night"];function N1(e){const[t]=zg(e?[e]:[],location.origin);return t?{agents:t}:{}}const pa=e=>typeof e=="string"&&/^\/[\w/-]{1,100}$/.test(e)?e:void 0;function b1(e){const t=pa(e);return t?{themeSave:t}:{}}function $1(e){const t=pa(e);return t?{trailAgents:t}:{}}function C1(e){const t=pa(e);return t?{setup:t}:{}}function T1(e){const t=pa(e);return t?{merge:t}:{}}function E1(e){const t=e;if(typeof(t==null?void 0:t.label)!="string"||!t.label.trim()||t.label.length>60||typeof t.href!="string")return{};const n=Nn(t.href);return n?{home:{label:t.label.trim(),href:n}}:{}}let rd;const ft=()=>rd;function A1(e){const t=e.managed;if(!t||typeof t.name!="string")return;const n=typeof t.signOut=="string"&&new URL(t.signOut,location.href).origin===location.origin,o=zg(t.pages,location.origin),a=S1.find(l=>l===t.theme);return rd={name:t.name,pages:o,...n?{signOut:t.signOut}:{},...a?{theme:a}:{},...b1(t.themeSave),...T1(t.merge),...C1(t.setup),...$1(t.trailAgents),...t.highRisk===!1?{highRisk:!1}:{},...E1(t.home),...t.tracker==="markdown"?{tracker:"markdown"}:{},...N1(t.agents)},a&&ma(a),rd}const I1=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),rn=(e,t)=>e>>>t|e<<32-t;function R1(e){const t=Math.ceil((e.length+9)/64)*64,n=new Uint8Array(t);n.set(e),n[e.length]=128;const o=new DataView(n.buffer);return o.setUint32(t-8,Math.floor(e.length*8/2**32)),o.setUint32(t-4,e.length*8>>>0),n}function M1(e,t,n,o){for(let w=0;w<16;w++)o[w]=t.getUint32(n+w*4);for(let w=16;w<64;w++){const j=rn(o[w-15],7)^rn(o[w-15],18)^o[w-15]>>>3,N=rn(o[w-2],17)^rn(o[w-2],19)^o[w-2]>>>10;o[w]=o[w-16]+j+o[w-7]+N>>>0}let[a,l,d,h,f,p,v,k]=e;for(let w=0;w<64;w++){const j=k+(rn(f,6)^rn(f,11)^rn(f,25))+(f&p^~f&v)+I1[w]+o[w]>>>0,N=(rn(a,2)^rn(a,13)^rn(a,22))+(a&l^a&d^l&d)>>>0;[k,v,p,f,h,d,l,a]=[v,p,f,h+j>>>0,d,l,a,j+N>>>0]}[a,l,d,h,f,p,v,k].forEach((w,j)=>e[j]=e[j]+w>>>0)}function Rc(e){const t=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),n=R1(e),o=new DataView(n.buffer),a=new Uint32Array(64);for(let h=0;h<n.length;h+=64)M1(t,o,h,a);const l=new Uint8Array(32),d=new DataView(l.buffer);return t.forEach((h,f)=>d.setUint32(f*4,h)),l}function L1(e,t){const n=new Uint8Array(64);n.set(e.length>64?Rc(e):e);const o=new Uint8Array(64+t.length),a=new Uint8Array(96);for(let l=0;l<64;l++)o[l]=n[l]^54,a[l]=n[l]^92;return o.set(t,64),a.set(Rc(o),64),Rc(a)}const Bg=e=>Array.from(e,t=>t.toString(16).padStart(2,"0")).join(""),O1=e=>new Uint8Array((e.match(/../g)??[]).map(t=>parseInt(t,16))),Ld=`${Z.slug}.session`;let Uo;const P1=e=>{const t=e;return!!t&&typeof t.id=="string"&&typeof t.secret=="string"&&typeof t.verifier=="string"};function Od(){try{const e=JSON.parse(localStorage.getItem(Ld)??"null");return P1(e)?e:Uo}catch{return Uo}}function _1(e){Uo=e;try{localStorage.setItem(Ld,JSON.stringify(e))}catch{}}function Fg(){Uo=void 0;try{localStorage.removeItem(Ld)}catch{}}let Pd="unproven",Mc;const od=new Set,Ug=e=>{Pd=e;for(const t of od)t(e)};function D1(e){return od.add(e),()=>void od.delete(e)}const z1=()=>Pd==="proven",B1=()=>Pd==="proven"&&Ug("unproven");function F1(){const e=new Uint8Array(16);return crypto.getRandomValues(e),Bg(e)}async function U1(){const e=Od();if(!e)return"unknown";const t=F1(),n=await fetch(`${Z.apiPrefix}/session/prove`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e.id,nonce:t})}).catch(()=>{});if((n==null?void 0:n.status)===404)return Fg(),"unknown";const o=n!=null&&n.ok?(await n.json().catch(()=>({}))).proof:void 0,a=Bg(L1(O1(e.verifier),new TextEncoder().encode(`${t}
|
|
135
|
+
${location.origin}`)));return o===a?"proven":"failed"}function ga(){return Mc??(Mc=U1().then(e=>(Mc=void 0,Ug(e),e))),Mc}const W1=1e4;class Wg{constructor(t=pe(),n="/events"){le(this,"inner");le(this,"listeners",[]);le(this,"closed",!1);le(this,"retryMs",1e3);this.base=t,this.path=n,this.connect()}addEventListener(t,n){var o;this.listeners.push([t,n]),(o=this.inner)==null||o.addEventListener(t,n)}set onmessage(t){this.addEventListener("message",t)}set onerror(t){this.addEventListener("error",t)}close(){var t;this.closed=!0,(t=this.inner)==null||t.close()}async connect(){if(this.closed)return;if(ft())return this.open(`${this.base}${this.path}`);if(await ga()!=="proven")return this.failed();const t=await fetch(`${Z.apiPrefix}/sign-in/stream`,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"}).then(n=>n.ok?n.json():void 0).then(n=>n==null?void 0:n.ticket).catch(()=>{});if(!this.closed){if(!t)return this.failed();this.open(`${this.base}${this.path}?ticket=${encodeURIComponent(t)}`)}}open(t){const n=new EventSource(t);this.inner=n;for(const[o,a]of this.listeners)n.addEventListener(o,a);n.addEventListener("open",()=>this.retryMs=1e3),n.addEventListener("error",()=>{n.close(),B1(),this.retry()})}failed(){for(const[t,n]of this.listeners)t==="error"&&n(new Event("error"));this.retry()}retry(){this.closed||(setTimeout(()=>void this.connect(),this.retryMs),this.retryMs=Math.min(this.retryMs*2,W1))}}function H1(){if(ft())return void fetch(`${Z.apiPrefix}/session`,{cache:"no-store"}).then(e=>e.status===401&&location.reload());ga().then(e=>e==="unknown"&&location.reload())}let zt;const Wo=new Set,or=new Map,Ho=new Set,Ko=new Set;function Hg(e){zt==null||zt.addEventListener(e,t=>{for(const n of or.get(e)??[])n(t.data)})}function va(){if(!zt){zt=new Wg,zt.onerror=()=>{for(const e of Ko)e();H1()},zt.addEventListener("open",()=>{for(const e of Ho)e()}),zt.onmessage=e=>{const t=JSON.parse(e.data).path;if(typeof t=="string")for(const n of Wo)n(t)};for(const e of or.keys())Hg(e)}}function ka(){const e=[...or.values()].some(t=>t.size>0);Wo.size||e||Ho.size||Ko.size||(zt==null||zt.close(),zt=void 0)}function _d(e){return Wo.add(e),va(),()=>{Wo.delete(e),ka()}}function si(e,t){let n=or.get(e);return n||(n=new Set,or.set(e,n),Hg(e)),n.add(t),va(),()=>{n.delete(t),ka()}}function vs(e){return Ho.add(e),va(),()=>{Ho.delete(e),ka()}}function K1(e){return Ko.add(e),va(),()=>{Ko.delete(e),ka()}}const Dd=(e,t)=>`${e}/${t}`;let Yt={reached:!1,live:!1,tickets:{}},ad=!1;const ld=new Set,cd=new Set,V1=ni();let dd=0;const Kg=new Map;let Vg=0;function Vo(e){Yt=e;for(const t of ld)t()}function G1(e,t){const n=Object.fromEntries(e.map(o=>[Dd(o.mapId,o.ticketId),o]));for(const[o,a]of Kg)a>t&&Yt.tickets[o]&&(n[o]=Yt.tickets[o]);return n}function Mm(){const e=V1.start(),t=dd;fetch(`${pe()}/verification/sync`).then(n=>n.ok?n.json():Promise.reject()).then(n=>e()&&Vo({reached:!0,live:!0,status:Vg>t?Yt.status:n.status,tickets:G1(n.tickets,t)}),()=>Yt.reached&&Vo({...Yt,live:!1}))}function q1(e){const t=JSON.parse(e);if(t.kind==="evidence")for(const a of cd)a();if(t.kind!=="sync")return;const n=t;Vg=++dd;const o={...Yt.tickets};for(const a of n.tickets){const l=Dd(a.mapId,a.ticketId);o[l]=a,Kg.set(l,dd)}Vo({reached:!0,live:!0,status:n.status,tickets:o})}function Lm(){ad=!0,si("verification",q1),K1(()=>Yt.reached&&Yt.live&&Vo({...Yt,live:!1})),vs(Mm),Mm()}const ei={subscribe(e){return ad||Lm(),ld.add(e),()=>void ld.delete(e)},get:()=>Yt,onEvidence(e){return ad||Lm(),cd.add(e),()=>void cd.delete(e)},ticket:(e,t,n)=>e.tickets[Dd(t,n)]};function Q1(e){if(e!=null&&e.flags.length)return e.flags.some(t=>t.severity==="alert")?"alert":"warn"}const Om={onboarded:!1,tracker:"markdown",hitlTranscript:"summary",agent:O0.id,github:{repo:""},linear:{team:""},briefing:{enabled:!0,awayMinutes:15},theme:"night"};function zd(){try{const e={...Om,...JSON.parse(localStorage.getItem(ea)??"{}")};return["markdown","github","linear"].includes(e.tracker)||(e.tracker="markdown"),e}catch{return Om}}const Lc=new Map,Oc=e=>`${pe()}/file?path=${encodeURIComponent(e)}`;async function Pc(e,t){const n=await e.json().catch(()=>({})),o=new Error(n.error??`${t}: ${e.status}`);return e.status===409?Object.assign(o,{stale:!0}):e.status===404?Object.assign(o,{code:"ENOENT"}):o}const Y1={async list(){return(await(await fetch(`${pe()}/list`)).json()).files},async read(e){const t=await fetch(Oc(e));if(!t.ok)throw await Pc(t,`read ${e}`);const n=await t.text(),o=t.headers.get("ETag");return o&&Lc.set(e,{text:n,etag:o}),n},async write(e,t,n){const o=(n==null?void 0:n.base)===void 0?void 0:Lc.get(e),a=o&&o.text===(n==null?void 0:n.base)?{"If-Match":o.etag}:{},l=await fetch(Oc(e),{method:"PUT",body:t,headers:a});if(!l.ok)throw await Pc(l,`write ${e}`);Lc.delete(e)},async create(e,t){const n=await fetch(Oc(e),{method:"PUT",body:t,headers:{"If-None-Match":"*"}});if(n.status===412)return!1;if(!n.ok)throw await Pc(n,`create ${e}`);return!0},watch(e){return _d(e)}},J1=15*6e4;class X1{constructor(t){le(this,"leases",[]);le(this,"changes",new Qs);le(this,"logged",new Set);le(this,"since",Date.now()-J1);this.activity=t}subscribe(t){return this.changes.on(t)}set(t){var n;this.leases=t;for(const o of t){const a=`${o.mapId}/${o.ticketId}/${(n=o.returned)==null?void 0:n.at}`;!o.returned||o.returned.at<this.since||this.logged.has(a)||(this.logged.add(a),this.activity.push({source:"system",level:"warn",ticketId:o.ticketId,text:Zj(o)}))}this.changes.emit(t)}async release(t,n,o){const a=await fetch(`${pe()}/agents/leases/release`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,ticketId:n,by:o})});if(!a.ok)throw new Error((await a.json().catch(()=>({}))).error??`HTTP ${a.status}`)}}function Z1(e){e.remoteAnswer=(t,n,o)=>{fetch(`${pe()}/agents/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:t.sessionId,questionId:t.id,text:n,author:o})}).then(async a=>{if(!a.ok)throw new Error((await a.json().catch(()=>({}))).error??`HTTP ${a.status}`)}).catch(a=>e.push({source:"system",level:"alert",sessionId:t.sessionId,text:`Answer not delivered to ${t.agent} · ${a.message}`}))}}function eN(e){const t=ni(),n=()=>{const o=t.start();fetch(`${pe()}/agents/leases`).then(a=>a.ok?a.json():{leases:[]}).then(({leases:a})=>o()&&e.set(a)).catch(()=>{})};si("leases",o=>{t.pushed(),e.set(JSON.parse(o).leases)}),vs(n),n()}function tN(e){let t=0;const n=new Map,o=()=>{const a=t;fetch(`${pe()}/agents`).then(l=>l.ok?l.json():{sessions:[]}).then(({sessions:l})=>[...l].reverse().filter(d=>(n.get(d.session.id)??0)<=a).forEach(d=>e.syncRemote(d))).catch(()=>{})};si("agent",a=>{const l=JSON.parse(a);n.set(l.session.id,++t),e.syncRemote(l)}),vs(o),o()}function Pm(e,t){Z1(e),eN(t),tN(e)}function _m(e){const t=n=>`${ea}:${e}:${n}`;return{get:n=>localStorage.getItem(t(n)),set:(n,o)=>{try{localStorage.setItem(t(n),o)}catch{}}}}const nN=["markdown","github","linear"];function sN(){const e=new URLSearchParams(location.search).get("tracker");return e&&nN.includes(e)?e:zd().tracker}function iN(e){let t,n;const o=new Yx,a=new X1(o),l={},d=Kx(pe());if(e==="github"||e==="linear"){const p=new R0(e,pe());p.openEvents=v=>new Wg(pe(),v),t=p,n=fetch(`${pe()}/trackers`).then(v=>v.json()).catch(()=>{}).then(v=>{p.location=(e==="github"?v==null?void 0:v.github.repo:[v==null?void 0:v.linear.teamKey,v==null?void 0:v.linear.projectName].filter(Boolean).join(" · "))||p.location;const k=_m(`${e}:${p.location}`);l.presence=new hm(k),o.ledger=new fm(k),Pm(o,a)})}else t=new A0(Y1,`./${Z.dataDir}`),n=fetch(`${pe()}/list`).then(p=>p.json()).catch(()=>({root:"default"})).then(({root:p})=>{const v=_m(p);l.presence=new hm(v),o.ledger=new fm(v),Pm(o,a)});const h=ej(t),f=h.adapter;return{kind:e,ready:n,get presence(){return l.presence},adapter:f,journal:d,monitor:h,activity:o,leases:a}}const dn=e=>e.status==="running",Gg=e=>dn(e)&&!!e.waitingOn,rN={blocking:0,soon:1,fyi:2};function oN(e,t,n){const o=e.filter(d=>d.sessionId===t),a=o.find(d=>d.id===n);if(a)return a;const l=d=>rN[d.urgency??"soon"];return[...o].sort((d,h)=>l(d)-l(h)||d.at-h.at)[0]}function Go(e,t=Date.now()){const n=Math.floor(Math.max(0,t-e)/6e4);if(n<1)return"just now";if(n<60)return`${n} min ago`;const o=Math.floor(n/60);if(o<24)return`${o} h ago`;const a=Math.floor(o/24);return a<30?a===1?"yesterday":`${a} days ago`:`on ${new Date(e).toISOString().slice(0,10)}`}const aN=/^slack:([A-Z0-9]+)$/i;function ps(e,t){var l;const n=(l=aN.exec(e))==null?void 0:l[1];if(!n)return e;if(t!=null&&t.owners.some(d=>d.id===n))return"you (Slack)";const o=t==null?void 0:t.allow.find(d=>d.id===n),a=(o==null?void 0:o.realName)||(o==null?void 0:o.name);return a?`${a} (Slack)`:"Slack user"}function qg(e,t){const n=ps(e.decidedBy,t);return e.decidedByName?`${e.decidedByName} (${n})`:n}function fs({n:e,urgent:t,pop:n,hideZero:o}){return i.jsx("span",{className:Ge("badge",t&&"urgent",n&&t&&"pop",o&&!e&&"zero"),children:o&&!e?"":e})}function M({variant:e="default",size:t="md",on:n,className:o,type:a,...l}){return i.jsx("button",{type:a??"button",className:Ge("btn",e!=="default"&&e,t==="sm"&&"sm",n&&"on",o),...l})}function un({as:e="div",tone:t,on:n,className:o,children:a,...l}){return i.jsx(e,{className:Ge("card",t,n&&"on",o),...l,children:a})}function ya({what:e,onReviewAgain:t}){return i.jsxs("div",{className:"changed-notice edge-note edge-attention",children:[i.jsxs("p",{className:"t-meta",children:[e," changed since you opened it: read it again before you approve it."]}),i.jsx(M,{size:"sm",onClick:t,children:"Review again"})]})}function ot({on:e,title:t,sub:n,disabled:o,onClick:a}){return i.jsxs(un,{as:"button",type:"button",className:"choice",on:e,disabled:o,onClick:a,children:[i.jsx("b",{className:"choice-title t-row-title",children:t}),n&&i.jsx("span",{className:"c-sub",children:n})]})}function Ie({children:e}){return i.jsx("div",{className:"empty",children:e})}function Sn({title:e,hint:t,art:n}){return i.jsxs("div",{className:n?"empty-state has-art":"empty-state",children:[n,i.jsxs("div",{className:"es-words",children:[i.jsx("span",{className:"es-title",children:e}),t&&i.jsx("span",{className:"es-hint",children:t})]})]})}function Ze({label:e,children:t,className:n}){return i.jsxs("label",{className:Ge("field",n),children:[e,t]})}const wa=y.forwardRef(function({value:t,onValueChange:n,onSubmit:o,action:a="Send",actionDisabled:l,className:d,...h},f){return i.jsxs("form",{className:Ge("input-row",d),onSubmit:p=>{p.preventDefault(),o(t)},children:[i.jsx("textarea",{ref:f,rows:1,value:t,onChange:p=>n(p.target.value),onKeyDown:p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),o(t))},...h}),i.jsx(M,{type:"submit",variant:"primary",disabled:l??(h.disabled||!t.trim()),children:a})]})});function ii({text:e}){return i.jsx("span",{className:"info-tip","data-tip":e,"data-tip-scout":!0,tabIndex:0,role:"img","aria-label":e,children:i.jsxs("svg",{viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":"true",children:[i.jsx("circle",{cx:"7",cy:"3.7",r:"1.3"}),i.jsx("path",{d:"M5.6 6.300H8v4.200h1v1.200H5v-1.200h1.200V7.500h-.6z"})]})})}function ze({as:e="span",variant:t="chip",hot:n,size:o,className:a,children:l,title:d}){return i.jsx(e,{className:Ge(t==="chip"?"chip-label":"mono-label",n&&"hot",o==="sm"&&(t==="chip"?"sm":"xs"),a),title:d,children:l})}const lN=e=>typeof e=="string"?{text:e}:e,cN=e=>Ge(e.code&&"t-code",e.strong&&"strong",e.urgent&&"urgent",e.className);function V(e){const t=e.parts.filter(n=>!!n&&(typeof n=="string"||!!n.text)).map(lN);return!t.length&&!e.children?null:i.jsxs("span",{className:Ge("meta-line t-meta",e.className),children:[t.map((n,o)=>i.jsxs("span",{children:[o>0&&i.jsx("span",{className:"sep",children:" · "}),i.jsx("span",{className:cN(n)||void 0,title:n.tip,children:n.text})]},o)),e.children]})}function Bd(e){return i.jsxs("div",{className:"ds-load-failed",role:"alert",children:[i.jsx(V,{parts:[e.what,e.reason]}),i.jsx(M,{size:"sm",variant:"ghost",onClick:e.onRetry,children:"Retry"})]})}function ri(e){const t=Array.from({length:e.rows??0},(n,o)=>o);return i.jsxs("div",{className:Ge("ds-loading",e.className),role:"status","aria-live":"polite",children:[i.jsxs("span",{className:"ds-loading-line t-meta",children:[i.jsx("span",{className:"ds-spinner","aria-hidden":"true"}),e.label]}),t.length>0&&i.jsx("ul",{className:"ds-skeleton-list","aria-hidden":"true",children:t.map(n=>i.jsxs("li",{className:"ds-skeleton-row",children:[i.jsx("span",{className:"ds-skeleton-bar title"}),i.jsx("span",{className:"ds-skeleton-bar meta"})]},n))})]})}const dN="M25.53 10.5 A11 11 0 1 1 16 5",uN="M20 5 L14.6 1.6 L14.6 8.4 Z";function oi({variant:e="mark",state:t="ok",size:n=20,className:o="",title:a}){const l=n<=14?3:2.4;return i.jsxs("svg",{className:`scout-mark mm-${e} mm-${t} ${o}`,viewBox:"0 0 32 32",width:n,height:n,role:a?"img":void 0,"aria-label":a,"aria-hidden":a?void 0:!0,children:[e==="status"||e==="alert"?i.jsx("circle",{cx:"16",cy:"16",r:"11",fill:"none",stroke:"currentColor",strokeWidth:l,strokeDasharray:t==="syncing"?"5 3.6":void 0}):i.jsx("path",{d:dN,fill:"none",stroke:"currentColor",strokeWidth:l,strokeLinecap:"butt"}),(e==="mark"||e==="action")&&i.jsx("path",{d:uN,fill:"currentColor"}),e==="action"&&i.jsx("path",{d:"M13 11 L21.5 16 L13 21 Z",fill:"currentColor"}),(e==="mark"||e==="voice")&&i.jsx("circle",{cx:"16",cy:"16",r:e==="voice"?4:3.4,fill:"currentColor"}),e==="status"&&(t==="idle"?i.jsx("circle",{cx:"16",cy:"16",r:"3.4",fill:"none",stroke:"currentColor",strokeWidth:"1.6"}):i.jsx("circle",{cx:"16",cy:"16",r:"4.2",fill:"currentColor"})),e==="alert"&&i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"14.4",y:"8.5",width:"3.2",height:"9.5",fill:"currentColor"}),i.jsx("rect",{x:"14.4",y:"20.5",width:"3.2",height:"3.2",fill:"currentColor"})]})]})}function ud({parts:e,className:t,as:n="div"}){const o=e.filter(a=>a!=null&&a!==!1&&a!=="");return i.jsx(n,{className:Ge("meta",t),children:o.map((a,l)=>i.jsxs("span",{children:[l>0&&" · ",a]},l))})}const Dm=()=>{const e=document.documentElement.dataset.theme;return e?e==="night":matchMedia("(prefers-color-scheme: dark)").matches};function Qg(){const[e,t]=y.useState(Dm);return y.useEffect(()=>{const n=()=>t(Dm()),o=matchMedia("(prefers-color-scheme: dark)");o.addEventListener("change",n);const a=new MutationObserver(n);return a.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{o.removeEventListener("change",n),a.disconnect()}},[]),e}function hN(){const e=()=>window.innerWidth>=1440?"wide":window.innerWidth>=1024?"laptop":"mobile",[t,n]=y.useState(e);return y.useEffect(()=>{const o=()=>n(e());return window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)},[]),t}const fN=15e3,zm=["pointerdown","pointermove","keydown","wheel","touchstart"];function mN(e,t,n,o){const[a,l]=y.useState(null),[d,h]=y.useState(!1),[f,p]=y.useState(!1),v=y.useRef(),k=y.useRef(Date.now()),w=y.useRef(!1),j=n.awayMinutes*6e4,N=y.useRef(t);N.current=t;const S=y.useRef(o);S.current=o;const I=y.useCallback((H,G)=>{const oe=N.current;return jj({snaps:Object.values(oe.allSnaps),decisions:oe.decisions,activity:oe.activity,ledger:e.activity.ledger,since:Q=>{var ke;return H[Q]??G??((ke=oe.allSnaps[Q])==null?void 0:ke.map.createdAt)??Date.now()},currentMapId:oe.mapId,attention:S.current})},[e]),$=y.useCallback((H=Date.now())=>{var G;return(G=e.presence)==null?void 0:G.markSeen(N.current.maps.map(oe=>oe.id),H)},[e]),_=y.useCallback(()=>{const H=e.presence;if(!H)return;const G=H.lastSeenAny();if(G!==void 0&&Date.now()-G>=j){const oe=H.snapshot();I(oe,G).changed&&(v.current={seen:oe,any:G},h(!0),n.enabled?l(oe):p(!0))}$()},[e,j,n.enabled,I,$]);y.useEffect(()=>{!t.loaded||w.current||!e.presence||(w.current=!0,_())},[t.loaded,e,_]),y.useEffect(()=>{const H=()=>{const Q=Date.now()-k.current>=j;k.current=Date.now(),Q&&w.current&&document.visibilityState==="visible"&&_()},G=()=>{if(document.visibilityState!=="visible"){w.current&&$(Date.now()-k.current<j?Date.now():k.current);return}k.current=Date.now(),w.current&&_()};for(const Q of zm)window.addEventListener(Q,H,{passive:!0});document.addEventListener("visibilitychange",G);const oe=setInterval(()=>{w.current&&document.visibilityState==="visible"&&$(k.current)},fN);return()=>{for(const Q of zm)window.removeEventListener(Q,H);document.removeEventListener("visibilitychange",G),clearInterval(oe)}},[j,_,$]);const O=y.useMemo(()=>{var H;return a?I(a,(H=v.current)==null?void 0:H.any):void 0},[a,I,t.allSnaps,t.decisions,t.activity,o]),D=y.useMemo(()=>O?$j(O):"",[O]);y.useEffect(()=>{a&&p(!1)},[a]);let q="none";return f?q="new":d&&(q="seen"),{shown:a!==null,status:q,briefing:O,line:D,open:()=>{const H=v.current;H&&l(H.seen)},dismiss:()=>l(null)}}function pN(e){const[t,n]=y.useState(e.leases.leases);return y.useEffect(()=>e.leases.subscribe(n),[e]),t}const gN="That changed while you were on it, so nothing was written. It is reloaded now: look again, then redo the change.";function vN(e){var X;const[t,n]=y.useState([]),[o,a]=y.useState(),[l,d]=y.useState(),[h,f]=y.useState({}),[p,v]=y.useState({}),[k,w]=y.useState(!1),[j,N]=y.useState(e.activity.snapshot),[S,I]=y.useState(e.monitor.health),$=pN(e);y.useEffect(()=>e.monitor.subscribe(I),[e]);const[_,O]=y.useState(null),[D,q]=y.useState(),[H,G]=y.useState(),oe=y.useRef(),Q=y.useRef(),ke=y.useRef(new Set),Oe=y.useRef();Oe.current=l;const Te=y.useCallback(z=>{oe.current=z,a(z),O(null)},[]),[ne]=y.useState(ni),ce=y.useCallback(async()=>{var je;const z=ne.start(),T=await e.adapter.listMaps();let P=oe.current;const de=Q.current;de&&T.some(ge=>ge.id===de)?(Q.current=void 0,P=de,P!==oe.current&&Te(P)):(!P||!T.some(ge=>ge.id===P))&&(P=(je=Aw(T)[0])==null?void 0:je.id,Te(P));const[me,we]=await Promise.all([Promise.all(T.map(ge=>e.adapter.loadMap(ge.id))),Promise.all(T.map(ge=>e.adapter.listDecisions(ge.id)))]);z()&&(n(T),f(Object.fromEntries(me.map(ge=>[ge.map.id,ge]))),v(Object.fromEntries(T.map((ge,Se)=>[ge.id,we[Se]]))),w(!0),d(me.find(ge=>ge.map.id===P)))},[e,Te,ne]);y.useEffect(()=>{let z,T=()=>{},P=()=>{},de=!0;const me=()=>{clearTimeout(z),z=setTimeout(()=>void ce().catch(ve=>q(String(ve))),40)},we=vs(me),je=(ve,Fe)=>dn(ve)&&e.activity.isRemote(ve.id)&&(!Fe||!ve.mapId||ve.mapId===Fe),ge=ve=>{var Fe;return(Fe=Oe.current)==null?void 0:Fe.tickets.find(Cn=>Cn.id===ve)},Se=ve=>{const Fe=Jx(ve,ge),Cn=ve.kind==="external.changed"&&e.activity.snapshot.sessions.some(ks=>je(ks,ve.mapId)),mr=!("mapId"in ve)||!ve.mapId||ve.mapId===oe.current||ve.kind==="map.created";Fe&&!Cn&&mr&&e.activity.push(Fe),me()};return e.ready.then(()=>{de&&(T=e.adapter.subscribe(Se),P=e.activity.subscribe(N),e.activity.push({source:"system",level:"ok",text:`Online · tracker ${e.adapter.label.toLowerCase()} · ${e.adapter.location}`}),ce().catch(ve=>q(String(ve))))}),()=>{de=!1,T(),P(),we(),clearTimeout(z)}},[e,ce]),y.useEffect(()=>{o&&ce().catch(z=>q(String(z)))},[o,ce]),y.useEffect(()=>{for(const z of j.sessions)z.mode!=="chart"||!z.mapId||!e.activity.isRemote(z.id)||ke.current.has(z.id)||(ke.current.add(z.id),!(z.status!=="running"&&Date.now()-(z.endedAt??0)>6e4)&&(Q.current=z.mapId,ce().catch(T=>q(String(T)))))},[j.sessions,e,ce]);const F=(X=j.pending[0])==null?void 0:X.sessionId;y.useEffect(()=>{if(!F)return;const z=T=>e.activity.snapshot.sessions.some(P=>P.id===T&&dn(P));G(T=>z(T)?T:F)},[F,e]);const J=y.useCallback(async(z,T)=>{e.activity.push({source:"trail lead",agent:St,level:"warn",text:z});try{q(void 0),await T()}catch(P){const de=P.stale===!0,me=de?gN:P.message??String(P);q(me),e.activity.push({source:"trail lead",agent:St,level:"alert",text:`Rejected · ${me}`}),de&&ce().catch(we=>q(String(we)))}},[e,ce]),ie=y.useMemo(()=>f1({rt:e,guard:J,setMapId:Te,mapIdRef:oe,snapRef:Oe,setChatSession:G,setSelection:O}),[J,e,Te]),W=y.useMemo(()=>Object.values(h).flatMap(z=>oj(z,p[z.map.id]??[])).sort((z,T)=>T.decidedAt-z.decidedAt),[h,p]);return{maps:t,allSnaps:h,mapId:o,snap:l,activity:j,health:S,selection:_,setSelection:O,error:D,chatSession:H,decisions:W,leases:$,loaded:k,actions:ie}}function Xt(e=1e3){const[t,n]=y.useState(Date.now());return y.useEffect(()=>{const o=setInterval(()=>n(Date.now()),e);return()=>clearInterval(o)},[e]),t}function kN(){const[e,t]=y.useState(zd),n=y.useCallback(o=>{t(a=>{const l={...a,...o};return localStorage.setItem(ea,JSON.stringify(l)),l})},[]);return[e,n]}const Yg=()=>{var e,t;return!!((e=ft())!=null&&e.theme)&&!((t=ft())!=null&&t.themeSave)},Jg=e=>{var t;return((t=ft())==null?void 0:t.theme)??e};function yN(e){const t=ft();t!=null&&t.themeSave&&(t.theme=e,ma(e),fetch(t.themeSave,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({theme:e})}).catch(()=>{}))}function wN(){const[e,t]=kN(),[n,o]=y.useReducer(l=>l+1,0);y.useEffect(()=>ma(Jg(e.theme)),[e.theme,n]);const a=y.useCallback(l=>{l.theme&&(yN(l.theme),o()),t(l)},[t]);return[e,a]}function Fd(){return y.useSyncExternalStore(ei.subscribe,ei.get)}function xN({className:e,size:t=18}){return i.jsx("span",{className:e,"aria-hidden":"true",children:i.jsx(Lg,{size:t,variant:Qg()?"night":"crt"})})}function Be({as:e="section",className:t,style:n,frameless:o,children:a,...l}){return i.jsx(e,{className:Ge("panel",o&&"frameless",t),style:n,...l,children:a})}function bn({tone:e,className:t,children:n,title:o}){return i.jsx("span",{className:Ge("pill",e,t),title:o,children:n})}function ln({label:e,value:t,layout:n="stack",urgent:o,title:a,className:l}){return i.jsxs("span",{className:Ge("readout",n!=="stack"&&n,o&&"urgent",l),title:a,children:[i.jsx("span",{className:"mono-label",children:e}),n==="inline"&&" ",i.jsx("b",{children:t})]})}function be(e){const{as:t="div",edge:n="neutral"}=e,o=e.onOpen?"button":"div";return i.jsxs(t,{className:Ge("ds-row",`edge-${n}`,e.selected&&"on",e.className),children:[i.jsxs(o,{className:"ds-row-main",...e.onOpen?{type:"button",onClick:e.onOpen}:{},title:e.titleText,"aria-current":e.current,children:[i.jsxs("span",{className:"ds-row-top",children:[i.jsx("span",{className:"ds-row-title t-row-title",children:e.title}),e.trailing&&i.jsx("span",{className:"ds-row-trail t-meta",children:e.trailing})]}),e.context&&i.jsx("span",{className:"ds-row-context",children:e.context}),e.detail&&i.jsx("span",{className:"ds-row-detail t-meta",title:e.detailText,children:e.detail})]}),e.actions&&i.jsx("span",{className:"ds-row-actions",children:e.actions}),e.below&&i.jsx("div",{className:"ds-row-below",children:e.below})]})}const Gn="#c8581e",jN={map:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M3 6l6-2.5 6 2.5 6-2.5v14.5L15 20.5 9 18l-6 2.5z"}),i.jsx("path",{d:"M9 3.5V18M15 6v14.5"}),i.jsx("path",{d:"M5.5 15c2-1 3-3 5-3.5s3-3 5-4",stroke:Gn,strokeDasharray:"2 2.2"})]}),note:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M5 3.5h14v13.5l-4 3.5H5z"}),i.jsx("path",{d:"M15 21v-4h4"}),i.jsx("path",{d:"M8.5 8h7M8.5 12h7",stroke:Gn})]}),book:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 6.5C10 4.5 7 4 3.5 4.5v14c3.5-.5 6.5 0 8.5 2 2-2 5-2.5 8.5-2v-14C17 4 14 4.5 12 6.5z"}),i.jsx("path",{d:"M12 6.5v14"}),i.jsx("path",{d:"M15 9.5l3-.5M15 13l3-.5",stroke:Gn})]}),flag:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M6 21.5V3"}),i.jsx("path",{d:"M6 4c4-1.5 7 1.5 12 0v9c-5 1.5-8-1.5-12 0z",fill:Gn,stroke:Gn})]}),tent:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 4L2.5 20h19z"}),i.jsx("path",{d:"M12 11l-4 9h8z",fill:Gn,stroke:Gn}),i.jsx("path",{d:"M12 4l-1.5-2M12 4l1.5-2"})]}),mailbox:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 21.500V14"}),i.jsx("path",{d:"M4 14V9.500A4.5 4.5 0 0 1 8.5 5h7A4.5 4.5 0 0 1 20 9.500V14z"}),i.jsx("path",{d:"M8.5 5A4.5 4.5 0 0 1 13 9.500V14"}),i.jsx("path",{d:"M16 10V6.500M16 6.500h3v2.500h-3",stroke:Gn})]})};function Xg({name:e}){return i.jsx("svg",{className:"zone-icon","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:jN[e]})}function At({title:e,count:t,right:n,hot:o,sub:a,children:l,className:d,info:h,icon:f}){return i.jsxs("header",{className:Ge("sec-h",a&&"sub",d),children:[l,f&&i.jsx(Xg,{name:f}),e!==void 0&&i.jsx(ze,{as:a?"h3":"h2",hot:o,children:e}),h&&i.jsx(ii,{text:h}),t,n!==void 0&&i.jsx("span",{className:"sec-h-right",children:n})]})}function at(e){const{value:t,options:n,onChange:o}=e,[a,l]=y.useState(!1),[d,h]=y.useState(0),[f,p]=y.useState(),v=y.useRef(null),k=y.useRef(null),w=y.useId(),j=n.find($=>$.value===t);y.useLayoutEffect(()=>{if(!a||!v.current)return;const $=v.current.getBoundingClientRect();p({left:$.left,top:$.bottom+4,minWidth:$.width})},[a]),y.useEffect(()=>{if(!a)return;const $=O=>{var D,q;O.target instanceof Node&&((D=k.current)!=null&&D.contains(O.target)||(q=v.current)!=null&&q.contains(O.target))||l(!1)},_=()=>l(!1);return document.addEventListener("mousedown",$),window.addEventListener("resize",_),window.addEventListener("scroll",_,!0),()=>{document.removeEventListener("mousedown",$),window.removeEventListener("resize",_),window.removeEventListener("scroll",_,!0)}},[a]),y.useEffect(()=>{var $,_;a&&((_=($=k.current)==null?void 0:$.querySelector(`[data-i="${d}"]`))==null||_.scrollIntoView({block:"nearest"}))},[a,d]);const N=()=>{h(Math.max(0,n.findIndex($=>$.value===t))),l(!0)},S=$=>{var O;const _=n[$];l(!1),(O=v.current)==null||O.focus(),_&&_.value!==t&&o(_.value)},I=$=>{if(!a){["ArrowDown","ArrowUp","Enter"," "].includes($.key)&&($.preventDefault(),N());return}const _=O=>h(D=>(D+O+n.length)%n.length);if($.key==="ArrowDown")_(1);else if($.key==="ArrowUp")_(-1);else if($.key==="Home")h(0);else if($.key==="End")h(n.length-1);else if($.key==="Enter"||$.key===" ")S(d);else{if($.key==="Escape"||$.key==="Tab")return l(!1);if($.key.length===1){const O=n.findIndex(D=>D.label.toLowerCase().startsWith($.key.toLowerCase()));O>=0&&h(O);return}else return}$.preventDefault()};return i.jsxs(i.Fragment,{children:[i.jsxs("button",{ref:v,type:"button",className:Ge("select",e.compact&&"compact",a&&"open",e.className),role:"combobox","aria-haspopup":"listbox","aria-expanded":a,"aria-controls":w,"aria-label":e["aria-label"],"aria-activedescendant":a?`${w}-${d}`:void 0,disabled:e.disabled,onClick:()=>a?l(!1):N(),onKeyDown:I,children:[i.jsx("span",{className:"select-value",children:(j==null?void 0:j.label)??"—"}),i.jsx("span",{className:"select-caret","aria-hidden":"true"})]}),a&&f&&i.jsx("ul",{ref:k,id:w,className:"select-menu",role:"listbox",style:f,children:n.map(($,_)=>i.jsxs("li",{id:`${w}-${_}`,"data-i":_,role:"option","aria-selected":$.value===t,className:Ge(_===d&&"active"),onMouseEnter:()=>h(_),onMouseDown:O=>O.preventDefault(),onClick:()=>S(_),children:[i.jsx("span",{className:"select-label",children:$.label}),$.hint&&i.jsx("span",{className:"select-hint",children:$.hint})]},$.value))})]})}function SN(e){return i.jsx("div",{className:`tabs ${e.className??""}`,role:"tablist",children:e.items.map(t=>i.jsxs("button",{role:"tab","aria-selected":e.value===t.id,className:`tab ${e.value===t.id?"on":""}`,onClick:()=>e.onChange(t.id),children:[t.label,t.n!==void 0&&i.jsx("span",{className:"n",children:t.n})]},t.id))})}const NN=350;function bN(){const[e,t]=y.useState(null);if(y.useEffect(()=>{let o=0,a=null;const l=()=>{window.clearTimeout(o),a=null,t(null)},d=v=>{const k=v.getAttribute("data-tip");if(!k)return;const w=v.getBoundingClientRect(),j=w.bottom+60>window.innerHeight;t({text:k,x:w.left+w.width/2,y:j?w.top-8:w.bottom+8,above:j,scout:v.hasAttribute("data-tip-scout")})},h=v=>{var j,N;const k=(N=(j=v.target)==null?void 0:j.closest)==null?void 0:N.call(j,"[data-tip], [title]");if(!k||k instanceof SVGElement&&!k.hasAttribute("data-tip"))return null;const w=k.getAttribute("title");return w&&(k.setAttribute("data-tip",w),k.removeAttribute("title")),k},f=v=>{if(v.pointerType==="touch")return;const k=h(v);k!==a&&(l(),k&&(a=k,o=window.setTimeout(()=>a===k&&d(k),v.type==="focusin"?0:NN)))},p=v=>{a&&!a.contains(v.relatedTarget)&&l()};return document.addEventListener("pointerover",f),document.addEventListener("pointerout",p),document.addEventListener("focusin",f),document.addEventListener("focusout",l),document.addEventListener("pointerdown",l),window.addEventListener("scroll",l,!0),window.addEventListener("keydown",l),()=>{l(),document.removeEventListener("pointerover",f),document.removeEventListener("pointerout",p),document.removeEventListener("focusin",f),document.removeEventListener("focusout",l),document.removeEventListener("pointerdown",l),window.removeEventListener("scroll",l,!0),window.removeEventListener("keydown",l)}},[]),!e)return null;const n=Math.min(Math.max(e.x,140),window.innerWidth-140);if(e.scout){const o=Math.min(Math.max(e.x-24,8),window.innerWidth-340);return i.jsxs("div",{className:`scout-tip ${e.above?"above":""}`,role:"tooltip",style:{left:o,top:e.y,transform:e.above?"translateY(-100%)":void 0},children:[i.jsx(ua,{size:1,framed:!1,speaking:e.text,className:"scout-tip-face"}),i.jsx("p",{className:"scout-tip-bubble",children:e.text})]})}return i.jsx("div",{className:`tooltip ${e.above?"above":""}`,role:"tooltip",style:{left:n,top:e.y,transform:`translate(-50%, ${e.above?"-100%":"0"})`},children:e.text})}function xa({as:e="span",className:t}){return i.jsxs(e,{className:t?`tt-wordmark ${t}`:"tt-wordmark",role:"img","aria-label":Z.name,children:[Z.name.toLowerCase(),i.jsx("span",{className:"tt-wordmark-dot","aria-hidden":"true"})]})}function Zg(e){return e.bare?i.jsx("div",{className:`zone-b ${e.className??""}`,children:e.children}):i.jsxs(Be,{className:`zone ${e.className??""}`,style:e.area?{gridArea:e.area}:void 0,children:[i.jsx(At,{className:"zone-title",icon:e.icon,title:e.title,info:e.info,count:e.count,right:e.right??null}),i.jsx("div",{className:"zone-b",children:e.children})]})}function Hs(e){return e.children.length?i.jsxs("div",{className:`bf-list ${e.urgent?"urgent":""}`,children:[i.jsx("span",{className:"mono-label",children:e.title}),i.jsx("ul",{children:e.children})]}):null}function Ao(e){return i.jsx("li",{children:i.jsxs("button",{className:"bf-row",onClick:e.onClick,title:e.title,children:[i.jsx("span",{className:"key t-code",children:e.k}),i.jsx("span",{className:"t",children:e.text}),e.meta&&i.jsx("span",{className:"t-meta",children:e.meta})]})})}function Ji(e){return i.jsxs(un,{tone:e.urgent?"urgent":void 0,className:`bf-tile ${e.className??""}`,children:[i.jsx("span",{className:"mono-label",children:e.label}),i.jsx("b",{children:e.value}),e.sub&&i.jsx(V,{parts:[],children:e.sub})]})}const $N=864e5;function CN(e,t){const n=new Date(e),o=n.toTimeString().slice(0,5),a=new Date(t).toDateString(),l=new Date(t-$N).toDateString();let d=` ${n.toLocaleDateString(void 0,{month:"short",day:"numeric"})}`;return n.toDateString()===a?d="":n.toDateString()===l&&(d=" yesterday"),`Since ${o}${d} · ${Jt(t-e)}`}function TN(e){const{briefing:t,bp:n,onClose:o}=e;y.useEffect(()=>{const k=w=>w.key==="Escape"&&o();return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[o]);const a=t==null?void 0:t.trails.flatMap(k=>k.waiting).sort((k,w)=>k.at-w.at)[0],l=t==null?void 0:t.totals,d=((t==null?void 0:t.trails.length)??0)>1,h=n==="mobile",f=k=>{var w,j;return k.ticketId&&((j=(w=e.snaps[k.mapId])==null?void 0:w.tickets.find(N=>N.id===k.ticketId))==null?void 0:j.title)||k.text},p=k=>{var w,j;return k.ticketId&&((j=(w=e.snaps[k.mapId])==null?void 0:w.tickets.find(N=>N.id===k.ticketId))==null?void 0:j.key)||k.agent},v=k=>{const w=($,_)=>i.jsx(Ao,{k:$.key,text:$.title,meta:_,onClick:()=>e.onTicket(k.mapId,$.id)},$.id),j=($,_)=>i.jsx(Ao,{k:$.id,text:$.summary||$.answer,title:$.risk?`${$.question}
|
|
136
|
+
|
|
137
|
+
${$.risk.reason}`:$.question,meta:_,onClick:()=>e.onDecision($.id)},$.id),N=Jj(k.agentDecisions).flatMap($=>$.decisions.map(_=>j(_,$.label))),S=[i.jsx(Hs,{title:"Done",children:k.done.map($=>w($))},"done"),i.jsx(Hs,{title:"Ruled out",children:h?[]:k.ruledOut.map($=>w($))},"oos"),i.jsx(Hs,{title:"Blocked",children:k.blocked.map($=>w($.ticket,`needs ${$.on.map(_=>_.key).join(", ")}`))},"blocked")],I=[i.jsx(Hs,{title:"Waiting on you",urgent:!0,children:k.waiting.map($=>i.jsx(Ao,{k:p($),text:f($),meta:t.now-$.at<6e4?"now":Jt(t.now-$.at),title:$.text,onClick:()=>e.onAnswer($)},$.id))},"waiting"),i.jsx(Hs,{title:"Agent decisions",children:h?[]:N},"agent"),i.jsx(Hs,{title:"Active sessions",children:h?[]:k.active.map($=>{var O;const _=$.ticketId?(O=e.snaps[k.mapId])==null?void 0:O.tickets.find(D=>D.id===$.ticketId):void 0;return i.jsx(Ao,{k:(_==null?void 0:_.key)??$.agent,text:_?`${_.title} · ${$.stepLabel}`:$.stepLabel,meta:`${$.step}/${$.total}`,onClick:()=>e.onSession($)},$.id)})},"active")];return i.jsxs("section",{className:"bf-trail",children:[d&&i.jsxs("div",{className:"bf-trail-h",children:[i.jsx("span",{className:"key",children:k.key})," ",k.title]}),i.jsxs("div",{className:"bf-cols",children:[i.jsx("div",{children:S}),i.jsx("div",{children:I})]})]},k.mapId)};return i.jsx("div",{className:"scrim",onClick:o,children:i.jsxs(Be,{as:"div",className:"dialog briefing",role:"dialog","aria-label":"While you were away",onClick:k=>k.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:"While you were away"}),t&&t.trails.length>0&&i.jsx(ze,{className:"bf-since",children:CN(t.since,t.now)}),i.jsx("button",{className:"icon-btn",onClick:o,"aria-label":"Close",children:"×"})]}),i.jsxs(un,{className:"bf-scout",children:[i.jsx(ua,{size:h?1.1:1.3,speaking:e.line||"Nothing new since you were last here.",caption:!1,framed:!1}),i.jsxs("div",{children:[i.jsx("span",{className:"mono-label",children:"Scout"}),i.jsx("p",{children:e.line||"Nothing new since you were last here."})]})]}),t&&l&&t.trails.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"bf-tiles",children:[i.jsx(Ji,{label:"Done",value:l.done,sub:l.ruledOut?`${l.ruledOut} ruled out`:void 0}),i.jsx(Ji,{label:"Blocked",value:l.blocked,sub:l.blocked?"Needs your answer":void 0}),i.jsx(Ji,{label:"Waiting on you",value:l.waiting,sub:EN(l.oldestWaitMs),urgent:l.waiting>0}),i.jsx(Ji,{label:"Agent decisions",value:l.agentDecisions,className:"opt"}),i.jsx(Ji,{label:"Spend",value:Js(l.usage.costUsd),sub:`${fa(l.usage.inputTokens+l.usage.outputTokens)} tokens · ${l.usage.sessions} sessions${l.active?` · ${l.active} active`:""}`})]}),i.jsx("div",{className:"bf-body",children:t.trails.map(v)})]}),i.jsxs("footer",{children:[i.jsx(M,{onClick:o,children:"Dismiss"}),a?i.jsxs(M,{variant:"urgent",onClick:()=>e.onAnswer(a),children:[i.jsx(oi,{variant:"alert",size:13}),"Answer first decision"]}):i.jsx(M,{variant:"primary",onClick:e.onResume,children:"Resume trail"})]})]})})}function EN(e){if(e!==void 0)return e<6e4?"Just asked":`Oldest ${Jt(e)}`}function AN(e){const{brief:t,bp:n}=e;return i.jsx(TN,{briefing:t.briefing,line:t.line,snaps:e.snaps,bp:n,onClose:t.dismiss,onTicket:(o,a)=>{t.dismiss(),e.openTicket(o,a)},onAnswer:o=>{t.dismiss(),e.closeDecisions(),e.openChat(o.sessionId,o.ticketId,o.mapId)},onSession:o=>{t.dismiss(),e.closeDecisions(),e.openChat(o.id,o.ticketId,o.mapId)},onDecision:o=>{t.dismiss(),e.openDecisions(o)},onResume:()=>{t.dismiss(),e.closeDecisions(),n==="mobile"&&e.showPhoneHome()}})}const IN={passed:"checks passed",failing:"checks failing",pending:"checks pending",unknown:"checks unknown",none:"no checks"};function RN({mapId:e,ticketId:t}){const n=ei.ticket(Fd(),e,t);if(!n)return null;const o=n.pr;return i.jsxs("div",{className:"pr-flags",children:[i.jsxs("span",{className:`pr-chip pr-${(o==null?void 0:o.state)??"unread"}`,title:o?`${o.title}
|
|
138
|
+
${o.headRef}`:void 0,children:[o?i.jsxs("a",{href:Nn(o.url),target:"_blank",rel:"noreferrer noopener",children:["PR #",o.number," · ",o.state,o.draft?" · draft":""]}):`PR #${n.link.number}`,i.jsx("span",{className:`ci ci-${n.checksSummary}`,children:IN[n.checksSummary]}),i.jsx("span",{className:"when",children:MN(n)})]}),n.flags.map(a=>i.jsx(bn,{className:`flag flag-${a.severity}`,title:a.text,children:a.kind},a.kind))]})}function MN(e){return e.error?"sync failed":e.syncedAt?_g(e.syncedAt):"not synced yet"}const LN={ok:"ok",failed:"error",stale:"syncing",unknown:"idle",off:"idle"};function ON({now:e}){const t=Fd();if(!t.reached)return null;const n=Gx(t.live?t.status:null,e);return n.tone!=="failed"&&n.tone!=="stale"?null:i.jsxs("span",{className:`tracker-chip pr-sync tone-${n.tone}`,title:n.title,children:[i.jsx(ze,{size:"sm",children:"CI"}),i.jsx(oi,{variant:"status",state:LN[n.tone],size:13,className:"sync-glyph"}),i.jsx("span",{className:"tl",children:n.label})]})}function ja(e){const t=e.role??"menu",[n,o]=y.useState(!1),a=y.useRef(null);return y.useEffect(()=>{if(!n)return;const l=d=>{var f;(d instanceof KeyboardEvent?d.key==="Escape":!((f=a.current)!=null&&f.contains(d.target)))&&o(!1)};return window.addEventListener("mousedown",l),window.addEventListener("keydown",l),()=>{window.removeEventListener("mousedown",l),window.removeEventListener("keydown",l)}},[n]),i.jsxs("div",{className:Ge("header-menu",e.className),ref:a,children:[i.jsxs(M,{variant:"ghost","aria-haspopup":t,"aria-label":e.ariaLabel,"aria-expanded":n,on:n,"data-tip":n?void 0:e.tip,onClick:()=>o(!n),children:[e.label," ",e.badge," ",i.jsx("span",{className:"caret",children:"▾"})]}),n&&i.jsx("div",{className:"header-menu-list",role:t,children:e.children(()=>o(!1))})]})}function PN(){const e=ft();if(!e)return null;const t=(n,o)=>{o(),location.assign(n)};return i.jsx(ja,{label:e.name,tip:"Your account on the server this Lookout runs on",children:n=>i.jsxs(i.Fragment,{children:[e.home&&i.jsxs("button",{role:"menuitem",className:"header-menu-item",onClick:()=>t(e.home.href,n),children:["← ",e.home.label]}),e.pages.map(o=>i.jsx("button",{role:"menuitem",className:"header-menu-item",onClick:()=>t(o.href,n),children:o.label},o.href)),e.signOut&&i.jsx("button",{role:"menuitem",className:"header-menu-item",onClick:()=>t(e.signOut,n),children:"Sign out"})]})})}const _N={new:"While you were away: a new trip report from Scout",seen:"Reopen the last trip report",none:"No trip report yet. Scout writes one when you come back after being away."};function DN(e){const t=e.briefingStatus==="new";return i.jsx(ja,{label:"Records",badge:i.jsxs(i.Fragment,{children:[e.knowledge>0&&i.jsx("span",{className:"n hot",children:e.knowledge}),t&&i.jsx("span",{className:"new-dot","aria-label":"new trip report"})]}),children:n=>i.jsxs(i.Fragment,{children:[i.jsxs("button",{role:"menuitem",className:"header-menu-item",disabled:e.briefingStatus==="none"&&!e.briefingOpen,title:_N[e.briefingStatus],onClick:()=>{n(),e.onBriefing()},children:[i.jsx("span",{children:"Trip report"}),t&&i.jsx("span",{className:"new-dot","aria-label":"new"})]}),i.jsxs("button",{role:"menuitem",className:"header-menu-item knowledge-btn",title:"What agents know about this codebase and product. Review suggestions, flags and stale entries",onClick:()=>{n(),e.onKnowledge()},children:[i.jsx("span",{children:"Field guide"}),e.knowledge>0&&i.jsx("span",{className:"n hot",children:e.knowledge})]}),i.jsxs("button",{role:"menuitem",className:"header-menu-item decisions-btn",title:"Every decision across your trails, with its reasoning. Search, filter and export",onClick:()=>{n(),e.onDecisions()},children:[i.jsx("span",{children:"Logbook"}),i.jsx("span",{className:"n",children:e.decisions})]}),i.jsx("button",{role:"menuitem",className:"header-menu-item stats-btn",title:"How your agents deliver across trails, by vendor, agent and ticket type.",onClick:()=>{n(),e.onStats()},children:i.jsx("span",{children:"Trail stats"})})]})})}const Et=()=>{var e;return(e=ft())==null?void 0:e.agents},ev=()=>{const e=Et();e&&location.assign(e.href)},tv=e=>{const t=e;if(!(typeof(t==null?void 0:t.on)!="boolean"||!Array.isArray(t.repos)))return{canRun:t.canRun===!0,repos:t.repos.filter(n=>typeof n=="string").slice(0,200),on:t.on,...typeof t.repo=="string"?{repo:t.repo}:{},running:Number.isInteger(t.running)?t.running:0,...typeof t.note=="string"?{note:t.note.slice(0,200)}:{}}},Sa=()=>{var e;return(e=ft())==null?void 0:e.trailAgents};async function zN(e){const t=Sa();if(!t)return;const n=await fetch(`${t}?trail=${encodeURIComponent(e)}`).catch(()=>{});return n!=null&&n.ok?tv(await n.json().catch(()=>{})):void 0}async function BN(e,t){const n=Sa();if(!n)return{error:"This Lookout doesn't run agents."};const o=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({trail:e,...t})}).catch(()=>{}),a=await(o==null?void 0:o.json().catch(()=>{}));return(o!=null&&o.ok?tv(a):void 0)??{error:typeof(a==null?void 0:a.error)=="string"?a.error.slice(0,200):"The server didn't answer."}}function Na({command:e,label:t="Copy"}){const[n,o]=y.useState(!1);return i.jsxs("span",{className:"agent-cmd",children:[i.jsx("code",{children:e}),i.jsx("button",{type:"button",className:"btn sm","data-tip":"Copy, then paste it in Claude Code or Codex",onClick:()=>void navigator.clipboard.writeText(e).then(()=>{o(!0),setTimeout(()=>o(!1),1500)}),children:n?"Copied":t})]})}const Io=[{text:"Agents pick up ready work from their chat",command:"/scout resume"},{text:"Answer what is waiting on you from the chat",command:"/scout inbox"},{text:"Ask Scout where the trail stands",command:"/scout status"},{text:"Start the next trail from your agent",command:'/scout new "your idea"'},{text:"Click a ticket to zoom in. Scroll or pinch to zoom, drag to pan, Fit to see it all"}],FN=9e3;function UN(){const[e,t]=y.useState(0),[n,o]=y.useState(!1);y.useEffect(()=>{if(n)return;const l=setInterval(()=>t(d=>(d+1)%Io.length),FN);return()=>clearInterval(l)},[n]);const a=Io[e];return i.jsxs("div",{className:"command-bar real",children:[i.jsx(Xg,{name:"map"}),i.jsx(ze,{as:"h2",className:"zone-title-label",children:"Trail map"}),i.jsx(ii,{text:"Every decision ticket in this trail and what blocks what. Click a ticket to see it in Trail step. The strip below sums up progress."}),i.jsxs("div",{className:"hint",onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),onFocus:()=>o(!0),onBlur:()=>o(!1),children:[i.jsx("span",{className:"dim",children:a.text}),a.command&&i.jsx(Na,{command:a.command})]},e),i.jsxs("button",{type:"button",className:"link hint-next","data-tip":"Next hint","aria-label":"Next hint",onClick:()=>t(l=>(l+1)%Io.length),children:[e+1,"/",Io.length," ›"]})]})}function WN(e){const t=[{v:"plan+execute",title:"Plan + execute"},{v:"plan-only",title:"Plan only"}];return i.jsx("div",{className:"choice-row",children:t.map(n=>i.jsx(ot,{on:e.value===n.v,title:n.title,onClick:()=>e.onChange(n.v)},n.v))})}function nv(e){return e.running?`Agents · ${e.running} working`:e.note?`Agents · ${e.note}`:"Agents · starting soon"}function sv({agents:e,onStarted:t}){const{state:n,busy:o,error:a,repo:l}=e;if(!n||!n.canRun)return null;const d=()=>void e.act(!0).then(f=>f&&(t==null?void 0:t())),h=Et();return n.on?i.jsxs("span",{className:"start-trail",children:[i.jsx("span",{className:"start-trail-status",children:nv(n)}),i.jsx(M,{size:"sm",variant:"ghost",disabled:o,onClick:()=>void e.act(!1),children:"Pause"}),h&&i.jsx("a",{className:"t-meta",href:`${h.href}#trail-${encodeURIComponent(e.mapId)}`,children:"Runs"}),a&&i.jsx("span",{className:"vf-err",children:a})]}):i.jsxs("span",{className:"start-trail",children:[n.repos.length>1&&i.jsxs("select",{"aria-label":"Repository",value:l??"",onChange:f=>e.setRepo(f.target.value||void 0),children:[i.jsx("option",{value:"",children:"Repository…"}),n.repos.map(f=>i.jsx("option",{value:f,children:f},f))]}),i.jsx(M,{variant:"primary",disabled:o||n.repos.length>1&&!l,onClick:d,children:"Start the trail"}),!n.repos.length&&i.jsx("span",{className:"t-meta",children:"Connect a repository first."}),a&&i.jsx("span",{className:"vf-err",children:a})]})}function iv(e){const[t,n]=y.useState(),[o,a]=y.useState(),[l,d]=y.useState(!1),[h,f]=y.useState();return y.useEffect(()=>{let v=!0;const k=()=>void zN(e).then(j=>v&&j&&n(j));k();const w=setInterval(k,15e3);return()=>{v=!1,clearInterval(w)}},[e]),{mapId:e,state:t,busy:l,error:h,repo:o,setRepo:a,act:async v=>{d(!0),f(void 0);const k=await BN(e,{on:v,...v&&o?{repo:o}:{}});return d(!1),"error"in k?(f(k.error),!1):(n(k),v)}}}function HN({mapId:e,onStarted:t}){return i.jsx(sv,{agents:iv(e),onStarted:t})}function KN({created:e,mapId:t,onStarted:n}){if(Sa())return i.jsxs("div",{className:"agent-draft created",children:[i.jsxs("span",{children:["Trail ",e," is on the map, starting with discovery."]}),i.jsx(HN,{mapId:t,onStarted:n})]});const o=Et();return o?i.jsxs("div",{className:"agent-draft created",children:[i.jsxs("span",{children:["Trail ",e," is on the map, starting with discovery. Turn your agents on for it to get it moving."]}),i.jsx(M,{onClick:ev,children:o.label})]}):i.jsxs("div",{className:"agent-draft created",children:[i.jsxs("span",{children:["Trail ",e," is on the map, starting with discovery. To get it moving, run this in Claude Code or Codex:"]}),i.jsx(Na,{command:"/scout resume",label:"Copy command"})]})}function VN({seed:e,onClose:t,tracker:n,onCreate:o}){const[a,l]=y.useState(),[d,h]=y.useState(!1),[f,p]=y.useState(),[v,k]=y.useState((e==null?void 0:e.title)??""),[w,j]=y.useState((e==null?void 0:e.destination)??""),[N,S]=y.useState((e==null?void 0:e.notes)??""),[I,$]=y.useState((e==null?void 0:e.assumptions.join(`
|
|
139
|
+
`))??""),_=[v.trim(),w.trim(),N.trim()].filter(Boolean).join(". ").replace(/"/g,"'");return y.useEffect(()=>{const O=D=>D.key==="Escape"&&t();return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[t]),i.jsx("div",{className:"scrim",onClick:t,children:i.jsxs(Be,{as:"div",className:"dialog",onClick:O=>O.stopPropagation(),children:[i.jsx("header",{children:i.jsx("h2",{className:"t-heading caps",children:e?"Start over":"New trail"})}),i.jsx(Ze,{label:"Title",children:i.jsx("input",{value:v,onChange:O=>k(O.target.value),autoFocus:!0})}),i.jsx(Ze,{label:"Destination",children:i.jsx("textarea",{rows:3,value:w,onChange:O=>j(O.target.value),placeholder:"What is true when this trail is done?"})}),i.jsx(Ze,{label:"Notes",children:i.jsx("textarea",{rows:2,value:N,onChange:O=>S(O.target.value)})}),i.jsx(Ze,{label:"Assumptions (optional, one per line)",children:i.jsx("textarea",{className:"new-trail-assumptions",rows:2,value:I,onChange:O=>$(O.target.value),placeholder:"What the plan takes for granted, e.g. The v2 API supports batch writes"})}),!Et()&&i.jsxs("div",{className:"agent-draft",children:[i.jsxs("span",{className:"dim",children:["Paste this in Claude Code or Codex. Scout frames the trail with you there, then charts it here in"," ",n,"."]}),i.jsx(Na,{command:`/scout new "${_||"your idea"}"`,label:"Copy command"})]}),a?i.jsx(KN,{created:a.key,mapId:a.id,onStarted:t}):f&&i.jsx("p",{className:"vf-err",children:f}),i.jsxs("footer",{children:[i.jsx(M,{variant:"ghost",onClick:t,children:"Close"}),!a&&i.jsx(M,{variant:"primary",disabled:d||!v.trim()||!w.trim(),"data-tip":Et()?"Put the trail on the map now, then turn your agents on for it":"Put the trail on the map now; any agent picks it up with /scout resume",onClick:()=>{h(!0);const O=I.split(`
|
|
140
|
+
`).map(D=>D.trim());o({title:v.trim(),destination:w.trim(),notes:N.trim(),assumptions:O.filter(Boolean)}).then(D=>l({key:D.key,id:D.id})).catch(D=>p(D.message)).finally(()=>h(!1))},children:"Create trail"})]})]})})}const GN=e=>({title:e.title,destination:e.sections.destination,notes:e.sections.notes,assumptions:(e.sections.assumptions??[]).filter(t=>t.status!=="invalidated").map(t=>t.text)});function qN({mapId:e}){const t=iv(e),{state:n}=t;if(!(n!=null&&n.on))return i.jsx(sv,{agents:t});const o=Et();return i.jsxs(i.Fragment,{children:[i.jsx(ja,{className:"agents-menu",label:i.jsxs(i.Fragment,{children:[i.jsx("span",{className:n.running?"agents-dot on":"agents-dot","aria-hidden":"true"}),nv(n)]}),children:a=>i.jsxs(i.Fragment,{children:[i.jsx("button",{role:"menuitem",className:"header-menu-item",disabled:t.busy,onClick:()=>{a(),t.act(!1)},children:"Pause agents"}),o&&i.jsx("a",{role:"menuitem",className:"header-menu-item",href:`${o.href}#trail-${encodeURIComponent(e)}`,children:"Runs"})]})}),t.error&&i.jsx("span",{className:"vf-err",children:t.error})]})}function QN({mapId:e}){if(Sa())return i.jsx(qN,{mapId:e});const t=Et();if(!t)return null;const n=()=>location.assign(`${t.href}#trail-${encodeURIComponent(e)}`);return i.jsx(M,{size:"sm",onClick:n,"data-tip":"Turn your agents on for this trail, or see them at work",children:"Run agents"})}const YN=i.jsxs(i.Fragment,{children:[i.jsx("circle",{cx:"9",cy:"9",r:"3.6",fill:"currentColor"}),i.jsx("path",{d:"M9 1v2.400M9 14.600V17M1 9h2.400M14.6 9H17M3.3 3.300L5 5M13 13l1.7 1.700M3.3 14.700L5 13M13 5l1.7-1.7",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]}),JN=i.jsx("path",{d:"M15.2 11.400A6.9 6.9 0 0 1 6.6 2.800a6.9 6.9 0 1 0 8.6 8.600z",fill:"currentColor"});function XN({onToggle:e}){const t=Qg(),n=t?"Switch to the day theme":"Switch to the night theme";return i.jsx(M,{variant:"ghost",className:"icon-only","aria-label":n,"data-tip":n,onClick:()=>e(!t),children:i.jsx("svg",{viewBox:"0 0 18 18",width:"16",height:"16","aria-hidden":"true",children:t?YN:JN})})}const ZN={idle:"Idle",syncing:"Syncing",ok:"Synced",error:"Sync error"};function eb({label:e,health:t,now:n}){if(t.status!=="error")return null;const o=[`${ZN[t.status]} · ${t.writes} writes · ${t.errors} errors`,t.lastWriteAt?`Last write ${Jt(t.lastWriteMs??0)}, ${Jt(n-t.lastWriteAt)} ago`:"No writes yet",t.lastError].filter(Boolean).join(`
|
|
141
|
+
`);return i.jsxs("span",{className:`tracker-chip sync-${t.status}`,title:o,children:[i.jsx(ze,{size:"sm",children:"Tracker"}),i.jsx(oi,{variant:"status",state:t.status,size:13,className:"sync-glyph"}),i.jsx("span",{className:"tl",children:e})]})}const Bm={"start-over":{text:e=>`Archive ${e.key} and start a new trail from its idea? The old map stays as history; its tickets and decisions don't carry over.`,confirm:"Start over"},archive:{text:e=>`Archive ${e.key}? It stays as history, read-only, and no agent takes work from it.`,confirm:"Archive"}};function tb(e){const{map:t}=e,[n,o]=y.useState();if(t.archived)return i.jsxs("button",{role:"menuitem",className:"trail-item act","data-tip":"Make it an active trail again: agents can take work from it",onClick:()=>(e.onArchive(!1),e.onDone()),children:["Restore ",t.key]});if(n)return i.jsxs("div",{className:"trail-confirm",role:"group",children:[i.jsx("p",{className:"t-meta",children:Bm[n].text(t)}),i.jsxs("div",{className:"actions",children:[i.jsx(M,{variant:"primary",onClick:()=>{n==="start-over"?e.onStartOver():e.onArchive(!0),e.onDone()},children:Bm[n].confirm}),i.jsx(M,{onClick:()=>o(void 0),children:"Cancel"})]})]});const a=t.mode==="plan-only";return i.jsxs(i.Fragment,{children:[e.onToggleMode&&i.jsx("button",{role:"menuitem",className:"trail-item act","data-tip":a?"Agents decide, then build what was decided":"Agents research and decide; execute tickets wait",onClick:()=>{var l;return(l=e.onToggleMode)==null||l.call(e),e.onDone()},children:a?"Switch to Plan + execute":"Switch to Plan only"}),i.jsxs("button",{role:"menuitem",className:"trail-item act","data-tip":"The map went wrong? Archive it and describe the idea again",onClick:()=>o("start-over"),children:["Start ",t.key," over…"]}),i.jsxs("button",{role:"menuitem",className:"trail-item act","data-tip":"Put the trail away as history",onClick:()=>o("archive"),children:["Archive ",t.key,"…"]})]})}function nb(e){const{map:t}=e.snap,n=ig(e.snap);return i.jsxs("button",{role:"menuitem",className:`trail-item ${e.on?"on":""} ${t.archived?"archived":""}`,onClick:e.onSelect,children:[i.jsx("span",{className:"key",children:t.key}),i.jsx("span",{className:"mi-title",children:t.title}),i.jsxs("span",{className:"mi-progress",children:[n.decided,"/",n.total]}),i.jsx(fs,{n:e.waiting,urgent:!!e.waiting,hideZero:!0})]})}function sb(e){var v;const[t,n]=y.useState(!1),o=y.useRef(null);y.useEffect(()=>{if(!t)return;const k=w=>{var j;(w instanceof KeyboardEvent?w.key==="Escape":!((j=o.current)!=null&&j.contains(w.target)))&&n(!1)};return window.addEventListener("mousedown",k),window.addEventListener("keydown",k),()=>{window.removeEventListener("mousedown",k),window.removeEventListener("keydown",k)}},[t]);const a=Object.values(e.snaps).sort((k,w)=>w.map.createdAt-k.map.createdAt),l=a.filter(k=>!k.map.archived),d=a.filter(k=>k.map.archived),h=k=>e.activity.pending.filter(w=>w.mapId===k).length,f=e.activity.pending.filter(k=>{var w;return k.mapId!==((w=e.map)==null?void 0:w.id)}).length,p=k=>{var w;return i.jsx(nb,{snap:k,on:k.map.id===((w=e.map)==null?void 0:w.id),waiting:h(k.map.id),onSelect:()=>{e.onSelectMap(k.map.id),n(!1)}},k.map.id)};return i.jsxs("div",{className:"trail-switcher",ref:o,children:[i.jsxs("button",{className:"trail-btn",onClick:()=>n(k=>!k),"aria-haspopup":"menu","aria-expanded":t,"data-tip":"Switch trail, or start a new one",children:[i.jsx("span",{className:"trail-title",children:e.map?`${e.map.key} ${e.map.title}`:"No trail"}),((v=e.map)==null?void 0:v.archived)&&i.jsx("span",{className:"trail-archived",children:"archived"}),f>0&&i.jsx(fs,{n:f,urgent:!0}),i.jsx("span",{className:"caret",children:"▾"})]}),t&&i.jsxs("div",{className:"trail-menu",role:"menu",children:[i.jsx(ze,{variant:"plain",className:"menu-h",children:"Trails"}),l.map(p),i.jsx("button",{role:"menuitem",className:"trail-item new",onClick:()=>{n(!1),e.onNewTrail()},children:"+ New trail"}),d.length>0&&i.jsxs(i.Fragment,{children:[i.jsx(ze,{variant:"plain",className:"menu-h",children:"Archived"}),d.map(p)]}),e.map&&e.onStartOver&&e.onArchive&&i.jsx("div",{className:"trail-acts",children:i.jsx(tb,{map:e.map,onStartOver:e.onStartOver,onArchive:e.onArchive,onToggleMode:e.onToggleMode,onDone:()=>n(!1)})})]})]})}function ib(e){const{map:t}=e,n=Xt(1e3),o=e.activity.pending.length,a=t&&e.snaps[t.id],l=a&&ig(a),d=t&&rg(e.activity,t.id);return i.jsxs(Be,{as:"header",className:"header",children:[i.jsxs("div",{className:"h-title",children:[i.jsxs("div",{className:"h-line1",children:[e.repo,i.jsx("span",{className:"sep",children:"/"}),i.jsx(sb,{...e})]}),i.jsxs("div",{className:"h-dest",title:t==null?void 0:t.sections.destination,children:[i.jsx(ze,{size:"sm",children:"Destination"}),(t==null?void 0:t.sections.destination)??"—"]})]}),i.jsxs("div",{className:"h-right",children:[i.jsx(eb,{label:e.trackerLabel,health:e.health,now:n}),i.jsx(ON,{now:n}),t&&l&&i.jsxs("span",{className:"trail-meta",children:[i.jsx(ln,{label:"Trail T+",value:Pg(n-t.createdAt),title:"Trail elapsed time, since it was charted"}),i.jsx(ln,{label:"Done",value:`${l.decided}/${l.total}`}),d&&d.costUsd+d.inputTokens+d.outputTokens>0&&i.jsx(ln,{className:"spend",label:"Spent",value:`${Js(d.costUsd)} · ${fa(d.inputTokens+d.outputTokens)} tok`,title:["Model spend and tokens for this trail, across every session",...ag(e.activity,t.id).map(h=>og[h].text)].join(`
|
|
142
|
+
`)})]}),e.attention,!e.attention&&o>0&&i.jsxs("span",{className:"waiting-chip",title:`${o} waiting on you`,children:[i.jsx(oi,{variant:"alert",size:14}),i.jsx("b",{children:o}),i.jsx("span",{className:"wl",children:" waiting on you"})]}),e.slackAlert&&i.jsx(M,{size:"sm",variant:"urgent",onClick:e.onSlack,title:e.slackAlert.why,children:e.slackAlert.label}),(t==null?void 0:t.mode)==="plan-only"&&i.jsx(M,{variant:"ghost",className:"mode-chip",onClick:e.onToggleMode,"data-tip":"Plan only: agents research and decide, but no execute tickets run. Click to switch to Plan + execute.",children:"Plan only"}),t&&i.jsx(QN,{mapId:t.id}),i.jsx(DN,{decisions:e.decisions,onDecisions:e.onDecisions,onStats:e.onStats,knowledge:e.knowledge,onKnowledge:e.onKnowledge,briefingOpen:e.briefingOpen,briefingStatus:e.briefingStatus,onBriefing:e.onBriefing}),i.jsx(M,{variant:"ghost",onClick:e.onSettings,"data-tip":"Tracker, verification, appearance and integrations",children:"Settings"}),Yg()?null:i.jsx(XN,{onToggle:e.onToggleTheme}),i.jsx(PN,{})]})]})}const rv=y.createContext(null);function ai(){const e=y.useContext(rv);if(!e)throw new Error("useKnowledge needs a KnowledgeContext provider");return e}function rb({snap:e,t}){const n=ai();if(!n.entries.length||t.state==="closed")return null;const o=yg(n.entries,{trailKey:e.map.key,ticket:{type:t.type,title:t.title,body:t.body},paths:wg(`${t.body}
|
|
143
|
+
${n.briefText}`)},4e3,a=>n.stale[a.id]??[]);return i.jsxs("div",{className:"kn-preview d-section",children:[i.jsxs("span",{className:"t-label","data-tip":"Picked by paths, words, trail and kind; confirmed entries and assumptions only",children:["Knowledge this agent gets · ",o.length]}),o.length>0&&i.jsx("ul",{className:"item-list inline",children:o.map(a=>i.jsxs("li",{children:[i.jsx("button",{className:"item-text kn-open",onClick:()=>n.setOpen(!0),"data-tip":a.why.join(" · "),children:a.title}),i.jsx(V,{parts:[{text:a.id,code:!0},a.status==="assumption"&&"assumption",a.mayBeOutdated&&{text:"may be outdated",className:"warn"}]})]},a.id))})]})}function Ro(e,t){return(e==null?void 0:e.hash)===void 0?{hash:t,latest:t}:e.latest===t?e:{hash:e.hash,latest:t}}function ba(e,t){const[n,o]=y.useState({key:e,shown:Ro(void 0,t)});let a=n;return n.key!==e?a={key:e,shown:Ro(void 0,t)}:n.shown.latest!==t&&(a={key:e,shown:Ro(n.shown,t)}),a!==n&&o(a),{hash:a.shown.hash,changed:a.shown.hash!==a.shown.latest,reviewAgain:()=>o({key:e,shown:Ro(void 0,t)})}}const ob={suggested:"Suggested by an agent. Not delivered to agents until you confirm it or keep it as an assumption.",confirmed:"Confirmed: agents treat it as a fact.",assumption:"Kept as an assumption: agents get it, marked as unverified.",outdated:"Outdated: kept for history, never delivered."};function ab({e}){const t=ai(),[n,o]=y.useState(!1),[a,l]=y.useState(e.title),[d,h]=y.useState(e.body);y.useEffect(()=>{o(!1),l(e.title),h(e.body)},[e.id,e.title,e.body]);const f=t.stale[e.id],p=ba(e.id,t.hashes[e.id]);return i.jsxs("div",{className:"kn-detail",children:[i.jsx(V,{parts:[{text:e.id,code:!0},e.kind.replace("-"," "),e.status]}),n?i.jsxs(i.Fragment,{children:[i.jsx(Ze,{label:"Title",children:i.jsx("input",{value:a,onChange:v=>l(v.target.value)})}),i.jsx(Ze,{label:"Body",children:i.jsx("textarea",{rows:8,value:d,onChange:v=>h(v.target.value)})})]}):i.jsxs(i.Fragment,{children:[i.jsx("h3",{className:"t-title",children:e.title}),i.jsx("p",{className:"kn-body",children:e.body})]}),i.jsx("p",{className:"dim",children:ob[e.status]}),e.flag&&i.jsxs("p",{className:"kn-warn",children:["Flagged by ",e.flag.by,": ",e.flag.reason]}),f&&e.status!=="outdated"&&i.jsxs("p",{className:"kn-warn",children:["May be outdated: ",f.join(", ")," changed since it was confirmed. Re-confirm or edit it."]}),i.jsxs("dl",{className:"facts",children:[e.scope.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Applies to"}),i.jsx("dd",{children:e.scope.join(", ")})]}),e.tags.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Tags"}),i.jsx("dd",{children:e.tags.join(", ")})]}),i.jsx("dt",{children:"From"}),i.jsx("dd",{children:[e.createdBy,...e.sources].join(" · ")}),e.anchors.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"About files"}),i.jsx("dd",{children:e.anchors.map(v=>v.path).join(", ")})]})]}),p.changed&&i.jsx(ya,{what:"This entry",onReviewAgain:p.reviewAgain}),t.error&&i.jsx("p",{className:"vf-err",children:t.error}),i.jsx("div",{className:"actions",children:n?i.jsxs(i.Fragment,{children:[i.jsx(M,{variant:"ghost",onClick:()=>o(!1),children:"Cancel"}),i.jsx(M,{variant:"primary",disabled:!a.trim(),onClick:()=>void t.call(e.id,{kind:"edit",title:a,body:d}).then(v=>v&&o(!1)),children:"Save"})]}):i.jsxs(i.Fragment,{children:[(e.status!=="confirmed"||f)&&i.jsx(M,{variant:"primary",disabled:p.changed,onClick:()=>void t.call(e.id,{kind:"confirm"},p.hash),children:e.status==="confirmed"?"Re-confirm":"Confirm"}),e.status!=="assumption"&&e.status!=="outdated"&&i.jsx(M,{disabled:p.changed,onClick:()=>void t.call(e.id,{kind:"assumption"},p.hash),children:"Keep as assumption"}),e.flag&&i.jsx(M,{onClick:()=>void t.call(e.id,{kind:"resolve-flag"}),children:"Resolve flag"}),i.jsx(M,{variant:"ghost",onClick:()=>o(!0),children:"Edit"}),e.status!=="outdated"&&i.jsx(M,{variant:"ghost",onClick:()=>void t.call(e.id,{kind:"outdated"}),children:"Mark outdated"})]})})]})}const lb={suggested:"Suggested",confirmed:"Confirmed",assumption:"Assumption",outdated:"Outdated"};function cb(){const e=ai(),[t,n]=y.useState("review"),[o,a]=y.useState(""),[l,d]=y.useState(""),[h,f]=y.useState();y.useEffect(()=>{if(!e.open)return;const S=I=>I.key==="Escape"&&e.setOpen(!1);return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[e]);const p=S=>S.status==="suggested"||!!S.flag||!!e.stale[S.id]&&S.status!=="outdated",v=(S,I)=>I==="all"?!0:I==="review"?p(S):S.status===I,k=y.useMemo(()=>{const S=l.trim().toLowerCase();return e.entries.filter(I=>v(I,t)&&(!o||I.kind===o)&&(!S||`${I.id} ${I.title} ${I.body} ${I.tags.join(" ")}`.toLowerCase().includes(S)))},[e.entries,e.stale,t,o,l]);if(!e.open)return null;const w=k.find(S=>S.id===h)??k[0],j=S=>e.entries.filter(I=>v(I,S)).length,N=[["review","Needs you"],["confirmed","Confirmed"],["assumption","Assumptions"],["outdated","Outdated"],["all","All"]];return i.jsx("div",{className:"scrim",onClick:()=>e.setOpen(!1),children:i.jsxs(Be,{as:"div",className:"dialog knowledge-view",onClick:S=>S.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:"Field guide"}),i.jsx(ii,{text:"What agents need to know about this codebase and product. Agents propose entries; only confirmed ones and assumptions reach them, picked for each ticket with the reason. Entries about files are flagged here when those files change. Seed it from a document with: teamtrail knowledge import <file.md>"})]}),i.jsxs("div",{className:"kn-filters",children:[N.map(([S,I])=>i.jsxs("button",{className:`chip ${t===S?"on":""}`,onClick:()=>n(S),children:[I," ",i.jsx("span",{className:"n",children:j(S)})]},S)),i.jsx(at,{compact:!0,"aria-label":"Kind",value:o,onChange:a,options:[{value:"",label:"Any kind"},...Uj.map(S=>({value:S,label:S.replace("-"," ")}))]}),i.jsx("input",{className:"kn-search",placeholder:"Search",value:l,onChange:S=>d(S.target.value)})]}),i.jsxs("div",{className:"kn-body-grid",children:[i.jsx("ul",{className:"kn-list",children:k.length?k.map(S=>i.jsx(be,{as:"li",className:`kn-row st-${S.status}`,edge:p(S)?"attention":"neutral",selected:S===w,onOpen:()=>f(S.id),title:S.title,titleText:S.title,context:i.jsx(V,{parts:[{text:S.id,code:!0},S.kind.replace("-"," "),p(S)&&S.status!=="suggested"?"Needs a check":lb[S.status]]})},S.id)):i.jsx(Ie,{children:t==="review"?"Nothing needs you":"No entries"})}),w?i.jsx(ab,{e:w}):i.jsx(Ie,{children:"Pick an entry"})]})]})})}function Ud({draft:e,label:t="Save as knowledge"}){const n=ai(),[o,a]=y.useState();return o?i.jsxs(M,{size:"sm",variant:"ghost",onClick:()=>n.setOpen(!0),"data-tip":"Open it in the field guide to confirm it",children:["Saved as ",o]}):i.jsx(M,{size:"sm",variant:"ghost","data-tip":"Add it to the field guide as a suggestion; confirm it there and agents get it with related work",onClick:()=>void n.propose(e()).then(l=>l&&a(l.id)),children:t})}const db=e=>{try{return JSON.parse(e)}catch{return}};function ov(e){const t=ni();let n=!1;const o=()=>{const h=t.start();e.load().then(f=>!n&&h()&&e.show(f),()=>{var f;return!n&&h()&&((f=e.failed)==null?void 0:f.call(e))})},{changed:a,events:l={}}=e,d=[vs(o),...a?[_d(h=>a(h)&&o())]:[],...Object.entries(l).map(([h,f])=>si(h,p=>f(db(p))&&o()))];return o(),{reload:o,pushed:()=>t.pushed(),stop:()=>{n=!0;for(const h of d)h()}}}function Ye(e){const t=y.useRef(e);t.current=e;const n=y.useRef(),o=y.useRef(e.version),{view:a,version:l}=e;y.useEffect(()=>{const f=t.current;o.current=f.version;const p=Object.keys(f.events??{}),v=ov({load:()=>t.current.load(),show:k=>t.current.show(k),failed:()=>{var k,w;return(w=(k=t.current).failed)==null?void 0:w.call(k)},...f.changed?{changed:k=>{var w,j;return((j=(w=t.current).changed)==null?void 0:j.call(w,k))===!0}}:{},events:Object.fromEntries(p.map(k=>[k,w=>{var j,N;return((N=(j=t.current.events)==null?void 0:j[k])==null?void 0:N.call(j,w))===!0}]))});return n.current=v,()=>{v.stop(),n.current=void 0}},[a]),y.useEffect(()=>{var f;Object.is(o.current,l)||(o.current=l,(f=n.current)==null||f.reload())},[l]);const d=y.useCallback(()=>{var f;return(f=n.current)==null?void 0:f.reload()},[]),h=y.useCallback(()=>{var f;return(f=n.current)==null?void 0:f.pushed()},[]);return{reload:d,pushed:h}}const av=`${pe()}/knowledge`;async function Fm(e,t){const n=await fetch(`${av}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),o=await n.json().catch(()=>({}));if(!n.ok)throw new Error(o.error??`HTTP ${n.status}`);return o}async function ub(){const e=await fetch(av);return e.ok?await e.json():null}function hb(e){const[t,n]=y.useState([]),[o,a]=y.useState({}),[l,d]=y.useState({}),[h,f]=y.useState(!1),[p,v]=y.useState(),{reload:k}=Ye({load:ub,show:j=>{j&&(n(j.entries),a(j.stale),d(j.hashes??{}))},changed:j=>j.startsWith("knowledge/")}),w=y.useMemo(()=>t.filter(j=>j.status==="suggested"||j.flag||o[j.id]&&j.status!=="outdated").length,[t,o]);return{entries:t,stale:o,briefText:e,attention:w,open:h,setOpen:f,error:p,hashes:l,call:(j,N,S)=>Fm("/call",{id:j,call:N,hash:S??l[j]}).then(()=>(v(void 0),k(),!0),I=>(v(I.message),k(),!1)),propose:j=>Fm("/propose",j).then(N=>(k(),N.entry),N=>(v(N.message),void 0))}}const fb=["awaiting","blocked","trail.done","resolved"];async function qn(e,t="GET",n){const o=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:n===void 0?void 0:JSON.stringify(n)}),a=await o.json().catch(()=>({}));if(!o.ok&&!a.status)throw new Error(a.error??`request failed (${o.status})`);return a}function mb(e){const t=`${e}/slack`;return{get:()=>qn(t),connectStart:n=>qn(`${t}/connect/start`,"POST",{project:n}),connectPreview:n=>qn(`${t}/connect/preview`,"POST",{code:n}),connectFinish:n=>qn(`${t}/connect/finish`,"POST",{code:n}),connectCancel:()=>qn(`${t}/connect/cancel`,"POST",{}),disconnect:()=>qn(`${t}/connect`,"DELETE"),update:n=>qn(`${t}/settings`,"PUT",n),members:()=>qn(`${t}/members`).then(n=>n.members)}}const jn=mb(pe());function pb(e){const{who:t}=e;return i.jsxs(i.Fragment,{children:[i.jsxs("p",{className:"sl-lead",children:["Connect as ",i.jsxs("b",{children:["@",t.user.name??t.user.id]})," in ",i.jsx("b",{children:t.workspace.name}),"? That Slack account becomes Scout's owner for this Teamtrail: questions and approvals reach it."]}),i.jsxs("div",{className:"c-actions",children:[i.jsx(M,{size:"sm",variant:"primary",onClick:e.onConnect,children:"Connect"}),i.jsx(M,{size:"sm",variant:"ghost",onClick:e.onCancel,children:"Cancel"})]})]})}const gb=e=>new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});function vb({problem:e}){const t=e.failures===1?"A message was":`${e.failures} messages were`;return i.jsxs("div",{className:"test-line warn",title:e.code,children:[t," not delivered (last ",gb(e.at),"). ",e.message]})}function hd(e){const[t,n]=y.useState(!1),o=()=>{n(!0),jn.connectStart(ur()).then(a=>location.assign(a.url),a=>{n(!1),e.onError(a.message)})};return i.jsx(M,{size:"sm",variant:"primary",disabled:t,onClick:o,children:e.again?"Add Scout to Slack again":"Add Scout to Slack"})}function kb(e){return i.jsxs("div",{className:"test-line mentions-hint",children:[i.jsx("span",{children:"Reconnect to allow @Scout mentions: Slack needs one more permission for them."}),i.jsx(hd,{again:!0,onError:e.onError})]})}function yb({s:e,connecting:t}){return t?i.jsx("p",{className:"sl-lead",children:"Connecting Scout…"}):i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"sl-lead",children:"Answer agents, approve finished work and save threads as decisions from Slack. Scout is Teamtrail's Slack app: add it to your workspace and it talks to you about this machine's trails. Questions and answers pass through Teamtrail's Scout service; your trails, decisions and approvals stay here."}),e.legacy&&i.jsx("p",{className:"sl-lead",children:"You made your own Slack app with an earlier version. Scout is now one app, so add it again: your old app's tokens are deleted from this machine when you do."})]})}function wb(e){return i.jsx("a",{className:["btn",e.primary&&"primary",e.small&&"sm"].filter(Boolean).join(" "),href:Nn(e.href,["slack:"]),target:"_blank",rel:"noreferrer",onClick:e.onClick,children:e.children})}function Um({onRemoved:e}){const[t,n]=y.useState(!1);if(!t)return i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>n(!0),children:"Disconnect"});const o=()=>void jn.disconnect().then(a=>{n(!1),e(a)},()=>{});return i.jsxs(i.Fragment,{children:[i.jsx(M,{size:"sm",variant:"danger",onClick:o,children:"Disconnect and forget Slack settings"}),i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>n(!1),children:"Keep"})]})}function xb(e){const{s:t}=e,n=t.state==="auth-error"||t.state==="other-service";return t.connected?i.jsxs("div",{className:"c-actions",children:[n?i.jsx(hd,{again:!0,onError:e.onError}):i.jsx(M,{size:"sm",on:t.enabled,onClick:e.onToggle,children:t.enabled?"Turn off":"Turn on"}),t.links.homeWeb&&i.jsx(wb,{small:!0,href:t.links.homeWeb,children:"Open Scout in Slack"}),i.jsx(Um,{onRemoved:e.onChanged})]}):i.jsxs("div",{className:"c-actions",children:[!e.busy&&i.jsx(hd,{again:t.legacy,onError:e.onError}),t.legacy&&i.jsx(Um,{onRemoved:e.onChanged})]})}const jb={awaiting:"Awaiting you",blocked:"Blocked","trail.done":"Trail done",resolved:"Resolved"};function Sb({s:e}){const[t,n]=Nb(e);return i.jsxs("div",{className:`sync-line ${t}`,title:e.error,children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:n})]})}function Nb(e){switch(e.state){case"online":return["ok","Online"];case"connecting":return["","Connecting"];case"offline":return["warn","Offline · reconnecting"];case"auth-error":return["alert",`Disconnected · ${e.error??"add Scout to Slack again"}`];case"elsewhere":{const t=e.heldBy?` (${e.heldBy})`:"";return["warn",`Connected from another ${Z.slug}${t}`]}case"other-service":return["alert","Not connected · this Teamtrail points at another Scout service"];case"unsupported":return["alert",e.error??"Not supported here"];default:return["",e.connected?"Off":"Not connected"]}}function bb(e){const{s:t,back:n}=e,o=!!n.confirm&&!t.connected;return i.jsxs(un,{className:Cb(t),children:[i.jsxs("div",{className:"card-row",children:[i.jsx("b",{className:"choice-title t-row-title",children:"Scout in Slack"}),t.connected&&i.jsx(bn,{className:t.enabled?"on":"",children:t.enabled?"On":"Off"})]}),t.connected&&i.jsx("div",{className:"c-loc",children:$b(t)}),t.connected&&i.jsx(Sb,{s:t}),t.connected&&i.jsx("div",{className:"t-meta",children:"Scout answers in Slack only while this Teamtrail is running."}),t.delivery&&i.jsx(vb,{problem:t.delivery}),t.connected&&t.mentions===!1&&!o&&i.jsx(kb,{onError:e.onError}),!t.connected&&!o&&i.jsx(yb,{s:t,connecting:n.busy}),o&&i.jsx(pb,{who:n.confirm,onConnect:n.connect,onCancel:n.cancel}),e.error&&i.jsxs("div",{className:"test-line alert",children:["✕ ",e.error]}),!o&&i.jsx(xb,{s:t,busy:n.busy,onError:e.onError,onChanged:e.onChanged,onToggle:e.onToggle})]})}function $b(e){var n,o,a;const t=(o=(n=e.workspace)==null?void 0:n.url)==null?void 0:o.replace(/^https?:\/\/|\/$/g,"");return[(a=e.workspace)==null?void 0:a.name,t].filter(Boolean).join(" · ")}function Cb(e){const t=e.connected&&e.enabled?"active":"",n=e.connected?"":"open";return`connector ${t} ${n}`}function Tb(e){const[t,n]=y.useState(e.value==="dm"?"":e.value),o=/^[CG][A-Z0-9]{6,}$/.test(t.trim());return i.jsxs("form",{className:"sl-field",onSubmit:a=>{a.preventDefault(),o&&e.onSave(t.trim())},children:[i.jsx("input",{value:t,spellCheck:!1,placeholder:"Channel ID, e.g. C0123ABCD","aria-label":"Channel ID",onChange:a=>n(a.target.value)}),i.jsx(M,{type:"submit",disabled:!o||t.trim()===e.value,children:"Save"})]})}function Eb(e){const[t,n]=y.useState(),[o,a]=y.useState();y.useEffect(()=>{jn.members().then(n,h=>a(h.message))},[]);const l=new Set(e.owners.map(h=>h.id)),d=new Set(e.value.map(h=>h.id));return o?i.jsxs("div",{className:"test-line alert",children:["✕ ",o]}):t?i.jsx("div",{className:"choice-row compact sl-members",children:t.map(h=>i.jsx(ot,{on:l.has(h.id)||d.has(h.id),disabled:l.has(h.id),title:`@${h.name??h.id}`,sub:l.has(h.id)?"Owner":void 0,onClick:()=>e.onChange(d.has(h.id)?e.value.filter(f=>f.id!==h.id):[...e.value,h])},h.id))}):i.jsx("span",{className:"t-meta",children:"Loading members…"})}function Ab(e){const{s:t,patch:n}=e,[o,a]=y.useState(!1),l=new Set(t.notify.events),d=o||t.notify.target!=="dm",h=t.owners[0],f=p=>{const v=l.has(p)?t.notify.events.filter(k=>k!==p):[...t.notify.events,p];n({notify:{events:v}})};return i.jsxs("div",{className:"sl-groups",children:[i.jsxs("div",{className:"sl-group",children:[i.jsx(ze,{variant:"plain",size:"sm",children:"Owner"}),i.jsxs("div",{className:"sl-owner",children:[i.jsxs("b",{children:["@",(h==null?void 0:h.name)??(h==null?void 0:h.id)]}),i.jsx("span",{className:"t-meta",children:"Added Scout from this machine"})]})]}),i.jsxs("div",{className:"sl-group",children:[i.jsx(ze,{variant:"plain",size:"sm",children:"Allowed users"}),i.jsx(Eb,{value:t.allow,owners:t.owners,onChange:p=>n({allow:p})},t.state)]}),i.jsxs("div",{className:"sl-group",children:[i.jsx(ze,{variant:"plain",size:"sm",children:"Notify"}),i.jsxs("div",{className:"choice-row compact",children:[i.jsx(ot,{on:!d,title:"DM to owner",onClick:()=>{a(!1),n({notify:{target:"dm",detail:"full"}})}}),i.jsx(ot,{on:d,title:"Channel",sub:t.notify.target!=="dm"?t.notify.target:void 0,onClick:()=>a(!0)})]}),d&&i.jsxs(i.Fragment,{children:[i.jsx(Ze,{label:"Channel ID (invite @Scout there first)",children:i.jsx(Tb,{value:t.notify.target,onSave:p=>n({notify:{target:p}})})}),i.jsxs("div",{className:"choice-row compact",children:[i.jsx(ot,{on:t.notify.detail==="full",title:"Full questions",onClick:()=>n({notify:{detail:"full"}})}),i.jsx(ot,{on:t.notify.detail==="titles-only",title:"Titles only",onClick:()=>n({notify:{detail:"titles-only"}})})]})]}),i.jsx("div",{className:"choice-row compact",children:fb.map(p=>i.jsx(ot,{on:l.has(p),title:jb[p],onClick:()=>f(p)},p))})]}),i.jsx(ud,{className:"dim",parts:[`${t.command} decide`,`${t.command} status`,`${t.command} inbox`,"Save as decision on any message"]})]})}function Ib(){if(typeof location>"u")return;const e=/(?:^#|&)slack-link=([A-Za-z0-9_-]{43})/.exec(location.hash);if(e)return history.replaceState(null,"",`${location.pathname}${location.search}`),e[1]}const _c={code:Ib()};function Rb(e){const[t,n]=y.useState(),[o,a]=y.useState(),[l,d]=y.useState(),[h,f]=y.useState(!!_c.code),p=k=>d(k.message);y.useEffect(()=>{const k=_c.code;k&&(_c.code=void 0,n(k),jn.connectPreview(k).then(a,p).finally(()=>f(!1)))},[]);const v=k=>{f(!0),a(void 0),k.then(e,p).finally(()=>f(!1))};return{busy:h,error:l,confirm:o,connect:()=>t&&v(jn.connectFinish(t)),cancel:()=>v(jn.connectCancel())}}function Wd(e=0){const[t,n]=y.useState(),o=y.useCallback(()=>jn.get().then(n,()=>n(null)),[]);return y.useEffect(()=>{if(o(),!e)return;const a=setInterval(()=>void o(),e);return()=>clearInterval(a)},[o,e]),[t,n]}function Mb(e){const[t,n]=Wd(3e3),o=Rb(n),[a,l]=y.useState(),d=y.useRef(null);if(y.useEffect(()=>{var f;e.focus&&t&&((f=d.current)==null||f.scrollIntoView({block:"start"}))},[e.focus,!!t]),!t)return null;const h=f=>jn.update(f).then(n,()=>{});return i.jsxs("div",{ref:d,className:"slack-settings",children:[i.jsx(bb,{s:t,back:o,error:a??o.error,onError:l,onToggle:()=>void h({enabled:!t.enabled}),onChanged:f=>{l(void 0),n(f)}}),t.connected&&i.jsx(Ab,{s:t,patch:f=>void h(f)})]})}function Lb(e){if(e.legacy&&!e.connected)return{label:"Add Scout to Slack again",why:"Scout is now one Slack app; your own app no longer works"};if(e.connected&&e.state==="auth-error")return{label:"Slack disconnected",why:e.error??"Add Scout again"}}let Wm;function Ob(){return Wm??(Wm=jn.get().then(e=>({owners:e.owners??[],allow:e.allow??[]}),()=>{})),Wm}function li(){const[e,t]=y.useState();return y.useEffect(()=>{let n=!0;return Ob().then(o=>n&&t(o)),()=>{n=!1}},[]),e}function Pb(e){const{api:t,rt:n,brief:o}=e,{snap:a,actions:l}=t,[d]=Wd(15e3),h=ai(),f=d?Lb(d):void 0;return i.jsx(ib,{repo:e.repo,snaps:t.allSnaps,map:a==null?void 0:a.map,activity:t.activity,health:t.health,onNewTrail:e.onNewTrail,onStartOver:e.onStartOver,onArchive:l.setArchived,trackerLabel:n.adapter.label.toLowerCase(),onSelectMap:l.selectMap,onToggleMode:()=>a&&l.setMode(a.map.mode==="plan-only"?"plan+execute":"plan-only"),onSettings:e.onSettings,onToggleTheme:e.onToggleTheme,attention:e.attention,slackAlert:f,onSlack:e.onSlack,decisions:t.decisions.length,decisionsOpen:e.decisionsOpen,onDecisions:e.onDecisions,onStats:e.onStats,knowledge:h.attention,knowledgeOpen:h.open,onKnowledge:()=>h.setOpen(!h.open),briefingOpen:o.shown,briefingStatus:o.status,onBriefing:()=>o.shown?o.dismiss():o.open()})}const _b="This is a high-risk call: only an owner, or someone they allowed to make high-risk calls, can make it. It waits for them.",lv=()=>{var e;return((e=ft())==null?void 0:e.highRisk)===!1};function Db(e){var t;return(t=e.options)!=null&&t.length?i.jsx("div",{className:"suggest",children:e.options.map(n=>i.jsx("button",{className:"chip",onClick:()=>e.onPick(n),children:n},n))}):null}function zb(e){const{pending:t}=e;return t!=null&&t.lookoutOnly&&lv()?i.jsx("p",{className:"vf-intro",children:_b}):i.jsxs(i.Fragment,{children:[i.jsx(Db,{options:t==null?void 0:t.suggestions,onPick:e.onSend}),i.jsx(wa,{ref:e.inputRef,className:"comms-input",value:e.draft,onValueChange:e.onDraft,onSubmit:e.onSend,disabled:!t,placeholder:t?"Answer":""})]})}function Bb(e){const{m:t}=e,n=li(),o=t.from==="human"?"human":"agent";return i.jsxs("div",{className:`msg from-${t.from} voice-${o}`,children:[i.jsx(V,{parts:[ps(t.author,n),Cx(t),ha(t.at)]}),i.jsx("div",{className:"msg-text",children:t.text}),e.stillOpen&&i.jsx("button",{className:"answer-this t-meta",onClick:e.onAnswerThis,children:"Answer this"})]})}function Fb(e){const{ticket:t}=e;return i.jsxs("div",{className:"comms-ticket",children:[i.jsxs("div",{className:"t-title",title:t&&`${t.key} ${t.title}`,children:[i.jsx("span",{className:"key",children:t==null?void 0:t.key})," ",t==null?void 0:t.title]}),i.jsx(V,{parts:[e.trail,e.agent]})]})}function Ub({id:e,text:t}){const[n,o]=y.useState(),a=n!==e;return i.jsx(ua,{size:.6,framed:!1,state:a?"speaking":"alert",speaking:a?t.slice(0,60):void 0,onSpeakEnd:()=>o(e),className:"q-avatar"})}function Wb(e){const{q:t}=e;return i.jsxs("div",{className:"msg open-q",children:[i.jsx(V,{parts:[t.agent,ha(t.at)]}),i.jsx(Ub,{id:e.chatId??t.id,text:t.text}),i.jsx("div",{className:"msg-text",children:t.text}),t.stakes&&i.jsx(V,{parts:[{text:t.stakes,strong:!0}]}),t.precedent&&i.jsx(V,{className:"open-q-precedent",parts:[t.precedent]})]})}function Hb(e){const{activity:t,sessionId:n}=e,[o,a]=y.useState(""),[l,d]=y.useState(),h=y.useRef(null),f=y.useRef(null),p=t.sessions.find(O=>O.id===n),v=t.chats.filter(O=>O.sessionId===n),k=oN(t.pending,n,l??e.questionId),w=new Set(t.pending.filter(O=>O.sessionId===n).map(O=>O.id)),j=v.find(O=>!!k&&O.questionId===k.id),N=v.filter(O=>O!==j),S=p?e.snaps[p.mapId]:void 0,I=p!=null&&p.ticketId?S==null?void 0:S.tickets.find(O=>O.id===p.ticketId):void 0;y.useEffect(()=>{const O=h.current;O==null||O.scrollTo({top:O.scrollHeight,behavior:"smooth"})},[N.length,k==null?void 0:k.id]),y.useEffect(()=>{var O;k&&!e.onBack&&((O=f.current)==null||O.focus({preventScroll:!0}))},[k==null?void 0:k.id,e.onBack]);const $=O=>{!k||!O.trim()||(e.onAnswer(k.id,O.trim()),a(""))},_=Kb(p,!!k);return i.jsxs("div",{className:`comms ${k?"asking":""}`,children:[i.jsx(At,{title:"HITL line",right:p?i.jsx("span",{className:`status ${k?"urgent":""}`,children:_}):void 0,children:e.onBack&&i.jsx("button",{className:"back",onClick:e.onBack,"aria-label":"Back to inbox",children:"‹ Inbox"})}),p?i.jsxs(i.Fragment,{children:[i.jsx(Fb,{ticket:I,trail:S==null?void 0:S.map.title,agent:p.agent}),i.jsx("div",{className:"comms-log",ref:h,children:N.map(O=>i.jsx(Bb,{m:O,stillOpen:!!O.questionId&&w.has(O.questionId),onAnswerThis:()=>d(O.questionId)},O.id))}),k&&i.jsx(Wb,{q:k,chatId:j==null?void 0:j.id}),i.jsx(zb,{pending:k,draft:o,onDraft:a,onSend:$,inputRef:f})]}):i.jsx(Ie,{children:"No conversation"})]})}function Kb(e,t){return e?t?"Your answer is needed":dn(e)?`${e.agent} is working…`:e.status==="done"?"Resolved · ticket closed":"Session ended":""}async function Vb(e){const[t,n]=e.ref.split("+"),o=await fetch(`${pe()}/workspaces/integration`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e.mapId,a:t,b:n})});return o.ok?void 0:(await o.json().catch(()=>({}))).error??`Adding failed (${o.status})`}function Gb({item:e}){const[t,n]=y.useState(!1),[o,a]=y.useState(),l=()=>{n(!0),a(void 0),Vb(e).then(a,d=>a(d.message)).finally(()=>n(!1))};return i.jsxs("div",{className:"att-action",children:[i.jsx(M,{size:"sm",className:"integration-add",disabled:t,onClick:l,children:t?"Adding…":"Add integration ticket"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}async function qb(e,t){const n=e.ref.slice(0,e.ref.lastIndexOf(":")),o=await fetch(`${pe()}/trackers/settings/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e.mapId,issueId:n,choice:t})});return o.ok?void 0:(await o.json().catch(()=>({}))).error??`Saving failed (${o.status})`}function Qb({item:e}){const[t,n]=y.useState(!1),[o,a]=y.useState(),l=d=>{n(!0),a(void 0),qb(e,d).then(a,h=>a(h.message)).finally(()=>n(!1))};return i.jsxs("div",{className:"att-action",children:[i.jsx(M,{size:"sm",disabled:t,onClick:()=>l("stricter"),children:"Keep stricter"}),i.jsx(M,{size:"sm",disabled:t,onClick:()=>l("as-is"),children:"Accept as is"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function Yb({item:e}){return e.kind==="integration"?i.jsx(Gb,{item:e}):e.kind==="tracker-settings"&&e.ref.includes(":")?i.jsx(Qb,{item:e}):null}const Jb=/(\S*\/\S*|#\d+)/g;function Xb({reasons:e}){return e.length?i.jsx("span",{className:"reason-line",children:e.map((t,n)=>i.jsxs("span",{children:[n>0&&i.jsx("span",{className:"sep",children:" · "}),t.split(Jb).map((o,a)=>a%2===1?i.jsx("span",{className:"t-code",children:o},a):o)]},t))}):null}const cv={question:"Question",approval:"Approve",blocked:"Blocked",flag:"PR / CI",stalled:"Stalled","hitl-ready":"Needs you",knowledge:"Field guide",brief:"Brief",policy:"Risk",reroute:"Reroute","reroute-suggested":"Reroute?",overlap:"Overlap",integration:"Integrate",guide:"Guide","guide-checks":"Approve",trust:"Approve",model:"Model",delivery:"Delivery","tracker-settings":"Settings",precedent:"Precedent","review-limit":"Review"},Zb={question:"questions",approval:"approvals",blocked:"blocked tickets",flag:"PR / CI flags",stalled:"stalled claims","hitl-ready":"tickets for you",knowledge:"field guide entries",brief:"briefs",policy:"risky changes",reroute:"reroutes","reroute-suggested":"suggested reroutes",overlap:"overlapping claims",integration:"clashing branches",guide:"guides to approve","guide-checks":"guide checks to approve",trust:"things to approve on this machine",model:"tickets waiting for a model",delivery:"connectors not delivering","tracker-settings":"settings changed in the tracker",precedent:"changes to what you decided","review-limit":"review queues full"},e$=[{minutes:30,label:"30 min"},{minutes:120,label:"2 hours"},{minutes:1440,label:"Tomorrow"}],t$=["blocked","flag","stalled","policy","reroute","overlap","integration","model"];function dv(e,t){return t||e.urgency==="blocking"?"urgent":t$.includes(e.kind)?"attention":"neutral"}const n$=[/^marked blocking$/,/^fyi\b/,/^soon\b/,/^waiting \d/,/^answer together/,/questions from /];function uv(e){return e.reasons.filter(t=>!n$.some(n=>n.test(t)))}function s$(e){const{item:t,snap:n}=e,o=n==null?void 0:n.tickets.find(h=>h.id===t.ticketId),a=t.kind==="question"&&t.agent?`${t.agent} asks`:cv[t.kind],l=[];t.urgency==="blocking"&&l.push({text:"Blocking",urgent:!0,className:"urgency-tag"}),l.push({text:a,strong:!0});const d=o&&i$(t.title,o);return d&&l.push(d),e.otherTrail&&l.push((n==null?void 0:n.map.title)??t.mapId),l}function i$(e,t){if(!e.includes(t.key))return e.includes(t.title)?{text:t.key,code:!0}:`${t.key} ${t.title}`}function r$(e){const[t,n]=y.useState(!1),o=a=>{n(!1),a()};return i.jsxs("span",{className:"snooze",children:[i.jsx("button",{type:"button",className:"snooze-btn","aria-expanded":t,"aria-label":`Later: ${e.title}`,onClick:()=>n(!t),children:"Later"}),t&&i.jsxs("span",{className:"snooze-menu",role:"menu",children:[e$.map(a=>i.jsx("button",{type:"button",role:"menuitem",onClick:()=>o(()=>e.onSnooze(a.minutes)),children:a.label},a.minutes)),e.canDismiss&&i.jsx("button",{type:"button",role:"menuitem",onClick:()=>o(e.onDismiss),children:"Set aside"})]})]})}const o$=15e3;function a$(e){const{item:t}=e,n=t.title.split(`
|
|
144
|
+
`)[0],o=uv(t),a=e.now-t.since<o$;return i.jsx(be,{as:"li",className:`att-item k-${t.kind} u-${t.urgency} ${e.selected?"sel":""} ${a?"incoming":""}`,edge:dv(t,e.interrupting),selected:e.selected,title:n,titleText:t.title,context:i.jsx(V,{parts:s$({item:t,snap:e.snap,otherTrail:e.otherTrail})}),detail:o.length>0&&i.jsx(Xb,{reasons:o}),detailText:o.join(`
|
|
145
|
+
`),trailing:hn(e.now-t.since),onOpen:e.onOpen,actions:i.jsx(r$,{title:t.title,canDismiss:e0(t),onSnooze:e.onSnooze,onDismiss:e.onDismiss}),below:i.jsx(Yb,{item:t})})}function l$(e){const t=[];for(const n of e){const o=t.at(-1);(o==null?void 0:o.key)===n.batchKey?o.items.push(n):t.push({key:n.batchKey,kind:n.kind,mapId:n.mapId,items:[n]})}return t}const c$={question:"inbox-list",approval:"inbox-list approvals"};function d$(e){const{batch:t}=e,n=t.items.length>1,o=t.kind==="question"?"answer together":"review together",a=[`${t.items.length} ${Zb[t.kind]}`,e.trail,o].filter(Boolean);return i.jsxs("div",{className:`att-batch ${n?"many":""}`,children:[n&&i.jsx("span",{className:"batch-head t-label",children:a.join(" · ")}),i.jsx("ul",{className:`att-list ${c$[t.kind]??""}`,children:e.children})]})}function Hm(e,t){e.ticketId?t.openTicket(e.mapId,e.ticketId):t.selectTrail(e.mapId)}const u$=new Set(["approval","blocked","policy","precedent","flag","stalled","hitl-ready","overlap","integration","model","tracker-settings"]);function hv(e,t){if(u$.has(e.kind))return Hm(e,t);switch(e.kind){case"question":return t.openQuestion(e.ref);case"knowledge":return t.openKnowledge();case"brief":return t.openBrief(e.mapId);case"reroute":case"reroute-suggested":return t.openReroute(e);case"guide":case"guide-checks":return t.openGuides();case"delivery":return t.openConnector(e.ref);case"trust":return t.openApprovals();default:return Hm(e,t)}}function h$(e){const t=Xt(1e3),{view:n}=e;if(!n.items.length)return i.jsx(Sn,{title:"Nothing waiting on you",hint:n.hidden?`${n.hidden} snoozed or set aside. They come back when the snooze ends.`:"When an agent needs your call, it lands here, most important first."});const o=Object.keys(e.snaps).length>1,a=h=>o&&h!==e.currentMapId,l=new Set(n.interrupting),d=h=>{var f;return(f=e.pending.find(p=>p.id===h))==null?void 0:f.sessionId};return i.jsx("div",{className:"attention-queue",children:l$(n.items).map(h=>{var f;return i.jsx(d$,{batch:h,trail:a(h.mapId)?(f=e.snaps[h.mapId])==null?void 0:f.map.title:void 0,children:h.items.map(p=>i.jsx(a$,{item:p,snap:e.snaps[p.mapId],otherTrail:a(p.mapId)&&h.items.length<2,selected:p.kind==="question"&&d(p.ref)===e.selected,interrupting:l.has(p.id),now:t,onOpen:()=>hv(p,e.handlers),onSnooze:v=>e.onSnooze(p.id,v),onDismiss:()=>e.onDismiss(p.id)},p.id))},h.key)})})}const Km={label:"Focus for 1 hour",change:{kind:"for",minutes:60}};function f$(e){switch(e.kind){case"manual":case"hours":return[{label:"End focus now",change:{kind:"end"},primary:!0}];case"paused":return[{label:"Resume quiet hours",change:{kind:"resume"},primary:!0},Km];case"off":return[{...Km,primary:!0},{label:"Focus for 3 hours",change:{kind:"for",minutes:180}}];default:return e}}const Vm=e=>ha(e).slice(0,5),m$=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function p$(e){const t=`${e.items.length} waiting on you`;return e.heldBack===0?`Nothing held back · ${t}`:`${m$(e.heldBack,"item")} would interrupt you · ${t}`}function Dc(e){const t=e.prefs.focus;return t?`Quiet hours ${t.from}–${t.to}`:"No quiet hours set"}const Gm=e=>`Items scoring ${e.policy.value.interrupt} or more interrupt you · ${e.items.length} waiting on you`;function g$(e){const t=e.focus;switch(t.kind){case"manual":case"hours":{const n=Vm(t.until),o=t.kind==="manual"?"Switched on here":Dc(e);return{word:"on",until:n,on:!0,title:`Focus is on until ${n}`,reason:o,detail:p$(e)}}case"paused":{const n=Vm(t.until),o=`Quiet hours paused until ${n}`;return{word:"paused",until:n,on:!1,title:o,reason:Dc(e),detail:Gm(e)}}case"off":return{word:"off",until:"",on:!1,title:"Focus is off",reason:Dc(e),detail:Gm(e)};default:return t}}const v$="Focus holds back interruptions: no browser notifications or Slack messages, even for urgent items. Nothing is answered or dropped: everything still waits in Waiting on you and the Slack digest. Quiet hours turn it on every day; you can also focus for a while or end it early. This stays on this machine.";function k$(e){const{view:t}=e,n=g$(t),o=t.focus.kind,a=i.jsxs("span",{className:Ge("focus-state",`focus-${o}`),children:[i.jsx("i",{className:"focus-dot","aria-hidden":"true"}),i.jsxs("span",{className:"focus-label",children:["Focus",i.jsxs("span",{className:"focus-word",children:[" ",n.word]})]}),n.until&&i.jsxs("span",{className:"focus-until",children:[i.jsx("span",{className:"sep",children:" · "}),i.jsx("span",{className:"focus-until-word",children:"until "}),n.until]})]});return i.jsx(ja,{className:"focus-menu",label:a,role:"dialog",tip:n.title,ariaLabel:n.title,children:l=>i.jsxs("div",{className:"focus-panel","aria-label":"Focus",children:[i.jsxs("div",{className:"focus-panel-head",children:[i.jsx("span",{className:"t-row-title",children:n.title}),i.jsx(ii,{text:v$})]}),i.jsx(V,{parts:[n.reason]}),i.jsx(V,{className:"focus-held",parts:[n.detail]}),i.jsxs("div",{className:"focus-panel-actions",children:[f$(t.focus).map(d=>i.jsx(M,{size:"sm",variant:d.primary?"primary":"default",onClick:()=>{l(),e.onChange(d.change)},children:d.label},d.label)),i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>{l(),e.onSettings()},children:"Quiet hours"})]})]})})}function y$(e){const{view:t}=e,n=t.interrupting.length;return i.jsxs("span",{className:"attention-head",children:[i.jsx(k$,{view:t,onChange:e.onFocus,onSettings:e.onSettings}),n>0&&i.jsxs("span",{className:"waiting-chip interrupting",title:`${n} need you now`,children:[i.jsx(oi,{variant:"alert",size:14}),i.jsx("b",{children:n}),i.jsx("span",{className:"wl",children:" need you now"})]})]})}const fv=`${pe()}/attention`,w$=250;async function zc(e,t,n){var l;const o=await fetch(`${fv}${e}`,{method:t,headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),a=await o.json().catch(()=>({}));if(!o.ok)throw new Error(((l=a.errors)==null?void 0:l.join("; "))??a.error??`HTTP ${o.status}`);return a}function mv(e){const[t,n]=y.useState(),[o,a]=y.useState(),[l]=y.useState(ni),d=y.useCallback(()=>{const p=l.start();fetch(fv).then(v=>v.ok?v.json():void 0).then(v=>v&&p()&&n(v)).catch(()=>{})},[l]);y.useEffect(()=>si("attention",p=>{l.pushed(),n(JSON.parse(p))}),[l]),y.useEffect(()=>vs(d),[d]),y.useEffect(()=>{const p=setTimeout(d,w$);return()=>clearTimeout(p)},[d,e]);const h=p=>p.then(()=>(a(void 0),d(),!0),v=>(a(v.message),!1)),f=(p,v)=>void zc(p,"POST",v).then(()=>(a(void 0),d()),k=>a(k.message));return{view:t,error:o,snooze:(p,v)=>f("/snooze",{id:p,minutes:v}),dismiss:p=>f("/dismiss",{id:p}),savePrefs:p=>h(zc("/prefs","PUT",p)),saveReviewLimit:p=>h(zc("/review-limit","PUT",{limit:p}))}}function x$(e){return e.prefs.channel!=="browser"?!1:typeof Notification<"u"&&Notification.permission==="granted"}function j$(e){const t=new Notification(`${Z.name} · needs you`,{body:e.title,tag:e.id});t.onclick=()=>{window.focus(),t.close()}}function S$(e){const t=y.useRef();y.useEffect(()=>{if(!e)return;const n=new Set(e.interrupting),o=t.current;if(t.current=n,!(!o||!x$(e)))for(const a of e.items)n.has(a.id)&&!o.has(a.id)&&j$(a)},[e])}function N$(e){const t=Xt(1e3);return e.items.length?i.jsx("ul",{className:"inbox-list approvals",children:e.items.map(n=>{var l;const o=n.kind!=="approve",a=n.mapId!==e.currentMapId?(l=e.snaps[n.mapId])==null?void 0:l.map.title:void 0;return i.jsx(be,{as:"li",edge:o?"attention":"neutral",title:`${o?"Decide":"Approve"}: ${n.title}`,context:i.jsx(V,{parts:[o?"Held":"Verified",{text:n.ticketKey,code:!0},a]}),detail:n.reason,detailText:n.reason,trailing:hn(t-n.at),onOpen:()=>e.onOpen(n.mapId,n.ticketId)},`${n.mapId}/${n.ticketId}`)})}):null}function qm({activity:e}){const t=Xt(1e3),n=sj(e);return i.jsxs("div",{className:"hitl-readout",children:[i.jsx(ln,{layout:"inline",label:"Oldest",value:n.oldestAt?Jt(t-n.oldestAt):"—",urgent:!!n.oldestAt&&t-n.oldestAt>6e4,title:"Oldest open question"}),i.jsx(ln,{layout:"inline",label:"Avg wait",value:n.avgWaitMs!==void 0?Jt(n.avgWaitMs):"—",title:`Average wait over ${n.answered} answered questions`}),i.jsx(ln,{layout:"inline",label:"Answered",value:n.answered})]})}function b$(e){const t=Xt(1e3);return e.items.length?i.jsx("ul",{className:"inbox-list",children:e.items.map(n=>{const o=e.snaps[n.mapId],a=o==null?void 0:o.tickets.find(h=>h.id===n.ticketId),l=n.mapId!==e.currentMapId?o==null?void 0:o.map.title:void 0,d=n.text.split(`
|
|
146
|
+
`)[0];return i.jsx(be,{as:"li",className:n.sessionId===e.selected?"sel":void 0,edge:n.urgency==="blocking"?"urgent":"neutral",selected:n.sessionId===e.selected,title:d,titleText:n.text,context:i.jsx(V,{parts:[n.urgency==="blocking"&&{text:"Blocking",urgent:!0},`${n.agent} asks`,a&&{text:a.key,code:!0},a==null?void 0:a.title,l]}),trailing:hn(t-n.at),onOpen:()=>e.onOpen(n.sessionId,n.ticketId)},n.id)})}):i.jsx(Sn,{title:"Nothing waiting on you",hint:"When an agent needs your call, its question lands here."})}const $$={pass:"Passed",fail:"Failed",error:"Could not run",interrupted:"Interrupted"},ar={off:"Off",checks:"Checks","checks+review":"Checks + review","checks+review+human":"Checks + review + you"},pv={off:"The agent saying “done” closes the ticket right away.",checks:"Your checks (tests, lint, typecheck…) run in the repo first. A failure goes back to the agent with the output.","checks+review":"After the checks pass, a different agent reviews the change. It is never the agent that did the work.","checks+review+human":"After checks and review, you approve it in the inbox before the ticket closes."},C$=e=>e.exitCode===0&&!e.timedOut&&!e.error;async function Qm(e){const t=await e.json().catch(()=>({}));if(!e.ok)throw new Error(t.error??`HTTP ${e.status}`);return t}const Mo=`${pe()}/verification`,fr={ticket:(e,t)=>fetch(`${Mo}/ticket?mapId=${encodeURIComponent(e)}&ticketId=${encodeURIComponent(t)}`).then(n=>n.ok?n.json():void 0,()=>{}),inbox:()=>fetch(`${Mo}/inbox`).then(e=>e.ok?e.json().then(t=>t.items):[],()=>[]),log:e=>fetch(`${Mo}/log?path=${encodeURIComponent(e)}`).then(t=>Qm(t)),act:e=>fetch(`${Mo}/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(t=>Qm(t))};function T$(e){const[t,n]=y.useState([]),o=Object.values(e).map(l=>l.tickets.map(d=>`${d.id}:${d.state}:${d.status??""}`).join()).join("|"),{reload:a}=Ye({version:o,load:fr.inbox,show:n});return y.useEffect(()=>ei.onEvidence(a),[a]),t}function E$(e,t){return{...e,items:e.items.filter(n=>!(n.kind==="brief"&&n.mapId===t))}}function A$(e){var h;const t=[...e.activity.pending].sort((f,p)=>f.at-p.at),n=T$(e.snaps),o=(h=e.attention)==null?void 0:h.view,a=o&&e.briefShown?E$(o,e.currentMapId):o,l=a?a.items.length:t.length+n.length,d=i.jsx(At,{hot:l>0,title:i.jsxs(i.Fragment,{children:[l>0&&i.jsx(oi,{variant:"alert",size:12}),"Waiting on you"]}),count:i.jsx(fs,{n:l,urgent:l>0,pop:!0},l)});return a&&e.attention&&e.handlers?i.jsxs("div",{className:"inbox-part",children:[d,i.jsx(qm,{activity:e.activity}),i.jsx(h$,{view:a,snaps:e.snaps,pending:e.activity.pending,currentMapId:e.currentMapId,selected:e.sessionId,handlers:e.handlers,onSnooze:e.attention.snooze,onDismiss:e.attention.dismiss})]}):i.jsxs("div",{className:"inbox-part",children:[d,i.jsx(qm,{activity:e.activity}),i.jsx(N$,{items:n,snaps:e.snaps,currentMapId:e.currentMapId,onOpen:e.onOpenTicket}),(t.length>0||!n.length)&&i.jsx(b$,{items:t,snaps:e.snaps,currentMapId:e.currentMapId,selected:e.sessionId,onOpen:e.onOpenQuestion})]})}function I$(e){const[t,n]=y.useState("list"),[o,a]=y.useState();y.useEffect(()=>{e.convRequest&&n("conv")},[e.convRequest]);const l=(v,k)=>{e.onOpen(v,k),n("conv")},d=v=>{const k=e.activity.pending.find(w=>w.id===v);k&&(a(k.id),l(k.sessionId,k.ticketId))},h=i.jsx(A$,{activity:e.activity,snaps:e.snaps,currentMapId:e.currentMapId,sessionId:e.sessionId,attention:e.attention,handlers:e.handlers&&{...e.handlers,openQuestion:d},briefShown:!!e.above,onOpenQuestion:l,onOpenTicket:e.onOpenTicket}),f=i.jsx(Hb,{activity:e.activity,snaps:e.snaps,sessionId:e.sessionId,questionId:o,onAnswer:e.onAnswer,onBack:e.layout==="stack"?()=>n("list"):void 0});if(e.layout==="stack")return i.jsx(Be,{className:"zone inbox stack",children:t==="conv"&&e.sessionId?f:i.jsxs("div",{className:"stack-scroll",children:[e.above,h,e.below]})});const p=!!e.activity.sessions.find(v=>v.id===e.sessionId);return i.jsxs(Be,{className:`zone inbox split ${p?"has-conv":""}`,style:{gridArea:"inbox"},children:[i.jsx(At,{className:"zone-title",icon:"mailbox",title:"Communication",info:"Where your agents reach you: everything waiting on you, ranked with the reasons why, the conversation with the agent that asked, and the tickets coming up next."}),e.above,h,p&&f,e.below]})}function R$(e){var h;const{snap:t}=e,n=t?ti(t.tickets,t.map.mode):new Map,o={claimed:0,frontier:1},a=((t==null?void 0:t.tickets)??[]).filter(f=>o[n.get(f.id)]!==void 0).sort((f,p)=>o[n.get(f.id)]-o[n.get(p.id)]),l=new Set(e.sessions.filter(Gg).map(f=>f.ticketId)),d=((h=e.selection)==null?void 0:h.kind)==="ticket"?e.selection.id:void 0;return i.jsxs("div",{className:"upnext",children:[i.jsx(At,{title:"Up next",count:i.jsx("span",{className:"n mono-label",children:a.length})}),!t&&i.jsx(Ie,{children:"Ready tickets show here"}),t&&!a.length&&i.jsx(Ie,{children:"Nothing ready"}),t&&a.length>0&&i.jsx("ul",{className:"ticket-list",children:a.map(f=>{const v={state:n.get(f.id),waiting:l.has(f.id),assignee:f.assignee,hitl:cr(f)==="hitl"},k=M$(v);return i.jsx("li",{className:`${d===f.id?"sel":""} st-${L$(v)}`,children:i.jsxs("button",{onClick:()=>e.onSelect({kind:"ticket",id:f.id}),children:[i.jsx("i",{className:"dot"}),i.jsx("span",{className:"key t-code",children:f.key}),i.jsx("span",{className:"ttl t-body",children:f.title}),i.jsx("span",{className:"st-text t-meta",children:k})]})},f.id)})})]})}function M$(e){if(e.waiting)return"waiting on you";if(e.state==="claimed")return e.assignee??"claimed";const t=Dg[e.state].toLowerCase();return e.hitl?`${t}, needs you`:t}function L$(e){return e.waiting?"waiting":e.state==="frontier"&&e.hitl?"attention":e.state}function O$(e){const{api:t,nav:n}=e;return i.jsx(I$,{activity:t.activity,snaps:t.allSnaps,currentMapId:t.mapId,sessionId:t.chatSession,layout:e.bp==="mobile"?"stack":"split",convRequest:n.convRequest,onOpen:n.openChat,onAnswer:t.actions.answer,onOpenTicket:n.openTicket,attention:e.attn.attention,handlers:e.attn.handlers,below:i.jsx(R$,{snap:t.snap,sessions:e.scoped.sessions,selection:t.selection,onSelect:n.select}),above:e.above})}function P$(e){return i.jsx(VN,{seed:e.seed,onClose:e.onClose,tracker:e.rt.adapter.label,onCreate:async t=>{const n=await v1(e.rt.adapter,t);return e.onCreated(n.id),n}})}function _$(e,t){const[n,o]=y.useState(!1);return{open:()=>o(!0),startOver:d=>void t.actions.setArchived(!0).then(()=>o(GN(d))),dialog:n&&i.jsx(P$,{rt:e,seed:typeof n=="object"?n:void 0,onClose:()=>o(!1),onCreated:d=>t.actions.selectMap(d)})}}const D$={gh:"your gh login",GITHUB_TOKEN:"GITHUB_TOKEN",GH_TOKEN:"GH_TOKEN",stored:"a saved token","signed-in":"your GitHub sign-in",LINEAR_API_KEY:"LINEAR_API_KEY"},Hd=e=>D$[e];function Kd(e){var t;return((t=e.account)==null?void 0:t.kind)==="user"?e.account.login:void 0}const Bc=e=>!!e.auth&&!!Kd(e);function gv(e,t){const n=Kd(e);return!e.auth||!n?void 0:`Will use ${t||"the repo you pick"} as ${n} (${Hd(e.auth)})`}function z$(e){if(!e.repo)return;const t=Kd(e),n=t?` as ${t}`:"",o=e.auth?`, using ${Hd(e.auth)}`:"";return`Connected to ${e.repo}${n}${o}`}function B$(e,t){if(!e.pushedAt)return;const n=Math.floor((t-Date.parse(e.pushedAt))/864e5);return n<1?"Pushed today":n<60?`Pushed ${n}d ago`:`Pushed ${Math.floor(n/30)}mo ago`}function F$(e){const{gh:t}=e;if(!t.auth)return null;const n=gv(t,e.repo);return i.jsxs("div",{className:"gh-identity",children:[n&&i.jsx("span",{className:"t-body",children:n}),i.jsxs("span",{className:"gh-identity-actions",children:[i.jsx("button",{type:"button",className:"btn ghost sm",onClick:e.onUseAnother,children:"Use another token"}),t.auth==="signed-in"&&i.jsx("button",{type:"button",className:"btn ghost sm",onClick:e.onSignOut,title:"Forgets the token on this machine. To revoke it, remove Teamtrail under GitHub → Settings → Applications.",children:"Sign out"})]})]})}const U$=/^[\w.-]+\/[\w.-]+$/;function W$(e){const t=e.query.trim().toLowerCase(),o=!!e.detected&&e.repos.every(f=>f.fullName!==e.detected)?[{fullName:e.detected,private:!1},...e.repos]:e.repos,a=[...o.filter(f=>f.fullName===e.detected),...o.filter(f=>f.fullName!==e.detected)],l=t?a.filter(f=>f.fullName.toLowerCase().includes(t)):a,h=U$.test(e.query.trim())&&l.every(f=>f.fullName.toLowerCase()!==t)?e.query.trim():void 0;return{shown:l.slice(0,e.limit),matches:l.length,typed:h}}function Ym(e){const{repo:t,listed:n}=e,o=t.private?"Private":"Public";return i.jsx(be,{as:"li",className:"repo-row",selected:e.selected,title:i.jsx("span",{className:"t-code",children:t.fullName}),context:i.jsx(V,{parts:[e.detected&&{text:"This project's repo",strong:!0},n&&o,n&&B$(t,e.now),!n&&"Checked when you connect"]}),onOpen:e.onPick})}const H$=40;function Jm(e){const[t,n]=y.useState(""),o=y.useMemo(()=>Date.now(),[]),a=y.useMemo(()=>new Set(e.repos.map(v=>v.fullName)),[e.repos]),{shown:l,matches:d,typed:h}=W$({repos:e.repos,detected:e.detected,query:t,limit:H$}),f=d>l.length?`${d-l.length} more: type to narrow`:"",p=e.truncated?`Your ${e.repos.length} most recently pushed repos`:"";return i.jsxs("div",{className:"repo-picker",children:[i.jsxs("label",{className:"field",children:["Repository",i.jsx("input",{value:t,placeholder:"Search your repos, or type owner/name",spellCheck:!1,"aria-label":"Search repositories",onChange:v=>n(v.target.value)})]}),i.jsxs("ul",{className:"repo-list","aria-label":"Repositories",children:[h&&i.jsx(Ym,{repo:{fullName:h,private:!1},detected:h===e.detected,listed:!1,selected:h===e.value,now:o,onPick:()=>e.onChange(h)}),l.map(v=>i.jsx(Ym,{repo:v,detected:v.fullName===e.detected,listed:a.has(v.fullName),selected:v.fullName===e.value,now:o,onPick:()=>e.onChange(v.fullName)},v.fullName))]}),i.jsx(V,{parts:[!d&&!h&&"No repo matches",f,p]})]})}function K$(e){const{list:t}=e;if(!t)return i.jsx(ri,{label:"Loading your repos…",rows:3,className:"picker-loading"});switch(t.kind){case"ok":return i.jsx(Jm,{repos:t.repos,truncated:t.truncated,detected:t.detectedRepo??e.detected,value:e.value,onChange:e.onChange});case"no-token":return i.jsx(V,{parts:["No GitHub token found"]});case"error":return i.jsxs(i.Fragment,{children:[i.jsx(Bd,{what:"Couldn't list your repos",reason:t.error,onRetry:e.onRetry}),i.jsx(Jm,{repos:[],truncated:!1,detected:e.detected,value:e.value,onChange:e.onChange})]});default:return t}}const V$={stored:"Saved token",gh:"gh CLI",GITHUB_TOKEN:"$GITHUB_TOKEN",GH_TOKEN:"$GH_TOKEN","signed-in":"Signed in with GitHub",LINEAR_API_KEY:"$LINEAR_API_KEY"},nr=e=>e==="github"||e==="linear";function vv(e){const[t,n]=y.useState(!e.source);return e.source&&!t?i.jsxs("div",{className:"ts-auth",children:[i.jsx("span",{className:"mono-label",children:e.label}),i.jsx("span",{className:"pill on",children:V$[e.source]}),i.jsx("button",{type:"button",className:"btn ghost sm",onClick:()=>n(!0),children:"Use another"})]}):i.jsxs("label",{className:"field",children:[i.jsxs("span",{className:"ts-label",children:[e.label,e.link&&i.jsx("a",{href:e.link.href,target:"_blank",rel:"noreferrer",children:e.link.text})]}),i.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,value:e.value,placeholder:e.placeholder,onChange:o=>e.onChange(o.target.value)})]})}function G$(e){const[t,n]=y.useState(!1),o=()=>{var a;return void((a=navigator.clipboard)==null?void 0:a.writeText(e.code).then(()=>n(!0),()=>{}))};return i.jsxs("div",{className:"gh-device",children:[i.jsx("span",{className:"t-label",children:"Enter this code on GitHub"}),i.jsxs("div",{className:"gh-device-row",children:[i.jsx("code",{className:"gh-device-code t-code","aria-label":"Your code",children:e.code}),i.jsx(M,{size:"sm",variant:"ghost",onClick:o,children:t?"Copied":"Copy"})]}),i.jsxs("div",{className:"gh-device-row",children:[i.jsx("a",{className:"btn primary",href:Nn(e.href),target:"_blank",rel:"noreferrer",onClick:o,children:"Open GitHub"}),i.jsx(M,{size:"sm",variant:"ghost",onClick:e.onCancel,children:"Cancel"})]}),i.jsx(ri,{label:"Waiting for you to approve on GitHub…"})]})}function q$(e){switch(e.kind){case"code":return{kind:"code",userCode:e.userCode,verificationUri:e.verificationUri,interval:e.interval,asked:0};case"unavailable":return{kind:"ended",reason:"Sign in with GitHub isn’t set up in this build"};case"error":return{kind:"ended",reason:e.error};default:return e}}function Q$(e,t){switch(t.kind){case"waiting":return{...e,interval:t.interval,asked:e.asked+1};case"signed-in":return{kind:"idle"};case"expired":return{kind:"ended",reason:"The code expired before it was approved"};case"denied":return{kind:"ended",reason:"The sign-in was declined on GitHub"};case"none":return{kind:"ended",reason:"The sign-in was stopped"};case"error":return{kind:"ended",reason:t.error};default:return t}}const Bt=M0(pe());function sr(e,t){e({tracker:t});const n=new URL(location.href);n.searchParams.delete("tracker"),location.href=n.toString()}function Y$(e){const[t,n]=y.useState({kind:"idle"}),o=y.useRef(e);o.current=e;const a=t.kind==="code";return y.useEffect(()=>{if(t.kind!=="code")return;let l=!0;const d=setTimeout(()=>void Bt.githubSignIn.poll().then(async h=>{l&&(h.kind==="signed-in"&&await o.current(),l&&n(Q$(t,h)))},h=>l&&n({kind:"ended",reason:h.message})),Math.max(t.interval,1)*1e3);return()=>{l=!1,clearTimeout(d)}},[t]),y.useEffect(()=>{if(a)return()=>void Bt.githubSignIn.cancel().catch(()=>{})},[a]),{state:t,start(){n({kind:"starting"}),Bt.githubSignIn.start().then(l=>n(q$(l)),l=>n({kind:"ended",reason:l.message}))},cancel(){n({kind:"idle"})}}}function J$(e){const{state:t,start:n,cancel:o}=Y$(e.onSignedIn);switch(t.kind){case"idle":return i.jsxs("div",{className:"gh-sign-in",children:[i.jsx(M,{variant:"primary",onClick:n,children:"Sign in with GitHub"}),i.jsx(V,{parts:["No gh login or token needed","the token stays on this machine"]}),i.jsx(V,{parts:["GitHub asks for access to your repos: it has no narrower scope for issues in private repos"]})]});case"starting":return i.jsx(ri,{label:"Asking GitHub for a code…"});case"code":return i.jsx(G$,{code:t.userCode,href:t.verificationUri,onCancel:o});case"ended":return i.jsxs("div",{className:"gh-sign-in",children:[i.jsx(M,{onClick:n,children:"Try again"}),i.jsx(V,{parts:["Didn't sign in",t.reason]})]});default:return t}}function X$(e){var d,h;const{gh:t}=e,n=t.auth&&((d=t.account)==null?void 0:d.kind)==="unknown"?`Found ${Hd(t.auth)}, but GitHub didn't accept it`:"",o=((h=t.account)==null?void 0:h.kind)==="unknown"?t.account.error:"",a=t.auth==="GITHUB_TOKEN"||t.auth==="GH_TOKEN",l=t.signIn.available&&!a;return i.jsxs(i.Fragment,{children:[n&&i.jsx(V,{parts:[n,o]}),l&&i.jsx(J$,{onSignedIn:e.onSignedIn}),l&&i.jsx("span",{className:"t-label gh-or",children:"Or paste a token"}),i.jsx(vv,{source:null,value:e.token,onChange:e.onToken,label:"Token",placeholder:"ghp_… or github_pat_…",link:{href:"https://github.com/settings/personal-access-tokens/new",text:"New token"}}),i.jsxs("span",{className:"t-meta",children:["Or run ",i.jsx("code",{className:"t-code",children:"gh auth login"})," in a terminal; this finds it in a few seconds."]}),i.jsxs("label",{className:"field",children:["Repository",i.jsx("input",{value:e.repo,placeholder:"owner/name",spellCheck:!1,onChange:f=>e.onRepo(f.target.value.trim())})]})]})}function kv({r:e}){var o,a;if(!e)return null;if(!e.ok)return i.jsxs("div",{className:"test-line alert",children:["✕ ",e.error]});const t=(o=e.rate)!=null&&o.limit?`${(a=e.rate.remaining)==null?void 0:a.toLocaleString()}/${e.rate.limit.toLocaleString()} req`:"";let n="";return e.canWrite===!1?n="read-only":e.canWrite&&(n="read/write"),i.jsxs("div",{className:"test-line ok",children:["✓ ",[e.account,e.target,n,t].filter(Boolean).join(" · ")]})}function Vd(e){const[t,n]=y.useState(),[o,a]=y.useState(0);y.useEffect(()=>{if(n(void 0),!e.enabled)return;let d=!0;return e.load().then(h=>d&&n(h),h=>d&&n(e.failed(h.message))),()=>{d=!1}},[e.enabled,e.key,o]);const l=y.useCallback(()=>a(d=>d+1),[]);return{value:t,retry:l}}function Z$(e){const{value:t,retry:n}=Vd({enabled:e.enabled,key:e.auth??"",load:()=>Bt.githubRepos(),failed:o=>({kind:"error",error:o})});return{list:t,retry:n}}function yv(e){const t=e.s.github,n=Bc(t),[o,a]=y.useState(!n),[l,d]=y.useState(t.repo??t.detectedRepo??""),[h,f]=y.useState(""),[p,v]=y.useState(),[k,w]=y.useState(!1),{list:j,retry:N}=Z$({enabled:!o,auth:t.auth});y.useEffect(()=>{n&&!h&&a(!1)},[n]);const S=async()=>{w(!0),v(void 0);try{await Bt.connect({active:"github",github:{repo:l,token:o?h:void 0}}),e.onConnected()}catch(D){v({ok:!1,error:D.message}),w(!1)}},I=async()=>{const D=await e.reload();D&&Bc(D.github)&&a(!1)},$=async()=>{await Bt.githubSignIn.signOut().catch(()=>{});const D=await e.reload();a(!D||!Bc(D.github))},O=!!l&&!(!o&&!j)&&(!o||!!h||n);return i.jsxs("div",{className:"card inset tracker-setup",children:[o?i.jsx(X$,{gh:t,token:h,onToken:f,repo:l,onRepo:d,onSignedIn:I}):i.jsxs(i.Fragment,{children:[i.jsx(F$,{gh:t,repo:l,onUseAnother:()=>a(!0),onSignOut:()=>void $()}),i.jsx(K$,{list:j,detected:t.detectedRepo,value:l,onChange:d,onRetry:N})]}),i.jsx(kv,{r:p}),i.jsx("footer",{children:i.jsx("button",{type:"button",className:"btn primary",disabled:k||!O,onClick:()=>void S(),children:k?"Connecting…":"Connect"})})]})}function eC(e){return e.line?i.jsxs("div",{className:"gh-identity",children:[i.jsxs("div",{className:"ln-who",children:[i.jsx("span",{className:"t-body",children:e.line}),e.email&&i.jsx(V,{parts:[e.email]})]}),e.onUseAnother&&i.jsx("button",{type:"button",className:"btn ghost sm",onClick:e.onUseAnother,children:"Use another key"})]}):null}const tC={LINEAR_API_KEY:"LINEAR_API_KEY",stored:"a saved key"},Gd=e=>tC[e]??e;function $a(e){return(e==null?void 0:e.kind)==="user"?e:void 0}const nC=e=>!!e.auth&&!!$a(e.viewer);function wv(e,t){if(e)return t?`${e} / ${t}`:e}function xv(e){const t=$a(e.viewer);if(!t)return;const n=wv(e.team,e.project)??"the team you pick",o=e.source?` (${Gd(e.source)})`:"";return`Will use ${n} in ${t.orgName} as ${t.name}${o}`}function sC(e){const t=wv(e.teamName??e.teamKey,e.projectName);if(!e.teamId||!t)return;const n=$a(e.viewer),o=e.orgName??(n==null?void 0:n.orgName),a=o?` in ${o}`:"",l=n?` as ${n.name}`:"",d=e.auth?`, using ${Gd(e.auth)}`:"";return`Connected to ${t}${a}${l}${d}`}function iC(e,t){if(!e.activeAt)return"No issues yet";const n=Math.floor((t-Date.parse(e.activeAt))/864e5);return n<1?"Active today":n<60?`Active ${n}d ago`:`Active ${Math.floor(n/30)}mo ago`}function rC(e){var a,l;const{ln:t}=e,n=t.auth&&((a=t.viewer)==null?void 0:a.kind)==="unknown"?`Found ${Gd(t.auth)}, but Linear didn't accept it`:"",o=((l=t.viewer)==null?void 0:l.kind)==="unknown"?t.viewer.error:"";return i.jsxs(i.Fragment,{children:[n&&i.jsx(V,{parts:[n,o]}),i.jsx(vv,{source:null,value:e.apiKey,onChange:e.onKey,label:"API key",placeholder:"lin_api_…",link:{href:"https://linear.app/settings/account/security",text:"New key"}}),i.jsxs("span",{className:"t-meta",children:["Or set ",i.jsx("code",{className:"t-code",children:"LINEAR_API_KEY"})," before starting Teamtrail."]})]})}function oC(e){const{list:t}=e;if(!t)return i.jsx(ri,{label:"Loading projects…"});if(t.kind==="error")return i.jsx(Bd,{what:"Couldn't list the team's projects",reason:t.error,onRetry:e.onRetry});if(t.kind!=="ok"||!t.projects.length)return null;const n=[{value:"",label:"All projects"},...t.projects.map(o=>({value:o.id,label:o.state?`${o.name} · ${o.state}`:o.name}))];return i.jsxs("label",{className:"field",children:["Project (optional)",i.jsx(at,{"aria-label":"Project",value:e.value,onChange:e.onChange,options:n})]})}function aC(e){const t=e.query.trim().toLowerCase(),n=t?e.teams.filter(o=>o.key.toLowerCase().includes(t)||o.name.toLowerCase().includes(t)):e.teams;return{shown:n.slice(0,e.limit),matches:n.length}}function lC(e,t){return t&&e.some(n=>n.id===t)?t:e.length===1?e[0].id:void 0}function cC(e){const{team:t}=e;return i.jsx(be,{as:"li",className:"repo-row team-row",selected:e.selected,title:t.name,context:i.jsx(V,{parts:[{text:t.key,code:!0},iC(t,e.now)]}),onOpen:e.onPick})}const dC=40;function uC(e){const[t,n]=y.useState(""),o=y.useMemo(()=>Date.now(),[]),{shown:a,matches:l}=aC({teams:e.teams,query:t,limit:dC}),d=l>a.length?`${l-a.length} more: type to narrow`:"",h=e.truncated?`The first ${e.teams.length} teams`:"",f=e.value?"":"Pick the team your trails go in";return i.jsxs("div",{className:"repo-picker",children:[i.jsxs("label",{className:"field",children:["Team",i.jsx("input",{value:t,placeholder:"Search your teams by key or name",spellCheck:!1,"aria-label":"Search teams",onChange:p=>n(p.target.value)})]}),i.jsx("ul",{className:"repo-list","aria-label":"Teams",children:a.map(p=>i.jsx(cC,{team:p,selected:p.id===e.value,now:o,onPick:()=>e.onChange(p.id)},p.id))}),i.jsx(V,{parts:[!l&&"No team matches",f,d,h]})]})}function hC(e){const{list:t}=e;if(!t)return i.jsx(ri,{label:"Loading teams…",rows:3,className:"picker-loading"});switch(t.kind){case"ok":return i.jsx(uC,{teams:t.teams,truncated:t.truncated,value:e.value,onChange:e.onChange});case"no-key":return i.jsx(V,{parts:["Paste a Linear API key to list your teams"]});case"error":return i.jsx(Bd,{what:"Couldn't list your teams",reason:t.error,onRetry:e.onRetry});default:return t}}function fC(e,t){const[n,o]=y.useState(e);return y.useEffect(()=>{const a=setTimeout(()=>o(e),t);return()=>clearTimeout(a)},[e,t]),n}function mC(e){const{value:t,retry:n}=Vd({enabled:e.enabled&&!!e.teamId,key:`${e.teamId}
|
|
147
|
+
${e.apiKey??""}`,load:()=>Bt.linearProjects(e.teamId,e.apiKey),failed:o=>({kind:"error",error:o})});return{list:t,retry:n}}function pC(e){const{value:t,retry:n}=Vd({enabled:e.enabled,key:e.apiKey??"",load:()=>Bt.linearTeams(e.apiKey),failed:o=>({kind:"error",error:o})});return{list:t,retry:n}}function gC(e){const t=fC(e.apiKey.trim(),400),n=e.paste&&t?t:void 0,o=e.paste?!!t:!!e.ln.auth,a=pC({enabled:o,apiKey:n}),l=mC({teamId:e.teamId,apiKey:n,enabled:o}),d=a.list,h=l.list,f=(d==null?void 0:d.kind)==="ok"?d.teams:[],p=o&&!d,v=o&&!!e.teamId&&!h;return{enabled:o,list:d,teams:f,projects:h,loading:p||v,retryTeams:a.retry,retryProjects:l.retry}}function jv(e){var ne;const t=e.s.linear,n=nC(t),[o,a]=y.useState(!n),[l,d]=y.useState(""),[h,f]=y.useState(t.teamId??""),[p,v]=y.useState(t.projectId??""),[k,w]=y.useState(),[j,N]=y.useState(!1),{enabled:S,list:I,teams:$,projects:_,loading:O,retryTeams:D,retryProjects:q}=gC({ln:t,paste:o,apiKey:l,teamId:h});y.useEffect(()=>{n&&!l&&a(!1)},[n]),y.useEffect(()=>{(I==null?void 0:I.kind)==="ok"&&f(lC(I.teams,t.teamId)??"")},[I]);const H=$.find(ce=>ce.id===h),G=(_==null?void 0:_.kind)==="ok"?_.projects.find(ce=>ce.id===p):void 0,oe=(I==null?void 0:I.kind)==="ok"?I.viewer:t.viewer,Q=o?null:t.auth,ke=xv({viewer:oe,team:H==null?void 0:H.name,project:G==null?void 0:G.name,source:Q}),Oe=async()=>{if(H){N(!0),w(void 0);try{await Bt.connect({active:"linear",linear:{teamId:H.id,teamKey:H.key,teamName:H.name,projectId:G==null?void 0:G.id,projectName:G==null?void 0:G.name,apiKey:o?l.trim():void 0}}),e.onConnected()}catch(ce){w({ok:!1,error:ce.message}),N(!1)}}},Te=ce=>{f(ce),v("")};return i.jsxs("div",{className:"card inset tracker-setup linear-setup",children:[o&&i.jsx(rC,{ln:t,apiKey:l,onKey:d}),i.jsx(eC,{line:ke,email:(ne=$a(oe))==null?void 0:ne.email,onUseAnother:o?void 0:()=>a(!0)}),S&&i.jsx(hC,{list:I,value:h,onChange:Te,onRetry:D}),H&&i.jsx(oC,{list:_,value:p,onChange:v,onRetry:q}),i.jsx(kv,{r:k}),i.jsx("footer",{children:i.jsx("button",{type:"button",className:"btn primary",disabled:j||O||!H,onClick:()=>void Oe(),children:j?"Connecting…":"Connect"})})]})}function vC(e){return i.jsxs("div",{className:"c-actions",children:[e.canSwitch&&i.jsx("button",{className:"btn sm",disabled:!e.usable,onClick:e.onSwitch,children:"Switch"}),e.remote&&i.jsx("button",{className:`btn sm ${e.open?"on":""}`,disabled:!e.usable,onClick:e.onToggle,children:e.configured?"Edit":"Connect"})]})}function kC(e){return["Anything this account writes counts as you, including agents signed in as you",`${e==="github"?"people with write access":"members (not guests)"} can claim, move and close tickets; their decisions show under their name`,"settings they change wait for you in the queue, to accept or keep stricter"]}function yC(e){const{id:t,active:n,s:o}=e,a=nr(t),l=n&&o?wC(t,o):void 0;return l&&a?i.jsxs(i.Fragment,{children:[i.jsx(V,{className:"c-who",parts:[l]}),i.jsx(V,{className:"c-trust",parts:kC(t)})]}):l?i.jsx(V,{className:"c-who",parts:[l]}):n&&(t==="markdown"||a)?i.jsx("div",{className:"c-loc",children:e.location}):a&&e.configured&&o?i.jsx("div",{className:"c-loc",children:xC(t,o)}):null}function wC(e,t){if(e==="github")return z$(t.github);if(e==="linear")return sC(t.linear)}function xC(e,t){return e==="github"?t.github.repo:[t.linear.teamKey,t.linear.projectName].filter(Boolean).join(" · ")}function jC({status:e}){var l,d;if(!e)return null;const t=(l=e.rate)!=null&&l.limit?`${((d=e.rate.remaining)==null?void 0:d.toLocaleString())??"?"}/${e.rate.limit.toLocaleString()} req`:"",n=e.queued?` · ${e.queued} queued`:"",[o,a]=SC(e,n);return i.jsxs("div",{className:`sync-line ${o}`,title:e.error,children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:a}),t&&i.jsx("span",{className:"rate",children:t})]})}function SC(e,t){switch(e.state){case"online":return["ok",`Online · synced ${_g(e.lastSyncAt)}${t}`];case"offline":return["warn",`Offline${t}`];case"rate-limited":return["warn",`Rate limited · resumes ${hr(e.resetAt)}${t}`];case"auth-error":return["alert",`Credentials rejected${t}`];default:return["",`Connecting${t}`]}}function NC(e){const{id:t,active:n,configured:o,s:a}=e,l=nr(t),d=!l||!!a,h=["card connector",n?"active":"",d?"":"disabled",e.open?"open":""];return i.jsxs("div",{className:h.join(" "),children:[i.jsxs("div",{className:"card-row",children:[i.jsx("b",{className:"choice-title t-row-title",children:e.name}),n&&i.jsx("span",{className:"pill on",children:"Active"})]}),i.jsx(yC,{id:t,active:n,configured:o,location:e.location,s:a}),l&&n&&i.jsx(jC,{status:a==null?void 0:a[t].status}),i.jsx(vC,{canSwitch:!n&&(!l||o),remote:l,usable:d,configured:o,open:e.open,onSwitch:e.onSwitch,onToggle:e.onToggle})]})}function Sv(e=0){const[t,n]=y.useState(),o=y.useCallback(()=>Bt.get().then(a=>(n(a),a),()=>(n(null),void 0)),[]);return y.useEffect(()=>{if(o(),!e)return;const a=setInterval(()=>void o(),e);return()=>clearInterval(a)},[o,e]),[t,n,o]}function bC(e){const[t,,n]=Sv(5e3),[o,a]=y.useState(null),l=async h=>{t&&(h==="markdown"||nr(h))&&await Bt.connect({active:h==="markdown"?"markdown":h,...h==="github"&&t.github.repo?{github:{repo:t.github.repo}}:{},...h==="linear"&&t.linear.teamId?{linear:{teamId:t.linear.teamId,teamKey:t.linear.teamKey,teamName:t.linear.teamName,projectId:t.linear.projectId,projectName:t.linear.projectName}}:{}}).catch(()=>{}),sr(e.update,h)},d=y.useMemo(()=>({github:!!(t!=null&&t.github.repo),linear:!!(t!=null&&t.linear.teamId)}),[t]);return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"connectors",children:L0.map(h=>{const f=h.id;return i.jsx(NC,{id:f,name:h.name,active:f===e.activeTracker,configured:nr(f)&&d[f],open:o===f,location:e.location,s:t,onSwitch:()=>void l(f),onToggle:()=>nr(f)&&a(o===f?null:f)},h.id)})}),t&&o==="github"&&i.jsx(yv,{s:t,reload:n,onConnected:()=>sr(e.update,"github")}),t&&o==="linear"&&i.jsx(jv,{s:t,onConnected:()=>sr(e.update,"linear")})]})}function $C(e,t){const n=e==null?void 0:e.github,o=e==null?void 0:e.linear,a=n&&t!=="github"?gv(n,n.repo??n.detectedRepo):void 0,l=o&&t!=="linear"?xv({viewer:o.viewer,team:o.teamName,project:o.projectName,source:o.auth}):void 0;return[{id:"markdown",title:"Local markdown",sub:"Files in .teamtrail/ in this repo"},{id:"github",title:"GitHub Issues",sub:a??"Trails as labelled issues in your repo"},{id:"linear",title:"Linear",sub:l??"Trails and tickets in your Linear team"}]}function Ee(e){return i.jsxs("section",{className:"set-sec",children:[i.jsx(ze,{as:"h4",children:e.title}),e.children]})}function Nv(e){const t=[{v:"summary",title:"Summary"},{v:"full",title:"Full transcript"}];return i.jsx("div",{className:"choice-row",children:t.map(n=>i.jsx(ot,{on:e.value===n.v,title:n.title,onClick:()=>e.onChange(n.v)},n.v))})}const CC={github:"Checking for a GitHub login…",linear:"Checking for a Linear key…"};function TC(e){var I;const{prefs:t,update:n}=e,[o,,a]=Sv(5e3),[l,d]=y.useState(!1),h=(I=o==null?void 0:o.pending)==null?void 0:I.target.split(":")[0],[f,p]=y.useState(!1);y.useEffect(()=>{h&&!f&&t.tracker!==h&&n({tracker:h})},[h,f,t.tracker,n]);const v=$C(o??void 0,t.tracker),k=t.tracker==="github"||t.tracker==="linear",w=k&&(o==null?void 0:o.active)===t.tracker,j=k&&!w,N=$=>{n({onboarded:!0}),sr(n,$)},S=async()=>{d(!0);const $=o&&!o.pending;t.tracker==="markdown"&&$&&await Bt.connect({active:"markdown"}).catch(()=>{}),n({onboarded:!0}),t.tracker!==e.activeTracker&&sr(n,t.tracker)};return i.jsx("div",{className:"scrim",children:i.jsxs(Be,{as:"div",className:"dialog onboarding",children:[i.jsx("div",{className:"onb-brand",children:i.jsx(xa,{className:"onb-title"})}),i.jsxs("h2",{className:"onb-question t-heading",children:[i.jsx(xN,{className:"voice-badge",size:22}),"Where should your trails live?"]}),i.jsxs(Ee,{title:"Tracker",children:[i.jsx("div",{className:"choice-row",children:v.map($=>i.jsx(ot,{on:t.tracker===$.id,title:$.title,sub:$.sub,onClick:()=>(p(!0),n({tracker:$.id}))},$.id))}),(o==null?void 0:o.pending)&&i.jsxs("p",{className:"t-meta onb-repo-tracker",children:["This repo keeps its trails in ",o.pending.label,". Connect it here, or keep local files on this machine; the team's choice in the repo isn't changed either way."]}),o===void 0&&k&&i.jsx(ri,{label:CC[t.tracker]??"Checking…"}),o&&t.tracker==="github"&&!w&&i.jsx(yv,{s:o,reload:a,onConnected:()=>N("github")}),o&&t.tracker==="linear"&&!w&&i.jsx(jv,{s:o,onConnected:()=>N("linear")})]}),i.jsx(Ee,{title:"HITL transcript",children:i.jsx(Nv,{value:t.hitlTranscript,onChange:$=>n({hitlTranscript:$})})}),i.jsx("footer",{children:i.jsx(M,{variant:"primary",disabled:l||j,onClick:()=>void S(),children:"Get started"})})]})})}function EC(e){var t;return(t=ft())!=null&&t.tracker?null:i.jsx(TC,{...e})}const lr=[{id:"trail",label:"This trail",intro:"How agents work on the trail on screen: its mode, the checks that prove work done, models and guides.",sections:[{id:"mode",title:"Trail mode"},{id:"verification",title:"Verification"},{id:"models",title:"Model matching"},{id:"team",title:"Team"}]},{id:"project",label:"Project",intro:"Where this repo keeps its trails, and the rules every agent working in it follows.",sections:[{id:"approvals",title:"Approvals"},{id:"tracker",title:"Tracker"},{id:"workspaces",title:"Workspaces"},{id:"proof",title:"Proof on pull requests"},{id:"remote-agents",title:"Remote agents"},{id:"policy",title:"Risk policy"},{id:"guides",title:"Guides"},{id:"labels",title:"Labels"}]},{id:"alerts",label:"Attention & alerts",intro:"What interrupts you, where questions reach you, and what Scout tells you when you come back.",sections:[{id:"attention",title:"Attention"},{id:"slack",title:"Slack"},{id:"trip-report",title:"Trip report"}]},{id:"you",label:"You",intro:"How the Lookout looks and reads for you, and the browsers and devices signed in to it.",sections:[{id:"appearance",title:"Appearance"},{id:"transcript",title:"HITL transcript"},{id:"agent",title:"Agent"},{id:"devices",title:"Browsers & devices"}]},{id:"projects",label:"All projects",intro:"Every repo this Lookout knows, so you can switch between them from the header.",sections:[{id:"projects",title:"Projects"}]},{id:"about",label:"About",intro:"What Teamtrail is, and what changed in each release.",sections:[{id:"changelog",title:"Changelog"}]}];function bv(e){if(e===null)return null;const t=lr.find(a=>a.id===e);if(t)return{group:t.id};const n=lr.find(a=>a.sections.some(l=>l.id===e));if(!n)return{};const o=n.sections.find(a=>a.id===e);return{group:n.id,section:o==null?void 0:o.id}}function AC(){return i.jsxs("p",{className:"sp-elsewhere t-meta",role:"note",children:["You're looking at this Lookout from another device. You can read, answer and approve from here. What changes what runs on the machine ",Z.name," runs on, or whom it trusts, is set there: the approvals of what the repo asks it to trust, the tracker connection, Slack, the risk policy, verification levels, workspaces, guides, remote agents, your attention settings and the projects list. Paths on that machine and its tracker account are not shown here."]})}const Xm={from:"18:00",to:"09:00"};function IC(e){const t=e.focus!==void 0,n=e.focus??Xm;return i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Quiet hours"}),i.jsx(M,{size:"sm",on:t,"aria-pressed":t,onClick:()=>e.onChange(t?void 0:Xm),children:t?"On":"Off"}),t&&i.jsxs(i.Fragment,{children:[i.jsx("input",{type:"time","aria-label":"Quiet from",value:n.from,onChange:o=>o.target.value&&e.onChange({...n,from:o.target.value})}),i.jsx("span",{className:"t-meta",children:"to"}),i.jsx("input",{type:"time","aria-label":"Quiet until",value:n.to,onChange:o=>o.target.value&&e.onChange({...n,to:o.target.value})})]})]})}const Fc=[3,5,8,12];function RC(e){const t=e&&!Fc.includes(e)?[...Fc,e].sort((n,o)=>n-o):Fc;return[{value:"off",label:"Off"},...t.map(n=>({value:String(n),label:`${n} waiting`}))]}const Zm=e=>`${e} finished ticket${e===1?"":"s"}`;function MC(e,t){const n=(e==null?void 0:e.waiting.length)??0;return t?e!=null&&e.full?`${Zm(n)} wait: agents start no new implementation work until you review some.`:`${n} of ${t} waiting: agents start new work.`:n?`${Zm(n)} wait for your review now.`:"Nothing waits for your review now."}function LC(e){const{limit:t,review:n}=e;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Review limit"}),i.jsx(at,{compact:!0,"aria-label":"Review limit",value:t?String(t):"off",options:RC(t),disabled:e.local===!1,onChange:o=>e.onChange(o==="off"?null:Number(o))})]}),i.jsxs("span",{className:"set-hint t-meta",children:["Agents finish rework and keep researching, but start no new implementation work while this many tickets wait for your review. ",MC(n,t)]})]})}function Ca(){const[e,t]=y.useState();return y.useEffect(()=>{fetch(`${pe()}/machine`).then(n=>n.ok?n.json():void 0).then(n=>t(n==null?void 0:n.local),()=>t(void 0))},[]),e}const OC=[{value:"browser",label:"Browser notification"},{value:"slack-dm",label:"Slack DM"},{value:"slack-channel",label:"Slack channel"},{value:"none",label:"Nothing, I check the queue"}];function PC(){typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()}function _C(){const{view:e,error:t,savePrefs:n,saveReviewLimit:o}=mv(0),a=Ca();if(!e)return null;const l=e.policy.value,d=`${Z.dataDir}/attention.json`,h=p=>void n({...e.prefs,...p}),f=typeof Notification<"u"&&Notification.permission==="denied";return i.jsxs(Ee,{title:"Attention",children:[i.jsxs("p",{className:"vf-intro",children:["Everything that needs you is ranked in Waiting on you. Only items scoring ",l.interrupt," or more interrupt you; the rest wait in the queue, and Slack gets them in a digest."]}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Interrupt me by"}),i.jsx(at,{compact:!0,"aria-label":"Interrupt me by",value:e.prefs.channel,options:OC,onChange:p=>{p==="browser"&&PC(),h({channel:p})}})]}),e.prefs.channel==="browser"&&f&&i.jsx("span",{className:"vf-err",children:"The browser blocks notifications for this page. Allow them in its site settings."}),i.jsx(IC,{focus:e.prefs.focus,onChange:p=>h({focus:p})}),i.jsx("span",{className:"set-hint t-meta",children:"Your channel and quiet hours stay on this machine."}),i.jsx(LC,{limit:l.reviewLimit,review:e.review,local:a,onChange:p=>void o(p)}),e.policy.errors.length>0&&i.jsx("ul",{className:"vf-errors",children:e.policy.errors.map(p=>i.jsxs("li",{children:[d,": ",p]},p))}),i.jsx(V,{className:"set-hint",parts:[e.policy.exists?{text:d,code:!0}:"Team defaults",`interrupt at ${l.interrupt}`,l.digestMinutes?`Slack digest every ${l.digestMinutes} min`:"Slack digest off",l.reviewLimit?`review limit ${l.reviewLimit}`:"review limit off"]}),t&&i.jsx("span",{className:"vf-err",children:t})]})}const DC=[5,15,30,60];function zC(e){const{value:t}=e;return i.jsxs("div",{className:"choice-row compact",children:[i.jsx(ot,{on:!t.enabled,title:"Off",onClick:()=>e.onChange({...t,enabled:!1})}),DC.map(n=>i.jsx(ot,{on:t.enabled&&t.awayMinutes===n,title:`Away ${n} min`,onClick:()=>e.onChange({enabled:!0,awayMinutes:n})},n))]})}const BC={repo:"Committed to the repo",machine:"Only on this machine",browser:"Only in this browser"};function Ke(e){const t=e.storage&&BC[e.storage];return i.jsxs("div",{className:"sp-slot",id:`settings-${e.id}`,children:[e.children,t&&i.jsx(V,{className:"sp-where",parts:[t]})]})}function FC(e){const[t]=Wd();return t?i.jsx(Ee,{title:"Slack",children:i.jsx(Mb,{focus:e.focus})}):null}function UC({data:e,route:t}){return i.jsxs(i.Fragment,{children:[i.jsx(Ke,{id:"attention",storage:"repo",children:i.jsx(_C,{})}),i.jsx(Ke,{id:"slack",storage:"machine",children:i.jsx(FC,{focus:t.section==="slack"})}),i.jsx(Ke,{id:"trip-report",storage:"browser",children:i.jsx(Ee,{title:"Trip report",children:i.jsx(zC,{value:e.prefs.briefing,onChange:n=>e.update({briefing:n})})})})]})}const WC=[{version:"0.35.0",date:"2026-11-15",items:["Settings → Project → Proof on pull requests: switch it on and Teamtrail posts each done ticket's report on its open pull request, updating the same comment as things change","A Teamtrail proof check sits next to CI on the pull request and passes only when the ticket is verified at its latest commit"]},{version:"0.34.0",date:"2026-11-15",items:["Verified by Teamtrail: `teamtrail proof <ticket>` prints what Teamtrail recorded about a ticket's completion (the checks it ran, criteria verified or only claimed, the review and the decisions it relies on), ready for a pull request","Agents get the same report from the new `proof_report` tool and put it in their pull requests","The report opens with a Teamtrail verified or not verified badge"]},{version:"0.33.1",date:"2026-11-14",items:["Teamtrail is now MIT licensed"]},{version:"0.33.0",date:"2026-11-14",items:["`teamtrail connect claude` offers to turn on Claude Code's sandbox, so the agent's shell commands can't reach Teamtrail's config folder either"]},{version:"0.32.0",date:"2026-11-13",items:["Scout has a new look: a scout companion with a cap, a headset and an antenna, looking out along the trail"]},{version:"0.31.1",date:"2026-11-13",items:["An archived trail’s held work and changes waiting for your approval stay in your queue"]},{version:"0.31.0",date:"2026-11-13",items:["Start a trail over: the trail menu archives the map that went wrong and opens New trail with its idea filled in","Archive a trail you are done with, or restore it: it stays as history, and no agent takes work from it","The empty map looks like every other empty zone, with New trail and the agent command under it"]},{version:"0.30.0",date:"2026-11-12",items:["Ask Scout more in Slack: “what's blocking #12?”, “what did we decide about retention?”, “who's working?”, as @Scout, a DM or /scout ticket, decisions and who","In a channel, the answers are seen only by you"]},{version:"0.29.3",date:"2026-11-12",items:["@Scout inbox and status in a channel now show up right away, seen only by you"]},{version:"0.29.2",date:"2026-11-12",items:["The Activity log reads in one style: a coloured bar marks what needs you (red), what went well (green) and what is held up (amber), and Slack answers show who gave them"]},{version:"0.29.1",date:"2026-11-12",items:["Scout says in Slack that it needs Teamtrail running on your computer, and how to start it, when it can’t reach yours","Ask Scout in your own words: “@Scout what’s in my inbox?” or “status of Slack live test” work, in a channel or a DM"]},{version:"0.29.0",date:"2026-11-12",items:["Ask Scout in Slack: @Scout inbox or @Scout status in a channel answers only you, or DM Scout; if you added Scout before, Settings asks you to reconnect once","A question your agent waits on gets its own Slack message with answer buttons, even right after it asked another one","Scout can be installed straight from Slack (scout.teamtrail.app/install-slack); each person then connects in Settings → Slack"]},{version:"0.28.0",date:"2026-11-12",items:["Scout is now one Slack app: Settings → Slack → Add Scout to Slack, no app to create and no tokens to paste","You confirm which Slack account becomes Scout’s owner before it connects; if you made your own Slack app before, add Scout again","High-risk calls are answered in the Lookout only, and so is approving an agent’s request to change your settings: Slack shows Open in Lookout, and Decline still works there"]},{version:"0.27.3",date:"2026-11-11",items:["On Linux, the Lookout sees every change an agent makes to a ticket again, not only the first: a claimed ticket no longer stays in the queue as waiting"]},{version:"0.27.2",date:"2026-11-11",items:["Settings, briefs, criteria, guides, reroutes and the other panels stay current through reconnects, and a GitHub or Linear map updates live again"]},{version:"0.27.1",date:"2026-11-11",items:["The map and the queue no longer miss a change made while the Lookout was loading or reconnecting"]},{version:"0.27.0",date:"2026-11-11",items:["Teamtrail opens your browser ready to sign in with one click; `teamtrail pair` does the same for another tab"]},{version:"0.26.2",date:"2026-11-11",items:["The Lookout shows the new teamtrail. wordmark"]},{version:"0.26.1",date:"2026-11-11",items:["A refreshed logo: the trail’s destination is larger, and there are light and dark versions that follow your theme"]},{version:"0.26.0",date:"2026-11-11",items:["The Lookout asks you to sign in: open the link `teamtrail` prints, and pair your phone with a QR code (again after each restart)","Your answers count only when you give them in the Lookout or Slack, and skipping discovery or changing a trail’s mode or destination waits for your Approve","Check commands, briefs, criteria and other trusted settings run only once you approve them on this machine, in Settings → Approvals","Changes made to trail files outside Teamtrail have no effect until you accept them"]}],HC=[{version:"0.10.0",date:"2026-10-31",items:["MCP server in the miloops package: `claude mcp add miloops -- npx -y miloops-cli mcp`, or the same for Codex","Connected agents start and resume missions, claim ready tickets, report steps, tokens and spend, close tickets and record decisions, live in the command center","Agent questions land in Waiting on you and the agent waits for your answer; answer in the command center or in the agent chat","/milo new, resume, status and inbox commands for Claude Code (and as a Codex prompt); `miloops connect claude|codex` sets them up","The command center follows a mission an agent just charted; sessions of agents that quit show as disconnected"]},{version:"0.9.0",date:"2026-10-31",items:["While you were away: MILO briefs you when you open the app or come back after being away: tickets done, now blocked, decisions waiting on you, agent decisions, spend and tokens since, active sessions","Briefing shows on return after 15 minutes hidden or idle; change the threshold or turn it off in Settings; reopen it from the header","Last seen per mission and usage over time are kept locally, so the briefing survives a reload","Mission title shows in full at laptop width; header readouts collapse to glyph and count","Prototype reviews link a real preview build and ask about the spike results"]},{version:"0.8.0",date:"2026-10-31",items:["Decisions: every decision across missions, newest first, with question, decision, alternatives, rationale, who decided and the full transcript","Filter decisions by mission, source, who decided and status; search; export to markdown","Supersede a decision; the chain stays visible on every record and in the mission","Decision records stored as markdown next to each mission and served by the local API with a live event stream","Resolve form: rationale and alternatives considered"]},{version:"0.7.0",date:"2026-10-31",items:["New type: Chakra Petch, Share Tech Mono and Barlow","Calmer palette; bright colour only for warnings and waiting on you","MILO mark, also used for status, action and alert glyphs","Dot-matrix signals for new decision requests and mission launches","Separate type voices for operators and agents","One-command install: npm i -g miloops-cli, then miloops in any repo","Packages renamed to @miloops-hq/core and @miloops-hq/command-center"]},{version:"0.6.0",date:"2026-10-31",items:["Named MILOOPS; MILO speaks for the platform in the activity log and onboarding","Tracker sync status, last-write latency and event pulse","Inbox: oldest question age and average wait","Critical path, decided per hour with burndown, type mix","Per-session tokens and cost, mission totals, claims per agent"]},{version:"0.5.0",date:"2026-10-31",items:["Status counters and resolution bar on the map","Current step tracker with step pipeline","Sessions with live timers","Activity log with time and source columns","Out-of-scope quarantine zone on the map"]},{version:"0.4.0",date:"2026-10-31",items:["Missions: switcher with progress and waiting count, New mission in the switcher","Inbox collects questions from every mission","Elapsed time and progress per mission","Responsive layout with progressive disclosure (wide, laptop, phone)","Map graph pans and zooms by drag, pinch and wheel","Changelog"]},{version:"0.3.0",date:"2026-10-31",items:["Fixed-zone layout","Plan + execute and plan-only mission modes","Execute tickets"]},{version:"0.2.0",date:"2026-10-31",items:["Local markdown tracker (default)","Onboarding","HITL transcript: summary or full","Settings with tracker connectors"]},{version:"0.1.0",date:"2026-10-31",items:["Live map graph","HITL vs AFK tickets","In-window HITL conversations","Demo tracker with simulated sessions"]}],KC=[{version:"0.25.0",date:"2026-11-10",items:["Agents on other machines or in cloud sandboxes can join your trails: `teamtrail mcp --http` serves the same tools over HTTP","One token per remote agent, created and revoked in Settings → Remote agents; without a token nothing is reachable","`teamtrail connect claude|codex --url` points an agent at a remote Teamtrail"]},{version:"0.24.2",date:"2026-11-10",items:["A ticket’s description no longer repeats which trail it is part of"]},{version:"0.24.1",date:"2026-11-10",items:["Buttons in the same row are always the same size"]},{version:"0.24.0",date:"2026-11-10",items:["Focus in the header: see at a glance whether it is on, and start or end it in one click","Sign in with GitHub, and pick your repo or Linear team from a searchable list","Write your own guides with `teamtrail guides new`, approve them in Settings and share them with the catalog","Settings is its own page, and the trail map has a cleaner, flatter look","Smaller polish: one colour for work in progress everywhere, a calmer first run and clearer Slack setup"]},{version:"0.23.0",date:"2026-11-08",items:["Match work to models: switch it on for a trail in Settings and each agent gets the tickets that fit the model it runs on, research on fast models and junctions on the strongest. You set the tier per ticket type; Teamtrail never switches a model, and a ticket no connected agent is strong enough for waits in your queue","Guides: a ticket can ask for a reviewer, QA, security, docs or architect, and the agent that claims it gets that guide’s instructions and a checklist it must answer before the work counts as done. Pick a trail’s team and each ticket’s guide in the Lookout, and add more guides from a moderated catalog in Settings → Guides. A guide can add checks but never remove one, its commands only run after you approve them, and a guide file edited after you approved it is switched off until you look at it again","Records has a new Trail stats view: delivery across every trail, by vendor, agent and ticket type, with plain observations from your own numbers. Teamtrail doesn't route work from them","MILOOPS is now Teamtrail. Missions are trails, the command center is the Lookout, MILO is Scout, and `/milo` is `/scout`","More room for the map: the summary of counts now slides up from a tab when you want it","A new day and night look, starting in night, with an Appearance setting to switch to day or follow your system","The map is now a landscape: tickets are trail signs, the trail shows what is walked and what is ahead, and an X marks the destination","A new greeting when you start `teamtrail` in a terminal","A new logo, a t whose stem runs along a trail to a node, and a new look for Scout: the original CRT head with ear cups and a baseball cap, with a lamp on the cap at night. No more pixel art, and new fonts too","All projects: every repo you supervise in one view, with one list of what needs you across them and what changed while you were away. Answer an agent's question in any repo from there, and switch projects from the header. Agents add their repo when they connect (`--no-register` opts out), or add one with `teamtrail projects add`"]},{version:"0.22.0",date:"2026-11-05",items:["A calmer, clearer command center: every list now reads the same way, what it is first, then one quiet line of context, and details when you want them","Red now only means something needs you now; other states show as a thin edge instead of colored text everywhere","The open question in a conversation can no longer be hidden by its suggested answers, and the phone header no longer runs off the side"]},{version:"0.21.0",date:"2026-11-05",items:["New plans can now edit a ticket, remove a dependency and reopen finished work, instead of working around it","Slack digests follow the team's digest setting (digestMinutes in attention.json); 0 turns them off, and everything still waits in Waiting on you","Remove a finished task's workspace from Settings → Workspaces or the ticket; the branch stays, and MILOOPS asks before discarding uncommitted changes"]},{version:"0.20.0",date:"2026-11-04",items:["Separate workspaces: switch on Settings → Workspaces and each ticket an agent claims gets its own copy of the repo on its own branch, so agents working at the same time don’t step on each other. When the work is done you get the branch to review; MILOOPS never merges or pushes for you","Warnings before a clash: agents say which files they expect to change. When two of them plan to change the same files, the second one is warned, and you see it in Waiting on you; open it to release either claim","When two agents’ branches did change the same files, Waiting on you suggests a ticket to bring the work together. One click adds it, waiting on both tickets, with the files listed","The ticket inspector shows which files an agent expects to change and the branch it works on","Fix: an execute ticket marked as needing you keeps that mark when saved to local files, GitHub Issues or Linear"]},{version:"0.19.0",date:"2026-11-04",items:["Risk policy: you decide what always needs you, such as database changes, logins and permissions, billing, deleting data or new dependencies (Settings → Risk policy). Agents can no longer make those calls on their own; they ask you. Their other decisions are labelled by risk in the briefing, and work that touched risky files without asking comes to you to check","One ranked list of everything that needs you in Waiting on you: questions, approvals, blocked work, briefs, knowledge and new plans, most important first, each with the reason (for example “blocks 3 tickets” or “claude-02 is waiting”). Related items are grouped so you answer them together; snooze what can wait","Fewer interruptions: agents say how urgent a question is, and only urgent items notify you (browser or Slack). Focus for an hour from the header, set quiet hours in Settings → Attention, and the rest waits in the list and the digest","Plans that adapt: missions list the assumptions they rely on, starting with the ones in the discovery brief. When an agent finds one is wrong, it shows the evidence and proposes a new plan; the tickets it would change are paused, the map previews the change, and nothing happens until you approve","Challenge the destination: an agent can tell you the work already exists, the mission targets the wrong problem, or it should be rescoped, with evidence and a suggested new goal","Assumptions on the Plan tab (confirm the ones you know are true) and an assumptions field when you create a mission","Fix: when an agent asks two questions at once, your answer goes to the one you opened; the inbox stats line no longer gets covered by the list"]},{version:"0.18.0",date:"2026-11-04",items:["Acceptance criteria: agents write down what done means before they start (required on missions with a discovery brief). When they finish, each point needs proof: one of your checks, a named test, the pull request, or your sign-off","Work whose criteria lack proof goes back with the reason; points only you can confirm come to your inbox to sign off","Business rules from your project knowledge are suggested as criteria, and the ticket shows any rule no criterion covers yet. Confirm a ticket’s criteria in the inspector","Cross-vendor review: when Claude and Codex agents both run, each reviews the other’s work first","Fix: answers from the command center could hang when too many live updates were open; all updates now share one connection"]},{version:"0.17.0",date:"2026-11-03",items:["Discovery brief: new missions start with an agent mapping the existing system (files, conventions, data and API impact, risks, assumptions, product context). Implementation tickets wait until you accept the brief or ask for changes, from the banner over the map or the card in Communication","Create mission: start a mission from the New mission dialog without a terminal; any agent picks it up with /milo resume","Knowledge: what agents need to know about your codebase and product (architecture, conventions, gotchas, dead ends, business rules, personas, UX principles, pricing). Agents propose, you confirm, keep as an assumption or retire. Confirmed entries reach agents with every claim, picked for the ticket with the reason, and the inspector shows what an agent gets","Knowledge about specific files is flagged for re-confirmation when those files change","Save decisions, cancelled tickets (as dead ends) and brief sections as knowledge in one click; seed it from a document with miloops knowledge import <file.md>"]},{version:"0.16.0",date:"2026-11-03",items:["Mission report (Mission plan → Report): tickets done, mission and median ticket lead time, your interventions, rework, review results and cost per verified ticket. Hover any number to see how it is computed; export it as markdown","Agents report the same numbers in one line from the status tool","Agents use missions for big work only, and decide routine calls themselves, keeping each one as a decision record you can review or reverse; they ask you when the call changes product behaviour, data, security, billing, a public API or the schema","Decisions: filter by who made the call, agents on their own or people. The briefing now counts only the calls agents made themselves, not your answers they recorded"]},{version:"0.15.0",date:"2026-10-31",items:["Verification in the ticket inspector: the level that applies and where it comes from, every attempt newest first with the git evidence (base → head, files changed, flags), its checks, exit codes, durations and the failing output, and the full log on demand","Verifying, Rework and Blocked on the map, in the legend and as status counters on missions that verify completions","Operator calls on a verifying or blocked ticket: Approve, Re-run checks, Send to rework with a note, Accept anyway and Unblock. Overrides need a reason, and each call is kept as a verdict next to the attempts and in the mission history. Approve asks for a re-run when the code changed since the checks passed","Set the verification level of a mission (Settings → Verification) or of one ticket (inspector). Only you can change it; agents cannot","The inspector updates live while checks run","Independent review: at Checks + review, a passing completion gets a review ticket that another agent takes and answers with PASS, FAIL (with findings) or NEEDS_HUMAN. The agent that did the work is never given its own review","Waiting on you lists reviewed work to approve (Checks + review + you) and held tickets, and Slack posts them with Approve and Rework… buttons","Agents can name their pull request in `report_completion` (`pr`); PR and CI tracking then follows that PR first"]},{version:"0.14.0",date:"2026-10-31",items:["Ticket lifecycle in plain words: Ready, Backlog, Working, Done and Cancelled (with Verifying, Rework and Blocked to come with verification)","Every claim, release, return to queue, resolution and rule-out goes through one lifecycle engine that records who, why and when in `.miloops/.events/<mission>.jsonl` (local history, never committed)","Settings → Verification shows the checks in `.miloops/verification.json`: argv commands with timeouts, run without a shell, secrets kept out of their environment. Read-only","Completion is a claim: on missions started with `verification.json` present, an execute or task ticket is only done once its checks pass. A failed check sends it back for Rework with the failing output (agents see it in close_ticket, next_ticket and claim_ticket, and rework comes first in the queue); after 3 failed attempts, or when the checks cannot run, it waits on you as Blocked","New MCP tools `report_completion` and `verification_status`; missions started before verification, and research, grilling and prototype tickets, close exactly as before","Git evidence, no GitHub needed: each claim records HEAD and the uncommitted state, and each completion lists the files changed since then. It flags no changes, overlap with another active ticket, a branch switch or reset, and edits to `verification.json` (which send the ticket to you as Blocked). A pass on code that changed while its checks ran is re-run","Pull request and CI evidence: with `verification.json` and a GitHub token (Settings, `GITHUB_TOKEN` or `gh auth login`), the command center finds each ticket’s PR (its branch `miloops-<mission>-<ticket>`, a `miloops:<mission>#<ticket>` line in the PR body, or a link you set) and flags mismatches: done with the PR still open, PR merged while the ticket is in progress, PR closed unmerged, required checks failing or unknown, PR head not the verified commit. Flags never change a ticket. A CI chip in the header shows sync health and never shows synced after a failed sync"]},{version:"0.13.0",date:"2026-10-31",items:["Crash recovery for claims: an agent’s claim is a lease (15 min by default) that every tool call renews, including waits on your answer","When an agent crashes or goes silent, its ticket goes back to the queue on its own, and the activity log says so; the next agent picks it up from next_ticket or claim_ticket","The returned ticket keeps a handoff comment with the previous agent’s progress notes and decisions, so the next agent resumes instead of starting over","Stalled state on the map, in sessions and in the ticket inspector when a lease is about to run out, with a Release to queue action","Works with GitHub and Linear: the return is an ordinary comment + unassign, queued in the offline outbox like any other write","Set the lease with `miloops mcp --lease-minutes <n>` or `MILOOPS_LEASE_MINUTES`"]},{version:"0.12.0",date:"2026-10-31",items:["Slack: your own MILO app, created from a manifest and connected from your machine over Socket Mode in five guided steps (Settings → Slack or `miloops connect slack`)","Tokens stay in your local credential store next to the GitHub and Linear ones; nothing passes through MILOOPS servers","Agent questions arrive as a Slack DM with answer buttons and a Reply… box; answering there resolves the item in Waiting on you, and answering in the command center closes the DM","Save as decision on any message, or `/milo decide`: the form is prefilled with a summary of the thread, and the decision is recorded with a permalink, resolving the related ticket by default","`/milo status` and `/milo inbox` for the mission at a glance; DMs when a ticket is blocked or a mission is done","Allowed users, notification target and events in Settings → Slack","Slack setup without Paste clicks: press ⌘V / Ctrl+V anywhere, or in Chrome just come back to the tab after copying; pasting the app token opens the install page; MILO recognises you by your git email, so there is nothing to claim in Slack"]},{version:"0.11.0",date:"2026-10-31",items:["GitHub Issues tracker: missions are labelled issues, tickets are sub-issues, blocking uses native issue dependencies",'Linear tracker: missions are labelled issues in a team (optionally one project), tickets are sub-issues, blocking uses "blocks" relations',"Two-way sync: tickets, status, claims, comments, blockers and decisions written from MILOOPS land in the tracker; changes made there show up within seconds","Decisions are posted as comments on their ticket and listed in the mission","Connect from Settings with Test connection; GitHub reuses your gh login or GITHUB_TOKEN, Linear takes a personal API key","Tokens stay on your machine: kept by the local server, never sent to the browser or anywhere else","Offline and rate limits: changes queue and send in order when the tracker answers again; the connector shows status, queue and remaining requests","Connected agents (MCP) work on the active tracker: with GitHub or Linear connected, their missions, claims and decisions land there, and their sessions show live in the command center"]},...HC],VC=[{area:"Teamtrail Cloud",items:["The Lookout as an app on your phone, with a nudge only for the calls that need you"]}],GC=[{version:"0.53.1",date:"2026-11-16",items:["A quieter header: tracker and CI show only when they fail, spend once there is any, and Plan only / Plan + execute moves into the trail menu"]},{version:"0.53.0",date:"2026-11-16",items:["Your trail's agents are one header menu: what they're doing, with Pause and Runs inside","Legend sits next to Summary under the map, no longer behind it"]},{version:"0.52.2",date:"2026-11-16",items:["Teamtrail Cloud: Scout and Get started show in the corner of the Lookout again"]},{version:"0.52.1",date:"2026-11-16",items:["Start the trail is a full-size button, like Create trail, and closes New trail once your agents are on"]},{version:"0.52.0",date:"2026-11-16",items:["Scope check: files an agent changed beyond the ones it said it would are listed first for whoever reviews","Choose in Settings → Verification whether they are only shown, sent back for rework, or left for you to decide","Proofs on pull requests say whether every change stayed inside the declared files"]},{version:"0.51.0",date:"2026-11-16",items:["Review limit: set how much finished work may wait for your review, and agents start no new work past it","Agents finish rework and keep researching meanwhile, and Waiting on you shows what to review first","Set it in Settings → Attention; in Teamtrail Cloud, workspace owners set it there too"]},{version:"0.50.0",date:"2026-11-16",items:["On the map, a done ticket’s check is green when its work is verified, grey when it isn’t","Cards say “checks running” while a completion is checked, and a Legend explains the dots"]},{version:"0.49.0",date:"2026-11-16",items:["In Teamtrail Cloud, Start the trail right after New trail, or from the trail’s header: agents start in place","A trail started in the Lookout gets your project’s default verification level, as one an agent starts does"]},{version:"0.48.1",date:"2026-11-16",items:["Scout’s Get started sits in the bottom-right corner; adding your own check shows examples"]},{version:"0.48.0",date:"2026-11-16",items:["In Teamtrail Cloud, Scout keeps Get started in the corner until your workspace is set up"]},{version:"0.47.0",date:"2026-11-16",items:["Set the checks every finished ticket must pass in Settings → Verification, no file to edit"]},{version:"0.46.0",date:"2026-11-16",items:["In Teamtrail Cloud, Approve and merge on a verified ticket merges its pull request at the commit that was checked"]},{version:"0.45.0",date:"2026-11-16",items:["In Teamtrail Cloud, Run agents on the trail takes you straight to its agents"]},{version:"0.44.2",date:"2026-11-16",items:["The middle of the Lookout gets the same margin at the top as at its sides"]},{version:"0.44.1",date:"2026-11-16",items:["Text you type in forms is full size (14px) again, not the small caps of the label above it"]},{version:"0.44.0",date:"2026-11-16",items:["In a hosted Lookout, the theme toggle and Settings → Appearance change your theme on the server too"]},{version:"0.43.1",date:"2026-11-15",items:["In a hosted Lookout that keeps your trails itself, Settings → Tracker says so instead of offering trackers"]},{version:"0.43.0",date:"2026-11-15",items:["Where the server runs your agents, the Lookout says to turn them on for a trail there, instead of offering /scout commands for an agent of your own"]},{version:"0.42.0",date:"2026-11-15",items:["A hosted Lookout has your menu in its header: back to all your workspaces, the server’s own pages, and Sign out","Where the server keeps your trails itself, the Lookout asks no tracker questions on its first run"]},{version:"0.41.0",date:"2026-11-15",items:["In a hosted Lookout, someone who may not make high-risk calls sees who can answer or approve one, instead of a box that would turn their answer away"]},{version:"0.40.0",date:"2026-11-15",items:["Decisions now say who made the call: your name from git on this machine, or the person signed in to a hosted Lookout, in the Logbook and in Verified by Teamtrail proofs","A hosted Lookout opens in the theme you picked in your account there"]},{version:"0.39.0",date:"2026-11-15",items:["A server that hosts Teamtrail can run a remote agent's checks on its pushed work, so that work is verified and its proof counts, like work done on your machine"]},{version:"0.38.0",date:"2026-11-15",items:["Decision memory: before an agent asks you something you already decided, Teamtrail hands it your earlier decision instead, and shows it next to the question if the agent asks anyway","Waiting on you flags finished work that changes files one of your decisions covers, so a later change never quietly undoes it","The Logbook groups decisions by area, the most cited first; share a project's decisions with your other projects in Settings → Projects"]},{version:"0.37.0",date:"2026-11-15",items:["Trail stats has a Scorecard: how each model, agent and vendor does on your own tickets, verified first time, rework and cost per verified ticket, with small samples marked too few","Settings → Model matching suggests a tier per ticket type when one model clearly does better on your repo, with the numbers; nothing changes until you take it","Copy the scorecard as Markdown to share it with your team"]},{version:"0.36.0",date:"2026-11-15",items:["Proof reports are signed with your machine's key: commit the key file Teamtrail writes in .teamtrail/proof-keys, and anyone can check a report with `teamtrail proof verify`","A GitHub Action, Verified by Teamtrail, checks every proof on a pull request and can be made a required check, so a PR without a valid proof can't merge","The ticket inspector shows the proof, with Copy for PR and a link to the comment once it is posted"]},...WC,...KC];function qC(){return i.jsxs("div",{className:"changelog",children:[i.jsxs("div",{className:"about",children:[i.jsx(xa,{className:"about-name"}),i.jsx("span",{className:"mono-label",children:Z.category}),i.jsx("p",{className:"onb-tagline",children:Z.tagline}),i.jsx(V,{parts:[Z.assistant.name]})]}),i.jsx(Ee,{title:"Next",children:VC.map(e=>i.jsxs("div",{className:"cl-row",children:[i.jsx("span",{className:"mono-label",children:e.area}),i.jsx("ul",{children:e.items.map(t=>i.jsx("li",{children:t},t))})]},e.area))}),GC.map(e=>i.jsx(Ee,{title:`${e.version} · ${e.date}`,children:i.jsx("ul",{children:e.items.map(t=>i.jsx("li",{children:t},t))})},e.version))]})}const ep={checks:"Completions run these commands on this machine",catalogs:"Guides can then be searched for and added from these addresses",policy:"Agents may then decide these alone",brief:"Implementation tickets of the trail open up",criteria:"These criteria define done for the ticket",knowledge:"Agents get it as trusted context with their claims",level:"Completions on it are checked this much",type:"The trail's level applies to a ticket by its type",state:"Accepting signs it as yours on this machine: gates then read the file as it is",discovery:"Agents may claim its implementation tickets without a discovery brief, and criteria are no longer required"},tp={checks:"Approval covers these commands, not what they run: npm run check runs package.json scripts, and an agent can edit those.",catalogs:"Approval covers where guides come from, not the guides: each one is still shown whole and approved on its own."};function $v(e){return e.kind==="state"?QC(e):e.committed===!1?"Not committed, so shown whole":e.standing==="elsewhere"?"Came with the repo, never approved on this machine":"Changed since you approved it here"}function QC(e){const t="Changed by a teammate or an agent outside Teamtrail";return e.standing==="elsewhere"?`${t}, or came with the repo · never signed on this machine`:e.committed===!1?`${t} · not committed`:t}const YC="Until you decide, Teamtrail uses the values it signed: a changed ticket is held for you, and a decision nobody signed here does not count. Accept signs the change as yours on this machine; Revert writes the signed values back into the file.";function JC(e){return`${e} committed ${e===1?"thing":"things"} in this repo say they were approved, or record a trail's state, but nothing on this machine signed them: a fresh clone, a teammate's push, or an upgrade from before they were kept per machine. Look them over, then approve them in one step. After that, only what Teamtrail writes here, and what you approve one at a time, counts.`}const XC=["Kept in your config folder, never in the repo","A repo moved to another folder is asked again","This stops an agent that can only write files in the repo, and a teammate's push. An agent that can read your home folder can read the key, and any local agent can answer questions with answer_question","An agent whose sandbox can write your config folder can approve for itself (teamtrail approve --hash, or approvals.json); where the sandbox blocks that folder, Teamtrail fails closed","A trail's state (ticket types, states, claims, blockers, levels, the trail's mode, decisions, assumptions) counts only as Teamtrail wrote it here, so a teammate's push shows as changed outside Teamtrail until you accept it on this machine. An agent that can write your config folder can forge that record too"];function ZC(e){const{queue:t}=e;return i.jsx(be,{as:"li",className:"ap-row",edge:"attention",title:`${t.writes} tracker writes queued before the upgrade`,context:i.jsx(V,{parts:[`For ${t.targets.join(", ")}`]}),below:i.jsxs("div",{className:"ap-below",children:[i.jsx("pre",{className:"ap-lines t-code",children:t.labels.join(`
|
|
148
|
+
`)}),i.jsx("p",{className:"ap-note t-meta",children:"An older version kept this queue in the repo, where anyone who could write it could add to it. Send them only if you recognise them; nothing is sent until you do."}),e.local&&i.jsxs("div",{className:"ap-actions",children:[i.jsx(M,{size:"sm",disabled:e.busy,onClick:()=>e.onDecide(!0),children:"Send them"}),i.jsx(M,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>e.onDecide(!1),children:"Discard"})]})]})})}function eT(e){return i.jsxs("div",{className:"ap-below",children:[i.jsxs("p",{className:"t-meta",children:["Delete ",e.files.join(", "),"? Nobody signed them on this machine; git still has them."]}),i.jsxs("div",{className:"ap-actions",children:[i.jsxs(M,{size:"sm",variant:"ghost",disabled:e.busy,onClick:e.onDelete,children:["Delete ",e.files.length===1?"it":`all ${e.files.length}`]}),i.jsx(M,{size:"sm",disabled:e.busy,onClick:e.onCancel,children:"Keep"})]})]})}const tT=e=>e.files??(e.file?[e.file]:[]);function nT(e){const{item:t}=e,[n,o]=y.useState(!1),a=tT(t),l=t.revert??"restore";return i.jsx(be,{as:"li",className:"ap-row",edge:"attention",title:t.title,context:i.jsx(V,{parts:[$v(t)]}),detail:a.join(", ")||void 0,detailText:a.join(", ")||void 0,below:i.jsxs("div",{className:"ap-below",children:[i.jsx("pre",{className:"ap-lines t-code",children:t.lines.join(`
|
|
149
|
+
`)}),e.local&&!n&&i.jsxs("div",{className:"ap-below ap-actions",children:[i.jsx(M,{size:"sm",disabled:e.busy,onClick:e.onAccept,children:"Accept this change"}),l!=="none"&&i.jsx(M,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>l==="delete"?o(!0):e.onRevert(),children:l==="delete"?"Delete…":"Revert"})]}),e.local&&n&&i.jsx(eT,{files:a,busy:e.busy,onDelete:()=>(o(!1),e.onRevert(a)),onCancel:()=>o(!1)})]})})}function sT(e){const{tracker:t}=e;return i.jsx(be,{as:"li",className:"ap-row",edge:"attention",title:`trackers.json now points at ${t.label}`,context:i.jsx(V,{parts:["Nothing is read from or sent there yet"]}),detail:`This machine keeps using ${t.approved}`,below:e.local&&i.jsxs("div",{className:"ap-below ap-actions",children:[i.jsxs(M,{size:"sm",disabled:e.busy,onClick:()=>e.onDecide(!0),children:["Use ",t.label]}),i.jsxs(M,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>e.onDecide(!1),children:["Keep ",t.approved]})]})})}function iT(e){const{item:t}=e,n=t.committed===!1,o=t.kind==="catalogs"?[...t.lines,""]:[],a=n?[...o,...t.content.split(`
|
|
150
|
+
`)]:t.lines;return i.jsx(be,{as:"li",className:"ap-row",edge:"attention",title:t.title,context:i.jsx(V,{parts:[$v(t)]}),detail:ep[t.kind],detailText:ep[t.kind],below:i.jsxs("div",{className:"ap-below",children:[i.jsx("pre",{className:"ap-lines t-code",children:a.join(`
|
|
151
|
+
`)}),tp[t.kind]&&i.jsx("p",{className:"ap-note t-meta",children:tp[t.kind]}),t.warnings.length>0&&i.jsx("ul",{className:"ap-warnings t-meta",children:t.warnings.map(l=>i.jsxs("li",{children:["Worth a look: ",l]},l))}),e.local&&i.jsx(M,{size:"sm",disabled:e.busy,onClick:e.onApprove,children:"Approve"})]})})}async function np(e,t){const n=await fetch(`${pe()}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),o=await n.json().catch(()=>({}));if(!n.ok)throw new Error(o.error??`Request failed (${n.status})`);return o}const Uc=async e=>e.ok?await e.json():void 0;async function sp(){var p;const[e,t,n]=await Promise.all(["/trust","/trackers","/trackers/legacy-outbox"].map(v=>fetch(`${pe()}${v}`))),o=await Uc(e);if(!o)return null;const{items:a}=o,l=(p=await Uc(t))==null?void 0:p.pending,d=await Uc(n),h=o.firstRun===!0,f=o.stateFirstRun===!0;return{items:a,firstRun:h,stateFirstRun:f,...l?{tracker:l}:{},...d!=null&&d.writes?{oldQueue:d}:{}}}const rT=(e,t)=>{var n,o,a,l;return JSON.stringify([e.items.map(d=>d.hash),(n=e.tracker)==null?void 0:n.target,(o=e.oldQueue)==null?void 0:o.writes])===JSON.stringify([t.items.map(d=>d.hash),(a=t.tracker)==null?void 0:a.target,(l=t.oldQueue)==null?void 0:l.writes])};function oT(e){var n,o;const t=[(n=e.changed)!=null&&n.length?`${e.changed.length} changed while you looked, so they wait; look again`:"",(o=e.refused)!=null&&o.length?`${e.refused.length} not committed, so they need their own look`:""].filter(Boolean);return t.length?`${t.join(". ")}.`:void 0}function aT(){const[e,t]=y.useState(),[n,o]=y.useState(!1),a=y.useRef();y.useEffect(()=>void(a.current=e),[e]);const l=y.useRef(0),[d]=y.useState(ni),h=y.useRef(0),f=y.useCallback(()=>{h.current++;const j=d.start(),N=S=>{j()&&(a.current=S,t(S),o(!1))};return sp().then(N,()=>N(null))},[d]),p=y.useCallback(async()=>{if(l.current)return;const j=h.current,N=await sp().catch(()=>null),S=a.current;h.current!==j||S===void 0||(!N||!S||!rT(N,S))&&o(!0)},[]);y.useEffect(()=>void f(),[f]),y.useEffect(()=>_d(j=>void(j.startsWith(".")||p())),[p]),y.useEffect(()=>vs(()=>void p()),[p]);const v=y.useCallback(async j=>{l.current++;try{const N=await j();return await f(),N}finally{l.current--}},[f]),k=y.useCallback(async j=>oT(await v(()=>np("/trust/approve",{items:j.map(N=>({key:N.key,hash:N.hash}))}))),[v]),w=y.useCallback(async(j,N)=>{await v(()=>np(j,N))},[v]);return{view:e,changed:n,load:f,approve:k,act:w}}function lT(){const{view:e,changed:t,load:n,approve:o,act:a}=aT(),l=Ca()!==!1,[d,h]=y.useState(!1),[f,p]=y.useState();if(!e)return null;const v=$=>{h(!0),p(void 0),$.then(_=>(h(!1),p(_??void 0)),_=>(h(!1),p(_.message)))},{items:k,tracker:w,oldQueue:j}=e,N=$=>!$.alone&&($.kind==="state"?e.stateFirstRun&&$.standing==="elsewhere":e.firstRun),S=k.filter($=>$.committed!==!1&&N($)),I=k.length+(w?1:0)+(j?1:0);return i.jsxs(Ee,{title:"Approvals",children:[i.jsxs("p",{className:"vf-intro",children:["Some files in the repo tell ",Z.name," what to trust: the commands checks run, where trails are kept, what needs you, how much each trail is checked, and briefs, criteria and knowledge marked accepted. Agents can edit those files and teammates push them, so nothing in them takes effect on this machine until you approve it here, exactly as it is. The same goes for a trail's state: a ticket closed, retyped, claimed or unblocked, a level or mode changed, or a decision written by editing files instead of through ",Z.name," shows here as changed outside ",Z.name,", and counts only once you accept it."]}),t&&i.jsxs("div",{className:"sync-line alert ap-changed",role:"status",children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:"Files changed while you were here. What's below is what you saw."}),i.jsx(M,{size:"sm",onClick:n,children:"Review again"})]}),I===0&&i.jsx("p",{className:"ap-none t-meta",children:"Nothing waiting. Everything the repo asks for is approved here."}),S.length>1&&i.jsx("p",{className:"ap-adopt",children:JC(S.length)}),k.some($=>$.kind==="state")&&i.jsx("p",{className:"ap-note t-meta",children:YC}),I>0&&i.jsxs("ul",{className:"ap-list",children:[w&&i.jsx(sT,{tracker:w,busy:d,local:l,onDecide:$=>v(a("/trackers/approval",{use:$,target:w.target}))}),j&&i.jsx(ZC,{queue:j,busy:d,local:l,onDecide:$=>v(a("/trackers/legacy-outbox",{action:$?"send":"discard",writes:j.writes}))}),k.map($=>$.kind==="state"?i.jsx(nT,{item:$,busy:d,local:l,onAccept:()=>v(o([$])),onRevert:_=>v(a("/trust/revert",{key:$.key,hash:$.hash,remove:_}))},$.key):i.jsx(iT,{item:$,busy:d,local:l,onApprove:()=>v(o([$]))},$.key))]}),l&&S.length>1&&i.jsxs(M,{disabled:d||t,onClick:()=>v(o(S)),children:["Approve all ",S.length," committed"]}),!l&&I>0&&i.jsxs("p",{className:"t-meta",children:["Approve these on the machine ",Z.name," runs on."]}),f&&i.jsx("span",{className:"vf-err",children:f}),i.jsx(V,{className:"set-hint",parts:XC})]})}function Cv(e){return i.jsx("ul",{className:"checklist-answers",children:e.answers.map(t=>i.jsxs("li",{className:t.done?"done":"not-done",children:[i.jsx("span",{className:"mark","aria-label":t.done?"Done":"Not done",children:t.done?"✓":"–"}),i.jsx("span",{className:"t-body",children:t.item}),t.note&&i.jsx("span",{className:"t-meta note",children:t.note})]},t.item))})}const Tv=`${Z.apiPrefix}`;async function Ev(e){const t=await e.json().catch(()=>({}));if(!e.ok)throw new Error(t.error??`Request failed (${e.status})`);return t}const qo=async e=>Ev(await fetch(`${Tv}${e}`)),Av=async(e,t)=>Ev(await fetch(`${Tv}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}));let Iv;const Po=new Set;let Yn;function fd(e){Iv=e;for(const t of Po)t()}function Rv(e){Yn==null||Yn.pushed(),fd(e)}const cT=()=>Iv;function dT(e){return Po.add(e),Yn??(Yn=ov({load:()=>qo("/guides"),show:fd,failed:()=>fd(null),changed:t=>t.includes("guides")})),()=>{Po.delete(e),!Po.size&&(Yn==null||Yn.stop(),Yn=void 0)}}function $n(){const e=y.useSyncExternalStore(dT,cT),t=y.useCallback(async(o,a)=>{try{Rv(await Av(o,a));return}catch(l){return l.message}},[]),n=y.useCallback(o=>o?e==null?void 0:e.guides.find(a=>a.id===o):void 0,[e]);return{view:e,act:t,find:n}}function uT(e){var h;const{view:t,find:n}=$n(),o=n(e.id),a=t!=null&&(o==null?void 0:o.status)!=="active",l=((h=o==null?void 0:o.guide)==null?void 0:h.name)??e.id,d=a?`${l}: ${(o==null?void 0:o.reason)??"not installed"}`:`Guide: ${l}`;return i.jsx("span",{className:Ge("guide-chip",a&&"off"),"data-guide-id":e.id,title:d,children:l})}const hT={active:"Active",unapproved:"New, waiting for your approval",tampered:"Changed since you approved it",invalid:"Can't be used"},fT={active:"Approved",unapproved:"Not approved yet",tampered:"Changed since you approved it",invalid:"Can't be used"},md=e=>{var t;return e.origin==="local"&&(!((t=e.lock)!=null&&t.source)||e.lock.source==="local")};function mT(e){return md(e)?{text:fT[e.status],strong:e.status==="active"}:e.status==="active"?void 0:hT[e.status]}function Qo(e){try{return new URL(e).host}catch{return e}}function pT(e){var n;if(e.origin==="builtin")return"Built in";const t=(n=e.lock)==null?void 0:n.source;return!t||t==="local"?e.overridesBuiltin?"Local, replaces the built-in":"Local":`From ${Qo(t.registry)}`}const qd=e=>e.map(t=>/\s/.test(t)?JSON.stringify(t):t).join(" "),ip=3;function gT(e,t){return e.length<=Math.max(t,ip+1)?e:`${e.slice(0,Math.max(t-1,ip)).trimEnd()}…`}function Mv(e){return e===_0?"Verified":`Verified by ${Qo(e)}'s catalog`}function Lv(e,t){return e.builtin?{text:"Built in",strong:!0}:e.verified?{text:Mv(t),strong:!0}:"Not reviewed"}function vT(e){var l,d;const t=(l=e.lock)==null?void 0:l.review;if(!t||e.status!=="active")return;if(!t.verified)return"Not reviewed";const n=t.reviewedBy.length>0?`Reviewed by ${t.reviewedBy.join(", ")}`:void 0,o=(d=e.lock)==null?void 0:d.source;return{text:o&&o!=="local"?Mv(o.registry):"Verified",strong:!0,tip:n}}var Ov=_p();function Pv(e){return jS(e.spec)?i.jsxs("span",{className:"guide-unknown",children:[i.jsx("span",{className:"t-body",children:"Unknown program: Teamtrail can't tell what this runs. Approve it only if you know what it does."}),i.jsxs(M,{size:"sm",disabled:e.busy,onClick:()=>e.onApprove(e.name,!0),children:["I know what it runs: approve check ",e.name]})]}):i.jsxs(M,{size:"sm",disabled:e.busy,onClick:()=>e.onApprove(e.name,!1),children:["Approve check ",e.name]})}function kT(e){var w;const{preview:t}=e,{act:n,find:o}=$n(),[a,l]=y.useState({kind:"ready"}),[d,h]=y.useState(),f=t.entry.id,p=async()=>{h(void 0),l({kind:"adding"});try{l({kind:"added",pending:(await e.add(f,t.entry.sha256)).pendingChecks})}catch(j){h(j.message),l({kind:"ready"})}};if(t.entry.builtin)return i.jsxs("span",{className:"t-meta",children:["Built into ",Z.name,": already available to every trail, nothing to add."]});if(a.kind!=="added"){const j=e.installed===t.entry.version,N=e.installed?"Update guide":"Add guide";return i.jsxs("div",{className:"add-guide",children:[!t.ok&&i.jsx("span",{className:"t-meta",children:"The lint found errors, so this guide can't be added."}),i.jsx(M,{variant:"primary",disabled:!t.ok||j||a.kind==="adding",onClick:()=>void p(),children:j?"Added":N}),d&&i.jsx("span",{className:"vf-err",children:d})]})}const v=((w=o(f))==null?void 0:w.pendingChecks)??a.pending,k=async(j,N)=>h(await n("/guides/checks/approve",{id:f,name:j,acknowledged:N}));return i.jsxs("div",{className:"add-guide",children:[i.jsx("p",{className:"t-body",children:v.length?`Added ${f} ${t.entry.version}. Approve each command it proposes; none runs until you do.`:`Added ${f} ${t.entry.version}. Agents get its instructions on tickets that ask for ${f}.`}),v.map(j=>{var N,S,I;return i.jsxs("span",{className:"guide-check",children:[i.jsxs("code",{className:"t-code",children:[j,": ",qd(((S=(N=t.guide)==null?void 0:N.proposedChecks[j])==null?void 0:S.run)??[])]}),i.jsx(Pv,{name:j,spec:((I=t.guide)==null?void 0:I.proposedChecks[j])??{run:[]},onApprove:($,_)=>void k($,_)})]},j)}),d&&i.jsx("span",{className:"vf-err",children:d})]})}function yT(e){const t=i.jsx("p",{className:"t-meta",children:"The lint looks for common problems; it isn't a review. Read the guide before you approve it."});return e.findings.length?i.jsxs(i.Fragment,{children:[i.jsx("ul",{className:"vf-findings guide-findings",children:e.findings.map((n,o)=>i.jsxs("li",{className:`sev-${n.level}`,children:[i.jsxs("code",{className:"t-code",children:["line ",n.line]})," ",n.message," ",i.jsxs("span",{className:"t-meta",children:["(",n.rule,")"]})]},o))}),t]}):i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"t-meta",children:"The lint found none of the problems it looks for."}),t]})}function _v(e){var o,a;const{p:t}=e,n=Object.entries(((o=t.guide)==null?void 0:o.proposedChecks)??{});return i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"t-label",children:"Lint"}),i.jsx(yT,{findings:t.findings}),t.guide&&t.guide.checklist.length>0&&i.jsx("span",{className:"t-label",children:"Checklist"}),t.guide&&i.jsx("ul",{className:"catalog-checklist t-body",children:t.guide.checklist.map(l=>i.jsx("li",{children:l},l))}),n.length>0&&i.jsx("span",{className:"t-label",children:"Commands it proposes"}),n.map(([l,d])=>i.jsxs("code",{className:"t-code guide-check",children:[l,": ",qd(d.run),d.cwd&&` (in ${d.cwd})`]},l)),i.jsx("span",{className:"t-label",children:"Instructions"}),i.jsx("pre",{className:"guide-preview",children:((a=t.guide)==null?void 0:a.instructions)??t.text})]})}function wT(e){const t=Nn(e.repo);if(!t)return null;const n=encodeURIComponent(`Report: ${e.id} ${e.version}`),o=`${t.replace(/\/+$/,"")}/issues/new?template=report-guide.yml&title=${n}`;return i.jsx("a",{className:"report-link t-meta",href:o,target:"_blank",rel:"noreferrer",children:"Report this guide"})}function xT(e){const t=e.entry,[n,o]=y.useState(),[a,l]=y.useState();return y.useEffect(()=>{e.preview(t.id).then(o,d=>l(d.message))},[t.id]),i.jsxs("div",{className:"catalog-entry",children:[i.jsx(M,{size:"sm",variant:"ghost",onClick:e.onBack,children:"← All guides"}),i.jsx("h3",{className:"t-title",children:t.name??t.id}),i.jsx(V,{parts:[{text:t.id,code:!0},t.version,`by ${t.author}`,Lv(t,e.catalogUrl),t.reviewedBy.length>0&&`reviewed by ${t.reviewedBy.join(", ")}`]}),i.jsx("p",{className:"t-body",children:t.summary}),t.history.length>0&&i.jsx("ul",{className:"catalog-history",children:t.history.map(d=>i.jsxs("li",{className:"t-meta",children:[d.version," · ",i.jsx("code",{className:"t-code",children:d.commit.slice(0,8)})," · ",d.at.slice(0,10)]},`${d.version}-${d.commit}`))}),a&&i.jsx("span",{className:"vf-err",children:a}),n&&i.jsx(_v,{p:n}),n&&i.jsx(wT,{repo:n.repo,id:t.id,version:t.version}),n&&i.jsx(kT,{preview:n,installed:e.installed,add:e.add})]})}function jT(e){const t=e.entry;return i.jsx("li",{className:"catalog-row","data-guide-id":t.id,children:i.jsx(be,{title:t.name??t.id,context:i.jsx(V,{parts:[{text:t.id,code:!0},t.version,t.author,Lv(t,e.catalogUrl),t.reported&&"Reported"]}),detail:t.summary,trailing:e.installed&&`installed ${e.installed}`,onOpen:e.onOpen})})}const rp=e=>e?`registry=${encodeURIComponent(e)}`:"";function ST(e){const[t,n]=y.useState(),[o,a]=y.useState();y.useEffect(()=>{let h=!0;return n(void 0),a(void 0),qo(`/guides/catalog?${rp(e)}`).then(f=>h&&n(f),f=>h&&a(f.message)),()=>{h=!1}},[e]);const l=y.useCallback(h=>qo(`/guides/catalog/preview?${rp(e)}&id=${encodeURIComponent(h)}`),[e]),d=y.useCallback(async(h,f)=>{const p=await Av("/guides/catalog/add",{registry:e,id:h,sha256:f});return Rv(p),p.installed},[e]);return{index:t,error:o,preview:l,add:d}}function NT(e){var S,I;const[t,n]=y.useState(((S=e.registries[0])==null?void 0:S.name)??""),o=ST(t||void 0),{find:a}=$n(),[l,d]=y.useState(""),[h,f]=y.useState(!0),[p,v]=y.useState(),k=o.index?SS({guides:o.index.guides},{query:l,verifiedOnly:h}):[],w=(I=o.index)==null?void 0:I.guides.find($=>$.id===p),j=$=>{var _,O,D;return((_=a($))==null?void 0:_.origin)==="local"?(D=(O=a($))==null?void 0:O.guide)==null?void 0:D.version:void 0},N=e.registries.find($=>$.name===t);return Ov.createPortal(i.jsx("div",{className:"scrim catalog-scrim",onClick:$=>{$.stopPropagation(),e.onClose()},children:i.jsxs(Be,{as:"div",className:"dialog catalog-dialog",onClick:$=>$.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h3",{className:"t-title",children:"Guide catalog"}),e.registries.length>1&&i.jsx(at,{compact:!0,"aria-label":"Catalog",value:t,options:e.registries.map($=>({value:$.name,label:`${$.name} · ${Qo($.url)}`,hint:$.url})),onChange:n}),i.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})]}),N&&e.registries.length===1&&i.jsx(V,{parts:[`Catalog ${N.name}`,{text:Qo(N.url),code:!0}]}),w?i.jsx(xT,{entry:w,catalogUrl:(N==null?void 0:N.url)??"",installed:j(w.id),preview:o.preview,add:o.add,onBack:()=>v(void 0)}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"catalog-filters",children:[i.jsx("input",{className:"catalog-search",placeholder:"Search guides","aria-label":"Search guides",value:l,onChange:$=>d($.target.value)}),i.jsx(M,{size:"sm",on:h,"aria-pressed":h,onClick:()=>f($=>!$),children:"Verified only"})]}),o.error&&i.jsx("span",{className:"vf-err",children:o.error}),!o.index&&!o.error&&i.jsx(Ie,{children:"Reading the catalog…"}),o.index&&!k.length&&i.jsx(Ie,{children:"No guides match."}),i.jsx("ul",{className:"catalog-list",children:k.map($=>i.jsx(jT,{entry:$,catalogUrl:(N==null?void 0:N.url)??"",installed:j($.id),onOpen:()=>v($.id)},$.id))})]})]})}),document.body)}function bT(e){const t=e.r.guide;if(!t)return null;const n=Object.entries(t.proposedChecks);if(!t.requiresChecks.length&&!n.length)return null;const o=e.r.status==="active";return i.jsxs("div",{className:"guide-checks",children:[t.requiresChecks.length>0&&i.jsxs("span",{className:"t-meta",children:["Adds checks ",i.jsx("code",{className:"t-code",children:t.requiresChecks.join(", ")})," to its tickets"]}),n.map(([a,l])=>{const d=e.r.pendingChecks.includes(a);return i.jsxs("span",{className:"guide-check",children:[i.jsxs("code",{className:"t-code",children:[a,": ",qd(l.run)]}),d&&o&&i.jsx(Pv,{name:a,spec:l,busy:e.busy,onApprove:e.onApprove}),d&&!o&&i.jsx("span",{className:"t-meta",children:"approve the guide first"}),!d&&i.jsx("span",{className:"t-meta",children:"approved"})]},a)})]})}function $T(e){const{r:t}=e;if(!t.guide||!t.sha256)return null;const n=t.sha256;return i.jsxs("div",{className:"guide-review",children:[i.jsx(_v,{p:{findings:t.findings,guide:t.guide}}),i.jsx(M,{size:"sm","aria-label":`Approve guide ${t.id}`,disabled:e.busy,onClick:()=>e.onApprove(n),children:"Approve"})]})}const CT="A file in guides/ replaces this built-in once you approve it; until then the built-in is used";function TT(e){var t,n;return e.override?CT:e.status==="unapproved"?(t=e.guide)==null?void 0:t.summary:e.reason??((n=e.guide)==null?void 0:n.summary)}function Dv(e){const{r:t}=e,n=t.id,o=t.override??t,a=(o.status==="unapproved"||o.status==="tampered")&&!!o.guide,l=t.status!=="active"||t.pendingChecks.length>0||a,d=t.guide?`${t.guide.name} ${t.guide.version}`:n;return i.jsx("li",{className:"guide-row","data-guide-id":n,children:i.jsx(be,{edge:l?"attention":"neutral",title:d,context:i.jsx(V,{parts:[{text:n,code:!0},pT(t),vT(t),mT(t),t.guide&&ET(t.guide.checklist.length)]}),detail:TT(t),actions:t.origin==="local"&&i.jsxs(M,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>e.onAct("/guides/remove",{id:n}),children:["Remove guide ",n]}),below:i.jsxs(i.Fragment,{children:[a&&i.jsx($T,{r:o,busy:e.busy,onApprove:h=>e.onAct("/guides/approve",{id:n,sha256:h})}),i.jsx(bT,{r:t,busy:e.busy,onApprove:(h,f)=>e.onAct("/guides/checks/approve",{id:n,name:h,acknowledged:f})})]})})})}const ET=e=>e===1?"1 checklist item":`${e} checklist items`;function AT(e){return i.jsxs(Ee,{title:"Write your own",children:[i.jsxs("p",{className:"vf-intro",children:["Write a guide for your team in your repo with ",i.jsxs("code",{className:"t-code",children:[Z.slug," guides new <id>"]}),". It starts from a template in ",i.jsxs("code",{className:"t-code",children:[Z.dataDir,"/guides/"]})," that passes the lint. Fill in the instructions and checklist, then approve it here: agents can only use it once you have, and again after every edit."]}),e.guides.length>0?i.jsx("ul",{className:"guides-list own-guides",children:e.guides.map(t=>i.jsx(Dv,{r:t,busy:e.busy,onAct:e.onAct},t.id))}):i.jsx(Ie,{children:"No guides of your own yet."}),e.error&&i.jsx("span",{className:"vf-err",children:e.error}),i.jsxs("p",{className:"t-meta guides-share",children:["Useful beyond your team? Check it with ",i.jsxs("code",{className:"t-code",children:[Z.slug," guides lint"]})," and"," ",i.jsx("a",{href:D0,target:"_blank",rel:"noreferrer",children:"share it in the public catalog"}),"."]})]})}function IT(e){const{view:t,act:n}=$n(),[o,a]=y.useState(),[l,d]=y.useState(!1),[h,f]=y.useState(!1),p=y.useRef(null);if(y.useEffect(()=>{var w;e.focus&&t&&((w=p.current)==null||w.scrollIntoView({block:"start"}))},[e.focus,!!t]),!t)return null;const v=w=>(j,N)=>{d(!0),n(j,N).then(S=>{a(S?{own:w,message:S}:void 0),d(!1)})},k=w=>o&&o.own===w?o.message:void 0;return i.jsxs("div",{className:"guides-section",ref:p,children:[i.jsxs(Ee,{title:"Guides",children:[i.jsx("p",{className:"vf-intro",children:"Guides give an agent instructions and a checklist for the tickets that ask for them. A guide can add checks, never remove them, and its commands only run once you approve them."}),i.jsx("ul",{className:"guides-list",children:t.guides.filter(w=>!md(w)).map(w=>i.jsx(Dv,{r:w,busy:l,onAct:v(!1)},w.id))}),i.jsxs("div",{className:"guides-foot",children:[i.jsx(M,{size:"sm",onClick:()=>f(!0),children:"Browse guides"}),i.jsx(V,{parts:[{text:`${Z.dataDir}/guides/`,code:!0},{text:"guides.lock.json",code:!0}]})]}),t.configErrors.length>0&&i.jsx("ul",{className:"vf-errors",children:t.configErrors.map(w=>i.jsx("li",{children:w},w))}),k(!1)&&i.jsx("span",{className:"vf-err",children:k(!1)})]}),i.jsx(AT,{guides:t.guides.filter(md),busy:l,onAct:v(!0),error:k(!0)}),h&&i.jsx(NT,{registries:t.registries,onClose:()=>f(!1)})]})}function RT(e){const{view:t,act:n}=$n(),[o,a]=y.useState();if(!t)return null;const l=e.map.guides??[],d=t.guides.filter(f=>f.status==="active"&&f.guide),h=f=>{const p=l.includes(f)?l.filter(v=>v!==f):[...l,f];a(void 0),n("/guides/team",{mapId:e.map.id,guides:p}).then(a)};return i.jsxs(Ee,{title:`Team of ${e.map.key}`,children:[i.jsx("p",{className:"vf-intro",children:"The guides this trail works with. With Reviewer on the team, review tickets come with the reviewer's instructions and checklist."}),i.jsx("div",{className:"team-guides",children:d.map(f=>{const p=l.includes(f.id);return i.jsx(M,{size:"sm",on:p,"aria-pressed":p,title:f.guide.summary,onClick:()=>h(f.id),children:f.guide.name},f.id)})}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function MT(e,t){const[n,o]=y.useState(),a=`/guides/checklist?mapId=${encodeURIComponent(e)}&ticketId=${encodeURIComponent(t)}`;return Ye({view:a,load:()=>qo(a),show:l=>o(l.checklist),failed:()=>o(null),changed:l=>l.endsWith("checklist.json")}),n}function LT(e){const t=MT(e.mapId,e.ticketId);if(!t)return null;const n=t.answers.filter(o=>!o.done).length;return i.jsxs("div",{className:"checklist-panel",children:[i.jsx(V,{parts:[`${t.guide.id} ${t.guide.version} checklist`,t.by,hr(t.at),n?`${n} not done`:"all done"]}),i.jsx(Cv,{answers:t.answers})]})}const op="";function OT(e){const{view:t,act:n}=$n(),[o,a]=y.useState();if(!t)return null;const l=e.ticket,d=t.guides.filter(p=>{var v;return p.status==="active"&&((v=p.guide)==null?void 0:v.handles.types.includes(l.type))}),h=[{value:op,label:"No guide"},...d.map(p=>({value:p.id,label:p.guide.name,hint:p.guide.summary}))];l.guide&&!d.some(p=>p.id===l.guide)&&h.push({value:l.guide,label:l.guide});const f=p=>{a(void 0),n("/guides/ticket",{mapId:e.mapId,ticketId:l.id,guide:p||null}).then(a)};return i.jsxs("span",{className:"guide-picker",children:[i.jsx(at,{compact:!0,"aria-label":"Ticket guide",value:l.guide??op,options:h,onChange:f}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function PT(e){const{view:t,find:n}=$n();if(!t)return null;const o=n(e.id);if((o==null?void 0:o.status)==="active")return null;const a=o?o.reason??o.status:"it is not installed";return i.jsxs("p",{className:"guide-warning t-meta",children:["Guide ",e.id," can't be used: ",a,". Claims get no guide instructions until you approve it in Settings → Guides."]})}function _T(e){const{view:t}=$n(),n=e.ticket;return!t||n.state!=="open"&&!n.guide?null:i.jsxs("section",{className:"ticket-guide d-section",children:[i.jsxs("span",{className:"guide-head",children:[i.jsx("span",{className:"t-label",children:"Guide"}),n.state==="open"?i.jsx(OT,{mapId:e.mapId,ticket:n}):n.guide&&i.jsx(uT,{id:n.guide})]}),n.guide&&i.jsx(PT,{id:n.guide}),i.jsx(LT,{mapId:e.mapId,ticketId:n.id})]})}function DT(e){var f;const{view:t,find:n}=$n();if(!e)return;const o=n(e),a=t!=null&&(o==null?void 0:o.status)!=="active",l=((f=o==null?void 0:o.guide)==null?void 0:f.name)??e,d=o!=null&&o.guide?`${l} ${o.guide.version}`:l,h=a?`Guide ${d}: ${(o==null?void 0:o.reason)??"not installed"}`:`Guide: ${d}`;return{id:e,name:l,tip:h,off:a}}const zv=()=>`${pe()}/proof/settings`;async function zT(){const e=await fetch(zv());return e.ok?await e.json():null}function BT(){const[e,t]=y.useState(),{pushed:n}=Ye({load:zT,show:a=>t((a==null?void 0:a.enabled)??null),failed:()=>t(null),events:{proof:()=>!0}}),o=y.useCallback(async a=>{const l=await fetch(zv(),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:a})}),d=await l.json();if(!l.ok)return d.error??`Saving failed (${l.status})`;n(),t(d.enabled===!0)},[n]);return{enabled:e,set:o}}function FT(){const{enabled:e,set:t}=BT(),[n,o]=y.useState();if(e==null)return null;const a=()=>{o(void 0),t(!e).then(o,l=>o(l.message))};return i.jsxs(Ee,{title:"Proof on pull requests",children:[i.jsxs("p",{className:"vf-intro",children:["When a ticket is done and its pull request is open, post its Verified by Teamtrail report as one comment on the PR, with a ",i.jsx("b",{children:"Teamtrail proof"})," check next to CI. The comment is updated, never repeated, when the proof or the PR changes."]}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Post proofs from this machine"}),i.jsx(M,{size:"sm",on:e,"aria-pressed":e,className:"proof-post-toggle",onClick:a,children:e?"On":"Off"})]}),i.jsxs("span",{className:"set-hint t-meta",children:["Posted with your GitHub token, to the repo Teamtrail syncs pull requests with (",i.jsx("code",{children:"github"})," in verification.json). Only this machine posts: a teammate switches it on in their own Lookout. The check passes only when the ticket is verified at the PR's latest commit."]}),n&&i.jsx("span",{className:"vf-err",children:n})]})}function UT(e){var l;const[t,n]=y.useState({kind:"idle"}),o=(l=ft())==null?void 0:l.merge;if(!o||!e.verified)return null;const a=async()=>{n({kind:"working"});try{const d=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({trail:e.mapId,ticket:e.ticketId})}),h=await d.json().catch(()=>({}));if(d.ok&&h.merged)return n({kind:"merged",url:h.url?Nn(h.url):void 0});n({kind:"error",text:String(h.error??`The server answered ${d.status}.`).slice(0,300)})}catch{n({kind:"error",text:"The server didn't answer. Try again."})}};return t.kind==="merged"?i.jsxs("span",{className:"t-meta merge-note",children:["Approved and merged at the verified commit."," ",t.url&&i.jsx("a",{href:t.url,target:"_blank",rel:"noreferrer",children:"See the pull request"})]}):t.kind==="confirm"?i.jsxs("div",{className:"merge-confirm",children:[i.jsx("span",{className:"t-meta",children:"Merge its pull request, at exactly the commit Teamtrail verified?"}),i.jsx(M,{size:"sm",onClick:()=>void a(),children:"Merge"}),i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>n({kind:"idle"}),children:"Cancel"})]}):i.jsxs("div",{className:"merge-confirm",children:[i.jsx(M,{size:"sm",disabled:t.kind==="working",onClick:()=>n({kind:"confirm"}),children:t.kind==="working"?"Merging…":"Approve and merge"}),t.kind==="error"&&i.jsx("span",{className:"t-meta",children:t.text})]})}function WT(e,t){const[n,o]=y.useState();return Ye({load:async()=>{const a=new URLSearchParams({mapId:e,ticketId:t}),l=await fetch(`${pe()}/proof/ticket?${a}`);return l.ok?await l.json():null},show:o,failed:()=>o(null),view:`${e}/${t}`,changed:a=>a.includes(`tickets/${t}.md`),events:{verification:()=>!0,proof:()=>!0}}),n}function HT(e){const t=WT(e.mapId,e.ticket.id),[n,o]=y.useState(!1);if(!t)return null;const{proof:a,post:l}=t,d=e.ticket.state==="closed"&&e.ticket.closeReason==="completed";if(!d&&!a.attempt.id)return null;const h=a.status==="verified",f=()=>void navigator.clipboard.writeText(t.markdown).then(()=>{o(!0),setTimeout(()=>o(!1),1500)}),p=l!=null&&l.commentUrl?Nn(l.commentUrl):void 0;return i.jsxs("section",{className:"d-section ticket-proof",children:[i.jsx("span",{className:"t-label",children:"Proof"}),i.jsxs("div",{className:"proof-head",children:[i.jsx(bn,{tone:h?"fill":"amber",children:h?"Verified by Teamtrail":"Not verified"}),i.jsx(M,{size:"sm",variant:"ghost",onClick:f,children:n?"Copied":"Copy for PR"})]}),a.gaps.length>0&&i.jsx("ul",{className:"proof-gaps t-meta",children:a.gaps.map(v=>i.jsx("li",{children:v},v))}),i.jsx(V,{className:"t-meta",parts:[a.checks.length>0&&`${a.checks.filter(v=>v.passed).length}/${a.checks.length} checks passed`,a.criteria.lines.length>0&&`${a.criteria.verified} criteria verified, ${a.criteria.claimed} claimed`,a.reviews.length>0&&`${a.reviews.length} review${a.reviews.length>1?"s":""}`,{text:a.digest.slice(0,19),code:!0}]}),d&&i.jsx(UT,{mapId:e.mapId,ticketId:e.ticket.id,verified:h}),p&&i.jsxs("a",{className:"t-meta",href:p,target:"_blank",rel:"noreferrer",children:["Posted on pull request #",l.pr]}),(l==null?void 0:l.error)&&i.jsxs("span",{className:"t-meta",children:["Posting failed, trying again: ",l.error]}),t.keyFile&&i.jsxs("span",{className:"t-meta",children:["Signed with this machine's key. Commit ",i.jsx("code",{children:`${Z.dataDir}/${t.keyFile}`})," so others can check it."]})]})}const Bv="0.53.1",pd="<endpoint>",Qd=zp(Bv,["mcp","--http"]);function KT(e,t){const n=zp(Bv,["connect",e,"--url"]),o=t===pd?t:Dp(t);return`read -rs ${Z.tokenEnv} && export ${Z.tokenEnv}
|
|
152
|
+
${n} ${o}`}function VT(e){return e.kind==="lookout"?["the Lookout","this machine only"]:["for remote agents",e.network?"open to your network":"this machine only, until a tunnel or proxy shares it"]}function GT({endpoints:e}){const t=e.some(n=>n.kind==="standalone");return i.jsxs("ul",{className:"ra-endpoints",children:[e.map(n=>i.jsx("li",{children:i.jsx(V,{className:"set-hint",parts:[{text:n.url,code:!0},...VT(n)]})},n.url)),!t&&i.jsx("li",{children:i.jsx(V,{className:"set-hint",parts:["For agents on other machines, start their server",{text:Qd,code:!0}]})})]})}function qT(e){const[t,n]=y.useState(""),[o,a]=y.useState(!1),[l,d]=y.useState(),h=async f=>{if(!f.trim()||o)return;a(!0);const p=await e.onCreate(f).catch(v=>v.message);a(!1),d(p),p||n("")};return i.jsxs("div",{className:"ra-new",children:[i.jsx(wa,{value:t,onValueChange:n,onSubmit:h,action:"Create token",actionDisabled:o||!t.trim(),placeholder:"Name the agent, e.g. cloud sandbox 1","aria-label":"Agent name",maxLength:60}),l&&i.jsx("span",{className:"vf-err",children:l})]})}function QT(){return i.jsx(Ee,{title:"Remote agents",children:i.jsxs("p",{className:"vf-intro",children:["Tokens for remote agents are created and revoked on the machine ",Z.name," runs on. Open the Lookout there to manage them."]})})}function YT(e){const[t,n]=y.useState(!1),[o,a]=y.useState(!1),[l,d]=y.useState(),h=async()=>{a(!0),d(await e.onRevoke().catch(f=>f.message)),a(!1),n(!1)};return t?i.jsxs("span",{className:"ra-revoke ask",children:[i.jsx("span",{className:"t-meta",children:"Its sessions end now."}),i.jsxs(M,{size:"sm",disabled:o,onClick:h,children:["Revoke ",e.name]}),i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>n(!1),children:"Keep"})]}):i.jsxs("span",{className:"ra-revoke",children:[i.jsx(M,{size:"sm","aria-label":`Revoke ${e.name}`,onClick:()=>n(!0),children:"Revoke"}),l&&i.jsx("span",{className:"vf-err",children:l})]})}function JT(e){if(!e.tokens.length)return null;const t=Date.now();return i.jsx("ul",{className:"ra-list",children:e.tokens.map(n=>i.jsx(be,{as:"li",className:"ra-row",title:n.name,titleText:n.name,context:i.jsx(V,{parts:[`Created ${Go(n.createdAt,t)}`,n.lastUsedAt?`Last used ${Go(n.lastUsedAt,t)}`:"Never used"]}),below:i.jsx(YT,{name:n.name,onRevoke:()=>e.onRevoke(n.id)})},n.id))})}function Wc(e){const[t,n]=y.useState(!1),o=()=>{var a;return void((a=navigator.clipboard)==null?void 0:a.writeText(e.value).then(()=>{n(!0),setTimeout(()=>n(!1),1500)},()=>n(!1)))};return i.jsxs("div",{className:"ra-copy",children:[i.jsx("code",{className:"ra-copy-value t-code","aria-label":e.label,children:e.value}),i.jsx(M,{size:"sm",className:"ra-copy-btn",onClick:o,children:t?"Copied":e.copyLabel??"Copy"})]})}const XT=[{id:"claude",label:"Claude Code"},{id:"codex",label:"Codex"}];function ZT(e){const[t,n]=y.useState("claude");return i.jsxs("div",{className:"ra-reveal",role:"status",children:[i.jsxs("p",{className:"ra-reveal-title t-row-title",children:["Token for ",e.created.name]}),i.jsxs("p",{className:"t-body ra-note",children:["Copy it now. ",Z.name," keeps only a fingerprint, so it can't show it again."]}),i.jsx(Wc,{label:"Token",value:e.created.token,copyLabel:"Copy token"}),!e.endpoint&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"ra-reveal-head",children:i.jsx(ze,{children:"Start the server for remote agents"})}),i.jsx(Wc,{label:"Start command",value:Qd,copyLabel:"Copy command"})]}),i.jsxs("div",{className:"ra-reveal-head",children:[i.jsx(ze,{children:"Run on the agent's machine"}),i.jsx("span",{className:"ra-clients",children:XT.map(o=>i.jsx(M,{size:"sm",on:t===o.id,"aria-pressed":t===o.id,onClick:()=>n(o.id),children:o.label},o.id))})]}),i.jsx(Wc,{label:"Connect command",value:KT(t,e.endpoint??pd),copyLabel:"Copy command"}),i.jsxs("p",{className:"t-meta ra-note",children:["The first line waits for the token: paste it and press Enter. It isn't shown, and it stays out of your shell history."," ",e.endpoint?"From another machine, use the address that machine reaches this one by.":`Put the address the server prints in place of ${pd}.`,t==="codex"&&` Start Codex from the same shell: it reads $${Z.tokenEnv} each time.`]}),i.jsx("span",{children:i.jsx(M,{variant:"primary",size:"sm",onClick:e.onDone,children:"I've copied it"})})]})}const Fv=`${pe()}/remote-agents`;async function ap(e,t){const n=await fetch(`${Fv}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return{ok:n.ok,reply:await n.json()}}async function e2(){const e=await fetch(Fv);return e.ok?await e.json():(await e.json().catch(()=>({}))).elsewhere?"elsewhere":null}function t2(){const[e,t]=y.useState(),[n,o]=y.useState(),{pushed:a}=Ye({load:e2,show:t,failed:()=>t(null),events:{"remote-agents":()=>!0}}),l=y.useCallback(f=>{a(),t({tokens:f.tokens,endpoints:f.endpoints})},[a]),d=y.useCallback(async f=>{const{ok:p,reply:v}=await ap("/tokens",{name:f});if(!p||!v.token||!v.created)return v.error??"The token could not be created.";l(v),o({token:v.token,name:v.created.name})},[l]),h=y.useCallback(async f=>{const{ok:p,reply:v}=await ap("/tokens/revoke",{id:f});return v.tokens&&l(v),p?void 0:v.error??"The token could not be revoked."},[l]);return{view:e,created:n,dismissCreated:()=>o(void 0),create:d,revoke:h}}function n2(){var d;const{view:e,created:t,dismissCreated:n,create:o,revoke:a}=t2();if(!e)return null;if(e==="elsewhere")return i.jsx(QT,{});const l=(d=e.endpoints.find(h=>h.kind==="standalone"))==null?void 0:d.url;return i.jsxs(Ee,{title:"Remote agents",children:[i.jsx("p",{className:"vf-intro",children:"Agents on another machine or in a cloud sandbox can work this repo's trails too. They connect over HTTP with a token and share the tickets, claims and inbox of the agents here. One token per agent; revoke it and that agent is out within about a second."}),i.jsx(GT,{endpoints:e.endpoints}),t&&i.jsx(ZT,{created:t,endpoint:l,onDone:n}),i.jsx(JT,{tokens:e.tokens,onRevoke:a}),e.tokens.length===0&&i.jsx("p",{className:"t-meta ra-note",children:"No tokens, so the endpoint is closed: every request is refused."}),i.jsx(qT,{onCreate:o}),i.jsxs("div",{className:"ra-notes",children:[i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"Before you open it to other machines."})," The connection is plain HTTP. Run ",i.jsx("code",{children:Qd}),", which serves the agent tools and nothing else, and put that port behind HTTPS with a reverse proxy or a tunnel. The Lookout's own port is not for sharing: its agent endpoint answers this machine only. A token only ever opens the agent tools, never the Lookout, which signs in browsers, not agents."]}),i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"What a remote agent can't do."})," Speak for you: it can't answer a question, skip discovery, change the trail's mode or destination, or close a ticket that needs you before you've answered here or in Slack. And its files aren't on this machine, so it gets no worktree, and on trails with verification its finished work comes to you to review instead of running the checks here."]}),i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"How far to trust one."})," The risk policy only sees what an agent declares: a call is held for you when the agent names a high-risk category or touches files your path rules cover. An agent that declares nothing isn't caught. Give an agent you don't fully trust only trails with verification on, where its finished work comes to you."]}),i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"What it does as you."})," With GitHub Issues or Linear as the tracker, everything a remote agent writes (tickets, comments, closing) goes to the tracker with your credentials, like the agents here."]})]})]})}const lp={schema:"Database schema","breaking-api":"Breaking API changes","auth-permissions":"Auth and permissions",billing:"Billing","data-deletion":"Deleting data","product-behaviour":"Product behaviour",dependencies:"Dependencies"},s2={low:"the agent decides",medium:"the agent decides and records it",high:"you decide"},i2=e=>e[0].toUpperCase()+e.slice(1),gd=cg.map(e=>({value:e,label:i2(e),hint:s2[e]}));function r2(e){const[t,n]=y.useState(""),[o,a]=y.useState("high"),{rules:l,onChange:d}=e,h=()=>{const f=t.trim();!f||l.some(p=>p.glob===f)||(d([...l,{glob:f,level:o}]),n(""))};return i.jsxs("div",{className:"risk-paths",children:[i.jsx("span",{className:"mono-label",children:"Files"}),l.map((f,p)=>i.jsxs("div",{className:"risk-row",children:[i.jsx("code",{children:f.glob}),i.jsx(at,{compact:!0,"aria-label":`${f.glob} risk`,value:f.level,options:gd,onChange:v=>d(l.map((k,w)=>w===p?{...k,level:v}:k))}),i.jsx("button",{className:"icon-btn","aria-label":`Remove ${f.glob}`,onClick:()=>d(l.filter((v,k)=>k!==p)),children:"×"})]},f.glob)),i.jsxs("div",{className:"risk-row",children:[i.jsx("input",{value:t,placeholder:"src/payments/**","aria-label":"New file pattern",onChange:f=>n(f.target.value),onKeyDown:f=>f.key==="Enter"&&h()}),i.jsx(at,{compact:!0,"aria-label":"New pattern risk",value:o,options:gd,onChange:a}),i.jsx(M,{onClick:h,disabled:!t.trim(),children:"Add"})]})]})}const Uv=`${pe()}/policy`;async function o2(){const e=await fetch(Uv);return e.ok?await e.json():null}function a2(){const[e,t]=y.useState(),{pushed:n}=Ye({load:o2,show:t,failed:()=>t(null),changed:a=>a.endsWith("policy.json")}),o=y.useCallback(async a=>{const l=await fetch(Uv,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),d=await l.json();if(!l.ok)return d.error??`Saving failed (${l.status})`;n(),t(d)},[n]);return{view:e,save:o}}function l2(){const{view:e,save:t}=a2(),[n,o]=y.useState();if(!e)return null;const a=`${Z.dataDir}/policy.json`,l=d=>{o(void 0),t(d).then(o,h=>o(h.message))};return i.jsxs(Ee,{title:"Risk policy",children:[i.jsx("p",{className:"vf-intro",children:"What agents may decide on their own. High: they must ask you. Medium: they decide, follow your conventions and record it for you to review. Low: they just decide."}),i.jsx("div",{className:"risk-grid",children:lg.map(d=>i.jsxs("label",{className:"risk-row",children:[i.jsx("span",{children:lp[d]}),i.jsx(at,{compact:!0,"aria-label":`${lp[d]} risk`,value:e.policy.categories[d],options:gd,onChange:h=>l({...e.policy,categories:{...e.policy.categories,[d]:h}})})]},d))}),i.jsx(r2,{rules:e.policy.paths,onChange:d=>l({...e.policy,paths:d})}),e.errors.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[a," has errors, so the defaults apply until it is fixed."]})]}),i.jsx("ul",{className:"vf-errors",children:e.errors.map(d=>i.jsx("li",{children:d},d))})]}),e.defaults&&e.errors.length===0&&i.jsxs("span",{className:"set-hint t-meta",children:["Defaults. Changing anything saves ",a,", so your team shares it."]}),n&&i.jsx("span",{className:"vf-err",children:n})]})}const vd=`${pe()}/workspaces`;async function c2(){const e=await fetch(vd);return e.ok?await e.json():null}function Wv(){const[e,t]=y.useState(),{pushed:n}=Ye({load:c2,show:t,failed:()=>t(null),changed:d=>d.endsWith("workspaces.json")||d.includes("workspaces/")||d.includes("leases/")}),o=y.useCallback(d=>{n(),t(d)},[n]),a=y.useCallback(async d=>{const h=await fetch(vd,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)}),f=await h.json();if(!h.ok)return f.error??`Saving failed (${h.status})`;o(f)},[o]),l=y.useCallback(async(d,h,f=!1)=>{const p=await fetch(`${vd}/remove`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:d,ticketId:h,force:f})}),v=await p.json();return p.ok?(o(v),{}):{error:v.error??`Removing failed (${p.status})`,dirty:v.dirty??!1}},[o]);return{view:e,save:a,remove:l}}function Hv(e){const[t,n]=y.useState(!1),[o,a]=y.useState(),[l,d]=y.useState(!1),h=async f=>{d(!0),a(void 0);const p=await e.onRemove(f).catch(v=>({error:v.message,dirty:!1}));d(!1),n(!!p.dirty&&!f),p.dirty||a(p.error)};return t?i.jsxs("span",{className:"ws-remove ask",children:[i.jsx("span",{className:"vf-err",children:"Uncommitted changes in this workspace will be lost."}),i.jsx(M,{size:"sm",disabled:l,onClick:()=>h(!0),children:"Remove anyway"}),i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>n(!1),children:"Keep"})]}):i.jsxs("span",{className:"ws-remove",children:[i.jsx(M,{size:"sm",disabled:l,onClick:()=>h(!1),children:e.label??"Remove"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function d2(e){return e.rows.length?i.jsx("ul",{className:"ws-list",children:e.rows.map(t=>i.jsx(be,{as:"li",className:`ws-row ${t.active?"active":"finished"}`,title:i.jsx("span",{className:"t-code",children:t.branch}),titleText:t.branch,context:i.jsx(V,{parts:[{text:t.ticketKey,code:!0},t.active?`Active · ${t.agent}`:"Finished"]}),detail:i.jsx("span",{className:"t-code",children:t.path}),detailText:t.path,below:t.active?void 0:i.jsx(Hv,{onRemove:n=>e.onRemove(t.mapId,t.ticketId,n)})},`${t.mapId}/${t.ticketId}`))}):null}function u2(e){const{view:t,remove:n}=Wv(),o=t==null?void 0:t.workspaces.find(a=>a.mapId===e.mapId&&a.ticketId===e.ticketId);return!o||o.active?null:i.jsxs("section",{className:"ticket-workspace d-section",children:[i.jsx("span",{className:"t-label",children:"Workspace"}),i.jsxs("p",{className:"t-meta",children:["Branch ",i.jsx("code",{className:"t-code",children:o.branch})," in"," ",i.jsx("code",{className:"t-code",title:o.path,children:o.path})]}),i.jsx(Hv,{label:"Remove workspace",onRemove:a=>n(e.mapId,e.ticketId,a)})]})}function h2(){const{view:e,save:t,remove:n}=Wv(),[o,a]=y.useState();if(!e)return null;const l=e.settings.worktrees,d=()=>{a(void 0),t({...e.settings,worktrees:!l}).then(a,h=>a(h.message))};return i.jsxs(Ee,{title:"Workspaces",children:[i.jsxs("p",{className:"vf-intro",children:["Give each agent its own copy of the repo for every ticket it claims, on its own branch, so agents working at the same time don't step on each other. You review and merge the branches; ",Z.name," never merges or pushes."]}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"A worktree per ticket"}),i.jsx(M,{size:"sm",on:l,"aria-pressed":l,className:"worktrees-toggle",onClick:d,children:l?"On":"Off"})]}),i.jsx(V,{className:"set-hint",parts:[{text:`${Z.dataDir}/workspaces.json`,code:!0},cp(e.workspaces.filter(h=>h.active).length,"active"),cp(e.workspaces.filter(h=>!h.active).length,"finished")]}),i.jsx(d2,{rows:e.workspaces,onRemove:n}),e.errors.length>0&&i.jsx("ul",{className:"vf-errors",children:e.errors.map(h=>i.jsx("li",{children:h},h))}),o&&i.jsx("span",{className:"vf-err",children:o})]})}const cp=(e,t)=>`${e} ${t}`;function f2({data:e,route:t}){var n;return i.jsxs(i.Fragment,{children:[i.jsx(Ke,{id:"approvals",storage:"machine",children:i.jsx(lT,{})}),i.jsx(Ke,{id:"tracker",children:i.jsx(Ee,{title:"Tracker",children:(n=ft())!=null&&n.tracker?i.jsx("p",{className:"vf-intro",children:"Trails are kept by the server this Lookout runs on, in its own storage."}):i.jsx(bC,{activeTracker:e.activeTracker,location:e.location,update:e.update})})}),i.jsx(Ke,{id:"workspaces",storage:"repo",children:i.jsx(h2,{})}),i.jsx(Ke,{id:"proof",storage:"machine",children:i.jsx(FT,{})}),i.jsx(Ke,{id:"remote-agents",storage:"machine",children:i.jsx(n2,{})}),i.jsx(Ke,{id:"policy",storage:"repo",children:i.jsx(l2,{})}),i.jsx(Ke,{id:"guides",storage:"repo",children:i.jsx(IT,{focus:t.section==="guides"})}),i.jsx(Ke,{id:"labels",children:i.jsx(Ee,{title:"Labels",children:i.jsxs("div",{className:"label-codes",children:[i.jsx("code",{children:jd}),i.jsxs("code",{children:[Z.labelPrefix,":<type>"]}),i.jsx("code",{children:Sd}),i.jsx("code",{children:Nd})]})})})]})}const kd=`${Z.apiPrefix}/projects`;async function Xi(e,t,n){const o=await fetch(`${kd}${e}`,{method:t,headers:{"Content-Type":"application/json"},body:n===void 0?void 0:JSON.stringify(n)}),a=await o.json().catch(()=>({}));if(!o.ok)throw new Error(a.error??`HTTP ${o.status}`);return a}const ms={url:kd,add:e=>Xi("","POST",{path:e}),remove:e=>Xi(`/${e}`,"DELETE"),setAutoRegister:e=>Xi("/settings","PUT",{autoRegister:e}),setShare:(e,t)=>Xi(`/${e}/share`,"PUT",{share:t}),answer:(e,t)=>Xi(`/${e}/answer`,"POST",t),async briefing(e){const t=await fetch(`${kd}/briefing?since=${e}`);return t.ok?await t.json():void 0}};function Kv(e){const[t,n]=y.useState(""),[o,a]=y.useState(),l=d=>{d.trim()&&(a(void 0),ms.add(d.trim()).then(()=>(n(""),e.onAdded()),h=>a(h.message)))};return i.jsxs("div",{className:"pj-add",children:[i.jsx(wa,{value:t,onValueChange:n,onSubmit:l,action:"Add project",placeholder:`/path/to/repo (a ${Z.dataDir} folder is created if missing)`,"aria-label":"Repo path",className:"t-code"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}const Ks=(e,t)=>e>0&&`${e} ${t}`;function m2(e){var n;const t=((n=e.briefing)==null?void 0:n.projects)??[];return!e.briefing||!t.length?null:i.jsxs("section",{className:"pj-section pj-briefing",children:[i.jsx(At,{title:"While you were away",count:t.length,info:`What changed in each project since ${hn(e.now-e.briefing.since)} ago`}),i.jsx("ul",{className:"pj-list",children:t.map(({projectId:o,project:a,briefing:l})=>i.jsx(be,{as:"li",edge:l.totals.waiting>0?"attention":"neutral",title:a,context:i.jsx(V,{parts:[Ks(l.totals.done,"done"),Ks(l.trails.reduce((d,h)=>d+h.opened.length,0),"new tickets"),Ks(l.totals.agentDecisions,"agent decisions"),Ks(l.totals.waiting,"waiting on you"),Ks(l.totals.ruledOut,"ruled out"),Ks(l.totals.active,"agents active")]}),onOpen:()=>e.onOpen(o)},o))})]})}function p2(e){const[t,n]=y.useState(""),[o,a]=y.useState(!1),[l,d]=y.useState(),h=f=>{!f.trim()||o||(a(!0),d(void 0),e.onAnswer(f.trim()).then(()=>n(""),p=>d(p.message)).finally(()=>a(!1)))};return i.jsxs("div",{className:"pj-answer",children:[i.jsx(wa,{value:t,onValueChange:n,onSubmit:h,action:"Answer",disabled:o,placeholder:"Your answer","aria-label":"Your answer"}),l&&i.jsx("span",{className:"vf-err",children:l})]})}function g2(e){const{item:t}=e,n=uv(t),o=t.kind==="question"&&t.agent?`${t.agent} asks`:cv[t.kind],a=t.urgency==="blocking"&&{text:"Blocking",urgent:!0,className:"urgency-tag"};return i.jsx(be,{as:"li",className:`att-item pj-item k-${t.kind}`,edge:dv(t,t.interrupting),title:t.title.split(`
|
|
153
|
+
`)[0],titleText:t.title,context:i.jsx(V,{parts:[a,{text:t.project,strong:!0},o]}),detail:n.length>0&&n.join(" · "),detailText:n.join(`
|
|
154
|
+
`),trailing:hn(e.now-t.since),onOpen:e.onOpen,below:e.onAnswer&&i.jsx(p2,{onAnswer:e.onAnswer})})}function v2(e){const t=e.view.attention,n=o=>{var a;return((a=e.view.projects.find(l=>l.id===o))==null?void 0:a.state.kind)!=="missing"};return i.jsxs("section",{className:"pj-section pj-attention",children:[i.jsx(At,{title:"Needs you",count:t.length,hot:t.some(o=>o.interrupting),info:"One queue across projects, ranked the way each project ranks its own. Answer questions here; the agent in that repo gets the answer."}),t.length===0&&i.jsx(Sn,{title:"Nothing needs you",hint:"Agents in every project can keep going."}),i.jsx("ul",{className:"pj-list",children:t.map(o=>i.jsx(g2,{item:o,now:e.now,onOpen:()=>e.onOpen(o.projectId,o.id),onAnswer:o.kind==="question"&&n(o.projectId)?a=>ms.answer(o.projectId,{questionId:o.ref,text:a}).then(e.onAnswered):void 0},`${o.projectId}/${o.id}`))})]})}const Hc=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`;function k2(e){return e.interrupting>0?"urgent":e.phases.blocked+e.phases.rework+e.flags+e.stalled>0||e.state.kind==="missing"?"attention":"neutral"}function y2(e){if(e.state.kind==="missing")return[{text:"Missing",strong:!0},{text:e.path,code:!0}];const t=[];e.needsYou&&t.push({text:`${e.needsYou} ${e.needsYou===1?"needs":"need"} you`,strong:!0,urgent:e.interrupting>0}),e.agents&&t.push(Hc(e.agents,"agent"));const{working:n,verifying:o,rework:a,blocked:l}=e.phases;n&&t.push(`${n} working`),o&&t.push(`${o} verifying`),a&&t.push(`${a} rework`),l&&t.push(`${l} blocked`),e.flags&&t.push(Hc(e.flags,"PR flag")),e.stalled&&t.push(Hc(e.stalled,"stalled claim")),t.length||t.push(e.trails?"Nothing waiting":"No trails yet");const d=w2(e.tracker);return d&&t.push(d),t}function w2(e){if(e.kind==="github"&&e.repo)return`Issues in ${e.repo}`;if(!(e.kind!=="linear"||!e.team))return e.org?`Linear: ${e.team} in ${e.org}`:`Linear: ${e.team}`}function x2(e){var t;return e.state.kind==="elsewhere"?e.state.url?`Served by another Lookout · ${e.state.url}`:"Served by another Teamtrail on this machine":((t=e.top)==null?void 0:t.title)??e.note??e.path}function Yo(e,t,n){if(e.state.kind!=="missing"){if(e.state.kind==="elsewhere"){const o=e.state.url?Nn(e.state.url):void 0;if(!o)return;const a=new URL(o);n&&a.searchParams.set(Ys,n),window.open(a.toString(),"_blank","noopener");return}location.href=p1({id:e.id,home:t,tracker:e.tracker.kind,item:n})}}function Vv(e){const{p:t}=e,n=x2(t);return i.jsx(be,{as:"li",className:`project-card st-${t.state.kind}`,edge:k2(t),selected:e.current,title:t.name,titleText:t.path,context:i.jsx(V,{parts:y2(t)}),detail:n,detailText:n,trailing:t.lastActivity?hn(e.now-t.lastActivity):void 0,onOpen:e.onOpen})}const Gv=`${ea}:projects:seen`,dp=24*36e5;function j2(e){try{const t=Number(localStorage.getItem(Gv));return t>0?t:e-dp}catch{return e-dp}}function S2(e){try{localStorage.setItem(Gv,String(e))}catch{}}function N2(){const[e,t]=y.useState();return y.useEffect(()=>{const n=Date.now();return ms.briefing(j2(n)).then(t).catch(()=>{}),()=>S2(n)},[]),e}function b2(e){const{view:t,reload:n}=e.projects,o=Xt(15e3),a=N2();if(y.useEffect(()=>{const f=p=>p.key==="Escape"&&e.onClose();return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[e]),!t)return null;const l=ur()??t.home,d=f=>{const p=t.projects.find(v=>v.id===f);(p==null?void 0:p.id)===l?e.onClose():p&&Yo(p,t.home)},h=(f,p)=>{const v=t.projects.find(k=>k.id===f);if(v){if(v.id!==l)return Yo(v,t.home,p);e.onClose(),e.onItemHere(p)}};return i.jsxs(Be,{className:`zone decisions-view projects-view dv-${e.bp}`,children:[i.jsxs("header",{className:"dv-head",children:[i.jsx(ze,{as:"h2",children:"All projects"}),i.jsx("span",{className:"dv-head-right",children:i.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})})]}),i.jsxs("div",{className:"pj-body",children:[i.jsx(v2,{view:t,now:o,onOpen:h,onAnswered:n}),i.jsxs("section",{className:"pj-section pj-projects",children:[i.jsx(At,{title:"Projects",count:t.projects.length,info:"Each repo registered on this machine, read from its own files. Nothing leaves your machine."}),i.jsx("ul",{className:"pj-list",children:t.projects.map(f=>i.jsx(Vv,{p:f,current:f.id===l,now:o,onOpen:f.state.kind==="missing"?void 0:()=>d(f.id)},f.id))}),i.jsx(Kv,{onAdded:n})]}),i.jsx(m2,{briefing:a,now:o,onOpen:d})]})]})}function $2(e){const[t,n]=y.useState(!1),o=y.useRef(null);y.useEffect(()=>{if(!t)return;const h=f=>{var p;(f instanceof KeyboardEvent?f.key==="Escape":!((p=o.current)!=null&&p.contains(f.target)))&&n(!1)};return window.addEventListener("mousedown",h),window.addEventListener("keydown",h),()=>{window.removeEventListener("mousedown",h),window.removeEventListener("keydown",h)}},[t]);const{view:a}=e.projects;if(!a||!e.projects.many)return i.jsx("span",{className:"repo",children:e.repo});const l=ur()??a.home,d=a.projects.filter(h=>h.id!==l).reduce((h,f)=>h+f.interrupting,0);return i.jsxs("div",{className:"project-switcher",ref:o,children:[i.jsxs("button",{className:"project-btn repo",onClick:()=>n(h=>!h),"aria-haspopup":"menu","aria-expanded":t,"data-tip":"Switch project, or see all of them",children:[i.jsx("span",{className:"project-name",children:e.repo}),d>0&&i.jsx(fs,{n:d,urgent:!0}),i.jsx("span",{className:"caret",children:"▾"})]}),t&&i.jsxs("div",{className:"trail-menu",role:"menu",children:[i.jsxs("button",{role:"menuitem",className:"trail-item all-projects",onClick:()=>{n(!1),e.onOverview()},children:[i.jsx("span",{className:"mi-title",children:"All projects"}),i.jsx(fs,{n:a.attention.length,urgent:a.attention.some(h=>h.interrupting),hideZero:!0})]}),i.jsx(ze,{variant:"plain",className:"menu-h",children:"Projects"}),a.projects.map(h=>i.jsxs("button",{role:"menuitem",className:`trail-item ${h.id===l?"on":""} st-${h.state.kind}`,disabled:h.state.kind==="missing",onClick:()=>{n(!1),h.id!==l&&Yo(h,a.home)},children:[i.jsx("span",{className:"mi-title",children:h.name}),i.jsx("span",{className:"mi-progress",children:C2(h.state.kind)}),i.jsx(fs,{n:h.needsYou,urgent:h.interrupting>0,hideZero:!0})]},h.id))]})]})}function C2(e){return e==="missing"?"missing":e==="elsewhere"?"other Lookout":""}function T2(e){const t=Xt(15e3),{view:n}=e.projects;if(!n||!e.projects.many)return null;const o=ur()??n.home;return i.jsxs("section",{className:"phone-projects",children:[i.jsx(At,{title:"Projects",count:n.projects.length,right:i.jsx(M,{size:"sm",variant:"ghost",onClick:e.onOverview,children:"All projects"})}),i.jsx("ul",{className:"pj-list",children:n.projects.filter(a=>a.id!==o).map(a=>i.jsx(Vv,{p:a,current:!1,now:t,onOpen:a.state.kind==="missing"?void 0:()=>Yo(a,n.home)},a.id))})]})}async function E2(){const e=await fetch(ms.url);return e.ok?await e.json():void 0}function qv(){const[e,t]=y.useState(),{reload:n,pushed:o}=Ye({load:E2,show:a=>a&&t(a)});return y.useEffect(()=>si("projects",a=>{o(),t(JSON.parse(a))}),[o]),{view:e,many:((e==null?void 0:e.projects.length)??0)>1,reload:n}}const A2=e=>[e.home&&{text:"This Lookout",strong:!0},e.state.kind==="missing"&&"Missing",{text:e.path,code:!0}];function I2(){const{view:e,reload:t}=qv(),[n,o]=y.useState();if(!e)return null;const a=l=>{o(void 0),l.then(t,d=>o(d.message))};return i.jsxs(Ee,{title:"Projects",children:[i.jsx("p",{className:"vf-intro",children:"Supervise several repos from this Lookout: All projects shows what needs you in each of them. The list lives in your config folder on this machine, never in a repo, and agents only ever work in their own repo. A project that shares its decisions offers them to agents in your other projects as suggestions, never as answers."}),i.jsx("ul",{className:"pj-list set-projects",children:e.projects.map(l=>i.jsx(be,{as:"li",edge:l.state.kind==="missing"?"attention":"neutral",title:l.name,context:i.jsx(V,{parts:A2(l)}),actions:i.jsxs(i.Fragment,{children:[i.jsx(M,{size:"sm",variant:"ghost",on:l.sharePrecedents,"aria-pressed":l.sharePrecedents,className:"share-precedents-toggle",title:"Offer this project's decisions as suggestions when agents look for precedents in your other projects",onClick:()=>a(ms.setShare(l.id,!l.sharePrecedents)),children:l.sharePrecedents?"Shares decisions":"Share decisions"}),!l.home&&i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>a(ms.remove(l.id)),children:"Remove"})]})},l.id))}),i.jsx(Kv,{onAdded:t}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Agents add their repo when they connect"}),i.jsx(M,{size:"sm",on:e.autoRegister,"aria-pressed":e.autoRegister,className:"auto-register-toggle",onClick:()=>a(ms.setAutoRegister(!e.autoRegister)),children:e.autoRegister?"On":"Off"})]}),i.jsx(V,{className:"set-hint",parts:[{text:`${Z.slug} projects add <path>`,code:!0},`--no-register or ${Z.noRegisterEnv} opts one agent out`]}),n&&i.jsx("span",{className:"vf-err",children:n})]})}const R2=`${Z.apiPrefix}/models`;async function M2(){const e=await fetch(R2);return e.ok?await e.json():null}function Yd(){const[e,t]=y.useState();return Ye({load:M2,show:t,failed:()=>t(null),changed:n=>n.endsWith("models.json")||n.endsWith("map.md")||n.includes("/tickets/"),events:{attention:()=>!0}}),e}function L2({mapId:e,ticketId:t}){const n=Yd(),o=n==null?void 0:n.waiting.find(a=>a.mapId===e&&a.ticketId===t);return o?i.jsx(be,{className:"model-wait d-section",edge:"attention",title:`Needs a ${o.tier} model`,context:i.jsx(V,{parts:[`Connected agents run ${o.best} at most`]}),detail:`Connect an agent on a ${o.tier} model, or have one claim ${o.ticketKey} by key.`}):null}function O2({view:e}){if(!e)return null;const t=`${Z.dataDir}/${e.file}`,n=Object.keys(e.models).length,o=e.agents.map(a=>`${a.agent} ${a.tier}`).join(", ");return i.jsxs(i.Fragment,{children:[i.jsx(V,{className:"set-hint",parts:[{text:t,code:!0},e.exists?`${n} of your own models`:"add new or custom models here","unknown models count as balanced"]}),o&&i.jsx(V,{className:"set-hint models-connected",parts:[`Connected now: ${o}`]}),e.errors.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[t," has errors, so only the built-in models count until it is fixed."]})]}),i.jsx("ul",{className:"vf-errors",children:e.errors.map(a=>i.jsx("li",{children:a},a))})]})]})}const ir={fast:"Fast",balanced:"Balanced",strongest:"Strongest"},P2={fast:"Haiku, mini and nano models",balanced:"Sonnet, GPT-4 models",strongest:"Opus, GPT-5 and o-series models"},_2=Do.map(e=>({value:e,label:ir[e],hint:P2[e]}));function D2(e){return i.jsx("div",{className:"tier-grid",children:na.map(t=>{const n=e.tiers[t],o=$d[t];return i.jsxs("div",{className:"tier-row",children:[i.jsx("span",{children:Zs[t]}),i.jsx(at,{compact:!0,"aria-label":`${Zs[t]} tickets' model`,className:`tier-select tier-${t}`,value:n,options:_2,onChange:a=>e.onChange(t,a)}),i.jsx(V,{className:"tier-hint",parts:[n!==o&&`default ${ir[o].toLowerCase()}`,e.hints[t]]})]},t)})})}const Lo=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function z2({rows:e}){return e.length?i.jsx("ul",{className:"perf-rows",children:e.map(t=>i.jsx(be,{as:"li",className:"perf-row",title:t.key,trailing:i.jsx("span",{title:"Median time from first claim to done",children:Qt(t.medianLeadMs)}),context:i.jsx(V,{parts:[`${t.done} of ${Lo(t.tickets,"ticket")} done`,t.cancelled>0&&`${t.cancelled} cancelled`,Lo(t.reworkCycles,"rework"),`reviews ${t.reviews.passed} passed, ${t.reviews.failed} failed`,t.answers>0&&Lo(t.answers,"question")]}),detail:t.findings.raised>0?`As reviewer: ${t.findings.upheld} of ${Lo(t.findings.raised,"finding")} upheld`:void 0},t.key))}):i.jsx(Ie,{children:"No claimed tickets yet"})}const up=e=>`${Math.round(e*100)}%`,B2=e=>e===void 0?void 0:`$${e.toFixed(2)} per verified`;function F2({r:e,minSample:t}){return i.jsx(be,{as:"li",className:"perf-row score-row",title:e.key,trailing:e.enough?i.jsxs("span",{title:"Verified on the first attempt",children:[up(e.firstTimeRate)," first time"]}):i.jsx("span",{className:"t-meta",title:`Compared from ${t} tickets`,children:"too few"}),context:i.jsx(V,{parts:[`${e.verified} of ${e.tickets} verified`,`${up(e.reworkRate)} rework`,e.attemptsPerVerified!==void 0&&`${e.attemptsPerVerified} attempts each`,B2(e.costPerVerifiedUsd),e.medianLeadMs!==void 0&&Qt(e.medianLeadMs)]}),detail:e.findings.error+e.findings.warn>0?`Review findings: ${e.findings.error} errors, ${e.findings.warn} warnings`:void 0})}async function U2(){const e=await fetch(`${pe()}/scorecard`);return e.ok?await e.json():null}function Qv(){const[e,t]=y.useState();return Ye({load:U2,show:t,failed:()=>t(null),events:{verification:()=>!0},changed:n=>n.includes("/tickets/")}),e}const W2=[{id:"byTypeAndModel",title:"Type × model"},{id:"byModel",title:"By model"},{id:"byVendor",title:"By vendor"},{id:"byAgent",title:"By agent"}];function H2(){const e=Qv(),[t,n]=y.useState("byTypeAndModel"),[o,a]=y.useState(!1);if(e==null)return null;const l=()=>void navigator.clipboard.writeText(ES(e)).then(()=>{a(!0),setTimeout(()=>a(!1),1500)});return i.jsxs("section",{className:"perf-section scorecard",children:[i.jsxs("div",{className:"score-head",children:[i.jsx(ze,{as:"h3",children:"Scorecard"}),i.jsx(M,{size:"sm",variant:"ghost",onClick:l,disabled:!e.tickets,children:o?"Copied":"Copy as Markdown"})]}),i.jsxs("p",{className:"perf-note t-meta",children:["How each model and agent does on your own tickets, from the checks Teamtrail ran. A ticket counts for whoever made its first completion. Groups under ",e.minSample," tickets show as too few and aren't compared."]}),i.jsx("div",{className:"choice-row compact",children:W2.map(d=>i.jsx(ot,{on:t===d.id,title:d.title,onClick:()=>n(d.id)},d.id))}),e[t].length?i.jsx("ul",{className:"perf-rows",children:e[t].map(d=>i.jsx(F2,{r:d,minSample:e.minSample},d.key))}):i.jsx(Ie,{children:"No completions yet. The scorecard fills in as agents finish verified tickets."})]})}function Yv(e){const[t,n]=y.useState({}),o=e.map(a=>`${a.map.id}:${a.tickets.reduce((l,d)=>Math.max(l,d.updatedAt),0)}`).join();return y.useEffect(()=>{let a=!0;return Promise.all(e.map(async l=>{const d=await fetch(`${pe()}/journal?mapId=${encodeURIComponent(l.map.id)}`).catch(()=>{}),h=d!=null&&d.ok?await d.json():{entries:[]};return[l.map.id,h.entries]})).then(l=>{a&&n(Object.fromEntries(l))}),()=>{a=!1}},[o]),t}const K2=[{id:"byVendor",title:"By vendor"},{id:"byAgent",title:"By agent"},{id:"byType",title:"By ticket type"}];function V2({api:e,bp:t,onClose:n}){const[o,a]=y.useState("byVendor"),l=y.useMemo(()=>Object.values(e.allSnaps),[e.allSnaps]),d=Yv(l),h=e.activity.answered,f=y.useMemo(()=>vg(l.map(p=>({snap:p,journal:d[p.map.id]??[],answered:h}))),[l,d,h]);return y.useEffect(()=>{const p=v=>v.key==="Escape"&&n();return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[n]),i.jsxs(Be,{className:`zone decisions-view perf-view dv-${t}`,children:[i.jsxs("header",{className:"dv-head",children:[i.jsx(ze,{as:"h2",children:"Trail stats"}),i.jsx(V,{parts:[`${f.trails} trails`,`${f.tickets} tickets`]}),i.jsx("span",{className:"dv-head-right",children:i.jsx("button",{className:"icon-btn",onClick:n,"aria-label":"Close",children:"×"})})]}),i.jsxs("div",{className:"perf-body",children:[i.jsxs("section",{className:"perf-section",children:[i.jsx(ze,{as:"h3",children:"What stands out"}),i.jsx("p",{className:"perf-note t-meta",children:"From your own numbers, for you to act on or ignore. Teamtrail doesn't route work from these."}),f.recommendations.length?i.jsx("ul",{className:"perf-recs",children:f.recommendations.map(p=>i.jsxs("li",{title:p.because,children:[i.jsx("span",{children:p.text}),i.jsx("span",{className:"t-meta",children:p.because})]},p.id))}):i.jsx(Ie,{children:"Nothing yet. This needs at least 5 results from two vendors to compare."})]}),i.jsx(H2,{}),i.jsxs("section",{className:"perf-section",children:[i.jsx("div",{className:"choice-row compact",children:K2.map(p=>i.jsx(ot,{on:o===p.id,title:p.title,onClick:()=>a(p.id)},p.id))}),i.jsx(z2,{rows:f[o]}),i.jsx("p",{className:"perf-note t-meta",children:"Spend is tracked per trail, so it isn't split by agent here."})]})]})]})}function G2(e){const t=Qv();if(!t)return null;const n=CS({scorecard:t,tiers:e.tiers,models:e.models});return n.length?i.jsx("ul",{className:"tier-suggestions",children:n.map(o=>i.jsxs("li",{children:[i.jsxs("span",{children:[Zs[o.type],": ",ir[o.tier].toLowerCase()," instead of ",ir[o.current].toLowerCase()]}),i.jsx("span",{className:"t-meta",children:o.because}),i.jsxs(M,{size:"sm",variant:"ghost",onClick:()=>e.onTake(o.type,o.tier),children:["Use ",ir[o.tier].toLowerCase()]})]},o.type))}):null}function q2(e,t){const n=Yv(e);return y.useMemo(()=>{var l;const o=vg(e.map(d=>({snap:d,journal:n[d.map.id]??[],answered:t}))),a={};for(const d of o.byType){if(!d.done)continue;const h=(l=o.recommendations.find(p=>p.id===`speed-${d.key}`))==null?void 0:l.text,f=[`Trail stats: ${d.done} done`,d.medianLeadMs!==void 0&&`median ${Qt(d.medianLeadMs)}`,d.reworkCycles>0&&`${d.reworkCycles} back to rework`,h];a[d.key]=f.filter(Boolean).join(" · ")}return a},[e,n,t])}function Q2(e){var h,f;const t=Yd(),n=q2(e.snaps,e.answered),o=e.map;if(!o)return null;const a=!!((h=o.modelMatching)!=null&&h.enabled),l=((f=o.modelMatching)==null?void 0:f.tiers)??{},d=(p,v)=>{const k={...l,[p]:v};v===$d[p]&&delete k[p],e.onChange({enabled:!0,tiers:k})};return i.jsxs(Ee,{title:"Model matching",children:[i.jsx("p",{className:"vf-intro",children:"Give each agent the tickets that fit the model it runs on: research to fast models, junctions, prototypes and reviews to the strongest. Teamtrail reads the model from the agent's log and never switches it. An agent can still claim any ticket by name, and tells you when it does."}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsxs("span",{className:"set-field-label",children:["Match work to models on trail ",o.key]}),i.jsx(M,{size:"sm",on:a,"aria-pressed":a,className:"model-matching-toggle",onClick:()=>e.onChange({...o.modelMatching,enabled:!a}),children:a?"On":"Off"})]}),a&&i.jsx(D2,{tiers:im(o),hints:n,onChange:d}),a&&i.jsx(G2,{tiers:im(o),models:t==null?void 0:t.models,onTake:d}),a&&i.jsx("span",{className:"set-hint t-meta",children:"Changes apply to the next claim; nothing running is interrupted."}),i.jsx(O2,{view:t})]})}function tr(e,t){const n=new URL(e);return n.searchParams.delete("settings"),t&&n.searchParams.set("settings",t.section??t.group??""),n.toString()}async function Y2(){const e=await fetch(`${pe()}/verification/config`);return e.ok?await e.json():null}function J2(){const[e,t]=y.useState();return Ye({load:Y2,show:t,failed:()=>t(null),changed:n=>n.endsWith("verification.json"),events:{attention:()=>!0}}),e}const hp=[{name:"test",command:"npm test"},{name:"lint",command:"npm run lint"},{name:"typecheck",command:"npm run typecheck"}];function X2(e){const t=e.config;return t?t.run.filter(n=>t.checks[n]).map(n=>({name:n,command:t.checks[n].run.join(" ")})):[]}const Z2=e=>e.trim().split(/\s+/).filter(Boolean);function eE({view:e}){const[t,n]=y.useState(()=>X2(e)),[o,a]=y.useState(!1),[l,d]=y.useState({kind:"idle"}),h=(v,k)=>n(t.map((w,j)=>j===v?{...w,...k}:w)),f=hp.filter(v=>!t.some(k=>k.name===v.name)),p=async()=>{var j;d({kind:"saving"});const v=t.filter(N=>N.name.trim()&&N.command.trim()).map(N=>({name:N.name.trim(),run:Z2(N.command)})),k=await fetch(`${pe()}/verification/config`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({checks:v,base:((j=e.approval)==null?void 0:j.base)??"none",acknowledged:!0})}).catch(()=>{}),w=await(k==null?void 0:k.json().catch(()=>({})));if(k!=null&&k.ok)return d({kind:"saved"});d({kind:"error",text:(w==null?void 0:w.error)??"The server didn't answer."})};return i.jsxs("div",{className:"vf-editor",children:[t.map((v,k)=>i.jsxs("div",{className:"vf-edit-row",children:[i.jsx("input",{"aria-label":"Name",value:v.name,placeholder:"name",onChange:w=>h(k,{name:w.target.value})}),i.jsx("input",{"aria-label":"Command",className:"t-code",value:v.command,placeholder:"npm test",onChange:w=>h(k,{command:w.target.value})}),i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>n(t.filter((w,j)=>j!==k)),children:"Remove"})]},k)),i.jsxs("div",{className:"vf-edit-add",children:[f.map(v=>i.jsxs(M,{size:"sm",variant:"ghost",onClick:()=>n([...t,v]),children:["+ ",v.command]},v.name)),i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>n([...t,{name:"",command:""}]),children:"+ Another"})]}),t.some(v=>!hp.some(k=>k.name===v.name))&&i.jsxs("p",{className:"vf-edit-hint t-meta",children:["Run from the repository's root, as words (no pipes or ",i.jsx("code",{children:"&&"}),"): the script must already be in the repo. For example ",i.jsx("code",{children:"npm run e2e"}),", ",i.jsx("code",{children:"make test"}),", ",i.jsx("code",{children:"./scripts/check.sh"})," ","or ",i.jsx("code",{children:"pytest -q"}),"."]}),i.jsxs("label",{className:"vf-edit-sure",children:[i.jsx("input",{type:"checkbox",checked:o,onChange:v=>a(v.target.checked)}),i.jsx("span",{children:"I know what these commands run, and approve them"})]}),i.jsxs("div",{className:"vf-edit-save",children:[i.jsx(M,{size:"sm",disabled:!o||l.kind==="saving",onClick:()=>void p(),children:l.kind==="saving"?"Saving…":"Save checks"}),l.kind==="saved"&&i.jsx("span",{className:"t-meta",children:"Saved and approved."}),l.kind==="error"&&i.jsx("span",{className:"vf-err",children:l.text})]})]})}function tE({config:e,file:t,hash:n}){return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line ok",title:n,children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[i.jsx("span",{className:"t-code",children:t})," · ",e.run.length," checks run on every completion"]})]}),i.jsx(V,{className:"set-hint",parts:[`New trails start at ${ar[e.default]}`,`${e.maxAttempts} attempts before it waits for you`,e.failFast&&"Stops at the first failure"]}),i.jsx("div",{className:"vf-checks",children:Object.entries(e.checks).map(([o,a])=>i.jsxs("div",{className:"vf-check",children:[i.jsx("span",{className:"t-code",children:e.run.includes(o)?o:`${o} (on request)`}),i.jsx("code",{children:a.run.join(" ")}),i.jsxs("span",{className:"dim",children:[a.timeoutSec," s",a.cwd&&a.cwd!=="."?` · in ${a.cwd}`:""]})]},o))})]})}const nE=[{value:"flag",title:"Show the reviewer",sub:"The proof and the review list them first"},{value:"fail",title:"Send back",sub:"The agent reverts them or says why it needs them"},{value:"human",title:"Ask me",sub:"The ticket waits for you to decide"}];function sE({view:e,local:t}){var h,f;const[n,o]=y.useState(),a=((h=e.config)==null?void 0:h.scope)??"flag",l=(f=e.approval)!=null&&f.waiting?"Approve the checks first.":void 0,d=async p=>{var w;o(void 0);const v=await fetch(`${pe()}/verification/scope`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:p,base:((w=e.approval)==null?void 0:w.base)??"none"})}).catch(()=>{});if(v!=null&&v.ok)return;const k=await(v==null?void 0:v.json().catch(()=>({})));o((k==null?void 0:k.error)??"The server didn't answer.")};return i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"set-field-label",children:"Changes outside the files an agent declared"}),i.jsx("div",{className:"choice-row vf-levels",children:nE.map(p=>i.jsx(ot,{on:a===p.value,title:p.title,sub:p.sub,disabled:!t||!!l,onClick:()=>void d(p.value)},p.value))}),i.jsxs("span",{className:"set-hint t-meta",children:["Agents say which files they'll change when they claim a ticket. Anything they change beyond that is code nobody asked for.",l?` ${l}`:"",t===!1?" Set on the machine Teamtrail runs on.":""]}),n&&i.jsx("span",{className:"vf-err",children:n})]})}function iE(e){var l;const{view:t,local:n,file:o}=e,a=t.config;return i.jsxs(i.Fragment,{children:[n&&i.jsx(eE,{view:t},((l=t.approval)==null?void 0:l.base)??"none"),!n&&!t.exists&&i.jsx("span",{className:"set-hint t-meta",children:"No checks yet. They're set on the machine Teamtrail runs on."}),!n&&a&&t.exists&&i.jsx(tE,{config:a,file:o,hash:t.hash}),a&&t.exists&&i.jsx(sE,{view:t,local:n})]})}function rE(e){var v;const t=J2(),n=Ca(),[o,a]=y.useState();if(!t)return null;const l=e.map,d=t.config,h=`${Z.dataDir}/${t.file}`,f=(l==null?void 0:l.verification)??"off",p=(d??tg).appliesTo.join(" and ");return i.jsxs(Ee,{title:"Verification",children:[i.jsxs("p",{className:"vf-intro",children:["When an agent says a ticket is done, Teamtrail can check the work before the ticket closes. This applies to"," ",p," tickets. Research, junction and prototype tickets close as soon as they are answered."]}),l&&i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"set-field-label",children:["How much checking for trail ",l.key]}),i.jsx("div",{className:"choice-row vf-levels",children:bd.map(k=>i.jsx(ot,{on:f===k,title:ar[k],sub:pv[k],onClick:()=>{a(void 0),fr.act({action:"level",mapId:l.id,level:k,by:St}).catch(w=>a(w.message))}},k))}),f!=="off"&&!d&&i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:"No working checks yet, so completions at this level stop and wait for you."})]}),o&&i.jsx("span",{className:"vf-err",children:o})]}),t.errors.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line alert",title:t.hash,children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[h," has errors. Completions that need checks wait for you until it is fixed."]})]}),i.jsx("ul",{className:"vf-errors",children:t.errors.map(k=>i.jsx("li",{children:k},k))})]}),((v=t.approval)==null?void 0:v.waiting)&&i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:["Its commands don't run on this machine until you approve them."," ",i.jsx("a",{href:tr(location.href,{group:"project",section:"approvals"}),children:"Review the commands"})]})]}),i.jsx(iE,{view:t,local:n,file:h}),i.jsxs("span",{className:"set-hint t-meta",children:["Saved here, checks are approved as you save them. A change to ",h," made in the repo, by an agent or a teammate, runs nothing until you approve it."]}),i.jsxs("span",{className:"set-hint t-meta",children:["Checks run on this machine as you, with no sandbox. Teamtrail passes them only the environment variables they need (more go in ",i.jsx("code",{children:"TEAMTRAIL_CHECK_ENV"}),"), but a check can still read your files (~/.aws, ~/.npmrc, ~/.ssh, ~/.kube, ~/.docker, the GitHub CLI's login, Teamtrail's own credentials) and use your SSH agent. That's why a changed check command needs your approval: you approve the command line, so read what it runs."]})]})}function oE({data:e}){const{map:t}=e;return i.jsxs(i.Fragment,{children:[t?i.jsx(Ke,{id:"mode",children:i.jsx(Ee,{title:`Trail ${t.key}`,children:i.jsx(WN,{value:t.mode,onChange:e.onMapMode})})}):i.jsx(Ie,{children:"Chart or pick a trail to set its mode, model matching and team."}),i.jsx(Ke,{id:"verification",storage:"repo",children:i.jsx(rE,{map:t})}),i.jsx(Ke,{id:"models",children:i.jsx(Q2,{map:t,snaps:e.snaps,answered:e.answered,onChange:e.onModelMatching})}),t&&i.jsx(Ke,{id:"team",children:i.jsx(RT,{map:t})})]})}const fp=10,Jv=[0,10,16,26,18,24,16,18,22,22,26],Xv=[0,1,1,1,2,2,4,4,4,5,5];function Zv(e){let t=(16*e+128)*e+64;if(e<2)return t;const n=Math.floor(e/7)+2;return t-=(25*n-10)*n-55,e>=7?t-36:t}const aE=e=>Jv[e],lE=e=>Xv[e],ek=e=>Math.floor(Zv(e)/8)-Jv[e]*Xv[e],tk=e=>e<10?8:16;function cE(e){if(e===1)return[];const t=Math.floor(e/7)+2,n=e*4+17,o=Math.ceil((e*4+4)/(t*2-2))*2,a=[6];for(let l=n-7;a.length<t;l-=o)a.splice(1,0,l);return a}function yd(e,t){let n=0;for(let o=7;o>=0;o--)n=n<<1^(n>>>7)*285,n^=(t>>>o&1)*e;return n}function dE(e){const t=new Array(e).fill(0);t[e-1]=1;let n=1;for(let o=0;o<e;o++){for(let a=0;a<t.length;a++)t[a]=yd(t[a],n),a+1<t.length&&(t[a]^=t[a+1]);n=yd(n,2)}return t}function uE(e,t){const n=t.map(()=>0);for(const o of e){const a=o^n.shift();n.push(0),t.forEach((l,d)=>n[d]^=yd(l,a))}return n}function hE(e,t){const n=[],o=(d,h)=>{for(let f=h-1;f>=0;f--)n.push(d>>>f&1)};o(4,4),o(e.length,tk(t));for(const d of e)o(d,8);const a=ek(t)*8;o(0,Math.min(4,a-n.length)),o(0,(8-n.length%8)%8);for(let d=236;n.length<a;d^=253)o(d,8);const l=[];for(let d=0;d<n.length;d+=8)l.push(n.slice(d,d+8).reduce((h,f)=>h<<1|f,0));return l}function fE(e,t){const n=hE(e,t),o=lE(t),a=aE(t),l=Math.floor(Zv(t)/8),d=o-l%o,h=Math.floor(l/o),f=dE(a),p=[];for(let k=0,w=0;k<o;k++){const j=n.slice(w,w+h-a+(k<d?0:1));w+=j.length;const N=uE(j,f);k<d&&j.push(0),p.push([...j,...N])}const v=[];for(let k=0;k<p[0].length;k++)for(let w=0;w<p.length;w++)(k!==h-a||w>=d)&&v.push(p[w][k]);return v}const mE=[(e,t)=>(e+t)%2===0,(e,t)=>t%2===0,e=>e%3===0,(e,t)=>(e+t)%3===0,(e,t)=>(Math.floor(e/3)+Math.floor(t/2))%2===0,(e,t)=>e*t%2+e*t%3===0,(e,t)=>(e*t%2+e*t%3)%2===0,(e,t)=>((e+t)%2+e*t%3)%2===0];function Kc(e,t){const n=mE[t];for(let o=0;o<e.size;o++)for(let a=0;a<e.size;a++)!e.fixed[o][a]&&n(a,o)&&(e.dark[o][a]=!e.dark[o][a])}function mp(e){let t=0,n=1;for(let a=1;a<=e.length;a++)a<e.length&&e[a]===e[a-1]?n++:(n>=5&&(t+=n-2),n=1);const o=e.map(a=>a?"1":"0").join("");for(const a of["00001011101","10111010000"])for(let l=o.indexOf(a);l>=0;l=o.indexOf(a,l+1))t+=40;return t}function pE(e){let t=0,n=0;for(let a=0;a<e.size;a++)t+=mp(e.dark[a]),t+=mp(e.dark.map(l=>l[a]));for(let a=0;a<e.size;a++)for(let l=0;l<e.size;l++){if(e.dark[a][l]&&n++,l===e.size-1||a===e.size-1)continue;const d=e.dark[a][l];d===e.dark[a][l+1]&&d===e.dark[a+1][l]&&d===e.dark[a+1][l+1]&&(t+=3)}const o=e.size*e.size;return t+Math.floor(Math.abs(n*20-o*10)/o)*10}const an=(e,t)=>(e>>>t&1)!==0;function Nt(e,t,n,o){e.dark[n][t]=o,e.fixed[n][t]=!0}function Vc(e,t,n){for(let o=-4;o<=4;o++)for(let a=-4;a<=4;a++){const l=t+a,d=n+o,h=Math.max(Math.abs(a),Math.abs(o));l>=0&&l<e.size&&d>=0&&d<e.size&&Nt(e,l,d,h!==2&&h!==4)}}function gE(e,t,n){for(let o=-2;o<=2;o++)for(let a=-2;a<=2;a++)Nt(e,t+a,n+o,Math.max(Math.abs(a),Math.abs(o))!==1)}function wd(e,t){const n=0|t;let o=n;for(let l=0;l<10;l++)o=o<<1^(o>>>9)*1335;const a=(n<<10|o)^21522;for(let l=0;l<=5;l++)Nt(e,8,l,an(a,l));Nt(e,8,7,an(a,6)),Nt(e,8,8,an(a,7)),Nt(e,7,8,an(a,8));for(let l=9;l<15;l++)Nt(e,14-l,8,an(a,l));for(let l=0;l<8;l++)Nt(e,e.size-1-l,8,an(a,l));for(let l=8;l<15;l++)Nt(e,8,e.size-15+l,an(a,l));Nt(e,8,e.size-8,!0)}function vE(e,t){if(t<7)return;let n=t;for(let a=0;a<12;a++)n=n<<1^(n>>>11)*7973;const o=t<<12|n;for(let a=0;a<18;a++){const l=e.size-11+a%3,d=Math.floor(a/3);Nt(e,l,d,an(o,a)),Nt(e,d,l,an(o,a))}}function kE(e){const t=e*4+17,n=()=>Array.from({length:t},()=>new Array(t).fill(!1)),o={size:t,dark:n(),fixed:n()};for(let d=0;d<t;d++)Nt(o,6,d,d%2===0),Nt(o,d,6,d%2===0);Vc(o,3,3),Vc(o,t-4,3),Vc(o,3,t-4);const a=cE(e),l=a.length-1;for(let d=0;d<=l;d++)for(let h=0;h<=l;h++)d===0&&h===0||d===0&&h===l||d===l&&h===0||gE(o,a[d],a[h]);return wd(o,0),vE(o,e),o}function yE(e){const t=[];for(let n=e-1;n>=1;n-=2){const o=n<=6?n-1:n,a=(o+1&2)===0;for(let l=0;l<e;l++){const d=a?e-1-l:l;t.push([o,d],[o-1,d])}}return t}function wE(e,t){let n=0;for(const[o,a]of yE(e.size))e.fixed[a][o]||n>=t.length*8||(e.dark[a][o]=an(t[n>>>3],7-(n&7)),n++)}function xE(e){const t=new TextEncoder().encode(e);let n=1;for(;n<=fp&&4+tk(n)+t.length*8>ek(n)*8;)n++;if(n>fp)return;const o=kE(n);wE(o,fE(t,n));let a=0,l=1/0;for(let d=0;d<8;d++){Kc(o,d),wd(o,d);const h=pE(o);h<l&&([a,l]=[d,h]),Kc(o,d)}return Kc(o,a),wd(o,a),o.dark}const Gc=4;function jE(e){const t=xE(e.text);if(!t)return null;const n=t.length+Gc*2,o=t.flatMap((a,l)=>a.map((d,h)=>d?`M${h+Gc} ${l+Gc}h1v1h-1z`:"")).join("");return i.jsxs("svg",{className:"si-qr",viewBox:`0 0 ${n} ${n}`,role:"img","aria-label":e.label,shapeRendering:"crispEdges",children:[i.jsx("rect",{width:n,height:n,fill:"#fff"}),i.jsx("path",{d:o,fill:"#000"})]})}function SE(e){const t=Xt(1e3),n=Math.max(0,Math.ceil((e.device.expiresAt-t)/6e4)),o=e.device.links[0];return e.device.expiresAt<=t?i.jsxs("div",{className:"si-code",children:[i.jsx("p",{className:"t-meta",children:"That code expired. Make a new one when the device is ready."}),i.jsx(M,{size:"sm",onClick:e.onDone,children:"Done"})]}):i.jsxs("div",{className:"si-code",children:[o&&i.jsx(jE,{text:o,label:"QR code that pairs another device"}),i.jsxs("div",{className:"si-code-words",children:[i.jsx("span",{className:"si-code-value t-code","aria-label":"Pairing code",children:e.device.code}),i.jsx(V,{parts:["Works once",`expires in ${n} min`]}),i.jsxs("p",{className:"t-meta si-note",children:["Scan it with the device’s camera, or open"," ",o?i.jsx("code",{className:"t-code",children:o.split("#")[0]}):"the Lookout"," there and type the code."]}),i.jsx(M,{size:"sm",onClick:e.onDone,children:"Done"})]})]})}function NE(e){const[t,n]=y.useState();return e.device?i.jsx(SE,{device:e.device,onDone:e.onDone}):e.lan.length?i.jsxs("div",{className:"si-pair",children:[i.jsx(M,{onClick:async()=>n(await e.onPair()),children:"Pair a device"}),t&&i.jsx("span",{className:"vf-err",children:t})]}):i.jsxs("p",{className:"t-meta si-note",children:["This Lookout listens on this machine only, so no other device can reach it. To pair a phone or another computer, start it with ",i.jsxs("code",{className:"t-code",children:[Z.slug," --host 0.0.0.0"]})," on a network you trust. Another browser on this machine: run ",i.jsxs("code",{className:"t-code",children:[Z.slug," pair"]}),"."]})}function bE(e){const[t,n]=y.useState(!1),[o,a]=y.useState(!1),[l,d]=y.useState(),h=async()=>{a(!0),d(await e.onRevoke().catch(f=>f.message)),a(!1),n(!1)};return t?i.jsxs("span",{className:"ra-revoke ask",children:[i.jsx("span",{className:"t-meta",children:"It’s signed out now."}),i.jsxs(M,{size:"sm",disabled:o,onClick:h,children:["Revoke ",e.name]}),i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>n(!1),children:"Keep"})]}):i.jsxs("span",{className:"ra-revoke",children:[i.jsx(M,{size:"sm","aria-label":`Revoke ${e.name}`,onClick:()=>n(!0),children:"Revoke"}),l&&i.jsx("span",{className:"vf-err",children:l})]})}const $E={machine:"This machine",device:"Another device"};function CE(e){const t=Date.now();return i.jsx("ul",{className:"ra-list si-list",children:e.sessions.map(n=>i.jsx(be,{as:"li",className:"ra-row",title:n.current?`${n.name} · this browser`:n.name,titleText:n.name,context:i.jsx(V,{parts:[$E[n.kind],n.via==="opened-page"?`From the page ${Z.name} opened`:void 0,n.via==="opened-page"?{text:z0(n.id),code:!0}:void 0,`Paired ${Go(n.pairedAt,t)}`,`Last used ${Go(n.lastUsedAt,t)}`]}),below:n.current?void 0:i.jsx(bE,{name:n.name,onRevoke:()=>e.onRevoke(n.id)})},n.id))})}function TE(){return i.jsxs("div",{className:"ra-notes",children:[i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"What it stops."})," A program on this machine, or a device on your network, that isn’t a paired browser: an agent with ",i.jsx("code",{children:"curl"})," can’t approve its own work, answer its own questions or change your settings through the Lookout. The session lives only in this page’s own storage and is sent only by this page, never as a cookie, so another server on this machine (an agent’s dev server on another port) gets nothing from your browser; and it goes only to a server that first proves it is this Lookout, so one that takes its port while the Lookout is stopped gets nothing either. A device paired here can read, answer and approve, but never change what runs on this machine or whom it trusts."]}),i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"What it can’t stop."})," A program that can read ",Z.name,"’s config folder can make a pairing code, and one that can read your browser’s profile on disk can copy a session. Keep agents out of both:"," ",i.jsxs("code",{children:[Z.slug," connect"]})," sets that up for the agents it registers."]})]})}const nk=`${Z.apiPrefix}/sign-in`;async function qc(e,t={}){const n=await fetch(`${nk}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return{ok:n.ok,reply:await n.json().catch(()=>({}))}}function EE(){const[e,t]=y.useState(),[n,o]=y.useState(),a=y.useCallback(()=>{fetch(`${nk}/sessions`).then(async f=>f.ok?await f.json():(await f.json().catch(()=>({}))).elsewhere?"elsewhere":null).then(t,()=>t(null))},[]);y.useEffect(a,[a]);const l=y.useCallback(async()=>{const{ok:f,reply:p}=await qc("/codes");if(!f)return p.error??"No code could be made.";o(p)},[]),d=y.useCallback(async f=>{const{ok:p,reply:v}=await qc("/revoke",{id:f});return a(),p?void 0:v.error??"That browser could not be revoked."},[a]),h=y.useCallback(async()=>{await qc("/sign-out"),Fg(),location.reload()},[]);return{view:e,device:n,closeDevice:()=>(o(void 0),a()),pairDevice:l,revoke:d,signOut:h}}function AE(){const{view:e,device:t,closeDevice:n,pairDevice:o,revoke:a,signOut:l}=EE();if(!e)return null;const d=i.jsx("div",{className:"si-signout",children:i.jsx(M,{size:"sm",variant:"ghost",onClick:l,children:"Sign out of this browser"})});return e==="elsewhere"?i.jsxs(Ee,{title:"Browsers & devices",children:[i.jsx("p",{className:"vf-intro",children:"This device is paired with the Lookout. Browsers and devices are paired and revoked on the machine it runs on."}),d]}):i.jsxs(Ee,{title:"Browsers & devices",children:[i.jsx("p",{className:"vf-intro",children:"Every browser that opens this Lookout is paired, and stays signed in while it runs (up to 30 days after it was last used). Revoke one and it’s signed out at once. When the Lookout restarts, browsers and devices pair again: the link is in the terminal where it starts."}),i.jsx(CE,{sessions:e.sessions,onRevoke:a}),i.jsx(NE,{lan:e.lan,device:t,onPair:o,onDone:n}),d,i.jsx(TE,{})]})}function IE({managed:e}){const{signOut:t,pages:n}=e;return i.jsxs(Ee,{title:"Signed in",children:[i.jsxs("p",{className:"vf-intro",children:["Signed in as ",e.name,". Sign-in is managed by the server this Lookout runs on."]}),n.length||e.home?i.jsxs("div",{className:"choice-row",children:[e.home&&i.jsxs(M,{size:"sm",onClick:()=>location.assign(e.home.href),children:["← ",e.home.label]}),n.map(o=>i.jsx(M,{size:"sm",onClick:()=>location.assign(o.href),children:o.label},o.href))]}):null,t?i.jsx("div",{className:"si-signout",children:i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>location.assign(t),children:"Sign out"})}):null]})}function RE(){return y.useEffect(()=>{const e=setInterval(()=>void ga().then(t=>t!=="failed"&&location.reload()),3e3);return()=>clearInterval(e)},[]),i.jsx("div",{className:"pair-page",children:i.jsxs(Be,{as:"main",className:"pair-card",children:[i.jsx("div",{className:"onb-brand",children:i.jsx(xa,{className:"onb-title"})}),i.jsxs("h1",{className:"t-heading pair-title",children:[Z.name," isn’t running here"]}),i.jsxs("p",{className:"t-body pair-step",children:["Start it with ",i.jsx("code",{className:"t-code",children:Z.slug})," on the machine it runs on. This page reconnects once the Lookout answers as itself; until then it sends nothing to this address."]})]})})}async function Jd(e){const t=await fetch(`${Z.apiPrefix}/pair`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e})}).catch(()=>{});if(!t)return"The Lookout didn’t answer. Try again.";const n=await t.json().catch(()=>({}));if(!t.ok)return n.error??"That code didn’t work. Get a new one.";n.id&&n.session&&n.verifier&&_1({id:n.id,secret:n.session,verifier:n.verifier})}function ME(e){const[t,n]=y.useState(!1),o=async()=>{n(!0);const a=await Jd(e.code);if(!a)return location.reload();n(!1),e.onFailed(a)};return i.jsxs("div",{className:"pair-confirm",children:[i.jsxs("p",{className:"t-body pair-step",children:["This link signs this browser in to the Lookout. Use it only if it came to you from"," ",i.jsx("code",{className:"t-code",children:Z.slug}),", ",i.jsxs("code",{className:"t-code",children:[Z.slug," pair"]})," or Pair a device in the Lookout’s Settings."]}),i.jsx("div",{children:i.jsx(M,{variant:"primary",disabled:t,onClick:o,children:"Sign in this browser"})})]})}function pp(){const[e,t]=y.useState(""),[n,o]=y.useState(!1),[a,l]=y.useState(),d=async()=>{if(!e.trim()||n)return;o(!0);const h=await Jd(e);o(!1),l(h),h||location.reload()};return i.jsxs("form",{className:"pair-device",onSubmit:h=>{h.preventDefault(),d()},children:[i.jsxs("p",{className:"t-body pair-step",children:["On a phone or another computer: in the Lookout on the machine ",Z.name," runs on, open Settings → You → Browsers & devices → Pair a device. Then type the code here, or scan it with this device’s camera."]}),i.jsxs("div",{className:"pair-code-row",children:[i.jsx("input",{className:"pair-code-input t-code",value:e,onChange:h=>t(h.target.value),placeholder:"ABCD-EFGH","aria-label":"Pairing code",autoComplete:"one-time-code",autoCapitalize:"characters",spellCheck:!1,maxLength:20}),i.jsx(M,{type:"submit",variant:"primary",disabled:n||!e.trim(),children:"Pair"})]}),a&&i.jsx("p",{className:"vf-err",role:"alert",children:a})]})}function gp(){return i.jsxs("p",{className:"t-body pair-step pair-here",children:["On the machine ",Z.name," runs on, run ",i.jsxs("code",{className:"t-code",children:[Z.slug," pair"]}),": it opens a tab ready to sign in, with one click. Or open the Sign in link ",i.jsx("code",{className:"t-code",children:Z.slug})," printed in its terminal."]})}function LE(e){return i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"t-body pair-step",children:"The Lookout opens only in browsers you’ve paired."}),e.local?i.jsx(gp,{}):i.jsx(pp,{}),e.local?i.jsx(pp,{}):i.jsx(gp,{})]})}function OE(e){const[t,n]=y.useState(),[o,a]=y.useState(e.code),[l,d]=y.useState(e.code);e.code!==l&&(d(e.code),a(e.code));const h=f=>(n(f),a(void 0));return i.jsx("div",{className:"pair-page",children:i.jsxs(Be,{as:"main",className:"pair-card",children:[i.jsx("div",{className:"onb-brand",children:i.jsx(xa,{className:"onb-title"})}),i.jsx("h1",{className:"t-heading pair-title",children:"Pair this browser"}),t&&i.jsx("p",{className:"pair-problem t-body",role:"alert",children:t}),o?i.jsx(ME,{code:o,onFailed:h}):i.jsx(LE,{local:e.local})]})})}function vp(){const e=/(?:^#|&)pair=([A-Za-z0-9_-]{1,64})/.exec(location.hash);if(e)return history.replaceState(null,"",`${location.pathname}${location.search}`),e[1]}async function kp(){try{const e=await fetch(`${Z.apiPrefix}/session`,{cache:"no-store"});if(!e.ok)return{kind:"no-server"};const t=await e.json();return typeof t.signedIn!="boolean"?{kind:"no-server"}:t.signedIn&&A1(t)?{kind:"signed-in"}:{kind:"signed-out",local:t.local===!0}}catch{return{kind:"no-server"}}}async function PE(){if(!Od())return kp();const e=await ga();return e==="proven"?{kind:"signed-in"}:e==="unknown"?kp():{kind:"not-running"}}function _E(){const[e,t]=y.useState({kind:"checking"});return y.useEffect(()=>void PE().then(t),[]),y.useEffect(()=>D1(n=>n==="failed"&&t({kind:"not-running"})),[]),e}function DE({children:e}){const t=_E(),[n,o]=y.useState(vp);return y.useEffect(()=>{const a=()=>o(l=>vp()??l);return window.addEventListener("hashchange",a),()=>window.removeEventListener("hashchange",a)},[]),y.useEffect(()=>{t.kind==="signed-in"&&n&&Jd(n)},[t.kind,n]),t.kind==="checking"?null:t.kind==="signed-out"?i.jsx(OE,{local:t.local,code:n}):t.kind==="not-running"?i.jsx(RE,{}):i.jsx(i.Fragment,{children:e})}function zE(){const e=ft();return e?i.jsx(IE,{managed:e}):i.jsx(Ke,{id:"devices",storage:"machine",children:i.jsx(AE,{})})}const BE=[{value:"auto",title:"Match my system"},{value:"day",title:"Day"},{value:"night",title:"Night"}];function FE(e){return i.jsx("div",{className:"choice-row compact",children:BE.map(t=>i.jsx(ot,{on:e.value===t.value,title:t.title,onClick:()=>e.onChange(t.value)},t.value))})}function UE({data:e}){var o;const{prefs:t,update:n}=e;return i.jsxs(i.Fragment,{children:[i.jsx(Ke,{id:"appearance",storage:"browser",children:i.jsxs(Ee,{title:"Appearance",children:[Yg()?i.jsx("p",{className:"vf-intro",children:"Follows the theme you picked in your account on the server. Change it from your name in its menu."}):i.jsx(FE,{value:Jg(t.theme),onChange:a=>n({theme:a})}),((o=ft())==null?void 0:o.themeSave)&&i.jsx("p",{className:"vf-intro",children:"Saved to your account, so the server's pages follow it."})]})}),i.jsx(Ke,{id:"transcript",storage:"browser",children:i.jsx(Ee,{title:"HITL transcript",children:i.jsx(Nv,{value:t.hitlTranscript,onChange:a=>n({hitlTranscript:a})})})}),i.jsx(Ke,{id:"agent",children:i.jsx(Ee,{title:"Agent",children:i.jsx("div",{className:"choice-row",children:Tg.map(a=>i.jsx(ot,{on:a.status==="primary",disabled:a.status!=="primary",title:a.name},a.id))})})}),i.jsx(zE,{})]})}function WE(e){const{data:t,route:n}=e;switch(e.group){case"trail":return i.jsx(oE,{data:t});case"project":return i.jsx(f2,{data:t,route:n});case"alerts":return i.jsx(UC,{data:t,route:n});case"you":return i.jsx(UE,{data:t});case"projects":return i.jsx(Ke,{id:"projects",storage:"machine",children:i.jsx(I2,{})});case"about":return i.jsx(Ke,{id:"changelog",children:i.jsx(qC,{})});default:return e.group}}function HE(e){const{group:t,route:n}=e,o=y.useRef(null),a=y.useRef(null);return y.useEffect(()=>{var d,h;(d=o.current)==null||d.focus({preventScroll:!0});const l=n.section&&document.getElementById(`settings-${n.section}`);l?l.scrollIntoView({block:"start"}):(h=a.current)==null||h.scrollTo({top:0})},[t.id,n.section]),i.jsx("div",{className:"sp-pane",ref:a,children:i.jsxs("div",{className:"sp-pane-in",children:[i.jsxs("header",{className:"sp-pane-head",children:[i.jsx("h2",{className:"sp-title t-title",ref:o,tabIndex:-1,children:t.label}),i.jsx("p",{className:"sp-intro t-meta",children:t.intro})]}),i.jsx(WE,{group:t.id,data:e.data,route:n})]})})}function KE(e){return i.jsx("nav",{className:"sp-nav","aria-label":"Settings groups",children:i.jsx("ul",{children:lr.map(t=>{const n=t.id===e.current;return i.jsx(be,{as:"li",className:"sp-nav-row",selected:n,current:n?"page":void 0,title:t.label,context:i.jsx(V,{parts:t.sections.map(o=>o.title)}),trailing:e.drill&&"›",onOpen:()=>e.onPick(t.id)},t.id)})})})}function VE(e,t){return e.group?lr.find(n=>n.id===e.group):t==="mobile"?void 0:lr[0]}const GE={page:"Back to the Lookout",list:"Lookout",group:"Settings"},qE=(e,t)=>e?t?"group":"list":"page";function QE(e){const{bp:t,route:n}=e,o=t==="mobile",a=VE(n,t),l=qE(o,!!a),d=Ca()===!1,h=()=>l==="group"?e.onShow({}):e.onClose();y.useEffect(()=>{const v=k=>{k.key!=="Escape"||k.defaultPrevented||document.querySelector(".scrim")||(l==="group"?e.onShow({}):e.onClose())};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[l,e]);const f=v=>e.onShow({group:v}),p=l!=="group"&&i.jsx(KE,{current:a==null?void 0:a.id,onPick:f,drill:o});return i.jsxs(Be,{className:`zone decisions-view settings-page sp-${t}`,"aria-label":"Settings",children:[i.jsxs("header",{className:"dv-head",children:[i.jsxs("button",{className:"back",onClick:h,children:["‹ ",GE[l]]}),l!=="group"&&i.jsx(ze,{as:"h2",children:"Settings"}),!o&&i.jsx("span",{className:"dv-head-right t-meta",children:"Esc"})]}),d&&i.jsx(AC,{}),i.jsxs("div",{className:"sp-body",children:[p,a&&i.jsx(HE,{group:a,data:e.data,route:n})]})]})}function YE(e){var a;const{rt:t,api:n,settings:o}=e;return o.route?i.jsx(QE,{bp:e.bp,route:o.route,onShow:o.show,onClose:o.close,data:{prefs:e.prefs,update:e.update,activeTracker:t.kind,location:t.adapter.location,map:(a=n.snap)==null?void 0:a.map,onMapMode:n.actions.setMode,snaps:Object.values(n.allSnaps),answered:n.activity.answered,onModelMatching:n.actions.setModelMatching}}):null}function JE(e){return i.jsxs(Be,{className:"zone side",style:{gridArea:"inspector"},children:[i.jsx(SN,{className:"zone-tabs",value:e.tab,onChange:e.onTab,items:[{id:"ticket",label:"Ticket"},{id:"activity",label:"Activity"},{id:"plan",label:"Plan",n:e.unspecified}]}),{ticket:e.ticket,activity:e.activity,plan:e.plan}[e.tab]]})}function sk(e){return e.filter(t=>t.state!=="out-of-scope").map(t=>({x:t.x,y:t.y,w:Ve,h:Qe}))}function XE(e){const{obstacles:t,from:n,to:o,clear:a}=e,l=t.flatMap(h=>[h.y-28,h.y+h.h+28]).filter(a),d=h=>Math.abs(h-n)+Math.abs(h-o);return l.reduce((h,f)=>d(f)<d(h)?f:h,l[0]??n)}const ZE=6;function eA(e){const t=e.filter((a,l)=>l===0||a.x!==e[l-1].x||a.y!==e[l-1].y);let n=`M${t[0].x} ${t[0].y}`;for(let a=1;a<t.length-1;a++){const[l,d,h]=[t[a-1],t[a],t[a+1]],f=Math.min(ZE,yp(l,d)/2,yp(d,h)/2),p=wp(d,l,f),v=wp(d,h,f);n+=`L${p.x} ${p.y}Q${d.x} ${d.y} ${v.x} ${v.y}`}const o=t[t.length-1];return`${n}L${o.x} ${o.y}`}function yp(e,t){return Math.abs(e.x-t.x)+Math.abs(e.y-t.y)}function wp(e,t,n){return{x:e.x+Math.sign(t.x-e.x)*n,y:e.y+Math.sign(t.y-e.y)*n}}function Jo(e){const t=e.direction==="TB",n=d=>t?{x:d.y,y:d.x}:d,o=n(e.a),a=n(e.b),l=e.obstacles.map(d=>t?{x:d.y,y:d.x,w:d.h,h:d.w}:d);return eA(tA({a:o,b:a,obstacles:l,gap:e.gap}).map(n))}function tA({a:e,b:t,obstacles:n,gap:o}){const a=n.filter(p=>p.x+p.w>e.x+1&&p.x<t.x-1),l=p=>!a.some(v=>p>v.y-8&&p<v.y+v.h+8),d=Math.min(e.x+o/2,(e.x+t.x)/2),h=Math.max(t.x-o/2,(e.x+t.x)/2);if(l(e.y))return[e,{x:h,y:e.y},{x:h,y:t.y},t];if(l(t.y))return[e,{x:d,y:e.y},{x:d,y:t.y},t];const f=XE({obstacles:a,from:e.y,to:t.y,clear:l});return[e,{x:d,y:e.y},{x:d,y:f},{x:h,y:f},{x:h,y:t.y},t]}function nA(e){if(e.direction==="LR"){const n=e.width+96;return{x:n,y:e.graphH/2,right:n+34,bottom:e.height}}const t=e.graphH+76;return{x:e.width/2,y:t,right:e.width,bottom:Math.max(e.height,t+40)}}function sA(e,t){const n=new Set(e.edges.map(l=>l.from)),o=e.nodes.filter(l=>l.state!=="out-of-scope"&&!n.has(l)),a=sk(e.nodes);return o.map(l=>{if(e.direction==="LR"){const f={x:l.x+Ve,y:l.y+Qe/2},p={x:t.x-30,y:t.y};return Jo({direction:"LR",a:f,b:p,obstacles:a,gap:96})}const d={x:l.x+Ve/2,y:l.y+Qe},h={x:t.x,y:t.y-30};return Jo({direction:"TB",a:d,b:h,obstacles:a,gap:48})})}function iA({x:e,y:t,text:n}){const o=n!=null&&n.trim()?`Destination
|
|
155
|
+
${n.trim()}`:`Destination
|
|
156
|
+
Where this trail ends`;return i.jsxs("g",{className:"destination",transform:`translate(${e} ${t})`,"aria-label":o,"data-tip":o,tabIndex:0,children:[i.jsx("rect",{className:"x-hit",x:-24,y:-24,width:48,height:48}),i.jsx("path",{className:"x-stroke",d:"M-15 -16 C-9 -10 2 4 16 17"}),i.jsx("path",{className:"x-stroke",d:"M17 -15 C8 -8 -6 5 -16 17"})]})}function rA({trails:e}){return e.map(t=>i.jsx("path",{className:"edge edge-open edge-destination",d:t},t))}function oA(){return i.jsxs("defs",{children:[i.jsx("pattern",{id:"map-grid",width:"40",height:"40",patternUnits:"userSpaceOnUse",children:i.jsx("path",{d:"M40 0H0V40",fill:"none",stroke:"var(--map-grid)",strokeWidth:"1"})}),i.jsx("pattern",{id:"hatch-oos",width:"10",height:"10",patternUnits:"userSpaceOnUse",patternTransform:"rotate(45)",children:i.jsx("line",{x1:"0",y1:"0",x2:"0",y2:"10",stroke:"var(--line2)",strokeWidth:"1"})})]})}const Xo=(e,t)=>`${e}>${t}`;function aA(e,t,n=[]){const o=new Map(e.tickets.map(l=>[l.id,l]));return{tickets:t.nodes.map(l=>{const d=o.get(l.id);return d?{...d,blockedBy:[...l.blockedBy,...l.removedEdges??[]]}:{id:l.id,key:"+",title:l.title,type:l.type,body:"",state:"open",blockedBy:l.blockedBy,comments:[],createdAt:e.map.updatedAt,updatedAt:e.map.updatedAt}}),marks:new Map(t.nodes.map(l=>[l.id,l.mark])),newEdges:new Set(t.nodes.flatMap(l=>l.newEdges.map(d=>Xo(d,l.id)))),removedEdges:new Set(t.nodes.flatMap(l=>(l.removedEdges??[]).map(d=>Xo(d,l.id)))),frozen:new Set(n)}}function lA(e,t){const n=tj({...e,tickets:t}),o=new Set;for(let a=1;a<n.length;a++)o.add(Xo(n[a-1].id,n[a].id));return o}const xp={LR:130,TB:68};function cA(e){const{direction:t,from:n,to:o,cards:a}=e;if(t==="LR"){const h={x:n.x+Ve,y:n.y+Qe/2},f={x:o.x,y:o.y+Qe/2};return Jo({direction:t,a:h,b:f,obstacles:a,gap:xp.LR})}const l={x:n.x+Ve/2,y:n.y+Qe},d={x:o.x+Ve/2,y:o.y};return Jo({direction:t,a:l,b:d,obstacles:a,gap:xp.TB})}function dA(e){const{from:t,to:n,direction:o}=e,l=["edge",t.ticket.state!=="open"?"edge-done":"edge-open"];return e.critical&&l.push("edge-critical"),e.added&&l.push("edge-added"),e.removed&&l.push("edge-removed"),i.jsx("path",{className:l.join(" "),d:cA({direction:o,from:t,to:n,cards:e.cards})})}function uA(e){const{snap:t,tickets:n,direction:o,preview:a}=e,l=y.useMemo(()=>lA(t,n),[t,n]),d=y.useMemo(()=>sk(e.nodes),[e.nodes]);return e.edges.map(({from:h,to:f})=>{const p=Xo(h.ticket.id,f.ticket.id);return i.jsx(dA,{from:h,to:f,direction:o,cards:d,critical:l.has(p),added:a==null?void 0:a.newEdges.has(p),removed:a==null?void 0:a.removedEdges.has(p)},p)})}const Xd=24,hA=13,fA=9.5;function mA(e){const t=e.guide;return i.jsx("g",{className:"meta",transform:`translate(${Xd} ${e.y})`,children:e.chips.map((n,o)=>{const a=n.kind==="guide"?t:void 0;return i.jsxs("g",{className:Ge("card-chip",n.kind,n.kind==="state"&&e.tone,(a==null?void 0:a.off)&&"off"),"data-guide-id":a==null?void 0:a.id,transform:`translate(${n.x} 0)`,children:[a&&i.jsx("title",{children:a.tip}),i.jsx("rect",{width:n.w,height:hA,rx:3}),i.jsx("text",{x:(n.w-n.textW)/2,y:fA,textLength:n.textW,lengthAdjust:"spacingAndGlyphs",children:n.text})]},o)})})}const ik=5,pA={sans:"9.5px 'Figtree Variable', system-ui, sans-serif",mono:"8.55px 'JetBrains Mono Variable', ui-monospace, monospace"};let Zi;function gA(){if(Zi!==void 0)return Zi;try{Zi=typeof document>"u"?null:document.createElement("canvas").getContext("2d")}catch{Zi=null}return Zi}function vA(e,t="sans"){const n=gA();return n?(n.font=pA[t],n.measureText(e).width*1.04):e.length*ik}const jp=4,Sp=3,kA=6;function yA(e){var k;const t=Ve-Xd-8-(e.reserve??0),n=((k=e.state)==null?void 0:k.split(" · "))??[],o=[{kind:"key",text:e.key},{kind:"type",text:e.type},...e.guide===void 0?[]:[{kind:"guide",text:e.guide}],...n.map(w=>({kind:"state",text:w})),...e.needsYou?[{kind:"needs",text:"needs you"}]:[]],a=t-o.length*2*jp-(o.length-1)*Sp,l=w=>vA(w.text,w.kind==="key"?"mono":"sans"),d=o.filter(w=>w.kind!=="guide").reduce((w,j)=>w+l(j),0),h=Math.max(kA,Math.floor((a-d)/ik)),f=o.map(w=>w.kind==="guide"?{...w,text:gT(w.text,h)}:w),p=Math.min(1,a/f.reduce((w,j)=>w+l(j),0));let v=0;return f.map(w=>{const j=l(w)*p,N={...w,x:v,w:j+2*jp,textW:j};return v+=N.w+Sp,N})}function wA(e,t,n){const o=e.state==="frontier"||e.state==="rework";if(!(!t||n||e.ticket.assignee||!o))return t}function xA(e){const t=["node",`st-${e.n.state}`,`tone-${e.tone}`,e.hitl?"hitl":"afk"];return e.selected&&t.push("sel"),e.live&&t.push("live"),e.waiting&&t.push("waiting"),e.stalled&&!e.waiting&&t.push("stalled"),e.mark&&t.push(`mark-${e.mark}`),e.frozen&&t.push("frozen"),t.join(" ")}function jA({wait:e,session:t}){return e?i.jsx("title",{children:`Needs a ${e} model: no connected agent runs one`}):t?i.jsx("title",{children:`${t.agent} · step ${t.step}/${t.total} · ${t.stepLabel.toLowerCase()}`}):null}const SA={claimed:"working",verifying:"working",frontier:"ready",blocked:"backlog",parked:"backlog",decided:"done","out-of-scope":"cancelled",rework:"attention",held:"attention"};function NA(e){const t=SA[e.state];return t==="done"||t==="cancelled"?t:e.attention?"attention":e.live?"working":t}function bA({mark:e,frozen:t}){const n=e&&e!=="unchanged"&&e!=="cancelled"?e:void 0;return i.jsxs(i.Fragment,{children:[e==="cancelled"&&i.jsx("line",{className:"strike",x1:8,y1:Qe/2,x2:Ve-8,y2:Qe/2}),n&&i.jsx("text",{className:"reroute-tag",x:Ve-8,y:Qe-7,textAnchor:"end",children:n}),t&&i.jsx("text",{className:"freeze",x:Ve-(n?58:8),y:Qe-7,textAnchor:"end",children:"❄"})]})}function $A(e){const{n:t,session:n}=e,o=t.ticket.assignee;return e.waiting?{text:"waiting on you",tone:"urgent"}:e.stalled?{text:`stalled · ${o}`,tone:"warn"}:e.wait?{text:`needs ${e.wait}`,tone:"warn"}:n&&e.step?{text:`${n.agent} · step ${n.step}/${n.total}`,tone:"agent"}:n?{text:n.agent,tone:"agent"}:t.state==="claimed"?{text:o??"working",tone:"agent"}:t.state==="verifying"?{text:"checks running",tone:"agent"}:t.state==="decided"&&e.verified?{text:"verified",tone:"verified"}:{text:y1[t.state],tone:""}}function rk({tone:e,cy:t,verified:n}){return e==="done"?i.jsx("path",{className:`dot dot-done${n?" dot-verified":""}`,d:`M10 ${t}l2.5 2.5 4.5 -5`}):i.jsx("circle",{className:`dot dot-${e}`,cx:13,cy:t,r:e==="backlog"?3:3.5})}function CA(e,t,n=2){const o=e.split(/\s+/),a=[];let l="";for(const d of o)(l+" "+d).trim().length>t?(a.push(l.trim()),l=d):l+=" "+d;if(a.push(l.trim()),a.length>n){const d=a.slice(0,n);return d[n-1]=d[n-1].slice(0,t-1)+"…",d}return a}const TA=26;function EA({n:e,session:t,stalled:n,flag:o,selected:a,onSelect:l,mark:d,frozen:h,needs:f,verified:p}){const v=e.ticket,k=CA(v.title,TA),w=cr(v)==="hitl",j=!!(t!=null&&t.waitingOn),N=!!d&&d!=="unchanged",S=wA(e,f,!!t),I=DT(v.guide),$=N?void 0:$A({n:e,session:t,waiting:j,stalled:n,wait:S,step:!I,verified:p}),_=w&&!N&&(v.type==="task"||v.type==="execute"),O=j||!!n||!!S||_&&e.state==="frontier",D=NA({state:e.state,live:!!t,attention:O}),q=Zs[v.type],H=(N&&d!=="cancelled"?44:0)+(h?12:0),G=yA({key:v.key,type:q,guide:I==null?void 0:I.name,state:$==null?void 0:$.text,needsYou:_,reserve:H}),oe=k.length>1?19:24;return i.jsxs("g",{className:xA({n:e,tone:D,hitl:w,selected:a,live:!!t,waiting:j,stalled:n,mark:d,frozen:h}),style:{transform:`translate(${e.x}px, ${e.y}px)`},onClick:Q=>{Q.stopPropagation(),l({kind:"ticket",id:v.id})},children:[i.jsx(jA,{wait:S,session:t}),i.jsx("rect",{className:"ring",x:-3.5,y:-3.5,width:Ve+7,height:Qe+7,rx:9}),i.jsx("rect",{className:"card",x:.5,y:.5,width:Ve-1,height:Qe-1,rx:6}),i.jsx(rk,{tone:D,cy:oe-4,verified:p}),k.map((Q,ke)=>i.jsx("text",{className:"title",x:Xd,y:oe+ke*14,children:Q},ke)),i.jsx(mA,{chips:G,y:oe+k.length*14-8,tone:$==null?void 0:$.tone,guide:I}),o&&i.jsx("circle",{className:`pr-flag-dot ${o}`,cx:Ve-2,cy:2,r:4}),i.jsx(bA,{mark:d,frozen:h})]})}const Np=.72;function AA(e){const{fit:t,nodes:n,size:o,pad:a}=e;if(t.k>=Np)return t;const l=n.find(h=>h.state==="claimed")??n.find(h=>h.state==="frontier")??n[0];if(!l)return t;const d=Np;return{k:d,x:o.w/2-(l.x+a+Ve/2)*d,y:o.h/2-(l.y+a+Qe/2)*d}}function IA(e){const{y:t,width:n,height:o}=e,a=e.nodes.filter(l=>l.state==="out-of-scope").length;return a?i.jsxs("g",{className:"quarantine",children:[i.jsx("rect",{x:-20,y:t-30,width:n+40,height:o+18,fill:"url(#hatch-oos)"}),i.jsx("line",{x1:-20,y1:t-30,x2:n+20,y2:t-30}),i.jsxs("text",{x:-12,y:t-12,children:["Out of scope · ",a]})]}):null}const st=280,bp=4,RA=220,Vs=e=>Math.round(e/bp)*bp;function MA(e){let t=2166136261;for(const n of e)t=Math.imul(t^n.charCodeAt(0),16777619);return()=>{t=t+1831565813|0;let n=Math.imul(t^t>>>15,1|t);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}function Qc(e,t,n,o){return Array.from({length:6},()=>{const a=o*(.5+e()*.7),l=o*(.3+e()*.4);return{x:Vs(t+(e()-.5)*o*.8-a/2),y:Vs(n+(e()-.5)*o*.5-l/2),w:Vs(a),h:Vs(l)}})}function LA(e){const{width:t,height:n,nodes:o}=e,a=MA(e.seed),l=(w,j)=>w+a()*(j-w),d=(w,j)=>!o.some(N=>w>N.x-52&&w<N.x+Ve+28&&j>N.y-52&&j<N.y+Qe+28),h=(t+st*2)*(n+st*2),f=Array.from({length:Math.round(h/9e4)},()=>Qc(a,l(-st,t+st),l(-st,n+st),l(160,360))).flat(),p=[...Qc(a,t+st*.55,n+st*.55,300),...Qc(a,-st*.5,-st*.45,220)],v=[],k=(w,j,N)=>{v.length<RA&&d(j,N)&&v.push({sprite:w,x:Vs(j),y:Vs(N)})};for(let w=0;w<Math.round(h/3e4);w++){const j=l(-st,t+st),N=l(-st,n+st),S=3+Math.floor(a()*5);for(let I=0;I<S;I++)k(a()<.65?"pine":"oak",j+l(-70,70),N+l(-44,44))}for(let w=0;w<Math.round(h/45e3);w++)k(a()<.4?"rock":"tuft",l(-st,t+st),l(-st,n+st));return v.sort((w,j)=>w.y-j.y),{grass:f,water:p,items:v}}const ok={pine:i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"16",y:"30",width:"4",height:"10",fill:"var(--map-trunk)"}),i.jsx("path",{d:"M18 0l9 12h-4l8 10h-4l9 11H0l9-11H5l8-10H9z",fill:"var(--map-pine)"}),i.jsx("path",{d:"M18 0l9 12h-4l8 10h-4l9 11H18z",fill:"var(--map-pine2)"})]}),oak:i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"16",y:"24",width:"4",height:"12",fill:"var(--map-trunk)"}),i.jsx("circle",{cx:"18",cy:"14",r:"14",fill:"var(--map-oak)"}),i.jsx("circle",{cx:"10",cy:"17",r:"8",fill:"var(--map-oak)"}),i.jsx("circle",{cx:"26",cy:"17",r:"8",fill:"var(--map-oak)"}),i.jsx("circle",{cx:"22",cy:"10",r:"6",fill:"var(--map-oak2)"})]}),rock:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M1 16Q2 6 10 3Q18-1 23 6Q28 11 27 16z",fill:"var(--map-rock)"}),i.jsx("path",{d:"M15 16Q15 8 19 4Q25 8 27 16z",fill:"var(--map-rock2)"})]}),tuft:i.jsx("path",{d:"M4 8Q3 4 1 1M14 8Q14 3 14 0M24 8Q25 4 27 1",fill:"none",stroke:"var(--map-pine2)",strokeWidth:"2.5",strokeLinecap:"round"})};function OA({name:e}){return i.jsx("symbol",{id:`terrain-${e}`,overflow:"visible",children:ok[e]})}const PA=Object.keys(ok),_A=y.memo(function(t){const{seed:n,width:o,height:a,nodes:l}=t,d=y.useMemo(()=>LA({seed:n,width:o,height:a,nodes:l}),[n,o,a,l]);return i.jsxs("g",{className:"terrain","aria-hidden":"true",children:[i.jsx("defs",{children:PA.map(h=>i.jsx(OA,{name:h},h))}),d.grass.map((h,f)=>i.jsx("rect",{x:h.x,y:h.y,width:h.w,height:h.h,fill:"var(--map-grass)"},f)),d.water.map((h,f)=>i.jsx("rect",{x:h.x,y:h.y,width:h.w,height:h.h,fill:"var(--map-water)"},f)),i.jsx("rect",{x:-4e3,y:-4e3,width:o+8e3,height:a+8e3,fill:"url(#map-grid)"}),d.items.map((h,f)=>i.jsx("use",{href:`#terrain-${h.sprite}`,x:h.x,y:h.y},f))]})}),DA=380;function zA(e){const{selId:t,size:n}=e,o=y.useRef(e);o.current=e;const a=y.useRef(!0);y.useEffect(()=>{if(a.current){a.current=!1;return}const{nodes:l,pad:d,view:h,setView:f,onFocus:p}=o.current,v=t?l.find($=>$.ticket.id===t):void 0;if(!v||!n.w)return;p();const k=Math.min(1.4,Math.max(h.k,1.05)),w={k,x:n.w/2-(d+v.x+Ve/2)*k,y:n.h/2-(d+v.y+Qe/2)*k};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return f(w);const j=h,N=performance.now();let S=0;const I=$=>{const _=Math.min(1,($-N)/DA),O=1-(1-_)**3;f({k:j.k+(w.k-j.k)*O,x:j.x+(w.x-j.x)*O,y:j.y+(w.y-j.y)*O}),_<1&&(S=requestAnimationFrame(I))};return S=requestAnimationFrame(I),()=>cancelAnimationFrame(S)},[t])}function BA(e,t){const[n,o]=y.useState({});return Ye({view:e,version:t,load:async()=>{const a=await fetch(`${pe()}/proof/trail?mapId=${encodeURIComponent(e)}`);return a.ok?(await a.json()).statuses??{}:{}},show:o,failed:()=>o({}),changed:a=>a.includes(".evidence")||a.includes(e)}),n}function FA(e,t){const n=y.useRef(t);n.current=t,y.useEffect(()=>{const o=e.current;if(!o)return;const a=p=>{const v=o.getBoundingClientRect();return{x:p.clientX-v.left,y:p.clientY-v.top}},l=p=>{p.preventDefault();const v=p.ctrlKey?.01:.0015;n.current(Math.exp(-p.deltaY*v),a(p))};let d=1;const h=p=>{p.preventDefault(),d=1},f=p=>{p.preventDefault();const v=p;n.current(v.scale/d,a(v)),d=v.scale};return o.addEventListener("wheel",l,{passive:!1}),o.addEventListener("gesturestart",h,{passive:!1}),o.addEventListener("gesturechange",f,{passive:!1}),()=>{o.removeEventListener("wheel",l),o.removeEventListener("gesturestart",h),o.removeEventListener("gesturechange",f)}},[e])}function $p(e,t,n){const o=Math.min(3,Math.max(.2,t));return{k:o,x:n.x-(n.x-e.x)*o/e.k,y:n.y-(n.y-e.y)*o/e.k}}const on=32,UA=1.8;function WA(e){var ce;const{snap:t,selection:n,onSelect:o,preview:a}=e,l=BA(t.map.id,t.tickets),d=(a==null?void 0:a.tickets)??t.tickets,h=y.useRef(null),[f,p]=y.useState({w:0,h:0});y.useEffect(()=>{const F=h.current;if(!F)return;const J=new ResizeObserver(([ie])=>p({w:ie.contentRect.width,h:ie.contentRect.height}));return J.observe(F),()=>J.disconnect()},[]);const v=y.useMemo(()=>{const F=nm(d,"LR",t.map.mode),J=nm(d,"TB",t.map.mode),ie=W=>Math.min(f.w/(W.width+on*2),f.h/(W.height+on*2+16));return ie(F)*UA>=ie(J)?F:J},[d,t.map.mode,f.w,f.h]),k=(F,J)=>Math.min(1.25,Math.max(e.minFit??0,Math.min(f.w/F,f.h/J))),w=y.useMemo(()=>{const F=v.width+on*2,J=v.height+on*2+16,W=v.nodes.some(z=>z.state==="out-of-scope")&&f.h?Math.max(0,f.h/k(F,J)-J):0;if(!W)return{...v,slack:W};const X=new Map(v.nodes.map(z=>[z,{...z,y:z.y+(z.state==="out-of-scope"?W:W/2)}]));return{...v,slack:W,nodes:[...X.values()],edges:v.edges.map(z=>({from:X.get(z.from),to:X.get(z.to)})),quarantineY:v.quarantineY+W,height:v.height+W}},[v,f.w,f.h,e.minFit]),j=nA(w),N=j.right+on*2,S=j.bottom+on*2+16,I=()=>{const F=k(N,S);return{k:F,x:Math.max(0,(f.w-N*F)/2),y:Math.max(0,(f.h-S*F)/2)}},[$,_]=y.useState({k:1,x:0,y:0}),O=y.useRef(!1);y.useEffect(()=>{O.current=!1},[t.map.id]),y.useEffect(()=>{!O.current&&f.w&&_(AA({fit:I(),nodes:w.nodes,size:f,pad:on}))},[f.w,f.h,N,S,t.map.id]);const D=y.useRef(new Map),q=y.useRef(null),H=F=>{const J=h.current.getBoundingClientRect();return{x:F.clientX-J.left,y:F.clientY-J.top}},G=()=>{var W;const F=[...D.current.values()],J=F.length>1?{x:(F[0].x+F[1].x)/2,y:(F[0].y+F[1].y)/2}:F[0],ie=F.length>1?Math.hypot(F[0].x-F[1].x,F[0].y-F[1].y):0;q.current={view:$,dist:ie,mid:J,moved:((W=q.current)==null?void 0:W.moved)??!1}};FA(h,(F,J)=>{O.current=!0,_(ie=>$p(ie,ie.k*F,J))});const oe=Xt(5e3),Q=Md(e.leases,t.map.id),ke=Fd(),Oe=(ce=Yd())==null?void 0:ce.waiting,Te=new Map(e.sessions.filter(F=>dn(F)&&F.ticketId).map(F=>[F.ticketId,F])),ne=(n==null?void 0:n.kind)==="ticket"?n.id:void 0;return zA({selId:ne,nodes:w.nodes,size:f,pad:on,view:$,setView:_,onFocus:()=>O.current=!0}),i.jsxs("div",{className:"graph-box",ref:h,onPointerDown:F=>{D.current.set(F.pointerId,H(F)),D.current.size===1&&(q.current=null),G()},onPointerMove:F=>{var W;if(!D.current.has(F.pointerId)||!q.current)return;D.current.set(F.pointerId,H(F));const J=q.current,ie=[...D.current.values()];if(ie.length>1){const X={x:(ie[0].x+ie[1].x)/2,y:(ie[0].y+ie[1].y)/2},z=Math.hypot(ie[0].x-ie[1].x,ie[0].y-ie[1].y),T=$p(J.view,J.view.k*z/(J.dist||z),J.mid);_({...T,x:T.x+X.x-J.mid.x,y:T.y+X.y-J.mid.y}),J.moved=!0}else{const X=ie[0].x-J.mid.x,z=ie[0].y-J.mid.y;if(!J.moved&&Math.hypot(X,z)<5)return;J.moved||(W=h.current)==null||W.setPointerCapture(F.pointerId),J.moved=!0,_({...J.view,x:J.view.x+X,y:J.view.y+z})}O.current=!0},onPointerUp:F=>{D.current.delete(F.pointerId),D.current.size&&G()},onPointerCancel:F=>D.current.delete(F.pointerId),onClickCapture:F=>{var J;(J=q.current)!=null&&J.moved&&(F.stopPropagation(),q.current=null)},children:[i.jsxs("svg",{className:"graph",width:f.w,height:f.h,onClick:()=>o(null),children:[i.jsx(oA,{}),i.jsx("g",{transform:`translate(${$.x} ${$.y}) scale(${$.k})`,children:i.jsxs("g",{transform:`translate(${on} ${on})`,children:[i.jsx(_A,{seed:t.map.id,width:N,height:S,nodes:w.nodes}),i.jsx(IA,{y:w.quarantineY,width:w.width,height:w.quarantineH,nodes:w.nodes}),i.jsx(uA,{snap:t,tickets:d,direction:w.direction,nodes:w.nodes,edges:w.edges,preview:a}),i.jsx(rA,{trails:sA(w,j)}),w.nodes.length>0&&i.jsx(iA,{x:j.x,y:j.y,text:t.map.sections.destination}),w.nodes.map(F=>{var J;return i.jsx(EA,{n:F,session:Te.get(F.ticket.id),stalled:!!Q.get(F.ticket.id)&&ca(Q.get(F.ticket.id),oe)!=="live",flag:Q1(ei.ticket(ke,t.map.id,F.ticket.id)),selected:ne===F.ticket.id,onSelect:o,mark:a==null?void 0:a.marks.get(F.ticket.id),frozen:a==null?void 0:a.frozen.has(F.ticket.id),needs:(J=Oe==null?void 0:Oe.find(ie=>ie.mapId===t.map.id&&ie.ticketId===F.ticket.id))==null?void 0:J.tier,verified:l[F.ticket.id]===void 0?void 0:l[F.ticket.id]==="verified"},F.ticket.id)})]})})]}),i.jsx("button",{className:"btn sm fit-btn","data-tip":"Fit the whole trail in view",onPointerDown:F=>F.stopPropagation(),onClick:F=>{F.stopPropagation(),O.current=!0,_(I())},children:"Fit"})]})}const HA=[{tone:"working",text:"An agent is on it"},{tone:"attention",text:"Waits on you, or held up"},{tone:"ready",text:"Ready for an agent"},{tone:"backlog",text:"Not ready yet"},{tone:"done",verified:!0,text:"Done and verified"},{tone:"done",text:"Done, not verified"},{tone:"cancelled",text:"Ruled out"}];function ak(){const[e,t]=y.useState(!1);return i.jsxs("div",{className:"map-legend",onPointerDown:n=>n.stopPropagation(),onClick:n=>n.stopPropagation(),children:[e&&i.jsx("ul",{className:"map-legend-list",children:HA.map(n=>i.jsxs("li",{children:[i.jsx("svg",{className:"node",width:"22",height:"16",viewBox:"4 0 18 16","aria-hidden":"true",children:i.jsx(rk,{tone:n.tone,cy:8,verified:n.verified})}),n.text]},n.text))}),i.jsx("button",{type:"button",className:"btn sm","aria-expanded":e,onClick:()=>t(!e),children:e?"Hide legend":"Legend"})]})}const Yc=[["decided","Done"],["claimed","Working"],["frontier","Ready"],["blocked","Backlog"],["parked","Parked"],["out-of-scope","Cancelled"]],Cp=[["verifying","Verifying"],["rework","Rework"],["held","Blocked"]];function KA({snap:e,sessions:t}){const n=sg(e),o=p=>n[p],a=t.filter(Gg).length,l=nj(e),d=Math.max(1,...l.map(p=>p.open+p.closed)),f=(e.map.verification??"off")!=="off"||Cp.some(([p])=>o(p))?[...Yc.slice(0,2),...Cp,...Yc.slice(2)]:Yc;return i.jsxs("div",{className:"status-panel",children:[i.jsxs("div",{className:"sp-col sp-status",children:[i.jsxs("div",{className:"sp-head",children:[i.jsx(ze,{as:"h3",children:"Status"}),i.jsxs("span",{className:"t-meta",children:[n.total," tickets"]})]}),i.jsxs("ul",{children:[f.map(([p,v])=>i.jsxs("li",{className:`st-${p} ${o(p)?"":"zero"}`,children:[i.jsx("i",{}),i.jsx("span",{children:v}),i.jsx("b",{children:o(p)})]},p)),i.jsxs("li",{className:`st-waiting ${a?"":"zero"}`,children:[i.jsx("i",{}),i.jsx("span",{children:"Waiting on you"}),i.jsx("b",{children:a})]})]})]}),i.jsxs("div",{className:"sp-block sp-col",children:[i.jsx("span",{className:"t-label",children:"Type mix"}),i.jsx("ul",{className:"mix",children:l.map(p=>i.jsxs("li",{title:`${p.type}: ${p.closed} closed, ${p.open} open`,children:[i.jsx("span",{className:"t-meta",children:Zs[p.type]}),i.jsxs("span",{className:"mix-bar",children:[i.jsx("i",{className:"closed",style:{width:`${p.closed/d*100}%`}}),i.jsx("i",{className:"open",style:{width:`${p.open/d*100}%`}})]}),i.jsx("b",{children:p.open+p.closed})]},p.type))})]})]})}function VA(e){const[t,n]=y.useState(!1);return i.jsxs("div",{className:t?"status-drawer open":"status-drawer",children:[i.jsxs("div",{className:"status-tabs",children:[i.jsxs("button",{type:"button",className:"status-toggle","aria-expanded":t,onPointerDown:o=>o.stopPropagation(),onClick:()=>n(!t),children:["Summary ",i.jsx("span",{className:"caret",children:t?"▾":"▴"})]}),i.jsx(ak,{})]}),i.jsx(KA,{snap:e.snap,sessions:e.sessions})]})}function GA(){const e=Et();return e?`Describe your idea here, then turn your agents on for it in ${e.label}. Scout frames it with you here, then they get to work.`:"Describe your idea here, or start it in Claude Code or Codex. Scout frames it with you, then your agents get to work."}function qA({planOnly:e,verifies:t}){const n=[["frontier","Ready"],["claimed","Working"],...t?[["verifying","Verifying"],["rework","Rework"],["held","Blocked"]]:[],["stalled","Stalled"],["blocked","Backlog"],["decided","Done"],...e?[["parked","Parked"]]:[],["out-of-scope","Cancelled"],["waiting","Waiting on you"]];return i.jsxs("div",{className:"legend",children:[n.map(([o,a])=>i.jsxs("span",{className:`lg st-${o}`,children:[i.jsx("i",{}),a]},o)),i.jsx("span",{className:"lg hitl",children:"● needs human"})]})}function QA(e){var o,a,l;const{snap:t,selection:n}=e.api;return i.jsxs(Be,{as:"main",className:"zone map-zone",style:{gridArea:"map"},children:[t&&!Et()&&i.jsx(UN,{}),(o=e.trail)==null?void 0:o.banner,i.jsxs("div",{className:"map-area",children:[t&&!e.compact&&i.jsx(VA,{snap:t,sessions:e.sessions}),t?i.jsx(WA,{snap:t,sessions:e.sessions,leases:e.api.leases,selection:n,onSelect:e.onSelect,minFit:e.minFit,preview:(a=e.trail)==null?void 0:a.preview}):i.jsxs("div",{className:"nomap",children:[i.jsx(Sn,{title:"No trail yet",hint:GA()}),i.jsx("div",{className:"actions",children:i.jsx(M,{variant:"primary",onClick:e.onNewTrail,"data-tip":"Describe the idea and create the trail",children:"New trail…"})}),Et()?i.jsx(M,{onClick:ev,children:(l=Et())==null?void 0:l.label}):i.jsx(Na,{command:'/scout new "your idea"'})]}),t&&e.compact&&i.jsx(ak,{}),t&&e.compact&&i.jsx(qA,{planOnly:t.map.mode==="plan-only",verifies:(t.map.verification??"off")!=="off"})]})]})}const YA=[["home","Inbox"],["map","Map"],["ticket","Ticket"],["activity","Activity"],["plan","Plan"]];function JA(e){const{tab:t,covered:n,pending:o}=e;return i.jsx("nav",{className:"tabbar",children:YA.map(([a,l])=>i.jsxs("button",{className:t===a&&!n?"on":"",onClick:()=>e.onPick(a),children:[l,a==="home"&&o>0&&i.jsx(fs,{n:o,urgent:!0,pop:!0},o)]},a))})}function XA(e){const t={home:e.projects?i.jsxs("div",{className:"phone-home",children:[e.projects,e.inbox]}):e.inbox,map:e.map,ticket:i.jsx(Be,{className:"zone",children:e.ticket}),activity:i.jsx(Be,{className:"zone",children:e.activity}),plan:e.plan};return i.jsx("main",{className:"phone-view",children:e.decisions||t[e.tab]})}const Tp={settingsPage:!0},Ep=()=>bv(new URLSearchParams(location.search).get("settings")),Ap=()=>{var e;return!!((e=history.state)!=null&&e.settingsPage)};function ZA(){const[e,t]=y.useState(Ep);y.useEffect(()=>{e&&!Ap()&&(history.replaceState(null,"",tr(location.href,null)),history.pushState(Tp,"",tr(location.href,e)));const l=()=>t(Ep());return window.addEventListener("popstate",l),()=>window.removeEventListener("popstate",l)},[]);const n=l=>{const d=tr(location.href,l);e?history.replaceState(history.state,"",d):history.pushState(Tp,"",d),t(l)},o=()=>{e&&(t(null),Ap()?history.back():history.replaceState(null,"",tr(location.href,null)))},a=l=>n(bv(l??"")??{});return{route:e,open:a,show:n,close:o,toggle:()=>e?o():a()}}function eI(e,t){const{activity:n,selection:o,setSelection:a,actions:l}=e,[d,h]=y.useState("ticket"),[f,p]=y.useState("home"),[v,k]=y.useState(0),[w,j]=y.useState(null),[N,S]=y.useState(!1),I=H=>{S(!1),j({focus:H})},$=()=>{j(null),S(H=>!H)};y.useEffect(()=>{const H=n.sessions.find(G=>G.id===e.chatSession);!o&&(H!=null&&H.ticketId)&&H.mapId===e.mapId&&a({kind:"ticket",id:H.ticketId})},[e.chatSession,e.mapId]);const _=H=>{a(H),H&&(t==="laptop"&&h("ticket"),t==="mobile"&&p("ticket"))},O=(H,G,oe)=>{oe&&oe!==e.mapId&&l.selectMap(oe),l.openChat(H);const Q=n.sessions.find(ke=>ke.id===H);G&&(Q==null?void 0:Q.mapId)===(oe??e.mapId)&&a({kind:"ticket",id:G}),t==="mobile"&&(p("home"),k(ke=>ke+1))};return{sideTab:d,setSideTab:h,phoneTab:f,setPhoneTab:p,convRequest:v,decisionsView:w,setDecisionsView:j,openDecisions:I,statsOpen:N,setStatsOpen:S,toggleStats:$,select:_,openChat:O,showChat:(H,G,oe)=>{O(H,G,oe),k(Q=>Q+1)},openTicket:(H,G)=>{H!==e.mapId&&l.selectMap(H),a({kind:"ticket",id:G}),j(null),t==="laptop"&&h("ticket"),t==="mobile"&&p("ticket")}}}function tI(e,t){y.useEffect(()=>{document.title=`${Z.name}: ${e?`(${e}) `:""}${t??"No trail"}`},[e,t])}function nI(e){const[t,n]=y.useState("…");return y.useEffect(()=>{fetch(`${pe()}/list`).then(o=>o.json()).then(o=>{var l;const a=o.root.split("/").filter(Boolean);n((l=a[a.length-1])!=null&&l.startsWith(".")?a[a.length-2]??"repo":a[a.length-1]??"repo")}).catch(()=>n("repo"))},[e]),t}function sI(e,t){return y.useMemo(()=>{const n=e.sessions.filter(a=>a.mapId===t),o=new Set(e.sessions.filter(a=>a.mapId!==t).map(a=>a.id));return{...e,sessions:n,feed:e.feed.filter(a=>!a.sessionId||!o.has(a.sessionId))}},[e,t])}function iI({text:e}){return e.trim()?i.jsx("div",{className:"brief-prose",children:e.split(`
|
|
157
|
+
`).map((t,n)=>i.jsx("p",{children:t.split(/(`[^`]+`|\/?\b[\w.-]+\/[\w./-]+\b)/g).map((o,a)=>a%2===1?i.jsx("code",{children:o.replace(/`/g,"")},a):o)},n))}):i.jsx(Ie,{children:"Not covered"})}const Ip=["summary","productContext","existing","conventions","dataModel","api","risks"];function rI(e){const{brief:t}=e,[n,o]=y.useState(!1),[a,l]=y.useState("");y.useEffect(()=>{const p=v=>v.key==="Escape"&&e.onClose();return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[e]);const d=t.sections,h=Ip.filter(p=>d[p].trim()),f=Ip.filter(p=>!d[p].trim());return i.jsx("div",{className:"scrim",onClick:e.onClose,children:i.jsxs(Be,{as:"div",className:"dialog brief-dialog",onClick:p=>p.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:"Discovery brief"}),i.jsx("span",{className:"t-meta",children:oI(t)})]}),i.jsxs("div",{className:"brief-body",children:[h.map(p=>i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:Yi[p]}),i.jsx(iI,{text:d[p]}),(p==="conventions"||p==="productContext")&&d[p].trim()&&i.jsx(Ud,{draft:()=>({title:`${Yi[p]}: ${d[p].split(`
|
|
158
|
+
`)[0].slice(0,80)}`,body:d[p],kind:p==="conventions"?"convention":"business-rule",sources:[`brief:${t.mapId}`]})})]},p)),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:Yi.assumptions}),d.assumptions.length?i.jsx("ul",{className:"item-list",children:d.assumptions.map(p=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:p.text}),i.jsx(V,{parts:[{text:p.id,code:!0}]})]},p.id))}):i.jsx(Ie,{children:"None listed"})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:Yi.openQuestions}),d.openQuestions.length?i.jsx("ul",{className:"brief-list",children:d.openQuestions.map(p=>i.jsx("li",{children:p},p))}):i.jsx(Ie,{children:"None"})]}),f.length>0&&i.jsxs("p",{className:"t-meta brief-empty",children:["Nothing noted on ",f.map(p=>Yi[p].toLowerCase()).join(", "),"."]}),t.note&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Your last request"}),i.jsx("p",{children:t.note})]})]}),n&&i.jsx(Ze,{label:"What should change?",children:i.jsx("textarea",{rows:3,value:a,onChange:p=>l(p.target.value),autoFocus:!0})}),e.changed&&e.onReviewAgain&&i.jsx(ya,{what:"The brief",onReviewAgain:e.onReviewAgain}),e.error&&i.jsx("p",{className:"urgent-text",children:e.error}),i.jsxs("div",{className:"actions",children:[t.status==="submitted"&&!n&&i.jsxs(i.Fragment,{children:[i.jsx(M,{onClick:()=>o(!0),children:"Request changes"}),i.jsx(M,{variant:"primary",disabled:e.changed,onClick:e.onAccept,children:"Accept brief"})]}),n&&i.jsxs(i.Fragment,{children:[i.jsx(M,{variant:"ghost",onClick:()=>o(!1),children:"Back"}),i.jsx(M,{variant:"primary",disabled:!a.trim(),onClick:()=>e.onRequestChanges(a.trim()),children:"Send to the agent"})]}),i.jsx(M,{variant:"ghost",onClick:e.onClose,children:"Close"})]})]})})}function oI(e){if(e.status==="draft")return"Not submitted yet";const t=[e.status.replace("-"," ")];return e.author&&t.push(`by ${e.author}`),e.submittedAt&&t.push(`${hn(Date.now()-e.submittedAt)} ago`),t.join(" · ")}function aI({brief:e,onReview:t}){return e.status!=="submitted"?null:i.jsx("div",{className:"brief-card",children:i.jsx(be,{edge:"attention",title:"Discovery brief ready for your review",context:i.jsx(V,{parts:["Discovery brief",e.author&&`by ${e.author}`]}),detail:e.sections.summary.split(`
|
|
159
|
+
`)[0],detailText:e.sections.summary,onOpen:t})})}const lI={draft:["Discovery in progress","An agent maps the existing system before anything is built."],submitted:["Discovery brief ready for your review","Implementation starts once you accept it."],"changes-requested":["You asked for changes","Waiting for the revised discovery brief."],accepted:["Discovery brief accepted",""]};function cI({brief:e,onReview:t}){if(e.status==="accepted")return null;const[n,o]=lI[e.status],a=e.status==="submitted"?"edge-attention":"edge-neutral";return i.jsxs("div",{className:`discovery-banner map-banner ${a} st-${e.status}`,role:"status",children:[i.jsxs("span",{className:"mb-text",children:[i.jsx("span",{className:"mb-lead",children:n}),i.jsx("span",{className:"t-meta",children:o})]}),i.jsx(ii,{text:"Before implementation, an agent maps the existing system: the files involved, conventions, data and API impact, risks and assumptions. You accept the brief or ask for changes; task, execute and prototype tickets can't be claimed until you accept it."}),i.jsx(M,{size:"sm",variant:e.status==="submitted"?"primary":"ghost",onClick:t,children:e.status==="submitted"?"Review brief":"Open brief"})]})}const lk=`${pe()}/briefs`;async function dI(e){if(!e)return{brief:null};const t=await fetch(`${lk}?mapId=${encodeURIComponent(e)}`);return t.ok?await t.json():{brief:null}}function uI(e){const t=e==null?void 0:e.map.id,[n,o]=y.useState(null),[a,l]=y.useState(),[d,h]=y.useState(),{reload:f,pushed:p}=Ye({view:t,version:e==null?void 0:e.tickets.reduce((w,j)=>Math.max(w,j.updatedAt),e.map.updatedAt),load:()=>dI(t),show:w=>{o(w.brief),h(w.hash)},failed:()=>o(null),changed:w=>w.startsWith("briefs/")}),v=(w,j,N)=>fetch(`${lk}/${w}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,note:j,hash:N})}).then(async S=>{const I=await S.json().catch(()=>({}));if(!S.ok||!I.brief)throw new Error(I.error??`HTTP ${S.status}`);l(void 0),p(),o(I.brief)}),k=(w,j,N)=>v(w,j,N).then(()=>!0,S=>(l(S.message),f(),!1));return{brief:n,error:a,hash:d,accept:w=>k("accept",void 0,w),requestChanges:w=>k("request-changes",w)}}function hI(e){const t=uI(e),[n,o]=y.useState(!1),a=()=>o(!0),l=t.brief,d=ba(n?l==null?void 0:l.mapId:void 0,t.hash),h=l==null?void 0:l.sections;return{review:a,briefText:h?[h.existing,h.conventions,h.dataModel,h.api].join(`
|
|
160
|
+
`):"",banner:l&&i.jsx(cI,{brief:l,onReview:a}),inboxCard:l&&i.jsx(aI,{brief:l,onReview:a}),dialog:l&&n&&i.jsx(rI,{brief:l,error:t.error,changed:d.changed,onReviewAgain:d.reviewAgain,onAccept:()=>void t.accept(d.hash).then(f=>f&&o(!1)),onRequestChanges:f=>void t.requestChanges(f).then(p=>p&&o(!1)),onClose:()=>o(!1)})}}function fI(e){var p;const{reroute:t,onReview:n}=e,o=t.kind==="challenge-destination",a=((p=t.frozen)==null?void 0:p.length)??0,l=o?"wrong mountain?":"proposes a new plan",d=a?` ${a} ticket${a===1?" is":"s are"} closed until you decide.`:"",h=t.wide?" It touches most of the open tickets, so nothing is frozen.":"",f=`${t.reason.replace(/\.$/,"")}.${d}${h}`;return i.jsxs("div",{className:"reroute-banner map-banner edge-attention",role:"status",title:f,children:[i.jsxs("span",{className:"mb-text",children:[i.jsxs("span",{className:"mb-lead",children:[t.by," ",l]}),i.jsx("span",{className:"t-meta",children:f})]}),i.jsx(ii,{text:"An agent found that an assumption or the plan no longer holds and proposes changes. The map shows them: dashed outlines are tickets it adds, struck ones it cancels, ❄ marks tickets frozen until you approve or reject. Nothing changes until you decide."}),i.jsx(M,{size:"sm",variant:"ghost",className:"reroute-dismiss",onClick:e.onDismiss,children:"Dismiss"}),i.jsx(M,{size:"sm",variant:"primary",onClick:n,children:"Review"})]})}const mI=e=>e.changes.flatMap(t=>"ticket"in t?[t.ticket]:[]);function pI(e,t){const n=new Set(mI(t));return e.tickets.filter(o=>n.has(o.id)&&o.updatedAt>t.at).map(o=>({key:o.key,title:o.title,what:gI(o)}))}function gI(e){return e.state==="closed"?"closed":e.assignee?`claimed by ${e.assignee}`:"changed"}function vI({parts:e}){return i.jsx("dl",{className:"reroute-parts",children:e.map(t=>i.jsxs("div",{children:[i.jsx("dt",{className:"t-label",children:t.label}),i.jsx("dd",{className:"t-body",children:t.text})]},t.label))})}const kI={"already-exists":"The work already exists","wrong-problem":"The trail targets the wrong problem",rescope:"The trail should be rescoped"},ck="Dismissed by the trail lead. Carry on with the current plan.",yI="Declined by the trail lead.";function wI(e,t){var n,o,a;switch(e.op){case"edit_ticket":return[...(n=e.title)!=null&&n.trim()?[{label:"New title",text:e.title.trim()}]:[],...(o=e.body)!=null&&o.trim()?[{label:"New description (replaces the old one)",text:e.body.trim()}]:[]];case"add_ticket":return[...(a=e.body)!=null&&a.trim()?[{label:"Description",text:e.body.trim()}]:[],{label:"Who decides",text:e.hitl?"You (HITL)":"Agents, without you"}];case"supersede_decision":return[{label:`New answer to ${e.decision}`,text:e.answer},{label:"Rationale",text:e.rationale},{label:"Recorded as",text:`Proposed by ${t}, approved by you; the words stay ${t}'s.`}];default:return[]}}function xI(e,t){var n;switch(e.op){case"add_ticket":{const o=(n=e.blockedBy)!=null&&n.length?`after ${e.blockedBy.map(t).join(", ")}`:void 0;return{verb:"Add",text:e.title,detail:[`new ${e.type} ticket`,o].filter(Boolean).join(" · ")}}case"cancel_ticket":return{verb:"Cancel",text:t(e.ticket),detail:e.reason};case"edit_ticket":return{verb:"Revise",text:t(e.ticket),detail:jI(e)};case"rewire":return{verb:"Rewire",text:t(e.ticket),detail:SI(e,t)};case"supersede_decision":return{verb:"Supersede",text:e.decision,detail:"Replaced by the answer below"};case"update_destination":return{verb:"Destination",text:e.text};case"add_unspecified":return{verb:"Not yet specified",text:e.text};case"add_out_of_scope":return{verb:"Out of scope",text:e.text};case"reopen":return{verb:"Reopen",text:t(e.ticket),detail:`Back in the queue: ${e.reason}`};case"skip_discovery":return{verb:"Skip discovery",text:"Implementation stops waiting for a discovery brief",detail:"The discovery ticket is ruled out"};case"set_mode":return{verb:"Mode",text:e.mode,detail:e.mode==="plan-only"?"Execute tickets wait":"Execute tickets can be worked"};default:return e}}function jI(e){var n,o;return[((n=e.title)==null?void 0:n.trim())&&"New title",((o=e.body)==null?void 0:o.trim())&&"new description"].filter(Boolean).join(" and ").replace(/^new/,"New")}function SI(e,t){var o,a;return[...(o=e.addBlockedBy)!=null&&o.length?[`now also after ${e.addBlockedBy.map(t).join(", ")}`]:[],...(a=e.removeBlockedBy)!=null&&a.length?[`no longer after ${e.removeBlockedBy.map(t).join(", ")}`]:[]].join(" · ")}const NI=new Set(["cancel_ticket","update_destination"]);function bI(e){const{change:t,name:n}=e,o=xI(t,n),a=wI(t,e.by);return i.jsx(be,{as:"li",className:`reroute-change op-${t.op}`,edge:NI.has(t.op)?"attention":"neutral",title:o.text,titleText:o.text,context:i.jsx(V,{parts:[{text:o.verb,strong:!0}]}),detail:o.detail,detailText:o.detail,below:a.length?i.jsx(vI,{parts:a}):void 0})}function $I(e){const{reason:t,destination:n}=e;return i.jsxs("section",{className:"reroute-destination",children:[t&&i.jsx("p",{className:"reroute-destination-why",children:kI[t]}),n&&i.jsxs("div",{className:"reroute-destination-diff",children:[i.jsxs("div",{children:[i.jsx("span",{className:"mono-label",children:"Destination now"}),i.jsx("p",{className:"before",children:n.before||"—"})]}),i.jsxs("div",{children:[i.jsx("span",{className:"mono-label",children:"Suggested destination"}),i.jsx("p",{className:"after",children:n.after})]})]})]})}function CI(e){return i.jsxs("section",{className:"reroute-drift edge-note edge-attention",children:[i.jsx("h3",{className:"mono-label",children:"Changed since it was proposed"}),i.jsx("ul",{className:"item-list",children:e.changed.map(t=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:t.title}),i.jsx(V,{parts:[{text:t.key,code:!0},t.what]})]},t.key))}),i.jsxs("label",{className:"reroute-seen t-body",children:[i.jsx("input",{type:"checkbox",checked:e.seen,onChange:t=>e.onSeen(t.target.checked)})," I’ve seen what changed: apply the proposal to the trail as it is now"]})]})}function TI(e,t){const n=new Map(e.tickets.map(a=>[a.id,a.key])),o=new Map(t.flatMap(a=>a.op==="add_ticket"?[[a.ref,a.title]]:[]));return a=>{const l=n.get(a);if(l)return l;const d=o.get(a);return d?`new: ${d}`:a}}function EI(e){var _,O;const{reroute:t,snap:n}=e,[o,a]=y.useState(""),[l,d]=y.useState(!1);y.useEffect(()=>{const D=q=>q.key==="Escape"&&e.onClose();return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[e]);const h=TI(n,t.changes),f=new Map(n.tickets.map(D=>[D.id,`${D.key} ${D.title}`])),p=D=>f.get(D)??h(D),v=n.map.sections.assumptions??[],k=t.invalidates.map(D=>v.find(q=>q.id===D)??{id:D,text:""}),w=t.status==="pending",j=w?pI(n,t):[],N=!j.length||l,S=t.kind==="challenge-destination",I=t.lane==="setting",$=I?`${t.by} asks to change your setting`:"Reroute proposal";return i.jsx("div",{className:"scrim",onClick:e.onClose,children:i.jsxs(Be,{as:"div",className:"dialog reroute-dialog",onClick:D=>D.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:S?"Destination challenged":$}),i.jsx(V,{parts:[{text:t.id,code:!0},t.status,`by ${t.by}`,`${hn(Date.now()-t.at)} ago`]})]}),i.jsxs("div",{className:"reroute-body",children:[e.replaced&&i.jsxs("p",{className:"reroute-replaced t-meta edge-note edge-attention",children:[t.by," replaced ",e.replaced," with this proposal while you were reading: review it again."]}),S&&i.jsx($I,{reason:t.destinationReason,destination:(_=t.diff)==null?void 0:_.destination}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Why"}),i.jsx("p",{children:t.reason})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Evidence"}),i.jsx("p",{className:"reroute-evidence",children:t.evidence})]}),k.length>0&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Assumptions it invalidates"}),i.jsx("ul",{className:"item-list",children:k.map(D=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:D.text}),i.jsx(V,{parts:[{text:D.id,code:!0}]})]},D.id))})]}),i.jsxs("section",{children:[i.jsxs("h3",{className:"mono-label",children:["Changes · ",t.changes.length]}),i.jsx("ul",{className:"reroute-changes row-list",children:t.changes.map((D,q)=>i.jsx(bI,{change:D,by:t.by,name:p},q))})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Closed until you decide"}),t.wide&&i.jsxs("p",{className:"t-meta",children:["It touches ",t.wide.touched," of ",t.wide.open," open tickets, so it freezes none: the current plan stands until you decide."]}),(O=t.frozen)!=null&&O.length?i.jsx("ul",{className:"item-list",children:t.frozen.map(D=>i.jsx("li",{className:"item-text",children:p(D)},D))}):i.jsx(Ie,{children:"No tickets closed"})]}),t.note&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Your note"}),i.jsx("p",{children:t.note})]})]}),j.length>0&&i.jsx(CI,{changed:j,seen:l,onSeen:d}),w&&i.jsx(Ze,{label:"Note for the agent (required to reject)",children:i.jsx("textarea",{rows:2,value:o,onChange:D=>a(D.target.value)})}),e.error&&i.jsx("p",{className:"urgent-text",children:e.error}),i.jsxs("div",{className:"actions",children:[w&&i.jsxs(i.Fragment,{children:[i.jsx(M,{className:"reroute-dismiss",variant:"ghost","data-tip":"Reject it without a note of your own",onClick:()=>e.onReject(I?yI:ck),children:I?"Decline":"Dismiss"}),i.jsx(M,{className:"reroute-reject",disabled:!o.trim(),onClick:()=>e.onReject(o.trim()),children:"Reject"}),lv()?i.jsx("span",{className:"vf-intro",children:"Only an owner, or someone they allowed to make high-risk calls, can approve it."}):i.jsx(M,{className:"reroute-approve",variant:"primary",disabled:!N,onClick:()=>e.onApprove(o.trim()),children:"Approve and apply"})]}),i.jsx(M,{variant:"ghost",onClick:e.onClose,children:"Close"})]})]})})}const dk=`${pe()}/reroutes`;async function AI(e){if(!e)return[];const t=await fetch(`${dk}?map=${encodeURIComponent(e)}`);return t.ok?(await t.json()).reroutes:[]}function II(e){const t=e==null?void 0:e.map.id,[n,o]=y.useState([]),[a,l]=y.useState(),{reload:d}=Ye({view:t,version:e==null?void 0:e.tickets.reduce((f,p)=>Math.max(f,p.updatedAt),e.map.updatedAt),load:()=>AI(t),show:o,failed:()=>o([]),events:{reroute:f=>(f==null?void 0:f.mapId)===t}}),h=async(f,p,v)=>{var N,S;const k=await fetch(`${dk}/${f}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,id:p,note:v,hash:(N=n.find(I=>I.id===p))==null?void 0:N.hash})}),w=await k.json().catch(()=>({}));if(k.ok)return l(void 0),d(),!0;const j=(S=w.errors)==null?void 0:S.map(I=>I.message).join("; ");return l([w.error??`HTTP ${k.status}`,j].filter(Boolean).join(": ")),!1};return{reroutes:n,pending:n.find(f=>f.status==="pending"),error:a,clearError:()=>l(void 0),approve:(f,p)=>h("approve",f,p),reject:(f,p)=>h("reject",f,p)}}function RI(e,t){let n=t;for(let o=0;n&&o<e.length;o++){const a=e.find(l=>l.id===n);if((a==null?void 0:a.status)!=="superseded"||!a.supersededBy)break;n=a.supersededBy}return n!==t?{id:n,replaced:t}:{id:t}}function MI(e,t){const n=II(e),[o,a]=y.useState(),l=RI(n.reroutes,o),d=n.reroutes.find(k=>k.id===l.id),h=d!=null&&d.diff?d:n.pending,f=()=>{a(void 0),n.clearError()},p=k=>k&&f(),v=n.pending;return{banner:v&&i.jsx(fI,{reroute:v,onReview:()=>a(v.id),onDismiss:()=>void n.reject(v.id,ck)}),preview:e&&(h!=null&&h.diff)?aA(e,h.diff,h.frozen):void 0,openReroute:(k,w)=>{k!==(e==null?void 0:e.map.id)&&(t==null||t(k)),a(w)},dialog:e&&d&&i.jsx(EI,{reroute:d,replaced:l.replaced,snap:e,error:n.error,onApprove:k=>void n.approve(d.id,k||void 0).then(p),onReject:k=>void n.reject(d.id,k).then(p),onClose:f},d.id)}}function LI(e,t){const n=hI(e),o=MI(e,t);return{briefText:n.briefText,inboxCard:n.inboxCard,review:n.review,banner:i.jsxs(i.Fragment,{children:[n.banner,o.banner]}),preview:o.preview,openReroute:o.openReroute,dialog:i.jsxs(i.Fragment,{children:[n.dialog,o.dialog]})}}function OI(){const e=new URL(location.href);e.searchParams.has(Ys)&&(e.searchParams.delete(Ys),history.replaceState(history.state,"",e))}function PI(e,t){return e.kind!=="question"||t.pending.some(n=>n.id===e.ref)}function _I(e){const[t,n]=y.useState(()=>new URLSearchParams(location.search).get(Ys)??void 0),{loaded:o,view:a,activity:l,handlers:d,showChat:h}=e;return y.useEffect(()=>{if(!t||!o||!a)return;const f=a.items.find(v=>v.id===t);if(f&&!PI(f,l)||(n(void 0),OI(),!f))return;hv(f,{...d,openQuestion:v=>{const k=l.pending.find(w=>w.id===v);k&&h(k.sessionId,k.ticketId)}})},[t,o,a,l,d,h]),{request:y.useCallback(f=>n(f),[])}}function DI(e){const{api:t,nav:n}=e,o=mv(t.allSnaps);S$(o.view);const a=p=>p&&t.actions.selectMap(p),l={openTicket:n.openTicket,openKnowledge:()=>e.knowledge.setOpen(!0),openBrief:p=>p===t.mapId?e.reviewBrief():a(p),openReroute:e.openReroute??(p=>p.ticketId?n.openTicket(p.mapId,p.ticketId):a(p.mapId)),selectTrail:a,openGuides:e.openGuides,openConnector:e.openConnector,openApprovals:e.openApprovals},d=o.view,h=_I({loaded:t.loaded,view:d,activity:t.activity,handlers:l,showChat:n.showChat}),f=d&&i.jsx(y$,{view:d,onFocus:p=>void o.savePrefs(r0(d.prefs,p,Date.now())),onSettings:e.openFocusSettings});return{attention:o,handlers:l,header:f,link:h}}async function zI(){const e=await fetch(`${pe()}/signed-state`);return e.ok?await e.json():null}function BI(){const[e,t]=y.useState();return Ye({load:zI,show:t,failed:()=>t(null),changed:n=>n.endsWith("map.md")||n.includes("/tickets/")||n.includes("/decisions/")}),e}const FI={ticket:"held until you accept or revert it",decision:"what you see is what was signed here, until you accept or revert it"};function UI(e){return e[0]==="added"?"added outside Teamtrail":e.map(t=>t==="words"?"its words":t).join(", ")}function uk({mapId:e,kind:t,id:n}){const o=BI(),a=d=>d.mapId===e&&d.kind===t&&d.id===n,l=o==null?void 0:o.changes.find(a);return l?i.jsx(be,{className:"d-section",edge:"attention",title:"Changed outside Teamtrail",context:i.jsx(V,{parts:[`${UI(l.fields)} · ${FI[t]}`]}),detail:"By a teammate or an agent editing the file. Settings → Approvals shows what changed."}):o!=null&&o.textEdits.some(a)?i.jsx(V,{className:"d-section",parts:["Text edited outside Teamtrail"]}):null}function WI({d:e}){return e.derived?i.jsx(V,{className:"d-section",parts:["Unverified · read from text anyone who can edit the tracker wrote, not a decision Teamtrail recorded"]}):null}function HI(e){const{d:t,snap:n}=e,o=li(),[a,l]=y.useState(!1),[d,h]=y.useState(""),[f,p]=y.useState("");y.useEffect(()=>{l(!1),h(""),p("")},[t.id,t.mapId]);const v=Px(e.all.filter(S=>S.mapId===t.mapId),t.id),k=dr(t),w=t.ticketId?n==null?void 0:n.tickets.find(S=>S.id===t.ticketId):void 0,j=Date.now(),N=Nn(t.source.url);return i.jsxs("div",{className:"detail dv-d",children:[i.jsxs("div",{className:"d-head",children:[i.jsx("span",{className:"key",children:t.id}),i.jsx(bn,{tone:"state",className:`dv-st-${k}`,children:k}),i.jsx(V,{parts:[k1(t.decidedAt),`${hn(j-t.decidedAt)} ago`]})]}),i.jsx("h3",{className:"t-heading",children:t.question}),i.jsx(uk,{mapId:t.mapId,kind:"decision",id:t.id}),i.jsx(WI,{d:t}),i.jsxs("div",{className:"resolution",children:[i.jsx(ud,{parts:["Decision"]}),i.jsx("p",{children:t.answer})]}),i.jsxs("dl",{className:"facts",children:[i.jsx("dt",{children:"Trail"}),i.jsx("dd",{children:n?`${n.map.key} ${n.map.title}`:t.mapId}),i.jsx("dt",{children:"Ticket"}),i.jsx("dd",{children:t.ticketId?i.jsxs("button",{className:"link",onClick:()=>e.onOpenTicket(t.mapId,t.ticketId),children:[t.ticketKey," ",(w==null?void 0:w.title)??""," · open in trail ›"]}):"—"}),i.jsx("dt",{children:"Decided by"}),i.jsx("dd",{children:[qg(t,o),eg(t)].filter(Boolean).join(", ")}),t.participants.length>1&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Participants"}),i.jsx("dd",{children:t.participants.map(S=>S.name??S.id).join(", ")})]}),i.jsx("dt",{children:"Source"}),i.jsxs("dd",{children:[Jn[t.source.kind].label,N&&i.jsxs(i.Fragment,{children:[" · ",i.jsx("a",{href:N,target:"_blank",rel:"noreferrer",children:t.source.label??"link"})]}),!N&&t.source.label&&` · ${t.source.label}`,t.source.ref&&i.jsxs("span",{className:"ref",children:[" ",t.source.ref]})]})]}),t.alternatives.length>0&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Alternatives"}),i.jsx("ul",{className:"dv-alts",children:t.alternatives.map(S=>i.jsx("li",{children:S},S))})]}),t.rationale&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Rationale"}),i.jsx("p",{children:t.rationale})]}),v.length>1&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Supersession"}),i.jsx("ol",{className:"dv-chain",children:v.map(S=>i.jsx("li",{className:`${S.id===t.id?"cur":""} ${S.supersededBy?"old":"live"}`,children:i.jsxs("button",{onClick:()=>e.onSelect(S.id),children:[i.jsx("i",{}),i.jsx("span",{className:"id",children:S.id}),i.jsx("span",{className:"a",children:S.summary}),i.jsx(V,{parts:[ps(S.decidedBy,o),Xs(S.decidedAt)]})]})},S.id))})]}),i.jsxs("div",{className:"actions",children:[i.jsx(Ud,{draft:()=>({title:t.summary||t.question,body:[t.answer,t.rationale&&`Why: ${t.rationale}`].filter(Boolean).join(`
|
|
161
|
+
|
|
162
|
+
`),kind:"product-decision",sources:[`decision:${t.id}`,...t.ticketKey?[`ticket:${t.ticketKey}`]:[]]})}),k==="active"&&!t.postedBy&&i.jsx(M,{on:a,onClick:()=>l(S=>!S),"data-tip":"Replace this decision with a new answer. Both stay on record",children:"Supersede…"})]}),a&&i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:S=>{S.preventDefault(),d.trim()&&(e.onSupersede(t,{answer:d.trim(),rationale:f.trim(),alternatives:[t.summary]}),l(!1))},children:[i.jsx(Ze,{label:"New decision",children:i.jsx("textarea",{rows:3,value:d,onChange:S=>h(S.target.value),autoFocus:!0})}),i.jsx(Ze,{label:"Rationale",children:i.jsx("input",{value:f,onChange:S=>p(S.target.value)})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(M,{variant:"ghost",onClick:()=>l(!1),children:"Cancel"}),i.jsx(M,{type:"submit",variant:"primary",disabled:!d.trim(),children:"Supersede"})]})]}),i.jsxs("div",{className:"dv-sec",children:[i.jsxs("h4",{className:"mono-label",children:["Transcript ",i.jsx("span",{className:"n",children:t.transcript.length})]}),t.transcript.length?i.jsx("div",{className:"dv-transcript comms-log",children:t.transcript.map((S,I)=>i.jsxs("div",{className:`msg from-${S.from} voice-${S.from==="human"?"human":"agent"}`,children:[i.jsx(ud,{parts:[ps(S.author,o),Rd(S.at)]}),i.jsx("div",{className:"msg-text",children:S.text})]},I))}):i.jsx(Ie,{children:"None recorded"})]})]})}function Dt(e){return i.jsx("li",{children:i.jsxs("button",{className:`dv-opt ${e.on?"on":""} ${e.cls??""}`,onClick:e.onClick,children:[i.jsx("span",{className:"ttl",children:e.label}),i.jsx("b",{children:e.n})]})})}function KI(e){const{filter:t,set:n,all:o}=e,a=l=>o.filter(l).length;return e.compact?i.jsxs("div",{className:"dv-filters compact",children:[i.jsx(at,{compact:!0,"aria-label":"Trail",value:t.mapId??"",onChange:l=>n({mapId:l||void 0}),options:[{value:"",label:"All trails"},...e.trails.map(l=>({value:l.map.id,label:`${l.map.key} ${l.map.title}`}))]}),i.jsx(at,{compact:!0,"aria-label":"Source",value:t.source??"",onChange:l=>n({source:l||void 0}),options:[{value:"",label:"All sources"},...Fo.map(l=>({value:l,label:Jn[l].label}))]}),i.jsx(at,{compact:!0,"aria-label":"Decided by",value:t.decidedBy??"",onChange:l=>n({decidedBy:l||void 0}),options:[{value:"",label:"Anyone"},...e.people.map(l=>({value:l,label:l}))]}),i.jsx(at,{compact:!0,"aria-label":"Status",value:t.status??"",onChange:l=>n({status:l||void 0}),options:[{value:"",label:"Any status"},{value:"active",label:"Active"},{value:"superseded",label:"Superseded"}]})]}):i.jsxs("aside",{className:"dv-filters",children:[i.jsx("h3",{className:"mono-label",children:"Trail"}),i.jsxs("ul",{children:[i.jsx(Dt,{on:!t.mapId,label:"All trails",n:o.length,onClick:()=>n({mapId:void 0})}),e.trails.map(l=>i.jsx(Dt,{on:t.mapId===l.map.id,label:`${l.map.key} ${l.map.title}`,n:a(d=>d.mapId===l.map.id),onClick:()=>n({mapId:l.map.id})},l.map.id))]}),i.jsx("h3",{className:"mono-label",children:"Source"}),i.jsxs("ul",{children:[i.jsx(Dt,{on:!t.source,label:"All",n:o.length,onClick:()=>n({source:void 0})}),Fo.map(l=>i.jsx(Dt,{cls:`src-${l}`,on:t.source===l,label:Jn[l].label,n:a(d=>d.source.kind===l),onClick:()=>n({source:t.source===l?void 0:l})},l))]}),i.jsx("h3",{className:"mono-label",children:"Made by"}),i.jsxs("ul",{children:[i.jsx(Dt,{on:!t.madeBy,label:"Anyone",n:o.length,onClick:()=>n({madeBy:void 0})}),i.jsx(Dt,{on:t.madeBy==="agent",label:"Agents, on their own",n:a(l=>rr(l)==="agent"),onClick:()=>n({madeBy:t.madeBy==="agent"?void 0:"agent"})}),i.jsx(Dt,{on:t.madeBy==="human",label:"People",n:a(l=>rr(l)==="human"),onClick:()=>n({madeBy:t.madeBy==="human"?void 0:"human"})})]}),i.jsx("h3",{className:"mono-label",children:"Decided by"}),i.jsxs("ul",{children:[i.jsx(Dt,{on:!t.decidedBy,label:"Anyone",n:o.length,onClick:()=>n({decidedBy:void 0})}),e.people.map(l=>i.jsx(Dt,{on:t.decidedBy===l,label:l,n:a(d=>d.decidedBy===l),onClick:()=>n({decidedBy:t.decidedBy===l?void 0:l})},l))]}),i.jsx("h3",{className:"mono-label",children:"Status"}),i.jsxs("ul",{children:[i.jsx(Dt,{on:!t.status,label:"Any",n:o.length,onClick:()=>n({status:void 0})}),i.jsx(Dt,{on:t.status==="active",label:"Active",n:a(l=>!l.supersededBy),onClick:()=>n({status:t.status==="active"?void 0:"active"})}),i.jsx(Dt,{on:t.status==="superseded",label:"Superseded",n:a(l=>!!l.supersededBy),onClick:()=>n({status:t.status==="superseded"?void 0:"superseded"})})]})]})}const Rp=e=>`${e.mapId}/${e.id}`;function VI(e,t){var a;const n=new Map;for(const l of e){const d=((a=t[Rp(l)])==null?void 0:a.area)??Ec;n.set(d,[...n.get(d)??[],l])}const o=l=>{var d;return((d=t[Rp(l)])==null?void 0:d.citedBy.length)??0};return[...n].map(([l,d])=>({area:l,rows:[...d].sort((h,f)=>o(f)-o(h)||f.decidedAt-h.decidedAt)})).sort((l,d)=>+(l.area===Ec)-+(d.area===Ec)||d.rows.length-l.rows.length||l.area.localeCompare(d.area))}function GI(e){if(dr(e)==="superseded")return`Replaced by ${e.supersededBy}`;if(e.supersedes)return`Replaces ${e.supersedes}`}function qI(e){const{d:t}=e,n=li(),o=dr(t);return i.jsxs(i.Fragment,{children:[e.newDay&&i.jsx("li",{className:"dv-day t-label",children:e.group??Xs(t.decidedAt)}),i.jsx(be,{as:"li",className:`dv-row ${o}`,selected:e.on,onOpen:e.onClick,title:t.question,titleText:t.question,trailing:Rd(t.decidedAt),context:i.jsx(V,{parts:[{text:t.id,code:!0},t.ticketKey&&{text:t.ticketKey,code:!0},e.showTrail&&e.trail,qg(t,n),eg(t)??Jn[t.source.kind].label,GI(t),!!e.cited&&`cited ${e.cited}×`]}),detail:t.summary,detailText:t.summary})]})}function QI(e){const{rows:t,current:n,memory:o}=e,a=(l,d,h)=>{var f,p;return i.jsx(qI,{d:l,newDay:d,group:h,cited:(f=o==null?void 0:o[`${l.mapId}/${l.id}`])==null?void 0:f.citedBy.length,trail:(p=e.snaps[l.mapId])==null?void 0:p.map.key,on:(n==null?void 0:n.id)===l.id&&n.mapId===l.mapId,showTrail:e.showTrail,onClick:()=>e.onSelect(l.id)},`${l.mapId}:${l.id}`)};return o&&t.length?i.jsx("ol",{className:"dv-list","aria-label":"Logbook by area",children:VI(t,o).flatMap(l=>l.rows.map((d,h)=>a(d,h===0,`${l.area} · ${l.rows.length}`)))}):i.jsx("ol",{className:"dv-list","aria-label":"Logbook",children:t.length?t.map((l,d)=>a(l,d===0||Xs(t[d-1].decidedAt)!==Xs(l.decidedAt))):i.jsx(Ie,{children:"No decisions"})})}function YI({stats:e}){return i.jsxs("span",{className:"dv-readouts",children:[i.jsx(ln,{layout:"start",label:"Active",value:e.active}),i.jsx(ln,{layout:"start",label:"Superseded",value:e.superseded}),i.jsx(ln,{layout:"start",label:"Last 24h",value:e.last24h}),i.jsx(ln,{layout:"start",label:"Human",value:`${e.total?Math.round(e.human/e.total*100):0}%`}),i.jsx(V,{className:"dv-src-mix",parts:Fo.filter(t=>e.bySource[t]).map(t=>`${Jn[t].label} ${e.bySource[t]}`)})]})}function JI(e){const{filter:t}=e,o=Object.values(t).filter(Boolean).length-(t.query?1:0),a=e.filtersOpen||o>0;return i.jsxs("div",{className:"dv-search",children:[i.jsx("input",{type:"search",placeholder:"Search decisions",value:t.query??"",onChange:l=>e.set({query:l.target.value})}),e.showToggle&&i.jsxs("button",{className:`chip ${a?"on":""}`,onClick:e.onToggle,children:["Filters",o>0?` · ${o}`:""]})]})}async function XI(){const e=await fetch(`${pe()}/decision-memory`);return e.ok?(await e.json()).entries:null}function ZI(){const[e,t]=y.useState();return Ye({load:XI,show:t,failed:()=>t(null),changed:n=>n.includes("/decisions/")||n.endsWith("map.md")}),e}function eR(e){const{api:t,bp:n}=e,o=t.decisions,[a,l]=y.useState({}),[d,h]=y.useState(e.focus),[f,p]=y.useState(!1),[v,k]=y.useState(!1),w=ZI();y.useEffect(()=>h(e.focus),[e.focus]),y.useEffect(()=>{const q=H=>{H.key==="Escape"&&(n==="mobile"&&d?h(void 0):e.onClose())};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[n,d,e]);const j=y.useMemo(()=>aj(o,a),[o,a]),N=y.useMemo(()=>lj(o),[o]),S=o.find(q=>q.id===d&&(!a.mapId||q.mapId===a.mapId))??(n==="mobile"?void 0:j[0]),I=y.useMemo(()=>Object.values(t.allSnaps).sort((q,H)=>H.map.createdAt-q.map.createdAt),[t.allSnaps]),$=y.useMemo(()=>[...new Set(o.map(q=>q.decidedBy))].sort(),[o]),_=q=>l(H=>({...H,...q})),O=()=>{const q=Object.fromEntries(I.map(H=>[H.map.id,{key:H.map.key,title:H.map.title}]));Og(`${Z.slug}-decisions-${Xs(Date.now())}.md`,wj(j,q,{title:`${Z.name} decisions`}))},D=n==="mobile"&&!!S;return i.jsxs(Be,{className:`zone decisions-view dv-${n}`,children:[i.jsxs("header",{className:"dv-head",children:[D?i.jsx("button",{className:"back",onClick:()=>h(void 0),children:"‹ Decisions"}):i.jsxs(ze,{as:"h2",children:["Decisions ",j.length!==o.length&&i.jsx("span",{className:"n",children:`${j.length}/${o.length}`})]}),n!=="mobile"&&i.jsx(YI,{stats:N}),i.jsxs("span",{className:"dv-head-right",children:[!D&&w&&i.jsx(M,{on:v,"aria-pressed":v,onClick:()=>k(q=>!q),title:"Group by the area each decision is about, the most cited first",children:"By area"}),!D&&i.jsx(M,{onClick:O,disabled:!j.length,title:"Export the filtered list as markdown",children:"Export .md"}),i.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})]})]}),!D&&i.jsx(JI,{filter:a,set:_,showToggle:n!=="wide",filtersOpen:f,onToggle:()=>p(q=>!q)}),i.jsxs("div",{className:"dv-body",children:[(n==="wide"||f&&!D)&&i.jsx(KI,{filter:a,set:_,all:o,trails:I,people:$,compact:n!=="wide"}),!D&&i.jsx(QI,{rows:j,current:S,snaps:t.allSnaps,showTrail:n==="wide",onSelect:h,memory:v&&w?w:void 0}),(n!=="mobile"||S)&&i.jsx("div",{className:"dv-detail",children:S?i.jsx(HI,{d:S,all:o,snap:t.allSnaps[S.mapId],onSelect:h,onOpenTicket:e.onOpenTicket,onSupersede:t.actions.supersede}):i.jsx(Ie,{children:"No decision selected"})})]})]})}function tR({api:e,bp:t,nav:n}){return n.statsOpen?i.jsx(V2,{api:e,bp:t,onClose:()=>n.setStatsOpen(!1)}):n.decisionsView?i.jsx(eR,{api:e,bp:t,focus:n.decisionsView.focus,onClose:()=>n.setDecisionsView(null),onOpenTicket:n.openTicket}):null}function nR(e,t,n){const o=qv(),[a,l]=y.useState(()=>new URLSearchParams(location.search).has("projects")),d=a&&o.many&&i.jsx(b2,{projects:o,bp:e,onClose:()=>l(!1),onItemHere:n});return{projects:o,overview:d,openOverview:()=>{t.setDecisionsView(null),t.setStatsOpen(!1),l(!0)}}}const sR={"asks-you":"urgent",answered:"good",launched:"good",done:"good",verified:"good","checks-failed":"attention",stalled:"attention",disconnected:"attention",problem:"attention"};function iR(e){if(e.kind)return sR[e.kind];if(e.signal){if(e.level==="alert")return"urgent";if(e.level==="ok")return"good"}}function hk({activity:e,onTicket:t}){const n=li(),o=e.feed.slice(-120).reverse();return o.length?i.jsx("div",{className:"log",children:o.map(a=>i.jsxs("div",{className:`log-row src-${a.source.replace(" ","-")} edge-${iR(a)??"none"}`,onClick:()=>a.ticketId&&t(a.ticketId),children:[i.jsx("span",{className:"t t-meta",children:ha(a.at)}),i.jsx("span",{className:"src t-meta",children:ps(a.agent??a.source,n)}),i.jsxs("span",{className:"msg",title:a.tag?`${a.tag} · ${a.text}`:a.text,children:[a.tag&&i.jsxs("span",{className:"tag t-meta",children:[a.tag," · "]}),a.text]})]},a.id))}):i.jsx(Sn,{title:"Nothing has happened yet",hint:"Claims, steps, questions and decisions appear here as agents work."})}function Mp({lease:e,now:t}){if(!e)return null;const n=ca(e,t);if(n==="live")return null;const o=e.expiresAt-t;return i.jsxs(bn,{tone:"amber",className:"stalled",title:`No activity from ${e.agent}; the ticket returns to the queue when the lease runs out`,children:["stalled · ",n==="expired"?"returning":Jt(o)]})}function rR({total:e,step:t}){return i.jsx("span",{className:"segs","aria-label":`Step ${t} of ${e}`,children:Array.from({length:e},(n,o)=>i.jsx("i",{className:oR(o+1,t)},o))})}function oR(e,t){return e<t?"done":e===t?"cur":""}function fk({snap:e,activity:t,leases:n,onSelect:o,onOpenChat:a}){var w;const l=Xt(1e3),d=t.sessions.filter(dn),h=new Set(d.map(j=>j.ticketId)),f=Md(n,e==null?void 0:e.map.id),p=(e==null?void 0:e.tickets.filter(j=>j.state==="open"&&j.assignee&&!h.has(j.id)))??[];if(!d.length&&!p.length)return i.jsx(Ie,{children:"No agent on a ticket"});const v=j=>!!j&&ca(j,l)!=="live",k=!!((w=e==null?void 0:e.map.modelMatching)!=null&&w.enabled);return i.jsxs("ul",{className:"sessions-list",children:[d.map(j=>{const N=e==null?void 0:e.tickets.find($=>$.id===j.ticketId),S=N?cr(N)==="hitl":!1,I=N&&f.get(N.id);return i.jsx(be,{as:"li",className:j.waitingOn?"waiting":void 0,edge:aR(j,v(I)),title:dR(N,j.mode)||j.agent,context:i.jsx(V,{parts:[{text:j.agent,strong:!0},k&&lR(j),j.waitingOn?{text:"Waiting on you",urgent:!0}:`${j.mode} · ${j.stepLabel.toLowerCase()}`,S&&!j.waitingOn&&"with you",cR(j)],children:i.jsx(Mp,{lease:I,now:l})}),trailing:Pg(l-j.startedAt),below:i.jsx(rR,{total:j.total,step:j.step}),onOpen:()=>{N&&o({kind:"ticket",id:N.id}),S&&a(j.id)}},j.id)}),p.map(j=>i.jsx(be,{as:"li",className:"claim",edge:v(f.get(j.id))?"attention":"neutral",title:`${j.key} ${j.title}`,context:i.jsx(V,{parts:[{text:j.assignee??"",strong:!0},"claimed, no live session"],children:i.jsx(Mp,{lease:f.get(j.id),now:l})}),onOpen:()=>o({kind:"ticket",id:j.id})},j.id))]})}function aR(e,t){return e.waitingOn?"urgent":t?"attention":"neutral"}function lR(e){const t=e.model?`Runs ${e.model}`:"No model reported, so it counts as balanced";return{text:e.tier??"balanced",tip:t,className:"session-tier"}}function cR(e){if(e.usage)return`${fa(ij(e))} tok · ${Js(e.usage.costUsd)}`}function dR(e,t){return e?`${e.key} ${e.title}`:t==="chart"?"Charting trail":""}function mk({activity:e,snap:t,running:n,usage:o=!0}){const a=rg(e,t==null?void 0:t.map.id),l=ag(e,t==null?void 0:t.map.id),d=new Set(e.sessions.filter(dn).map(f=>f.ticketId)),h=(t==null?void 0:t.tickets.filter(f=>f.state==="open"&&f.assignee&&!d.has(f.id)).length)??0;return i.jsx(At,{sub:!0,className:"sessions-head",title:i.jsxs(i.Fragment,{children:["Agents on tickets ",i.jsx("span",{className:"n",children:n+h})]}),right:o?i.jsxs("span",{className:"usage",title:["Model usage for this trail, all sessions",...l.map(f=>og[f].text)].join(`
|
|
163
|
+
`),children:[i.jsx("span",{className:"mono-label",children:"Trail"})," ",fa(a.inputTokens+a.outputTokens)," tok · ",Js(a.costUsd)]}):void 0})}function uR(e){const t=[...e.feed].reverse().find(n=>n.level==="step"&&n.sessionId);return t?e.sessions.find(n=>n.id===t.sessionId):void 0}const hR={running:"Working",done:"Done",failed:"Stopped"};function pk({activity:e,snap:t}){var d;const n=uR(e);if(!n)return i.jsx(Sn,{title:"No agent working yet",hint:Et()?`Turn your agents on for this trail in ${(d=Et())==null?void 0:d.label}. Each step they report shows here.`:"Run /scout resume in Claude Code or Codex. Each step an agent reports shows here."});const o=n.ticketId?t==null?void 0:t.tickets.find(h=>h.id===n.ticketId):void 0,a=ra[n.mode],l=n.waitingOn?"Waiting on you":hR[n.status];return i.jsxs("div",{className:`step-tracker ${n.waitingOn?"waiting":""}`,children:[i.jsxs("div",{className:"st-meta",children:[i.jsx(V,{parts:[{text:n.agent,strong:!0},`${n.mode}, step ${n.step} of ${n.total}`]}),i.jsx("span",{className:`t-label st-status ${n.waitingOn?"urgent":""}`,children:l})]}),i.jsxs("div",{className:"st-big",children:[n.stepLabel,o&&i.jsxs("span",{className:"st-key",children:[" ",o.key]})]}),o&&i.jsx("div",{className:"st-ticket t-meta",children:o.title}),i.jsx("ol",{className:"pipeline",children:a.map((h,f)=>{const p=f+1,v=p<n.step||p===n.step&&n.status==="done";let k="";return v?k="done":p===n.step&&(k="cur"),i.jsxs("li",{className:k,children:[i.jsx("i",{}),i.jsxs("span",{children:[String(p).padStart(2,"0")," ",h]})]},h)})})]})}function Lp(e){return i.jsxs("div",{className:"zone-b activity-stack",children:[i.jsx(pk,{activity:e.activity,snap:e.snap}),i.jsx(mk,{activity:e.activity,snap:e.snap,running:e.activity.sessions.filter(dn).length}),i.jsx(fk,{snap:e.snap,activity:e.activity,leases:e.leases,onSelect:t=>(t==null?void 0:t.kind)==="ticket"&&e.onTicket(t.id),onOpenChat:e.onOpenChat}),i.jsx(At,{sub:!0,title:"Activity log"}),i.jsx(hk,{activity:e.activity,onTicket:e.onTicket})]})}function fR(e){return i.jsx(Zg,{area:"log",className:"log-zone",icon:"book",title:"Activity log",info:"Everything that happened in this trail, newest first: claims, steps, questions, decisions and errors.",right:i.jsxs("span",{className:"mono-label dim",children:[e.activity.feed.length," events"]}),children:i.jsx(hk,{activity:e.activity,onTicket:e.onTicket})})}function mR(e){var o;const t=e.activity.sessions.filter(dn).length,n=!e.activity.sessions.length&&!((o=e.snap)!=null&&o.tickets.some(a=>a.state==="open"&&a.assignee));return i.jsxs(Be,{className:"zone step-zone",style:{gridArea:"step"},children:[i.jsx(At,{className:"zone-title",icon:"tent",title:"Current trail step",info:"What your agents are doing right now. The top shows the latest step an agent reported; below is every agent holding a ticket."}),i.jsxs("div",{className:"zone-b",children:[i.jsx(pk,{activity:e.activity,snap:e.snap}),!n&&i.jsxs(i.Fragment,{children:[i.jsx(mk,{activity:e.activity,snap:e.snap,running:t,usage:!1}),i.jsx(fk,{snap:e.snap,activity:e.activity,leases:e.leases,onSelect:a=>(a==null?void 0:a.kind)==="ticket"&&e.onTicket(a.id),onOpenChat:e.onOpenChat})]})]})]})}const pR=e=>typeof e=="string"&&/^\/(?!\/)[\w/?=&#.-]{0,200}$/.test(e)?e:void 0;function gR(e){const t=e;if(!Number.isInteger(t==null?void 0:t.done)||!Number.isInteger(t==null?void 0:t.total)||!Array.isArray(t==null?void 0:t.steps))return;const n=t.steps.slice(0,10).flatMap(o=>{const a=pR(o==null?void 0:o.href);return typeof(o==null?void 0:o.title)!="string"||!a?[]:[{title:o.title.slice(0,80),href:a,done:o.done===!0,next:o.next===!0,optional:o.optional===!0}]});return{done:t.done,total:t.total,complete:t.complete===!0,steps:n}}function vR(){var o;const e=(o=ft())==null?void 0:o.setup,[t,n]=y.useState();return y.useEffect(()=>{if(!e)return;const a=()=>void fetch(e).then(d=>d.ok?d.json():void 0).then(d=>n(gR(d))).catch(()=>{});a();const l=()=>document.visibilityState==="visible"&&a();return document.addEventListener("visibilitychange",l),()=>document.removeEventListener("visibilitychange",l)},[e]),t}const gk="teamtrail.guide.open";function kR(){try{return localStorage.getItem(gk)!=="no"}catch{return!0}}function yR(e){try{localStorage.setItem(gk,e?"yes":"no")}catch{}}function wR(){const e=vR(),[t,n]=y.useState(kR);if(!e||e.complete)return null;const o=l=>{n(l),yR(l)},a=`${e.done} of ${e.total}`;return Ov.createPortal(i.jsxs("aside",{className:`setup-guide${t?" open":""}`,"aria-label":"Get started",children:[t&&i.jsxs("div",{className:"setup-bubble",children:[i.jsxs("header",{children:[i.jsx("b",{children:"Get started"}),i.jsx("span",{className:"t-meta",children:a}),i.jsx(M,{size:"sm",variant:"ghost",onClick:()=>o(!1),"aria-label":"Minimize",children:"–"})]}),i.jsx("ol",{children:e.steps.map((l,d)=>i.jsxs("li",{className:[l.done&&"done",l.next&&"next"].filter(Boolean).join(" "),children:[i.jsx("span",{className:"setup-mark","aria-hidden":"true",children:l.done?"✓":d+1}),i.jsx("a",{href:l.href,children:l.title}),l.optional&&i.jsx("span",{className:"t-meta",children:"optional"})]},l.href+l.title))})]}),i.jsxs("button",{type:"button",className:"setup-scout",onClick:()=>o(!t),"aria-expanded":t,children:[i.jsx(ua,{size:1,framed:!1,state:"idle"}),!t&&i.jsxs("span",{className:"setup-chip",children:["Get started · ",a]})]})]}),document.body)}function xR(e){const t=ba(e.ticketId,e.hash),[n,o]=y.useState(),a=e.confirmed?"Unconfirm":"Confirm criteria",l=e.confirmed?"Take your confirmation back":"Agree that these criteria define done for this ticket",d=t.changed&&!e.confirmed;return i.jsxs(i.Fragment,{children:[t.changed&&i.jsx(ya,{what:"These criteria",onReviewAgain:t.reviewAgain}),i.jsx(M,{size:"sm",variant:e.confirmed?"ghost":"default",disabled:d,"data-tip":l,onClick:()=>void e.confirm(!e.confirmed,t.hash).then(o),children:a}),n&&i.jsx("p",{className:"vf-err",children:n})]})}function jR(e){const{proposal:t}=e;return i.jsxs("div",{className:"crit-proposal edge-note edge-attention",children:[i.jsxs("p",{className:"t-meta",children:[t.by," proposes new criteria. Yours stay in force until you take these."]}),i.jsx("ul",{className:"item-list",children:t.criteria.map(n=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:n.text}),i.jsx(V,{parts:[{text:n.id,code:!0},n.kind.replace("-"," "),n.source&&`from ${n.source}`]})]},n.id))}),i.jsxs("div",{className:"actions",children:[i.jsx(M,{size:"sm",variant:"ghost",onClick:e.onDismiss,children:"Keep mine"}),i.jsx(M,{size:"sm",disabled:!e.canAccept,onClick:e.onAccept,children:"Take these"})]})]})}function SR(e){const{proposal:t}=e,n=ba(`${t.ticketId}@${t.at}`,t.hash),[o,a]=y.useState(),l=d=>void e.decide(d,n.hash).then(a);return i.jsxs(i.Fragment,{children:[n.changed&&i.jsx(ya,{what:"The proposal",onReviewAgain:n.reviewAgain}),i.jsx(jR,{proposal:t,canAccept:!n.changed,onAccept:()=>l("accept"),onDismiss:()=>l("dismiss")}),o&&i.jsx("p",{className:"vf-err",children:o})]})}async function vk(e){return e?e.ok?void 0:(await e.json().catch(()=>({}))).error??`HTTP ${e.status}`:"Could not reach the Lookout"}const kk=`${pe()}/criteria`;async function NR(e){if(!e)return[];const t=await fetch(`${kk}?mapId=${encodeURIComponent(e)}`);return t.ok?(await t.json()).tickets:[]}function bR(e){const[t,n]=y.useState([]),{reload:o}=Ye({view:e,load:()=>NR(e),show:n,failed:()=>n([]),changed:l=>l.startsWith("criteria/")});return{tickets:t,confirm:l=>fetch(`${kk}/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,...l})}).catch(()=>{}).then(async d=>{const h=await vk(d);return o(),h})}}const yk=`${pe()}/criteria-proposals`;async function $R(e){if(!e)return[];const t=await fetch(`${yk}?mapId=${encodeURIComponent(e)}`);return t.ok?(await t.json()).proposals:[]}function CR(e){const[t,n]=y.useState([]),{reload:o}=Ye({view:e,load:()=>$R(e),show:n,failed:()=>n([]),events:{"criteria-proposals":l=>(l==null?void 0:l.mapId)===e}});return{proposals:t,decide:(l,d)=>fetch(`${yk}/${l}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,...d})}).catch(()=>{}).then(async h=>{const f=await vk(h);return o(),f})}}function TR({snap:e,t}){const{tickets:n,confirm:o}=bR(e.map.id),a=CR(e.map.id),l=a.proposals.find(k=>k.ticketId===t.id),d=ai(),h=n.find(k=>k.ticketId===t.id),f=(h==null?void 0:h.criteria)??[],v=yg(d.entries,{trailKey:e.map.key,ticket:{type:t.type,title:t.title,body:t.body},paths:wg(`${t.body}
|
|
164
|
+
${d.briefText}`)}).filter(k=>k.kind==="business-rule").filter(k=>Bj(f,[k.id]).length);return!f.length&&!v.length&&!l?null:i.jsxs("div",{className:"criteria-section d-section",children:[i.jsxs("span",{className:"t-label","data-tip":"Agreed before the work starts; each needs evidence before the ticket counts as done",children:["Acceptance criteria · ",f.length,(h==null?void 0:h.confirmed)&&i.jsx("span",{className:"ok-text",children:" · confirmed by you"})]}),f.length>0&&i.jsx("ul",{className:"criteria-list item-list",children:f.map(k=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:k.text}),i.jsx(V,{parts:[{text:k.id,code:!0},k.kind.replace("-"," "),k.source&&`from ${k.source}`]})]},k.id))}),l&&i.jsx(SR,{proposal:l,decide:(k,w)=>a.decide(k,{title:e.map.title,ticketId:t.id,hash:w})}),v.length>0&&i.jsxs("div",{className:"crit-uncovered edge-note edge-attention",children:[i.jsx("p",{className:"t-meta",children:"No criterion covers these rules yet:"}),i.jsx("ul",{className:"item-list",children:v.map(k=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:k.title}),i.jsx(V,{parts:[{text:k.id,code:!0},"business rule"]})]},k.id))})]}),f.length>0&&t.state==="open"&&i.jsx(xR,{ticketId:t.id,hash:h==null?void 0:h.hash,confirmed:!!(h!=null&&h.confirmed),confirm:(k,w)=>o({title:e.map.title,ticketId:t.id,ticketKey:t.key,confirmed:k,hash:w})})]})}const Zo="";function ER(e){const t=bd.map(o=>({value:o,label:ar[o],hint:pv[o]})),n=[...AR(e),...t];return i.jsx(at,{compact:!0,className:"vf-level","aria-label":"Verification level",value:e.value??Zo,options:n,onChange:o=>e.onChange(o===Zo?null:o)})}function AR(e){return e.inherit!==void 0?[{value:Zo,label:e.inherit,hint:"Use the trail’s level for this ticket."}]:e.value===void 0?[{value:Zo,label:"Off (not set)"}]:[]}function IR({check:e}){const t=C$(e),[n,o]=y.useState(),[a,l]=y.useState(),d=RR(e);return i.jsxs("details",{className:`vf-row ${t?"ok":"bad"}`,open:!t,children:[i.jsxs("summary",{children:[i.jsx("span",{className:"vf-mark",children:t?"✓":"✕"}),i.jsx("span",{className:"t-code vf-name",children:e.name}),i.jsx("span",{className:"t-meta",children:d}),i.jsx("span",{className:"t-meta vf-dur",children:Jt(e.durationMs)})]}),i.jsx("code",{className:"vf-argv",children:e.argv.join(" ")}),e.error&&i.jsx("p",{className:"vf-note",children:e.error}),i.jsx("pre",{className:"vf-tail",children:n??(e.tail||"No output.")}),i.jsxs("div",{className:"vf-log-line",children:[n===void 0&&i.jsx("button",{className:"link",onClick:()=>fr.log(e.log).then(h=>o(h.clipped?`[earlier output not shown]
|
|
165
|
+
${h.text}`:h.text),h=>l(h.message)),children:"Full log ›"}),e.truncated&&i.jsx("span",{className:"dim",children:"log capped at 1 MB"}),a&&i.jsx("span",{className:"vf-err",children:a})]})]})}function RR(e){return e.error?"did not start":e.timedOut?"timed out":`exit ${e.exitCode??e.signal??"?"}`}const Op=e=>(e==null?void 0:e.slice(0,8))??"none",Pp=e=>e===null?"·":String(e);function MR({attempt:e}){var d;const t=e.git;if(!t)return null;const{files:n,add:o,del:a}=t.stats,l=new Set(((d=t.flags.find(h=>h.kind==="outside-scope"))==null?void 0:d.files)??[]);return i.jsxs("div",{className:"vf-git",children:[i.jsx(V,{parts:[t.tree?{text:`${t.base?`${Op(t.base.head)} → `:""}${Op(t.tree.head)}`,code:!0}:"not a git repo",t.tree&&{text:t.tree.branch??"detached HEAD",code:!!t.tree.branch},t.tree&&`${n} file${n===1?"":"s"} +${o} −${a}`]}),t.flags.filter(h=>h.kind!=="no-git").map(h=>{var f;return i.jsxs("p",{className:`vf-flag lv-${h.level}`,title:(f=h.files)==null?void 0:f.join(`
|
|
166
|
+
`),children:[i.jsx("span",{className:"t-code",children:h.kind})," ",h.message]},h.kind)}),t.changed.length>0&&i.jsxs("details",{className:"vf-files",children:[i.jsx("summary",{className:"t-label",children:"Changed files"}),i.jsx("ul",{children:t.changed.map(h=>i.jsxs("li",{children:[i.jsx("code",{children:h.path}),i.jsxs("span",{className:"dim",children:[h.untracked?"new":`+${Pp(h.add)} −${Pp(h.del)}`,h.dirtyAtClaim?" · dirty at claim":"",l.has(h.path)?" · outside the declared files":""]})]},h.path))})]})]})}function LR({attempt:e,latest:t}){return i.jsxs("details",{className:`vf-attempt r-${e.result}`,open:t,children:[i.jsxs("summary",{children:[i.jsx(bn,{tone:"state",className:`r-${e.result}`,children:$$[e.result]}),i.jsx(V,{parts:[{text:e.id,code:!0},e.agent,hr(e.submittedAt),Jt(e.finishedAt-e.submittedAt)]})]}),i.jsx("p",{className:"vf-claim",children:e.summary??e.resolution}),e.note&&i.jsx("p",{className:"vf-note",children:e.note}),e.criteria&&i.jsx("ul",{className:"vf-criteria",children:e.criteria.lines.map(n=>i.jsx("li",{className:OR(n),children:n},n))}),i.jsx(MR,{attempt:e}),e.checks.map(n=>i.jsx(IR,{check:n},n.name))]})}function OR(e){return e.includes(" ✓ ")?"ok":e.includes(" ✗ ")?"bad":e.includes(" ? ")?"claimed":"wait"}const PR={PASS:"Passed",FAIL:"Sent back",NEEDS_HUMAN:"Needs you"};function _R({verdict:e}){const{guide:t,checklist:n}=e;return i.jsxs("div",{className:`vf-verdict v-${e.verdict.toLowerCase()}`,children:[i.jsx(V,{parts:[{text:e.byKind==="trail lead"&&e.verdict==="PASS"?"Approved":PR[e.verdict],strong:!0},{text:e.id,code:!0},e.byKind==="trail lead"?e.by:`review ${e.by}`,e.sessionId&&`session ${e.sessionId.slice(0,8)}`,t&&`as ${t.id} ${t.version}`,`on ${e.attemptId}`,hr(e.at)]}),i.jsx("p",{children:e.summary}),e.findings.length>0&&i.jsx("ul",{className:"vf-findings",children:e.findings.map((o,a)=>i.jsxs("li",{className:`sev-${o.severity}`,children:[o.path&&i.jsx("code",{children:o.line?`${o.path}:${o.line}`:o.path})," ",o.text]},a))}),n&&n.length>0&&i.jsx(Cv,{answers:n})]})}function DR(e,t,n){const[o,a]=y.useState(),l=`${e}/${t}`;y.useEffect(()=>a(void 0),[l]);const{reload:d}=Ye({view:l,version:n,load:()=>fr.ticket(e,t),show:a});return y.useEffect(()=>ei.onEvidence(d),[d]),{data:o,reload:d}}const Jc={rework:{label:"What to fix",submit:"Send to rework",hint:"Posted on the ticket for the next agent."},accept:{label:"Why accept",submit:"Accept anyway",hint:"Closes the ticket as done despite the checks."},unblock:{label:"Why",submit:"Unblock",hint:"Back to the queue without running checks."}};function zR(e){const[t,n]=y.useState(),[o,a]=y.useState(""),[l,d]=y.useState("rework"),{state:h,submitted:f,running:p,act:v}=e;if(p||h!=="verifying"&&h!=="held")return null;const k=j=>{n(t===j?void 0:j),a("")},w=j=>{j.preventDefault(),!(!t||!o.trim())&&(v({action:t,reason:o.trim(),...t==="unblock"?{to:l}:{}}),n(void 0))};return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"actions vf-actions",children:[h==="verifying"&&f&&i.jsx(M,{variant:"primary",onClick:()=>void v({action:"approve"}),"data-tip":"Checks passed: approve and close the ticket",children:"Approve"}),f&&i.jsx(M,{onClick:()=>void v({action:"rerun"}),"data-tip":"Run the repo's checks again on the current code",children:"Re-run checks"}),i.jsx(M,{on:t==="rework",onClick:()=>k("rework"),"data-tip":"Send it back to an agent with what to fix",children:"Rework…"}),h==="held"&&i.jsxs(i.Fragment,{children:[i.jsx(M,{on:t==="accept",onClick:()=>k("accept"),"data-tip":"Close it as done despite the failing checks",children:"Accept anyway…"}),i.jsx(M,{on:t==="unblock",onClick:()=>k("unblock"),"data-tip":"Put it back in the queue without running checks",children:"Unblock…"})]})]}),t&&i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:w,children:[i.jsx(Ze,{label:Jc[t].label,children:i.jsx("textarea",{rows:2,value:o,onChange:j=>a(j.target.value),autoFocus:!0})}),t==="unblock"&&i.jsx(Ze,{label:"Back to",children:i.jsx(at,{"aria-label":"Back to",value:l,onChange:d,options:[{value:"rework",label:"Rework",hint:"Keeps the feedback for the next agent."},{value:"ready",label:"Ready",hint:"Back in the queue as a fresh ticket."}]})}),i.jsx("span",{className:"dim vf-hint",children:Jc[t].hint}),i.jsxs("div",{className:"form-actions",children:[i.jsx(M,{variant:"ghost",onClick:()=>n(void 0),children:"Cancel"}),i.jsx(M,{type:"submit",variant:t==="accept"?"danger":"primary",disabled:!o.trim(),children:Jc[t].submit})]})]})]})}const BR={ticket:"set on this ticket",trail:"from the trail",none:"not set"},FR=new Set(["verifying","rework","held"]);function UR(e){const{mapId:t,ticket:n,state:o}=e,{data:a,reload:l}=DR(t,n.id,n.updatedAt),[d,h]=y.useState();if(!a||a.level.level==="off"&&!a.attempts.length&&!FR.has(o))return null;const f=v=>(h(void 0),fr.act({...v,mapId:t,ticketId:n.id,by:St}).then(l,k=>h(k.message))),p=a.running;return i.jsxs("section",{className:"vf-panel",children:[i.jsxs("div",{className:"vf-head",children:[i.jsx(ze,{as:"h4",children:"Verification"}),i.jsx(V,{parts:[ar[a.level.level],BR[a.level.source]]}),n.state==="open"&&i.jsx(ER,{value:n.verification,inherit:`Trail (${ar[e.trail??"off"]})`,onChange:v=>void f({action:"level",level:v})})]}),p&&i.jsxs("div",{className:"sync-line vf-running",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:["Checking ",p.id," for ",p.agent," · since ",hr(p.startedAt)]})]}),i.jsx(zR,{state:o,submitted:a.attempts.length>0,running:!!p,act:f}),d&&i.jsx("p",{className:"vf-err",children:d}),a.verdicts.map(v=>i.jsx(_R,{verdict:v},v.id)),a.attempts.map((v,k)=>i.jsx(LR,{attempt:v,latest:k===0},v.id)),!a.attempts.length&&!p&&i.jsx(V,{parts:[`Checks: ${a.level.checks.join(", ")||"none"}`,"run when the ticket is submitted"]})]})}function WR({lease:e,onRelease:t}){const n=Xt(1e3),o=ca(e,n),a=o==="live";return i.jsxs("div",{className:`lease lease-${o} edge-note ${a?"":"edge-attention"}`,children:[i.jsxs("div",{className:"edge-note-head",children:[i.jsx(V,{parts:[{text:`Claimed by ${e.agent}`,strong:!0},`active ${hn(n-e.renewedAt)} ago`]}),!a&&i.jsx(bn,{tone:"amber",children:"Stalled"})]}),i.jsx("p",{className:"t-meta lease-line",children:HR(o,KR(e.expiresAt-n))}),e.workspace&&i.jsxs("p",{className:"t-meta lease-branch",children:["Works on ",i.jsx("code",{className:"t-code",children:e.workspace.branch})," in its own worktree"]}),e.touches&&e.touches.length>0&&i.jsxs("p",{className:"t-meta lease-touches",children:["Expects to change"," ",e.touches.map((l,d)=>i.jsxs("span",{children:[d>0&&", ",i.jsx("code",{className:"t-code",children:l})]},l))]}),e.notes.length>0&&i.jsx("ul",{className:"lease-notes t-meta",children:e.notes.slice(-3).map((l,d)=>i.jsx("li",{children:l},d))}),i.jsx("div",{className:"actions",children:i.jsx(M,{variant:a?"default":"urgent",onClick:t,children:"Release to queue"})})]})}function HR(e,t){return e==="expired"?"Lease expired, going back to the queue":e==="stalled"?`The agent went quiet. Back in the queue in ${t}.`:`Back in the queue after ${t} without activity.`}function KR(e){const t=e/864e5;return t>=2?`${Math.round(t)} days`:Jt(Math.max(0,e))}function VR({comments:e}){const t=li();if(!e.length)return null;const n=e.length>1?"s":"";return i.jsxs("details",{className:"comments",children:[i.jsxs("summary",{className:"t-label",children:[e.length," other comment",n]}),e.map(o=>i.jsxs("div",{className:"comment",children:[i.jsx(V,{parts:[{text:ps(o.author,t),strong:!0}]}),i.jsx("div",{className:"c-body",children:o.body.replace(/\*\*/g,"")})]},o.id))]})}function GR({resolution:e,decisions:t,onOpenDecision:n}){const o=li(),a=t.find(h=>!h.supersededBy)??t[0],l=e.body.startsWith("**Ruled")?"ruled out":"resolution",d=t.length>1?` · ${t.length} in chain`:"";return i.jsxs("div",{className:"resolution edge-note edge-done",children:[i.jsxs("div",{className:"edge-note-head",children:[i.jsx(V,{parts:[{text:ps(e.author,o),strong:!0},l]}),a&&n&&i.jsxs("button",{className:"link t-meta",onClick:()=>n(a.id),children:[a.id,d," ›"]})]}),i.jsx("p",{children:e.body.replace(/^\*\*[^*]+\*\*\s*/,"")})]})}function qR(e){const{t,state:n,session:o,mine:a,form:l,setForm:d,actions:h,onOpenChat:f}=e;return i.jsxs("div",{className:"actions",children:[o&&i.jsx(M,{variant:o.waitingOn?"urgent":"default",onClick:()=>f(o.id),"data-tip":o.waitingOn?"The agent is waiting for your answer":"Open the conversation with this agent",children:o.waitingOn?"Answer":"Conversation"}),n==="frontier"&&i.jsx(M,{onClick:()=>h.claim(t.id),"data-tip":"Take this ticket yourself, so no agent picks it up",children:"Claim"}),(n==="frontier"||n==="claimed"&&a)&&i.jsx(M,{on:l==="resolve",onClick:()=>d(l==="resolve"?null:"resolve"),"data-tip":"Answer it yourself and close the ticket, with a decision record",children:"Resolve…"}),a&&n==="claimed"&&i.jsx(M,{onClick:()=>h.release(t.id),"data-tip":"Give the ticket back to the queue",children:"Release"}),(n==="frontier"||n==="blocked"||n==="parked")&&i.jsx(M,{variant:"danger",on:l==="rule",onClick:()=>d(l==="rule"?null:"rule"),"data-tip":"Move it out of scope. It's set aside with your reason, not deleted",children:"Rule out…"})]})}function QR(e){return e.replace(/\s*Part of trail \S+\.\s*$/,"").trim()}function YR({t:e,state:t,tickets:n}){const o=new Map(n.map(p=>[p.id,p])),a=p=>{var v;return((v=o.get(p))==null?void 0:v.key)??p},l=e.blockedBy.map(p=>{var v;return`${a(p)}${((v=o.get(p))==null?void 0:v.state)==="closed"?" ✓":""}`}).join(", "),d=n.filter(p=>p.blockedBy.includes(e.id)).map(p=>p.key).join(", "),h=[["Type",Zs[e.type]],["Assignee",e.assignee],["Blocked by",l],["Blocks",d],["Reviews",e.reviewOf&&a(e.reviewOf)]],f=cr(e)==="hitl";return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"d-head",children:[i.jsx("span",{className:"key t-code",children:e.key}),i.jsx(bn,{tone:"state",className:`st-${t}`,children:Dg[t]}),i.jsx("span",{className:"d-att t-meta","data-tip":f?"A person takes this one":"An agent takes this alone",children:f?"Needs a person":"Agent work"})]}),i.jsx("h3",{className:"t-heading",children:e.title}),i.jsx("dl",{className:"facts",children:h.filter(([,p])=>p).flatMap(([p,v])=>[i.jsx("dt",{className:"t-label",children:p},`${p}-k`),i.jsx("dd",{children:v},`${p}-v`)])})]})}function JR(e){const{snap:t,api:n,form:o,setForm:a}=e,{actions:l}=n,[d,h]=y.useState(""),[f,p]=y.useState(""),[v,k]=y.useState(""),[w,j]=y.useState("Not needed to reach the destination."),N=t.tickets.find(G=>G.id===e.id);if(!N)return i.jsx(Ie,{children:"Ticket not found."});const S=ti(t.tickets,t.map.mode).get(N.id),I=e.sessions.find(G=>G.ticketId===N.id&&dn(G)),$=N.assignee===St,_=N.state==="open"?Md(n.leases,t.map.id).get(N.id):void 0,O=[...N.comments].reverse().find(G=>/^\*\*(Resolution|Ruled out of scope)\*\*/.test(G.body)),D=N.comments.filter(G=>G!==O),q=QR(N.body),H=n.decisions.filter(G=>G.mapId===t.map.id&&G.ticketId===N.id);return i.jsxs("div",{className:"detail",children:[i.jsx(YR,{t:N,state:S,tickets:t.tickets}),i.jsx(uk,{mapId:t.map.id,kind:"ticket",id:N.id}),q&&i.jsxs("section",{className:"d-section ticket-body",children:[i.jsx("span",{className:"t-label",children:"Description"}),i.jsx("p",{className:"body",children:q})]}),i.jsx(L2,{mapId:t.map.id,ticketId:N.id}),i.jsx(RN,{mapId:t.map.id,ticketId:N.id}),i.jsx(_T,{mapId:t.map.id,ticket:N}),i.jsx(TR,{snap:t,t:N}),i.jsx(rb,{snap:t,t:N}),N.closeReason==="not_planned"&&i.jsx(Ud,{label:"Save as dead end",draft:()=>{var G;return{title:`Ruled out: ${N.title}`,body:((G=N.comments.at(-1))==null?void 0:G.body)??N.body,kind:"dead-end",sources:[`trail:${t.map.key}`,`ticket:${N.key}`]}}}),_&&i.jsx(WR,{lease:_,onRelease:()=>l.releaseLease(N.id)}),!_&&i.jsx(u2,{mapId:t.map.id,ticketId:N.id}),i.jsx(UR,{mapId:t.map.id,trail:t.map.verification,ticket:N,state:S}),i.jsx(HT,{mapId:t.map.id,ticket:N}),i.jsx(qR,{t:N,state:S,session:I,mine:$,form:o,setForm:a,actions:l,onOpenChat:e.onOpenChat}),o==="resolve"&&i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:G=>{G.preventDefault(),d.trim()&&(l.resolve(N.id,d.trim(),{rationale:f.trim(),alternatives:v.split(`
|
|
167
|
+
`).map(oe=>oe.trim()).filter(Boolean)}),a(null),h(""),p(""),k(""))},children:[i.jsx(Ze,{label:"Resolution",children:i.jsx("textarea",{rows:3,value:d,onChange:G=>h(G.target.value),autoFocus:!0})}),i.jsx(Ze,{label:"Rationale",children:i.jsx("input",{value:f,onChange:G=>p(G.target.value)})}),i.jsx(Ze,{label:"Alternatives considered",children:i.jsx("textarea",{rows:2,value:v,onChange:G=>k(G.target.value),placeholder:"One per line"})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(M,{variant:"ghost",onClick:()=>a(null),children:"Cancel"}),i.jsx(M,{type:"submit",variant:"primary",disabled:!d.trim(),children:"Resolve"})]})]}),o==="rule"&&i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:G=>{G.preventDefault(),l.ruleOut({ticketId:N.id},w),a(null)},children:[i.jsx(Ze,{label:"Reason",children:i.jsx("input",{value:w,onChange:G=>j(G.target.value),autoFocus:!0})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(M,{variant:"ghost",onClick:()=>a(null),children:"Cancel"}),i.jsx(M,{type:"submit",variant:"danger",children:"Rule out"})]})]}),O&&i.jsx(GR,{resolution:O,decisions:H,onOpenDecision:e.onOpenDecision}),i.jsx(VR,{comments:D})]})}function XR({snap:e,item:t,api:n}){const o=Xp(e.map.mode),[a,l]=y.useState("research"),[d,h]=y.useState(t),[f,p]=y.useState(!1),[v,k]=y.useState([]),[w,j]=y.useState("Not needed to reach the destination.");y.useEffect(()=>h(t),[t]);const N=e.tickets.filter(S=>S.state==="open");return i.jsxs("div",{className:"detail",children:[i.jsx("div",{className:"d-head",children:i.jsx(bn,{tone:"state",className:"st-unspecified",children:"Not yet specified"})}),i.jsx("h3",{className:"t-heading",children:t}),i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:S=>{S.preventDefault(),n.actions.graduate({unspecified:t,type:a,title:d,blockedBy:v,hitl:f})},children:[i.jsx(Ze,{label:"Title",children:i.jsx("input",{value:d,onChange:S=>h(S.target.value)})}),i.jsxs("div",{className:"chips",children:[o.map(S=>i.jsx("button",{type:"button",className:`chip ${a===S?"on":""}`,onClick:()=>l(S),children:S},S)),Rw.includes(a)&&i.jsx("button",{type:"button",className:`chip ${f?"on":""}`,onClick:()=>p(S=>!S),children:"needs human"})]}),i.jsx("span",{className:"field",children:"Blocked by"}),i.jsx("div",{className:"chips",children:N.map(S=>i.jsx("button",{type:"button",className:`chip ${v.includes(S.id)?"on":""}`,onClick:()=>k(I=>I.includes(S.id)?I.filter($=>$!==S.id):[...I,S.id]),children:S.key},S.id))}),i.jsx("div",{className:"form-actions",children:i.jsx(M,{type:"submit",variant:"primary",children:"Promote to ticket"})})]}),i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:S=>{S.preventDefault(),n.actions.ruleOut({unspecified:t},w)},children:[i.jsx(Ze,{label:"Reason",children:i.jsx("input",{value:w,onChange:S=>j(S.target.value)})}),i.jsx("div",{className:"form-actions",children:i.jsx(M,{type:"submit",variant:"danger",children:"Rule out"})})]})]})}function ZR({api:e,sessions:t,bare:n,onOpenChat:o,onOpenDecision:a}){const{snap:l,selection:d,actions:h}=e,[f,p]=y.useState(null),v=eM(d);y.useEffect(()=>p(null),[v]);let k;return l?d?d.kind==="unspecified"?k=i.jsx(XR,{snap:l,item:d.item,api:e}):k=i.jsx(JR,{snap:l,id:d.id,api:e,sessions:t,form:f,setForm:p,onOpenChat:o??h.openChat,onOpenDecision:a}):k=i.jsx(Sn,{title:"No ticket selected",hint:"Pick a ticket on the map: what it is, who has it, what blocks it, and its decision."}):k=i.jsx(Sn,{title:"No trail yet",hint:"Once there's a trail, pick a ticket on the map to see it here."}),i.jsx(Zg,{area:"inspector",icon:"note",title:"Trail step",info:"The ticket you selected on the map: what it is, who has it, what blocks it, and its decision once it's made.",className:"inspector",bare:n,children:k})}function eM(e){return(e==null?void 0:e.kind)==="ticket"?e.id:(e==null?void 0:e.kind)==="unspecified"?e.item:""}const tM={holding:"Holding",challenged:"Challenged",invalidated:"Invalidated",confirmed:"Confirmed"};function nM(e){if(e.decidedBy)return e.status==="invalidated"?`invalidated by ${e.decidedBy}`:e.status==="confirmed"?`confirmed by ${e.decidedBy==="trail lead"?"you":e.decidedBy}`:`kept by ${e.decidedBy}`}function sM(e){const{a:t,snap:n}=e,o=t.tickets.flatMap(l=>n.tickets.filter(d=>d.id===l)),a=t.challenge&&`${t.challenge.by}: ${t.challenge.evidence}`;return i.jsx(be,{as:"li",className:`assumption st-${t.status}`,edge:t.status==="challenged"?"attention":"neutral",title:t.text,titleText:t.text,context:i.jsx(V,{parts:[{text:t.id,code:!0},tM[t.status],nM(t)],children:o.length>0&&i.jsxs("span",{className:"assumption-tickets",children:[i.jsx("span",{className:"sep",children:" · "}),"relied on by",o.map(l=>i.jsx("button",{className:"link t-code",onClick:()=>e.onSelect({kind:"ticket",id:l.id}),children:l.key},l.id))]})}),detail:a,detailText:a,actions:e.onConfirm&&i.jsx(M,{size:"sm",variant:"ghost",disabled:e.busy,onClick:e.onConfirm,children:"Confirm"})})}function iM(e){const[t,n]=y.useState(),[o,a]=y.useState();return{confirm:async(d,h)=>{a(d);const f=await fetch(`${pe()}/assumptions/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,id:d,text:h})}).catch(()=>{});if(a(void 0),f!=null&&f.ok)return n(void 0);const p=await(f==null?void 0:f.json().catch(()=>({})));n((p==null?void 0:p.error)??"Could not confirm it; is the Lookout connected?")},busy:o,error:t}}function rM({snap:e,onSelect:t}){const{confirm:n,busy:o,error:a}=iM(e.map.id),l=e.map.sections.assumptions??[];return l.length?i.jsxs(i.Fragment,{children:[a&&i.jsx("p",{className:"urgent-text",children:a}),i.jsx("ul",{className:"assumptions row-list",children:l.map(d=>{const h=d.status==="holding"||d.status==="challenged";return i.jsx(sM,{a:d,snap:e,onSelect:t,onConfirm:h?()=>void n(d.id,d.text):void 0,busy:o===d.id},d.id)})})]}):i.jsx(Ie,{children:"None yet. They come from the accepted discovery brief or the trail's start."})}function oM(e){const[,t,n=e]=/^(#\d+)\s+(.+)$/.exec(e)??[],[o=n,...a]=n.split(/\s+[—–]\s+/);return{key:t,title:o,reason:a.join(" — ")||void 0}}function aM(e){const[t,n]=y.useState([]),o=e==null?void 0:e.map.id,a=(e==null?void 0:e.tickets.reduce((l,d)=>Math.max(l,d.updatedAt),e.map.updatedAt))??0;return y.useEffect(()=>{if(!o)return;let l=!0;return fetch(`${pe()}/journal?mapId=${encodeURIComponent(o)}`).then(d=>d.ok?d.json():{entries:[]}).then(d=>l&&n(d.entries)).catch(()=>l&&n([])),()=>{l=!1}},[o,a]),t}function lM({snap:e,activity:t,onTicket:n}){const o=aM(e),a=t.usageByMap[e.map.id],l=y.useMemo(()=>fg({snap:e,journal:o,answered:t.answered,usage:a}),[e,o,t.answered,a]),d=l.interventions,h=[["Done",`${l.done}`,`${l.done} done · ${l.cancelled} cancelled · ${l.open} open`],["Lead time",Qt(l.trailLeadMs),"Trail lead time: from when the trail was charted to its last done ticket"],["Median ticket",Qt(l.medianLeadMs),"Median time from a ticket's first claim to done"],["Interventions",`${d.total}`,`${d.answers} agent questions you answered + ${d.operatorActions} lifecycle calls you made (approve, send back, accept, unblock, cancel, release), of which ${d.reworkRequested} sent work back. Answers count while their sessions are on record.`],["Rework",`${l.rework.cycles}`,`Times work went back to rework, on ${l.rework.tickets} tickets`],["Reviews",`${l.reviews.passed}/${l.reviews.failed}`,`${l.reviews.passed} passed, ${l.reviews.failed} failed, ${l.reviews.needsHuman} needed you`],["Cost / ticket",l.spend.perVerifiedTicketUsd===void 0?"—":Js(l.spend.perVerifiedTicketUsd),`Cost per verified ticket: trail spend ${Js(l.spend.costUsd)} ÷ ${l.done} done tickets`]];return i.jsxs("div",{className:"report",children:[i.jsx("ul",{className:"report-stats",children:h.map(([f,p,v])=>i.jsxs("li",{"data-tip":v,children:[i.jsx("span",{className:"mono-label",children:f}),i.jsx("b",{children:p})]},f))}),i.jsxs("div",{className:"report-bar",children:[i.jsx("span",{className:"mono-label",children:"Tickets"}),i.jsx(M,{size:"sm",variant:"ghost","data-tip":"Download this report as markdown",onClick:()=>Og(`${e.map.key.replace("#","trail-")}-report.md`,Ej(l,e.map.title)),children:"Export markdown"})]}),l.tickets.length?i.jsx("ul",{className:"list report-tickets",children:l.tickets.map(f=>i.jsx("li",{className:`out-${f.outcome}`,children:i.jsxs("button",{onClick:()=>n(f.id),"data-tip":`${f.outcome} · rework ${f.reworks} · reviews ${f.reviews.passed}/${f.reviews.failed} · your calls ${f.operatorActions}`,children:[i.jsx("span",{className:"key",children:f.key}),i.jsx("span",{className:"ttl",children:f.title}),i.jsx("span",{className:"lead",children:f.outcome==="done"?Qt(f.leadMs):f.outcome})]})},f.id))}):i.jsx(Ie,{children:"No tickets yet"})]})}function cM({tab:e,snap:t,selection:n,onSelect:o,activity:a}){const l=t.map.sections;switch(e){case"report":return a?i.jsx(lM,{snap:t,activity:a,onTicket:d=>o({kind:"ticket",id:d})}):i.jsx(Ie,{children:"No activity yet"});case"assumptions":return i.jsx(rM,{snap:t,onSelect:o});case"decisions":return l.decisions.length?i.jsx("ol",{className:"row-list decisions",children:[...l.decisions].reverse().map((d,h)=>i.jsx(be,{as:"li",title:d.text,titleText:d.text,context:d.ticketKey&&i.jsx(V,{parts:[{text:d.ticketKey,code:!0}]}),onOpen:d.ticketId?()=>o({kind:"ticket",id:d.ticketId}):void 0},`${d.ticketKey}-${h}`))}):i.jsx(Ie,{children:"None"});case"unspecified":return l.unspecified.length?i.jsx("ul",{className:"row-list unspecified",children:l.unspecified.map(d=>i.jsx(be,{as:"li",title:d,titleText:d,selected:(n==null?void 0:n.kind)==="unspecified"&&n.item===d,onOpen:()=>o({kind:"unspecified",item:d})},d))}):i.jsx(Ie,{children:"None"});case"oos":return l.outOfScope.length?i.jsx("ul",{className:"row-list oos",children:l.outOfScope.map(d=>{const h=oM(d);return i.jsx(be,{as:"li",title:h.title,titleText:d,context:i.jsx(V,{parts:[h.key&&{text:h.key,code:!0},h.reason]})},d)})}):i.jsx(Ie,{children:"None"});case"notes":return i.jsx("p",{className:"notes t-body",children:l.notes||"No notes yet."});default:return e}}function dM({snap:e,selection:t,onSelect:n,bare:o,onAudit:a,activity:l}){var k;const[d,h]=y.useState("unspecified"),f=e==null?void 0:e.map.sections,p=[{id:"unspecified",label:"Not yet specified",n:f==null?void 0:f.unspecified.length},{id:"assumptions",label:"Assumptions",n:(k=f==null?void 0:f.assumptions)==null?void 0:k.length},{id:"decisions",label:"Decisions",n:f==null?void 0:f.decisions.length},{id:"oos",label:"Out of scope",n:f==null?void 0:f.outOfScope.length},{id:"notes",label:"Notes"},{id:"report",label:"Report"}],v=e?i.jsx(cM,{tab:d,snap:e,selection:t,onSelect:n,activity:l}):i.jsx(Sn,{title:"No plan yet",hint:"Open questions, decisions, what's ruled out, notes and the trail report collect here."});return i.jsxs(Be,{className:`zone sections ${o?"bare":""}`,style:o?void 0:{gridArea:"plan"},children:[!o&&i.jsx(At,{className:"zone-title",icon:"flag",title:"Trail plan",info:"The parts of the plan that aren't tickets yet: open questions still to specify, the assumptions the plan relies on, decisions already made, what's ruled out, and notes. Report shows how the trail is going: lead times, your interventions, rework, reviews and cost per verified ticket."}),i.jsxs("div",{className:"sections-tabs",children:[i.jsx(at,{compact:!0,"aria-label":"Plan section",value:d,onChange:h,options:p.map(w=>({value:w.id,label:w.n===void 0?w.label:`${w.label} · ${w.n}`}))}),d==="decisions"&&a&&i.jsx("button",{className:"link",onClick:a,children:"Audit ›"})]}),i.jsx("div",{className:"zone-b",children:v})]})}function uM(){var F;const e=y.useMemo(()=>iN(sN()),[]),t=vN(e),{snap:n,activity:o,selection:a,actions:l}=t,[d,h]=wN(),f=ZA(),p=_$(e,t),v=nI(e.kind),k=hN(),w=o.pending.length,j=sI(o,t.mapId);tI(w,n==null?void 0:n.map.title);const N=eI(t,k),S=LI(n,l.selectMap),I=hb(S.briefText),$=DI({api:t,nav:N,knowledge:I,reviewBrief:S.review,openReroute:J=>S.openReroute(J.mapId,J.ref),openGuides:()=>f.open("guides"),openConnector:J=>f.open(J),openApprovals:()=>f.open("approvals"),openFocusSettings:()=>f.open("attention")}),_=mN(e,t,d.briefing,(F=$.attention.view)==null?void 0:F.items),O=i.jsx(O$,{api:t,nav:N,bp:k,scoped:j,attn:$,above:S.inboxCard}),D=i.jsx(QA,{api:t,sessions:j.sessions,onSelect:N.select,onNewTrail:p.open,compact:k==="mobile",minFit:k==="mobile"?.7:0,trail:S}),q=J=>i.jsx(ZR,{api:t,sessions:j.sessions,bare:J,onOpenChat:ie=>N.openChat(ie),onOpenDecision:N.openDecisions}),H={activity:j,snap:n,leases:t.leases,onTicket:J=>N.select({kind:"ticket",id:J}),onOpenChat:J=>N.openChat(J)},G=J=>i.jsx(dM,{snap:n,selection:a,onSelect:N.select,bare:J,onAudit:()=>N.openDecisions(),activity:j}),{projects:oe,overview:Q,openOverview:ke}=nR(k,N,$.link.request),Oe=f.route&&i.jsx(YE,{rt:e,api:t,bp:k,prefs:d,update:h,settings:f}),Te=(N.statsOpen||N.decisionsView)&&i.jsx(tR,{api:t,bp:k,nav:N}),ne=Oe||Q||Te,ce=_.shown&&i.jsx(AN,{brief:_,snaps:t.allSnaps,bp:k,openTicket:N.openTicket,openChat:N.openChat,openDecisions:N.openDecisions,closeDecisions:()=>N.setDecisionsView(null),showPhoneHome:()=>N.setPhoneTab("home")});return i.jsx(rv.Provider,{value:I,children:i.jsxs("div",{className:`app bp-${k}`,children:[i.jsx(Pb,{api:t,rt:e,repo:i.jsx($2,{repo:v,projects:oe,onOverview:ke}),brief:_,attention:$.header,decisionsOpen:!!N.decisionsView,onDecisions:()=>{f.close(),N.decisionsView?N.setDecisionsView(null):N.openDecisions()},onStats:()=>{f.close(),N.toggleStats()},onNewTrail:p.open,onStartOver:()=>n&&p.startOver(n.map),onSettings:f.toggle,onSlack:()=>f.open("slack"),onToggleTheme:J=>h({theme:J?"night":"day"})}),k==="wide"&&i.jsxs(i.Fragment,{children:[O,D,q(!1),i.jsx(mR,{...H}),i.jsx(fR,{...H}),G(!1),ne]}),k==="laptop"&&i.jsxs(i.Fragment,{children:[O,D,i.jsx(JE,{tab:N.sideTab,onTab:N.setSideTab,unspecified:n==null?void 0:n.map.sections.unspecified.length,ticket:q(!0),activity:i.jsx(Lp,{...H}),plan:G(!0)}),ne]}),k==="mobile"&&i.jsxs(i.Fragment,{children:[i.jsx(XA,{tab:N.phoneTab,decisions:ne,inbox:O,projects:oe.many&&i.jsx(T2,{projects:oe,onOverview:ke}),map:D,ticket:q(!0),activity:i.jsx(Lp,{...H}),plan:G(!0)}),i.jsx(JA,{tab:N.phoneTab,covered:!!ne,pending:w,onPick:J=>{f.close(),N.setPhoneTab(J),N.setDecisionsView(null)}})]}),ce,S.dialog,t.error&&i.jsx("div",{className:"error-toast",children:t.error}),p.dialog,!d.onboarded&&i.jsx(EC,{prefs:d,update:h,activeTracker:e.kind}),i.jsx(cb,{}),i.jsx(wR,{})]})})}const hM="X-Teamtrail-Session";function fM(e){return typeof e=="string"?e:e instanceof URL?e.href:e.url}function mM(e){const t=new URL(fM(e),location.href),n=Z.apiPrefix;return t.origin===location.origin&&(t.pathname===n||t.pathname.startsWith(`${n}/`))}function pM(){const e=window.fetch.bind(window);window.fetch=(t,n)=>{const o=z1()?Od():void 0;if(!o||!mM(t))return e(t,n);const a=new Headers((n==null?void 0:n.headers)??(t instanceof Request?t.headers:void 0));return a.set(hM,o.secret),e(t,{...n,headers:a})}}ma(zd().theme);pM();bw.createRoot(document.getElementById("root")).render(i.jsxs(DE,{children:[i.jsx(uM,{}),i.jsx(bN,{})]}));
|