teamtrail 0.61.0 → 0.64.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,181 @@
1
+ var Qj=Object.defineProperty;var Yj=(e,t,n)=>t in e?Qj(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var oe=(e,t,n)=>Yj(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 cp;function Jj(){if(cp)return xe;cp=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 lp;function vu(){return lp||(lp=1,nd.exports=Jj()),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 dp;function Xj(){if(dp)return cr;dp=1;var e=vu(),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 up;function Zj(){return up||(up=1,td.exports=Xj()),td.exports}var s=Zj(),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 hp;function e0(){return hp||(hp=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 fp;function t0(){return fp||(fp=1,id.exports=e0()),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 mp;function n0(){if(mp)return $t;mp=1;var e=vu(),t=t0();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 mh(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 ph(r,a){a=a.checked,a!=null&&D(r,"checked",a,!1)}function lc(r,a){ph(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 gh(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 kh(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 vh(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 wh(r){var a=r.textContent;a===r._wrapperState.initialValue&&a!==""&&a!==null&&(r.value=a)}function yh(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"?yh(a):r==="http://www.w3.org/2000/svg"&&a==="foreignObject"?"http://www.w3.org/1999/xhtml":r}var _r,xh=(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},Zy=["Webkit","ms","Moz","O"];Object.keys(Ni).forEach(function(r){Zy.forEach(function(a){a=a+r.charAt(0).toUpperCase()+r.substring(1),Ni[a]=Ni[r]})});function jh(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 bh(r,a){r=r.style;for(var l in a)if(a.hasOwnProperty(l)){var h=l.indexOf("--")===0,p=jh(l,a[l],h);l==="float"&&(l="cssFloat"),h?r.setProperty(l,p):r[l]=p}}var ex=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(ex[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 Sh(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 Nh(r){Ms?Ls?Ls.push(r):Ls=[r]:Ms=r}function $h(){if(Ms){var r=Ms,a=Ls;if(Ls=Ms=null,Sh(r),a)for(r=0;r<a.length;r++)Sh(a[r])}}function Ch(r,a){return r(a)}function Th(){}var vc=!1;function Eh(r,a,l){if(vc)return r(a,l);vc=!0;try{return Ch(r,a,l)}finally{vc=!1,(Ms!==null||Ls!==null)&&(Th(),$h())}}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 tx(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,nx={onError:function(r){Ti=!0,Br=r}};function sx(r,a,l,h,p,v,j,C,T){Ti=!1,Br=null,tx.apply(nx,arguments)}function ix(r,a,l,h,p,v,j,C,T){if(sx.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 Ah(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 Ih(r){if(cs(r)!==r)throw Error(n(188))}function rx(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 Ih(p),r;if(v===h)return Ih(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 Rh(r){return r=rx(r),r!==null?Mh(r):null}function Mh(r){if(r.tag===5||r.tag===6)return r;for(r=r.child;r!==null;){var a=Mh(r);if(a!==null)return a;r=r.sibling}return null}var Lh=t.unstable_scheduleCallback,Oh=t.unstable_cancelCallback,ox=t.unstable_shouldYield,ax=t.unstable_requestPaint,qe=t.unstable_now,cx=t.unstable_getCurrentPriorityLevel,xc=t.unstable_ImmediatePriority,Ph=t.unstable_UserBlockingPriority,zr=t.unstable_NormalPriority,lx=t.unstable_LowPriority,Dh=t.unstable_IdlePriority,Ur=null,cn=null;function dx(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:fx,ux=Math.log,hx=Math.LN2;function fx(r){return r>>>=0,r===0?32:31-(ux(r)/hx|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 mx(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 px(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]=mx(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 _h(){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 gx(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 Bh(r){return r&=-r,1<r?4<r?(r&268435455)!==0?16:536870912:4:1}var Fh,Nc,zh,Uh,Wh,$c=!1,Gr=[],Rn=null,Mn=null,Ln=null,Ii=new Map,Ri=new Map,On=[],kx="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 Hh(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 vx(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 Kh(r){var a=ls(r.target);if(a!==null){var l=cs(a);if(l!==null){if(a=l.tag,a===13){if(a=Ah(l),a!==null){r.blockedOn=a,Wh(r.priority,function(){zh(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 Gh(r,a,l){Vr(r)&&l.delete(a)}function wx(){$c=!1,Rn!==null&&Vr(Rn)&&(Rn=null),Mn!==null&&Vr(Mn)&&(Mn=null),Ln!==null&&Vr(Ln)&&(Ln=null),Ii.forEach(Gh),Ri.forEach(Gh)}function Li(r,a){r.blockedOn===a&&(r.blockedOn=null,$c||($c=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,wx)))}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);)Kh(l),l.blockedOn===null&&On.shift()}var Os=F.ReactCurrentBatchConfig,qr=!0;function yx(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 xx(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),Hh(r,h);else if(vx(p,r,a,l,h))h.stopPropagation();else if(Hh(r,h),a&4&&-1<kx.indexOf(r)){for(;p!==null;){var v=Vi(p);if(v!==null&&Fh(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=Ah(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 Vh(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(cx()){case xc:return 1;case Ph:return 4;case zr:case lx:return 16;case Dh: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 Qh(){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:Qh,this.isPropagationStopped=Qh,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}),jx=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}}),Yh=It(Zr),bx=U({},Zr,{dataTransfer:0}),Sx=It(bx),Nx=U({},Pi,{relatedTarget:0}),Mc=It(Nx),$x=U({},Ps,{animationName:0,elapsedTime:0,pseudoElement:0}),Cx=It($x),Tx=U({},Ps,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),Ex=It(Tx),Ax=U({},Ps,{data:0}),Jh=It(Ax),Ix={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Rx={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"},Mx={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Lx(r){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(r):(r=Mx[r])?!!a[r]:!1}function Lc(){return Lx}var Ox=U({},Pi,{key:function(r){if(r.key){var a=Ix[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"?Rx[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}}),Px=It(Ox),Dx=U({},Zr,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Xh=It(Dx),_x=U({},Pi,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Lc}),Bx=It(_x),Fx=U({},Ps,{propertyName:0,elapsedTime:0,pseudoElement:0}),zx=It(Fx),Ux=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}),Wx=It(Ux),Hx=[9,13,27,32],Oc=u&&"CompositionEvent"in window,_i=null;u&&"documentMode"in document&&(_i=document.documentMode);var Kx=u&&"TextEvent"in window&&!_i,Zh=u&&(!Oc||_i&&8<_i&&11>=_i),ef=" ",tf=!1;function nf(r,a){switch(r){case"keyup":return Hx.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function sf(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var Ds=!1;function Gx(r,a){switch(r){case"compositionend":return sf(a);case"keypress":return a.which!==32?null:(tf=!0,ef);case"textInput":return r=a.data,r===ef&&tf?null:r;default:return null}}function Vx(r,a){if(Ds)return r==="compositionend"||!Oc&&nf(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 Zh&&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 rf(r){var a=r&&r.nodeName&&r.nodeName.toLowerCase();return a==="input"?!!qx[r.type]:a==="textarea"}function of(r,a,l,h){Nh(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 Qx(r){Sf(r,0)}function eo(r){var a=Us(r);if(Dr(a))return r}function Yx(r,a){if(r==="change")return a}var af=!1;if(u){var Pc;if(u){var Dc="oninput"in document;if(!Dc){var cf=document.createElement("div");cf.setAttribute("oninput","return;"),Dc=typeof cf.oninput=="function"}Pc=Dc}else Pc=!1;af=Pc&&(!document.documentMode||9<document.documentMode)}function lf(){Bi&&(Bi.detachEvent("onpropertychange",df),Fi=Bi=null)}function df(r){if(r.propertyName==="value"&&eo(Fi)){var a=[];of(a,Fi,r,gc(r)),Eh(Qx,a)}}function Jx(r,a,l){r==="focusin"?(lf(),Bi=a,Fi=l,Bi.attachEvent("onpropertychange",df)):r==="focusout"&&lf()}function Xx(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return eo(Fi)}function Zx(r,a){if(r==="click")return eo(a)}function ej(r,a){if(r==="input"||r==="change")return eo(a)}function tj(r,a){return r===a&&(r!==0||1/r===1/a)||r!==r&&a!==a}var Jt=typeof Object.is=="function"?Object.is:tj;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 uf(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function hf(r,a){var l=uf(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=uf(l)}}function ff(r,a){return r&&a?r===a?!0:r&&r.nodeType===3?!1:a&&a.nodeType===3?ff(r,a.parentNode):"contains"in r?r.contains(a):r.compareDocumentPosition?!!(r.compareDocumentPosition(a)&16):!1:!1}function mf(){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 nj(r){var a=mf(),l=r.focusedElem,h=r.selectionRange;if(a!==l&&l&&l.ownerDocument&&ff(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=hf(l,v);var j=hf(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 sj=u&&"documentMode"in document&&11>=document.documentMode,_s=null,Bc=null,Ui=null,Fc=!1;function pf(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={},gf={};u&&(gf=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 gf)return zc[r]=a[l];return r}var kf=no("animationend"),vf=no("animationiteration"),wf=no("animationstart"),yf=no("transitionend"),xf=new Map,jf="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){xf.set(r,a),c(a,[r])}for(var Uc=0;Uc<jf.length;Uc++){var Wc=jf[Uc],ij=Wc.toLowerCase(),rj=Wc[0].toUpperCase()+Wc.slice(1);Dn(ij,"on"+rj)}Dn(kf,"onAnimationEnd"),Dn(vf,"onAnimationIteration"),Dn(wf,"onAnimationStart"),Dn("dblclick","onDoubleClick"),Dn("focusin","onFocus"),Dn("focusout","onBlur"),Dn(yf,"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(" "),oj=new Set("cancel close invalid load scroll toggle".split(" ").concat(Wi));function bf(r,a,l){var h=r.type||"unknown-event";r.currentTarget=l,ix(h,a,void 0,r),r.currentTarget=null}function Sf(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;bf(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;bf(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)||(Nf(a,r,2,!1),l.add(h))}function Hc(r,a,l){var h=0;a&&(h|=4),Nf(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"&&(oj.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 Nf(r,a,l,h){switch(Vh(a)){case 1:var p=yx;break;case 4:p=xx;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}Eh(function(){var P=v,H=gc(l),G=[];e:{var W=xf.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=Px;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=Yh;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":X=Sx;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":X=Bx;break;case kf:case vf:case wf:X=Cx;break;case yf:X=zx;break;case"scroll":X=jx;break;case"wheel":X=Wx;break;case"copy":case"cut":case"paste":X=Ex;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":X=Xh}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=Yh,V="onMouseLeave",M="onMouseEnter",A="mouse",(r==="pointerout"||r==="pointerover")&&(se=Xh,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&&$f(G,W,X,se,!1),ne!==null&&Qe!==null&&$f(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=Yx;else if(rf(W))if(af)ie=ej;else{ie=Xx;var le=Jx}else(X=W.nodeName)&&X.toLowerCase()==="input"&&(W.type==="checkbox"||W.type==="radio")&&(ie=Zx);if(ie&&(ie=ie(r,P))){of(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":(rf(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,pf(G,l,H);break;case"selectionchange":if(sj)break;case"keydown":case"keyup":pf(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?nf(r,l)&&(he="onCompositionEnd"):r==="keydown"&&l.keyCode===229&&(he="onCompositionStart");he&&(Zh&&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 Jh(he,r,null,l,H),G.push({event:he,listeners:le}),de?he.data=de:(de=sf(l),de!==null&&(he.data=de)))),(de=Kx?Gx(r,l):Vx(r,l))&&(P=io(P,"onBeforeInput"),0<P.length&&(H=new Jh("onBeforeInput","beforeinput",null,l,H),G.push({event:H,listeners:P}),H.data=de))}Sf(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 $f(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 aj=/\r\n?/g,cj=/\u0000|\uFFFD/g;function Cf(r){return(typeof r=="string"?r:""+r).replace(aj,`
38
+ `).replace(cj,"")}function ro(r,a,l){if(a=Cf(a),Cf(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,lj=typeof clearTimeout=="function"?clearTimeout:void 0,Tf=typeof Promise=="function"?Promise:void 0,dj=typeof queueMicrotask=="function"?queueMicrotask:typeof Tf<"u"?function(r){return Tf.resolve(null).then(r).catch(uj)}:Qc;function uj(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 Ef(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,hj="__reactListeners$"+zs,fj="__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=Ef(r);r!==null;){if(l=r[ln])return l;r=Ef(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 Af(r,a,l){if(ct.current!==Fn)throw Error(n(168));Le(ct,a),Le(xt,l)}function If(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 Rf(r,a,l){var h=r.stateNode;if(!h)throw Error(n(169));l?(r=If(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 Mf(r){wn===null?wn=[r]:wn.push(r)}function mj(r){uo=!0,Mf(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)),Lh(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 Lf(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),Lf(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 Of(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 Pf(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(!Pf(r,a)){if(nl(r))throw Error(n(418));a=_n(l.nextSibling);var h=Rt;a&&Pf(r,a)?Of(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 Df(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 Df(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 _f(),Error(n(418));for(;a;)Of(r,a),a=_n(a.nextSibling)}if(Df(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 _f(){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 pj=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 Bf(r){var a=r._init;return a(r._payload)}function Ff(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&&Bf(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&&Bf(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=Ff(!0),zf=Ff(!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 Uf(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 Wf(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 Hf(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 Kf(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 Gf(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,gj=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?yj:xj,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=jj,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 Vf(){}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(Jf.bind(null,l,h,r),[r]),h.getSnapshot!==a||v||et!==null&&et.memoizedState.tag&1){if(l.flags|=2048,tr(9,Yf.bind(null,l,h,p,a),void 0,null),tt===null)throw Error(n(349));(ps&30)!==0||Qf(l,a,p)}return p}function Qf(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 Yf(r,a,l,h){a.value=l,a.getSnapshot=h,Xf(a)&&Zf(r)}function Jf(r,a,l){return l(function(){Xf(a)&&Zf(r)})}function Xf(r){var a=r.getSnapshot;r=r.value;try{var l=a();return!Jt(r,l)}catch{return!0}}function Zf(r){var a=jn(r,1);a!==null&&nn(a,r,1,-1)}function em(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=wj.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 tm(){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 nm(r,a){return bo(8390656,8,r,a)}function xl(r,a){return So(2048,8,r,a)}function sm(r,a){return So(4,2,r,a)}function im(r,a){return So(4,4,r,a)}function rm(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 om(r,a,l){return l=l!=null?l.concat([r]):null,So(4,4,rm.bind(null,a,r),l)}function jl(){}function am(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 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]:(r=r(),l.memoizedState=[r,a],r)}function lm(r,a,l){return(ps&21)===0?(r.baseState&&(r.baseState=!1,bt=!0),r.memoizedState=l):(Jt(l,a)||(l=_h(),We.lanes|=l,gs|=l,r.baseState=!0),a)}function kj(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 dm(){return Bt().memoizedState}function vj(r,a,l){var h=Vn(r);if(l={lane:h,action:l,hasEagerState:!1,eagerState:null,next:null},um(r))hm(a,l);else if(l=Uf(r,a,l,h),l!==null){var p=vt();nn(l,r,h,p),fm(l,a,h)}}function wj(r,a,l){var h=Vn(r),p={lane:h,action:l,hasEagerState:!1,eagerState:null,next:null};if(um(r))hm(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=Uf(r,a,p,h),l!==null&&(p=vt(),nn(l,r,h,p),fm(l,a,h))}}function um(r){var a=r.alternate;return r===We||a!==null&&a===We}function hm(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 fm(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},yj={readContext:_t,useCallback:function(r,a){return un().memoizedState=[r,a===void 0?null:a],r},useContext:_t,useEffect:nm,useImperativeHandle:function(r,a,l){return l=l!=null?l.concat([r]):null,bo(4194308,4,rm.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=vj.bind(null,We,r),[h.memoizedState,r]},useRef:function(r){var a=un();return r={current:r},a.memoizedState=r},useState:em,useDebugValue:jl,useDeferredValue:function(r){return un().memoizedState=r},useTransition:function(){var r=em(!1),a=r[0];return r=kj.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||Qf(h,a,l)}p.memoizedState=l;var v={value:l,getSnapshot:a};return p.queue=v,nm(Jf.bind(null,h,v,r),[r]),h.flags|=2048,tr(9,Yf.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=gj++,a=":"+a+"r"+l.toString(32)+":";return r.memoizedState=a},unstable_isNewReconciler:!1},xj={readContext:_t,useCallback:am,useContext:_t,useEffect:xl,useImperativeHandle:om,useInsertionEffect:sm,useLayoutEffect:im,useMemo:cm,useReducer:wl,useRef:tm,useState:function(){return wl(er)},useDebugValue:jl,useDeferredValue:function(r){var a=Bt();return lm(a,Xe.memoizedState,r)},useTransition:function(){var r=wl(er)[0],a=Bt().memoizedState;return[r,a]},useMutableSource:Vf,useSyncExternalStore:qf,useId:dm,unstable_isNewReconciler:!1},jj={readContext:_t,useCallback:am,useContext:_t,useEffect:xl,useImperativeHandle:om,useInsertionEffect:sm,useLayoutEffect:im,useMemo:cm,useReducer:yl,useRef:tm,useState:function(){return yl(er)},useDebugValue:jl,useDeferredValue:function(r){var a=Bt();return Xe===null?a.memoizedState=r:lm(a,Xe.memoizedState,r)},useTransition:function(){var r=yl(er)[0],a=Bt().memoizedState;return[r,a]},useMutableSource:Vf,useSyncExternalStore:qf,useId:dm,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 mm(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 pm(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 gm(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 bj=typeof WeakMap=="function"?WeakMap:Map;function km(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 vm(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 wm(r,a,l){var h=r.pingCache;if(h===null){h=r.pingCache=new bj;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=Dj.bind(null,r,a,l),a.then(r,r))}function ym(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 xm(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 Sj=F.ReactCurrentOwner,bt=!1;function kt(r,a,l,h){a.child=r===null?zf(a,null,l,h):qs(a,r.child,l,h)}function jm(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 bm(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,Sm(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 Sm(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 Nm(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 $m(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 Cm(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),pm(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)&&gm(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||mm(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,Wf(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)&&gm(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||mm(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){$m(r,a);var j=(a.flags&128)!==0;if(!h&&!j)return p&&Rf(a,l,!1),Sn(r,a,v);h=a.stateNode,Sj.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&&Rf(a,l,!0),a.child}function Tm(r){var a=r.stateNode;a.pendingContext?Af(r,a.pendingContext,a.pendingContext!==a.context):a.context&&Af(r,a.context,!1),ul(r,a.containerInfo)}function Em(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 Am(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 Nj(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 Nj(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=_j.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 Im(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 Rm(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&&Im(r,l,a);else if(r.tag===19)Im(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 $j(r,a,l){switch(a.tag){case 3:Tm(a),Vs();break;case 5:Gf(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?Am(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 Rm(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,Nm(r,a,l)}return Sn(r,a,l)}var Mm,Ml,Lm,Om;Mm=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(){},Lm=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)}},Om=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 Cj(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)Lm(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":mh(h,v),De("invalid",h);break;case"select":h._wrapperState={wasMultiple:!!v.multiple},De("invalid",h);break;case"textarea":kh(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),gh(h,v,!0);break;case"textarea":In(h),wh(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=yh(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,Mm(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":mh(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":kh(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"?bh(r,T):v==="dangerouslySetInnerHTML"?(T=T?T.__html:void 0,T!=null&&xh(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),gh(r,h,!1);break;case"textarea":In(r),wh(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)Om(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)_f(),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 Tj(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,Ej=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 Pm=!1;function Aj(r,a){if(Gc=qr,r=mf(),_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=Pm,Pm=!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 Dm(r){var a=r.alternate;a!==null&&(r.alternate=null,Dm(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[hj],delete a[fj])),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 _m(r){return r.tag===5||r.tag===3||r.tag===4}function Bm(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||_m(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;)Fm(r,a,l),l=l.sibling}function Fm(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 zm(r){var a=r.updateQueue;if(a!==null){r.updateQueue=null;var l=r.stateNode;l===null&&(l=r.stateNode=new Ej),a.forEach(function(h){var p=Bj.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));Fm(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;)Um(a,r),a=a.sibling}function Um(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&&ph(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"?bh(p,G):H==="dangerouslySetInnerHTML"?xh(p,G):H==="children"?Si(p,G):D(p,H,G,P)}switch(C){case"input":lc(p,v);break;case"textarea":vh(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&&zm(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){Km(G);continue}}X!==null?(X.return=W,te=X):Km(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=jh("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&&zm(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(_m(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=Bm(r);Dl(r,v,p);break;case 3:case 4:var j=h.stateNode.containerInfo,C=Bm(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 Ij(r,a,l){te=r,Wm(r)}function Wm(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?Gm(p):T!==null?(T.return=j,te=T):Gm(p);for(;v!==null;)te=v,Wm(v),v=v.sibling;te=p,Eo=C,ut=P}Hm(r)}else(p.subtreeFlags&8772)!==0&&v!==null?(v.return=p,te=v):Hm(r)}}function Hm(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&&Kf(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}Kf(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 Km(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 Gm(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 Rj=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:pj.transition!==null?(Do===0&&(Do=_h()),Do):(r=Re,r!==0||(r=window.event,r=r===void 0?16:Vh(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;px(r,a);var h=Kr(r,r===tt?ot:0);if(h===0)l!==null&&Oh(l),r.callbackNode=null,r.callbackPriority=0;else if(a=h&-h,r.callbackPriority!==a){if(l!=null&&Oh(l),a===1)r.tag===0?mj(qm.bind(null,r)):Mf(qm.bind(null,r)),dj(function(){(Ce&6)===0&&zn()}),l=null;else{switch(Bh(h)){case 1:l=xc;break;case 4:l=Ph;break;case 16:l=zr;break;case 536870912:l=Dh;break;default:l=zr}l=np(l,Vm.bind(null,r))}r.callbackPriority=a,r.callbackNode=l}}function Vm(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=Ym();(tt!==r||ot!==a)&&(Nn=null,ti=qe()+500,vs(r,a));do try{Oj();break}catch(C){Qm(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&&!Mj(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*Rj(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?Vm.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 Mj(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,lj(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 Qm(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=ym(j);if(X!==null){X.flags&=-257,xm(X,j,C,v,a),X.mode&1&&wm(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){wm(v,P,a),Vl();break e}T=Error(n(426))}}else if(Fe&&C.mode&1){var Qe=ym(j);if(Qe!==null){(Qe.flags&65536)===0&&(Qe.flags|=256),xm(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=km(v,T,a);Hf(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=vm(v,C,a);Hf(v,V);break e}}v=v.return}while(v!==null)}Xm(l)}catch(ie){a=ie,Ye===l&&l!==null&&(Ye=l=l.return);continue}break}while(!0)}function Ym(){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=Ym();(tt!==r||ot!==a)&&(Nn=null,vs(r,a));do try{Lj();break}catch(p){Qm(r,p)}while(!0);if(ol(),Ce=l,Io.current=h,Ye!==null)throw Error(n(261));return tt=null,ot=0,Ze}function Lj(){for(;Ye!==null;)Jm(Ye)}function Oj(){for(;Ye!==null&&!ox();)Jm(Ye)}function Jm(r){var a=tp(r.alternate,r,Lt);r.memoizedProps=r.pendingProps,a===null?Xm(r):Ye=a,_l.current=null}function Xm(r){var a=r;do{var l=a.alternate;if(r=a.return,(a.flags&32768)===0){if(l=Cj(l,a,Lt),l!==null){Ye=l;return}}else{if(l=Tj(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,Pj(r,a,l,h)}finally{Ft.transition=p,Re=h}return null}function Pj(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(gx(r,v),r===tt&&(Ye=tt=null,ot=0),(l.subtreeFlags&2064)===0&&(l.flags&2064)===0||Lo||(Lo=!0,np(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,Aj(r,l),Um(l,r),nj(Vc),qr=!!Gc,Vc=Gc=null,r.current=l,Ij(l),ax(),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),dx(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=Bh(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(Dm(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 Zm(r,a,l){a=Xs(l,a),a=km(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)Zm(r,r,l);else for(;a!==null;){if(a.tag===3){Zm(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=vm(a,r,1),a=Wn(a,r,1),r=vt(),a!==null&&(Ai(a,1,r),Nt(a,r));break}}a=a.return}}function Dj(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 ep(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 _j(r){var a=r.memoizedState,l=0;a!==null&&(l=a.retryLane),ep(r,l)}function Bj(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),ep(r,l)}var tp;tp=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,$j(r,a,l);bt=(r.flags&131072)!==0}else bt=!1,Fe&&(a.flags&1048576)!==0&&Lf(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=zj(h),r=Zt(h,r),p){case 0:a=Cl(null,a,h,r,l);break e;case 1:a=Cm(null,a,h,r,l);break e;case 11:a=jm(null,a,h,r,l);break e;case 14:a=bm(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),Cm(r,a,h,p,l);case 3:e:{if(Tm(a),r===null)throw Error(n(387));h=a.pendingProps,v=a.memoizedState,p=v.element,Wf(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=Em(r,a,h,l,p);break e}else if(h!==p){p=Xs(Error(n(424)),a),a=Em(r,a,h,l,p);break e}else for(Mt=_n(a.stateNode.containerInfo.firstChild),Rt=a,Fe=!0,Xt=null,l=zf(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 Gf(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),$m(r,a),kt(r,a,j,l),a.child;case 6:return r===null&&sl(a),null;case 13:return Am(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),jm(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),bm(r,a,h,p,l);case 15:return Sm(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),pm(a,h,p),Sl(a,h,p,l),Tl(null,a,h,!0,r,l);case 19:return Rm(r,a,l);case 22:return Nm(r,a,l)}throw Error(n(156,a.tag))};function np(r,a){return Lh(r,a)}function Fj(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 Fj(r,a,l,h)}function ql(r){return r=r.prototype,!(!r||!r.isReactComponent)}function zj(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 Uj(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 Uj(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 Wj(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 sp(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 If(r,l,a)}return a}function ip(r,a,l,h,p,v,j,C,T){return r=Jl(l,h,!0,r,p,v,j,C,T),r.context=sp(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=sp(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 rp(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){rp(r,a),(r=r.alternate)&&rp(r,a)}function Hj(){return null}var op=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=Uh();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&&Kh(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 ap(){}function Kj(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=ip(a,h,r,0,null,!1,!1,"",ap);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,"",ap);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=Kj(l,a,r,p,h);return Uo(j)}Fh=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)}},zh=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)}},Uh=function(){return Re},Wh=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":vh(r,l);break;case"select":a=l.value,a!=null&&Rs(r,!!l.multiple,a,!1)}},Ch=Kl,Th=ks;var Gj={usingClientEntryPoint:!1,Events:[Vi,Us,ao,Nh,$h,Kl]},ar={findFiberByHostInstance:ls,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Vj={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=Rh(r),r===null?null:r.stateNode},findFiberByHostInstance:ar.findFiberByHostInstance||Hj,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(Vj),cn=Go}catch{}}return $t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Gj,$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 Wj(r,a,null,l)},$t.createRoot=function(r,a){if(!ed(r))throw Error(n(299));var l=!1,h="",p=op;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=Rh(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=op;if(l!=null&&(l.unstable_strictMode===!0&&(p=!0),l.identifierPrefix!==void 0&&(v=l.identifierPrefix),l.onRecoverableError!==void 0&&(j=l.onRecoverableError)),a=ip(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 pp;function Nk(){if(pp)return sd.exports;pp=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=n0(),sd.exports}var gp;function s0(){if(gp)return Vo;gp=1;var e=Nk();return Vo.createRoot=e.createRoot,Vo.hydrateRoot=e.hydrateRoot,Vo}var i0=s0(),w=vu();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}`,wu=La("map"),yu=La("hitl"),r0=e=>e==="task"||e==="execute",xu=La("plan-only");function $k(e){return/^[A-Za-z0-9_@%+=:,./-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}const o0=e=>e.map($k).join(" "),a0=/^\d+\.\d+\.\d+(-[0-9A-Za-z][0-9A-Za-z.-]*)?$/;function c0(e){return a0.test(e)?`${J.npm}@${e}`:J.npm}function Ck(e,t){return o0(["npx","-y",c0(e),...t])}const ua=["research","prototype","junction","task","execute"],rs=[...ua,"review"],Cs="plan+execute",l0=e=>e.filter(t=>!t.archived),d0=["verifying","rework","blocked"],ju=["off","checks","checks+review","checks+review+human"],Tk=e=>ju.find(t=>t===e);function gi(e){return e.type==="junction"||e.type==="prototype"?"hitl":e.type==="research"?"afk":e.hitl?"hitl":"afk"}const u0=["task","execute"];function Ek(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,Ek(i,n,t)]))}const kp=e=>{var t;return Number(((t=/(\d+)\D*$/.exec(e.key))==null?void 0:t[1])??NaN)};function h0(e,t){const n=kp(e),i=kp(t);return n!==i&&!Number.isNaN(n)&&!Number.isNaN(i)?n-i:e.key.localeCompare(t.key)||e.id.localeCompare(t.id)}function f0(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=m0(d,t);return f?o(f):0};return o}function m0(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}},Ak=4;function p0(e){const{wishes:t,lane:n}=e,i=[...t];let o=0;for(;o<t.length;){const c=g0(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 g0(e,t){const n=e[t];if(!vp(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(!vp(d)||d.at!==n.at)break;i.push(...o,c),o=[]}return i}const vp=e=>e.at!==void 0&&e.weight<Ak;function k0(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:w0(u),weight:v0({ticket:t,chain:m}),links:d.length}}function v0(e){return e.chain?Ak:e.ticket.type==="review"?1:2}function w0(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 y0(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 x0(t)){const{lo:d,hi:u}=o(c),f=j0({wish:t[c],at:i,lane:n});i[c]=f===void 0?b0(d,u):Math.min(u,Math.max(d,f))}return i.map(c=>c??0)}function x0(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 j0(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 b0(e,t){return e>-1/0?e:t<1/0?t:0}function S0(e){const{layers:t}=e,{lane:n,across:i}=Tr[e.direction],o=T0(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?$0(k):N0(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 N0(e){const{layer:t,lane:n}=e,i=t.tickets.map(c=>k0({...e,ticket:c,layer:t.tickets})),o=y0({wishes:p0({wishes:i,lane:n}),lane:n});t.tickets.forEach((c,d)=>e.tops.set(c.id,o[d]))}function $0(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?C0(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 C0(e){return(Math.min(...e)+Math.max(...e))/2}function T0(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 E0=6;function A0(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]<=E0)return i;i[f]=Math.ceil(t[f]/(c-1))}}function wp(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=f0(e),f=[];for(const ee of c)(f[q=u(ee.id)]??(f[q]=[])).push(ee);const m=I0(Array.from(f,ee=>ee??[]),t),g=S0({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=R0({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 I0(e,t){const n=A0({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(h0):[...c].sort(M0({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 R0(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 M0(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"],yp="balanced",L0=[["*-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"]],Ik=e=>ha.includes(e),bu={research:"fast",task:"balanced",execute:"balanced",junction:"strongest",prototype:"strongest",review:"strongest"};function O0(e,t){var o,c;const n=(c=(o=t.modelMatching)==null?void 0:o.tiers)==null?void 0:c[e.type],i=bu[e.type];return t.settingsUnconfirmed&&n?ha.indexOf(n)>=ha.indexOf(i)?n:i:n??i}function xp(e){return Object.fromEntries(rs.map(t=>[t,O0({type:t},e)]))}const P0=e=>e!=="__proto__"&&e!=="constructor"&&e!=="prototype",D0=64;function _0(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 B0(n)}function B0(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 F0({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 z0(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]=F0({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 Rk(e,t,n){const i=_0(e,n.segments);if(i.filter(c=>c.kind!=="char").length>D0)return!1;let o=new Uint8Array(t.length+1);o[t.length]=1;for(let c=i.length-1;c>=0;c--)o=z0(i[c],o,t);return o[0]===1}function jp(e,t){return Rk(e.trim().toLowerCase(),t.trim().toLowerCase(),{segments:!1})}function U0(e,t={}){const n=e==null?void 0:e.trim();if(!n)return{tier:yp,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])=>jp(d,n));if(o)return{tier:o[1],model:n,source:"project",reason:`${n} is ${o[1]} in models.json`};const c=L0.find(([d])=>jp(d,n));return c?{tier:c[1],model:n,source:"built-in",reason:`${n} is a ${c[1]} model`}:{tier:yp,model:n,source:"unknown",reason:`${n} is not a known model, so it counts as balanced`}}const W0=["holding","challenged","invalidated","confirmed"],H0=e=>W0.includes(e),K0=J.labelPrefix,Bd=" -->",G0=7e4,Mk=e=>`<!-- ${K0}:${e} `,V0=e=>JSON.stringify(e).replace(/--/g,"-\\u002d"),q0=(e,t)=>`${Mk(e)}${t}${Bd}`;function Q0(e,t){const n=e.trimEnd();if(!n.endsWith(Bd))return;const i=Mk(t),o=n.lastIndexOf(i);if(!(o===-1||n.length-o>G0))return{before:n.slice(0,o),payload:n.slice(o+i.length,-Bd.length)}}const Y0=/[\u0000-\u001f\u007f-\u009f\u2028\u2029\u200b\u2060\ufeff\u202a-\u202e\u2066-\u2069]/,J0=/[\u0000-\u001f\u007f-\u009f\u2028\u2029\u200b\u2060\ufeff\u202a-\u202e\u2066-\u2069]+/g,X0=/\r\n|[\r\u0085\u2028\u2029]/g,Z0=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u0084\u0086-\u009f\u200b\u2060\ufeff\u202a-\u202e\u2066-\u2069]/g,eb=e=>Y0.test(e),js=e=>e.replace(J0," ").trim(),tb=e=>e.replace(X0,`
41
+ `).replace(Z0,"");function Oa(e,t){const n=new RegExp(`^\\\\*(?:${t})`);return tb(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 Lk=J.labelPrefix,nb=new RegExp(`<(\\\\*)!--(?=\\s*${Lk}:)`,"g"),sb=new RegExp(`<\\\\(\\\\*)!--(?=\\s*${Lk}:)`,"g"),Pa=e=>e.replace(nb,"<\\$1!--"),ai=e=>e.replace(sb,"<$1!--"),Ok="asm",ib=/^-\s+(?:\[([a-z]+)\]\s+)?/,rb=1e3;function ob(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,rb)}}:{},...e.decidedBy?{decidedBy:e.decidedBy}:{}};return`- [${e.status}] ${Pa(js(e.text))} ${q0(Ok,V0(t))}`}function ab(e){const t=e.map(cb);let n=Math.max(0,...t.map(i=>db(i.id)))+1;return t.map(i=>i.id?i:{...i,id:`S-${n++}`})}function cb(e){const t=Q0(e,Ok),n=t?t.before:e,i=n.match(ib),o=i==null?void 0:i[1],c=ai(n.slice(i?i[0].length:0).trim()),d=lb(t==null?void 0:t.payload);return{id:d.id??"",text:c,status:H0(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 lb(e){if(!e)return{};try{const t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}function db(e){const t=e==null?void 0:e.match(/^S-(\d+)$/);return t?Number(t[1]):0}const Pk=[["destination","Destination"],["notes","Notes"],["assumptions","Assumptions"],["decisions","Decisions so far"],["unspecified","Not yet specified"],["outOfScope","Out of scope"]],ub=Object.fromEntries(Pk),Dk="##\\s",bp=e=>Pa(Oa(e.trim(),Dk)),Sp=e=>fa(ai(e),Dk),Np=e=>Pa(js(e)),hb=/^-\s+(?:\[?([#A-Z0-9-]+)\]?:?\s+)?(.*)$/;function fb(e){var i;const t=o=>o.length?o.map(c=>`- ${Np(c)}`).join(`
46
+ `):"_None yet._",n=o=>o.length?o.map(c=>`- ${c.ticketKey?`${js(c.ticketKey)}: `:""}${Np(c.text)}`).join(`
47
+ `):"_None yet._";return[`## Destination
48
+
49
+ ${bp(e.destination)}`,`## Notes
50
+
51
+ ${bp(e.notes)||"_None yet._"}`,...(i=e.assumptions)!=null&&i.length?[`## Assumptions
52
+
53
+ ${e.assumptions.map(ob).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 mb(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=Pk.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=Sp(u):f==="notes"?t.notes=m?"":Sp(u):f==="assumptions"?t.assumptions=ab(g):f==="decisions"?t.decisions=g.map(k=>{const y=k.match(hb);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 Su(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"]},pb=(e,t)=>`${e[0].toUpperCase()}${e.slice(1)} ${t}/${Da[e].length}`;class Me extends Error{}async function gb(e,t,n={}){var g,k,y;const{destination:i,notes:o,assumptions:c}=t.sections,d=Su({destination:i,notes:o,assumptions:c==null?void 0:c.map(b=>b.text)});if(d)throw new Me(d);const u=kb(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 kb(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 _k(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 vb{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 wb={frontier:"ready",blocked:"backlog",parked:"backlog",claimed:"working",verifying:"verifying",rework:"rework",held:"blocked",decided:"done","out-of-scope":"cancelled"};function yb(e,t,n=Cs){return wb[Ek(e,t,n)]}const xb=["backlog","ready","working","verifying","rework","blocked"],dr=["agent","trail lead"],jb=[{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:xb,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"]}],bb=e=>jb.find(t=>t.event===e),Sb=new vb;function Nb(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 $b(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 Sb.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=yb(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=bb(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=Nb(u,c,i.to);await $b(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 $p(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`);_k(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 Cb(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 Bk=e=>e==="lookout",Tb=e=>e.via==="chat"?`in ${e.chatOf??"an agent"}'s chat`:void 0;function Eb(e){return e.via?e.via==="chat"&&e.chatOf?{via:e.via,chatOf:e.chatOf}:{via:e.via}:{}}function Fk(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||Bk(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(Fk(i,n))}async function Ab(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&&!Bk(c)&&((d=i.risk)==null?void 0:d.level)==="high")throw new Me(Fk(i.id,c))}async function Nu(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 Ib(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 Ab({...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 Rb(e,t,n){await e.setMapMode(t,n)}function zk(e){return e==="plan-only"?ua.filter(t=>t!=="execute"):ua}function Mb(e,t){if(!zk(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),Lb=e=>e in ts,Uk=" (unverified, from text)";function jr(e){return e.derived||e.decidedBy.endsWith(Uk)?"unverified":e.postedBy?"teammate":e.source.kind==="agent"&&e.decidedBy!=="trail lead"&&!e.decidedBy.startsWith("slack:")?"agent":"human"}const Wk=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 Ob(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 Pb=e=>Number(e.replace(/\D/g,""))||0;function Db(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 _b(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 Nu(e,t,Bb(c,i),{trailLine:i.trailLine,guard:i.guard}),c}function Bb(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 Fb(e,t,n,i){const o=await e.loadMap(t);if(_k(o.map),!o.map.sections.unspecified.includes(n))throw new Me(`"${n}" is not in Not yet specified`);Mb(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 zb(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 Nu(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 Ub(e,t,n,i){n&&Wb(n),await e.setMapMeta(t,{modelMatching:n&&Hb(n),confirm:!0})}function Wb(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(!Ik(n))throw new Me(`"${t}" must be fast, balanced or strongest`)}}function Hb(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 Kb(e,t,n,i){await e.setMapArchived(t,n)}const Hk=Object.freeze({research:["architect"],junction:["architect"],prototype:["architect"],task:["qa","security"],execute:["qa","security"],review:["reviewer"]}),Gb=(e,t)=>e.guidesByType?"trail":t?"team":"defaults";function $u(e){var c;const t=(c=e.guides)!=null&&c.length?new Set(e.guides):void 0,n=e.guidesByType??Hk,i=d=>!!e.guidesByType||!t||t.has(d);return{byType:Object.fromEntries(rs.map(d=>[d,[...new Set((n[d]??[]).filter(i))]])),source:Gb(e,!!t)}}const Kk=e=>[...new Set([...e.guide?[e.guide]:[],...e.guidesAdded??[]])];function Vb(e,t){const n=new Set(t.guidesRemoved??[]),i=$u(e).byType[t.type]??[],o=i.map(c=>({id:c,via:"type"}));for(const c of Kk(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 Qb=["off","observe","enforce"],Gk=["check-guard","independent-review","diff-rules","flaky"],Vk={"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:{...Vk},rules:[],github:{enabled:"auto",requiredChecks:[],pollSec:60}};new Set(Object.keys(qk));function Yb(e,t){var n;return e?((n=e.gates)==null?void 0:n[t])??Vk[t]:"off"}const Jb=e=>e?`on ${e.slice(0,7)}`:"on the same code",Xb=e=>`${e.name}${e.test?` (${e.test})`:""} ${e.failure==="timed out"?"timed out":"failed"} in ${e.failedIn}, then passed ${Jb(e.head)} with no change`,Zb=e=>e.map(Xb).join("; "),Cu=e=>{var t;return(e==null?void 0:e.result)==="pass"&&((t=e.flaky)==null?void 0:t.mode)==="enforce"},eS=3;function tS(e){const t=e.slice(0,eS).map(i=>i.text),n=e.length-t.length;return`${t.join("; ")}${n>0?`; and ${n} more`:""}`}const nS=2*6e4,od=e=>e<6e4?`${Math.round(e/1e3)}s`:`${Math.round(e/6e4)}m`;function sS(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+nS?{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 iS=0;const oa=(e="id")=>`${e}_${Date.now().toString(36)}${(iS++).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)}:{}}),Qk=(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 rS(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:pb(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=Qk(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 oS{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=Eb(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=Qk(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=rS(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 aS(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 ${wu}`};case"map.updated":return{source:"tracker",level:"info",text:`Trail updated${e.section?` · ${ub[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 cS=new Set(["createMap","setMapMode","setMapArchived","setMapMeta","updateMapSections","createTicket","addBlocking","removeBlocking","editTicket","reopen","assign","comment","close","setMeta","createDecision","markSuperseded"]),lS=5*6e4;function dS(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-lS;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:cS.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 Yk(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 uS(e){const t=Yk(e);return{decided:t.decided,total:t.total-t["out-of-scope"]}}function hS(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 fS(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 mS(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 Jk(e,t){return t&&e.usageByMap[t]||{inputTokens:0,outputTokens:0,costUsd:0}}const pS=e=>e.usage?e.usage.inputTokens+e.usage.outputTokens:0,Xk={"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 Zk(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`,gS=e=>e.charAt(0).toLowerCase()+e.slice(1);function Cp(e){return e.kind==="passed"?`verified together on ${e.branch??"main"} at ${e.commit.slice(0,7)}`:gS(e.reason)}function kS(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 · ${Cp(o)}`};const d=c.length===i?"none verified":`${c.length} not verified`,u=[`${ad(i)} done`,...c.length?[d]:[],Cp(o)];return{kind:"unverified",done:i,unverified:c,together:o,reason:u.join(" · ")}}function vS(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 wS(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?vS(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}${Uk}`,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 yS(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 xS(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();P0(c)&&(n[c]=d.startsWith("[")?SS(d.slice(1,-1)).map(Ep).filter(Boolean):Ep(d))}return{front:n,body:t[2]}}const jS=e=>e===""||/^[\s#&*!|>'"%@`[\]{},?:-]|[:#]\s|\s$|,|["\\[\]]/.test(e)||eb(e)||/^(true|false|null|~|\d[\d.e+-]*)$/i.test(e),bS=e=>JSON.stringify(e).replace(/[\u007f\u0085\u2028\u2029]/g,t=>`\\u${t.charCodeAt(0).toString(16).padStart(4,"0")}`),Tp=e=>jS(e)?bS(e):e;function Ep(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 SS(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 NS(e){if(!/^[\w-]+$/.test(e))throw new Error(`invalid frontmatter key: ${JSON.stringify(e)}`);return e}function Tu(e,t){return`---
81
+ ${Object.entries(e).map(([i,o])=>`${NS(i)}: ${Array.isArray(o)?`[${o.map(Tp).join(", ")}]`:Tp(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(),ev=["schema","breaking-api","auth-permissions","billing","data-deletion","product-behaviour","dependencies"],tv=["low","medium","high"],$S=e=>ev.includes(e),CS=e=>tv.includes(e);function TS(e){return e?{risk:e.level,...e.category?{risk_category:e.category}:{},risk_reason:e.reason}:{}}function ES(e){const t=ke(e.risk);if(!CS(t))return{};const n=ke(e.risk_category);return{risk:{level:t,...$S(n)?{category:n}:{},reason:ke(e.risk_reason)}}}const nv=["Question","Decision","Summary","Alternatives","Rationale","Transcript"],Eu=`## (?:${nv.join("|")})\\s*$`,sv=`${Eu}|### `,qo=e=>Oa(e.trim(),Eu),AS=e=>e.name?`${e.id}|${e.name}`:e.id,IS=e=>{const t=e.indexOf("|");return t<0?{id:e}:{id:e.slice(0,t),name:e.slice(t+1)}};function iv(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(AS),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}:{},...TS(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(),sv)}`).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 Tu(t,o)}function zd(e){const{front:t,body:n}=Fa(e),i={},o=new RegExp(`^## (${nv.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,Eu);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(),sv)}}),u=ke(t.source),f=ft(t.source_meta),m={kind:Lb(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(IS),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,...ES(t)}}function RS(e){return e.url?` · [${e.label??"link"}](${e.url})`:e.label?` · ${e.label}`:""}function MS(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}${RS(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 Ap{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,LS=14*864e5;class Ip{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()-LS;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 OS(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=PS(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 PS(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 DS(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 _S(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 BS(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=_S(DS(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 FS=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 zS(e){return e.state==="open"?"open":e.closeReason==="not_planned"?"cancelled":"done"}function rv({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=zS(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:FS(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 Rp=e=>e===void 0?"—":`$${e.toFixed(e<1?4:2)}`;function US(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 | ${Rp(e.spend.costUsd)} · ${e.spend.tokens.toLocaleString("en-US")} tokens |`,`| Cost per verified ticket | ${Rp(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 Au=5,ov=1.5,WS=15,Qo=e=>Math.round(e*100);function HS(e){const t=e.filter(d=>d.findings.raised>=Au).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)<WS?[]:[{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 KS(e){const t=c=>c.reworkCycles/c.tickets,n=e.filter(c=>c.tickets>=Au).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)*ov?[]:[{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 GS(e,t){const n=d=>d.medianLeadMs??0,i=t.filter(d=>d.done>=Au&&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)*ov?[]:[{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 VS(e){const t=Object.keys(e.byTypeAndVendor).sort();return[...HS(e.byVendor),...KS(e.byVendor),...t.flatMap(n=>GS(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)},av=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 QS(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=av(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 YS(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 cv(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,cv(i,o)]))}const Hd=(e,t)=>{const n=e.get(t)??cv(t,[]);return e.set(t,n),n};function Mp(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 lv(e){const t=e.flatMap(({snap:m,journal:g,answered:k,usage:y})=>rv({snap:m,journal:g,answered:k,usage:y}).tickets.map(b=>({ticket:b,agent:av(Wd(g,m.map.id,b.id))??YS(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 QS(m,g))Mp(i,y.reviewer,y.upheld),Mp(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:VS(f)}}const dv=["research","junction","review"],JS={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
+ `)},XS=[["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(XS),uv=["task","execute","prototype"];function ZS(e,t){const n=new Set(e.map(i=>i.source).filter(Boolean));return t.filter(i=>!n.has(i))}const eN=["architecture","convention","gotcha","dead-end","glossary","fact"],hv=["business-rule","product-decision","persona","ux-principle","pricing"],tN=[...eN,...hv],nN=e=>e.status==="confirmed"||e.status==="assumption";function sN(e,t){return Rk(e,t.replace(/^\.\//,""),{segments:!0})}const iN={"business-rule":3,convention:3,"product-decision":2,architecture:2,gotcha:2,"dead-end":2,"ux-principle":2},rN=["business-rule","ux-principle","convention"],Lp=600,oN=e=>`flagged as possibly outdated by ${e}; the human is reviewing it`,aN=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(" ")),Op=e=>new Set((e.toLowerCase().match(/[a-z0-9][a-z0-9_-]{2,}/g)??[]).filter(t=>!aN.has(t)));function fv(e,t,n=4e3,i=()=>[]){const o=t.ticket?Op(`${t.ticket.title} ${t.ticket.body}`):new Set,c=new Set((t.tags??[]).map(m=>m.toLowerCase())),d=e.filter(nN).map(m=>{const g=[];let k=iN[m.kind]??1;for(const S of m.scope){const x=t.paths.find($=>sN(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=[...Op(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&&hv.includes(m.kind)&&(k+=8,g.push("product context for discovery")),!g.length&&rN.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>Lp?`${m.body.slice(0,Lp)}…`: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:oN(m.flag.by)}:{}})}return u}const cN=new RegExp("`([^`\\s]+/[^`\\s]+)`|(?:^|[\\s(])/?((?:[\\w.-]+/)+[\\w.-]+)","gm");function mv(e){const t=new Set;for(const n of e.matchAll(cN))t.add((n[1]??n[2]).replace(/^\.?\//,"").replace(/[.,;:]+$/,""));return[...t]}const lN=[{level:"high",label:"High risk"},{level:"medium",label:"Medium risk"},{level:"low",label:"Low risk"},{level:"none",label:"No category"}];function dN(e){return lN.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 uN=1/3;function Es(e,t=Date.now()){const n=e.expiresAt-t;return n<=0?"expired":n<=e.ttlMs*uN?"stalled":"live"}function hN(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 fN=e=>e.urgency==="fyi"||e.kind==="policy"||e.kind==="escape";function mN(e){const t=e.filter(([n,i])=>rs.includes(n)&&Ik(i));return Object.fromEntries(t)}const Pp=e=>Number(e.slice(0,2))*60+Number(e.slice(3,5));function pN(e,t){const n=new Date(t),i=n.getHours()*60+n.getMinutes(),o=Pp(e.from),c=Pp(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 gN(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 kN(e,t){const n=e.focusUntil??0;if(n>t)return{kind:"manual",until:n};if(!e.focus||!pN(e.focus,t))return{kind:"off"};const i=gN(e.focus,t);return(e.focusOffUntil??0)>t?{kind:"paused",until:i}:{kind:"hours",until:i}}function vN(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=kN(i,n);return o.kind==="hours"?{...i,focusOffUntil:o.until}:i}default:return t}}const wN=e=>({id:e.id,key:e.key,title:e.title,...e.archived?{archived:!0}:{}});function yN(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 xN(e,t,n){const i=Date.now();return{id:e,key:t,...n,state:"open",blockedBy:[],comments:[],createdAt:i,updatedAt:i}}const jN=(e,t)=>({...e,blockedBy:e.blockedBy.filter(n=>n!==t)}),bN=(e,t)=>{var n;return{...e,...(n=t.title)!=null&&n.trim()?{title:t.title.trim()}:{},...t.body!==void 0?{body:t.body}:{}}};function SN(e){const{closeReason:t,closedAt:n,...i}=e;return{...i,state:"open"}}const NN=["status","verification","checks","reviewOf","guide","guidesAdded","guidesRemoved"];function $N(e,t){const n={...e};for(const i of NN)t[i]!==void 0&&(t[i]===null?delete n[i]:n[i]=t[i]);return t.confirm&&delete n.settingsUnconfirmed,n}function CN(e,t){const n={...e};return t?n.archived=!0:delete n.archived,n}async function pv(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 gv="### [^\\n]* @ \\d{4}-\\d\\d-\\d\\dT",kv=`## Comments\\s*$|${gv}`,vv=`<!-- ${J.labelPrefix}:comments -->`,TN=new RegExp(`^## Comments[ \\t]*\\n${vv}[ \\t]*$`,"m"),EN=new RegExp(`^(?=${gv})### `,"m"),Iu=2,wv=e=>Pa(Oa(e,kv)),Dp=e=>fa(ai(e),kv);function AN(e,t){const n=(t>=Iu?TN:/^## Comments\s*$/m).exec(e);return n?[e.slice(0,n.index),e.slice(n.index+n[0].length)]:[e,""]}function _p(e){const{front:t,body:n}=Fa(e),i=Number(ke(t.format))||1,[o,c]=AN(n,i),d=c.split(i>=Iu?EN:/^### /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:Dp(g.slice(y+1).trim())}}),u=ke(t.close_reason),f=d0.find(g=>g===ke(t.status)),m=Tk(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(yu)||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:Dp(o.trim()),comments:d,createdAt:ci(t.created),updatedAt:ci(t.updated),closedAt:ci(t.closed)||void 0}}function yv(e){var i,o;const t={id:e.id,format:String(Iu),title:e.title,type:e.type,labels:[La(e.type),...r0(e.type)&&e.hitl?[yu]:[]],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
+ ${vv}
118
+
119
+ ${e.comments.map(IN).join(`
120
+
121
+ `)}`:"";return Tu(t,wv(e.body)+n)}function IN(e){return`### ${js(e.author)} @ ${pn(e.createdAt)}
122
+
123
+ ${wv(e.body)}`}async function RN(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 MN(e,t,n){const i=await pv(e),o=xN(String(i),`#${i}`,n);return{path:`${t}/tickets/${o.id}.md`,text:yv({...o,updatedAt:Date.now()}),value:o}}async function LN(e,t,n){const i=(await e.list()).filter(d=>d.includes("/decisions/")),o=Math.max(0,...i.map(d=>Pb(d.split("/").pop())))+1,c=Ob(`D-${o}`,t,n);return{path:`${t}/decisions/${c.id}.md`,text:iv(c),value:c}}const ON=/^([^/]+)\/decisions\/([^/]+)\.md$/,PN=(e,t)=>e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,40)||`map-${t}`,xv=/^[A-Za-z0-9][A-Za-z0-9_-]*(?:\.[A-Za-z0-9_-]+)*$/;function xs(e){if(typeof e!="string"||e.length>128||!xv.test(e))throw new Error(`not a valid id: ${JSON.stringify(e)}`);return e}const DN=e=>{const t=e.match(/^[^/]+\/tickets\/([^/]+)\.md$/);return!!t&&xv.test(t[1])};class _N{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=>ON.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 BN(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 FN(e){if(!e)return{};const t=rs.flatMap(n=>(e[n]??[]).map(i=>`${n}=${i}`));return{[Kd]:t}}function zN(e){const t=ke(e["model-matching"]);if(t!=="on"&&t!=="off")return;const n=mN(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 UN(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 Bp(e,t){const{front:n,body:i}=Fa(t),o=Tk(ke(n.verification)),c=zN(n),d=BN(n);return{id:e,key:ke(n.key)||e,title:ke(n.title)||e,mode:ke(n.mode)==="plan-only"||ft(n.labels).includes(xu)?"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:mb(i),createdAt:ci(n.created),updatedAt:ci(n.updated)}}function WN(e){var t;return Tu({key:e.key,title:e.title,mode:e.mode,...e.verification?{verification:e.verification}:{},...(t=e.guides)!=null&&t.length?{guides:e.guides}:{},...FN(e.guidesByType),...UN(e.modelMatching),...e.archived?{archived:"true"}:{},labels:[wu,...e.mode==="plan-only"?[xu]:[]],created:pn(e.createdAt),updated:pn(e.updatedAt)},fb(e.sections))}function HN(e,t){t.code!=="ENOENT"&&console.warn(`Teamtrail: decision ${e} can't be read: ${t.message}`)}class KN{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 _N(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=>CN(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 RN(this.fs,t,n=>this.selfWrites.set(n,Date.now()))}async readMap(t){return Bp(t,await this.fs.read(`${xs(t)}/map.md`))}async writeMap(t,n){await this.put(`${xs(t.id)}/map.md`,WN(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=>wN(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/`)&&DN(d)),c=await Promise.all(o.map(async d=>_p(await this.fs.read(d))));return{map:i,tickets:c.sort((d,u)=>d.createdAt-u.createdAt)}}async createMap(t){const n=await pv(this.fs),i=PN(t.title,n),o={id:i,key:`#${n}`,title:t.title,mode:t.mode??Cs,...t.verification?{verification:t.verification}:{},sections:t.sections,createdAt:Date.now(),updatedAt:Date.now()};return await this.writeMap(o),this.events.emit({kind:"map.created",mapId:i,at:Date.now()}),o}async editMap(t,n,i){const o=await this.fs.read(`${xs(t)}/map.md`);await this.writeMap({...n(Bp(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=>yN(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(()=>MN(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=_p(o),d=i(c);d!==c&&await this.put(this.ticketPath(t,c.id),yv({...d,updatedAt:Date.now()}),o)}async removeBlocking(t,n,i){await this.update(t,i,o=>jN(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=>bN(o,i)),this.events.emit({kind:"ticket.updated",mapId:t,ticketId:n,at:Date.now()})}async reopen(t,n){await this.update(t,n,SN),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=>$N(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=>HN(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 LN(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=iv({...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 Fp extends Error{constructor(t,n,i,o){super(n),this.code=t,this.status=i,this.resetAt=o,this.name="TrackerError"}}const GN={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 Fp("offline","Lookout server unreachable; is `teamtrail` still running?")}const o=await i.json().catch(()=>({}));if(!i.ok)throw new Fp(o.code??"http",o.error??`request failed (${i.status})`,i.status,o.resetAt);return o}class VN{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=GN[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 qN(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 QN=[{id:"markdown",name:"Local markdown",status:"available"},{id:"github",name:"GitHub Issues",status:"available"},{id:"linear",name:"Linear",status:"available"}],jv=[{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"}],YN=jv[0],JN="https://github.com/teamtrailhq/teamtrail-guides",XN="https://raw.githubusercontent.com/teamtrailhq/teamtrail-guides/main",ZN=`${JN}/blob/main/CONTRIBUTING.md`,e1=e=>e.slice(0,9),t1=/[a-z][\w+.-]*:\/\/(?!(localhost|127\.0\.0\.1)(:\d+)?(\/|$|\s))/i,n1=/^[\w.-]+@[\w.-]+:/,s1=/^(@[\w.-]+\/)?[\w./-]+@[\w^~<>=*.-]+$/,i1=/(^|=)(npm|jsr|github|gitlab|bitbucket|git\+[a-z]+|https?):/i,r1=/^--?(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,o1={tar:/^-[A-Za-z]*[IF]/,zip:/^-TT|^--unzip-command/,make:/^-E|^--eval/,perl:/^-[A-Za-z]*M/};function a1(e,t){var n;if(t1.test(t)||n1.test(t))return"names a remote address, so it reaches the network";if(s1.test(t)&&!t.startsWith("-"))return`names a package to download (${t})`;if(i1.test(t))return`names a package from a registry (${t})`;if(r1.test(t))return`runs a command it's given (${t.split("=")[0]})`;if((n=o1[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(c1.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 c1=/\|\s*(sh|bash|zsh|dash|ksh|fish|pwsh|node|python\d*|perl|ruby)\b|\$\(|`|;|&&|\|\||\b(curl|wget)\s/;function l1(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 d1(e,t){const n=l1(e,t);if(n)return n;for(const i of t){const o=a1(e,i);if(o)return o}}const u1=/^(-c|-e|-E|-ex|-x|-r|-command|-Command|-EncodedCommand)$|^--(eval|exec|command|expr|execute|run)(=|$)/,h1=/(^|[\s|'"=])[a-z0-9-]+(\.[a-z0-9-]+)*\.[a-z]{2,}(:\d+)?\/\S*/i;function f1(e,t){const n=e.find(i=>{var o;return u1.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=>h1.test(i)))return"names an address, so it may reach the network"}const m1=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"]),p1=new Set(["-C","--git-dir","--work-tree","--namespace","--super-prefix"]);function g1(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(p1.has(i)){n.includes("=")||t++;continue}if(n.startsWith("-"))continue;const o=n.toLowerCase();return m1.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 k1=["--require","--import","--loader","--experimental-loader","--env-file","--input-type"],zp={inline:"ep",value:"rC",long:["--eval","--print"],longValue:k1},v1={node:zp,nodejs:zp,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 w1(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 y1(e,t){var o;if(/^data:|=data:/i.test(e))return"code";if(!e.startsWith("--"))return w1(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 x1(e,t){const n=v1[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=y1(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 Up=e=>new RegExp(`^(?![-/~\\\\])(?!.*\\.\\.)(?![a-zA-Z]:)[\\w./-]+\\.(${e})$`),Ut={},ht=e=>e.split(/\s+/).filter(Boolean),j1={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:Up("[cm]?[jt]s"),sub:["--test"]},python:{script:Up("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"]}},b1=/^(\.\/)?node_modules\/\.bin\/([\w.-]+)$/;function S1(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 bv(e){var i;const t=(i=b1.exec(e.argv0))==null?void 0:i[2],n=j1[t??e.program];return n&&S1(n,e.args)?n:void 0}const N1=e=>!!bv(e),za=e=>new Set(e.split(/\s+/).filter(Boolean)),$1=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
+ `),C1=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
+ `),T1=za("npx pnpx bunx uvx uv pipx docker podman nix nix-shell nix-env flatpak snap"),E1=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"],A1={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 I1(e){const t=(e.split(/[\\/]/).pop()??"").toLowerCase().replace(/\.(exe|cmd|bat|com)$/,"");return t.replace(new RegExp("(?<=[a-z])[\\d.-]+$"),"")||t}const R1=e=>{var t;return((t=e.find(n=>!n.startsWith("-")))==null?void 0:t.toLowerCase())??""};function Wp(e){const t=e.findIndex(n=>n.startsWith("-m"));if(!(t<0))return e[t]==="-m"?e[t+1]:e[t].slice(2)}const M1=new Set(["pip","ensurepip","pipx","uv","venv","http.server","webbrowser"]);function L1(e,t){var i;if($1.has(e))return`runs a shell (${e}); name the program and its arguments instead`;if(C1.has(e))return`runs ${e}, which reaches the network`;if(T1.has(e))return`runs ${e}, which downloads and runs a package; use one installed in the repo`;if(E1.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=R1(t);if((i=A1[e])!=null&&i.has(n))return`runs ${e} ${n}, which downloads packages; use one installed in the repo`;if(e==="python"&&M1.has(Wp(t)??""))return`runs python -m ${Wp(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 Sv(e){const t=e.run[0]??"";return{argv0:t,program:I1(t),args:e.run.slice(1)}}function O1(e){const{argv0:t,program:n,args:i}=Sv(e),o=bv({argv0:t,program:n,args:i}),c=[L1(n,i),x1(n,i),n==="git"?g1(i):void 0,d1(n,i),f1(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 P1="unknown program: Teamtrail can't tell what this runs";function D1(e){if(O1(e).length)return;const{argv0:t,program:n,args:i}=Sv(e);return N1({argv0:t,program:n,args:i})?void 0:P1}function _1(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 B1="unknown model",F1=e=>`${Math.round(e.firstTimeRate*100)}%`,Hp=(e,t)=>`${e.model} passes ${F1(e)} of your ${t} tickets first time (${e.tickets} tickets)`;function z1(e,t){return t.firstTimeRate-e.firstTimeRate||(e.costPerVerifiedUsd??1/0)-(t.costPerVerifiedUsd??1/0)||e.key.localeCompare(t.key)}function U1(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!==B1).sort(z1);if(i.length<2||i[0].firstTimeRate===i[1].firstTimeRate)return[];const o=i[0],c=U0(o.model,e.models).tier,d=e.tiers[n];if(!d||c===d)return[];const u=`${Hp(o,n)}; ${Hp(i[1],n)}`;return[{type:n,current:d,tier:c,model:o.model??"",because:u}]})}const aa=e=>`${Math.round(e*100)}%`,W1=e=>e===void 0?"–":`$${e.toFixed(2)}`,Ru=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=>[`| ${Ru(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??"–",`${W1(n.costPerVerifiedUsd)} |`].join(" | "))]}function H1(e){return["| Check | Verified tickets it passed | Came back |","| --- | ---: | ---: |",...e.map(t=>`| ${Ru(t.key)}${t.enough?"":" (too few)"} | ${t.verified} | ${aa(t.escapeRate)} (${t.escaped}) |`)]}function K1(e,t="Agent scorecard"){var n,i;return[`## ${Ru(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)?["",...H1(e.byCheck)]:[]].join(`
134
+ `)}const ud="No area yet";function G1(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 Kp({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 Gp({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 V1(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 Gp(hd,t)+Gp(fd,t);const[n,i]=e==="aside"?[4,-5]:[0,0];return Kp(hd,n,i,t)+Kp(fd,n,i,t)}function q1(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 Q1({eyes:e,mouth:t},n){return V1(e,n)+q1(t,n)}function Y1(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 J1(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 X1({face:e,lamp:t,lit:n,simple:i,c:o}){const c=Y1(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}"/>`,J1(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 Z1={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"},Nv={on:"#ffb347",dim:"#a8501c",alert:"#ff5a48"},e$={on:"#ffd166",dim:"#a8501c",alert:"#ff5a48"},t$={circle:100,rounded:46,square:0},n$=.94;let s$=0;function i$(e,{lamp:t=Nv,simple:n=!1,shape:i="circle",colors:o=Z1}={}){const c=o,d=e.light??"on",u=i==="circle"?n$:1,f=100*(1-u),m=`scout-clip-${++s$}`,g=X1({face:Q1(e,c),lamp:t[d],lit:d!=="dim",simple:n,c});return[`<defs><clipPath id="${m}"><rect width="200" height="200" rx="${t$[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})">${G1(c)}${g}</g>`,"</g>"].join("")}const $v={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:Nv,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:e$,wave:{bar:"#66828d",lead:"#e8833a"}}},r$="crt",o$={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"}},a$={idle:"WATCHING",speaking:"TALKING",alert:"NEEDS YOU",thinking:"THINKING"},Cn={msPerChar:55,mouthHoldMs:110,blinkEveryMs:5600,blinkMs:140,thinkingStepMs:520};function c$(e){return e?/[aeiouy]/i.test(e)?"open":/[a-z0-9]/i.test(e)?"mid":"rest":"rest"}function l$(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 d$(e,t,n){return Array.from({length:n},(i,o)=>{const c=t-(n-1-o);return c>=0&&c<e.length?l$(e[c],c):0})}function Cv({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(()=>i$({eyes:d,mouth:u,light:f},{lamp:$v[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 u$(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 h$={xs:.8,sm:2,md:4,lg:6},f$=40,Vp=20,qp="(prefers-reduced-motion: reduce)",m$=40,p$=350;function g$(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 k$=e=>e.length*Cn.msPerChar,v$=(e,t)=>t&&(e.effective==="idle"||e.effective==="speaking"||e.effective==="alert");function w$(e,t,n,i){const o=o$[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=c$(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 y$(e,t){const n=typeof e.size=="number"?e.size:h$[e.size],i=e.reduced?Math.min(e.text.length-1,Vp-1):t;return{base:n,px:f$*n,bars:Vp,waveCursor:i}}function x$(e,{label:t,speechDone:n,cursor:i,caption:o}){const c=e.talking&&n?"idle":e.effective,d=a$[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:j$(e,n,i)}}function j$(e,t,n){return e.talking?e.reduced||t?e.text:e.text.slice(0,n+1):""}function b$(){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 S$(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 N$(e){const{key:t,talking:n,at:i}=e,o=i!==void 0,c=k$(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+p$);return()=>clearTimeout(b)},[n,t,c,o]);const m=n&&d!==t,g=S$(t,e.animate&&(m||e.thinking),m?m$:Cn.thinkingStepMs),k=i??g,y=n&&(o?k>=c:d===t);return{t:k,speechDone:y}}const $$=e=>e*2,Gd=3.5;function C$(e,t,n){return(e??[]).map((i,o)=>{const c=(1+2*i)*.5;return{x:o*2,y:(Gd-c)/2,width:1,height:c,fill:o>=t-2&&i>0?n.lead:n.bar}})}function T$({heights:e,bars:t,unit:n,colors:i}){const o=$$(t);return s.jsx("svg",{className:`scout-wave${e?" on":""}`,width:o*n,height:Gd*n,viewBox:`0 0 ${o} ${Gd}`,"aria-hidden":"true",children:C$(e,t,i).map((c,d)=>s.jsx("rect",{...c},d))})}function Ua({state:e="idle",size:t="md",speaking:n,variant:i=r$,framed:o,caption:c,label:d="Scout",onSpeakEnd:u,at:f,className:m,style:g}){const k=g$({state:e,size:t,speaking:n,framed:o},b$()),{text:y,effective:b,talking:S,reduced:x}=k,$=$v[i],O=!x&&!(f!==void 0),D=`${b}|${i}|${y}`,{t:F,speechDone:K}=N$({key:D,text:y,talking:S,thinking:b==="thinking",animate:O,at:f,onSpeakEnd:u}),I=u$(v$(k,O)),Q=S&&!K,{eyes:Z,mouth:q,light:ee,cursor:Se}=w$(k,F,I,Q),{base:ve,px:be,bars:ae,waveCursor:Ie}=y$(k,Se),we=w.useMemo(()=>Q?d$(y,Ie,ae):null,[Q,y,Ie,ae]),{shownState:Ne,status:z,ariaLabel:Y,showCaption:U,shown:E}=x$(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(Cv,{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(T$,{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 E$({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",()=>$p(e.adapter,i.current,f,{...u,assignee:wt})),release:f=>t("Release claim",()=>Cb(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 $p(e.adapter,i.current,f,{...u,assignee:wt}),await _b(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 Nu(e.adapter,f.mapId,x,{appendToTrail:!1})).id}await Ib(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 Fb(e.adapter,i.current,f,m);d({kind:"ticket",id:g.id})}),ruleOut:(f,m)=>t("Rule out of scope",async()=>{await zb(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 Kb(e.adapter,i.current,f),f&&n(void 0)}),setMode:f=>t(`Trail mode · ${f}`,()=>Rb(e.adapter,i.current,f)),setModelMatching:f=>t(`Model matching · ${f.enabled?"on":"off"}`,()=>Ub(e.adapter,i.current,f))}}const ue=(...e)=>e.filter(Boolean).join(" "),$s="item",A$=/^[0-9a-f]{6,64}$/;function Ar(){const e=new URLSearchParams(location.search).get("project")??void 0;return e&&A$.test(e)?e:void 0}function re(e=Ar()){return e?`${J.apiPrefix}/p/${e}`:J.apiPrefix}function I$(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 R$(){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 M$(e,t){var d;const n=(t.assumptions??[]).map((u,f)=>({id:`S-${f+1}`,text:u,status:"holding",tickets:[]})),i=await R$(),{map:o,tickets:c}=await gb(e,{title:t.title,...i?{verification:i}:{},sections:{destination:t.destination,notes:t.notes,decisions:[],unspecified:[],outOfScope:[],...n.length?{assumptions:n}:{}},tickets:[{ref:"discovery",...JS}]});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 Tv(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 Ev(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),Mu=e=>new Date(e).toTimeString().slice(0,5),L$=e=>`${fi(e)} ${Mu(e)}`,Av=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"},Iv={decided:"done",claimed:"working",frontier:"ready",blocked:"backlog",parked:"parked","out-of-scope":"cancelled",verifying:"verifying",rework:"rework",held:"blocked"};function Lu(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 O$=8,P$=40;function D$(e,t){try{return new URL(e,t).origin===t}catch{return!1}}function Rv(e,t){if(!Array.isArray(e))return[];const n=[];for(const i of e.slice(0,O$)){const{label:o,href:c}=i??{};if(typeof o!="string"||typeof c!="string")continue;const d=o.trim();!d||d.length>P$||!D$(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 _$=["auto","day","night"];function B$(e){const[t]=Rv(e?[e]:[],location.origin);return t?{agents:t}:{}}const Ga=e=>typeof e=="string"&&/^\/[\w/-]{1,100}$/.test(e)?e:void 0;function F$(e){const t=Ga(e);return t?{themeSave:t}:{}}function z$(e){const t=Ga(e);return t?{trailAgents:t}:{}}function U$(e){const t=Ga(e);return t?{setup:t}:{}}function W$(e){const t=Ga(e);return t?{merge:t}:{}}function H$(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 Vd;const pt=()=>Vd;function K$(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=Rv(t.pages,location.origin),o=_$.find(c=>c===t.theme);return Vd={name:t.name,pages:i,...n?{signOut:t.signOut}:{},...o?{theme:o}:{},...F$(t.themeSave),...W$(t.merge),...U$(t.setup),...z$(t.trailAgents),...t.highRisk===!1?{highRisk:!1}:{},...H$(t.home),...t.tracker==="markdown"?{tracker:"markdown"}:{},...B$(t.agents)},o&&Ka(o),Vd}const G$=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 V$(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 q$(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)+G$[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=V$(e),i=new DataView(n.buffer),o=new Uint32Array(64);for(let u=0;u<n.length;u+=64)q$(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 Q$(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 Mv=e=>Array.from(e,t=>t.toString(16).padStart(2,"0")).join(""),Y$=e=>new Uint8Array((e.match(/../g)??[]).map(t=>parseInt(t,16))),Ou=`${J.slug}.session`;let ka;const J$=e=>{const t=e;return!!t&&typeof t.id=="string"&&typeof t.secret=="string"&&typeof t.verifier=="string"};function Pu(){try{const e=JSON.parse(localStorage.getItem(Ou)??"null");return J$(e)?e:ka}catch{return ka}}function X$(e){ka=e;try{localStorage.setItem(Ou,JSON.stringify(e))}catch{}}function Lv(){ka=void 0;try{localStorage.removeItem(Ou)}catch{}}let Du="unproven",pd;const qd=new Set,Ov=e=>{Du=e;for(const t of qd)t(e)};function Z$(e){return qd.add(e),()=>void qd.delete(e)}const eC=()=>Du==="proven",tC=()=>Du==="proven"&&Ov("unproven");function nC(){const e=new Uint8Array(16);return crypto.getRandomValues(e),Mv(e)}async function sC(){const e=Pu();if(!e)return"unknown";const t=nC(),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 Lv(),"unknown";const i=n!=null&&n.ok?(await n.json().catch(()=>({}))).proof:void 0,o=Mv(Q$(Y$(e.verifier),new TextEncoder().encode(`${t}
135
+ ${location.origin}`)));return i===o?"proven":"failed"}function Va(){return pd??(pd=sC().then(e=>(pd=void 0,Ov(e),e))),pd}const iC=1e4;class Pv{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(),tC(),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,iC))}}function rC(){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 Dv(e){Kt==null||Kt.addEventListener(e,t=>{for(const n of br.get(e)??[])n(t.data)})}function qa(){if(!Kt){Kt=new Pv,Kt.onerror=()=>{for(const e of ya)e();rC()},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())Dv(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),Dv(e)),n.add(t),qa(),()=>{n.delete(t),Qa()}}function as(e){return wa.add(e),qa(),()=>{wa.delete(e),Qa()}}function oC(e){return ya.add(e),qa(),()=>{ya.delete(e),Qa()}}const _u=(e,t)=>`${e}/${t}`;let on={reached:!1,live:!1,tickets:{}},Qd=!1;const Yd=new Set,Jd=new Set,aC=ki();let Xd=0;const _v=new Map;let Bv=0;function xa(e){on=e;for(const t of Yd)t()}function cC(e,t){const n=Object.fromEntries(e.map(i=>[_u(i.mapId,i.ticketId),i]));for(const[i,o]of _v)o>t&&on.tickets[i]&&(n[i]=on.tickets[i]);return n}function Qp(){const e=aC.start(),t=Xd;fetch(`${re()}/verification/sync`).then(n=>n.ok?n.json():Promise.reject()).then(n=>e()&&xa({reached:!0,live:!0,status:Bv>t?on.status:n.status,tickets:cC(n.tickets,t)}),()=>on.reached&&xa({...on,live:!1}))}function lC(e){const t=JSON.parse(e);if(t.kind==="evidence")for(const o of Jd)o();if(t.kind!=="sync")return;const n=t;Bv=++Xd;const i={...on.tickets};for(const o of n.tickets){const c=_u(o.mapId,o.ticketId);i[c]=o,_v.set(c,Xd)}xa({reached:!0,live:!0,status:n.status,tickets:i})}function Yp(){Qd=!0,vi("verification",lC),oC(()=>on.reached&&on.live&&xa({...on,live:!1})),as(Qp),Qp()}const ss={subscribe(e){return Qd||Yp(),Yd.add(e),()=>void Yd.delete(e)},get:()=>on,onEvidence(e){return Qd||Yp(),Jd.add(e),()=>void Jd.delete(e)},ticket:(e,t,n)=>e.tickets[_u(t,n)]};function dC(e){if(e!=null&&e.flags.length)return e.flags.some(t=>t.severity==="alert")?"alert":"warn"}const Jp={onboarded:!1,tracker:"markdown",hitlTranscript:"summary",agent:YN.id,github:{repo:""},linear:{team:""},briefing:{enabled:!0,awayMinutes:15},theme:"night"};function Bu(){try{const e={...Jp,...JSON.parse(localStorage.getItem(Ma)??"{}")};return["markdown","github","linear"].includes(e.tracker)||(e.tracker="markdown"),e}catch{return Jp}}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 uC={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)}},hC=15*6e4;class fC{constructor(t){oe(this,"leases",[]);oe(this,"changes",new ui);oe(this,"logged",new Set);oe(this,"since",Date.now()-hC);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:hN(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 mC(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 pC(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 gC(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 Xp(e,t){mC(e),pC(t),gC(e)}function Zp(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 kC=["markdown","github","linear"];function vC(){const e=new URLSearchParams(location.search).get("tracker");return e&&kC.includes(e)?e:Bu().tracker}function wC(e){let t,n;const i=new oS,o=new fC(i),c={},d=qb(re());if(e==="github"||e==="linear"){const m=new VN(e,re());m.openEvents=g=>new Pv(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=Zp(`${e}:${m.location}`);c.presence=new Ap(k),i.ledger=new Ip(k),Xp(i,o)})}else t=new KN(uC,`./${J.dataDir}`),n=fetch(`${re()}/list`).then(m=>m.json()).catch(()=>({root:"default"})).then(({root:m})=>{const g=Zp(m);c.presence=new Ap(g),i.ledger=new Ip(g),Xp(i,o)});const u=dS(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",yC=e=>gn(e)&&!!e.waitingOn,xC={blocking:0,soon:1,fyi:2};function jC(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=>xC[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"},bC=e=>/^\d{8}$/.test(e)||e==="latest",SC=e=>/^\d{1,2}$/.test(e);function NC(e){const t=e.find(i=>ca[i]);if(!t)return;const n=e.filter(SC).join(".");return n?`${ca[t]} ${n}`:ca[t]}function $C(e){const[,t,...n]=e,i=n.filter(o=>!bC(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")?NC(n)??t:n[0]==="gpt"?$C(n):t.replace(/[-_](\d{8}|latest)$/,"")}const CC=/^slack:([A-Z0-9]+)$/i;function mi(e,t){var c;const n=(c=CC.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 Fu(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 zu({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 TC=6,EC=2e4,AC=/[\\`*_{}[\]()#+\-.!~<>|]/,eg=/https?:\/\/[^\s<>]+/y,IC=/[.,;:!?'")\]]+$/,RC=1e3;function Ir(e,t={depth:0,inLink:!1}){if(e.length>EC||t.depth>TC)return[{kind:"text",text:e}];const n=[];let i="",o=0;for(;o<e.length;){const c=MC(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 MC(e,t,n){switch(e[t]){case"\\":return LC(e,t);case`
136
+ `:return{nodes:[{kind:"break"}],next:t+1};case"`":return OC(e,t);case"*":case"_":return PC(e,t,n);case"~":return e[t+1]==="~"?Fv({text:e,i:t,ctx:n,size:2}):void 0;case"!":return e[t+1]==="["?BC(e,t,n):void 0;case"[":return _C(e,t,n);case"<":return FC(e,t,n);case"h":return zC(e,t,n);default:return}}function LC(e,t){const n=e[t+1];return n===`
137
+ `?{nodes:[{kind:"break"}],next:t+2}:n&&AC.test(n)?{text:n,next:t+2}:void 0}function OC(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 PC(e,t,n){const i=e[t];if(i==="_"&&/\w/.test(e[t-1]??""))return;const o=e[t+1]===i?2:1;return Fv({text:e,i:t,ctx:n,size:o})}function Fv(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=DC({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 DC(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 _C(e,t,n){const i=zv(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 BC(e,t,n){const i=zv(e,t+1);if(i)return{nodes:Ir(i.label,{depth:n.depth+1,inLink:!0}),next:i.next}}function zv(e,t){const n=tg({text:e,i:t,open:"[",shut:"]"});if(n<0||e[n+1]!=="(")return;const i=tg({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 tg(e){const{text:t,open:n,shut:i}=e;let o=0;const c=Math.min(t.length,e.i+RC);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 FC(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 zC(e,t,n){var c;if(n.inLink||/[^\s(]/.test(e[t-1]??" "))return;eg.lastIndex=t;const i=(c=eg.exec(e))==null?void 0:c[0].replace(IC,""),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 Uu=/^ {0,3}(`{3,}|~{3,})/,Uv=/^ {0,3}(#{1,6})(?:\s+(.*?))?\s*#*\s*$/,Wu=/^ {0,3}([-*_])(?:\s*\1){2,}\s*$/,ja=/^ {0,3}>\s?/,UC=/^( {0,3})([-*+]|\d{1,9}[.)])(\s+|$)/,WC=6;function Wv(e){const t=e.replace(/\r\n?/g,`
138
+ `).replace(/\t/g," ").split(`
139
+ `);return Hu(t,0)}function Hu(e,t){const n=[];let i=0;for(;i<e.length;){if(!e[i].trim()){i++;continue}const o=HC(e,i,t);n.push(o.block),i=o.next}return n}function HC(e,t,n){const i=e[t];if(Uu.test(i))return KC(e,t);const o=i.match(Uv);if(o)return{block:{kind:"heading",level:o[1].length,text:o[2]??""},next:t+1};if(Wu.test(i))return{block:{kind:"rule"},next:t+1};const c=n<WC;if(c&&ja.test(i))return GC(e,t,n);const d=c?Ja(i):void 0;return d?qC({lines:e,i:t,depth:n,first:d}):VC(e,t)}function KC(e,t){const n=e[t].match(Uu)[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 GC(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:Hu(i,n+1)},next:o}}function VC(e,t){const n=[e[t].trim()];let i=t+1;for(;i<e.length&&e[i].trim()&&!Hv(e[i]);)n.push(e[i++].trim());return{block:{kind:"paragraph",text:n.join(`
141
+ `)},next:i}}function qC(e){const{lines:t,first:n}=e,i=[];let o=e.i;for(;o<t.length;){const c=t[o].trim()?o:Kv(t,o),d=c<0?void 0:Ja(t[c]);if(!d||d.ordered!==n.ordered||d.indent>n.indent+1)break;const u=QC(t,c,d);i.push(Hu(u.lines,e.depth+1)),o=u.next}return{block:{kind:"list",ordered:n.ordered,start:n.start,items:i},next:o}}function QC(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(Hv(c))break;i.push(c.trim())}else{const u=Kv(e,o);if(u<0||!d(e[u]))break;i.push("")}o++}return{lines:i,next:o}}function Ja(e){const t=e.match(UC);if(!t||Wu.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 Hv=e=>Uu.test(e)||Uv.test(e)||Wu.test(e)||ja.test(e)||!!Ja(e),la=e=>e.length-e.trimStart().length;function Kv(e,t){for(let n=t;n<e.length;n++)if(e[n].trim())return n;return-1}const Gv=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 Gv(t.children);default:return t}}).join(""),YC=e=>Gv(Ir(e)).replace(/\s+/g," ").trim();function Zd(e){for(const t of e){const n=JC(t);if(n)return n}}function JC(e){switch(e.kind){case"paragraph":case"heading":return YC(e.text)||void 0;case"list":return Zd(e.items.flat());case"quote":return Zd(e.blocks);case"code":case"rule":return;default:return e}}const XC=/^(.+?[.!?])\s+(?=[A-Z0-9])/;function Ku(e,t=160){var d;const n=Zd(Wv(e))??"",i=((d=n.match(XC))==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 eu({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(eu,{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(eu,{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(()=>Wv(t.text),[t.text]);return s.jsx("div",{ref:n,className:ue("md t-body",t.className),children:s.jsx(eu,{blocks:i})})});function Gu({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 ZC=e=>typeof e=="string"?{text:e}:e,eT=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(ZC);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:eT(n)||void 0,title:n.tip,children:n.text})]},i)),e.children]})}function Vu(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 tT="M25.53 10.5 A11 11 0 1 1 16 5",nT="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:tT,fill:"none",stroke:"currentColor",strokeWidth:c,strokeLinecap:"butt"}),(e==="mark"||e==="action")&&s.jsx("path",{d:nT,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 tu({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 Vv({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 ng=()=>{const e=document.documentElement.dataset.theme;return e?e==="night":matchMedia("(prefers-color-scheme: dark)").matches};function qv(){const[e,t]=w.useState(ng);return w.useEffect(()=>{const n=()=>t(ng()),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 sT(){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 iT=15e3,sg=["pointerdown","pointermove","keydown","wheel","touchstart"];function rT(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 OS({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 sg)window.addEventListener(q,I,{passive:!0});document.addEventListener("visibilitychange",Q);const Z=setInterval(()=>{y.current&&document.visibilityState==="visible"&&N(k.current)},iT);return()=>{for(const q of sg)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?BS(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 oT(e){const[t,n]=w.useState(e.leases.leases);return w.useEffect(()=>e.leases.subscribe(n),[e]),t}const aT="That changed while you were on it, so nothing was written. It is reloaded now: look again, then redo the change.";function cT(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=oT(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=l0(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=aS(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?aT: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(()=>E$({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=>wS(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 lT(){const[e,t]=w.useState(Bu),n=w.useCallback(i=>{t(o=>{const c={...o,...i};return localStorage.setItem(Ma,JSON.stringify(c)),c})},[]);return[e,n]}const Qv=()=>{var e,t;return!!((e=pt())!=null&&e.theme)&&!((t=pt())!=null&&t.themeSave)},Yv=e=>{var t;return((t=pt())==null?void 0:t.theme)??e};function dT(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 uT(){const[e,t]=lT(),[n,i]=w.useReducer(c=>c+1,0);w.useEffect(()=>Ka(Yv(e.theme)),[e.theme,n]);const o=w.useCallback(c=>{c.theme&&(dT(c.theme),i()),t(c)},[t]);return[e,o]}function Mr(){return w.useSyncExternalStore(ss.subscribe,ss.get)}function hT({className:e,size:t=18}){return s.jsx("span",{className:e,"aria-hidden":"true",children:s.jsx(Cv,{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",fT={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 Jv({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:fT[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(Jv,{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 mT(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 pT(e){return s.jsx("span",{className:ue("tag",e.tone,e.code&&"t-code",e.className),"data-tip":e.tip,children:e.children})}const gT=350;function kT(){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:gT)))},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 vT(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 wT=864e5;function yT(e,t){const n=new Date(e),i=n.toTimeString().slice(0,5),o=new Date(t).toDateString(),c=new Date(t-wT).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 xT(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=dN(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:yT(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:jT(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 jT(e){if(e!==void 0)return e<6e4?"Just asked":`Oldest ${qt(e)}`}function bT(e){const{brief:t,bp:n}=e;return t.shown?s.jsx(xT,{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 Xv(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 Zv(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(Vv,{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 ST(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 NT(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 $T(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 ST(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:NT(e,t)};default:return n}}const nu=e=>e.join(", "),CT=e=>`${nu(e)} ${e.length===1?"fails":"fail"} on main`;function TT(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 ET(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:CT(e.failing),why:AT(e.fixing,t)};case"accepted":return{edge:"attention",title:IT(e.known,e.dropped)};default:return e}}function AT(e,t){return e?"Waiting for main to be fixed":t?"Implementation waits for you":void 0}function IT(e,t){return[e.length?`Known failures on main: ${nu(e)}`:"",t.length?`Dropped for this trail: ${nu(t)}`:""].filter(Boolean).join(" · ")}function RT(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 ew(e,t){const n=ET(e.state,e.holds),i=n.detail??(e.state.kind==="failed"?RT(e.run):void 0);return{edge:n.edge,title:n.title,context:[...n.why?[n.why]:[],...TT(e.run,t)],...i?{detail:i}:{}}}const MT=e=>{try{return JSON.parse(e)}catch{return}};function tw(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(MT(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=tw({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 nw=()=>`${re()}/main-checks`,LT=(e,t)=>fetch(`${nw()}${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(`${nw()}?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 LT(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 sw(e){var d;const t=qu(e.mapId),n=t.view;if(!n||n.state.kind==="off")return null;const i=ew(n,e.now),o=$T(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(Zv,{actions:o,busy:t.busy,error:t.error})}),c.length>0&&s.jsx(Xv,{checks:c})]})}function OT(e){const t=qu(e.mapId),n=gt(3e4),i=t.view;if(!i)return null;const o=ew(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 PT(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}),DT=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 _T(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:[DT(t)]};default:return n}}function ig(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 BT(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 FT=["passed","failed","running","unavailable"],zT={pass:"passed",fail:"failed",running:"running",unavailable:"couldn't run"};function UT(e,t){const n=e.run;if(!n)return[];if(FT.includes(e.state.kind))return ig(n,t,e.state.kind==="passed");const i=n.complete?"":", before everything was merged";return[`Last run ${zT[n.result]}${i}`,...ig(n,t)]}function WT(e,t){const n=BT(e.state,e.run);return{edge:n.edge,title:n.title,context:UT(e,t),...n.detail?{detail:n.detail}:{}}}const iw=()=>`${re()}/trail-checks`,HT=(e,t)=>fetch(`${iw()}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).catch(()=>{});function rw(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(`${iw()}?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 HT(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 ow(e){var f;const t=rw(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=WT(n,e.now),d=_T(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(Zv,{actions:d,busy:t.busy,error:t.error})}),u.length>0&&s.jsx(Xv,{checks:u})]})}function KT({text:e}){return e.trim()?s.jsx(Ot,{label:"What is true when it's done",className:"bubble-destination",children:s.jsx(Gu,{markdown:!0,text:e})}):null}const GT="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.",aw=()=>{var e;return((e=pt())==null?void 0:e.highRisk)===!1};function VT(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 cw(e){const{pending:t}=e;return t!=null&&t.lookoutOnly&&aw()?s.jsx("p",{className:"vf-intro",children:GT}):s.jsxs(s.Fragment,{children:[s.jsx(VT,{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 qT=["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 QT(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=QT(re());function YT(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 JT=e=>new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});function XT({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 ",JT(e.at),"). ",e.message]})}function su(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 ZT(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(su,{again:!0,onError:e.onError})]})}function e2({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 t2(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 rg({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 n2(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(su,{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(t2,{small:!0,href:t.links.homeWeb,children:"Open Scout in Slack"}),s.jsx(rg,{onRemoved:e.onChanged})]}):s.jsxs("div",{className:"c-actions",children:[!e.busy&&s.jsx(su,{again:t.legacy,onError:e.onError}),t.legacy&&s.jsx(rg,{onRemoved:e.onChanged})]})}const s2={awaiting:"Awaiting you",blocked:"Blocked","trail.done":"Trail done",resolved:"Resolved"};function i2({s:e}){const[t,n]=r2(e);return s.jsxs("div",{className:`sync-line ${t}`,title:e.error,children:[s.jsx("span",{className:"dot"}),s.jsx("span",{children:n})]})}function r2(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 o2(e){const{s:t,back:n}=e,i=!!n.confirm&&!t.connected;return s.jsxs(Qt,{className:c2(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:a2(t)}),t.connected&&s.jsx(i2,{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(XT,{problem:t.delivery}),t.connected&&t.mentions===!1&&!i&&s.jsx(ZT,{onError:e.onError}),!t.connected&&!i&&s.jsx(e2,{s:t,connecting:n.busy}),i&&s.jsx(YT,{who:n.confirm,onConnect:n.connect,onCancel:n.cancel}),e.error&&s.jsxs("div",{className:"test-line alert",children:["✕ ",e.error]}),!i&&s.jsx(n2,{s:t,busy:n.busy,onError:e.onError,onChanged:e.onChanged,onToggle:e.onToggle})]})}function a2(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 c2(e){const t=e.connected&&e.enabled?"active":"",n=e.connected?"":"open";return`connector ${t} ${n}`}function l2(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 d2(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 u2(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(d2,{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(l2,{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:qT.map(m=>s.jsx(at,{on:c.has(m),title:s2[m],onClick:()=>f(m)},m))})]}),s.jsx(tu,{className:"dim",parts:[`${t.command} decide`,`${t.command} status`,`${t.command} inbox`,"Save as decision on any message"]})]})}function h2(){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:h2()};function f2(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 Qu(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 m2(e){const[t,n]=Qu(3e3),i=f2(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(o2,{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(u2,{s:t,patch:f=>void u(f)})]})}function p2(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 og;function g2(){return og??(og=En.get().then(e=>({owners:e.owners??[],allow:e.allow??[]}),()=>{})),og}function Lr(){const[e,t]=w.useState();return w.useEffect(()=>{let n=!0;return g2().then(i=>n&&t(i)),()=>{n=!1}},[]),e}function k2(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),Tb(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 v2(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 w2({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 y2(e){const{q:t}=e;return s.jsxs("div",{className:"msg open-q",children:[s.jsx(_,{parts:[t.agent,Wa(t.at)]}),s.jsx(w2,{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 x2(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=jC(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=j2(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(v2,{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(k2,{m:D,stillOpen:!!D.questionId&&y.has(D.questionId),onAnswerThis:()=>d(D.questionId)},D.id))}),k&&s.jsx(y2,{q:k,chatId:b==null?void 0:b.id}),s.jsx(cw,{pending:k,draft:i,onDraft:o,onSend:N,inputRef:f})]}):s.jsx(Te,{children:"No conversation"})]})}function j2(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 b2(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 S2({item:e}){const[t,n]=w.useState(!1),[i,o]=w.useState(),c=()=>{n(!0),o(void 0),b2(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 N2(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 $2({item:e}){const[t,n]=w.useState(!1),[i,o]=w.useState(),c=d=>{n(!0),o(void 0),N2(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 lw({item:e}){return e.kind==="integration"?s.jsx(S2,{item:e}):e.kind==="tracker-settings"&&e.ref.includes(":")?s.jsx($2,{item:e}):null}const C2=/(\S*\/\S*|#\d+)/g;function T2({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(C2).map((i,o)=>o%2===1?s.jsx("span",{className:"t-code",children:i},o):i)]},t))}):null}const Yu={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"},E2={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"},A2=[{minutes:30,label:"30 min"},{minutes:120,label:"2 hours"},{minutes:1440,label:"Tomorrow"}],I2=["blocked","flag","stalled","policy","reroute","overlap","integration","model"];function Or(e,t){return t||e.urgency==="blocking"?"urgent":I2.includes(e.kind)?"attention":"neutral"}const R2=[/^marked blocking$/,/^fyi\b/,/^soon\b/,/^waiting \d/,/^answer together/,/questions from /];function Ju(e){return e.reasons.filter(t=>!R2.some(n=>n.test(t)))}function dw(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`:Yu[t.kind],c=[];t.urgency==="blocking"&&c.push({text:"Blocking",urgent:!0,className:"urgency-tag"}),c.push({text:o,strong:!0});const d=i&&M2(t.title,i);return d&&c.push(d),e.otherTrail&&c.push((n==null?void 0:n.map.title)??t.mapId),c}function M2(e,t){if(!e.includes(t.key))return e.includes(t.title)?{text:t.key,code:!0}:`${t.key} ${t.title}`}function L2(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:[A2.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 O2=15e3;function P2(e){const{item:t}=e,n=t.title.split(`
145
+ `)[0],i=Ju(t),o=e.now-t.since<O2;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:dw({item:t,snap:e.snap,otherTrail:e.otherTrail})}),detail:i.length>0&&s.jsx(T2,{reasons:i}),detailText:i.join(`
146
+ `),trailing:Je(e.now-t.since),onOpen:e.onOpen,actions:s.jsx(L2,{title:t.title,canDismiss:fN(t),onSnooze:e.onSnooze,onDismiss:e.onDismiss}),below:s.jsx(lw,{item:t})})}function D2(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 _2={question:"inbox-list",approval:"inbox-list approvals"};function B2(e){const{batch:t}=e,n=t.items.length>1,i=t.kind==="question"?"answer together":"review together",o=[`${t.items.length} ${E2[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 ${_2[t.kind]??""}`,children:e.children})]})}function xd(e,t){e.ticketId?t.openTicket(e.mapId,e.ticketId):t.selectTrail(e.mapId)}const F2=new Set(["approval","blocked","policy","precedent","flag","stalled","hitl-ready","overlap","integration","model","tracker-settings"]);function Xu(e,t){if(F2.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 uw(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:D2(n.items).map(u=>{var f;return s.jsx(B2,{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(P2,{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:()=>Xu(m,e.handlers),onSnooze:g=>e.onSnooze(m.id,g),onDismiss:()=>e.onDismiss(m.id)},m.id))},u.key)})})}const z2={passed:"checks passed",failing:"checks failing",pending:"checks pending",unknown:"checks unknown",none:"no checks"};function U2({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:z2[n.checksSummary]}),s.jsx("span",{className:"when",children:W2(n)})]})})}function W2(e){return e.error?"sync failed":e.syncedAt?Av(e.syncedAt):"not synced yet"}const H2={ok:"ok",failed:"error",stale:"syncing",unknown:"idle",off:"idle"};function K2({now:e}){const t=Mr();if(!t.reached)return null;const n=sS(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:H2[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 G2(){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 V2={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 q2(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:V2[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},hw=()=>{const e=Gt();e&&location.assign(e.href)},fw=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 Q2(e){const t=nc();if(!t)return;const n=await fetch(`${t}?trail=${encodeURIComponent(e)}`).catch(()=>{});return n!=null&&n.ok?fw(await n.json().catch(()=>{})):void 0}const iu="teamtrail:trail-agents";async function Y2(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?fw(o):void 0;return c&&window.dispatchEvent(new Event(iu)),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"}],J2=9e3;function X2(){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),J2);return()=>clearInterval(c)},[n]);const o=ea[e];return s.jsxs("div",{className:"command-bar real",children:[s.jsx(Jv,{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 Z2(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 eE=/^(?:[-*+]|\d{1,3}[.)])\s+(?:\[[ xX]\]\s+)?/,mw=e=>e.split(/\r\n|\r|\n/).map(t=>t.trim().replace(eE,"").trim()).filter(Boolean);function tE({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 nE=".md,.markdown,.txt,text/markdown,text/plain",sE=/\.(md|markdown|txt)$/i,ag=e=>e.toLocaleString("en-US");async function iE(e,t){if(!sE.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:cg(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:cg(e.name,t,n.length)}:{kind:"text",name:e.name,text:n}}function cg(e,t,n){const i=n===void 0?"":` (${ag(n)} characters)`;return`${e} is too long${i}: this field takes at most ${ag(t)} characters.`}function rE({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 oE({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 aE(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 cE(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 lg=e=>e.toLocaleString("en-US");function lE(e){const[t,n]=w.useState(),[i,o]=w.useState();return{load:async f=>{if(!f)return;o(void 0);const m=await iE(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 ${lg(f.length)} characters, at most ${lg(e.max)}.`);e.onChange(f)},cancel:()=>n(void 0),message:i}}const dE=[{id:"write",label:"Write"},{id:"preview",label:"Preview"}];function ru(e){const t=w.useId(),[n,i]=w.useState("write"),[o,c]=w.useState(!1),d=w.useRef(null),u=w.useRef(null),f=lE({value:e.value,onChange:e.onChange,max:e.max,label:e.label});cE(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(mT,{className:"doc-tabs",value:n,onChange:i,items:dE})]})]}),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:nE,"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(rE,{text:e.value,preview:e.preview}),f.pending&&s.jsx(aE,{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(oE,{length:e.value.trim().length,max:e.max,label:e.label}),e.footer]})}const uE=12;function hE({value:e,onChange:t}){const n=mw(e),i=Su({assumptions:n}),o=ma;return s.jsx(ru,{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(tE,{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>uE&&!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 pw(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 gw({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:pw(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 kw(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 Q2(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 Y2(e,{on:g,...g&&i?{repo:i}:{}});return d(!1),"error"in k?(f(k.error),!1):(n(k),g)}}}function fE({mapId:e,onStarted:t}){return s.jsx(gw,{agents:kw(e),onStarted:t})}function mE({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(fE,{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:hw,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 pE(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(mE,{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 gE({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:mw($)},D=Su(O),F=[O.title,Ku(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(ru,{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(hE,{value:$,onChange:N})]}),s.jsx(ru,{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(pE,{idea:F,tracker:n,created:o,error:f,disabled:d||!O.title||!O.destination||!!D,onCreate:Q,onClose:t})]})})}const kE=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 vE({mapId:e}){const t=kw(e),{state:n}=t;if(!(n!=null&&n.on))return s.jsx(gw,{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"}),pw(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 wE({mapId:e}){if(nc())return s.jsx(vE,{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 yE=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"})]}),xE=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 jE({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?yE:xE})})}const bE={idle:"Idle",syncing:"Syncing",ok:"Synced",error:"Sync error"};function SE({label:e,health:t,now:n}){if(t.status!=="error")return null;const i=[`${bE[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 dg={"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 NE(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:dg[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:dg[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 $E(e){const{map:t}=e.snap,n=uS(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 CE(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($E,{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(NE,{map:e.map,onStartOver:e.onStartOver,onArchive:e.onArchive,onToggleMode:e.onToggleMode,onDone:()=>n(!1)})})]})]})}function TE(e){const{map:t}=e,n=gt(1e3),i=e.activity.pending.length,o=t&&e.snaps[t.id],c=t&&Jk(e.activity,t.id),d=t?Ku(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(CE,{...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(SE,{label:e.trackerLabel,health:e.health,now:n}),s.jsx(K2,{now:n}),t&&o&&s.jsxs("span",{className:"trail-meta",children:[s.jsx(Tn,{label:"Trail T+",value:Ev(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",...Zk(e.activity,t.id).map(u=>Xk[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(wE,{mapId:t.id}),s.jsx(q2,{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"}),Qv()?null:s.jsx(jE,{onToggle:e.onToggleTheme}),s.jsx(G2,{})]})]})}function EE(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 AE(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 ug={label:"Focus for 1 hour",change:{kind:"for",minutes:60}};function IE(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},ug];case"off":return[{...ug,primary:!0},{label:"Focus for 3 hours",change:{kind:"for",minutes:180}}];default:return e}}const hg=e=>Wa(e).slice(0,5),RE=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function ME(e){const t=`${e.items.length} waiting on you`;return e.heldBack===0?`Nothing held back · ${t}`:`${RE(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 fg=e=>`Items scoring ${e.policy.value.interrupt} or more interrupt you · ${e.items.length} waiting on you`;function LE(e){const t=e.focus;switch(t.kind){case"manual":case"hours":{const n=hg(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:ME(e)}}case"paused":{const n=hg(t.until),i=`Quiet hours paused until ${n}`;return{word:"paused",until:n,on:!1,title:i,reason:jd(e),detail:fg(e)}}case"off":return{word:"off",until:"",on:!1,title:"Focus is off",reason:jd(e),detail:fg(e)};default:return t}}const OE="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 PE(e){const{view:t}=e,n=LE(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:OE})]}),s.jsx(_,{parts:[n.reason]}),s.jsx(_,{className:"focus-held",parts:[n.detail]}),s.jsxs("div",{className:"focus-panel-actions",children:[IE(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 DE(e){return s.jsx("span",{className:"attention-head",children:s.jsx(PE,{view:e.view,onChange:e.onFocus,onSettings:e.onSettings})})}const vw=`${re()}/attention`,_E=250;async function bd(e,t,n){var c;const i=await fetch(`${vw}${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 ww(e){const[t,n]=w.useState(),[i,o]=w.useState(),[c]=w.useState(ki),d=w.useCallback(()=>{const m=c.start();fetch(vw).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,_E);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 BE(e){return e.prefs.channel!=="browser"?!1:typeof Notification<"u"&&Notification.permission==="granted"}function FE(e){const t=new Notification(`${J.name} · needs you`,{body:e.title,tag:e.id});t.onclick=()=>{window.focus(),t.close()}}function zE(e){const t=w.useRef();w.useEffect(()=>{if(!e)return;const n=new Set(e.interrupting),i=t.current;if(t.current=n,!(!i||!BE(e)))for(const o of e.items)n.has(o.id)&&!i.has(o.id)&&FE(o)},[e])}const UE={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"},WE={"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 yw(e){return UE[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$/,""):WE[e.kind]??Yu[e.kind]}function HE(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 KE(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 mg({activity:e}){const t=gt(1e3),n=mS(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 GE(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 xw={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"},Zu={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."},jw=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 VE(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 qE(e){var u;const t=[...e.activity.pending].sort((f,m)=>f.at-m.at),n=VE(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(mg,{activity:e.activity}),s.jsx(uw,{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(mg,{activity:e.activity}),e.brief,s.jsx(KE,{items:n,snaps:e.snaps,currentMapId:e.currentMapId,onOpen:e.onOpenTicket}),(t.length>0||!(n.length+o))&&s.jsx(GE,{items:t,snaps:e.snaps,currentMapId:e.currentMapId,selected:e.sessionId,onOpen:e.onOpenQuestion})]})}function bw(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(cw,{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 QE(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 YE(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(QE,{mapId:e.mapId,ticketId:e.ticketId,rule:i.id,onDone:()=>{n(void 0),e.onWaived()}})},i.id))})]})}function JE(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 XE(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 ZE(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(XE,{mapId:e.mapId,ticketId:e.ticketId,rule:t.rule,onDone:e.onUndone})},t.rule))}):null}function eA(e){const{held:t,waived:n,reload:i}=JE(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(YE,{mapId:e.mapId,ticketId:e.ticketId,held:t,onWaived:i}),s.jsx(ZE,{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 tA(){const e=await fetch(`${re()}/verification/config`);return e.ok?await e.json():null}function eh(){const[e,t]=w.useState(),{reload:n}=Pe({load:tA,show:t,failed:()=>t(null),changed:i=>i.endsWith("verification.json"),events:{attention:()=>!0}});return{view:e,reload:n}}function nA(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 sA=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})),ou=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 iA(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=ou({when:i,check:"",ask:"",why:""}).when.join(",");if(!t.some(d=>ou(d).when.join(",")===o))return{when:i,check:"",ask:"",why:(n.get("why")??"").slice(0,300)}}const rA={when:"",check:"",ask:"",why:""};function oA(e){var b;const{view:t,lastMatched:n}=e,[i,o]=w.useState(()=>{const S=sA(t.config),x=iA(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(ou),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(nA,{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,rA])},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 aA({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 cA(){const e=await fetch(`${re()}/verification/rules`);return e.ok?(await e.json()).lastMatched??{}:{}}function lA(){const[e,t]=w.useState({});return Pe({load:cA,show:t,events:{verification:()=>!0}}),e}function dA(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 uA(){var u,f;const{view:e}=eh(),t=ji(),n=lA(),[i,o]=w.useState(!1);if(!e)return null;const c=((u=e.config)==null?void 0:u.rules)??[],d=dA(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(oA,{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(aA,{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 Sw=()=>`${re()}/proof/settings`;async function hA(){const e=await fetch(Sw());return e.ok?await e.json():null}function fA(){const[e,t]=w.useState(),{pushed:n}=Pe({load:hA,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(Sw(),{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 mA(){const{enabled:e,set:t}=fA(),[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 pA(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 gA(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`,pA(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 kA=(e,t)=>e?"the same model as the author":t?`author on ${t}`:"author model unknown";function vA(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}`,kA(n.sameModel,t)])}function th(e,t){const n=e.state==="closed"&&e.closeReason==="completed";return!!t.attempt.id||n&&uv.includes(e.type)}function wA(e){const{view:t}=e;if(!t)return null;const{proof:n,post:i}=t;if(!th(e.ticket,n))return null;const o=n.status==="verified",c=i!=null&&i.commentUrl?At(i.commentUrl):void 0,d=gA(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)})]}),vA(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 yA(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 Nw(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 pg="The server didn't answer. Try again.",$w=(e,t)=>String(e.error??`The server answered ${t}.`).slice(0,300);async function Cw(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 xA(e){const t=await Cw(`${re()}/proof/merge-anyway`,e),n=t.json.gapsHash;return t.ok&&typeof n=="string"?{hash:n}:{error:$w(t.json,t.status)}}async function jA(e){try{const t=e.gaps?await xA({mapId:e.mapId,ticketId:e.ticketId,gaps:e.gaps}):void 0;if(t&&"error"in t)return{kind:"error",text:t.error??pg};const n=t?{anyway:!0,gaps:t.hash}:{},i=await Cw(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:$w(i.json,i.status)}}catch{return{kind:"error",text:pg}}}function Tw(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 jA({...e,gaps:o}))}}}function bA(e){const t=Tw(e),{state:n}=t;return n.kind==="merged"?s.jsx(Nw,{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 gg(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 SA(e){const t=Tw(e),{state:n}=t;return n.kind==="merged"?s.jsx(Nw,{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(gg,{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(gg,{gaps:e.gaps})]})}function NA(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(bA,{...c}):s.jsx(SA,{...c,gaps:n.gaps})}function kg({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 $A({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 CA({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(kg,{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(kg,{criteria:n.criteria})]}),s.jsx($A,{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 Ew=w.createContext(null);function As(){const e=w.useContext(Ew);if(!e)throw new Error("useKnowledge needs a KnowledgeContext provider");return e}function TA({snap:e,t}){const n=As();if(!n.entries.length||t.state==="closed")return null;const i=fv(n.entries,{trailKey:e.map.key,ticket:{type:t.type,title:t.title,body:t.body},paths:mv(`${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 EA={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 AA({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:EA[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(zu,{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 IA={suggested:"Suggested",confirmed:"Confirmed",assumption:"Assumption",outdated:"Outdated"};function RA(){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"},...tN.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":IA[x.status]]})},x.id)):s.jsx(Te,{children:t==="review"?"Nothing needs you":"No entries"})}),y?s.jsx(AA,{e:y}):s.jsx(Te,{children:"Pick an entry"})]})]})})}function Aw({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 Iw=`${re()}/knowledge`;async function vg(e,t){const n=await fetch(`${Iw}${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 MA(){const e=await fetch(Iw);return e.ok?await e.json():null}function LA(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:MA,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)=>vg("/call",{id:b,call:S,hash:x??c[b]}).then(()=>(g(void 0),k(),!0),$=>(g($.message),k(),!1)),propose:b=>vg("/propose",b).then(S=>(k(),S.entry),S=>(g(S.message),void 0))}}const Rw=`${re()}/criteria`;async function OA(e){if(!e)return[];const t=await fetch(`${Rw}?mapId=${encodeURIComponent(e)}`);return t.ok?(await t.json()).tickets:[]}function PA(e){const[t,n]=w.useState([]),{reload:i}=Pe({view:e,load:()=>OA(e),show:n,failed:()=>n([]),changed:c=>c.startsWith("criteria/")});return{tickets:t,confirm:c=>fetch(`${Rw}/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 Mw=`${re()}/criteria-proposals`;async function DA(e){if(!e)return[];const t=await fetch(`${Mw}?mapId=${encodeURIComponent(e)}`);return t.ok?(await t.json()).proposals:[]}function _A(e){const[t,n]=w.useState([]),{reload:i}=Pe({view:e,load:()=>DA(e),show:n,failed:()=>n([]),events:{"criteria-proposals":c=>(c==null?void 0:c.mapId)===e}});return{proposals:t,decide:(c,d)=>fetch(`${Mw}/${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 BA(e,t){const{tickets:n,confirm:i}=PA(e.map.id),o=_A(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=fv(d.entries,{trailKey:e.map.key,ticket:{type:t.type,title:t.title,body:t.body},paths:mv(`${t.body}
156
+ ${d.briefText}`)}).filter(S=>S.kind==="business-rule").filter(S=>ZS(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 Lw({v:e}){const t=e.criteria,n=uv.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(CA,{c:t})})}const Ow=/^\*\*([^*]+)\*\*\s*/;function FA(e){var n;const t=(n=e.match(Ow))==null?void 0:n[1];return t?t.replace(/:$/,"").toLowerCase():"comment"}function zA(e){const t=e.decisions.map(i=>({id:i.id,at:i.decidedAt,who:Fu(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:FA(i.body),text:i.body.replace(Ow,"")}));return[...t,...n].sort((i,o)=>o.at-i.at)}function UA(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(Gu,{text:t.text,markdown:!0})]})}function WA(e){const t=Lr(),[n,i]=w.useState(!1),o=zA({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(UA,{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 Pw(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 Dw=`${J.apiPrefix}`;async function _w(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=>_w(await fetch(`${Dw}${e}`)),Bw=async(e,t)=>_w(await fetch(`${Dw}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}));function HA(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 KA(e){const t=HA(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(Pw,{answers:i.answers})]},i.guide.id))})]})}let Fw;const da=new Set;let es;function au(e){Fw=e;for(const t of da)t()}function zw(e){es==null||es.pushed(),au(e)}const GA=()=>Fw;function VA(e){return da.add(e),es??(es=tw({load:()=>$a("/guides"),show:au,failed:()=>au(null),changed:t=>t.includes("guides")})),()=>{da.delete(e),!da.size&&(es==null||es.stop(),es=void 0)}}function kn(){const e=w.useSyncExternalStore(VA,GA),t=w.useCallback(async(i,o)=>{try{zw(await Bw(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 qA={active:"Active",unapproved:"New, waiting for your approval",tampered:"Changed since you approved it",invalid:"Can't be used"},QA={active:"Approved",unapproved:"Not approved yet",tampered:"Changed since you approved it",invalid:"Can't be used"},cu=e=>{var t;return e.origin==="local"&&(!((t=e.lock)!=null&&t.source)||e.lock.source==="local")};function YA(e){return cu(e)?{text:QA[e.status],strong:e.status==="active"}:e.status==="active"?void 0:qA[e.status]}function Ca(e){try{return new URL(e).host}catch{return e}}function JA(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 nh=e=>e.map(t=>/\s/.test(t)?JSON.stringify(t):t).join(" "),wg=3;function XA(e,t){return e.length<=Math.max(t,wg+1)?e:`${e.slice(0,Math.max(t-1,wg)).trimEnd()}…`}function Uw(e){return e===XN?"Verified":`Verified by ${Ca(e)}'s catalog`}function Ww(e,t){return e.builtin?{text:"Built in",strong:!0}:e.verified?{text:Uw(t),strong:!0}:"Not reviewed"}function ZA(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"?Uw(i.registry):"Verified",strong:!0,tip:n}}var Hw=Nk();function Kw(e){return D1(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 eI(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,": ",nh(((x=(S=t.guide)==null?void 0:S.proposedChecks[b])==null?void 0:x.run)??[])]}),s.jsx(Kw,{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 tI(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 Gw(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(tI,{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,": ",nh(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 nI(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 sI(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}`,Ww(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(Gw,{p:n}),n&&s.jsx(nI,{repo:n.repo,id:t.id,version:t.version}),n&&s.jsx(eI,{preview:n,installed:e.installed,add:e.add})]})}function iI(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,Ww(t,e.catalogUrl),t.reported&&"Reported"]}),detail:t.summary,trailing:e.installed&&`installed ${e.installed}`,onOpen:e.onOpen})})}const yg=e=>e?`registry=${encodeURIComponent(e)}`:"";function rI(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?${yg(e)}`).then(f=>u&&n(f),f=>u&&o(f.message)),()=>{u=!1}},[e]);const c=w.useCallback(u=>$a(`/guides/catalog/preview?${yg(e)}&id=${encodeURIComponent(u)}`),[e]),d=w.useCallback(async(u,f)=>{const m=await Bw("/guides/catalog/add",{registry:e,id:u,sha256:f});return zw(m),m.installed},[e]);return{index:t,error:i,preview:c,add:d}}function oI(e){var x,$;const[t,n]=w.useState(((x=e.registries[0])==null?void 0:x.name)??""),i=rI(t||void 0),{find:o}=kn(),[c,d]=w.useState(""),[u,f]=w.useState(!0),[m,g]=w.useState(),k=i.index?_1({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 Hw.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(sI,{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(iI,{entry:N,catalogUrl:(S==null?void 0:S.url)??"",installed:b(N.id),onOpen:()=>g(N.id)},N.id))})]})]})}),document.body)}async function aI(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 cI=400;function Vw(e){const[t,n]=w.useState([]),i=JSON.stringify(e);return w.useEffect(()=>{const o=new AbortController,c=setTimeout(()=>{const d=JSON.parse(i);aI(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)})))})},cI);return()=>{clearTimeout(c),o.abort()}},[i]),t}function lI({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 dI={"wont-run":"Won't run",unsure:"May not run"},Nd=s.jsx("span",{className:"sep",children:" · "});function uI(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:dI[t.severity]}),e.named&&s.jsxs(s.Fragment,{children:[Nd,s.jsx("code",{className:"t-code",children:t.check})]}),Nd,s.jsx(lI,{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(uI,{finding:t,named:e.named,onFix:e.onFix},`${t.check} ${t.text}`))}),e.action]}):null}function hI({spec:e}){const t=Vw([{name:"0",run:e.run,...e.cwd?{cwd:e.cwd}:{}}]);return s.jsx(ic,{findings:t})}function fI(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,": ",nh(c.run)]}),d&&i&&s.jsx(hI,{spec:c}),d&&i&&s.jsx(Kw,{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 mI(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(Gw,{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 pI="A file in guides/ replaces this built-in once you approve it; until then the built-in is used";function gI(e){var t,n;return e.override?pI: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},JA(t),ZA(t),YA(t),t.guide&&kI(t.guide.checklist.length)]}),detail:gI(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(mI,{r:i,busy:e.busy,onApprove:u=>e.onAct("/guides/approve",{id:n,sha256:u})}),s.jsx(fI,{r:t,busy:e.busy,onApprove:(u,f)=>e.onAct("/guides/checks/approve",{id:n,name:u,acknowledged:f})})]})})})}const kI=e=>e===1?"1 checklist item":`${e} checklist items`;function vI(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:ZN,target:"_blank",rel:"noreferrer",children:"share it in the public catalog"}),"."]})]})}function wI(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=>!cu(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(vI,{guides:t.guides.filter(cu),busy:c,onAct:g(!0),error:k(!0)}),u&&s.jsx(oI,{registries:t.registries,onClose:()=>f(!1)})]})}function yI(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 xI={type:"by type",ticket:"added",removed:"removed"},jI=(e,t)=>e.removed?{change:{add:e.id},label:`Put back ${t}`,mark:"+"}:{change:{remove:e.id},label:`Remove ${t}`,mark:"×"};function Qw(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}=jI(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:xI[u]}),e.editable&&s.jsx("button",{type:"button",className:"chip-act","aria-label":g,title:g,onClick:()=>e.onChange(m),children:k})]})}function Yw(e,t){const n=Vb(e,t).map(c=>({...c,removed:!1})),o=($u(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 bI(e){const{view:t}=kn();if(!t)return null;const n=Yw(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(Qw,{row:i,editable:!1,onChange:()=>{}},i.id))}),n.map(i=>s.jsx(yI,{id:i.id},i.id))]}):s.jsx("span",{className:"t-meta",children:"None"})}const xg="";function SI(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:xg,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:xg,options:i,onChange:o=>o&&e.onAdd(o)})}function NI(e){const{view:t,act:n}=kn(),[i,o]=w.useState();if(!t)return null;const c=e.ticket,d=Yw(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(Qw,{row:m,editable:!0,onChange:f},m.id)),s.jsx(SI,{taken:u.map(m=>m.id),onAdd:m=>f({add:m})})]}),i&&s.jsx("span",{className:"vf-err",children:i})]})}function $I(e){const{type:t,ids:n,usable:i}=e,o=n.filter(m=>!i.some(g=>g.id===m)),c=Hk[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 CI={defaults:"Defaults",team:"Defaults, kept within the trail's earlier team"};function TI(e){var g;const{view:t,act:n}=kn(),[i,o]=w.useState();if(!t)return null;const{byType:c,source:d}=$u(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:[CI[d],d==="team"&&((g=e.map.guides)==null?void 0:g.join(", "))]})}),s.jsx("div",{className:"type-guides",children:rs.map(k=>s.jsx($I,{type:k,ids:c[k]??[],usable:u,onToggle:y=>m(k,y)},k))}),i&&s.jsx("span",{className:"vf-err",children:i})]})}function EI(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 AI({check:e}){const t=jw(e),[n,i]=w.useState(),[o,c]=w.useState(),d=II(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 II(e){return e.error?"did not start":e.timedOut?"timed out":`exit ${e.exitCode??e.signal??"?"}`}const jg=e=>(e==null?void 0:e.slice(0,8))??"none",bg=e=>e===null?"·":String(e);function RI({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?`${jg(t.base.head)} → `:""}${jg(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":`+${bg(u.add)} −${bg(u.del)}`,u.dirtyAtClaim?" · dirty at claim":"",c.has(u.path)?" · outside the declared files":""]})]},u.path))})]})]})}function MI({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 LI({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:xw[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(MI,{attempt:e}),e.criteria&&s.jsx("ul",{className:"vf-criteria",children:e.criteria.lines.map(n=>s.jsx("li",{className:OI(n),children:n},n))}),s.jsx(RI,{attempt:e}),e.checks.map(n=>s.jsx(AI,{check:n},n.name))]})}function OI(e){return e.includes(" ✓ ")?"ok":e.includes(" ✗ ")?"bad":e.includes(" ? ")?"claimed":"wait"}const PI={PASS:"Passed",FAIL:"Sent back",NEEDS_HUMAN:"Needs you"};function DI(e){var t;return(t=e.guides)!=null&&t.length?e.guides:e.guide?[{guide:e.guide,answers:e.checklist??[]}]:[]}function _I({verdict:e}){const t=DI(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":PI[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(Pw,{answers:n.answers},n.guide.id))]})}const BI={PASS:"review passed",FAIL:"review sent it back",NEEDS_HUMAN:"reviewer asked for you"};function FI({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 ",xw[t.result].toLowerCase()]}),s.jsx(_,{parts:[{text:t.id,code:!0},t.agent,os(t.submittedAt),i&&BI[i.verdict]]}),s.jsx(an,{children:s.jsxs("div",{className:"vf-panel",children:[e.verdicts.map(o=>s.jsx(_I,{verdict:o},o.id)),e.attempts.map((o,c)=>s.jsx(LI,{attempt:o,latest:c===0},o.id))]})})]})}const Ta="";function zI(e){const t=ju.map(i=>({value:i,label:Pr[i],hint:Zu[i]})),n=[...UI(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 UI(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 WI={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."}},HI={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."}},Sg="The pass counts although the work changed what its checks run. The proof says you accepted it.";function KI(e){return e.kind!=="accept"||!e.guarded?e.hint:e.retried?`${Sg} It also passed only on retry.`:Sg}function GI(e){const{kind:t}=e,n=e.retried&&HI[t]||WI[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:KI({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 VI(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 qI={ticket:"set on this ticket",trail:"from the trail",none:"not set"};function QI({level:e}){return e.level==="off"?"Off":e.checks.join(", ")||"No checks"}function YI({data:e}){const{level:t}=e;return s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"t-body",children:QI(e)}),s.jsx(_,{parts:[t.level!=="off"&&Pr[t.level],qI[t.source]]}),s.jsx(an,{children:s.jsx("p",{className:"t-meta",children:Zu[t.level]})})]})}function JI(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 XI(e){if(e)return e.timedOut?"timed out":e.error?`couldn't run: ${e.error}`:`exited ${e.exitCode??e.signal}`}function ZI(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},XI(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 eR({v:e,act:t}){return s.jsxs("dl",{className:"facts how-editor",children:[s.jsx(Et,{label:"Guides",children:s.jsx(NI,{map:e.snap.map,ticket:e.t})}),s.jsx(Et,{label:"Verification",children:s.jsx(zI,{value:e.t.verification,inherit:`Trail (${Pr[e.snap.map.verification??"off"]})`,onChange:n=>void t({action:"level",level:n})})})]})}function tR({v:e}){return s.jsxs("dl",{className:"facts",children:[s.jsx(Et,{label:"Guides",children:s.jsx(bI,{map:e.snap.map,ticket:e.t})}),e.verification&&s.jsx(Et,{label:"Checks",children:s.jsx(YI,{data:e.verification})}),s.jsx(TA,{snap:e.snap,t:e.t})]})}function nR(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(eR,{v:t,act:e.act}):s.jsx(tR,{v:t})})}function sR({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"&&iR(rR(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 iR(e){return`back in the queue after ${e} without activity`}function rR(e){const t=e/864e5;return t>=2?`${Math.round(t)} days`:qt(Math.max(0,e))}function oR({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(sR,{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(U2,{mapId:i,ticketId:e.t.id})}),n>0&&e.verification&&s.jsx(Et,{label:"Attempts",children:s.jsx(FI,{data:e.verification})}),n>0&&s.jsx(KA,{mapId:i,ticketId:e.t.id}),s.jsx(JI,{waivers:((c=e.verification)==null?void 0:c.waivers)??[],onUndo:t})]})})}function Jw(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(zu,{what:"The criteria",onReviewAgain:o.reviewAgain})]})}function aR(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(NA,{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(Vv,{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}),cR={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 cR[e]}const lu=`${re()}/workspaces`;async function lR(){const e=await fetch(lu);return e.ok?await e.json():null}function Xw(){const[e,t]=w.useState(),{pushed:n}=Pe({load:lR,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(lu,{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(`${lu}/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 Zw(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 dR(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(Zw,{onRemove:n=>e.onRemove(t.mapId,t.ticketId,n)})},`${t.mapId}/${t.ticketId}`))}):null}function uR(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(Zw,{label:"Remove workspace",onRemove:e.onRemove})]})]})}function hR(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 fR(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 mR=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 pR(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(hR,{onResolve:(m,g)=>{i.resolve(n.t.id,m,g),o()},onCancel:o});case"rule":return s.jsx(fR,{onRuleOut:m=>{i.ruleOut({ticketId:n.t.id},m),o()},onCancel:o});case"rework":case"accept":case"unblock":return s.jsx(GI,{kind:t,retried:n.state==="held"&&Cu((c=n.verification)==null?void 0:c.attempts[0]),guarded:mR(n),onSubmit:m=>{e.act(m),o()},onCancel:o});case"waive":return s.jsx(ZI,{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(uR,{workspace:n.workspace,onRemove:n.removeWorkspace,onCancel:o}):null;case null:return null;default:return t}}function ey(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(pR,{form:e.form,setForm:e.setForm,v:t,actions:e.actions,act:n.act,waive:n.waive}),o&&s.jsx(lw,{item:o}),s.jsx(aR,{v:t,bar:n,onOpenChat:e.onOpenChat,trailing:e.trailing})]})}function gR({chips:e}){return s.jsx("div",{className:"ticket-chips",children:e.map(t=>s.jsx(pT,{tone:t.tone,code:t.kind==="key",className:`tag-${t.kind}`,tip:t.tip,children:t.text},t.kind))})}function ty({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(gR,{chips:e.chips}),s.jsx(_,{parts:[u&&"needs a person",i.reviewOf&&`reviews ${c(i.reviewOf)}`,d.length>0&&`blocks ${d.join(", ")}`]})]})}function kR(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 vR(e,t){return[...wR(e,t),...yR(e,t),...SR(e,t),...NR(e,t),...$R(e,t)].filter(n=>!!n)}function wR(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 yR(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=xR(c);return o&&!d&&Cu(c)?jR(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 xR=e=>{var t;return(e==null?void 0:e.result)==="pass"&&((t=e.guard)==null?void 0:t.mode)==="enforce"};function jR(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 bR=new Set(["rework","held","claimed"]);function SR(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&&bR.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 NR(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 $R(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 CR={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 ny(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=vR(t,y),S=TR(t,e.onOpenChat),x=t.standing.primary,$=b.find(I=>I.id==="take-criteria")??b.find(I=>I.id==="confirm-criteria"),N=x==="need"?kR({v:t,all:b,onItem:e.onItem,onDismiss:e.onDismiss}):void 0,O=x&&x!=="need"?b.find(I=>I.id===CR[x]):void 0,D=S??N??O??$,F=ER({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 TR(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 ER(e){return e.urgent?"urgent":e.named?"primary":"default"}function AR({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 Ng=["summary","productContext","existing","conventions","dataModel","api","risks"];function IR(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=Ng.filter(m=>d[m].trim()),f=Ng.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:RR(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(AR,{text:d[m]}),(m==="conventions"||m==="productContext")&&d[m].trim()&&s.jsx(Aw,{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(zu,{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 RR(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 MR({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 LR({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 OR={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 PR({brief:e,onReview:t}){if(e.status==="accepted")return null;const[n,i]=OR[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 sy=`${re()}/briefs`;async function DR(e){if(!e)return{brief:null};const t=await fetch(`${sy}?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:()=>DR(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(`${sy}/${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 $g=new Set,Cg=e=>`teamtrail.brief-ready:${re()}:${e.mapId}:${e.submittedAt??""}`,Tg={has(e){const t=Cg(e);if($g.has(t))return!0;try{return localStorage.getItem(t)==="1"}catch{return!1}},add(e){const t=Cg(e);$g.add(t);try{localStorage.setItem(t,"1")}catch{}}};function _R(e){const[,t]=w.useState(0);return{show:(e==null?void 0:e.status)==="submitted"&&!Tg.has(e),close:()=>{e&&Tg.add(e),t(o=>o+1)}}}function BR(e,t){return e&&t.state==="open"&&!dv.includes(t.type)}function FR(e){const{gated:t}=oc(e);return n=>BR(t,n)}const zR=`${J.apiPrefix}/models`;async function UR(){const e=await fetch(zR);return e.ok?await e.json():null}function sh(){const[e,t]=w.useState();return Pe({load:UR,show:t,failed:()=>t(null),changed:n=>n.endsWith("models.json")||n.endsWith("map.md")||n.includes("/tickets/"),events:{attention:()=>!0}}),e}async function WR(){const e=await fetch(`${re()}/signed-state`);return e.ok?await e.json():null}function iy(){const[e,t]=w.useState();return Pe({load:WR,show:t,failed:()=>t(null),changed:n=>n.endsWith("map.md")||n.includes("/tickets/")||n.includes("/decisions/")}),e}const HR={ticket:"held until you accept or revert it",decision:"what you see is what was signed here, until you accept or revert it"};function KR(e){return e[0]==="added"?"added outside Teamtrail":e.map(t=>t==="words"?"its words":t).join(", ")}function GR({mapId:e,kind:t,id:n}){const i=iy(),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:[`${KR(c.fields)} · ${HR[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 Eg={low:0,medium:1,high:2};function VR(e){return{key:e.t.key,type:e.t.type,state:e.state,need:qR(e),agent:QR(e),proof:JR(e),risk:XR(e)}}function qR(e){if(e.question)return"waiting on you";const t=e.items.find(n=>n.kind!=="question");return t&&yw(t)}function QR(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:YR(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 YR=e=>e===wt?"you":e;function JR(e){var n;const t=(n=e.proof)==null?void 0:n.proof;if(!(!t||e.state!=="decided"||!th(e.t,t)))return{verified:t.status==="verified",gap:t.gaps[0]}}function XR(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)=>Eg[c.level]-Eg[o.level])[0]}const ZR=new Set(["claimed","verifying"]),eM=new Set(["held","rework"]),tM={medium:"medium risk",high:"high risk"};function nM(e){const t=[{kind:"key",text:e.key},{kind:"type",text:ns[e.type]},sM(e)];return e.agent&&t.push(...rM(e.agent)),e.proof&&t.push(oM(e.proof)),e.risk&&e.risk.level!=="low"&&t.push({kind:"risk",text:tM[e.risk.level],tone:"warn",tip:e.risk.reason}),t}function sM(e){return e.need?{kind:"state",text:e.need,tone:"urgent"}:{kind:"state",text:Iv[e.state],tone:iM(e.state)}}function iM(e){return ZR.has(e)?"agent":eM.has(e)?"warn":void 0}function rM(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 oM(e){return e.verified?{kind:"proof",text:"verified",tone:"verified",tip:"Verified by Teamtrail"}:{kind:"proof",text:"not verified",tip:e.gap}}const aM=e=>e[0]==="added"?"added outside Teamtrail":e.map(t=>t==="words"?"its words":t).join(", ");function cM(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&&`${aM(e.change.fields)} · held until you accept or revert it`,lease:d,assignee:t.assignee,mine:e.mine,hitl:gi(t)==="hitl",briefHeld:lM(e),modelWait:e.modelWait&&{tier:e.modelWait.tier,best:e.modelWait.best},running:(f=e.verification)==null?void 0:f.running,latest:c&&dM(c),sentBack:hM(e.verification),reviewWaits:fM(e.verification),verified:e.proof&&th(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 lM(e){if(!(!e.brief||e.state!=="frontier"||dv.includes(e.t.type)))return e.brief.status==="submitted"?"submitted":"writing"}function dM(e){var o;const t=e.checks.filter(c=>!jw(c)).map(c=>c.name),n=e.flaky&&Cu(e)?Zb(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:tS(i.findings)}:{},...n?{retried:n}:{}}}const uM={FAIL:"the review sent it back",NEEDS_HUMAN:"the reviewer asked for you"};function hM(e){const t=e==null?void 0:e.attempts[0],n=t&&e.verdicts.find(i=>i.attemptId===t.id);return n&&uM[n.verdict]}function fM(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 mM=new Set(["question","approval","blocked","hitl-ready","stalled","model"]);function pM(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=>!mM.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 gM(e){const t=kM(e),n=t.edge==="neutral"||t.edge==="done";return e.atRisk&&n?{...t,edge:"attention"}:t}function kM(e){if(e.question)return wM(e,e.question);if(e.outsideChange)return{edge:"attention",title:"Held: changed outside Teamtrail",parts:[e.outsideChange],primary:"review-change"};const t=$M(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 yM(e);case"out-of-scope":return{edge:"neutral",title:"Ruled out",parts:jM(e)};case"verifying":return bM(e);case"held":return vM(e);case"claimed":return SM(e);case"rework":return{edge:"attention",title:`Rework: ${ry(e)}`,parts:["waits for an agent"]};case"frontier":return NM(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 vM(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: ${ry(e)}`,parts:["waits on you"],primary:(d=e.latest)!=null&&d.failed.length?"waive":"unblock"}}function wM(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 yM(e){const t=xM(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 xM(e){if(e!==void 0)return e?"verified":"not verified"}function jM(e){return e.closedAt?[Nr(e.now,e.closedAt)]:[]}function bM(e){var t;return((t=e.item)==null?void 0:t.kind)==="approval"?{edge:e.item.edge,title:"Waiting on you: approve it",parts:Ag(e),primary:"approve"}:e.reviewWaits?{edge:"neutral",title:"Waiting for a review agent",parts:Ag(e)}:{edge:"neutral",title:"Verifying",parts:[]}}function Ag(e){var t;return((t=e.latest)==null?void 0:t.result)==="pass"?["checks passed"]:[]}function ry(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 SM(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 NM(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 $M(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 oy(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=VI(o,n.id,n.updatedAt),f=yA(o,n.id),m=BA(t,n),g=iy(),k=sh(),y=ss.ticket(Mr(),o,n.id),b=oc(t),S=Xw(),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"?Lu(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=pM($),O=gM({...cM($),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:nM(VR($))}}function CM(e){return e.replace(/\s*Part of trail \S+\.\s*$/,"").trim()}function ay({v:e}){const t=CM(e.t.body);return t?s.jsx(Ot,{label:"What",className:"ticket-body",children:s.jsx(Gu,{text:t,markdown:!0})}):null}function TM(e){const{snap:t,t:n,api:i}=e,o=oy({snap:t,t:n,api:i,sessions:e.sessions,attention:e.attention}),[c,d]=w.useState(!1),u=ny({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(ty,{v:o}),s.jsx(Jw,{v:o}),s.jsx(ay,{v:o}),s.jsx(Lw,{v:o}),s.jsx(nR,{v:o,editing:c,setEditing:d,act:u.act}),s.jsx(oR,{v:o,onUndoWaiver:u.undoWaiver}),s.jsx(eA,{mapId:t.map.id,ticketId:n.id}),s.jsx(wA,{ticket:n,view:o.proof}),s.jsx(WA,{t:n,decisions:o.decisions,onOpenDecision:e.onOpenDecision}),s.jsx(ey,{v:o,bar:u,form:e.form,setForm:e.setForm,actions:i.actions,onOpenChat:e.onOpenChat,className:"sticky"})]})}function EM(e){const t=e.snap.tickets.find(n=>n.id===e.id);return t?s.jsx(TM,{...e,t},t.id):s.jsx(Te,{children:"Ticket not found."})}const Ig=[{phase:"discovery",label:"Discovery"},{phase:"brief",label:"Brief"},{phase:"building",label:"Building"},{phase:"review",label:"Review"},{phase:"done",label:"Done"}],AM=new Set(["decided","out-of-scope"]),IM=new Set(["verifying","held"]);function RM(e){if(e.done)return"done";if(e.gated)return e.briefStatus==="submitted"?"brief":"discovery";const t=e.states.filter(n=>!AM.has(n));return t.length&&t.every(n=>IM.has(n))?"review":"building"}function MM(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 LM(e){const t=Ig.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:Ig.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:MM(e.phase,{done:i,total:n.length,reason:e.reason})})]})}function cy(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=RM({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(LM,{phase:d,snap:t,states:o,reason:c?(b=e.done)==null?void 0:b.reason:void 0}),c?s.jsx(ow,{mapId:t.map.id,now:e.now}):s.jsx(sw,{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:dw({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 ly({snap:e,item:t,api:n}){const i=zk(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)),u0.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 OM(e){const{api:t}=e,{snap:n,selection:i,actions:o}=t,[c,d]=w.useState(null),u=gt(5e3),f=PM(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(cy,{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(ly,{snap:n,item:i.item,api:t}):g=s.jsx(EM,{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(vT,{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 PM(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 dy(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 DM({session:e}){return s.jsxs("div",{className:"bubble-agent",children:[s.jsx(_,{parts:[`step ${e.step} of ${e.total}`,e.stepLabel.toLowerCase()]}),s.jsx(dy,{step:e.step,total:e.total})]})}function _M(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(ty,{v:t,titled:!o,small:!!n}),s.jsx(Jw,{v:t,className:"bubble-state",asked:c,shownItem:n==null?void 0:n.item}),t.session&&s.jsx(DM,{session:t.session}),s.jsx(ay,{v:t}),s.jsx(Lw,{v:t})]})}function BM(e){const{need:t,pr:n}=e,i=Ju(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 FM={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"},zM=e=>e.split(`
166
+ `)[0].replace(/^[^\s:]+: /,"");function UM(e){if(e.questionId)return{kind:"question",questionId:e.questionId};const t=e.items.find(i=>i.kind!=="question");return t?{kind:"item",label:FM[t.kind]??"Needs you",title:zM(t.title),urgent:e.urgentOf(t),item:t}:{kind:"none"}}function WM(e){var S,x,$,N;const{api:t,t:n}=e,i=oy({snap:e.snap,t:n,api:t,sessions:e.sessions,attention:e.attention}),[o,c]=w.useState(null),d=ny({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=UM({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(bw,{q:i.question,now:i.now,keyOf:y,onAnswer:t.actions.answer,onOpenChat:e.onOpenChat}),u.kind==="item"&&s.jsx(BM,{need:u,now:i.now,pr:b}),s.jsx(_M,{v:i,need:HM(u,(N=i.question)==null?void 0:N.text)}),s.jsx(ey,{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 HM(e,t){if(e.kind==="item")return{text:e.title,item:e.item.title};if(e.kind==="question")return{text:t??""}}function KM(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(WM,{...e,snap:n,t:c},c.id):s.jsx(Te,{children:"Ticket not found."})}case"main":return n?s.jsx(sw,{mapId:n.map.id,now:o}):null;case"together":return n?s.jsxs(s.Fragment,{children:[s.jsx(KT,{text:n.map.sections.destination}),s.jsx(ow,{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(bw,{q:c,now:o,keyOf:d,onAnswer:i.actions.answer,onOpenChat:e.onOpenChat})}case"unspecified":return null;default:return t}}const Rg=14,$n=8;function GM(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+Rg,m=t.left-Rg-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 VM(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=GM({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 qM={ticket:"Ticket",main:"Checks on main",together:"Destination",question:"Question"};function QM(e){if(e.kind==="ticket")return e.id;if(e.kind==="main")return"main";if(e.kind==="together")return"destination"}function YM(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=QM(o),m=o.kind==="main"?e.mainNeeds:o.kind==="question"||c;return s.jsx(VM,{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:qM[o.kind],onClose:()=>n.select(null),children:s.jsx(KM,{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 JM=["plan","activity","logbook"],uy=[{id:"map",label:"Map"},{id:"plan",label:"Plan"},{id:"activity",label:"Activity"},{id:"logbook",label:"Logbook"}];function XM(e){var g;const{api:t,rt:n,brief:i}=e,{snap:o,actions:c}=t,[d]=Qu(15e3),u=As(),f=d?p2(d):void 0,m=s.jsx(TE,{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(EE,{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(AE,{tabs:uy,value:e.view,onChange:e.onView})]})}function ZM(e){return s.jsx(gE,{seed:e.seed,onClose:e.onClose,tracker:e.rt.adapter.label,onCreate:async t=>{const n=await M$(e.rt.adapter,t);return e.onCreated(n.id),n}})}const eL={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"},ih=e=>eL[e];function rh(e){var t;return((t=e.account)==null?void 0:t.kind)==="user"?e.account.login:void 0}const $d=e=>!!e.auth&&!!rh(e);function hy(e,t){const n=rh(e);return!e.auth||!n?void 0:`Will use ${t||"the repo you pick"} as ${n} (${ih(e.auth)})`}function tL(e){if(!e.repo)return;const t=rh(e),n=t?` as ${t}`:"",i=e.auth?`, using ${ih(e.auth)}`:"";return`Connected to ${e.repo}${n}${i}`}function nL(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 sL(e){const{gh:t}=e;if(!t.auth)return null;const n=hy(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 iL=/^[\w.-]+\/[\w.-]+$/;function rL(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=iL.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 Mg(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&&nL(t,e.now),!n&&"Checked when you connect"]}),onOpen:e.onPick})}const oL=40;function Lg(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}=rL({repos:e.repos,detected:e.detected,query:t,limit:oL}),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(Mg,{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(Mg,{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 aL(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(Lg,{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(Vu,{what:"Couldn't list your repos",reason:t.error,onRetry:e.onRetry}),s.jsx(Lg,{repos:[],truncated:!1,detected:e.detected,value:e.value,onChange:e.onChange})]});default:return t}}const cL={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 fy(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:cL[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 lL(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 dL(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 uL(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=qN(re());function yr(e,t){e({tracker:t});const n=new URL(location.href);n.searchParams.delete("tracker"),location.href=n.toString()}function hL(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(uL(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(dL(c)),c=>n({kind:"ended",reason:c.message}))},cancel(){n({kind:"idle"})}}}function fL(e){const{state:t,start:n,cancel:i}=hL(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(lL,{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 mL(e){var d,u;const{gh:t}=e,n=t.auth&&((d=t.account)==null?void 0:d.kind)==="unknown"?`Found ${ih(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(fL,{onSignedIn:e.onSignedIn}),c&&s.jsx("span",{className:"t-label gh-or",children:"Or paste a token"}),s.jsx(fy,{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 my({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 oh(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 pL(e){const{value:t,retry:n}=oh({enabled:e.enabled,key:e.auth??"",load:()=>Vt.githubRepos(),failed:i=>({kind:"error",error:i})});return{list:t,retry:n}}function py(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}=pL({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(mL,{gh:t,token:u,onToken:f,repo:c,onRepo:d,onSignedIn:$}):s.jsxs(s.Fragment,{children:[s.jsx(sL,{gh:t,repo:c,onUseAnother:()=>o(!0),onSignOut:()=>void N()}),s.jsx(aL,{list:b,detected:t.detectedRepo,value:c,onChange:d,onRetry:S})]}),s.jsx(my,{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 gL(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 kL={LINEAR_API_KEY:"LINEAR_API_KEY",stored:"a saved key"},ah=e=>kL[e]??e;function ac(e){return(e==null?void 0:e.kind)==="user"?e:void 0}const vL=e=>!!e.auth&&!!ac(e.viewer);function gy(e,t){if(e)return t?`${e} / ${t}`:e}function ky(e){const t=ac(e.viewer);if(!t)return;const n=gy(e.team,e.project)??"the team you pick",i=e.source?` (${ah(e.source)})`:"";return`Will use ${n} in ${t.orgName} as ${t.name}${i}`}function wL(e){const t=gy(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 ${ah(e.auth)}`:"";return`Connected to ${t}${o}${c}${d}`}function yL(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 xL(e){var o,c;const{ln:t}=e,n=t.auth&&((o=t.viewer)==null?void 0:o.kind)==="unknown"?`Found ${ah(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(fy,{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 jL(e){const{list:t}=e;if(!t)return s.jsx(yi,{label:"Loading projects…"});if(t.kind==="error")return s.jsx(Vu,{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 bL(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 SL(e,t){return t&&e.some(n=>n.id===t)?t:e.length===1?e[0].id:void 0}function NL(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},yL(t,e.now)]}),onOpen:e.onPick})}const $L=40;function CL(e){const[t,n]=w.useState(""),i=w.useMemo(()=>Date.now(),[]),{shown:o,matches:c}=bL({teams:e.teams,query:t,limit:$L}),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(NL,{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 TL(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(CL,{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(Vu,{what:"Couldn't list your teams",reason:t.error,onRetry:e.onRetry});default:return t}}function EL(e,t){const[n,i]=w.useState(e);return w.useEffect(()=>{const o=setTimeout(()=>i(e),t);return()=>clearTimeout(o)},[e,t]),n}function AL(e){const{value:t,retry:n}=oh({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 IL(e){const{value:t,retry:n}=oh({enabled:e.enabled,key:e.apiKey??"",load:()=>Vt.linearTeams(e.apiKey),failed:i=>({kind:"error",error:i})});return{list:t,retry:n}}function RL(e){const t=EL(e.apiKey.trim(),400),n=e.paste&&t?t:void 0,i=e.paste?!!t:!!e.ln.auth,o=IL({enabled:i,apiKey:n}),c=AL({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 vy(e){var be;const t=e.s.linear,n=vL(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}=RL({ln:t,paste:i,apiKey:c,teamId:u});w.useEffect(()=>{n&&!c&&o(!1)},[n]),w.useEffect(()=>{($==null?void 0:$.kind)==="ok"&&f(SL($.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=ky({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(xL,{ln:t,apiKey:c,onKey:d}),s.jsx(gL,{line:ee,email:(be=ac(Z))==null?void 0:be.email,onUseAnother:i?void 0:()=>o(!0)}),x&&s.jsx(TL,{list:$,value:u,onChange:ve,onRetry:F}),I&&s.jsx(jL,{list:O,value:m,onChange:g,onRetry:K}),s.jsx(my,{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 ML(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 LL(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 OL(e){const{id:t,active:n,s:i}=e,o=wr(t),c=n&&i?PL(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:LL(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:DL(t,i)}):null}function PL(e,t){if(e==="github")return tL(t.github);if(e==="linear")return wL(t.linear)}function DL(e,t){return e==="github"?t.github.repo:[t.linear.teamKey,t.linear.projectName].filter(Boolean).join(" · ")}function _L({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]=BL(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 BL(e,t){switch(e.state){case"online":return["ok",`Online · synced ${Av(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 FL(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(OL,{id:t,active:n,configured:i,location:e.location,s:o}),c&&n&&s.jsx(_L,{status:o==null?void 0:o[t].status}),s.jsx(ML,{canSwitch:!n&&(!c||i),remote:c,usable:d,configured:i,open:e.open,onSwitch:e.onSwitch,onToggle:e.onToggle})]})}function wy(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 zL(e){const[t,,n]=wy(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:QN.map(u=>{const f=u.id;return s.jsx(FL,{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(py,{s:t,reload:n,onConnected:()=>yr(e.update,"github")}),t&&i==="linear"&&s.jsx(vy,{s:t,onConnected:()=>yr(e.update,"linear")})]})}function UL(e,t){const n=e==null?void 0:e.github,i=e==null?void 0:e.linear,o=n&&t!=="github"?hy(n,n.repo??n.detectedRepo):void 0,c=i&&t!=="linear"?ky({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 yy(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 WL={github:"Checking for a GitHub login…",linear:"Checking for a Linear key…"};function HL(e){var $;const{prefs:t,update:n}=e,[i,,o]=wy(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=UL(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(hT,{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:WL[t.tracker]??"Checking…"}),i&&t.tracker==="github"&&!y&&s.jsx(py,{s:i,reload:o,onConnected:()=>S("github")}),i&&t.tracker==="linear"&&!y&&s.jsx(vy,{s:i,onConnected:()=>S("linear")})]}),s.jsx(Ae,{title:"HITL transcript",children:s.jsx(yy,{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 KL(e){var t;return(t=pt())!=null&&t.tracker?null:s.jsx(HL,{...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 ch(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 GL(e,t){const n=new URL(e);return n.searchParams.set("when",t.when.join(",")),n.searchParams.set("why",t.why),n.toString()}function VL(e,t){var i;const n=String((i=ch("rules"))==null?void 0:i.section)==="rules";e(n?"rules":"verification"),history.replaceState(history.state,"",GL(location.href,t))}function qL(){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 Og={from:"18:00",to:"09:00"};function QL(e){const t=e.focus!==void 0,n=e.focus??Og;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:Og),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 YL(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 Pg=e=>`${e} finished ticket${e===1?"":"s"}`;function JL(e,t){const n=(e==null?void 0:e.waiting.length)??0;return t?e!=null&&e.full?`${Pg(n)} wait: agents start no new implementation work until you review some.`:`${n} of ${t} waiting: agents start new work.`:n?`${Pg(n)} wait for your review now.`:"Nothing waits for your review now."}function XL(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:YL(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. ",JL(n,t)]})]})}const ZL=[{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 eO(){typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()}function tO(){const{view:e,error:t,savePrefs:n,saveReviewLimit:i}=ww(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:ZL,onChange:m=>{m==="browser"&&eO(),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(QL,{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(XL,{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 nO=[5,15,30,60];function sO(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})}),nO.map(n=>s.jsx(at,{on:t.enabled&&t.awayMinutes===n,title:`Away ${n} min`,onClick:()=>e.onChange({enabled:!0,awayMinutes:n})},n))]})}const iO={repo:"Committed to the repo",machine:"Only on this machine",browser:"Only in this browser"};function He(e){const t=e.storage&&iO[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 rO(e){const[t]=Qu();return t?s.jsx(Ae,{title:"Slack",children:s.jsx(m2,{focus:e.focus})}):null}function oO({data:e,route:t}){return s.jsxs(s.Fragment,{children:[s.jsx(He,{id:"attention",storage:"repo",children:s.jsx(tO,{})}),s.jsx(He,{id:"slack",storage:"machine",children:s.jsx(rO,{focus:t.section==="slack"})}),s.jsx(He,{id:"trip-report",storage:"browser",children:s.jsx(Ae,{title:"Trip report",children:s.jsx(sO,{value:e.prefs.briefing,onChange:n=>e.update({briefing:n})})})})]})}const aO=[{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"]}],cO=[{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"]}],lO=[{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"]}],dO=[{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"]},...lO],uO=[{area:"Teamtrail Cloud",items:["The Lookout as an app on your phone, with a nudge only for the calls that need you"]}],hO=[{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"]},...aO,...cO,...dO];function fO(){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:uO.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))}),hO.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 Dg={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"},_g={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 xy(e){return e.kind==="state"?mO(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 mO(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 pO="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 gO(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 kO=["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 vO(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 wO(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 yO=e=>e.files??(e.file?[e.file]:[]);function xO(e){const{item:t}=e,[n,i]=w.useState(!1),o=yO(t),c=t.revert??"restore";return s.jsx(fe,{as:"li",className:"ap-row",edge:"attention",title:t.title,context:s.jsx(_,{parts:[xy(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(wO,{files:o,busy:e.busy,onDelete:()=>(i(!1),e.onRevert(o)),onCancel:()=>i(!1)})]})})}function jO(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 bO(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 SO(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:[xy(t)]}),detail:Dg[t.kind],detailText:Dg[t.kind],below:s.jsxs("div",{className:"ap-below",children:[s.jsx("pre",{className:"ap-lines t-code",children:o.join(`
171
+ `)}),_g[t.kind]&&s.jsx("p",{className:"ap-note t-meta",children:_g[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",{...bO("verification"),children:"Edit checks"})}),e.local&&s.jsx(R,{size:"sm",disabled:e.busy,onClick:e.onApprove,children:"Approve"})]})})}async function Bg(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 Fg(){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 NO=(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 $O(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 CO(){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 Fg().then(S,()=>S(null))},[d]),m=w.useCallback(async()=>{if(c.current)return;const b=u.current,S=await Fg().catch(()=>null),x=o.current;u.current!==b||x===void 0||(!S||!x||!NO(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=>$O(await g(()=>Bg("/trust/approve",{items:b.map(S=>({key:S.key,hash:S.hash}))}))),[g]),y=w.useCallback(async(b,S)=>{await g(()=>Bg(b,S))},[g]);return{view:e,changed:n,load:f,approve:k,act:y}}function TO(){const{view:e,changed:t,load:n,approve:i,act:o}=CO(),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:gO(x.length)}),k.some(N=>N.kind==="state")&&s.jsx("p",{className:"ap-note t-meta",children:pO}),$>0&&s.jsxs("ul",{className:"ap-list",children:[y&&s.jsx(jO,{tracker:y,busy:d,local:c,onDecide:N=>g(o("/trackers/approval",{use:N,target:y.target}))}),b&&s.jsx(vO,{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(xO,{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(SO,{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:kO})]})}const jy="0.64.1",du="<endpoint>",lh=Ck(jy,["mcp","--http"]);function EO(e,t){const n=Ck(jy,["connect",e,"--url"]),i=t===du?t:$k(t);return`read -rs ${J.tokenEnv} && export ${J.tokenEnv}
172
+ ${n} ${i}`}function AO(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 IO({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},...AO(n)]})},n.url)),!t&&s.jsx("li",{children:s.jsx(_,{className:"set-hint",parts:["For agents on other machines, start their server",{text:lh,code:!0}]})})]})}function RO(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 MO(){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 LO(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 OO(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(LO,{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 PO=[{id:"claude",label:"Claude Code"},{id:"codex",label:"Codex"}];function DO(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:lh,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:PO.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:EO(t,e.endpoint??du),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 ${du}.`,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 by=`${re()}/remote-agents`;async function zg(e,t){const n=await fetch(`${by}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return{ok:n.ok,reply:await n.json()}}async function _O(){const e=await fetch(by);return e.ok?await e.json():(await e.json().catch(()=>({}))).elsewhere?"elsewhere":null}function BO(){const[e,t]=w.useState(),[n,i]=w.useState(),{pushed:o}=Pe({load:_O,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 zg("/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 zg("/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 FO(){var d;const{view:e,created:t,dismissCreated:n,create:i,revoke:o}=BO();if(!e)return null;if(e==="elsewhere")return s.jsx(MO,{});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(IO,{endpoints:e.endpoints}),t&&s.jsx(DO,{created:t,endpoint:c,onDone:n}),s.jsx(OO,{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(RO,{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:lh}),", 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 Ug={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"},zO={low:"the agent decides",medium:"the agent decides and records it",high:"you decide"},UO=e=>e[0].toUpperCase()+e.slice(1),uu=tv.map(e=>({value:e,label:UO(e),hint:zO[e]}));function WO(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:uu,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:uu,onChange:o}),s.jsx(R,{onClick:u,disabled:!t.trim(),children:"Add"})]})]})}const Sy=`${re()}/policy`;async function HO(){const e=await fetch(Sy);return e.ok?await e.json():null}function KO(){const[e,t]=w.useState(),{pushed:n}=Pe({load:HO,show:t,failed:()=>t(null),changed:o=>o.endsWith("policy.json")}),i=w.useCallback(async o=>{const c=await fetch(Sy,{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 GO(){const{view:e,save:t}=KO(),[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:ev.map(d=>s.jsxs("label",{className:"risk-row",children:[s.jsx("span",{children:Ug[d]}),s.jsx(it,{compact:!0,"aria-label":`${Ug[d]} risk`,value:e.policy.categories[d],options:uu,onChange:u=>c({...e.policy,categories:{...e.policy.categories,[d]:u}})})]},d))}),s.jsx(WO,{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 VO(){const{view:e,save:t,remove:n}=Xw(),[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},Wg(e.workspaces.filter(u=>u.active).length,"active"),Wg(e.workspaces.filter(u=>!u.active).length,"finished")]}),s.jsx(dR,{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 Wg=(e,t)=>`${e} ${t}`;function qO({data:e,route:t}){var n;return s.jsxs(s.Fragment,{children:[s.jsx(He,{id:"approvals",storage:"machine",children:s.jsx(TO,{})}),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(zL,{activeTracker:e.activeTracker,location:e.location,update:e.update})})}),s.jsx(He,{id:"workspaces",storage:"repo",children:s.jsx(VO,{})}),s.jsx(He,{id:"proof",storage:"machine",children:s.jsx(mA,{})}),s.jsx(He,{id:"remote-agents",storage:"machine",children:s.jsx(FO,{})}),s.jsx(He,{id:"policy",storage:"repo",children:s.jsx(GO,{})}),s.jsx(He,{id:"guides",storage:"repo",children:s.jsx(wI,{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:wu}),s.jsxs("code",{children:[J.labelPrefix,":<type>"]}),s.jsx("code",{children:yu}),s.jsx("code",{children:xu})]})})})]})}const hu=`${J.apiPrefix}/projects`;async function fr(e,t,n){const i=await fetch(`${hu}${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:hu,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(`${hu}/briefing?since=${e}`);return t.ok?await t.json():void 0}};function Ny(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 QO(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 YO(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 JO(e){const{item:t}=e,n=Ju(t),i=t.kind==="question"&&t.agent?`${t.agent} asks`:Yu[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(YO,{onAnswer:e.onAnswer})})}function XO(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(JO,{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 ZO(e){return e.interrupting>0?"urgent":e.phases.blocked+e.phases.rework+e.flags+e.stalled>0||e.state.kind==="missing"?"attention":"neutral"}function eP(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=tP(e.tracker);return d&&t.push(d),t}function tP(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 nP(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=I$({id:e.id,home:t,tracker:e.tracker.kind,item:n})}}function $y(e){const{p:t}=e,n=nP(t);return s.jsx(fe,{as:"li",className:`project-card st-${t.state.kind}`,edge:ZO(t),selected:e.current,title:t.name,titleText:t.path,context:s.jsx(_,{parts:eP(t)}),detail:n,detailText:n,trailing:t.lastActivity?Je(e.now-t.lastActivity):void 0,onOpen:e.onOpen})}const Cy=`${Ma}:projects:seen`,Hg=24*36e5;function sP(e){try{const t=Number(localStorage.getItem(Cy));return t>0?t:e-Hg}catch{return e-Hg}}function iP(e){try{localStorage.setItem(Cy,String(e))}catch{}}function rP(){const[e,t]=w.useState();return w.useEffect(()=>{const n=Date.now();return Ns.briefing(sP(n)).then(t).catch(()=>{}),()=>iP(n)},[]),e}function oP(e){const{view:t,reload:n}=e.projects,i=gt(15e3),o=rP();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(XO,{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($y,{p:f,current:f.id===c,now:i,onOpen:f.state.kind==="missing"?void 0:()=>d(f.id)},f.id))}),s.jsx(Ny,{onAdded:n})]}),s.jsx(QO,{briefing:o,now:i,onOpen:d})]})]})}function aP(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:cP(u.state.kind)}),s.jsx(bs,{n:u.needsYou,urgent:u.interrupting>0,hideZero:!0})]},u.id))]})]})}function cP(e){return e==="missing"?"missing":e==="elsewhere"?"other Lookout":""}function lP(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($y,{p:o,current:!1,now:t,onOpen:o.state.kind==="missing"?void 0:()=>Ea(o,n.home)},o.id))})]})}async function dP(){const e=await fetch(Ns.url);return e.ok?await e.json():void 0}function Ty(){const[e,t]=w.useState(),{reload:n,pushed:i}=Pe({load:dP,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 uP=e=>[e.home&&{text:"This Lookout",strong:!0},e.state.kind==="missing"&&"Missing",{text:e.path,code:!0}];function hP(){const{view:e,reload:t}=Ty(),[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:uP(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(Ny,{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 fP(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 Kg=e=>`${e} ticket${e===1?"":"s"}`;function mP(e,t){const n=`in the last ${t} days`,i=e.held?`Held ${Kg(e.held)}`:"",o=e.wouldHold?`would have held ${Kg(e.wouldHold)}`:"";return i&&o?`${i}, ${o} ${n}`:i?`${i} ${n}`:o?`W${o.slice(1)} ${n}`:`Nothing held ${n}`}const pP={enforce:"Held",observe:"Would have held"};function gP(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},pP[n.mode]]}),trailing:is(n.at,t),onOpen:o?()=>e.onOpenTicket(n.mapId,o):void 0},`${n.at}-${i}`)})})})}const Ey={"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=>Gk.includes(e);function kP(e){return Cr(e)?Ey[e].title:e}function vP(e){return Cr(e)?Ey[e].about:void 0}const Gg={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 wP(e){return s.jsx("div",{className:"gate-modes",role:"radiogroup","aria-label":`${e.label} mode`,"data-gate":e.gate,children:Qb.map(t=>s.jsx("button",{type:"button",role:"radio","aria-checked":e.value===t,className:ue("gate-mode",e.value===t&&"on"),title:Gg[t].tip,disabled:e.disabled,onClick:()=>e.value!==t&&e.onChange(t),children:Gg[t].label},t))})}function yP(e){const{summary:t}=e,n=kP(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:[vP(t.gate)]}),detail:e.days?mP(t,e.days):void 0,below:s.jsxs(s.Fragment,{children:[i&&s.jsx(wP,{gate:t.gate,label:n,value:e.mode,disabled:e.locked,onChange:e.onMode}),s.jsx(gP,{entries:t.entries,onOpenTicket:e.onOpenTicket})]})})}function Vg(e){return new Set(e.map((t,n)=>t.ticketId?`${t.mapId}/${t.ticketId}`:`#${n}`)).size}function xP(e){const t=[...e].sort((i,o)=>o.at-i.at),n=[...Gk];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:Vg(o.filter(c=>c.mode==="enforce")),wouldHold:Vg(o.filter(c=>c.mode==="observe")),entries:o}})}async function jP(){const e=await fetch(`${re()}/verification/gates`);return e.ok?await e.json():null}function bP(){const[e,t]=w.useState();return Pe({load:jP,show:t,failed:()=>t(null),changed:n=>n.endsWith("verification.json"),events:{verification:()=>!0,attention:()=>!0}}),e}async function SP(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 NP(e){var x,$;const{view:t,reload:n}=eh(),i=bP(),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=fP({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:Yb(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 SP(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:xP((i==null?void 0:i.entries)??[]).map(N=>s.jsx(yP,{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 $P({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"},CP={fast:"Haiku, mini and nano models",balanced:"Sonnet, GPT-4 models",strongest:"Opus, GPT-5 and o-series models"},TP=ha.map(e=>({value:e,label:xr[e],hint:CP[e]}));function EP(e){return s.jsx("div",{className:"tier-grid",children:rs.map(t=>{const n=e.tiers[t],i=bu[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:TP,onChange:o=>e.onChange(t,o)}),s.jsx(_,{className:"tier-hint",parts:[n!==i&&`default ${xr[i].toLowerCase()}`,e.hints[t]]})]},t)})})}async function AP(){const e=await fetch(`${re()}/flaky-checks`);return e.ok?await e.json():null}function IP(){const[e,t]=w.useState();return Pe({load:AP,show:t,failed:()=>t(null),events:{verification:()=>!0},changed:n=>n.includes("/tickets/")}),e}const RP={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 MP(){const e=IP();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. ",RP[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 LP({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 OP=e=>`${Math.round(e*100)}%`;function PP({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:[OP(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 DP({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 _P(e){return e.escapes.length?s.jsxs("ul",{className:"perf-rows",children:[e.checks.map(t=>s.jsx(PP,{r:t,minSample:e.minSample},t.key)),e.escapes.map(t=>s.jsx(DP,{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)}%`,BP=e=>e===void 0?void 0:`$${e.toFixed(2)} per verified`;function FP({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`,BP(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 zP({rows:e,minSample:t}){return e.length?s.jsx("ul",{className:"perf-rows",children:e.map(n=>s.jsx(FP,{r:n,minSample:t},n.key))}):s.jsx(Te,{children:"No completions yet. The scorecard fills in as agents finish verified tickets."})}async function UP(){const e=await fetch(`${re()}/scorecard`);return e.ok?await e.json():null}function Ay(){const[e,t]=w.useState();return Pe({load:UP,show:t,failed:()=>t(null),events:{verification:()=>!0},changed:n=>n.includes("/tickets/")}),e}const WP=[{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 HP(){const e=Ay(),[t,n]=w.useState("byTypeAndModel"),[i,o]=w.useState(!1);if(e==null)return null;const c=()=>void navigator.clipboard.writeText(K1(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:WP.map(d=>s.jsx(at,{on:t===d.id,title:d.title,onClick:()=>n(d.id)},d.id))}),t==="cameBack"?s.jsx(_P,{checks:e.byCheck??[],escapes:e.escapes??[],minSample:e.minSample}):s.jsx(zP,{rows:e[t]??[],minSample:e.minSample})]})}function Iy(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 KP=[{id:"byVendor",title:"By vendor"},{id:"byAgent",title:"By agent"},{id:"byType",title:"By ticket type"}];function GP({api:e,bp:t,onClose:n}){const[i,o]=w.useState("byVendor"),c=w.useMemo(()=>Object.values(e.allSnaps),[e.allSnaps]),d=Iy(c),u=e.activity.answered,f=w.useMemo(()=>lv(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(HP,{}),s.jsx(MP,{}),s.jsxs("section",{className:"perf-section",children:[s.jsx("div",{className:"choice-row compact",children:KP.map(m=>s.jsx(at,{on:i===m.id,title:m.title,onClick:()=>o(m.id)},m.id))}),s.jsx(LP,{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 VP(e){const t=Ay();if(!t)return null;const n=U1({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 qP(e,t){const n=Iy(e);return w.useMemo(()=>{var c;const i=lv(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 QP(e){var u,f;const t=sh(),n=qP(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===bu[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(EP,{tiers:xp(i),hints:n,onChange:d}),o&&s.jsx(VP,{tiers:xp(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($P,{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 fu=e=>e.trim().split(/\s+/).filter(Boolean);function YP(e){return e.rows.map((t,n)=>{const i=fu(t.command).join(" ");return e.findings.filter(o=>o.check===String(n)&&o.command===i)})}function JP(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 XP=[{name:"test",command:"npm test"},{name:"lint",command:"npm run lint"},{name:"typecheck",command:"npm run typecheck"}];function ZP(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"}),XP.map(t=>s.jsx("button",{type:"button",className:"chip t-code",onClick:()=>e.onAdd(t),children:t.command},t.name))]})]})}function e3(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 t3(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 n3({view:e}){const[t,n]=w.useState(()=>t3(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:fu(S.command),cwd:(N=($=e.config)==null?void 0:$.checks[S.name])==null?void 0:N.cwd}}),k=Vw(g),y=YP({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:fu(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(JP,{check:S,findings:y[x],focus:i&&x===t.length-1,onChange:$=>m(x,$),onRemove:()=>n(t.filter(($,N)=>N!==x))},x))}),s.jsx(ZP,{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(e3,{sure:c,onSure:d,state:u,onSave:()=>void b()})]})}function s3({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 i3=[{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 r3({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:i3.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 o3(e){var c;const{view:t,local:n,file:i}=e,o=t.config;return s.jsxs(s.Fragment,{children:[n&&s.jsx(n3,{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(s3,{config:o,file:i,hash:t.hash}),!n&&s.jsx(ic,{findings:t.screening??[],named:!0}),o&&t.exists&&s.jsx(r3,{view:t,local:n})]})}function a3(e){var g;const{view:t}=eh(),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:ju.map(k=>s.jsx(at,{on:f===k,title:Pr[k],sub:Zu[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(o3,{view:t,local:n,file:u}),c&&s.jsx(OT,{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 c3({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(Z2,{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(a3,{map:t})}),s.jsx(He,{id:"gates",storage:"repo",children:s.jsx(NP,{onOpenTicket:e.onOpenTicket})}),s.jsx(He,{id:"rules",storage:"repo",children:s.jsx(uA,{})}),s.jsx(He,{id:"models",children:s.jsx(QP,{map:t,snaps:e.snaps,answered:e.answered,onChange:e.onModelMatching})}),t&&s.jsx(He,{id:"trail-guides",children:s.jsx(TI,{map:t})})]})}const Qg=10,Ry=[0,10,16,26,18,24,16,18,22,22,26],My=[0,1,1,1,2,2,4,4,4,5,5];function Ly(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 l3=e=>Ry[e],d3=e=>My[e],Oy=e=>Math.floor(Ly(e)/8)-Ry[e]*My[e],Py=e=>e<10?8:16;function u3(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 mu(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 h3(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]=mu(t[o],n),o+1<t.length&&(t[o]^=t[o+1]);n=mu(n,2)}return t}function f3(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]^=mu(c,o))}return n}function m3(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,Py(t));for(const d of e)i(d,8);const o=Oy(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 p3(e,t){const n=m3(e,t),i=d3(t),o=l3(t),c=Math.floor(Ly(t)/8),d=i-c%i,u=Math.floor(c/i),f=h3(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=f3(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 g3=[(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=g3[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 Yg(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 k3(e){let t=0,n=0;for(let o=0;o<e.size;o++)t+=Yg(e.dark[o]),t+=Yg(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 v3(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 pu(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 w3(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 y3(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=u3(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||v3(i,o[d],o[u]);return pu(i,0),w3(i,e),i}function x3(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 j3(e,t){let n=0;for(const[i,o]of x3(e.size))e.fixed[o][i]||n>=t.length*8||(e.dark[o][i]=mn(t[n>>>3],7-(n&7)),n++)}function b3(e){const t=new TextEncoder().encode(e);let n=1;for(;n<=Qg&&4+Py(n)+t.length*8>Oy(n)*8;)n++;if(n>Qg)return;const i=y3(n);j3(i,p3(t,n));let o=0,c=1/0;for(let d=0;d<8;d++){Id(i,d),pu(i,d);const u=k3(i);u<c&&([o,c]=[d,u]),Id(i,d)}return Id(i,o),pu(i,o),i.dark}const Md=4;function S3(e){const t=b3(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 N3(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(S3,{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 $3(e){const[t,n]=w.useState();return e.device?s.jsx(N3,{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 C3(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 T3={machine:"This machine",device:"Another device"};function E3(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:[T3[n.kind],n.via==="opened-page"?`From the page ${J.name} opened`:void 0,n.via==="opened-page"?{text:e1(n.id),code:!0}:void 0,`Paired ${is(n.pairedAt,t)}`,`Last used ${is(n.lastUsedAt,t)}`]}),below:n.current?void 0:s.jsx(C3,{name:n.name,onRevoke:()=>e.onRevoke(n.id)})},n.id))})}function A3(){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 Dy=`${J.apiPrefix}/sign-in`;async function Ld(e,t={}){const n=await fetch(`${Dy}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return{ok:n.ok,reply:await n.json().catch(()=>({}))}}function I3(){const[e,t]=w.useState(),[n,i]=w.useState(),o=w.useCallback(()=>{fetch(`${Dy}/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"),Lv(),location.reload()},[]);return{view:e,device:n,closeDevice:()=>(i(void 0),o()),pairDevice:c,revoke:d,signOut:u}}function R3(){const{view:e,device:t,closeDevice:n,pairDevice:i,revoke:o,signOut:c}=I3();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(E3,{sessions:e.sessions,onRevoke:o}),s.jsx($3,{lan:e.lan,device:t,onPair:i,onDone:n}),d,s.jsx(A3,{})]})}function M3({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 L3(){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 dh(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&&X$({id:n.id,secret:n.session,verifier:n.verifier})}function O3(e){const[t,n]=w.useState(!1),i=async()=>{n(!0);const o=await dh(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 Jg(){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 dh(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 Xg(){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 P3(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(Xg,{}):s.jsx(Jg,{}),e.local?s.jsx(Jg,{}):s.jsx(Xg,{})]})}function D3(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(O3,{code:i,onFailed:u}):s.jsx(P3,{local:e.local})]})})}function Zg(){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 ek(){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&&K$(t)?{kind:"signed-in"}:{kind:"signed-out",local:t.local===!0}}catch{return{kind:"no-server"}}}async function _3(){if(!Pu())return ek();const e=await Va();return e==="proven"?{kind:"signed-in"}:e==="unknown"?ek():{kind:"not-running"}}function B3(){const[e,t]=w.useState({kind:"checking"});return w.useEffect(()=>void _3().then(t),[]),w.useEffect(()=>Z$(n=>n==="failed"&&t({kind:"not-running"})),[]),e}function F3({children:e}){const t=B3(),[n,i]=w.useState(Zg);return w.useEffect(()=>{const o=()=>i(c=>Zg()??c);return window.addEventListener("hashchange",o),()=>window.removeEventListener("hashchange",o)},[]),w.useEffect(()=>{t.kind==="signed-in"&&n&&dh(n)},[t.kind,n]),t.kind==="checking"?null:t.kind==="signed-out"?s.jsx(D3,{local:t.local,code:n}):t.kind==="not-running"?s.jsx(L3,{}):s.jsx(s.Fragment,{children:e})}function z3(){const e=pt();return e?s.jsx(M3,{managed:e}):s.jsx(He,{id:"devices",storage:"machine",children:s.jsx(R3,{})})}const U3=[{value:"auto",title:"Match my system"},{value:"day",title:"Day"},{value:"night",title:"Night"}];function W3(e){return s.jsx("div",{className:"choice-row compact",children:U3.map(t=>s.jsx(at,{on:e.value===t.value,title:t.title,onClick:()=>e.onChange(t.value)},t.value))})}function H3({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:[Qv()?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(W3,{value:Yv(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(yy,{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:jv.map(o=>s.jsx(at,{on:o.status==="primary",disabled:o.status!=="primary",title:o.name},o.id))})})}),s.jsx(z3,{})]})}function K3(e){const{data:t,route:n}=e;switch(e.group){case"trail":return s.jsx(c3,{data:t});case"project":return s.jsx(qO,{data:t,route:n});case"alerts":return s.jsx(oO,{data:t,route:n});case"you":return s.jsx(H3,{data:t});case"projects":return s.jsx(He,{id:"projects",storage:"machine",children:s.jsx(hP,{})});case"about":return s.jsx(He,{id:"changelog",children:s.jsx(fO,{})});default:return e.group}}function G3(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(K3,{group:t.id,data:e.data,route:n})]})})}function V3(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 q3(e,t){return e.group?$r.find(n=>n.id===e.group):t==="mobile"?void 0:$r[0]}const Q3={page:"Back to the Lookout",list:"Lookout",group:"Settings"},Y3=(e,t)=>e?t?"group":"list":"page";function J3(e){const{bp:t,route:n}=e,i=t==="mobile",o=q3(n,t),c=Y3(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(V3,{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:["‹ ",Q3[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(qL,{}),s.jsxs("div",{className:"sp-body",children:[m,o&&s.jsx(G3,{group:o,data:e.data,route:n})]})]})}function X3(e){var o;const{rt:t,api:n,settings:i}=e;return i.route?s.jsx(J3,{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 Z3(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(OM,{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 e4(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(dy,{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 t4(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(uw,{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 n4(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:HE(i,e.keyOf)},i.id)),n>0&&s.jsxs("button",{type:"button",className:"need-chip more",onClick:e.onMore,children:["+",n]})]}):null}function s4(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 i4(e){const t=[...e.values()].filter(i=>i.tone!=="cancelled"),n=s4(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 r4(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 o4(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 tk={done:"done",working:"an agent is on it",needs:"needs you","waiting-agent":"waiting for an agent","not-started":"not started"};function a4(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} · ${tk[t.tone]}`,"aria-label":`${t.key} ${t.title}: ${tk[t.tone]}`,onClick:()=>e.onSelect(t.id)},t.id))})}function c4(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(a4,{segments:e.segments,selected:e.selected,onSelect:e.onTicket}),s.jsx("span",{className:"trail-counts",children:o4(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(n4,{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 l4=6;function d4(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,l4)}function u4(e){const t=d4(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 _y="teamtrail.trail-bar.more";function h4(){try{return localStorage.getItem(_y)==="yes"}catch{return!1}}function f4(){const[e,t]=w.useState(h4);return[e,i=>{t(i);try{localStorage.setItem(_y,i?"yes":"no")}catch{}}]}function m4(e){const{api:t,nav:n,attn:i,trail:o}=e,[c,d]=f4(),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(c4,{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(qE,{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(t4,{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(e4,{working:g,now:u,onTicket:k,onOpenChat:S=>n.openChat(S)}),s.jsx(u4,{live:m,now:u,onTicket:k})]})}):null}function p4(e,t){const[n,i]=w.useState(!1);return{open:()=>i(!0),startOver:d=>void t.actions.setArchived(!0).then(()=>i(kE(d))),dialog:n&&s.jsx(ZM,{rt:e,seed:typeof n=="object"?n:void 0,onClose:()=>i(!1),onCreated:d=>t.actions.selectMap(d)})}}const g4=390;function nk(e){return e>900?g4:0}function k4(){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 uh(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 v4(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 w4(e,t){const n=hS({...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 y4(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 x4=6;function By(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(x4,sk(c,d)/2,sk(d,u)/2),m=ik(d,c,f),g=ik(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 sk(e,t){return Math.abs(e.x-t.x)+Math.abs(e.y-t.y)}function ik(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 By(j4({a:i,b:o,obstacles:c,gap:e.gap,gapIn:e.gapIn??e.gap}).map(n))}function j4(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=y4({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 b4(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 rk=e=>e.ticket.state==="closed"&&e.ticket.closeReason==="completed";function S4(e){const{from:t,to:n,direction:i}=e,c=["edge",t.ticket.state!=="open"?"edge-done":"edge-open"];return rk(t)&&rk(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:b4({direction:i,from:t,to:n,cards:e.cards})})}function N4(e){const{snap:t,tickets:n,direction:i,preview:o}=e,c=w.useMemo(()=>w4(t,n),[t,n]),d=w.useMemo(()=>uh(e.nodes),[e.nodes]);return e.edges.map(({from:u,to:f})=>{const m=Aa(u.ticket.id,f.ticket.id);return s.jsx(S4,{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 $4(e,t,n){return!!t&&e.state==="frontier"&&!n}const hh=24,C4=13,T4=9.5;function E4(e){const t=e.guide;return s.jsx("g",{className:"meta",transform:`translate(${hh} ${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:C4,rx:3}),s.jsx("text",{x:(n.w-n.textW)/2,y:T4,textLength:n.textW,lengthAdjust:"spacingAndGlyphs",children:n.text})]},i)})})}function A4(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 Fy=5,I4={sans:"9.5px 'Figtree Variable', system-ui, sans-serif",mono:"8.55px 'JetBrains Mono Variable', ui-monospace, monospace"};let mr;function R4(){if(mr!==void 0)return mr;try{mr=typeof document>"u"?null:document.createElement("canvas").getContext("2d")}catch{mr=null}return mr}function M4(e,t="sans"){const n=R4();return n?(n.font=I4[t],n.measureText(e).width*1.04):e.length*Fy}const ok=4,ak=3,L4=6;function O4(e){var k;const t=Oe-hh-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*ok-(i.length-1)*ak,c=y=>M4(y.text,y.kind==="key"?"mono":"sans"),d=i.filter(y=>y.kind!=="guide").reduce((y,b)=>y+c(b),0),u=Math.max(L4,Math.floor((o-d)/Fy)),f=i.map(y=>y.kind==="guide"?{...y,text:XA(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*ok,textW:b};return g+=S.w+ak,S})}function P4(e,t,n){return{text:[e.agent,n,t?`${e.step}/${e.total}`:void 0].filter(Boolean).join(" · "),tone:"agent"}}function D4(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?P4(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:Iv[t.state],tone:""}}function _4(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&&A4(n.waitsOn,n.waitsOnYours),m=S=>i?void 0:D4({n:t,session:n==null?void 0:n.session,waiting:e.waiting,need:c&&yw(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:O4({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 B4(e,t,n){const i=e.state==="frontier"||e.state==="rework";if(!(!t||n||e.ticket.assignee||!i))return t}function F4(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 z4({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 U4={claimed:"working",verifying:"working",frontier:"ready",blocked:"backlog",parked:"backlog",decided:"done","out-of-scope":"cancelled",rework:"attention",held:"attention"};function W4(e){const t=U4[e.state];return t==="done"||t==="cancelled"?t:e.attention?"attention":e.live?"working":t}function H4({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 zy(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 K4({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 G4(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 V4=26;function q4({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=G4(y.title,V4),x=gi(y)==="hitl",$=!!(b!=null&&b.waitingOn),N=!!u&&u!=="unchanged",O=B4(e,m,!!b),D=$4(e,k,!!b),F=EI(Kk(y).find(be=>{var ae;return!((ae=y.guidesRemoved)!=null&&ae.includes(be))})),K=x&&!N&&(y.type==="task"||y.type==="execute"),I=Q4(u,f),Q=_4({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=W4({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:F4({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(z4,{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(K4,{step:b.step,total:b.total}),s.jsx(zy,{tone:ee,cy:ve-4,verified:g,spin:Se,pulse:!!b&&!$}),S.map((be,ae)=>s.jsx("text",{className:"title",x:hh,y:ve+ae*14,children:be},ae)),s.jsx(E4,{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(H4,{mark:u,frozen:f})]})}function Q4(e,t){return(e&&e!=="unchanged"&&e!=="cancelled"?44:0)+(t?12:0)}function fh(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 ck=16,lk=8;function Uy(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-ck:o.x+o.w+ck,d=n==="before"?c+lk:c-lk,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:By(f),at:u({x:c,y:o.y+o.h/2})}}function Wy(e){const{whole:t,single:n}=fh(e);if(t.length)return;const i=n.filter(c=>c.ticket.type!=="review"),o=i.length===1?i[0]:Y4(n);if(o)return e.direction==="LR"?o.y+ze/2:o.x+Oe/2}const Y4=e=>e.length===1?e[0]:void 0,li=62,di=26,gu={LR:{x:130,y:0},TB:{x:0,y:84}},J4={LR:96,TB:48};function X4(e,t){return t?gu[e]:{x:0,y:0}}function Z4(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}=fh({groups:i,nodes:n,ends:o}),u=uh(n),f=J4[t],m=Wy({direction:t,nodes:n,groups:i,ends:o}),g=t==="LR"?{x:-gu.LR.x+20,y:(m??e.graphH/2)-di/2}:{x:(m??e.width/2)-li/2,y:-gu.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 $=Uy({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 eD(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 tD={LR:96,TB:48};function nD(e){const t=Wy({...e,ends:Hy(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 Hy(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 sD(e,t){const{direction:n}=e,{whole:i,single:o}=fh({groups:e.groups,nodes:e.nodes,ends:Hy(e)}),c=uh(e.nodes),d=tD[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=Uy({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 Ky(){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 iD(e){const{x:t,y:n,text:i,done:o,onSelect:c}=e,d=i&&Ku(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(Ky,{}):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 rD({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 oD(e){const{laid:t,spot:n,done:i}=e,o=!!i&&i.kind!=="not-done";return s.jsxs(s.Fragment,{children:[s.jsx(rD,{trails:sD(t,n),travelled:o}),t.nodes.length>0&&s.jsx(iD,{x:n.x,y:n.y,text:e.text,done:i,selected:e.selected,onSelect:e.onSelect})]})}const Ra=.95;function aD(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 dk(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 cD(e){const{fit:t,nodes:n,size:i,pad:o}=e;if(t.k>=Ra)return t;const c=aD(n,e.focus??[]);if(!c.length)return t;const d=Ra,u=Math.max(i.w/2,i.w-(e.room??0)),f=dk(c,o),g=(f.right-f.left)*d<=u-32&&(f.bottom-f.top)*d<=i.h-32?f:dk(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 lD(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,uk=4,dD=220,oi=e=>Math.round(e/uk)*uk;function uD(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 hD(e){const{width:t,height:n,nodes:i}=e,o=uD(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<dD&&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 Gy={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 fD({name:e}){return s.jsx("symbol",{id:`terrain-${e}`,overflow:"visible",children:Gy[e]})}const mD=Object.keys(Gy),pD=w.memo(function(t){const{seed:n,width:i,height:o,nodes:c}=t,d=w.useMemo(()=>hD({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:mD.map(u=>s.jsx(fD,{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 Vy(e){var i;const t=(i=sh())==null?void 0:i.waiting,n=FR(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 gD=380;function kD(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,vD({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)/gD),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 vD(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 wD(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,yD=1.8;function xD(e){const{tickets:t,mode:n,size:i}=e,o=w.useMemo(()=>{const k=wp(t,"LR",n),y=wp(t,"TB",n),b=S=>Math.min(i.w/(S.width+Ht*2),i.h/(S.height+Ht*2+16));return b(k)*yD>=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=nD(d),f=X4(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 jD(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 bD(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}=xD({tickets:d,mode:t.map.mode,size:f,minFit:e.minFit,main:!!e.main}),$=w.useMemo(()=>e.main?Z4({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(cD({fit:D(),nodes:N,size:f,pad:Ht,focus:e.focus,room:nk(f.w)}))},[f.w,f.h,b,S,t.map.id,(we=e.focus)==null?void 0:we[0]]);const Q=wD({box:u,view:F,setView:K,onTouch:()=>I.current=!0});jD(u,(z,Y)=>{I.current=!0,K(U=>qy(U,U.k*z,Y))});const Z=gt(5e3),q=Lu(e.leases,t.map.id),ee=Mr(),Se=Vy(t),ve=(n==null?void 0:n.kind)==="ticket"?n.id:void 0;kD({selId:ve,nodes:N,size:f,pad:Ht,view:F,setView:K,room:nk(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(k4,{}),s.jsxs("g",{transform:`translate(${F.x} ${F.y}) scale(${F.k})`,children:[s.jsx("g",{transform:`translate(${Ht} ${Ht})`,children:s.jsx(pD,{seed:t.map.id,width:b,height:S,nodes:N})}),s.jsxs("g",{transform:`translate(${O.x} ${O.y})`,children:[s.jsx(lD,{y:g.quarantineY,width:g.width,height:g.quarantineH,nodes:g.nodes}),s.jsx(N4,{snap:t,tickets:d,direction:g.direction,nodes:g.nodes,edges:g.edges,preview:o}),s.jsx(oD,{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(eD,{...$,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(q4,{n:z,live:e.live.get(z.ticket.id),now:Z,stalled:!!Y&&Es(Y,Z)!=="live",flag:dC(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 SD=[{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 ND(){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:SD.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(zy,{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 $D(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 CD(){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 TD(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(X2,{}),(i=e.trail)==null?void 0:i.banner,s.jsxs("div",{className:"map-area",children:[t?s.jsx(bD,{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:CD()}),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:hw,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(ND,{})]}),e.docked&&e.bubble()]})}function ED(e){const{view:t,covered:n,needs:i}=e;return s.jsx("nav",{className:"tabbar",children:uy.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 AD(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 hk={settingsPage:!0},fk=()=>ch(new URLSearchParams(location.search).get("settings")),mk=()=>{var e;return!!((e=history.state)!=null&&e.settingsPage)};function ID(){const[e,t]=w.useState(fk);w.useEffect(()=>{e&&!mk()&&(history.replaceState(null,"",kr(location.href,null)),history.pushState(hk,"",kr(location.href,e)));const d=()=>t(fk());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(hk,"",u),t(d)},i=()=>{e&&(t(null),mk()?history.back():history.replaceState(null,"",kr(location.href,null)))},o=d=>n(ch(d??"")??{});return{route:e,open:o,show:n,close:i,dismiss:()=>t(null),toggle:()=>e?i():o()}}const ku="view",Dd={lookoutPage:!0},pk=()=>{const e=new URLSearchParams(location.search).get(ku);return JM.includes(e)?e:null},gk=()=>{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(ku),t.searchParams.delete("settings"),e&&t.searchParams.set(ku,e),t.toString()}function RD(){const[e,t]=w.useState(pk);return w.useEffect(()=>{e&&!gk()&&(history.replaceState(null,"",ra(null)),history.pushState(Dd,"",ra(e)));const o=()=>t(pk());return window.addEventListener("popstate",o),()=>window.removeEventListener("popstate",o)},[]),{page:e,open:o=>{const c=ra(o);gk()?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 MD(e){const{activity:t,selection:n,setSelection:i,actions:o}=e,c=RD(),[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 LD(e,t){w.useEffect(()=>{document.title=`${J.name}: ${e?`(${e}) `:""}${t??"No trail"}`},[e,t])}function OD(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 PD(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 DD(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=PD({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"?OD(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 _D(e){const{snap:t,sessions:n,view:i}=e,o=Vy(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?DD({snap:t,sessions:m,items:d,heldBack:x=>{const $=o(x);return!!$.needs||$.briefHeld}}):new Map,y=i4(k),b=r4(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 BD(e,t){const n=qu(e),i=t.some(c=>c.kind==="main-checks"),o=PT(n.view,i);return{tone:o,needs:o==="needs"}}const kk=["pointerdown","keydown"],vk={capture:!0};function FD(e,t){function n(){for(const o of kk)e.removeEventListener(o,i,vk)}function i(){n(),t()}for(const o of kk)e.addEventListener(o,i,vk);return n}const zD=new Set(["question","main-checks","trail-checks"]),UD=e=>!!e.ticketId||zD.has(e.kind);function WD(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(()=>FD(window,()=>t.current=!0),[]),w.useEffect(()=>{if(t.current||!n||!i||!c)return;const f=i.items.find(m=>m.mapId===c&&UD(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 HD(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 KD(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 GD(e){const t=oc(e),[n,i]=w.useState(!1),o=()=>i(!0),c=t.brief,d=_R(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(IR,{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(LR,{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(PR,{brief:c,onReview:o}),inboxCard:(c==null?void 0:c.status)==="submitted"&&s.jsx(MR,{brief:c,onReview:o}),dialog:s.jsxs(s.Fragment,{children:[m,g]})}}function VD(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 qD=e=>e.changes.flatMap(t=>"ticket"in t?[t.ticket]:[]);function QD(e,t){const n=new Set(qD(t));return e.tickets.filter(i=>n.has(i.id)&&i.updatedAt>t.at).map(i=>({key:i.key,title:i.title,what:YD(i)}))}function YD(e){return e.state==="closed"?"closed":e.assignee?`claimed by ${e.assignee}`:"changed"}function JD({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 XD={"already-exists":"The work already exists","wrong-problem":"The trail targets the wrong problem",rescope:"The trail should be rescoped"},Qy="Dismissed by the trail lead. Carry on with the current plan.",ZD="Declined by the trail lead.";function e_(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 t_(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:n_(e)};case"rewire":return{verb:"Rewire",text:t(e.ticket),detail:s_(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 n_(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 s_(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 i_=new Set(["cancel_ticket","update_destination"]);function r_(e){const{change:t,name:n}=e,i=t_(t,n),o=e_(t,e.by);return s.jsx(fe,{as:"li",className:`reroute-change op-${t.op}`,edge:i_.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(JD,{parts:o}):void 0})}function o_(e){const{reason:t,destination:n}=e;return s.jsxs("section",{className:"reroute-destination",children:[t&&s.jsx("p",{className:"reroute-destination-why",children:XD[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 a_(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 c_(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 l_(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=c_(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?QD(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(o_,{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(r_,{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(a_,{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($?ZD:Qy),children:$?"Decline":"Dismiss"}),s.jsx(R,{className:"reroute-reject",disabled:!i.trim(),onClick:()=>e.onReject(i.trim()),children:"Reject"}),aw()?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 Yy=`${re()}/reroutes`;async function d_(e){if(!e)return[];const t=await fetch(`${Yy}?map=${encodeURIComponent(e)}`);return t.ok?(await t.json()).reroutes:[]}function u_(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:()=>d_(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(`${Yy}/${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 h_(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 f_(e,t){const n=u_(e),[i,o]=w.useState(),c=h_(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(VD,{reroute:g,onReview:()=>o(g.id),onDismiss:()=>void n.reject(g.id,Qy)}),pending:n.reroutes.filter(k=>k.status==="pending").length,preview:e&&(u!=null&&u.diff)?v4(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(l_,{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 m_(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 p_=20;function Jy(e=p_){const t=document.querySelector(".ticket-proof");if(t)return t.scrollIntoView({block:"start",behavior:"smooth"});e>0&&setTimeout(()=>Jy(e-1),100)}function g_(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 k_({onClose:e}){return s.jsx(R,{variant:"primary",autoFocus:!0,onClick:e,children:"Close"})}function v_(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 w_(e){return e.done.kind==="unverified"&&e.done.together.kind==="failed"?s.jsx(g_,{onChecks:e.onChecks,onClose:e.onClose}):e.pulls>0?s.jsx(v_,{pulls:e.pulls,onReview:e.onReview,onClose:e.onClose}):s.jsx(k_,{onClose:e.onClose})}const y_=e=>e===1?"1 pull request to merge.":`${e} pull requests to merge.`;function x_(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&&` ${y_(n)}`]}),s.jsx("footer",{children:s.jsx(w_,{...e})})]})})}function j_({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(Ky,{})});return s.jsx(An,{title:"Destination reached",hint:e.reason,art:t})}function b_(e,t){return e.every(n=>n.state!=="closed"||n.closeReason!=="completed"||t[n.id]!==void 0)}function S_(e,t){const n=$D(e==null?void 0:e.map.id,e==null?void 0:e.tickets),i=rw(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||!b_(e.tickets,n)))return kS({tickets:e.tickets,proofs:n,pendingReroutes:t,together:o})},[e,n,t,o]);return{proofs:n,done:c}}const wk=new Set,yk=e=>`teamtrail.trail-done:${re()}:${e}`,xk={has(e){const t=yk(e);if(wk.has(t))return!0;try{return localStorage.getItem(t)==="1"}catch{return!1}},add(e){const t=yk(e);wk.add(t);try{localStorage.setItem(t,"1")}catch{}}};function N_(e,t){return t.kind==="verified"?`${e}:verified`:t.together.kind==="failed"?`${e}:failed:${t.together.runId}`:e}function $_(e,t){const[,n]=w.useState(0),i=e==null?void 0:e.map.id,o=i&&t&&t.kind!=="not-done"?N_(i,t):void 0;return{show:!!o&&!(e!=null&&e.map.archived)&&!xk.has(o),close:()=>{o&&xk.add(o),n(u=>u+1)}}}function C_(e){const{snap:t}=e,{proofs:n,done:i}=S_(t,e.pendingReroutes),o=$_(t,i),c=Mr(),d=t?m_(c,t):[],u=()=>{o.close(),!(!t||!d.length)&&(e.openTicket(t.map.id,d[0]),Jy())},f=()=>{o.close(),t&&e.openTrailChecks(t.map.id)},m=o.show&&i&&i.kind!=="not-done"&&s.jsx(x_,{done:i,pulls:d.length,onReview:u,onChecks:f,onClose:o.close});return{proofs:n,done:i,dialog:m}}function T_(e){const{snap:t}=e,n=GD(t),i=f_(t,e.selectMap),o=C_({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 E_(){const e=new URL(location.href);e.searchParams.has($s)&&(e.searchParams.delete($s),history.replaceState(history.state,"",e))}function A_(e,t){return e.kind!=="question"||t.pending.some(n=>n.id===e.ref)}function I_(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&&!A_(u,c)||(n(void 0),E_(),u&&Xu(u,d))},[t,i,o,c,d]),{request:w.useCallback(u=>n(u),[])}}function R_(e){const{api:t,nav:n}=e,i=ww(t.allSnaps);zE(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=I_({loaded:t.loaded,view:d,activity:t.activity,handlers:c}),f=d&&s.jsx(DE,{view:d,onFocus:m=>void i.savePrefs(vN(d.prefs,m,Date.now())),onSettings:e.openFocusSettings});return{attention:i,handlers:c,header:f,link:u,open:m=>Xu(m,c)}}function M_({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 L_(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=Db(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:[L$(t.decidedAt),`${Je(b-t.decidedAt)} ago`]})]}),s.jsx("h3",{className:"t-heading",children:t.question}),s.jsx(GR,{mapId:t.mapId,kind:"decision",id:t.id}),s.jsx(M_,{d:t}),s.jsxs("div",{className:"resolution",children:[s.jsx(tu,{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:[Fu(t,i),Wk(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(Aw,{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(tu,{parts:[mi(x.author,i),Mu(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 O_(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 jk=e=>`${e.mapId}/${e.id}`;function P_(e,t){var o;const n=new Map;for(const c of e){const d=((o=t[jk(c)])==null?void 0:o.area)??ud;n.set(d,[...n.get(d)??[],c])}const i=c=>{var d;return((d=t[jk(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 D_(e){if(Er(e)==="superseded")return`Replaced by ${e.supersededBy}`;if(e.supersedes)return`Replaces ${e.supersedes}`}function __(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:Mu(t.decidedAt),context:s.jsx(_,{parts:[{text:t.id,code:!0},t.ticketKey&&{text:t.ticketKey,code:!0},e.showTrail&&e.trail,Fu(t,n),Wk(t)??ts[t.source.kind].label,D_(t),!!e.cited&&`cited ${e.cited}×`]}),detail:t.summary,detailText:t.summary})]})}function B_(e){const{rows:t,current:n,memory:i}=e,o=(c,d,u)=>{var f,m;return s.jsx(__,{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:P_(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 F_({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 z_(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 U_(){const e=await fetch(`${re()}/decision-memory`);return e.ok?(await e.json()).entries:null}function W_(){const[e,t]=w.useState();return Pe({load:U_,show:t,failed:()=>t(null),changed:n=>n.includes("/decisions/")||n.endsWith("map.md")}),e}function H_(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=W_();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(()=>yS(i,o),[i,o]),S=w.useMemo(()=>xS(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}]));Tv(`${J.slug}-decisions-${fi(Date.now())}.md`,MS(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(F_,{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(z_,{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(O_,{filter:o,set:O,all:i,trails:$,people:N,compact:n!=="wide"}),!F&&s.jsx(B_,{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(L_,{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 K_={"asks-you":"urgent",answered:"good",launched:"good",done:"good",verified:"good","checks-failed":"attention",stalled:"attention",disconnected:"attention",problem:"attention"};function G_(e){if(e.kind)return K_[e.kind];if(e.signal){if(e.level==="alert")return"urgent";if(e.level==="ok")return"good"}}function V_({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-${G_(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 bk({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 q_({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:Q_(i+1,t)},i))})}function Q_(e,t){return e<t?"done":e===t?"cur":""}function Y_({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=Lu(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:J_(b,g($)),title:t6(S,b.mode)||b.agent,context:s.jsx(_,{parts:[{text:b.agent,strong:!0},Z_(b),k&&X_(b),b.waitingOn?{text:"Waiting on you",urgent:!0}:`${b.mode} · ${b.stepLabel.toLowerCase()}`,x&&!b.waitingOn&&"with you",e6(b)],children:s.jsx(bk,{lease:$,now:c})}),trailing:Ev(c-b.startedAt),below:s.jsx(q_,{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(bk,{lease:f.get(b.id),now:c})}),onOpen:()=>i({kind:"ticket",id:b.id})},b.id))]})}function J_(e,t){return e.waitingOn?"urgent":t?"attention":"neutral"}function X_(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 Z_(e){const t=Sr(e.model);return t&&{text:t,tip:e.model,className:"agent-model"}}function e6(e){if(e.usage)return`${Ha(pS(e))} tok · ${hi(e.usage.costUsd)}`}function t6(e,t){return e?`${e.key} ${e.title}`:t==="chart"?"Charting trail":""}function n6({activity:e,snap:t,running:n,usage:i=!0}){const o=Jk(e,t==null?void 0:t.map.id),c=Zk(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=>Xk[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 s6(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 i6={running:"Working",done:"Done",failed:"Stopped"};function r6({activity:e,snap:t,done:n}){var u;if(n&&n.kind!=="not-done")return s.jsx(j_,{done:n});const i=s6(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":i6[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 o6(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(r6,{activity:t,snap:e.snap,done:e.done}),s.jsx(n6,{activity:t,snap:e.snap,running:t.sessions.filter(gn).length}),s.jsx(Y_,{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(V_,{activity:t,onTicket:e.onTicket})})]}),s.jsx("section",{className:"page-col conversation-col",children:s.jsx(x2,{activity:e.allActivity,snaps:e.snaps,sessionId:e.chatSession,onAnswer:e.onAnswer})})]})}const a6={holding:"Holding",challenged:"Challenged",invalidated:"Invalidated",confirmed:"Confirmed"};function c6(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 l6(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},a6[t.status],c6(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 d6(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 u6({snap:e,onSelect:t}){const{confirm:n,busy:i,error:o}=d6(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(l6,{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 h6(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 f6(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 m6({snap:e,activity:t,onTicket:n}){const i=f6(e),o=t.usageByMap[e.map.id],c=w.useMemo(()=>rv({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:()=>Tv(`${e.map.key.replace("#","trail-")}-report.md`,US(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 p6({tab:e,snap:t,selection:n,onSelect:i,activity:o}){const c=t.map.sections;switch(e){case"report":return o?s.jsx(m6,{snap:t,activity:o,onTicket:d=>i({kind:"ticket",id:d})}):s.jsx(Te,{children:"No activity yet"});case"assumptions":return s.jsx(u6,{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=h6(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 g6({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(p6,{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"]],Sk=[["verifying","Verifying"],["rework","Rework"],["held","Blocked"]];function k6({snap:e,sessions:t}){const n=Yk(e),i=m=>n[m],o=t.filter(yC).length,c=fS(e),d=Math.max(1,...c.map(m=>m.open+m.closed)),f=(e.map.verification??"off")!=="off"||Sk.some(([m])=>i(m))?[..._d.slice(0,2),...Sk,..._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 v6(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(g6,{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(ly,{snap:t,item:i,api:e.api}),t&&!i&&s.jsxs(s.Fragment,{children:[e.glance,s.jsx(k6,{snap:t,sessions:e.activity.sessions})]})]})]})]})}function w6({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(GP,{api:e,bp:t,onClose:()=>n.setStatsOpen(!1)});switch(n.page){case"logbook":return s.jsx(H_,{api:e,bp:t,focus:n.logbookFocus,onClose:n.toMap,onOpenTicket:n.openTicket});case"plan":return s.jsx(v6,{api:e,snap:e.snap,activity:i,selection:e.selection,onSelect:n.select,onAudit:()=>n.openDecisions(),glance:e.snap&&s.jsx(cy,{snap:e.snap,sessions:i.sessions,attention:c.attention.view,done:o,now:d,onTicket:u,onItem:c.open})});case"activity":return s.jsx(o6,{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 y6(e,t,n){const i=Ty(),[o,c]=w.useState(()=>new URLSearchParams(location.search).has("projects")),d=o&&i.many&&s.jsx(oP,{projects:i,bp:e,onClose:()=>c(!1),onItemHere:n});return{projects:i,overview:d,closeOverview:()=>c(!1),openOverview:()=>{t.toMap(),c(!0)}}}const x6=e=>typeof e=="string"&&/^\/(?!\/)[\w/?=&#.-]{0,200}$/.test(e)?e:void 0;function j6(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=x6(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 b6(){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=j6(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(iu,f);const m=Ya(f),g=as(f);return()=>{clearTimeout(u),document.removeEventListener("visibilitychange",d),window.removeEventListener(iu,f),m(),g()}},[e]),t}const Xy="teamtrail.guide.open";function S6(){try{return localStorage.getItem(Xy)!=="no"}catch{return!0}}function N6(e){try{localStorage.setItem(Xy,e?"yes":"no")}catch{}}function $6(){const e=b6(),[t,n]=w.useState(S6);if(!e||e.complete)return null;const i=c=>{n(c),N6(c)},o=`${e.done} of ${e.total}`;return Hw.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 C6(){const e=w.useMemo(()=>wC(vC()),[]),t=cT(e),{snap:n,activity:i}=t,[o,c]=uT(),d=ID(),u=p4(e,t),f=HD(e.kind),m=sT(),g=KD(i,t.mapId);LD(i.pending.length,n==null?void 0:n.map.title);const k=MD(t),y=T_({snap:n,selectMap:t.actions.selectMap,openTicket:k.openTicket,openTrailChecks:k.openTrailChecks}),b=LA(y.briefText),S=R_({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=>VL(d.open,we),openFocusSettings:()=>d.open("attention")}),x=S.attention.view,$=rT(e,t,o.briefing,x==null?void 0:x.items),N=_D({snap:n,sessions:g.sessions,view:x}),O=BD(t.mapId,N.items),{projects:D,overview:F,openOverview:K,closeOverview:I}=y6(m,k,S.link.request),Q=d.route&&s.jsx(X3,{rt:e,api:t,bp:m,prefs:o,update:c,settings:d,openTicket:k.openTicket}),Z=(k.statsOpen||k.page)&&s.jsx(w6,{api:t,bp:m,nav:k,scoped:g,done:y.done,attn:S}),q=Q||F||Z;WD({...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(TD,{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(YM,{api:t,nav:k,attn:S,sessions:g.sessions,mainNeeds:O.needs,place:we})}),ae=s.jsx(m4,{api:t,nav:k,attn:S,trail:N,bp:m,brief:y.inboxCard}),Ie=s.jsx(bT,{brief:$,snaps:t.allSnaps,bp:m,openTicket:k.openTicket,openChat:k.openChat,openDecisions:k.openDecisions,openQuestion:k.openQuestion,toMap:k.toMap});return s.jsx(Ew.Provider,{value:b,children:s.jsxs("div",{className:`app bp-${m} view-${ee}`,children:[s.jsx(XM,{api:t,rt:e,repo:s.jsx(aP,{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(AD,{covered:q,map:be,trailBar:ae,projects:D.many&&s.jsx(lP,{projects:D,onOverview:K})}),s.jsx(ED,{view:ee,covered:!!Q||!!F,needs:N.items.length,onPick:Se})]}):s.jsxs(s.Fragment,{children:[be,ae,q]}),s.jsx(Z3,{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(KL,{prefs:o,update:c,activeTracker:e.kind}),s.jsx(RA,{}),s.jsx($6,{})]})})}const T6="X-Teamtrail-Session";function E6(e){return typeof e=="string"?e:e instanceof URL?e.href:e.url}function A6(e){const t=new URL(E6(e),location.href),n=J.apiPrefix;return t.origin===location.origin&&(t.pathname===n||t.pathname.startsWith(`${n}/`))}function I6(){const e=window.fetch.bind(window);window.fetch=(t,n)=>{const i=eC()?Pu():void 0;if(!i||!A6(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(T6,i.secret),e(t,{...n,headers:o})}}Ka(Bu().theme);I6();i0.createRoot(document.getElementById("root")).render(s.jsxs(F3,{children:[s.jsx(C6,{}),s.jsx(kT,{})]}));