teamtrail 0.27.1-next.37 → 0.28.0-next.40

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 Ty=Object.defineProperty;var Ey=(e,t,s)=>t in e?Ty(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var ce=(e,t,s)=>Ey(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 d of c.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&o(d)}).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 dc={exports:{}},Hi={},hc={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 If;function Ay(){if(If)return ye;If=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"),d=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 j={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},b=Object.assign,S={};function I(T,_,ue){this.props=T,this.context=_,this.refs=S,this.updater=ue||j}I.prototype.isReactComponent={},I.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")},I.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function C(){}C.prototype=I.prototype;function R(T,_,ue){this.props=T,this.context=_,this.refs=S,this.updater=ue||j}var O=R.prototype=new C;O.constructor=R,b(O,I.prototype),O.isPureReactComponent=!0;var U=Array.isArray,X=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),_)X.call(_,me)&&!W.hasOwnProperty(me)&&(ke[me]=_[me]);var Se=arguments.length-2;if(Se===1)ke.children=ue;else if(1<Se){for(var ge=Array(Se),Be=0;Be<Se;Be++)ge[Be]=arguments[Be+2];ke.children=ge}if(T&&T.defaultProps)for(me in Se=T.defaultProps,Se)ke[me]===void 0&&(ke[me]=Se[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 Pe(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?Pe(""+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 Se=0;Se<T.length;Se++){xe=T[Se];var ge=me+oe(xe,Se);pe+=D(xe,_,ue,ge,ke)}else if(ge=x(T),typeof ge=="function")for(T=ge.call(T),Se=0;!(xe=T.next()).done;)xe=xe.value,ge=me+oe(xe,Se++),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 J(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 ee={current:null},K={transition:null},Y={ReactCurrentDispatcher:ee,ReactCurrentBatchConfig:K,ReactCurrentOwner:Q};function B(){throw Error("act(...) is not supported in production builds of React.")}return ye.Children={map:J,forEach:function(T,_,ue){J(T,function(){_.apply(this,arguments)},ue)},count:function(T){var _=0;return J(T,function(){_++}),_},toArray:function(T){return J(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=I,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=b({},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 Se=T.type.defaultProps;for(ge in _)X.call(_,ge)&&!W.hasOwnProperty(ge)&&(me[ge]=_[ge]===void 0&&Se!==void 0?Se[ge]:_[ge])}var ge=arguments.length-2;if(ge===1)me.children=ue;else if(1<ge){Se=Array(ge);for(var Be=0;Be<ge;Be++)Se[Be]=arguments[Be+2];me.children=Se}return{$$typeof:e,type:T.type,key:ke,ref:xe,props:me,_owner:pe}},ye.createContext=function(T){return T={$$typeof:d,_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 ee.current.useCallback(T,_)},ye.useContext=function(T){return ee.current.useContext(T)},ye.useDebugValue=function(){},ye.useDeferredValue=function(T){return ee.current.useDeferredValue(T)},ye.useEffect=function(T,_){return ee.current.useEffect(T,_)},ye.useId=function(){return ee.current.useId()},ye.useImperativeHandle=function(T,_,ue){return ee.current.useImperativeHandle(T,_,ue)},ye.useInsertionEffect=function(T,_){return ee.current.useInsertionEffect(T,_)},ye.useLayoutEffect=function(T,_){return ee.current.useLayoutEffect(T,_)},ye.useMemo=function(T,_){return ee.current.useMemo(T,_)},ye.useReducer=function(T,_,ue){return ee.current.useReducer(T,_,ue)},ye.useRef=function(T){return ee.current.useRef(T)},ye.useState=function(T){return ee.current.useState(T)},ye.useSyncExternalStore=function(T,_,ue){return ee.current.useSyncExternalStore(T,_,ue)},ye.useTransition=function(){return ee.current.useTransition()},ye.version="18.3.1",ye}var Mf;function iu(){return Mf||(Mf=1,hc.exports=Ay()),hc.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 Rf;function Iy(){if(Rf)return Hi;Rf=1;var e=iu(),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 d(h,m,p){var v,k={},x=null,j=null;p!==void 0&&(x=""+p),m.key!==void 0&&(x=""+m.key),m.ref!==void 0&&(j=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:j,props:k,_owner:a.current}}return Hi.Fragment=s,Hi.jsx=d,Hi.jsxs=d,Hi}var Lf;function My(){return Lf||(Lf=1,dc.exports=Iy()),dc.exports}var i=My(),yo={},fc={exports:{}},xt={},mc={exports:{}},pc={};/**
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 Of;function Ry(){return Of||(Of=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 d=Date,h=d.now();e.unstable_now=function(){return d.now()-h}}var m=[],p=[],v=1,k=null,x=3,j=!1,b=!1,S=!1,I=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 O(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(S=!1,O(K),!b)if(s(m)!==null)b=!0,le(X);else{var Y=s(p);Y!==null&&ee(U,Y.startTime-K)}}function X(K,Y){b=!1,S&&(S=!1,C(ie),ie=-1),j=!0;var B=x;try{for(O(Y),k=s(m);k!==null&&(!(k.expirationTime>Y)||K&&!Pe());){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),O(Y)}else o(m);k=s(m)}if(k!==null)var ue=!0;else{var me=s(p);me!==null&&ee(U,me.startTime-Y),ue=!1}return ue}finally{k=null,x=B,j=!1}}var Q=!1,W=null,ie=-1,G=5,ve=-1;function Pe(){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,J=D.port2;D.port1.onmessage=$e,oe=function(){J.postMessage(null)}}else oe=function(){I($e,0)};function le(K){W=K,Q||(Q=!0,oe())}function ee(K,Y){ie=I(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(){b||j||(b=!0,le(X))},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)&&(S?(C(ie),ie=-1):S=!0,ee(U,B-T))):(K.sortIndex=_,t(m,K),b||j||(b=!0,le(X))),K},e.unstable_shouldYield=Pe,e.unstable_wrapCallback=function(K){var Y=x;return function(){var B=x;x=Y;try{return K.apply(this,arguments)}finally{x=B}}}})(pc)),pc}var Pf;function Ly(){return Pf||(Pf=1,mc.exports=Ry()),mc.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 _f;function Oy(){if(_f)return xt;_f=1;var e=iu(),t=Ly();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){d(n,r),d(n+"Capture",r)}function d(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 j(n,r,l,u){if(l!==null&&l.type===0)return!1;switch(typeof r){case"function":case"symbol":return!0;case"boolean":return u?!1:l!==null?!l.acceptsBooleans:(n=n.toLowerCase().slice(0,5),n!=="data-"&&n!=="aria-");default:return!1}}function b(n,r,l,u){if(r===null||typeof r>"u"||j(n,r,l,u))return!0;if(u)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 S(n,r,l,u,f,g,w){this.acceptsBooleans=r===2||r===3||r===4,this.attributeName=u,this.attributeNamespace=f,this.mustUseProperty=l,this.propertyName=n,this.type=r,this.sanitizeURL=g,this.removeEmptyString=w}var I={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(n){I[n]=new S(n,0,!1,n,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(n){var r=n[0];I[r]=new S(r,1,!1,n[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(n){I[n]=new S(n,2,!1,n.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(n){I[n]=new S(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){I[n]=new S(n,3,!1,n.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(n){I[n]=new S(n,3,!0,n,null,!1,!1)}),["capture","download"].forEach(function(n){I[n]=new S(n,4,!1,n,null,!1,!1)}),["cols","rows","size","span"].forEach(function(n){I[n]=new S(n,6,!1,n,null,!1,!1)}),["rowSpan","start"].forEach(function(n){I[n]=new S(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);I[r]=new S(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);I[r]=new S(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);I[r]=new S(r,1,!1,n,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(n){I[n]=new S(n,1,!1,n.toLowerCase(),null,!1,!1)}),I.xlinkHref=new S("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(n){I[n]=new S(n,1,!1,n.toLowerCase(),null,!0,!0)});function O(n,r,l,u){var f=I.hasOwnProperty(r)?I[r]:null;(f!==null?f.type!==0:u||!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(b(r,l,f,u)&&(l=null),u||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,u=f.attributeNamespace,l===null?n.removeAttribute(r):(f=f.type,l=f===3||f===4&&l===!0?"":""+l,u?n.setAttributeNS(u,r,l):n.setAttribute(r,l))))}var U=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,X=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"),Pe=Symbol.for("react.context"),$e=Symbol.for("react.forward_ref"),oe=Symbol.for("react.suspense"),D=Symbol.for("react.suspense_list"),J=Symbol.for("react.memo"),le=Symbol.for("react.lazy"),ee=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(L){var u=L}Reflect.construct(n,[],r)}else{try{r.call()}catch(L){u=L}n.call(r.prototype)}else{try{throw Error()}catch(L){u=L}n()}}catch(L){if(L&&u&&typeof L.stack=="string"){for(var f=L.stack.split(`
35
+ `),g=u.stack.split(`
36
+ `),w=f.length-1,N=g.length-1;1<=w&&0<=N&&f[w]!==g[N];)N--;for(;1<=w&&0<=N;w--,N--)if(f[w]!==g[N]){if(w!==1||N!==1)do if(w--,N--,0>N||f[w]!==g[N]){var $=`
37
+ `+f[w].replace(" at new "," at ");return n.displayName&&$.includes("<anonymous>")&&($=$.replace("<anonymous>",n.displayName)),$}while(1<=w&&0<=N);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 Pe: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 J: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 Se(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),u=""+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){u=""+w,g.call(this,w)}}),Object.defineProperty(n,r,{enumerable:l.enumerable}),{getValue:function(){return u},setValue:function(w){u=""+w},stopTracking:function(){n._valueTracker=null,delete n[r]}}}}function jn(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(),u="";return n&&(u=ge(n)?n.checked?"true":"false":n.value),n=u,n!==l?(r.setValue(n),!0):!1}function fs(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 ka(n,r){var l=r.checked;return B({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:l??n._wrapperState.initialChecked})}function _u(n,r){var l=r.defaultValue==null?"":r.defaultValue,u=r.checked!=null?r.checked:r.defaultChecked;l=Se(r.value!=null?r.value:l),n._wrapperState={initialChecked:u,initialValue:l,controlled:r.type==="checkbox"||r.type==="radio"?r.checked!=null:r.value!=null}}function Du(n,r){r=r.checked,r!=null&&O(n,"checked",r,!1)}function ya(n,r){Du(n,r);var l=Se(r.value),u=r.type;if(l!=null)u==="number"?(l===0&&n.value===""||n.value!=l)&&(n.value=""+l):n.value!==""+l&&(n.value=""+l);else if(u==="submit"||u==="reset"){n.removeAttribute("value");return}r.hasOwnProperty("value")?wa(n,r.type,l):r.hasOwnProperty("defaultValue")&&wa(n,r.type,Se(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(n.defaultChecked=!!r.defaultChecked)}function zu(n,r,l){if(r.hasOwnProperty("value")||r.hasOwnProperty("defaultValue")){var u=r.type;if(!(u!=="submit"&&u!=="reset"||r.value!==void 0&&r.value!==null))return;r=""+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 wa(n,r,l){(r!=="number"||fs(n.ownerDocument)!==n)&&(l==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+l&&(n.defaultValue=""+l))}var ri=Array.isArray;function ms(n,r,l,u){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&&u&&(n[l].defaultSelected=!0)}else{for(l=""+Se(l),r=null,f=0;f<n.length;f++){if(n[f].value===l){n[f].selected=!0,u&&(n[f].defaultSelected=!0);return}r!==null||n[f].disabled||(r=n[f])}r!==null&&(r.selected=!0)}}function xa(n,r){if(r.dangerouslySetInnerHTML!=null)throw Error(s(91));return B({},r,{value:void 0,defaultValue:void 0,children:""+n._wrapperState.initialValue})}function Bu(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(ri(l)){if(1<l.length)throw Error(s(93));l=l[0]}r=l}r==null&&(r=""),l=r}n._wrapperState={initialValue:Se(l)}}function Fu(n,r){var l=Se(r.value),u=Se(r.defaultValue);l!=null&&(l=""+l,l!==n.value&&(n.value=l),r.defaultValue==null&&n.defaultValue!==l&&(n.defaultValue=l)),u!=null&&(n.defaultValue=""+u)}function Uu(n){var r=n.textContent;r===n._wrapperState.initialValue&&r!==""&&r!==null&&(n.value=r)}function Wu(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 ja(n,r){return n==null||n==="http://www.w3.org/1999/xhtml"?Wu(r):n==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":n}var ur,Hu=(function(n){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(r,l,u,f){MSApp.execUnsafeLocalFunction(function(){return n(r,l,u,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 oi(n,r){if(r){var l=n.firstChild;if(l&&l===n.lastChild&&l.nodeType===3){l.nodeValue=r;return}}n.textContent=r}var ai={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},Mv=["Webkit","ms","Moz","O"];Object.keys(ai).forEach(function(n){Mv.forEach(function(r){r=r+n.charAt(0).toUpperCase()+n.substring(1),ai[r]=ai[n]})});function Ku(n,r,l){return r==null||typeof r=="boolean"||r===""?"":l||typeof r!="number"||r===0||ai.hasOwnProperty(n)&&ai[n]?(""+r).trim():r+"px"}function Vu(n,r){n=n.style;for(var l in r)if(r.hasOwnProperty(l)){var u=l.indexOf("--")===0,f=Ku(l,r[l],u);l==="float"&&(l="cssFloat"),u?n.setProperty(l,f):n[l]=f}}var Rv=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 Sa(n,r){if(r){if(Rv[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 Na(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 ba=null;function Ca(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var $a=null,ps=null,gs=null;function Gu(n){if(n=Ei(n)){if(typeof $a!="function")throw Error(s(280));var r=n.stateNode;r&&(r=Rr(r),$a(n.stateNode,n.type,r))}}function qu(n){ps?gs?gs.push(n):gs=[n]:ps=n}function Qu(){if(ps){var n=ps,r=gs;if(gs=ps=null,Gu(n),r)for(n=0;n<r.length;n++)Gu(r[n])}}function Yu(n,r){return n(r)}function Ju(){}var Ta=!1;function Xu(n,r,l){if(Ta)return n(r,l);Ta=!0;try{return Yu(n,r,l)}finally{Ta=!1,(ps!==null||gs!==null)&&(Ju(),Qu())}}function li(n,r){var l=n.stateNode;if(l===null)return null;var u=Rr(l);if(u===null)return null;l=u[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(u=!u.disabled)||(n=n.type,u=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!u;break e;default:n=!1}if(n)return null;if(l&&typeof l!="function")throw Error(s(231,r,typeof l));return l}var Ea=!1;if(h)try{var ci={};Object.defineProperty(ci,"passive",{get:function(){Ea=!0}}),window.addEventListener("test",ci,ci),window.removeEventListener("test",ci,ci)}catch{Ea=!1}function Lv(n,r,l,u,f,g,w,N,$){var L=Array.prototype.slice.call(arguments,3);try{r.apply(l,L)}catch(F){this.onError(F)}}var ui=!1,dr=null,hr=!1,Aa=null,Ov={onError:function(n){ui=!0,dr=n}};function Pv(n,r,l,u,f,g,w,N,$){ui=!1,dr=null,Lv.apply(Ov,arguments)}function _v(n,r,l,u,f,g,w,N,$){if(Pv.apply(this,arguments),ui){if(ui){var L=dr;ui=!1,dr=null}else throw Error(s(198));hr||(hr=!0,Aa=L)}}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 Zu(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 ed(n){if(Yn(n)!==n)throw Error(s(188))}function Dv(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,u=r;;){var f=l.return;if(f===null)break;var g=f.alternate;if(g===null){if(u=f.return,u!==null){l=u;continue}break}if(f.child===g.child){for(g=f.child;g;){if(g===l)return ed(f),n;if(g===u)return ed(f),r;g=g.sibling}throw Error(s(188))}if(l.return!==u.return)l=f,u=g;else{for(var w=!1,N=f.child;N;){if(N===l){w=!0,l=f,u=g;break}if(N===u){w=!0,u=f,l=g;break}N=N.sibling}if(!w){for(N=g.child;N;){if(N===l){w=!0,l=g,u=f;break}if(N===u){w=!0,u=g,l=f;break}N=N.sibling}if(!w)throw Error(s(189))}}if(l.alternate!==u)throw Error(s(190))}if(l.tag!==3)throw Error(s(188));return l.stateNode.current===l?n:r}function td(n){return n=Dv(n),n!==null?nd(n):null}function nd(n){if(n.tag===5||n.tag===6)return n;for(n=n.child;n!==null;){var r=nd(n);if(r!==null)return r;n=n.sibling}return null}var sd=t.unstable_scheduleCallback,id=t.unstable_cancelCallback,zv=t.unstable_shouldYield,Bv=t.unstable_requestPaint,We=t.unstable_now,Fv=t.unstable_getCurrentPriorityLevel,Ia=t.unstable_ImmediatePriority,rd=t.unstable_UserBlockingPriority,fr=t.unstable_NormalPriority,Uv=t.unstable_LowPriority,od=t.unstable_IdlePriority,mr=null,Jt=null;function Wv(n){if(Jt&&typeof Jt.onCommitFiberRoot=="function")try{Jt.onCommitFiberRoot(mr,n,void 0,(n.current.flags&128)===128)}catch{}}var Bt=Math.clz32?Math.clz32:Vv,Hv=Math.log,Kv=Math.LN2;function Vv(n){return n>>>=0,n===0?32:31-(Hv(n)/Kv|0)|0}var pr=64,gr=4194304;function di(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 u=0,f=n.suspendedLanes,g=n.pingedLanes,w=l&268435455;if(w!==0){var N=w&~f;N!==0?u=di(N):(g&=w,g!==0&&(u=di(g)))}else w=l&~f,w!==0?u=di(w):g!==0&&(u=di(g));if(u===0)return 0;if(r!==0&&r!==u&&(r&f)===0&&(f=u&-u,g=r&-r,f>=g||f===16&&(g&4194240)!==0))return r;if((u&4)!==0&&(u|=l&16),r=n.entangledLanes,r!==0)for(n=n.entanglements,r&=u;0<r;)l=31-Bt(r),f=1<<l,u|=n[l],r&=~f;return u}function Gv(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 qv(n,r){for(var l=n.suspendedLanes,u=n.pingedLanes,f=n.expirationTimes,g=n.pendingLanes;0<g;){var w=31-Bt(g),N=1<<w,$=f[w];$===-1?((N&l)===0||(N&u)!==0)&&(f[w]=Gv(N,r)):$<=r&&(n.expiredLanes|=N),g&=~N}}function Ma(n){return n=n.pendingLanes&-1073741825,n!==0?n:n&1073741824?1073741824:0}function ad(){var n=pr;return pr<<=1,(pr&4194240)===0&&(pr=64),n}function Ra(n){for(var r=[],l=0;31>l;l++)r.push(n);return r}function hi(n,r,l){n.pendingLanes|=r,r!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,r=31-Bt(r),n[r]=l}function Qv(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 u=n.eventTimes;for(n=n.expirationTimes;0<l;){var f=31-Bt(l),g=1<<f;r[f]=0,u[f]=-1,n[f]=-1,l&=~g}}function La(n,r){var l=n.entangledLanes|=r;for(n=n.entanglements;l;){var u=31-Bt(l),f=1<<u;f&r|n[u]&r&&(n[u]|=r),l&=~f}}var Te=0;function ld(n){return n&=-n,1<n?4<n?(n&268435455)!==0?16:536870912:4:1}var cd,Oa,ud,dd,hd,Pa=!1,kr=[],Sn=null,Nn=null,bn=null,fi=new Map,mi=new Map,Cn=[],Yv="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 fd(n,r){switch(n){case"focusin":case"focusout":Sn=null;break;case"dragenter":case"dragleave":Nn=null;break;case"mouseover":case"mouseout":bn=null;break;case"pointerover":case"pointerout":fi.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":mi.delete(r.pointerId)}}function pi(n,r,l,u,f,g){return n===null||n.nativeEvent!==g?(n={blockedOn:r,domEventName:l,eventSystemFlags:u,nativeEvent:g,targetContainers:[f]},r!==null&&(r=Ei(r),r!==null&&Oa(r)),n):(n.eventSystemFlags|=u,r=n.targetContainers,f!==null&&r.indexOf(f)===-1&&r.push(f),n)}function Jv(n,r,l,u,f){switch(r){case"focusin":return Sn=pi(Sn,n,r,l,u,f),!0;case"dragenter":return Nn=pi(Nn,n,r,l,u,f),!0;case"mouseover":return bn=pi(bn,n,r,l,u,f),!0;case"pointerover":var g=f.pointerId;return fi.set(g,pi(fi.get(g)||null,n,r,l,u,f)),!0;case"gotpointercapture":return g=f.pointerId,mi.set(g,pi(mi.get(g)||null,n,r,l,u,f)),!0}return!1}function md(n){var r=Jn(n.target);if(r!==null){var l=Yn(r);if(l!==null){if(r=l.tag,r===13){if(r=Zu(l),r!==null){n.blockedOn=r,hd(n.priority,function(){ud(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=Da(n.domEventName,n.eventSystemFlags,r[0],n.nativeEvent);if(l===null){l=n.nativeEvent;var u=new l.constructor(l.type,l);ba=u,l.target.dispatchEvent(u),ba=null}else return r=Ei(l),r!==null&&Oa(r),n.blockedOn=l,!1;r.shift()}return!0}function pd(n,r,l){yr(n)&&l.delete(r)}function Xv(){Pa=!1,Sn!==null&&yr(Sn)&&(Sn=null),Nn!==null&&yr(Nn)&&(Nn=null),bn!==null&&yr(bn)&&(bn=null),fi.forEach(pd),mi.forEach(pd)}function gi(n,r){n.blockedOn===r&&(n.blockedOn=null,Pa||(Pa=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Xv)))}function vi(n){function r(f){return gi(f,n)}if(0<kr.length){gi(kr[0],n);for(var l=1;l<kr.length;l++){var u=kr[l];u.blockedOn===n&&(u.blockedOn=null)}}for(Sn!==null&&gi(Sn,n),Nn!==null&&gi(Nn,n),bn!==null&&gi(bn,n),fi.forEach(r),mi.forEach(r),l=0;l<Cn.length;l++)u=Cn[l],u.blockedOn===n&&(u.blockedOn=null);for(;0<Cn.length&&(l=Cn[0],l.blockedOn===null);)md(l),l.blockedOn===null&&Cn.shift()}var vs=U.ReactCurrentBatchConfig,wr=!0;function Zv(n,r,l,u){var f=Te,g=vs.transition;vs.transition=null;try{Te=1,_a(n,r,l,u)}finally{Te=f,vs.transition=g}}function ek(n,r,l,u){var f=Te,g=vs.transition;vs.transition=null;try{Te=4,_a(n,r,l,u)}finally{Te=f,vs.transition=g}}function _a(n,r,l,u){if(wr){var f=Da(n,r,l,u);if(f===null)tl(n,r,u,xr,l),fd(n,u);else if(Jv(f,n,r,l,u))u.stopPropagation();else if(fd(n,u),r&4&&-1<Yv.indexOf(n)){for(;f!==null;){var g=Ei(f);if(g!==null&&cd(g),g=Da(n,r,l,u),g===null&&tl(n,r,u,xr,l),g===f)break;f=g}f!==null&&u.stopPropagation()}else tl(n,r,u,null,l)}}var xr=null;function Da(n,r,l,u){if(xr=null,n=Ca(u),n=Jn(n),n!==null)if(r=Yn(n),r===null)n=null;else if(l=r.tag,l===13){if(n=Zu(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 gd(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(Fv()){case Ia:return 1;case rd:return 4;case fr:case Uv:return 16;case od:return 536870912;default:return 16}default:return 16}}var $n=null,za=null,jr=null;function vd(){if(jr)return jr;var n,r=za,l=r.length,u,f="value"in $n?$n.value:$n.textContent,g=f.length;for(n=0;n<l&&r[n]===f[n];n++);var w=l-n;for(u=1;u<=w&&r[l-u]===f[g-u];u++);return jr=f.slice(n,1<u?1-u:void 0)}function Sr(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 Nr(){return!0}function kd(){return!1}function bt(n){function r(l,u,f,g,w){this._reactName=l,this._targetInst=f,this.type=u,this.nativeEvent=g,this.target=w,this.currentTarget=null;for(var N in n)n.hasOwnProperty(N)&&(l=n[N],this[N]=l?l(g):g[N]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?Nr:kd,this.isPropagationStopped=kd,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=Nr)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=Nr)},persist:function(){},isPersistent:Nr}),r}var ks={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ba=bt(ks),ki=B({},ks,{view:0,detail:0}),tk=bt(ki),Fa,Ua,yi,br=B({},ki,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ha,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!==yi&&(yi&&n.type==="mousemove"?(Fa=n.screenX-yi.screenX,Ua=n.screenY-yi.screenY):Ua=Fa=0,yi=n),Fa)},movementY:function(n){return"movementY"in n?n.movementY:Ua}}),yd=bt(br),nk=B({},br,{dataTransfer:0}),sk=bt(nk),ik=B({},ki,{relatedTarget:0}),Wa=bt(ik),rk=B({},ks,{animationName:0,elapsedTime:0,pseudoElement:0}),ok=bt(rk),ak=B({},ks,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),lk=bt(ak),ck=B({},ks,{data:0}),wd=bt(ck),uk={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},dk={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"},hk={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function fk(n){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(n):(n=hk[n])?!!r[n]:!1}function Ha(){return fk}var mk=B({},ki,{key:function(n){if(n.key){var r=uk[n.key]||n.key;if(r!=="Unidentified")return r}return n.type==="keypress"?(n=Sr(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?dk[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ha,charCode:function(n){return n.type==="keypress"?Sr(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?Sr(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),pk=bt(mk),gk=B({},br,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),xd=bt(gk),vk=B({},ki,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ha}),kk=bt(vk),yk=B({},ks,{propertyName:0,elapsedTime:0,pseudoElement:0}),wk=bt(yk),xk=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}),jk=bt(xk),Sk=[9,13,27,32],Ka=h&&"CompositionEvent"in window,wi=null;h&&"documentMode"in document&&(wi=document.documentMode);var Nk=h&&"TextEvent"in window&&!wi,jd=h&&(!Ka||wi&&8<wi&&11>=wi),Sd=" ",Nd=!1;function bd(n,r){switch(n){case"keyup":return Sk.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Cd(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var ys=!1;function bk(n,r){switch(n){case"compositionend":return Cd(r);case"keypress":return r.which!==32?null:(Nd=!0,Sd);case"textInput":return n=r.data,n===Sd&&Nd?null:n;default:return null}}function Ck(n,r){if(ys)return n==="compositionend"||!Ka&&bd(n,r)?(n=vd(),jr=za=$n=null,ys=!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 jd&&r.locale!=="ko"?null:r.data;default:return null}}var $k={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 $d(n){var r=n&&n.nodeName&&n.nodeName.toLowerCase();return r==="input"?!!$k[n.type]:r==="textarea"}function Td(n,r,l,u){qu(u),r=Ar(r,"onChange"),0<r.length&&(l=new Ba("onChange","change",null,l,u),n.push({event:l,listeners:r}))}var xi=null,ji=null;function Tk(n){Vd(n,0)}function Cr(n){var r=Ns(n);if(cr(r))return n}function Ek(n,r){if(n==="change")return r}var Ed=!1;if(h){var Va;if(h){var Ga="oninput"in document;if(!Ga){var Ad=document.createElement("div");Ad.setAttribute("oninput","return;"),Ga=typeof Ad.oninput=="function"}Va=Ga}else Va=!1;Ed=Va&&(!document.documentMode||9<document.documentMode)}function Id(){xi&&(xi.detachEvent("onpropertychange",Md),ji=xi=null)}function Md(n){if(n.propertyName==="value"&&Cr(ji)){var r=[];Td(r,ji,n,Ca(n)),Xu(Tk,r)}}function Ak(n,r,l){n==="focusin"?(Id(),xi=r,ji=l,xi.attachEvent("onpropertychange",Md)):n==="focusout"&&Id()}function Ik(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return Cr(ji)}function Mk(n,r){if(n==="click")return Cr(r)}function Rk(n,r){if(n==="input"||n==="change")return Cr(r)}function Lk(n,r){return n===r&&(n!==0||1/n===1/r)||n!==n&&r!==r}var Ft=typeof Object.is=="function"?Object.is:Lk;function Si(n,r){if(Ft(n,r))return!0;if(typeof n!="object"||n===null||typeof r!="object"||r===null)return!1;var l=Object.keys(n),u=Object.keys(r);if(l.length!==u.length)return!1;for(u=0;u<l.length;u++){var f=l[u];if(!m.call(r,f)||!Ft(n[f],r[f]))return!1}return!0}function Rd(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function Ld(n,r){var l=Rd(n);n=0;for(var u;l;){if(l.nodeType===3){if(u=n+l.textContent.length,n<=r&&u>=r)return{node:l,offset:r-n};n=u}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=Rd(l)}}function Od(n,r){return n&&r?n===r?!0:n&&n.nodeType===3?!1:r&&r.nodeType===3?Od(n,r.parentNode):"contains"in n?n.contains(r):n.compareDocumentPosition?!!(n.compareDocumentPosition(r)&16):!1:!1}function Pd(){for(var n=window,r=fs();r instanceof n.HTMLIFrameElement;){try{var l=typeof r.contentWindow.location.href=="string"}catch{l=!1}if(l)n=r.contentWindow;else break;r=fs(n.document)}return r}function qa(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 Ok(n){var r=Pd(),l=n.focusedElem,u=n.selectionRange;if(r!==l&&l&&l.ownerDocument&&Od(l.ownerDocument.documentElement,l)){if(u!==null&&qa(l)){if(r=u.start,n=u.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(u.start,f);u=u.end===void 0?g:Math.min(u.end,f),!n.extend&&g>u&&(f=u,u=g,g=f),f=Ld(l,g);var w=Ld(l,u);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>u?(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 Pk=h&&"documentMode"in document&&11>=document.documentMode,ws=null,Qa=null,Ni=null,Ya=!1;function _d(n,r,l){var u=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Ya||ws==null||ws!==fs(u)||(u=ws,"selectionStart"in u&&qa(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),Ni&&Si(Ni,u)||(Ni=u,u=Ar(Qa,"onSelect"),0<u.length&&(r=new Ba("onSelect","select",null,r,l),n.push({event:r,listeners:u}),r.target=ws)))}function $r(n,r){var l={};return l[n.toLowerCase()]=r.toLowerCase(),l["Webkit"+n]="webkit"+r,l["Moz"+n]="moz"+r,l}var xs={animationend:$r("Animation","AnimationEnd"),animationiteration:$r("Animation","AnimationIteration"),animationstart:$r("Animation","AnimationStart"),transitionend:$r("Transition","TransitionEnd")},Ja={},Dd={};h&&(Dd=document.createElement("div").style,"AnimationEvent"in window||(delete xs.animationend.animation,delete xs.animationiteration.animation,delete xs.animationstart.animation),"TransitionEvent"in window||delete xs.transitionend.transition);function Tr(n){if(Ja[n])return Ja[n];if(!xs[n])return n;var r=xs[n],l;for(l in r)if(r.hasOwnProperty(l)&&l in Dd)return Ja[n]=r[l];return n}var zd=Tr("animationend"),Bd=Tr("animationiteration"),Fd=Tr("animationstart"),Ud=Tr("transitionend"),Wd=new Map,Hd="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 Tn(n,r){Wd.set(n,r),c(r,[n])}for(var Xa=0;Xa<Hd.length;Xa++){var Za=Hd[Xa],_k=Za.toLowerCase(),Dk=Za[0].toUpperCase()+Za.slice(1);Tn(_k,"on"+Dk)}Tn(zd,"onAnimationEnd"),Tn(Bd,"onAnimationIteration"),Tn(Fd,"onAnimationStart"),Tn("dblclick","onDoubleClick"),Tn("focusin","onFocus"),Tn("focusout","onBlur"),Tn(Ud,"onTransitionEnd"),d("onMouseEnter",["mouseout","mouseover"]),d("onMouseLeave",["mouseout","mouseover"]),d("onPointerEnter",["pointerout","pointerover"]),d("onPointerLeave",["pointerout","pointerover"]),c("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),c("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),c("onBeforeInput",["compositionend","keypress","textInput","paste"]),c("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),c("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),c("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var bi="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(" "),zk=new Set("cancel close invalid load scroll toggle".split(" ").concat(bi));function Kd(n,r,l){var u=n.type||"unknown-event";n.currentTarget=l,_v(u,r,void 0,n),n.currentTarget=null}function Vd(n,r){r=(r&4)!==0;for(var l=0;l<n.length;l++){var u=n[l],f=u.event;u=u.listeners;e:{var g=void 0;if(r)for(var w=u.length-1;0<=w;w--){var N=u[w],$=N.instance,L=N.currentTarget;if(N=N.listener,$!==g&&f.isPropagationStopped())break e;Kd(f,N,L),g=$}else for(w=0;w<u.length;w++){if(N=u[w],$=N.instance,L=N.currentTarget,N=N.listener,$!==g&&f.isPropagationStopped())break e;Kd(f,N,L),g=$}}}if(hr)throw n=Aa,hr=!1,Aa=null,n}function Me(n,r){var l=r[al];l===void 0&&(l=r[al]=new Set);var u=n+"__bubble";l.has(u)||(Gd(r,n,2,!1),l.add(u))}function el(n,r,l){var u=0;r&&(u|=4),Gd(l,n,u,r)}var Er="_reactListening"+Math.random().toString(36).slice(2);function Ci(n){if(!n[Er]){n[Er]=!0,o.forEach(function(l){l!=="selectionchange"&&(zk.has(l)||el(l,!1,n),el(l,!0,n))});var r=n.nodeType===9?n:n.ownerDocument;r===null||r[Er]||(r[Er]=!0,el("selectionchange",!1,r))}}function Gd(n,r,l,u){switch(gd(r)){case 1:var f=Zv;break;case 4:f=ek;break;default:f=_a}l=f.bind(null,r,l,n),f=void 0,!Ea||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(f=!0),u?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 tl(n,r,l,u,f){var g=u;if((r&1)===0&&(r&2)===0&&u!==null)e:for(;;){if(u===null)return;var w=u.tag;if(w===3||w===4){var N=u.stateNode.containerInfo;if(N===f||N.nodeType===8&&N.parentNode===f)break;if(w===4)for(w=u.return;w!==null;){var $=w.tag;if(($===3||$===4)&&($=w.stateNode.containerInfo,$===f||$.nodeType===8&&$.parentNode===f))return;w=w.return}for(;N!==null;){if(w=Jn(N),w===null)return;if($=w.tag,$===5||$===6){u=g=w;continue e}N=N.parentNode}}u=u.return}Xu(function(){var L=g,F=Ca(l),H=[];e:{var z=Wd.get(n);if(z!==void 0){var Z=Ba,se=n;switch(n){case"keypress":if(Sr(l)===0)break e;case"keydown":case"keyup":Z=pk;break;case"focusin":se="focus",Z=Wa;break;case"focusout":se="blur",Z=Wa;break;case"beforeblur":case"afterblur":Z=Wa;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":Z=yd;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Z=sk;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Z=kk;break;case zd:case Bd:case Fd:Z=ok;break;case Ud:Z=wk;break;case"scroll":Z=tk;break;case"wheel":Z=jk;break;case"copy":case"cut":case"paste":Z=lk;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Z=xd}var re=(r&4)!==0,He=!re&&n==="scroll",A=re?z!==null?z+"Capture":null:z;re=[];for(var E=L,M;E!==null;){M=E;var q=M.stateNode;if(M.tag===5&&q!==null&&(M=q,A!==null&&(q=li(E,A),q!=null&&re.push($i(E,q,M)))),He)break;E=E.return}0<re.length&&(z=new Z(z,se,null,l,F),H.push({event:z,listeners:re}))}}if((r&7)===0){e:{if(z=n==="mouseover"||n==="pointerover",Z=n==="mouseout"||n==="pointerout",z&&l!==ba&&(se=l.relatedTarget||l.fromElement)&&(Jn(se)||se[hn]))break e;if((Z||z)&&(z=F.window===F?F:(z=F.ownerDocument)?z.defaultView||z.parentWindow:window,Z?(se=l.relatedTarget||l.toElement,Z=L,se=se?Jn(se):null,se!==null&&(He=Yn(se),se!==He||se.tag!==5&&se.tag!==6)&&(se=null)):(Z=null,se=L),Z!==se)){if(re=yd,q="onMouseLeave",A="onMouseEnter",E="mouse",(n==="pointerout"||n==="pointerover")&&(re=xd,q="onPointerLeave",A="onPointerEnter",E="pointer"),He=Z==null?z:Ns(Z),M=se==null?z:Ns(se),z=new re(q,E+"leave",Z,l,F),z.target=He,z.relatedTarget=M,q=null,Jn(F)===L&&(re=new re(A,E+"enter",se,l,F),re.target=M,re.relatedTarget=He,q=re),He=q,Z&&se)t:{for(re=Z,A=se,E=0,M=re;M;M=js(M))E++;for(M=0,q=A;q;q=js(q))M++;for(;0<E-M;)re=js(re),E--;for(;0<M-E;)A=js(A),M--;for(;E--;){if(re===A||A!==null&&re===A.alternate)break t;re=js(re),A=js(A)}re=null}else re=null;Z!==null&&qd(H,z,Z,re,!1),se!==null&&He!==null&&qd(H,He,se,re,!0)}}e:{if(z=L?Ns(L):window,Z=z.nodeName&&z.nodeName.toLowerCase(),Z==="select"||Z==="input"&&z.type==="file")var ae=Ek;else if($d(z))if(Ed)ae=Rk;else{ae=Ik;var de=Ak}else(Z=z.nodeName)&&Z.toLowerCase()==="input"&&(z.type==="checkbox"||z.type==="radio")&&(ae=Mk);if(ae&&(ae=ae(n,L))){Td(H,ae,l,F);break e}de&&de(n,z,L),n==="focusout"&&(de=z._wrapperState)&&de.controlled&&z.type==="number"&&wa(z,"number",z.value)}switch(de=L?Ns(L):window,n){case"focusin":($d(de)||de.contentEditable==="true")&&(ws=de,Qa=L,Ni=null);break;case"focusout":Ni=Qa=ws=null;break;case"mousedown":Ya=!0;break;case"contextmenu":case"mouseup":case"dragend":Ya=!1,_d(H,l,F);break;case"selectionchange":if(Pk)break;case"keydown":case"keyup":_d(H,l,F)}var he;if(Ka)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 ys?bd(n,l)&&(fe="onCompositionEnd"):n==="keydown"&&l.keyCode===229&&(fe="onCompositionStart");fe&&(jd&&l.locale!=="ko"&&(ys||fe!=="onCompositionStart"?fe==="onCompositionEnd"&&ys&&(he=vd()):($n=F,za="value"in $n?$n.value:$n.textContent,ys=!0)),de=Ar(L,fe),0<de.length&&(fe=new wd(fe,n,null,l,F),H.push({event:fe,listeners:de}),he?fe.data=he:(he=Cd(l),he!==null&&(fe.data=he)))),(he=Nk?bk(n,l):Ck(n,l))&&(L=Ar(L,"onBeforeInput"),0<L.length&&(F=new wd("onBeforeInput","beforeinput",null,l,F),H.push({event:F,listeners:L}),F.data=he))}Vd(H,r)})}function $i(n,r,l){return{instance:n,listener:r,currentTarget:l}}function Ar(n,r){for(var l=r+"Capture",u=[];n!==null;){var f=n,g=f.stateNode;f.tag===5&&g!==null&&(f=g,g=li(n,l),g!=null&&u.unshift($i(n,g,f)),g=li(n,r),g!=null&&u.push($i(n,g,f))),n=n.return}return u}function js(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5);return n||null}function qd(n,r,l,u,f){for(var g=r._reactName,w=[];l!==null&&l!==u;){var N=l,$=N.alternate,L=N.stateNode;if($!==null&&$===u)break;N.tag===5&&L!==null&&(N=L,f?($=li(l,g),$!=null&&w.unshift($i(l,$,N))):f||($=li(l,g),$!=null&&w.push($i(l,$,N)))),l=l.return}w.length!==0&&n.push({event:r,listeners:w})}var Bk=/\r\n?/g,Fk=/\u0000|\uFFFD/g;function Qd(n){return(typeof n=="string"?n:""+n).replace(Bk,`
38
+ `).replace(Fk,"")}function Ir(n,r,l){if(r=Qd(r),Qd(n)!==r&&l)throw Error(s(425))}function Mr(){}var nl=null,sl=null;function il(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 rl=typeof setTimeout=="function"?setTimeout:void 0,Uk=typeof clearTimeout=="function"?clearTimeout:void 0,Yd=typeof Promise=="function"?Promise:void 0,Wk=typeof queueMicrotask=="function"?queueMicrotask:typeof Yd<"u"?function(n){return Yd.resolve(null).then(n).catch(Hk)}:rl;function Hk(n){setTimeout(function(){throw n})}function ol(n,r){var l=r,u=0;do{var f=l.nextSibling;if(n.removeChild(l),f&&f.nodeType===8)if(l=f.data,l==="/$"){if(u===0){n.removeChild(f),vi(r);return}u--}else l!=="$"&&l!=="$?"&&l!=="$!"||u++;l=f}while(l);vi(r)}function En(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 Jd(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),Xt="__reactFiber$"+Ss,Ti="__reactProps$"+Ss,hn="__reactContainer$"+Ss,al="__reactEvents$"+Ss,Kk="__reactListeners$"+Ss,Vk="__reactHandles$"+Ss;function Jn(n){var r=n[Xt];if(r)return r;for(var l=n.parentNode;l;){if(r=l[hn]||l[Xt]){if(l=r.alternate,r.child!==null||l!==null&&l.child!==null)for(n=Jd(n);n!==null;){if(l=n[Xt])return l;n=Jd(n)}return r}n=l,l=n.parentNode}return null}function Ei(n){return n=n[Xt]||n[hn],!n||n.tag!==5&&n.tag!==6&&n.tag!==13&&n.tag!==3?null:n}function Ns(n){if(n.tag===5||n.tag===6)return n.stateNode;throw Error(s(33))}function Rr(n){return n[Ti]||null}var ll=[],bs=-1;function An(n){return{current:n}}function Re(n){0>bs||(n.current=ll[bs],ll[bs]=null,bs--)}function Ee(n,r){bs++,ll[bs]=n.current,n.current=r}var In={},ot=An(In),gt=An(!1),Xn=In;function Cs(n,r){var l=n.type.contextTypes;if(!l)return In;var u=n.stateNode;if(u&&u.__reactInternalMemoizedUnmaskedChildContext===r)return u.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in l)f[g]=r[g];return u&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=r,n.__reactInternalMemoizedMaskedChildContext=f),f}function vt(n){return n=n.childContextTypes,n!=null}function Lr(){Re(gt),Re(ot)}function Xd(n,r,l){if(ot.current!==In)throw Error(s(168));Ee(ot,r),Ee(gt,l)}function Zd(n,r,l){var u=n.stateNode;if(r=r.childContextTypes,typeof u.getChildContext!="function")return l;u=u.getChildContext();for(var f in u)if(!(f in r))throw Error(s(108,pe(n)||"Unknown",f));return B({},l,u)}function Or(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||In,Xn=ot.current,Ee(ot,n),Ee(gt,gt.current),!0}function eh(n,r,l){var u=n.stateNode;if(!u)throw Error(s(169));l?(n=Zd(n,r,Xn),u.__reactInternalMemoizedMergedChildContext=n,Re(gt),Re(ot),Ee(ot,n)):Re(gt),Ee(gt,l)}var fn=null,Pr=!1,cl=!1;function th(n){fn===null?fn=[n]:fn.push(n)}function Gk(n){Pr=!0,th(n)}function Mn(){if(!cl&&fn!==null){cl=!0;var n=0,r=Te;try{var l=fn;for(Te=1;n<l.length;n++){var u=l[n];do u=u(!0);while(u!==null)}fn=null,Pr=!1}catch(f){throw fn!==null&&(fn=fn.slice(n+1)),sd(Ia,Mn),f}finally{Te=r,cl=!1}}return null}var $s=[],Ts=0,_r=null,Dr=0,At=[],It=0,Zn=null,mn=1,pn="";function es(n,r){$s[Ts++]=Dr,$s[Ts++]=_r,_r=n,Dr=r}function nh(n,r,l){At[It++]=mn,At[It++]=pn,At[It++]=Zn,Zn=n;var u=mn;n=pn;var f=32-Bt(u)-1;u&=~(1<<f),l+=1;var g=32-Bt(r)+f;if(30<g){var w=f-f%5;g=(u&(1<<w)-1).toString(32),u>>=w,f-=w,mn=1<<32-Bt(r)+f|l<<f|u,pn=g+n}else mn=1<<g|l<<f|u,pn=n}function ul(n){n.return!==null&&(es(n,1),nh(n,1,0))}function dl(n){for(;n===_r;)_r=$s[--Ts],$s[Ts]=null,Dr=$s[--Ts],$s[Ts]=null;for(;n===Zn;)Zn=At[--It],At[It]=null,pn=At[--It],At[It]=null,mn=At[--It],At[It]=null}var Ct=null,$t=null,Oe=!1,Ut=null;function sh(n,r){var l=Ot(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 ih(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=En(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:mn,overflow:pn}:null,n.memoizedState={dehydrated:r,treeContext:l,retryLane:1073741824},l=Ot(18,null,null,0),l.stateNode=r,l.return=n,n.child=l,Ct=n,$t=null,!0):!1;default:return!1}}function hl(n){return(n.mode&1)!==0&&(n.flags&128)===0}function fl(n){if(Oe){var r=$t;if(r){var l=r;if(!ih(n,r)){if(hl(n))throw Error(s(418));r=En(l.nextSibling);var u=Ct;r&&ih(n,r)?sh(u,l):(n.flags=n.flags&-4097|2,Oe=!1,Ct=n)}}else{if(hl(n))throw Error(s(418));n.flags=n.flags&-4097|2,Oe=!1,Ct=n}}}function rh(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 rh(n),Oe=!0,!1;var r;if((r=n.tag!==3)&&!(r=n.tag!==5)&&(r=n.type,r=r!=="head"&&r!=="body"&&!il(n.type,n.memoizedProps)),r&&(r=$t)){if(hl(n))throw oh(),Error(s(418));for(;r;)sh(n,r),r=En(r.nextSibling)}if(rh(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=En(n.nextSibling);break e}r--}else l!=="$"&&l!=="$!"&&l!=="$?"||r++}n=n.nextSibling}$t=null}}else $t=Ct?En(n.stateNode.nextSibling):null;return!0}function oh(){for(var n=$t;n;)n=En(n.nextSibling)}function Es(){$t=Ct=null,Oe=!1}function ml(n){Ut===null?Ut=[n]:Ut.push(n)}var qk=U.ReactCurrentBatchConfig;function Ai(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 u=l.stateNode}if(!u)throw Error(s(147,n));var f=u,g=""+n;return r!==null&&r.ref!==null&&typeof r.ref=="function"&&r.ref._stringRef===g?r.ref:(r=function(w){var N=f.refs;w===null?delete N[g]:N[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 ah(n){var r=n._init;return r(n._payload)}function lh(n){function r(A,E){if(n){var M=A.deletions;M===null?(A.deletions=[E],A.flags|=16):M.push(E)}}function l(A,E){if(!n)return null;for(;E!==null;)r(A,E),E=E.sibling;return null}function u(A,E){for(A=new Map;E!==null;)E.key!==null?A.set(E.key,E):A.set(E.index,E),E=E.sibling;return A}function f(A,E){return A=Bn(A,E),A.index=0,A.sibling=null,A}function g(A,E,M){return A.index=M,n?(M=A.alternate,M!==null?(M=M.index,M<E?(A.flags|=2,E):M):(A.flags|=2,E)):(A.flags|=1048576,E)}function w(A){return n&&A.alternate===null&&(A.flags|=2),A}function N(A,E,M,q){return E===null||E.tag!==6?(E=rc(M,A.mode,q),E.return=A,E):(E=f(E,M),E.return=A,E)}function $(A,E,M,q){var ae=M.type;return ae===W?F(A,E,M.props.children,q,M.key):E!==null&&(E.elementType===ae||typeof ae=="object"&&ae!==null&&ae.$$typeof===le&&ah(ae)===E.type)?(q=f(E,M.props),q.ref=Ai(A,E,M),q.return=A,q):(q=uo(M.type,M.key,M.props,null,A.mode,q),q.ref=Ai(A,E,M),q.return=A,q)}function L(A,E,M,q){return E===null||E.tag!==4||E.stateNode.containerInfo!==M.containerInfo||E.stateNode.implementation!==M.implementation?(E=oc(M,A.mode,q),E.return=A,E):(E=f(E,M.children||[]),E.return=A,E)}function F(A,E,M,q,ae){return E===null||E.tag!==7?(E=ls(M,A.mode,q,ae),E.return=A,E):(E=f(E,M),E.return=A,E)}function H(A,E,M){if(typeof E=="string"&&E!==""||typeof E=="number")return E=rc(""+E,A.mode,M),E.return=A,E;if(typeof E=="object"&&E!==null){switch(E.$$typeof){case X:return M=uo(E.type,E.key,E.props,null,A.mode,M),M.ref=Ai(A,null,E),M.return=A,M;case Q:return E=oc(E,A.mode,M),E.return=A,E;case le:var q=E._init;return H(A,q(E._payload),M)}if(ri(E)||Y(E))return E=ls(E,A.mode,M,null),E.return=A,E;Br(A,E)}return null}function z(A,E,M,q){var ae=E!==null?E.key:null;if(typeof M=="string"&&M!==""||typeof M=="number")return ae!==null?null:N(A,E,""+M,q);if(typeof M=="object"&&M!==null){switch(M.$$typeof){case X:return M.key===ae?$(A,E,M,q):null;case Q:return M.key===ae?L(A,E,M,q):null;case le:return ae=M._init,z(A,E,ae(M._payload),q)}if(ri(M)||Y(M))return ae!==null?null:F(A,E,M,q,null);Br(A,M)}return null}function Z(A,E,M,q,ae){if(typeof q=="string"&&q!==""||typeof q=="number")return A=A.get(M)||null,N(E,A,""+q,ae);if(typeof q=="object"&&q!==null){switch(q.$$typeof){case X:return A=A.get(q.key===null?M:q.key)||null,$(E,A,q,ae);case Q:return A=A.get(q.key===null?M:q.key)||null,L(E,A,q,ae);case le:var de=q._init;return Z(A,E,M,de(q._payload),ae)}if(ri(q)||Y(q))return A=A.get(M)||null,F(E,A,q,ae,null);Br(E,q)}return null}function se(A,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(A,he,M[fe],q);if(be===null){he===null&&(he=nt);break}n&&he&&be.alternate===null&&r(A,he),E=g(be,E,fe),de===null?ae=be:de.sibling=be,de=be,he=nt}if(fe===M.length)return l(A,he),Oe&&es(A,fe),ae;if(he===null){for(;fe<M.length;fe++)he=H(A,M[fe],q),he!==null&&(E=g(he,E,fe),de===null?ae=he:de.sibling=he,de=he);return Oe&&es(A,fe),ae}for(he=u(A,he);fe<M.length;fe++)nt=Z(he,A,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(Fn){return r(A,Fn)}),Oe&&es(A,fe),ae}function re(A,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 Fn=z(A,he,be.value,q);if(Fn===null){he===null&&(he=nt);break}n&&he&&Fn.alternate===null&&r(A,he),E=g(Fn,E,fe),de===null?ae=Fn:de.sibling=Fn,de=Fn,he=nt}if(be.done)return l(A,he),Oe&&es(A,fe),ae;if(he===null){for(;!be.done;fe++,be=M.next())be=H(A,be.value,q),be!==null&&(E=g(be,E,fe),de===null?ae=be:de.sibling=be,de=be);return Oe&&es(A,fe),ae}for(he=u(A,he);!be.done;fe++,be=M.next())be=Z(he,A,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($y){return r(A,$y)}),Oe&&es(A,fe),ae}function He(A,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 X: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(A,de.sibling),E=f(de,M.props.children),E.return=A,A=E;break e}}else if(de.elementType===ae||typeof ae=="object"&&ae!==null&&ae.$$typeof===le&&ah(ae)===de.type){l(A,de.sibling),E=f(de,M.props),E.ref=Ai(A,de,M),E.return=A,A=E;break e}l(A,de);break}else r(A,de);de=de.sibling}M.type===W?(E=ls(M.props.children,A.mode,q,M.key),E.return=A,A=E):(q=uo(M.type,M.key,M.props,null,A.mode,q),q.ref=Ai(A,E,M),q.return=A,A=q)}return w(A);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(A,E.sibling),E=f(E,M.children||[]),E.return=A,A=E;break e}else{l(A,E);break}else r(A,E);E=E.sibling}E=oc(M,A.mode,q),E.return=A,A=E}return w(A);case le:return de=M._init,He(A,E,de(M._payload),q)}if(ri(M))return se(A,E,M,q);if(Y(M))return re(A,E,M,q);Br(A,M)}return typeof M=="string"&&M!==""||typeof M=="number"?(M=""+M,E!==null&&E.tag===6?(l(A,E.sibling),E=f(E,M),E.return=A,A=E):(l(A,E),E=rc(M,A.mode,q),E.return=A,A=E),w(A)):l(A,E)}return He}var As=lh(!0),ch=lh(!1),Fr=An(null),Ur=null,Is=null,pl=null;function gl(){pl=Is=Ur=null}function vl(n){var r=Fr.current;Re(Fr),n._currentValue=r}function kl(n,r,l){for(;n!==null;){var u=n.alternate;if((n.childLanes&r)!==r?(n.childLanes|=r,u!==null&&(u.childLanes|=r)):u!==null&&(u.childLanes&r)!==r&&(u.childLanes|=r),n===l)break;n=n.return}}function Ms(n,r){Ur=n,pl=Is=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(pl!==n)if(n={context:n,memoizedValue:r,next:null},Is===null){if(Ur===null)throw Error(s(308));Is=n,Ur.dependencies={lanes:0,firstContext:n}}else Is=Is.next=n;return r}var ts=null;function yl(n){ts===null?ts=[n]:ts.push(n)}function uh(n,r,l,u){var f=r.interleaved;return f===null?(l.next=l,yl(r)):(l.next=f.next,f.next=l),r.interleaved=l,gn(n,u)}function gn(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 Rn=!1;function wl(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function dh(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 vn(n,r){return{eventTime:n,lane:r,tag:0,payload:null,callback:null,next:null}}function Ln(n,r,l){var u=n.updateQueue;if(u===null)return null;if(u=u.shared,(Ne&2)!==0){var f=u.pending;return f===null?r.next=r:(r.next=f.next,f.next=r),u.pending=r,gn(n,l)}return f=u.interleaved,f===null?(r.next=r,yl(u)):(r.next=f.next,f.next=r),u.interleaved=r,gn(n,l)}function Wr(n,r,l){if(r=r.updateQueue,r!==null&&(r=r.shared,(l&4194240)!==0)){var u=r.lanes;u&=n.pendingLanes,l|=u,r.lanes=l,La(n,l)}}function hh(n,r){var l=n.updateQueue,u=n.alternate;if(u!==null&&(u=u.updateQueue,l===u)){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:u.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:u.shared,effects:u.effects},n.updateQueue=l;return}n=l.lastBaseUpdate,n===null?l.firstBaseUpdate=r:n.next=r,l.lastBaseUpdate=r}function Hr(n,r,l,u){var f=n.updateQueue;Rn=!1;var g=f.firstBaseUpdate,w=f.lastBaseUpdate,N=f.shared.pending;if(N!==null){f.shared.pending=null;var $=N,L=$.next;$.next=null,w===null?g=L:w.next=L,w=$;var F=n.alternate;F!==null&&(F=F.updateQueue,N=F.lastBaseUpdate,N!==w&&(N===null?F.firstBaseUpdate=L:N.next=L,F.lastBaseUpdate=$))}if(g!==null){var H=f.baseState;w=0,F=L=$=null,N=g;do{var z=N.lane,Z=N.eventTime;if((u&z)===z){F!==null&&(F=F.next={eventTime:Z,lane:0,tag:N.tag,payload:N.payload,callback:N.callback,next:null});e:{var se=n,re=N;switch(z=r,Z=l,re.tag){case 1:if(se=re.payload,typeof se=="function"){H=se.call(Z,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(Z,H,z):se,z==null)break e;H=B({},H,z);break e;case 2:Rn=!0}}N.callback!==null&&N.lane!==0&&(n.flags|=64,z=f.effects,z===null?f.effects=[N]:z.push(N))}else Z={eventTime:Z,lane:z,tag:N.tag,payload:N.payload,callback:N.callback,next:null},F===null?(L=F=Z,$=H):F=F.next=Z,w|=z;if(N=N.next,N===null){if(N=f.shared.pending,N===null)break;z=N,N=z.next,z.next=null,f.lastBaseUpdate=z,f.shared.pending=null}}while(!0);if(F===null&&($=H),f.baseState=$,f.firstBaseUpdate=L,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 fh(n,r,l){if(n=r.effects,r.effects=null,n!==null)for(r=0;r<n.length;r++){var u=n[r],f=u.callback;if(f!==null){if(u.callback=null,u=l,typeof f!="function")throw Error(s(191,f));f.call(u)}}}var Ii={},Zt=An(Ii),Mi=An(Ii),Ri=An(Ii);function ns(n){if(n===Ii)throw Error(s(174));return n}function xl(n,r){switch(Ee(Ri,r),Ee(Mi,n),Ee(Zt,Ii),n=r.nodeType,n){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:ja(null,"");break;default:n=n===8?r.parentNode:r,r=n.namespaceURI||null,n=n.tagName,r=ja(r,n)}Re(Zt),Ee(Zt,r)}function Rs(){Re(Zt),Re(Mi),Re(Ri)}function mh(n){ns(Ri.current);var r=ns(Zt.current),l=ja(r,n.type);r!==l&&(Ee(Mi,n),Ee(Zt,l))}function jl(n){Mi.current===n&&(Re(Zt),Re(Mi))}var _e=An(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 Sl=[];function Nl(){for(var n=0;n<Sl.length;n++)Sl[n]._workInProgressVersionPrimary=null;Sl.length=0}var Vr=U.ReactCurrentDispatcher,bl=U.ReactCurrentBatchConfig,ss=0,De=null,Je=null,et=null,Gr=!1,Li=!1,Oi=0,Qk=0;function at(){throw Error(s(321))}function Cl(n,r){if(r===null)return!1;for(var l=0;l<r.length&&l<n.length;l++)if(!Ft(n[l],r[l]))return!1;return!0}function $l(n,r,l,u,f,g){if(ss=g,De=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,Vr.current=n===null||n.memoizedState===null?Zk:ey,n=l(u,f),Li){g=0;do{if(Li=!1,Oi=0,25<=g)throw Error(s(301));g+=1,et=Je=null,r.updateQueue=null,Vr.current=ty,n=l(u,f)}while(Li)}if(Vr.current=Yr,r=Je!==null&&Je.next!==null,ss=0,et=Je=De=null,Gr=!1,r)throw Error(s(300));return n}function Tl(){var n=Oi!==0;return Oi=0,n}function en(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return et===null?De.memoizedState=et=n:et=et.next=n,et}function Rt(){if(Je===null){var n=De.alternate;n=n!==null?n.memoizedState:null}else n=Je.next;var r=et===null?De.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?De.memoizedState=et=n:et=et.next=n}return et}function Pi(n,r){return typeof r=="function"?r(n):r}function El(n){var r=Rt(),l=r.queue;if(l===null)throw Error(s(311));l.lastRenderedReducer=n;var u=Je,f=u.baseQueue,g=l.pending;if(g!==null){if(f!==null){var w=f.next;f.next=g.next,g.next=w}u.baseQueue=f=g,l.pending=null}if(f!==null){g=f.next,u=u.baseState;var N=w=null,$=null,L=g;do{var F=L.lane;if((ss&F)===F)$!==null&&($=$.next={lane:0,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null}),u=L.hasEagerState?L.eagerState:n(u,L.action);else{var H={lane:F,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null};$===null?(N=$=H,w=u):$=$.next=H,De.lanes|=F,is|=F}L=L.next}while(L!==null&&L!==g);$===null?w=u:$.next=N,Ft(u,r.memoizedState)||(kt=!0),r.memoizedState=u,r.baseState=w,r.baseQueue=$,l.lastRenderedState=u}if(n=l.interleaved,n!==null){f=n;do g=f.lane,De.lanes|=g,is|=g,f=f.next;while(f!==n)}else f===null&&(l.lanes=0);return[r.memoizedState,l.dispatch]}function Al(n){var r=Rt(),l=r.queue;if(l===null)throw Error(s(311));l.lastRenderedReducer=n;var u=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);Ft(g,r.memoizedState)||(kt=!0),r.memoizedState=g,r.baseQueue===null&&(r.baseState=g),l.lastRenderedState=g}return[g,u]}function ph(){}function gh(n,r){var l=De,u=Rt(),f=r(),g=!Ft(u.memoizedState,f);if(g&&(u.memoizedState=f,kt=!0),u=u.queue,Il(yh.bind(null,l,u,n),[n]),u.getSnapshot!==r||g||et!==null&&et.memoizedState.tag&1){if(l.flags|=2048,_i(9,kh.bind(null,l,u,f,r),void 0,null),tt===null)throw Error(s(349));(ss&30)!==0||vh(l,r,f)}return f}function vh(n,r,l){n.flags|=16384,n={getSnapshot:r,value:l},r=De.updateQueue,r===null?(r={lastEffect:null,stores:null},De.updateQueue=r,r.stores=[n]):(l=r.stores,l===null?r.stores=[n]:l.push(n))}function kh(n,r,l,u){r.value=l,r.getSnapshot=u,wh(r)&&xh(n)}function yh(n,r,l){return l(function(){wh(r)&&xh(n)})}function wh(n){var r=n.getSnapshot;n=n.value;try{var l=r();return!Ft(n,l)}catch{return!0}}function xh(n){var r=gn(n,1);r!==null&&Vt(r,n,1,-1)}function jh(n){var r=en();return typeof n=="function"&&(n=n()),r.memoizedState=r.baseState=n,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Pi,lastRenderedState:n},r.queue=n,n=n.dispatch=Xk.bind(null,De,n),[r.memoizedState,n]}function _i(n,r,l,u){return n={tag:n,create:r,destroy:l,deps:u,next:null},r=De.updateQueue,r===null?(r={lastEffect:null,stores:null},De.updateQueue=r,r.lastEffect=n.next=n):(l=r.lastEffect,l===null?r.lastEffect=n.next=n:(u=l.next,l.next=n,n.next=u,r.lastEffect=n)),n}function Sh(){return Rt().memoizedState}function qr(n,r,l,u){var f=en();De.flags|=n,f.memoizedState=_i(1|r,l,void 0,u===void 0?null:u)}function Qr(n,r,l,u){var f=Rt();u=u===void 0?null:u;var g=void 0;if(Je!==null){var w=Je.memoizedState;if(g=w.destroy,u!==null&&Cl(u,w.deps)){f.memoizedState=_i(r,l,g,u);return}}De.flags|=n,f.memoizedState=_i(1|r,l,g,u)}function Nh(n,r){return qr(8390656,8,n,r)}function Il(n,r){return Qr(2048,8,n,r)}function bh(n,r){return Qr(4,2,n,r)}function Ch(n,r){return Qr(4,4,n,r)}function $h(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 Th(n,r,l){return l=l!=null?l.concat([n]):null,Qr(4,4,$h.bind(null,r,n),l)}function Ml(){}function Eh(n,r){var l=Rt();r=r===void 0?null:r;var u=l.memoizedState;return u!==null&&r!==null&&Cl(r,u[1])?u[0]:(l.memoizedState=[n,r],n)}function Ah(n,r){var l=Rt();r=r===void 0?null:r;var u=l.memoizedState;return u!==null&&r!==null&&Cl(r,u[1])?u[0]:(n=n(),l.memoizedState=[n,r],n)}function Ih(n,r,l){return(ss&21)===0?(n.baseState&&(n.baseState=!1,kt=!0),n.memoizedState=l):(Ft(l,r)||(l=ad(),De.lanes|=l,is|=l,n.baseState=!0),r)}function Yk(n,r){var l=Te;Te=l!==0&&4>l?l:4,n(!0);var u=bl.transition;bl.transition={};try{n(!1),r()}finally{Te=l,bl.transition=u}}function Mh(){return Rt().memoizedState}function Jk(n,r,l){var u=Dn(n);if(l={lane:u,action:l,hasEagerState:!1,eagerState:null,next:null},Rh(n))Lh(r,l);else if(l=uh(n,r,l,u),l!==null){var f=ft();Vt(l,n,u,f),Oh(l,r,u)}}function Xk(n,r,l){var u=Dn(n),f={lane:u,action:l,hasEagerState:!1,eagerState:null,next:null};if(Rh(n))Lh(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,N=g(w,l);if(f.hasEagerState=!0,f.eagerState=N,Ft(N,w)){var $=r.interleaved;$===null?(f.next=f,yl(r)):(f.next=$.next,$.next=f),r.interleaved=f;return}}catch{}finally{}l=uh(n,r,f,u),l!==null&&(f=ft(),Vt(l,n,u,f),Oh(l,r,u))}}function Rh(n){var r=n.alternate;return n===De||r!==null&&r===De}function Lh(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 Oh(n,r,l){if((l&4194240)!==0){var u=r.lanes;u&=n.pendingLanes,l|=u,r.lanes=l,La(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},Zk={readContext:Mt,useCallback:function(n,r){return en().memoizedState=[n,r===void 0?null:r],n},useContext:Mt,useEffect:Nh,useImperativeHandle:function(n,r,l){return l=l!=null?l.concat([n]):null,qr(4194308,4,$h.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=en();return r=r===void 0?null:r,n=n(),l.memoizedState=[n,r],n},useReducer:function(n,r,l){var u=en();return r=l!==void 0?l(r):r,u.memoizedState=u.baseState=r,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:r},u.queue=n,n=n.dispatch=Jk.bind(null,De,n),[u.memoizedState,n]},useRef:function(n){var r=en();return n={current:n},r.memoizedState=n},useState:jh,useDebugValue:Ml,useDeferredValue:function(n){return en().memoizedState=n},useTransition:function(){var n=jh(!1),r=n[0];return n=Yk.bind(null,n[1]),en().memoizedState=n,[r,n]},useMutableSource:function(){},useSyncExternalStore:function(n,r,l){var u=De,f=en();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||vh(u,r,l)}f.memoizedState=l;var g={value:l,getSnapshot:r};return f.queue=g,Nh(yh.bind(null,u,g,n),[n]),u.flags|=2048,_i(9,kh.bind(null,u,g,l,r),void 0,null),l},useId:function(){var n=en(),r=tt.identifierPrefix;if(Oe){var l=pn,u=mn;l=(u&~(1<<32-Bt(u)-1)).toString(32)+l,r=":"+r+"R"+l,l=Oi++,0<l&&(r+="H"+l.toString(32)),r+=":"}else l=Qk++,r=":"+r+"r"+l.toString(32)+":";return n.memoizedState=r},unstable_isNewReconciler:!1},ey={readContext:Mt,useCallback:Eh,useContext:Mt,useEffect:Il,useImperativeHandle:Th,useInsertionEffect:bh,useLayoutEffect:Ch,useMemo:Ah,useReducer:El,useRef:Sh,useState:function(){return El(Pi)},useDebugValue:Ml,useDeferredValue:function(n){var r=Rt();return Ih(r,Je.memoizedState,n)},useTransition:function(){var n=El(Pi)[0],r=Rt().memoizedState;return[n,r]},useMutableSource:ph,useSyncExternalStore:gh,useId:Mh,unstable_isNewReconciler:!1},ty={readContext:Mt,useCallback:Eh,useContext:Mt,useEffect:Il,useImperativeHandle:Th,useInsertionEffect:bh,useLayoutEffect:Ch,useMemo:Ah,useReducer:Al,useRef:Sh,useState:function(){return Al(Pi)},useDebugValue:Ml,useDeferredValue:function(n){var r=Rt();return Je===null?r.memoizedState=n:Ih(r,Je.memoizedState,n)},useTransition:function(){var n=Al(Pi)[0],r=Rt().memoizedState;return[n,r]},useMutableSource:ph,useSyncExternalStore:gh,useId:Mh,unstable_isNewReconciler:!1};function Wt(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 Rl(n,r,l,u){r=n.memoizedState,l=l(u,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 u=ft(),f=Dn(n),g=vn(u,f);g.payload=r,l!=null&&(g.callback=l),r=Ln(n,g,f),r!==null&&(Vt(r,n,f,u),Wr(r,n,f))},enqueueReplaceState:function(n,r,l){n=n._reactInternals;var u=ft(),f=Dn(n),g=vn(u,f);g.tag=1,g.payload=r,l!=null&&(g.callback=l),r=Ln(n,g,f),r!==null&&(Vt(r,n,f,u),Wr(r,n,f))},enqueueForceUpdate:function(n,r){n=n._reactInternals;var l=ft(),u=Dn(n),f=vn(l,u);f.tag=2,r!=null&&(f.callback=r),r=Ln(n,f,u),r!==null&&(Vt(r,n,u,l),Wr(r,n,u))}};function Ph(n,r,l,u,f,g,w){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(u,g,w):r.prototype&&r.prototype.isPureReactComponent?!Si(l,u)||!Si(f,g):!0}function _h(n,r,l){var u=!1,f=In,g=r.contextType;return typeof g=="object"&&g!==null?g=Mt(g):(f=vt(r)?Xn:ot.current,u=r.contextTypes,g=(u=u!=null)?Cs(n,f):In),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,u&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=f,n.__reactInternalMemoizedMaskedChildContext=g),r}function Dh(n,r,l,u){n=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(l,u),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(l,u),r.state!==n&&Jr.enqueueReplaceState(r,r.state,null)}function Ll(n,r,l,u){var f=n.stateNode;f.props=l,f.state=n.memoizedState,f.refs={},wl(n);var g=r.contextType;typeof g=="object"&&g!==null?f.context=Mt(g):(g=vt(r)?Xn:ot.current,f.context=Cs(n,g)),f.state=n.memoizedState,g=r.getDerivedStateFromProps,typeof g=="function"&&(Rl(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,u),f.state=n.memoizedState),typeof f.componentDidMount=="function"&&(n.flags|=4194308)}function Ls(n,r){try{var l="",u=r;do l+=ke(u),u=u.return;while(u);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 Ol(n,r,l){return{value:n,source:null,stack:l??null,digest:r??null}}function Pl(n,r){try{console.error(r.value)}catch(l){setTimeout(function(){throw l})}}var ny=typeof WeakMap=="function"?WeakMap:Map;function zh(n,r,l){l=vn(-1,l),l.tag=3,l.payload={element:null};var u=r.value;return l.callback=function(){io||(io=!0,Jl=u),Pl(n,r)},l}function Bh(n,r,l){l=vn(-1,l),l.tag=3;var u=n.type.getDerivedStateFromError;if(typeof u=="function"){var f=r.value;l.payload=function(){return u(f)},l.callback=function(){Pl(n,r)}}var g=n.stateNode;return g!==null&&typeof g.componentDidCatch=="function"&&(l.callback=function(){Pl(n,r),typeof u!="function"&&(Pn===null?Pn=new Set([this]):Pn.add(this));var w=r.stack;this.componentDidCatch(r.value,{componentStack:w!==null?w:""})}),l}function Fh(n,r,l){var u=n.pingCache;if(u===null){u=n.pingCache=new ny;var f=new Set;u.set(r,f)}else f=u.get(r),f===void 0&&(f=new Set,u.set(r,f));f.has(l)||(f.add(l),n=gy.bind(null,n,r,l),r.then(n,n))}function Uh(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 Wh(n,r,l,u,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=vn(-1,1),r.tag=2,Ln(l,r,1))),l.lanes|=1),n):(n.flags|=65536,n.lanes=f,n)}var sy=U.ReactCurrentOwner,kt=!1;function ht(n,r,l,u){r.child=n===null?ch(r,null,l,u):As(r,n.child,l,u)}function Hh(n,r,l,u,f){l=l.render;var g=r.ref;return Ms(r,f),u=$l(n,r,l,u,g,f),l=Tl(),n!==null&&!kt?(r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~f,kn(n,r,f)):(Oe&&l&&ul(r),r.flags|=1,ht(n,r,u,f),r.child)}function Kh(n,r,l,u,f){if(n===null){var g=l.type;return typeof g=="function"&&!ic(g)&&g.defaultProps===void 0&&l.compare===null&&l.defaultProps===void 0?(r.tag=15,r.type=g,Vh(n,r,g,u,f)):(n=uo(l.type,null,u,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,u)&&n.ref===r.ref)return kn(n,r,f)}return r.flags|=1,n=Bn(g,u),n.ref=r.ref,n.return=r,r.child=n}function Vh(n,r,l,u,f){if(n!==null){var g=n.memoizedProps;if(Si(g,u)&&n.ref===r.ref)if(kt=!1,r.pendingProps=u=g,(n.lanes&f)!==0)(n.flags&131072)!==0&&(kt=!0);else return r.lanes=n.lanes,kn(n,r,f)}return _l(n,r,l,u,f)}function Gh(n,r,l){var u=r.pendingProps,f=u.children,g=n!==null?n.memoizedState:null;if(u.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ee(Ps,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(Ps,Tt),Tt|=n,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},u=g!==null?g.baseLanes:l,Ee(Ps,Tt),Tt|=u}else g!==null?(u=g.baseLanes|l,r.memoizedState=null):u=l,Ee(Ps,Tt),Tt|=u;return ht(n,r,f,l),r.child}function qh(n,r){var l=r.ref;(n===null&&l!==null||n!==null&&n.ref!==l)&&(r.flags|=512,r.flags|=2097152)}function _l(n,r,l,u,f){var g=vt(l)?Xn:ot.current;return g=Cs(r,g),Ms(r,f),l=$l(n,r,l,u,g,f),u=Tl(),n!==null&&!kt?(r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~f,kn(n,r,f)):(Oe&&u&&ul(r),r.flags|=1,ht(n,r,l,f),r.child)}function Qh(n,r,l,u,f){if(vt(l)){var g=!0;Or(r)}else g=!1;if(Ms(r,f),r.stateNode===null)Zr(n,r),_h(r,l,u),Ll(r,l,u,f),u=!0;else if(n===null){var w=r.stateNode,N=r.memoizedProps;w.props=N;var $=w.context,L=l.contextType;typeof L=="object"&&L!==null?L=Mt(L):(L=vt(l)?Xn:ot.current,L=Cs(r,L));var F=l.getDerivedStateFromProps,H=typeof F=="function"||typeof w.getSnapshotBeforeUpdate=="function";H||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(N!==u||$!==L)&&Dh(r,w,u,L),Rn=!1;var z=r.memoizedState;w.state=z,Hr(r,u,w,f),$=r.memoizedState,N!==u||z!==$||gt.current||Rn?(typeof F=="function"&&(Rl(r,l,F,u),$=r.memoizedState),(N=Rn||Ph(r,l,N,u,z,$,L))?(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=u,r.memoizedState=$),w.props=u,w.state=$,w.context=L,u=N):(typeof w.componentDidMount=="function"&&(r.flags|=4194308),u=!1)}else{w=r.stateNode,dh(n,r),N=r.memoizedProps,L=r.type===r.elementType?N:Wt(r.type,N),w.props=L,H=r.pendingProps,z=w.context,$=l.contextType,typeof $=="object"&&$!==null?$=Mt($):($=vt(l)?Xn:ot.current,$=Cs(r,$));var Z=l.getDerivedStateFromProps;(F=typeof Z=="function"||typeof w.getSnapshotBeforeUpdate=="function")||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(N!==H||z!==$)&&Dh(r,w,u,$),Rn=!1,z=r.memoizedState,w.state=z,Hr(r,u,w,f);var se=r.memoizedState;N!==H||z!==se||gt.current||Rn?(typeof Z=="function"&&(Rl(r,l,Z,u),se=r.memoizedState),(L=Rn||Ph(r,l,L,u,z,se,$)||!1)?(F||typeof w.UNSAFE_componentWillUpdate!="function"&&typeof w.componentWillUpdate!="function"||(typeof w.componentWillUpdate=="function"&&w.componentWillUpdate(u,se,$),typeof w.UNSAFE_componentWillUpdate=="function"&&w.UNSAFE_componentWillUpdate(u,se,$)),typeof w.componentDidUpdate=="function"&&(r.flags|=4),typeof w.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof w.componentDidUpdate!="function"||N===n.memoizedProps&&z===n.memoizedState||(r.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||N===n.memoizedProps&&z===n.memoizedState||(r.flags|=1024),r.memoizedProps=u,r.memoizedState=se),w.props=u,w.state=se,w.context=$,u=L):(typeof w.componentDidUpdate!="function"||N===n.memoizedProps&&z===n.memoizedState||(r.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||N===n.memoizedProps&&z===n.memoizedState||(r.flags|=1024),u=!1)}return Dl(n,r,l,u,g,f)}function Dl(n,r,l,u,f,g){qh(n,r);var w=(r.flags&128)!==0;if(!u&&!w)return f&&eh(r,l,!1),kn(n,r,g);u=r.stateNode,sy.current=r;var N=w&&typeof l.getDerivedStateFromError!="function"?null:u.render();return r.flags|=1,n!==null&&w?(r.child=As(r,n.child,null,g),r.child=As(r,null,N,g)):ht(n,r,N,g),r.memoizedState=u.state,f&&eh(r,l,!0),r.child}function Yh(n){var r=n.stateNode;r.pendingContext?Xd(n,r.pendingContext,r.pendingContext!==r.context):r.context&&Xd(n,r.context,!1),xl(n,r.containerInfo)}function Jh(n,r,l,u,f){return Es(),ml(f),r.flags|=256,ht(n,r,l,u),r.child}var zl={dehydrated:null,treeContext:null,retryLane:0};function Bl(n){return{baseLanes:n,cachePool:null,transitions:null}}function Xh(n,r,l){var u=r.pendingProps,f=_e.current,g=!1,w=(r.flags&128)!==0,N;if((N=w)||(N=n!==null&&n.memoizedState===null?!1:(f&2)!==0),N?(g=!0,r.flags&=-129):(n===null||n.memoizedState!==null)&&(f|=1),Ee(_e,f&1),n===null)return fl(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=u.children,n=u.fallback,g?(u=r.mode,g=r.child,w={mode:"hidden",children:w},(u&1)===0&&g!==null?(g.childLanes=0,g.pendingProps=w):g=ho(w,u,0,null),n=ls(n,u,l,null),g.return=r,n.return=r,g.sibling=n,r.child=g,r.child.memoizedState=Bl(l),r.memoizedState=zl,n):Fl(r,w));if(f=n.memoizedState,f!==null&&(N=f.dehydrated,N!==null))return iy(n,r,w,u,N,f,l);if(g){g=u.fallback,w=r.mode,f=n.child,N=f.sibling;var $={mode:"hidden",children:u.children};return(w&1)===0&&r.child!==f?(u=r.child,u.childLanes=0,u.pendingProps=$,r.deletions=null):(u=Bn(f,$),u.subtreeFlags=f.subtreeFlags&14680064),N!==null?g=Bn(N,g):(g=ls(g,w,l,null),g.flags|=2),g.return=r,u.return=r,u.sibling=g,r.child=u,u=g,g=r.child,w=n.child.memoizedState,w=w===null?Bl(l):{baseLanes:w.baseLanes|l,cachePool:null,transitions:w.transitions},g.memoizedState=w,g.childLanes=n.childLanes&~l,r.memoizedState=zl,u}return g=n.child,n=g.sibling,u=Bn(g,{mode:"visible",children:u.children}),(r.mode&1)===0&&(u.lanes=l),u.return=r,u.sibling=null,n!==null&&(l=r.deletions,l===null?(r.deletions=[n],r.flags|=16):l.push(n)),r.child=u,r.memoizedState=null,u}function Fl(n,r){return r=ho({mode:"visible",children:r},n.mode,0,null),r.return=n,n.child=r}function Xr(n,r,l,u){return u!==null&&ml(u),As(r,n.child,null,l),n=Fl(r,r.pendingProps.children),n.flags|=2,r.memoizedState=null,n}function iy(n,r,l,u,f,g,w){if(l)return r.flags&256?(r.flags&=-257,u=Ol(Error(s(422))),Xr(n,r,w,u)):r.memoizedState!==null?(r.child=n.child,r.flags|=128,null):(g=u.fallback,f=r.mode,u=ho({mode:"visible",children:u.children},f,0,null),g=ls(g,f,w,null),g.flags|=2,u.return=r,g.return=r,u.sibling=g,r.child=u,(r.mode&1)!==0&&As(r,n.child,null,w),r.child.memoizedState=Bl(w),r.memoizedState=zl,g);if((r.mode&1)===0)return Xr(n,r,w,null);if(f.data==="$!"){if(u=f.nextSibling&&f.nextSibling.dataset,u)var N=u.dgst;return u=N,g=Error(s(419)),u=Ol(g,u,void 0),Xr(n,r,w,u)}if(N=(w&n.childLanes)!==0,kt||N){if(u=tt,u!==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&(u.suspendedLanes|w))!==0?0:f,f!==0&&f!==g.retryLane&&(g.retryLane=f,gn(n,f),Vt(u,n,f,-1))}return sc(),u=Ol(Error(s(421))),Xr(n,r,w,u)}return f.data==="$?"?(r.flags|=128,r.child=n.child,r=vy.bind(null,n),f._reactRetry=r,null):(n=g.treeContext,$t=En(f.nextSibling),Ct=r,Oe=!0,Ut=null,n!==null&&(At[It++]=mn,At[It++]=pn,At[It++]=Zn,mn=n.id,pn=n.overflow,Zn=r),r=Fl(r,u.children),r.flags|=4096,r)}function Zh(n,r,l){n.lanes|=r;var u=n.alternate;u!==null&&(u.lanes|=r),kl(n.return,r,l)}function Ul(n,r,l,u,f){var g=n.memoizedState;g===null?n.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:u,tail:l,tailMode:f}:(g.isBackwards=r,g.rendering=null,g.renderingStartTime=0,g.last=u,g.tail=l,g.tailMode=f)}function ef(n,r,l){var u=r.pendingProps,f=u.revealOrder,g=u.tail;if(ht(n,r,u.children,l),u=_e.current,(u&2)!==0)u=u&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&&Zh(n,l,r);else if(n.tag===19)Zh(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}u&=1}if(Ee(_e,u),(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),Ul(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}Ul(r,!0,l,null,g);break;case"together":Ul(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 kn(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=Bn(n,n.pendingProps),r.child=l,l.return=r;n.sibling!==null;)n=n.sibling,l=l.sibling=Bn(n,n.pendingProps),l.return=r;l.sibling=null}return r.child}function ry(n,r,l){switch(r.tag){case 3:Yh(r),Es();break;case 5:mh(r);break;case 1:vt(r.type)&&Or(r);break;case 4:xl(r,r.stateNode.containerInfo);break;case 10:var u=r.type._context,f=r.memoizedProps.value;Ee(Fr,u._currentValue),u._currentValue=f;break;case 13:if(u=r.memoizedState,u!==null)return u.dehydrated!==null?(Ee(_e,_e.current&1),r.flags|=128,null):(l&r.child.childLanes)!==0?Xh(n,r,l):(Ee(_e,_e.current&1),n=kn(n,r,l),n!==null?n.sibling:null);Ee(_e,_e.current&1);break;case 19:if(u=(l&r.childLanes)!==0,(n.flags&128)!==0){if(u)return ef(n,r,l);r.flags|=128}if(f=r.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),Ee(_e,_e.current),u)break;return null;case 22:case 23:return r.lanes=0,Gh(n,r,l)}return kn(n,r,l)}var tf,Wl,nf,sf;tf=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}},Wl=function(){},nf=function(n,r,l,u){var f=n.memoizedProps;if(f!==u){n=r.stateNode,ns(Zt.current);var g=null;switch(l){case"input":f=ka(n,f),u=ka(n,u),g=[];break;case"select":f=B({},f,{value:void 0}),u=B({},u,{value:void 0}),g=[];break;case"textarea":f=xa(n,f),u=xa(n,u),g=[];break;default:typeof f.onClick!="function"&&typeof u.onClick=="function"&&(n.onclick=Mr)}Sa(l,u);var w;l=null;for(L in f)if(!u.hasOwnProperty(L)&&f.hasOwnProperty(L)&&f[L]!=null)if(L==="style"){var N=f[L];for(w in N)N.hasOwnProperty(w)&&(l||(l={}),l[w]="")}else L!=="dangerouslySetInnerHTML"&&L!=="children"&&L!=="suppressContentEditableWarning"&&L!=="suppressHydrationWarning"&&L!=="autoFocus"&&(a.hasOwnProperty(L)?g||(g=[]):(g=g||[]).push(L,null));for(L in u){var $=u[L];if(N=f!=null?f[L]:void 0,u.hasOwnProperty(L)&&$!==N&&($!=null||N!=null))if(L==="style")if(N){for(w in N)!N.hasOwnProperty(w)||$&&$.hasOwnProperty(w)||(l||(l={}),l[w]="");for(w in $)$.hasOwnProperty(w)&&N[w]!==$[w]&&(l||(l={}),l[w]=$[w])}else l||(g||(g=[]),g.push(L,l)),l=$;else L==="dangerouslySetInnerHTML"?($=$?$.__html:void 0,N=N?N.__html:void 0,$!=null&&N!==$&&(g=g||[]).push(L,$)):L==="children"?typeof $!="string"&&typeof $!="number"||(g=g||[]).push(L,""+$):L!=="suppressContentEditableWarning"&&L!=="suppressHydrationWarning"&&(a.hasOwnProperty(L)?($!=null&&L==="onScroll"&&Me("scroll",n),g||N===$||(g=[])):(g=g||[]).push(L,$))}l&&(g=g||[]).push("style",l);var L=g;(r.updateQueue=L)&&(r.flags|=4)}},sf=function(n,r,l,u){l!==u&&(r.flags|=4)};function Di(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 u=null;l!==null;)l.alternate!==null&&(u=l),l=l.sibling;u===null?r||n.tail===null?n.tail=null:n.tail.sibling=null:u.sibling=null}}function lt(n){var r=n.alternate!==null&&n.alternate.child===n.child,l=0,u=0;if(r)for(var f=n.child;f!==null;)l|=f.lanes|f.childLanes,u|=f.subtreeFlags&14680064,u|=f.flags&14680064,f.return=n,f=f.sibling;else for(f=n.child;f!==null;)l|=f.lanes|f.childLanes,u|=f.subtreeFlags,u|=f.flags,f.return=n,f=f.sibling;return n.subtreeFlags|=u,n.childLanes=l,r}function oy(n,r,l){var u=r.pendingProps;switch(dl(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)&&Lr(),lt(r),null;case 3:return u=r.stateNode,Rs(),Re(gt),Re(ot),Nl(),u.pendingContext&&(u.context=u.pendingContext,u.pendingContext=null),(n===null||n.child===null)&&(zr(r)?r.flags|=4:n===null||n.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,Ut!==null&&(ec(Ut),Ut=null))),Wl(n,r),lt(r),null;case 5:jl(r);var f=ns(Ri.current);if(l=r.type,n!==null&&r.stateNode!=null)nf(n,r,l,u,f),n.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!u){if(r.stateNode===null)throw Error(s(166));return lt(r),null}if(n=ns(Zt.current),zr(r)){u=r.stateNode,l=r.type;var g=r.memoizedProps;switch(u[Xt]=r,u[Ti]=g,n=(r.mode&1)!==0,l){case"dialog":Me("cancel",u),Me("close",u);break;case"iframe":case"object":case"embed":Me("load",u);break;case"video":case"audio":for(f=0;f<bi.length;f++)Me(bi[f],u);break;case"source":Me("error",u);break;case"img":case"image":case"link":Me("error",u),Me("load",u);break;case"details":Me("toggle",u);break;case"input":_u(u,g),Me("invalid",u);break;case"select":u._wrapperState={wasMultiple:!!g.multiple},Me("invalid",u);break;case"textarea":Bu(u,g),Me("invalid",u)}Sa(l,g),f=null;for(var w in g)if(g.hasOwnProperty(w)){var N=g[w];w==="children"?typeof N=="string"?u.textContent!==N&&(g.suppressHydrationWarning!==!0&&Ir(u.textContent,N,n),f=["children",N]):typeof N=="number"&&u.textContent!==""+N&&(g.suppressHydrationWarning!==!0&&Ir(u.textContent,N,n),f=["children",""+N]):a.hasOwnProperty(w)&&N!=null&&w==="onScroll"&&Me("scroll",u)}switch(l){case"input":jn(u),zu(u,g,!0);break;case"textarea":jn(u),Uu(u);break;case"select":case"option":break;default:typeof g.onClick=="function"&&(u.onclick=Mr)}u=f,r.updateQueue=u,u!==null&&(r.flags|=4)}else{w=f.nodeType===9?f:f.ownerDocument,n==="http://www.w3.org/1999/xhtml"&&(n=Wu(l)),n==="http://www.w3.org/1999/xhtml"?l==="script"?(n=w.createElement("div"),n.innerHTML="<script><\/script>",n=n.removeChild(n.firstChild)):typeof u.is=="string"?n=w.createElement(l,{is:u.is}):(n=w.createElement(l),l==="select"&&(w=n,u.multiple?w.multiple=!0:u.size&&(w.size=u.size))):n=w.createElementNS(n,l),n[Xt]=r,n[Ti]=u,tf(n,r,!1,!1),r.stateNode=n;e:{switch(w=Na(l,u),l){case"dialog":Me("cancel",n),Me("close",n),f=u;break;case"iframe":case"object":case"embed":Me("load",n),f=u;break;case"video":case"audio":for(f=0;f<bi.length;f++)Me(bi[f],n);f=u;break;case"source":Me("error",n),f=u;break;case"img":case"image":case"link":Me("error",n),Me("load",n),f=u;break;case"details":Me("toggle",n),f=u;break;case"input":_u(n,u),f=ka(n,u),Me("invalid",n);break;case"option":f=u;break;case"select":n._wrapperState={wasMultiple:!!u.multiple},f=B({},u,{value:void 0}),Me("invalid",n);break;case"textarea":Bu(n,u),f=xa(n,u),Me("invalid",n);break;default:f=u}Sa(l,f),N=f;for(g in N)if(N.hasOwnProperty(g)){var $=N[g];g==="style"?Vu(n,$):g==="dangerouslySetInnerHTML"?($=$?$.__html:void 0,$!=null&&Hu(n,$)):g==="children"?typeof $=="string"?(l!=="textarea"||$!=="")&&oi(n,$):typeof $=="number"&&oi(n,""+$):g!=="suppressContentEditableWarning"&&g!=="suppressHydrationWarning"&&g!=="autoFocus"&&(a.hasOwnProperty(g)?$!=null&&g==="onScroll"&&Me("scroll",n):$!=null&&O(n,g,$,w))}switch(l){case"input":jn(n),zu(n,u,!1);break;case"textarea":jn(n),Uu(n);break;case"option":u.value!=null&&n.setAttribute("value",""+Se(u.value));break;case"select":n.multiple=!!u.multiple,g=u.value,g!=null?ms(n,!!u.multiple,g,!1):u.defaultValue!=null&&ms(n,!!u.multiple,u.defaultValue,!0);break;default:typeof f.onClick=="function"&&(n.onclick=Mr)}switch(l){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}}u&&(r.flags|=4)}r.ref!==null&&(r.flags|=512,r.flags|=2097152)}return lt(r),null;case 6:if(n&&r.stateNode!=null)sf(n,r,n.memoizedProps,u);else{if(typeof u!="string"&&r.stateNode===null)throw Error(s(166));if(l=ns(Ri.current),ns(Zt.current),zr(r)){if(u=r.stateNode,l=r.memoizedProps,u[Xt]=r,(g=u.nodeValue!==l)&&(n=Ct,n!==null))switch(n.tag){case 3:Ir(u.nodeValue,l,(n.mode&1)!==0);break;case 5:n.memoizedProps.suppressHydrationWarning!==!0&&Ir(u.nodeValue,l,(n.mode&1)!==0)}g&&(r.flags|=4)}else u=(l.nodeType===9?l:l.ownerDocument).createTextNode(u),u[Xt]=r,r.stateNode=u}return lt(r),null;case 13:if(Re(_e),u=r.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(Oe&&$t!==null&&(r.mode&1)!==0&&(r.flags&128)===0)oh(),Es(),r.flags|=98560,g=!1;else if(g=zr(r),u!==null&&u.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[Xt]=r}else Es(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;lt(r),g=!1}else Ut!==null&&(ec(Ut),Ut=null),g=!0;if(!g)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=l,r):(u=u!==null,u!==(n!==null&&n.memoizedState!==null)&&u&&(r.child.flags|=8192,(r.mode&1)!==0&&(n===null||(_e.current&1)!==0?Xe===0&&(Xe=3):sc())),r.updateQueue!==null&&(r.flags|=4),lt(r),null);case 4:return Rs(),Wl(n,r),n===null&&Ci(r.stateNode.containerInfo),lt(r),null;case 10:return vl(r.type._context),lt(r),null;case 17:return vt(r.type)&&Lr(),lt(r),null;case 19:if(Re(_e),g=r.memoizedState,g===null)return lt(r),null;if(u=(r.flags&128)!==0,w=g.rendering,w===null)if(u)Di(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,Di(g,!1),u=w.updateQueue,u!==null&&(r.updateQueue=u,r.flags|=4),r.subtreeFlags=0,u=l,l=r.child;l!==null;)g=l,n=u,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(_e,_e.current&1|2),r.child}n=n.sibling}g.tail!==null&&We()>_s&&(r.flags|=128,u=!0,Di(g,!1),r.lanes=4194304)}else{if(!u)if(n=Kr(w),n!==null){if(r.flags|=128,u=!0,l=n.updateQueue,l!==null&&(r.updateQueue=l,r.flags|=4),Di(g,!0),g.tail===null&&g.tailMode==="hidden"&&!w.alternate&&!Oe)return lt(r),null}else 2*We()-g.renderingStartTime>_s&&l!==1073741824&&(r.flags|=128,u=!0,Di(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=_e.current,Ee(_e,u?l&1|2:l&1),r):(lt(r),null);case 22:case 23:return nc(),u=r.memoizedState!==null,n!==null&&n.memoizedState!==null!==u&&(r.flags|=8192),u&&(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 ay(n,r){switch(dl(r),r.tag){case 1:return vt(r.type)&&Lr(),n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 3:return Rs(),Re(gt),Re(ot),Nl(),n=r.flags,(n&65536)!==0&&(n&128)===0?(r.flags=n&-65537|128,r):null;case 5:return jl(r),null;case 13:if(Re(_e),n=r.memoizedState,n!==null&&n.dehydrated!==null){if(r.alternate===null)throw Error(s(340));Es()}return n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 19:return Re(_e),null;case 4:return Rs(),null;case 10:return vl(r.type._context),null;case 22:case 23:return nc(),null;case 24:return null;default:return null}}var eo=!1,ct=!1,ly=typeof WeakSet=="function"?WeakSet:Set,ne=null;function Os(n,r){var l=n.ref;if(l!==null)if(typeof l=="function")try{l(null)}catch(u){Fe(n,r,u)}else l.current=null}function Hl(n,r,l){try{l()}catch(u){Fe(n,r,u)}}var rf=!1;function cy(n,r){if(nl=wr,n=Pd(),qa(n)){if("selectionStart"in n)var l={start:n.selectionStart,end:n.selectionEnd};else e:{l=(l=n.ownerDocument)&&l.defaultView||window;var u=l.getSelection&&l.getSelection();if(u&&u.rangeCount!==0){l=u.anchorNode;var f=u.anchorOffset,g=u.focusNode;u=u.focusOffset;try{l.nodeType,g.nodeType}catch{l=null;break e}var w=0,N=-1,$=-1,L=0,F=0,H=n,z=null;t:for(;;){for(var Z;H!==l||f!==0&&H.nodeType!==3||(N=w+f),H!==g||u!==0&&H.nodeType!==3||($=w+u),H.nodeType===3&&(w+=H.nodeValue.length),(Z=H.firstChild)!==null;)z=H,H=Z;for(;;){if(H===n)break t;if(z===l&&++L===f&&(N=w),z===g&&++F===u&&($=w),(Z=H.nextSibling)!==null)break;H=z,z=H.parentNode}H=Z}l=N===-1||$===-1?null:{start:N,end:$}}else l=null}l=l||{start:0,end:0}}else l=null;for(sl={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,A=r.stateNode,E=A.getSnapshotBeforeUpdate(r.elementType===r.type?re:Wt(r.type,re),He);A.__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=rf,rf=!1,se}function zi(n,r,l){var u=r.updateQueue;if(u=u!==null?u.lastEffect:null,u!==null){var f=u=u.next;do{if((f.tag&n)===n){var g=f.destroy;f.destroy=void 0,g!==void 0&&Hl(r,l,g)}f=f.next}while(f!==u)}}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 u=l.create;l.destroy=u()}l=l.next}while(l!==r)}}function Kl(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 of(n){var r=n.alternate;r!==null&&(n.alternate=null,of(r)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(r=n.stateNode,r!==null&&(delete r[Xt],delete r[Ti],delete r[al],delete r[Kk],delete r[Vk])),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 af(n){return n.tag===5||n.tag===3||n.tag===4}function lf(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||af(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 Vl(n,r,l){var u=n.tag;if(u===5||u===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(u!==4&&(n=n.child,n!==null))for(Vl(n,r,l),n=n.sibling;n!==null;)Vl(n,r,l),n=n.sibling}function Gl(n,r,l){var u=n.tag;if(u===5||u===6)n=n.stateNode,r?l.insertBefore(n,r):l.appendChild(n);else if(u!==4&&(n=n.child,n!==null))for(Gl(n,r,l),n=n.sibling;n!==null;)Gl(n,r,l),n=n.sibling}var it=null,Ht=!1;function On(n,r,l){for(l=l.child;l!==null;)cf(n,r,l),l=l.sibling}function cf(n,r,l){if(Jt&&typeof Jt.onCommitFiberUnmount=="function")try{Jt.onCommitFiberUnmount(mr,l)}catch{}switch(l.tag){case 5:ct||Os(l,r);case 6:var u=it,f=Ht;it=null,On(n,r,l),it=u,Ht=f,it!==null&&(Ht?(n=it,l=l.stateNode,n.nodeType===8?n.parentNode.removeChild(l):n.removeChild(l)):it.removeChild(l.stateNode));break;case 18:it!==null&&(Ht?(n=it,l=l.stateNode,n.nodeType===8?ol(n.parentNode,l):n.nodeType===1&&ol(n,l),vi(n)):ol(it,l.stateNode));break;case 4:u=it,f=Ht,it=l.stateNode.containerInfo,Ht=!0,On(n,r,l),it=u,Ht=f;break;case 0:case 11:case 14:case 15:if(!ct&&(u=l.updateQueue,u!==null&&(u=u.lastEffect,u!==null))){f=u=u.next;do{var g=f,w=g.destroy;g=g.tag,w!==void 0&&((g&2)!==0||(g&4)!==0)&&Hl(l,r,w),f=f.next}while(f!==u)}On(n,r,l);break;case 1:if(!ct&&(Os(l,r),u=l.stateNode,typeof u.componentWillUnmount=="function"))try{u.props=l.memoizedProps,u.state=l.memoizedState,u.componentWillUnmount()}catch(N){Fe(l,r,N)}On(n,r,l);break;case 21:On(n,r,l);break;case 22:l.mode&1?(ct=(u=ct)||l.memoizedState!==null,On(n,r,l),ct=u):On(n,r,l);break;default:On(n,r,l)}}function uf(n){var r=n.updateQueue;if(r!==null){n.updateQueue=null;var l=n.stateNode;l===null&&(l=n.stateNode=new ly),r.forEach(function(u){var f=ky.bind(null,n,u);l.has(u)||(l.add(u),u.then(f,f))})}}function Kt(n,r){var l=r.deletions;if(l!==null)for(var u=0;u<l.length;u++){var f=l[u];try{var g=n,w=r,N=w;e:for(;N!==null;){switch(N.tag){case 5:it=N.stateNode,Ht=!1;break e;case 3:it=N.stateNode.containerInfo,Ht=!0;break e;case 4:it=N.stateNode.containerInfo,Ht=!0;break e}N=N.return}if(it===null)throw Error(s(160));cf(g,w,f),it=null,Ht=!1;var $=f.alternate;$!==null&&($.return=null),f.return=null}catch(L){Fe(f,r,L)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)df(r,n),r=r.sibling}function df(n,r){var l=n.alternate,u=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:if(Kt(r,n),tn(n),u&4){try{zi(3,n,n.return),to(3,n)}catch(re){Fe(n,n.return,re)}try{zi(5,n,n.return)}catch(re){Fe(n,n.return,re)}}break;case 1:Kt(r,n),tn(n),u&512&&l!==null&&Os(l,l.return);break;case 5:if(Kt(r,n),tn(n),u&512&&l!==null&&Os(l,l.return),n.flags&32){var f=n.stateNode;try{oi(f,"")}catch(re){Fe(n,n.return,re)}}if(u&4&&(f=n.stateNode,f!=null)){var g=n.memoizedProps,w=l!==null?l.memoizedProps:g,N=n.type,$=n.updateQueue;if(n.updateQueue=null,$!==null)try{N==="input"&&g.type==="radio"&&g.name!=null&&Du(f,g),Na(N,w);var L=Na(N,g);for(w=0;w<$.length;w+=2){var F=$[w],H=$[w+1];F==="style"?Vu(f,H):F==="dangerouslySetInnerHTML"?Hu(f,H):F==="children"?oi(f,H):O(f,F,H,L)}switch(N){case"input":ya(f,g);break;case"textarea":Fu(f,g);break;case"select":var z=f._wrapperState.wasMultiple;f._wrapperState.wasMultiple=!!g.multiple;var Z=g.value;Z!=null?ms(f,!!g.multiple,Z,!1):z!==!!g.multiple&&(g.defaultValue!=null?ms(f,!!g.multiple,g.defaultValue,!0):ms(f,!!g.multiple,g.multiple?[]:"",!1))}f[Ti]=g}catch(re){Fe(n,n.return,re)}}break;case 6:if(Kt(r,n),tn(n),u&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(Kt(r,n),tn(n),u&4&&l!==null&&l.memoizedState.isDehydrated)try{vi(r.containerInfo)}catch(re){Fe(n,n.return,re)}break;case 4:Kt(r,n),tn(n);break;case 13:Kt(r,n),tn(n),f=n.child,f.flags&8192&&(g=f.memoizedState!==null,f.stateNode.isHidden=g,!g||f.alternate!==null&&f.alternate.memoizedState!==null||(Yl=We())),u&4&&uf(n);break;case 22:if(F=l!==null&&l.memoizedState!==null,n.mode&1?(ct=(L=ct)||F,Kt(r,n),ct=L):Kt(r,n),tn(n),u&8192){if(L=n.memoizedState!==null,(n.stateNode.isHidden=L)&&!F&&(n.mode&1)!==0)for(ne=n,F=n.child;F!==null;){for(H=ne=F;ne!==null;){switch(z=ne,Z=z.child,z.tag){case 0:case 11:case 14:case 15:zi(4,z,z.return);break;case 1:Os(z,z.return);var se=z.stateNode;if(typeof se.componentWillUnmount=="function"){u=z,l=z.return;try{r=u,se.props=r.memoizedProps,se.state=r.memoizedState,se.componentWillUnmount()}catch(re){Fe(u,l,re)}}break;case 5:Os(z,z.return);break;case 22:if(z.memoizedState!==null){mf(H);continue}}Z!==null?(Z.return=z,ne=Z):mf(H)}F=F.sibling}e:for(F=null,H=n;;){if(H.tag===5){if(F===null){F=H;try{f=H.stateNode,L?(g=f.style,typeof g.setProperty=="function"?g.setProperty("display","none","important"):g.display="none"):(N=H.stateNode,$=H.memoizedProps.style,w=$!=null&&$.hasOwnProperty("display")?$.display:null,N.style.display=Ku("display",w))}catch(re){Fe(n,n.return,re)}}}else if(H.tag===6){if(F===null)try{H.stateNode.nodeValue=L?"":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:Kt(r,n),tn(n),u&4&&uf(n);break;case 21:break;default:Kt(r,n),tn(n)}}function tn(n){var r=n.flags;if(r&2){try{e:{for(var l=n.return;l!==null;){if(af(l)){var u=l;break e}l=l.return}throw Error(s(160))}switch(u.tag){case 5:var f=u.stateNode;u.flags&32&&(oi(f,""),u.flags&=-33);var g=lf(n);Gl(n,g,f);break;case 3:case 4:var w=u.stateNode.containerInfo,N=lf(n);Vl(n,N,w);break;default:throw Error(s(161))}}catch($){Fe(n,n.return,$)}n.flags&=-3}r&4096&&(n.flags&=-4097)}function uy(n,r,l){ne=n,hf(n)}function hf(n,r,l){for(var u=(n.mode&1)!==0;ne!==null;){var f=ne,g=f.child;if(f.tag===22&&u){var w=f.memoizedState!==null||eo;if(!w){var N=f.alternate,$=N!==null&&N.memoizedState!==null||ct;N=eo;var L=ct;if(eo=w,(ct=$)&&!L)for(ne=f;ne!==null;)w=ne,$=w.child,w.tag===22&&w.memoizedState!==null?pf(f):$!==null?($.return=w,ne=$):pf(f);for(;g!==null;)ne=g,hf(g),g=g.sibling;ne=f,eo=N,ct=L}ff(n)}else(f.subtreeFlags&8772)!==0&&g!==null?(g.return=f,ne=g):ff(n)}}function ff(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 u=r.stateNode;if(r.flags&4&&!ct)if(l===null)u.componentDidMount();else{var f=r.elementType===r.type?l.memoizedProps:Wt(r.type,l.memoizedProps);u.componentDidUpdate(f,l.memoizedState,u.__reactInternalSnapshotBeforeUpdate)}var g=r.updateQueue;g!==null&&fh(r,g,u);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}fh(r,w,l)}break;case 5:var N=r.stateNode;if(l===null&&r.flags&4){l=N;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 L=r.alternate;if(L!==null){var F=L.memoizedState;if(F!==null){var H=F.dehydrated;H!==null&&vi(H)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(s(163))}ct||r.flags&512&&Kl(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 mf(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 pf(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 u=r.stateNode;if(typeof u.componentDidMount=="function"){var f=r.return;try{u.componentDidMount()}catch($){Fe(r,f,$)}}var g=r.return;try{Kl(r)}catch($){Fe(r,g,$)}break;case 5:var w=r.return;try{Kl(r)}catch($){Fe(r,w,$)}}}catch($){Fe(r,r.return,$)}if(r===n){ne=null;break}var N=r.sibling;if(N!==null){N.return=r.return,ne=N;break}ne=r.return}}var dy=Math.ceil,no=U.ReactCurrentDispatcher,ql=U.ReactCurrentOwner,Lt=U.ReactCurrentBatchConfig,Ne=0,tt=null,qe=null,rt=0,Tt=0,Ps=An(0),Xe=0,Bi=null,is=0,so=0,Ql=0,Fi=null,yt=null,Yl=0,_s=1/0,yn=null,io=!1,Jl=null,Pn=null,ro=!1,_n=null,oo=0,Ui=0,Xl=null,ao=-1,lo=0;function ft(){return(Ne&6)!==0?We():ao!==-1?ao:ao=We()}function Dn(n){return(n.mode&1)===0?1:(Ne&2)!==0&&rt!==0?rt&-rt:qk.transition!==null?(lo===0&&(lo=ad()),lo):(n=Te,n!==0||(n=window.event,n=n===void 0?16:gd(n.type)),n)}function Vt(n,r,l,u){if(50<Ui)throw Ui=0,Xl=null,Error(s(185));hi(n,l,u),((Ne&2)===0||n!==tt)&&(n===tt&&((Ne&2)===0&&(so|=l),Xe===4&&zn(n,rt)),wt(n,u),l===1&&Ne===0&&(r.mode&1)===0&&(_s=We()+500,Pr&&Mn()))}function wt(n,r){var l=n.callbackNode;qv(n,r);var u=vr(n,n===tt?rt:0);if(u===0)l!==null&&id(l),n.callbackNode=null,n.callbackPriority=0;else if(r=u&-u,n.callbackPriority!==r){if(l!=null&&id(l),r===1)n.tag===0?Gk(vf.bind(null,n)):th(vf.bind(null,n)),Wk(function(){(Ne&6)===0&&Mn()}),l=null;else{switch(ld(u)){case 1:l=Ia;break;case 4:l=rd;break;case 16:l=fr;break;case 536870912:l=od;break;default:l=fr}l=bf(l,gf.bind(null,n))}n.callbackPriority=r,n.callbackNode=l}}function gf(n,r){if(ao=-1,lo=0,(Ne&6)!==0)throw Error(s(327));var l=n.callbackNode;if(Ds()&&n.callbackNode!==l)return null;var u=vr(n,n===tt?rt:0);if(u===0)return null;if((u&30)!==0||(u&n.expiredLanes)!==0||r)r=co(n,u);else{r=u;var f=Ne;Ne|=2;var g=yf();(tt!==n||rt!==r)&&(yn=null,_s=We()+500,os(n,r));do try{my();break}catch(N){kf(n,N)}while(!0);gl(),no.current=g,Ne=f,qe!==null?r=0:(tt=null,rt=0,r=Xe)}if(r!==0){if(r===2&&(f=Ma(n),f!==0&&(u=f,r=Zl(n,f))),r===1)throw l=Bi,os(n,0),zn(n,u),wt(n,We()),l;if(r===6)zn(n,u);else{if(f=n.current.alternate,(u&30)===0&&!hy(f)&&(r=co(n,u),r===2&&(g=Ma(n),g!==0&&(u=g,r=Zl(n,g))),r===1))throw l=Bi,os(n,0),zn(n,u),wt(n,We()),l;switch(n.finishedWork=f,n.finishedLanes=u,r){case 0:case 1:throw Error(s(345));case 2:as(n,yt,yn);break;case 3:if(zn(n,u),(u&130023424)===u&&(r=Yl+500-We(),10<r)){if(vr(n,0)!==0)break;if(f=n.suspendedLanes,(f&u)!==u){ft(),n.pingedLanes|=n.suspendedLanes&f;break}n.timeoutHandle=rl(as.bind(null,n,yt,yn),r);break}as(n,yt,yn);break;case 4:if(zn(n,u),(u&4194240)===u)break;for(r=n.eventTimes,f=-1;0<u;){var w=31-Bt(u);g=1<<w,w=r[w],w>f&&(f=w),u&=~g}if(u=f,u=We()-u,u=(120>u?120:480>u?480:1080>u?1080:1920>u?1920:3e3>u?3e3:4320>u?4320:1960*dy(u/1960))-u,10<u){n.timeoutHandle=rl(as.bind(null,n,yt,yn),u);break}as(n,yt,yn);break;case 5:as(n,yt,yn);break;default:throw Error(s(329))}}}return wt(n,We()),n.callbackNode===l?gf.bind(null,n):null}function Zl(n,r){var l=Fi;return n.current.memoizedState.isDehydrated&&(os(n,r).flags|=256),n=co(n,r),n!==2&&(r=yt,yt=l,r!==null&&ec(r)),n}function ec(n){yt===null?yt=n:yt.push.apply(yt,n)}function hy(n){for(var r=n;;){if(r.flags&16384){var l=r.updateQueue;if(l!==null&&(l=l.stores,l!==null))for(var u=0;u<l.length;u++){var f=l[u],g=f.getSnapshot;f=f.value;try{if(!Ft(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 zn(n,r){for(r&=~Ql,r&=~so,n.suspendedLanes|=r,n.pingedLanes&=~r,n=n.expirationTimes;0<r;){var l=31-Bt(r),u=1<<l;n[l]=-1,r&=~u}}function vf(n){if((Ne&6)!==0)throw Error(s(327));Ds();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 u=Ma(n);u!==0&&(r=u,l=Zl(n,u))}if(l===1)throw l=Bi,os(n,0),zn(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,yn),wt(n,We()),null}function tc(n,r){var l=Ne;Ne|=1;try{return n(r)}finally{Ne=l,Ne===0&&(_s=We()+500,Pr&&Mn())}}function rs(n){_n!==null&&_n.tag===0&&(Ne&6)===0&&Ds();var r=Ne;Ne|=1;var l=Lt.transition,u=Te;try{if(Lt.transition=null,Te=1,n)return n()}finally{Te=u,Lt.transition=l,Ne=r,(Ne&6)===0&&Mn()}}function nc(){Tt=Ps.current,Re(Ps)}function os(n,r){n.finishedWork=null,n.finishedLanes=0;var l=n.timeoutHandle;if(l!==-1&&(n.timeoutHandle=-1,Uk(l)),qe!==null)for(l=qe.return;l!==null;){var u=l;switch(dl(u),u.tag){case 1:u=u.type.childContextTypes,u!=null&&Lr();break;case 3:Rs(),Re(gt),Re(ot),Nl();break;case 5:jl(u);break;case 4:Rs();break;case 13:Re(_e);break;case 19:Re(_e);break;case 10:vl(u.type._context);break;case 22:case 23:nc()}l=l.return}if(tt=n,qe=n=Bn(n.current,null),rt=Tt=r,Xe=0,Bi=null,Ql=so=is=0,yt=Fi=null,ts!==null){for(r=0;r<ts.length;r++)if(l=ts[r],u=l.interleaved,u!==null){l.interleaved=null;var f=u.next,g=l.pending;if(g!==null){var w=g.next;g.next=f,u.next=w}l.pending=u}ts=null}return n}function kf(n,r){do{var l=qe;try{if(gl(),Vr.current=Yr,Gr){for(var u=De.memoizedState;u!==null;){var f=u.queue;f!==null&&(f.pending=null),u=u.next}Gr=!1}if(ss=0,et=Je=De=null,Li=!1,Oi=0,ql.current=null,l===null||l.return===null){Xe=1,Bi=r,qe=null;break}e:{var g=n,w=l.return,N=l,$=r;if(r=rt,N.flags|=32768,$!==null&&typeof $=="object"&&typeof $.then=="function"){var L=$,F=N,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 Z=Uh(w);if(Z!==null){Z.flags&=-257,Wh(Z,w,N,g,r),Z.mode&1&&Fh(g,L,r),r=Z,$=L;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){Fh(g,L,r),sc();break e}$=Error(s(426))}}else if(Oe&&N.mode&1){var He=Uh(w);if(He!==null){(He.flags&65536)===0&&(He.flags|=256),Wh(He,w,N,g,r),ml(Ls($,N));break e}}g=$=Ls($,N),Xe!==4&&(Xe=2),Fi===null?Fi=[g]:Fi.push(g),g=w;do{switch(g.tag){case 3:g.flags|=65536,r&=-r,g.lanes|=r;var A=zh(g,$,r);hh(g,A);break e;case 1:N=$;var E=g.type,M=g.stateNode;if((g.flags&128)===0&&(typeof E.getDerivedStateFromError=="function"||M!==null&&typeof M.componentDidCatch=="function"&&(Pn===null||!Pn.has(M)))){g.flags|=65536,r&=-r,g.lanes|=r;var q=Bh(g,N,r);hh(g,q);break e}}g=g.return}while(g!==null)}xf(l)}catch(ae){r=ae,qe===l&&l!==null&&(qe=l=l.return);continue}break}while(!0)}function yf(){var n=no.current;return no.current=Yr,n===null?Yr:n}function sc(){(Xe===0||Xe===3||Xe===2)&&(Xe=4),tt===null||(is&268435455)===0&&(so&268435455)===0||zn(tt,rt)}function co(n,r){var l=Ne;Ne|=2;var u=yf();(tt!==n||rt!==r)&&(yn=null,os(n,r));do try{fy();break}catch(f){kf(n,f)}while(!0);if(gl(),Ne=l,no.current=u,qe!==null)throw Error(s(261));return tt=null,rt=0,Xe}function fy(){for(;qe!==null;)wf(qe)}function my(){for(;qe!==null&&!zv();)wf(qe)}function wf(n){var r=Nf(n.alternate,n,Tt);n.memoizedProps=n.pendingProps,r===null?xf(n):qe=r,ql.current=null}function xf(n){var r=n;do{var l=r.alternate;if(n=r.return,(r.flags&32768)===0){if(l=oy(l,r,Tt),l!==null){qe=l;return}}else{if(l=ay(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 u=Te,f=Lt.transition;try{Lt.transition=null,Te=1,py(n,r,l,u)}finally{Lt.transition=f,Te=u}return null}function py(n,r,l,u){do Ds();while(_n!==null);if((Ne&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(Qv(n,g),n===tt&&(qe=tt=null,rt=0),(l.subtreeFlags&2064)===0&&(l.flags&2064)===0||ro||(ro=!0,bf(fr,function(){return Ds(),null})),g=(l.flags&15990)!==0,(l.subtreeFlags&15990)!==0||g){g=Lt.transition,Lt.transition=null;var w=Te;Te=1;var N=Ne;Ne|=4,ql.current=null,cy(n,l),df(l,n),Ok(sl),wr=!!nl,sl=nl=null,n.current=l,uy(l),Bv(),Ne=N,Te=w,Lt.transition=g}else n.current=l;if(ro&&(ro=!1,_n=n,oo=f),g=n.pendingLanes,g===0&&(Pn=null),Wv(l.stateNode),wt(n,We()),r!==null)for(u=n.onRecoverableError,l=0;l<r.length;l++)f=r[l],u(f.value,{componentStack:f.stack,digest:f.digest});if(io)throw io=!1,n=Jl,Jl=null,n;return(oo&1)!==0&&n.tag!==0&&Ds(),g=n.pendingLanes,(g&1)!==0?n===Xl?Ui++:(Ui=0,Xl=n):Ui=0,Mn(),null}function Ds(){if(_n!==null){var n=ld(oo),r=Lt.transition,l=Te;try{if(Lt.transition=null,Te=16>n?16:n,_n===null)var u=!1;else{if(n=_n,_n=null,oo=0,(Ne&6)!==0)throw Error(s(331));var f=Ne;for(Ne|=4,ne=n.current;ne!==null;){var g=ne,w=g.child;if((ne.flags&16)!==0){var N=g.deletions;if(N!==null){for(var $=0;$<N.length;$++){var L=N[$];for(ne=L;ne!==null;){var F=ne;switch(F.tag){case 0:case 11:case 15:zi(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,Z=F.return;if(of(F),F===L){ne=null;break}if(z!==null){z.return=Z,ne=z;break}ne=Z}}}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:zi(9,g,g.return)}var A=g.sibling;if(A!==null){A.return=g.return,ne=A;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(N=ne,(N.flags&2048)!==0)try{switch(N.tag){case 0:case 11:case 15:to(9,N)}}catch(ae){Fe(N,N.return,ae)}if(N===w){ne=null;break e}var q=N.sibling;if(q!==null){q.return=N.return,ne=q;break e}ne=N.return}}if(Ne=f,Mn(),Jt&&typeof Jt.onPostCommitFiberRoot=="function")try{Jt.onPostCommitFiberRoot(mr,n)}catch{}u=!0}return u}finally{Te=l,Lt.transition=r}}return!1}function jf(n,r,l){r=Ls(l,r),r=zh(n,r,1),n=Ln(n,r,1),r=ft(),n!==null&&(hi(n,1,r),wt(n,r))}function Fe(n,r,l){if(n.tag===3)jf(n,n,l);else for(;r!==null;){if(r.tag===3){jf(r,n,l);break}else if(r.tag===1){var u=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(Pn===null||!Pn.has(u))){n=Ls(l,n),n=Bh(r,n,1),r=Ln(r,n,1),n=ft(),r!==null&&(hi(r,1,n),wt(r,n));break}}r=r.return}}function gy(n,r,l){var u=n.pingCache;u!==null&&u.delete(r),r=ft(),n.pingedLanes|=n.suspendedLanes&l,tt===n&&(rt&l)===l&&(Xe===4||Xe===3&&(rt&130023424)===rt&&500>We()-Yl?os(n,0):Ql|=l),wt(n,r)}function Sf(n,r){r===0&&((n.mode&1)===0?r=1:(r=gr,gr<<=1,(gr&130023424)===0&&(gr=4194304)));var l=ft();n=gn(n,r),n!==null&&(hi(n,r,l),wt(n,l))}function vy(n){var r=n.memoizedState,l=0;r!==null&&(l=r.retryLane),Sf(n,l)}function ky(n,r){var l=0;switch(n.tag){case 13:var u=n.stateNode,f=n.memoizedState;f!==null&&(l=f.retryLane);break;case 19:u=n.stateNode;break;default:throw Error(s(314))}u!==null&&u.delete(r),Sf(n,l)}var Nf;Nf=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,ry(n,r,l);kt=(n.flags&131072)!==0}else kt=!1,Oe&&(r.flags&1048576)!==0&&nh(r,Dr,r.index);switch(r.lanes=0,r.tag){case 2:var u=r.type;Zr(n,r),n=r.pendingProps;var f=Cs(r,ot.current);Ms(r,l),f=$l(null,r,u,n,f,l);var g=Tl();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(u)?(g=!0,Or(r)):g=!1,r.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,wl(r),f.updater=Jr,r.stateNode=f,f._reactInternals=r,Ll(r,u,n,l),r=Dl(null,r,u,!0,g,l)):(r.tag=0,Oe&&g&&ul(r),ht(null,r,f,l),r=r.child),r;case 16:u=r.elementType;e:{switch(Zr(n,r),n=r.pendingProps,f=u._init,u=f(u._payload),r.type=u,f=r.tag=wy(u),n=Wt(u,n),f){case 0:r=_l(null,r,u,n,l);break e;case 1:r=Qh(null,r,u,n,l);break e;case 11:r=Hh(null,r,u,n,l);break e;case 14:r=Kh(null,r,u,Wt(u.type,n),l);break e}throw Error(s(306,u,""))}return r;case 0:return u=r.type,f=r.pendingProps,f=r.elementType===u?f:Wt(u,f),_l(n,r,u,f,l);case 1:return u=r.type,f=r.pendingProps,f=r.elementType===u?f:Wt(u,f),Qh(n,r,u,f,l);case 3:e:{if(Yh(r),n===null)throw Error(s(387));u=r.pendingProps,g=r.memoizedState,f=g.element,dh(n,r),Hr(r,u,null,l);var w=r.memoizedState;if(u=w.element,g.isDehydrated)if(g={element:u,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=Jh(n,r,u,l,f);break e}else if(u!==f){f=Ls(Error(s(424)),r),r=Jh(n,r,u,l,f);break e}else for($t=En(r.stateNode.containerInfo.firstChild),Ct=r,Oe=!0,Ut=null,l=ch(r,null,u,l),r.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(Es(),u===f){r=kn(n,r,l);break e}ht(n,r,u,l)}r=r.child}return r;case 5:return mh(r),n===null&&fl(r),u=r.type,f=r.pendingProps,g=n!==null?n.memoizedProps:null,w=f.children,il(u,f)?w=null:g!==null&&il(u,g)&&(r.flags|=32),qh(n,r),ht(n,r,w,l),r.child;case 6:return n===null&&fl(r),null;case 13:return Xh(n,r,l);case 4:return xl(r,r.stateNode.containerInfo),u=r.pendingProps,n===null?r.child=As(r,null,u,l):ht(n,r,u,l),r.child;case 11:return u=r.type,f=r.pendingProps,f=r.elementType===u?f:Wt(u,f),Hh(n,r,u,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(u=r.type._context,f=r.pendingProps,g=r.memoizedProps,w=f.value,Ee(Fr,u._currentValue),u._currentValue=w,g!==null)if(Ft(g.value,w)){if(g.children===f.children&&!gt.current){r=kn(n,r,l);break e}}else for(g=r.child,g!==null&&(g.return=r);g!==null;){var N=g.dependencies;if(N!==null){w=g.child;for(var $=N.firstContext;$!==null;){if($.context===u){if(g.tag===1){$=vn(-1,l&-l),$.tag=2;var L=g.updateQueue;if(L!==null){L=L.shared;var F=L.pending;F===null?$.next=$:($.next=F.next,F.next=$),L.pending=$}}g.lanes|=l,$=g.alternate,$!==null&&($.lanes|=l),kl(g.return,l,r),N.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,N=w.alternate,N!==null&&(N.lanes|=l),kl(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,u=r.pendingProps.children,Ms(r,l),f=Mt(f),u=u(f),r.flags|=1,ht(n,r,u,l),r.child;case 14:return u=r.type,f=Wt(u,r.pendingProps),f=Wt(u.type,f),Kh(n,r,u,f,l);case 15:return Vh(n,r,r.type,r.pendingProps,l);case 17:return u=r.type,f=r.pendingProps,f=r.elementType===u?f:Wt(u,f),Zr(n,r),r.tag=1,vt(u)?(n=!0,Or(r)):n=!1,Ms(r,l),_h(r,u,f),Ll(r,u,f,l),Dl(null,r,u,!0,n,l);case 19:return ef(n,r,l);case 22:return Gh(n,r,l)}throw Error(s(156,r.tag))};function bf(n,r){return sd(n,r)}function yy(n,r,l,u){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=u,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ot(n,r,l,u){return new yy(n,r,l,u)}function ic(n){return n=n.prototype,!(!n||!n.isReactComponent)}function wy(n){if(typeof n=="function")return ic(n)?1:0;if(n!=null){if(n=n.$$typeof,n===$e)return 11;if(n===J)return 14}return 2}function Bn(n,r){var l=n.alternate;return l===null?(l=Ot(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,u,f,g){var w=2;if(u=n,typeof n=="function")ic(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=Ot(12,l,r,f|2),n.elementType=G,n.lanes=g,n;case oe:return n=Ot(13,l,r,f),n.elementType=oe,n.lanes=g,n;case D:return n=Ot(19,l,r,f),n.elementType=D,n.lanes=g,n;case ee:return ho(l,f,g,r);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case ve:w=10;break e;case Pe:w=9;break e;case $e:w=11;break e;case J:w=14;break e;case le:w=16,u=null;break e}throw Error(s(130,n==null?n:typeof n,""))}return r=Ot(w,l,r,f),r.elementType=n,r.type=u,r.lanes=g,r}function ls(n,r,l,u){return n=Ot(7,n,u,r),n.lanes=l,n}function ho(n,r,l,u){return n=Ot(22,n,u,r),n.elementType=ee,n.lanes=l,n.stateNode={isHidden:!1},n}function rc(n,r,l){return n=Ot(6,n,null,r),n.lanes=l,n}function oc(n,r,l){return r=Ot(4,n.children!==null?n.children:[],n.key,r),r.lanes=l,r.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},r}function xy(n,r,l,u,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=Ra(0),this.expirationTimes=Ra(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ra(0),this.identifierPrefix=u,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function ac(n,r,l,u,f,g,w,N,$){return n=new xy(n,r,l,N,$),r===1?(r=1,g===!0&&(r|=8)):r=0,g=Ot(3,null,null,r),n.current=g,g.stateNode=n,g.memoizedState={element:u,isDehydrated:l,cache:null,transitions:null,pendingSuspenseBoundaries:null},wl(g),n}function jy(n,r,l){var u=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Q,key:u==null?null:""+u,children:n,containerInfo:r,implementation:l}}function Cf(n){if(!n)return In;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 Zd(n,l,r)}return r}function $f(n,r,l,u,f,g,w,N,$){return n=ac(l,u,!0,n,f,g,w,N,$),n.context=Cf(null),l=n.current,u=ft(),f=Dn(l),g=vn(u,f),g.callback=r??null,Ln(l,g,f),n.current.lanes=f,hi(n,f,u),wt(n,u),n}function fo(n,r,l,u){var f=r.current,g=ft(),w=Dn(f);return l=Cf(l),r.context===null?r.context=l:r.pendingContext=l,r=vn(g,w),r.payload={element:n},u=u===void 0?null:u,u!==null&&(r.callback=u),n=Ln(f,r,w),n!==null&&(Vt(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 Tf(n,r){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var l=n.retryLane;n.retryLane=l!==0&&l<r?l:r}}function lc(n,r){Tf(n,r),(n=n.alternate)&&Tf(n,r)}function Sy(){return null}var Ef=typeof reportError=="function"?reportError:function(n){console.error(n)};function cc(n){this._internalRoot=n}po.prototype.render=cc.prototype.render=function(n){var r=this._internalRoot;if(r===null)throw Error(s(409));fo(n,r,null,null)},po.prototype.unmount=cc.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[hn]=null}};function po(n){this._internalRoot=n}po.prototype.unstable_scheduleHydration=function(n){if(n){var r=dd();n={blockedOn:null,target:n,priority:r};for(var l=0;l<Cn.length&&r!==0&&r<Cn[l].priority;l++);Cn.splice(l,0,n),l===0&&md(n)}};function uc(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 Af(){}function Ny(n,r,l,u,f){if(f){if(typeof u=="function"){var g=u;u=function(){var L=mo(w);g.call(L)}}var w=$f(r,u,n,0,null,!1,!1,"",Af);return n._reactRootContainer=w,n[hn]=w.current,Ci(n.nodeType===8?n.parentNode:n),rs(),w}for(;f=n.lastChild;)n.removeChild(f);if(typeof u=="function"){var N=u;u=function(){var L=mo($);N.call(L)}}var $=ac(n,0,!1,null,null,!1,!1,"",Af);return n._reactRootContainer=$,n[hn]=$.current,Ci(n.nodeType===8?n.parentNode:n),rs(function(){fo(r,$,l,u)}),$}function vo(n,r,l,u,f){var g=l._reactRootContainer;if(g){var w=g;if(typeof f=="function"){var N=f;f=function(){var $=mo(w);N.call($)}}fo(r,w,n,f)}else w=Ny(l,r,n,f,u);return mo(w)}cd=function(n){switch(n.tag){case 3:var r=n.stateNode;if(r.current.memoizedState.isDehydrated){var l=di(r.pendingLanes);l!==0&&(La(r,l|1),wt(r,We()),(Ne&6)===0&&(_s=We()+500,Mn()))}break;case 13:rs(function(){var u=gn(n,1);if(u!==null){var f=ft();Vt(u,n,1,f)}}),lc(n,1)}},Oa=function(n){if(n.tag===13){var r=gn(n,134217728);if(r!==null){var l=ft();Vt(r,n,134217728,l)}lc(n,134217728)}},ud=function(n){if(n.tag===13){var r=Dn(n),l=gn(n,r);if(l!==null){var u=ft();Vt(l,n,r,u)}lc(n,r)}},dd=function(){return Te},hd=function(n,r){var l=Te;try{return Te=n,r()}finally{Te=l}},$a=function(n,r,l){switch(r){case"input":if(ya(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 u=l[r];if(u!==n&&u.form===n.form){var f=Rr(u);if(!f)throw Error(s(90));cr(u),ya(u,f)}}}break;case"textarea":Fu(n,l);break;case"select":r=l.value,r!=null&&ms(n,!!l.multiple,r,!1)}},Yu=tc,Ju=rs;var by={usingClientEntryPoint:!1,Events:[Ei,Ns,Rr,qu,Qu,tc]},Wi={findFiberByHostInstance:Jn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Cy={bundleType:Wi.bundleType,version:Wi.version,rendererPackageName:Wi.rendererPackageName,rendererConfig:Wi.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=td(n),n===null?null:n.stateNode},findFiberByHostInstance:Wi.findFiberByHostInstance||Sy,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(Cy),Jt=ko}catch{}}return xt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=by,xt.createPortal=function(n,r){var l=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!uc(r))throw Error(s(200));return jy(n,r,null,l)},xt.createRoot=function(n,r){if(!uc(n))throw Error(s(299));var l=!1,u="",f=Ef;return r!=null&&(r.unstable_strictMode===!0&&(l=!0),r.identifierPrefix!==void 0&&(u=r.identifierPrefix),r.onRecoverableError!==void 0&&(f=r.onRecoverableError)),r=ac(n,1,!1,null,null,l,!1,u,f),n[hn]=r.current,Ci(n.nodeType===8?n.parentNode:n),new cc(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=td(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(!uc(n))throw Error(s(405));var u=l!=null&&l.hydratedSources||null,f=!1,g="",w=Ef;if(l!=null&&(l.unstable_strictMode===!0&&(f=!0),l.identifierPrefix!==void 0&&(g=l.identifierPrefix),l.onRecoverableError!==void 0&&(w=l.onRecoverableError)),r=$f(r,null,n,1,l??null,f,!1,g,w),n[hn]=r.current,Ci(n),u)for(n=0;n<u.length;n++)l=u[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[hn]=null})}),!0):!1},xt.unstable_batchedUpdates=tc,xt.unstable_renderSubtreeIntoContainer=function(n,r,l,u){if(!go(l))throw Error(s(200));if(n==null||n._reactInternals===void 0)throw Error(s(38));return vo(n,r,l,!1,u)},xt.version="18.3.1-next-f1338f8080-20240426",xt}var Df;function hp(){if(Df)return fc.exports;Df=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(),fc.exports=Oy(),fc.exports}var zf;function Py(){if(zf)return yo;zf=1;var e=hp();return yo.createRoot=e.createRoot,yo.hydrateRoot=e.hydrateRoot,yo}var _y=Py(),y=iu();const Hn="teamtrail",te={slug:Hn,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:Hn,dataDir:`.${Hn}`,apiPrefix:`/__${Hn}`,dataDirEnv:`${Hn.toUpperCase()}_DIR`,noRegisterEnv:`${Hn.toUpperCase()}_NO_REGISTER`,tokenEnv:`${Hn.toUpperCase()}_TOKEN`},Yo=`${Hn}.prefs`,Jo=e=>`${te.labelPrefix}:${e}`,ru=Jo("map"),ou=Jo("hitl"),Dy=e=>e==="task"||e==="execute",au=Jo("plan-only");function fp(e){return/^[A-Za-z0-9_@%+=:,./-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}const zy=e=>e.map(fp).join(" "),By=/^\d+\.\d+\.\d+(-[0-9A-Za-z][0-9A-Za-z.-]*)?$/;function Fy(e){return By.test(e)?`${te.npm}@${e}`:te.npm}function mp(e,t){return zy(["npx","-y",Fy(e),...t])}const Ro=["research","prototype","junction","task","execute"],Xo=[...Ro,"review"],ds="plan+execute",Uy=["verifying","rework","blocked"],lu=["off","checks","checks+review","checks+review+human"],pp=e=>lu.find(t=>t===e);function ir(e){return e.type==="junction"||e.type==="prototype"?"hitl":e.type==="research"?"afk":e.hitl?"hitl":"afk"}const Wy=["task","execute"];function gp(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 Js(e,t=ds){const s=new Map(e.map(o=>[o.id,o]));return new Map(e.map(o=>[o.id,gp(o,s,t)]))}const Ke=200,Ye=56;function Bf(e,t="LR",s=ds){var $e;const o=t==="LR"?330:124,a=t==="LR"?112:262,c=Js(e,s),d=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=d.get(oe),J=D&&D.blockedBy.length?1+Math.max(...D.blockedBy.filter(le=>d.has(le)).map(p),-1):0;return m.delete(oe),h.set(oe,J),J},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 j=[],b=new Map;let S=0;x.forEach(oe=>{oe&&(oe.sort((D,J)=>{const le=ee=>{const K=ee.blockedBy.map(Y=>b.get(Y)).filter(Y=>Y!==void 0);return K.length?K.reduce((Y,B)=>Y+B,0)/K.length:ee.createdAt/1e12};return le(D)-le(J)||D.createdAt-J.createdAt}),S=Math.max(S,oe.length),oe.forEach((D,J)=>b.set(D.id,J)))}),x.forEach((oe,D)=>{if(!oe)return;const J=(S-oe.length)*a/2;oe.forEach((le,ee)=>{const K=D*o,Y=J+ee*a;j.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(S,1)*a-(a-(t==="LR"?Ye:Ke)),O=t==="LR"?C:R,U=t==="LR"?R:C,X=U+54,Q=Math.max(1,Math.floor((O+24)/(Ke+24)));k.forEach((oe,D)=>{j.push({ticket:oe,state:"out-of-scope",layer:-1,x:D%Q*(Ke+24),y:X+Math.floor(D/Q)*(Ye+16)})});const W=[],ie=new Map(j.map(oe=>[oe.ticket.id,oe]));for(const oe of j)for(const D of oe.ticket.blockedBy){const J=ie.get(D);J&&W.push({from:J,to:oe})}const G=Math.ceil(k.length/Q),ve=Math.max(O,Math.min(k.length,Q)*(Ke+24)-24),Pe=k.length?X+G*(Ye+16)-16:U;return{direction:t,nodes:j,edges:W,width:ve,graphH:U,quarantineY:X,height:Pe,quarantineH:G*(Ye+16)+24}}const Lo=["fast","balanced","strongest"],vp=e=>Lo.includes(e),cu={research:"fast",task:"balanced",execute:"balanced",junction:"strongest",prototype:"strongest",review:"strongest"};function Hy(e,t){var a,c;const s=(c=(a=t.modelMatching)==null?void 0:a.tiers)==null?void 0:c[e.type],o=cu[e.type];return t.settingsUnconfirmed&&s?Lo.indexOf(s)>=Lo.indexOf(o)?s:o:s??o}function Ky(e){return Object.fromEntries(Xo.map(t=>[t,Hy({type:t},e)]))}const Vy=e=>e!=="__proto__"&&e!=="constructor"&&e!=="prototype",Gy=64;function qy(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 Qy(s)}function Qy(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 Yy({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 Jy(e,t,s){const o=s.length,a=new Uint8Array(o+1);let c=0;for(let d=o;d>=0;d--){const h=d<o,m=h?s[d]:"";if(e.kind!=="dirs"){a[d]=Yy({t:e,c:m,inText:h,next:t,cur:a,j:d});continue}m==="/"&&t[d+1]&&(c=1),a[d]=t[d]||c}return a}function Xy(e,t,s){const o=qy(e,s.segments);if(o.filter(c=>c.kind!=="char").length>Gy)return!1;let a=new Uint8Array(t.length+1);a[t.length]=1;for(let c=o.length-1;c>=0;c--)a=Jy(o[c],a,t);return a[0]===1}const Zy=["holding","challenged","invalidated","confirmed"],ew=e=>Zy.includes(e),tw=te.labelPrefix,_c=" -->",nw=7e4,kp=e=>`<!-- ${tw}:${e} `,sw=e=>JSON.stringify(e).replace(/--/g,"-\\u002d"),iw=(e,t)=>`${kp(e)}${t}${_c}`;function rw(e,t){const s=e.trimEnd();if(!s.endsWith(_c))return;const o=kp(t),a=s.lastIndexOf(o);if(!(a===-1||s.length-a>nw))return{before:s.slice(0,a),payload:s.slice(a+o.length,-_c.length)}}const ow=/[\u0000-\u001f\u007f-\u009f\u2028\u2029\u200b\u2060\ufeff\u202a-\u202e\u2066-\u2069]/,aw=/[\u0000-\u001f\u007f-\u009f\u2028\u2029\u200b\u2060\ufeff\u202a-\u202e\u2066-\u2069]+/g,lw=/\r\n|[\r\u0085\u2028\u2029]/g,cw=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u0084\u0086-\u009f\u200b\u2060\ufeff\u202a-\u202e\u2066-\u2069]/g,uw=e=>ow.test(e),Hs=e=>e.replace(aw," ").trim(),dw=e=>e.replace(lw,`
41
+ `).replace(cw,"");function Zo(e,t){const s=new RegExp(`^\\\\*(?:${t})`);return dw(e).trim().split(`
42
+ `).map(o=>s.test(o)?`\\${o}`:o).join(`
43
+ `)}function Oo(e,t){const s=new RegExp(`^\\\\+(?:${t})`);return e.split(`
44
+ `).map(o=>s.test(o)?o.slice(1):o).join(`
45
+ `)}const yp=te.labelPrefix,hw=new RegExp(`<(\\\\*)!--(?=\\s*${yp}:)`,"g"),fw=new RegExp(`<\\\\(\\\\*)!--(?=\\s*${yp}:)`,"g"),ea=e=>e.replace(hw,"<\\$1!--"),Us=e=>e.replace(fw,"<$1!--"),wp="asm",mw=/^-\s+(?:\[([a-z]+)\]\s+)?/,pw=1e3;function gw(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,pw)}}:{},...e.decidedBy?{decidedBy:e.decidedBy}:{}};return`- [${e.status}] ${ea(Hs(e.text))} ${iw(wp,sw(t))}`}function vw(e){const t=e.map(kw);let s=Math.max(0,...t.map(o=>ww(o.id)))+1;return t.map(o=>o.id?o:{...o,id:`S-${s++}`})}function kw(e){const t=rw(e,wp),s=t?t.before:e,o=s.match(mw),a=o==null?void 0:o[1],c=Us(s.slice(o?o[0].length:0).trim()),d=yw(t==null?void 0:t.payload);return{id:d.id??"",text:c,status:ew(a)?a:"holding",tickets:Array.isArray(d.tickets)?d.tickets.map(String):[],...d.source?{source:d.source}:{},...d.challenge?{challenge:d.challenge}:{},...d.decidedBy?{decidedBy:d.decidedBy}:{}}}function yw(e){if(!e)return{};try{const t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}function ww(e){const t=e==null?void 0:e.match(/^S-(\d+)$/);return t?Number(t[1]):0}const xp=[["destination","Destination"],["notes","Notes"],["assumptions","Assumptions"],["decisions","Decisions so far"],["unspecified","Not yet specified"],["outOfScope","Out of scope"]],xw=Object.fromEntries(xp),jp="##\\s",Ff=e=>ea(Zo(e.trim(),jp)),Uf=e=>Oo(Us(e),jp),Wf=e=>ea(Hs(e)),jw=/^-\s+(?:\[?([#A-Z0-9-]+)\]?:?\s+)?(.*)$/;function Sw(e){var o;const t=a=>a.length?a.map(c=>`- ${Wf(c)}`).join(`
46
+ `):"_None yet._",s=a=>a.length?a.map(c=>`- ${c.ticketKey?`${Hs(c.ticketKey)}: `:""}${Wf(c.text)}`).join(`
47
+ `):"_None yet._";return[`## Destination
48
+
49
+ ${Ff(e.destination)}`,`## Notes
50
+
51
+ ${Ff(e.notes)||"_None yet._"}`,...(o=e.assumptions)!=null&&o.length?[`## Assumptions
52
+
53
+ ${e.assumptions.map(gw).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 Nw(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
+ `),d=a.slice(0,c===-1?void 0:c).trim().toLowerCase(),h=(c===-1?"":a.slice(c+1)).trim(),m=(o=xp.find(([,k])=>k.toLowerCase()===d))==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=Uf(h):m==="notes"?t.notes=p?"":Uf(h):m==="assumptions"?t.assumptions=vw(v):m==="decisions"?t.decisions=v.map(k=>{const x=k.match(jw);return x&&x[1]&&/\d/.test(x[1])?{ticketKey:x[1],text:Us(x[2])}:{text:Us(k.slice(2))}}):t[m]=v.map(k=>Us(k.slice(2)))}return t}const ta={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"]},bw=(e,t)=>`${e[0].toUpperCase()}${e.slice(1)} ${t}/${ta[e].length}`;async function Cw(e,t,s={}){var d,h,m;const o=$w(t,t.mode??ds),a=await e.createMap({title:o.title,mode:o.mode,sections:o.sections,...o.verification?{verification:o.verification}:{}});await((d=s.onMapCreated)==null?void 0:d.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 $w(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 Tw{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 Le extends Error{}const Ew={frontier:"ready",blocked:"backlog",parked:"backlog",claimed:"working",verifying:"verifying",rework:"rework",held:"blocked",decided:"done","out-of-scope":"cancelled"};function Aw(e,t,s=ds){return Ew[gp(e,t,s)]}const Iw=["backlog","ready","working","verifying","rework","blocked"],Ki=["agent","trail lead"],Mw=[{event:"claim",from:["ready","rework"],to:["working"],actors:Ki},{event:"release",from:["working"],to:["ready","rework"],actors:Ki},{event:"expire",from:["working"],to:["ready","rework"],actors:["engine","trail lead"]},{event:"complete",from:["backlog","ready","working","rework"],to:["done"],actors:Ki},{event:"submit",from:["working"],to:["verifying"],actors:Ki},{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:Iw,to:["cancelled"],actors:[...Ki,"engine"]},{event:"reopen",from:["done","cancelled"],to:["ready"],actors:["trail lead"]}],Rw=e=>Mw.find(t=>t.event===e),Lw=new Tw;function Ow(e,t,s){if(s){if(!e.to.includes(s))throw new Le(`${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 Le(`${e.event} needs a target: ${e.to.join(" or ")}`)}async function Pw(e,t,s,o){const{to:a,actor:c}=o,d=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 d(a==="rework"?"rework":null),s.assignee&&await e.assign(t,s.id,null);return;case"verifying":case"blocked":await d(a);return;case"done":case"cancelled":await d(null),await e.close(t,s.id,a==="done"?"completed":"not_planned");return;case"backlog":throw new Le("backlog follows from blockers; no transition leads there")}}function na(e,t,s,o){return Lw.run(`${t}/${s}`,async()=>{var p;const a=await e.loadMap(t),c=a.tickets.find(v=>v.id===s);if(!c)throw new Le(`ticket ${s} not found`);const d=Aw(c,new Map(a.tickets.map(v=>[v.id,v])),a.map.mode);if(o.expect&&d!==o.expect)throw new Le(`${c.key} changed: it is ${d} now`);const h=Rw(o.event);if(!h.from.includes(d))throw new Le(`${c.key} is ${d}; ${o.event} needs ${h.from.join(" or ")}`);if(!h.actors.includes(o.actorKind))throw new Le(`${o.event} is not for ${o.actorKind}s`);const m=Ow(h,c,o.to);await Pw(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:d,to:m,actor:o.actor,actorKind:o.actorKind,...o.reason?{reason:o.reason}:{},...o.sessionId?{sessionId:o.sessionId}:{}}))}catch{}return{ticket:c,from:d,to:m}})}async function Hf(e,t,s,o){const{assignee:a}=o,c=await e.loadMap(t),d=c.tickets.find(v=>v.id===s);if(!d)throw new Le(`ticket ${s} not found`);const h=Js(c.tickets,c.map.mode).get(s);if(h!=="frontier"&&h!=="rework")throw new Le(`${d.key} is ${h}, not on the frontier`);await na(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 Le(`${d.key} was claimed by ${p.assignee}`);return p}async function _w(e,t,s,o={}){const c=(await e.loadMap(t)).tickets.find(d=>d.id===s);if(!c)throw new Le(`ticket ${s} not found`);await na(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})}const Dw=e=>e==="lookout",zw=e=>e.via==="chat"?`in ${e.chatOf??"an agent"}'s chat`:void 0;function Bw(e){return e.via?e.via==="chat"&&e.chatOf?{via:e.via,chatOf:e.chatOf}:{via:e.via}:{}}async function Sp(e,t){const s=e.via??(e.sourceKind==="slack"?"slack":void 0);if(!s||Dw(s)||!t.ticketId)return;const o=t.key??t.ticketId;if(!e.highRisk)throw new Le(`Can't tell whether ${o} is high risk: decide it in the Lookout.`);if(await e.highRisk(t.mapId,t.ticketId))throw new Le(`${o} is high risk: decide it in the Lookout. Answers given in Slack don't count for it.`)}async function uu(e,t,s,o={}){if(await Sp({...o.guard,sourceKind:s.source.kind},{mapId:t,ticketId:s.ticketId,key:s.ticketKey}),s.source.ref){const c=(await e.listDecisions(t)).find(d=>!d.postedBy&&d.source.kind===s.source.kind&&d.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 Fw(e,t,s,o){const c=(await e.listDecisions(t)).find(k=>k.id===s);if(!c)throw new Le(`decision ${s} not found`);if(c.postedBy)throw new Le(`${c.id} is ${c.postedBy}'s decision; record your own instead`);if(c.supersededBy)throw new Le(`${c.id} is already superseded by ${c.supersededBy}`);const d=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,d.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:d.ticketId,ticketKey:d.ticketKey,text:d.summary};return await e.updateMapSections(t,{decisions:p<0?[...m,v]:m.map((k,x)=>x===p?v:k)}),d}async function Uw(e,t,s){await e.setMapMode(t,s)}function Np(e){return e==="plan-only"?Ro.filter(t=>t!=="execute"):Ro}function Ww(e,t){if(!Np(e).includes(t))throw new Le(`${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),Hw=e=>e in Gn,bp=" (unverified, from text)";function Zi(e){return e.derived||e.decidedBy.endsWith(bp)?"unverified":e.postedBy?"teammate":e.source.kind==="agent"&&e.decidedBy!=="trail lead"&&!e.decidedBy.startsWith("slack:")?"agent":"human"}const Cp=e=>e.postedBy?`posted by ${e.postedBy} in ${e.postedIn??"the tracker"}`:void 0,rr=e=>e.supersededBy?"superseded":"active";function sa(e){const t=e.replace(/\s+/g," ").trim(),s=t.match(/^(.{20,180}?[.!?])(\s|$)/);return s?s[1]:t.slice(0,180)}function Kw(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())||sa(s.answer),alternatives:s.alternatives??[],rationale:s.rationale??"",participants:s.participants??[{id:s.decidedBy}],transcript:s.transcript??[]}}const Vw=e=>Number(e.replace(/\D/g,""))||0;function Gw(e,t){const s=new Map(e.map(d=>[d.id,d])),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 d=a;d&&!o.has(d.id);d=d.supersededBy?s.get(d.supersededBy):void 0)o.add(d.id),c.push(d);return c}async function qw(e,t,s,o){var d,h;const c=(await e.loadMap(t)).tickets.find(m=>m.id===s);if(!c)throw new Le(`ticket ${s} not found`);if(c.state==="closed")throw new Le(`${c.key} is already closed`);return await Sp({...o.guard,sourceKind:(h=(d=o.decision)==null?void 0:d.source)==null?void 0:h.kind},{mapId:t,ticketId:c.id,key:c.key}),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 na(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"}:{}}),await uu(e,t,Qw(c,o),{trailLine:o.trailLine,guard:o.guard}),c}function Qw(e,t){var o;const s=t.decision??{};return{ticketId:e.id,ticketKey:e.key,question:s.question??e.title,answer:s.answer??t.answer,summary:s.summary??t.summary??sa(t.answer),alternatives:s.alternatives,rationale:s.rationale,decidedBy:s.decidedBy??t.author,participants:s.participants,source:s.source??{kind:"agent",label:t.author},transcript:s.transcript,...s.risk?{risk:s.risk}:{},...(o=s.assumes)!=null&&o.length?{assumes:s.assumes}:{}}}async function Yw(e,t,s,o){const a=await e.loadMap(t);if(!a.map.sections.unspecified.includes(s))throw new Le(`"${s}" is not in Not yet specified`);Ww(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 d=await e.loadMap(t);return await e.updateMapSections(t,{unspecified:d.map.sections.unspecified.filter(h=>h!==s)}),c}async function Jw(e,t,s,o){const a=await e.loadMap(t),{unspecified:c,outOfScope:d}=a.map.sections;if("unspecified"in s){if(!c.includes(s.unspecified))throw new Le(`"${s.unspecified}" is not in Not yet specified`);await e.updateMapSections(t,{unspecified:c.filter(p=>p!==s.unspecified),outOfScope:[...d,`${s.unspecified} — ${o.reason}`]});return}const h=a.tickets.find(p=>p.id===s.ticketId);if(!h)throw new Le(`ticket ${s.ticketId} not found`);await e.comment(t,h.id,o.author,`**Ruled out of scope**
74
+
75
+ ${o.reason}`),await na(e,t,h.id,{event:"cancel",actor:o.author,actorKind:o.actorKind??"agent",reason:o.reason,sessionId:o.sessionId,journal:o.journal}),await uu(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 Le('"enabled" must be true or false');for(const[t,s]of Object.entries(e.tiers??{})){if(!Xo.includes(t))throw new Le(`unknown ticket type "${t}"`);if(!vp(s))throw new Le(`"${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 $p={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($p));const nx=2*6e4,gc=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 ${gc(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 ${gc(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 ${gc(t-e.lastOkAt)}`,title:`PR/CI synced${s}, ${o}`}}class Ks{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)}`,Dc=(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)}:{}}),Tp=(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 rx(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,d,h){const m=ta[s][c-1];e.patchSession(t.id,{step:c,stepLabel:m,...h?{ticketId:h}:{}}),a({tag:bw(s,c),level:"step",text:d?`${m}: ${d}`:m,ticketId:h??o().ticketId})},log(c,d="info"){a({level:d,text:c,ticketId:o().ticketId})},say(c){e.chat({sessionId:t.id,ticketId:o().ticketId,from:"agent",author:t.agent,text:c})},ask(c,d,h){var p;const m={id:Io("q"),sessionId:t.id,mapId:t.mapId,ticketId:o().ticketId,agent:t.agent,text:c,suggestions:d,at:Date.now(),...h!=null&&h.urgency?{urgency:h.urgency}:{},...(p=h==null?void 0:h.blocks)!=null&&p.length?{blocks:h.blocks}:{}};return e.chat({sessionId:t.id,ticketId: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,d,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:d??(c?"Session closed":"Session aborted"),signal:h==null?void 0:h.signal})},bindMap(c){var h;const d=o().usage;d&&(e.addMapUsage(c,d),(h=e.ledger())==null||h.add(c,d,t.id)),e.patchSession(t.id,{mapId:c})},usage(c){var m;const d=o().mapId;(m=e.ledger())==null||m.add(d,c,t.id),e.addMapUsage(d,c);const h=o().usage;e.patchSession(t.id,{usage:{...Dc(h,c),source:c.source??(h==null?void 0:h.source)}})},setUsage(c){var v;const d=o().usage,h=Tp(c,d);if(!h.inputTokens&&!h.outputTokens&&!h.costUsd&&!h.cachedInputTokens&&(d==null?void 0:d.source)===c.source&&`${d==null?void 0:d.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,d){const h=o();h.model===c&&h.tier===d||e.patchSession(t.id,{model:c,tier:d})}}}class ox{constructor(t=400,s){ce(this,"state",{sessions:[],feed:[],chats:[],pending:[],answered:[],usageByMap:{}});ce(this,"changes",new Ks);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]:Dc(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=te.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){var p;const c=this.state.pending.find(v=>v.id===t),d=this.resolvers.get(t),h=!!c&&this.remote.has(c.sessionId)&&!!this.remoteAnswer;if(!c||!d&&!h)return!1;this.resolvers.delete(t);const m=Bw(a);return this.chat({sessionId:c.sessionId,ticketId:c.ticketId,from:"human",author:o,text:s,...m}),this.set({pending:this.state.pending.filter(v=>v.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}:{},...(p=c.categories)!=null&&p.length?{categories:c.categories}:{},...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}`}),d?d(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=Tp(s.usage,a);(v.inputTokens||v.outputTokens||v.costUsd)&&(c={...c,[s.mapId]:Dc(c[s.mapId],v)}),(p=this.ledger)==null||p.addTotal(s.mapId,o,s.usage)}const d=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:[...d(this.state.chats),...t.chats].sort((v,k)=>v.at-k.at).slice(-600),pending:[...d(this.state.pending),...t.pending],answered:[...this.state.answered,...t.answered.filter(v=>!h.has(v.id))].sort((v,k)=>v.answeredAt-k.answeredAt).slice(-200),feed:[...this.state.feed.filter(v=>v.sessionId!==o),...t.feed].sort((v,k)=>v.at-k.at).slice(-this.maxFeed),usageByMap:c})}isRemote(t){return this.remote.has(t)}startSession(t){const s={...t,id:t.id??Io("s"),step:0,total:ta[t.mode].length,stepLabel:"BOOT",status:"running",startedAt:Date.now()};this.set({sessions:[...this.state.sessions,s].slice(-24)});const o=rx(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 ax(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 ${ru}`};case"map.updated":return{source:"tracker",level:"info",text:`Trail updated${e.section?` · ${xw[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 lx=new Set(["createMap","setMapMode","setMapMeta","updateMapSections","createTicket","addBlocking","removeBlocking","editTicket","reopen","assign","comment","close","setMeta","createDecision","markSuperseded"]),cx=5*6e4;function ux(e){let t={status:"idle",inflight:0,writes:0,errors:0,events:[]};const s=new Ks,o=c=>{t={...t,...c},s.emit(t)};return e.subscribe(c=>{const d=c.at-cx;o({events:[...t.events.filter(h=>h.at>=d),{at:c.at,external:c.kind==="external.changed"||"external"in c&&!!c.external}]})}),{adapter:new Proxy(e,{get(c,d,h){const m=Reflect.get(c,d,h);return typeof m!="function"?m:lx.has(d)?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 Ep(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 Js(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 Ap(e){const t=Ep(e);return{decided:t.decided,total:t.total-t["out-of-scope"]}}function dx(e){const t=new Map(e.tickets.filter(d=>d.state==="open").map(d=>[d.id,d])),s=new Map,o=new Set,a=d=>{if(s.has(d))return s.get(d);if(o.has(d))return[];o.add(d);const h=t.get(d);let m=[];for(const v of h.blockedBy)if(t.has(v)){const k=a(v);k.length>m.length&&(m=k)}o.delete(d);const p=[...m,h];return s.set(d,p),p};let c=[];for(const d of t.keys()){const h=a(d);h.length>c.length&&(c=h)}return c}function hx(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 fx(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 Ip(e,t){return t&&e.usageByMap[t]||{inputTokens:0,outputTokens:0,costUsd:0}}const mx=e=>e.usage?e.usage.inputTokens+e.usage.outputTokens:0,Mp={"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 Rp(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 px(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 gx(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**")),d=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?px(m.body,m.createdAt):[];return{id:`T${a.key}`,mapId:e.map.id,ticketId:a.id,ticketKey:a.key,question:a.title,answer:d,summary:sa(d),alternatives:[],rationale:"",decidedBy:`${h}${bp}`,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 vx(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||Zi(a)===t.madeBy)&&(!t.status||rr(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 kx(e,t=Date.now()){const s=Object.fromEntries(Po.map(d=>[d,0]));let o=0,a=0,c=0;for(const d of e){s[d.source.kind]++,d.supersededBy&&o++,t-d.decidedAt<864e5&&a++;const h=Zi(d);(h==="human"||h==="agent"&&d.transcript.some(m=>m.from==="human"))&&c++}return{total:e.length,active:e.length-o,superseded:o,last24h:a,human:c,bySource:s}}function ia(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(),d=o.slice(a+1).trim();Vy(c)&&(s[c]=d.startsWith("[")?xx(d.slice(1,-1)).map(Vf).filter(Boolean):Vf(d))}return{front:s,body:t[2]}}const yx=e=>e===""||/^[\s#&*!|>'"%@`[\]{},?:-]|[:#]\s|\s$|,|["\\[\]]/.test(e)||uw(e)||/^(true|false|null|~|\d[\d.e+-]*)$/i.test(e),wx=e=>JSON.stringify(e).replace(/[\u007f\u0085\u2028\u2029]/g,t=>`\\u${t.charCodeAt(0).toString(16).padStart(4,"0")}`),Kf=e=>yx(e)?wx(e):e;function Vf(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 xx(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 jx(e){if(!/^[\w-]+$/.test(e))throw new Error(`invalid frontmatter key: ${JSON.stringify(e)}`);return e}function du(e,t){return`---
81
+ ${Object.entries(e).map(([o,a])=>`${jx(o)}: ${Array.isArray(a)?`[${a.map(Kf).join(", ")}]`:Kf(a)}`).join(`
82
+ `)}
83
+ ---
84
+
85
+ ${t.trim()}
86
+ `}const we=e=>Array.isArray(e)?e.join(","):e??"";function Gt(e){return Array.isArray(e)?e:e?[e]:[]}const Ws=e=>Date.parse(we(e))||0,an=e=>new Date(e).toISOString(),Lp=["schema","breaking-api","auth-permissions","billing","data-deletion","product-behaviour","dependencies"],Op=["low","medium","high"],Sx=e=>Lp.includes(e),Nx=e=>Op.includes(e);function bx(e){return e?{risk:e.level,...e.category?{risk_category:e.category}:{},risk_reason:e.reason}:{}}function Cx(e){const t=we(e.risk);if(!Nx(t))return{};const s=we(e.risk_category);return{risk:{level:t,...Sx(s)?{category:s}:{},reason:we(e.risk_reason)}}}const Pp=["Question","Decision","Summary","Alternatives","Rationale","Transcript"],hu=`## (?:${Pp.join("|")})\\s*$`,_p=`${hu}|### `,wo=e=>Zo(e.trim(),hu),$x=e=>e.name?`${e.id}|${e.name}`:e.id,Tx=e=>{const t=e.indexOf("|");return t<0?{id:e}:{id:e.slice(0,t),name:e.slice(t+1)}};function Dp(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:an(e.decidedAt),participants:e.participants.map($x),source:e.source.kind,...e.source.ref?{source_ref:e.source.ref}:{},...e.source.url?{source_url:e.source.url}:{},...e.source.label?{source_label:e.source.label}:{},...e.source.meta?{source_meta:Object.entries(e.source.meta).map(([d,h])=>`${d}=${h}`)}:{},...e.supersedes?{supersedes:e.supersedes}:{},...e.supersededBy?{superseded_by:e.supersededBy}:{},...bx(e.risk),...(c=e.assumes)!=null&&c.length?{assumes:e.assumes}:{}},s=d=>d.length?d.map(h=>`- ${Hs(h)}`).join(`
87
+ `):"_None._",o=e.transcript.length?e.transcript.map(d=>`### ${Hs(d.author)} · ${d.from} @ ${an(d.at)}
88
+
89
+ ${Zo(d.text.trim(),_p)}`).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 du(t,a)}function zc(e){const{front:t,body:s}=ia(e),o={},a=new RegExp(`^## (${Pp.join("|")})\\s*$`,"gm"),c=[...s.matchAll(a)];c.forEach((k,x)=>{var I;const j=s.slice(k.index+k[0].length,((I=c[x+1])==null?void 0:I.index)??s.length).trim(),b=k[1],S=b==="Transcript"?j:Oo(j,hu);o[b]=/^_none\._$/i.test(j)?"":S});const d=(o.Transcript??"").split(/^### /m).slice(1).map(k=>{const x=k.indexOf(`
106
+ `),j=x<0?k:k.slice(0,x),b=j.lastIndexOf(" @ "),S=b<0?j:j.slice(0,b),I=b<0?"":j.slice(b+3),C=S.lastIndexOf(" · "),R=C<0?S:S.slice(0,C),O=C<0?"agent":S.slice(C+3);return{author:R.trim(),from:["agent","human","system"].includes(O.trim())?O.trim():"agent",at:Date.parse(I)||0,text:x<0?"":Oo(k.slice(x+1).trim(),_p)}}),h=we(t.source),m=Gt(t.source_meta),p={kind:Hw(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||sa(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:Ws(t.decided_at),participants:Gt(t.participants).map(Tx),source:p,supersedes:we(t.supersedes)||void 0,supersededBy:we(t.superseded_by)||void 0,...Gt(t.assumes).length?{assumes:Gt(t.assumes)}:{},transcript:d,...Cx(t)}}function Ex(e){return e.url?` · [${e.label??"link"}](${e.url})`:e.label?` · ${e.label}`:""}function Ax(e,t,s={}){const o=[`# ${s.title??"Decisions"}`,"",`Exported ${an(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,d]of a){const h=t[c];o.push("",`## Trail ${h?`${h.key} ${h.title}`:c}`);for(const m of d){const p=Gn[m.source.kind].label;o.push("",`### ${m.id}${m.ticketKey?` · ${m.ticketKey}`:""} · ${m.question}`,"",`- **Status:** ${rr(m)}${m.supersededBy?` (superseded by ${m.supersededBy})`:""}${m.supersedes?` · supersedes ${m.supersedes}`:""}`,`- **Decided by:** ${m.decidedBy} · ${an(m.decidedAt)}`,`- **Source:** ${p}${Ex(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 Bc(e,t,s){try{const o=e.get(t);return o?JSON.parse(o):s}catch{return s}}class Gf{constructor(t,s="presence"){ce(this,"seen");this.store=t,this.key=s,this.seen=Bc(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 vc=5*6e4,Ix=14*864e5;class qf{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=Bc(t,s,{}),this.totals=Bc(t,`${s}.totals`,{})}addTotal(t,s,o,a=Date.now()){const c=this.totals[s],d={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},d.inputTokens>0||d.outputTokens>0||d.costUsd>0?this.add(t,d,s,a):this.save()}add(t,s,o,a=Date.now()){var m;if(!t)return;const c=Math.floor(a/vc)*vc,d=(m=this.buckets)[t]??(m[t]=[]);let h=d.find(p=>p.at===c);h||(h={at:c,i:0,o:0,c:0,s:[]},d.push(h),d.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+vc<=s||(o.inputTokens+=c.i,o.outputTokens+=c.o,o.costUsd+=c.c,c.s.forEach(d=>a.add(d)));return o.sessions=a.size,o}save(){this.dirty=!0,!this.timer&&(this.timer=setTimeout(()=>{if(this.timer=void 0,!this.dirty)return;this.dirty=!1;const t=Date.now()-Ix;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 Mx(e){const t=e.now??Date.now(),s=e.snaps.map(d=>{var ie;const h=d.map.id,m=e.since(h),p=G=>!!G&&G>=m,v=Js(d.tickets,d.map.mode),k=new Map(d.tickets.map(G=>[G.id,G])),x=(e.attention??[]).filter(G=>G.mapId===h),j=Rx(e.activity.pending.filter(G=>G.mapId===h),x),b=new Set(j.map(G=>G.ticketId)),S=G=>G.state==="open"&&(b.has(G.id)||ir(G)==="hitl"),I=d.tickets.filter(G=>v.get(G.id)==="blocked").map(G=>({ticket:G,on:G.blockedBy.map(ve=>k.get(ve)).filter(ve=>!!ve&&S(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=d.tickets.filter(G=>G.state==="closed"&&p(G.closedAt)).sort((G,ve)=>(G.closedAt??0)-(ve.closedAt??0)),O=R.filter(G=>G.closeReason==="completed"),U=R.filter(G=>G.closeReason==="not_planned"),X=d.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:d.map.key,title:d.map.title,since:m,done:O,ruledOut:U,opened:X,blocked:I,waiting:j,needsYou:x,decisions:C,agentDecisions:C.filter(G=>Zi(G)==="agent"),usage:Q,active:W,changed:!!(R.length||X.length||C.length||j.some(G=>p(G.at))||Q.costUsd>0)}}),o=s.filter(d=>d.changed||d.waiting.length).sort((d,h)=>+(h.mapId===e.currentMapId)-+(d.mapId===e.currentMapId)),a=d=>o.reduce((h,m)=>h+m[d].length,0),c=o.flatMap(d=>d.waiting).reduce((d,h)=>d===void 0||h.at<d?h.at:d,void 0);return{since:o.length?Math.min(...o.map(d=>d.since)):t,now:t,trails:o,totals:{done:a("done"),ruledOut:a("ruledOut"),blocked:a("blocked"),waiting:a("waiting"),oldestWaitMs:c===void 0?void 0:t-c,agentDecisions:a("agentDecisions"),usage:o.reduce((d,h)=>({inputTokens:d.inputTokens+h.usage.inputTokens,outputTokens:d.outputTokens+h.usage.outputTokens,costUsd:d.costUsd+h.usage.costUsd,sessions:d.sessions+h.usage.sessions}),{inputTokens:0,outputTokens:0,costUsd:0,sessions:0}),active:a("active")},changed:s.some(d=>d.changed)}}function Rx(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 Qi=(e,t,s=`${t}s`)=>`${e} ${e===1?t:s}`;function Lx(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 Ox(e){return e.length===1?`, and it holds up ${e[0].ticket.title.replace(/^./,t=>t.toLowerCase())}`:e.length>1?`, holding up ${Qi(e.length,"ticket")}`:""}function Px(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(`${Qi(s.done,"ticket")} ${s.done===1?"is":"are"} done.`),s.agentDecisions&&c.push(`Agents made ${Qi(s.agentDecisions,"decision")}.`),s.waiting){const d=Ox(Lx(e));c.push(`${Qi(s.waiting,"decision")} ${s.waiting===1?"is":"are"} waiting on you${d}.`)}else c.push("Nothing is waiting on you.");return!s.done&&!s.agentDecisions&&s.ruledOut&&c.unshift(`${Qi(s.ruledOut,"ticket")} ruled out of scope.`),[a,...c].join(" ")}const _x=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 Dx(e){return e.state==="open"?"open":e.closeReason==="not_planned"?"cancelled":"done"}function zp({snap:e,journal:t,answered:s,usage:o}){const a=e.map.id,c=t.filter(S=>S.mapId===a).sort((S,I)=>S.at-I.at),d=new Map;for(const S of c)d.set(S.ticketId,[...d.get(S.ticketId)??[],S]);const h=e.tickets.filter(S=>S.type!=="review").map(S=>{var U;const I=d.get(S.id)??[],C=Dx(S),R=(U=I.find(X=>X.event==="claim"))==null?void 0:U.at,O=C==="done"?S.closedAt:void 0;return{id:S.id,key:S.key,title:S.title,type:S.type,outcome:C,claimedAt:R,doneAt:O,leadMs:O&&R&&O>=R?O-R:void 0,reworks:I.filter(X=>X.to==="rework").length,reviews:{passed:I.filter(X=>X.event==="review.pass").length,failed:I.filter(X=>X.event==="review.fail").length,needsHuman:I.filter(X=>X.event==="review.needs_human").length},operatorActions:I.filter(X=>X.actorKind==="trail lead").length}}),m=h.filter(S=>S.outcome==="done"),p=Math.max(0,...m.map(S=>S.doneAt??0)),v=c.filter(S=>S.actorKind==="trail lead"),k=new Set(s.filter(S=>S.mapId===a).map(S=>S.id)).size,x=v.length,j=S=>h.reduce((I,C)=>I+S(C),0),b=(o==null?void 0:o.costUsd)??0;return{mapId:a,tickets:h,done:m.length,cancelled:h.filter(S=>S.outcome==="cancelled").length,open:h.filter(S=>S.outcome==="open").length,trailLeadMs:p&&p>=e.map.createdAt?p-e.map.createdAt:void 0,medianLeadMs:_x(m.flatMap(S=>S.leadMs===void 0?[]:[S.leadMs])),interventions:{answers:k,operatorActions:x,reworkRequested:v.filter(S=>S.event==="reject").length,total:k+x},rework:{tickets:h.filter(S=>S.reworks>0).length,cycles:j(S=>S.reworks)},reviews:{passed:j(S=>S.reviews.passed),failed:j(S=>S.reviews.failed),needsHuman:j(S=>S.reviews.needsHuman)},spend:{costUsd:Math.round(b*1e4)/1e4,tokens:((o==null?void 0:o.inputTokens)??0)+((o==null?void 0:o.outputTokens)??0),perVerifiedTicketUsd:m.length&&b?Math.round(b/m.length*1e4)/1e4:void 0}}}const kc=e=>e.split("-")[0];function ln(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 Qf=e=>e===void 0?"—":`$${e.toFixed(e<1?4:2)}`;function zx(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) | ${ln(e.trailLeadMs)} |`,`| Median ticket lead time (claim → done) | ${ln(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 | ${Qf(e.spend.costUsd)} · ${e.spend.tokens.toLocaleString("en-US")} tokens |`,`| Cost per verified ticket | ${Qf(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} | ${ln(c.leadMs)} | ${c.reworks} | ${c.reviews.passed}/${c.reviews.failed} | ${c.operatorActions} |`),""].join(`
112
+ `)}const fu=5,Bp=1.5,Bx=15,xo=e=>Math.round(e*100);function Fx(e){const t=e.filter(d=>d.findings.raised>=fu).sort((d,h)=>h.findings.upheld/h.findings.raised-d.findings.upheld/d.findings.raised||d.key.localeCompare(h.key));if(t.length<2)return[];const[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)<Bx?[]:[{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 Ux(e){const t=c=>c.reworkCycles/c.tickets,s=e.filter(c=>c.tickets>=fu).sort((c,d)=>t(c)-t(d)||c.key.localeCompare(d.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)*Bp?[]:[{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 Wx(e,t){const s=d=>d.medianLeadMs??0,o=t.filter(d=>d.done>=fu&&d.medianLeadMs!==void 0).sort((d,h)=>s(d)-s(h)||d.key.localeCompare(h.key));if(o.length<2)return[];const[a,c]=[o[0],o[o.length-1]];return s(c)<s(a)*Bp?[]:[{id:`speed-${e}`,text:`${e} tickets: ${a.key} is faster, ${ln(a.medianLeadMs)} vs ${c.key} ${ln(c.medianLeadMs)}`,because:`Median first claim to done, over ${a.done} and ${c.done} done tickets`}]}function Hx(e){const t=Object.keys(e.byTypeAndVendor).sort();return[...Fx(e.byVendor),...Ux(e.byVendor),...t.flatMap(s=>Wx(s,e.byTypeAndVendor[s]))]}const Kx=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)},Fp=e=>{var t;return(t=e.filter(s=>s.event==="claim"&&s.actorKind==="agent").at(-1))==null?void 0:t.actor},Fc=(e,t,s)=>e.filter(o=>o.mapId===t&&o.ticketId===s).sort((o,a)=>o.at-a.at);function Vx(e,t){return e.tickets.flatMap(s=>{var k;if(s.type!=="review"||!s.reviewOf)return[];const o=Fc(t,e.map.id,s.id),a=Fp(o);if(!a)return[];const c=((k=o.filter(x=>x.event==="claim").at(-1))==null?void 0:k.at)??0,d=Fc(t,e.map.id,s.reviewOf),h=d.findIndex(x=>x.at>=c&&x.event.startsWith("review."));if(h<0||d[h].event!=="review.fail")return[];const m=d.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 Gx(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 Up(e,t){const s=a=>t.reduce((c,{ticket:d})=>c+a(d),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:Kx(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,Up(o,a)]))}const Uc=(e,t)=>{const s=e.get(t)??Up(t,[]);return e.set(t,s),s};function Yf(e,t,s){const o=Uc(e,t);o.findings.raised+=1,s&&(o.findings.upheld+=1)}const So=e=>[...e.values()].sort((t,s)=>s.tickets-t.tickets||t.key.localeCompare(s.key));function Wp(e){const t=e.flatMap(({snap:p,journal:v,answered:k,usage:x})=>zp({snap:p,journal:v,answered:k,usage:x}).tickets.map(j=>({ticket:j,agent:Fp(Fc(v,p.map.id,j.id))??Gx(p,j.id)}))),s=p=>p.agent?kc(p.agent):void 0,o=jo(t,p=>p.agent),a=jo(t,s),c=jo(t,p=>p.ticket.type),d=new Set;for(const{snap:p,journal:v,answered:k}of e){for(const x of k){const j=`${x.mapId}/${x.id}`;x.mapId!==p.map.id||d.has(j)||(d.add(j),Uc(o,x.agent).answers+=1,Uc(a,kc(x.agent)).answers+=1)}for(const x of Vx(p,v))Yf(o,x.reviewer,x.upheld),Yf(a,kc(x.reviewer),x.upheld)}const h=Object.fromEntries([...c.keys()].map(p=>[p,So(jo(t.filter(v=>v.ticket.type===p),s))])),m={trails:e.length,tickets:t.length,byAgent:So(o),byVendor:So(a),byType:So(c),byTypeAndVendor:h};return{...m,recommendations:Hx(m)}}const qx={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
+ `)},Qx=[["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"]],Vi=Object.fromEntries(Qx);function Yx(e,t){const s=new Set(e.map(o=>o.source).filter(Boolean));return t.filter(o=>!s.has(o))}const Jx=["architecture","convention","gotcha","dead-end","glossary","fact"],Hp=["business-rule","product-decision","persona","ux-principle","pricing"],Xx=[...Jx,...Hp],Zx=e=>e.status==="confirmed"||e.status==="assumption";function ej(e,t){return Xy(e,t.replace(/^\.\//,""),{segments:!0})}const tj={"business-rule":3,convention:3,"product-decision":2,architecture:2,gotcha:2,"dead-end":2,"ux-principle":2},nj=["business-rule","ux-principle","convention"],Jf=600,sj=e=>`flagged as possibly outdated by ${e}; the human is reviewing it`,ij=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(" ")),Xf=e=>new Set((e.toLowerCase().match(/[a-z0-9][a-z0-9_-]{2,}/g)??[]).filter(t=>!ij.has(t)));function Kp(e,t,s=4e3,o=()=>[]){const a=t.ticket?Xf(`${t.ticket.title} ${t.ticket.body}`):new Set,c=new Set((t.tags??[]).map(p=>p.toLowerCase())),d=e.filter(Zx).map(p=>{const v=[];let k=tj[p.kind]??1;for(const b of p.scope){const S=t.paths.find(I=>ej(b,I));if(S){k+=6,v.push(`path match ${b} (${S})`);break}}const x=p.tags.filter(b=>c.has(b.toLowerCase())||a.has(b.toLowerCase()));x.length&&(k+=3*x.length,v.push(`tag ${x.join(", ")}`));const j=[...Xf(p.title)].filter(b=>a.has(b));return j.length&&(k+=j.length,v.push(`mentions ${j.slice(0,3).join(", ")}`)),t.trailKey&&p.sources.includes(`trail:${t.trailKey}`)&&(k+=3,v.push("same trail")),t.discovery&&Hp.includes(p.kind)&&(k+=8,v.push("product context for discovery")),!v.length&&nj.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 d){const k=p.body.length>Jf?`${p.body.slice(0,Jf)}…`: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:sj(p.flag.by)}:{}})}return h}const rj=new RegExp("`([^`\\s]+/[^`\\s]+)`|(?:^|[\\s(])/?((?:[\\w.-]+/)+[\\w.-]+)","gm");function Vp(e){const t=new Set;for(const s of e.matchAll(rj))t.add((s[1]??s[2]).replace(/^\.?\//,"").replace(/[.,;:]+$/,""));return[...t]}const oj=[{level:"high",label:"High risk"},{level:"medium",label:"Medium risk"},{level:"low",label:"Low risk"},{level:"none",label:"No category"}];function aj(e){return oj.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 lj=1/3;function ra(e,t=Date.now()){const s=e.expiresAt-t;return s<=0?"expired":s<=e.ttlMs*lj?"stalled":"live"}function cj(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 uj=e=>e.urgency==="fyi"||e.kind==="policy";function dj(e){const t=e.filter(([s,o])=>Xo.includes(s)&&vp(o));return Object.fromEntries(t)}const Zf=e=>Number(e.slice(0,2))*60+Number(e.slice(3,5));function hj(e,t){const s=new Date(t),o=s.getHours()*60+s.getMinutes(),a=Zf(e.from),c=Zf(e.to),d=c<=a;if(!(d?o>=a||o<c:o>=a&&o<c))return!1;if(!e.days)return!0;const m=d&&o<c,p=(s.getDay()+(m?6:0))%7;return e.days.includes(p)}function fj(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 mj(e,t){const s=e.focusUntil??0;if(s>t)return{kind:"manual",until:s};if(!e.focus||!hj(e.focus,t))return{kind:"off"};const o=fj(e.focus,t);return(e.focusOffUntil??0)>t?{kind:"paused",until:o}:{kind:"hours",until:o}}function pj(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=mj(o,s);return a.kind==="hours"?{...o,focusOffUntil:a.until}:o}default:return t}}function gj(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 vj(e,t,s){const o=Date.now();return{id:e,key:t,...s,state:"open",blockedBy:[],comments:[],createdAt:o,updatedAt:o}}const kj=(e,t)=>({...e,blockedBy:e.blockedBy.filter(s=>s!==t)}),yj=(e,t)=>{var s;return{...e,...(s=t.title)!=null&&s.trim()?{title:t.title.trim()}:{},...t.body!==void 0?{body:t.body}:{}}};function wj(e){const{closeReason:t,closedAt:s,...o}=e;return{...o,state:"open"}}const xj=["status","verification","checks","reviewOf","guide"];function jj(e,t){const s={...e};for(const o of xj)t[o]!==void 0&&(t[o]===null?delete s[o]:s[o]=t[o]);return t.confirm&&delete s.settingsUnconfirmed,s}async function Gp(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(ia(await e.read(a)).front.key).replace(/\D/g,""))||0));return Math.max(0,...s,...o)+1}const qp="### [^\\n]* @ \\d{4}-\\d\\d-\\d\\dT",Qp=`## Comments\\s*$|${qp}`,Yp=`<!-- ${te.labelPrefix}:comments -->`,Sj=new RegExp(`^## Comments[ \\t]*\\n${Yp}[ \\t]*$`,"m"),Nj=new RegExp(`^(?=${qp})### `,"m"),mu=2,Jp=e=>ea(Zo(e,Qp)),em=e=>Oo(Us(e),Qp);function bj(e,t){const s=(t>=mu?Sj:/^## Comments\s*$/m).exec(e);return s?[e.slice(0,s.index),e.slice(s.index+s[0].length)]:[e,""]}function tm(e){const{front:t,body:s}=ia(e),o=Number(we(t.format))||1,[a,c]=bj(s,o),d=c.split(o>=mu?Nj:/^### /m).slice(1).map((v,k)=>{const x=v.indexOf(`
114
+ `),j=v.slice(0,x),b=j.lastIndexOf(" @ ");return{id:`c${k}`,author:j.slice(0,b<0?void 0:b).trim(),createdAt:b>=0&&Date.parse(j.slice(b+3))||0,body:em(v.slice(x+1).trim())}}),h=we(t.close_reason),m=Uy.find(v=>v===we(t.status)),p=pp(we(t.verification));return{id:we(t.id),key:`#${we(t.id)}`,title:we(t.title),type:we(t.type)||"task",hitl:Gt(t.labels).includes(ou)||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:Gt(t.checks)}:{},...we(t.review_of)?{reviewOf:we(t.review_of)}:{},...we(t.guide)?{guide:we(t.guide)}:{},blockedBy:Gt(t.blocked_by),body:em(a.trim()),comments:d,createdAt:Ws(t.created),updatedAt:Ws(t.updated),closedAt:Ws(t.closed)||void 0}}function Xp(e){const t={id:e.id,format:String(mu),title:e.title,type:e.type,labels:[Jo(e.type),...Dy(e.type)&&e.hitl?[ou]:[]],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:an(e.createdAt),updated:an(e.updatedAt),...e.closedAt?{closed:an(e.closedAt)}:{}},s=e.comments.length?`
115
+
116
+ ## Comments
117
+ ${Yp}
118
+
119
+ ${e.comments.map(Cj).join(`
120
+
121
+ `)}`:"";return du(t,Jp(e.body)+s)}function Cj(e){return`### ${Hs(e.author)} @ ${an(e.createdAt)}
122
+
123
+ ${Jp(e.body)}`}async function $j(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 Tj(e,t,s){const o=await Gp(e),a=vj(String(o),`#${o}`,s);return{path:`${t}/tickets/${a.id}.md`,text:Xp({...a,updatedAt:Date.now()}),value:a}}async function Ej(e,t,s){const o=(await e.list()).filter(d=>d.includes("/decisions/")),a=Math.max(0,...o.map(d=>Vw(d.split("/").pop())))+1,c=Kw(`D-${a}`,t,s);return{path:`${t}/decisions/${c.id}.md`,text:Dp(c),value:c}}const Aj=/^([^/]+)\/decisions\/([^/]+)\.md$/,Ij=(e,t)=>e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,40)||`map-${t}`,Zp=/^[A-Za-z0-9][A-Za-z0-9_-]*(?:\.[A-Za-z0-9_-]+)*$/;function cs(e){if(typeof e!="string"||e.length>128||!Zp.test(e))throw new Error(`not a valid id: ${JSON.stringify(e)}`);return e}const Mj=e=>{const t=e.match(/^[^/]+\/tickets\/([^/]+)\.md$/);return!!t&&Zp.test(t[1])};class Rj{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(d=>Aj.test(d)),a=[];for(const d of o){const h=await this.read(d).catch(()=>""),m=this.seen.get(d);if(!h||(m==null?void 0:m.text)===h)continue;const p=zc(h);this.seen.set(d,{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=d=>d.kind==="decision.recorded"?0:1;a.sort((d,h)=>c(d)-c(h));for(const d of a)this.emit(d)}}function Lj(e){const t=we(e["model-matching"]);if(t!=="on"&&t!=="off")return;const s=dj(Gt(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 Oj(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 nm(e,t){const{front:s,body:o}=ia(t),a=pp(we(s.verification)),c=Lj(s);return{id:e,key:we(s.key)||e,title:we(s.title)||e,mode:we(s.mode)==="plan-only"||Gt(s.labels).includes(au)?"plan-only":ds,...a?{verification:a}:{},...Gt(s.guides).length?{guides:Gt(s.guides)}:{},...c?{modelMatching:c}:{},sections:Nw(o),createdAt:Ws(s.created),updatedAt:Ws(s.updated)}}function Pj(e){var t;return du({key:e.key,title:e.title,mode:e.mode,...e.verification?{verification:e.verification}:{},...(t=e.guides)!=null&&t.length?{guides:e.guides}:{},...Oj(e.modelMatching),labels:[ru,...e.mode==="plan-only"?[au]:[]],created:an(e.createdAt),updated:an(e.updatedAt)},Sw(e.sections))}function _j(e,t){t.code!=="ENOENT"&&console.warn(`Teamtrail: decision ${e} can't be read: ${t.message}`)}class Dj{constructor(t,s=`./${te.dataDir}`){ce(this,"kind","markdown");ce(this,"label","Local markdown");ce(this,"events",new Ks);ce(this,"selfWrites",new Map);ce(this,"external",new Rj(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 $j(this.fs,t,s=>this.selfWrites.set(s,Date.now()))}async readMap(t){return nm(t,await this.fs.read(`${cs(t)}/map.md`))}async writeMap(t,s){await this.put(`${cs(t.id)}/map.md`,Pj(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(d=>d.startsWith(`${t}/tickets/`)&&Mj(d)),c=await Promise.all(a.map(async d=>tm(await this.fs.read(d))));return{map:o,tickets:c.sort((d,h)=>d.createdAt-h.createdAt)}}async createMap(t){const s=await Gp(this.fs),o=Ij(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(nm(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=>gj(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(()=>Tj(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=tm(a),d=o(c);d!==c&&await this.put(this.ticketPath(t,c.id),Xp({...d,updatedAt:Date.now()}),a)}async removeBlocking(t,s,o){await this.update(t,o,a=>kj(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=>yj(a,o)),this.events.emit({kind:"ticket.updated",mapId:t,ticketId:s,at:Date.now()})}async reopen(t,s){await this.update(t,s,wj),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=>jj(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=>_j(a,h));if(!c)return;const d={...zc(c),mapId:t};return this.external.knows(a)||this.external.remember(a,c,d.supersededBy),d});return(await Promise.all(o)).filter(a=>!!a)}async createDecision(t,s){const o=await this.putNew(async()=>{const a=await Ej(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),d=Dp({...zc(c),mapId:t,supersededBy:o});this.external.remember(a,d,o),await this.put(a,d,c),this.events.emit({kind:"decision.superseded",mapId:t,decisionId:s,supersededBy:o,at:Date.now()})}subscribe(t){return this.events.on(t)}}function Xs(e,t=[]){if(e)try{const{protocol:s}=new URL(e);return["http:","https:",...t].includes(s)?e:void 0}catch{return}}class sm extends Error{constructor(t,s,o,a){super(s),this.code=t,this.status=o,this.resetAt=a,this.name="TrackerError"}}const zj={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 sm("offline","Lookout server unreachable; is `teamtrail` still running?")}const a=await o.json().catch(()=>({}));if(!o.ok)throw new sm(a.code??"http",a.error??`request failed (${o.status})`,o.status,a.resetAt);return a}class Bj{constructor(t,s,o=""){ce(this,"label");ce(this,"location");ce(this,"status",{state:"connecting",queued:0});ce(this,"events",new Ks);ce(this,"statusEvents",new Ks);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=zj[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 Fj(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 Uj=[{id:"markdown",name:"Local markdown",status:"available"},{id:"github",name:"GitHub Issues",status:"available"},{id:"linear",name:"Linear",status:"available"}],eg=[{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"}],Wj=eg[0],Hj="https://github.com/teamtrailhq/teamtrail-guides",Kj="https://raw.githubusercontent.com/teamtrailhq/teamtrail-guides/main",Vj=`${Hj}/blob/main/CONTRIBUTING.md`,Gj=e=>e.slice(0,9),qj=/[a-z][\w+.-]*:\/\/(?!(localhost|127\.0\.0\.1)(:\d+)?(\/|$|\s))/i,Qj=/^[\w.-]+@[\w.-]+:/,Yj=/^(@[\w.-]+\/)?[\w./-]+@[\w^~<>=*.-]+$/,Jj=/(^|=)(npm|jsr|github|gitlab|bitbucket|git\+[a-z]+|https?):/i,Xj=/^--?(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,Zj={tar:/^-[A-Za-z]*[IF]/,zip:/^-TT|^--unzip-command/,make:/^-E|^--eval/,perl:/^-[A-Za-z]*M/};function e0(e,t){var s;if(qj.test(t)||Qj.test(t))return"names a remote address, so it reaches the network";if(Yj.test(t)&&!t.startsWith("-"))return`names a package to download (${t})`;if(Jj.test(t))return`names a package from a registry (${t})`;if(Xj.test(t))return`runs a command it's given (${t.split("=")[0]})`;if((s=Zj[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(t0.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 t0=/\|\s*(sh|bash|zsh|dash|ksh|fish|pwsh|node|python\d*|perl|ruby)\b|\$\(|`|;|&&|\|\||\b(curl|wget)\s/;function n0(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 s0(e,t){const s=n0(e,t);if(s)return s;for(const o of t){const a=e0(e,o);if(a)return a}}const i0=/^(-c|-e|-E|-ex|-x|-r|-command|-Command|-EncodedCommand)$|^--(eval|exec|command|expr|execute|run)(=|$)/,r0=/(^|[\s|'"=])[a-z0-9-]+(\.[a-z0-9-]+)*\.[a-z]{2,}(:\d+)?\/\S*/i;function o0(e,t){const s=e.find(o=>{var a;return i0.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=>r0.test(o)))return"names an address, so it may reach the network"}const a0=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"]),l0=new Set(["-C","--git-dir","--work-tree","--namespace","--super-prefix"]);function c0(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(l0.has(o)){s.includes("=")||t++;continue}if(s.startsWith("-"))continue;const a=s.toLowerCase();return a0.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 u0=["--require","--import","--loader","--experimental-loader","--env-file","--input-type"],im={inline:"ep",value:"rC",long:["--eval","--print"],longValue:u0},d0={node:im,nodejs:im,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 h0(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 f0(e,t){var a;if(/^data:|=data:/i.test(e))return"code";if(!e.startsWith("--"))return h0(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 m0(e,t){const s=d0[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=f0(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 rm=e=>new RegExp(`^(?![-/~\\\\])(?!.*\\.\\.)(?![a-zA-Z]:)[\\w./-]+\\.(${e})$`),Pt={},ut=e=>e.split(/\s+/).filter(Boolean),p0={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:rm("[cm]?[jt]s"),sub:["--test"]},python:{script:rm("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"]}},g0=/^(\.\/)?node_modules\/\.bin\/([\w.-]+)$/;function v0(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 tg(e){var o;const t=(o=g0.exec(e.argv0))==null?void 0:o[2],s=p0[t??e.program];return s&&v0(s,e.args)?s:void 0}const k0=e=>!!tg(e),oa=e=>new Set(e.split(/\s+/).filter(Boolean)),y0=oa(`
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
+ `),w0=oa(`
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
+ `),x0=oa("npx pnpx bunx uvx uv pipx docker podman nix nix-shell nix-env flatpak snap"),j0=oa(`
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
+ `),No=["exec","x","dlx","install","i","add","ci","create","init","update","upgrade"],S0={npm:new Set(No),pnpm:new Set(No),yarn:new Set(No),bun:new Set(No),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 N0(e){const t=(e.split(/[\\/]/).pop()??"").toLowerCase().replace(/\.(exe|cmd|bat|com)$/,"");return t.replace(new RegExp("(?<=[a-z])[\\d.-]+$"),"")||t}const b0=e=>{var t;return((t=e.find(s=>!s.startsWith("-")))==null?void 0:t.toLowerCase())??""};function om(e){const t=e.findIndex(s=>s.startsWith("-m"));if(!(t<0))return e[t]==="-m"?e[t+1]:e[t].slice(2)}const C0=new Set(["pip","ensurepip","pipx","uv","venv","http.server","webbrowser"]);function $0(e,t){var o;if(y0.has(e))return`runs a shell (${e}); name the program and its arguments instead`;if(w0.has(e))return`runs ${e}, which reaches the network`;if(x0.has(e))return`runs ${e}, which downloads and runs a package; use one installed in the repo`;if(j0.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=b0(t);if((o=S0[e])!=null&&o.has(s))return`runs ${e} ${s}, which downloads packages; use one installed in the repo`;if(e==="python"&&C0.has(om(t)??""))return`runs python -m ${om(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 ng(e){const t=e.run[0]??"";return{argv0:t,program:N0(t),args:e.run.slice(1)}}function T0(e){const{argv0:t,program:s,args:o}=ng(e),a=tg({argv0:t,program:s,args:o}),c=[$0(s,o),m0(s,o),s==="git"?c0(o):void 0,s0(s,o),o0(o,a)].filter(d=>!!d);return e.cwd&&(e.cwd.startsWith("/")||e.cwd.split(/[\\/]/).includes(".."))&&c.push("cwd must stay inside the repo"),c}const E0="unknown program: Teamtrail can't tell what this runs";function A0(e){if(T0(e).length)return;const{argv0:t,program:s,args:o}=ng(e);return k0({argv0:t,program:s,args:o})?void 0:E0}function I0(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 M0={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"},sg={on:"#e2711d",dim:"#a8501c",alert:"#ff5a48"},R0={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 am(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 L0(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 O0=[13,15,17,19,21,23];function P0(e){return[O0.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 lm(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 _0(e,{lamp:t=sg,simple:s=!1,colors:o=M0}={}){const a=o,c=s?"open":e.eyes,d=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"/>`,lm(.6,a,h),lm(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?"":P0(a),am(11,c,a),am(18,c,a),L0(d,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 ig={crt:{id:"crt",name:"Day",blurb:"The original CRT head with ear cups and a baseball cap.",lamp:sg,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:R0,wave:{bar:"#66828d",lead:"#e8833a"}}},D0="crt",z0={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"}},B0={idle:"WATCHING",speaking:"TALKING",alert:"NEEDS YOU",thinking:"THINKING"},wn={msPerChar:55,mouthHoldMs:110,blinkEveryMs:5600,blinkMs:140,thinkingStepMs:520};function F0(e){return e?/[aeiouy]/i.test(e)?"open":/[a-z0-9]/i.test(e)?"mid":"rest":"rest"}function U0(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 W0(e,t,s){return Array.from({length:s},(o,a)=>{const c=t-(s-1-a);return c>=0&&c<e.length?U0(e[c],c):0})}function rg({face:e={eyes:"open",mouth:"rest"},variant:t="crt",size:s,simple:o,className:a}){const{eyes:c,mouth:d,light:h}=e,m=y.useMemo(()=>_0({eyes:c,mouth:d,light:h},{lamp:ig[t].lamp,simple:o??s<28}),[c,d,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 H0(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),wn.blinkMs)},wn.blinkEveryMs);return()=>{clearInterval(a),o&&clearTimeout(o)}},[e]),t}const K0={xs:.8,sm:2,md:4,lg:6},V0=40,cm=20,um="(prefers-reduced-motion: reduce)",G0=40,q0=350;function Q0(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,d=s==="xs";return{size:s,text:a,effective:c,talking:c==="speaking"&&a.length>0,mini:d,framed:e.framed??!d,reduced:t||d}}const Y0=e=>e.length*wn.msPerChar,J0=(e,t)=>t&&(e.effective==="idle"||e.effective==="speaking"||e.effective==="alert");function X0(e,t,s,o){const a=z0[e.effective],c=s?"closed":a.eyes;let d=a.mouth,h=e.text.length-1;if(o)if(e.reduced)d="open";else{h=Math.min(e.text.length-1,Math.floor(t/wn.msPerChar));const p=Math.floor(t/wn.mouthHoldMs)*Math.round(wn.mouthHoldMs/wn.msPerChar);d=F0(e.text[Math.min(e.text.length-1,p)])}let m=a.light;return e.effective==="thinking"&&!e.reduced&&Math.floor(t/wn.thinkingStepMs)%2===1&&(m="on"),{eyes:c,mouth:d,light:m,cursor:h}}function Z0(e,t){const s=typeof e.size=="number"?e.size:K0[e.size],o=e.reduced?Math.min(e.text.length-1,cm-1):t;return{base:s,px:V0*s,bars:cm,waveCursor:o}}function eS(e,{label:t,speechDone:s,cursor:o,caption:a}){const c=e.talking&&s?"idle":e.effective,d=B0[c],h=e.size==="md"||e.size==="lg"||typeof e.size=="number"&&e.size>=4;return{shownState:c,status:d,ariaLabel:`${t}, ${d.toLowerCase()}`,showCaption:a??h,shown:tS(e,s,o)}}function tS(e,t,s){return e.talking?e.reduced||t?e.text:e.text.slice(0,s+1):""}function nS(){const[e,t]=y.useState(()=>{var s;return typeof window<"u"&&!!((s=window.matchMedia)!=null&&s.call(window,um).matches)});return y.useEffect(()=>{var a;const s=(a=window.matchMedia)==null?void 0:a.call(window,um);if(!s)return;const o=()=>t(s.matches);return o(),s.addEventListener("change",o),()=>s.removeEventListener("change",o)},[]),e}function sS(e,t,s){const[o,a]=y.useState(0);return y.useEffect(()=>{if(a(0),!t)return;const c=performance.now(),d=setInterval(()=>a(performance.now()-c),s);return()=>clearInterval(d)},[e,t,s]),o}function iS(e){const{key:t,talking:s,at:o}=e,a=o!==void 0,c=Y0(e.text),[d,h]=y.useState(""),m=y.useRef(e.onSpeakEnd);m.current=e.onSpeakEnd,y.useEffect(()=>{if(!s||a)return;const j=setTimeout(()=>{var b;h(t),(b=m.current)==null||b.call(m)},c+q0);return()=>clearTimeout(j)},[s,t,c,a]);const p=s&&d!==t,v=sS(t,e.animate&&(p||e.thinking),p?G0:wn.thinkingStepMs),k=o??v,x=s&&(a?k>=c:d===t);return{t:k,speechDone:x}}const rS=e=>e*2,Wc=3.5;function oS(e,t,s){return(e??[]).map((o,a)=>{const c=(1+2*o)*.5;return{x:a*2,y:(Wc-c)/2,width:1,height:c,fill:a>=t-2&&o>0?s.lead:s.bar}})}function aS({heights:e,bars:t,unit:s,colors:o}){const a=rS(t);return i.jsx("svg",{className:`scout-wave${e?" on":""}`,width:a*s,height:Wc*s,viewBox:`0 0 ${a} ${Wc}`,"aria-hidden":"true",children:oS(e,t,o).map((c,d)=>i.jsx("rect",{...c},d))})}function aa({state:e="idle",size:t="md",speaking:s,variant:o=D0,framed:a,caption:c,label:d="Scout",onSpeakEnd:h,at:m,className:p,style:v}){const k=Q0({state:e,size:t,speaking:s,framed:a},nS()),{text:x,effective:j,talking:b,reduced:S}=k,I=ig[o],R=!S&&!(m!==void 0),O=`${j}|${o}|${x}`,{t:U,speechDone:X}=iS({key:O,text:x,talking:b,thinking:j==="thinking",animate:R,at:m,onSpeakEnd:h}),Q=H0(J0(k,R)),W=b&&!X,{eyes:ie,mouth:G,light:ve,cursor:Pe}=X0(k,U,Q,W),{base:$e,px:oe,bars:D,waveCursor:J}=Z0(k,Pe),le=y.useMemo(()=>W?W0(x,J,D):null,[W,x,J,D]),{shownState:ee,status:K,ariaLabel:Y,showCaption:B,shown:T}=eS(k,{label:d,speechDone:X,cursor:Pe,caption:c}),_={...v,"--scout-u":`${$e}px`},ue=i.jsx("span",{className:"scout-sprite",children:i.jsx(rg,{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-${ee} scout-v-${o} ${p??""}`,style:_,"data-state":ee,children:[i.jsxs("figcaption",{className:"scout-head",children:[i.jsx("span",{className:"scout-name",children:d}),i.jsx("span",{className:"scout-sep",children:"//"}),i.jsx("span",{className:"scout-status",children:K})]}),i.jsxs("div",{className:"scout-feed",role:"img","aria-label":Y,children:[ue,i.jsx(aS,{heights:le,bars:D,unit:$e,colors:I.wave})]}),B&&i.jsxs("p",{className:"scout-caption","aria-hidden":"true",children:[T,b&&!X&&!S&&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-${ee} ${p??""}`,style:_,role:"img","aria-label":Y,children:ue})}const St="trail lead";function lS({rt:e,guard:t,setMapId:s,mapIdRef:o,snapRef:a,setChatSession:c,setSelection:d}){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,St,{via:"lookout"}),claim:m=>t("Claim",()=>Hf(e.adapter,o.current,m,{...h,assignee:St})),release:m=>t("Release claim",()=>_w(e.adapter,o.current,m,{...h,actor:St})),releaseLease:m=>t("Release to queue",()=>e.leases.release(o.current,m,St)),resolve:(m,p,v={})=>t("Resolve · record answer",async()=>{var x;const k=(x=a.current)==null?void 0:x.tickets.find(j=>j.id===m);k&&!k.assignee&&await Hf(e.adapter,o.current,m,{...h,assignee:St}),await qw(e.adapter,o.current,m,{...h,answer:p,author:St,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:j,supersededBy:b,...S}=m;v=(await uu(e.adapter,m.mapId,S,{appendToTrail:!1})).id}await Fw(e.adapter,m.mapId,v,{...p,decidedBy:St,participants:[{id:St}],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);d({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:St,source:{kind:"lookout",label:"Ticket inspector"}}),d(null)}),setMode:m=>t(`Trail mode · ${m}`,()=>Uw(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(" "),Vs="item",cS=/^[0-9a-f]{6,64}$/;function or(){const e=new URLSearchParams(location.search).get("project")??void 0;return e&&cS.test(e)?e:void 0}function je(e=or()){return e?`${te.apiPrefix}/p/${e}`:te.apiPrefix}function uS(e){const t=new URLSearchParams(location.search);for(const o of["projects","project","tracker",Vs])t.delete(o);e.item&&t.set(Vs,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 dS(e,t){var c;const s=(t.assumptions??[]).map((d,h)=>({id:`S-${h+1}`,text:d,status:"holding",tickets:[]})),{map:o,tickets:a}=await Cw(e,{title:t.title,sections:{destination:t.destination,notes:t.notes,decisions:[],unspecified:[],outOfScope:[],...s.length?{assumptions:s}:{}},tickets:[{ref:"discovery",...qx}]});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 og(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 dn(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 ag(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 la=e=>new Date(e).toTimeString().slice(0,8);function Qt(e){if(e<1e3)return`${Math.round(e)}ms`;const t=Math.round(e/1e3);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m ${String(t%60).padStart(2,"0")}s`:`${Math.floor(t/3600)}h ${String(Math.floor(t%3600/60)).padStart(2,"0")}m`}function ca(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}const Gs=e=>`$${e<10?e.toFixed(2):e.toFixed(1)}`,qs=e=>new Date(e).toISOString().slice(0,10),pu=e=>new Date(e).toTimeString().slice(0,5),hS=e=>`${qs(e)} ${pu(e)}`,lg=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"}):"",er={research:"Research",prototype:"Prototype",junction:"Junction",task:"Task",execute:"Execute",review:"Review"},cg={decided:"Done",claimed:"Working",frontier:"Ready",blocked:"Backlog",parked:"Parked (plan-only)","out-of-scope":"Cancelled",verifying:"Verifying",rework:"Rework",held:"Blocked"},fS={decided:"done",claimed:"working",frontier:"ready",blocked:"backlog",parked:"parked","out-of-scope":"cancelled",verifying:"verifying",rework:"rework",held:"blocked"};function gu(e,t){return new Map((e??[]).filter(s=>s.mapId===t&&!s.returned).map(s=>[s.ticketId,s]))}function Zs(){let e=0,t=0;return{start(){const s=++e;return()=>s<=t?!1:(t=s,!0)},pushed(){t=++e}}}const mS=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]),nn=(e,t)=>e>>>t|e<<32-t;function pS(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 gS(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 j=nn(o[x-15],7)^nn(o[x-15],18)^o[x-15]>>>3,b=nn(o[x-2],17)^nn(o[x-2],19)^o[x-2]>>>10;o[x]=o[x-16]+j+o[x-7]+b>>>0}let[a,c,d,h,m,p,v,k]=e;for(let x=0;x<64;x++){const j=k+(nn(m,6)^nn(m,11)^nn(m,25))+(m&p^~m&v)+mS[x]+o[x]>>>0,b=(nn(a,2)^nn(a,13)^nn(a,22))+(a&c^a&d^c&d)>>>0;[k,v,p,m,h,d,c,a]=[v,p,m,h+j>>>0,d,c,a,j+b>>>0]}[a,c,d,h,m,p,v,k].forEach((x,j)=>e[j]=e[j]+x>>>0)}function yc(e){const t=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),s=pS(e),o=new DataView(s.buffer),a=new Uint32Array(64);for(let h=0;h<s.length;h+=64)gS(t,o,h,a);const c=new Uint8Array(32),d=new DataView(c.buffer);return t.forEach((h,m)=>d.setUint32(m*4,h)),c}function vS(e,t){const s=new Uint8Array(64);s.set(e.length>64?yc(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(yc(o),64),yc(a)}const ug=e=>Array.from(e,t=>t.toString(16).padStart(2,"0")).join(""),kS=e=>new Uint8Array((e.match(/../g)??[]).map(t=>parseInt(t,16))),vu=`${te.slug}.session`;let _o;const yS=e=>{const t=e;return!!t&&typeof t.id=="string"&&typeof t.secret=="string"&&typeof t.verifier=="string"};function ku(){try{const e=JSON.parse(localStorage.getItem(vu)??"null");return yS(e)?e:_o}catch{return _o}}function wS(e){_o=e;try{localStorage.setItem(vu,JSON.stringify(e))}catch{}}function dg(){_o=void 0;try{localStorage.removeItem(vu)}catch{}}let yu="unproven",wc;const Hc=new Set,hg=e=>{yu=e;for(const t of Hc)t(e)};function xS(e){return Hc.add(e),()=>void Hc.delete(e)}const jS=()=>yu==="proven",SS=()=>yu==="proven"&&hg("unproven");function NS(){const e=new Uint8Array(16);return crypto.getRandomValues(e),ug(e)}async function bS(){const e=ku();if(!e)return"unknown";const t=NS(),s=await fetch(`${te.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 dg(),"unknown";const o=s!=null&&s.ok?(await s.json().catch(()=>({}))).proof:void 0,a=ug(vS(kS(e.verifier),new TextEncoder().encode(`${t}
134
+ ${location.origin}`)));return o===a?"proven":"failed"}function ua(){return wc??(wc=bS().then(e=>(wc=void 0,hg(e),e))),wc}const CS=1e4;class fg{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 ua()!=="proven")return this.failed();const t=await fetch(`${te.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(),SS(),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,CS))}}function $S(){ua().then(e=>e==="unknown"&&location.reload())}let Dt;const Do=new Set,tr=new Map,zo=new Set,Bo=new Set;function mg(e){Dt==null||Dt.addEventListener(e,t=>{for(const s of tr.get(e)??[])s(t.data)})}function da(){if(!Dt){Dt=new fg,Dt.onerror=()=>{for(const e of Bo)e();$S()},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 tr.keys())mg(e)}}function ha(){const e=[...tr.values()].some(t=>t.size>0);Do.size||e||zo.size||Bo.size||(Dt==null||Dt.close(),Dt=void 0)}function wu(e){return Do.add(e),da(),()=>{Do.delete(e),ha()}}function ei(e,t){let s=tr.get(e);return s||(s=new Set,tr.set(e,s),mg(e)),s.add(t),da(),()=>{s.delete(t),ha()}}function hs(e){return zo.add(e),da(),()=>{zo.delete(e),ha()}}function TS(e){return Bo.add(e),da(),()=>{Bo.delete(e),ha()}}const xu=(e,t)=>`${e}/${t}`;let qt={reached:!1,live:!1,tickets:{}},Kc=!1;const Vc=new Set,Gc=new Set,ES=Zs();let qc=0;const pg=new Map;let gg=0;function Fo(e){qt=e;for(const t of Vc)t()}function AS(e,t){const s=Object.fromEntries(e.map(o=>[xu(o.mapId,o.ticketId),o]));for(const[o,a]of pg)a>t&&qt.tickets[o]&&(s[o]=qt.tickets[o]);return s}function dm(){const e=ES.start(),t=qc;fetch(`${je()}/verification/sync`).then(s=>s.ok?s.json():Promise.reject()).then(s=>e()&&Fo({reached:!0,live:!0,status:gg>t?qt.status:s.status,tickets:AS(s.tickets,t)}),()=>qt.reached&&Fo({...qt,live:!1}))}function IS(e){const t=JSON.parse(e);if(t.kind==="evidence")for(const a of Gc)a();if(t.kind!=="sync")return;const s=t;gg=++qc;const o={...qt.tickets};for(const a of s.tickets){const c=xu(a.mapId,a.ticketId);o[c]=a,pg.set(c,qc)}Fo({reached:!0,live:!0,status:s.status,tickets:o})}function hm(){Kc=!0,ei("verification",IS),TS(()=>qt.reached&&qt.live&&Fo({...qt,live:!1})),hs(dm),dm()}const Qs={subscribe(e){return Kc||hm(),Vc.add(e),()=>void Vc.delete(e)},get:()=>qt,onEvidence(e){return Kc||hm(),Gc.add(e),()=>void Gc.delete(e)},ticket:(e,t,s)=>e.tickets[xu(t,s)]};function MS(e){if(e!=null&&e.flags.length)return e.flags.some(t=>t.severity==="alert")?"alert":"warn"}const fm={onboarded:!1,tracker:"markdown",hitlTranscript:"summary",agent:Wj.id,github:{repo:""},linear:{team:""},briefing:{enabled:!0,awayMinutes:15},theme:"night"};function ju(){try{const e={...fm,...JSON.parse(localStorage.getItem(Yo)??"{}")};return["markdown","github","linear"].includes(e.tracker)||(e.tracker="markdown"),e}catch{return fm}}function vg(e){e==="auto"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e}const xc=new Map,jc=e=>`${je()}/file?path=${encodeURIComponent(e)}`;async function Sc(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 RS={async list(){return(await(await fetch(`${je()}/list`)).json()).files},async read(e){const t=await fetch(jc(e));if(!t.ok)throw await Sc(t,`read ${e}`);const s=await t.text(),o=t.headers.get("ETag");return o&&xc.set(e,{text:s,etag:o}),s},async write(e,t,s){const o=(s==null?void 0:s.base)===void 0?void 0:xc.get(e),a=o&&o.text===(s==null?void 0:s.base)?{"If-Match":o.etag}:{},c=await fetch(jc(e),{method:"PUT",body:t,headers:a});if(!c.ok)throw await Sc(c,`write ${e}`);xc.delete(e)},async create(e,t){const s=await fetch(jc(e),{method:"PUT",body:t,headers:{"If-None-Match":"*"}});if(s.status===412)return!1;if(!s.ok)throw await Sc(s,`create ${e}`);return!0},watch(e){return wu(e)}},LS=15*6e4;class OS{constructor(t){ce(this,"leases",[]);ce(this,"changes",new Ks);ce(this,"logged",new Set);ce(this,"since",Date.now()-LS);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:cj(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 PS(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 _S(e){const t=Zs(),s=()=>{const o=t.start();fetch(`${je()}/agents/leases`).then(a=>a.ok?a.json():{leases:[]}).then(({leases:a})=>o()&&e.set(a)).catch(()=>{})};ei("leases",o=>{t.pushed(),e.set(JSON.parse(o).leases)}),hs(s),s()}function DS(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(d=>(s.get(d.session.id)??0)<=a).forEach(d=>e.syncRemote(d))).catch(()=>{})};ei("agent",a=>{const c=JSON.parse(a);s.set(c.session.id,++t),e.syncRemote(c)}),hs(o),o()}function mm(e,t){PS(e),_S(t),DS(e)}function pm(e){const t=s=>`${Yo}:${e}:${s}`;return{get:s=>localStorage.getItem(t(s)),set:(s,o)=>{try{localStorage.setItem(t(s),o)}catch{}}}}const zS=["markdown","github","linear"];function BS(){const e=new URLSearchParams(location.search).get("tracker");return e&&zS.includes(e)?e:ju().tracker}function FS(e){let t,s;const o=new ox,a=new OS(o),c={},d=tx(je());if(e==="github"||e==="linear"){const p=new Bj(e,je());p.openEvents=v=>new fg(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=pm(`${e}:${p.location}`);c.presence=new Gf(k),o.ledger=new qf(k),mm(o,a)})}else t=new Dj(RS,`./${te.dataDir}`),s=fetch(`${je()}/list`).then(p=>p.json()).catch(()=>({root:"default"})).then(({root:p})=>{const v=pm(p);c.presence=new Gf(v),o.ledger=new qf(v),mm(o,a)});const h=ux(t),m=h.adapter;return{kind:e,ready:s,get presence(){return c.presence},adapter:m,journal:d,monitor:h,activity:o,leases:a}}const cn=e=>e.status==="running",kg=e=>cn(e)&&!!e.waitingOn,US={blocking:0,soon:1,fyi:2};function WS(e,t,s){const o=e.filter(d=>d.sessionId===t),a=o.find(d=>d.id===s);if(a)return a;const c=d=>US[d.urgency??"soon"];return[...o].sort((d,h)=>c(d)-c(h)||d.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 un({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 fa({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(un,{as:"button",type:"button",className:"choice",on:e,disabled:o,onClick:a,children:[i.jsx("b",{className:"choice-title t-row-title",children:t}),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 ma=y.forwardRef(function({value:t,onValueChange:s,onSubmit:o,action:a="Send",actionDisabled:c,className:d,...h},m){return i.jsxs("form",{className:Ge("input-row",d),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 ti({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:d}){return i.jsx(e,{className:Ge(t==="chip"?"chip-label":"mono-label",s&&"hot",o==="sm"&&(t==="chip"?"sm":"xs"),a),title:d,children:c})}const HS=e=>typeof e=="string"?{text:e}:e,KS=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(HS);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:KS(s)||void 0,title:s.tip,children:s.text})]},o)),e.children]})}function Su(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 ni(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 VS="M25.53 10.5 A11 11 0 1 1 16 5",GS="M20 5 L14.6 1.6 L14.6 8.4 Z";function si({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:VS,fill:"none",stroke:"currentColor",strokeWidth:c,strokeLinecap:"butt"}),(e==="mark"||e==="action")&&i.jsx("path",{d:GS,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 Qc({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 gm=()=>{const e=document.documentElement.dataset.theme;return e?e==="night":matchMedia("(prefers-color-scheme: dark)").matches};function Nu(){const[e,t]=y.useState(gm);return y.useEffect(()=>{const s=()=>t(gm()),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 qS(){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 QS=15e3,vm=["pointerdown","pointermove","keydown","wheel","touchstart"];function YS(e,t,s,o){const[a,c]=y.useState(null),[d,h]=y.useState(!1),[m,p]=y.useState(!1),v=y.useRef(),k=y.useRef(Date.now()),x=y.useRef(!1),j=s.awayMinutes*6e4,b=y.useRef(t);b.current=t;const S=y.useRef(o);S.current=o;const I=y.useCallback((Q,W)=>{const ie=b.current;return Mx({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:S.current})},[e]),C=y.useCallback((Q=Date.now())=>{var W;return(W=e.presence)==null?void 0:W.markSeen(b.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>=j){const ie=Q.snapshot();I(ie,W).changed&&(v.current={seen:ie,any:W},h(!0),s.enabled?c(ie):p(!0))}C()},[e,j,s.enabled,I,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>=j;k.current=Date.now(),G&&x.current&&document.visibilityState==="visible"&&R()},W=()=>{if(document.visibilityState!=="visible"){x.current&&C(Date.now()-k.current<j?Date.now():k.current);return}k.current=Date.now(),x.current&&R()};for(const G of vm)window.addEventListener(G,Q,{passive:!0});document.addEventListener("visibilitychange",W);const ie=setInterval(()=>{x.current&&document.visibilityState==="visible"&&C(k.current)},QS);return()=>{for(const G of vm)window.removeEventListener(G,Q);document.removeEventListener("visibilitychange",W),clearInterval(ie)}},[j,R,C]);const O=y.useMemo(()=>{var Q;return a?I(a,(Q=v.current)==null?void 0:Q.any):void 0},[a,I,t.allSnaps,t.decisions,t.activity,o]),U=y.useMemo(()=>O?Px(O):"",[O]);y.useEffect(()=>{a&&p(!1)},[a]);let X="none";return m?X="new":d&&(X="seen"),{shown:a!==null,status:X,briefing:O,line:U,open:()=>{const Q=v.current;Q&&c(Q.seen)},dismiss:()=>c(null)}}function JS(e){const[t,s]=y.useState(e.leases.leases);return y.useEffect(()=>e.leases.subscribe(s),[e]),t}const XS="That changed while you were on it, so nothing was written. It is reloaded now: look again, then redo the change.";function ZS(e){var Y;const[t,s]=y.useState([]),[o,a]=y.useState(),[c,d]=y.useState(),[h,m]=y.useState({}),[p,v]=y.useState({}),[k,x]=y.useState(!1),[j,b]=y.useState(e.activity.snapshot),[S,I]=y.useState(e.monitor.health),C=JS(e);y.useEffect(()=>e.monitor.subscribe(I),[e]);const[R,O]=y.useState(null),[U,X]=y.useState(),[Q,W]=y.useState(),ie=y.useRef(),G=y.useRef(),ve=y.useRef(new Set),Pe=y.useRef();Pe.current=c;const $e=y.useCallback(B=>{ie.current=B,a(B),O(null)},[]),[oe]=y.useState(Zs),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,Se)=>[pe.id,ke[Se]]))),x(!0),d(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=>X(String(ge))),40)},ke=hs(me),xe=(ge,Be)=>cn(ge)&&e.activity.isRemote(ge.id)&&(!Be||!ge.mapId||ge.mapId===Be),pe=ge=>{var Be;return(Be=Pe.current)==null?void 0:Be.tickets.find(jn=>jn.id===ge)},Se=ge=>{const Be=ax(ge,pe),jn=ge.kind==="external.changed"&&e.activity.snapshot.sessions.some(fs=>xe(fs,ge.mapId)),cr=!("mapId"in ge)||!ge.mapId||ge.mapId===ie.current||ge.kind==="map.created";Be&&!jn&&cr&&e.activity.push(Be),me()};return e.ready.then(()=>{ue&&(T=e.adapter.subscribe(Se),_=e.activity.subscribe(b),e.activity.push({source:"system",level:"ok",text:`Online · tracker ${e.adapter.label.toLowerCase()} · ${e.adapter.location}`}),D().catch(ge=>X(String(ge))))}),()=>{ue=!1,T(),_(),ke(),clearTimeout(B)}},[e,D]),y.useEffect(()=>{o&&D().catch(B=>X(String(B)))},[o,D]),y.useEffect(()=>{for(const B of j.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=>X(String(T)))))},[j.sessions,e,D]);const J=(Y=j.pending[0])==null?void 0:Y.sessionId;y.useEffect(()=>{if(!J)return;const B=T=>e.activity.snapshot.sessions.some(_=>_.id===T&&cn(_));W(T=>B(T)?T:J)},[J,e]);const le=y.useCallback(async(B,T)=>{e.activity.push({source:"trail lead",agent:St,level:"warn",text:B});try{X(void 0),await T()}catch(_){const ue=_.stale===!0,me=ue?XS:_.message??String(_);X(me),e.activity.push({source:"trail lead",agent:St,level:"alert",text:`Rejected · ${me}`}),ue&&D().catch(ke=>X(String(ke)))}},[e,D]),ee=y.useMemo(()=>lS({rt:e,guard:le,setMapId:$e,mapIdRef:ie,snapRef:Pe,setChatSession:W,setSelection:O}),[le,e,$e]),K=y.useMemo(()=>Object.values(h).flatMap(B=>gx(B,p[B.map.id]??[])).sort((B,T)=>T.decidedAt-B.decidedAt),[h,p]);return{maps:t,allSnaps:h,mapId:o,snap:c,activity:j,health:S,selection:R,setSelection:O,error:U,chatSession:Q,decisions:K,leases:C,loaded:k,actions:ee}}function Yt(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 eN(){const[e,t]=y.useState(ju),s=y.useCallback(o=>{t(a=>{const c={...a,...o};return localStorage.setItem(Yo,JSON.stringify(c)),c})},[]);return[e,s]}function bu(){return y.useSyncExternalStore(Qs.subscribe,Qs.get)}function tN({className:e,size:t=18}){return i.jsx("span",{className:e,"aria-hidden":"true",children:i.jsx(rg,{size:t,variant:Nu()?"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 on({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 Un="#c8581e",nN={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:Un,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:Un})]}),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:Un})]}),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:Un,stroke:Un})]}),tent:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 4L2.5 20h19z"}),i.jsx("path",{d:"M12 11l-4 9h8z",fill:Un,stroke:Un}),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:Un})]})};function yg({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:nN[e]})}function Et({title:e,count:t,right:s,hot:o,sub:a,children:c,className:d,info:h,icon:m}){return i.jsxs("header",{className:Ge("sec-h",a&&"sub",d),children:[c,m&&i.jsx(yg,{name:m}),e!==void 0&&i.jsx(Ve,{as:a?"h3":"h2",hot:o,children:e}),h&&i.jsx(ti,{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),[d,h]=y.useState(0),[m,p]=y.useState(),v=y.useRef(null),k=y.useRef(null),x=y.useId(),j=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=O=>{var U,X;O.target instanceof Node&&((U=k.current)!=null&&U.contains(O.target)||(X=v.current)!=null&&X.contains(O.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="${d}"]`))==null||R.scrollIntoView({block:"nearest"}))},[a,d]);const b=()=>{h(Math.max(0,s.findIndex(C=>C.value===t))),c(!0)},S=C=>{var O;const R=s[C];c(!1),(O=v.current)==null||O.focus(),R&&R.value!==t&&o(R.value)},I=C=>{if(!a){["ArrowDown","ArrowUp","Enter"," "].includes(C.key)&&(C.preventDefault(),b());return}const R=O=>h(U=>(U+O+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===" ")S(d);else{if(C.key==="Escape"||C.key==="Tab")return c(!1);if(C.key.length===1){const O=s.findIndex(U=>U.label.toLowerCase().startsWith(C.key.toLowerCase()));O>=0&&h(O);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}-${d}`:void 0,disabled:e.disabled,onClick:()=>a?c(!1):b(),onKeyDown:I,children:[i.jsx("span",{className:"select-value",children:(j==null?void 0:j.label)??"—"}),i.jsx("span",{className:"select-caret","aria-hidden":"true"})]}),a&&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===d&&"active"),onMouseEnter:()=>h(R),onMouseDown:O=>O.preventDefault(),onClick:()=>S(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 sN(e){return i.jsx("div",{className:`tabs ${e.className??""}`,role:"tablist",children:e.items.map(t=>i.jsxs("button",{role:"tab","aria-selected":e.value===t.id,className:`tab ${e.value===t.id?"on":""}`,onClick:()=>e.onChange(t.id),children:[t.label,t.n!==void 0&&i.jsx("span",{className:"n",children:t.n})]},t.id))})}const iN=350;function rN(){const[e,t]=y.useState(null);if(y.useEffect(()=>{let o=0,a=null;const c=()=>{window.clearTimeout(o),a=null,t(null)},d=v=>{const k=v.getAttribute("data-tip");if(!k)return;const x=v.getBoundingClientRect(),j=x.bottom+60>window.innerHeight;t({text:k,x:x.left+x.width/2,y:j?x.top-8:x.bottom+8,above:j,scout:v.hasAttribute("data-tip-scout")})},h=v=>{var j,b;const k=(b=(j=v.target)==null?void 0:j.closest)==null?void 0:b.call(j,"[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&&d(k),v.type==="focusin"?0:iN)))},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(aa,{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 pa({as:e="span",className:t}){return i.jsxs(e,{className:t?`tt-wordmark ${t}`:"tt-wordmark",role:"img","aria-label":te.name,children:[te.name.toLowerCase(),i.jsx("span",{className:"tt-wordmark-dot","aria-hidden":"true"})]})}function wg(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 zs(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 Gi(e){return i.jsxs(un,{tone:e.urgent?"urgent":void 0,className:`bf-tile ${e.className??""}`,children:[i.jsx("span",{className:"mono-label",children:e.label}),i.jsx("b",{children:e.value}),e.sub&&i.jsx(V,{parts:[],children:e.sub})]})}const oN=864e5;function aN(e,t){const s=new Date(e),o=s.toTimeString().slice(0,5),a=new Date(t).toDateString(),c=new Date(t-oN).toDateString();let d=` ${s.toLocaleDateString(void 0,{month:"short",day:"numeric"})}`;return s.toDateString()===a?d="":s.toDateString()===c&&(d=" yesterday"),`Since ${o}${d} · ${Qt(t-e)}`}function lN(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,d=((t==null?void 0:t.trails.length)??0)>1,h=s==="mobile",m=k=>{var x,j;return k.ticketId&&((j=(x=e.snaps[k.mapId])==null?void 0:x.tickets.find(b=>b.id===k.ticketId))==null?void 0:j.title)||k.text},p=k=>{var x,j;return k.ticketId&&((j=(x=e.snaps[k.mapId])==null?void 0:x.tickets.find(b=>b.id===k.ticketId))==null?void 0:j.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),j=(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),b=aj(k.agentDecisions).flatMap(C=>C.decisions.map(R=>j(R,C.label))),S=[i.jsx(zs,{title:"Done",children:k.done.map(C=>x(C))},"done"),i.jsx(zs,{title:"Ruled out",children:h?[]:k.ruledOut.map(C=>x(C))},"oos"),i.jsx(zs,{title:"Blocked",children:k.blocked.map(C=>x(C.ticket,`needs ${C.on.map(R=>R.key).join(", ")}`))},"blocked")],I=[i.jsx(zs,{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":Qt(t.now-C.at),title:C.text,onClick:()=>e.onAnswer(C)},C.id))},"waiting"),i.jsx(zs,{title:"Agent decisions",children:h?[]:b},"agent"),i.jsx(zs,{title:"Active sessions",children:h?[]:k.active.map(C=>{var O;const R=C.ticketId?(O=e.snaps[k.mapId])==null?void 0:O.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:[d&&i.jsxs("div",{className:"bf-trail-h",children:[i.jsx("span",{className:"key",children:k.key})," ",k.title]}),i.jsxs("div",{className:"bf-cols",children:[i.jsx("div",{children:S}),i.jsx("div",{children:I})]})]},k.mapId)};return i.jsx("div",{className:"scrim",onClick:o,children:i.jsxs(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:aN(t.since,t.now)}),i.jsx("button",{className:"icon-btn",onClick:o,"aria-label":"Close",children:"×"})]}),i.jsxs(un,{className:"bf-scout",children:[i.jsx(aa,{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(Gi,{label:"Done",value:c.done,sub:c.ruledOut?`${c.ruledOut} ruled out`:void 0}),i.jsx(Gi,{label:"Blocked",value:c.blocked,sub:c.blocked?"Needs your answer":void 0}),i.jsx(Gi,{label:"Waiting on you",value:c.waiting,sub:cN(c.oldestWaitMs),urgent:c.waiting>0}),i.jsx(Gi,{label:"Agent decisions",value:c.agentDecisions,className:"opt"}),i.jsx(Gi,{label:"Spend",value:Gs(c.usage.costUsd),sub:`${ca(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(si,{variant:"alert",size:13}),"Answer first decision"]}):i.jsx(P,{variant:"primary",onClick:e.onResume,children:"Resume trail"})]})]})})}function cN(e){if(e!==void 0)return e<6e4?"Just asked":`Oldest ${Qt(e)}`}function uN(e){const{brief:t,bp:s}=e;return i.jsx(lN,{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 dN={passed:"checks passed",failing:"checks failing",pending:"checks pending",unknown:"checks unknown",none:"no checks"};function hN({mapId:e,ticketId:t}){const s=Qs.ticket(bu(),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:Xs(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:dN[s.checksSummary]}),i.jsx("span",{className:"when",children:fN(s)})]}),s.flags.map(a=>i.jsx(Qn,{className:`flag flag-${a.severity}`,title:a.text,children:a.kind},a.kind))]})}function fN(e){return e.error?"sync failed":e.syncedAt?lg(e.syncedAt):"not synced yet"}const mN={ok:"ok",failed:"error",stale:"syncing",unknown:"idle",off:"idle"};function pN({now:e}){const t=bu();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(si,{variant:"status",state:mN[s.tone],size:13,className:"sync-glyph"}),i.jsx("span",{className:"tl",children:s.label})]})}function xg(e){const t=e.role??"menu",[s,o]=y.useState(!1),a=y.useRef(null);return y.useEffect(()=>{if(!s)return;const c=d=>{var m;(d instanceof KeyboardEvent?d.key==="Escape":!((m=a.current)!=null&&m.contains(d.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 gN={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 vN(e){const t=e.briefingStatus==="new";return i.jsx(xg,{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:gN[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 kN=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"})]}),yN=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 wN({onToggle:e}){const t=Nu(),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?kN:yN})})}const xN={idle:"Idle",syncing:"Syncing",ok:"Synced",error:"Sync error"};function jN({label:e,health:t,now:s}){const o=[`${xN[t.status]} · ${t.writes} writes · ${t.errors} errors`,t.lastWriteAt?`Last write ${Qt(t.lastWriteMs??0)}, ${Qt(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(si,{variant:"status",state:t.status,size:13,className:"sync-glyph"}),i.jsx("span",{className:"tl",children:e})]})}function SN(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,d=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"}),d>0&&i.jsx(us,{n:d,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=Ap(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 NN(e){const{map:t}=e,s=Yt(1e3),o=e.activity.pending.length,a=t&&e.snaps[t.id],c=a&&Ap(a),d=t&&Ip(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(SN,{...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(jN,{label:e.trackerLabel,health:e.health,now:s}),i.jsx(pN,{now:s}),t&&c&&i.jsxs("span",{className:"trail-meta",children:[i.jsx(on,{label:"Trail T+",value:ag(s-t.createdAt),title:"Trail elapsed time, since it was charted"}),i.jsx(on,{label:"Done",value:`${c.decided}/${c.total}`}),d&&i.jsx(on,{className:"spend",label:"Spent",value:`${Gs(d.costUsd)} · ${ca(d.inputTokens+d.outputTokens)} tok`,title:["Model spend and tokens for this trail, across every session",...Rp(e.activity,t.id).map(h=>Mp[h].text)].join(`
139
+ `)})]}),e.attention,!e.attention&&o>0&&i.jsxs("span",{className:"waiting-chip",title:`${o} waiting on you`,children:[i.jsx(si,{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(vN,{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(wN,{onToggle:e.onToggleTheme})]})]})}const jg=y.createContext(null);function ii(){const e=y.useContext(jg);if(!e)throw new Error("useKnowledge needs a KnowledgeContext provider");return e}function bN({snap:e,t}){const s=ii();if(!s.entries.length||t.state==="closed")return null;const o=Kp(s.entries,{trailKey:e.map.key,ticket:{type:t.type,title:t.title,body:t.body},paths:Vp(`${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 ga(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 CN={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 $N({e}){const t=ii(),[s,o]=y.useState(!1),[a,c]=y.useState(e.title),[d,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=ga(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:d,onChange:v=>h(v.target.value)})})]}):i.jsxs(i.Fragment,{children:[i.jsx("h3",{className:"t-title",children:e.title}),i.jsx("p",{className:"kn-body",children:e.body})]}),i.jsx("p",{className:"dim",children:CN[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(fa,{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:d}).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 TN={suggested:"Suggested",confirmed:"Confirmed",assumption:"Assumption",outdated:"Outdated"};function EN(){const e=ii(),[t,s]=y.useState("review"),[o,a]=y.useState(""),[c,d]=y.useState(""),[h,m]=y.useState();y.useEffect(()=>{if(!e.open)return;const S=I=>I.key==="Escape"&&e.setOpen(!1);return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[e]);const p=S=>S.status==="suggested"||!!S.flag||!!e.stale[S.id]&&S.status!=="outdated",v=(S,I)=>I==="all"?!0:I==="review"?p(S):S.status===I,k=y.useMemo(()=>{const S=c.trim().toLowerCase();return e.entries.filter(I=>v(I,t)&&(!o||I.kind===o)&&(!S||`${I.id} ${I.title} ${I.body} ${I.tags.join(" ")}`.toLowerCase().includes(S)))},[e.entries,e.stale,t,o,c]);if(!e.open)return null;const x=k.find(S=>S.id===h)??k[0],j=S=>e.entries.filter(I=>v(I,S)).length,b=[["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:S=>S.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:"Field guide"}),i.jsx(ti,{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:[b.map(([S,I])=>i.jsxs("button",{className:`chip ${t===S?"on":""}`,onClick:()=>s(S),children:[I," ",i.jsx("span",{className:"n",children:j(S)})]},S)),i.jsx(dt,{compact:!0,"aria-label":"Kind",value:o,onChange:a,options:[{value:"",label:"Any kind"},...Xx.map(S=>({value:S,label:S.replace("-"," ")}))]}),i.jsx("input",{className:"kn-search",placeholder:"Search",value:c,onChange:S=>d(S.target.value)})]}),i.jsxs("div",{className:"kn-body-grid",children:[i.jsx("ul",{className:"kn-list",children:k.length?k.map(S=>i.jsx(Ce,{as:"li",className:`kn-row st-${S.status}`,edge:p(S)?"attention":"neutral",selected:S===x,onOpen:()=>m(S.id),title:S.title,titleText:S.title,context:i.jsx(V,{parts:[{text:S.id,code:!0},S.kind.replace("-"," "),p(S)&&S.status!=="suggested"?"Needs a check":TN[S.status]]})},S.id)):i.jsx(Ae,{children:t==="review"?"Nothing needs you":"No entries"})}),x?i.jsx($N,{e:x}):i.jsx(Ae,{children:"Pick an entry"})]})]})})}function Cu({draft:e,label:t="Save as knowledge"}){const s=ii(),[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 AN=e=>{try{return JSON.parse(e)}catch{return}};function Sg(e){const t=Zs();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,d=[hs(o),...a?[wu(h=>a(h)&&o())]:[],...Object.entries(c).map(([h,m])=>ei(h,p=>m(AN(p))&&o()))];return o(),{reload:o,pushed:()=>t.pushed(),stop:()=>{s=!0;for(const h of d)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=Sg({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,j;return((j=(x=t.current).changed)==null?void 0:j.call(x,k))===!0}}:{},events:Object.fromEntries(p.map(k=>[k,x=>{var j,b;return((b=(j=t.current.events)==null?void 0:j[k])==null?void 0:b.call(j,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 d=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:d,pushed:h}}const Ng=`${je()}/knowledge`;async function km(e,t){const s=await fetch(`${Ng}${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 IN(){const e=await fetch(Ng);return e.ok?await e.json():null}function MN(e){const[t,s]=y.useState([]),[o,a]=y.useState({}),[c,d]=y.useState({}),[h,m]=y.useState(!1),[p,v]=y.useState(),{reload:k}=pt({load:IN,show:j=>{j&&(s(j.entries),a(j.stale),d(j.hashes??{}))},changed:j=>j.startsWith("knowledge/")}),x=y.useMemo(()=>t.filter(j=>j.status==="suggested"||j.flag||o[j.id]&&j.status!=="outdated").length,[t,o]);return{entries:t,stale:o,briefText:e,attention:x,open:h,setOpen:m,error:p,hashes:c,call:(j,b,S)=>km("/call",{id:j,call:b,hash:S??c[j]}).then(()=>(v(void 0),k(),!0),I=>(v(I.message),k(),!1)),propose:j=>km("/propose",j).then(b=>(k(),b.entry),b=>(v(b.message),void 0))}}const RN=["awaiting","blocked","trail.done","resolved"];async function Wn(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 LN(e){const t=`${e}/slack`;return{get:()=>Wn(t),connectStart:s=>Wn(`${t}/connect/start`,"POST",{project:s}),connectPreview:s=>Wn(`${t}/connect/preview`,"POST",{code:s}),connectFinish:s=>Wn(`${t}/connect/finish`,"POST",{code:s}),connectCancel:()=>Wn(`${t}/connect/cancel`,"POST",{}),disconnect:()=>Wn(`${t}/connect`,"DELETE"),update:s=>Wn(`${t}/settings`,"PUT",s),members:()=>Wn(`${t}/members`).then(s=>s.members)}}const Vn=LN(je());function ON(e){const{who:t}=e;return i.jsxs(i.Fragment,{children:[i.jsxs("p",{className:"sl-lead",children:["Connect as ",i.jsxs("b",{children:["@",t.user.name??t.user.id]})," in ",i.jsx("b",{children:t.workspace.name}),"? That Slack account becomes Scout's owner for this Teamtrail: questions and approvals reach it."]}),i.jsxs("div",{className:"c-actions",children:[i.jsx(P,{size:"sm",variant:"primary",onClick:e.onConnect,children:"Connect"}),i.jsx(P,{size:"sm",variant:"ghost",onClick:e.onCancel,children:"Cancel"})]})]})}const PN=e=>new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});function _N({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 ",PN(e.at),"). ",e.message]})}function DN({s:e,connecting:t}){return t?i.jsx("p",{className:"sl-lead",children:"Connecting Scout…"}):i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"sl-lead",children:"Answer agents, approve finished work and save threads as decisions from Slack. Scout is Teamtrail's Slack app: add it to your workspace and it talks to you about this machine's trails. Questions and answers pass through Teamtrail's Scout service; your trails, decisions and approvals stay here."}),e.legacy&&i.jsx("p",{className:"sl-lead",children:"You made your own Slack app with an earlier version. Scout is now one app, so add it again: your old app's tokens are deleted from this machine when you do."})]})}function ym(e){const[t,s]=y.useState(!1),o=()=>{s(!0),Vn.connectStart(or()).then(a=>location.assign(a.url),a=>{s(!1),e.onError(a.message)})};return i.jsx(P,{size:"sm",variant:"primary",disabled:t,onClick:o,children:e.again?"Add Scout to Slack again":"Add Scout to Slack"})}function zN(e){return i.jsx("a",{className:["btn",e.primary&&"primary",e.small&&"sm"].filter(Boolean).join(" "),href:Xs(e.href,["slack:"]),target:"_blank",rel:"noreferrer",onClick:e.onClick,children:e.children})}function wm({onRemoved:e}){const[t,s]=y.useState(!1);if(!t)return i.jsx(P,{size:"sm",variant:"ghost",onClick:()=>s(!0),children:"Disconnect"});const o=()=>void Vn.disconnect().then(a=>{s(!1),e(a)},()=>{});return i.jsxs(i.Fragment,{children:[i.jsx(P,{size:"sm",variant:"danger",onClick:o,children:"Disconnect and forget Slack settings"}),i.jsx(P,{size:"sm",variant:"ghost",onClick:()=>s(!1),children:"Keep"})]})}function BN(e){const{s:t}=e,s=t.state==="auth-error"||t.state==="other-service";return t.connected?i.jsxs("div",{className:"c-actions",children:[s?i.jsx(ym,{again:!0,onError:e.onError}):i.jsx(P,{size:"sm",on:t.enabled,onClick:e.onToggle,children:t.enabled?"Turn off":"Turn on"}),t.links.homeWeb&&i.jsx(zN,{small:!0,href:t.links.homeWeb,children:"Open Scout in Slack"}),i.jsx(wm,{onRemoved:e.onChanged})]}):i.jsxs("div",{className:"c-actions",children:[!e.busy&&i.jsx(ym,{again:t.legacy,onError:e.onError}),t.legacy&&i.jsx(wm,{onRemoved:e.onChanged})]})}const FN={awaiting:"Awaiting you",blocked:"Blocked","trail.done":"Trail done",resolved:"Resolved"};function UN({s:e}){const[t,s]=WN(e);return i.jsxs("div",{className:`sync-line ${t}`,title:e.error,children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:s})]})}function WN(e){switch(e.state){case"online":return["ok","Online"];case"connecting":return["","Connecting"];case"offline":return["warn","Offline · reconnecting"];case"auth-error":return["alert",`Disconnected · ${e.error??"add Scout to Slack again"}`];case"elsewhere":{const t=e.heldBy?` (${e.heldBy})`:"";return["warn",`Connected from another ${te.slug}${t}`]}case"other-service":return["alert","Not connected · this Teamtrail points at another Scout service"];case"unsupported":return["alert",e.error??"Not supported here"];default:return["",e.connected?"Off":"Not connected"]}}function HN(e){const{s:t,back:s}=e,o=!!s.confirm&&!t.connected;return i.jsxs(un,{className:VN(t),children:[i.jsxs("div",{className:"card-row",children:[i.jsx("b",{className:"choice-title t-row-title",children:"Scout in Slack"}),t.connected&&i.jsx(Qn,{className:t.enabled?"on":"",children:t.enabled?"On":"Off"})]}),t.connected&&i.jsx("div",{className:"c-loc",children:KN(t)}),t.connected&&i.jsx(UN,{s:t}),t.delivery&&i.jsx(_N,{problem:t.delivery}),!t.connected&&!o&&i.jsx(DN,{s:t,connecting:s.busy}),o&&i.jsx(ON,{who:s.confirm,onConnect:s.connect,onCancel:s.cancel}),e.error&&i.jsxs("div",{className:"test-line alert",children:["✕ ",e.error]}),!o&&i.jsx(BN,{s:t,busy:s.busy,onError:e.onError,onChanged:e.onChanged,onToggle:e.onToggle})]})}function KN(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].filter(Boolean).join(" · ")}function VN(e){const t=e.connected&&e.enabled?"active":"",s=e.connected?"":"open";return`connector ${t} ${s}`}function GN(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-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 qN(e){const[t,s]=y.useState(),[o,a]=y.useState();y.useEffect(()=>{Vn.members().then(s,h=>a(h.message))},[]);const c=new Set(e.owners.map(h=>h.id)),d=new Set(e.value.map(h=>h.id));return o?i.jsxs("div",{className:"test-line alert",children:["✕ ",o]}):t?i.jsx("div",{className:"choice-row compact sl-members",children:t.map(h=>i.jsx(mt,{on:c.has(h.id)||d.has(h.id),disabled:c.has(h.id),title:`@${h.name??h.id}`,sub:c.has(h.id)?"Owner":void 0,onClick:()=>e.onChange(d.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 QN(e){const{s:t,patch:s}=e,[o,a]=y.useState(!1),c=new Set(t.notify.events),d=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:"Added Scout from this machine"})]})]}),i.jsxs("div",{className:"sl-group",children:[i.jsx(Ve,{variant:"plain",size:"sm",children:"Allowed users"}),i.jsx(qN,{value:t.allow,owners:t.owners,onChange:p=>s({allow:p})},t.state)]}),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:!d,title:"DM to owner",onClick:()=>{a(!1),s({notify:{target:"dm",detail:"full"}})}}),i.jsx(mt,{on:d,title:"Channel",sub:t.notify.target!=="dm"?t.notify.target:void 0,onClick:()=>a(!0)})]}),d&&i.jsxs(i.Fragment,{children:[i.jsx(Ze,{label:"Channel ID (invite @Scout there first)",children:i.jsx(GN,{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:RN.map(p=>i.jsx(mt,{on:c.has(p),title:FN[p],onClick:()=>m(p)},p))})]}),i.jsx(Qc,{className:"dim",parts:[`${t.command} decide`,`${t.command} status`,`${t.command} inbox`,"Save as decision on any message"]})]})}function YN(){if(typeof location>"u")return;const e=/(?:^#|&)slack-link=([A-Za-z0-9_-]{43})/.exec(location.hash);if(e)return history.replaceState(null,"",`${location.pathname}${location.search}`),e[1]}const Nc={code:YN()};function JN(e){const[t,s]=y.useState(),[o,a]=y.useState(),[c,d]=y.useState(),[h,m]=y.useState(!!Nc.code),p=k=>d(k.message);y.useEffect(()=>{const k=Nc.code;k&&(Nc.code=void 0,s(k),Vn.connectPreview(k).then(a,p).finally(()=>m(!1)))},[]);const v=k=>{m(!0),a(void 0),k.then(e,p).finally(()=>m(!1))};return{busy:h,error:c,confirm:o,connect:()=>t&&v(Vn.connectFinish(t)),cancel:()=>v(Vn.connectCancel())}}function $u(e=0){const[t,s]=y.useState(),o=y.useCallback(()=>Vn.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 XN(e){const[t,s]=$u(3e3),o=JN(s),[a,c]=y.useState(),d=y.useRef(null);if(y.useEffect(()=>{var m;e.focus&&t&&((m=d.current)==null||m.scrollIntoView({block:"start"}))},[e.focus,!!t]),!t)return null;const h=m=>Vn.update(m).then(s,()=>{});return i.jsxs("div",{ref:d,className:"slack-settings",children:[i.jsx(HN,{s:t,back:o,error:a??o.error,onError:c,onToggle:()=>void h({enabled:!t.enabled}),onChanged:m=>{c(void 0),s(m)}}),t.connected&&i.jsx(QN,{s:t,patch:m=>void h(m)})]})}function ZN(e){if(e.legacy&&!e.connected)return{label:"Add Scout to Slack again",why:"Scout is now one Slack app; your own app no longer works"};if(e.connected&&e.state==="auth-error")return{label:"Slack disconnected",why:e.error??"Add Scout again"}}function e1(e){const{api:t,rt:s,brief:o}=e,{snap:a,actions:c}=t,[d]=$u(15e3),h=ii(),m=d?ZN(d):void 0;return i.jsx(NN,{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 t1(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,zw(t),la(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 n1(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 s1({id:e,text:t}){const[s,o]=y.useState(),a=s!==e;return i.jsx(aa,{size:1,framed:!1,state:a?"speaking":"alert",speaking:a?t.slice(0,60):void 0,onSpeakEnd:()=>o(e),className:"q-avatar"})}function i1(e){const{q:t}=e;return i.jsxs("div",{className:"msg open-q",children:[i.jsx(V,{parts:[t.agent,la(t.at)]}),i.jsx(s1,{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 r1(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 o1(e){const{activity:t,sessionId:s}=e,[o,a]=y.useState(""),[c,d]=y.useState(),h=y.useRef(null),m=y.useRef(null),p=t.sessions.find(O=>O.id===s),v=t.chats.filter(O=>O.sessionId===s),k=WS(t.pending,s,c??e.questionId),x=new Set(t.pending.filter(O=>O.sessionId===s).map(O=>O.id)),j=v.find(O=>!!k&&O.questionId===k.id),b=v.filter(O=>O!==j),S=p?e.snaps[p.mapId]:void 0,I=p!=null&&p.ticketId?S==null?void 0:S.tickets.find(O=>O.id===p.ticketId):void 0;y.useEffect(()=>{const O=h.current;O==null||O.scrollTo({top:O.scrollHeight,behavior:"smooth"})},[b.length,k==null?void 0:k.id]),y.useEffect(()=>{var O;k&&!e.onBack&&((O=m.current)==null||O.focus({preventScroll:!0}))},[k==null?void 0:k.id,e.onBack]);const C=O=>{!k||!O.trim()||(e.onAnswer(k.id,O.trim()),a(""))},R=a1(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(n1,{ticket:I,trail:S==null?void 0:S.map.title,agent:p.agent}),i.jsx("div",{className:"comms-log",ref:h,children:b.map(O=>i.jsx(t1,{m:O,stillOpen:!!O.questionId&&x.has(O.questionId),onAnswerThis:()=>d(O.questionId)},O.id))}),k&&i.jsx(i1,{q:k,chatId:j==null?void 0:j.id}),i.jsx(r1,{options:k==null?void 0:k.suggestions,onPick:C}),i.jsx(ma,{ref:m,className:"comms-input",value:o,onValueChange:a,onSubmit:C,disabled:!k,placeholder:k?"Answer":""})]}):i.jsx(Ae,{children:"No conversation"})]})}function a1(e,t){return e?t?"Your answer is needed":cn(e)?`${e.agent} is working…`:e.status==="done"?"Resolved · ticket closed":"Session ended":""}async function l1(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 c1({item:e}){const[t,s]=y.useState(!1),[o,a]=y.useState(),c=()=>{s(!0),a(void 0),l1(e).then(a,d=>a(d.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 u1(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 d1({item:e}){const[t,s]=y.useState(!1),[o,a]=y.useState(),c=d=>{s(!0),a(void 0),u1(e,d).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 h1({item:e}){return e.kind==="integration"?i.jsx(c1,{item:e}):e.kind==="tracker-settings"&&e.ref.includes(":")?i.jsx(d1,{item:e}):null}const f1=/(\S*\/\S*|#\d+)/g;function m1({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(f1).map((o,a)=>a%2===1?i.jsx("span",{className:"t-code",children:o},a):o)]},t))}):null}const bg={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"},p1={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"},g1=[{minutes:30,label:"30 min"},{minutes:120,label:"2 hours"},{minutes:1440,label:"Tomorrow"}],v1=["blocked","flag","stalled","policy","reroute","overlap","integration","model"];function Cg(e,t){return t||e.urgency==="blocking"?"urgent":v1.includes(e.kind)?"attention":"neutral"}const k1=[/^marked blocking$/,/^fyi\b/,/^soon\b/,/^waiting \d/,/^answer together/,/questions from /];function $g(e){return e.reasons.filter(t=>!k1.some(s=>s.test(t)))}function y1(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`:bg[t.kind],c=[];t.urgency==="blocking"&&c.push({text:"Blocking",urgent:!0,className:"urgency-tag"}),c.push({text:a,strong:!0});const d=o&&w1(t.title,o);return d&&c.push(d),e.otherTrail&&c.push((s==null?void 0:s.map.title)??t.mapId),c}function w1(e,t){if(!e.includes(t.key))return e.includes(t.title)?{text:t.key,code:!0}:`${t.key} ${t.title}`}function x1(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:[g1.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 j1=15e3;function S1(e){const{item:t}=e,s=t.title.split(`
141
+ `)[0],o=$g(t),a=e.now-t.since<j1;return i.jsx(Ce,{as:"li",className:`att-item k-${t.kind} u-${t.urgency} ${e.selected?"sel":""} ${a?"incoming":""}`,edge:Cg(t,e.interrupting),selected:e.selected,title:s,titleText:t.title,context:i.jsx(V,{parts:y1({item:t,snap:e.snap,otherTrail:e.otherTrail})}),detail:o.length>0&&i.jsx(m1,{reasons:o}),detailText:o.join(`
142
+ `),trailing:dn(e.now-t.since),onOpen:e.onOpen,actions:i.jsx(x1,{title:t.title,canDismiss:uj(t),onSnooze:e.onSnooze,onDismiss:e.onDismiss}),below:i.jsx(h1,{item:t})})}function N1(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 b1={question:"inbox-list",approval:"inbox-list approvals"};function C1(e){const{batch:t}=e,s=t.items.length>1,o=t.kind==="question"?"answer together":"review together",a=[`${t.items.length} ${p1[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 ${b1[t.kind]??""}`,children:e.children})]})}function $1(e,t){e.ticketId?t.openTicket(e.mapId,e.ticketId):t.selectTrail(e.mapId)}function Tg(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 $1(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 T1(e){const t=Yt(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),d=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:N1(s.items).map(h=>{var m;return i.jsx(C1,{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(S1,{item:p,snap:e.snaps[p.mapId],otherTrail:a(p.mapId)&&h.items.length<2,selected:p.kind==="question"&&d(p.ref)===e.selected,interrupting:c.has(p.id),now:t,onOpen:()=>Tg(p,e.handlers),onSnooze:v=>e.onSnooze(p.id,v),onDismiss:()=>e.onDismiss(p.id)},p.id))},h.key)})})}const xm={label:"Focus for 1 hour",change:{kind:"for",minutes:60}};function E1(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},xm];case"off":return[{...xm,primary:!0},{label:"Focus for 3 hours",change:{kind:"for",minutes:180}}];default:return e}}const jm=e=>la(e).slice(0,5),A1=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function I1(e){const t=`${e.items.length} waiting on you`;return e.heldBack===0?`Nothing held back · ${t}`:`${A1(e.heldBack,"item")} would interrupt you · ${t}`}function bc(e){const t=e.prefs.focus;return t?`Quiet hours ${t.from}–${t.to}`:"No quiet hours set"}const Sm=e=>`Items scoring ${e.policy.value.interrupt} or more interrupt you · ${e.items.length} waiting on you`;function M1(e){const t=e.focus;switch(t.kind){case"manual":case"hours":{const s=jm(t.until),o=t.kind==="manual"?"Switched on here":bc(e);return{word:"on",until:s,on:!0,title:`Focus is on until ${s}`,reason:o,detail:I1(e)}}case"paused":{const s=jm(t.until),o=`Quiet hours paused until ${s}`;return{word:"paused",until:s,on:!1,title:o,reason:bc(e),detail:Sm(e)}}case"off":return{word:"off",until:"",on:!1,title:"Focus is off",reason:bc(e),detail:Sm(e)};default:return t}}const R1="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 L1(e){const{view:t}=e,s=M1(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(xg,{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(ti,{text:R1})]}),i.jsx(V,{parts:[s.reason]}),i.jsx(V,{className:"focus-held",parts:[s.detail]}),i.jsxs("div",{className:"focus-panel-actions",children:[E1(t.focus).map(d=>i.jsx(P,{size:"sm",variant:d.primary?"primary":"default",onClick:()=>{c(),e.onChange(d.change)},children:d.label},d.label)),i.jsx(P,{size:"sm",variant:"ghost",onClick:()=>{c(),e.onSettings()},children:"Quiet hours"})]})]})})}function O1(e){const{view:t}=e,s=t.interrupting.length;return i.jsxs("span",{className:"attention-head",children:[i.jsx(L1,{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(si,{variant:"alert",size:14}),i.jsx("b",{children:s}),i.jsx("span",{className:"wl",children:" need you now"})]})]})}const Eg=`${je()}/attention`,P1=250;async function Nm(e,t,s){var c;const o=await fetch(`${Eg}${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 Ag(e){const[t,s]=y.useState(),[o,a]=y.useState(),[c]=y.useState(Zs),d=y.useCallback(()=>{const m=c.start();fetch(Eg).then(p=>p.ok?p.json():void 0).then(p=>p&&m()&&s(p)).catch(()=>{})},[c]);y.useEffect(()=>ei("attention",m=>{c.pushed(),s(JSON.parse(m))}),[c]),y.useEffect(()=>hs(d),[d]),y.useEffect(()=>{const m=setTimeout(d,P1);return()=>clearTimeout(m)},[d,e]);const h=(m,p)=>void Nm(m,"POST",p).then(()=>(a(void 0),d()),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=>Nm("/prefs","PUT",m).then(()=>(a(void 0),d(),!0),p=>(a(p.message),!1))}}function _1(e){return e.prefs.channel!=="browser"?!1:typeof Notification<"u"&&Notification.permission==="granted"}function D1(e){const t=new Notification(`${te.name} · needs you`,{body:e.title,tag:e.id});t.onclick=()=>{window.focus(),t.close()}}function z1(e){const t=y.useRef();y.useEffect(()=>{if(!e)return;const s=new Set(e.interrupting),o=t.current;if(t.current=s,!(!o||!_1(e)))for(const a of e.items)s.has(a.id)&&!o.has(a.id)&&D1(a)},[e])}function B1(e){const t=Yt(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:dn(t-s.at),onOpen:()=>e.onOpen(s.mapId,s.ticketId)},`${s.mapId}/${s.ticketId}`)})}):null}function bm({activity:e}){const t=Yt(1e3),s=fx(e);return i.jsxs("div",{className:"hitl-readout",children:[i.jsx(on,{layout:"inline",label:"Oldest",value:s.oldestAt?Qt(t-s.oldestAt):"—",urgent:!!s.oldestAt&&t-s.oldestAt>6e4,title:"Oldest open question"}),i.jsx(on,{layout:"inline",label:"Avg wait",value:s.avgWaitMs!==void 0?Qt(s.avgWaitMs):"—",title:`Average wait over ${s.answered} answered questions`}),i.jsx(on,{layout:"inline",label:"Answered",value:s.answered})]})}function F1(e){const t=Yt(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,d=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:d,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:dn(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 U1={pass:"Passed",fail:"Failed",error:"Could not run",interrupted:"Interrupted"},nr={off:"Off",checks:"Checks","checks+review":"Checks + review","checks+review+human":"Checks + review + you"},Ig={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."},W1=e=>e.exitCode===0&&!e.timedOut&&!e.error;async function Cm(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=>Cm(t)),act:e=>fetch(`${$o}/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(t=>Cm(t))};function H1(e){const[t,s]=y.useState([]),o=Object.values(e).map(c=>c.tickets.map(d=>`${d.id}:${d.state}:${d.status??""}`).join()).join("|"),{reload:a}=pt({version:o,load:lr.inbox,show:s});return y.useEffect(()=>Qs.onEvidence(a),[a]),t}function K1(e,t){return{...e,items:e.items.filter(s=>!(s.kind==="brief"&&s.mapId===t))}}function V1(e){var h;const t=[...e.activity.pending].sort((m,p)=>m.at-p.at),s=H1(e.snaps),o=(h=e.attention)==null?void 0:h.view,a=o&&e.briefShown?K1(o,e.currentMapId):o,c=a?a.items.length:t.length+s.length,d=i.jsx(Et,{hot:c>0,title:i.jsxs(i.Fragment,{children:[c>0&&i.jsx(si,{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:[d,i.jsx(bm,{activity:e.activity}),i.jsx(T1,{view:a,snaps:e.snaps,pending:e.activity.pending,currentMapId:e.currentMapId,selected:e.sessionId,handlers:e.handlers,onSnooze:e.attention.snooze,onDismiss:e.attention.dismiss})]}):i.jsxs("div",{className:"inbox-part",children:[d,i.jsx(bm,{activity:e.activity}),i.jsx(B1,{items:s,snaps:e.snaps,currentMapId:e.currentMapId,onOpen:e.onOpenTicket}),(t.length>0||!s.length)&&i.jsx(F1,{items:t,snaps:e.snaps,currentMapId:e.currentMapId,selected:e.sessionId,onOpen:e.onOpenQuestion})]})}function G1(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")},d=v=>{const k=e.activity.pending.find(x=>x.id===v);k&&(a(k.id),c(k.sessionId,k.ticketId))},h=i.jsx(V1,{activity:e.activity,snaps:e.snaps,currentMapId:e.currentMapId,sessionId:e.sessionId,attention:e.attention,handlers:e.handlers&&{...e.handlers,openQuestion:d},briefShown:!!e.above,onOpenQuestion:c,onOpenTicket:e.onOpenTicket}),m=i.jsx(o1,{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 q1(e){var h;const{snap:t}=e,s=t?Js(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(kg).map(m=>m.ticketId)),d=((h=e.selection)==null?void 0:h.kind)==="ticket"?e.selection.id:void 0;return i.jsxs("div",{className:"upnext",children:[i.jsx(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:ir(m)==="hitl"},k=Q1(v);return i.jsx("li",{className:`${d===m.id?"sel":""} st-${Y1(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 Q1(e){if(e.waiting)return"waiting on you";if(e.state==="claimed")return e.assignee??"claimed";const t=cg[e.state].toLowerCase();return e.hitl?`${t}, needs you`:t}function Y1(e){return e.waiting?"waiting":e.state==="frontier"&&e.hitl?"attention":e.state}function J1(e){const{api:t,nav:s}=e;return i.jsx(G1,{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(q1,{snap:t.snap,sessions:e.scoped.sessions,selection:t.selection,onSelect:s.select}),above:e.above})}function Wo({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"}],X1=9e3;function Z1(){const[e,t]=y.useState(0),[s,o]=y.useState(!1);y.useEffect(()=>{if(s)return;const c=setInterval(()=>t(d=>(d+1)%To.length),X1);return()=>clearInterval(c)},[s]);const a=To[e];return i.jsxs("div",{className:"command-bar real",children:[i.jsx(yg,{name:"map"}),i.jsx(Ve,{as:"h2",className:"zone-title-label",children:"Trail map"}),i.jsx(ti,{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(Wo,{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 eb(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 tb({onClose:e,tracker:t,onCreate:s}){const[o,a]=y.useState(),[c,d]=y.useState(!1),[h,m]=y.useState(),[p,v]=y.useState(""),[k,x]=y.useState(""),[j,b]=y.useState(""),[S,I]=y.useState(""),C=[p.trim(),k.trim(),j.trim()].filter(Boolean).join(". ").replace(/"/g,"'");return y.useEffect(()=>{const R=O=>O.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:j,onChange:R=>b(R.target.value)})}),i.jsx(Ze,{label:"Assumptions (optional, one per line)",children:i.jsx("textarea",{className:"new-trail-assumptions",rows:2,value:S,onChange:R=>I(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(Wo,{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(Wo,{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:()=>{d(!0);const R=S.split(`
144
+ `).map(O=>O.trim());s({title:p.trim(),destination:k.trim(),notes:j.trim(),assumptions:R.filter(Boolean)}).then(O=>a(O.key)).catch(O=>m(O.message)).finally(()=>d(!1))},children:"Create trail"})]})]})})}const $m=["Ready when you are","What's the next big idea?","I keep the party on the trail","Describe it, I frame it"],nb=5e3;function sb(){const e=Nu(),[t,s]=y.useState(0),[o,a]=y.useState(!0);return y.useEffect(()=>{if(o)return;const c=setTimeout(()=>{s(d=>(d+1)%$m.length),a(!0)},nb);return()=>clearTimeout(c)},[o]),i.jsxs("div",{className:"floating-scout","aria-hidden":"true",children:[i.jsx(aa,{variant:e?"night":"crt",size:3,framed:!1,speaking:o?$m[t]:void 0,onSpeakEnd:()=>a(!1),className:"fm-avatar"}),i.jsx("span",{className:"fm-shadow"})]})}function ib(e){return i.jsx(tb,{onClose:e.onClose,tracker:e.rt.adapter.label,onCreate:async t=>{const s=await dS(e.rt.adapter,t);return e.onCreated(s.id),s}})}const rb={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"},Tu=e=>rb[e];function Eu(e){var t;return((t=e.account)==null?void 0:t.kind)==="user"?e.account.login:void 0}const Cc=e=>!!e.auth&&!!Eu(e);function Mg(e,t){const s=Eu(e);return!e.auth||!s?void 0:`Will use ${t||"the repo you pick"} as ${s} (${Tu(e.auth)})`}function ob(e){if(!e.repo)return;const t=Eu(e),s=t?` as ${t}`:"",o=e.auth?`, using ${Tu(e.auth)}`:"";return`Connected to ${e.repo}${s}${o}`}function ab(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 lb(e){const{gh:t}=e;if(!t.auth)return null;const s=Mg(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 cb=/^[\w.-]+\/[\w.-]+$/;function ub(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=cb.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 Tm(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&&ab(t,e.now),!s&&"Checked when you connect"]}),onOpen:e.onPick})}const db=40;function Em(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:d,typed:h}=ub({repos:e.repos,detected:e.detected,query:t,limit:db}),m=d>c.length?`${d-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(Tm,{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(Tm,{repo:v,detected:v.fullName===e.detected,listed:a.has(v.fullName),selected:v.fullName===e.value,now:o,onPick:()=>e.onChange(v.fullName)},v.fullName))]}),i.jsx(V,{parts:[!d&&!h&&"No repo matches",m,p]})]})}function hb(e){const{list:t}=e;if(!t)return i.jsx(ni,{label:"Loading your repos…",rows:3,className:"picker-loading"});switch(t.kind){case"ok":return i.jsx(Em,{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(Su,{what:"Couldn't list your repos",reason:t.error,onRetry:e.onRetry}),i.jsx(Em,{repos:[],truncated:!1,detected:e.detected,value:e.value,onChange:e.onChange})]});default:return t}}const fb={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"},Ji=e=>e==="github"||e==="linear";function Rg(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:fb[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 mb(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:Xs(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(ni,{label:"Waiting for you to approve on GitHub…"})]})}function pb(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 gb(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=Fj(je());function Xi(e,t){e({tracker:t});const s=new URL(location.href);s.searchParams.delete("tracker"),location.href=s.toString()}function vb(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 d=setTimeout(()=>void zt.githubSignIn.poll().then(async h=>{c&&(h.kind==="signed-in"&&await o.current(),c&&s(gb(t,h)))},h=>c&&s({kind:"ended",reason:h.message})),Math.max(t.interval,1)*1e3);return()=>{c=!1,clearTimeout(d)}},[t]),y.useEffect(()=>{if(a)return()=>void zt.githubSignIn.cancel().catch(()=>{})},[a]),{state:t,start(){s({kind:"starting"}),zt.githubSignIn.start().then(c=>s(pb(c)),c=>s({kind:"ended",reason:c.message}))},cancel(){s({kind:"idle"})}}}function kb(e){const{state:t,start:s,cancel:o}=vb(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(ni,{label:"Asking GitHub for a code…"});case"code":return i.jsx(mb,{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 yb(e){var d,h;const{gh:t}=e,s=t.auth&&((d=t.account)==null?void 0:d.kind)==="unknown"?`Found ${Tu(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(kb,{onSignedIn:e.onSignedIn}),c&&i.jsx("span",{className:"t-label gh-or",children:"Or paste a token"}),i.jsx(Rg,{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 Lg({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 Au(e){const[t,s]=y.useState(),[o,a]=y.useState(0);y.useEffect(()=>{if(s(void 0),!e.enabled)return;let d=!0;return e.load().then(h=>d&&s(h),h=>d&&s(e.failed(h.message))),()=>{d=!1}},[e.enabled,e.key,o]);const c=y.useCallback(()=>a(d=>d+1),[]);return{value:t,retry:c}}function wb(e){const{value:t,retry:s}=Au({enabled:e.enabled,key:e.auth??"",load:()=>zt.githubRepos(),failed:o=>({kind:"error",error:o})});return{list:t,retry:s}}function Og(e){const t=e.s.github,s=Cc(t),[o,a]=y.useState(!s),[c,d]=y.useState(t.repo??t.detectedRepo??""),[h,m]=y.useState(""),[p,v]=y.useState(),[k,x]=y.useState(!1),{list:j,retry:b}=wb({enabled:!o,auth:t.auth});y.useEffect(()=>{s&&!h&&a(!1)},[s]);const S=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)}},I=async()=>{const U=await e.reload();U&&Cc(U.github)&&a(!1)},C=async()=>{await zt.githubSignIn.signOut().catch(()=>{});const U=await e.reload();a(!U||!Cc(U.github))},O=!!c&&!(!o&&!j)&&(!o||!!h||s);return i.jsxs("div",{className:"card inset tracker-setup",children:[o?i.jsx(yb,{gh:t,token:h,onToken:m,repo:c,onRepo:d,onSignedIn:I}):i.jsxs(i.Fragment,{children:[i.jsx(lb,{gh:t,repo:c,onUseAnother:()=>a(!0),onSignOut:()=>void C()}),i.jsx(hb,{list:j,detected:t.detectedRepo,value:c,onChange:d,onRetry:b})]}),i.jsx(Lg,{r:p}),i.jsx("footer",{children:i.jsx("button",{type:"button",className:"btn primary",disabled:k||!O,onClick:()=>void S(),children:k?"Connecting…":"Connect"})})]})}function xb(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 jb={LINEAR_API_KEY:"LINEAR_API_KEY",stored:"a saved key"},Iu=e=>jb[e]??e;function va(e){return(e==null?void 0:e.kind)==="user"?e:void 0}const Sb=e=>!!e.auth&&!!va(e.viewer);function Pg(e,t){if(e)return t?`${e} / ${t}`:e}function _g(e){const t=va(e.viewer);if(!t)return;const s=Pg(e.team,e.project)??"the team you pick",o=e.source?` (${Iu(e.source)})`:"";return`Will use ${s} in ${t.orgName} as ${t.name}${o}`}function Nb(e){const t=Pg(e.teamName??e.teamKey,e.projectName);if(!e.teamId||!t)return;const s=va(e.viewer),o=e.orgName??(s==null?void 0:s.orgName),a=o?` in ${o}`:"",c=s?` as ${s.name}`:"",d=e.auth?`, using ${Iu(e.auth)}`:"";return`Connected to ${t}${a}${c}${d}`}function bb(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 Cb(e){var a,c;const{ln:t}=e,s=t.auth&&((a=t.viewer)==null?void 0:a.kind)==="unknown"?`Found ${Iu(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(Rg,{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 $b(e){const{list:t}=e;if(!t)return i.jsx(ni,{label:"Loading projects…"});if(t.kind==="error")return i.jsx(Su,{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 Tb(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 Eb(e,t){return t&&e.some(s=>s.id===t)?t:e.length===1?e[0].id:void 0}function Ab(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},bb(t,e.now)]}),onOpen:e.onPick})}const Ib=40;function Mb(e){const[t,s]=y.useState(""),o=y.useMemo(()=>Date.now(),[]),{shown:a,matches:c}=Tb({teams:e.teams,query:t,limit:Ib}),d=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(Ab,{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,d,h]})]})}function Rb(e){const{list:t}=e;if(!t)return i.jsx(ni,{label:"Loading teams…",rows:3,className:"picker-loading"});switch(t.kind){case"ok":return i.jsx(Mb,{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(Su,{what:"Couldn't list your teams",reason:t.error,onRetry:e.onRetry});default:return t}}function Lb(e,t){const[s,o]=y.useState(e);return y.useEffect(()=>{const a=setTimeout(()=>o(e),t);return()=>clearTimeout(a)},[e,t]),s}function Ob(e){const{value:t,retry:s}=Au({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 Pb(e){const{value:t,retry:s}=Au({enabled:e.enabled,key:e.apiKey??"",load:()=>zt.linearTeams(e.apiKey),failed:o=>({kind:"error",error:o})});return{list:t,retry:s}}function _b(e){const t=Lb(e.apiKey.trim(),400),s=e.paste&&t?t:void 0,o=e.paste?!!t:!!e.ln.auth,a=Pb({enabled:o,apiKey:s}),c=Ob({teamId:e.teamId,apiKey:s,enabled:o}),d=a.list,h=c.list,m=(d==null?void 0:d.kind)==="ok"?d.teams:[],p=o&&!d,v=o&&!!e.teamId&&!h;return{enabled:o,list:d,teams:m,projects:h,loading:p||v,retryTeams:a.retry,retryProjects:c.retry}}function Dg(e){var oe;const t=e.s.linear,s=Sb(t),[o,a]=y.useState(!s),[c,d]=y.useState(""),[h,m]=y.useState(t.teamId??""),[p,v]=y.useState(t.projectId??""),[k,x]=y.useState(),[j,b]=y.useState(!1),{enabled:S,list:I,teams:C,projects:R,loading:O,retryTeams:U,retryProjects:X}=_b({ln:t,paste:o,apiKey:c,teamId:h});y.useEffect(()=>{s&&!c&&a(!1)},[s]),y.useEffect(()=>{(I==null?void 0:I.kind)==="ok"&&m(Eb(I.teams,t.teamId)??"")},[I]);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=(I==null?void 0:I.kind)==="ok"?I.viewer:t.viewer,G=o?null:t.auth,ve=_g({viewer:ie,team:Q==null?void 0:Q.name,project:W==null?void 0:W.name,source:G}),Pe=async()=>{if(Q){b(!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}),b(!1)}}},$e=D=>{m(D),v("")};return i.jsxs("div",{className:"card inset tracker-setup linear-setup",children:[o&&i.jsx(Cb,{ln:t,apiKey:c,onKey:d}),i.jsx(xb,{line:ve,email:(oe=va(ie))==null?void 0:oe.email,onUseAnother:o?void 0:()=>a(!0)}),S&&i.jsx(Rb,{list:I,value:h,onChange:$e,onRetry:U}),Q&&i.jsx($b,{list:R,value:p,onChange:v,onRetry:X}),i.jsx(Lg,{r:k}),i.jsx("footer",{children:i.jsx("button",{type:"button",className:"btn primary",disabled:j||O||!Q,onClick:()=>void Pe(),children:j?"Connecting…":"Connect"})})]})}function Db(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 zb(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 Bb(e){const{id:t,active:s,s:o}=e,a=Ji(t),c=s&&o?Fb(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:zb(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:Ub(t,o)}):null}function Fb(e,t){if(e==="github")return ob(t.github);if(e==="linear")return Nb(t.linear)}function Ub(e,t){return e==="github"?t.github.repo:[t.linear.teamKey,t.linear.projectName].filter(Boolean).join(" · ")}function Wb({status:e}){var c,d;if(!e)return null;const t=(c=e.rate)!=null&&c.limit?`${((d=e.rate.remaining)==null?void 0:d.toLocaleString())??"?"}/${e.rate.limit.toLocaleString()} req`:"",s=e.queued?` · ${e.queued} queued`:"",[o,a]=Hb(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 Hb(e,t){switch(e.state){case"online":return["ok",`Online · synced ${lg(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 Kb(e){const{id:t,active:s,configured:o,s:a}=e,c=Ji(t),d=!c||!!a,h=["card connector",s?"active":"",d?"":"disabled",e.open?"open":""];return i.jsxs("div",{className:h.join(" "),children:[i.jsxs("div",{className:"card-row",children:[i.jsx("b",{className:"choice-title t-row-title",children:e.name}),s&&i.jsx("span",{className:"pill on",children:"Active"})]}),i.jsx(Bb,{id:t,active:s,configured:o,location:e.location,s:a}),c&&s&&i.jsx(Wb,{status:a==null?void 0:a[t].status}),i.jsx(Db,{canSwitch:!s&&(!c||o),remote:c,usable:d,configured:o,open:e.open,onSwitch:e.onSwitch,onToggle:e.onToggle})]})}function zg(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 Vb(e){const[t,,s]=zg(5e3),[o,a]=y.useState(null),c=async h=>{t&&(h==="markdown"||Ji(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(()=>{}),Xi(e.update,h)},d=y.useMemo(()=>({github:!!(t!=null&&t.github.repo),linear:!!(t!=null&&t.linear.teamId)}),[t]);return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"connectors",children:Uj.map(h=>{const m=h.id;return i.jsx(Kb,{id:m,name:h.name,active:m===e.activeTracker,configured:Ji(m)&&d[m],open:o===m,location:e.location,s:t,onSwitch:()=>void c(m),onToggle:()=>Ji(m)&&a(o===m?null:m)},h.id)})}),t&&o==="github"&&i.jsx(Og,{s:t,reload:s,onConnected:()=>Xi(e.update,"github")}),t&&o==="linear"&&i.jsx(Dg,{s:t,onConnected:()=>Xi(e.update,"linear")})]})}function Gb(e,t){const s=e==null?void 0:e.github,o=e==null?void 0:e.linear,a=s&&t!=="github"?Mg(s,s.repo??s.detectedRepo):void 0,c=o&&t!=="linear"?_g({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 Bg(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 qb={github:"Checking for a GitHub login…",linear:"Checking for a Linear key…"};function Qb(e){var I;const{prefs:t,update:s}=e,[o,,a]=zg(5e3),[c,d]=y.useState(!1),h=(I=o==null?void 0:o.pending)==null?void 0:I.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=Gb(o??void 0,t.tracker),k=t.tracker==="github"||t.tracker==="linear",x=k&&(o==null?void 0:o.active)===t.tracker,j=k&&!x,b=C=>{s({onboarded:!0}),Xi(s,C)},S=async()=>{d(!0);const C=o&&!o.pending;t.tracker==="markdown"&&C&&await zt.connect({active:"markdown"}).catch(()=>{}),s({onboarded:!0}),t.tracker!==e.activeTracker&&Xi(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(pa,{className:"onb-title"})}),i.jsxs("h2",{className:"onb-question t-heading",children:[i.jsx(tN,{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(ni,{label:qb[t.tracker]??"Checking…"}),o&&t.tracker==="github"&&!x&&i.jsx(Og,{s:o,reload:a,onConnected:()=>b("github")}),o&&t.tracker==="linear"&&!x&&i.jsx(Dg,{s:o,onConnected:()=>b("linear")})]}),i.jsx(Ie,{title:"HITL transcript",children:i.jsx(Bg,{value:t.hitlTranscript,onChange:C=>s({hitlTranscript:C})})}),i.jsx("footer",{children:i.jsx(P,{variant:"primary",disabled:c||j,onClick:()=>void S(),children:"Get started"})})]})})}const sr=[{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 Fg(e){if(e===null)return null;const t=sr.find(a=>a.id===e);if(t)return{group:t.id};const s=sr.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 Yb(){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 ",te.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 Am={from:"18:00",to:"09:00"};function Jb(e){const t=e.focus!==void 0,s=e.focus??Am;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:Am),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 Xb=[{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 Zb(){typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()}function eC(){const{view:e,error:t,savePrefs:s}=Ag(0);if(!e)return null;const o=e.policy.value,a=`${te.dataDir}/attention.json`,c=h=>void s({...e.prefs,...h}),d=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:Xb,onChange:h=>{h==="browser"&&Zb(),c({channel:h})}})]}),e.prefs.channel==="browser"&&d&&i.jsx("span",{className:"vf-err",children:"The browser blocks notifications for this page. Allow them in its site settings."}),i.jsx(Jb,{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 tC=[5,15,30,60];function nC(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})}),tC.map(s=>i.jsx(mt,{on:t.enabled&&t.awayMinutes===s,title:`Away ${s} min`,onClick:()=>e.onChange({enabled:!0,awayMinutes:s})},s))]})}const sC={repo:"Committed to the repo",machine:"Only on this machine",browser:"Only in this browser"};function Qe(e){const t=e.storage&&sC[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 iC(e){const[t]=$u();return t?i.jsx(Ie,{title:"Slack",children:i.jsx(XN,{focus:e.focus})}):null}function rC({data:e,route:t}){return i.jsxs(i.Fragment,{children:[i.jsx(Qe,{id:"attention",storage:"repo",children:i.jsx(eC,{})}),i.jsx(Qe,{id:"slack",storage:"machine",children:i.jsx(iC,{focus:t.section==="slack"})}),i.jsx(Qe,{id:"trip-report",storage:"browser",children:i.jsx(Ie,{title:"Trip report",children:i.jsx(nC,{value:e.prefs.briefing,onChange:s=>e.update({briefing:s})})})})]})}const oC=[{version:"0.15.0",date:"2026-10-31",items:["Verification in the ticket inspector: the level that applies and where it comes from, every attempt newest first with the git evidence (base → head, files changed, flags), its checks, exit codes, durations and the failing output, and the full log on demand","Verifying, Rework and Blocked on the map, in the legend and as status counters on missions that verify completions","Operator calls on a verifying or blocked ticket: Approve, Re-run checks, Send to rework with a note, Accept anyway and Unblock. Overrides need a reason, and each call is kept as a verdict next to the attempts and in the mission history. Approve asks for a re-run when the code changed since the checks passed","Set the verification level of a mission (Settings → Verification) or of one ticket (inspector). Only you can change it; agents cannot","The inspector updates live while checks run","Independent review: at Checks + review, a passing completion gets a review ticket that another agent takes and answers with PASS, FAIL (with findings) or NEEDS_HUMAN. The agent that did the work is never given its own review","Waiting on you lists reviewed work to approve (Checks + review + you) and held tickets, and Slack posts them with Approve and Rework… buttons","Agents can name their pull request in `report_completion` (`pr`); PR and CI tracking then follows that PR first"]},{version:"0.14.0",date:"2026-10-31",items:["Ticket lifecycle in plain words: Ready, Backlog, Working, Done and Cancelled (with Verifying, Rework and Blocked to come with verification)","Every claim, release, return to queue, resolution and rule-out goes through one lifecycle engine that records who, why and when in `.miloops/.events/<mission>.jsonl` (local history, never committed)","Settings → Verification shows the checks in `.miloops/verification.json`: argv commands with timeouts, run without a shell, secrets kept out of their environment. Read-only","Completion is a claim: on missions started with `verification.json` present, an execute or task ticket is only done once its checks pass. A failed check sends it back for Rework with the failing output (agents see it in close_ticket, next_ticket and claim_ticket, and rework comes first in the queue); after 3 failed attempts, or when the checks cannot run, it waits on you as Blocked","New MCP tools `report_completion` and `verification_status`; missions started before verification, and research, grilling and prototype tickets, close exactly as before","Git evidence, no GitHub needed: each claim records HEAD and the uncommitted state, and each completion lists the files changed since then. It flags no changes, overlap with another active ticket, a branch switch or reset, and edits to `verification.json` (which send the ticket to you as Blocked). A pass on code that changed while its checks ran is re-run","Pull request and CI evidence: with `verification.json` and a GitHub token (Settings, `GITHUB_TOKEN` or `gh auth login`), the command center finds each ticket’s PR (its branch `miloops-<mission>-<ticket>`, a `miloops:<mission>#<ticket>` line in the PR body, or a link you set) and flags mismatches: done with the PR still open, PR merged while the ticket is in progress, PR closed unmerged, required checks failing or unknown, PR head not the verified commit. Flags never change a ticket. A CI chip in the header shows sync health and never shows synced after a failed sync"]},{version:"0.13.0",date:"2026-10-31",items:["Crash recovery for claims: an agent’s claim is a lease (15 min by default) that every tool call renews, including waits on your answer","When an agent crashes or goes silent, its ticket goes back to the queue on its own, and the activity log says so; the next agent picks it up from next_ticket or claim_ticket","The returned ticket keeps a handoff comment with the previous agent’s progress notes and decisions, so the next agent resumes instead of starting over","Stalled state on the map, in sessions and in the ticket inspector when a lease is about to run out, with a Release to queue action","Works with GitHub and Linear: the return is an ordinary comment + unassign, queued in the offline outbox like any other write","Set the lease with `miloops mcp --lease-minutes <n>` or `MILOOPS_LEASE_MINUTES`"]},{version:"0.12.0",date:"2026-10-31",items:["Slack: your own MILO app, created from a manifest and connected from your machine over Socket Mode in five guided steps (Settings → Slack or `miloops connect slack`)","Tokens stay in your local credential store next to the GitHub and Linear ones; nothing passes through MILOOPS servers","Agent questions arrive as a Slack DM with answer buttons and a Reply… box; answering there resolves the item in Waiting on you, and answering in the command center closes the DM","Save as decision on any message, or `/milo decide`: the form is prefilled with a summary of the thread, and the decision is recorded with a permalink, resolving the related ticket by default","`/milo status` and `/milo inbox` for the mission at a glance; DMs when a ticket is blocked or a mission is done","Allowed users, notification target and events in Settings → Slack","Slack setup without Paste clicks: press ⌘V / Ctrl+V anywhere, or in Chrome just come back to the tab after copying; pasting the app token opens the install page; MILO recognises you by your git email, so there is nothing to claim in Slack"]},{version:"0.11.0",date:"2026-10-31",items:["GitHub Issues tracker: missions are labelled issues, tickets are sub-issues, blocking uses native issue dependencies",'Linear tracker: missions are labelled issues in a team (optionally one project), tickets are sub-issues, blocking uses "blocks" relations',"Two-way sync: tickets, status, claims, comments, blockers and decisions written from MILOOPS land in the tracker; changes made there show up within seconds","Decisions are posted as comments on their ticket and listed in the mission","Connect from Settings with Test connection; GitHub reuses your gh login or GITHUB_TOKEN, Linear takes a personal API key","Tokens stay on your machine: kept by the local server, never sent to the browser or anywhere else","Offline and rate limits: changes queue and send in order when the tracker answers again; the connector shows status, queue and remaining requests","Connected agents (MCP) work on the active tracker: with GitHub or Linear connected, their missions, claims and decisions land there, and their sessions show live in the command center"]},{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"]}],aC=[{area:"Teamtrail Cloud",items:["Agents that run in the cloud, steered from the same Lookout"]}],lC=[{version:"0.28.0",date:"2026-11-12",items:["Scout is now one Slack app: Settings → Slack → Add Scout to Slack, no app to create and no tokens to paste","You confirm which Slack account becomes Scout’s owner before it connects; if you made your own Slack app before, add Scout again","High-risk calls are answered in the Lookout only, and so is approving an agent’s request to change your settings: Slack shows Open in Lookout, and Decline still works there"]},{version:"0.27.3",date:"2026-11-11",items:["On Linux, the Lookout sees every change an agent makes to a ticket again, not only the first: a claimed ticket no longer stays in the queue as waiting"]},{version:"0.27.2",date:"2026-11-11",items:["Settings, briefs, criteria, guides, reroutes and the other panels stay current through reconnects, and a GitHub or Linear map updates live again"]},{version:"0.27.1",date:"2026-11-11",items:["The map and the queue no longer miss a change made while the Lookout was loading or reconnecting"]},{version:"0.27.0",date:"2026-11-11",items:["Teamtrail opens your browser ready to sign in with one click; `teamtrail pair` does the same for another tab"]},{version:"0.26.2",date:"2026-11-11",items:["The Lookout shows the new teamtrail. wordmark"]},{version:"0.26.1",date:"2026-11-11",items:["A refreshed logo: the trail’s destination is larger, and there are light and dark versions that follow your theme"]},{version:"0.26.0",date:"2026-11-11",items:["The Lookout asks you to sign in: open the link `teamtrail` prints, and pair your phone with a QR code (again after each restart)","Your answers count only when you give them in the Lookout or Slack, and skipping discovery or changing a trail’s mode or destination waits for your Approve","Check commands, briefs, criteria and other trusted settings run only once you approve them on this machine, in Settings → Approvals","Changes made to trail files outside Teamtrail have no effect until you accept them"]},{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"]},...oC];function cC(){return i.jsxs("div",{className:"changelog",children:[i.jsxs("div",{className:"about",children:[i.jsx(pa,{className:"about-name"}),i.jsx("span",{className:"mono-label",children:te.category}),i.jsx("p",{className:"onb-tagline",children:te.tagline}),i.jsx(V,{parts:[te.assistant.name]})]}),i.jsx(Ie,{title:"Next",children:aC.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))}),lC.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 Ug(){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 Im={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"},Mm={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 Wg(e){return e.kind==="state"?uC(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 uC(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 dC="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 hC(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 fC=["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 mC(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 pC(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 gC=e=>e.files??(e.file?[e.file]:[]);function vC(e){const{item:t}=e,[s,o]=y.useState(!1),a=gC(t),c=t.revert??"restore";return i.jsx(Ce,{as:"li",className:"ap-row",edge:"attention",title:t.title,context:i.jsx(V,{parts:[Wg(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(pC,{files:a,busy:e.busy,onDelete:()=>(o(!1),e.onRevert(a)),onCancel:()=>o(!1)})]})})}function kC(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 yC(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:[Wg(t)]}),detail:Im[t.kind],detailText:Im[t.kind],below:i.jsxs("div",{className:"ap-below",children:[i.jsx("pre",{className:"ap-lines t-code",children:a.join(`
149
+ `)}),Mm[t.kind]&&i.jsx("p",{className:"ap-note t-meta",children:Mm[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 Rm(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 $c=async e=>e.ok?await e.json():void 0;async function Lm(){var p;const[e,t,s]=await Promise.all(["/trust","/trackers","/trackers/legacy-outbox"].map(v=>fetch(`${je()}${v}`))),o=await $c(e);if(!o)return null;const{items:a}=o,c=(p=await $c(t))==null?void 0:p.pending,d=await $c(s),h=o.firstRun===!0,m=o.stateFirstRun===!0;return{items:a,firstRun:h,stateFirstRun:m,...c?{tracker:c}:{},...d!=null&&d.writes?{oldQueue:d}:{}}}const wC=(e,t)=>{var s,o,a,c;return JSON.stringify([e.items.map(d=>d.hash),(s=e.tracker)==null?void 0:s.target,(o=e.oldQueue)==null?void 0:o.writes])===JSON.stringify([t.items.map(d=>d.hash),(a=t.tracker)==null?void 0:a.target,(c=t.oldQueue)==null?void 0:c.writes])};function xC(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 jC(){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),[d]=y.useState(Zs),h=y.useRef(0),m=y.useCallback(()=>{h.current++;const j=d.start(),b=S=>{j()&&(a.current=S,t(S),o(!1))};return Lm().then(b,()=>b(null))},[d]),p=y.useCallback(async()=>{if(c.current)return;const j=h.current,b=await Lm().catch(()=>null),S=a.current;h.current!==j||S===void 0||(!b||!S||!wC(b,S))&&o(!0)},[]);y.useEffect(()=>void m(),[m]),y.useEffect(()=>wu(j=>void(j.startsWith(".")||p())),[p]),y.useEffect(()=>hs(()=>void p()),[p]);const v=y.useCallback(async j=>{c.current++;try{const b=await j();return await m(),b}finally{c.current--}},[m]),k=y.useCallback(async j=>xC(await v(()=>Rm("/trust/approve",{items:j.map(b=>({key:b.key,hash:b.hash}))}))),[v]),x=y.useCallback(async(j,b)=>{await v(()=>Rm(j,b))},[v]);return{view:e,changed:s,load:m,approve:k,act:x}}function SC(){const{view:e,changed:t,load:s,approve:o,act:a}=jC(),c=Ug()!==!1,[d,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:j}=e,b=C=>!C.alone&&(C.kind==="state"?e.stateFirstRun&&C.standing==="elsewhere":e.firstRun),S=k.filter(C=>C.committed!==!1&&b(C)),I=k.length+(x?1:0)+(j?1:0);return i.jsxs(Ie,{title:"Approvals",children:[i.jsxs("p",{className:"vf-intro",children:["Some files in the repo tell ",te.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 ",te.name," shows here as changed outside ",te.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"})]}),I===0&&i.jsx("p",{className:"ap-none t-meta",children:"Nothing waiting. Everything the repo asks for is approved here."}),S.length>1&&i.jsx("p",{className:"ap-adopt",children:hC(S.length)}),k.some(C=>C.kind==="state")&&i.jsx("p",{className:"ap-note t-meta",children:dC}),I>0&&i.jsxs("ul",{className:"ap-list",children:[x&&i.jsx(kC,{tracker:x,busy:d,local:c,onDecide:C=>v(a("/trackers/approval",{use:C,target:x.target}))}),j&&i.jsx(mC,{queue:j,busy:d,local:c,onDecide:C=>v(a("/trackers/legacy-outbox",{action:C?"send":"discard",writes:j.writes}))}),k.map(C=>C.kind==="state"?i.jsx(vC,{item:C,busy:d,local:c,onAccept:()=>v(o([C])),onRevert:R=>v(a("/trust/revert",{key:C.key,hash:C.hash,remove:R}))},C.key):i.jsx(yC,{item:C,busy:d,local:c,onApprove:()=>v(o([C]))},C.key))]}),c&&S.length>1&&i.jsxs(P,{disabled:d||t,onClick:()=>v(o(S)),children:["Approve all ",S.length," committed"]}),!c&&I>0&&i.jsxs("p",{className:"t-meta",children:["Approve these on the machine ",te.name," runs on."]}),m&&i.jsx("span",{className:"vf-err",children:m}),i.jsx(V,{className:"set-hint",parts:fC})]})}function Hg(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 Kg=`${te.apiPrefix}`;async function Vg(e){const t=await e.json().catch(()=>({}));if(!e.ok)throw new Error(t.error??`Request failed (${e.status})`);return t}const Ho=async e=>Vg(await fetch(`${Kg}${e}`)),Gg=async(e,t)=>Vg(await fetch(`${Kg}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}));let qg;const Mo=new Set;let Kn;function Yc(e){qg=e;for(const t of Mo)t()}function Qg(e){Kn==null||Kn.pushed(),Yc(e)}const NC=()=>qg;function bC(e){return Mo.add(e),Kn??(Kn=Sg({load:()=>Ho("/guides"),show:Yc,failed:()=>Yc(null),changed:t=>t.includes("guides")})),()=>{Mo.delete(e),!Mo.size&&(Kn==null||Kn.stop(),Kn=void 0)}}function xn(){const e=y.useSyncExternalStore(bC,NC),t=y.useCallback(async(o,a)=>{try{Qg(await Gg(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 CC(e){var h;const{view:t,find:s}=xn(),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,d=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:d,children:c})}const $C={active:"Active",unapproved:"New, waiting for your approval",tampered:"Changed since you approved it",invalid:"Can't be used"},TC={active:"Approved",unapproved:"Not approved yet",tampered:"Changed since you approved it",invalid:"Can't be used"},Jc=e=>{var t;return e.origin==="local"&&(!((t=e.lock)!=null&&t.source)||e.lock.source==="local")};function EC(e){return Jc(e)?{text:TC[e.status],strong:e.status==="active"}:e.status==="active"?void 0:$C[e.status]}function Ko(e){try{return new URL(e).host}catch{return e}}function AC(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 ${Ko(t.registry)}`}const Mu=e=>e.map(t=>/\s/.test(t)?JSON.stringify(t):t).join(" "),Om=3;function IC(e,t){return e.length<=Math.max(t,Om+1)?e:`${e.slice(0,Math.max(t-1,Om)).trimEnd()}…`}function Yg(e){return e===Kj?"Verified":`Verified by ${Ko(e)}'s catalog`}function Jg(e,t){return e.builtin?{text:"Built in",strong:!0}:e.verified?{text:Yg(t),strong:!0}:"Not reviewed"}function MC(e){var c,d;const t=(c=e.lock)==null?void 0:c.review;if(!t||e.status!=="active")return;if(!t.verified)return"Not reviewed";const s=t.reviewedBy.length>0?`Reviewed by ${t.reviewedBy.join(", ")}`:void 0,o=(d=e.lock)==null?void 0:d.source;return{text:o&&o!=="local"?Yg(o.registry):"Verified",strong:!0,tip:s}}var RC=hp();function Xg(e){return A0(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 LC(e){var x;const{preview:t}=e,{act:s,find:o}=xn(),[a,c]=y.useState({kind:"ready"}),[d,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(j){h(j.message),c({kind:"ready"})}};if(t.entry.builtin)return i.jsxs("span",{className:"t-meta",children:["Built into ",te.name,": already available to every trail, nothing to add."]});if(a.kind!=="added"){const j=e.installed===t.entry.version,b=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||j||a.kind==="adding",onClick:()=>void p(),children:j?"Added":b}),d&&i.jsx("span",{className:"vf-err",children:d})]})}const v=((x=o(m))==null?void 0:x.pendingChecks)??a.pending,k=async(j,b)=>h(await s("/guides/checks/approve",{id:m,name:j,acknowledged:b}));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(j=>{var b,S,I;return i.jsxs("span",{className:"guide-check",children:[i.jsxs("code",{className:"t-code",children:[j,": ",Mu(((S=(b=t.guide)==null?void 0:b.proposedChecks[j])==null?void 0:S.run)??[])]}),i.jsx(Xg,{name:j,spec:((I=t.guide)==null?void 0:I.proposedChecks[j])??{run:[]},onApprove:(C,R)=>void k(C,R)})]},j)}),d&&i.jsx("span",{className:"vf-err",children:d})]})}function OC(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 Zg(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(OC,{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,d])=>i.jsxs("code",{className:"t-code guide-check",children:[c,": ",Mu(d.run),d.cwd&&` (in ${d.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 PC(e){const t=Xs(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 _C(e){const t=e.entry,[s,o]=y.useState(),[a,c]=y.useState();return y.useEffect(()=>{e.preview(t.id).then(o,d=>c(d.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}`,Jg(t,e.catalogUrl),t.reviewedBy.length>0&&`reviewed by ${t.reviewedBy.join(", ")}`]}),i.jsx("p",{className:"t-body",children:t.summary}),t.history.length>0&&i.jsx("ul",{className:"catalog-history",children:t.history.map(d=>i.jsxs("li",{className:"t-meta",children:[d.version," · ",i.jsx("code",{className:"t-code",children:d.commit.slice(0,8)})," · ",d.at.slice(0,10)]},`${d.version}-${d.commit}`))}),a&&i.jsx("span",{className:"vf-err",children:a}),s&&i.jsx(Zg,{p:s}),s&&i.jsx(PC,{repo:s.repo,id:t.id,version:t.version}),s&&i.jsx(LC,{preview:s,installed:e.installed,add:e.add})]})}function DC(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,Jg(t,e.catalogUrl),t.reported&&"Reported"]}),detail:t.summary,trailing:e.installed&&`installed ${e.installed}`,onOpen:e.onOpen})})}const Pm=e=>e?`registry=${encodeURIComponent(e)}`:"";function zC(e){const[t,s]=y.useState(),[o,a]=y.useState();y.useEffect(()=>{let h=!0;return s(void 0),a(void 0),Ho(`/guides/catalog?${Pm(e)}`).then(m=>h&&s(m),m=>h&&a(m.message)),()=>{h=!1}},[e]);const c=y.useCallback(h=>Ho(`/guides/catalog/preview?${Pm(e)}&id=${encodeURIComponent(h)}`),[e]),d=y.useCallback(async(h,m)=>{const p=await Gg("/guides/catalog/add",{registry:e,id:h,sha256:m});return Qg(p),p.installed},[e]);return{index:t,error:o,preview:c,add:d}}function BC(e){var S,I;const[t,s]=y.useState(((S=e.registries[0])==null?void 0:S.name)??""),o=zC(t||void 0),{find:a}=xn(),[c,d]=y.useState(""),[h,m]=y.useState(!0),[p,v]=y.useState(),k=o.index?I0({guides:o.index.guides},{query:c,verifiedOnly:h}):[],x=(I=o.index)==null?void 0:I.guides.find(C=>C.id===p),j=C=>{var R,O,U;return((R=a(C))==null?void 0:R.origin)==="local"?(U=(O=a(C))==null?void 0:O.guide)==null?void 0:U.version:void 0},b=e.registries.find(C=>C.name===t);return RC.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} · ${Ko(C.url)}`,hint:C.url})),onChange:s}),i.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})]}),b&&e.registries.length===1&&i.jsx(V,{parts:[`Catalog ${b.name}`,{text:Ko(b.url),code:!0}]}),x?i.jsx(_C,{entry:x,catalogUrl:(b==null?void 0:b.url)??"",installed:j(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=>d(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(DC,{entry:C,catalogUrl:(b==null?void 0:b.url)??"",installed:j(C.id),onOpen:()=>v(C.id)},C.id))})]})]})}),document.body)}function FC(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 d=e.r.pendingChecks.includes(a);return i.jsxs("span",{className:"guide-check",children:[i.jsxs("code",{className:"t-code",children:[a,": ",Mu(c.run)]}),d&&o&&i.jsx(Xg,{name:a,spec:c,busy:e.busy,onApprove:e.onApprove}),d&&!o&&i.jsx("span",{className:"t-meta",children:"approve the guide first"}),!d&&i.jsx("span",{className:"t-meta",children:"approved"})]},a)})]})}function UC(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(Zg,{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 WC="A file in guides/ replaces this built-in once you approve it; until then the built-in is used";function HC(e){var t,s;return e.override?WC:e.status==="unapproved"?(t=e.guide)==null?void 0:t.summary:e.reason??((s=e.guide)==null?void 0:s.summary)}function ev(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,d=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:d,context:i.jsx(V,{parts:[{text:s,code:!0},AC(t),MC(t),EC(t),t.guide&&KC(t.guide.checklist.length)]}),detail:HC(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(UC,{r:o,busy:e.busy,onApprove:h=>e.onAct("/guides/approve",{id:s,sha256:h})}),i.jsx(FC,{r:t,busy:e.busy,onApprove:(h,m)=>e.onAct("/guides/checks/approve",{id:s,name:h,acknowledged:m})})]})})})}const KC=e=>e===1?"1 checklist item":`${e} checklist items`;function VC(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:[te.slug," guides new <id>"]}),". It starts from a template in ",i.jsxs("code",{className:"t-code",children:[te.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(ev,{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:[te.slug," guides lint"]})," and"," ",i.jsx("a",{href:Vj,target:"_blank",rel:"noreferrer",children:"share it in the public catalog"}),"."]})]})}function GC(e){const{view:t,act:s}=xn(),[o,a]=y.useState(),[c,d]=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=>(j,b)=>{d(!0),s(j,b).then(S=>{a(S?{own:x,message:S}:void 0),d(!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=>!Jc(x)).map(x=>i.jsx(ev,{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:`${te.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(VC,{guides:t.guides.filter(Jc),busy:c,onAct:v(!0),error:k(!0)}),h&&i.jsx(BC,{registries:t.registries,onClose:()=>m(!1)})]})}function qC(e){const{view:t,act:s}=xn(),[o,a]=y.useState();if(!t)return null;const c=e.map.guides??[],d=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:d.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 QC(e,t){const[s,o]=y.useState(),a=`/guides/checklist?mapId=${encodeURIComponent(e)}&ticketId=${encodeURIComponent(t)}`;return pt({view:a,load:()=>Ho(a),show:c=>o(c.checklist),failed:()=>o(null),changed:c=>c.endsWith("checklist.json")}),s}function YC(e){const t=QC(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(Hg,{answers:t.answers})]})}const _m="";function JC(e){const{view:t,act:s}=xn(),[o,a]=y.useState();if(!t)return null;const c=e.ticket,d=t.guides.filter(p=>{var v;return p.status==="active"&&((v=p.guide)==null?void 0:v.handles.types.includes(c.type))}),h=[{value:_m,label:"No guide"},...d.map(p=>({value:p.id,label:p.guide.name,hint:p.guide.summary}))];c.guide&&!d.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??_m,options:h,onChange:m}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function XC(e){const{view:t,find:s}=xn();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 ZC(e){const{view:t}=xn(),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(JC,{mapId:e.mapId,ticket:s}):s.guide&&i.jsx(CC,{id:s.guide})]}),s.guide&&i.jsx(XC,{id:s.guide}),i.jsx(YC,{mapId:e.mapId,ticketId:s.id})]})}function e$(e){var m;const{view:t,find:s}=xn();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,d=o!=null&&o.guide?`${c} ${o.guide.version}`:c,h=a?`Guide ${d}: ${(o==null?void 0:o.reason)??"not installed"}`:`Guide: ${d}`;return{id:e,name:c,tip:h,off:a}}const tv="0.28.0-next.40",Xc="<endpoint>",Ru=mp(tv,["mcp","--http"]);function t$(e,t){const s=mp(tv,["connect",e,"--url"]),o=t===Xc?t:fp(t);return`read -rs ${te.tokenEnv} && export ${te.tokenEnv}
150
+ ${s} ${o}`}function n$(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 s$({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},...n$(s)]})},s.url)),!t&&i.jsx("li",{children:i.jsx(V,{className:"set-hint",parts:["For agents on other machines, start their server",{text:Ru,code:!0}]})})]})}function i$(e){const[t,s]=y.useState(""),[o,a]=y.useState(!1),[c,d]=y.useState(),h=async m=>{if(!m.trim()||o)return;a(!0);const p=await e.onCreate(m).catch(v=>v.message);a(!1),d(p),p||s("")};return i.jsxs("div",{className:"ra-new",children:[i.jsx(ma,{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 r$(){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 ",te.name," runs on. Open the Lookout there to manage them."]})})}function o$(e){const[t,s]=y.useState(!1),[o,a]=y.useState(!1),[c,d]=y.useState(),h=async()=>{a(!0),d(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 a$(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(o$,{name:s.name,onRevoke:()=>e.onRevoke(s.id)})},s.id))})}function Tc(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 l$=[{id:"claude",label:"Claude Code"},{id:"codex",label:"Codex"}];function c$(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. ",te.name," keeps only a fingerprint, so it can't show it again."]}),i.jsx(Tc,{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(Tc,{label:"Start command",value:Ru,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:l$.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(Tc,{label:"Connect command",value:t$(t,e.endpoint??Xc),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 ${Xc}.`,t==="codex"&&` Start Codex from the same shell: it reads $${te.tokenEnv} each time.`]}),i.jsx("span",{children:i.jsx(P,{variant:"primary",size:"sm",onClick:e.onDone,children:"I've copied it"})})]})}const nv=`${je()}/remote-agents`;async function Dm(e,t){const s=await fetch(`${nv}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return{ok:s.ok,reply:await s.json()}}async function u$(){const e=await fetch(nv);return e.ok?await e.json():(await e.json().catch(()=>({}))).elsewhere?"elsewhere":null}function d$(){const[e,t]=y.useState(),[s,o]=y.useState(),{pushed:a}=pt({load:u$,show:t,failed:()=>t(null),events:{"remote-agents":()=>!0}}),c=y.useCallback(m=>{a(),t({tokens:m.tokens,endpoints:m.endpoints})},[a]),d=y.useCallback(async m=>{const{ok:p,reply:v}=await Dm("/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 Dm("/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:d,revoke:h}}function h$(){var d;const{view:e,created:t,dismissCreated:s,create:o,revoke:a}=d$();if(!e)return null;if(e==="elsewhere")return i.jsx(r$,{});const c=(d=e.endpoints.find(h=>h.kind==="standalone"))==null?void 0:d.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(s$,{endpoints:e.endpoints}),t&&i.jsx(c$,{created:t,endpoint:c,onDone:s}),i.jsx(a$,{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(i$,{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:Ru}),", 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 zm={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"},f$={low:"the agent decides",medium:"the agent decides and records it",high:"you decide"},m$=e=>e[0].toUpperCase()+e.slice(1),Zc=Op.map(e=>({value:e,label:m$(e),hint:f$[e]}));function p$(e){const[t,s]=y.useState(""),[o,a]=y.useState("high"),{rules:c,onChange:d}=e,h=()=>{const m=t.trim();!m||c.some(p=>p.glob===m)||(d([...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:Zc,onChange:v=>d(c.map((k,x)=>x===p?{...k,level:v}:k))}),i.jsx("button",{className:"icon-btn","aria-label":`Remove ${m.glob}`,onClick:()=>d(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:Zc,onChange:a}),i.jsx(P,{onClick:h,disabled:!t.trim(),children:"Add"})]})]})}const sv=`${je()}/policy`;async function g$(){const e=await fetch(sv);return e.ok?await e.json():null}function v$(){const[e,t]=y.useState(),{pushed:s}=pt({load:g$,show:t,failed:()=>t(null),changed:a=>a.endsWith("policy.json")}),o=y.useCallback(async a=>{const c=await fetch(sv,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),d=await c.json();if(!c.ok)return d.error??`Saving failed (${c.status})`;s(),t(d)},[s]);return{view:e,save:o}}function k$(){const{view:e,save:t}=v$(),[s,o]=y.useState();if(!e)return null;const a=`${te.dataDir}/policy.json`,c=d=>{o(void 0),t(d).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:Lp.map(d=>i.jsxs("label",{className:"risk-row",children:[i.jsx("span",{children:zm[d]}),i.jsx(dt,{compact:!0,"aria-label":`${zm[d]} risk`,value:e.policy.categories[d],options:Zc,onChange:h=>c({...e.policy,categories:{...e.policy.categories,[d]:h}})})]},d))}),i.jsx(p$,{rules:e.policy.paths,onChange:d=>c({...e.policy,paths:d})}),e.errors.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[a," has errors, so the defaults apply until it is fixed."]})]}),i.jsx("ul",{className:"vf-errors",children:e.errors.map(d=>i.jsx("li",{children:d},d))})]}),e.defaults&&e.errors.length===0&&i.jsxs("span",{className:"set-hint t-meta",children:["Defaults. Changing anything saves ",a,", so your team shares it."]}),s&&i.jsx("span",{className:"vf-err",children:s})]})}const eu=`${je()}/workspaces`;async function y$(){const e=await fetch(eu);return e.ok?await e.json():null}function iv(){const[e,t]=y.useState(),{pushed:s}=pt({load:y$,show:t,failed:()=>t(null),changed:d=>d.endsWith("workspaces.json")||d.includes("workspaces/")||d.includes("leases/")}),o=y.useCallback(d=>{s(),t(d)},[s]),a=y.useCallback(async d=>{const h=await fetch(eu,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)}),m=await h.json();if(!h.ok)return m.error??`Saving failed (${h.status})`;o(m)},[o]),c=y.useCallback(async(d,h,m=!1)=>{const p=await fetch(`${eu}/remove`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:d,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 rv(e){const[t,s]=y.useState(!1),[o,a]=y.useState(),[c,d]=y.useState(!1),h=async m=>{d(!0),a(void 0);const p=await e.onRemove(m).catch(v=>({error:v.message,dirty:!1}));d(!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 w$(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(rv,{onRemove:s=>e.onRemove(t.mapId,t.ticketId,s)})},`${t.mapId}/${t.ticketId}`))}):null}function x$(e){const{view:t,remove:s}=iv(),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(rv,{label:"Remove workspace",onRemove:a=>s(e.mapId,e.ticketId,a)})]})}function j$(){const{view:e,save:t,remove:s}=iv(),[o,a]=y.useState();if(!e)return null;const c=e.settings.worktrees,d=()=>{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; ",te.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:d,children:c?"On":"Off"})]}),i.jsx(V,{className:"set-hint",parts:[{text:`${te.dataDir}/workspaces.json`,code:!0},Bm(e.workspaces.filter(h=>h.active).length,"active"),Bm(e.workspaces.filter(h=>!h.active).length,"finished")]}),i.jsx(w$,{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 Bm=(e,t)=>`${e} ${t}`;function S$({data:e,route:t}){return i.jsxs(i.Fragment,{children:[i.jsx(Qe,{id:"approvals",storage:"machine",children:i.jsx(SC,{})}),i.jsx(Qe,{id:"tracker",children:i.jsx(Ie,{title:"Tracker",children:i.jsx(Vb,{activeTracker:e.activeTracker,location:e.location,update:e.update})})}),i.jsx(Qe,{id:"workspaces",storage:"repo",children:i.jsx(j$,{})}),i.jsx(Qe,{id:"remote-agents",storage:"machine",children:i.jsx(h$,{})}),i.jsx(Qe,{id:"policy",storage:"repo",children:i.jsx(k$,{})}),i.jsx(Qe,{id:"guides",storage:"repo",children:i.jsx(GC,{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:ru}),i.jsxs("code",{children:[te.labelPrefix,":<type>"]}),i.jsx("code",{children:ou}),i.jsx("code",{children:au})]})})})]})}const tu=`${te.apiPrefix}/projects`;async function Eo(e,t,s){const o=await fetch(`${tu}${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 Ys={url:tu,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(`${tu}/briefing?since=${e}`);return t.ok?await t.json():void 0}};function ov(e){const[t,s]=y.useState(""),[o,a]=y.useState(),c=d=>{d.trim()&&(a(void 0),Ys.add(d.trim()).then(()=>(s(""),e.onAdded()),h=>a(h.message)))};return i.jsxs("div",{className:"pj-add",children:[i.jsx(ma,{value:t,onValueChange:s,onSubmit:c,action:"Add project",placeholder:`/path/to/repo (a ${te.dataDir} folder is created if missing)`,"aria-label":"Repo path",className:"t-code"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}const Bs=(e,t)=>e>0&&`${e} ${t}`;function N$(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 ${dn(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:[Bs(c.totals.done,"done"),Bs(c.trails.reduce((d,h)=>d+h.opened.length,0),"new tickets"),Bs(c.totals.agentDecisions,"agent decisions"),Bs(c.totals.waiting,"waiting on you"),Bs(c.totals.ruledOut,"ruled out"),Bs(c.totals.active,"agents active")]}),onOpen:()=>e.onOpen(o)},o))})]})}function b$(e){const[t,s]=y.useState(""),[o,a]=y.useState(!1),[c,d]=y.useState(),h=m=>{!m.trim()||o||(a(!0),d(void 0),e.onAnswer(m.trim()).then(()=>s(""),p=>d(p.message)).finally(()=>a(!1)))};return i.jsxs("div",{className:"pj-answer",children:[i.jsx(ma,{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 C$(e){const{item:t}=e,s=$g(t),o=t.kind==="question"&&t.agent?`${t.agent} asks`:bg[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:Cg(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:dn(e.now-t.since),onOpen:e.onOpen,below:e.onAnswer&&i.jsx(b$,{onAnswer:e.onAnswer})})}function $$(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(C$,{item:o,now:e.now,onOpen:()=>e.onOpen(o.projectId,o.id),onAnswer:o.kind==="question"&&s(o.projectId)?a=>Ys.answer(o.projectId,{questionId:o.ref,text:a}).then(e.onAnswered):void 0},`${o.projectId}/${o.id}`))})]})}const Ec=(e,t,s=`${t}s`)=>`${e} ${e===1?t:s}`;function T$(e){return e.interrupting>0?"urgent":e.phases.blocked+e.phases.rework+e.flags+e.stalled>0||e.state.kind==="missing"?"attention":"neutral"}function E$(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(Ec(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(Ec(e.flags,"PR flag")),e.stalled&&t.push(Ec(e.stalled,"stalled claim")),t.length||t.push(e.trails?"Nothing waiting":"No trails yet");const d=A$(e.tracker);return d&&t.push(d),t}function A$(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 I$(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 Vo(e,t,s){if(e.state.kind!=="missing"){if(e.state.kind==="elsewhere"){const o=e.state.url?Xs(e.state.url):void 0;if(!o)return;const a=new URL(o);s&&a.searchParams.set(Vs,s),window.open(a.toString(),"_blank","noopener");return}location.href=uS({id:e.id,home:t,tracker:e.tracker.kind,item:s})}}function av(e){const{p:t}=e,s=I$(t);return i.jsx(Ce,{as:"li",className:`project-card st-${t.state.kind}`,edge:T$(t),selected:e.current,title:t.name,titleText:t.path,context:i.jsx(V,{parts:E$(t)}),detail:s,detailText:s,trailing:t.lastActivity?dn(e.now-t.lastActivity):void 0,onOpen:e.onOpen})}const lv=`${Yo}:projects:seen`,Fm=24*36e5;function M$(e){try{const t=Number(localStorage.getItem(lv));return t>0?t:e-Fm}catch{return e-Fm}}function R$(e){try{localStorage.setItem(lv,String(e))}catch{}}function L$(){const[e,t]=y.useState();return y.useEffect(()=>{const s=Date.now();return Ys.briefing(M$(s)).then(t).catch(()=>{}),()=>R$(s)},[]),e}function O$(e){const{view:t,reload:s}=e.projects,o=Yt(15e3),a=L$();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=or()??t.home,d=m=>{const p=t.projects.find(v=>v.id===m);(p==null?void 0:p.id)===c?e.onClose():p&&Vo(p,t.home)},h=(m,p)=>{const v=t.projects.find(k=>k.id===m);if(v){if(v.id!==c)return Vo(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($$,{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(av,{p:m,current:m.id===c,now:o,onOpen:m.state.kind==="missing"?void 0:()=>d(m.id)},m.id))}),i.jsx(ov,{onAdded:s})]}),i.jsx(N$,{briefing:a,now:o,onOpen:d})]})]})}function P$(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=or()??a.home,d=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}),d>0&&i.jsx(us,{n:d,urgent:!0}),i.jsx("span",{className:"caret",children:"▾"})]}),t&&i.jsxs("div",{className:"trail-menu",role:"menu",children:[i.jsxs("button",{role:"menuitem",className:"trail-item all-projects",onClick:()=>{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&&Vo(h,a.home)},children:[i.jsx("span",{className:"mi-title",children:h.name}),i.jsx("span",{className:"mi-progress",children:_$(h.state.kind)}),i.jsx(us,{n:h.needsYou,urgent:h.interrupting>0,hideZero:!0})]},h.id))]})]})}function _$(e){return e==="missing"?"missing":e==="elsewhere"?"other Lookout":""}function D$(e){const t=Yt(15e3),{view:s}=e.projects;if(!s||!e.projects.many)return null;const o=or()??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(av,{p:a,current:!1,now:t,onOpen:a.state.kind==="missing"?void 0:()=>Vo(a,s.home)},a.id))})]})}async function z$(){const e=await fetch(Ys.url);return e.ok?await e.json():void 0}function cv(){const[e,t]=y.useState(),{reload:s,pushed:o}=pt({load:z$,show:a=>a&&t(a)});return y.useEffect(()=>ei("projects",a=>{o(),t(JSON.parse(a))}),[o]),{view:e,many:((e==null?void 0:e.projects.length)??0)>1,reload:s}}const B$=e=>[e.home&&{text:"This Lookout",strong:!0},e.state.kind==="missing"&&"Missing",{text:e.path,code:!0}];function F$(){const{view:e,reload:t}=cv(),[s,o]=y.useState();if(!e)return null;const a=c=>{o(void 0),c.then(t,d=>o(d.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:B$(c)}),actions:!c.home&&i.jsx(P,{size:"sm",variant:"ghost",onClick:()=>a(Ys.remove(c.id)),children:"Remove"})},c.id))}),i.jsx(ov,{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(Ys.setAutoRegister(!e.autoRegister)),children:e.autoRegister?"On":"Off"})]}),i.jsx(V,{className:"set-hint",parts:[{text:`${te.slug} projects add <path>`,code:!0},`--no-register or ${te.noRegisterEnv} opts one agent out`]}),s&&i.jsx("span",{className:"vf-err",children:s})]})}const U$=`${te.apiPrefix}/models`;async function W$(){const e=await fetch(U$);return e.ok?await e.json():null}function Lu(){const[e,t]=y.useState();return pt({load:W$,show:t,failed:()=>t(null),changed:s=>s.endsWith("models.json")||s.endsWith("map.md")||s.includes("/tickets/"),events:{attention:()=>!0}}),e}function H$({mapId:e,ticketId:t}){const s=Lu(),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 K$({view:e}){if(!e)return null;const t=`${te.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 uv={fast:"Fast",balanced:"Balanced",strongest:"Strongest"},V$={fast:"Haiku, mini and nano models",balanced:"Sonnet, GPT-4 models",strongest:"Opus, GPT-5 and o-series models"},G$=Lo.map(e=>({value:e,label:uv[e],hint:V$[e]}));function q$(e){return i.jsx("div",{className:"tier-grid",children:Xo.map(t=>{const s=e.tiers[t],o=cu[t];return i.jsxs("div",{className:"tier-row",children:[i.jsx("span",{children:er[t]}),i.jsx(dt,{compact:!0,"aria-label":`${er[t]} tickets' model`,className:`tier-select tier-${t}`,value:s,options:G$,onChange:a=>e.onChange(t,a)}),i.jsx(V,{className:"tier-hint",parts:[s!==o&&`default ${uv[o].toLowerCase()}`,e.hints[t]]})]},t)})})}const Ao=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function Q$({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:ln(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 dv(e){const[t,s]=y.useState({}),o=e.map(a=>`${a.map.id}:${a.tickets.reduce((c,d)=>Math.max(c,d.updatedAt),0)}`).join();return y.useEffect(()=>{let a=!0;return Promise.all(e.map(async c=>{const d=await fetch(`${je()}/journal?mapId=${encodeURIComponent(c.map.id)}`).catch(()=>{}),h=d!=null&&d.ok?await d.json():{entries:[]};return[c.map.id,h.entries]})).then(c=>{a&&s(Object.fromEntries(c))}),()=>{a=!1}},[o]),t}const Y$=[{id:"byVendor",title:"By vendor"},{id:"byAgent",title:"By agent"},{id:"byType",title:"By ticket type"}];function J$({api:e,bp:t,onClose:s}){const[o,a]=y.useState("byVendor"),c=y.useMemo(()=>Object.values(e.allSnaps),[e.allSnaps]),d=dv(c),h=e.activity.answered,m=y.useMemo(()=>Wp(c.map(p=>({snap:p,journal:d[p.map.id]??[],answered:h}))),[c,d,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:Y$.map(p=>i.jsx(mt,{on:o===p.id,title:p.title,onClick:()=>a(p.id)},p.id))}),i.jsx(Q$,{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 X$(e,t){const s=dv(e);return y.useMemo(()=>{var c;const o=Wp(e.map(d=>({snap:d,journal:s[d.map.id]??[],answered:t}))),a={};for(const d of o.byType){if(!d.done)continue;const h=(c=o.recommendations.find(p=>p.id===`speed-${d.key}`))==null?void 0:c.text,m=[`Trail stats: ${d.done} done`,d.medianLeadMs!==void 0&&`median ${ln(d.medianLeadMs)}`,d.reworkCycles>0&&`${d.reworkCycles} back to rework`,h];a[d.key]=m.filter(Boolean).join(" · ")}return a},[e,s,t])}function Z$(e){var d,h;const t=Lu(),s=X$(e.snaps,e.answered),o=e.map;if(!o)return null;const a=!!((d=o.modelMatching)!=null&&d.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(q$,{tiers:Ky(o),hints:s,onChange:(m,p)=>{const v={...c,[m]:p};p===cu[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(K$,{view:t})]})}function Yi(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 eT(){const e=await fetch(`${je()}/verification/config`);return e.ok?await e.json():null}function tT(){const[e,t]=y.useState();return pt({load:eT,show:t,failed:()=>t(null),changed:s=>s.endsWith("verification.json"),events:{attention:()=>!0}}),e}const Um=`{
153
+ "v": 1,
154
+ "checks": {
155
+ "test": { "run": ["npm", "test"] },
156
+ "lint": { "run": ["npm", "run", "lint"] }
157
+ },
158
+ "run": ["test", "lint"]
159
+ }
160
+ `;function nT({file:e}){const[t,s]=y.useState(!1),o=()=>void navigator.clipboard.writeText(Um).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:Um}),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 sT(e){var p;const t=tT(),[s,o]=y.useState();if(!t)return null;const a=e.map,c=t.config,d=`${te.dataDir}/${t.file}`,h=(a==null?void 0:a.verification)??"off",m=(c??$p).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:lu.map(v=>i.jsx(mt,{on:h===v,title:nr[v],sub:Ig[v],onClick:()=>{o(void 0),lr.act({action:"level",mapId:a.id,level:v,by:St}).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:[d," 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:Yi(location.href,{group:"project",section:"approvals"}),children:"Review the commands"})]})]}),!t.exists&&i.jsx(nT,{file:d}),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:d})," · ",c.run.length," checks run on every completion"]})]}),i.jsx(V,{className:"set-hint",parts:[`New trails start at ${nr[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 ",d,". 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 iT({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(eb,{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(sT,{map:t})}),i.jsx(Qe,{id:"models",children:i.jsx(Z$,{map:t,snaps:e.snaps,answered:e.answered,onChange:e.onModelMatching})}),t&&i.jsx(Qe,{id:"team",children:i.jsx(qC,{map:t})})]})}const Wm=10,hv=[0,10,16,26,18,24,16,18,22,22,26],fv=[0,1,1,1,2,2,4,4,4,5,5];function mv(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 rT=e=>hv[e],oT=e=>fv[e],pv=e=>Math.floor(mv(e)/8)-hv[e]*fv[e],gv=e=>e<10?8:16;function aT(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 nu(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 lT(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]=nu(t[a],s),a+1<t.length&&(t[a]^=t[a+1]);s=nu(s,2)}return t}function cT(e,t){const s=t.map(()=>0);for(const o of e){const a=o^s.shift();s.push(0),t.forEach((c,d)=>s[d]^=nu(c,a))}return s}function uT(e,t){const s=[],o=(d,h)=>{for(let m=h-1;m>=0;m--)s.push(d>>>m&1)};o(4,4),o(e.length,gv(t));for(const d of e)o(d,8);const a=pv(t)*8;o(0,Math.min(4,a-s.length)),o(0,(8-s.length%8)%8);for(let d=236;s.length<a;d^=253)o(d,8);const c=[];for(let d=0;d<s.length;d+=8)c.push(s.slice(d,d+8).reduce((h,m)=>h<<1|m,0));return c}function dT(e,t){const s=uT(e,t),o=oT(t),a=rT(t),c=Math.floor(mv(t)/8),d=o-c%o,h=Math.floor(c/o),m=lT(a),p=[];for(let k=0,x=0;k<o;k++){const j=s.slice(x,x+h-a+(k<d?0:1));x+=j.length;const b=cT(j,m);k<d&&j.push(0),p.push([...j,...b])}const v=[];for(let k=0;k<p[0].length;k++)for(let x=0;x<p.length;x++)(k!==h-a||x>=d)&&v.push(p[x][k]);return v}const hT=[(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 Ac(e,t){const s=hT[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 Hm(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 fT(e){let t=0,s=0;for(let a=0;a<e.size;a++)t+=Hm(e.dark[a]),t+=Hm(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 d=e.dark[a][c];d===e.dark[a][c+1]&&d===e.dark[a+1][c]&&d===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 rn=(e,t)=>(e>>>t&1)!==0;function Nt(e,t,s,o){e.dark[s][t]=o,e.fixed[s][t]=!0}function Ic(e,t,s){for(let o=-4;o<=4;o++)for(let a=-4;a<=4;a++){const c=t+a,d=s+o,h=Math.max(Math.abs(a),Math.abs(o));c>=0&&c<e.size&&d>=0&&d<e.size&&Nt(e,c,d,h!==2&&h!==4)}}function mT(e,t,s){for(let o=-2;o<=2;o++)for(let a=-2;a<=2;a++)Nt(e,t+a,s+o,Math.max(Math.abs(a),Math.abs(o))!==1)}function su(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++)Nt(e,8,c,rn(a,c));Nt(e,8,7,rn(a,6)),Nt(e,8,8,rn(a,7)),Nt(e,7,8,rn(a,8));for(let c=9;c<15;c++)Nt(e,14-c,8,rn(a,c));for(let c=0;c<8;c++)Nt(e,e.size-1-c,8,rn(a,c));for(let c=8;c<15;c++)Nt(e,8,e.size-15+c,rn(a,c));Nt(e,8,e.size-8,!0)}function pT(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,d=Math.floor(a/3);Nt(e,c,d,rn(o,a)),Nt(e,d,c,rn(o,a))}}function gT(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 d=0;d<t;d++)Nt(o,6,d,d%2===0),Nt(o,d,6,d%2===0);Ic(o,3,3),Ic(o,t-4,3),Ic(o,3,t-4);const a=aT(e),c=a.length-1;for(let d=0;d<=c;d++)for(let h=0;h<=c;h++)d===0&&h===0||d===0&&h===c||d===c&&h===0||mT(o,a[d],a[h]);return su(o,0),pT(o,e),o}function vT(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 d=a?e-1-c:c;t.push([o,d],[o-1,d])}}return t}function kT(e,t){let s=0;for(const[o,a]of vT(e.size))e.fixed[a][o]||s>=t.length*8||(e.dark[a][o]=rn(t[s>>>3],7-(s&7)),s++)}function yT(e){const t=new TextEncoder().encode(e);let s=1;for(;s<=Wm&&4+gv(s)+t.length*8>pv(s)*8;)s++;if(s>Wm)return;const o=gT(s);kT(o,dT(t,s));let a=0,c=1/0;for(let d=0;d<8;d++){Ac(o,d),su(o,d);const h=fT(o);h<c&&([a,c]=[d,h]),Ac(o,d)}return Ac(o,a),su(o,a),o.dark}const Mc=4;function wT(e){const t=yT(e.text);if(!t)return null;const s=t.length+Mc*2,o=t.flatMap((a,c)=>a.map((d,h)=>d?`M${h+Mc} ${c+Mc}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 xT(e){const t=Yt(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(wT,{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 jT(e){const[t,s]=y.useState();return e.device?i.jsx(xT,{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:[te.slug," --host 0.0.0.0"]})," on a network you trust. Another browser on this machine: run ",i.jsxs("code",{className:"t-code",children:[te.slug," pair"]}),"."]})}function ST(e){const[t,s]=y.useState(!1),[o,a]=y.useState(!1),[c,d]=y.useState(),h=async()=>{a(!0),d(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 NT={machine:"This machine",device:"Another device"};function bT(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:[NT[s.kind],s.via==="opened-page"?`From the page ${te.name} opened`:void 0,s.via==="opened-page"?{text:Gj(s.id),code:!0}:void 0,`Paired ${Uo(s.pairedAt,t)}`,`Last used ${Uo(s.lastUsedAt,t)}`]}),below:s.current?void 0:i.jsx(ST,{name:s.name,onRevoke:()=>e.onRevoke(s.id)})},s.id))})}function CT(){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 ",te.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:[te.slug," connect"]})," sets that up for the agents it registers."]})]})}const vv=`${te.apiPrefix}/sign-in`;async function Rc(e,t={}){const s=await fetch(`${vv}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return{ok:s.ok,reply:await s.json().catch(()=>({}))}}function $T(){const[e,t]=y.useState(),[s,o]=y.useState(),a=y.useCallback(()=>{fetch(`${vv}/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 Rc("/codes");if(!m)return p.error??"No code could be made.";o(p)},[]),d=y.useCallback(async m=>{const{ok:p,reply:v}=await Rc("/revoke",{id:m});return a(),p?void 0:v.error??"That browser could not be revoked."},[a]),h=y.useCallback(async()=>{await Rc("/sign-out"),dg(),location.reload()},[]);return{view:e,device:s,closeDevice:()=>(o(void 0),a()),pairDevice:c,revoke:d,signOut:h}}function TT(){const{view:e,device:t,closeDevice:s,pairDevice:o,revoke:a,signOut:c}=$T();if(!e)return null;const d=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."}),d]}):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(bT,{sessions:e.sessions,onRevoke:a}),i.jsx(jT,{lan:e.lan,device:t,onPair:o,onDone:s}),d,i.jsx(CT,{})]})}function ET(){return y.useEffect(()=>{const e=setInterval(()=>void ua().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(pa,{className:"onb-title"})}),i.jsxs("h1",{className:"t-heading pair-title",children:[te.name," isn’t running here"]}),i.jsxs("p",{className:"t-body pair-step",children:["Start it with ",i.jsx("code",{className:"t-code",children:te.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 Ou(e){const t=await fetch(`${te.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&&wS({id:s.id,secret:s.session,verifier:s.verifier})}function AT(e){const[t,s]=y.useState(!1),o=async()=>{s(!0);const a=await Ou(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:te.slug}),", ",i.jsxs("code",{className:"t-code",children:[te.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 Km(){const[e,t]=y.useState(""),[s,o]=y.useState(!1),[a,c]=y.useState(),d=async()=>{if(!e.trim()||s)return;o(!0);const h=await Ou(e);o(!1),c(h),h||location.reload()};return i.jsxs("form",{className:"pair-device",onSubmit:h=>{h.preventDefault(),d()},children:[i.jsxs("p",{className:"t-body pair-step",children:["On a phone or another computer: in the Lookout on the machine ",te.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 Vm(){return i.jsxs("p",{className:"t-body pair-step pair-here",children:["On the machine ",te.name," runs on, run ",i.jsxs("code",{className:"t-code",children:[te.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:te.slug})," printed in its terminal."]})}function IT(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(Vm,{}):i.jsx(Km,{}),e.local?i.jsx(Km,{}):i.jsx(Vm,{})]})}function MT(e){const[t,s]=y.useState(),[o,a]=y.useState(e.code),[c,d]=y.useState(e.code);e.code!==c&&(d(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(pa,{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(AT,{code:o,onFailed:h}):i.jsx(IT,{local:e.local})]})})}function Gm(){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 qm(){try{const e=await fetch(`${te.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 RT(){if(!ku())return qm();const e=await ua();return e==="proven"?{kind:"signed-in"}:e==="unknown"?qm():{kind:"not-running"}}function LT(){const[e,t]=y.useState({kind:"checking"});return y.useEffect(()=>void RT().then(t),[]),y.useEffect(()=>xS(s=>s==="failed"&&t({kind:"not-running"})),[]),e}function OT({children:e}){const t=LT(),[s,o]=y.useState(Gm);return y.useEffect(()=>{const a=()=>o(c=>Gm()??c);return window.addEventListener("hashchange",a),()=>window.removeEventListener("hashchange",a)},[]),y.useEffect(()=>{t.kind==="signed-in"&&s&&Ou(s)},[t.kind,s]),t.kind==="checking"?null:t.kind==="signed-out"?i.jsx(MT,{local:t.local,code:s}):t.kind==="not-running"?i.jsx(ET,{}):i.jsx(i.Fragment,{children:e})}const PT=[{value:"auto",title:"Match my system"},{value:"day",title:"Day"},{value:"night",title:"Night"}];function _T(e){return i.jsx("div",{className:"choice-row compact",children:PT.map(t=>i.jsx(mt,{on:e.value===t.value,title:t.title,onClick:()=>e.onChange(t.value)},t.value))})}function DT({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(_T,{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(Bg,{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:eg.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(TT,{})})]})}function zT(e){const{data:t,route:s}=e;switch(e.group){case"trail":return i.jsx(iT,{data:t});case"project":return i.jsx(S$,{data:t,route:s});case"alerts":return i.jsx(rC,{data:t,route:s});case"you":return i.jsx(DT,{data:t});case"projects":return i.jsx(Qe,{id:"projects",storage:"machine",children:i.jsx(F$,{})});case"about":return i.jsx(Qe,{id:"changelog",children:i.jsx(cC,{})});default:return e.group}}function BT(e){const{group:t,route:s}=e,o=y.useRef(null),a=y.useRef(null);return y.useEffect(()=>{var d,h;(d=o.current)==null||d.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(zT,{group:t.id,data:e.data,route:s})]})})}function FT(e){return i.jsx("nav",{className:"sp-nav","aria-label":"Settings groups",children:i.jsx("ul",{children:sr.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 UT(e,t){return e.group?sr.find(s=>s.id===e.group):t==="mobile"?void 0:sr[0]}const WT={page:"Back to the Lookout",list:"Lookout",group:"Settings"},HT=(e,t)=>e?t?"group":"list":"page";function KT(e){const{bp:t,route:s}=e,o=t==="mobile",a=UT(s,t),c=HT(o,!!a),d=Ug()===!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(FT,{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:["‹ ",WT[c]]}),c!=="group"&&i.jsx(Ve,{as:"h2",children:"Settings"}),!o&&i.jsx("span",{className:"dv-head-right t-meta",children:"Esc"})]}),d&&i.jsx(Yb,{}),i.jsxs("div",{className:"sp-body",children:[p,a&&i.jsx(BT,{group:a,data:e.data,route:s})]})]})}function VT(e){var a;const{rt:t,api:s,settings:o}=e;return o.route?i.jsx(KT,{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 GT(e){return i.jsxs(ze,{className:"zone side",style:{gridArea:"inspector"},children:[i.jsx(sN,{className:"zone-tabs",value:e.tab,onChange:e.onTab,items:[{id:"ticket",label:"Ticket"},{id:"activity",label:"Activity"},{id:"plan",label:"Plan",n:e.unspecified}]}),{ticket:e.ticket,activity:e.activity,plan:e.plan}[e.tab]]})}function kv(e){return e.filter(t=>t.state!=="out-of-scope").map(t=>({x:t.x,y:t.y,w:Ke,h:Ye}))}function qT(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),d=h=>Math.abs(h-s)+Math.abs(h-o);return c.reduce((h,m)=>d(m)<d(h)?m:h,c[0]??s)}const QT=6;function YT(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,d,h]=[t[a-1],t[a],t[a+1]],m=Math.min(QT,Qm(c,d)/2,Qm(d,h)/2),p=Ym(d,c,m),v=Ym(d,h,m);s+=`L${p.x} ${p.y}Q${d.x} ${d.y} ${v.x} ${v.y}`}const o=t[t.length-1];return`${s}L${o.x} ${o.y}`}function Qm(e,t){return Math.abs(e.x-t.x)+Math.abs(e.y-t.y)}function Ym(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 Go(e){const t=e.direction==="TB",s=d=>t?{x:d.y,y:d.x}:d,o=s(e.a),a=s(e.b),c=e.obstacles.map(d=>t?{x:d.y,y:d.x,w:d.h,h:d.w}:d);return YT(JT({a:o,b:a,obstacles:c,gap:e.gap}).map(s))}function JT({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),d=Math.min(e.x+o/2,(e.x+t.x)/2),h=Math.max(t.x-o/2,(e.x+t.x)/2);if(c(e.y))return[e,{x:h,y:e.y},{x:h,y:t.y},t];if(c(t.y))return[e,{x:d,y:e.y},{x:d,y:t.y},t];const m=qT({obstacles:a,from:e.y,to:t.y,clear:c});return[e,{x:d,y:e.y},{x:d,y:m},{x:h,y:m},{x:h,y:t.y},t]}function XT(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 ZT(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=kv(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 Go({direction:"LR",a:m,b:p,obstacles:a,gap:96})}const d={x:c.x+Ke/2,y:c.y+Ye},h={x:t.x,y:t.y-30};return Go({direction:"TB",a:d,b:h,obstacles:a,gap:48})})}function eE({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 tE({trails:e}){return e.map(t=>i.jsx("path",{className:"edge edge-open edge-destination",d:t},t))}function nE(){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 sE(e,t,s=[]){const o=new Map(e.tickets.map(c=>[c.id,c]));return{tickets:t.nodes.map(c=>{const d=o.get(c.id);return d?{...d,blockedBy:[...c.blockedBy,...c.removedEdges??[]]}:{id:c.id,key:"+",title:c.title,type:c.type,body:"",state:"open",blockedBy:c.blockedBy,comments:[],createdAt:e.map.updatedAt,updatedAt:e.map.updatedAt}}),marks:new Map(t.nodes.map(c=>[c.id,c.mark])),newEdges:new Set(t.nodes.flatMap(c=>c.newEdges.map(d=>qo(d,c.id)))),removedEdges:new Set(t.nodes.flatMap(c=>(c.removedEdges??[]).map(d=>qo(d,c.id)))),frozen:new Set(s)}}function iE(e,t){const s=dx({...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 Jm={LR:130,TB:68};function rE(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 Go({direction:t,a:h,b:m,obstacles:a,gap:Jm.LR})}const c={x:s.x+Ke/2,y:s.y+Ye},d={x:o.x+Ke/2,y:o.y};return Go({direction:t,a:c,b:d,obstacles:a,gap:Jm.TB})}function oE(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:rE({direction:o,from:t,to:s,cards:e.cards})})}function aE(e){const{snap:t,tickets:s,direction:o,preview:a}=e,c=y.useMemo(()=>iE(t,s),[t,s]),d=y.useMemo(()=>kv(e.nodes),[e.nodes]);return e.edges.map(({from:h,to:m})=>{const p=qo(h.ticket.id,m.ticket.id);return i.jsx(oE,{from:h,to:m,direction:o,cards:d,critical:c.has(p),added:a==null?void 0:a.newEdges.has(p),removed:a==null?void 0:a.removedEdges.has(p)},p)})}const Pu=24,lE=13,cE=9.5;function uE(e){const t=e.guide;return i.jsx("g",{className:"meta",transform:`translate(${Pu} ${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:lE,rx:3}),i.jsx("text",{x:(s.w-s.textW)/2,y:cE,textLength:s.textW,lengthAdjust:"spacingAndGlyphs",children:s.text})]},o)})})}const yv=5,dE={sans:"9.5px 'Figtree Variable', system-ui, sans-serif",mono:"8.55px 'JetBrains Mono Variable', ui-monospace, monospace"};let qi;function hE(){if(qi!==void 0)return qi;try{qi=typeof document>"u"?null:document.createElement("canvas").getContext("2d")}catch{qi=null}return qi}function fE(e,t="sans"){const s=hE();return s?(s.font=dE[t],s.measureText(e).width*1.04):e.length*yv}const Xm=4,Zm=3,mE=6;function pE(e){var k;const t=Ke-Pu-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*Xm-(o.length-1)*Zm,c=x=>fE(x.text,x.kind==="key"?"mono":"sans"),d=o.filter(x=>x.kind!=="guide").reduce((x,j)=>x+c(j),0),h=Math.max(mE,Math.floor((a-d)/yv)),m=o.map(x=>x.kind==="guide"?{...x,text:IC(x.text,h)}:x),p=Math.min(1,a/m.reduce((x,j)=>x+c(j),0));let v=0;return m.map(x=>{const j=c(x)*p,b={...x,x:v,w:j+2*Xm,textW:j};return v+=b.w+Zm,b})}function gE(e,t,s){const o=e.state==="frontier"||e.state==="rework";if(!(!t||s||e.ticket.assignee||!o))return t}function vE(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 kE({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 yE={claimed:"working",verifying:"working",frontier:"ready",blocked:"backlog",parked:"backlog",decided:"done","out-of-scope":"cancelled",rework:"attention",held:"attention"};function wE(e){const t=yE[e.state];return t==="done"||t==="cancelled"?t:e.attention?"attention":e.live?"working":t}function xE({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 jE(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:fS[t.state],tone:""}}function SE({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 NE(e,t,s=2){const o=e.split(/\s+/),a=[];let c="";for(const d of o)(c+" "+d).trim().length>t?(a.push(c.trim()),c=d):c+=" "+d;if(a.push(c.trim()),a.length>s){const d=a.slice(0,s);return d[s-1]=d[s-1].slice(0,t-1)+"…",d}return a}const bE=26;function CE({n:e,session:t,stalled:s,flag:o,selected:a,onSelect:c,mark:d,frozen:h,needs:m}){const p=e.ticket,v=NE(p.title,bE),k=ir(p)==="hitl",x=!!(t!=null&&t.waitingOn),j=!!d&&d!=="unchanged",b=gE(e,m,!!t),S=e$(p.guide),I=j?void 0:jE({n:e,session:t,waiting:x,stalled:s,wait:b,step:!S}),C=k&&!j&&(p.type==="task"||p.type==="execute"),R=x||!!s||!!b||C&&e.state==="frontier",O=wE({state:e.state,live:!!t,attention:R}),U=er[p.type],X=(j&&d!=="cancelled"?44:0)+(h?12:0),Q=pE({key:p.key,type:U,guide:S==null?void 0:S.name,state:I==null?void 0:I.text,needsYou:C,reserve:X}),W=v.length>1?19:24;return i.jsxs("g",{className:vE({n:e,tone:O,hitl:k,selected:a,live:!!t,waiting:x,stalled:s,mark:d,frozen:h}),style:{transform:`translate(${e.x}px, ${e.y}px)`},onClick:ie=>{ie.stopPropagation(),c({kind:"ticket",id:p.id})},children:[i.jsx(kE,{wait:b,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(SE,{tone:O,cy:W-4}),v.map((ie,G)=>i.jsx("text",{className:"title",x:Pu,y:W+G*14,children:ie},G)),i.jsx(uE,{chips:Q,y:W+v.length*14-8,tone:I==null?void 0:I.tone,guide:S}),o&&i.jsx("circle",{className:`pr-flag-dot ${o}`,cx:Ke-2,cy:2,r:4}),i.jsx(xE,{mark:d,frozen:h})]})}const ep=.72;function $E(e){const{fit:t,nodes:s,size:o,pad:a}=e;if(t.k>=ep)return t;const c=s.find(h=>h.state==="claimed")??s.find(h=>h.state==="frontier")??s[0];if(!c)return t;const d=ep;return{k:d,x:o.w/2-(c.x+a+Ke/2)*d,y:o.h/2-(c.y+a+Ye/2)*d}}function TE(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,tp=4,EE=220,Fs=e=>Math.round(e/tp)*tp;function AE(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:Fs(t+(e()-.5)*o*.8-a/2),y:Fs(s+(e()-.5)*o*.5-c/2),w:Fs(a),h:Fs(c)}})}function IE(e){const{width:t,height:s,nodes:o}=e,a=AE(e.seed),c=(x,j)=>x+a()*(j-x),d=(x,j)=>!o.some(b=>x>b.x-52&&x<b.x+Ke+28&&j>b.y-52&&j<b.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,j,b)=>{v.length<EE&&d(j,b)&&v.push({sprite:x,x:Fs(j),y:Fs(b)})};for(let x=0;x<Math.round(h/3e4);x++){const j=c(-st,t+st),b=c(-st,s+st),S=3+Math.floor(a()*5);for(let I=0;I<S;I++)k(a()<.65?"pine":"oak",j+c(-70,70),b+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,j)=>x.y-j.y),{grass:m,water:p,items:v}}const wv={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 ME({name:e}){return i.jsx("symbol",{id:`terrain-${e}`,overflow:"visible",children:wv[e]})}const RE=Object.keys(wv),LE=y.memo(function(t){const{seed:s,width:o,height:a,nodes:c}=t,d=y.useMemo(()=>IE({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:RE.map(h=>i.jsx(ME,{name:h},h))}),d.grass.map((h,m)=>i.jsx("rect",{x:h.x,y:h.y,width:h.w,height:h.h,fill:"var(--map-grass)"},m)),d.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)"}),d.items.map((h,m)=>i.jsx("use",{href:`#terrain-${h.sprite}`,x:h.x,y:h.y},m))]})}),OE=380;function PE(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:d,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-(d+v.x+Ke/2)*k,y:s.h/2-(d+v.y+Ye/2)*k};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return m(x);const j=h,b=performance.now();let S=0;const I=C=>{const R=Math.min(1,(C-b)/OE),O=1-(1-R)**3;m({k:j.k+(x.k-j.k)*O,x:j.x+(x.x-j.x)*O,y:j.y+(x.y-j.y)*O}),R<1&&(S=requestAnimationFrame(I))};return S=requestAnimationFrame(I),()=>cancelAnimationFrame(S)},[t])}function _E(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 d=1;const h=p=>{p.preventDefault(),d=1},m=p=>{p.preventDefault();const v=p;s.current(v.scale/d,a(v)),d=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 np(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 sn=32,DE=1.8;function zE(e){var oe;const{snap:t,selection:s,onSelect:o,preview:a}=e,c=(a==null?void 0:a.tickets)??t.tickets,d=y.useRef(null),[h,m]=y.useState({w:0,h:0});y.useEffect(()=>{const D=d.current;if(!D)return;const J=new ResizeObserver(([le])=>m({w:le.contentRect.width,h:le.contentRect.height}));return J.observe(D),()=>J.disconnect()},[]);const p=y.useMemo(()=>{const D=Bf(c,"LR",t.map.mode),J=Bf(c,"TB",t.map.mode),le=ee=>Math.min(h.w/(ee.width+sn*2),h.h/(ee.height+sn*2+16));return le(D)*DE>=le(J)?D:J},[c,t.map.mode,h.w,h.h]),v=(D,J)=>Math.min(1.25,Math.max(e.minFit??0,Math.min(h.w/D,h.h/J))),k=y.useMemo(()=>{const D=p.width+sn*2,J=p.height+sn*2+16,ee=p.nodes.some(Y=>Y.state==="out-of-scope")&&h.h?Math.max(0,h.h/v(D,J)-J):0;if(!ee)return{...p,slack:ee};const K=new Map(p.nodes.map(Y=>[Y,{...Y,y:Y.y+(Y.state==="out-of-scope"?ee:ee/2)}]));return{...p,slack:ee,nodes:[...K.values()],edges:p.edges.map(Y=>({from:K.get(Y.from),to:K.get(Y.to)})),quarantineY:p.quarantineY+ee,height:p.height+ee}},[p,h.w,h.h,e.minFit]),x=XT(k),j=x.right+sn*2,b=x.bottom+sn*2+16,S=()=>{const D=v(j,b);return{k:D,x:Math.max(0,(h.w-j*D)/2),y:Math.max(0,(h.h-b*D)/2)}},[I,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($E({fit:S(),nodes:k.nodes,size:h,pad:sn}))},[h.w,h.h,j,b,t.map.id]);const O=y.useRef(new Map),U=y.useRef(null),X=D=>{const J=d.current.getBoundingClientRect();return{x:D.clientX-J.left,y:D.clientY-J.top}},Q=()=>{var ee;const D=[...O.current.values()],J=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:I,dist:le,mid:J,moved:((ee=U.current)==null?void 0:ee.moved)??!1}};_E(d,(D,J)=>{R.current=!0,C(le=>np(le,le.k*D,J))});const W=Yt(5e3),ie=gu(e.leases,t.map.id),G=bu(),ve=(oe=Lu())==null?void 0:oe.waiting,Pe=new Map(e.sessions.filter(D=>cn(D)&&D.ticketId).map(D=>[D.ticketId,D])),$e=(s==null?void 0:s.kind)==="ticket"?s.id:void 0;return PE({selId:$e,nodes:k.nodes,size:h,pad:sn,view:I,setView:C,onFocus:()=>R.current=!0}),i.jsxs("div",{className:"graph-box",ref:d,onPointerDown:D=>{O.current.set(D.pointerId,X(D)),O.current.size===1&&(U.current=null),Q()},onPointerMove:D=>{var ee;if(!O.current.has(D.pointerId)||!U.current)return;O.current.set(D.pointerId,X(D));const J=U.current,le=[...O.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=np(J.view,J.view.k*Y/(J.dist||Y),J.mid);C({...B,x:B.x+K.x-J.mid.x,y:B.y+K.y-J.mid.y}),J.moved=!0}else{const K=le[0].x-J.mid.x,Y=le[0].y-J.mid.y;if(!J.moved&&Math.hypot(K,Y)<5)return;J.moved||(ee=d.current)==null||ee.setPointerCapture(D.pointerId),J.moved=!0,C({...J.view,x:J.view.x+K,y:J.view.y+Y})}R.current=!0},onPointerUp:D=>{O.current.delete(D.pointerId),O.current.size&&Q()},onPointerCancel:D=>O.current.delete(D.pointerId),onClickCapture:D=>{var J;(J=U.current)!=null&&J.moved&&(D.stopPropagation(),U.current=null)},children:[i.jsxs("svg",{className:"graph",width:h.w,height:h.h,onClick:()=>o(null),children:[i.jsx(nE,{}),i.jsx("g",{transform:`translate(${I.x} ${I.y}) scale(${I.k})`,children:i.jsxs("g",{transform:`translate(${sn} ${sn})`,children:[i.jsx(LE,{seed:t.map.id,width:j,height:b,nodes:k.nodes}),i.jsx(TE,{y:k.quarantineY,width:k.width,height:k.quarantineH,nodes:k.nodes}),i.jsx(aE,{snap:t,tickets:c,direction:k.direction,nodes:k.nodes,edges:k.edges,preview:a}),i.jsx(tE,{trails:ZT(k,x)}),k.nodes.length>0&&i.jsx(eE,{x:x.x,y:x.y,text:t.map.sections.destination}),k.nodes.map(D=>{var J;return i.jsx(CE,{n:D,session:Pe.get(D.ticket.id),stalled:!!ie.get(D.ticket.id)&&ra(ie.get(D.ticket.id),W)!=="live",flag:MS(Qs.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:(J=ve==null?void 0:ve.find(le=>le.mapId===t.map.id&&le.ticketId===D.ticket.id))==null?void 0:J.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(S())},children:"Fit"})]})}const Oc=[["decided","Done"],["claimed","Working"],["frontier","Ready"],["blocked","Backlog"],["parked","Parked"],["out-of-scope","Cancelled"]],sp=[["verifying","Verifying"],["rework","Rework"],["held","Blocked"]];function BE({snap:e,sessions:t}){const s=Ep(e),o=p=>s[p],a=t.filter(kg).length,c=hx(e),d=Math.max(1,...c.map(p=>p.open+p.closed)),m=(e.map.verification??"off")!=="off"||sp.some(([p])=>o(p))?[...Oc.slice(0,2),...sp,...Oc.slice(2)]:Oc;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:er[p.type]}),i.jsxs("span",{className:"mix-bar",children:[i.jsx("i",{className:"closed",style:{width:`${p.closed/d*100}%`}}),i.jsx("i",{className:"open",style:{width:`${p.open/d*100}%`}})]}),i.jsx("b",{children:p.open+p.closed})]},p.type))})]})]})}function FE(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(BE,{snap:e.snap,sessions:e.sessions})]})}function UE({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 WE(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(Z1,{}),(o=e.trail)==null?void 0:o.banner,i.jsxs("div",{className:"map-area",children:[t&&!e.compact&&i.jsx(FE,{snap:t,sessions:e.sessions}),t?i.jsx(zE,{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(sb,{}),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(Wo,{command:'/scout new "your idea"'})]}),t&&e.compact&&i.jsx(UE,{planOnly:t.map.mode==="plan-only",verifies:(t.map.verification??"off")!=="off"})]})]})}const HE=[["home","Inbox"],["map","Map"],["ticket","Ticket"],["activity","Activity"],["plan","Plan"]];function KE(e){const{tab:t,covered:s,pending:o}=e;return i.jsx("nav",{className:"tabbar",children:HE.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 VE(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 ip={settingsPage:!0},rp=()=>Fg(new URLSearchParams(location.search).get("settings")),op=()=>{var e;return!!((e=history.state)!=null&&e.settingsPage)};function GE(){const[e,t]=y.useState(rp);y.useEffect(()=>{e&&!op()&&(history.replaceState(null,"",Yi(location.href,null)),history.pushState(ip,"",Yi(location.href,e)));const c=()=>t(rp());return window.addEventListener("popstate",c),()=>window.removeEventListener("popstate",c)},[]);const s=c=>{const d=Yi(location.href,c);e?history.replaceState(history.state,"",d):history.pushState(ip,"",d),t(c)},o=()=>{e&&(t(null),op()?history.back():history.replaceState(null,"",Yi(location.href,null)))},a=c=>s(Fg(c??"")??{});return{route:e,open:a,show:s,close:o,toggle:()=>e?o():a()}}function qE(e,t){const{activity:s,selection:o,setSelection:a,actions:c}=e,[d,h]=y.useState("ticket"),[m,p]=y.useState("home"),[v,k]=y.useState(0),[x,j]=y.useState(null),[b,S]=y.useState(!1),I=Q=>{S(!1),j({focus:Q})},C=()=>{j(null),S(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"))},O=(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:d,setSideTab:h,phoneTab:m,setPhoneTab:p,convRequest:v,decisionsView:x,setDecisionsView:j,openDecisions:I,statsOpen:b,setStatsOpen:S,toggleStats:C,select:R,openChat:O,showChat:(Q,W,ie)=>{O(Q,W,ie),k(G=>G+1)},openTicket:(Q,W)=>{Q!==e.mapId&&c.selectMap(Q),a({kind:"ticket",id:W}),j(null),t==="laptop"&&h("ticket"),t==="mobile"&&p("ticket")}}}function QE(e,t){y.useEffect(()=>{document.title=`${te.name}: ${e?`(${e}) `:""}${t??"No trail"}`},[e,t])}function YE(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 JE(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 XE({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 ap=["summary","productContext","existing","conventions","dataModel","api","risks"];function ZE(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 d=t.sections,h=ap.filter(p=>d[p].trim()),m=ap.filter(p=>!d[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:e2(t)})]}),i.jsxs("div",{className:"brief-body",children:[h.map(p=>i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:Vi[p]}),i.jsx(XE,{text:d[p]}),(p==="conventions"||p==="productContext")&&d[p].trim()&&i.jsx(Cu,{draft:()=>({title:`${Vi[p]}: ${d[p].split(`
164
+ `)[0].slice(0,80)}`,body:d[p],kind:p==="conventions"?"convention":"business-rule",sources:[`brief:${t.mapId}`]})})]},p)),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:Vi.assumptions}),d.assumptions.length?i.jsx("ul",{className:"item-list",children:d.assumptions.map(p=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:p.text}),i.jsx(V,{parts:[{text:p.id,code:!0}]})]},p.id))}):i.jsx(Ae,{children:"None listed"})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:Vi.openQuestions}),d.openQuestions.length?i.jsx("ul",{className:"brief-list",children:d.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=>Vi[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(fa,{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 e2(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(`${dn(Date.now()-e.submittedAt)} ago`),t.join(" · ")}function t2({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 n2={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 s2({brief:e,onReview:t}){if(e.status==="accepted")return null;const[s,o]=n2[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(ti,{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 xv=`${je()}/briefs`;async function i2(e){if(!e)return{brief:null};const t=await fetch(`${xv}?mapId=${encodeURIComponent(e)}`);return t.ok?await t.json():{brief:null}}function r2(e){const t=e==null?void 0:e.map.id,[s,o]=y.useState(null),[a,c]=y.useState(),[d,h]=y.useState(),{reload:m,pushed:p}=pt({view:t,version:e==null?void 0:e.tickets.reduce((x,j)=>Math.max(x,j.updatedAt),e.map.updatedAt),load:()=>i2(t),show:x=>{o(x.brief),h(x.hash)},failed:()=>o(null),changed:x=>x.startsWith("briefs/")}),v=(x,j,b)=>fetch(`${xv}/${x}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,note:j,hash:b})}).then(async S=>{const I=await S.json().catch(()=>({}));if(!S.ok||!I.brief)throw new Error(I.error??`HTTP ${S.status}`);c(void 0),p(),o(I.brief)}),k=(x,j,b)=>v(x,j,b).then(()=>!0,S=>(c(S.message),m(),!1));return{brief:s,error:a,hash:d,accept:x=>k("accept",void 0,x),requestChanges:x=>k("request-changes",x)}}function o2(e){const t=r2(e),[s,o]=y.useState(!1),a=()=>o(!0),c=t.brief,d=ga(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(s2,{brief:c,onReview:a}),inboxCard:c&&i.jsx(t2,{brief:c,onReview:a}),dialog:c&&s&&i.jsx(ZE,{brief:c,error:t.error,changed:d.changed,onReviewAgain:d.reviewAgain,onAccept:()=>void t.accept(d.hash).then(m=>m&&o(!1)),onRequestChanges:m=>void t.requestChanges(m).then(p=>p&&o(!1)),onClose:()=>o(!1)})}}function a2(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",d=a?` ${a} ticket${a===1?" is":"s are"} closed until you decide.`:"",h=t.wide?" It touches most of the open tickets, so nothing is frozen.":"",m=`${t.reason.replace(/\.$/,"")}.${d}${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(ti,{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 l2=e=>e.changes.flatMap(t=>"ticket"in t?[t.ticket]:[]);function c2(e,t){const s=new Set(l2(t));return e.tickets.filter(o=>s.has(o.id)&&o.updatedAt>t.at).map(o=>({key:o.key,title:o.title,what:u2(o)}))}function u2(e){return e.state==="closed"?"closed":e.assignee?`claimed by ${e.assignee}`:"changed"}function d2({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 h2={"already-exists":"The work already exists","wrong-problem":"The trail targets the wrong problem",rescope:"The trail should be rescoped"},jv="Dismissed by the trail lead. Carry on with the current plan.",f2="Declined by the trail lead.";function m2(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 p2(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:g2(e)};case"rewire":return{verb:"Rewire",text:t(e.ticket),detail:v2(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 g2(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 v2(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 k2=new Set(["cancel_ticket","update_destination"]);function y2(e){const{change:t,name:s}=e,o=p2(t,s),a=m2(t,e.by);return i.jsx(Ce,{as:"li",className:`reroute-change op-${t.op}`,edge:k2.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(d2,{parts:a}):void 0})}function w2(e){const{reason:t,destination:s}=e;return i.jsxs("section",{className:"reroute-destination",children:[t&&i.jsx("p",{className:"reroute-destination-why",children:h2[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 x2(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 j2(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 d=o.get(a);return d?`new: ${d}`:a}}function S2(e){var R,O;const{reroute:t,snap:s}=e,[o,a]=y.useState(""),[c,d]=y.useState(!1);y.useEffect(()=>{const U=X=>X.key==="Escape"&&e.onClose();return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[e]);const h=j2(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(X=>X.id===U)??{id:U,text:""}),x=t.status==="pending",j=x?c2(s,t):[],b=!j.length||c,S=t.kind==="challenge-destination",I=t.lane==="setting",C=I?`${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:S?"Destination challenged":C}),i.jsx(V,{parts:[{text:t.id,code:!0},t.status,`by ${t.by}`,`${dn(Date.now()-t.at)} ago`]})]}),i.jsxs("div",{className:"reroute-body",children:[e.replaced&&i.jsxs("p",{className:"reroute-replaced t-meta edge-note edge-attention",children:[t.by," replaced ",e.replaced," with this proposal while you were reading: review it again."]}),S&&i.jsx(w2,{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,X)=>i.jsx(y2,{change:U,by:t.by,name:p},X))})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Closed until you decide"}),t.wide&&i.jsxs("p",{className:"t-meta",children:["It touches ",t.wide.touched," of ",t.wide.open," open tickets, so it freezes none: the current plan stands until you decide."]}),(O=t.frozen)!=null&&O.length?i.jsx("ul",{className:"item-list",children:t.frozen.map(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})]})]}),j.length>0&&i.jsx(x2,{changed:j,seen:c,onSeen:d}),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(I?f2:jv),children:I?"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:!b,onClick:()=>e.onApprove(o.trim()),children:"Approve and apply"})]}),i.jsx(P,{variant:"ghost",onClick:e.onClose,children:"Close"})]})]})})}const Sv=`${je()}/reroutes`;async function N2(e){if(!e)return[];const t=await fetch(`${Sv}?map=${encodeURIComponent(e)}`);return t.ok?(await t.json()).reroutes:[]}function b2(e){const t=e==null?void 0:e.map.id,[s,o]=y.useState([]),[a,c]=y.useState(),{reload:d}=pt({view:t,version:e==null?void 0:e.tickets.reduce((m,p)=>Math.max(m,p.updatedAt),e.map.updatedAt),load:()=>N2(t),show:o,failed:()=>o([]),events:{reroute:m=>(m==null?void 0:m.mapId)===t}}),h=async(m,p,v)=>{var b,S;const k=await fetch(`${Sv}/${m}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,id:p,note:v,hash:(b=s.find(I=>I.id===p))==null?void 0:b.hash})}),x=await k.json().catch(()=>({}));if(k.ok)return c(void 0),d(),!0;const j=(S=x.errors)==null?void 0:S.map(I=>I.message).join("; ");return c([x.error??`HTTP ${k.status}`,j].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 C2(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 $2(e,t){const s=b2(e),[o,a]=y.useState(),c=C2(s.reroutes,o),d=s.reroutes.find(k=>k.id===c.id),h=d!=null&&d.diff?d:s.pending,m=()=>{a(void 0),s.clearError()},p=k=>k&&m(),v=s.pending;return{banner:v&&i.jsx(a2,{reroute:v,onReview:()=>a(v.id),onDismiss:()=>void s.reject(v.id,jv)}),preview:e&&(h!=null&&h.diff)?sE(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&&d&&i.jsx(S2,{reroute:d,replaced:c.replaced,snap:e,error:s.error,onApprove:k=>void s.approve(d.id,k||void 0).then(p),onReject:k=>void s.reject(d.id,k).then(p),onClose:m},d.id)}}function T2(e,t){const s=o2(e),o=$2(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 E2(){const e=new URL(location.href);e.searchParams.has(Vs)&&(e.searchParams.delete(Vs),history.replaceState(history.state,"",e))}function A2(e,t){return e.kind!=="question"||t.pending.some(s=>s.id===e.ref)}function I2(e){const[t,s]=y.useState(()=>new URLSearchParams(location.search).get(Vs)??void 0),{loaded:o,view:a,activity:c,handlers:d,showChat:h}=e;return y.useEffect(()=>{if(!t||!o||!a)return;const m=a.items.find(v=>v.id===t);if(m&&!A2(m,c)||(s(void 0),E2(),!m))return;Tg(m,{...d,openQuestion:v=>{const k=c.pending.find(x=>x.id===v);k&&h(k.sessionId,k.ticketId)}})},[t,o,a,c,d,h]),{request:y.useCallback(m=>s(m),[])}}function M2(e){const{api:t,nav:s}=e,o=Ag(t.allSnaps);z1(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},d=o.view,h=I2({loaded:t.loaded,view:d,activity:t.activity,handlers:c,showChat:s.showChat}),m=d&&i.jsx(O1,{view:d,onFocus:p=>void o.savePrefs(pj(d.prefs,p,Date.now())),onSettings:e.openFocusSettings});return{attention:o,handlers:c,header:m,link:h}}async function R2(){const e=await fetch(`${je()}/signed-state`);return e.ok?await e.json():null}function L2(){const[e,t]=y.useState();return pt({load:R2,show:t,failed:()=>t(null),changed:s=>s.endsWith("map.md")||s.includes("/tickets/")||s.includes("/decisions/")}),e}const O2={ticket:"held until you accept or revert it",decision:"what you see is what was signed here, until you accept or revert it"};function P2(e){return e[0]==="added"?"added outside Teamtrail":e.map(t=>t==="words"?"its words":t).join(", ")}function Nv({mapId:e,kind:t,id:s}){const o=L2(),a=d=>d.mapId===e&&d.kind===t&&d.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:[`${P2(c.fields)} · ${O2[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 _2({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 D2(e){const{d:t,snap:s}=e,[o,a]=y.useState(!1),[c,d]=y.useState(""),[h,m]=y.useState("");y.useEffect(()=>{a(!1),d(""),m("")},[t.id,t.mapId]);const p=Gw(e.all.filter(b=>b.mapId===t.mapId),t.id),v=rr(t),k=t.ticketId?s==null?void 0:s.tickets.find(b=>b.id===t.ticketId):void 0,x=Date.now(),j=Xs(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:[hS(t.decidedAt),`${dn(x-t.decidedAt)} ago`]})]}),i.jsx("h3",{className:"t-heading",children:t.question}),i.jsx(Nv,{mapId:t.mapId,kind:"decision",id:t.id}),i.jsx(_2,{d:t}),i.jsxs("div",{className:"resolution",children:[i.jsx(Qc,{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,Cp(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(b=>b.name??b.id).join(", ")})]}),i.jsx("dt",{children:"Source"}),i.jsxs("dd",{children:[Gn[t.source.kind].label,j&&i.jsxs(i.Fragment,{children:[" · ",i.jsx("a",{href:j,target:"_blank",rel:"noreferrer",children:t.source.label??"link"})]}),!j&&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(b=>i.jsx("li",{children:b},b))})]}),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(b=>i.jsx("li",{className:`${b.id===t.id?"cur":""} ${b.supersededBy?"old":"live"}`,children:i.jsxs("button",{onClick:()=>e.onSelect(b.id),children:[i.jsx("i",{}),i.jsx("span",{className:"id",children:b.id}),i.jsx("span",{className:"a",children:b.summary}),i.jsx(V,{parts:[b.decidedBy,qs(b.decidedAt)]})]})},b.id))})]}),i.jsxs("div",{className:"actions",children:[i.jsx(Cu,{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(b=>!b),"data-tip":"Replace this decision with a new answer. Both stay on record",children:"Supersede…"})]}),o&&i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:b=>{b.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:b=>d(b.target.value),autoFocus:!0})}),i.jsx(Ze,{label:"Rationale",children:i.jsx("input",{value:h,onChange:b=>m(b.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((b,S)=>i.jsxs("div",{className:`msg from-${b.from} voice-${b.from==="human"?"human":"agent"}`,children:[i.jsx(Qc,{parts:[b.author,pu(b.at)]}),i.jsx("div",{className:"msg-text",children:b.text})]},S))}):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 z2(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(d=>d.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(d=>d.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=>Zi(c)==="agent"),onClick:()=>s({madeBy:t.madeBy==="agent"?void 0:"agent"})}),i.jsx(_t,{on:t.madeBy==="human",label:"People",n:a(c=>Zi(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(d=>d.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 B2(e){if(rr(e)==="superseded")return`Replaced by ${e.supersededBy}`;if(e.supersedes)return`Replaces ${e.supersedes}`}function F2(e){const{d:t}=e,s=rr(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:pu(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,Cp(t)??Gn[t.source.kind].label,B2(t)]}),detail:t.summary,detailText:t.summary})]})}function U2(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(F2,{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 W2({stats:e}){return i.jsxs("span",{className:"dv-readouts",children:[i.jsx(on,{layout:"start",label:"Active",value:e.active}),i.jsx(on,{layout:"start",label:"Superseded",value:e.superseded}),i.jsx(on,{layout:"start",label:"Last 24h",value:e.last24h}),i.jsx(on,{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 H2(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 K2(e){const{api:t,bp:s}=e,o=t.decisions,[a,c]=y.useState({}),[d,h]=y.useState(e.focus),[m,p]=y.useState(!1);y.useEffect(()=>h(e.focus),[e.focus]),y.useEffect(()=>{const R=O=>{O.key==="Escape"&&(s==="mobile"&&d?h(void 0):e.onClose())};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[s,d,e]);const v=y.useMemo(()=>vx(o,a),[o,a]),k=y.useMemo(()=>kx(o),[o]),x=o.find(R=>R.id===d&&(!a.mapId||R.mapId===a.mapId))??(s==="mobile"?void 0:v[0]),j=y.useMemo(()=>Object.values(t.allSnaps).sort((R,O)=>O.map.createdAt-R.map.createdAt),[t.allSnaps]),b=y.useMemo(()=>[...new Set(o.map(R=>R.decidedBy))].sort(),[o]),S=R=>c(O=>({...O,...R})),I=()=>{const R=Object.fromEntries(j.map(O=>[O.map.id,{key:O.map.key,title:O.map.title}]));og(`${te.slug}-decisions-${qs(Date.now())}.md`,Ax(v,R,{title:`${te.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(W2,{stats:k}),i.jsxs("span",{className:"dv-head-right",children:[!C&&i.jsx(P,{onClick:I,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(H2,{filter:a,set:S,showToggle:s!=="wide",filtersOpen:m,onToggle:()=>p(R=>!R)}),i.jsxs("div",{className:"dv-body",children:[(s==="wide"||m&&!C)&&i.jsx(z2,{filter:a,set:S,all:o,trails:j,people:b,compact:s!=="wide"}),!C&&i.jsx(U2,{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(D2,{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 V2({api:e,bp:t,nav:s}){return s.statsOpen?i.jsx(J$,{api:e,bp:t,onClose:()=>s.setStatsOpen(!1)}):s.decisionsView?i.jsx(K2,{api:e,bp:t,focus:s.decisionsView.focus,onClose:()=>s.setDecisionsView(null),onOpenTicket:s.openTicket}):null}function G2(e,t,s){const o=cv(),[a,c]=y.useState(()=>new URLSearchParams(location.search).has("projects")),d=a&&o.many&&i.jsx(O$,{projects:o,bp:e,onClose:()=>c(!1),onItemHere:s});return{projects:o,overview:d,openOverview:()=>{t.setDecisionsView(null),t.setStatsOpen(!1),c(!0)}}}function bv({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:la(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 lp({lease:e,now:t}){if(!e)return null;const s=ra(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":Qt(o)]})}function q2({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:Q2(o+1,t)},o))})}function Q2(e,t){return e<t?"done":e===t?"cur":""}function Cv({snap:e,activity:t,leases:s,onSelect:o,onOpenChat:a}){var x;const c=Yt(1e3),d=t.sessions.filter(cn),h=new Set(d.map(j=>j.ticketId)),m=gu(s,e==null?void 0:e.map.id),p=(e==null?void 0:e.tickets.filter(j=>j.state==="open"&&j.assignee&&!h.has(j.id)))??[];if(!d.length&&!p.length)return i.jsx(Ae,{children:"No agent on a ticket"});const v=j=>!!j&&ra(j,c)!=="live",k=!!((x=e==null?void 0:e.map.modelMatching)!=null&&x.enabled);return i.jsxs("ul",{className:"sessions-list",children:[d.map(j=>{const b=e==null?void 0:e.tickets.find(C=>C.id===j.ticketId),S=b?ir(b)==="hitl":!1,I=b&&m.get(b.id);return i.jsx(Ce,{as:"li",className:j.waitingOn?"waiting":void 0,edge:Y2(j,v(I)),title:Z2(b,j.mode)||j.agent,context:i.jsx(V,{parts:[{text:j.agent,strong:!0},k&&J2(j),j.waitingOn?{text:"Waiting on you",urgent:!0}:`${j.mode} · ${j.stepLabel.toLowerCase()}`,S&&!j.waitingOn&&"with you",X2(j)],children:i.jsx(lp,{lease:I,now:c})}),trailing:ag(c-j.startedAt),below:i.jsx(q2,{total:j.total,step:j.step}),onOpen:()=>{b&&o({kind:"ticket",id:b.id}),S&&a(j.id)}},j.id)}),p.map(j=>i.jsx(Ce,{as:"li",className:"claim",edge:v(m.get(j.id))?"attention":"neutral",title:`${j.key} ${j.title}`,context:i.jsx(V,{parts:[{text:j.assignee??"",strong:!0},"claimed, no live session"],children:i.jsx(lp,{lease:m.get(j.id),now:c})}),onOpen:()=>o({kind:"ticket",id:j.id})},j.id))]})}function Y2(e,t){return e.waitingOn?"urgent":t?"attention":"neutral"}function J2(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 X2(e){if(e.usage)return`${ca(mx(e))} tok · ${Gs(e.usage.costUsd)}`}function Z2(e,t){return e?`${e.key} ${e.title}`:t==="chart"?"Charting trail":""}function $v({activity:e,snap:t,running:s,usage:o=!0}){const a=Ip(e,t==null?void 0:t.map.id),c=Rp(e,t==null?void 0:t.map.id),d=new Set(e.sessions.filter(cn).map(m=>m.ticketId)),h=(t==null?void 0:t.tickets.filter(m=>m.state==="open"&&m.assignee&&!d.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=>Mp[m].text)].join(`
169
+ `),children:[i.jsx("span",{className:"mono-label",children:"Trail"})," ",ca(a.inputTokens+a.outputTokens)," tok · ",Gs(a.costUsd)]}):void 0})}function eA(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 tA={running:"Working",done:"Done",failed:"Stopped"};function Tv({activity:e,snap:t}){const s=eA(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(d=>d.id===s.ticketId):void 0,a=ta[s.mode],c=s.waitingOn?"Waiting on you":tA[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((d,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")," ",d]})]},d)})})]})}function cp(e){return i.jsxs("div",{className:"zone-b activity-stack",children:[i.jsx(Tv,{activity:e.activity,snap:e.snap}),i.jsx($v,{activity:e.activity,snap:e.snap,running:e.activity.sessions.filter(cn).length}),i.jsx(Cv,{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(bv,{activity:e.activity,onTicket:e.onTicket})]})}function nA(e){return i.jsx(wg,{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(bv,{activity:e.activity,onTicket:e.onTicket})})}function sA(e){var o;const t=e.activity.sessions.filter(cn).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(Tv,{activity:e.activity,snap:e.snap}),!s&&i.jsxs(i.Fragment,{children:[i.jsx($v,{activity:e.activity,snap:e.snap,running:t,usage:!1}),i.jsx(Cv,{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 iA(e){const t=ga(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",d=t.changed&&!e.confirmed;return i.jsxs(i.Fragment,{children:[t.changed&&i.jsx(fa,{what:"These criteria",onReviewAgain:t.reviewAgain}),i.jsx(P,{size:"sm",variant:e.confirmed?"ghost":"default",disabled:d,"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 rA(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 oA(e){const{proposal:t}=e,s=ga(`${t.ticketId}@${t.at}`,t.hash),[o,a]=y.useState(),c=d=>void e.decide(d,s.hash).then(a);return i.jsxs(i.Fragment,{children:[s.changed&&i.jsx(fa,{what:"The proposal",onReviewAgain:s.reviewAgain}),i.jsx(rA,{proposal:t,canAccept:!s.changed,onAccept:()=>c("accept"),onDismiss:()=>c("dismiss")}),o&&i.jsx("p",{className:"vf-err",children:o})]})}async function Ev(e){return e?e.ok?void 0:(await e.json().catch(()=>({}))).error??`HTTP ${e.status}`:"Could not reach the Lookout"}const Av=`${je()}/criteria`;async function aA(e){if(!e)return[];const t=await fetch(`${Av}?mapId=${encodeURIComponent(e)}`);return t.ok?(await t.json()).tickets:[]}function lA(e){const[t,s]=y.useState([]),{reload:o}=pt({view:e,load:()=>aA(e),show:s,failed:()=>s([]),changed:c=>c.startsWith("criteria/")});return{tickets:t,confirm:c=>fetch(`${Av}/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,...c})}).catch(()=>{}).then(async d=>{const h=await Ev(d);return o(),h})}}const Iv=`${je()}/criteria-proposals`;async function cA(e){if(!e)return[];const t=await fetch(`${Iv}?mapId=${encodeURIComponent(e)}`);return t.ok?(await t.json()).proposals:[]}function uA(e){const[t,s]=y.useState([]),{reload:o}=pt({view:e,load:()=>cA(e),show:s,failed:()=>s([]),events:{"criteria-proposals":c=>(c==null?void 0:c.mapId)===e}});return{proposals:t,decide:(c,d)=>fetch(`${Iv}/${c}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,...d})}).catch(()=>{}).then(async h=>{const m=await Ev(h);return o(),m})}}function dA({snap:e,t}){const{tickets:s,confirm:o}=lA(e.map.id),a=uA(e.map.id),c=a.proposals.find(k=>k.ticketId===t.id),d=ii(),h=s.find(k=>k.ticketId===t.id),m=(h==null?void 0:h.criteria)??[],v=Kp(d.entries,{trailKey:e.map.key,ticket:{type:t.type,title:t.title,body:t.body},paths:Vp(`${t.body}
170
+ ${d.briefText}`)}).filter(k=>k.kind==="business-rule").filter(k=>Yx(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(oA,{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(iA,{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 Qo="";function hA(e){const t=lu.map(o=>({value:o,label:nr[o],hint:Ig[o]})),s=[...fA(e),...t];return i.jsx(dt,{compact:!0,className:"vf-level","aria-label":"Verification level",value:e.value??Qo,options:s,onChange:o=>e.onChange(o===Qo?null:o)})}function fA(e){return e.inherit!==void 0?[{value:Qo,label:e.inherit,hint:"Use the trail’s level for this ticket."}]:e.value===void 0?[{value:Qo,label:"Off (not set)"}]:[]}function mA({check:e}){const t=W1(e),[s,o]=y.useState(),[a,c]=y.useState(),d=pA(e);return i.jsxs("details",{className:`vf-row ${t?"ok":"bad"}`,open:!t,children:[i.jsxs("summary",{children:[i.jsx("span",{className:"vf-mark",children:t?"✓":"✕"}),i.jsx("span",{className:"t-code vf-name",children:e.name}),i.jsx("span",{className:"t-meta",children:d}),i.jsx("span",{className:"t-meta vf-dur",children:Qt(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 pA(e){return e.error?"did not start":e.timedOut?"timed out":`exit ${e.exitCode??e.signal??"?"}`}const up=e=>(e==null?void 0:e.slice(0,8))??"none",dp=e=>e===null?"·":String(e);function gA({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?`${up(t.base.head)} → `:""}${up(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 d;return i.jsxs("p",{className:`vf-flag lv-${c.level}`,title:(d=c.files)==null?void 0:d.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":`+${dp(c.add)} −${dp(c.del)}`,c.dirtyAtClaim?" · dirty at claim":""]})]},c.path))})]})]})}function vA({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:U1[e.result]}),i.jsx(V,{parts:[{text:e.id,code:!0},e.agent,ar(e.submittedAt),Qt(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:kA(s),children:s},s))}),i.jsx(gA,{attempt:e}),e.checks.map(s=>i.jsx(mA,{check:s},s.name))]})}function kA(e){return e.includes(" ✓ ")?"ok":e.includes(" ✗ ")?"bad":e.includes(" ? ")?"claimed":"wait"}const yA={PASS:"Passed",FAIL:"Sent back",NEEDS_HUMAN:"Needs you"};function wA({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":yA[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(Hg,{answers:s})]})}function xA(e,t,s){const[o,a]=y.useState(),c=`${e}/${t}`;y.useEffect(()=>a(void 0),[c]);const{reload:d}=pt({view:c,version:s,load:()=>lr.ticket(e,t),show:a});return y.useEffect(()=>Qs.onEvidence(d),[d]),{data:o,reload:d}}const Pc={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 jA(e){const[t,s]=y.useState(),[o,a]=y.useState(""),[c,d]=y.useState("rework"),{state:h,submitted:m,running:p,act:v}=e;if(p||h!=="verifying"&&h!=="held")return null;const k=j=>{s(t===j?void 0:j),a("")},x=j=>{j.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(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:x,children:[i.jsx(Ze,{label:Pc[t].label,children:i.jsx("textarea",{rows:2,value:o,onChange:j=>a(j.target.value),autoFocus:!0})}),t==="unblock"&&i.jsx(Ze,{label:"Back to",children:i.jsx(dt,{"aria-label":"Back to",value:c,onChange:d,options:[{value:"rework",label:"Rework",hint:"Keeps the feedback for the next agent."},{value:"ready",label:"Ready",hint:"Back in the queue as a fresh ticket."}]})}),i.jsx("span",{className:"dim vf-hint",children:Pc[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:Pc[t].submit})]})]})]})}const SA={ticket:"set on this ticket",trail:"from the trail",none:"not set"},NA=new Set(["verifying","rework","held"]);function bA(e){const{mapId:t,ticket:s,state:o}=e,{data:a,reload:c}=xA(t,s.id,s.updatedAt),[d,h]=y.useState();if(!a||a.level.level==="off"&&!a.attempts.length&&!NA.has(o))return null;const m=v=>(h(void 0),lr.act({...v,mapId:t,ticketId:s.id,by:St}).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:[nr[a.level.level],SA[a.level.source]]}),s.state==="open"&&i.jsx(hA,{value:s.verification,inherit:`Trail (${nr[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(jA,{state:o,submitted:a.attempts.length>0,running:!!p,act:m}),d&&i.jsx("p",{className:"vf-err",children:d}),a.verdicts.map(v=>i.jsx(wA,{verdict:v},v.id)),a.attempts.map((v,k)=>i.jsx(vA,{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 CA({lease:e,onRelease:t}){const s=Yt(1e3),o=ra(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 ${dn(s-e.renewedAt)} ago`]}),!a&&i.jsx(Qn,{tone:"amber",children:"Stalled"})]}),i.jsx("p",{className:"t-meta lease-line",children:$A(o,TA(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,d)=>i.jsxs("span",{children:[d>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,d)=>i.jsx("li",{children:c},d))}),i.jsx("div",{className:"actions",children:i.jsx(P,{variant:a?"default":"urgent",onClick:t,children:"Release to queue"})})]})}function $A(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 TA(e){const t=e/864e5;return t>=2?`${Math.round(t)} days`:Qt(Math.max(0,e))}function EA({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 AA({resolution:e,decisions:t,onOpenDecision:s}){const o=t.find(d=>!d.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 IA(e){const{t,state:s,session:o,mine:a,form:c,setForm:d,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:()=>d(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:()=>d(c==="rule"?null:"rule"),"data-tip":"Move it out of scope. It's set aside with your reason, not deleted",children:"Rule out…"})]})}function MA(e){return e.replace(/\s*Part of trail \S+\.\s*$/,"").trim()}function RA({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(", "),d=s.filter(p=>p.blockedBy.includes(e.id)).map(p=>p.key).join(", "),h=[["Type",er[e.type]],["Assignee",e.assignee],["Blocked by",c],["Blocks",d],["Reviews",e.reviewOf&&a(e.reviewOf)]],m=ir(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:cg[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 LA(e){const{snap:t,api:s,form:o,setForm:a}=e,{actions:c}=s,[d,h]=y.useState(""),[m,p]=y.useState(""),[v,k]=y.useState(""),[x,j]=y.useState("Not needed to reach the destination."),b=t.tickets.find(W=>W.id===e.id);if(!b)return i.jsx(Ae,{children:"Ticket not found."});const S=Js(t.tickets,t.map.mode).get(b.id),I=e.sessions.find(W=>W.ticketId===b.id&&cn(W)),C=b.assignee===St,R=b.state==="open"?gu(s.leases,t.map.id).get(b.id):void 0,O=[...b.comments].reverse().find(W=>/^\*\*(Resolution|Ruled out of scope)\*\*/.test(W.body)),U=b.comments.filter(W=>W!==O),X=MA(b.body),Q=s.decisions.filter(W=>W.mapId===t.map.id&&W.ticketId===b.id);return i.jsxs("div",{className:"detail",children:[i.jsx(RA,{t:b,state:S,tickets:t.tickets}),i.jsx(Nv,{mapId:t.map.id,kind:"ticket",id:b.id}),X&&i.jsxs("section",{className:"d-section ticket-body",children:[i.jsx("span",{className:"t-label",children:"Description"}),i.jsx("p",{className:"body",children:X})]}),i.jsx(H$,{mapId:t.map.id,ticketId:b.id}),i.jsx(hN,{mapId:t.map.id,ticketId:b.id}),i.jsx(ZC,{mapId:t.map.id,ticket:b}),i.jsx(dA,{snap:t,t:b}),i.jsx(bN,{snap:t,t:b}),b.closeReason==="not_planned"&&i.jsx(Cu,{label:"Save as dead end",draft:()=>{var W;return{title:`Ruled out: ${b.title}`,body:((W=b.comments.at(-1))==null?void 0:W.body)??b.body,kind:"dead-end",sources:[`trail:${t.map.key}`,`ticket:${b.key}`]}}}),R&&i.jsx(CA,{lease:R,onRelease:()=>c.releaseLease(b.id)}),!R&&i.jsx(x$,{mapId:t.map.id,ticketId:b.id}),i.jsx(bA,{mapId:t.map.id,trail:t.map.verification,ticket:b,state:S}),i.jsx(IA,{t:b,state:S,session:I,mine:C,form:o,setForm:a,actions:c,onOpenChat:e.onOpenChat}),o==="resolve"&&i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:W=>{W.preventDefault(),d.trim()&&(c.resolve(b.id,d.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:d,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:!d.trim(),children:"Resolve"})]})]}),o==="rule"&&i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:W=>{W.preventDefault(),c.ruleOut({ticketId:b.id},x),a(null)},children:[i.jsx(Ze,{label:"Reason",children:i.jsx("input",{value:x,onChange:W=>j(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"})]})]}),O&&i.jsx(AA,{resolution:O,decisions:Q,onOpenDecision:e.onOpenDecision}),i.jsx(EA,{comments:U})]})}function OA({snap:e,item:t,api:s}){const o=Np(e.map.mode),[a,c]=y.useState("research"),[d,h]=y.useState(t),[m,p]=y.useState(!1),[v,k]=y.useState([]),[x,j]=y.useState("Not needed to reach the destination.");y.useEffect(()=>h(t),[t]);const b=e.tickets.filter(S=>S.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(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:S=>{S.preventDefault(),s.actions.graduate({unspecified:t,type:a,title:d,blockedBy:v,hitl:m})},children:[i.jsx(Ze,{label:"Title",children:i.jsx("input",{value:d,onChange:S=>h(S.target.value)})}),i.jsxs("div",{className:"chips",children:[o.map(S=>i.jsx("button",{type:"button",className:`chip ${a===S?"on":""}`,onClick:()=>c(S),children:S},S)),Wy.includes(a)&&i.jsx("button",{type:"button",className:`chip ${m?"on":""}`,onClick:()=>p(S=>!S),children:"needs human"})]}),i.jsx("span",{className:"field",children:"Blocked by"}),i.jsx("div",{className:"chips",children:b.map(S=>i.jsx("button",{type:"button",className:`chip ${v.includes(S.id)?"on":""}`,onClick:()=>k(I=>I.includes(S.id)?I.filter(C=>C!==S.id):[...I,S.id]),children:S.key},S.id))}),i.jsx("div",{className:"form-actions",children:i.jsx(P,{type:"submit",variant:"primary",children:"Promote to ticket"})})]}),i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:S=>{S.preventDefault(),s.actions.ruleOut({unspecified:t},x)},children:[i.jsx(Ze,{label:"Reason",children:i.jsx("input",{value:x,onChange:S=>j(S.target.value)})}),i.jsx("div",{className:"form-actions",children:i.jsx(P,{type:"submit",variant:"danger",children:"Rule out"})})]})]})}function PA({api:e,sessions:t,bare:s,onOpenChat:o,onOpenDecision:a}){const{snap:c,selection:d,actions:h}=e,[m,p]=y.useState(null),v=_A(d);y.useEffect(()=>p(null),[v]);let k;return c?d?d.kind==="unspecified"?k=i.jsx(OA,{snap:c,item:d.item,api:e}):k=i.jsx(LA,{snap:c,id:d.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(wg,{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 _A(e){return(e==null?void 0:e.kind)==="ticket"?e.id:(e==null?void 0:e.kind)==="unspecified"?e.item:""}const DA={holding:"Holding",challenged:"Challenged",invalidated:"Invalidated",confirmed:"Confirmed"};function zA(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 BA(e){const{a:t,snap:s}=e,o=t.tickets.flatMap(c=>s.tickets.filter(d=>d.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},DA[t.status],zA(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 FA(e){const[t,s]=y.useState(),[o,a]=y.useState();return{confirm:async(d,h)=>{a(d);const m=await fetch(`${je()}/assumptions/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,id:d,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 UA({snap:e,onSelect:t}){const{confirm:s,busy:o,error:a}=FA(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(d=>{const h=d.status==="holding"||d.status==="challenged";return i.jsx(BA,{a:d,snap:e,onSelect:t,onConfirm:h?()=>void s(d.id,d.text):void 0,busy:o===d.id},d.id)})})]}):i.jsx(Ae,{children:"None yet. They come from the accepted discovery brief or the trail's start."})}function WA(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 HA(e){const[t,s]=y.useState([]),o=e==null?void 0:e.map.id,a=(e==null?void 0:e.tickets.reduce((c,d)=>Math.max(c,d.updatedAt),e.map.updatedAt))??0;return y.useEffect(()=>{if(!o)return;let c=!0;return fetch(`${je()}/journal?mapId=${encodeURIComponent(o)}`).then(d=>d.ok?d.json():{entries:[]}).then(d=>c&&s(d.entries)).catch(()=>c&&s([])),()=>{c=!1}},[o,a]),t}function KA({snap:e,activity:t,onTicket:s}){const o=HA(e),a=t.usageByMap[e.map.id],c=y.useMemo(()=>zp({snap:e,journal:o,answered:t.answered,usage:a}),[e,o,t.answered,a]),d=c.interventions,h=[["Done",`${c.done}`,`${c.done} done · ${c.cancelled} cancelled · ${c.open} open`],["Lead time",ln(c.trailLeadMs),"Trail lead time: from when the trail was charted to its last done ticket"],["Median ticket",ln(c.medianLeadMs),"Median time from a ticket's first claim to done"],["Interventions",`${d.total}`,`${d.answers} agent questions you answered + ${d.operatorActions} lifecycle calls you made (approve, send back, accept, unblock, cancel, release), of which ${d.reworkRequested} sent work back. Answers count while their sessions are on record.`],["Rework",`${c.rework.cycles}`,`Times work went back to rework, on ${c.rework.tickets} tickets`],["Reviews",`${c.reviews.passed}/${c.reviews.failed}`,`${c.reviews.passed} passed, ${c.reviews.failed} failed, ${c.reviews.needsHuman} needed you`],["Cost / ticket",c.spend.perVerifiedTicketUsd===void 0?"—":Gs(c.spend.perVerifiedTicketUsd),`Cost per verified ticket: trail spend ${Gs(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:()=>og(`${e.map.key.replace("#","trail-")}-report.md`,zx(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"?ln(m.leadMs):m.outcome})]})},m.id))}):i.jsx(Ae,{children:"No tickets yet"})]})}function VA({tab:e,snap:t,selection:s,onSelect:o,activity:a}){const c=t.map.sections;switch(e){case"report":return a?i.jsx(KA,{snap:t,activity:a,onTicket:d=>o({kind:"ticket",id:d})}):i.jsx(Ae,{children:"No activity yet"});case"assumptions":return i.jsx(UA,{snap:t,onSelect:o});case"decisions":return c.decisions.length?i.jsx("ol",{className:"row-list decisions",children:[...c.decisions].reverse().map((d,h)=>i.jsx(Ce,{as:"li",title:d.text,titleText:d.text,context:d.ticketKey&&i.jsx(V,{parts:[{text:d.ticketKey,code:!0}]}),onOpen:d.ticketId?()=>o({kind:"ticket",id:d.ticketId}):void 0},`${d.ticketKey}-${h}`))}):i.jsx(Ae,{children:"None"});case"unspecified":return c.unspecified.length?i.jsx("ul",{className:"row-list unspecified",children:c.unspecified.map(d=>i.jsx(Ce,{as:"li",title:d,titleText:d,selected:(s==null?void 0:s.kind)==="unspecified"&&s.item===d,onOpen:()=>o({kind:"unspecified",item:d})},d))}):i.jsx(Ae,{children:"None"});case"oos":return c.outOfScope.length?i.jsx("ul",{className:"row-list oos",children:c.outOfScope.map(d=>{const h=WA(d);return i.jsx(Ce,{as:"li",title:h.title,titleText:d,context:i.jsx(V,{parts:[h.key&&{text:h.key,code:!0},h.reason]})},d)})}):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 GA({snap:e,selection:t,onSelect:s,bare:o,onAudit:a,activity:c}){var k;const[d,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(VA,{tab:d,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:d,onChange:h,options:p.map(x=>({value:x.id,label:x.n===void 0?x.label:`${x.label} · ${x.n}`}))}),d==="decisions"&&a&&i.jsx("button",{className:"link",onClick:a,children:"Audit ›"})]}),i.jsx("div",{className:"zone-b",children:v})]})}function qA(){var le;const e=y.useMemo(()=>FS(BS()),[]),t=ZS(e),{snap:s,activity:o,selection:a,actions:c}=t,[d,h]=eN();y.useEffect(()=>vg(d.theme),[d.theme]);const m=GE(),[p,v]=y.useState(!1),k=YE(e.kind),x=qS(),j=o.pending.length,b=JE(o,t.mapId);QE(j,s==null?void 0:s.map.title);const S=qE(t,x),I=T2(s,c.selectMap),C=MN(I.briefText),R=M2({api:t,nav:S,knowledge:C,reviewBrief:I.review,openReroute:ee=>I.openReroute(ee.mapId,ee.ref),openGuides:()=>m.open("guides"),openConnector:ee=>m.open(ee),openApprovals:()=>m.open("approvals"),openFocusSettings:()=>m.open("attention")}),O=YS(e,t,d.briefing,(le=R.attention.view)==null?void 0:le.items),U=i.jsx(J1,{api:t,nav:S,bp:x,scoped:b,attn:R,above:I.inboxCard}),X=i.jsx(WE,{api:t,sessions:b.sessions,onSelect:S.select,onNewTrail:()=>v(!0),compact:x==="mobile",minFit:x==="mobile"?.7:0,trail:I}),Q=ee=>i.jsx(PA,{api:t,sessions:b.sessions,bare:ee,onOpenChat:K=>S.openChat(K),onOpenDecision:S.openDecisions}),W={activity:b,snap:s,leases:t.leases,onTicket:ee=>S.select({kind:"ticket",id:ee}),onOpenChat:ee=>S.openChat(ee)},ie=ee=>i.jsx(GA,{snap:s,selection:a,onSelect:S.select,bare:ee,onAudit:()=>S.openDecisions(),activity:b}),{projects:G,overview:ve,openOverview:Pe}=G2(x,S,R.link.request),$e=m.route&&i.jsx(VT,{rt:e,api:t,bp:x,prefs:d,update:h,settings:m}),oe=(S.statsOpen||S.decisionsView)&&i.jsx(V2,{api:t,bp:x,nav:S}),D=$e||ve||oe,J=O.shown&&i.jsx(uN,{brief:O,snaps:t.allSnaps,bp:x,openTicket:S.openTicket,openChat:S.openChat,openDecisions:S.openDecisions,closeDecisions:()=>S.setDecisionsView(null),showPhoneHome:()=>S.setPhoneTab("home")});return i.jsx(jg.Provider,{value:C,children:i.jsxs("div",{className:`app bp-${x}`,children:[i.jsx(e1,{api:t,rt:e,repo:i.jsx(P$,{repo:k,projects:G,onOverview:Pe}),brief:O,attention:R.header,decisionsOpen:!!S.decisionsView,onDecisions:()=>{m.close(),S.decisionsView?S.setDecisionsView(null):S.openDecisions()},onStats:()=>{m.close(),S.toggleStats()},onNewTrail:()=>v(!0),onSettings:m.toggle,onSlack:()=>m.open("slack"),onToggleTheme:ee=>h({theme:ee?"night":"day"})}),x==="wide"&&i.jsxs(i.Fragment,{children:[U,X,Q(!1),i.jsx(sA,{...W}),i.jsx(nA,{...W}),ie(!1),D]}),x==="laptop"&&i.jsxs(i.Fragment,{children:[U,X,i.jsx(GT,{tab:S.sideTab,onTab:S.setSideTab,unspecified:s==null?void 0:s.map.sections.unspecified.length,ticket:Q(!0),activity:i.jsx(cp,{...W}),plan:ie(!0)}),D]}),x==="mobile"&&i.jsxs(i.Fragment,{children:[i.jsx(VE,{tab:S.phoneTab,decisions:D,inbox:U,projects:G.many&&i.jsx(D$,{projects:G,onOverview:Pe}),map:X,ticket:Q(!0),activity:i.jsx(cp,{...W}),plan:ie(!0)}),i.jsx(KE,{tab:S.phoneTab,covered:!!D,pending:j,onPick:ee=>{m.close(),S.setPhoneTab(ee),S.setDecisionsView(null)}})]}),J,I.dialog,t.error&&i.jsx("div",{className:"error-toast",children:t.error}),p&&i.jsx(ib,{rt:e,onClose:()=>v(!1),onCreated:ee=>c.selectMap(ee)}),!d.onboarded&&i.jsx(Qb,{prefs:d,update:h,activeTracker:e.kind}),i.jsx(EN,{})]})})}const QA="X-Teamtrail-Session";function YA(e){return typeof e=="string"?e:e instanceof URL?e.href:e.url}function JA(e){const t=new URL(YA(e),location.href),s=te.apiPrefix;return t.origin===location.origin&&(t.pathname===s||t.pathname.startsWith(`${s}/`))}function XA(){const e=window.fetch.bind(window);window.fetch=(t,s)=>{const o=jS()?ku():void 0;if(!o||!JA(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(QA,o.secret),e(t,{...s,headers:a})}}vg(ju().theme);XA();_y.createRoot(document.getElementById("root")).render(i.jsxs(OT,{children:[i.jsx(qA,{}),i.jsx(rN,{})]}));