teamtrail 0.26.0-next.36 → 0.27.3-next.39

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,173 @@
1
+ var My=Object.defineProperty;var Ry=(e,t,s)=>t in e?My(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var ce=(e,t,s)=>Ry(e,typeof t!="symbol"?t+"":t,s);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))o(a);new MutationObserver(a=>{for(const c of a)if(c.type==="childList")for(const u of c.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&o(u)}).observe(document,{childList:!0,subtree:!0});function s(a){const c={};return a.integrity&&(c.integrity=a.integrity),a.referrerPolicy&&(c.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?c.credentials="include":a.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function o(a){if(a.ep)return;a.ep=!0;const c=s(a);fetch(a.href,c)}})();var fc={exports:{}},Ki={},mc={exports:{}},ye={};/**
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 Of;function Oy(){if(Of)return ye;Of=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),u=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),k=Symbol.iterator;function x(T){return T===null||typeof T!="object"?null:(T=k&&T[k]||T["@@iterator"],typeof T=="function"?T:null)}var N={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,j={};function A(T,_,ue){this.props=T,this.context=_,this.refs=j,this.updater=ue||N}A.prototype.isReactComponent={},A.prototype.setState=function(T,_){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,_,"setState")},A.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function C(){}C.prototype=A.prototype;function R(T,_,ue){this.props=T,this.context=_,this.refs=j,this.updater=ue||N}var L=R.prototype=new C;L.constructor=R,S(L,A.prototype),L.isPureReactComponent=!0;var U=Array.isArray,Z=Object.prototype.hasOwnProperty,Q={current:null},W={key:!0,ref:!0,__self:!0,__source:!0};function ie(T,_,ue){var me,ke={},xe=null,pe=null;if(_!=null)for(me in _.ref!==void 0&&(pe=_.ref),_.key!==void 0&&(xe=""+_.key),_)Z.call(_,me)&&!W.hasOwnProperty(me)&&(ke[me]=_[me]);var Ne=arguments.length-2;if(Ne===1)ke.children=ue;else if(1<Ne){for(var ge=Array(Ne),Be=0;Be<Ne;Be++)ge[Be]=arguments[Be+2];ke.children=ge}if(T&&T.defaultProps)for(me in Ne=T.defaultProps,Ne)ke[me]===void 0&&(ke[me]=Ne[me]);return{$$typeof:e,type:T,key:xe,ref:pe,props:ke,_owner:Q.current}}function G(T,_){return{$$typeof:e,type:T.type,key:_,ref:T.ref,props:T.props,_owner:T._owner}}function ve(T){return typeof T=="object"&&T!==null&&T.$$typeof===e}function Le(T){var _={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(ue){return _[ue]})}var $e=/\/+/g;function oe(T,_){return typeof T=="object"&&T!==null&&T.key!=null?Le(""+T.key):_.toString(36)}function D(T,_,ue,me,ke){var xe=typeof T;(xe==="undefined"||xe==="boolean")&&(T=null);var pe=!1;if(T===null)pe=!0;else switch(xe){case"string":case"number":pe=!0;break;case"object":switch(T.$$typeof){case e:case t:pe=!0}}if(pe)return pe=T,ke=ke(pe),T=me===""?"."+oe(pe,0):me,U(ke)?(ue="",T!=null&&(ue=T.replace($e,"$&/")+"/"),D(ke,_,ue,"",function(Be){return Be})):ke!=null&&(ve(ke)&&(ke=G(ke,ue+(!ke.key||pe&&pe.key===ke.key?"":(""+ke.key).replace($e,"$&/")+"/")+T)),_.push(ke)),1;if(pe=0,me=me===""?".":me+":",U(T))for(var Ne=0;Ne<T.length;Ne++){xe=T[Ne];var ge=me+oe(xe,Ne);pe+=D(xe,_,ue,ge,ke)}else if(ge=x(T),typeof ge=="function")for(T=ge.call(T),Ne=0;!(xe=T.next()).done;)xe=xe.value,ge=me+oe(xe,Ne++),pe+=D(xe,_,ue,ge,ke);else if(xe==="object")throw _=String(T),Error("Objects are not valid as a React child (found: "+(_==="[object Object]"?"object with keys {"+Object.keys(T).join(", ")+"}":_)+"). If you meant to render a collection of children, use an array instead.");return pe}function X(T,_,ue){if(T==null)return T;var me=[],ke=0;return D(T,me,"","",function(xe){return _.call(ue,xe,ke++)}),me}function le(T){if(T._status===-1){var _=T._result;_=_(),_.then(function(ue){(T._status===0||T._status===-1)&&(T._status=1,T._result=ue)},function(ue){(T._status===0||T._status===-1)&&(T._status=2,T._result=ue)}),T._status===-1&&(T._status=0,T._result=_)}if(T._status===1)return T._result.default;throw T._result}var te={current:null},K={transition:null},Y={ReactCurrentDispatcher:te,ReactCurrentBatchConfig:K,ReactCurrentOwner:Q};function B(){throw Error("act(...) is not supported in production builds of React.")}return ye.Children={map:X,forEach:function(T,_,ue){X(T,function(){_.apply(this,arguments)},ue)},count:function(T){var _=0;return X(T,function(){_++}),_},toArray:function(T){return X(T,function(_){return _})||[]},only:function(T){if(!ve(T))throw Error("React.Children.only expected to receive a single React element child.");return T}},ye.Component=A,ye.Fragment=s,ye.Profiler=a,ye.PureComponent=R,ye.StrictMode=o,ye.Suspense=m,ye.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Y,ye.act=B,ye.cloneElement=function(T,_,ue){if(T==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+T+".");var me=S({},T.props),ke=T.key,xe=T.ref,pe=T._owner;if(_!=null){if(_.ref!==void 0&&(xe=_.ref,pe=Q.current),_.key!==void 0&&(ke=""+_.key),T.type&&T.type.defaultProps)var Ne=T.type.defaultProps;for(ge in _)Z.call(_,ge)&&!W.hasOwnProperty(ge)&&(me[ge]=_[ge]===void 0&&Ne!==void 0?Ne[ge]:_[ge])}var ge=arguments.length-2;if(ge===1)me.children=ue;else if(1<ge){Ne=Array(ge);for(var Be=0;Be<ge;Be++)Ne[Be]=arguments[Be+2];me.children=Ne}return{$$typeof:e,type:T.type,key:ke,ref:xe,props:me,_owner:pe}},ye.createContext=function(T){return T={$$typeof:u,_currentValue:T,_currentValue2:T,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},T.Provider={$$typeof:c,_context:T},T.Consumer=T},ye.createElement=ie,ye.createFactory=function(T){var _=ie.bind(null,T);return _.type=T,_},ye.createRef=function(){return{current:null}},ye.forwardRef=function(T){return{$$typeof:h,render:T}},ye.isValidElement=ve,ye.lazy=function(T){return{$$typeof:v,_payload:{_status:-1,_result:T},_init:le}},ye.memo=function(T,_){return{$$typeof:p,type:T,compare:_===void 0?null:_}},ye.startTransition=function(T){var _=K.transition;K.transition={};try{T()}finally{K.transition=_}},ye.unstable_act=B,ye.useCallback=function(T,_){return te.current.useCallback(T,_)},ye.useContext=function(T){return te.current.useContext(T)},ye.useDebugValue=function(){},ye.useDeferredValue=function(T){return te.current.useDeferredValue(T)},ye.useEffect=function(T,_){return te.current.useEffect(T,_)},ye.useId=function(){return te.current.useId()},ye.useImperativeHandle=function(T,_,ue){return te.current.useImperativeHandle(T,_,ue)},ye.useInsertionEffect=function(T,_){return te.current.useInsertionEffect(T,_)},ye.useLayoutEffect=function(T,_){return te.current.useLayoutEffect(T,_)},ye.useMemo=function(T,_){return te.current.useMemo(T,_)},ye.useReducer=function(T,_,ue){return te.current.useReducer(T,_,ue)},ye.useRef=function(T){return te.current.useRef(T)},ye.useState=function(T){return te.current.useState(T)},ye.useSyncExternalStore=function(T,_,ue){return te.current.useSyncExternalStore(T,_,ue)},ye.useTransition=function(){return te.current.useTransition()},ye.version="18.3.1",ye}var Lf;function ou(){return Lf||(Lf=1,mc.exports=Oy()),mc.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 Pf;function Ly(){if(Pf)return Ki;Pf=1;var e=ou(),t=Symbol.for("react.element"),s=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,a=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function u(h,m,p){var v,k={},x=null,N=null;p!==void 0&&(x=""+p),m.key!==void 0&&(x=""+m.key),m.ref!==void 0&&(N=m.ref);for(v in m)o.call(m,v)&&!c.hasOwnProperty(v)&&(k[v]=m[v]);if(h&&h.defaultProps)for(v in m=h.defaultProps,m)k[v]===void 0&&(k[v]=m[v]);return{$$typeof:t,type:h,key:x,ref:N,props:k,_owner:a.current}}return Ki.Fragment=s,Ki.jsx=u,Ki.jsxs=u,Ki}var _f;function Py(){return _f||(_f=1,fc.exports=Ly()),fc.exports}var i=Py(),yo={},pc={exports:{}},xt={},gc={exports:{}},vc={};/**
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 Df;function _y(){return Df||(Df=1,(function(e){function t(K,Y){var B=K.length;K.push(Y);e:for(;0<B;){var T=B-1>>>1,_=K[T];if(0<a(_,Y))K[T]=Y,K[B]=_,B=T;else break e}}function s(K){return K.length===0?null:K[0]}function o(K){if(K.length===0)return null;var Y=K[0],B=K.pop();if(B!==Y){K[0]=B;e:for(var T=0,_=K.length,ue=_>>>1;T<ue;){var me=2*(T+1)-1,ke=K[me],xe=me+1,pe=K[xe];if(0>a(ke,B))xe<_&&0>a(pe,ke)?(K[T]=pe,K[xe]=B,T=xe):(K[T]=ke,K[me]=B,T=me);else if(xe<_&&0>a(pe,B))K[T]=pe,K[xe]=B,T=xe;else break e}}return Y}function a(K,Y){var B=K.sortIndex-Y.sortIndex;return B!==0?B:K.id-Y.id}if(typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var u=Date,h=u.now();e.unstable_now=function(){return u.now()-h}}var m=[],p=[],v=1,k=null,x=3,N=!1,S=!1,j=!1,A=typeof setTimeout=="function"?setTimeout:null,C=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function L(K){for(var Y=s(p);Y!==null;){if(Y.callback===null)o(p);else if(Y.startTime<=K)o(p),Y.sortIndex=Y.expirationTime,t(m,Y);else break;Y=s(p)}}function U(K){if(j=!1,L(K),!S)if(s(m)!==null)S=!0,le(Z);else{var Y=s(p);Y!==null&&te(U,Y.startTime-K)}}function Z(K,Y){S=!1,j&&(j=!1,C(ie),ie=-1),N=!0;var B=x;try{for(L(Y),k=s(m);k!==null&&(!(k.expirationTime>Y)||K&&!Le());){var T=k.callback;if(typeof T=="function"){k.callback=null,x=k.priorityLevel;var _=T(k.expirationTime<=Y);Y=e.unstable_now(),typeof _=="function"?k.callback=_:k===s(m)&&o(m),L(Y)}else o(m);k=s(m)}if(k!==null)var ue=!0;else{var me=s(p);me!==null&&te(U,me.startTime-Y),ue=!1}return ue}finally{k=null,x=B,N=!1}}var Q=!1,W=null,ie=-1,G=5,ve=-1;function Le(){return!(e.unstable_now()-ve<G)}function $e(){if(W!==null){var K=e.unstable_now();ve=K;var Y=!0;try{Y=W(!0,K)}finally{Y?oe():(Q=!1,W=null)}}else Q=!1}var oe;if(typeof R=="function")oe=function(){R($e)};else if(typeof MessageChannel<"u"){var D=new MessageChannel,X=D.port2;D.port1.onmessage=$e,oe=function(){X.postMessage(null)}}else oe=function(){A($e,0)};function le(K){W=K,Q||(Q=!0,oe())}function te(K,Y){ie=A(function(){K(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(K){K.callback=null},e.unstable_continueExecution=function(){S||N||(S=!0,le(Z))},e.unstable_forceFrameRate=function(K){0>K||125<K?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):G=0<K?Math.floor(1e3/K):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_getFirstCallbackNode=function(){return s(m)},e.unstable_next=function(K){switch(x){case 1:case 2:case 3:var Y=3;break;default:Y=x}var B=x;x=Y;try{return K()}finally{x=B}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(K,Y){switch(K){case 1:case 2:case 3:case 4:case 5:break;default:K=3}var B=x;x=K;try{return Y()}finally{x=B}},e.unstable_scheduleCallback=function(K,Y,B){var T=e.unstable_now();switch(typeof B=="object"&&B!==null?(B=B.delay,B=typeof B=="number"&&0<B?T+B:T):B=T,K){case 1:var _=-1;break;case 2:_=250;break;case 5:_=1073741823;break;case 4:_=1e4;break;default:_=5e3}return _=B+_,K={id:v++,callback:Y,priorityLevel:K,startTime:B,expirationTime:_,sortIndex:-1},B>T?(K.sortIndex=B,t(p,K),s(m)===null&&K===s(p)&&(j?(C(ie),ie=-1):j=!0,te(U,B-T))):(K.sortIndex=_,t(m,K),S||N||(S=!0,le(Z))),K},e.unstable_shouldYield=Le,e.unstable_wrapCallback=function(K){var Y=x;return function(){var B=x;x=Y;try{return K.apply(this,arguments)}finally{x=B}}}})(vc)),vc}var zf;function Dy(){return zf||(zf=1,gc.exports=_y()),gc.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 Bf;function zy(){if(Bf)return xt;Bf=1;var e=ou(),t=Dy();function s(n){for(var r="https://reactjs.org/docs/error-decoder.html?invariant="+n,l=1;l<arguments.length;l++)r+="&args[]="+encodeURIComponent(arguments[l]);return"Minified React error #"+n+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var o=new Set,a={};function c(n,r){u(n,r),u(n+"Capture",r)}function u(n,r){for(a[n]=r,n=0;n<r.length;n++)o.add(r[n])}var h=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),m=Object.prototype.hasOwnProperty,p=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,v={},k={};function x(n){return m.call(k,n)?!0:m.call(v,n)?!1:p.test(n)?k[n]=!0:(v[n]=!0,!1)}function N(n,r,l,d){if(l!==null&&l.type===0)return!1;switch(typeof r){case"function":case"symbol":return!0;case"boolean":return d?!1:l!==null?!l.acceptsBooleans:(n=n.toLowerCase().slice(0,5),n!=="data-"&&n!=="aria-");default:return!1}}function S(n,r,l,d){if(r===null||typeof r>"u"||N(n,r,l,d))return!0;if(d)return!1;if(l!==null)switch(l.type){case 3:return!r;case 4:return r===!1;case 5:return isNaN(r);case 6:return isNaN(r)||1>r}return!1}function j(n,r,l,d,f,g,w){this.acceptsBooleans=r===2||r===3||r===4,this.attributeName=d,this.attributeNamespace=f,this.mustUseProperty=l,this.propertyName=n,this.type=r,this.sanitizeURL=g,this.removeEmptyString=w}var A={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(n){A[n]=new j(n,0,!1,n,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(n){var r=n[0];A[r]=new j(r,1,!1,n[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(n){A[n]=new j(n,2,!1,n.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(n){A[n]=new j(n,2,!1,n,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(n){A[n]=new j(n,3,!1,n.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(n){A[n]=new j(n,3,!0,n,null,!1,!1)}),["capture","download"].forEach(function(n){A[n]=new j(n,4,!1,n,null,!1,!1)}),["cols","rows","size","span"].forEach(function(n){A[n]=new j(n,6,!1,n,null,!1,!1)}),["rowSpan","start"].forEach(function(n){A[n]=new j(n,5,!1,n.toLowerCase(),null,!1,!1)});var C=/[\-:]([a-z])/g;function R(n){return n[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(n){var r=n.replace(C,R);A[r]=new j(r,1,!1,n,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(n){var r=n.replace(C,R);A[r]=new j(r,1,!1,n,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(n){var r=n.replace(C,R);A[r]=new j(r,1,!1,n,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(n){A[n]=new j(n,1,!1,n.toLowerCase(),null,!1,!1)}),A.xlinkHref=new j("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(n){A[n]=new j(n,1,!1,n.toLowerCase(),null,!0,!0)});function L(n,r,l,d){var f=A.hasOwnProperty(r)?A[r]:null;(f!==null?f.type!==0:d||!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(S(r,l,f,d)&&(l=null),d||f===null?x(r)&&(l===null?n.removeAttribute(r):n.setAttribute(r,""+l)):f.mustUseProperty?n[f.propertyName]=l===null?f.type===3?!1:"":l:(r=f.attributeName,d=f.attributeNamespace,l===null?n.removeAttribute(r):(f=f.type,l=f===3||f===4&&l===!0?"":""+l,d?n.setAttributeNS(d,r,l):n.setAttribute(r,l))))}var U=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Z=Symbol.for("react.element"),Q=Symbol.for("react.portal"),W=Symbol.for("react.fragment"),ie=Symbol.for("react.strict_mode"),G=Symbol.for("react.profiler"),ve=Symbol.for("react.provider"),Le=Symbol.for("react.context"),$e=Symbol.for("react.forward_ref"),oe=Symbol.for("react.suspense"),D=Symbol.for("react.suspense_list"),X=Symbol.for("react.memo"),le=Symbol.for("react.lazy"),te=Symbol.for("react.offscreen"),K=Symbol.iterator;function Y(n){return n===null||typeof n!="object"?null:(n=K&&n[K]||n["@@iterator"],typeof n=="function"?n:null)}var B=Object.assign,T;function _(n){if(T===void 0)try{throw Error()}catch(l){var r=l.stack.trim().match(/\n( *(at )?)/);T=r&&r[1]||""}return`
34
+ `+T+n}var ue=!1;function me(n,r){if(!n||ue)return"";ue=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(r)if(r=function(){throw Error()},Object.defineProperty(r.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(r,[])}catch(O){var d=O}Reflect.construct(n,[],r)}else{try{r.call()}catch(O){d=O}n.call(r.prototype)}else{try{throw Error()}catch(O){d=O}n()}}catch(O){if(O&&d&&typeof O.stack=="string"){for(var f=O.stack.split(`
35
+ `),g=d.stack.split(`
36
+ `),w=f.length-1,b=g.length-1;1<=w&&0<=b&&f[w]!==g[b];)b--;for(;1<=w&&0<=b;w--,b--)if(f[w]!==g[b]){if(w!==1||b!==1)do if(w--,b--,0>b||f[w]!==g[b]){var $=`
37
+ `+f[w].replace(" at new "," at ");return n.displayName&&$.includes("<anonymous>")&&($=$.replace("<anonymous>",n.displayName)),$}while(1<=w&&0<=b);break}}}finally{ue=!1,Error.prepareStackTrace=l}return(n=n?n.displayName||n.name:"")?_(n):""}function ke(n){switch(n.tag){case 5:return _(n.type);case 16:return _("Lazy");case 13:return _("Suspense");case 19:return _("SuspenseList");case 0:case 2:case 15:return n=me(n.type,!1),n;case 11:return n=me(n.type.render,!1),n;case 1:return n=me(n.type,!0),n;default:return""}}function xe(n){if(n==null)return null;if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case W:return"Fragment";case Q:return"Portal";case G:return"Profiler";case ie:return"StrictMode";case oe:return"Suspense";case D:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case Le:return(n.displayName||"Context")+".Consumer";case ve:return(n._context.displayName||"Context")+".Provider";case $e:var r=n.render;return n=n.displayName,n||(n=r.displayName||r.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case X:return r=n.displayName||null,r!==null?r:xe(n.type)||"Memo";case le:r=n._payload,n=n._init;try{return xe(n(r))}catch{}}return null}function pe(n){var r=n.type;switch(n.tag){case 24:return"Cache";case 9:return(r.displayName||"Context")+".Consumer";case 10:return(r._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return n=r.render,n=n.displayName||n.name||"",r.displayName||(n!==""?"ForwardRef("+n+")":"ForwardRef");case 7:return"Fragment";case 5:return r;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return xe(r);case 8:return r===ie?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r}return null}function Ne(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function ge(n){var r=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function Be(n){var r=ge(n)?"checked":"value",l=Object.getOwnPropertyDescriptor(n.constructor.prototype,r),d=""+n[r];if(!n.hasOwnProperty(r)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var f=l.get,g=l.set;return Object.defineProperty(n,r,{configurable:!0,get:function(){return f.call(this)},set:function(w){d=""+w,g.call(this,w)}}),Object.defineProperty(n,r,{enumerable:l.enumerable}),{getValue:function(){return d},setValue:function(w){d=""+w},stopTracking:function(){n._valueTracker=null,delete n[r]}}}}function Sn(n){n._valueTracker||(n._valueTracker=Be(n))}function cr(n){if(!n)return!1;var r=n._valueTracker;if(!r)return!0;var l=r.getValue(),d="";return n&&(d=ge(n)?n.checked?"true":"false":n.value),n=d,n!==l?(r.setValue(n),!0):!1}function ms(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}function wa(n,r){var l=r.checked;return B({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:l??n._wrapperState.initialChecked})}function Bu(n,r){var l=r.defaultValue==null?"":r.defaultValue,d=r.checked!=null?r.checked:r.defaultChecked;l=Ne(r.value!=null?r.value:l),n._wrapperState={initialChecked:d,initialValue:l,controlled:r.type==="checkbox"||r.type==="radio"?r.checked!=null:r.value!=null}}function Fu(n,r){r=r.checked,r!=null&&L(n,"checked",r,!1)}function xa(n,r){Fu(n,r);var l=Ne(r.value),d=r.type;if(l!=null)d==="number"?(l===0&&n.value===""||n.value!=l)&&(n.value=""+l):n.value!==""+l&&(n.value=""+l);else if(d==="submit"||d==="reset"){n.removeAttribute("value");return}r.hasOwnProperty("value")?ja(n,r.type,l):r.hasOwnProperty("defaultValue")&&ja(n,r.type,Ne(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(n.defaultChecked=!!r.defaultChecked)}function Uu(n,r,l){if(r.hasOwnProperty("value")||r.hasOwnProperty("defaultValue")){var d=r.type;if(!(d!=="submit"&&d!=="reset"||r.value!==void 0&&r.value!==null))return;r=""+n._wrapperState.initialValue,l||r===n.value||(n.value=r),n.defaultValue=r}l=n.name,l!==""&&(n.name=""),n.defaultChecked=!!n._wrapperState.initialChecked,l!==""&&(n.name=l)}function ja(n,r,l){(r!=="number"||ms(n.ownerDocument)!==n)&&(l==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+l&&(n.defaultValue=""+l))}var oi=Array.isArray;function ps(n,r,l,d){if(n=n.options,r){r={};for(var f=0;f<l.length;f++)r["$"+l[f]]=!0;for(l=0;l<n.length;l++)f=r.hasOwnProperty("$"+n[l].value),n[l].selected!==f&&(n[l].selected=f),f&&d&&(n[l].defaultSelected=!0)}else{for(l=""+Ne(l),r=null,f=0;f<n.length;f++){if(n[f].value===l){n[f].selected=!0,d&&(n[f].defaultSelected=!0);return}r!==null||n[f].disabled||(r=n[f])}r!==null&&(r.selected=!0)}}function Na(n,r){if(r.dangerouslySetInnerHTML!=null)throw Error(s(91));return B({},r,{value:void 0,defaultValue:void 0,children:""+n._wrapperState.initialValue})}function Wu(n,r){var l=r.value;if(l==null){if(l=r.children,r=r.defaultValue,l!=null){if(r!=null)throw Error(s(92));if(oi(l)){if(1<l.length)throw Error(s(93));l=l[0]}r=l}r==null&&(r=""),l=r}n._wrapperState={initialValue:Ne(l)}}function Hu(n,r){var l=Ne(r.value),d=Ne(r.defaultValue);l!=null&&(l=""+l,l!==n.value&&(n.value=l),r.defaultValue==null&&n.defaultValue!==l&&(n.defaultValue=l)),d!=null&&(n.defaultValue=""+d)}function Ku(n){var r=n.textContent;r===n._wrapperState.initialValue&&r!==""&&r!==null&&(n.value=r)}function Vu(n){switch(n){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Sa(n,r){return n==null||n==="http://www.w3.org/1999/xhtml"?Vu(r):n==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":n}var ur,Gu=(function(n){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(r,l,d,f){MSApp.execUnsafeLocalFunction(function(){return n(r,l,d,f)})}:n})(function(n,r){if(n.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in n)n.innerHTML=r;else{for(ur=ur||document.createElement("div"),ur.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=ur.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;r.firstChild;)n.appendChild(r.firstChild)}});function ai(n,r){if(r){var l=n.firstChild;if(l&&l===n.lastChild&&l.nodeType===3){l.nodeValue=r;return}}n.textContent=r}var li={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},Pv=["Webkit","ms","Moz","O"];Object.keys(li).forEach(function(n){Pv.forEach(function(r){r=r+n.charAt(0).toUpperCase()+n.substring(1),li[r]=li[n]})});function qu(n,r,l){return r==null||typeof r=="boolean"||r===""?"":l||typeof r!="number"||r===0||li.hasOwnProperty(n)&&li[n]?(""+r).trim():r+"px"}function Qu(n,r){n=n.style;for(var l in r)if(r.hasOwnProperty(l)){var d=l.indexOf("--")===0,f=qu(l,r[l],d);l==="float"&&(l="cssFloat"),d?n.setProperty(l,f):n[l]=f}}var _v=B({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 ba(n,r){if(r){if(_v[n]&&(r.children!=null||r.dangerouslySetInnerHTML!=null))throw Error(s(137,n));if(r.dangerouslySetInnerHTML!=null){if(r.children!=null)throw Error(s(60));if(typeof r.dangerouslySetInnerHTML!="object"||!("__html"in r.dangerouslySetInnerHTML))throw Error(s(61))}if(r.style!=null&&typeof r.style!="object")throw Error(s(62))}}function Ca(n,r){if(n.indexOf("-")===-1)return typeof r.is=="string";switch(n){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var $a=null;function Ta(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var Ea=null,gs=null,vs=null;function Yu(n){if(n=Ai(n)){if(typeof Ea!="function")throw Error(s(280));var r=n.stateNode;r&&(r=Rr(r),Ea(n.stateNode,n.type,r))}}function Ju(n){gs?vs?vs.push(n):vs=[n]:gs=n}function Xu(){if(gs){var n=gs,r=vs;if(vs=gs=null,Yu(n),r)for(n=0;n<r.length;n++)Yu(r[n])}}function Zu(n,r){return n(r)}function ed(){}var Aa=!1;function td(n,r,l){if(Aa)return n(r,l);Aa=!0;try{return Zu(n,r,l)}finally{Aa=!1,(gs!==null||vs!==null)&&(ed(),Xu())}}function ci(n,r){var l=n.stateNode;if(l===null)return null;var d=Rr(l);if(d===null)return null;l=d[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(d=!d.disabled)||(n=n.type,d=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!d;break e;default:n=!1}if(n)return null;if(l&&typeof l!="function")throw Error(s(231,r,typeof l));return l}var Ia=!1;if(h)try{var ui={};Object.defineProperty(ui,"passive",{get:function(){Ia=!0}}),window.addEventListener("test",ui,ui),window.removeEventListener("test",ui,ui)}catch{Ia=!1}function Dv(n,r,l,d,f,g,w,b,$){var O=Array.prototype.slice.call(arguments,3);try{r.apply(l,O)}catch(F){this.onError(F)}}var di=!1,dr=null,hr=!1,Ma=null,zv={onError:function(n){di=!0,dr=n}};function Bv(n,r,l,d,f,g,w,b,$){di=!1,dr=null,Dv.apply(zv,arguments)}function Fv(n,r,l,d,f,g,w,b,$){if(Bv.apply(this,arguments),di){if(di){var O=dr;di=!1,dr=null}else throw Error(s(198));hr||(hr=!0,Ma=O)}}function Yn(n){var r=n,l=n;if(n.alternate)for(;r.return;)r=r.return;else{n=r;do r=n,(r.flags&4098)!==0&&(l=r.return),n=r.return;while(n)}return r.tag===3?l:null}function nd(n){if(n.tag===13){var r=n.memoizedState;if(r===null&&(n=n.alternate,n!==null&&(r=n.memoizedState)),r!==null)return r.dehydrated}return null}function sd(n){if(Yn(n)!==n)throw Error(s(188))}function Uv(n){var r=n.alternate;if(!r){if(r=Yn(n),r===null)throw Error(s(188));return r!==n?null:n}for(var l=n,d=r;;){var f=l.return;if(f===null)break;var g=f.alternate;if(g===null){if(d=f.return,d!==null){l=d;continue}break}if(f.child===g.child){for(g=f.child;g;){if(g===l)return sd(f),n;if(g===d)return sd(f),r;g=g.sibling}throw Error(s(188))}if(l.return!==d.return)l=f,d=g;else{for(var w=!1,b=f.child;b;){if(b===l){w=!0,l=f,d=g;break}if(b===d){w=!0,d=f,l=g;break}b=b.sibling}if(!w){for(b=g.child;b;){if(b===l){w=!0,l=g,d=f;break}if(b===d){w=!0,d=g,l=f;break}b=b.sibling}if(!w)throw Error(s(189))}}if(l.alternate!==d)throw Error(s(190))}if(l.tag!==3)throw Error(s(188));return l.stateNode.current===l?n:r}function id(n){return n=Uv(n),n!==null?rd(n):null}function rd(n){if(n.tag===5||n.tag===6)return n;for(n=n.child;n!==null;){var r=rd(n);if(r!==null)return r;n=n.sibling}return null}var od=t.unstable_scheduleCallback,ad=t.unstable_cancelCallback,Wv=t.unstable_shouldYield,Hv=t.unstable_requestPaint,We=t.unstable_now,Kv=t.unstable_getCurrentPriorityLevel,Ra=t.unstable_ImmediatePriority,ld=t.unstable_UserBlockingPriority,fr=t.unstable_NormalPriority,Vv=t.unstable_LowPriority,cd=t.unstable_IdlePriority,mr=null,Zt=null;function Gv(n){if(Zt&&typeof Zt.onCommitFiberRoot=="function")try{Zt.onCommitFiberRoot(mr,n,void 0,(n.current.flags&128)===128)}catch{}}var Ft=Math.clz32?Math.clz32:Yv,qv=Math.log,Qv=Math.LN2;function Yv(n){return n>>>=0,n===0?32:31-(qv(n)/Qv|0)|0}var pr=64,gr=4194304;function hi(n){switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return n&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return n}}function vr(n,r){var l=n.pendingLanes;if(l===0)return 0;var d=0,f=n.suspendedLanes,g=n.pingedLanes,w=l&268435455;if(w!==0){var b=w&~f;b!==0?d=hi(b):(g&=w,g!==0&&(d=hi(g)))}else w=l&~f,w!==0?d=hi(w):g!==0&&(d=hi(g));if(d===0)return 0;if(r!==0&&r!==d&&(r&f)===0&&(f=d&-d,g=r&-r,f>=g||f===16&&(g&4194240)!==0))return r;if((d&4)!==0&&(d|=l&16),r=n.entangledLanes,r!==0)for(n=n.entanglements,r&=d;0<r;)l=31-Ft(r),f=1<<l,d|=n[l],r&=~f;return d}function Jv(n,r){switch(n){case 1:case 2:case 4:return r+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Xv(n,r){for(var l=n.suspendedLanes,d=n.pingedLanes,f=n.expirationTimes,g=n.pendingLanes;0<g;){var w=31-Ft(g),b=1<<w,$=f[w];$===-1?((b&l)===0||(b&d)!==0)&&(f[w]=Jv(b,r)):$<=r&&(n.expiredLanes|=b),g&=~b}}function Oa(n){return n=n.pendingLanes&-1073741825,n!==0?n:n&1073741824?1073741824:0}function ud(){var n=pr;return pr<<=1,(pr&4194240)===0&&(pr=64),n}function La(n){for(var r=[],l=0;31>l;l++)r.push(n);return r}function fi(n,r,l){n.pendingLanes|=r,r!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,r=31-Ft(r),n[r]=l}function Zv(n,r){var l=n.pendingLanes&~r;n.pendingLanes=r,n.suspendedLanes=0,n.pingedLanes=0,n.expiredLanes&=r,n.mutableReadLanes&=r,n.entangledLanes&=r,r=n.entanglements;var d=n.eventTimes;for(n=n.expirationTimes;0<l;){var f=31-Ft(l),g=1<<f;r[f]=0,d[f]=-1,n[f]=-1,l&=~g}}function Pa(n,r){var l=n.entangledLanes|=r;for(n=n.entanglements;l;){var d=31-Ft(l),f=1<<d;f&r|n[d]&r&&(n[d]|=r),l&=~f}}var Te=0;function dd(n){return n&=-n,1<n?4<n?(n&268435455)!==0?16:536870912:4:1}var hd,_a,fd,md,pd,Da=!1,kr=[],bn=null,Cn=null,$n=null,mi=new Map,pi=new Map,Tn=[],ek="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 gd(n,r){switch(n){case"focusin":case"focusout":bn=null;break;case"dragenter":case"dragleave":Cn=null;break;case"mouseover":case"mouseout":$n=null;break;case"pointerover":case"pointerout":mi.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":pi.delete(r.pointerId)}}function gi(n,r,l,d,f,g){return n===null||n.nativeEvent!==g?(n={blockedOn:r,domEventName:l,eventSystemFlags:d,nativeEvent:g,targetContainers:[f]},r!==null&&(r=Ai(r),r!==null&&_a(r)),n):(n.eventSystemFlags|=d,r=n.targetContainers,f!==null&&r.indexOf(f)===-1&&r.push(f),n)}function tk(n,r,l,d,f){switch(r){case"focusin":return bn=gi(bn,n,r,l,d,f),!0;case"dragenter":return Cn=gi(Cn,n,r,l,d,f),!0;case"mouseover":return $n=gi($n,n,r,l,d,f),!0;case"pointerover":var g=f.pointerId;return mi.set(g,gi(mi.get(g)||null,n,r,l,d,f)),!0;case"gotpointercapture":return g=f.pointerId,pi.set(g,gi(pi.get(g)||null,n,r,l,d,f)),!0}return!1}function vd(n){var r=Jn(n.target);if(r!==null){var l=Yn(r);if(l!==null){if(r=l.tag,r===13){if(r=nd(l),r!==null){n.blockedOn=r,pd(n.priority,function(){fd(l)});return}}else if(r===3&&l.stateNode.current.memoizedState.isDehydrated){n.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}n.blockedOn=null}function yr(n){if(n.blockedOn!==null)return!1;for(var r=n.targetContainers;0<r.length;){var l=Ba(n.domEventName,n.eventSystemFlags,r[0],n.nativeEvent);if(l===null){l=n.nativeEvent;var d=new l.constructor(l.type,l);$a=d,l.target.dispatchEvent(d),$a=null}else return r=Ai(l),r!==null&&_a(r),n.blockedOn=l,!1;r.shift()}return!0}function kd(n,r,l){yr(n)&&l.delete(r)}function nk(){Da=!1,bn!==null&&yr(bn)&&(bn=null),Cn!==null&&yr(Cn)&&(Cn=null),$n!==null&&yr($n)&&($n=null),mi.forEach(kd),pi.forEach(kd)}function vi(n,r){n.blockedOn===r&&(n.blockedOn=null,Da||(Da=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,nk)))}function ki(n){function r(f){return vi(f,n)}if(0<kr.length){vi(kr[0],n);for(var l=1;l<kr.length;l++){var d=kr[l];d.blockedOn===n&&(d.blockedOn=null)}}for(bn!==null&&vi(bn,n),Cn!==null&&vi(Cn,n),$n!==null&&vi($n,n),mi.forEach(r),pi.forEach(r),l=0;l<Tn.length;l++)d=Tn[l],d.blockedOn===n&&(d.blockedOn=null);for(;0<Tn.length&&(l=Tn[0],l.blockedOn===null);)vd(l),l.blockedOn===null&&Tn.shift()}var ks=U.ReactCurrentBatchConfig,wr=!0;function sk(n,r,l,d){var f=Te,g=ks.transition;ks.transition=null;try{Te=1,za(n,r,l,d)}finally{Te=f,ks.transition=g}}function ik(n,r,l,d){var f=Te,g=ks.transition;ks.transition=null;try{Te=4,za(n,r,l,d)}finally{Te=f,ks.transition=g}}function za(n,r,l,d){if(wr){var f=Ba(n,r,l,d);if(f===null)sl(n,r,d,xr,l),gd(n,d);else if(tk(f,n,r,l,d))d.stopPropagation();else if(gd(n,d),r&4&&-1<ek.indexOf(n)){for(;f!==null;){var g=Ai(f);if(g!==null&&hd(g),g=Ba(n,r,l,d),g===null&&sl(n,r,d,xr,l),g===f)break;f=g}f!==null&&d.stopPropagation()}else sl(n,r,d,null,l)}}var xr=null;function Ba(n,r,l,d){if(xr=null,n=Ta(d),n=Jn(n),n!==null)if(r=Yn(n),r===null)n=null;else if(l=r.tag,l===13){if(n=nd(r),n!==null)return n;n=null}else if(l===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;n=null}else r!==n&&(n=null);return xr=n,null}function yd(n){switch(n){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Kv()){case Ra:return 1;case ld:return 4;case fr:case Vv:return 16;case cd:return 536870912;default:return 16}default:return 16}}var En=null,Fa=null,jr=null;function wd(){if(jr)return jr;var n,r=Fa,l=r.length,d,f="value"in En?En.value:En.textContent,g=f.length;for(n=0;n<l&&r[n]===f[n];n++);var w=l-n;for(d=1;d<=w&&r[l-d]===f[g-d];d++);return jr=f.slice(n,1<d?1-d:void 0)}function Nr(n){var r=n.keyCode;return"charCode"in n?(n=n.charCode,n===0&&r===13&&(n=13)):n=r,n===10&&(n=13),32<=n||n===13?n:0}function Sr(){return!0}function xd(){return!1}function bt(n){function r(l,d,f,g,w){this._reactName=l,this._targetInst=f,this.type=d,this.nativeEvent=g,this.target=w,this.currentTarget=null;for(var b in n)n.hasOwnProperty(b)&&(l=n[b],this[b]=l?l(g):g[b]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?Sr:xd,this.isPropagationStopped=xd,this}return B(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=Sr)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=Sr)},persist:function(){},isPersistent:Sr}),r}var ys={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ua=bt(ys),yi=B({},ys,{view:0,detail:0}),rk=bt(yi),Wa,Ha,wi,br=B({},yi,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Va,button:0,buttons:0,relatedTarget:function(n){return n.relatedTarget===void 0?n.fromElement===n.srcElement?n.toElement:n.fromElement:n.relatedTarget},movementX:function(n){return"movementX"in n?n.movementX:(n!==wi&&(wi&&n.type==="mousemove"?(Wa=n.screenX-wi.screenX,Ha=n.screenY-wi.screenY):Ha=Wa=0,wi=n),Wa)},movementY:function(n){return"movementY"in n?n.movementY:Ha}}),jd=bt(br),ok=B({},br,{dataTransfer:0}),ak=bt(ok),lk=B({},yi,{relatedTarget:0}),Ka=bt(lk),ck=B({},ys,{animationName:0,elapsedTime:0,pseudoElement:0}),uk=bt(ck),dk=B({},ys,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),hk=bt(dk),fk=B({},ys,{data:0}),Nd=bt(fk),mk={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},pk={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"},gk={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function vk(n){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(n):(n=gk[n])?!!r[n]:!1}function Va(){return vk}var kk=B({},yi,{key:function(n){if(n.key){var r=mk[n.key]||n.key;if(r!=="Unidentified")return r}return n.type==="keypress"?(n=Nr(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?pk[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Va,charCode:function(n){return n.type==="keypress"?Nr(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?Nr(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),yk=bt(kk),wk=B({},br,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Sd=bt(wk),xk=B({},yi,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Va}),jk=bt(xk),Nk=B({},ys,{propertyName:0,elapsedTime:0,pseudoElement:0}),Sk=bt(Nk),bk=B({},br,{deltaX:function(n){return"deltaX"in n?n.deltaX:"wheelDeltaX"in n?-n.wheelDeltaX:0},deltaY:function(n){return"deltaY"in n?n.deltaY:"wheelDeltaY"in n?-n.wheelDeltaY:"wheelDelta"in n?-n.wheelDelta:0},deltaZ:0,deltaMode:0}),Ck=bt(bk),$k=[9,13,27,32],Ga=h&&"CompositionEvent"in window,xi=null;h&&"documentMode"in document&&(xi=document.documentMode);var Tk=h&&"TextEvent"in window&&!xi,bd=h&&(!Ga||xi&&8<xi&&11>=xi),Cd=" ",$d=!1;function Td(n,r){switch(n){case"keyup":return $k.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ed(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var ws=!1;function Ek(n,r){switch(n){case"compositionend":return Ed(r);case"keypress":return r.which!==32?null:($d=!0,Cd);case"textInput":return n=r.data,n===Cd&&$d?null:n;default:return null}}function Ak(n,r){if(ws)return n==="compositionend"||!Ga&&Td(n,r)?(n=wd(),jr=Fa=En=null,ws=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return bd&&r.locale!=="ko"?null:r.data;default:return null}}var Ik={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 Ad(n){var r=n&&n.nodeName&&n.nodeName.toLowerCase();return r==="input"?!!Ik[n.type]:r==="textarea"}function Id(n,r,l,d){Ju(d),r=Ar(r,"onChange"),0<r.length&&(l=new Ua("onChange","change",null,l,d),n.push({event:l,listeners:r}))}var ji=null,Ni=null;function Mk(n){Qd(n,0)}function Cr(n){var r=bs(n);if(cr(r))return n}function Rk(n,r){if(n==="change")return r}var Md=!1;if(h){var qa;if(h){var Qa="oninput"in document;if(!Qa){var Rd=document.createElement("div");Rd.setAttribute("oninput","return;"),Qa=typeof Rd.oninput=="function"}qa=Qa}else qa=!1;Md=qa&&(!document.documentMode||9<document.documentMode)}function Od(){ji&&(ji.detachEvent("onpropertychange",Ld),Ni=ji=null)}function Ld(n){if(n.propertyName==="value"&&Cr(Ni)){var r=[];Id(r,Ni,n,Ta(n)),td(Mk,r)}}function Ok(n,r,l){n==="focusin"?(Od(),ji=r,Ni=l,ji.attachEvent("onpropertychange",Ld)):n==="focusout"&&Od()}function Lk(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return Cr(Ni)}function Pk(n,r){if(n==="click")return Cr(r)}function _k(n,r){if(n==="input"||n==="change")return Cr(r)}function Dk(n,r){return n===r&&(n!==0||1/n===1/r)||n!==n&&r!==r}var Ut=typeof Object.is=="function"?Object.is:Dk;function Si(n,r){if(Ut(n,r))return!0;if(typeof n!="object"||n===null||typeof r!="object"||r===null)return!1;var l=Object.keys(n),d=Object.keys(r);if(l.length!==d.length)return!1;for(d=0;d<l.length;d++){var f=l[d];if(!m.call(r,f)||!Ut(n[f],r[f]))return!1}return!0}function Pd(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function _d(n,r){var l=Pd(n);n=0;for(var d;l;){if(l.nodeType===3){if(d=n+l.textContent.length,n<=r&&d>=r)return{node:l,offset:r-n};n=d}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=Pd(l)}}function Dd(n,r){return n&&r?n===r?!0:n&&n.nodeType===3?!1:r&&r.nodeType===3?Dd(n,r.parentNode):"contains"in n?n.contains(r):n.compareDocumentPosition?!!(n.compareDocumentPosition(r)&16):!1:!1}function zd(){for(var n=window,r=ms();r instanceof n.HTMLIFrameElement;){try{var l=typeof r.contentWindow.location.href=="string"}catch{l=!1}if(l)n=r.contentWindow;else break;r=ms(n.document)}return r}function Ya(n){var r=n&&n.nodeName&&n.nodeName.toLowerCase();return r&&(r==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||r==="textarea"||n.contentEditable==="true")}function zk(n){var r=zd(),l=n.focusedElem,d=n.selectionRange;if(r!==l&&l&&l.ownerDocument&&Dd(l.ownerDocument.documentElement,l)){if(d!==null&&Ya(l)){if(r=d.start,n=d.end,n===void 0&&(n=r),"selectionStart"in l)l.selectionStart=r,l.selectionEnd=Math.min(n,l.value.length);else if(n=(r=l.ownerDocument||document)&&r.defaultView||window,n.getSelection){n=n.getSelection();var f=l.textContent.length,g=Math.min(d.start,f);d=d.end===void 0?g:Math.min(d.end,f),!n.extend&&g>d&&(f=d,d=g,g=f),f=_d(l,g);var w=_d(l,d);f&&w&&(n.rangeCount!==1||n.anchorNode!==f.node||n.anchorOffset!==f.offset||n.focusNode!==w.node||n.focusOffset!==w.offset)&&(r=r.createRange(),r.setStart(f.node,f.offset),n.removeAllRanges(),g>d?(n.addRange(r),n.extend(w.node,w.offset)):(r.setEnd(w.node,w.offset),n.addRange(r)))}}for(r=[],n=l;n=n.parentNode;)n.nodeType===1&&r.push({element:n,left:n.scrollLeft,top:n.scrollTop});for(typeof l.focus=="function"&&l.focus(),l=0;l<r.length;l++)n=r[l],n.element.scrollLeft=n.left,n.element.scrollTop=n.top}}var Bk=h&&"documentMode"in document&&11>=document.documentMode,xs=null,Ja=null,bi=null,Xa=!1;function Bd(n,r,l){var d=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Xa||xs==null||xs!==ms(d)||(d=xs,"selectionStart"in d&&Ya(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),bi&&Si(bi,d)||(bi=d,d=Ar(Ja,"onSelect"),0<d.length&&(r=new Ua("onSelect","select",null,r,l),n.push({event:r,listeners:d}),r.target=xs)))}function $r(n,r){var l={};return l[n.toLowerCase()]=r.toLowerCase(),l["Webkit"+n]="webkit"+r,l["Moz"+n]="moz"+r,l}var js={animationend:$r("Animation","AnimationEnd"),animationiteration:$r("Animation","AnimationIteration"),animationstart:$r("Animation","AnimationStart"),transitionend:$r("Transition","TransitionEnd")},Za={},Fd={};h&&(Fd=document.createElement("div").style,"AnimationEvent"in window||(delete js.animationend.animation,delete js.animationiteration.animation,delete js.animationstart.animation),"TransitionEvent"in window||delete js.transitionend.transition);function Tr(n){if(Za[n])return Za[n];if(!js[n])return n;var r=js[n],l;for(l in r)if(r.hasOwnProperty(l)&&l in Fd)return Za[n]=r[l];return n}var Ud=Tr("animationend"),Wd=Tr("animationiteration"),Hd=Tr("animationstart"),Kd=Tr("transitionend"),Vd=new Map,Gd="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 An(n,r){Vd.set(n,r),c(r,[n])}for(var el=0;el<Gd.length;el++){var tl=Gd[el],Fk=tl.toLowerCase(),Uk=tl[0].toUpperCase()+tl.slice(1);An(Fk,"on"+Uk)}An(Ud,"onAnimationEnd"),An(Wd,"onAnimationIteration"),An(Hd,"onAnimationStart"),An("dblclick","onDoubleClick"),An("focusin","onFocus"),An("focusout","onBlur"),An(Kd,"onTransitionEnd"),u("onMouseEnter",["mouseout","mouseover"]),u("onMouseLeave",["mouseout","mouseover"]),u("onPointerEnter",["pointerout","pointerover"]),u("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 Ci="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(" "),Wk=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ci));function qd(n,r,l){var d=n.type||"unknown-event";n.currentTarget=l,Fv(d,r,void 0,n),n.currentTarget=null}function Qd(n,r){r=(r&4)!==0;for(var l=0;l<n.length;l++){var d=n[l],f=d.event;d=d.listeners;e:{var g=void 0;if(r)for(var w=d.length-1;0<=w;w--){var b=d[w],$=b.instance,O=b.currentTarget;if(b=b.listener,$!==g&&f.isPropagationStopped())break e;qd(f,b,O),g=$}else for(w=0;w<d.length;w++){if(b=d[w],$=b.instance,O=b.currentTarget,b=b.listener,$!==g&&f.isPropagationStopped())break e;qd(f,b,O),g=$}}}if(hr)throw n=Ma,hr=!1,Ma=null,n}function Me(n,r){var l=r[cl];l===void 0&&(l=r[cl]=new Set);var d=n+"__bubble";l.has(d)||(Yd(r,n,2,!1),l.add(d))}function nl(n,r,l){var d=0;r&&(d|=4),Yd(l,n,d,r)}var Er="_reactListening"+Math.random().toString(36).slice(2);function $i(n){if(!n[Er]){n[Er]=!0,o.forEach(function(l){l!=="selectionchange"&&(Wk.has(l)||nl(l,!1,n),nl(l,!0,n))});var r=n.nodeType===9?n:n.ownerDocument;r===null||r[Er]||(r[Er]=!0,nl("selectionchange",!1,r))}}function Yd(n,r,l,d){switch(yd(r)){case 1:var f=sk;break;case 4:f=ik;break;default:f=za}l=f.bind(null,r,l,n),f=void 0,!Ia||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(f=!0),d?f!==void 0?n.addEventListener(r,l,{capture:!0,passive:f}):n.addEventListener(r,l,!0):f!==void 0?n.addEventListener(r,l,{passive:f}):n.addEventListener(r,l,!1)}function sl(n,r,l,d,f){var g=d;if((r&1)===0&&(r&2)===0&&d!==null)e:for(;;){if(d===null)return;var w=d.tag;if(w===3||w===4){var b=d.stateNode.containerInfo;if(b===f||b.nodeType===8&&b.parentNode===f)break;if(w===4)for(w=d.return;w!==null;){var $=w.tag;if(($===3||$===4)&&($=w.stateNode.containerInfo,$===f||$.nodeType===8&&$.parentNode===f))return;w=w.return}for(;b!==null;){if(w=Jn(b),w===null)return;if($=w.tag,$===5||$===6){d=g=w;continue e}b=b.parentNode}}d=d.return}td(function(){var O=g,F=Ta(l),H=[];e:{var z=Vd.get(n);if(z!==void 0){var ee=Ua,se=n;switch(n){case"keypress":if(Nr(l)===0)break e;case"keydown":case"keyup":ee=yk;break;case"focusin":se="focus",ee=Ka;break;case"focusout":se="blur",ee=Ka;break;case"beforeblur":case"afterblur":ee=Ka;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":ee=jd;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ee=ak;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ee=jk;break;case Ud:case Wd:case Hd:ee=uk;break;case Kd:ee=Sk;break;case"scroll":ee=rk;break;case"wheel":ee=Ck;break;case"copy":case"cut":case"paste":ee=hk;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ee=Sd}var re=(r&4)!==0,He=!re&&n==="scroll",I=re?z!==null?z+"Capture":null:z;re=[];for(var E=O,M;E!==null;){M=E;var q=M.stateNode;if(M.tag===5&&q!==null&&(M=q,I!==null&&(q=ci(E,I),q!=null&&re.push(Ti(E,q,M)))),He)break;E=E.return}0<re.length&&(z=new ee(z,se,null,l,F),H.push({event:z,listeners:re}))}}if((r&7)===0){e:{if(z=n==="mouseover"||n==="pointerover",ee=n==="mouseout"||n==="pointerout",z&&l!==$a&&(se=l.relatedTarget||l.fromElement)&&(Jn(se)||se[fn]))break e;if((ee||z)&&(z=F.window===F?F:(z=F.ownerDocument)?z.defaultView||z.parentWindow:window,ee?(se=l.relatedTarget||l.toElement,ee=O,se=se?Jn(se):null,se!==null&&(He=Yn(se),se!==He||se.tag!==5&&se.tag!==6)&&(se=null)):(ee=null,se=O),ee!==se)){if(re=jd,q="onMouseLeave",I="onMouseEnter",E="mouse",(n==="pointerout"||n==="pointerover")&&(re=Sd,q="onPointerLeave",I="onPointerEnter",E="pointer"),He=ee==null?z:bs(ee),M=se==null?z:bs(se),z=new re(q,E+"leave",ee,l,F),z.target=He,z.relatedTarget=M,q=null,Jn(F)===O&&(re=new re(I,E+"enter",se,l,F),re.target=M,re.relatedTarget=He,q=re),He=q,ee&&se)t:{for(re=ee,I=se,E=0,M=re;M;M=Ns(M))E++;for(M=0,q=I;q;q=Ns(q))M++;for(;0<E-M;)re=Ns(re),E--;for(;0<M-E;)I=Ns(I),M--;for(;E--;){if(re===I||I!==null&&re===I.alternate)break t;re=Ns(re),I=Ns(I)}re=null}else re=null;ee!==null&&Jd(H,z,ee,re,!1),se!==null&&He!==null&&Jd(H,He,se,re,!0)}}e:{if(z=O?bs(O):window,ee=z.nodeName&&z.nodeName.toLowerCase(),ee==="select"||ee==="input"&&z.type==="file")var ae=Rk;else if(Ad(z))if(Md)ae=_k;else{ae=Lk;var de=Ok}else(ee=z.nodeName)&&ee.toLowerCase()==="input"&&(z.type==="checkbox"||z.type==="radio")&&(ae=Pk);if(ae&&(ae=ae(n,O))){Id(H,ae,l,F);break e}de&&de(n,z,O),n==="focusout"&&(de=z._wrapperState)&&de.controlled&&z.type==="number"&&ja(z,"number",z.value)}switch(de=O?bs(O):window,n){case"focusin":(Ad(de)||de.contentEditable==="true")&&(xs=de,Ja=O,bi=null);break;case"focusout":bi=Ja=xs=null;break;case"mousedown":Xa=!0;break;case"contextmenu":case"mouseup":case"dragend":Xa=!1,Bd(H,l,F);break;case"selectionchange":if(Bk)break;case"keydown":case"keyup":Bd(H,l,F)}var he;if(Ga)e:{switch(n){case"compositionstart":var fe="onCompositionStart";break e;case"compositionend":fe="onCompositionEnd";break e;case"compositionupdate":fe="onCompositionUpdate";break e}fe=void 0}else ws?Td(n,l)&&(fe="onCompositionEnd"):n==="keydown"&&l.keyCode===229&&(fe="onCompositionStart");fe&&(bd&&l.locale!=="ko"&&(ws||fe!=="onCompositionStart"?fe==="onCompositionEnd"&&ws&&(he=wd()):(En=F,Fa="value"in En?En.value:En.textContent,ws=!0)),de=Ar(O,fe),0<de.length&&(fe=new Nd(fe,n,null,l,F),H.push({event:fe,listeners:de}),he?fe.data=he:(he=Ed(l),he!==null&&(fe.data=he)))),(he=Tk?Ek(n,l):Ak(n,l))&&(O=Ar(O,"onBeforeInput"),0<O.length&&(F=new Nd("onBeforeInput","beforeinput",null,l,F),H.push({event:F,listeners:O}),F.data=he))}Qd(H,r)})}function Ti(n,r,l){return{instance:n,listener:r,currentTarget:l}}function Ar(n,r){for(var l=r+"Capture",d=[];n!==null;){var f=n,g=f.stateNode;f.tag===5&&g!==null&&(f=g,g=ci(n,l),g!=null&&d.unshift(Ti(n,g,f)),g=ci(n,r),g!=null&&d.push(Ti(n,g,f))),n=n.return}return d}function Ns(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5);return n||null}function Jd(n,r,l,d,f){for(var g=r._reactName,w=[];l!==null&&l!==d;){var b=l,$=b.alternate,O=b.stateNode;if($!==null&&$===d)break;b.tag===5&&O!==null&&(b=O,f?($=ci(l,g),$!=null&&w.unshift(Ti(l,$,b))):f||($=ci(l,g),$!=null&&w.push(Ti(l,$,b)))),l=l.return}w.length!==0&&n.push({event:r,listeners:w})}var Hk=/\r\n?/g,Kk=/\u0000|\uFFFD/g;function Xd(n){return(typeof n=="string"?n:""+n).replace(Hk,`
38
+ `).replace(Kk,"")}function Ir(n,r,l){if(r=Xd(r),Xd(n)!==r&&l)throw Error(s(425))}function Mr(){}var il=null,rl=null;function ol(n,r){return n==="textarea"||n==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var al=typeof setTimeout=="function"?setTimeout:void 0,Vk=typeof clearTimeout=="function"?clearTimeout:void 0,Zd=typeof Promise=="function"?Promise:void 0,Gk=typeof queueMicrotask=="function"?queueMicrotask:typeof Zd<"u"?function(n){return Zd.resolve(null).then(n).catch(qk)}:al;function qk(n){setTimeout(function(){throw n})}function ll(n,r){var l=r,d=0;do{var f=l.nextSibling;if(n.removeChild(l),f&&f.nodeType===8)if(l=f.data,l==="/$"){if(d===0){n.removeChild(f),ki(r);return}d--}else l!=="$"&&l!=="$?"&&l!=="$!"||d++;l=f}while(l);ki(r)}function In(n){for(;n!=null;n=n.nextSibling){var r=n.nodeType;if(r===1||r===3)break;if(r===8){if(r=n.data,r==="$"||r==="$!"||r==="$?")break;if(r==="/$")return null}}return n}function eh(n){n=n.previousSibling;for(var r=0;n;){if(n.nodeType===8){var l=n.data;if(l==="$"||l==="$!"||l==="$?"){if(r===0)return n;r--}else l==="/$"&&r++}n=n.previousSibling}return null}var Ss=Math.random().toString(36).slice(2),en="__reactFiber$"+Ss,Ei="__reactProps$"+Ss,fn="__reactContainer$"+Ss,cl="__reactEvents$"+Ss,Qk="__reactListeners$"+Ss,Yk="__reactHandles$"+Ss;function Jn(n){var r=n[en];if(r)return r;for(var l=n.parentNode;l;){if(r=l[fn]||l[en]){if(l=r.alternate,r.child!==null||l!==null&&l.child!==null)for(n=eh(n);n!==null;){if(l=n[en])return l;n=eh(n)}return r}n=l,l=n.parentNode}return null}function Ai(n){return n=n[en]||n[fn],!n||n.tag!==5&&n.tag!==6&&n.tag!==13&&n.tag!==3?null:n}function bs(n){if(n.tag===5||n.tag===6)return n.stateNode;throw Error(s(33))}function Rr(n){return n[Ei]||null}var ul=[],Cs=-1;function Mn(n){return{current:n}}function Re(n){0>Cs||(n.current=ul[Cs],ul[Cs]=null,Cs--)}function Ee(n,r){Cs++,ul[Cs]=n.current,n.current=r}var Rn={},ot=Mn(Rn),gt=Mn(!1),Xn=Rn;function $s(n,r){var l=n.type.contextTypes;if(!l)return Rn;var d=n.stateNode;if(d&&d.__reactInternalMemoizedUnmaskedChildContext===r)return d.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in l)f[g]=r[g];return d&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=r,n.__reactInternalMemoizedMaskedChildContext=f),f}function vt(n){return n=n.childContextTypes,n!=null}function Or(){Re(gt),Re(ot)}function th(n,r,l){if(ot.current!==Rn)throw Error(s(168));Ee(ot,r),Ee(gt,l)}function nh(n,r,l){var d=n.stateNode;if(r=r.childContextTypes,typeof d.getChildContext!="function")return l;d=d.getChildContext();for(var f in d)if(!(f in r))throw Error(s(108,pe(n)||"Unknown",f));return B({},l,d)}function Lr(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||Rn,Xn=ot.current,Ee(ot,n),Ee(gt,gt.current),!0}function sh(n,r,l){var d=n.stateNode;if(!d)throw Error(s(169));l?(n=nh(n,r,Xn),d.__reactInternalMemoizedMergedChildContext=n,Re(gt),Re(ot),Ee(ot,n)):Re(gt),Ee(gt,l)}var mn=null,Pr=!1,dl=!1;function ih(n){mn===null?mn=[n]:mn.push(n)}function Jk(n){Pr=!0,ih(n)}function On(){if(!dl&&mn!==null){dl=!0;var n=0,r=Te;try{var l=mn;for(Te=1;n<l.length;n++){var d=l[n];do d=d(!0);while(d!==null)}mn=null,Pr=!1}catch(f){throw mn!==null&&(mn=mn.slice(n+1)),od(Ra,On),f}finally{Te=r,dl=!1}}return null}var Ts=[],Es=0,_r=null,Dr=0,At=[],It=0,Zn=null,pn=1,gn="";function es(n,r){Ts[Es++]=Dr,Ts[Es++]=_r,_r=n,Dr=r}function rh(n,r,l){At[It++]=pn,At[It++]=gn,At[It++]=Zn,Zn=n;var d=pn;n=gn;var f=32-Ft(d)-1;d&=~(1<<f),l+=1;var g=32-Ft(r)+f;if(30<g){var w=f-f%5;g=(d&(1<<w)-1).toString(32),d>>=w,f-=w,pn=1<<32-Ft(r)+f|l<<f|d,gn=g+n}else pn=1<<g|l<<f|d,gn=n}function hl(n){n.return!==null&&(es(n,1),rh(n,1,0))}function fl(n){for(;n===_r;)_r=Ts[--Es],Ts[Es]=null,Dr=Ts[--Es],Ts[Es]=null;for(;n===Zn;)Zn=At[--It],At[It]=null,gn=At[--It],At[It]=null,pn=At[--It],At[It]=null}var Ct=null,$t=null,Oe=!1,Wt=null;function oh(n,r){var l=Lt(5,null,null,0);l.elementType="DELETED",l.stateNode=r,l.return=n,r=n.deletions,r===null?(n.deletions=[l],n.flags|=16):r.push(l)}function ah(n,r){switch(n.tag){case 5:var l=n.type;return r=r.nodeType!==1||l.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(n.stateNode=r,Ct=n,$t=In(r.firstChild),!0):!1;case 6:return r=n.pendingProps===""||r.nodeType!==3?null:r,r!==null?(n.stateNode=r,Ct=n,$t=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(l=Zn!==null?{id:pn,overflow:gn}:null,n.memoizedState={dehydrated:r,treeContext:l,retryLane:1073741824},l=Lt(18,null,null,0),l.stateNode=r,l.return=n,n.child=l,Ct=n,$t=null,!0):!1;default:return!1}}function ml(n){return(n.mode&1)!==0&&(n.flags&128)===0}function pl(n){if(Oe){var r=$t;if(r){var l=r;if(!ah(n,r)){if(ml(n))throw Error(s(418));r=In(l.nextSibling);var d=Ct;r&&ah(n,r)?oh(d,l):(n.flags=n.flags&-4097|2,Oe=!1,Ct=n)}}else{if(ml(n))throw Error(s(418));n.flags=n.flags&-4097|2,Oe=!1,Ct=n}}}function lh(n){for(n=n.return;n!==null&&n.tag!==5&&n.tag!==3&&n.tag!==13;)n=n.return;Ct=n}function zr(n){if(n!==Ct)return!1;if(!Oe)return lh(n),Oe=!0,!1;var r;if((r=n.tag!==3)&&!(r=n.tag!==5)&&(r=n.type,r=r!=="head"&&r!=="body"&&!ol(n.type,n.memoizedProps)),r&&(r=$t)){if(ml(n))throw ch(),Error(s(418));for(;r;)oh(n,r),r=In(r.nextSibling)}if(lh(n),n.tag===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(s(317));e:{for(n=n.nextSibling,r=0;n;){if(n.nodeType===8){var l=n.data;if(l==="/$"){if(r===0){$t=In(n.nextSibling);break e}r--}else l!=="$"&&l!=="$!"&&l!=="$?"||r++}n=n.nextSibling}$t=null}}else $t=Ct?In(n.stateNode.nextSibling):null;return!0}function ch(){for(var n=$t;n;)n=In(n.nextSibling)}function As(){$t=Ct=null,Oe=!1}function gl(n){Wt===null?Wt=[n]:Wt.push(n)}var Xk=U.ReactCurrentBatchConfig;function Ii(n,r,l){if(n=l.ref,n!==null&&typeof n!="function"&&typeof n!="object"){if(l._owner){if(l=l._owner,l){if(l.tag!==1)throw Error(s(309));var d=l.stateNode}if(!d)throw Error(s(147,n));var f=d,g=""+n;return r!==null&&r.ref!==null&&typeof r.ref=="function"&&r.ref._stringRef===g?r.ref:(r=function(w){var b=f.refs;w===null?delete b[g]:b[g]=w},r._stringRef=g,r)}if(typeof n!="string")throw Error(s(284));if(!l._owner)throw Error(s(290,n))}return n}function Br(n,r){throw n=Object.prototype.toString.call(r),Error(s(31,n==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":n))}function uh(n){var r=n._init;return r(n._payload)}function dh(n){function r(I,E){if(n){var M=I.deletions;M===null?(I.deletions=[E],I.flags|=16):M.push(E)}}function l(I,E){if(!n)return null;for(;E!==null;)r(I,E),E=E.sibling;return null}function d(I,E){for(I=new Map;E!==null;)E.key!==null?I.set(E.key,E):I.set(E.index,E),E=E.sibling;return I}function f(I,E){return I=Un(I,E),I.index=0,I.sibling=null,I}function g(I,E,M){return I.index=M,n?(M=I.alternate,M!==null?(M=M.index,M<E?(I.flags|=2,E):M):(I.flags|=2,E)):(I.flags|=1048576,E)}function w(I){return n&&I.alternate===null&&(I.flags|=2),I}function b(I,E,M,q){return E===null||E.tag!==6?(E=ac(M,I.mode,q),E.return=I,E):(E=f(E,M),E.return=I,E)}function $(I,E,M,q){var ae=M.type;return ae===W?F(I,E,M.props.children,q,M.key):E!==null&&(E.elementType===ae||typeof ae=="object"&&ae!==null&&ae.$$typeof===le&&uh(ae)===E.type)?(q=f(E,M.props),q.ref=Ii(I,E,M),q.return=I,q):(q=uo(M.type,M.key,M.props,null,I.mode,q),q.ref=Ii(I,E,M),q.return=I,q)}function O(I,E,M,q){return E===null||E.tag!==4||E.stateNode.containerInfo!==M.containerInfo||E.stateNode.implementation!==M.implementation?(E=lc(M,I.mode,q),E.return=I,E):(E=f(E,M.children||[]),E.return=I,E)}function F(I,E,M,q,ae){return E===null||E.tag!==7?(E=ls(M,I.mode,q,ae),E.return=I,E):(E=f(E,M),E.return=I,E)}function H(I,E,M){if(typeof E=="string"&&E!==""||typeof E=="number")return E=ac(""+E,I.mode,M),E.return=I,E;if(typeof E=="object"&&E!==null){switch(E.$$typeof){case Z:return M=uo(E.type,E.key,E.props,null,I.mode,M),M.ref=Ii(I,null,E),M.return=I,M;case Q:return E=lc(E,I.mode,M),E.return=I,E;case le:var q=E._init;return H(I,q(E._payload),M)}if(oi(E)||Y(E))return E=ls(E,I.mode,M,null),E.return=I,E;Br(I,E)}return null}function z(I,E,M,q){var ae=E!==null?E.key:null;if(typeof M=="string"&&M!==""||typeof M=="number")return ae!==null?null:b(I,E,""+M,q);if(typeof M=="object"&&M!==null){switch(M.$$typeof){case Z:return M.key===ae?$(I,E,M,q):null;case Q:return M.key===ae?O(I,E,M,q):null;case le:return ae=M._init,z(I,E,ae(M._payload),q)}if(oi(M)||Y(M))return ae!==null?null:F(I,E,M,q,null);Br(I,M)}return null}function ee(I,E,M,q,ae){if(typeof q=="string"&&q!==""||typeof q=="number")return I=I.get(M)||null,b(E,I,""+q,ae);if(typeof q=="object"&&q!==null){switch(q.$$typeof){case Z:return I=I.get(q.key===null?M:q.key)||null,$(E,I,q,ae);case Q:return I=I.get(q.key===null?M:q.key)||null,O(E,I,q,ae);case le:var de=q._init;return ee(I,E,M,de(q._payload),ae)}if(oi(q)||Y(q))return I=I.get(M)||null,F(E,I,q,ae,null);Br(E,q)}return null}function se(I,E,M,q){for(var ae=null,de=null,he=E,fe=E=0,nt=null;he!==null&&fe<M.length;fe++){he.index>fe?(nt=he,he=null):nt=he.sibling;var be=z(I,he,M[fe],q);if(be===null){he===null&&(he=nt);break}n&&he&&be.alternate===null&&r(I,he),E=g(be,E,fe),de===null?ae=be:de.sibling=be,de=be,he=nt}if(fe===M.length)return l(I,he),Oe&&es(I,fe),ae;if(he===null){for(;fe<M.length;fe++)he=H(I,M[fe],q),he!==null&&(E=g(he,E,fe),de===null?ae=he:de.sibling=he,de=he);return Oe&&es(I,fe),ae}for(he=d(I,he);fe<M.length;fe++)nt=ee(he,I,fe,M[fe],q),nt!==null&&(n&&nt.alternate!==null&&he.delete(nt.key===null?fe:nt.key),E=g(nt,E,fe),de===null?ae=nt:de.sibling=nt,de=nt);return n&&he.forEach(function(Wn){return r(I,Wn)}),Oe&&es(I,fe),ae}function re(I,E,M,q){var ae=Y(M);if(typeof ae!="function")throw Error(s(150));if(M=ae.call(M),M==null)throw Error(s(151));for(var de=ae=null,he=E,fe=E=0,nt=null,be=M.next();he!==null&&!be.done;fe++,be=M.next()){he.index>fe?(nt=he,he=null):nt=he.sibling;var Wn=z(I,he,be.value,q);if(Wn===null){he===null&&(he=nt);break}n&&he&&Wn.alternate===null&&r(I,he),E=g(Wn,E,fe),de===null?ae=Wn:de.sibling=Wn,de=Wn,he=nt}if(be.done)return l(I,he),Oe&&es(I,fe),ae;if(he===null){for(;!be.done;fe++,be=M.next())be=H(I,be.value,q),be!==null&&(E=g(be,E,fe),de===null?ae=be:de.sibling=be,de=be);return Oe&&es(I,fe),ae}for(he=d(I,he);!be.done;fe++,be=M.next())be=ee(he,I,fe,be.value,q),be!==null&&(n&&be.alternate!==null&&he.delete(be.key===null?fe:be.key),E=g(be,E,fe),de===null?ae=be:de.sibling=be,de=be);return n&&he.forEach(function(Iy){return r(I,Iy)}),Oe&&es(I,fe),ae}function He(I,E,M,q){if(typeof M=="object"&&M!==null&&M.type===W&&M.key===null&&(M=M.props.children),typeof M=="object"&&M!==null){switch(M.$$typeof){case Z:e:{for(var ae=M.key,de=E;de!==null;){if(de.key===ae){if(ae=M.type,ae===W){if(de.tag===7){l(I,de.sibling),E=f(de,M.props.children),E.return=I,I=E;break e}}else if(de.elementType===ae||typeof ae=="object"&&ae!==null&&ae.$$typeof===le&&uh(ae)===de.type){l(I,de.sibling),E=f(de,M.props),E.ref=Ii(I,de,M),E.return=I,I=E;break e}l(I,de);break}else r(I,de);de=de.sibling}M.type===W?(E=ls(M.props.children,I.mode,q,M.key),E.return=I,I=E):(q=uo(M.type,M.key,M.props,null,I.mode,q),q.ref=Ii(I,E,M),q.return=I,I=q)}return w(I);case Q:e:{for(de=M.key;E!==null;){if(E.key===de)if(E.tag===4&&E.stateNode.containerInfo===M.containerInfo&&E.stateNode.implementation===M.implementation){l(I,E.sibling),E=f(E,M.children||[]),E.return=I,I=E;break e}else{l(I,E);break}else r(I,E);E=E.sibling}E=lc(M,I.mode,q),E.return=I,I=E}return w(I);case le:return de=M._init,He(I,E,de(M._payload),q)}if(oi(M))return se(I,E,M,q);if(Y(M))return re(I,E,M,q);Br(I,M)}return typeof M=="string"&&M!==""||typeof M=="number"?(M=""+M,E!==null&&E.tag===6?(l(I,E.sibling),E=f(E,M),E.return=I,I=E):(l(I,E),E=ac(M,I.mode,q),E.return=I,I=E),w(I)):l(I,E)}return He}var Is=dh(!0),hh=dh(!1),Fr=Mn(null),Ur=null,Ms=null,vl=null;function kl(){vl=Ms=Ur=null}function yl(n){var r=Fr.current;Re(Fr),n._currentValue=r}function wl(n,r,l){for(;n!==null;){var d=n.alternate;if((n.childLanes&r)!==r?(n.childLanes|=r,d!==null&&(d.childLanes|=r)):d!==null&&(d.childLanes&r)!==r&&(d.childLanes|=r),n===l)break;n=n.return}}function Rs(n,r){Ur=n,vl=Ms=null,n=n.dependencies,n!==null&&n.firstContext!==null&&((n.lanes&r)!==0&&(kt=!0),n.firstContext=null)}function Mt(n){var r=n._currentValue;if(vl!==n)if(n={context:n,memoizedValue:r,next:null},Ms===null){if(Ur===null)throw Error(s(308));Ms=n,Ur.dependencies={lanes:0,firstContext:n}}else Ms=Ms.next=n;return r}var ts=null;function xl(n){ts===null?ts=[n]:ts.push(n)}function fh(n,r,l,d){var f=r.interleaved;return f===null?(l.next=l,xl(r)):(l.next=f.next,f.next=l),r.interleaved=l,vn(n,d)}function vn(n,r){n.lanes|=r;var l=n.alternate;for(l!==null&&(l.lanes|=r),l=n,n=n.return;n!==null;)n.childLanes|=r,l=n.alternate,l!==null&&(l.childLanes|=r),l=n,n=n.return;return l.tag===3?l.stateNode:null}var Ln=!1;function jl(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function mh(n,r){n=n.updateQueue,r.updateQueue===n&&(r.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,effects:n.effects})}function kn(n,r){return{eventTime:n,lane:r,tag:0,payload:null,callback:null,next:null}}function Pn(n,r,l){var d=n.updateQueue;if(d===null)return null;if(d=d.shared,(Se&2)!==0){var f=d.pending;return f===null?r.next=r:(r.next=f.next,f.next=r),d.pending=r,vn(n,l)}return f=d.interleaved,f===null?(r.next=r,xl(d)):(r.next=f.next,f.next=r),d.interleaved=r,vn(n,l)}function Wr(n,r,l){if(r=r.updateQueue,r!==null&&(r=r.shared,(l&4194240)!==0)){var d=r.lanes;d&=n.pendingLanes,l|=d,r.lanes=l,Pa(n,l)}}function ph(n,r){var l=n.updateQueue,d=n.alternate;if(d!==null&&(d=d.updateQueue,l===d)){var f=null,g=null;if(l=l.firstBaseUpdate,l!==null){do{var w={eventTime:l.eventTime,lane:l.lane,tag:l.tag,payload:l.payload,callback:l.callback,next:null};g===null?f=g=w:g=g.next=w,l=l.next}while(l!==null);g===null?f=g=r:g=g.next=r}else f=g=r;l={baseState:d.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:d.shared,effects:d.effects},n.updateQueue=l;return}n=l.lastBaseUpdate,n===null?l.firstBaseUpdate=r:n.next=r,l.lastBaseUpdate=r}function Hr(n,r,l,d){var f=n.updateQueue;Ln=!1;var g=f.firstBaseUpdate,w=f.lastBaseUpdate,b=f.shared.pending;if(b!==null){f.shared.pending=null;var $=b,O=$.next;$.next=null,w===null?g=O:w.next=O,w=$;var F=n.alternate;F!==null&&(F=F.updateQueue,b=F.lastBaseUpdate,b!==w&&(b===null?F.firstBaseUpdate=O:b.next=O,F.lastBaseUpdate=$))}if(g!==null){var H=f.baseState;w=0,F=O=$=null,b=g;do{var z=b.lane,ee=b.eventTime;if((d&z)===z){F!==null&&(F=F.next={eventTime:ee,lane:0,tag:b.tag,payload:b.payload,callback:b.callback,next:null});e:{var se=n,re=b;switch(z=r,ee=l,re.tag){case 1:if(se=re.payload,typeof se=="function"){H=se.call(ee,H,z);break e}H=se;break e;case 3:se.flags=se.flags&-65537|128;case 0:if(se=re.payload,z=typeof se=="function"?se.call(ee,H,z):se,z==null)break e;H=B({},H,z);break e;case 2:Ln=!0}}b.callback!==null&&b.lane!==0&&(n.flags|=64,z=f.effects,z===null?f.effects=[b]:z.push(b))}else ee={eventTime:ee,lane:z,tag:b.tag,payload:b.payload,callback:b.callback,next:null},F===null?(O=F=ee,$=H):F=F.next=ee,w|=z;if(b=b.next,b===null){if(b=f.shared.pending,b===null)break;z=b,b=z.next,z.next=null,f.lastBaseUpdate=z,f.shared.pending=null}}while(!0);if(F===null&&($=H),f.baseState=$,f.firstBaseUpdate=O,f.lastBaseUpdate=F,r=f.shared.interleaved,r!==null){f=r;do w|=f.lane,f=f.next;while(f!==r)}else g===null&&(f.shared.lanes=0);is|=w,n.lanes=w,n.memoizedState=H}}function gh(n,r,l){if(n=r.effects,r.effects=null,n!==null)for(r=0;r<n.length;r++){var d=n[r],f=d.callback;if(f!==null){if(d.callback=null,d=l,typeof f!="function")throw Error(s(191,f));f.call(d)}}}var Mi={},tn=Mn(Mi),Ri=Mn(Mi),Oi=Mn(Mi);function ns(n){if(n===Mi)throw Error(s(174));return n}function Nl(n,r){switch(Ee(Oi,r),Ee(Ri,n),Ee(tn,Mi),n=r.nodeType,n){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:Sa(null,"");break;default:n=n===8?r.parentNode:r,r=n.namespaceURI||null,n=n.tagName,r=Sa(r,n)}Re(tn),Ee(tn,r)}function Os(){Re(tn),Re(Ri),Re(Oi)}function vh(n){ns(Oi.current);var r=ns(tn.current),l=Sa(r,n.type);r!==l&&(Ee(Ri,n),Ee(tn,l))}function Sl(n){Ri.current===n&&(Re(tn),Re(Ri))}var Pe=Mn(0);function Kr(n){for(var r=n;r!==null;){if(r.tag===13){var l=r.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||l.data==="$?"||l.data==="$!"))return r}else if(r.tag===19&&r.memoizedProps.revealOrder!==void 0){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===n)break;for(;r.sibling===null;){if(r.return===null||r.return===n)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var bl=[];function Cl(){for(var n=0;n<bl.length;n++)bl[n]._workInProgressVersionPrimary=null;bl.length=0}var Vr=U.ReactCurrentDispatcher,$l=U.ReactCurrentBatchConfig,ss=0,_e=null,Je=null,et=null,Gr=!1,Li=!1,Pi=0,Zk=0;function at(){throw Error(s(321))}function Tl(n,r){if(r===null)return!1;for(var l=0;l<r.length&&l<n.length;l++)if(!Ut(n[l],r[l]))return!1;return!0}function El(n,r,l,d,f,g){if(ss=g,_e=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,Vr.current=n===null||n.memoizedState===null?sy:iy,n=l(d,f),Li){g=0;do{if(Li=!1,Pi=0,25<=g)throw Error(s(301));g+=1,et=Je=null,r.updateQueue=null,Vr.current=ry,n=l(d,f)}while(Li)}if(Vr.current=Yr,r=Je!==null&&Je.next!==null,ss=0,et=Je=_e=null,Gr=!1,r)throw Error(s(300));return n}function Al(){var n=Pi!==0;return Pi=0,n}function nn(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return et===null?_e.memoizedState=et=n:et=et.next=n,et}function Rt(){if(Je===null){var n=_e.alternate;n=n!==null?n.memoizedState:null}else n=Je.next;var r=et===null?_e.memoizedState:et.next;if(r!==null)et=r,Je=n;else{if(n===null)throw Error(s(310));Je=n,n={memoizedState:Je.memoizedState,baseState:Je.baseState,baseQueue:Je.baseQueue,queue:Je.queue,next:null},et===null?_e.memoizedState=et=n:et=et.next=n}return et}function _i(n,r){return typeof r=="function"?r(n):r}function Il(n){var r=Rt(),l=r.queue;if(l===null)throw Error(s(311));l.lastRenderedReducer=n;var d=Je,f=d.baseQueue,g=l.pending;if(g!==null){if(f!==null){var w=f.next;f.next=g.next,g.next=w}d.baseQueue=f=g,l.pending=null}if(f!==null){g=f.next,d=d.baseState;var b=w=null,$=null,O=g;do{var F=O.lane;if((ss&F)===F)$!==null&&($=$.next={lane:0,action:O.action,hasEagerState:O.hasEagerState,eagerState:O.eagerState,next:null}),d=O.hasEagerState?O.eagerState:n(d,O.action);else{var H={lane:F,action:O.action,hasEagerState:O.hasEagerState,eagerState:O.eagerState,next:null};$===null?(b=$=H,w=d):$=$.next=H,_e.lanes|=F,is|=F}O=O.next}while(O!==null&&O!==g);$===null?w=d:$.next=b,Ut(d,r.memoizedState)||(kt=!0),r.memoizedState=d,r.baseState=w,r.baseQueue=$,l.lastRenderedState=d}if(n=l.interleaved,n!==null){f=n;do g=f.lane,_e.lanes|=g,is|=g,f=f.next;while(f!==n)}else f===null&&(l.lanes=0);return[r.memoizedState,l.dispatch]}function Ml(n){var r=Rt(),l=r.queue;if(l===null)throw Error(s(311));l.lastRenderedReducer=n;var d=l.dispatch,f=l.pending,g=r.memoizedState;if(f!==null){l.pending=null;var w=f=f.next;do g=n(g,w.action),w=w.next;while(w!==f);Ut(g,r.memoizedState)||(kt=!0),r.memoizedState=g,r.baseQueue===null&&(r.baseState=g),l.lastRenderedState=g}return[g,d]}function kh(){}function yh(n,r){var l=_e,d=Rt(),f=r(),g=!Ut(d.memoizedState,f);if(g&&(d.memoizedState=f,kt=!0),d=d.queue,Rl(jh.bind(null,l,d,n),[n]),d.getSnapshot!==r||g||et!==null&&et.memoizedState.tag&1){if(l.flags|=2048,Di(9,xh.bind(null,l,d,f,r),void 0,null),tt===null)throw Error(s(349));(ss&30)!==0||wh(l,r,f)}return f}function wh(n,r,l){n.flags|=16384,n={getSnapshot:r,value:l},r=_e.updateQueue,r===null?(r={lastEffect:null,stores:null},_e.updateQueue=r,r.stores=[n]):(l=r.stores,l===null?r.stores=[n]:l.push(n))}function xh(n,r,l,d){r.value=l,r.getSnapshot=d,Nh(r)&&Sh(n)}function jh(n,r,l){return l(function(){Nh(r)&&Sh(n)})}function Nh(n){var r=n.getSnapshot;n=n.value;try{var l=r();return!Ut(n,l)}catch{return!0}}function Sh(n){var r=vn(n,1);r!==null&&Gt(r,n,1,-1)}function bh(n){var r=nn();return typeof n=="function"&&(n=n()),r.memoizedState=r.baseState=n,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:_i,lastRenderedState:n},r.queue=n,n=n.dispatch=ny.bind(null,_e,n),[r.memoizedState,n]}function Di(n,r,l,d){return n={tag:n,create:r,destroy:l,deps:d,next:null},r=_e.updateQueue,r===null?(r={lastEffect:null,stores:null},_e.updateQueue=r,r.lastEffect=n.next=n):(l=r.lastEffect,l===null?r.lastEffect=n.next=n:(d=l.next,l.next=n,n.next=d,r.lastEffect=n)),n}function Ch(){return Rt().memoizedState}function qr(n,r,l,d){var f=nn();_e.flags|=n,f.memoizedState=Di(1|r,l,void 0,d===void 0?null:d)}function Qr(n,r,l,d){var f=Rt();d=d===void 0?null:d;var g=void 0;if(Je!==null){var w=Je.memoizedState;if(g=w.destroy,d!==null&&Tl(d,w.deps)){f.memoizedState=Di(r,l,g,d);return}}_e.flags|=n,f.memoizedState=Di(1|r,l,g,d)}function $h(n,r){return qr(8390656,8,n,r)}function Rl(n,r){return Qr(2048,8,n,r)}function Th(n,r){return Qr(4,2,n,r)}function Eh(n,r){return Qr(4,4,n,r)}function Ah(n,r){if(typeof r=="function")return n=n(),r(n),function(){r(null)};if(r!=null)return n=n(),r.current=n,function(){r.current=null}}function Ih(n,r,l){return l=l!=null?l.concat([n]):null,Qr(4,4,Ah.bind(null,r,n),l)}function Ol(){}function Mh(n,r){var l=Rt();r=r===void 0?null:r;var d=l.memoizedState;return d!==null&&r!==null&&Tl(r,d[1])?d[0]:(l.memoizedState=[n,r],n)}function Rh(n,r){var l=Rt();r=r===void 0?null:r;var d=l.memoizedState;return d!==null&&r!==null&&Tl(r,d[1])?d[0]:(n=n(),l.memoizedState=[n,r],n)}function Oh(n,r,l){return(ss&21)===0?(n.baseState&&(n.baseState=!1,kt=!0),n.memoizedState=l):(Ut(l,r)||(l=ud(),_e.lanes|=l,is|=l,n.baseState=!0),r)}function ey(n,r){var l=Te;Te=l!==0&&4>l?l:4,n(!0);var d=$l.transition;$l.transition={};try{n(!1),r()}finally{Te=l,$l.transition=d}}function Lh(){return Rt().memoizedState}function ty(n,r,l){var d=Bn(n);if(l={lane:d,action:l,hasEagerState:!1,eagerState:null,next:null},Ph(n))_h(r,l);else if(l=fh(n,r,l,d),l!==null){var f=ft();Gt(l,n,d,f),Dh(l,r,d)}}function ny(n,r,l){var d=Bn(n),f={lane:d,action:l,hasEagerState:!1,eagerState:null,next:null};if(Ph(n))_h(r,f);else{var g=n.alternate;if(n.lanes===0&&(g===null||g.lanes===0)&&(g=r.lastRenderedReducer,g!==null))try{var w=r.lastRenderedState,b=g(w,l);if(f.hasEagerState=!0,f.eagerState=b,Ut(b,w)){var $=r.interleaved;$===null?(f.next=f,xl(r)):(f.next=$.next,$.next=f),r.interleaved=f;return}}catch{}finally{}l=fh(n,r,f,d),l!==null&&(f=ft(),Gt(l,n,d,f),Dh(l,r,d))}}function Ph(n){var r=n.alternate;return n===_e||r!==null&&r===_e}function _h(n,r){Li=Gr=!0;var l=n.pending;l===null?r.next=r:(r.next=l.next,l.next=r),n.pending=r}function Dh(n,r,l){if((l&4194240)!==0){var d=r.lanes;d&=n.pendingLanes,l|=d,r.lanes=l,Pa(n,l)}}var Yr={readContext:Mt,useCallback:at,useContext:at,useEffect:at,useImperativeHandle:at,useInsertionEffect:at,useLayoutEffect:at,useMemo:at,useReducer:at,useRef:at,useState:at,useDebugValue:at,useDeferredValue:at,useTransition:at,useMutableSource:at,useSyncExternalStore:at,useId:at,unstable_isNewReconciler:!1},sy={readContext:Mt,useCallback:function(n,r){return nn().memoizedState=[n,r===void 0?null:r],n},useContext:Mt,useEffect:$h,useImperativeHandle:function(n,r,l){return l=l!=null?l.concat([n]):null,qr(4194308,4,Ah.bind(null,r,n),l)},useLayoutEffect:function(n,r){return qr(4194308,4,n,r)},useInsertionEffect:function(n,r){return qr(4,2,n,r)},useMemo:function(n,r){var l=nn();return r=r===void 0?null:r,n=n(),l.memoizedState=[n,r],n},useReducer:function(n,r,l){var d=nn();return r=l!==void 0?l(r):r,d.memoizedState=d.baseState=r,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:r},d.queue=n,n=n.dispatch=ty.bind(null,_e,n),[d.memoizedState,n]},useRef:function(n){var r=nn();return n={current:n},r.memoizedState=n},useState:bh,useDebugValue:Ol,useDeferredValue:function(n){return nn().memoizedState=n},useTransition:function(){var n=bh(!1),r=n[0];return n=ey.bind(null,n[1]),nn().memoizedState=n,[r,n]},useMutableSource:function(){},useSyncExternalStore:function(n,r,l){var d=_e,f=nn();if(Oe){if(l===void 0)throw Error(s(407));l=l()}else{if(l=r(),tt===null)throw Error(s(349));(ss&30)!==0||wh(d,r,l)}f.memoizedState=l;var g={value:l,getSnapshot:r};return f.queue=g,$h(jh.bind(null,d,g,n),[n]),d.flags|=2048,Di(9,xh.bind(null,d,g,l,r),void 0,null),l},useId:function(){var n=nn(),r=tt.identifierPrefix;if(Oe){var l=gn,d=pn;l=(d&~(1<<32-Ft(d)-1)).toString(32)+l,r=":"+r+"R"+l,l=Pi++,0<l&&(r+="H"+l.toString(32)),r+=":"}else l=Zk++,r=":"+r+"r"+l.toString(32)+":";return n.memoizedState=r},unstable_isNewReconciler:!1},iy={readContext:Mt,useCallback:Mh,useContext:Mt,useEffect:Rl,useImperativeHandle:Ih,useInsertionEffect:Th,useLayoutEffect:Eh,useMemo:Rh,useReducer:Il,useRef:Ch,useState:function(){return Il(_i)},useDebugValue:Ol,useDeferredValue:function(n){var r=Rt();return Oh(r,Je.memoizedState,n)},useTransition:function(){var n=Il(_i)[0],r=Rt().memoizedState;return[n,r]},useMutableSource:kh,useSyncExternalStore:yh,useId:Lh,unstable_isNewReconciler:!1},ry={readContext:Mt,useCallback:Mh,useContext:Mt,useEffect:Rl,useImperativeHandle:Ih,useInsertionEffect:Th,useLayoutEffect:Eh,useMemo:Rh,useReducer:Ml,useRef:Ch,useState:function(){return Ml(_i)},useDebugValue:Ol,useDeferredValue:function(n){var r=Rt();return Je===null?r.memoizedState=n:Oh(r,Je.memoizedState,n)},useTransition:function(){var n=Ml(_i)[0],r=Rt().memoizedState;return[n,r]},useMutableSource:kh,useSyncExternalStore:yh,useId:Lh,unstable_isNewReconciler:!1};function Ht(n,r){if(n&&n.defaultProps){r=B({},r),n=n.defaultProps;for(var l in n)r[l]===void 0&&(r[l]=n[l]);return r}return r}function Ll(n,r,l,d){r=n.memoizedState,l=l(d,r),l=l==null?r:B({},r,l),n.memoizedState=l,n.lanes===0&&(n.updateQueue.baseState=l)}var Jr={isMounted:function(n){return(n=n._reactInternals)?Yn(n)===n:!1},enqueueSetState:function(n,r,l){n=n._reactInternals;var d=ft(),f=Bn(n),g=kn(d,f);g.payload=r,l!=null&&(g.callback=l),r=Pn(n,g,f),r!==null&&(Gt(r,n,f,d),Wr(r,n,f))},enqueueReplaceState:function(n,r,l){n=n._reactInternals;var d=ft(),f=Bn(n),g=kn(d,f);g.tag=1,g.payload=r,l!=null&&(g.callback=l),r=Pn(n,g,f),r!==null&&(Gt(r,n,f,d),Wr(r,n,f))},enqueueForceUpdate:function(n,r){n=n._reactInternals;var l=ft(),d=Bn(n),f=kn(l,d);f.tag=2,r!=null&&(f.callback=r),r=Pn(n,f,d),r!==null&&(Gt(r,n,d,l),Wr(r,n,d))}};function zh(n,r,l,d,f,g,w){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(d,g,w):r.prototype&&r.prototype.isPureReactComponent?!Si(l,d)||!Si(f,g):!0}function Bh(n,r,l){var d=!1,f=Rn,g=r.contextType;return typeof g=="object"&&g!==null?g=Mt(g):(f=vt(r)?Xn:ot.current,d=r.contextTypes,g=(d=d!=null)?$s(n,f):Rn),r=new r(l,g),n.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=Jr,n.stateNode=r,r._reactInternals=n,d&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=f,n.__reactInternalMemoizedMaskedChildContext=g),r}function Fh(n,r,l,d){n=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(l,d),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(l,d),r.state!==n&&Jr.enqueueReplaceState(r,r.state,null)}function Pl(n,r,l,d){var f=n.stateNode;f.props=l,f.state=n.memoizedState,f.refs={},jl(n);var g=r.contextType;typeof g=="object"&&g!==null?f.context=Mt(g):(g=vt(r)?Xn:ot.current,f.context=$s(n,g)),f.state=n.memoizedState,g=r.getDerivedStateFromProps,typeof g=="function"&&(Ll(n,r,g,l),f.state=n.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof f.getSnapshotBeforeUpdate=="function"||typeof f.UNSAFE_componentWillMount!="function"&&typeof f.componentWillMount!="function"||(r=f.state,typeof f.componentWillMount=="function"&&f.componentWillMount(),typeof f.UNSAFE_componentWillMount=="function"&&f.UNSAFE_componentWillMount(),r!==f.state&&Jr.enqueueReplaceState(f,f.state,null),Hr(n,l,f,d),f.state=n.memoizedState),typeof f.componentDidMount=="function"&&(n.flags|=4194308)}function Ls(n,r){try{var l="",d=r;do l+=ke(d),d=d.return;while(d);var f=l}catch(g){f=`
39
+ Error generating stack: `+g.message+`
40
+ `+g.stack}return{value:n,source:r,stack:f,digest:null}}function _l(n,r,l){return{value:n,source:null,stack:l??null,digest:r??null}}function Dl(n,r){try{console.error(r.value)}catch(l){setTimeout(function(){throw l})}}var oy=typeof WeakMap=="function"?WeakMap:Map;function Uh(n,r,l){l=kn(-1,l),l.tag=3,l.payload={element:null};var d=r.value;return l.callback=function(){io||(io=!0,Zl=d),Dl(n,r)},l}function Wh(n,r,l){l=kn(-1,l),l.tag=3;var d=n.type.getDerivedStateFromError;if(typeof d=="function"){var f=r.value;l.payload=function(){return d(f)},l.callback=function(){Dl(n,r)}}var g=n.stateNode;return g!==null&&typeof g.componentDidCatch=="function"&&(l.callback=function(){Dl(n,r),typeof d!="function"&&(Dn===null?Dn=new Set([this]):Dn.add(this));var w=r.stack;this.componentDidCatch(r.value,{componentStack:w!==null?w:""})}),l}function Hh(n,r,l){var d=n.pingCache;if(d===null){d=n.pingCache=new oy;var f=new Set;d.set(r,f)}else f=d.get(r),f===void 0&&(f=new Set,d.set(r,f));f.has(l)||(f.add(l),n=wy.bind(null,n,r,l),r.then(n,n))}function Kh(n){do{var r;if((r=n.tag===13)&&(r=n.memoizedState,r=r!==null?r.dehydrated!==null:!0),r)return n;n=n.return}while(n!==null);return null}function Vh(n,r,l,d,f){return(n.mode&1)===0?(n===r?n.flags|=65536:(n.flags|=128,l.flags|=131072,l.flags&=-52805,l.tag===1&&(l.alternate===null?l.tag=17:(r=kn(-1,1),r.tag=2,Pn(l,r,1))),l.lanes|=1),n):(n.flags|=65536,n.lanes=f,n)}var ay=U.ReactCurrentOwner,kt=!1;function ht(n,r,l,d){r.child=n===null?hh(r,null,l,d):Is(r,n.child,l,d)}function Gh(n,r,l,d,f){l=l.render;var g=r.ref;return Rs(r,f),d=El(n,r,l,d,g,f),l=Al(),n!==null&&!kt?(r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~f,yn(n,r,f)):(Oe&&l&&hl(r),r.flags|=1,ht(n,r,d,f),r.child)}function qh(n,r,l,d,f){if(n===null){var g=l.type;return typeof g=="function"&&!oc(g)&&g.defaultProps===void 0&&l.compare===null&&l.defaultProps===void 0?(r.tag=15,r.type=g,Qh(n,r,g,d,f)):(n=uo(l.type,null,d,r,r.mode,f),n.ref=r.ref,n.return=r,r.child=n)}if(g=n.child,(n.lanes&f)===0){var w=g.memoizedProps;if(l=l.compare,l=l!==null?l:Si,l(w,d)&&n.ref===r.ref)return yn(n,r,f)}return r.flags|=1,n=Un(g,d),n.ref=r.ref,n.return=r,r.child=n}function Qh(n,r,l,d,f){if(n!==null){var g=n.memoizedProps;if(Si(g,d)&&n.ref===r.ref)if(kt=!1,r.pendingProps=d=g,(n.lanes&f)!==0)(n.flags&131072)!==0&&(kt=!0);else return r.lanes=n.lanes,yn(n,r,f)}return zl(n,r,l,d,f)}function Yh(n,r,l){var d=r.pendingProps,f=d.children,g=n!==null?n.memoizedState:null;if(d.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ee(_s,Tt),Tt|=l;else{if((l&1073741824)===0)return n=g!==null?g.baseLanes|l:l,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:n,cachePool:null,transitions:null},r.updateQueue=null,Ee(_s,Tt),Tt|=n,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},d=g!==null?g.baseLanes:l,Ee(_s,Tt),Tt|=d}else g!==null?(d=g.baseLanes|l,r.memoizedState=null):d=l,Ee(_s,Tt),Tt|=d;return ht(n,r,f,l),r.child}function Jh(n,r){var l=r.ref;(n===null&&l!==null||n!==null&&n.ref!==l)&&(r.flags|=512,r.flags|=2097152)}function zl(n,r,l,d,f){var g=vt(l)?Xn:ot.current;return g=$s(r,g),Rs(r,f),l=El(n,r,l,d,g,f),d=Al(),n!==null&&!kt?(r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~f,yn(n,r,f)):(Oe&&d&&hl(r),r.flags|=1,ht(n,r,l,f),r.child)}function Xh(n,r,l,d,f){if(vt(l)){var g=!0;Lr(r)}else g=!1;if(Rs(r,f),r.stateNode===null)Zr(n,r),Bh(r,l,d),Pl(r,l,d,f),d=!0;else if(n===null){var w=r.stateNode,b=r.memoizedProps;w.props=b;var $=w.context,O=l.contextType;typeof O=="object"&&O!==null?O=Mt(O):(O=vt(l)?Xn:ot.current,O=$s(r,O));var F=l.getDerivedStateFromProps,H=typeof F=="function"||typeof w.getSnapshotBeforeUpdate=="function";H||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(b!==d||$!==O)&&Fh(r,w,d,O),Ln=!1;var z=r.memoizedState;w.state=z,Hr(r,d,w,f),$=r.memoizedState,b!==d||z!==$||gt.current||Ln?(typeof F=="function"&&(Ll(r,l,F,d),$=r.memoizedState),(b=Ln||zh(r,l,b,d,z,$,O))?(H||typeof w.UNSAFE_componentWillMount!="function"&&typeof w.componentWillMount!="function"||(typeof w.componentWillMount=="function"&&w.componentWillMount(),typeof w.UNSAFE_componentWillMount=="function"&&w.UNSAFE_componentWillMount()),typeof w.componentDidMount=="function"&&(r.flags|=4194308)):(typeof w.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=d,r.memoizedState=$),w.props=d,w.state=$,w.context=O,d=b):(typeof w.componentDidMount=="function"&&(r.flags|=4194308),d=!1)}else{w=r.stateNode,mh(n,r),b=r.memoizedProps,O=r.type===r.elementType?b:Ht(r.type,b),w.props=O,H=r.pendingProps,z=w.context,$=l.contextType,typeof $=="object"&&$!==null?$=Mt($):($=vt(l)?Xn:ot.current,$=$s(r,$));var ee=l.getDerivedStateFromProps;(F=typeof ee=="function"||typeof w.getSnapshotBeforeUpdate=="function")||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(b!==H||z!==$)&&Fh(r,w,d,$),Ln=!1,z=r.memoizedState,w.state=z,Hr(r,d,w,f);var se=r.memoizedState;b!==H||z!==se||gt.current||Ln?(typeof ee=="function"&&(Ll(r,l,ee,d),se=r.memoizedState),(O=Ln||zh(r,l,O,d,z,se,$)||!1)?(F||typeof w.UNSAFE_componentWillUpdate!="function"&&typeof w.componentWillUpdate!="function"||(typeof w.componentWillUpdate=="function"&&w.componentWillUpdate(d,se,$),typeof w.UNSAFE_componentWillUpdate=="function"&&w.UNSAFE_componentWillUpdate(d,se,$)),typeof w.componentDidUpdate=="function"&&(r.flags|=4),typeof w.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof w.componentDidUpdate!="function"||b===n.memoizedProps&&z===n.memoizedState||(r.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||b===n.memoizedProps&&z===n.memoizedState||(r.flags|=1024),r.memoizedProps=d,r.memoizedState=se),w.props=d,w.state=se,w.context=$,d=O):(typeof w.componentDidUpdate!="function"||b===n.memoizedProps&&z===n.memoizedState||(r.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||b===n.memoizedProps&&z===n.memoizedState||(r.flags|=1024),d=!1)}return Bl(n,r,l,d,g,f)}function Bl(n,r,l,d,f,g){Jh(n,r);var w=(r.flags&128)!==0;if(!d&&!w)return f&&sh(r,l,!1),yn(n,r,g);d=r.stateNode,ay.current=r;var b=w&&typeof l.getDerivedStateFromError!="function"?null:d.render();return r.flags|=1,n!==null&&w?(r.child=Is(r,n.child,null,g),r.child=Is(r,null,b,g)):ht(n,r,b,g),r.memoizedState=d.state,f&&sh(r,l,!0),r.child}function Zh(n){var r=n.stateNode;r.pendingContext?th(n,r.pendingContext,r.pendingContext!==r.context):r.context&&th(n,r.context,!1),Nl(n,r.containerInfo)}function ef(n,r,l,d,f){return As(),gl(f),r.flags|=256,ht(n,r,l,d),r.child}var Fl={dehydrated:null,treeContext:null,retryLane:0};function Ul(n){return{baseLanes:n,cachePool:null,transitions:null}}function tf(n,r,l){var d=r.pendingProps,f=Pe.current,g=!1,w=(r.flags&128)!==0,b;if((b=w)||(b=n!==null&&n.memoizedState===null?!1:(f&2)!==0),b?(g=!0,r.flags&=-129):(n===null||n.memoizedState!==null)&&(f|=1),Ee(Pe,f&1),n===null)return pl(r),n=r.memoizedState,n!==null&&(n=n.dehydrated,n!==null)?((r.mode&1)===0?r.lanes=1:n.data==="$!"?r.lanes=8:r.lanes=1073741824,null):(w=d.children,n=d.fallback,g?(d=r.mode,g=r.child,w={mode:"hidden",children:w},(d&1)===0&&g!==null?(g.childLanes=0,g.pendingProps=w):g=ho(w,d,0,null),n=ls(n,d,l,null),g.return=r,n.return=r,g.sibling=n,r.child=g,r.child.memoizedState=Ul(l),r.memoizedState=Fl,n):Wl(r,w));if(f=n.memoizedState,f!==null&&(b=f.dehydrated,b!==null))return ly(n,r,w,d,b,f,l);if(g){g=d.fallback,w=r.mode,f=n.child,b=f.sibling;var $={mode:"hidden",children:d.children};return(w&1)===0&&r.child!==f?(d=r.child,d.childLanes=0,d.pendingProps=$,r.deletions=null):(d=Un(f,$),d.subtreeFlags=f.subtreeFlags&14680064),b!==null?g=Un(b,g):(g=ls(g,w,l,null),g.flags|=2),g.return=r,d.return=r,d.sibling=g,r.child=d,d=g,g=r.child,w=n.child.memoizedState,w=w===null?Ul(l):{baseLanes:w.baseLanes|l,cachePool:null,transitions:w.transitions},g.memoizedState=w,g.childLanes=n.childLanes&~l,r.memoizedState=Fl,d}return g=n.child,n=g.sibling,d=Un(g,{mode:"visible",children:d.children}),(r.mode&1)===0&&(d.lanes=l),d.return=r,d.sibling=null,n!==null&&(l=r.deletions,l===null?(r.deletions=[n],r.flags|=16):l.push(n)),r.child=d,r.memoizedState=null,d}function Wl(n,r){return r=ho({mode:"visible",children:r},n.mode,0,null),r.return=n,n.child=r}function Xr(n,r,l,d){return d!==null&&gl(d),Is(r,n.child,null,l),n=Wl(r,r.pendingProps.children),n.flags|=2,r.memoizedState=null,n}function ly(n,r,l,d,f,g,w){if(l)return r.flags&256?(r.flags&=-257,d=_l(Error(s(422))),Xr(n,r,w,d)):r.memoizedState!==null?(r.child=n.child,r.flags|=128,null):(g=d.fallback,f=r.mode,d=ho({mode:"visible",children:d.children},f,0,null),g=ls(g,f,w,null),g.flags|=2,d.return=r,g.return=r,d.sibling=g,r.child=d,(r.mode&1)!==0&&Is(r,n.child,null,w),r.child.memoizedState=Ul(w),r.memoizedState=Fl,g);if((r.mode&1)===0)return Xr(n,r,w,null);if(f.data==="$!"){if(d=f.nextSibling&&f.nextSibling.dataset,d)var b=d.dgst;return d=b,g=Error(s(419)),d=_l(g,d,void 0),Xr(n,r,w,d)}if(b=(w&n.childLanes)!==0,kt||b){if(d=tt,d!==null){switch(w&-w){case 4:f=2;break;case 16:f=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:f=32;break;case 536870912:f=268435456;break;default:f=0}f=(f&(d.suspendedLanes|w))!==0?0:f,f!==0&&f!==g.retryLane&&(g.retryLane=f,vn(n,f),Gt(d,n,f,-1))}return rc(),d=_l(Error(s(421))),Xr(n,r,w,d)}return f.data==="$?"?(r.flags|=128,r.child=n.child,r=xy.bind(null,n),f._reactRetry=r,null):(n=g.treeContext,$t=In(f.nextSibling),Ct=r,Oe=!0,Wt=null,n!==null&&(At[It++]=pn,At[It++]=gn,At[It++]=Zn,pn=n.id,gn=n.overflow,Zn=r),r=Wl(r,d.children),r.flags|=4096,r)}function nf(n,r,l){n.lanes|=r;var d=n.alternate;d!==null&&(d.lanes|=r),wl(n.return,r,l)}function Hl(n,r,l,d,f){var g=n.memoizedState;g===null?n.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:d,tail:l,tailMode:f}:(g.isBackwards=r,g.rendering=null,g.renderingStartTime=0,g.last=d,g.tail=l,g.tailMode=f)}function sf(n,r,l){var d=r.pendingProps,f=d.revealOrder,g=d.tail;if(ht(n,r,d.children,l),d=Pe.current,(d&2)!==0)d=d&1|2,r.flags|=128;else{if(n!==null&&(n.flags&128)!==0)e:for(n=r.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&nf(n,l,r);else if(n.tag===19)nf(n,l,r);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===r)break e;for(;n.sibling===null;){if(n.return===null||n.return===r)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}d&=1}if(Ee(Pe,d),(r.mode&1)===0)r.memoizedState=null;else switch(f){case"forwards":for(l=r.child,f=null;l!==null;)n=l.alternate,n!==null&&Kr(n)===null&&(f=l),l=l.sibling;l=f,l===null?(f=r.child,r.child=null):(f=l.sibling,l.sibling=null),Hl(r,!1,f,l,g);break;case"backwards":for(l=null,f=r.child,r.child=null;f!==null;){if(n=f.alternate,n!==null&&Kr(n)===null){r.child=f;break}n=f.sibling,f.sibling=l,l=f,f=n}Hl(r,!0,l,null,g);break;case"together":Hl(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function Zr(n,r){(r.mode&1)===0&&n!==null&&(n.alternate=null,r.alternate=null,r.flags|=2)}function yn(n,r,l){if(n!==null&&(r.dependencies=n.dependencies),is|=r.lanes,(l&r.childLanes)===0)return null;if(n!==null&&r.child!==n.child)throw Error(s(153));if(r.child!==null){for(n=r.child,l=Un(n,n.pendingProps),r.child=l,l.return=r;n.sibling!==null;)n=n.sibling,l=l.sibling=Un(n,n.pendingProps),l.return=r;l.sibling=null}return r.child}function cy(n,r,l){switch(r.tag){case 3:Zh(r),As();break;case 5:vh(r);break;case 1:vt(r.type)&&Lr(r);break;case 4:Nl(r,r.stateNode.containerInfo);break;case 10:var d=r.type._context,f=r.memoizedProps.value;Ee(Fr,d._currentValue),d._currentValue=f;break;case 13:if(d=r.memoizedState,d!==null)return d.dehydrated!==null?(Ee(Pe,Pe.current&1),r.flags|=128,null):(l&r.child.childLanes)!==0?tf(n,r,l):(Ee(Pe,Pe.current&1),n=yn(n,r,l),n!==null?n.sibling:null);Ee(Pe,Pe.current&1);break;case 19:if(d=(l&r.childLanes)!==0,(n.flags&128)!==0){if(d)return sf(n,r,l);r.flags|=128}if(f=r.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),Ee(Pe,Pe.current),d)break;return null;case 22:case 23:return r.lanes=0,Yh(n,r,l)}return yn(n,r,l)}var rf,Kl,of,af;rf=function(n,r){for(var l=r.child;l!==null;){if(l.tag===5||l.tag===6)n.appendChild(l.stateNode);else if(l.tag!==4&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===r)break;for(;l.sibling===null;){if(l.return===null||l.return===r)return;l=l.return}l.sibling.return=l.return,l=l.sibling}},Kl=function(){},of=function(n,r,l,d){var f=n.memoizedProps;if(f!==d){n=r.stateNode,ns(tn.current);var g=null;switch(l){case"input":f=wa(n,f),d=wa(n,d),g=[];break;case"select":f=B({},f,{value:void 0}),d=B({},d,{value:void 0}),g=[];break;case"textarea":f=Na(n,f),d=Na(n,d),g=[];break;default:typeof f.onClick!="function"&&typeof d.onClick=="function"&&(n.onclick=Mr)}ba(l,d);var w;l=null;for(O in f)if(!d.hasOwnProperty(O)&&f.hasOwnProperty(O)&&f[O]!=null)if(O==="style"){var b=f[O];for(w in b)b.hasOwnProperty(w)&&(l||(l={}),l[w]="")}else O!=="dangerouslySetInnerHTML"&&O!=="children"&&O!=="suppressContentEditableWarning"&&O!=="suppressHydrationWarning"&&O!=="autoFocus"&&(a.hasOwnProperty(O)?g||(g=[]):(g=g||[]).push(O,null));for(O in d){var $=d[O];if(b=f!=null?f[O]:void 0,d.hasOwnProperty(O)&&$!==b&&($!=null||b!=null))if(O==="style")if(b){for(w in b)!b.hasOwnProperty(w)||$&&$.hasOwnProperty(w)||(l||(l={}),l[w]="");for(w in $)$.hasOwnProperty(w)&&b[w]!==$[w]&&(l||(l={}),l[w]=$[w])}else l||(g||(g=[]),g.push(O,l)),l=$;else O==="dangerouslySetInnerHTML"?($=$?$.__html:void 0,b=b?b.__html:void 0,$!=null&&b!==$&&(g=g||[]).push(O,$)):O==="children"?typeof $!="string"&&typeof $!="number"||(g=g||[]).push(O,""+$):O!=="suppressContentEditableWarning"&&O!=="suppressHydrationWarning"&&(a.hasOwnProperty(O)?($!=null&&O==="onScroll"&&Me("scroll",n),g||b===$||(g=[])):(g=g||[]).push(O,$))}l&&(g=g||[]).push("style",l);var O=g;(r.updateQueue=O)&&(r.flags|=4)}},af=function(n,r,l,d){l!==d&&(r.flags|=4)};function zi(n,r){if(!Oe)switch(n.tailMode){case"hidden":r=n.tail;for(var l=null;r!==null;)r.alternate!==null&&(l=r),r=r.sibling;l===null?n.tail=null:l.sibling=null;break;case"collapsed":l=n.tail;for(var d=null;l!==null;)l.alternate!==null&&(d=l),l=l.sibling;d===null?r||n.tail===null?n.tail=null:n.tail.sibling=null:d.sibling=null}}function lt(n){var r=n.alternate!==null&&n.alternate.child===n.child,l=0,d=0;if(r)for(var f=n.child;f!==null;)l|=f.lanes|f.childLanes,d|=f.subtreeFlags&14680064,d|=f.flags&14680064,f.return=n,f=f.sibling;else for(f=n.child;f!==null;)l|=f.lanes|f.childLanes,d|=f.subtreeFlags,d|=f.flags,f.return=n,f=f.sibling;return n.subtreeFlags|=d,n.childLanes=l,r}function uy(n,r,l){var d=r.pendingProps;switch(fl(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return lt(r),null;case 1:return vt(r.type)&&Or(),lt(r),null;case 3:return d=r.stateNode,Os(),Re(gt),Re(ot),Cl(),d.pendingContext&&(d.context=d.pendingContext,d.pendingContext=null),(n===null||n.child===null)&&(zr(r)?r.flags|=4:n===null||n.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,Wt!==null&&(nc(Wt),Wt=null))),Kl(n,r),lt(r),null;case 5:Sl(r);var f=ns(Oi.current);if(l=r.type,n!==null&&r.stateNode!=null)of(n,r,l,d,f),n.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!d){if(r.stateNode===null)throw Error(s(166));return lt(r),null}if(n=ns(tn.current),zr(r)){d=r.stateNode,l=r.type;var g=r.memoizedProps;switch(d[en]=r,d[Ei]=g,n=(r.mode&1)!==0,l){case"dialog":Me("cancel",d),Me("close",d);break;case"iframe":case"object":case"embed":Me("load",d);break;case"video":case"audio":for(f=0;f<Ci.length;f++)Me(Ci[f],d);break;case"source":Me("error",d);break;case"img":case"image":case"link":Me("error",d),Me("load",d);break;case"details":Me("toggle",d);break;case"input":Bu(d,g),Me("invalid",d);break;case"select":d._wrapperState={wasMultiple:!!g.multiple},Me("invalid",d);break;case"textarea":Wu(d,g),Me("invalid",d)}ba(l,g),f=null;for(var w in g)if(g.hasOwnProperty(w)){var b=g[w];w==="children"?typeof b=="string"?d.textContent!==b&&(g.suppressHydrationWarning!==!0&&Ir(d.textContent,b,n),f=["children",b]):typeof b=="number"&&d.textContent!==""+b&&(g.suppressHydrationWarning!==!0&&Ir(d.textContent,b,n),f=["children",""+b]):a.hasOwnProperty(w)&&b!=null&&w==="onScroll"&&Me("scroll",d)}switch(l){case"input":Sn(d),Uu(d,g,!0);break;case"textarea":Sn(d),Ku(d);break;case"select":case"option":break;default:typeof g.onClick=="function"&&(d.onclick=Mr)}d=f,r.updateQueue=d,d!==null&&(r.flags|=4)}else{w=f.nodeType===9?f:f.ownerDocument,n==="http://www.w3.org/1999/xhtml"&&(n=Vu(l)),n==="http://www.w3.org/1999/xhtml"?l==="script"?(n=w.createElement("div"),n.innerHTML="<script><\/script>",n=n.removeChild(n.firstChild)):typeof d.is=="string"?n=w.createElement(l,{is:d.is}):(n=w.createElement(l),l==="select"&&(w=n,d.multiple?w.multiple=!0:d.size&&(w.size=d.size))):n=w.createElementNS(n,l),n[en]=r,n[Ei]=d,rf(n,r,!1,!1),r.stateNode=n;e:{switch(w=Ca(l,d),l){case"dialog":Me("cancel",n),Me("close",n),f=d;break;case"iframe":case"object":case"embed":Me("load",n),f=d;break;case"video":case"audio":for(f=0;f<Ci.length;f++)Me(Ci[f],n);f=d;break;case"source":Me("error",n),f=d;break;case"img":case"image":case"link":Me("error",n),Me("load",n),f=d;break;case"details":Me("toggle",n),f=d;break;case"input":Bu(n,d),f=wa(n,d),Me("invalid",n);break;case"option":f=d;break;case"select":n._wrapperState={wasMultiple:!!d.multiple},f=B({},d,{value:void 0}),Me("invalid",n);break;case"textarea":Wu(n,d),f=Na(n,d),Me("invalid",n);break;default:f=d}ba(l,f),b=f;for(g in b)if(b.hasOwnProperty(g)){var $=b[g];g==="style"?Qu(n,$):g==="dangerouslySetInnerHTML"?($=$?$.__html:void 0,$!=null&&Gu(n,$)):g==="children"?typeof $=="string"?(l!=="textarea"||$!=="")&&ai(n,$):typeof $=="number"&&ai(n,""+$):g!=="suppressContentEditableWarning"&&g!=="suppressHydrationWarning"&&g!=="autoFocus"&&(a.hasOwnProperty(g)?$!=null&&g==="onScroll"&&Me("scroll",n):$!=null&&L(n,g,$,w))}switch(l){case"input":Sn(n),Uu(n,d,!1);break;case"textarea":Sn(n),Ku(n);break;case"option":d.value!=null&&n.setAttribute("value",""+Ne(d.value));break;case"select":n.multiple=!!d.multiple,g=d.value,g!=null?ps(n,!!d.multiple,g,!1):d.defaultValue!=null&&ps(n,!!d.multiple,d.defaultValue,!0);break;default:typeof f.onClick=="function"&&(n.onclick=Mr)}switch(l){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}}d&&(r.flags|=4)}r.ref!==null&&(r.flags|=512,r.flags|=2097152)}return lt(r),null;case 6:if(n&&r.stateNode!=null)af(n,r,n.memoizedProps,d);else{if(typeof d!="string"&&r.stateNode===null)throw Error(s(166));if(l=ns(Oi.current),ns(tn.current),zr(r)){if(d=r.stateNode,l=r.memoizedProps,d[en]=r,(g=d.nodeValue!==l)&&(n=Ct,n!==null))switch(n.tag){case 3:Ir(d.nodeValue,l,(n.mode&1)!==0);break;case 5:n.memoizedProps.suppressHydrationWarning!==!0&&Ir(d.nodeValue,l,(n.mode&1)!==0)}g&&(r.flags|=4)}else d=(l.nodeType===9?l:l.ownerDocument).createTextNode(d),d[en]=r,r.stateNode=d}return lt(r),null;case 13:if(Re(Pe),d=r.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(Oe&&$t!==null&&(r.mode&1)!==0&&(r.flags&128)===0)ch(),As(),r.flags|=98560,g=!1;else if(g=zr(r),d!==null&&d.dehydrated!==null){if(n===null){if(!g)throw Error(s(318));if(g=r.memoizedState,g=g!==null?g.dehydrated:null,!g)throw Error(s(317));g[en]=r}else As(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;lt(r),g=!1}else Wt!==null&&(nc(Wt),Wt=null),g=!0;if(!g)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=l,r):(d=d!==null,d!==(n!==null&&n.memoizedState!==null)&&d&&(r.child.flags|=8192,(r.mode&1)!==0&&(n===null||(Pe.current&1)!==0?Xe===0&&(Xe=3):rc())),r.updateQueue!==null&&(r.flags|=4),lt(r),null);case 4:return Os(),Kl(n,r),n===null&&$i(r.stateNode.containerInfo),lt(r),null;case 10:return yl(r.type._context),lt(r),null;case 17:return vt(r.type)&&Or(),lt(r),null;case 19:if(Re(Pe),g=r.memoizedState,g===null)return lt(r),null;if(d=(r.flags&128)!==0,w=g.rendering,w===null)if(d)zi(g,!1);else{if(Xe!==0||n!==null&&(n.flags&128)!==0)for(n=r.child;n!==null;){if(w=Kr(n),w!==null){for(r.flags|=128,zi(g,!1),d=w.updateQueue,d!==null&&(r.updateQueue=d,r.flags|=4),r.subtreeFlags=0,d=l,l=r.child;l!==null;)g=l,n=d,g.flags&=14680066,w=g.alternate,w===null?(g.childLanes=0,g.lanes=n,g.child=null,g.subtreeFlags=0,g.memoizedProps=null,g.memoizedState=null,g.updateQueue=null,g.dependencies=null,g.stateNode=null):(g.childLanes=w.childLanes,g.lanes=w.lanes,g.child=w.child,g.subtreeFlags=0,g.deletions=null,g.memoizedProps=w.memoizedProps,g.memoizedState=w.memoizedState,g.updateQueue=w.updateQueue,g.type=w.type,n=w.dependencies,g.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),l=l.sibling;return Ee(Pe,Pe.current&1|2),r.child}n=n.sibling}g.tail!==null&&We()>Ds&&(r.flags|=128,d=!0,zi(g,!1),r.lanes=4194304)}else{if(!d)if(n=Kr(w),n!==null){if(r.flags|=128,d=!0,l=n.updateQueue,l!==null&&(r.updateQueue=l,r.flags|=4),zi(g,!0),g.tail===null&&g.tailMode==="hidden"&&!w.alternate&&!Oe)return lt(r),null}else 2*We()-g.renderingStartTime>Ds&&l!==1073741824&&(r.flags|=128,d=!0,zi(g,!1),r.lanes=4194304);g.isBackwards?(w.sibling=r.child,r.child=w):(l=g.last,l!==null?l.sibling=w:r.child=w,g.last=w)}return g.tail!==null?(r=g.tail,g.rendering=r,g.tail=r.sibling,g.renderingStartTime=We(),r.sibling=null,l=Pe.current,Ee(Pe,d?l&1|2:l&1),r):(lt(r),null);case 22:case 23:return ic(),d=r.memoizedState!==null,n!==null&&n.memoizedState!==null!==d&&(r.flags|=8192),d&&(r.mode&1)!==0?(Tt&1073741824)!==0&&(lt(r),r.subtreeFlags&6&&(r.flags|=8192)):lt(r),null;case 24:return null;case 25:return null}throw Error(s(156,r.tag))}function dy(n,r){switch(fl(r),r.tag){case 1:return vt(r.type)&&Or(),n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 3:return Os(),Re(gt),Re(ot),Cl(),n=r.flags,(n&65536)!==0&&(n&128)===0?(r.flags=n&-65537|128,r):null;case 5:return Sl(r),null;case 13:if(Re(Pe),n=r.memoizedState,n!==null&&n.dehydrated!==null){if(r.alternate===null)throw Error(s(340));As()}return n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 19:return Re(Pe),null;case 4:return Os(),null;case 10:return yl(r.type._context),null;case 22:case 23:return ic(),null;case 24:return null;default:return null}}var eo=!1,ct=!1,hy=typeof WeakSet=="function"?WeakSet:Set,ne=null;function Ps(n,r){var l=n.ref;if(l!==null)if(typeof l=="function")try{l(null)}catch(d){Fe(n,r,d)}else l.current=null}function Vl(n,r,l){try{l()}catch(d){Fe(n,r,d)}}var lf=!1;function fy(n,r){if(il=wr,n=zd(),Ya(n)){if("selectionStart"in n)var l={start:n.selectionStart,end:n.selectionEnd};else e:{l=(l=n.ownerDocument)&&l.defaultView||window;var d=l.getSelection&&l.getSelection();if(d&&d.rangeCount!==0){l=d.anchorNode;var f=d.anchorOffset,g=d.focusNode;d=d.focusOffset;try{l.nodeType,g.nodeType}catch{l=null;break e}var w=0,b=-1,$=-1,O=0,F=0,H=n,z=null;t:for(;;){for(var ee;H!==l||f!==0&&H.nodeType!==3||(b=w+f),H!==g||d!==0&&H.nodeType!==3||($=w+d),H.nodeType===3&&(w+=H.nodeValue.length),(ee=H.firstChild)!==null;)z=H,H=ee;for(;;){if(H===n)break t;if(z===l&&++O===f&&(b=w),z===g&&++F===d&&($=w),(ee=H.nextSibling)!==null)break;H=z,z=H.parentNode}H=ee}l=b===-1||$===-1?null:{start:b,end:$}}else l=null}l=l||{start:0,end:0}}else l=null;for(rl={focusedElem:n,selectionRange:l},wr=!1,ne=r;ne!==null;)if(r=ne,n=r.child,(r.subtreeFlags&1028)!==0&&n!==null)n.return=r,ne=n;else for(;ne!==null;){r=ne;try{var se=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(se!==null){var re=se.memoizedProps,He=se.memoizedState,I=r.stateNode,E=I.getSnapshotBeforeUpdate(r.elementType===r.type?re:Ht(r.type,re),He);I.__reactInternalSnapshotBeforeUpdate=E}break;case 3:var M=r.stateNode.containerInfo;M.nodeType===1?M.textContent="":M.nodeType===9&&M.documentElement&&M.removeChild(M.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(s(163))}}catch(q){Fe(r,r.return,q)}if(n=r.sibling,n!==null){n.return=r.return,ne=n;break}ne=r.return}return se=lf,lf=!1,se}function Bi(n,r,l){var d=r.updateQueue;if(d=d!==null?d.lastEffect:null,d!==null){var f=d=d.next;do{if((f.tag&n)===n){var g=f.destroy;f.destroy=void 0,g!==void 0&&Vl(r,l,g)}f=f.next}while(f!==d)}}function to(n,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&n)===n){var d=l.create;l.destroy=d()}l=l.next}while(l!==r)}}function Gl(n){var r=n.ref;if(r!==null){var l=n.stateNode;switch(n.tag){case 5:n=l;break;default:n=l}typeof r=="function"?r(n):r.current=n}}function cf(n){var r=n.alternate;r!==null&&(n.alternate=null,cf(r)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(r=n.stateNode,r!==null&&(delete r[en],delete r[Ei],delete r[cl],delete r[Qk],delete r[Yk])),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}function uf(n){return n.tag===5||n.tag===3||n.tag===4}function df(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||uf(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function ql(n,r,l){var d=n.tag;if(d===5||d===6)n=n.stateNode,r?l.nodeType===8?l.parentNode.insertBefore(n,r):l.insertBefore(n,r):(l.nodeType===8?(r=l.parentNode,r.insertBefore(n,l)):(r=l,r.appendChild(n)),l=l._reactRootContainer,l!=null||r.onclick!==null||(r.onclick=Mr));else if(d!==4&&(n=n.child,n!==null))for(ql(n,r,l),n=n.sibling;n!==null;)ql(n,r,l),n=n.sibling}function Ql(n,r,l){var d=n.tag;if(d===5||d===6)n=n.stateNode,r?l.insertBefore(n,r):l.appendChild(n);else if(d!==4&&(n=n.child,n!==null))for(Ql(n,r,l),n=n.sibling;n!==null;)Ql(n,r,l),n=n.sibling}var it=null,Kt=!1;function _n(n,r,l){for(l=l.child;l!==null;)hf(n,r,l),l=l.sibling}function hf(n,r,l){if(Zt&&typeof Zt.onCommitFiberUnmount=="function")try{Zt.onCommitFiberUnmount(mr,l)}catch{}switch(l.tag){case 5:ct||Ps(l,r);case 6:var d=it,f=Kt;it=null,_n(n,r,l),it=d,Kt=f,it!==null&&(Kt?(n=it,l=l.stateNode,n.nodeType===8?n.parentNode.removeChild(l):n.removeChild(l)):it.removeChild(l.stateNode));break;case 18:it!==null&&(Kt?(n=it,l=l.stateNode,n.nodeType===8?ll(n.parentNode,l):n.nodeType===1&&ll(n,l),ki(n)):ll(it,l.stateNode));break;case 4:d=it,f=Kt,it=l.stateNode.containerInfo,Kt=!0,_n(n,r,l),it=d,Kt=f;break;case 0:case 11:case 14:case 15:if(!ct&&(d=l.updateQueue,d!==null&&(d=d.lastEffect,d!==null))){f=d=d.next;do{var g=f,w=g.destroy;g=g.tag,w!==void 0&&((g&2)!==0||(g&4)!==0)&&Vl(l,r,w),f=f.next}while(f!==d)}_n(n,r,l);break;case 1:if(!ct&&(Ps(l,r),d=l.stateNode,typeof d.componentWillUnmount=="function"))try{d.props=l.memoizedProps,d.state=l.memoizedState,d.componentWillUnmount()}catch(b){Fe(l,r,b)}_n(n,r,l);break;case 21:_n(n,r,l);break;case 22:l.mode&1?(ct=(d=ct)||l.memoizedState!==null,_n(n,r,l),ct=d):_n(n,r,l);break;default:_n(n,r,l)}}function ff(n){var r=n.updateQueue;if(r!==null){n.updateQueue=null;var l=n.stateNode;l===null&&(l=n.stateNode=new hy),r.forEach(function(d){var f=jy.bind(null,n,d);l.has(d)||(l.add(d),d.then(f,f))})}}function Vt(n,r){var l=r.deletions;if(l!==null)for(var d=0;d<l.length;d++){var f=l[d];try{var g=n,w=r,b=w;e:for(;b!==null;){switch(b.tag){case 5:it=b.stateNode,Kt=!1;break e;case 3:it=b.stateNode.containerInfo,Kt=!0;break e;case 4:it=b.stateNode.containerInfo,Kt=!0;break e}b=b.return}if(it===null)throw Error(s(160));hf(g,w,f),it=null,Kt=!1;var $=f.alternate;$!==null&&($.return=null),f.return=null}catch(O){Fe(f,r,O)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)mf(r,n),r=r.sibling}function mf(n,r){var l=n.alternate,d=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:if(Vt(r,n),sn(n),d&4){try{Bi(3,n,n.return),to(3,n)}catch(re){Fe(n,n.return,re)}try{Bi(5,n,n.return)}catch(re){Fe(n,n.return,re)}}break;case 1:Vt(r,n),sn(n),d&512&&l!==null&&Ps(l,l.return);break;case 5:if(Vt(r,n),sn(n),d&512&&l!==null&&Ps(l,l.return),n.flags&32){var f=n.stateNode;try{ai(f,"")}catch(re){Fe(n,n.return,re)}}if(d&4&&(f=n.stateNode,f!=null)){var g=n.memoizedProps,w=l!==null?l.memoizedProps:g,b=n.type,$=n.updateQueue;if(n.updateQueue=null,$!==null)try{b==="input"&&g.type==="radio"&&g.name!=null&&Fu(f,g),Ca(b,w);var O=Ca(b,g);for(w=0;w<$.length;w+=2){var F=$[w],H=$[w+1];F==="style"?Qu(f,H):F==="dangerouslySetInnerHTML"?Gu(f,H):F==="children"?ai(f,H):L(f,F,H,O)}switch(b){case"input":xa(f,g);break;case"textarea":Hu(f,g);break;case"select":var z=f._wrapperState.wasMultiple;f._wrapperState.wasMultiple=!!g.multiple;var ee=g.value;ee!=null?ps(f,!!g.multiple,ee,!1):z!==!!g.multiple&&(g.defaultValue!=null?ps(f,!!g.multiple,g.defaultValue,!0):ps(f,!!g.multiple,g.multiple?[]:"",!1))}f[Ei]=g}catch(re){Fe(n,n.return,re)}}break;case 6:if(Vt(r,n),sn(n),d&4){if(n.stateNode===null)throw Error(s(162));f=n.stateNode,g=n.memoizedProps;try{f.nodeValue=g}catch(re){Fe(n,n.return,re)}}break;case 3:if(Vt(r,n),sn(n),d&4&&l!==null&&l.memoizedState.isDehydrated)try{ki(r.containerInfo)}catch(re){Fe(n,n.return,re)}break;case 4:Vt(r,n),sn(n);break;case 13:Vt(r,n),sn(n),f=n.child,f.flags&8192&&(g=f.memoizedState!==null,f.stateNode.isHidden=g,!g||f.alternate!==null&&f.alternate.memoizedState!==null||(Xl=We())),d&4&&ff(n);break;case 22:if(F=l!==null&&l.memoizedState!==null,n.mode&1?(ct=(O=ct)||F,Vt(r,n),ct=O):Vt(r,n),sn(n),d&8192){if(O=n.memoizedState!==null,(n.stateNode.isHidden=O)&&!F&&(n.mode&1)!==0)for(ne=n,F=n.child;F!==null;){for(H=ne=F;ne!==null;){switch(z=ne,ee=z.child,z.tag){case 0:case 11:case 14:case 15:Bi(4,z,z.return);break;case 1:Ps(z,z.return);var se=z.stateNode;if(typeof se.componentWillUnmount=="function"){d=z,l=z.return;try{r=d,se.props=r.memoizedProps,se.state=r.memoizedState,se.componentWillUnmount()}catch(re){Fe(d,l,re)}}break;case 5:Ps(z,z.return);break;case 22:if(z.memoizedState!==null){vf(H);continue}}ee!==null?(ee.return=z,ne=ee):vf(H)}F=F.sibling}e:for(F=null,H=n;;){if(H.tag===5){if(F===null){F=H;try{f=H.stateNode,O?(g=f.style,typeof g.setProperty=="function"?g.setProperty("display","none","important"):g.display="none"):(b=H.stateNode,$=H.memoizedProps.style,w=$!=null&&$.hasOwnProperty("display")?$.display:null,b.style.display=qu("display",w))}catch(re){Fe(n,n.return,re)}}}else if(H.tag===6){if(F===null)try{H.stateNode.nodeValue=O?"":H.memoizedProps}catch(re){Fe(n,n.return,re)}}else if((H.tag!==22&&H.tag!==23||H.memoizedState===null||H===n)&&H.child!==null){H.child.return=H,H=H.child;continue}if(H===n)break e;for(;H.sibling===null;){if(H.return===null||H.return===n)break e;F===H&&(F=null),H=H.return}F===H&&(F=null),H.sibling.return=H.return,H=H.sibling}}break;case 19:Vt(r,n),sn(n),d&4&&ff(n);break;case 21:break;default:Vt(r,n),sn(n)}}function sn(n){var r=n.flags;if(r&2){try{e:{for(var l=n.return;l!==null;){if(uf(l)){var d=l;break e}l=l.return}throw Error(s(160))}switch(d.tag){case 5:var f=d.stateNode;d.flags&32&&(ai(f,""),d.flags&=-33);var g=df(n);Ql(n,g,f);break;case 3:case 4:var w=d.stateNode.containerInfo,b=df(n);ql(n,b,w);break;default:throw Error(s(161))}}catch($){Fe(n,n.return,$)}n.flags&=-3}r&4096&&(n.flags&=-4097)}function my(n,r,l){ne=n,pf(n)}function pf(n,r,l){for(var d=(n.mode&1)!==0;ne!==null;){var f=ne,g=f.child;if(f.tag===22&&d){var w=f.memoizedState!==null||eo;if(!w){var b=f.alternate,$=b!==null&&b.memoizedState!==null||ct;b=eo;var O=ct;if(eo=w,(ct=$)&&!O)for(ne=f;ne!==null;)w=ne,$=w.child,w.tag===22&&w.memoizedState!==null?kf(f):$!==null?($.return=w,ne=$):kf(f);for(;g!==null;)ne=g,pf(g),g=g.sibling;ne=f,eo=b,ct=O}gf(n)}else(f.subtreeFlags&8772)!==0&&g!==null?(g.return=f,ne=g):gf(n)}}function gf(n){for(;ne!==null;){var r=ne;if((r.flags&8772)!==0){var l=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:ct||to(5,r);break;case 1:var d=r.stateNode;if(r.flags&4&&!ct)if(l===null)d.componentDidMount();else{var f=r.elementType===r.type?l.memoizedProps:Ht(r.type,l.memoizedProps);d.componentDidUpdate(f,l.memoizedState,d.__reactInternalSnapshotBeforeUpdate)}var g=r.updateQueue;g!==null&&gh(r,g,d);break;case 3:var w=r.updateQueue;if(w!==null){if(l=null,r.child!==null)switch(r.child.tag){case 5:l=r.child.stateNode;break;case 1:l=r.child.stateNode}gh(r,w,l)}break;case 5:var b=r.stateNode;if(l===null&&r.flags&4){l=b;var $=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":$.autoFocus&&l.focus();break;case"img":$.src&&(l.src=$.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(r.memoizedState===null){var O=r.alternate;if(O!==null){var F=O.memoizedState;if(F!==null){var H=F.dehydrated;H!==null&&ki(H)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(s(163))}ct||r.flags&512&&Gl(r)}catch(z){Fe(r,r.return,z)}}if(r===n){ne=null;break}if(l=r.sibling,l!==null){l.return=r.return,ne=l;break}ne=r.return}}function vf(n){for(;ne!==null;){var r=ne;if(r===n){ne=null;break}var l=r.sibling;if(l!==null){l.return=r.return,ne=l;break}ne=r.return}}function kf(n){for(;ne!==null;){var r=ne;try{switch(r.tag){case 0:case 11:case 15:var l=r.return;try{to(4,r)}catch($){Fe(r,l,$)}break;case 1:var d=r.stateNode;if(typeof d.componentDidMount=="function"){var f=r.return;try{d.componentDidMount()}catch($){Fe(r,f,$)}}var g=r.return;try{Gl(r)}catch($){Fe(r,g,$)}break;case 5:var w=r.return;try{Gl(r)}catch($){Fe(r,w,$)}}}catch($){Fe(r,r.return,$)}if(r===n){ne=null;break}var b=r.sibling;if(b!==null){b.return=r.return,ne=b;break}ne=r.return}}var py=Math.ceil,no=U.ReactCurrentDispatcher,Yl=U.ReactCurrentOwner,Ot=U.ReactCurrentBatchConfig,Se=0,tt=null,qe=null,rt=0,Tt=0,_s=Mn(0),Xe=0,Fi=null,is=0,so=0,Jl=0,Ui=null,yt=null,Xl=0,Ds=1/0,wn=null,io=!1,Zl=null,Dn=null,ro=!1,zn=null,oo=0,Wi=0,ec=null,ao=-1,lo=0;function ft(){return(Se&6)!==0?We():ao!==-1?ao:ao=We()}function Bn(n){return(n.mode&1)===0?1:(Se&2)!==0&&rt!==0?rt&-rt:Xk.transition!==null?(lo===0&&(lo=ud()),lo):(n=Te,n!==0||(n=window.event,n=n===void 0?16:yd(n.type)),n)}function Gt(n,r,l,d){if(50<Wi)throw Wi=0,ec=null,Error(s(185));fi(n,l,d),((Se&2)===0||n!==tt)&&(n===tt&&((Se&2)===0&&(so|=l),Xe===4&&Fn(n,rt)),wt(n,d),l===1&&Se===0&&(r.mode&1)===0&&(Ds=We()+500,Pr&&On()))}function wt(n,r){var l=n.callbackNode;Xv(n,r);var d=vr(n,n===tt?rt:0);if(d===0)l!==null&&ad(l),n.callbackNode=null,n.callbackPriority=0;else if(r=d&-d,n.callbackPriority!==r){if(l!=null&&ad(l),r===1)n.tag===0?Jk(wf.bind(null,n)):ih(wf.bind(null,n)),Gk(function(){(Se&6)===0&&On()}),l=null;else{switch(dd(d)){case 1:l=Ra;break;case 4:l=ld;break;case 16:l=fr;break;case 536870912:l=cd;break;default:l=fr}l=Tf(l,yf.bind(null,n))}n.callbackPriority=r,n.callbackNode=l}}function yf(n,r){if(ao=-1,lo=0,(Se&6)!==0)throw Error(s(327));var l=n.callbackNode;if(zs()&&n.callbackNode!==l)return null;var d=vr(n,n===tt?rt:0);if(d===0)return null;if((d&30)!==0||(d&n.expiredLanes)!==0||r)r=co(n,d);else{r=d;var f=Se;Se|=2;var g=jf();(tt!==n||rt!==r)&&(wn=null,Ds=We()+500,os(n,r));do try{ky();break}catch(b){xf(n,b)}while(!0);kl(),no.current=g,Se=f,qe!==null?r=0:(tt=null,rt=0,r=Xe)}if(r!==0){if(r===2&&(f=Oa(n),f!==0&&(d=f,r=tc(n,f))),r===1)throw l=Fi,os(n,0),Fn(n,d),wt(n,We()),l;if(r===6)Fn(n,d);else{if(f=n.current.alternate,(d&30)===0&&!gy(f)&&(r=co(n,d),r===2&&(g=Oa(n),g!==0&&(d=g,r=tc(n,g))),r===1))throw l=Fi,os(n,0),Fn(n,d),wt(n,We()),l;switch(n.finishedWork=f,n.finishedLanes=d,r){case 0:case 1:throw Error(s(345));case 2:as(n,yt,wn);break;case 3:if(Fn(n,d),(d&130023424)===d&&(r=Xl+500-We(),10<r)){if(vr(n,0)!==0)break;if(f=n.suspendedLanes,(f&d)!==d){ft(),n.pingedLanes|=n.suspendedLanes&f;break}n.timeoutHandle=al(as.bind(null,n,yt,wn),r);break}as(n,yt,wn);break;case 4:if(Fn(n,d),(d&4194240)===d)break;for(r=n.eventTimes,f=-1;0<d;){var w=31-Ft(d);g=1<<w,w=r[w],w>f&&(f=w),d&=~g}if(d=f,d=We()-d,d=(120>d?120:480>d?480:1080>d?1080:1920>d?1920:3e3>d?3e3:4320>d?4320:1960*py(d/1960))-d,10<d){n.timeoutHandle=al(as.bind(null,n,yt,wn),d);break}as(n,yt,wn);break;case 5:as(n,yt,wn);break;default:throw Error(s(329))}}}return wt(n,We()),n.callbackNode===l?yf.bind(null,n):null}function tc(n,r){var l=Ui;return n.current.memoizedState.isDehydrated&&(os(n,r).flags|=256),n=co(n,r),n!==2&&(r=yt,yt=l,r!==null&&nc(r)),n}function nc(n){yt===null?yt=n:yt.push.apply(yt,n)}function gy(n){for(var r=n;;){if(r.flags&16384){var l=r.updateQueue;if(l!==null&&(l=l.stores,l!==null))for(var d=0;d<l.length;d++){var f=l[d],g=f.getSnapshot;f=f.value;try{if(!Ut(g(),f))return!1}catch{return!1}}}if(l=r.child,r.subtreeFlags&16384&&l!==null)l.return=r,r=l;else{if(r===n)break;for(;r.sibling===null;){if(r.return===null||r.return===n)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function Fn(n,r){for(r&=~Jl,r&=~so,n.suspendedLanes|=r,n.pingedLanes&=~r,n=n.expirationTimes;0<r;){var l=31-Ft(r),d=1<<l;n[l]=-1,r&=~d}}function wf(n){if((Se&6)!==0)throw Error(s(327));zs();var r=vr(n,0);if((r&1)===0)return wt(n,We()),null;var l=co(n,r);if(n.tag!==0&&l===2){var d=Oa(n);d!==0&&(r=d,l=tc(n,d))}if(l===1)throw l=Fi,os(n,0),Fn(n,r),wt(n,We()),l;if(l===6)throw Error(s(345));return n.finishedWork=n.current.alternate,n.finishedLanes=r,as(n,yt,wn),wt(n,We()),null}function sc(n,r){var l=Se;Se|=1;try{return n(r)}finally{Se=l,Se===0&&(Ds=We()+500,Pr&&On())}}function rs(n){zn!==null&&zn.tag===0&&(Se&6)===0&&zs();var r=Se;Se|=1;var l=Ot.transition,d=Te;try{if(Ot.transition=null,Te=1,n)return n()}finally{Te=d,Ot.transition=l,Se=r,(Se&6)===0&&On()}}function ic(){Tt=_s.current,Re(_s)}function os(n,r){n.finishedWork=null,n.finishedLanes=0;var l=n.timeoutHandle;if(l!==-1&&(n.timeoutHandle=-1,Vk(l)),qe!==null)for(l=qe.return;l!==null;){var d=l;switch(fl(d),d.tag){case 1:d=d.type.childContextTypes,d!=null&&Or();break;case 3:Os(),Re(gt),Re(ot),Cl();break;case 5:Sl(d);break;case 4:Os();break;case 13:Re(Pe);break;case 19:Re(Pe);break;case 10:yl(d.type._context);break;case 22:case 23:ic()}l=l.return}if(tt=n,qe=n=Un(n.current,null),rt=Tt=r,Xe=0,Fi=null,Jl=so=is=0,yt=Ui=null,ts!==null){for(r=0;r<ts.length;r++)if(l=ts[r],d=l.interleaved,d!==null){l.interleaved=null;var f=d.next,g=l.pending;if(g!==null){var w=g.next;g.next=f,d.next=w}l.pending=d}ts=null}return n}function xf(n,r){do{var l=qe;try{if(kl(),Vr.current=Yr,Gr){for(var d=_e.memoizedState;d!==null;){var f=d.queue;f!==null&&(f.pending=null),d=d.next}Gr=!1}if(ss=0,et=Je=_e=null,Li=!1,Pi=0,Yl.current=null,l===null||l.return===null){Xe=1,Fi=r,qe=null;break}e:{var g=n,w=l.return,b=l,$=r;if(r=rt,b.flags|=32768,$!==null&&typeof $=="object"&&typeof $.then=="function"){var O=$,F=b,H=F.tag;if((F.mode&1)===0&&(H===0||H===11||H===15)){var z=F.alternate;z?(F.updateQueue=z.updateQueue,F.memoizedState=z.memoizedState,F.lanes=z.lanes):(F.updateQueue=null,F.memoizedState=null)}var ee=Kh(w);if(ee!==null){ee.flags&=-257,Vh(ee,w,b,g,r),ee.mode&1&&Hh(g,O,r),r=ee,$=O;var se=r.updateQueue;if(se===null){var re=new Set;re.add($),r.updateQueue=re}else se.add($);break e}else{if((r&1)===0){Hh(g,O,r),rc();break e}$=Error(s(426))}}else if(Oe&&b.mode&1){var He=Kh(w);if(He!==null){(He.flags&65536)===0&&(He.flags|=256),Vh(He,w,b,g,r),gl(Ls($,b));break e}}g=$=Ls($,b),Xe!==4&&(Xe=2),Ui===null?Ui=[g]:Ui.push(g),g=w;do{switch(g.tag){case 3:g.flags|=65536,r&=-r,g.lanes|=r;var I=Uh(g,$,r);ph(g,I);break e;case 1:b=$;var E=g.type,M=g.stateNode;if((g.flags&128)===0&&(typeof E.getDerivedStateFromError=="function"||M!==null&&typeof M.componentDidCatch=="function"&&(Dn===null||!Dn.has(M)))){g.flags|=65536,r&=-r,g.lanes|=r;var q=Wh(g,b,r);ph(g,q);break e}}g=g.return}while(g!==null)}Sf(l)}catch(ae){r=ae,qe===l&&l!==null&&(qe=l=l.return);continue}break}while(!0)}function jf(){var n=no.current;return no.current=Yr,n===null?Yr:n}function rc(){(Xe===0||Xe===3||Xe===2)&&(Xe=4),tt===null||(is&268435455)===0&&(so&268435455)===0||Fn(tt,rt)}function co(n,r){var l=Se;Se|=2;var d=jf();(tt!==n||rt!==r)&&(wn=null,os(n,r));do try{vy();break}catch(f){xf(n,f)}while(!0);if(kl(),Se=l,no.current=d,qe!==null)throw Error(s(261));return tt=null,rt=0,Xe}function vy(){for(;qe!==null;)Nf(qe)}function ky(){for(;qe!==null&&!Wv();)Nf(qe)}function Nf(n){var r=$f(n.alternate,n,Tt);n.memoizedProps=n.pendingProps,r===null?Sf(n):qe=r,Yl.current=null}function Sf(n){var r=n;do{var l=r.alternate;if(n=r.return,(r.flags&32768)===0){if(l=uy(l,r,Tt),l!==null){qe=l;return}}else{if(l=dy(l,r),l!==null){l.flags&=32767,qe=l;return}if(n!==null)n.flags|=32768,n.subtreeFlags=0,n.deletions=null;else{Xe=6,qe=null;return}}if(r=r.sibling,r!==null){qe=r;return}qe=r=n}while(r!==null);Xe===0&&(Xe=5)}function as(n,r,l){var d=Te,f=Ot.transition;try{Ot.transition=null,Te=1,yy(n,r,l,d)}finally{Ot.transition=f,Te=d}return null}function yy(n,r,l,d){do zs();while(zn!==null);if((Se&6)!==0)throw Error(s(327));l=n.finishedWork;var f=n.finishedLanes;if(l===null)return null;if(n.finishedWork=null,n.finishedLanes=0,l===n.current)throw Error(s(177));n.callbackNode=null,n.callbackPriority=0;var g=l.lanes|l.childLanes;if(Zv(n,g),n===tt&&(qe=tt=null,rt=0),(l.subtreeFlags&2064)===0&&(l.flags&2064)===0||ro||(ro=!0,Tf(fr,function(){return zs(),null})),g=(l.flags&15990)!==0,(l.subtreeFlags&15990)!==0||g){g=Ot.transition,Ot.transition=null;var w=Te;Te=1;var b=Se;Se|=4,Yl.current=null,fy(n,l),mf(l,n),zk(rl),wr=!!il,rl=il=null,n.current=l,my(l),Hv(),Se=b,Te=w,Ot.transition=g}else n.current=l;if(ro&&(ro=!1,zn=n,oo=f),g=n.pendingLanes,g===0&&(Dn=null),Gv(l.stateNode),wt(n,We()),r!==null)for(d=n.onRecoverableError,l=0;l<r.length;l++)f=r[l],d(f.value,{componentStack:f.stack,digest:f.digest});if(io)throw io=!1,n=Zl,Zl=null,n;return(oo&1)!==0&&n.tag!==0&&zs(),g=n.pendingLanes,(g&1)!==0?n===ec?Wi++:(Wi=0,ec=n):Wi=0,On(),null}function zs(){if(zn!==null){var n=dd(oo),r=Ot.transition,l=Te;try{if(Ot.transition=null,Te=16>n?16:n,zn===null)var d=!1;else{if(n=zn,zn=null,oo=0,(Se&6)!==0)throw Error(s(331));var f=Se;for(Se|=4,ne=n.current;ne!==null;){var g=ne,w=g.child;if((ne.flags&16)!==0){var b=g.deletions;if(b!==null){for(var $=0;$<b.length;$++){var O=b[$];for(ne=O;ne!==null;){var F=ne;switch(F.tag){case 0:case 11:case 15:Bi(8,F,g)}var H=F.child;if(H!==null)H.return=F,ne=H;else for(;ne!==null;){F=ne;var z=F.sibling,ee=F.return;if(cf(F),F===O){ne=null;break}if(z!==null){z.return=ee,ne=z;break}ne=ee}}}var se=g.alternate;if(se!==null){var re=se.child;if(re!==null){se.child=null;do{var He=re.sibling;re.sibling=null,re=He}while(re!==null)}}ne=g}}if((g.subtreeFlags&2064)!==0&&w!==null)w.return=g,ne=w;else e:for(;ne!==null;){if(g=ne,(g.flags&2048)!==0)switch(g.tag){case 0:case 11:case 15:Bi(9,g,g.return)}var I=g.sibling;if(I!==null){I.return=g.return,ne=I;break e}ne=g.return}}var E=n.current;for(ne=E;ne!==null;){w=ne;var M=w.child;if((w.subtreeFlags&2064)!==0&&M!==null)M.return=w,ne=M;else e:for(w=E;ne!==null;){if(b=ne,(b.flags&2048)!==0)try{switch(b.tag){case 0:case 11:case 15:to(9,b)}}catch(ae){Fe(b,b.return,ae)}if(b===w){ne=null;break e}var q=b.sibling;if(q!==null){q.return=b.return,ne=q;break e}ne=b.return}}if(Se=f,On(),Zt&&typeof Zt.onPostCommitFiberRoot=="function")try{Zt.onPostCommitFiberRoot(mr,n)}catch{}d=!0}return d}finally{Te=l,Ot.transition=r}}return!1}function bf(n,r,l){r=Ls(l,r),r=Uh(n,r,1),n=Pn(n,r,1),r=ft(),n!==null&&(fi(n,1,r),wt(n,r))}function Fe(n,r,l){if(n.tag===3)bf(n,n,l);else for(;r!==null;){if(r.tag===3){bf(r,n,l);break}else if(r.tag===1){var d=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(Dn===null||!Dn.has(d))){n=Ls(l,n),n=Wh(r,n,1),r=Pn(r,n,1),n=ft(),r!==null&&(fi(r,1,n),wt(r,n));break}}r=r.return}}function wy(n,r,l){var d=n.pingCache;d!==null&&d.delete(r),r=ft(),n.pingedLanes|=n.suspendedLanes&l,tt===n&&(rt&l)===l&&(Xe===4||Xe===3&&(rt&130023424)===rt&&500>We()-Xl?os(n,0):Jl|=l),wt(n,r)}function Cf(n,r){r===0&&((n.mode&1)===0?r=1:(r=gr,gr<<=1,(gr&130023424)===0&&(gr=4194304)));var l=ft();n=vn(n,r),n!==null&&(fi(n,r,l),wt(n,l))}function xy(n){var r=n.memoizedState,l=0;r!==null&&(l=r.retryLane),Cf(n,l)}function jy(n,r){var l=0;switch(n.tag){case 13:var d=n.stateNode,f=n.memoizedState;f!==null&&(l=f.retryLane);break;case 19:d=n.stateNode;break;default:throw Error(s(314))}d!==null&&d.delete(r),Cf(n,l)}var $f;$f=function(n,r,l){if(n!==null)if(n.memoizedProps!==r.pendingProps||gt.current)kt=!0;else{if((n.lanes&l)===0&&(r.flags&128)===0)return kt=!1,cy(n,r,l);kt=(n.flags&131072)!==0}else kt=!1,Oe&&(r.flags&1048576)!==0&&rh(r,Dr,r.index);switch(r.lanes=0,r.tag){case 2:var d=r.type;Zr(n,r),n=r.pendingProps;var f=$s(r,ot.current);Rs(r,l),f=El(null,r,d,n,f,l);var g=Al();return r.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(r.tag=1,r.memoizedState=null,r.updateQueue=null,vt(d)?(g=!0,Lr(r)):g=!1,r.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,jl(r),f.updater=Jr,r.stateNode=f,f._reactInternals=r,Pl(r,d,n,l),r=Bl(null,r,d,!0,g,l)):(r.tag=0,Oe&&g&&hl(r),ht(null,r,f,l),r=r.child),r;case 16:d=r.elementType;e:{switch(Zr(n,r),n=r.pendingProps,f=d._init,d=f(d._payload),r.type=d,f=r.tag=Sy(d),n=Ht(d,n),f){case 0:r=zl(null,r,d,n,l);break e;case 1:r=Xh(null,r,d,n,l);break e;case 11:r=Gh(null,r,d,n,l);break e;case 14:r=qh(null,r,d,Ht(d.type,n),l);break e}throw Error(s(306,d,""))}return r;case 0:return d=r.type,f=r.pendingProps,f=r.elementType===d?f:Ht(d,f),zl(n,r,d,f,l);case 1:return d=r.type,f=r.pendingProps,f=r.elementType===d?f:Ht(d,f),Xh(n,r,d,f,l);case 3:e:{if(Zh(r),n===null)throw Error(s(387));d=r.pendingProps,g=r.memoizedState,f=g.element,mh(n,r),Hr(r,d,null,l);var w=r.memoizedState;if(d=w.element,g.isDehydrated)if(g={element:d,isDehydrated:!1,cache:w.cache,pendingSuspenseBoundaries:w.pendingSuspenseBoundaries,transitions:w.transitions},r.updateQueue.baseState=g,r.memoizedState=g,r.flags&256){f=Ls(Error(s(423)),r),r=ef(n,r,d,l,f);break e}else if(d!==f){f=Ls(Error(s(424)),r),r=ef(n,r,d,l,f);break e}else for($t=In(r.stateNode.containerInfo.firstChild),Ct=r,Oe=!0,Wt=null,l=hh(r,null,d,l),r.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(As(),d===f){r=yn(n,r,l);break e}ht(n,r,d,l)}r=r.child}return r;case 5:return vh(r),n===null&&pl(r),d=r.type,f=r.pendingProps,g=n!==null?n.memoizedProps:null,w=f.children,ol(d,f)?w=null:g!==null&&ol(d,g)&&(r.flags|=32),Jh(n,r),ht(n,r,w,l),r.child;case 6:return n===null&&pl(r),null;case 13:return tf(n,r,l);case 4:return Nl(r,r.stateNode.containerInfo),d=r.pendingProps,n===null?r.child=Is(r,null,d,l):ht(n,r,d,l),r.child;case 11:return d=r.type,f=r.pendingProps,f=r.elementType===d?f:Ht(d,f),Gh(n,r,d,f,l);case 7:return ht(n,r,r.pendingProps,l),r.child;case 8:return ht(n,r,r.pendingProps.children,l),r.child;case 12:return ht(n,r,r.pendingProps.children,l),r.child;case 10:e:{if(d=r.type._context,f=r.pendingProps,g=r.memoizedProps,w=f.value,Ee(Fr,d._currentValue),d._currentValue=w,g!==null)if(Ut(g.value,w)){if(g.children===f.children&&!gt.current){r=yn(n,r,l);break e}}else for(g=r.child,g!==null&&(g.return=r);g!==null;){var b=g.dependencies;if(b!==null){w=g.child;for(var $=b.firstContext;$!==null;){if($.context===d){if(g.tag===1){$=kn(-1,l&-l),$.tag=2;var O=g.updateQueue;if(O!==null){O=O.shared;var F=O.pending;F===null?$.next=$:($.next=F.next,F.next=$),O.pending=$}}g.lanes|=l,$=g.alternate,$!==null&&($.lanes|=l),wl(g.return,l,r),b.lanes|=l;break}$=$.next}}else if(g.tag===10)w=g.type===r.type?null:g.child;else if(g.tag===18){if(w=g.return,w===null)throw Error(s(341));w.lanes|=l,b=w.alternate,b!==null&&(b.lanes|=l),wl(w,l,r),w=g.sibling}else w=g.child;if(w!==null)w.return=g;else for(w=g;w!==null;){if(w===r){w=null;break}if(g=w.sibling,g!==null){g.return=w.return,w=g;break}w=w.return}g=w}ht(n,r,f.children,l),r=r.child}return r;case 9:return f=r.type,d=r.pendingProps.children,Rs(r,l),f=Mt(f),d=d(f),r.flags|=1,ht(n,r,d,l),r.child;case 14:return d=r.type,f=Ht(d,r.pendingProps),f=Ht(d.type,f),qh(n,r,d,f,l);case 15:return Qh(n,r,r.type,r.pendingProps,l);case 17:return d=r.type,f=r.pendingProps,f=r.elementType===d?f:Ht(d,f),Zr(n,r),r.tag=1,vt(d)?(n=!0,Lr(r)):n=!1,Rs(r,l),Bh(r,d,f),Pl(r,d,f,l),Bl(null,r,d,!0,n,l);case 19:return sf(n,r,l);case 22:return Yh(n,r,l)}throw Error(s(156,r.tag))};function Tf(n,r){return od(n,r)}function Ny(n,r,l,d){this.tag=n,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=d,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Lt(n,r,l,d){return new Ny(n,r,l,d)}function oc(n){return n=n.prototype,!(!n||!n.isReactComponent)}function Sy(n){if(typeof n=="function")return oc(n)?1:0;if(n!=null){if(n=n.$$typeof,n===$e)return 11;if(n===X)return 14}return 2}function Un(n,r){var l=n.alternate;return l===null?(l=Lt(n.tag,r,n.key,n.mode),l.elementType=n.elementType,l.type=n.type,l.stateNode=n.stateNode,l.alternate=n,n.alternate=l):(l.pendingProps=r,l.type=n.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=n.flags&14680064,l.childLanes=n.childLanes,l.lanes=n.lanes,l.child=n.child,l.memoizedProps=n.memoizedProps,l.memoizedState=n.memoizedState,l.updateQueue=n.updateQueue,r=n.dependencies,l.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},l.sibling=n.sibling,l.index=n.index,l.ref=n.ref,l}function uo(n,r,l,d,f,g){var w=2;if(d=n,typeof n=="function")oc(n)&&(w=1);else if(typeof n=="string")w=5;else e:switch(n){case W:return ls(l.children,f,g,r);case ie:w=8,f|=8;break;case G:return n=Lt(12,l,r,f|2),n.elementType=G,n.lanes=g,n;case oe:return n=Lt(13,l,r,f),n.elementType=oe,n.lanes=g,n;case D:return n=Lt(19,l,r,f),n.elementType=D,n.lanes=g,n;case te:return ho(l,f,g,r);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case ve:w=10;break e;case Le:w=9;break e;case $e:w=11;break e;case X:w=14;break e;case le:w=16,d=null;break e}throw Error(s(130,n==null?n:typeof n,""))}return r=Lt(w,l,r,f),r.elementType=n,r.type=d,r.lanes=g,r}function ls(n,r,l,d){return n=Lt(7,n,d,r),n.lanes=l,n}function ho(n,r,l,d){return n=Lt(22,n,d,r),n.elementType=te,n.lanes=l,n.stateNode={isHidden:!1},n}function ac(n,r,l){return n=Lt(6,n,null,r),n.lanes=l,n}function lc(n,r,l){return r=Lt(4,n.children!==null?n.children:[],n.key,r),r.lanes=l,r.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},r}function by(n,r,l,d,f){this.tag=r,this.containerInfo=n,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=La(0),this.expirationTimes=La(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=La(0),this.identifierPrefix=d,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function cc(n,r,l,d,f,g,w,b,$){return n=new by(n,r,l,b,$),r===1?(r=1,g===!0&&(r|=8)):r=0,g=Lt(3,null,null,r),n.current=g,g.stateNode=n,g.memoizedState={element:d,isDehydrated:l,cache:null,transitions:null,pendingSuspenseBoundaries:null},jl(g),n}function Cy(n,r,l){var d=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Q,key:d==null?null:""+d,children:n,containerInfo:r,implementation:l}}function Ef(n){if(!n)return Rn;n=n._reactInternals;e:{if(Yn(n)!==n||n.tag!==1)throw Error(s(170));var r=n;do{switch(r.tag){case 3:r=r.stateNode.context;break e;case 1:if(vt(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}}r=r.return}while(r!==null);throw Error(s(171))}if(n.tag===1){var l=n.type;if(vt(l))return nh(n,l,r)}return r}function Af(n,r,l,d,f,g,w,b,$){return n=cc(l,d,!0,n,f,g,w,b,$),n.context=Ef(null),l=n.current,d=ft(),f=Bn(l),g=kn(d,f),g.callback=r??null,Pn(l,g,f),n.current.lanes=f,fi(n,f,d),wt(n,d),n}function fo(n,r,l,d){var f=r.current,g=ft(),w=Bn(f);return l=Ef(l),r.context===null?r.context=l:r.pendingContext=l,r=kn(g,w),r.payload={element:n},d=d===void 0?null:d,d!==null&&(r.callback=d),n=Pn(f,r,w),n!==null&&(Gt(n,f,w,g),Wr(n,f,w)),w}function mo(n){if(n=n.current,!n.child)return null;switch(n.child.tag){case 5:return n.child.stateNode;default:return n.child.stateNode}}function If(n,r){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var l=n.retryLane;n.retryLane=l!==0&&l<r?l:r}}function uc(n,r){If(n,r),(n=n.alternate)&&If(n,r)}function $y(){return null}var Mf=typeof reportError=="function"?reportError:function(n){console.error(n)};function dc(n){this._internalRoot=n}po.prototype.render=dc.prototype.render=function(n){var r=this._internalRoot;if(r===null)throw Error(s(409));fo(n,r,null,null)},po.prototype.unmount=dc.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var r=n.containerInfo;rs(function(){fo(null,n,null,null)}),r[fn]=null}};function po(n){this._internalRoot=n}po.prototype.unstable_scheduleHydration=function(n){if(n){var r=md();n={blockedOn:null,target:n,priority:r};for(var l=0;l<Tn.length&&r!==0&&r<Tn[l].priority;l++);Tn.splice(l,0,n),l===0&&vd(n)}};function hc(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function go(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11&&(n.nodeType!==8||n.nodeValue!==" react-mount-point-unstable "))}function Rf(){}function Ty(n,r,l,d,f){if(f){if(typeof d=="function"){var g=d;d=function(){var O=mo(w);g.call(O)}}var w=Af(r,d,n,0,null,!1,!1,"",Rf);return n._reactRootContainer=w,n[fn]=w.current,$i(n.nodeType===8?n.parentNode:n),rs(),w}for(;f=n.lastChild;)n.removeChild(f);if(typeof d=="function"){var b=d;d=function(){var O=mo($);b.call(O)}}var $=cc(n,0,!1,null,null,!1,!1,"",Rf);return n._reactRootContainer=$,n[fn]=$.current,$i(n.nodeType===8?n.parentNode:n),rs(function(){fo(r,$,l,d)}),$}function vo(n,r,l,d,f){var g=l._reactRootContainer;if(g){var w=g;if(typeof f=="function"){var b=f;f=function(){var $=mo(w);b.call($)}}fo(r,w,n,f)}else w=Ty(l,r,n,f,d);return mo(w)}hd=function(n){switch(n.tag){case 3:var r=n.stateNode;if(r.current.memoizedState.isDehydrated){var l=hi(r.pendingLanes);l!==0&&(Pa(r,l|1),wt(r,We()),(Se&6)===0&&(Ds=We()+500,On()))}break;case 13:rs(function(){var d=vn(n,1);if(d!==null){var f=ft();Gt(d,n,1,f)}}),uc(n,1)}},_a=function(n){if(n.tag===13){var r=vn(n,134217728);if(r!==null){var l=ft();Gt(r,n,134217728,l)}uc(n,134217728)}},fd=function(n){if(n.tag===13){var r=Bn(n),l=vn(n,r);if(l!==null){var d=ft();Gt(l,n,r,d)}uc(n,r)}},md=function(){return Te},pd=function(n,r){var l=Te;try{return Te=n,r()}finally{Te=l}},Ea=function(n,r,l){switch(r){case"input":if(xa(n,l),r=l.name,l.type==="radio"&&r!=null){for(l=n;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll("input[name="+JSON.stringify(""+r)+'][type="radio"]'),r=0;r<l.length;r++){var d=l[r];if(d!==n&&d.form===n.form){var f=Rr(d);if(!f)throw Error(s(90));cr(d),xa(d,f)}}}break;case"textarea":Hu(n,l);break;case"select":r=l.value,r!=null&&ps(n,!!l.multiple,r,!1)}},Zu=sc,ed=rs;var Ey={usingClientEntryPoint:!1,Events:[Ai,bs,Rr,Ju,Xu,sc]},Hi={findFiberByHostInstance:Jn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Ay={bundleType:Hi.bundleType,version:Hi.version,rendererPackageName:Hi.rendererPackageName,rendererConfig:Hi.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:U.ReactCurrentDispatcher,findHostInstanceByFiber:function(n){return n=id(n),n===null?null:n.stateNode},findFiberByHostInstance:Hi.findFiberByHostInstance||$y,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 ko=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ko.isDisabled&&ko.supportsFiber)try{mr=ko.inject(Ay),Zt=ko}catch{}}return xt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Ey,xt.createPortal=function(n,r){var l=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!hc(r))throw Error(s(200));return Cy(n,r,null,l)},xt.createRoot=function(n,r){if(!hc(n))throw Error(s(299));var l=!1,d="",f=Mf;return r!=null&&(r.unstable_strictMode===!0&&(l=!0),r.identifierPrefix!==void 0&&(d=r.identifierPrefix),r.onRecoverableError!==void 0&&(f=r.onRecoverableError)),r=cc(n,1,!1,null,null,l,!1,d,f),n[fn]=r.current,$i(n.nodeType===8?n.parentNode:n),new dc(r)},xt.findDOMNode=function(n){if(n==null)return null;if(n.nodeType===1)return n;var r=n._reactInternals;if(r===void 0)throw typeof n.render=="function"?Error(s(188)):(n=Object.keys(n).join(","),Error(s(268,n)));return n=id(r),n=n===null?null:n.stateNode,n},xt.flushSync=function(n){return rs(n)},xt.hydrate=function(n,r,l){if(!go(r))throw Error(s(200));return vo(null,n,r,!0,l)},xt.hydrateRoot=function(n,r,l){if(!hc(n))throw Error(s(405));var d=l!=null&&l.hydratedSources||null,f=!1,g="",w=Mf;if(l!=null&&(l.unstable_strictMode===!0&&(f=!0),l.identifierPrefix!==void 0&&(g=l.identifierPrefix),l.onRecoverableError!==void 0&&(w=l.onRecoverableError)),r=Af(r,null,n,1,l??null,f,!1,g,w),n[fn]=r.current,$i(n),d)for(n=0;n<d.length;n++)l=d[n],f=l._getVersion,f=f(l._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[l,f]:r.mutableSourceEagerHydrationData.push(l,f);return new po(r)},xt.render=function(n,r,l){if(!go(r))throw Error(s(200));return vo(null,n,r,!1,l)},xt.unmountComponentAtNode=function(n){if(!go(n))throw Error(s(40));return n._reactRootContainer?(rs(function(){vo(null,null,n,!1,function(){n._reactRootContainer=null,n[fn]=null})}),!0):!1},xt.unstable_batchedUpdates=sc,xt.unstable_renderSubtreeIntoContainer=function(n,r,l,d){if(!go(l))throw Error(s(200));if(n==null||n._reactInternals===void 0)throw Error(s(38));return vo(n,r,l,!1,d)},xt.version="18.3.1-next-f1338f8080-20240426",xt}var Ff;function gp(){if(Ff)return pc.exports;Ff=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(),pc.exports=zy(),pc.exports}var Uf;function By(){if(Uf)return yo;Uf=1;var e=gp();return yo.createRoot=e.createRoot,yo.hydrateRoot=e.hydrateRoot,yo}var Fy=By(),y=ou();const Kn="teamtrail",J={slug:Kn,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:Kn,dataDir:`.${Kn}`,apiPrefix:`/__${Kn}`,dataDirEnv:`${Kn.toUpperCase()}_DIR`,noRegisterEnv:`${Kn.toUpperCase()}_NO_REGISTER`,tokenEnv:`${Kn.toUpperCase()}_TOKEN`},Jo=`${Kn}.prefs`,Xo=e=>`${J.labelPrefix}:${e}`,au=Xo("map"),lu=Xo("hitl"),Uy=e=>e==="task"||e==="execute",cu=Xo("plan-only");function vp(e){return/^[A-Za-z0-9_@%+=:,./-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}const Wy=e=>e.map(vp).join(" "),Hy=/^\d+\.\d+\.\d+(-[0-9A-Za-z][0-9A-Za-z.-]*)?$/;function Ky(e){return Hy.test(e)?`${J.npm}@${e}`:J.npm}function kp(e,t){return Wy(["npx","-y",Ky(e),...t])}const Ro=["research","prototype","junction","task","execute"],Zo=[...Ro,"review"],ds="plan+execute",Vy=["verifying","rework","blocked"],uu=["off","checks","checks+review","checks+review+human"],yp=e=>uu.find(t=>t===e);function rr(e){return e.type==="junction"||e.type==="prototype"?"hitl":e.type==="research"?"afk":e.hitl?"hitl":"afk"}const Gy=["task","execute"];function wp(e,t,s=ds){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":s==="plan-only"&&e.type==="execute"?"parked":e.blockedBy.some(a=>{var c;return((c=t.get(a))==null?void 0:c.state)==="open"})?"blocked":"frontier"}function Zs(e,t=ds){const s=new Map(e.map(o=>[o.id,o]));return new Map(e.map(o=>[o.id,wp(o,s,t)]))}const Ke=200,Ye=56;function Wf(e,t="LR",s=ds){var $e;const o=t==="LR"?330:124,a=t==="LR"?112:262,c=Zs(e,s),u=new Map(e.map(oe=>[oe.id,oe])),h=new Map,m=new Set,p=oe=>{if(h.has(oe))return h.get(oe);if(m.has(oe))return 0;m.add(oe);const D=u.get(oe),X=D&&D.blockedBy.length?1+Math.max(...D.blockedBy.filter(le=>u.has(le)).map(p),-1):0;return m.delete(oe),h.set(oe,X),X},v=e.filter(oe=>c.get(oe.id)!=="out-of-scope"),k=e.filter(oe=>c.get(oe.id)==="out-of-scope"),x=[];for(const oe of v)(x[$e=p(oe.id)]??(x[$e]=[])).push(oe);const N=[],S=new Map;let j=0;x.forEach(oe=>{oe&&(oe.sort((D,X)=>{const le=te=>{const K=te.blockedBy.map(Y=>S.get(Y)).filter(Y=>Y!==void 0);return K.length?K.reduce((Y,B)=>Y+B,0)/K.length:te.createdAt/1e12};return le(D)-le(X)||D.createdAt-X.createdAt}),j=Math.max(j,oe.length),oe.forEach((D,X)=>S.set(D.id,X)))}),x.forEach((oe,D)=>{if(!oe)return;const X=(j-oe.length)*a/2;oe.forEach((le,te)=>{const K=D*o,Y=X+te*a;N.push({ticket:le,state:c.get(le.id),layer:D,x:t==="LR"?K:Y,y:t==="LR"?Y:K})})});const C=Math.max(x.length,1)*o-(o-(t==="LR"?Ke:Ye)),R=Math.max(j,1)*a-(a-(t==="LR"?Ye:Ke)),L=t==="LR"?C:R,U=t==="LR"?R:C,Z=U+54,Q=Math.max(1,Math.floor((L+24)/(Ke+24)));k.forEach((oe,D)=>{N.push({ticket:oe,state:"out-of-scope",layer:-1,x:D%Q*(Ke+24),y:Z+Math.floor(D/Q)*(Ye+16)})});const W=[],ie=new Map(N.map(oe=>[oe.ticket.id,oe]));for(const oe of N)for(const D of oe.ticket.blockedBy){const X=ie.get(D);X&&W.push({from:X,to:oe})}const G=Math.ceil(k.length/Q),ve=Math.max(L,Math.min(k.length,Q)*(Ke+24)-24),Le=k.length?Z+G*(Ye+16)-16:U;return{direction:t,nodes:N,edges:W,width:ve,graphH:U,quarantineY:Z,height:Le,quarantineH:G*(Ye+16)+24}}const Oo=["fast","balanced","strongest"],xp=e=>Oo.includes(e),du={research:"fast",task:"balanced",execute:"balanced",junction:"strongest",prototype:"strongest",review:"strongest"};function qy(e,t){var a,c;const s=(c=(a=t.modelMatching)==null?void 0:a.tiers)==null?void 0:c[e.type],o=du[e.type];return t.settingsUnconfirmed&&s?Oo.indexOf(s)>=Oo.indexOf(o)?s:o:s??o}function Qy(e){return Object.fromEntries(Zo.map(t=>[t,qy({type:t},e)]))}const Yy=e=>e!=="__proto__"&&e!=="constructor"&&e!=="prototype",Jy=64;function Xy(e,t){const s=[];for(let o=0;o<e.length;o++){const a=e[o];if(a!=="*"&&!(a==="?"&&t))s.push({kind:"char",c:a});else if(a==="?")s.push({kind:"one"});else if(e[o+1]!=="*")s.push({kind:"star"});else{const c=e[o+2]==="/";o+=c?2:1,s.push({kind:c?"dirs":"deep"})}}return Zy(s)}function Zy(e){const t=[];for(const s of e){const o=t.at(-1);(o==null?void 0:o.kind)==="dirs"&&s.kind==="dirs"||(o==null?void 0:o.kind)==="deep"&&(s.kind==="deep"||s.kind==="dirs")||((o==null?void 0:o.kind)==="dirs"&&s.kind==="deep"?t[t.length-1]=s:t.push(s))}return t}function ew({t:e,c:t,inText:s,next:o,cur:a,j:c}){switch(e.kind){case"char":return s&&t===e.c?o[c+1]:0;case"one":return s&&t!=="/"?o[c+1]:0;case"star":return o[c]||(s&&t!=="/"?a[c+1]:0);case"deep":return o[c]||(s?a[c+1]:0);case"dirs":return 0;default:return e}}function tw(e,t,s){const o=s.length,a=new Uint8Array(o+1);let c=0;for(let u=o;u>=0;u--){const h=u<o,m=h?s[u]:"";if(e.kind!=="dirs"){a[u]=ew({t:e,c:m,inText:h,next:t,cur:a,j:u});continue}m==="/"&&t[u+1]&&(c=1),a[u]=t[u]||c}return a}function nw(e,t,s){const o=Xy(e,s.segments);if(o.filter(c=>c.kind!=="char").length>Jy)return!1;let a=new Uint8Array(t.length+1);a[t.length]=1;for(let c=o.length-1;c>=0;c--)a=tw(o[c],a,t);return a[0]===1}const sw=["holding","challenged","invalidated","confirmed"],iw=e=>sw.includes(e),rw=J.labelPrefix,Dc=" -->",ow=7e4,jp=e=>`<!-- ${rw}:${e} `,aw=e=>JSON.stringify(e).replace(/--/g,"-\\u002d"),lw=(e,t)=>`${jp(e)}${t}${Dc}`;function cw(e,t){const s=e.trimEnd();if(!s.endsWith(Dc))return;const o=jp(t),a=s.lastIndexOf(o);if(!(a===-1||s.length-a>ow))return{before:s.slice(0,a),payload:s.slice(a+o.length,-Dc.length)}}const uw=/[\u0000-\u001f\u007f-\u009f\u2028\u2029\u200b\u2060\ufeff\u202a-\u202e\u2066-\u2069]/,dw=/[\u0000-\u001f\u007f-\u009f\u2028\u2029\u200b\u2060\ufeff\u202a-\u202e\u2066-\u2069]+/g,hw=/\r\n|[\r\u0085\u2028\u2029]/g,fw=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u0084\u0086-\u009f\u200b\u2060\ufeff\u202a-\u202e\u2066-\u2069]/g,mw=e=>uw.test(e),Ks=e=>e.replace(dw," ").trim(),pw=e=>e.replace(hw,`
41
+ `).replace(fw,"");function ea(e,t){const s=new RegExp(`^\\\\*(?:${t})`);return pw(e).trim().split(`
42
+ `).map(o=>s.test(o)?`\\${o}`:o).join(`
43
+ `)}function Lo(e,t){const s=new RegExp(`^\\\\+(?:${t})`);return e.split(`
44
+ `).map(o=>s.test(o)?o.slice(1):o).join(`
45
+ `)}const Np=J.labelPrefix,gw=new RegExp(`<(\\\\*)!--(?=\\s*${Np}:)`,"g"),vw=new RegExp(`<\\\\(\\\\*)!--(?=\\s*${Np}:)`,"g"),ta=e=>e.replace(gw,"<\\$1!--"),Ws=e=>e.replace(vw,"<$1!--"),Sp="asm",kw=/^-\s+(?:\[([a-z]+)\]\s+)?/,yw=1e3;function ww(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,yw)}}:{},...e.decidedBy?{decidedBy:e.decidedBy}:{}};return`- [${e.status}] ${ta(Ks(e.text))} ${lw(Sp,aw(t))}`}function xw(e){const t=e.map(jw);let s=Math.max(0,...t.map(o=>Sw(o.id)))+1;return t.map(o=>o.id?o:{...o,id:`S-${s++}`})}function jw(e){const t=cw(e,Sp),s=t?t.before:e,o=s.match(kw),a=o==null?void 0:o[1],c=Ws(s.slice(o?o[0].length:0).trim()),u=Nw(t==null?void 0:t.payload);return{id:u.id??"",text:c,status:iw(a)?a:"holding",tickets:Array.isArray(u.tickets)?u.tickets.map(String):[],...u.source?{source:u.source}:{},...u.challenge?{challenge:u.challenge}:{},...u.decidedBy?{decidedBy:u.decidedBy}:{}}}function Nw(e){if(!e)return{};try{const t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}function Sw(e){const t=e==null?void 0:e.match(/^S-(\d+)$/);return t?Number(t[1]):0}const bp=[["destination","Destination"],["notes","Notes"],["assumptions","Assumptions"],["decisions","Decisions so far"],["unspecified","Not yet specified"],["outOfScope","Out of scope"]],bw=Object.fromEntries(bp),Cp="##\\s",Hf=e=>ta(ea(e.trim(),Cp)),Kf=e=>Lo(Ws(e),Cp),Vf=e=>ta(Ks(e)),Cw=/^-\s+(?:\[?([#A-Z0-9-]+)\]?:?\s+)?(.*)$/;function $w(e){var o;const t=a=>a.length?a.map(c=>`- ${Vf(c)}`).join(`
46
+ `):"_None yet._",s=a=>a.length?a.map(c=>`- ${c.ticketKey?`${Ks(c.ticketKey)}: `:""}${Vf(c.text)}`).join(`
47
+ `):"_None yet._";return[`## Destination
48
+
49
+ ${Hf(e.destination)}`,`## Notes
50
+
51
+ ${Hf(e.notes)||"_None yet._"}`,...(o=e.assumptions)!=null&&o.length?[`## Assumptions
52
+
53
+ ${e.assumptions.map(ww).join(`
54
+ `)}`]:[],`## Decisions so far
55
+
56
+ ${s(e.decisions)}`,`## Not yet specified
57
+
58
+ ${t(e.unspecified)}`,`## Out of scope
59
+
60
+ ${t(e.outOfScope)}`].join(`
61
+
62
+ `)+`
63
+ `}function Tw(e){var o;const t={destination:"",notes:"",decisions:[],unspecified:[],outOfScope:[]},s=e.split(/^##\s+/m).slice(1);for(const a of s){const c=a.indexOf(`
64
+ `),u=a.slice(0,c===-1?void 0:c).trim().toLowerCase(),h=(c===-1?"":a.slice(c+1)).trim(),m=(o=bp.find(([,k])=>k.toLowerCase()===u))==null?void 0:o[0];if(!m)continue;const p=/^_none yet\._$/i.test(h),v=p?[]:h.split(`
65
+ `).map(k=>k.trim()).filter(k=>k.startsWith("- "));m==="destination"?t.destination=Kf(h):m==="notes"?t.notes=p?"":Kf(h):m==="assumptions"?t.assumptions=xw(v):m==="decisions"?t.decisions=v.map(k=>{const x=k.match(Cw);return x&&x[1]&&/\d/.test(x[1])?{ticketKey:x[1],text:Ws(x[2])}:{text:Ws(k.slice(2))}}):t[m]=v.map(k=>Ws(k.slice(2)))}return t}const na={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"]},Ew=(e,t)=>`${e[0].toUpperCase()}${e.slice(1)} ${t}/${na[e].length}`;async function Aw(e,t,s={}){var u,h,m;const o=Iw(t,t.mode??ds),a=await e.createMap({title:o.title,mode:o.mode,sections:o.sections,...o.verification?{verification:o.verification}:{}});await((u=s.onMapCreated)==null?void 0:u.call(s,a));const c=new Map;for(const p of o.tickets){const v=await e.createTicket(a.id,{title:p.title,type:p.type,hitl:p.hitl,body:`${p.body}
66
+
67
+ Part of trail ${a.key}.`});c.set(p.ref,v),await((h=s.onTicketCreated)==null?void 0:h.call(s,v,p.ref))}for(const p of o.tickets)for(const v of p.blockedBy??[]){const k=c.get(v),x=c.get(p.ref);k&&(await e.addBlocking(a.id,k.id,x.id),await((m=s.onEdgeWired)==null?void 0:m.call(s,k,x)))}return{map:a,tickets:[...c.values()]}}function Iw(e,t){if(t==="plan+execute")return{...e,mode:t};const s=new Map(e.tickets.filter(a=>a.type==="execute").map(a=>[a.ref,a.blockedBy??[]])),o=a=>a.flatMap(c=>s.has(c)?o(s.get(c)):[c]);return{...e,mode:t,tickets:e.tickets.filter(a=>!s.has(a.ref)).map(a=>({...a,blockedBy:[...new Set(o(a.blockedBy??[]))]}))}}class Mw{constructor(){ce(this,"tails",new Map)}run(t,s){const a=(this.tails.get(t)??Promise.resolve()).catch(()=>{}).then(s);return this.tails.set(t,a),a.finally(()=>this.tails.get(t)===a&&this.tails.delete(t)).catch(()=>{}),a}}class De extends Error{}const Rw={frontier:"ready",blocked:"backlog",parked:"backlog",claimed:"working",verifying:"verifying",rework:"rework",held:"blocked",decided:"done","out-of-scope":"cancelled"};function Ow(e,t,s=ds){return Rw[wp(e,t,s)]}const Lw=["backlog","ready","working","verifying","rework","blocked"],Vi=["agent","trail lead"],Pw=[{event:"claim",from:["ready","rework"],to:["working"],actors:Vi},{event:"release",from:["working"],to:["ready","rework"],actors:Vi},{event:"expire",from:["working"],to:["ready","rework"],actors:["engine","trail lead"]},{event:"complete",from:["backlog","ready","working","rework"],to:["done"],actors:Vi},{event:"submit",from:["working"],to:["verifying"],actors:Vi},{event:"checks.pass",from:["verifying"],to:["verifying","done"],actors:["engine"]},{event:"checks.fail",from:["verifying"],to:["rework","blocked"],actors:["engine"]},{event:"checks.error",from:["verifying"],to:["blocked"],actors:["engine"]},{event:"reverify",from:["verifying"],to:["verifying"],actors:["engine","trail lead"]},{event:"review.pass",from:["verifying"],to:["verifying","done"],actors:["engine"]},{event:"review.fail",from:["verifying"],to:["rework"],actors:["engine"]},{event:"review.needs_human",from:["verifying"],to:["blocked"],actors:["engine"]},{event:"approve",from:["verifying"],to:["done"],actors:["trail lead"]},{event:"reject",from:["verifying","blocked"],to:["rework"],actors:["trail lead"]},{event:"accept",from:["verifying","blocked"],to:["done"],actors:["trail lead"]},{event:"unblock",from:["blocked"],to:["ready","rework","verifying"],actors:["trail lead"]},{event:"cancel",from:Lw,to:["cancelled"],actors:[...Vi,"engine"]},{event:"reopen",from:["done","cancelled"],to:["ready"],actors:["trail lead"]}],_w=e=>Pw.find(t=>t.event===e),Dw=new Mw;function zw(e,t,s){if(s){if(!e.to.includes(s))throw new De(`${e.event} cannot lead to ${s}`);return s}if(e.to.length===1)return e.to[0];if(e.event==="release"||e.event==="expire")return t.status==="rework"?"rework":"ready";throw new De(`${e.event} needs a target: ${e.to.join(" or ")}`)}async function Bw(e,t,s,o){const{to:a,actor:c}=o,u=async h=>{(s.status??null)!==h&&await e.setMeta(t,s.id,{status:h})};switch(a){case"working":s.assignee!==c&&await e.assign(t,s.id,c);return;case"ready":case"rework":s.state==="closed"&&await e.reopen(t,s.id),await u(a==="rework"?"rework":null),s.assignee&&await e.assign(t,s.id,null);return;case"verifying":case"blocked":await u(a);return;case"done":case"cancelled":await u(null),await e.close(t,s.id,a==="done"?"completed":"not_planned");return;case"backlog":throw new De("backlog follows from blockers; no transition leads there")}}function sa(e,t,s,o){return Dw.run(`${t}/${s}`,async()=>{var p;const a=await e.loadMap(t),c=a.tickets.find(v=>v.id===s);if(!c)throw new De(`ticket ${s} not found`);const u=Ow(c,new Map(a.tickets.map(v=>[v.id,v])),a.map.mode);if(o.expect&&u!==o.expect)throw new De(`${c.key} changed: it is ${u} now`);const h=_w(o.event);if(!h.from.includes(u))throw new De(`${c.key} is ${u}; ${o.event} needs ${h.from.join(" or ")}`);if(!h.actors.includes(o.actorKind))throw new De(`${o.event} is not for ${o.actorKind}s`);const m=zw(h,c,o.to);await Bw(e,t,c,{to:m,actor:o.actor});try{await((p=o.journal)==null?void 0:p.append({v:1,kind:"transition",at:Date.now(),mapId:t,ticketId:s,ticketKey:c.key,event:o.event,from:u,to:m,actor:o.actor,actorKind:o.actorKind,...o.reason?{reason:o.reason}:{},...o.sessionId?{sessionId:o.sessionId}:{}}))}catch{}return{ticket:c,from:u,to:m}})}async function Gf(e,t,s,o){const{assignee:a}=o,c=await e.loadMap(t),u=c.tickets.find(v=>v.id===s);if(!u)throw new De(`ticket ${s} not found`);const h=Zs(c.tickets,c.map.mode).get(s);if(h!=="frontier"&&h!=="rework")throw new De(`${u.key} is ${h}, not on the frontier`);await sa(e,t,s,{event:"claim",actor:a,actorKind:o.actorKind??"agent",reason:o.reason,sessionId:o.sessionId,journal:o.journal});const p=(await e.loadMap(t)).tickets.find(v=>v.id===s);if(p.assignee!==a)throw new De(`${u.key} was claimed by ${p.assignee}`);return p}async function Fw(e,t,s,o={}){const c=(await e.loadMap(t)).tickets.find(u=>u.id===s);if(!c)throw new De(`ticket ${s} not found`);await sa(e,t,s,{event:"release",actor:o.actor??c.assignee??"trail lead",actorKind:o.actorKind??"agent",reason:o.reason,sessionId:o.sessionId,journal:o.journal})}async function hu(e,t,s,o={}){if(s.source.ref){const c=(await e.listDecisions(t)).find(u=>!u.postedBy&&u.source.kind===s.source.kind&&u.source.ref===s.source.ref);if(c)return c}const a=await e.createDecision(t,s);if(o.appendToTrail??!0){const c=await e.loadMap(t);await e.updateMapSections(t,{decisions:[...c.map.sections.decisions,{ticketId:a.ticketId,ticketKey:a.ticketKey,text:o.trailLine??a.summary}]})}return a}async function Uw(e,t,s,o){const c=(await e.listDecisions(t)).find(k=>k.id===s);if(!c)throw new De(`decision ${s} not found`);if(c.postedBy)throw new De(`${c.id} is ${c.postedBy}'s decision; record your own instead`);if(c.supersededBy)throw new De(`${c.id} is already superseded by ${c.supersededBy}`);const u=await e.createDecision(t,{ticketId:c.ticketId,ticketKey:c.ticketKey,...o,question:o.question??c.question,supersedes:c.id});await e.markSuperseded(t,c.id,u.id);const m=(await e.loadMap(t)).map.sections.decisions,p=m.findIndex(k=>k.text===c.summary||!!c.ticketId&&k.ticketId===c.ticketId||!!c.ticketKey&&k.ticketKey===c.ticketKey),v={ticketId:u.ticketId,ticketKey:u.ticketKey,text:u.summary};return await e.updateMapSections(t,{decisions:p<0?[...m,v]:m.map((k,x)=>x===p?v:k)}),u}async function Ww(e,t,s){await e.setMapMode(t,s)}function $p(e){return e==="plan-only"?Ro.filter(t=>t!=="execute"):Ro}function Hw(e,t){if(!$p(e).includes(t))throw new De(`${t} tickets are disabled on plan-only maps`)}const Gn={lookout:{label:"Lookout",code:"CMD"},agent:{label:"Agent",code:"AGT"},slack:{label:"Slack",code:"SLK"},tracker:{label:"Tracker",code:"TRK"}},Po=Object.keys(Gn),Kw=e=>e in Gn,Tp=" (unverified, from text)";function er(e){return e.derived||e.decidedBy.endsWith(Tp)?"unverified":e.postedBy?"teammate":e.source.kind==="agent"&&e.decidedBy!=="trail lead"&&!e.decidedBy.startsWith("slack:")?"agent":"human"}const Ep=e=>e.postedBy?`posted by ${e.postedBy} in ${e.postedIn??"the tracker"}`:void 0,or=e=>e.supersededBy?"superseded":"active";function ia(e){const t=e.replace(/\s+/g," ").trim(),s=t.match(/^(.{20,180}?[.!?])(\s|$)/);return s?s[1]:t.slice(0,180)}function Vw(e,t,s){var o;return{...s,id:e,mapId:t,decidedAt:s.decidedAt??Date.now(),summary:((o=s.summary)==null?void 0:o.trim())||ia(s.answer),alternatives:s.alternatives??[],rationale:s.rationale??"",participants:s.participants??[{id:s.decidedBy}],transcript:s.transcript??[]}}const Gw=e=>Number(e.replace(/\D/g,""))||0;function qw(e,t){const s=new Map(e.map(u=>[u.id,u])),o=new Set;let a=s.get(t);for(;a!=null&&a.supersedes&&s.has(a.supersedes)&&!o.has(a.id);)o.add(a.id),a=s.get(a.supersedes);const c=[];o.clear();for(let u=a;u&&!o.has(u.id);u=u.supersededBy?s.get(u.supersededBy):void 0)o.add(u.id),c.push(u);return c}async function Qw(e,t,s,o){var h;const c=(await e.loadMap(t)).tickets.find(m=>m.id===s);if(!c)throw new De(`ticket ${s} not found`);if(c.state==="closed")throw new De(`${c.key} is already closed`);o.transcript&&await e.comment(t,s,o.author,`**HITL transcript**
68
+
69
+ ${o.transcript}`),await e.comment(t,s,o.author,`**Resolution**
70
+
71
+ ${o.answer}`),await sa(e,t,s,{event:o.event??"complete",actor:o.actor??o.author,actorKind:o.actorKind??"agent",sessionId:o.sessionId,reason:o.reason,journal:o.journal,...o.event&&o.event!=="complete"?{to:"done"}:{}});const u=o.decision??{};return await hu(e,t,{ticketId:c.id,ticketKey:c.key,question:u.question??c.title,answer:u.answer??o.answer,summary:u.summary??o.summary??ia(o.answer),alternatives:u.alternatives,rationale:u.rationale,decidedBy:u.decidedBy??o.author,participants:u.participants,source:u.source??{kind:"agent",label:o.author},transcript:u.transcript,...u.risk?{risk:u.risk}:{},...(h=u.assumes)!=null&&h.length?{assumes:u.assumes}:{}},{trailLine:o.trailLine}),c}async function Yw(e,t,s,o){const a=await e.loadMap(t);if(!a.map.sections.unspecified.includes(s))throw new De(`"${s}" is not in Not yet specified`);Hw(a.map.mode,o.type);const c=await e.createTicket(t,{title:o.title??s,type:o.type,hitl:o.hitl,body:`${o.body??`Promoted from Not yet specified: ${s}`}
72
+
73
+ Part of trail ${a.map.key}.`});for(const h of o.blockedBy??[])await e.addBlocking(t,h,c.id);const u=await e.loadMap(t);return await e.updateMapSections(t,{unspecified:u.map.sections.unspecified.filter(h=>h!==s)}),c}async function Jw(e,t,s,o){const a=await e.loadMap(t),{unspecified:c,outOfScope:u}=a.map.sections;if("unspecified"in s){if(!c.includes(s.unspecified))throw new De(`"${s.unspecified}" is not in Not yet specified`);await e.updateMapSections(t,{unspecified:c.filter(p=>p!==s.unspecified),outOfScope:[...u,`${s.unspecified} — ${o.reason}`]});return}const h=a.tickets.find(p=>p.id===s.ticketId);if(!h)throw new De(`ticket ${s.ticketId} not found`);await e.comment(t,h.id,o.author,`**Ruled out of scope**
74
+
75
+ ${o.reason}`),await sa(e,t,h.id,{event:"cancel",actor:o.author,actorKind:o.actorKind??"agent",reason:o.reason,sessionId:o.sessionId,journal:o.journal}),await hu(e,t,{ticketId:h.id,ticketKey:h.key,question:h.title,answer:`Out of scope: ${o.reason}`,decidedBy:o.author,source:o.source??{kind:"agent",label:o.author}},{appendToTrail:!1});const m=await e.loadMap(t);await e.updateMapSections(t,{outOfScope:[...m.map.sections.outOfScope,`${h.key} ${h.title} — ${o.reason}`]})}async function Xw(e,t,s,o){s&&Zw(s),await e.setMapMeta(t,{modelMatching:s&&ex(s),confirm:!0})}function Zw(e){if(typeof e.enabled!="boolean")throw new De('"enabled" must be true or false');for(const[t,s]of Object.entries(e.tiers??{})){if(!Zo.includes(t))throw new De(`unknown ticket type "${t}"`);if(!xp(s))throw new De(`"${t}" must be fast, balanced or strongest`)}}function ex(e){const t=Object.fromEntries(Object.entries(e.tiers??{}).filter(([,s])=>s));return Object.keys(t).length?{enabled:e.enabled,tiers:t}:{enabled:e.enabled}}function tx(e){return{async append(t){await fetch(`${e}/journal`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}}}const Ap={v:1,default:"checks",appliesTo:["execute","task"],checks:{},run:[],failFast:!0,maxAttempts:3,totalTimeoutSec:1800,noChanges:{allow:["research","junction","prototype"],else:"flag"},stale:"reverify",github:{enabled:"auto",requiredChecks:[],pollSec:60}};new Set(Object.keys(Ap));const nx=2*6e4,kc=e=>e<6e4?`${Math.round(e/1e3)}s`:`${Math.round(e/6e4)}m`;function sx(e,t){if(!e)return{tone:"unknown",label:"PR sync ?",title:"PR/CI sync state unavailable"};const s=e.repo?` · ${e.repo}`:"",o=e.lastOkAt?`last ok ${kc(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"}${s}
76
+ ${o}`}:e.state==="rate-limited"?{tone:"failed",label:"PR sync paused",title:`Rate limited${s}; retrying ${e.nextAt?`in ${kc(Math.max(0,e.nextAt-t))}`:"later"}
77
+ ${o}`}:!e.lastOkAt||e.lastOkAt!==e.lastAttemptAt||e.nextAt!==void 0&&t>e.nextAt+nx?{tone:"stale",label:"PR sync stale",title:`No recent sync${s}
78
+ ${o}`}:{tone:"ok",label:`PR sync ${kc(t-e.lastOkAt)}`,title:`PR/CI synced${s}, ${o}`}}class Vs{constructor(){ce(this,"listeners",new Set)}on(t){return this.listeners.add(t),()=>this.listeners.delete(t)}emit(t){for(const s of[...this.listeners])s(t)}}let ix=0;const Io=(e="id")=>`${e}_${Date.now().toString(36)}${(ix++).toString(36)}`,rx=e=>e.via==="chat"?`in ${e.chatOf??"an agent"}'s chat`:void 0;function ox(e){return e.via?e.via==="chat"&&e.chatOf?{via:e.via,chatOf:e.chatOf}:{via:e.via}:{}}const zc=(e,t)=>({inputTokens:((e==null?void 0:e.inputTokens)??0)+t.inputTokens,outputTokens:((e==null?void 0:e.outputTokens)??0)+t.outputTokens,costUsd:((e==null?void 0:e.costUsd)??0)+t.costUsd,...e!=null&&e.cachedInputTokens||t.cachedInputTokens?{cachedInputTokens:((e==null?void 0:e.cachedInputTokens)??0)+(t.cachedInputTokens??0)}:{}}),Ip=(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 ax(e,t,s){const o=()=>e.find(t.id)??t,a=c=>e.push({source:"session",sessionId:t.id,agent:t.agent,...c});return{id:t.id,get info(){return o()},step(c,u,h){const m=na[s][c-1];e.patchSession(t.id,{step:c,stepLabel:m,...h?{ticketId:h}:{}}),a({tag:Ew(s,c),level:"step",text:u?`${m}: ${u}`:m,ticketId:h??o().ticketId})},log(c,u="info"){a({level:u,text:c,ticketId:o().ticketId})},say(c){e.chat({sessionId:t.id,ticketId:o().ticketId,from:"agent",author:t.agent,text:c})},ask(c,u,h){var p;const m={id:Io("q"),sessionId:t.id,mapId:t.mapId,ticketId:o().ticketId,agent:t.agent,text:c,suggestions:u,at:Date.now(),...h!=null&&h.urgency?{urgency:h.urgency}:{},...(p=h==null?void 0:h.blocks)!=null&&p.length?{blocks:h.blocks}:{}};return e.chat({sessionId:t.id,ticketId:m.ticketId,from:"agent",author:t.agent,text:c,questionId:m.id}),e.addPending(m),e.patchSession(t.id,{waitingOn:m.id}),a({level:"alert",ticketId:m.ticketId,text:"Decision request · waiting on you",signal:!0}),e.awaitAnswer(m.id)},done(c=!0,u,h){e.patchSession(t.id,{status:c?"done":"failed",endedAt:Date.now(),waitingOn:void 0}),e.dropPending(t.id),a({level:c?"ok":"alert",text:u??(c?"Session closed":"Session aborted"),signal:h==null?void 0:h.signal})},bindMap(c){var h;const u=o().usage;u&&(e.addMapUsage(c,u),(h=e.ledger())==null||h.add(c,u,t.id)),e.patchSession(t.id,{mapId:c})},usage(c){var m;const u=o().mapId;(m=e.ledger())==null||m.add(u,c,t.id),e.addMapUsage(u,c);const h=o().usage;e.patchSession(t.id,{usage:{...zc(h,c),source:c.source??(h==null?void 0:h.source)}})},setUsage(c){var v;const u=o().usage,h=Ip(c,u);if(!h.inputTokens&&!h.outputTokens&&!h.costUsd&&!h.cachedInputTokens&&(u==null?void 0:u.source)===c.source&&`${u==null?void 0:u.models}`==`${c.models}`)return;const p=o().mapId;(h.inputTokens>0||h.outputTokens>0||h.costUsd>0)&&((v=e.ledger())==null||v.add(p,h,t.id)),e.addMapUsage(p,h),e.patchSession(t.id,{usage:c})},setModel(c,u){const h=o();h.model===c&&h.tier===u||e.patchSession(t.id,{model:c,tier:u})}}}class lx{constructor(t=400,s){ce(this,"state",{sessions:[],feed:[],chats:[],pending:[],answered:[],usageByMap:{}});ce(this,"changes",new Vs);ce(this,"resolvers",new Map);ce(this,"remote",new Map);ce(this,"remoteAnswer");ce(this,"host",{find:t=>this.state.sessions.find(s=>s.id===t),patchSession:(t,s)=>this.patchSession(t,s),push:t=>void this.push(t),chat:t=>this.chat(t),addPending:t=>this.set({pending:[...this.state.pending,t]}),dropPending:t=>{this.state.pending.filter(o=>o.sessionId===t).length&&this.set({pending:this.state.pending.filter(o=>o.sessionId!==t)})},awaitAnswer:t=>new Promise(s=>this.resolvers.set(t,s)),addMapUsage:(t,s)=>{this.state={...this.state,usageByMap:{...this.state.usageByMap,[t]:zc(this.state.usageByMap[t],s)}}},ledger:()=>this.ledger});this.maxFeed=t,this.ledger=s}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 s={id:Io("f"),at:t.at??Date.now(),...t};return s.source==="system"&&!s.agent&&(s.agent=J.assistant.name),this.set({feed:[...this.state.feed,s].slice(-this.maxFeed)}),s}patchSession(t,s){this.set({sessions:this.state.sessions.map(o=>o.id===t?{...o,...s}:o)})}chat(t){this.set({chats:[...this.state.chats,{id:Io("m"),at:Date.now(),...t}].slice(-600)})}answer(t,s,o,a){const c=this.state.pending.find(p=>p.id===t),u=this.resolvers.get(t),h=!!c&&this.remote.has(c.sessionId)&&!!this.remoteAnswer;if(!c||!u&&!h)return!1;this.resolvers.delete(t);const m=ox(a);return this.chat({sessionId:c.sessionId,ticketId:c.ticketId,from:"human",author:o,text:s,...m}),this.set({pending:this.state.pending.filter(p=>p.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}:{},...c.urgency?{urgency:c.urgency}:{},...m}].slice(-200)}),this.patchSession(c.sessionId,{waitingOn:void 0}),this.push({source:"trail lead",agent:o,level:"ok",ticketId:c.ticketId,sessionId:c.sessionId,text:`Answered ${c.agent}`}),u?u(s):this.remoteAnswer(c,s,o),!0}syncRemote(t){var p;const{session:s}=t,o=s.id;if(!this.remote.has(o)&&this.state.sessions.some(v=>v.id===o))return;const a=this.remote.get(o);this.remote.set(o,s.mapId?s.usage:a);let c=this.state.usageByMap;if(s.usage&&s.mapId){const v=Ip(s.usage,a);(v.inputTokens||v.outputTokens||v.costUsd)&&(c={...c,[s.mapId]:zc(c[s.mapId],v)}),(p=this.ledger)==null||p.addTotal(s.mapId,o,s.usage)}const u=v=>v.filter(k=>k.sessionId!==o),h=new Set(this.state.answered.map(v=>v.id)),m=this.state.sessions.some(v=>v.id===o)?this.state.sessions.map(v=>v.id===o?s:v):[...this.state.sessions,s].slice(-24);this.set({sessions:m,chats:[...u(this.state.chats),...t.chats].sort((v,k)=>v.at-k.at).slice(-600),pending:[...u(this.state.pending),...t.pending],answered:[...this.state.answered,...t.answered.filter(v=>!h.has(v.id))].sort((v,k)=>v.answeredAt-k.answeredAt).slice(-200),feed:[...this.state.feed.filter(v=>v.sessionId!==o),...t.feed].sort((v,k)=>v.at-k.at).slice(-this.maxFeed),usageByMap:c})}isRemote(t){return this.remote.has(t)}startSession(t){const s={...t,id:t.id??Io("s"),step:0,total:na[t.mode].length,stepLabel:"BOOT",status:"running",startedAt:Date.now()};this.set({sessions:[...this.state.sessions,s].slice(-24)});const o=ax(this.host,s,t.mode);return this.push({source:"session",sessionId:s.id,agent:s.agent,level:"info",text:`Session opened · ${t.mode}`}),o}}function cx(e,t){const s=o=>{var a;return((a=t(o))==null?void 0:a.key)??o};switch(e.kind){case"map.created":return{source:"tracker",level:"ok",text:`Trail created · label ${au}`};case"map.updated":return{source:"tracker",level:"info",text:`Trail updated${e.section?` · ${bw[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 ${s(e.ticketId)}`};case"ticket.claimed":return{source:"tracker",level:"warn",ticketId:e.ticketId,text:`Assigned ${s(e.ticketId)} to ${e.assignee}`};case"ticket.released":return{source:"tracker",level:"info",ticketId:e.ticketId,text:`Unassigned ${s(e.ticketId)}`};case"ticket.closed":return{source:"tracker",level:e.reason==="completed"?"ok":"alert",ticketId:e.ticketId,text:`Closed ${s(e.ticketId)} · ${e.reason==="completed"?"completed":"not planned"}`};case"ticket.commented":return{source:"tracker",level:"info",ticketId:e.ticketId,text:`Comment on ${s(e.ticketId)}`};case"edge.added":return{source:"tracker",level:"info",ticketId:e.blockedId,text:`${s(e.blockerId)} blocks ${s(e.blockedId)}`};case"edge.removed":return{source:"tracker",level:"info",ticketId:e.blockedId,text:`${s(e.blockerId)} no longer blocks ${s(e.blockedId)}`};case"decision.recorded":return{source:"tracker",level:"ok",ticketId:e.ticketId,text:`Decision ${e.decisionId} recorded${e.ticketId?` · ${s(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 ux=new Set(["createMap","setMapMode","setMapMeta","updateMapSections","createTicket","addBlocking","removeBlocking","editTicket","reopen","assign","comment","close","setMeta","createDecision","markSuperseded"]),dx=5*6e4;function hx(e){let t={status:"idle",inflight:0,writes:0,errors:0,events:[]};const s=new Vs,o=c=>{t={...t,...c},s.emit(t)};return e.subscribe(c=>{const u=c.at-dx;o({events:[...t.events.filter(h=>h.at>=u),{at:c.at,external:c.kind==="external.changed"||"external"in c&&!!c.external}]})}),{adapter:new Proxy(e,{get(c,u,h){const m=Reflect.get(c,u,h);return typeof m!="function"?m:ux.has(u)?async(...p)=>{const v=Date.now();o({inflight:t.inflight+1,status:"syncing"});try{const k=await m.apply(c,p),x=t.inflight-1;return o({inflight:x,writes:t.writes+1,lastWriteMs:Date.now()-v,lastWriteAt:Date.now(),status:x?"syncing":"ok",lastError:void 0}),k}catch(k){const x=t.inflight-1;throw o({inflight:x,errors:t.errors+1,status:"error",lastError:String(k.message??k)}),k}}:m.bind(c)}}),get health(){return t},subscribe:c=>s.on(c)}}function Mp(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 s of Zs(e.tickets,e.map.mode).values())t[s]++;return t.resolvedPct=t.total?Math.round((t.decided+t["out-of-scope"])/t.total*100):0,t}function Rp(e){const t=Mp(e);return{decided:t.decided,total:t.total-t["out-of-scope"]}}function fx(e){const t=new Map(e.tickets.filter(u=>u.state==="open").map(u=>[u.id,u])),s=new Map,o=new Set,a=u=>{if(s.has(u))return s.get(u);if(o.has(u))return[];o.add(u);const h=t.get(u);let m=[];for(const v of h.blockedBy)if(t.has(v)){const k=a(v);k.length>m.length&&(m=k)}o.delete(u);const p=[...m,h];return s.set(u,p),p};let c=[];for(const u of t.keys()){const h=a(u);h.length>c.length&&(c=h)}return c}function mx(e){return Ro.map(t=>{const s=e.tickets.filter(o=>o.type===t);return{type:t,open:s.filter(o=>o.state==="open").length,closed:s.filter(o=>o.state==="closed").length}}).filter(t=>t.open+t.closed>0)}function px(e,t){const s=e.pending.filter(a=>!0),o=e.answered.filter(a=>!0);return{open:s.length,oldestAt:s.length?Math.min(...s.map(a=>a.at)):void 0,answered:o.length,avgWaitMs:o.length?o.reduce((a,c)=>a+(c.answeredAt-c.askedAt),0)/o.length:void 0}}function Op(e,t){return t&&e.usageByMap[t]||{inputTokens:0,outputTokens:0,costUsd:0}}const gx=e=>e.usage?e.usage.inputTokens+e.usage.outputTokens:0,Lp={"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 Pp(e,t){var o;const s=new Set;for(const a of e.sessions)t&&a.mapId===t&&((o=a.usage)!=null&&o.source)&&s.add(a.usage.source);return[...s].sort()}function vx(e,t){return e.replace(/^\*\*HITL transcript\*\*\s*/,"").split(/\n\n(?=\*\*[^*]+:\*\* )/).map(s=>s.match(/^\*\*([^*]+):\*\* ([\s\S]*)$/)).filter(s=>!!s).map(s=>({from:"agent",author:s[1],text:s[2].trim(),at:t}))}function kx(e,t){const s=new Set(t.map(a=>a.ticketId).filter(Boolean)),o=e.tickets.filter(a=>a.state==="closed"&&a.closeReason==="completed"&&!s.has(a.id)).map(a=>{var v;const c=[...a.comments].reverse().find(k=>k.body.startsWith("**Resolution**")),u=c?c.body.replace(/^\*\*Resolution\*\*\s*/,""):((v=e.map.sections.decisions.find(k=>k.ticketId===a.id||k.ticketKey===a.key))==null?void 0:v.text)??"",h=(c==null?void 0:c.author)??a.assignee??"unknown",m=a.comments.find(k=>k.body.startsWith("**HITL transcript**")),p=m?vx(m.body,m.createdAt):[];return{id:`T${a.key}`,mapId:e.map.id,ticketId:a.id,ticketKey:a.key,question:a.title,answer:u,summary:ia(u),alternatives:[],rationale:"",decidedBy:`${h}${Tp}`,decidedAt:a.closedAt??(c==null?void 0:c.createdAt)??a.updatedAt,participants:[...new Set([h,...p.map(k=>k.author)])].map(k=>({id:k})),source:{kind:"tracker",ref:`${e.map.id}/tickets/${a.id}`,label:`unverified, from text: ${c?`${a.key} resolution comment`:"the map’s Decisions so far"}`},transcript:p,derived:!0}});return[...t,...o].sort((a,c)=>c.decidedAt-a.decidedAt)}function yx(e,t){var o;const s=(o=t.query)==null?void 0:o.trim().toLowerCase();return e.filter(a=>(!t.mapId||a.mapId===t.mapId)&&(!t.source||a.source.kind===t.source)&&(!t.decidedBy||a.decidedBy===t.decidedBy)&&(!t.madeBy||er(a)===t.madeBy)&&(!t.status||or(a)===t.status)&&(!s||[a.id,a.ticketKey,a.question,a.answer,a.summary,a.rationale,a.decidedBy,...a.alternatives,...a.transcript.map(c=>c.text)].join(`
79
+ `).toLowerCase().includes(s)))}function wx(e,t=Date.now()){const s=Object.fromEntries(Po.map(u=>[u,0]));let o=0,a=0,c=0;for(const u of e){s[u.source.kind]++,u.supersededBy&&o++,t-u.decidedAt<864e5&&a++;const h=er(u);(h==="human"||h==="agent"&&u.transcript.some(m=>m.from==="human"))&&c++}return{total:e.length,active:e.length-o,superseded:o,last24h:a,human:c,bySource:s}}function ra(e){const t=e.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);if(!t)return{front:{},body:e};const s={};for(const o of t[1].split(`
80
+ `)){const a=o.indexOf(":");if(a<0)continue;const c=o.slice(0,a).trim(),u=o.slice(a+1).trim();Yy(c)&&(s[c]=u.startsWith("[")?Nx(u.slice(1,-1)).map(Qf).filter(Boolean):Qf(u))}return{front:s,body:t[2]}}const xx=e=>e===""||/^[\s#&*!|>'"%@`[\]{},?:-]|[:#]\s|\s$|,|["\\[\]]/.test(e)||mw(e)||/^(true|false|null|~|\d[\d.e+-]*)$/i.test(e),jx=e=>JSON.stringify(e).replace(/[\u007f\u0085\u2028\u2029]/g,t=>`\\u${t.charCodeAt(0).toString(16).padStart(4,"0")}`),qf=e=>xx(e)?jx(e):e;function Qf(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 Nx(e){const t=[];let s="",o=!1,a=!1;for(const c of e)c==='"'&&!a&&(o=!o),a=o&&c==="\\"&&!a,c===","&&!o?(t.push(s.trim()),s=""):s+=c;return s.trim()&&t.push(s.trim()),t}function Sx(e){if(!/^[\w-]+$/.test(e))throw new Error(`invalid frontmatter key: ${JSON.stringify(e)}`);return e}function fu(e,t){return`---
81
+ ${Object.entries(e).map(([o,a])=>`${Sx(o)}: ${Array.isArray(a)?`[${a.map(qf).join(", ")}]`:qf(a)}`).join(`
82
+ `)}
83
+ ---
84
+
85
+ ${t.trim()}
86
+ `}const we=e=>Array.isArray(e)?e.join(","):e??"";function qt(e){return Array.isArray(e)?e:e?[e]:[]}const Hs=e=>Date.parse(we(e))||0,cn=e=>new Date(e).toISOString(),_p=["schema","breaking-api","auth-permissions","billing","data-deletion","product-behaviour","dependencies"],Dp=["low","medium","high"],bx=e=>_p.includes(e),Cx=e=>Dp.includes(e);function $x(e){return e?{risk:e.level,...e.category?{risk_category:e.category}:{},risk_reason:e.reason}:{}}function Tx(e){const t=we(e.risk);if(!Cx(t))return{};const s=we(e.risk_category);return{risk:{level:t,...bx(s)?{category:s}:{},reason:we(e.risk_reason)}}}const zp=["Question","Decision","Summary","Alternatives","Rationale","Transcript"],mu=`## (?:${zp.join("|")})\\s*$`,Bp=`${mu}|### `,wo=e=>ea(e.trim(),mu),Ex=e=>e.name?`${e.id}|${e.name}`:e.id,Ax=e=>{const t=e.indexOf("|");return t<0?{id:e}:{id:e.slice(0,t),name:e.slice(t+1)}};function Fp(e){var c;const t={id:e.id,trail:e.mapId,...e.ticketId?{ticket:e.ticketId,ticket_key:e.ticketKey??""}:{},decided_by:e.decidedBy,decided_at:cn(e.decidedAt),participants:e.participants.map(Ex),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(([u,h])=>`${u}=${h}`)}:{},...e.supersedes?{supersedes:e.supersedes}:{},...e.supersededBy?{superseded_by:e.supersededBy}:{},...$x(e.risk),...(c=e.assumes)!=null&&c.length?{assumes:e.assumes}:{}},s=u=>u.length?u.map(h=>`- ${Ks(h)}`).join(`
87
+ `):"_None._",o=e.transcript.length?e.transcript.map(u=>`### ${Ks(u.author)} · ${u.from} @ ${cn(u.at)}
88
+
89
+ ${ea(u.text.trim(),Bp)}`).join(`
90
+
91
+ `):"_None._",a=[`## Question
92
+
93
+ ${wo(e.question)}`,`## Decision
94
+
95
+ ${wo(e.answer)}`,`## Summary
96
+
97
+ ${wo(e.summary)}`,`## Alternatives
98
+
99
+ ${s(e.alternatives)}`,`## Rationale
100
+
101
+ ${wo(e.rationale)||"_None._"}`,`## Transcript
102
+
103
+ ${o}`].join(`
104
+
105
+ `);return fu(t,a)}function Bc(e){const{front:t,body:s}=ra(e),o={},a=new RegExp(`^## (${zp.join("|")})\\s*$`,"gm"),c=[...s.matchAll(a)];c.forEach((k,x)=>{var A;const N=s.slice(k.index+k[0].length,((A=c[x+1])==null?void 0:A.index)??s.length).trim(),S=k[1],j=S==="Transcript"?N:Lo(N,mu);o[S]=/^_none\._$/i.test(N)?"":j});const u=(o.Transcript??"").split(/^### /m).slice(1).map(k=>{const x=k.indexOf(`
106
+ `),N=x<0?k:k.slice(0,x),S=N.lastIndexOf(" @ "),j=S<0?N:N.slice(0,S),A=S<0?"":N.slice(S+3),C=j.lastIndexOf(" · "),R=C<0?j:j.slice(0,C),L=C<0?"agent":j.slice(C+3);return{author:R.trim(),from:["agent","human","system"].includes(L.trim())?L.trim():"agent",at:Date.parse(A)||0,text:x<0?"":Lo(k.slice(x+1).trim(),Bp)}}),h=we(t.source),m=qt(t.source_meta),p={kind:Kw(h)?h:"tracker",...we(t.source_ref)?{ref:we(t.source_ref)}:{},...we(t.source_url)?{url:we(t.source_url)}:{},...we(t.source_label)?{label:we(t.source_label)}:{},...m.length?{meta:Object.fromEntries(m.map(k=>[k.slice(0,k.indexOf("=")),k.slice(k.indexOf("=")+1)]))}:{}},v=o.Decision??"";return{id:we(t.id),mapId:we(t.trail),ticketId:we(t.ticket)||void 0,ticketKey:we(t.ticket_key)||void 0,question:o.Question??"",answer:v,summary:o.Summary||ia(v),alternatives:(o.Alternatives??"").split(`
107
+ `).map(k=>k.trim()).filter(k=>k.startsWith("- ")).map(k=>k.slice(2)),rationale:o.Rationale??"",decidedBy:we(t.decided_by),decidedAt:Hs(t.decided_at),participants:qt(t.participants).map(Ax),source:p,supersedes:we(t.supersedes)||void 0,supersededBy:we(t.superseded_by)||void 0,...qt(t.assumes).length?{assumes:qt(t.assumes)}:{},transcript:u,...Tx(t)}}function Ix(e){return e.url?` · [${e.label??"link"}](${e.url})`:e.label?` · ${e.label}`:""}function Mx(e,t,s={}){const o=[`# ${s.title??"Decisions"}`,"",`Exported ${cn(s.now??Date.now())} · ${e.length} decisions`],a=new Map;for(const c of e)a.set(c.mapId,[...a.get(c.mapId)??[],c]);for(const[c,u]of a){const h=t[c];o.push("",`## Trail ${h?`${h.key} ${h.title}`:c}`);for(const m of u){const p=Gn[m.source.kind].label;o.push("",`### ${m.id}${m.ticketKey?` · ${m.ticketKey}`:""} · ${m.question}`,"",`- **Status:** ${or(m)}${m.supersededBy?` (superseded by ${m.supersededBy})`:""}${m.supersedes?` · supersedes ${m.supersedes}`:""}`,`- **Decided by:** ${m.decidedBy} · ${cn(m.decidedAt)}`,`- **Source:** ${p}${Ix(m.source)}`,...m.participants.length?[`- **Participants:** ${m.participants.map(v=>v.name??v.id).join(", ")}`]:[],"",`**Decision:** ${m.answer}`,...m.alternatives.length?["","**Alternatives:**",...m.alternatives.map(v=>`- ${v}`)]:[],...m.rationale?["",`**Rationale:** ${m.rationale}`]:[],...m.transcript.length?["","<details><summary>Transcript</summary>","",...m.transcript.map(v=>`> **${v.author}:** ${v.text.replace(/\n/g,`
108
+ > `)}
109
+ >`),"","</details>"]:[])}}return o.join(`
110
+ `)+`
111
+ `}function Fc(e,t,s){try{const o=e.get(t);return o?JSON.parse(o):s}catch{return s}}class Yf{constructor(t,s="presence"){ce(this,"seen");this.store=t,this.key=s,this.seen=Fc(t,s,{})}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,s=Date.now()){let o=!1;for(const a of t)(this.seen[a]??0)>=s||(this.seen[a]=s,o=!0);o&&this.store.set(this.key,JSON.stringify(this.seen))}}const yc=5*6e4,Rx=14*864e5;class Jf{constructor(t,s="usage"){ce(this,"buckets");ce(this,"dirty",!1);ce(this,"timer");ce(this,"totals");this.store=t,this.key=s,this.buckets=Fc(t,s,{}),this.totals=Fc(t,`${s}.totals`,{})}addTotal(t,s,o,a=Date.now()){const c=this.totals[s],u={inputTokens:o.inputTokens-((c==null?void 0:c.inputTokens)??0),outputTokens:o.outputTokens-((c==null?void 0:c.outputTokens)??0),costUsd:o.costUsd-((c==null?void 0:c.costUsd)??0)};this.totals[s]={...o,at:a},u.inputTokens>0||u.outputTokens>0||u.costUsd>0?this.add(t,u,s,a):this.save()}add(t,s,o,a=Date.now()){var m;if(!t)return;const c=Math.floor(a/yc)*yc,u=(m=this.buckets)[t]??(m[t]=[]);let h=u.find(p=>p.at===c);h||(h={at:c,i:0,o:0,c:0,s:[]},u.push(h),u.sort((p,v)=>p.at-v.at)),h.i+=s.inputTokens,h.o+=s.outputTokens,h.c+=s.costUsd,h.s.includes(o)||h.s.push(o),this.save()}since(t,s){const o={inputTokens:0,outputTokens:0,costUsd:0,sessions:0},a=new Set;for(const c of this.buckets[t]??[])c.at+yc<=s||(o.inputTokens+=c.i,o.outputTokens+=c.o,o.costUsd+=c.c,c.s.forEach(u=>a.add(u)));return o.sessions=a.size,o}save(){this.dirty=!0,!this.timer&&(this.timer=setTimeout(()=>{if(this.timer=void 0,!this.dirty)return;this.dirty=!1;const t=Date.now()-Rx;for(const s of Object.keys(this.buckets))this.buckets[s]=this.buckets[s].filter(o=>o.at>=t);for(const[s,o]of Object.entries(this.totals))o.at<t&&delete this.totals[s];this.store.set(this.key,JSON.stringify(this.buckets)),this.store.set(`${this.key}.totals`,JSON.stringify(this.totals))},2e3))}}function Ox(e){const t=e.now??Date.now(),s=e.snaps.map(u=>{var ie;const h=u.map.id,m=e.since(h),p=G=>!!G&&G>=m,v=Zs(u.tickets,u.map.mode),k=new Map(u.tickets.map(G=>[G.id,G])),x=(e.attention??[]).filter(G=>G.mapId===h),N=Lx(e.activity.pending.filter(G=>G.mapId===h),x),S=new Set(N.map(G=>G.ticketId)),j=G=>G.state==="open"&&(S.has(G.id)||rr(G)==="hitl"),A=u.tickets.filter(G=>v.get(G.id)==="blocked").map(G=>({ticket:G,on:G.blockedBy.map(ve=>k.get(ve)).filter(ve=>!!ve&&j(ve))})).filter(G=>G.on.length),C=e.decisions.filter(G=>G.mapId===h&&p(G.decidedAt)).sort((G,ve)=>ve.decidedAt-G.decidedAt),R=u.tickets.filter(G=>G.state==="closed"&&p(G.closedAt)).sort((G,ve)=>(G.closedAt??0)-(ve.closedAt??0)),L=R.filter(G=>G.closeReason==="completed"),U=R.filter(G=>G.closeReason==="not_planned"),Z=u.tickets.filter(G=>p(G.createdAt)),Q=((ie=e.ledger)==null?void 0:ie.since(h,m))??{inputTokens:0,outputTokens:0,costUsd:0,sessions:0},W=e.activity.sessions.filter(G=>G.mapId===h&&G.status==="running");return{mapId:h,key:u.map.key,title:u.map.title,since:m,done:L,ruledOut:U,opened:Z,blocked:A,waiting:N,needsYou:x,decisions:C,agentDecisions:C.filter(G=>er(G)==="agent"),usage:Q,active:W,changed:!!(R.length||Z.length||C.length||N.some(G=>p(G.at))||Q.costUsd>0)}}),o=s.filter(u=>u.changed||u.waiting.length).sort((u,h)=>+(h.mapId===e.currentMapId)-+(u.mapId===e.currentMapId)),a=u=>o.reduce((h,m)=>h+m[u].length,0),c=o.flatMap(u=>u.waiting).reduce((u,h)=>u===void 0||h.at<u?h.at:u,void 0);return{since:o.length?Math.min(...o.map(u=>u.since)):t,now:t,trails:o,totals:{done:a("done"),ruledOut:a("ruledOut"),blocked:a("blocked"),waiting:a("waiting"),oldestWaitMs:c===void 0?void 0:t-c,agentDecisions:a("agentDecisions"),usage:o.reduce((u,h)=>({inputTokens:u.inputTokens+h.usage.inputTokens,outputTokens:u.outputTokens+h.usage.outputTokens,costUsd:u.costUsd+h.usage.costUsd,sessions:u.sessions+h.usage.sessions}),{inputTokens:0,outputTokens:0,costUsd:0,sessions:0}),active:a("active")},changed:s.some(u=>u.changed)}}function Lx(e,t){const s=new Map(t.filter(a=>a.kind==="question").map((a,c)=>[a.ref,c])),o=a=>s.get(a.id)??Number.MAX_SAFE_INTEGER;return[...e].sort((a,c)=>o(a)-o(c)||a.at-c.at)}const Yi=(e,t,s=`${t}s`)=>`${e} ${e===1?t:s}`;function Px(e){return e.trails.flatMap(t=>{const s=new Set(t.waiting.map(o=>o.ticketId));return t.blocked.filter(o=>o.on.some(a=>s.has(a.id)))})}function _x(e){return e.length===1?`, and it holds up ${e[0].ticket.title.replace(/^./,t=>t.toLowerCase())}`:e.length>1?`, holding up ${Yi(e.length,"ticket")}`:""}function Dx(e,t=new Date(e.now).getHours()){const s=e.totals,a=e.now-e.since>=6*36e5&&t>=5&&t<12?"Good morning.":"Welcome back.",c=[];if(s.done&&c.push(`${Yi(s.done,"ticket")} ${s.done===1?"is":"are"} done.`),s.agentDecisions&&c.push(`Agents made ${Yi(s.agentDecisions,"decision")}.`),s.waiting){const u=_x(Px(e));c.push(`${Yi(s.waiting,"decision")} ${s.waiting===1?"is":"are"} waiting on you${u}.`)}else c.push("Nothing is waiting on you.");return!s.done&&!s.agentDecisions&&s.ruledOut&&c.unshift(`${Yi(s.ruledOut,"ticket")} ruled out of scope.`),[a,...c].join(" ")}const zx=e=>{if(!e.length)return;const t=[...e].sort((o,a)=>o-a),s=Math.floor(t.length/2);return t.length%2?t[s]:Math.round((t[s-1]+t[s])/2)};function Bx(e){return e.state==="open"?"open":e.closeReason==="not_planned"?"cancelled":"done"}function Up({snap:e,journal:t,answered:s,usage:o}){const a=e.map.id,c=t.filter(j=>j.mapId===a).sort((j,A)=>j.at-A.at),u=new Map;for(const j of c)u.set(j.ticketId,[...u.get(j.ticketId)??[],j]);const h=e.tickets.filter(j=>j.type!=="review").map(j=>{var U;const A=u.get(j.id)??[],C=Bx(j),R=(U=A.find(Z=>Z.event==="claim"))==null?void 0:U.at,L=C==="done"?j.closedAt:void 0;return{id:j.id,key:j.key,title:j.title,type:j.type,outcome:C,claimedAt:R,doneAt:L,leadMs:L&&R&&L>=R?L-R:void 0,reworks:A.filter(Z=>Z.to==="rework").length,reviews:{passed:A.filter(Z=>Z.event==="review.pass").length,failed:A.filter(Z=>Z.event==="review.fail").length,needsHuman:A.filter(Z=>Z.event==="review.needs_human").length},operatorActions:A.filter(Z=>Z.actorKind==="trail lead").length}}),m=h.filter(j=>j.outcome==="done"),p=Math.max(0,...m.map(j=>j.doneAt??0)),v=c.filter(j=>j.actorKind==="trail lead"),k=new Set(s.filter(j=>j.mapId===a).map(j=>j.id)).size,x=v.length,N=j=>h.reduce((A,C)=>A+j(C),0),S=(o==null?void 0:o.costUsd)??0;return{mapId:a,tickets:h,done:m.length,cancelled:h.filter(j=>j.outcome==="cancelled").length,open:h.filter(j=>j.outcome==="open").length,trailLeadMs:p&&p>=e.map.createdAt?p-e.map.createdAt:void 0,medianLeadMs:zx(m.flatMap(j=>j.leadMs===void 0?[]:[j.leadMs])),interventions:{answers:k,operatorActions:x,reworkRequested:v.filter(j=>j.event==="reject").length,total:k+x},rework:{tickets:h.filter(j=>j.reworks>0).length,cycles:N(j=>j.reworks)},reviews:{passed:N(j=>j.reviews.passed),failed:N(j=>j.reviews.failed),needsHuman:N(j=>j.reviews.needsHuman)},spend:{costUsd:Math.round(S*1e4)/1e4,tokens:((o==null?void 0:o.inputTokens)??0)+((o==null?void 0:o.outputTokens)??0),perVerifiedTicketUsd:m.length&&S?Math.round(S/m.length*1e4)/1e4:void 0}}}const wc=e=>e.split("-")[0];function un(e){if(e===void 0)return"—";const t=Math.round(e/6e4);if(t<90)return`${t} min`;const s=e/36e5;return s<48?`${Math.round(s*10)/10} h`:`${Math.round(s/24*10)/10} d`}const Xf=e=>e===void 0?"—":`$${e.toFixed(e<1?4:2)}`;function Fx(e,t,s=Date.now()){const o=e.interventions;return[`# Trail report: ${t}`,"",`_Generated ${new Date(s).toISOString()} by Teamtrail._`,"","| Measure | Value |","| --- | --- |",`| Tickets done / cancelled / open | ${e.done} / ${e.cancelled} / ${e.open} |`,`| Trail lead time (created → last done) | ${un(e.trailLeadMs)} |`,`| Median ticket lead time (claim → done) | ${un(e.medianLeadMs)} |`,`| Human interventions | ${o.total} (${o.answers} answers, ${o.operatorActions} operator actions, ${o.reworkRequested} sent back) |`,`| Rework | ${e.rework.cycles} cycles on ${e.rework.tickets} tickets |`,`| Reviews | ${e.reviews.passed} passed, ${e.reviews.failed} failed, ${e.reviews.needsHuman} needed a human |`,`| Spend | ${Xf(e.spend.costUsd)} · ${e.spend.tokens.toLocaleString("en-US")} tokens |`,`| Cost per verified ticket | ${Xf(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} | ${un(c.leadMs)} | ${c.reworks} | ${c.reviews.passed}/${c.reviews.failed} | ${c.operatorActions} |`),""].join(`
112
+ `)}const pu=5,Wp=1.5,Ux=15,xo=e=>Math.round(e*100);function Wx(e){const t=e.filter(u=>u.findings.raised>=pu).sort((u,h)=>h.findings.upheld/h.findings.raised-u.findings.upheld/u.findings.raised||u.key.localeCompare(h.key));if(t.length<2)return[];const[s,o]=[t[0],t[t.length-1]],[a,c]=[s.findings.upheld/s.findings.raised,o.findings.upheld/o.findings.raised];return xo(a)-xo(c)<Ux?[]:[{id:"review-findings",text:`${s.key} review findings upheld ${xo(a)}% vs ${o.key} ${xo(c)}%`,because:`${s.findings.upheld} of ${s.findings.raised} and ${o.findings.upheld} of ${o.findings.raised} failed reviews stood; a finding is overruled when you accept the work anyway`}]}function Hx(e){const t=c=>c.reworkCycles/c.tickets,s=e.filter(c=>c.tickets>=pu).sort((c,u)=>t(c)-t(u)||c.key.localeCompare(u.key));if(s.length<2)return[];const[o,a]=[s[0],s[s.length-1]];return t(a)-t(o)<.2||t(a)<t(o)*Wp?[]:[{id:"rework",text:`${a.key} work goes back to rework more: ${t(a).toFixed(1)} times per ticket vs ${o.key} ${t(o).toFixed(1)}`,because:`${a.reworkCycles} cycles on ${a.tickets} tickets, and ${o.reworkCycles} on ${o.tickets}`}]}function Kx(e,t){const s=u=>u.medianLeadMs??0,o=t.filter(u=>u.done>=pu&&u.medianLeadMs!==void 0).sort((u,h)=>s(u)-s(h)||u.key.localeCompare(h.key));if(o.length<2)return[];const[a,c]=[o[0],o[o.length-1]];return s(c)<s(a)*Wp?[]:[{id:`speed-${e}`,text:`${e} tickets: ${a.key} is faster, ${un(a.medianLeadMs)} vs ${c.key} ${un(c.medianLeadMs)}`,because:`Median first claim to done, over ${a.done} and ${c.done} done tickets`}]}function Vx(e){const t=Object.keys(e.byTypeAndVendor).sort();return[...Wx(e.byVendor),...Hx(e.byVendor),...t.flatMap(s=>Kx(s,e.byTypeAndVendor[s]))]}const Gx=e=>{if(!e.length)return;const t=[...e].sort((o,a)=>o-a),s=Math.floor(t.length/2);return t.length%2?t[s]:Math.round((t[s-1]+t[s])/2)},Hp=e=>{var t;return(t=e.filter(s=>s.event==="claim"&&s.actorKind==="agent").at(-1))==null?void 0:t.actor},Uc=(e,t,s)=>e.filter(o=>o.mapId===t&&o.ticketId===s).sort((o,a)=>o.at-a.at);function qx(e,t){return e.tickets.flatMap(s=>{var k;if(s.type!=="review"||!s.reviewOf)return[];const o=Uc(t,e.map.id,s.id),a=Hp(o);if(!a)return[];const c=((k=o.filter(x=>x.event==="claim").at(-1))==null?void 0:k.at)??0,u=Uc(t,e.map.id,s.reviewOf),h=u.findIndex(x=>x.at>=c&&x.event.startsWith("review."));if(h<0||u[h].event!=="review.fail")return[];const m=u.slice(h+1),p=m.findIndex(x=>x.event.startsWith("review.")),v=p<0?m:m.slice(0,p);return[{reviewer:a,upheld:!v.some(x=>x.event==="accept"&&x.actorKind==="trail lead")}]})}function Qx(e,t){var o;const s=(o=e.tickets.find(a=>a.id===t))==null?void 0:o.assignee;return s&&/^[a-z]+-\d+$/.test(s)?s:void 0}function Kp(e,t){const s=a=>t.reduce((c,{ticket:u})=>c+a(u),0),o=a=>t.filter(c=>c.ticket.outcome===a).length;return{key:e,tickets:t.length,done:o("done"),cancelled:o("cancelled"),open:o("open"),medianLeadMs:Gx(t.flatMap(({ticket:a})=>a.leadMs===void 0?[]:[a.leadMs])),reworkCycles:s(a=>a.reworks),reviews:{passed:s(a=>a.reviews.passed),failed:s(a=>a.reviews.failed),needsHuman:s(a=>a.reviews.needsHuman)},answers:0,findings:{raised:0,upheld:0}}}function jo(e,t){const s=new Map;for(const o of e){const a=t(o);a&&s.set(a,[...s.get(a)??[],o])}return new Map([...s].map(([o,a])=>[o,Kp(o,a)]))}const Wc=(e,t)=>{const s=e.get(t)??Kp(t,[]);return e.set(t,s),s};function Zf(e,t,s){const o=Wc(e,t);o.findings.raised+=1,s&&(o.findings.upheld+=1)}const No=e=>[...e.values()].sort((t,s)=>s.tickets-t.tickets||t.key.localeCompare(s.key));function Vp(e){const t=e.flatMap(({snap:p,journal:v,answered:k,usage:x})=>Up({snap:p,journal:v,answered:k,usage:x}).tickets.map(N=>({ticket:N,agent:Hp(Uc(v,p.map.id,N.id))??Qx(p,N.id)}))),s=p=>p.agent?wc(p.agent):void 0,o=jo(t,p=>p.agent),a=jo(t,s),c=jo(t,p=>p.ticket.type),u=new Set;for(const{snap:p,journal:v,answered:k}of e){for(const x of k){const N=`${x.mapId}/${x.id}`;x.mapId!==p.map.id||u.has(N)||(u.add(N),Wc(o,x.agent).answers+=1,Wc(a,wc(x.agent)).answers+=1)}for(const x of qx(p,v))Zf(o,x.reviewer,x.upheld),Zf(a,wc(x.reviewer),x.upheld)}const h=Object.fromEntries([...c.keys()].map(p=>[p,No(jo(t.filter(v=>v.ticket.type===p),s))])),m={trails:e.length,tickets:t.length,byAgent:No(o),byVendor:No(a),byType:No(c),byTypeAndVendor:h};return{...m,recommendations:Vx(m)}}const Yx={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
+ `)},Jx=[["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"]],Gi=Object.fromEntries(Jx);function Xx(e,t){const s=new Set(e.map(o=>o.source).filter(Boolean));return t.filter(o=>!s.has(o))}const Zx=["architecture","convention","gotcha","dead-end","glossary","fact"],Gp=["business-rule","product-decision","persona","ux-principle","pricing"],ej=[...Zx,...Gp],tj=e=>e.status==="confirmed"||e.status==="assumption";function nj(e,t){return nw(e,t.replace(/^\.\//,""),{segments:!0})}const sj={"business-rule":3,convention:3,"product-decision":2,architecture:2,gotcha:2,"dead-end":2,"ux-principle":2},ij=["business-rule","ux-principle","convention"],em=600,rj=e=>`flagged as possibly outdated by ${e}; the human is reviewing it`,oj=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(" ")),tm=e=>new Set((e.toLowerCase().match(/[a-z0-9][a-z0-9_-]{2,}/g)??[]).filter(t=>!oj.has(t)));function qp(e,t,s=4e3,o=()=>[]){const a=t.ticket?tm(`${t.ticket.title} ${t.ticket.body}`):new Set,c=new Set((t.tags??[]).map(p=>p.toLowerCase())),u=e.filter(tj).map(p=>{const v=[];let k=sj[p.kind]??1;for(const S of p.scope){const j=t.paths.find(A=>nj(S,A));if(j){k+=6,v.push(`path match ${S} (${j})`);break}}const x=p.tags.filter(S=>c.has(S.toLowerCase())||a.has(S.toLowerCase()));x.length&&(k+=3*x.length,v.push(`tag ${x.join(", ")}`));const N=[...tm(p.title)].filter(S=>a.has(S));return N.length&&(k+=N.length,v.push(`mentions ${N.slice(0,3).join(", ")}`)),t.trailKey&&p.sources.includes(`trail:${t.trailKey}`)&&(k+=3,v.push("same trail")),t.discovery&&Gp.includes(p.kind)&&(k+=8,v.push("product context for discovery")),!v.length&&ij.includes(p.kind)&&!p.scope.length&&v.push(`${p.kind.replace("-"," ")} for the whole project`),{e:p,score:k,why:v}}).filter(p=>p.why.length>0).sort((p,v)=>v.score-p.score||p.e.id.localeCompare(v.e.id,void 0,{numeric:!0})),h=[];let m=0;for(const{e:p,why:v}of u){const k=p.body.length>em?`${p.body.slice(0,em)}…`:p.body;if(m+k.length>s&&h.length)break;m+=k.length;const x=o(p);h.push({id:p.id,title:p.title,kind:p.kind,status:p.status,body:k,why:v,...x.length?{mayBeOutdated:x}:{},...p.flag?{flagged:rj(p.flag.by)}:{}})}return h}const aj=new RegExp("`([^`\\s]+/[^`\\s]+)`|(?:^|[\\s(])/?((?:[\\w.-]+/)+[\\w.-]+)","gm");function Qp(e){const t=new Set;for(const s of e.matchAll(aj))t.add((s[1]??s[2]).replace(/^\.?\//,"").replace(/[.,;:]+$/,""));return[...t]}const lj=[{level:"high",label:"High risk"},{level:"medium",label:"Medium risk"},{level:"low",label:"Low risk"},{level:"none",label:"No category"}];function cj(e){return lj.map(t=>({...t,decisions:e.filter(s=>{var o;return(((o=s.risk)==null?void 0:o.level)??"none")===t.level})})).filter(t=>t.decisions.length)}const uj=1/3;function oa(e,t=Date.now()){const s=e.expiresAt-t;return s<=0?"expired":s<=e.ttlMs*uj?"stalled":"live"}function dj(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 hj=e=>e.urgency==="fyi"||e.kind==="policy";function fj(e){const t=e.filter(([s,o])=>Zo.includes(s)&&xp(o));return Object.fromEntries(t)}const nm=e=>Number(e.slice(0,2))*60+Number(e.slice(3,5));function mj(e,t){const s=new Date(t),o=s.getHours()*60+s.getMinutes(),a=nm(e.from),c=nm(e.to),u=c<=a;if(!(u?o>=a||o<c:o>=a&&o<c))return!1;if(!e.days)return!0;const m=u&&o<c,p=(s.getDay()+(m?6:0))%7;return e.days.includes(p)}function pj(e,t){const s=new Date(t);return s.setHours(Number(e.to.slice(0,2)),Number(e.to.slice(3,5)),0,0),s.getTime()<=t&&s.setDate(s.getDate()+1),s.getTime()}function gj(e,t){const s=e.focusUntil??0;if(s>t)return{kind:"manual",until:s};if(!e.focus||!mj(e.focus,t))return{kind:"off"};const o=pj(e.focus,t);return(e.focusOffUntil??0)>t?{kind:"paused",until:o}:{kind:"hours",until:o}}function vj(e,t,s){const o={...e};switch(delete o.focusUntil,delete o.focusOffUntil,t.kind){case"for":return{...o,focusUntil:s+t.minutes*6e4};case"resume":return o;case"end":{const a=gj(o,s);return a.kind==="hours"?{...o,focusOffUntil:a.until}:o}default:return t}}function kj(e,t){var o;const s={...e};return t.verification===null?delete s.verification:t.verification&&(s.verification=t.verification),t.guides===null||((o=t.guides)==null?void 0:o.length)===0?delete s.guides:t.guides&&(s.guides=t.guides),t.modelMatching===null?delete s.modelMatching:t.modelMatching&&(s.modelMatching=t.modelMatching),t.confirm&&delete s.settingsUnconfirmed,s}function yj(e,t,s){const o=Date.now();return{id:e,key:t,...s,state:"open",blockedBy:[],comments:[],createdAt:o,updatedAt:o}}const wj=(e,t)=>({...e,blockedBy:e.blockedBy.filter(s=>s!==t)}),xj=(e,t)=>{var s;return{...e,...(s=t.title)!=null&&s.trim()?{title:t.title.trim()}:{},...t.body!==void 0?{body:t.body}:{}}};function jj(e){const{closeReason:t,closedAt:s,...o}=e;return{...o,state:"open"}}const Nj=["status","verification","checks","reviewOf","guide"];function Sj(e,t){const s={...e};for(const o of Nj)t[o]!==void 0&&(t[o]===null?delete s[o]:s[o]=t[o]);return t.confirm&&delete s.settingsUnconfirmed,s}async function Yp(e){const t=await e.list(),s=t.filter(a=>!a.includes("/decisions/")).map(a=>{var c;return Number(((c=a.match(/(\d+)\.md$/))==null?void 0:c[1])??0)}),o=await Promise.all(t.filter(a=>a.endsWith("/map.md")).map(async a=>Number(we(ra(await e.read(a)).front.key).replace(/\D/g,""))||0));return Math.max(0,...s,...o)+1}const Jp="### [^\\n]* @ \\d{4}-\\d\\d-\\d\\dT",Xp=`## Comments\\s*$|${Jp}`,Zp=`<!-- ${J.labelPrefix}:comments -->`,bj=new RegExp(`^## Comments[ \\t]*\\n${Zp}[ \\t]*$`,"m"),Cj=new RegExp(`^(?=${Jp})### `,"m"),gu=2,eg=e=>ta(ea(e,Xp)),sm=e=>Lo(Ws(e),Xp);function $j(e,t){const s=(t>=gu?bj:/^## Comments\s*$/m).exec(e);return s?[e.slice(0,s.index),e.slice(s.index+s[0].length)]:[e,""]}function im(e){const{front:t,body:s}=ra(e),o=Number(we(t.format))||1,[a,c]=$j(s,o),u=c.split(o>=gu?Cj:/^### /m).slice(1).map((v,k)=>{const x=v.indexOf(`
114
+ `),N=v.slice(0,x),S=N.lastIndexOf(" @ ");return{id:`c${k}`,author:N.slice(0,S<0?void 0:S).trim(),createdAt:S>=0&&Date.parse(N.slice(S+3))||0,body:sm(v.slice(x+1).trim())}}),h=we(t.close_reason),m=Vy.find(v=>v===we(t.status)),p=yp(we(t.verification));return{id:we(t.id),key:`#${we(t.id)}`,title:we(t.title),type:we(t.type)||"task",hitl:qt(t.labels).includes(lu)||void 0,state:we(t.state)==="closed"?"closed":"open",closeReason:h==="completed"||h==="not_planned"?h:void 0,assignee:we(t.assignee)||void 0,...m?{status:m}:{},...p?{verification:p}:{},...t.checks!==void 0?{checks:qt(t.checks)}:{},...we(t.review_of)?{reviewOf:we(t.review_of)}:{},...we(t.guide)?{guide:we(t.guide)}:{},blockedBy:qt(t.blocked_by),body:sm(a.trim()),comments:u,createdAt:Hs(t.created),updatedAt:Hs(t.updated),closedAt:Hs(t.closed)||void 0}}function tg(e){const t={id:e.id,format:String(gu),title:e.title,type:e.type,labels:[Xo(e.type),...Uy(e.type)&&e.hitl?[lu]:[]],state:e.state,close_reason:e.closeReason??"",assignee:e.assignee??"",...e.status?{status:e.status}:{},...e.verification?{verification:e.verification}:{},...e.checks?{checks:e.checks}:{},...e.reviewOf?{review_of:e.reviewOf}:{},...e.guide?{guide:e.guide}:{},blocked_by:e.blockedBy,created:cn(e.createdAt),updated:cn(e.updatedAt),...e.closedAt?{closed:cn(e.closedAt)}:{}},s=e.comments.length?`
115
+
116
+ ## Comments
117
+ ${Zp}
118
+
119
+ ${e.comments.map(Tj).join(`
120
+
121
+ `)}`:"";return fu(t,eg(e.body)+s)}function Tj(e){return`### ${Ks(e.author)} @ ${cn(e.createdAt)}
122
+
123
+ ${eg(e.body)}`}async function Ej(e,t,s){for(let o=0;;o++){const a=await t();if(s(a.path),!e.create)return await e.write(a.path,a.text),a.value;if(await e.create(a.path,a.text))return a.value;if(o>=50)throw new Error(`could not allocate ${a.path}`)}}async function Aj(e,t,s){const o=await Yp(e),a=yj(String(o),`#${o}`,s);return{path:`${t}/tickets/${a.id}.md`,text:tg({...a,updatedAt:Date.now()}),value:a}}async function Ij(e,t,s){const o=(await e.list()).filter(u=>u.includes("/decisions/")),a=Math.max(0,...o.map(u=>Gw(u.split("/").pop())))+1,c=Vw(`D-${a}`,t,s);return{path:`${t}/decisions/${c.id}.md`,text:Fp(c),value:c}}const Mj=/^([^/]+)\/decisions\/([^/]+)\.md$/,Rj=(e,t)=>e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,40)||`map-${t}`,ng=/^[A-Za-z0-9][A-Za-z0-9_-]*(?:\.[A-Za-z0-9_-]+)*$/;function cs(e){if(typeof e!="string"||e.length>128||!ng.test(e))throw new Error(`not a valid id: ${JSON.stringify(e)}`);return e}const Oj=e=>{const t=e.match(/^[^/]+\/tickets\/([^/]+)\.md$/);return!!t&&ng.test(t[1])};class Lj{constructor(t,s){ce(this,"seen",new Map);ce(this,"pending",new Map);this.read=t,this.emit=s}knows(t){return this.seen.has(t)}remember(t,s,o){this.seen.set(t,{text:s,supersededBy:o})}queue(t){const s=t.split("/")[0],o=this.pending.get(s)??{paths:new Set,timer:setTimeout(()=>void this.flush(s),250)};o.paths.add(t),this.pending.set(s,o)}async flush(t){const s=this.pending.get(t);if(this.pending.delete(t),!s)return;const o=[...s.paths].filter(u=>Mj.test(u)),a=[];for(const u of o){const h=await this.read(u).catch(()=>""),m=this.seen.get(u);if(!h||(m==null?void 0:m.text)===h)continue;const p=Bc(h);this.seen.set(u,{text:h,supersededBy:p.supersededBy}),m?p.supersededBy&&p.supersededBy!==m.supersededBy&&a.push({kind:"decision.superseded",mapId:t,decisionId:p.id,supersededBy:p.supersededBy,external:!0,at:Date.now()}):a.push({kind:"decision.recorded",mapId:t,decisionId:p.id,ticketId:p.ticketId,external:!0,at:Date.now()})}o.length?!a.length&&o.length<s.paths.size&&a.push({kind:"external.changed",mapId:t,at:Date.now()}):a.push({kind:"external.changed",mapId:t,at:Date.now()});const c=u=>u.kind==="decision.recorded"?0:1;a.sort((u,h)=>c(u)-c(h));for(const u of a)this.emit(u)}}function Pj(e){const t=we(e["model-matching"]);if(t!=="on"&&t!=="off")return;const s=fj(qt(e["model-tiers"]).map(o=>o.split("=").map(a=>a.trim())));return Object.keys(s).length?{enabled:t==="on",tiers:s}:{enabled:t==="on"}}function _j(e){if(!e)return{};const t=Object.entries(e.tiers??{}).map(([s,o])=>`${s}=${o}`);return{"model-matching":e.enabled?"on":"off",...t.length?{"model-tiers":t}:{}}}function rm(e,t){const{front:s,body:o}=ra(t),a=yp(we(s.verification)),c=Pj(s);return{id:e,key:we(s.key)||e,title:we(s.title)||e,mode:we(s.mode)==="plan-only"||qt(s.labels).includes(cu)?"plan-only":ds,...a?{verification:a}:{},...qt(s.guides).length?{guides:qt(s.guides)}:{},...c?{modelMatching:c}:{},sections:Tw(o),createdAt:Hs(s.created),updatedAt:Hs(s.updated)}}function Dj(e){var t;return fu({key:e.key,title:e.title,mode:e.mode,...e.verification?{verification:e.verification}:{},...(t=e.guides)!=null&&t.length?{guides:e.guides}:{},..._j(e.modelMatching),labels:[au,...e.mode==="plan-only"?[cu]:[]],created:cn(e.createdAt),updated:cn(e.updatedAt)},$w(e.sections))}function zj(e,t){t.code!=="ENOENT"&&console.warn(`Teamtrail: decision ${e} can't be read: ${t.message}`)}class Bj{constructor(t,s=`./${J.dataDir}`){ce(this,"kind","markdown");ce(this,"label","Local markdown");ce(this,"events",new Vs);ce(this,"selfWrites",new Map);ce(this,"external",new Lj(t=>this.fs.read(t),t=>this.events.emit(t)));ce(this,"ticketPath",(t,s)=>`${cs(t)}/tickets/${cs(s)}.md`);var o;this.fs=t,this.location=s,(o=t.watch)==null||o.call(t,a=>{const c=this.selfWrites.get(a);c&&Date.now()-c<1500||this.external.queue(a)})}async put(t,s,o){this.selfWrites.set(t,Date.now()),await this.fs.write(t,s,o===void 0?void 0:{base:o})}putNew(t){return Ej(this.fs,t,s=>this.selfWrites.set(s,Date.now()))}async readMap(t){return rm(t,await this.fs.read(`${cs(t)}/map.md`))}async writeMap(t,s){await this.put(`${cs(t.id)}/map.md`,Dj(t),s)}async listMaps(){const s=(await this.fs.list()).filter(o=>/^[^/]+\/map\.md$/.test(o)).map(o=>o.split("/")[0]);return Promise.all(s.map(async o=>{const a=await this.readMap(o);return{id:o,key:a.key,title:a.title}}))}async loadMap(t){const s=await this.fs.list(),o=await this.readMap(t),a=s.filter(u=>u.startsWith(`${t}/tickets/`)&&Oj(u)),c=await Promise.all(a.map(async u=>im(await this.fs.read(u))));return{map:o,tickets:c.sort((u,h)=>u.createdAt-h.createdAt)}}async createMap(t){const s=await Yp(this.fs),o=Rj(t.title,s),a={id:o,key:`#${s}`,title:t.title,mode:t.mode??ds,...t.verification?{verification:t.verification}:{},sections:t.sections,createdAt:Date.now(),updatedAt:Date.now()};return await this.writeMap(a),this.events.emit({kind:"map.created",mapId:o,at:Date.now()}),a}async editMap(t,s,o){const a=await this.fs.read(`${cs(t)}/map.md`);await this.writeMap({...s(rm(t,a)),updatedAt:Date.now()},a),this.events.emit(o)}setMapMode(t,s){return this.editMap(t,o=>({...o,mode:s}),{kind:"map.mode",mapId:t,mode:s,at:Date.now()})}setMapMeta(t,s){return this.editMap(t,o=>kj(o,s),{kind:"map.updated",mapId:t,at:Date.now()})}updateMapSections(t,s){const o=Object.keys(s)[0];return this.editMap(t,a=>({...a,sections:{...a.sections,...s}}),{kind:"map.updated",mapId:t,section:o,at:Date.now()})}async createTicket(t,s){const o=await this.putNew(()=>Aj(this.fs,t,s));return this.events.emit({kind:"ticket.created",mapId:t,ticketId:o.id,at:Date.now()}),o}async addBlocking(t,s,o){await this.update(t,o,a=>a.blockedBy.includes(s)?a:{...a,blockedBy:[...a.blockedBy,s]}),this.events.emit({kind:"edge.added",mapId:t,blockerId:s,blockedId:o,at:Date.now()})}async update(t,s,o){const a=await this.fs.read(this.ticketPath(t,s)),c=im(a),u=o(c);u!==c&&await this.put(this.ticketPath(t,c.id),tg({...u,updatedAt:Date.now()}),a)}async removeBlocking(t,s,o){await this.update(t,o,a=>wj(a,s)),this.events.emit({kind:"edge.removed",mapId:t,blockerId:s,blockedId:o,at:Date.now()})}async editTicket(t,s,o){await this.update(t,s,a=>xj(a,o)),this.events.emit({kind:"ticket.updated",mapId:t,ticketId:s,at:Date.now()})}async reopen(t,s){await this.update(t,s,jj),this.events.emit({kind:"ticket.updated",mapId:t,ticketId:s,at:Date.now()})}async assign(t,s,o){await this.update(t,s,a=>({...a,assignee:o??void 0})),this.events.emit(o?{kind:"ticket.claimed",mapId:t,ticketId:s,assignee:o,at:Date.now()}:{kind:"ticket.released",mapId:t,ticketId:s,at:Date.now()})}async comment(t,s,o,a){await this.update(t,s,c=>({...c,comments:[...c.comments,{id:`c${c.comments.length}`,author:o,body:a,createdAt:Date.now()}]})),this.events.emit({kind:"ticket.commented",mapId:t,ticketId:s,at:Date.now()})}async close(t,s,o){await this.update(t,s,a=>({...a,state:"closed",closeReason:o,closedAt:Date.now()})),this.events.emit({kind:"ticket.closed",mapId:t,ticketId:s,reason:o,at:Date.now()})}async setMeta(t,s,o){await this.update(t,s,a=>Sj(a,o)),this.events.emit({kind:"ticket.updated",mapId:t,ticketId:s,at:Date.now()})}async listDecisions(t){const o=(await this.fs.list()).filter(a=>a.startsWith(`${t}/decisions/`)).map(async a=>{const c=await this.fs.read(a).catch(h=>zj(a,h));if(!c)return;const u={...Bc(c),mapId:t};return this.external.knows(a)||this.external.remember(a,c,u.supersededBy),u});return(await Promise.all(o)).filter(a=>!!a)}async createDecision(t,s){const o=await this.putNew(async()=>{const a=await Ij(this.fs,t,s);return this.external.remember(a.path,a.text),a});return this.events.emit({kind:"decision.recorded",mapId:t,decisionId:o.id,ticketId:o.ticketId,at:Date.now()}),o}async markSuperseded(t,s,o){const a=`${cs(t)}/decisions/${cs(s)}.md`,c=await this.fs.read(a),u=Fp({...Bc(c),mapId:t,supersededBy:o});this.external.remember(a,u,o),await this.put(a,u,c),this.events.emit({kind:"decision.superseded",mapId:t,decisionId:s,supersededBy:o,at:Date.now()})}subscribe(t){return this.events.on(t)}}function hs(e,t=[]){if(e)try{const{protocol:s}=new URL(e);return["http:","https:",...t].includes(s)?e:void 0}catch{return}}class om extends Error{constructor(t,s,o,a){super(s),this.code=t,this.status=o,this.resetAt=a,this.name="TrackerError"}}const Fj={github:"GitHub Issues",linear:"Linear"};async function jt(e,t,s){let o;try{o=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:s===void 0?void 0:JSON.stringify(s)})}catch{throw new om("offline","Lookout server unreachable; is `teamtrail` still running?")}const a=await o.json().catch(()=>({}));if(!o.ok)throw new om(a.code??"http",a.error??`request failed (${o.status})`,o.status,a.resetAt);return a}class Uj{constructor(t,s,o=""){ce(this,"label");ce(this,"location");ce(this,"status",{state:"connecting",queued:0});ce(this,"events",new Vs);ce(this,"statusEvents",new Vs);ce(this,"source");ce(this,"listeners",0);ce(this,"openEvents",t=>new EventSource(`${this.base}${t}`));ce(this,"listMaps",()=>this.call("listMaps"));ce(this,"loadMap",t=>this.call("loadMap",t));ce(this,"createMap",t=>this.call("createMap",t));ce(this,"setMapMode",(t,s)=>this.call("setMapMode",t,s));ce(this,"setMapMeta",(t,s)=>this.call("setMapMeta",t,s));ce(this,"updateMapSections",(t,s)=>this.call("updateMapSections",t,s));ce(this,"createTicket",(t,s)=>this.call("createTicket",t,s));ce(this,"addBlocking",(t,s,o)=>this.call("addBlocking",t,s,o));ce(this,"removeBlocking",(t,s,o)=>this.call("removeBlocking",t,s,o));ce(this,"editTicket",(t,s,o)=>this.call("editTicket",t,s,o));ce(this,"reopen",(t,s)=>this.call("reopen",t,s));ce(this,"assign",(t,s,o)=>this.call("assign",t,s,o));ce(this,"comment",(t,s,o,a)=>this.call("comment",t,s,o,a));ce(this,"close",(t,s,o)=>this.call("close",t,s,o));ce(this,"setMeta",(t,s,o)=>this.call("setMeta",t,s,o));ce(this,"listDecisions",t=>this.call("listDecisions",t));ce(this,"createDecision",(t,s)=>this.call("createDecision",t,s));ce(this,"markSuperseded",(t,s,o)=>this.call("markSuperseded",t,s,o));this.kind=t,this.base=s,this.label=Fj[t],this.location=o}async call(t,...s){return(await jt(`${this.base}/tracker/${this.kind}/call`,"POST",{method:t,args:s})).result}open(){const t=this.openEvents(`/tracker/${this.kind}/events`);t.addEventListener("message",s=>this.events.emit(JSON.parse(s.data))),t.addEventListener("status",s=>{const o=JSON.parse(s.data);o.location&&(this.location=o.location),this.status=o,this.statusEvents.emit(o)}),t.addEventListener("error",()=>{this.status.state!=="offline"&&(this.status={...this.status,state:"offline",error:"Lookout server unreachable"},this.statusEvents.emit(this.status))}),this.source=t}subscribe(t){const s=this.events.on(t);return++this.listeners===1&&this.open(),()=>{var o;s(),--this.listeners===0&&((o=this.source)==null||o.close(),this.source=void 0)}}onStatus(t){return this.statusEvents.on(t)}}function Wj(e){return{get:()=>jt(`${e}/trackers`,"GET"),test:t=>jt(`${e}/trackers/test`,"POST",t),connect:t=>jt(`${e}/trackers`,"PUT",t),forget:t=>jt(`${e}/trackers/credentials/${t}`,"DELETE"),githubRepos:()=>jt(`${e}/trackers/github/repos`,"GET"),githubSignIn:{start:()=>jt(`${e}/trackers/github/sign-in/start`,"POST"),poll:()=>jt(`${e}/trackers/github/sign-in/poll`,"POST"),cancel:()=>jt(`${e}/trackers/github/sign-in/cancel`,"POST"),signOut:()=>jt(`${e}/trackers/github/sign-in`,"DELETE")},linearTeams:t=>t?jt(`${e}/trackers/linear/teams`,"POST",{apiKey:t}):jt(`${e}/trackers/linear/teams`,"GET"),linearProjects:(t,s)=>s?jt(`${e}/trackers/linear/projects`,"POST",{apiKey:s,teamId:t}):jt(`${e}/trackers/linear/projects?team=${encodeURIComponent(t)}`,"GET")}}const Hj=[{id:"markdown",name:"Local markdown",status:"available"},{id:"github",name:"GitHub Issues",status:"available"},{id:"linear",name:"Linear",status:"available"}],sg=[{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"}],Kj=sg[0],Vj="https://github.com/teamtrailhq/teamtrail-guides",Gj="https://raw.githubusercontent.com/teamtrailhq/teamtrail-guides/main",qj=`${Vj}/blob/main/CONTRIBUTING.md`,Qj=e=>e.slice(0,9),Yj=/[a-z][\w+.-]*:\/\/(?!(localhost|127\.0\.0\.1)(:\d+)?(\/|$|\s))/i,Jj=/^[\w.-]+@[\w.-]+:/,Xj=/^(@[\w.-]+\/)?[\w./-]+@[\w^~<>=*.-]+$/,Zj=/(^|=)(npm|jsr|github|gitlab|bitbucket|git\+[a-z]+|https?):/i,e0=/^--?(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,t0={tar:/^-[A-Za-z]*[IF]/,zip:/^-TT|^--unzip-command/,make:/^-E|^--eval/,perl:/^-[A-Za-z]*M/};function n0(e,t){var s;if(Yj.test(t)||Jj.test(t))return"names a remote address, so it reaches the network";if(Xj.test(t)&&!t.startsWith("-"))return`names a package to download (${t})`;if(Zj.test(t))return`names a package from a registry (${t})`;if(e0.test(t))return`runs a command it's given (${t.split("=")[0]})`;if((s=t0[e])!=null&&s.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(s0.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 s0=/\|\s*(sh|bash|zsh|dash|ksh|fish|pwsh|node|python\d*|perl|ruby)\b|\$\(|`|;|&&|\|\||\b(curl|wget)\s/;function i0(e,t){var s;if(e==="cargo")for(let o=0;o<t.length;o++){const a=t[o]==="--config"?t[o+1]:(s=/^--config=(.*)$/s.exec(t[o]))==null?void 0:s[1];if(a!==void 0&&!/^[\w./-]+\.toml$/.test(a))return"sets cargo configuration inline (--config)"}}function r0(e,t){const s=i0(e,t);if(s)return s;for(const o of t){const a=n0(e,o);if(a)return a}}const o0=/^(-c|-e|-E|-ex|-x|-r|-command|-Command|-EncodedCommand)$|^--(eval|exec|command|expr|execute|run)(=|$)/,a0=/(^|[\s|'"=])[a-z0-9-]+(\.[a-z0-9-]+)*\.[a-z]{2,}(:\d+)?\/\S*/i;function l0(e,t){const s=e.find(o=>{var a;return o0.test(o)&&!((a=t==null?void 0:t.exempt)!=null&&a.includes(o.split("=")[0]))});if(s)return`passes ${s.split("=")[0]}, which usually means "run this code"; point at a script in the repo`;if(!t&&e.some(o=>a0.test(o)))return"names an address, so it may reach the network"}const c0=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"]),u0=new Set(["-C","--git-dir","--work-tree","--namespace","--super-prefix"]);function d0(e){for(let t=0;t<e.length;t++){const s=e[t],o=s.split("=")[0];if(o==="-c"||o.startsWith("-c")||o==="--config-env"||o==="--exec-path")return`sets git's configuration or programs inline (${o})`;if(u0.has(o)){s.includes("=")||t++;continue}if(s.startsWith("-"))continue;const a=s.toLowerCase();return c0.has(a)||a.startsWith("remote-")?`runs git ${a}, which reaches a remote, runs commands or changes git's configuration`:a==="grep"&&e.slice(t+1).some(c=>/^-[A-Za-z]*O|^--open-files-in-pager/.test(c))?"runs git grep with a pager command (-O)":void 0}}const h0=["--require","--import","--loader","--experimental-loader","--env-file","--input-type"],am={inline:"ep",value:"rC",long:["--eval","--print"],longValue:h0},f0={node:am,nodejs:am,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 m0(e,t){const s=e.slice(1);for(let o=0;o<s.length;o++){if(t.inline.includes(s[o]))return"code";if(t.value.includes(s[o]))return o===s.length-1?"takes-next":"plain"}return"plain"}function p0(e,t){var a;if(/^data:|=data:/i.test(e))return"code";if(!e.startsWith("--"))return m0(e,t);const[s,o]=e.toLowerCase().split(/=(.*)/s,2);return t.long.includes(s)?"code":o===void 0&&((a=t.longValue)!=null&&a.includes(s))?"takes-next":"plain"}function g0(e,t){const s=f0[e];if(s)for(let o=0;o<t.length;o++){const a=t[o];if(a==="--"||!a.startsWith("-")||a===s.stop)return;const c=p0(a,s);if(c==="code")return"runs code given inline; point at a script in the repo instead";if(c==="takes-next"&&/^data:/i.test(t[o+1]??""))return"runs code given inline";c==="takes-next"&&o++}}const lm=e=>new RegExp(`^(?![-/~\\\\])(?!.*\\.\\.)(?![a-zA-Z]:)[\\w./-]+\\.(${e})$`),Pt={},ut=e=>e.split(/\s+/).filter(Boolean),v0={npm:{sub:ut("test t run run-script")},pnpm:{sub:ut("test t run")},yarn:{sub:ut("test run")},bun:{sub:ut("test run")},make:Pt,cargo:{sub:ut("test check clippy build fmt")},go:{sub:ut("test vet build")},deno:{sub:ut("test lint check")},node:{script:lm("[cm]?[jt]s"),sub:["--test"]},python:{script:lm("py"),modules:ut("pytest unittest mypy ruff black flake8 pylint"),exempt:["-c"]},pytest:{exempt:["-c"]},ruff:{sub:ut("check format")},mypy:Pt,pyright:Pt,black:{needs:["--check"]},flake8:Pt,pylint:Pt,tsc:Pt,eslint:{exempt:["-c"]},"pa11y-ci":Pt,prettier:{needs:ut("--check -c --list-different -l")},biome:{sub:ut("check lint ci")},jest:{exempt:["-c"]},vitest:Pt,mocha:Pt,playwright:{sub:["test"]},rubocop:Pt,rspec:{exempt:["-e"]},phpunit:Pt,phpstan:Pt,"golangci-lint":{sub:["run"]},swift:{sub:ut("test build")},dotnet:{sub:ut("test build")},mvn:{sub:ut("test verify compile")},gradle:{sub:ut("test check build")},gradlew:{sub:ut("test check build")},git:{sub:["diff"]}},k0=/^(\.\/)?node_modules\/\.bin\/([\w.-]+)$/;function y0(e,t){var o;const s=t[0]??"";return e.needs&&!t.some(a=>e.needs.includes(a))?!1:(o=e.script)!=null&&o.test(s)?!0:e.modules?s==="-m"&&e.modules.includes(t[1]??""):e.sub?e.sub.includes(s):!0}function ig(e){var o;const t=(o=k0.exec(e.argv0))==null?void 0:o[2],s=v0[t??e.program];return s&&y0(s,e.args)?s:void 0}const w0=e=>!!ig(e),aa=e=>new Set(e.split(/\s+/).filter(Boolean)),x0=aa(`
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
+ `),j0=aa(`
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
+ `),N0=aa("npx pnpx bunx uvx uv pipx docker podman nix nix-shell nix-env flatpak snap"),S0=aa(`
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
+ `),So=["exec","x","dlx","install","i","add","ci","create","init","update","upgrade"],b0={npm:new Set(So),pnpm:new Set(So),yarn:new Set(So),bun:new Set(So),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 C0(e){const t=(e.split(/[\\/]/).pop()??"").toLowerCase().replace(/\.(exe|cmd|bat|com)$/,"");return t.replace(new RegExp("(?<=[a-z])[\\d.-]+$"),"")||t}const $0=e=>{var t;return((t=e.find(s=>!s.startsWith("-")))==null?void 0:t.toLowerCase())??""};function cm(e){const t=e.findIndex(s=>s.startsWith("-m"));if(!(t<0))return e[t]==="-m"?e[t+1]:e[t].slice(2)}const T0=new Set(["pip","ensurepip","pipx","uv","venv","http.server","webbrowser"]);function E0(e,t){var o;if(x0.has(e))return`runs a shell (${e}); name the program and its arguments instead`;if(j0.has(e))return`runs ${e}, which reaches the network`;if(N0.has(e))return`runs ${e}, which downloads and runs a package; use one installed in the repo`;if(S0.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 s=$0(t);if((o=b0[e])!=null&&o.has(s))return`runs ${e} ${s}, which downloads packages; use one installed in the repo`;if(e==="python"&&T0.has(cm(t)??""))return`runs python -m ${cm(t)}, which downloads or serves`;if(e==="find"&&t.some(a=>/^-(exec|execdir|ok|okdir|delete)$/.test(a)))return"runs find with -exec or -delete, which runs or removes other things"}function rg(e){const t=e.run[0]??"";return{argv0:t,program:C0(t),args:e.run.slice(1)}}function A0(e){const{argv0:t,program:s,args:o}=rg(e),a=ig({argv0:t,program:s,args:o}),c=[E0(s,o),g0(s,o),s==="git"?d0(o):void 0,r0(s,o),l0(o,a)].filter(u=>!!u);return e.cwd&&(e.cwd.startsWith("/")||e.cwd.split(/[\\/]/).includes(".."))&&c.push("cwd must stay inside the repo"),c}const I0="unknown program: Teamtrail can't tell what this runs";function M0(e){if(A0(e).length)return;const{argv0:t,program:s,args:o}=rg(e);return w0({argv0:t,program:s,args:o})?void 0:I0}function R0(e,t={}){const s=(t.query??"").toLowerCase().split(/\s+/).filter(Boolean);return e.guides.filter(o=>{if(t.verifiedOnly&&!o.verified&&!o.builtin)return!1;const a=[o.id,o.name??"",o.summary,o.author].join(" ").toLowerCase();return s.every(c=>a.includes(c))})}const O0={ink:"#16302a",shellLight:"#f6f1e2",shell:"#eae3cf",shellShade:"#c8bea2",frame:"#b4aa8f",glass:"#14241f",scan:"#18302a",glow:"#6fbf8f",glowLight:"#b4e8c0",cup:"#b9562a",cupLight:"#d67a45",cupDark:"#8a3d1d",band:"#8f9690",hat:"#8a5a38",visor:"#6b4630",panel:"#e6dcc0",button:"#c8581e"},og={on:"#e2711d",dim:"#a8501c",alert:"#ff5a48"},L0={on:"#ffd166",dim:"#a8501c",alert:"#ff5a48"},Ue=([e,t,s,o],a,c=.35)=>`<rect x="${e}" y="${t}" width="${s}" height="${o}" rx="${c}" fill="${a}"/>`;function um(e,t,s){if(t==="closed")return Ue([e,17,3,1],s.glow);if(t==="wide")return Ue([e,15,3,3],s.glowLight)+Ue([e+1,16,1,1],s.glass,.2);const o=t==="aside"?e+1:e;return Ue([o,16,3,1.1],s.glow)+Ue([o,17,3,1],s.glowLight)}function P0(e,t){return e==="open"?Ue([13,20,6,1.1],t.glowLight)+Ue([15,21,2,1],t.glow):e==="mid"?Ue([14,20,4,1],t.glowLight):Ue(e==="aside"?[17,20,2,1]:[15,20,2,1],t.glow)}const _0=[13,15,17,19,21,23];function D0(e){return[_0.map(t=>Ue([9.2,t,13.6,1],e.scan,0)).join(""),Ue([10,13,2,1],e.frame,.2),Ue([10,14,1,1],e.frame,.2),Ue([10,25.2,1,1],e.button,.2),Ue([11.2,25.2,1,1],e.cupDark,.2),[17,19,21].map(t=>Ue([t,25.2,1,1.6],e.shellLight,.2)+Ue([t,25.2,1,.8],e.frame,.2)).join("")].join("")}function dm(e,t,s){return[`<rect x="${e}" y="15" width="5.4" height="11" rx="1.7" fill="${t.cup}" ${s}/>`,Ue([e+1,16,1.2,9],t.cupLight,.5),Ue([e+3.6,16,.9,9],t.cupDark,.4)].join("")}function z0(e,{lamp:t=og,simple:s=!1,colors:o=O0}={}){const a=o,c=s?"open":e.eyes,u=s?"rest":e.mouth,h=`stroke="${a.ink}" stroke-width=".9" stroke-linejoin="round"`;return['<g transform="scale(6.25)">',`<path d="M3 16.5Q3 6 16 5.5Q29 6 29 16.5" fill="none" stroke="${a.ink}" stroke-width="3"/>`,`<path d="M3 16.5Q3 6 16 5.5Q29 6 29 16.5" fill="none" stroke="${a.band}" stroke-width="1.5"/>`,dm(.6,a,h),dm(26,a,h),`<path d="M8 9H24Q26 9 26 11V25L23.5 28.5H8.5L6 25V11Q6 9 8 9Z" fill="${a.shell}" ${h}/>`,`<path d="M6.5 25H25.5L23.3 28H8.7Z" fill="${a.shellShade}"/>`,Ue([6.6,10,1.6,15],a.shellLight,.6),Ue([8.4,11,15.2,13.6],a.frame,1.3),Ue([9,11.6,14,12.4],a.glass,1),s?"":D0(a),um(11,c,a),um(18,c,a),P0(u,a),`<path d="M6.5 10.5Q5.8 3.5 16 3.100Q26.2 3.5 25.5 10.5Z" fill="${a.hat}" ${h}/>`,`<path d="M10.5 9.5Q10.3 4.9 16 4.5Q21.7 4.9 21.5 9.5Z" fill="${a.panel}" stroke="${a.ink}" stroke-width=".5"/>`,s?"":`<path d="M16 5.400l1.2 1.7h-.6l1 1.5h-3.2l1-1.5h-.6z" fill="${a.hat}"/>`,`<path d="M6.3 9.8Q16 7.9 25.7 9.8Q27.2 12 25 12.600Q16 10.9 7 12.600Q4.8 12 6.3 9.8Z" fill="${a.visor}" ${h}/>`,`<circle cx="16" cy="2.600" r="1.3" fill="${t[e.light??"on"]}" stroke="${a.ink}" stroke-width=".7"/>`,"</g>"].join("")}const ag={crt:{id:"crt",name:"Day",blurb:"The original CRT head with ear cups and a baseball cap.",lamp:og,wave:{bar:"#6f8a78",lead:"#c8581e"}},night:{id:"night",name:"Night",blurb:"The same Scout, with the cap lamp burning bright, for the night theme.",lamp:L0,wave:{bar:"#66828d",lead:"#e8833a"}}},B0="crt",F0={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"}},U0={idle:"WATCHING",speaking:"TALKING",alert:"NEEDS YOU",thinking:"THINKING"},jn={msPerChar:55,mouthHoldMs:110,blinkEveryMs:5600,blinkMs:140,thinkingStepMs:520};function W0(e){return e?/[aeiouy]/i.test(e)?"open":/[a-z0-9]/i.test(e)?"mid":"rest":"rest"}function H0(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 K0(e,t,s){return Array.from({length:s},(o,a)=>{const c=t-(s-1-a);return c>=0&&c<e.length?H0(e[c],c):0})}function lg({face:e={eyes:"open",mouth:"rest"},variant:t="crt",size:s,simple:o,className:a}){const{eyes:c,mouth:u,light:h}=e,m=y.useMemo(()=>z0({eyes:c,mouth:u,light:h},{lamp:ag[t].lamp,simple:o??s<28}),[c,u,h,t,o,s]);return i.jsx("svg",{className:a,width:s,height:s,viewBox:"0 0 200 200","aria-hidden":"true",dangerouslySetInnerHTML:{__html:m}})}function V0(e){const[t,s]=y.useState(!1);return y.useEffect(()=>{if(!e){s(!1);return}let o;const a=setInterval(()=>{s(!0),o=setTimeout(()=>s(!1),jn.blinkMs)},jn.blinkEveryMs);return()=>{clearInterval(a),o&&clearTimeout(o)}},[e]),t}const G0={xs:.8,sm:2,md:4,lg:6},q0=40,hm=20,fm="(prefers-reduced-motion: reduce)",Q0=40,Y0=350;function J0(e,t){var h;const s=e.size??"md",o=e.state??"idle",a=((h=e.speaking)==null?void 0:h.trim())??"",c=a&&(o==="idle"||o==="speaking")?"speaking":o,u=s==="xs";return{size:s,text:a,effective:c,talking:c==="speaking"&&a.length>0,mini:u,framed:e.framed??!u,reduced:t||u}}const X0=e=>e.length*jn.msPerChar,Z0=(e,t)=>t&&(e.effective==="idle"||e.effective==="speaking"||e.effective==="alert");function eN(e,t,s,o){const a=F0[e.effective],c=s?"closed":a.eyes;let u=a.mouth,h=e.text.length-1;if(o)if(e.reduced)u="open";else{h=Math.min(e.text.length-1,Math.floor(t/jn.msPerChar));const p=Math.floor(t/jn.mouthHoldMs)*Math.round(jn.mouthHoldMs/jn.msPerChar);u=W0(e.text[Math.min(e.text.length-1,p)])}let m=a.light;return e.effective==="thinking"&&!e.reduced&&Math.floor(t/jn.thinkingStepMs)%2===1&&(m="on"),{eyes:c,mouth:u,light:m,cursor:h}}function tN(e,t){const s=typeof e.size=="number"?e.size:G0[e.size],o=e.reduced?Math.min(e.text.length-1,hm-1):t;return{base:s,px:q0*s,bars:hm,waveCursor:o}}function nN(e,{label:t,speechDone:s,cursor:o,caption:a}){const c=e.talking&&s?"idle":e.effective,u=U0[c],h=e.size==="md"||e.size==="lg"||typeof e.size=="number"&&e.size>=4;return{shownState:c,status:u,ariaLabel:`${t}, ${u.toLowerCase()}`,showCaption:a??h,shown:sN(e,s,o)}}function sN(e,t,s){return e.talking?e.reduced||t?e.text:e.text.slice(0,s+1):""}function iN(){const[e,t]=y.useState(()=>{var s;return typeof window<"u"&&!!((s=window.matchMedia)!=null&&s.call(window,fm).matches)});return y.useEffect(()=>{var a;const s=(a=window.matchMedia)==null?void 0:a.call(window,fm);if(!s)return;const o=()=>t(s.matches);return o(),s.addEventListener("change",o),()=>s.removeEventListener("change",o)},[]),e}function rN(e,t,s){const[o,a]=y.useState(0);return y.useEffect(()=>{if(a(0),!t)return;const c=performance.now(),u=setInterval(()=>a(performance.now()-c),s);return()=>clearInterval(u)},[e,t,s]),o}function oN(e){const{key:t,talking:s,at:o}=e,a=o!==void 0,c=X0(e.text),[u,h]=y.useState(""),m=y.useRef(e.onSpeakEnd);m.current=e.onSpeakEnd,y.useEffect(()=>{if(!s||a)return;const N=setTimeout(()=>{var S;h(t),(S=m.current)==null||S.call(m)},c+Y0);return()=>clearTimeout(N)},[s,t,c,a]);const p=s&&u!==t,v=rN(t,e.animate&&(p||e.thinking),p?Q0:jn.thinkingStepMs),k=o??v,x=s&&(a?k>=c:u===t);return{t:k,speechDone:x}}const aN=e=>e*2,Hc=3.5;function lN(e,t,s){return(e??[]).map((o,a)=>{const c=(1+2*o)*.5;return{x:a*2,y:(Hc-c)/2,width:1,height:c,fill:a>=t-2&&o>0?s.lead:s.bar}})}function cN({heights:e,bars:t,unit:s,colors:o}){const a=aN(t);return i.jsx("svg",{className:`scout-wave${e?" on":""}`,width:a*s,height:Hc*s,viewBox:`0 0 ${a} ${Hc}`,"aria-hidden":"true",children:lN(e,t,o).map((c,u)=>i.jsx("rect",{...c},u))})}function la({state:e="idle",size:t="md",speaking:s,variant:o=B0,framed:a,caption:c,label:u="Scout",onSpeakEnd:h,at:m,className:p,style:v}){const k=J0({state:e,size:t,speaking:s,framed:a},iN()),{text:x,effective:N,talking:S,reduced:j}=k,A=ag[o],R=!j&&!(m!==void 0),L=`${N}|${o}|${x}`,{t:U,speechDone:Z}=oN({key:L,text:x,talking:S,thinking:N==="thinking",animate:R,at:m,onSpeakEnd:h}),Q=V0(Z0(k,R)),W=S&&!Z,{eyes:ie,mouth:G,light:ve,cursor:Le}=eN(k,U,Q,W),{base:$e,px:oe,bars:D,waveCursor:X}=tN(k,Le),le=y.useMemo(()=>W?K0(x,X,D):null,[W,x,X,D]),{shownState:te,status:K,ariaLabel:Y,showCaption:B,shown:T}=nN(k,{label:u,speechDone:Z,cursor:Le,caption:c}),_={...v,"--scout-u":`${$e}px`},ue=i.jsx("span",{className:"scout-sprite",children:i.jsx(lg,{face:{eyes:ie,mouth:G,light:ve},variant:o,size:oe,simple:k.mini})});return k.framed?i.jsxs("figure",{className:`scout scout-panel scout-${te} scout-v-${o} ${p??""}`,style:_,"data-state":te,children:[i.jsxs("figcaption",{className:"scout-head",children:[i.jsx("span",{className:"scout-name",children:u}),i.jsx("span",{className:"scout-sep",children:"//"}),i.jsx("span",{className:"scout-status",children:K})]}),i.jsxs("div",{className:"scout-feed",role:"img","aria-label":Y,children:[ue,i.jsx(cN,{heights:le,bars:D,unit:$e,colors:A.wave})]}),B&&i.jsxs("p",{className:"scout-caption","aria-hidden":"true",children:[T,S&&!Z&&!j&&i.jsx("span",{className:"scout-caret",children:"_"})]}),x&&i.jsx("span",{className:"scout-sr","aria-live":"polite",children:x})]}):i.jsx("span",{className:`scout scout-bare scout-${te} ${p??""}`,style:_,role:"img","aria-label":Y,children:ue})}const Nt="trail lead";function uN({rt:e,guard:t,setMapId:s,mapIdRef:o,snapRef:a,setChatSession:c,setSelection:u}){const h={actorKind:"trail lead",journal:e.journal};return{selectMap:m=>s(m),openChat:m=>c(m),answer:(m,p)=>e.activity.answer(m,p,Nt,{via:"lookout"}),claim:m=>t("Claim",()=>Gf(e.adapter,o.current,m,{...h,assignee:Nt})),release:m=>t("Release claim",()=>Fw(e.adapter,o.current,m,{...h,actor:Nt})),releaseLease:m=>t("Release to queue",()=>e.leases.release(o.current,m,Nt)),resolve:(m,p,v={})=>t("Resolve · record answer",async()=>{var x;const k=(x=a.current)==null?void 0:x.tickets.find(N=>N.id===m);k&&!k.assignee&&await Gf(e.adapter,o.current,m,{...h,assignee:Nt}),await Qw(e.adapter,o.current,m,{...h,answer:p,author:Nt,decision:{...v,source:{kind:"lookout",label:"Ticket inspector"}}})}),supersede:(m,p)=>t(`Supersede ${m.id}`,async()=>{let v=m.id;if(m.derived){const{id:k,mapId:x,derived:N,supersededBy:S,...j}=m;v=(await hu(e.adapter,m.mapId,j,{appendToTrail:!1})).id}await Uw(e.adapter,m.mapId,v,{...p,decidedBy:Nt,participants:[{id:Nt}],source:{kind:"lookout",label:"Logbook"}})}),graduate:({unspecified:m,...p})=>t(`Promote to ticket · ${m}`,async()=>{const v=await Yw(e.adapter,o.current,m,p);u({kind:"ticket",id:v.id})}),ruleOut:(m,p)=>t("Rule out of scope",async()=>{await Jw(e.adapter,o.current,m,{...h,reason:p,author:Nt,source:{kind:"lookout",label:"Ticket inspector"}}),u(null)}),setMode:m=>t(`Trail mode · ${m}`,()=>Ww(e.adapter,o.current,m)),setModelMatching:m=>t(`Model matching · ${m.enabled?"on":"off"}`,()=>Xw(e.adapter,o.current,m))}}const Ge=(...e)=>e.filter(Boolean).join(" "),Gs="item",dN=/^[0-9a-f]{6,64}$/;function ca(){const e=new URLSearchParams(location.search).get("project")??void 0;return e&&dN.test(e)?e:void 0}function je(e=ca()){return e?`${J.apiPrefix}/p/${e}`:J.apiPrefix}function hN(e){const t=new URLSearchParams(location.search);for(const o of["projects","project","tracker",Gs])t.delete(o);e.item&&t.set(Gs,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 s=t.toString();return`${location.pathname}${s?`?${s}`:""}`}async function fN(e,t){var c;const s=(t.assumptions??[]).map((u,h)=>({id:`S-${h+1}`,text:u,status:"holding",tickets:[]})),{map:o,tickets:a}=await Aw(e,{title:t.title,sections:{destination:t.destination,notes:t.notes,decisions:[],unspecified:[],outOfScope:[],...s.length?{assumptions:s}:{}},tickets:[{ref:"discovery",...Yx}]});return await fetch(`${je()}/briefs/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:o.id,ticketId:(c=a[0])==null?void 0:c.id})}),o}function cg(e,t){const s=URL.createObjectURL(new Blob([t],{type:"text/markdown;charset=utf-8"}));Object.assign(document.createElement("a"),{href:s,download:e}).click(),setTimeout(()=>URL.revokeObjectURL(s),1e3)}function hn(e){const t=Math.max(0,Math.floor(e/1e3));return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:`${Math.floor(t/3600)}h`}function ug(e){const t=Math.max(0,Math.floor(e/1e3)),s=o=>String(o).padStart(2,"0");return`${s(Math.floor(t/3600))}:${s(Math.floor(t%3600/60))}:${s(t%60)}`}const ua=e=>new Date(e).toTimeString().slice(0,8);function Yt(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 da(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}const qs=e=>`$${e<10?e.toFixed(2):e.toFixed(1)}`,Qs=e=>new Date(e).toISOString().slice(0,10),vu=e=>new Date(e).toTimeString().slice(0,5),mN=e=>`${Qs(e)} ${vu(e)}`,dg=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`},ar=e=>e?new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",tr={research:"Research",prototype:"Prototype",junction:"Junction",task:"Task",execute:"Execute",review:"Review"},hg={decided:"Done",claimed:"Working",frontier:"Ready",blocked:"Backlog",parked:"Parked (plan-only)","out-of-scope":"Cancelled",verifying:"Verifying",rework:"Rework",held:"Blocked"},pN={decided:"done",claimed:"working",frontier:"ready",blocked:"backlog",parked:"parked","out-of-scope":"cancelled",verifying:"verifying",rework:"rework",held:"blocked"};function ku(e,t){return new Map((e??[]).filter(s=>s.mapId===t&&!s.returned).map(s=>[s.ticketId,s]))}function ei(){let e=0,t=0;return{start(){const s=++e;return()=>s<=t?!1:(t=s,!0)},pushed(){t=++e}}}const gN=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),rn=(e,t)=>e>>>t|e<<32-t;function vN(e){const t=Math.ceil((e.length+9)/64)*64,s=new Uint8Array(t);s.set(e),s[e.length]=128;const o=new DataView(s.buffer);return o.setUint32(t-8,Math.floor(e.length*8/2**32)),o.setUint32(t-4,e.length*8>>>0),s}function kN(e,t,s,o){for(let x=0;x<16;x++)o[x]=t.getUint32(s+x*4);for(let x=16;x<64;x++){const N=rn(o[x-15],7)^rn(o[x-15],18)^o[x-15]>>>3,S=rn(o[x-2],17)^rn(o[x-2],19)^o[x-2]>>>10;o[x]=o[x-16]+N+o[x-7]+S>>>0}let[a,c,u,h,m,p,v,k]=e;for(let x=0;x<64;x++){const N=k+(rn(m,6)^rn(m,11)^rn(m,25))+(m&p^~m&v)+gN[x]+o[x]>>>0,S=(rn(a,2)^rn(a,13)^rn(a,22))+(a&c^a&u^c&u)>>>0;[k,v,p,m,h,u,c,a]=[v,p,m,h+N>>>0,u,c,a,N+S>>>0]}[a,c,u,h,m,p,v,k].forEach((x,N)=>e[N]=e[N]+x>>>0)}function xc(e){const t=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),s=vN(e),o=new DataView(s.buffer),a=new Uint32Array(64);for(let h=0;h<s.length;h+=64)kN(t,o,h,a);const c=new Uint8Array(32),u=new DataView(c.buffer);return t.forEach((h,m)=>u.setUint32(m*4,h)),c}function yN(e,t){const s=new Uint8Array(64);s.set(e.length>64?xc(e):e);const o=new Uint8Array(64+t.length),a=new Uint8Array(96);for(let c=0;c<64;c++)o[c]=s[c]^54,a[c]=s[c]^92;return o.set(t,64),a.set(xc(o),64),xc(a)}const fg=e=>Array.from(e,t=>t.toString(16).padStart(2,"0")).join(""),wN=e=>new Uint8Array((e.match(/../g)??[]).map(t=>parseInt(t,16))),yu=`${J.slug}.session`;let _o;const xN=e=>{const t=e;return!!t&&typeof t.id=="string"&&typeof t.secret=="string"&&typeof t.verifier=="string"};function wu(){try{const e=JSON.parse(localStorage.getItem(yu)??"null");return xN(e)?e:_o}catch{return _o}}function jN(e){_o=e;try{localStorage.setItem(yu,JSON.stringify(e))}catch{}}function mg(){_o=void 0;try{localStorage.removeItem(yu)}catch{}}let xu="unproven",jc;const Kc=new Set,pg=e=>{xu=e;for(const t of Kc)t(e)};function NN(e){return Kc.add(e),()=>void Kc.delete(e)}const SN=()=>xu==="proven",bN=()=>xu==="proven"&&pg("unproven");function CN(){const e=new Uint8Array(16);return crypto.getRandomValues(e),fg(e)}async function $N(){const e=wu();if(!e)return"unknown";const t=CN(),s=await fetch(`${J.apiPrefix}/session/prove`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e.id,nonce:t})}).catch(()=>{});if((s==null?void 0:s.status)===404)return mg(),"unknown";const o=s!=null&&s.ok?(await s.json().catch(()=>({}))).proof:void 0,a=fg(yN(wN(e.verifier),new TextEncoder().encode(`${t}
134
+ ${location.origin}`)));return o===a?"proven":"failed"}function ha(){return jc??(jc=$N().then(e=>(jc=void 0,pg(e),e))),jc}const TN=1e4;class gg{constructor(t=je(),s="/events"){ce(this,"inner");ce(this,"listeners",[]);ce(this,"closed",!1);ce(this,"retryMs",1e3);this.base=t,this.path=s,this.connect()}addEventListener(t,s){var o;this.listeners.push([t,s]),(o=this.inner)==null||o.addEventListener(t,s)}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(await ha()!=="proven")return this.failed();const t=await fetch(`${J.apiPrefix}/sign-in/stream`,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"}).then(o=>o.ok?o.json():void 0).then(o=>o==null?void 0:o.ticket).catch(()=>{});if(this.closed)return;if(!t)return this.failed();const s=new EventSource(`${this.base}${this.path}?ticket=${encodeURIComponent(t)}`);this.inner=s;for(const[o,a]of this.listeners)s.addEventListener(o,a);s.addEventListener("open",()=>this.retryMs=1e3),s.addEventListener("error",()=>{s.close(),bN(),this.retry()})}failed(){for(const[t,s]of this.listeners)t==="error"&&s(new Event("error"));this.retry()}retry(){this.closed||(setTimeout(()=>void this.connect(),this.retryMs),this.retryMs=Math.min(this.retryMs*2,TN))}}function EN(){ha().then(e=>e==="unknown"&&location.reload())}let Dt;const Do=new Set,nr=new Map,zo=new Set,Bo=new Set;function vg(e){Dt==null||Dt.addEventListener(e,t=>{for(const s of nr.get(e)??[])s(t.data)})}function fa(){if(!Dt){Dt=new gg,Dt.onerror=()=>{for(const e of Bo)e();EN()},Dt.addEventListener("open",()=>{for(const e of zo)e()}),Dt.onmessage=e=>{const t=JSON.parse(e.data).path;if(typeof t=="string")for(const s of Do)s(t)};for(const e of nr.keys())vg(e)}}function ma(){const e=[...nr.values()].some(t=>t.size>0);Do.size||e||zo.size||Bo.size||(Dt==null||Dt.close(),Dt=void 0)}function ju(e){return Do.add(e),fa(),()=>{Do.delete(e),ma()}}function ti(e,t){let s=nr.get(e);return s||(s=new Set,nr.set(e,s),vg(e)),s.add(t),fa(),()=>{s.delete(t),ma()}}function fs(e){return zo.add(e),fa(),()=>{zo.delete(e),ma()}}function AN(e){return Bo.add(e),fa(),()=>{Bo.delete(e),ma()}}const Nu=(e,t)=>`${e}/${t}`;let Qt={reached:!1,live:!1,tickets:{}},Vc=!1;const Gc=new Set,qc=new Set,IN=ei();let Qc=0;const kg=new Map;let yg=0;function Fo(e){Qt=e;for(const t of Gc)t()}function MN(e,t){const s=Object.fromEntries(e.map(o=>[Nu(o.mapId,o.ticketId),o]));for(const[o,a]of kg)a>t&&Qt.tickets[o]&&(s[o]=Qt.tickets[o]);return s}function mm(){const e=IN.start(),t=Qc;fetch(`${je()}/verification/sync`).then(s=>s.ok?s.json():Promise.reject()).then(s=>e()&&Fo({reached:!0,live:!0,status:yg>t?Qt.status:s.status,tickets:MN(s.tickets,t)}),()=>Qt.reached&&Fo({...Qt,live:!1}))}function RN(e){const t=JSON.parse(e);if(t.kind==="evidence")for(const a of qc)a();if(t.kind!=="sync")return;const s=t;yg=++Qc;const o={...Qt.tickets};for(const a of s.tickets){const c=Nu(a.mapId,a.ticketId);o[c]=a,kg.set(c,Qc)}Fo({reached:!0,live:!0,status:s.status,tickets:o})}function pm(){Vc=!0,ti("verification",RN),AN(()=>Qt.reached&&Qt.live&&Fo({...Qt,live:!1})),fs(mm),mm()}const Ys={subscribe(e){return Vc||pm(),Gc.add(e),()=>void Gc.delete(e)},get:()=>Qt,onEvidence(e){return Vc||pm(),qc.add(e),()=>void qc.delete(e)},ticket:(e,t,s)=>e.tickets[Nu(t,s)]};function ON(e){if(e!=null&&e.flags.length)return e.flags.some(t=>t.severity==="alert")?"alert":"warn"}const gm={onboarded:!1,tracker:"markdown",hitlTranscript:"summary",agent:Kj.id,github:{repo:""},linear:{team:""},briefing:{enabled:!0,awayMinutes:15},theme:"night"};function Su(){try{const e={...gm,...JSON.parse(localStorage.getItem(Jo)??"{}")};return["markdown","github","linear"].includes(e.tracker)||(e.tracker="markdown"),e}catch{return gm}}function wg(e){e==="auto"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e}const Nc=new Map,Sc=e=>`${je()}/file?path=${encodeURIComponent(e)}`;async function bc(e,t){const s=await e.json().catch(()=>({})),o=new Error(s.error??`${t}: ${e.status}`);return e.status===409?Object.assign(o,{stale:!0}):e.status===404?Object.assign(o,{code:"ENOENT"}):o}const LN={async list(){return(await(await fetch(`${je()}/list`)).json()).files},async read(e){const t=await fetch(Sc(e));if(!t.ok)throw await bc(t,`read ${e}`);const s=await t.text(),o=t.headers.get("ETag");return o&&Nc.set(e,{text:s,etag:o}),s},async write(e,t,s){const o=(s==null?void 0:s.base)===void 0?void 0:Nc.get(e),a=o&&o.text===(s==null?void 0:s.base)?{"If-Match":o.etag}:{},c=await fetch(Sc(e),{method:"PUT",body:t,headers:a});if(!c.ok)throw await bc(c,`write ${e}`);Nc.delete(e)},async create(e,t){const s=await fetch(Sc(e),{method:"PUT",body:t,headers:{"If-None-Match":"*"}});if(s.status===412)return!1;if(!s.ok)throw await bc(s,`create ${e}`);return!0},watch(e){return ju(e)}},PN=15*6e4;class _N{constructor(t){ce(this,"leases",[]);ce(this,"changes",new Vs);ce(this,"logged",new Set);ce(this,"since",Date.now()-PN);this.activity=t}subscribe(t){return this.changes.on(t)}set(t){var s;this.leases=t;for(const o of t){const a=`${o.mapId}/${o.ticketId}/${(s=o.returned)==null?void 0:s.at}`;!o.returned||o.returned.at<this.since||this.logged.has(a)||(this.logged.add(a),this.activity.push({source:"system",level:"warn",ticketId:o.ticketId,text:dj(o)}))}this.changes.emit(t)}async release(t,s,o){const a=await fetch(`${je()}/agents/leases/release`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,ticketId:s,by:o})});if(!a.ok)throw new Error((await a.json().catch(()=>({}))).error??`HTTP ${a.status}`)}}function DN(e){e.remoteAnswer=(t,s,o)=>{fetch(`${je()}/agents/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:t.sessionId,questionId:t.id,text:s,author:o})}).then(async a=>{if(!a.ok)throw new Error((await a.json().catch(()=>({}))).error??`HTTP ${a.status}`)}).catch(a=>e.push({source:"system",level:"alert",sessionId:t.sessionId,text:`Answer not delivered to ${t.agent} · ${a.message}`}))}}function zN(e){const t=ei(),s=()=>{const o=t.start();fetch(`${je()}/agents/leases`).then(a=>a.ok?a.json():{leases:[]}).then(({leases:a})=>o()&&e.set(a)).catch(()=>{})};ti("leases",o=>{t.pushed(),e.set(JSON.parse(o).leases)}),fs(s),s()}function BN(e){let t=0;const s=new Map,o=()=>{const a=t;fetch(`${je()}/agents`).then(c=>c.ok?c.json():{sessions:[]}).then(({sessions:c})=>[...c].reverse().filter(u=>(s.get(u.session.id)??0)<=a).forEach(u=>e.syncRemote(u))).catch(()=>{})};ti("agent",a=>{const c=JSON.parse(a);s.set(c.session.id,++t),e.syncRemote(c)}),fs(o),o()}function vm(e,t){DN(e),zN(t),BN(e)}function km(e){const t=s=>`${Jo}:${e}:${s}`;return{get:s=>localStorage.getItem(t(s)),set:(s,o)=>{try{localStorage.setItem(t(s),o)}catch{}}}}const FN=["markdown","github","linear"];function UN(){const e=new URLSearchParams(location.search).get("tracker");return e&&FN.includes(e)?e:Su().tracker}function WN(e){let t,s;const o=new lx,a=new _N(o),c={},u=tx(je());if(e==="github"||e==="linear"){const p=new Uj(e,je());p.openEvents=v=>new gg(je(),v),t=p,s=fetch(`${je()}/trackers`).then(v=>v.json()).catch(()=>{}).then(v=>{p.location=(e==="github"?v==null?void 0:v.github.repo:[v==null?void 0:v.linear.teamKey,v==null?void 0:v.linear.projectName].filter(Boolean).join(" · "))||p.location;const k=km(`${e}:${p.location}`);c.presence=new Yf(k),o.ledger=new Jf(k),vm(o,a)})}else t=new Bj(LN,`./${J.dataDir}`),s=fetch(`${je()}/list`).then(p=>p.json()).catch(()=>({root:"default"})).then(({root:p})=>{const v=km(p);c.presence=new Yf(v),o.ledger=new Jf(v),vm(o,a)});const h=hx(t),m=h.adapter;return{kind:e,ready:s,get presence(){return c.presence},adapter:m,journal:u,monitor:h,activity:o,leases:a}}const dn=e=>e.status==="running",xg=e=>dn(e)&&!!e.waitingOn,HN={blocking:0,soon:1,fyi:2};function KN(e,t,s){const o=e.filter(u=>u.sessionId===t),a=o.find(u=>u.id===s);if(a)return a;const c=u=>HN[u.urgency??"soon"];return[...o].sort((u,h)=>c(u)-c(h)||u.at-h.at)[0]}function Uo(e,t=Date.now()){const s=Math.floor(Math.max(0,t-e)/6e4);if(s<1)return"just now";if(s<60)return`${s} min ago`;const o=Math.floor(s/60);if(o<24)return`${o} h ago`;const a=Math.floor(o/24);return a<30?a===1?"yesterday":`${a} days ago`:`on ${new Date(e).toISOString().slice(0,10)}`}function us({n:e,urgent:t,pop:s,hideZero:o}){return i.jsx("span",{className:Ge("badge",t&&"urgent",s&&t&&"pop",o&&!e&&"zero"),children:o&&!e?"":e})}function P({variant:e="default",size:t="md",on:s,className:o,type:a,...c}){return i.jsx("button",{type:a??"button",className:Ge("btn",e!=="default"&&e,t==="sm"&&"sm",s&&"on",o),...c})}function Bt({as:e="div",tone:t,on:s,className:o,children:a,...c}){return i.jsx(e,{className:Ge("card",t,s&&"on",o),...c,children:a})}function pa({what:e,onReviewAgain:t}){return i.jsxs("div",{className:"changed-notice edge-note edge-attention",children:[i.jsxs("p",{className:"t-meta",children:[e," changed since you opened it: read it again before you approve it."]}),i.jsx(P,{size:"sm",onClick:t,children:"Review again"})]})}function mt({on:e,title:t,sub:s,disabled:o,onClick:a}){return i.jsxs(Bt,{as:"button",type:"button",className:"choice",on:e,disabled:o,onClick:a,children:[i.jsx("b",{className:"choice-title t-row-title",children:t}),s&&i.jsx("span",{className:"c-sub",children:s})]})}function Ae({children:e}){return i.jsx("div",{className:"empty",children:e})}function qn({title:e,hint:t,art:s}){return i.jsxs("div",{className:s?"empty-state has-art":"empty-state",children:[s,i.jsxs("div",{className:"es-words",children:[i.jsx("span",{className:"es-title",children:e}),t&&i.jsx("span",{className:"es-hint",children:t})]})]})}function Ze({label:e,children:t,className:s}){return i.jsxs("label",{className:Ge("field",s),children:[e,t]})}const ga=y.forwardRef(function({value:t,onValueChange:s,onSubmit:o,action:a="Send",actionDisabled:c,className:u,...h},m){return i.jsxs("form",{className:Ge("input-row",u),onSubmit:p=>{p.preventDefault(),o(t)},children:[i.jsx("textarea",{ref:m,rows:1,value:t,onChange:p=>s(p.target.value),onKeyDown:p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),o(t))},...h}),i.jsx(P,{type:"submit",variant:"primary",disabled:c??(h.disabled||!t.trim()),children:a})]})});function ni({text:e}){return i.jsx("span",{className:"info-tip","data-tip":e,"data-tip-scout":!0,tabIndex:0,role:"img","aria-label":e,children:i.jsxs("svg",{viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":"true",children:[i.jsx("circle",{cx:"7",cy:"3.7",r:"1.3"}),i.jsx("path",{d:"M5.6 6.300H8v4.200h1v1.200H5v-1.200h1.200V7.500h-.6z"})]})})}function Ve({as:e="span",variant:t="chip",hot:s,size:o,className:a,children:c,title:u}){return i.jsx(e,{className:Ge(t==="chip"?"chip-label":"mono-label",s&&"hot",o==="sm"&&(t==="chip"?"sm":"xs"),a),title:u,children:c})}const VN=e=>typeof e=="string"?{text:e}:e,GN=e=>Ge(e.code&&"t-code",e.strong&&"strong",e.urgent&&"urgent",e.className);function V(e){const t=e.parts.filter(s=>!!s&&(typeof s=="string"||!!s.text)).map(VN);return!t.length&&!e.children?null:i.jsxs("span",{className:Ge("meta-line t-meta",e.className),children:[t.map((s,o)=>i.jsxs("span",{children:[o>0&&i.jsx("span",{className:"sep",children:" · "}),i.jsx("span",{className:GN(s)||void 0,title:s.tip,children:s.text})]},o)),e.children]})}function bu(e){return i.jsxs("div",{className:"ds-load-failed",role:"alert",children:[i.jsx(V,{parts:[e.what,e.reason]}),i.jsx(P,{size:"sm",variant:"ghost",onClick:e.onRetry,children:"Retry"})]})}function si(e){const t=Array.from({length:e.rows??0},(s,o)=>o);return i.jsxs("div",{className:Ge("ds-loading",e.className),role:"status","aria-live":"polite",children:[i.jsxs("span",{className:"ds-loading-line t-meta",children:[i.jsx("span",{className:"ds-spinner","aria-hidden":"true"}),e.label]}),t.length>0&&i.jsx("ul",{className:"ds-skeleton-list","aria-hidden":"true",children:t.map(s=>i.jsxs("li",{className:"ds-skeleton-row",children:[i.jsx("span",{className:"ds-skeleton-bar title"}),i.jsx("span",{className:"ds-skeleton-bar meta"})]},s))})]})}const qN="M25.53 10.5 A11 11 0 1 1 16 5",QN="M20 5 L14.6 1.6 L14.6 8.4 Z";function ii({variant:e="mark",state:t="ok",size:s=20,className:o="",title:a}){const c=s<=14?3:2.4;return i.jsxs("svg",{className:`scout-mark mm-${e} mm-${t} ${o}`,viewBox:"0 0 32 32",width:s,height:s,role:a?"img":void 0,"aria-label":a,"aria-hidden":a?void 0:!0,children:[e==="status"||e==="alert"?i.jsx("circle",{cx:"16",cy:"16",r:"11",fill:"none",stroke:"currentColor",strokeWidth:c,strokeDasharray:t==="syncing"?"5 3.6":void 0}):i.jsx("path",{d:qN,fill:"none",stroke:"currentColor",strokeWidth:c,strokeLinecap:"butt"}),(e==="mark"||e==="action")&&i.jsx("path",{d:QN,fill:"currentColor"}),e==="action"&&i.jsx("path",{d:"M13 11 L21.5 16 L13 21 Z",fill:"currentColor"}),(e==="mark"||e==="voice")&&i.jsx("circle",{cx:"16",cy:"16",r:e==="voice"?4:3.4,fill:"currentColor"}),e==="status"&&(t==="idle"?i.jsx("circle",{cx:"16",cy:"16",r:"3.4",fill:"none",stroke:"currentColor",strokeWidth:"1.6"}):i.jsx("circle",{cx:"16",cy:"16",r:"4.2",fill:"currentColor"})),e==="alert"&&i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"14.4",y:"8.5",width:"3.2",height:"9.5",fill:"currentColor"}),i.jsx("rect",{x:"14.4",y:"20.5",width:"3.2",height:"3.2",fill:"currentColor"})]})]})}function Js({parts:e,className:t,as:s="div"}){const o=e.filter(a=>a!=null&&a!==!1&&a!=="");return i.jsx(s,{className:Ge("meta",t),children:o.map((a,c)=>i.jsxs("span",{children:[c>0&&" · ",a]},c))})}const ym=()=>{const e=document.documentElement.dataset.theme;return e?e==="night":matchMedia("(prefers-color-scheme: dark)").matches};function Cu(){const[e,t]=y.useState(ym);return y.useEffect(()=>{const s=()=>t(ym()),o=matchMedia("(prefers-color-scheme: dark)");o.addEventListener("change",s);const a=new MutationObserver(s);return a.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{o.removeEventListener("change",s),a.disconnect()}},[]),e}function YN(){const e=()=>window.innerWidth>=1440?"wide":window.innerWidth>=1024?"laptop":"mobile",[t,s]=y.useState(e);return y.useEffect(()=>{const o=()=>s(e());return window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)},[]),t}const JN=15e3,wm=["pointerdown","pointermove","keydown","wheel","touchstart"];function XN(e,t,s,o){const[a,c]=y.useState(null),[u,h]=y.useState(!1),[m,p]=y.useState(!1),v=y.useRef(),k=y.useRef(Date.now()),x=y.useRef(!1),N=s.awayMinutes*6e4,S=y.useRef(t);S.current=t;const j=y.useRef(o);j.current=o;const A=y.useCallback((Q,W)=>{const ie=S.current;return Ox({snaps:Object.values(ie.allSnaps),decisions:ie.decisions,activity:ie.activity,ledger:e.activity.ledger,since:G=>{var ve;return Q[G]??W??((ve=ie.allSnaps[G])==null?void 0:ve.map.createdAt)??Date.now()},currentMapId:ie.mapId,attention:j.current})},[e]),C=y.useCallback((Q=Date.now())=>{var W;return(W=e.presence)==null?void 0:W.markSeen(S.current.maps.map(ie=>ie.id),Q)},[e]),R=y.useCallback(()=>{const Q=e.presence;if(!Q)return;const W=Q.lastSeenAny();if(W!==void 0&&Date.now()-W>=N){const ie=Q.snapshot();A(ie,W).changed&&(v.current={seen:ie,any:W},h(!0),s.enabled?c(ie):p(!0))}C()},[e,N,s.enabled,A,C]);y.useEffect(()=>{!t.loaded||x.current||!e.presence||(x.current=!0,R())},[t.loaded,e,R]),y.useEffect(()=>{const Q=()=>{const G=Date.now()-k.current>=N;k.current=Date.now(),G&&x.current&&document.visibilityState==="visible"&&R()},W=()=>{if(document.visibilityState!=="visible"){x.current&&C(Date.now()-k.current<N?Date.now():k.current);return}k.current=Date.now(),x.current&&R()};for(const G of wm)window.addEventListener(G,Q,{passive:!0});document.addEventListener("visibilitychange",W);const ie=setInterval(()=>{x.current&&document.visibilityState==="visible"&&C(k.current)},JN);return()=>{for(const G of wm)window.removeEventListener(G,Q);document.removeEventListener("visibilitychange",W),clearInterval(ie)}},[N,R,C]);const L=y.useMemo(()=>{var Q;return a?A(a,(Q=v.current)==null?void 0:Q.any):void 0},[a,A,t.allSnaps,t.decisions,t.activity,o]),U=y.useMemo(()=>L?Dx(L):"",[L]);y.useEffect(()=>{a&&p(!1)},[a]);let Z="none";return m?Z="new":u&&(Z="seen"),{shown:a!==null,status:Z,briefing:L,line:U,open:()=>{const Q=v.current;Q&&c(Q.seen)},dismiss:()=>c(null)}}function ZN(e){const[t,s]=y.useState(e.leases.leases);return y.useEffect(()=>e.leases.subscribe(s),[e]),t}const eS="That changed while you were on it, so nothing was written. It is reloaded now: look again, then redo the change.";function tS(e){var Y;const[t,s]=y.useState([]),[o,a]=y.useState(),[c,u]=y.useState(),[h,m]=y.useState({}),[p,v]=y.useState({}),[k,x]=y.useState(!1),[N,S]=y.useState(e.activity.snapshot),[j,A]=y.useState(e.monitor.health),C=ZN(e);y.useEffect(()=>e.monitor.subscribe(A),[e]);const[R,L]=y.useState(null),[U,Z]=y.useState(),[Q,W]=y.useState(),ie=y.useRef(),G=y.useRef(),ve=y.useRef(new Set),Le=y.useRef();Le.current=c;const $e=y.useCallback(B=>{ie.current=B,a(B),L(null)},[]),[oe]=y.useState(ei),D=y.useCallback(async()=>{var xe;const B=oe.start(),T=await e.adapter.listMaps();let _=ie.current;const ue=G.current;ue&&T.some(pe=>pe.id===ue)?(G.current=void 0,_=ue,_!==ie.current&&$e(_)):(!_||!T.some(pe=>pe.id===_))&&(_=(xe=T[0])==null?void 0:xe.id,$e(_));const[me,ke]=await Promise.all([Promise.all(T.map(pe=>e.adapter.loadMap(pe.id))),Promise.all(T.map(pe=>e.adapter.listDecisions(pe.id)))]);B()&&(s(T),m(Object.fromEntries(me.map(pe=>[pe.map.id,pe]))),v(Object.fromEntries(T.map((pe,Ne)=>[pe.id,ke[Ne]]))),x(!0),u(me.find(pe=>pe.map.id===_)))},[e,$e,oe]);y.useEffect(()=>{let B,T=()=>{},_=()=>{},ue=!0;const me=()=>{clearTimeout(B),B=setTimeout(()=>void D().catch(ge=>Z(String(ge))),40)},ke=fs(me),xe=(ge,Be)=>dn(ge)&&e.activity.isRemote(ge.id)&&(!Be||!ge.mapId||ge.mapId===Be),pe=ge=>{var Be;return(Be=Le.current)==null?void 0:Be.tickets.find(Sn=>Sn.id===ge)},Ne=ge=>{const Be=cx(ge,pe),Sn=ge.kind==="external.changed"&&e.activity.snapshot.sessions.some(ms=>xe(ms,ge.mapId)),cr=!("mapId"in ge)||!ge.mapId||ge.mapId===ie.current||ge.kind==="map.created";Be&&!Sn&&cr&&e.activity.push(Be),me()};return e.ready.then(()=>{ue&&(T=e.adapter.subscribe(Ne),_=e.activity.subscribe(S),e.activity.push({source:"system",level:"ok",text:`Online · tracker ${e.adapter.label.toLowerCase()} · ${e.adapter.location}`}),D().catch(ge=>Z(String(ge))))}),()=>{ue=!1,T(),_(),ke(),clearTimeout(B)}},[e,D]),y.useEffect(()=>{o&&D().catch(B=>Z(String(B)))},[o,D]),y.useEffect(()=>{for(const B of N.sessions)B.mode!=="chart"||!B.mapId||!e.activity.isRemote(B.id)||ve.current.has(B.id)||(ve.current.add(B.id),!(B.status!=="running"&&Date.now()-(B.endedAt??0)>6e4)&&(G.current=B.mapId,D().catch(T=>Z(String(T)))))},[N.sessions,e,D]);const X=(Y=N.pending[0])==null?void 0:Y.sessionId;y.useEffect(()=>{if(!X)return;const B=T=>e.activity.snapshot.sessions.some(_=>_.id===T&&dn(_));W(T=>B(T)?T:X)},[X,e]);const le=y.useCallback(async(B,T)=>{e.activity.push({source:"trail lead",agent:Nt,level:"warn",text:B});try{Z(void 0),await T()}catch(_){const ue=_.stale===!0,me=ue?eS:_.message??String(_);Z(me),e.activity.push({source:"trail lead",agent:Nt,level:"alert",text:`Rejected · ${me}`}),ue&&D().catch(ke=>Z(String(ke)))}},[e,D]),te=y.useMemo(()=>uN({rt:e,guard:le,setMapId:$e,mapIdRef:ie,snapRef:Le,setChatSession:W,setSelection:L}),[le,e,$e]),K=y.useMemo(()=>Object.values(h).flatMap(B=>kx(B,p[B.map.id]??[])).sort((B,T)=>T.decidedAt-B.decidedAt),[h,p]);return{maps:t,allSnaps:h,mapId:o,snap:c,activity:N,health:j,selection:R,setSelection:L,error:U,chatSession:Q,decisions:K,leases:C,loaded:k,actions:te}}function Xt(e=1e3){const[t,s]=y.useState(Date.now());return y.useEffect(()=>{const o=setInterval(()=>s(Date.now()),e);return()=>clearInterval(o)},[e]),t}function nS(){const[e,t]=y.useState(Su),s=y.useCallback(o=>{t(a=>{const c={...a,...o};return localStorage.setItem(Jo,JSON.stringify(c)),c})},[]);return[e,s]}function $u(){return y.useSyncExternalStore(Ys.subscribe,Ys.get)}function sS({className:e,size:t=18}){return i.jsx("span",{className:e,"aria-hidden":"true",children:i.jsx(lg,{size:t,variant:Cu()?"night":"crt"})})}function ze({as:e="section",className:t,style:s,frameless:o,children:a,...c}){return i.jsx(e,{className:Ge("panel",o&&"frameless",t),style:s,...c,children:a})}function Qn({tone:e,className:t,children:s,title:o}){return i.jsx("span",{className:Ge("pill",e,t),title:o,children:s})}function ln({label:e,value:t,layout:s="stack",urgent:o,title:a,className:c}){return i.jsxs("span",{className:Ge("readout",s!=="stack"&&s,o&&"urgent",c),title:a,children:[i.jsx("span",{className:"mono-label",children:e}),s==="inline"&&" ",i.jsx("b",{children:t})]})}function Ce(e){const{as:t="div",edge:s="neutral"}=e,o=e.onOpen?"button":"div";return i.jsxs(t,{className:Ge("ds-row",`edge-${s}`,e.selected&&"on",e.className),children:[i.jsxs(o,{className:"ds-row-main",...e.onOpen?{type:"button",onClick:e.onOpen}:{},title:e.titleText,"aria-current":e.current,children:[i.jsxs("span",{className:"ds-row-top",children:[i.jsx("span",{className:"ds-row-title t-row-title",children:e.title}),e.trailing&&i.jsx("span",{className:"ds-row-trail t-meta",children:e.trailing})]}),e.context&&i.jsx("span",{className:"ds-row-context",children:e.context}),e.detail&&i.jsx("span",{className:"ds-row-detail t-meta",title:e.detailText,children:e.detail})]}),e.actions&&i.jsx("span",{className:"ds-row-actions",children:e.actions}),e.below&&i.jsx("div",{className:"ds-row-below",children:e.below})]})}const Hn="#c8581e",iS={map:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M3 6l6-2.5 6 2.5 6-2.5v14.5L15 20.5 9 18l-6 2.5z"}),i.jsx("path",{d:"M9 3.5V18M15 6v14.5"}),i.jsx("path",{d:"M5.5 15c2-1 3-3 5-3.5s3-3 5-4",stroke:Hn,strokeDasharray:"2 2.2"})]}),note:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M5 3.5h14v13.5l-4 3.5H5z"}),i.jsx("path",{d:"M15 21v-4h4"}),i.jsx("path",{d:"M8.5 8h7M8.5 12h7",stroke:Hn})]}),book:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 6.5C10 4.5 7 4 3.5 4.5v14c3.5-.5 6.5 0 8.5 2 2-2 5-2.5 8.5-2v-14C17 4 14 4.5 12 6.5z"}),i.jsx("path",{d:"M12 6.5v14"}),i.jsx("path",{d:"M15 9.5l3-.5M15 13l3-.5",stroke:Hn})]}),flag:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M6 21.5V3"}),i.jsx("path",{d:"M6 4c4-1.5 7 1.5 12 0v9c-5 1.5-8-1.5-12 0z",fill:Hn,stroke:Hn})]}),tent:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 4L2.5 20h19z"}),i.jsx("path",{d:"M12 11l-4 9h8z",fill:Hn,stroke:Hn}),i.jsx("path",{d:"M12 4l-1.5-2M12 4l1.5-2"})]}),mailbox:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 21.500V14"}),i.jsx("path",{d:"M4 14V9.500A4.5 4.5 0 0 1 8.5 5h7A4.5 4.5 0 0 1 20 9.500V14z"}),i.jsx("path",{d:"M8.5 5A4.5 4.5 0 0 1 13 9.500V14"}),i.jsx("path",{d:"M16 10V6.500M16 6.500h3v2.500h-3",stroke:Hn})]})};function jg({name:e}){return i.jsx("svg",{className:"zone-icon","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:iS[e]})}function Et({title:e,count:t,right:s,hot:o,sub:a,children:c,className:u,info:h,icon:m}){return i.jsxs("header",{className:Ge("sec-h",a&&"sub",u),children:[c,m&&i.jsx(jg,{name:m}),e!==void 0&&i.jsx(Ve,{as:a?"h3":"h2",hot:o,children:e}),h&&i.jsx(ni,{text:h}),t,s!==void 0&&i.jsx("span",{className:"sec-h-right",children:s})]})}function dt(e){const{value:t,options:s,onChange:o}=e,[a,c]=y.useState(!1),[u,h]=y.useState(0),[m,p]=y.useState(),v=y.useRef(null),k=y.useRef(null),x=y.useId(),N=s.find(C=>C.value===t);y.useLayoutEffect(()=>{if(!a||!v.current)return;const C=v.current.getBoundingClientRect();p({left:C.left,top:C.bottom+4,minWidth:C.width})},[a]),y.useEffect(()=>{if(!a)return;const C=L=>{var U,Z;L.target instanceof Node&&((U=k.current)!=null&&U.contains(L.target)||(Z=v.current)!=null&&Z.contains(L.target))||c(!1)},R=()=>c(!1);return document.addEventListener("mousedown",C),window.addEventListener("resize",R),window.addEventListener("scroll",R,!0),()=>{document.removeEventListener("mousedown",C),window.removeEventListener("resize",R),window.removeEventListener("scroll",R,!0)}},[a]),y.useEffect(()=>{var C,R;a&&((R=(C=k.current)==null?void 0:C.querySelector(`[data-i="${u}"]`))==null||R.scrollIntoView({block:"nearest"}))},[a,u]);const S=()=>{h(Math.max(0,s.findIndex(C=>C.value===t))),c(!0)},j=C=>{var L;const R=s[C];c(!1),(L=v.current)==null||L.focus(),R&&R.value!==t&&o(R.value)},A=C=>{if(!a){["ArrowDown","ArrowUp","Enter"," "].includes(C.key)&&(C.preventDefault(),S());return}const R=L=>h(U=>(U+L+s.length)%s.length);if(C.key==="ArrowDown")R(1);else if(C.key==="ArrowUp")R(-1);else if(C.key==="Home")h(0);else if(C.key==="End")h(s.length-1);else if(C.key==="Enter"||C.key===" ")j(u);else{if(C.key==="Escape"||C.key==="Tab")return c(!1);if(C.key.length===1){const L=s.findIndex(U=>U.label.toLowerCase().startsWith(C.key.toLowerCase()));L>=0&&h(L);return}else return}C.preventDefault()};return i.jsxs(i.Fragment,{children:[i.jsxs("button",{ref:v,type:"button",className:Ge("select",e.compact&&"compact",a&&"open",e.className),role:"combobox","aria-haspopup":"listbox","aria-expanded":a,"aria-controls":x,"aria-label":e["aria-label"],"aria-activedescendant":a?`${x}-${u}`:void 0,disabled:e.disabled,onClick:()=>a?c(!1):S(),onKeyDown:A,children:[i.jsx("span",{className:"select-value",children:(N==null?void 0:N.label)??"—"}),i.jsx("span",{className:"select-caret","aria-hidden":"true"})]}),a&&m&&i.jsx("ul",{ref:k,id:x,className:"select-menu",role:"listbox",style:m,children:s.map((C,R)=>i.jsxs("li",{id:`${x}-${R}`,"data-i":R,role:"option","aria-selected":C.value===t,className:Ge(R===u&&"active"),onMouseEnter:()=>h(R),onMouseDown:L=>L.preventDefault(),onClick:()=>j(R),children:[i.jsx("span",{className:"select-label",children:C.label}),C.hint&&i.jsx("span",{className:"select-hint",children:C.hint})]},C.value))})]})}function rS(e){return i.jsx("div",{className:`tabs ${e.className??""}`,role:"tablist",children:e.items.map(t=>i.jsxs("button",{role:"tab","aria-selected":e.value===t.id,className:`tab ${e.value===t.id?"on":""}`,onClick:()=>e.onChange(t.id),children:[t.label,t.n!==void 0&&i.jsx("span",{className:"n",children:t.n})]},t.id))})}const oS=350;function aS(){const[e,t]=y.useState(null);if(y.useEffect(()=>{let o=0,a=null;const c=()=>{window.clearTimeout(o),a=null,t(null)},u=v=>{const k=v.getAttribute("data-tip");if(!k)return;const x=v.getBoundingClientRect(),N=x.bottom+60>window.innerHeight;t({text:k,x:x.left+x.width/2,y:N?x.top-8:x.bottom+8,above:N,scout:v.hasAttribute("data-tip-scout")})},h=v=>{var N,S;const k=(S=(N=v.target)==null?void 0:N.closest)==null?void 0:S.call(N,"[data-tip], [title]");if(!k||k instanceof SVGElement&&!k.hasAttribute("data-tip"))return null;const x=k.getAttribute("title");return x&&(k.setAttribute("data-tip",x),k.removeAttribute("title")),k},m=v=>{if(v.pointerType==="touch")return;const k=h(v);k!==a&&(c(),k&&(a=k,o=window.setTimeout(()=>a===k&&u(k),v.type==="focusin"?0:oS)))},p=v=>{a&&!a.contains(v.relatedTarget)&&c()};return document.addEventListener("pointerover",m),document.addEventListener("pointerout",p),document.addEventListener("focusin",m),document.addEventListener("focusout",c),document.addEventListener("pointerdown",c),window.addEventListener("scroll",c,!0),window.addEventListener("keydown",c),()=>{c(),document.removeEventListener("pointerover",m),document.removeEventListener("pointerout",p),document.removeEventListener("focusin",m),document.removeEventListener("focusout",c),document.removeEventListener("pointerdown",c),window.removeEventListener("scroll",c,!0),window.removeEventListener("keydown",c)}},[]),!e)return null;const s=Math.min(Math.max(e.x,140),window.innerWidth-140);if(e.scout){const o=Math.min(Math.max(e.x-24,8),window.innerWidth-340);return i.jsxs("div",{className:`scout-tip ${e.above?"above":""}`,role:"tooltip",style:{left:o,top:e.y,transform:e.above?"translateY(-100%)":void 0},children:[i.jsx(la,{size:1,framed:!1,speaking:e.text,className:"scout-tip-face"}),i.jsx("p",{className:"scout-tip-bubble",children:e.text})]})}return i.jsx("div",{className:`tooltip ${e.above?"above":""}`,role:"tooltip",style:{left:s,top:e.y,transform:`translate(-50%, ${e.above?"-100%":"0"})`},children:e.text})}function va({as:e="span",className:t}){return i.jsxs(e,{className:t?`tt-wordmark ${t}`:"tt-wordmark",role:"img","aria-label":J.name,children:[J.name.toLowerCase(),i.jsx("span",{className:"tt-wordmark-dot","aria-hidden":"true"})]})}function Ng(e){return e.bare?i.jsx("div",{className:`zone-b ${e.className??""}`,children:e.children}):i.jsxs(ze,{className:`zone ${e.className??""}`,style:e.area?{gridArea:e.area}:void 0,children:[i.jsx(Et,{className:"zone-title",icon:e.icon,title:e.title,info:e.info,count:e.count,right:e.right??null}),i.jsx("div",{className:"zone-b",children:e.children})]})}function Bs(e){return e.children.length?i.jsxs("div",{className:`bf-list ${e.urgent?"urgent":""}`,children:[i.jsx("span",{className:"mono-label",children:e.title}),i.jsx("ul",{children:e.children})]}):null}function bo(e){return i.jsx("li",{children:i.jsxs("button",{className:"bf-row",onClick:e.onClick,title:e.title,children:[i.jsx("span",{className:"key t-code",children:e.k}),i.jsx("span",{className:"t",children:e.text}),e.meta&&i.jsx("span",{className:"t-meta",children:e.meta})]})})}function qi(e){return i.jsxs(Bt,{tone:e.urgent?"urgent":void 0,className:`bf-tile ${e.className??""}`,children:[i.jsx("span",{className:"mono-label",children:e.label}),i.jsx("b",{children:e.value}),e.sub&&i.jsx(V,{parts:[],children:e.sub})]})}const lS=864e5;function cS(e,t){const s=new Date(e),o=s.toTimeString().slice(0,5),a=new Date(t).toDateString(),c=new Date(t-lS).toDateString();let u=` ${s.toLocaleDateString(void 0,{month:"short",day:"numeric"})}`;return s.toDateString()===a?u="":s.toDateString()===c&&(u=" yesterday"),`Since ${o}${u} · ${Yt(t-e)}`}function uS(e){const{briefing:t,bp:s,onClose:o}=e;y.useEffect(()=>{const k=x=>x.key==="Escape"&&o();return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[o]);const a=t==null?void 0:t.trails.flatMap(k=>k.waiting).sort((k,x)=>k.at-x.at)[0],c=t==null?void 0:t.totals,u=((t==null?void 0:t.trails.length)??0)>1,h=s==="mobile",m=k=>{var x,N;return k.ticketId&&((N=(x=e.snaps[k.mapId])==null?void 0:x.tickets.find(S=>S.id===k.ticketId))==null?void 0:N.title)||k.text},p=k=>{var x,N;return k.ticketId&&((N=(x=e.snaps[k.mapId])==null?void 0:x.tickets.find(S=>S.id===k.ticketId))==null?void 0:N.key)||k.agent},v=k=>{const x=(C,R)=>i.jsx(bo,{k:C.key,text:C.title,meta:R,onClick:()=>e.onTicket(k.mapId,C.id)},C.id),N=(C,R)=>i.jsx(bo,{k:C.id,text:C.summary||C.answer,title:C.risk?`${C.question}
135
+
136
+ ${C.risk.reason}`:C.question,meta:R,onClick:()=>e.onDecision(C.id)},C.id),S=cj(k.agentDecisions).flatMap(C=>C.decisions.map(R=>N(R,C.label))),j=[i.jsx(Bs,{title:"Done",children:k.done.map(C=>x(C))},"done"),i.jsx(Bs,{title:"Ruled out",children:h?[]:k.ruledOut.map(C=>x(C))},"oos"),i.jsx(Bs,{title:"Blocked",children:k.blocked.map(C=>x(C.ticket,`needs ${C.on.map(R=>R.key).join(", ")}`))},"blocked")],A=[i.jsx(Bs,{title:"Waiting on you",urgent:!0,children:k.waiting.map(C=>i.jsx(bo,{k:p(C),text:m(C),meta:t.now-C.at<6e4?"now":Yt(t.now-C.at),title:C.text,onClick:()=>e.onAnswer(C)},C.id))},"waiting"),i.jsx(Bs,{title:"Agent decisions",children:h?[]:S},"agent"),i.jsx(Bs,{title:"Active sessions",children:h?[]:k.active.map(C=>{var L;const R=C.ticketId?(L=e.snaps[k.mapId])==null?void 0:L.tickets.find(U=>U.id===C.ticketId):void 0;return i.jsx(bo,{k:(R==null?void 0:R.key)??C.agent,text:R?`${R.title} · ${C.stepLabel}`:C.stepLabel,meta:`${C.step}/${C.total}`,onClick:()=>e.onSession(C)},C.id)})},"active")];return i.jsxs("section",{className:"bf-trail",children:[u&&i.jsxs("div",{className:"bf-trail-h",children:[i.jsx("span",{className:"key",children:k.key})," ",k.title]}),i.jsxs("div",{className:"bf-cols",children:[i.jsx("div",{children:j}),i.jsx("div",{children:A})]})]},k.mapId)};return i.jsx("div",{className:"scrim",onClick:o,children:i.jsxs(ze,{as:"div",className:"dialog briefing",role:"dialog","aria-label":"While you were away",onClick:k=>k.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:"While you were away"}),t&&t.trails.length>0&&i.jsx(Ve,{className:"bf-since",children:cS(t.since,t.now)}),i.jsx("button",{className:"icon-btn",onClick:o,"aria-label":"Close",children:"×"})]}),i.jsxs(Bt,{className:"bf-scout",children:[i.jsx(la,{size:h?1.1:1.3,speaking:e.line||"Nothing new since you were last here.",caption:!1,framed:!1}),i.jsxs("div",{children:[i.jsx("span",{className:"mono-label",children:"Scout"}),i.jsx("p",{children:e.line||"Nothing new since you were last here."})]})]}),t&&c&&t.trails.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"bf-tiles",children:[i.jsx(qi,{label:"Done",value:c.done,sub:c.ruledOut?`${c.ruledOut} ruled out`:void 0}),i.jsx(qi,{label:"Blocked",value:c.blocked,sub:c.blocked?"Needs your answer":void 0}),i.jsx(qi,{label:"Waiting on you",value:c.waiting,sub:dS(c.oldestWaitMs),urgent:c.waiting>0}),i.jsx(qi,{label:"Agent decisions",value:c.agentDecisions,className:"opt"}),i.jsx(qi,{label:"Spend",value:qs(c.usage.costUsd),sub:`${da(c.usage.inputTokens+c.usage.outputTokens)} tokens · ${c.usage.sessions} sessions${c.active?` · ${c.active} active`:""}`})]}),i.jsx("div",{className:"bf-body",children:t.trails.map(v)})]}),i.jsxs("footer",{children:[i.jsx(P,{onClick:o,children:"Dismiss"}),a?i.jsxs(P,{variant:"urgent",onClick:()=>e.onAnswer(a),children:[i.jsx(ii,{variant:"alert",size:13}),"Answer first decision"]}):i.jsx(P,{variant:"primary",onClick:e.onResume,children:"Resume trail"})]})]})})}function dS(e){if(e!==void 0)return e<6e4?"Just asked":`Oldest ${Yt(e)}`}function hS(e){const{brief:t,bp:s}=e;return i.jsx(uS,{briefing:t.briefing,line:t.line,snaps:e.snaps,bp:s,onClose:t.dismiss,onTicket:(o,a)=>{t.dismiss(),e.openTicket(o,a)},onAnswer:o=>{t.dismiss(),e.closeDecisions(),e.openChat(o.sessionId,o.ticketId,o.mapId)},onSession:o=>{t.dismiss(),e.closeDecisions(),e.openChat(o.id,o.ticketId,o.mapId)},onDecision:o=>{t.dismiss(),e.openDecisions(o)},onResume:()=>{t.dismiss(),e.closeDecisions(),s==="mobile"&&e.showPhoneHome()}})}const fS={passed:"checks passed",failing:"checks failing",pending:"checks pending",unknown:"checks unknown",none:"no checks"};function mS({mapId:e,ticketId:t}){const s=Ys.ticket($u(),e,t);if(!s)return null;const o=s.pr;return i.jsxs("div",{className:"pr-flags",children:[i.jsxs("span",{className:`pr-chip pr-${(o==null?void 0:o.state)??"unread"}`,title:o?`${o.title}
137
+ ${o.headRef}`:void 0,children:[o?i.jsxs("a",{href:hs(o.url),target:"_blank",rel:"noreferrer noopener",children:["PR #",o.number," · ",o.state,o.draft?" · draft":""]}):`PR #${s.link.number}`,i.jsx("span",{className:`ci ci-${s.checksSummary}`,children:fS[s.checksSummary]}),i.jsx("span",{className:"when",children:pS(s)})]}),s.flags.map(a=>i.jsx(Qn,{className:`flag flag-${a.severity}`,title:a.text,children:a.kind},a.kind))]})}function pS(e){return e.error?"sync failed":e.syncedAt?dg(e.syncedAt):"not synced yet"}const gS={ok:"ok",failed:"error",stale:"syncing",unknown:"idle",off:"idle"};function vS({now:e}){const t=$u();if(!t.reached)return null;const s=sx(t.live?t.status:null,e);return i.jsxs("span",{className:`tracker-chip pr-sync tone-${s.tone}`,title:s.title,children:[i.jsx(Ve,{size:"sm",children:"CI"}),i.jsx(ii,{variant:"status",state:gS[s.tone],size:13,className:"sync-glyph"}),i.jsx("span",{className:"tl",children:s.label})]})}function Sg(e){const t=e.role??"menu",[s,o]=y.useState(!1),a=y.useRef(null);return y.useEffect(()=>{if(!s)return;const c=u=>{var m;(u instanceof KeyboardEvent?u.key==="Escape":!((m=a.current)!=null&&m.contains(u.target)))&&o(!1)};return window.addEventListener("mousedown",c),window.addEventListener("keydown",c),()=>{window.removeEventListener("mousedown",c),window.removeEventListener("keydown",c)}},[s]),i.jsxs("div",{className:Ge("header-menu",e.className),ref:a,children:[i.jsxs(P,{variant:"ghost","aria-haspopup":t,"aria-label":e.ariaLabel,"aria-expanded":s,on:s,"data-tip":s?void 0:e.tip,onClick:()=>o(!s),children:[e.label," ",e.badge," ",i.jsx("span",{className:"caret",children:"▾"})]}),s&&i.jsx("div",{className:"header-menu-list",role:t,children:e.children(()=>o(!1))})]})}const kS={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 yS(e){const t=e.briefingStatus==="new";return i.jsx(Sg,{label:"Records",badge:i.jsxs(i.Fragment,{children:[e.knowledge>0&&i.jsx("span",{className:"n hot",children:e.knowledge}),t&&i.jsx("span",{className:"new-dot","aria-label":"new trip report"})]}),children:s=>i.jsxs(i.Fragment,{children:[i.jsxs("button",{role:"menuitem",className:"header-menu-item",disabled:e.briefingStatus==="none"&&!e.briefingOpen,title:kS[e.briefingStatus],onClick:()=>{s(),e.onBriefing()},children:[i.jsx("span",{children:"Trip report"}),t&&i.jsx("span",{className:"new-dot","aria-label":"new"})]}),i.jsxs("button",{role:"menuitem",className:"header-menu-item knowledge-btn",title:"What agents know about this codebase and product. Review suggestions, flags and stale entries",onClick:()=>{s(),e.onKnowledge()},children:[i.jsx("span",{children:"Field guide"}),e.knowledge>0&&i.jsx("span",{className:"n hot",children:e.knowledge})]}),i.jsxs("button",{role:"menuitem",className:"header-menu-item decisions-btn",title:"Every decision across your trails, with its reasoning. Search, filter and export",onClick:()=>{s(),e.onDecisions()},children:[i.jsx("span",{children:"Logbook"}),i.jsx("span",{className:"n",children:e.decisions})]}),i.jsx("button",{role:"menuitem",className:"header-menu-item stats-btn",title:"How your agents deliver across trails, by vendor, agent and ticket type.",onClick:()=>{s(),e.onStats()},children:i.jsx("span",{children:"Trail stats"})})]})})}const wS=i.jsxs(i.Fragment,{children:[i.jsx("circle",{cx:"9",cy:"9",r:"3.6",fill:"currentColor"}),i.jsx("path",{d:"M9 1v2.400M9 14.600V17M1 9h2.400M14.6 9H17M3.3 3.300L5 5M13 13l1.7 1.700M3.3 14.700L5 13M13 5l1.7-1.7",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]}),xS=i.jsx("path",{d:"M15.2 11.400A6.9 6.9 0 0 1 6.6 2.800a6.9 6.9 0 1 0 8.6 8.600z",fill:"currentColor"});function jS({onToggle:e}){const t=Cu(),s=t?"Switch to the day theme":"Switch to the night theme";return i.jsx(P,{variant:"ghost",className:"icon-only","aria-label":s,"data-tip":s,onClick:()=>e(!t),children:i.jsx("svg",{viewBox:"0 0 18 18",width:"16",height:"16","aria-hidden":"true",children:t?wS:xS})})}const NS={idle:"Idle",syncing:"Syncing",ok:"Synced",error:"Sync error"};function SS({label:e,health:t,now:s}){const o=[`${NS[t.status]} · ${t.writes} writes · ${t.errors} errors`,t.lastWriteAt?`Last write ${Yt(t.lastWriteMs??0)}, ${Yt(s-t.lastWriteAt)} ago`:"No writes yet",t.lastError].filter(Boolean).join(`
138
+ `);return i.jsxs("span",{className:`tracker-chip sync-${t.status}`,title:o,children:[i.jsx(Ve,{size:"sm",children:"Tracker"}),i.jsx(ii,{variant:"status",state:t.status,size:13,className:"sync-glyph"}),i.jsx("span",{className:"tl",children:e})]})}function bS(e){const[t,s]=y.useState(!1),o=y.useRef(null);y.useEffect(()=>{if(!t)return;const h=m=>{var p;(m instanceof KeyboardEvent?m.key==="Escape":!((p=o.current)!=null&&p.contains(m.target)))&&s(!1)};return window.addEventListener("mousedown",h),window.addEventListener("keydown",h),()=>{window.removeEventListener("mousedown",h),window.removeEventListener("keydown",h)}},[t]);const a=Object.values(e.snaps).sort((h,m)=>m.map.createdAt-h.map.createdAt),c=h=>e.activity.pending.filter(m=>m.mapId===h).length,u=e.activity.pending.filter(h=>{var m;return h.mapId!==((m=e.map)==null?void 0:m.id)}).length;return i.jsxs("div",{className:"trail-switcher",ref:o,children:[i.jsxs("button",{className:"trail-btn",onClick:()=>s(h=>!h),"aria-haspopup":"menu","aria-expanded":t,"data-tip":"Switch trail, or start a new one",children:[i.jsx("span",{className:"trail-title",children:e.map?`${e.map.key} ${e.map.title}`:"No trail"}),u>0&&i.jsx(us,{n:u,urgent:!0}),i.jsx("span",{className:"caret",children:"▾"})]}),t&&i.jsxs("div",{className:"trail-menu",role:"menu",children:[i.jsx(Ve,{variant:"plain",className:"menu-h",children:"Trails"}),a.map(h=>{var v;const m=Rp(h),p=c(h.map.id);return i.jsxs("button",{role:"menuitem",className:`trail-item ${h.map.id===((v=e.map)==null?void 0:v.id)?"on":""}`,onClick:()=>{e.onSelectMap(h.map.id),s(!1)},children:[i.jsx("span",{className:"key",children:h.map.key}),i.jsx("span",{className:"mi-title",children:h.map.title}),i.jsxs("span",{className:"mi-progress",children:[m.decided,"/",m.total]}),i.jsx(us,{n:p,urgent:!!p,hideZero:!0})]},h.map.id)}),i.jsx("button",{role:"menuitem",className:"trail-item new",onClick:()=>{s(!1),e.onNewTrail()},children:"+ New trail"})]})]})}function CS(e){const{map:t}=e,s=Xt(1e3),o=e.activity.pending.length,a=t&&e.snaps[t.id],c=a&&Rp(a),u=t&&Op(e.activity,t.id);return i.jsxs(ze,{as:"header",className:"header",children:[i.jsxs("div",{className:"h-title",children:[i.jsxs("div",{className:"h-line1",children:[e.repo,i.jsx("span",{className:"sep",children:"/"}),i.jsx(bS,{...e})]}),i.jsxs("div",{className:"h-dest",title:t==null?void 0:t.sections.destination,children:[i.jsx(Ve,{size:"sm",children:"Destination"}),(t==null?void 0:t.sections.destination)??"—"]})]}),i.jsxs("div",{className:"h-right",children:[i.jsx(SS,{label:e.trackerLabel,health:e.health,now:s}),i.jsx(vS,{now:s}),t&&c&&i.jsxs("span",{className:"trail-meta",children:[i.jsx(ln,{label:"Trail T+",value:ug(s-t.createdAt),title:"Trail elapsed time, since it was charted"}),i.jsx(ln,{label:"Done",value:`${c.decided}/${c.total}`}),u&&i.jsx(ln,{className:"spend",label:"Spent",value:`${qs(u.costUsd)} · ${da(u.inputTokens+u.outputTokens)} tok`,title:["Model spend and tokens for this trail, across every session",...Pp(e.activity,t.id).map(h=>Lp[h].text)].join(`
139
+ `)})]}),e.attention,!e.attention&&o>0&&i.jsxs("span",{className:"waiting-chip",title:`${o} waiting on you`,children:[i.jsx(ii,{variant:"alert",size:14}),i.jsx("b",{children:o}),i.jsx("span",{className:"wl",children:" waiting on you"})]}),e.slackAlert&&i.jsx(P,{size:"sm",variant:"urgent",onClick:e.onSlack,title:e.slackAlert.why,children:e.slackAlert.label}),t&&i.jsx(P,{variant:"ghost",className:"mode-chip",onClick:e.onToggleMode,"data-tip":t.mode==="plan-only"?"Plan only: agents research and decide, but no execute tickets run. Click to switch to Plan + execute.":"Plan + execute: agents decide, then build what was decided. Click to switch to Plan only, which parks execute tickets.",children:t.mode==="plan-only"?"Plan only":"Plan + execute"}),i.jsx(yS,{decisions:e.decisions,onDecisions:e.onDecisions,onStats:e.onStats,knowledge:e.knowledge,onKnowledge:e.onKnowledge,briefingOpen:e.briefingOpen,briefingStatus:e.briefingStatus,onBriefing:e.onBriefing}),i.jsx(P,{variant:"ghost",onClick:e.onSettings,"data-tip":"Tracker, verification, appearance and integrations",children:"Settings"}),i.jsx(jS,{onToggle:e.onToggleTheme})]})]})}const bg=y.createContext(null);function ri(){const e=y.useContext(bg);if(!e)throw new Error("useKnowledge needs a KnowledgeContext provider");return e}function $S({snap:e,t}){const s=ri();if(!s.entries.length||t.state==="closed")return null;const o=qp(s.entries,{trailKey:e.map.key,ticket:{type:t.type,title:t.title,body:t.body},paths:Qp(`${t.body}
140
+ ${s.briefText}`)},4e3,a=>s.stale[a.id]??[]);return i.jsxs("div",{className:"kn-preview d-section",children:[i.jsxs("span",{className:"t-label","data-tip":"Picked by paths, words, trail and kind; confirmed entries and assumptions only",children:["Knowledge this agent gets · ",o.length]}),o.length>0&&i.jsx("ul",{className:"item-list inline",children:o.map(a=>i.jsxs("li",{children:[i.jsx("button",{className:"item-text kn-open",onClick:()=>s.setOpen(!0),"data-tip":a.why.join(" · "),children:a.title}),i.jsx(V,{parts:[{text:a.id,code:!0},a.status==="assumption"&&"assumption",a.mayBeOutdated&&{text:"may be outdated",className:"warn"}]})]},a.id))})]})}function Co(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 ka(e,t){const[s,o]=y.useState({key:e,shown:Co(void 0,t)});let a=s;return s.key!==e?a={key:e,shown:Co(void 0,t)}:s.shown.latest!==t&&(a={key:e,shown:Co(s.shown,t)}),a!==s&&o(a),{hash:a.shown.hash,changed:a.shown.hash!==a.shown.latest,reviewAgain:()=>o({key:e,shown:Co(void 0,t)})}}const TS={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 ES({e}){const t=ri(),[s,o]=y.useState(!1),[a,c]=y.useState(e.title),[u,h]=y.useState(e.body);y.useEffect(()=>{o(!1),c(e.title),h(e.body)},[e.id,e.title,e.body]);const m=t.stale[e.id],p=ka(e.id,t.hashes[e.id]);return i.jsxs("div",{className:"kn-detail",children:[i.jsx(V,{parts:[{text:e.id,code:!0},e.kind.replace("-"," "),e.status]}),s?i.jsxs(i.Fragment,{children:[i.jsx(Ze,{label:"Title",children:i.jsx("input",{value:a,onChange:v=>c(v.target.value)})}),i.jsx(Ze,{label:"Body",children:i.jsx("textarea",{rows:8,value:u,onChange:v=>h(v.target.value)})})]}):i.jsxs(i.Fragment,{children:[i.jsx("h3",{className:"t-title",children:e.title}),i.jsx("p",{className:"kn-body",children:e.body})]}),i.jsx("p",{className:"dim",children:TS[e.status]}),e.flag&&i.jsxs("p",{className:"kn-warn",children:["Flagged by ",e.flag.by,": ",e.flag.reason]}),m&&e.status!=="outdated"&&i.jsxs("p",{className:"kn-warn",children:["May be outdated: ",m.join(", ")," changed since it was confirmed. Re-confirm or edit it."]}),i.jsxs("dl",{className:"facts",children:[e.scope.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Applies to"}),i.jsx("dd",{children:e.scope.join(", ")})]}),e.tags.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Tags"}),i.jsx("dd",{children:e.tags.join(", ")})]}),i.jsx("dt",{children:"From"}),i.jsx("dd",{children:[e.createdBy,...e.sources].join(" · ")}),e.anchors.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"About files"}),i.jsx("dd",{children:e.anchors.map(v=>v.path).join(", ")})]})]}),p.changed&&i.jsx(pa,{what:"This entry",onReviewAgain:p.reviewAgain}),t.error&&i.jsx("p",{className:"vf-err",children:t.error}),i.jsx("div",{className:"actions",children:s?i.jsxs(i.Fragment,{children:[i.jsx(P,{variant:"ghost",onClick:()=>o(!1),children:"Cancel"}),i.jsx(P,{variant:"primary",disabled:!a.trim(),onClick:()=>void t.call(e.id,{kind:"edit",title:a,body:u}).then(v=>v&&o(!1)),children:"Save"})]}):i.jsxs(i.Fragment,{children:[(e.status!=="confirmed"||m)&&i.jsx(P,{variant:"primary",disabled:p.changed,onClick:()=>void t.call(e.id,{kind:"confirm"},p.hash),children:e.status==="confirmed"?"Re-confirm":"Confirm"}),e.status!=="assumption"&&e.status!=="outdated"&&i.jsx(P,{disabled:p.changed,onClick:()=>void t.call(e.id,{kind:"assumption"},p.hash),children:"Keep as assumption"}),e.flag&&i.jsx(P,{onClick:()=>void t.call(e.id,{kind:"resolve-flag"}),children:"Resolve flag"}),i.jsx(P,{variant:"ghost",onClick:()=>o(!0),children:"Edit"}),e.status!=="outdated"&&i.jsx(P,{variant:"ghost",onClick:()=>void t.call(e.id,{kind:"outdated"}),children:"Mark outdated"})]})})]})}const AS={suggested:"Suggested",confirmed:"Confirmed",assumption:"Assumption",outdated:"Outdated"};function IS(){const e=ri(),[t,s]=y.useState("review"),[o,a]=y.useState(""),[c,u]=y.useState(""),[h,m]=y.useState();y.useEffect(()=>{if(!e.open)return;const j=A=>A.key==="Escape"&&e.setOpen(!1);return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[e]);const p=j=>j.status==="suggested"||!!j.flag||!!e.stale[j.id]&&j.status!=="outdated",v=(j,A)=>A==="all"?!0:A==="review"?p(j):j.status===A,k=y.useMemo(()=>{const j=c.trim().toLowerCase();return e.entries.filter(A=>v(A,t)&&(!o||A.kind===o)&&(!j||`${A.id} ${A.title} ${A.body} ${A.tags.join(" ")}`.toLowerCase().includes(j)))},[e.entries,e.stale,t,o,c]);if(!e.open)return null;const x=k.find(j=>j.id===h)??k[0],N=j=>e.entries.filter(A=>v(A,j)).length,S=[["review","Needs you"],["confirmed","Confirmed"],["assumption","Assumptions"],["outdated","Outdated"],["all","All"]];return i.jsx("div",{className:"scrim",onClick:()=>e.setOpen(!1),children:i.jsxs(ze,{as:"div",className:"dialog knowledge-view",onClick:j=>j.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:"Field guide"}),i.jsx(ni,{text:"What agents need to know about this codebase and product. Agents propose entries; only confirmed ones and assumptions reach them, picked for each ticket with the reason. Entries about files are flagged here when those files change. Seed it from a document with: teamtrail knowledge import <file.md>"})]}),i.jsxs("div",{className:"kn-filters",children:[S.map(([j,A])=>i.jsxs("button",{className:`chip ${t===j?"on":""}`,onClick:()=>s(j),children:[A," ",i.jsx("span",{className:"n",children:N(j)})]},j)),i.jsx(dt,{compact:!0,"aria-label":"Kind",value:o,onChange:a,options:[{value:"",label:"Any kind"},...ej.map(j=>({value:j,label:j.replace("-"," ")}))]}),i.jsx("input",{className:"kn-search",placeholder:"Search",value:c,onChange:j=>u(j.target.value)})]}),i.jsxs("div",{className:"kn-body-grid",children:[i.jsx("ul",{className:"kn-list",children:k.length?k.map(j=>i.jsx(Ce,{as:"li",className:`kn-row st-${j.status}`,edge:p(j)?"attention":"neutral",selected:j===x,onOpen:()=>m(j.id),title:j.title,titleText:j.title,context:i.jsx(V,{parts:[{text:j.id,code:!0},j.kind.replace("-"," "),p(j)&&j.status!=="suggested"?"Needs a check":AS[j.status]]})},j.id)):i.jsx(Ae,{children:t==="review"?"Nothing needs you":"No entries"})}),x?i.jsx(ES,{e:x}):i.jsx(Ae,{children:"Pick an entry"})]})]})})}function Tu({draft:e,label:t="Save as knowledge"}){const s=ri(),[o,a]=y.useState();return o?i.jsxs(P,{size:"sm",variant:"ghost",onClick:()=>s.setOpen(!0),"data-tip":"Open it in the field guide to confirm it",children:["Saved as ",o]}):i.jsx(P,{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 s.propose(e()).then(c=>c&&a(c.id)),children:t})}const MS=e=>{try{return JSON.parse(e)}catch{return}};function Cg(e){const t=ei();let s=!1;const o=()=>{const h=t.start();e.load().then(m=>!s&&h()&&e.show(m),()=>{var m;return!s&&h()&&((m=e.failed)==null?void 0:m.call(e))})},{changed:a,events:c={}}=e,u=[fs(o),...a?[ju(h=>a(h)&&o())]:[],...Object.entries(c).map(([h,m])=>ti(h,p=>m(MS(p))&&o()))];return o(),{reload:o,pushed:()=>t.pushed(),stop:()=>{s=!0;for(const h of u)h()}}}function pt(e){const t=y.useRef(e);t.current=e;const s=y.useRef(),o=y.useRef(e.version),{view:a,version:c}=e;y.useEffect(()=>{const m=t.current;o.current=m.version;const p=Object.keys(m.events??{}),v=Cg({load:()=>t.current.load(),show:k=>t.current.show(k),failed:()=>{var k,x;return(x=(k=t.current).failed)==null?void 0:x.call(k)},...m.changed?{changed:k=>{var x,N;return((N=(x=t.current).changed)==null?void 0:N.call(x,k))===!0}}:{},events:Object.fromEntries(p.map(k=>[k,x=>{var N,S;return((S=(N=t.current.events)==null?void 0:N[k])==null?void 0:S.call(N,x))===!0}]))});return s.current=v,()=>{v.stop(),s.current=void 0}},[a]),y.useEffect(()=>{var m;Object.is(o.current,c)||(o.current=c,(m=s.current)==null||m.reload())},[c]);const u=y.useCallback(()=>{var m;return(m=s.current)==null?void 0:m.reload()},[]),h=y.useCallback(()=>{var m;return(m=s.current)==null?void 0:m.pushed()},[]);return{reload:u,pushed:h}}const $g=`${je()}/knowledge`;async function xm(e,t){const s=await fetch(`${$g}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),o=await s.json().catch(()=>({}));if(!s.ok)throw new Error(o.error??`HTTP ${s.status}`);return o}async function RS(){const e=await fetch($g);return e.ok?await e.json():null}function OS(e){const[t,s]=y.useState([]),[o,a]=y.useState({}),[c,u]=y.useState({}),[h,m]=y.useState(!1),[p,v]=y.useState(),{reload:k}=pt({load:RS,show:N=>{N&&(s(N.entries),a(N.stale),u(N.hashes??{}))},changed:N=>N.startsWith("knowledge/")}),x=y.useMemo(()=>t.filter(N=>N.status==="suggested"||N.flag||o[N.id]&&N.status!=="outdated").length,[t,o]);return{entries:t,stale:o,briefText:e,attention:x,open:h,setOpen:m,error:p,hashes:c,call:(N,S,j)=>xm("/call",{id:N,call:S,hash:j??c[N]}).then(()=>(v(void 0),k(),!0),A=>(v(A.message),k(),!1)),propose:N=>xm("/propose",N).then(S=>(k(),S.entry),S=>(v(S.message),void 0))}}function Yc(e){const[t,s]=y.useState(!1),[o,a]=y.useState(""),c=async()=>{let u="";try{u=await navigator.clipboard.readText()}catch{s(!0);return}u.trim()?e.onToken(u,!0):s(!0)};return i.jsxs("div",{className:"sl-paste",children:[i.jsx(P,{variant:"primary",disabled:e.busy,onClick:()=>void c(),children:e.busy?"Checking…":"Paste"}),t?i.jsxs("form",{className:"sl-paste-field",onSubmit:u=>{u.preventDefault(),e.onToken(o,!0),a("")},children:[i.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,autoFocus:!0,value:o,placeholder:e.placeholder,"aria-label":"Token",onChange:u=>a(u.target.value)}),i.jsx(P,{type:"submit",disabled:e.busy||!o.trim(),children:"Save"})]}):i.jsx("button",{type:"button",className:"link",onClick:()=>s(!0),children:"Type it instead"})]})}const LS=["awaiting","blocked","trail.done","resolved"],PS=["commands","chat:write","im:write","channels:history","groups:history","im:history","mpim:history","users:read"],_S=["users:read.email"],DS="save_decision",zS=`/${J.assistant.name.toLowerCase()}`;function BS(e={}){const t=J.assistant.name;return{display_information:{name:t,description:`${J.name} decisions and agent questions`,background_color:"#1b2226"},features:{app_home:{home_tab_enabled:!0,messages_tab_enabled:!0,messages_tab_read_only_enabled:!1},bot_user:{display_name:t,always_online:!0},slash_commands:[{command:e.command??zS,description:"Record a decision, check a trail, answer agents",usage_hint:"decide [text] | status [trail] | inbox | help",should_escape:!1}],shortcuts:[{name:"Save as decision",type:"message",callback_id:DS,description:`Record this thread as a ${J.name} decision`}]},oauth_config:{scopes:{bot:[...PS,..._S]}},settings:{event_subscriptions:{bot_events:["app_home_opened"]},interactivity:{is_enabled:!0},org_deploy_enabled:!1,socket_mode_enabled:!0,token_rotation_enabled:!1}}}const FS={create:e=>`https://api.slack.com/apps?new_app=1&manifest_json=${encodeURIComponent(JSON.stringify(BS({command:e})))}`,app:e=>`https://api.slack.com/apps/${e}/general`,install:e=>`https://api.slack.com/apps/${e}/install-on-team`,home:(e,t)=>`slack://app?team=${e}&id=${t}&tab=home`,homeWeb:(e,t)=>`https://slack.com/app_redirect?app=${t}&team=${e}`};function US(e){const t=e.trim().match(/^xapp-\d+-(A[A-Z0-9]+)-/);return t==null?void 0:t[1]}async function xn(e,t="GET",s){const o=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:s===void 0?void 0:JSON.stringify(s)}),a=await o.json().catch(()=>({}));if(!o.ok&&!a.status)throw new Error(a.error??`request failed (${o.status})`);return a}function WS(e){const t=`${e}/slack`;return{get:()=>xn(t),created:()=>xn(`${t}/created`,"POST",{}),token:s=>xn(`${t}/token`,"POST",{token:s}),update:s=>xn(`${t}/settings`,"PUT",s),ownerCode:()=>xn(`${t}/owner/code`,"POST",{}),confirmOwner:s=>xn(`${t}/owner/confirm`,"POST",{id:s}),resetOwner:()=>xn(`${t}/owner/reset`,"POST",{}),members:()=>xn(`${t}/members`).then(s=>s.members),remove:()=>xn(t,"DELETE")}}const Jt=WS(je());function HS(e){const[t,s]=y.useState(!1),[o,a]=y.useState(),c=u=>{s(!0),Jt.token(u).then(h=>{s(!1),a(h.ok?void 0:h.error),e.set(h.status)},h=>{s(!1),a(h.message)})};return i.jsxs(i.Fragment,{children:[i.jsx(Yc,{busy:t,placeholder:"xapp-… or xoxb-…",onToken:c}),o&&i.jsxs("div",{className:"test-line alert",children:["✕ ",o]})]})}const KS=e=>new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});function VS({problem:e}){const t=e.failures===1?"A message was":`${e.failures} messages were`;return i.jsxs("div",{className:"test-line warn",title:e.code,children:[t," not delivered (last ",KS(e.at),"). ",e.message]})}function GS({onRemoved:e}){const[t,s]=y.useState(!1);if(!t)return i.jsx(P,{size:"sm",variant:"ghost",onClick:()=>s(!0),children:"Remove"});const o=()=>void Jt.remove().then(a=>{s(!1),e(a)},()=>{});return i.jsxs(i.Fragment,{children:[i.jsx(P,{size:"sm",variant:"danger",onClick:o,children:"Remove tokens and settings"}),i.jsx(P,{size:"sm",variant:"ghost",onClick:()=>s(!1),children:"Keep"})]})}const qS={awaiting:"Awaiting you",blocked:"Blocked","trail.done":"Trail done",resolved:"Resolved"};function Jc({s:e}){const[t,s]=QS(e);return i.jsxs("div",{className:`sync-line ${t}`,title:e.error,children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:s})]})}function QS(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 · Slack rejected the tokens"];case"elsewhere":{const t=e.heldBy?` (${e.heldBy})`:"";return["warn",`Connected from another ${J.slug}${t}`]}case"unsupported":return["alert",e.error??"Not supported here"];default:return["",e.step==="done"?"Off":"Not connected"]}}function YS(e){const{s:t,setup:s}=e,o=t.step==="done";return i.jsxs(Bt,{className:XS(t,s),children:[i.jsxs("div",{className:"card-row",children:[i.jsx("b",{className:"choice-title t-row-title",children:"Your Scout app"}),o&&i.jsx(Qn,{className:t.enabled?"on":"",children:t.enabled?"On":"Off"})]}),o&&i.jsx("div",{className:"c-loc",children:JS(t)}),o&&i.jsx(Jc,{s:t}),t.delivery&&i.jsx(VS,{problem:t.delivery}),!o&&t.step===1&&!s&&i.jsx("p",{className:"sl-lead",children:"Answer agents and save threads as decisions from Slack. You create your own Scout app in your workspace; it runs from this machine and its tokens stay in your local credential store."}),i.jsxs("div",{className:"c-actions",children:[!o&&!s&&i.jsx(P,{size:"sm",variant:"primary",onClick:()=>e.onSetup(!0),children:t.step===1?"Connect":`Resume at step ${t.step}`}),o&&i.jsx(P,{size:"sm",on:t.enabled,onClick:e.onToggle,children:t.enabled?"Turn off":"Turn on"}),o&&t.state==="auth-error"&&i.jsx(P,{size:"sm",variant:"primary",onClick:()=>e.onSetup(!0),children:"Reconnect"}),t.step!==1&&i.jsx(GS,{onRemoved:e.onRemoved})]})]})}function JS(e){var s,o,a;const t=(o=(s=e.workspace)==null?void 0:s.url)==null?void 0:o.replace(/^https?:\/\/|\/$/g,"");return[(a=e.workspace)==null?void 0:a.name,t,e.setup.appId].filter(Boolean).join(" · ")}function XS(e,t){const s=e.step==="done";return`connector ${s&&e.enabled?"active":""} ${t||!s?"open":""}`}function ZS(e){const[t,s]=y.useState(e.value==="dm"?"":e.value),o=/^[CG][A-Z0-9]{6,}$/.test(t.trim());return i.jsxs("form",{className:"sl-paste-field",onSubmit:a=>{a.preventDefault(),o&&e.onSave(t.trim())},children:[i.jsx("input",{value:t,spellCheck:!1,placeholder:"Channel ID, e.g. C0123ABCD","aria-label":"Channel ID",onChange:a=>s(a.target.value)}),i.jsx(P,{type:"submit",disabled:!o||t.trim()===e.value,children:"Save"})]})}function e1(e){const[t,s]=y.useState(),[o,a]=y.useState();y.useEffect(()=>{Jt.members().then(s,h=>a(h.message))},[]);const c=new Set(e.owners.map(h=>h.id)),u=new Set(e.value.map(h=>h.id));return o?i.jsxs("div",{className:"test-line alert",children:["✕ ",o]}):t?i.jsx("div",{className:"choice-row compact sl-members",children:t.map(h=>i.jsx(mt,{on:c.has(h.id)||u.has(h.id),disabled:c.has(h.id),title:`@${h.name??h.id}`,sub:c.has(h.id)?"Owner":void 0,onClick:()=>e.onChange(u.has(h.id)?e.value.filter(m=>m.id!==h.id):[...e.value,h])},h.id))}):i.jsx("span",{className:"t-meta",children:"Loading members…"})}function t1(e){const{s:t,patch:s}=e,[o,a]=y.useState(!1),c=new Set(t.notify.events),u=o||t.notify.target!=="dm",h=t.owners[0],m=p=>{const v=c.has(p)?t.notify.events.filter(k=>k!==p):[...t.notify.events,p];s({notify:{events:v}})};return i.jsxs("div",{className:"sl-groups",children:[i.jsxs("div",{className:"sl-group",children:[i.jsx(Ve,{variant:"plain",size:"sm",children:"Owner"}),i.jsxs("div",{className:"sl-owner",children:[i.jsxs("b",{children:["@",(h==null?void 0:h.name)??(h==null?void 0:h.id)]}),i.jsx("span",{className:"t-meta",children:"Confirmed on this machine"}),i.jsx("button",{type:"button",className:"link",onClick:()=>void Jt.resetOwner().then(e.set,()=>{}),children:"Not you? Reset"})]})]}),i.jsxs("div",{className:"sl-group",children:[i.jsx(Ve,{variant:"plain",size:"sm",children:"Allowed users"}),i.jsx(e1,{value:t.allow,owners:t.owners,onChange:p=>s({allow:p})})]}),i.jsxs("div",{className:"sl-group",children:[i.jsx(Ve,{variant:"plain",size:"sm",children:"Notify"}),i.jsxs("div",{className:"choice-row compact",children:[i.jsx(mt,{on:!u,title:"DM to owner",onClick:()=>{a(!1),s({notify:{target:"dm",detail:"full"}})}}),i.jsx(mt,{on:u,title:"Channel",sub:t.notify.target!=="dm"?t.notify.target:void 0,onClick:()=>a(!0)})]}),u&&i.jsxs(i.Fragment,{children:[i.jsx(Ze,{label:"Channel ID (invite @Scout there first)",children:i.jsx(ZS,{value:t.notify.target,onSave:p=>s({notify:{target:p}})})}),i.jsxs("div",{className:"choice-row compact",children:[i.jsx(mt,{on:t.notify.detail==="full",title:"Full questions",onClick:()=>s({notify:{detail:"full"}})}),i.jsx(mt,{on:t.notify.detail==="titles-only",title:"Titles only",onClick:()=>s({notify:{detail:"titles-only"}})})]})]}),i.jsx("div",{className:"choice-row compact",children:LS.map(p=>i.jsx(mt,{on:c.has(p),title:qS[p],onClick:()=>m(p)},p))})]}),i.jsx(Js,{className:"dim",parts:[`${t.command} decide`,`${t.command} status`,`${t.command} inbox`,"Save as decision on any message"]})]})}function Wo(e){return i.jsx("a",{className:`btn ${e.primary?"primary":""}`,href:hs(e.href,["slack:"]),target:"_blank",rel:"noreferrer",onClick:e.onClick,children:e.children})}function jm({tries:e,dropped:t}){const s=e.map(o=>`${o.name?`@${o.name}`:o.id} (${o.count})`).join(", ");return t?i.jsxs("div",{className:"test-line warn",children:["Your last code was dropped after too many wrong tries, from ",s,". If that wasn't you, someone in the workspace is guessing. Get a new code."]}):i.jsxs("div",{className:"test-line warn",children:["Wrong code typed in Slack by ",s]})}const n1=e=>Math.max(1,Math.ceil((e-Date.now())/6e4));function s1(e){var v;const{s:t,set:s}=e,o=!t.ownerRedo,[a,c]=y.useState(),[u,h]=y.useState(),m=()=>void Jt.ownerCode().then(k=>{h(void 0),c(k),s(k.status)},k=>h(k.message)),p=a&&((v=t.ownerCode)==null?void 0:v.expiresAt)===a.expiresAt?a:void 0;return p?i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:["In Slack, open Scout's ",i.jsx("b",{children:"Home"})," tab → ",i.jsx("b",{children:"Enter code"}),", and type:"]}),i.jsx("output",{className:"sl-code","aria-label":"One-time code",children:p.code}),i.jsxs("div",{className:"sl-actions",children:[i.jsx(Wo,{primary:!0,href:t.links.home,children:"Open Scout in Slack"}),t.links.homeWeb&&i.jsx(Wo,{href:t.links.homeWeb,children:"Open in browser"}),i.jsx(P,{variant:"ghost",onClick:m,children:"New code"})]}),u&&i.jsxs("div",{className:"test-line alert",children:["✕ ",u]}),i.jsx(Js,{className:"dim",parts:["Works once",`Valid for ${n1(p.expiresAt)} min`]}),t.ownerCode&&t.ownerCode.wrongTries.length>0&&i.jsx(jm,{tries:t.ownerCode.wrongTries}),i.jsx(Jc,{s:t})]}):i.jsxs(i.Fragment,{children:[o&&i.jsx("p",{children:"Show Scout which Slack account is yours. Get a code here, then enter it in Scout's Home tab in Slack. Until then Scout sends nothing to anyone."}),i.jsx("div",{className:"sl-actions",children:i.jsx(P,{variant:"primary",onClick:m,children:"Get a code"})}),t.ownerCodeDropped&&i.jsx(jm,{tries:t.ownerCodeDropped.by,dropped:!0}),a&&!t.ownerCodeDropped&&i.jsx("div",{className:"test-line alert",children:"That code expired or was used up. Get a new one."}),u&&i.jsxs("div",{className:"test-line alert",children:["✕ ",u]}),i.jsx(Jc,{s:t})]})}const i1=e=>e.displayName&&e.displayName!==e.name?`shown as “${e.displayName}”`:void 0,r1={true:"Its Slack email is your git email",false:"Its Slack email is not your git email"};function o1(e){var v,k;const{s:t,who:s,set:o}=e,[a,c]=y.useState(),u=x=>c(x.message),h=s.name?`@${s.name}`:s.id,m=(k=(v=t.workspace)==null?void 0:v.url)==null?void 0:k.replace(/^https?:\/\/|\/$/g,""),p=s.gitEmail===void 0?void 0:r1[`${s.gitEmail}`];return i.jsxs(i.Fragment,{children:[i.jsx("p",{children:"A Slack account entered your code. Check that this is the account you just typed the code into, in your workspace."}),i.jsxs("div",{className:"sl-who",children:[i.jsx("b",{className:"t-row-title",children:h}),i.jsx(V,{parts:[i1(s),s.realName,t.workspace&&`${t.workspace.name} workspace`,m]}),i.jsx(V,{parts:[{text:s.id,code:!0},p]})]}),i.jsxs("div",{className:"sl-actions",children:[i.jsx(P,{variant:"primary",onClick:()=>void Jt.confirmOwner(s.id).then(o,u),children:"Yes, this is me"}),i.jsx(P,{onClick:()=>void Jt.resetOwner().then(o,u),children:"Not me"})]}),a&&i.jsxs("div",{className:"test-line alert",children:["✕ ",a]}),i.jsx(Js,{className:"dim",parts:["Nothing is sent in Slack until you confirm"]})]})}const a1={home:"was the first to click “This is me” in Slack","git-email":"has a Slack email that matched your git email"};function l1({redo:e}){const t=e.was.name?`@${e.was.name}`:e.was.id;return i.jsxs("p",{className:"sl-redo",children:["Set your Slack owner again. An earlier version of ",J.name," made ",t," the owner because that account"," ",a1[e.via],". Anyone in the workspace could have done that, so Scout stopped sending questions and approvals there. Get a code below and enter it from your own Slack account."]})}function c1(e){const{s:t,set:s}=e;return t.pendingOwner?i.jsx(o1,{s:t,who:t.pendingOwner,set:s}):i.jsxs(i.Fragment,{children:[t.ownerRedo&&i.jsx(l1,{redo:t.ownerRedo}),i.jsx(s1,{s:t,set:s})]})}function u1({s:e,n:t}){const s=d1(e,t);return s?i.jsx("span",{className:"t-meta",children:s}):null}function d1(e,t){var o;if(t===3)return e.setup.appId&&`app ${e.setup.appId}`;if(t===4)return e.workspace&&`${e.workspace.name} · @${((o=e.bot)==null?void 0:o.name)??"scout"}`;const s=e.owners[0];if(t===5&&s)return`owner ${s.name??s.id}`;if(t===5&&e.pendingOwner)return"waiting for you to confirm";if(t===5&&e.ownerRedo)return"set it again"}const Nm=[{n:1,title:"Create your app"},{n:2,title:"Workspace"},{n:3,title:"App token"},{n:4,title:"Install"},{n:5,title:"Owner"}],Eu=(e,t)=>e===t||e===2&&t===3,Tg=(e,t)=>e==="done"||typeof e=="number"&&t<e&&!Eu(e,t);function Sm(e,t){return Tg(e,t)?"done":Eu(e,t)?"cur":""}const h1=/^(xapp-|xoxb-|xoxp-|xoxe)/,f1=typeof navigator<"u"&&/Mac|iP(hone|ad)/.test(navigator.platform)?"⌘V":"Ctrl+V";function m1(e){const t=y.useRef(e);t.current=e;const[s,o]=y.useState(!1);return y.useEffect(()=>{let a="";const c=(m,p)=>{const v=m.trim();return!h1.test(v)||!p&&v===a?!1:(a=v,t.current(v,p),!0)},u=m=>{var p;c(((p=m.clipboardData)==null?void 0:p.getData("text"))??"",!0)&&m.preventDefault()},h=async()=>{if(document.visibilityState==="visible")try{const m=await navigator.permissions.query({name:"clipboard-read"});o(m.state==="granted"),m.state==="granted"&&c(await navigator.clipboard.readText(),!1)}catch{}};return h(),document.addEventListener("paste",u),window.addEventListener("focus",h),document.addEventListener("visibilitychange",h),()=>{document.removeEventListener("paste",u),window.removeEventListener("focus",h),document.removeEventListener("visibilitychange",h)}},[]),s}function p1(e){const{s:t,set:s}=e,[o,a]=y.useState(),[c,u]=y.useState(!1),[h,m]=y.useState(!1),p=(j,A)=>{const C=US(j);A&&C&&!t.setup.botToken&&window.open(FS.install(C),"_blank")&&m(!0),u(!0),Jt.token(j).catch(R=>({ok:!1,error:R.message,status:t})).then(R=>{u(!1),a(R),s(R.status)})},k=m1(p)?"come back to this tab":`press ${f1} here`,x=t.step,N=j=>{if(!o)return null;const A=!o.ok&&j===4==(x===4);return o.kind===(j===4?"bot":"app")||A?i.jsx("div",{className:`test-line ${o.ok?"ok":"alert"}`,children:g1(o)}):null},S={1:i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:["Create your app in Slack. It opens filled in from a manifest, so your app already has the ",t.command," command, Save as decision and Socket Mode."]}),i.jsx("div",{className:"sl-actions",children:i.jsx(Wo,{primary:!0,href:t.links.create,onClick:()=>void Jt.created().then(s,()=>{}),children:"Create your Slack app"})})]}),2:i.jsxs("p",{children:["In Slack: pick your workspace → ",i.jsx("b",{children:"Next"})," → ",i.jsx("b",{children:"Create"}),". Your app lives in the workspace you pick."]}),3:i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:["Give your app a token so Scout can connect from this machine. On the page Slack just opened:"," ",i.jsx("b",{children:"App-Level Tokens"})," → ",i.jsx("b",{children:"Generate Token and Scopes"})," → name it ",i.jsx("code",{children:"teamtrail"})," → add"," ",i.jsx("code",{children:"connections:write"})," → ",i.jsx("b",{children:"Generate"})," → ",i.jsx("b",{children:"Copy"}),", then ",k,"."]}),i.jsx("div",{className:"sl-actions",children:i.jsx(Yc,{busy:c,placeholder:"xapp-…",onToken:p})}),N(3),i.jsx(Js,{className:"dim",parts:["Waiting for the app-level token",t.links.create&&i.jsx("a",{href:hs(t.links.create),target:"_blank",rel:"noreferrer",children:"Open the manifest again"},"again")]})]}),4:i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:["Install your app so Scout can post and DM you."," ",h?"Slack's install page is open in a new tab: ":i.jsxs(i.Fragment,{children:[i.jsx("b",{children:"Install to workspace"})," →"," "]}),i.jsx("b",{children:"Allow"})," → copy the ",i.jsx("b",{children:"Bot User OAuth Token"})," (starts with ",i.jsx("code",{children:"xoxb-"}),"), then ",k,"."]}),i.jsxs("div",{className:"sl-actions",children:[i.jsx(Wo,{primary:!h,href:t.links.install,children:h?"Open install page again":"Install to workspace"}),i.jsx(Yc,{busy:c,placeholder:"xoxb-…",onToken:p})]}),N(4)]}),5:i.jsx(c1,{s:t,set:s})};return i.jsxs(Bt,{tone:"inset",className:"slack-setup",children:[i.jsxs("p",{className:"sl-own",children:["You create your own Scout app in your Slack workspace. It runs from this machine over Socket Mode; nothing goes through ",J.name,". Prefer one click? Add to Slack is coming with ",J.name," Cloud."]}),i.jsx("ol",{className:"pipeline sl-pipeline","aria-label":"Slack setup",children:Nm.map(j=>i.jsxs("li",{className:Sm(x,j.n),children:[i.jsx("i",{}),i.jsxs("span",{children:[j.n," ",j.title]})]},j.n))}),i.jsx("ol",{className:"sl-steps",children:Nm.map(j=>{const A=Tg(x,j.n),C=Eu(x,j.n);return i.jsxs("li",{className:Sm(x,j.n),children:[i.jsxs("div",{className:"sl-step-h",children:[i.jsx("span",{className:"sl-n",children:A?"✓":j.n}),i.jsx("b",{children:j.title}),A&&i.jsx(u1,{s:t,n:j.n})]}),C&&i.jsx("div",{className:"sl-step-b",children:S[j.n]})]},j.n)})})]})}function g1(e){var t,s;return e.ok?e.kind==="app"?`✓ Socket Mode reachable · app ${e.status.setup.appId}`:`✓ Installed in ${(t=e.status.workspace)==null?void 0:t.name} as @${((s=e.status.bot)==null?void 0:s.name)??"scout"}`:`✕ ${e.error}`}function Au(e=0){const[t,s]=y.useState(),o=y.useCallback(()=>Jt.get().then(s,()=>s(null)),[]);return y.useEffect(()=>{if(o(),!e)return;const a=setInterval(()=>void o(),e);return()=>clearInterval(a)},[o,e]),[t,s]}function v1(e){const[t,s]=Au(3e3),[o,a]=y.useState(!1),c=y.useRef(null);if(y.useEffect(()=>{var m;e.focus&&t&&((m=c.current)==null||m.scrollIntoView({block:"start"}))},[e.focus,!!t]),!t)return null;const u=t.step==="done",h=m=>Jt.update(m).then(s,()=>{});return i.jsxs("div",{ref:c,className:"slack-settings",children:[i.jsx(YS,{s:t,setup:o,onSetup:a,onToggle:()=>void h({enabled:!t.enabled}),onRemoved:m=>{s(m),a(!1)}}),!u&&(o||t.step!==1)&&i.jsx(p1,{s:t,set:s}),o&&u&&t.state==="auth-error"&&i.jsxs(Bt,{tone:"inset",className:"slack-setup",children:[i.jsx("p",{children:"Generate a new app-level token or reinstall the app, then paste the new token. Settings and the owner are kept."}),i.jsx(HS,{set:s})]}),u&&i.jsx(t1,{s:t,set:s,patch:m=>void h(m)})]})}function k1(e){if(e.enabled){if(e.state==="auth-error")return{label:"Slack disconnected",why:e.error??"Slack rejected the tokens"};if(e.pendingOwner)return{label:"Confirm Slack owner",why:"Nothing is sent in Slack until you confirm which account is yours"};if(e.ownerRedo)return{label:"Set Slack owner again",why:"Nothing is sent in Slack until you set the owner with a code"}}}function y1(e){const{api:t,rt:s,brief:o}=e,{snap:a,actions:c}=t,[u]=Au(15e3),h=ri(),m=u?k1(u):void 0;return i.jsx(CS,{repo:e.repo,snaps:t.allSnaps,map:a==null?void 0:a.map,activity:t.activity,health:t.health,onNewTrail:e.onNewTrail,trackerLabel:s.adapter.label.toLowerCase(),onSelectMap:c.selectMap,onToggleMode:()=>a&&c.setMode(a.map.mode==="plan-only"?"plan+execute":"plan-only"),onSettings:e.onSettings,onToggleTheme:e.onToggleTheme,attention:e.attention,slackAlert:m,onSlack:e.onSlack,decisions:t.decisions.length,decisionsOpen:e.decisionsOpen,onDecisions:e.onDecisions,onStats:e.onStats,knowledge:h.attention,knowledgeOpen:h.open,onKnowledge:()=>h.setOpen(!h.open),briefingOpen:o.shown,briefingStatus:o.status,onBriefing:()=>o.shown?o.dismiss():o.open()})}function w1(e){const{m:t}=e,s=t.from==="human"?"human":"agent";return i.jsxs("div",{className:`msg from-${t.from} voice-${s}`,children:[i.jsx(V,{parts:[t.author,rx(t),ua(t.at)]}),i.jsx("div",{className:"msg-text",children:t.text}),e.stillOpen&&i.jsx("button",{className:"answer-this t-meta",onClick:e.onAnswerThis,children:"Answer this"})]})}function x1(e){const{ticket:t}=e;return i.jsxs("div",{className:"comms-ticket",children:[i.jsxs("div",{className:"t-title",title:t&&`${t.key} ${t.title}`,children:[i.jsx("span",{className:"key",children:t==null?void 0:t.key})," ",t==null?void 0:t.title]}),i.jsx(V,{parts:[e.trail,e.agent]})]})}function j1({id:e,text:t}){const[s,o]=y.useState(),a=s!==e;return i.jsx(la,{size:1,framed:!1,state:a?"speaking":"alert",speaking:a?t.slice(0,60):void 0,onSpeakEnd:()=>o(e),className:"q-avatar"})}function N1(e){const{q:t}=e;return i.jsxs("div",{className:"msg open-q",children:[i.jsx(V,{parts:[t.agent,ua(t.at)]}),i.jsx(j1,{id:e.chatId??t.id,text:t.text}),i.jsx("div",{className:"msg-text",children:t.text}),t.stakes&&i.jsx(V,{parts:[{text:t.stakes,strong:!0}]})]})}function S1(e){var t;return(t=e.options)!=null&&t.length?i.jsx("div",{className:"suggest",children:e.options.map(s=>i.jsx("button",{className:"chip",onClick:()=>e.onPick(s),children:s},s))}):null}function b1(e){const{activity:t,sessionId:s}=e,[o,a]=y.useState(""),[c,u]=y.useState(),h=y.useRef(null),m=y.useRef(null),p=t.sessions.find(L=>L.id===s),v=t.chats.filter(L=>L.sessionId===s),k=KN(t.pending,s,c??e.questionId),x=new Set(t.pending.filter(L=>L.sessionId===s).map(L=>L.id)),N=v.find(L=>!!k&&L.questionId===k.id),S=v.filter(L=>L!==N),j=p?e.snaps[p.mapId]:void 0,A=p!=null&&p.ticketId?j==null?void 0:j.tickets.find(L=>L.id===p.ticketId):void 0;y.useEffect(()=>{const L=h.current;L==null||L.scrollTo({top:L.scrollHeight,behavior:"smooth"})},[S.length,k==null?void 0:k.id]),y.useEffect(()=>{var L;k&&!e.onBack&&((L=m.current)==null||L.focus({preventScroll:!0}))},[k==null?void 0:k.id,e.onBack]);const C=L=>{!k||!L.trim()||(e.onAnswer(k.id,L.trim()),a(""))},R=C1(p,!!k);return i.jsxs("div",{className:`comms ${k?"asking":""}`,children:[i.jsx(Et,{title:"HITL line",right:p?i.jsx("span",{className:`status ${k?"urgent":""}`,children:R}):void 0,children:e.onBack&&i.jsx("button",{className:"back",onClick:e.onBack,"aria-label":"Back to inbox",children:"‹ Inbox"})}),p?i.jsxs(i.Fragment,{children:[i.jsx(x1,{ticket:A,trail:j==null?void 0:j.map.title,agent:p.agent}),i.jsx("div",{className:"comms-log",ref:h,children:S.map(L=>i.jsx(w1,{m:L,stillOpen:!!L.questionId&&x.has(L.questionId),onAnswerThis:()=>u(L.questionId)},L.id))}),k&&i.jsx(N1,{q:k,chatId:N==null?void 0:N.id}),i.jsx(S1,{options:k==null?void 0:k.suggestions,onPick:C}),i.jsx(ga,{ref:m,className:"comms-input",value:o,onValueChange:a,onSubmit:C,disabled:!k,placeholder:k?"Answer":""})]}):i.jsx(Ae,{children:"No conversation"})]})}function C1(e,t){return e?t?"Your answer is needed":dn(e)?`${e.agent} is working…`:e.status==="done"?"Resolved · ticket closed":"Session ended":""}async function $1(e){const[t,s]=e.ref.split("+"),o=await fetch(`${je()}/workspaces/integration`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e.mapId,a:t,b:s})});return o.ok?void 0:(await o.json().catch(()=>({}))).error??`Adding failed (${o.status})`}function T1({item:e}){const[t,s]=y.useState(!1),[o,a]=y.useState(),c=()=>{s(!0),a(void 0),$1(e).then(a,u=>a(u.message)).finally(()=>s(!1))};return i.jsxs("div",{className:"att-action",children:[i.jsx(P,{size:"sm",className:"integration-add",disabled:t,onClick:c,children:t?"Adding…":"Add integration ticket"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}async function E1(e,t){const s=e.ref.slice(0,e.ref.lastIndexOf(":")),o=await fetch(`${je()}/trackers/settings/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e.mapId,issueId:s,choice:t})});return o.ok?void 0:(await o.json().catch(()=>({}))).error??`Saving failed (${o.status})`}function A1({item:e}){const[t,s]=y.useState(!1),[o,a]=y.useState(),c=u=>{s(!0),a(void 0),E1(e,u).then(a,h=>a(h.message)).finally(()=>s(!1))};return i.jsxs("div",{className:"att-action",children:[i.jsx(P,{size:"sm",disabled:t,onClick:()=>c("stricter"),children:"Keep stricter"}),i.jsx(P,{size:"sm",disabled:t,onClick:()=>c("as-is"),children:"Accept as is"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function I1({item:e}){return e.kind==="integration"?i.jsx(T1,{item:e}):e.kind==="tracker-settings"&&e.ref.includes(":")?i.jsx(A1,{item:e}):null}const M1=/(\S*\/\S*|#\d+)/g;function R1({reasons:e}){return e.length?i.jsx("span",{className:"reason-line",children:e.map((t,s)=>i.jsxs("span",{children:[s>0&&i.jsx("span",{className:"sep",children:" · "}),t.split(M1).map((o,a)=>a%2===1?i.jsx("span",{className:"t-code",children:o},a):o)]},t))}):null}const Eg={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"},O1={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"},L1=[{minutes:30,label:"30 min"},{minutes:120,label:"2 hours"},{minutes:1440,label:"Tomorrow"}],P1=["blocked","flag","stalled","policy","reroute","overlap","integration","model"];function Ag(e,t){return t||e.urgency==="blocking"?"urgent":P1.includes(e.kind)?"attention":"neutral"}const _1=[/^marked blocking$/,/^fyi\b/,/^soon\b/,/^waiting \d/,/^answer together/,/questions from /];function Ig(e){return e.reasons.filter(t=>!_1.some(s=>s.test(t)))}function D1(e){const{item:t,snap:s}=e,o=s==null?void 0:s.tickets.find(h=>h.id===t.ticketId),a=t.kind==="question"&&t.agent?`${t.agent} asks`:Eg[t.kind],c=[];t.urgency==="blocking"&&c.push({text:"Blocking",urgent:!0,className:"urgency-tag"}),c.push({text:a,strong:!0});const u=o&&z1(t.title,o);return u&&c.push(u),e.otherTrail&&c.push((s==null?void 0:s.map.title)??t.mapId),c}function z1(e,t){if(!e.includes(t.key))return e.includes(t.title)?{text:t.key,code:!0}:`${t.key} ${t.title}`}function B1(e){const[t,s]=y.useState(!1),o=a=>{s(!1),a()};return i.jsxs("span",{className:"snooze",children:[i.jsx("button",{type:"button",className:"snooze-btn","aria-expanded":t,"aria-label":`Later: ${e.title}`,onClick:()=>s(!t),children:"Later"}),t&&i.jsxs("span",{className:"snooze-menu",role:"menu",children:[L1.map(a=>i.jsx("button",{type:"button",role:"menuitem",onClick:()=>o(()=>e.onSnooze(a.minutes)),children:a.label},a.minutes)),e.canDismiss&&i.jsx("button",{type:"button",role:"menuitem",onClick:()=>o(e.onDismiss),children:"Set aside"})]})]})}const F1=15e3;function U1(e){const{item:t}=e,s=t.title.split(`
141
+ `)[0],o=Ig(t),a=e.now-t.since<F1;return i.jsx(Ce,{as:"li",className:`att-item k-${t.kind} u-${t.urgency} ${e.selected?"sel":""} ${a?"incoming":""}`,edge:Ag(t,e.interrupting),selected:e.selected,title:s,titleText:t.title,context:i.jsx(V,{parts:D1({item:t,snap:e.snap,otherTrail:e.otherTrail})}),detail:o.length>0&&i.jsx(R1,{reasons:o}),detailText:o.join(`
142
+ `),trailing:hn(e.now-t.since),onOpen:e.onOpen,actions:i.jsx(B1,{title:t.title,canDismiss:hj(t),onSnooze:e.onSnooze,onDismiss:e.onDismiss}),below:i.jsx(I1,{item:t})})}function W1(e){const t=[];for(const s of e){const o=t.at(-1);(o==null?void 0:o.key)===s.batchKey?o.items.push(s):t.push({key:s.batchKey,kind:s.kind,mapId:s.mapId,items:[s]})}return t}const H1={question:"inbox-list",approval:"inbox-list approvals"};function K1(e){const{batch:t}=e,s=t.items.length>1,o=t.kind==="question"?"answer together":"review together",a=[`${t.items.length} ${O1[t.kind]}`,e.trail,o].filter(Boolean);return i.jsxs("div",{className:`att-batch ${s?"many":""}`,children:[s&&i.jsx("span",{className:"batch-head t-label",children:a.join(" · ")}),i.jsx("ul",{className:`att-list ${H1[t.kind]??""}`,children:e.children})]})}function V1(e,t){e.ticketId?t.openTicket(e.mapId,e.ticketId):t.selectTrail(e.mapId)}function Mg(e,t){switch(e.kind){case"question":return t.openQuestion(e.ref);case"approval":case"blocked":case"policy":case"flag":case"stalled":case"hitl-ready":case"overlap":case"integration":case"model":case"tracker-settings":return V1(e,t);case"knowledge":return t.openKnowledge();case"brief":return t.openBrief(e.mapId);case"reroute":case"reroute-suggested":return t.openReroute(e);case"guide":case"guide-checks":return t.openGuides();case"delivery":return t.openConnector(e.ref);case"trust":return t.openApprovals();default:return e.kind}}function G1(e){const t=Xt(1e3),{view:s}=e;if(!s.items.length)return i.jsx(qn,{title:"Nothing waiting on you",hint:s.hidden?`${s.hidden} snoozed or set aside. They come back when the snooze ends.`:"When an agent needs your call, it lands here, most important first."});const o=Object.keys(e.snaps).length>1,a=h=>o&&h!==e.currentMapId,c=new Set(s.interrupting),u=h=>{var m;return(m=e.pending.find(p=>p.id===h))==null?void 0:m.sessionId};return i.jsx("div",{className:"attention-queue",children:W1(s.items).map(h=>{var m;return i.jsx(K1,{batch:h,trail:a(h.mapId)?(m=e.snaps[h.mapId])==null?void 0:m.map.title:void 0,children:h.items.map(p=>i.jsx(U1,{item:p,snap:e.snaps[p.mapId],otherTrail:a(p.mapId)&&h.items.length<2,selected:p.kind==="question"&&u(p.ref)===e.selected,interrupting:c.has(p.id),now:t,onOpen:()=>Mg(p,e.handlers),onSnooze:v=>e.onSnooze(p.id,v),onDismiss:()=>e.onDismiss(p.id)},p.id))},h.key)})})}const bm={label:"Focus for 1 hour",change:{kind:"for",minutes:60}};function q1(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},bm];case"off":return[{...bm,primary:!0},{label:"Focus for 3 hours",change:{kind:"for",minutes:180}}];default:return e}}const Cm=e=>ua(e).slice(0,5),Q1=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function Y1(e){const t=`${e.items.length} waiting on you`;return e.heldBack===0?`Nothing held back · ${t}`:`${Q1(e.heldBack,"item")} would interrupt you · ${t}`}function Cc(e){const t=e.prefs.focus;return t?`Quiet hours ${t.from}–${t.to}`:"No quiet hours set"}const $m=e=>`Items scoring ${e.policy.value.interrupt} or more interrupt you · ${e.items.length} waiting on you`;function J1(e){const t=e.focus;switch(t.kind){case"manual":case"hours":{const s=Cm(t.until),o=t.kind==="manual"?"Switched on here":Cc(e);return{word:"on",until:s,on:!0,title:`Focus is on until ${s}`,reason:o,detail:Y1(e)}}case"paused":{const s=Cm(t.until),o=`Quiet hours paused until ${s}`;return{word:"paused",until:s,on:!1,title:o,reason:Cc(e),detail:$m(e)}}case"off":return{word:"off",until:"",on:!1,title:"Focus is off",reason:Cc(e),detail:$m(e)};default:return t}}const X1="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 Z1(e){const{view:t}=e,s=J1(t),o=t.focus.kind,a=i.jsxs("span",{className:Ge("focus-state",`focus-${o}`),children:[i.jsx("i",{className:"focus-dot","aria-hidden":"true"}),i.jsxs("span",{className:"focus-label",children:["Focus",i.jsxs("span",{className:"focus-word",children:[" ",s.word]})]}),s.until&&i.jsxs("span",{className:"focus-until",children:[i.jsx("span",{className:"sep",children:" · "}),i.jsx("span",{className:"focus-until-word",children:"until "}),s.until]})]});return i.jsx(Sg,{className:"focus-menu",label:a,role:"dialog",tip:s.title,ariaLabel:s.title,children:c=>i.jsxs("div",{className:"focus-panel","aria-label":"Focus",children:[i.jsxs("div",{className:"focus-panel-head",children:[i.jsx("span",{className:"t-row-title",children:s.title}),i.jsx(ni,{text:X1})]}),i.jsx(V,{parts:[s.reason]}),i.jsx(V,{className:"focus-held",parts:[s.detail]}),i.jsxs("div",{className:"focus-panel-actions",children:[q1(t.focus).map(u=>i.jsx(P,{size:"sm",variant:u.primary?"primary":"default",onClick:()=>{c(),e.onChange(u.change)},children:u.label},u.label)),i.jsx(P,{size:"sm",variant:"ghost",onClick:()=>{c(),e.onSettings()},children:"Quiet hours"})]})]})})}function eb(e){const{view:t}=e,s=t.interrupting.length;return i.jsxs("span",{className:"attention-head",children:[i.jsx(Z1,{view:t,onChange:e.onFocus,onSettings:e.onSettings}),s>0&&i.jsxs("span",{className:"waiting-chip interrupting",title:`${s} need you now`,children:[i.jsx(ii,{variant:"alert",size:14}),i.jsx("b",{children:s}),i.jsx("span",{className:"wl",children:" need you now"})]})]})}const Rg=`${je()}/attention`,tb=250;async function Tm(e,t,s){var c;const o=await fetch(`${Rg}${e}`,{method:t,headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),a=await o.json().catch(()=>({}));if(!o.ok)throw new Error(((c=a.errors)==null?void 0:c.join("; "))??a.error??`HTTP ${o.status}`);return a}function Og(e){const[t,s]=y.useState(),[o,a]=y.useState(),[c]=y.useState(ei),u=y.useCallback(()=>{const m=c.start();fetch(Rg).then(p=>p.ok?p.json():void 0).then(p=>p&&m()&&s(p)).catch(()=>{})},[c]);y.useEffect(()=>ti("attention",m=>{c.pushed(),s(JSON.parse(m))}),[c]),y.useEffect(()=>fs(u),[u]),y.useEffect(()=>{const m=setTimeout(u,tb);return()=>clearTimeout(m)},[u,e]);const h=(m,p)=>void Tm(m,"POST",p).then(()=>(a(void 0),u()),v=>a(v.message));return{view:t,error:o,snooze:(m,p)=>h("/snooze",{id:m,minutes:p}),dismiss:m=>h("/dismiss",{id:m}),savePrefs:m=>Tm("/prefs","PUT",m).then(()=>(a(void 0),u(),!0),p=>(a(p.message),!1))}}function nb(e){return e.prefs.channel!=="browser"?!1:typeof Notification<"u"&&Notification.permission==="granted"}function sb(e){const t=new Notification(`${J.name} · needs you`,{body:e.title,tag:e.id});t.onclick=()=>{window.focus(),t.close()}}function ib(e){const t=y.useRef();y.useEffect(()=>{if(!e)return;const s=new Set(e.interrupting),o=t.current;if(t.current=s,!(!o||!nb(e)))for(const a of e.items)s.has(a.id)&&!o.has(a.id)&&sb(a)},[e])}function rb(e){const t=Xt(1e3);return e.items.length?i.jsx("ul",{className:"inbox-list approvals",children:e.items.map(s=>{var c;const o=s.kind!=="approve",a=s.mapId!==e.currentMapId?(c=e.snaps[s.mapId])==null?void 0:c.map.title:void 0;return i.jsx(Ce,{as:"li",edge:o?"attention":"neutral",title:`${o?"Decide":"Approve"}: ${s.title}`,context:i.jsx(V,{parts:[o?"Held":"Verified",{text:s.ticketKey,code:!0},a]}),detail:s.reason,detailText:s.reason,trailing:hn(t-s.at),onOpen:()=>e.onOpen(s.mapId,s.ticketId)},`${s.mapId}/${s.ticketId}`)})}):null}function Em({activity:e}){const t=Xt(1e3),s=px(e);return i.jsxs("div",{className:"hitl-readout",children:[i.jsx(ln,{layout:"inline",label:"Oldest",value:s.oldestAt?Yt(t-s.oldestAt):"—",urgent:!!s.oldestAt&&t-s.oldestAt>6e4,title:"Oldest open question"}),i.jsx(ln,{layout:"inline",label:"Avg wait",value:s.avgWaitMs!==void 0?Yt(s.avgWaitMs):"—",title:`Average wait over ${s.answered} answered questions`}),i.jsx(ln,{layout:"inline",label:"Answered",value:s.answered})]})}function ob(e){const t=Xt(1e3);return e.items.length?i.jsx("ul",{className:"inbox-list",children:e.items.map(s=>{const o=e.snaps[s.mapId],a=o==null?void 0:o.tickets.find(h=>h.id===s.ticketId),c=s.mapId!==e.currentMapId?o==null?void 0:o.map.title:void 0,u=s.text.split(`
143
+ `)[0];return i.jsx(Ce,{as:"li",className:s.sessionId===e.selected?"sel":void 0,edge:s.urgency==="blocking"?"urgent":"neutral",selected:s.sessionId===e.selected,title:u,titleText:s.text,context:i.jsx(V,{parts:[s.urgency==="blocking"&&{text:"Blocking",urgent:!0},`${s.agent} asks`,a&&{text:a.key,code:!0},a==null?void 0:a.title,c]}),trailing:hn(t-s.at),onOpen:()=>e.onOpen(s.sessionId,s.ticketId)},s.id)})}):i.jsx(qn,{title:"Nothing waiting on you",hint:"When an agent needs your call, its question lands here."})}const ab={pass:"Passed",fail:"Failed",error:"Could not run",interrupted:"Interrupted"},sr={off:"Off",checks:"Checks","checks+review":"Checks + review","checks+review+human":"Checks + review + you"},Lg={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."},lb=e=>e.exitCode===0&&!e.timedOut&&!e.error;async function Am(e){const t=await e.json().catch(()=>({}));if(!e.ok)throw new Error(t.error??`HTTP ${e.status}`);return t}const $o=`${je()}/verification`,lr={ticket:(e,t)=>fetch(`${$o}/ticket?mapId=${encodeURIComponent(e)}&ticketId=${encodeURIComponent(t)}`).then(s=>s.ok?s.json():void 0,()=>{}),inbox:()=>fetch(`${$o}/inbox`).then(e=>e.ok?e.json().then(t=>t.items):[],()=>[]),log:e=>fetch(`${$o}/log?path=${encodeURIComponent(e)}`).then(t=>Am(t)),act:e=>fetch(`${$o}/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(t=>Am(t))};function cb(e){const[t,s]=y.useState([]),o=Object.values(e).map(c=>c.tickets.map(u=>`${u.id}:${u.state}:${u.status??""}`).join()).join("|"),{reload:a}=pt({version:o,load:lr.inbox,show:s});return y.useEffect(()=>Ys.onEvidence(a),[a]),t}function ub(e,t){return{...e,items:e.items.filter(s=>!(s.kind==="brief"&&s.mapId===t))}}function db(e){var h;const t=[...e.activity.pending].sort((m,p)=>m.at-p.at),s=cb(e.snaps),o=(h=e.attention)==null?void 0:h.view,a=o&&e.briefShown?ub(o,e.currentMapId):o,c=a?a.items.length:t.length+s.length,u=i.jsx(Et,{hot:c>0,title:i.jsxs(i.Fragment,{children:[c>0&&i.jsx(ii,{variant:"alert",size:12}),"Waiting on you"]}),count:i.jsx(us,{n:c,urgent:c>0,pop:!0},c)});return a&&e.attention&&e.handlers?i.jsxs("div",{className:"inbox-part",children:[u,i.jsx(Em,{activity:e.activity}),i.jsx(G1,{view:a,snaps:e.snaps,pending:e.activity.pending,currentMapId:e.currentMapId,selected:e.sessionId,handlers:e.handlers,onSnooze:e.attention.snooze,onDismiss:e.attention.dismiss})]}):i.jsxs("div",{className:"inbox-part",children:[u,i.jsx(Em,{activity:e.activity}),i.jsx(rb,{items:s,snaps:e.snaps,currentMapId:e.currentMapId,onOpen:e.onOpenTicket}),(t.length>0||!s.length)&&i.jsx(ob,{items:t,snaps:e.snaps,currentMapId:e.currentMapId,selected:e.sessionId,onOpen:e.onOpenQuestion})]})}function hb(e){const[t,s]=y.useState("list"),[o,a]=y.useState();y.useEffect(()=>{e.convRequest&&s("conv")},[e.convRequest]);const c=(v,k)=>{e.onOpen(v,k),s("conv")},u=v=>{const k=e.activity.pending.find(x=>x.id===v);k&&(a(k.id),c(k.sessionId,k.ticketId))},h=i.jsx(db,{activity:e.activity,snaps:e.snaps,currentMapId:e.currentMapId,sessionId:e.sessionId,attention:e.attention,handlers:e.handlers&&{...e.handlers,openQuestion:u},briefShown:!!e.above,onOpenQuestion:c,onOpenTicket:e.onOpenTicket}),m=i.jsx(b1,{activity:e.activity,snaps:e.snaps,sessionId:e.sessionId,questionId:o,onAnswer:e.onAnswer,onBack:e.layout==="stack"?()=>s("list"):void 0});if(e.layout==="stack")return i.jsx(ze,{className:"zone inbox stack",children:t==="conv"&&e.sessionId?m:i.jsxs("div",{className:"stack-scroll",children:[e.above,h,e.below]})});const p=!!e.activity.sessions.find(v=>v.id===e.sessionId);return i.jsxs(ze,{className:`zone inbox split ${p?"has-conv":""}`,style:{gridArea:"inbox"},children:[i.jsx(Et,{className:"zone-title",icon:"mailbox",title:"Communication",info:"Where your agents reach you: everything waiting on you, ranked with the reasons why, the conversation with the agent that asked, and the tickets coming up next."}),e.above,h,p&&m,e.below]})}function fb(e){var h;const{snap:t}=e,s=t?Zs(t.tickets,t.map.mode):new Map,o={claimed:0,frontier:1},a=((t==null?void 0:t.tickets)??[]).filter(m=>o[s.get(m.id)]!==void 0).sort((m,p)=>o[s.get(m.id)]-o[s.get(p.id)]),c=new Set(e.sessions.filter(xg).map(m=>m.ticketId)),u=((h=e.selection)==null?void 0:h.kind)==="ticket"?e.selection.id:void 0;return i.jsxs("div",{className:"upnext",children:[i.jsx(Et,{title:"Up next",count:i.jsx("span",{className:"n mono-label",children:a.length})}),!t&&i.jsx(Ae,{children:"Ready tickets show here"}),t&&!a.length&&i.jsx(Ae,{children:"Nothing ready"}),t&&a.length>0&&i.jsx("ul",{className:"ticket-list",children:a.map(m=>{const v={state:s.get(m.id),waiting:c.has(m.id),assignee:m.assignee,hitl:rr(m)==="hitl"},k=mb(v);return i.jsx("li",{className:`${u===m.id?"sel":""} st-${pb(v)}`,children:i.jsxs("button",{onClick:()=>e.onSelect({kind:"ticket",id:m.id}),children:[i.jsx("i",{className:"dot"}),i.jsx("span",{className:"key t-code",children:m.key}),i.jsx("span",{className:"ttl t-body",children:m.title}),i.jsx("span",{className:"st-text t-meta",children:k})]})},m.id)})})]})}function mb(e){if(e.waiting)return"waiting on you";if(e.state==="claimed")return e.assignee??"claimed";const t=hg[e.state].toLowerCase();return e.hitl?`${t}, needs you`:t}function pb(e){return e.waiting?"waiting":e.state==="frontier"&&e.hitl?"attention":e.state}function gb(e){const{api:t,nav:s}=e;return i.jsx(hb,{activity:t.activity,snaps:t.allSnaps,currentMapId:t.mapId,sessionId:t.chatSession,layout:e.bp==="mobile"?"stack":"split",convRequest:s.convRequest,onOpen:s.openChat,onAnswer:t.actions.answer,onOpenTicket:s.openTicket,attention:e.attn.attention,handlers:e.attn.handlers,below:i.jsx(fb,{snap:t.snap,sessions:e.scoped.sessions,selection:t.selection,onSelect:s.select}),above:e.above})}function Ho({command:e,label:t="Copy"}){const[s,o]=y.useState(!1);return i.jsxs("span",{className:"agent-cmd",children:[i.jsx("code",{children:e}),i.jsx("button",{type:"button",className:"btn sm","data-tip":"Copy, then paste it in Claude Code or Codex",onClick:()=>void navigator.clipboard.writeText(e).then(()=>{o(!0),setTimeout(()=>o(!1),1500)}),children:s?"Copied":t})]})}const To=[{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"}],vb=9e3;function kb(){const[e,t]=y.useState(0),[s,o]=y.useState(!1);y.useEffect(()=>{if(s)return;const c=setInterval(()=>t(u=>(u+1)%To.length),vb);return()=>clearInterval(c)},[s]);const a=To[e];return i.jsxs("div",{className:"command-bar real",children:[i.jsx(jg,{name:"map"}),i.jsx(Ve,{as:"h2",className:"zone-title-label",children:"Trail map"}),i.jsx(ni,{text:"Every decision ticket in this trail and what blocks what. Click a ticket to see it in Trail step. The strip below sums up progress."}),i.jsxs("div",{className:"hint",onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),onFocus:()=>o(!0),onBlur:()=>o(!1),children:[i.jsx("span",{className:"dim",children:a.text}),a.command&&i.jsx(Ho,{command:a.command})]},e),i.jsxs("button",{type:"button",className:"link hint-next","data-tip":"Next hint","aria-label":"Next hint",onClick:()=>t(c=>(c+1)%To.length),children:[e+1,"/",To.length," ›"]})]})}function yb(e){const t=[{v:"plan+execute",title:"Plan + execute"},{v:"plan-only",title:"Plan only"}];return i.jsx("div",{className:"choice-row",children:t.map(s=>i.jsx(mt,{on:e.value===s.v,title:s.title,onClick:()=>e.onChange(s.v)},s.v))})}function wb({onClose:e,tracker:t,onCreate:s}){const[o,a]=y.useState(),[c,u]=y.useState(!1),[h,m]=y.useState(),[p,v]=y.useState(""),[k,x]=y.useState(""),[N,S]=y.useState(""),[j,A]=y.useState(""),C=[p.trim(),k.trim(),N.trim()].filter(Boolean).join(". ").replace(/"/g,"'");return y.useEffect(()=>{const R=L=>L.key==="Escape"&&e();return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[e]),i.jsx("div",{className:"scrim",onClick:e,children:i.jsxs(ze,{as:"div",className:"dialog",onClick:R=>R.stopPropagation(),children:[i.jsx("header",{children:i.jsx("h2",{className:"t-heading caps",children:"New trail"})}),i.jsx(Ze,{label:"Title",children:i.jsx("input",{value:p,onChange:R=>v(R.target.value),autoFocus:!0})}),i.jsx(Ze,{label:"Destination",children:i.jsx("textarea",{rows:3,value:k,onChange:R=>x(R.target.value),placeholder:"What is true when this trail is done?"})}),i.jsx(Ze,{label:"Notes",children:i.jsx("textarea",{rows:2,value:N,onChange:R=>S(R.target.value)})}),i.jsx(Ze,{label:"Assumptions (optional, one per line)",children:i.jsx("textarea",{className:"new-trail-assumptions",rows:2,value:j,onChange:R=>A(R.target.value),placeholder:"What the plan takes for granted, e.g. The v2 API supports batch writes"})}),i.jsxs("div",{className:"agent-draft",children:[i.jsxs("span",{className:"dim",children:["Paste this in Claude Code or Codex. Scout frames the trail with you there, then charts it here in ",t,"."]}),i.jsx(Ho,{command:`/scout new "${C||"your idea"}"`,label:"Copy command"})]}),o?i.jsxs("div",{className:"agent-draft created",children:[i.jsxs("span",{children:["Trail ",o," is on the map, starting with discovery. To get it moving, run this in Claude Code or Codex:"]}),i.jsx(Ho,{command:"/scout resume",label:"Copy command"})]}):h&&i.jsx("p",{className:"vf-err",children:h}),i.jsxs("footer",{children:[i.jsx(P,{variant:"ghost",onClick:e,children:"Close"}),!o&&i.jsx(P,{variant:"primary",disabled:c||!p.trim()||!k.trim(),"data-tip":"Put the trail on the map now; any agent picks it up with /scout resume",onClick:()=>{u(!0);const R=j.split(`
144
+ `).map(L=>L.trim());s({title:p.trim(),destination:k.trim(),notes:N.trim(),assumptions:R.filter(Boolean)}).then(L=>a(L.key)).catch(L=>m(L.message)).finally(()=>u(!1))},children:"Create trail"})]})]})})}const Im=["Ready when you are","What's the next big idea?","I keep the party on the trail","Describe it, I frame it"],xb=5e3;function jb(){const e=Cu(),[t,s]=y.useState(0),[o,a]=y.useState(!0);return y.useEffect(()=>{if(o)return;const c=setTimeout(()=>{s(u=>(u+1)%Im.length),a(!0)},xb);return()=>clearTimeout(c)},[o]),i.jsxs("div",{className:"floating-scout","aria-hidden":"true",children:[i.jsx(la,{variant:e?"night":"crt",size:3,framed:!1,speaking:o?Im[t]:void 0,onSpeakEnd:()=>a(!1),className:"fm-avatar"}),i.jsx("span",{className:"fm-shadow"})]})}function Nb(e){return i.jsx(wb,{onClose:e.onClose,tracker:e.rt.adapter.label,onCreate:async t=>{const s=await fN(e.rt.adapter,t);return e.onCreated(s.id),s}})}const Sb={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"},Iu=e=>Sb[e];function Mu(e){var t;return((t=e.account)==null?void 0:t.kind)==="user"?e.account.login:void 0}const $c=e=>!!e.auth&&!!Mu(e);function Pg(e,t){const s=Mu(e);return!e.auth||!s?void 0:`Will use ${t||"the repo you pick"} as ${s} (${Iu(e.auth)})`}function bb(e){if(!e.repo)return;const t=Mu(e),s=t?` as ${t}`:"",o=e.auth?`, using ${Iu(e.auth)}`:"";return`Connected to ${e.repo}${s}${o}`}function Cb(e,t){if(!e.pushedAt)return;const s=Math.floor((t-Date.parse(e.pushedAt))/864e5);return s<1?"Pushed today":s<60?`Pushed ${s}d ago`:`Pushed ${Math.floor(s/30)}mo ago`}function $b(e){const{gh:t}=e;if(!t.auth)return null;const s=Pg(t,e.repo);return i.jsxs("div",{className:"gh-identity",children:[s&&i.jsx("span",{className:"t-body",children:s}),i.jsxs("span",{className:"gh-identity-actions",children:[i.jsx("button",{type:"button",className:"btn ghost sm",onClick:e.onUseAnother,children:"Use another token"}),t.auth==="signed-in"&&i.jsx("button",{type:"button",className:"btn ghost sm",onClick:e.onSignOut,title:"Forgets the token on this machine. To revoke it, remove Teamtrail under GitHub → Settings → Applications.",children:"Sign out"})]})]})}const Tb=/^[\w.-]+\/[\w.-]+$/;function Eb(e){const t=e.query.trim().toLowerCase(),o=!!e.detected&&e.repos.every(m=>m.fullName!==e.detected)?[{fullName:e.detected,private:!1},...e.repos]:e.repos,a=[...o.filter(m=>m.fullName===e.detected),...o.filter(m=>m.fullName!==e.detected)],c=t?a.filter(m=>m.fullName.toLowerCase().includes(t)):a,h=Tb.test(e.query.trim())&&c.every(m=>m.fullName.toLowerCase()!==t)?e.query.trim():void 0;return{shown:c.slice(0,e.limit),matches:c.length,typed:h}}function Mm(e){const{repo:t,listed:s}=e,o=t.private?"Private":"Public";return i.jsx(Ce,{as:"li",className:"repo-row",selected:e.selected,title:i.jsx("span",{className:"t-code",children:t.fullName}),context:i.jsx(V,{parts:[e.detected&&{text:"This project's repo",strong:!0},s&&o,s&&Cb(t,e.now),!s&&"Checked when you connect"]}),onOpen:e.onPick})}const Ab=40;function Rm(e){const[t,s]=y.useState(""),o=y.useMemo(()=>Date.now(),[]),a=y.useMemo(()=>new Set(e.repos.map(v=>v.fullName)),[e.repos]),{shown:c,matches:u,typed:h}=Eb({repos:e.repos,detected:e.detected,query:t,limit:Ab}),m=u>c.length?`${u-c.length} more: type to narrow`:"",p=e.truncated?`Your ${e.repos.length} most recently pushed repos`:"";return i.jsxs("div",{className:"repo-picker",children:[i.jsxs("label",{className:"field",children:["Repository",i.jsx("input",{value:t,placeholder:"Search your repos, or type owner/name",spellCheck:!1,"aria-label":"Search repositories",onChange:v=>s(v.target.value)})]}),i.jsxs("ul",{className:"repo-list","aria-label":"Repositories",children:[h&&i.jsx(Mm,{repo:{fullName:h,private:!1},detected:h===e.detected,listed:!1,selected:h===e.value,now:o,onPick:()=>e.onChange(h)}),c.map(v=>i.jsx(Mm,{repo:v,detected:v.fullName===e.detected,listed:a.has(v.fullName),selected:v.fullName===e.value,now:o,onPick:()=>e.onChange(v.fullName)},v.fullName))]}),i.jsx(V,{parts:[!u&&!h&&"No repo matches",m,p]})]})}function Ib(e){const{list:t}=e;if(!t)return i.jsx(si,{label:"Loading your repos…",rows:3,className:"picker-loading"});switch(t.kind){case"ok":return i.jsx(Rm,{repos:t.repos,truncated:t.truncated,detected:t.detectedRepo??e.detected,value:e.value,onChange:e.onChange});case"no-token":return i.jsx(V,{parts:["No GitHub token found"]});case"error":return i.jsxs(i.Fragment,{children:[i.jsx(bu,{what:"Couldn't list your repos",reason:t.error,onRetry:e.onRetry}),i.jsx(Rm,{repos:[],truncated:!1,detected:e.detected,value:e.value,onChange:e.onChange})]});default:return t}}const Mb={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"},Xi=e=>e==="github"||e==="linear";function _g(e){const[t,s]=y.useState(!e.source);return e.source&&!t?i.jsxs("div",{className:"ts-auth",children:[i.jsx("span",{className:"mono-label",children:e.label}),i.jsx("span",{className:"pill on",children:Mb[e.source]}),i.jsx("button",{type:"button",className:"btn ghost sm",onClick:()=>s(!0),children:"Use another"})]}):i.jsxs("label",{className:"field",children:[i.jsxs("span",{className:"ts-label",children:[e.label,e.link&&i.jsx("a",{href:e.link.href,target:"_blank",rel:"noreferrer",children:e.link.text})]}),i.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,value:e.value,placeholder:e.placeholder,onChange:o=>e.onChange(o.target.value)})]})}function Rb(e){const[t,s]=y.useState(!1),o=()=>{var a;return void((a=navigator.clipboard)==null?void 0:a.writeText(e.code).then(()=>s(!0),()=>{}))};return i.jsxs("div",{className:"gh-device",children:[i.jsx("span",{className:"t-label",children:"Enter this code on GitHub"}),i.jsxs("div",{className:"gh-device-row",children:[i.jsx("code",{className:"gh-device-code t-code","aria-label":"Your code",children:e.code}),i.jsx(P,{size:"sm",variant:"ghost",onClick:o,children:t?"Copied":"Copy"})]}),i.jsxs("div",{className:"gh-device-row",children:[i.jsx("a",{className:"btn primary",href:hs(e.href),target:"_blank",rel:"noreferrer",onClick:o,children:"Open GitHub"}),i.jsx(P,{size:"sm",variant:"ghost",onClick:e.onCancel,children:"Cancel"})]}),i.jsx(si,{label:"Waiting for you to approve on GitHub…"})]})}function Ob(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 Lb(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 zt=Wj(je());function Zi(e,t){e({tracker:t});const s=new URL(location.href);s.searchParams.delete("tracker"),location.href=s.toString()}function Pb(e){const[t,s]=y.useState({kind:"idle"}),o=y.useRef(e);o.current=e;const a=t.kind==="code";return y.useEffect(()=>{if(t.kind!=="code")return;let c=!0;const u=setTimeout(()=>void zt.githubSignIn.poll().then(async h=>{c&&(h.kind==="signed-in"&&await o.current(),c&&s(Lb(t,h)))},h=>c&&s({kind:"ended",reason:h.message})),Math.max(t.interval,1)*1e3);return()=>{c=!1,clearTimeout(u)}},[t]),y.useEffect(()=>{if(a)return()=>void zt.githubSignIn.cancel().catch(()=>{})},[a]),{state:t,start(){s({kind:"starting"}),zt.githubSignIn.start().then(c=>s(Ob(c)),c=>s({kind:"ended",reason:c.message}))},cancel(){s({kind:"idle"})}}}function _b(e){const{state:t,start:s,cancel:o}=Pb(e.onSignedIn);switch(t.kind){case"idle":return i.jsxs("div",{className:"gh-sign-in",children:[i.jsx(P,{variant:"primary",onClick:s,children:"Sign in with GitHub"}),i.jsx(V,{parts:["No gh login or token needed","the token stays on this machine"]}),i.jsx(V,{parts:["GitHub asks for access to your repos: it has no narrower scope for issues in private repos"]})]});case"starting":return i.jsx(si,{label:"Asking GitHub for a code…"});case"code":return i.jsx(Rb,{code:t.userCode,href:t.verificationUri,onCancel:o});case"ended":return i.jsxs("div",{className:"gh-sign-in",children:[i.jsx(P,{onClick:s,children:"Try again"}),i.jsx(V,{parts:["Didn't sign in",t.reason]})]});default:return t}}function Db(e){var u,h;const{gh:t}=e,s=t.auth&&((u=t.account)==null?void 0:u.kind)==="unknown"?`Found ${Iu(t.auth)}, but GitHub didn't accept it`:"",o=((h=t.account)==null?void 0:h.kind)==="unknown"?t.account.error:"",a=t.auth==="GITHUB_TOKEN"||t.auth==="GH_TOKEN",c=t.signIn.available&&!a;return i.jsxs(i.Fragment,{children:[s&&i.jsx(V,{parts:[s,o]}),c&&i.jsx(_b,{onSignedIn:e.onSignedIn}),c&&i.jsx("span",{className:"t-label gh-or",children:"Or paste a token"}),i.jsx(_g,{source:null,value:e.token,onChange:e.onToken,label:"Token",placeholder:"ghp_… or github_pat_…",link:{href:"https://github.com/settings/personal-access-tokens/new",text:"New token"}}),i.jsxs("span",{className:"t-meta",children:["Or run ",i.jsx("code",{className:"t-code",children:"gh auth login"})," in a terminal; this finds it in a few seconds."]}),i.jsxs("label",{className:"field",children:["Repository",i.jsx("input",{value:e.repo,placeholder:"owner/name",spellCheck:!1,onChange:m=>e.onRepo(m.target.value.trim())})]})]})}function Dg({r:e}){var o,a;if(!e)return null;if(!e.ok)return i.jsxs("div",{className:"test-line alert",children:["✕ ",e.error]});const t=(o=e.rate)!=null&&o.limit?`${(a=e.rate.remaining)==null?void 0:a.toLocaleString()}/${e.rate.limit.toLocaleString()} req`:"";let s="";return e.canWrite===!1?s="read-only":e.canWrite&&(s="read/write"),i.jsxs("div",{className:"test-line ok",children:["✓ ",[e.account,e.target,s,t].filter(Boolean).join(" · ")]})}function Ru(e){const[t,s]=y.useState(),[o,a]=y.useState(0);y.useEffect(()=>{if(s(void 0),!e.enabled)return;let u=!0;return e.load().then(h=>u&&s(h),h=>u&&s(e.failed(h.message))),()=>{u=!1}},[e.enabled,e.key,o]);const c=y.useCallback(()=>a(u=>u+1),[]);return{value:t,retry:c}}function zb(e){const{value:t,retry:s}=Ru({enabled:e.enabled,key:e.auth??"",load:()=>zt.githubRepos(),failed:o=>({kind:"error",error:o})});return{list:t,retry:s}}function zg(e){const t=e.s.github,s=$c(t),[o,a]=y.useState(!s),[c,u]=y.useState(t.repo??t.detectedRepo??""),[h,m]=y.useState(""),[p,v]=y.useState(),[k,x]=y.useState(!1),{list:N,retry:S}=zb({enabled:!o,auth:t.auth});y.useEffect(()=>{s&&!h&&a(!1)},[s]);const j=async()=>{x(!0),v(void 0);try{await zt.connect({active:"github",github:{repo:c,token:o?h:void 0}}),e.onConnected()}catch(U){v({ok:!1,error:U.message}),x(!1)}},A=async()=>{const U=await e.reload();U&&$c(U.github)&&a(!1)},C=async()=>{await zt.githubSignIn.signOut().catch(()=>{});const U=await e.reload();a(!U||!$c(U.github))},L=!!c&&!(!o&&!N)&&(!o||!!h||s);return i.jsxs("div",{className:"card inset tracker-setup",children:[o?i.jsx(Db,{gh:t,token:h,onToken:m,repo:c,onRepo:u,onSignedIn:A}):i.jsxs(i.Fragment,{children:[i.jsx($b,{gh:t,repo:c,onUseAnother:()=>a(!0),onSignOut:()=>void C()}),i.jsx(Ib,{list:N,detected:t.detectedRepo,value:c,onChange:u,onRetry:S})]}),i.jsx(Dg,{r:p}),i.jsx("footer",{children:i.jsx("button",{type:"button",className:"btn primary",disabled:k||!L,onClick:()=>void j(),children:k?"Connecting…":"Connect"})})]})}function Bb(e){return e.line?i.jsxs("div",{className:"gh-identity",children:[i.jsxs("div",{className:"ln-who",children:[i.jsx("span",{className:"t-body",children:e.line}),e.email&&i.jsx(V,{parts:[e.email]})]}),e.onUseAnother&&i.jsx("button",{type:"button",className:"btn ghost sm",onClick:e.onUseAnother,children:"Use another key"})]}):null}const Fb={LINEAR_API_KEY:"LINEAR_API_KEY",stored:"a saved key"},Ou=e=>Fb[e]??e;function ya(e){return(e==null?void 0:e.kind)==="user"?e:void 0}const Ub=e=>!!e.auth&&!!ya(e.viewer);function Bg(e,t){if(e)return t?`${e} / ${t}`:e}function Fg(e){const t=ya(e.viewer);if(!t)return;const s=Bg(e.team,e.project)??"the team you pick",o=e.source?` (${Ou(e.source)})`:"";return`Will use ${s} in ${t.orgName} as ${t.name}${o}`}function Wb(e){const t=Bg(e.teamName??e.teamKey,e.projectName);if(!e.teamId||!t)return;const s=ya(e.viewer),o=e.orgName??(s==null?void 0:s.orgName),a=o?` in ${o}`:"",c=s?` as ${s.name}`:"",u=e.auth?`, using ${Ou(e.auth)}`:"";return`Connected to ${t}${a}${c}${u}`}function Hb(e,t){if(!e.activeAt)return"No issues yet";const s=Math.floor((t-Date.parse(e.activeAt))/864e5);return s<1?"Active today":s<60?`Active ${s}d ago`:`Active ${Math.floor(s/30)}mo ago`}function Kb(e){var a,c;const{ln:t}=e,s=t.auth&&((a=t.viewer)==null?void 0:a.kind)==="unknown"?`Found ${Ou(t.auth)}, but Linear didn't accept it`:"",o=((c=t.viewer)==null?void 0:c.kind)==="unknown"?t.viewer.error:"";return i.jsxs(i.Fragment,{children:[s&&i.jsx(V,{parts:[s,o]}),i.jsx(_g,{source:null,value:e.apiKey,onChange:e.onKey,label:"API key",placeholder:"lin_api_…",link:{href:"https://linear.app/settings/account/security",text:"New key"}}),i.jsxs("span",{className:"t-meta",children:["Or set ",i.jsx("code",{className:"t-code",children:"LINEAR_API_KEY"})," before starting Teamtrail."]})]})}function Vb(e){const{list:t}=e;if(!t)return i.jsx(si,{label:"Loading projects…"});if(t.kind==="error")return i.jsx(bu,{what:"Couldn't list the team's projects",reason:t.error,onRetry:e.onRetry});if(t.kind!=="ok"||!t.projects.length)return null;const s=[{value:"",label:"All projects"},...t.projects.map(o=>({value:o.id,label:o.state?`${o.name} · ${o.state}`:o.name}))];return i.jsxs("label",{className:"field",children:["Project (optional)",i.jsx(dt,{"aria-label":"Project",value:e.value,onChange:e.onChange,options:s})]})}function Gb(e){const t=e.query.trim().toLowerCase(),s=t?e.teams.filter(o=>o.key.toLowerCase().includes(t)||o.name.toLowerCase().includes(t)):e.teams;return{shown:s.slice(0,e.limit),matches:s.length}}function qb(e,t){return t&&e.some(s=>s.id===t)?t:e.length===1?e[0].id:void 0}function Qb(e){const{team:t}=e;return i.jsx(Ce,{as:"li",className:"repo-row team-row",selected:e.selected,title:t.name,context:i.jsx(V,{parts:[{text:t.key,code:!0},Hb(t,e.now)]}),onOpen:e.onPick})}const Yb=40;function Jb(e){const[t,s]=y.useState(""),o=y.useMemo(()=>Date.now(),[]),{shown:a,matches:c}=Gb({teams:e.teams,query:t,limit:Yb}),u=c>a.length?`${c-a.length} more: type to narrow`:"",h=e.truncated?`The first ${e.teams.length} teams`:"",m=e.value?"":"Pick the team your trails go in";return i.jsxs("div",{className:"repo-picker",children:[i.jsxs("label",{className:"field",children:["Team",i.jsx("input",{value:t,placeholder:"Search your teams by key or name",spellCheck:!1,"aria-label":"Search teams",onChange:p=>s(p.target.value)})]}),i.jsx("ul",{className:"repo-list","aria-label":"Teams",children:a.map(p=>i.jsx(Qb,{team:p,selected:p.id===e.value,now:o,onPick:()=>e.onChange(p.id)},p.id))}),i.jsx(V,{parts:[!c&&"No team matches",m,u,h]})]})}function Xb(e){const{list:t}=e;if(!t)return i.jsx(si,{label:"Loading teams…",rows:3,className:"picker-loading"});switch(t.kind){case"ok":return i.jsx(Jb,{teams:t.teams,truncated:t.truncated,value:e.value,onChange:e.onChange});case"no-key":return i.jsx(V,{parts:["Paste a Linear API key to list your teams"]});case"error":return i.jsx(bu,{what:"Couldn't list your teams",reason:t.error,onRetry:e.onRetry});default:return t}}function Zb(e,t){const[s,o]=y.useState(e);return y.useEffect(()=>{const a=setTimeout(()=>o(e),t);return()=>clearTimeout(a)},[e,t]),s}function eC(e){const{value:t,retry:s}=Ru({enabled:e.enabled&&!!e.teamId,key:`${e.teamId}
145
+ ${e.apiKey??""}`,load:()=>zt.linearProjects(e.teamId,e.apiKey),failed:o=>({kind:"error",error:o})});return{list:t,retry:s}}function tC(e){const{value:t,retry:s}=Ru({enabled:e.enabled,key:e.apiKey??"",load:()=>zt.linearTeams(e.apiKey),failed:o=>({kind:"error",error:o})});return{list:t,retry:s}}function nC(e){const t=Zb(e.apiKey.trim(),400),s=e.paste&&t?t:void 0,o=e.paste?!!t:!!e.ln.auth,a=tC({enabled:o,apiKey:s}),c=eC({teamId:e.teamId,apiKey:s,enabled:o}),u=a.list,h=c.list,m=(u==null?void 0:u.kind)==="ok"?u.teams:[],p=o&&!u,v=o&&!!e.teamId&&!h;return{enabled:o,list:u,teams:m,projects:h,loading:p||v,retryTeams:a.retry,retryProjects:c.retry}}function Ug(e){var oe;const t=e.s.linear,s=Ub(t),[o,a]=y.useState(!s),[c,u]=y.useState(""),[h,m]=y.useState(t.teamId??""),[p,v]=y.useState(t.projectId??""),[k,x]=y.useState(),[N,S]=y.useState(!1),{enabled:j,list:A,teams:C,projects:R,loading:L,retryTeams:U,retryProjects:Z}=nC({ln:t,paste:o,apiKey:c,teamId:h});y.useEffect(()=>{s&&!c&&a(!1)},[s]),y.useEffect(()=>{(A==null?void 0:A.kind)==="ok"&&m(qb(A.teams,t.teamId)??"")},[A]);const Q=C.find(D=>D.id===h),W=(R==null?void 0:R.kind)==="ok"?R.projects.find(D=>D.id===p):void 0,ie=(A==null?void 0:A.kind)==="ok"?A.viewer:t.viewer,G=o?null:t.auth,ve=Fg({viewer:ie,team:Q==null?void 0:Q.name,project:W==null?void 0:W.name,source:G}),Le=async()=>{if(Q){S(!0),x(void 0);try{await zt.connect({active:"linear",linear:{teamId:Q.id,teamKey:Q.key,teamName:Q.name,projectId:W==null?void 0:W.id,projectName:W==null?void 0:W.name,apiKey:o?c.trim():void 0}}),e.onConnected()}catch(D){x({ok:!1,error:D.message}),S(!1)}}},$e=D=>{m(D),v("")};return i.jsxs("div",{className:"card inset tracker-setup linear-setup",children:[o&&i.jsx(Kb,{ln:t,apiKey:c,onKey:u}),i.jsx(Bb,{line:ve,email:(oe=ya(ie))==null?void 0:oe.email,onUseAnother:o?void 0:()=>a(!0)}),j&&i.jsx(Xb,{list:A,value:h,onChange:$e,onRetry:U}),Q&&i.jsx(Vb,{list:R,value:p,onChange:v,onRetry:Z}),i.jsx(Dg,{r:k}),i.jsx("footer",{children:i.jsx("button",{type:"button",className:"btn primary",disabled:N||L||!Q,onClick:()=>void Le(),children:N?"Connecting…":"Connect"})})]})}function sC(e){return i.jsxs("div",{className:"c-actions",children:[e.canSwitch&&i.jsx("button",{className:"btn sm",disabled:!e.usable,onClick:e.onSwitch,children:"Switch"}),e.remote&&i.jsx("button",{className:`btn sm ${e.open?"on":""}`,disabled:!e.usable,onClick:e.onToggle,children:e.configured?"Edit":"Connect"})]})}function iC(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 rC(e){const{id:t,active:s,s:o}=e,a=Xi(t),c=s&&o?oC(t,o):void 0;return c&&a?i.jsxs(i.Fragment,{children:[i.jsx(V,{className:"c-who",parts:[c]}),i.jsx(V,{className:"c-trust",parts:iC(t)})]}):c?i.jsx(V,{className:"c-who",parts:[c]}):s&&(t==="markdown"||a)?i.jsx("div",{className:"c-loc",children:e.location}):a&&e.configured&&o?i.jsx("div",{className:"c-loc",children:aC(t,o)}):null}function oC(e,t){if(e==="github")return bb(t.github);if(e==="linear")return Wb(t.linear)}function aC(e,t){return e==="github"?t.github.repo:[t.linear.teamKey,t.linear.projectName].filter(Boolean).join(" · ")}function lC({status:e}){var c,u;if(!e)return null;const t=(c=e.rate)!=null&&c.limit?`${((u=e.rate.remaining)==null?void 0:u.toLocaleString())??"?"}/${e.rate.limit.toLocaleString()} req`:"",s=e.queued?` · ${e.queued} queued`:"",[o,a]=cC(e,s);return i.jsxs("div",{className:`sync-line ${o}`,title:e.error,children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:a}),t&&i.jsx("span",{className:"rate",children:t})]})}function cC(e,t){switch(e.state){case"online":return["ok",`Online · synced ${dg(e.lastSyncAt)}${t}`];case"offline":return["warn",`Offline${t}`];case"rate-limited":return["warn",`Rate limited · resumes ${ar(e.resetAt)}${t}`];case"auth-error":return["alert",`Credentials rejected${t}`];default:return["",`Connecting${t}`]}}function uC(e){const{id:t,active:s,configured:o,s:a}=e,c=Xi(t),u=!c||!!a,h=["card connector",s?"active":"",u?"":"disabled",e.open?"open":""];return i.jsxs("div",{className:h.join(" "),children:[i.jsxs("div",{className:"card-row",children:[i.jsx("b",{className:"choice-title t-row-title",children:e.name}),s&&i.jsx("span",{className:"pill on",children:"Active"})]}),i.jsx(rC,{id:t,active:s,configured:o,location:e.location,s:a}),c&&s&&i.jsx(lC,{status:a==null?void 0:a[t].status}),i.jsx(sC,{canSwitch:!s&&(!c||o),remote:c,usable:u,configured:o,open:e.open,onSwitch:e.onSwitch,onToggle:e.onToggle})]})}function Wg(e=0){const[t,s]=y.useState(),o=y.useCallback(()=>zt.get().then(a=>(s(a),a),()=>(s(null),void 0)),[]);return y.useEffect(()=>{if(o(),!e)return;const a=setInterval(()=>void o(),e);return()=>clearInterval(a)},[o,e]),[t,s,o]}function dC(e){const[t,,s]=Wg(5e3),[o,a]=y.useState(null),c=async h=>{t&&(h==="markdown"||Xi(h))&&await zt.connect({active:h==="markdown"?"markdown":h,...h==="github"&&t.github.repo?{github:{repo:t.github.repo}}:{},...h==="linear"&&t.linear.teamId?{linear:{teamId:t.linear.teamId,teamKey:t.linear.teamKey,teamName:t.linear.teamName,projectId:t.linear.projectId,projectName:t.linear.projectName}}:{}}).catch(()=>{}),Zi(e.update,h)},u=y.useMemo(()=>({github:!!(t!=null&&t.github.repo),linear:!!(t!=null&&t.linear.teamId)}),[t]);return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"connectors",children:Hj.map(h=>{const m=h.id;return i.jsx(uC,{id:m,name:h.name,active:m===e.activeTracker,configured:Xi(m)&&u[m],open:o===m,location:e.location,s:t,onSwitch:()=>void c(m),onToggle:()=>Xi(m)&&a(o===m?null:m)},h.id)})}),t&&o==="github"&&i.jsx(zg,{s:t,reload:s,onConnected:()=>Zi(e.update,"github")}),t&&o==="linear"&&i.jsx(Ug,{s:t,onConnected:()=>Zi(e.update,"linear")})]})}function hC(e,t){const s=e==null?void 0:e.github,o=e==null?void 0:e.linear,a=s&&t!=="github"?Pg(s,s.repo??s.detectedRepo):void 0,c=o&&t!=="linear"?Fg({viewer:o.viewer,team:o.teamName,project:o.projectName,source:o.auth}):void 0;return[{id:"markdown",title:"Local markdown",sub:"Files in .teamtrail/ in this repo"},{id:"github",title:"GitHub Issues",sub:a??"Trails as labelled issues in your repo"},{id:"linear",title:"Linear",sub:c??"Trails and tickets in your Linear team"}]}function Ie(e){return i.jsxs("section",{className:"set-sec",children:[i.jsx(Ve,{as:"h4",children:e.title}),e.children]})}function Hg(e){const t=[{v:"summary",title:"Summary"},{v:"full",title:"Full transcript"}];return i.jsx("div",{className:"choice-row",children:t.map(s=>i.jsx(mt,{on:e.value===s.v,title:s.title,onClick:()=>e.onChange(s.v)},s.v))})}const fC={github:"Checking for a GitHub login…",linear:"Checking for a Linear key…"};function mC(e){var A;const{prefs:t,update:s}=e,[o,,a]=Wg(5e3),[c,u]=y.useState(!1),h=(A=o==null?void 0:o.pending)==null?void 0:A.target.split(":")[0],[m,p]=y.useState(!1);y.useEffect(()=>{h&&!m&&t.tracker!==h&&s({tracker:h})},[h,m,t.tracker,s]);const v=hC(o??void 0,t.tracker),k=t.tracker==="github"||t.tracker==="linear",x=k&&(o==null?void 0:o.active)===t.tracker,N=k&&!x,S=C=>{s({onboarded:!0}),Zi(s,C)},j=async()=>{u(!0);const C=o&&!o.pending;t.tracker==="markdown"&&C&&await zt.connect({active:"markdown"}).catch(()=>{}),s({onboarded:!0}),t.tracker!==e.activeTracker&&Zi(s,t.tracker)};return i.jsx("div",{className:"scrim",children:i.jsxs(ze,{as:"div",className:"dialog onboarding",children:[i.jsx("div",{className:"onb-brand",children:i.jsx(va,{className:"onb-title"})}),i.jsxs("h2",{className:"onb-question t-heading",children:[i.jsx(sS,{className:"voice-badge",size:22}),"Where should your trails live?"]}),i.jsxs(Ie,{title:"Tracker",children:[i.jsx("div",{className:"choice-row",children:v.map(C=>i.jsx(mt,{on:t.tracker===C.id,title:C.title,sub:C.sub,onClick:()=>(p(!0),s({tracker:C.id}))},C.id))}),(o==null?void 0:o.pending)&&i.jsxs("p",{className:"t-meta onb-repo-tracker",children:["This repo keeps its trails in ",o.pending.label,". Connect it here, or keep local files on this machine; the team's choice in the repo isn't changed either way."]}),o===void 0&&k&&i.jsx(si,{label:fC[t.tracker]??"Checking…"}),o&&t.tracker==="github"&&!x&&i.jsx(zg,{s:o,reload:a,onConnected:()=>S("github")}),o&&t.tracker==="linear"&&!x&&i.jsx(Ug,{s:o,onConnected:()=>S("linear")})]}),i.jsx(Ie,{title:"HITL transcript",children:i.jsx(Hg,{value:t.hitlTranscript,onChange:C=>s({hitlTranscript:C})})}),i.jsx("footer",{children:i.jsx(P,{variant:"primary",disabled:c||N,onClick:()=>void j(),children:"Get started"})})]})})}const ir=[{id:"trail",label:"This trail",intro:"How agents work on the trail on screen: its mode, the checks that prove work done, models and guides.",sections:[{id:"mode",title:"Trail mode"},{id:"verification",title:"Verification"},{id:"models",title:"Model matching"},{id:"team",title:"Team"}]},{id:"project",label:"Project",intro:"Where this repo keeps its trails, and the rules every agent working in it follows.",sections:[{id:"approvals",title:"Approvals"},{id:"tracker",title:"Tracker"},{id:"workspaces",title:"Workspaces"},{id:"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 Kg(e){if(e===null)return null;const t=ir.find(a=>a.id===e);if(t)return{group:t.id};const s=ir.find(a=>a.sections.some(c=>c.id===e));if(!s)return{};const o=s.sections.find(a=>a.id===e);return{group:s.id,section:o==null?void 0:o.id}}function pC(){return i.jsxs("p",{className:"sp-elsewhere t-meta",role:"note",children:["You're looking at this Lookout from another device. You can read, answer and approve from here. What changes what runs on the machine ",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 Om={from:"18:00",to:"09:00"};function gC(e){const t=e.focus!==void 0,s=e.focus??Om;return i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Quiet hours"}),i.jsx(P,{size:"sm",on:t,"aria-pressed":t,onClick:()=>e.onChange(t?void 0:Om),children:t?"On":"Off"}),t&&i.jsxs(i.Fragment,{children:[i.jsx("input",{type:"time","aria-label":"Quiet from",value:s.from,onChange:o=>o.target.value&&e.onChange({...s,from:o.target.value})}),i.jsx("span",{className:"t-meta",children:"to"}),i.jsx("input",{type:"time","aria-label":"Quiet until",value:s.to,onChange:o=>o.target.value&&e.onChange({...s,to:o.target.value})})]})]})}const vC=[{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 kC(){typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()}function yC(){const{view:e,error:t,savePrefs:s}=Og(0);if(!e)return null;const o=e.policy.value,a=`${J.dataDir}/attention.json`,c=h=>void s({...e.prefs,...h}),u=typeof Notification<"u"&&Notification.permission==="denied";return i.jsxs(Ie,{title:"Attention",children:[i.jsxs("p",{className:"vf-intro",children:["Everything that needs you is ranked in Waiting on you. Only items scoring ",o.interrupt," or more interrupt you; the rest wait in the queue, and Slack gets them in a digest."]}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Interrupt me by"}),i.jsx(dt,{compact:!0,"aria-label":"Interrupt me by",value:e.prefs.channel,options:vC,onChange:h=>{h==="browser"&&kC(),c({channel:h})}})]}),e.prefs.channel==="browser"&&u&&i.jsx("span",{className:"vf-err",children:"The browser blocks notifications for this page. Allow them in its site settings."}),i.jsx(gC,{focus:e.prefs.focus,onChange:h=>c({focus:h})}),i.jsx("span",{className:"set-hint t-meta",children:"Your channel and quiet hours stay on this machine."}),e.policy.errors.length>0&&i.jsx("ul",{className:"vf-errors",children:e.policy.errors.map(h=>i.jsxs("li",{children:[a,": ",h]},h))}),i.jsx(V,{className:"set-hint",parts:[e.policy.exists?{text:a,code:!0}:"Team defaults",`interrupt at ${o.interrupt}`,o.digestMinutes?`Slack digest every ${o.digestMinutes} min`:"Slack digest off"]}),t&&i.jsx("span",{className:"vf-err",children:t})]})}const wC=[5,15,30,60];function xC(e){const{value:t}=e;return i.jsxs("div",{className:"choice-row compact",children:[i.jsx(mt,{on:!t.enabled,title:"Off",onClick:()=>e.onChange({...t,enabled:!1})}),wC.map(s=>i.jsx(mt,{on:t.enabled&&t.awayMinutes===s,title:`Away ${s} min`,onClick:()=>e.onChange({enabled:!0,awayMinutes:s})},s))]})}const jC={repo:"Committed to the repo",machine:"Only on this machine",browser:"Only in this browser"};function Qe(e){const t=e.storage&&jC[e.storage];return i.jsxs("div",{className:"sp-slot",id:`settings-${e.id}`,children:[e.children,t&&i.jsx(V,{className:"sp-where",parts:[t]})]})}function NC(e){const[t]=Au();return t?i.jsx(Ie,{title:"Slack",children:i.jsx(v1,{focus:e.focus})}):null}function SC({data:e,route:t}){return i.jsxs(i.Fragment,{children:[i.jsx(Qe,{id:"attention",storage:"repo",children:i.jsx(yC,{})}),i.jsx(Qe,{id:"slack",storage:"machine",children:i.jsx(NC,{focus:t.section==="slack"})}),i.jsx(Qe,{id:"trip-report",storage:"browser",children:i.jsx(Ie,{title:"Trip report",children:i.jsx(xC,{value:e.prefs.briefing,onChange:s=>e.update({briefing:s})})})})]})}const bC=[{version:"0.14.0",date:"2026-10-31",items:["Ticket lifecycle in plain words: Ready, Backlog, Working, Done and Cancelled (with Verifying, Rework and Blocked to come with verification)","Every claim, release, return to queue, resolution and rule-out goes through one lifecycle engine that records who, why and when in `.miloops/.events/<mission>.jsonl` (local history, never committed)","Settings → Verification shows the checks in `.miloops/verification.json`: argv commands with timeouts, run without a shell, secrets kept out of their environment. Read-only","Completion is a claim: on missions started with `verification.json` present, an execute or task ticket is only done once its checks pass. A failed check sends it back for Rework with the failing output (agents see it in close_ticket, next_ticket and claim_ticket, and rework comes first in the queue); after 3 failed attempts, or when the checks cannot run, it waits on you as Blocked","New MCP tools `report_completion` and `verification_status`; missions started before verification, and research, grilling and prototype tickets, close exactly as before","Git evidence, no GitHub needed: each claim records HEAD and the uncommitted state, and each completion lists the files changed since then. It flags no changes, overlap with another active ticket, a branch switch or reset, and edits to `verification.json` (which send the ticket to you as Blocked). A pass on code that changed while its checks ran is re-run","Pull request and CI evidence: with `verification.json` and a GitHub token (Settings, `GITHUB_TOKEN` or `gh auth login`), the command center finds each ticket’s PR (its branch `miloops-<mission>-<ticket>`, a `miloops:<mission>#<ticket>` line in the PR body, or a link you set) and flags mismatches: done with the PR still open, PR merged while the ticket is in progress, PR closed unmerged, required checks failing or unknown, PR head not the verified commit. Flags never change a ticket. A CI chip in the header shows sync health and never shows synced after a failed sync"]},{version:"0.13.0",date:"2026-10-31",items:["Crash recovery for claims: an agent’s claim is a lease (15 min by default) that every tool call renews, including waits on your answer","When an agent crashes or goes silent, its ticket goes back to the queue on its own, and the activity log says so; the next agent picks it up from next_ticket or claim_ticket","The returned ticket keeps a handoff comment with the previous agent’s progress notes and decisions, so the next agent resumes instead of starting over","Stalled state on the map, in sessions and in the ticket inspector when a lease is about to run out, with a Release to queue action","Works with GitHub and Linear: the return is an ordinary comment + unassign, queued in the offline outbox like any other write","Set the lease with `miloops mcp --lease-minutes <n>` or `MILOOPS_LEASE_MINUTES`"]},{version:"0.12.0",date:"2026-10-31",items:["Slack: your own MILO app, created from a manifest and connected from your machine over Socket Mode in five guided steps (Settings → Slack or `miloops connect slack`)","Tokens stay in your local credential store next to the GitHub and Linear ones; nothing passes through MILOOPS servers","Agent questions arrive as a Slack DM with answer buttons and a Reply… box; answering there resolves the item in Waiting on you, and answering in the command center closes the DM","Save as decision on any message, or `/milo decide`: the form is prefilled with a summary of the thread, and the decision is recorded with a permalink, resolving the related ticket by default","`/milo status` and `/milo inbox` for the mission at a glance; DMs when a ticket is blocked or a mission is done","Allowed users, notification target and events in Settings → Slack","Slack setup without Paste clicks: press ⌘V / Ctrl+V anywhere, or in Chrome just come back to the tab after copying; pasting the app token opens the install page; MILO recognises you by your git email, so there is nothing to claim in Slack"]},{version:"0.11.0",date:"2026-10-31",items:["GitHub Issues tracker: missions are labelled issues, tickets are sub-issues, blocking uses native issue dependencies",'Linear tracker: missions are labelled issues in a team (optionally one project), tickets are sub-issues, blocking uses "blocks" relations',"Two-way sync: tickets, status, claims, comments, blockers and decisions written from MILOOPS land in the tracker; changes made there show up within seconds","Decisions are posted as comments on their ticket and listed in the mission","Connect from Settings with Test connection; GitHub reuses your gh login or GITHUB_TOKEN, Linear takes a personal API key","Tokens stay on your machine: kept by the local server, never sent to the browser or anywhere else","Offline and rate limits: changes queue and send in order when the tracker answers again; the connector shows status, queue and remaining requests","Connected agents (MCP) work on the active tracker: with GitHub or Linear connected, their missions, claims and decisions land there, and their sessions show live in the command center"]},{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"]}],CC=[{area:"Teamtrail Cloud",items:["Agents that run in the cloud, steered from the same Lookout"]}],$C=[{version:"0.27.3",date:"2026-11-11",items:["On Linux, the Lookout sees every change an agent makes to a ticket again, not only the first: a claimed ticket no longer stays in the queue as waiting"]},{version:"0.27.2",date:"2026-11-11",items:["Settings, briefs, criteria, guides, reroutes and the other panels stay current through reconnects, and a GitHub or Linear map updates live again"]},{version:"0.27.1",date:"2026-11-11",items:["The map and the queue no longer miss a change made while the Lookout was loading or reconnecting"]},{version:"0.27.0",date:"2026-11-11",items:["Teamtrail opens your browser ready to sign in with one click; `teamtrail pair` does the same for another tab"]},{version:"0.26.2",date:"2026-11-11",items:["The Lookout shows the new teamtrail. wordmark"]},{version:"0.26.1",date:"2026-11-11",items:["A refreshed logo: the trail’s destination is larger, and there are light and dark versions that follow your theme"]},{version:"0.26.0",date:"2026-11-11",items:["The Lookout asks you to sign in: open the link `teamtrail` prints, and pair your phone with a QR code (again after each restart)","Your answers count only when you give them in the Lookout or Slack, and skipping discovery or changing a trail’s mode or destination waits for your Approve","Check commands, briefs, criteria and other trusted settings run only once you approve them on this machine, in Settings → Approvals","Changes made to trail files outside Teamtrail have no effect until you accept them"]},{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"]},...bC];function TC(){return i.jsxs("div",{className:"changelog",children:[i.jsxs("div",{className:"about",children:[i.jsx(va,{className:"about-name"}),i.jsx("span",{className:"mono-label",children:J.category}),i.jsx("p",{className:"onb-tagline",children:J.tagline}),i.jsx(V,{parts:[J.assistant.name]})]}),i.jsx(Ie,{title:"Next",children:CC.map(e=>i.jsxs("div",{className:"cl-row",children:[i.jsx("span",{className:"mono-label",children:e.area}),i.jsx("ul",{children:e.items.map(t=>i.jsx("li",{children:t},t))})]},e.area))}),$C.map(e=>i.jsx(Ie,{title:`${e.version} · ${e.date}`,children:i.jsx("ul",{children:e.items.map(t=>i.jsx("li",{children:t},t))})},e.version))]})}function Vg(){const[e,t]=y.useState();return y.useEffect(()=>{fetch(`${je()}/machine`).then(s=>s.ok?s.json():void 0).then(s=>t(s==null?void 0:s.local),()=>t(void 0))},[]),e}const Lm={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"},Pm={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 Gg(e){return e.kind==="state"?EC(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 EC(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 AC="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 IC(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 MC=["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 RC(e){const{queue:t}=e;return i.jsx(Ce,{as:"li",className:"ap-row",edge:"attention",title:`${t.writes} tracker writes queued before the upgrade`,context:i.jsx(V,{parts:[`For ${t.targets.join(", ")}`]}),below:i.jsxs("div",{className:"ap-below",children:[i.jsx("pre",{className:"ap-lines t-code",children:t.labels.join(`
146
+ `)}),i.jsx("p",{className:"ap-note t-meta",children:"An older version kept this queue in the repo, where anyone who could write it could add to it. Send them only if you recognise them; nothing is sent until you do."}),e.local&&i.jsxs("div",{className:"ap-actions",children:[i.jsx(P,{size:"sm",disabled:e.busy,onClick:()=>e.onDecide(!0),children:"Send them"}),i.jsx(P,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>e.onDecide(!1),children:"Discard"})]})]})})}function OC(e){return i.jsxs("div",{className:"ap-below",children:[i.jsxs("p",{className:"t-meta",children:["Delete ",e.files.join(", "),"? Nobody signed them on this machine; git still has them."]}),i.jsxs("div",{className:"ap-actions",children:[i.jsxs(P,{size:"sm",variant:"ghost",disabled:e.busy,onClick:e.onDelete,children:["Delete ",e.files.length===1?"it":`all ${e.files.length}`]}),i.jsx(P,{size:"sm",disabled:e.busy,onClick:e.onCancel,children:"Keep"})]})]})}const LC=e=>e.files??(e.file?[e.file]:[]);function PC(e){const{item:t}=e,[s,o]=y.useState(!1),a=LC(t),c=t.revert??"restore";return i.jsx(Ce,{as:"li",className:"ap-row",edge:"attention",title:t.title,context:i.jsx(V,{parts:[Gg(t)]}),detail:a.join(", ")||void 0,detailText:a.join(", ")||void 0,below:i.jsxs("div",{className:"ap-below",children:[i.jsx("pre",{className:"ap-lines t-code",children:t.lines.join(`
147
+ `)}),e.local&&!s&&i.jsxs("div",{className:"ap-below ap-actions",children:[i.jsx(P,{size:"sm",disabled:e.busy,onClick:e.onAccept,children:"Accept this change"}),c!=="none"&&i.jsx(P,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>c==="delete"?o(!0):e.onRevert(),children:c==="delete"?"Delete…":"Revert"})]}),e.local&&s&&i.jsx(OC,{files:a,busy:e.busy,onDelete:()=>(o(!1),e.onRevert(a)),onCancel:()=>o(!1)})]})})}function _C(e){const{tracker:t}=e;return i.jsx(Ce,{as:"li",className:"ap-row",edge:"attention",title:`trackers.json now points at ${t.label}`,context:i.jsx(V,{parts:["Nothing is read from or sent there yet"]}),detail:`This machine keeps using ${t.approved}`,below:e.local&&i.jsxs("div",{className:"ap-below ap-actions",children:[i.jsxs(P,{size:"sm",disabled:e.busy,onClick:()=>e.onDecide(!0),children:["Use ",t.label]}),i.jsxs(P,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>e.onDecide(!1),children:["Keep ",t.approved]})]})})}function DC(e){const{item:t}=e,s=t.committed===!1,o=t.kind==="catalogs"?[...t.lines,""]:[],a=s?[...o,...t.content.split(`
148
+ `)]:t.lines;return i.jsx(Ce,{as:"li",className:"ap-row",edge:"attention",title:t.title,context:i.jsx(V,{parts:[Gg(t)]}),detail:Lm[t.kind],detailText:Lm[t.kind],below:i.jsxs("div",{className:"ap-below",children:[i.jsx("pre",{className:"ap-lines t-code",children:a.join(`
149
+ `)}),Pm[t.kind]&&i.jsx("p",{className:"ap-note t-meta",children:Pm[t.kind]}),t.warnings.length>0&&i.jsx("ul",{className:"ap-warnings t-meta",children:t.warnings.map(c=>i.jsxs("li",{children:["Worth a look: ",c]},c))}),e.local&&i.jsx(P,{size:"sm",disabled:e.busy,onClick:e.onApprove,children:"Approve"})]})})}async function _m(e,t){const s=await fetch(`${je()}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),o=await s.json().catch(()=>({}));if(!s.ok)throw new Error(o.error??`Request failed (${s.status})`);return o}const Tc=async e=>e.ok?await e.json():void 0;async function Dm(){var p;const[e,t,s]=await Promise.all(["/trust","/trackers","/trackers/legacy-outbox"].map(v=>fetch(`${je()}${v}`))),o=await Tc(e);if(!o)return null;const{items:a}=o,c=(p=await Tc(t))==null?void 0:p.pending,u=await Tc(s),h=o.firstRun===!0,m=o.stateFirstRun===!0;return{items:a,firstRun:h,stateFirstRun:m,...c?{tracker:c}:{},...u!=null&&u.writes?{oldQueue:u}:{}}}const zC=(e,t)=>{var s,o,a,c;return JSON.stringify([e.items.map(u=>u.hash),(s=e.tracker)==null?void 0:s.target,(o=e.oldQueue)==null?void 0:o.writes])===JSON.stringify([t.items.map(u=>u.hash),(a=t.tracker)==null?void 0:a.target,(c=t.oldQueue)==null?void 0:c.writes])};function BC(e){var s,o;const t=[(s=e.changed)!=null&&s.length?`${e.changed.length} changed while you looked, so they wait; look again`:"",(o=e.refused)!=null&&o.length?`${e.refused.length} not committed, so they need their own look`:""].filter(Boolean);return t.length?`${t.join(". ")}.`:void 0}function FC(){const[e,t]=y.useState(),[s,o]=y.useState(!1),a=y.useRef();y.useEffect(()=>void(a.current=e),[e]);const c=y.useRef(0),[u]=y.useState(ei),h=y.useRef(0),m=y.useCallback(()=>{h.current++;const N=u.start(),S=j=>{N()&&(a.current=j,t(j),o(!1))};return Dm().then(S,()=>S(null))},[u]),p=y.useCallback(async()=>{if(c.current)return;const N=h.current,S=await Dm().catch(()=>null),j=a.current;h.current!==N||j===void 0||(!S||!j||!zC(S,j))&&o(!0)},[]);y.useEffect(()=>void m(),[m]),y.useEffect(()=>ju(N=>void(N.startsWith(".")||p())),[p]),y.useEffect(()=>fs(()=>void p()),[p]);const v=y.useCallback(async N=>{c.current++;try{const S=await N();return await m(),S}finally{c.current--}},[m]),k=y.useCallback(async N=>BC(await v(()=>_m("/trust/approve",{items:N.map(S=>({key:S.key,hash:S.hash}))}))),[v]),x=y.useCallback(async(N,S)=>{await v(()=>_m(N,S))},[v]);return{view:e,changed:s,load:m,approve:k,act:x}}function UC(){const{view:e,changed:t,load:s,approve:o,act:a}=FC(),c=Vg()!==!1,[u,h]=y.useState(!1),[m,p]=y.useState();if(!e)return null;const v=C=>{h(!0),p(void 0),C.then(R=>(h(!1),p(R??void 0)),R=>(h(!1),p(R.message)))},{items:k,tracker:x,oldQueue:N}=e,S=C=>!C.alone&&(C.kind==="state"?e.stateFirstRun&&C.standing==="elsewhere":e.firstRun),j=k.filter(C=>C.committed!==!1&&S(C)),A=k.length+(x?1:0)+(N?1:0);return i.jsxs(Ie,{title:"Approvals",children:[i.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&&i.jsxs("div",{className:"sync-line alert ap-changed",role:"status",children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:"Files changed while you were here. What's below is what you saw."}),i.jsx(P,{size:"sm",onClick:s,children:"Review again"})]}),A===0&&i.jsx("p",{className:"ap-none t-meta",children:"Nothing waiting. Everything the repo asks for is approved here."}),j.length>1&&i.jsx("p",{className:"ap-adopt",children:IC(j.length)}),k.some(C=>C.kind==="state")&&i.jsx("p",{className:"ap-note t-meta",children:AC}),A>0&&i.jsxs("ul",{className:"ap-list",children:[x&&i.jsx(_C,{tracker:x,busy:u,local:c,onDecide:C=>v(a("/trackers/approval",{use:C,target:x.target}))}),N&&i.jsx(RC,{queue:N,busy:u,local:c,onDecide:C=>v(a("/trackers/legacy-outbox",{action:C?"send":"discard",writes:N.writes}))}),k.map(C=>C.kind==="state"?i.jsx(PC,{item:C,busy:u,local:c,onAccept:()=>v(o([C])),onRevert:R=>v(a("/trust/revert",{key:C.key,hash:C.hash,remove:R}))},C.key):i.jsx(DC,{item:C,busy:u,local:c,onApprove:()=>v(o([C]))},C.key))]}),c&&j.length>1&&i.jsxs(P,{disabled:u||t,onClick:()=>v(o(j)),children:["Approve all ",j.length," committed"]}),!c&&A>0&&i.jsxs("p",{className:"t-meta",children:["Approve these on the machine ",J.name," runs on."]}),m&&i.jsx("span",{className:"vf-err",children:m}),i.jsx(V,{className:"set-hint",parts:MC})]})}function qg(e){return i.jsx("ul",{className:"checklist-answers",children:e.answers.map(t=>i.jsxs("li",{className:t.done?"done":"not-done",children:[i.jsx("span",{className:"mark","aria-label":t.done?"Done":"Not done",children:t.done?"✓":"–"}),i.jsx("span",{className:"t-body",children:t.item}),t.note&&i.jsx("span",{className:"t-meta note",children:t.note})]},t.item))})}const Qg=`${J.apiPrefix}`;async function Yg(e){const t=await e.json().catch(()=>({}));if(!e.ok)throw new Error(t.error??`Request failed (${e.status})`);return t}const Ko=async e=>Yg(await fetch(`${Qg}${e}`)),Jg=async(e,t)=>Yg(await fetch(`${Qg}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}));let Xg;const Mo=new Set;let Vn;function Xc(e){Xg=e;for(const t of Mo)t()}function Zg(e){Vn==null||Vn.pushed(),Xc(e)}const WC=()=>Xg;function HC(e){return Mo.add(e),Vn??(Vn=Cg({load:()=>Ko("/guides"),show:Xc,failed:()=>Xc(null),changed:t=>t.includes("guides")})),()=>{Mo.delete(e),!Mo.size&&(Vn==null||Vn.stop(),Vn=void 0)}}function Nn(){const e=y.useSyncExternalStore(HC,WC),t=y.useCallback(async(o,a)=>{try{Zg(await Jg(o,a));return}catch(c){return c.message}},[]),s=y.useCallback(o=>o?e==null?void 0:e.guides.find(a=>a.id===o):void 0,[e]);return{view:e,act:t,find:s}}function KC(e){var h;const{view:t,find:s}=Nn(),o=s(e.id),a=t!=null&&(o==null?void 0:o.status)!=="active",c=((h=o==null?void 0:o.guide)==null?void 0:h.name)??e.id,u=a?`${c}: ${(o==null?void 0:o.reason)??"not installed"}`:`Guide: ${c}`;return i.jsx("span",{className:Ge("guide-chip",a&&"off"),"data-guide-id":e.id,title:u,children:c})}const VC={active:"Active",unapproved:"New, waiting for your approval",tampered:"Changed since you approved it",invalid:"Can't be used"},GC={active:"Approved",unapproved:"Not approved yet",tampered:"Changed since you approved it",invalid:"Can't be used"},Zc=e=>{var t;return e.origin==="local"&&(!((t=e.lock)!=null&&t.source)||e.lock.source==="local")};function qC(e){return Zc(e)?{text:GC[e.status],strong:e.status==="active"}:e.status==="active"?void 0:VC[e.status]}function Vo(e){try{return new URL(e).host}catch{return e}}function QC(e){var s;if(e.origin==="builtin")return"Built in";const t=(s=e.lock)==null?void 0:s.source;return!t||t==="local"?e.overridesBuiltin?"Local, replaces the built-in":"Local":`From ${Vo(t.registry)}`}const Lu=e=>e.map(t=>/\s/.test(t)?JSON.stringify(t):t).join(" "),zm=3;function YC(e,t){return e.length<=Math.max(t,zm+1)?e:`${e.slice(0,Math.max(t-1,zm)).trimEnd()}…`}function ev(e){return e===Gj?"Verified":`Verified by ${Vo(e)}'s catalog`}function tv(e,t){return e.builtin?{text:"Built in",strong:!0}:e.verified?{text:ev(t),strong:!0}:"Not reviewed"}function JC(e){var c,u;const t=(c=e.lock)==null?void 0:c.review;if(!t||e.status!=="active")return;if(!t.verified)return"Not reviewed";const s=t.reviewedBy.length>0?`Reviewed by ${t.reviewedBy.join(", ")}`:void 0,o=(u=e.lock)==null?void 0:u.source;return{text:o&&o!=="local"?ev(o.registry):"Verified",strong:!0,tip:s}}var XC=gp();function nv(e){return M0(e.spec)?i.jsxs("span",{className:"guide-unknown",children:[i.jsx("span",{className:"t-body",children:"Unknown program: Teamtrail can't tell what this runs. Approve it only if you know what it does."}),i.jsxs(P,{size:"sm",disabled:e.busy,onClick:()=>e.onApprove(e.name,!0),children:["I know what it runs: approve check ",e.name]})]}):i.jsxs(P,{size:"sm",disabled:e.busy,onClick:()=>e.onApprove(e.name,!1),children:["Approve check ",e.name]})}function ZC(e){var x;const{preview:t}=e,{act:s,find:o}=Nn(),[a,c]=y.useState({kind:"ready"}),[u,h]=y.useState(),m=t.entry.id,p=async()=>{h(void 0),c({kind:"adding"});try{c({kind:"added",pending:(await e.add(m,t.entry.sha256)).pendingChecks})}catch(N){h(N.message),c({kind:"ready"})}};if(t.entry.builtin)return i.jsxs("span",{className:"t-meta",children:["Built into ",J.name,": already available to every trail, nothing to add."]});if(a.kind!=="added"){const N=e.installed===t.entry.version,S=e.installed?"Update guide":"Add guide";return i.jsxs("div",{className:"add-guide",children:[!t.ok&&i.jsx("span",{className:"t-meta",children:"The lint found errors, so this guide can't be added."}),i.jsx(P,{variant:"primary",disabled:!t.ok||N||a.kind==="adding",onClick:()=>void p(),children:N?"Added":S}),u&&i.jsx("span",{className:"vf-err",children:u})]})}const v=((x=o(m))==null?void 0:x.pendingChecks)??a.pending,k=async(N,S)=>h(await s("/guides/checks/approve",{id:m,name:N,acknowledged:S}));return i.jsxs("div",{className:"add-guide",children:[i.jsx("p",{className:"t-body",children:v.length?`Added ${m} ${t.entry.version}. Approve each command it proposes; none runs until you do.`:`Added ${m} ${t.entry.version}. Agents get its instructions on tickets that ask for ${m}.`}),v.map(N=>{var S,j,A;return i.jsxs("span",{className:"guide-check",children:[i.jsxs("code",{className:"t-code",children:[N,": ",Lu(((j=(S=t.guide)==null?void 0:S.proposedChecks[N])==null?void 0:j.run)??[])]}),i.jsx(nv,{name:N,spec:((A=t.guide)==null?void 0:A.proposedChecks[N])??{run:[]},onApprove:(C,R)=>void k(C,R)})]},N)}),u&&i.jsx("span",{className:"vf-err",children:u})]})}function e$(e){const t=i.jsx("p",{className:"t-meta",children:"The lint looks for common problems; it isn't a review. Read the guide before you approve it."});return e.findings.length?i.jsxs(i.Fragment,{children:[i.jsx("ul",{className:"vf-findings guide-findings",children:e.findings.map((s,o)=>i.jsxs("li",{className:`sev-${s.level}`,children:[i.jsxs("code",{className:"t-code",children:["line ",s.line]})," ",s.message," ",i.jsxs("span",{className:"t-meta",children:["(",s.rule,")"]})]},o))}),t]}):i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"t-meta",children:"The lint found none of the problems it looks for."}),t]})}function sv(e){var o,a;const{p:t}=e,s=Object.entries(((o=t.guide)==null?void 0:o.proposedChecks)??{});return i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"t-label",children:"Lint"}),i.jsx(e$,{findings:t.findings}),t.guide&&t.guide.checklist.length>0&&i.jsx("span",{className:"t-label",children:"Checklist"}),t.guide&&i.jsx("ul",{className:"catalog-checklist t-body",children:t.guide.checklist.map(c=>i.jsx("li",{children:c},c))}),s.length>0&&i.jsx("span",{className:"t-label",children:"Commands it proposes"}),s.map(([c,u])=>i.jsxs("code",{className:"t-code guide-check",children:[c,": ",Lu(u.run),u.cwd&&` (in ${u.cwd})`]},c)),i.jsx("span",{className:"t-label",children:"Instructions"}),i.jsx("pre",{className:"guide-preview",children:((a=t.guide)==null?void 0:a.instructions)??t.text})]})}function t$(e){const t=hs(e.repo);if(!t)return null;const s=encodeURIComponent(`Report: ${e.id} ${e.version}`),o=`${t.replace(/\/+$/,"")}/issues/new?template=report-guide.yml&title=${s}`;return i.jsx("a",{className:"report-link t-meta",href:o,target:"_blank",rel:"noreferrer",children:"Report this guide"})}function n$(e){const t=e.entry,[s,o]=y.useState(),[a,c]=y.useState();return y.useEffect(()=>{e.preview(t.id).then(o,u=>c(u.message))},[t.id]),i.jsxs("div",{className:"catalog-entry",children:[i.jsx(P,{size:"sm",variant:"ghost",onClick:e.onBack,children:"← All guides"}),i.jsx("h3",{className:"t-title",children:t.name??t.id}),i.jsx(V,{parts:[{text:t.id,code:!0},t.version,`by ${t.author}`,tv(t,e.catalogUrl),t.reviewedBy.length>0&&`reviewed by ${t.reviewedBy.join(", ")}`]}),i.jsx("p",{className:"t-body",children:t.summary}),t.history.length>0&&i.jsx("ul",{className:"catalog-history",children:t.history.map(u=>i.jsxs("li",{className:"t-meta",children:[u.version," · ",i.jsx("code",{className:"t-code",children:u.commit.slice(0,8)})," · ",u.at.slice(0,10)]},`${u.version}-${u.commit}`))}),a&&i.jsx("span",{className:"vf-err",children:a}),s&&i.jsx(sv,{p:s}),s&&i.jsx(t$,{repo:s.repo,id:t.id,version:t.version}),s&&i.jsx(ZC,{preview:s,installed:e.installed,add:e.add})]})}function s$(e){const t=e.entry;return i.jsx("li",{className:"catalog-row","data-guide-id":t.id,children:i.jsx(Ce,{title:t.name??t.id,context:i.jsx(V,{parts:[{text:t.id,code:!0},t.version,t.author,tv(t,e.catalogUrl),t.reported&&"Reported"]}),detail:t.summary,trailing:e.installed&&`installed ${e.installed}`,onOpen:e.onOpen})})}const Bm=e=>e?`registry=${encodeURIComponent(e)}`:"";function i$(e){const[t,s]=y.useState(),[o,a]=y.useState();y.useEffect(()=>{let h=!0;return s(void 0),a(void 0),Ko(`/guides/catalog?${Bm(e)}`).then(m=>h&&s(m),m=>h&&a(m.message)),()=>{h=!1}},[e]);const c=y.useCallback(h=>Ko(`/guides/catalog/preview?${Bm(e)}&id=${encodeURIComponent(h)}`),[e]),u=y.useCallback(async(h,m)=>{const p=await Jg("/guides/catalog/add",{registry:e,id:h,sha256:m});return Zg(p),p.installed},[e]);return{index:t,error:o,preview:c,add:u}}function r$(e){var j,A;const[t,s]=y.useState(((j=e.registries[0])==null?void 0:j.name)??""),o=i$(t||void 0),{find:a}=Nn(),[c,u]=y.useState(""),[h,m]=y.useState(!0),[p,v]=y.useState(),k=o.index?R0({guides:o.index.guides},{query:c,verifiedOnly:h}):[],x=(A=o.index)==null?void 0:A.guides.find(C=>C.id===p),N=C=>{var R,L,U;return((R=a(C))==null?void 0:R.origin)==="local"?(U=(L=a(C))==null?void 0:L.guide)==null?void 0:U.version:void 0},S=e.registries.find(C=>C.name===t);return XC.createPortal(i.jsx("div",{className:"scrim catalog-scrim",onClick:C=>{C.stopPropagation(),e.onClose()},children:i.jsxs(ze,{as:"div",className:"dialog catalog-dialog",onClick:C=>C.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h3",{className:"t-title",children:"Guide catalog"}),e.registries.length>1&&i.jsx(dt,{compact:!0,"aria-label":"Catalog",value:t,options:e.registries.map(C=>({value:C.name,label:`${C.name} · ${Vo(C.url)}`,hint:C.url})),onChange:s}),i.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})]}),S&&e.registries.length===1&&i.jsx(V,{parts:[`Catalog ${S.name}`,{text:Vo(S.url),code:!0}]}),x?i.jsx(n$,{entry:x,catalogUrl:(S==null?void 0:S.url)??"",installed:N(x.id),preview:o.preview,add:o.add,onBack:()=>v(void 0)}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"catalog-filters",children:[i.jsx("input",{className:"catalog-search",placeholder:"Search guides","aria-label":"Search guides",value:c,onChange:C=>u(C.target.value)}),i.jsx(P,{size:"sm",on:h,"aria-pressed":h,onClick:()=>m(C=>!C),children:"Verified only"})]}),o.error&&i.jsx("span",{className:"vf-err",children:o.error}),!o.index&&!o.error&&i.jsx(Ae,{children:"Reading the catalog…"}),o.index&&!k.length&&i.jsx(Ae,{children:"No guides match."}),i.jsx("ul",{className:"catalog-list",children:k.map(C=>i.jsx(s$,{entry:C,catalogUrl:(S==null?void 0:S.url)??"",installed:N(C.id),onOpen:()=>v(C.id)},C.id))})]})]})}),document.body)}function o$(e){const t=e.r.guide;if(!t)return null;const s=Object.entries(t.proposedChecks);if(!t.requiresChecks.length&&!s.length)return null;const o=e.r.status==="active";return i.jsxs("div",{className:"guide-checks",children:[t.requiresChecks.length>0&&i.jsxs("span",{className:"t-meta",children:["Adds checks ",i.jsx("code",{className:"t-code",children:t.requiresChecks.join(", ")})," to its tickets"]}),s.map(([a,c])=>{const u=e.r.pendingChecks.includes(a);return i.jsxs("span",{className:"guide-check",children:[i.jsxs("code",{className:"t-code",children:[a,": ",Lu(c.run)]}),u&&o&&i.jsx(nv,{name:a,spec:c,busy:e.busy,onApprove:e.onApprove}),u&&!o&&i.jsx("span",{className:"t-meta",children:"approve the guide first"}),!u&&i.jsx("span",{className:"t-meta",children:"approved"})]},a)})]})}function a$(e){const{r:t}=e;if(!t.guide||!t.sha256)return null;const s=t.sha256;return i.jsxs("div",{className:"guide-review",children:[i.jsx(sv,{p:{findings:t.findings,guide:t.guide}}),i.jsx(P,{size:"sm","aria-label":`Approve guide ${t.id}`,disabled:e.busy,onClick:()=>e.onApprove(s),children:"Approve"})]})}const l$="A file in guides/ replaces this built-in once you approve it; until then the built-in is used";function c$(e){var t,s;return e.override?l$:e.status==="unapproved"?(t=e.guide)==null?void 0:t.summary:e.reason??((s=e.guide)==null?void 0:s.summary)}function iv(e){const{r:t}=e,s=t.id,o=t.override??t,a=(o.status==="unapproved"||o.status==="tampered")&&!!o.guide,c=t.status!=="active"||t.pendingChecks.length>0||a,u=t.guide?`${t.guide.name} ${t.guide.version}`:s;return i.jsx("li",{className:"guide-row","data-guide-id":s,children:i.jsx(Ce,{edge:c?"attention":"neutral",title:u,context:i.jsx(V,{parts:[{text:s,code:!0},QC(t),JC(t),qC(t),t.guide&&u$(t.guide.checklist.length)]}),detail:c$(t),actions:t.origin==="local"&&i.jsxs(P,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>e.onAct("/guides/remove",{id:s}),children:["Remove guide ",s]}),below:i.jsxs(i.Fragment,{children:[a&&i.jsx(a$,{r:o,busy:e.busy,onApprove:h=>e.onAct("/guides/approve",{id:s,sha256:h})}),i.jsx(o$,{r:t,busy:e.busy,onApprove:(h,m)=>e.onAct("/guides/checks/approve",{id:s,name:h,acknowledged:m})})]})})})}const u$=e=>e===1?"1 checklist item":`${e} checklist items`;function d$(e){return i.jsxs(Ie,{title:"Write your own",children:[i.jsxs("p",{className:"vf-intro",children:["Write a guide for your team in your repo with ",i.jsxs("code",{className:"t-code",children:[J.slug," guides new <id>"]}),". It starts from a template in ",i.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?i.jsx("ul",{className:"guides-list own-guides",children:e.guides.map(t=>i.jsx(iv,{r:t,busy:e.busy,onAct:e.onAct},t.id))}):i.jsx(Ae,{children:"No guides of your own yet."}),e.error&&i.jsx("span",{className:"vf-err",children:e.error}),i.jsxs("p",{className:"t-meta guides-share",children:["Useful beyond your team? Check it with ",i.jsxs("code",{className:"t-code",children:[J.slug," guides lint"]})," and"," ",i.jsx("a",{href:qj,target:"_blank",rel:"noreferrer",children:"share it in the public catalog"}),"."]})]})}function h$(e){const{view:t,act:s}=Nn(),[o,a]=y.useState(),[c,u]=y.useState(!1),[h,m]=y.useState(!1),p=y.useRef(null);if(y.useEffect(()=>{var x;e.focus&&t&&((x=p.current)==null||x.scrollIntoView({block:"start"}))},[e.focus,!!t]),!t)return null;const v=x=>(N,S)=>{u(!0),s(N,S).then(j=>{a(j?{own:x,message:j}:void 0),u(!1)})},k=x=>o&&o.own===x?o.message:void 0;return i.jsxs("div",{className:"guides-section",ref:p,children:[i.jsxs(Ie,{title:"Guides",children:[i.jsx("p",{className:"vf-intro",children:"Guides give an agent instructions and a checklist for the tickets that ask for them. A guide can add checks, never remove them, and its commands only run once you approve them."}),i.jsx("ul",{className:"guides-list",children:t.guides.filter(x=>!Zc(x)).map(x=>i.jsx(iv,{r:x,busy:c,onAct:v(!1)},x.id))}),i.jsxs("div",{className:"guides-foot",children:[i.jsx(P,{size:"sm",onClick:()=>m(!0),children:"Browse guides"}),i.jsx(V,{parts:[{text:`${J.dataDir}/guides/`,code:!0},{text:"guides.lock.json",code:!0}]})]}),t.configErrors.length>0&&i.jsx("ul",{className:"vf-errors",children:t.configErrors.map(x=>i.jsx("li",{children:x},x))}),k(!1)&&i.jsx("span",{className:"vf-err",children:k(!1)})]}),i.jsx(d$,{guides:t.guides.filter(Zc),busy:c,onAct:v(!0),error:k(!0)}),h&&i.jsx(r$,{registries:t.registries,onClose:()=>m(!1)})]})}function f$(e){const{view:t,act:s}=Nn(),[o,a]=y.useState();if(!t)return null;const c=e.map.guides??[],u=t.guides.filter(m=>m.status==="active"&&m.guide),h=m=>{const p=c.includes(m)?c.filter(v=>v!==m):[...c,m];a(void 0),s("/guides/team",{mapId:e.map.id,guides:p}).then(a)};return i.jsxs(Ie,{title:`Team of ${e.map.key}`,children:[i.jsx("p",{className:"vf-intro",children:"The guides this trail works with. With Reviewer on the team, review tickets come with the reviewer's instructions and checklist."}),i.jsx("div",{className:"team-guides",children:u.map(m=>{const p=c.includes(m.id);return i.jsx(P,{size:"sm",on:p,"aria-pressed":p,title:m.guide.summary,onClick:()=>h(m.id),children:m.guide.name},m.id)})}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function m$(e,t){const[s,o]=y.useState(),a=`/guides/checklist?mapId=${encodeURIComponent(e)}&ticketId=${encodeURIComponent(t)}`;return pt({view:a,load:()=>Ko(a),show:c=>o(c.checklist),failed:()=>o(null),changed:c=>c.endsWith("checklist.json")}),s}function p$(e){const t=m$(e.mapId,e.ticketId);if(!t)return null;const s=t.answers.filter(o=>!o.done).length;return i.jsxs("div",{className:"checklist-panel",children:[i.jsx(V,{parts:[`${t.guide.id} ${t.guide.version} checklist`,t.by,ar(t.at),s?`${s} not done`:"all done"]}),i.jsx(qg,{answers:t.answers})]})}const Fm="";function g$(e){const{view:t,act:s}=Nn(),[o,a]=y.useState();if(!t)return null;const c=e.ticket,u=t.guides.filter(p=>{var v;return p.status==="active"&&((v=p.guide)==null?void 0:v.handles.types.includes(c.type))}),h=[{value:Fm,label:"No guide"},...u.map(p=>({value:p.id,label:p.guide.name,hint:p.guide.summary}))];c.guide&&!u.some(p=>p.id===c.guide)&&h.push({value:c.guide,label:c.guide});const m=p=>{a(void 0),s("/guides/ticket",{mapId:e.mapId,ticketId:c.id,guide:p||null}).then(a)};return i.jsxs("span",{className:"guide-picker",children:[i.jsx(dt,{compact:!0,"aria-label":"Ticket guide",value:c.guide??Fm,options:h,onChange:m}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function v$(e){const{view:t,find:s}=Nn();if(!t)return null;const o=s(e.id);if((o==null?void 0:o.status)==="active")return null;const a=o?o.reason??o.status:"it is not installed";return i.jsxs("p",{className:"guide-warning t-meta",children:["Guide ",e.id," can't be used: ",a,". Claims get no guide instructions until you approve it in Settings → Guides."]})}function k$(e){const{view:t}=Nn(),s=e.ticket;return!t||s.state!=="open"&&!s.guide?null:i.jsxs("section",{className:"ticket-guide d-section",children:[i.jsxs("span",{className:"guide-head",children:[i.jsx("span",{className:"t-label",children:"Guide"}),s.state==="open"?i.jsx(g$,{mapId:e.mapId,ticket:s}):s.guide&&i.jsx(KC,{id:s.guide})]}),s.guide&&i.jsx(v$,{id:s.guide}),i.jsx(p$,{mapId:e.mapId,ticketId:s.id})]})}function y$(e){var m;const{view:t,find:s}=Nn();if(!e)return;const o=s(e),a=t!=null&&(o==null?void 0:o.status)!=="active",c=((m=o==null?void 0:o.guide)==null?void 0:m.name)??e,u=o!=null&&o.guide?`${c} ${o.guide.version}`:c,h=a?`Guide ${u}: ${(o==null?void 0:o.reason)??"not installed"}`:`Guide: ${u}`;return{id:e,name:c,tip:h,off:a}}const rv="0.27.3-next.39",eu="<endpoint>",Pu=kp(rv,["mcp","--http"]);function w$(e,t){const s=kp(rv,["connect",e,"--url"]),o=t===eu?t:vp(t);return`read -rs ${J.tokenEnv} && export ${J.tokenEnv}
150
+ ${s} ${o}`}function x$(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 j$({endpoints:e}){const t=e.some(s=>s.kind==="standalone");return i.jsxs("ul",{className:"ra-endpoints",children:[e.map(s=>i.jsx("li",{children:i.jsx(V,{className:"set-hint",parts:[{text:s.url,code:!0},...x$(s)]})},s.url)),!t&&i.jsx("li",{children:i.jsx(V,{className:"set-hint",parts:["For agents on other machines, start their server",{text:Pu,code:!0}]})})]})}function N$(e){const[t,s]=y.useState(""),[o,a]=y.useState(!1),[c,u]=y.useState(),h=async m=>{if(!m.trim()||o)return;a(!0);const p=await e.onCreate(m).catch(v=>v.message);a(!1),u(p),p||s("")};return i.jsxs("div",{className:"ra-new",children:[i.jsx(ga,{value:t,onValueChange:s,onSubmit:h,action:"Create token",actionDisabled:o||!t.trim(),placeholder:"Name the agent, e.g. cloud sandbox 1","aria-label":"Agent name",maxLength:60}),c&&i.jsx("span",{className:"vf-err",children:c})]})}function S$(){return i.jsx(Ie,{title:"Remote agents",children:i.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 b$(e){const[t,s]=y.useState(!1),[o,a]=y.useState(!1),[c,u]=y.useState(),h=async()=>{a(!0),u(await e.onRevoke().catch(m=>m.message)),a(!1),s(!1)};return t?i.jsxs("span",{className:"ra-revoke ask",children:[i.jsx("span",{className:"t-meta",children:"Its sessions end now."}),i.jsxs(P,{size:"sm",disabled:o,onClick:h,children:["Revoke ",e.name]}),i.jsx(P,{size:"sm",variant:"ghost",onClick:()=>s(!1),children:"Keep"})]}):i.jsxs("span",{className:"ra-revoke",children:[i.jsx(P,{size:"sm","aria-label":`Revoke ${e.name}`,onClick:()=>s(!0),children:"Revoke"}),c&&i.jsx("span",{className:"vf-err",children:c})]})}function C$(e){if(!e.tokens.length)return null;const t=Date.now();return i.jsx("ul",{className:"ra-list",children:e.tokens.map(s=>i.jsx(Ce,{as:"li",className:"ra-row",title:s.name,titleText:s.name,context:i.jsx(V,{parts:[`Created ${Uo(s.createdAt,t)}`,s.lastUsedAt?`Last used ${Uo(s.lastUsedAt,t)}`:"Never used"]}),below:i.jsx(b$,{name:s.name,onRevoke:()=>e.onRevoke(s.id)})},s.id))})}function Ec(e){const[t,s]=y.useState(!1),o=()=>{var a;return void((a=navigator.clipboard)==null?void 0:a.writeText(e.value).then(()=>{s(!0),setTimeout(()=>s(!1),1500)},()=>s(!1)))};return i.jsxs("div",{className:"ra-copy",children:[i.jsx("code",{className:"ra-copy-value t-code","aria-label":e.label,children:e.value}),i.jsx(P,{size:"sm",className:"ra-copy-btn",onClick:o,children:t?"Copied":e.copyLabel??"Copy"})]})}const $$=[{id:"claude",label:"Claude Code"},{id:"codex",label:"Codex"}];function T$(e){const[t,s]=y.useState("claude");return i.jsxs("div",{className:"ra-reveal",role:"status",children:[i.jsxs("p",{className:"ra-reveal-title t-row-title",children:["Token for ",e.created.name]}),i.jsxs("p",{className:"t-body ra-note",children:["Copy it now. ",J.name," keeps only a fingerprint, so it can't show it again."]}),i.jsx(Ec,{label:"Token",value:e.created.token,copyLabel:"Copy token"}),!e.endpoint&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"ra-reveal-head",children:i.jsx(Ve,{children:"Start the server for remote agents"})}),i.jsx(Ec,{label:"Start command",value:Pu,copyLabel:"Copy command"})]}),i.jsxs("div",{className:"ra-reveal-head",children:[i.jsx(Ve,{children:"Run on the agent's machine"}),i.jsx("span",{className:"ra-clients",children:$$.map(o=>i.jsx(P,{size:"sm",on:t===o.id,"aria-pressed":t===o.id,onClick:()=>s(o.id),children:o.label},o.id))})]}),i.jsx(Ec,{label:"Connect command",value:w$(t,e.endpoint??eu),copyLabel:"Copy command"}),i.jsxs("p",{className:"t-meta ra-note",children:["The first line waits for the token: paste it and press Enter. It isn't shown, and it stays out of your shell history."," ",e.endpoint?"From another machine, use the address that machine reaches this one by.":`Put the address the server prints in place of ${eu}.`,t==="codex"&&` Start Codex from the same shell: it reads $${J.tokenEnv} each time.`]}),i.jsx("span",{children:i.jsx(P,{variant:"primary",size:"sm",onClick:e.onDone,children:"I've copied it"})})]})}const ov=`${je()}/remote-agents`;async function Um(e,t){const s=await fetch(`${ov}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return{ok:s.ok,reply:await s.json()}}async function E$(){const e=await fetch(ov);return e.ok?await e.json():(await e.json().catch(()=>({}))).elsewhere?"elsewhere":null}function A$(){const[e,t]=y.useState(),[s,o]=y.useState(),{pushed:a}=pt({load:E$,show:t,failed:()=>t(null),events:{"remote-agents":()=>!0}}),c=y.useCallback(m=>{a(),t({tokens:m.tokens,endpoints:m.endpoints})},[a]),u=y.useCallback(async m=>{const{ok:p,reply:v}=await Um("/tokens",{name:m});if(!p||!v.token||!v.created)return v.error??"The token could not be created.";c(v),o({token:v.token,name:v.created.name})},[c]),h=y.useCallback(async m=>{const{ok:p,reply:v}=await Um("/tokens/revoke",{id:m});return v.tokens&&c(v),p?void 0:v.error??"The token could not be revoked."},[c]);return{view:e,created:s,dismissCreated:()=>o(void 0),create:u,revoke:h}}function I$(){var u;const{view:e,created:t,dismissCreated:s,create:o,revoke:a}=A$();if(!e)return null;if(e==="elsewhere")return i.jsx(S$,{});const c=(u=e.endpoints.find(h=>h.kind==="standalone"))==null?void 0:u.url;return i.jsxs(Ie,{title:"Remote agents",children:[i.jsx("p",{className:"vf-intro",children:"Agents on another machine or in a cloud sandbox can work this repo's trails too. They connect over HTTP with a token and share the tickets, claims and inbox of the agents here. One token per agent; revoke it and that agent is out within about a second."}),i.jsx(j$,{endpoints:e.endpoints}),t&&i.jsx(T$,{created:t,endpoint:c,onDone:s}),i.jsx(C$,{tokens:e.tokens,onRevoke:a}),e.tokens.length===0&&i.jsx("p",{className:"t-meta ra-note",children:"No tokens, so the endpoint is closed: every request is refused."}),i.jsx(N$,{onCreate:o}),i.jsxs("div",{className:"ra-notes",children:[i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"Before you open it to other machines."})," The connection is plain HTTP. Run ",i.jsx("code",{children:Pu}),", which serves the agent tools and nothing else, and put that port behind HTTPS with a reverse proxy or a tunnel. The Lookout's own port is not for sharing: its agent endpoint answers this machine only. A token only ever opens the agent tools, never the Lookout, which signs in browsers, not agents."]}),i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"What a remote agent can't do."})," Speak for you: it can't answer a question, skip discovery, change the trail's mode or destination, or close a ticket that needs you before you've answered here or in Slack. And its files aren't on this machine, so it gets no worktree, and on trails with verification its finished work comes to you to review instead of running the checks here."]}),i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"How far to trust one."})," The risk policy only sees what an agent declares: a call is held for you when the agent names a high-risk category or touches files your path rules cover. An agent that declares nothing isn't caught. Give an agent you don't fully trust only trails with verification on, where its finished work comes to you."]}),i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"What it does as you."})," With GitHub Issues or Linear as the tracker, everything a remote agent writes (tickets, comments, closing) goes to the tracker with your credentials, like the agents here."]})]})]})}const Wm={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"},M$={low:"the agent decides",medium:"the agent decides and records it",high:"you decide"},R$=e=>e[0].toUpperCase()+e.slice(1),tu=Dp.map(e=>({value:e,label:R$(e),hint:M$[e]}));function O$(e){const[t,s]=y.useState(""),[o,a]=y.useState("high"),{rules:c,onChange:u}=e,h=()=>{const m=t.trim();!m||c.some(p=>p.glob===m)||(u([...c,{glob:m,level:o}]),s(""))};return i.jsxs("div",{className:"risk-paths",children:[i.jsx("span",{className:"mono-label",children:"Files"}),c.map((m,p)=>i.jsxs("div",{className:"risk-row",children:[i.jsx("code",{children:m.glob}),i.jsx(dt,{compact:!0,"aria-label":`${m.glob} risk`,value:m.level,options:tu,onChange:v=>u(c.map((k,x)=>x===p?{...k,level:v}:k))}),i.jsx("button",{className:"icon-btn","aria-label":`Remove ${m.glob}`,onClick:()=>u(c.filter((v,k)=>k!==p)),children:"×"})]},m.glob)),i.jsxs("div",{className:"risk-row",children:[i.jsx("input",{value:t,placeholder:"src/payments/**","aria-label":"New file pattern",onChange:m=>s(m.target.value),onKeyDown:m=>m.key==="Enter"&&h()}),i.jsx(dt,{compact:!0,"aria-label":"New pattern risk",value:o,options:tu,onChange:a}),i.jsx(P,{onClick:h,disabled:!t.trim(),children:"Add"})]})]})}const av=`${je()}/policy`;async function L$(){const e=await fetch(av);return e.ok?await e.json():null}function P$(){const[e,t]=y.useState(),{pushed:s}=pt({load:L$,show:t,failed:()=>t(null),changed:a=>a.endsWith("policy.json")}),o=y.useCallback(async a=>{const c=await fetch(av,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),u=await c.json();if(!c.ok)return u.error??`Saving failed (${c.status})`;s(),t(u)},[s]);return{view:e,save:o}}function _$(){const{view:e,save:t}=P$(),[s,o]=y.useState();if(!e)return null;const a=`${J.dataDir}/policy.json`,c=u=>{o(void 0),t(u).then(o,h=>o(h.message))};return i.jsxs(Ie,{title:"Risk policy",children:[i.jsx("p",{className:"vf-intro",children:"What agents may decide on their own. High: they must ask you. Medium: they decide, follow your conventions and record it for you to review. Low: they just decide."}),i.jsx("div",{className:"risk-grid",children:_p.map(u=>i.jsxs("label",{className:"risk-row",children:[i.jsx("span",{children:Wm[u]}),i.jsx(dt,{compact:!0,"aria-label":`${Wm[u]} risk`,value:e.policy.categories[u],options:tu,onChange:h=>c({...e.policy,categories:{...e.policy.categories,[u]:h}})})]},u))}),i.jsx(O$,{rules:e.policy.paths,onChange:u=>c({...e.policy,paths:u})}),e.errors.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[a," has errors, so the defaults apply until it is fixed."]})]}),i.jsx("ul",{className:"vf-errors",children:e.errors.map(u=>i.jsx("li",{children:u},u))})]}),e.defaults&&e.errors.length===0&&i.jsxs("span",{className:"set-hint t-meta",children:["Defaults. Changing anything saves ",a,", so your team shares it."]}),s&&i.jsx("span",{className:"vf-err",children:s})]})}const nu=`${je()}/workspaces`;async function D$(){const e=await fetch(nu);return e.ok?await e.json():null}function lv(){const[e,t]=y.useState(),{pushed:s}=pt({load:D$,show:t,failed:()=>t(null),changed:u=>u.endsWith("workspaces.json")||u.includes("workspaces/")||u.includes("leases/")}),o=y.useCallback(u=>{s(),t(u)},[s]),a=y.useCallback(async u=>{const h=await fetch(nu,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)}),m=await h.json();if(!h.ok)return m.error??`Saving failed (${h.status})`;o(m)},[o]),c=y.useCallback(async(u,h,m=!1)=>{const p=await fetch(`${nu}/remove`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:u,ticketId:h,force:m})}),v=await p.json();return p.ok?(o(v),{}):{error:v.error??`Removing failed (${p.status})`,dirty:v.dirty??!1}},[o]);return{view:e,save:a,remove:c}}function cv(e){const[t,s]=y.useState(!1),[o,a]=y.useState(),[c,u]=y.useState(!1),h=async m=>{u(!0),a(void 0);const p=await e.onRemove(m).catch(v=>({error:v.message,dirty:!1}));u(!1),s(!!p.dirty&&!m),p.dirty||a(p.error)};return t?i.jsxs("span",{className:"ws-remove ask",children:[i.jsx("span",{className:"vf-err",children:"Uncommitted changes in this workspace will be lost."}),i.jsx(P,{size:"sm",disabled:c,onClick:()=>h(!0),children:"Remove anyway"}),i.jsx(P,{size:"sm",variant:"ghost",onClick:()=>s(!1),children:"Keep"})]}):i.jsxs("span",{className:"ws-remove",children:[i.jsx(P,{size:"sm",disabled:c,onClick:()=>h(!1),children:e.label??"Remove"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function z$(e){return e.rows.length?i.jsx("ul",{className:"ws-list",children:e.rows.map(t=>i.jsx(Ce,{as:"li",className:`ws-row ${t.active?"active":"finished"}`,title:i.jsx("span",{className:"t-code",children:t.branch}),titleText:t.branch,context:i.jsx(V,{parts:[{text:t.ticketKey,code:!0},t.active?`Active · ${t.agent}`:"Finished"]}),detail:i.jsx("span",{className:"t-code",children:t.path}),detailText:t.path,below:t.active?void 0:i.jsx(cv,{onRemove:s=>e.onRemove(t.mapId,t.ticketId,s)})},`${t.mapId}/${t.ticketId}`))}):null}function B$(e){const{view:t,remove:s}=lv(),o=t==null?void 0:t.workspaces.find(a=>a.mapId===e.mapId&&a.ticketId===e.ticketId);return!o||o.active?null:i.jsxs("section",{className:"ticket-workspace d-section",children:[i.jsx("span",{className:"t-label",children:"Workspace"}),i.jsxs("p",{className:"t-meta",children:["Branch ",i.jsx("code",{className:"t-code",children:o.branch})," in"," ",i.jsx("code",{className:"t-code",title:o.path,children:o.path})]}),i.jsx(cv,{label:"Remove workspace",onRemove:a=>s(e.mapId,e.ticketId,a)})]})}function F$(){const{view:e,save:t,remove:s}=lv(),[o,a]=y.useState();if(!e)return null;const c=e.settings.worktrees,u=()=>{a(void 0),t({...e.settings,worktrees:!c}).then(a,h=>a(h.message))};return i.jsxs(Ie,{title:"Workspaces",children:[i.jsxs("p",{className:"vf-intro",children:["Give each agent its own copy of the repo for every ticket it claims, on its own branch, so agents working at the same time don't step on each other. You review and merge the branches; ",J.name," never merges or pushes."]}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"A worktree per ticket"}),i.jsx(P,{size:"sm",on:c,"aria-pressed":c,className:"worktrees-toggle",onClick:u,children:c?"On":"Off"})]}),i.jsx(V,{className:"set-hint",parts:[{text:`${J.dataDir}/workspaces.json`,code:!0},Hm(e.workspaces.filter(h=>h.active).length,"active"),Hm(e.workspaces.filter(h=>!h.active).length,"finished")]}),i.jsx(z$,{rows:e.workspaces,onRemove:s}),e.errors.length>0&&i.jsx("ul",{className:"vf-errors",children:e.errors.map(h=>i.jsx("li",{children:h},h))}),o&&i.jsx("span",{className:"vf-err",children:o})]})}const Hm=(e,t)=>`${e} ${t}`;function U$({data:e,route:t}){return i.jsxs(i.Fragment,{children:[i.jsx(Qe,{id:"approvals",storage:"machine",children:i.jsx(UC,{})}),i.jsx(Qe,{id:"tracker",children:i.jsx(Ie,{title:"Tracker",children:i.jsx(dC,{activeTracker:e.activeTracker,location:e.location,update:e.update})})}),i.jsx(Qe,{id:"workspaces",storage:"repo",children:i.jsx(F$,{})}),i.jsx(Qe,{id:"remote-agents",storage:"machine",children:i.jsx(I$,{})}),i.jsx(Qe,{id:"policy",storage:"repo",children:i.jsx(_$,{})}),i.jsx(Qe,{id:"guides",storage:"repo",children:i.jsx(h$,{focus:t.section==="guides"})}),i.jsx(Qe,{id:"labels",children:i.jsx(Ie,{title:"Labels",children:i.jsxs("div",{className:"label-codes",children:[i.jsx("code",{children:au}),i.jsxs("code",{children:[J.labelPrefix,":<type>"]}),i.jsx("code",{children:lu}),i.jsx("code",{children:cu})]})})})]})}const su=`${J.apiPrefix}/projects`;async function Eo(e,t,s){const o=await fetch(`${su}${e}`,{method:t,headers:{"Content-Type":"application/json"},body:s===void 0?void 0:JSON.stringify(s)}),a=await o.json().catch(()=>({}));if(!o.ok)throw new Error(a.error??`HTTP ${o.status}`);return a}const Xs={url:su,add:e=>Eo("","POST",{path:e}),remove:e=>Eo(`/${e}`,"DELETE"),setAutoRegister:e=>Eo("/settings","PUT",{autoRegister:e}),answer:(e,t)=>Eo(`/${e}/answer`,"POST",t),async briefing(e){const t=await fetch(`${su}/briefing?since=${e}`);return t.ok?await t.json():void 0}};function uv(e){const[t,s]=y.useState(""),[o,a]=y.useState(),c=u=>{u.trim()&&(a(void 0),Xs.add(u.trim()).then(()=>(s(""),e.onAdded()),h=>a(h.message)))};return i.jsxs("div",{className:"pj-add",children:[i.jsx(ga,{value:t,onValueChange:s,onSubmit:c,action:"Add project",placeholder:`/path/to/repo (a ${J.dataDir} folder is created if missing)`,"aria-label":"Repo path",className:"t-code"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}const Fs=(e,t)=>e>0&&`${e} ${t}`;function W$(e){var s;const t=((s=e.briefing)==null?void 0:s.projects)??[];return!e.briefing||!t.length?null:i.jsxs("section",{className:"pj-section pj-briefing",children:[i.jsx(Et,{title:"While you were away",count:t.length,info:`What changed in each project since ${hn(e.now-e.briefing.since)} ago`}),i.jsx("ul",{className:"pj-list",children:t.map(({projectId:o,project:a,briefing:c})=>i.jsx(Ce,{as:"li",edge:c.totals.waiting>0?"attention":"neutral",title:a,context:i.jsx(V,{parts:[Fs(c.totals.done,"done"),Fs(c.trails.reduce((u,h)=>u+h.opened.length,0),"new tickets"),Fs(c.totals.agentDecisions,"agent decisions"),Fs(c.totals.waiting,"waiting on you"),Fs(c.totals.ruledOut,"ruled out"),Fs(c.totals.active,"agents active")]}),onOpen:()=>e.onOpen(o)},o))})]})}function H$(e){const[t,s]=y.useState(""),[o,a]=y.useState(!1),[c,u]=y.useState(),h=m=>{!m.trim()||o||(a(!0),u(void 0),e.onAnswer(m.trim()).then(()=>s(""),p=>u(p.message)).finally(()=>a(!1)))};return i.jsxs("div",{className:"pj-answer",children:[i.jsx(ga,{value:t,onValueChange:s,onSubmit:h,action:"Answer",disabled:o,placeholder:"Your answer","aria-label":"Your answer"}),c&&i.jsx("span",{className:"vf-err",children:c})]})}function K$(e){const{item:t}=e,s=Ig(t),o=t.kind==="question"&&t.agent?`${t.agent} asks`:Eg[t.kind],a=t.urgency==="blocking"&&{text:"Blocking",urgent:!0,className:"urgency-tag"};return i.jsx(Ce,{as:"li",className:`att-item pj-item k-${t.kind}`,edge:Ag(t,t.interrupting),title:t.title.split(`
151
+ `)[0],titleText:t.title,context:i.jsx(V,{parts:[a,{text:t.project,strong:!0},o]}),detail:s.length>0&&s.join(" · "),detailText:s.join(`
152
+ `),trailing:hn(e.now-t.since),onOpen:e.onOpen,below:e.onAnswer&&i.jsx(H$,{onAnswer:e.onAnswer})})}function V$(e){const t=e.view.attention,s=o=>{var a;return((a=e.view.projects.find(c=>c.id===o))==null?void 0:a.state.kind)!=="missing"};return i.jsxs("section",{className:"pj-section pj-attention",children:[i.jsx(Et,{title:"Needs you",count:t.length,hot:t.some(o=>o.interrupting),info:"One queue across projects, ranked the way each project ranks its own. Answer questions here; the agent in that repo gets the answer."}),t.length===0&&i.jsx(qn,{title:"Nothing needs you",hint:"Agents in every project can keep going."}),i.jsx("ul",{className:"pj-list",children:t.map(o=>i.jsx(K$,{item:o,now:e.now,onOpen:()=>e.onOpen(o.projectId,o.id),onAnswer:o.kind==="question"&&s(o.projectId)?a=>Xs.answer(o.projectId,{questionId:o.ref,text:a}).then(e.onAnswered):void 0},`${o.projectId}/${o.id}`))})]})}const Ac=(e,t,s=`${t}s`)=>`${e} ${e===1?t:s}`;function G$(e){return e.interrupting>0?"urgent":e.phases.blocked+e.phases.rework+e.flags+e.stalled>0||e.state.kind==="missing"?"attention":"neutral"}function q$(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(Ac(e.agents,"agent"));const{working:s,verifying:o,rework:a,blocked:c}=e.phases;s&&t.push(`${s} working`),o&&t.push(`${o} verifying`),a&&t.push(`${a} rework`),c&&t.push(`${c} blocked`),e.flags&&t.push(Ac(e.flags,"PR flag")),e.stalled&&t.push(Ac(e.stalled,"stalled claim")),t.length||t.push(e.trails?"Nothing waiting":"No trails yet");const u=Q$(e.tracker);return u&&t.push(u),t}function Q$(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 Y$(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 Go(e,t,s){if(e.state.kind!=="missing"){if(e.state.kind==="elsewhere"){const o=e.state.url?hs(e.state.url):void 0;if(!o)return;const a=new URL(o);s&&a.searchParams.set(Gs,s),window.open(a.toString(),"_blank","noopener");return}location.href=hN({id:e.id,home:t,tracker:e.tracker.kind,item:s})}}function dv(e){const{p:t}=e,s=Y$(t);return i.jsx(Ce,{as:"li",className:`project-card st-${t.state.kind}`,edge:G$(t),selected:e.current,title:t.name,titleText:t.path,context:i.jsx(V,{parts:q$(t)}),detail:s,detailText:s,trailing:t.lastActivity?hn(e.now-t.lastActivity):void 0,onOpen:e.onOpen})}const hv=`${Jo}:projects:seen`,Km=24*36e5;function J$(e){try{const t=Number(localStorage.getItem(hv));return t>0?t:e-Km}catch{return e-Km}}function X$(e){try{localStorage.setItem(hv,String(e))}catch{}}function Z$(){const[e,t]=y.useState();return y.useEffect(()=>{const s=Date.now();return Xs.briefing(J$(s)).then(t).catch(()=>{}),()=>X$(s)},[]),e}function eT(e){const{view:t,reload:s}=e.projects,o=Xt(15e3),a=Z$();if(y.useEffect(()=>{const m=p=>p.key==="Escape"&&e.onClose();return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[e]),!t)return null;const c=ca()??t.home,u=m=>{const p=t.projects.find(v=>v.id===m);(p==null?void 0:p.id)===c?e.onClose():p&&Go(p,t.home)},h=(m,p)=>{const v=t.projects.find(k=>k.id===m);if(v){if(v.id!==c)return Go(v,t.home,p);e.onClose(),e.onItemHere(p)}};return i.jsxs(ze,{className:`zone decisions-view projects-view dv-${e.bp}`,children:[i.jsxs("header",{className:"dv-head",children:[i.jsx(Ve,{as:"h2",children:"All projects"}),i.jsx("span",{className:"dv-head-right",children:i.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})})]}),i.jsxs("div",{className:"pj-body",children:[i.jsx(V$,{view:t,now:o,onOpen:h,onAnswered:s}),i.jsxs("section",{className:"pj-section pj-projects",children:[i.jsx(Et,{title:"Projects",count:t.projects.length,info:"Each repo registered on this machine, read from its own files. Nothing leaves your machine."}),i.jsx("ul",{className:"pj-list",children:t.projects.map(m=>i.jsx(dv,{p:m,current:m.id===c,now:o,onOpen:m.state.kind==="missing"?void 0:()=>u(m.id)},m.id))}),i.jsx(uv,{onAdded:s})]}),i.jsx(W$,{briefing:a,now:o,onOpen:u})]})]})}function tT(e){const[t,s]=y.useState(!1),o=y.useRef(null);y.useEffect(()=>{if(!t)return;const h=m=>{var p;(m instanceof KeyboardEvent?m.key==="Escape":!((p=o.current)!=null&&p.contains(m.target)))&&s(!1)};return window.addEventListener("mousedown",h),window.addEventListener("keydown",h),()=>{window.removeEventListener("mousedown",h),window.removeEventListener("keydown",h)}},[t]);const{view:a}=e.projects;if(!a||!e.projects.many)return i.jsx("span",{className:"repo",children:e.repo});const c=ca()??a.home,u=a.projects.filter(h=>h.id!==c).reduce((h,m)=>h+m.interrupting,0);return i.jsxs("div",{className:"project-switcher",ref:o,children:[i.jsxs("button",{className:"project-btn repo",onClick:()=>s(h=>!h),"aria-haspopup":"menu","aria-expanded":t,"data-tip":"Switch project, or see all of them",children:[i.jsx("span",{className:"project-name",children:e.repo}),u>0&&i.jsx(us,{n:u,urgent:!0}),i.jsx("span",{className:"caret",children:"▾"})]}),t&&i.jsxs("div",{className:"trail-menu",role:"menu",children:[i.jsxs("button",{role:"menuitem",className:"trail-item all-projects",onClick:()=>{s(!1),e.onOverview()},children:[i.jsx("span",{className:"mi-title",children:"All projects"}),i.jsx(us,{n:a.attention.length,urgent:a.attention.some(h=>h.interrupting),hideZero:!0})]}),i.jsx(Ve,{variant:"plain",className:"menu-h",children:"Projects"}),a.projects.map(h=>i.jsxs("button",{role:"menuitem",className:`trail-item ${h.id===c?"on":""} st-${h.state.kind}`,disabled:h.state.kind==="missing",onClick:()=>{s(!1),h.id!==c&&Go(h,a.home)},children:[i.jsx("span",{className:"mi-title",children:h.name}),i.jsx("span",{className:"mi-progress",children:nT(h.state.kind)}),i.jsx(us,{n:h.needsYou,urgent:h.interrupting>0,hideZero:!0})]},h.id))]})]})}function nT(e){return e==="missing"?"missing":e==="elsewhere"?"other Lookout":""}function sT(e){const t=Xt(15e3),{view:s}=e.projects;if(!s||!e.projects.many)return null;const o=ca()??s.home;return i.jsxs("section",{className:"phone-projects",children:[i.jsx(Et,{title:"Projects",count:s.projects.length,right:i.jsx(P,{size:"sm",variant:"ghost",onClick:e.onOverview,children:"All projects"})}),i.jsx("ul",{className:"pj-list",children:s.projects.filter(a=>a.id!==o).map(a=>i.jsx(dv,{p:a,current:!1,now:t,onOpen:a.state.kind==="missing"?void 0:()=>Go(a,s.home)},a.id))})]})}async function iT(){const e=await fetch(Xs.url);return e.ok?await e.json():void 0}function fv(){const[e,t]=y.useState(),{reload:s,pushed:o}=pt({load:iT,show:a=>a&&t(a)});return y.useEffect(()=>ti("projects",a=>{o(),t(JSON.parse(a))}),[o]),{view:e,many:((e==null?void 0:e.projects.length)??0)>1,reload:s}}const rT=e=>[e.home&&{text:"This Lookout",strong:!0},e.state.kind==="missing"&&"Missing",{text:e.path,code:!0}];function oT(){const{view:e,reload:t}=fv(),[s,o]=y.useState();if(!e)return null;const a=c=>{o(void 0),c.then(t,u=>o(u.message))};return i.jsxs(Ie,{title:"Projects",children:[i.jsx("p",{className:"vf-intro",children:"Supervise several repos from this Lookout: All projects shows what needs you in each of them. The list lives in your config folder on this machine, never in a repo, and agents only ever work in their own repo."}),i.jsx("ul",{className:"pj-list set-projects",children:e.projects.map(c=>i.jsx(Ce,{as:"li",edge:c.state.kind==="missing"?"attention":"neutral",title:c.name,context:i.jsx(V,{parts:rT(c)}),actions:!c.home&&i.jsx(P,{size:"sm",variant:"ghost",onClick:()=>a(Xs.remove(c.id)),children:"Remove"})},c.id))}),i.jsx(uv,{onAdded:t}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Agents add their repo when they connect"}),i.jsx(P,{size:"sm",on:e.autoRegister,"aria-pressed":e.autoRegister,className:"auto-register-toggle",onClick:()=>a(Xs.setAutoRegister(!e.autoRegister)),children:e.autoRegister?"On":"Off"})]}),i.jsx(V,{className:"set-hint",parts:[{text:`${J.slug} projects add <path>`,code:!0},`--no-register or ${J.noRegisterEnv} opts one agent out`]}),s&&i.jsx("span",{className:"vf-err",children:s})]})}const aT=`${J.apiPrefix}/models`;async function lT(){const e=await fetch(aT);return e.ok?await e.json():null}function _u(){const[e,t]=y.useState();return pt({load:lT,show:t,failed:()=>t(null),changed:s=>s.endsWith("models.json")||s.endsWith("map.md")||s.includes("/tickets/"),events:{attention:()=>!0}}),e}function cT({mapId:e,ticketId:t}){const s=_u(),o=s==null?void 0:s.waiting.find(a=>a.mapId===e&&a.ticketId===t);return o?i.jsx(Ce,{className:"model-wait d-section",edge:"attention",title:`Needs a ${o.tier} model`,context:i.jsx(V,{parts:[`Connected agents run ${o.best} at most`]}),detail:`Connect an agent on a ${o.tier} model, or have one claim ${o.ticketKey} by key.`}):null}function uT({view:e}){if(!e)return null;const t=`${J.dataDir}/${e.file}`,s=Object.keys(e.models).length,o=e.agents.map(a=>`${a.agent} ${a.tier}`).join(", ");return i.jsxs(i.Fragment,{children:[i.jsx(V,{className:"set-hint",parts:[{text:t,code:!0},e.exists?`${s} of your own models`:"add new or custom models here","unknown models count as balanced"]}),o&&i.jsx(V,{className:"set-hint models-connected",parts:[`Connected now: ${o}`]}),e.errors.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[t," has errors, so only the built-in models count until it is fixed."]})]}),i.jsx("ul",{className:"vf-errors",children:e.errors.map(a=>i.jsx("li",{children:a},a))})]})]})}const mv={fast:"Fast",balanced:"Balanced",strongest:"Strongest"},dT={fast:"Haiku, mini and nano models",balanced:"Sonnet, GPT-4 models",strongest:"Opus, GPT-5 and o-series models"},hT=Oo.map(e=>({value:e,label:mv[e],hint:dT[e]}));function fT(e){return i.jsx("div",{className:"tier-grid",children:Zo.map(t=>{const s=e.tiers[t],o=du[t];return i.jsxs("div",{className:"tier-row",children:[i.jsx("span",{children:tr[t]}),i.jsx(dt,{compact:!0,"aria-label":`${tr[t]} tickets' model`,className:`tier-select tier-${t}`,value:s,options:hT,onChange:a=>e.onChange(t,a)}),i.jsx(V,{className:"tier-hint",parts:[s!==o&&`default ${mv[o].toLowerCase()}`,e.hints[t]]})]},t)})})}const Ao=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function mT({rows:e}){return e.length?i.jsx("ul",{className:"perf-rows",children:e.map(t=>i.jsx(Ce,{as:"li",className:"perf-row",title:t.key,trailing:i.jsx("span",{title:"Median time from first claim to done",children:un(t.medianLeadMs)}),context:i.jsx(V,{parts:[`${t.done} of ${Ao(t.tickets,"ticket")} done`,t.cancelled>0&&`${t.cancelled} cancelled`,Ao(t.reworkCycles,"rework"),`reviews ${t.reviews.passed} passed, ${t.reviews.failed} failed`,t.answers>0&&Ao(t.answers,"question")]}),detail:t.findings.raised>0?`As reviewer: ${t.findings.upheld} of ${Ao(t.findings.raised,"finding")} upheld`:void 0},t.key))}):i.jsx(Ae,{children:"No claimed tickets yet"})}function pv(e){const[t,s]=y.useState({}),o=e.map(a=>`${a.map.id}:${a.tickets.reduce((c,u)=>Math.max(c,u.updatedAt),0)}`).join();return y.useEffect(()=>{let a=!0;return Promise.all(e.map(async c=>{const u=await fetch(`${je()}/journal?mapId=${encodeURIComponent(c.map.id)}`).catch(()=>{}),h=u!=null&&u.ok?await u.json():{entries:[]};return[c.map.id,h.entries]})).then(c=>{a&&s(Object.fromEntries(c))}),()=>{a=!1}},[o]),t}const pT=[{id:"byVendor",title:"By vendor"},{id:"byAgent",title:"By agent"},{id:"byType",title:"By ticket type"}];function gT({api:e,bp:t,onClose:s}){const[o,a]=y.useState("byVendor"),c=y.useMemo(()=>Object.values(e.allSnaps),[e.allSnaps]),u=pv(c),h=e.activity.answered,m=y.useMemo(()=>Vp(c.map(p=>({snap:p,journal:u[p.map.id]??[],answered:h}))),[c,u,h]);return y.useEffect(()=>{const p=v=>v.key==="Escape"&&s();return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[s]),i.jsxs(ze,{className:`zone decisions-view perf-view dv-${t}`,children:[i.jsxs("header",{className:"dv-head",children:[i.jsx(Ve,{as:"h2",children:"Trail stats"}),i.jsx(V,{parts:[`${m.trails} trails`,`${m.tickets} tickets`]}),i.jsx("span",{className:"dv-head-right",children:i.jsx("button",{className:"icon-btn",onClick:s,"aria-label":"Close",children:"×"})})]}),i.jsxs("div",{className:"perf-body",children:[i.jsxs("section",{className:"perf-section",children:[i.jsx(Ve,{as:"h3",children:"What stands out"}),i.jsx("p",{className:"perf-note t-meta",children:"From your own numbers, for you to act on or ignore. Teamtrail doesn't route work from these."}),m.recommendations.length?i.jsx("ul",{className:"perf-recs",children:m.recommendations.map(p=>i.jsxs("li",{title:p.because,children:[i.jsx("span",{children:p.text}),i.jsx("span",{className:"t-meta",children:p.because})]},p.id))}):i.jsx(Ae,{children:"Nothing yet. This needs at least 5 results from two vendors to compare."})]}),i.jsxs("section",{className:"perf-section",children:[i.jsx("div",{className:"choice-row compact",children:pT.map(p=>i.jsx(mt,{on:o===p.id,title:p.title,onClick:()=>a(p.id)},p.id))}),i.jsx(mT,{rows:m[o]}),i.jsx("p",{className:"perf-note t-meta",children:"Spend is tracked per trail, so it isn't split by agent here."})]})]})]})}function vT(e,t){const s=pv(e);return y.useMemo(()=>{var c;const o=Vp(e.map(u=>({snap:u,journal:s[u.map.id]??[],answered:t}))),a={};for(const u of o.byType){if(!u.done)continue;const h=(c=o.recommendations.find(p=>p.id===`speed-${u.key}`))==null?void 0:c.text,m=[`Trail stats: ${u.done} done`,u.medianLeadMs!==void 0&&`median ${un(u.medianLeadMs)}`,u.reworkCycles>0&&`${u.reworkCycles} back to rework`,h];a[u.key]=m.filter(Boolean).join(" · ")}return a},[e,s,t])}function kT(e){var u,h;const t=_u(),s=vT(e.snaps,e.answered),o=e.map;if(!o)return null;const a=!!((u=o.modelMatching)!=null&&u.enabled),c=((h=o.modelMatching)==null?void 0:h.tiers)??{};return i.jsxs(Ie,{title:"Model matching",children:[i.jsx("p",{className:"vf-intro",children:"Give each agent the tickets that fit the model it runs on: research to fast models, junctions, prototypes and reviews to the strongest. Teamtrail reads the model from the agent's log and never switches it. An agent can still claim any ticket by name, and tells you when it does."}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsxs("span",{className:"set-field-label",children:["Match work to models on trail ",o.key]}),i.jsx(P,{size:"sm",on:a,"aria-pressed":a,className:"model-matching-toggle",onClick:()=>e.onChange({...o.modelMatching,enabled:!a}),children:a?"On":"Off"})]}),a&&i.jsx(fT,{tiers:Qy(o),hints:s,onChange:(m,p)=>{const v={...c,[m]:p};p===du[m]&&delete v[m],e.onChange({enabled:!0,tiers:v})}}),a&&i.jsx("span",{className:"set-hint t-meta",children:"Changes apply to the next claim; nothing running is interrupted."}),i.jsx(uT,{view:t})]})}function Ji(e,t){const s=new URL(e);return s.searchParams.delete("settings"),t&&s.searchParams.set("settings",t.section??t.group??""),s.toString()}async function yT(){const e=await fetch(`${je()}/verification/config`);return e.ok?await e.json():null}function wT(){const[e,t]=y.useState();return pt({load:yT,show:t,failed:()=>t(null),changed:s=>s.endsWith("verification.json"),events:{attention:()=>!0}}),e}const Vm=`{
153
+ "v": 1,
154
+ "checks": {
155
+ "test": { "run": ["npm", "test"] },
156
+ "lint": { "run": ["npm", "run", "lint"] }
157
+ },
158
+ "run": ["test", "lint"]
159
+ }
160
+ `;function xT({file:e}){const[t,s]=y.useState(!1),o=()=>void navigator.clipboard.writeText(Vm).then(()=>{s(!0),setTimeout(()=>s(!1),1500)});return i.jsxs("div",{className:"vf-setup",children:[i.jsx("b",{className:"vf-setup-h",children:"Set up checks"}),i.jsxs("p",{children:["Checks are the commands that prove a ticket is really done, such as your tests and linter. They live in"," ",i.jsx("code",{children:e})," in your repo. Create it with the commands you trust, then commit it:"]}),i.jsxs("div",{className:"vf-snippet",children:[i.jsx("pre",{children:Vm}),i.jsx(P,{size:"sm",variant:"ghost",onClick:o,children:t?"Copied":"Copy"})]}),i.jsxs("p",{className:"dim",children:[i.jsx("code",{children:"run"})," lists the checks that run on every completion. Each ",i.jsx("code",{children:"run"})," command is a list of words, not a shell line. Until the file exists, levels above Off can’t run their checks, so those completions stop and wait for you."]})]})}function jT(e){var p;const t=wT(),[s,o]=y.useState();if(!t)return null;const a=e.map,c=t.config,u=`${J.dataDir}/${t.file}`,h=(a==null?void 0:a.verification)??"off",m=(c??Ap).appliesTo.join(" and ");return i.jsxs(Ie,{title:"Verification",children:[i.jsxs("p",{className:"vf-intro",children:["When an agent says a ticket is done, Teamtrail can check the work before the ticket closes. This applies to"," ",m," tickets. Research, junction and prototype tickets close as soon as they are answered."]}),a&&i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"set-field-label",children:["How much checking for trail ",a.key]}),i.jsx("div",{className:"choice-row vf-levels",children:uu.map(v=>i.jsx(mt,{on:h===v,title:sr[v],sub:Lg[v],onClick:()=>{o(void 0),lr.act({action:"level",mapId:a.id,level:v,by:Nt}).catch(k=>o(k.message))}},v))}),h!=="off"&&!c&&i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:"No working checks yet, so completions at this level stop and wait for you."})]}),s&&i.jsx("span",{className:"vf-err",children:s})]}),t.errors.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line alert",title:t.hash,children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[u," has errors. Completions that need checks wait for you until it is fixed."]})]}),i.jsx("ul",{className:"vf-errors",children:t.errors.map(v=>i.jsx("li",{children:v},v))})]}),((p=t.approval)==null?void 0:p.waiting)&&i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:["Its commands don't run on this machine until you approve them."," ",i.jsx("a",{href:Ji(location.href,{group:"project",section:"approvals"}),children:"Review the commands"})]})]}),!t.exists&&i.jsx(xT,{file:u}),c&&t.exists&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line ok",title:t.hash,children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[i.jsx("span",{className:"t-code",children:u})," · ",c.run.length," checks run on every completion"]})]}),i.jsx(V,{className:"set-hint",parts:[`New trails start at ${sr[c.default]}`,`${c.maxAttempts} attempts before it waits for you`,c.failFast&&"Stops at the first failure"]}),i.jsx("div",{className:"vf-checks",children:Object.entries(c.checks).map(([v,k])=>i.jsxs("div",{className:"vf-check",children:[i.jsx("span",{className:"t-code",children:c.run.includes(v)?v:`${v} (on request)`}),i.jsx("code",{children:k.run.join(" ")}),i.jsxs("span",{className:"dim",children:[k.timeoutSec," s",k.cwd&&k.cwd!=="."?` · in ${k.cwd}`:""]})]},v))})]}),i.jsxs("span",{className:"set-hint t-meta",children:["Teamtrail never edits ",u,". Change checks in the repo, then approve them here: an edit by an agent or a teammate runs nothing on this machine until you do."]}),i.jsxs("span",{className:"set-hint t-meta",children:["Checks run on this machine as you, with no sandbox. Teamtrail passes them only the environment variables they need (more go in ",i.jsx("code",{children:"TEAMTRAIL_CHECK_ENV"}),"), but a check can still read your files (~/.aws, ~/.npmrc, ~/.ssh, ~/.kube, ~/.docker, the GitHub CLI's login, Teamtrail's own credentials) and use your SSH agent. That's why a changed check command needs your approval: you approve the command line, so read what it runs."]})]})}function NT({data:e}){const{map:t}=e;return i.jsxs(i.Fragment,{children:[t?i.jsx(Qe,{id:"mode",children:i.jsx(Ie,{title:`Trail ${t.key}`,children:i.jsx(yb,{value:t.mode,onChange:e.onMapMode})})}):i.jsx(Ae,{children:"Chart or pick a trail to set its mode, model matching and team."}),i.jsx(Qe,{id:"verification",storage:"repo",children:i.jsx(jT,{map:t})}),i.jsx(Qe,{id:"models",children:i.jsx(kT,{map:t,snaps:e.snaps,answered:e.answered,onChange:e.onModelMatching})}),t&&i.jsx(Qe,{id:"team",children:i.jsx(f$,{map:t})})]})}const Gm=10,gv=[0,10,16,26,18,24,16,18,22,22,26],vv=[0,1,1,1,2,2,4,4,4,5,5];function kv(e){let t=(16*e+128)*e+64;if(e<2)return t;const s=Math.floor(e/7)+2;return t-=(25*s-10)*s-55,e>=7?t-36:t}const ST=e=>gv[e],bT=e=>vv[e],yv=e=>Math.floor(kv(e)/8)-gv[e]*vv[e],wv=e=>e<10?8:16;function CT(e){if(e===1)return[];const t=Math.floor(e/7)+2,s=e*4+17,o=Math.ceil((e*4+4)/(t*2-2))*2,a=[6];for(let c=s-7;a.length<t;c-=o)a.splice(1,0,c);return a}function iu(e,t){let s=0;for(let o=7;o>=0;o--)s=s<<1^(s>>>7)*285,s^=(t>>>o&1)*e;return s}function $T(e){const t=new Array(e).fill(0);t[e-1]=1;let s=1;for(let o=0;o<e;o++){for(let a=0;a<t.length;a++)t[a]=iu(t[a],s),a+1<t.length&&(t[a]^=t[a+1]);s=iu(s,2)}return t}function TT(e,t){const s=t.map(()=>0);for(const o of e){const a=o^s.shift();s.push(0),t.forEach((c,u)=>s[u]^=iu(c,a))}return s}function ET(e,t){const s=[],o=(u,h)=>{for(let m=h-1;m>=0;m--)s.push(u>>>m&1)};o(4,4),o(e.length,wv(t));for(const u of e)o(u,8);const a=yv(t)*8;o(0,Math.min(4,a-s.length)),o(0,(8-s.length%8)%8);for(let u=236;s.length<a;u^=253)o(u,8);const c=[];for(let u=0;u<s.length;u+=8)c.push(s.slice(u,u+8).reduce((h,m)=>h<<1|m,0));return c}function AT(e,t){const s=ET(e,t),o=bT(t),a=ST(t),c=Math.floor(kv(t)/8),u=o-c%o,h=Math.floor(c/o),m=$T(a),p=[];for(let k=0,x=0;k<o;k++){const N=s.slice(x,x+h-a+(k<u?0:1));x+=N.length;const S=TT(N,m);k<u&&N.push(0),p.push([...N,...S])}const v=[];for(let k=0;k<p[0].length;k++)for(let x=0;x<p.length;x++)(k!==h-a||x>=u)&&v.push(p[x][k]);return v}const IT=[(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 Ic(e,t){const s=IT[t];for(let o=0;o<e.size;o++)for(let a=0;a<e.size;a++)!e.fixed[o][a]&&s(a,o)&&(e.dark[o][a]=!e.dark[o][a])}function qm(e){let t=0,s=1;for(let a=1;a<=e.length;a++)a<e.length&&e[a]===e[a-1]?s++:(s>=5&&(t+=s-2),s=1);const o=e.map(a=>a?"1":"0").join("");for(const a of["00001011101","10111010000"])for(let c=o.indexOf(a);c>=0;c=o.indexOf(a,c+1))t+=40;return t}function MT(e){let t=0,s=0;for(let a=0;a<e.size;a++)t+=qm(e.dark[a]),t+=qm(e.dark.map(c=>c[a]));for(let a=0;a<e.size;a++)for(let c=0;c<e.size;c++){if(e.dark[a][c]&&s++,c===e.size-1||a===e.size-1)continue;const u=e.dark[a][c];u===e.dark[a][c+1]&&u===e.dark[a+1][c]&&u===e.dark[a+1][c+1]&&(t+=3)}const o=e.size*e.size;return t+Math.floor(Math.abs(s*20-o*10)/o)*10}const an=(e,t)=>(e>>>t&1)!==0;function St(e,t,s,o){e.dark[s][t]=o,e.fixed[s][t]=!0}function Mc(e,t,s){for(let o=-4;o<=4;o++)for(let a=-4;a<=4;a++){const c=t+a,u=s+o,h=Math.max(Math.abs(a),Math.abs(o));c>=0&&c<e.size&&u>=0&&u<e.size&&St(e,c,u,h!==2&&h!==4)}}function RT(e,t,s){for(let o=-2;o<=2;o++)for(let a=-2;a<=2;a++)St(e,t+a,s+o,Math.max(Math.abs(a),Math.abs(o))!==1)}function ru(e,t){const s=0|t;let o=s;for(let c=0;c<10;c++)o=o<<1^(o>>>9)*1335;const a=(s<<10|o)^21522;for(let c=0;c<=5;c++)St(e,8,c,an(a,c));St(e,8,7,an(a,6)),St(e,8,8,an(a,7)),St(e,7,8,an(a,8));for(let c=9;c<15;c++)St(e,14-c,8,an(a,c));for(let c=0;c<8;c++)St(e,e.size-1-c,8,an(a,c));for(let c=8;c<15;c++)St(e,8,e.size-15+c,an(a,c));St(e,8,e.size-8,!0)}function OT(e,t){if(t<7)return;let s=t;for(let a=0;a<12;a++)s=s<<1^(s>>>11)*7973;const o=t<<12|s;for(let a=0;a<18;a++){const c=e.size-11+a%3,u=Math.floor(a/3);St(e,c,u,an(o,a)),St(e,u,c,an(o,a))}}function LT(e){const t=e*4+17,s=()=>Array.from({length:t},()=>new Array(t).fill(!1)),o={size:t,dark:s(),fixed:s()};for(let u=0;u<t;u++)St(o,6,u,u%2===0),St(o,u,6,u%2===0);Mc(o,3,3),Mc(o,t-4,3),Mc(o,3,t-4);const a=CT(e),c=a.length-1;for(let u=0;u<=c;u++)for(let h=0;h<=c;h++)u===0&&h===0||u===0&&h===c||u===c&&h===0||RT(o,a[u],a[h]);return ru(o,0),OT(o,e),o}function PT(e){const t=[];for(let s=e-1;s>=1;s-=2){const o=s<=6?s-1:s,a=(o+1&2)===0;for(let c=0;c<e;c++){const u=a?e-1-c:c;t.push([o,u],[o-1,u])}}return t}function _T(e,t){let s=0;for(const[o,a]of PT(e.size))e.fixed[a][o]||s>=t.length*8||(e.dark[a][o]=an(t[s>>>3],7-(s&7)),s++)}function DT(e){const t=new TextEncoder().encode(e);let s=1;for(;s<=Gm&&4+wv(s)+t.length*8>yv(s)*8;)s++;if(s>Gm)return;const o=LT(s);_T(o,AT(t,s));let a=0,c=1/0;for(let u=0;u<8;u++){Ic(o,u),ru(o,u);const h=MT(o);h<c&&([a,c]=[u,h]),Ic(o,u)}return Ic(o,a),ru(o,a),o.dark}const Rc=4;function zT(e){const t=DT(e.text);if(!t)return null;const s=t.length+Rc*2,o=t.flatMap((a,c)=>a.map((u,h)=>u?`M${h+Rc} ${c+Rc}h1v1h-1z`:"")).join("");return i.jsxs("svg",{className:"si-qr",viewBox:`0 0 ${s} ${s}`,role:"img","aria-label":e.label,shapeRendering:"crispEdges",children:[i.jsx("rect",{width:s,height:s,fill:"#fff"}),i.jsx("path",{d:o,fill:"#000"})]})}function BT(e){const t=Xt(1e3),s=Math.max(0,Math.ceil((e.device.expiresAt-t)/6e4)),o=e.device.links[0];return e.device.expiresAt<=t?i.jsxs("div",{className:"si-code",children:[i.jsx("p",{className:"t-meta",children:"That code expired. Make a new one when the device is ready."}),i.jsx(P,{size:"sm",onClick:e.onDone,children:"Done"})]}):i.jsxs("div",{className:"si-code",children:[o&&i.jsx(zT,{text:o,label:"QR code that pairs another device"}),i.jsxs("div",{className:"si-code-words",children:[i.jsx("span",{className:"si-code-value t-code","aria-label":"Pairing code",children:e.device.code}),i.jsx(V,{parts:["Works once",`expires in ${s} min`]}),i.jsxs("p",{className:"t-meta si-note",children:["Scan it with the device’s camera, or open"," ",o?i.jsx("code",{className:"t-code",children:o.split("#")[0]}):"the Lookout"," there and type the code."]}),i.jsx(P,{size:"sm",onClick:e.onDone,children:"Done"})]})]})}function FT(e){const[t,s]=y.useState();return e.device?i.jsx(BT,{device:e.device,onDone:e.onDone}):e.lan.length?i.jsxs("div",{className:"si-pair",children:[i.jsx(P,{onClick:async()=>s(await e.onPair()),children:"Pair a device"}),t&&i.jsx("span",{className:"vf-err",children:t})]}):i.jsxs("p",{className:"t-meta si-note",children:["This Lookout listens on this machine only, so no other device can reach it. To pair a phone or another computer, start it with ",i.jsxs("code",{className:"t-code",children:[J.slug," --host 0.0.0.0"]})," on a network you trust. Another browser on this machine: run ",i.jsxs("code",{className:"t-code",children:[J.slug," pair"]}),"."]})}function UT(e){const[t,s]=y.useState(!1),[o,a]=y.useState(!1),[c,u]=y.useState(),h=async()=>{a(!0),u(await e.onRevoke().catch(m=>m.message)),a(!1),s(!1)};return t?i.jsxs("span",{className:"ra-revoke ask",children:[i.jsx("span",{className:"t-meta",children:"It’s signed out now."}),i.jsxs(P,{size:"sm",disabled:o,onClick:h,children:["Revoke ",e.name]}),i.jsx(P,{size:"sm",variant:"ghost",onClick:()=>s(!1),children:"Keep"})]}):i.jsxs("span",{className:"ra-revoke",children:[i.jsx(P,{size:"sm","aria-label":`Revoke ${e.name}`,onClick:()=>s(!0),children:"Revoke"}),c&&i.jsx("span",{className:"vf-err",children:c})]})}const WT={machine:"This machine",device:"Another device"};function HT(e){const t=Date.now();return i.jsx("ul",{className:"ra-list si-list",children:e.sessions.map(s=>i.jsx(Ce,{as:"li",className:"ra-row",title:s.current?`${s.name} · this browser`:s.name,titleText:s.name,context:i.jsx(V,{parts:[WT[s.kind],s.via==="opened-page"?`From the page ${J.name} opened`:void 0,s.via==="opened-page"?{text:Qj(s.id),code:!0}:void 0,`Paired ${Uo(s.pairedAt,t)}`,`Last used ${Uo(s.lastUsedAt,t)}`]}),below:s.current?void 0:i.jsx(UT,{name:s.name,onRevoke:()=>e.onRevoke(s.id)})},s.id))})}function KT(){return i.jsxs("div",{className:"ra-notes",children:[i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"What it stops."})," A program on this machine, or a device on your network, that isn’t a paired browser: an agent with ",i.jsx("code",{children:"curl"})," can’t approve its own work, answer its own questions or change your settings through the Lookout. The session lives only in this page’s own storage and is sent only by this page, never as a cookie, so another server on this machine (an agent’s dev server on another port) gets nothing from your browser; and it goes only to a server that first proves it is this Lookout, so one that takes its port while the Lookout is stopped gets nothing either. A device paired here can read, answer and approve, but never change what runs on this machine or whom it trusts."]}),i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"What it can’t stop."})," A program that can read ",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:"," ",i.jsxs("code",{children:[J.slug," connect"]})," sets that up for the agents it registers."]})]})}const xv=`${J.apiPrefix}/sign-in`;async function Oc(e,t={}){const s=await fetch(`${xv}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return{ok:s.ok,reply:await s.json().catch(()=>({}))}}function VT(){const[e,t]=y.useState(),[s,o]=y.useState(),a=y.useCallback(()=>{fetch(`${xv}/sessions`).then(async m=>m.ok?await m.json():(await m.json().catch(()=>({}))).elsewhere?"elsewhere":null).then(t,()=>t(null))},[]);y.useEffect(a,[a]);const c=y.useCallback(async()=>{const{ok:m,reply:p}=await Oc("/codes");if(!m)return p.error??"No code could be made.";o(p)},[]),u=y.useCallback(async m=>{const{ok:p,reply:v}=await Oc("/revoke",{id:m});return a(),p?void 0:v.error??"That browser could not be revoked."},[a]),h=y.useCallback(async()=>{await Oc("/sign-out"),mg(),location.reload()},[]);return{view:e,device:s,closeDevice:()=>(o(void 0),a()),pairDevice:c,revoke:u,signOut:h}}function GT(){const{view:e,device:t,closeDevice:s,pairDevice:o,revoke:a,signOut:c}=VT();if(!e)return null;const u=i.jsx("div",{className:"si-signout",children:i.jsx(P,{size:"sm",variant:"ghost",onClick:c,children:"Sign out of this browser"})});return e==="elsewhere"?i.jsxs(Ie,{title:"Browsers & devices",children:[i.jsx("p",{className:"vf-intro",children:"This device is paired with the Lookout. Browsers and devices are paired and revoked on the machine it runs on."}),u]}):i.jsxs(Ie,{title:"Browsers & devices",children:[i.jsx("p",{className:"vf-intro",children:"Every browser that opens this Lookout is paired, and stays signed in while it runs (up to 30 days after it was last used). Revoke one and it’s signed out at once. When the Lookout restarts, browsers and devices pair again: the link is in the terminal where it starts."}),i.jsx(HT,{sessions:e.sessions,onRevoke:a}),i.jsx(FT,{lan:e.lan,device:t,onPair:o,onDone:s}),u,i.jsx(KT,{})]})}function qT(){return y.useEffect(()=>{const e=setInterval(()=>void ha().then(t=>t!=="failed"&&location.reload()),3e3);return()=>clearInterval(e)},[]),i.jsx("div",{className:"pair-page",children:i.jsxs(ze,{as:"main",className:"pair-card",children:[i.jsx("div",{className:"onb-brand",children:i.jsx(va,{className:"onb-title"})}),i.jsxs("h1",{className:"t-heading pair-title",children:[J.name," isn’t running here"]}),i.jsxs("p",{className:"t-body pair-step",children:["Start it with ",i.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 Du(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 s=await t.json().catch(()=>({}));if(!t.ok)return s.error??"That code didn’t work. Get a new one.";s.id&&s.session&&s.verifier&&jN({id:s.id,secret:s.session,verifier:s.verifier})}function QT(e){const[t,s]=y.useState(!1),o=async()=>{s(!0);const a=await Du(e.code);if(!a)return location.reload();s(!1),e.onFailed(a)};return i.jsxs("div",{className:"pair-confirm",children:[i.jsxs("p",{className:"t-body pair-step",children:["This link signs this browser in to the Lookout. Use it only if it came to you from"," ",i.jsx("code",{className:"t-code",children:J.slug}),", ",i.jsxs("code",{className:"t-code",children:[J.slug," pair"]})," or Pair a device in the Lookout’s Settings."]}),i.jsx("div",{children:i.jsx(P,{variant:"primary",disabled:t,onClick:o,children:"Sign in this browser"})})]})}function Qm(){const[e,t]=y.useState(""),[s,o]=y.useState(!1),[a,c]=y.useState(),u=async()=>{if(!e.trim()||s)return;o(!0);const h=await Du(e);o(!1),c(h),h||location.reload()};return i.jsxs("form",{className:"pair-device",onSubmit:h=>{h.preventDefault(),u()},children:[i.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."]}),i.jsxs("div",{className:"pair-code-row",children:[i.jsx("input",{className:"pair-code-input t-code",value:e,onChange:h=>t(h.target.value),placeholder:"ABCD-EFGH","aria-label":"Pairing code",autoComplete:"one-time-code",autoCapitalize:"characters",spellCheck:!1,maxLength:20}),i.jsx(P,{type:"submit",variant:"primary",disabled:s||!e.trim(),children:"Pair"})]}),a&&i.jsx("p",{className:"vf-err",role:"alert",children:a})]})}function Ym(){return i.jsxs("p",{className:"t-body pair-step pair-here",children:["On the machine ",J.name," runs on, run ",i.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 ",i.jsx("code",{className:"t-code",children:J.slug})," printed in its terminal."]})}function YT(e){return i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"t-body pair-step",children:"The Lookout opens only in browsers you’ve paired."}),e.local?i.jsx(Ym,{}):i.jsx(Qm,{}),e.local?i.jsx(Qm,{}):i.jsx(Ym,{})]})}function JT(e){const[t,s]=y.useState(),[o,a]=y.useState(e.code),[c,u]=y.useState(e.code);e.code!==c&&(u(e.code),a(e.code));const h=m=>(s(m),a(void 0));return i.jsx("div",{className:"pair-page",children:i.jsxs(ze,{as:"main",className:"pair-card",children:[i.jsx("div",{className:"onb-brand",children:i.jsx(va,{className:"onb-title"})}),i.jsx("h1",{className:"t-heading pair-title",children:"Pair this browser"}),t&&i.jsx("p",{className:"pair-problem t-body",role:"alert",children:t}),o?i.jsx(QT,{code:o,onFailed:h}):i.jsx(YT,{local:e.local})]})})}function Jm(){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 Xm(){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"}:{kind:"signed-out",local:t.local===!0}}catch{return{kind:"no-server"}}}async function XT(){if(!wu())return Xm();const e=await ha();return e==="proven"?{kind:"signed-in"}:e==="unknown"?Xm():{kind:"not-running"}}function ZT(){const[e,t]=y.useState({kind:"checking"});return y.useEffect(()=>void XT().then(t),[]),y.useEffect(()=>NN(s=>s==="failed"&&t({kind:"not-running"})),[]),e}function eE({children:e}){const t=ZT(),[s,o]=y.useState(Jm);return y.useEffect(()=>{const a=()=>o(c=>Jm()??c);return window.addEventListener("hashchange",a),()=>window.removeEventListener("hashchange",a)},[]),y.useEffect(()=>{t.kind==="signed-in"&&s&&Du(s)},[t.kind,s]),t.kind==="checking"?null:t.kind==="signed-out"?i.jsx(JT,{local:t.local,code:s}):t.kind==="not-running"?i.jsx(qT,{}):i.jsx(i.Fragment,{children:e})}const tE=[{value:"auto",title:"Match my system"},{value:"day",title:"Day"},{value:"night",title:"Night"}];function nE(e){return i.jsx("div",{className:"choice-row compact",children:tE.map(t=>i.jsx(mt,{on:e.value===t.value,title:t.title,onClick:()=>e.onChange(t.value)},t.value))})}function sE({data:e}){const{prefs:t,update:s}=e;return i.jsxs(i.Fragment,{children:[i.jsx(Qe,{id:"appearance",storage:"browser",children:i.jsx(Ie,{title:"Appearance",children:i.jsx(nE,{value:t.theme,onChange:o=>s({theme:o})})})}),i.jsx(Qe,{id:"transcript",storage:"browser",children:i.jsx(Ie,{title:"HITL transcript",children:i.jsx(Hg,{value:t.hitlTranscript,onChange:o=>s({hitlTranscript:o})})})}),i.jsx(Qe,{id:"agent",children:i.jsx(Ie,{title:"Agent",children:i.jsx("div",{className:"choice-row",children:sg.map(o=>i.jsx(mt,{on:o.status==="primary",disabled:o.status!=="primary",title:o.name},o.id))})})}),i.jsx(Qe,{id:"devices",storage:"machine",children:i.jsx(GT,{})})]})}function iE(e){const{data:t,route:s}=e;switch(e.group){case"trail":return i.jsx(NT,{data:t});case"project":return i.jsx(U$,{data:t,route:s});case"alerts":return i.jsx(SC,{data:t,route:s});case"you":return i.jsx(sE,{data:t});case"projects":return i.jsx(Qe,{id:"projects",storage:"machine",children:i.jsx(oT,{})});case"about":return i.jsx(Qe,{id:"changelog",children:i.jsx(TC,{})});default:return e.group}}function rE(e){const{group:t,route:s}=e,o=y.useRef(null),a=y.useRef(null);return y.useEffect(()=>{var u,h;(u=o.current)==null||u.focus({preventScroll:!0});const c=s.section&&document.getElementById(`settings-${s.section}`);c?c.scrollIntoView({block:"start"}):(h=a.current)==null||h.scrollTo({top:0})},[t.id,s.section]),i.jsx("div",{className:"sp-pane",ref:a,children:i.jsxs("div",{className:"sp-pane-in",children:[i.jsxs("header",{className:"sp-pane-head",children:[i.jsx("h2",{className:"sp-title t-title",ref:o,tabIndex:-1,children:t.label}),i.jsx("p",{className:"sp-intro t-meta",children:t.intro})]}),i.jsx(iE,{group:t.id,data:e.data,route:s})]})})}function oE(e){return i.jsx("nav",{className:"sp-nav","aria-label":"Settings groups",children:i.jsx("ul",{children:ir.map(t=>{const s=t.id===e.current;return i.jsx(Ce,{as:"li",className:"sp-nav-row",selected:s,current:s?"page":void 0,title:t.label,context:i.jsx(V,{parts:t.sections.map(o=>o.title)}),trailing:e.drill&&"›",onOpen:()=>e.onPick(t.id)},t.id)})})})}function aE(e,t){return e.group?ir.find(s=>s.id===e.group):t==="mobile"?void 0:ir[0]}const lE={page:"Back to the Lookout",list:"Lookout",group:"Settings"},cE=(e,t)=>e?t?"group":"list":"page";function uE(e){const{bp:t,route:s}=e,o=t==="mobile",a=aE(s,t),c=cE(o,!!a),u=Vg()===!1,h=()=>c==="group"?e.onShow({}):e.onClose();y.useEffect(()=>{const v=k=>{k.key!=="Escape"||k.defaultPrevented||document.querySelector(".scrim")||(c==="group"?e.onShow({}):e.onClose())};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[c,e]);const m=v=>e.onShow({group:v}),p=c!=="group"&&i.jsx(oE,{current:a==null?void 0:a.id,onPick:m,drill:o});return i.jsxs(ze,{className:`zone decisions-view settings-page sp-${t}`,"aria-label":"Settings",children:[i.jsxs("header",{className:"dv-head",children:[i.jsxs("button",{className:"back",onClick:h,children:["‹ ",lE[c]]}),c!=="group"&&i.jsx(Ve,{as:"h2",children:"Settings"}),!o&&i.jsx("span",{className:"dv-head-right t-meta",children:"Esc"})]}),u&&i.jsx(pC,{}),i.jsxs("div",{className:"sp-body",children:[p,a&&i.jsx(rE,{group:a,data:e.data,route:s})]})]})}function dE(e){var a;const{rt:t,api:s,settings:o}=e;return o.route?i.jsx(uE,{bp:e.bp,route:o.route,onShow:o.show,onClose:o.close,data:{prefs:e.prefs,update:e.update,activeTracker:t.kind,location:t.adapter.location,map:(a=s.snap)==null?void 0:a.map,onMapMode:s.actions.setMode,snaps:Object.values(s.allSnaps),answered:s.activity.answered,onModelMatching:s.actions.setModelMatching}}):null}function hE(e){return i.jsxs(ze,{className:"zone side",style:{gridArea:"inspector"},children:[i.jsx(rS,{className:"zone-tabs",value:e.tab,onChange:e.onTab,items:[{id:"ticket",label:"Ticket"},{id:"activity",label:"Activity"},{id:"plan",label:"Plan",n:e.unspecified}]}),{ticket:e.ticket,activity:e.activity,plan:e.plan}[e.tab]]})}function jv(e){return e.filter(t=>t.state!=="out-of-scope").map(t=>({x:t.x,y:t.y,w:Ke,h:Ye}))}function fE(e){const{obstacles:t,from:s,to:o,clear:a}=e,c=t.flatMap(h=>[h.y-28,h.y+h.h+28]).filter(a),u=h=>Math.abs(h-s)+Math.abs(h-o);return c.reduce((h,m)=>u(m)<u(h)?m:h,c[0]??s)}const mE=6;function pE(e){const t=e.filter((a,c)=>c===0||a.x!==e[c-1].x||a.y!==e[c-1].y);let s=`M${t[0].x} ${t[0].y}`;for(let a=1;a<t.length-1;a++){const[c,u,h]=[t[a-1],t[a],t[a+1]],m=Math.min(mE,Zm(c,u)/2,Zm(u,h)/2),p=ep(u,c,m),v=ep(u,h,m);s+=`L${p.x} ${p.y}Q${u.x} ${u.y} ${v.x} ${v.y}`}const o=t[t.length-1];return`${s}L${o.x} ${o.y}`}function Zm(e,t){return Math.abs(e.x-t.x)+Math.abs(e.y-t.y)}function ep(e,t,s){return{x:e.x+Math.sign(t.x-e.x)*s,y:e.y+Math.sign(t.y-e.y)*s}}function qo(e){const t=e.direction==="TB",s=u=>t?{x:u.y,y:u.x}:u,o=s(e.a),a=s(e.b),c=e.obstacles.map(u=>t?{x:u.y,y:u.x,w:u.h,h:u.w}:u);return pE(gE({a:o,b:a,obstacles:c,gap:e.gap}).map(s))}function gE({a:e,b:t,obstacles:s,gap:o}){const a=s.filter(p=>p.x+p.w>e.x+1&&p.x<t.x-1),c=p=>!a.some(v=>p>v.y-8&&p<v.y+v.h+8),u=Math.min(e.x+o/2,(e.x+t.x)/2),h=Math.max(t.x-o/2,(e.x+t.x)/2);if(c(e.y))return[e,{x:h,y:e.y},{x:h,y:t.y},t];if(c(t.y))return[e,{x:u,y:e.y},{x:u,y:t.y},t];const m=fE({obstacles:a,from:e.y,to:t.y,clear:c});return[e,{x:u,y:e.y},{x:u,y:m},{x:h,y:m},{x:h,y:t.y},t]}function vE(e){if(e.direction==="LR"){const s=e.width+96;return{x:s,y:e.graphH/2,right:s+34,bottom:e.height}}const t=e.graphH+76;return{x:e.width/2,y:t,right:e.width,bottom:Math.max(e.height,t+40)}}function kE(e,t){const s=new Set(e.edges.map(c=>c.from)),o=e.nodes.filter(c=>c.state!=="out-of-scope"&&!s.has(c)),a=jv(e.nodes);return o.map(c=>{if(e.direction==="LR"){const m={x:c.x+Ke,y:c.y+Ye/2},p={x:t.x-30,y:t.y};return qo({direction:"LR",a:m,b:p,obstacles:a,gap:96})}const u={x:c.x+Ke/2,y:c.y+Ye},h={x:t.x,y:t.y-30};return qo({direction:"TB",a:u,b:h,obstacles:a,gap:48})})}function yE({x:e,y:t,text:s}){const o=s!=null&&s.trim()?`Destination
161
+ ${s.trim()}`:`Destination
162
+ Where this trail ends`;return i.jsxs("g",{className:"destination",transform:`translate(${e} ${t})`,"aria-label":o,"data-tip":o,tabIndex:0,children:[i.jsx("rect",{className:"x-hit",x:-24,y:-24,width:48,height:48}),i.jsx("path",{className:"x-stroke",d:"M-15 -16 C-9 -10 2 4 16 17"}),i.jsx("path",{className:"x-stroke",d:"M17 -15 C8 -8 -6 5 -16 17"})]})}function wE({trails:e}){return e.map(t=>i.jsx("path",{className:"edge edge-open edge-destination",d:t},t))}function xE(){return i.jsxs("defs",{children:[i.jsx("pattern",{id:"map-grid",width:"40",height:"40",patternUnits:"userSpaceOnUse",children:i.jsx("path",{d:"M40 0H0V40",fill:"none",stroke:"var(--map-grid)",strokeWidth:"1"})}),i.jsx("pattern",{id:"hatch-oos",width:"10",height:"10",patternUnits:"userSpaceOnUse",patternTransform:"rotate(45)",children:i.jsx("line",{x1:"0",y1:"0",x2:"0",y2:"10",stroke:"var(--line2)",strokeWidth:"1"})})]})}const Qo=(e,t)=>`${e}>${t}`;function jE(e,t,s=[]){const o=new Map(e.tickets.map(c=>[c.id,c]));return{tickets:t.nodes.map(c=>{const u=o.get(c.id);return u?{...u,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(u=>Qo(u,c.id)))),removedEdges:new Set(t.nodes.flatMap(c=>(c.removedEdges??[]).map(u=>Qo(u,c.id)))),frozen:new Set(s)}}function NE(e,t){const s=fx({...e,tickets:t}),o=new Set;for(let a=1;a<s.length;a++)o.add(Qo(s[a-1].id,s[a].id));return o}const tp={LR:130,TB:68};function SE(e){const{direction:t,from:s,to:o,cards:a}=e;if(t==="LR"){const h={x:s.x+Ke,y:s.y+Ye/2},m={x:o.x,y:o.y+Ye/2};return qo({direction:t,a:h,b:m,obstacles:a,gap:tp.LR})}const c={x:s.x+Ke/2,y:s.y+Ye},u={x:o.x+Ke/2,y:o.y};return qo({direction:t,a:c,b:u,obstacles:a,gap:tp.TB})}function bE(e){const{from:t,to:s,direction:o}=e,c=["edge",t.ticket.state!=="open"?"edge-done":"edge-open"];return e.critical&&c.push("edge-critical"),e.added&&c.push("edge-added"),e.removed&&c.push("edge-removed"),i.jsx("path",{className:c.join(" "),d:SE({direction:o,from:t,to:s,cards:e.cards})})}function CE(e){const{snap:t,tickets:s,direction:o,preview:a}=e,c=y.useMemo(()=>NE(t,s),[t,s]),u=y.useMemo(()=>jv(e.nodes),[e.nodes]);return e.edges.map(({from:h,to:m})=>{const p=Qo(h.ticket.id,m.ticket.id);return i.jsx(bE,{from:h,to:m,direction:o,cards:u,critical:c.has(p),added:a==null?void 0:a.newEdges.has(p),removed:a==null?void 0:a.removedEdges.has(p)},p)})}const zu=24,$E=13,TE=9.5;function EE(e){const t=e.guide;return i.jsx("g",{className:"meta",transform:`translate(${zu} ${e.y})`,children:e.chips.map((s,o)=>{const a=s.kind==="guide"?t:void 0;return i.jsxs("g",{className:Ge("card-chip",s.kind,s.kind==="state"&&e.tone,(a==null?void 0:a.off)&&"off"),"data-guide-id":a==null?void 0:a.id,transform:`translate(${s.x} 0)`,children:[a&&i.jsx("title",{children:a.tip}),i.jsx("rect",{width:s.w,height:$E,rx:3}),i.jsx("text",{x:(s.w-s.textW)/2,y:TE,textLength:s.textW,lengthAdjust:"spacingAndGlyphs",children:s.text})]},o)})})}const Nv=5,AE={sans:"9.5px 'Figtree Variable', system-ui, sans-serif",mono:"8.55px 'JetBrains Mono Variable', ui-monospace, monospace"};let Qi;function IE(){if(Qi!==void 0)return Qi;try{Qi=typeof document>"u"?null:document.createElement("canvas").getContext("2d")}catch{Qi=null}return Qi}function ME(e,t="sans"){const s=IE();return s?(s.font=AE[t],s.measureText(e).width*1.04):e.length*Nv}const np=4,sp=3,RE=6;function OE(e){var k;const t=Ke-zu-8-(e.reserve??0),s=((k=e.state)==null?void 0:k.split(" · "))??[],o=[{kind:"key",text:e.key},{kind:"type",text:e.type},...e.guide===void 0?[]:[{kind:"guide",text:e.guide}],...s.map(x=>({kind:"state",text:x})),...e.needsYou?[{kind:"needs",text:"needs you"}]:[]],a=t-o.length*2*np-(o.length-1)*sp,c=x=>ME(x.text,x.kind==="key"?"mono":"sans"),u=o.filter(x=>x.kind!=="guide").reduce((x,N)=>x+c(N),0),h=Math.max(RE,Math.floor((a-u)/Nv)),m=o.map(x=>x.kind==="guide"?{...x,text:YC(x.text,h)}:x),p=Math.min(1,a/m.reduce((x,N)=>x+c(N),0));let v=0;return m.map(x=>{const N=c(x)*p,S={...x,x:v,w:N+2*np,textW:N};return v+=S.w+sp,S})}function LE(e,t,s){const o=e.state==="frontier"||e.state==="rework";if(!(!t||s||e.ticket.assignee||!o))return t}function PE(e){const t=["node",`st-${e.n.state}`,`tone-${e.tone}`,e.hitl?"hitl":"afk"];return e.selected&&t.push("sel"),e.live&&t.push("live"),e.waiting&&t.push("waiting"),e.stalled&&!e.waiting&&t.push("stalled"),e.mark&&t.push(`mark-${e.mark}`),e.frozen&&t.push("frozen"),t.join(" ")}function _E({wait:e,session:t}){return e?i.jsx("title",{children:`Needs a ${e} model: no connected agent runs one`}):t?i.jsx("title",{children:`${t.agent} · step ${t.step}/${t.total} · ${t.stepLabel.toLowerCase()}`}):null}const DE={claimed:"working",verifying:"working",frontier:"ready",blocked:"backlog",parked:"backlog",decided:"done","out-of-scope":"cancelled",rework:"attention",held:"attention"};function zE(e){const t=DE[e.state];return t==="done"||t==="cancelled"?t:e.attention?"attention":e.live?"working":t}function BE({mark:e,frozen:t}){const s=e&&e!=="unchanged"&&e!=="cancelled"?e:void 0;return i.jsxs(i.Fragment,{children:[e==="cancelled"&&i.jsx("line",{className:"strike",x1:8,y1:Ye/2,x2:Ke-8,y2:Ye/2}),s&&i.jsx("text",{className:"reroute-tag",x:Ke-8,y:Ye-7,textAnchor:"end",children:s}),t&&i.jsx("text",{className:"freeze",x:Ke-(s?58:8),y:Ye-7,textAnchor:"end",children:"❄"})]})}function FE(e){const{n:t,session:s}=e,o=t.ticket.assignee;return e.waiting?{text:"waiting on you",tone:"urgent"}:e.stalled?{text:`stalled · ${o}`,tone:"warn"}:e.wait?{text:`needs ${e.wait}`,tone:"warn"}:s&&e.step?{text:`${s.agent} · step ${s.step}/${s.total}`,tone:"agent"}:s?{text:s.agent,tone:"agent"}:t.state==="claimed"?{text:o??"working",tone:"agent"}:{text:pN[t.state],tone:""}}function UE({tone:e,cy:t}){return e==="done"?i.jsx("path",{className:"dot dot-done",d:`M10 ${t}l2.5 2.5 4.5 -5`}):i.jsx("circle",{className:`dot dot-${e}`,cx:13,cy:t,r:e==="backlog"?3:3.5})}function WE(e,t,s=2){const o=e.split(/\s+/),a=[];let c="";for(const u of o)(c+" "+u).trim().length>t?(a.push(c.trim()),c=u):c+=" "+u;if(a.push(c.trim()),a.length>s){const u=a.slice(0,s);return u[s-1]=u[s-1].slice(0,t-1)+"…",u}return a}const HE=26;function KE({n:e,session:t,stalled:s,flag:o,selected:a,onSelect:c,mark:u,frozen:h,needs:m}){const p=e.ticket,v=WE(p.title,HE),k=rr(p)==="hitl",x=!!(t!=null&&t.waitingOn),N=!!u&&u!=="unchanged",S=LE(e,m,!!t),j=y$(p.guide),A=N?void 0:FE({n:e,session:t,waiting:x,stalled:s,wait:S,step:!j}),C=k&&!N&&(p.type==="task"||p.type==="execute"),R=x||!!s||!!S||C&&e.state==="frontier",L=zE({state:e.state,live:!!t,attention:R}),U=tr[p.type],Z=(N&&u!=="cancelled"?44:0)+(h?12:0),Q=OE({key:p.key,type:U,guide:j==null?void 0:j.name,state:A==null?void 0:A.text,needsYou:C,reserve:Z}),W=v.length>1?19:24;return i.jsxs("g",{className:PE({n:e,tone:L,hitl:k,selected:a,live:!!t,waiting:x,stalled:s,mark:u,frozen:h}),style:{transform:`translate(${e.x}px, ${e.y}px)`},onClick:ie=>{ie.stopPropagation(),c({kind:"ticket",id:p.id})},children:[i.jsx(_E,{wait:S,session:t}),i.jsx("rect",{className:"ring",x:-3.5,y:-3.5,width:Ke+7,height:Ye+7,rx:9}),i.jsx("rect",{className:"card",x:.5,y:.5,width:Ke-1,height:Ye-1,rx:6}),i.jsx(UE,{tone:L,cy:W-4}),v.map((ie,G)=>i.jsx("text",{className:"title",x:zu,y:W+G*14,children:ie},G)),i.jsx(EE,{chips:Q,y:W+v.length*14-8,tone:A==null?void 0:A.tone,guide:j}),o&&i.jsx("circle",{className:`pr-flag-dot ${o}`,cx:Ke-2,cy:2,r:4}),i.jsx(BE,{mark:u,frozen:h})]})}const ip=.72;function VE(e){const{fit:t,nodes:s,size:o,pad:a}=e;if(t.k>=ip)return t;const c=s.find(h=>h.state==="claimed")??s.find(h=>h.state==="frontier")??s[0];if(!c)return t;const u=ip;return{k:u,x:o.w/2-(c.x+a+Ke/2)*u,y:o.h/2-(c.y+a+Ye/2)*u}}function GE(e){const{y:t,width:s,height:o}=e,a=e.nodes.filter(c=>c.state==="out-of-scope").length;return a?i.jsxs("g",{className:"quarantine",children:[i.jsx("rect",{x:-20,y:t-30,width:s+40,height:o+18,fill:"url(#hatch-oos)"}),i.jsx("line",{x1:-20,y1:t-30,x2:s+20,y2:t-30}),i.jsxs("text",{x:-12,y:t-12,children:["Out of scope · ",a]})]}):null}const st=280,rp=4,qE=220,Us=e=>Math.round(e/rp)*rp;function QE(e){let t=2166136261;for(const s of e)t=Math.imul(t^s.charCodeAt(0),16777619);return()=>{t=t+1831565813|0;let s=Math.imul(t^t>>>15,1|t);return s=s+Math.imul(s^s>>>7,61|s)^s,((s^s>>>14)>>>0)/4294967296}}function Lc(e,t,s,o){return Array.from({length:6},()=>{const a=o*(.5+e()*.7),c=o*(.3+e()*.4);return{x:Us(t+(e()-.5)*o*.8-a/2),y:Us(s+(e()-.5)*o*.5-c/2),w:Us(a),h:Us(c)}})}function YE(e){const{width:t,height:s,nodes:o}=e,a=QE(e.seed),c=(x,N)=>x+a()*(N-x),u=(x,N)=>!o.some(S=>x>S.x-52&&x<S.x+Ke+28&&N>S.y-52&&N<S.y+Ye+28),h=(t+st*2)*(s+st*2),m=Array.from({length:Math.round(h/9e4)},()=>Lc(a,c(-st,t+st),c(-st,s+st),c(160,360))).flat(),p=[...Lc(a,t+st*.55,s+st*.55,300),...Lc(a,-st*.5,-st*.45,220)],v=[],k=(x,N,S)=>{v.length<qE&&u(N,S)&&v.push({sprite:x,x:Us(N),y:Us(S)})};for(let x=0;x<Math.round(h/3e4);x++){const N=c(-st,t+st),S=c(-st,s+st),j=3+Math.floor(a()*5);for(let A=0;A<j;A++)k(a()<.65?"pine":"oak",N+c(-70,70),S+c(-44,44))}for(let x=0;x<Math.round(h/45e3);x++)k(a()<.4?"rock":"tuft",c(-st,t+st),c(-st,s+st));return v.sort((x,N)=>x.y-N.y),{grass:m,water:p,items:v}}const Sv={pine:i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"16",y:"30",width:"4",height:"10",fill:"var(--map-trunk)"}),i.jsx("path",{d:"M18 0l9 12h-4l8 10h-4l9 11H0l9-11H5l8-10H9z",fill:"var(--map-pine)"}),i.jsx("path",{d:"M18 0l9 12h-4l8 10h-4l9 11H18z",fill:"var(--map-pine2)"})]}),oak:i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"16",y:"24",width:"4",height:"12",fill:"var(--map-trunk)"}),i.jsx("circle",{cx:"18",cy:"14",r:"14",fill:"var(--map-oak)"}),i.jsx("circle",{cx:"10",cy:"17",r:"8",fill:"var(--map-oak)"}),i.jsx("circle",{cx:"26",cy:"17",r:"8",fill:"var(--map-oak)"}),i.jsx("circle",{cx:"22",cy:"10",r:"6",fill:"var(--map-oak2)"})]}),rock:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M1 16Q2 6 10 3Q18-1 23 6Q28 11 27 16z",fill:"var(--map-rock)"}),i.jsx("path",{d:"M15 16Q15 8 19 4Q25 8 27 16z",fill:"var(--map-rock2)"})]}),tuft:i.jsx("path",{d:"M4 8Q3 4 1 1M14 8Q14 3 14 0M24 8Q25 4 27 1",fill:"none",stroke:"var(--map-pine2)",strokeWidth:"2.5",strokeLinecap:"round"})};function JE({name:e}){return i.jsx("symbol",{id:`terrain-${e}`,overflow:"visible",children:Sv[e]})}const XE=Object.keys(Sv),ZE=y.memo(function(t){const{seed:s,width:o,height:a,nodes:c}=t,u=y.useMemo(()=>YE({seed:s,width:o,height:a,nodes:c}),[s,o,a,c]);return i.jsxs("g",{className:"terrain","aria-hidden":"true",children:[i.jsx("defs",{children:XE.map(h=>i.jsx(JE,{name:h},h))}),u.grass.map((h,m)=>i.jsx("rect",{x:h.x,y:h.y,width:h.w,height:h.h,fill:"var(--map-grass)"},m)),u.water.map((h,m)=>i.jsx("rect",{x:h.x,y:h.y,width:h.w,height:h.h,fill:"var(--map-water)"},m)),i.jsx("rect",{x:-4e3,y:-4e3,width:o+8e3,height:a+8e3,fill:"url(#map-grid)"}),u.items.map((h,m)=>i.jsx("use",{href:`#terrain-${h.sprite}`,x:h.x,y:h.y},m))]})}),e2=380;function t2(e){const{selId:t,size:s}=e,o=y.useRef(e);o.current=e;const a=y.useRef(!0);y.useEffect(()=>{if(a.current){a.current=!1;return}const{nodes:c,pad:u,view:h,setView:m,onFocus:p}=o.current,v=t?c.find(C=>C.ticket.id===t):void 0;if(!v||!s.w)return;p();const k=Math.min(1.4,Math.max(h.k,1.05)),x={k,x:s.w/2-(u+v.x+Ke/2)*k,y:s.h/2-(u+v.y+Ye/2)*k};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return m(x);const N=h,S=performance.now();let j=0;const A=C=>{const R=Math.min(1,(C-S)/e2),L=1-(1-R)**3;m({k:N.k+(x.k-N.k)*L,x:N.x+(x.x-N.x)*L,y:N.y+(x.y-N.y)*L}),R<1&&(j=requestAnimationFrame(A))};return j=requestAnimationFrame(A),()=>cancelAnimationFrame(j)},[t])}function n2(e,t){const s=y.useRef(t);s.current=t,y.useEffect(()=>{const o=e.current;if(!o)return;const a=p=>{const v=o.getBoundingClientRect();return{x:p.clientX-v.left,y:p.clientY-v.top}},c=p=>{p.preventDefault();const v=p.ctrlKey?.01:.0015;s.current(Math.exp(-p.deltaY*v),a(p))};let u=1;const h=p=>{p.preventDefault(),u=1},m=p=>{p.preventDefault();const v=p;s.current(v.scale/u,a(v)),u=v.scale};return o.addEventListener("wheel",c,{passive:!1}),o.addEventListener("gesturestart",h,{passive:!1}),o.addEventListener("gesturechange",m,{passive:!1}),()=>{o.removeEventListener("wheel",c),o.removeEventListener("gesturestart",h),o.removeEventListener("gesturechange",m)}},[e])}function op(e,t,s){const o=Math.min(3,Math.max(.2,t));return{k:o,x:s.x-(s.x-e.x)*o/e.k,y:s.y-(s.y-e.y)*o/e.k}}const on=32,s2=1.8;function i2(e){var oe;const{snap:t,selection:s,onSelect:o,preview:a}=e,c=(a==null?void 0:a.tickets)??t.tickets,u=y.useRef(null),[h,m]=y.useState({w:0,h:0});y.useEffect(()=>{const D=u.current;if(!D)return;const X=new ResizeObserver(([le])=>m({w:le.contentRect.width,h:le.contentRect.height}));return X.observe(D),()=>X.disconnect()},[]);const p=y.useMemo(()=>{const D=Wf(c,"LR",t.map.mode),X=Wf(c,"TB",t.map.mode),le=te=>Math.min(h.w/(te.width+on*2),h.h/(te.height+on*2+16));return le(D)*s2>=le(X)?D:X},[c,t.map.mode,h.w,h.h]),v=(D,X)=>Math.min(1.25,Math.max(e.minFit??0,Math.min(h.w/D,h.h/X))),k=y.useMemo(()=>{const D=p.width+on*2,X=p.height+on*2+16,te=p.nodes.some(Y=>Y.state==="out-of-scope")&&h.h?Math.max(0,h.h/v(D,X)-X):0;if(!te)return{...p,slack:te};const K=new Map(p.nodes.map(Y=>[Y,{...Y,y:Y.y+(Y.state==="out-of-scope"?te:te/2)}]));return{...p,slack:te,nodes:[...K.values()],edges:p.edges.map(Y=>({from:K.get(Y.from),to:K.get(Y.to)})),quarantineY:p.quarantineY+te,height:p.height+te}},[p,h.w,h.h,e.minFit]),x=vE(k),N=x.right+on*2,S=x.bottom+on*2+16,j=()=>{const D=v(N,S);return{k:D,x:Math.max(0,(h.w-N*D)/2),y:Math.max(0,(h.h-S*D)/2)}},[A,C]=y.useState({k:1,x:0,y:0}),R=y.useRef(!1);y.useEffect(()=>{R.current=!1},[t.map.id]),y.useEffect(()=>{!R.current&&h.w&&C(VE({fit:j(),nodes:k.nodes,size:h,pad:on}))},[h.w,h.h,N,S,t.map.id]);const L=y.useRef(new Map),U=y.useRef(null),Z=D=>{const X=u.current.getBoundingClientRect();return{x:D.clientX-X.left,y:D.clientY-X.top}},Q=()=>{var te;const D=[...L.current.values()],X=D.length>1?{x:(D[0].x+D[1].x)/2,y:(D[0].y+D[1].y)/2}:D[0],le=D.length>1?Math.hypot(D[0].x-D[1].x,D[0].y-D[1].y):0;U.current={view:A,dist:le,mid:X,moved:((te=U.current)==null?void 0:te.moved)??!1}};n2(u,(D,X)=>{R.current=!0,C(le=>op(le,le.k*D,X))});const W=Xt(5e3),ie=ku(e.leases,t.map.id),G=$u(),ve=(oe=_u())==null?void 0:oe.waiting,Le=new Map(e.sessions.filter(D=>dn(D)&&D.ticketId).map(D=>[D.ticketId,D])),$e=(s==null?void 0:s.kind)==="ticket"?s.id:void 0;return t2({selId:$e,nodes:k.nodes,size:h,pad:on,view:A,setView:C,onFocus:()=>R.current=!0}),i.jsxs("div",{className:"graph-box",ref:u,onPointerDown:D=>{L.current.set(D.pointerId,Z(D)),L.current.size===1&&(U.current=null),Q()},onPointerMove:D=>{var te;if(!L.current.has(D.pointerId)||!U.current)return;L.current.set(D.pointerId,Z(D));const X=U.current,le=[...L.current.values()];if(le.length>1){const K={x:(le[0].x+le[1].x)/2,y:(le[0].y+le[1].y)/2},Y=Math.hypot(le[0].x-le[1].x,le[0].y-le[1].y),B=op(X.view,X.view.k*Y/(X.dist||Y),X.mid);C({...B,x:B.x+K.x-X.mid.x,y:B.y+K.y-X.mid.y}),X.moved=!0}else{const K=le[0].x-X.mid.x,Y=le[0].y-X.mid.y;if(!X.moved&&Math.hypot(K,Y)<5)return;X.moved||(te=u.current)==null||te.setPointerCapture(D.pointerId),X.moved=!0,C({...X.view,x:X.view.x+K,y:X.view.y+Y})}R.current=!0},onPointerUp:D=>{L.current.delete(D.pointerId),L.current.size&&Q()},onPointerCancel:D=>L.current.delete(D.pointerId),onClickCapture:D=>{var X;(X=U.current)!=null&&X.moved&&(D.stopPropagation(),U.current=null)},children:[i.jsxs("svg",{className:"graph",width:h.w,height:h.h,onClick:()=>o(null),children:[i.jsx(xE,{}),i.jsx("g",{transform:`translate(${A.x} ${A.y}) scale(${A.k})`,children:i.jsxs("g",{transform:`translate(${on} ${on})`,children:[i.jsx(ZE,{seed:t.map.id,width:N,height:S,nodes:k.nodes}),i.jsx(GE,{y:k.quarantineY,width:k.width,height:k.quarantineH,nodes:k.nodes}),i.jsx(CE,{snap:t,tickets:c,direction:k.direction,nodes:k.nodes,edges:k.edges,preview:a}),i.jsx(wE,{trails:kE(k,x)}),k.nodes.length>0&&i.jsx(yE,{x:x.x,y:x.y,text:t.map.sections.destination}),k.nodes.map(D=>{var X;return i.jsx(KE,{n:D,session:Le.get(D.ticket.id),stalled:!!ie.get(D.ticket.id)&&oa(ie.get(D.ticket.id),W)!=="live",flag:ON(Ys.ticket(G,t.map.id,D.ticket.id)),selected:$e===D.ticket.id,onSelect:o,mark:a==null?void 0:a.marks.get(D.ticket.id),frozen:a==null?void 0:a.frozen.has(D.ticket.id),needs:(X=ve==null?void 0:ve.find(le=>le.mapId===t.map.id&&le.ticketId===D.ticket.id))==null?void 0:X.tier},D.ticket.id)})]})})]}),i.jsx("button",{className:"btn sm fit-btn","data-tip":"Fit the whole trail in view",onPointerDown:D=>D.stopPropagation(),onClick:D=>{D.stopPropagation(),R.current=!0,C(j())},children:"Fit"})]})}const Pc=[["decided","Done"],["claimed","Working"],["frontier","Ready"],["blocked","Backlog"],["parked","Parked"],["out-of-scope","Cancelled"]],ap=[["verifying","Verifying"],["rework","Rework"],["held","Blocked"]];function r2({snap:e,sessions:t}){const s=Mp(e),o=p=>s[p],a=t.filter(xg).length,c=mx(e),u=Math.max(1,...c.map(p=>p.open+p.closed)),m=(e.map.verification??"off")!=="off"||ap.some(([p])=>o(p))?[...Pc.slice(0,2),...ap,...Pc.slice(2)]:Pc;return i.jsxs("div",{className:"status-panel",children:[i.jsxs("div",{className:"sp-col sp-status",children:[i.jsxs("div",{className:"sp-head",children:[i.jsx(Ve,{as:"h3",children:"Status"}),i.jsxs("span",{className:"t-meta",children:[s.total," tickets"]})]}),i.jsxs("ul",{children:[m.map(([p,v])=>i.jsxs("li",{className:`st-${p} ${o(p)?"":"zero"}`,children:[i.jsx("i",{}),i.jsx("span",{children:v}),i.jsx("b",{children:o(p)})]},p)),i.jsxs("li",{className:`st-waiting ${a?"":"zero"}`,children:[i.jsx("i",{}),i.jsx("span",{children:"Waiting on you"}),i.jsx("b",{children:a})]})]})]}),i.jsxs("div",{className:"sp-block sp-col",children:[i.jsx("span",{className:"t-label",children:"Type mix"}),i.jsx("ul",{className:"mix",children:c.map(p=>i.jsxs("li",{title:`${p.type}: ${p.closed} closed, ${p.open} open`,children:[i.jsx("span",{className:"t-meta",children:tr[p.type]}),i.jsxs("span",{className:"mix-bar",children:[i.jsx("i",{className:"closed",style:{width:`${p.closed/u*100}%`}}),i.jsx("i",{className:"open",style:{width:`${p.open/u*100}%`}})]}),i.jsx("b",{children:p.open+p.closed})]},p.type))})]})]})}function o2(e){const[t,s]=y.useState(!1);return i.jsxs("div",{className:t?"status-drawer open":"status-drawer",children:[i.jsxs("button",{type:"button",className:"status-toggle","aria-expanded":t,onPointerDown:o=>o.stopPropagation(),onClick:()=>s(!t),children:["Summary ",i.jsx("span",{className:"caret",children:t?"▾":"▴"})]}),i.jsx(r2,{snap:e.snap,sessions:e.sessions})]})}function a2({planOnly:e,verifies:t}){const s=[["frontier","Ready"],["claimed","Working"],...t?[["verifying","Verifying"],["rework","Rework"],["held","Blocked"]]:[],["stalled","Stalled"],["blocked","Backlog"],["decided","Done"],...e?[["parked","Parked"]]:[],["out-of-scope","Cancelled"],["waiting","Waiting on you"]];return i.jsxs("div",{className:"legend",children:[s.map(([o,a])=>i.jsxs("span",{className:`lg st-${o}`,children:[i.jsx("i",{}),a]},o)),i.jsx("span",{className:"lg hitl",children:"● needs human"})]})}function l2(e){var o,a;const{snap:t,selection:s}=e.api;return i.jsxs(ze,{as:"main",className:"zone map-zone",style:{gridArea:"map"},children:[t&&i.jsx(kb,{}),(o=e.trail)==null?void 0:o.banner,i.jsxs("div",{className:"map-area",children:[t&&!e.compact&&i.jsx(o2,{snap:t,sessions:e.sessions}),t?i.jsx(i2,{snap:t,sessions:e.sessions,leases:e.api.leases,selection:s,onSelect:e.onSelect,minFit:e.minFit,preview:(a=e.trail)==null?void 0:a.preview}):i.jsxs("div",{className:"nomap",children:[i.jsx(jb,{}),i.jsx("h2",{children:"No trail"}),i.jsx("p",{className:"nomap-lede",children:"Describe your idea and create the trail here, or start it in your agent's chat. Scout frames it with you, then your agents get to work."}),i.jsx("div",{className:"actions",children:i.jsx(P,{variant:"primary",onClick:e.onNewTrail,"data-tip":"Describe the idea and create the trail",children:"New trail…"})}),i.jsx(Ho,{command:'/scout new "your idea"'})]}),t&&e.compact&&i.jsx(a2,{planOnly:t.map.mode==="plan-only",verifies:(t.map.verification??"off")!=="off"})]})]})}const c2=[["home","Inbox"],["map","Map"],["ticket","Ticket"],["activity","Activity"],["plan","Plan"]];function u2(e){const{tab:t,covered:s,pending:o}=e;return i.jsx("nav",{className:"tabbar",children:c2.map(([a,c])=>i.jsxs("button",{className:t===a&&!s?"on":"",onClick:()=>e.onPick(a),children:[c,a==="home"&&o>0&&i.jsx(us,{n:o,urgent:!0,pop:!0},o)]},a))})}function d2(e){const t={home:e.projects?i.jsxs("div",{className:"phone-home",children:[e.projects,e.inbox]}):e.inbox,map:e.map,ticket:i.jsx(ze,{className:"zone",children:e.ticket}),activity:i.jsx(ze,{className:"zone",children:e.activity}),plan:e.plan};return i.jsx("main",{className:"phone-view",children:e.decisions||t[e.tab]})}const lp={settingsPage:!0},cp=()=>Kg(new URLSearchParams(location.search).get("settings")),up=()=>{var e;return!!((e=history.state)!=null&&e.settingsPage)};function h2(){const[e,t]=y.useState(cp);y.useEffect(()=>{e&&!up()&&(history.replaceState(null,"",Ji(location.href,null)),history.pushState(lp,"",Ji(location.href,e)));const c=()=>t(cp());return window.addEventListener("popstate",c),()=>window.removeEventListener("popstate",c)},[]);const s=c=>{const u=Ji(location.href,c);e?history.replaceState(history.state,"",u):history.pushState(lp,"",u),t(c)},o=()=>{e&&(t(null),up()?history.back():history.replaceState(null,"",Ji(location.href,null)))},a=c=>s(Kg(c??"")??{});return{route:e,open:a,show:s,close:o,toggle:()=>e?o():a()}}function f2(e,t){const{activity:s,selection:o,setSelection:a,actions:c}=e,[u,h]=y.useState("ticket"),[m,p]=y.useState("home"),[v,k]=y.useState(0),[x,N]=y.useState(null),[S,j]=y.useState(!1),A=Q=>{j(!1),N({focus:Q})},C=()=>{N(null),j(Q=>!Q)};y.useEffect(()=>{const Q=s.sessions.find(W=>W.id===e.chatSession);!o&&(Q!=null&&Q.ticketId)&&Q.mapId===e.mapId&&a({kind:"ticket",id:Q.ticketId})},[e.chatSession,e.mapId]);const R=Q=>{a(Q),Q&&(t==="laptop"&&h("ticket"),t==="mobile"&&p("ticket"))},L=(Q,W,ie)=>{ie&&ie!==e.mapId&&c.selectMap(ie),c.openChat(Q);const G=s.sessions.find(ve=>ve.id===Q);W&&(G==null?void 0:G.mapId)===(ie??e.mapId)&&a({kind:"ticket",id:W}),t==="mobile"&&(p("home"),k(ve=>ve+1))};return{sideTab:u,setSideTab:h,phoneTab:m,setPhoneTab:p,convRequest:v,decisionsView:x,setDecisionsView:N,openDecisions:A,statsOpen:S,setStatsOpen:j,toggleStats:C,select:R,openChat:L,showChat:(Q,W,ie)=>{L(Q,W,ie),k(G=>G+1)},openTicket:(Q,W)=>{Q!==e.mapId&&c.selectMap(Q),a({kind:"ticket",id:W}),N(null),t==="laptop"&&h("ticket"),t==="mobile"&&p("ticket")}}}function m2(e,t){y.useEffect(()=>{document.title=`${J.name}: ${e?`(${e}) `:""}${t??"No trail"}`},[e,t])}function p2(e){const[t,s]=y.useState("…");return y.useEffect(()=>{fetch(`${je()}/list`).then(o=>o.json()).then(o=>{var c;const a=o.root.split("/").filter(Boolean);s((c=a[a.length-1])!=null&&c.startsWith(".")?a[a.length-2]??"repo":a[a.length-1]??"repo")}).catch(()=>s("repo"))},[e]),t}function g2(e,t){return y.useMemo(()=>{const s=e.sessions.filter(a=>a.mapId===t),o=new Set(e.sessions.filter(a=>a.mapId!==t).map(a=>a.id));return{...e,sessions:s,feed:e.feed.filter(a=>!a.sessionId||!o.has(a.sessionId))}},[e,t])}function v2({text:e}){return e.trim()?i.jsx("div",{className:"brief-prose",children:e.split(`
163
+ `).map((t,s)=>i.jsx("p",{children:t.split(/(`[^`]+`|\/?\b[\w.-]+\/[\w./-]+\b)/g).map((o,a)=>a%2===1?i.jsx("code",{children:o.replace(/`/g,"")},a):o)},s))}):i.jsx(Ae,{children:"Not covered"})}const dp=["summary","productContext","existing","conventions","dataModel","api","risks"];function k2(e){const{brief:t}=e,[s,o]=y.useState(!1),[a,c]=y.useState("");y.useEffect(()=>{const p=v=>v.key==="Escape"&&e.onClose();return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[e]);const u=t.sections,h=dp.filter(p=>u[p].trim()),m=dp.filter(p=>!u[p].trim());return i.jsx("div",{className:"scrim",onClick:e.onClose,children:i.jsxs(ze,{as:"div",className:"dialog brief-dialog",onClick:p=>p.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:"Discovery brief"}),i.jsx("span",{className:"t-meta",children:y2(t)})]}),i.jsxs("div",{className:"brief-body",children:[h.map(p=>i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:Gi[p]}),i.jsx(v2,{text:u[p]}),(p==="conventions"||p==="productContext")&&u[p].trim()&&i.jsx(Tu,{draft:()=>({title:`${Gi[p]}: ${u[p].split(`
164
+ `)[0].slice(0,80)}`,body:u[p],kind:p==="conventions"?"convention":"business-rule",sources:[`brief:${t.mapId}`]})})]},p)),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:Gi.assumptions}),u.assumptions.length?i.jsx("ul",{className:"item-list",children:u.assumptions.map(p=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:p.text}),i.jsx(V,{parts:[{text:p.id,code:!0}]})]},p.id))}):i.jsx(Ae,{children:"None listed"})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:Gi.openQuestions}),u.openQuestions.length?i.jsx("ul",{className:"brief-list",children:u.openQuestions.map(p=>i.jsx("li",{children:p},p))}):i.jsx(Ae,{children:"None"})]}),m.length>0&&i.jsxs("p",{className:"t-meta brief-empty",children:["Nothing noted on ",m.map(p=>Gi[p].toLowerCase()).join(", "),"."]}),t.note&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Your last request"}),i.jsx("p",{children:t.note})]})]}),s&&i.jsx(Ze,{label:"What should change?",children:i.jsx("textarea",{rows:3,value:a,onChange:p=>c(p.target.value),autoFocus:!0})}),e.changed&&e.onReviewAgain&&i.jsx(pa,{what:"The brief",onReviewAgain:e.onReviewAgain}),e.error&&i.jsx("p",{className:"urgent-text",children:e.error}),i.jsxs("div",{className:"actions",children:[t.status==="submitted"&&!s&&i.jsxs(i.Fragment,{children:[i.jsx(P,{onClick:()=>o(!0),children:"Request changes"}),i.jsx(P,{variant:"primary",disabled:e.changed,onClick:e.onAccept,children:"Accept brief"})]}),s&&i.jsxs(i.Fragment,{children:[i.jsx(P,{variant:"ghost",onClick:()=>o(!1),children:"Back"}),i.jsx(P,{variant:"primary",disabled:!a.trim(),onClick:()=>e.onRequestChanges(a.trim()),children:"Send to the agent"})]}),i.jsx(P,{variant:"ghost",onClick:e.onClose,children:"Close"})]})]})})}function y2(e){if(e.status==="draft")return"Not submitted yet";const t=[e.status.replace("-"," ")];return e.author&&t.push(`by ${e.author}`),e.submittedAt&&t.push(`${hn(Date.now()-e.submittedAt)} ago`),t.join(" · ")}function w2({brief:e,onReview:t}){return e.status!=="submitted"?null:i.jsx("div",{className:"brief-card",children:i.jsx(Ce,{edge:"attention",title:"Discovery brief ready for your review",context:i.jsx(V,{parts:["Discovery brief",e.author&&`by ${e.author}`]}),detail:e.sections.summary.split(`
165
+ `)[0],detailText:e.sections.summary,onOpen:t})})}const x2={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 j2({brief:e,onReview:t}){if(e.status==="accepted")return null;const[s,o]=x2[e.status],a=e.status==="submitted"?"edge-attention":"edge-neutral";return i.jsxs("div",{className:`discovery-banner map-banner ${a} st-${e.status}`,role:"status",children:[i.jsxs("span",{className:"mb-text",children:[i.jsx("span",{className:"mb-lead",children:s}),i.jsx("span",{className:"t-meta",children:o})]}),i.jsx(ni,{text:"Before implementation, an agent maps the existing system: the files involved, conventions, data and API impact, risks and assumptions. You accept the brief or ask for changes; task, execute and prototype tickets can't be claimed until you accept it."}),i.jsx(P,{size:"sm",variant:e.status==="submitted"?"primary":"ghost",onClick:t,children:e.status==="submitted"?"Review brief":"Open brief"})]})}const bv=`${je()}/briefs`;async function N2(e){if(!e)return{brief:null};const t=await fetch(`${bv}?mapId=${encodeURIComponent(e)}`);return t.ok?await t.json():{brief:null}}function S2(e){const t=e==null?void 0:e.map.id,[s,o]=y.useState(null),[a,c]=y.useState(),[u,h]=y.useState(),{reload:m,pushed:p}=pt({view:t,version:e==null?void 0:e.tickets.reduce((x,N)=>Math.max(x,N.updatedAt),e.map.updatedAt),load:()=>N2(t),show:x=>{o(x.brief),h(x.hash)},failed:()=>o(null),changed:x=>x.startsWith("briefs/")}),v=(x,N,S)=>fetch(`${bv}/${x}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,note:N,hash:S})}).then(async j=>{const A=await j.json().catch(()=>({}));if(!j.ok||!A.brief)throw new Error(A.error??`HTTP ${j.status}`);c(void 0),p(),o(A.brief)}),k=(x,N,S)=>v(x,N,S).then(()=>!0,j=>(c(j.message),m(),!1));return{brief:s,error:a,hash:u,accept:x=>k("accept",void 0,x),requestChanges:x=>k("request-changes",x)}}function b2(e){const t=S2(e),[s,o]=y.useState(!1),a=()=>o(!0),c=t.brief,u=ka(s?c==null?void 0:c.mapId:void 0,t.hash),h=c==null?void 0:c.sections;return{review:a,briefText:h?[h.existing,h.conventions,h.dataModel,h.api].join(`
166
+ `):"",banner:c&&i.jsx(j2,{brief:c,onReview:a}),inboxCard:c&&i.jsx(w2,{brief:c,onReview:a}),dialog:c&&s&&i.jsx(k2,{brief:c,error:t.error,changed:u.changed,onReviewAgain:u.reviewAgain,onAccept:()=>void t.accept(u.hash).then(m=>m&&o(!1)),onRequestChanges:m=>void t.requestChanges(m).then(p=>p&&o(!1)),onClose:()=>o(!1)})}}function C2(e){var p;const{reroute:t,onReview:s}=e,o=t.kind==="challenge-destination",a=((p=t.frozen)==null?void 0:p.length)??0,c=o?"wrong mountain?":"proposes a new plan",u=a?` ${a} ticket${a===1?" is":"s are"} closed until you decide.`:"",h=t.wide?" It touches most of the open tickets, so nothing is frozen.":"",m=`${t.reason.replace(/\.$/,"")}.${u}${h}`;return i.jsxs("div",{className:"reroute-banner map-banner edge-attention",role:"status",title:m,children:[i.jsxs("span",{className:"mb-text",children:[i.jsxs("span",{className:"mb-lead",children:[t.by," ",c]}),i.jsx("span",{className:"t-meta",children:m})]}),i.jsx(ni,{text:"An agent found that an assumption or the plan no longer holds and proposes changes. The map shows them: dashed outlines are tickets it adds, struck ones it cancels, ❄ marks tickets frozen until you approve or reject. Nothing changes until you decide."}),i.jsx(P,{size:"sm",variant:"ghost",className:"reroute-dismiss",onClick:e.onDismiss,children:"Dismiss"}),i.jsx(P,{size:"sm",variant:"primary",onClick:s,children:"Review"})]})}const $2=e=>e.changes.flatMap(t=>"ticket"in t?[t.ticket]:[]);function T2(e,t){const s=new Set($2(t));return e.tickets.filter(o=>s.has(o.id)&&o.updatedAt>t.at).map(o=>({key:o.key,title:o.title,what:E2(o)}))}function E2(e){return e.state==="closed"?"closed":e.assignee?`claimed by ${e.assignee}`:"changed"}function A2({parts:e}){return i.jsx("dl",{className:"reroute-parts",children:e.map(t=>i.jsxs("div",{children:[i.jsx("dt",{className:"t-label",children:t.label}),i.jsx("dd",{className:"t-body",children:t.text})]},t.label))})}const I2={"already-exists":"The work already exists","wrong-problem":"The trail targets the wrong problem",rescope:"The trail should be rescoped"},Cv="Dismissed by the trail lead. Carry on with the current plan.",M2="Declined by the trail lead.";function R2(e,t){var s,o,a;switch(e.op){case"edit_ticket":return[...(s=e.title)!=null&&s.trim()?[{label:"New title",text:e.title.trim()}]:[],...(o=e.body)!=null&&o.trim()?[{label:"New description (replaces the old one)",text:e.body.trim()}]:[]];case"add_ticket":return[...(a=e.body)!=null&&a.trim()?[{label:"Description",text:e.body.trim()}]:[],{label:"Who decides",text:e.hitl?"You (HITL)":"Agents, without you"}];case"supersede_decision":return[{label:`New answer to ${e.decision}`,text:e.answer},{label:"Rationale",text:e.rationale},{label:"Recorded as",text:`Proposed by ${t}, approved by you; the words stay ${t}'s.`}];default:return[]}}function O2(e,t){var s;switch(e.op){case"add_ticket":{const o=(s=e.blockedBy)!=null&&s.length?`after ${e.blockedBy.map(t).join(", ")}`:void 0;return{verb:"Add",text:e.title,detail:[`new ${e.type} ticket`,o].filter(Boolean).join(" · ")}}case"cancel_ticket":return{verb:"Cancel",text:t(e.ticket),detail:e.reason};case"edit_ticket":return{verb:"Revise",text:t(e.ticket),detail:L2(e)};case"rewire":return{verb:"Rewire",text:t(e.ticket),detail:P2(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 L2(e){var s,o;return[((s=e.title)==null?void 0:s.trim())&&"New title",((o=e.body)==null?void 0:o.trim())&&"new description"].filter(Boolean).join(" and ").replace(/^new/,"New")}function P2(e,t){var o,a;return[...(o=e.addBlockedBy)!=null&&o.length?[`now also after ${e.addBlockedBy.map(t).join(", ")}`]:[],...(a=e.removeBlockedBy)!=null&&a.length?[`no longer after ${e.removeBlockedBy.map(t).join(", ")}`]:[]].join(" · ")}const _2=new Set(["cancel_ticket","update_destination"]);function D2(e){const{change:t,name:s}=e,o=O2(t,s),a=R2(t,e.by);return i.jsx(Ce,{as:"li",className:`reroute-change op-${t.op}`,edge:_2.has(t.op)?"attention":"neutral",title:o.text,titleText:o.text,context:i.jsx(V,{parts:[{text:o.verb,strong:!0}]}),detail:o.detail,detailText:o.detail,below:a.length?i.jsx(A2,{parts:a}):void 0})}function z2(e){const{reason:t,destination:s}=e;return i.jsxs("section",{className:"reroute-destination",children:[t&&i.jsx("p",{className:"reroute-destination-why",children:I2[t]}),s&&i.jsxs("div",{className:"reroute-destination-diff",children:[i.jsxs("div",{children:[i.jsx("span",{className:"mono-label",children:"Destination now"}),i.jsx("p",{className:"before",children:s.before||"—"})]}),i.jsxs("div",{children:[i.jsx("span",{className:"mono-label",children:"Suggested destination"}),i.jsx("p",{className:"after",children:s.after})]})]})]})}function B2(e){return i.jsxs("section",{className:"reroute-drift edge-note edge-attention",children:[i.jsx("h3",{className:"mono-label",children:"Changed since it was proposed"}),i.jsx("ul",{className:"item-list",children:e.changed.map(t=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:t.title}),i.jsx(V,{parts:[{text:t.key,code:!0},t.what]})]},t.key))}),i.jsxs("label",{className:"reroute-seen t-body",children:[i.jsx("input",{type:"checkbox",checked:e.seen,onChange:t=>e.onSeen(t.target.checked)})," I’ve seen what changed: apply the proposal to the trail as it is now"]})]})}function F2(e,t){const s=new Map(e.tickets.map(a=>[a.id,a.key])),o=new Map(t.flatMap(a=>a.op==="add_ticket"?[[a.ref,a.title]]:[]));return a=>{const c=s.get(a);if(c)return c;const u=o.get(a);return u?`new: ${u}`:a}}function U2(e){var R,L;const{reroute:t,snap:s}=e,[o,a]=y.useState(""),[c,u]=y.useState(!1);y.useEffect(()=>{const U=Z=>Z.key==="Escape"&&e.onClose();return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[e]);const h=F2(s,t.changes),m=new Map(s.tickets.map(U=>[U.id,`${U.key} ${U.title}`])),p=U=>m.get(U)??h(U),v=s.map.sections.assumptions??[],k=t.invalidates.map(U=>v.find(Z=>Z.id===U)??{id:U,text:""}),x=t.status==="pending",N=x?T2(s,t):[],S=!N.length||c,j=t.kind==="challenge-destination",A=t.lane==="setting",C=A?`${t.by} asks to change your setting`:"Reroute proposal";return i.jsx("div",{className:"scrim",onClick:e.onClose,children:i.jsxs(ze,{as:"div",className:"dialog reroute-dialog",onClick:U=>U.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:j?"Destination challenged":C}),i.jsx(V,{parts:[{text:t.id,code:!0},t.status,`by ${t.by}`,`${hn(Date.now()-t.at)} ago`]})]}),i.jsxs("div",{className:"reroute-body",children:[e.replaced&&i.jsxs("p",{className:"reroute-replaced t-meta edge-note edge-attention",children:[t.by," replaced ",e.replaced," with this proposal while you were reading: review it again."]}),j&&i.jsx(z2,{reason:t.destinationReason,destination:(R=t.diff)==null?void 0:R.destination}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Why"}),i.jsx("p",{children:t.reason})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Evidence"}),i.jsx("p",{className:"reroute-evidence",children:t.evidence})]}),k.length>0&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Assumptions it invalidates"}),i.jsx("ul",{className:"item-list",children:k.map(U=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:U.text}),i.jsx(V,{parts:[{text:U.id,code:!0}]})]},U.id))})]}),i.jsxs("section",{children:[i.jsxs("h3",{className:"mono-label",children:["Changes · ",t.changes.length]}),i.jsx("ul",{className:"reroute-changes row-list",children:t.changes.map((U,Z)=>i.jsx(D2,{change:U,by:t.by,name:p},Z))})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Closed until you decide"}),t.wide&&i.jsxs("p",{className:"t-meta",children:["It touches ",t.wide.touched," of ",t.wide.open," open tickets, so it freezes none: the current plan stands until you decide."]}),(L=t.frozen)!=null&&L.length?i.jsx("ul",{className:"item-list",children:t.frozen.map(U=>i.jsx("li",{className:"item-text",children:p(U)},U))}):i.jsx(Ae,{children:"No tickets closed"})]}),t.note&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Your note"}),i.jsx("p",{children:t.note})]})]}),N.length>0&&i.jsx(B2,{changed:N,seen:c,onSeen:u}),x&&i.jsx(Ze,{label:"Note for the agent (required to reject)",children:i.jsx("textarea",{rows:2,value:o,onChange:U=>a(U.target.value)})}),e.error&&i.jsx("p",{className:"urgent-text",children:e.error}),i.jsxs("div",{className:"actions",children:[x&&i.jsxs(i.Fragment,{children:[i.jsx(P,{className:"reroute-dismiss",variant:"ghost","data-tip":"Reject it without a note of your own",onClick:()=>e.onReject(A?M2:Cv),children:A?"Decline":"Dismiss"}),i.jsx(P,{className:"reroute-reject",disabled:!o.trim(),onClick:()=>e.onReject(o.trim()),children:"Reject"}),i.jsx(P,{className:"reroute-approve",variant:"primary",disabled:!S,onClick:()=>e.onApprove(o.trim()),children:"Approve and apply"})]}),i.jsx(P,{variant:"ghost",onClick:e.onClose,children:"Close"})]})]})})}const $v=`${je()}/reroutes`;async function W2(e){if(!e)return[];const t=await fetch(`${$v}?map=${encodeURIComponent(e)}`);return t.ok?(await t.json()).reroutes:[]}function H2(e){const t=e==null?void 0:e.map.id,[s,o]=y.useState([]),[a,c]=y.useState(),{reload:u}=pt({view:t,version:e==null?void 0:e.tickets.reduce((m,p)=>Math.max(m,p.updatedAt),e.map.updatedAt),load:()=>W2(t),show:o,failed:()=>o([]),events:{reroute:m=>(m==null?void 0:m.mapId)===t}}),h=async(m,p,v)=>{var S,j;const k=await fetch(`${$v}/${m}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,id:p,note:v,hash:(S=s.find(A=>A.id===p))==null?void 0:S.hash})}),x=await k.json().catch(()=>({}));if(k.ok)return c(void 0),u(),!0;const N=(j=x.errors)==null?void 0:j.map(A=>A.message).join("; ");return c([x.error??`HTTP ${k.status}`,N].filter(Boolean).join(": ")),!1};return{reroutes:s,pending:s.find(m=>m.status==="pending"),error:a,clearError:()=>c(void 0),approve:(m,p)=>h("approve",m,p),reject:(m,p)=>h("reject",m,p)}}function K2(e,t){let s=t;for(let o=0;s&&o<e.length;o++){const a=e.find(c=>c.id===s);if((a==null?void 0:a.status)!=="superseded"||!a.supersededBy)break;s=a.supersededBy}return s!==t?{id:s,replaced:t}:{id:t}}function V2(e,t){const s=H2(e),[o,a]=y.useState(),c=K2(s.reroutes,o),u=s.reroutes.find(k=>k.id===c.id),h=u!=null&&u.diff?u:s.pending,m=()=>{a(void 0),s.clearError()},p=k=>k&&m(),v=s.pending;return{banner:v&&i.jsx(C2,{reroute:v,onReview:()=>a(v.id),onDismiss:()=>void s.reject(v.id,Cv)}),preview:e&&(h!=null&&h.diff)?jE(e,h.diff,h.frozen):void 0,openReroute:(k,x)=>{k!==(e==null?void 0:e.map.id)&&(t==null||t(k)),a(x)},dialog:e&&u&&i.jsx(U2,{reroute:u,replaced:c.replaced,snap:e,error:s.error,onApprove:k=>void s.approve(u.id,k||void 0).then(p),onReject:k=>void s.reject(u.id,k).then(p),onClose:m},u.id)}}function G2(e,t){const s=b2(e),o=V2(e,t);return{briefText:s.briefText,inboxCard:s.inboxCard,review:s.review,banner:i.jsxs(i.Fragment,{children:[s.banner,o.banner]}),preview:o.preview,openReroute:o.openReroute,dialog:i.jsxs(i.Fragment,{children:[s.dialog,o.dialog]})}}function q2(){const e=new URL(location.href);e.searchParams.has(Gs)&&(e.searchParams.delete(Gs),history.replaceState(history.state,"",e))}function Q2(e,t){return e.kind!=="question"||t.pending.some(s=>s.id===e.ref)}function Y2(e){const[t,s]=y.useState(()=>new URLSearchParams(location.search).get(Gs)??void 0),{loaded:o,view:a,activity:c,handlers:u,showChat:h}=e;return y.useEffect(()=>{if(!t||!o||!a)return;const m=a.items.find(v=>v.id===t);if(m&&!Q2(m,c)||(s(void 0),q2(),!m))return;Mg(m,{...u,openQuestion:v=>{const k=c.pending.find(x=>x.id===v);k&&h(k.sessionId,k.ticketId)}})},[t,o,a,c,u,h]),{request:y.useCallback(m=>s(m),[])}}function J2(e){const{api:t,nav:s}=e,o=Og(t.allSnaps);ib(o.view);const a=p=>p&&t.actions.selectMap(p),c={openTicket:s.openTicket,openKnowledge:()=>e.knowledge.setOpen(!0),openBrief:p=>p===t.mapId?e.reviewBrief():a(p),openReroute:e.openReroute??(p=>p.ticketId?s.openTicket(p.mapId,p.ticketId):a(p.mapId)),selectTrail:a,openGuides:e.openGuides,openConnector:e.openConnector,openApprovals:e.openApprovals},u=o.view,h=Y2({loaded:t.loaded,view:u,activity:t.activity,handlers:c,showChat:s.showChat}),m=u&&i.jsx(eb,{view:u,onFocus:p=>void o.savePrefs(vj(u.prefs,p,Date.now())),onSettings:e.openFocusSettings});return{attention:o,handlers:c,header:m,link:h}}async function X2(){const e=await fetch(`${je()}/signed-state`);return e.ok?await e.json():null}function Z2(){const[e,t]=y.useState();return pt({load:X2,show:t,failed:()=>t(null),changed:s=>s.endsWith("map.md")||s.includes("/tickets/")||s.includes("/decisions/")}),e}const eA={ticket:"held until you accept or revert it",decision:"what you see is what was signed here, until you accept or revert it"};function tA(e){return e[0]==="added"?"added outside Teamtrail":e.map(t=>t==="words"?"its words":t).join(", ")}function Tv({mapId:e,kind:t,id:s}){const o=Z2(),a=u=>u.mapId===e&&u.kind===t&&u.id===s,c=o==null?void 0:o.changes.find(a);return c?i.jsx(Ce,{className:"d-section",edge:"attention",title:"Changed outside Teamtrail",context:i.jsx(V,{parts:[`${tA(c.fields)} · ${eA[t]}`]}),detail:"By a teammate or an agent editing the file. Settings → Approvals shows what changed."}):o!=null&&o.textEdits.some(a)?i.jsx(V,{className:"d-section",parts:["Text edited outside Teamtrail"]}):null}function nA({d:e}){return e.derived?i.jsx(V,{className:"d-section",parts:["Unverified · read from text anyone who can edit the tracker wrote, not a decision Teamtrail recorded"]}):null}function sA(e){const{d:t,snap:s}=e,[o,a]=y.useState(!1),[c,u]=y.useState(""),[h,m]=y.useState("");y.useEffect(()=>{a(!1),u(""),m("")},[t.id,t.mapId]);const p=qw(e.all.filter(S=>S.mapId===t.mapId),t.id),v=or(t),k=t.ticketId?s==null?void 0:s.tickets.find(S=>S.id===t.ticketId):void 0,x=Date.now(),N=hs(t.source.url);return i.jsxs("div",{className:"detail dv-d",children:[i.jsxs("div",{className:"d-head",children:[i.jsx("span",{className:"key",children:t.id}),i.jsx(Qn,{tone:"state",className:`dv-st-${v}`,children:v}),i.jsx(V,{parts:[mN(t.decidedAt),`${hn(x-t.decidedAt)} ago`]})]}),i.jsx("h3",{className:"t-heading",children:t.question}),i.jsx(Tv,{mapId:t.mapId,kind:"decision",id:t.id}),i.jsx(nA,{d:t}),i.jsxs("div",{className:"resolution",children:[i.jsx(Js,{parts:["Decision"]}),i.jsx("p",{children:t.answer})]}),i.jsxs("dl",{className:"facts",children:[i.jsx("dt",{children:"Trail"}),i.jsx("dd",{children:s?`${s.map.key} ${s.map.title}`:t.mapId}),i.jsx("dt",{children:"Ticket"}),i.jsx("dd",{children:t.ticketId?i.jsxs("button",{className:"link",onClick:()=>e.onOpenTicket(t.mapId,t.ticketId),children:[t.ticketKey," ",(k==null?void 0:k.title)??""," · open in trail ›"]}):"—"}),i.jsx("dt",{children:"Decided by"}),i.jsx("dd",{children:[t.decidedBy,Ep(t)].filter(Boolean).join(", ")}),t.participants.length>1&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Participants"}),i.jsx("dd",{children:t.participants.map(S=>S.name??S.id).join(", ")})]}),i.jsx("dt",{children:"Source"}),i.jsxs("dd",{children:[Gn[t.source.kind].label,N&&i.jsxs(i.Fragment,{children:[" · ",i.jsx("a",{href:N,target:"_blank",rel:"noreferrer",children:t.source.label??"link"})]}),!N&&t.source.label&&` · ${t.source.label}`,t.source.ref&&i.jsxs("span",{className:"ref",children:[" ",t.source.ref]})]})]}),t.alternatives.length>0&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Alternatives"}),i.jsx("ul",{className:"dv-alts",children:t.alternatives.map(S=>i.jsx("li",{children:S},S))})]}),t.rationale&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Rationale"}),i.jsx("p",{children:t.rationale})]}),p.length>1&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Supersession"}),i.jsx("ol",{className:"dv-chain",children:p.map(S=>i.jsx("li",{className:`${S.id===t.id?"cur":""} ${S.supersededBy?"old":"live"}`,children:i.jsxs("button",{onClick:()=>e.onSelect(S.id),children:[i.jsx("i",{}),i.jsx("span",{className:"id",children:S.id}),i.jsx("span",{className:"a",children:S.summary}),i.jsx(V,{parts:[S.decidedBy,Qs(S.decidedAt)]})]})},S.id))})]}),i.jsxs("div",{className:"actions",children:[i.jsx(Tu,{draft:()=>({title:t.summary||t.question,body:[t.answer,t.rationale&&`Why: ${t.rationale}`].filter(Boolean).join(`
167
+
168
+ `),kind:"product-decision",sources:[`decision:${t.id}`,...t.ticketKey?[`ticket:${t.ticketKey}`]:[]]})}),v==="active"&&!t.postedBy&&i.jsx(P,{on:o,onClick:()=>a(S=>!S),"data-tip":"Replace this decision with a new answer. Both stay on record",children:"Supersede…"})]}),o&&i.jsxs(Bt,{as:"form",tone:"inset",className:"inline-form",onSubmit:S=>{S.preventDefault(),c.trim()&&(e.onSupersede(t,{answer:c.trim(),rationale:h.trim(),alternatives:[t.summary]}),a(!1))},children:[i.jsx(Ze,{label:"New decision",children:i.jsx("textarea",{rows:3,value:c,onChange:S=>u(S.target.value),autoFocus:!0})}),i.jsx(Ze,{label:"Rationale",children:i.jsx("input",{value:h,onChange:S=>m(S.target.value)})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(P,{variant:"ghost",onClick:()=>a(!1),children:"Cancel"}),i.jsx(P,{type:"submit",variant:"primary",disabled:!c.trim(),children:"Supersede"})]})]}),i.jsxs("div",{className:"dv-sec",children:[i.jsxs("h4",{className:"mono-label",children:["Transcript ",i.jsx("span",{className:"n",children:t.transcript.length})]}),t.transcript.length?i.jsx("div",{className:"dv-transcript comms-log",children:t.transcript.map((S,j)=>i.jsxs("div",{className:`msg from-${S.from} voice-${S.from==="human"?"human":"agent"}`,children:[i.jsx(Js,{parts:[S.author,vu(S.at)]}),i.jsx("div",{className:"msg-text",children:S.text})]},j))}):i.jsx(Ae,{children:"None recorded"})]})]})}function _t(e){return i.jsx("li",{children:i.jsxs("button",{className:`dv-opt ${e.on?"on":""} ${e.cls??""}`,onClick:e.onClick,children:[i.jsx("span",{className:"ttl",children:e.label}),i.jsx("b",{children:e.n})]})})}function iA(e){const{filter:t,set:s,all:o}=e,a=c=>o.filter(c).length;return e.compact?i.jsxs("div",{className:"dv-filters compact",children:[i.jsx(dt,{compact:!0,"aria-label":"Trail",value:t.mapId??"",onChange:c=>s({mapId:c||void 0}),options:[{value:"",label:"All trails"},...e.trails.map(c=>({value:c.map.id,label:`${c.map.key} ${c.map.title}`}))]}),i.jsx(dt,{compact:!0,"aria-label":"Source",value:t.source??"",onChange:c=>s({source:c||void 0}),options:[{value:"",label:"All sources"},...Po.map(c=>({value:c,label:Gn[c].label}))]}),i.jsx(dt,{compact:!0,"aria-label":"Decided by",value:t.decidedBy??"",onChange:c=>s({decidedBy:c||void 0}),options:[{value:"",label:"Anyone"},...e.people.map(c=>({value:c,label:c}))]}),i.jsx(dt,{compact:!0,"aria-label":"Status",value:t.status??"",onChange:c=>s({status:c||void 0}),options:[{value:"",label:"Any status"},{value:"active",label:"Active"},{value:"superseded",label:"Superseded"}]})]}):i.jsxs("aside",{className:"dv-filters",children:[i.jsx("h3",{className:"mono-label",children:"Trail"}),i.jsxs("ul",{children:[i.jsx(_t,{on:!t.mapId,label:"All trails",n:o.length,onClick:()=>s({mapId:void 0})}),e.trails.map(c=>i.jsx(_t,{on:t.mapId===c.map.id,label:`${c.map.key} ${c.map.title}`,n:a(u=>u.mapId===c.map.id),onClick:()=>s({mapId:c.map.id})},c.map.id))]}),i.jsx("h3",{className:"mono-label",children:"Source"}),i.jsxs("ul",{children:[i.jsx(_t,{on:!t.source,label:"All",n:o.length,onClick:()=>s({source:void 0})}),Po.map(c=>i.jsx(_t,{cls:`src-${c}`,on:t.source===c,label:Gn[c].label,n:a(u=>u.source.kind===c),onClick:()=>s({source:t.source===c?void 0:c})},c))]}),i.jsx("h3",{className:"mono-label",children:"Made by"}),i.jsxs("ul",{children:[i.jsx(_t,{on:!t.madeBy,label:"Anyone",n:o.length,onClick:()=>s({madeBy:void 0})}),i.jsx(_t,{on:t.madeBy==="agent",label:"Agents, on their own",n:a(c=>er(c)==="agent"),onClick:()=>s({madeBy:t.madeBy==="agent"?void 0:"agent"})}),i.jsx(_t,{on:t.madeBy==="human",label:"People",n:a(c=>er(c)==="human"),onClick:()=>s({madeBy:t.madeBy==="human"?void 0:"human"})})]}),i.jsx("h3",{className:"mono-label",children:"Decided by"}),i.jsxs("ul",{children:[i.jsx(_t,{on:!t.decidedBy,label:"Anyone",n:o.length,onClick:()=>s({decidedBy:void 0})}),e.people.map(c=>i.jsx(_t,{on:t.decidedBy===c,label:c,n:a(u=>u.decidedBy===c),onClick:()=>s({decidedBy:t.decidedBy===c?void 0:c})},c))]}),i.jsx("h3",{className:"mono-label",children:"Status"}),i.jsxs("ul",{children:[i.jsx(_t,{on:!t.status,label:"Any",n:o.length,onClick:()=>s({status:void 0})}),i.jsx(_t,{on:t.status==="active",label:"Active",n:a(c=>!c.supersededBy),onClick:()=>s({status:t.status==="active"?void 0:"active"})}),i.jsx(_t,{on:t.status==="superseded",label:"Superseded",n:a(c=>!!c.supersededBy),onClick:()=>s({status:t.status==="superseded"?void 0:"superseded"})})]})]})}function rA(e){if(or(e)==="superseded")return`Replaced by ${e.supersededBy}`;if(e.supersedes)return`Replaces ${e.supersedes}`}function oA(e){const{d:t}=e,s=or(t);return i.jsxs(i.Fragment,{children:[e.newDay&&i.jsx("li",{className:"dv-day t-label",children:Qs(t.decidedAt)}),i.jsx(Ce,{as:"li",className:`dv-row ${s}`,selected:e.on,onOpen:e.onClick,title:t.question,titleText:t.question,trailing:vu(t.decidedAt),context:i.jsx(V,{parts:[{text:t.id,code:!0},t.ticketKey&&{text:t.ticketKey,code:!0},e.showTrail&&e.trail,t.decidedBy,Ep(t)??Gn[t.source.kind].label,rA(t)]}),detail:t.summary,detailText:t.summary})]})}function aA(e){const{rows:t,current:s}=e;return i.jsx("ol",{className:"dv-list","aria-label":"Logbook",children:t.length?t.map((o,a)=>{var c;return i.jsx(oA,{d:o,newDay:a===0||Qs(t[a-1].decidedAt)!==Qs(o.decidedAt),trail:(c=e.snaps[o.mapId])==null?void 0:c.map.key,on:(s==null?void 0:s.id)===o.id&&s.mapId===o.mapId,showTrail:e.showTrail,onClick:()=>e.onSelect(o.id)},`${o.mapId}:${o.id}`)}):i.jsx(Ae,{children:"No decisions"})})}function lA({stats:e}){return i.jsxs("span",{className:"dv-readouts",children:[i.jsx(ln,{layout:"start",label:"Active",value:e.active}),i.jsx(ln,{layout:"start",label:"Superseded",value:e.superseded}),i.jsx(ln,{layout:"start",label:"Last 24h",value:e.last24h}),i.jsx(ln,{layout:"start",label:"Human",value:`${e.total?Math.round(e.human/e.total*100):0}%`}),i.jsx(V,{className:"dv-src-mix",parts:Po.filter(t=>e.bySource[t]).map(t=>`${Gn[t].label} ${e.bySource[t]}`)})]})}function cA(e){const{filter:t}=e,o=Object.values(t).filter(Boolean).length-(t.query?1:0),a=e.filtersOpen||o>0;return i.jsxs("div",{className:"dv-search",children:[i.jsx("input",{type:"search",placeholder:"Search decisions",value:t.query??"",onChange:c=>e.set({query:c.target.value})}),e.showToggle&&i.jsxs("button",{className:`chip ${a?"on":""}`,onClick:e.onToggle,children:["Filters",o>0?` · ${o}`:""]})]})}function uA(e){const{api:t,bp:s}=e,o=t.decisions,[a,c]=y.useState({}),[u,h]=y.useState(e.focus),[m,p]=y.useState(!1);y.useEffect(()=>h(e.focus),[e.focus]),y.useEffect(()=>{const R=L=>{L.key==="Escape"&&(s==="mobile"&&u?h(void 0):e.onClose())};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[s,u,e]);const v=y.useMemo(()=>yx(o,a),[o,a]),k=y.useMemo(()=>wx(o),[o]),x=o.find(R=>R.id===u&&(!a.mapId||R.mapId===a.mapId))??(s==="mobile"?void 0:v[0]),N=y.useMemo(()=>Object.values(t.allSnaps).sort((R,L)=>L.map.createdAt-R.map.createdAt),[t.allSnaps]),S=y.useMemo(()=>[...new Set(o.map(R=>R.decidedBy))].sort(),[o]),j=R=>c(L=>({...L,...R})),A=()=>{const R=Object.fromEntries(N.map(L=>[L.map.id,{key:L.map.key,title:L.map.title}]));cg(`${J.slug}-decisions-${Qs(Date.now())}.md`,Mx(v,R,{title:`${J.name} decisions`}))},C=s==="mobile"&&!!x;return i.jsxs(ze,{className:`zone decisions-view dv-${s}`,children:[i.jsxs("header",{className:"dv-head",children:[C?i.jsx("button",{className:"back",onClick:()=>h(void 0),children:"‹ Decisions"}):i.jsxs(Ve,{as:"h2",children:["Decisions ",v.length!==o.length&&i.jsx("span",{className:"n",children:`${v.length}/${o.length}`})]}),s!=="mobile"&&i.jsx(lA,{stats:k}),i.jsxs("span",{className:"dv-head-right",children:[!C&&i.jsx(P,{onClick:A,disabled:!v.length,title:"Export the filtered list as markdown",children:"Export .md"}),i.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})]})]}),!C&&i.jsx(cA,{filter:a,set:j,showToggle:s!=="wide",filtersOpen:m,onToggle:()=>p(R=>!R)}),i.jsxs("div",{className:"dv-body",children:[(s==="wide"||m&&!C)&&i.jsx(iA,{filter:a,set:j,all:o,trails:N,people:S,compact:s!=="wide"}),!C&&i.jsx(aA,{rows:v,current:x,snaps:t.allSnaps,showTrail:s==="wide",onSelect:h}),(s!=="mobile"||x)&&i.jsx("div",{className:"dv-detail",children:x?i.jsx(sA,{d:x,all:o,snap:t.allSnaps[x.mapId],onSelect:h,onOpenTicket:e.onOpenTicket,onSupersede:t.actions.supersede}):i.jsx(Ae,{children:"No decision selected"})})]})]})}function dA({api:e,bp:t,nav:s}){return s.statsOpen?i.jsx(gT,{api:e,bp:t,onClose:()=>s.setStatsOpen(!1)}):s.decisionsView?i.jsx(uA,{api:e,bp:t,focus:s.decisionsView.focus,onClose:()=>s.setDecisionsView(null),onOpenTicket:s.openTicket}):null}function hA(e,t,s){const o=fv(),[a,c]=y.useState(()=>new URLSearchParams(location.search).has("projects")),u=a&&o.many&&i.jsx(eT,{projects:o,bp:e,onClose:()=>c(!1),onItemHere:s});return{projects:o,overview:u,openOverview:()=>{t.setDecisionsView(null),t.setStatsOpen(!1),c(!0)}}}function Ev({activity:e,onTicket:t}){const s=e.feed.slice(-120).reverse();return s.length?i.jsx("div",{className:"log",children:s.map(o=>i.jsxs("div",{className:`log-row lv-${o.level} src-${o.source} ${o.signal?"signal":""}`,onClick:()=>o.ticketId&&t(o.ticketId),children:[i.jsx("span",{className:"t t-meta",children:ua(o.at)}),i.jsx("span",{className:"src t-meta",children:o.agent??o.source}),i.jsxs("span",{className:"msg",title:o.tag?`${o.tag} · ${o.text}`:o.text,children:[o.tag&&i.jsxs("span",{className:"tag t-meta",children:[o.tag," · "]}),o.text]})]},o.id))}):i.jsx(qn,{title:"Nothing has happened yet",hint:"Claims, steps, questions and decisions appear here as agents work."})}function hp({lease:e,now:t}){if(!e)return null;const s=oa(e,t);if(s==="live")return null;const o=e.expiresAt-t;return i.jsxs(Qn,{tone:"amber",className:"stalled",title:`No activity from ${e.agent}; the ticket returns to the queue when the lease runs out`,children:["stalled · ",s==="expired"?"returning":Yt(o)]})}function fA({total:e,step:t}){return i.jsx("span",{className:"segs","aria-label":`Step ${t} of ${e}`,children:Array.from({length:e},(s,o)=>i.jsx("i",{className:mA(o+1,t)},o))})}function mA(e,t){return e<t?"done":e===t?"cur":""}function Av({snap:e,activity:t,leases:s,onSelect:o,onOpenChat:a}){var x;const c=Xt(1e3),u=t.sessions.filter(dn),h=new Set(u.map(N=>N.ticketId)),m=ku(s,e==null?void 0:e.map.id),p=(e==null?void 0:e.tickets.filter(N=>N.state==="open"&&N.assignee&&!h.has(N.id)))??[];if(!u.length&&!p.length)return i.jsx(Ae,{children:"No agent on a ticket"});const v=N=>!!N&&oa(N,c)!=="live",k=!!((x=e==null?void 0:e.map.modelMatching)!=null&&x.enabled);return i.jsxs("ul",{className:"sessions-list",children:[u.map(N=>{const S=e==null?void 0:e.tickets.find(C=>C.id===N.ticketId),j=S?rr(S)==="hitl":!1,A=S&&m.get(S.id);return i.jsx(Ce,{as:"li",className:N.waitingOn?"waiting":void 0,edge:pA(N,v(A)),title:kA(S,N.mode)||N.agent,context:i.jsx(V,{parts:[{text:N.agent,strong:!0},k&&gA(N),N.waitingOn?{text:"Waiting on you",urgent:!0}:`${N.mode} · ${N.stepLabel.toLowerCase()}`,j&&!N.waitingOn&&"with you",vA(N)],children:i.jsx(hp,{lease:A,now:c})}),trailing:ug(c-N.startedAt),below:i.jsx(fA,{total:N.total,step:N.step}),onOpen:()=>{S&&o({kind:"ticket",id:S.id}),j&&a(N.id)}},N.id)}),p.map(N=>i.jsx(Ce,{as:"li",className:"claim",edge:v(m.get(N.id))?"attention":"neutral",title:`${N.key} ${N.title}`,context:i.jsx(V,{parts:[{text:N.assignee??"",strong:!0},"claimed, no live session"],children:i.jsx(hp,{lease:m.get(N.id),now:c})}),onOpen:()=>o({kind:"ticket",id:N.id})},N.id))]})}function pA(e,t){return e.waitingOn?"urgent":t?"attention":"neutral"}function gA(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 vA(e){if(e.usage)return`${da(gx(e))} tok · ${qs(e.usage.costUsd)}`}function kA(e,t){return e?`${e.key} ${e.title}`:t==="chart"?"Charting trail":""}function Iv({activity:e,snap:t,running:s,usage:o=!0}){const a=Op(e,t==null?void 0:t.map.id),c=Pp(e,t==null?void 0:t.map.id),u=new Set(e.sessions.filter(dn).map(m=>m.ticketId)),h=(t==null?void 0:t.tickets.filter(m=>m.state==="open"&&m.assignee&&!u.has(m.id)).length)??0;return i.jsx(Et,{sub:!0,className:"sessions-head",title:i.jsxs(i.Fragment,{children:["Agents on tickets ",i.jsx("span",{className:"n",children:s+h})]}),right:o?i.jsxs("span",{className:"usage",title:["Model usage for this trail, all sessions",...c.map(m=>Lp[m].text)].join(`
169
+ `),children:[i.jsx("span",{className:"mono-label",children:"Trail"})," ",da(a.inputTokens+a.outputTokens)," tok · ",qs(a.costUsd)]}):void 0})}function yA(e){const t=[...e.feed].reverse().find(s=>s.level==="step"&&s.sessionId);return t?e.sessions.find(s=>s.id===t.sessionId):void 0}const wA={running:"Working",done:"Done",failed:"Stopped"};function Mv({activity:e,snap:t}){const s=yA(e);if(!s)return i.jsx(qn,{title:"No agent working yet",hint:"Run /scout resume in Claude Code or Codex. Each step an agent reports shows here."});const o=s.ticketId?t==null?void 0:t.tickets.find(u=>u.id===s.ticketId):void 0,a=na[s.mode],c=s.waitingOn?"Waiting on you":wA[s.status];return i.jsxs("div",{className:`step-tracker ${s.waitingOn?"waiting":""}`,children:[i.jsxs("div",{className:"st-meta",children:[i.jsx(V,{parts:[{text:s.agent,strong:!0},`${s.mode}, step ${s.step} of ${s.total}`]}),i.jsx("span",{className:`t-label st-status ${s.waitingOn?"urgent":""}`,children:c})]}),i.jsxs("div",{className:"st-big",children:[s.stepLabel,o&&i.jsxs("span",{className:"st-key",children:[" ",o.key]})]}),o&&i.jsx("div",{className:"st-ticket t-meta",children:o.title}),i.jsx("ol",{className:"pipeline",children:a.map((u,h)=>{const m=h+1,p=m<s.step||m===s.step&&s.status==="done";let v="";return p?v="done":m===s.step&&(v="cur"),i.jsxs("li",{className:v,children:[i.jsx("i",{}),i.jsxs("span",{children:[String(m).padStart(2,"0")," ",u]})]},u)})})]})}function fp(e){return i.jsxs("div",{className:"zone-b activity-stack",children:[i.jsx(Mv,{activity:e.activity,snap:e.snap}),i.jsx(Iv,{activity:e.activity,snap:e.snap,running:e.activity.sessions.filter(dn).length}),i.jsx(Av,{snap:e.snap,activity:e.activity,leases:e.leases,onSelect:t=>(t==null?void 0:t.kind)==="ticket"&&e.onTicket(t.id),onOpenChat:e.onOpenChat}),i.jsx(Et,{sub:!0,title:"Activity log"}),i.jsx(Ev,{activity:e.activity,onTicket:e.onTicket})]})}function xA(e){return i.jsx(Ng,{area:"log",className:"log-zone",icon:"book",title:"Activity log",info:"Everything that happened in this trail, newest first: claims, steps, questions, decisions and errors.",right:i.jsxs("span",{className:"mono-label dim",children:[e.activity.feed.length," events"]}),children:i.jsx(Ev,{activity:e.activity,onTicket:e.onTicket})})}function jA(e){var o;const t=e.activity.sessions.filter(dn).length,s=!e.activity.sessions.length&&!((o=e.snap)!=null&&o.tickets.some(a=>a.state==="open"&&a.assignee));return i.jsxs(ze,{className:"zone step-zone",style:{gridArea:"step"},children:[i.jsx(Et,{className:"zone-title",icon:"tent",title:"Current trail step",info:"What your agents are doing right now. The top shows the latest step an agent reported; below is every agent holding a ticket."}),i.jsxs("div",{className:"zone-b",children:[i.jsx(Mv,{activity:e.activity,snap:e.snap}),!s&&i.jsxs(i.Fragment,{children:[i.jsx(Iv,{activity:e.activity,snap:e.snap,running:t,usage:!1}),i.jsx(Av,{snap:e.snap,activity:e.activity,leases:e.leases,onSelect:a=>(a==null?void 0:a.kind)==="ticket"&&e.onTicket(a.id),onOpenChat:e.onOpenChat})]})]})]})}function NA(e){const t=ka(e.ticketId,e.hash),[s,o]=y.useState(),a=e.confirmed?"Unconfirm":"Confirm criteria",c=e.confirmed?"Take your confirmation back":"Agree that these criteria define done for this ticket",u=t.changed&&!e.confirmed;return i.jsxs(i.Fragment,{children:[t.changed&&i.jsx(pa,{what:"These criteria",onReviewAgain:t.reviewAgain}),i.jsx(P,{size:"sm",variant:e.confirmed?"ghost":"default",disabled:u,"data-tip":c,onClick:()=>void e.confirm(!e.confirmed,t.hash).then(o),children:a}),s&&i.jsx("p",{className:"vf-err",children:s})]})}function SA(e){const{proposal:t}=e;return i.jsxs("div",{className:"crit-proposal edge-note edge-attention",children:[i.jsxs("p",{className:"t-meta",children:[t.by," proposes new criteria. Yours stay in force until you take these."]}),i.jsx("ul",{className:"item-list",children:t.criteria.map(s=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:s.text}),i.jsx(V,{parts:[{text:s.id,code:!0},s.kind.replace("-"," "),s.source&&`from ${s.source}`]})]},s.id))}),i.jsxs("div",{className:"actions",children:[i.jsx(P,{size:"sm",variant:"ghost",onClick:e.onDismiss,children:"Keep mine"}),i.jsx(P,{size:"sm",disabled:!e.canAccept,onClick:e.onAccept,children:"Take these"})]})]})}function bA(e){const{proposal:t}=e,s=ka(`${t.ticketId}@${t.at}`,t.hash),[o,a]=y.useState(),c=u=>void e.decide(u,s.hash).then(a);return i.jsxs(i.Fragment,{children:[s.changed&&i.jsx(pa,{what:"The proposal",onReviewAgain:s.reviewAgain}),i.jsx(SA,{proposal:t,canAccept:!s.changed,onAccept:()=>c("accept"),onDismiss:()=>c("dismiss")}),o&&i.jsx("p",{className:"vf-err",children:o})]})}async function Rv(e){return e?e.ok?void 0:(await e.json().catch(()=>({}))).error??`HTTP ${e.status}`:"Could not reach the Lookout"}const Ov=`${je()}/criteria`;async function CA(e){if(!e)return[];const t=await fetch(`${Ov}?mapId=${encodeURIComponent(e)}`);return t.ok?(await t.json()).tickets:[]}function $A(e){const[t,s]=y.useState([]),{reload:o}=pt({view:e,load:()=>CA(e),show:s,failed:()=>s([]),changed:c=>c.startsWith("criteria/")});return{tickets:t,confirm:c=>fetch(`${Ov}/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,...c})}).catch(()=>{}).then(async u=>{const h=await Rv(u);return o(),h})}}const Lv=`${je()}/criteria-proposals`;async function TA(e){if(!e)return[];const t=await fetch(`${Lv}?mapId=${encodeURIComponent(e)}`);return t.ok?(await t.json()).proposals:[]}function EA(e){const[t,s]=y.useState([]),{reload:o}=pt({view:e,load:()=>TA(e),show:s,failed:()=>s([]),events:{"criteria-proposals":c=>(c==null?void 0:c.mapId)===e}});return{proposals:t,decide:(c,u)=>fetch(`${Lv}/${c}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,...u})}).catch(()=>{}).then(async h=>{const m=await Rv(h);return o(),m})}}function AA({snap:e,t}){const{tickets:s,confirm:o}=$A(e.map.id),a=EA(e.map.id),c=a.proposals.find(k=>k.ticketId===t.id),u=ri(),h=s.find(k=>k.ticketId===t.id),m=(h==null?void 0:h.criteria)??[],v=qp(u.entries,{trailKey:e.map.key,ticket:{type:t.type,title:t.title,body:t.body},paths:Qp(`${t.body}
170
+ ${u.briefText}`)}).filter(k=>k.kind==="business-rule").filter(k=>Xx(m,[k.id]).length);return!m.length&&!v.length&&!c?null:i.jsxs("div",{className:"criteria-section d-section",children:[i.jsxs("span",{className:"t-label","data-tip":"Agreed before the work starts; each needs evidence before the ticket counts as done",children:["Acceptance criteria · ",m.length,(h==null?void 0:h.confirmed)&&i.jsx("span",{className:"ok-text",children:" · confirmed by you"})]}),m.length>0&&i.jsx("ul",{className:"criteria-list item-list",children:m.map(k=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:k.text}),i.jsx(V,{parts:[{text:k.id,code:!0},k.kind.replace("-"," "),k.source&&`from ${k.source}`]})]},k.id))}),c&&i.jsx(bA,{proposal:c,decide:(k,x)=>a.decide(k,{title:e.map.title,ticketId:t.id,hash:x})}),v.length>0&&i.jsxs("div",{className:"crit-uncovered edge-note edge-attention",children:[i.jsx("p",{className:"t-meta",children:"No criterion covers these rules yet:"}),i.jsx("ul",{className:"item-list",children:v.map(k=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:k.title}),i.jsx(V,{parts:[{text:k.id,code:!0},"business rule"]})]},k.id))})]}),m.length>0&&t.state==="open"&&i.jsx(NA,{ticketId:t.id,hash:h==null?void 0:h.hash,confirmed:!!(h!=null&&h.confirmed),confirm:(k,x)=>o({title:e.map.title,ticketId:t.id,ticketKey:t.key,confirmed:k,hash:x})})]})}const Yo="";function IA(e){const t=uu.map(o=>({value:o,label:sr[o],hint:Lg[o]})),s=[...MA(e),...t];return i.jsx(dt,{compact:!0,className:"vf-level","aria-label":"Verification level",value:e.value??Yo,options:s,onChange:o=>e.onChange(o===Yo?null:o)})}function MA(e){return e.inherit!==void 0?[{value:Yo,label:e.inherit,hint:"Use the trail’s level for this ticket."}]:e.value===void 0?[{value:Yo,label:"Off (not set)"}]:[]}function RA({check:e}){const t=lb(e),[s,o]=y.useState(),[a,c]=y.useState(),u=OA(e);return i.jsxs("details",{className:`vf-row ${t?"ok":"bad"}`,open:!t,children:[i.jsxs("summary",{children:[i.jsx("span",{className:"vf-mark",children:t?"✓":"✕"}),i.jsx("span",{className:"t-code vf-name",children:e.name}),i.jsx("span",{className:"t-meta",children:u}),i.jsx("span",{className:"t-meta vf-dur",children:Yt(e.durationMs)})]}),i.jsx("code",{className:"vf-argv",children:e.argv.join(" ")}),e.error&&i.jsx("p",{className:"vf-note",children:e.error}),i.jsx("pre",{className:"vf-tail",children:s??(e.tail||"No output.")}),i.jsxs("div",{className:"vf-log-line",children:[s===void 0&&i.jsx("button",{className:"link",onClick:()=>lr.log(e.log).then(h=>o(h.clipped?`[earlier output not shown]
171
+ ${h.text}`:h.text),h=>c(h.message)),children:"Full log ›"}),e.truncated&&i.jsx("span",{className:"dim",children:"log capped at 1 MB"}),a&&i.jsx("span",{className:"vf-err",children:a})]})]})}function OA(e){return e.error?"did not start":e.timedOut?"timed out":`exit ${e.exitCode??e.signal??"?"}`}const mp=e=>(e==null?void 0:e.slice(0,8))??"none",pp=e=>e===null?"·":String(e);function LA({attempt:e}){const t=e.git;if(!t)return null;const{files:s,add:o,del:a}=t.stats;return i.jsxs("div",{className:"vf-git",children:[i.jsx(V,{parts:[t.tree?{text:`${t.base?`${mp(t.base.head)} → `:""}${mp(t.tree.head)}`,code:!0}:"not a git repo",t.tree&&{text:t.tree.branch??"detached HEAD",code:!!t.tree.branch},t.tree&&`${s} file${s===1?"":"s"} +${o} −${a}`]}),t.flags.filter(c=>c.kind!=="no-git").map(c=>{var u;return i.jsxs("p",{className:`vf-flag lv-${c.level}`,title:(u=c.files)==null?void 0:u.join(`
172
+ `),children:[i.jsx("span",{className:"t-code",children:c.kind})," ",c.message]},c.kind)}),t.changed.length>0&&i.jsxs("details",{className:"vf-files",children:[i.jsx("summary",{className:"t-label",children:"Changed files"}),i.jsx("ul",{children:t.changed.map(c=>i.jsxs("li",{children:[i.jsx("code",{children:c.path}),i.jsxs("span",{className:"dim",children:[c.untracked?"new":`+${pp(c.add)} −${pp(c.del)}`,c.dirtyAtClaim?" · dirty at claim":""]})]},c.path))})]})]})}function PA({attempt:e,latest:t}){return i.jsxs("details",{className:`vf-attempt r-${e.result}`,open:t,children:[i.jsxs("summary",{children:[i.jsx(Qn,{tone:"state",className:`r-${e.result}`,children:ab[e.result]}),i.jsx(V,{parts:[{text:e.id,code:!0},e.agent,ar(e.submittedAt),Yt(e.finishedAt-e.submittedAt)]})]}),i.jsx("p",{className:"vf-claim",children:e.summary??e.resolution}),e.note&&i.jsx("p",{className:"vf-note",children:e.note}),e.criteria&&i.jsx("ul",{className:"vf-criteria",children:e.criteria.lines.map(s=>i.jsx("li",{className:_A(s),children:s},s))}),i.jsx(LA,{attempt:e}),e.checks.map(s=>i.jsx(RA,{check:s},s.name))]})}function _A(e){return e.includes(" ✓ ")?"ok":e.includes(" ✗ ")?"bad":e.includes(" ? ")?"claimed":"wait"}const DA={PASS:"Passed",FAIL:"Sent back",NEEDS_HUMAN:"Needs you"};function zA({verdict:e}){const{guide:t,checklist:s}=e;return i.jsxs("div",{className:`vf-verdict v-${e.verdict.toLowerCase()}`,children:[i.jsx(V,{parts:[{text:e.byKind==="trail lead"&&e.verdict==="PASS"?"Approved":DA[e.verdict],strong:!0},{text:e.id,code:!0},e.byKind==="trail lead"?e.by:`review ${e.by}`,e.sessionId&&`session ${e.sessionId.slice(0,8)}`,t&&`as ${t.id} ${t.version}`,`on ${e.attemptId}`,ar(e.at)]}),i.jsx("p",{children:e.summary}),e.findings.length>0&&i.jsx("ul",{className:"vf-findings",children:e.findings.map((o,a)=>i.jsxs("li",{className:`sev-${o.severity}`,children:[o.path&&i.jsx("code",{children:o.line?`${o.path}:${o.line}`:o.path})," ",o.text]},a))}),s&&s.length>0&&i.jsx(qg,{answers:s})]})}function BA(e,t,s){const[o,a]=y.useState(),c=`${e}/${t}`;y.useEffect(()=>a(void 0),[c]);const{reload:u}=pt({view:c,version:s,load:()=>lr.ticket(e,t),show:a});return y.useEffect(()=>Ys.onEvidence(u),[u]),{data:o,reload:u}}const _c={rework:{label:"What to fix",submit:"Send to rework",hint:"Posted on the ticket for the next agent."},accept:{label:"Why accept",submit:"Accept anyway",hint:"Closes the ticket as done despite the checks."},unblock:{label:"Why",submit:"Unblock",hint:"Back to the queue without running checks."}};function FA(e){const[t,s]=y.useState(),[o,a]=y.useState(""),[c,u]=y.useState("rework"),{state:h,submitted:m,running:p,act:v}=e;if(p||h!=="verifying"&&h!=="held")return null;const k=N=>{s(t===N?void 0:N),a("")},x=N=>{N.preventDefault(),!(!t||!o.trim())&&(v({action:t,reason:o.trim(),...t==="unblock"?{to:c}:{}}),s(void 0))};return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"actions vf-actions",children:[h==="verifying"&&m&&i.jsx(P,{variant:"primary",onClick:()=>void v({action:"approve"}),"data-tip":"Checks passed: approve and close the ticket",children:"Approve"}),m&&i.jsx(P,{onClick:()=>void v({action:"rerun"}),"data-tip":"Run the repo's checks again on the current code",children:"Re-run checks"}),i.jsx(P,{on:t==="rework",onClick:()=>k("rework"),"data-tip":"Send it back to an agent with what to fix",children:"Rework…"}),h==="held"&&i.jsxs(i.Fragment,{children:[i.jsx(P,{on:t==="accept",onClick:()=>k("accept"),"data-tip":"Close it as done despite the failing checks",children:"Accept anyway…"}),i.jsx(P,{on:t==="unblock",onClick:()=>k("unblock"),"data-tip":"Put it back in the queue without running checks",children:"Unblock…"})]})]}),t&&i.jsxs(Bt,{as:"form",tone:"inset",className:"inline-form",onSubmit:x,children:[i.jsx(Ze,{label:_c[t].label,children:i.jsx("textarea",{rows:2,value:o,onChange:N=>a(N.target.value),autoFocus:!0})}),t==="unblock"&&i.jsx(Ze,{label:"Back to",children:i.jsx(dt,{"aria-label":"Back to",value:c,onChange:u,options:[{value:"rework",label:"Rework",hint:"Keeps the feedback for the next agent."},{value:"ready",label:"Ready",hint:"Back in the queue as a fresh ticket."}]})}),i.jsx("span",{className:"dim vf-hint",children:_c[t].hint}),i.jsxs("div",{className:"form-actions",children:[i.jsx(P,{variant:"ghost",onClick:()=>s(void 0),children:"Cancel"}),i.jsx(P,{type:"submit",variant:t==="accept"?"danger":"primary",disabled:!o.trim(),children:_c[t].submit})]})]})]})}const UA={ticket:"set on this ticket",trail:"from the trail",none:"not set"},WA=new Set(["verifying","rework","held"]);function HA(e){const{mapId:t,ticket:s,state:o}=e,{data:a,reload:c}=BA(t,s.id,s.updatedAt),[u,h]=y.useState();if(!a||a.level.level==="off"&&!a.attempts.length&&!WA.has(o))return null;const m=v=>(h(void 0),lr.act({...v,mapId:t,ticketId:s.id,by:Nt}).then(c,k=>h(k.message))),p=a.running;return i.jsxs("section",{className:"vf-panel",children:[i.jsxs("div",{className:"vf-head",children:[i.jsx(Ve,{as:"h4",children:"Verification"}),i.jsx(V,{parts:[sr[a.level.level],UA[a.level.source]]}),s.state==="open"&&i.jsx(IA,{value:s.verification,inherit:`Trail (${sr[e.trail??"off"]})`,onChange:v=>void m({action:"level",level:v})})]}),p&&i.jsxs("div",{className:"sync-line vf-running",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:["Checking ",p.id," for ",p.agent," · since ",ar(p.startedAt)]})]}),i.jsx(FA,{state:o,submitted:a.attempts.length>0,running:!!p,act:m}),u&&i.jsx("p",{className:"vf-err",children:u}),a.verdicts.map(v=>i.jsx(zA,{verdict:v},v.id)),a.attempts.map((v,k)=>i.jsx(PA,{attempt:v,latest:k===0},v.id)),!a.attempts.length&&!p&&i.jsx(V,{parts:[`Checks: ${a.level.checks.join(", ")||"none"}`,"run when the ticket is submitted"]})]})}function KA({lease:e,onRelease:t}){const s=Xt(1e3),o=oa(e,s),a=o==="live";return i.jsxs("div",{className:`lease lease-${o} edge-note ${a?"":"edge-attention"}`,children:[i.jsxs("div",{className:"edge-note-head",children:[i.jsx(V,{parts:[{text:`Claimed by ${e.agent}`,strong:!0},`active ${hn(s-e.renewedAt)} ago`]}),!a&&i.jsx(Qn,{tone:"amber",children:"Stalled"})]}),i.jsx("p",{className:"t-meta lease-line",children:VA(o,GA(e.expiresAt-s))}),e.workspace&&i.jsxs("p",{className:"t-meta lease-branch",children:["Works on ",i.jsx("code",{className:"t-code",children:e.workspace.branch})," in its own worktree"]}),e.touches&&e.touches.length>0&&i.jsxs("p",{className:"t-meta lease-touches",children:["Expects to change"," ",e.touches.map((c,u)=>i.jsxs("span",{children:[u>0&&", ",i.jsx("code",{className:"t-code",children:c})]},c))]}),e.notes.length>0&&i.jsx("ul",{className:"lease-notes t-meta",children:e.notes.slice(-3).map((c,u)=>i.jsx("li",{children:c},u))}),i.jsx("div",{className:"actions",children:i.jsx(P,{variant:a?"default":"urgent",onClick:t,children:"Release to queue"})})]})}function VA(e,t){return e==="expired"?"Lease expired, going back to the queue":e==="stalled"?`The agent went quiet. Back in the queue in ${t}.`:`Back in the queue after ${t} without activity.`}function GA(e){const t=e/864e5;return t>=2?`${Math.round(t)} days`:Yt(Math.max(0,e))}function qA({comments:e}){if(!e.length)return null;const t=e.length>1?"s":"";return i.jsxs("details",{className:"comments",children:[i.jsxs("summary",{className:"t-label",children:[e.length," other comment",t]}),e.map(s=>i.jsxs("div",{className:"comment",children:[i.jsx(V,{parts:[{text:s.author,strong:!0}]}),i.jsx("div",{className:"c-body",children:s.body.replace(/\*\*/g,"")})]},s.id))]})}function QA({resolution:e,decisions:t,onOpenDecision:s}){const o=t.find(u=>!u.supersededBy)??t[0],a=e.body.startsWith("**Ruled")?"ruled out":"resolution",c=t.length>1?` · ${t.length} in chain`:"";return i.jsxs("div",{className:"resolution edge-note edge-done",children:[i.jsxs("div",{className:"edge-note-head",children:[i.jsx(V,{parts:[{text:e.author,strong:!0},a]}),o&&s&&i.jsxs("button",{className:"link t-meta",onClick:()=>s(o.id),children:[o.id,c," ›"]})]}),i.jsx("p",{children:e.body.replace(/^\*\*[^*]+\*\*\s*/,"")})]})}function YA(e){const{t,state:s,session:o,mine:a,form:c,setForm:u,actions:h,onOpenChat:m}=e;return i.jsxs("div",{className:"actions",children:[o&&i.jsx(P,{variant:o.waitingOn?"urgent":"default",onClick:()=>m(o.id),"data-tip":o.waitingOn?"The agent is waiting for your answer":"Open the conversation with this agent",children:o.waitingOn?"Answer":"Conversation"}),s==="frontier"&&i.jsx(P,{onClick:()=>h.claim(t.id),"data-tip":"Take this ticket yourself, so no agent picks it up",children:"Claim"}),(s==="frontier"||s==="claimed"&&a)&&i.jsx(P,{on:c==="resolve",onClick:()=>u(c==="resolve"?null:"resolve"),"data-tip":"Answer it yourself and close the ticket, with a decision record",children:"Resolve…"}),a&&s==="claimed"&&i.jsx(P,{onClick:()=>h.release(t.id),"data-tip":"Give the ticket back to the queue",children:"Release"}),(s==="frontier"||s==="blocked"||s==="parked")&&i.jsx(P,{variant:"danger",on:c==="rule",onClick:()=>u(c==="rule"?null:"rule"),"data-tip":"Move it out of scope. It's set aside with your reason, not deleted",children:"Rule out…"})]})}function JA(e){return e.replace(/\s*Part of trail \S+\.\s*$/,"").trim()}function XA({t:e,state:t,tickets:s}){const o=new Map(s.map(p=>[p.id,p])),a=p=>{var v;return((v=o.get(p))==null?void 0:v.key)??p},c=e.blockedBy.map(p=>{var v;return`${a(p)}${((v=o.get(p))==null?void 0:v.state)==="closed"?" ✓":""}`}).join(", "),u=s.filter(p=>p.blockedBy.includes(e.id)).map(p=>p.key).join(", "),h=[["Type",tr[e.type]],["Assignee",e.assignee],["Blocked by",c],["Blocks",u],["Reviews",e.reviewOf&&a(e.reviewOf)]],m=rr(e)==="hitl";return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"d-head",children:[i.jsx("span",{className:"key t-code",children:e.key}),i.jsx(Qn,{tone:"state",className:`st-${t}`,children:hg[t]}),i.jsx("span",{className:"d-att t-meta","data-tip":m?"A person takes this one":"An agent takes this alone",children:m?"Needs a person":"Agent work"})]}),i.jsx("h3",{className:"t-heading",children:e.title}),i.jsx("dl",{className:"facts",children:h.filter(([,p])=>p).flatMap(([p,v])=>[i.jsx("dt",{className:"t-label",children:p},`${p}-k`),i.jsx("dd",{children:v},`${p}-v`)])})]})}function ZA(e){const{snap:t,api:s,form:o,setForm:a}=e,{actions:c}=s,[u,h]=y.useState(""),[m,p]=y.useState(""),[v,k]=y.useState(""),[x,N]=y.useState("Not needed to reach the destination."),S=t.tickets.find(W=>W.id===e.id);if(!S)return i.jsx(Ae,{children:"Ticket not found."});const j=Zs(t.tickets,t.map.mode).get(S.id),A=e.sessions.find(W=>W.ticketId===S.id&&dn(W)),C=S.assignee===Nt,R=S.state==="open"?ku(s.leases,t.map.id).get(S.id):void 0,L=[...S.comments].reverse().find(W=>/^\*\*(Resolution|Ruled out of scope)\*\*/.test(W.body)),U=S.comments.filter(W=>W!==L),Z=JA(S.body),Q=s.decisions.filter(W=>W.mapId===t.map.id&&W.ticketId===S.id);return i.jsxs("div",{className:"detail",children:[i.jsx(XA,{t:S,state:j,tickets:t.tickets}),i.jsx(Tv,{mapId:t.map.id,kind:"ticket",id:S.id}),Z&&i.jsxs("section",{className:"d-section ticket-body",children:[i.jsx("span",{className:"t-label",children:"Description"}),i.jsx("p",{className:"body",children:Z})]}),i.jsx(cT,{mapId:t.map.id,ticketId:S.id}),i.jsx(mS,{mapId:t.map.id,ticketId:S.id}),i.jsx(k$,{mapId:t.map.id,ticket:S}),i.jsx(AA,{snap:t,t:S}),i.jsx($S,{snap:t,t:S}),S.closeReason==="not_planned"&&i.jsx(Tu,{label:"Save as dead end",draft:()=>{var W;return{title:`Ruled out: ${S.title}`,body:((W=S.comments.at(-1))==null?void 0:W.body)??S.body,kind:"dead-end",sources:[`trail:${t.map.key}`,`ticket:${S.key}`]}}}),R&&i.jsx(KA,{lease:R,onRelease:()=>c.releaseLease(S.id)}),!R&&i.jsx(B$,{mapId:t.map.id,ticketId:S.id}),i.jsx(HA,{mapId:t.map.id,trail:t.map.verification,ticket:S,state:j}),i.jsx(YA,{t:S,state:j,session:A,mine:C,form:o,setForm:a,actions:c,onOpenChat:e.onOpenChat}),o==="resolve"&&i.jsxs(Bt,{as:"form",tone:"inset",className:"inline-form",onSubmit:W=>{W.preventDefault(),u.trim()&&(c.resolve(S.id,u.trim(),{rationale:m.trim(),alternatives:v.split(`
173
+ `).map(ie=>ie.trim()).filter(Boolean)}),a(null),h(""),p(""),k(""))},children:[i.jsx(Ze,{label:"Resolution",children:i.jsx("textarea",{rows:3,value:u,onChange:W=>h(W.target.value),autoFocus:!0})}),i.jsx(Ze,{label:"Rationale",children:i.jsx("input",{value:m,onChange:W=>p(W.target.value)})}),i.jsx(Ze,{label:"Alternatives considered",children:i.jsx("textarea",{rows:2,value:v,onChange:W=>k(W.target.value),placeholder:"One per line"})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(P,{variant:"ghost",onClick:()=>a(null),children:"Cancel"}),i.jsx(P,{type:"submit",variant:"primary",disabled:!u.trim(),children:"Resolve"})]})]}),o==="rule"&&i.jsxs(Bt,{as:"form",tone:"inset",className:"inline-form",onSubmit:W=>{W.preventDefault(),c.ruleOut({ticketId:S.id},x),a(null)},children:[i.jsx(Ze,{label:"Reason",children:i.jsx("input",{value:x,onChange:W=>N(W.target.value),autoFocus:!0})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(P,{variant:"ghost",onClick:()=>a(null),children:"Cancel"}),i.jsx(P,{type:"submit",variant:"danger",children:"Rule out"})]})]}),L&&i.jsx(QA,{resolution:L,decisions:Q,onOpenDecision:e.onOpenDecision}),i.jsx(qA,{comments:U})]})}function eI({snap:e,item:t,api:s}){const o=$p(e.map.mode),[a,c]=y.useState("research"),[u,h]=y.useState(t),[m,p]=y.useState(!1),[v,k]=y.useState([]),[x,N]=y.useState("Not needed to reach the destination.");y.useEffect(()=>h(t),[t]);const S=e.tickets.filter(j=>j.state==="open");return i.jsxs("div",{className:"detail",children:[i.jsx("div",{className:"d-head",children:i.jsx(Qn,{tone:"state",className:"st-unspecified",children:"Not yet specified"})}),i.jsx("h3",{className:"t-heading",children:t}),i.jsxs(Bt,{as:"form",tone:"inset",className:"inline-form",onSubmit:j=>{j.preventDefault(),s.actions.graduate({unspecified:t,type:a,title:u,blockedBy:v,hitl:m})},children:[i.jsx(Ze,{label:"Title",children:i.jsx("input",{value:u,onChange:j=>h(j.target.value)})}),i.jsxs("div",{className:"chips",children:[o.map(j=>i.jsx("button",{type:"button",className:`chip ${a===j?"on":""}`,onClick:()=>c(j),children:j},j)),Gy.includes(a)&&i.jsx("button",{type:"button",className:`chip ${m?"on":""}`,onClick:()=>p(j=>!j),children:"needs human"})]}),i.jsx("span",{className:"field",children:"Blocked by"}),i.jsx("div",{className:"chips",children:S.map(j=>i.jsx("button",{type:"button",className:`chip ${v.includes(j.id)?"on":""}`,onClick:()=>k(A=>A.includes(j.id)?A.filter(C=>C!==j.id):[...A,j.id]),children:j.key},j.id))}),i.jsx("div",{className:"form-actions",children:i.jsx(P,{type:"submit",variant:"primary",children:"Promote to ticket"})})]}),i.jsxs(Bt,{as:"form",tone:"inset",className:"inline-form",onSubmit:j=>{j.preventDefault(),s.actions.ruleOut({unspecified:t},x)},children:[i.jsx(Ze,{label:"Reason",children:i.jsx("input",{value:x,onChange:j=>N(j.target.value)})}),i.jsx("div",{className:"form-actions",children:i.jsx(P,{type:"submit",variant:"danger",children:"Rule out"})})]})]})}function tI({api:e,sessions:t,bare:s,onOpenChat:o,onOpenDecision:a}){const{snap:c,selection:u,actions:h}=e,[m,p]=y.useState(null),v=nI(u);y.useEffect(()=>p(null),[v]);let k;return c?u?u.kind==="unspecified"?k=i.jsx(eI,{snap:c,item:u.item,api:e}):k=i.jsx(ZA,{snap:c,id:u.id,api:e,sessions:t,form:m,setForm:p,onOpenChat:o??h.openChat,onOpenDecision:a}):k=i.jsx(qn,{title:"No ticket selected",hint:"Pick a ticket on the map: what it is, who has it, what blocks it, and its decision."}):k=i.jsx(qn,{title:"No trail yet",hint:"Once there's a trail, pick a ticket on the map to see it here."}),i.jsx(Ng,{area:"inspector",icon:"note",title:"Trail step",info:"The ticket you selected on the map: what it is, who has it, what blocks it, and its decision once it's made.",className:"inspector",bare:s,children:k})}function nI(e){return(e==null?void 0:e.kind)==="ticket"?e.id:(e==null?void 0:e.kind)==="unspecified"?e.item:""}const sI={holding:"Holding",challenged:"Challenged",invalidated:"Invalidated",confirmed:"Confirmed"};function iI(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 rI(e){const{a:t,snap:s}=e,o=t.tickets.flatMap(c=>s.tickets.filter(u=>u.id===c)),a=t.challenge&&`${t.challenge.by}: ${t.challenge.evidence}`;return i.jsx(Ce,{as:"li",className:`assumption st-${t.status}`,edge:t.status==="challenged"?"attention":"neutral",title:t.text,titleText:t.text,context:i.jsx(V,{parts:[{text:t.id,code:!0},sI[t.status],iI(t)],children:o.length>0&&i.jsxs("span",{className:"assumption-tickets",children:[i.jsx("span",{className:"sep",children:" · "}),"relied on by",o.map(c=>i.jsx("button",{className:"link t-code",onClick:()=>e.onSelect({kind:"ticket",id:c.id}),children:c.key},c.id))]})}),detail:a,detailText:a,actions:e.onConfirm&&i.jsx(P,{size:"sm",variant:"ghost",disabled:e.busy,onClick:e.onConfirm,children:"Confirm"})})}function oI(e){const[t,s]=y.useState(),[o,a]=y.useState();return{confirm:async(u,h)=>{a(u);const m=await fetch(`${je()}/assumptions/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,id:u,text:h})}).catch(()=>{});if(a(void 0),m!=null&&m.ok)return s(void 0);const p=await(m==null?void 0:m.json().catch(()=>({})));s((p==null?void 0:p.error)??"Could not confirm it; is the Lookout connected?")},busy:o,error:t}}function aI({snap:e,onSelect:t}){const{confirm:s,busy:o,error:a}=oI(e.map.id),c=e.map.sections.assumptions??[];return c.length?i.jsxs(i.Fragment,{children:[a&&i.jsx("p",{className:"urgent-text",children:a}),i.jsx("ul",{className:"assumptions row-list",children:c.map(u=>{const h=u.status==="holding"||u.status==="challenged";return i.jsx(rI,{a:u,snap:e,onSelect:t,onConfirm:h?()=>void s(u.id,u.text):void 0,busy:o===u.id},u.id)})})]}):i.jsx(Ae,{children:"None yet. They come from the accepted discovery brief or the trail's start."})}function lI(e){const[,t,s=e]=/^(#\d+)\s+(.+)$/.exec(e)??[],[o=s,...a]=s.split(/\s+[—–]\s+/);return{key:t,title:o,reason:a.join(" — ")||void 0}}function cI(e){const[t,s]=y.useState([]),o=e==null?void 0:e.map.id,a=(e==null?void 0:e.tickets.reduce((c,u)=>Math.max(c,u.updatedAt),e.map.updatedAt))??0;return y.useEffect(()=>{if(!o)return;let c=!0;return fetch(`${je()}/journal?mapId=${encodeURIComponent(o)}`).then(u=>u.ok?u.json():{entries:[]}).then(u=>c&&s(u.entries)).catch(()=>c&&s([])),()=>{c=!1}},[o,a]),t}function uI({snap:e,activity:t,onTicket:s}){const o=cI(e),a=t.usageByMap[e.map.id],c=y.useMemo(()=>Up({snap:e,journal:o,answered:t.answered,usage:a}),[e,o,t.answered,a]),u=c.interventions,h=[["Done",`${c.done}`,`${c.done} done · ${c.cancelled} cancelled · ${c.open} open`],["Lead time",un(c.trailLeadMs),"Trail lead time: from when the trail was charted to its last done ticket"],["Median ticket",un(c.medianLeadMs),"Median time from a ticket's first claim to done"],["Interventions",`${u.total}`,`${u.answers} agent questions you answered + ${u.operatorActions} lifecycle calls you made (approve, send back, accept, unblock, cancel, release), of which ${u.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?"—":qs(c.spend.perVerifiedTicketUsd),`Cost per verified ticket: trail spend ${qs(c.spend.costUsd)} ÷ ${c.done} done tickets`]];return i.jsxs("div",{className:"report",children:[i.jsx("ul",{className:"report-stats",children:h.map(([m,p,v])=>i.jsxs("li",{"data-tip":v,children:[i.jsx("span",{className:"mono-label",children:m}),i.jsx("b",{children:p})]},m))}),i.jsxs("div",{className:"report-bar",children:[i.jsx("span",{className:"mono-label",children:"Tickets"}),i.jsx(P,{size:"sm",variant:"ghost","data-tip":"Download this report as markdown",onClick:()=>cg(`${e.map.key.replace("#","trail-")}-report.md`,Fx(c,e.map.title)),children:"Export markdown"})]}),c.tickets.length?i.jsx("ul",{className:"list report-tickets",children:c.tickets.map(m=>i.jsx("li",{className:`out-${m.outcome}`,children:i.jsxs("button",{onClick:()=>s(m.id),"data-tip":`${m.outcome} · rework ${m.reworks} · reviews ${m.reviews.passed}/${m.reviews.failed} · your calls ${m.operatorActions}`,children:[i.jsx("span",{className:"key",children:m.key}),i.jsx("span",{className:"ttl",children:m.title}),i.jsx("span",{className:"lead",children:m.outcome==="done"?un(m.leadMs):m.outcome})]})},m.id))}):i.jsx(Ae,{children:"No tickets yet"})]})}function dI({tab:e,snap:t,selection:s,onSelect:o,activity:a}){const c=t.map.sections;switch(e){case"report":return a?i.jsx(uI,{snap:t,activity:a,onTicket:u=>o({kind:"ticket",id:u})}):i.jsx(Ae,{children:"No activity yet"});case"assumptions":return i.jsx(aI,{snap:t,onSelect:o});case"decisions":return c.decisions.length?i.jsx("ol",{className:"row-list decisions",children:[...c.decisions].reverse().map((u,h)=>i.jsx(Ce,{as:"li",title:u.text,titleText:u.text,context:u.ticketKey&&i.jsx(V,{parts:[{text:u.ticketKey,code:!0}]}),onOpen:u.ticketId?()=>o({kind:"ticket",id:u.ticketId}):void 0},`${u.ticketKey}-${h}`))}):i.jsx(Ae,{children:"None"});case"unspecified":return c.unspecified.length?i.jsx("ul",{className:"row-list unspecified",children:c.unspecified.map(u=>i.jsx(Ce,{as:"li",title:u,titleText:u,selected:(s==null?void 0:s.kind)==="unspecified"&&s.item===u,onOpen:()=>o({kind:"unspecified",item:u})},u))}):i.jsx(Ae,{children:"None"});case"oos":return c.outOfScope.length?i.jsx("ul",{className:"row-list oos",children:c.outOfScope.map(u=>{const h=lI(u);return i.jsx(Ce,{as:"li",title:h.title,titleText:u,context:i.jsx(V,{parts:[h.key&&{text:h.key,code:!0},h.reason]})},u)})}):i.jsx(Ae,{children:"None"});case"notes":return i.jsx("p",{className:"notes t-body",children:c.notes||"No notes yet."});default:return e}}function hI({snap:e,selection:t,onSelect:s,bare:o,onAudit:a,activity:c}){var k;const[u,h]=y.useState("unspecified"),m=e==null?void 0:e.map.sections,p=[{id:"unspecified",label:"Not yet specified",n:m==null?void 0:m.unspecified.length},{id:"assumptions",label:"Assumptions",n:(k=m==null?void 0:m.assumptions)==null?void 0:k.length},{id:"decisions",label:"Decisions",n:m==null?void 0:m.decisions.length},{id:"oos",label:"Out of scope",n:m==null?void 0:m.outOfScope.length},{id:"notes",label:"Notes"},{id:"report",label:"Report"}],v=e?i.jsx(dI,{tab:u,snap:e,selection:t,onSelect:s,activity:c}):i.jsx(qn,{title:"No plan yet",hint:"Open questions, decisions, what's ruled out, notes and the trail report collect here."});return i.jsxs(ze,{className:`zone sections ${o?"bare":""}`,style:o?void 0:{gridArea:"plan"},children:[!o&&i.jsx(Et,{className:"zone-title",icon:"flag",title:"Trail plan",info:"The parts of the plan that aren't tickets yet: open questions still to specify, the assumptions the plan relies on, decisions already made, what's ruled out, and notes. Report shows how the trail is going: lead times, your interventions, rework, reviews and cost per verified ticket."}),i.jsxs("div",{className:"sections-tabs",children:[i.jsx(dt,{compact:!0,"aria-label":"Plan section",value:u,onChange:h,options:p.map(x=>({value:x.id,label:x.n===void 0?x.label:`${x.label} · ${x.n}`}))}),u==="decisions"&&a&&i.jsx("button",{className:"link",onClick:a,children:"Audit ›"})]}),i.jsx("div",{className:"zone-b",children:v})]})}function fI(){var le;const e=y.useMemo(()=>WN(UN()),[]),t=tS(e),{snap:s,activity:o,selection:a,actions:c}=t,[u,h]=nS();y.useEffect(()=>wg(u.theme),[u.theme]);const m=h2(),[p,v]=y.useState(!1),k=p2(e.kind),x=YN(),N=o.pending.length,S=g2(o,t.mapId);m2(N,s==null?void 0:s.map.title);const j=f2(t,x),A=G2(s,c.selectMap),C=OS(A.briefText),R=J2({api:t,nav:j,knowledge:C,reviewBrief:A.review,openReroute:te=>A.openReroute(te.mapId,te.ref),openGuides:()=>m.open("guides"),openConnector:te=>m.open(te),openApprovals:()=>m.open("approvals"),openFocusSettings:()=>m.open("attention")}),L=XN(e,t,u.briefing,(le=R.attention.view)==null?void 0:le.items),U=i.jsx(gb,{api:t,nav:j,bp:x,scoped:S,attn:R,above:A.inboxCard}),Z=i.jsx(l2,{api:t,sessions:S.sessions,onSelect:j.select,onNewTrail:()=>v(!0),compact:x==="mobile",minFit:x==="mobile"?.7:0,trail:A}),Q=te=>i.jsx(tI,{api:t,sessions:S.sessions,bare:te,onOpenChat:K=>j.openChat(K),onOpenDecision:j.openDecisions}),W={activity:S,snap:s,leases:t.leases,onTicket:te=>j.select({kind:"ticket",id:te}),onOpenChat:te=>j.openChat(te)},ie=te=>i.jsx(hI,{snap:s,selection:a,onSelect:j.select,bare:te,onAudit:()=>j.openDecisions(),activity:S}),{projects:G,overview:ve,openOverview:Le}=hA(x,j,R.link.request),$e=m.route&&i.jsx(dE,{rt:e,api:t,bp:x,prefs:u,update:h,settings:m}),oe=(j.statsOpen||j.decisionsView)&&i.jsx(dA,{api:t,bp:x,nav:j}),D=$e||ve||oe,X=L.shown&&i.jsx(hS,{brief:L,snaps:t.allSnaps,bp:x,openTicket:j.openTicket,openChat:j.openChat,openDecisions:j.openDecisions,closeDecisions:()=>j.setDecisionsView(null),showPhoneHome:()=>j.setPhoneTab("home")});return i.jsx(bg.Provider,{value:C,children:i.jsxs("div",{className:`app bp-${x}`,children:[i.jsx(y1,{api:t,rt:e,repo:i.jsx(tT,{repo:k,projects:G,onOverview:Le}),brief:L,attention:R.header,decisionsOpen:!!j.decisionsView,onDecisions:()=>{m.close(),j.decisionsView?j.setDecisionsView(null):j.openDecisions()},onStats:()=>{m.close(),j.toggleStats()},onNewTrail:()=>v(!0),onSettings:m.toggle,onSlack:()=>m.open("slack"),onToggleTheme:te=>h({theme:te?"night":"day"})}),x==="wide"&&i.jsxs(i.Fragment,{children:[U,Z,Q(!1),i.jsx(jA,{...W}),i.jsx(xA,{...W}),ie(!1),D]}),x==="laptop"&&i.jsxs(i.Fragment,{children:[U,Z,i.jsx(hE,{tab:j.sideTab,onTab:j.setSideTab,unspecified:s==null?void 0:s.map.sections.unspecified.length,ticket:Q(!0),activity:i.jsx(fp,{...W}),plan:ie(!0)}),D]}),x==="mobile"&&i.jsxs(i.Fragment,{children:[i.jsx(d2,{tab:j.phoneTab,decisions:D,inbox:U,projects:G.many&&i.jsx(sT,{projects:G,onOverview:Le}),map:Z,ticket:Q(!0),activity:i.jsx(fp,{...W}),plan:ie(!0)}),i.jsx(u2,{tab:j.phoneTab,covered:!!D,pending:N,onPick:te=>{m.close(),j.setPhoneTab(te),j.setDecisionsView(null)}})]}),X,A.dialog,t.error&&i.jsx("div",{className:"error-toast",children:t.error}),p&&i.jsx(Nb,{rt:e,onClose:()=>v(!1),onCreated:te=>c.selectMap(te)}),!u.onboarded&&i.jsx(mC,{prefs:u,update:h,activeTracker:e.kind}),i.jsx(IS,{})]})})}const mI="X-Teamtrail-Session";function pI(e){return typeof e=="string"?e:e instanceof URL?e.href:e.url}function gI(e){const t=new URL(pI(e),location.href),s=J.apiPrefix;return t.origin===location.origin&&(t.pathname===s||t.pathname.startsWith(`${s}/`))}function vI(){const e=window.fetch.bind(window);window.fetch=(t,s)=>{const o=SN()?wu():void 0;if(!o||!gI(t))return e(t,s);const a=new Headers((s==null?void 0:s.headers)??(t instanceof Request?t.headers:void 0));return a.set(mI,o.secret),e(t,{...s,headers:a})}}wg(Su().theme);vI();Fy.createRoot(document.getElementById("root")).render(i.jsxs(eE,{children:[i.jsx(fI,{}),i.jsx(aS,{})]}));