teamtrail 0.61.2 → 0.64.2

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.
@@ -0,0 +1,181 @@
1
+ var Yj=Object.defineProperty;var Jj=(e,t,n)=>t in e?Yj(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var oe=(e,t,n)=>Jj(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))i(o);new MutationObserver(o=>{for(const c of o)if(c.type==="childList")for(const d of c.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&i(d)}).observe(document,{childList:!0,subtree:!0});function n(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function i(o){if(o.ep)return;o.ep=!0;const c=n(o);fetch(o.href,c)}})();var td={exports:{}},cr={},nd={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 lp;function Xj(){if(lp)return xe;lp=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),d=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),k=Symbol.iterator;function y(E){return E===null||typeof E!="object"?null:(E=k&&E[k]||E["@@iterator"],typeof E=="function"?E:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,x={};function $(E,B,ce){this.props=E,this.context=B,this.refs=x,this.updater=ce||b}$.prototype.isReactComponent={},$.prototype.setState=function(E,B){if(typeof E!="object"&&typeof E!="function"&&E!=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,E,B,"setState")},$.prototype.forceUpdate=function(E){this.updater.enqueueForceUpdate(this,E,"forceUpdate")};function N(){}N.prototype=$.prototype;function O(E,B,ce){this.props=E,this.context=B,this.refs=x,this.updater=ce||b}var D=O.prototype=new N;D.constructor=O,S(D,$.prototype),D.isPureReactComponent=!0;var F=Array.isArray,K=Object.prototype.hasOwnProperty,I={current:null},Q={key:!0,ref:!0,__self:!0,__source:!0};function Z(E,B,ce){var me,ye={},je=null,pe=null;if(B!=null)for(me in B.ref!==void 0&&(pe=B.ref),B.key!==void 0&&(je=""+B.key),B)K.call(B,me)&&!Q.hasOwnProperty(me)&&(ye[me]=B[me]);var $e=arguments.length-2;if($e===1)ye.children=ce;else if(1<$e){for(var ge=Array($e),Ge=0;Ge<$e;Ge++)ge[Ge]=arguments[Ge+2];ye.children=ge}if(E&&E.defaultProps)for(me in $e=E.defaultProps,$e)ye[me]===void 0&&(ye[me]=$e[me]);return{$$typeof:e,type:E,key:je,ref:pe,props:ye,_owner:I.current}}function q(E,B){return{$$typeof:e,type:E.type,key:B,ref:E.ref,props:E.props,_owner:E._owner}}function ee(E){return typeof E=="object"&&E!==null&&E.$$typeof===e}function Se(E){var B={"=":"=0",":":"=2"};return"$"+E.replace(/[=:]/g,function(ce){return B[ce]})}var ve=/\/+/g;function be(E,B){return typeof E=="object"&&E!==null&&E.key!=null?Se(""+E.key):B.toString(36)}function ae(E,B,ce,me,ye){var je=typeof E;(je==="undefined"||je==="boolean")&&(E=null);var pe=!1;if(E===null)pe=!0;else switch(je){case"string":case"number":pe=!0;break;case"object":switch(E.$$typeof){case e:case t:pe=!0}}if(pe)return pe=E,ye=ye(pe),E=me===""?"."+be(pe,0):me,F(ye)?(ce="",E!=null&&(ce=E.replace(ve,"$&/")+"/"),ae(ye,B,ce,"",function(Ge){return Ge})):ye!=null&&(ee(ye)&&(ye=q(ye,ce+(!ye.key||pe&&pe.key===ye.key?"":(""+ye.key).replace(ve,"$&/")+"/")+E)),B.push(ye)),1;if(pe=0,me=me===""?".":me+":",F(E))for(var $e=0;$e<E.length;$e++){je=E[$e];var ge=me+be(je,$e);pe+=ae(je,B,ce,ge,ye)}else if(ge=y(E),typeof ge=="function")for(E=ge.call(E),$e=0;!(je=E.next()).done;)je=je.value,ge=me+be(je,$e++),pe+=ae(je,B,ce,ge,ye);else if(je==="object")throw B=String(E),Error("Objects are not valid as a React child (found: "+(B==="[object Object]"?"object with keys {"+Object.keys(E).join(", ")+"}":B)+"). If you meant to render a collection of children, use an array instead.");return pe}function Ie(E,B,ce){if(E==null)return E;var me=[],ye=0;return ae(E,me,"","",function(je){return B.call(ce,je,ye++)}),me}function we(E){if(E._status===-1){var B=E._result;B=B(),B.then(function(ce){(E._status===0||E._status===-1)&&(E._status=1,E._result=ce)},function(ce){(E._status===0||E._status===-1)&&(E._status=2,E._result=ce)}),E._status===-1&&(E._status=0,E._result=B)}if(E._status===1)return E._result.default;throw E._result}var Ne={current:null},z={transition:null},Y={ReactCurrentDispatcher:Ne,ReactCurrentBatchConfig:z,ReactCurrentOwner:I};function U(){throw Error("act(...) is not supported in production builds of React.")}return xe.Children={map:Ie,forEach:function(E,B,ce){Ie(E,function(){B.apply(this,arguments)},ce)},count:function(E){var B=0;return Ie(E,function(){B++}),B},toArray:function(E){return Ie(E,function(B){return B})||[]},only:function(E){if(!ee(E))throw Error("React.Children.only expected to receive a single React element child.");return E}},xe.Component=$,xe.Fragment=n,xe.Profiler=o,xe.PureComponent=O,xe.StrictMode=i,xe.Suspense=f,xe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Y,xe.act=U,xe.cloneElement=function(E,B,ce){if(E==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+E+".");var me=S({},E.props),ye=E.key,je=E.ref,pe=E._owner;if(B!=null){if(B.ref!==void 0&&(je=B.ref,pe=I.current),B.key!==void 0&&(ye=""+B.key),E.type&&E.type.defaultProps)var $e=E.type.defaultProps;for(ge in B)K.call(B,ge)&&!Q.hasOwnProperty(ge)&&(me[ge]=B[ge]===void 0&&$e!==void 0?$e[ge]:B[ge])}var ge=arguments.length-2;if(ge===1)me.children=ce;else if(1<ge){$e=Array(ge);for(var Ge=0;Ge<ge;Ge++)$e[Ge]=arguments[Ge+2];me.children=$e}return{$$typeof:e,type:E.type,key:ye,ref:je,props:me,_owner:pe}},xe.createContext=function(E){return E={$$typeof:d,_currentValue:E,_currentValue2:E,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},E.Provider={$$typeof:c,_context:E},E.Consumer=E},xe.createElement=Z,xe.createFactory=function(E){var B=Z.bind(null,E);return B.type=E,B},xe.createRef=function(){return{current:null}},xe.forwardRef=function(E){return{$$typeof:u,render:E}},xe.isValidElement=ee,xe.lazy=function(E){return{$$typeof:g,_payload:{_status:-1,_result:E},_init:we}},xe.memo=function(E,B){return{$$typeof:m,type:E,compare:B===void 0?null:B}},xe.startTransition=function(E){var B=z.transition;z.transition={};try{E()}finally{z.transition=B}},xe.unstable_act=U,xe.useCallback=function(E,B){return Ne.current.useCallback(E,B)},xe.useContext=function(E){return Ne.current.useContext(E)},xe.useDebugValue=function(){},xe.useDeferredValue=function(E){return Ne.current.useDeferredValue(E)},xe.useEffect=function(E,B){return Ne.current.useEffect(E,B)},xe.useId=function(){return Ne.current.useId()},xe.useImperativeHandle=function(E,B,ce){return Ne.current.useImperativeHandle(E,B,ce)},xe.useInsertionEffect=function(E,B){return Ne.current.useInsertionEffect(E,B)},xe.useLayoutEffect=function(E,B){return Ne.current.useLayoutEffect(E,B)},xe.useMemo=function(E,B){return Ne.current.useMemo(E,B)},xe.useReducer=function(E,B,ce){return Ne.current.useReducer(E,B,ce)},xe.useRef=function(E){return Ne.current.useRef(E)},xe.useState=function(E){return Ne.current.useState(E)},xe.useSyncExternalStore=function(E,B,ce){return Ne.current.useSyncExternalStore(E,B,ce)},xe.useTransition=function(){return Ne.current.useTransition()},xe.version="18.3.1",xe}var dp;function wu(){return dp||(dp=1,nd.exports=Xj()),nd.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 up;function Zj(){if(up)return cr;up=1;var e=wu(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function d(u,f,m){var g,k={},y=null,b=null;m!==void 0&&(y=""+m),f.key!==void 0&&(y=""+f.key),f.ref!==void 0&&(b=f.ref);for(g in f)i.call(f,g)&&!c.hasOwnProperty(g)&&(k[g]=f[g]);if(u&&u.defaultProps)for(g in f=u.defaultProps,f)k[g]===void 0&&(k[g]=f[g]);return{$$typeof:t,type:u,key:y,ref:b,props:k,_owner:o.current}}return cr.Fragment=n,cr.jsx=d,cr.jsxs=d,cr}var hp;function e0(){return hp||(hp=1,td.exports=Zj()),td.exports}var s=e0(),Vo={},sd={exports:{}},$t={},id={exports:{}},rd={};/**
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 fp;function t0(){return fp||(fp=1,(function(e){function t(z,Y){var U=z.length;z.push(Y);e:for(;0<U;){var E=U-1>>>1,B=z[E];if(0<o(B,Y))z[E]=Y,z[U]=B,U=E;else break e}}function n(z){return z.length===0?null:z[0]}function i(z){if(z.length===0)return null;var Y=z[0],U=z.pop();if(U!==Y){z[0]=U;e:for(var E=0,B=z.length,ce=B>>>1;E<ce;){var me=2*(E+1)-1,ye=z[me],je=me+1,pe=z[je];if(0>o(ye,U))je<B&&0>o(pe,ye)?(z[E]=pe,z[je]=U,E=je):(z[E]=ye,z[me]=U,E=me);else if(je<B&&0>o(pe,U))z[E]=pe,z[je]=U,E=je;else break e}}return Y}function o(z,Y){var U=z.sortIndex-Y.sortIndex;return U!==0?U:z.id-Y.id}if(typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var d=Date,u=d.now();e.unstable_now=function(){return d.now()-u}}var f=[],m=[],g=1,k=null,y=3,b=!1,S=!1,x=!1,$=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,O=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function D(z){for(var Y=n(m);Y!==null;){if(Y.callback===null)i(m);else if(Y.startTime<=z)i(m),Y.sortIndex=Y.expirationTime,t(f,Y);else break;Y=n(m)}}function F(z){if(x=!1,D(z),!S)if(n(f)!==null)S=!0,we(K);else{var Y=n(m);Y!==null&&Ne(F,Y.startTime-z)}}function K(z,Y){S=!1,x&&(x=!1,N(Z),Z=-1),b=!0;var U=y;try{for(D(Y),k=n(f);k!==null&&(!(k.expirationTime>Y)||z&&!Se());){var E=k.callback;if(typeof E=="function"){k.callback=null,y=k.priorityLevel;var B=E(k.expirationTime<=Y);Y=e.unstable_now(),typeof B=="function"?k.callback=B:k===n(f)&&i(f),D(Y)}else i(f);k=n(f)}if(k!==null)var ce=!0;else{var me=n(m);me!==null&&Ne(F,me.startTime-Y),ce=!1}return ce}finally{k=null,y=U,b=!1}}var I=!1,Q=null,Z=-1,q=5,ee=-1;function Se(){return!(e.unstable_now()-ee<q)}function ve(){if(Q!==null){var z=e.unstable_now();ee=z;var Y=!0;try{Y=Q(!0,z)}finally{Y?be():(I=!1,Q=null)}}else I=!1}var be;if(typeof O=="function")be=function(){O(ve)};else if(typeof MessageChannel<"u"){var ae=new MessageChannel,Ie=ae.port2;ae.port1.onmessage=ve,be=function(){Ie.postMessage(null)}}else be=function(){$(ve,0)};function we(z){Q=z,I||(I=!0,be())}function Ne(z,Y){Z=$(function(){z(e.unstable_now())},Y)}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(z){z.callback=null},e.unstable_continueExecution=function(){S||b||(S=!0,we(K))},e.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):q=0<z?Math.floor(1e3/z):5},e.unstable_getCurrentPriorityLevel=function(){return y},e.unstable_getFirstCallbackNode=function(){return n(f)},e.unstable_next=function(z){switch(y){case 1:case 2:case 3:var Y=3;break;default:Y=y}var U=y;y=Y;try{return z()}finally{y=U}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(z,Y){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var U=y;y=z;try{return Y()}finally{y=U}},e.unstable_scheduleCallback=function(z,Y,U){var E=e.unstable_now();switch(typeof U=="object"&&U!==null?(U=U.delay,U=typeof U=="number"&&0<U?E+U:E):U=E,z){case 1:var B=-1;break;case 2:B=250;break;case 5:B=1073741823;break;case 4:B=1e4;break;default:B=5e3}return B=U+B,z={id:g++,callback:Y,priorityLevel:z,startTime:U,expirationTime:B,sortIndex:-1},U>E?(z.sortIndex=U,t(m,z),n(f)===null&&z===n(m)&&(x?(N(Z),Z=-1):x=!0,Ne(F,U-E))):(z.sortIndex=B,t(f,z),S||b||(S=!0,we(K))),z},e.unstable_shouldYield=Se,e.unstable_wrapCallback=function(z){var Y=y;return function(){var U=y;y=Y;try{return z.apply(this,arguments)}finally{y=U}}}})(rd)),rd}var mp;function n0(){return mp||(mp=1,id.exports=t0()),id.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 pp;function s0(){if(pp)return $t;pp=1;var e=wu(),t=n0();function n(r){for(var a="https://reactjs.org/docs/error-decoder.html?invariant="+r,l=1;l<arguments.length;l++)a+="&args[]="+encodeURIComponent(arguments[l]);return"Minified React error #"+r+"; visit "+a+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var i=new Set,o={};function c(r,a){d(r,a),d(r+"Capture",a)}function d(r,a){for(o[r]=a,r=0;r<a.length;r++)i.add(a[r])}var u=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),f=Object.prototype.hasOwnProperty,m=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,g={},k={};function y(r){return f.call(k,r)?!0:f.call(g,r)?!1:m.test(r)?k[r]=!0:(g[r]=!0,!1)}function b(r,a,l,h){if(l!==null&&l.type===0)return!1;switch(typeof a){case"function":case"symbol":return!0;case"boolean":return h?!1:l!==null?!l.acceptsBooleans:(r=r.toLowerCase().slice(0,5),r!=="data-"&&r!=="aria-");default:return!1}}function S(r,a,l,h){if(a===null||typeof a>"u"||b(r,a,l,h))return!0;if(h)return!1;if(l!==null)switch(l.type){case 3:return!a;case 4:return a===!1;case 5:return isNaN(a);case 6:return isNaN(a)||1>a}return!1}function x(r,a,l,h,p,v,j){this.acceptsBooleans=a===2||a===3||a===4,this.attributeName=h,this.attributeNamespace=p,this.mustUseProperty=l,this.propertyName=r,this.type=a,this.sanitizeURL=v,this.removeEmptyString=j}var $={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(r){$[r]=new x(r,0,!1,r,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(r){var a=r[0];$[a]=new x(a,1,!1,r[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(r){$[r]=new x(r,2,!1,r.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(r){$[r]=new x(r,2,!1,r,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(r){$[r]=new x(r,3,!1,r.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(r){$[r]=new x(r,3,!0,r,null,!1,!1)}),["capture","download"].forEach(function(r){$[r]=new x(r,4,!1,r,null,!1,!1)}),["cols","rows","size","span"].forEach(function(r){$[r]=new x(r,6,!1,r,null,!1,!1)}),["rowSpan","start"].forEach(function(r){$[r]=new x(r,5,!1,r.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function O(r){return r[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(r){var a=r.replace(N,O);$[a]=new x(a,1,!1,r,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(r){var a=r.replace(N,O);$[a]=new x(a,1,!1,r,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(r){var a=r.replace(N,O);$[a]=new x(a,1,!1,r,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(r){$[r]=new x(r,1,!1,r.toLowerCase(),null,!1,!1)}),$.xlinkHref=new x("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(r){$[r]=new x(r,1,!1,r.toLowerCase(),null,!0,!0)});function D(r,a,l,h){var p=$.hasOwnProperty(a)?$[a]:null;(p!==null?p.type!==0:h||!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(S(a,l,p,h)&&(l=null),h||p===null?y(a)&&(l===null?r.removeAttribute(a):r.setAttribute(a,""+l)):p.mustUseProperty?r[p.propertyName]=l===null?p.type===3?!1:"":l:(a=p.attributeName,h=p.attributeNamespace,l===null?r.removeAttribute(a):(p=p.type,l=p===3||p===4&&l===!0?"":""+l,h?r.setAttributeNS(h,a,l):r.setAttribute(a,l))))}var F=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,K=Symbol.for("react.element"),I=Symbol.for("react.portal"),Q=Symbol.for("react.fragment"),Z=Symbol.for("react.strict_mode"),q=Symbol.for("react.profiler"),ee=Symbol.for("react.provider"),Se=Symbol.for("react.context"),ve=Symbol.for("react.forward_ref"),be=Symbol.for("react.suspense"),ae=Symbol.for("react.suspense_list"),Ie=Symbol.for("react.memo"),we=Symbol.for("react.lazy"),Ne=Symbol.for("react.offscreen"),z=Symbol.iterator;function Y(r){return r===null||typeof r!="object"?null:(r=z&&r[z]||r["@@iterator"],typeof r=="function"?r:null)}var U=Object.assign,E;function B(r){if(E===void 0)try{throw Error()}catch(l){var a=l.stack.trim().match(/\n( *(at )?)/);E=a&&a[1]||""}return`
34
+ `+E+r}var ce=!1;function me(r,a){if(!r||ce)return"";ce=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(a)if(a=function(){throw Error()},Object.defineProperty(a.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(a,[])}catch(P){var h=P}Reflect.construct(r,[],a)}else{try{a.call()}catch(P){h=P}r.call(a.prototype)}else{try{throw Error()}catch(P){h=P}r()}}catch(P){if(P&&h&&typeof P.stack=="string"){for(var p=P.stack.split(`
35
+ `),v=h.stack.split(`
36
+ `),j=p.length-1,C=v.length-1;1<=j&&0<=C&&p[j]!==v[C];)C--;for(;1<=j&&0<=C;j--,C--)if(p[j]!==v[C]){if(j!==1||C!==1)do if(j--,C--,0>C||p[j]!==v[C]){var T=`
37
+ `+p[j].replace(" at new "," at ");return r.displayName&&T.includes("<anonymous>")&&(T=T.replace("<anonymous>",r.displayName)),T}while(1<=j&&0<=C);break}}}finally{ce=!1,Error.prepareStackTrace=l}return(r=r?r.displayName||r.name:"")?B(r):""}function ye(r){switch(r.tag){case 5:return B(r.type);case 16:return B("Lazy");case 13:return B("Suspense");case 19:return B("SuspenseList");case 0:case 2:case 15:return r=me(r.type,!1),r;case 11:return r=me(r.type.render,!1),r;case 1:return r=me(r.type,!0),r;default:return""}}function je(r){if(r==null)return null;if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case Q:return"Fragment";case I:return"Portal";case q:return"Profiler";case Z:return"StrictMode";case be:return"Suspense";case ae:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case Se:return(r.displayName||"Context")+".Consumer";case ee:return(r._context.displayName||"Context")+".Provider";case ve:var a=r.render;return r=r.displayName,r||(r=a.displayName||a.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case Ie:return a=r.displayName||null,a!==null?a:je(r.type)||"Memo";case we:a=r._payload,r=r._init;try{return je(r(a))}catch{}}return null}function pe(r){var a=r.type;switch(r.tag){case 24:return"Cache";case 9:return(a.displayName||"Context")+".Consumer";case 10:return(a._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return r=a.render,r=r.displayName||r.name||"",a.displayName||(r!==""?"ForwardRef("+r+")":"ForwardRef");case 7:return"Fragment";case 5:return a;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return je(a);case 8:return a===Z?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a}return null}function $e(r){switch(typeof r){case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function ge(r){var a=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function Ge(r){var a=ge(r)?"checked":"value",l=Object.getOwnPropertyDescriptor(r.constructor.prototype,a),h=""+r[a];if(!r.hasOwnProperty(a)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var p=l.get,v=l.set;return Object.defineProperty(r,a,{configurable:!0,get:function(){return p.call(this)},set:function(j){h=""+j,v.call(this,j)}}),Object.defineProperty(r,a,{enumerable:l.enumerable}),{getValue:function(){return h},setValue:function(j){h=""+j},stopTracking:function(){r._valueTracker=null,delete r[a]}}}}function In(r){r._valueTracker||(r._valueTracker=Ge(r))}function Dr(r){if(!r)return!1;var a=r._valueTracker;if(!a)return!0;var l=a.getValue(),h="";return r&&(h=ge(r)?r.checked?"true":"false":r.value),r=h,r!==l?(a.setValue(r),!0):!1}function Is(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}function cc(r,a){var l=a.checked;return U({},a,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:l??r._wrapperState.initialChecked})}function ph(r,a){var l=a.defaultValue==null?"":a.defaultValue,h=a.checked!=null?a.checked:a.defaultChecked;l=$e(a.value!=null?a.value:l),r._wrapperState={initialChecked:h,initialValue:l,controlled:a.type==="checkbox"||a.type==="radio"?a.checked!=null:a.value!=null}}function gh(r,a){a=a.checked,a!=null&&D(r,"checked",a,!1)}function lc(r,a){gh(r,a);var l=$e(a.value),h=a.type;if(l!=null)h==="number"?(l===0&&r.value===""||r.value!=l)&&(r.value=""+l):r.value!==""+l&&(r.value=""+l);else if(h==="submit"||h==="reset"){r.removeAttribute("value");return}a.hasOwnProperty("value")?dc(r,a.type,l):a.hasOwnProperty("defaultValue")&&dc(r,a.type,$e(a.defaultValue)),a.checked==null&&a.defaultChecked!=null&&(r.defaultChecked=!!a.defaultChecked)}function kh(r,a,l){if(a.hasOwnProperty("value")||a.hasOwnProperty("defaultValue")){var h=a.type;if(!(h!=="submit"&&h!=="reset"||a.value!==void 0&&a.value!==null))return;a=""+r._wrapperState.initialValue,l||a===r.value||(r.value=a),r.defaultValue=a}l=r.name,l!==""&&(r.name=""),r.defaultChecked=!!r._wrapperState.initialChecked,l!==""&&(r.name=l)}function dc(r,a,l){(a!=="number"||Is(r.ownerDocument)!==r)&&(l==null?r.defaultValue=""+r._wrapperState.initialValue:r.defaultValue!==""+l&&(r.defaultValue=""+l))}var bi=Array.isArray;function Rs(r,a,l,h){if(r=r.options,a){a={};for(var p=0;p<l.length;p++)a["$"+l[p]]=!0;for(l=0;l<r.length;l++)p=a.hasOwnProperty("$"+r[l].value),r[l].selected!==p&&(r[l].selected=p),p&&h&&(r[l].defaultSelected=!0)}else{for(l=""+$e(l),a=null,p=0;p<r.length;p++){if(r[p].value===l){r[p].selected=!0,h&&(r[p].defaultSelected=!0);return}a!==null||r[p].disabled||(a=r[p])}a!==null&&(a.selected=!0)}}function uc(r,a){if(a.dangerouslySetInnerHTML!=null)throw Error(n(91));return U({},a,{value:void 0,defaultValue:void 0,children:""+r._wrapperState.initialValue})}function vh(r,a){var l=a.value;if(l==null){if(l=a.children,a=a.defaultValue,l!=null){if(a!=null)throw Error(n(92));if(bi(l)){if(1<l.length)throw Error(n(93));l=l[0]}a=l}a==null&&(a=""),l=a}r._wrapperState={initialValue:$e(l)}}function wh(r,a){var l=$e(a.value),h=$e(a.defaultValue);l!=null&&(l=""+l,l!==r.value&&(r.value=l),a.defaultValue==null&&r.defaultValue!==l&&(r.defaultValue=l)),h!=null&&(r.defaultValue=""+h)}function yh(r){var a=r.textContent;a===r._wrapperState.initialValue&&a!==""&&a!==null&&(r.value=a)}function xh(r){switch(r){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 hc(r,a){return r==null||r==="http://www.w3.org/1999/xhtml"?xh(a):r==="http://www.w3.org/2000/svg"&&a==="foreignObject"?"http://www.w3.org/1999/xhtml":r}var _r,jh=(function(r){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(a,l,h,p){MSApp.execUnsafeLocalFunction(function(){return r(a,l,h,p)})}:r})(function(r,a){if(r.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in r)r.innerHTML=a;else{for(_r=_r||document.createElement("div"),_r.innerHTML="<svg>"+a.valueOf().toString()+"</svg>",a=_r.firstChild;r.firstChild;)r.removeChild(r.firstChild);for(;a.firstChild;)r.appendChild(a.firstChild)}});function Si(r,a){if(a){var l=r.firstChild;if(l&&l===r.lastChild&&l.nodeType===3){l.nodeValue=a;return}}r.textContent=a}var Ni={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},ex=["Webkit","ms","Moz","O"];Object.keys(Ni).forEach(function(r){ex.forEach(function(a){a=a+r.charAt(0).toUpperCase()+r.substring(1),Ni[a]=Ni[r]})});function bh(r,a,l){return a==null||typeof a=="boolean"||a===""?"":l||typeof a!="number"||a===0||Ni.hasOwnProperty(r)&&Ni[r]?(""+a).trim():a+"px"}function Sh(r,a){r=r.style;for(var l in a)if(a.hasOwnProperty(l)){var h=l.indexOf("--")===0,p=bh(l,a[l],h);l==="float"&&(l="cssFloat"),h?r.setProperty(l,p):r[l]=p}}var tx=U({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 fc(r,a){if(a){if(tx[r]&&(a.children!=null||a.dangerouslySetInnerHTML!=null))throw Error(n(137,r));if(a.dangerouslySetInnerHTML!=null){if(a.children!=null)throw Error(n(60));if(typeof a.dangerouslySetInnerHTML!="object"||!("__html"in a.dangerouslySetInnerHTML))throw Error(n(61))}if(a.style!=null&&typeof a.style!="object")throw Error(n(62))}}function mc(r,a){if(r.indexOf("-")===-1)return typeof a.is=="string";switch(r){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 pc=null;function gc(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var kc=null,Ms=null,Ls=null;function Nh(r){if(r=Vi(r)){if(typeof kc!="function")throw Error(n(280));var a=r.stateNode;a&&(a=ao(a),kc(r.stateNode,r.type,a))}}function $h(r){Ms?Ls?Ls.push(r):Ls=[r]:Ms=r}function Ch(){if(Ms){var r=Ms,a=Ls;if(Ls=Ms=null,Nh(r),a)for(r=0;r<a.length;r++)Nh(a[r])}}function Th(r,a){return r(a)}function Eh(){}var vc=!1;function Ah(r,a,l){if(vc)return r(a,l);vc=!0;try{return Th(r,a,l)}finally{vc=!1,(Ms!==null||Ls!==null)&&(Eh(),Ch())}}function $i(r,a){var l=r.stateNode;if(l===null)return null;var h=ao(l);if(h===null)return null;l=h[a];e:switch(a){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(h=!h.disabled)||(r=r.type,h=!(r==="button"||r==="input"||r==="select"||r==="textarea")),r=!h;break e;default:r=!1}if(r)return null;if(l&&typeof l!="function")throw Error(n(231,a,typeof l));return l}var wc=!1;if(u)try{var Ci={};Object.defineProperty(Ci,"passive",{get:function(){wc=!0}}),window.addEventListener("test",Ci,Ci),window.removeEventListener("test",Ci,Ci)}catch{wc=!1}function nx(r,a,l,h,p,v,j,C,T){var P=Array.prototype.slice.call(arguments,3);try{a.apply(l,P)}catch(H){this.onError(H)}}var Ti=!1,Br=null,Fr=!1,yc=null,sx={onError:function(r){Ti=!0,Br=r}};function ix(r,a,l,h,p,v,j,C,T){Ti=!1,Br=null,nx.apply(sx,arguments)}function rx(r,a,l,h,p,v,j,C,T){if(ix.apply(this,arguments),Ti){if(Ti){var P=Br;Ti=!1,Br=null}else throw Error(n(198));Fr||(Fr=!0,yc=P)}}function cs(r){var a=r,l=r;if(r.alternate)for(;a.return;)a=a.return;else{r=a;do a=r,(a.flags&4098)!==0&&(l=a.return),r=a.return;while(r)}return a.tag===3?l:null}function Ih(r){if(r.tag===13){var a=r.memoizedState;if(a===null&&(r=r.alternate,r!==null&&(a=r.memoizedState)),a!==null)return a.dehydrated}return null}function Rh(r){if(cs(r)!==r)throw Error(n(188))}function ox(r){var a=r.alternate;if(!a){if(a=cs(r),a===null)throw Error(n(188));return a!==r?null:r}for(var l=r,h=a;;){var p=l.return;if(p===null)break;var v=p.alternate;if(v===null){if(h=p.return,h!==null){l=h;continue}break}if(p.child===v.child){for(v=p.child;v;){if(v===l)return Rh(p),r;if(v===h)return Rh(p),a;v=v.sibling}throw Error(n(188))}if(l.return!==h.return)l=p,h=v;else{for(var j=!1,C=p.child;C;){if(C===l){j=!0,l=p,h=v;break}if(C===h){j=!0,h=p,l=v;break}C=C.sibling}if(!j){for(C=v.child;C;){if(C===l){j=!0,l=v,h=p;break}if(C===h){j=!0,h=v,l=p;break}C=C.sibling}if(!j)throw Error(n(189))}}if(l.alternate!==h)throw Error(n(190))}if(l.tag!==3)throw Error(n(188));return l.stateNode.current===l?r:a}function Mh(r){return r=ox(r),r!==null?Lh(r):null}function Lh(r){if(r.tag===5||r.tag===6)return r;for(r=r.child;r!==null;){var a=Lh(r);if(a!==null)return a;r=r.sibling}return null}var Oh=t.unstable_scheduleCallback,Ph=t.unstable_cancelCallback,ax=t.unstable_shouldYield,cx=t.unstable_requestPaint,qe=t.unstable_now,lx=t.unstable_getCurrentPriorityLevel,xc=t.unstable_ImmediatePriority,Dh=t.unstable_UserBlockingPriority,zr=t.unstable_NormalPriority,dx=t.unstable_LowPriority,_h=t.unstable_IdlePriority,Ur=null,cn=null;function ux(r){if(cn&&typeof cn.onCommitFiberRoot=="function")try{cn.onCommitFiberRoot(Ur,r,void 0,(r.current.flags&128)===128)}catch{}}var Yt=Math.clz32?Math.clz32:mx,hx=Math.log,fx=Math.LN2;function mx(r){return r>>>=0,r===0?32:31-(hx(r)/fx|0)|0}var Wr=64,Hr=4194304;function Ei(r){switch(r&-r){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 r&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return r&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return r}}function Kr(r,a){var l=r.pendingLanes;if(l===0)return 0;var h=0,p=r.suspendedLanes,v=r.pingedLanes,j=l&268435455;if(j!==0){var C=j&~p;C!==0?h=Ei(C):(v&=j,v!==0&&(h=Ei(v)))}else j=l&~p,j!==0?h=Ei(j):v!==0&&(h=Ei(v));if(h===0)return 0;if(a!==0&&a!==h&&(a&p)===0&&(p=h&-h,v=a&-a,p>=v||p===16&&(v&4194240)!==0))return a;if((h&4)!==0&&(h|=l&16),a=r.entangledLanes,a!==0)for(r=r.entanglements,a&=h;0<a;)l=31-Yt(a),p=1<<l,h|=r[l],a&=~p;return h}function px(r,a){switch(r){case 1:case 2:case 4:return a+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return a+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function gx(r,a){for(var l=r.suspendedLanes,h=r.pingedLanes,p=r.expirationTimes,v=r.pendingLanes;0<v;){var j=31-Yt(v),C=1<<j,T=p[j];T===-1?((C&l)===0||(C&h)!==0)&&(p[j]=px(C,a)):T<=a&&(r.expiredLanes|=C),v&=~C}}function jc(r){return r=r.pendingLanes&-1073741825,r!==0?r:r&1073741824?1073741824:0}function Bh(){var r=Wr;return Wr<<=1,(Wr&4194240)===0&&(Wr=64),r}function bc(r){for(var a=[],l=0;31>l;l++)a.push(r);return a}function Ai(r,a,l){r.pendingLanes|=a,a!==536870912&&(r.suspendedLanes=0,r.pingedLanes=0),r=r.eventTimes,a=31-Yt(a),r[a]=l}function kx(r,a){var l=r.pendingLanes&~a;r.pendingLanes=a,r.suspendedLanes=0,r.pingedLanes=0,r.expiredLanes&=a,r.mutableReadLanes&=a,r.entangledLanes&=a,a=r.entanglements;var h=r.eventTimes;for(r=r.expirationTimes;0<l;){var p=31-Yt(l),v=1<<p;a[p]=0,h[p]=-1,r[p]=-1,l&=~v}}function Sc(r,a){var l=r.entangledLanes|=a;for(r=r.entanglements;l;){var h=31-Yt(l),p=1<<h;p&a|r[h]&a&&(r[h]|=a),l&=~p}}var Re=0;function Fh(r){return r&=-r,1<r?4<r?(r&268435455)!==0?16:536870912:4:1}var zh,Nc,Uh,Wh,Hh,$c=!1,Gr=[],Rn=null,Mn=null,Ln=null,Ii=new Map,Ri=new Map,On=[],vx="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 Kh(r,a){switch(r){case"focusin":case"focusout":Rn=null;break;case"dragenter":case"dragleave":Mn=null;break;case"mouseover":case"mouseout":Ln=null;break;case"pointerover":case"pointerout":Ii.delete(a.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ri.delete(a.pointerId)}}function Mi(r,a,l,h,p,v){return r===null||r.nativeEvent!==v?(r={blockedOn:a,domEventName:l,eventSystemFlags:h,nativeEvent:v,targetContainers:[p]},a!==null&&(a=Vi(a),a!==null&&Nc(a)),r):(r.eventSystemFlags|=h,a=r.targetContainers,p!==null&&a.indexOf(p)===-1&&a.push(p),r)}function wx(r,a,l,h,p){switch(a){case"focusin":return Rn=Mi(Rn,r,a,l,h,p),!0;case"dragenter":return Mn=Mi(Mn,r,a,l,h,p),!0;case"mouseover":return Ln=Mi(Ln,r,a,l,h,p),!0;case"pointerover":var v=p.pointerId;return Ii.set(v,Mi(Ii.get(v)||null,r,a,l,h,p)),!0;case"gotpointercapture":return v=p.pointerId,Ri.set(v,Mi(Ri.get(v)||null,r,a,l,h,p)),!0}return!1}function Gh(r){var a=ls(r.target);if(a!==null){var l=cs(a);if(l!==null){if(a=l.tag,a===13){if(a=Ih(l),a!==null){r.blockedOn=a,Hh(r.priority,function(){Uh(l)});return}}else if(a===3&&l.stateNode.current.memoizedState.isDehydrated){r.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}r.blockedOn=null}function Vr(r){if(r.blockedOn!==null)return!1;for(var a=r.targetContainers;0<a.length;){var l=Tc(r.domEventName,r.eventSystemFlags,a[0],r.nativeEvent);if(l===null){l=r.nativeEvent;var h=new l.constructor(l.type,l);pc=h,l.target.dispatchEvent(h),pc=null}else return a=Vi(l),a!==null&&Nc(a),r.blockedOn=l,!1;a.shift()}return!0}function Vh(r,a,l){Vr(r)&&l.delete(a)}function yx(){$c=!1,Rn!==null&&Vr(Rn)&&(Rn=null),Mn!==null&&Vr(Mn)&&(Mn=null),Ln!==null&&Vr(Ln)&&(Ln=null),Ii.forEach(Vh),Ri.forEach(Vh)}function Li(r,a){r.blockedOn===a&&(r.blockedOn=null,$c||($c=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,yx)))}function Oi(r){function a(p){return Li(p,r)}if(0<Gr.length){Li(Gr[0],r);for(var l=1;l<Gr.length;l++){var h=Gr[l];h.blockedOn===r&&(h.blockedOn=null)}}for(Rn!==null&&Li(Rn,r),Mn!==null&&Li(Mn,r),Ln!==null&&Li(Ln,r),Ii.forEach(a),Ri.forEach(a),l=0;l<On.length;l++)h=On[l],h.blockedOn===r&&(h.blockedOn=null);for(;0<On.length&&(l=On[0],l.blockedOn===null);)Gh(l),l.blockedOn===null&&On.shift()}var Os=F.ReactCurrentBatchConfig,qr=!0;function xx(r,a,l,h){var p=Re,v=Os.transition;Os.transition=null;try{Re=1,Cc(r,a,l,h)}finally{Re=p,Os.transition=v}}function jx(r,a,l,h){var p=Re,v=Os.transition;Os.transition=null;try{Re=4,Cc(r,a,l,h)}finally{Re=p,Os.transition=v}}function Cc(r,a,l,h){if(qr){var p=Tc(r,a,l,h);if(p===null)Kc(r,a,h,Qr,l),Kh(r,h);else if(wx(p,r,a,l,h))h.stopPropagation();else if(Kh(r,h),a&4&&-1<vx.indexOf(r)){for(;p!==null;){var v=Vi(p);if(v!==null&&zh(v),v=Tc(r,a,l,h),v===null&&Kc(r,a,h,Qr,l),v===p)break;p=v}p!==null&&h.stopPropagation()}else Kc(r,a,h,null,l)}}var Qr=null;function Tc(r,a,l,h){if(Qr=null,r=gc(h),r=ls(r),r!==null)if(a=cs(r),a===null)r=null;else if(l=a.tag,l===13){if(r=Ih(a),r!==null)return r;r=null}else if(l===3){if(a.stateNode.current.memoizedState.isDehydrated)return a.tag===3?a.stateNode.containerInfo:null;r=null}else a!==r&&(r=null);return Qr=r,null}function qh(r){switch(r){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(lx()){case xc:return 1;case Dh:return 4;case zr:case dx:return 16;case _h:return 536870912;default:return 16}default:return 16}}var Pn=null,Ec=null,Yr=null;function Qh(){if(Yr)return Yr;var r,a=Ec,l=a.length,h,p="value"in Pn?Pn.value:Pn.textContent,v=p.length;for(r=0;r<l&&a[r]===p[r];r++);var j=l-r;for(h=1;h<=j&&a[l-h]===p[v-h];h++);return Yr=p.slice(r,1<h?1-h:void 0)}function Jr(r){var a=r.keyCode;return"charCode"in r?(r=r.charCode,r===0&&a===13&&(r=13)):r=a,r===10&&(r=13),32<=r||r===13?r:0}function Xr(){return!0}function Yh(){return!1}function It(r){function a(l,h,p,v,j){this._reactName=l,this._targetInst=p,this.type=h,this.nativeEvent=v,this.target=j,this.currentTarget=null;for(var C in r)r.hasOwnProperty(C)&&(l=r[C],this[C]=l?l(v):v[C]);return this.isDefaultPrevented=(v.defaultPrevented!=null?v.defaultPrevented:v.returnValue===!1)?Xr:Yh,this.isPropagationStopped=Yh,this}return U(a.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=Xr)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=Xr)},persist:function(){},isPersistent:Xr}),a}var Ps={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ac=It(Ps),Pi=U({},Ps,{view:0,detail:0}),bx=It(Pi),Ic,Rc,Di,Zr=U({},Pi,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Lc,button:0,buttons:0,relatedTarget:function(r){return r.relatedTarget===void 0?r.fromElement===r.srcElement?r.toElement:r.fromElement:r.relatedTarget},movementX:function(r){return"movementX"in r?r.movementX:(r!==Di&&(Di&&r.type==="mousemove"?(Ic=r.screenX-Di.screenX,Rc=r.screenY-Di.screenY):Rc=Ic=0,Di=r),Ic)},movementY:function(r){return"movementY"in r?r.movementY:Rc}}),Jh=It(Zr),Sx=U({},Zr,{dataTransfer:0}),Nx=It(Sx),$x=U({},Pi,{relatedTarget:0}),Mc=It($x),Cx=U({},Ps,{animationName:0,elapsedTime:0,pseudoElement:0}),Tx=It(Cx),Ex=U({},Ps,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),Ax=It(Ex),Ix=U({},Ps,{data:0}),Xh=It(Ix),Rx={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Mx={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"},Lx={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Ox(r){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(r):(r=Lx[r])?!!a[r]:!1}function Lc(){return Ox}var Px=U({},Pi,{key:function(r){if(r.key){var a=Rx[r.key]||r.key;if(a!=="Unidentified")return a}return r.type==="keypress"?(r=Jr(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?Mx[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Lc,charCode:function(r){return r.type==="keypress"?Jr(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?Jr(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),Dx=It(Px),_x=U({},Zr,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Zh=It(_x),Bx=U({},Pi,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Lc}),Fx=It(Bx),zx=U({},Ps,{propertyName:0,elapsedTime:0,pseudoElement:0}),Ux=It(zx),Wx=U({},Zr,{deltaX:function(r){return"deltaX"in r?r.deltaX:"wheelDeltaX"in r?-r.wheelDeltaX:0},deltaY:function(r){return"deltaY"in r?r.deltaY:"wheelDeltaY"in r?-r.wheelDeltaY:"wheelDelta"in r?-r.wheelDelta:0},deltaZ:0,deltaMode:0}),Hx=It(Wx),Kx=[9,13,27,32],Oc=u&&"CompositionEvent"in window,_i=null;u&&"documentMode"in document&&(_i=document.documentMode);var Gx=u&&"TextEvent"in window&&!_i,ef=u&&(!Oc||_i&&8<_i&&11>=_i),tf=" ",nf=!1;function sf(r,a){switch(r){case"keyup":return Kx.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function rf(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var Ds=!1;function Vx(r,a){switch(r){case"compositionend":return rf(a);case"keypress":return a.which!==32?null:(nf=!0,tf);case"textInput":return r=a.data,r===tf&&nf?null:r;default:return null}}function qx(r,a){if(Ds)return r==="compositionend"||!Oc&&sf(r,a)?(r=Qh(),Yr=Ec=Pn=null,Ds=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(a.ctrlKey||a.altKey||a.metaKey)||a.ctrlKey&&a.altKey){if(a.char&&1<a.char.length)return a.char;if(a.which)return String.fromCharCode(a.which)}return null;case"compositionend":return ef&&a.locale!=="ko"?null:a.data;default:return null}}var Qx={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 of(r){var a=r&&r.nodeName&&r.nodeName.toLowerCase();return a==="input"?!!Qx[r.type]:a==="textarea"}function af(r,a,l,h){$h(h),a=io(a,"onChange"),0<a.length&&(l=new Ac("onChange","change",null,l,h),r.push({event:l,listeners:a}))}var Bi=null,Fi=null;function Yx(r){Nf(r,0)}function eo(r){var a=Us(r);if(Dr(a))return r}function Jx(r,a){if(r==="change")return a}var cf=!1;if(u){var Pc;if(u){var Dc="oninput"in document;if(!Dc){var lf=document.createElement("div");lf.setAttribute("oninput","return;"),Dc=typeof lf.oninput=="function"}Pc=Dc}else Pc=!1;cf=Pc&&(!document.documentMode||9<document.documentMode)}function df(){Bi&&(Bi.detachEvent("onpropertychange",uf),Fi=Bi=null)}function uf(r){if(r.propertyName==="value"&&eo(Fi)){var a=[];af(a,Fi,r,gc(r)),Ah(Yx,a)}}function Xx(r,a,l){r==="focusin"?(df(),Bi=a,Fi=l,Bi.attachEvent("onpropertychange",uf)):r==="focusout"&&df()}function Zx(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return eo(Fi)}function ej(r,a){if(r==="click")return eo(a)}function tj(r,a){if(r==="input"||r==="change")return eo(a)}function nj(r,a){return r===a&&(r!==0||1/r===1/a)||r!==r&&a!==a}var Jt=typeof Object.is=="function"?Object.is:nj;function zi(r,a){if(Jt(r,a))return!0;if(typeof r!="object"||r===null||typeof a!="object"||a===null)return!1;var l=Object.keys(r),h=Object.keys(a);if(l.length!==h.length)return!1;for(h=0;h<l.length;h++){var p=l[h];if(!f.call(a,p)||!Jt(r[p],a[p]))return!1}return!0}function hf(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function ff(r,a){var l=hf(r);r=0;for(var h;l;){if(l.nodeType===3){if(h=r+l.textContent.length,r<=a&&h>=a)return{node:l,offset:a-r};r=h}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=hf(l)}}function mf(r,a){return r&&a?r===a?!0:r&&r.nodeType===3?!1:a&&a.nodeType===3?mf(r,a.parentNode):"contains"in r?r.contains(a):r.compareDocumentPosition?!!(r.compareDocumentPosition(a)&16):!1:!1}function pf(){for(var r=window,a=Is();a instanceof r.HTMLIFrameElement;){try{var l=typeof a.contentWindow.location.href=="string"}catch{l=!1}if(l)r=a.contentWindow;else break;a=Is(r.document)}return a}function _c(r){var a=r&&r.nodeName&&r.nodeName.toLowerCase();return a&&(a==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||a==="textarea"||r.contentEditable==="true")}function sj(r){var a=pf(),l=r.focusedElem,h=r.selectionRange;if(a!==l&&l&&l.ownerDocument&&mf(l.ownerDocument.documentElement,l)){if(h!==null&&_c(l)){if(a=h.start,r=h.end,r===void 0&&(r=a),"selectionStart"in l)l.selectionStart=a,l.selectionEnd=Math.min(r,l.value.length);else if(r=(a=l.ownerDocument||document)&&a.defaultView||window,r.getSelection){r=r.getSelection();var p=l.textContent.length,v=Math.min(h.start,p);h=h.end===void 0?v:Math.min(h.end,p),!r.extend&&v>h&&(p=h,h=v,v=p),p=ff(l,v);var j=ff(l,h);p&&j&&(r.rangeCount!==1||r.anchorNode!==p.node||r.anchorOffset!==p.offset||r.focusNode!==j.node||r.focusOffset!==j.offset)&&(a=a.createRange(),a.setStart(p.node,p.offset),r.removeAllRanges(),v>h?(r.addRange(a),r.extend(j.node,j.offset)):(a.setEnd(j.node,j.offset),r.addRange(a)))}}for(a=[],r=l;r=r.parentNode;)r.nodeType===1&&a.push({element:r,left:r.scrollLeft,top:r.scrollTop});for(typeof l.focus=="function"&&l.focus(),l=0;l<a.length;l++)r=a[l],r.element.scrollLeft=r.left,r.element.scrollTop=r.top}}var ij=u&&"documentMode"in document&&11>=document.documentMode,_s=null,Bc=null,Ui=null,Fc=!1;function gf(r,a,l){var h=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Fc||_s==null||_s!==Is(h)||(h=_s,"selectionStart"in h&&_c(h)?h={start:h.selectionStart,end:h.selectionEnd}:(h=(h.ownerDocument&&h.ownerDocument.defaultView||window).getSelection(),h={anchorNode:h.anchorNode,anchorOffset:h.anchorOffset,focusNode:h.focusNode,focusOffset:h.focusOffset}),Ui&&zi(Ui,h)||(Ui=h,h=io(Bc,"onSelect"),0<h.length&&(a=new Ac("onSelect","select",null,a,l),r.push({event:a,listeners:h}),a.target=_s)))}function to(r,a){var l={};return l[r.toLowerCase()]=a.toLowerCase(),l["Webkit"+r]="webkit"+a,l["Moz"+r]="moz"+a,l}var Bs={animationend:to("Animation","AnimationEnd"),animationiteration:to("Animation","AnimationIteration"),animationstart:to("Animation","AnimationStart"),transitionend:to("Transition","TransitionEnd")},zc={},kf={};u&&(kf=document.createElement("div").style,"AnimationEvent"in window||(delete Bs.animationend.animation,delete Bs.animationiteration.animation,delete Bs.animationstart.animation),"TransitionEvent"in window||delete Bs.transitionend.transition);function no(r){if(zc[r])return zc[r];if(!Bs[r])return r;var a=Bs[r],l;for(l in a)if(a.hasOwnProperty(l)&&l in kf)return zc[r]=a[l];return r}var vf=no("animationend"),wf=no("animationiteration"),yf=no("animationstart"),xf=no("transitionend"),jf=new Map,bf="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 Dn(r,a){jf.set(r,a),c(a,[r])}for(var Uc=0;Uc<bf.length;Uc++){var Wc=bf[Uc],rj=Wc.toLowerCase(),oj=Wc[0].toUpperCase()+Wc.slice(1);Dn(rj,"on"+oj)}Dn(vf,"onAnimationEnd"),Dn(wf,"onAnimationIteration"),Dn(yf,"onAnimationStart"),Dn("dblclick","onDoubleClick"),Dn("focusin","onFocus"),Dn("focusout","onBlur"),Dn(xf,"onTransitionEnd"),d("onMouseEnter",["mouseout","mouseover"]),d("onMouseLeave",["mouseout","mouseover"]),d("onPointerEnter",["pointerout","pointerover"]),d("onPointerLeave",["pointerout","pointerover"]),c("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),c("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),c("onBeforeInput",["compositionend","keypress","textInput","paste"]),c("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),c("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),c("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Wi="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(" "),aj=new Set("cancel close invalid load scroll toggle".split(" ").concat(Wi));function Sf(r,a,l){var h=r.type||"unknown-event";r.currentTarget=l,rx(h,a,void 0,r),r.currentTarget=null}function Nf(r,a){a=(a&4)!==0;for(var l=0;l<r.length;l++){var h=r[l],p=h.event;h=h.listeners;e:{var v=void 0;if(a)for(var j=h.length-1;0<=j;j--){var C=h[j],T=C.instance,P=C.currentTarget;if(C=C.listener,T!==v&&p.isPropagationStopped())break e;Sf(p,C,P),v=T}else for(j=0;j<h.length;j++){if(C=h[j],T=C.instance,P=C.currentTarget,C=C.listener,T!==v&&p.isPropagationStopped())break e;Sf(p,C,P),v=T}}}if(Fr)throw r=yc,Fr=!1,yc=null,r}function De(r,a){var l=a[Jc];l===void 0&&(l=a[Jc]=new Set);var h=r+"__bubble";l.has(h)||($f(a,r,2,!1),l.add(h))}function Hc(r,a,l){var h=0;a&&(h|=4),$f(l,r,h,a)}var so="_reactListening"+Math.random().toString(36).slice(2);function Hi(r){if(!r[so]){r[so]=!0,i.forEach(function(l){l!=="selectionchange"&&(aj.has(l)||Hc(l,!1,r),Hc(l,!0,r))});var a=r.nodeType===9?r:r.ownerDocument;a===null||a[so]||(a[so]=!0,Hc("selectionchange",!1,a))}}function $f(r,a,l,h){switch(qh(a)){case 1:var p=xx;break;case 4:p=jx;break;default:p=Cc}l=p.bind(null,a,l,r),p=void 0,!wc||a!=="touchstart"&&a!=="touchmove"&&a!=="wheel"||(p=!0),h?p!==void 0?r.addEventListener(a,l,{capture:!0,passive:p}):r.addEventListener(a,l,!0):p!==void 0?r.addEventListener(a,l,{passive:p}):r.addEventListener(a,l,!1)}function Kc(r,a,l,h,p){var v=h;if((a&1)===0&&(a&2)===0&&h!==null)e:for(;;){if(h===null)return;var j=h.tag;if(j===3||j===4){var C=h.stateNode.containerInfo;if(C===p||C.nodeType===8&&C.parentNode===p)break;if(j===4)for(j=h.return;j!==null;){var T=j.tag;if((T===3||T===4)&&(T=j.stateNode.containerInfo,T===p||T.nodeType===8&&T.parentNode===p))return;j=j.return}for(;C!==null;){if(j=ls(C),j===null)return;if(T=j.tag,T===5||T===6){h=v=j;continue e}C=C.parentNode}}h=h.return}Ah(function(){var P=v,H=gc(l),G=[];e:{var W=jf.get(r);if(W!==void 0){var X=Ac,ne=r;switch(r){case"keypress":if(Jr(l)===0)break e;case"keydown":case"keyup":X=Dx;break;case"focusin":ne="focus",X=Mc;break;case"focusout":ne="blur",X=Mc;break;case"beforeblur":case"afterblur":X=Mc;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":X=Jh;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":X=Nx;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":X=Fx;break;case vf:case wf:case yf:X=Tx;break;case xf:X=Ux;break;case"scroll":X=bx;break;case"wheel":X=Hx;break;case"copy":case"cut":case"paste":X=Ax;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":X=Zh}var se=(a&4)!==0,Qe=!se&&r==="scroll",M=se?W!==null?W+"Capture":null:W;se=[];for(var A=P,L;A!==null;){L=A;var V=L.stateNode;if(L.tag===5&&V!==null&&(L=V,M!==null&&(V=$i(A,M),V!=null&&se.push(Ki(A,V,L)))),Qe)break;A=A.return}0<se.length&&(W=new X(W,ne,null,l,H),G.push({event:W,listeners:se}))}}if((a&7)===0){e:{if(W=r==="mouseover"||r==="pointerover",X=r==="mouseout"||r==="pointerout",W&&l!==pc&&(ne=l.relatedTarget||l.fromElement)&&(ls(ne)||ne[vn]))break e;if((X||W)&&(W=H.window===H?H:(W=H.ownerDocument)?W.defaultView||W.parentWindow:window,X?(ne=l.relatedTarget||l.toElement,X=P,ne=ne?ls(ne):null,ne!==null&&(Qe=cs(ne),ne!==Qe||ne.tag!==5&&ne.tag!==6)&&(ne=null)):(X=null,ne=P),X!==ne)){if(se=Jh,V="onMouseLeave",M="onMouseEnter",A="mouse",(r==="pointerout"||r==="pointerover")&&(se=Zh,V="onPointerLeave",M="onPointerEnter",A="pointer"),Qe=X==null?W:Us(X),L=ne==null?W:Us(ne),W=new se(V,A+"leave",X,l,H),W.target=Qe,W.relatedTarget=L,V=null,ls(H)===P&&(se=new se(M,A+"enter",ne,l,H),se.target=L,se.relatedTarget=Qe,V=se),Qe=V,X&&ne)t:{for(se=X,M=ne,A=0,L=se;L;L=Fs(L))A++;for(L=0,V=M;V;V=Fs(V))L++;for(;0<A-L;)se=Fs(se),A--;for(;0<L-A;)M=Fs(M),L--;for(;A--;){if(se===M||M!==null&&se===M.alternate)break t;se=Fs(se),M=Fs(M)}se=null}else se=null;X!==null&&Cf(G,W,X,se,!1),ne!==null&&Qe!==null&&Cf(G,Qe,ne,se,!0)}}e:{if(W=P?Us(P):window,X=W.nodeName&&W.nodeName.toLowerCase(),X==="select"||X==="input"&&W.type==="file")var ie=Jx;else if(of(W))if(cf)ie=tj;else{ie=Zx;var le=Xx}else(X=W.nodeName)&&X.toLowerCase()==="input"&&(W.type==="checkbox"||W.type==="radio")&&(ie=ej);if(ie&&(ie=ie(r,P))){af(G,ie,l,H);break e}le&&le(r,W,P),r==="focusout"&&(le=W._wrapperState)&&le.controlled&&W.type==="number"&&dc(W,"number",W.value)}switch(le=P?Us(P):window,r){case"focusin":(of(le)||le.contentEditable==="true")&&(_s=le,Bc=P,Ui=null);break;case"focusout":Ui=Bc=_s=null;break;case"mousedown":Fc=!0;break;case"contextmenu":case"mouseup":case"dragend":Fc=!1,gf(G,l,H);break;case"selectionchange":if(ij)break;case"keydown":case"keyup":gf(G,l,H)}var de;if(Oc)e:{switch(r){case"compositionstart":var he="onCompositionStart";break e;case"compositionend":he="onCompositionEnd";break e;case"compositionupdate":he="onCompositionUpdate";break e}he=void 0}else Ds?sf(r,l)&&(he="onCompositionEnd"):r==="keydown"&&l.keyCode===229&&(he="onCompositionStart");he&&(ef&&l.locale!=="ko"&&(Ds||he!=="onCompositionStart"?he==="onCompositionEnd"&&Ds&&(de=Qh()):(Pn=H,Ec="value"in Pn?Pn.value:Pn.textContent,Ds=!0)),le=io(P,he),0<le.length&&(he=new Xh(he,r,null,l,H),G.push({event:he,listeners:le}),de?he.data=de:(de=rf(l),de!==null&&(he.data=de)))),(de=Gx?Vx(r,l):qx(r,l))&&(P=io(P,"onBeforeInput"),0<P.length&&(H=new Xh("onBeforeInput","beforeinput",null,l,H),G.push({event:H,listeners:P}),H.data=de))}Nf(G,a)})}function Ki(r,a,l){return{instance:r,listener:a,currentTarget:l}}function io(r,a){for(var l=a+"Capture",h=[];r!==null;){var p=r,v=p.stateNode;p.tag===5&&v!==null&&(p=v,v=$i(r,l),v!=null&&h.unshift(Ki(r,v,p)),v=$i(r,a),v!=null&&h.push(Ki(r,v,p))),r=r.return}return h}function Fs(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5);return r||null}function Cf(r,a,l,h,p){for(var v=a._reactName,j=[];l!==null&&l!==h;){var C=l,T=C.alternate,P=C.stateNode;if(T!==null&&T===h)break;C.tag===5&&P!==null&&(C=P,p?(T=$i(l,v),T!=null&&j.unshift(Ki(l,T,C))):p||(T=$i(l,v),T!=null&&j.push(Ki(l,T,C)))),l=l.return}j.length!==0&&r.push({event:a,listeners:j})}var cj=/\r\n?/g,lj=/\u0000|\uFFFD/g;function Tf(r){return(typeof r=="string"?r:""+r).replace(cj,`
38
+ `).replace(lj,"")}function ro(r,a,l){if(a=Tf(a),Tf(r)!==a&&l)throw Error(n(425))}function oo(){}var Gc=null,Vc=null;function qc(r,a){return r==="textarea"||r==="noscript"||typeof a.children=="string"||typeof a.children=="number"||typeof a.dangerouslySetInnerHTML=="object"&&a.dangerouslySetInnerHTML!==null&&a.dangerouslySetInnerHTML.__html!=null}var Qc=typeof setTimeout=="function"?setTimeout:void 0,dj=typeof clearTimeout=="function"?clearTimeout:void 0,Ef=typeof Promise=="function"?Promise:void 0,uj=typeof queueMicrotask=="function"?queueMicrotask:typeof Ef<"u"?function(r){return Ef.resolve(null).then(r).catch(hj)}:Qc;function hj(r){setTimeout(function(){throw r})}function Yc(r,a){var l=a,h=0;do{var p=l.nextSibling;if(r.removeChild(l),p&&p.nodeType===8)if(l=p.data,l==="/$"){if(h===0){r.removeChild(p),Oi(a);return}h--}else l!=="$"&&l!=="$?"&&l!=="$!"||h++;l=p}while(l);Oi(a)}function _n(r){for(;r!=null;r=r.nextSibling){var a=r.nodeType;if(a===1||a===3)break;if(a===8){if(a=r.data,a==="$"||a==="$!"||a==="$?")break;if(a==="/$")return null}}return r}function Af(r){r=r.previousSibling;for(var a=0;r;){if(r.nodeType===8){var l=r.data;if(l==="$"||l==="$!"||l==="$?"){if(a===0)return r;a--}else l==="/$"&&a++}r=r.previousSibling}return null}var zs=Math.random().toString(36).slice(2),ln="__reactFiber$"+zs,Gi="__reactProps$"+zs,vn="__reactContainer$"+zs,Jc="__reactEvents$"+zs,fj="__reactListeners$"+zs,mj="__reactHandles$"+zs;function ls(r){var a=r[ln];if(a)return a;for(var l=r.parentNode;l;){if(a=l[vn]||l[ln]){if(l=a.alternate,a.child!==null||l!==null&&l.child!==null)for(r=Af(r);r!==null;){if(l=r[ln])return l;r=Af(r)}return a}r=l,l=r.parentNode}return null}function Vi(r){return r=r[ln]||r[vn],!r||r.tag!==5&&r.tag!==6&&r.tag!==13&&r.tag!==3?null:r}function Us(r){if(r.tag===5||r.tag===6)return r.stateNode;throw Error(n(33))}function ao(r){return r[Gi]||null}var Xc=[],Ws=-1;function Bn(r){return{current:r}}function _e(r){0>Ws||(r.current=Xc[Ws],Xc[Ws]=null,Ws--)}function Le(r,a){Ws++,Xc[Ws]=r.current,r.current=a}var Fn={},ct=Bn(Fn),xt=Bn(!1),ds=Fn;function Hs(r,a){var l=r.type.contextTypes;if(!l)return Fn;var h=r.stateNode;if(h&&h.__reactInternalMemoizedUnmaskedChildContext===a)return h.__reactInternalMemoizedMaskedChildContext;var p={},v;for(v in l)p[v]=a[v];return h&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=a,r.__reactInternalMemoizedMaskedChildContext=p),p}function jt(r){return r=r.childContextTypes,r!=null}function co(){_e(xt),_e(ct)}function If(r,a,l){if(ct.current!==Fn)throw Error(n(168));Le(ct,a),Le(xt,l)}function Rf(r,a,l){var h=r.stateNode;if(a=a.childContextTypes,typeof h.getChildContext!="function")return l;h=h.getChildContext();for(var p in h)if(!(p in a))throw Error(n(108,pe(r)||"Unknown",p));return U({},l,h)}function lo(r){return r=(r=r.stateNode)&&r.__reactInternalMemoizedMergedChildContext||Fn,ds=ct.current,Le(ct,r),Le(xt,xt.current),!0}function Mf(r,a,l){var h=r.stateNode;if(!h)throw Error(n(169));l?(r=Rf(r,a,ds),h.__reactInternalMemoizedMergedChildContext=r,_e(xt),_e(ct),Le(ct,r)):_e(xt),Le(xt,l)}var wn=null,uo=!1,Zc=!1;function Lf(r){wn===null?wn=[r]:wn.push(r)}function pj(r){uo=!0,Lf(r)}function zn(){if(!Zc&&wn!==null){Zc=!0;var r=0,a=Re;try{var l=wn;for(Re=1;r<l.length;r++){var h=l[r];do h=h(!0);while(h!==null)}wn=null,uo=!1}catch(p){throw wn!==null&&(wn=wn.slice(r+1)),Oh(xc,zn),p}finally{Re=a,Zc=!1}}return null}var Ks=[],Gs=0,ho=null,fo=0,Pt=[],Dt=0,us=null,yn=1,xn="";function hs(r,a){Ks[Gs++]=fo,Ks[Gs++]=ho,ho=r,fo=a}function Of(r,a,l){Pt[Dt++]=yn,Pt[Dt++]=xn,Pt[Dt++]=us,us=r;var h=yn;r=xn;var p=32-Yt(h)-1;h&=~(1<<p),l+=1;var v=32-Yt(a)+p;if(30<v){var j=p-p%5;v=(h&(1<<j)-1).toString(32),h>>=j,p-=j,yn=1<<32-Yt(a)+p|l<<p|h,xn=v+r}else yn=1<<v|l<<p|h,xn=r}function el(r){r.return!==null&&(hs(r,1),Of(r,1,0))}function tl(r){for(;r===ho;)ho=Ks[--Gs],Ks[Gs]=null,fo=Ks[--Gs],Ks[Gs]=null;for(;r===us;)us=Pt[--Dt],Pt[Dt]=null,xn=Pt[--Dt],Pt[Dt]=null,yn=Pt[--Dt],Pt[Dt]=null}var Rt=null,Mt=null,Fe=!1,Xt=null;function Pf(r,a){var l=zt(5,null,null,0);l.elementType="DELETED",l.stateNode=a,l.return=r,a=r.deletions,a===null?(r.deletions=[l],r.flags|=16):a.push(l)}function Df(r,a){switch(r.tag){case 5:var l=r.type;return a=a.nodeType!==1||l.toLowerCase()!==a.nodeName.toLowerCase()?null:a,a!==null?(r.stateNode=a,Rt=r,Mt=_n(a.firstChild),!0):!1;case 6:return a=r.pendingProps===""||a.nodeType!==3?null:a,a!==null?(r.stateNode=a,Rt=r,Mt=null,!0):!1;case 13:return a=a.nodeType!==8?null:a,a!==null?(l=us!==null?{id:yn,overflow:xn}:null,r.memoizedState={dehydrated:a,treeContext:l,retryLane:1073741824},l=zt(18,null,null,0),l.stateNode=a,l.return=r,r.child=l,Rt=r,Mt=null,!0):!1;default:return!1}}function nl(r){return(r.mode&1)!==0&&(r.flags&128)===0}function sl(r){if(Fe){var a=Mt;if(a){var l=a;if(!Df(r,a)){if(nl(r))throw Error(n(418));a=_n(l.nextSibling);var h=Rt;a&&Df(r,a)?Pf(h,l):(r.flags=r.flags&-4097|2,Fe=!1,Rt=r)}}else{if(nl(r))throw Error(n(418));r.flags=r.flags&-4097|2,Fe=!1,Rt=r}}}function _f(r){for(r=r.return;r!==null&&r.tag!==5&&r.tag!==3&&r.tag!==13;)r=r.return;Rt=r}function mo(r){if(r!==Rt)return!1;if(!Fe)return _f(r),Fe=!0,!1;var a;if((a=r.tag!==3)&&!(a=r.tag!==5)&&(a=r.type,a=a!=="head"&&a!=="body"&&!qc(r.type,r.memoizedProps)),a&&(a=Mt)){if(nl(r))throw Bf(),Error(n(418));for(;a;)Pf(r,a),a=_n(a.nextSibling)}if(_f(r),r.tag===13){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(n(317));e:{for(r=r.nextSibling,a=0;r;){if(r.nodeType===8){var l=r.data;if(l==="/$"){if(a===0){Mt=_n(r.nextSibling);break e}a--}else l!=="$"&&l!=="$!"&&l!=="$?"||a++}r=r.nextSibling}Mt=null}}else Mt=Rt?_n(r.stateNode.nextSibling):null;return!0}function Bf(){for(var r=Mt;r;)r=_n(r.nextSibling)}function Vs(){Mt=Rt=null,Fe=!1}function il(r){Xt===null?Xt=[r]:Xt.push(r)}var gj=F.ReactCurrentBatchConfig;function qi(r,a,l){if(r=l.ref,r!==null&&typeof r!="function"&&typeof r!="object"){if(l._owner){if(l=l._owner,l){if(l.tag!==1)throw Error(n(309));var h=l.stateNode}if(!h)throw Error(n(147,r));var p=h,v=""+r;return a!==null&&a.ref!==null&&typeof a.ref=="function"&&a.ref._stringRef===v?a.ref:(a=function(j){var C=p.refs;j===null?delete C[v]:C[v]=j},a._stringRef=v,a)}if(typeof r!="string")throw Error(n(284));if(!l._owner)throw Error(n(290,r))}return r}function po(r,a){throw r=Object.prototype.toString.call(a),Error(n(31,r==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":r))}function Ff(r){var a=r._init;return a(r._payload)}function zf(r){function a(M,A){if(r){var L=M.deletions;L===null?(M.deletions=[A],M.flags|=16):L.push(A)}}function l(M,A){if(!r)return null;for(;A!==null;)a(M,A),A=A.sibling;return null}function h(M,A){for(M=new Map;A!==null;)A.key!==null?M.set(A.key,A):M.set(A.index,A),A=A.sibling;return M}function p(M,A){return M=Qn(M,A),M.index=0,M.sibling=null,M}function v(M,A,L){return M.index=L,r?(L=M.alternate,L!==null?(L=L.index,L<A?(M.flags|=2,A):L):(M.flags|=2,A)):(M.flags|=1048576,A)}function j(M){return r&&M.alternate===null&&(M.flags|=2),M}function C(M,A,L,V){return A===null||A.tag!==6?(A=Ql(L,M.mode,V),A.return=M,A):(A=p(A,L),A.return=M,A)}function T(M,A,L,V){var ie=L.type;return ie===Q?H(M,A,L.props.children,V,L.key):A!==null&&(A.elementType===ie||typeof ie=="object"&&ie!==null&&ie.$$typeof===we&&Ff(ie)===A.type)?(V=p(A,L.props),V.ref=qi(M,A,L),V.return=M,V):(V=Bo(L.type,L.key,L.props,null,M.mode,V),V.ref=qi(M,A,L),V.return=M,V)}function P(M,A,L,V){return A===null||A.tag!==4||A.stateNode.containerInfo!==L.containerInfo||A.stateNode.implementation!==L.implementation?(A=Yl(L,M.mode,V),A.return=M,A):(A=p(A,L.children||[]),A.return=M,A)}function H(M,A,L,V,ie){return A===null||A.tag!==7?(A=ys(L,M.mode,V,ie),A.return=M,A):(A=p(A,L),A.return=M,A)}function G(M,A,L){if(typeof A=="string"&&A!==""||typeof A=="number")return A=Ql(""+A,M.mode,L),A.return=M,A;if(typeof A=="object"&&A!==null){switch(A.$$typeof){case K:return L=Bo(A.type,A.key,A.props,null,M.mode,L),L.ref=qi(M,null,A),L.return=M,L;case I:return A=Yl(A,M.mode,L),A.return=M,A;case we:var V=A._init;return G(M,V(A._payload),L)}if(bi(A)||Y(A))return A=ys(A,M.mode,L,null),A.return=M,A;po(M,A)}return null}function W(M,A,L,V){var ie=A!==null?A.key:null;if(typeof L=="string"&&L!==""||typeof L=="number")return ie!==null?null:C(M,A,""+L,V);if(typeof L=="object"&&L!==null){switch(L.$$typeof){case K:return L.key===ie?T(M,A,L,V):null;case I:return L.key===ie?P(M,A,L,V):null;case we:return ie=L._init,W(M,A,ie(L._payload),V)}if(bi(L)||Y(L))return ie!==null?null:H(M,A,L,V,null);po(M,L)}return null}function X(M,A,L,V,ie){if(typeof V=="string"&&V!==""||typeof V=="number")return M=M.get(L)||null,C(A,M,""+V,ie);if(typeof V=="object"&&V!==null){switch(V.$$typeof){case K:return M=M.get(V.key===null?L:V.key)||null,T(A,M,V,ie);case I:return M=M.get(V.key===null?L:V.key)||null,P(A,M,V,ie);case we:var le=V._init;return X(M,A,L,le(V._payload),ie)}if(bi(V)||Y(V))return M=M.get(L)||null,H(A,M,V,ie,null);po(A,V)}return null}function ne(M,A,L,V){for(var ie=null,le=null,de=A,he=A=0,nt=null;de!==null&&he<L.length;he++){de.index>he?(nt=de,de=null):nt=de.sibling;var Ee=W(M,de,L[he],V);if(Ee===null){de===null&&(de=nt);break}r&&de&&Ee.alternate===null&&a(M,de),A=v(Ee,A,he),le===null?ie=Ee:le.sibling=Ee,le=Ee,de=nt}if(he===L.length)return l(M,de),Fe&&hs(M,he),ie;if(de===null){for(;he<L.length;he++)de=G(M,L[he],V),de!==null&&(A=v(de,A,he),le===null?ie=de:le.sibling=de,le=de);return Fe&&hs(M,he),ie}for(de=h(M,de);he<L.length;he++)nt=X(de,M,he,L[he],V),nt!==null&&(r&&nt.alternate!==null&&de.delete(nt.key===null?he:nt.key),A=v(nt,A,he),le===null?ie=nt:le.sibling=nt,le=nt);return r&&de.forEach(function(Yn){return a(M,Yn)}),Fe&&hs(M,he),ie}function se(M,A,L,V){var ie=Y(L);if(typeof ie!="function")throw Error(n(150));if(L=ie.call(L),L==null)throw Error(n(151));for(var le=ie=null,de=A,he=A=0,nt=null,Ee=L.next();de!==null&&!Ee.done;he++,Ee=L.next()){de.index>he?(nt=de,de=null):nt=de.sibling;var Yn=W(M,de,Ee.value,V);if(Yn===null){de===null&&(de=nt);break}r&&de&&Yn.alternate===null&&a(M,de),A=v(Yn,A,he),le===null?ie=Yn:le.sibling=Yn,le=Yn,de=nt}if(Ee.done)return l(M,de),Fe&&hs(M,he),ie;if(de===null){for(;!Ee.done;he++,Ee=L.next())Ee=G(M,Ee.value,V),Ee!==null&&(A=v(Ee,A,he),le===null?ie=Ee:le.sibling=Ee,le=Ee);return Fe&&hs(M,he),ie}for(de=h(M,de);!Ee.done;he++,Ee=L.next())Ee=X(de,M,he,Ee.value,V),Ee!==null&&(r&&Ee.alternate!==null&&de.delete(Ee.key===null?he:Ee.key),A=v(Ee,A,he),le===null?ie=Ee:le.sibling=Ee,le=Ee);return r&&de.forEach(function(Qj){return a(M,Qj)}),Fe&&hs(M,he),ie}function Qe(M,A,L,V){if(typeof L=="object"&&L!==null&&L.type===Q&&L.key===null&&(L=L.props.children),typeof L=="object"&&L!==null){switch(L.$$typeof){case K:e:{for(var ie=L.key,le=A;le!==null;){if(le.key===ie){if(ie=L.type,ie===Q){if(le.tag===7){l(M,le.sibling),A=p(le,L.props.children),A.return=M,M=A;break e}}else if(le.elementType===ie||typeof ie=="object"&&ie!==null&&ie.$$typeof===we&&Ff(ie)===le.type){l(M,le.sibling),A=p(le,L.props),A.ref=qi(M,le,L),A.return=M,M=A;break e}l(M,le);break}else a(M,le);le=le.sibling}L.type===Q?(A=ys(L.props.children,M.mode,V,L.key),A.return=M,M=A):(V=Bo(L.type,L.key,L.props,null,M.mode,V),V.ref=qi(M,A,L),V.return=M,M=V)}return j(M);case I:e:{for(le=L.key;A!==null;){if(A.key===le)if(A.tag===4&&A.stateNode.containerInfo===L.containerInfo&&A.stateNode.implementation===L.implementation){l(M,A.sibling),A=p(A,L.children||[]),A.return=M,M=A;break e}else{l(M,A);break}else a(M,A);A=A.sibling}A=Yl(L,M.mode,V),A.return=M,M=A}return j(M);case we:return le=L._init,Qe(M,A,le(L._payload),V)}if(bi(L))return ne(M,A,L,V);if(Y(L))return se(M,A,L,V);po(M,L)}return typeof L=="string"&&L!==""||typeof L=="number"?(L=""+L,A!==null&&A.tag===6?(l(M,A.sibling),A=p(A,L),A.return=M,M=A):(l(M,A),A=Ql(L,M.mode,V),A.return=M,M=A),j(M)):l(M,A)}return Qe}var qs=zf(!0),Uf=zf(!1),go=Bn(null),ko=null,Qs=null,rl=null;function ol(){rl=Qs=ko=null}function al(r){var a=go.current;_e(go),r._currentValue=a}function cl(r,a,l){for(;r!==null;){var h=r.alternate;if((r.childLanes&a)!==a?(r.childLanes|=a,h!==null&&(h.childLanes|=a)):h!==null&&(h.childLanes&a)!==a&&(h.childLanes|=a),r===l)break;r=r.return}}function Ys(r,a){ko=r,rl=Qs=null,r=r.dependencies,r!==null&&r.firstContext!==null&&((r.lanes&a)!==0&&(bt=!0),r.firstContext=null)}function _t(r){var a=r._currentValue;if(rl!==r)if(r={context:r,memoizedValue:a,next:null},Qs===null){if(ko===null)throw Error(n(308));Qs=r,ko.dependencies={lanes:0,firstContext:r}}else Qs=Qs.next=r;return a}var fs=null;function ll(r){fs===null?fs=[r]:fs.push(r)}function Wf(r,a,l,h){var p=a.interleaved;return p===null?(l.next=l,ll(a)):(l.next=p.next,p.next=l),a.interleaved=l,jn(r,h)}function jn(r,a){r.lanes|=a;var l=r.alternate;for(l!==null&&(l.lanes|=a),l=r,r=r.return;r!==null;)r.childLanes|=a,l=r.alternate,l!==null&&(l.childLanes|=a),l=r,r=r.return;return l.tag===3?l.stateNode:null}var Un=!1;function dl(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Hf(r,a){r=r.updateQueue,a.updateQueue===r&&(a.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,effects:r.effects})}function bn(r,a){return{eventTime:r,lane:a,tag:0,payload:null,callback:null,next:null}}function Wn(r,a,l){var h=r.updateQueue;if(h===null)return null;if(h=h.shared,(Ce&2)!==0){var p=h.pending;return p===null?a.next=a:(a.next=p.next,p.next=a),h.pending=a,jn(r,l)}return p=h.interleaved,p===null?(a.next=a,ll(h)):(a.next=p.next,p.next=a),h.interleaved=a,jn(r,l)}function vo(r,a,l){if(a=a.updateQueue,a!==null&&(a=a.shared,(l&4194240)!==0)){var h=a.lanes;h&=r.pendingLanes,l|=h,a.lanes=l,Sc(r,l)}}function Kf(r,a){var l=r.updateQueue,h=r.alternate;if(h!==null&&(h=h.updateQueue,l===h)){var p=null,v=null;if(l=l.firstBaseUpdate,l!==null){do{var j={eventTime:l.eventTime,lane:l.lane,tag:l.tag,payload:l.payload,callback:l.callback,next:null};v===null?p=v=j:v=v.next=j,l=l.next}while(l!==null);v===null?p=v=a:v=v.next=a}else p=v=a;l={baseState:h.baseState,firstBaseUpdate:p,lastBaseUpdate:v,shared:h.shared,effects:h.effects},r.updateQueue=l;return}r=l.lastBaseUpdate,r===null?l.firstBaseUpdate=a:r.next=a,l.lastBaseUpdate=a}function wo(r,a,l,h){var p=r.updateQueue;Un=!1;var v=p.firstBaseUpdate,j=p.lastBaseUpdate,C=p.shared.pending;if(C!==null){p.shared.pending=null;var T=C,P=T.next;T.next=null,j===null?v=P:j.next=P,j=T;var H=r.alternate;H!==null&&(H=H.updateQueue,C=H.lastBaseUpdate,C!==j&&(C===null?H.firstBaseUpdate=P:C.next=P,H.lastBaseUpdate=T))}if(v!==null){var G=p.baseState;j=0,H=P=T=null,C=v;do{var W=C.lane,X=C.eventTime;if((h&W)===W){H!==null&&(H=H.next={eventTime:X,lane:0,tag:C.tag,payload:C.payload,callback:C.callback,next:null});e:{var ne=r,se=C;switch(W=a,X=l,se.tag){case 1:if(ne=se.payload,typeof ne=="function"){G=ne.call(X,G,W);break e}G=ne;break e;case 3:ne.flags=ne.flags&-65537|128;case 0:if(ne=se.payload,W=typeof ne=="function"?ne.call(X,G,W):ne,W==null)break e;G=U({},G,W);break e;case 2:Un=!0}}C.callback!==null&&C.lane!==0&&(r.flags|=64,W=p.effects,W===null?p.effects=[C]:W.push(C))}else X={eventTime:X,lane:W,tag:C.tag,payload:C.payload,callback:C.callback,next:null},H===null?(P=H=X,T=G):H=H.next=X,j|=W;if(C=C.next,C===null){if(C=p.shared.pending,C===null)break;W=C,C=W.next,W.next=null,p.lastBaseUpdate=W,p.shared.pending=null}}while(!0);if(H===null&&(T=G),p.baseState=T,p.firstBaseUpdate=P,p.lastBaseUpdate=H,a=p.shared.interleaved,a!==null){p=a;do j|=p.lane,p=p.next;while(p!==a)}else v===null&&(p.shared.lanes=0);gs|=j,r.lanes=j,r.memoizedState=G}}function Gf(r,a,l){if(r=a.effects,a.effects=null,r!==null)for(a=0;a<r.length;a++){var h=r[a],p=h.callback;if(p!==null){if(h.callback=null,h=l,typeof p!="function")throw Error(n(191,p));p.call(h)}}}var Qi={},dn=Bn(Qi),Yi=Bn(Qi),Ji=Bn(Qi);function ms(r){if(r===Qi)throw Error(n(174));return r}function ul(r,a){switch(Le(Ji,a),Le(Yi,r),Le(dn,Qi),r=a.nodeType,r){case 9:case 11:a=(a=a.documentElement)?a.namespaceURI:hc(null,"");break;default:r=r===8?a.parentNode:a,a=r.namespaceURI||null,r=r.tagName,a=hc(a,r)}_e(dn),Le(dn,a)}function Js(){_e(dn),_e(Yi),_e(Ji)}function Vf(r){ms(Ji.current);var a=ms(dn.current),l=hc(a,r.type);a!==l&&(Le(Yi,r),Le(dn,l))}function hl(r){Yi.current===r&&(_e(dn),_e(Yi))}var Ue=Bn(0);function yo(r){for(var a=r;a!==null;){if(a.tag===13){var l=a.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||l.data==="$?"||l.data==="$!"))return a}else if(a.tag===19&&a.memoizedProps.revealOrder!==void 0){if((a.flags&128)!==0)return a}else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===r)break;for(;a.sibling===null;){if(a.return===null||a.return===r)return null;a=a.return}a.sibling.return=a.return,a=a.sibling}return null}var fl=[];function ml(){for(var r=0;r<fl.length;r++)fl[r]._workInProgressVersionPrimary=null;fl.length=0}var xo=F.ReactCurrentDispatcher,pl=F.ReactCurrentBatchConfig,ps=0,We=null,Xe=null,et=null,jo=!1,Xi=!1,Zi=0,kj=0;function lt(){throw Error(n(321))}function gl(r,a){if(a===null)return!1;for(var l=0;l<a.length&&l<r.length;l++)if(!Jt(r[l],a[l]))return!1;return!0}function kl(r,a,l,h,p,v){if(ps=v,We=a,a.memoizedState=null,a.updateQueue=null,a.lanes=0,xo.current=r===null||r.memoizedState===null?xj:jj,r=l(h,p),Xi){v=0;do{if(Xi=!1,Zi=0,25<=v)throw Error(n(301));v+=1,et=Xe=null,a.updateQueue=null,xo.current=bj,r=l(h,p)}while(Xi)}if(xo.current=No,a=Xe!==null&&Xe.next!==null,ps=0,et=Xe=We=null,jo=!1,a)throw Error(n(300));return r}function vl(){var r=Zi!==0;return Zi=0,r}function un(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return et===null?We.memoizedState=et=r:et=et.next=r,et}function Bt(){if(Xe===null){var r=We.alternate;r=r!==null?r.memoizedState:null}else r=Xe.next;var a=et===null?We.memoizedState:et.next;if(a!==null)et=a,Xe=r;else{if(r===null)throw Error(n(310));Xe=r,r={memoizedState:Xe.memoizedState,baseState:Xe.baseState,baseQueue:Xe.baseQueue,queue:Xe.queue,next:null},et===null?We.memoizedState=et=r:et=et.next=r}return et}function er(r,a){return typeof a=="function"?a(r):a}function wl(r){var a=Bt(),l=a.queue;if(l===null)throw Error(n(311));l.lastRenderedReducer=r;var h=Xe,p=h.baseQueue,v=l.pending;if(v!==null){if(p!==null){var j=p.next;p.next=v.next,v.next=j}h.baseQueue=p=v,l.pending=null}if(p!==null){v=p.next,h=h.baseState;var C=j=null,T=null,P=v;do{var H=P.lane;if((ps&H)===H)T!==null&&(T=T.next={lane:0,action:P.action,hasEagerState:P.hasEagerState,eagerState:P.eagerState,next:null}),h=P.hasEagerState?P.eagerState:r(h,P.action);else{var G={lane:H,action:P.action,hasEagerState:P.hasEagerState,eagerState:P.eagerState,next:null};T===null?(C=T=G,j=h):T=T.next=G,We.lanes|=H,gs|=H}P=P.next}while(P!==null&&P!==v);T===null?j=h:T.next=C,Jt(h,a.memoizedState)||(bt=!0),a.memoizedState=h,a.baseState=j,a.baseQueue=T,l.lastRenderedState=h}if(r=l.interleaved,r!==null){p=r;do v=p.lane,We.lanes|=v,gs|=v,p=p.next;while(p!==r)}else p===null&&(l.lanes=0);return[a.memoizedState,l.dispatch]}function yl(r){var a=Bt(),l=a.queue;if(l===null)throw Error(n(311));l.lastRenderedReducer=r;var h=l.dispatch,p=l.pending,v=a.memoizedState;if(p!==null){l.pending=null;var j=p=p.next;do v=r(v,j.action),j=j.next;while(j!==p);Jt(v,a.memoizedState)||(bt=!0),a.memoizedState=v,a.baseQueue===null&&(a.baseState=v),l.lastRenderedState=v}return[v,h]}function qf(){}function Qf(r,a){var l=We,h=Bt(),p=a(),v=!Jt(h.memoizedState,p);if(v&&(h.memoizedState=p,bt=!0),h=h.queue,xl(Xf.bind(null,l,h,r),[r]),h.getSnapshot!==a||v||et!==null&&et.memoizedState.tag&1){if(l.flags|=2048,tr(9,Jf.bind(null,l,h,p,a),void 0,null),tt===null)throw Error(n(349));(ps&30)!==0||Yf(l,a,p)}return p}function Yf(r,a,l){r.flags|=16384,r={getSnapshot:a,value:l},a=We.updateQueue,a===null?(a={lastEffect:null,stores:null},We.updateQueue=a,a.stores=[r]):(l=a.stores,l===null?a.stores=[r]:l.push(r))}function Jf(r,a,l,h){a.value=l,a.getSnapshot=h,Zf(a)&&em(r)}function Xf(r,a,l){return l(function(){Zf(a)&&em(r)})}function Zf(r){var a=r.getSnapshot;r=r.value;try{var l=a();return!Jt(r,l)}catch{return!0}}function em(r){var a=jn(r,1);a!==null&&nn(a,r,1,-1)}function tm(r){var a=un();return typeof r=="function"&&(r=r()),a.memoizedState=a.baseState=r,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:er,lastRenderedState:r},a.queue=r,r=r.dispatch=yj.bind(null,We,r),[a.memoizedState,r]}function tr(r,a,l,h){return r={tag:r,create:a,destroy:l,deps:h,next:null},a=We.updateQueue,a===null?(a={lastEffect:null,stores:null},We.updateQueue=a,a.lastEffect=r.next=r):(l=a.lastEffect,l===null?a.lastEffect=r.next=r:(h=l.next,l.next=r,r.next=h,a.lastEffect=r)),r}function nm(){return Bt().memoizedState}function bo(r,a,l,h){var p=un();We.flags|=r,p.memoizedState=tr(1|a,l,void 0,h===void 0?null:h)}function So(r,a,l,h){var p=Bt();h=h===void 0?null:h;var v=void 0;if(Xe!==null){var j=Xe.memoizedState;if(v=j.destroy,h!==null&&gl(h,j.deps)){p.memoizedState=tr(a,l,v,h);return}}We.flags|=r,p.memoizedState=tr(1|a,l,v,h)}function sm(r,a){return bo(8390656,8,r,a)}function xl(r,a){return So(2048,8,r,a)}function im(r,a){return So(4,2,r,a)}function rm(r,a){return So(4,4,r,a)}function om(r,a){if(typeof a=="function")return r=r(),a(r),function(){a(null)};if(a!=null)return r=r(),a.current=r,function(){a.current=null}}function am(r,a,l){return l=l!=null?l.concat([r]):null,So(4,4,om.bind(null,a,r),l)}function jl(){}function cm(r,a){var l=Bt();a=a===void 0?null:a;var h=l.memoizedState;return h!==null&&a!==null&&gl(a,h[1])?h[0]:(l.memoizedState=[r,a],r)}function lm(r,a){var l=Bt();a=a===void 0?null:a;var h=l.memoizedState;return h!==null&&a!==null&&gl(a,h[1])?h[0]:(r=r(),l.memoizedState=[r,a],r)}function dm(r,a,l){return(ps&21)===0?(r.baseState&&(r.baseState=!1,bt=!0),r.memoizedState=l):(Jt(l,a)||(l=Bh(),We.lanes|=l,gs|=l,r.baseState=!0),a)}function vj(r,a){var l=Re;Re=l!==0&&4>l?l:4,r(!0);var h=pl.transition;pl.transition={};try{r(!1),a()}finally{Re=l,pl.transition=h}}function um(){return Bt().memoizedState}function wj(r,a,l){var h=Vn(r);if(l={lane:h,action:l,hasEagerState:!1,eagerState:null,next:null},hm(r))fm(a,l);else if(l=Wf(r,a,l,h),l!==null){var p=vt();nn(l,r,h,p),mm(l,a,h)}}function yj(r,a,l){var h=Vn(r),p={lane:h,action:l,hasEagerState:!1,eagerState:null,next:null};if(hm(r))fm(a,p);else{var v=r.alternate;if(r.lanes===0&&(v===null||v.lanes===0)&&(v=a.lastRenderedReducer,v!==null))try{var j=a.lastRenderedState,C=v(j,l);if(p.hasEagerState=!0,p.eagerState=C,Jt(C,j)){var T=a.interleaved;T===null?(p.next=p,ll(a)):(p.next=T.next,T.next=p),a.interleaved=p;return}}catch{}finally{}l=Wf(r,a,p,h),l!==null&&(p=vt(),nn(l,r,h,p),mm(l,a,h))}}function hm(r){var a=r.alternate;return r===We||a!==null&&a===We}function fm(r,a){Xi=jo=!0;var l=r.pending;l===null?a.next=a:(a.next=l.next,l.next=a),r.pending=a}function mm(r,a,l){if((l&4194240)!==0){var h=a.lanes;h&=r.pendingLanes,l|=h,a.lanes=l,Sc(r,l)}}var No={readContext:_t,useCallback:lt,useContext:lt,useEffect:lt,useImperativeHandle:lt,useInsertionEffect:lt,useLayoutEffect:lt,useMemo:lt,useReducer:lt,useRef:lt,useState:lt,useDebugValue:lt,useDeferredValue:lt,useTransition:lt,useMutableSource:lt,useSyncExternalStore:lt,useId:lt,unstable_isNewReconciler:!1},xj={readContext:_t,useCallback:function(r,a){return un().memoizedState=[r,a===void 0?null:a],r},useContext:_t,useEffect:sm,useImperativeHandle:function(r,a,l){return l=l!=null?l.concat([r]):null,bo(4194308,4,om.bind(null,a,r),l)},useLayoutEffect:function(r,a){return bo(4194308,4,r,a)},useInsertionEffect:function(r,a){return bo(4,2,r,a)},useMemo:function(r,a){var l=un();return a=a===void 0?null:a,r=r(),l.memoizedState=[r,a],r},useReducer:function(r,a,l){var h=un();return a=l!==void 0?l(a):a,h.memoizedState=h.baseState=a,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:a},h.queue=r,r=r.dispatch=wj.bind(null,We,r),[h.memoizedState,r]},useRef:function(r){var a=un();return r={current:r},a.memoizedState=r},useState:tm,useDebugValue:jl,useDeferredValue:function(r){return un().memoizedState=r},useTransition:function(){var r=tm(!1),a=r[0];return r=vj.bind(null,r[1]),un().memoizedState=r,[a,r]},useMutableSource:function(){},useSyncExternalStore:function(r,a,l){var h=We,p=un();if(Fe){if(l===void 0)throw Error(n(407));l=l()}else{if(l=a(),tt===null)throw Error(n(349));(ps&30)!==0||Yf(h,a,l)}p.memoizedState=l;var v={value:l,getSnapshot:a};return p.queue=v,sm(Xf.bind(null,h,v,r),[r]),h.flags|=2048,tr(9,Jf.bind(null,h,v,l,a),void 0,null),l},useId:function(){var r=un(),a=tt.identifierPrefix;if(Fe){var l=xn,h=yn;l=(h&~(1<<32-Yt(h)-1)).toString(32)+l,a=":"+a+"R"+l,l=Zi++,0<l&&(a+="H"+l.toString(32)),a+=":"}else l=kj++,a=":"+a+"r"+l.toString(32)+":";return r.memoizedState=a},unstable_isNewReconciler:!1},jj={readContext:_t,useCallback:cm,useContext:_t,useEffect:xl,useImperativeHandle:am,useInsertionEffect:im,useLayoutEffect:rm,useMemo:lm,useReducer:wl,useRef:nm,useState:function(){return wl(er)},useDebugValue:jl,useDeferredValue:function(r){var a=Bt();return dm(a,Xe.memoizedState,r)},useTransition:function(){var r=wl(er)[0],a=Bt().memoizedState;return[r,a]},useMutableSource:qf,useSyncExternalStore:Qf,useId:um,unstable_isNewReconciler:!1},bj={readContext:_t,useCallback:cm,useContext:_t,useEffect:xl,useImperativeHandle:am,useInsertionEffect:im,useLayoutEffect:rm,useMemo:lm,useReducer:yl,useRef:nm,useState:function(){return yl(er)},useDebugValue:jl,useDeferredValue:function(r){var a=Bt();return Xe===null?a.memoizedState=r:dm(a,Xe.memoizedState,r)},useTransition:function(){var r=yl(er)[0],a=Bt().memoizedState;return[r,a]},useMutableSource:qf,useSyncExternalStore:Qf,useId:um,unstable_isNewReconciler:!1};function Zt(r,a){if(r&&r.defaultProps){a=U({},a),r=r.defaultProps;for(var l in r)a[l]===void 0&&(a[l]=r[l]);return a}return a}function bl(r,a,l,h){a=r.memoizedState,l=l(h,a),l=l==null?a:U({},a,l),r.memoizedState=l,r.lanes===0&&(r.updateQueue.baseState=l)}var $o={isMounted:function(r){return(r=r._reactInternals)?cs(r)===r:!1},enqueueSetState:function(r,a,l){r=r._reactInternals;var h=vt(),p=Vn(r),v=bn(h,p);v.payload=a,l!=null&&(v.callback=l),a=Wn(r,v,p),a!==null&&(nn(a,r,p,h),vo(a,r,p))},enqueueReplaceState:function(r,a,l){r=r._reactInternals;var h=vt(),p=Vn(r),v=bn(h,p);v.tag=1,v.payload=a,l!=null&&(v.callback=l),a=Wn(r,v,p),a!==null&&(nn(a,r,p,h),vo(a,r,p))},enqueueForceUpdate:function(r,a){r=r._reactInternals;var l=vt(),h=Vn(r),p=bn(l,h);p.tag=2,a!=null&&(p.callback=a),a=Wn(r,p,h),a!==null&&(nn(a,r,h,l),vo(a,r,h))}};function pm(r,a,l,h,p,v,j){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(h,v,j):a.prototype&&a.prototype.isPureReactComponent?!zi(l,h)||!zi(p,v):!0}function gm(r,a,l){var h=!1,p=Fn,v=a.contextType;return typeof v=="object"&&v!==null?v=_t(v):(p=jt(a)?ds:ct.current,h=a.contextTypes,v=(h=h!=null)?Hs(r,p):Fn),a=new a(l,v),r.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=$o,r.stateNode=a,a._reactInternals=r,h&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=p,r.__reactInternalMemoizedMaskedChildContext=v),a}function km(r,a,l,h){r=a.state,typeof a.componentWillReceiveProps=="function"&&a.componentWillReceiveProps(l,h),typeof a.UNSAFE_componentWillReceiveProps=="function"&&a.UNSAFE_componentWillReceiveProps(l,h),a.state!==r&&$o.enqueueReplaceState(a,a.state,null)}function Sl(r,a,l,h){var p=r.stateNode;p.props=l,p.state=r.memoizedState,p.refs={},dl(r);var v=a.contextType;typeof v=="object"&&v!==null?p.context=_t(v):(v=jt(a)?ds:ct.current,p.context=Hs(r,v)),p.state=r.memoizedState,v=a.getDerivedStateFromProps,typeof v=="function"&&(bl(r,a,v,l),p.state=r.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof p.getSnapshotBeforeUpdate=="function"||typeof p.UNSAFE_componentWillMount!="function"&&typeof p.componentWillMount!="function"||(a=p.state,typeof p.componentWillMount=="function"&&p.componentWillMount(),typeof p.UNSAFE_componentWillMount=="function"&&p.UNSAFE_componentWillMount(),a!==p.state&&$o.enqueueReplaceState(p,p.state,null),wo(r,l,p,h),p.state=r.memoizedState),typeof p.componentDidMount=="function"&&(r.flags|=4194308)}function Xs(r,a){try{var l="",h=a;do l+=ye(h),h=h.return;while(h);var p=l}catch(v){p=`
39
+ Error generating stack: `+v.message+`
40
+ `+v.stack}return{value:r,source:a,stack:p,digest:null}}function Nl(r,a,l){return{value:r,source:null,stack:l??null,digest:a??null}}function $l(r,a){try{console.error(a.value)}catch(l){setTimeout(function(){throw l})}}var Sj=typeof WeakMap=="function"?WeakMap:Map;function vm(r,a,l){l=bn(-1,l),l.tag=3,l.payload={element:null};var h=a.value;return l.callback=function(){Mo||(Mo=!0,zl=h),$l(r,a)},l}function wm(r,a,l){l=bn(-1,l),l.tag=3;var h=r.type.getDerivedStateFromError;if(typeof h=="function"){var p=a.value;l.payload=function(){return h(p)},l.callback=function(){$l(r,a)}}var v=r.stateNode;return v!==null&&typeof v.componentDidCatch=="function"&&(l.callback=function(){$l(r,a),typeof h!="function"&&(Kn===null?Kn=new Set([this]):Kn.add(this));var j=a.stack;this.componentDidCatch(a.value,{componentStack:j!==null?j:""})}),l}function ym(r,a,l){var h=r.pingCache;if(h===null){h=r.pingCache=new Sj;var p=new Set;h.set(a,p)}else p=h.get(a),p===void 0&&(p=new Set,h.set(a,p));p.has(l)||(p.add(l),r=_j.bind(null,r,a,l),a.then(r,r))}function xm(r){do{var a;if((a=r.tag===13)&&(a=r.memoizedState,a=a!==null?a.dehydrated!==null:!0),a)return r;r=r.return}while(r!==null);return null}function jm(r,a,l,h,p){return(r.mode&1)===0?(r===a?r.flags|=65536:(r.flags|=128,l.flags|=131072,l.flags&=-52805,l.tag===1&&(l.alternate===null?l.tag=17:(a=bn(-1,1),a.tag=2,Wn(l,a,1))),l.lanes|=1),r):(r.flags|=65536,r.lanes=p,r)}var Nj=F.ReactCurrentOwner,bt=!1;function kt(r,a,l,h){a.child=r===null?Uf(a,null,l,h):qs(a,r.child,l,h)}function bm(r,a,l,h,p){l=l.render;var v=a.ref;return Ys(a,p),h=kl(r,a,l,h,v,p),l=vl(),r!==null&&!bt?(a.updateQueue=r.updateQueue,a.flags&=-2053,r.lanes&=~p,Sn(r,a,p)):(Fe&&l&&el(a),a.flags|=1,kt(r,a,h,p),a.child)}function Sm(r,a,l,h,p){if(r===null){var v=l.type;return typeof v=="function"&&!ql(v)&&v.defaultProps===void 0&&l.compare===null&&l.defaultProps===void 0?(a.tag=15,a.type=v,Nm(r,a,v,h,p)):(r=Bo(l.type,null,h,a,a.mode,p),r.ref=a.ref,r.return=a,a.child=r)}if(v=r.child,(r.lanes&p)===0){var j=v.memoizedProps;if(l=l.compare,l=l!==null?l:zi,l(j,h)&&r.ref===a.ref)return Sn(r,a,p)}return a.flags|=1,r=Qn(v,h),r.ref=a.ref,r.return=a,a.child=r}function Nm(r,a,l,h,p){if(r!==null){var v=r.memoizedProps;if(zi(v,h)&&r.ref===a.ref)if(bt=!1,a.pendingProps=h=v,(r.lanes&p)!==0)(r.flags&131072)!==0&&(bt=!0);else return a.lanes=r.lanes,Sn(r,a,p)}return Cl(r,a,l,h,p)}function $m(r,a,l){var h=a.pendingProps,p=h.children,v=r!==null?r.memoizedState:null;if(h.mode==="hidden")if((a.mode&1)===0)a.memoizedState={baseLanes:0,cachePool:null,transitions:null},Le(ei,Lt),Lt|=l;else{if((l&1073741824)===0)return r=v!==null?v.baseLanes|l:l,a.lanes=a.childLanes=1073741824,a.memoizedState={baseLanes:r,cachePool:null,transitions:null},a.updateQueue=null,Le(ei,Lt),Lt|=r,null;a.memoizedState={baseLanes:0,cachePool:null,transitions:null},h=v!==null?v.baseLanes:l,Le(ei,Lt),Lt|=h}else v!==null?(h=v.baseLanes|l,a.memoizedState=null):h=l,Le(ei,Lt),Lt|=h;return kt(r,a,p,l),a.child}function Cm(r,a){var l=a.ref;(r===null&&l!==null||r!==null&&r.ref!==l)&&(a.flags|=512,a.flags|=2097152)}function Cl(r,a,l,h,p){var v=jt(l)?ds:ct.current;return v=Hs(a,v),Ys(a,p),l=kl(r,a,l,h,v,p),h=vl(),r!==null&&!bt?(a.updateQueue=r.updateQueue,a.flags&=-2053,r.lanes&=~p,Sn(r,a,p)):(Fe&&h&&el(a),a.flags|=1,kt(r,a,l,p),a.child)}function Tm(r,a,l,h,p){if(jt(l)){var v=!0;lo(a)}else v=!1;if(Ys(a,p),a.stateNode===null)To(r,a),gm(a,l,h),Sl(a,l,h,p),h=!0;else if(r===null){var j=a.stateNode,C=a.memoizedProps;j.props=C;var T=j.context,P=l.contextType;typeof P=="object"&&P!==null?P=_t(P):(P=jt(l)?ds:ct.current,P=Hs(a,P));var H=l.getDerivedStateFromProps,G=typeof H=="function"||typeof j.getSnapshotBeforeUpdate=="function";G||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(C!==h||T!==P)&&km(a,j,h,P),Un=!1;var W=a.memoizedState;j.state=W,wo(a,h,j,p),T=a.memoizedState,C!==h||W!==T||xt.current||Un?(typeof H=="function"&&(bl(a,l,H,h),T=a.memoizedState),(C=Un||pm(a,l,C,h,W,T,P))?(G||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount()),typeof j.componentDidMount=="function"&&(a.flags|=4194308)):(typeof j.componentDidMount=="function"&&(a.flags|=4194308),a.memoizedProps=h,a.memoizedState=T),j.props=h,j.state=T,j.context=P,h=C):(typeof j.componentDidMount=="function"&&(a.flags|=4194308),h=!1)}else{j=a.stateNode,Hf(r,a),C=a.memoizedProps,P=a.type===a.elementType?C:Zt(a.type,C),j.props=P,G=a.pendingProps,W=j.context,T=l.contextType,typeof T=="object"&&T!==null?T=_t(T):(T=jt(l)?ds:ct.current,T=Hs(a,T));var X=l.getDerivedStateFromProps;(H=typeof X=="function"||typeof j.getSnapshotBeforeUpdate=="function")||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(C!==G||W!==T)&&km(a,j,h,T),Un=!1,W=a.memoizedState,j.state=W,wo(a,h,j,p);var ne=a.memoizedState;C!==G||W!==ne||xt.current||Un?(typeof X=="function"&&(bl(a,l,X,h),ne=a.memoizedState),(P=Un||pm(a,l,P,h,W,ne,T)||!1)?(H||typeof j.UNSAFE_componentWillUpdate!="function"&&typeof j.componentWillUpdate!="function"||(typeof j.componentWillUpdate=="function"&&j.componentWillUpdate(h,ne,T),typeof j.UNSAFE_componentWillUpdate=="function"&&j.UNSAFE_componentWillUpdate(h,ne,T)),typeof j.componentDidUpdate=="function"&&(a.flags|=4),typeof j.getSnapshotBeforeUpdate=="function"&&(a.flags|=1024)):(typeof j.componentDidUpdate!="function"||C===r.memoizedProps&&W===r.memoizedState||(a.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||C===r.memoizedProps&&W===r.memoizedState||(a.flags|=1024),a.memoizedProps=h,a.memoizedState=ne),j.props=h,j.state=ne,j.context=T,h=P):(typeof j.componentDidUpdate!="function"||C===r.memoizedProps&&W===r.memoizedState||(a.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||C===r.memoizedProps&&W===r.memoizedState||(a.flags|=1024),h=!1)}return Tl(r,a,l,h,v,p)}function Tl(r,a,l,h,p,v){Cm(r,a);var j=(a.flags&128)!==0;if(!h&&!j)return p&&Mf(a,l,!1),Sn(r,a,v);h=a.stateNode,Nj.current=a;var C=j&&typeof l.getDerivedStateFromError!="function"?null:h.render();return a.flags|=1,r!==null&&j?(a.child=qs(a,r.child,null,v),a.child=qs(a,null,C,v)):kt(r,a,C,v),a.memoizedState=h.state,p&&Mf(a,l,!0),a.child}function Em(r){var a=r.stateNode;a.pendingContext?If(r,a.pendingContext,a.pendingContext!==a.context):a.context&&If(r,a.context,!1),ul(r,a.containerInfo)}function Am(r,a,l,h,p){return Vs(),il(p),a.flags|=256,kt(r,a,l,h),a.child}var El={dehydrated:null,treeContext:null,retryLane:0};function Al(r){return{baseLanes:r,cachePool:null,transitions:null}}function Im(r,a,l){var h=a.pendingProps,p=Ue.current,v=!1,j=(a.flags&128)!==0,C;if((C=j)||(C=r!==null&&r.memoizedState===null?!1:(p&2)!==0),C?(v=!0,a.flags&=-129):(r===null||r.memoizedState!==null)&&(p|=1),Le(Ue,p&1),r===null)return sl(a),r=a.memoizedState,r!==null&&(r=r.dehydrated,r!==null)?((a.mode&1)===0?a.lanes=1:r.data==="$!"?a.lanes=8:a.lanes=1073741824,null):(j=h.children,r=h.fallback,v?(h=a.mode,v=a.child,j={mode:"hidden",children:j},(h&1)===0&&v!==null?(v.childLanes=0,v.pendingProps=j):v=Fo(j,h,0,null),r=ys(r,h,l,null),v.return=a,r.return=a,v.sibling=r,a.child=v,a.child.memoizedState=Al(l),a.memoizedState=El,r):Il(a,j));if(p=r.memoizedState,p!==null&&(C=p.dehydrated,C!==null))return $j(r,a,j,h,C,p,l);if(v){v=h.fallback,j=a.mode,p=r.child,C=p.sibling;var T={mode:"hidden",children:h.children};return(j&1)===0&&a.child!==p?(h=a.child,h.childLanes=0,h.pendingProps=T,a.deletions=null):(h=Qn(p,T),h.subtreeFlags=p.subtreeFlags&14680064),C!==null?v=Qn(C,v):(v=ys(v,j,l,null),v.flags|=2),v.return=a,h.return=a,h.sibling=v,a.child=h,h=v,v=a.child,j=r.child.memoizedState,j=j===null?Al(l):{baseLanes:j.baseLanes|l,cachePool:null,transitions:j.transitions},v.memoizedState=j,v.childLanes=r.childLanes&~l,a.memoizedState=El,h}return v=r.child,r=v.sibling,h=Qn(v,{mode:"visible",children:h.children}),(a.mode&1)===0&&(h.lanes=l),h.return=a,h.sibling=null,r!==null&&(l=a.deletions,l===null?(a.deletions=[r],a.flags|=16):l.push(r)),a.child=h,a.memoizedState=null,h}function Il(r,a){return a=Fo({mode:"visible",children:a},r.mode,0,null),a.return=r,r.child=a}function Co(r,a,l,h){return h!==null&&il(h),qs(a,r.child,null,l),r=Il(a,a.pendingProps.children),r.flags|=2,a.memoizedState=null,r}function $j(r,a,l,h,p,v,j){if(l)return a.flags&256?(a.flags&=-257,h=Nl(Error(n(422))),Co(r,a,j,h)):a.memoizedState!==null?(a.child=r.child,a.flags|=128,null):(v=h.fallback,p=a.mode,h=Fo({mode:"visible",children:h.children},p,0,null),v=ys(v,p,j,null),v.flags|=2,h.return=a,v.return=a,h.sibling=v,a.child=h,(a.mode&1)!==0&&qs(a,r.child,null,j),a.child.memoizedState=Al(j),a.memoizedState=El,v);if((a.mode&1)===0)return Co(r,a,j,null);if(p.data==="$!"){if(h=p.nextSibling&&p.nextSibling.dataset,h)var C=h.dgst;return h=C,v=Error(n(419)),h=Nl(v,h,void 0),Co(r,a,j,h)}if(C=(j&r.childLanes)!==0,bt||C){if(h=tt,h!==null){switch(j&-j){case 4:p=2;break;case 16:p=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:p=32;break;case 536870912:p=268435456;break;default:p=0}p=(p&(h.suspendedLanes|j))!==0?0:p,p!==0&&p!==v.retryLane&&(v.retryLane=p,jn(r,p),nn(h,r,p,-1))}return Vl(),h=Nl(Error(n(421))),Co(r,a,j,h)}return p.data==="$?"?(a.flags|=128,a.child=r.child,a=Bj.bind(null,r),p._reactRetry=a,null):(r=v.treeContext,Mt=_n(p.nextSibling),Rt=a,Fe=!0,Xt=null,r!==null&&(Pt[Dt++]=yn,Pt[Dt++]=xn,Pt[Dt++]=us,yn=r.id,xn=r.overflow,us=a),a=Il(a,h.children),a.flags|=4096,a)}function Rm(r,a,l){r.lanes|=a;var h=r.alternate;h!==null&&(h.lanes|=a),cl(r.return,a,l)}function Rl(r,a,l,h,p){var v=r.memoizedState;v===null?r.memoizedState={isBackwards:a,rendering:null,renderingStartTime:0,last:h,tail:l,tailMode:p}:(v.isBackwards=a,v.rendering=null,v.renderingStartTime=0,v.last=h,v.tail=l,v.tailMode=p)}function Mm(r,a,l){var h=a.pendingProps,p=h.revealOrder,v=h.tail;if(kt(r,a,h.children,l),h=Ue.current,(h&2)!==0)h=h&1|2,a.flags|=128;else{if(r!==null&&(r.flags&128)!==0)e:for(r=a.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&Rm(r,l,a);else if(r.tag===19)Rm(r,l,a);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===a)break e;for(;r.sibling===null;){if(r.return===null||r.return===a)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}h&=1}if(Le(Ue,h),(a.mode&1)===0)a.memoizedState=null;else switch(p){case"forwards":for(l=a.child,p=null;l!==null;)r=l.alternate,r!==null&&yo(r)===null&&(p=l),l=l.sibling;l=p,l===null?(p=a.child,a.child=null):(p=l.sibling,l.sibling=null),Rl(a,!1,p,l,v);break;case"backwards":for(l=null,p=a.child,a.child=null;p!==null;){if(r=p.alternate,r!==null&&yo(r)===null){a.child=p;break}r=p.sibling,p.sibling=l,l=p,p=r}Rl(a,!0,l,null,v);break;case"together":Rl(a,!1,null,null,void 0);break;default:a.memoizedState=null}return a.child}function To(r,a){(a.mode&1)===0&&r!==null&&(r.alternate=null,a.alternate=null,a.flags|=2)}function Sn(r,a,l){if(r!==null&&(a.dependencies=r.dependencies),gs|=a.lanes,(l&a.childLanes)===0)return null;if(r!==null&&a.child!==r.child)throw Error(n(153));if(a.child!==null){for(r=a.child,l=Qn(r,r.pendingProps),a.child=l,l.return=a;r.sibling!==null;)r=r.sibling,l=l.sibling=Qn(r,r.pendingProps),l.return=a;l.sibling=null}return a.child}function Cj(r,a,l){switch(a.tag){case 3:Em(a),Vs();break;case 5:Vf(a);break;case 1:jt(a.type)&&lo(a);break;case 4:ul(a,a.stateNode.containerInfo);break;case 10:var h=a.type._context,p=a.memoizedProps.value;Le(go,h._currentValue),h._currentValue=p;break;case 13:if(h=a.memoizedState,h!==null)return h.dehydrated!==null?(Le(Ue,Ue.current&1),a.flags|=128,null):(l&a.child.childLanes)!==0?Im(r,a,l):(Le(Ue,Ue.current&1),r=Sn(r,a,l),r!==null?r.sibling:null);Le(Ue,Ue.current&1);break;case 19:if(h=(l&a.childLanes)!==0,(r.flags&128)!==0){if(h)return Mm(r,a,l);a.flags|=128}if(p=a.memoizedState,p!==null&&(p.rendering=null,p.tail=null,p.lastEffect=null),Le(Ue,Ue.current),h)break;return null;case 22:case 23:return a.lanes=0,$m(r,a,l)}return Sn(r,a,l)}var Lm,Ml,Om,Pm;Lm=function(r,a){for(var l=a.child;l!==null;){if(l.tag===5||l.tag===6)r.appendChild(l.stateNode);else if(l.tag!==4&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===a)break;for(;l.sibling===null;){if(l.return===null||l.return===a)return;l=l.return}l.sibling.return=l.return,l=l.sibling}},Ml=function(){},Om=function(r,a,l,h){var p=r.memoizedProps;if(p!==h){r=a.stateNode,ms(dn.current);var v=null;switch(l){case"input":p=cc(r,p),h=cc(r,h),v=[];break;case"select":p=U({},p,{value:void 0}),h=U({},h,{value:void 0}),v=[];break;case"textarea":p=uc(r,p),h=uc(r,h),v=[];break;default:typeof p.onClick!="function"&&typeof h.onClick=="function"&&(r.onclick=oo)}fc(l,h);var j;l=null;for(P in p)if(!h.hasOwnProperty(P)&&p.hasOwnProperty(P)&&p[P]!=null)if(P==="style"){var C=p[P];for(j in C)C.hasOwnProperty(j)&&(l||(l={}),l[j]="")}else P!=="dangerouslySetInnerHTML"&&P!=="children"&&P!=="suppressContentEditableWarning"&&P!=="suppressHydrationWarning"&&P!=="autoFocus"&&(o.hasOwnProperty(P)?v||(v=[]):(v=v||[]).push(P,null));for(P in h){var T=h[P];if(C=p!=null?p[P]:void 0,h.hasOwnProperty(P)&&T!==C&&(T!=null||C!=null))if(P==="style")if(C){for(j in C)!C.hasOwnProperty(j)||T&&T.hasOwnProperty(j)||(l||(l={}),l[j]="");for(j in T)T.hasOwnProperty(j)&&C[j]!==T[j]&&(l||(l={}),l[j]=T[j])}else l||(v||(v=[]),v.push(P,l)),l=T;else P==="dangerouslySetInnerHTML"?(T=T?T.__html:void 0,C=C?C.__html:void 0,T!=null&&C!==T&&(v=v||[]).push(P,T)):P==="children"?typeof T!="string"&&typeof T!="number"||(v=v||[]).push(P,""+T):P!=="suppressContentEditableWarning"&&P!=="suppressHydrationWarning"&&(o.hasOwnProperty(P)?(T!=null&&P==="onScroll"&&De("scroll",r),v||C===T||(v=[])):(v=v||[]).push(P,T))}l&&(v=v||[]).push("style",l);var P=v;(a.updateQueue=P)&&(a.flags|=4)}},Pm=function(r,a,l,h){l!==h&&(a.flags|=4)};function nr(r,a){if(!Fe)switch(r.tailMode){case"hidden":a=r.tail;for(var l=null;a!==null;)a.alternate!==null&&(l=a),a=a.sibling;l===null?r.tail=null:l.sibling=null;break;case"collapsed":l=r.tail;for(var h=null;l!==null;)l.alternate!==null&&(h=l),l=l.sibling;h===null?a||r.tail===null?r.tail=null:r.tail.sibling=null:h.sibling=null}}function dt(r){var a=r.alternate!==null&&r.alternate.child===r.child,l=0,h=0;if(a)for(var p=r.child;p!==null;)l|=p.lanes|p.childLanes,h|=p.subtreeFlags&14680064,h|=p.flags&14680064,p.return=r,p=p.sibling;else for(p=r.child;p!==null;)l|=p.lanes|p.childLanes,h|=p.subtreeFlags,h|=p.flags,p.return=r,p=p.sibling;return r.subtreeFlags|=h,r.childLanes=l,a}function Tj(r,a,l){var h=a.pendingProps;switch(tl(a),a.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return dt(a),null;case 1:return jt(a.type)&&co(),dt(a),null;case 3:return h=a.stateNode,Js(),_e(xt),_e(ct),ml(),h.pendingContext&&(h.context=h.pendingContext,h.pendingContext=null),(r===null||r.child===null)&&(mo(a)?a.flags|=4:r===null||r.memoizedState.isDehydrated&&(a.flags&256)===0||(a.flags|=1024,Xt!==null&&(Hl(Xt),Xt=null))),Ml(r,a),dt(a),null;case 5:hl(a);var p=ms(Ji.current);if(l=a.type,r!==null&&a.stateNode!=null)Om(r,a,l,h,p),r.ref!==a.ref&&(a.flags|=512,a.flags|=2097152);else{if(!h){if(a.stateNode===null)throw Error(n(166));return dt(a),null}if(r=ms(dn.current),mo(a)){h=a.stateNode,l=a.type;var v=a.memoizedProps;switch(h[ln]=a,h[Gi]=v,r=(a.mode&1)!==0,l){case"dialog":De("cancel",h),De("close",h);break;case"iframe":case"object":case"embed":De("load",h);break;case"video":case"audio":for(p=0;p<Wi.length;p++)De(Wi[p],h);break;case"source":De("error",h);break;case"img":case"image":case"link":De("error",h),De("load",h);break;case"details":De("toggle",h);break;case"input":ph(h,v),De("invalid",h);break;case"select":h._wrapperState={wasMultiple:!!v.multiple},De("invalid",h);break;case"textarea":vh(h,v),De("invalid",h)}fc(l,v),p=null;for(var j in v)if(v.hasOwnProperty(j)){var C=v[j];j==="children"?typeof C=="string"?h.textContent!==C&&(v.suppressHydrationWarning!==!0&&ro(h.textContent,C,r),p=["children",C]):typeof C=="number"&&h.textContent!==""+C&&(v.suppressHydrationWarning!==!0&&ro(h.textContent,C,r),p=["children",""+C]):o.hasOwnProperty(j)&&C!=null&&j==="onScroll"&&De("scroll",h)}switch(l){case"input":In(h),kh(h,v,!0);break;case"textarea":In(h),yh(h);break;case"select":case"option":break;default:typeof v.onClick=="function"&&(h.onclick=oo)}h=p,a.updateQueue=h,h!==null&&(a.flags|=4)}else{j=p.nodeType===9?p:p.ownerDocument,r==="http://www.w3.org/1999/xhtml"&&(r=xh(l)),r==="http://www.w3.org/1999/xhtml"?l==="script"?(r=j.createElement("div"),r.innerHTML="<script><\/script>",r=r.removeChild(r.firstChild)):typeof h.is=="string"?r=j.createElement(l,{is:h.is}):(r=j.createElement(l),l==="select"&&(j=r,h.multiple?j.multiple=!0:h.size&&(j.size=h.size))):r=j.createElementNS(r,l),r[ln]=a,r[Gi]=h,Lm(r,a,!1,!1),a.stateNode=r;e:{switch(j=mc(l,h),l){case"dialog":De("cancel",r),De("close",r),p=h;break;case"iframe":case"object":case"embed":De("load",r),p=h;break;case"video":case"audio":for(p=0;p<Wi.length;p++)De(Wi[p],r);p=h;break;case"source":De("error",r),p=h;break;case"img":case"image":case"link":De("error",r),De("load",r),p=h;break;case"details":De("toggle",r),p=h;break;case"input":ph(r,h),p=cc(r,h),De("invalid",r);break;case"option":p=h;break;case"select":r._wrapperState={wasMultiple:!!h.multiple},p=U({},h,{value:void 0}),De("invalid",r);break;case"textarea":vh(r,h),p=uc(r,h),De("invalid",r);break;default:p=h}fc(l,p),C=p;for(v in C)if(C.hasOwnProperty(v)){var T=C[v];v==="style"?Sh(r,T):v==="dangerouslySetInnerHTML"?(T=T?T.__html:void 0,T!=null&&jh(r,T)):v==="children"?typeof T=="string"?(l!=="textarea"||T!=="")&&Si(r,T):typeof T=="number"&&Si(r,""+T):v!=="suppressContentEditableWarning"&&v!=="suppressHydrationWarning"&&v!=="autoFocus"&&(o.hasOwnProperty(v)?T!=null&&v==="onScroll"&&De("scroll",r):T!=null&&D(r,v,T,j))}switch(l){case"input":In(r),kh(r,h,!1);break;case"textarea":In(r),yh(r);break;case"option":h.value!=null&&r.setAttribute("value",""+$e(h.value));break;case"select":r.multiple=!!h.multiple,v=h.value,v!=null?Rs(r,!!h.multiple,v,!1):h.defaultValue!=null&&Rs(r,!!h.multiple,h.defaultValue,!0);break;default:typeof p.onClick=="function"&&(r.onclick=oo)}switch(l){case"button":case"input":case"select":case"textarea":h=!!h.autoFocus;break e;case"img":h=!0;break e;default:h=!1}}h&&(a.flags|=4)}a.ref!==null&&(a.flags|=512,a.flags|=2097152)}return dt(a),null;case 6:if(r&&a.stateNode!=null)Pm(r,a,r.memoizedProps,h);else{if(typeof h!="string"&&a.stateNode===null)throw Error(n(166));if(l=ms(Ji.current),ms(dn.current),mo(a)){if(h=a.stateNode,l=a.memoizedProps,h[ln]=a,(v=h.nodeValue!==l)&&(r=Rt,r!==null))switch(r.tag){case 3:ro(h.nodeValue,l,(r.mode&1)!==0);break;case 5:r.memoizedProps.suppressHydrationWarning!==!0&&ro(h.nodeValue,l,(r.mode&1)!==0)}v&&(a.flags|=4)}else h=(l.nodeType===9?l:l.ownerDocument).createTextNode(h),h[ln]=a,a.stateNode=h}return dt(a),null;case 13:if(_e(Ue),h=a.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(Fe&&Mt!==null&&(a.mode&1)!==0&&(a.flags&128)===0)Bf(),Vs(),a.flags|=98560,v=!1;else if(v=mo(a),h!==null&&h.dehydrated!==null){if(r===null){if(!v)throw Error(n(318));if(v=a.memoizedState,v=v!==null?v.dehydrated:null,!v)throw Error(n(317));v[ln]=a}else Vs(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;dt(a),v=!1}else Xt!==null&&(Hl(Xt),Xt=null),v=!0;if(!v)return a.flags&65536?a:null}return(a.flags&128)!==0?(a.lanes=l,a):(h=h!==null,h!==(r!==null&&r.memoizedState!==null)&&h&&(a.child.flags|=8192,(a.mode&1)!==0&&(r===null||(Ue.current&1)!==0?Ze===0&&(Ze=3):Vl())),a.updateQueue!==null&&(a.flags|=4),dt(a),null);case 4:return Js(),Ml(r,a),r===null&&Hi(a.stateNode.containerInfo),dt(a),null;case 10:return al(a.type._context),dt(a),null;case 17:return jt(a.type)&&co(),dt(a),null;case 19:if(_e(Ue),v=a.memoizedState,v===null)return dt(a),null;if(h=(a.flags&128)!==0,j=v.rendering,j===null)if(h)nr(v,!1);else{if(Ze!==0||r!==null&&(r.flags&128)!==0)for(r=a.child;r!==null;){if(j=yo(r),j!==null){for(a.flags|=128,nr(v,!1),h=j.updateQueue,h!==null&&(a.updateQueue=h,a.flags|=4),a.subtreeFlags=0,h=l,l=a.child;l!==null;)v=l,r=h,v.flags&=14680066,j=v.alternate,j===null?(v.childLanes=0,v.lanes=r,v.child=null,v.subtreeFlags=0,v.memoizedProps=null,v.memoizedState=null,v.updateQueue=null,v.dependencies=null,v.stateNode=null):(v.childLanes=j.childLanes,v.lanes=j.lanes,v.child=j.child,v.subtreeFlags=0,v.deletions=null,v.memoizedProps=j.memoizedProps,v.memoizedState=j.memoizedState,v.updateQueue=j.updateQueue,v.type=j.type,r=j.dependencies,v.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),l=l.sibling;return Le(Ue,Ue.current&1|2),a.child}r=r.sibling}v.tail!==null&&qe()>ti&&(a.flags|=128,h=!0,nr(v,!1),a.lanes=4194304)}else{if(!h)if(r=yo(j),r!==null){if(a.flags|=128,h=!0,l=r.updateQueue,l!==null&&(a.updateQueue=l,a.flags|=4),nr(v,!0),v.tail===null&&v.tailMode==="hidden"&&!j.alternate&&!Fe)return dt(a),null}else 2*qe()-v.renderingStartTime>ti&&l!==1073741824&&(a.flags|=128,h=!0,nr(v,!1),a.lanes=4194304);v.isBackwards?(j.sibling=a.child,a.child=j):(l=v.last,l!==null?l.sibling=j:a.child=j,v.last=j)}return v.tail!==null?(a=v.tail,v.rendering=a,v.tail=a.sibling,v.renderingStartTime=qe(),a.sibling=null,l=Ue.current,Le(Ue,h?l&1|2:l&1),a):(dt(a),null);case 22:case 23:return Gl(),h=a.memoizedState!==null,r!==null&&r.memoizedState!==null!==h&&(a.flags|=8192),h&&(a.mode&1)!==0?(Lt&1073741824)!==0&&(dt(a),a.subtreeFlags&6&&(a.flags|=8192)):dt(a),null;case 24:return null;case 25:return null}throw Error(n(156,a.tag))}function Ej(r,a){switch(tl(a),a.tag){case 1:return jt(a.type)&&co(),r=a.flags,r&65536?(a.flags=r&-65537|128,a):null;case 3:return Js(),_e(xt),_e(ct),ml(),r=a.flags,(r&65536)!==0&&(r&128)===0?(a.flags=r&-65537|128,a):null;case 5:return hl(a),null;case 13:if(_e(Ue),r=a.memoizedState,r!==null&&r.dehydrated!==null){if(a.alternate===null)throw Error(n(340));Vs()}return r=a.flags,r&65536?(a.flags=r&-65537|128,a):null;case 19:return _e(Ue),null;case 4:return Js(),null;case 10:return al(a.type._context),null;case 22:case 23:return Gl(),null;case 24:return null;default:return null}}var Eo=!1,ut=!1,Aj=typeof WeakSet=="function"?WeakSet:Set,te=null;function Zs(r,a){var l=r.ref;if(l!==null)if(typeof l=="function")try{l(null)}catch(h){Ve(r,a,h)}else l.current=null}function Ll(r,a,l){try{l()}catch(h){Ve(r,a,h)}}var Dm=!1;function Ij(r,a){if(Gc=qr,r=pf(),_c(r)){if("selectionStart"in r)var l={start:r.selectionStart,end:r.selectionEnd};else e:{l=(l=r.ownerDocument)&&l.defaultView||window;var h=l.getSelection&&l.getSelection();if(h&&h.rangeCount!==0){l=h.anchorNode;var p=h.anchorOffset,v=h.focusNode;h=h.focusOffset;try{l.nodeType,v.nodeType}catch{l=null;break e}var j=0,C=-1,T=-1,P=0,H=0,G=r,W=null;t:for(;;){for(var X;G!==l||p!==0&&G.nodeType!==3||(C=j+p),G!==v||h!==0&&G.nodeType!==3||(T=j+h),G.nodeType===3&&(j+=G.nodeValue.length),(X=G.firstChild)!==null;)W=G,G=X;for(;;){if(G===r)break t;if(W===l&&++P===p&&(C=j),W===v&&++H===h&&(T=j),(X=G.nextSibling)!==null)break;G=W,W=G.parentNode}G=X}l=C===-1||T===-1?null:{start:C,end:T}}else l=null}l=l||{start:0,end:0}}else l=null;for(Vc={focusedElem:r,selectionRange:l},qr=!1,te=a;te!==null;)if(a=te,r=a.child,(a.subtreeFlags&1028)!==0&&r!==null)r.return=a,te=r;else for(;te!==null;){a=te;try{var ne=a.alternate;if((a.flags&1024)!==0)switch(a.tag){case 0:case 11:case 15:break;case 1:if(ne!==null){var se=ne.memoizedProps,Qe=ne.memoizedState,M=a.stateNode,A=M.getSnapshotBeforeUpdate(a.elementType===a.type?se:Zt(a.type,se),Qe);M.__reactInternalSnapshotBeforeUpdate=A}break;case 3:var L=a.stateNode.containerInfo;L.nodeType===1?L.textContent="":L.nodeType===9&&L.documentElement&&L.removeChild(L.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(V){Ve(a,a.return,V)}if(r=a.sibling,r!==null){r.return=a.return,te=r;break}te=a.return}return ne=Dm,Dm=!1,ne}function sr(r,a,l){var h=a.updateQueue;if(h=h!==null?h.lastEffect:null,h!==null){var p=h=h.next;do{if((p.tag&r)===r){var v=p.destroy;p.destroy=void 0,v!==void 0&&Ll(a,l,v)}p=p.next}while(p!==h)}}function Ao(r,a){if(a=a.updateQueue,a=a!==null?a.lastEffect:null,a!==null){var l=a=a.next;do{if((l.tag&r)===r){var h=l.create;l.destroy=h()}l=l.next}while(l!==a)}}function Ol(r){var a=r.ref;if(a!==null){var l=r.stateNode;switch(r.tag){case 5:r=l;break;default:r=l}typeof a=="function"?a(r):a.current=r}}function _m(r){var a=r.alternate;a!==null&&(r.alternate=null,_m(a)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(a=r.stateNode,a!==null&&(delete a[ln],delete a[Gi],delete a[Jc],delete a[fj],delete a[mj])),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}function Bm(r){return r.tag===5||r.tag===3||r.tag===4}function Fm(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||Bm(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function Pl(r,a,l){var h=r.tag;if(h===5||h===6)r=r.stateNode,a?l.nodeType===8?l.parentNode.insertBefore(r,a):l.insertBefore(r,a):(l.nodeType===8?(a=l.parentNode,a.insertBefore(r,l)):(a=l,a.appendChild(r)),l=l._reactRootContainer,l!=null||a.onclick!==null||(a.onclick=oo));else if(h!==4&&(r=r.child,r!==null))for(Pl(r,a,l),r=r.sibling;r!==null;)Pl(r,a,l),r=r.sibling}function Dl(r,a,l){var h=r.tag;if(h===5||h===6)r=r.stateNode,a?l.insertBefore(r,a):l.appendChild(r);else if(h!==4&&(r=r.child,r!==null))for(Dl(r,a,l),r=r.sibling;r!==null;)Dl(r,a,l),r=r.sibling}var rt=null,en=!1;function Hn(r,a,l){for(l=l.child;l!==null;)zm(r,a,l),l=l.sibling}function zm(r,a,l){if(cn&&typeof cn.onCommitFiberUnmount=="function")try{cn.onCommitFiberUnmount(Ur,l)}catch{}switch(l.tag){case 5:ut||Zs(l,a);case 6:var h=rt,p=en;rt=null,Hn(r,a,l),rt=h,en=p,rt!==null&&(en?(r=rt,l=l.stateNode,r.nodeType===8?r.parentNode.removeChild(l):r.removeChild(l)):rt.removeChild(l.stateNode));break;case 18:rt!==null&&(en?(r=rt,l=l.stateNode,r.nodeType===8?Yc(r.parentNode,l):r.nodeType===1&&Yc(r,l),Oi(r)):Yc(rt,l.stateNode));break;case 4:h=rt,p=en,rt=l.stateNode.containerInfo,en=!0,Hn(r,a,l),rt=h,en=p;break;case 0:case 11:case 14:case 15:if(!ut&&(h=l.updateQueue,h!==null&&(h=h.lastEffect,h!==null))){p=h=h.next;do{var v=p,j=v.destroy;v=v.tag,j!==void 0&&((v&2)!==0||(v&4)!==0)&&Ll(l,a,j),p=p.next}while(p!==h)}Hn(r,a,l);break;case 1:if(!ut&&(Zs(l,a),h=l.stateNode,typeof h.componentWillUnmount=="function"))try{h.props=l.memoizedProps,h.state=l.memoizedState,h.componentWillUnmount()}catch(C){Ve(l,a,C)}Hn(r,a,l);break;case 21:Hn(r,a,l);break;case 22:l.mode&1?(ut=(h=ut)||l.memoizedState!==null,Hn(r,a,l),ut=h):Hn(r,a,l);break;default:Hn(r,a,l)}}function Um(r){var a=r.updateQueue;if(a!==null){r.updateQueue=null;var l=r.stateNode;l===null&&(l=r.stateNode=new Aj),a.forEach(function(h){var p=Fj.bind(null,r,h);l.has(h)||(l.add(h),h.then(p,p))})}}function tn(r,a){var l=a.deletions;if(l!==null)for(var h=0;h<l.length;h++){var p=l[h];try{var v=r,j=a,C=j;e:for(;C!==null;){switch(C.tag){case 5:rt=C.stateNode,en=!1;break e;case 3:rt=C.stateNode.containerInfo,en=!0;break e;case 4:rt=C.stateNode.containerInfo,en=!0;break e}C=C.return}if(rt===null)throw Error(n(160));zm(v,j,p),rt=null,en=!1;var T=p.alternate;T!==null&&(T.return=null),p.return=null}catch(P){Ve(p,a,P)}}if(a.subtreeFlags&12854)for(a=a.child;a!==null;)Wm(a,r),a=a.sibling}function Wm(r,a){var l=r.alternate,h=r.flags;switch(r.tag){case 0:case 11:case 14:case 15:if(tn(a,r),hn(r),h&4){try{sr(3,r,r.return),Ao(3,r)}catch(se){Ve(r,r.return,se)}try{sr(5,r,r.return)}catch(se){Ve(r,r.return,se)}}break;case 1:tn(a,r),hn(r),h&512&&l!==null&&Zs(l,l.return);break;case 5:if(tn(a,r),hn(r),h&512&&l!==null&&Zs(l,l.return),r.flags&32){var p=r.stateNode;try{Si(p,"")}catch(se){Ve(r,r.return,se)}}if(h&4&&(p=r.stateNode,p!=null)){var v=r.memoizedProps,j=l!==null?l.memoizedProps:v,C=r.type,T=r.updateQueue;if(r.updateQueue=null,T!==null)try{C==="input"&&v.type==="radio"&&v.name!=null&&gh(p,v),mc(C,j);var P=mc(C,v);for(j=0;j<T.length;j+=2){var H=T[j],G=T[j+1];H==="style"?Sh(p,G):H==="dangerouslySetInnerHTML"?jh(p,G):H==="children"?Si(p,G):D(p,H,G,P)}switch(C){case"input":lc(p,v);break;case"textarea":wh(p,v);break;case"select":var W=p._wrapperState.wasMultiple;p._wrapperState.wasMultiple=!!v.multiple;var X=v.value;X!=null?Rs(p,!!v.multiple,X,!1):W!==!!v.multiple&&(v.defaultValue!=null?Rs(p,!!v.multiple,v.defaultValue,!0):Rs(p,!!v.multiple,v.multiple?[]:"",!1))}p[Gi]=v}catch(se){Ve(r,r.return,se)}}break;case 6:if(tn(a,r),hn(r),h&4){if(r.stateNode===null)throw Error(n(162));p=r.stateNode,v=r.memoizedProps;try{p.nodeValue=v}catch(se){Ve(r,r.return,se)}}break;case 3:if(tn(a,r),hn(r),h&4&&l!==null&&l.memoizedState.isDehydrated)try{Oi(a.containerInfo)}catch(se){Ve(r,r.return,se)}break;case 4:tn(a,r),hn(r);break;case 13:tn(a,r),hn(r),p=r.child,p.flags&8192&&(v=p.memoizedState!==null,p.stateNode.isHidden=v,!v||p.alternate!==null&&p.alternate.memoizedState!==null||(Fl=qe())),h&4&&Um(r);break;case 22:if(H=l!==null&&l.memoizedState!==null,r.mode&1?(ut=(P=ut)||H,tn(a,r),ut=P):tn(a,r),hn(r),h&8192){if(P=r.memoizedState!==null,(r.stateNode.isHidden=P)&&!H&&(r.mode&1)!==0)for(te=r,H=r.child;H!==null;){for(G=te=H;te!==null;){switch(W=te,X=W.child,W.tag){case 0:case 11:case 14:case 15:sr(4,W,W.return);break;case 1:Zs(W,W.return);var ne=W.stateNode;if(typeof ne.componentWillUnmount=="function"){h=W,l=W.return;try{a=h,ne.props=a.memoizedProps,ne.state=a.memoizedState,ne.componentWillUnmount()}catch(se){Ve(h,l,se)}}break;case 5:Zs(W,W.return);break;case 22:if(W.memoizedState!==null){Gm(G);continue}}X!==null?(X.return=W,te=X):Gm(G)}H=H.sibling}e:for(H=null,G=r;;){if(G.tag===5){if(H===null){H=G;try{p=G.stateNode,P?(v=p.style,typeof v.setProperty=="function"?v.setProperty("display","none","important"):v.display="none"):(C=G.stateNode,T=G.memoizedProps.style,j=T!=null&&T.hasOwnProperty("display")?T.display:null,C.style.display=bh("display",j))}catch(se){Ve(r,r.return,se)}}}else if(G.tag===6){if(H===null)try{G.stateNode.nodeValue=P?"":G.memoizedProps}catch(se){Ve(r,r.return,se)}}else if((G.tag!==22&&G.tag!==23||G.memoizedState===null||G===r)&&G.child!==null){G.child.return=G,G=G.child;continue}if(G===r)break e;for(;G.sibling===null;){if(G.return===null||G.return===r)break e;H===G&&(H=null),G=G.return}H===G&&(H=null),G.sibling.return=G.return,G=G.sibling}}break;case 19:tn(a,r),hn(r),h&4&&Um(r);break;case 21:break;default:tn(a,r),hn(r)}}function hn(r){var a=r.flags;if(a&2){try{e:{for(var l=r.return;l!==null;){if(Bm(l)){var h=l;break e}l=l.return}throw Error(n(160))}switch(h.tag){case 5:var p=h.stateNode;h.flags&32&&(Si(p,""),h.flags&=-33);var v=Fm(r);Dl(r,v,p);break;case 3:case 4:var j=h.stateNode.containerInfo,C=Fm(r);Pl(r,C,j);break;default:throw Error(n(161))}}catch(T){Ve(r,r.return,T)}r.flags&=-3}a&4096&&(r.flags&=-4097)}function Rj(r,a,l){te=r,Hm(r)}function Hm(r,a,l){for(var h=(r.mode&1)!==0;te!==null;){var p=te,v=p.child;if(p.tag===22&&h){var j=p.memoizedState!==null||Eo;if(!j){var C=p.alternate,T=C!==null&&C.memoizedState!==null||ut;C=Eo;var P=ut;if(Eo=j,(ut=T)&&!P)for(te=p;te!==null;)j=te,T=j.child,j.tag===22&&j.memoizedState!==null?Vm(p):T!==null?(T.return=j,te=T):Vm(p);for(;v!==null;)te=v,Hm(v),v=v.sibling;te=p,Eo=C,ut=P}Km(r)}else(p.subtreeFlags&8772)!==0&&v!==null?(v.return=p,te=v):Km(r)}}function Km(r){for(;te!==null;){var a=te;if((a.flags&8772)!==0){var l=a.alternate;try{if((a.flags&8772)!==0)switch(a.tag){case 0:case 11:case 15:ut||Ao(5,a);break;case 1:var h=a.stateNode;if(a.flags&4&&!ut)if(l===null)h.componentDidMount();else{var p=a.elementType===a.type?l.memoizedProps:Zt(a.type,l.memoizedProps);h.componentDidUpdate(p,l.memoizedState,h.__reactInternalSnapshotBeforeUpdate)}var v=a.updateQueue;v!==null&&Gf(a,v,h);break;case 3:var j=a.updateQueue;if(j!==null){if(l=null,a.child!==null)switch(a.child.tag){case 5:l=a.child.stateNode;break;case 1:l=a.child.stateNode}Gf(a,j,l)}break;case 5:var C=a.stateNode;if(l===null&&a.flags&4){l=C;var T=a.memoizedProps;switch(a.type){case"button":case"input":case"select":case"textarea":T.autoFocus&&l.focus();break;case"img":T.src&&(l.src=T.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(a.memoizedState===null){var P=a.alternate;if(P!==null){var H=P.memoizedState;if(H!==null){var G=H.dehydrated;G!==null&&Oi(G)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}ut||a.flags&512&&Ol(a)}catch(W){Ve(a,a.return,W)}}if(a===r){te=null;break}if(l=a.sibling,l!==null){l.return=a.return,te=l;break}te=a.return}}function Gm(r){for(;te!==null;){var a=te;if(a===r){te=null;break}var l=a.sibling;if(l!==null){l.return=a.return,te=l;break}te=a.return}}function Vm(r){for(;te!==null;){var a=te;try{switch(a.tag){case 0:case 11:case 15:var l=a.return;try{Ao(4,a)}catch(T){Ve(a,l,T)}break;case 1:var h=a.stateNode;if(typeof h.componentDidMount=="function"){var p=a.return;try{h.componentDidMount()}catch(T){Ve(a,p,T)}}var v=a.return;try{Ol(a)}catch(T){Ve(a,v,T)}break;case 5:var j=a.return;try{Ol(a)}catch(T){Ve(a,j,T)}}}catch(T){Ve(a,a.return,T)}if(a===r){te=null;break}var C=a.sibling;if(C!==null){C.return=a.return,te=C;break}te=a.return}}var Mj=Math.ceil,Io=F.ReactCurrentDispatcher,_l=F.ReactCurrentOwner,Ft=F.ReactCurrentBatchConfig,Ce=0,tt=null,Ye=null,ot=0,Lt=0,ei=Bn(0),Ze=0,ir=null,gs=0,Ro=0,Bl=0,rr=null,St=null,Fl=0,ti=1/0,Nn=null,Mo=!1,zl=null,Kn=null,Lo=!1,Gn=null,Oo=0,or=0,Ul=null,Po=-1,Do=0;function vt(){return(Ce&6)!==0?qe():Po!==-1?Po:Po=qe()}function Vn(r){return(r.mode&1)===0?1:(Ce&2)!==0&&ot!==0?ot&-ot:gj.transition!==null?(Do===0&&(Do=Bh()),Do):(r=Re,r!==0||(r=window.event,r=r===void 0?16:qh(r.type)),r)}function nn(r,a,l,h){if(50<or)throw or=0,Ul=null,Error(n(185));Ai(r,l,h),((Ce&2)===0||r!==tt)&&(r===tt&&((Ce&2)===0&&(Ro|=l),Ze===4&&qn(r,ot)),Nt(r,h),l===1&&Ce===0&&(a.mode&1)===0&&(ti=qe()+500,uo&&zn()))}function Nt(r,a){var l=r.callbackNode;gx(r,a);var h=Kr(r,r===tt?ot:0);if(h===0)l!==null&&Ph(l),r.callbackNode=null,r.callbackPriority=0;else if(a=h&-h,r.callbackPriority!==a){if(l!=null&&Ph(l),a===1)r.tag===0?pj(Qm.bind(null,r)):Lf(Qm.bind(null,r)),uj(function(){(Ce&6)===0&&zn()}),l=null;else{switch(Fh(h)){case 1:l=xc;break;case 4:l=Dh;break;case 16:l=zr;break;case 536870912:l=_h;break;default:l=zr}l=sp(l,qm.bind(null,r))}r.callbackPriority=a,r.callbackNode=l}}function qm(r,a){if(Po=-1,Do=0,(Ce&6)!==0)throw Error(n(327));var l=r.callbackNode;if(ni()&&r.callbackNode!==l)return null;var h=Kr(r,r===tt?ot:0);if(h===0)return null;if((h&30)!==0||(h&r.expiredLanes)!==0||a)a=_o(r,h);else{a=h;var p=Ce;Ce|=2;var v=Jm();(tt!==r||ot!==a)&&(Nn=null,ti=qe()+500,vs(r,a));do try{Pj();break}catch(C){Ym(r,C)}while(!0);ol(),Io.current=v,Ce=p,Ye!==null?a=0:(tt=null,ot=0,a=Ze)}if(a!==0){if(a===2&&(p=jc(r),p!==0&&(h=p,a=Wl(r,p))),a===1)throw l=ir,vs(r,0),qn(r,h),Nt(r,qe()),l;if(a===6)qn(r,h);else{if(p=r.current.alternate,(h&30)===0&&!Lj(p)&&(a=_o(r,h),a===2&&(v=jc(r),v!==0&&(h=v,a=Wl(r,v))),a===1))throw l=ir,vs(r,0),qn(r,h),Nt(r,qe()),l;switch(r.finishedWork=p,r.finishedLanes=h,a){case 0:case 1:throw Error(n(345));case 2:ws(r,St,Nn);break;case 3:if(qn(r,h),(h&130023424)===h&&(a=Fl+500-qe(),10<a)){if(Kr(r,0)!==0)break;if(p=r.suspendedLanes,(p&h)!==h){vt(),r.pingedLanes|=r.suspendedLanes&p;break}r.timeoutHandle=Qc(ws.bind(null,r,St,Nn),a);break}ws(r,St,Nn);break;case 4:if(qn(r,h),(h&4194240)===h)break;for(a=r.eventTimes,p=-1;0<h;){var j=31-Yt(h);v=1<<j,j=a[j],j>p&&(p=j),h&=~v}if(h=p,h=qe()-h,h=(120>h?120:480>h?480:1080>h?1080:1920>h?1920:3e3>h?3e3:4320>h?4320:1960*Mj(h/1960))-h,10<h){r.timeoutHandle=Qc(ws.bind(null,r,St,Nn),h);break}ws(r,St,Nn);break;case 5:ws(r,St,Nn);break;default:throw Error(n(329))}}}return Nt(r,qe()),r.callbackNode===l?qm.bind(null,r):null}function Wl(r,a){var l=rr;return r.current.memoizedState.isDehydrated&&(vs(r,a).flags|=256),r=_o(r,a),r!==2&&(a=St,St=l,a!==null&&Hl(a)),r}function Hl(r){St===null?St=r:St.push.apply(St,r)}function Lj(r){for(var a=r;;){if(a.flags&16384){var l=a.updateQueue;if(l!==null&&(l=l.stores,l!==null))for(var h=0;h<l.length;h++){var p=l[h],v=p.getSnapshot;p=p.value;try{if(!Jt(v(),p))return!1}catch{return!1}}}if(l=a.child,a.subtreeFlags&16384&&l!==null)l.return=a,a=l;else{if(a===r)break;for(;a.sibling===null;){if(a.return===null||a.return===r)return!0;a=a.return}a.sibling.return=a.return,a=a.sibling}}return!0}function qn(r,a){for(a&=~Bl,a&=~Ro,r.suspendedLanes|=a,r.pingedLanes&=~a,r=r.expirationTimes;0<a;){var l=31-Yt(a),h=1<<l;r[l]=-1,a&=~h}}function Qm(r){if((Ce&6)!==0)throw Error(n(327));ni();var a=Kr(r,0);if((a&1)===0)return Nt(r,qe()),null;var l=_o(r,a);if(r.tag!==0&&l===2){var h=jc(r);h!==0&&(a=h,l=Wl(r,h))}if(l===1)throw l=ir,vs(r,0),qn(r,a),Nt(r,qe()),l;if(l===6)throw Error(n(345));return r.finishedWork=r.current.alternate,r.finishedLanes=a,ws(r,St,Nn),Nt(r,qe()),null}function Kl(r,a){var l=Ce;Ce|=1;try{return r(a)}finally{Ce=l,Ce===0&&(ti=qe()+500,uo&&zn())}}function ks(r){Gn!==null&&Gn.tag===0&&(Ce&6)===0&&ni();var a=Ce;Ce|=1;var l=Ft.transition,h=Re;try{if(Ft.transition=null,Re=1,r)return r()}finally{Re=h,Ft.transition=l,Ce=a,(Ce&6)===0&&zn()}}function Gl(){Lt=ei.current,_e(ei)}function vs(r,a){r.finishedWork=null,r.finishedLanes=0;var l=r.timeoutHandle;if(l!==-1&&(r.timeoutHandle=-1,dj(l)),Ye!==null)for(l=Ye.return;l!==null;){var h=l;switch(tl(h),h.tag){case 1:h=h.type.childContextTypes,h!=null&&co();break;case 3:Js(),_e(xt),_e(ct),ml();break;case 5:hl(h);break;case 4:Js();break;case 13:_e(Ue);break;case 19:_e(Ue);break;case 10:al(h.type._context);break;case 22:case 23:Gl()}l=l.return}if(tt=r,Ye=r=Qn(r.current,null),ot=Lt=a,Ze=0,ir=null,Bl=Ro=gs=0,St=rr=null,fs!==null){for(a=0;a<fs.length;a++)if(l=fs[a],h=l.interleaved,h!==null){l.interleaved=null;var p=h.next,v=l.pending;if(v!==null){var j=v.next;v.next=p,h.next=j}l.pending=h}fs=null}return r}function Ym(r,a){do{var l=Ye;try{if(ol(),xo.current=No,jo){for(var h=We.memoizedState;h!==null;){var p=h.queue;p!==null&&(p.pending=null),h=h.next}jo=!1}if(ps=0,et=Xe=We=null,Xi=!1,Zi=0,_l.current=null,l===null||l.return===null){Ze=1,ir=a,Ye=null;break}e:{var v=r,j=l.return,C=l,T=a;if(a=ot,C.flags|=32768,T!==null&&typeof T=="object"&&typeof T.then=="function"){var P=T,H=C,G=H.tag;if((H.mode&1)===0&&(G===0||G===11||G===15)){var W=H.alternate;W?(H.updateQueue=W.updateQueue,H.memoizedState=W.memoizedState,H.lanes=W.lanes):(H.updateQueue=null,H.memoizedState=null)}var X=xm(j);if(X!==null){X.flags&=-257,jm(X,j,C,v,a),X.mode&1&&ym(v,P,a),a=X,T=P;var ne=a.updateQueue;if(ne===null){var se=new Set;se.add(T),a.updateQueue=se}else ne.add(T);break e}else{if((a&1)===0){ym(v,P,a),Vl();break e}T=Error(n(426))}}else if(Fe&&C.mode&1){var Qe=xm(j);if(Qe!==null){(Qe.flags&65536)===0&&(Qe.flags|=256),jm(Qe,j,C,v,a),il(Xs(T,C));break e}}v=T=Xs(T,C),Ze!==4&&(Ze=2),rr===null?rr=[v]:rr.push(v),v=j;do{switch(v.tag){case 3:v.flags|=65536,a&=-a,v.lanes|=a;var M=vm(v,T,a);Kf(v,M);break e;case 1:C=T;var A=v.type,L=v.stateNode;if((v.flags&128)===0&&(typeof A.getDerivedStateFromError=="function"||L!==null&&typeof L.componentDidCatch=="function"&&(Kn===null||!Kn.has(L)))){v.flags|=65536,a&=-a,v.lanes|=a;var V=wm(v,C,a);Kf(v,V);break e}}v=v.return}while(v!==null)}Zm(l)}catch(ie){a=ie,Ye===l&&l!==null&&(Ye=l=l.return);continue}break}while(!0)}function Jm(){var r=Io.current;return Io.current=No,r===null?No:r}function Vl(){(Ze===0||Ze===3||Ze===2)&&(Ze=4),tt===null||(gs&268435455)===0&&(Ro&268435455)===0||qn(tt,ot)}function _o(r,a){var l=Ce;Ce|=2;var h=Jm();(tt!==r||ot!==a)&&(Nn=null,vs(r,a));do try{Oj();break}catch(p){Ym(r,p)}while(!0);if(ol(),Ce=l,Io.current=h,Ye!==null)throw Error(n(261));return tt=null,ot=0,Ze}function Oj(){for(;Ye!==null;)Xm(Ye)}function Pj(){for(;Ye!==null&&!ax();)Xm(Ye)}function Xm(r){var a=np(r.alternate,r,Lt);r.memoizedProps=r.pendingProps,a===null?Zm(r):Ye=a,_l.current=null}function Zm(r){var a=r;do{var l=a.alternate;if(r=a.return,(a.flags&32768)===0){if(l=Tj(l,a,Lt),l!==null){Ye=l;return}}else{if(l=Ej(l,a),l!==null){l.flags&=32767,Ye=l;return}if(r!==null)r.flags|=32768,r.subtreeFlags=0,r.deletions=null;else{Ze=6,Ye=null;return}}if(a=a.sibling,a!==null){Ye=a;return}Ye=a=r}while(a!==null);Ze===0&&(Ze=5)}function ws(r,a,l){var h=Re,p=Ft.transition;try{Ft.transition=null,Re=1,Dj(r,a,l,h)}finally{Ft.transition=p,Re=h}return null}function Dj(r,a,l,h){do ni();while(Gn!==null);if((Ce&6)!==0)throw Error(n(327));l=r.finishedWork;var p=r.finishedLanes;if(l===null)return null;if(r.finishedWork=null,r.finishedLanes=0,l===r.current)throw Error(n(177));r.callbackNode=null,r.callbackPriority=0;var v=l.lanes|l.childLanes;if(kx(r,v),r===tt&&(Ye=tt=null,ot=0),(l.subtreeFlags&2064)===0&&(l.flags&2064)===0||Lo||(Lo=!0,sp(zr,function(){return ni(),null})),v=(l.flags&15990)!==0,(l.subtreeFlags&15990)!==0||v){v=Ft.transition,Ft.transition=null;var j=Re;Re=1;var C=Ce;Ce|=4,_l.current=null,Ij(r,l),Wm(l,r),sj(Vc),qr=!!Gc,Vc=Gc=null,r.current=l,Rj(l),cx(),Ce=C,Re=j,Ft.transition=v}else r.current=l;if(Lo&&(Lo=!1,Gn=r,Oo=p),v=r.pendingLanes,v===0&&(Kn=null),ux(l.stateNode),Nt(r,qe()),a!==null)for(h=r.onRecoverableError,l=0;l<a.length;l++)p=a[l],h(p.value,{componentStack:p.stack,digest:p.digest});if(Mo)throw Mo=!1,r=zl,zl=null,r;return(Oo&1)!==0&&r.tag!==0&&ni(),v=r.pendingLanes,(v&1)!==0?r===Ul?or++:(or=0,Ul=r):or=0,zn(),null}function ni(){if(Gn!==null){var r=Fh(Oo),a=Ft.transition,l=Re;try{if(Ft.transition=null,Re=16>r?16:r,Gn===null)var h=!1;else{if(r=Gn,Gn=null,Oo=0,(Ce&6)!==0)throw Error(n(331));var p=Ce;for(Ce|=4,te=r.current;te!==null;){var v=te,j=v.child;if((te.flags&16)!==0){var C=v.deletions;if(C!==null){for(var T=0;T<C.length;T++){var P=C[T];for(te=P;te!==null;){var H=te;switch(H.tag){case 0:case 11:case 15:sr(8,H,v)}var G=H.child;if(G!==null)G.return=H,te=G;else for(;te!==null;){H=te;var W=H.sibling,X=H.return;if(_m(H),H===P){te=null;break}if(W!==null){W.return=X,te=W;break}te=X}}}var ne=v.alternate;if(ne!==null){var se=ne.child;if(se!==null){ne.child=null;do{var Qe=se.sibling;se.sibling=null,se=Qe}while(se!==null)}}te=v}}if((v.subtreeFlags&2064)!==0&&j!==null)j.return=v,te=j;else e:for(;te!==null;){if(v=te,(v.flags&2048)!==0)switch(v.tag){case 0:case 11:case 15:sr(9,v,v.return)}var M=v.sibling;if(M!==null){M.return=v.return,te=M;break e}te=v.return}}var A=r.current;for(te=A;te!==null;){j=te;var L=j.child;if((j.subtreeFlags&2064)!==0&&L!==null)L.return=j,te=L;else e:for(j=A;te!==null;){if(C=te,(C.flags&2048)!==0)try{switch(C.tag){case 0:case 11:case 15:Ao(9,C)}}catch(ie){Ve(C,C.return,ie)}if(C===j){te=null;break e}var V=C.sibling;if(V!==null){V.return=C.return,te=V;break e}te=C.return}}if(Ce=p,zn(),cn&&typeof cn.onPostCommitFiberRoot=="function")try{cn.onPostCommitFiberRoot(Ur,r)}catch{}h=!0}return h}finally{Re=l,Ft.transition=a}}return!1}function ep(r,a,l){a=Xs(l,a),a=vm(r,a,1),r=Wn(r,a,1),a=vt(),r!==null&&(Ai(r,1,a),Nt(r,a))}function Ve(r,a,l){if(r.tag===3)ep(r,r,l);else for(;a!==null;){if(a.tag===3){ep(a,r,l);break}else if(a.tag===1){var h=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof h.componentDidCatch=="function"&&(Kn===null||!Kn.has(h))){r=Xs(l,r),r=wm(a,r,1),a=Wn(a,r,1),r=vt(),a!==null&&(Ai(a,1,r),Nt(a,r));break}}a=a.return}}function _j(r,a,l){var h=r.pingCache;h!==null&&h.delete(a),a=vt(),r.pingedLanes|=r.suspendedLanes&l,tt===r&&(ot&l)===l&&(Ze===4||Ze===3&&(ot&130023424)===ot&&500>qe()-Fl?vs(r,0):Bl|=l),Nt(r,a)}function tp(r,a){a===0&&((r.mode&1)===0?a=1:(a=Hr,Hr<<=1,(Hr&130023424)===0&&(Hr=4194304)));var l=vt();r=jn(r,a),r!==null&&(Ai(r,a,l),Nt(r,l))}function Bj(r){var a=r.memoizedState,l=0;a!==null&&(l=a.retryLane),tp(r,l)}function Fj(r,a){var l=0;switch(r.tag){case 13:var h=r.stateNode,p=r.memoizedState;p!==null&&(l=p.retryLane);break;case 19:h=r.stateNode;break;default:throw Error(n(314))}h!==null&&h.delete(a),tp(r,l)}var np;np=function(r,a,l){if(r!==null)if(r.memoizedProps!==a.pendingProps||xt.current)bt=!0;else{if((r.lanes&l)===0&&(a.flags&128)===0)return bt=!1,Cj(r,a,l);bt=(r.flags&131072)!==0}else bt=!1,Fe&&(a.flags&1048576)!==0&&Of(a,fo,a.index);switch(a.lanes=0,a.tag){case 2:var h=a.type;To(r,a),r=a.pendingProps;var p=Hs(a,ct.current);Ys(a,l),p=kl(null,a,h,r,p,l);var v=vl();return a.flags|=1,typeof p=="object"&&p!==null&&typeof p.render=="function"&&p.$$typeof===void 0?(a.tag=1,a.memoizedState=null,a.updateQueue=null,jt(h)?(v=!0,lo(a)):v=!1,a.memoizedState=p.state!==null&&p.state!==void 0?p.state:null,dl(a),p.updater=$o,a.stateNode=p,p._reactInternals=a,Sl(a,h,r,l),a=Tl(null,a,h,!0,v,l)):(a.tag=0,Fe&&v&&el(a),kt(null,a,p,l),a=a.child),a;case 16:h=a.elementType;e:{switch(To(r,a),r=a.pendingProps,p=h._init,h=p(h._payload),a.type=h,p=a.tag=Uj(h),r=Zt(h,r),p){case 0:a=Cl(null,a,h,r,l);break e;case 1:a=Tm(null,a,h,r,l);break e;case 11:a=bm(null,a,h,r,l);break e;case 14:a=Sm(null,a,h,Zt(h.type,r),l);break e}throw Error(n(306,h,""))}return a;case 0:return h=a.type,p=a.pendingProps,p=a.elementType===h?p:Zt(h,p),Cl(r,a,h,p,l);case 1:return h=a.type,p=a.pendingProps,p=a.elementType===h?p:Zt(h,p),Tm(r,a,h,p,l);case 3:e:{if(Em(a),r===null)throw Error(n(387));h=a.pendingProps,v=a.memoizedState,p=v.element,Hf(r,a),wo(a,h,null,l);var j=a.memoizedState;if(h=j.element,v.isDehydrated)if(v={element:h,isDehydrated:!1,cache:j.cache,pendingSuspenseBoundaries:j.pendingSuspenseBoundaries,transitions:j.transitions},a.updateQueue.baseState=v,a.memoizedState=v,a.flags&256){p=Xs(Error(n(423)),a),a=Am(r,a,h,l,p);break e}else if(h!==p){p=Xs(Error(n(424)),a),a=Am(r,a,h,l,p);break e}else for(Mt=_n(a.stateNode.containerInfo.firstChild),Rt=a,Fe=!0,Xt=null,l=Uf(a,null,h,l),a.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(Vs(),h===p){a=Sn(r,a,l);break e}kt(r,a,h,l)}a=a.child}return a;case 5:return Vf(a),r===null&&sl(a),h=a.type,p=a.pendingProps,v=r!==null?r.memoizedProps:null,j=p.children,qc(h,p)?j=null:v!==null&&qc(h,v)&&(a.flags|=32),Cm(r,a),kt(r,a,j,l),a.child;case 6:return r===null&&sl(a),null;case 13:return Im(r,a,l);case 4:return ul(a,a.stateNode.containerInfo),h=a.pendingProps,r===null?a.child=qs(a,null,h,l):kt(r,a,h,l),a.child;case 11:return h=a.type,p=a.pendingProps,p=a.elementType===h?p:Zt(h,p),bm(r,a,h,p,l);case 7:return kt(r,a,a.pendingProps,l),a.child;case 8:return kt(r,a,a.pendingProps.children,l),a.child;case 12:return kt(r,a,a.pendingProps.children,l),a.child;case 10:e:{if(h=a.type._context,p=a.pendingProps,v=a.memoizedProps,j=p.value,Le(go,h._currentValue),h._currentValue=j,v!==null)if(Jt(v.value,j)){if(v.children===p.children&&!xt.current){a=Sn(r,a,l);break e}}else for(v=a.child,v!==null&&(v.return=a);v!==null;){var C=v.dependencies;if(C!==null){j=v.child;for(var T=C.firstContext;T!==null;){if(T.context===h){if(v.tag===1){T=bn(-1,l&-l),T.tag=2;var P=v.updateQueue;if(P!==null){P=P.shared;var H=P.pending;H===null?T.next=T:(T.next=H.next,H.next=T),P.pending=T}}v.lanes|=l,T=v.alternate,T!==null&&(T.lanes|=l),cl(v.return,l,a),C.lanes|=l;break}T=T.next}}else if(v.tag===10)j=v.type===a.type?null:v.child;else if(v.tag===18){if(j=v.return,j===null)throw Error(n(341));j.lanes|=l,C=j.alternate,C!==null&&(C.lanes|=l),cl(j,l,a),j=v.sibling}else j=v.child;if(j!==null)j.return=v;else for(j=v;j!==null;){if(j===a){j=null;break}if(v=j.sibling,v!==null){v.return=j.return,j=v;break}j=j.return}v=j}kt(r,a,p.children,l),a=a.child}return a;case 9:return p=a.type,h=a.pendingProps.children,Ys(a,l),p=_t(p),h=h(p),a.flags|=1,kt(r,a,h,l),a.child;case 14:return h=a.type,p=Zt(h,a.pendingProps),p=Zt(h.type,p),Sm(r,a,h,p,l);case 15:return Nm(r,a,a.type,a.pendingProps,l);case 17:return h=a.type,p=a.pendingProps,p=a.elementType===h?p:Zt(h,p),To(r,a),a.tag=1,jt(h)?(r=!0,lo(a)):r=!1,Ys(a,l),gm(a,h,p),Sl(a,h,p,l),Tl(null,a,h,!0,r,l);case 19:return Mm(r,a,l);case 22:return $m(r,a,l)}throw Error(n(156,a.tag))};function sp(r,a){return Oh(r,a)}function zj(r,a,l,h){this.tag=r,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=a,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=h,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function zt(r,a,l,h){return new zj(r,a,l,h)}function ql(r){return r=r.prototype,!(!r||!r.isReactComponent)}function Uj(r){if(typeof r=="function")return ql(r)?1:0;if(r!=null){if(r=r.$$typeof,r===ve)return 11;if(r===Ie)return 14}return 2}function Qn(r,a){var l=r.alternate;return l===null?(l=zt(r.tag,a,r.key,r.mode),l.elementType=r.elementType,l.type=r.type,l.stateNode=r.stateNode,l.alternate=r,r.alternate=l):(l.pendingProps=a,l.type=r.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=r.flags&14680064,l.childLanes=r.childLanes,l.lanes=r.lanes,l.child=r.child,l.memoizedProps=r.memoizedProps,l.memoizedState=r.memoizedState,l.updateQueue=r.updateQueue,a=r.dependencies,l.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext},l.sibling=r.sibling,l.index=r.index,l.ref=r.ref,l}function Bo(r,a,l,h,p,v){var j=2;if(h=r,typeof r=="function")ql(r)&&(j=1);else if(typeof r=="string")j=5;else e:switch(r){case Q:return ys(l.children,p,v,a);case Z:j=8,p|=8;break;case q:return r=zt(12,l,a,p|2),r.elementType=q,r.lanes=v,r;case be:return r=zt(13,l,a,p),r.elementType=be,r.lanes=v,r;case ae:return r=zt(19,l,a,p),r.elementType=ae,r.lanes=v,r;case Ne:return Fo(l,p,v,a);default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case ee:j=10;break e;case Se:j=9;break e;case ve:j=11;break e;case Ie:j=14;break e;case we:j=16,h=null;break e}throw Error(n(130,r==null?r:typeof r,""))}return a=zt(j,l,a,p),a.elementType=r,a.type=h,a.lanes=v,a}function ys(r,a,l,h){return r=zt(7,r,h,a),r.lanes=l,r}function Fo(r,a,l,h){return r=zt(22,r,h,a),r.elementType=Ne,r.lanes=l,r.stateNode={isHidden:!1},r}function Ql(r,a,l){return r=zt(6,r,null,a),r.lanes=l,r}function Yl(r,a,l){return a=zt(4,r.children!==null?r.children:[],r.key,a),a.lanes=l,a.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},a}function Wj(r,a,l,h,p){this.tag=a,this.containerInfo=r,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=bc(0),this.expirationTimes=bc(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=bc(0),this.identifierPrefix=h,this.onRecoverableError=p,this.mutableSourceEagerHydrationData=null}function Jl(r,a,l,h,p,v,j,C,T){return r=new Wj(r,a,l,C,T),a===1?(a=1,v===!0&&(a|=8)):a=0,v=zt(3,null,null,a),r.current=v,v.stateNode=r,v.memoizedState={element:h,isDehydrated:l,cache:null,transitions:null,pendingSuspenseBoundaries:null},dl(v),r}function Hj(r,a,l){var h=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:I,key:h==null?null:""+h,children:r,containerInfo:a,implementation:l}}function ip(r){if(!r)return Fn;r=r._reactInternals;e:{if(cs(r)!==r||r.tag!==1)throw Error(n(170));var a=r;do{switch(a.tag){case 3:a=a.stateNode.context;break e;case 1:if(jt(a.type)){a=a.stateNode.__reactInternalMemoizedMergedChildContext;break e}}a=a.return}while(a!==null);throw Error(n(171))}if(r.tag===1){var l=r.type;if(jt(l))return Rf(r,l,a)}return a}function rp(r,a,l,h,p,v,j,C,T){return r=Jl(l,h,!0,r,p,v,j,C,T),r.context=ip(null),l=r.current,h=vt(),p=Vn(l),v=bn(h,p),v.callback=a??null,Wn(l,v,p),r.current.lanes=p,Ai(r,p,h),Nt(r,h),r}function zo(r,a,l,h){var p=a.current,v=vt(),j=Vn(p);return l=ip(l),a.context===null?a.context=l:a.pendingContext=l,a=bn(v,j),a.payload={element:r},h=h===void 0?null:h,h!==null&&(a.callback=h),r=Wn(p,a,j),r!==null&&(nn(r,p,j,v),vo(r,p,j)),j}function Uo(r){if(r=r.current,!r.child)return null;switch(r.child.tag){case 5:return r.child.stateNode;default:return r.child.stateNode}}function op(r,a){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var l=r.retryLane;r.retryLane=l!==0&&l<a?l:a}}function Xl(r,a){op(r,a),(r=r.alternate)&&op(r,a)}function Kj(){return null}var ap=typeof reportError=="function"?reportError:function(r){console.error(r)};function Zl(r){this._internalRoot=r}Wo.prototype.render=Zl.prototype.render=function(r){var a=this._internalRoot;if(a===null)throw Error(n(409));zo(r,a,null,null)},Wo.prototype.unmount=Zl.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var a=r.containerInfo;ks(function(){zo(null,r,null,null)}),a[vn]=null}};function Wo(r){this._internalRoot=r}Wo.prototype.unstable_scheduleHydration=function(r){if(r){var a=Wh();r={blockedOn:null,target:r,priority:a};for(var l=0;l<On.length&&a!==0&&a<On[l].priority;l++);On.splice(l,0,r),l===0&&Gh(r)}};function ed(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11)}function Ho(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11&&(r.nodeType!==8||r.nodeValue!==" react-mount-point-unstable "))}function cp(){}function Gj(r,a,l,h,p){if(p){if(typeof h=="function"){var v=h;h=function(){var P=Uo(j);v.call(P)}}var j=rp(a,h,r,0,null,!1,!1,"",cp);return r._reactRootContainer=j,r[vn]=j.current,Hi(r.nodeType===8?r.parentNode:r),ks(),j}for(;p=r.lastChild;)r.removeChild(p);if(typeof h=="function"){var C=h;h=function(){var P=Uo(T);C.call(P)}}var T=Jl(r,0,!1,null,null,!1,!1,"",cp);return r._reactRootContainer=T,r[vn]=T.current,Hi(r.nodeType===8?r.parentNode:r),ks(function(){zo(a,T,l,h)}),T}function Ko(r,a,l,h,p){var v=l._reactRootContainer;if(v){var j=v;if(typeof p=="function"){var C=p;p=function(){var T=Uo(j);C.call(T)}}zo(a,j,r,p)}else j=Gj(l,a,r,p,h);return Uo(j)}zh=function(r){switch(r.tag){case 3:var a=r.stateNode;if(a.current.memoizedState.isDehydrated){var l=Ei(a.pendingLanes);l!==0&&(Sc(a,l|1),Nt(a,qe()),(Ce&6)===0&&(ti=qe()+500,zn()))}break;case 13:ks(function(){var h=jn(r,1);if(h!==null){var p=vt();nn(h,r,1,p)}}),Xl(r,1)}},Nc=function(r){if(r.tag===13){var a=jn(r,134217728);if(a!==null){var l=vt();nn(a,r,134217728,l)}Xl(r,134217728)}},Uh=function(r){if(r.tag===13){var a=Vn(r),l=jn(r,a);if(l!==null){var h=vt();nn(l,r,a,h)}Xl(r,a)}},Wh=function(){return Re},Hh=function(r,a){var l=Re;try{return Re=r,a()}finally{Re=l}},kc=function(r,a,l){switch(a){case"input":if(lc(r,l),a=l.name,l.type==="radio"&&a!=null){for(l=r;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll("input[name="+JSON.stringify(""+a)+'][type="radio"]'),a=0;a<l.length;a++){var h=l[a];if(h!==r&&h.form===r.form){var p=ao(h);if(!p)throw Error(n(90));Dr(h),lc(h,p)}}}break;case"textarea":wh(r,l);break;case"select":a=l.value,a!=null&&Rs(r,!!l.multiple,a,!1)}},Th=Kl,Eh=ks;var Vj={usingClientEntryPoint:!1,Events:[Vi,Us,ao,$h,Ch,Kl]},ar={findFiberByHostInstance:ls,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},qj={bundleType:ar.bundleType,version:ar.version,rendererPackageName:ar.rendererPackageName,rendererConfig:ar.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:F.ReactCurrentDispatcher,findHostInstanceByFiber:function(r){return r=Mh(r),r===null?null:r.stateNode},findFiberByHostInstance:ar.findFiberByHostInstance||Kj,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 Go=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Go.isDisabled&&Go.supportsFiber)try{Ur=Go.inject(qj),cn=Go}catch{}}return $t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Vj,$t.createPortal=function(r,a){var l=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!ed(a))throw Error(n(200));return Hj(r,a,null,l)},$t.createRoot=function(r,a){if(!ed(r))throw Error(n(299));var l=!1,h="",p=ap;return a!=null&&(a.unstable_strictMode===!0&&(l=!0),a.identifierPrefix!==void 0&&(h=a.identifierPrefix),a.onRecoverableError!==void 0&&(p=a.onRecoverableError)),a=Jl(r,1,!1,null,null,l,!1,h,p),r[vn]=a.current,Hi(r.nodeType===8?r.parentNode:r),new Zl(a)},$t.findDOMNode=function(r){if(r==null)return null;if(r.nodeType===1)return r;var a=r._reactInternals;if(a===void 0)throw typeof r.render=="function"?Error(n(188)):(r=Object.keys(r).join(","),Error(n(268,r)));return r=Mh(a),r=r===null?null:r.stateNode,r},$t.flushSync=function(r){return ks(r)},$t.hydrate=function(r,a,l){if(!Ho(a))throw Error(n(200));return Ko(null,r,a,!0,l)},$t.hydrateRoot=function(r,a,l){if(!ed(r))throw Error(n(405));var h=l!=null&&l.hydratedSources||null,p=!1,v="",j=ap;if(l!=null&&(l.unstable_strictMode===!0&&(p=!0),l.identifierPrefix!==void 0&&(v=l.identifierPrefix),l.onRecoverableError!==void 0&&(j=l.onRecoverableError)),a=rp(a,null,r,1,l??null,p,!1,v,j),r[vn]=a.current,Hi(r),h)for(r=0;r<h.length;r++)l=h[r],p=l._getVersion,p=p(l._source),a.mutableSourceEagerHydrationData==null?a.mutableSourceEagerHydrationData=[l,p]:a.mutableSourceEagerHydrationData.push(l,p);return new Wo(a)},$t.render=function(r,a,l){if(!Ho(a))throw Error(n(200));return Ko(null,r,a,!1,l)},$t.unmountComponentAtNode=function(r){if(!Ho(r))throw Error(n(40));return r._reactRootContainer?(ks(function(){Ko(null,null,r,!1,function(){r._reactRootContainer=null,r[vn]=null})}),!0):!1},$t.unstable_batchedUpdates=Kl,$t.unstable_renderSubtreeIntoContainer=function(r,a,l,h){if(!Ho(l))throw Error(n(200));if(r==null||r._reactInternals===void 0)throw Error(n(38));return Ko(r,a,l,!1,h)},$t.version="18.3.1-next-f1338f8080-20240426",$t}var gp;function $k(){if(gp)return sd.exports;gp=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(),sd.exports=s0(),sd.exports}var kp;function i0(){if(kp)return Vo;kp=1;var e=$k();return Vo.createRoot=e.createRoot,Vo.hydrateRoot=e.hydrateRoot,Vo}var r0=i0(),w=wu();const Zn="teamtrail",J={slug:Zn,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:Zn,dataDir:`.${Zn}`,apiPrefix:`/__${Zn}`,dataDirEnv:`${Zn.toUpperCase()}_DIR`,noRegisterEnv:`${Zn.toUpperCase()}_NO_REGISTER`,tokenEnv:`${Zn.toUpperCase()}_TOKEN`},Ma=`${Zn}.prefs`,La=e=>`${J.labelPrefix}:${e}`,yu=La("map"),xu=La("hitl"),o0=e=>e==="task"||e==="execute",ju=La("plan-only");function Ck(e){return/^[A-Za-z0-9_@%+=:,./-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}const a0=e=>e.map(Ck).join(" "),c0=/^\d+\.\d+\.\d+(-[0-9A-Za-z][0-9A-Za-z.-]*)?$/;function l0(e){return c0.test(e)?`${J.npm}@${e}`:J.npm}function Tk(e,t){return a0(["npx","-y",l0(e),...t])}const ua=["research","prototype","junction","task","execute"],rs=[...ua,"review"],Cs="plan+execute",d0=e=>e.filter(t=>!t.archived),u0=["verifying","rework","blocked"],bu=["off","checks","checks+review","checks+review+human"],Ek=e=>bu.find(t=>t===e);function gi(e){return e.type==="junction"||e.type==="prototype"?"hitl":e.type==="research"?"afk":e.hitl?"hitl":"afk"}const h0=["task","execute"];function Ak(e,t,n=Cs){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(o=>{var c;return((c=t.get(o))==null?void 0:c.state)==="open"})?"blocked":"frontier"}function Ts(e,t=Cs){const n=new Map(e.map(i=>[i.id,i]));return new Map(e.map(i=>[i.id,Ak(i,n,t)]))}const vp=e=>{var t;return Number(((t=/(\d+)\D*$/.exec(e.key))==null?void 0:t[1])??NaN)};function f0(e,t){const n=vp(e),i=vp(t);return n!==i&&!Number.isNaN(n)&&!Number.isNaN(i)?n-i:e.key.localeCompare(t.key)||e.id.localeCompare(t.id)}function m0(e){const t=new Map(e.map(d=>[d.id,d])),n=new Map,i=new Set,o=d=>{const u=n.get(d);if(u!==void 0)return u;if(i.has(d))return 0;i.add(d);const f=c(t.get(d));return i.delete(d),n.set(d,f),f},c=d=>{if(!d)return 0;const u=d.blockedBy.filter(m=>t.has(m));if(u.length)return 1+Math.max(...u.map(o));const f=p0(d,t);return f?o(f):0};return o}function p0(e,t){if(!(e.type!=="review"||!e.reviewOf||e.reviewOf===e.id))return t.has(e.reviewOf)?e.reviewOf:void 0}const Oe=200,ze=56,Tr={LR:{layer:330,lane:112,sub:260,along:Oe,across:ze,aspect:1.6},TB:{layer:124,lane:262,sub:100,along:ze,across:Oe,aspect:4/3}},Ik=4;function g0(e){const{wishes:t,lane:n}=e,i=[...t];let o=0;for(;o<t.length;){const c=k0(t,o);if(c.length>1){const d=t[o].at,u=t[o].weight;c.forEach((f,m)=>{i[f]={...t[f],at:d+(m-(c.length-1)/2)*n,beside:void 0,weight:u}})}o=Math.max(o+1,(c.at(-1)??o)+1)}return i}function k0(e,t){const n=e[t];if(!wp(n))return[t];const i=[t];let o=[];for(let c=t+1;c<e.length;c++){const d=e[c];if(d.beside!==void 0){o.push(c);continue}if(!wp(d)||d.at!==n.at)break;i.push(...o,c),o=[]}return i}const wp=e=>e.at!==void 0&&e.weight<Ik;function v0(e){const{ticket:t,links:n,toward:i,tops:o}=e,c=e.layer.findIndex(g=>g.id===t.reviewOf),d=n[i].get(t.id)??[];if(t.type==="review"&&c>=0&&!d.length)return{beside:c,weight:-1,links:0};const u=d.map(g=>o.get(g)).filter(g=>g!==void 0);if(!u.length)return{weight:0,links:0};const f=i==="blockers"?n.blocked:n.blockers,m=d.length===1&&(f.get(d[0])??[]).length===1;return{at:y0(u),weight:w0({ticket:t,chain:m}),links:d.length}}function w0(e){return e.chain?Ik:e.ticket.type==="review"?1:2}function y0(e){const t=[...e].sort((i,o)=>i-o),n=Math.floor(t.length/2);return t.length%2?t[n]:(t[n-1]+t[n])/2}function x0(e){const{wishes:t,lane:n}=e,i=t.map(()=>{}),o=c=>{let d=-1/0,u=1/0;return i.forEach((f,m)=>{f!==void 0&&(m<c&&(d=Math.max(d,f+(c-m)*n)),m>c&&(u=Math.min(u,f-(m-c)*n)))}),{lo:d,hi:u}};for(const c of j0(t)){const{lo:d,hi:u}=o(c),f=b0({wish:t[c],at:i,lane:n});i[c]=f===void 0?S0(d,u):Math.min(u,Math.max(d,f))}return i.map(c=>c??0)}function j0(e){const t=(e.length-1)/2;return e.map((n,i)=>({w:n,i})).sort((n,i)=>i.w.weight-n.w.weight||i.w.links-n.w.links||Math.abs(n.i-t)-Math.abs(i.i-t)||n.i-i.i).map(({i:n})=>n)}function b0(e){const{wish:t,at:n,lane:i}=e;if(t.at!==void 0)return t.at;if(t.beside===void 0)return;const o=n[t.beside];return o===void 0?void 0:o+i}function S0(e,t){return e>-1/0?e:t<1/0?t:0}function N0(e){const{layers:t}=e,{lane:n,across:i}=Tr[e.direction],o=E0(t.flatMap(m=>m.tickets)),c=new Map,d=(m,g)=>{const k={layer:m,toward:g,links:o,tops:c,lane:n};m.subs>1?C0(k):$0(k)};for(const m of t)d(m,"blockers");if(t.length>1){d(t[0],"blocked");for(const m of t.slice(1))d(m,"blockers")}const u=c.size?Math.min(...c.values()):0;for(const[m,g]of c)c.set(m,g-u);const f=Math.max(i,...[...c.values()].map(m=>m+i));return{tops:c,span:f}}function $0(e){const{layer:t,lane:n}=e,i=t.tickets.map(c=>v0({...e,ticket:c,layer:t.tickets})),o=x0({wishes:g0({wishes:i,lane:n}),lane:n});t.tickets.forEach((c,d)=>e.tops.set(c.id,o[d]))}function C0(e){const{layer:t,links:n,tops:i,lane:o}=e,d=t.tickets.flatMap(g=>n[e.toward].get(g.id)??[]).map(g=>i.get(g)).filter(g=>g!==void 0),u=i.get(t.tickets[0].id)??0,m=(d.length?T0(d):u+(t.lanes-1)*o/2)-(t.lanes-1)*o/2;t.tickets.forEach((g,k)=>i.set(g.id,m+k%t.lanes*o))}function T0(e){return(Math.min(...e)+Math.max(...e))/2}function E0(e){const t=new Set(e.map(o=>o.id)),n=new Map,i=new Map;for(const o of e){const c=[...new Set(o.blockedBy)].filter(d=>t.has(d)&&d!==o.id);n.set(o.id,c);for(const d of c)i.set(d,[...i.get(d)??[],o.id])}return{blockers:n,blocked:i}}const A0=6;function I0(e){const{sizes:t}=e,n=Tr[e.direction],i=t.map(()=>1),o=c=>Math.ceil(t[c]/i[c]);for(;;){const c=Math.max(1,...t.map((m,g)=>o(g))),d=t.reduce((m,g,k)=>m+(i[k]-1)*n.sub+n.layer,0)-(n.layer-n.along),u=c*n.lane-(n.lane-n.across);if(d>=n.aspect*u||c<=1)return i;const f=t.findIndex((m,g)=>o(g)===c);if(t[f]<=A0)return i;i[f]=Math.ceil(t[f]/(c-1))}}function yp(e,t="LR",n=Cs){var q;const i=Tr[t],o=Ts(e,n),c=e.filter(ee=>o.get(ee.id)!=="out-of-scope"),d=e.filter(ee=>o.get(ee.id)==="out-of-scope"),u=m0(e),f=[];for(const ee of c)(f[q=u(ee.id)]??(f[q]=[])).push(ee);const m=R0(Array.from(f,ee=>ee??[]),t),g=N0({layers:m,direction:t}),k=[],y=[];let b=0;m.forEach((ee,Se)=>{const ve=(ae,Ie)=>t==="LR"?{x:ae,y:Ie}:{x:Ie,y:ae},be=ee.subs>1;if(ee.tickets.forEach((ae,Ie)=>{const we=Math.floor(Ie/ee.lanes),Ne=be?{wrap:{group:y.length,sub:we,subs:ee.subs}}:{},z=ve(b+we*i.sub,g.tops.get(ae.id)??0);k.push({ticket:ae,state:o.get(ae.id),layer:Se,...z,...Ne})}),be){const ae=ve(b,g.tops.get(ee.tickets[0].id)??0),Ie=ve((ee.subs-1)*i.sub+i.along,(ee.lanes-1)*i.lane+i.across);y.push({layer:Se,...ae,w:Ie.x,h:Ie.y,subs:ee.subs,lanes:ee.lanes})}b+=(ee.subs-1)*i.sub+i.layer});const S=Math.max(b,i.layer)-(i.layer-i.along),x=g.span,$=t==="LR"?S:x,N=t==="LR"?x:S,O=M0({ruled:d,graphW:$,graphH:N});k.push(...O.nodes);const D=[],F=new Map(k.map(ee=>[ee.ticket.id,ee]));for(const ee of k)for(const Se of ee.ticket.blockedBy){const ve=F.get(Se);ve&&D.push({from:ve,to:ee})}const{width:K,height:I,quarantineY:Q,quarantineH:Z}=O;return{direction:t,nodes:k,edges:D,groups:y,width:K,graphH:N,quarantineY:Q,height:I,quarantineH:Z}}function R0(e,t){const n=I0({sizes:e.map(c=>c.length),direction:t}),i=new Map,o=c=>{const d=c.blockedBy.map(u=>i.get(u)).filter(u=>u!==void 0);return d.length?d.reduce((u,f)=>u+f,0)/d.length:c.createdAt/1e12};return e.map((c,d)=>{const u=Math.ceil(c.length/n[d]),m=n[d]>1?[...c].sort(f0):[...c].sort(L0({layer:c,barycentre:o}));return m.forEach((g,k)=>i.set(g.id,k%Math.max(u,1))),{tickets:m,lanes:u,subs:u?Math.ceil(c.length/u):1}})}function M0(e){const{ruled:t,graphW:n,graphH:i}=e,o=i+54,c=Math.max(1,Math.floor((n+24)/(Oe+24))),d=t.map((g,k)=>({ticket:g,state:"out-of-scope",layer:-1,x:k%c*(Oe+24),y:o+Math.floor(k/c)*(ze+16)})),u=Math.ceil(t.length/c),f=Math.max(n,Math.min(t.length,c)*(Oe+24)-24),m=t.length?o+u*(ze+16)-16:i;return{nodes:d,width:f,height:m,quarantineY:o,quarantineH:u*(ze+16)+24}}function L0(e){const{barycentre:t}=e,n=new Map(e.layer.map(o=>[o.id,o])),i=o=>o.type==="review"&&o.reviewOf&&n.get(o.reviewOf)||o;return(o,c)=>{const d=i(o),u=i(c);return d!==u?t(d)-t(u)||d.createdAt-u.createdAt||d.id.localeCompare(u.id):+(o!==d)-+(c!==u)||o.createdAt-c.createdAt}}const ha=["fast","balanced","strongest"],xp="balanced",O0=[["*-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"]],Rk=e=>ha.includes(e),Su={research:"fast",task:"balanced",execute:"balanced",junction:"strongest",prototype:"strongest",review:"strongest"};function P0(e,t){var o,c;const n=(c=(o=t.modelMatching)==null?void 0:o.tiers)==null?void 0:c[e.type],i=Su[e.type];return t.settingsUnconfirmed&&n?ha.indexOf(n)>=ha.indexOf(i)?n:i:n??i}function jp(e){return Object.fromEntries(rs.map(t=>[t,P0({type:t},e)]))}const D0=e=>e!=="__proto__"&&e!=="constructor"&&e!=="prototype",_0=64;function B0(e,t){const n=[];for(let i=0;i<e.length;i++){const o=e[i];if(o!=="*"&&!(o==="?"&&t))n.push({kind:"char",c:o});else if(o==="?")n.push({kind:"one"});else if(!t||e[i+1]!=="*")n.push({kind:t?"star":"deep"});else{const c=e[i+2]==="/";i+=c?2:1,n.push({kind:c?"dirs":"deep"})}}return F0(n)}function F0(e){const t=[];for(const n of e){const i=t.at(-1);(i==null?void 0:i.kind)==="dirs"&&n.kind==="dirs"||(i==null?void 0:i.kind)==="deep"&&(n.kind==="deep"||n.kind==="dirs")||((i==null?void 0:i.kind)==="dirs"&&n.kind==="deep"?t[t.length-1]=n:t.push(n))}return t}function z0({t:e,c:t,inText:n,next:i,cur:o,j:c}){switch(e.kind){case"char":return n&&t===e.c?i[c+1]:0;case"one":return n&&t!=="/"?i[c+1]:0;case"star":return i[c]||(n&&t!=="/"?o[c+1]:0);case"deep":return i[c]||(n?o[c+1]:0);case"dirs":return 0;default:return e}}function U0(e,t,n){const i=n.length,o=new Uint8Array(i+1);let c=0;for(let d=i;d>=0;d--){const u=d<i,f=u?n[d]:"";if(e.kind!=="dirs"){o[d]=z0({t:e,c:f,inText:u,next:t,cur:o,j:d});continue}f==="/"&&t[d+1]&&(c=1),o[d]=t[d]||c}return o}function Mk(e,t,n){const i=B0(e,n.segments);if(i.filter(c=>c.kind!=="char").length>_0)return!1;let o=new Uint8Array(t.length+1);o[t.length]=1;for(let c=i.length-1;c>=0;c--)o=U0(i[c],o,t);return o[0]===1}function bp(e,t){return Mk(e.trim().toLowerCase(),t.trim().toLowerCase(),{segments:!1})}function W0(e,t={}){const n=e==null?void 0:e.trim();if(!n)return{tier:xp,source:"unknown",reason:"no model reported, so it counts as balanced"};const o=Object.entries(t).find(([d])=>d.trim().toLowerCase()===n.toLowerCase())??Object.entries(t).find(([d])=>bp(d,n));if(o)return{tier:o[1],model:n,source:"project",reason:`${n} is ${o[1]} in models.json`};const c=O0.find(([d])=>bp(d,n));return c?{tier:c[1],model:n,source:"built-in",reason:`${n} is a ${c[1]} model`}:{tier:xp,model:n,source:"unknown",reason:`${n} is not a known model, so it counts as balanced`}}const H0=["holding","challenged","invalidated","confirmed"],K0=e=>H0.includes(e),G0=J.labelPrefix,Bd=" -->",V0=7e4,Lk=e=>`<!-- ${G0}:${e} `,q0=e=>JSON.stringify(e).replace(/--/g,"-\\u002d"),Q0=(e,t)=>`${Lk(e)}${t}${Bd}`;function Y0(e,t){const n=e.trimEnd();if(!n.endsWith(Bd))return;const i=Lk(t),o=n.lastIndexOf(i);if(!(o===-1||n.length-o>V0))return{before:n.slice(0,o),payload:n.slice(o+i.length,-Bd.length)}}const J0=/[\u0000-\u001f\u007f-\u009f\u2028\u2029\u200b\u2060\ufeff\u202a-\u202e\u2066-\u2069]/,X0=/[\u0000-\u001f\u007f-\u009f\u2028\u2029\u200b\u2060\ufeff\u202a-\u202e\u2066-\u2069]+/g,Z0=/\r\n|[\r\u0085\u2028\u2029]/g,eb=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u0084\u0086-\u009f\u200b\u2060\ufeff\u202a-\u202e\u2066-\u2069]/g,tb=e=>J0.test(e),js=e=>e.replace(X0," ").trim(),nb=e=>e.replace(Z0,`
41
+ `).replace(eb,"");function Oa(e,t){const n=new RegExp(`^\\\\*(?:${t})`);return nb(e).trim().split(`
42
+ `).map(i=>n.test(i)?`\\${i}`:i).join(`
43
+ `)}function fa(e,t){const n=new RegExp(`^\\\\+(?:${t})`);return e.split(`
44
+ `).map(i=>n.test(i)?i.slice(1):i).join(`
45
+ `)}const Ok=J.labelPrefix,sb=new RegExp(`<(\\\\*)!--(?=\\s*${Ok}:)`,"g"),ib=new RegExp(`<\\\\(\\\\*)!--(?=\\s*${Ok}:)`,"g"),Pa=e=>e.replace(sb,"<\\$1!--"),ai=e=>e.replace(ib,"<$1!--"),Pk="asm",rb=/^-\s+(?:\[([a-z]+)\]\s+)?/,ob=1e3;function ab(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,ob)}}:{},...e.decidedBy?{decidedBy:e.decidedBy}:{}};return`- [${e.status}] ${Pa(js(e.text))} ${Q0(Pk,q0(t))}`}function cb(e){const t=e.map(lb);let n=Math.max(0,...t.map(i=>ub(i.id)))+1;return t.map(i=>i.id?i:{...i,id:`S-${n++}`})}function lb(e){const t=Y0(e,Pk),n=t?t.before:e,i=n.match(rb),o=i==null?void 0:i[1],c=ai(n.slice(i?i[0].length:0).trim()),d=db(t==null?void 0:t.payload);return{id:d.id??"",text:c,status:K0(o)?o:"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 db(e){if(!e)return{};try{const t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}function ub(e){const t=e==null?void 0:e.match(/^S-(\d+)$/);return t?Number(t[1]):0}const Dk=[["destination","Destination"],["notes","Notes"],["assumptions","Assumptions"],["decisions","Decisions so far"],["unspecified","Not yet specified"],["outOfScope","Out of scope"]],hb=Object.fromEntries(Dk),_k="##\\s",Sp=e=>Pa(Oa(e.trim(),_k)),Np=e=>fa(ai(e),_k),$p=e=>Pa(js(e)),fb=/^-\s+(?:\[?([#A-Z0-9-]+)\]?:?\s+)?(.*)$/;function mb(e){var i;const t=o=>o.length?o.map(c=>`- ${$p(c)}`).join(`
46
+ `):"_None yet._",n=o=>o.length?o.map(c=>`- ${c.ticketKey?`${js(c.ticketKey)}: `:""}${$p(c.text)}`).join(`
47
+ `):"_None yet._";return[`## Destination
48
+
49
+ ${Sp(e.destination)}`,`## Notes
50
+
51
+ ${Sp(e.notes)||"_None yet._"}`,...(i=e.assumptions)!=null&&i.length?[`## Assumptions
52
+
53
+ ${e.assumptions.map(ab).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 pb(e){var i;const t={destination:"",notes:"",decisions:[],unspecified:[],outOfScope:[]},n=e.split(/^##\s+/m).slice(1);for(const o of n){const c=o.indexOf(`
64
+ `),d=o.slice(0,c===-1?void 0:c).trim().toLowerCase(),u=(c===-1?"":o.slice(c+1)).trim(),f=(i=Dk.find(([,k])=>k.toLowerCase()===d))==null?void 0:i[0];if(!f)continue;const m=/^_none yet\._$/i.test(u),g=m?[]:u.split(`
65
+ `).map(k=>k.trim()).filter(k=>k.startsWith("- "));f==="destination"?t.destination=Np(u):f==="notes"?t.notes=m?"":Np(u):f==="assumptions"?t.assumptions=cb(g):f==="decisions"?t.decisions=g.map(k=>{const y=k.match(fb);return y&&y[1]&&/\d/.test(y[1])?{ticketKey:y[1],text:ai(y[2])}:{text:ai(k.slice(2))}}):t[f]=g.map(k=>ai(k.slice(2)))}return t}const ma={destination:1e4,notes:5e4,assumptions:100,assumption:500},lr=e=>e.toLocaleString("en-US");function Nu(e){var d,u;const t=ma,n=((d=e.destination)==null?void 0:d.trim().length)??0;if(n>t.destination)return`The destination is too long: ${lr(n)} characters, at most ${lr(t.destination)}.`;const i=((u=e.notes)==null?void 0:u.trim().length)??0;if(i>t.notes)return`The notes are too long: ${lr(i)} characters, at most ${lr(t.notes)}.`;const o=e.assumptions??[];if(o.length>t.assumptions)return`Too many assumptions: ${lr(o.length)}, at most ${t.assumptions}. Each line is one assumption.`;const c=o.findIndex(f=>f.trim().length>t.assumption);if(c>=0)return`Assumption ${c+1} is too long: at most ${t.assumption} characters on one line.`}const Da={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"]},gb=(e,t)=>`${e[0].toUpperCase()}${e.slice(1)} ${t}/${Da[e].length}`;class Me extends Error{}async function kb(e,t,n={}){var g,k,y;const{destination:i,notes:o,assumptions:c}=t.sections,d=Nu({destination:i,notes:o,assumptions:c==null?void 0:c.map(b=>b.text)});if(d)throw new Me(d);const u=vb(t,t.mode??Cs),f=await e.createMap({title:u.title,mode:u.mode,sections:u.sections,...u.verification?{verification:u.verification}:{}});await((g=n.onMapCreated)==null?void 0:g.call(n,f));const m=new Map;for(const b of u.tickets){const S=await e.createTicket(f.id,{title:b.title,type:b.type,hitl:b.hitl,body:`${b.body}
66
+
67
+ Part of trail ${f.key}.`});m.set(b.ref,S),await((k=n.onTicketCreated)==null?void 0:k.call(n,S,b.ref))}for(const b of u.tickets)for(const S of b.blockedBy??[]){const x=m.get(S),$=m.get(b.ref);x&&(await e.addBlocking(f.id,x.id,$.id),await((y=n.onEdgeWired)==null?void 0:y.call(n,x,$)))}return{map:f,tickets:[...m.values()]}}function vb(e,t){if(t==="plan+execute")return{...e,mode:t};const n=new Map(e.tickets.filter(o=>o.type==="execute").map(o=>[o.ref,o.blockedBy??[]])),i=o=>o.flatMap(c=>n.has(c)?i(n.get(c)):[c]);return{...e,mode:t,tickets:e.tickets.filter(o=>!n.has(o.ref)).map(o=>({...o,blockedBy:[...new Set(i(o.blockedBy??[]))]}))}}function Bk(e){if(e.archived)throw new Me(`Trail ${e.key} "${e.title}" is archived: no work is taken from it. Only the trail lead can restore it in the Lookout.`)}class wb{constructor(){oe(this,"tails",new Map)}run(t,n){const o=(this.tails.get(t)??Promise.resolve()).catch(()=>{}).then(n);return this.tails.set(t,o),o.finally(()=>this.tails.get(t)===o&&this.tails.delete(t)).catch(()=>{}),o}}const yb={frontier:"ready",blocked:"backlog",parked:"backlog",claimed:"working",verifying:"verifying",rework:"rework",held:"blocked",decided:"done","out-of-scope":"cancelled"};function xb(e,t,n=Cs){return yb[Ak(e,t,n)]}const jb=["backlog","ready","working","verifying","rework","blocked"],dr=["agent","trail lead"],bb=[{event:"claim",from:["ready","rework"],to:["working"],actors:dr},{event:"release",from:["working"],to:["ready","rework"],actors:dr},{event:"expire",from:["working"],to:["ready","rework"],actors:["engine","trail lead"]},{event:"complete",from:["backlog","ready","working","rework"],to:["done"],actors:dr},{event:"submit",from:["working"],to:["verifying"],actors:dr},{event:"checks.pass",from:["verifying"],to:["verifying","done","blocked"],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:jb,to:["cancelled"],actors:[...dr,"engine"]},{event:"reopen",from:["done","cancelled"],to:["ready"],actors:["trail lead"]},{event:"waive",from:["rework","blocked"],to:["verifying"],actors:["trail lead"]}],Sb=e=>bb.find(t=>t.event===e),Nb=new wb;function $b(e,t,n){if(n){if(!e.to.includes(n))throw new Me(`${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 Me(`${e.event} needs a target: ${e.to.join(" or ")}`)}async function Cb(e,t,n,i){const{to:o,actor:c}=i,d=async u=>{(n.status??null)!==u&&await e.setMeta(t,n.id,{status:u})};switch(o){case"working":n.assignee!==c&&await e.assign(t,n.id,c);return;case"ready":case"rework":n.state==="closed"&&await e.reopen(t,n.id),await d(o==="rework"?"rework":null),n.assignee&&await e.assign(t,n.id,null);return;case"verifying":case"blocked":await d(o);return;case"done":case"cancelled":await d(null),await e.close(t,n.id,o==="done"?"completed":"not_planned");return;case"backlog":throw new Me("backlog follows from blockers; no transition leads there")}}function _a(e,t,n,i){return Nb.run(`${t}/${n}`,async()=>{var m;const o=await e.loadMap(t),c=o.tickets.find(g=>g.id===n);if(!c)throw new Me(`ticket ${n} not found`);const d=xb(c,new Map(o.tickets.map(g=>[g.id,g])),o.map.mode);if(i.expect&&d!==i.expect)throw new Me(`${c.key} changed: it is ${d} now`);const u=Sb(i.event);if(!u.from.includes(d))throw new Me(`${c.key} is ${d}; ${i.event} needs ${u.from.join(" or ")}`);if(!u.actors.includes(i.actorKind))throw new Me(`${i.event} is not for ${i.actorKind}s`);const f=$b(u,c,i.to);await Cb(e,t,c,{to:f,actor:i.actor});try{await((m=i.journal)==null?void 0:m.append({v:1,kind:"transition",at:Date.now(),mapId:t,ticketId:n,ticketKey:c.key,event:i.event,from:d,to:f,actor:i.actor,actorKind:i.actorKind,...i.reason?{reason:i.reason}:{},...i.sessionId?{sessionId:i.sessionId}:{}}))}catch{}return{ticket:c,from:d,to:f}})}async function Cp(e,t,n,i){const{assignee:o}=i,c=await e.loadMap(t),d=c.tickets.find(g=>g.id===n);if(!d)throw new Me(`ticket ${n} not found`);Bk(c.map);const u=Ts(c.tickets,c.map.mode).get(n);if(u!=="frontier"&&u!=="rework")throw new Me(`${d.key} is ${u}, not on the frontier`);await _a(e,t,n,{event:"claim",actor:o,actorKind:i.actorKind??"agent",reason:i.reason,sessionId:i.sessionId,journal:i.journal});const m=(await e.loadMap(t)).tickets.find(g=>g.id===n);if(m.assignee!==o)throw new Me(`${d.key} was claimed by ${m.assignee}`);return m}async function Tb(e,t,n,i={}){const c=(await e.loadMap(t)).tickets.find(d=>d.id===n);if(!c)throw new Me(`ticket ${n} not found`);await _a(e,t,n,{event:"release",actor:i.actor??c.assignee??"trail lead",actorKind:i.actorKind??"agent",reason:i.reason,sessionId:i.sessionId,journal:i.journal})}const Fk=e=>e==="lookout",Eb=e=>e.via==="chat"?`in ${e.chatOf??"an agent"}'s chat`:void 0;function Ab(e){return e.via?e.via==="chat"&&e.chatOf?{via:e.via,chatOf:e.chatOf}:{via:e.via}:{}}function zk(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 pa(e,t){const n=e.via??(e.sourceKind==="slack"?"slack":void 0);if(!n||Fk(n)||!t.ticketId)return;const i=t.key??t.ticketId,o=n==="lookout-limited"?"ask someone allowed to make high-risk calls":"decide it in the Lookout";if(!e.highRisk)throw new Me(`Can't tell whether ${i} is high risk: ${o}.`);if(await e.highRisk(t.mapId,t.ticketId))throw new Me(zk(i,n))}async function Ib(e,t){var d;const{mapId:n,old:i,next:o}=t;await pa(e,{mapId:n,ticketId:i.ticketId,key:i.ticketKey??i.id}),o.ticketId&&o.ticketId!==i.ticketId&&await pa(e,{mapId:n,ticketId:o.ticketId,key:o.ticketKey});const c=e.via??(e.sourceKind==="slack"?"slack":void 0);if(c&&!Fk(c)&&((d=i.risk)==null?void 0:d.level)==="high")throw new Me(zk(i.id,c))}async function $u(e,t,n,i={}){if(await pa({...i.guard,sourceKind:n.source.kind},{mapId:t,ticketId:n.ticketId,key:n.ticketKey}),n.source.ref){const c=(await e.listDecisions(t)).find(d=>!d.postedBy&&d.source.kind===n.source.kind&&d.source.ref===n.source.ref);if(c)return c}const o=await e.createDecision(t,n);if(i.appendToTrail??!0){const c=await e.loadMap(t);await e.updateMapSections(t,{decisions:[...c.map.sections.decisions,{ticketId:o.ticketId,ticketKey:o.ticketKey,text:i.trailLine??o.summary}]})}return o}async function Rb(e,t,n,{guard:i,...o}){const d=(await e.listDecisions(t)).find(b=>b.id===n);if(!d)throw new Me(`decision ${n} not found`);if(d.postedBy)throw new Me(`${d.id} is ${d.postedBy}'s decision; record your own instead`);if(d.supersededBy)throw new Me(`${d.id} is already superseded by ${d.supersededBy}`);const u={ticketId:d.ticketId,ticketKey:d.ticketKey,...o,question:o.question??d.question,supersedes:d.id};await Ib({...i,sourceKind:o.source.kind},{mapId:t,old:d,next:u});const f=await e.createDecision(t,u);await e.markSuperseded(t,d.id,f.id);const g=(await e.loadMap(t)).map.sections.decisions,k=g.findIndex(b=>b.text===d.summary||!!d.ticketId&&b.ticketId===d.ticketId||!!d.ticketKey&&b.ticketKey===d.ticketKey),y={ticketId:f.ticketId,ticketKey:f.ticketKey,text:f.summary};return await e.updateMapSections(t,{decisions:k<0?[...g,y]:g.map((b,S)=>S===k?y:b)}),f}async function Mb(e,t,n){await e.setMapMode(t,n)}function Uk(e){return e==="plan-only"?ua.filter(t=>t!=="execute"):ua}function Lb(e,t){if(!Uk(e).includes(t))throw new Me(`${t} tickets are disabled on plan-only maps`)}const ts={lookout:{label:"Lookout",code:"CMD"},agent:{label:"Agent",code:"AGT"},slack:{label:"Slack",code:"SLK"},tracker:{label:"Tracker",code:"TRK"}},ga=Object.keys(ts),Ob=e=>e in ts,Wk=" (unverified, from text)";function jr(e){return e.derived||e.decidedBy.endsWith(Wk)?"unverified":e.postedBy?"teammate":e.source.kind==="agent"&&e.decidedBy!=="trail lead"&&!e.decidedBy.startsWith("slack:")?"agent":"human"}const Hk=e=>e.postedBy?`posted by ${e.postedBy} in ${e.postedIn??"the tracker"}`:void 0,Er=e=>e.supersededBy?"superseded":"active";function Ba(e){const t=e.replace(/\s+/g," ").trim(),n=t.match(/^(.{20,180}?[.!?])(\s|$)/);return n?n[1]:t.slice(0,180)}function Pb(e,t,n){var i;return{...n,id:e,mapId:t,decidedAt:n.decidedAt??Date.now(),summary:((i=n.summary)==null?void 0:i.trim())||Ba(n.answer),alternatives:n.alternatives??[],rationale:n.rationale??"",participants:n.participants??[{id:n.decidedBy}],transcript:n.transcript??[]}}const Db=e=>Number(e.replace(/\D/g,""))||0;function _b(e,t){const n=new Map(e.map(d=>[d.id,d])),i=new Set;let o=n.get(t);for(;o!=null&&o.supersedes&&n.has(o.supersedes)&&!i.has(o.id);)i.add(o.id),o=n.get(o.supersedes);const c=[];i.clear();for(let d=o;d&&!i.has(d.id);d=d.supersededBy?n.get(d.supersededBy):void 0)i.add(d.id),c.push(d);return c}async function Bb(e,t,n,i){var d,u;const c=(await e.loadMap(t)).tickets.find(f=>f.id===n);if(!c)throw new Me(`ticket ${n} not found`);if(c.state==="closed")throw new Me(`${c.key} is already closed`);return await pa({...i.guard,sourceKind:(u=(d=i.decision)==null?void 0:d.source)==null?void 0:u.kind},{mapId:t,ticketId:c.id,key:c.key}),i.transcript&&await e.comment(t,n,i.author,`**HITL transcript**
68
+
69
+ ${i.transcript}`),await e.comment(t,n,i.author,`**Resolution**
70
+
71
+ ${i.answer}`),await _a(e,t,n,{event:i.event??"complete",actor:i.actor??i.author,actorKind:i.actorKind??"agent",sessionId:i.sessionId,reason:i.reason,journal:i.journal,...i.event&&i.event!=="complete"?{to:"done"}:{}}),await $u(e,t,Fb(c,i),{trailLine:i.trailLine,guard:i.guard}),c}function Fb(e,t){var i;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??Ba(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}:{},...(i=n.assumes)!=null&&i.length?{assumes:n.assumes}:{}}}async function zb(e,t,n,i){const o=await e.loadMap(t);if(Bk(o.map),!o.map.sections.unspecified.includes(n))throw new Me(`"${n}" is not in Not yet specified`);Lb(o.map.mode,i.type);const c=await e.createTicket(t,{title:i.title??n,type:i.type,hitl:i.hitl,body:`${i.body??`Promoted from Not yet specified: ${n}`}
72
+
73
+ Part of trail ${o.map.key}.`});for(const u of i.blockedBy??[])await e.addBlocking(t,u,c.id);const d=await e.loadMap(t);return await e.updateMapSections(t,{unspecified:d.map.sections.unspecified.filter(u=>u!==n)}),c}async function Ub(e,t,n,i){const o=await e.loadMap(t),{unspecified:c,outOfScope:d}=o.map.sections;if("unspecified"in n){if(!c.includes(n.unspecified))throw new Me(`"${n.unspecified}" is not in Not yet specified`);await e.updateMapSections(t,{unspecified:c.filter(m=>m!==n.unspecified),outOfScope:[...d,`${n.unspecified} — ${i.reason}`]});return}const u=o.tickets.find(m=>m.id===n.ticketId);if(!u)throw new Me(`ticket ${n.ticketId} not found`);await e.comment(t,u.id,i.author,`**Ruled out of scope**
74
+
75
+ ${i.reason}`),await _a(e,t,u.id,{event:"cancel",actor:i.author,actorKind:i.actorKind??"agent",reason:i.reason,sessionId:i.sessionId,journal:i.journal}),await $u(e,t,{ticketId:u.id,ticketKey:u.key,question:u.title,answer:`Out of scope: ${i.reason}`,decidedBy:i.author,source:i.source??{kind:"agent",label:i.author}},{appendToTrail:!1});const f=await e.loadMap(t);await e.updateMapSections(t,{outOfScope:[...f.map.sections.outOfScope,`${u.key} ${u.title} — ${i.reason}`]})}async function Wb(e,t,n,i){n&&Hb(n),await e.setMapMeta(t,{modelMatching:n&&Kb(n),confirm:!0})}function Hb(e){if(typeof e.enabled!="boolean")throw new Me('"enabled" must be true or false');for(const[t,n]of Object.entries(e.tiers??{})){if(!rs.includes(t))throw new Me(`unknown ticket type "${t}"`);if(!Rk(n))throw new Me(`"${t}" must be fast, balanced or strongest`)}}function Kb(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 Gb(e,t,n,i){await e.setMapArchived(t,n)}const Kk=Object.freeze({research:["architect"],junction:["architect"],prototype:["architect"],task:["qa","security"],execute:["qa","security"],review:["reviewer"]}),Vb=(e,t)=>e.guidesByType?"trail":t?"team":"defaults";function Cu(e){var c;const t=(c=e.guides)!=null&&c.length?new Set(e.guides):void 0,n=e.guidesByType??Kk,i=d=>!!e.guidesByType||!t||t.has(d);return{byType:Object.fromEntries(rs.map(d=>[d,[...new Set((n[d]??[]).filter(i))]])),source:Vb(e,!!t)}}const Gk=e=>[...new Set([...e.guide?[e.guide]:[],...e.guidesAdded??[]])];function qb(e,t){const n=new Set(t.guidesRemoved??[]),i=Cu(e).byType[t.type]??[],o=i.map(c=>({id:c,via:"type"}));for(const c of Gk(t))i.includes(c)||o.push({id:c,via:"ticket"});return o.filter(c=>!n.has(c.id))}function Qb(e){return{async append(t){await fetch(`${e}/journal`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}}}const Yb=["off","observe","enforce"],Vk=["check-guard","independent-review","diff-rules","flaky"],qk={"check-guard":"enforce","independent-review":"observe","diff-rules":"enforce",flaky:"enforce"},Qk={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",gates:{...qk},rules:[],github:{enabled:"auto",requiredChecks:[],pollSec:60}};new Set(Object.keys(Qk));function Jb(e,t){var n;return e?((n=e.gates)==null?void 0:n[t])??qk[t]:"off"}const Xb=e=>e?`on ${e.slice(0,7)}`:"on the same code",Zb=e=>`${e.name}${e.test?` (${e.test})`:""} ${e.failure==="timed out"?"timed out":"failed"} in ${e.failedIn}, then passed ${Xb(e.head)} with no change`,eS=e=>e.map(Zb).join("; "),Tu=e=>{var t;return(e==null?void 0:e.result)==="pass"&&((t=e.flaky)==null?void 0:t.mode)==="enforce"},tS=3;function nS(e){const t=e.slice(0,tS).map(i=>i.text),n=e.length-t.length;return`${t.join("; ")}${n>0?`; and ${n} more`:""}`}const sS=2*6e4,od=e=>e<6e4?`${Math.round(e/1e3)}s`:`${Math.round(e/6e4)}m`;function iS(e,t){if(!e)return{tone:"unknown",label:"PR sync ?",title:"PR/CI sync state unavailable"};const n=e.repo?` · ${e.repo}`:"",i=e.lastOkAt?`last ok ${od(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
+ ${i}`}:e.state==="rate-limited"?{tone:"failed",label:"PR sync paused",title:`Rate limited${n}; retrying ${e.nextAt?`in ${od(Math.max(0,e.nextAt-t))}`:"later"}
77
+ ${i}`}:!e.lastOkAt||e.lastOkAt!==e.lastAttemptAt||e.nextAt!==void 0&&t>e.nextAt+sS?{tone:"stale",label:"PR sync stale",title:`No recent sync${n}
78
+ ${i}`}:{tone:"ok",label:`PR sync ${od(t-e.lastOkAt)}`,title:`PR/CI synced${n}, ${i}`}}class ui{constructor(){oe(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 rS=0;const oa=(e="id")=>`${e}_${Date.now().toString(36)}${(rS++).toString(36)}`,Fd=(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)}:{}}),Yk=(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 oS(e,t,n){const i=()=>e.find(t.id)??t,o=c=>e.push({source:"session",sessionId:t.id,agent:t.agent,...c});return{id:t.id,get info(){return i()},step(c,d,u){const f=Da[n][c-1];e.patchSession(t.id,{step:c,stepLabel:f,...u?{ticketId:u}:{}}),o({tag:gb(n,c),level:"step",text:d?`${f}: ${d}`:f,ticketId:u??i().ticketId})},log(c,d="info",u){o({level:d,text:c,ticketId:i().ticketId,...u?{kind:u}:{}})},say(c){e.chat({sessionId:t.id,ticketId:i().ticketId,from:"agent",author:t.agent,text:c})},ask(c,d,u){var m;const f={id:oa("q"),sessionId:t.id,mapId:t.mapId,ticketId:i().ticketId,agent:t.agent,text:c,suggestions:d,at:Date.now(),...u!=null&&u.urgency?{urgency:u.urgency}:{},...(m=u==null?void 0:u.blocks)!=null&&m.length?{blocks:u.blocks}:{}};return e.chat({sessionId:t.id,ticketId:f.ticketId,from:"agent",author:t.agent,text:c,questionId:f.id}),e.addPending(f),e.patchSession(t.id,{waitingOn:f.id}),o({level:"alert",kind:"asks-you",ticketId:f.ticketId,text:"Decision request · waiting on you",signal:!0}),e.awaitAnswer(f.id)},done(c=!0,d,u){e.patchSession(t.id,{status:c?"done":"failed",endedAt:Date.now(),waitingOn:void 0}),e.dropPending(t.id),o({level:c?"ok":"alert",text:d??(c?"Session closed":"Session aborted"),signal:u==null?void 0:u.signal,...u!=null&&u.kind?{kind:u.kind}:{}})},bindMap(c){var u;const d=i().usage;d&&(e.addMapUsage(c,d),(u=e.ledger())==null||u.add(c,d,t.id)),e.patchSession(t.id,{mapId:c})},usage(c){var f;const d=i().mapId;(f=e.ledger())==null||f.add(d,c,t.id),e.addMapUsage(d,c);const u=i().usage;e.patchSession(t.id,{usage:{...Fd(u,c),source:c.source??(u==null?void 0:u.source)}})},setUsage(c){var g;const d=i().usage,u=Yk(c,d);if(!u.inputTokens&&!u.outputTokens&&!u.costUsd&&!u.cachedInputTokens&&(d==null?void 0:d.source)===c.source&&`${d==null?void 0:d.models}`==`${c.models}`)return;const m=i().mapId;(u.inputTokens>0||u.outputTokens>0||u.costUsd>0)&&((g=e.ledger())==null||g.add(m,u,t.id)),e.addMapUsage(m,u),e.patchSession(t.id,{usage:c})},setModel(c,d){const u=i();u.model===c&&u.tier===d||e.patchSession(t.id,{model:c,tier:d})}}}class aS{constructor(t=400,n){oe(this,"state",{sessions:[],feed:[],chats:[],pending:[],answered:[],usageByMap:{}});oe(this,"changes",new ui);oe(this,"resolvers",new Map);oe(this,"remote",new Map);oe(this,"remoteAnswer");oe(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(i=>i.sessionId===t).length&&this.set({pending:this.state.pending.filter(i=>i.sessionId!==t)})},awaitAnswer:t=>new Promise(n=>this.resolvers.set(t,n)),addMapUsage:(t,n)=>{this.state={...this.state,usageByMap:{...this.state.usageByMap,[t]:Fd(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:oa("f"),at:t.at??Date.now(),...t};return n.source==="system"&&!n.agent&&(n.agent=J.assistant.name),this.set({feed:[...this.state.feed,n].slice(-this.maxFeed)}),n}patchSession(t,n){this.set({sessions:this.state.sessions.map(i=>i.id===t?{...i,...n}:i)})}chat(t){this.set({chats:[...this.state.chats,{id:oa("m"),at:Date.now(),...t}].slice(-600)})}answer(t,n,i,o){var g;const c=this.state.pending.find(k=>k.id===t),d=this.resolvers.get(t),u=!!c&&this.remote.has(c.sessionId)&&!!this.remoteAnswer;if(!c||!d&&!u)return!1;this.resolvers.delete(t);const f=Ab(o),m=o.by?{by:o.by}:{};return this.chat({sessionId:c.sessionId,ticketId:c.ticketId,from:"human",author:i,text:n,...f,...m}),this.set({pending:this.state.pending.filter(k=>k.id!==t),answered:[...this.state.answered,{id:c.id,mapId:c.mapId,sessionId:c.sessionId,agent:c.agent,askedAt:c.at,answeredAt:Date.now(),...c.ticketId?{ticketId:c.ticketId}:{},...c.category?{category:c.category}:{},...(g=c.categories)!=null&&g.length?{categories:c.categories}:{},...c.urgency?{urgency:c.urgency}:{},...f,...m}].slice(-200)}),this.patchSession(c.sessionId,{waitingOn:void 0}),this.push({source:"trail lead",agent:i,level:"ok",kind:"answered",ticketId:c.ticketId,sessionId:c.sessionId,text:`Answered ${c.agent}`}),d?d(n):this.remoteAnswer(c,n,i),!0}syncRemote(t){var m;const{session:n}=t,i=n.id;if(!this.remote.has(i)&&this.state.sessions.some(g=>g.id===i))return;const o=this.remote.get(i);this.remote.set(i,n.mapId?n.usage:o);let c=this.state.usageByMap;if(n.usage&&n.mapId){const g=Yk(n.usage,o);(g.inputTokens||g.outputTokens||g.costUsd)&&(c={...c,[n.mapId]:Fd(c[n.mapId],g)}),(m=this.ledger)==null||m.addTotal(n.mapId,i,n.usage)}const d=g=>g.filter(k=>k.sessionId!==i),u=new Set(this.state.answered.map(g=>g.id)),f=this.state.sessions.some(g=>g.id===i)?this.state.sessions.map(g=>g.id===i?n:g):[...this.state.sessions,n].slice(-24);this.set({sessions:f,chats:[...d(this.state.chats),...t.chats].sort((g,k)=>g.at-k.at).slice(-600),pending:[...d(this.state.pending),...t.pending],answered:[...this.state.answered,...t.answered.filter(g=>!u.has(g.id))].sort((g,k)=>g.answeredAt-k.answeredAt).slice(-200),feed:[...this.state.feed.filter(g=>g.sessionId!==i),...t.feed].sort((g,k)=>g.at-k.at).slice(-this.maxFeed),usageByMap:c})}isRemote(t){return this.remote.has(t)}startSession(t){const n={...t,id:t.id??oa("s"),step:0,total:Da[t.mode].length,stepLabel:"BOOT",status:"running",startedAt:Date.now()};this.set({sessions:[...this.state.sessions,n].slice(-24)});const i=oS(this.host,n,t.mode);return this.push({source:"session",sessionId:n.id,agent:n.agent,level:"info",text:`Session opened · ${t.mode}`}),i}}function cS(e,t){const n=i=>{var o;return((o=t(i))==null?void 0:o.key)??i};switch(e.kind){case"map.created":return{source:"tracker",level:"ok",text:`Trail created · label ${yu}`};case"map.updated":return{source:"tracker",level:"info",text:`Trail updated${e.section?` · ${hb[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 lS=new Set(["createMap","setMapMode","setMapArchived","setMapMeta","updateMapSections","createTicket","addBlocking","removeBlocking","editTicket","reopen","assign","comment","close","setMeta","createDecision","markSuperseded"]),dS=5*6e4;function uS(e){let t={status:"idle",inflight:0,writes:0,errors:0,events:[]};const n=new ui,i=c=>{t={...t,...c},n.emit(t)};return e.subscribe(c=>{const d=c.at-dS;i({events:[...t.events.filter(u=>u.at>=d),{at:c.at,external:c.kind==="external.changed"||"external"in c&&!!c.external}]})}),{adapter:new Proxy(e,{get(c,d,u){const f=Reflect.get(c,d,u);return typeof f!="function"?f:lS.has(d)?async(...m)=>{const g=Date.now();i({inflight:t.inflight+1,status:"syncing"});try{const k=await f.apply(c,m),y=t.inflight-1;return i({inflight:y,writes:t.writes+1,lastWriteMs:Date.now()-g,lastWriteAt:Date.now(),status:y?"syncing":"ok",lastError:void 0}),k}catch(k){const y=t.inflight-1;throw i({inflight:y,errors:t.errors+1,status:"error",lastError:String(k.message??k)}),k}}:f.bind(c)}}),get health(){return t},subscribe:c=>n.on(c)}}function Jk(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 Ts(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 hS(e){const t=Jk(e);return{decided:t.decided,total:t.total-t["out-of-scope"]}}function fS(e){const t=new Map(e.tickets.filter(d=>d.state==="open").map(d=>[d.id,d])),n=new Map,i=new Set,o=d=>{if(n.has(d))return n.get(d);if(i.has(d))return[];i.add(d);const u=t.get(d);let f=[];for(const g of u.blockedBy)if(t.has(g)){const k=o(g);k.length>f.length&&(f=k)}i.delete(d);const m=[...f,u];return n.set(d,m),m};let c=[];for(const d of t.keys()){const u=o(d);u.length>c.length&&(c=u)}return c}function mS(e){return ua.map(t=>{const n=e.tickets.filter(i=>i.type===t);return{type:t,open:n.filter(i=>i.state==="open").length,closed:n.filter(i=>i.state==="closed").length}}).filter(t=>t.open+t.closed>0)}function pS(e,t){const n=e.pending.filter(o=>!0),i=e.answered.filter(o=>!0);return{open:n.length,oldestAt:n.length?Math.min(...n.map(o=>o.at)):void 0,answered:i.length,avgWaitMs:i.length?i.reduce((o,c)=>o+(c.answeredAt-c.askedAt),0)/i.length:void 0}}function Xk(e,t){return t&&e.usageByMap[t]||{inputTokens:0,outputTokens:0,costUsd:0}}const gS=e=>e.usage?e.usage.inputTokens+e.usage.outputTokens:0,Zk={"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 ev(e,t){var i;const n=new Set;for(const o of e.sessions)t&&o.mapId===t&&((i=o.usage)!=null&&i.source)&&n.add(o.usage.source);return[...n].sort()}const ad=e=>e===1?"1 ticket":`${e} tickets`,kS=e=>e.charAt(0).toLowerCase()+e.slice(1);function Tp(e){return e.kind==="passed"?`verified together on ${e.branch??"main"} at ${e.commit.slice(0,7)}`:kS(e.reason)}function vS(e){const t=e.tickets.filter(f=>!(f.state==="closed"&&f.closeReason==="not_planned")),n=t.filter(f=>f.state==="open").length;if(n)return{kind:"not-done",reason:`${ad(n)} still open`};if(!t.length)return{kind:"not-done",reason:"No tickets in scope"};if(e.pendingReroutes)return{kind:"not-done",reason:"A reroute waits for your review"};const i=t.length,{together:o}=e,c=t.filter(f=>e.proofs[f.id]!=="verified").map(f=>f.id);if(!c.length&&o.kind==="passed")return{kind:"verified",done:i,together:o,reason:`All ${ad(i)} verified · ${Tp(o)}`};const d=c.length===i?"none verified":`${c.length} not verified`,u=[`${ad(i)} done`,...c.length?[d]:[],Tp(o)];return{kind:"unverified",done:i,unverified:c,together:o,reason:u.join(" · ")}}function wS(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 yS(e,t){const n=new Set(t.map(o=>o.ticketId).filter(Boolean)),i=e.tickets.filter(o=>o.state==="closed"&&o.closeReason==="completed"&&!n.has(o.id)).map(o=>{var g;const c=[...o.comments].reverse().find(k=>k.body.startsWith("**Resolution**")),d=c?c.body.replace(/^\*\*Resolution\*\*\s*/,""):((g=e.map.sections.decisions.find(k=>k.ticketId===o.id||k.ticketKey===o.key))==null?void 0:g.text)??"",u=(c==null?void 0:c.author)??o.assignee??"unknown",f=o.comments.find(k=>k.body.startsWith("**HITL transcript**")),m=f?wS(f.body,f.createdAt):[];return{id:`T${o.key}`,mapId:e.map.id,ticketId:o.id,ticketKey:o.key,question:o.title,answer:d,summary:Ba(d),alternatives:[],rationale:"",decidedBy:`${u}${Wk}`,decidedAt:o.closedAt??(c==null?void 0:c.createdAt)??o.updatedAt,participants:[...new Set([u,...m.map(k=>k.author)])].map(k=>({id:k})),source:{kind:"tracker",ref:`${e.map.id}/tickets/${o.id}`,label:`unverified, from text: ${c?`${o.key} resolution comment`:"the map’s Decisions so far"}`},transcript:m,derived:!0}});return[...t,...i].sort((o,c)=>c.decidedAt-o.decidedAt)}function xS(e,t){var i;const n=(i=t.query)==null?void 0:i.trim().toLowerCase();return e.filter(o=>(!t.mapId||o.mapId===t.mapId)&&(!t.source||o.source.kind===t.source)&&(!t.decidedBy||o.decidedBy===t.decidedBy)&&(!t.madeBy||jr(o)===t.madeBy)&&(!t.status||Er(o)===t.status)&&(!n||[o.id,o.ticketKey,o.question,o.answer,o.summary,o.rationale,o.decidedBy,...o.alternatives,...o.transcript.map(c=>c.text)].join(`
79
+ `).toLowerCase().includes(n)))}function jS(e,t=Date.now()){const n=Object.fromEntries(ga.map(d=>[d,0]));let i=0,o=0,c=0;for(const d of e){n[d.source.kind]++,d.supersededBy&&i++,t-d.decidedAt<864e5&&o++;const u=jr(d);(u==="human"||u==="agent"&&d.transcript.some(f=>f.from==="human"))&&c++}return{total:e.length,active:e.length-i,superseded:i,last24h:o,human:c,bySource:n}}function Fa(e){const t=e.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);if(!t)return{front:{},body:e};const n={};for(const i of t[1].split(`
80
+ `)){const o=i.indexOf(":");if(o<0)continue;const c=i.slice(0,o).trim(),d=i.slice(o+1).trim();D0(c)&&(n[c]=d.startsWith("[")?NS(d.slice(1,-1)).map(Ap).filter(Boolean):Ap(d))}return{front:n,body:t[2]}}const bS=e=>e===""||/^[\s#&*!|>'"%@`[\]{},?:-]|[:#]\s|\s$|,|["\\[\]]/.test(e)||tb(e)||/^(true|false|null|~|\d[\d.e+-]*)$/i.test(e),SS=e=>JSON.stringify(e).replace(/[\u007f\u0085\u2028\u2029]/g,t=>`\\u${t.charCodeAt(0).toString(16).padStart(4,"0")}`),Ep=e=>bS(e)?SS(e):e;function Ap(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 NS(e){const t=[];let n="",i=!1,o=!1;for(const c of e)c==='"'&&!o&&(i=!i),o=i&&c==="\\"&&!o,c===","&&!i?(t.push(n.trim()),n=""):n+=c;return n.trim()&&t.push(n.trim()),t}function $S(e){if(!/^[\w-]+$/.test(e))throw new Error(`invalid frontmatter key: ${JSON.stringify(e)}`);return e}function Eu(e,t){return`---
81
+ ${Object.entries(e).map(([i,o])=>`${$S(i)}: ${Array.isArray(o)?`[${o.map(Ep).join(", ")}]`:Ep(o)}`).join(`
82
+ `)}
83
+ ---
84
+
85
+ ${t.trim()}
86
+ `}const ke=e=>Array.isArray(e)?e.join(","):e??"";function ft(e){return Array.isArray(e)?e:e?[e]:[]}const ci=e=>Date.parse(ke(e))||0,pn=e=>new Date(e).toISOString(),tv=["schema","breaking-api","auth-permissions","billing","data-deletion","product-behaviour","dependencies"],nv=["low","medium","high"],CS=e=>tv.includes(e),TS=e=>nv.includes(e);function ES(e){return e?{risk:e.level,...e.category?{risk_category:e.category}:{},risk_reason:e.reason}:{}}function AS(e){const t=ke(e.risk);if(!TS(t))return{};const n=ke(e.risk_category);return{risk:{level:t,...CS(n)?{category:n}:{},reason:ke(e.risk_reason)}}}const sv=["Question","Decision","Summary","Alternatives","Rationale","Transcript"],Au=`## (?:${sv.join("|")})\\s*$`,iv=`${Au}|### `,qo=e=>Oa(e.trim(),Au),IS=e=>e.name?`${e.id}|${e.name}`:e.id,RS=e=>{const t=e.indexOf("|");return t<0?{id:e}:{id:e.slice(0,t),name:e.slice(t+1)}};function rv(e){var c;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:js(e.decidedByName).slice(0,100)}:{},decided_at:pn(e.decidedAt),participants:e.participants.map(IS),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,u])=>`${d}=${u}`)}:{},...e.supersedes?{supersedes:e.supersedes}:{},...e.supersededBy?{superseded_by:e.supersededBy}:{},...ES(e.risk),...(c=e.assumes)!=null&&c.length?{assumes:e.assumes}:{}},n=d=>d.length?d.map(u=>`- ${js(u)}`).join(`
87
+ `):"_None._",i=e.transcript.length?e.transcript.map(d=>`### ${js(d.author)} · ${d.from} @ ${pn(d.at)}
88
+
89
+ ${Oa(d.text.trim(),iv)}`).join(`
90
+
91
+ `):"_None._",o=[`## Question
92
+
93
+ ${qo(e.question)}`,`## Decision
94
+
95
+ ${qo(e.answer)}`,`## Summary
96
+
97
+ ${qo(e.summary)}`,`## Alternatives
98
+
99
+ ${n(e.alternatives)}`,`## Rationale
100
+
101
+ ${qo(e.rationale)||"_None._"}`,`## Transcript
102
+
103
+ ${i}`].join(`
104
+
105
+ `);return Eu(t,o)}function zd(e){const{front:t,body:n}=Fa(e),i={},o=new RegExp(`^## (${sv.join("|")})\\s*$`,"gm"),c=[...n.matchAll(o)];c.forEach((k,y)=>{var $;const b=n.slice(k.index+k[0].length,(($=c[y+1])==null?void 0:$.index)??n.length).trim(),S=k[1],x=S==="Transcript"?b:fa(b,Au);i[S]=/^_none\._$/i.test(b)?"":x});const d=(i.Transcript??"").split(/^### /m).slice(1).map(k=>{const y=k.indexOf(`
106
+ `),b=y<0?k:k.slice(0,y),S=b.lastIndexOf(" @ "),x=S<0?b:b.slice(0,S),$=S<0?"":b.slice(S+3),N=x.lastIndexOf(" · "),O=N<0?x:x.slice(0,N),D=N<0?"agent":x.slice(N+3);return{author:O.trim(),from:["agent","human","system"].includes(D.trim())?D.trim():"agent",at:Date.parse($)||0,text:y<0?"":fa(k.slice(y+1).trim(),iv)}}),u=ke(t.source),f=ft(t.source_meta),m={kind:Ob(u)?u:"tracker",...ke(t.source_ref)?{ref:ke(t.source_ref)}:{},...ke(t.source_url)?{url:ke(t.source_url)}:{},...ke(t.source_label)?{label:ke(t.source_label)}:{},...f.length?{meta:Object.fromEntries(f.map(k=>[k.slice(0,k.indexOf("=")),k.slice(k.indexOf("=")+1)]))}:{}},g=i.Decision??"";return{id:ke(t.id),mapId:ke(t.trail),ticketId:ke(t.ticket)||void 0,ticketKey:ke(t.ticket_key)||void 0,question:i.Question??"",answer:g,summary:i.Summary||Ba(g),alternatives:(i.Alternatives??"").split(`
107
+ `).map(k=>k.trim()).filter(k=>k.startsWith("- ")).map(k=>k.slice(2)),rationale:i.Rationale??"",decidedBy:ke(t.decided_by),...ke(t.decided_by_name)?{decidedByName:ke(t.decided_by_name)}:{},decidedAt:ci(t.decided_at),participants:ft(t.participants).map(RS),source:m,supersedes:ke(t.supersedes)||void 0,supersededBy:ke(t.superseded_by)||void 0,...ft(t.assumes).length?{assumes:ft(t.assumes)}:{},transcript:d,...AS(t)}}function MS(e){return e.url?` · [${e.label??"link"}](${e.url})`:e.label?` · ${e.label}`:""}function LS(e,t,n={}){const i=[`# ${n.title??"Decisions"}`,"",`Exported ${pn(n.now??Date.now())} · ${e.length} decisions`],o=new Map;for(const c of e)o.set(c.mapId,[...o.get(c.mapId)??[],c]);for(const[c,d]of o){const u=t[c];i.push("",`## Trail ${u?`${u.key} ${u.title}`:c}`);for(const f of d){const m=ts[f.source.kind].label;i.push("",`### ${f.id}${f.ticketKey?` · ${f.ticketKey}`:""} · ${f.question}`,"",`- **Status:** ${Er(f)}${f.supersededBy?` (superseded by ${f.supersededBy})`:""}${f.supersedes?` · supersedes ${f.supersedes}`:""}`,`- **Decided by:** ${f.decidedBy} · ${pn(f.decidedAt)}`,`- **Source:** ${m}${MS(f.source)}`,...f.participants.length?[`- **Participants:** ${f.participants.map(g=>g.name??g.id).join(", ")}`]:[],"",`**Decision:** ${f.answer}`,...f.alternatives.length?["","**Alternatives:**",...f.alternatives.map(g=>`- ${g}`)]:[],...f.rationale?["",`**Rationale:** ${f.rationale}`]:[],...f.transcript.length?["","<details><summary>Transcript</summary>","",...f.transcript.map(g=>`> **${g.author}:** ${g.text.replace(/\n/g,`
108
+ > `)}
109
+ >`),"","</details>"]:[])}}return i.join(`
110
+ `)+`
111
+ `}function Ud(e,t,n){try{const i=e.get(t);return i?JSON.parse(i):n}catch{return n}}class Ip{constructor(t,n="presence"){oe(this,"seen");this.store=t,this.key=n,this.seen=Ud(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 i=!1;for(const o of t)(this.seen[o]??0)>=n||(this.seen[o]=n,i=!0);i&&this.store.set(this.key,JSON.stringify(this.seen))}}const cd=5*6e4,OS=14*864e5;class Rp{constructor(t,n="usage"){oe(this,"buckets");oe(this,"dirty",!1);oe(this,"timer");oe(this,"totals");this.store=t,this.key=n,this.buckets=Ud(t,n,{}),this.totals=Ud(t,`${n}.totals`,{})}addTotal(t,n,i,o=Date.now()){const c=this.totals[n],d={inputTokens:i.inputTokens-((c==null?void 0:c.inputTokens)??0),outputTokens:i.outputTokens-((c==null?void 0:c.outputTokens)??0),costUsd:i.costUsd-((c==null?void 0:c.costUsd)??0)};this.totals[n]={...i,at:o},d.inputTokens>0||d.outputTokens>0||d.costUsd>0?this.add(t,d,n,o):this.save()}add(t,n,i,o=Date.now()){var f;if(!t)return;const c=Math.floor(o/cd)*cd,d=(f=this.buckets)[t]??(f[t]=[]);let u=d.find(m=>m.at===c);u||(u={at:c,i:0,o:0,c:0,s:[]},d.push(u),d.sort((m,g)=>m.at-g.at)),u.i+=n.inputTokens,u.o+=n.outputTokens,u.c+=n.costUsd,u.s.includes(i)||u.s.push(i),this.save()}since(t,n){const i={inputTokens:0,outputTokens:0,costUsd:0,sessions:0},o=new Set;for(const c of this.buckets[t]??[])c.at+cd<=n||(i.inputTokens+=c.i,i.outputTokens+=c.o,i.costUsd+=c.c,c.s.forEach(d=>o.add(d)));return i.sessions=o.size,i}save(){this.dirty=!0,!this.timer&&(this.timer=setTimeout(()=>{if(this.timer=void 0,!this.dirty)return;this.dirty=!1;const t=Date.now()-OS;for(const n of Object.keys(this.buckets))this.buckets[n]=this.buckets[n].filter(i=>i.at>=t);for(const[n,i]of Object.entries(this.totals))i.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 PS(e){const t=e.now??Date.now(),n=e.snaps.map(d=>{var Z;const u=d.map.id,f=e.since(u),m=q=>!!q&&q>=f,g=Ts(d.tickets,d.map.mode),k=new Map(d.tickets.map(q=>[q.id,q])),y=(e.attention??[]).filter(q=>q.mapId===u),b=DS(e.activity.pending.filter(q=>q.mapId===u),y),S=new Set(b.map(q=>q.ticketId)),x=q=>q.state==="open"&&(S.has(q.id)||gi(q)==="hitl"),$=d.tickets.filter(q=>g.get(q.id)==="blocked").map(q=>({ticket:q,on:q.blockedBy.map(ee=>k.get(ee)).filter(ee=>!!ee&&x(ee))})).filter(q=>q.on.length),N=e.decisions.filter(q=>q.mapId===u&&m(q.decidedAt)).sort((q,ee)=>ee.decidedAt-q.decidedAt),O=d.tickets.filter(q=>q.state==="closed"&&m(q.closedAt)).sort((q,ee)=>(q.closedAt??0)-(ee.closedAt??0)),D=O.filter(q=>q.closeReason==="completed"),F=O.filter(q=>q.closeReason==="not_planned"),K=d.tickets.filter(q=>m(q.createdAt)),I=((Z=e.ledger)==null?void 0:Z.since(u,f))??{inputTokens:0,outputTokens:0,costUsd:0,sessions:0},Q=e.activity.sessions.filter(q=>q.mapId===u&&q.status==="running");return{mapId:u,key:d.map.key,title:d.map.title,since:f,done:D,ruledOut:F,opened:K,blocked:$,waiting:b,needsYou:y,decisions:N,agentDecisions:N.filter(q=>jr(q)==="agent"),usage:I,active:Q,changed:!!(O.length||K.length||N.length||b.some(q=>m(q.at))||I.costUsd>0)}}),i=n.filter(d=>d.changed||d.waiting.length).sort((d,u)=>+(u.mapId===e.currentMapId)-+(d.mapId===e.currentMapId)),o=d=>i.reduce((u,f)=>u+f[d].length,0),c=i.flatMap(d=>d.waiting).reduce((d,u)=>d===void 0||u.at<d?u.at:d,void 0);return{since:i.length?Math.min(...i.map(d=>d.since)):t,now:t,trails:i,totals:{done:o("done"),ruledOut:o("ruledOut"),blocked:o("blocked"),waiting:o("waiting"),oldestWaitMs:c===void 0?void 0:t-c,agentDecisions:o("agentDecisions"),usage:i.reduce((d,u)=>({inputTokens:d.inputTokens+u.usage.inputTokens,outputTokens:d.outputTokens+u.usage.outputTokens,costUsd:d.costUsd+u.usage.costUsd,sessions:d.sessions+u.usage.sessions}),{inputTokens:0,outputTokens:0,costUsd:0,sessions:0}),active:o("active")},changed:n.some(d=>d.changed)}}function DS(e,t){const n=new Map(t.filter(o=>o.kind==="question").map((o,c)=>[o.ref,c])),i=o=>n.get(o.id)??Number.MAX_SAFE_INTEGER;return[...e].sort((o,c)=>i(o)-i(c)||o.at-c.at)}const pr=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`;function _S(e){return e.trails.flatMap(t=>{const n=new Set(t.waiting.map(i=>i.ticketId));return t.blocked.filter(i=>i.on.some(o=>n.has(o.id)))})}function BS(e){return e.length===1?`, and it holds up ${e[0].ticket.title.replace(/^./,t=>t.toLowerCase())}`:e.length>1?`, holding up ${pr(e.length,"ticket")}`:""}function FS(e,t=new Date(e.now).getHours()){const n=e.totals,o=e.now-e.since>=6*36e5&&t>=5&&t<12?"Good morning.":"Welcome back.",c=[];if(n.done&&c.push(`${pr(n.done,"ticket")} ${n.done===1?"is":"are"} done.`),n.agentDecisions&&c.push(`Agents made ${pr(n.agentDecisions,"decision")}.`),n.waiting){const d=BS(_S(e));c.push(`${pr(n.waiting,"decision")} ${n.waiting===1?"is":"are"} waiting on you${d}.`)}else c.push("Nothing is waiting on you.");return!n.done&&!n.agentDecisions&&n.ruledOut&&c.unshift(`${pr(n.ruledOut,"ticket")} ruled out of scope.`),[o,...c].join(" ")}const zS=e=>{if(!e.length)return;const t=[...e].sort((i,o)=>i-o),n=Math.floor(t.length/2);return t.length%2?t[n]:Math.round((t[n-1]+t[n])/2)};function US(e){return e.state==="open"?"open":e.closeReason==="not_planned"?"cancelled":"done"}function ov({snap:e,journal:t,answered:n,usage:i}){const o=e.map.id,c=t.filter(x=>x.mapId===o).sort((x,$)=>x.at-$.at),d=new Map;for(const x of c)d.set(x.ticketId,[...d.get(x.ticketId)??[],x]);const u=e.tickets.filter(x=>x.type!=="review").map(x=>{var F;const $=d.get(x.id)??[],N=US(x),O=(F=$.find(K=>K.event==="claim"))==null?void 0:F.at,D=N==="done"?x.closedAt:void 0;return{id:x.id,key:x.key,title:x.title,type:x.type,outcome:N,claimedAt:O,doneAt:D,leadMs:D&&O&&D>=O?D-O:void 0,reworks:$.filter(K=>K.to==="rework").length,reviews:{passed:$.filter(K=>K.event==="review.pass").length,failed:$.filter(K=>K.event==="review.fail").length,needsHuman:$.filter(K=>K.event==="review.needs_human").length},operatorActions:$.filter(K=>K.actorKind==="trail lead").length}}),f=u.filter(x=>x.outcome==="done"),m=Math.max(0,...f.map(x=>x.doneAt??0)),g=c.filter(x=>x.actorKind==="trail lead"),k=new Set(n.filter(x=>x.mapId===o).map(x=>x.id)).size,y=g.length,b=x=>u.reduce(($,N)=>$+x(N),0),S=(i==null?void 0:i.costUsd)??0;return{mapId:o,tickets:u,done:f.length,cancelled:u.filter(x=>x.outcome==="cancelled").length,open:u.filter(x=>x.outcome==="open").length,trailLeadMs:m&&m>=e.map.createdAt?m-e.map.createdAt:void 0,medianLeadMs:zS(f.flatMap(x=>x.leadMs===void 0?[]:[x.leadMs])),interventions:{answers:k,operatorActions:y,reworkRequested:g.filter(x=>x.event==="reject").length,total:k+y},rework:{tickets:u.filter(x=>x.reworks>0).length,cycles:b(x=>x.reworks)},reviews:{passed:b(x=>x.reviews.passed),failed:b(x=>x.reviews.failed),needsHuman:b(x=>x.reviews.needsHuman)},spend:{costUsd:Math.round(S*1e4)/1e4,tokens:((i==null?void 0:i.inputTokens)??0)+((i==null?void 0:i.outputTokens)??0),perVerifiedTicketUsd:f.length&&S?Math.round(S/f.length*1e4)/1e4:void 0}}}const ld=e=>e.split("-")[0];function rn(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 Mp=e=>e===void 0?"—":`$${e.toFixed(e<1?4:2)}`;function WS(e,t,n=Date.now()){const i=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) | ${rn(e.trailLeadMs)} |`,`| Median ticket lead time (claim → done) | ${rn(e.medianLeadMs)} |`,`| Human interventions | ${i.total} (${i.answers} answers, ${i.operatorActions} operator actions, ${i.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 | ${Mp(e.spend.costUsd)} · ${e.spend.tokens.toLocaleString("en-US")} tokens |`,`| Cost per verified ticket | ${Mp(e.spend.perVerifiedTicketUsd)} |`,"","## Tickets","","| Ticket | Type | Outcome | Lead time | Rework | Reviews (pass/fail) | Operator actions |","| --- | --- | --- | --- | --- | --- | --- |",...e.tickets.map(c=>`| ${c.key} ${c.title.replace(/\|/g,"\\|")} | ${c.type} | ${c.outcome} | ${rn(c.leadMs)} | ${c.reworks} | ${c.reviews.passed}/${c.reviews.failed} | ${c.operatorActions} |`),""].join(`
112
+ `)}const Iu=5,av=1.5,HS=15,Qo=e=>Math.round(e*100);function KS(e){const t=e.filter(d=>d.findings.raised>=Iu).sort((d,u)=>u.findings.upheld/u.findings.raised-d.findings.upheld/d.findings.raised||d.key.localeCompare(u.key));if(t.length<2)return[];const[n,i]=[t[0],t[t.length-1]],[o,c]=[n.findings.upheld/n.findings.raised,i.findings.upheld/i.findings.raised];return Qo(o)-Qo(c)<HS?[]:[{id:"review-findings",text:`${n.key} review findings upheld ${Qo(o)}% vs ${i.key} ${Qo(c)}%`,because:`${n.findings.upheld} of ${n.findings.raised} and ${i.findings.upheld} of ${i.findings.raised} failed reviews stood; a finding is overruled when you accept the work anyway`}]}function GS(e){const t=c=>c.reworkCycles/c.tickets,n=e.filter(c=>c.tickets>=Iu).sort((c,d)=>t(c)-t(d)||c.key.localeCompare(d.key));if(n.length<2)return[];const[i,o]=[n[0],n[n.length-1]];return t(o)-t(i)<.2||t(o)<t(i)*av?[]:[{id:"rework",text:`${o.key} work goes back to rework more: ${t(o).toFixed(1)} times per ticket vs ${i.key} ${t(i).toFixed(1)}`,because:`${o.reworkCycles} cycles on ${o.tickets} tickets, and ${i.reworkCycles} on ${i.tickets}`}]}function VS(e,t){const n=d=>d.medianLeadMs??0,i=t.filter(d=>d.done>=Iu&&d.medianLeadMs!==void 0).sort((d,u)=>n(d)-n(u)||d.key.localeCompare(u.key));if(i.length<2)return[];const[o,c]=[i[0],i[i.length-1]];return n(c)<n(o)*av?[]:[{id:`speed-${e}`,text:`${e} tickets: ${o.key} is faster, ${rn(o.medianLeadMs)} vs ${c.key} ${rn(c.medianLeadMs)}`,because:`Median first claim to done, over ${o.done} and ${c.done} done tickets`}]}function qS(e){const t=Object.keys(e.byTypeAndVendor).sort();return[...KS(e.byVendor),...GS(e.byVendor),...t.flatMap(n=>VS(n,e.byTypeAndVendor[n]))]}const QS=e=>{if(!e.length)return;const t=[...e].sort((i,o)=>i-o),n=Math.floor(t.length/2);return t.length%2?t[n]:Math.round((t[n-1]+t[n])/2)},cv=e=>{var t;return(t=e.filter(n=>n.event==="claim"&&n.actorKind==="agent").at(-1))==null?void 0:t.actor},Wd=(e,t,n)=>e.filter(i=>i.mapId===t&&i.ticketId===n).sort((i,o)=>i.at-o.at);function YS(e,t){return e.tickets.flatMap(n=>{var k;if(n.type!=="review"||!n.reviewOf)return[];const i=Wd(t,e.map.id,n.id),o=cv(i);if(!o)return[];const c=((k=i.filter(y=>y.event==="claim").at(-1))==null?void 0:k.at)??0,d=Wd(t,e.map.id,n.reviewOf),u=d.findIndex(y=>y.at>=c&&y.event.startsWith("review."));if(u<0||d[u].event!=="review.fail")return[];const f=d.slice(u+1),m=f.findIndex(y=>y.event.startsWith("review.")),g=m<0?f:f.slice(0,m);return[{reviewer:o,upheld:!g.some(y=>y.event==="accept"&&y.actorKind==="trail lead")}]})}function JS(e,t){var i;const n=(i=e.tickets.find(o=>o.id===t))==null?void 0:i.assignee;return n&&/^[a-z]+-\d+$/.test(n)?n:void 0}function lv(e,t){const n=o=>t.reduce((c,{ticket:d})=>c+o(d),0),i=o=>t.filter(c=>c.ticket.outcome===o).length;return{key:e,tickets:t.length,done:i("done"),cancelled:i("cancelled"),open:i("open"),medianLeadMs:QS(t.flatMap(({ticket:o})=>o.leadMs===void 0?[]:[o.leadMs])),reworkCycles:n(o=>o.reworks),reviews:{passed:n(o=>o.reviews.passed),failed:n(o=>o.reviews.failed),needsHuman:n(o=>o.reviews.needsHuman)},answers:0,findings:{raised:0,upheld:0}}}function Yo(e,t){const n=new Map;for(const i of e){const o=t(i);o&&n.set(o,[...n.get(o)??[],i])}return new Map([...n].map(([i,o])=>[i,lv(i,o)]))}const Hd=(e,t)=>{const n=e.get(t)??lv(t,[]);return e.set(t,n),n};function Lp(e,t,n){const i=Hd(e,t);i.findings.raised+=1,n&&(i.findings.upheld+=1)}const Jo=e=>[...e.values()].sort((t,n)=>n.tickets-t.tickets||t.key.localeCompare(n.key));function dv(e){const t=e.flatMap(({snap:m,journal:g,answered:k,usage:y})=>ov({snap:m,journal:g,answered:k,usage:y}).tickets.map(b=>({ticket:b,agent:cv(Wd(g,m.map.id,b.id))??JS(m,b.id)}))),n=m=>m.agent?ld(m.agent):void 0,i=Yo(t,m=>m.agent),o=Yo(t,n),c=Yo(t,m=>m.ticket.type),d=new Set;for(const{snap:m,journal:g,answered:k}of e){for(const y of k){const b=`${y.mapId}/${y.id}`;y.mapId!==m.map.id||d.has(b)||(d.add(b),Hd(i,y.agent).answers+=1,Hd(o,ld(y.agent)).answers+=1)}for(const y of YS(m,g))Lp(i,y.reviewer,y.upheld),Lp(o,ld(y.reviewer),y.upheld)}const u=Object.fromEntries([...c.keys()].map(m=>[m,Jo(Yo(t.filter(g=>g.ticket.type===m),n))])),f={trails:e.length,tickets:t.length,byAgent:Jo(i),byVendor:Jo(o),byType:Jo(c),byTypeAndVendor:u};return{...f,recommendations:qS(f)}}const uv=["research","junction","review"],XS={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
+ `)},ZS=[["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"]],ur=Object.fromEntries(ZS),hv=["task","execute","prototype"];function eN(e,t){const n=new Set(e.map(i=>i.source).filter(Boolean));return t.filter(i=>!n.has(i))}const tN=["architecture","convention","gotcha","dead-end","glossary","fact"],fv=["business-rule","product-decision","persona","ux-principle","pricing"],nN=[...tN,...fv],sN=e=>e.status==="confirmed"||e.status==="assumption";function iN(e,t){return Mk(e,t.replace(/^\.\//,""),{segments:!0})}const rN={"business-rule":3,convention:3,"product-decision":2,architecture:2,gotcha:2,"dead-end":2,"ux-principle":2},oN=["business-rule","ux-principle","convention"],Op=600,aN=e=>`flagged as possibly outdated by ${e}; the human is reviewing it`,cN=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(" ")),Pp=e=>new Set((e.toLowerCase().match(/[a-z0-9][a-z0-9_-]{2,}/g)??[]).filter(t=>!cN.has(t)));function mv(e,t,n=4e3,i=()=>[]){const o=t.ticket?Pp(`${t.ticket.title} ${t.ticket.body}`):new Set,c=new Set((t.tags??[]).map(m=>m.toLowerCase())),d=e.filter(sN).map(m=>{const g=[];let k=rN[m.kind]??1;for(const S of m.scope){const x=t.paths.find($=>iN(S,$));if(x){k+=6,g.push(`path match ${S} (${x})`);break}}const y=m.tags.filter(S=>c.has(S.toLowerCase())||o.has(S.toLowerCase()));y.length&&(k+=3*y.length,g.push(`tag ${y.join(", ")}`));const b=[...Pp(m.title)].filter(S=>o.has(S));return b.length&&(k+=b.length,g.push(`mentions ${b.slice(0,3).join(", ")}`)),t.trailKey&&m.sources.includes(`trail:${t.trailKey}`)&&(k+=3,g.push("same trail")),t.discovery&&fv.includes(m.kind)&&(k+=8,g.push("product context for discovery")),!g.length&&oN.includes(m.kind)&&!m.scope.length&&g.push(`${m.kind.replace("-"," ")} for the whole project`),{e:m,score:k,why:g}}).filter(m=>m.why.length>0).sort((m,g)=>g.score-m.score||m.e.id.localeCompare(g.e.id,void 0,{numeric:!0})),u=[];let f=0;for(const{e:m,why:g}of d){const k=m.body.length>Op?`${m.body.slice(0,Op)}…`:m.body;if(f+k.length>n&&u.length)break;f+=k.length;const y=i(m);u.push({id:m.id,title:m.title,kind:m.kind,status:m.status,body:k,why:g,...y.length?{mayBeOutdated:y}:{},...m.flag?{flagged:aN(m.flag.by)}:{}})}return u}const lN=new RegExp("`([^`\\s]+/[^`\\s]+)`|(?:^|[\\s(])/?((?:[\\w.-]+/)+[\\w.-]+)","gm");function pv(e){const t=new Set;for(const n of e.matchAll(lN))t.add((n[1]??n[2]).replace(/^\.?\//,"").replace(/[.,;:]+$/,""));return[...t]}const dN=[{level:"high",label:"High risk"},{level:"medium",label:"Medium risk"},{level:"low",label:"Low risk"},{level:"none",label:"No category"}];function uN(e){return dN.map(t=>({...t,decisions:e.filter(n=>{var i;return(((i=n.risk)==null?void 0:i.level)??"none")===t.level})})).filter(t=>t.decisions.length)}const hN=1/3;function Es(e,t=Date.now()){const n=e.expiresAt-t;return n<=0?"expired":n<=e.ttlMs*hN?"stalled":"live"}function fN(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 mN=e=>e.urgency==="fyi"||e.kind==="policy"||e.kind==="escape";function pN(e){const t=e.filter(([n,i])=>rs.includes(n)&&Rk(i));return Object.fromEntries(t)}const Dp=e=>Number(e.slice(0,2))*60+Number(e.slice(3,5));function gN(e,t){const n=new Date(t),i=n.getHours()*60+n.getMinutes(),o=Dp(e.from),c=Dp(e.to),d=c<=o;if(!(d?i>=o||i<c:i>=o&&i<c))return!1;if(!e.days)return!0;const f=d&&i<c,m=(n.getDay()+(f?6:0))%7;return e.days.includes(m)}function kN(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 vN(e,t){const n=e.focusUntil??0;if(n>t)return{kind:"manual",until:n};if(!e.focus||!gN(e.focus,t))return{kind:"off"};const i=kN(e.focus,t);return(e.focusOffUntil??0)>t?{kind:"paused",until:i}:{kind:"hours",until:i}}function wN(e,t,n){const i={...e};switch(delete i.focusUntil,delete i.focusOffUntil,t.kind){case"for":return{...i,focusUntil:n+t.minutes*6e4};case"resume":return i;case"end":{const o=vN(i,n);return o.kind==="hours"?{...i,focusOffUntil:o.until}:i}default:return t}}const yN=e=>({id:e.id,key:e.key,title:e.title,...e.archived?{archived:!0}:{}});function xN(e,t){var i;const n={...e};return t.verification===null?delete n.verification:t.verification&&(n.verification=t.verification),t.guides===null||((i=t.guides)==null?void 0:i.length)===0?delete n.guides:t.guides&&(n.guides=t.guides),t.guidesByType===null?delete n.guidesByType:t.guidesByType&&(n.guidesByType=t.guidesByType),t.modelMatching===null?delete n.modelMatching:t.modelMatching&&(n.modelMatching=t.modelMatching),t.confirm&&delete n.settingsUnconfirmed,n}function jN(e,t,n){const i=Date.now();return{id:e,key:t,...n,state:"open",blockedBy:[],comments:[],createdAt:i,updatedAt:i}}const bN=(e,t)=>({...e,blockedBy:e.blockedBy.filter(n=>n!==t)}),SN=(e,t)=>{var n;return{...e,...(n=t.title)!=null&&n.trim()?{title:t.title.trim()}:{},...t.body!==void 0?{body:t.body}:{}}};function NN(e){const{closeReason:t,closedAt:n,...i}=e;return{...i,state:"open"}}const $N=["status","verification","checks","reviewOf","guide","guidesAdded","guidesRemoved"];function CN(e,t){const n={...e};for(const i of $N)t[i]!==void 0&&(t[i]===null?delete n[i]:n[i]=t[i]);return t.confirm&&delete n.settingsUnconfirmed,n}function TN(e,t){const n={...e};return t?n.archived=!0:delete n.archived,n}async function gv(e){const t=await e.list(),n=t.filter(o=>!o.includes("/decisions/")).map(o=>{var c;return Number(((c=o.match(/(\d+)\.md$/))==null?void 0:c[1])??0)}),i=await Promise.all(t.filter(o=>o.endsWith("/map.md")).map(async o=>Number(ke(Fa(await e.read(o)).front.key).replace(/\D/g,""))||0));return Math.max(0,...n,...i)+1}const kv="### [^\\n]* @ \\d{4}-\\d\\d-\\d\\dT",vv=`## Comments\\s*$|${kv}`,wv=`<!-- ${J.labelPrefix}:comments -->`,EN=new RegExp(`^## Comments[ \\t]*\\n${wv}[ \\t]*$`,"m"),AN=new RegExp(`^(?=${kv})### `,"m"),Ru=2,yv=e=>Pa(Oa(e,vv)),_p=e=>fa(ai(e),vv);function IN(e,t){const n=(t>=Ru?EN:/^## Comments\s*$/m).exec(e);return n?[e.slice(0,n.index),e.slice(n.index+n[0].length)]:[e,""]}function Bp(e){const{front:t,body:n}=Fa(e),i=Number(ke(t.format))||1,[o,c]=IN(n,i),d=c.split(i>=Ru?AN:/^### /m).slice(1).map((g,k)=>{const y=g.indexOf(`
114
+ `),b=g.slice(0,y),S=b.lastIndexOf(" @ ");return{id:`c${k}`,author:b.slice(0,S<0?void 0:S).trim(),createdAt:S>=0&&Date.parse(b.slice(S+3))||0,body:_p(g.slice(y+1).trim())}}),u=ke(t.close_reason),f=u0.find(g=>g===ke(t.status)),m=Ek(ke(t.verification));return{id:ke(t.id),key:`#${ke(t.id)}`,title:ke(t.title),type:ke(t.type)||"task",hitl:ft(t.labels).includes(xu)||void 0,state:ke(t.state)==="closed"?"closed":"open",closeReason:u==="completed"||u==="not_planned"?u:void 0,assignee:ke(t.assignee)||void 0,...f?{status:f}:{},...m?{verification:m}:{},...t.checks!==void 0?{checks:ft(t.checks)}:{},...ke(t.review_of)?{reviewOf:ke(t.review_of)}:{},...ke(t.guide)?{guide:ke(t.guide)}:{},...ft(t.guides_added).length?{guidesAdded:ft(t.guides_added)}:{},...ft(t.guides_removed).length?{guidesRemoved:ft(t.guides_removed)}:{},blockedBy:ft(t.blocked_by),body:_p(o.trim()),comments:d,createdAt:ci(t.created),updatedAt:ci(t.updated),closedAt:ci(t.closed)||void 0}}function xv(e){var i,o;const t={id:e.id,format:String(Ru),title:e.title,type:e.type,labels:[La(e.type),...o0(e.type)&&e.hitl?[xu]:[]],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}:{},...(i=e.guidesAdded)!=null&&i.length?{guides_added:e.guidesAdded}:{},...(o=e.guidesRemoved)!=null&&o.length?{guides_removed:e.guidesRemoved}:{},blocked_by:e.blockedBy,created:pn(e.createdAt),updated:pn(e.updatedAt),...e.closedAt?{closed:pn(e.closedAt)}:{}},n=e.comments.length?`
115
+
116
+ ## Comments
117
+ ${wv}
118
+
119
+ ${e.comments.map(RN).join(`
120
+
121
+ `)}`:"";return Eu(t,yv(e.body)+n)}function RN(e){return`### ${js(e.author)} @ ${pn(e.createdAt)}
122
+
123
+ ${yv(e.body)}`}async function MN(e,t,n){for(let i=0;;i++){const o=await t();if(n(o.path),!e.create)return await e.write(o.path,o.text),o.value;if(await e.create(o.path,o.text))return o.value;if(i>=50)throw new Error(`could not allocate ${o.path}`)}}async function LN(e,t,n){const i=await gv(e),o=jN(String(i),`#${i}`,n);return{path:`${t}/tickets/${o.id}.md`,text:xv({...o,updatedAt:Date.now()}),value:o}}async function ON(e,t,n){const i=(await e.list()).filter(d=>d.includes("/decisions/")),o=Math.max(0,...i.map(d=>Db(d.split("/").pop())))+1,c=Pb(`D-${o}`,t,n);return{path:`${t}/decisions/${c.id}.md`,text:rv(c),value:c}}const PN=/^([^/]+)\/decisions\/([^/]+)\.md$/,DN=(e,t)=>e.toLowerCase().replace(/[^a-z0-9]+/g,"-").slice(0,40).replace(/^-+|-+$/g,"")||`map-${t}`,jv=/^[A-Za-z0-9][A-Za-z0-9_-]*(?:\.[A-Za-z0-9_-]+)*$/;function xs(e){if(typeof e!="string"||e.length>128||!jv.test(e))throw new Error(`not a valid id: ${JSON.stringify(e)}`);return e}const _N=e=>{const t=e.match(/^[^/]+\/tickets\/([^/]+)\.md$/);return!!t&&jv.test(t[1])};class BN{constructor(t,n){oe(this,"seen",new Map);oe(this,"pending",new Map);this.read=t,this.emit=n}knows(t){return this.seen.has(t)}remember(t,n,i){this.seen.set(t,{text:n,supersededBy:i})}queue(t){const n=t.split("/")[0],i=this.pending.get(n)??{paths:new Set,timer:setTimeout(()=>void this.flush(n),250)};i.paths.add(t),this.pending.set(n,i)}async flush(t){const n=this.pending.get(t);if(this.pending.delete(t),!n)return;const i=[...n.paths].filter(d=>PN.test(d)),o=[];for(const d of i){const u=await this.read(d).catch(()=>""),f=this.seen.get(d);if(!u||(f==null?void 0:f.text)===u)continue;const m=zd(u);this.seen.set(d,{text:u,supersededBy:m.supersededBy}),f?m.supersededBy&&m.supersededBy!==f.supersededBy&&o.push({kind:"decision.superseded",mapId:t,decisionId:m.id,supersededBy:m.supersededBy,external:!0,at:Date.now()}):o.push({kind:"decision.recorded",mapId:t,decisionId:m.id,ticketId:m.ticketId,external:!0,at:Date.now()})}i.length?!o.length&&i.length<n.paths.size&&o.push({kind:"external.changed",mapId:t,at:Date.now()}):o.push({kind:"external.changed",mapId:t,at:Date.now()});const c=d=>d.kind==="decision.recorded"?0:1;o.sort((d,u)=>c(d)-c(u));for(const d of o)this.emit(d)}}const Kd="guides-by-type";function FN(e){if(e[Kd]===void 0)return;const t={};for(const n of ft(e[Kd])){const[i,o]=n.split("=").map(d=>d.trim());if(!o||!rs.includes(i))continue;const c=t[i]??[];c.includes(o)||(t[i]=[...c,o])}return t}function zN(e){if(!e)return{};const t=rs.flatMap(n=>(e[n]??[]).map(i=>`${n}=${i}`));return{[Kd]:t}}function UN(e){const t=ke(e["model-matching"]);if(t!=="on"&&t!=="off")return;const n=pN(ft(e["model-tiers"]).map(i=>i.split("=").map(o=>o.trim())));return Object.keys(n).length?{enabled:t==="on",tiers:n}:{enabled:t==="on"}}function WN(e){if(!e)return{};const t=Object.entries(e.tiers??{}).map(([n,i])=>`${n}=${i}`);return{"model-matching":e.enabled?"on":"off",...t.length?{"model-tiers":t}:{}}}function Fp(e,t){const{front:n,body:i}=Fa(t),o=Ek(ke(n.verification)),c=UN(n),d=FN(n);return{id:e,key:ke(n.key)||e,title:ke(n.title)||e,mode:ke(n.mode)==="plan-only"||ft(n.labels).includes(ju)?"plan-only":Cs,...o?{verification:o}:{},...ft(n.guides).length?{guides:ft(n.guides)}:{},...d?{guidesByType:d}:{},...c?{modelMatching:c}:{},...ke(n.archived)==="true"?{archived:!0}:{},sections:pb(i),createdAt:ci(n.created),updatedAt:ci(n.updated)}}function Gd(e){var t;return Eu({key:e.key,title:e.title,mode:e.mode,...e.verification?{verification:e.verification}:{},...(t=e.guides)!=null&&t.length?{guides:e.guides}:{},...zN(e.guidesByType),...WN(e.modelMatching),...e.archived?{archived:"true"}:{},labels:[yu,...e.mode==="plan-only"?[ju]:[]],created:pn(e.createdAt),updated:pn(e.updatedAt)},mb(e.sections))}const HN=new Set(["briefs","criteria","knowledge","guides","proof-keys"]),KN=200;function GN(e,t){return HN.has(e)?!0:t.some(n=>n.startsWith(`${e}/`)||n===`briefs/${e}.md`||n===`criteria/${e}.md`)}const VN=(e,t,n)=>({id:e,key:`#${t}`,title:n.title,mode:n.mode??Cs,...n.verification?{verification:n.verification}:{},sections:n.sections,createdAt:Date.now(),updatedAt:Date.now()});async function qN(e,t,n){const i=await gv(e),o=DN(t.title,i),c=await e.list();for(let d=1;d<=KN;d++){const u=d===1?o:`${o}-${d}`;if(GN(u,c))continue;const f=VN(u,i,t),m=`${u}/map.md`;if(n(m),!e.create)return await e.write(m,Gd(f)),f;if(await e.create(m,Gd(f)))return f}throw new Error(`could not find a free folder for the trail ${JSON.stringify(o)}`)}function QN(e,t){t.code!=="ENOENT"&&console.warn(`Teamtrail: decision ${e} can't be read: ${t.message}`)}class YN{constructor(t,n=`./${J.dataDir}`){oe(this,"kind","markdown");oe(this,"label","Local markdown");oe(this,"events",new ui);oe(this,"selfWrites",new Map);oe(this,"external",new BN(t=>this.fs.read(t),t=>this.events.emit(t)));oe(this,"ticketPath",(t,n)=>`${xs(t)}/tickets/${xs(n)}.md`);oe(this,"setMapArchived",(t,n)=>this.editMap(t,i=>TN(i,n),{kind:"map.updated",mapId:t,at:Date.now()}));var i;this.fs=t,this.location=n,(i=t.watch)==null||i.call(t,o=>{const c=this.selfWrites.get(o);c&&Date.now()-c<1500||this.external.queue(o)})}async put(t,n,i){this.selfWrites.set(t,Date.now()),await this.fs.write(t,n,i===void 0?void 0:{base:i})}putNew(t){return MN(this.fs,t,n=>this.selfWrites.set(n,Date.now()))}async readMap(t){return Fp(t,await this.fs.read(`${xs(t)}/map.md`))}async writeMap(t,n){await this.put(`${xs(t.id)}/map.md`,Gd(t),n)}async listMaps(){const n=(await this.fs.list()).filter(i=>/^[^/]+\/map\.md$/.test(i)).map(i=>i.split("/")[0]);return Promise.all(n.map(async i=>yN(await this.readMap(i))))}async loadMap(t){const n=await this.fs.list(),i=await this.readMap(t),o=n.filter(d=>d.startsWith(`${t}/tickets/`)&&_N(d)),c=await Promise.all(o.map(async d=>Bp(await this.fs.read(d))));return{map:i,tickets:c.sort((d,u)=>d.createdAt-u.createdAt)}}async createMap(t){const n=await qN(this.fs,t,i=>this.selfWrites.set(i,Date.now()));return this.events.emit({kind:"map.created",mapId:n.id,at:Date.now()}),n}async editMap(t,n,i){const o=await this.fs.read(`${xs(t)}/map.md`);await this.writeMap({...n(Fp(t,o)),updatedAt:Date.now()},o),this.events.emit(i)}setMapMode(t,n){return this.editMap(t,i=>({...i,mode:n}),{kind:"map.mode",mapId:t,mode:n,at:Date.now()})}setMapMeta(t,n){return this.editMap(t,i=>xN(i,n),{kind:"map.updated",mapId:t,at:Date.now()})}updateMapSections(t,n){const i=Object.keys(n)[0];return this.editMap(t,o=>({...o,sections:{...o.sections,...n}}),{kind:"map.updated",mapId:t,section:i,at:Date.now()})}async createTicket(t,n){const i=await this.putNew(()=>LN(this.fs,t,n));return this.events.emit({kind:"ticket.created",mapId:t,ticketId:i.id,at:Date.now()}),i}async addBlocking(t,n,i){await this.update(t,i,o=>o.blockedBy.includes(n)?o:{...o,blockedBy:[...o.blockedBy,n]}),this.events.emit({kind:"edge.added",mapId:t,blockerId:n,blockedId:i,at:Date.now()})}async update(t,n,i){const o=await this.fs.read(this.ticketPath(t,n)),c=Bp(o),d=i(c);d!==c&&await this.put(this.ticketPath(t,c.id),xv({...d,updatedAt:Date.now()}),o)}async removeBlocking(t,n,i){await this.update(t,i,o=>bN(o,n)),this.events.emit({kind:"edge.removed",mapId:t,blockerId:n,blockedId:i,at:Date.now()})}async editTicket(t,n,i){await this.update(t,n,o=>SN(o,i)),this.events.emit({kind:"ticket.updated",mapId:t,ticketId:n,at:Date.now()})}async reopen(t,n){await this.update(t,n,NN),this.events.emit({kind:"ticket.updated",mapId:t,ticketId:n,at:Date.now()})}async assign(t,n,i){await this.update(t,n,o=>({...o,assignee:i??void 0})),this.events.emit(i?{kind:"ticket.claimed",mapId:t,ticketId:n,assignee:i,at:Date.now()}:{kind:"ticket.released",mapId:t,ticketId:n,at:Date.now()})}async comment(t,n,i,o){await this.update(t,n,c=>({...c,comments:[...c.comments,{id:`c${c.comments.length}`,author:i,body:o,createdAt:Date.now()}]})),this.events.emit({kind:"ticket.commented",mapId:t,ticketId:n,at:Date.now()})}async close(t,n,i){await this.update(t,n,o=>({...o,state:"closed",closeReason:i,closedAt:Date.now()})),this.events.emit({kind:"ticket.closed",mapId:t,ticketId:n,reason:i,at:Date.now()})}async setMeta(t,n,i){await this.update(t,n,o=>CN(o,i)),this.events.emit({kind:"ticket.updated",mapId:t,ticketId:n,at:Date.now()})}async listDecisions(t){const i=(await this.fs.list()).filter(o=>o.startsWith(`${t}/decisions/`)).map(async o=>{const c=await this.fs.read(o).catch(u=>QN(o,u));if(!c)return;const d={...zd(c),mapId:t};return this.external.knows(o)||this.external.remember(o,c,d.supersededBy),d});return(await Promise.all(i)).filter(o=>!!o)}async createDecision(t,n){const i=await this.putNew(async()=>{const o=await ON(this.fs,t,n);return this.external.remember(o.path,o.text),o});return this.events.emit({kind:"decision.recorded",mapId:t,decisionId:i.id,ticketId:i.ticketId,at:Date.now()}),i}async markSuperseded(t,n,i){const o=`${xs(t)}/decisions/${xs(n)}.md`,c=await this.fs.read(o),d=rv({...zd(c),mapId:t,supersededBy:i});this.external.remember(o,d,i),await this.put(o,d,c),this.events.emit({kind:"decision.superseded",mapId:t,decisionId:n,supersededBy:i,at:Date.now()})}subscribe(t){return this.events.on(t)}}function At(e,t=[]){if(e)try{const{protocol:n}=new URL(e);return["http:","https:",...t].includes(n)?e:void 0}catch{return}}class zp extends Error{constructor(t,n,i,o){super(n),this.code=t,this.status=i,this.resetAt=o,this.name="TrackerError"}}const JN={github:"GitHub Issues",linear:"Linear"};async function Ct(e,t,n){let i;try{i=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:n===void 0?void 0:JSON.stringify(n)})}catch{throw new zp("offline","Lookout server unreachable; is `teamtrail` still running?")}const o=await i.json().catch(()=>({}));if(!i.ok)throw new zp(o.code??"http",o.error??`request failed (${i.status})`,i.status,o.resetAt);return o}class XN{constructor(t,n,i=""){oe(this,"label");oe(this,"location");oe(this,"status",{state:"connecting",queued:0});oe(this,"events",new ui);oe(this,"statusEvents",new ui);oe(this,"source");oe(this,"listeners",0);oe(this,"openEvents",t=>new EventSource(`${this.base}${t}`));oe(this,"listMaps",()=>this.call("listMaps"));oe(this,"loadMap",t=>this.call("loadMap",t));oe(this,"createMap",t=>this.call("createMap",t));oe(this,"setMapMode",(t,n)=>this.call("setMapMode",t,n));oe(this,"setMapArchived",(t,n)=>this.call("setMapArchived",t,n));oe(this,"setMapMeta",(t,n)=>this.call("setMapMeta",t,n));oe(this,"updateMapSections",(t,n)=>this.call("updateMapSections",t,n));oe(this,"createTicket",(t,n)=>this.call("createTicket",t,n));oe(this,"addBlocking",(t,n,i)=>this.call("addBlocking",t,n,i));oe(this,"removeBlocking",(t,n,i)=>this.call("removeBlocking",t,n,i));oe(this,"editTicket",(t,n,i)=>this.call("editTicket",t,n,i));oe(this,"reopen",(t,n)=>this.call("reopen",t,n));oe(this,"assign",(t,n,i)=>this.call("assign",t,n,i));oe(this,"comment",(t,n,i,o)=>this.call("comment",t,n,i,o));oe(this,"close",(t,n,i)=>this.call("close",t,n,i));oe(this,"setMeta",(t,n,i)=>this.call("setMeta",t,n,i));oe(this,"listDecisions",t=>this.call("listDecisions",t));oe(this,"createDecision",(t,n)=>this.call("createDecision",t,n));oe(this,"markSuperseded",(t,n,i)=>this.call("markSuperseded",t,n,i));this.kind=t,this.base=n,this.label=JN[t],this.location=i}async call(t,...n){return(await Ct(`${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 i=JSON.parse(n.data);i.location&&(this.location=i.location),this.status=i,this.statusEvents.emit(i)}),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 i;n(),--this.listeners===0&&((i=this.source)==null||i.close(),this.source=void 0)}}onStatus(t){return this.statusEvents.on(t)}}function ZN(e){return{get:()=>Ct(`${e}/trackers`,"GET"),test:t=>Ct(`${e}/trackers/test`,"POST",t),connect:t=>Ct(`${e}/trackers`,"PUT",t),forget:t=>Ct(`${e}/trackers/credentials/${t}`,"DELETE"),githubRepos:()=>Ct(`${e}/trackers/github/repos`,"GET"),githubSignIn:{start:()=>Ct(`${e}/trackers/github/sign-in/start`,"POST"),poll:()=>Ct(`${e}/trackers/github/sign-in/poll`,"POST"),cancel:()=>Ct(`${e}/trackers/github/sign-in/cancel`,"POST"),signOut:()=>Ct(`${e}/trackers/github/sign-in`,"DELETE")},linearTeams:t=>t?Ct(`${e}/trackers/linear/teams`,"POST",{apiKey:t}):Ct(`${e}/trackers/linear/teams`,"GET"),linearProjects:(t,n)=>n?Ct(`${e}/trackers/linear/projects`,"POST",{apiKey:n,teamId:t}):Ct(`${e}/trackers/linear/projects?team=${encodeURIComponent(t)}`,"GET")}}const e1=[{id:"markdown",name:"Local markdown",status:"available"},{id:"github",name:"GitHub Issues",status:"available"},{id:"linear",name:"Linear",status:"available"}],bv=[{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"}],t1=bv[0],n1="https://github.com/teamtrailhq/teamtrail-guides",s1="https://raw.githubusercontent.com/teamtrailhq/teamtrail-guides/main",i1=`${n1}/blob/main/CONTRIBUTING.md`,r1=e=>e.slice(0,9),o1=/[a-z][\w+.-]*:\/\/(?!(localhost|127\.0\.0\.1)(:\d+)?(\/|$|\s))/i,a1=/^[\w.-]+@[\w.-]+:/,c1=/^(@[\w.-]+\/)?[\w./-]+@[\w^~<>=*.-]+$/,l1=/(^|=)(npm|jsr|github|gitlab|bitbucket|git\+[a-z]+|https?):/i,d1=/^--?(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,u1={tar:/^-[A-Za-z]*[IF]/,zip:/^-TT|^--unzip-command/,make:/^-E|^--eval/,perl:/^-[A-Za-z]*M/};function h1(e,t){var n;if(o1.test(t)||a1.test(t))return"names a remote address, so it reaches the network";if(c1.test(t)&&!t.startsWith("-"))return`names a package to download (${t})`;if(l1.test(t))return`names a package from a registry (${t})`;if(d1.test(t))return`runs a command it's given (${t.split("=")[0]})`;if((n=u1[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(f1.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 f1=/\|\s*(sh|bash|zsh|dash|ksh|fish|pwsh|node|python\d*|perl|ruby)\b|\$\(|`|;|&&|\|\||\b(curl|wget)\s/;function m1(e,t){var n;if(e==="cargo")for(let i=0;i<t.length;i++){const o=t[i]==="--config"?t[i+1]:(n=/^--config=(.*)$/s.exec(t[i]))==null?void 0:n[1];if(o!==void 0&&!/^[\w./-]+\.toml$/.test(o))return"sets cargo configuration inline (--config)"}}function p1(e,t){const n=m1(e,t);if(n)return n;for(const i of t){const o=h1(e,i);if(o)return o}}const g1=/^(-c|-e|-E|-ex|-x|-r|-command|-Command|-EncodedCommand)$|^--(eval|exec|command|expr|execute|run)(=|$)/,k1=/(^|[\s|'"=])[a-z0-9-]+(\.[a-z0-9-]+)*\.[a-z]{2,}(:\d+)?\/\S*/i;function v1(e,t){const n=e.find(i=>{var o;return g1.test(i)&&!((o=t==null?void 0:t.exempt)!=null&&o.includes(i.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(i=>k1.test(i)))return"names an address, so it may reach the network"}const w1=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"]),y1=new Set(["-C","--git-dir","--work-tree","--namespace","--super-prefix"]);function x1(e){for(let t=0;t<e.length;t++){const n=e[t],i=n.split("=")[0];if(i==="-c"||i.startsWith("-c")||i==="--config-env"||i==="--exec-path")return`sets git's configuration or programs inline (${i})`;if(y1.has(i)){n.includes("=")||t++;continue}if(n.startsWith("-"))continue;const o=n.toLowerCase();return w1.has(o)||o.startsWith("remote-")?`runs git ${o}, which reaches a remote, runs commands or changes git's configuration`:o==="grep"&&e.slice(t+1).some(c=>/^-[A-Za-z]*O|^--open-files-in-pager/.test(c))?"runs git grep with a pager command (-O)":void 0}}const j1=["--require","--import","--loader","--experimental-loader","--env-file","--input-type"],Up={inline:"ep",value:"rC",long:["--eval","--print"],longValue:j1},b1={node:Up,nodejs:Up,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 S1(e,t){const n=e.slice(1);for(let i=0;i<n.length;i++){if(t.inline.includes(n[i]))return"code";if(t.value.includes(n[i]))return i===n.length-1?"takes-next":"plain"}return"plain"}function N1(e,t){var o;if(/^data:|=data:/i.test(e))return"code";if(!e.startsWith("--"))return S1(e,t);const[n,i]=e.toLowerCase().split(/=(.*)/s,2);return t.long.includes(n)?"code":i===void 0&&((o=t.longValue)!=null&&o.includes(n))?"takes-next":"plain"}function $1(e,t){const n=b1[e];if(n)for(let i=0;i<t.length;i++){const o=t[i];if(o==="--"||!o.startsWith("-")||o===n.stop)return;const c=N1(o,n);if(c==="code")return"runs code given inline; point at a script in the repo instead";if(c==="takes-next"&&/^data:/i.test(t[i+1]??""))return"runs code given inline";c==="takes-next"&&i++}}const Wp=e=>new RegExp(`^(?![-/~\\\\])(?!.*\\.\\.)(?![a-zA-Z]:)[\\w./-]+\\.(${e})$`),Ut={},ht=e=>e.split(/\s+/).filter(Boolean),C1={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:Ut,cargo:{sub:ht("test check clippy build fmt")},go:{sub:ht("test vet build")},deno:{sub:ht("test lint check")},node:{script:Wp("[cm]?[jt]s"),sub:["--test"]},python:{script:Wp("py"),modules:ht("pytest unittest mypy ruff black flake8 pylint"),exempt:["-c"]},pytest:{exempt:["-c"]},ruff:{sub:ht("check format")},mypy:Ut,pyright:Ut,black:{needs:["--check"]},flake8:Ut,pylint:Ut,tsc:Ut,eslint:{exempt:["-c"]},"pa11y-ci":Ut,prettier:{needs:ht("--check -c --list-different -l")},biome:{sub:ht("check lint ci")},jest:{exempt:["-c"]},vitest:Ut,mocha:Ut,playwright:{sub:["test"]},rubocop:Ut,rspec:{exempt:["-e"]},phpunit:Ut,phpstan:Ut,"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"]}},T1=/^(\.\/)?node_modules\/\.bin\/([\w.-]+)$/;function E1(e,t){var i;const n=t[0]??"";return e.needs&&!t.some(o=>e.needs.includes(o))?!1:(i=e.script)!=null&&i.test(n)?!0:e.modules?n==="-m"&&e.modules.includes(t[1]??""):e.sub?e.sub.includes(n):!0}function Sv(e){var i;const t=(i=T1.exec(e.argv0))==null?void 0:i[2],n=C1[t??e.program];return n&&E1(n,e.args)?n:void 0}const A1=e=>!!Sv(e),za=e=>new Set(e.split(/\s+/).filter(Boolean)),I1=za(`
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
+ `),R1=za(`
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
+ `),M1=za("npx pnpx bunx uvx uv pipx docker podman nix nix-shell nix-env flatpak snap"),L1=za(`
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
+ `),Xo=["exec","x","dlx","install","i","add","ci","create","init","update","upgrade"],O1={npm:new Set(Xo),pnpm:new Set(Xo),yarn:new Set(Xo),bun:new Set(Xo),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 P1(e){const t=(e.split(/[\\/]/).pop()??"").toLowerCase().replace(/\.(exe|cmd|bat|com)$/,"");return t.replace(new RegExp("(?<=[a-z])[\\d.-]+$"),"")||t}const D1=e=>{var t;return((t=e.find(n=>!n.startsWith("-")))==null?void 0:t.toLowerCase())??""};function Hp(e){const t=e.findIndex(n=>n.startsWith("-m"));if(!(t<0))return e[t]==="-m"?e[t+1]:e[t].slice(2)}const _1=new Set(["pip","ensurepip","pipx","uv","venv","http.server","webbrowser"]);function B1(e,t){var i;if(I1.has(e))return`runs a shell (${e}); name the program and its arguments instead`;if(R1.has(e))return`runs ${e}, which reaches the network`;if(M1.has(e))return`runs ${e}, which downloads and runs a package; use one installed in the repo`;if(L1.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=D1(t);if((i=O1[e])!=null&&i.has(n))return`runs ${e} ${n}, which downloads packages; use one installed in the repo`;if(e==="python"&&_1.has(Hp(t)??""))return`runs python -m ${Hp(t)}, which downloads or serves`;if(e==="find"&&t.some(o=>/^-(exec|execdir|ok|okdir|delete)$/.test(o)))return"runs find with -exec or -delete, which runs or removes other things"}function Nv(e){const t=e.run[0]??"";return{argv0:t,program:P1(t),args:e.run.slice(1)}}function F1(e){const{argv0:t,program:n,args:i}=Nv(e),o=Sv({argv0:t,program:n,args:i}),c=[B1(n,i),$1(n,i),n==="git"?x1(i):void 0,p1(n,i),v1(i,o)].filter(d=>!!d);return e.cwd&&(e.cwd.startsWith("/")||e.cwd.split(/[\\/]/).includes(".."))&&c.push("cwd must stay inside the repo"),c}const z1="unknown program: Teamtrail can't tell what this runs";function U1(e){if(F1(e).length)return;const{argv0:t,program:n,args:i}=Nv(e);return A1({argv0:t,program:n,args:i})?void 0:z1}function W1(e,t={}){const n=(t.query??"").toLowerCase().split(/\s+/).filter(Boolean);return e.guides.filter(i=>{if(t.verifiedOnly&&!i.verified&&!i.builtin)return!1;const o=[i.id,i.name??"",i.summary,i.author].join(" ").toLowerCase();return n.every(c=>o.includes(c))})}const H1="unknown model",K1=e=>`${Math.round(e.firstTimeRate*100)}%`,Kp=(e,t)=>`${e.model} passes ${K1(e)} of your ${t} tickets first time (${e.tickets} tickets)`;function G1(e,t){return t.firstTimeRate-e.firstTimeRate||(e.costPerVerifiedUsd??1/0)-(t.costPerVerifiedUsd??1/0)||e.key.localeCompare(t.key)}function V1(e){return[...new Set(e.scorecard.byTypeAndModel.map(n=>n.type??""))].filter(Boolean).sort().flatMap(n=>{const i=e.scorecard.byTypeAndModel.filter(f=>f.type===n&&f.enough&&f.model!==H1).sort(G1);if(i.length<2||i[0].firstTimeRate===i[1].firstTimeRate)return[];const o=i[0],c=W0(o.model,e.models).tier,d=e.tiers[n];if(!d||c===d)return[];const u=`${Kp(o,n)}; ${Kp(i[1],n)}`;return[{type:n,current:d,tier:c,model:o.model??"",because:u}]})}const aa=e=>`${Math.round(e*100)}%`,q1=e=>e===void 0?"–":`$${e.toFixed(2)}`,Mu=e=>e.replace(/[^\w .@/·-]/g,"").slice(0,60);function dd(e,t){return[`| ${t} | Tickets | Verified first time | Rework | Came back | Attempts per verified | Cost per verified |`,"| --- | ---: | ---: | ---: | ---: | ---: | ---: |",...e.map(n=>[`| ${Mu(n.key)}${n.enough?"":" (too few)"}`,n.tickets,aa(n.firstTimeRate),aa(n.reworkRate),n.escapeRate===void 0?"–":`${aa(n.escapeRate)} (${n.escaped??0})`,n.attemptsPerVerified??"–",`${q1(n.costPerVerifiedUsd)} |`].join(" | "))]}function Q1(e){return["| Check | Verified tickets it passed | Came back |","| --- | ---: | ---: |",...e.map(t=>`| ${Mu(t.key)}${t.enough?"":" (too few)"} | ${t.verified} | ${aa(t.escapeRate)} (${t.escaped}) |`)]}function Y1(e,t="Agent scorecard"){var n,i;return[`## ${Mu(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.`,"",...dd(e.byTypeAndModel,"Ticket type · model"),"",...dd(e.byVendor,"Vendor"),...(n=e.byGuide)!=null&&n.length?["",...dd(e.byGuide,"Guide")]:[],...(i=e.byCheck)!=null&&i.some(o=>o.escaped)?["",...Q1(e.byCheck)]:[]].join(`
134
+ `)}const ud="No area yet";function J1(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 hd={x:112,w:15},fd={x:136,w:10};function Gp({x:e,w:t},n,i,o){const c=e+n;return[`<rect x="${c}" y="${94+i}" width="${t}" height="12" rx="${t>12?5:4}" fill="${o.glowLight}"/>`,`<rect x="${c}" y="${100+i}" width="${t}" height="6" rx="3" fill="${o.glow}"/>`,`<rect x="${c+t-6}" y="${96+i}" width="${t>12?3.5:2.5}" height="3.5" rx="1" fill="#fff"/>`].join("")}function Vp({x:e,w:t},n){const i=t+3,o=t>12?6:5;return`<rect x="${e-2}" y="90" width="${i}" height="18" rx="${i/2.6}" fill="${n.glowLight}"/><rect x="${e-2+(i-o)/2}" y="96" width="${o}" height="6" rx="2" fill="${n.glass}"/>`}function X1(e,t){if(e==="closed")return[hd,fd].map(({x:o,w:c})=>`<rect x="${o}" y="100" width="${c}" height="4" rx="2" fill="${t.glow}"/>`).join("");if(e==="wide")return Vp(hd,t)+Vp(fd,t);const[n,i]=e==="aside"?[4,-5]:[0,0];return Gp(hd,n,i,t)+Gp(fd,n,i,t)}function Z1(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 e$({eyes:e,mouth:t},n){return X1(e,n)+Z1(t,n)}function t$(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 n$(e,t,n,i){return[`<path d="M86 34L80 16" stroke="${i.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 s$({face:e,lamp:t,lit:n,simple:i,c:o}){const c=t$(o);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="${o.band}" stroke-width="8" stroke-linecap="round"/>`,`<path d="M44 78Q44 62 60 60L74 58V152L60 150Q44 148 44 132Z" fill="${o.side}"/>`,`<rect x="68" y="56" width="98" height="96" rx="20" fill="${o.shell}"/>`,`<rect x="72" y="60" width="8" height="84" rx="4" fill="${o.shellLight}"/>`,`<path d="M68 132H166V140Q166 152 152 152H82Q68 152 68 140Z" fill="${o.shade}"/>`,`<rect x="82" y="72" width="76" height="62" rx="16" fill="${o.frame}"/>`,`<rect x="86" y="76" width="70" height="55" rx="13" fill="${o.glass}"/>`,i?"":c.shine,e,i?"":c.chin,`<ellipse cx="50" cy="108" rx="13" ry="21" fill="${o.orangeDark}"/>`,`<ellipse cx="56" cy="108" rx="12" ry="20" fill="${o.orange}"/>`,`<ellipse cx="53" cy="104" rx="4" ry="11" fill="${o.orangeLight}"/>`,`<path d="M60 122Q64 146 88 148" fill="none" stroke="${o.band}" stroke-width="5" stroke-linecap="round"/>`,`<circle cx="90" cy="148" r="6" fill="${o.band}"/><circle cx="91.5" cy="146.5" r="2" fill="${o.orange}"/>`,n$(t,n,i,o),`<path d="M48 76Q46 30 104 28Q158 30 162 70Z" fill="${o.hat}"/>`,`<path d="M48 76Q46 34 88 29Q66 42 66 74Z" fill="${o.hatDark}"/>`,`<path d="M96 70Q96 40 126 36Q152 40 154 68Z" fill="${o.panel}"/>`,i?"":c.pine,`<path d="M150 82Q120 76 66 84L58 80Q56 72 64 70Q122 62 180 70Q190 76 182 84Z" fill="${o.brim}"/>`,'<path d="M70 84Q120 78 166 84L166 90Q120 84 70 90Z" fill="#000" opacity=".22"/>'].join("")}const i$={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"},$v={on:"#ffb347",dim:"#a8501c",alert:"#ff5a48"},r$={on:"#ffd166",dim:"#a8501c",alert:"#ff5a48"},o$={circle:100,rounded:46,square:0},a$=.94;let c$=0;function l$(e,{lamp:t=$v,simple:n=!1,shape:i="circle",colors:o=i$}={}){const c=o,d=e.light??"on",u=i==="circle"?a$:1,f=100*(1-u),m=`scout-clip-${++c$}`,g=s$({face:e$(e,c),lamp:t[d],lit:d!=="dim",simple:n,c});return[`<defs><clipPath id="${m}"><rect width="200" height="200" rx="${o$[i]}"/></clipPath></defs>`,`<g clip-path="url(#${m})">`,`<rect width="200" height="200" fill="${c.ground}"/>`,`<circle cx="120" cy="88" r="74" fill="${c.groundLight}"/>`,`<g transform="translate(${f} ${f}) scale(${u})">${J1(c)}${g}</g>`,"</g>"].join("")}const Cv={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:$v,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:r$,wave:{bar:"#66828d",lead:"#e8833a"}}},d$="crt",u$={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"}},h$={idle:"WATCHING",speaking:"TALKING",alert:"NEEDS YOU",thinking:"THINKING"},Cn={msPerChar:55,mouthHoldMs:110,blinkEveryMs:5600,blinkMs:140,thinkingStepMs:520};function f$(e){return e?/[aeiouy]/i.test(e)?"open":/[a-z0-9]/i.test(e)?"mid":"rest":"rest"}function m$(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 p$(e,t,n){return Array.from({length:n},(i,o)=>{const c=t-(n-1-o);return c>=0&&c<e.length?m$(e[c],c):0})}function Tv({face:e={eyes:"open",mouth:"rest"},variant:t="crt",size:n,simple:i,shape:o="circle",className:c}){const{eyes:d,mouth:u,light:f}=e,m=w.useMemo(()=>l$({eyes:d,mouth:u,light:f},{lamp:Cv[t].lamp,simple:i??n<40,shape:o}),[d,u,f,t,i,n,o]);return s.jsx("svg",{className:c,width:n,height:n,viewBox:"0 0 200 200","aria-hidden":"true",dangerouslySetInnerHTML:{__html:m}})}function g$(e){const[t,n]=w.useState(!1);return w.useEffect(()=>{if(!e){n(!1);return}let i;const o=setInterval(()=>{n(!0),i=setTimeout(()=>n(!1),Cn.blinkMs)},Cn.blinkEveryMs);return()=>{clearInterval(o),i&&clearTimeout(i)}},[e]),t}const k$={xs:.8,sm:2,md:4,lg:6},v$=40,qp=20,Qp="(prefers-reduced-motion: reduce)",w$=40,y$=350;function x$(e,t){var u;const n=e.size??"md",i=e.state??"idle",o=((u=e.speaking)==null?void 0:u.trim())??"",c=o&&(i==="idle"||i==="speaking")?"speaking":i,d=n==="xs";return{size:n,text:o,effective:c,talking:c==="speaking"&&o.length>0,mini:d,framed:e.framed??!d,reduced:t||d}}const j$=e=>e.length*Cn.msPerChar,b$=(e,t)=>t&&(e.effective==="idle"||e.effective==="speaking"||e.effective==="alert");function S$(e,t,n,i){const o=u$[e.effective],c=n?"closed":o.eyes;let d=o.mouth,u=e.text.length-1;if(i)if(e.reduced)d="open";else{u=Math.min(e.text.length-1,Math.floor(t/Cn.msPerChar));const m=Math.floor(t/Cn.mouthHoldMs)*Math.round(Cn.mouthHoldMs/Cn.msPerChar);d=f$(e.text[Math.min(e.text.length-1,m)])}let f=o.light;return e.effective==="thinking"&&!e.reduced&&Math.floor(t/Cn.thinkingStepMs)%2===1&&(f="on"),{eyes:c,mouth:d,light:f,cursor:u}}function N$(e,t){const n=typeof e.size=="number"?e.size:k$[e.size],i=e.reduced?Math.min(e.text.length-1,qp-1):t;return{base:n,px:v$*n,bars:qp,waveCursor:i}}function $$(e,{label:t,speechDone:n,cursor:i,caption:o}){const c=e.talking&&n?"idle":e.effective,d=h$[c],u=e.size==="md"||e.size==="lg"||typeof e.size=="number"&&e.size>=4;return{shownState:c,status:d,ariaLabel:`${t}, ${d.toLowerCase()}`,showCaption:o??u,shown:C$(e,n,i)}}function C$(e,t,n){return e.talking?e.reduced||t?e.text:e.text.slice(0,n+1):""}function T$(){const[e,t]=w.useState(()=>{var n;return typeof window<"u"&&!!((n=window.matchMedia)!=null&&n.call(window,Qp).matches)});return w.useEffect(()=>{var o;const n=(o=window.matchMedia)==null?void 0:o.call(window,Qp);if(!n)return;const i=()=>t(n.matches);return i(),n.addEventListener("change",i),()=>n.removeEventListener("change",i)},[]),e}function E$(e,t,n){const[i,o]=w.useState(0);return w.useEffect(()=>{if(o(0),!t)return;const c=performance.now(),d=setInterval(()=>o(performance.now()-c),n);return()=>clearInterval(d)},[e,t,n]),i}function A$(e){const{key:t,talking:n,at:i}=e,o=i!==void 0,c=j$(e.text),[d,u]=w.useState(""),f=w.useRef(e.onSpeakEnd);f.current=e.onSpeakEnd,w.useEffect(()=>{if(!n||o)return;const b=setTimeout(()=>{var S;u(t),(S=f.current)==null||S.call(f)},c+y$);return()=>clearTimeout(b)},[n,t,c,o]);const m=n&&d!==t,g=E$(t,e.animate&&(m||e.thinking),m?w$:Cn.thinkingStepMs),k=i??g,y=n&&(o?k>=c:d===t);return{t:k,speechDone:y}}const I$=e=>e*2,Vd=3.5;function R$(e,t,n){return(e??[]).map((i,o)=>{const c=(1+2*i)*.5;return{x:o*2,y:(Vd-c)/2,width:1,height:c,fill:o>=t-2&&i>0?n.lead:n.bar}})}function M$({heights:e,bars:t,unit:n,colors:i}){const o=I$(t);return s.jsx("svg",{className:`scout-wave${e?" on":""}`,width:o*n,height:Vd*n,viewBox:`0 0 ${o} ${Vd}`,"aria-hidden":"true",children:R$(e,t,i).map((c,d)=>s.jsx("rect",{...c},d))})}function Ua({state:e="idle",size:t="md",speaking:n,variant:i=d$,framed:o,caption:c,label:d="Scout",onSpeakEnd:u,at:f,className:m,style:g}){const k=x$({state:e,size:t,speaking:n,framed:o},T$()),{text:y,effective:b,talking:S,reduced:x}=k,$=Cv[i],O=!x&&!(f!==void 0),D=`${b}|${i}|${y}`,{t:F,speechDone:K}=A$({key:D,text:y,talking:S,thinking:b==="thinking",animate:O,at:f,onSpeakEnd:u}),I=g$(b$(k,O)),Q=S&&!K,{eyes:Z,mouth:q,light:ee,cursor:Se}=S$(k,F,I,Q),{base:ve,px:be,bars:ae,waveCursor:Ie}=N$(k,Se),we=w.useMemo(()=>Q?p$(y,Ie,ae):null,[Q,y,Ie,ae]),{shownState:Ne,status:z,ariaLabel:Y,showCaption:U,shown:E}=$$(k,{label:d,speechDone:K,cursor:Se,caption:c}),B={...g,"--scout-u":`${ve}px`},ce=s.jsx("span",{className:"scout-sprite",children:s.jsx(Tv,{face:{eyes:Z,mouth:q,light:ee},variant:i,size:be,simple:k.mini})});return k.framed?s.jsxs("figure",{className:`scout scout-panel scout-${Ne} scout-v-${i} ${m??""}`,style:B,"data-state":Ne,children:[s.jsxs("figcaption",{className:"scout-head",children:[s.jsx("span",{className:"scout-name",children:d}),s.jsx("span",{className:"scout-sep",children:"//"}),s.jsx("span",{className:"scout-status",children:z})]}),s.jsxs("div",{className:"scout-feed",role:"img","aria-label":Y,children:[ce,s.jsx(M$,{heights:we,bars:ae,unit:ve,colors:$.wave})]}),U&&s.jsxs("p",{className:"scout-caption","aria-hidden":"true",children:[E,S&&!K&&!x&&s.jsx("span",{className:"scout-caret",children:"_"})]}),y&&s.jsx("span",{className:"scout-sr","aria-live":"polite",children:y})]}):s.jsx("span",{className:`scout scout-bare scout-${Ne} ${m??""}`,style:B,role:"img","aria-label":Y,children:ce})}const wt="trail lead";function L$({rt:e,guard:t,setMapId:n,mapIdRef:i,snapRef:o,setChatSession:c,setSelection:d}){const u={actorKind:"trail lead",journal:e.journal};return{selectMap:f=>n(f),openChat:f=>c(f),answer:(f,m)=>e.activity.answer(f,m,wt,{via:"lookout"}),claim:f=>t("Claim",()=>Cp(e.adapter,i.current,f,{...u,assignee:wt})),release:f=>t("Release claim",()=>Tb(e.adapter,i.current,f,{...u,actor:wt})),releaseLease:f=>t("Release to queue",()=>e.leases.release(i.current,f,wt)),resolve:(f,m,g={})=>t("Resolve · record answer",async()=>{var y;const k=(y=o.current)==null?void 0:y.tickets.find(b=>b.id===f);k&&!k.assignee&&await Cp(e.adapter,i.current,f,{...u,assignee:wt}),await Bb(e.adapter,i.current,f,{...u,answer:m,author:wt,decision:{...g,source:{kind:"lookout",label:"Ticket inspector"}}})}),supersede:(f,m)=>t(`Supersede ${f.id}`,async()=>{let g=f.id;if(f.derived){const{id:k,mapId:y,derived:b,supersededBy:S,...x}=f;g=(await $u(e.adapter,f.mapId,x,{appendToTrail:!1})).id}await Rb(e.adapter,f.mapId,g,{...m,decidedBy:wt,participants:[{id:wt}],source:{kind:"lookout",label:"Logbook"}})}),graduate:({unspecified:f,...m})=>t(`Promote to ticket · ${f}`,async()=>{const g=await zb(e.adapter,i.current,f,m);d({kind:"ticket",id:g.id})}),ruleOut:(f,m)=>t("Rule out of scope",async()=>{await Ub(e.adapter,i.current,f,{...u,reason:m,author:wt,source:{kind:"lookout",label:"Ticket inspector"}}),d(null)}),setArchived:f=>t(f?"Archive trail":"Restore trail",async()=>{await Gb(e.adapter,i.current,f),f&&n(void 0)}),setMode:f=>t(`Trail mode · ${f}`,()=>Mb(e.adapter,i.current,f)),setModelMatching:f=>t(`Model matching · ${f.enabled?"on":"off"}`,()=>Wb(e.adapter,i.current,f))}}const ue=(...e)=>e.filter(Boolean).join(" "),$s="item",O$=/^[0-9a-f]{6,64}$/;function Ar(){const e=new URLSearchParams(location.search).get("project")??void 0;return e&&O$.test(e)?e:void 0}function re(e=Ar()){return e?`${J.apiPrefix}/p/${e}`:J.apiPrefix}function P$(e){const t=new URLSearchParams(location.search);for(const i of["projects","project","tracker",$s])t.delete(i);e.item&&t.set($s,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 D$(){var n,i;const e=await fetch(`${re()}/verification/config`).then(o=>o.ok?o.json():void 0).catch(()=>{}),t=((n=e==null?void 0:e.approval)==null?void 0:n.state)==="approved"?(i=e.config)==null?void 0:i.default:void 0;return t&&t!=="off"?t:void 0}async function _$(e,t){var d;const n=(t.assumptions??[]).map((u,f)=>({id:`S-${f+1}`,text:u,status:"holding",tickets:[]})),i=await D$(),{map:o,tickets:c}=await kb(e,{title:t.title,...i?{verification:i}:{},sections:{destination:t.destination,notes:t.notes,decisions:[],unspecified:[],outOfScope:[],...n.length?{assumptions:n}:{}},tickets:[{ref:"discovery",...XS}]});return await fetch(`${re()}/briefs/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:o.id,ticketId:(d=c[0])==null?void 0:d.id})}),o}function Ev(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 Je(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 Av(e){const t=Math.max(0,Math.floor(e/1e3)),n=i=>String(i).padStart(2,"0");return`${n(Math.floor(t/3600))}:${n(Math.floor(t%3600/60))}:${n(t%60)}`}const Wa=e=>new Date(e).toTimeString().slice(0,8);function qt(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 Ha(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}const hi=e=>`$${e<10?e.toFixed(2):e.toFixed(1)}`,fi=e=>new Date(e).toISOString().slice(0,10),Lu=e=>new Date(e).toTimeString().slice(0,5),B$=e=>`${fi(e)} ${Lu(e)}`,Iv=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`},os=e=>e?new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",ns={research:"Research",prototype:"Prototype",junction:"Junction",task:"Task",execute:"Execute",review:"Review"},Rv={decided:"done",claimed:"working",frontier:"ready",blocked:"backlog",parked:"parked","out-of-scope":"cancelled",verifying:"verifying",rework:"rework",held:"blocked"};function Ou(e,t){return new Map((e??[]).filter(n=>n.mapId===t&&!n.returned).map(n=>[n.ticketId,n]))}function ki(){let e=0,t=0;return{start(){const n=++e;return()=>n<=t?!1:(t=n,!0)},pushed(){t=++e}}}const F$=8,z$=40;function U$(e,t){try{return new URL(e,t).origin===t}catch{return!1}}function Mv(e,t){if(!Array.isArray(e))return[];const n=[];for(const i of e.slice(0,F$)){const{label:o,href:c}=i??{};if(typeof o!="string"||typeof c!="string")continue;const d=o.trim();!d||d.length>z$||!U$(c,t)||n.push({label:d,href:c})}return n}function Ka(e){e==="auto"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e}const W$=["auto","day","night"];function H$(e){const[t]=Mv(e?[e]:[],location.origin);return t?{agents:t}:{}}const Ga=e=>typeof e=="string"&&/^\/[\w/-]{1,100}$/.test(e)?e:void 0;function K$(e){const t=Ga(e);return t?{themeSave:t}:{}}function G$(e){const t=Ga(e);return t?{trailAgents:t}:{}}function V$(e){const t=Ga(e);return t?{setup:t}:{}}function q$(e){const t=Ga(e);return t?{merge:t}:{}}function Q$(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=At(t.href);return n?{home:{label:t.label.trim(),href:n}}:{}}let qd;const pt=()=>qd;function Y$(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,i=Mv(t.pages,location.origin),o=W$.find(c=>c===t.theme);return qd={name:t.name,pages:i,...n?{signOut:t.signOut}:{},...o?{theme:o}:{},...K$(t.themeSave),...q$(t.merge),...V$(t.setup),...G$(t.trailAgents),...t.highRisk===!1?{highRisk:!1}:{},...Q$(t.home),...t.tracker==="markdown"?{tracker:"markdown"}:{},...H$(t.agents)},o&&Ka(o),qd}const J$=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]),fn=(e,t)=>e>>>t|e<<32-t;function X$(e){const t=Math.ceil((e.length+9)/64)*64,n=new Uint8Array(t);n.set(e),n[e.length]=128;const i=new DataView(n.buffer);return i.setUint32(t-8,Math.floor(e.length*8/2**32)),i.setUint32(t-4,e.length*8>>>0),n}function Z$(e,t,n,i){for(let y=0;y<16;y++)i[y]=t.getUint32(n+y*4);for(let y=16;y<64;y++){const b=fn(i[y-15],7)^fn(i[y-15],18)^i[y-15]>>>3,S=fn(i[y-2],17)^fn(i[y-2],19)^i[y-2]>>>10;i[y]=i[y-16]+b+i[y-7]+S>>>0}let[o,c,d,u,f,m,g,k]=e;for(let y=0;y<64;y++){const b=k+(fn(f,6)^fn(f,11)^fn(f,25))+(f&m^~f&g)+J$[y]+i[y]>>>0,S=(fn(o,2)^fn(o,13)^fn(o,22))+(o&c^o&d^c&d)>>>0;[k,g,m,f,u,d,c,o]=[g,m,f,u+b>>>0,d,c,o,b+S>>>0]}[o,c,d,u,f,m,g,k].forEach((y,b)=>e[b]=e[b]+y>>>0)}function md(e){const t=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),n=X$(e),i=new DataView(n.buffer),o=new Uint32Array(64);for(let u=0;u<n.length;u+=64)Z$(t,i,u,o);const c=new Uint8Array(32),d=new DataView(c.buffer);return t.forEach((u,f)=>d.setUint32(f*4,u)),c}function eC(e,t){const n=new Uint8Array(64);n.set(e.length>64?md(e):e);const i=new Uint8Array(64+t.length),o=new Uint8Array(96);for(let c=0;c<64;c++)i[c]=n[c]^54,o[c]=n[c]^92;return i.set(t,64),o.set(md(i),64),md(o)}const Lv=e=>Array.from(e,t=>t.toString(16).padStart(2,"0")).join(""),tC=e=>new Uint8Array((e.match(/../g)??[]).map(t=>parseInt(t,16))),Pu=`${J.slug}.session`;let ka;const nC=e=>{const t=e;return!!t&&typeof t.id=="string"&&typeof t.secret=="string"&&typeof t.verifier=="string"};function Du(){try{const e=JSON.parse(localStorage.getItem(Pu)??"null");return nC(e)?e:ka}catch{return ka}}function sC(e){ka=e;try{localStorage.setItem(Pu,JSON.stringify(e))}catch{}}function Ov(){ka=void 0;try{localStorage.removeItem(Pu)}catch{}}let _u="unproven",pd;const Qd=new Set,Pv=e=>{_u=e;for(const t of Qd)t(e)};function iC(e){return Qd.add(e),()=>void Qd.delete(e)}const rC=()=>_u==="proven",oC=()=>_u==="proven"&&Pv("unproven");function aC(){const e=new Uint8Array(16);return crypto.getRandomValues(e),Lv(e)}async function cC(){const e=Du();if(!e)return"unknown";const t=aC(),n=await fetch(`${J.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 Ov(),"unknown";const i=n!=null&&n.ok?(await n.json().catch(()=>({}))).proof:void 0,o=Lv(eC(tC(e.verifier),new TextEncoder().encode(`${t}
135
+ ${location.origin}`)));return i===o?"proven":"failed"}function Va(){return pd??(pd=cC().then(e=>(pd=void 0,Pv(e),e))),pd}const lC=1e4;class Dv{constructor(t=re(),n="/events"){oe(this,"inner");oe(this,"listeners",[]);oe(this,"closed",!1);oe(this,"retryMs",1e3);this.base=t,this.path=n,this.connect()}addEventListener(t,n){var i;this.listeners.push([t,n]),(i=this.inner)==null||i.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(pt())return this.open(`${this.base}${this.path}`);if(await Va()!=="proven")return this.failed();const t=await fetch(`${J.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[i,o]of this.listeners)n.addEventListener(i,o);n.addEventListener("open",()=>this.retryMs=1e3),n.addEventListener("error",()=>{n.close(),oC(),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,lC))}}function dC(){if(pt())return void fetch(`${J.apiPrefix}/session`,{cache:"no-store"}).then(e=>e.status===401&&location.reload());Va().then(e=>e==="unknown"&&location.reload())}let Kt;const va=new Set,br=new Map,wa=new Set,ya=new Set;function _v(e){Kt==null||Kt.addEventListener(e,t=>{for(const n of br.get(e)??[])n(t.data)})}function qa(){if(!Kt){Kt=new Dv,Kt.onerror=()=>{for(const e of ya)e();dC()},Kt.addEventListener("open",()=>{for(const e of wa)e()}),Kt.onmessage=e=>{const t=JSON.parse(e.data).path;if(typeof t=="string")for(const n of va)n(t)};for(const e of br.keys())_v(e)}}function Qa(){const e=[...br.values()].some(t=>t.size>0);va.size||e||wa.size||ya.size||(Kt==null||Kt.close(),Kt=void 0)}function Ya(e){return va.add(e),qa(),()=>{va.delete(e),Qa()}}function vi(e,t){let n=br.get(e);return n||(n=new Set,br.set(e,n),_v(e)),n.add(t),qa(),()=>{n.delete(t),Qa()}}function as(e){return wa.add(e),qa(),()=>{wa.delete(e),Qa()}}function uC(e){return ya.add(e),qa(),()=>{ya.delete(e),Qa()}}const Bu=(e,t)=>`${e}/${t}`;let on={reached:!1,live:!1,tickets:{}},Yd=!1;const Jd=new Set,Xd=new Set,hC=ki();let Zd=0;const Bv=new Map;let Fv=0;function xa(e){on=e;for(const t of Jd)t()}function fC(e,t){const n=Object.fromEntries(e.map(i=>[Bu(i.mapId,i.ticketId),i]));for(const[i,o]of Bv)o>t&&on.tickets[i]&&(n[i]=on.tickets[i]);return n}function Yp(){const e=hC.start(),t=Zd;fetch(`${re()}/verification/sync`).then(n=>n.ok?n.json():Promise.reject()).then(n=>e()&&xa({reached:!0,live:!0,status:Fv>t?on.status:n.status,tickets:fC(n.tickets,t)}),()=>on.reached&&xa({...on,live:!1}))}function mC(e){const t=JSON.parse(e);if(t.kind==="evidence")for(const o of Xd)o();if(t.kind!=="sync")return;const n=t;Fv=++Zd;const i={...on.tickets};for(const o of n.tickets){const c=Bu(o.mapId,o.ticketId);i[c]=o,Bv.set(c,Zd)}xa({reached:!0,live:!0,status:n.status,tickets:i})}function Jp(){Yd=!0,vi("verification",mC),uC(()=>on.reached&&on.live&&xa({...on,live:!1})),as(Yp),Yp()}const ss={subscribe(e){return Yd||Jp(),Jd.add(e),()=>void Jd.delete(e)},get:()=>on,onEvidence(e){return Yd||Jp(),Xd.add(e),()=>void Xd.delete(e)},ticket:(e,t,n)=>e.tickets[Bu(t,n)]};function pC(e){if(e!=null&&e.flags.length)return e.flags.some(t=>t.severity==="alert")?"alert":"warn"}const Xp={onboarded:!1,tracker:"markdown",hitlTranscript:"summary",agent:t1.id,github:{repo:""},linear:{team:""},briefing:{enabled:!0,awayMinutes:15},theme:"night"};function Fu(){try{const e={...Xp,...JSON.parse(localStorage.getItem(Ma)??"{}")};return["markdown","github","linear"].includes(e.tracker)||(e.tracker="markdown"),e}catch{return Xp}}const gd=new Map,kd=e=>`${re()}/file?path=${encodeURIComponent(e)}`;async function vd(e,t){const n=await e.json().catch(()=>({})),i=new Error(n.error??`${t}: ${e.status}`);return e.status===409?Object.assign(i,{stale:!0}):e.status===404?Object.assign(i,{code:"ENOENT"}):i}const gC={async list(){return(await(await fetch(`${re()}/list`)).json()).files},async read(e){const t=await fetch(kd(e));if(!t.ok)throw await vd(t,`read ${e}`);const n=await t.text(),i=t.headers.get("ETag");return i&&gd.set(e,{text:n,etag:i}),n},async write(e,t,n){const i=(n==null?void 0:n.base)===void 0?void 0:gd.get(e),o=i&&i.text===(n==null?void 0:n.base)?{"If-Match":i.etag}:{},c=await fetch(kd(e),{method:"PUT",body:t,headers:o});if(!c.ok)throw await vd(c,`write ${e}`);gd.delete(e)},async create(e,t){const n=await fetch(kd(e),{method:"PUT",body:t,headers:{"If-None-Match":"*"}});if(n.status===412)return!1;if(!n.ok)throw await vd(n,`create ${e}`);return!0},watch(e){return Ya(e)}},kC=15*6e4;class vC{constructor(t){oe(this,"leases",[]);oe(this,"changes",new ui);oe(this,"logged",new Set);oe(this,"since",Date.now()-kC);this.activity=t}subscribe(t){return this.changes.on(t)}set(t){var n;this.leases=t;for(const i of t){const o=`${i.mapId}/${i.ticketId}/${(n=i.returned)==null?void 0:n.at}`;!i.returned||i.returned.at<this.since||this.logged.has(o)||(this.logged.add(o),this.activity.push({source:"system",level:"warn",ticketId:i.ticketId,text:fN(i)}))}this.changes.emit(t)}async release(t,n,i){const o=await fetch(`${re()}/agents/leases/release`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,ticketId:n,by:i})});if(!o.ok)throw new Error((await o.json().catch(()=>({}))).error??`HTTP ${o.status}`)}}function wC(e){e.remoteAnswer=(t,n,i)=>{fetch(`${re()}/agents/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:t.sessionId,questionId:t.id,text:n,author:i})}).then(async o=>{if(!o.ok)throw new Error((await o.json().catch(()=>({}))).error??`HTTP ${o.status}`)}).catch(o=>e.push({source:"system",level:"alert",sessionId:t.sessionId,text:`Answer not delivered to ${t.agent} · ${o.message}`}))}}function yC(e){const t=ki(),n=()=>{const i=t.start();fetch(`${re()}/agents/leases`).then(o=>o.ok?o.json():{leases:[]}).then(({leases:o})=>i()&&e.set(o)).catch(()=>{})};vi("leases",i=>{t.pushed(),e.set(JSON.parse(i).leases)}),as(n),n()}function xC(e){let t=0;const n=new Map,i=()=>{const o=t;fetch(`${re()}/agents`).then(c=>c.ok?c.json():{sessions:[]}).then(({sessions:c})=>[...c].reverse().filter(d=>(n.get(d.session.id)??0)<=o).forEach(d=>e.syncRemote(d))).catch(()=>{})};vi("agent",o=>{const c=JSON.parse(o);n.set(c.session.id,++t),e.syncRemote(c)}),as(i),i()}function Zp(e,t){wC(e),yC(t),xC(e)}function eg(e){const t=n=>`${Ma}:${e}:${n}`;return{get:n=>localStorage.getItem(t(n)),set:(n,i)=>{try{localStorage.setItem(t(n),i)}catch{}}}}const jC=["markdown","github","linear"];function bC(){const e=new URLSearchParams(location.search).get("tracker");return e&&jC.includes(e)?e:Fu().tracker}function SC(e){let t,n;const i=new aS,o=new vC(i),c={},d=Qb(re());if(e==="github"||e==="linear"){const m=new XN(e,re());m.openEvents=g=>new Dv(re(),g),t=m,n=fetch(`${re()}/trackers`).then(g=>g.json()).catch(()=>{}).then(g=>{m.location=(e==="github"?g==null?void 0:g.github.repo:[g==null?void 0:g.linear.teamKey,g==null?void 0:g.linear.projectName].filter(Boolean).join(" · "))||m.location;const k=eg(`${e}:${m.location}`);c.presence=new Ip(k),i.ledger=new Rp(k),Zp(i,o)})}else t=new YN(gC,`./${J.dataDir}`),n=fetch(`${re()}/list`).then(m=>m.json()).catch(()=>({root:"default"})).then(({root:m})=>{const g=eg(m);c.presence=new Ip(g),i.ledger=new Rp(g),Zp(i,o)});const u=uS(t),f=u.adapter;return{kind:e,ready:n,get presence(){return c.presence},adapter:f,journal:d,monitor:u,activity:i,leases:o}}const gn=e=>e.status==="running",NC=e=>gn(e)&&!!e.waitingOn,$C={blocking:0,soon:1,fyi:2};function CC(e,t,n){const i=e.filter(d=>d.sessionId===t),o=i.find(d=>d.id===n);if(o)return o;const c=d=>$C[d.urgency??"soon"];return[...i].sort((d,u)=>c(d)-c(u)||d.at-u.at)[0]}function is(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 i=Math.floor(n/60);if(i<24)return`${i} h ago`;const o=Math.floor(i/24);return o<30?o===1?"yesterday":`${o} days ago`:`on ${new Date(e).toISOString().slice(0,10)}`}const ca={opus:"Opus",sonnet:"Sonnet",haiku:"Haiku",fable:"Fable",codex:"Codex",mini:"mini",nano:"nano"},TC=e=>/^\d{8}$/.test(e)||e==="latest",EC=e=>/^\d{1,2}$/.test(e);function AC(e){const t=e.find(i=>ca[i]);if(!t)return;const n=e.filter(EC).join(".");return n?`${ca[t]} ${n}`:ca[t]}function IC(e){const[,t,...n]=e,i=n.filter(o=>!TC(o)).map(o=>ca[o]??o);return[`GPT-${t??""}`,...i].join(" ").trim()}function Sr(e){const t=e==null?void 0:e.trim();if(!t)return;const n=t.toLowerCase().split(/[-_/]/).filter(Boolean);return n.includes("claude")?AC(n)??t:n[0]==="gpt"?IC(n):t.replace(/[-_](\d{8}|latest)$/,"")}const RC=/^slack:([A-Z0-9]+)$/i;function mi(e,t){var c;const n=(c=RC.exec(e))==null?void 0:c[1];if(!n)return e;if(t!=null&&t.owners.some(d=>d.id===n))return"you (Slack)";const i=t==null?void 0:t.allow.find(d=>d.id===n),o=(i==null?void 0:i.realName)||(i==null?void 0:i.name);return o?`${o} (Slack)`:"Slack user"}function zu(e,t){const n=mi(e.decidedBy,t);return e.decidedByName?`${e.decidedByName} (${n})`:n}function bs({n:e,urgent:t,pop:n,hideZero:i}){return s.jsx("span",{className:ue("badge",t&&"urgent",n&&t&&"pop",i&&!e&&"zero"),children:i&&!e?"":e})}function R({variant:e="default",size:t="md",on:n,className:i,type:o,...c}){return s.jsx("button",{type:o??"button",className:ue("btn",e!=="default"&&e,t==="sm"&&"sm",n&&"on",i),...c})}function Qt({as:e="div",tone:t,on:n,className:i,children:o,...c}){return s.jsx(e,{className:ue("card",t,n&&"on",i),...c,children:o})}function Uu({what:e,onReviewAgain:t}){return s.jsxs("div",{className:"changed-notice edge-note edge-attention",children:[s.jsxs("p",{className:"t-meta",children:[e," changed since you opened it: read it again before you approve it."]}),s.jsx(R,{size:"sm",onClick:t,children:"Review again"})]})}const MC=6,LC=2e4,OC=/[\\`*_{}[\]()#+\-.!~<>|]/,tg=/https?:\/\/[^\s<>]+/y,PC=/[.,;:!?'")\]]+$/,DC=1e3;function Ir(e,t={depth:0,inLink:!1}){if(e.length>LC||t.depth>MC)return[{kind:"text",text:e}];const n=[];let i="",o=0;for(;o<e.length;){const c=_C(e,o,t);if(!c){i+=e[o++];continue}if(o=c.next,"text"in c){i+=c.text;continue}i&&n.push({kind:"text",text:i}),i="",n.push(...c.nodes)}return i&&n.push({kind:"text",text:i}),n}function _C(e,t,n){switch(e[t]){case"\\":return BC(e,t);case`
136
+ `:return{nodes:[{kind:"break"}],next:t+1};case"`":return FC(e,t);case"*":case"_":return zC(e,t,n);case"~":return e[t+1]==="~"?zv({text:e,i:t,ctx:n,size:2}):void 0;case"!":return e[t+1]==="["?HC(e,t,n):void 0;case"[":return WC(e,t,n);case"<":return KC(e,t,n);case"h":return GC(e,t,n);default:return}}function BC(e,t){const n=e[t+1];return n===`
137
+ `?{nodes:[{kind:"break"}],next:t+2}:n&&OC.test(n)?{text:n,next:t+2}:void 0}function FC(e,t){let n=1;for(;e[t+n]==="`";)n++;const i="`".repeat(n),o=e.indexOf(i,t+n);if(o<0)return{text:i,next:t+n};let c=e.slice(t+n,o).replace(/\n/g," ");return c.length>2&&c.startsWith(" ")&&c.endsWith(" ")&&(c=c.slice(1,-1)),{nodes:[{kind:"code",text:c}],next:o+n}}function zC(e,t,n){const i=e[t];if(i==="_"&&/\w/.test(e[t-1]??""))return;const o=e[t+1]===i?2:1;return zv({text:e,i:t,ctx:n,size:o})}function zv(e){const{text:t,i:n,size:i}=e,o=t[n],c=n+i;if(!t[c]||/\s/.test(t[c]))return;const d=UC({text:t,from:c,c:o,size:i});if(d<0)return;const u=Ir(t.slice(c,d),{...e.ctx,depth:e.ctx.depth+1});return o==="~"?{nodes:[{kind:"del",children:u}],next:d+i}:{nodes:[{kind:i===2?"strong":"em",children:u}],next:d+i}}function UC(e){const{text:t,c:n,size:i}=e;let o=t.indexOf(n,e.from+1);for(;o>=0;){let c=1;for(;t[o+c]===n;)c++;const d=c===i||c>=3,u=n==="_"&&/\w/.test(t[o+c]??"");if(d&&!/\s/.test(t[o-1])&&!u)return o+c-i;o=t.indexOf(n,o+c)}return-1}function WC(e,t,n){const i=Uv(e,t);if(!i)return;const o=Ir(i.label,{depth:n.depth+1,inLink:!0}),c=n.inLink?void 0:At(i.url);return c?{nodes:[{kind:"link",href:c,children:o}],next:i.next}:{nodes:o,next:i.next}}function HC(e,t,n){const i=Uv(e,t+1);if(i)return{nodes:Ir(i.label,{depth:n.depth+1,inLink:!0}),next:i.next}}function Uv(e,t){const n=ng({text:e,i:t,open:"[",shut:"]"});if(n<0||e[n+1]!=="(")return;const i=ng({text:e,i:n+1,open:"(",shut:")"});if(i<0)return;const c=(e.slice(n+2,i).trim().split(/\s+/)[0]??"").replace(/^<(.*)>$/,"$1");return{label:e.slice(t+1,n),url:c,next:i+1}}function ng(e){const{text:t,open:n,shut:i}=e;let o=0;const c=Math.min(t.length,e.i+DC);for(let d=e.i;d<c;d++)if(t[d]==="\\")d++;else if(t[d]===n)o++;else if(t[d]===i&&--o===0)return d;return-1}function KC(e,t,n){const i=e.indexOf(">",t+1);if(i<0)return;const o=e.slice(t+1,i),c=!n.inLink&&!/\s/.test(o)?At(o):void 0;return c?{nodes:[{kind:"link",href:c,children:[{kind:"text",text:o}]}],next:i+1}:void 0}function GC(e,t,n){var c;if(n.inLink||/[^\s(]/.test(e[t-1]??" "))return;tg.lastIndex=t;const i=(c=tg.exec(e))==null?void 0:c[0].replace(PC,""),o=i?At(i):void 0;if(!(!i||!o))return{nodes:[{kind:"link",href:o,children:[{kind:"text",text:i}]}],next:t+i.length}}const Wu=/^ {0,3}(`{3,}|~{3,})/,Wv=/^ {0,3}(#{1,6})(?:\s+(.*?))?\s*#*\s*$/,Hu=/^ {0,3}([-*_])(?:\s*\1){2,}\s*$/,ja=/^ {0,3}>\s?/,VC=/^( {0,3})([-*+]|\d{1,9}[.)])(\s+|$)/,qC=6;function Hv(e){const t=e.replace(/\r\n?/g,`
138
+ `).replace(/\t/g," ").split(`
139
+ `);return Ku(t,0)}function Ku(e,t){const n=[];let i=0;for(;i<e.length;){if(!e[i].trim()){i++;continue}const o=QC(e,i,t);n.push(o.block),i=o.next}return n}function QC(e,t,n){const i=e[t];if(Wu.test(i))return YC(e,t);const o=i.match(Wv);if(o)return{block:{kind:"heading",level:o[1].length,text:o[2]??""},next:t+1};if(Hu.test(i))return{block:{kind:"rule"},next:t+1};const c=n<qC;if(c&&ja.test(i))return JC(e,t,n);const d=c?Ja(i):void 0;return d?ZC({lines:e,i:t,depth:n,first:d}):XC(e,t)}function YC(e,t){const n=e[t].match(Wu)[1],i=d=>{const u=d.trim();return/^(`{3,}|~{3,})$/.test(u)&&u[0]===n[0]&&u.length>=n.length&&la(d)<4},o=[];let c=t+1;for(;c<e.length&&!i(e[c]);)o.push(e[c++]);return{block:{kind:"code",text:o.join(`
140
+ `)},next:c+1}}function JC(e,t,n){const i=[];let o=t;for(;o<e.length&&ja.test(e[o]);)i.push(e[o++].replace(ja,""));return{block:{kind:"quote",blocks:Ku(i,n+1)},next:o}}function XC(e,t){const n=[e[t].trim()];let i=t+1;for(;i<e.length&&e[i].trim()&&!Kv(e[i]);)n.push(e[i++].trim());return{block:{kind:"paragraph",text:n.join(`
141
+ `)},next:i}}function ZC(e){const{lines:t,first:n}=e,i=[];let o=e.i;for(;o<t.length;){const c=t[o].trim()?o:Gv(t,o),d=c<0?void 0:Ja(t[c]);if(!d||d.ordered!==n.ordered||d.indent>n.indent+1)break;const u=eT(t,c,d);i.push(Ku(u.lines,e.depth+1)),o=u.next}return{block:{kind:"list",ordered:n.ordered,start:n.start,items:i},next:o}}function eT(e,t,n){const i=[n.rest];let o=t+1;for(;o<e.length;){const c=e[o],d=u=>la(u)>=n.content||la(u)>n.indent&&!!Ja(u);if(c.trim())if(d(c))i.push(c.slice(Math.min(la(c),n.content)));else{if(Kv(c))break;i.push(c.trim())}else{const u=Gv(e,o);if(u<0||!d(e[u]))break;i.push("")}o++}return{lines:i,next:o}}function Ja(e){const t=e.match(VC);if(!t||Hu.test(e))return;const n=/\d/.test(t[2]);return{ordered:n,start:n?parseInt(t[2],10):1,indent:t[1].length,content:t[0].length,rest:e.slice(t[0].length)}}const Kv=e=>Wu.test(e)||Wv.test(e)||Hu.test(e)||ja.test(e)||!!Ja(e),la=e=>e.length-e.trimStart().length;function Gv(e,t){for(let n=t;n<e.length;n++)if(e[n].trim())return n;return-1}const Vv=e=>e.map(t=>{switch(t.kind){case"text":case"code":return t.text;case"break":return" ";case"strong":case"em":case"del":case"link":return Vv(t.children);default:return t}}).join(""),tT=e=>Vv(Ir(e)).replace(/\s+/g," ").trim();function eu(e){for(const t of e){const n=nT(t);if(n)return n}}function nT(e){switch(e.kind){case"paragraph":case"heading":return tT(e.text)||void 0;case"list":return eu(e.items.flat());case"quote":return eu(e.blocks);case"code":case"rule":return;default:return e}}const sT=/^(.+?[.!?])\s+(?=[A-Z0-9])/;function Gu(e,t=160){var d;const n=eu(Hv(e))??"",i=((d=n.match(sT))==null?void 0:d[1])??n;if(i.length<=t)return i;const o=i.slice(0,t-1),c=o.lastIndexOf(" ");return`${(c>t/2?o.slice(0,c):o).trimEnd()}…`}function gr({nodes:e}){return s.jsx(s.Fragment,{children:e.map((t,n)=>{switch(t.kind){case"text":return t.text;case"break":return s.jsx("br",{},n);case"code":return s.jsx("code",{className:"md-code",children:t.text},n);case"strong":return s.jsx("strong",{children:s.jsx(gr,{nodes:t.children})},n);case"em":return s.jsx("em",{children:s.jsx(gr,{nodes:t.children})},n);case"del":return s.jsx("del",{children:s.jsx(gr,{nodes:t.children})},n);case"link":return s.jsx("a",{href:t.href,target:"_blank",rel:"noreferrer noopener",children:s.jsx(gr,{nodes:t.children})},n);default:return t}})})}function ba({text:e,className:t}){const n=w.useMemo(()=>Ir(e),[e]);return s.jsx("span",{className:t,children:s.jsx(gr,{nodes:n})})}function tu({blocks:e}){return s.jsx(s.Fragment,{children:e.map((t,n)=>{switch(t.kind){case"paragraph":return s.jsx("p",{children:s.jsx(ba,{text:t.text})},n);case"heading":return s.jsx("p",{className:`md-h md-h${Math.min(t.level,3)}`,children:s.jsx(ba,{text:t.text})},n);case"list":{const i=t.items.map((o,c)=>s.jsx("li",{children:s.jsx(tu,{blocks:o})},c));return t.ordered?s.jsx("ol",{start:t.start===1?void 0:t.start,children:i},n):s.jsx("ul",{children:i},n)}case"code":return s.jsx("pre",{className:"md-pre",children:s.jsx("code",{children:t.text})},n);case"quote":return s.jsx("blockquote",{children:s.jsx(tu,{blocks:t.blocks})},n);case"rule":return s.jsx("hr",{},n);default:return t}})})}const Sa=w.forwardRef(function(t,n){const i=w.useMemo(()=>Hv(t.text),[t.text]);return s.jsx("div",{ref:n,className:ue("md t-body",t.className),children:s.jsx(tu,{blocks:i})})});function Vu({text:e,className:t,markdown:n}){const i=w.useRef(null),[o,c]=w.useState(!1),[d,u]=w.useState(!1);w.useLayoutEffect(()=>{const m=i.current;m&&!o&&u(m.scrollHeight>m.clientHeight+1)},[e,o]);const f=!o&&"cut";return s.jsxs("div",{className:"clamp",children:[n?s.jsx(Sa,{ref:i,text:e,className:ue("clamp-md",f,d&&f&&"faded",t)}):s.jsx("p",{ref:i,className:ue("t-body clamp-text",f,t),children:e}),(d||o)&&s.jsx("button",{type:"button",className:"d-more","aria-expanded":o,onClick:()=>c(!o),children:o?"Show less":"Read more"})]})}function at({on:e,title:t,sub:n,disabled:i,onClick:o}){return s.jsxs(Qt,{as:"button",type:"button",className:"choice",on:e,disabled:i,onClick:o,children:[s.jsx("b",{className:"choice-title t-row-title",children:t}),n&&s.jsx("span",{className:"c-sub",children:n})]})}function Ot(e){return s.jsxs("section",{className:ue("d-section",e.className),children:[s.jsxs("header",{className:"d-section-head",children:[s.jsx("span",{className:"t-label",children:e.label}),e.onEdit&&s.jsx("button",{type:"button",className:"d-edit",onClick:e.onEdit,children:e.editLabel??"Edit"})]}),e.children]})}function an(e){const[t,n]=w.useState(!1),i=e.label??"Details";return s.jsxs("div",{className:"disclosure",children:[s.jsx("button",{type:"button",className:"d-more","aria-expanded":t,onClick:()=>n(!t),children:t?`Hide ${i.toLowerCase()}`:i}),t&&s.jsx("div",{className:"disclosure-body",children:e.children})]})}function Te({children:e}){return s.jsx("div",{className:"empty",children:e})}function Et({label:e,children:t}){return s.jsxs("div",{className:"fact",children:[s.jsx("dt",{className:"t-label",children:e}),s.jsx("dd",{children:t})]})}function An({title:e,hint:t,art:n}){return s.jsxs("div",{className:n?"empty-state has-art":"empty-state",children:[n,s.jsxs("div",{className:"es-words",children:[s.jsx("span",{className:"es-title",children:e}),t&&s.jsx("span",{className:"es-hint",children:t})]})]})}function mt({label:e,children:t,className:n}){return s.jsxs("label",{className:ue("field",n),children:[e,t]})}const Xa=w.forwardRef(function({value:t,onValueChange:n,onSubmit:i,action:o="Send",actionDisabled:c,className:d,...u},f){return s.jsxs("form",{className:ue("input-row",d),onSubmit:m=>{m.preventDefault(),i(t)},children:[s.jsx("textarea",{ref:f,rows:1,value:t,onChange:m=>n(m.target.value),onKeyDown:m=>{m.key==="Enter"&&!m.shiftKey&&(m.preventDefault(),i(t))},...u}),s.jsx(R,{type:"submit",variant:"primary",disabled:c??(u.disabled||!t.trim()),children:o})]})});function wi({text:e}){return s.jsx("span",{className:"info-tip","data-tip":e,"data-tip-scout":!0,tabIndex:0,role:"img","aria-label":e,children:s.jsxs("svg",{viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":"true",children:[s.jsx("circle",{cx:"7",cy:"3.7",r:"1.3"}),s.jsx("path",{d:"M5.6 6.300H8v4.200h1v1.200H5v-1.200h1.200V7.500h-.6z"})]})})}function Ke({as:e="span",variant:t="chip",hot:n,size:i,className:o,children:c,title:d}){return s.jsx(e,{className:ue(t==="chip"?"chip-label":"mono-label",n&&"hot",i==="sm"&&(t==="chip"?"sm":"xs"),o),title:d,children:c})}const iT=e=>typeof e=="string"?{text:e}:e,rT=e=>ue(e.code&&"t-code",e.strong&&"strong",e.urgent&&"urgent",e.className);function _(e){const t=e.parts.filter(n=>!!n&&(typeof n=="string"||!!n.text)).map(iT);return!t.length&&!e.children?null:s.jsxs("span",{className:ue("meta-line t-meta",e.className),children:[t.map((n,i)=>s.jsxs("span",{children:[i>0&&s.jsx("span",{className:"sep",children:" · "}),s.jsx("span",{className:rT(n)||void 0,title:n.tip,children:n.text})]},i)),e.children]})}function qu(e){return s.jsxs("div",{className:"ds-load-failed",role:"alert",children:[s.jsx(_,{parts:[e.what,e.reason]}),s.jsx(R,{size:"sm",variant:"ghost",onClick:e.onRetry,children:"Retry"})]})}function yi(e){const t=Array.from({length:e.rows??0},(n,i)=>i);return s.jsxs("div",{className:ue("ds-loading",e.className),role:"status","aria-live":"polite",children:[s.jsxs("span",{className:"ds-loading-line t-meta",children:[s.jsx("span",{className:"ds-spinner","aria-hidden":"true"}),e.label]}),t.length>0&&s.jsx("ul",{className:"ds-skeleton-list","aria-hidden":"true",children:t.map(n=>s.jsxs("li",{className:"ds-skeleton-row",children:[s.jsx("span",{className:"ds-skeleton-bar title"}),s.jsx("span",{className:"ds-skeleton-bar meta"})]},n))})]})}const oT="M25.53 10.5 A11 11 0 1 1 16 5",aT="M20 5 L14.6 1.6 L14.6 8.4 Z";function Rr({variant:e="mark",state:t="ok",size:n=20,className:i="",title:o}){const c=n<=14?3:2.4;return s.jsxs("svg",{className:`scout-mark mm-${e} mm-${t} ${i}`,viewBox:"0 0 32 32",width:n,height:n,role:o?"img":void 0,"aria-label":o,"aria-hidden":o?void 0:!0,children:[e==="status"||e==="alert"?s.jsx("circle",{cx:"16",cy:"16",r:"11",fill:"none",stroke:"currentColor",strokeWidth:c,strokeDasharray:t==="syncing"?"5 3.6":void 0}):s.jsx("path",{d:oT,fill:"none",stroke:"currentColor",strokeWidth:c,strokeLinecap:"butt"}),(e==="mark"||e==="action")&&s.jsx("path",{d:aT,fill:"currentColor"}),e==="action"&&s.jsx("path",{d:"M13 11 L21.5 16 L13 21 Z",fill:"currentColor"}),(e==="mark"||e==="voice")&&s.jsx("circle",{cx:"16",cy:"16",r:e==="voice"?4:3.4,fill:"currentColor"}),e==="status"&&(t==="idle"?s.jsx("circle",{cx:"16",cy:"16",r:"3.4",fill:"none",stroke:"currentColor",strokeWidth:"1.6"}):s.jsx("circle",{cx:"16",cy:"16",r:"4.2",fill:"currentColor"})),e==="alert"&&s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"14.4",y:"8.5",width:"3.2",height:"9.5",fill:"currentColor"}),s.jsx("rect",{x:"14.4",y:"20.5",width:"3.2",height:"3.2",fill:"currentColor"})]})]})}function nu({parts:e,className:t,as:n="div"}){const i=e.filter(o=>o!=null&&o!==!1&&o!=="");return s.jsx(n,{className:ue("meta",t),children:i.map((o,c)=>s.jsxs("span",{children:[c>0&&" · ",o]},c))})}function qv({items:e,label:t="More actions"}){const[n,i]=w.useState(!1),o=w.useRef(null);return w.useEffect(()=>{if(!n)return;const c=u=>{var f;(f=o.current)!=null&&f.contains(u.target)||i(!1)},d=u=>{u.key==="Escape"&&i(!1)};return document.addEventListener("mousedown",c),document.addEventListener("keydown",d),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",d)}},[n]),e.length?s.jsxs("span",{className:"more-menu",ref:o,children:[s.jsx("button",{type:"button",className:ue("btn more-btn",n&&"on"),"aria-label":t,"aria-haspopup":"menu","aria-expanded":n,onClick:()=>i(!n),children:"⋯"}),n&&s.jsx("span",{className:"more-list",role:"menu",children:e.map(c=>s.jsx("button",{type:"button",role:"menuitem",className:ue("more-item",c.danger&&"danger"),"data-tip":c.tip,onClick:()=>{i(!1),c.onSelect()},children:c.label},c.id))})]}):null}const sg=()=>{const e=document.documentElement.dataset.theme;return e?e==="night":matchMedia("(prefers-color-scheme: dark)").matches};function Qv(){const[e,t]=w.useState(sg);return w.useEffect(()=>{const n=()=>t(sg()),i=matchMedia("(prefers-color-scheme: dark)");i.addEventListener("change",n);const o=new MutationObserver(n);return o.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{i.removeEventListener("change",n),o.disconnect()}},[]),e}function cT(){const e=()=>window.innerWidth>=1440?"wide":window.innerWidth>=1024?"laptop":"mobile",[t,n]=w.useState(e);return w.useEffect(()=>{const i=()=>n(e());return window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)},[]),t}const lT=15e3,ig=["pointerdown","pointermove","keydown","wheel","touchstart"];function dT(e,t,n,i){const[o,c]=w.useState(null),[d,u]=w.useState(!1),[f,m]=w.useState(!1),g=w.useRef(),k=w.useRef(Date.now()),y=w.useRef(!1),b=n.awayMinutes*6e4,S=w.useRef(t);S.current=t;const x=w.useRef(i);x.current=i;const $=w.useCallback((I,Q)=>{const Z=S.current;return PS({snaps:Object.values(Z.allSnaps),decisions:Z.decisions,activity:Z.activity,ledger:e.activity.ledger,since:q=>{var ee;return I[q]??Q??((ee=Z.allSnaps[q])==null?void 0:ee.map.createdAt)??Date.now()},currentMapId:Z.mapId,attention:x.current})},[e]),N=w.useCallback((I=Date.now())=>{var Q;return(Q=e.presence)==null?void 0:Q.markSeen(S.current.maps.map(Z=>Z.id),I)},[e]),O=w.useCallback(()=>{const I=e.presence;if(!I)return;const Q=I.lastSeenAny();if(Q!==void 0&&Date.now()-Q>=b){const Z=I.snapshot();$(Z,Q).changed&&(g.current={seen:Z,any:Q},u(!0),n.enabled?c(Z):m(!0))}N()},[e,b,n.enabled,$,N]);w.useEffect(()=>{!t.loaded||y.current||!e.presence||(y.current=!0,O())},[t.loaded,e,O]),w.useEffect(()=>{const I=()=>{const q=Date.now()-k.current>=b;k.current=Date.now(),q&&y.current&&document.visibilityState==="visible"&&O()},Q=()=>{if(document.visibilityState!=="visible"){y.current&&N(Date.now()-k.current<b?Date.now():k.current);return}k.current=Date.now(),y.current&&O()};for(const q of ig)window.addEventListener(q,I,{passive:!0});document.addEventListener("visibilitychange",Q);const Z=setInterval(()=>{y.current&&document.visibilityState==="visible"&&N(k.current)},lT);return()=>{for(const q of ig)window.removeEventListener(q,I);document.removeEventListener("visibilitychange",Q),clearInterval(Z)}},[b,O,N]);const D=w.useMemo(()=>{var I;return o?$(o,(I=g.current)==null?void 0:I.any):void 0},[o,$,t.allSnaps,t.decisions,t.activity,i]),F=w.useMemo(()=>D?FS(D):"",[D]);w.useEffect(()=>{o&&m(!1)},[o]);let K="none";return f?K="new":d&&(K="seen"),{shown:o!==null,status:K,briefing:D,line:F,open:()=>{const I=g.current;I&&c(I.seen)},dismiss:()=>c(null)}}function uT(e){const[t,n]=w.useState(e.leases.leases);return w.useEffect(()=>e.leases.subscribe(n),[e]),t}const hT="That changed while you were on it, so nothing was written. It is reloaded now: look again, then redo the change.";function fT(e){var Y;const[t,n]=w.useState([]),[i,o]=w.useState(),[c,d]=w.useState(),[u,f]=w.useState({}),[m,g]=w.useState({}),[k,y]=w.useState(!1),[b,S]=w.useState(e.activity.snapshot),[x,$]=w.useState(e.monitor.health),N=uT(e);w.useEffect(()=>e.monitor.subscribe($),[e]);const[O,D]=w.useState(null),[F,K]=w.useState(),[I,Q]=w.useState(),Z=w.useRef(),q=w.useRef(),ee=w.useRef(new Set),Se=w.useRef();Se.current=c;const ve=w.useCallback(U=>{Z.current=U,o(U),D(null)},[]),[be]=w.useState(ki),ae=w.useCallback(async()=>{var je;const U=be.start(),E=await e.adapter.listMaps();let B=Z.current;const ce=q.current;ce&&E.some(pe=>pe.id===ce)?(q.current=void 0,B=ce,B!==Z.current&&ve(B)):(!B||!E.some(pe=>pe.id===B))&&(B=(je=d0(E)[0])==null?void 0:je.id,B!==Z.current&&ve(B));const[me,ye]=await Promise.all([Promise.all(E.map(pe=>e.adapter.loadMap(pe.id))),Promise.all(E.map(pe=>e.adapter.listDecisions(pe.id)))]);U()&&(n(E),f(Object.fromEntries(me.map(pe=>[pe.map.id,pe]))),g(Object.fromEntries(E.map((pe,$e)=>[pe.id,ye[$e]]))),y(!0),d(me.find(pe=>pe.map.id===B)))},[e,ve,be]);w.useEffect(()=>{let U,E=()=>{},B=()=>{},ce=!0;const me=()=>{clearTimeout(U),U=setTimeout(()=>void ae().catch(ge=>K(String(ge))),40)},ye=as(me),je=(ge,Ge)=>gn(ge)&&e.activity.isRemote(ge.id)&&(!Ge||!ge.mapId||ge.mapId===Ge),pe=ge=>{var Ge;return(Ge=Se.current)==null?void 0:Ge.tickets.find(In=>In.id===ge)},$e=ge=>{const Ge=cS(ge,pe),In=ge.kind==="external.changed"&&e.activity.snapshot.sessions.some(Is=>je(Is,ge.mapId)),Dr=!("mapId"in ge)||!ge.mapId||ge.mapId===Z.current||ge.kind==="map.created";Ge&&!In&&Dr&&e.activity.push(Ge),me()};return e.ready.then(()=>{ce&&(E=e.adapter.subscribe($e),B=e.activity.subscribe(S),e.activity.push({source:"system",level:"ok",text:`Online · tracker ${e.adapter.label.toLowerCase()} · ${e.adapter.location}`}),ae().catch(ge=>K(String(ge))))}),()=>{ce=!1,E(),B(),ye(),clearTimeout(U)}},[e,ae]),w.useEffect(()=>{i&&ae().catch(U=>K(String(U)))},[i,ae]),w.useEffect(()=>{for(const U of b.sessions)U.mode!=="chart"||!U.mapId||!e.activity.isRemote(U.id)||ee.current.has(U.id)||(ee.current.add(U.id),!(U.status!=="running"&&Date.now()-(U.endedAt??0)>6e4)&&(q.current=U.mapId,ae().catch(E=>K(String(E)))))},[b.sessions,e,ae]);const Ie=(Y=b.pending[0])==null?void 0:Y.sessionId;w.useEffect(()=>{if(!Ie)return;const U=E=>e.activity.snapshot.sessions.some(B=>B.id===E&&gn(B));Q(E=>U(E)?E:Ie)},[Ie,e]);const we=w.useCallback(async(U,E)=>{e.activity.push({source:"trail lead",agent:wt,level:"warn",text:U});try{K(void 0),await E()}catch(B){const ce=B.stale===!0,me=ce?hT:B.message??String(B);K(me),e.activity.push({source:"trail lead",agent:wt,level:"alert",text:`Rejected · ${me}`}),ce&&ae().catch(ye=>K(String(ye)))}},[e,ae]),Ne=w.useMemo(()=>L$({rt:e,guard:we,setMapId:ve,mapIdRef:Z,snapRef:Se,setChatSession:Q,setSelection:D}),[we,e,ve]),z=w.useMemo(()=>Object.values(u).flatMap(U=>yS(U,m[U.map.id]??[])).sort((U,E)=>E.decidedAt-U.decidedAt),[u,m]);return{maps:t,allSnaps:u,mapId:i,snap:c,activity:b,health:x,selection:O,setSelection:D,error:F,chatSession:I,decisions:z,leases:N,loaded:k,actions:Ne}}function gt(e=1e3){const[t,n]=w.useState(Date.now());return w.useEffect(()=>{const i=setInterval(()=>n(Date.now()),e);return()=>clearInterval(i)},[e]),t}function mT(){const[e,t]=w.useState(Fu),n=w.useCallback(i=>{t(o=>{const c={...o,...i};return localStorage.setItem(Ma,JSON.stringify(c)),c})},[]);return[e,n]}const Yv=()=>{var e,t;return!!((e=pt())!=null&&e.theme)&&!((t=pt())!=null&&t.themeSave)},Jv=e=>{var t;return((t=pt())==null?void 0:t.theme)??e};function pT(e){const t=pt();t!=null&&t.themeSave&&(t.theme=e,Ka(e),fetch(t.themeSave,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({theme:e})}).catch(()=>{}))}function gT(){const[e,t]=mT(),[n,i]=w.useReducer(c=>c+1,0);w.useEffect(()=>Ka(Jv(e.theme)),[e.theme,n]);const o=w.useCallback(c=>{c.theme&&(pT(c.theme),i()),t(c)},[t]);return[e,o]}function Mr(){return w.useSyncExternalStore(ss.subscribe,ss.get)}function kT({className:e,size:t=18}){return s.jsx("span",{className:e,"aria-hidden":"true",children:s.jsx(Tv,{size:t,variant:Qv()?"night":"crt"})})}function Be({as:e="section",className:t,style:n,frameless:i,children:o,...c}){return s.jsx(e,{className:ue("panel",i&&"frameless",t),style:n,...c,children:o})}function xi({tone:e,className:t,children:n,title:i}){return s.jsx("span",{className:ue("pill",e,t),title:i,children:n})}function Tn({label:e,value:t,layout:n="stack",urgent:i,title:o,className:c}){return s.jsxs("span",{className:ue("readout",n!=="stack"&&n,i&&"urgent",c),title:o,children:[s.jsx("span",{className:"mono-label",children:e}),n==="inline"&&" ",s.jsx("b",{children:t})]})}function fe(e){const{as:t="div",edge:n="neutral"}=e,i=e.onOpen?"button":"div";return s.jsxs(t,{className:ue("ds-row",`edge-${n}`,e.selected&&"on",e.className),children:[s.jsxs(i,{className:"ds-row-main",...e.onOpen?{type:"button",onClick:e.onOpen}:{},title:e.titleText,"aria-current":e.current,children:[s.jsxs("span",{className:"ds-row-top",children:[s.jsx("span",{className:"ds-row-title t-row-title",children:e.title}),e.trailing&&s.jsx("span",{className:"ds-row-trail t-meta",children:e.trailing})]}),e.context&&s.jsx("span",{className:"ds-row-context",children:e.context}),e.detail&&s.jsx("span",{className:"ds-row-detail t-meta",title:e.detailText,children:e.detail})]}),e.actions&&s.jsx("span",{className:"ds-row-actions",children:e.actions}),e.below&&s.jsx("div",{className:"ds-row-below",children:e.below})]})}const Jn="#c8581e",vT={map:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M3 6l6-2.5 6 2.5 6-2.5v14.5L15 20.5 9 18l-6 2.5z"}),s.jsx("path",{d:"M9 3.5V18M15 6v14.5"}),s.jsx("path",{d:"M5.5 15c2-1 3-3 5-3.5s3-3 5-4",stroke:Jn,strokeDasharray:"2 2.2"})]}),note:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 3.5h14v13.5l-4 3.5H5z"}),s.jsx("path",{d:"M15 21v-4h4"}),s.jsx("path",{d:"M8.5 8h7M8.5 12h7",stroke:Jn})]}),book:s.jsxs(s.Fragment,{children:[s.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"}),s.jsx("path",{d:"M12 6.5v14"}),s.jsx("path",{d:"M15 9.5l3-.5M15 13l3-.5",stroke:Jn})]}),flag:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M6 21.5V3"}),s.jsx("path",{d:"M6 4c4-1.5 7 1.5 12 0v9c-5 1.5-8-1.5-12 0z",fill:Jn,stroke:Jn})]}),tent:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 4L2.5 20h19z"}),s.jsx("path",{d:"M12 11l-4 9h8z",fill:Jn,stroke:Jn}),s.jsx("path",{d:"M12 4l-1.5-2M12 4l1.5-2"})]}),mailbox:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 21.500V14"}),s.jsx("path",{d:"M4 14V9.500A4.5 4.5 0 0 1 8.5 5h7A4.5 4.5 0 0 1 20 9.500V14z"}),s.jsx("path",{d:"M8.5 5A4.5 4.5 0 0 1 13 9.500V14"}),s.jsx("path",{d:"M16 10V6.500M16 6.500h3v2.500h-3",stroke:Jn})]})};function Xv({name:e}){return s.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:vT[e]})}function yt({title:e,count:t,right:n,hot:i,sub:o,children:c,className:d,info:u,icon:f}){return s.jsxs("header",{className:ue("sec-h",o&&"sub",d),children:[c,f&&s.jsx(Xv,{name:f}),e!==void 0&&s.jsx(Ke,{as:o?"h3":"h2",hot:i,children:e}),u&&s.jsx(wi,{text:u}),t,n!==void 0&&s.jsx("span",{className:"sec-h-right",children:n})]})}function it(e){const{value:t,options:n,onChange:i}=e,[o,c]=w.useState(!1),[d,u]=w.useState(0),[f,m]=w.useState(),g=w.useRef(null),k=w.useRef(null),y=w.useId(),b=n.find(N=>N.value===t);w.useLayoutEffect(()=>{if(!o||!g.current)return;const N=g.current.getBoundingClientRect();m({left:N.left,top:N.bottom+4,minWidth:N.width})},[o]),w.useEffect(()=>{if(!o)return;const N=D=>{var F,K;D.target instanceof Node&&((F=k.current)!=null&&F.contains(D.target)||(K=g.current)!=null&&K.contains(D.target))||c(!1)},O=()=>c(!1);return document.addEventListener("mousedown",N),window.addEventListener("resize",O),window.addEventListener("scroll",O,!0),()=>{document.removeEventListener("mousedown",N),window.removeEventListener("resize",O),window.removeEventListener("scroll",O,!0)}},[o]),w.useEffect(()=>{var N,O;o&&((O=(N=k.current)==null?void 0:N.querySelector(`[data-i="${d}"]`))==null||O.scrollIntoView({block:"nearest"}))},[o,d]);const S=()=>{u(Math.max(0,n.findIndex(N=>N.value===t))),c(!0)},x=N=>{var D;const O=n[N];c(!1),(D=g.current)==null||D.focus(),O&&O.value!==t&&i(O.value)},$=N=>{if(!o){["ArrowDown","ArrowUp","Enter"," "].includes(N.key)&&(N.preventDefault(),S());return}const O=D=>u(F=>(F+D+n.length)%n.length);if(N.key==="ArrowDown")O(1);else if(N.key==="ArrowUp")O(-1);else if(N.key==="Home")u(0);else if(N.key==="End")u(n.length-1);else if(N.key==="Enter"||N.key===" ")x(d);else{if(N.key==="Escape"||N.key==="Tab")return c(!1);if(N.key.length===1){const D=n.findIndex(F=>F.label.toLowerCase().startsWith(N.key.toLowerCase()));D>=0&&u(D);return}else return}N.preventDefault()};return s.jsxs(s.Fragment,{children:[s.jsxs("button",{ref:g,type:"button",className:ue("select",e.compact&&"compact",o&&"open",e.className),role:"combobox","aria-haspopup":"listbox","aria-expanded":o,"aria-controls":y,"aria-label":e["aria-label"],"aria-activedescendant":o?`${y}-${d}`:void 0,disabled:e.disabled,onClick:()=>o?c(!1):S(),onKeyDown:$,children:[s.jsx("span",{className:"select-value",children:(b==null?void 0:b.label)??"—"}),s.jsx("span",{className:"select-caret","aria-hidden":"true"})]}),o&&f&&s.jsx("ul",{ref:k,id:y,className:"select-menu",role:"listbox",style:f,children:n.map((N,O)=>s.jsxs("li",{id:`${y}-${O}`,"data-i":O,role:"option","aria-selected":N.value===t,className:ue(O===d&&"active"),onMouseEnter:()=>u(O),onMouseDown:D=>D.preventDefault(),onClick:()=>x(O),children:[s.jsx("span",{className:"select-label",children:N.label}),N.hint&&s.jsx("span",{className:"select-hint",children:N.hint})]},N.value))})]})}function wT(e){return s.jsx("div",{className:`tabs ${e.className??""}`,role:"tablist",children:e.items.map(t=>s.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&&s.jsx("span",{className:"n",children:t.n})]},t.id))})}function yT(e){return s.jsx("span",{className:ue("tag",e.tone,e.code&&"t-code",e.className),"data-tip":e.tip,children:e.children})}const xT=350;function jT(){const[e,t]=w.useState(null);if(w.useEffect(()=>{let i=0,o=null;const c=()=>{window.clearTimeout(i),o=null,t(null)},d=g=>{const k=g.getAttribute("data-tip");if(!k)return;const y=g.getBoundingClientRect(),b=y.bottom+60>window.innerHeight;t({text:k,x:y.left+y.width/2,y:b?y.top-8:y.bottom+8,above:b,scout:g.hasAttribute("data-tip-scout")})},u=g=>{var b,S;const k=(S=(b=g.target)==null?void 0:b.closest)==null?void 0:S.call(b,"[data-tip], [title]");if(!k||k instanceof SVGElement&&!k.hasAttribute("data-tip"))return null;const y=k.getAttribute("title");return y&&(k.setAttribute("data-tip",y),k.removeAttribute("title")),k},f=g=>{if(g.pointerType==="touch")return;const k=u(g);k!==o&&(c(),k&&(o=k,i=window.setTimeout(()=>o===k&&d(k),g.type==="focusin"?0:xT)))},m=g=>{o&&!o.contains(g.relatedTarget)&&c()};return document.addEventListener("pointerover",f),document.addEventListener("pointerout",m),document.addEventListener("focusin",f),document.addEventListener("focusout",c),document.addEventListener("pointerdown",c),window.addEventListener("scroll",c,!0),window.addEventListener("keydown",c),()=>{c(),document.removeEventListener("pointerover",f),document.removeEventListener("pointerout",m),document.removeEventListener("focusin",f),document.removeEventListener("focusout",c),document.removeEventListener("pointerdown",c),window.removeEventListener("scroll",c,!0),window.removeEventListener("keydown",c)}},[]),!e)return null;const n=Math.min(Math.max(e.x,140),window.innerWidth-140);if(e.scout){const i=Math.min(Math.max(e.x-24,8),window.innerWidth-340);return s.jsxs("div",{className:`scout-tip ${e.above?"above":""}`,role:"tooltip",style:{left:i,top:e.y,transform:e.above?"translateY(-100%)":void 0},children:[s.jsx(Ua,{size:1,framed:!1,speaking:e.text,className:"scout-tip-face"}),s.jsx("p",{className:"scout-tip-bubble",children:e.text})]})}return s.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 Za({as:e="span",className:t}){return s.jsxs(e,{className:t?`tt-wordmark ${t}`:"tt-wordmark",role:"img","aria-label":J.name,children:[J.name.toLowerCase(),s.jsx("span",{className:"tt-wordmark-dot","aria-hidden":"true"})]})}function bT(e){return e.bare?s.jsx("div",{className:`zone-b ${e.className??""}`,children:e.children}):s.jsxs(Be,{className:`zone ${e.className??""}`,style:e.area?{gridArea:e.area}:void 0,children:[s.jsx(yt,{className:"zone-title",icon:e.icon,title:e.title,info:e.info,count:e.count,right:e.right??null}),s.jsx("div",{className:"zone-b",children:e.children})]})}function si(e){return e.children.length?s.jsxs("div",{className:`bf-list ${e.urgent?"urgent":""}`,children:[s.jsx("span",{className:"mono-label",children:e.title}),s.jsx("ul",{children:e.children})]}):null}function Zo(e){return s.jsx("li",{children:s.jsxs("button",{className:"bf-row",onClick:e.onClick,title:e.title,children:[s.jsx("span",{className:"key t-code",children:e.k}),s.jsx("span",{className:"t",children:e.text}),e.meta&&s.jsx("span",{className:"t-meta",children:e.meta})]})})}function hr(e){return s.jsxs(Qt,{tone:e.urgent?"urgent":void 0,className:`bf-tile ${e.className??""}`,children:[s.jsx("span",{className:"mono-label",children:e.label}),s.jsx("b",{children:e.value}),e.sub&&s.jsx(_,{parts:[],children:e.sub})]})}const ST=864e5;function NT(e,t){const n=new Date(e),i=n.toTimeString().slice(0,5),o=new Date(t).toDateString(),c=new Date(t-ST).toDateString();let d=` ${n.toLocaleDateString(void 0,{month:"short",day:"numeric"})}`;return n.toDateString()===o?d="":n.toDateString()===c&&(d=" yesterday"),`Since ${i}${d} · ${qt(t-e)}`}function $T(e){const{briefing:t,bp:n,onClose:i}=e;w.useEffect(()=>{const k=y=>y.key==="Escape"&&i();return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[i]);const o=t==null?void 0:t.trails.flatMap(k=>k.waiting).sort((k,y)=>k.at-y.at)[0],c=t==null?void 0:t.totals,d=((t==null?void 0:t.trails.length)??0)>1,u=n==="mobile",f=k=>{var y,b;return k.ticketId&&((b=(y=e.snaps[k.mapId])==null?void 0:y.tickets.find(S=>S.id===k.ticketId))==null?void 0:b.title)||k.text},m=k=>{var y,b;return k.ticketId&&((b=(y=e.snaps[k.mapId])==null?void 0:y.tickets.find(S=>S.id===k.ticketId))==null?void 0:b.key)||k.agent},g=k=>{const y=(N,O)=>s.jsx(Zo,{k:N.key,text:N.title,meta:O,onClick:()=>e.onTicket(k.mapId,N.id)},N.id),b=(N,O)=>s.jsx(Zo,{k:N.id,text:N.summary||N.answer,title:N.risk?`${N.question}
142
+
143
+ ${N.risk.reason}`:N.question,meta:O,onClick:()=>e.onDecision(N.id)},N.id),S=uN(k.agentDecisions).flatMap(N=>N.decisions.map(O=>b(O,N.label))),x=[s.jsx(si,{title:"Done",children:k.done.map(N=>y(N))},"done"),s.jsx(si,{title:"Ruled out",children:u?[]:k.ruledOut.map(N=>y(N))},"oos"),s.jsx(si,{title:"Blocked",children:k.blocked.map(N=>y(N.ticket,`needs ${N.on.map(O=>O.key).join(", ")}`))},"blocked")],$=[s.jsx(si,{title:"Waiting on you",urgent:!0,children:k.waiting.map(N=>s.jsx(Zo,{k:m(N),text:f(N),meta:t.now-N.at<6e4?"now":qt(t.now-N.at),title:N.text,onClick:()=>e.onAnswer(N)},N.id))},"waiting"),s.jsx(si,{title:"Agent decisions",children:u?[]:S},"agent"),s.jsx(si,{title:"Active sessions",children:u?[]:k.active.map(N=>{var D;const O=N.ticketId?(D=e.snaps[k.mapId])==null?void 0:D.tickets.find(F=>F.id===N.ticketId):void 0;return s.jsx(Zo,{k:(O==null?void 0:O.key)??N.agent,text:O?`${O.title} · ${N.stepLabel}`:N.stepLabel,meta:`${N.step}/${N.total}`,onClick:()=>e.onSession(N)},N.id)})},"active")];return s.jsxs("section",{className:"bf-trail",children:[d&&s.jsxs("div",{className:"bf-trail-h",children:[s.jsx("span",{className:"key",children:k.key})," ",k.title]}),s.jsxs("div",{className:"bf-cols",children:[s.jsx("div",{children:x}),s.jsx("div",{children:$})]})]},k.mapId)};return s.jsx("div",{className:"scrim",onClick:i,children:s.jsxs(Be,{as:"div",className:"dialog briefing",role:"dialog","aria-label":"While you were away",onClick:k=>k.stopPropagation(),children:[s.jsxs("header",{children:[s.jsx("h2",{className:"t-heading caps",children:"While you were away"}),t&&t.trails.length>0&&s.jsx(Ke,{className:"bf-since",children:NT(t.since,t.now)}),s.jsx("button",{className:"icon-btn",onClick:i,"aria-label":"Close",children:"×"})]}),s.jsxs(Qt,{className:"bf-scout",children:[s.jsx(Ua,{size:u?1.1:1.3,speaking:e.line||"Nothing new since you were last here.",caption:!1,framed:!1}),s.jsxs("div",{children:[s.jsx("span",{className:"mono-label",children:"Scout"}),s.jsx("p",{children:e.line||"Nothing new since you were last here."})]})]}),t&&c&&t.trails.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"bf-tiles",children:[s.jsx(hr,{label:"Done",value:c.done,sub:c.ruledOut?`${c.ruledOut} ruled out`:void 0}),s.jsx(hr,{label:"Blocked",value:c.blocked,sub:c.blocked?"Needs your answer":void 0}),s.jsx(hr,{label:"Waiting on you",value:c.waiting,sub:CT(c.oldestWaitMs),urgent:c.waiting>0}),s.jsx(hr,{label:"Agent decisions",value:c.agentDecisions,className:"opt"}),s.jsx(hr,{label:"Spend",value:hi(c.usage.costUsd),sub:`${Ha(c.usage.inputTokens+c.usage.outputTokens)} tokens · ${c.usage.sessions} sessions${c.active?` · ${c.active} active`:""}`})]}),s.jsx("div",{className:"bf-body",children:t.trails.map(g)})]}),s.jsxs("footer",{children:[s.jsx(R,{onClick:i,children:"Dismiss"}),o?s.jsxs(R,{variant:"urgent",onClick:()=>e.onAnswer(o),children:[s.jsx(Rr,{variant:"alert",size:13}),"Answer first decision"]}):s.jsx(R,{variant:"primary",onClick:e.onResume,children:"Resume trail"})]})]})})}function CT(e){if(e!==void 0)return e<6e4?"Just asked":`Oldest ${qt(e)}`}function TT(e){const{brief:t,bp:n}=e;return t.shown?s.jsx($T,{briefing:t.briefing,line:t.line,snaps:e.snaps,bp:n,onClose:t.dismiss,onTicket:(i,o)=>{t.dismiss(),e.openTicket(i,o)},onAnswer:i=>{t.dismiss(),e.openQuestion(i.id)},onSession:i=>{t.dismiss(),e.openChat(i.id,i.ticketId,i.mapId)},onDecision:i=>{t.dismiss(),e.openDecisions(i)},onResume:()=>{t.dismiss(),e.toMap()}}):null}function Zv(e){return s.jsx(an,{label:"Output",children:e.checks.map(t=>s.jsxs("figure",{className:"main-check-output",children:[s.jsxs("figcaption",{className:"t-meta",children:[s.jsx("span",{className:"t-code",children:t.argv.join(" ")})," · exit ",t.exitCode??"none"]}),s.jsx("pre",{className:"t-code",children:t.tail})]},t.name))})}function ew(e){const{buttons:t,menu:n}=e.actions;return!t.length&&!n.length&&!e.error?null:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"actions main-checks-bar",children:[t.map(i=>s.jsx(R,{size:"sm","data-tip":i.tip,disabled:e.busy,onClick:i.onSelect,children:i.label},i.id)),s.jsx(qv,{items:n,label:"More about checks on main"})]}),e.error&&s.jsx("p",{className:"vf-err",children:e.error})]})}const vr=(e,t="Run checks on main again")=>({id:"run",label:t,tip:"Run the approved checks on the default branch's head now",onSelect:e.run});function ET(e,t){const n=e.map(c=>({id:`drop-${c}`,label:`Drop ${c} for this trail`,tip:`Completions on this trail stop running ${c}; you can restore it`,onSelect:()=>t.choose({kind:"drop",check:c})})),i={id:"fix-main",label:"Fix main first",tip:"Implementation keeps waiting; run the checks again once main is fixed",onSelect:()=>t.choose({kind:"fix-main"})},o={id:"proceed",label:"Start anyway",tip:"Known failures: a completion that fails only in these, the same way, isn't sent back",onSelect:()=>t.choose({kind:"proceed"})};return{buttons:[i,...n.slice(0,1),o],menu:[...n.slice(1),vr(t)]}}function AT(e,t){const n=e.choices.dropped.map(o=>({id:`restore-${o.name}`,label:`Restore ${o.name} for this trail`,onSelect:()=>t.choose({kind:"restore",check:o.name})})),i=e.choices.proceed?[{id:"unmark",label:"Unmark known failures",onSelect:()=>t.choose({kind:"undo-proceed"})}]:[];return[vr(t),...n,...i]}function IT(e,t){const{state:n}=e;switch(n.kind){case"off":case"not-run":return{buttons:[],menu:[]};case"running":{const i={id:"wait",label:"Wait for them",onSelect:()=>t.choose({kind:"undo-proceed"})},o={id:"proceed",label:"Start without waiting",tip:"Agents start building now; what fails on main is a known failure",onSelect:()=>t.choose({kind:"proceed"})};return n.proceeding?{buttons:[],menu:[i]}:{buttons:[o],menu:[]}}case"passed":return{buttons:[],menu:[vr(t)]};case"unavailable":return{buttons:[vr(t,"Run again")],menu:[]};case"failed":{if(!n.fixing)return ET(n.failing,t);const i={id:"choose",label:"Choose again",onSelect:()=>t.choose({kind:"undo-fix-main"})};return{buttons:[vr(t,"Run again")],menu:[i]}}case"accepted":return{buttons:[],menu:AT(e,t)};default:return n}}const su=e=>e.join(", "),RT=e=>`${su(e)} ${e.length===1?"fails":"fail"} on main`;function MT(e,t){if(!e)return[];const n=e.finishedAt??e.startedAt;return[e.branch??"main",...e.commit?[{text:e.commit.slice(0,8),code:!0}]:[],...e.runner?[`by ${e.runner}`]:[],Je(t-n)]}function LT(e,t){switch(e.kind){case"off":return{edge:"neutral",title:"Checks on main are off",why:e.reason};case"not-run":return{edge:"neutral",title:"Checks on main run before building starts"};case"running":return{edge:"neutral",title:"Running checks on main",why:e.proceeding?"Agents start without waiting":"Implementation waits for them"};case"passed":return{edge:"neutral",title:"Checks pass on main"};case"unavailable":return{edge:"attention",title:"Checks on main couldn't run",detail:e.reason};case"failed":return{edge:e.fixing?"attention":"urgent",title:RT(e.failing),why:OT(e.fixing,t)};case"accepted":return{edge:"attention",title:PT(e.known,e.dropped)};default:return e}}function OT(e,t){return e?"Waiting for main to be fixed":t?"Implementation waits for you":void 0}function PT(e,t){return[e.length?`Known failures on main: ${su(e)}`:"",t.length?`Dropped for this trail: ${su(t)}`:""].filter(Boolean).join(" · ")}function DT(e){const t=e==null?void 0:e.checks.find(i=>!i.passed),n=t==null?void 0:t.tail.split(`
144
+ `).filter(i=>i.trim());return n==null?void 0:n.at(-1)}function tw(e,t){const n=LT(e.state,e.holds),i=n.detail??(e.state.kind==="failed"?DT(e.run):void 0);return{edge:n.edge,title:n.title,context:[...n.why?[n.why]:[],...MT(e.run,t)],...i?{detail:i}:{}}}const _T=e=>{try{return JSON.parse(e)}catch{return}};function nw(e){const t=ki();let n=!1;const i=()=>{const u=t.start();e.load().then(f=>!n&&u()&&e.show(f),()=>{var f;return!n&&u()&&((f=e.failed)==null?void 0:f.call(e))})},{changed:o,events:c={}}=e,d=[as(i),...o?[Ya(u=>o(u)&&i())]:[],...Object.entries(c).map(([u,f])=>vi(u,m=>f(_T(m))&&i()))];return i(),{reload:i,pushed:()=>t.pushed(),stop:()=>{n=!0;for(const u of d)u()}}}function Pe(e){const t=w.useRef(e);t.current=e;const n=w.useRef(),i=w.useRef(e.version),{view:o,version:c}=e;w.useEffect(()=>{const f=t.current;i.current=f.version;const m=Object.keys(f.events??{}),g=nw({load:()=>t.current.load(),show:k=>t.current.show(k),failed:()=>{var k,y;return(y=(k=t.current).failed)==null?void 0:y.call(k)},...f.changed?{changed:k=>{var y,b;return((b=(y=t.current).changed)==null?void 0:b.call(y,k))===!0}}:{},events:Object.fromEntries(m.map(k=>[k,y=>{var b,S;return((S=(b=t.current.events)==null?void 0:b[k])==null?void 0:S.call(b,y))===!0}]))});return n.current=g,()=>{g.stop(),n.current=void 0}},[o]),w.useEffect(()=>{var f;Object.is(i.current,c)||(i.current=c,(f=n.current)==null||f.reload())},[c]);const d=w.useCallback(()=>{var f;return(f=n.current)==null?void 0:f.reload()},[]),u=w.useCallback(()=>{var f;return(f=n.current)==null?void 0:f.pushed()},[]);return{reload:d,pushed:u}}async function ec(e){return e?e.ok?void 0:(await e.json().catch(()=>({}))).error??`HTTP ${e.status}`:"Could not reach the Lookout"}const sw=()=>`${re()}/main-checks`,BT=(e,t)=>fetch(`${sw()}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).catch(()=>{});function Qu(e){const[t,n]=w.useState(),[i,o]=w.useState(),[c,d]=w.useState(!1),{reload:u,pushed:f}=Pe({view:e,load:async()=>{if(!e)return;const g=await fetch(`${sw()}?mapId=${encodeURIComponent(e)}`);return g.ok?await g.json():void 0},show:n,events:{"main-checks":()=>!0}}),m=async(g,k)=>{d(!0);const y=await BT(g,k);d(!1);const b=await ec(y);if(o(b),b)return u();g==="/choose"?(f(),n(await y.json())):u()};return{view:t,error:i,busy:c,choose:g=>m("/choose",{mapId:e,choice:g}),run:()=>m("/run",{mapId:e})}}function iw(e){var d;const t=Qu(e.mapId),n=t.view;if(!n||n.state.kind==="off")return null;const i=tw(n,e.now),o=IT(n,{choose:u=>void t.choose(u),run:()=>void t.run()}),c=((d=n.run)==null?void 0:d.checks.filter(u=>!u.passed))??[];return s.jsxs(Ot,{label:"Checks on main",className:"main-checks",children:[s.jsx(fe,{edge:i.edge,title:i.title,context:s.jsx(_,{parts:i.context}),detail:i.detail,detailText:i.detail,below:s.jsx(ew,{actions:o,busy:t.busy,error:t.error})}),c.length>0&&s.jsx(Zv,{checks:c})]})}function FT(e){const t=Qu(e.mapId),n=gt(3e4),i=t.view;if(!i)return null;const o=tw(i,n),c=i.state.kind==="off";return s.jsxs("div",{className:"main-checks-setting",children:[s.jsx("span",{className:"set-field-label",children:"Checks on main"}),s.jsx("p",{className:"t-body",children:o.title}),s.jsx(_,{parts:o.context}),s.jsx("div",{className:"actions",children:s.jsx(R,{size:"sm",disabled:c||t.busy||i.state.kind==="running",onClick:()=>void t.run(),children:"Run checks on main"})}),t.error&&s.jsx("p",{className:"vf-err",children:t.error}),s.jsx("span",{className:"set-hint t-meta",children:"Before agents build, the approved checks run once on the default branch, in a worktree next to the repo. A check that already fails there is yours to decide on: fix main first, drop it for the trail, or start anyway."})]})}function zT(e,t){if(!(!e||e.state.kind==="off")){if(t)return"needs";switch(e.state.kind){case"failed":return e.state.fixing?"attention":"needs";case"unavailable":case"accepted":return"attention";case"passed":return"passed";case"running":return"running";case"not-run":return"neutral";default:return e.state}}}const wd=e=>({id:"run",label:"Run again",tip:"Run the approved checks on the default branch with every merge now",onSelect:e.run}),UT=e=>({id:"run-now",label:"Run now on main as it is",tip:"Before everything is merged: shows what fails on main today. It doesn't verify the trail",onSelect:e.run});function WT(e,t){const{state:n,run:i}=e;switch(n.kind){case"off":case"due":case"running":return{buttons:[],menu:[]};case"failed":return{buttons:[{id:"fix-ticket",label:"Add a fix ticket",tip:"A task on this trail with the failing checks and their output, for agents to pick up",onSelect:()=>i&&t.fixTicket(i.id)},wd(t)],menu:[]};case"unavailable":return{buttons:[wd(t)],menu:[]};case"passed":return{buttons:[],menu:[wd(t)]};case"waiting":return{buttons:[],menu:[UT(t)]};default:return n}}function rg(e,t,n=!1){return[...n?[]:[e.branch??"main"],...e.commit&&!n?[{text:e.commit.slice(0,7),code:!0}]:[],...e.runner?[`by ${e.runner}`]:[],Je(t-(e.finishedAt??e.startedAt))]}function HT(e,t){var n;switch(e.kind){case"off":return{edge:"neutral",title:"Checks on main together are off",detail:e.reason};case"waiting":return{edge:"neutral",title:"Checks on main run once everything is merged",detail:e.reason};case"due":case"running":return{edge:"neutral",title:"Running the checks on main with every merge"};case"passed":return{edge:"neutral",title:`Verified together on ${(t==null?void 0:t.branch)??"main"} at ${(n=t==null?void 0:t.commit)==null?void 0:n.slice(0,7)}`};case"failed":{const i=e.failing.length===1?"fails":"fail";return{edge:"urgent",title:`${e.failing.join(", ")} ${i} on main with every merge`}}case"unavailable":return{edge:"attention",title:"Checks on main together couldn't run",detail:e.reason};default:return e}}const KT=["passed","failed","running","unavailable"],GT={pass:"passed",fail:"failed",running:"running",unavailable:"couldn't run"};function VT(e,t){const n=e.run;if(!n)return[];if(KT.includes(e.state.kind))return rg(n,t,e.state.kind==="passed");const i=n.complete?"":", before everything was merged";return[`Last run ${GT[n.result]}${i}`,...rg(n,t)]}function qT(e,t){const n=HT(e.state,e.run);return{edge:n.edge,title:n.title,context:VT(e,t),...n.detail?{detail:n.detail}:{}}}const rw=()=>`${re()}/trail-checks`,QT=(e,t)=>fetch(`${rw()}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).catch(()=>{});function ow(e){const[t,n]=w.useState(),[i,o]=w.useState(),[c,d]=w.useState(!1),{reload:u}=Pe({view:e,load:async()=>{if(!e)return;const m=await fetch(`${rw()}?mapId=${encodeURIComponent(e)}`);return m.ok?await m.json():void 0},show:n,events:{"trail-checks":()=>!0}}),f=async(m,g)=>{d(!0);const k=await QT(m,g);d(!1),o(await ec(k)),u()};return{view:t,error:i,busy:c,run:()=>f("/run",{mapId:e}),fixTicket:m=>f("/fix-ticket",{mapId:e,runId:m})}}function aw(e){var f;const t=ow(e.mapId),n=t.view,i=(n==null?void 0:n.state.kind)==="failed",{onUrgent:o}=e;if(w.useEffect(()=>o==null?void 0:o(i),[o,i]),!n||n.state.kind==="off")return null;const c=qT(n,e.now),d=WT(n,{run:()=>void t.run(),fixTicket:m=>void t.fixTicket(m)}),u=n.state.kind==="running"?[]:((f=n.run)==null?void 0:f.checks.filter(m=>!m.passed))??[];return s.jsxs(Ot,{label:"Checks on main, together",className:"trail-checks",children:[s.jsx(fe,{edge:c.edge,title:c.title,context:s.jsx(_,{parts:c.context}),detail:c.detail,detailText:c.detail,below:s.jsx(ew,{actions:d,busy:t.busy,error:t.error})}),u.length>0&&s.jsx(Zv,{checks:u})]})}function YT({text:e}){return e.trim()?s.jsx(Ot,{label:"What is true when it's done",className:"bubble-destination",children:s.jsx(Vu,{markdown:!0,text:e})}):null}const JT="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.",cw=()=>{var e;return((e=pt())==null?void 0:e.highRisk)===!1};function XT(e){var t;return(t=e.options)!=null&&t.length?s.jsx("div",{className:"suggest",children:e.options.map(n=>s.jsx("button",{className:"chip",onClick:()=>e.onPick(n),children:n},n))}):null}function lw(e){const{pending:t}=e;return t!=null&&t.lookoutOnly&&cw()?s.jsx("p",{className:"vf-intro",children:JT}):s.jsxs(s.Fragment,{children:[s.jsx(XT,{options:t==null?void 0:t.suggestions,onPick:e.onSend}),s.jsx(Xa,{ref:e.inputRef,className:"comms-input",value:e.draft,onValueChange:e.onDraft,onSubmit:e.onSend,disabled:!t,placeholder:t?"Answer":""})]})}const ZT=["awaiting","blocked","trail.done","resolved"];async function Xn(e,t="GET",n){const i=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:n===void 0?void 0:JSON.stringify(n)}),o=await i.json().catch(()=>({}));if(!i.ok&&!o.status)throw new Error(o.error??`request failed (${i.status})`);return o}function e2(e){const t=`${e}/slack`;return{get:()=>Xn(t),connectStart:n=>Xn(`${t}/connect/start`,"POST",{project:n}),connectPreview:n=>Xn(`${t}/connect/preview`,"POST",{code:n}),connectFinish:n=>Xn(`${t}/connect/finish`,"POST",{code:n}),connectCancel:()=>Xn(`${t}/connect/cancel`,"POST",{}),disconnect:()=>Xn(`${t}/connect`,"DELETE"),update:n=>Xn(`${t}/settings`,"PUT",n),members:()=>Xn(`${t}/members`).then(n=>n.members)}}const En=e2(re());function t2(e){const{who:t}=e;return s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"sl-lead",children:["Connect as ",s.jsxs("b",{children:["@",t.user.name??t.user.id]})," in ",s.jsx("b",{children:t.workspace.name}),"? That Slack account becomes Scout's owner for this Teamtrail: questions and approvals reach it."]}),s.jsxs("div",{className:"c-actions",children:[s.jsx(R,{size:"sm",variant:"primary",onClick:e.onConnect,children:"Connect"}),s.jsx(R,{size:"sm",variant:"ghost",onClick:e.onCancel,children:"Cancel"})]})]})}const n2=e=>new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});function s2({problem:e}){const t=e.failures===1?"A message was":`${e.failures} messages were`;return s.jsxs("div",{className:"test-line warn",title:e.code,children:[t," not delivered (last ",n2(e.at),"). ",e.message]})}function iu(e){const[t,n]=w.useState(!1),i=()=>{n(!0),En.connectStart(Ar()).then(o=>location.assign(o.url),o=>{n(!1),e.onError(o.message)})};return s.jsx(R,{size:"sm",variant:"primary",disabled:t,onClick:i,children:e.again?"Add Scout to Slack again":"Add Scout to Slack"})}function i2(e){return s.jsxs("div",{className:"test-line mentions-hint",children:[s.jsx("span",{children:"Reconnect to allow @Scout mentions: Slack needs one more permission for them."}),s.jsx(iu,{again:!0,onError:e.onError})]})}function r2({s:e,connecting:t}){return t?s.jsx("p",{className:"sl-lead",children:"Connecting Scout…"}):s.jsxs(s.Fragment,{children:[s.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&&s.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 o2(e){return s.jsx("a",{className:["btn",e.primary&&"primary",e.small&&"sm"].filter(Boolean).join(" "),href:At(e.href,["slack:"]),target:"_blank",rel:"noreferrer",onClick:e.onClick,children:e.children})}function og({onRemoved:e}){const[t,n]=w.useState(!1);if(!t)return s.jsx(R,{size:"sm",variant:"ghost",onClick:()=>n(!0),children:"Disconnect"});const i=()=>void En.disconnect().then(o=>{n(!1),e(o)},()=>{});return s.jsxs(s.Fragment,{children:[s.jsx(R,{size:"sm",variant:"danger",onClick:i,children:"Disconnect and forget Slack settings"}),s.jsx(R,{size:"sm",variant:"ghost",onClick:()=>n(!1),children:"Keep"})]})}function a2(e){const{s:t}=e,n=t.state==="auth-error"||t.state==="other-service";return t.connected?s.jsxs("div",{className:"c-actions",children:[n?s.jsx(iu,{again:!0,onError:e.onError}):s.jsx(R,{size:"sm",on:t.enabled,onClick:e.onToggle,children:t.enabled?"Turn off":"Turn on"}),t.links.homeWeb&&s.jsx(o2,{small:!0,href:t.links.homeWeb,children:"Open Scout in Slack"}),s.jsx(og,{onRemoved:e.onChanged})]}):s.jsxs("div",{className:"c-actions",children:[!e.busy&&s.jsx(iu,{again:t.legacy,onError:e.onError}),t.legacy&&s.jsx(og,{onRemoved:e.onChanged})]})}const c2={awaiting:"Awaiting you",blocked:"Blocked","trail.done":"Trail done",resolved:"Resolved"};function l2({s:e}){const[t,n]=d2(e);return s.jsxs("div",{className:`sync-line ${t}`,title:e.error,children:[s.jsx("span",{className:"dot"}),s.jsx("span",{children:n})]})}function d2(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 ${J.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 u2(e){const{s:t,back:n}=e,i=!!n.confirm&&!t.connected;return s.jsxs(Qt,{className:f2(t),children:[s.jsxs("div",{className:"card-row",children:[s.jsx("b",{className:"choice-title t-row-title",children:"Scout in Slack"}),t.connected&&s.jsx(xi,{className:t.enabled?"on":"",children:t.enabled?"On":"Off"})]}),t.connected&&s.jsx("div",{className:"c-loc",children:h2(t)}),t.connected&&s.jsx(l2,{s:t}),t.connected&&s.jsx("div",{className:"t-meta",children:"Scout answers in Slack only while this Teamtrail is running."}),t.delivery&&s.jsx(s2,{problem:t.delivery}),t.connected&&t.mentions===!1&&!i&&s.jsx(i2,{onError:e.onError}),!t.connected&&!i&&s.jsx(r2,{s:t,connecting:n.busy}),i&&s.jsx(t2,{who:n.confirm,onConnect:n.connect,onCancel:n.cancel}),e.error&&s.jsxs("div",{className:"test-line alert",children:["✕ ",e.error]}),!i&&s.jsx(a2,{s:t,busy:n.busy,onError:e.onError,onChanged:e.onChanged,onToggle:e.onToggle})]})}function h2(e){var n,i,o;const t=(i=(n=e.workspace)==null?void 0:n.url)==null?void 0:i.replace(/^https?:\/\/|\/$/g,"");return[(o=e.workspace)==null?void 0:o.name,t].filter(Boolean).join(" · ")}function f2(e){const t=e.connected&&e.enabled?"active":"",n=e.connected?"":"open";return`connector ${t} ${n}`}function m2(e){const[t,n]=w.useState(e.value==="dm"?"":e.value),i=/^[CG][A-Z0-9]{6,}$/.test(t.trim());return s.jsxs("form",{className:"sl-field",onSubmit:o=>{o.preventDefault(),i&&e.onSave(t.trim())},children:[s.jsx("input",{value:t,spellCheck:!1,placeholder:"Channel ID, e.g. C0123ABCD","aria-label":"Channel ID",onChange:o=>n(o.target.value)}),s.jsx(R,{type:"submit",disabled:!i||t.trim()===e.value,children:"Save"})]})}function p2(e){const[t,n]=w.useState(),[i,o]=w.useState();w.useEffect(()=>{En.members().then(n,u=>o(u.message))},[]);const c=new Set(e.owners.map(u=>u.id)),d=new Set(e.value.map(u=>u.id));return i?s.jsxs("div",{className:"test-line alert",children:["✕ ",i]}):t?s.jsx("div",{className:"choice-row compact sl-members",children:t.map(u=>s.jsx(at,{on:c.has(u.id)||d.has(u.id),disabled:c.has(u.id),title:`@${u.name??u.id}`,sub:c.has(u.id)?"Owner":void 0,onClick:()=>e.onChange(d.has(u.id)?e.value.filter(f=>f.id!==u.id):[...e.value,u])},u.id))}):s.jsx("span",{className:"t-meta",children:"Loading members…"})}function g2(e){const{s:t,patch:n}=e,[i,o]=w.useState(!1),c=new Set(t.notify.events),d=i||t.notify.target!=="dm",u=t.owners[0],f=m=>{const g=c.has(m)?t.notify.events.filter(k=>k!==m):[...t.notify.events,m];n({notify:{events:g}})};return s.jsxs("div",{className:"sl-groups",children:[s.jsxs("div",{className:"sl-group",children:[s.jsx(Ke,{variant:"plain",size:"sm",children:"Owner"}),s.jsxs("div",{className:"sl-owner",children:[s.jsxs("b",{children:["@",(u==null?void 0:u.name)??(u==null?void 0:u.id)]}),s.jsx("span",{className:"t-meta",children:"Added Scout from this machine"})]})]}),s.jsxs("div",{className:"sl-group",children:[s.jsx(Ke,{variant:"plain",size:"sm",children:"Allowed users"}),s.jsx(p2,{value:t.allow,owners:t.owners,onChange:m=>n({allow:m})},t.state)]}),s.jsxs("div",{className:"sl-group",children:[s.jsx(Ke,{variant:"plain",size:"sm",children:"Notify"}),s.jsxs("div",{className:"choice-row compact",children:[s.jsx(at,{on:!d,title:"DM to owner",onClick:()=>{o(!1),n({notify:{target:"dm",detail:"full"}})}}),s.jsx(at,{on:d,title:"Channel",sub:t.notify.target!=="dm"?t.notify.target:void 0,onClick:()=>o(!0)})]}),d&&s.jsxs(s.Fragment,{children:[s.jsx(mt,{label:"Channel ID (invite @Scout there first)",children:s.jsx(m2,{value:t.notify.target,onSave:m=>n({notify:{target:m}})})}),s.jsxs("div",{className:"choice-row compact",children:[s.jsx(at,{on:t.notify.detail==="full",title:"Full questions",onClick:()=>n({notify:{detail:"full"}})}),s.jsx(at,{on:t.notify.detail==="titles-only",title:"Titles only",onClick:()=>n({notify:{detail:"titles-only"}})})]})]}),s.jsx("div",{className:"choice-row compact",children:ZT.map(m=>s.jsx(at,{on:c.has(m),title:c2[m],onClick:()=>f(m)},m))})]}),s.jsx(nu,{className:"dim",parts:[`${t.command} decide`,`${t.command} status`,`${t.command} inbox`,"Save as decision on any message"]})]})}function k2(){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 yd={code:k2()};function v2(e){const[t,n]=w.useState(),[i,o]=w.useState(),[c,d]=w.useState(),[u,f]=w.useState(!!yd.code),m=k=>d(k.message);w.useEffect(()=>{const k=yd.code;k&&(yd.code=void 0,n(k),En.connectPreview(k).then(o,m).finally(()=>f(!1)))},[]);const g=k=>{f(!0),o(void 0),k.then(e,m).finally(()=>f(!1))};return{busy:u,error:c,confirm:i,connect:()=>t&&g(En.connectFinish(t)),cancel:()=>g(En.connectCancel())}}function Yu(e=0){const[t,n]=w.useState(),i=w.useCallback(()=>En.get().then(n,()=>n(null)),[]);return w.useEffect(()=>{if(i(),!e)return;const o=setInterval(()=>void i(),e);return()=>clearInterval(o)},[i,e]),[t,n]}function w2(e){const[t,n]=Yu(3e3),i=v2(n),[o,c]=w.useState(),d=w.useRef(null);if(w.useEffect(()=>{var f;e.focus&&t&&((f=d.current)==null||f.scrollIntoView({block:"start"}))},[e.focus,!!t]),!t)return null;const u=f=>En.update(f).then(n,()=>{});return s.jsxs("div",{ref:d,className:"slack-settings",children:[s.jsx(u2,{s:t,back:i,error:o??i.error,onError:c,onToggle:()=>void u({enabled:!t.enabled}),onChanged:f=>{c(void 0),n(f)}}),t.connected&&s.jsx(g2,{s:t,patch:f=>void u(f)})]})}function y2(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 ag;function x2(){return ag??(ag=En.get().then(e=>({owners:e.owners??[],allow:e.allow??[]}),()=>{})),ag}function Lr(){const[e,t]=w.useState();return w.useEffect(()=>{let n=!0;return x2().then(i=>n&&t(i)),()=>{n=!1}},[]),e}function j2(e){const{m:t}=e,n=Lr(),i=t.from==="human"?"human":"agent";return s.jsxs("div",{className:`msg from-${t.from} voice-${i}`,children:[s.jsx(_,{parts:[mi(t.author,n),Eb(t),Wa(t.at)]}),s.jsx("div",{className:"msg-text",children:t.text}),e.stillOpen&&s.jsx("button",{className:"answer-this t-meta",onClick:e.onAnswerThis,children:"Answer this"})]})}function b2(e){const{ticket:t}=e;return s.jsxs("div",{className:"comms-ticket",children:[s.jsxs("div",{className:"t-title",title:t&&`${t.key} ${t.title}`,children:[s.jsx("span",{className:"key",children:t==null?void 0:t.key})," ",t==null?void 0:t.title]}),s.jsx(_,{parts:[e.trail,e.agent]})]})}function S2({id:e,text:t}){const[n,i]=w.useState(),o=n!==e;return s.jsx(Ua,{size:.6,framed:!1,state:o?"speaking":"alert",speaking:o?t.slice(0,60):void 0,onSpeakEnd:()=>i(e),className:"q-avatar"})}function N2(e){const{q:t}=e;return s.jsxs("div",{className:"msg open-q",children:[s.jsx(_,{parts:[t.agent,Wa(t.at)]}),s.jsx(S2,{id:e.chatId??t.id,text:t.text}),s.jsx("div",{className:"msg-text",children:t.text}),t.stakes&&s.jsx(_,{parts:[{text:t.stakes,strong:!0}]}),t.precedent&&s.jsx(_,{className:"open-q-precedent",parts:[t.precedent]})]})}function $2(e){const{activity:t,sessionId:n}=e,[i,o]=w.useState(""),[c,d]=w.useState(),u=w.useRef(null),f=w.useRef(null),m=t.sessions.find(D=>D.id===n),g=t.chats.filter(D=>D.sessionId===n),k=CC(t.pending,n,c??e.questionId),y=new Set(t.pending.filter(D=>D.sessionId===n).map(D=>D.id)),b=g.find(D=>!!k&&D.questionId===k.id),S=g.filter(D=>D!==b),x=m?e.snaps[m.mapId]:void 0,$=m!=null&&m.ticketId?x==null?void 0:x.tickets.find(D=>D.id===m.ticketId):void 0;w.useEffect(()=>{const D=u.current;D==null||D.scrollTo({top:D.scrollHeight,behavior:"smooth"})},[S.length,k==null?void 0:k.id]),w.useEffect(()=>{var D;k&&!e.onBack&&((D=f.current)==null||D.focus({preventScroll:!0}))},[k==null?void 0:k.id,e.onBack]);const N=D=>{!k||!D.trim()||(e.onAnswer(k.id,D.trim()),o(""))},O=C2(m,!!k);return s.jsxs("div",{className:`comms ${k?"asking":""}`,children:[s.jsx(yt,{title:"HITL line",right:m?s.jsx("span",{className:`status ${k?"urgent":""}`,children:O}):void 0,children:e.onBack&&s.jsx("button",{className:"back",onClick:e.onBack,"aria-label":"Back to inbox",children:"‹ Inbox"})}),m?s.jsxs(s.Fragment,{children:[s.jsx(b2,{ticket:$,trail:x==null?void 0:x.map.title,agent:m.agent}),s.jsx("div",{className:"comms-log",ref:u,children:S.map(D=>s.jsx(j2,{m:D,stillOpen:!!D.questionId&&y.has(D.questionId),onAnswerThis:()=>d(D.questionId)},D.id))}),k&&s.jsx(N2,{q:k,chatId:b==null?void 0:b.id}),s.jsx(lw,{pending:k,draft:i,onDraft:o,onSend:N,inputRef:f})]}):s.jsx(Te,{children:"No conversation"})]})}function C2(e,t){return e?t?"Your answer is needed":gn(e)?`${e.agent} is working…`:e.status==="done"?"Resolved · ticket closed":"Session ended":""}async function T2(e){const[t,n]=e.ref.split("+"),i=await fetch(`${re()}/workspaces/integration`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e.mapId,a:t,b:n})});return i.ok?void 0:(await i.json().catch(()=>({}))).error??`Adding failed (${i.status})`}function E2({item:e}){const[t,n]=w.useState(!1),[i,o]=w.useState(),c=()=>{n(!0),o(void 0),T2(e).then(o,d=>o(d.message)).finally(()=>n(!1))};return s.jsxs("div",{className:"att-action",children:[s.jsx(R,{size:"sm",className:"integration-add",disabled:t,onClick:c,children:t?"Adding…":"Add integration ticket"}),i&&s.jsx("span",{className:"vf-err",children:i})]})}async function A2(e,t){const n=e.ref.slice(0,e.ref.lastIndexOf(":")),i=await fetch(`${re()}/trackers/settings/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e.mapId,issueId:n,choice:t})});return i.ok?void 0:(await i.json().catch(()=>({}))).error??`Saving failed (${i.status})`}function I2({item:e}){const[t,n]=w.useState(!1),[i,o]=w.useState(),c=d=>{n(!0),o(void 0),A2(e,d).then(o,u=>o(u.message)).finally(()=>n(!1))};return s.jsxs("div",{className:"att-action",children:[s.jsx(R,{size:"sm",disabled:t,onClick:()=>c("stricter"),children:"Keep stricter"}),s.jsx(R,{size:"sm",disabled:t,onClick:()=>c("as-is"),children:"Accept as is"}),i&&s.jsx("span",{className:"vf-err",children:i})]})}function dw({item:e}){return e.kind==="integration"?s.jsx(E2,{item:e}):e.kind==="tracker-settings"&&e.ref.includes(":")?s.jsx(I2,{item:e}):null}const R2=/(\S*\/\S*|#\d+)/g;function M2({reasons:e}){return e.length?s.jsx("span",{className:"reason-line",children:e.map((t,n)=>s.jsxs("span",{children:[n>0&&s.jsx("span",{className:"sep",children:" · "}),t.split(R2).map((i,o)=>o%2===1?s.jsx("span",{className:"t-code",children:i},o):i)]},t))}):null}const Ju={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","main-checks":"Main","trail-checks":"Together",merge:"Merge",escape:"Came back"},L2={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","main-checks":"checks failing on main","trail-checks":"trails failing on main together",merge:"pull requests ready to merge",escape:"verified work that came back"},O2=[{minutes:30,label:"30 min"},{minutes:120,label:"2 hours"},{minutes:1440,label:"Tomorrow"}],P2=["blocked","flag","stalled","policy","reroute","overlap","integration","model"];function Or(e,t){return t||e.urgency==="blocking"?"urgent":P2.includes(e.kind)?"attention":"neutral"}const D2=[/^marked blocking$/,/^fyi\b/,/^soon\b/,/^waiting \d/,/^answer together/,/questions from /];function Xu(e){return e.reasons.filter(t=>!D2.some(n=>n.test(t)))}function uw(e){const{item:t,snap:n}=e,i=n==null?void 0:n.tickets.find(u=>u.id===t.ticketId),o=t.kind==="question"&&t.agent?`${t.agent} asks`:Ju[t.kind],c=[];t.urgency==="blocking"&&c.push({text:"Blocking",urgent:!0,className:"urgency-tag"}),c.push({text:o,strong:!0});const d=i&&_2(t.title,i);return d&&c.push(d),e.otherTrail&&c.push((n==null?void 0:n.map.title)??t.mapId),c}function _2(e,t){if(!e.includes(t.key))return e.includes(t.title)?{text:t.key,code:!0}:`${t.key} ${t.title}`}function B2(e){const[t,n]=w.useState(!1),i=o=>{n(!1),o()};return s.jsxs("span",{className:"snooze",children:[s.jsx("button",{type:"button",className:"snooze-btn","aria-expanded":t,"aria-label":`Later: ${e.title}`,onClick:()=>n(!t),children:"Later"}),t&&s.jsxs("span",{className:"snooze-menu",role:"menu",children:[O2.map(o=>s.jsx("button",{type:"button",role:"menuitem",onClick:()=>i(()=>e.onSnooze(o.minutes)),children:o.label},o.minutes)),e.canDismiss&&s.jsx("button",{type:"button",role:"menuitem",onClick:()=>i(e.onDismiss),children:"Set aside"})]})]})}const F2=15e3;function z2(e){const{item:t}=e,n=t.title.split(`
145
+ `)[0],i=Xu(t),o=e.now-t.since<F2;return s.jsx(fe,{as:"li",className:`att-item k-${t.kind} u-${t.urgency} ${e.selected?"sel":""} ${o?"incoming":""}`,edge:Or(t,e.interrupting),selected:e.selected,title:n,titleText:t.title,context:s.jsx(_,{parts:uw({item:t,snap:e.snap,otherTrail:e.otherTrail})}),detail:i.length>0&&s.jsx(M2,{reasons:i}),detailText:i.join(`
146
+ `),trailing:Je(e.now-t.since),onOpen:e.onOpen,actions:s.jsx(B2,{title:t.title,canDismiss:mN(t),onSnooze:e.onSnooze,onDismiss:e.onDismiss}),below:s.jsx(dw,{item:t})})}function U2(e){const t=[];for(const n of e){const i=t.at(-1);(i==null?void 0:i.key)===n.batchKey?i.items.push(n):t.push({key:n.batchKey,kind:n.kind,mapId:n.mapId,items:[n]})}return t}const W2={question:"inbox-list",approval:"inbox-list approvals"};function H2(e){const{batch:t}=e,n=t.items.length>1,i=t.kind==="question"?"answer together":"review together",o=[`${t.items.length} ${L2[t.kind]}`,e.trail,i].filter(Boolean);return s.jsxs("div",{className:`att-batch ${n?"many":""}`,children:[n&&s.jsx("span",{className:"batch-head t-label",children:o.join(" · ")}),s.jsx("ul",{className:`att-list ${W2[t.kind]??""}`,children:e.children})]})}function xd(e,t){e.ticketId?t.openTicket(e.mapId,e.ticketId):t.selectTrail(e.mapId)}const K2=new Set(["approval","blocked","policy","precedent","flag","stalled","hitl-ready","overlap","integration","model","tracker-settings"]);function Zu(e,t){if(K2.has(e.kind))return xd(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();case"main-checks":return t.openMainChecks(e.mapId);case"trail-checks":return t.openTrailChecks(e.mapId);case"escape":return e.rule?t.openRule(e.rule):xd(e,t);default:return xd(e,t)}}function hw(e){const t=gt(1e3),{view:n}=e;if(!n.items.length)return s.jsx(An,{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 i=Object.keys(e.snaps).length>1,o=u=>i&&u!==e.currentMapId,c=new Set(n.interrupting),d=u=>{var f;return(f=e.pending.find(m=>m.id===u))==null?void 0:f.sessionId};return s.jsx("div",{className:"attention-queue",children:U2(n.items).map(u=>{var f;return s.jsx(H2,{batch:u,trail:o(u.mapId)?(f=e.snaps[u.mapId])==null?void 0:f.map.title:void 0,children:u.items.map(m=>s.jsx(z2,{item:m,snap:e.snaps[m.mapId],otherTrail:o(m.mapId)&&u.items.length<2,selected:m.kind==="question"&&d(m.ref)===e.selected,interrupting:c.has(m.id),now:t,onOpen:()=>Zu(m,e.handlers),onSnooze:g=>e.onSnooze(m.id,g),onDismiss:()=>e.onDismiss(m.id)},m.id))},u.key)})})}const G2={passed:"checks passed",failing:"checks failing",pending:"checks pending",unknown:"checks unknown",none:"no checks"};function V2({mapId:e,ticketId:t}){const n=ss.ticket(Mr(),e,t);if(!n)return null;const i=n.pr;return s.jsx("div",{className:"pr-flags",children:s.jsxs("span",{className:`pr-chip pr-${(i==null?void 0:i.state)??"unread"}`,title:i?`${i.title}
147
+ ${i.headRef}`:void 0,children:[i?s.jsxs("a",{href:At(i.url),target:"_blank",rel:"noreferrer noopener",children:["PR #",i.number," · ",i.state,i.draft?" · draft":""]}):`PR #${n.link.number}`,s.jsx("span",{className:`ci ci-${n.checksSummary}`,children:G2[n.checksSummary]}),s.jsx("span",{className:"when",children:q2(n)})]})})}function q2(e){return e.error?"sync failed":e.syncedAt?Iv(e.syncedAt):"not synced yet"}const Q2={ok:"ok",failed:"error",stale:"syncing",unknown:"idle",off:"idle"};function Y2({now:e}){const t=Mr();if(!t.reached)return null;const n=iS(t.live?t.status:null,e);return n.tone!=="failed"&&n.tone!=="stale"?null:s.jsxs("span",{className:`tracker-chip pr-sync tone-${n.tone}`,title:n.title,children:[s.jsx(Ke,{size:"sm",children:"CI"}),s.jsx(Rr,{variant:"status",state:Q2[n.tone],size:13,className:"sync-glyph"}),s.jsx("span",{className:"tl",children:n.label})]})}function tc(e){const t=e.role??"menu",[n,i]=w.useState(!1),o=w.useRef(null);return w.useEffect(()=>{if(!n)return;const c=d=>{var f;(d instanceof KeyboardEvent?d.key==="Escape":!((f=o.current)!=null&&f.contains(d.target)))&&i(!1)};return window.addEventListener("mousedown",c),window.addEventListener("keydown",c),()=>{window.removeEventListener("mousedown",c),window.removeEventListener("keydown",c)}},[n]),s.jsxs("div",{className:ue("header-menu",e.className),ref:o,children:[s.jsxs(R,{variant:"ghost","aria-haspopup":t,"aria-label":e.ariaLabel,"aria-expanded":n,on:n,"data-tip":n?void 0:e.tip,onClick:()=>i(!n),children:[e.label," ",e.badge," ",s.jsx("span",{className:"caret",children:"▾"})]}),n&&s.jsx("div",{className:"header-menu-list",role:t,children:e.children(()=>i(!1))})]})}function J2(){const e=pt();if(!e)return null;const t=(n,i)=>{i(),location.assign(n)};return s.jsx(tc,{label:e.name,tip:"Your account on the server this Lookout runs on",children:n=>s.jsxs(s.Fragment,{children:[e.home&&s.jsxs("button",{role:"menuitem",className:"header-menu-item",onClick:()=>t(e.home.href,n),children:["← ",e.home.label]}),e.pages.map(i=>s.jsx("button",{role:"menuitem",className:"header-menu-item",onClick:()=>t(i.href,n),children:i.label},i.href)),e.signOut&&s.jsx("button",{role:"menuitem",className:"header-menu-item",onClick:()=>t(e.signOut,n),children:"Sign out"})]})})}const X2={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 Z2(e){const t=e.briefingStatus==="new";return s.jsx(tc,{label:"Records",badge:s.jsxs(s.Fragment,{children:[e.knowledge>0&&s.jsx("span",{className:"n hot",children:e.knowledge}),t&&s.jsx("span",{className:"new-dot","aria-label":"new trip report"})]}),children:n=>s.jsxs(s.Fragment,{children:[s.jsxs("button",{role:"menuitem",className:"header-menu-item",disabled:e.briefingStatus==="none"&&!e.briefingOpen,title:X2[e.briefingStatus],onClick:()=>{n(),e.onBriefing()},children:[s.jsx("span",{children:"Trip report"}),t&&s.jsx("span",{className:"new-dot","aria-label":"new"})]}),s.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:[s.jsx("span",{children:"Field guide"}),e.knowledge>0&&s.jsx("span",{className:"n hot",children:e.knowledge})]}),s.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:s.jsx("span",{children:"Trail stats"})})]})})}const Gt=()=>{var e;return(e=pt())==null?void 0:e.agents},fw=()=>{const e=Gt();e&&location.assign(e.href)},mw=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.model=="string"&&t.model.trim()?{model:t.model.trim().slice(0,80)}:{},...typeof t.note=="string"?{note:t.note.slice(0,200)}:{}}},nc=()=>{var e;return(e=pt())==null?void 0:e.trailAgents};async function eE(e){const t=nc();if(!t)return;const n=await fetch(`${t}?trail=${encodeURIComponent(e)}`).catch(()=>{});return n!=null&&n.ok?mw(await n.json().catch(()=>{})):void 0}const ru="teamtrail:trail-agents";async function tE(e,t){const n=nc();if(!n)return{error:"This Lookout doesn't run agents."};const i=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({trail:e,...t})}).catch(()=>{}),o=await(i==null?void 0:i.json().catch(()=>{})),c=i!=null&&i.ok?mw(o):void 0;return c&&window.dispatchEvent(new Event(ru)),c??{error:typeof(o==null?void 0:o.error)=="string"?o.error.slice(0,200):"The server didn't answer."}}function sc({command:e,label:t="Copy"}){const[n,i]=w.useState(!1);return s.jsxs("span",{className:"agent-cmd",children:[s.jsx("code",{children:e}),s.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(()=>{i(!0),setTimeout(()=>i(!1),1500)}),children:n?"Copied":t})]})}const ea=[{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"}],nE=9e3;function sE(){const[e,t]=w.useState(0),[n,i]=w.useState(!1);w.useEffect(()=>{if(n)return;const c=setInterval(()=>t(d=>(d+1)%ea.length),nE);return()=>clearInterval(c)},[n]);const o=ea[e];return s.jsxs("div",{className:"command-bar real",children:[s.jsx(Xv,{name:"map"}),s.jsx(Ke,{as:"h2",className:"zone-title-label",children:"Trail map"}),s.jsx(wi,{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."}),s.jsxs("div",{className:"hint",onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),onFocus:()=>i(!0),onBlur:()=>i(!1),children:[s.jsx("span",{className:"dim",children:o.text}),o.command&&s.jsx(sc,{command:o.command})]},e),s.jsxs("button",{type:"button",className:"link hint-next","data-tip":"Next hint","aria-label":"Next hint",onClick:()=>t(c=>(c+1)%ea.length),children:[e+1,"/",ea.length," ›"]})]})}function iE(e){const t=[{v:"plan+execute",title:"Plan + execute"},{v:"plan-only",title:"Plan only"}];return s.jsx("div",{className:"choice-row",children:t.map(n=>s.jsx(at,{on:e.value===n.v,title:n.title,onClick:()=>e.onChange(n.v)},n.v))})}const rE=/^(?:[-*+]|\d{1,3}[.)])\s+(?:\[[ xX]\]\s+)?/,pw=e=>e.split(/\r\n|\r|\n/).map(t=>t.trim().replace(rE,"").trim()).filter(Boolean);function oE({lines:e}){return s.jsx("ol",{className:"doc-assumption-list",children:e.map((t,n)=>s.jsxs("li",{children:[s.jsxs("span",{className:"t-code",children:["S-",n+1]})," ",s.jsx(ba,{text:t})]},n))})}const aE=".md,.markdown,.txt,text/markdown,text/plain",cE=/\.(md|markdown|txt)$/i,cg=e=>e.toLocaleString("en-US");async function lE(e,t){if(!cE.test(e.name))return{kind:"refused",reason:`${e.name} isn't a markdown or text file: use a .md, .markdown or .txt file.`};if(e.size>t*4)return{kind:"refused",reason:lg(e.name,t)};const n=(await e.text()).replace(/^\uFEFF/,"");return n.includes("\0")?{kind:"refused",reason:`${e.name} isn't text.`}:n.length>t?{kind:"refused",reason:lg(e.name,t,n.length)}:{kind:"text",name:e.name,text:n}}function lg(e,t,n){const i=n===void 0?"":` (${cg(n)} characters)`;return`${e} is too long${i}: this field takes at most ${cg(t)} characters.`}function dE({text:e,preview:t}){return e.trim()?s.jsx("div",{className:"doc-preview",children:t??s.jsx(Sa,{text:e})}):s.jsx("p",{className:"doc-preview t-meta",children:"Nothing to preview yet."})}const ta=e=>e.toLocaleString("en-US");function uE({length:e,max:t,label:n}){return e>t?s.jsxs("p",{className:"vf-err",role:"alert",children:[n,": ",ta(e)," characters, at most ",ta(t),". Shorten it to create the trail."]}):e<t*.8?null:s.jsxs("p",{className:"t-meta doc-count",children:[ta(e)," of ",ta(t)," characters"]})}function hE(e){return s.jsxs("div",{className:"doc-load-prompt",role:"group","aria-label":`Load ${e.file.name}`,children:[s.jsxs("span",{className:"t-meta",children:[e.field," already has text. Replace it with ",s.jsx("b",{className:"t-code",children:e.file.name}),", or add the file after it?"]}),s.jsxs("span",{className:"doc-load-actions",children:[s.jsx(R,{size:"sm",onClick:e.onReplace,children:"Replace"}),s.jsx(R,{size:"sm",onClick:e.onAppend,children:"Append"}),s.jsx(R,{size:"sm",variant:"ghost",onClick:e.onCancel,children:"Cancel"})]})]})}function fE(e,t,n){w.useLayoutEffect(()=>{const i=e.current;!i||!n||(i.style.height="auto",i.style.height=`${i.scrollHeight+2}px`)},[e,t,n])}const dg=e=>e.toLocaleString("en-US");function mE(e){const[t,n]=w.useState(),[i,o]=w.useState();return{load:async f=>{if(!f)return;o(void 0);const m=await lE(f,e.max);if(m.kind==="refused")return o(m.reason);if(e.value.trim())return n({name:m.name,text:m.text});e.onChange(m.text)},pending:t,replace:()=>{t&&e.onChange(t.text),n(void 0)},append:()=>{if(!t)return;const f=`${e.value.trimEnd()}
148
+
149
+ ${t.text}`;if(n(void 0),f.length>e.max)return o(`${e.label} with ${t.name} would be ${dg(f.length)} characters, at most ${dg(e.max)}.`);e.onChange(f)},cancel:()=>n(void 0),message:i}}const pE=[{id:"write",label:"Write"},{id:"preview",label:"Preview"}];function ou(e){const t=w.useId(),[n,i]=w.useState("write"),[o,c]=w.useState(!1),d=w.useRef(null),u=w.useRef(null),f=mE({value:e.value,onChange:e.onChange,max:e.max,label:e.label});fE(d,e.value,n==="write");const m=!e.noFile;return s.jsxs("div",{className:ue("doc-field",o&&"dropping",e.className),onDragOver:g=>{!m||!g.dataTransfer.types.includes("Files")||(g.preventDefault(),c(!0))},onDragLeave:()=>c(!1),onDrop:g=>{m&&(g.preventDefault(),c(!1),i("write"),f.load(g.dataTransfer.files[0]))},children:[s.jsxs("div",{className:"doc-field-head",children:[s.jsx("label",{className:"new-trail-label",htmlFor:t,children:e.label}),s.jsxs("span",{className:"doc-field-tools",children:[m&&s.jsx(R,{size:"sm",variant:"ghost",onClick:()=>{var g;return(g=u.current)==null?void 0:g.click()},children:"Load from file"}),s.jsx(wT,{className:"doc-tabs",value:n,onChange:i,items:pE})]})]}),e.hint&&s.jsx("p",{className:"t-meta doc-field-hint",children:e.hint}),m&&s.jsx("input",{ref:u,type:"file",hidden:!0,accept:aE,"aria-label":`Load ${e.label} from a file`,onChange:g=>{var k;f.load((k=g.target.files)==null?void 0:k[0]),g.target.value=""}}),n==="write"?s.jsx("textarea",{id:t,ref:d,rows:4,value:e.value,placeholder:e.placeholder,onChange:g=>e.onChange(g.target.value)}):s.jsx(dE,{text:e.value,preview:e.preview}),f.pending&&s.jsx(hE,{file:f.pending,field:e.label,onReplace:f.replace,onAppend:f.append,onCancel:f.cancel}),f.message&&s.jsx("p",{className:"vf-err",role:"alert",children:f.message}),s.jsx(uE,{length:e.value.trim().length,max:e.max,label:e.label}),e.footer]})}const gE=12;function kE({value:e,onChange:t}){const n=pw(e),i=Nu({assumptions:n}),o=ma;return s.jsx(ou,{className:"doc-assumptions",label:"Assumptions",hint:"Optional. One per line: each line is one assumption the plan relies on.",value:e,onChange:t,max:o.assumptions*o.assumption,placeholder:`The v2 API supports batch writes
150
+ Users stay on one device per session`,preview:s.jsx(oE,{lines:n}),noFile:!0,footer:s.jsxs(s.Fragment,{children:[n.length>0&&s.jsxs("p",{className:"t-meta doc-count","data-testid":"assumption-count",children:[n.length===1?"1 assumption":`${n.length} assumptions`," will be created",n.length>gE&&!i?". That's a lot: if this is a document, put it in Notes.":"."]}),i&&s.jsx("p",{className:"vf-err",role:"alert",children:i})]})})}function gw(e){return e.running?e.model?`Agents · ${e.running} working · ${e.model}`:`Agents · ${e.running} working`:e.note?`Agents · ${e.note}`:"Agents · starting soon"}function kw({agents:e,onStarted:t}){const{state:n,busy:i,error:o,repo:c}=e;if(!n||!n.canRun)return null;const d=()=>void e.act(!0).then(f=>f&&(t==null?void 0:t())),u=Gt();return n.on?s.jsxs("span",{className:"start-trail",children:[s.jsx("span",{className:"start-trail-status",children:gw(n)}),s.jsx(R,{size:"sm",variant:"ghost",disabled:i,onClick:()=>void e.act(!1),children:"Pause"}),u&&s.jsx("a",{className:"t-meta",href:`${u.href}#trail-${encodeURIComponent(e.mapId)}`,children:"Runs"}),o&&s.jsx("span",{className:"vf-err",children:o})]}):s.jsxs("span",{className:"start-trail",children:[n.repos.length>1&&s.jsxs("select",{"aria-label":"Repository",value:c??"",onChange:f=>e.setRepo(f.target.value||void 0),children:[s.jsx("option",{value:"",children:"Repository…"}),n.repos.map(f=>s.jsx("option",{value:f,children:f},f))]}),s.jsx(R,{variant:"primary",disabled:i||n.repos.length>1&&!c,onClick:d,children:"Start the trail"}),!n.repos.length&&s.jsx("span",{className:"t-meta",children:"Connect a repository first."}),o&&s.jsx("span",{className:"vf-err",children:o})]})}function vw(e){const[t,n]=w.useState(),[i,o]=w.useState(),[c,d]=w.useState(!1),[u,f]=w.useState();return w.useEffect(()=>{let g=!0;const k=()=>void eE(e).then(b=>g&&b&&n(b));k();const y=setInterval(k,15e3);return()=>{g=!1,clearInterval(y)}},[e]),{mapId:e,state:t,busy:c,error:u,repo:i,setRepo:o,act:async g=>{d(!0),f(void 0);const k=await tE(e,{on:g,...g&&i?{repo:i}:{}});return d(!1),"error"in k?(f(k.error),!1):(n(k),g)}}}function vE({mapId:e,onStarted:t}){return s.jsx(kw,{agents:vw(e),onStarted:t})}function wE({created:e,mapId:t,onStarted:n}){if(nc())return s.jsxs("div",{className:"agent-draft created",children:[s.jsxs("span",{children:["Trail ",e," is on the map, starting with discovery."]}),s.jsx(vE,{mapId:t,onStarted:n})]});const i=Gt();return i?s.jsxs("div",{className:"agent-draft created",children:[s.jsxs("span",{children:["Trail ",e," is on the map, starting with discovery. Turn your agents on for it to get it moving."]}),s.jsx(R,{onClick:fw,children:i.label})]}):s.jsxs("div",{className:"agent-draft created",children:[s.jsxs("span",{children:["Trail ",e," is on the map, starting with discovery. To get it moving, run this in Claude Code or Codex:"]}),s.jsx(sc,{command:"/scout resume",label:"Copy command"})]})}function yE(e){const t=Gt();return s.jsxs("footer",{className:"new-trail-foot",children:[!t&&!e.created&&s.jsxs("div",{className:"agent-draft",children:[s.jsxs("span",{className:"dim",children:["Or paste this in Claude Code or Codex. Scout frames the trail with you there, then charts it here in"," ",e.tracker,"."]}),s.jsx(sc,{command:`/scout new "${e.idea||"your idea"}"`,label:"Copy command"})]}),e.created&&s.jsx(wE,{created:e.created.key,mapId:e.created.id,onStarted:e.onClose}),e.error&&s.jsx("p",{className:"vf-err",role:"alert",children:e.error}),s.jsxs("div",{className:"new-trail-buttons",children:[s.jsx(R,{variant:"ghost",onClick:e.onClose,children:"Close"}),!e.created&&s.jsx(R,{variant:"primary",disabled:e.disabled,"data-tip":t?"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:e.onCreate,children:"Create trail"})]})]})}function xE({seed:e,onClose:t,tracker:n,onCreate:i}){const[o,c]=w.useState(),[d,u]=w.useState(!1),[f,m]=w.useState(),[g,k]=w.useState((e==null?void 0:e.title)??""),[y,b]=w.useState((e==null?void 0:e.destination)??""),[S,x]=w.useState((e==null?void 0:e.notes)??""),[$,N]=w.useState((e==null?void 0:e.assumptions.join(`
151
+ `))??""),O={title:g.trim(),destination:y.trim(),notes:S.trim(),assumptions:pw($)},D=Nu(O),F=[O.title,Gu(O.destination)].filter(Boolean).join(". ").replace(/"/g,"'"),K=!o&&!!(g.trim()||y.trim()||S.trim()||$.trim()),I=()=>{K||t()};w.useEffect(()=>{const Z=q=>q.key==="Escape"&&!K&&t();return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[t,K]);const Q=()=>{u(!0),m(void 0),i(O).then(Z=>c({key:Z.key,id:Z.id})).catch(Z=>m(Z.message)).finally(()=>u(!1))};return s.jsx("div",{className:"scrim new-trail-scrim",onClick:I,children:s.jsxs(Be,{as:"div",className:"dialog new-trail",onClick:Z=>Z.stopPropagation(),children:[s.jsx("header",{children:s.jsx("h2",{className:"t-heading caps",children:e?"Start over":"New trail"})}),s.jsxs("div",{className:"new-trail-body",children:[s.jsxs("div",{className:"new-trail-col",children:[s.jsxs("label",{className:"new-trail-title",children:[s.jsx("span",{className:"new-trail-label",children:"Title"}),s.jsx("input",{value:g,onChange:Z=>k(Z.target.value),autoFocus:!0})]}),s.jsx(ou,{className:"doc-destination",label:"Destination",hint:"Markdown. Its first sentence is the one-line summary in the header.",value:y,onChange:b,max:ma.destination,placeholder:"What is true when this trail is done?"}),s.jsx(kE,{value:$,onChange:N})]}),s.jsx(ou,{className:"doc-notes",label:"Notes",hint:"Optional. A spec, a design doc, links: markdown, typed or loaded.",value:S,onChange:x,max:ma.notes})]}),s.jsx(yE,{idea:F,tracker:n,created:o,error:f,disabled:d||!O.title||!O.destination||!!D,onCreate:Q,onClose:t})]})})}const jE=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 bE({mapId:e}){const t=vw(e),{state:n}=t;if(!(n!=null&&n.on))return s.jsx(kw,{agents:t});const i=Gt();return s.jsxs(s.Fragment,{children:[s.jsx(tc,{className:"agents-menu",label:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:n.running?"agents-dot on":"agents-dot","aria-hidden":"true"}),gw(n)]}),children:o=>s.jsxs(s.Fragment,{children:[s.jsx("button",{role:"menuitem",className:"header-menu-item",disabled:t.busy,onClick:()=>{o(),t.act(!1)},children:"Pause agents"}),i&&s.jsx("a",{role:"menuitem",className:"header-menu-item",href:`${i.href}#trail-${encodeURIComponent(e)}`,children:"Runs"})]})}),t.error&&s.jsx("span",{className:"vf-err",children:t.error})]})}function SE({mapId:e}){if(nc())return s.jsx(bE,{mapId:e});const t=Gt();if(!t)return null;const n=()=>location.assign(`${t.href}#trail-${encodeURIComponent(e)}`);return s.jsx(R,{size:"sm",onClick:n,"data-tip":"Turn your agents on for this trail, or see them at work",children:"Run agents"})}const NE=s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9",cy:"9",r:"3.6",fill:"currentColor"}),s.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"})]}),$E=s.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 CE({onToggle:e}){const t=Qv(),n=t?"Switch to the day theme":"Switch to the night theme";return s.jsx(R,{variant:"ghost",className:"icon-only","aria-label":n,"data-tip":n,onClick:()=>e(!t),children:s.jsx("svg",{viewBox:"0 0 18 18",width:"16",height:"16","aria-hidden":"true",children:t?NE:$E})})}const TE={idle:"Idle",syncing:"Syncing",ok:"Synced",error:"Sync error"};function EE({label:e,health:t,now:n}){if(t.status!=="error")return null;const i=[`${TE[t.status]} · ${t.writes} writes · ${t.errors} errors`,t.lastWriteAt?`Last write ${qt(t.lastWriteMs??0)}, ${qt(n-t.lastWriteAt)} ago`:"No writes yet",t.lastError].filter(Boolean).join(`
152
+ `);return s.jsxs("span",{className:`tracker-chip sync-${t.status}`,title:i,children:[s.jsx(Ke,{size:"sm",children:"Tracker"}),s.jsx(Rr,{variant:"status",state:t.status,size:13,className:"sync-glyph"}),s.jsx("span",{className:"tl",children:e})]})}const ug={"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 AE(e){const{map:t}=e,[n,i]=w.useState();if(t.archived)return s.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 s.jsxs("div",{className:"trail-confirm",role:"group",children:[s.jsx("p",{className:"t-meta",children:ug[n].text(t)}),s.jsxs("div",{className:"actions",children:[s.jsx(R,{variant:"primary",onClick:()=>{n==="start-over"?e.onStartOver():e.onArchive(!0),e.onDone()},children:ug[n].confirm}),s.jsx(R,{onClick:()=>i(void 0),children:"Cancel"})]})]});const o=t.mode==="plan-only";return s.jsxs(s.Fragment,{children:[e.onToggleMode&&s.jsx("button",{role:"menuitem",className:"trail-item act","data-tip":o?"Agents decide, then build what was decided":"Agents research and decide; execute tickets wait",onClick:()=>{var c;return(c=e.onToggleMode)==null||c.call(e),e.onDone()},children:o?"Switch to Plan + execute":"Switch to Plan only"}),s.jsxs("button",{role:"menuitem",className:"trail-item act","data-tip":"The map went wrong? Archive it and describe the idea again",onClick:()=>i("start-over"),children:["Start ",t.key," over…"]}),s.jsxs("button",{role:"menuitem",className:"trail-item act","data-tip":"Put the trail away as history",onClick:()=>i("archive"),children:["Archive ",t.key,"…"]})]})}function IE(e){const{map:t}=e.snap,n=hS(e.snap);return s.jsxs("button",{role:"menuitem",className:`trail-item ${e.on?"on":""} ${t.archived?"archived":""}`,onClick:e.onSelect,children:[s.jsx("span",{className:"key",children:t.key}),s.jsx("span",{className:"mi-title",children:t.title}),s.jsxs("span",{className:"mi-progress",children:[n.decided,"/",n.total]}),s.jsx(bs,{n:e.waiting,urgent:!!e.waiting,hideZero:!0})]})}function RE(e){var g;const[t,n]=w.useState(!1),i=w.useRef(null);w.useEffect(()=>{if(!t)return;const k=y=>{var b;(y instanceof KeyboardEvent?y.key==="Escape":!((b=i.current)!=null&&b.contains(y.target)))&&n(!1)};return window.addEventListener("mousedown",k),window.addEventListener("keydown",k),()=>{window.removeEventListener("mousedown",k),window.removeEventListener("keydown",k)}},[t]);const o=Object.values(e.snaps).sort((k,y)=>y.map.createdAt-k.map.createdAt),c=o.filter(k=>!k.map.archived),d=o.filter(k=>k.map.archived),u=k=>e.activity.pending.filter(y=>y.mapId===k).length,f=e.activity.pending.filter(k=>{var y;return k.mapId!==((y=e.map)==null?void 0:y.id)}).length,m=k=>{var y;return s.jsx(IE,{snap:k,on:k.map.id===((y=e.map)==null?void 0:y.id),waiting:u(k.map.id),onSelect:()=>{e.onSelectMap(k.map.id),n(!1)}},k.map.id)};return s.jsxs("div",{className:"trail-switcher",ref:i,children:[s.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:[s.jsx("span",{className:"trail-title",children:e.map?`${e.map.key} ${e.map.title}`:"No trail"}),((g=e.map)==null?void 0:g.archived)&&s.jsx("span",{className:"trail-archived",children:"archived"}),f>0&&s.jsx(bs,{n:f,urgent:!0}),s.jsx("span",{className:"caret",children:"▾"})]}),t&&s.jsxs("div",{className:"trail-menu",role:"menu",children:[s.jsx(Ke,{variant:"plain",className:"menu-h",children:"Trails"}),c.map(m),s.jsx("button",{role:"menuitem",className:"trail-item new",onClick:()=>{n(!1),e.onNewTrail()},children:"+ New trail"}),d.length>0&&s.jsxs(s.Fragment,{children:[s.jsx(Ke,{variant:"plain",className:"menu-h",children:"Archived"}),d.map(m)]}),e.map&&e.onStartOver&&e.onArchive&&s.jsx("div",{className:"trail-acts",children:s.jsx(AE,{map:e.map,onStartOver:e.onStartOver,onArchive:e.onArchive,onToggleMode:e.onToggleMode,onDone:()=>n(!1)})})]})]})}function ME(e){const{map:t}=e,n=gt(1e3),i=e.activity.pending.length,o=t&&e.snaps[t.id],c=t&&Xk(e.activity,t.id),d=t?Gu(t.sections.destination):"";return s.jsxs(Be,{as:"header",className:"header",children:[s.jsxs("div",{className:"h-title",children:[s.jsxs("div",{className:"h-line1",children:[e.repo,s.jsx("span",{className:"sep",children:"/"}),s.jsx(RE,{...e})]}),s.jsxs("div",{className:"h-dest",title:d,children:[s.jsx(Ke,{size:"sm",children:"Destination"}),d||"—"]})]}),s.jsxs("div",{className:"h-right",children:[s.jsx(EE,{label:e.trackerLabel,health:e.health,now:n}),s.jsx(Y2,{now:n}),t&&o&&s.jsxs("span",{className:"trail-meta",children:[s.jsx(Tn,{label:"Trail T+",value:Av(n-t.createdAt),title:"Trail elapsed time, since it was charted"}),c&&c.costUsd+c.inputTokens+c.outputTokens>0&&s.jsx(Tn,{className:"spend",label:"Spent",value:`${hi(c.costUsd)} · ${Ha(c.inputTokens+c.outputTokens)} tok`,title:["Model spend and tokens for this trail, across every session",...ev(e.activity,t.id).map(u=>Zk[u].text)].join(`
153
+ `)})]}),e.attention,e.needs,!e.attention&&!e.needs&&i>0&&s.jsxs("span",{className:"waiting-chip",title:`${i} waiting on you`,children:[s.jsx(Rr,{variant:"alert",size:14}),s.jsx("b",{children:i}),s.jsx("span",{className:"wl",children:" waiting on you"})]}),e.slackAlert&&s.jsx(R,{size:"sm",variant:"urgent",onClick:e.onSlack,title:e.slackAlert.why,children:e.slackAlert.label}),(t==null?void 0:t.mode)==="plan-only"&&s.jsx(R,{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&&s.jsx(SE,{mapId:t.id}),s.jsx(Z2,{onStats:e.onStats,knowledge:e.knowledge,onKnowledge:e.onKnowledge,briefingOpen:e.briefingOpen,briefingStatus:e.briefingStatus,onBriefing:e.onBriefing}),s.jsx(R,{variant:"ghost",onClick:e.onSettings,"data-tip":"Tracker, verification, appearance and integrations",children:"Settings"}),Yv()?null:s.jsx(CE,{onToggle:e.onToggleTheme}),s.jsx(J2,{})]})]})}function LE(e){const{count:t,elsewhere:n}=e,i=n>0?`${n} more on other trails`:"";if(!t&&!n)return null;if(!t)return s.jsx(R,{className:"needs-btn elsewhere","data-tip":`Nothing here · ${i}`,onClick:e.onOpen,children:"On other trails"});const o=`${t} need${t===1?"s":""} you`,c=[e.top&&`Most urgent: ${e.top}`,i].filter(Boolean).join(" · ");return s.jsx(R,{variant:"urgent",className:"needs-btn","data-tip":c,"aria-label":i?`${o} on this trail, ${i}`:o,onClick:e.onOpen,children:o})}function OE(e){return s.jsx(Be,{as:"nav",className:"view-bar","aria-label":"Views",children:e.tabs.map(t=>s.jsx("button",{type:"button",className:ue("view-bar-tab",e.value===t.id&&"on"),"aria-current":e.value===t.id?"page":void 0,onClick:()=>e.onChange(t.id),children:t.label},t.id))})}const hg={label:"Focus for 1 hour",change:{kind:"for",minutes:60}};function PE(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},hg];case"off":return[{...hg,primary:!0},{label:"Focus for 3 hours",change:{kind:"for",minutes:180}}];default:return e}}const fg=e=>Wa(e).slice(0,5),DE=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function _E(e){const t=`${e.items.length} waiting on you`;return e.heldBack===0?`Nothing held back · ${t}`:`${DE(e.heldBack,"item")} would interrupt you · ${t}`}function jd(e){const t=e.prefs.focus;return t?`Quiet hours ${t.from}–${t.to}`:"No quiet hours set"}const mg=e=>`Items scoring ${e.policy.value.interrupt} or more interrupt you · ${e.items.length} waiting on you`;function BE(e){const t=e.focus;switch(t.kind){case"manual":case"hours":{const n=fg(t.until),i=t.kind==="manual"?"Switched on here":jd(e);return{word:"on",until:n,on:!0,title:`Focus is on until ${n}`,reason:i,detail:_E(e)}}case"paused":{const n=fg(t.until),i=`Quiet hours paused until ${n}`;return{word:"paused",until:n,on:!1,title:i,reason:jd(e),detail:mg(e)}}case"off":return{word:"off",until:"",on:!1,title:"Focus is off",reason:jd(e),detail:mg(e)};default:return t}}const FE="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 zE(e){const{view:t}=e,n=BE(t),i=t.focus.kind,o=s.jsxs("span",{className:ue("focus-state",`focus-${i}`),children:[s.jsx("i",{className:"focus-dot","aria-hidden":"true"}),s.jsxs("span",{className:"focus-label",children:["Focus",s.jsxs("span",{className:"focus-word",children:[" ",n.word]})]}),n.until&&s.jsxs("span",{className:"focus-until",children:[s.jsx("span",{className:"sep",children:" · "}),s.jsx("span",{className:"focus-until-word",children:"until "}),n.until]})]});return s.jsx(tc,{className:"focus-menu",label:o,role:"dialog",tip:n.title,ariaLabel:n.title,children:c=>s.jsxs("div",{className:"focus-panel","aria-label":"Focus",children:[s.jsxs("div",{className:"focus-panel-head",children:[s.jsx("span",{className:"t-row-title",children:n.title}),s.jsx(wi,{text:FE})]}),s.jsx(_,{parts:[n.reason]}),s.jsx(_,{className:"focus-held",parts:[n.detail]}),s.jsxs("div",{className:"focus-panel-actions",children:[PE(t.focus).map(d=>s.jsx(R,{size:"sm",variant:d.primary?"primary":"default",onClick:()=>{c(),e.onChange(d.change)},children:d.label},d.label)),s.jsx(R,{size:"sm",variant:"ghost",onClick:()=>{c(),e.onSettings()},children:"Quiet hours"})]})]})})}function UE(e){return s.jsx("span",{className:"attention-head",children:s.jsx(zE,{view:e.view,onChange:e.onFocus,onSettings:e.onSettings})})}const ww=`${re()}/attention`,WE=250;async function bd(e,t,n){var c;const i=await fetch(`${ww}${e}`,{method:t,headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),o=await i.json().catch(()=>({}));if(!i.ok)throw new Error(((c=o.errors)==null?void 0:c.join("; "))??o.error??`HTTP ${i.status}`);return o}function yw(e){const[t,n]=w.useState(),[i,o]=w.useState(),[c]=w.useState(ki),d=w.useCallback(()=>{const m=c.start();fetch(ww).then(g=>g.ok?g.json():void 0).then(g=>g&&m()&&n(g)).catch(()=>{})},[c]);w.useEffect(()=>vi("attention",m=>{c.pushed(),n(JSON.parse(m))}),[c]),w.useEffect(()=>as(d),[d]),w.useEffect(()=>{const m=setTimeout(d,WE);return()=>clearTimeout(m)},[d,e]);const u=m=>m.then(()=>(o(void 0),d(),!0),g=>(o(g.message),!1)),f=(m,g)=>void bd(m,"POST",g).then(()=>(o(void 0),d()),k=>o(k.message));return{view:t,error:i,snooze:(m,g)=>f("/snooze",{id:m,minutes:g}),dismiss:m=>f("/dismiss",{id:m}),savePrefs:m=>u(bd("/prefs","PUT",m)),saveReviewLimit:m=>u(bd("/review-limit","PUT",{limit:m}))}}function HE(e){return e.prefs.channel!=="browser"?!1:typeof Notification<"u"&&Notification.permission==="granted"}function KE(e){const t=new Notification(`${J.name} · needs you`,{body:e.title,tag:e.id});t.onclick=()=>{window.focus(),t.close()}}function GE(e){const t=w.useRef();w.useEffect(()=>{if(!e)return;const n=new Set(e.interrupting),i=t.current;if(t.current=n,!(!i||!HE(e)))for(const o of e.items)n.has(o.id)&&!i.has(o.id)&&KE(o)},[e])}const VE={question:"waiting on you",approval:"approve it",merge:"ready to merge",blocked:"blocked",stalled:"went quiet","hitl-ready":"yours to decide",model:"needs a model",policy:"risky change",flag:"PR or CI",overlap:"same files",integration:"branches clash",precedent:"your decision","tracker-settings":"settings changed","review-limit":"review waits",escape:"came back"},qE={"trail-checks":"Fails on main together","hitl-ready":"Decide",approval:"Approve",blocked:"Unblock",stalled:"Went quiet",model:"Needs a model",policy:"Risky change",brief:"Brief",reroute:"Reroute","reroute-suggested":"Reroute?",trust:"Approve on this machine",guide:"Approve a guide","guide-checks":"Approve guide checks",knowledge:"Field guide",overlap:"Same files",integration:"Branches clash",precedent:"Your decision",flag:"PR or CI","tracker-settings":"Settings changed","review-limit":"Review waits",escape:"Came back"};function xw(e){return VE[e.kind]??"needs you"}function Sd(e){var t;return e.kind==="question"?e.agent?`Answer ${e.agent}`:"Answer":e.kind==="merge"?((t=e.title.match(/PR #\d+/))==null?void 0:t[0].replace("PR","Merge PR"))??"Merge":e.kind==="main-checks"?e.title.split(":")[0].replace(" already","").replace(/ on main$/,""):qE[e.kind]??Ju[e.kind]}function QE(e,t){const n=e.ticketId?t(e.ticketId):void 0;return e.kind==="main-checks"?`main: ${Sd(e)}`:n?`${n} ${Sd(e)}`:Sd(e)}function YE(e){const t=gt(1e3);return e.items.length?s.jsx("ul",{className:"inbox-list approvals",children:e.items.map(n=>{var c;const i=n.kind!=="approve",o=n.mapId!==e.currentMapId?(c=e.snaps[n.mapId])==null?void 0:c.map.title:void 0;return s.jsx(fe,{as:"li",edge:i?"attention":"neutral",title:`${i?"Decide":"Approve"}: ${n.title}`,context:s.jsx(_,{parts:[i?"Held":"Verified",{text:n.ticketKey,code:!0},o]}),detail:n.reason,detailText:n.reason,trailing:Je(t-n.at),onOpen:()=>e.onOpen(n.mapId,n.ticketId)},`${n.mapId}/${n.ticketId}`)})}):null}function pg({activity:e}){const t=gt(1e3),n=pS(e);return s.jsxs("div",{className:"hitl-readout",children:[s.jsx(Tn,{layout:"inline",label:"Oldest",value:n.oldestAt?qt(t-n.oldestAt):"—",urgent:!!n.oldestAt&&t-n.oldestAt>6e4,title:"Oldest open question"}),s.jsx(Tn,{layout:"inline",label:"Avg wait",value:n.avgWaitMs!==void 0?qt(n.avgWaitMs):"—",title:`Average wait over ${n.answered} answered questions`}),s.jsx(Tn,{layout:"inline",label:"Answered",value:n.answered})]})}function JE(e){const t=gt(1e3);return e.items.length?s.jsx("ul",{className:"inbox-list",children:e.items.map(n=>{const i=e.snaps[n.mapId],o=i==null?void 0:i.tickets.find(u=>u.id===n.ticketId),c=n.mapId!==e.currentMapId?i==null?void 0:i.map.title:void 0,d=n.text.split(`
154
+ `)[0];return s.jsx(fe,{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:s.jsx(_,{parts:[n.urgency==="blocking"&&{text:"Blocking",urgent:!0},`${n.agent} asks`,o&&{text:o.key,code:!0},o==null?void 0:o.title,c]}),trailing:Je(t-n.at),onOpen:()=>e.onOpen(n.sessionId,n.ticketId)},n.id)})}):s.jsx(An,{title:"Nothing waiting on you",hint:"When an agent needs your call, its question lands here."})}const jw={pass:"Passed",fail:"Failed",error:"Could not run",interrupted:"Interrupted"},Pr={off:"Off",checks:"Checks","checks+review":"Checks + review","checks+review+human":"Checks + review + you"},eh={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."},bw=e=>e.exitCode===0&&!e.timedOut&&!e.error;async function na(e){const t=await e.json().catch(()=>({}));if(!e.ok)throw new Error(t.error??`HTTP ${e.status}`);return t}const ii=`${re()}/verification`,Ss={ticket:(e,t)=>fetch(`${ii}/ticket?mapId=${encodeURIComponent(e)}&ticketId=${encodeURIComponent(t)}`).then(n=>n.ok?n.json():void 0,()=>{}),inbox:()=>fetch(`${ii}/inbox`).then(e=>e.ok?e.json().then(t=>t.items):[],()=>[]),log:e=>fetch(`${ii}/log?path=${encodeURIComponent(e)}`).then(t=>na(t)),waive:e=>fetch(`${ii}/waive`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(t=>na(t)),undoWaiver:e=>fetch(`${ii}/waive/undo`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(t=>na(t)),act:e=>fetch(`${ii}/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(t=>na(t))};function XE(e){const[t,n]=w.useState([]),i=Object.values(e).map(c=>c.tickets.map(d=>`${d.id}:${d.state}:${d.status??""}`).join()).join("|"),{reload:o}=Pe({version:i,load:Ss.inbox,show:n});return w.useEffect(()=>ss.onEvidence(o),[o]),t}function ZE(e){var u;const t=[...e.activity.pending].sort((f,m)=>f.at-m.at),n=XE(e.snaps),i=(u=e.attention)==null?void 0:u.view,o=e.brief?1:0,c=i?i.items.length:t.length+n.length+o,d=s.jsx(yt,{hot:c>0,title:s.jsxs(s.Fragment,{children:[c>0&&s.jsx(Rr,{variant:"alert",size:12}),"Waiting on you"]}),count:s.jsx(bs,{n:c,urgent:c>0,pop:!0},c)});return i&&e.attention&&e.handlers?s.jsxs("div",{className:"inbox-part",children:[d,s.jsx(pg,{activity:e.activity}),s.jsx(hw,{view:i,snaps:e.snaps,pending:e.activity.pending,currentMapId:e.currentMapId,selected:e.sessionId,handlers:e.handlers,onSnooze:e.attention.snooze,onDismiss:e.attention.dismiss})]}):s.jsxs("div",{className:"inbox-part",children:[d,s.jsx(pg,{activity:e.activity}),e.brief,s.jsx(YE,{items:n,snaps:e.snaps,currentMapId:e.currentMapId,onOpen:e.onOpenTicket}),(t.length>0||!(n.length+o))&&s.jsx(JE,{items:t,snaps:e.snaps,currentMapId:e.currentMapId,selected:e.sessionId,onOpen:e.onOpenQuestion})]})}function Sw(e){const{q:t}=e,[n,i]=w.useState(""),o=w.useRef(null),c=(t.blocks??[]).map(e.keyOf).filter(Boolean),d=u=>{u.trim()&&(e.onAnswer(t.id,u.trim()),i(""))};return s.jsxs("div",{className:"bubble-need open-q",children:[s.jsx("span",{className:"t-label urgent",children:"Waiting on you"}),s.jsx("h3",{className:"bubble-title",children:t.text}),s.jsx(_,{parts:[`${t.agent} asks`,c.length>0&&`blocks ${c.join(" and ")}`,Je(e.now-t.at)]}),t.stakes&&s.jsx(_,{parts:[{text:t.stakes,strong:!0}]}),t.precedent&&s.jsx(_,{className:"open-q-precedent",parts:[t.precedent]}),s.jsx("div",{className:"bubble-answer",children:s.jsx(lw,{pending:t,draft:n,onDraft:i,onSend:d,inputRef:o})}),s.jsx("button",{type:"button",className:"link",onClick:()=>e.onOpenChat(t.sessionId),children:"The whole conversation"})]})}function eA(e){const[t,n]=w.useState(""),[i,o]=w.useState(),[c,d]=w.useState(!1),u=async()=>{d(!0),o(void 0);const f=await fetch(`${re()}/verification/rules/waive`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e.mapId,ticketId:e.ticketId,rule:e.rule,reason:t})}).catch(()=>{});if(d(!1),f!=null&&f.ok)return e.onDone();const m=await(f==null?void 0:f.json().catch(()=>({})));o((m==null?void 0:m.error)??"The server didn't answer.")};return s.jsxs("form",{className:"dr-waive",onSubmit:f=>{f.preventDefault(),u()},children:[s.jsx("input",{"aria-label":`Why ${e.rule} can go unanswered`,value:t,placeholder:"Why it can go unanswered",autoFocus:!0,onChange:f=>n(f.target.value)}),s.jsxs(R,{type:"submit",disabled:c||!t.trim(),children:["Go without ",e.rule]}),i&&s.jsx("span",{className:"vf-err",children:i})]})}function tA(e){const[t,n]=w.useState();return s.jsxs("div",{className:"dr-held",children:[s.jsxs("p",{className:"t-meta",children:[e.held.agent,"'s completion waits for these answers."]}),s.jsx("ul",{className:"dr-list",children:e.held.rules.map(i=>s.jsx(fe,{as:"li",edge:"attention",title:i.ask,context:s.jsx(_,{parts:[{text:i.id,code:!0},`Why: ${i.why}`]}),detail:i.files.join(", "),actions:s.jsx(R,{size:"sm",onClick:()=>n(i.id),children:"Go without"}),below:t===i.id&&s.jsx(eA,{mapId:e.mapId,ticketId:e.ticketId,rule:i.id,onDone:()=>{n(void 0),e.onWaived()}})},i.id))})]})}function nA(e,t){const[n,i]=w.useState({waived:[]}),o=async()=>{const d=new URLSearchParams({mapId:e,ticketId:t}),u=await fetch(`${re()}/verification/rules/held?${d}`);if(!u.ok)return{waived:[]};const f=await u.json();return{held:f.held,waived:f.waived??[]}},c=Pe({view:`${e}/${t}`,load:o,show:i,events:{verification:()=>!0,leases:()=>!0,attention:()=>!0}});return{...n,reload:c.reload}}function sA(e){const[t,n]=w.useState(),[i,o]=w.useState(!1),c=async()=>{o(!0),n(void 0);const d=await fetch(`${re()}/verification/rules/waive/undo`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e.mapId,ticketId:e.ticketId,rule:e.rule})}).catch(()=>{});if(o(!1),d!=null&&d.ok)return e.onDone();const u=await(d==null?void 0:d.json().catch(()=>({})));n((u==null?void 0:u.error)??"The server didn't answer.")};return s.jsxs(s.Fragment,{children:[s.jsx(R,{size:"sm",variant:"ghost",disabled:i,"aria-label":`Undo going without ${e.rule}`,"data-tip":"The rule asks again on the next completion",onClick:()=>void c(),children:"Undo"}),t&&s.jsx("span",{className:"vf-err",children:t})]})}function iA(e){return e.waived.length?s.jsx("ul",{className:"dr-list dr-waived",children:e.waived.map(t=>s.jsx(fe,{as:"li",title:`Went without ${t.rule}`,context:s.jsx(_,{parts:[t.by,is(t.at)]}),detail:t.reason,actions:s.jsx(sA,{mapId:e.mapId,ticketId:e.ticketId,rule:t.rule,onDone:e.onUndone})},t.rule))}):null}function rA(e){const{held:t,waived:n,reload:i}=nA(e.mapId,e.ticketId),o=t&&t.rules.length>0;return!o&&!n.length?null:s.jsxs(Ot,{label:"Diff rules",className:"dr-rules",children:[o&&s.jsx(tA,{mapId:e.mapId,ticketId:e.ticketId,held:t,onWaived:i}),s.jsx(iA,{mapId:e.mapId,ticketId:e.ticketId,waived:n,onUndone:i})]})}function Ae(e){return s.jsxs("section",{className:"set-sec",children:[s.jsx(Ke,{as:"h4",children:e.title}),e.children]})}function ji(){const[e,t]=w.useState();return w.useEffect(()=>{fetch(`${re()}/machine`).then(n=>n.ok?n.json():void 0).then(n=>t(n==null?void 0:n.local),()=>t(void 0))},[]),e}async function oA(){const e=await fetch(`${re()}/verification/config`);return e.ok?await e.json():null}function th(){const[e,t]=w.useState(),{reload:n}=Pe({load:oA,show:t,failed:()=>t(null),changed:i=>i.endsWith("verification.json"),events:{attention:()=>!0}});return{view:e,reload:n}}function aA(e){const{rule:t,onChange:n}=e,i=t.id?`Remove ${t.id}`:"Remove rule",o=[{value:"",label:"No check"},...e.checks.map(d=>({value:d,label:`Run ${d}`}))],c=e.lastMatched?`Last matched ${is(e.lastMatched)}`:"Not matched yet";return s.jsxs("li",{className:"dr-edit-rule",children:[s.jsxs("div",{className:"dr-edit-head",children:[s.jsx("span",{className:"t-code dr-id",children:t.id??"New"}),s.jsx("input",{"aria-label":"When these files change",className:"t-code",value:t.when,placeholder:"src/session/**, src/store.ts",autoFocus:e.focus,onChange:d=>n({when:d.target.value})}),s.jsx("button",{type:"button",className:"icon-btn vf-edit-remove","aria-label":i,"data-tip":i,onClick:e.onRemove,children:"×"})]}),s.jsxs("div",{className:"dr-edit-body",children:[s.jsx(it,{"aria-label":"Check",value:t.check,options:o,onChange:d=>n({check:d})}),s.jsx("input",{"aria-label":"Question",value:t.ask,placeholder:"Question the agent answers (optional)",onChange:d=>n({ask:d.target.value})}),s.jsx("input",{"aria-label":"Why",value:t.why,placeholder:"Why: the incident behind it",onChange:d=>n({why:d.target.value})}),t.id&&s.jsx("span",{className:"t-meta",children:c})]})]})}const cA=e=>((e==null?void 0:e.rules)??[]).map(t=>({id:t.id,when:t.when.join(", "),check:t.check??"",ask:t.ask??"",why:t.why})),au=e=>({...e.id?{id:e.id}:{},when:e.when.split(",").map(t=>t.trim()).filter(Boolean),...e.check?{check:e.check}:{},...e.ask.trim()?{ask:e.ask.trim()}:{},why:e.why.trim()});function lA(e,t){var c;const n=new URLSearchParams(e),i=(c=n.get("when"))==null?void 0:c.trim().slice(0,1e3);if(n.get("settings")!=="rules"||!i)return;const o=au({when:i,check:"",ask:"",why:""}).when.join(",");if(!t.some(d=>au(d).when.join(",")===o))return{when:i,check:"",ask:"",why:(n.get("why")??"").slice(0,300)}}const dA={when:"",check:"",ask:"",why:""};function uA(e){var b;const{view:t,lastMatched:n}=e,[i,o]=w.useState(()=>{const S=cA(t.config),x=lA(location.search,S);return[...S,...x?[x]:[]]}),[c,d]=w.useState(!1),[u,f]=w.useState({kind:"idle"}),m=Object.keys(((b=t.config)==null?void 0:b.checks)??{}),g=(S,x)=>o(i.map(($,N)=>N===S?{...$,...x}:$)),k=async()=>{var N;f({kind:"saving"});const S=i.filter(O=>O.when.trim()).map(au),x=await fetch(`${re()}/verification/rules`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({rules:S,base:((N=t.approval)==null?void 0:N.base)??"none"})}).catch(()=>{}),$=await(x==null?void 0:x.json().catch(()=>({})));if(x!=null&&x.ok)return f({kind:"idle"}),e.onSaved();f({kind:"error",text:($==null?void 0:$.error)??"The server didn't answer."})},y=u.kind==="saving";return s.jsxs("div",{className:"vf-editor dr-editor",children:[i.length>0&&s.jsx("ul",{className:"vf-edit-list",children:i.map((S,x)=>s.jsx(aA,{rule:S,checks:m,lastMatched:S.id?n[S.id]:void 0,focus:c&&x===i.length-1,onChange:$=>g(x,$),onRemove:()=>o(i.filter(($,N)=>N!==x))},S.id??`new-${x}`))}),s.jsx("div",{className:"vf-edit-add",children:s.jsx(R,{onClick:()=>{d(!0),o([...i,dA])},children:"Add rule"})}),s.jsxs("div",{className:"vf-edit-foot",children:[s.jsx("span",{className:"t-meta",children:"Saving approves them on this machine."}),s.jsxs("div",{className:"vf-edit-save",children:[e.saved&&u.kind==="idle"&&s.jsx("span",{className:"t-meta",children:"Saved and approved."}),u.kind==="error"&&s.jsx("span",{className:"vf-err",children:u.text}),s.jsx(R,{variant:"primary",disabled:y,onClick:()=>void k(),children:y?"Saving…":"Save rules"})]})]})]})}function hA({rules:e,lastMatched:t}){return s.jsx("ul",{className:"dr-list",children:e.map(n=>s.jsx(fe,{as:"li",title:s.jsx("span",{className:"t-code",children:n.when.join(", ")}),context:s.jsx(_,{parts:[{text:n.id,code:!0},n.check&&`Runs ${n.check}`,n.ask&&`Asks: ${n.ask}`]}),detail:`Why: ${n.why}`,trailing:t[n.id]?is(t[n.id]):"Not matched yet"},n.id))})}async function fA(){const e=await fetch(`${re()}/verification/rules`);return e.ok?(await e.json()).lastMatched??{}:{}}function mA(){const[e,t]=w.useState({});return Pe({load:fA,show:t,events:{verification:()=>!0}}),e}function pA(e){var t;if(!e.exists)return"Set the checks first: without them nothing is verified.";if((t=e.approval)!=null&&t.waiting)return"Approve the checks first."}function gA(){var u,f;const{view:e}=th(),t=ji(),n=mA(),[i,o]=w.useState(!1);if(!e)return null;const c=((u=e.config)==null?void 0:u.rules)??[],d=pA(e);return s.jsxs(Ae,{title:"Diff rules",children:[s.jsx("p",{className:"vf-intro",children:"When a change touches certain files, run a check or ask the agent a question it must answer before the ticket completes. Each rule says why it exists."}),t&&!d&&s.jsx(uA,{view:e,lastMatched:n,saved:i,onSaved:()=>o(!0)},((f=e.approval)==null?void 0:f.base)??"none"),(!t||d)&&c.length>0&&s.jsx(hA,{rules:c,lastMatched:n}),d&&s.jsx("span",{className:"set-hint t-meta",children:d}),t===!1&&s.jsx("span",{className:"set-hint t-meta",children:"Set on the machine Teamtrail runs on."})]})}const Nw=()=>`${re()}/proof/settings`;async function kA(){const e=await fetch(Nw());return e.ok?await e.json():null}function vA(){const[e,t]=w.useState(),{pushed:n}=Pe({load:kA,show:o=>t((o==null?void 0:o.enabled)??null),failed:()=>t(null),events:{proof:()=>!0}}),i=w.useCallback(async o=>{const c=await fetch(Nw(),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:o})}),d=await c.json();if(!c.ok)return d.error??`Saving failed (${c.status})`;n(),t(d.enabled===!0)},[n]);return{enabled:e,set:i}}function wA(){const{enabled:e,set:t}=vA(),[n,i]=w.useState();if(e==null)return null;const o=()=>{i(void 0),t(!e).then(i,c=>i(c.message))};return s.jsxs(Ae,{title:"Proof on pull requests",children:[s.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 ",s.jsx("b",{children:"Teamtrail proof"})," check next to CI. The comment is updated, never repeated, when the proof or the PR changes."]}),s.jsxs("div",{className:"att-settings-row set-field",children:[s.jsx("span",{className:"set-field-label",children:"Post proofs from this machine"}),s.jsx(R,{size:"sm",on:e,"aria-pressed":e,className:"proof-post-toggle",onClick:o,children:e?"On":"Off"})]}),s.jsxs("span",{className:"set-hint t-meta",children:["Posted with your GitHub token, to the repo Teamtrail syncs pull requests with (",s.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&&s.jsx("span",{className:"vf-err",children:n})]})}function yA(e){const t=e.guard;return t?t.accepted?`changed what its checks run, accepted by ${t.accepted.by}`:t.mode==="observe"&&"changed what its checks run (observed)":!1}function xA(e){var i,o,c;const t=e.checks.filter(d=>d.passed).length,n=e.reviews.length;return[e.checks.length>0&&`${t}/${e.checks.length} checks passed`,!!((i=e.waived)!=null&&i.length)&&`${e.waived.map(d=>d.name).join(", ")} skipped`,!!((o=e.retried)!=null&&o.length)&&`${e.retried.map(d=>d.name).join(", ")} passed on retry`,yA(e),e.criteria.lines.length>0&&`${e.criteria.verified} criteria verified, ${e.criteria.claimed} claimed`,n>0&&`${n} review${n>1?"s":""}`,!!((c=e.guides)!=null&&c.length)&&`guides ${e.guides.map(d=>d.id).join(", ")}`,{text:e.digest.slice(0,19),code:!0}]}const jA=(e,t)=>e?"the same model as the author":t?`author on ${t}`:"author model unknown";function bA(e){const t=e.attempt.model;return e.reviews.filter(n=>n.byKind==="agent"&&n.model).map(n=>[`Reviewed by ${n.by} on ${n.model}`,jA(n.sameModel,t)])}function nh(e,t){const n=e.state==="closed"&&e.closeReason==="completed";return!!t.attempt.id||n&&hv.includes(e.type)}function SA(e){const{view:t}=e;if(!t)return null;const{proof:n,post:i}=t;if(!nh(e.ticket,n))return null;const o=n.status==="verified",c=i!=null&&i.commentUrl?At(i.commentUrl):void 0,d=xA(n);return s.jsxs(Ot,{label:"Proof",className:"ticket-proof",children:[s.jsxs("div",{className:"proof-head",children:[s.jsx(xi,{tone:o?"fill":"amber",children:o?"Verified by Teamtrail":"Not verified"}),s.jsx(_,{parts:d.slice(0,-1)})]}),bA(n).map((u,f)=>s.jsx("div",{className:"proof-review-model",children:s.jsx(_,{parts:u})},f)),n.gaps.length>0&&s.jsx("ul",{className:"proof-gaps t-meta",children:n.gaps.map(u=>s.jsx("li",{children:u},u))}),s.jsxs(an,{children:[s.jsx(_,{parts:["Digest",...d.slice(-1)]}),c&&s.jsxs("a",{className:"t-meta",href:c,target:"_blank",rel:"noreferrer",children:["Posted on pull request #",i.pr]}),(i==null?void 0:i.error)&&s.jsxs("p",{className:"t-meta",children:["Posting failed, trying again: ",i.error]}),t.keyFile&&s.jsxs("p",{className:"t-meta",children:["Signed with this machine's key. Commit ",s.jsx("code",{children:`${J.dataDir}/${t.keyFile}`})," so others can check it."]})]})]})}function NA(e,t){const[n,i]=w.useState();return Pe({load:async()=>{const o=new URLSearchParams({mapId:e,ticketId:t}),c=await fetch(`${re()}/proof/ticket?${o}`);return c.ok?await c.json():null},show:i,failed:()=>i(null),view:`${e}/${t}`,changed:o=>o.includes(`tickets/${t}.md`),events:{verification:()=>!0,proof:()=>!0}}),n}function $w(e){const t=e.anyway?"Merged at the commit its proof covers.":"Approved and merged at the verified commit.";return s.jsxs("span",{className:"t-meta merge-note",children:[t," ",e.url&&s.jsx("a",{href:e.url,target:"_blank",rel:"noreferrer",children:"See the pull request"})]})}const gg="The server didn't answer. Try again.",Cw=(e,t)=>String(e.error??`The server answered ${t}.`).slice(0,300);async function Tw(e,t){const n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),i=await n.json().catch(()=>({}));return{ok:n.ok,status:n.status,json:i}}async function $A(e){const t=await Tw(`${re()}/proof/merge-anyway`,e),n=t.json.gapsHash;return t.ok&&typeof n=="string"?{hash:n}:{error:Cw(t.json,t.status)}}async function CA(e){try{const t=e.gaps?await $A({mapId:e.mapId,ticketId:e.ticketId,gaps:e.gaps}):void 0;if(t&&"error"in t)return{kind:"error",text:t.error??gg};const n=t?{anyway:!0,gaps:t.hash}:{},i=await Tw(e.path,{trail:e.mapId,ticket:e.ticketId,...n}),o=typeof i.json.url=="string"?At(i.json.url):void 0;return i.ok&&i.json.merged?{kind:"merged",url:o}:{kind:"error",text:Cw(i.json,i.status)}}catch{return{kind:"error",text:gg}}}function Ew(e){const[t,n]=w.useState({kind:"idle"});return{state:t,ask:()=>n({kind:"confirm"}),cancel:()=>n({kind:"idle"}),merge:async o=>{n({kind:"working"}),n(await CA({...e,gaps:o}))}}}function TA(e){const t=Ew(e),{state:n}=t;return n.kind==="merged"?s.jsx($w,{url:n.url}):n.kind==="confirm"?s.jsxs("div",{className:"merge-confirm",children:[s.jsx("span",{className:"t-meta",children:"Merge its pull request, at exactly the commit Teamtrail verified?"}),s.jsx(R,{size:"sm",onClick:()=>void t.merge(),children:"Merge"}),s.jsx(R,{size:"sm",variant:"ghost",onClick:t.cancel,children:"Cancel"})]}):s.jsxs("div",{className:"merge-confirm",children:[s.jsx(R,{size:"sm",disabled:n.kind==="working",onClick:t.ask,children:n.kind==="working"?"Merging…":"Approve and merge"}),n.kind==="error"&&s.jsx("span",{className:"t-meta",children:n.text})]})}function kg(e){const[t,...n]=e.gaps;return s.jsxs("div",{className:"merge-gaps",children:[s.jsxs("span",{className:"t-meta",children:["Not verified: ",t??"no passing completion."]}),n.length>0&&s.jsx(an,{label:`${n.length} more`,children:s.jsx("ul",{className:"proof-gaps t-meta",children:n.map(i=>s.jsx("li",{children:i},i))})})]})}function EA(e){const t=Ew(e),{state:n}=t;return n.kind==="merged"?s.jsx($w,{url:n.url,anyway:!0}):n.kind==="confirm"?s.jsxs("div",{className:"merge-confirm",children:[s.jsx("span",{className:"t-meta",children:"Merge without a verified proof? It is recorded as your decision, accepting what isn't verified."}),s.jsx(R,{size:"sm",onClick:()=>void t.merge(e.gaps),children:"Merge anyway"}),s.jsx(R,{size:"sm",variant:"ghost",onClick:t.cancel,children:"Cancel"}),s.jsx(kg,{gaps:e.gaps})]}):s.jsxs("div",{className:"merge-confirm",children:[s.jsx(R,{size:"sm",disabled:n.kind==="working",onClick:t.ask,children:n.kind==="working"?"Merging…":"Merge anyway"}),n.kind==="error"&&s.jsx("span",{className:"t-meta",children:n.text}),s.jsx(kg,{gaps:e.gaps})]})}function AA(e){var d,u,f;const t=(d=pt())==null?void 0:d.merge,n=(u=e.proof)==null?void 0:u.proof;if(!t||!n)return null;const i=!!n.attempt.id&&!!((f=n.git)!=null&&f.head)&&!!n.git.branch,o=e.prState!==void 0&&e.prState!=="open";if(!i||o)return null;const c={path:t,mapId:e.mapId,ticketId:e.ticketId};return n.status==="verified"?s.jsx(TA,{...c}):s.jsx(EA,{...c,gaps:n.gaps})}function vg({criteria:e}){return s.jsx("ul",{className:"criteria-list item-list",children:e.map(t=>s.jsxs("li",{children:[s.jsx(ba,{className:"item-text",text:t.text}),s.jsx(_,{parts:[{text:t.id,code:!0},t.kind.replace("-"," "),t.source&&`from ${t.source}`]})]},t.id))})}function IA({rules:e}){return e.length?s.jsxs("p",{className:"t-meta crit-uncovered",children:["No criterion covers knowledge"," ",e.map((t,n)=>s.jsxs("span",{children:[n>0&&", ",s.jsx("span",{className:"t-code","data-tip":t.title,children:t.id})]},t.id))," ","yet"]}):null}function RA({c:e}){const{criteria:t,proposal:n,uncovered:i}=e,o=e.confirmed?"confirmed by you":"not confirmed yet";return s.jsxs("div",{className:"criteria-section",children:[t.length>0?s.jsxs(s.Fragment,{children:[s.jsx(_,{parts:[`${t.length} ${t.length===1?"criterion":"criteria"}`,o]}),s.jsx(vg,{criteria:t})]}):s.jsx(_,{parts:["None yet"]}),n&&s.jsxs("div",{className:"crit-proposal",children:[s.jsx(_,{parts:[`${n.by} proposes new criteria`,"yours stay in force until you take these"]}),s.jsx(vg,{criteria:n.criteria})]}),s.jsx(IA,{rules:i})]})}function sa(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 Na(e,t){const[n,i]=w.useState({key:e,shown:sa(void 0,t)});let o=n;return n.key!==e?o={key:e,shown:sa(void 0,t)}:n.shown.latest!==t&&(o={key:e,shown:sa(n.shown,t)}),o!==n&&i(o),{hash:o.shown.hash,changed:o.shown.hash!==o.shown.latest,reviewAgain:()=>i({key:e,shown:sa(void 0,t)})}}const Aw=w.createContext(null);function As(){const e=w.useContext(Aw);if(!e)throw new Error("useKnowledge needs a KnowledgeContext provider");return e}function MA({snap:e,t}){const n=As();if(!n.entries.length||t.state==="closed")return null;const i=mv(n.entries,{trailKey:e.map.key,ticket:{type:t.type,title:t.title,body:t.body},paths:pv(`${t.body}
155
+ ${n.briefText}`)},4e3,c=>n.stale[c.id]??[]),o=i.length===1?"entry":"entries";return s.jsxs(Et,{label:"Knowledge",children:[s.jsx("span",{className:"t-body",children:i.length?`${i.length} ${o}`:"None picked"}),i.length>0&&s.jsx(an,{children:s.jsx("ul",{className:"item-list",children:i.map(c=>s.jsxs("li",{children:[s.jsx("button",{className:"item-text kn-open",onClick:()=>n.setOpen(!0),"data-tip":c.why.join(" · "),children:c.title}),s.jsx(_,{parts:[{text:c.id,code:!0},c.status==="assumption"&&"assumption",c.mayBeOutdated&&{text:"may be outdated",className:"warn"}]})]},c.id))})})]})}const LA={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 OA({e}){const t=As(),[n,i]=w.useState(!1),[o,c]=w.useState(e.title),[d,u]=w.useState(e.body);w.useEffect(()=>{i(!1),c(e.title),u(e.body)},[e.id,e.title,e.body]);const f=t.stale[e.id],m=Na(e.id,t.hashes[e.id]);return s.jsxs("div",{className:"kn-detail",children:[s.jsx(_,{parts:[{text:e.id,code:!0},e.kind.replace("-"," "),e.status]}),n?s.jsxs(s.Fragment,{children:[s.jsx(mt,{label:"Title",children:s.jsx("input",{value:o,onChange:g=>c(g.target.value)})}),s.jsx(mt,{label:"Body",children:s.jsx("textarea",{rows:8,value:d,onChange:g=>u(g.target.value)})})]}):s.jsxs(s.Fragment,{children:[s.jsx("h3",{className:"t-title",children:e.title}),s.jsx("p",{className:"kn-body",children:e.body})]}),s.jsx("p",{className:"dim",children:LA[e.status]}),e.flag&&s.jsxs("p",{className:"kn-warn",children:["Flagged by ",e.flag.by,": ",e.flag.reason]}),f&&e.status!=="outdated"&&s.jsxs("p",{className:"kn-warn",children:["May be outdated: ",f.join(", ")," changed since it was confirmed. Re-confirm or edit it."]}),s.jsxs("dl",{className:"facts",children:[e.scope.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Applies to"}),s.jsx("dd",{children:e.scope.join(", ")})]}),e.tags.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Tags"}),s.jsx("dd",{children:e.tags.join(", ")})]}),s.jsx("dt",{children:"From"}),s.jsx("dd",{children:[e.createdBy,...e.sources].join(" · ")}),e.anchors.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"About files"}),s.jsx("dd",{children:e.anchors.map(g=>g.path).join(", ")})]})]}),m.changed&&s.jsx(Uu,{what:"This entry",onReviewAgain:m.reviewAgain}),t.error&&s.jsx("p",{className:"vf-err",children:t.error}),s.jsx("div",{className:"actions",children:n?s.jsxs(s.Fragment,{children:[s.jsx(R,{variant:"ghost",onClick:()=>i(!1),children:"Cancel"}),s.jsx(R,{variant:"primary",disabled:!o.trim(),onClick:()=>void t.call(e.id,{kind:"edit",title:o,body:d}).then(g=>g&&i(!1)),children:"Save"})]}):s.jsxs(s.Fragment,{children:[(e.status!=="confirmed"||f)&&s.jsx(R,{variant:"primary",disabled:m.changed,onClick:()=>void t.call(e.id,{kind:"confirm"},m.hash),children:e.status==="confirmed"?"Re-confirm":"Confirm"}),e.status!=="assumption"&&e.status!=="outdated"&&s.jsx(R,{disabled:m.changed,onClick:()=>void t.call(e.id,{kind:"assumption"},m.hash),children:"Keep as assumption"}),e.flag&&s.jsx(R,{onClick:()=>void t.call(e.id,{kind:"resolve-flag"}),children:"Resolve flag"}),s.jsx(R,{variant:"ghost",onClick:()=>i(!0),children:"Edit"}),e.status!=="outdated"&&s.jsx(R,{variant:"ghost",onClick:()=>void t.call(e.id,{kind:"outdated"}),children:"Mark outdated"})]})})]})}const PA={suggested:"Suggested",confirmed:"Confirmed",assumption:"Assumption",outdated:"Outdated"};function DA(){const e=As(),[t,n]=w.useState("review"),[i,o]=w.useState(""),[c,d]=w.useState(""),[u,f]=w.useState();w.useEffect(()=>{if(!e.open)return;const x=$=>$.key==="Escape"&&e.setOpen(!1);return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[e]);const m=x=>x.status==="suggested"||!!x.flag||!!e.stale[x.id]&&x.status!=="outdated",g=(x,$)=>$==="all"?!0:$==="review"?m(x):x.status===$,k=w.useMemo(()=>{const x=c.trim().toLowerCase();return e.entries.filter($=>g($,t)&&(!i||$.kind===i)&&(!x||`${$.id} ${$.title} ${$.body} ${$.tags.join(" ")}`.toLowerCase().includes(x)))},[e.entries,e.stale,t,i,c]);if(!e.open)return null;const y=k.find(x=>x.id===u)??k[0],b=x=>e.entries.filter($=>g($,x)).length,S=[["review","Needs you"],["confirmed","Confirmed"],["assumption","Assumptions"],["outdated","Outdated"],["all","All"]];return s.jsx("div",{className:"scrim",onClick:()=>e.setOpen(!1),children:s.jsxs(Be,{as:"div",className:"dialog knowledge-view",onClick:x=>x.stopPropagation(),children:[s.jsxs("header",{children:[s.jsx("h2",{className:"t-heading caps",children:"Field guide"}),s.jsx(wi,{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>"})]}),s.jsxs("div",{className:"kn-filters",children:[S.map(([x,$])=>s.jsxs("button",{className:`chip ${t===x?"on":""}`,onClick:()=>n(x),children:[$," ",s.jsx("span",{className:"n",children:b(x)})]},x)),s.jsx(it,{compact:!0,"aria-label":"Kind",value:i,onChange:o,options:[{value:"",label:"Any kind"},...nN.map(x=>({value:x,label:x.replace("-"," ")}))]}),s.jsx("input",{className:"kn-search",placeholder:"Search",value:c,onChange:x=>d(x.target.value)})]}),s.jsxs("div",{className:"kn-body-grid",children:[s.jsx("ul",{className:"kn-list",children:k.length?k.map(x=>s.jsx(fe,{as:"li",className:`kn-row st-${x.status}`,edge:m(x)?"attention":"neutral",selected:x===y,onOpen:()=>f(x.id),title:x.title,titleText:x.title,context:s.jsx(_,{parts:[{text:x.id,code:!0},x.kind.replace("-"," "),m(x)&&x.status!=="suggested"?"Needs a check":PA[x.status]]})},x.id)):s.jsx(Te,{children:t==="review"?"Nothing needs you":"No entries"})}),y?s.jsx(OA,{e:y}):s.jsx(Te,{children:"Pick an entry"})]})]})})}function Iw({draft:e,label:t="Save as knowledge"}){const n=As(),[i,o]=w.useState();return i?s.jsxs(R,{size:"sm",variant:"ghost",onClick:()=>n.setOpen(!0),"data-tip":"Open it in the field guide to confirm it",children:["Saved as ",i]}):s.jsx(R,{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(c=>c&&o(c.id)),children:t})}const Rw=`${re()}/knowledge`;async function wg(e,t){const n=await fetch(`${Rw}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),i=await n.json().catch(()=>({}));if(!n.ok)throw new Error(i.error??`HTTP ${n.status}`);return i}async function _A(){const e=await fetch(Rw);return e.ok?await e.json():null}function BA(e){const[t,n]=w.useState([]),[i,o]=w.useState({}),[c,d]=w.useState({}),[u,f]=w.useState(!1),[m,g]=w.useState(),{reload:k}=Pe({load:_A,show:b=>{b&&(n(b.entries),o(b.stale),d(b.hashes??{}))},changed:b=>b.startsWith("knowledge/")}),y=w.useMemo(()=>t.filter(b=>b.status==="suggested"||b.flag||i[b.id]&&b.status!=="outdated").length,[t,i]);return{entries:t,stale:i,briefText:e,attention:y,open:u,setOpen:f,error:m,hashes:c,call:(b,S,x)=>wg("/call",{id:b,call:S,hash:x??c[b]}).then(()=>(g(void 0),k(),!0),$=>(g($.message),k(),!1)),propose:b=>wg("/propose",b).then(S=>(k(),S.entry),S=>(g(S.message),void 0))}}const Mw=`${re()}/criteria`;async function FA(e){if(!e)return[];const t=await fetch(`${Mw}?mapId=${encodeURIComponent(e)}`);return t.ok?(await t.json()).tickets:[]}function zA(e){const[t,n]=w.useState([]),{reload:i}=Pe({view:e,load:()=>FA(e),show:n,failed:()=>n([]),changed:c=>c.startsWith("criteria/")});return{tickets:t,confirm:c=>fetch(`${Mw}/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,...c})}).catch(()=>{}).then(async d=>{const u=await ec(d);return i(),u})}}const Lw=`${re()}/criteria-proposals`;async function UA(e){if(!e)return[];const t=await fetch(`${Lw}?mapId=${encodeURIComponent(e)}`);return t.ok?(await t.json()).proposals:[]}function WA(e){const[t,n]=w.useState([]),{reload:i}=Pe({view:e,load:()=>UA(e),show:n,failed:()=>n([]),events:{"criteria-proposals":c=>(c==null?void 0:c.mapId)===e}});return{proposals:t,decide:(c,d)=>fetch(`${Lw}/${c}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,...d})}).catch(()=>{}).then(async u=>{const f=await ec(u);return i(),f})}}function HA(e,t){const{tickets:n,confirm:i}=zA(e.map.id),o=WA(e.map.id),c=o.proposals.find(S=>S.ticketId===t.id),d=As(),u=n.find(S=>S.ticketId===t.id),f=(u==null?void 0:u.criteria)??[],m=Na(t.id,u==null?void 0:u.hash),g=Na(c&&`${c.ticketId}@${c.at}`,c==null?void 0:c.hash),y=mv(d.entries,{trailKey:e.map.key,ticket:{type:t.type,title:t.title,body:t.body},paths:pv(`${t.body}
156
+ ${d.briefText}`)}).filter(S=>S.kind==="business-rule").filter(S=>eN(f,[S.id]).length),b=S=>o.decide(S,{title:e.map.title,ticketId:t.id,hash:g.hash});return{criteria:f,confirmed:!!(u!=null&&u.confirmed),proposal:c,uncovered:y,changed:m.changed?m:void 0,proposalChanged:c&&g.changed?g:void 0,setConfirmed:S=>i({title:e.map.title,ticketId:t.id,ticketKey:t.key,confirmed:S,hash:m.hash}),take:()=>b("accept"),keep:()=>b("dismiss")}}function Ow({v:e}){const t=e.criteria,n=hv.includes(e.t.type)&&e.t.state==="open";return!t.criteria.length&&!t.proposal&&!n?null:s.jsx(Ot,{label:"Acceptance criteria",className:"ticket-criteria",children:s.jsx(RA,{c:t})})}const Pw=/^\*\*([^*]+)\*\*\s*/;function KA(e){var n;const t=(n=e.match(Pw))==null?void 0:n[1];return t?t.replace(/:$/,"").toLowerCase():"comment"}function GA(e){const t=e.decisions.map(i=>({id:i.id,at:i.decidedAt,who:zu(i,e.people),kind:i.supersededBy?`decision, superseded by ${i.supersededBy}`:"decision",text:i.summary||i.answer,decision:i.id})),n=e.comments.filter(i=>!(t.length&&i.body.startsWith("**Resolution**"))).map(i=>({id:i.id,at:i.createdAt,who:mi(i.author,e.people),kind:KA(i.body),text:i.body.replace(Pw,"")}));return[...t,...n].sort((i,o)=>o.at-i.at)}function VA(e){const t=e.entry,n=t.decision&&e.onOpenDecision;return s.jsxs("li",{className:"history-item",children:[s.jsx(_,{parts:[{text:t.who,strong:!0},t.kind,os(t.at)],children:n&&s.jsxs("button",{type:"button",className:"d-more",onClick:()=>{var i;return(i=e.onOpenDecision)==null?void 0:i.call(e,t.decision)},children:[t.decision," ›"]})}),s.jsx(Vu,{text:t.text,markdown:!0})]})}function qA(e){const t=Lr(),[n,i]=w.useState(!1),o=GA({comments:e.t.comments,decisions:e.decisions,people:t});if(!o.length)return null;const c=n?o:o.slice(0,1);return s.jsxs(Ot,{label:"History",className:"ticket-history",children:[s.jsx("ul",{className:"history",children:c.map(d=>s.jsx(VA,{entry:d,onOpenDecision:e.onOpenDecision},d.id))}),o.length>1&&s.jsx("button",{type:"button",className:"d-more","aria-expanded":n,onClick:()=>i(!n),children:n?"Show the latest only":`Show all ${o.length}`})]})}function Dw(e){return s.jsx("ul",{className:"checklist-answers",children:e.answers.map(t=>s.jsxs("li",{className:t.done?"done":"not-done",children:[s.jsx("span",{className:"mark","aria-label":t.done?"Done":"Not done",children:t.done?"✓":"–"}),s.jsx("span",{className:"t-body",children:t.item}),t.note&&s.jsx("span",{className:"t-meta note",children:t.note})]},t.item))})}const _w=`${J.apiPrefix}`;async function Bw(e){const t=await e.json().catch(()=>({}));if(!e.ok)throw new Error(t.error??`Request failed (${e.status})`);return t}const $a=async e=>Bw(await fetch(`${_w}${e}`)),Fw=async(e,t)=>Bw(await fetch(`${_w}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}));function QA(e,t){const[n,i]=w.useState(),o=`/guides/checklist?mapId=${encodeURIComponent(e)}&ticketId=${encodeURIComponent(t)}`;return Pe({view:o,load:()=>$a(o),show:c=>i(c.checklist),failed:()=>i(null),changed:c=>c.endsWith("checklist.json")}),n}function YA(e){const t=QA(e.mapId,e.ticketId);if(!t)return null;const n=t.guides.map(i=>`${i.guide.id} ${i.answers.filter(o=>o.done).length}/${i.answers.length}`);return s.jsxs(Et,{label:"Checklists",children:[s.jsx("span",{className:"t-body",children:n.join(" · ")}),s.jsx(an,{children:t.guides.map(i=>s.jsxs("div",{className:"checklist-panel",children:[s.jsx(_,{parts:[`${i.guide.id} ${i.guide.version}`,t.by,os(t.at)]}),s.jsx(Dw,{answers:i.answers})]},i.guide.id))})]})}let zw;const da=new Set;let es;function cu(e){zw=e;for(const t of da)t()}function Uw(e){es==null||es.pushed(),cu(e)}const JA=()=>zw;function XA(e){return da.add(e),es??(es=nw({load:()=>$a("/guides"),show:cu,failed:()=>cu(null),changed:t=>t.includes("guides")})),()=>{da.delete(e),!da.size&&(es==null||es.stop(),es=void 0)}}function kn(){const e=w.useSyncExternalStore(XA,JA),t=w.useCallback(async(i,o)=>{try{Uw(await Fw(i,o));return}catch(c){return c.message}},[]),n=w.useCallback(i=>i?e==null?void 0:e.guides.find(o=>o.id===i):void 0,[e]);return{view:e,act:t,find:n}}const ZA={active:"Active",unapproved:"New, waiting for your approval",tampered:"Changed since you approved it",invalid:"Can't be used"},eI={active:"Approved",unapproved:"Not approved yet",tampered:"Changed since you approved it",invalid:"Can't be used"},lu=e=>{var t;return e.origin==="local"&&(!((t=e.lock)!=null&&t.source)||e.lock.source==="local")};function tI(e){return lu(e)?{text:eI[e.status],strong:e.status==="active"}:e.status==="active"?void 0:ZA[e.status]}function Ca(e){try{return new URL(e).host}catch{return e}}function nI(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 ${Ca(t.registry)}`}const sh=e=>e.map(t=>/\s/.test(t)?JSON.stringify(t):t).join(" "),yg=3;function sI(e,t){return e.length<=Math.max(t,yg+1)?e:`${e.slice(0,Math.max(t-1,yg)).trimEnd()}…`}function Ww(e){return e===s1?"Verified":`Verified by ${Ca(e)}'s catalog`}function Hw(e,t){return e.builtin?{text:"Built in",strong:!0}:e.verified?{text:Ww(t),strong:!0}:"Not reviewed"}function iI(e){var c,d;const t=(c=e.lock)==null?void 0:c.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,i=(d=e.lock)==null?void 0:d.source;return{text:i&&i!=="local"?Ww(i.registry):"Verified",strong:!0,tip:n}}var Kw=$k();function Gw(e){return U1(e.spec)?s.jsxs("span",{className:"guide-unknown",children:[s.jsx("span",{className:"t-body",children:"Unknown program: Teamtrail can't tell what this runs. Approve it only if you know what it does."}),s.jsxs(R,{size:"sm",disabled:e.busy,onClick:()=>e.onApprove(e.name,!0),children:["I know what it runs: approve check ",e.name]})]}):s.jsxs(R,{size:"sm",disabled:e.busy,onClick:()=>e.onApprove(e.name,!1),children:["Approve check ",e.name]})}function rI(e){var y;const{preview:t}=e,{act:n,find:i}=kn(),[o,c]=w.useState({kind:"ready"}),[d,u]=w.useState(),f=t.entry.id,m=async()=>{u(void 0),c({kind:"adding"});try{c({kind:"added",pending:(await e.add(f,t.entry.sha256)).pendingChecks})}catch(b){u(b.message),c({kind:"ready"})}};if(t.entry.builtin)return s.jsxs("span",{className:"t-meta",children:["Built into ",J.name,": already available to every trail, nothing to add."]});if(o.kind!=="added"){const b=e.installed===t.entry.version,S=e.installed?"Update guide":"Add guide";return s.jsxs("div",{className:"add-guide",children:[!t.ok&&s.jsx("span",{className:"t-meta",children:"The lint found errors, so this guide can't be added."}),s.jsx(R,{variant:"primary",disabled:!t.ok||b||o.kind==="adding",onClick:()=>void m(),children:b?"Added":S}),d&&s.jsx("span",{className:"vf-err",children:d})]})}const g=((y=i(f))==null?void 0:y.pendingChecks)??o.pending,k=async(b,S)=>u(await n("/guides/checks/approve",{id:f,name:b,acknowledged:S}));return s.jsxs("div",{className:"add-guide",children:[s.jsx("p",{className:"t-body",children:g.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}.`}),g.map(b=>{var S,x,$;return s.jsxs("span",{className:"guide-check",children:[s.jsxs("code",{className:"t-code",children:[b,": ",sh(((x=(S=t.guide)==null?void 0:S.proposedChecks[b])==null?void 0:x.run)??[])]}),s.jsx(Gw,{name:b,spec:(($=t.guide)==null?void 0:$.proposedChecks[b])??{run:[]},onApprove:(N,O)=>void k(N,O)})]},b)}),d&&s.jsx("span",{className:"vf-err",children:d})]})}function oI(e){const t=s.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?s.jsxs(s.Fragment,{children:[s.jsx("ul",{className:"vf-findings guide-findings",children:e.findings.map((n,i)=>s.jsxs("li",{className:`sev-${n.level}`,children:[s.jsxs("code",{className:"t-code",children:["line ",n.line]})," ",n.message," ",s.jsxs("span",{className:"t-meta",children:["(",n.rule,")"]})]},i))}),t]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"t-meta",children:"The lint found none of the problems it looks for."}),t]})}function Vw(e){var i,o;const{p:t}=e,n=Object.entries(((i=t.guide)==null?void 0:i.proposedChecks)??{});return s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"t-label",children:"Lint"}),s.jsx(oI,{findings:t.findings}),t.guide&&t.guide.checklist.length>0&&s.jsx("span",{className:"t-label",children:"Checklist"}),t.guide&&s.jsx("ul",{className:"catalog-checklist t-body",children:t.guide.checklist.map(c=>s.jsx("li",{children:c},c))}),n.length>0&&s.jsx("span",{className:"t-label",children:"Commands it proposes"}),n.map(([c,d])=>s.jsxs("code",{className:"t-code guide-check",children:[c,": ",sh(d.run),d.cwd&&` (in ${d.cwd})`]},c)),s.jsx("span",{className:"t-label",children:"Instructions"}),s.jsx("pre",{className:"guide-preview",children:((o=t.guide)==null?void 0:o.instructions)??t.text})]})}function aI(e){const t=At(e.repo);if(!t)return null;const n=encodeURIComponent(`Report: ${e.id} ${e.version}`),i=`${t.replace(/\/+$/,"")}/issues/new?template=report-guide.yml&title=${n}`;return s.jsx("a",{className:"report-link t-meta",href:i,target:"_blank",rel:"noreferrer",children:"Report this guide"})}function cI(e){const t=e.entry,[n,i]=w.useState(),[o,c]=w.useState();return w.useEffect(()=>{e.preview(t.id).then(i,d=>c(d.message))},[t.id]),s.jsxs("div",{className:"catalog-entry",children:[s.jsx(R,{size:"sm",variant:"ghost",onClick:e.onBack,children:"← All guides"}),s.jsx("h3",{className:"t-title",children:t.name??t.id}),s.jsx(_,{parts:[{text:t.id,code:!0},t.version,`by ${t.author}`,Hw(t,e.catalogUrl),t.reviewedBy.length>0&&`reviewed by ${t.reviewedBy.join(", ")}`]}),s.jsx("p",{className:"t-body",children:t.summary}),t.history.length>0&&s.jsx("ul",{className:"catalog-history",children:t.history.map(d=>s.jsxs("li",{className:"t-meta",children:[d.version," · ",s.jsx("code",{className:"t-code",children:d.commit.slice(0,8)})," · ",d.at.slice(0,10)]},`${d.version}-${d.commit}`))}),o&&s.jsx("span",{className:"vf-err",children:o}),n&&s.jsx(Vw,{p:n}),n&&s.jsx(aI,{repo:n.repo,id:t.id,version:t.version}),n&&s.jsx(rI,{preview:n,installed:e.installed,add:e.add})]})}function lI(e){const t=e.entry;return s.jsx("li",{className:"catalog-row","data-guide-id":t.id,children:s.jsx(fe,{title:t.name??t.id,context:s.jsx(_,{parts:[{text:t.id,code:!0},t.version,t.author,Hw(t,e.catalogUrl),t.reported&&"Reported"]}),detail:t.summary,trailing:e.installed&&`installed ${e.installed}`,onOpen:e.onOpen})})}const xg=e=>e?`registry=${encodeURIComponent(e)}`:"";function dI(e){const[t,n]=w.useState(),[i,o]=w.useState();w.useEffect(()=>{let u=!0;return n(void 0),o(void 0),$a(`/guides/catalog?${xg(e)}`).then(f=>u&&n(f),f=>u&&o(f.message)),()=>{u=!1}},[e]);const c=w.useCallback(u=>$a(`/guides/catalog/preview?${xg(e)}&id=${encodeURIComponent(u)}`),[e]),d=w.useCallback(async(u,f)=>{const m=await Fw("/guides/catalog/add",{registry:e,id:u,sha256:f});return Uw(m),m.installed},[e]);return{index:t,error:i,preview:c,add:d}}function uI(e){var x,$;const[t,n]=w.useState(((x=e.registries[0])==null?void 0:x.name)??""),i=dI(t||void 0),{find:o}=kn(),[c,d]=w.useState(""),[u,f]=w.useState(!0),[m,g]=w.useState(),k=i.index?W1({guides:i.index.guides},{query:c,verifiedOnly:u}):[],y=($=i.index)==null?void 0:$.guides.find(N=>N.id===m),b=N=>{var O,D,F;return((O=o(N))==null?void 0:O.origin)==="local"?(F=(D=o(N))==null?void 0:D.guide)==null?void 0:F.version:void 0},S=e.registries.find(N=>N.name===t);return Kw.createPortal(s.jsx("div",{className:"scrim catalog-scrim",onClick:N=>{N.stopPropagation(),e.onClose()},children:s.jsxs(Be,{as:"div",className:"dialog catalog-dialog",onClick:N=>N.stopPropagation(),children:[s.jsxs("header",{children:[s.jsx("h3",{className:"t-title",children:"Guide catalog"}),e.registries.length>1&&s.jsx(it,{compact:!0,"aria-label":"Catalog",value:t,options:e.registries.map(N=>({value:N.name,label:`${N.name} · ${Ca(N.url)}`,hint:N.url})),onChange:n}),s.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})]}),S&&e.registries.length===1&&s.jsx(_,{parts:[`Catalog ${S.name}`,{text:Ca(S.url),code:!0}]}),y?s.jsx(cI,{entry:y,catalogUrl:(S==null?void 0:S.url)??"",installed:b(y.id),preview:i.preview,add:i.add,onBack:()=>g(void 0)}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"catalog-filters",children:[s.jsx("input",{className:"catalog-search",placeholder:"Search guides","aria-label":"Search guides",value:c,onChange:N=>d(N.target.value)}),s.jsx(R,{size:"sm",on:u,"aria-pressed":u,onClick:()=>f(N=>!N),children:"Verified only"})]}),i.error&&s.jsx("span",{className:"vf-err",children:i.error}),!i.index&&!i.error&&s.jsx(Te,{children:"Reading the catalog…"}),i.index&&!k.length&&s.jsx(Te,{children:"No guides match."}),s.jsx("ul",{className:"catalog-list",children:k.map(N=>s.jsx(lI,{entry:N,catalogUrl:(S==null?void 0:S.url)??"",installed:b(N.id),onOpen:()=>g(N.id)},N.id))})]})]})}),document.body)}async function hI(e,t){const n=await fetch(`${re()}/verification/screen`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({checks:e}),signal:t}).catch(()=>{});return n!=null&&n.ok?(await n.json().catch(()=>({}))).findings:void 0}const fI=400;function qw(e){const[t,n]=w.useState([]),i=JSON.stringify(e);return w.useEffect(()=>{const o=new AbortController,c=setTimeout(()=>{const d=JSON.parse(i);hI(d,o.signal).then((u=[])=>{const f=m=>{var g;return((g=d[Number(m)])==null?void 0:g.run.join(" "))??""};o.signal.aborted||n(u.map(m=>({...m,command:f(m.check)})))})},fI);return()=>{clearTimeout(c),o.abort()}},[i]),t}function mI({text:e}){const t=e.split("`");return s.jsx(s.Fragment,{children:t.map((n,i)=>i%2?s.jsx("code",{className:"t-code",children:n},i):n)})}const pI={"wont-run":"Won't run",unsure:"May not run"},Nd=s.jsx("span",{className:"sep",children:" · "});function gI(e){const{finding:t,onFix:n}=e,i=n&&t.fix;return s.jsxs("li",{className:`cs-finding cs-finding-${t.severity} t-meta`,children:[s.jsx("span",{className:"cs-dot","aria-hidden":"true"}),s.jsxs("span",{children:[s.jsx("span",{className:"cs-severity",children:pI[t.severity]}),e.named&&s.jsxs(s.Fragment,{children:[Nd,s.jsx("code",{className:"t-code",children:t.check})]}),Nd,s.jsx(mI,{text:i?i.problem:t.text}),i&&s.jsxs(s.Fragment,{children:[Nd,s.jsxs("button",{type:"button",className:"d-more",onClick:()=>n(i.run),children:["Use ",s.jsx("code",{className:"t-code",children:i.run.join(" ")})]})]})]})]})}function ic(e){return e.findings.length?s.jsxs("div",{className:"cs-findings",children:[s.jsx("ul",{children:e.findings.map(t=>s.jsx(gI,{finding:t,named:e.named,onFix:e.onFix},`${t.check} ${t.text}`))}),e.action]}):null}function kI({spec:e}){const t=qw([{name:"0",run:e.run,...e.cwd?{cwd:e.cwd}:{}}]);return s.jsx(ic,{findings:t})}function vI(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 i=e.r.status==="active";return s.jsxs("div",{className:"guide-checks",children:[t.requiresChecks.length>0&&s.jsxs("span",{className:"t-meta",children:["Adds checks ",s.jsx("code",{className:"t-code",children:t.requiresChecks.join(", ")})," to its tickets"]}),n.map(([o,c])=>{const d=e.r.pendingChecks.includes(o);return s.jsxs("span",{className:"guide-check",children:[s.jsxs("code",{className:"t-code",children:[o,": ",sh(c.run)]}),d&&i&&s.jsx(kI,{spec:c}),d&&i&&s.jsx(Gw,{name:o,spec:c,busy:e.busy,onApprove:e.onApprove}),d&&!i&&s.jsx("span",{className:"t-meta",children:"approve the guide first"}),!d&&s.jsx("span",{className:"t-meta",children:"approved"})]},o)})]})}function wI(e){const{r:t}=e;if(!t.guide||!t.sha256)return null;const n=t.sha256;return s.jsxs("div",{className:"guide-review",children:[s.jsx(Vw,{p:{findings:t.findings,guide:t.guide}}),s.jsx(R,{size:"sm","aria-label":`Approve guide ${t.id}`,disabled:e.busy,onClick:()=>e.onApprove(n),children:"Approve"})]})}const yI="A file in guides/ replaces this built-in once you approve it; until then the built-in is used";function xI(e){var t,n;return e.override?yI:e.status==="unapproved"?(t=e.guide)==null?void 0:t.summary:e.reason??((n=e.guide)==null?void 0:n.summary)}function Qw(e){const{r:t}=e,n=t.id,i=t.override??t,o=(i.status==="unapproved"||i.status==="tampered")&&!!i.guide,c=t.status!=="active"||t.pendingChecks.length>0||o,d=t.guide?`${t.guide.name} ${t.guide.version}`:n;return s.jsx("li",{className:"guide-row","data-guide-id":n,children:s.jsx(fe,{edge:c?"attention":"neutral",title:d,context:s.jsx(_,{parts:[{text:n,code:!0},nI(t),iI(t),tI(t),t.guide&&jI(t.guide.checklist.length)]}),detail:xI(t),actions:t.origin==="local"&&s.jsxs(R,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>e.onAct("/guides/remove",{id:n}),children:["Remove guide ",n]}),below:s.jsxs(s.Fragment,{children:[o&&s.jsx(wI,{r:i,busy:e.busy,onApprove:u=>e.onAct("/guides/approve",{id:n,sha256:u})}),s.jsx(vI,{r:t,busy:e.busy,onApprove:(u,f)=>e.onAct("/guides/checks/approve",{id:n,name:u,acknowledged:f})})]})})})}const jI=e=>e===1?"1 checklist item":`${e} checklist items`;function bI(e){return s.jsxs(Ae,{title:"Write your own",children:[s.jsxs("p",{className:"vf-intro",children:["Write a guide for your team in your repo with ",s.jsxs("code",{className:"t-code",children:[J.slug," guides new <id>"]}),". It starts from a template in ",s.jsxs("code",{className:"t-code",children:[J.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?s.jsx("ul",{className:"guides-list own-guides",children:e.guides.map(t=>s.jsx(Qw,{r:t,busy:e.busy,onAct:e.onAct},t.id))}):s.jsx(Te,{children:"No guides of your own yet."}),e.error&&s.jsx("span",{className:"vf-err",children:e.error}),s.jsxs("p",{className:"t-meta guides-share",children:["Useful beyond your team? Check it with ",s.jsxs("code",{className:"t-code",children:[J.slug," guides lint"]})," and"," ",s.jsx("a",{href:i1,target:"_blank",rel:"noreferrer",children:"share it in the public catalog"}),"."]})]})}function SI(e){const{view:t,act:n}=kn(),[i,o]=w.useState(),[c,d]=w.useState(!1),[u,f]=w.useState(!1),m=w.useRef(null);if(w.useEffect(()=>{var y;e.focus&&t&&((y=m.current)==null||y.scrollIntoView({block:"start"}))},[e.focus,!!t]),!t)return null;const g=y=>(b,S)=>{d(!0),n(b,S).then(x=>{o(x?{own:y,message:x}:void 0),d(!1)})},k=y=>i&&i.own===y?i.message:void 0;return s.jsxs("div",{className:"guides-section",ref:m,children:[s.jsxs(Ae,{title:"Guides",children:[s.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."}),s.jsx("ul",{className:"guides-list",children:t.guides.filter(y=>!lu(y)).map(y=>s.jsx(Qw,{r:y,busy:c,onAct:g(!1)},y.id))}),s.jsxs("div",{className:"guides-foot",children:[s.jsx(R,{size:"sm",onClick:()=>f(!0),children:"Browse guides"}),s.jsx(_,{parts:[{text:`${J.dataDir}/guides/`,code:!0},{text:"guides.lock.json",code:!0}]})]}),t.configErrors.length>0&&s.jsx("ul",{className:"vf-errors",children:t.configErrors.map(y=>s.jsx("li",{children:y},y))}),k(!1)&&s.jsx("span",{className:"vf-err",children:k(!1)})]}),s.jsx(bI,{guides:t.guides.filter(lu),busy:c,onAct:g(!0),error:k(!0)}),u&&s.jsx(uI,{registries:t.registries,onClose:()=>f(!1)})]})}function NI(e){const{view:t,find:n}=kn();if(!t)return null;const i=n(e.id);if((i==null?void 0:i.status)==="active")return null;const o=i?i.reason??i.status:"it is not installed";return s.jsxs("p",{className:"guide-warning t-meta",children:["Guide ",e.id," can't be used: ",o,". Claims get no guide instructions until you approve it in Settings → Guides."]})}const $I={type:"by type",ticket:"added",removed:"removed"},CI=(e,t)=>e.removed?{change:{add:e.id},label:`Put back ${t}`,mark:"+"}:{change:{remove:e.id},label:`Remove ${t}`,mark:"×"};function Yw(e){var y,b;const{view:t,find:n}=kn(),{row:i}=e,o=n(i.id),c=!!t&&(o==null?void 0:o.status)!=="active",d=((y=o==null?void 0:o.guide)==null?void 0:y.name)??i.id,u=i.removed?"removed":i.via,f=c?`${d}: ${(o==null?void 0:o.reason)??"not installed"}`:((b=o==null?void 0:o.guide)==null?void 0:b.summary)??d,{change:m,label:g,mark:k}=CI(i,d);return s.jsxs("span",{className:ue("ticket-guide-chip",i.removed&&"removed",c&&"off"),"data-guide-id":i.id,"data-via":u,title:f,children:[s.jsx("span",{className:"name",children:d}),s.jsx("span",{className:"how t-meta",children:$I[u]}),e.editable&&s.jsx("button",{type:"button",className:"chip-act","aria-label":g,title:g,onClick:()=>e.onChange(m),children:k})]})}function Jw(e,t){const n=qb(e,t).map(c=>({...c,removed:!1})),o=(Cu(e).byType[t.type]??[]).filter(c=>{var d;return(d=t.guidesRemoved)==null?void 0:d.includes(c)});return[...n,...o.map(c=>({id:c,via:"type",removed:!0}))]}function TI(e){const{view:t}=kn();if(!t)return null;const n=Jw(e.map,e.ticket).filter(i=>!i.removed);return n.length?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"ticket-guides plain",children:n.map(i=>s.jsx(Yw,{row:i,editable:!1,onChange:()=>{}},i.id))}),n.map(i=>s.jsx(NI,{id:i.id},i.id))]}):s.jsx("span",{className:"t-meta",children:"None"})}const jg="";function EI(e){const{view:t}=kn();if(!t)return null;const n=t.guides.filter(o=>o.status==="active"&&o.guide&&!e.taken.includes(o.id));if(!n.length)return null;const i=[{value:jg,label:"Add a guide"},...n.map(o=>({value:o.id,label:o.guide.name,hint:o.guide.summary}))];return s.jsx(it,{compact:!0,className:"add-ticket-guide","aria-label":"Add a guide to this ticket",value:jg,options:i,onChange:o=>o&&e.onAdd(o)})}function AI(e){const{view:t,act:n}=kn(),[i,o]=w.useState();if(!t)return null;const c=e.ticket,d=Jw(e.map,c),u=d.filter(m=>!m.removed),f=m=>{o(void 0),n("/guides/ticket",{mapId:e.map.id,ticketId:c.id,...m}).then(o)};return s.jsxs("div",{className:"ticket-guides",children:[s.jsxs("span",{className:"guide-head",children:[d.map(m=>s.jsx(Yw,{row:m,editable:!0,onChange:f},m.id)),s.jsx(EI,{taken:u.map(m=>m.id),onAdd:m=>f({add:m})})]}),i&&s.jsx("span",{className:"vf-err",children:i})]})}function II(e){const{type:t,ids:n,usable:i}=e,o=n.filter(m=>!i.some(g=>g.id===m)),c=Kk[t]??[],d=c.length!==n.length||c.some(m=>!n.includes(m)),u=m=>{var g,k;return((k=(g=i.find(y=>y.id===m))==null?void 0:g.guide)==null?void 0:k.name)??m},f=d?`default ${c.map(u).join(", ")||"none"}`:void 0;return s.jsxs("div",{className:"type-guides-row","data-type":t,children:[s.jsx("span",{className:"type-name",children:ns[t]}),s.jsxs("span",{className:"type-toggles",children:[i.map(m=>{const g=n.includes(m.id);return s.jsx(R,{size:"sm",on:g,"aria-pressed":g,title:m.guide.summary,"data-guide-id":m.id,onClick:()=>e.onToggle(m.id),children:m.guide.name},m.id)}),o.map(m=>s.jsx(R,{size:"sm",on:!0,"aria-pressed":!0,className:"off",title:`${m} can't be used now`,onClick:()=>e.onToggle(m),children:m},m))]}),s.jsx(_,{className:"type-hint",parts:[f]})]})}const RI={defaults:"Defaults",team:"Defaults, kept within the trail's earlier team"};function MI(e){var g;const{view:t,act:n}=kn(),[i,o]=w.useState();if(!t)return null;const{byType:c,source:d}=Cu(e.map),u=t.guides.filter(k=>k.status==="active"&&k.guide),f=k=>{o(void 0),n("/guides/trail",{mapId:e.map.id,byType:k}).then(o)},m=(k,y)=>{const b=c[k]??[],S=b.includes(y)?b.filter(x=>x!==y):[...b,y];f({...c,[k]:S})};return s.jsxs(Ae,{title:"Guides by type",children:[s.jsx("div",{className:"type-guides-head",children:d==="trail"?s.jsx(R,{size:"sm",variant:"ghost",onClick:()=>f(null),children:"Back to defaults"}):s.jsx(_,{parts:[RI[d],d==="team"&&((g=e.map.guides)==null?void 0:g.join(", "))]})}),s.jsx("div",{className:"type-guides",children:rs.map(k=>s.jsx(II,{type:k,ids:c[k]??[],usable:u,onToggle:y=>m(k,y)},k))}),i&&s.jsx("span",{className:"vf-err",children:i})]})}function LI(e){var f;const{view:t,find:n}=kn();if(!e)return;const i=n(e),o=t!=null&&(i==null?void 0:i.status)!=="active",c=((f=i==null?void 0:i.guide)==null?void 0:f.name)??e,d=i!=null&&i.guide?`${c} ${i.guide.version}`:c,u=o?`Guide ${d}: ${(i==null?void 0:i.reason)??"not installed"}`:`Guide: ${d}`;return{id:e,name:c,tip:u,off:o}}function OI({check:e}){const t=bw(e),[n,i]=w.useState(),[o,c]=w.useState(),d=PI(e);return s.jsxs("details",{className:`vf-row ${t?"ok":"bad"}`,open:!t,children:[s.jsxs("summary",{children:[s.jsx("span",{className:"vf-mark",children:t?"✓":"✕"}),s.jsx("span",{className:"t-code vf-name",children:e.name}),s.jsx("span",{className:"t-meta",children:d}),s.jsx("span",{className:"t-meta vf-dur",children:qt(e.durationMs)})]}),s.jsx("code",{className:"vf-argv",children:e.argv.join(" ")}),e.error&&s.jsx("p",{className:"vf-note",children:e.error}),s.jsx("pre",{className:"vf-tail",children:n??(e.tail||"No output.")}),s.jsxs("div",{className:"vf-log-line",children:[n===void 0&&s.jsx("button",{className:"link",onClick:()=>Ss.log(e.log).then(u=>i(u.clipped?`[earlier output not shown]
157
+ ${u.text}`:u.text),u=>c(u.message)),children:"Full log ›"}),e.truncated&&s.jsx("span",{className:"dim",children:"log capped at 1 MB"}),o&&s.jsx("span",{className:"vf-err",children:o})]})]})}function PI(e){return e.error?"did not start":e.timedOut?"timed out":`exit ${e.exitCode??e.signal??"?"}`}const bg=e=>(e==null?void 0:e.slice(0,8))??"none",Sg=e=>e===null?"·":String(e);function DI({attempt:e}){var d;const t=e.git;if(!t)return null;const{files:n,add:i,del:o}=t.stats,c=new Set(((d=t.flags.find(u=>u.kind==="outside-scope"))==null?void 0:d.files)??[]);return s.jsxs("div",{className:"vf-git",children:[s.jsx(_,{parts:[t.tree?{text:`${t.base?`${bg(t.base.head)} → `:""}${bg(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"} +${i} −${o}`]}),t.flags.filter(u=>u.kind!=="no-git"&&u.kind!=="check-guard").map(u=>{var f;return s.jsxs("p",{className:`vf-flag lv-${u.level}`,title:(f=u.files)==null?void 0:f.join(`
158
+ `),children:[s.jsx("span",{className:"t-code",children:u.kind})," ",u.message]},u.kind)}),t.changed.length>0&&s.jsxs("details",{className:"vf-files",children:[s.jsx("summary",{className:"t-label",children:"Changed files"}),s.jsx("ul",{children:t.changed.map(u=>s.jsxs("li",{children:[s.jsx("code",{children:u.path}),s.jsxs("span",{className:"dim",children:[u.untracked?"new":`+${Sg(u.add)} −${Sg(u.del)}`,u.dirtyAtClaim?" · dirty at claim":"",c.has(u.path)?" · outside the declared files":""]})]},u.path))})]})]})}function _I({attempt:e}){const t=e.guard;if(!(t!=null&&t.findings.length))return null;const n=t.mode==="enforce"&&e.result==="pass";return s.jsxs("div",{className:`vf-guard${n?" held":""}`,children:[s.jsx("p",{className:"vf-guard-head",children:n?"Checks passed, but the work changed what they run":"The work changed what its checks run"}),s.jsx("ul",{children:t.findings.map(i=>s.jsxs("li",{children:[i.text,i.check&&s.jsxs("span",{className:"dim",children:[" · ",i.check]})]},`${i.file}\0${i.text}`))}),n&&s.jsx("p",{className:"t-meta",children:"The pass counts once you accept it."})]})}function BI({attempt:e,latest:t}){return s.jsxs("details",{className:`vf-attempt r-${e.result}`,open:t,children:[s.jsxs("summary",{children:[s.jsx(xi,{tone:"state",className:`r-${e.result}`,children:jw[e.result]}),s.jsx(_,{parts:[{text:e.id,code:!0},e.agent,os(e.submittedAt),qt(e.finishedAt-e.submittedAt)]})]}),s.jsx("p",{className:"vf-claim",children:e.summary??e.resolution}),e.note&&!(e.result==="pass"&&e.guard)&&s.jsx("p",{className:"vf-note",children:e.note}),s.jsx(_I,{attempt:e}),e.criteria&&s.jsx("ul",{className:"vf-criteria",children:e.criteria.lines.map(n=>s.jsx("li",{className:FI(n),children:n},n))}),s.jsx(DI,{attempt:e}),e.checks.map(n=>s.jsx(OI,{check:n},n.name))]})}function FI(e){return e.includes(" ✓ ")?"ok":e.includes(" ✗ ")?"bad":e.includes(" ? ")?"claimed":"wait"}const zI={PASS:"Passed",FAIL:"Sent back",NEEDS_HUMAN:"Needs you"};function UI(e){var t;return(t=e.guides)!=null&&t.length?e.guides:e.guide?[{guide:e.guide,answers:e.checklist??[]}]:[]}function WI({verdict:e}){const t=UI(e);return s.jsxs("div",{className:`vf-verdict v-${e.verdict.toLowerCase()}`,children:[s.jsx(_,{parts:[{text:e.byKind==="trail lead"&&e.verdict==="PASS"?"Approved":zI[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.length>0&&`as ${t.map(n=>`${n.guide.id} ${n.guide.version}`).join(", ")}`,`on ${e.attemptId}`,os(e.at)]}),s.jsx("p",{children:e.summary}),e.findings.length>0&&s.jsx("ul",{className:"vf-findings",children:e.findings.map((n,i)=>s.jsxs("li",{className:`sev-${n.severity}`,children:[n.path&&s.jsx("code",{children:n.line?`${n.path}:${n.line}`:n.path})," ",n.text]},i))}),t.map(n=>n.answers.length>0&&s.jsx(Dw,{answers:n.answers},n.guide.id))]})}const HI={PASS:"review passed",FAIL:"review sent it back",NEEDS_HUMAN:"reviewer asked for you"};function KI({data:e}){const t=e.attempts[0];if(!t)return null;const n=e.attempts.length,i=e.verdicts.find(o=>o.attemptId===t.id);return s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"t-body",children:[n," ",n===1?"attempt":"attempts"," · latest ",jw[t.result].toLowerCase()]}),s.jsx(_,{parts:[{text:t.id,code:!0},t.agent,os(t.submittedAt),i&&HI[i.verdict]]}),s.jsx(an,{children:s.jsxs("div",{className:"vf-panel",children:[e.verdicts.map(o=>s.jsx(WI,{verdict:o},o.id)),e.attempts.map((o,c)=>s.jsx(BI,{attempt:o,latest:c===0},o.id))]})})]})}const Ta="";function GI(e){const t=bu.map(i=>({value:i,label:Pr[i],hint:eh[i]})),n=[...VI(e),...t];return s.jsx(it,{compact:!0,className:"vf-level","aria-label":"Verification level",value:e.value??Ta,options:n,onChange:i=>e.onChange(i===Ta?null:i)})}function VI(e){return e.inherit!==void 0?[{value:Ta,label:e.inherit,hint:"Use the trail’s level for this ticket."}]:e.value===void 0?[{value:Ta,label:"Off (not set)"}]:[]}const qI={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."}},QI={rework:{label:"What to fix",submit:"Send to rework",hint:"The agent is told to find the root cause: no sleeps, retries or skipped tests."},accept:{label:"Why the pass counts",submit:"Accept the pass",hint:"Closes it as done. The proof says it passed on retry."}},Ng="The pass counts although the work changed what its checks run. The proof says you accepted it.";function YI(e){return e.kind!=="accept"||!e.guarded?e.hint:e.retried?`${Ng} It also passed only on retry.`:Ng}function JI(e){const{kind:t}=e,n=e.retried&&QI[t]||qI[t],[i,o]=w.useState(""),[c,d]=w.useState("rework"),u=f=>{f.preventDefault(),i.trim()&&e.onSubmit({action:t,reason:i.trim(),...t==="unblock"?{to:c}:{}})};return s.jsxs(Qt,{as:"form",tone:"inset",className:"inline-form",onSubmit:u,children:[s.jsx(mt,{label:n.label,children:s.jsx("textarea",{rows:2,value:i,onChange:f=>o(f.target.value),autoFocus:!0})}),t==="unblock"&&s.jsx(mt,{label:"Back to",children:s.jsx(it,{"aria-label":"Back to",value:c,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."}]})}),s.jsx("span",{className:"t-meta",children:YI({kind:t,guarded:e.guarded,retried:e.retried,hint:n.hint})}),s.jsxs("div",{className:"form-actions",children:[s.jsx(R,{variant:"ghost",onClick:e.onCancel,children:"Cancel"}),s.jsx(R,{type:"submit",variant:t==="accept"?"danger":"primary",disabled:!i.trim(),children:n.submit})]})]})}function XI(e,t,n){const[i,o]=w.useState(),c=`${e}/${t}`;w.useEffect(()=>o(void 0),[c]);const{reload:d}=Pe({view:c,version:n,load:()=>Ss.ticket(e,t),show:o});return w.useEffect(()=>ss.onEvidence(d),[d]),{data:i,reload:d}}const ZI={ticket:"set on this ticket",trail:"from the trail",none:"not set"};function eR({level:e}){return e.level==="off"?"Off":e.checks.join(", ")||"No checks"}function tR({data:e}){const{level:t}=e;return s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"t-body",children:eR(e)}),s.jsx(_,{parts:[t.level!=="off"&&Pr[t.level],ZI[t.source]]}),s.jsx(an,{children:s.jsx("p",{className:"t-meta",children:eh[t.level]})})]})}function nR(e){return e.waivers.length?s.jsxs(Et,{label:"Skipped",children:[e.waivers.map(t=>s.jsx(_,{parts:[{text:t.checks.map(n=>n.name).join(", "),code:!0},t.by,t.reason]},t.id)),s.jsx(R,{size:"sm",variant:"ghost","data-tip":"The checks run again on the next completion",onClick:e.onUndo,children:"Undo"})]}):null}function sR(e){if(e)return e.timedOut?"timed out":e.error?`couldn't run: ${e.error}`:`exited ${e.exitCode??e.signal}`}function iR(e){const[t,n]=w.useState(()=>new Set(e.waivable.map(g=>g.name))),[i,o]=w.useState(""),c=e.waivable.filter(g=>t.has(g.name)),d=c.map(g=>g.name).join(", "),u=c.length>0&&!!i.trim(),f=(g,k)=>{const y=new Set(t);k?y.add(g):y.delete(g),n(y)},m=g=>{g.preventDefault(),u&&e.onSubmit({checks:c,reason:i.trim()})};return s.jsxs(Qt,{as:"form",tone:"inset",className:"inline-form waive-form",onSubmit:m,children:[e.waivable.length>1&&s.jsx("fieldset",{className:"waive-checks",children:e.waivable.map(g=>s.jsxs("label",{className:"waive-check t-body",children:[s.jsx("input",{type:"checkbox",checked:t.has(g.name),onChange:k=>f(g.name,k.target.checked)}),s.jsx("code",{className:"t-code",children:g.name})]},g.name))}),s.jsx(mt,{label:`Why it can go without ${d||"them"}`,children:s.jsx("textarea",{rows:2,value:i,onChange:g=>o(g.target.value),autoFocus:!0})}),s.jsx("span",{className:"t-meta",children:"The other checks run again. The proof shows what was skipped, by you, and why."}),s.jsx(an,{label:"What failed",children:e.waivable.map(g=>s.jsx(_,{parts:[{text:g.name,code:!0},{text:g.argv.join(" "),code:!0},sR(e.results.find(k=>k.name===g.name))]},g.name))}),s.jsxs("div",{className:"form-actions",children:[s.jsx(R,{variant:"ghost",onClick:e.onCancel,children:"Cancel"}),s.jsx(R,{type:"submit",variant:"primary",disabled:!u,children:c.length?`Accept without ${d}`:"Pick a check"})]})]})}function rR({v:e,act:t}){return s.jsxs("dl",{className:"facts how-editor",children:[s.jsx(Et,{label:"Guides",children:s.jsx(AI,{map:e.snap.map,ticket:e.t})}),s.jsx(Et,{label:"Verification",children:s.jsx(GI,{value:e.t.verification,inherit:`Trail (${Pr[e.snap.map.verification??"off"]})`,onChange:n=>void t({action:"level",level:n})})})]})}function oR({v:e}){return s.jsxs("dl",{className:"facts",children:[s.jsx(Et,{label:"Guides",children:s.jsx(TI,{map:e.snap.map,ticket:e.t})}),e.verification&&s.jsx(Et,{label:"Checks",children:s.jsx(tR,{data:e.verification})}),s.jsx(MA,{snap:e.snap,t:e.t})]})}function aR(e){const{v:t}=e,n=e.editing&&t.t.state==="open",i=t.t.state==="open"?()=>e.setEditing(!n):void 0;return s.jsx(Ot,{label:"How",className:"ticket-how",onEdit:i,editLabel:n?"Done":"Edit",children:n?s.jsx(rR,{v:t,act:e.act}):s.jsx(oR,{v:t})})}function cR({lease:e,now:t}){var o;const n=Es(e,t),i=e.notes.at(-1);return s.jsxs(s.Fragment,{children:[s.jsxs(Et,{label:"Claim",children:[s.jsxs("span",{className:"t-body",children:[e.agent," since ",os(e.claimedAt)]}),s.jsx(_,{parts:[`active ${Je(t-e.renewedAt)} ago`,n==="live"&&lR(dR(e.expiresAt-t))]})]}),e.workspace&&s.jsxs(Et,{label:"Branch",children:[s.jsx("code",{className:"t-code",children:e.workspace.branch}),s.jsx(_,{parts:["its own worktree"]})]}),!!((o=e.touches)!=null&&o.length)&&s.jsx(Et,{label:"Changes",children:s.jsx("span",{className:"t-code",children:e.touches.join(", ")})}),i&&s.jsxs(Et,{label:"Latest note",children:[s.jsx("span",{className:"t-body",children:i}),e.notes.length>1&&s.jsx(an,{label:"Earlier notes",children:s.jsx("ul",{className:"lease-notes t-meta",children:e.notes.slice(0,-1).map((c,d)=>s.jsx("li",{children:c},d))})})]})]})}function lR(e){return`back in the queue after ${e} without activity`}function dR(e){const t=e/864e5;return t>=2?`${Math.round(t)} days`:qt(Math.max(0,e))}function uR({v:e,onUndoWaiver:t}){var o,c;const n=((o=e.verification)==null?void 0:o.attempts.length)??0;if(!e.lease&&!e.workspace&&!n&&!e.pr)return null;const i=e.snap.map.id;return s.jsx(Ot,{label:"Progress",className:"ticket-progress",children:s.jsxs("dl",{className:"facts",children:[e.lease&&s.jsx(cR,{lease:e.lease,now:e.now}),e.workspace&&s.jsxs(Et,{label:"Workspace",children:[s.jsx("code",{className:"t-code",children:e.workspace.branch}),s.jsx("span",{className:"t-meta ws-path",title:e.workspace.path,children:e.workspace.path})]}),e.pr&&s.jsx(Et,{label:"Pull request",children:s.jsx(V2,{mapId:i,ticketId:e.t.id})}),n>0&&e.verification&&s.jsx(Et,{label:"Attempts",children:s.jsx(KI,{data:e.verification})}),n>0&&s.jsx(YA,{mapId:i,ticketId:e.t.id}),s.jsx(nR,{waivers:((c=e.verification)==null?void 0:c.waivers)??[],onUndo:t})]})})}function Xw(e){const{v:t}=e,n=t.standing,i=t.lease&&Es(t.lease,t.now),o=t.criteria.changed??t.criteria.proposalChanged,c=new Set(t.chips.map(m=>m.text.toLowerCase())),d=e.asked||c.has(n.title.toLowerCase())?void 0:n.title,u=e.asked?[]:n.parts.filter(m=>!c.has(m.toLowerCase())),f=t.notices.filter(m=>m.text!==e.shownItem);return!d&&!u.length&&!f.length&&!o?null:s.jsxs("div",{className:ue("standing edge-note",`edge-${n.edge}`,`st-${t.state}`,i&&`lease-${i}`,t.modelWait&&"model-wait",e.className),children:[d&&s.jsx("span",{className:"t-row-title standing-title state-title",children:d}),s.jsx(_,{parts:u}),f.map(m=>s.jsx("span",{className:"t-meta standing-notice",children:m.text},m.text)),o&&s.jsx(Uu,{what:"The criteria",onReviewAgain:o.reviewAgain})]})}function hR(e){var u,f;const{v:t,bar:n}=e,{primary:i}=n,o=t.session,c=o&&(i==null?void 0:i.id)!=="answer",d=t.t.state==="closed"&&t.t.closeReason==="completed";return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"actions action-bar",children:[i&&s.jsx(R,{variant:n.variant,"data-tip":i.tip,onClick:i.onSelect,children:i.label}),d&&s.jsx(AA,{mapId:t.snap.map.id,ticketId:t.t.id,proof:t.proof,prState:(f=(u=t.pr)==null?void 0:u.pr)==null?void 0:f.state}),c&&s.jsx(R,{onClick:()=>e.onOpenChat(o.id),"data-tip":`The conversation with ${o.agent}`,children:"Open chat"}),e.trailing&&s.jsx("span",{className:"action-bar-end",children:e.trailing}),s.jsx(qv,{items:n.menu,label:"More ticket actions"})]}),n.error&&s.jsx("p",{className:"vf-err",children:n.error}),n.note&&s.jsx("p",{className:"t-meta bar-note",children:n.note})]})}const sn=e=>({kind:"item",label:e}),fR={brief:{ask:"review the discovery brief",act:sn("Review the brief")},reroute:{ask:"review the reroute",act:sn("Review the reroute")},"reroute-suggested":{ask:"decide whether to reroute",act:sn("Review the reroute")},trust:{ask:"review what changed",act:sn("Open Approvals")},escape:{ask:"decide on a rule",act:sn("Add a rule")},knowledge:{ask:"review the field guide",act:sn("Open the field guide")},guide:{ask:"review the guide",act:sn("Review the guide")},"guide-checks":{ask:"review the guide's checks",act:sn("Review the guide")},"main-checks":{ask:"checks fail on main",act:sn("Open checks on main")},"trail-checks":{ask:"checks fail on main together",act:sn("Open checks on main")},delivery:{ask:"a message could not be delivered",act:sn("Open its settings")},merge:{ask:"merge its pull request",act:{kind:"pr",label:"Open the PR"}},flag:{ask:"look at its pull request",act:{kind:"pr",label:"Open the PR"}},policy:{ask:"check the risky change",act:{kind:"dismiss",label:"Checked: set aside"}},overlap:{ask:"hold one claim",act:{kind:"menu",id:"release-lease"}},integration:{ask:"settle the branches that clash",act:{kind:"inline"}},"tracker-settings":{ask:"settle its changed settings",act:{kind:"inline"}},precedent:{ask:"check it against your decision"},"review-limit":{ask:"review finished work first"}};function rc(e){return fR[e]}const du=`${re()}/workspaces`;async function mR(){const e=await fetch(du);return e.ok?await e.json():null}function Zw(){const[e,t]=w.useState(),{pushed:n}=Pe({load:mR,show:t,failed:()=>t(null),changed:d=>d.endsWith("workspaces.json")||d.includes("workspaces/")||d.includes("leases/")}),i=w.useCallback(d=>{n(),t(d)},[n]),o=w.useCallback(async d=>{const u=await fetch(du,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)}),f=await u.json();if(!u.ok)return f.error??`Saving failed (${u.status})`;i(f)},[i]),c=w.useCallback(async(d,u,f=!1)=>{const m=await fetch(`${du}/remove`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:d,ticketId:u,force:f})}),g=await m.json();return m.ok?(i(g),{}):{error:g.error??`Removing failed (${m.status})`,dirty:g.dirty??!1}},[i]);return{view:e,save:o,remove:c}}function ey(e){const[t,n]=w.useState(!1),[i,o]=w.useState(),[c,d]=w.useState(!1),u=async f=>{d(!0),o(void 0);const m=await e.onRemove(f).catch(g=>({error:g.message,dirty:!1}));d(!1),n(!!m.dirty&&!f),m.dirty||o(m.error)};return t?s.jsxs("span",{className:"ws-remove ask",children:[s.jsx("span",{className:"vf-err",children:"Uncommitted changes in this workspace will be lost."}),s.jsx(R,{size:"sm",disabled:c,onClick:()=>u(!0),children:"Remove anyway"}),s.jsx(R,{size:"sm",variant:"ghost",onClick:()=>n(!1),children:"Keep"})]}):s.jsxs("span",{className:"ws-remove",children:[s.jsx(R,{size:"sm",disabled:c,onClick:()=>u(!1),children:e.label??"Remove"}),i&&s.jsx("span",{className:"vf-err",children:i})]})}function pR(e){return e.rows.length?s.jsx("ul",{className:"ws-list",children:e.rows.map(t=>s.jsx(fe,{as:"li",className:`ws-row ${t.active?"active":"finished"}`,title:s.jsx("span",{className:"t-code",children:t.branch}),titleText:t.branch,context:s.jsx(_,{parts:[{text:t.ticketKey,code:!0},t.active?`Active · ${t.agent}`:"Finished"]}),detail:s.jsx("span",{className:"t-code",children:t.path}),detailText:t.path,below:t.active?void 0:s.jsx(ey,{onRemove:n=>e.onRemove(t.mapId,t.ticketId,n)})},`${t.mapId}/${t.ticketId}`))}):null}function gR(e){const t=e.workspace;return s.jsxs(Qt,{tone:"inset",className:"inline-form",children:[s.jsxs("p",{className:"t-body",children:["Delete the worktree at"," ",s.jsx("code",{className:"t-code",title:t.path,children:t.path}),"? Branch ",s.jsx("code",{className:"t-code",children:t.branch})," stays."]}),s.jsxs("div",{className:"form-actions",children:[s.jsx(R,{variant:"ghost",onClick:e.onCancel,children:"Cancel"}),s.jsx(ey,{label:"Remove workspace",onRemove:e.onRemove})]})]})}function kR(e){const[t,n]=w.useState(""),[i,o]=w.useState(""),[c,d]=w.useState(""),u=f=>{if(f.preventDefault(),!t.trim())return;const m=c.split(`
159
+ `).map(g=>g.trim()).filter(Boolean);e.onResolve(t.trim(),{rationale:i.trim(),alternatives:m})};return s.jsxs(Qt,{as:"form",tone:"inset",className:"inline-form",onSubmit:u,children:[s.jsx(mt,{label:"Resolution",children:s.jsx("textarea",{rows:3,value:t,onChange:f=>n(f.target.value),autoFocus:!0})}),s.jsx(mt,{label:"Rationale",children:s.jsx("input",{value:i,onChange:f=>o(f.target.value)})}),s.jsx(mt,{label:"Alternatives considered",children:s.jsx("textarea",{rows:2,value:c,onChange:f=>d(f.target.value),placeholder:"One per line"})}),s.jsxs("div",{className:"form-actions",children:[s.jsx(R,{variant:"ghost",onClick:e.onCancel,children:"Cancel"}),s.jsx(R,{type:"submit",variant:"primary",disabled:!t.trim(),children:"Resolve"})]})]})}function vR(e){const[t,n]=w.useState("Not needed to reach the destination."),i=o=>{o.preventDefault(),e.onRuleOut(t)};return s.jsxs(Qt,{as:"form",tone:"inset",className:"inline-form",onSubmit:i,children:[s.jsx(mt,{label:"Reason",children:s.jsx("input",{value:t,onChange:o=>n(o.target.value),autoFocus:!0})}),s.jsxs("div",{className:"form-actions",children:[s.jsx(R,{variant:"ghost",onClick:e.onCancel,children:"Cancel"}),s.jsx(R,{type:"submit",variant:"danger",children:"Rule out"})]})]})}const wR=e=>{var n,i;const t=(n=e.verification)==null?void 0:n.attempts[0];return(t==null?void 0:t.result)==="pass"&&((i=t.guard)==null?void 0:i.mode)==="enforce"};function yR(e){var c,d,u,f;const{form:t,v:n,actions:i}=e,o=()=>e.setForm(null);switch(t){case"resolve":return s.jsx(kR,{onResolve:(m,g)=>{i.resolve(n.t.id,m,g),o()},onCancel:o});case"rule":return s.jsx(vR,{onRuleOut:m=>{i.ruleOut({ticketId:n.t.id},m),o()},onCancel:o});case"rework":case"accept":case"unblock":return s.jsx(JI,{kind:t,retried:n.state==="held"&&Tu((c=n.verification)==null?void 0:c.attempts[0]),guarded:wR(n),onSubmit:m=>{e.act(m),o()},onCancel:o});case"waive":return s.jsx(iR,{waivable:((d=n.verification)==null?void 0:d.waivable)??[],results:((f=(u=n.verification)==null?void 0:u.attempts[0])==null?void 0:f.checks)??[],onSubmit:m=>{e.waive(m),o()},onCancel:o});case"workspace":return n.workspace?s.jsx(gR,{workspace:n.workspace,onRemove:n.removeWorkspace,onCancel:o}):null;case null:return null;default:return t}}function ty(e){var d,u;const{v:t,bar:n}=e,i=t.items[0],o=i&&((u=(d=rc(i.kind))==null?void 0:d.act)==null?void 0:u.kind)==="inline"?i:void 0;return!n.primary&&!n.menu.length&&!t.session&&!t.proof&&!e.form&&!e.trailing&&!o&&!n.error&&!n.note?null:s.jsxs("footer",{className:ue("ticket-footer",e.className),children:[s.jsx(yR,{form:e.form,setForm:e.setForm,v:t,actions:e.actions,act:n.act,waive:n.waive}),o&&s.jsx(dw,{item:o}),s.jsx(hR,{v:t,bar:n,onOpenChat:e.onOpenChat,trailing:e.trailing})]})}function xR({chips:e}){return s.jsx("div",{className:"ticket-chips",children:e.map(t=>s.jsx(yT,{tone:t.tone,code:t.kind==="key",className:`tag-${t.kind}`,tip:t.tip,children:t.text},t.kind))})}function ny({v:e,titled:t=!0,small:n}){const{t:i,snap:o}=e,c=f=>{var m;return((m=o.tickets.find(g=>g.id===f))==null?void 0:m.key)??f},d=o.tickets.filter(f=>f.blockedBy.includes(i.id)&&f.state==="open").map(f=>f.key),u=gi(i)==="hitl"&&i.state==="open"&&!e.standing.title.includes("needs a person");return s.jsxs("header",{className:"ticket-head",children:[t&&s.jsx("h3",{className:ue("t-title ticket-title",n&&"small"),children:i.title}),s.jsx(xR,{chips:e.chips}),s.jsx(_,{parts:[u&&"needs a person",i.reviewOf&&`reviews ${c(i.reviewOf)}`,d.length>0&&`blocks ${d.join(", ")}`]})]})}function jR(e){var o,c,d;const t=e.v.items[0],n=t&&((o=rc(t.kind))==null?void 0:o.act);if(!t||!n)return;const i=t.title.split(`
160
+ `)[0];switch(n.kind){case"menu":return e.all.find(u=>u.id===n.id);case"item":{const u=e.onItem;return u&&{id:"need",label:n.label,tip:i,onSelect:()=>u(t)}}case"pr":{const u=At((d=(c=e.v.pr)==null?void 0:c.pr)==null?void 0:d.url);return u?{id:"need",label:n.label,tip:i,onSelect:()=>void window.open(u,"_blank","noopener")}:void 0}case"dismiss":{const u=e.onDismiss;return u&&{id:"need",label:n.label,tip:i,onSelect:()=>u(t.id)}}case"inline":return;default:return n}}function bR(e,t){return[...SR(e,t),...NR(e,t),...ER(e,t),...AR(e,t),...IR(e,t)].filter(n=>!!n)}function SR(e,t){const{state:n,mine:i}=e,o=n==="frontier";return[o&&{id:"claim",label:"Claim",tip:"Take it yourself, so no agent picks it up",onSelect:t.claim},(o||n==="claimed"&&i)&&{id:"resolve",label:"Resolve myself…",tip:"Answer it yourself and close the ticket, with a decision record",onSelect:()=>t.form("resolve")},i&&n==="claimed"&&{id:"release",label:"Give back to the queue",onSelect:t.release},!!e.lease&&{id:"release-lease",label:"Release to queue",tip:"Take the claim back from the agent; its notes go to the next one",onSelect:t.releaseLease}]}function NR(e,t){var u,f,m;if(!(e.state==="verifying"||e.state==="held")||(u=e.verification)!=null&&u.running)return[];const i=!!((f=e.verification)!=null&&f.attempts.length)||e.items.some(g=>g.kind==="approval"),o=e.state==="held",c=(m=e.verification)==null?void 0:m.attempts[0],d=$R(c);return o&&!d&&Tu(c)?CR(t):[e.state==="verifying"&&i&&{id:"approve",label:"Approve",tip:"Approve the work and close the ticket",onSelect:t.approve},i&&{id:"rerun",label:"Re-run checks",tip:"Run the repo's checks again on the current code",onSelect:t.rerun},{id:"rework",label:"Send to rework…",tip:"Back to an agent with what to fix",onSelect:()=>t.form("rework")},o&&{id:"unblock",label:"Unblock…",tip:"Back to the queue without running checks",onSelect:()=>t.form("unblock")},o&&{id:"accept",label:d?"Accept the pass…":"Accept anyway…",tip:d?"Count the checks although the work changed what they run; the proof says you accepted it":"Close it as done despite the checks",onSelect:()=>t.form("accept")}]}const $R=e=>{var t;return(e==null?void 0:e.result)==="pass"&&((t=e.guard)==null?void 0:t.mode)==="enforce"};function CR(e){return[{id:"rework",label:"Send to rework…",tip:"The agent finds why the test is flaky and fixes it: no sleeps, retries or skipped tests",onSelect:()=>e.form("rework")},{id:"accept",label:"Accept the pass…",tip:"Count the pass on retry and close it as done; the proof says it passed on retry",onSelect:()=>e.form("accept")}]}const TR=new Set(["rework","held","claimed"]);function ER(e,t){var c,d,u;const n=((c=e.verification)==null?void 0:c.waivable)??[],i=[...new Set((((d=e.verification)==null?void 0:d.waivers)??[]).flatMap(f=>f.checks.map(m=>m.name)))],o=n.length===1?`Accept without ${n[0].name}…`:"Accept without failing checks…";return[n.length>0&&TR.has(e.state)&&!((u=e.verification)!=null&&u.running)&&{id:"waive",label:o,tip:"When a check can't pass in this repo: the ticket completes without it, with your reason",onSelect:()=>t.form("waive")},i.length>0&&{id:"undo-waiver",label:`Run ${i.join(", ")} again`,tip:"Undo accepting it without them",onSelect:t.undoWaiver}]}function AR(e,t){const n=e.criteria,o=e.t.state==="open"&&n.criteria.length>0&&!(n.changed&&!n.confirmed),c=!!n.proposal&&!n.proposalChanged;return[o&&!n.confirmed&&{id:"confirm-criteria",label:"Confirm criteria",tip:"Agree that these criteria define done for this ticket",onSelect:()=>t.criteria(!0)},o&&n.confirmed&&{id:"unconfirm-criteria",label:"Unconfirm criteria",onSelect:()=>t.criteria(!1)},c&&{id:"take-criteria",label:"Take the new criteria",tip:"Replace yours with the proposed ones",onSelect:t.take},c&&{id:"keep-criteria",label:"Keep my criteria",tip:"Drop the proposal",onSelect:t.keep}]}function IR(e,t){var o;const{state:n,t:i}=e;return[i.state==="open"&&{id:"edit-how",label:"Change guides or verification",tip:"The guides and the verification level for this ticket alone",onSelect:t.editHow},!!e.change&&{id:"review-change",label:"Review the change",tip:"Accept or revert it in Approvals",onSelect:t.reviewChange},((o=e.brief)==null?void 0:o.status)==="submitted"&&{id:"review-brief",label:"Review the brief",onSelect:t.reviewBrief},!!e.proof&&{id:"copy-proof",label:"Copy proof for PR",tip:"The signed report, as Markdown",onSelect:t.copyProof},!!e.workspace&&{id:"remove-workspace",label:"Remove workspace…",tip:"Delete its worktree folder; the branch stays",onSelect:()=>t.form("workspace")},i.closeReason==="not_planned"&&{id:"dead-end",label:"Save as dead end",tip:"Add it to the field guide as a suggestion, so agents learn from it",onSelect:t.deadEnd},(n==="frontier"||n==="blocked"||n==="parked")&&{id:"rule",label:"Rule out…",tip:"Move it out of scope. It's set aside with your reason, not deleted",danger:!0,onSelect:()=>t.form("rule")}]}const RR={answer:"answer",approve:"approve",accept:"accept",waive:"waive",unblock:"unblock",rework:"rework",release:"release-lease",resolve:"resolve","review-brief":"review-brief","review-change":"review-change","confirm-criteria":"confirm-criteria","take-criteria":"take-criteria"};function sy(e){const{v:t,api:n}=e,[i,o]=w.useState(),[c,d]=w.useState(),u=As(),f=I=>{d(I),setTimeout(()=>d(void 0),2500)},m=I=>o(I),g=I=>(o(void 0),Ss.act({...I,mapId:t.snap.map.id,ticketId:t.t.id,by:wt}).then(t.reloadVerification,Q=>o(Q.message))),k=I=>{var q,ee;const Q=((ee=(q=t.verification)==null?void 0:q.attempts[0])==null?void 0:ee.id)??"",Z=I.checks.map(Se=>({name:Se.name,hash:Se.hash}));return o(void 0),Ss.waive({mapId:t.snap.map.id,ticketId:t.t.id,attemptId:Q,checks:Z,reason:I.reason}).then(t.reloadVerification,Se=>o(Se.message))},y={form:I=>e.setForm(I),claim:()=>void n.actions.claim(t.t.id),release:()=>void n.actions.release(t.t.id),releaseLease:()=>void n.actions.releaseLease(t.t.id),approve:()=>void g({action:"approve"}),rerun:()=>void g({action:"rerun"}),undoWaiver:()=>void Ss.undoWaiver({mapId:t.snap.map.id,ticketId:t.t.id}).then(t.reloadVerification,I=>o(I.message)),criteria:I=>void t.criteria.setConfirmed(I).then(m),take:()=>void t.criteria.take().then(m),keep:()=>void t.criteria.keep().then(m),editHow:e.onEditHow,reviewChange:()=>{var I;return(I=e.onReviewChange)==null?void 0:I.call(e)},reviewBrief:()=>{var I;return(I=e.onReviewBrief)==null?void 0:I.call(e,t.snap.map.id)},copyProof:()=>{var I;return void navigator.clipboard.writeText(((I=t.proof)==null?void 0:I.markdown)??"").then(()=>f("Copied for PR"))},deadEnd:()=>{var I;return void u.propose({title:`Ruled out: ${t.t.title}`,body:((I=t.t.comments.at(-1))==null?void 0:I.body)??t.t.body,kind:"dead-end",sources:[`trail:${t.snap.map.key}`,`ticket:${t.t.key}`]}).then(Q=>Q&&f(`Saved as ${Q.id} in the field guide`))}},b=bR(t,y),S=MR(t,e.onOpenChat),x=t.standing.primary,$=b.find(I=>I.id==="take-criteria")??b.find(I=>I.id==="confirm-criteria"),N=x==="need"?jR({v:t,all:b,onItem:e.onItem,onDismiss:e.onDismiss}):void 0,O=x&&x!=="need"?b.find(I=>I.id===RR[x]):void 0,D=S??N??O??$,F=LR({urgent:t.standing.edge==="urgent",named:!!x&&D!==$}),K=b.filter(I=>I!==D);return{primary:D,variant:F,menu:K,error:i,note:c,act:g,waive:k,undoWaiver:y.undoWaiver}}function MR(e,t){const n=e.question;if(!(e.standing.primary!=="answer"||!n))return{id:"answer",label:"Answer",tip:`${n.agent} is waiting for your answer`,onSelect:()=>t(n.sessionId)}}function LR(e){return e.urgent?"urgent":e.named?"primary":"default"}function OR({text:e}){return e.trim()?s.jsx("div",{className:"brief-prose",children:e.split(`
161
+ `).map((t,n)=>s.jsx("p",{children:t.split(/(`[^`]+`|\/?\b[\w.-]+\/[\w./-]+\b)/g).map((i,o)=>o%2===1?s.jsx("code",{children:i.replace(/`/g,"")},o):i)},n))}):s.jsx(Te,{children:"Not covered"})}const $g=["summary","productContext","existing","conventions","dataModel","api","risks"];function PR(e){const{brief:t}=e,[n,i]=w.useState(!1),[o,c]=w.useState("");w.useEffect(()=>{const m=g=>g.key==="Escape"&&e.onClose();return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[e]);const d=t.sections,u=$g.filter(m=>d[m].trim()),f=$g.filter(m=>!d[m].trim());return s.jsx("div",{className:"scrim",onClick:e.onClose,children:s.jsxs(Be,{as:"div",className:"dialog brief-dialog",onClick:m=>m.stopPropagation(),children:[s.jsxs("header",{children:[s.jsx("h2",{className:"t-heading caps",children:"Discovery brief"}),s.jsx("span",{className:"t-meta",children:DR(t)})]}),s.jsxs("div",{className:"brief-body",children:[u.map(m=>s.jsxs("section",{children:[s.jsx("h3",{className:"mono-label",children:ur[m]}),s.jsx(OR,{text:d[m]}),(m==="conventions"||m==="productContext")&&d[m].trim()&&s.jsx(Iw,{draft:()=>({title:`${ur[m]}: ${d[m].split(`
162
+ `)[0].slice(0,80)}`,body:d[m],kind:m==="conventions"?"convention":"business-rule",sources:[`brief:${t.mapId}`]})})]},m)),s.jsxs("section",{children:[s.jsx("h3",{className:"mono-label",children:ur.assumptions}),d.assumptions.length?s.jsx("ul",{className:"item-list",children:d.assumptions.map(m=>s.jsxs("li",{children:[s.jsx("span",{className:"item-text",children:m.text}),s.jsx(_,{parts:[{text:m.id,code:!0}]})]},m.id))}):s.jsx(Te,{children:"None listed"})]}),s.jsxs("section",{children:[s.jsx("h3",{className:"mono-label",children:ur.openQuestions}),d.openQuestions.length?s.jsx("ul",{className:"brief-list",children:d.openQuestions.map(m=>s.jsx("li",{children:m},m))}):s.jsx(Te,{children:"None"})]}),f.length>0&&s.jsxs("p",{className:"t-meta brief-empty",children:["Nothing noted on ",f.map(m=>ur[m].toLowerCase()).join(", "),"."]}),t.note&&s.jsxs("section",{children:[s.jsx("h3",{className:"mono-label",children:"Your last request"}),s.jsx("p",{children:t.note})]})]}),n&&s.jsx(mt,{label:"What should change?",children:s.jsx("textarea",{rows:3,value:o,onChange:m=>c(m.target.value),autoFocus:!0})}),e.changed&&e.onReviewAgain&&s.jsx(Uu,{what:"The brief",onReviewAgain:e.onReviewAgain}),e.error&&s.jsx("p",{className:"urgent-text",children:e.error}),s.jsxs("div",{className:"actions",children:[t.status==="submitted"&&!n&&s.jsxs(s.Fragment,{children:[s.jsx(R,{onClick:()=>i(!0),children:"Request changes"}),s.jsx(R,{variant:"primary",disabled:e.changed,onClick:e.onAccept,children:"Accept brief"})]}),n&&s.jsxs(s.Fragment,{children:[s.jsx(R,{variant:"ghost",onClick:()=>i(!1),children:"Back"}),s.jsx(R,{variant:"primary",disabled:!o.trim(),onClick:()=>e.onRequestChanges(o.trim()),children:"Send to the agent"})]}),s.jsx(R,{variant:"ghost",onClick:e.onClose,children:"Close"})]})]})})}function DR(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(`${Je(Date.now()-e.submittedAt)} ago`),t.join(" · ")}function _R({brief:e,onReview:t}){return e.status!=="submitted"?null:s.jsx("div",{className:"brief-card",children:s.jsx(fe,{edge:"attention",title:"Discovery brief ready for your review",context:s.jsx(_,{parts:["Discovery brief",e.author&&`by ${e.author}`]}),detail:e.sections.summary.split(`
163
+ `)[0],detailText:e.sections.summary,onOpen:t})})}function BR({onReview:e,onClose:t}){return w.useEffect(()=>{const n=i=>i.key==="Escape"&&t();return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[t]),s.jsx("div",{className:"scrim",onClick:t,children:s.jsxs(Be,{as:"div",className:"dialog brief-ready",role:"dialog","aria-label":"Research is done",onClick:n=>n.stopPropagation(),children:[s.jsx("header",{children:s.jsx("h2",{className:"t-heading caps",children:"Research is done"})}),s.jsx("p",{className:"t-body",children:"The discovery brief needs your review. Implementation starts once you accept it."}),s.jsxs("footer",{children:[s.jsx(R,{variant:"ghost",onClick:t,children:"Later"}),s.jsx(R,{variant:"primary",autoFocus:!0,onClick:e,children:"Review brief"})]})]})})}const FR={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 zR({brief:e,onReview:t}){if(e.status==="accepted")return null;const[n,i]=FR[e.status],o=e.status==="submitted"?"edge-attention":"edge-neutral";return s.jsxs("div",{className:`discovery-banner map-banner ${o} st-${e.status}`,role:"status",children:[s.jsxs("span",{className:"mb-text",children:[s.jsx("span",{className:"mb-lead",children:n}),s.jsx("span",{className:"t-meta",children:i})]}),s.jsx(wi,{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."}),s.jsx(R,{size:"sm",variant:e.status==="submitted"?"primary":"ghost",onClick:t,children:e.status==="submitted"?"Review brief":"Open brief"})]})}const iy=`${re()}/briefs`;async function UR(e){if(!e)return{brief:null};const t=await fetch(`${iy}?mapId=${encodeURIComponent(e)}`);return t.ok?await t.json():{brief:null}}function oc(e){const t=e==null?void 0:e.map.id,[n,i]=w.useState(null),[o,c]=w.useState(),[d,u]=w.useState(),[f,m]=w.useState(!1),{reload:g,pushed:k}=Pe({view:t,version:e==null?void 0:e.tickets.reduce((S,x)=>Math.max(S,x.updatedAt),e.map.updatedAt),load:()=>UR(t),show:S=>{i(S.brief),u(S.hash),m(!!S.gated)},failed:()=>(i(null),m(!1)),changed:S=>S.startsWith("briefs/")}),y=(S,x,$)=>fetch(`${iy}/${S}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,note:x,hash:$})}).then(async N=>{const O=await N.json().catch(()=>({}));if(!N.ok||!O.brief)throw new Error(O.error??`HTTP ${N.status}`);c(void 0),k(),i(O.brief),O.brief.status==="accepted"&&m(!1)}),b=(S,x,$)=>y(S,x,$).then(()=>!0,N=>(c(N.message),g(),!1));return{brief:n,error:o,hash:d,gated:f,accept:S=>b("accept",void 0,S),requestChanges:S=>b("request-changes",S)}}const Cg=new Set,Tg=e=>`teamtrail.brief-ready:${re()}:${e.mapId}:${e.submittedAt??""}`,Eg={has(e){const t=Tg(e);if(Cg.has(t))return!0;try{return localStorage.getItem(t)==="1"}catch{return!1}},add(e){const t=Tg(e);Cg.add(t);try{localStorage.setItem(t,"1")}catch{}}};function WR(e){const[,t]=w.useState(0);return{show:(e==null?void 0:e.status)==="submitted"&&!Eg.has(e),close:()=>{e&&Eg.add(e),t(o=>o+1)}}}function HR(e,t){return e&&t.state==="open"&&!uv.includes(t.type)}function KR(e){const{gated:t}=oc(e);return n=>HR(t,n)}const GR=`${J.apiPrefix}/models`;async function VR(){const e=await fetch(GR);return e.ok?await e.json():null}function ih(){const[e,t]=w.useState();return Pe({load:VR,show:t,failed:()=>t(null),changed:n=>n.endsWith("models.json")||n.endsWith("map.md")||n.includes("/tickets/"),events:{attention:()=>!0}}),e}async function qR(){const e=await fetch(`${re()}/signed-state`);return e.ok?await e.json():null}function ry(){const[e,t]=w.useState();return Pe({load:qR,show:t,failed:()=>t(null),changed:n=>n.endsWith("map.md")||n.includes("/tickets/")||n.includes("/decisions/")}),e}const QR={ticket:"held until you accept or revert it",decision:"what you see is what was signed here, until you accept or revert it"};function YR(e){return e[0]==="added"?"added outside Teamtrail":e.map(t=>t==="words"?"its words":t).join(", ")}function JR({mapId:e,kind:t,id:n}){const i=ry(),o=d=>d.mapId===e&&d.kind===t&&d.id===n,c=i==null?void 0:i.changes.find(o);return c?s.jsx(fe,{className:"d-section",edge:"attention",title:"Changed outside Teamtrail",context:s.jsx(_,{parts:[`${YR(c.fields)} · ${QR[t]}`]}),detail:"By a teammate or an agent editing the file. Settings → Approvals shows what changed."}):i!=null&&i.textEdits.some(o)?s.jsx(_,{className:"d-section",parts:["Text edited outside Teamtrail"]}):null}const Ag={low:0,medium:1,high:2};function XR(e){return{key:e.t.key,type:e.t.type,state:e.state,need:ZR(e),agent:eM(e),proof:nM(e),risk:sM(e)}}function ZR(e){if(e.question)return"waiting on you";const t=e.items.find(n=>n.kind!=="question");return t&&xw(t)}function eM(e){var i;const t=e.session;if(t)return{name:t.agent,model:Sr(t.model),modelId:t.model,working:!0};if(e.lease)return{name:e.lease.agent,working:!0};if(e.state==="claimed"&&e.t.assignee)return{name:tM(e.t.assignee),working:!0};const n=(i=e.proof)==null?void 0:i.proof.attempt;if(!(e.state!=="decided"||!(n!=null&&n.id)))return{name:n.agent,model:Sr(n.model),modelId:n.model,working:!1}}const tM=e=>e===wt?"you":e;function nM(e){var n;const t=(n=e.proof)==null?void 0:n.proof;if(!(!t||e.state!=="decided"||!nh(e.t,t)))return{verified:t.status==="verified",gap:t.gaps[0]}}function sM(e){var i;const t=e.decisions.flatMap(o=>o.risk?[{level:o.risk.level,reason:`${o.id}: ${o.risk.reason}`}]:[]);(i=e.question)!=null&&i.lookoutOnly&&t.push({level:"high",reason:"Its question is high risk by the risk policy"});const n=e.items.find(o=>o.kind==="policy");return n&&t.push({level:"high",reason:n.title}),t.sort((o,c)=>Ag[c.level]-Ag[o.level])[0]}const iM=new Set(["claimed","verifying"]),rM=new Set(["held","rework"]),oM={medium:"medium risk",high:"high risk"};function aM(e){const t=[{kind:"key",text:e.key},{kind:"type",text:ns[e.type]},cM(e)];return e.agent&&t.push(...dM(e.agent)),e.proof&&t.push(uM(e.proof)),e.risk&&e.risk.level!=="low"&&t.push({kind:"risk",text:oM[e.risk.level],tone:"warn",tip:e.risk.reason}),t}function cM(e){return e.need?{kind:"state",text:e.need,tone:"urgent"}:{kind:"state",text:Rv[e.state],tone:lM(e.state)}}function lM(e){return iM.has(e)?"agent":rM.has(e)?"warn":void 0}function dM(e){const t=e.working?"agent":void 0,n={kind:"agent",text:e.name,tone:t};return e.model?[n,{kind:"model",text:e.model,tip:e.modelId}]:[n]}function uM(e){return e.verified?{kind:"proof",text:"verified",tone:"verified",tip:"Verified by Teamtrail"}:{kind:"proof",text:"not verified",tip:e.gap}}const hM=e=>e[0]==="added"?"added outside Teamtrail":e.map(t=>t==="words"?"its words":t).join(", ");function fM(e){var u,f,m;const{t,snap:n}=e,i=e.items[0],o=new Map(n.tickets.map(g=>[g.id,g])),c=(u=e.verification)==null?void 0:u.attempts[0],d=e.lease&&{agent:e.lease.agent,renewedAt:e.lease.renewedAt,expiresAt:e.lease.expiresAt,health:Es(e.lease,e.now)};return{state:e.state,now:e.now,question:e.question&&{agent:e.question.agent,at:e.question.at},item:i&&{kind:i.kind,edge:Or(i,e.interrupting.includes(i.id)),title:i.title.split(`
164
+ `)[0].replace(/^[^\s:]+: /,"")},outsideChange:e.change&&`${hM(e.change.fields)} · held until you accept or revert it`,lease:d,assignee:t.assignee,mine:e.mine,hitl:gi(t)==="hitl",briefHeld:mM(e),modelWait:e.modelWait&&{tier:e.modelWait.tier,best:e.modelWait.best},running:(f=e.verification)==null?void 0:f.running,latest:c&&pM(c),sentBack:kM(e.verification),reviewWaits:vM(e.verification),verified:e.proof&&nh(e.t,e.proof.proof)?e.proof.proof.status==="verified":void 0,pr:((m=e.pr)==null?void 0:m.pr)&&{number:e.pr.pr.number,state:e.pr.pr.state},openBlockers:t.blockedBy.filter(g=>{var k;return((k=o.get(g))==null?void 0:k.state)==="open"}).map(g=>{var k;return((k=o.get(g))==null?void 0:k.key)??g}),closedAt:t.closedAt}}function mM(e){if(!(!e.brief||e.state!=="frontier"||uv.includes(e.t.type)))return e.brief.status==="submitted"?"submitted":"writing"}function pM(e){var o;const t=e.checks.filter(c=>!bw(c)).map(c=>c.name),n=e.flaky&&Tu(e)?eS(e.flaky.checks):void 0,i=e.result==="pass"&&((o=e.guard)==null?void 0:o.mode)==="enforce"?e.guard:void 0;return{result:e.result,agent:e.agent,failed:t,...i?{guarded:nS(i.findings)}:{},...n?{retried:n}:{}}}const gM={FAIL:"the review sent it back",NEEDS_HUMAN:"the reviewer asked for you"};function kM(e){const t=e==null?void 0:e.attempts[0],n=t&&e.verdicts.find(i=>i.attemptId===t.id);return n&&gM[n.verdict]}function vM(e){const t=e==null?void 0:e.attempts[0];return!t||t.result!=="pass"||!e.level.level.includes("review")?!1:!e.verdicts.some(n=>n.attemptId===t.id)}const wM=new Set(["question","approval","blocked","hitl-ready","stalled","model"]);function yM(e){var c;const t=((c=e.pr)==null?void 0:c.flags.map(d=>({text:d.text,risk:!0})))??[],n=d=>d===e.items[0]&&!!rc(d.kind),i=e.items.filter(d=>!wM.has(d.kind)&&!n(d)).map(d=>({text:d.title,risk:!0})),o=e.textEdited&&!e.change?[{text:"Text edited outside Teamtrail",risk:!1}]:[];return[...t,...i,...o]}function xM(e){const t=jM(e),n=t.edge==="neutral"||t.edge==="done";return e.atRisk&&n?{...t,edge:"attention"}:t}function jM(e){if(e.question)return SM(e,e.question);if(e.outsideChange)return{edge:"attention",title:"Held: changed outside Teamtrail",parts:[e.outsideChange],primary:"review-change"};const t=IM(e);if(t)return t;if(e.running&&e.state!=="decided"&&e.state!=="out-of-scope")return{edge:"neutral",title:`Checking ${e.running.agent}'s work`,parts:[`since ${os(e.running.startedAt)}`]};switch(e.state){case"decided":return NM(e);case"out-of-scope":return{edge:"neutral",title:"Ruled out",parts:CM(e)};case"verifying":return TM(e);case"held":return bM(e);case"claimed":return EM(e);case"rework":return{edge:"attention",title:`Rework: ${oy(e)}`,parts:["waits for an agent"]};case"frontier":return AM(e);case"blocked":return{edge:"neutral",title:`Waits on ${e.openBlockers.join(", ")}`,parts:[]};case"parked":return{edge:"neutral",title:"Parked",parts:["a plan-only trail builds nothing"]};default:return e.state}}function bM(e){var i,o,c,d;const t=((i=e.item)==null?void 0:i.edge)??"attention",n=(o=e.latest)==null?void 0:o.retried;return(c=e.latest)!=null&&c.guarded?{edge:t,title:"Held: the work changed what its checks run",parts:[e.latest.guarded,...n?[`only on retry: ${n}`]:[],"waits on you"],primary:"accept"}:n?{edge:t,title:"Held: passed only on retry",parts:[n],primary:"rework"}:{edge:t,title:`Blocked: ${oy(e)}`,parts:["waits on you"],primary:(d=e.latest)!=null&&d.failed.length?"waive":"unblock"}}function SM(e,t){var i;return{edge:((i=e.item)==null?void 0:i.kind)==="question"?e.item.edge:"urgent",title:`Waiting on you: answer ${t.agent}'s question`,parts:[Nr(e.now,t.at)],primary:"answer"}}function NM(e){const t=$M(e.verified),n=e.pr&&`PR #${e.pr.number} ${e.pr.state}`,i=e.closedAt&&`finished ${Nr(e.now,e.closedAt)}`;return{edge:"done",title:"Done",parts:[t,n,i].filter(o=>!!o)}}function $M(e){if(e!==void 0)return e?"verified":"not verified"}function CM(e){return e.closedAt?[Nr(e.now,e.closedAt)]:[]}function TM(e){var t;return((t=e.item)==null?void 0:t.kind)==="approval"?{edge:e.item.edge,title:"Waiting on you: approve it",parts:Ig(e),primary:"approve"}:e.reviewWaits?{edge:"neutral",title:"Waiting for a review agent",parts:Ig(e)}:{edge:"neutral",title:"Verifying",parts:[]}}function Ig(e){var t;return((t=e.latest)==null?void 0:t.result)==="pass"?["checks passed"]:[]}function oy(e){var n,i,o,c;const t=(n=e.latest)!=null&&n.failed.length?` (${e.latest.failed.join(", ")})`:"";return((i=e.latest)==null?void 0:i.result)==="fail"?`checks failed${t}`:((o=e.latest)==null?void 0:o.result)==="error"?`checks could not run${t}`:((c=e.latest)==null?void 0:c.result)==="interrupted"?"checks were interrupted":e.sentBack??"sent back"}function EM(e){const t=e.lease;if(t&&t.health!=="live"){const i=t.health==="expired"?"going back to the queue":`back in the queue in ${qt(t.expiresAt-e.now)}`,o=[`active ${Nr(e.now,t.renewedAt)}`,i];return{edge:"attention",title:`${t.agent} went quiet`,parts:o,primary:"release"}}return e.mine?{edge:"neutral",title:"You have it",parts:[],primary:"resolve"}:{edge:"neutral",title:`${(t==null?void 0:t.agent)??e.assignee??"An agent"} is working on it`,parts:t?[`active ${Nr(e.now,t.renewedAt)}`]:[]}}function AM(e){var t;if(e.briefHeld==="submitted")return{edge:"attention",title:"Held: waits on the brief",parts:["the brief waits on you"],primary:"review-brief"};if(e.briefHeld)return{edge:"attention",title:"Held: waits on the brief",parts:["research is still writing it"]};if(e.hitl){const i=["decide it yourself, or let an agent ask you",e.modelWait&&`agents need a ${e.modelWait.tier} model`].filter(o=>!!o);return{edge:((t=e.item)==null?void 0:t.edge)??"neutral",title:"Ready: needs a person",parts:i,primary:"resolve"}}return e.modelWait?{edge:"attention",title:`Waits for a ${e.modelWait.tier} model`,parts:[`connected agents run ${e.modelWait.best} at most`]}:{edge:"neutral",title:"Ready",parts:["the next agent takes it"]}}const Nr=(e,t)=>`${Je(e-t)} ago`;function IM(e){const t=e.item&&rc(e.item.kind);if(!e.item||!t)return;const n=e.item.edge==="neutral"?"attention":e.item.edge,i=e.item.title?[e.item.title]:[];return{edge:n,title:`Waiting on you: ${t.ask}`,parts:i,primary:t.act?"need":void 0}}function ay(e){var D,F,K;const{snap:t,t:n,api:i}=e,o=t.map.id,c=gt(1e3),d=Ts(t.tickets,t.map.mode).get(n.id),u=XI(o,n.id,n.updatedAt),f=NA(o,n.id),m=HA(t,n),g=ry(),k=ih(),y=ss.ticket(Mr(),o,n.id),b=oc(t),S=Zw(),x=I=>I.mapId===o&&I.kind==="ticket"&&I.id===n.id,$={t:n,snap:t,state:d,now:c,mine:n.assignee===wt,lease:n.state==="open"?Ou(i.leases,o).get(n.id):void 0,session:e.sessions.find(I=>I.ticketId===n.id&&gn(I)),question:i.activity.pending.find(I=>I.mapId===o&&I.ticketId===n.id),items:(((D=e.attention)==null?void 0:D.items)??[]).filter(I=>I.mapId===o&&I.ticketId===n.id),interrupting:((F=e.attention)==null?void 0:F.interrupting)??[],verification:u.data,proof:f??void 0,pr:y,change:g==null?void 0:g.changes.find(x),textEdited:!!(g!=null&&g.textEdits.some(x)),brief:b.gated?b.brief:null,modelWait:k==null?void 0:k.waiting.find(I=>I.mapId===o&&I.ticketId===n.id),workspace:(K=S.view)==null?void 0:K.workspaces.find(I=>I.mapId===o&&I.ticketId===n.id&&!I.active),decisions:i.decisions.filter(I=>I.mapId===o&&I.ticketId===n.id)},N=yM($),O=xM({...fM($),atRisk:N.some(I=>I.risk)});return{...$,reloadVerification:u.reload,criteria:m,removeWorkspace:I=>S.remove(o,n.id,I),standing:O,notices:N,chips:aM(XR($))}}function RM(e){return e.replace(/\s*Part of trail \S+\.\s*$/,"").trim()}function cy({v:e}){const t=RM(e.t.body);return t?s.jsx(Ot,{label:"What",className:"ticket-body",children:s.jsx(Vu,{text:t,markdown:!0})}):null}function MM(e){const{snap:t,t:n,api:i}=e,o=ay({snap:t,t:n,api:i,sessions:e.sessions,attention:e.attention}),[c,d]=w.useState(!1),u=sy({v:o,api:i,setForm:e.setForm,onEditHow:()=>d(!0),onOpenChat:e.onOpenChat,onReviewChange:e.onReviewChange,onReviewBrief:e.onReviewBrief,onItem:e.onItem,onDismiss:e.onDismiss});return s.jsxs("div",{className:"detail ticket-panel",children:[s.jsx(ny,{v:o}),s.jsx(Xw,{v:o}),s.jsx(cy,{v:o}),s.jsx(Ow,{v:o}),s.jsx(aR,{v:o,editing:c,setEditing:d,act:u.act}),s.jsx(uR,{v:o,onUndoWaiver:u.undoWaiver}),s.jsx(rA,{mapId:t.map.id,ticketId:n.id}),s.jsx(SA,{ticket:n,view:o.proof}),s.jsx(qA,{t:n,decisions:o.decisions,onOpenDecision:e.onOpenDecision}),s.jsx(ty,{v:o,bar:u,form:e.form,setForm:e.setForm,actions:i.actions,onOpenChat:e.onOpenChat,className:"sticky"})]})}function LM(e){const t=e.snap.tickets.find(n=>n.id===e.id);return t?s.jsx(MM,{...e,t},t.id):s.jsx(Te,{children:"Ticket not found."})}const Rg=[{phase:"discovery",label:"Discovery"},{phase:"brief",label:"Brief"},{phase:"building",label:"Building"},{phase:"review",label:"Review"},{phase:"done",label:"Done"}],OM=new Set(["decided","out-of-scope"]),PM=new Set(["verifying","held"]);function DM(e){if(e.done)return"done";if(e.gated)return e.briefStatus==="submitted"?"brief":"discovery";const t=e.states.filter(n=>!OM.has(n));return t.length&&t.every(n=>PM.has(n))?"review":"building"}function _M(e,t){switch(e){case"discovery":return"Research maps the existing system for the brief; implementation waits for it";case"brief":return"The brief waits on you: implementation starts once you accept it";case"building":return`${t.done} of ${t.total} tickets done`;case"review":return"All the work is in and waits for verification";case"done":return t.reason??"Every ticket in scope is done";default:return e}}function BM(e){const t=Rg.findIndex(o=>o.phase===e.phase),n=e.snap.tickets.filter(o=>e.states.get(o.id)!=="out-of-scope"),i=n.filter(o=>e.states.get(o.id)==="decided").length;return s.jsxs("header",{className:"glance-head",children:[s.jsx("ol",{className:"phase-steps","aria-label":"Trail phase",children:Rg.map((o,c)=>s.jsx("li",{className:ue(c<t&&"past",c===t&&"now"),"aria-current":c===t?"step":void 0,children:o.label},o.phase))}),s.jsx("p",{className:"t-body",children:_M(e.phase,{done:i,total:n.length,reason:e.reason})})]})}function ly(e){var y,b,S;const{snap:t}=e,{brief:n,gated:i}=oc(t),o=Ts(t.tickets,t.map.mode),c=!!e.done&&e.done.kind!=="not-done",d=DM({done:c,gated:i,briefStatus:n==null?void 0:n.status,states:[...o.values()]}),u=(((y=e.attention)==null?void 0:y.items)??[]).filter(x=>x.mapId===t.map.id),f=u[0],m=e.sessions.filter(x=>gn(x)&&x.mapId===t.map.id&&x.ticketId),g=t.tickets.filter(x=>o.get(x.id)==="frontier"),k=new Map(t.tickets.map(x=>[x.id,x]));return s.jsxs("div",{className:"detail trail-glance",children:[s.jsx(BM,{phase:d,snap:t,states:o,reason:c?(b=e.done)==null?void 0:b.reason:void 0}),c?s.jsx(aw,{mapId:t.map.id,now:e.now}):s.jsx(iw,{mapId:t.map.id,now:e.now}),f&&s.jsx(Ot,{label:`Waits on you · ${u.length}`,children:s.jsx(fe,{edge:Or(f,((S=e.attention)==null?void 0:S.interrupting.includes(f.id))??!1),title:f.title.split(`
165
+ `)[0],context:s.jsx(_,{parts:uw({item:f,snap:t,otherTrail:!1})}),trailing:Je(e.now-f.since),onOpen:()=>e.onItem(f)})}),m.length>0&&s.jsx(Ot,{label:`Agents now · ${m.length}`,children:m.map(x=>{var $;return s.jsx(fe,{edge:x.waitingOn?"urgent":"neutral",title:(($=k.get(x.ticketId))==null?void 0:$.title)??x.stepLabel,context:s.jsx(_,{parts:[{text:x.agent,strong:!0},`${x.stepLabel}, step ${x.step} of ${x.total}`]}),onOpen:()=>e.onTicket(x.ticketId)},x.id)})}),g.length>0&&s.jsx(Ot,{label:`Ready next · ${g.length}`,children:g.slice(0,3).map(x=>s.jsx(fe,{title:x.title,context:s.jsx(_,{parts:[{text:x.key,code:!0},ns[x.type]]}),onOpen:()=>e.onTicket(x.id)},x.id))}),s.jsx("p",{className:"t-meta glance-hint",children:"A ticket opens in its bubble on the map."})]})}function dy({snap:e,item:t,api:n}){const i=Uk(e.map.mode),[o,c]=w.useState("research"),[d,u]=w.useState(t),[f,m]=w.useState(!1),[g,k]=w.useState([]),[y,b]=w.useState("Not needed to reach the destination.");w.useEffect(()=>u(t),[t]);const S=e.tickets.filter(x=>x.state==="open");return s.jsxs("div",{className:"detail",children:[s.jsx("div",{className:"d-head",children:s.jsx(xi,{tone:"state",className:"st-unspecified",children:"Not yet specified"})}),s.jsx("h3",{className:"t-heading",children:t}),s.jsxs(Qt,{as:"form",tone:"inset",className:"inline-form",onSubmit:x=>{x.preventDefault(),n.actions.graduate({unspecified:t,type:o,title:d,blockedBy:g,hitl:f})},children:[s.jsx(mt,{label:"Title",children:s.jsx("input",{value:d,onChange:x=>u(x.target.value)})}),s.jsxs("div",{className:"chips",children:[i.map(x=>s.jsx("button",{type:"button",className:`chip ${o===x?"on":""}`,onClick:()=>c(x),children:x},x)),h0.includes(o)&&s.jsx("button",{type:"button",className:`chip ${f?"on":""}`,onClick:()=>m(x=>!x),children:"needs human"})]}),s.jsx("span",{className:"field",children:"Blocked by"}),s.jsx("div",{className:"chips",children:S.map(x=>s.jsx("button",{type:"button",className:`chip ${g.includes(x.id)?"on":""}`,onClick:()=>k($=>$.includes(x.id)?$.filter(N=>N!==x.id):[...$,x.id]),children:x.key},x.id))}),s.jsx("div",{className:"form-actions",children:s.jsx(R,{type:"submit",variant:"primary",children:"Promote to ticket"})})]}),s.jsxs(Qt,{as:"form",tone:"inset",className:"inline-form",onSubmit:x=>{x.preventDefault(),n.actions.ruleOut({unspecified:t},y)},children:[s.jsx(mt,{label:"Reason",children:s.jsx("input",{value:y,onChange:x=>b(x.target.value)})}),s.jsx("div",{className:"form-actions",children:s.jsx(R,{type:"submit",variant:"danger",children:"Rule out"})})]})]})}function FM(e){const{api:t}=e,{snap:n,selection:i,actions:o}=t,[c,d]=w.useState(null),u=gt(5e3),f=zM(i);w.useEffect(()=>d(null),[f]);const m=e.onOpenChat??o.openChat;let g;return n?(i==null?void 0:i.kind)!=="ticket"&&(i==null?void 0:i.kind)!=="unspecified"?g=s.jsx(ly,{snap:n,sessions:e.sessions,attention:e.attention,done:e.done,now:u,onTicket:k=>t.setSelection({kind:"ticket",id:k}),onItem:k=>{var y;return(y=e.onItem)==null?void 0:y.call(e,k)}}):i.kind==="unspecified"?g=s.jsx(dy,{snap:n,item:i.item,api:t}):g=s.jsx(LM,{snap:n,id:i.id,api:t,sessions:e.sessions,attention:e.attention,form:c,setForm:d,onOpenChat:m,onOpenDecision:e.onOpenDecision,onReviewChange:e.onReviewChange,onReviewBrief:e.onReviewBrief,onItem:e.onItem,onDismiss:e.onDismiss}):g=s.jsx(An,{title:"No trail yet",hint:"Once there's a trail, pick a ticket on the map to see it here."}),s.jsx(bT,{area:"inspector",icon:"note",title:"Trail step",info:"The ticket you selected on the map: where it stands, what you can do, and what it is. With none selected, the trail at a glance.",className:"inspector",bare:e.bare,children:g})}function zM(e){return(e==null?void 0:e.kind)==="ticket"?e.id:(e==null?void 0:e.kind)==="unspecified"?e.item:(e==null?void 0:e.kind)??""}function uy(e){const t=Array.from({length:Math.max(1,e.total)},(n,i)=>i+1);return s.jsx("span",{className:ue("step-segments",e.mini&&"mini"),role:"img","aria-label":`Step ${e.step} of ${e.total}`,children:t.map(n=>s.jsx("span",{className:ue(n<e.step&&"done",n===e.step&&"now")},n))})}function UM({session:e}){return s.jsxs("div",{className:"bubble-agent",children:[s.jsx(_,{parts:[`step ${e.step} of ${e.total}`,e.stepLabel.toLowerCase()]}),s.jsx(uy,{step:e.step,total:e.total})]})}function WM(e){const{v:t,need:n}=e,i=t.lease&&Es(t.lease,t.now),o=!!n&&n.text.toLowerCase().includes(t.t.title.toLowerCase()),c=!!n&&!!t.standing.primary;return s.jsxs("div",{className:ue("bubble-ticket",n&&"under",i&&`lease-${i}`,t.modelWait&&"model-wait"),children:[s.jsx(ny,{v:t,titled:!o,small:!!n}),s.jsx(Xw,{v:t,className:"bubble-state",asked:c,shownItem:n==null?void 0:n.item}),t.session&&s.jsx(UM,{session:t.session}),s.jsx(cy,{v:t}),s.jsx(Ow,{v:t})]})}function HM(e){const{need:t,pr:n}=e,i=Xu(t.item),o=n&&At(n.url);return s.jsxs("div",{className:"bubble-need",children:[s.jsx("span",{className:ue("t-label",t.urgent&&"urgent"),children:t.label}),s.jsx("h3",{className:"bubble-title",children:t.title}),s.jsx(_,{parts:[...i,Je(e.now-t.item.since)]}),t.item.kind==="merge"&&n&&o&&s.jsxs("a",{className:"link",href:o,target:"_blank",rel:"noreferrer",children:["Open PR #",n.number]})]})}const KM={merge:"Ready to merge",approval:"Approve it",blocked:"Blocked",stalled:"Went quiet","hitl-ready":"Yours to decide",policy:"Check a risky change",overlap:"Two agents, same files",integration:"Branches clash",model:"Waits for a model",precedent:"Touches your decision",flag:"PR or CI","tracker-settings":"Settings changed","review-limit":"Review waits",escape:"Verified, then came back"},GM=e=>e.split(`
166
+ `)[0].replace(/^[^\s:]+: /,"");function VM(e){if(e.questionId)return{kind:"question",questionId:e.questionId};const t=e.items.find(i=>i.kind!=="question");return t?{kind:"item",label:KM[t.kind]??"Needs you",title:GM(t.title),urgent:e.urgentOf(t),item:t}:{kind:"none"}}function qM(e){var S,x,$,N;const{api:t,t:n}=e,i=ay({snap:e.snap,t:n,api:t,sessions:e.sessions,attention:e.attention}),[o,c]=w.useState(null),d=sy({v:i,api:t,setForm:c,onEditHow:e.onFullTicket,onOpenChat:e.onOpenChat,onReviewChange:e.onReviewChange,onReviewBrief:e.onReviewBrief,onItem:e.onItem,onDismiss:e.onDismiss}),u=VM({questionId:(S=i.question)==null?void 0:S.id,items:i.items,urgentOf:O=>Or(O,i.interrupting.includes(O.id))==="urgent"}),f=u.kind==="question"||u.kind==="item"&&u.urgent,{onUrgent:m}=e;w.useEffect(()=>m(f),[f,m]);const g=u.kind==="question",k=g&&((x=d.primary)==null?void 0:x.id)==="answer"?{...d,primary:void 0}:d,y=O=>{var D;return(D=e.snap.tickets.find(F=>F.id===O))==null?void 0:D.key},b=(($=i.pr)==null?void 0:$.pr)&&{number:i.pr.pr.number,url:i.pr.pr.url};return s.jsxs(s.Fragment,{children:[g&&i.question&&s.jsx(Sw,{q:i.question,now:i.now,keyOf:y,onAnswer:t.actions.answer,onOpenChat:e.onOpenChat}),u.kind==="item"&&s.jsx(HM,{need:u,now:i.now,pr:b}),s.jsx(WM,{v:i,need:QM(u,(N=i.question)==null?void 0:N.text)}),s.jsx(ty,{v:i,bar:k,form:o,setForm:c,actions:t.actions,onOpenChat:e.onOpenChat,trailing:s.jsx("button",{type:"button",className:"link full-ticket",onClick:e.onFullTicket,children:"Full ticket"})})]})}function QM(e,t){if(e.kind==="item")return{text:e.title,item:e.item.title};if(e.kind==="question")return{text:t??""}}function YM(e){const{selection:t,snap:n,api:i}=e,o=gt(5e3);switch(t.kind){case"ticket":{const c=n==null?void 0:n.tickets.find(d=>d.id===t.id);return c?s.jsx(qM,{...e,snap:n,t:c},c.id):s.jsx(Te,{children:"Ticket not found."})}case"main":return n?s.jsx(iw,{mapId:n.map.id,now:o}):null;case"together":return n?s.jsxs(s.Fragment,{children:[s.jsx(YT,{text:n.map.sections.destination}),s.jsx(aw,{mapId:n.map.id,now:o,onUrgent:e.onUrgent})]}):null;case"question":{const c=i.activity.pending.find(u=>u.id===t.id);if(!c)return s.jsx(Te,{children:"Answered."});const d=u=>{var f;return(f=n==null?void 0:n.tickets.find(m=>m.id===u))==null?void 0:f.key};return s.jsx(Sw,{q:c,now:o,keyOf:d,onAnswer:i.actions.answer,onOpenChat:e.onOpenChat})}case"unspecified":return null;default:return t}}const Mg=14,$n=8;function JM(e){const{anchor:t,box:n,bubble:i}=e,o=Math.max($n,n.w-i.w-$n),c=Math.max($n,n.h-i.h-$n);if(!t)return{left:o,top:$n,side:"corner"};const d=(t.top+t.bottom)/2,u=Math.min(c,Math.max($n,d-i.h/2)),f=t.right+Mg,m=t.left-Mg-i.w;if(f+i.w<=n.w-$n)return{left:f,top:u,side:"right"};if(m>=$n)return{left:m,top:u,side:"left"};const g=n.w-t.right,k=t.left;return g>=k?{left:Math.min(f,o),top:u,side:"right"}:{left:Math.max($n,m),top:u,side:"left"}}function XM(e){const t=w.useRef(null),[n,i]=w.useState({w:0,h:0});w.useLayoutEffect(()=>{const u=t.current;if(!u||e.docked)return;const f=new ResizeObserver(()=>i({w:u.offsetWidth,h:u.offsetHeight}));return f.observe(u),()=>f.disconnect()},[e.docked]);const{onClose:o}=e;w.useEffect(()=>{const u=f=>f.key==="Escape"&&!f.defaultPrevented&&o();return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[o]);const c=JM({anchor:e.anchor,box:e.box,bubble:n}),d=e.docked?void 0:{left:c.left,top:c.top,maxHeight:e.box.h-16};return s.jsxs("section",{ref:t,className:ue("bubble",e.docked&&"docked",`side-${c.side}`,e.urgent&&"urgent"),style:d,"aria-label":e.label,children:[s.jsx("button",{type:"button",className:"bubble-close","aria-label":"Close",onClick:o,children:"×"}),e.children]})}const ZM={ticket:"Ticket",main:"Checks on main",together:"Destination",question:"Question"};function eL(e){if(e.kind==="ticket")return e.id;if(e.kind==="main")return"main";if(e.kind==="together")return"destination"}function tL(e){var g,k;const{api:t,nav:n,attn:i}=e,o=t.selection,[c,d]=w.useState(!1),u=w.useCallback(y=>d(y),[]);if(!o||o.kind==="unspecified"||n.fullTicket||!t.snap&&o.kind!=="question")return null;const f=eL(o),m=o.kind==="main"?e.mainNeeds:o.kind==="question"||c;return s.jsx(XM,{anchor:f?(g=e.place)==null?void 0:g.anchorOf(f):void 0,box:((k=e.place)==null?void 0:k.box)??{w:0,h:0},docked:!e.place,urgent:m,label:ZM[o.kind],onClose:()=>n.select(null),children:s.jsx(YM,{selection:o,snap:t.snap,api:t,sessions:e.sessions,attention:i.attention.view,onUrgent:u,onFullTicket:()=>n.setFullTicket(!0),onOpenChat:y=>n.openChat(y),onReviewChange:i.handlers.openApprovals,onReviewBrief:i.handlers.openBrief,onItem:i.open,onDismiss:i.attention.dismiss})})}const nL=["plan","activity","logbook"],hy=[{id:"map",label:"Map"},{id:"plan",label:"Plan"},{id:"activity",label:"Activity"},{id:"logbook",label:"Logbook"}];function sL(e){var g;const{api:t,rt:n,brief:i}=e,{snap:o,actions:c}=t,[d]=Yu(15e3),u=As(),f=d?y2(d):void 0,m=s.jsx(ME,{repo:e.repo,snaps:t.allSnaps,map:o==null?void 0:o.map,activity:t.activity,health:t.health,onNewTrail:e.onNewTrail,onStartOver:e.onStartOver,onArchive:c.setArchived,trackerLabel:n.adapter.label.toLowerCase(),onSelectMap:c.selectMap,onToggleMode:()=>o&&c.setMode(o.map.mode==="plan-only"?"plan+execute":"plan-only"),onSettings:e.onSettings,onToggleTheme:e.onToggleTheme,attention:e.attention,needs:s.jsx(LE,{count:e.needs.length,elsewhere:e.elsewhere.length,top:(g=e.needs[0])==null?void 0:g.title,onOpen:()=>{const k=e.needs[0]??e.elsewhere[0];k&&e.onNeed(k)}}),slackAlert:f,onSlack:e.onSlack,onStats:e.onStats,knowledge:u.attention,knowledgeOpen:u.open,onKnowledge:()=>u.setOpen(!u.open),briefingOpen:i.shown,briefingStatus:i.status,onBriefing:()=>i.shown?i.dismiss():i.open()});return e.phone?m:s.jsxs("div",{className:"app-top",children:[m,s.jsx(OE,{tabs:hy,value:e.view,onChange:e.onView})]})}function iL(e){return s.jsx(xE,{seed:e.seed,onClose:e.onClose,tracker:e.rt.adapter.label,onCreate:async t=>{const n=await _$(e.rt.adapter,t);return e.onCreated(n.id),n}})}const rL={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"},rh=e=>rL[e];function oh(e){var t;return((t=e.account)==null?void 0:t.kind)==="user"?e.account.login:void 0}const $d=e=>!!e.auth&&!!oh(e);function fy(e,t){const n=oh(e);return!e.auth||!n?void 0:`Will use ${t||"the repo you pick"} as ${n} (${rh(e.auth)})`}function oL(e){if(!e.repo)return;const t=oh(e),n=t?` as ${t}`:"",i=e.auth?`, using ${rh(e.auth)}`:"";return`Connected to ${e.repo}${n}${i}`}function aL(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 cL(e){const{gh:t}=e;if(!t.auth)return null;const n=fy(t,e.repo);return s.jsxs("div",{className:"gh-identity",children:[n&&s.jsx("span",{className:"t-body",children:n}),s.jsxs("span",{className:"gh-identity-actions",children:[s.jsx("button",{type:"button",className:"btn ghost sm",onClick:e.onUseAnother,children:"Use another token"}),t.auth==="signed-in"&&s.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 lL=/^[\w.-]+\/[\w.-]+$/;function dL(e){const t=e.query.trim().toLowerCase(),i=!!e.detected&&e.repos.every(f=>f.fullName!==e.detected)?[{fullName:e.detected,private:!1},...e.repos]:e.repos,o=[...i.filter(f=>f.fullName===e.detected),...i.filter(f=>f.fullName!==e.detected)],c=t?o.filter(f=>f.fullName.toLowerCase().includes(t)):o,u=lL.test(e.query.trim())&&c.every(f=>f.fullName.toLowerCase()!==t)?e.query.trim():void 0;return{shown:c.slice(0,e.limit),matches:c.length,typed:u}}function Lg(e){const{repo:t,listed:n}=e,i=t.private?"Private":"Public";return s.jsx(fe,{as:"li",className:"repo-row",selected:e.selected,title:s.jsx("span",{className:"t-code",children:t.fullName}),context:s.jsx(_,{parts:[e.detected&&{text:"This project's repo",strong:!0},n&&i,n&&aL(t,e.now),!n&&"Checked when you connect"]}),onOpen:e.onPick})}const uL=40;function Og(e){const[t,n]=w.useState(""),i=w.useMemo(()=>Date.now(),[]),o=w.useMemo(()=>new Set(e.repos.map(g=>g.fullName)),[e.repos]),{shown:c,matches:d,typed:u}=dL({repos:e.repos,detected:e.detected,query:t,limit:uL}),f=d>c.length?`${d-c.length} more: type to narrow`:"",m=e.truncated?`Your ${e.repos.length} most recently pushed repos`:"";return s.jsxs("div",{className:"repo-picker",children:[s.jsxs("label",{className:"field",children:["Repository",s.jsx("input",{value:t,placeholder:"Search your repos, or type owner/name",spellCheck:!1,"aria-label":"Search repositories",onChange:g=>n(g.target.value)})]}),s.jsxs("ul",{className:"repo-list","aria-label":"Repositories",children:[u&&s.jsx(Lg,{repo:{fullName:u,private:!1},detected:u===e.detected,listed:!1,selected:u===e.value,now:i,onPick:()=>e.onChange(u)}),c.map(g=>s.jsx(Lg,{repo:g,detected:g.fullName===e.detected,listed:o.has(g.fullName),selected:g.fullName===e.value,now:i,onPick:()=>e.onChange(g.fullName)},g.fullName))]}),s.jsx(_,{parts:[!d&&!u&&"No repo matches",f,m]})]})}function hL(e){const{list:t}=e;if(!t)return s.jsx(yi,{label:"Loading your repos…",rows:3,className:"picker-loading"});switch(t.kind){case"ok":return s.jsx(Og,{repos:t.repos,truncated:t.truncated,detected:t.detectedRepo??e.detected,value:e.value,onChange:e.onChange});case"no-token":return s.jsx(_,{parts:["No GitHub token found"]});case"error":return s.jsxs(s.Fragment,{children:[s.jsx(qu,{what:"Couldn't list your repos",reason:t.error,onRetry:e.onRetry}),s.jsx(Og,{repos:[],truncated:!1,detected:e.detected,value:e.value,onChange:e.onChange})]});default:return t}}const fL={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"},wr=e=>e==="github"||e==="linear";function my(e){const[t,n]=w.useState(!e.source);return e.source&&!t?s.jsxs("div",{className:"ts-auth",children:[s.jsx("span",{className:"mono-label",children:e.label}),s.jsx("span",{className:"pill on",children:fL[e.source]}),s.jsx("button",{type:"button",className:"btn ghost sm",onClick:()=>n(!0),children:"Use another"})]}):s.jsxs("label",{className:"field",children:[s.jsxs("span",{className:"ts-label",children:[e.label,e.link&&s.jsx("a",{href:e.link.href,target:"_blank",rel:"noreferrer",children:e.link.text})]}),s.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,value:e.value,placeholder:e.placeholder,onChange:i=>e.onChange(i.target.value)})]})}function mL(e){const[t,n]=w.useState(!1),i=()=>{var o;return void((o=navigator.clipboard)==null?void 0:o.writeText(e.code).then(()=>n(!0),()=>{}))};return s.jsxs("div",{className:"gh-device",children:[s.jsx("span",{className:"t-label",children:"Enter this code on GitHub"}),s.jsxs("div",{className:"gh-device-row",children:[s.jsx("code",{className:"gh-device-code t-code","aria-label":"Your code",children:e.code}),s.jsx(R,{size:"sm",variant:"ghost",onClick:i,children:t?"Copied":"Copy"})]}),s.jsxs("div",{className:"gh-device-row",children:[s.jsx("a",{className:"btn primary",href:At(e.href),target:"_blank",rel:"noreferrer",onClick:i,children:"Open GitHub"}),s.jsx(R,{size:"sm",variant:"ghost",onClick:e.onCancel,children:"Cancel"})]}),s.jsx(yi,{label:"Waiting for you to approve on GitHub…"})]})}function pL(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 gL(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 Vt=ZN(re());function yr(e,t){e({tracker:t});const n=new URL(location.href);n.searchParams.delete("tracker"),location.href=n.toString()}function kL(e){const[t,n]=w.useState({kind:"idle"}),i=w.useRef(e);i.current=e;const o=t.kind==="code";return w.useEffect(()=>{if(t.kind!=="code")return;let c=!0;const d=setTimeout(()=>void Vt.githubSignIn.poll().then(async u=>{c&&(u.kind==="signed-in"&&await i.current(),c&&n(gL(t,u)))},u=>c&&n({kind:"ended",reason:u.message})),Math.max(t.interval,1)*1e3);return()=>{c=!1,clearTimeout(d)}},[t]),w.useEffect(()=>{if(o)return()=>void Vt.githubSignIn.cancel().catch(()=>{})},[o]),{state:t,start(){n({kind:"starting"}),Vt.githubSignIn.start().then(c=>n(pL(c)),c=>n({kind:"ended",reason:c.message}))},cancel(){n({kind:"idle"})}}}function vL(e){const{state:t,start:n,cancel:i}=kL(e.onSignedIn);switch(t.kind){case"idle":return s.jsxs("div",{className:"gh-sign-in",children:[s.jsx(R,{variant:"primary",onClick:n,children:"Sign in with GitHub"}),s.jsx(_,{parts:["No gh login or token needed","the token stays on this machine"]}),s.jsx(_,{parts:["GitHub asks for access to your repos: it has no narrower scope for issues in private repos"]})]});case"starting":return s.jsx(yi,{label:"Asking GitHub for a code…"});case"code":return s.jsx(mL,{code:t.userCode,href:t.verificationUri,onCancel:i});case"ended":return s.jsxs("div",{className:"gh-sign-in",children:[s.jsx(R,{onClick:n,children:"Try again"}),s.jsx(_,{parts:["Didn't sign in",t.reason]})]});default:return t}}function wL(e){var d,u;const{gh:t}=e,n=t.auth&&((d=t.account)==null?void 0:d.kind)==="unknown"?`Found ${rh(t.auth)}, but GitHub didn't accept it`:"",i=((u=t.account)==null?void 0:u.kind)==="unknown"?t.account.error:"",o=t.auth==="GITHUB_TOKEN"||t.auth==="GH_TOKEN",c=t.signIn.available&&!o;return s.jsxs(s.Fragment,{children:[n&&s.jsx(_,{parts:[n,i]}),c&&s.jsx(vL,{onSignedIn:e.onSignedIn}),c&&s.jsx("span",{className:"t-label gh-or",children:"Or paste a token"}),s.jsx(my,{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"}}),s.jsxs("span",{className:"t-meta",children:["Or run ",s.jsx("code",{className:"t-code",children:"gh auth login"})," in a terminal; this finds it in a few seconds."]}),s.jsxs("label",{className:"field",children:["Repository",s.jsx("input",{value:e.repo,placeholder:"owner/name",spellCheck:!1,onChange:f=>e.onRepo(f.target.value.trim())})]})]})}function py({r:e}){var i,o;if(!e)return null;if(!e.ok)return s.jsxs("div",{className:"test-line alert",children:["✕ ",e.error]});const t=(i=e.rate)!=null&&i.limit?`${(o=e.rate.remaining)==null?void 0:o.toLocaleString()}/${e.rate.limit.toLocaleString()} req`:"";let n="";return e.canWrite===!1?n="read-only":e.canWrite&&(n="read/write"),s.jsxs("div",{className:"test-line ok",children:["✓ ",[e.account,e.target,n,t].filter(Boolean).join(" · ")]})}function ah(e){const[t,n]=w.useState(),[i,o]=w.useState(0);w.useEffect(()=>{if(n(void 0),!e.enabled)return;let d=!0;return e.load().then(u=>d&&n(u),u=>d&&n(e.failed(u.message))),()=>{d=!1}},[e.enabled,e.key,i]);const c=w.useCallback(()=>o(d=>d+1),[]);return{value:t,retry:c}}function yL(e){const{value:t,retry:n}=ah({enabled:e.enabled,key:e.auth??"",load:()=>Vt.githubRepos(),failed:i=>({kind:"error",error:i})});return{list:t,retry:n}}function gy(e){const t=e.s.github,n=$d(t),[i,o]=w.useState(!n),[c,d]=w.useState(t.repo??t.detectedRepo??""),[u,f]=w.useState(""),[m,g]=w.useState(),[k,y]=w.useState(!1),{list:b,retry:S}=yL({enabled:!i,auth:t.auth});w.useEffect(()=>{n&&!u&&o(!1)},[n]);const x=async()=>{y(!0),g(void 0);try{await Vt.connect({active:"github",github:{repo:c,token:i?u:void 0}}),e.onConnected()}catch(F){g({ok:!1,error:F.message}),y(!1)}},$=async()=>{const F=await e.reload();F&&$d(F.github)&&o(!1)},N=async()=>{await Vt.githubSignIn.signOut().catch(()=>{});const F=await e.reload();o(!F||!$d(F.github))},D=!!c&&!(!i&&!b)&&(!i||!!u||n);return s.jsxs("div",{className:"card inset tracker-setup",children:[i?s.jsx(wL,{gh:t,token:u,onToken:f,repo:c,onRepo:d,onSignedIn:$}):s.jsxs(s.Fragment,{children:[s.jsx(cL,{gh:t,repo:c,onUseAnother:()=>o(!0),onSignOut:()=>void N()}),s.jsx(hL,{list:b,detected:t.detectedRepo,value:c,onChange:d,onRetry:S})]}),s.jsx(py,{r:m}),s.jsx("footer",{children:s.jsx("button",{type:"button",className:"btn primary",disabled:k||!D,onClick:()=>void x(),children:k?"Connecting…":"Connect"})})]})}function xL(e){return e.line?s.jsxs("div",{className:"gh-identity",children:[s.jsxs("div",{className:"ln-who",children:[s.jsx("span",{className:"t-body",children:e.line}),e.email&&s.jsx(_,{parts:[e.email]})]}),e.onUseAnother&&s.jsx("button",{type:"button",className:"btn ghost sm",onClick:e.onUseAnother,children:"Use another key"})]}):null}const jL={LINEAR_API_KEY:"LINEAR_API_KEY",stored:"a saved key"},ch=e=>jL[e]??e;function ac(e){return(e==null?void 0:e.kind)==="user"?e:void 0}const bL=e=>!!e.auth&&!!ac(e.viewer);function ky(e,t){if(e)return t?`${e} / ${t}`:e}function vy(e){const t=ac(e.viewer);if(!t)return;const n=ky(e.team,e.project)??"the team you pick",i=e.source?` (${ch(e.source)})`:"";return`Will use ${n} in ${t.orgName} as ${t.name}${i}`}function SL(e){const t=ky(e.teamName??e.teamKey,e.projectName);if(!e.teamId||!t)return;const n=ac(e.viewer),i=e.orgName??(n==null?void 0:n.orgName),o=i?` in ${i}`:"",c=n?` as ${n.name}`:"",d=e.auth?`, using ${ch(e.auth)}`:"";return`Connected to ${t}${o}${c}${d}`}function NL(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 $L(e){var o,c;const{ln:t}=e,n=t.auth&&((o=t.viewer)==null?void 0:o.kind)==="unknown"?`Found ${ch(t.auth)}, but Linear didn't accept it`:"",i=((c=t.viewer)==null?void 0:c.kind)==="unknown"?t.viewer.error:"";return s.jsxs(s.Fragment,{children:[n&&s.jsx(_,{parts:[n,i]}),s.jsx(my,{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"}}),s.jsxs("span",{className:"t-meta",children:["Or set ",s.jsx("code",{className:"t-code",children:"LINEAR_API_KEY"})," before starting Teamtrail."]})]})}function CL(e){const{list:t}=e;if(!t)return s.jsx(yi,{label:"Loading projects…"});if(t.kind==="error")return s.jsx(qu,{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(i=>({value:i.id,label:i.state?`${i.name} · ${i.state}`:i.name}))];return s.jsxs("label",{className:"field",children:["Project (optional)",s.jsx(it,{"aria-label":"Project",value:e.value,onChange:e.onChange,options:n})]})}function TL(e){const t=e.query.trim().toLowerCase(),n=t?e.teams.filter(i=>i.key.toLowerCase().includes(t)||i.name.toLowerCase().includes(t)):e.teams;return{shown:n.slice(0,e.limit),matches:n.length}}function EL(e,t){return t&&e.some(n=>n.id===t)?t:e.length===1?e[0].id:void 0}function AL(e){const{team:t}=e;return s.jsx(fe,{as:"li",className:"repo-row team-row",selected:e.selected,title:t.name,context:s.jsx(_,{parts:[{text:t.key,code:!0},NL(t,e.now)]}),onOpen:e.onPick})}const IL=40;function RL(e){const[t,n]=w.useState(""),i=w.useMemo(()=>Date.now(),[]),{shown:o,matches:c}=TL({teams:e.teams,query:t,limit:IL}),d=c>o.length?`${c-o.length} more: type to narrow`:"",u=e.truncated?`The first ${e.teams.length} teams`:"",f=e.value?"":"Pick the team your trails go in";return s.jsxs("div",{className:"repo-picker",children:[s.jsxs("label",{className:"field",children:["Team",s.jsx("input",{value:t,placeholder:"Search your teams by key or name",spellCheck:!1,"aria-label":"Search teams",onChange:m=>n(m.target.value)})]}),s.jsx("ul",{className:"repo-list","aria-label":"Teams",children:o.map(m=>s.jsx(AL,{team:m,selected:m.id===e.value,now:i,onPick:()=>e.onChange(m.id)},m.id))}),s.jsx(_,{parts:[!c&&"No team matches",f,d,u]})]})}function ML(e){const{list:t}=e;if(!t)return s.jsx(yi,{label:"Loading teams…",rows:3,className:"picker-loading"});switch(t.kind){case"ok":return s.jsx(RL,{teams:t.teams,truncated:t.truncated,value:e.value,onChange:e.onChange});case"no-key":return s.jsx(_,{parts:["Paste a Linear API key to list your teams"]});case"error":return s.jsx(qu,{what:"Couldn't list your teams",reason:t.error,onRetry:e.onRetry});default:return t}}function LL(e,t){const[n,i]=w.useState(e);return w.useEffect(()=>{const o=setTimeout(()=>i(e),t);return()=>clearTimeout(o)},[e,t]),n}function OL(e){const{value:t,retry:n}=ah({enabled:e.enabled&&!!e.teamId,key:`${e.teamId}
167
+ ${e.apiKey??""}`,load:()=>Vt.linearProjects(e.teamId,e.apiKey),failed:i=>({kind:"error",error:i})});return{list:t,retry:n}}function PL(e){const{value:t,retry:n}=ah({enabled:e.enabled,key:e.apiKey??"",load:()=>Vt.linearTeams(e.apiKey),failed:i=>({kind:"error",error:i})});return{list:t,retry:n}}function DL(e){const t=LL(e.apiKey.trim(),400),n=e.paste&&t?t:void 0,i=e.paste?!!t:!!e.ln.auth,o=PL({enabled:i,apiKey:n}),c=OL({teamId:e.teamId,apiKey:n,enabled:i}),d=o.list,u=c.list,f=(d==null?void 0:d.kind)==="ok"?d.teams:[],m=i&&!d,g=i&&!!e.teamId&&!u;return{enabled:i,list:d,teams:f,projects:u,loading:m||g,retryTeams:o.retry,retryProjects:c.retry}}function wy(e){var be;const t=e.s.linear,n=bL(t),[i,o]=w.useState(!n),[c,d]=w.useState(""),[u,f]=w.useState(t.teamId??""),[m,g]=w.useState(t.projectId??""),[k,y]=w.useState(),[b,S]=w.useState(!1),{enabled:x,list:$,teams:N,projects:O,loading:D,retryTeams:F,retryProjects:K}=DL({ln:t,paste:i,apiKey:c,teamId:u});w.useEffect(()=>{n&&!c&&o(!1)},[n]),w.useEffect(()=>{($==null?void 0:$.kind)==="ok"&&f(EL($.teams,t.teamId)??"")},[$]);const I=N.find(ae=>ae.id===u),Q=(O==null?void 0:O.kind)==="ok"?O.projects.find(ae=>ae.id===m):void 0,Z=($==null?void 0:$.kind)==="ok"?$.viewer:t.viewer,q=i?null:t.auth,ee=vy({viewer:Z,team:I==null?void 0:I.name,project:Q==null?void 0:Q.name,source:q}),Se=async()=>{if(I){S(!0),y(void 0);try{await Vt.connect({active:"linear",linear:{teamId:I.id,teamKey:I.key,teamName:I.name,projectId:Q==null?void 0:Q.id,projectName:Q==null?void 0:Q.name,apiKey:i?c.trim():void 0}}),e.onConnected()}catch(ae){y({ok:!1,error:ae.message}),S(!1)}}},ve=ae=>{f(ae),g("")};return s.jsxs("div",{className:"card inset tracker-setup linear-setup",children:[i&&s.jsx($L,{ln:t,apiKey:c,onKey:d}),s.jsx(xL,{line:ee,email:(be=ac(Z))==null?void 0:be.email,onUseAnother:i?void 0:()=>o(!0)}),x&&s.jsx(ML,{list:$,value:u,onChange:ve,onRetry:F}),I&&s.jsx(CL,{list:O,value:m,onChange:g,onRetry:K}),s.jsx(py,{r:k}),s.jsx("footer",{children:s.jsx("button",{type:"button",className:"btn primary",disabled:b||D||!I,onClick:()=>void Se(),children:b?"Connecting…":"Connect"})})]})}function _L(e){return s.jsxs("div",{className:"c-actions",children:[e.canSwitch&&s.jsx("button",{className:"btn sm",disabled:!e.usable,onClick:e.onSwitch,children:"Switch"}),e.remote&&s.jsx("button",{className:`btn sm ${e.open?"on":""}`,disabled:!e.usable,onClick:e.onToggle,children:e.configured?"Edit":"Connect"})]})}function BL(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 FL(e){const{id:t,active:n,s:i}=e,o=wr(t),c=n&&i?zL(t,i):void 0;return c&&o?s.jsxs(s.Fragment,{children:[s.jsx(_,{className:"c-who",parts:[c]}),s.jsx(_,{className:"c-trust",parts:BL(t)})]}):c?s.jsx(_,{className:"c-who",parts:[c]}):n&&(t==="markdown"||o)?s.jsx("div",{className:"c-loc",children:e.location}):o&&e.configured&&i?s.jsx("div",{className:"c-loc",children:UL(t,i)}):null}function zL(e,t){if(e==="github")return oL(t.github);if(e==="linear")return SL(t.linear)}function UL(e,t){return e==="github"?t.github.repo:[t.linear.teamKey,t.linear.projectName].filter(Boolean).join(" · ")}function WL({status:e}){var c,d;if(!e)return null;const t=(c=e.rate)!=null&&c.limit?`${((d=e.rate.remaining)==null?void 0:d.toLocaleString())??"?"}/${e.rate.limit.toLocaleString()} req`:"",n=e.queued?` · ${e.queued} queued`:"",[i,o]=HL(e,n);return s.jsxs("div",{className:`sync-line ${i}`,title:e.error,children:[s.jsx("span",{className:"dot"}),s.jsx("span",{children:o}),t&&s.jsx("span",{className:"rate",children:t})]})}function HL(e,t){switch(e.state){case"online":return["ok",`Online · synced ${Iv(e.lastSyncAt)}${t}`];case"offline":return["warn",`Offline${t}`];case"rate-limited":return["warn",`Rate limited · resumes ${os(e.resetAt)}${t}`];case"auth-error":return["alert",`Credentials rejected${t}`];default:return["",`Connecting${t}`]}}function KL(e){const{id:t,active:n,configured:i,s:o}=e,c=wr(t),d=!c||!!o,u=["card connector",n?"active":"",d?"":"disabled",e.open?"open":""];return s.jsxs("div",{className:u.join(" "),children:[s.jsxs("div",{className:"card-row",children:[s.jsx("b",{className:"choice-title t-row-title",children:e.name}),n&&s.jsx("span",{className:"pill on",children:"Active"})]}),s.jsx(FL,{id:t,active:n,configured:i,location:e.location,s:o}),c&&n&&s.jsx(WL,{status:o==null?void 0:o[t].status}),s.jsx(_L,{canSwitch:!n&&(!c||i),remote:c,usable:d,configured:i,open:e.open,onSwitch:e.onSwitch,onToggle:e.onToggle})]})}function yy(e=0){const[t,n]=w.useState(),i=w.useCallback(()=>Vt.get().then(o=>(n(o),o),()=>(n(null),void 0)),[]);return w.useEffect(()=>{if(i(),!e)return;const o=setInterval(()=>void i(),e);return()=>clearInterval(o)},[i,e]),[t,n,i]}function GL(e){const[t,,n]=yy(5e3),[i,o]=w.useState(null),c=async u=>{t&&(u==="markdown"||wr(u))&&await Vt.connect({active:u==="markdown"?"markdown":u,...u==="github"&&t.github.repo?{github:{repo:t.github.repo}}:{},...u==="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(()=>{}),yr(e.update,u)},d=w.useMemo(()=>({github:!!(t!=null&&t.github.repo),linear:!!(t!=null&&t.linear.teamId)}),[t]);return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"connectors",children:e1.map(u=>{const f=u.id;return s.jsx(KL,{id:f,name:u.name,active:f===e.activeTracker,configured:wr(f)&&d[f],open:i===f,location:e.location,s:t,onSwitch:()=>void c(f),onToggle:()=>wr(f)&&o(i===f?null:f)},u.id)})}),t&&i==="github"&&s.jsx(gy,{s:t,reload:n,onConnected:()=>yr(e.update,"github")}),t&&i==="linear"&&s.jsx(wy,{s:t,onConnected:()=>yr(e.update,"linear")})]})}function VL(e,t){const n=e==null?void 0:e.github,i=e==null?void 0:e.linear,o=n&&t!=="github"?fy(n,n.repo??n.detectedRepo):void 0,c=i&&t!=="linear"?vy({viewer:i.viewer,team:i.teamName,project:i.projectName,source:i.auth}):void 0;return[{id:"markdown",title:"Local markdown",sub:"Files in .teamtrail/ in this repo"},{id:"github",title:"GitHub Issues",sub:o??"Trails as labelled issues in your repo"},{id:"linear",title:"Linear",sub:c??"Trails and tickets in your Linear team"}]}function xy(e){const t=[{v:"summary",title:"Summary"},{v:"full",title:"Full transcript"}];return s.jsx("div",{className:"choice-row",children:t.map(n=>s.jsx(at,{on:e.value===n.v,title:n.title,onClick:()=>e.onChange(n.v)},n.v))})}const qL={github:"Checking for a GitHub login…",linear:"Checking for a Linear key…"};function QL(e){var $;const{prefs:t,update:n}=e,[i,,o]=yy(5e3),[c,d]=w.useState(!1),u=($=i==null?void 0:i.pending)==null?void 0:$.target.split(":")[0],[f,m]=w.useState(!1);w.useEffect(()=>{u&&!f&&t.tracker!==u&&n({tracker:u})},[u,f,t.tracker,n]);const g=VL(i??void 0,t.tracker),k=t.tracker==="github"||t.tracker==="linear",y=k&&(i==null?void 0:i.active)===t.tracker,b=k&&!y,S=N=>{n({onboarded:!0}),yr(n,N)},x=async()=>{d(!0);const N=i&&!i.pending;t.tracker==="markdown"&&N&&await Vt.connect({active:"markdown"}).catch(()=>{}),n({onboarded:!0}),t.tracker!==e.activeTracker&&yr(n,t.tracker)};return s.jsx("div",{className:"scrim",children:s.jsxs(Be,{as:"div",className:"dialog onboarding",children:[s.jsx("div",{className:"onb-brand",children:s.jsx(Za,{className:"onb-title"})}),s.jsxs("h2",{className:"onb-question t-heading",children:[s.jsx(kT,{className:"voice-badge",size:22}),"Where should your trails live?"]}),s.jsxs(Ae,{title:"Tracker",children:[s.jsx("div",{className:"choice-row",children:g.map(N=>s.jsx(at,{on:t.tracker===N.id,title:N.title,sub:N.sub,onClick:()=>(m(!0),n({tracker:N.id}))},N.id))}),(i==null?void 0:i.pending)&&s.jsxs("p",{className:"t-meta onb-repo-tracker",children:["This repo keeps its trails in ",i.pending.label,". Connect it here, or keep local files on this machine; the team's choice in the repo isn't changed either way."]}),i===void 0&&k&&s.jsx(yi,{label:qL[t.tracker]??"Checking…"}),i&&t.tracker==="github"&&!y&&s.jsx(gy,{s:i,reload:o,onConnected:()=>S("github")}),i&&t.tracker==="linear"&&!y&&s.jsx(wy,{s:i,onConnected:()=>S("linear")})]}),s.jsx(Ae,{title:"HITL transcript",children:s.jsx(xy,{value:t.hitlTranscript,onChange:N=>n({hitlTranscript:N})})}),s.jsx("footer",{children:s.jsx(R,{variant:"primary",disabled:c||b,onClick:()=>void x(),children:"Get started"})})]})})}function YL(e){var t;return(t=pt())!=null&&t.tracker?null:s.jsx(QL,{...e})}const $r=[{id:"trail",label:"This trail",intro:"How agents work on the trail on screen: its mode, the checks that prove work done, the gates, diff rules, models and guides.",sections:[{id:"mode",title:"Trail mode"},{id:"verification",title:"Verification"},{id:"gates",title:"Gates"},{id:"rules",title:"Diff rules"},{id:"models",title:"Model matching"},{id:"trail-guides",title:"Guides by type"}]},{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 lh(e){if(e===null)return null;const t=$r.find(o=>o.id===e);if(t)return{group:t.id};const n=$r.find(o=>o.sections.some(c=>c.id===e));if(!n)return{};const i=n.sections.find(o=>o.id===e);return{group:n.id,section:i==null?void 0:i.id}}function JL(e,t){const n=new URL(e);return n.searchParams.set("when",t.when.join(",")),n.searchParams.set("why",t.why),n.toString()}function XL(e,t){var i;const n=String((i=lh("rules"))==null?void 0:i.section)==="rules";e(n?"rules":"verification"),history.replaceState(history.state,"",JL(location.href,t))}function ZL(){return s.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 ",J.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 Pg={from:"18:00",to:"09:00"};function eO(e){const t=e.focus!==void 0,n=e.focus??Pg;return s.jsxs("div",{className:"att-settings-row set-field",children:[s.jsx("span",{className:"set-field-label",children:"Quiet hours"}),s.jsx(R,{size:"sm",on:t,"aria-pressed":t,onClick:()=>e.onChange(t?void 0:Pg),children:t?"On":"Off"}),t&&s.jsxs(s.Fragment,{children:[s.jsx("input",{type:"time","aria-label":"Quiet from",value:n.from,onChange:i=>i.target.value&&e.onChange({...n,from:i.target.value})}),s.jsx("span",{className:"t-meta",children:"to"}),s.jsx("input",{type:"time","aria-label":"Quiet until",value:n.to,onChange:i=>i.target.value&&e.onChange({...n,to:i.target.value})})]})]})}const Cd=[3,5,8,12];function tO(e){const t=e&&!Cd.includes(e)?[...Cd,e].sort((n,i)=>n-i):Cd;return[{value:"off",label:"Off"},...t.map(n=>({value:String(n),label:`${n} waiting`}))]}const Dg=e=>`${e} finished ticket${e===1?"":"s"}`;function nO(e,t){const n=(e==null?void 0:e.waiting.length)??0;return t?e!=null&&e.full?`${Dg(n)} wait: agents start no new implementation work until you review some.`:`${n} of ${t} waiting: agents start new work.`:n?`${Dg(n)} wait for your review now.`:"Nothing waits for your review now."}function sO(e){const{limit:t,review:n}=e;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"att-settings-row set-field",children:[s.jsx("span",{className:"set-field-label",children:"Review limit"}),s.jsx(it,{compact:!0,"aria-label":"Review limit",value:t?String(t):"off",options:tO(t),disabled:e.local===!1,onChange:i=>e.onChange(i==="off"?null:Number(i))})]}),s.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. ",nO(n,t)]})]})}const iO=[{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 rO(){typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()}function oO(){const{view:e,error:t,savePrefs:n,saveReviewLimit:i}=yw(0),o=ji();if(!e)return null;const c=e.policy.value,d=`${J.dataDir}/attention.json`,u=m=>void n({...e.prefs,...m}),f=typeof Notification<"u"&&Notification.permission==="denied";return s.jsxs(Ae,{title:"Attention",children:[s.jsxs("p",{className:"vf-intro",children:["Everything that needs you is ranked in Waiting on you. Only items scoring ",c.interrupt," or more interrupt you; the rest wait in the queue, and Slack gets them in a digest."]}),s.jsxs("div",{className:"att-settings-row set-field",children:[s.jsx("span",{className:"set-field-label",children:"Interrupt me by"}),s.jsx(it,{compact:!0,"aria-label":"Interrupt me by",value:e.prefs.channel,options:iO,onChange:m=>{m==="browser"&&rO(),u({channel:m})}})]}),e.prefs.channel==="browser"&&f&&s.jsx("span",{className:"vf-err",children:"The browser blocks notifications for this page. Allow them in its site settings."}),s.jsx(eO,{focus:e.prefs.focus,onChange:m=>u({focus:m})}),s.jsx("span",{className:"set-hint t-meta",children:"Your channel and quiet hours stay on this machine."}),s.jsx(sO,{limit:c.reviewLimit,review:e.review,local:o,onChange:m=>void i(m)}),e.policy.errors.length>0&&s.jsx("ul",{className:"vf-errors",children:e.policy.errors.map(m=>s.jsxs("li",{children:[d,": ",m]},m))}),s.jsx(_,{className:"set-hint",parts:[e.policy.exists?{text:d,code:!0}:"Team defaults",`interrupt at ${c.interrupt}`,c.digestMinutes?`Slack digest every ${c.digestMinutes} min`:"Slack digest off",c.reviewLimit?`review limit ${c.reviewLimit}`:"review limit off"]}),t&&s.jsx("span",{className:"vf-err",children:t})]})}const aO=[5,15,30,60];function cO(e){const{value:t}=e;return s.jsxs("div",{className:"choice-row compact",children:[s.jsx(at,{on:!t.enabled,title:"Off",onClick:()=>e.onChange({...t,enabled:!1})}),aO.map(n=>s.jsx(at,{on:t.enabled&&t.awayMinutes===n,title:`Away ${n} min`,onClick:()=>e.onChange({enabled:!0,awayMinutes:n})},n))]})}const lO={repo:"Committed to the repo",machine:"Only on this machine",browser:"Only in this browser"};function He(e){const t=e.storage&&lO[e.storage];return s.jsxs("div",{className:"sp-slot",id:`settings-${e.id}`,children:[e.children,t&&s.jsx(_,{className:"sp-where",parts:[t]})]})}function dO(e){const[t]=Yu();return t?s.jsx(Ae,{title:"Slack",children:s.jsx(w2,{focus:e.focus})}):null}function uO({data:e,route:t}){return s.jsxs(s.Fragment,{children:[s.jsx(He,{id:"attention",storage:"repo",children:s.jsx(oO,{})}),s.jsx(He,{id:"slack",storage:"machine",children:s.jsx(dO,{focus:t.section==="slack"})}),s.jsx(He,{id:"trip-report",storage:"browser",children:s.jsx(Ae,{title:"Trip report",children:s.jsx(cO,{value:e.prefs.briefing,onChange:n=>e.update({briefing:n})})})})]})}const hO=[{version:"0.55.2",date:"2026-11-16",items:["Teamtrail Cloud: the agents menu says which model your agents are working on"]},{version:"0.55.1",date:"2026-11-16",items:["Teamtrail Cloud: Get started ticks off your trail and your agents as soon as you start them"]},{version:"0.55.0",date:"2026-11-16",items:["A finished trail looks finished: the stretches you walked turn solid green, and a flag stands where the X was","Destination reached, once per trail, with a way to the pull requests still waiting to be merged","Done but not verified stays honest: a grey flag, and how many tickets were closed without a verified proof"]},{version:"0.54.0",date:"2026-11-16",items:["When discovery ends, the Lookout tells you research is done and opens the brief for your review","A brief waiting for your review counts in Waiting on you","Tickets held until you accept the brief show as waiting on it, on the map and in Up next, not as ready"]},{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"]}],fO=[{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"]},{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"]}],mO=[{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"]},{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"]}],pO=[{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"]},{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"]},...mO],gO=[{area:"Teamtrail Cloud",items:["The Lookout as an app on your phone, with a nudge only for the calls that need you"]}],kO=[{version:"0.64.2",date:"2026-11-18",items:["Two trails with the same title no longer share a folder"]},{version:"0.64.1",date:"2026-11-18",items:["Fix: what you open while the Lookout is still loading stays open; what needs you no longer opens over it on its own","Fix: changing a gate twice in quick succession no longer refuses the second change as stale"]},{version:"0.64.0",date:"2026-11-18",items:["New trail is a large editor: the destination and notes can be whole markdown documents, with Write and Preview, full screen on a phone","Load from file (or drop one on the field) puts a .md or .txt file in the destination or notes, to edit before you create","Assumptions are one per line, and the dialog says how many it will create","The header keeps the destination to its first sentence; Plan → Destination and Notes show them in full, as markdown"]},{version:"0.63.1",date:"2026-11-18",items:["At night, trail cards stand out from the map: a raised grey card, its chips in darker wells"]},{version:"0.63.0",date:"2026-11-18",items:["Tickets read as their agents wrote them: lists, bold, code and links, in the bubble and the full ticket","Every ticket has the same shape: its title and chips (state, agent and model, verified, risk), then What, Acceptance criteria, How, Progress, Proof and History, and its actions at the end","Merge anyway shows only on done work with something to merge, never on a research ticket","A ticket that needs you says so in red, says what is asked, and its first button does it; in the dark theme, the ticket and menus sit on a lighter sheet over the map"]},{version:"0.62.0",date:"2026-11-18",items:["Map, Plan, Activity and Logbook sit in a bar of their own under the header","The map runs a chain of tickets in a straight line, from main to the destination, with a review beside the ticket it reviews","Legend has a background, like Fit"]},{version:"0.61.2",date:"2026-11-18",items:["Went without a diff rule by mistake? Undo it in the ticket, and the rule asks again on the next completion","Where a ticket's work started is kept on your machine, not in the repo, so an agent can't move it to slip a change past the check guard","In Teamtrail Cloud, a trail is checked on exactly the commit Teamtrail names on main"]},{version:"0.61.1",date:"2026-11-18",items:["A trail with many tickets side by side lays them out in a grid, in order of number, instead of one tall column"]},{version:"0.61.0",date:"2026-11-18",items:["A pass counts only when the work didn't change what the check runs, skip or delete tests, or pass only on a retry","A trail is verified only when your checks pass again on main with every ticket merged","Reviews go first to an agent on another model, and rules you write ask agents about the files they touch","Settings → This trail → Gates: try each gate in Observe first; the scorecard shows verified work that came back"]},{version:"0.60.0",date:"2026-11-17",items:["The map takes the page: click a ticket and a bubble opens beside it, with what it needs from you first, then the ticket","Under the map, the trail bar: every ticket at a glance, what needs you, and More for agents at work and what is next","Cards move while something happens: waiting for an agent, an agent at work with its model and step, a halo when it needs you","Plan, Activity and the Logbook are pages of their own, from the tabs in the header"]},{version:"0.59.4",date:"2026-11-17",items:["A check that fails only as it already does on main no longer sends the first completion back for rework when an acceptance criterion names it","Where Teamtrail merges pull requests, a done ticket that isn't verified offers Merge anyway: why in one line, one question, and it's kept as your decision","A done ticket whose pull request is still open shows in your queue as ready to merge"]},{version:"0.59.3",date:"2026-11-17",items:["Checks on main find the dependencies of a package folder with its own install, like apps/web/node_modules","An agent held by checks failing on main tells you to choose in the Lookout, instead of asking you a question"]},{version:"0.59.2",date:"2026-11-17",items:["Settings → Verification reads calmer: one line per check, a warning under its command with the fix one click away, and Save apart"]},{version:"0.59.1",date:"2026-11-17",items:["A check like `npm web:lint`, a command npm doesn't have, is now flagged, with `npm run web:lint` suggested"]},{version:"0.59.0",date:"2026-11-17",items:["A check that can't pass in your repo no longer strands a ticket: Accept without it, with your reason. The other checks run again, the proof shows who skipped it and why, and Undo puts it back","Setting or approving checks now says which ones can't run as your repo is (a missing script, no go.mod, a missing make target), with Remove check or Keep anyway"]},{version:"0.58.0",date:"2026-11-17",items:["Before agents build, the approved checks run once on the default branch, so a check already failing on main is known before any agent is blamed for it","When one fails, the trail waits for your call: fix main first, drop that check for the trail, or start anyway. Each can be undone","After Start anyway, a completion that fails only in those checks, the same way, isn’t sent back, and its proof marks them as known failures, not verified","Run checks on main again any time, from the trail at a glance or Settings → Verification"]},{version:"0.57.0",date:"2026-11-17",items:["A ticket says where it stands first: who has it, or what it waits on, with the one thing to do next as a button","Every ticket action sits in one bar under it; the rest of the ticket reads as What, How, Progress, Proof and History, with details a click away","With no ticket selected, Trail step shows the trail at a glance: its phase, what waits on you, what each agent is on, and what is ready next"]},{version:"0.56.0",date:"2026-11-17",items:["Guides come with the ticket type: the architect on research, junctions and prototypes, QA and security on tasks, the reviewer on reviews. Change them per trail in Settings → Guides by type, your own guides included","A ticket can take several guides: add or remove one for that ticket alone in the inspector","A guide you add while an agent works reaches it at its next report, and its checklist counts at completion"]},...hO,...fO,...pO];function vO(){return s.jsxs("div",{className:"changelog",children:[s.jsxs("div",{className:"about",children:[s.jsx(Za,{className:"about-name"}),s.jsx("span",{className:"mono-label",children:J.category}),s.jsx("p",{className:"onb-tagline",children:J.tagline}),s.jsx(_,{parts:[J.assistant.name]})]}),s.jsx(Ae,{title:"Next",children:gO.map(e=>s.jsxs("div",{className:"cl-row",children:[s.jsx("span",{className:"mono-label",children:e.area}),s.jsx("ul",{children:e.items.map(t=>s.jsx("li",{children:t},t))})]},e.area))}),kO.map(e=>s.jsx(Ae,{title:`${e.version} · ${e.date}`,children:s.jsx("ul",{children:e.items.map(t=>s.jsx("li",{children:t},t))})},e.version))]})}const _g={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"},Bg={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 jy(e){return e.kind==="state"?wO(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 wO(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 yO="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 xO(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 jO=["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 bO(e){const{queue:t}=e;return s.jsx(fe,{as:"li",className:"ap-row",edge:"attention",title:`${t.writes} tracker writes queued before the upgrade`,context:s.jsx(_,{parts:[`For ${t.targets.join(", ")}`]}),below:s.jsxs("div",{className:"ap-below",children:[s.jsx("pre",{className:"ap-lines t-code",children:t.labels.join(`
168
+ `)}),s.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&&s.jsxs("div",{className:"ap-actions",children:[s.jsx(R,{size:"sm",disabled:e.busy,onClick:()=>e.onDecide(!0),children:"Send them"}),s.jsx(R,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>e.onDecide(!1),children:"Discard"})]})]})})}function SO(e){return s.jsxs("div",{className:"ap-below",children:[s.jsxs("p",{className:"t-meta",children:["Delete ",e.files.join(", "),"? Nobody signed them on this machine; git still has them."]}),s.jsxs("div",{className:"ap-actions",children:[s.jsxs(R,{size:"sm",variant:"ghost",disabled:e.busy,onClick:e.onDelete,children:["Delete ",e.files.length===1?"it":`all ${e.files.length}`]}),s.jsx(R,{size:"sm",disabled:e.busy,onClick:e.onCancel,children:"Keep"})]})]})}const NO=e=>e.files??(e.file?[e.file]:[]);function $O(e){const{item:t}=e,[n,i]=w.useState(!1),o=NO(t),c=t.revert??"restore";return s.jsx(fe,{as:"li",className:"ap-row",edge:"attention",title:t.title,context:s.jsx(_,{parts:[jy(t)]}),detail:o.join(", ")||void 0,detailText:o.join(", ")||void 0,below:s.jsxs("div",{className:"ap-below",children:[s.jsx("pre",{className:"ap-lines t-code",children:t.lines.join(`
169
+ `)}),e.local&&!n&&s.jsxs("div",{className:"ap-below ap-actions",children:[s.jsx(R,{size:"sm",disabled:e.busy,onClick:e.onAccept,children:"Accept this change"}),c!=="none"&&s.jsx(R,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>c==="delete"?i(!0):e.onRevert(),children:c==="delete"?"Delete…":"Revert"})]}),e.local&&n&&s.jsx(SO,{files:o,busy:e.busy,onDelete:()=>(i(!1),e.onRevert(o)),onCancel:()=>i(!1)})]})})}function CO(e){const{tracker:t}=e;return s.jsx(fe,{as:"li",className:"ap-row",edge:"attention",title:`trackers.json now points at ${t.label}`,context:s.jsx(_,{parts:["Nothing is read from or sent there yet"]}),detail:`This machine keeps using ${t.approved}`,below:e.local&&s.jsxs("div",{className:"ap-below ap-actions",children:[s.jsxs(R,{size:"sm",disabled:e.busy,onClick:()=>e.onDecide(!0),children:["Use ",t.label]}),s.jsxs(R,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>e.onDecide(!1),children:["Keep ",t.approved]})]})})}function TO(e){const t=new URL(location.href);return t.searchParams.set("settings",e),{href:t.toString(),onClick:n=>{n.preventDefault(),history.replaceState(history.state,"",t.toString()),window.dispatchEvent(new PopStateEvent("popstate"))}}}function EO(e){const{item:t}=e,n=t.committed===!1,i=t.kind==="catalogs"?[...t.lines,""]:[],o=n?[...i,...t.content.split(`
170
+ `)]:t.lines;return s.jsx(fe,{as:"li",className:"ap-row",edge:"attention",title:t.title,context:s.jsx(_,{parts:[jy(t)]}),detail:_g[t.kind],detailText:_g[t.kind],below:s.jsxs("div",{className:"ap-below",children:[s.jsx("pre",{className:"ap-lines t-code",children:o.join(`
171
+ `)}),Bg[t.kind]&&s.jsx("p",{className:"ap-note t-meta",children:Bg[t.kind]}),t.warnings.length>0&&s.jsx("ul",{className:"ap-warnings t-meta",children:t.warnings.map(c=>s.jsxs("li",{children:["Worth a look: ",c]},c))}),s.jsx(ic,{findings:t.screening??[],named:!0,action:e.local&&s.jsx("a",{...TO("verification"),children:"Edit checks"})}),e.local&&s.jsx(R,{size:"sm",disabled:e.busy,onClick:e.onApprove,children:"Approve"})]})})}async function Fg(e,t){const n=await fetch(`${re()}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),i=await n.json().catch(()=>({}));if(!n.ok)throw new Error(i.error??`Request failed (${n.status})`);return i}const Td=async e=>e.ok?await e.json():void 0;async function zg(){var m;const[e,t,n]=await Promise.all(["/trust","/trackers","/trackers/legacy-outbox"].map(g=>fetch(`${re()}${g}`))),i=await Td(e);if(!i)return null;const{items:o}=i,c=(m=await Td(t))==null?void 0:m.pending,d=await Td(n),u=i.firstRun===!0,f=i.stateFirstRun===!0;return{items:o,firstRun:u,stateFirstRun:f,...c?{tracker:c}:{},...d!=null&&d.writes?{oldQueue:d}:{}}}const AO=(e,t)=>{var n,i,o,c;return JSON.stringify([e.items.map(d=>d.hash),(n=e.tracker)==null?void 0:n.target,(i=e.oldQueue)==null?void 0:i.writes])===JSON.stringify([t.items.map(d=>d.hash),(o=t.tracker)==null?void 0:o.target,(c=t.oldQueue)==null?void 0:c.writes])};function IO(e){var n,i;const t=[(n=e.changed)!=null&&n.length?`${e.changed.length} changed while you looked, so they wait; look again`:"",(i=e.refused)!=null&&i.length?`${e.refused.length} not committed, so they need their own look`:""].filter(Boolean);return t.length?`${t.join(". ")}.`:void 0}function RO(){const[e,t]=w.useState(),[n,i]=w.useState(!1),o=w.useRef();w.useEffect(()=>void(o.current=e),[e]);const c=w.useRef(0),[d]=w.useState(ki),u=w.useRef(0),f=w.useCallback(()=>{u.current++;const b=d.start(),S=x=>{b()&&(o.current=x,t(x),i(!1))};return zg().then(S,()=>S(null))},[d]),m=w.useCallback(async()=>{if(c.current)return;const b=u.current,S=await zg().catch(()=>null),x=o.current;u.current!==b||x===void 0||(!S||!x||!AO(S,x))&&i(!0)},[]);w.useEffect(()=>void f(),[f]),w.useEffect(()=>Ya(b=>void(b.startsWith(".")||m())),[m]),w.useEffect(()=>as(()=>void m()),[m]);const g=w.useCallback(async b=>{c.current++;try{const S=await b();return await f(),S}finally{c.current--}},[f]),k=w.useCallback(async b=>IO(await g(()=>Fg("/trust/approve",{items:b.map(S=>({key:S.key,hash:S.hash}))}))),[g]),y=w.useCallback(async(b,S)=>{await g(()=>Fg(b,S))},[g]);return{view:e,changed:n,load:f,approve:k,act:y}}function MO(){const{view:e,changed:t,load:n,approve:i,act:o}=RO(),c=ji()!==!1,[d,u]=w.useState(!1),[f,m]=w.useState();if(!e)return null;const g=N=>{u(!0),m(void 0),N.then(O=>(u(!1),m(O??void 0)),O=>(u(!1),m(O.message)))},{items:k,tracker:y,oldQueue:b}=e,S=N=>!N.alone&&(N.kind==="state"?e.stateFirstRun&&N.standing==="elsewhere":e.firstRun),x=k.filter(N=>N.committed!==!1&&S(N)),$=k.length+(y?1:0)+(b?1:0);return s.jsxs(Ae,{title:"Approvals",children:[s.jsxs("p",{className:"vf-intro",children:["Some files in the repo tell ",J.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 ",J.name," shows here as changed outside ",J.name,", and counts only once you accept it."]}),t&&s.jsxs("div",{className:"sync-line alert ap-changed",role:"status",children:[s.jsx("span",{className:"dot"}),s.jsx("span",{children:"Files changed while you were here. What's below is what you saw."}),s.jsx(R,{size:"sm",onClick:n,children:"Review again"})]}),$===0&&s.jsx("p",{className:"ap-none t-meta",children:"Nothing waiting. Everything the repo asks for is approved here."}),x.length>1&&s.jsx("p",{className:"ap-adopt",children:xO(x.length)}),k.some(N=>N.kind==="state")&&s.jsx("p",{className:"ap-note t-meta",children:yO}),$>0&&s.jsxs("ul",{className:"ap-list",children:[y&&s.jsx(CO,{tracker:y,busy:d,local:c,onDecide:N=>g(o("/trackers/approval",{use:N,target:y.target}))}),b&&s.jsx(bO,{queue:b,busy:d,local:c,onDecide:N=>g(o("/trackers/legacy-outbox",{action:N?"send":"discard",writes:b.writes}))}),k.map(N=>N.kind==="state"?s.jsx($O,{item:N,busy:d,local:c,onAccept:()=>g(i([N])),onRevert:O=>g(o("/trust/revert",{key:N.key,hash:N.hash,remove:O}))},N.key):s.jsx(EO,{item:N,busy:d,local:c,onApprove:()=>g(i([N]))},N.key))]}),c&&x.length>1&&s.jsxs(R,{disabled:d||t,onClick:()=>g(i(x)),children:["Approve all ",x.length," committed"]}),!c&&$>0&&s.jsxs("p",{className:"t-meta",children:["Approve these on the machine ",J.name," runs on."]}),f&&s.jsx("span",{className:"vf-err",children:f}),s.jsx(_,{className:"set-hint",parts:jO})]})}const by="0.64.2",uu="<endpoint>",dh=Tk(by,["mcp","--http"]);function LO(e,t){const n=Tk(by,["connect",e,"--url"]),i=t===uu?t:Ck(t);return`read -rs ${J.tokenEnv} && export ${J.tokenEnv}
172
+ ${n} ${i}`}function OO(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 PO({endpoints:e}){const t=e.some(n=>n.kind==="standalone");return s.jsxs("ul",{className:"ra-endpoints",children:[e.map(n=>s.jsx("li",{children:s.jsx(_,{className:"set-hint",parts:[{text:n.url,code:!0},...OO(n)]})},n.url)),!t&&s.jsx("li",{children:s.jsx(_,{className:"set-hint",parts:["For agents on other machines, start their server",{text:dh,code:!0}]})})]})}function DO(e){const[t,n]=w.useState(""),[i,o]=w.useState(!1),[c,d]=w.useState(),u=async f=>{if(!f.trim()||i)return;o(!0);const m=await e.onCreate(f).catch(g=>g.message);o(!1),d(m),m||n("")};return s.jsxs("div",{className:"ra-new",children:[s.jsx(Xa,{value:t,onValueChange:n,onSubmit:u,action:"Create token",actionDisabled:i||!t.trim(),placeholder:"Name the agent, e.g. cloud sandbox 1","aria-label":"Agent name",maxLength:60}),c&&s.jsx("span",{className:"vf-err",children:c})]})}function _O(){return s.jsx(Ae,{title:"Remote agents",children:s.jsxs("p",{className:"vf-intro",children:["Tokens for remote agents are created and revoked on the machine ",J.name," runs on. Open the Lookout there to manage them."]})})}function BO(e){const[t,n]=w.useState(!1),[i,o]=w.useState(!1),[c,d]=w.useState(),u=async()=>{o(!0),d(await e.onRevoke().catch(f=>f.message)),o(!1),n(!1)};return t?s.jsxs("span",{className:"ra-revoke ask",children:[s.jsx("span",{className:"t-meta",children:"Its sessions end now."}),s.jsxs(R,{size:"sm",disabled:i,onClick:u,children:["Revoke ",e.name]}),s.jsx(R,{size:"sm",variant:"ghost",onClick:()=>n(!1),children:"Keep"})]}):s.jsxs("span",{className:"ra-revoke",children:[s.jsx(R,{size:"sm","aria-label":`Revoke ${e.name}`,onClick:()=>n(!0),children:"Revoke"}),c&&s.jsx("span",{className:"vf-err",children:c})]})}function FO(e){if(!e.tokens.length)return null;const t=Date.now();return s.jsx("ul",{className:"ra-list",children:e.tokens.map(n=>s.jsx(fe,{as:"li",className:"ra-row",title:n.name,titleText:n.name,context:s.jsx(_,{parts:[`Created ${is(n.createdAt,t)}`,n.lastUsedAt?`Last used ${is(n.lastUsedAt,t)}`:"Never used"]}),below:s.jsx(BO,{name:n.name,onRevoke:()=>e.onRevoke(n.id)})},n.id))})}function Ed(e){const[t,n]=w.useState(!1),i=()=>{var o;return void((o=navigator.clipboard)==null?void 0:o.writeText(e.value).then(()=>{n(!0),setTimeout(()=>n(!1),1500)},()=>n(!1)))};return s.jsxs("div",{className:"ra-copy",children:[s.jsx("code",{className:"ra-copy-value t-code","aria-label":e.label,children:e.value}),s.jsx(R,{size:"sm",className:"ra-copy-btn",onClick:i,children:t?"Copied":e.copyLabel??"Copy"})]})}const zO=[{id:"claude",label:"Claude Code"},{id:"codex",label:"Codex"}];function UO(e){const[t,n]=w.useState("claude");return s.jsxs("div",{className:"ra-reveal",role:"status",children:[s.jsxs("p",{className:"ra-reveal-title t-row-title",children:["Token for ",e.created.name]}),s.jsxs("p",{className:"t-body ra-note",children:["Copy it now. ",J.name," keeps only a fingerprint, so it can't show it again."]}),s.jsx(Ed,{label:"Token",value:e.created.token,copyLabel:"Copy token"}),!e.endpoint&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"ra-reveal-head",children:s.jsx(Ke,{children:"Start the server for remote agents"})}),s.jsx(Ed,{label:"Start command",value:dh,copyLabel:"Copy command"})]}),s.jsxs("div",{className:"ra-reveal-head",children:[s.jsx(Ke,{children:"Run on the agent's machine"}),s.jsx("span",{className:"ra-clients",children:zO.map(i=>s.jsx(R,{size:"sm",on:t===i.id,"aria-pressed":t===i.id,onClick:()=>n(i.id),children:i.label},i.id))})]}),s.jsx(Ed,{label:"Connect command",value:LO(t,e.endpoint??uu),copyLabel:"Copy command"}),s.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 ${uu}.`,t==="codex"&&` Start Codex from the same shell: it reads $${J.tokenEnv} each time.`]}),s.jsx("span",{children:s.jsx(R,{variant:"primary",size:"sm",onClick:e.onDone,children:"I've copied it"})})]})}const Sy=`${re()}/remote-agents`;async function Ug(e,t){const n=await fetch(`${Sy}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return{ok:n.ok,reply:await n.json()}}async function WO(){const e=await fetch(Sy);return e.ok?await e.json():(await e.json().catch(()=>({}))).elsewhere?"elsewhere":null}function HO(){const[e,t]=w.useState(),[n,i]=w.useState(),{pushed:o}=Pe({load:WO,show:t,failed:()=>t(null),events:{"remote-agents":()=>!0}}),c=w.useCallback(f=>{o(),t({tokens:f.tokens,endpoints:f.endpoints})},[o]),d=w.useCallback(async f=>{const{ok:m,reply:g}=await Ug("/tokens",{name:f});if(!m||!g.token||!g.created)return g.error??"The token could not be created.";c(g),i({token:g.token,name:g.created.name})},[c]),u=w.useCallback(async f=>{const{ok:m,reply:g}=await Ug("/tokens/revoke",{id:f});return g.tokens&&c(g),m?void 0:g.error??"The token could not be revoked."},[c]);return{view:e,created:n,dismissCreated:()=>i(void 0),create:d,revoke:u}}function KO(){var d;const{view:e,created:t,dismissCreated:n,create:i,revoke:o}=HO();if(!e)return null;if(e==="elsewhere")return s.jsx(_O,{});const c=(d=e.endpoints.find(u=>u.kind==="standalone"))==null?void 0:d.url;return s.jsxs(Ae,{title:"Remote agents",children:[s.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."}),s.jsx(PO,{endpoints:e.endpoints}),t&&s.jsx(UO,{created:t,endpoint:c,onDone:n}),s.jsx(FO,{tokens:e.tokens,onRevoke:o}),e.tokens.length===0&&s.jsx("p",{className:"t-meta ra-note",children:"No tokens, so the endpoint is closed: every request is refused."}),s.jsx(DO,{onCreate:i}),s.jsxs("div",{className:"ra-notes",children:[s.jsxs("p",{className:"t-meta ra-note",children:[s.jsx("b",{children:"Before you open it to other machines."})," The connection is plain HTTP. Run ",s.jsx("code",{children:dh}),", 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."]}),s.jsxs("p",{className:"t-meta ra-note",children:[s.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."]}),s.jsxs("p",{className:"t-meta ra-note",children:[s.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."]}),s.jsxs("p",{className:"t-meta ra-note",children:[s.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 Wg={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"},GO={low:"the agent decides",medium:"the agent decides and records it",high:"you decide"},VO=e=>e[0].toUpperCase()+e.slice(1),hu=nv.map(e=>({value:e,label:VO(e),hint:GO[e]}));function qO(e){const[t,n]=w.useState(""),[i,o]=w.useState("high"),{rules:c,onChange:d}=e,u=()=>{const f=t.trim();!f||c.some(m=>m.glob===f)||(d([...c,{glob:f,level:i}]),n(""))};return s.jsxs("div",{className:"risk-paths",children:[s.jsx("span",{className:"mono-label",children:"Files"}),c.map((f,m)=>s.jsxs("div",{className:"risk-row",children:[s.jsx("code",{children:f.glob}),s.jsx(it,{compact:!0,"aria-label":`${f.glob} risk`,value:f.level,options:hu,onChange:g=>d(c.map((k,y)=>y===m?{...k,level:g}:k))}),s.jsx("button",{className:"icon-btn","aria-label":`Remove ${f.glob}`,onClick:()=>d(c.filter((g,k)=>k!==m)),children:"×"})]},f.glob)),s.jsxs("div",{className:"risk-row",children:[s.jsx("input",{value:t,placeholder:"src/payments/**","aria-label":"New file pattern",onChange:f=>n(f.target.value),onKeyDown:f=>f.key==="Enter"&&u()}),s.jsx(it,{compact:!0,"aria-label":"New pattern risk",value:i,options:hu,onChange:o}),s.jsx(R,{onClick:u,disabled:!t.trim(),children:"Add"})]})]})}const Ny=`${re()}/policy`;async function QO(){const e=await fetch(Ny);return e.ok?await e.json():null}function YO(){const[e,t]=w.useState(),{pushed:n}=Pe({load:QO,show:t,failed:()=>t(null),changed:o=>o.endsWith("policy.json")}),i=w.useCallback(async o=>{const c=await fetch(Ny,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}),d=await c.json();if(!c.ok)return d.error??`Saving failed (${c.status})`;n(),t(d)},[n]);return{view:e,save:i}}function JO(){const{view:e,save:t}=YO(),[n,i]=w.useState();if(!e)return null;const o=`${J.dataDir}/policy.json`,c=d=>{i(void 0),t(d).then(i,u=>i(u.message))};return s.jsxs(Ae,{title:"Risk policy",children:[s.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."}),s.jsx("div",{className:"risk-grid",children:tv.map(d=>s.jsxs("label",{className:"risk-row",children:[s.jsx("span",{children:Wg[d]}),s.jsx(it,{compact:!0,"aria-label":`${Wg[d]} risk`,value:e.policy.categories[d],options:hu,onChange:u=>c({...e.policy,categories:{...e.policy.categories,[d]:u}})})]},d))}),s.jsx(qO,{rules:e.policy.paths,onChange:d=>c({...e.policy,paths:d})}),e.errors.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"sync-line alert",children:[s.jsx("span",{className:"dot"}),s.jsxs("span",{children:[o," has errors, so the defaults apply until it is fixed."]})]}),s.jsx("ul",{className:"vf-errors",children:e.errors.map(d=>s.jsx("li",{children:d},d))})]}),e.defaults&&e.errors.length===0&&s.jsxs("span",{className:"set-hint t-meta",children:["Defaults. Changing anything saves ",o,", so your team shares it."]}),n&&s.jsx("span",{className:"vf-err",children:n})]})}function XO(){const{view:e,save:t,remove:n}=Zw(),[i,o]=w.useState();if(!e)return null;const c=e.settings.worktrees,d=()=>{o(void 0),t({...e.settings,worktrees:!c}).then(o,u=>o(u.message))};return s.jsxs(Ae,{title:"Workspaces",children:[s.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; ",J.name," never merges or pushes."]}),s.jsxs("div",{className:"att-settings-row set-field",children:[s.jsx("span",{className:"set-field-label",children:"A worktree per ticket"}),s.jsx(R,{size:"sm",on:c,"aria-pressed":c,className:"worktrees-toggle",onClick:d,children:c?"On":"Off"})]}),s.jsx(_,{className:"set-hint",parts:[{text:`${J.dataDir}/workspaces.json`,code:!0},Hg(e.workspaces.filter(u=>u.active).length,"active"),Hg(e.workspaces.filter(u=>!u.active).length,"finished")]}),s.jsx(pR,{rows:e.workspaces,onRemove:n}),e.errors.length>0&&s.jsx("ul",{className:"vf-errors",children:e.errors.map(u=>s.jsx("li",{children:u},u))}),i&&s.jsx("span",{className:"vf-err",children:i})]})}const Hg=(e,t)=>`${e} ${t}`;function ZO({data:e,route:t}){var n;return s.jsxs(s.Fragment,{children:[s.jsx(He,{id:"approvals",storage:"machine",children:s.jsx(MO,{})}),s.jsx(He,{id:"tracker",children:s.jsx(Ae,{title:"Tracker",children:(n=pt())!=null&&n.tracker?s.jsx("p",{className:"vf-intro",children:"Trails are kept by the server this Lookout runs on, in its own storage."}):s.jsx(GL,{activeTracker:e.activeTracker,location:e.location,update:e.update})})}),s.jsx(He,{id:"workspaces",storage:"repo",children:s.jsx(XO,{})}),s.jsx(He,{id:"proof",storage:"machine",children:s.jsx(wA,{})}),s.jsx(He,{id:"remote-agents",storage:"machine",children:s.jsx(KO,{})}),s.jsx(He,{id:"policy",storage:"repo",children:s.jsx(JO,{})}),s.jsx(He,{id:"guides",storage:"repo",children:s.jsx(SI,{focus:t.section==="guides"})}),s.jsx(He,{id:"labels",children:s.jsx(Ae,{title:"Labels",children:s.jsxs("div",{className:"label-codes",children:[s.jsx("code",{children:yu}),s.jsxs("code",{children:[J.labelPrefix,":<type>"]}),s.jsx("code",{children:xu}),s.jsx("code",{children:ju})]})})})]})}const fu=`${J.apiPrefix}/projects`;async function fr(e,t,n){const i=await fetch(`${fu}${e}`,{method:t,headers:{"Content-Type":"application/json"},body:n===void 0?void 0:JSON.stringify(n)}),o=await i.json().catch(()=>({}));if(!i.ok)throw new Error(o.error??`HTTP ${i.status}`);return o}const Ns={url:fu,add:e=>fr("","POST",{path:e}),remove:e=>fr(`/${e}`,"DELETE"),setAutoRegister:e=>fr("/settings","PUT",{autoRegister:e}),setShare:(e,t)=>fr(`/${e}/share`,"PUT",{share:t}),answer:(e,t)=>fr(`/${e}/answer`,"POST",t),async briefing(e){const t=await fetch(`${fu}/briefing?since=${e}`);return t.ok?await t.json():void 0}};function $y(e){const[t,n]=w.useState(""),[i,o]=w.useState(),c=d=>{d.trim()&&(o(void 0),Ns.add(d.trim()).then(()=>(n(""),e.onAdded()),u=>o(u.message)))};return s.jsxs("div",{className:"pj-add",children:[s.jsx(Xa,{value:t,onValueChange:n,onSubmit:c,action:"Add project",placeholder:`/path/to/repo (a ${J.dataDir} folder is created if missing)`,"aria-label":"Repo path",className:"t-code"}),i&&s.jsx("span",{className:"vf-err",children:i})]})}const ri=(e,t)=>e>0&&`${e} ${t}`;function eP(e){var n;const t=((n=e.briefing)==null?void 0:n.projects)??[];return!e.briefing||!t.length?null:s.jsxs("section",{className:"pj-section pj-briefing",children:[s.jsx(yt,{title:"While you were away",count:t.length,info:`What changed in each project since ${Je(e.now-e.briefing.since)} ago`}),s.jsx("ul",{className:"pj-list",children:t.map(({projectId:i,project:o,briefing:c})=>s.jsx(fe,{as:"li",edge:c.totals.waiting>0?"attention":"neutral",title:o,context:s.jsx(_,{parts:[ri(c.totals.done,"done"),ri(c.trails.reduce((d,u)=>d+u.opened.length,0),"new tickets"),ri(c.totals.agentDecisions,"agent decisions"),ri(c.totals.waiting,"waiting on you"),ri(c.totals.ruledOut,"ruled out"),ri(c.totals.active,"agents active")]}),onOpen:()=>e.onOpen(i)},i))})]})}function tP(e){const[t,n]=w.useState(""),[i,o]=w.useState(!1),[c,d]=w.useState(),u=f=>{!f.trim()||i||(o(!0),d(void 0),e.onAnswer(f.trim()).then(()=>n(""),m=>d(m.message)).finally(()=>o(!1)))};return s.jsxs("div",{className:"pj-answer",children:[s.jsx(Xa,{value:t,onValueChange:n,onSubmit:u,action:"Answer",disabled:i,placeholder:"Your answer","aria-label":"Your answer"}),c&&s.jsx("span",{className:"vf-err",children:c})]})}function nP(e){const{item:t}=e,n=Xu(t),i=t.kind==="question"&&t.agent?`${t.agent} asks`:Ju[t.kind],o=t.urgency==="blocking"&&{text:"Blocking",urgent:!0,className:"urgency-tag"};return s.jsx(fe,{as:"li",className:`att-item pj-item k-${t.kind}`,edge:Or(t,t.interrupting),title:t.title.split(`
173
+ `)[0],titleText:t.title,context:s.jsx(_,{parts:[o,{text:t.project,strong:!0},i]}),detail:n.length>0&&n.join(" · "),detailText:n.join(`
174
+ `),trailing:Je(e.now-t.since),onOpen:e.onOpen,below:e.onAnswer&&s.jsx(tP,{onAnswer:e.onAnswer})})}function sP(e){const t=e.view.attention,n=i=>{var o;return((o=e.view.projects.find(c=>c.id===i))==null?void 0:o.state.kind)!=="missing"};return s.jsxs("section",{className:"pj-section pj-attention",children:[s.jsx(yt,{title:"Needs you",count:t.length,hot:t.some(i=>i.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&&s.jsx(An,{title:"Nothing needs you",hint:"Agents in every project can keep going."}),s.jsx("ul",{className:"pj-list",children:t.map(i=>s.jsx(nP,{item:i,now:e.now,onOpen:()=>e.onOpen(i.projectId,i.id),onAnswer:i.kind==="question"&&n(i.projectId)?o=>Ns.answer(i.projectId,{questionId:i.ref,text:o}).then(e.onAnswered):void 0},`${i.projectId}/${i.id}`))})]})}const Ad=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`;function iP(e){return e.interrupting>0?"urgent":e.phases.blocked+e.phases.rework+e.flags+e.stalled>0||e.state.kind==="missing"?"attention":"neutral"}function rP(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(Ad(e.agents,"agent"));const{working:n,verifying:i,rework:o,blocked:c}=e.phases;n&&t.push(`${n} working`),i&&t.push(`${i} verifying`),o&&t.push(`${o} rework`),c&&t.push(`${c} blocked`),e.flags&&t.push(Ad(e.flags,"PR flag")),e.stalled&&t.push(Ad(e.stalled,"stalled claim")),t.length||t.push(e.trails?"Nothing waiting":"No trails yet");const d=oP(e.tracker);return d&&t.push(d),t}function oP(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 aP(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 Ea(e,t,n){if(e.state.kind!=="missing"){if(e.state.kind==="elsewhere"){const i=e.state.url?At(e.state.url):void 0;if(!i)return;const o=new URL(i);n&&o.searchParams.set($s,n),window.open(o.toString(),"_blank","noopener");return}location.href=P$({id:e.id,home:t,tracker:e.tracker.kind,item:n})}}function Cy(e){const{p:t}=e,n=aP(t);return s.jsx(fe,{as:"li",className:`project-card st-${t.state.kind}`,edge:iP(t),selected:e.current,title:t.name,titleText:t.path,context:s.jsx(_,{parts:rP(t)}),detail:n,detailText:n,trailing:t.lastActivity?Je(e.now-t.lastActivity):void 0,onOpen:e.onOpen})}const Ty=`${Ma}:projects:seen`,Kg=24*36e5;function cP(e){try{const t=Number(localStorage.getItem(Ty));return t>0?t:e-Kg}catch{return e-Kg}}function lP(e){try{localStorage.setItem(Ty,String(e))}catch{}}function dP(){const[e,t]=w.useState();return w.useEffect(()=>{const n=Date.now();return Ns.briefing(cP(n)).then(t).catch(()=>{}),()=>lP(n)},[]),e}function uP(e){const{view:t,reload:n}=e.projects,i=gt(15e3),o=dP();if(w.useEffect(()=>{const f=m=>m.key==="Escape"&&e.onClose();return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[e]),!t)return null;const c=Ar()??t.home,d=f=>{const m=t.projects.find(g=>g.id===f);(m==null?void 0:m.id)===c?e.onClose():m&&Ea(m,t.home)},u=(f,m)=>{const g=t.projects.find(k=>k.id===f);if(g){if(g.id!==c)return Ea(g,t.home,m);e.onClose(),e.onItemHere(m)}};return s.jsxs(Be,{className:`zone decisions-view projects-view dv-${e.bp}`,children:[s.jsxs("header",{className:"dv-head",children:[s.jsx(Ke,{as:"h2",children:"All projects"}),s.jsx("span",{className:"dv-head-right",children:s.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})})]}),s.jsxs("div",{className:"pj-body",children:[s.jsx(sP,{view:t,now:i,onOpen:u,onAnswered:n}),s.jsxs("section",{className:"pj-section pj-projects",children:[s.jsx(yt,{title:"Projects",count:t.projects.length,info:"Each repo registered on this machine, read from its own files. Nothing leaves your machine."}),s.jsx("ul",{className:"pj-list",children:t.projects.map(f=>s.jsx(Cy,{p:f,current:f.id===c,now:i,onOpen:f.state.kind==="missing"?void 0:()=>d(f.id)},f.id))}),s.jsx($y,{onAdded:n})]}),s.jsx(eP,{briefing:o,now:i,onOpen:d})]})]})}function hP(e){const[t,n]=w.useState(!1),i=w.useRef(null);w.useEffect(()=>{if(!t)return;const u=f=>{var m;(f instanceof KeyboardEvent?f.key==="Escape":!((m=i.current)!=null&&m.contains(f.target)))&&n(!1)};return window.addEventListener("mousedown",u),window.addEventListener("keydown",u),()=>{window.removeEventListener("mousedown",u),window.removeEventListener("keydown",u)}},[t]);const{view:o}=e.projects;if(!o||!e.projects.many)return s.jsx("span",{className:"repo",children:e.repo});const c=Ar()??o.home,d=o.projects.filter(u=>u.id!==c).reduce((u,f)=>u+f.interrupting,0);return s.jsxs("div",{className:"project-switcher",ref:i,children:[s.jsxs("button",{className:"project-btn repo",onClick:()=>n(u=>!u),"aria-haspopup":"menu","aria-expanded":t,"data-tip":"Switch project, or see all of them",children:[s.jsx("span",{className:"project-name",children:e.repo}),d>0&&s.jsx(bs,{n:d,urgent:!0}),s.jsx("span",{className:"caret",children:"▾"})]}),t&&s.jsxs("div",{className:"trail-menu",role:"menu",children:[s.jsxs("button",{role:"menuitem",className:"trail-item all-projects",onClick:()=>{n(!1),e.onOverview()},children:[s.jsx("span",{className:"mi-title",children:"All projects"}),s.jsx(bs,{n:o.attention.length,urgent:o.attention.some(u=>u.interrupting),hideZero:!0})]}),s.jsx(Ke,{variant:"plain",className:"menu-h",children:"Projects"}),o.projects.map(u=>s.jsxs("button",{role:"menuitem",className:`trail-item ${u.id===c?"on":""} st-${u.state.kind}`,disabled:u.state.kind==="missing",onClick:()=>{n(!1),u.id!==c&&Ea(u,o.home)},children:[s.jsx("span",{className:"mi-title",children:u.name}),s.jsx("span",{className:"mi-progress",children:fP(u.state.kind)}),s.jsx(bs,{n:u.needsYou,urgent:u.interrupting>0,hideZero:!0})]},u.id))]})]})}function fP(e){return e==="missing"?"missing":e==="elsewhere"?"other Lookout":""}function mP(e){const t=gt(15e3),{view:n}=e.projects;if(!n||!e.projects.many)return null;const i=Ar()??n.home;return s.jsxs("section",{className:"phone-projects",children:[s.jsx(yt,{title:"Projects",count:n.projects.length,right:s.jsx(R,{size:"sm",variant:"ghost",onClick:e.onOverview,children:"All projects"})}),s.jsx("ul",{className:"pj-list",children:n.projects.filter(o=>o.id!==i).map(o=>s.jsx(Cy,{p:o,current:!1,now:t,onOpen:o.state.kind==="missing"?void 0:()=>Ea(o,n.home)},o.id))})]})}async function pP(){const e=await fetch(Ns.url);return e.ok?await e.json():void 0}function Ey(){const[e,t]=w.useState(),{reload:n,pushed:i}=Pe({load:pP,show:o=>o&&t(o)});return w.useEffect(()=>vi("projects",o=>{i(),t(JSON.parse(o))}),[i]),{view:e,many:((e==null?void 0:e.projects.length)??0)>1,reload:n}}const gP=e=>[e.home&&{text:"This Lookout",strong:!0},e.state.kind==="missing"&&"Missing",{text:e.path,code:!0}];function kP(){const{view:e,reload:t}=Ey(),[n,i]=w.useState();if(!e)return null;const o=c=>{i(void 0),c.then(t,d=>i(d.message))};return s.jsxs(Ae,{title:"Projects",children:[s.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."}),s.jsx("ul",{className:"pj-list set-projects",children:e.projects.map(c=>s.jsx(fe,{as:"li",edge:c.state.kind==="missing"?"attention":"neutral",title:c.name,context:s.jsx(_,{parts:gP(c)}),actions:s.jsxs(s.Fragment,{children:[s.jsx(R,{size:"sm",variant:"ghost",on:c.sharePrecedents,"aria-pressed":c.sharePrecedents,className:"share-precedents-toggle",title:"Offer this project's decisions as suggestions when agents look for precedents in your other projects",onClick:()=>o(Ns.setShare(c.id,!c.sharePrecedents)),children:c.sharePrecedents?"Shares decisions":"Share decisions"}),!c.home&&s.jsx(R,{size:"sm",variant:"ghost",onClick:()=>o(Ns.remove(c.id)),children:"Remove"})]})},c.id))}),s.jsx($y,{onAdded:t}),s.jsxs("div",{className:"att-settings-row set-field",children:[s.jsx("span",{className:"set-field-label",children:"Agents add their repo when they connect"}),s.jsx(R,{size:"sm",on:e.autoRegister,"aria-pressed":e.autoRegister,className:"auto-register-toggle",onClick:()=>o(Ns.setAutoRegister(!e.autoRegister)),children:e.autoRegister?"On":"Off"})]}),s.jsx(_,{className:"set-hint",parts:[{text:`${J.slug} projects add <path>`,code:!0},`--no-register or ${J.noRegisterEnv} opts one agent out`]}),n&&s.jsx("span",{className:"vf-err",children:n})]})}function vP(e){return e.local===!1?{kind:"locked",reason:"Set on the machine Teamtrail runs on."}:e.exists?e.valid?e.waiting?{kind:"locked",reason:"Approve the checks first."}:e.local===void 0?{kind:"locked"}:{kind:"open"}:{kind:"locked",reason:"Fix verification.json first."}:{kind:"locked",reason:"Set the checks first: without them nothing is verified."}}const Gg=e=>`${e} ticket${e===1?"":"s"}`;function wP(e,t){const n=`in the last ${t} days`,i=e.held?`Held ${Gg(e.held)}`:"",o=e.wouldHold?`would have held ${Gg(e.wouldHold)}`:"";return i&&o?`${i}, ${o} ${n}`:i?`${i} ${n}`:o?`W${o.slice(1)} ${n}`:`Nothing held ${n}`}const yP={enforce:"Held",observe:"Would have held"};function xP(e){if(!e.entries.length)return null;const t=Date.now();return s.jsx(an,{label:`Tickets (${e.entries.length})`,children:s.jsx("ul",{className:"gate-entries",children:e.entries.map((n,i)=>{const o=n.ticketId;return s.jsx(fe,{as:"li",className:"gate-entry",edge:n.mode==="enforce"?"attention":"neutral",title:n.reason,titleText:n.reason,context:s.jsx(_,{parts:[n.ticketKey&&{text:n.ticketKey,code:!0},yP[n.mode]]}),trailing:is(n.at,t),onOpen:o?()=>e.onOpenTicket(n.mapId,o):void 0},`${n.at}-${i}`)})})})}const Ay={"check-guard":{title:"Check guard",about:"A pass counts only if the work left what the checks run, and its tests, alone."},"independent-review":{title:"Independent review",about:"A review by an agent on the same model as the author doesn’t count as independent."},"diff-rules":{title:"Diff rules",about:"A change to files a rule covers waits until the rule’s check runs or its question is answered."},flaky:{title:"Flaky checks",about:"A check that failed, then passed on the same commit, needs you before the pass counts."}},Cr=e=>Vk.includes(e);function jP(e){return Cr(e)?Ay[e].title:e}function bP(e){return Cr(e)?Ay[e].about:void 0}const Vg={off:{label:"Off",tip:"Does nothing"},observe:{label:"Observe",tip:"Notes what it would hold and lets the work through"},enforce:{label:"Enforce",tip:"Holds the work for you, with a way past it"}};function SP(e){return s.jsx("div",{className:"gate-modes",role:"radiogroup","aria-label":`${e.label} mode`,"data-gate":e.gate,children:Yb.map(t=>s.jsx("button",{type:"button",role:"radio","aria-checked":e.value===t,className:ue("gate-mode",e.value===t&&"on"),title:Vg[t].tip,disabled:e.disabled,onClick:()=>e.value!==t&&e.onChange(t),children:Vg[t].label},t))})}function NP(e){const{summary:t}=e,n=jP(t.gate),i=Cr(t.gate);return s.jsx(fe,{as:"li",className:"gate-row",edge:t.held?"attention":"neutral",title:i?n:s.jsx("span",{className:"t-code",children:n}),context:s.jsx(_,{parts:[bP(t.gate)]}),detail:e.days?wP(t,e.days):void 0,below:s.jsxs(s.Fragment,{children:[i&&s.jsx(SP,{gate:t.gate,label:n,value:e.mode,disabled:e.locked,onChange:e.onMode}),s.jsx(xP,{entries:t.entries,onOpenTicket:e.onOpenTicket})]})})}function qg(e){return new Set(e.map((t,n)=>t.ticketId?`${t.mapId}/${t.ticketId}`:`#${n}`)).size}function $P(e){const t=[...e].sort((i,o)=>o.at-i.at),n=[...Vk];for(const i of t)n.includes(i.gate)||n.push(i.gate);return n.map(i=>{const o=t.filter(c=>c.gate===i);return{gate:i,held:qg(o.filter(c=>c.mode==="enforce")),wouldHold:qg(o.filter(c=>c.mode==="observe")),entries:o}})}async function CP(){const e=await fetch(`${re()}/verification/gates`);return e.ok?await e.json():null}function TP(){const[e,t]=w.useState();return Pe({load:CP,show:t,failed:()=>t(null),changed:n=>n.endsWith("verification.json"),events:{verification:()=>!0,attention:()=>!0}}),e}async function EP(e){const t=await fetch(`${re()}/verification/gates`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).catch(()=>{});if(t!=null&&t.ok)return;const n=await(t==null?void 0:t.json().catch(()=>({})));return(n==null?void 0:n.error)??"The server didn't answer."}function AP(e){var x,$;const{view:t,reload:n}=th(),i=TP(),o=ji(),[c,d]=w.useState(),[u,f]=w.useState();if(!t)return null;const m=((x=t.approval)==null?void 0:x.base)??"none",g=vP({local:o,exists:t.exists,valid:!!t.config,waiting:($=t.approval)==null?void 0:$.waiting}),k=(c==null?void 0:c.base)===m?c:void 0,y=g.kind==="locked"||!!k,b=N=>Cr(N)?(k==null?void 0:k.gate)===N?k.mode:Jb(t.exists?t.config:void 0,N):"off",S=async(N,O)=>{if(!Cr(N)||O===b(N))return;const D={gate:N,mode:O,base:m};f(void 0),d(D);const F=await EP(D);if(!F)return n();d(void 0),f(F)};return s.jsxs(Ae,{title:"Gates",children:[s.jsx("p",{className:"vf-intro",children:"Gates catch work that passed its checks but shouldn't count yet. Observe a gate first to see what it would hold, then enforce it: held work waits for you, with a way past it."}),s.jsx("ul",{className:"gate-list",children:$P((i==null?void 0:i.entries)??[]).map(N=>s.jsx(NP,{summary:N,days:i==null?void 0:i.days,mode:b(N.gate),locked:y,onMode:O=>void S(N.gate,O),onOpenTicket:e.onOpenTicket},N.gate))}),g.kind==="locked"&&g.reason&&s.jsx("span",{className:"set-hint t-meta",children:g.reason}),i===null&&s.jsx("span",{className:"set-hint t-meta",children:"What the gates did couldn't be loaded."}),u&&s.jsx("span",{className:"vf-err",children:u})]})}function IP({view:e}){if(!e)return null;const t=`${J.dataDir}/${e.file}`,n=Object.keys(e.models).length,i=e.agents.map(o=>`${o.agent} ${o.tier}`).join(", ");return s.jsxs(s.Fragment,{children:[s.jsx(_,{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"]}),i&&s.jsx(_,{className:"set-hint models-connected",parts:[`Connected now: ${i}`]}),e.errors.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"sync-line alert",children:[s.jsx("span",{className:"dot"}),s.jsxs("span",{children:[t," has errors, so only the built-in models count until it is fixed."]})]}),s.jsx("ul",{className:"vf-errors",children:e.errors.map(o=>s.jsx("li",{children:o},o))})]})]})}const xr={fast:"Fast",balanced:"Balanced",strongest:"Strongest"},RP={fast:"Haiku, mini and nano models",balanced:"Sonnet, GPT-4 models",strongest:"Opus, GPT-5 and o-series models"},MP=ha.map(e=>({value:e,label:xr[e],hint:RP[e]}));function LP(e){return s.jsx("div",{className:"tier-grid",children:rs.map(t=>{const n=e.tiers[t],i=Su[t];return s.jsxs("div",{className:"tier-row",children:[s.jsx("span",{children:ns[t]}),s.jsx(it,{compact:!0,"aria-label":`${ns[t]} tickets' model`,className:`tier-select tier-${t}`,value:n,options:MP,onChange:o=>e.onChange(t,o)}),s.jsx(_,{className:"tier-hint",parts:[n!==i&&`default ${xr[i].toLowerCase()}`,e.hints[t]]})]},t)})})}async function OP(){const e=await fetch(`${re()}/flaky-checks`);return e.ok?await e.json():null}function PP(){const[e,t]=w.useState();return Pe({load:OP,show:t,failed:()=>t(null),events:{verification:()=>!0},changed:n=>n.includes("/tickets/")}),e}const DP={enforce:"A pass on retry waits for you.",observe:"A pass on retry goes through, flagged.",off:"The flaky gate is off: passes on retry count."};function _P(){const e=PP();if(!e)return null;const t=Date.now();return s.jsxs("section",{className:"perf-section flaky-checks",children:[s.jsx(Ke,{as:"h3",children:"Flaky checks"}),s.jsxs("p",{className:"perf-note t-meta",children:["Checks that failed, then passed on the same code with no change. ",DP[e.mode]]}),e.rows.length?s.jsx("ul",{className:"perf-rows",children:e.rows.map(n=>s.jsx(fe,{as:"li",className:"perf-row",title:n.test?`${n.name} · ${n.test}`:n.name,trailing:s.jsx("span",{children:n.count===1?"once":`${n.count} times`}),context:s.jsx(_,{parts:[n.tickets.join(", "),`last seen ${Je(t-n.lastSeen)} ago`]})},`${n.name}
175
+ ${n.test??""}`))}):s.jsx(Te,{children:"No flaky checks seen."})]})}const ia=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function BP({rows:e}){return e.length?s.jsx("ul",{className:"perf-rows",children:e.map(t=>s.jsx(fe,{as:"li",className:"perf-row",title:t.key,trailing:s.jsx("span",{title:"Median time from first claim to done",children:rn(t.medianLeadMs)}),context:s.jsx(_,{parts:[`${t.done} of ${ia(t.tickets,"ticket")} done`,t.cancelled>0&&`${t.cancelled} cancelled`,ia(t.reworkCycles,"rework"),`reviews ${t.reviews.passed} passed, ${t.reviews.failed} failed`,t.answers>0&&ia(t.answers,"question")]}),detail:t.findings.raised>0?`As reviewer: ${t.findings.upheld} of ${ia(t.findings.raised,"finding")} upheld`:void 0},t.key))}):s.jsx(Te,{children:"No claimed tickets yet"})}const FP=e=>`${Math.round(e*100)}%`;function zP({r:e,minSample:t}){return s.jsx(fe,{as:"li",className:"perf-row score-row",title:e.key,trailing:e.enough?s.jsxs("span",{title:"Verified work it passed that was reopened or reverted",children:[FP(e.escapeRate)," came back"]}):s.jsx("span",{className:"t-meta",title:`Compared from ${t} verified tickets`,children:"too few"}),context:s.jsx(_,{parts:[`passed ${e.verified} verified`,`${e.escaped} came back`]})})}function UP({e}){return s.jsx(fe,{as:"li",className:"perf-row score-row",title:`${e.ticketKey} ${e.kind}`,trailing:s.jsx("span",{className:"t-meta",children:new Date(e.at).toLocaleDateString()}),context:s.jsx(_,{parts:[e.agent,e.checks.length?`passed ${e.checks.join(", ")}`:"no check ran"]}),detail:e.evidence})}function WP(e){return e.escapes.length?s.jsxs("ul",{className:"perf-rows",children:[e.checks.map(t=>s.jsx(zP,{r:t,minSample:e.minSample},t.key)),e.escapes.map(t=>s.jsx(UP,{e:t},`${t.mapId}/${t.ticketId}/${t.attemptId}`))]}):s.jsx(Te,{children:"Nothing verified has come back: no reopens, no reverts on main."})}const Qg=e=>`${Math.round(e*100)}%`,HP=e=>e===void 0?void 0:`$${e.toFixed(2)} per verified`;function KP({r:e,minSample:t}){return s.jsx(fe,{as:"li",className:"perf-row score-row",title:e.key,trailing:e.enough?s.jsxs("span",{title:"Verified on the first attempt",children:[Qg(e.firstTimeRate)," first time"]}):s.jsx("span",{className:"t-meta",title:`Compared from ${t} tickets`,children:"too few"}),context:s.jsx(_,{parts:[`${e.verified} of ${e.tickets} verified`,`${Qg(e.reworkRate)} rework`,e.attemptsPerVerified!==void 0&&`${e.attemptsPerVerified} attempts each`,HP(e.costPerVerifiedUsd),e.medianLeadMs!==void 0&&rn(e.medianLeadMs),!!e.escaped&&`${e.escaped} came back`]}),detail:e.findings.error+e.findings.warn>0?`Review findings: ${e.findings.error} errors, ${e.findings.warn} warnings`:void 0})}function GP({rows:e,minSample:t}){return e.length?s.jsx("ul",{className:"perf-rows",children:e.map(n=>s.jsx(KP,{r:n,minSample:t},n.key))}):s.jsx(Te,{children:"No completions yet. The scorecard fills in as agents finish verified tickets."})}async function VP(){const e=await fetch(`${re()}/scorecard`);return e.ok?await e.json():null}function Iy(){const[e,t]=w.useState();return Pe({load:VP,show:t,failed:()=>t(null),events:{verification:()=>!0},changed:n=>n.includes("/tickets/")}),e}const qP=[{id:"byTypeAndModel",title:"Type × model"},{id:"byType",title:"By type"},{id:"byModel",title:"By model"},{id:"byVendor",title:"By vendor"},{id:"byAgent",title:"By agent"},{id:"byGuide",title:"By guide"},{id:"cameBack",title:"Came back"}];function QP(){const e=Iy(),[t,n]=w.useState("byTypeAndModel"),[i,o]=w.useState(!1);if(e==null)return null;const c=()=>void navigator.clipboard.writeText(Y1(e)).then(()=>{o(!0),setTimeout(()=>o(!1),1500)});return s.jsxs("section",{className:"perf-section scorecard",children:[s.jsxs("div",{className:"score-head",children:[s.jsx(Ke,{as:"h3",children:"Scorecard"}),s.jsx(R,{size:"sm",variant:"ghost",onClick:c,disabled:!e.tickets,children:i?"Copied":"Copy as Markdown"})]}),s.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. Came back: verified, then reopened or reverted on main."]}),s.jsx("div",{className:"choice-row compact",children:qP.map(d=>s.jsx(at,{on:t===d.id,title:d.title,onClick:()=>n(d.id)},d.id))}),t==="cameBack"?s.jsx(WP,{checks:e.byCheck??[],escapes:e.escapes??[],minSample:e.minSample}):s.jsx(GP,{rows:e[t]??[],minSample:e.minSample})]})}function Ry(e){const[t,n]=w.useState({}),i=e.map(o=>`${o.map.id}:${o.tickets.reduce((c,d)=>Math.max(c,d.updatedAt),0)}`).join();return w.useEffect(()=>{let o=!0;return Promise.all(e.map(async c=>{const d=await fetch(`${re()}/journal?mapId=${encodeURIComponent(c.map.id)}`).catch(()=>{}),u=d!=null&&d.ok?await d.json():{entries:[]};return[c.map.id,u.entries]})).then(c=>{o&&n(Object.fromEntries(c))}),()=>{o=!1}},[i]),t}const YP=[{id:"byVendor",title:"By vendor"},{id:"byAgent",title:"By agent"},{id:"byType",title:"By ticket type"}];function JP({api:e,bp:t,onClose:n}){const[i,o]=w.useState("byVendor"),c=w.useMemo(()=>Object.values(e.allSnaps),[e.allSnaps]),d=Ry(c),u=e.activity.answered,f=w.useMemo(()=>dv(c.map(m=>({snap:m,journal:d[m.map.id]??[],answered:u}))),[c,d,u]);return w.useEffect(()=>{const m=g=>g.key==="Escape"&&n();return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[n]),s.jsxs(Be,{className:`zone decisions-view perf-view dv-${t}`,children:[s.jsxs("header",{className:"dv-head",children:[s.jsx(Ke,{as:"h2",children:"Trail stats"}),s.jsx(_,{parts:[`${f.trails} trails`,`${f.tickets} tickets`]}),s.jsx("span",{className:"dv-head-right",children:s.jsx("button",{className:"icon-btn",onClick:n,"aria-label":"Close",children:"×"})})]}),s.jsxs("div",{className:"perf-body",children:[s.jsxs("section",{className:"perf-section",children:[s.jsx(Ke,{as:"h3",children:"What stands out"}),s.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?s.jsx("ul",{className:"perf-recs",children:f.recommendations.map(m=>s.jsxs("li",{title:m.because,children:[s.jsx("span",{children:m.text}),s.jsx("span",{className:"t-meta",children:m.because})]},m.id))}):s.jsx(Te,{children:"Nothing yet. This needs at least 5 results from two vendors to compare."})]}),s.jsx(QP,{}),s.jsx(_P,{}),s.jsxs("section",{className:"perf-section",children:[s.jsx("div",{className:"choice-row compact",children:YP.map(m=>s.jsx(at,{on:i===m.id,title:m.title,onClick:()=>o(m.id)},m.id))}),s.jsx(BP,{rows:f[i]}),s.jsx("p",{className:"perf-note t-meta",children:"Spend is tracked per trail, so it isn't split by agent here."})]})]})]})}function XP(e){const t=Iy();if(!t)return null;const n=V1({scorecard:t,tiers:e.tiers,models:e.models});return n.length?s.jsx("ul",{className:"tier-suggestions",children:n.map(i=>s.jsxs("li",{children:[s.jsxs("span",{children:[ns[i.type],": ",xr[i.tier].toLowerCase()," instead of ",xr[i.current].toLowerCase()]}),s.jsx("span",{className:"t-meta",children:i.because}),s.jsxs(R,{size:"sm",variant:"ghost",onClick:()=>e.onTake(i.type,i.tier),children:["Use ",xr[i.tier].toLowerCase()]})]},i.type))}):null}function ZP(e,t){const n=Ry(e);return w.useMemo(()=>{var c;const i=dv(e.map(d=>({snap:d,journal:n[d.map.id]??[],answered:t}))),o={};for(const d of i.byType){if(!d.done)continue;const u=(c=i.recommendations.find(m=>m.id===`speed-${d.key}`))==null?void 0:c.text,f=[`Trail stats: ${d.done} done`,d.medianLeadMs!==void 0&&`median ${rn(d.medianLeadMs)}`,d.reworkCycles>0&&`${d.reworkCycles} back to rework`,u];o[d.key]=f.filter(Boolean).join(" · ")}return o},[e,n,t])}function e3(e){var u,f;const t=ih(),n=ZP(e.snaps,e.answered),i=e.map;if(!i)return null;const o=!!((u=i.modelMatching)!=null&&u.enabled),c=((f=i.modelMatching)==null?void 0:f.tiers)??{},d=(m,g)=>{const k={...c,[m]:g};g===Su[m]&&delete k[m],e.onChange({enabled:!0,tiers:k})};return s.jsxs(Ae,{title:"Model matching",children:[s.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."}),s.jsxs("div",{className:"att-settings-row set-field",children:[s.jsxs("span",{className:"set-field-label",children:["Match work to models on trail ",i.key]}),s.jsx(R,{size:"sm",on:o,"aria-pressed":o,className:"model-matching-toggle",onClick:()=>e.onChange({...i.modelMatching,enabled:!o}),children:o?"On":"Off"})]}),o&&s.jsx(LP,{tiers:jp(i),hints:n,onChange:d}),o&&s.jsx(XP,{tiers:jp(i),models:t==null?void 0:t.models,onTake:d}),o&&s.jsx("span",{className:"set-hint t-meta",children:"Changes apply to the next claim; nothing running is interrupted."}),s.jsx(IP,{view:t})]})}function kr(e,t){const n=new URL(e);return n.searchParams.delete("settings"),t&&n.searchParams.set("settings",t.section??t.group??""),n.toString()}const mu=e=>e.trim().split(/\s+/).filter(Boolean);function t3(e){return e.rows.map((t,n)=>{const i=mu(t.command).join(" ");return e.findings.filter(o=>o.check===String(n)&&o.command===i)})}function n3(e){const{check:t,onChange:n}=e,i=t.name.trim()?`Remove ${t.name.trim()}`:"Remove check";return s.jsx("li",{className:"vf-edit-check",children:s.jsxs("div",{className:"vf-edit-row",children:[s.jsx("input",{"aria-label":"Name",value:t.name,placeholder:"name",autoFocus:e.focus,onChange:o=>n({name:o.target.value})}),s.jsx("input",{"aria-label":"Command",className:"t-code",value:t.command,placeholder:"npm test",onChange:o=>n({command:o.target.value})}),s.jsx("button",{type:"button",className:"icon-btn vf-edit-remove","aria-label":i,"data-tip":i,onClick:e.onRemove,children:"×"}),s.jsx(ic,{findings:e.findings,onFix:o=>n({command:o.join(" ")})})]})})}const s3=[{name:"test",command:"npm test"},{name:"lint",command:"npm run lint"},{name:"typecheck",command:"npm run typecheck"}];function i3(e){return s.jsxs("div",{className:"vf-edit-add",children:[s.jsx(R,{onClick:()=>e.onAdd({name:"",command:""}),children:"Add check"}),e.empty&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"t-meta",children:"or start with"}),s3.map(t=>s.jsx("button",{type:"button",className:"chip t-code",onClick:()=>e.onAdd(t),children:t.command},t.name))]})]})}function r3(e){const{state:t}=e,n=t.kind==="saving";return s.jsxs("div",{className:"vf-edit-foot",children:[s.jsxs("label",{className:"vf-edit-sure",children:[s.jsx("input",{type:"checkbox",checked:e.sure,onChange:i=>e.onSure(i.target.checked)}),s.jsx("span",{children:"I know what these commands run, and approve them"})]}),s.jsxs("div",{className:"vf-edit-save",children:[t.kind==="saved"&&s.jsx("span",{className:"t-meta",children:"Saved and approved."}),t.kind==="error"&&s.jsx("span",{className:"vf-err",children:t.text}),s.jsx(R,{variant:"primary",disabled:!e.sure||n,onClick:e.onSave,children:n?"Saving…":"Save checks"})]})]})}function o3(e){const t=e.config;return t?t.run.filter(n=>t.checks[n]).map(n=>({name:n,command:t.checks[n].run.join(" ")})):[]}function a3({view:e}){const[t,n]=w.useState(()=>o3(e)),[i,o]=w.useState(!1),[c,d]=w.useState(!1),[u,f]=w.useState({kind:"idle"}),m=(S,x)=>n(t.map(($,N)=>N===S?{...$,...x}:$)),g=t.map((S,x)=>{var $,N;return{name:String(x),run:mu(S.command),cwd:(N=($=e.config)==null?void 0:$.checks[S.name])==null?void 0:N.cwd}}),k=qw(g),y=t3({findings:k,rows:t}),b=async()=>{var N;f({kind:"saving"});const S=t.filter(O=>O.name.trim()&&O.command.trim()).map(O=>({name:O.name.trim(),run:mu(O.command)})),x=await fetch(`${re()}/verification/config`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({checks:S,base:((N=e.approval)==null?void 0:N.base)??"none",acknowledged:!0})}).catch(()=>{}),$=await(x==null?void 0:x.json().catch(()=>({})));if(x!=null&&x.ok)return f({kind:"saved"});f({kind:"error",text:($==null?void 0:$.error)??"The server didn't answer."})};return s.jsxs("div",{className:"vf-editor",children:[t.length>0&&s.jsx("ul",{className:"vf-edit-list",children:t.map((S,x)=>s.jsx(n3,{check:S,findings:y[x],focus:i&&x===t.length-1,onChange:$=>m(x,$),onRemove:()=>n(t.filter(($,N)=>N!==x))},x))}),s.jsx(i3,{empty:t.length===0,onAdd:S=>{o(!0),n([...t,S])}}),s.jsx(an,{label:"How checks run",children:s.jsxs("p",{className:"t-meta",children:["Each command runs from the repository's root as words, never through a shell: no pipes or"," ",s.jsx("code",{className:"t-code",children:"&&"}),", and what it runs must already be in the repo. For example"," ",s.jsx("code",{className:"t-code",children:"npm run e2e"}),", ",s.jsx("code",{className:"t-code",children:"make test"}),","," ",s.jsx("code",{className:"t-code",children:"./scripts/check.sh"})," or ",s.jsx("code",{className:"t-code",children:"pytest -q"}),"."]})}),s.jsx(r3,{sure:c,onSure:d,state:u,onSave:()=>void b()})]})}function c3({config:e,file:t,hash:n}){return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"sync-line ok",title:n,children:[s.jsx("span",{className:"dot"}),s.jsxs("span",{children:[s.jsx("span",{className:"t-code",children:t})," · ",e.run.length," checks run on every completion"]})]}),s.jsx(_,{className:"set-hint",parts:[`New trails start at ${Pr[e.default]}`,`${e.maxAttempts} attempts before it waits for you`,e.failFast&&"Stops at the first failure"]}),s.jsx("div",{className:"vf-checks",children:Object.entries(e.checks).map(([i,o])=>s.jsxs("div",{className:"vf-check",children:[s.jsx("span",{className:"t-code",children:e.run.includes(i)?i:`${i} (on request)`}),s.jsx("code",{children:o.run.join(" ")}),s.jsxs("span",{className:"dim",children:[o.timeoutSec," s",o.cwd&&o.cwd!=="."?` · in ${o.cwd}`:""]})]},i))})]})}const l3=[{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 d3({view:e,local:t}){var u,f;const[n,i]=w.useState(),o=((u=e.config)==null?void 0:u.scope)??"flag",c=(f=e.approval)!=null&&f.waiting?"Approve the checks first.":void 0,d=async m=>{var y;i(void 0);const g=await fetch(`${re()}/verification/scope`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:m,base:((y=e.approval)==null?void 0:y.base)??"none"})}).catch(()=>{});if(g!=null&&g.ok)return;const k=await(g==null?void 0:g.json().catch(()=>({})));i((k==null?void 0:k.error)??"The server didn't answer.")};return s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"set-field-label",children:"Changes outside the files an agent declared"}),s.jsx("div",{className:"choice-row vf-levels",children:l3.map(m=>s.jsx(at,{on:o===m.value,title:m.title,sub:m.sub,disabled:!t||!!c,onClick:()=>void d(m.value)},m.value))}),s.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.",c?` ${c}`:"",t===!1?" Set on the machine Teamtrail runs on.":""]}),n&&s.jsx("span",{className:"vf-err",children:n})]})}function u3(e){var c;const{view:t,local:n,file:i}=e,o=t.config;return s.jsxs(s.Fragment,{children:[n&&s.jsx(a3,{view:t},((c=t.approval)==null?void 0:c.base)??"none"),!n&&!t.exists&&s.jsx("span",{className:"set-hint t-meta",children:"No checks yet. They're set on the machine Teamtrail runs on."}),!n&&o&&t.exists&&s.jsx(c3,{config:o,file:i,hash:t.hash}),!n&&s.jsx(ic,{findings:t.screening??[],named:!0}),o&&t.exists&&s.jsx(d3,{view:t,local:n})]})}function h3(e){var g;const{view:t}=th(),n=ji(),[i,o]=w.useState();if(!t)return null;const c=e.map,d=t.config,u=`${J.dataDir}/${t.file}`,f=(c==null?void 0:c.verification)??"off",m=(d??Qk).appliesTo.join(" and ");return s.jsxs(Ae,{title:"Verification",children:[s.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"," ",m," tickets. Research, junction and prototype tickets close as soon as they are answered."]}),c&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"set-field-label",children:["How much checking for trail ",c.key]}),s.jsx("div",{className:"choice-row vf-levels",children:bu.map(k=>s.jsx(at,{on:f===k,title:Pr[k],sub:eh[k],onClick:()=>{o(void 0),Ss.act({action:"level",mapId:c.id,level:k,by:wt}).catch(y=>o(y.message))}},k))}),f!=="off"&&!d&&s.jsxs("div",{className:"sync-line alert",children:[s.jsx("span",{className:"dot"}),s.jsx("span",{children:"No working checks yet, so completions at this level stop and wait for you."})]}),i&&s.jsx("span",{className:"vf-err",children:i})]}),t.errors.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"sync-line alert",title:t.hash,children:[s.jsx("span",{className:"dot"}),s.jsxs("span",{children:[u," has errors. Completions that need checks wait for you until it is fixed."]})]}),s.jsx("ul",{className:"vf-errors",children:t.errors.map(k=>s.jsx("li",{children:k},k))})]}),((g=t.approval)==null?void 0:g.waiting)&&s.jsxs("div",{className:"sync-line alert",children:[s.jsx("span",{className:"dot"}),s.jsxs("span",{children:["Its commands don't run on this machine until you approve them."," ",s.jsx("a",{href:kr(location.href,{group:"project",section:"approvals"}),children:"Review the commands"})]})]}),s.jsx(u3,{view:t,local:n,file:u}),c&&s.jsx(FT,{mapId:c.id}),s.jsxs("span",{className:"set-hint t-meta",children:["Saved here, checks are approved as you save them. A change to ",u," made in the repo, by an agent or a teammate, runs nothing until you approve it."]}),s.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 ",s.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 f3({data:e}){const{map:t}=e;return s.jsxs(s.Fragment,{children:[t?s.jsx(He,{id:"mode",children:s.jsx(Ae,{title:`Trail ${t.key}`,children:s.jsx(iE,{value:t.mode,onChange:e.onMapMode})})}):s.jsx(Te,{children:"Chart or pick a trail to set its mode, model matching and guides."}),s.jsx(He,{id:"verification",storage:"repo",children:s.jsx(h3,{map:t})}),s.jsx(He,{id:"gates",storage:"repo",children:s.jsx(AP,{onOpenTicket:e.onOpenTicket})}),s.jsx(He,{id:"rules",storage:"repo",children:s.jsx(gA,{})}),s.jsx(He,{id:"models",children:s.jsx(e3,{map:t,snaps:e.snaps,answered:e.answered,onChange:e.onModelMatching})}),t&&s.jsx(He,{id:"trail-guides",children:s.jsx(MI,{map:t})})]})}const Yg=10,My=[0,10,16,26,18,24,16,18,22,22,26],Ly=[0,1,1,1,2,2,4,4,4,5,5];function Oy(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 m3=e=>My[e],p3=e=>Ly[e],Py=e=>Math.floor(Oy(e)/8)-My[e]*Ly[e],Dy=e=>e<10?8:16;function g3(e){if(e===1)return[];const t=Math.floor(e/7)+2,n=e*4+17,i=Math.ceil((e*4+4)/(t*2-2))*2,o=[6];for(let c=n-7;o.length<t;c-=i)o.splice(1,0,c);return o}function pu(e,t){let n=0;for(let i=7;i>=0;i--)n=n<<1^(n>>>7)*285,n^=(t>>>i&1)*e;return n}function k3(e){const t=new Array(e).fill(0);t[e-1]=1;let n=1;for(let i=0;i<e;i++){for(let o=0;o<t.length;o++)t[o]=pu(t[o],n),o+1<t.length&&(t[o]^=t[o+1]);n=pu(n,2)}return t}function v3(e,t){const n=t.map(()=>0);for(const i of e){const o=i^n.shift();n.push(0),t.forEach((c,d)=>n[d]^=pu(c,o))}return n}function w3(e,t){const n=[],i=(d,u)=>{for(let f=u-1;f>=0;f--)n.push(d>>>f&1)};i(4,4),i(e.length,Dy(t));for(const d of e)i(d,8);const o=Py(t)*8;i(0,Math.min(4,o-n.length)),i(0,(8-n.length%8)%8);for(let d=236;n.length<o;d^=253)i(d,8);const c=[];for(let d=0;d<n.length;d+=8)c.push(n.slice(d,d+8).reduce((u,f)=>u<<1|f,0));return c}function y3(e,t){const n=w3(e,t),i=p3(t),o=m3(t),c=Math.floor(Oy(t)/8),d=i-c%i,u=Math.floor(c/i),f=k3(o),m=[];for(let k=0,y=0;k<i;k++){const b=n.slice(y,y+u-o+(k<d?0:1));y+=b.length;const S=v3(b,f);k<d&&b.push(0),m.push([...b,...S])}const g=[];for(let k=0;k<m[0].length;k++)for(let y=0;y<m.length;y++)(k!==u-o||y>=d)&&g.push(m[y][k]);return g}const x3=[(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 Id(e,t){const n=x3[t];for(let i=0;i<e.size;i++)for(let o=0;o<e.size;o++)!e.fixed[i][o]&&n(o,i)&&(e.dark[i][o]=!e.dark[i][o])}function Jg(e){let t=0,n=1;for(let o=1;o<=e.length;o++)o<e.length&&e[o]===e[o-1]?n++:(n>=5&&(t+=n-2),n=1);const i=e.map(o=>o?"1":"0").join("");for(const o of["00001011101","10111010000"])for(let c=i.indexOf(o);c>=0;c=i.indexOf(o,c+1))t+=40;return t}function j3(e){let t=0,n=0;for(let o=0;o<e.size;o++)t+=Jg(e.dark[o]),t+=Jg(e.dark.map(c=>c[o]));for(let o=0;o<e.size;o++)for(let c=0;c<e.size;c++){if(e.dark[o][c]&&n++,c===e.size-1||o===e.size-1)continue;const d=e.dark[o][c];d===e.dark[o][c+1]&&d===e.dark[o+1][c]&&d===e.dark[o+1][c+1]&&(t+=3)}const i=e.size*e.size;return t+Math.floor(Math.abs(n*20-i*10)/i)*10}const mn=(e,t)=>(e>>>t&1)!==0;function Tt(e,t,n,i){e.dark[n][t]=i,e.fixed[n][t]=!0}function Rd(e,t,n){for(let i=-4;i<=4;i++)for(let o=-4;o<=4;o++){const c=t+o,d=n+i,u=Math.max(Math.abs(o),Math.abs(i));c>=0&&c<e.size&&d>=0&&d<e.size&&Tt(e,c,d,u!==2&&u!==4)}}function b3(e,t,n){for(let i=-2;i<=2;i++)for(let o=-2;o<=2;o++)Tt(e,t+o,n+i,Math.max(Math.abs(o),Math.abs(i))!==1)}function gu(e,t){const n=0|t;let i=n;for(let c=0;c<10;c++)i=i<<1^(i>>>9)*1335;const o=(n<<10|i)^21522;for(let c=0;c<=5;c++)Tt(e,8,c,mn(o,c));Tt(e,8,7,mn(o,6)),Tt(e,8,8,mn(o,7)),Tt(e,7,8,mn(o,8));for(let c=9;c<15;c++)Tt(e,14-c,8,mn(o,c));for(let c=0;c<8;c++)Tt(e,e.size-1-c,8,mn(o,c));for(let c=8;c<15;c++)Tt(e,8,e.size-15+c,mn(o,c));Tt(e,8,e.size-8,!0)}function S3(e,t){if(t<7)return;let n=t;for(let o=0;o<12;o++)n=n<<1^(n>>>11)*7973;const i=t<<12|n;for(let o=0;o<18;o++){const c=e.size-11+o%3,d=Math.floor(o/3);Tt(e,c,d,mn(i,o)),Tt(e,d,c,mn(i,o))}}function N3(e){const t=e*4+17,n=()=>Array.from({length:t},()=>new Array(t).fill(!1)),i={size:t,dark:n(),fixed:n()};for(let d=0;d<t;d++)Tt(i,6,d,d%2===0),Tt(i,d,6,d%2===0);Rd(i,3,3),Rd(i,t-4,3),Rd(i,3,t-4);const o=g3(e),c=o.length-1;for(let d=0;d<=c;d++)for(let u=0;u<=c;u++)d===0&&u===0||d===0&&u===c||d===c&&u===0||b3(i,o[d],o[u]);return gu(i,0),S3(i,e),i}function $3(e){const t=[];for(let n=e-1;n>=1;n-=2){const i=n<=6?n-1:n,o=(i+1&2)===0;for(let c=0;c<e;c++){const d=o?e-1-c:c;t.push([i,d],[i-1,d])}}return t}function C3(e,t){let n=0;for(const[i,o]of $3(e.size))e.fixed[o][i]||n>=t.length*8||(e.dark[o][i]=mn(t[n>>>3],7-(n&7)),n++)}function T3(e){const t=new TextEncoder().encode(e);let n=1;for(;n<=Yg&&4+Dy(n)+t.length*8>Py(n)*8;)n++;if(n>Yg)return;const i=N3(n);C3(i,y3(t,n));let o=0,c=1/0;for(let d=0;d<8;d++){Id(i,d),gu(i,d);const u=j3(i);u<c&&([o,c]=[d,u]),Id(i,d)}return Id(i,o),gu(i,o),i.dark}const Md=4;function E3(e){const t=T3(e.text);if(!t)return null;const n=t.length+Md*2,i=t.flatMap((o,c)=>o.map((d,u)=>d?`M${u+Md} ${c+Md}h1v1h-1z`:"")).join("");return s.jsxs("svg",{className:"si-qr",viewBox:`0 0 ${n} ${n}`,role:"img","aria-label":e.label,shapeRendering:"crispEdges",children:[s.jsx("rect",{width:n,height:n,fill:"#fff"}),s.jsx("path",{d:i,fill:"#000"})]})}function A3(e){const t=gt(1e3),n=Math.max(0,Math.ceil((e.device.expiresAt-t)/6e4)),i=e.device.links[0];return e.device.expiresAt<=t?s.jsxs("div",{className:"si-code",children:[s.jsx("p",{className:"t-meta",children:"That code expired. Make a new one when the device is ready."}),s.jsx(R,{size:"sm",onClick:e.onDone,children:"Done"})]}):s.jsxs("div",{className:"si-code",children:[i&&s.jsx(E3,{text:i,label:"QR code that pairs another device"}),s.jsxs("div",{className:"si-code-words",children:[s.jsx("span",{className:"si-code-value t-code","aria-label":"Pairing code",children:e.device.code}),s.jsx(_,{parts:["Works once",`expires in ${n} min`]}),s.jsxs("p",{className:"t-meta si-note",children:["Scan it with the device’s camera, or open"," ",i?s.jsx("code",{className:"t-code",children:i.split("#")[0]}):"the Lookout"," there and type the code."]}),s.jsx(R,{size:"sm",onClick:e.onDone,children:"Done"})]})]})}function I3(e){const[t,n]=w.useState();return e.device?s.jsx(A3,{device:e.device,onDone:e.onDone}):e.lan.length?s.jsxs("div",{className:"si-pair",children:[s.jsx(R,{onClick:async()=>n(await e.onPair()),children:"Pair a device"}),t&&s.jsx("span",{className:"vf-err",children:t})]}):s.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 ",s.jsxs("code",{className:"t-code",children:[J.slug," --host 0.0.0.0"]})," on a network you trust. Another browser on this machine: run ",s.jsxs("code",{className:"t-code",children:[J.slug," pair"]}),"."]})}function R3(e){const[t,n]=w.useState(!1),[i,o]=w.useState(!1),[c,d]=w.useState(),u=async()=>{o(!0),d(await e.onRevoke().catch(f=>f.message)),o(!1),n(!1)};return t?s.jsxs("span",{className:"ra-revoke ask",children:[s.jsx("span",{className:"t-meta",children:"It’s signed out now."}),s.jsxs(R,{size:"sm",disabled:i,onClick:u,children:["Revoke ",e.name]}),s.jsx(R,{size:"sm",variant:"ghost",onClick:()=>n(!1),children:"Keep"})]}):s.jsxs("span",{className:"ra-revoke",children:[s.jsx(R,{size:"sm","aria-label":`Revoke ${e.name}`,onClick:()=>n(!0),children:"Revoke"}),c&&s.jsx("span",{className:"vf-err",children:c})]})}const M3={machine:"This machine",device:"Another device"};function L3(e){const t=Date.now();return s.jsx("ul",{className:"ra-list si-list",children:e.sessions.map(n=>s.jsx(fe,{as:"li",className:"ra-row",title:n.current?`${n.name} · this browser`:n.name,titleText:n.name,context:s.jsx(_,{parts:[M3[n.kind],n.via==="opened-page"?`From the page ${J.name} opened`:void 0,n.via==="opened-page"?{text:r1(n.id),code:!0}:void 0,`Paired ${is(n.pairedAt,t)}`,`Last used ${is(n.lastUsedAt,t)}`]}),below:n.current?void 0:s.jsx(R3,{name:n.name,onRevoke:()=>e.onRevoke(n.id)})},n.id))})}function O3(){return s.jsxs("div",{className:"ra-notes",children:[s.jsxs("p",{className:"t-meta ra-note",children:[s.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 ",s.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."]}),s.jsxs("p",{className:"t-meta ra-note",children:[s.jsx("b",{children:"What it can’t stop."})," A program that can read ",J.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:"," ",s.jsxs("code",{children:[J.slug," connect"]})," sets that up for the agents it registers."]})]})}const _y=`${J.apiPrefix}/sign-in`;async function Ld(e,t={}){const n=await fetch(`${_y}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return{ok:n.ok,reply:await n.json().catch(()=>({}))}}function P3(){const[e,t]=w.useState(),[n,i]=w.useState(),o=w.useCallback(()=>{fetch(`${_y}/sessions`).then(async f=>f.ok?await f.json():(await f.json().catch(()=>({}))).elsewhere?"elsewhere":null).then(t,()=>t(null))},[]);w.useEffect(o,[o]);const c=w.useCallback(async()=>{const{ok:f,reply:m}=await Ld("/codes");if(!f)return m.error??"No code could be made.";i(m)},[]),d=w.useCallback(async f=>{const{ok:m,reply:g}=await Ld("/revoke",{id:f});return o(),m?void 0:g.error??"That browser could not be revoked."},[o]),u=w.useCallback(async()=>{await Ld("/sign-out"),Ov(),location.reload()},[]);return{view:e,device:n,closeDevice:()=>(i(void 0),o()),pairDevice:c,revoke:d,signOut:u}}function D3(){const{view:e,device:t,closeDevice:n,pairDevice:i,revoke:o,signOut:c}=P3();if(!e)return null;const d=s.jsx("div",{className:"si-signout",children:s.jsx(R,{size:"sm",variant:"ghost",onClick:c,children:"Sign out of this browser"})});return e==="elsewhere"?s.jsxs(Ae,{title:"Browsers & devices",children:[s.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]}):s.jsxs(Ae,{title:"Browsers & devices",children:[s.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."}),s.jsx(L3,{sessions:e.sessions,onRevoke:o}),s.jsx(I3,{lan:e.lan,device:t,onPair:i,onDone:n}),d,s.jsx(O3,{})]})}function _3({managed:e}){const{signOut:t,pages:n}=e;return s.jsxs(Ae,{title:"Signed in",children:[s.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?s.jsxs("div",{className:"choice-row",children:[e.home&&s.jsxs(R,{size:"sm",onClick:()=>location.assign(e.home.href),children:["← ",e.home.label]}),n.map(i=>s.jsx(R,{size:"sm",onClick:()=>location.assign(i.href),children:i.label},i.href))]}):null,t?s.jsx("div",{className:"si-signout",children:s.jsx(R,{size:"sm",variant:"ghost",onClick:()=>location.assign(t),children:"Sign out"})}):null]})}function B3(){return w.useEffect(()=>{const e=setInterval(()=>void Va().then(t=>t!=="failed"&&location.reload()),3e3);return()=>clearInterval(e)},[]),s.jsx("div",{className:"pair-page",children:s.jsxs(Be,{as:"main",className:"pair-card",children:[s.jsx("div",{className:"onb-brand",children:s.jsx(Za,{className:"onb-title"})}),s.jsxs("h1",{className:"t-heading pair-title",children:[J.name," isn’t running here"]}),s.jsxs("p",{className:"t-body pair-step",children:["Start it with ",s.jsx("code",{className:"t-code",children:J.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 uh(e){const t=await fetch(`${J.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&&sC({id:n.id,secret:n.session,verifier:n.verifier})}function F3(e){const[t,n]=w.useState(!1),i=async()=>{n(!0);const o=await uh(e.code);if(!o)return location.reload();n(!1),e.onFailed(o)};return s.jsxs("div",{className:"pair-confirm",children:[s.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"," ",s.jsx("code",{className:"t-code",children:J.slug}),", ",s.jsxs("code",{className:"t-code",children:[J.slug," pair"]})," or Pair a device in the Lookout’s Settings."]}),s.jsx("div",{children:s.jsx(R,{variant:"primary",disabled:t,onClick:i,children:"Sign in this browser"})})]})}function Xg(){const[e,t]=w.useState(""),[n,i]=w.useState(!1),[o,c]=w.useState(),d=async()=>{if(!e.trim()||n)return;i(!0);const u=await uh(e);i(!1),c(u),u||location.reload()};return s.jsxs("form",{className:"pair-device",onSubmit:u=>{u.preventDefault(),d()},children:[s.jsxs("p",{className:"t-body pair-step",children:["On a phone or another computer: in the Lookout on the machine ",J.name," runs on, open Settings → You → Browsers & devices → Pair a device. Then type the code here, or scan it with this device’s camera."]}),s.jsxs("div",{className:"pair-code-row",children:[s.jsx("input",{className:"pair-code-input t-code",value:e,onChange:u=>t(u.target.value),placeholder:"ABCD-EFGH","aria-label":"Pairing code",autoComplete:"one-time-code",autoCapitalize:"characters",spellCheck:!1,maxLength:20}),s.jsx(R,{type:"submit",variant:"primary",disabled:n||!e.trim(),children:"Pair"})]}),o&&s.jsx("p",{className:"vf-err",role:"alert",children:o})]})}function Zg(){return s.jsxs("p",{className:"t-body pair-step pair-here",children:["On the machine ",J.name," runs on, run ",s.jsxs("code",{className:"t-code",children:[J.slug," pair"]}),": it opens a tab ready to sign in, with one click. Or open the Sign in link ",s.jsx("code",{className:"t-code",children:J.slug})," printed in its terminal."]})}function z3(e){return s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"t-body pair-step",children:"The Lookout opens only in browsers you’ve paired."}),e.local?s.jsx(Zg,{}):s.jsx(Xg,{}),e.local?s.jsx(Xg,{}):s.jsx(Zg,{})]})}function U3(e){const[t,n]=w.useState(),[i,o]=w.useState(e.code),[c,d]=w.useState(e.code);e.code!==c&&(d(e.code),o(e.code));const u=f=>(n(f),o(void 0));return s.jsx("div",{className:"pair-page",children:s.jsxs(Be,{as:"main",className:"pair-card",children:[s.jsx("div",{className:"onb-brand",children:s.jsx(Za,{className:"onb-title"})}),s.jsx("h1",{className:"t-heading pair-title",children:"Pair this browser"}),t&&s.jsx("p",{className:"pair-problem t-body",role:"alert",children:t}),i?s.jsx(F3,{code:i,onFailed:u}):s.jsx(z3,{local:e.local})]})})}function ek(){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 tk(){try{const e=await fetch(`${J.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&&Y$(t)?{kind:"signed-in"}:{kind:"signed-out",local:t.local===!0}}catch{return{kind:"no-server"}}}async function W3(){if(!Du())return tk();const e=await Va();return e==="proven"?{kind:"signed-in"}:e==="unknown"?tk():{kind:"not-running"}}function H3(){const[e,t]=w.useState({kind:"checking"});return w.useEffect(()=>void W3().then(t),[]),w.useEffect(()=>iC(n=>n==="failed"&&t({kind:"not-running"})),[]),e}function K3({children:e}){const t=H3(),[n,i]=w.useState(ek);return w.useEffect(()=>{const o=()=>i(c=>ek()??c);return window.addEventListener("hashchange",o),()=>window.removeEventListener("hashchange",o)},[]),w.useEffect(()=>{t.kind==="signed-in"&&n&&uh(n)},[t.kind,n]),t.kind==="checking"?null:t.kind==="signed-out"?s.jsx(U3,{local:t.local,code:n}):t.kind==="not-running"?s.jsx(B3,{}):s.jsx(s.Fragment,{children:e})}function G3(){const e=pt();return e?s.jsx(_3,{managed:e}):s.jsx(He,{id:"devices",storage:"machine",children:s.jsx(D3,{})})}const V3=[{value:"auto",title:"Match my system"},{value:"day",title:"Day"},{value:"night",title:"Night"}];function q3(e){return s.jsx("div",{className:"choice-row compact",children:V3.map(t=>s.jsx(at,{on:e.value===t.value,title:t.title,onClick:()=>e.onChange(t.value)},t.value))})}function Q3({data:e}){var i;const{prefs:t,update:n}=e;return s.jsxs(s.Fragment,{children:[s.jsx(He,{id:"appearance",storage:"browser",children:s.jsxs(Ae,{title:"Appearance",children:[Yv()?s.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."}):s.jsx(q3,{value:Jv(t.theme),onChange:o=>n({theme:o})}),((i=pt())==null?void 0:i.themeSave)&&s.jsx("p",{className:"vf-intro",children:"Saved to your account, so the server's pages follow it."})]})}),s.jsx(He,{id:"transcript",storage:"browser",children:s.jsx(Ae,{title:"HITL transcript",children:s.jsx(xy,{value:t.hitlTranscript,onChange:o=>n({hitlTranscript:o})})})}),s.jsx(He,{id:"agent",children:s.jsx(Ae,{title:"Agent",children:s.jsx("div",{className:"choice-row",children:bv.map(o=>s.jsx(at,{on:o.status==="primary",disabled:o.status!=="primary",title:o.name},o.id))})})}),s.jsx(G3,{})]})}function Y3(e){const{data:t,route:n}=e;switch(e.group){case"trail":return s.jsx(f3,{data:t});case"project":return s.jsx(ZO,{data:t,route:n});case"alerts":return s.jsx(uO,{data:t,route:n});case"you":return s.jsx(Q3,{data:t});case"projects":return s.jsx(He,{id:"projects",storage:"machine",children:s.jsx(kP,{})});case"about":return s.jsx(He,{id:"changelog",children:s.jsx(vO,{})});default:return e.group}}function J3(e){const{group:t,route:n}=e,i=w.useRef(null),o=w.useRef(null);return w.useEffect(()=>{var d,u;(d=i.current)==null||d.focus({preventScroll:!0});const c=n.section&&document.getElementById(`settings-${n.section}`);c?c.scrollIntoView({block:"start"}):(u=o.current)==null||u.scrollTo({top:0})},[t.id,n.section]),s.jsx("div",{className:"sp-pane",ref:o,children:s.jsxs("div",{className:"sp-pane-in",children:[s.jsxs("header",{className:"sp-pane-head",children:[s.jsx("h2",{className:"sp-title t-title",ref:i,tabIndex:-1,children:t.label}),s.jsx("p",{className:"sp-intro t-meta",children:t.intro})]}),s.jsx(Y3,{group:t.id,data:e.data,route:n})]})})}function X3(e){return s.jsx("nav",{className:"sp-nav","aria-label":"Settings groups",children:s.jsx("ul",{children:$r.map(t=>{const n=t.id===e.current;return s.jsx(fe,{as:"li",className:"sp-nav-row",selected:n,current:n?"page":void 0,title:t.label,context:s.jsx(_,{parts:t.sections.map(i=>i.title)}),trailing:e.drill&&"›",onOpen:()=>e.onPick(t.id)},t.id)})})})}function Z3(e,t){return e.group?$r.find(n=>n.id===e.group):t==="mobile"?void 0:$r[0]}const e4={page:"Back to the Lookout",list:"Lookout",group:"Settings"},t4=(e,t)=>e?t?"group":"list":"page";function n4(e){const{bp:t,route:n}=e,i=t==="mobile",o=Z3(n,t),c=t4(i,!!o),d=ji()===!1,u=()=>c==="group"?e.onShow({}):e.onClose();w.useEffect(()=>{const g=k=>{k.key!=="Escape"||k.defaultPrevented||document.querySelector(".scrim")||(c==="group"?e.onShow({}):e.onClose())};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[c,e]);const f=g=>e.onShow({group:g}),m=c!=="group"&&s.jsx(X3,{current:o==null?void 0:o.id,onPick:f,drill:i});return s.jsxs(Be,{className:`zone decisions-view settings-page sp-${t}`,"aria-label":"Settings",children:[s.jsxs("header",{className:"dv-head",children:[s.jsxs("button",{className:"back",onClick:u,children:["‹ ",e4[c]]}),c!=="group"&&s.jsx(Ke,{as:"h2",children:"Settings"}),!i&&s.jsx("span",{className:"dv-head-right t-meta",children:"Esc"})]}),d&&s.jsx(ZL,{}),s.jsxs("div",{className:"sp-body",children:[m,o&&s.jsx(J3,{group:o,data:e.data,route:n})]})]})}function s4(e){var o;const{rt:t,api:n,settings:i}=e;return i.route?s.jsx(n4,{bp:e.bp,route:i.route,onShow:i.show,onClose:i.close,data:{prefs:e.prefs,update:e.update,activeTracker:t.kind,location:t.adapter.location,map:(o=n.snap)==null?void 0:o.map,onMapMode:n.actions.setMode,snaps:Object.values(n.allSnaps),answered:n.activity.answered,onModelMatching:n.actions.setModelMatching,onOpenTicket:(c,d)=>{i.dismiss(),e.openTicket(c,d)}}}):null}function i4(e){var d;const{api:t,nav:n,attn:i}=e,o=n.fullTicket&&((d=t.selection)==null?void 0:d.kind)==="ticket",c=()=>n.setFullTicket(!1);return w.useEffect(()=>{if(!o)return;const u=f=>f.key==="Escape"&&!f.defaultPrevented&&n.setFullTicket(!1);return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[o,n]),o?s.jsxs(Be,{className:"ticket-drawer","aria-label":"Full ticket",children:[s.jsx("button",{type:"button",className:"bubble-close","aria-label":"Close the full ticket",onClick:c,children:"×"}),s.jsx(FM,{api:t,sessions:e.sessions,bare:!0,attention:i.attention.view,done:e.done,onOpenChat:u=>n.openChat(u),onOpenDecision:n.openDecisions,onItem:u=>i.open(u),onReviewChange:i.handlers.openApprovals,onReviewBrief:i.handlers.openBrief,onDismiss:i.attention.dismiss})]}):null}function r4(e){return s.jsxs("section",{className:"panel trail-list agents-list",children:[s.jsx(yt,{title:"Agents at work",count:s.jsx("span",{className:"n mono-label",children:e.working.length})}),e.working.length===0&&s.jsx(Te,{children:"No agent is on this trail now"}),s.jsx("ul",{className:"trail-list-rows",children:e.working.map(t=>{const n=t.session,i=Sr(n==null?void 0:n.model),o=n?[{text:n.agent,strong:!0},i&&{text:i,tip:n.model},`step ${n.step} of ${n.total}`,n.stepLabel.toLowerCase(),Je(e.now-n.startedAt)]:[{text:t.ticket.assignee??"An agent",strong:!0},"claimed, no live session"];return s.jsx(fe,{as:"li",className:"agent-row",title:`${t.ticket.key} ${t.ticket.title}`,context:s.jsx(_,{parts:o}),trailing:n&&s.jsx(uy,{step:n.step,total:n.total,mini:!0}),onOpen:()=>e.onTicket(t.ticket.id),actions:n&&s.jsx(R,{size:"sm",onClick:()=>e.onOpenChat(n.id),children:"Chat"})},t.ticket.id)})})]})}function o4(e){return e.items.length?s.jsxs("div",{className:"other-trails",children:[s.jsx(yt,{title:"Other trails",count:s.jsx("span",{className:"n mono-label",children:e.items.length})}),s.jsx(hw,{view:{...e.view,items:e.items},snaps:e.snaps,pending:e.pending,currentMapId:e.currentMapId,handlers:e.handlers,onSnooze:e.onSnooze,onDismiss:e.onDismiss})]}):null}function a4(e){const t=e.items.slice(0,e.max),n=e.items.length-t.length;return t.length?s.jsxs("span",{className:"need-chips",children:[t.map(i=>s.jsx("button",{type:"button",className:ue("need-chip",e.selected===i.id&&"on"),title:i.title,onClick:()=>e.onOpen(i),children:QE(i,e.keyOf)},i.id)),n>0&&s.jsxs("button",{type:"button",className:"need-chip more",onClick:e.onMore,children:["+",n]})]}):null}function c4(e){const t=new Map(e.map(o=>[o.id,o])),n=new Map,i=(o,c)=>{var m;const d=n.get(o);if(d!==void 0)return d;if(c.has(o))return 0;c.add(o);const u=((m=t.get(o))==null?void 0:m.blockedBy.filter(g=>t.has(g)))??[],f=u.length?1+Math.max(...u.map(g=>i(g,c))):0;return n.set(o,f),f};return new Map(e.map(o=>[o.id,i(o.id,new Set)]))}function l4(e){const t=[...e.values()].filter(i=>i.tone!=="cancelled"),n=c4(t.map(i=>i.ticket));return t.map((i,o)=>({l:i,i:o,d:n.get(i.ticket.id)??0})).sort((i,o)=>i.d-o.d||i.i-o.i).map(({l:i})=>({id:i.ticket.id,key:i.ticket.key,title:i.ticket.title,tone:i.tone}))}function d4(e,t){const n=i=>e.filter(o=>o.tone===i).length;return{done:n("done"),total:e.length,working:n("working"),needs:t.length,waiting:n("waiting-agent"),notStarted:n("not-started")}}function u4(e){const t=[{n:e.working,text:`${e.working} working`},{n:e.needs,text:`${e.needs} need${e.needs===1?"s":""} you`,urgent:!0},{n:e.waiting,text:`${e.waiting} waiting for an agent`},{n:e.notStarted,text:`${e.notStarted} not started`}];return[{text:`${e.done} of ${e.total} done`},...t.filter(n=>n.n>0).map(({text:n,urgent:i})=>({text:n,urgent:i}))]}const nk={done:"done",working:"an agent is on it",needs:"needs you","waiting-agent":"waiting for an agent","not-started":"not started"};function h4(e){return s.jsx("div",{className:"trail-segments",role:"list","aria-label":"Tickets on the trail",children:e.segments.map(t=>s.jsx("button",{type:"button",role:"listitem",className:ue("seg",`seg-${t.tone}`,e.selected===t.id&&"on"),title:`${t.key} ${t.title} · ${nk[t.tone]}`,"aria-label":`${t.key} ${t.title}: ${nk[t.tone]}`,onClick:()=>e.onSelect(t.id)},t.id))})}function f4(e){const t=e.more||e.fixed;return s.jsxs("div",{className:ue("trail-bar-zone",t&&"extended"),children:[s.jsxs(Be,{className:"trail-bar",children:[s.jsx("span",{className:"t-label",children:"Trail"}),s.jsx(h4,{segments:e.segments,selected:e.selected,onSelect:e.onTicket}),s.jsx("span",{className:"trail-counts",children:u4(e.counts).map((n,i)=>s.jsxs("span",{className:ue(i===0&&"strong",n.urgent&&"urgent"),children:[i>0&&s.jsx("span",{className:"sep",children:" · "}),n.text]},n.text))}),!t&&s.jsx(a4,{items:e.needs,keyOf:e.keyOf,onOpen:e.onNeed,onMore:()=>e.onMore(!0),max:e.chips}),!e.fixed&&s.jsx(R,{size:"sm","aria-expanded":e.more,onClick:()=>e.onMore(!e.more),children:e.more?"Less":"More"})]}),t&&s.jsx("div",{className:"trail-lists",children:e.lists})]})}const m4=6;function p4(e,t){const n=e.filter(o=>o.tone==="waiting-agent").sort((o,c)=>(o.readySince??0)-(c.readySince??0)).map(o=>({ticket:o.ticket,context:`Waiting for an agent to pick it up · ${Je(Math.max(0,t-(o.readySince??t)))}`})),i=e.filter(o=>o.waitsOnYours.length>0).map(o=>({ticket:o.ticket,context:`Waits on your ${o.waitsOnYours.join(", ")}`}));return[...n,...i].slice(0,m4)}function g4(e){const t=p4(e.live,e.now);return s.jsxs("section",{className:"panel trail-list upnext-list",children:[s.jsx(yt,{title:"Up next",count:s.jsx("span",{className:"n mono-label",children:t.length})}),t.length===0&&s.jsx(Te,{children:"Nothing ready"}),s.jsx("ul",{className:"trail-list-rows",children:t.map(n=>s.jsx(fe,{as:"li",title:`${n.ticket.key} ${n.ticket.title}`,context:s.jsx(_,{parts:[n.context]}),onOpen:()=>e.onTicket(n.ticket.id)},n.ticket.id))})]})}const By="teamtrail.trail-bar.more";function k4(){try{return localStorage.getItem(By)==="yes"}catch{return!1}}function v4(){const[e,t]=w.useState(k4);return[e,i=>{t(i);try{localStorage.setItem(By,i?"yes":"no")}catch{}}]}function w4(e){const{api:t,nav:n,attn:i,trail:o}=e,[c,d]=v4(),u=gt(5e3),f=t.selection,m=[...o.live.values()],g=m.filter(S=>S.tone==="working"||S.tone==="needs"&&S.session),k=S=>n.select({kind:"ticket",id:S}),y=i.attention.view,b={...i.attention,view:y&&{...y,items:o.items}};return t.snap?s.jsx(f4,{segments:o.segments,counts:o.counts,needs:o.items,keyOf:o.keyOf,selected:(f==null?void 0:f.kind)==="ticket"?f.id:void 0,more:c,fixed:e.bp==="mobile",chips:e.bp==="wide"?3:2,onMore:d,onTicket:k,onNeed:i.open,lists:s.jsxs(s.Fragment,{children:[s.jsxs(Be,{className:"trail-list needs-list",children:[s.jsx(ZE,{activity:t.activity,snaps:t.allSnaps,currentMapId:t.mapId,attention:b,handlers:i.handlers,onOpenQuestion:S=>{const x=t.activity.pending.find($=>$.sessionId===S);x&&n.openQuestion(x.id)},onOpenTicket:n.openTicket,brief:e.brief}),y&&s.jsx(o4,{view:y,items:o.elsewhere,snaps:t.allSnaps,pending:t.activity.pending,currentMapId:t.mapId,handlers:i.handlers,onSnooze:i.attention.snooze,onDismiss:i.attention.dismiss})]}),s.jsx(r4,{working:g,now:u,onTicket:k,onOpenChat:S=>n.openChat(S)}),s.jsx(g4,{live:m,now:u,onTicket:k})]})}):null}function y4(e,t){const[n,i]=w.useState(!1);return{open:()=>i(!0),startOver:d=>void t.actions.setArchived(!0).then(()=>i(jE(d))),dialog:n&&s.jsx(iL,{rt:e,seed:typeof n=="object"?n:void 0,onClose:()=>i(!1),onCreated:d=>t.actions.selectMap(d)})}}const x4=390;function sk(e){return e>900?x4:0}function j4(){return s.jsxs("defs",{children:[s.jsx("pattern",{id:"map-grid",width:"40",height:"40",patternUnits:"userSpaceOnUse",children:s.jsx("path",{d:"M40 0H0V40",fill:"none",stroke:"var(--map-grid)",strokeWidth:"1"})}),s.jsx("pattern",{id:"hatch-oos",width:"10",height:"10",patternUnits:"userSpaceOnUse",patternTransform:"rotate(45)",children:s.jsx("line",{x1:"0",y1:"0",x2:"0",y2:"10",stroke:"var(--line2)",strokeWidth:"1"})})]})}function hh(e){return e.filter(t=>t.state!=="out-of-scope").map(t=>({x:t.x,y:t.y,w:Oe,h:ze}))}const Aa=(e,t)=>`${e}>${t}`;function b4(e,t,n=[]){const i=new Map(e.tickets.map(c=>[c.id,c]));return{tickets:t.nodes.map(c=>{const d=i.get(c.id);return d?{...d,blockedBy:[...c.blockedBy,...c.removedEdges??[]]}:{id:c.id,key:"+",title:c.title,type:c.type,body:"",state:"open",blockedBy:c.blockedBy,comments:[],createdAt:e.map.updatedAt,updatedAt:e.map.updatedAt}}),marks:new Map(t.nodes.map(c=>[c.id,c.mark])),newEdges:new Set(t.nodes.flatMap(c=>c.newEdges.map(d=>Aa(d,c.id)))),removedEdges:new Set(t.nodes.flatMap(c=>(c.removedEdges??[]).map(d=>Aa(d,c.id)))),frozen:new Set(n)}}function S4(e,t){const n=fS({...e,tickets:t}),i=new Set;for(let o=1;o<n.length;o++)i.add(Aa(n[o-1].id,n[o].id));return i}function Ia(e){const t=Tr[e.direction],n=t.sub-t.along,i=e.node.wrap,o=i&&i.sub>0?n:e.outer,c=i&&i.sub<i.subs-1?n:e.outer;return{before:o,after:c}}function N4(e){const{obstacles:t,from:n,to:i,clear:o}=e,c=t.flatMap(u=>[u.y-28,u.y+u.h+28]).filter(o),d=u=>Math.abs(u-n)+Math.abs(u-i);return c.reduce((u,f)=>d(f)<d(u)?f:u,c[0]??n)}const $4=6;function Fy(e){const t=e.filter((o,c)=>c===0||o.x!==e[c-1].x||o.y!==e[c-1].y);let n=`M${t[0].x} ${t[0].y}`;for(let o=1;o<t.length-1;o++){const[c,d,u]=[t[o-1],t[o],t[o+1]],f=Math.min($4,ik(c,d)/2,ik(d,u)/2),m=rk(d,c,f),g=rk(d,u,f);n+=`L${m.x} ${m.y}Q${d.x} ${d.y} ${g.x} ${g.y}`}const i=t[t.length-1];return`${n}L${i.x} ${i.y}`}function ik(e,t){return Math.abs(e.x-t.x)+Math.abs(e.y-t.y)}function rk(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 pi(e){const t=e.direction==="TB",n=d=>t?{x:d.y,y:d.x}:d,i=n(e.a),o=n(e.b),c=e.obstacles.map(d=>t?{x:d.y,y:d.x,w:d.h,h:d.w}:d);return Fy(C4({a:i,b:o,obstacles:c,gap:e.gap,gapIn:e.gapIn??e.gap}).map(n))}function C4(e){const{a:t,b:n,obstacles:i,gap:o,gapIn:c}=e,d=i.filter(k=>k.x+k.w>t.x+1&&k.x<n.x-1),u=k=>!d.some(y=>k>y.y-8&&k<y.y+y.h+8),f=Math.min(t.x+o/2,(t.x+n.x)/2),m=Math.max(n.x-c/2,(t.x+n.x)/2);if(u(t.y))return[t,{x:m,y:t.y},{x:m,y:n.y},n];if(u(n.y))return[t,{x:f,y:t.y},{x:f,y:n.y},n];const g=N4({obstacles:d,from:t.y,to:n.y,clear:u});return[t,{x:f,y:t.y},{x:f,y:g},{x:m,y:g},{x:m,y:n.y},n]}function T4(e){const{direction:t,from:n,to:i,cards:o}=e,c=Tr[t],d=c.layer-c.along,u=Ia({direction:t,node:n,outer:d}).after,f=Ia({direction:t,node:i,outer:d}).before;if(t==="LR"){const k={x:n.x+Oe,y:n.y+ze/2},y={x:i.x,y:i.y+ze/2};return pi({direction:t,a:k,b:y,obstacles:o,gap:u,gapIn:f})}const m={x:n.x+Oe/2,y:n.y+ze},g={x:i.x+Oe/2,y:i.y};return pi({direction:t,a:m,b:g,obstacles:o,gap:u,gapIn:f})}const ok=e=>e.ticket.state==="closed"&&e.ticket.closeReason==="completed";function E4(e){const{from:t,to:n,direction:i}=e,c=["edge",t.ticket.state!=="open"?"edge-done":"edge-open"];return ok(t)&&ok(n)&&c.push("edge-travelled"),e.critical&&c.push("edge-critical"),e.added&&c.push("edge-added"),e.removed&&c.push("edge-removed"),s.jsx("path",{className:c.join(" "),d:T4({direction:i,from:t,to:n,cards:e.cards})})}function A4(e){const{snap:t,tickets:n,direction:i,preview:o}=e,c=w.useMemo(()=>S4(t,n),[t,n]),d=w.useMemo(()=>hh(e.nodes),[e.nodes]);return e.edges.map(({from:u,to:f})=>{const m=Aa(u.ticket.id,f.ticket.id);return s.jsx(E4,{from:u,to:f,direction:i,cards:d,critical:c.has(m),added:o==null?void 0:o.newEdges.has(m),removed:o==null?void 0:o.removedEdges.has(m)},m)})}function I4(e,t,n){return!!t&&e.state==="frontier"&&!n}const fh=24,R4=13,M4=9.5;function L4(e){const t=e.guide;return s.jsx("g",{className:"meta",transform:`translate(${fh} ${e.y})`,children:e.chips.map((n,i)=>{const o=n.kind==="guide"?t:void 0;return s.jsxs("g",{className:ue("card-chip",n.kind,n.kind==="state"&&e.tone,(o==null?void 0:o.off)&&"off"),"data-guide-id":o==null?void 0:o.id,transform:`translate(${n.x} 0)`,children:[o&&s.jsx("title",{children:o.tip}),s.jsx("rect",{width:n.w,height:R4,rx:3}),s.jsx("text",{x:(n.w-n.textW)/2,y:M4,textLength:n.textW,lengthAdjust:"spacingAndGlyphs",children:n.text})]},i)})})}function O4(e,t){return e.length?e.length>2?`waits on ${e.length} tickets`:`waits on ${e.map(i=>t.includes(i)?`your ${i}`:i).join(", ")}`:void 0}const zy=5,P4={sans:"9.5px 'Figtree Variable', system-ui, sans-serif",mono:"8.55px 'JetBrains Mono Variable', ui-monospace, monospace"};let mr;function D4(){if(mr!==void 0)return mr;try{mr=typeof document>"u"?null:document.createElement("canvas").getContext("2d")}catch{mr=null}return mr}function _4(e,t="sans"){const n=D4();return n?(n.font=P4[t],n.measureText(e).width*1.04):e.length*zy}const ak=4,ck=3,B4=6;function F4(e){var k;const t=Oe-fh-8-(e.reserve??0),n=((k=e.state)==null?void 0:k.split(" · "))??[],i=[{kind:"key",text:e.key},...e.type?[{kind:"type",text:e.type}]:[],...e.guide===void 0?[]:[{kind:"guide",text:e.guide}],...n.map(y=>({kind:"state",text:y})),...e.needsYou?[{kind:"needs",text:"needs you"}]:[]],o=t-i.length*2*ak-(i.length-1)*ck,c=y=>_4(y.text,y.kind==="key"?"mono":"sans"),d=i.filter(y=>y.kind!=="guide").reduce((y,b)=>y+c(b),0),u=Math.max(B4,Math.floor((o-d)/zy)),f=i.map(y=>y.kind==="guide"?{...y,text:sI(y.text,u)}:y),m=Math.min(1,o/f.reduce((y,b)=>y+c(b),0));e.onScale&&e.onScale(m);let g=0;return f.map(y=>{const b=c(y)*m,S={...y,x:g,w:b+2*ak,textW:b};return g+=S.w+ck,S})}function z4(e,t,n){return{text:[e.agent,n,t?`${e.step}/${e.total}`:void 0].filter(Boolean).join(" · "),tone:"agent"}}function U4(e){const{n:t,session:n}=e,i=t.ticket.assignee;return e.waiting?{text:"waiting on you",tone:"urgent"}:e.need?{text:e.need,tone:"urgent"}:e.stalled?{text:`stalled · ${i}`,tone:"warn"}:e.brief?{text:"waits on brief",tone:"warn"}:e.wait?{text:`needs ${e.wait}`,tone:"warn"}:n?z4(n,e.step,e.model):t.state==="claimed"?{text:i??"working",tone:"agent"}:t.state==="verifying"?{text:"checks running",tone:"agent"}:e.readyFor!==void 0?{text:`waiting for an agent · ${e.readyFor}`,tone:"wait"}:e.waitsOn?{text:e.waitsOn,tone:"waits"}:t.state==="decided"&&e.verified?{text:"verified",tone:"verified"}:{text:Rv[t.state],tone:""}}function W4(e){var b;const{n:t,live:n,marked:i}=e,o=t.ticket,c=n==null?void 0:n.items[0],d=t.state==="frontier"?n==null?void 0:n.readySince:void 0,u=d===void 0?void 0:Je(Math.max(0,e.now-d)),f=n&&O4(n.waitsOn,n.waitsOnYours),m=S=>i?void 0:U4({n:t,session:n==null?void 0:n.session,waiting:e.waiting,need:c&&xw(c),stalled:e.stalled,brief:e.brief,wait:e.wait,step:!e.guide,model:S,readyFor:u,waitsOn:f,verified:e.verified}),g=S=>{let x=1;const $=m(S);return{chips:F4({key:o.key,type:($==null?void 0:$.tone)==="wait"||($==null?void 0:$.tone)==="waits"?void 0:ns[o.type],guide:e.guide,state:$==null?void 0:$.text,needsYou:e.needsYou&&!c,reserve:e.reserve,onScale:O=>x=O}),tone:$==null?void 0:$.tone,scale:x}},k=Sr((b=n==null?void 0:n.session)==null?void 0:b.model),y=k?g(k):void 0;return y&&y.scale>=1?y:g()}function H4(e,t,n){const i=e.state==="frontier"||e.state==="rework";if(!(!t||n||e.ticket.assignee||!i))return t}function K4(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&&t.push("stalled"),e.mark&&t.push(`mark-${e.mark}`),e.frozen&&t.push("frozen"),e.pickUp&&t.push("pick-up"),t.join(" ")}function G4({wait:e,session:t}){return e?s.jsx("title",{children:`Needs a ${e} model: no connected agent runs one`}):t?s.jsx("title",{children:`${t.agent} · step ${t.step}/${t.total} · ${t.stepLabel.toLowerCase()}`}):null}const V4={claimed:"working",verifying:"working",frontier:"ready",blocked:"backlog",parked:"backlog",decided:"done","out-of-scope":"cancelled",rework:"attention",held:"attention"};function q4(e){const t=V4[e.state];return t==="done"||t==="cancelled"?t:e.attention?"attention":e.live?"working":t}function Q4({mark:e,frozen:t}){const n=e&&e!=="unchanged"&&e!=="cancelled"?e:void 0;return s.jsxs(s.Fragment,{children:[e==="cancelled"&&s.jsx("line",{className:"strike",x1:8,y1:ze/2,x2:Oe-8,y2:ze/2}),n&&s.jsx("text",{className:"reroute-tag",x:Oe-8,y:ze-7,textAnchor:"end",children:n}),t&&s.jsx("text",{className:"freeze",x:Oe-(n?58:8),y:ze-7,textAnchor:"end",children:"❄"})]})}function Uy(e){const{tone:t,cy:n}=e;if(t==="done")return s.jsx("path",{className:`dot dot-done${e.verified?" dot-verified":""}`,d:`M10 ${n}l2.5 2.5 4.5 -5`});if(e.spin)return s.jsx("circle",{className:"dot dot-spin",cx:13,cy:n,r:4.5});const i=s.jsx("circle",{className:`dot dot-${t}`,cx:13,cy:n,r:t==="backlog"?3:3.5});return e.pulse?s.jsxs(s.Fragment,{children:[s.jsx("circle",{className:"dot-pulse",cx:13,cy:n,r:3.5}),i]}):i}const Od=8;function Y4({step:e,total:t}){const n=Oe-Od*2,i=t>0?Math.max(0,Math.min(1,(e-.5)/t)):0;return s.jsxs("g",{className:"step-bar","aria-hidden":"true",children:[s.jsx("rect",{className:"step-track",x:Od,y:3,width:n,height:2.5,rx:1}),s.jsx("rect",{className:"step-fill",x:Od,y:3,width:n*i,height:2.5,rx:1})]})}function J4(e,t,n=2){const i=e.split(/\s+/),o=[];let c="";for(const d of i)(c+" "+d).trim().length>t?(o.push(c.trim()),c=d):c+=" "+d;if(o.push(c.trim()),o.length>n){const d=o.slice(0,n);return d[n-1]=d[n-1].slice(0,t-1)+"…",d}return o}const X4=26;function Z4({n:e,live:t,now:n,stalled:i,flag:o,selected:c,onSelect:d,mark:u,frozen:f,needs:m,verified:g,briefHeld:k}){const y=e.ticket,b=t==null?void 0:t.session,S=J4(y.title,X4),x=gi(y)==="hitl",$=!!(b!=null&&b.waitingOn),N=!!u&&u!=="unchanged",O=H4(e,m,!!b),D=I4(e,k,!!b),F=LI(Gk(y).find(be=>{var ae;return!((ae=y.guidesRemoved)!=null&&ae.includes(be))})),K=x&&!N&&(y.type==="task"||y.type==="execute"),I=eD(u,f),Q=W4({n:e,live:t,now:n,marked:N,waiting:$,stalled:i,brief:D,wait:O,verified:g,needsYou:K,reserve:I,guide:F==null?void 0:F.name}),Z=$||(t==null?void 0:t.tone)==="needs",q=[Z,i,D,O,K&&e.state==="frontier"].some(Boolean),ee=q4({state:e.state,live:!!b,attention:q}),Se=(t==null?void 0:t.tone)==="waiting-agent"&&!N&&!f,ve=S.length>1?19:24;return s.jsxs("g",{className:K4({n:e,tone:ee,hitl:x,selected:c,live:!!b,waiting:Z,stalled:i,mark:u,frozen:f,pickUp:Se}),style:{transform:`translate(${e.x}px, ${e.y}px)`},"data-ticket":y.key,onClick:be=>{be.stopPropagation(),d({kind:"ticket",id:y.id})},children:[s.jsx(G4,{wait:O,session:b}),s.jsx("rect",{className:"ring",x:-3.5,y:-3.5,width:Oe+7,height:ze+7,rx:9}),s.jsx("rect",{className:"card",x:.5,y:.5,width:Oe-1,height:ze-1,rx:6}),b&&s.jsx(Y4,{step:b.step,total:b.total}),s.jsx(Uy,{tone:ee,cy:ve-4,verified:g,spin:Se,pulse:!!b&&!$}),S.map((be,ae)=>s.jsx("text",{className:"title",x:fh,y:ve+ae*14,children:be},ae)),s.jsx(L4,{chips:Q.chips,y:ve+S.length*14-8,tone:Q.tone,guide:F}),o&&s.jsx("circle",{className:`pr-flag-dot ${o}`,cx:Oe-2,cy:2,r:4}),s.jsx(Q4,{mark:u,frozen:f})]})}function eD(e,t){return(e&&e!=="unchanged"&&e!=="cancelled"?44:0)+(t?12:0)}function mh(e){const{groups:t,nodes:n,ends:i}=e,o=t.filter((u,f)=>{const m=n.filter(g=>{var k;return((k=g.wrap)==null?void 0:k.group)===f});return m.length>0&&m.every(g=>i.includes(g))}),c=new Set(o.map(u=>t.indexOf(u))),d=i.filter(u=>u.wrap===void 0||!c.has(u.wrap.group));return{whole:o,single:d}}const lk=16,dk=8;function Wy(e){const{group:t,side:n}=e,i=e.direction==="TB",o=i?{x:t.y,y:t.x,w:t.h,h:t.w}:t,c=n==="before"?o.x-lk:o.x+o.w+lk,d=n==="before"?c+dk:c-dk,u=m=>i?{x:m.y,y:m.x}:m,f=[{x:d,y:o.y},{x:c,y:o.y},{x:c,y:o.y+o.h},{x:d,y:o.y+o.h}].map(u);return{d:Fy(f),at:u({x:c,y:o.y+o.h/2})}}function Hy(e){const{whole:t,single:n}=mh(e);if(t.length)return;const i=n.filter(c=>c.ticket.type!=="review"),o=i.length===1?i[0]:tD(n);if(o)return e.direction==="LR"?o.y+ze/2:o.x+Oe/2}const tD=e=>e.length===1?e[0]:void 0,li=62,di=26,ku={LR:{x:130,y:0},TB:{x:0,y:84}},nD={LR:96,TB:48};function sD(e,t){return t?ku[e]:{x:0,y:0}}function iD(e){const{direction:t,nodes:n,groups:i}=e,o=n.filter(x=>x.state!=="out-of-scope"&&!x.ticket.blockedBy.some($=>n.some(N=>N.ticket.id===$))),{whole:c,single:d}=mh({groups:i,nodes:n,ends:o}),u=hh(n),f=nD[t],m=Hy({direction:t,nodes:n,groups:i,ends:o}),g=t==="LR"?{x:-ku.LR.x+20,y:(m??e.graphH/2)-di/2}:{x:(m??e.width/2)-li/2,y:-ku.TB.y+16},k=t==="LR"?{x:g.x+li,y:g.y+di/2}:{x:g.x+li/2,y:g.y+di},y=x=>t==="LR"?{x:x.x,y:x.y+ze/2}:{x:x.x+Oe/2,y:x.y},b=d.map(x=>{const $=Ia({direction:t,node:x,outer:f}).before;return pi({direction:t,a:k,b:y(x),obstacles:u,gap:f,gapIn:$})}),S=c.flatMap(x=>{const $=Wy({direction:t,group:x,side:"before"});return[pi({direction:t,a:k,b:$.at,obstacles:u,gap:f,gapIn:f-32}),$.d]});return{...g,edges:[...b,...S]}}function rD(e){const{tone:t}=e,n=t==="passed";return s.jsxs(s.Fragment,{children:[e.edges.map(i=>s.jsx("path",{className:ue("edge",n?"edge-done":"edge-open"),d:i},i)),s.jsxs("g",{className:ue("node main-mark",`main-${t}`,t==="needs"&&"waiting",e.selected&&"sel"),transform:`translate(${e.x} ${e.y})`,role:"button",tabIndex:0,"aria-label":"Checks on main",onClick:i=>{i.stopPropagation(),e.onSelect()},onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&e.onSelect()},children:[s.jsx("rect",{className:"ring",x:-3.5,y:-3.5,width:li+7,height:di+7,rx:8}),s.jsx("rect",{className:"card",x:.5,y:.5,width:li-1,height:di-1,rx:5}),n?s.jsx("path",{className:"dot dot-done dot-verified",d:"M8 13l2.5 2.5 4.5 -5"}):s.jsx("circle",{className:ue("dot",`main-dot-${t}`),cx:11,cy:13,r:3.5}),s.jsx("text",{className:"main-label",x:20,y:17,children:"main"})]})]})}const oD={LR:96,TB:48};function aD(e){const t=Hy({...e,ends:Ky(e)});if(e.direction==="LR"){const i=e.width+96;return{x:i,y:t??e.graphH/2,right:i+34,bottom:e.height}}const n=e.graphH+76;return{x:t??e.width/2,y:n,right:e.width,bottom:Math.max(e.height,n+40)}}function Ky(e){const t=new Set(e.edges.map(n=>n.from));return e.nodes.filter(n=>n.state!=="out-of-scope"&&!t.has(n))}function cD(e,t){const{direction:n}=e,{whole:i,single:o}=mh({groups:e.groups,nodes:e.nodes,ends:Ky(e)}),c=hh(e.nodes),d=oD[n],u=n==="LR"?{x:t.x-30,y:t.y}:{x:t.x,y:t.y-30},f=k=>n==="LR"?{x:k.x+Oe,y:k.y+ze/2}:{x:k.x+Oe/2,y:k.y+ze},m=o.map(k=>{const y=Ia({direction:n,node:k,outer:d}).after;return pi({direction:n,a:f(k),b:u,obstacles:c,gap:y,gapIn:d})}),g=i.flatMap(k=>{const y=Wy({direction:n,group:k,side:"after"});return[y.d,pi({direction:n,a:y.at,b:u,obstacles:c,gap:d-32,gapIn:d})]});return[...m,...g]}function Gy(){return s.jsxs(s.Fragment,{children:[s.jsx("path",{className:"flag-ground",d:"M-17 18 C-12 17 -5 17 1 18"}),s.jsx("path",{className:"flag-pole",d:"M-8 18 C-8.6 6 -7.6 -6 -8 -18"}),s.jsx("path",{className:"flag-cloth",d:"M-8 -18 C-1 -16 6 -13 15 -10 C6 -7.5 -1 -5.5 -8 -3 Z"})]})}function lD(e){const{x:t,y:n,text:i,done:o,onSelect:c}=e,d=i&&Gu(i)||"Where this trail ends",u=o&&o.kind!=="not-done",f=u?`Destination reached · ${o.reason}
176
+ ${d}`:`Destination
177
+ ${d}`,m=(o==null?void 0:o.kind)==="unverified"&&o.together.kind==="failed",g=ue("destination",u&&`reached ${o.kind}`,m&&"failing",e.selected&&"sel");return s.jsxs("g",{className:g,transform:`translate(${t} ${n})`,"aria-label":f,"data-tip":f,tabIndex:0,role:c?"button":void 0,onClick:k=>{c&&(k.stopPropagation(),c())},onKeyDown:k=>{c&&(k.key==="Enter"||k.key===" ")&&c()},children:[s.jsx("rect",{className:"x-hit",x:-24,y:-24,width:48,height:48}),u?s.jsx(Gy,{}):s.jsxs(s.Fragment,{children:[s.jsx("path",{className:"x-stroke",d:"M-15 -16 C-9 -10 2 4 16 17"}),s.jsx("path",{className:"x-stroke",d:"M17 -15 C8 -8 -6 5 -16 17"})]})]})}function dD({trails:e,travelled:t}){const n=t?"edge edge-done edge-travelled edge-destination":"edge edge-open edge-destination";return e.map(i=>s.jsx("path",{className:n,d:i},i))}function uD(e){const{laid:t,spot:n,done:i}=e,o=!!i&&i.kind!=="not-done";return s.jsxs(s.Fragment,{children:[s.jsx(dD,{trails:cD(t,n),travelled:o}),t.nodes.length>0&&s.jsx(lD,{x:n.x,y:n.y,text:e.text,done:i,selected:e.selected,onSelect:e.onSelect})]})}const Ra=.95;function hD(e,t){const n=new Map(e.map(u=>[u.ticket.id,u])),i=t.map(u=>n.get(u)).filter(u=>!!u),o=e.filter(u=>u.state==="claimed"||u.state==="verifying"),c=[...i,...o.filter(u=>!i.includes(u))];if(c.length)return c;const d=e.find(u=>u.state==="frontier")??e[0];return d?[d]:[]}function uk(e,t){return{left:Math.min(...e.map(n=>n.x))+t,top:Math.min(...e.map(n=>n.y))+t,right:Math.max(...e.map(n=>n.x+Oe))+t,bottom:Math.max(...e.map(n=>n.y+ze))+t}}function fD(e){const{fit:t,nodes:n,size:i,pad:o}=e;if(t.k>=Ra)return t;const c=hD(n,e.focus??[]);if(!c.length)return t;const d=Ra,u=Math.max(i.w/2,i.w-(e.room??0)),f=uk(c,o),g=(f.right-f.left)*d<=u-32&&(f.bottom-f.top)*d<=i.h-32?f:uk(c.slice(0,1),o);return{k:d,x:u/2-(g.left+g.right)/2*d,y:i.h/2-(g.top+g.bottom)/2*d}}function mD(e){const{y:t,width:n,height:i}=e,o=e.nodes.filter(c=>c.state==="out-of-scope").length;return o?s.jsxs("g",{className:"quarantine",children:[s.jsx("rect",{x:-20,y:t-30,width:n+40,height:i+18,fill:"url(#hatch-oos)"}),s.jsx("line",{x1:-20,y1:t-30,x2:n+20,y2:t-30}),s.jsxs("text",{x:-12,y:t-12,children:["Out of scope · ",o]})]}):null}const st=280,hk=4,pD=220,oi=e=>Math.round(e/hk)*hk;function gD(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 Pd(e,t,n,i){return Array.from({length:6},()=>{const o=i*(.5+e()*.7),c=i*(.3+e()*.4);return{x:oi(t+(e()-.5)*i*.8-o/2),y:oi(n+(e()-.5)*i*.5-c/2),w:oi(o),h:oi(c)}})}function kD(e){const{width:t,height:n,nodes:i}=e,o=gD(e.seed),c=(y,b)=>y+o()*(b-y),d=(y,b)=>!i.some(S=>y>S.x-52&&y<S.x+Oe+28&&b>S.y-52&&b<S.y+ze+28),u=(t+st*2)*(n+st*2),f=Array.from({length:Math.round(u/9e4)},()=>Pd(o,c(-st,t+st),c(-st,n+st),c(160,360))).flat(),m=[...Pd(o,t+st*.55,n+st*.55,300),...Pd(o,-st*.5,-st*.45,220)],g=[],k=(y,b,S)=>{g.length<pD&&d(b,S)&&g.push({sprite:y,x:oi(b),y:oi(S)})};for(let y=0;y<Math.round(u/3e4);y++){const b=c(-st,t+st),S=c(-st,n+st),x=3+Math.floor(o()*5);for(let $=0;$<x;$++)k(o()<.65?"pine":"oak",b+c(-70,70),S+c(-44,44))}for(let y=0;y<Math.round(u/45e3);y++)k(o()<.4?"rock":"tuft",c(-st,t+st),c(-st,n+st));return g.sort((y,b)=>y.y-b.y),{grass:f,water:m,items:g}}const Vy={pine:s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"16",y:"30",width:"4",height:"10",fill:"var(--map-trunk)"}),s.jsx("path",{d:"M18 0l9 12h-4l8 10h-4l9 11H0l9-11H5l8-10H9z",fill:"var(--map-pine)"}),s.jsx("path",{d:"M18 0l9 12h-4l8 10h-4l9 11H18z",fill:"var(--map-pine2)"})]}),oak:s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"16",y:"24",width:"4",height:"12",fill:"var(--map-trunk)"}),s.jsx("circle",{cx:"18",cy:"14",r:"14",fill:"var(--map-oak)"}),s.jsx("circle",{cx:"10",cy:"17",r:"8",fill:"var(--map-oak)"}),s.jsx("circle",{cx:"26",cy:"17",r:"8",fill:"var(--map-oak)"}),s.jsx("circle",{cx:"22",cy:"10",r:"6",fill:"var(--map-oak2)"})]}),rock:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M1 16Q2 6 10 3Q18-1 23 6Q28 11 27 16z",fill:"var(--map-rock)"}),s.jsx("path",{d:"M15 16Q15 8 19 4Q25 8 27 16z",fill:"var(--map-rock2)"})]}),tuft:s.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 vD({name:e}){return s.jsx("symbol",{id:`terrain-${e}`,overflow:"visible",children:Vy[e]})}const wD=Object.keys(Vy),yD=w.memo(function(t){const{seed:n,width:i,height:o,nodes:c}=t,d=w.useMemo(()=>kD({seed:n,width:i,height:o,nodes:c}),[n,i,o,c]);return s.jsxs("g",{className:"terrain","aria-hidden":"true",children:[s.jsx("defs",{children:wD.map(u=>s.jsx(vD,{name:u},u))}),d.grass.map((u,f)=>s.jsx("rect",{x:u.x,y:u.y,width:u.w,height:u.h,fill:"var(--map-grass)"},f)),d.water.map((u,f)=>s.jsx("rect",{x:u.x,y:u.y,width:u.w,height:u.h,fill:"var(--map-water)"},f)),s.jsx("rect",{x:-4e3,y:-4e3,width:i+8e3,height:o+8e3,fill:"url(#map-grid)"}),d.items.map((u,f)=>s.jsx("use",{href:`#terrain-${u.sprite}`,x:u.x,y:u.y},f))]})});function qy(e){var i;const t=(i=ih())==null?void 0:i.waiting,n=KR(e);return o=>{var c;return{needs:(c=t==null?void 0:t.find(d=>d.mapId===(e==null?void 0:e.map.id)&&d.ticketId===o.id))==null?void 0:c.tier,briefHeld:n(o)}}}const xD=380;function jD(e){const{selId:t,size:n}=e,i=w.useRef(e);i.current=e;const o=w.useRef(),c=n.w>0;w.useEffect(()=>{t||(o.current=void 0);const{nodes:d,pad:u,view:f,setView:m,onFocus:g,room:k}=i.current,y=t?d.find(F=>F.ticket.id===t):void 0;if(!y||!c||o.current===t||(o.current=t,bD({n:y,pad:u,view:f,size:{w:n.w-k,h:n.h}})))return;g();const b=Math.min(1.4,Math.max(f.k,Ra)),S=(n.w-k)/2,x={k:b,x:S-(u+y.x+Oe/2)*b,y:n.h/2-(u+y.y+ze/2)*b};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return m(x);const $=f,N=performance.now();let O=0;const D=F=>{const K=Math.min(1,(F-N)/xD),I=1-(1-K)**3;m({k:$.k+(x.k-$.k)*I,x:$.x+(x.x-$.x)*I,y:$.y+(x.y-$.y)*I}),K<1&&(O=requestAnimationFrame(D))};return O=requestAnimationFrame(D),()=>cancelAnimationFrame(O)},[t,c])}function bD(e){const{n:t,pad:n,view:i,size:o}=e,c=i.x+(n+t.x)*i.k,d=i.y+(n+t.y)*i.k,u=c+Oe*i.k,f=d+ze*i.k;return i.k>=Ra&&c>=16&&d>=16&&u<=o.w-16&&f<=o.h-16}function Qy(e,t,n){const i=Math.min(3,Math.max(.2,t));return{k:i,x:n.x-(n.x-e.x)*i/e.k,y:n.y-(n.y-e.y)*i/e.k}}function SD(e){const{box:t,view:n,setView:i}=e,o=w.useRef(new Map),c=w.useRef(null),d=g=>{const k=t.current.getBoundingClientRect();return{x:g.clientX-k.left,y:g.clientY-k.top}},u=()=>{var b;const g=[...o.current.values()],k=g.length>1?{x:(g[0].x+g[1].x)/2,y:(g[0].y+g[1].y)/2}:g[0],y=g.length>1?Math.hypot(g[0].x-g[1].x,g[0].y-g[1].y):0;c.current={view:n,dist:y,mid:k,moved:((b=c.current)==null?void 0:b.moved)??!1}},f=(g,k)=>{const y={x:(k[0].x+k[1].x)/2,y:(k[0].y+k[1].y)/2},b=Math.hypot(k[0].x-k[1].x,k[0].y-k[1].y),S=Qy(g.view,g.view.k*b/(g.dist||b),g.mid);i({...S,x:S.x+y.x-g.mid.x,y:S.y+y.y-g.mid.y}),g.moved=!0},m=(g,k,y)=>{var x;const b=y.x-k.mid.x,S=y.y-k.mid.y;return!k.moved&&Math.hypot(b,S)<5?!1:(k.moved||(x=t.current)==null||x.setPointerCapture(g.pointerId),k.moved=!0,i({...k.view,x:k.view.x+b,y:k.view.y+S}),!0)};return{onPointerDown:g=>{o.current.set(g.pointerId,d(g)),o.current.size===1&&(c.current=null),u()},onPointerMove:g=>{const k=c.current;if(!o.current.has(g.pointerId)||!k)return;o.current.set(g.pointerId,d(g));const y=[...o.current.values()];if(y.length>1)f(k,y);else if(!m(g,k,y[0]))return;e.onTouch()},onPointerUp:g=>{o.current.delete(g.pointerId),o.current.size&&u()},onPointerCancel:g=>void o.current.delete(g.pointerId),onClickCapture:g=>{var k;(k=c.current)!=null&&k.moved&&(g.stopPropagation(),c.current=null)}}}const Ht=32,ND=1.8;function $D(e){const{tickets:t,mode:n,size:i}=e,o=w.useMemo(()=>{const k=yp(t,"LR",n),y=yp(t,"TB",n),b=S=>Math.min(i.w/(S.width+Ht*2),i.h/(S.height+Ht*2+16));return b(k)*ND>=b(y)?k:y},[t,n,i.w,i.h]),c=(k,y)=>Math.min(1.25,Math.max(e.minFit??0,Math.min(i.w/k,i.h/y))),d=w.useMemo(()=>{const k=o.width+Ht*2,y=o.height+Ht*2+16,S=o.nodes.some($=>$.state==="out-of-scope")&&i.h?Math.max(0,i.h/c(k,y)-y):0;if(!S)return{...o,slack:S};const x=new Map(o.nodes.map($=>[$,{...$,y:$.y+($.state==="out-of-scope"?S:S/2)}]));return{...o,slack:S,nodes:[...x.values()],edges:o.edges.map($=>({from:x.get($.from),to:x.get($.to)})),groups:o.groups.map($=>({...$,y:$.y+S/2})),quarantineY:o.quarantineY+S,height:o.height+S}},[o,i.w,i.h,e.minFit]),u=aD(d),f=sD(d.direction,e.main),m=u.right+Ht*2+f.x,g=u.bottom+Ht*2+16+f.y;return{L:d,destination:u,room:f,W:m,H:g,fitK:c}}function CD(e,t){const n=w.useRef(t);n.current=t,w.useEffect(()=>{const i=e.current;if(!i)return;const o=m=>{const g=i.getBoundingClientRect();return{x:m.clientX-g.left,y:m.clientY-g.top}},c=m=>{m.preventDefault();const g=m.ctrlKey?.01:.0015;n.current(Math.exp(-m.deltaY*g),o(m))};let d=1;const u=m=>{m.preventDefault(),d=1},f=m=>{m.preventDefault();const g=m;n.current(g.scale/d,o(g)),d=g.scale};return i.addEventListener("wheel",c,{passive:!1}),i.addEventListener("gesturestart",u,{passive:!1}),i.addEventListener("gesturechange",f,{passive:!1}),()=>{i.removeEventListener("wheel",c),i.removeEventListener("gesturestart",u),i.removeEventListener("gesturechange",f)}},[e])}function TD(e){var we,Ne;const{snap:t,selection:n,onSelect:i,preview:o}=e,c=e.proofs??{},d=(o==null?void 0:o.tickets)??t.tickets,u=w.useRef(null),[f,m]=w.useState({w:0,h:0});w.useEffect(()=>{const z=u.current;if(!z)return;const Y=new ResizeObserver(([U])=>m({w:U.contentRect.width,h:U.contentRect.height}));return Y.observe(z),()=>Y.disconnect()},[]);const{L:g,destination:k,room:y,W:b,H:S,fitK:x}=$D({tickets:d,mode:t.map.mode,size:f,minFit:e.minFit,main:!!e.main}),$=w.useMemo(()=>e.main?iD({direction:g.direction,nodes:g.nodes,groups:g.groups,graphH:g.graphH,width:g.width}):null,[e.main,g]),N=w.useMemo(()=>g.nodes.map(z=>({...z,x:z.x+y.x,y:z.y+y.y})),[g.nodes,y]),O={x:Ht+y.x,y:Ht+y.y},D=()=>{const z=x(b,S);return{k:z,x:Math.max(0,(f.w-b*z)/2),y:Math.max(0,(f.h-S*z)/2)}},[F,K]=w.useState({k:1,x:0,y:0}),I=w.useRef(!1);w.useEffect(()=>{I.current=!1},[t.map.id]),w.useEffect(()=>{!I.current&&f.w&&K(fD({fit:D(),nodes:N,size:f,pad:Ht,focus:e.focus,room:sk(f.w)}))},[f.w,f.h,b,S,t.map.id,(we=e.focus)==null?void 0:we[0]]);const Q=SD({box:u,view:F,setView:K,onTouch:()=>I.current=!0});CD(u,(z,Y)=>{I.current=!0,K(U=>Qy(U,U.k*z,Y))});const Z=gt(5e3),q=Ou(e.leases,t.map.id),ee=Mr(),Se=qy(t),ve=(n==null?void 0:n.kind)==="ticket"?n.id:void 0;jD({selId:ve,nodes:N,size:f,pad:Ht,view:F,setView:K,room:sk(f.w),onFocus:()=>I.current=!0});const be=z=>{const Y=z==="main"?$&&{x:$.x,y:$.y,w:li,h:di}:ae(z)??Ie(z);if(!Y)return;const U=F.x+(O.x+Y.x)*F.k,E=F.y+(O.y+Y.y)*F.k;return{left:U,top:E,right:U+Y.w*F.k,bottom:E+Y.h*F.k}},ae=z=>z==="destination"?{x:k.x-24,y:k.y-24,w:48,h:48}:void 0,Ie=z=>{const Y=g.nodes.find(U=>U.ticket.id===z);return Y&&{x:Y.x,y:Y.y,w:Oe,h:ze}};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"graph-box",ref:u,...Q,children:[s.jsxs("svg",{className:"graph",width:f.w,height:f.h,onClick:()=>i(null),children:[s.jsx(j4,{}),s.jsxs("g",{transform:`translate(${F.x} ${F.y}) scale(${F.k})`,children:[s.jsx("g",{transform:`translate(${Ht} ${Ht})`,children:s.jsx(yD,{seed:t.map.id,width:b,height:S,nodes:N})}),s.jsxs("g",{transform:`translate(${O.x} ${O.y})`,children:[s.jsx(mD,{y:g.quarantineY,width:g.width,height:g.quarantineH,nodes:g.nodes}),s.jsx(A4,{snap:t,tickets:d,direction:g.direction,nodes:g.nodes,edges:g.edges,preview:o}),s.jsx(uD,{laid:g,spot:k,text:t.map.sections.destination,done:e.done,selected:(n==null?void 0:n.kind)==="together",onSelect:()=>i({kind:"together"})}),$&&e.main&&s.jsx(rD,{...$,tone:e.main,selected:(n==null?void 0:n.kind)==="main",onSelect:()=>i({kind:"main"})}),g.nodes.map(z=>{const Y=q.get(z.ticket.id);return s.jsx(Z4,{n:z,live:e.live.get(z.ticket.id),now:Z,stalled:!!Y&&Es(Y,Z)!=="live",flag:pC(ss.ticket(ee,t.map.id,z.ticket.id)),selected:ve===z.ticket.id,onSelect:i,mark:o==null?void 0:o.marks.get(z.ticket.id),frozen:o==null?void 0:o.frozen.has(z.ticket.id),...Se(z.ticket),verified:c[z.ticket.id]===void 0?void 0:c[z.ticket.id]==="verified"},z.ticket.id)})]})]})]}),s.jsx("button",{className:"btn sm fit-btn","data-tip":"Fit the whole trail in view",onPointerDown:z=>z.stopPropagation(),onClick:z=>{z.stopPropagation(),I.current=!0,K(D())},children:"Fit"})]}),(Ne=e.overlay)==null?void 0:Ne.call(e,be,f)]})}const ED=[{tone:"working",text:"An agent is on it"},{tone:"attention",urgent:!0,text:"Needs you"},{tone:"attention",text:"Held up"},{tone:"ready",spin:!0,text:"Waiting for an agent"},{tone:"backlog",text:"Not started yet"},{tone:"done",verified:!0,text:"Done and verified"},{tone:"done",text:"Done, not verified"},{tone:"cancelled",text:"Ruled out"}];function AD(){const[e,t]=w.useState(!1);return s.jsxs("div",{className:"map-legend",onPointerDown:n=>n.stopPropagation(),onClick:n=>n.stopPropagation(),children:[e&&s.jsx("ul",{className:"map-legend-list",children:ED.map(n=>s.jsxs("li",{children:[s.jsx("svg",{className:n.urgent?"node waiting":"node",width:"22",height:"16",viewBox:"4 0 18 16","aria-hidden":"true",children:s.jsx(Uy,{tone:n.tone,cy:8,verified:n.verified,spin:n.spin})}),n.text]},n.text))}),s.jsx("button",{type:"button",className:"btn sm","aria-expanded":e,onClick:()=>t(!e),children:e?"Hide legend":"Legend"})]})}function ID(e,t){const[n,i]=w.useState({statuses:{}});return Pe({view:e,version:t,load:async()=>{if(!e)return{mapId:e,statuses:{}};const o=await fetch(`${re()}/proof/trail?mapId=${encodeURIComponent(e)}`),c=o.ok?(await o.json()).statuses??{}:{};return{mapId:e,statuses:c}},show:i,failed:()=>i({mapId:e,statuses:{}}),changed:o=>o.includes(".evidence")||!!e&&o.includes(e)}),e&&n.mapId===e?n.statuses:void 0}function RD(){const e=Gt();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 MD(e){var i,o,c,d,u;const{snap:t,selection:n}=e.api;return s.jsxs(Be,{as:"main",className:"zone map-zone",style:{gridArea:"map"},children:[t&&!Gt()&&s.jsx(sE,{}),(i=e.trail)==null?void 0:i.banner,s.jsxs("div",{className:"map-area",children:[t?s.jsx(TD,{snap:t,live:e.live,leases:e.api.leases,selection:n,onSelect:e.onSelect,minFit:e.minFit,preview:(o=e.trail)==null?void 0:o.preview,proofs:(c=e.trail)==null?void 0:c.proofs,done:(d=e.trail)==null?void 0:d.done,main:e.main,focus:e.focus,overlay:e.docked?void 0:(f,m)=>e.bubble({anchorOf:f,box:m})}):s.jsxs("div",{className:"nomap",children:[s.jsx(An,{title:"No trail yet",hint:RD()}),s.jsx("div",{className:"actions",children:s.jsx(R,{variant:"primary",onClick:e.onNewTrail,"data-tip":"Describe the idea and create the trail",children:"New trail…"})}),Gt()?s.jsx(R,{onClick:fw,children:(u=Gt())==null?void 0:u.label}):s.jsx(sc,{command:'/scout new "your idea"'})]}),!t&&!e.docked&&e.bubble({anchorOf:()=>{},box:{w:0,h:0}}),t&&s.jsx(AD,{})]}),e.docked&&e.bubble()]})}function LD(e){const{view:t,covered:n,needs:i}=e;return s.jsx("nav",{className:"tabbar",children:hy.map(({id:o,label:c})=>s.jsxs("button",{className:t===o&&!n?"on":"",onClick:()=>e.onPick(o),children:[c,o==="map"&&i>0&&s.jsx(bs,{n:i,urgent:!0,pop:!0},i)]},o))})}function OD(e){return e.covered?s.jsx("main",{className:"phone-view",children:e.covered}):s.jsxs("main",{className:"phone-view phone-map",children:[e.map,e.trailBar,e.projects]})}const fk={settingsPage:!0},mk=()=>lh(new URLSearchParams(location.search).get("settings")),pk=()=>{var e;return!!((e=history.state)!=null&&e.settingsPage)};function PD(){const[e,t]=w.useState(mk);w.useEffect(()=>{e&&!pk()&&(history.replaceState(null,"",kr(location.href,null)),history.pushState(fk,"",kr(location.href,e)));const d=()=>t(mk());return window.addEventListener("popstate",d),()=>window.removeEventListener("popstate",d)},[]);const n=d=>{const u=kr(location.href,d);e?history.replaceState(history.state,"",u):history.pushState(fk,"",u),t(d)},i=()=>{e&&(t(null),pk()?history.back():history.replaceState(null,"",kr(location.href,null)))},o=d=>n(lh(d??"")??{});return{route:e,open:o,show:n,close:i,dismiss:()=>t(null),toggle:()=>e?i():o()}}const vu="view",Dd={lookoutPage:!0},gk=()=>{const e=new URLSearchParams(location.search).get(vu);return nL.includes(e)?e:null},kk=()=>{const e=history.state;return!!(e!=null&&e.lookoutPage||e!=null&&e.settingsPage)};function ra(e){const t=new URL(location.href);return t.searchParams.delete(vu),t.searchParams.delete("settings"),e&&t.searchParams.set(vu,e),t.toString()}function DD(){const[e,t]=w.useState(gk);return w.useEffect(()=>{e&&!kk()&&(history.replaceState(null,"",ra(null)),history.pushState(Dd,"",ra(e)));const o=()=>t(gk());return window.addEventListener("popstate",o),()=>window.removeEventListener("popstate",o)},[]),{page:e,open:o=>{const c=ra(o);kk()?history.replaceState(Dd,"",c):history.pushState(Dd,"",c),t(o)},close:()=>{var o;!e&&!new URLSearchParams(location.search).has("settings")||(t(null),(o=history.state)!=null&&o.lookoutPage?history.back():history.replaceState(null,"",ra(null)))}}}function _D(e){const{activity:t,selection:n,setSelection:i,actions:o}=e,c=DD(),[d,u]=w.useState(!1),[f,m]=w.useState(),[g,k]=w.useState(!1);w.useEffect(()=>{const I=t.sessions.find(Q=>Q.id===e.chatSession);!n&&(I!=null&&I.ticketId)&&I.mapId===e.mapId&&i({kind:"ticket",id:I.ticketId})},[e.chatSession,e.mapId]);const y=()=>{k(!1),c.close()},b=I=>{k(!1),c.open(I)},S=I=>{i(I),I||u(!1)},x=I=>{I&&I!==e.mapId&&o.selectMap(I)},$=(I,Q)=>{x(I),i({kind:"ticket",id:Q}),y()},N=I=>{const Q=t.pending.find(Z=>Z.id===I);Q&&(x(Q.mapId),i(Q.ticketId?{kind:"ticket",id:Q.ticketId}:{kind:"question",id:Q.id}),y())},O=I=>{x(I),i({kind:"main"}),y()},D=I=>{x(I),i({kind:"together"}),y()},F=(I,Q,Z)=>{x(Z),o.openChat(I),b("activity")},K=I=>{m(I),b("logbook")};return{page:c.page,openPage:b,toMap:y,fullTicket:d,setFullTicket:u,logbookFocus:f,openDecisions:K,statsOpen:g,setStatsOpen:k,toggleStats:()=>k(I=>!I),select:S,openTicket:$,openQuestion:N,openMainChecks:O,openTrailChecks:D,openChat:F}}function BD(e,t){w.useEffect(()=>{document.title=`${J.name}: ${e?`(${e}) `:""}${t??"No trail"}`},[e,t])}function FD(e,t){const n=e.blockedBy.map(i=>{var o;return((o=t.get(i))==null?void 0:o.closedAt)??0});return Math.max(e.createdAt,...n)}function zD(e){const{t,state:n,session:i,items:o}=e;return n==="out-of-scope"?"cancelled":o.length||i!=null&&i.waitingOn?"needs":n==="decided"?"done":i||n==="claimed"||n==="verifying"?"working":(n==="frontier"||n==="rework")&&!t.assignee&&gi(t)!=="hitl"&&!e.held?"waiting-agent":"not-started"}function UD(e){const{snap:t}=e,n=Ts(t.tickets,t.map.mode),i=new Map(t.tickets.map(u=>[u.id,u])),o=e.items.filter(u=>u.mapId===t.map.id&&u.ticketId),c=t.tickets.map(u=>{var y;const f=o.filter(b=>b.ticketId===u.id),m=e.sessions.find(b=>b.ticketId===u.id&&b.mapId===t.map.id),g=((y=e.heldBack)==null?void 0:y.call(e,u))??!1,k=zD({t:u,state:n.get(u.id),session:m,items:f,held:g});return{ticket:u,tone:k,session:m,items:f}}),d=new Map(c.map(u=>[u.ticket.id,u.tone]));return new Map(c.map(u=>{const f=u.ticket.blockedBy.filter(k=>{var y;return((y=i.get(k))==null?void 0:y.state)==="open"}),m=f.filter(k=>d.get(k)==="needs"),g={...u,readySince:u.tone==="waiting-agent"?FD(u.ticket,i):void 0,waitsOn:u.tone==="not-started"?f.map(k=>i.get(k).key):[],waitsOnYours:u.tone==="not-started"?m.map(k=>i.get(k).key):[]};return[u.ticket.id,g]}))}function WD(e){const{snap:t,sessions:n,view:i}=e,o=qy(t),c=t==null?void 0:t.map.id,[d,u]=w.useMemo(()=>{const x=(i==null?void 0:i.items)??[],$=N=>!N.mapId||N.mapId===c;return[x.filter($),x.filter(N=>!$(N))]},[i,c]),f=w.useMemo(()=>[...new Set(d.flatMap(x=>x.ticketId?[x.ticketId]:[]))],[d]),m=w.useMemo(()=>n.filter(gn),[n]),k=t?UD({snap:t,sessions:m,items:d,heldBack:x=>{const $=o(x);return!!$.needs||$.briefHeld}}):new Map,y=l4(k),b=d4(y,d);return{live:k,items:d,elsewhere:u,focus:f,segments:y,counts:b,keyOf:x=>{var $;return($=t==null?void 0:t.tickets.find(N=>N.id===x))==null?void 0:$.key}}}function HD(e,t){const n=Qu(e),i=t.some(c=>c.kind==="main-checks"),o=zT(n.view,i);return{tone:o,needs:o==="needs"}}const vk=["pointerdown","keydown"],wk={capture:!0};function KD(e,t){function n(){for(const o of vk)e.removeEventListener(o,i,wk)}function i(){n(),t()}for(const o of vk)e.addEventListener(o,i,wk);return n}const GD=new Set(["question","main-checks","trail-checks"]),VD=e=>!!e.ticketId||GD.has(e.kind);function qD(e){const t=w.useRef(new URLSearchParams(location.search).has($s)),{loaded:n,view:i,activity:o,mapId:c,busy:d,open:u}=e;w.useEffect(()=>KD(window,()=>t.current=!0),[]),w.useEffect(()=>{if(t.current||!n||!i||!c)return;const f=i.items.find(m=>m.mapId===c&&VD(m));(f==null?void 0:f.kind)==="question"&&!o.pending.some(m=>m.id===f.ref)||(t.current=!0,f&&!d&&u(f))},[n,i,o,c,d,u])}function QD(e){const[t,n]=w.useState("…");return w.useEffect(()=>{fetch(`${re()}/list`).then(i=>i.json()).then(i=>{var c;const o=i.root.split("/").filter(Boolean);n((c=o[o.length-1])!=null&&c.startsWith(".")?o[o.length-2]??"repo":o[o.length-1]??"repo")}).catch(()=>n("repo"))},[e]),t}function YD(e,t){return w.useMemo(()=>{const n=e.sessions.filter(o=>o.mapId===t),i=new Set(e.sessions.filter(o=>o.mapId!==t).map(o=>o.id));return{...e,sessions:n,feed:e.feed.filter(o=>!o.sessionId||!i.has(o.sessionId))}},[e,t])}function JD(e){const t=oc(e),[n,i]=w.useState(!1),o=()=>i(!0),c=t.brief,d=WR(c),u=Na(n?c==null?void 0:c.mapId:void 0,t.hash),f=c==null?void 0:c.sections,m=c&&n&&s.jsx(PR,{brief:c,error:t.error,changed:u.changed,onReviewAgain:u.reviewAgain,onAccept:()=>void t.accept(u.hash).then(k=>k&&i(!1)),onRequestChanges:k=>void t.requestChanges(k).then(y=>y&&i(!1)),onClose:()=>i(!1)}),g=d.show&&!n&&s.jsx(BR,{onReview:()=>{d.close(),o()},onClose:d.close});return{review:o,briefText:f?[f.existing,f.conventions,f.dataModel,f.api].join(`
178
+ `):"",banner:c&&s.jsx(zR,{brief:c,onReview:o}),inboxCard:(c==null?void 0:c.status)==="submitted"&&s.jsx(_R,{brief:c,onReview:o}),dialog:s.jsxs(s.Fragment,{children:[m,g]})}}function XD(e){var m;const{reroute:t,onReview:n}=e,i=t.kind==="challenge-destination",o=((m=t.frozen)==null?void 0:m.length)??0,c=i?"wrong mountain?":"proposes a new plan",d=o?` ${o} ticket${o===1?" is":"s are"} closed until you decide.`:"",u=t.wide?" It touches most of the open tickets, so nothing is frozen.":"",f=`${t.reason.replace(/\.$/,"")}.${d}${u}`;return s.jsxs("div",{className:"reroute-banner map-banner edge-attention",role:"status",title:f,children:[s.jsxs("span",{className:"mb-text",children:[s.jsxs("span",{className:"mb-lead",children:[t.by," ",c]}),s.jsx("span",{className:"t-meta",children:f})]}),s.jsx(wi,{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."}),s.jsx(R,{size:"sm",variant:"ghost",className:"reroute-dismiss",onClick:e.onDismiss,children:"Dismiss"}),s.jsx(R,{size:"sm",variant:"primary",onClick:n,children:"Review"})]})}const ZD=e=>e.changes.flatMap(t=>"ticket"in t?[t.ticket]:[]);function e_(e,t){const n=new Set(ZD(t));return e.tickets.filter(i=>n.has(i.id)&&i.updatedAt>t.at).map(i=>({key:i.key,title:i.title,what:t_(i)}))}function t_(e){return e.state==="closed"?"closed":e.assignee?`claimed by ${e.assignee}`:"changed"}function n_({parts:e}){return s.jsx("dl",{className:"reroute-parts",children:e.map(t=>s.jsxs("div",{children:[s.jsx("dt",{className:"t-label",children:t.label}),s.jsx("dd",{className:"t-body",children:t.text})]},t.label))})}const s_={"already-exists":"The work already exists","wrong-problem":"The trail targets the wrong problem",rescope:"The trail should be rescoped"},Yy="Dismissed by the trail lead. Carry on with the current plan.",i_="Declined by the trail lead.";function r_(e,t){var n,i,o;switch(e.op){case"edit_ticket":return[...(n=e.title)!=null&&n.trim()?[{label:"New title",text:e.title.trim()}]:[],...(i=e.body)!=null&&i.trim()?[{label:"New description (replaces the old one)",text:e.body.trim()}]:[]];case"add_ticket":return[...(o=e.body)!=null&&o.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 o_(e,t){var n;switch(e.op){case"add_ticket":{const i=(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`,i].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:a_(e)};case"rewire":return{verb:"Rewire",text:t(e.ticket),detail:c_(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 a_(e){var n,i;return[((n=e.title)==null?void 0:n.trim())&&"New title",((i=e.body)==null?void 0:i.trim())&&"new description"].filter(Boolean).join(" and ").replace(/^new/,"New")}function c_(e,t){var i,o;return[...(i=e.addBlockedBy)!=null&&i.length?[`now also after ${e.addBlockedBy.map(t).join(", ")}`]:[],...(o=e.removeBlockedBy)!=null&&o.length?[`no longer after ${e.removeBlockedBy.map(t).join(", ")}`]:[]].join(" · ")}const l_=new Set(["cancel_ticket","update_destination"]);function d_(e){const{change:t,name:n}=e,i=o_(t,n),o=r_(t,e.by);return s.jsx(fe,{as:"li",className:`reroute-change op-${t.op}`,edge:l_.has(t.op)?"attention":"neutral",title:i.text,titleText:i.text,context:s.jsx(_,{parts:[{text:i.verb,strong:!0}]}),detail:i.detail,detailText:i.detail,below:o.length?s.jsx(n_,{parts:o}):void 0})}function u_(e){const{reason:t,destination:n}=e;return s.jsxs("section",{className:"reroute-destination",children:[t&&s.jsx("p",{className:"reroute-destination-why",children:s_[t]}),n&&s.jsxs("div",{className:"reroute-destination-diff",children:[s.jsxs("div",{children:[s.jsx("span",{className:"mono-label",children:"Destination now"}),s.jsx("p",{className:"before",children:n.before||"—"})]}),s.jsxs("div",{children:[s.jsx("span",{className:"mono-label",children:"Suggested destination"}),s.jsx("p",{className:"after",children:n.after})]})]})]})}function h_(e){return s.jsxs("section",{className:"reroute-drift edge-note edge-attention",children:[s.jsx("h3",{className:"mono-label",children:"Changed since it was proposed"}),s.jsx("ul",{className:"item-list",children:e.changed.map(t=>s.jsxs("li",{children:[s.jsx("span",{className:"item-text",children:t.title}),s.jsx(_,{parts:[{text:t.key,code:!0},t.what]})]},t.key))}),s.jsxs("label",{className:"reroute-seen t-body",children:[s.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 f_(e,t){const n=new Map(e.tickets.map(o=>[o.id,o.key])),i=new Map(t.flatMap(o=>o.op==="add_ticket"?[[o.ref,o.title]]:[]));return o=>{const c=n.get(o);if(c)return c;const d=i.get(o);return d?`new: ${d}`:o}}function m_(e){var O,D;const{reroute:t,snap:n}=e,[i,o]=w.useState(""),[c,d]=w.useState(!1);w.useEffect(()=>{const F=K=>K.key==="Escape"&&e.onClose();return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[e]);const u=f_(n,t.changes),f=new Map(n.tickets.map(F=>[F.id,`${F.key} ${F.title}`])),m=F=>f.get(F)??u(F),g=n.map.sections.assumptions??[],k=t.invalidates.map(F=>g.find(K=>K.id===F)??{id:F,text:""}),y=t.status==="pending",b=y?e_(n,t):[],S=!b.length||c,x=t.kind==="challenge-destination",$=t.lane==="setting",N=$?`${t.by} asks to change your setting`:"Reroute proposal";return s.jsx("div",{className:"scrim",onClick:e.onClose,children:s.jsxs(Be,{as:"div",className:"dialog reroute-dialog",onClick:F=>F.stopPropagation(),children:[s.jsxs("header",{children:[s.jsx("h2",{className:"t-heading caps",children:x?"Destination challenged":N}),s.jsx(_,{parts:[{text:t.id,code:!0},t.status,`by ${t.by}`,`${Je(Date.now()-t.at)} ago`]})]}),s.jsxs("div",{className:"reroute-body",children:[e.replaced&&s.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."]}),x&&s.jsx(u_,{reason:t.destinationReason,destination:(O=t.diff)==null?void 0:O.destination}),s.jsxs("section",{children:[s.jsx("h3",{className:"mono-label",children:"Why"}),s.jsx("p",{children:t.reason})]}),s.jsxs("section",{children:[s.jsx("h3",{className:"mono-label",children:"Evidence"}),s.jsx("p",{className:"reroute-evidence",children:t.evidence})]}),k.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"mono-label",children:"Assumptions it invalidates"}),s.jsx("ul",{className:"item-list",children:k.map(F=>s.jsxs("li",{children:[s.jsx("span",{className:"item-text",children:F.text}),s.jsx(_,{parts:[{text:F.id,code:!0}]})]},F.id))})]}),s.jsxs("section",{children:[s.jsxs("h3",{className:"mono-label",children:["Changes · ",t.changes.length]}),s.jsx("ul",{className:"reroute-changes row-list",children:t.changes.map((F,K)=>s.jsx(d_,{change:F,by:t.by,name:m},K))})]}),s.jsxs("section",{children:[s.jsx("h3",{className:"mono-label",children:"Closed until you decide"}),t.wide&&s.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."]}),(D=t.frozen)!=null&&D.length?s.jsx("ul",{className:"item-list",children:t.frozen.map(F=>s.jsx("li",{className:"item-text",children:m(F)},F))}):s.jsx(Te,{children:"No tickets closed"})]}),t.note&&s.jsxs("section",{children:[s.jsx("h3",{className:"mono-label",children:"Your note"}),s.jsx("p",{children:t.note})]})]}),b.length>0&&s.jsx(h_,{changed:b,seen:c,onSeen:d}),y&&s.jsx(mt,{label:"Note for the agent (required to reject)",children:s.jsx("textarea",{rows:2,value:i,onChange:F=>o(F.target.value)})}),e.error&&s.jsx("p",{className:"urgent-text",children:e.error}),s.jsxs("div",{className:"actions",children:[y&&s.jsxs(s.Fragment,{children:[s.jsx(R,{className:"reroute-dismiss",variant:"ghost","data-tip":"Reject it without a note of your own",onClick:()=>e.onReject($?i_:Yy),children:$?"Decline":"Dismiss"}),s.jsx(R,{className:"reroute-reject",disabled:!i.trim(),onClick:()=>e.onReject(i.trim()),children:"Reject"}),cw()?s.jsx("span",{className:"vf-intro",children:"Only an owner, or someone they allowed to make high-risk calls, can approve it."}):s.jsx(R,{className:"reroute-approve",variant:"primary",disabled:!S,onClick:()=>e.onApprove(i.trim()),children:"Approve and apply"})]}),s.jsx(R,{variant:"ghost",onClick:e.onClose,children:"Close"})]})]})})}const Jy=`${re()}/reroutes`;async function p_(e){if(!e)return[];const t=await fetch(`${Jy}?map=${encodeURIComponent(e)}`);return t.ok?(await t.json()).reroutes:[]}function g_(e){const t=e==null?void 0:e.map.id,[n,i]=w.useState([]),[o,c]=w.useState(),{reload:d}=Pe({view:t,version:e==null?void 0:e.tickets.reduce((f,m)=>Math.max(f,m.updatedAt),e.map.updatedAt),load:()=>p_(t),show:i,failed:()=>i([]),events:{reroute:f=>(f==null?void 0:f.mapId)===t}}),u=async(f,m,g)=>{var S,x;const k=await fetch(`${Jy}/${f}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,id:m,note:g,hash:(S=n.find($=>$.id===m))==null?void 0:S.hash})}),y=await k.json().catch(()=>({}));if(k.ok)return c(void 0),d(),!0;const b=(x=y.errors)==null?void 0:x.map($=>$.message).join("; ");return c([y.error??`HTTP ${k.status}`,b].filter(Boolean).join(": ")),!1};return{reroutes:n,pending:n.find(f=>f.status==="pending"),error:o,clearError:()=>c(void 0),approve:(f,m)=>u("approve",f,m),reject:(f,m)=>u("reject",f,m)}}function k_(e,t){let n=t;for(let i=0;n&&i<e.length;i++){const o=e.find(c=>c.id===n);if((o==null?void 0:o.status)!=="superseded"||!o.supersededBy)break;n=o.supersededBy}return n!==t?{id:n,replaced:t}:{id:t}}function v_(e,t){const n=g_(e),[i,o]=w.useState(),c=k_(n.reroutes,i),d=n.reroutes.find(k=>k.id===c.id),u=d!=null&&d.diff?d:n.pending,f=()=>{o(void 0),n.clearError()},m=k=>k&&f(),g=n.pending;return{banner:g&&s.jsx(XD,{reroute:g,onReview:()=>o(g.id),onDismiss:()=>void n.reject(g.id,Yy)}),pending:n.reroutes.filter(k=>k.status==="pending").length,preview:e&&(u!=null&&u.diff)?b4(e,u.diff,u.frozen):void 0,openReroute:(k,y)=>{k!==(e==null?void 0:e.map.id)&&(t==null||t(k)),o(y)},dialog:e&&d&&s.jsx(m_,{reroute:d,replaced:c.replaced,snap:e,error:n.error,onApprove:k=>void n.approve(d.id,k||void 0).then(m),onReject:k=>void n.reject(d.id,k).then(m),onClose:f},d.id)}}function w_(e,t){return t.tickets.filter(i=>i.state==="closed"&&i.closeReason==="completed").filter(i=>{var o;return(o=ss.ticket(e,t.map.id,i.id))==null?void 0:o.flags.some(c=>c.kind==="done-pr-open")}).map(i=>i.id)}const y_=20;function Xy(e=y_){const t=document.querySelector(".ticket-proof");if(t)return t.scrollIntoView({block:"start",behavior:"smooth"});e>0&&setTimeout(()=>Xy(e-1),100)}function x_(e){return s.jsxs(s.Fragment,{children:[s.jsx(R,{variant:"ghost",onClick:e.onClose,children:"Later"}),s.jsx(R,{variant:"primary",autoFocus:!0,onClick:e.onChecks,children:"See what fails"})]})}function j_({onClose:e}){return s.jsx(R,{variant:"primary",autoFocus:!0,onClick:e,children:"Close"})}function b_(e){const t=e.pulls===1?"Review pull request":"Review pull requests";return s.jsxs(s.Fragment,{children:[s.jsx(R,{variant:"ghost",onClick:e.onClose,children:"Later"}),s.jsx(R,{variant:"primary",autoFocus:!0,onClick:e.onReview,children:t})]})}function S_(e){return e.done.kind==="unverified"&&e.done.together.kind==="failed"?s.jsx(x_,{onChecks:e.onChecks,onClose:e.onClose}):e.pulls>0?s.jsx(b_,{pulls:e.pulls,onReview:e.onReview,onClose:e.onClose}):s.jsx(j_,{onClose:e.onClose})}const N_=e=>e===1?"1 pull request to merge.":`${e} pull requests to merge.`;function $_(e){const{done:t,pulls:n,onClose:i}=e;return w.useEffect(()=>{const o=c=>c.key==="Escape"&&i();return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[i]),s.jsx("div",{className:"scrim",onClick:i,children:s.jsxs(Be,{as:"div",className:`dialog trail-done ${t.kind}`,role:"dialog","aria-label":"Destination reached",onClick:o=>o.stopPropagation(),children:[s.jsx("header",{children:s.jsx("h2",{className:"t-heading caps",children:"Destination reached"})}),s.jsxs("p",{className:"t-body",children:[t.reason,".",n>0&&` ${N_(n)}`]}),s.jsx("footer",{children:s.jsx(S_,{...e})})]})})}function C_({done:e}){const t=s.jsx("svg",{className:`destination reached ${e.kind}`,width:"34",height:"34",viewBox:"-20 -21 40 42","aria-hidden":"true",children:s.jsx(Gy,{})});return s.jsx(An,{title:"Destination reached",hint:e.reason,art:t})}function T_(e,t){return e.every(n=>n.state!=="closed"||n.closeReason!=="completed"||t[n.id]!==void 0)}function E_(e,t){const n=ID(e==null?void 0:e.map.id,e==null?void 0:e.tickets),i=ow(e==null?void 0:e.map.id).view,o=i&&i.mapId===(e==null?void 0:e.map.id)?i.together:void 0,c=w.useMemo(()=>{if(!(!e||!n||!o||!T_(e.tickets,n)))return vS({tickets:e.tickets,proofs:n,pendingReroutes:t,together:o})},[e,n,t,o]);return{proofs:n,done:c}}const yk=new Set,xk=e=>`teamtrail.trail-done:${re()}:${e}`,jk={has(e){const t=xk(e);if(yk.has(t))return!0;try{return localStorage.getItem(t)==="1"}catch{return!1}},add(e){const t=xk(e);yk.add(t);try{localStorage.setItem(t,"1")}catch{}}};function A_(e,t){return t.kind==="verified"?`${e}:verified`:t.together.kind==="failed"?`${e}:failed:${t.together.runId}`:e}function I_(e,t){const[,n]=w.useState(0),i=e==null?void 0:e.map.id,o=i&&t&&t.kind!=="not-done"?A_(i,t):void 0;return{show:!!o&&!(e!=null&&e.map.archived)&&!jk.has(o),close:()=>{o&&jk.add(o),n(u=>u+1)}}}function R_(e){const{snap:t}=e,{proofs:n,done:i}=E_(t,e.pendingReroutes),o=I_(t,i),c=Mr(),d=t?w_(c,t):[],u=()=>{o.close(),!(!t||!d.length)&&(e.openTicket(t.map.id,d[0]),Xy())},f=()=>{o.close(),t&&e.openTrailChecks(t.map.id)},m=o.show&&i&&i.kind!=="not-done"&&s.jsx($_,{done:i,pulls:d.length,onReview:u,onChecks:f,onClose:o.close});return{proofs:n,done:i,dialog:m}}function M_(e){const{snap:t}=e,n=JD(t),i=v_(t,e.selectMap),o=R_({snap:t,pendingReroutes:i.pending,...e});return{briefText:n.briefText,inboxCard:n.inboxCard,review:n.review,banner:s.jsxs(s.Fragment,{children:[n.banner,i.banner]}),preview:i.preview,proofs:o.proofs,done:o.done,openReroute:i.openReroute,dialog:s.jsxs(s.Fragment,{children:[n.dialog,i.dialog,o.dialog]})}}function L_(){const e=new URL(location.href);e.searchParams.has($s)&&(e.searchParams.delete($s),history.replaceState(history.state,"",e))}function O_(e,t){return e.kind!=="question"||t.pending.some(n=>n.id===e.ref)}function P_(e){const[t,n]=w.useState(()=>new URLSearchParams(location.search).get($s)??void 0),{loaded:i,view:o,activity:c,handlers:d}=e;return w.useEffect(()=>{if(!t||!i||!o)return;const u=o.items.find(f=>f.id===t);u&&!O_(u,c)||(n(void 0),L_(),u&&Zu(u,d))},[t,i,o,c,d]),{request:w.useCallback(u=>n(u),[])}}function D_(e){const{api:t,nav:n}=e,i=yw(t.allSnaps);GE(i.view);const o=m=>m&&t.actions.selectMap(m),c={openQuestion:n.openQuestion,openTicket:n.openTicket,openKnowledge:()=>e.knowledge.setOpen(!0),openBrief:m=>m===t.mapId?e.reviewBrief():o(m),openReroute:e.openReroute??(m=>m.ticketId?n.openTicket(m.mapId,m.ticketId):o(m.mapId)),selectTrail:o,openGuides:e.openGuides,openConnector:e.openConnector,openApprovals:e.openApprovals,openMainChecks:n.openMainChecks,openTrailChecks:n.openTrailChecks,openRule:e.openRule},d=i.view,u=P_({loaded:t.loaded,view:d,activity:t.activity,handlers:c}),f=d&&s.jsx(UE,{view:d,onFocus:m=>void i.savePrefs(wN(d.prefs,m,Date.now())),onSettings:e.openFocusSettings});return{attention:i,handlers:c,header:f,link:u,open:m=>Zu(m,c)}}function __({d:e}){return e.derived?s.jsx(_,{className:"d-section",parts:["Unverified · read from text anyone who can edit the tracker wrote, not a decision Teamtrail recorded"]}):null}function B_(e){const{d:t,snap:n}=e,i=Lr(),[o,c]=w.useState(!1),[d,u]=w.useState(""),[f,m]=w.useState("");w.useEffect(()=>{c(!1),u(""),m("")},[t.id,t.mapId]);const g=_b(e.all.filter(x=>x.mapId===t.mapId),t.id),k=Er(t),y=t.ticketId?n==null?void 0:n.tickets.find(x=>x.id===t.ticketId):void 0,b=Date.now(),S=At(t.source.url);return s.jsxs("div",{className:"detail dv-d",children:[s.jsxs("div",{className:"d-head",children:[s.jsx("span",{className:"key",children:t.id}),s.jsx(xi,{tone:"state",className:`dv-st-${k}`,children:k}),s.jsx(_,{parts:[B$(t.decidedAt),`${Je(b-t.decidedAt)} ago`]})]}),s.jsx("h3",{className:"t-heading",children:t.question}),s.jsx(JR,{mapId:t.mapId,kind:"decision",id:t.id}),s.jsx(__,{d:t}),s.jsxs("div",{className:"resolution",children:[s.jsx(nu,{parts:["Decision"]}),s.jsx("p",{children:t.answer})]}),s.jsxs("dl",{className:"facts",children:[s.jsx("dt",{children:"Trail"}),s.jsx("dd",{children:n?`${n.map.key} ${n.map.title}`:t.mapId}),s.jsx("dt",{children:"Ticket"}),s.jsx("dd",{children:t.ticketId?s.jsxs("button",{className:"link",onClick:()=>e.onOpenTicket(t.mapId,t.ticketId),children:[t.ticketKey," ",(y==null?void 0:y.title)??""," · open in trail ›"]}):"—"}),s.jsx("dt",{children:"Decided by"}),s.jsx("dd",{children:[zu(t,i),Hk(t)].filter(Boolean).join(", ")}),t.participants.length>1&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Participants"}),s.jsx("dd",{children:t.participants.map(x=>x.name??x.id).join(", ")})]}),s.jsx("dt",{children:"Source"}),s.jsxs("dd",{children:[ts[t.source.kind].label,S&&s.jsxs(s.Fragment,{children:[" · ",s.jsx("a",{href:S,target:"_blank",rel:"noreferrer",children:t.source.label??"link"})]}),!S&&t.source.label&&` · ${t.source.label}`,t.source.ref&&s.jsxs("span",{className:"ref",children:[" ",t.source.ref]})]})]}),t.alternatives.length>0&&s.jsxs("div",{className:"dv-sec",children:[s.jsx("h4",{className:"mono-label",children:"Alternatives"}),s.jsx("ul",{className:"dv-alts",children:t.alternatives.map(x=>s.jsx("li",{children:x},x))})]}),t.rationale&&s.jsxs("div",{className:"dv-sec",children:[s.jsx("h4",{className:"mono-label",children:"Rationale"}),s.jsx("p",{children:t.rationale})]}),g.length>1&&s.jsxs("div",{className:"dv-sec",children:[s.jsx("h4",{className:"mono-label",children:"Supersession"}),s.jsx("ol",{className:"dv-chain",children:g.map(x=>s.jsx("li",{className:`${x.id===t.id?"cur":""} ${x.supersededBy?"old":"live"}`,children:s.jsxs("button",{onClick:()=>e.onSelect(x.id),children:[s.jsx("i",{}),s.jsx("span",{className:"id",children:x.id}),s.jsx("span",{className:"a",children:x.summary}),s.jsx(_,{parts:[mi(x.decidedBy,i),fi(x.decidedAt)]})]})},x.id))})]}),s.jsxs("div",{className:"actions",children:[s.jsx(Iw,{draft:()=>({title:t.summary||t.question,body:[t.answer,t.rationale&&`Why: ${t.rationale}`].filter(Boolean).join(`
179
+
180
+ `),kind:"product-decision",sources:[`decision:${t.id}`,...t.ticketKey?[`ticket:${t.ticketKey}`]:[]]})}),k==="active"&&!t.postedBy&&s.jsx(R,{on:o,onClick:()=>c(x=>!x),"data-tip":"Replace this decision with a new answer. Both stay on record",children:"Supersede…"})]}),o&&s.jsxs(Qt,{as:"form",tone:"inset",className:"inline-form",onSubmit:x=>{x.preventDefault(),d.trim()&&(e.onSupersede(t,{answer:d.trim(),rationale:f.trim(),alternatives:[t.summary]}),c(!1))},children:[s.jsx(mt,{label:"New decision",children:s.jsx("textarea",{rows:3,value:d,onChange:x=>u(x.target.value),autoFocus:!0})}),s.jsx(mt,{label:"Rationale",children:s.jsx("input",{value:f,onChange:x=>m(x.target.value)})}),s.jsxs("div",{className:"form-actions",children:[s.jsx(R,{variant:"ghost",onClick:()=>c(!1),children:"Cancel"}),s.jsx(R,{type:"submit",variant:"primary",disabled:!d.trim(),children:"Supersede"})]})]}),s.jsxs("div",{className:"dv-sec",children:[s.jsxs("h4",{className:"mono-label",children:["Transcript ",s.jsx("span",{className:"n",children:t.transcript.length})]}),t.transcript.length?s.jsx("div",{className:"dv-transcript comms-log",children:t.transcript.map((x,$)=>s.jsxs("div",{className:`msg from-${x.from} voice-${x.from==="human"?"human":"agent"}`,children:[s.jsx(nu,{parts:[mi(x.author,i),Lu(x.at)]}),s.jsx("div",{className:"msg-text",children:x.text})]},$))}):s.jsx(Te,{children:"None recorded"})]})]})}function Wt(e){return s.jsx("li",{children:s.jsxs("button",{className:`dv-opt ${e.on?"on":""} ${e.cls??""}`,onClick:e.onClick,children:[s.jsx("span",{className:"ttl",children:e.label}),s.jsx("b",{children:e.n})]})})}function F_(e){const{filter:t,set:n,all:i}=e,o=c=>i.filter(c).length;return e.compact?s.jsxs("div",{className:"dv-filters compact",children:[s.jsx(it,{compact:!0,"aria-label":"Trail",value:t.mapId??"",onChange:c=>n({mapId:c||void 0}),options:[{value:"",label:"All trails"},...e.trails.map(c=>({value:c.map.id,label:`${c.map.key} ${c.map.title}`}))]}),s.jsx(it,{compact:!0,"aria-label":"Source",value:t.source??"",onChange:c=>n({source:c||void 0}),options:[{value:"",label:"All sources"},...ga.map(c=>({value:c,label:ts[c].label}))]}),s.jsx(it,{compact:!0,"aria-label":"Decided by",value:t.decidedBy??"",onChange:c=>n({decidedBy:c||void 0}),options:[{value:"",label:"Anyone"},...e.people.map(c=>({value:c,label:c}))]}),s.jsx(it,{compact:!0,"aria-label":"Status",value:t.status??"",onChange:c=>n({status:c||void 0}),options:[{value:"",label:"Any status"},{value:"active",label:"Active"},{value:"superseded",label:"Superseded"}]})]}):s.jsxs("aside",{className:"dv-filters",children:[s.jsx("h3",{className:"mono-label",children:"Trail"}),s.jsxs("ul",{children:[s.jsx(Wt,{on:!t.mapId,label:"All trails",n:i.length,onClick:()=>n({mapId:void 0})}),e.trails.map(c=>s.jsx(Wt,{on:t.mapId===c.map.id,label:`${c.map.key} ${c.map.title}`,n:o(d=>d.mapId===c.map.id),onClick:()=>n({mapId:c.map.id})},c.map.id))]}),s.jsx("h3",{className:"mono-label",children:"Source"}),s.jsxs("ul",{children:[s.jsx(Wt,{on:!t.source,label:"All",n:i.length,onClick:()=>n({source:void 0})}),ga.map(c=>s.jsx(Wt,{cls:`src-${c}`,on:t.source===c,label:ts[c].label,n:o(d=>d.source.kind===c),onClick:()=>n({source:t.source===c?void 0:c})},c))]}),s.jsx("h3",{className:"mono-label",children:"Made by"}),s.jsxs("ul",{children:[s.jsx(Wt,{on:!t.madeBy,label:"Anyone",n:i.length,onClick:()=>n({madeBy:void 0})}),s.jsx(Wt,{on:t.madeBy==="agent",label:"Agents, on their own",n:o(c=>jr(c)==="agent"),onClick:()=>n({madeBy:t.madeBy==="agent"?void 0:"agent"})}),s.jsx(Wt,{on:t.madeBy==="human",label:"People",n:o(c=>jr(c)==="human"),onClick:()=>n({madeBy:t.madeBy==="human"?void 0:"human"})})]}),s.jsx("h3",{className:"mono-label",children:"Decided by"}),s.jsxs("ul",{children:[s.jsx(Wt,{on:!t.decidedBy,label:"Anyone",n:i.length,onClick:()=>n({decidedBy:void 0})}),e.people.map(c=>s.jsx(Wt,{on:t.decidedBy===c,label:c,n:o(d=>d.decidedBy===c),onClick:()=>n({decidedBy:t.decidedBy===c?void 0:c})},c))]}),s.jsx("h3",{className:"mono-label",children:"Status"}),s.jsxs("ul",{children:[s.jsx(Wt,{on:!t.status,label:"Any",n:i.length,onClick:()=>n({status:void 0})}),s.jsx(Wt,{on:t.status==="active",label:"Active",n:o(c=>!c.supersededBy),onClick:()=>n({status:t.status==="active"?void 0:"active"})}),s.jsx(Wt,{on:t.status==="superseded",label:"Superseded",n:o(c=>!!c.supersededBy),onClick:()=>n({status:t.status==="superseded"?void 0:"superseded"})})]})]})}const bk=e=>`${e.mapId}/${e.id}`;function z_(e,t){var o;const n=new Map;for(const c of e){const d=((o=t[bk(c)])==null?void 0:o.area)??ud;n.set(d,[...n.get(d)??[],c])}const i=c=>{var d;return((d=t[bk(c)])==null?void 0:d.citedBy.length)??0};return[...n].map(([c,d])=>({area:c,rows:[...d].sort((u,f)=>i(f)-i(u)||f.decidedAt-u.decidedAt)})).sort((c,d)=>+(c.area===ud)-+(d.area===ud)||d.rows.length-c.rows.length||c.area.localeCompare(d.area))}function U_(e){if(Er(e)==="superseded")return`Replaced by ${e.supersededBy}`;if(e.supersedes)return`Replaces ${e.supersedes}`}function W_(e){const{d:t}=e,n=Lr(),i=Er(t);return s.jsxs(s.Fragment,{children:[e.newDay&&s.jsx("li",{className:"dv-day t-label",children:e.group??fi(t.decidedAt)}),s.jsx(fe,{as:"li",className:`dv-row ${i}`,selected:e.on,onOpen:e.onClick,title:t.question,titleText:t.question,trailing:Lu(t.decidedAt),context:s.jsx(_,{parts:[{text:t.id,code:!0},t.ticketKey&&{text:t.ticketKey,code:!0},e.showTrail&&e.trail,zu(t,n),Hk(t)??ts[t.source.kind].label,U_(t),!!e.cited&&`cited ${e.cited}×`]}),detail:t.summary,detailText:t.summary})]})}function H_(e){const{rows:t,current:n,memory:i}=e,o=(c,d,u)=>{var f,m;return s.jsx(W_,{d:c,newDay:d,group:u,cited:(f=i==null?void 0:i[`${c.mapId}/${c.id}`])==null?void 0:f.citedBy.length,trail:(m=e.snaps[c.mapId])==null?void 0:m.map.key,on:(n==null?void 0:n.id)===c.id&&n.mapId===c.mapId,showTrail:e.showTrail,onClick:()=>e.onSelect(c.id)},`${c.mapId}:${c.id}`)};return i&&t.length?s.jsx("ol",{className:"dv-list","aria-label":"Logbook by area",children:z_(t,i).flatMap(c=>c.rows.map((d,u)=>o(d,u===0,`${c.area} · ${c.rows.length}`)))}):s.jsx("ol",{className:"dv-list","aria-label":"Logbook",children:t.length?t.map((c,d)=>o(c,d===0||fi(t[d-1].decidedAt)!==fi(c.decidedAt))):s.jsx(Te,{children:"No decisions"})})}function K_({stats:e}){return s.jsxs("span",{className:"dv-readouts",children:[s.jsx(Tn,{layout:"start",label:"Active",value:e.active}),s.jsx(Tn,{layout:"start",label:"Superseded",value:e.superseded}),s.jsx(Tn,{layout:"start",label:"Last 24h",value:e.last24h}),s.jsx(Tn,{layout:"start",label:"Human",value:`${e.total?Math.round(e.human/e.total*100):0}%`}),s.jsx(_,{className:"dv-src-mix",parts:ga.filter(t=>e.bySource[t]).map(t=>`${ts[t].label} ${e.bySource[t]}`)})]})}function G_(e){const{filter:t}=e,i=Object.values(t).filter(Boolean).length-(t.query?1:0),o=e.filtersOpen||i>0;return s.jsxs("div",{className:"dv-search",children:[s.jsx("input",{type:"search",placeholder:"Search decisions",value:t.query??"",onChange:c=>e.set({query:c.target.value})}),e.showToggle&&s.jsxs("button",{className:`chip ${o?"on":""}`,onClick:e.onToggle,children:["Filters",i>0?` · ${i}`:""]})]})}async function V_(){const e=await fetch(`${re()}/decision-memory`);return e.ok?(await e.json()).entries:null}function q_(){const[e,t]=w.useState();return Pe({load:V_,show:t,failed:()=>t(null),changed:n=>n.includes("/decisions/")||n.endsWith("map.md")}),e}function Q_(e){const{api:t,bp:n}=e,i=t.decisions,[o,c]=w.useState({}),[d,u]=w.useState(e.focus),[f,m]=w.useState(!1),[g,k]=w.useState(!1),y=q_();w.useEffect(()=>u(e.focus),[e.focus]),w.useEffect(()=>{const K=I=>{I.key==="Escape"&&(n==="mobile"&&d?u(void 0):e.onClose())};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[n,d,e]);const b=w.useMemo(()=>xS(i,o),[i,o]),S=w.useMemo(()=>jS(i),[i]),x=i.find(K=>K.id===d&&(!o.mapId||K.mapId===o.mapId))??(n==="mobile"?void 0:b[0]),$=w.useMemo(()=>Object.values(t.allSnaps).sort((K,I)=>I.map.createdAt-K.map.createdAt),[t.allSnaps]),N=w.useMemo(()=>[...new Set(i.map(K=>K.decidedBy))].sort(),[i]),O=K=>c(I=>({...I,...K})),D=()=>{const K=Object.fromEntries($.map(I=>[I.map.id,{key:I.map.key,title:I.map.title}]));Ev(`${J.slug}-decisions-${fi(Date.now())}.md`,LS(b,K,{title:`${J.name} decisions`}))},F=n==="mobile"&&!!x;return s.jsxs(Be,{className:`zone decisions-view dv-${n}`,children:[s.jsxs("header",{className:"dv-head",children:[F?s.jsx("button",{className:"back",onClick:()=>u(void 0),children:"‹ Decisions"}):s.jsxs(Ke,{as:"h2",children:["Decisions ",b.length!==i.length&&s.jsx("span",{className:"n",children:`${b.length}/${i.length}`})]}),n!=="mobile"&&s.jsx(K_,{stats:S}),s.jsxs("span",{className:"dv-head-right",children:[!F&&y&&s.jsx(R,{on:g,"aria-pressed":g,onClick:()=>k(K=>!K),title:"Group by the area each decision is about, the most cited first",children:"By area"}),!F&&s.jsx(R,{onClick:D,disabled:!b.length,title:"Export the filtered list as markdown",children:"Export .md"}),s.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})]})]}),!F&&s.jsx(G_,{filter:o,set:O,showToggle:n!=="wide",filtersOpen:f,onToggle:()=>m(K=>!K)}),s.jsxs("div",{className:"dv-body",children:[(n==="wide"||f&&!F)&&s.jsx(F_,{filter:o,set:O,all:i,trails:$,people:N,compact:n!=="wide"}),!F&&s.jsx(H_,{rows:b,current:x,snaps:t.allSnaps,showTrail:n==="wide",onSelect:u,memory:g&&y?y:void 0}),(n!=="mobile"||x)&&s.jsx("div",{className:"dv-detail",children:x?s.jsx(B_,{d:x,all:i,snap:t.allSnaps[x.mapId],onSelect:u,onOpenTicket:e.onOpenTicket,onSupersede:t.actions.supersede}):s.jsx(Te,{children:"No decision selected"})})]})]})}const Y_={"asks-you":"urgent",answered:"good",launched:"good",done:"good",verified:"good","checks-failed":"attention",stalled:"attention",disconnected:"attention",problem:"attention"};function J_(e){if(e.kind)return Y_[e.kind];if(e.signal){if(e.level==="alert")return"urgent";if(e.level==="ok")return"good"}}function X_({activity:e,onTicket:t}){const n=Lr(),i=e.feed.slice(-120).reverse();return i.length?s.jsx("div",{className:"log",children:i.map(o=>s.jsxs("div",{className:`log-row src-${o.source.replace(" ","-")} edge-${J_(o)??"none"}`,onClick:()=>o.ticketId&&t(o.ticketId),children:[s.jsx("span",{className:"t t-meta",children:Wa(o.at)}),s.jsx("span",{className:"src t-meta",children:mi(o.agent??o.source,n)}),s.jsxs("span",{className:"msg",title:o.tag?`${o.tag} · ${o.text}`:o.text,children:[o.tag&&s.jsxs("span",{className:"tag t-meta",children:[o.tag," · "]}),o.text]})]},o.id))}):s.jsx(An,{title:"Nothing has happened yet",hint:"Claims, steps, questions and decisions appear here as agents work."})}function Sk({lease:e,now:t}){if(!e)return null;const n=Es(e,t);if(n==="live")return null;const i=e.expiresAt-t;return s.jsxs(xi,{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":qt(i)]})}function Z_({total:e,step:t}){return s.jsx("span",{className:"segs","aria-label":`Step ${t} of ${e}`,children:Array.from({length:e},(n,i)=>s.jsx("i",{className:e6(i+1,t)},i))})}function e6(e,t){return e<t?"done":e===t?"cur":""}function t6({snap:e,activity:t,leases:n,onSelect:i,onOpenChat:o}){var y;const c=gt(1e3),d=t.sessions.filter(gn),u=new Set(d.map(b=>b.ticketId)),f=Ou(n,e==null?void 0:e.map.id),m=(e==null?void 0:e.tickets.filter(b=>b.state==="open"&&b.assignee&&!u.has(b.id)))??[];if(!d.length&&!m.length)return s.jsx(Te,{children:"No agent on a ticket"});const g=b=>!!b&&Es(b,c)!=="live",k=!!((y=e==null?void 0:e.map.modelMatching)!=null&&y.enabled);return s.jsxs("ul",{className:"sessions-list",children:[d.map(b=>{const S=e==null?void 0:e.tickets.find(N=>N.id===b.ticketId),x=S?gi(S)==="hitl":!1,$=S&&f.get(S.id);return s.jsx(fe,{as:"li",className:b.waitingOn?"waiting":void 0,edge:n6(b,g($)),title:o6(S,b.mode)||b.agent,context:s.jsx(_,{parts:[{text:b.agent,strong:!0},i6(b),k&&s6(b),b.waitingOn?{text:"Waiting on you",urgent:!0}:`${b.mode} · ${b.stepLabel.toLowerCase()}`,x&&!b.waitingOn&&"with you",r6(b)],children:s.jsx(Sk,{lease:$,now:c})}),trailing:Av(c-b.startedAt),below:s.jsx(Z_,{total:b.total,step:b.step}),onOpen:()=>{S&&i({kind:"ticket",id:S.id}),x&&o(b.id)}},b.id)}),m.map(b=>s.jsx(fe,{as:"li",className:"claim",edge:g(f.get(b.id))?"attention":"neutral",title:`${b.key} ${b.title}`,context:s.jsx(_,{parts:[{text:b.assignee??"",strong:!0},"claimed, no live session"],children:s.jsx(Sk,{lease:f.get(b.id),now:c})}),onOpen:()=>i({kind:"ticket",id:b.id})},b.id))]})}function n6(e,t){return e.waitingOn?"urgent":t?"attention":"neutral"}function s6(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 i6(e){const t=Sr(e.model);return t&&{text:t,tip:e.model,className:"agent-model"}}function r6(e){if(e.usage)return`${Ha(gS(e))} tok · ${hi(e.usage.costUsd)}`}function o6(e,t){return e?`${e.key} ${e.title}`:t==="chart"?"Charting trail":""}function a6({activity:e,snap:t,running:n,usage:i=!0}){const o=Xk(e,t==null?void 0:t.map.id),c=ev(e,t==null?void 0:t.map.id),d=new Set(e.sessions.filter(gn).map(f=>f.ticketId)),u=(t==null?void 0:t.tickets.filter(f=>f.state==="open"&&f.assignee&&!d.has(f.id)).length)??0;return s.jsx(yt,{sub:!0,className:"sessions-head",title:s.jsxs(s.Fragment,{children:["Agents on tickets ",s.jsx("span",{className:"n",children:n+u})]}),right:i?s.jsxs("span",{className:"usage",title:["Model usage for this trail, all sessions",...c.map(f=>Zk[f].text)].join(`
181
+ `),children:[s.jsx("span",{className:"mono-label",children:"Trail"})," ",Ha(o.inputTokens+o.outputTokens)," tok · ",hi(o.costUsd)]}):void 0})}function c6(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 l6={running:"Working",done:"Done",failed:"Stopped"};function d6({activity:e,snap:t,done:n}){var u;if(n&&n.kind!=="not-done")return s.jsx(C_,{done:n});const i=c6(e);if(!i)return s.jsx(An,{title:"No agent working yet",hint:Gt()?`Turn your agents on for this trail in ${(u=Gt())==null?void 0:u.label}. Each step they report shows here.`:"Run /scout resume in Claude Code or Codex. Each step an agent reports shows here."});const o=i.ticketId?t==null?void 0:t.tickets.find(f=>f.id===i.ticketId):void 0,c=Da[i.mode],d=i.waitingOn?"Waiting on you":l6[i.status];return s.jsxs("div",{className:`step-tracker ${i.waitingOn?"waiting":""}`,children:[s.jsxs("div",{className:"st-meta",children:[s.jsx(_,{parts:[{text:i.agent,strong:!0},`${i.mode}, step ${i.step} of ${i.total}`]}),s.jsx("span",{className:`t-label st-status ${i.waitingOn?"urgent":""}`,children:d})]}),s.jsxs("div",{className:"st-big",children:[i.stepLabel,o&&s.jsxs("span",{className:"st-key",children:[" ",o.key]})]}),o&&s.jsx("div",{className:"st-ticket t-meta",children:o.title}),s.jsx("ol",{className:"pipeline",children:c.map((f,m)=>{const g=m+1,k=g<i.step||g===i.step&&i.status==="done";let y="";return k?y="done":g===i.step&&(y="cur"),s.jsxs("li",{className:y,children:[s.jsx("i",{}),s.jsxs("span",{children:[String(g).padStart(2,"0")," ",f]})]},f)})})]})}function u6(e){const{activity:t}=e;return s.jsxs(Be,{className:"zone page activity-page",children:[s.jsxs("section",{className:"page-col",children:[s.jsx(yt,{title:"Agents"}),s.jsxs("div",{className:"zone-b",children:[s.jsx(d6,{activity:t,snap:e.snap,done:e.done}),s.jsx(a6,{activity:t,snap:e.snap,running:t.sessions.filter(gn).length}),s.jsx(t6,{snap:e.snap,activity:t,leases:e.leases,onSelect:n=>(n==null?void 0:n.kind)==="ticket"&&e.onTicket(n.id),onOpenChat:e.onOpenChat})]})]}),s.jsxs("section",{className:"page-col",children:[s.jsx(yt,{title:"Activity log",right:s.jsxs("span",{className:"mono-label dim",children:[t.feed.length," events"]})}),s.jsx("div",{className:"zone-b",children:s.jsx(X_,{activity:t,onTicket:e.onTicket})})]}),s.jsx("section",{className:"page-col conversation-col",children:s.jsx($2,{activity:e.allActivity,snaps:e.snaps,sessionId:e.chatSession,onAnswer:e.onAnswer})})]})}const h6={holding:"Holding",challenged:"Challenged",invalidated:"Invalidated",confirmed:"Confirmed"};function f6(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 m6(e){const{a:t,snap:n}=e,i=t.tickets.flatMap(c=>n.tickets.filter(d=>d.id===c)),o=t.challenge&&`${t.challenge.by}: ${t.challenge.evidence}`;return s.jsx(fe,{as:"li",className:`assumption st-${t.status}`,edge:t.status==="challenged"?"attention":"neutral",title:t.text,titleText:t.text,context:s.jsx(_,{parts:[{text:t.id,code:!0},h6[t.status],f6(t)],children:i.length>0&&s.jsxs("span",{className:"assumption-tickets",children:[s.jsx("span",{className:"sep",children:" · "}),"relied on by",i.map(c=>s.jsx("button",{className:"link t-code",onClick:()=>e.onSelect({kind:"ticket",id:c.id}),children:c.key},c.id))]})}),detail:o,detailText:o,actions:e.onConfirm&&s.jsx(R,{size:"sm",variant:"ghost",disabled:e.busy,onClick:e.onConfirm,children:"Confirm"})})}function p6(e){const[t,n]=w.useState(),[i,o]=w.useState();return{confirm:async(d,u)=>{o(d);const f=await fetch(`${re()}/assumptions/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,id:d,text:u})}).catch(()=>{});if(o(void 0),f!=null&&f.ok)return n(void 0);const m=await(f==null?void 0:f.json().catch(()=>({})));n((m==null?void 0:m.error)??"Could not confirm it; is the Lookout connected?")},busy:i,error:t}}function g6({snap:e,onSelect:t}){const{confirm:n,busy:i,error:o}=p6(e.map.id),c=e.map.sections.assumptions??[];return c.length?s.jsxs(s.Fragment,{children:[o&&s.jsx("p",{className:"urgent-text",children:o}),s.jsx("ul",{className:"assumptions row-list",children:c.map(d=>{const u=d.status==="holding"||d.status==="challenged";return s.jsx(m6,{a:d,snap:e,onSelect:t,onConfirm:u?()=>void n(d.id,d.text):void 0,busy:i===d.id},d.id)})})]}):s.jsx(Te,{children:"None yet. They come from the accepted discovery brief or the trail's start."})}function k6(e){const[,t,n=e]=/^(#\d+)\s+(.+)$/.exec(e)??[],[i=n,...o]=n.split(/\s+[—–]\s+/);return{key:t,title:i,reason:o.join(" — ")||void 0}}function v6(e){const[t,n]=w.useState([]),i=e==null?void 0:e.map.id,o=(e==null?void 0:e.tickets.reduce((c,d)=>Math.max(c,d.updatedAt),e.map.updatedAt))??0;return w.useEffect(()=>{if(!i)return;let c=!0;return fetch(`${re()}/journal?mapId=${encodeURIComponent(i)}`).then(d=>d.ok?d.json():{entries:[]}).then(d=>c&&n(d.entries)).catch(()=>c&&n([])),()=>{c=!1}},[i,o]),t}function w6({snap:e,activity:t,onTicket:n}){const i=v6(e),o=t.usageByMap[e.map.id],c=w.useMemo(()=>ov({snap:e,journal:i,answered:t.answered,usage:o}),[e,i,t.answered,o]),d=c.interventions,u=[["Done",`${c.done}`,`${c.done} done · ${c.cancelled} cancelled · ${c.open} open`],["Lead time",rn(c.trailLeadMs),"Trail lead time: from when the trail was charted to its last done ticket"],["Median ticket",rn(c.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",`${c.rework.cycles}`,`Times work went back to rework, on ${c.rework.tickets} tickets`],["Reviews",`${c.reviews.passed}/${c.reviews.failed}`,`${c.reviews.passed} passed, ${c.reviews.failed} failed, ${c.reviews.needsHuman} needed you`],["Cost / ticket",c.spend.perVerifiedTicketUsd===void 0?"—":hi(c.spend.perVerifiedTicketUsd),`Cost per verified ticket: trail spend ${hi(c.spend.costUsd)} ÷ ${c.done} done tickets`]];return s.jsxs("div",{className:"report",children:[s.jsx("ul",{className:"report-stats",children:u.map(([f,m,g])=>s.jsxs("li",{"data-tip":g,children:[s.jsx("span",{className:"mono-label",children:f}),s.jsx("b",{children:m})]},f))}),s.jsxs("div",{className:"report-bar",children:[s.jsx("span",{className:"mono-label",children:"Tickets"}),s.jsx(R,{size:"sm",variant:"ghost","data-tip":"Download this report as markdown",onClick:()=>Ev(`${e.map.key.replace("#","trail-")}-report.md`,WS(c,e.map.title)),children:"Export markdown"})]}),c.tickets.length?s.jsx("ul",{className:"list report-tickets",children:c.tickets.map(f=>s.jsx("li",{className:`out-${f.outcome}`,children:s.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:[s.jsx("span",{className:"key",children:f.key}),s.jsx("span",{className:"ttl",children:f.title}),s.jsx("span",{className:"lead",children:f.outcome==="done"?rn(f.leadMs):f.outcome})]})},f.id))}):s.jsx(Te,{children:"No tickets yet"})]})}function y6({tab:e,snap:t,selection:n,onSelect:i,activity:o}){const c=t.map.sections;switch(e){case"report":return o?s.jsx(w6,{snap:t,activity:o,onTicket:d=>i({kind:"ticket",id:d})}):s.jsx(Te,{children:"No activity yet"});case"assumptions":return s.jsx(g6,{snap:t,onSelect:i});case"decisions":return c.decisions.length?s.jsx("ol",{className:"row-list decisions",children:[...c.decisions].reverse().map((d,u)=>s.jsx(fe,{as:"li",title:d.text,titleText:d.text,context:d.ticketKey&&s.jsx(_,{parts:[{text:d.ticketKey,code:!0}]}),onOpen:d.ticketId?()=>i({kind:"ticket",id:d.ticketId}):void 0},`${d.ticketKey}-${u}`))}):s.jsx(Te,{children:"None"});case"unspecified":return c.unspecified.length?s.jsx("ul",{className:"row-list unspecified",children:c.unspecified.map(d=>s.jsx(fe,{as:"li",title:d,titleText:d,selected:(n==null?void 0:n.kind)==="unspecified"&&n.item===d,onOpen:()=>i({kind:"unspecified",item:d})},d))}):s.jsx(Te,{children:"None"});case"oos":return c.outOfScope.length?s.jsx("ul",{className:"row-list oos",children:c.outOfScope.map(d=>{const u=k6(d);return s.jsx(fe,{as:"li",title:u.title,titleText:d,context:s.jsx(_,{parts:[u.key&&{text:u.key,code:!0},u.reason]})},d)})}):s.jsx(Te,{children:"None"});case"destination":return c.destination.trim()?s.jsx(Sa,{className:"plan-doc",text:c.destination}):s.jsx(Te,{children:"No destination yet"});case"notes":return c.notes.trim()?s.jsx(Sa,{className:"plan-doc",text:c.notes}):s.jsx(Te,{children:"No notes yet"});default:return e}}function x6({snap:e,selection:t,onSelect:n,bare:i,onAudit:o,activity:c}){var k;const[d,u]=w.useState("unspecified"),f=e==null?void 0:e.map.sections,m=[{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:"destination",label:"Destination"},{id:"notes",label:"Notes"},{id:"report",label:"Report"}],g=e?s.jsx(y6,{tab:d,snap:e,selection:t,onSelect:n,activity:c}):s.jsx(An,{title:"No plan yet",hint:"Open questions, decisions, what's ruled out, notes and the trail report collect here."});return s.jsxs(Be,{className:`zone sections ${i?"bare":""}`,style:i?void 0:{gridArea:"plan"},children:[!i&&s.jsx(yt,{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, the destination in full, and notes. Report shows how the trail is going: lead times, your interventions, rework, reviews and cost per verified ticket."}),s.jsxs("div",{className:"sections-tabs",children:[s.jsx(it,{compact:!0,"aria-label":"Plan section",value:d,onChange:u,options:m.map(y=>({value:y.id,label:y.n===void 0?y.label:`${y.label} · ${y.n}`}))}),d==="decisions"&&o&&s.jsx("button",{className:"link",onClick:o,children:"Audit ›"})]}),s.jsx("div",{className:"zone-b",children:g})]})}const _d=[["decided","Done"],["claimed","Working"],["frontier","Ready"],["blocked","Backlog"],["parked","Parked"],["out-of-scope","Cancelled"]],Nk=[["verifying","Verifying"],["rework","Rework"],["held","Blocked"]];function j6({snap:e,sessions:t}){const n=Jk(e),i=m=>n[m],o=t.filter(NC).length,c=mS(e),d=Math.max(1,...c.map(m=>m.open+m.closed)),f=(e.map.verification??"off")!=="off"||Nk.some(([m])=>i(m))?[..._d.slice(0,2),...Nk,..._d.slice(2)]:_d;return s.jsxs("div",{className:"status-panel",children:[s.jsxs("div",{className:"sp-col sp-status",children:[s.jsxs("div",{className:"sp-head",children:[s.jsx(Ke,{as:"h3",children:"Status"}),s.jsxs("span",{className:"t-meta",children:[n.total," tickets"]})]}),s.jsxs("ul",{children:[f.map(([m,g])=>s.jsxs("li",{className:`st-${m} ${i(m)?"":"zero"}`,children:[s.jsx("i",{}),s.jsx("span",{children:g}),s.jsx("b",{children:i(m)})]},m)),s.jsxs("li",{className:`st-waiting ${o?"":"zero"}`,children:[s.jsx("i",{}),s.jsx("span",{children:"Waiting on you"}),s.jsx("b",{children:o})]})]})]}),s.jsxs("div",{className:"sp-block sp-col",children:[s.jsx("span",{className:"t-label",children:"Type mix"}),s.jsx("ul",{className:"mix",children:c.map(m=>s.jsxs("li",{title:`${m.type}: ${m.closed} closed, ${m.open} open`,children:[s.jsx("span",{className:"t-meta",children:ns[m.type]}),s.jsxs("span",{className:"mix-bar",children:[s.jsx("i",{className:"closed",style:{width:`${m.closed/d*100}%`}}),s.jsx("i",{className:"open",style:{width:`${m.open/d*100}%`}})]}),s.jsx("b",{children:m.open+m.closed})]},m.type))})]})]})}function b6(e){const{snap:t,selection:n}=e,i=(n==null?void 0:n.kind)==="unspecified"?n.item:void 0;return s.jsxs(Be,{className:"zone page plan-page",children:[s.jsx("section",{className:"page-col",children:s.jsx(x6,{snap:t,selection:n,onSelect:e.onSelect,bare:!0,onAudit:e.onAudit,activity:e.activity})}),s.jsxs("section",{className:"page-col",children:[i&&s.jsx(yt,{title:"Open question"}),s.jsxs("div",{className:"zone-b",children:[t&&i&&s.jsx(dy,{snap:t,item:i,api:e.api}),t&&!i&&s.jsxs(s.Fragment,{children:[e.glance,s.jsx(j6,{snap:t,sessions:e.activity.sessions})]})]})]})]})}function S6({api:e,bp:t,nav:n,scoped:i,done:o,attn:c}){const d=gt(5e3),u=f=>e.mapId&&n.openTicket(e.mapId,f);if(n.statsOpen)return s.jsx(JP,{api:e,bp:t,onClose:()=>n.setStatsOpen(!1)});switch(n.page){case"logbook":return s.jsx(Q_,{api:e,bp:t,focus:n.logbookFocus,onClose:n.toMap,onOpenTicket:n.openTicket});case"plan":return s.jsx(b6,{api:e,snap:e.snap,activity:i,selection:e.selection,onSelect:n.select,onAudit:()=>n.openDecisions(),glance:e.snap&&s.jsx(ly,{snap:e.snap,sessions:i.sessions,attention:c.attention.view,done:o,now:d,onTicket:u,onItem:c.open})});case"activity":return s.jsx(u6,{activity:i,allActivity:e.activity,snaps:e.allSnaps,snap:e.snap,leases:e.leases,done:o,chatSession:e.chatSession,onTicket:u,onOpenChat:f=>n.openChat(f),onAnswer:e.actions.answer});default:return null}}function N6(e,t,n){const i=Ey(),[o,c]=w.useState(()=>new URLSearchParams(location.search).has("projects")),d=o&&i.many&&s.jsx(uP,{projects:i,bp:e,onClose:()=>c(!1),onItemHere:n});return{projects:i,overview:d,closeOverview:()=>c(!1),openOverview:()=>{t.toMap(),c(!0)}}}const $6=e=>typeof e=="string"&&/^\/(?!\/)[\w/?=&#.-]{0,200}$/.test(e)?e:void 0;function C6(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(i=>{const o=$6(i==null?void 0:i.href);return typeof(i==null?void 0:i.title)!="string"||!o?[]:[{title:i.title.slice(0,80),href:o,done:i.done===!0,next:i.next===!0,optional:i.optional===!0}]});return{done:t.done,total:t.total,complete:t.complete===!0,steps:n}}function T6(){var i;const e=(i=pt())==null?void 0:i.setup,[t,n]=w.useState();return w.useEffect(()=>{if(!e)return;let o=!1;const c=()=>void fetch(e).then(k=>k.ok?k.json():void 0).then(k=>{const y=C6(k);o=(y==null?void 0:y.complete)===!0,n(y)}).catch(()=>{});c();const d=()=>document.visibilityState==="visible"&&c();let u;const f=()=>{o||(clearTimeout(u),u=setTimeout(c,500))};document.addEventListener("visibilitychange",d),window.addEventListener(ru,f);const m=Ya(f),g=as(f);return()=>{clearTimeout(u),document.removeEventListener("visibilitychange",d),window.removeEventListener(ru,f),m(),g()}},[e]),t}const Zy="teamtrail.guide.open";function E6(){try{return localStorage.getItem(Zy)!=="no"}catch{return!0}}function A6(e){try{localStorage.setItem(Zy,e?"yes":"no")}catch{}}function I6(){const e=T6(),[t,n]=w.useState(E6);if(!e||e.complete)return null;const i=c=>{n(c),A6(c)},o=`${e.done} of ${e.total}`;return Kw.createPortal(s.jsxs("aside",{className:`setup-guide${t?" open":""}`,"aria-label":"Get started",children:[t&&s.jsxs("div",{className:"setup-bubble",children:[s.jsxs("header",{children:[s.jsx("b",{children:"Get started"}),s.jsx("span",{className:"t-meta",children:o}),s.jsx(R,{size:"sm",variant:"ghost",onClick:()=>i(!1),"aria-label":"Minimize",children:"–"})]}),s.jsx("ol",{children:e.steps.map((c,d)=>s.jsxs("li",{className:[c.done&&"done",c.next&&"next"].filter(Boolean).join(" "),children:[s.jsx("span",{className:"setup-mark","aria-hidden":"true",children:c.done?"✓":d+1}),s.jsx("a",{href:c.href,children:c.title}),c.optional&&s.jsx("span",{className:"t-meta",children:"optional"})]},c.href+c.title))})]}),s.jsxs("button",{type:"button",className:"setup-scout",onClick:()=>i(!t),"aria-expanded":t,children:[s.jsx(Ua,{size:1,framed:!1,state:"idle"}),!t&&s.jsxs("span",{className:"setup-chip",children:["Get started · ",o]})]})]}),document.body)}function R6(){const e=w.useMemo(()=>SC(bC()),[]),t=fT(e),{snap:n,activity:i}=t,[o,c]=gT(),d=PD(),u=y4(e,t),f=QD(e.kind),m=cT(),g=YD(i,t.mapId);BD(i.pending.length,n==null?void 0:n.map.title);const k=_D(t),y=M_({snap:n,selectMap:t.actions.selectMap,openTicket:k.openTicket,openTrailChecks:k.openTrailChecks}),b=BA(y.briefText),S=D_({api:t,nav:k,knowledge:b,reviewBrief:y.review,openReroute:we=>y.openReroute(we.mapId,we.ref),openGuides:()=>d.open("guides"),openConnector:we=>d.open(we),openApprovals:()=>d.open("approvals"),openRule:we=>XL(d.open,we),openFocusSettings:()=>d.open("attention")}),x=S.attention.view,$=dT(e,t,o.briefing,x==null?void 0:x.items),N=WD({snap:n,sessions:g.sessions,view:x}),O=HD(t.mapId,N.items),{projects:D,overview:F,openOverview:K,closeOverview:I}=N6(m,k,S.link.request),Q=d.route&&s.jsx(s4,{rt:e,api:t,bp:m,prefs:o,update:c,settings:d,openTicket:k.openTicket}),Z=(k.statsOpen||k.page)&&s.jsx(S6,{api:t,bp:m,nav:k,scoped:g,done:y.done,attn:S}),q=Q||F||Z;qD({...t,view:x,busy:!!q||!!t.selection,open:S.open});const ee=k.page??"map",Se=we=>{d.dismiss(),I(),we==="map"?k.toMap():k.openPage(we)},ve=m==="mobile",be=s.jsx(MD,{api:t,live:N.live,main:O.tone,focus:N.focus,onSelect:k.select,onNewTrail:u.open,minFit:ve?.7:0,docked:ve,trail:y,bubble:we=>s.jsx(tL,{api:t,nav:k,attn:S,sessions:g.sessions,mainNeeds:O.needs,place:we})}),ae=s.jsx(w4,{api:t,nav:k,attn:S,trail:N,bp:m,brief:y.inboxCard}),Ie=s.jsx(TT,{brief:$,snaps:t.allSnaps,bp:m,openTicket:k.openTicket,openChat:k.openChat,openDecisions:k.openDecisions,openQuestion:k.openQuestion,toMap:k.toMap});return s.jsx(Aw.Provider,{value:b,children:s.jsxs("div",{className:`app bp-${m} view-${ee}`,children:[s.jsx(sL,{api:t,rt:e,repo:s.jsx(hP,{repo:f,projects:D,onOverview:K}),brief:$,attention:S.header,view:Q||F?void 0:ee,onView:Se,phone:ve,needs:N.items,elsewhere:N.elsewhere,onNeed:S.open,onStats:()=>{d.dismiss(),k.toggleStats()},onNewTrail:u.open,onStartOver:()=>n&&u.startOver(n.map),onSettings:d.toggle,onSlack:()=>d.open("slack"),onToggleTheme:we=>c({theme:we?"night":"day"})}),ve?s.jsxs(s.Fragment,{children:[s.jsx(OD,{covered:q,map:be,trailBar:ae,projects:D.many&&s.jsx(mP,{projects:D,onOverview:K})}),s.jsx(LD,{view:ee,covered:!!Q||!!F,needs:N.items.length,onPick:Se})]}):s.jsxs(s.Fragment,{children:[be,ae,q]}),s.jsx(i4,{api:t,nav:k,attn:S,sessions:g.sessions,done:y.done}),Ie,y.dialog,t.error&&s.jsx("div",{className:"error-toast",children:t.error}),u.dialog,!o.onboarded&&s.jsx(YL,{prefs:o,update:c,activeTracker:e.kind}),s.jsx(DA,{}),s.jsx(I6,{})]})})}const M6="X-Teamtrail-Session";function L6(e){return typeof e=="string"?e:e instanceof URL?e.href:e.url}function O6(e){const t=new URL(L6(e),location.href),n=J.apiPrefix;return t.origin===location.origin&&(t.pathname===n||t.pathname.startsWith(`${n}/`))}function P6(){const e=window.fetch.bind(window);window.fetch=(t,n)=>{const i=rC()?Du():void 0;if(!i||!O6(t))return e(t,n);const o=new Headers((n==null?void 0:n.headers)??(t instanceof Request?t.headers:void 0));return o.set(M6,i.secret),e(t,{...n,headers:o})}}Ka(Fu().theme);P6();r0.createRoot(document.getElementById("root")).render(s.jsxs(K3,{children:[s.jsx(R6,{}),s.jsx(jT,{})]}));