teamtrail 0.30.0-next.44 → 0.32.0-next.46

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,174 @@
1
+ var Ry=Object.defineProperty;var Ly=(e,t,s)=>t in e?Ry(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var le=(e,t,s)=>Ly(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:{}},Ki={},hc={exports:{}},we={};/**
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 Lf;function Oy(){if(Lf)return we;Lf=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"),k=Symbol.for("react.lazy"),v=Symbol.iterator;function x(T){return T===null||typeof T!="object"?null:(T=v&&T[v]||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 O(T,_,ue){this.props=T,this.context=_,this.refs=S,this.updater=ue||j}var R=O.prototype=new C;R.constructor=O,b(R,I.prototype),R.isPureReactComponent=!0;var z=Array.isArray,Z=Object.prototype.hasOwnProperty,q={current:null},H={key:!0,ref:!0,__self:!0,__source:!0};function re(T,_,ue){var me,ye={},xe=null,pe=null;if(_!=null)for(me in _.ref!==void 0&&(pe=_.ref),_.key!==void 0&&(xe=""+_.key),_)Z.call(_,me)&&!H.hasOwnProperty(me)&&(ye[me]=_[me]);var Se=arguments.length-2;if(Se===1)ye.children=ue;else if(1<Se){for(var ge=Array(Se),Be=0;Be<Se;Be++)ge[Be]=arguments[Be+2];ye.children=ge}if(T&&T.defaultProps)for(me in Se=T.defaultProps,Se)ye[me]===void 0&&(ye[me]=Se[me]);return{$$typeof:e,type:T,key:xe,ref:pe,props:ye,_owner:q.current}}function Q(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 ze(T){var _={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(ue){return _[ue]})}var $e=/\/+/g;function se(T,_){return typeof T=="object"&&T!==null&&T.key!=null?ze(""+T.key):_.toString(36)}function D(T,_,ue,me,ye){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,ye=ye(pe),T=me===""?"."+se(pe,0):me,z(ye)?(ue="",T!=null&&(ue=T.replace($e,"$&/")+"/"),D(ye,_,ue,"",function(Be){return Be})):ye!=null&&(ve(ye)&&(ye=Q(ye,ue+(!ye.key||pe&&pe.key===ye.key?"":(""+ye.key).replace($e,"$&/")+"/")+T)),_.push(ye)),1;if(pe=0,me=me===""?".":me+":",z(T))for(var Se=0;Se<T.length;Se++){xe=T[Se];var ge=me+se(xe,Se);pe+=D(xe,_,ue,ge,ye)}else if(ge=x(T),typeof ge=="function")for(T=ge.call(T),Se=0;!(xe=T.next()).done;)xe=xe.value,ge=me+se(xe,Se++),pe+=D(xe,_,ue,ge,ye);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=[],ye=0;return D(T,me,"","",function(xe){return _.call(ue,xe,ye++)}),me}function X(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 ce={current:null},K={transition:null},Y={ReactCurrentDispatcher:ce,ReactCurrentBatchConfig:K,ReactCurrentOwner:q};function F(){throw Error("act(...) is not supported in production builds of React.")}return we.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}},we.Component=I,we.Fragment=s,we.Profiler=a,we.PureComponent=O,we.StrictMode=o,we.Suspense=m,we.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Y,we.act=F,we.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),ye=T.key,xe=T.ref,pe=T._owner;if(_!=null){if(_.ref!==void 0&&(xe=_.ref,pe=q.current),_.key!==void 0&&(ye=""+_.key),T.type&&T.type.defaultProps)var Se=T.type.defaultProps;for(ge in _)Z.call(_,ge)&&!H.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:ye,ref:xe,props:me,_owner:pe}},we.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},we.createElement=re,we.createFactory=function(T){var _=re.bind(null,T);return _.type=T,_},we.createRef=function(){return{current:null}},we.forwardRef=function(T){return{$$typeof:h,render:T}},we.isValidElement=ve,we.lazy=function(T){return{$$typeof:k,_payload:{_status:-1,_result:T},_init:X}},we.memo=function(T,_){return{$$typeof:p,type:T,compare:_===void 0?null:_}},we.startTransition=function(T){var _=K.transition;K.transition={};try{T()}finally{K.transition=_}},we.unstable_act=F,we.useCallback=function(T,_){return ce.current.useCallback(T,_)},we.useContext=function(T){return ce.current.useContext(T)},we.useDebugValue=function(){},we.useDeferredValue=function(T){return ce.current.useDeferredValue(T)},we.useEffect=function(T,_){return ce.current.useEffect(T,_)},we.useId=function(){return ce.current.useId()},we.useImperativeHandle=function(T,_,ue){return ce.current.useImperativeHandle(T,_,ue)},we.useInsertionEffect=function(T,_){return ce.current.useInsertionEffect(T,_)},we.useLayoutEffect=function(T,_){return ce.current.useLayoutEffect(T,_)},we.useMemo=function(T,_){return ce.current.useMemo(T,_)},we.useReducer=function(T,_,ue){return ce.current.useReducer(T,_,ue)},we.useRef=function(T){return ce.current.useRef(T)},we.useState=function(T){return ce.current.useState(T)},we.useSyncExternalStore=function(T,_,ue){return ce.current.useSyncExternalStore(T,_,ue)},we.useTransition=function(){return ce.current.useTransition()},we.version="18.3.1",we}var Of;function au(){return Of||(Of=1,hc.exports=Oy()),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 Pf;function Py(){if(Pf)return Ki;Pf=1;var e=au(),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 k,v={},x=null,j=null;p!==void 0&&(x=""+p),m.key!==void 0&&(x=""+m.key),m.ref!==void 0&&(j=m.ref);for(k in m)o.call(m,k)&&!c.hasOwnProperty(k)&&(v[k]=m[k]);if(h&&h.defaultProps)for(k in m=h.defaultProps,m)v[k]===void 0&&(v[k]=m[k]);return{$$typeof:t,type:h,key:x,ref:j,props:v,_owner:a.current}}return Ki.Fragment=s,Ki.jsx=d,Ki.jsxs=d,Ki}var _f;function _y(){return _f||(_f=1,dc.exports=Py()),dc.exports}var i=_y(),wo={},fc={exports:{}},wt={},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 Df;function Dy(){return Df||(Df=1,(function(e){function t(K,Y){var F=K.length;K.push(Y);e:for(;0<F;){var T=F-1>>>1,_=K[T];if(0<a(_,Y))K[T]=Y,K[F]=_,F=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],F=K.pop();if(F!==Y){K[0]=F;e:for(var T=0,_=K.length,ue=_>>>1;T<ue;){var me=2*(T+1)-1,ye=K[me],xe=me+1,pe=K[xe];if(0>a(ye,F))xe<_&&0>a(pe,ye)?(K[T]=pe,K[xe]=F,T=xe):(K[T]=ye,K[me]=F,T=me);else if(xe<_&&0>a(pe,F))K[T]=pe,K[xe]=F,T=xe;else break e}}return Y}function a(K,Y){var F=K.sortIndex-Y.sortIndex;return F!==0?F: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=[],k=1,v=null,x=3,j=!1,b=!1,S=!1,I=typeof setTimeout=="function"?setTimeout:null,C=typeof clearTimeout=="function"?clearTimeout:null,O=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function R(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 z(K){if(S=!1,R(K),!b)if(s(m)!==null)b=!0,X(Z);else{var Y=s(p);Y!==null&&ce(z,Y.startTime-K)}}function Z(K,Y){b=!1,S&&(S=!1,C(re),re=-1),j=!0;var F=x;try{for(R(Y),v=s(m);v!==null&&(!(v.expirationTime>Y)||K&&!ze());){var T=v.callback;if(typeof T=="function"){v.callback=null,x=v.priorityLevel;var _=T(v.expirationTime<=Y);Y=e.unstable_now(),typeof _=="function"?v.callback=_:v===s(m)&&o(m),R(Y)}else o(m);v=s(m)}if(v!==null)var ue=!0;else{var me=s(p);me!==null&&ce(z,me.startTime-Y),ue=!1}return ue}finally{v=null,x=F,j=!1}}var q=!1,H=null,re=-1,Q=5,ve=-1;function ze(){return!(e.unstable_now()-ve<Q)}function $e(){if(H!==null){var K=e.unstable_now();ve=K;var Y=!0;try{Y=H(!0,K)}finally{Y?se():(q=!1,H=null)}}else q=!1}var se;if(typeof O=="function")se=function(){O($e)};else if(typeof MessageChannel<"u"){var D=new MessageChannel,J=D.port2;D.port1.onmessage=$e,se=function(){J.postMessage(null)}}else se=function(){I($e,0)};function X(K){H=K,q||(q=!0,se())}function ce(K,Y){re=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,X(Z))},e.unstable_forceFrameRate=function(K){0>K||125<K?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Q=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 F=x;x=Y;try{return K()}finally{x=F}},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 F=x;x=K;try{return Y()}finally{x=F}},e.unstable_scheduleCallback=function(K,Y,F){var T=e.unstable_now();switch(typeof F=="object"&&F!==null?(F=F.delay,F=typeof F=="number"&&0<F?T+F:T):F=T,K){case 1:var _=-1;break;case 2:_=250;break;case 5:_=1073741823;break;case 4:_=1e4;break;default:_=5e3}return _=F+_,K={id:k++,callback:Y,priorityLevel:K,startTime:F,expirationTime:_,sortIndex:-1},F>T?(K.sortIndex=F,t(p,K),s(m)===null&&K===s(p)&&(S?(C(re),re=-1):S=!0,ce(z,F-T))):(K.sortIndex=_,t(m,K),b||j||(b=!0,X(Z))),K},e.unstable_shouldYield=ze,e.unstable_wrapCallback=function(K){var Y=x;return function(){var F=x;x=Y;try{return K.apply(this,arguments)}finally{x=F}}}})(pc)),pc}var zf;function zy(){return zf||(zf=1,mc.exports=Dy()),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 Bf;function By(){if(Bf)return wt;Bf=1;var e=au(),t=zy();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]*$/,k={},v={};function x(n){return m.call(v,n)?!0:m.call(k,n)?!1:p.test(n)?v[n]=!0:(k[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 O(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,O);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,O);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,O);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 R(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 z=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Z=Symbol.for("react.element"),q=Symbol.for("react.portal"),H=Symbol.for("react.fragment"),re=Symbol.for("react.strict_mode"),Q=Symbol.for("react.profiler"),ve=Symbol.for("react.provider"),ze=Symbol.for("react.context"),$e=Symbol.for("react.forward_ref"),se=Symbol.for("react.suspense"),D=Symbol.for("react.suspense_list"),J=Symbol.for("react.memo"),X=Symbol.for("react.lazy"),ce=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 F=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 ye(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 H:return"Fragment";case q:return"Portal";case Q:return"Profiler";case re:return"StrictMode";case se:return"Suspense";case D:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case ze: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 X: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===re?"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 Sn(n){n._valueTracker||(n._valueTracker=Be(n))}function ur(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 F({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:l??n._wrapperState.initialChecked})}function Bu(n,r){var l=r.defaultValue==null?"":r.defaultValue,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 Fu(n,r){r=r.checked,r!=null&&R(n,"checked",r,!1)}function ya(n,r){Fu(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 Uu(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 oi=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 F({},r,{value:void 0,defaultValue:void 0,children:""+n._wrapperState.initialValue})}function Wu(n,r){var l=r.value;if(l==null){if(l=r.children,r=r.defaultValue,l!=null){if(r!=null)throw Error(s(92));if(oi(l)){if(1<l.length)throw Error(s(93));l=l[0]}r=l}r==null&&(r=""),l=r}n._wrapperState={initialValue:Se(l)}}function Hu(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 Ku(n){var r=n.textContent;r===n._wrapperState.initialValue&&r!==""&&r!==null&&(n.value=r)}function Vu(n){switch(n){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function ja(n,r){return n==null||n==="http://www.w3.org/1999/xhtml"?Vu(r):n==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":n}var dr,Gu=(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(dr=dr||document.createElement("div"),dr.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=dr.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;r.firstChild;)n.appendChild(r.firstChild)}});function ai(n,r){if(r){var l=n.firstChild;if(l&&l===n.lastChild&&l.nodeType===3){l.nodeValue=r;return}}n.textContent=r}var li={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},_v=["Webkit","ms","Moz","O"];Object.keys(li).forEach(function(n){_v.forEach(function(r){r=r+n.charAt(0).toUpperCase()+n.substring(1),li[r]=li[n]})});function qu(n,r,l){return r==null||typeof r=="boolean"||r===""?"":l||typeof r!="number"||r===0||li.hasOwnProperty(n)&&li[n]?(""+r).trim():r+"px"}function Qu(n,r){n=n.style;for(var l in r)if(r.hasOwnProperty(l)){var u=l.indexOf("--")===0,f=qu(l,r[l],u);l==="float"&&(l="cssFloat"),u?n.setProperty(l,f):n[l]=f}}var Dv=F({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(Dv[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 Yu(n){if(n=Ai(n)){if(typeof $a!="function")throw Error(s(280));var r=n.stateNode;r&&(r=Lr(r),$a(n.stateNode,n.type,r))}}function Ju(n){ps?gs?gs.push(n):gs=[n]:ps=n}function Xu(){if(ps){var n=ps,r=gs;if(gs=ps=null,Yu(n),r)for(n=0;n<r.length;n++)Yu(r[n])}}function Zu(n,r){return n(r)}function ed(){}var Ta=!1;function td(n,r,l){if(Ta)return n(r,l);Ta=!0;try{return Zu(n,r,l)}finally{Ta=!1,(ps!==null||gs!==null)&&(ed(),Xu())}}function ci(n,r){var l=n.stateNode;if(l===null)return null;var u=Lr(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 ui={};Object.defineProperty(ui,"passive",{get:function(){Ea=!0}}),window.addEventListener("test",ui,ui),window.removeEventListener("test",ui,ui)}catch{Ea=!1}function zv(n,r,l,u,f,g,w,N,$){var L=Array.prototype.slice.call(arguments,3);try{r.apply(l,L)}catch(U){this.onError(U)}}var di=!1,hr=null,fr=!1,Aa=null,Bv={onError:function(n){di=!0,hr=n}};function Fv(n,r,l,u,f,g,w,N,$){di=!1,hr=null,zv.apply(Bv,arguments)}function Uv(n,r,l,u,f,g,w,N,$){if(Fv.apply(this,arguments),di){if(di){var L=hr;di=!1,hr=null}else throw Error(s(198));fr||(fr=!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 nd(n){if(n.tag===13){var r=n.memoizedState;if(r===null&&(n=n.alternate,n!==null&&(r=n.memoizedState)),r!==null)return r.dehydrated}return null}function sd(n){if(Yn(n)!==n)throw Error(s(188))}function Wv(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 sd(f),n;if(g===u)return sd(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 id(n){return n=Wv(n),n!==null?rd(n):null}function rd(n){if(n.tag===5||n.tag===6)return n;for(n=n.child;n!==null;){var r=rd(n);if(r!==null)return r;n=n.sibling}return null}var od=t.unstable_scheduleCallback,ad=t.unstable_cancelCallback,Hv=t.unstable_shouldYield,Kv=t.unstable_requestPaint,We=t.unstable_now,Vv=t.unstable_getCurrentPriorityLevel,Ia=t.unstable_ImmediatePriority,ld=t.unstable_UserBlockingPriority,mr=t.unstable_NormalPriority,Gv=t.unstable_LowPriority,cd=t.unstable_IdlePriority,pr=null,Yt=null;function qv(n){if(Yt&&typeof Yt.onCommitFiberRoot=="function")try{Yt.onCommitFiberRoot(pr,n,void 0,(n.current.flags&128)===128)}catch{}}var zt=Math.clz32?Math.clz32:Jv,Qv=Math.log,Yv=Math.LN2;function Jv(n){return n>>>=0,n===0?32:31-(Qv(n)/Yv|0)|0}var gr=64,vr=4194304;function hi(n){switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return n&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return n}}function kr(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=hi(N):(g&=w,g!==0&&(u=hi(g)))}else w=l&~f,w!==0?u=hi(w):g!==0&&(u=hi(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-zt(r),f=1<<l,u|=n[l],r&=~f;return u}function Xv(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 Zv(n,r){for(var l=n.suspendedLanes,u=n.pingedLanes,f=n.expirationTimes,g=n.pendingLanes;0<g;){var w=31-zt(g),N=1<<w,$=f[w];$===-1?((N&l)===0||(N&u)!==0)&&(f[w]=Xv(N,r)):$<=r&&(n.expiredLanes|=N),g&=~N}}function Ma(n){return n=n.pendingLanes&-1073741825,n!==0?n:n&1073741824?1073741824:0}function ud(){var n=gr;return gr<<=1,(gr&4194240)===0&&(gr=64),n}function Ra(n){for(var r=[],l=0;31>l;l++)r.push(n);return r}function fi(n,r,l){n.pendingLanes|=r,r!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,r=31-zt(r),n[r]=l}function ek(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-zt(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-zt(l),f=1<<u;f&r|n[u]&r&&(n[u]|=r),l&=~f}}var Te=0;function dd(n){return n&=-n,1<n?4<n?(n&268435455)!==0?16:536870912:4:1}var hd,Oa,fd,md,pd,Pa=!1,yr=[],Nn=null,bn=null,Cn=null,mi=new Map,pi=new Map,$n=[],tk="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function gd(n,r){switch(n){case"focusin":case"focusout":Nn=null;break;case"dragenter":case"dragleave":bn=null;break;case"mouseover":case"mouseout":Cn=null;break;case"pointerover":case"pointerout":mi.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":pi.delete(r.pointerId)}}function gi(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=Ai(r),r!==null&&Oa(r)),n):(n.eventSystemFlags|=u,r=n.targetContainers,f!==null&&r.indexOf(f)===-1&&r.push(f),n)}function nk(n,r,l,u,f){switch(r){case"focusin":return Nn=gi(Nn,n,r,l,u,f),!0;case"dragenter":return bn=gi(bn,n,r,l,u,f),!0;case"mouseover":return Cn=gi(Cn,n,r,l,u,f),!0;case"pointerover":var g=f.pointerId;return mi.set(g,gi(mi.get(g)||null,n,r,l,u,f)),!0;case"gotpointercapture":return g=f.pointerId,pi.set(g,gi(pi.get(g)||null,n,r,l,u,f)),!0}return!1}function vd(n){var r=Jn(n.target);if(r!==null){var l=Yn(r);if(l!==null){if(r=l.tag,r===13){if(r=nd(l),r!==null){n.blockedOn=r,pd(n.priority,function(){fd(l)});return}}else if(r===3&&l.stateNode.current.memoizedState.isDehydrated){n.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}n.blockedOn=null}function wr(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=Ai(l),r!==null&&Oa(r),n.blockedOn=l,!1;r.shift()}return!0}function kd(n,r,l){wr(n)&&l.delete(r)}function sk(){Pa=!1,Nn!==null&&wr(Nn)&&(Nn=null),bn!==null&&wr(bn)&&(bn=null),Cn!==null&&wr(Cn)&&(Cn=null),mi.forEach(kd),pi.forEach(kd)}function vi(n,r){n.blockedOn===r&&(n.blockedOn=null,Pa||(Pa=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,sk)))}function ki(n){function r(f){return vi(f,n)}if(0<yr.length){vi(yr[0],n);for(var l=1;l<yr.length;l++){var u=yr[l];u.blockedOn===n&&(u.blockedOn=null)}}for(Nn!==null&&vi(Nn,n),bn!==null&&vi(bn,n),Cn!==null&&vi(Cn,n),mi.forEach(r),pi.forEach(r),l=0;l<$n.length;l++)u=$n[l],u.blockedOn===n&&(u.blockedOn=null);for(;0<$n.length&&(l=$n[0],l.blockedOn===null);)vd(l),l.blockedOn===null&&$n.shift()}var vs=z.ReactCurrentBatchConfig,xr=!0;function ik(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 rk(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(xr){var f=Da(n,r,l,u);if(f===null)tl(n,r,u,jr,l),gd(n,u);else if(nk(f,n,r,l,u))u.stopPropagation();else if(gd(n,u),r&4&&-1<tk.indexOf(n)){for(;f!==null;){var g=Ai(f);if(g!==null&&hd(g),g=Da(n,r,l,u),g===null&&tl(n,r,u,jr,l),g===f)break;f=g}f!==null&&u.stopPropagation()}else tl(n,r,u,null,l)}}var jr=null;function Da(n,r,l,u){if(jr=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=nd(r),n!==null)return n;n=null}else if(l===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;n=null}else r!==n&&(n=null);return jr=n,null}function yd(n){switch(n){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Vv()){case Ia:return 1;case ld:return 4;case mr:case Gv:return 16;case cd:return 536870912;default:return 16}default:return 16}}var Tn=null,za=null,Sr=null;function wd(){if(Sr)return Sr;var n,r=za,l=r.length,u,f="value"in Tn?Tn.value:Tn.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 Sr=f.slice(n,1<u?1-u:void 0)}function Nr(n){var r=n.keyCode;return"charCode"in n?(n=n.charCode,n===0&&r===13&&(n=13)):n=r,n===10&&(n=13),32<=n||n===13?n:0}function br(){return!0}function xd(){return!1}function Nt(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)?br:xd,this.isPropagationStopped=xd,this}return F(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=br)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=br)},persist:function(){},isPersistent:br}),r}var ks={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ba=Nt(ks),yi=F({},ks,{view:0,detail:0}),ok=Nt(yi),Fa,Ua,wi,Cr=F({},yi,{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!==wi&&(wi&&n.type==="mousemove"?(Fa=n.screenX-wi.screenX,Ua=n.screenY-wi.screenY):Ua=Fa=0,wi=n),Fa)},movementY:function(n){return"movementY"in n?n.movementY:Ua}}),jd=Nt(Cr),ak=F({},Cr,{dataTransfer:0}),lk=Nt(ak),ck=F({},yi,{relatedTarget:0}),Wa=Nt(ck),uk=F({},ks,{animationName:0,elapsedTime:0,pseudoElement:0}),dk=Nt(uk),hk=F({},ks,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),fk=Nt(hk),mk=F({},ks,{data:0}),Sd=Nt(mk),pk={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},gk={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"},vk={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function kk(n){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(n):(n=vk[n])?!!r[n]:!1}function Ha(){return kk}var yk=F({},yi,{key:function(n){if(n.key){var r=pk[n.key]||n.key;if(r!=="Unidentified")return r}return n.type==="keypress"?(n=Nr(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?gk[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"?Nr(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?Nr(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),wk=Nt(yk),xk=F({},Cr,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Nd=Nt(xk),jk=F({},yi,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ha}),Sk=Nt(jk),Nk=F({},ks,{propertyName:0,elapsedTime:0,pseudoElement:0}),bk=Nt(Nk),Ck=F({},Cr,{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}),$k=Nt(Ck),Tk=[9,13,27,32],Ka=h&&"CompositionEvent"in window,xi=null;h&&"documentMode"in document&&(xi=document.documentMode);var Ek=h&&"TextEvent"in window&&!xi,bd=h&&(!Ka||xi&&8<xi&&11>=xi),Cd=" ",$d=!1;function Td(n,r){switch(n){case"keyup":return Tk.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ed(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var ys=!1;function Ak(n,r){switch(n){case"compositionend":return Ed(r);case"keypress":return r.which!==32?null:($d=!0,Cd);case"textInput":return n=r.data,n===Cd&&$d?null:n;default:return null}}function Ik(n,r){if(ys)return n==="compositionend"||!Ka&&Td(n,r)?(n=wd(),Sr=za=Tn=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 bd&&r.locale!=="ko"?null:r.data;default:return null}}var Mk={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Ad(n){var r=n&&n.nodeName&&n.nodeName.toLowerCase();return r==="input"?!!Mk[n.type]:r==="textarea"}function Id(n,r,l,u){Ju(u),r=Ir(r,"onChange"),0<r.length&&(l=new Ba("onChange","change",null,l,u),n.push({event:l,listeners:r}))}var ji=null,Si=null;function Rk(n){Qd(n,0)}function $r(n){var r=Ns(n);if(ur(r))return n}function Lk(n,r){if(n==="change")return r}var Md=!1;if(h){var Va;if(h){var Ga="oninput"in document;if(!Ga){var Rd=document.createElement("div");Rd.setAttribute("oninput","return;"),Ga=typeof Rd.oninput=="function"}Va=Ga}else Va=!1;Md=Va&&(!document.documentMode||9<document.documentMode)}function Ld(){ji&&(ji.detachEvent("onpropertychange",Od),Si=ji=null)}function Od(n){if(n.propertyName==="value"&&$r(Si)){var r=[];Id(r,Si,n,Ca(n)),td(Rk,r)}}function Ok(n,r,l){n==="focusin"?(Ld(),ji=r,Si=l,ji.attachEvent("onpropertychange",Od)):n==="focusout"&&Ld()}function Pk(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return $r(Si)}function _k(n,r){if(n==="click")return $r(r)}function Dk(n,r){if(n==="input"||n==="change")return $r(r)}function zk(n,r){return n===r&&(n!==0||1/n===1/r)||n!==n&&r!==r}var Bt=typeof Object.is=="function"?Object.is:zk;function Ni(n,r){if(Bt(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)||!Bt(n[f],r[f]))return!1}return!0}function Pd(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function _d(n,r){var l=Pd(n);n=0;for(var 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=Pd(l)}}function Dd(n,r){return n&&r?n===r?!0:n&&n.nodeType===3?!1:r&&r.nodeType===3?Dd(n,r.parentNode):"contains"in n?n.contains(r):n.compareDocumentPosition?!!(n.compareDocumentPosition(r)&16):!1:!1}function zd(){for(var n=window,r=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 Bk(n){var r=zd(),l=n.focusedElem,u=n.selectionRange;if(r!==l&&l&&l.ownerDocument&&Dd(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=_d(l,g);var w=_d(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 Fk=h&&"documentMode"in document&&11>=document.documentMode,ws=null,Qa=null,bi=null,Ya=!1;function Bd(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}),bi&&Ni(bi,u)||(bi=u,u=Ir(Qa,"onSelect"),0<u.length&&(r=new Ba("onSelect","select",null,r,l),n.push({event:r,listeners:u}),r.target=ws)))}function Tr(n,r){var l={};return l[n.toLowerCase()]=r.toLowerCase(),l["Webkit"+n]="webkit"+r,l["Moz"+n]="moz"+r,l}var xs={animationend:Tr("Animation","AnimationEnd"),animationiteration:Tr("Animation","AnimationIteration"),animationstart:Tr("Animation","AnimationStart"),transitionend:Tr("Transition","TransitionEnd")},Ja={},Fd={};h&&(Fd=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 Er(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 Fd)return Ja[n]=r[l];return n}var Ud=Er("animationend"),Wd=Er("animationiteration"),Hd=Er("animationstart"),Kd=Er("transitionend"),Vd=new Map,Gd="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function En(n,r){Vd.set(n,r),c(r,[n])}for(var Xa=0;Xa<Gd.length;Xa++){var Za=Gd[Xa],Uk=Za.toLowerCase(),Wk=Za[0].toUpperCase()+Za.slice(1);En(Uk,"on"+Wk)}En(Ud,"onAnimationEnd"),En(Wd,"onAnimationIteration"),En(Hd,"onAnimationStart"),En("dblclick","onDoubleClick"),En("focusin","onFocus"),En("focusout","onBlur"),En(Kd,"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 Ci="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Hk=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ci));function qd(n,r,l){var u=n.type||"unknown-event";n.currentTarget=l,Uv(u,r,void 0,n),n.currentTarget=null}function Qd(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;qd(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;qd(f,N,L),g=$}}}if(fr)throw n=Aa,fr=!1,Aa=null,n}function Re(n,r){var l=r[al];l===void 0&&(l=r[al]=new Set);var u=n+"__bubble";l.has(u)||(Yd(r,n,2,!1),l.add(u))}function el(n,r,l){var u=0;r&&(u|=4),Yd(l,n,u,r)}var Ar="_reactListening"+Math.random().toString(36).slice(2);function $i(n){if(!n[Ar]){n[Ar]=!0,o.forEach(function(l){l!=="selectionchange"&&(Hk.has(l)||el(l,!1,n),el(l,!0,n))});var r=n.nodeType===9?n:n.ownerDocument;r===null||r[Ar]||(r[Ar]=!0,el("selectionchange",!1,r))}}function Yd(n,r,l,u){switch(yd(r)){case 1:var f=ik;break;case 4:f=rk;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}td(function(){var L=g,U=Ca(l),W=[];e:{var B=Vd.get(n);if(B!==void 0){var ee=Ba,ie=n;switch(n){case"keypress":if(Nr(l)===0)break e;case"keydown":case"keyup":ee=wk;break;case"focusin":ie="focus",ee=Wa;break;case"focusout":ie="blur",ee=Wa;break;case"beforeblur":case"afterblur":ee=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":ee=jd;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ee=lk;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ee=Sk;break;case Ud:case Wd:case Hd:ee=dk;break;case Kd:ee=bk;break;case"scroll":ee=ok;break;case"wheel":ee=$k;break;case"copy":case"cut":case"paste":ee=fk;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ee=Nd}var oe=(r&4)!==0,He=!oe&&n==="scroll",A=oe?B!==null?B+"Capture":null:B;oe=[];for(var E=L,M;E!==null;){M=E;var G=M.stateNode;if(M.tag===5&&G!==null&&(M=G,A!==null&&(G=ci(E,A),G!=null&&oe.push(Ti(E,G,M)))),He)break;E=E.return}0<oe.length&&(B=new ee(B,ie,null,l,U),W.push({event:B,listeners:oe}))}}if((r&7)===0){e:{if(B=n==="mouseover"||n==="pointerover",ee=n==="mouseout"||n==="pointerout",B&&l!==ba&&(ie=l.relatedTarget||l.fromElement)&&(Jn(ie)||ie[dn]))break e;if((ee||B)&&(B=U.window===U?U:(B=U.ownerDocument)?B.defaultView||B.parentWindow:window,ee?(ie=l.relatedTarget||l.toElement,ee=L,ie=ie?Jn(ie):null,ie!==null&&(He=Yn(ie),ie!==He||ie.tag!==5&&ie.tag!==6)&&(ie=null)):(ee=null,ie=L),ee!==ie)){if(oe=jd,G="onMouseLeave",A="onMouseEnter",E="mouse",(n==="pointerout"||n==="pointerover")&&(oe=Nd,G="onPointerLeave",A="onPointerEnter",E="pointer"),He=ee==null?B:Ns(ee),M=ie==null?B:Ns(ie),B=new oe(G,E+"leave",ee,l,U),B.target=He,B.relatedTarget=M,G=null,Jn(U)===L&&(oe=new oe(A,E+"enter",ie,l,U),oe.target=M,oe.relatedTarget=He,G=oe),He=G,ee&&ie)t:{for(oe=ee,A=ie,E=0,M=oe;M;M=js(M))E++;for(M=0,G=A;G;G=js(G))M++;for(;0<E-M;)oe=js(oe),E--;for(;0<M-E;)A=js(A),M--;for(;E--;){if(oe===A||A!==null&&oe===A.alternate)break t;oe=js(oe),A=js(A)}oe=null}else oe=null;ee!==null&&Jd(W,B,ee,oe,!1),ie!==null&&He!==null&&Jd(W,He,ie,oe,!0)}}e:{if(B=L?Ns(L):window,ee=B.nodeName&&B.nodeName.toLowerCase(),ee==="select"||ee==="input"&&B.type==="file")var ae=Lk;else if(Ad(B))if(Md)ae=Dk;else{ae=Pk;var de=Ok}else(ee=B.nodeName)&&ee.toLowerCase()==="input"&&(B.type==="checkbox"||B.type==="radio")&&(ae=_k);if(ae&&(ae=ae(n,L))){Id(W,ae,l,U);break e}de&&de(n,B,L),n==="focusout"&&(de=B._wrapperState)&&de.controlled&&B.type==="number"&&wa(B,"number",B.value)}switch(de=L?Ns(L):window,n){case"focusin":(Ad(de)||de.contentEditable==="true")&&(ws=de,Qa=L,bi=null);break;case"focusout":bi=Qa=ws=null;break;case"mousedown":Ya=!0;break;case"contextmenu":case"mouseup":case"dragend":Ya=!1,Bd(W,l,U);break;case"selectionchange":if(Fk)break;case"keydown":case"keyup":Bd(W,l,U)}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?Td(n,l)&&(fe="onCompositionEnd"):n==="keydown"&&l.keyCode===229&&(fe="onCompositionStart");fe&&(bd&&l.locale!=="ko"&&(ys||fe!=="onCompositionStart"?fe==="onCompositionEnd"&&ys&&(he=wd()):(Tn=U,za="value"in Tn?Tn.value:Tn.textContent,ys=!0)),de=Ir(L,fe),0<de.length&&(fe=new Sd(fe,n,null,l,U),W.push({event:fe,listeners:de}),he?fe.data=he:(he=Ed(l),he!==null&&(fe.data=he)))),(he=Ek?Ak(n,l):Ik(n,l))&&(L=Ir(L,"onBeforeInput"),0<L.length&&(U=new Sd("onBeforeInput","beforeinput",null,l,U),W.push({event:U,listeners:L}),U.data=he))}Qd(W,r)})}function Ti(n,r,l){return{instance:n,listener:r,currentTarget:l}}function Ir(n,r){for(var l=r+"Capture",u=[];n!==null;){var f=n,g=f.stateNode;f.tag===5&&g!==null&&(f=g,g=ci(n,l),g!=null&&u.unshift(Ti(n,g,f)),g=ci(n,r),g!=null&&u.push(Ti(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 Jd(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?($=ci(l,g),$!=null&&w.unshift(Ti(l,$,N))):f||($=ci(l,g),$!=null&&w.push(Ti(l,$,N)))),l=l.return}w.length!==0&&n.push({event:r,listeners:w})}var Kk=/\r\n?/g,Vk=/\u0000|\uFFFD/g;function Xd(n){return(typeof n=="string"?n:""+n).replace(Kk,`
38
+ `).replace(Vk,"")}function Mr(n,r,l){if(r=Xd(r),Xd(n)!==r&&l)throw Error(s(425))}function Rr(){}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,Gk=typeof clearTimeout=="function"?clearTimeout:void 0,Zd=typeof Promise=="function"?Promise:void 0,qk=typeof queueMicrotask=="function"?queueMicrotask:typeof Zd<"u"?function(n){return Zd.resolve(null).then(n).catch(Qk)}:rl;function Qk(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),ki(r);return}u--}else l!=="$"&&l!=="$?"&&l!=="$!"||u++;l=f}while(l);ki(r)}function An(n){for(;n!=null;n=n.nextSibling){var r=n.nodeType;if(r===1||r===3)break;if(r===8){if(r=n.data,r==="$"||r==="$!"||r==="$?")break;if(r==="/$")return null}}return n}function eh(n){n=n.previousSibling;for(var r=0;n;){if(n.nodeType===8){var l=n.data;if(l==="$"||l==="$!"||l==="$?"){if(r===0)return n;r--}else l==="/$"&&r++}n=n.previousSibling}return null}var Ss=Math.random().toString(36).slice(2),Jt="__reactFiber$"+Ss,Ei="__reactProps$"+Ss,dn="__reactContainer$"+Ss,al="__reactEvents$"+Ss,Yk="__reactListeners$"+Ss,Jk="__reactHandles$"+Ss;function Jn(n){var r=n[Jt];if(r)return r;for(var l=n.parentNode;l;){if(r=l[dn]||l[Jt]){if(l=r.alternate,r.child!==null||l!==null&&l.child!==null)for(n=eh(n);n!==null;){if(l=n[Jt])return l;n=eh(n)}return r}n=l,l=n.parentNode}return null}function Ai(n){return n=n[Jt]||n[dn],!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 Lr(n){return n[Ei]||null}var ll=[],bs=-1;function In(n){return{current:n}}function Le(n){0>bs||(n.current=ll[bs],ll[bs]=null,bs--)}function Ee(n,r){bs++,ll[bs]=n.current,n.current=r}var Mn={},rt=In(Mn),pt=In(!1),Xn=Mn;function Cs(n,r){var l=n.type.contextTypes;if(!l)return Mn;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 gt(n){return n=n.childContextTypes,n!=null}function Or(){Le(pt),Le(rt)}function th(n,r,l){if(rt.current!==Mn)throw Error(s(168));Ee(rt,r),Ee(pt,l)}function nh(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 F({},l,u)}function Pr(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||Mn,Xn=rt.current,Ee(rt,n),Ee(pt,pt.current),!0}function sh(n,r,l){var u=n.stateNode;if(!u)throw Error(s(169));l?(n=nh(n,r,Xn),u.__reactInternalMemoizedMergedChildContext=n,Le(pt),Le(rt),Ee(rt,n)):Le(pt),Ee(pt,l)}var hn=null,_r=!1,cl=!1;function ih(n){hn===null?hn=[n]:hn.push(n)}function Xk(n){_r=!0,ih(n)}function Rn(){if(!cl&&hn!==null){cl=!0;var n=0,r=Te;try{var l=hn;for(Te=1;n<l.length;n++){var u=l[n];do u=u(!0);while(u!==null)}hn=null,_r=!1}catch(f){throw hn!==null&&(hn=hn.slice(n+1)),od(Ia,Rn),f}finally{Te=r,cl=!1}}return null}var $s=[],Ts=0,Dr=null,zr=0,Et=[],At=0,Zn=null,fn=1,mn="";function es(n,r){$s[Ts++]=zr,$s[Ts++]=Dr,Dr=n,zr=r}function rh(n,r,l){Et[At++]=fn,Et[At++]=mn,Et[At++]=Zn,Zn=n;var u=fn;n=mn;var f=32-zt(u)-1;u&=~(1<<f),l+=1;var g=32-zt(r)+f;if(30<g){var w=f-f%5;g=(u&(1<<w)-1).toString(32),u>>=w,f-=w,fn=1<<32-zt(r)+f|l<<f|u,mn=g+n}else fn=1<<g|l<<f|u,mn=n}function ul(n){n.return!==null&&(es(n,1),rh(n,1,0))}function dl(n){for(;n===Dr;)Dr=$s[--Ts],$s[Ts]=null,zr=$s[--Ts],$s[Ts]=null;for(;n===Zn;)Zn=Et[--At],Et[At]=null,mn=Et[--At],Et[At]=null,fn=Et[--At],Et[At]=null}var bt=null,Ct=null,Oe=!1,Ft=null;function oh(n,r){var l=Lt(5,null,null,0);l.elementType="DELETED",l.stateNode=r,l.return=n,r=n.deletions,r===null?(n.deletions=[l],n.flags|=16):r.push(l)}function ah(n,r){switch(n.tag){case 5:var l=n.type;return r=r.nodeType!==1||l.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(n.stateNode=r,bt=n,Ct=An(r.firstChild),!0):!1;case 6:return r=n.pendingProps===""||r.nodeType!==3?null:r,r!==null?(n.stateNode=r,bt=n,Ct=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(l=Zn!==null?{id:fn,overflow:mn}:null,n.memoizedState={dehydrated:r,treeContext:l,retryLane:1073741824},l=Lt(18,null,null,0),l.stateNode=r,l.return=n,n.child=l,bt=n,Ct=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=Ct;if(r){var l=r;if(!ah(n,r)){if(hl(n))throw Error(s(418));r=An(l.nextSibling);var u=bt;r&&ah(n,r)?oh(u,l):(n.flags=n.flags&-4097|2,Oe=!1,bt=n)}}else{if(hl(n))throw Error(s(418));n.flags=n.flags&-4097|2,Oe=!1,bt=n}}}function lh(n){for(n=n.return;n!==null&&n.tag!==5&&n.tag!==3&&n.tag!==13;)n=n.return;bt=n}function Br(n){if(n!==bt)return!1;if(!Oe)return lh(n),Oe=!0,!1;var r;if((r=n.tag!==3)&&!(r=n.tag!==5)&&(r=n.type,r=r!=="head"&&r!=="body"&&!il(n.type,n.memoizedProps)),r&&(r=Ct)){if(hl(n))throw ch(),Error(s(418));for(;r;)oh(n,r),r=An(r.nextSibling)}if(lh(n),n.tag===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(s(317));e:{for(n=n.nextSibling,r=0;n;){if(n.nodeType===8){var l=n.data;if(l==="/$"){if(r===0){Ct=An(n.nextSibling);break e}r--}else l!=="$"&&l!=="$!"&&l!=="$?"||r++}n=n.nextSibling}Ct=null}}else Ct=bt?An(n.stateNode.nextSibling):null;return!0}function ch(){for(var n=Ct;n;)n=An(n.nextSibling)}function Es(){Ct=bt=null,Oe=!1}function ml(n){Ft===null?Ft=[n]:Ft.push(n)}var Zk=z.ReactCurrentBatchConfig;function Ii(n,r,l){if(n=l.ref,n!==null&&typeof n!="function"&&typeof n!="object"){if(l._owner){if(l=l._owner,l){if(l.tag!==1)throw Error(s(309));var 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 Fr(n,r){throw n=Object.prototype.toString.call(r),Error(s(31,n==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":n))}function uh(n){var r=n._init;return r(n._payload)}function dh(n){function r(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=Fn(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,G){return E===null||E.tag!==6?(E=rc(M,A.mode,G),E.return=A,E):(E=f(E,M),E.return=A,E)}function $(A,E,M,G){var ae=M.type;return ae===H?U(A,E,M.props.children,G,M.key):E!==null&&(E.elementType===ae||typeof ae=="object"&&ae!==null&&ae.$$typeof===X&&uh(ae)===E.type)?(G=f(E,M.props),G.ref=Ii(A,E,M),G.return=A,G):(G=ho(M.type,M.key,M.props,null,A.mode,G),G.ref=Ii(A,E,M),G.return=A,G)}function L(A,E,M,G){return E===null||E.tag!==4||E.stateNode.containerInfo!==M.containerInfo||E.stateNode.implementation!==M.implementation?(E=oc(M,A.mode,G),E.return=A,E):(E=f(E,M.children||[]),E.return=A,E)}function U(A,E,M,G,ae){return E===null||E.tag!==7?(E=ls(M,A.mode,G,ae),E.return=A,E):(E=f(E,M),E.return=A,E)}function W(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 Z:return M=ho(E.type,E.key,E.props,null,A.mode,M),M.ref=Ii(A,null,E),M.return=A,M;case q:return E=oc(E,A.mode,M),E.return=A,E;case X:var G=E._init;return W(A,G(E._payload),M)}if(oi(E)||Y(E))return E=ls(E,A.mode,M,null),E.return=A,E;Fr(A,E)}return null}function B(A,E,M,G){var ae=E!==null?E.key:null;if(typeof M=="string"&&M!==""||typeof M=="number")return ae!==null?null:N(A,E,""+M,G);if(typeof M=="object"&&M!==null){switch(M.$$typeof){case Z:return M.key===ae?$(A,E,M,G):null;case q:return M.key===ae?L(A,E,M,G):null;case X:return ae=M._init,B(A,E,ae(M._payload),G)}if(oi(M)||Y(M))return ae!==null?null:U(A,E,M,G,null);Fr(A,M)}return null}function ee(A,E,M,G,ae){if(typeof G=="string"&&G!==""||typeof G=="number")return A=A.get(M)||null,N(E,A,""+G,ae);if(typeof G=="object"&&G!==null){switch(G.$$typeof){case Z:return A=A.get(G.key===null?M:G.key)||null,$(E,A,G,ae);case q:return A=A.get(G.key===null?M:G.key)||null,L(E,A,G,ae);case X:var de=G._init;return ee(A,E,M,de(G._payload),ae)}if(oi(G)||Y(G))return A=A.get(M)||null,U(E,A,G,ae,null);Fr(E,G)}return null}function ie(A,E,M,G){for(var ae=null,de=null,he=E,fe=E=0,tt=null;he!==null&&fe<M.length;fe++){he.index>fe?(tt=he,he=null):tt=he.sibling;var be=B(A,he,M[fe],G);if(be===null){he===null&&(he=tt);break}n&&he&&be.alternate===null&&r(A,he),E=g(be,E,fe),de===null?ae=be:de.sibling=be,de=be,he=tt}if(fe===M.length)return l(A,he),Oe&&es(A,fe),ae;if(he===null){for(;fe<M.length;fe++)he=W(A,M[fe],G),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++)tt=ee(he,A,fe,M[fe],G),tt!==null&&(n&&tt.alternate!==null&&he.delete(tt.key===null?fe:tt.key),E=g(tt,E,fe),de===null?ae=tt:de.sibling=tt,de=tt);return n&&he.forEach(function(Un){return r(A,Un)}),Oe&&es(A,fe),ae}function oe(A,E,M,G){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,tt=null,be=M.next();he!==null&&!be.done;fe++,be=M.next()){he.index>fe?(tt=he,he=null):tt=he.sibling;var Un=B(A,he,be.value,G);if(Un===null){he===null&&(he=tt);break}n&&he&&Un.alternate===null&&r(A,he),E=g(Un,E,fe),de===null?ae=Un:de.sibling=Un,de=Un,he=tt}if(be.done)return l(A,he),Oe&&es(A,fe),ae;if(he===null){for(;!be.done;fe++,be=M.next())be=W(A,be.value,G),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=ee(he,A,fe,be.value,G),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(My){return r(A,My)}),Oe&&es(A,fe),ae}function He(A,E,M,G){if(typeof M=="object"&&M!==null&&M.type===H&&M.key===null&&(M=M.props.children),typeof M=="object"&&M!==null){switch(M.$$typeof){case Z:e:{for(var ae=M.key,de=E;de!==null;){if(de.key===ae){if(ae=M.type,ae===H){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===X&&uh(ae)===de.type){l(A,de.sibling),E=f(de,M.props),E.ref=Ii(A,de,M),E.return=A,A=E;break e}l(A,de);break}else r(A,de);de=de.sibling}M.type===H?(E=ls(M.props.children,A.mode,G,M.key),E.return=A,A=E):(G=ho(M.type,M.key,M.props,null,A.mode,G),G.ref=Ii(A,E,M),G.return=A,A=G)}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,G),E.return=A,A=E}return w(A);case X:return de=M._init,He(A,E,de(M._payload),G)}if(oi(M))return ie(A,E,M,G);if(Y(M))return oe(A,E,M,G);Fr(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,G),E.return=A,A=E),w(A)):l(A,E)}return He}var As=dh(!0),hh=dh(!1),Ur=In(null),Wr=null,Is=null,pl=null;function gl(){pl=Is=Wr=null}function vl(n){var r=Ur.current;Le(Ur),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){Wr=n,pl=Is=null,n=n.dependencies,n!==null&&n.firstContext!==null&&((n.lanes&r)!==0&&(vt=!0),n.firstContext=null)}function It(n){var r=n._currentValue;if(pl!==n)if(n={context:n,memoizedValue:r,next:null},Is===null){if(Wr===null)throw Error(s(308));Is=n,Wr.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 fh(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,pn(n,u)}function pn(n,r){n.lanes|=r;var l=n.alternate;for(l!==null&&(l.lanes|=r),l=n,n=n.return;n!==null;)n.childLanes|=r,l=n.alternate,l!==null&&(l.childLanes|=r),l=n,n=n.return;return l.tag===3?l.stateNode:null}var Ln=!1;function wl(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function mh(n,r){n=n.updateQueue,r.updateQueue===n&&(r.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,effects:n.effects})}function gn(n,r){return{eventTime:n,lane:r,tag:0,payload:null,callback:null,next:null}}function On(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,pn(n,l)}return f=u.interleaved,f===null?(r.next=r,yl(u)):(r.next=f.next,f.next=r),u.interleaved=r,pn(n,l)}function Hr(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 ph(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 Kr(n,r,l,u){var f=n.updateQueue;Ln=!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 U=n.alternate;U!==null&&(U=U.updateQueue,N=U.lastBaseUpdate,N!==w&&(N===null?U.firstBaseUpdate=L:N.next=L,U.lastBaseUpdate=$))}if(g!==null){var W=f.baseState;w=0,U=L=$=null,N=g;do{var B=N.lane,ee=N.eventTime;if((u&B)===B){U!==null&&(U=U.next={eventTime:ee,lane:0,tag:N.tag,payload:N.payload,callback:N.callback,next:null});e:{var ie=n,oe=N;switch(B=r,ee=l,oe.tag){case 1:if(ie=oe.payload,typeof ie=="function"){W=ie.call(ee,W,B);break e}W=ie;break e;case 3:ie.flags=ie.flags&-65537|128;case 0:if(ie=oe.payload,B=typeof ie=="function"?ie.call(ee,W,B):ie,B==null)break e;W=F({},W,B);break e;case 2:Ln=!0}}N.callback!==null&&N.lane!==0&&(n.flags|=64,B=f.effects,B===null?f.effects=[N]:B.push(N))}else ee={eventTime:ee,lane:B,tag:N.tag,payload:N.payload,callback:N.callback,next:null},U===null?(L=U=ee,$=W):U=U.next=ee,w|=B;if(N=N.next,N===null){if(N=f.shared.pending,N===null)break;B=N,N=B.next,B.next=null,f.lastBaseUpdate=B,f.shared.pending=null}}while(!0);if(U===null&&($=W),f.baseState=$,f.firstBaseUpdate=L,f.lastBaseUpdate=U,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=W}}function gh(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 Mi={},Xt=In(Mi),Ri=In(Mi),Li=In(Mi);function ns(n){if(n===Mi)throw Error(s(174));return n}function xl(n,r){switch(Ee(Li,r),Ee(Ri,n),Ee(Xt,Mi),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)}Le(Xt),Ee(Xt,r)}function Rs(){Le(Xt),Le(Ri),Le(Li)}function vh(n){ns(Li.current);var r=ns(Xt.current),l=ja(r,n.type);r!==l&&(Ee(Ri,n),Ee(Xt,l))}function jl(n){Ri.current===n&&(Le(Xt),Le(Ri))}var Pe=In(0);function Vr(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 Gr=z.ReactCurrentDispatcher,bl=z.ReactCurrentBatchConfig,ss=0,_e=null,Ye=null,Ze=null,qr=!1,Oi=!1,Pi=0,ey=0;function ot(){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(!Bt(n[l],r[l]))return!1;return!0}function $l(n,r,l,u,f,g){if(ss=g,_e=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,Gr.current=n===null||n.memoizedState===null?iy:ry,n=l(u,f),Oi){g=0;do{if(Oi=!1,Pi=0,25<=g)throw Error(s(301));g+=1,Ze=Ye=null,r.updateQueue=null,Gr.current=oy,n=l(u,f)}while(Oi)}if(Gr.current=Jr,r=Ye!==null&&Ye.next!==null,ss=0,Ze=Ye=_e=null,qr=!1,r)throw Error(s(300));return n}function Tl(){var n=Pi!==0;return Pi=0,n}function Zt(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ze===null?_e.memoizedState=Ze=n:Ze=Ze.next=n,Ze}function Mt(){if(Ye===null){var n=_e.alternate;n=n!==null?n.memoizedState:null}else n=Ye.next;var r=Ze===null?_e.memoizedState:Ze.next;if(r!==null)Ze=r,Ye=n;else{if(n===null)throw Error(s(310));Ye=n,n={memoizedState:Ye.memoizedState,baseState:Ye.baseState,baseQueue:Ye.baseQueue,queue:Ye.queue,next:null},Ze===null?_e.memoizedState=Ze=n:Ze=Ze.next=n}return Ze}function _i(n,r){return typeof r=="function"?r(n):r}function El(n){var r=Mt(),l=r.queue;if(l===null)throw Error(s(311));l.lastRenderedReducer=n;var u=Ye,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 U=L.lane;if((ss&U)===U)$!==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 W={lane:U,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null};$===null?(N=$=W,w=u):$=$.next=W,_e.lanes|=U,is|=U}L=L.next}while(L!==null&&L!==g);$===null?w=u:$.next=N,Bt(u,r.memoizedState)||(vt=!0),r.memoizedState=u,r.baseState=w,r.baseQueue=$,l.lastRenderedState=u}if(n=l.interleaved,n!==null){f=n;do g=f.lane,_e.lanes|=g,is|=g,f=f.next;while(f!==n)}else f===null&&(l.lanes=0);return[r.memoizedState,l.dispatch]}function Al(n){var r=Mt(),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);Bt(g,r.memoizedState)||(vt=!0),r.memoizedState=g,r.baseQueue===null&&(r.baseState=g),l.lastRenderedState=g}return[g,u]}function kh(){}function yh(n,r){var l=_e,u=Mt(),f=r(),g=!Bt(u.memoizedState,f);if(g&&(u.memoizedState=f,vt=!0),u=u.queue,Il(jh.bind(null,l,u,n),[n]),u.getSnapshot!==r||g||Ze!==null&&Ze.memoizedState.tag&1){if(l.flags|=2048,Di(9,xh.bind(null,l,u,f,r),void 0,null),et===null)throw Error(s(349));(ss&30)!==0||wh(l,r,f)}return f}function wh(n,r,l){n.flags|=16384,n={getSnapshot:r,value:l},r=_e.updateQueue,r===null?(r={lastEffect:null,stores:null},_e.updateQueue=r,r.stores=[n]):(l=r.stores,l===null?r.stores=[n]:l.push(n))}function xh(n,r,l,u){r.value=l,r.getSnapshot=u,Sh(r)&&Nh(n)}function jh(n,r,l){return l(function(){Sh(r)&&Nh(n)})}function Sh(n){var r=n.getSnapshot;n=n.value;try{var l=r();return!Bt(n,l)}catch{return!0}}function Nh(n){var r=pn(n,1);r!==null&&Kt(r,n,1,-1)}function bh(n){var r=Zt();return typeof n=="function"&&(n=n()),r.memoizedState=r.baseState=n,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:_i,lastRenderedState:n},r.queue=n,n=n.dispatch=sy.bind(null,_e,n),[r.memoizedState,n]}function Di(n,r,l,u){return n={tag:n,create:r,destroy:l,deps:u,next:null},r=_e.updateQueue,r===null?(r={lastEffect:null,stores:null},_e.updateQueue=r,r.lastEffect=n.next=n):(l=r.lastEffect,l===null?r.lastEffect=n.next=n:(u=l.next,l.next=n,n.next=u,r.lastEffect=n)),n}function Ch(){return Mt().memoizedState}function Qr(n,r,l,u){var f=Zt();_e.flags|=n,f.memoizedState=Di(1|r,l,void 0,u===void 0?null:u)}function Yr(n,r,l,u){var f=Mt();u=u===void 0?null:u;var g=void 0;if(Ye!==null){var w=Ye.memoizedState;if(g=w.destroy,u!==null&&Cl(u,w.deps)){f.memoizedState=Di(r,l,g,u);return}}_e.flags|=n,f.memoizedState=Di(1|r,l,g,u)}function $h(n,r){return Qr(8390656,8,n,r)}function Il(n,r){return Yr(2048,8,n,r)}function Th(n,r){return Yr(4,2,n,r)}function Eh(n,r){return Yr(4,4,n,r)}function Ah(n,r){if(typeof r=="function")return n=n(),r(n),function(){r(null)};if(r!=null)return n=n(),r.current=n,function(){r.current=null}}function Ih(n,r,l){return l=l!=null?l.concat([n]):null,Yr(4,4,Ah.bind(null,r,n),l)}function Ml(){}function Mh(n,r){var l=Mt();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 Rh(n,r){var l=Mt();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 Lh(n,r,l){return(ss&21)===0?(n.baseState&&(n.baseState=!1,vt=!0),n.memoizedState=l):(Bt(l,r)||(l=ud(),_e.lanes|=l,is|=l,n.baseState=!0),r)}function ty(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 Oh(){return Mt().memoizedState}function ny(n,r,l){var u=zn(n);if(l={lane:u,action:l,hasEagerState:!1,eagerState:null,next:null},Ph(n))_h(r,l);else if(l=fh(n,r,l,u),l!==null){var f=ht();Kt(l,n,u,f),Dh(l,r,u)}}function sy(n,r,l){var u=zn(n),f={lane:u,action:l,hasEagerState:!1,eagerState:null,next:null};if(Ph(n))_h(r,f);else{var g=n.alternate;if(n.lanes===0&&(g===null||g.lanes===0)&&(g=r.lastRenderedReducer,g!==null))try{var w=r.lastRenderedState,N=g(w,l);if(f.hasEagerState=!0,f.eagerState=N,Bt(N,w)){var $=r.interleaved;$===null?(f.next=f,yl(r)):(f.next=$.next,$.next=f),r.interleaved=f;return}}catch{}finally{}l=fh(n,r,f,u),l!==null&&(f=ht(),Kt(l,n,u,f),Dh(l,r,u))}}function Ph(n){var r=n.alternate;return n===_e||r!==null&&r===_e}function _h(n,r){Oi=qr=!0;var l=n.pending;l===null?r.next=r:(r.next=l.next,l.next=r),n.pending=r}function Dh(n,r,l){if((l&4194240)!==0){var u=r.lanes;u&=n.pendingLanes,l|=u,r.lanes=l,La(n,l)}}var Jr={readContext:It,useCallback:ot,useContext:ot,useEffect:ot,useImperativeHandle:ot,useInsertionEffect:ot,useLayoutEffect:ot,useMemo:ot,useReducer:ot,useRef:ot,useState:ot,useDebugValue:ot,useDeferredValue:ot,useTransition:ot,useMutableSource:ot,useSyncExternalStore:ot,useId:ot,unstable_isNewReconciler:!1},iy={readContext:It,useCallback:function(n,r){return Zt().memoizedState=[n,r===void 0?null:r],n},useContext:It,useEffect:$h,useImperativeHandle:function(n,r,l){return l=l!=null?l.concat([n]):null,Qr(4194308,4,Ah.bind(null,r,n),l)},useLayoutEffect:function(n,r){return Qr(4194308,4,n,r)},useInsertionEffect:function(n,r){return Qr(4,2,n,r)},useMemo:function(n,r){var l=Zt();return r=r===void 0?null:r,n=n(),l.memoizedState=[n,r],n},useReducer:function(n,r,l){var u=Zt();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=ny.bind(null,_e,n),[u.memoizedState,n]},useRef:function(n){var r=Zt();return n={current:n},r.memoizedState=n},useState:bh,useDebugValue:Ml,useDeferredValue:function(n){return Zt().memoizedState=n},useTransition:function(){var n=bh(!1),r=n[0];return n=ty.bind(null,n[1]),Zt().memoizedState=n,[r,n]},useMutableSource:function(){},useSyncExternalStore:function(n,r,l){var u=_e,f=Zt();if(Oe){if(l===void 0)throw Error(s(407));l=l()}else{if(l=r(),et===null)throw Error(s(349));(ss&30)!==0||wh(u,r,l)}f.memoizedState=l;var g={value:l,getSnapshot:r};return f.queue=g,$h(jh.bind(null,u,g,n),[n]),u.flags|=2048,Di(9,xh.bind(null,u,g,l,r),void 0,null),l},useId:function(){var n=Zt(),r=et.identifierPrefix;if(Oe){var l=mn,u=fn;l=(u&~(1<<32-zt(u)-1)).toString(32)+l,r=":"+r+"R"+l,l=Pi++,0<l&&(r+="H"+l.toString(32)),r+=":"}else l=ey++,r=":"+r+"r"+l.toString(32)+":";return n.memoizedState=r},unstable_isNewReconciler:!1},ry={readContext:It,useCallback:Mh,useContext:It,useEffect:Il,useImperativeHandle:Ih,useInsertionEffect:Th,useLayoutEffect:Eh,useMemo:Rh,useReducer:El,useRef:Ch,useState:function(){return El(_i)},useDebugValue:Ml,useDeferredValue:function(n){var r=Mt();return Lh(r,Ye.memoizedState,n)},useTransition:function(){var n=El(_i)[0],r=Mt().memoizedState;return[n,r]},useMutableSource:kh,useSyncExternalStore:yh,useId:Oh,unstable_isNewReconciler:!1},oy={readContext:It,useCallback:Mh,useContext:It,useEffect:Il,useImperativeHandle:Ih,useInsertionEffect:Th,useLayoutEffect:Eh,useMemo:Rh,useReducer:Al,useRef:Ch,useState:function(){return Al(_i)},useDebugValue:Ml,useDeferredValue:function(n){var r=Mt();return Ye===null?r.memoizedState=n:Lh(r,Ye.memoizedState,n)},useTransition:function(){var n=Al(_i)[0],r=Mt().memoizedState;return[n,r]},useMutableSource:kh,useSyncExternalStore:yh,useId:Oh,unstable_isNewReconciler:!1};function Ut(n,r){if(n&&n.defaultProps){r=F({},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:F({},r,l),n.memoizedState=l,n.lanes===0&&(n.updateQueue.baseState=l)}var Xr={isMounted:function(n){return(n=n._reactInternals)?Yn(n)===n:!1},enqueueSetState:function(n,r,l){n=n._reactInternals;var u=ht(),f=zn(n),g=gn(u,f);g.payload=r,l!=null&&(g.callback=l),r=On(n,g,f),r!==null&&(Kt(r,n,f,u),Hr(r,n,f))},enqueueReplaceState:function(n,r,l){n=n._reactInternals;var u=ht(),f=zn(n),g=gn(u,f);g.tag=1,g.payload=r,l!=null&&(g.callback=l),r=On(n,g,f),r!==null&&(Kt(r,n,f,u),Hr(r,n,f))},enqueueForceUpdate:function(n,r){n=n._reactInternals;var l=ht(),u=zn(n),f=gn(l,u);f.tag=2,r!=null&&(f.callback=r),r=On(n,f,u),r!==null&&(Kt(r,n,u,l),Hr(r,n,u))}};function zh(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?!Ni(l,u)||!Ni(f,g):!0}function Bh(n,r,l){var u=!1,f=Mn,g=r.contextType;return typeof g=="object"&&g!==null?g=It(g):(f=gt(r)?Xn:rt.current,u=r.contextTypes,g=(u=u!=null)?Cs(n,f):Mn),r=new r(l,g),n.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=Xr,n.stateNode=r,r._reactInternals=n,u&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=f,n.__reactInternalMemoizedMaskedChildContext=g),r}function Fh(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&&Xr.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=It(g):(g=gt(r)?Xn:rt.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&&Xr.enqueueReplaceState(f,f.state,null),Kr(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+=ye(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 ay=typeof WeakMap=="function"?WeakMap:Map;function Uh(n,r,l){l=gn(-1,l),l.tag=3,l.payload={element:null};var u=r.value;return l.callback=function(){ro||(ro=!0,Jl=u),Pl(n,r)},l}function Wh(n,r,l){l=gn(-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"&&(_n===null?_n=new Set([this]):_n.add(this));var w=r.stack;this.componentDidCatch(r.value,{componentStack:w!==null?w:""})}),l}function Hh(n,r,l){var u=n.pingCache;if(u===null){u=n.pingCache=new ay;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=xy.bind(null,n,r,l),r.then(n,n))}function Kh(n){do{var r;if((r=n.tag===13)&&(r=n.memoizedState,r=r!==null?r.dehydrated!==null:!0),r)return n;n=n.return}while(n!==null);return null}function Vh(n,r,l,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=gn(-1,1),r.tag=2,On(l,r,1))),l.lanes|=1),n):(n.flags|=65536,n.lanes=f,n)}var ly=z.ReactCurrentOwner,vt=!1;function dt(n,r,l,u){r.child=n===null?hh(r,null,l,u):As(r,n.child,l,u)}function Gh(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&&!vt?(r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~f,vn(n,r,f)):(Oe&&l&&ul(r),r.flags|=1,dt(n,r,u,f),r.child)}function qh(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,Qh(n,r,g,u,f)):(n=ho(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:Ni,l(w,u)&&n.ref===r.ref)return vn(n,r,f)}return r.flags|=1,n=Fn(g,u),n.ref=r.ref,n.return=r,r.child=n}function Qh(n,r,l,u,f){if(n!==null){var g=n.memoizedProps;if(Ni(g,u)&&n.ref===r.ref)if(vt=!1,r.pendingProps=u=g,(n.lanes&f)!==0)(n.flags&131072)!==0&&(vt=!0);else return r.lanes=n.lanes,vn(n,r,f)}return _l(n,r,l,u,f)}function Yh(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,$t),$t|=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,$t),$t|=n,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},u=g!==null?g.baseLanes:l,Ee(Ps,$t),$t|=u}else g!==null?(u=g.baseLanes|l,r.memoizedState=null):u=l,Ee(Ps,$t),$t|=u;return dt(n,r,f,l),r.child}function Jh(n,r){var l=r.ref;(n===null&&l!==null||n!==null&&n.ref!==l)&&(r.flags|=512,r.flags|=2097152)}function _l(n,r,l,u,f){var g=gt(l)?Xn:rt.current;return g=Cs(r,g),Ms(r,f),l=$l(n,r,l,u,g,f),u=Tl(),n!==null&&!vt?(r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~f,vn(n,r,f)):(Oe&&u&&ul(r),r.flags|=1,dt(n,r,l,f),r.child)}function Xh(n,r,l,u,f){if(gt(l)){var g=!0;Pr(r)}else g=!1;if(Ms(r,f),r.stateNode===null)eo(n,r),Bh(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=It(L):(L=gt(l)?Xn:rt.current,L=Cs(r,L));var U=l.getDerivedStateFromProps,W=typeof U=="function"||typeof w.getSnapshotBeforeUpdate=="function";W||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(N!==u||$!==L)&&Fh(r,w,u,L),Ln=!1;var B=r.memoizedState;w.state=B,Kr(r,u,w,f),$=r.memoizedState,N!==u||B!==$||pt.current||Ln?(typeof U=="function"&&(Rl(r,l,U,u),$=r.memoizedState),(N=Ln||zh(r,l,N,u,B,$,L))?(W||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,mh(n,r),N=r.memoizedProps,L=r.type===r.elementType?N:Ut(r.type,N),w.props=L,W=r.pendingProps,B=w.context,$=l.contextType,typeof $=="object"&&$!==null?$=It($):($=gt(l)?Xn:rt.current,$=Cs(r,$));var ee=l.getDerivedStateFromProps;(U=typeof ee=="function"||typeof w.getSnapshotBeforeUpdate=="function")||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(N!==W||B!==$)&&Fh(r,w,u,$),Ln=!1,B=r.memoizedState,w.state=B,Kr(r,u,w,f);var ie=r.memoizedState;N!==W||B!==ie||pt.current||Ln?(typeof ee=="function"&&(Rl(r,l,ee,u),ie=r.memoizedState),(L=Ln||zh(r,l,L,u,B,ie,$)||!1)?(U||typeof w.UNSAFE_componentWillUpdate!="function"&&typeof w.componentWillUpdate!="function"||(typeof w.componentWillUpdate=="function"&&w.componentWillUpdate(u,ie,$),typeof w.UNSAFE_componentWillUpdate=="function"&&w.UNSAFE_componentWillUpdate(u,ie,$)),typeof w.componentDidUpdate=="function"&&(r.flags|=4),typeof w.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof w.componentDidUpdate!="function"||N===n.memoizedProps&&B===n.memoizedState||(r.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||N===n.memoizedProps&&B===n.memoizedState||(r.flags|=1024),r.memoizedProps=u,r.memoizedState=ie),w.props=u,w.state=ie,w.context=$,u=L):(typeof w.componentDidUpdate!="function"||N===n.memoizedProps&&B===n.memoizedState||(r.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||N===n.memoizedProps&&B===n.memoizedState||(r.flags|=1024),u=!1)}return Dl(n,r,l,u,g,f)}function Dl(n,r,l,u,f,g){Jh(n,r);var w=(r.flags&128)!==0;if(!u&&!w)return f&&sh(r,l,!1),vn(n,r,g);u=r.stateNode,ly.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)):dt(n,r,N,g),r.memoizedState=u.state,f&&sh(r,l,!0),r.child}function Zh(n){var r=n.stateNode;r.pendingContext?th(n,r.pendingContext,r.pendingContext!==r.context):r.context&&th(n,r.context,!1),xl(n,r.containerInfo)}function ef(n,r,l,u,f){return Es(),ml(f),r.flags|=256,dt(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 tf(n,r,l){var u=r.pendingProps,f=Pe.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(Pe,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=fo(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 cy(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=Fn(f,$),u.subtreeFlags=f.subtreeFlags&14680064),N!==null?g=Fn(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=Fn(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=fo({mode:"visible",children:r},n.mode,0,null),r.return=n,n.child=r}function Zr(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 cy(n,r,l,u,f,g,w){if(l)return r.flags&256?(r.flags&=-257,u=Ol(Error(s(422))),Zr(n,r,w,u)):r.memoizedState!==null?(r.child=n.child,r.flags|=128,null):(g=u.fallback,f=r.mode,u=fo({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 Zr(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),Zr(n,r,w,u)}if(N=(w&n.childLanes)!==0,vt||N){if(u=et,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,pn(n,f),Kt(u,n,f,-1))}return sc(),u=Ol(Error(s(421))),Zr(n,r,w,u)}return f.data==="$?"?(r.flags|=128,r.child=n.child,r=jy.bind(null,n),f._reactRetry=r,null):(n=g.treeContext,Ct=An(f.nextSibling),bt=r,Oe=!0,Ft=null,n!==null&&(Et[At++]=fn,Et[At++]=mn,Et[At++]=Zn,fn=n.id,mn=n.overflow,Zn=r),r=Fl(r,u.children),r.flags|=4096,r)}function nf(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 sf(n,r,l){var u=r.pendingProps,f=u.revealOrder,g=u.tail;if(dt(n,r,u.children,l),u=Pe.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&&nf(n,l,r);else if(n.tag===19)nf(n,l,r);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===r)break e;for(;n.sibling===null;){if(n.return===null||n.return===r)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}u&=1}if(Ee(Pe,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&&Vr(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&&Vr(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 eo(n,r){(r.mode&1)===0&&n!==null&&(n.alternate=null,r.alternate=null,r.flags|=2)}function vn(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=Fn(n,n.pendingProps),r.child=l,l.return=r;n.sibling!==null;)n=n.sibling,l=l.sibling=Fn(n,n.pendingProps),l.return=r;l.sibling=null}return r.child}function uy(n,r,l){switch(r.tag){case 3:Zh(r),Es();break;case 5:vh(r);break;case 1:gt(r.type)&&Pr(r);break;case 4:xl(r,r.stateNode.containerInfo);break;case 10:var u=r.type._context,f=r.memoizedProps.value;Ee(Ur,u._currentValue),u._currentValue=f;break;case 13:if(u=r.memoizedState,u!==null)return u.dehydrated!==null?(Ee(Pe,Pe.current&1),r.flags|=128,null):(l&r.child.childLanes)!==0?tf(n,r,l):(Ee(Pe,Pe.current&1),n=vn(n,r,l),n!==null?n.sibling:null);Ee(Pe,Pe.current&1);break;case 19:if(u=(l&r.childLanes)!==0,(n.flags&128)!==0){if(u)return sf(n,r,l);r.flags|=128}if(f=r.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),Ee(Pe,Pe.current),u)break;return null;case 22:case 23:return r.lanes=0,Yh(n,r,l)}return vn(n,r,l)}var rf,Wl,of,af;rf=function(n,r){for(var l=r.child;l!==null;){if(l.tag===5||l.tag===6)n.appendChild(l.stateNode);else if(l.tag!==4&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===r)break;for(;l.sibling===null;){if(l.return===null||l.return===r)return;l=l.return}l.sibling.return=l.return,l=l.sibling}},Wl=function(){},of=function(n,r,l,u){var f=n.memoizedProps;if(f!==u){n=r.stateNode,ns(Xt.current);var g=null;switch(l){case"input":f=ka(n,f),u=ka(n,u),g=[];break;case"select":f=F({},f,{value:void 0}),u=F({},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=Rr)}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"&&Re("scroll",n),g||N===$||(g=[])):(g=g||[]).push(L,$))}l&&(g=g||[]).push("style",l);var L=g;(r.updateQueue=L)&&(r.flags|=4)}},af=function(n,r,l,u){l!==u&&(r.flags|=4)};function zi(n,r){if(!Oe)switch(n.tailMode){case"hidden":r=n.tail;for(var l=null;r!==null;)r.alternate!==null&&(l=r),r=r.sibling;l===null?n.tail=null:l.sibling=null;break;case"collapsed":l=n.tail;for(var 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 at(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 dy(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 at(r),null;case 1:return gt(r.type)&&Or(),at(r),null;case 3:return u=r.stateNode,Rs(),Le(pt),Le(rt),Nl(),u.pendingContext&&(u.context=u.pendingContext,u.pendingContext=null),(n===null||n.child===null)&&(Br(r)?r.flags|=4:n===null||n.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,Ft!==null&&(ec(Ft),Ft=null))),Wl(n,r),at(r),null;case 5:jl(r);var f=ns(Li.current);if(l=r.type,n!==null&&r.stateNode!=null)of(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 at(r),null}if(n=ns(Xt.current),Br(r)){u=r.stateNode,l=r.type;var g=r.memoizedProps;switch(u[Jt]=r,u[Ei]=g,n=(r.mode&1)!==0,l){case"dialog":Re("cancel",u),Re("close",u);break;case"iframe":case"object":case"embed":Re("load",u);break;case"video":case"audio":for(f=0;f<Ci.length;f++)Re(Ci[f],u);break;case"source":Re("error",u);break;case"img":case"image":case"link":Re("error",u),Re("load",u);break;case"details":Re("toggle",u);break;case"input":Bu(u,g),Re("invalid",u);break;case"select":u._wrapperState={wasMultiple:!!g.multiple},Re("invalid",u);break;case"textarea":Wu(u,g),Re("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&&Mr(u.textContent,N,n),f=["children",N]):typeof N=="number"&&u.textContent!==""+N&&(g.suppressHydrationWarning!==!0&&Mr(u.textContent,N,n),f=["children",""+N]):a.hasOwnProperty(w)&&N!=null&&w==="onScroll"&&Re("scroll",u)}switch(l){case"input":Sn(u),Uu(u,g,!0);break;case"textarea":Sn(u),Ku(u);break;case"select":case"option":break;default:typeof g.onClick=="function"&&(u.onclick=Rr)}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=Vu(l)),n==="http://www.w3.org/1999/xhtml"?l==="script"?(n=w.createElement("div"),n.innerHTML="<script><\/script>",n=n.removeChild(n.firstChild)):typeof 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[Jt]=r,n[Ei]=u,rf(n,r,!1,!1),r.stateNode=n;e:{switch(w=Na(l,u),l){case"dialog":Re("cancel",n),Re("close",n),f=u;break;case"iframe":case"object":case"embed":Re("load",n),f=u;break;case"video":case"audio":for(f=0;f<Ci.length;f++)Re(Ci[f],n);f=u;break;case"source":Re("error",n),f=u;break;case"img":case"image":case"link":Re("error",n),Re("load",n),f=u;break;case"details":Re("toggle",n),f=u;break;case"input":Bu(n,u),f=ka(n,u),Re("invalid",n);break;case"option":f=u;break;case"select":n._wrapperState={wasMultiple:!!u.multiple},f=F({},u,{value:void 0}),Re("invalid",n);break;case"textarea":Wu(n,u),f=xa(n,u),Re("invalid",n);break;default:f=u}Sa(l,f),N=f;for(g in N)if(N.hasOwnProperty(g)){var $=N[g];g==="style"?Qu(n,$):g==="dangerouslySetInnerHTML"?($=$?$.__html:void 0,$!=null&&Gu(n,$)):g==="children"?typeof $=="string"?(l!=="textarea"||$!=="")&&ai(n,$):typeof $=="number"&&ai(n,""+$):g!=="suppressContentEditableWarning"&&g!=="suppressHydrationWarning"&&g!=="autoFocus"&&(a.hasOwnProperty(g)?$!=null&&g==="onScroll"&&Re("scroll",n):$!=null&&R(n,g,$,w))}switch(l){case"input":Sn(n),Uu(n,u,!1);break;case"textarea":Sn(n),Ku(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=Rr)}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 at(r),null;case 6:if(n&&r.stateNode!=null)af(n,r,n.memoizedProps,u);else{if(typeof u!="string"&&r.stateNode===null)throw Error(s(166));if(l=ns(Li.current),ns(Xt.current),Br(r)){if(u=r.stateNode,l=r.memoizedProps,u[Jt]=r,(g=u.nodeValue!==l)&&(n=bt,n!==null))switch(n.tag){case 3:Mr(u.nodeValue,l,(n.mode&1)!==0);break;case 5:n.memoizedProps.suppressHydrationWarning!==!0&&Mr(u.nodeValue,l,(n.mode&1)!==0)}g&&(r.flags|=4)}else u=(l.nodeType===9?l:l.ownerDocument).createTextNode(u),u[Jt]=r,r.stateNode=u}return at(r),null;case 13:if(Le(Pe),u=r.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(Oe&&Ct!==null&&(r.mode&1)!==0&&(r.flags&128)===0)ch(),Es(),r.flags|=98560,g=!1;else if(g=Br(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[Jt]=r}else Es(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;at(r),g=!1}else Ft!==null&&(ec(Ft),Ft=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||(Pe.current&1)!==0?Je===0&&(Je=3):sc())),r.updateQueue!==null&&(r.flags|=4),at(r),null);case 4:return Rs(),Wl(n,r),n===null&&$i(r.stateNode.containerInfo),at(r),null;case 10:return vl(r.type._context),at(r),null;case 17:return gt(r.type)&&Or(),at(r),null;case 19:if(Le(Pe),g=r.memoizedState,g===null)return at(r),null;if(u=(r.flags&128)!==0,w=g.rendering,w===null)if(u)zi(g,!1);else{if(Je!==0||n!==null&&(n.flags&128)!==0)for(n=r.child;n!==null;){if(w=Vr(n),w!==null){for(r.flags|=128,zi(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(Pe,Pe.current&1|2),r.child}n=n.sibling}g.tail!==null&&We()>_s&&(r.flags|=128,u=!0,zi(g,!1),r.lanes=4194304)}else{if(!u)if(n=Vr(w),n!==null){if(r.flags|=128,u=!0,l=n.updateQueue,l!==null&&(r.updateQueue=l,r.flags|=4),zi(g,!0),g.tail===null&&g.tailMode==="hidden"&&!w.alternate&&!Oe)return at(r),null}else 2*We()-g.renderingStartTime>_s&&l!==1073741824&&(r.flags|=128,u=!0,zi(g,!1),r.lanes=4194304);g.isBackwards?(w.sibling=r.child,r.child=w):(l=g.last,l!==null?l.sibling=w:r.child=w,g.last=w)}return g.tail!==null?(r=g.tail,g.rendering=r,g.tail=r.sibling,g.renderingStartTime=We(),r.sibling=null,l=Pe.current,Ee(Pe,u?l&1|2:l&1),r):(at(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?($t&1073741824)!==0&&(at(r),r.subtreeFlags&6&&(r.flags|=8192)):at(r),null;case 24:return null;case 25:return null}throw Error(s(156,r.tag))}function hy(n,r){switch(dl(r),r.tag){case 1:return gt(r.type)&&Or(),n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 3:return Rs(),Le(pt),Le(rt),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(Le(Pe),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 Le(Pe),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 to=!1,lt=!1,fy=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 lf=!1;function my(n,r){if(nl=xr,n=zd(),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,U=0,W=n,B=null;t:for(;;){for(var ee;W!==l||f!==0&&W.nodeType!==3||(N=w+f),W!==g||u!==0&&W.nodeType!==3||($=w+u),W.nodeType===3&&(w+=W.nodeValue.length),(ee=W.firstChild)!==null;)B=W,W=ee;for(;;){if(W===n)break t;if(B===l&&++L===f&&(N=w),B===g&&++U===u&&($=w),(ee=W.nextSibling)!==null)break;W=B,B=W.parentNode}W=ee}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},xr=!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 ie=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(ie!==null){var oe=ie.memoizedProps,He=ie.memoizedState,A=r.stateNode,E=A.getSnapshotBeforeUpdate(r.elementType===r.type?oe:Ut(r.type,oe),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(G){Fe(r,r.return,G)}if(n=r.sibling,n!==null){n.return=r.return,ne=n;break}ne=r.return}return ie=lf,lf=!1,ie}function Bi(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 no(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 cf(n){var r=n.alternate;r!==null&&(n.alternate=null,cf(r)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(r=n.stateNode,r!==null&&(delete r[Jt],delete r[Ei],delete r[al],delete r[Yk],delete r[Jk])),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}function uf(n){return n.tag===5||n.tag===3||n.tag===4}function df(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||uf(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function 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=Rr));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 st=null,Wt=!1;function Pn(n,r,l){for(l=l.child;l!==null;)hf(n,r,l),l=l.sibling}function hf(n,r,l){if(Yt&&typeof Yt.onCommitFiberUnmount=="function")try{Yt.onCommitFiberUnmount(pr,l)}catch{}switch(l.tag){case 5:lt||Os(l,r);case 6:var u=st,f=Wt;st=null,Pn(n,r,l),st=u,Wt=f,st!==null&&(Wt?(n=st,l=l.stateNode,n.nodeType===8?n.parentNode.removeChild(l):n.removeChild(l)):st.removeChild(l.stateNode));break;case 18:st!==null&&(Wt?(n=st,l=l.stateNode,n.nodeType===8?ol(n.parentNode,l):n.nodeType===1&&ol(n,l),ki(n)):ol(st,l.stateNode));break;case 4:u=st,f=Wt,st=l.stateNode.containerInfo,Wt=!0,Pn(n,r,l),st=u,Wt=f;break;case 0:case 11:case 14:case 15:if(!lt&&(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)}Pn(n,r,l);break;case 1:if(!lt&&(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)}Pn(n,r,l);break;case 21:Pn(n,r,l);break;case 22:l.mode&1?(lt=(u=lt)||l.memoizedState!==null,Pn(n,r,l),lt=u):Pn(n,r,l);break;default:Pn(n,r,l)}}function ff(n){var r=n.updateQueue;if(r!==null){n.updateQueue=null;var l=n.stateNode;l===null&&(l=n.stateNode=new fy),r.forEach(function(u){var f=Sy.bind(null,n,u);l.has(u)||(l.add(u),u.then(f,f))})}}function Ht(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:st=N.stateNode,Wt=!1;break e;case 3:st=N.stateNode.containerInfo,Wt=!0;break e;case 4:st=N.stateNode.containerInfo,Wt=!0;break e}N=N.return}if(st===null)throw Error(s(160));hf(g,w,f),st=null,Wt=!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;)mf(r,n),r=r.sibling}function mf(n,r){var l=n.alternate,u=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:if(Ht(r,n),en(n),u&4){try{Bi(3,n,n.return),no(3,n)}catch(oe){Fe(n,n.return,oe)}try{Bi(5,n,n.return)}catch(oe){Fe(n,n.return,oe)}}break;case 1:Ht(r,n),en(n),u&512&&l!==null&&Os(l,l.return);break;case 5:if(Ht(r,n),en(n),u&512&&l!==null&&Os(l,l.return),n.flags&32){var f=n.stateNode;try{ai(f,"")}catch(oe){Fe(n,n.return,oe)}}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&&Fu(f,g),Na(N,w);var L=Na(N,g);for(w=0;w<$.length;w+=2){var U=$[w],W=$[w+1];U==="style"?Qu(f,W):U==="dangerouslySetInnerHTML"?Gu(f,W):U==="children"?ai(f,W):R(f,U,W,L)}switch(N){case"input":ya(f,g);break;case"textarea":Hu(f,g);break;case"select":var B=f._wrapperState.wasMultiple;f._wrapperState.wasMultiple=!!g.multiple;var ee=g.value;ee!=null?ms(f,!!g.multiple,ee,!1):B!==!!g.multiple&&(g.defaultValue!=null?ms(f,!!g.multiple,g.defaultValue,!0):ms(f,!!g.multiple,g.multiple?[]:"",!1))}f[Ei]=g}catch(oe){Fe(n,n.return,oe)}}break;case 6:if(Ht(r,n),en(n),u&4){if(n.stateNode===null)throw Error(s(162));f=n.stateNode,g=n.memoizedProps;try{f.nodeValue=g}catch(oe){Fe(n,n.return,oe)}}break;case 3:if(Ht(r,n),en(n),u&4&&l!==null&&l.memoizedState.isDehydrated)try{ki(r.containerInfo)}catch(oe){Fe(n,n.return,oe)}break;case 4:Ht(r,n),en(n);break;case 13:Ht(r,n),en(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&&ff(n);break;case 22:if(U=l!==null&&l.memoizedState!==null,n.mode&1?(lt=(L=lt)||U,Ht(r,n),lt=L):Ht(r,n),en(n),u&8192){if(L=n.memoizedState!==null,(n.stateNode.isHidden=L)&&!U&&(n.mode&1)!==0)for(ne=n,U=n.child;U!==null;){for(W=ne=U;ne!==null;){switch(B=ne,ee=B.child,B.tag){case 0:case 11:case 14:case 15:Bi(4,B,B.return);break;case 1:Os(B,B.return);var ie=B.stateNode;if(typeof ie.componentWillUnmount=="function"){u=B,l=B.return;try{r=u,ie.props=r.memoizedProps,ie.state=r.memoizedState,ie.componentWillUnmount()}catch(oe){Fe(u,l,oe)}}break;case 5:Os(B,B.return);break;case 22:if(B.memoizedState!==null){vf(W);continue}}ee!==null?(ee.return=B,ne=ee):vf(W)}U=U.sibling}e:for(U=null,W=n;;){if(W.tag===5){if(U===null){U=W;try{f=W.stateNode,L?(g=f.style,typeof g.setProperty=="function"?g.setProperty("display","none","important"):g.display="none"):(N=W.stateNode,$=W.memoizedProps.style,w=$!=null&&$.hasOwnProperty("display")?$.display:null,N.style.display=qu("display",w))}catch(oe){Fe(n,n.return,oe)}}}else if(W.tag===6){if(U===null)try{W.stateNode.nodeValue=L?"":W.memoizedProps}catch(oe){Fe(n,n.return,oe)}}else if((W.tag!==22&&W.tag!==23||W.memoizedState===null||W===n)&&W.child!==null){W.child.return=W,W=W.child;continue}if(W===n)break e;for(;W.sibling===null;){if(W.return===null||W.return===n)break e;U===W&&(U=null),W=W.return}U===W&&(U=null),W.sibling.return=W.return,W=W.sibling}}break;case 19:Ht(r,n),en(n),u&4&&ff(n);break;case 21:break;default:Ht(r,n),en(n)}}function en(n){var r=n.flags;if(r&2){try{e:{for(var l=n.return;l!==null;){if(uf(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&&(ai(f,""),u.flags&=-33);var g=df(n);Gl(n,g,f);break;case 3:case 4:var w=u.stateNode.containerInfo,N=df(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 py(n,r,l){ne=n,pf(n)}function pf(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||to;if(!w){var N=f.alternate,$=N!==null&&N.memoizedState!==null||lt;N=to;var L=lt;if(to=w,(lt=$)&&!L)for(ne=f;ne!==null;)w=ne,$=w.child,w.tag===22&&w.memoizedState!==null?kf(f):$!==null?($.return=w,ne=$):kf(f);for(;g!==null;)ne=g,pf(g),g=g.sibling;ne=f,to=N,lt=L}gf(n)}else(f.subtreeFlags&8772)!==0&&g!==null?(g.return=f,ne=g):gf(n)}}function gf(n){for(;ne!==null;){var r=ne;if((r.flags&8772)!==0){var l=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:lt||no(5,r);break;case 1:var u=r.stateNode;if(r.flags&4&&!lt)if(l===null)u.componentDidMount();else{var f=r.elementType===r.type?l.memoizedProps:Ut(r.type,l.memoizedProps);u.componentDidUpdate(f,l.memoizedState,u.__reactInternalSnapshotBeforeUpdate)}var g=r.updateQueue;g!==null&&gh(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}gh(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 U=L.memoizedState;if(U!==null){var W=U.dehydrated;W!==null&&ki(W)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(s(163))}lt||r.flags&512&&Kl(r)}catch(B){Fe(r,r.return,B)}}if(r===n){ne=null;break}if(l=r.sibling,l!==null){l.return=r.return,ne=l;break}ne=r.return}}function vf(n){for(;ne!==null;){var r=ne;if(r===n){ne=null;break}var l=r.sibling;if(l!==null){l.return=r.return,ne=l;break}ne=r.return}}function kf(n){for(;ne!==null;){var r=ne;try{switch(r.tag){case 0:case 11:case 15:var l=r.return;try{no(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 gy=Math.ceil,so=z.ReactCurrentDispatcher,ql=z.ReactCurrentOwner,Rt=z.ReactCurrentBatchConfig,Ne=0,et=null,Ge=null,it=0,$t=0,Ps=In(0),Je=0,Fi=null,is=0,io=0,Ql=0,Ui=null,kt=null,Yl=0,_s=1/0,kn=null,ro=!1,Jl=null,_n=null,oo=!1,Dn=null,ao=0,Wi=0,Xl=null,lo=-1,co=0;function ht(){return(Ne&6)!==0?We():lo!==-1?lo:lo=We()}function zn(n){return(n.mode&1)===0?1:(Ne&2)!==0&&it!==0?it&-it:Zk.transition!==null?(co===0&&(co=ud()),co):(n=Te,n!==0||(n=window.event,n=n===void 0?16:yd(n.type)),n)}function Kt(n,r,l,u){if(50<Wi)throw Wi=0,Xl=null,Error(s(185));fi(n,l,u),((Ne&2)===0||n!==et)&&(n===et&&((Ne&2)===0&&(io|=l),Je===4&&Bn(n,it)),yt(n,u),l===1&&Ne===0&&(r.mode&1)===0&&(_s=We()+500,_r&&Rn()))}function yt(n,r){var l=n.callbackNode;Zv(n,r);var u=kr(n,n===et?it:0);if(u===0)l!==null&&ad(l),n.callbackNode=null,n.callbackPriority=0;else if(r=u&-u,n.callbackPriority!==r){if(l!=null&&ad(l),r===1)n.tag===0?Xk(wf.bind(null,n)):ih(wf.bind(null,n)),qk(function(){(Ne&6)===0&&Rn()}),l=null;else{switch(dd(u)){case 1:l=Ia;break;case 4:l=ld;break;case 16:l=mr;break;case 536870912:l=cd;break;default:l=mr}l=Tf(l,yf.bind(null,n))}n.callbackPriority=r,n.callbackNode=l}}function yf(n,r){if(lo=-1,co=0,(Ne&6)!==0)throw Error(s(327));var l=n.callbackNode;if(Ds()&&n.callbackNode!==l)return null;var u=kr(n,n===et?it:0);if(u===0)return null;if((u&30)!==0||(u&n.expiredLanes)!==0||r)r=uo(n,u);else{r=u;var f=Ne;Ne|=2;var g=jf();(et!==n||it!==r)&&(kn=null,_s=We()+500,os(n,r));do try{yy();break}catch(N){xf(n,N)}while(!0);gl(),so.current=g,Ne=f,Ge!==null?r=0:(et=null,it=0,r=Je)}if(r!==0){if(r===2&&(f=Ma(n),f!==0&&(u=f,r=Zl(n,f))),r===1)throw l=Fi,os(n,0),Bn(n,u),yt(n,We()),l;if(r===6)Bn(n,u);else{if(f=n.current.alternate,(u&30)===0&&!vy(f)&&(r=uo(n,u),r===2&&(g=Ma(n),g!==0&&(u=g,r=Zl(n,g))),r===1))throw l=Fi,os(n,0),Bn(n,u),yt(n,We()),l;switch(n.finishedWork=f,n.finishedLanes=u,r){case 0:case 1:throw Error(s(345));case 2:as(n,kt,kn);break;case 3:if(Bn(n,u),(u&130023424)===u&&(r=Yl+500-We(),10<r)){if(kr(n,0)!==0)break;if(f=n.suspendedLanes,(f&u)!==u){ht(),n.pingedLanes|=n.suspendedLanes&f;break}n.timeoutHandle=rl(as.bind(null,n,kt,kn),r);break}as(n,kt,kn);break;case 4:if(Bn(n,u),(u&4194240)===u)break;for(r=n.eventTimes,f=-1;0<u;){var w=31-zt(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*gy(u/1960))-u,10<u){n.timeoutHandle=rl(as.bind(null,n,kt,kn),u);break}as(n,kt,kn);break;case 5:as(n,kt,kn);break;default:throw Error(s(329))}}}return yt(n,We()),n.callbackNode===l?yf.bind(null,n):null}function Zl(n,r){var l=Ui;return n.current.memoizedState.isDehydrated&&(os(n,r).flags|=256),n=uo(n,r),n!==2&&(r=kt,kt=l,r!==null&&ec(r)),n}function ec(n){kt===null?kt=n:kt.push.apply(kt,n)}function vy(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(!Bt(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 Bn(n,r){for(r&=~Ql,r&=~io,n.suspendedLanes|=r,n.pingedLanes&=~r,n=n.expirationTimes;0<r;){var l=31-zt(r),u=1<<l;n[l]=-1,r&=~u}}function wf(n){if((Ne&6)!==0)throw Error(s(327));Ds();var r=kr(n,0);if((r&1)===0)return yt(n,We()),null;var l=uo(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=Fi,os(n,0),Bn(n,r),yt(n,We()),l;if(l===6)throw Error(s(345));return n.finishedWork=n.current.alternate,n.finishedLanes=r,as(n,kt,kn),yt(n,We()),null}function tc(n,r){var l=Ne;Ne|=1;try{return n(r)}finally{Ne=l,Ne===0&&(_s=We()+500,_r&&Rn())}}function rs(n){Dn!==null&&Dn.tag===0&&(Ne&6)===0&&Ds();var r=Ne;Ne|=1;var l=Rt.transition,u=Te;try{if(Rt.transition=null,Te=1,n)return n()}finally{Te=u,Rt.transition=l,Ne=r,(Ne&6)===0&&Rn()}}function nc(){$t=Ps.current,Le(Ps)}function os(n,r){n.finishedWork=null,n.finishedLanes=0;var l=n.timeoutHandle;if(l!==-1&&(n.timeoutHandle=-1,Gk(l)),Ge!==null)for(l=Ge.return;l!==null;){var u=l;switch(dl(u),u.tag){case 1:u=u.type.childContextTypes,u!=null&&Or();break;case 3:Rs(),Le(pt),Le(rt),Nl();break;case 5:jl(u);break;case 4:Rs();break;case 13:Le(Pe);break;case 19:Le(Pe);break;case 10:vl(u.type._context);break;case 22:case 23:nc()}l=l.return}if(et=n,Ge=n=Fn(n.current,null),it=$t=r,Je=0,Fi=null,Ql=io=is=0,kt=Ui=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 xf(n,r){do{var l=Ge;try{if(gl(),Gr.current=Jr,qr){for(var u=_e.memoizedState;u!==null;){var f=u.queue;f!==null&&(f.pending=null),u=u.next}qr=!1}if(ss=0,Ze=Ye=_e=null,Oi=!1,Pi=0,ql.current=null,l===null||l.return===null){Je=1,Fi=r,Ge=null;break}e:{var g=n,w=l.return,N=l,$=r;if(r=it,N.flags|=32768,$!==null&&typeof $=="object"&&typeof $.then=="function"){var L=$,U=N,W=U.tag;if((U.mode&1)===0&&(W===0||W===11||W===15)){var B=U.alternate;B?(U.updateQueue=B.updateQueue,U.memoizedState=B.memoizedState,U.lanes=B.lanes):(U.updateQueue=null,U.memoizedState=null)}var ee=Kh(w);if(ee!==null){ee.flags&=-257,Vh(ee,w,N,g,r),ee.mode&1&&Hh(g,L,r),r=ee,$=L;var ie=r.updateQueue;if(ie===null){var oe=new Set;oe.add($),r.updateQueue=oe}else ie.add($);break e}else{if((r&1)===0){Hh(g,L,r),sc();break e}$=Error(s(426))}}else if(Oe&&N.mode&1){var He=Kh(w);if(He!==null){(He.flags&65536)===0&&(He.flags|=256),Vh(He,w,N,g,r),ml(Ls($,N));break e}}g=$=Ls($,N),Je!==4&&(Je=2),Ui===null?Ui=[g]:Ui.push(g),g=w;do{switch(g.tag){case 3:g.flags|=65536,r&=-r,g.lanes|=r;var A=Uh(g,$,r);ph(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"&&(_n===null||!_n.has(M)))){g.flags|=65536,r&=-r,g.lanes|=r;var G=Wh(g,N,r);ph(g,G);break e}}g=g.return}while(g!==null)}Nf(l)}catch(ae){r=ae,Ge===l&&l!==null&&(Ge=l=l.return);continue}break}while(!0)}function jf(){var n=so.current;return so.current=Jr,n===null?Jr:n}function sc(){(Je===0||Je===3||Je===2)&&(Je=4),et===null||(is&268435455)===0&&(io&268435455)===0||Bn(et,it)}function uo(n,r){var l=Ne;Ne|=2;var u=jf();(et!==n||it!==r)&&(kn=null,os(n,r));do try{ky();break}catch(f){xf(n,f)}while(!0);if(gl(),Ne=l,so.current=u,Ge!==null)throw Error(s(261));return et=null,it=0,Je}function ky(){for(;Ge!==null;)Sf(Ge)}function yy(){for(;Ge!==null&&!Hv();)Sf(Ge)}function Sf(n){var r=$f(n.alternate,n,$t);n.memoizedProps=n.pendingProps,r===null?Nf(n):Ge=r,ql.current=null}function Nf(n){var r=n;do{var l=r.alternate;if(n=r.return,(r.flags&32768)===0){if(l=dy(l,r,$t),l!==null){Ge=l;return}}else{if(l=hy(l,r),l!==null){l.flags&=32767,Ge=l;return}if(n!==null)n.flags|=32768,n.subtreeFlags=0,n.deletions=null;else{Je=6,Ge=null;return}}if(r=r.sibling,r!==null){Ge=r;return}Ge=r=n}while(r!==null);Je===0&&(Je=5)}function as(n,r,l){var u=Te,f=Rt.transition;try{Rt.transition=null,Te=1,wy(n,r,l,u)}finally{Rt.transition=f,Te=u}return null}function wy(n,r,l,u){do Ds();while(Dn!==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(ek(n,g),n===et&&(Ge=et=null,it=0),(l.subtreeFlags&2064)===0&&(l.flags&2064)===0||oo||(oo=!0,Tf(mr,function(){return Ds(),null})),g=(l.flags&15990)!==0,(l.subtreeFlags&15990)!==0||g){g=Rt.transition,Rt.transition=null;var w=Te;Te=1;var N=Ne;Ne|=4,ql.current=null,my(n,l),mf(l,n),Bk(sl),xr=!!nl,sl=nl=null,n.current=l,py(l),Kv(),Ne=N,Te=w,Rt.transition=g}else n.current=l;if(oo&&(oo=!1,Dn=n,ao=f),g=n.pendingLanes,g===0&&(_n=null),qv(l.stateNode),yt(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(ro)throw ro=!1,n=Jl,Jl=null,n;return(ao&1)!==0&&n.tag!==0&&Ds(),g=n.pendingLanes,(g&1)!==0?n===Xl?Wi++:(Wi=0,Xl=n):Wi=0,Rn(),null}function Ds(){if(Dn!==null){var n=dd(ao),r=Rt.transition,l=Te;try{if(Rt.transition=null,Te=16>n?16:n,Dn===null)var u=!1;else{if(n=Dn,Dn=null,ao=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 U=ne;switch(U.tag){case 0:case 11:case 15:Bi(8,U,g)}var W=U.child;if(W!==null)W.return=U,ne=W;else for(;ne!==null;){U=ne;var B=U.sibling,ee=U.return;if(cf(U),U===L){ne=null;break}if(B!==null){B.return=ee,ne=B;break}ne=ee}}}var ie=g.alternate;if(ie!==null){var oe=ie.child;if(oe!==null){ie.child=null;do{var He=oe.sibling;oe.sibling=null,oe=He}while(oe!==null)}}ne=g}}if((g.subtreeFlags&2064)!==0&&w!==null)w.return=g,ne=w;else e:for(;ne!==null;){if(g=ne,(g.flags&2048)!==0)switch(g.tag){case 0:case 11:case 15:Bi(9,g,g.return)}var 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:no(9,N)}}catch(ae){Fe(N,N.return,ae)}if(N===w){ne=null;break e}var G=N.sibling;if(G!==null){G.return=N.return,ne=G;break e}ne=N.return}}if(Ne=f,Rn(),Yt&&typeof Yt.onPostCommitFiberRoot=="function")try{Yt.onPostCommitFiberRoot(pr,n)}catch{}u=!0}return u}finally{Te=l,Rt.transition=r}}return!1}function bf(n,r,l){r=Ls(l,r),r=Uh(n,r,1),n=On(n,r,1),r=ht(),n!==null&&(fi(n,1,r),yt(n,r))}function Fe(n,r,l){if(n.tag===3)bf(n,n,l);else for(;r!==null;){if(r.tag===3){bf(r,n,l);break}else if(r.tag===1){var u=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(_n===null||!_n.has(u))){n=Ls(l,n),n=Wh(r,n,1),r=On(r,n,1),n=ht(),r!==null&&(fi(r,1,n),yt(r,n));break}}r=r.return}}function xy(n,r,l){var u=n.pingCache;u!==null&&u.delete(r),r=ht(),n.pingedLanes|=n.suspendedLanes&l,et===n&&(it&l)===l&&(Je===4||Je===3&&(it&130023424)===it&&500>We()-Yl?os(n,0):Ql|=l),yt(n,r)}function Cf(n,r){r===0&&((n.mode&1)===0?r=1:(r=vr,vr<<=1,(vr&130023424)===0&&(vr=4194304)));var l=ht();n=pn(n,r),n!==null&&(fi(n,r,l),yt(n,l))}function jy(n){var r=n.memoizedState,l=0;r!==null&&(l=r.retryLane),Cf(n,l)}function Sy(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),Cf(n,l)}var $f;$f=function(n,r,l){if(n!==null)if(n.memoizedProps!==r.pendingProps||pt.current)vt=!0;else{if((n.lanes&l)===0&&(r.flags&128)===0)return vt=!1,uy(n,r,l);vt=(n.flags&131072)!==0}else vt=!1,Oe&&(r.flags&1048576)!==0&&rh(r,zr,r.index);switch(r.lanes=0,r.tag){case 2:var u=r.type;eo(n,r),n=r.pendingProps;var f=Cs(r,rt.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,gt(u)?(g=!0,Pr(r)):g=!1,r.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,wl(r),f.updater=Xr,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),dt(null,r,f,l),r=r.child),r;case 16:u=r.elementType;e:{switch(eo(n,r),n=r.pendingProps,f=u._init,u=f(u._payload),r.type=u,f=r.tag=by(u),n=Ut(u,n),f){case 0:r=_l(null,r,u,n,l);break e;case 1:r=Xh(null,r,u,n,l);break e;case 11:r=Gh(null,r,u,n,l);break e;case 14:r=qh(null,r,u,Ut(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:Ut(u,f),_l(n,r,u,f,l);case 1:return u=r.type,f=r.pendingProps,f=r.elementType===u?f:Ut(u,f),Xh(n,r,u,f,l);case 3:e:{if(Zh(r),n===null)throw Error(s(387));u=r.pendingProps,g=r.memoizedState,f=g.element,mh(n,r),Kr(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=ef(n,r,u,l,f);break e}else if(u!==f){f=Ls(Error(s(424)),r),r=ef(n,r,u,l,f);break e}else for(Ct=An(r.stateNode.containerInfo.firstChild),bt=r,Oe=!0,Ft=null,l=hh(r,null,u,l),r.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(Es(),u===f){r=vn(n,r,l);break e}dt(n,r,u,l)}r=r.child}return r;case 5:return vh(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),Jh(n,r),dt(n,r,w,l),r.child;case 6:return n===null&&fl(r),null;case 13:return tf(n,r,l);case 4:return xl(r,r.stateNode.containerInfo),u=r.pendingProps,n===null?r.child=As(r,null,u,l):dt(n,r,u,l),r.child;case 11:return u=r.type,f=r.pendingProps,f=r.elementType===u?f:Ut(u,f),Gh(n,r,u,f,l);case 7:return dt(n,r,r.pendingProps,l),r.child;case 8:return dt(n,r,r.pendingProps.children,l),r.child;case 12:return dt(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(Ur,u._currentValue),u._currentValue=w,g!==null)if(Bt(g.value,w)){if(g.children===f.children&&!pt.current){r=vn(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){$=gn(-1,l&-l),$.tag=2;var L=g.updateQueue;if(L!==null){L=L.shared;var U=L.pending;U===null?$.next=$:($.next=U.next,U.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}dt(n,r,f.children,l),r=r.child}return r;case 9:return f=r.type,u=r.pendingProps.children,Ms(r,l),f=It(f),u=u(f),r.flags|=1,dt(n,r,u,l),r.child;case 14:return u=r.type,f=Ut(u,r.pendingProps),f=Ut(u.type,f),qh(n,r,u,f,l);case 15:return Qh(n,r,r.type,r.pendingProps,l);case 17:return u=r.type,f=r.pendingProps,f=r.elementType===u?f:Ut(u,f),eo(n,r),r.tag=1,gt(u)?(n=!0,Pr(r)):n=!1,Ms(r,l),Bh(r,u,f),Ll(r,u,f,l),Dl(null,r,u,!0,n,l);case 19:return sf(n,r,l);case 22:return Yh(n,r,l)}throw Error(s(156,r.tag))};function Tf(n,r){return od(n,r)}function Ny(n,r,l,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 Lt(n,r,l,u){return new Ny(n,r,l,u)}function ic(n){return n=n.prototype,!(!n||!n.isReactComponent)}function by(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 Fn(n,r){var l=n.alternate;return l===null?(l=Lt(n.tag,r,n.key,n.mode),l.elementType=n.elementType,l.type=n.type,l.stateNode=n.stateNode,l.alternate=n,n.alternate=l):(l.pendingProps=r,l.type=n.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=n.flags&14680064,l.childLanes=n.childLanes,l.lanes=n.lanes,l.child=n.child,l.memoizedProps=n.memoizedProps,l.memoizedState=n.memoizedState,l.updateQueue=n.updateQueue,r=n.dependencies,l.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},l.sibling=n.sibling,l.index=n.index,l.ref=n.ref,l}function ho(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 H:return ls(l.children,f,g,r);case re:w=8,f|=8;break;case Q:return n=Lt(12,l,r,f|2),n.elementType=Q,n.lanes=g,n;case se:return n=Lt(13,l,r,f),n.elementType=se,n.lanes=g,n;case D:return n=Lt(19,l,r,f),n.elementType=D,n.lanes=g,n;case ce:return fo(l,f,g,r);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case ve:w=10;break e;case ze:w=9;break e;case $e:w=11;break e;case J:w=14;break e;case X:w=16,u=null;break e}throw Error(s(130,n==null?n:typeof n,""))}return r=Lt(w,l,r,f),r.elementType=n,r.type=u,r.lanes=g,r}function ls(n,r,l,u){return n=Lt(7,n,u,r),n.lanes=l,n}function fo(n,r,l,u){return n=Lt(22,n,u,r),n.elementType=ce,n.lanes=l,n.stateNode={isHidden:!1},n}function rc(n,r,l){return n=Lt(6,n,null,r),n.lanes=l,n}function oc(n,r,l){return r=Lt(4,n.children!==null?n.children:[],n.key,r),r.lanes=l,r.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},r}function Cy(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 Cy(n,r,l,N,$),r===1?(r=1,g===!0&&(r|=8)):r=0,g=Lt(3,null,null,r),n.current=g,g.stateNode=n,g.memoizedState={element:u,isDehydrated:l,cache:null,transitions:null,pendingSuspenseBoundaries:null},wl(g),n}function $y(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 Ef(n){if(!n)return Mn;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(gt(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(gt(l))return nh(n,l,r)}return r}function Af(n,r,l,u,f,g,w,N,$){return n=ac(l,u,!0,n,f,g,w,N,$),n.context=Ef(null),l=n.current,u=ht(),f=zn(l),g=gn(u,f),g.callback=r??null,On(l,g,f),n.current.lanes=f,fi(n,f,u),yt(n,u),n}function mo(n,r,l,u){var f=r.current,g=ht(),w=zn(f);return l=Ef(l),r.context===null?r.context=l:r.pendingContext=l,r=gn(g,w),r.payload={element:n},u=u===void 0?null:u,u!==null&&(r.callback=u),n=On(f,r,w),n!==null&&(Kt(n,f,w,g),Hr(n,f,w)),w}function po(n){if(n=n.current,!n.child)return null;switch(n.child.tag){case 5:return n.child.stateNode;default:return n.child.stateNode}}function If(n,r){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var l=n.retryLane;n.retryLane=l!==0&&l<r?l:r}}function lc(n,r){If(n,r),(n=n.alternate)&&If(n,r)}function Ty(){return null}var Mf=typeof reportError=="function"?reportError:function(n){console.error(n)};function cc(n){this._internalRoot=n}go.prototype.render=cc.prototype.render=function(n){var r=this._internalRoot;if(r===null)throw Error(s(409));mo(n,r,null,null)},go.prototype.unmount=cc.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var r=n.containerInfo;rs(function(){mo(null,n,null,null)}),r[dn]=null}};function go(n){this._internalRoot=n}go.prototype.unstable_scheduleHydration=function(n){if(n){var r=md();n={blockedOn:null,target:n,priority:r};for(var l=0;l<$n.length&&r!==0&&r<$n[l].priority;l++);$n.splice(l,0,n),l===0&&vd(n)}};function uc(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function vo(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11&&(n.nodeType!==8||n.nodeValue!==" react-mount-point-unstable "))}function Rf(){}function Ey(n,r,l,u,f){if(f){if(typeof u=="function"){var g=u;u=function(){var L=po(w);g.call(L)}}var w=Af(r,u,n,0,null,!1,!1,"",Rf);return n._reactRootContainer=w,n[dn]=w.current,$i(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=po($);N.call(L)}}var $=ac(n,0,!1,null,null,!1,!1,"",Rf);return n._reactRootContainer=$,n[dn]=$.current,$i(n.nodeType===8?n.parentNode:n),rs(function(){mo(r,$,l,u)}),$}function ko(n,r,l,u,f){var g=l._reactRootContainer;if(g){var w=g;if(typeof f=="function"){var N=f;f=function(){var $=po(w);N.call($)}}mo(r,w,n,f)}else w=Ey(l,r,n,f,u);return po(w)}hd=function(n){switch(n.tag){case 3:var r=n.stateNode;if(r.current.memoizedState.isDehydrated){var l=hi(r.pendingLanes);l!==0&&(La(r,l|1),yt(r,We()),(Ne&6)===0&&(_s=We()+500,Rn()))}break;case 13:rs(function(){var u=pn(n,1);if(u!==null){var f=ht();Kt(u,n,1,f)}}),lc(n,1)}},Oa=function(n){if(n.tag===13){var r=pn(n,134217728);if(r!==null){var l=ht();Kt(r,n,134217728,l)}lc(n,134217728)}},fd=function(n){if(n.tag===13){var r=zn(n),l=pn(n,r);if(l!==null){var u=ht();Kt(l,n,r,u)}lc(n,r)}},md=function(){return Te},pd=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=Lr(u);if(!f)throw Error(s(90));ur(u),ya(u,f)}}}break;case"textarea":Hu(n,l);break;case"select":r=l.value,r!=null&&ms(n,!!l.multiple,r,!1)}},Zu=tc,ed=rs;var Ay={usingClientEntryPoint:!1,Events:[Ai,Ns,Lr,Ju,Xu,tc]},Hi={findFiberByHostInstance:Jn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Iy={bundleType:Hi.bundleType,version:Hi.version,rendererPackageName:Hi.rendererPackageName,rendererConfig:Hi.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:z.ReactCurrentDispatcher,findHostInstanceByFiber:function(n){return n=id(n),n===null?null:n.stateNode},findFiberByHostInstance:Hi.findFiberByHostInstance||Ty,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 yo=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!yo.isDisabled&&yo.supportsFiber)try{pr=yo.inject(Iy),Yt=yo}catch{}}return wt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Ay,wt.createPortal=function(n,r){var l=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!uc(r))throw Error(s(200));return $y(n,r,null,l)},wt.createRoot=function(n,r){if(!uc(n))throw Error(s(299));var l=!1,u="",f=Mf;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[dn]=r.current,$i(n.nodeType===8?n.parentNode:n),new cc(r)},wt.findDOMNode=function(n){if(n==null)return null;if(n.nodeType===1)return n;var r=n._reactInternals;if(r===void 0)throw typeof n.render=="function"?Error(s(188)):(n=Object.keys(n).join(","),Error(s(268,n)));return n=id(r),n=n===null?null:n.stateNode,n},wt.flushSync=function(n){return rs(n)},wt.hydrate=function(n,r,l){if(!vo(r))throw Error(s(200));return ko(null,n,r,!0,l)},wt.hydrateRoot=function(n,r,l){if(!uc(n))throw Error(s(405));var u=l!=null&&l.hydratedSources||null,f=!1,g="",w=Mf;if(l!=null&&(l.unstable_strictMode===!0&&(f=!0),l.identifierPrefix!==void 0&&(g=l.identifierPrefix),l.onRecoverableError!==void 0&&(w=l.onRecoverableError)),r=Af(r,null,n,1,l??null,f,!1,g,w),n[dn]=r.current,$i(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 go(r)},wt.render=function(n,r,l){if(!vo(r))throw Error(s(200));return ko(null,n,r,!1,l)},wt.unmountComponentAtNode=function(n){if(!vo(n))throw Error(s(40));return n._reactRootContainer?(rs(function(){ko(null,null,n,!1,function(){n._reactRootContainer=null,n[dn]=null})}),!0):!1},wt.unstable_batchedUpdates=tc,wt.unstable_renderSubtreeIntoContainer=function(n,r,l,u){if(!vo(l))throw Error(s(200));if(n==null||n._reactInternals===void 0)throw Error(s(38));return ko(n,r,l,!1,u)},wt.version="18.3.1-next-f1338f8080-20240426",wt}var Ff;function pp(){if(Ff)return fc.exports;Ff=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),fc.exports=By(),fc.exports}var Uf;function Fy(){if(Uf)return wo;Uf=1;var e=pp();return wo.createRoot=e.createRoot,wo.hydrateRoot=e.hydrateRoot,wo}var Uy=Fy(),y=au();const Kn="teamtrail",te={slug:Kn,npm:"teamtrail",name:"Teamtrail",category:"The trail map for AI coding agents",tagline:"You pick the destination. Your agents walk the trail.",assistant:{name:"Scout"},labelPrefix:Kn,dataDir:`.${Kn}`,apiPrefix:`/__${Kn}`,dataDirEnv:`${Kn.toUpperCase()}_DIR`,noRegisterEnv:`${Kn.toUpperCase()}_NO_REGISTER`,tokenEnv:`${Kn.toUpperCase()}_TOKEN`},Jo=`${Kn}.prefs`,Xo=e=>`${te.labelPrefix}:${e}`,lu=Xo("map"),cu=Xo("hitl"),Wy=e=>e==="task"||e==="execute",uu=Xo("plan-only");function gp(e){return/^[A-Za-z0-9_@%+=:,./-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}const Hy=e=>e.map(gp).join(" "),Ky=/^\d+\.\d+\.\d+(-[0-9A-Za-z][0-9A-Za-z.-]*)?$/;function Vy(e){return Ky.test(e)?`${te.npm}@${e}`:te.npm}function vp(e,t){return Hy(["npx","-y",Vy(e),...t])}const Lo=["research","prototype","junction","task","execute"],Zo=[...Lo,"review"],ds="plan+execute",Gy=e=>e.filter(t=>!t.archived),qy=["verifying","rework","blocked"],du=["off","checks","checks+review","checks+review+human"],kp=e=>du.find(t=>t===e);function rr(e){return e.type==="junction"||e.type==="prototype"?"hitl":e.type==="research"?"afk":e.hitl?"hitl":"afk"}const Qy=["task","execute"];function yp(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,yp(o,s,t)]))}const Ke=200,Qe=56;function Wf(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(se=>[se.id,se])),h=new Map,m=new Set,p=se=>{if(h.has(se))return h.get(se);if(m.has(se))return 0;m.add(se);const D=d.get(se),J=D&&D.blockedBy.length?1+Math.max(...D.blockedBy.filter(X=>d.has(X)).map(p),-1):0;return m.delete(se),h.set(se,J),J},k=e.filter(se=>c.get(se.id)!=="out-of-scope"),v=e.filter(se=>c.get(se.id)==="out-of-scope"),x=[];for(const se of k)(x[$e=p(se.id)]??(x[$e]=[])).push(se);const j=[],b=new Map;let S=0;x.forEach(se=>{se&&(se.sort((D,J)=>{const X=ce=>{const K=ce.blockedBy.map(Y=>b.get(Y)).filter(Y=>Y!==void 0);return K.length?K.reduce((Y,F)=>Y+F,0)/K.length:ce.createdAt/1e12};return X(D)-X(J)||D.createdAt-J.createdAt}),S=Math.max(S,se.length),se.forEach((D,J)=>b.set(D.id,J)))}),x.forEach((se,D)=>{if(!se)return;const J=(S-se.length)*a/2;se.forEach((X,ce)=>{const K=D*o,Y=J+ce*a;j.push({ticket:X,state:c.get(X.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:Qe)),O=Math.max(S,1)*a-(a-(t==="LR"?Qe:Ke)),R=t==="LR"?C:O,z=t==="LR"?O:C,Z=z+54,q=Math.max(1,Math.floor((R+24)/(Ke+24)));v.forEach((se,D)=>{j.push({ticket:se,state:"out-of-scope",layer:-1,x:D%q*(Ke+24),y:Z+Math.floor(D/q)*(Qe+16)})});const H=[],re=new Map(j.map(se=>[se.ticket.id,se]));for(const se of j)for(const D of se.ticket.blockedBy){const J=re.get(D);J&&H.push({from:J,to:se})}const Q=Math.ceil(v.length/q),ve=Math.max(R,Math.min(v.length,q)*(Ke+24)-24),ze=v.length?Z+Q*(Qe+16)-16:z;return{direction:t,nodes:j,edges:H,width:ve,graphH:z,quarantineY:Z,height:ze,quarantineH:Q*(Qe+16)+24}}const Oo=["fast","balanced","strongest"],wp=e=>Oo.includes(e),hu={research:"fast",task:"balanced",execute:"balanced",junction:"strongest",prototype:"strongest",review:"strongest"};function Yy(e,t){var a,c;const s=(c=(a=t.modelMatching)==null?void 0:a.tiers)==null?void 0:c[e.type],o=hu[e.type];return t.settingsUnconfirmed&&s?Oo.indexOf(s)>=Oo.indexOf(o)?s:o:s??o}function Jy(e){return Object.fromEntries(Zo.map(t=>[t,Yy({type:t},e)]))}const Xy=e=>e!=="__proto__"&&e!=="constructor"&&e!=="prototype",Zy=64;function ew(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 tw(s)}function tw(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 nw({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 sw(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]=nw({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 iw(e,t,s){const o=ew(e,s.segments);if(o.filter(c=>c.kind!=="char").length>Zy)return!1;let a=new Uint8Array(t.length+1);a[t.length]=1;for(let c=o.length-1;c>=0;c--)a=sw(o[c],a,t);return a[0]===1}const rw=["holding","challenged","invalidated","confirmed"],ow=e=>rw.includes(e),aw=te.labelPrefix,zc=" -->",lw=7e4,xp=e=>`<!-- ${aw}:${e} `,cw=e=>JSON.stringify(e).replace(/--/g,"-\\u002d"),uw=(e,t)=>`${xp(e)}${t}${zc}`;function dw(e,t){const s=e.trimEnd();if(!s.endsWith(zc))return;const o=xp(t),a=s.lastIndexOf(o);if(!(a===-1||s.length-a>lw))return{before:s.slice(0,a),payload:s.slice(a+o.length,-zc.length)}}const hw=/[\u0000-\u001f\u007f-\u009f\u2028\u2029\u200b\u2060\ufeff\u202a-\u202e\u2066-\u2069]/,fw=/[\u0000-\u001f\u007f-\u009f\u2028\u2029\u200b\u2060\ufeff\u202a-\u202e\u2066-\u2069]+/g,mw=/\r\n|[\r\u0085\u2028\u2029]/g,pw=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u0084\u0086-\u009f\u200b\u2060\ufeff\u202a-\u202e\u2066-\u2069]/g,gw=e=>hw.test(e),Hs=e=>e.replace(fw," ").trim(),vw=e=>e.replace(mw,`
41
+ `).replace(pw,"");function ea(e,t){const s=new RegExp(`^\\\\*(?:${t})`);return vw(e).trim().split(`
42
+ `).map(o=>s.test(o)?`\\${o}`:o).join(`
43
+ `)}function Po(e,t){const s=new RegExp(`^\\\\+(?:${t})`);return e.split(`
44
+ `).map(o=>s.test(o)?o.slice(1):o).join(`
45
+ `)}const jp=te.labelPrefix,kw=new RegExp(`<(\\\\*)!--(?=\\s*${jp}:)`,"g"),yw=new RegExp(`<\\\\(\\\\*)!--(?=\\s*${jp}:)`,"g"),ta=e=>e.replace(kw,"<\\$1!--"),Us=e=>e.replace(yw,"<$1!--"),Sp="asm",ww=/^-\s+(?:\[([a-z]+)\]\s+)?/,xw=1e3;function jw(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,xw)}}:{},...e.decidedBy?{decidedBy:e.decidedBy}:{}};return`- [${e.status}] ${ta(Hs(e.text))} ${uw(Sp,cw(t))}`}function Sw(e){const t=e.map(Nw);let s=Math.max(0,...t.map(o=>Cw(o.id)))+1;return t.map(o=>o.id?o:{...o,id:`S-${s++}`})}function Nw(e){const t=dw(e,Sp),s=t?t.before:e,o=s.match(ww),a=o==null?void 0:o[1],c=Us(s.slice(o?o[0].length:0).trim()),d=bw(t==null?void 0:t.payload);return{id:d.id??"",text:c,status:ow(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 bw(e){if(!e)return{};try{const t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}function Cw(e){const t=e==null?void 0:e.match(/^S-(\d+)$/);return t?Number(t[1]):0}const Np=[["destination","Destination"],["notes","Notes"],["assumptions","Assumptions"],["decisions","Decisions so far"],["unspecified","Not yet specified"],["outOfScope","Out of scope"]],$w=Object.fromEntries(Np),bp="##\\s",Hf=e=>ta(ea(e.trim(),bp)),Kf=e=>Po(Us(e),bp),Vf=e=>ta(Hs(e)),Tw=/^-\s+(?:\[?([#A-Z0-9-]+)\]?:?\s+)?(.*)$/;function Ew(e){var o;const t=a=>a.length?a.map(c=>`- ${Vf(c)}`).join(`
46
+ `):"_None yet._",s=a=>a.length?a.map(c=>`- ${c.ticketKey?`${Hs(c.ticketKey)}: `:""}${Vf(c.text)}`).join(`
47
+ `):"_None yet._";return[`## Destination
48
+
49
+ ${Hf(e.destination)}`,`## Notes
50
+
51
+ ${Hf(e.notes)||"_None yet._"}`,...(o=e.assumptions)!=null&&o.length?[`## Assumptions
52
+
53
+ ${e.assumptions.map(jw).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 Aw(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=Np.find(([,v])=>v.toLowerCase()===d))==null?void 0:o[0];if(!m)continue;const p=/^_none yet\._$/i.test(h),k=p?[]:h.split(`
65
+ `).map(v=>v.trim()).filter(v=>v.startsWith("- "));m==="destination"?t.destination=Kf(h):m==="notes"?t.notes=p?"":Kf(h):m==="assumptions"?t.assumptions=Sw(k):m==="decisions"?t.decisions=k.map(v=>{const x=v.match(Tw);return x&&x[1]&&/\d/.test(x[1])?{ticketKey:x[1],text:Us(x[2])}:{text:Us(v.slice(2))}}):t[m]=k.map(v=>Us(v.slice(2)))}return t}const na={chart:["Name destination","Find frontier","Create trail","Create tickets + wire blocking","Fire research"],work:["Load trail","Claim","Resolve","Record","Update plan"],research:["Claim","Investigate","Record"]},Iw=(e,t)=>`${e[0].toUpperCase()}${e.slice(1)} ${t}/${na[e].length}`;async function Mw(e,t,s={}){var d,h,m;const o=Rw(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 k=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,k),await((h=s.onTicketCreated)==null?void 0:h.call(s,k,p.ref))}for(const p of o.tickets)for(const k of p.blockedBy??[]){const v=c.get(k),x=c.get(p.ref);v&&(await e.addBlocking(a.id,v.id,x.id),await((m=s.onEdgeWired)==null?void 0:m.call(s,v,x)))}return{map:a,tickets:[...c.values()]}}function Rw(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 Ae extends Error{}function Cp(e){if(e.archived)throw new Ae(`Trail ${e.key} "${e.title}" is archived: no work is taken from it. Only the trail lead can restore it in the Lookout.`)}class Lw{constructor(){le(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}}const Ow={frontier:"ready",blocked:"backlog",parked:"backlog",claimed:"working",verifying:"verifying",rework:"rework",held:"blocked",decided:"done","out-of-scope":"cancelled"};function Pw(e,t,s=ds){return Ow[yp(e,t,s)]}const _w=["backlog","ready","working","verifying","rework","blocked"],Vi=["agent","trail lead"],Dw=[{event:"claim",from:["ready","rework"],to:["working"],actors:Vi},{event:"release",from:["working"],to:["ready","rework"],actors:Vi},{event:"expire",from:["working"],to:["ready","rework"],actors:["engine","trail lead"]},{event:"complete",from:["backlog","ready","working","rework"],to:["done"],actors:Vi},{event:"submit",from:["working"],to:["verifying"],actors:Vi},{event:"checks.pass",from:["verifying"],to:["verifying","done"],actors:["engine"]},{event:"checks.fail",from:["verifying"],to:["rework","blocked"],actors:["engine"]},{event:"checks.error",from:["verifying"],to:["blocked"],actors:["engine"]},{event:"reverify",from:["verifying"],to:["verifying"],actors:["engine","trail lead"]},{event:"review.pass",from:["verifying"],to:["verifying","done"],actors:["engine"]},{event:"review.fail",from:["verifying"],to:["rework"],actors:["engine"]},{event:"review.needs_human",from:["verifying"],to:["blocked"],actors:["engine"]},{event:"approve",from:["verifying"],to:["done"],actors:["trail lead"]},{event:"reject",from:["verifying","blocked"],to:["rework"],actors:["trail lead"]},{event:"accept",from:["verifying","blocked"],to:["done"],actors:["trail lead"]},{event:"unblock",from:["blocked"],to:["ready","rework","verifying"],actors:["trail lead"]},{event:"cancel",from:_w,to:["cancelled"],actors:[...Vi,"engine"]},{event:"reopen",from:["done","cancelled"],to:["ready"],actors:["trail lead"]}],zw=e=>Dw.find(t=>t.event===e),Bw=new Lw;function Fw(e,t,s){if(s){if(!e.to.includes(s))throw new Ae(`${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 Ae(`${e.event} needs a target: ${e.to.join(" or ")}`)}async function Uw(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 Ae("backlog follows from blockers; no transition leads there")}}function sa(e,t,s,o){return Bw.run(`${t}/${s}`,async()=>{var p;const a=await e.loadMap(t),c=a.tickets.find(k=>k.id===s);if(!c)throw new Ae(`ticket ${s} not found`);const d=Pw(c,new Map(a.tickets.map(k=>[k.id,k])),a.map.mode);if(o.expect&&d!==o.expect)throw new Ae(`${c.key} changed: it is ${d} now`);const h=zw(o.event);if(!h.from.includes(d))throw new Ae(`${c.key} is ${d}; ${o.event} needs ${h.from.join(" or ")}`);if(!h.actors.includes(o.actorKind))throw new Ae(`${o.event} is not for ${o.actorKind}s`);const m=Fw(h,c,o.to);await Uw(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 Gf(e,t,s,o){const{assignee:a}=o,c=await e.loadMap(t),d=c.tickets.find(k=>k.id===s);if(!d)throw new Ae(`ticket ${s} not found`);Cp(c.map);const h=Js(c.tickets,c.map.mode).get(s);if(h!=="frontier"&&h!=="rework")throw new Ae(`${d.key} is ${h}, not on the frontier`);await sa(e,t,s,{event:"claim",actor:a,actorKind:o.actorKind??"agent",reason:o.reason,sessionId:o.sessionId,journal:o.journal});const p=(await e.loadMap(t)).tickets.find(k=>k.id===s);if(p.assignee!==a)throw new Ae(`${d.key} was claimed by ${p.assignee}`);return p}async function Ww(e,t,s,o={}){const c=(await e.loadMap(t)).tickets.find(d=>d.id===s);if(!c)throw new Ae(`ticket ${s} not found`);await sa(e,t,s,{event:"release",actor:o.actor??c.assignee??"trail lead",actorKind:o.actorKind??"agent",reason:o.reason,sessionId:o.sessionId,journal:o.journal})}const Hw=e=>e==="lookout",Kw=e=>e.via==="chat"?`in ${e.chatOf??"an agent"}'s chat`:void 0;function Vw(e){return e.via?e.via==="chat"&&e.chatOf?{via:e.via,chatOf:e.chatOf}:{via:e.via}:{}}async function $p(e,t){const s=e.via??(e.sourceKind==="slack"?"slack":void 0);if(!s||Hw(s)||!t.ticketId)return;const o=t.key??t.ticketId;if(!e.highRisk)throw new Ae(`Can't tell whether ${o} is high risk: decide it in the Lookout.`);if(await e.highRisk(t.mapId,t.ticketId))throw new Ae(`${o} is high risk: decide it in the Lookout. Answers given in Slack don't count for it.`)}async function fu(e,t,s,o={}){if(await $p({...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 Gw(e,t,s,o){const c=(await e.listDecisions(t)).find(v=>v.id===s);if(!c)throw new Ae(`decision ${s} not found`);if(c.postedBy)throw new Ae(`${c.id} is ${c.postedBy}'s decision; record your own instead`);if(c.supersededBy)throw new Ae(`${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(v=>v.text===c.summary||!!c.ticketId&&v.ticketId===c.ticketId||!!c.ticketKey&&v.ticketKey===c.ticketKey),k={ticketId:d.ticketId,ticketKey:d.ticketKey,text:d.summary};return await e.updateMapSections(t,{decisions:p<0?[...m,k]:m.map((v,x)=>x===p?k:v)}),d}async function qw(e,t,s){await e.setMapMode(t,s)}function Tp(e){return e==="plan-only"?Lo.filter(t=>t!=="execute"):Lo}function Qw(e,t){if(!Tp(e).includes(t))throw new Ae(`${t} tickets are disabled on plan-only maps`)}const qn={lookout:{label:"Lookout",code:"CMD"},agent:{label:"Agent",code:"AGT"},slack:{label:"Slack",code:"SLK"},tracker:{label:"Tracker",code:"TRK"}},_o=Object.keys(qn),Yw=e=>e in qn,Ep=" (unverified, from text)";function er(e){return e.derived||e.decidedBy.endsWith(Ep)?"unverified":e.postedBy?"teammate":e.source.kind==="agent"&&e.decidedBy!=="trail lead"&&!e.decidedBy.startsWith("slack:")?"agent":"human"}const Ap=e=>e.postedBy?`posted by ${e.postedBy} in ${e.postedIn??"the tracker"}`:void 0,or=e=>e.supersededBy?"superseded":"active";function ia(e){const t=e.replace(/\s+/g," ").trim(),s=t.match(/^(.{20,180}?[.!?])(\s|$)/);return s?s[1]:t.slice(0,180)}function Jw(e,t,s){var o;return{...s,id:e,mapId:t,decidedAt:s.decidedAt??Date.now(),summary:((o=s.summary)==null?void 0:o.trim())||ia(s.answer),alternatives:s.alternatives??[],rationale:s.rationale??"",participants:s.participants??[{id:s.decidedBy}],transcript:s.transcript??[]}}const Xw=e=>Number(e.replace(/\D/g,""))||0;function Zw(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 ex(e,t,s,o){var d,h;const c=(await e.loadMap(t)).tickets.find(m=>m.id===s);if(!c)throw new Ae(`ticket ${s} not found`);if(c.state==="closed")throw new Ae(`${c.key} is already closed`);return await $p({...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 sa(e,t,s,{event:o.event??"complete",actor:o.actor??o.author,actorKind:o.actorKind??"agent",sessionId:o.sessionId,reason:o.reason,journal:o.journal,...o.event&&o.event!=="complete"?{to:"done"}:{}}),await fu(e,t,tx(c,o),{trailLine:o.trailLine,guard:o.guard}),c}function tx(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??ia(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 nx(e,t,s,o){const a=await e.loadMap(t);if(Cp(a.map),!a.map.sections.unspecified.includes(s))throw new Ae(`"${s}" is not in Not yet specified`);Qw(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 sx(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 Ae(`"${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 Ae(`ticket ${s.ticketId} not found`);await e.comment(t,h.id,o.author,`**Ruled out of scope**
74
+
75
+ ${o.reason}`),await sa(e,t,h.id,{event:"cancel",actor:o.author,actorKind:o.actorKind??"agent",reason:o.reason,sessionId:o.sessionId,journal:o.journal}),await fu(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 ix(e,t,s,o){s&&rx(s),await e.setMapMeta(t,{modelMatching:s&&ox(s),confirm:!0})}function rx(e){if(typeof e.enabled!="boolean")throw new Ae('"enabled" must be true or false');for(const[t,s]of Object.entries(e.tiers??{})){if(!Zo.includes(t))throw new Ae(`unknown ticket type "${t}"`);if(!wp(s))throw new Ae(`"${t}" must be fast, balanced or strongest`)}}function ox(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}}async function ax(e,t,s,o){await e.setMapArchived(t,s)}function lx(e){return{async append(t){await fetch(`${e}/journal`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}}}const Ip={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(Ip));const cx=2*6e4,gc=e=>e<6e4?`${Math.round(e/1e3)}s`:`${Math.round(e/6e4)}m`;function ux(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+cx?{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(){le(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 dx=0;const Mo=(e="id")=>`${e}_${Date.now().toString(36)}${(dx++).toString(36)}`,Bc=(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)}:{}}),Mp=(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 hx(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=na[s][c-1];e.patchSession(t.id,{step:c,stepLabel:m,...h?{ticketId:h}:{}}),a({tag:Iw(s,c),level:"step",text:d?`${m}: ${d}`:m,ticketId:h??o().ticketId})},log(c,d="info",h){a({level:d,text:c,ticketId:o().ticketId,...h?{kind:h}:{}})},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:Mo("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",kind:"asks-you",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,...h!=null&&h.kind?{kind:h.kind}:{}})},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:{...Bc(h,c),source:c.source??(h==null?void 0:h.source)}})},setUsage(c){var k;const d=o().usage,h=Mp(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)&&((k=e.ledger())==null||k.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 fx{constructor(t=400,s){le(this,"state",{sessions:[],feed:[],chats:[],pending:[],answered:[],usageByMap:{}});le(this,"changes",new Ks);le(this,"resolvers",new Map);le(this,"remote",new Map);le(this,"remoteAnswer");le(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]:Bc(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:Mo("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:Mo("m"),at:Date.now(),...t}].slice(-600)})}answer(t,s,o,a){var p;const c=this.state.pending.find(k=>k.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=Vw(a);return this.chat({sessionId:c.sessionId,ticketId:c.ticketId,from:"human",author:o,text:s,...m}),this.set({pending:this.state.pending.filter(k=>k.id!==t),answered:[...this.state.answered,{id:c.id,mapId:c.mapId,sessionId:c.sessionId,agent:c.agent,askedAt:c.at,answeredAt:Date.now(),...c.ticketId?{ticketId:c.ticketId}:{},...c.category?{category:c.category}:{},...(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",kind:"answered",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(k=>k.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 k=Mp(s.usage,a);(k.inputTokens||k.outputTokens||k.costUsd)&&(c={...c,[s.mapId]:Bc(c[s.mapId],k)}),(p=this.ledger)==null||p.addTotal(s.mapId,o,s.usage)}const d=k=>k.filter(v=>v.sessionId!==o),h=new Set(this.state.answered.map(k=>k.id)),m=this.state.sessions.some(k=>k.id===o)?this.state.sessions.map(k=>k.id===o?s:k):[...this.state.sessions,s].slice(-24);this.set({sessions:m,chats:[...d(this.state.chats),...t.chats].sort((k,v)=>k.at-v.at).slice(-600),pending:[...d(this.state.pending),...t.pending],answered:[...this.state.answered,...t.answered.filter(k=>!h.has(k.id))].sort((k,v)=>k.answeredAt-v.answeredAt).slice(-200),feed:[...this.state.feed.filter(k=>k.sessionId!==o),...t.feed].sort((k,v)=>k.at-v.at).slice(-this.maxFeed),usageByMap:c})}isRemote(t){return this.remote.has(t)}startSession(t){const s={...t,id:t.id??Mo("s"),step:0,total:na[t.mode].length,stepLabel:"BOOT",status:"running",startedAt:Date.now()};this.set({sessions:[...this.state.sessions,s].slice(-24)});const o=hx(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 mx(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 ${lu}`};case"map.updated":return{source:"tracker",level:"info",text:`Trail updated${e.section?` · ${$w[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",...e.reason==="completed"?{kind:"done"}:{},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 px=new Set(["createMap","setMapMode","setMapArchived","setMapMeta","updateMapSections","createTicket","addBlocking","removeBlocking","editTicket","reopen","assign","comment","close","setMeta","createDecision","markSuperseded"]),gx=5*6e4;function vx(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-gx;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:px.has(d)?async(...p)=>{const k=Date.now();o({inflight:t.inflight+1,status:"syncing"});try{const v=await m.apply(c,p),x=t.inflight-1;return o({inflight:x,writes:t.writes+1,lastWriteMs:Date.now()-k,lastWriteAt:Date.now(),status:x?"syncing":"ok",lastError:void 0}),v}catch(v){const x=t.inflight-1;throw o({inflight:x,errors:t.errors+1,status:"error",lastError:String(v.message??v)}),v}}:m.bind(c)}}),get health(){return t},subscribe:c=>s.on(c)}}function Rp(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 Lp(e){const t=Rp(e);return{decided:t.decided,total:t.total-t["out-of-scope"]}}function kx(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 k of h.blockedBy)if(t.has(k)){const v=a(k);v.length>m.length&&(m=v)}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 yx(e){return Lo.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 wx(e,t){const s=e.pending.filter(a=>!0),o=e.answered.filter(a=>!0);return{open:s.length,oldestAt:s.length?Math.min(...s.map(a=>a.at)):void 0,answered:o.length,avgWaitMs:o.length?o.reduce((a,c)=>a+(c.answeredAt-c.askedAt),0)/o.length:void 0}}function Op(e,t){return t&&e.usageByMap[t]||{inputTokens:0,outputTokens:0,costUsd:0}}const xx=e=>e.usage?e.usage.inputTokens+e.usage.outputTokens:0,Pp={"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 _p(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 jx(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 Sx(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 k;const c=[...a.comments].reverse().find(v=>v.body.startsWith("**Resolution**")),d=c?c.body.replace(/^\*\*Resolution\*\*\s*/,""):((k=e.map.sections.decisions.find(v=>v.ticketId===a.id||v.ticketKey===a.key))==null?void 0:k.text)??"",h=(c==null?void 0:c.author)??a.assignee??"unknown",m=a.comments.find(v=>v.body.startsWith("**HITL transcript**")),p=m?jx(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:ia(d),alternatives:[],rationale:"",decidedBy:`${h}${Ep}`,decidedAt:a.closedAt??(c==null?void 0:c.createdAt)??a.updatedAt,participants:[...new Set([h,...p.map(v=>v.author)])].map(v=>({id:v})),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 Nx(e,t){var o;const s=(o=t.query)==null?void 0:o.trim().toLowerCase();return e.filter(a=>(!t.mapId||a.mapId===t.mapId)&&(!t.source||a.source.kind===t.source)&&(!t.decidedBy||a.decidedBy===t.decidedBy)&&(!t.madeBy||er(a)===t.madeBy)&&(!t.status||or(a)===t.status)&&(!s||[a.id,a.ticketKey,a.question,a.answer,a.summary,a.rationale,a.decidedBy,...a.alternatives,...a.transcript.map(c=>c.text)].join(`
79
+ `).toLowerCase().includes(s)))}function bx(e,t=Date.now()){const s=Object.fromEntries(_o.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=er(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 ra(e){const t=e.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);if(!t)return{front:{},body:e};const s={};for(const o of t[1].split(`
80
+ `)){const a=o.indexOf(":");if(a<0)continue;const c=o.slice(0,a).trim(),d=o.slice(a+1).trim();Xy(c)&&(s[c]=d.startsWith("[")?Tx(d.slice(1,-1)).map(Qf).filter(Boolean):Qf(d))}return{front:s,body:t[2]}}const Cx=e=>e===""||/^[\s#&*!|>'"%@`[\]{},?:-]|[:#]\s|\s$|,|["\\[\]]/.test(e)||gw(e)||/^(true|false|null|~|\d[\d.e+-]*)$/i.test(e),$x=e=>JSON.stringify(e).replace(/[\u007f\u0085\u2028\u2029]/g,t=>`\\u${t.charCodeAt(0).toString(16).padStart(4,"0")}`),qf=e=>Cx(e)?$x(e):e;function Qf(e){if(e.startsWith('"'))try{return JSON.parse(e)}catch{return e.slice(1,-1)}return e.startsWith("'")?e.slice(1,-1).replace(/''/g,"'"):e}function Tx(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 Ex(e){if(!/^[\w-]+$/.test(e))throw new Error(`invalid frontmatter key: ${JSON.stringify(e)}`);return e}function mu(e,t){return`---
81
+ ${Object.entries(e).map(([o,a])=>`${Ex(o)}: ${Array.isArray(a)?`[${a.map(qf).join(", ")}]`:qf(a)}`).join(`
82
+ `)}
83
+ ---
84
+
85
+ ${t.trim()}
86
+ `}const ke=e=>Array.isArray(e)?e.join(","):e??"";function Vt(e){return Array.isArray(e)?e:e?[e]:[]}const Ws=e=>Date.parse(ke(e))||0,on=e=>new Date(e).toISOString(),Dp=["schema","breaking-api","auth-permissions","billing","data-deletion","product-behaviour","dependencies"],zp=["low","medium","high"],Ax=e=>Dp.includes(e),Ix=e=>zp.includes(e);function Mx(e){return e?{risk:e.level,...e.category?{risk_category:e.category}:{},risk_reason:e.reason}:{}}function Rx(e){const t=ke(e.risk);if(!Ix(t))return{};const s=ke(e.risk_category);return{risk:{level:t,...Ax(s)?{category:s}:{},reason:ke(e.risk_reason)}}}const Bp=["Question","Decision","Summary","Alternatives","Rationale","Transcript"],pu=`## (?:${Bp.join("|")})\\s*$`,Fp=`${pu}|### `,xo=e=>ea(e.trim(),pu),Lx=e=>e.name?`${e.id}|${e.name}`:e.id,Ox=e=>{const t=e.indexOf("|");return t<0?{id:e}:{id:e.slice(0,t),name:e.slice(t+1)}};function Up(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:on(e.decidedAt),participants:e.participants.map(Lx),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}:{},...Mx(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} @ ${on(d.at)}
88
+
89
+ ${ea(d.text.trim(),Fp)}`).join(`
90
+
91
+ `):"_None._",a=[`## Question
92
+
93
+ ${xo(e.question)}`,`## Decision
94
+
95
+ ${xo(e.answer)}`,`## Summary
96
+
97
+ ${xo(e.summary)}`,`## Alternatives
98
+
99
+ ${s(e.alternatives)}`,`## Rationale
100
+
101
+ ${xo(e.rationale)||"_None._"}`,`## Transcript
102
+
103
+ ${o}`].join(`
104
+
105
+ `);return mu(t,a)}function Fc(e){const{front:t,body:s}=ra(e),o={},a=new RegExp(`^## (${Bp.join("|")})\\s*$`,"gm"),c=[...s.matchAll(a)];c.forEach((v,x)=>{var I;const j=s.slice(v.index+v[0].length,((I=c[x+1])==null?void 0:I.index)??s.length).trim(),b=v[1],S=b==="Transcript"?j:Po(j,pu);o[b]=/^_none\._$/i.test(j)?"":S});const d=(o.Transcript??"").split(/^### /m).slice(1).map(v=>{const x=v.indexOf(`
106
+ `),j=x<0?v:v.slice(0,x),b=j.lastIndexOf(" @ "),S=b<0?j:j.slice(0,b),I=b<0?"":j.slice(b+3),C=S.lastIndexOf(" · "),O=C<0?S:S.slice(0,C),R=C<0?"agent":S.slice(C+3);return{author:O.trim(),from:["agent","human","system"].includes(R.trim())?R.trim():"agent",at:Date.parse(I)||0,text:x<0?"":Po(v.slice(x+1).trim(),Fp)}}),h=ke(t.source),m=Vt(t.source_meta),p={kind:Yw(h)?h:"tracker",...ke(t.source_ref)?{ref:ke(t.source_ref)}:{},...ke(t.source_url)?{url:ke(t.source_url)}:{},...ke(t.source_label)?{label:ke(t.source_label)}:{},...m.length?{meta:Object.fromEntries(m.map(v=>[v.slice(0,v.indexOf("=")),v.slice(v.indexOf("=")+1)]))}:{}},k=o.Decision??"";return{id:ke(t.id),mapId:ke(t.trail),ticketId:ke(t.ticket)||void 0,ticketKey:ke(t.ticket_key)||void 0,question:o.Question??"",answer:k,summary:o.Summary||ia(k),alternatives:(o.Alternatives??"").split(`
107
+ `).map(v=>v.trim()).filter(v=>v.startsWith("- ")).map(v=>v.slice(2)),rationale:o.Rationale??"",decidedBy:ke(t.decided_by),decidedAt:Ws(t.decided_at),participants:Vt(t.participants).map(Ox),source:p,supersedes:ke(t.supersedes)||void 0,supersededBy:ke(t.superseded_by)||void 0,...Vt(t.assumes).length?{assumes:Vt(t.assumes)}:{},transcript:d,...Rx(t)}}function Px(e){return e.url?` · [${e.label??"link"}](${e.url})`:e.label?` · ${e.label}`:""}function _x(e,t,s={}){const o=[`# ${s.title??"Decisions"}`,"",`Exported ${on(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=qn[m.source.kind].label;o.push("",`### ${m.id}${m.ticketKey?` · ${m.ticketKey}`:""} · ${m.question}`,"",`- **Status:** ${or(m)}${m.supersededBy?` (superseded by ${m.supersededBy})`:""}${m.supersedes?` · supersedes ${m.supersedes}`:""}`,`- **Decided by:** ${m.decidedBy} · ${on(m.decidedAt)}`,`- **Source:** ${p}${Px(m.source)}`,...m.participants.length?[`- **Participants:** ${m.participants.map(k=>k.name??k.id).join(", ")}`]:[],"",`**Decision:** ${m.answer}`,...m.alternatives.length?["","**Alternatives:**",...m.alternatives.map(k=>`- ${k}`)]:[],...m.rationale?["",`**Rationale:** ${m.rationale}`]:[],...m.transcript.length?["","<details><summary>Transcript</summary>","",...m.transcript.map(k=>`> **${k.author}:** ${k.text.replace(/\n/g,`
108
+ > `)}
109
+ >`),"","</details>"]:[])}}return o.join(`
110
+ `)+`
111
+ `}function Uc(e,t,s){try{const o=e.get(t);return o?JSON.parse(o):s}catch{return s}}class Yf{constructor(t,s="presence"){le(this,"seen");this.store=t,this.key=s,this.seen=Uc(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,Dx=14*864e5;class Jf{constructor(t,s="usage"){le(this,"buckets");le(this,"dirty",!1);le(this,"timer");le(this,"totals");this.store=t,this.key=s,this.buckets=Uc(t,s,{}),this.totals=Uc(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,k)=>p.at-k.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()-Dx;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 zx(e){const t=e.now??Date.now(),s=e.snaps.map(d=>{var re;const h=d.map.id,m=e.since(h),p=Q=>!!Q&&Q>=m,k=Js(d.tickets,d.map.mode),v=new Map(d.tickets.map(Q=>[Q.id,Q])),x=(e.attention??[]).filter(Q=>Q.mapId===h),j=Bx(e.activity.pending.filter(Q=>Q.mapId===h),x),b=new Set(j.map(Q=>Q.ticketId)),S=Q=>Q.state==="open"&&(b.has(Q.id)||rr(Q)==="hitl"),I=d.tickets.filter(Q=>k.get(Q.id)==="blocked").map(Q=>({ticket:Q,on:Q.blockedBy.map(ve=>v.get(ve)).filter(ve=>!!ve&&S(ve))})).filter(Q=>Q.on.length),C=e.decisions.filter(Q=>Q.mapId===h&&p(Q.decidedAt)).sort((Q,ve)=>ve.decidedAt-Q.decidedAt),O=d.tickets.filter(Q=>Q.state==="closed"&&p(Q.closedAt)).sort((Q,ve)=>(Q.closedAt??0)-(ve.closedAt??0)),R=O.filter(Q=>Q.closeReason==="completed"),z=O.filter(Q=>Q.closeReason==="not_planned"),Z=d.tickets.filter(Q=>p(Q.createdAt)),q=((re=e.ledger)==null?void 0:re.since(h,m))??{inputTokens:0,outputTokens:0,costUsd:0,sessions:0},H=e.activity.sessions.filter(Q=>Q.mapId===h&&Q.status==="running");return{mapId:h,key:d.map.key,title:d.map.title,since:m,done:R,ruledOut:z,opened:Z,blocked:I,waiting:j,needsYou:x,decisions:C,agentDecisions:C.filter(Q=>er(Q)==="agent"),usage:q,active:H,changed:!!(O.length||Z.length||C.length||j.some(Q=>p(Q.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 Bx(e,t){const s=new Map(t.filter(a=>a.kind==="question").map((a,c)=>[a.ref,c])),o=a=>s.get(a.id)??Number.MAX_SAFE_INTEGER;return[...e].sort((a,c)=>o(a)-o(c)||a.at-c.at)}const Yi=(e,t,s=`${t}s`)=>`${e} ${e===1?t:s}`;function Fx(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 Ux(e){return e.length===1?`, and it holds up ${e[0].ticket.title.replace(/^./,t=>t.toLowerCase())}`:e.length>1?`, holding up ${Yi(e.length,"ticket")}`:""}function Wx(e,t=new Date(e.now).getHours()){const s=e.totals,a=e.now-e.since>=6*36e5&&t>=5&&t<12?"Good morning.":"Welcome back.",c=[];if(s.done&&c.push(`${Yi(s.done,"ticket")} ${s.done===1?"is":"are"} done.`),s.agentDecisions&&c.push(`Agents made ${Yi(s.agentDecisions,"decision")}.`),s.waiting){const d=Ux(Fx(e));c.push(`${Yi(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(`${Yi(s.ruledOut,"ticket")} ruled out of scope.`),[a,...c].join(" ")}const Hx=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 Kx(e){return e.state==="open"?"open":e.closeReason==="not_planned"?"cancelled":"done"}function Wp({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 z;const I=d.get(S.id)??[],C=Kx(S),O=(z=I.find(Z=>Z.event==="claim"))==null?void 0:z.at,R=C==="done"?S.closedAt:void 0;return{id:S.id,key:S.key,title:S.title,type:S.type,outcome:C,claimedAt:O,doneAt:R,leadMs:R&&O&&R>=O?R-O:void 0,reworks:I.filter(Z=>Z.to==="rework").length,reviews:{passed:I.filter(Z=>Z.event==="review.pass").length,failed:I.filter(Z=>Z.event==="review.fail").length,needsHuman:I.filter(Z=>Z.event==="review.needs_human").length},operatorActions:I.filter(Z=>Z.actorKind==="trail lead").length}}),m=h.filter(S=>S.outcome==="done"),p=Math.max(0,...m.map(S=>S.doneAt??0)),k=c.filter(S=>S.actorKind==="trail lead"),v=new Set(s.filter(S=>S.mapId===a).map(S=>S.id)).size,x=k.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:Hx(m.flatMap(S=>S.leadMs===void 0?[]:[S.leadMs])),interventions:{answers:v,operatorActions:x,reworkRequested:k.filter(S=>S.event==="reject").length,total:v+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 an(e){if(e===void 0)return"—";const t=Math.round(e/6e4);if(t<90)return`${t} min`;const s=e/36e5;return s<48?`${Math.round(s*10)/10} h`:`${Math.round(s/24*10)/10} d`}const Xf=e=>e===void 0?"—":`$${e.toFixed(e<1?4:2)}`;function Vx(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) | ${an(e.trailLeadMs)} |`,`| Median ticket lead time (claim → done) | ${an(e.medianLeadMs)} |`,`| Human interventions | ${o.total} (${o.answers} answers, ${o.operatorActions} operator actions, ${o.reworkRequested} sent back) |`,`| Rework | ${e.rework.cycles} cycles on ${e.rework.tickets} tickets |`,`| Reviews | ${e.reviews.passed} passed, ${e.reviews.failed} failed, ${e.reviews.needsHuman} needed a human |`,`| Spend | ${Xf(e.spend.costUsd)} · ${e.spend.tokens.toLocaleString("en-US")} tokens |`,`| Cost per verified ticket | ${Xf(e.spend.perVerifiedTicketUsd)} |`,"","## Tickets","","| Ticket | Type | Outcome | Lead time | Rework | Reviews (pass/fail) | Operator actions |","| --- | --- | --- | --- | --- | --- | --- |",...e.tickets.map(c=>`| ${c.key} ${c.title.replace(/\|/g,"\\|")} | ${c.type} | ${c.outcome} | ${an(c.leadMs)} | ${c.reworks} | ${c.reviews.passed}/${c.reviews.failed} | ${c.operatorActions} |`),""].join(`
112
+ `)}const gu=5,Hp=1.5,Gx=15,jo=e=>Math.round(e*100);function qx(e){const t=e.filter(d=>d.findings.raised>=gu).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 jo(a)-jo(c)<Gx?[]:[{id:"review-findings",text:`${s.key} review findings upheld ${jo(a)}% vs ${o.key} ${jo(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 Qx(e){const t=c=>c.reworkCycles/c.tickets,s=e.filter(c=>c.tickets>=gu).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)*Hp?[]:[{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 Yx(e,t){const s=d=>d.medianLeadMs??0,o=t.filter(d=>d.done>=gu&&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)*Hp?[]:[{id:`speed-${e}`,text:`${e} tickets: ${a.key} is faster, ${an(a.medianLeadMs)} vs ${c.key} ${an(c.medianLeadMs)}`,because:`Median first claim to done, over ${a.done} and ${c.done} done tickets`}]}function Jx(e){const t=Object.keys(e.byTypeAndVendor).sort();return[...qx(e.byVendor),...Qx(e.byVendor),...t.flatMap(s=>Yx(s,e.byTypeAndVendor[s]))]}const Xx=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)},Kp=e=>{var t;return(t=e.filter(s=>s.event==="claim"&&s.actorKind==="agent").at(-1))==null?void 0:t.actor},Wc=(e,t,s)=>e.filter(o=>o.mapId===t&&o.ticketId===s).sort((o,a)=>o.at-a.at);function Zx(e,t){return e.tickets.flatMap(s=>{var v;if(s.type!=="review"||!s.reviewOf)return[];const o=Wc(t,e.map.id,s.id),a=Kp(o);if(!a)return[];const c=((v=o.filter(x=>x.event==="claim").at(-1))==null?void 0:v.at)??0,d=Wc(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.")),k=p<0?m:m.slice(0,p);return[{reviewer:a,upheld:!k.some(x=>x.event==="accept"&&x.actorKind==="trail lead")}]})}function ej(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 Vp(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:Xx(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 So(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,Vp(o,a)]))}const Hc=(e,t)=>{const s=e.get(t)??Vp(t,[]);return e.set(t,s),s};function Zf(e,t,s){const o=Hc(e,t);o.findings.raised+=1,s&&(o.findings.upheld+=1)}const No=e=>[...e.values()].sort((t,s)=>s.tickets-t.tickets||t.key.localeCompare(s.key));function Gp(e){const t=e.flatMap(({snap:p,journal:k,answered:v,usage:x})=>Wp({snap:p,journal:k,answered:v,usage:x}).tickets.map(j=>({ticket:j,agent:Kp(Wc(k,p.map.id,j.id))??ej(p,j.id)}))),s=p=>p.agent?kc(p.agent):void 0,o=So(t,p=>p.agent),a=So(t,s),c=So(t,p=>p.ticket.type),d=new Set;for(const{snap:p,journal:k,answered:v}of e){for(const x of v){const j=`${x.mapId}/${x.id}`;x.mapId!==p.map.id||d.has(j)||(d.add(j),Hc(o,x.agent).answers+=1,Hc(a,kc(x.agent)).answers+=1)}for(const x of Zx(p,k))Zf(o,x.reviewer,x.upheld),Zf(a,kc(x.reviewer),x.upheld)}const h=Object.fromEntries([...c.keys()].map(p=>[p,No(So(t.filter(k=>k.ticket.type===p),s))])),m={trails:e.length,tickets:t.length,byAgent:No(o),byVendor:No(a),byType:No(c),byTypeAndVendor:h};return{...m,recommendations:Jx(m)}}const tj={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
+ `)},nj=[["summary","Summary"],["productContext","Product context"],["existing","Existing implementation"],["conventions","Conventions and abstractions"],["dataModel","Data model impact"],["api","API impact"],["risks","Risks and possible regressions"],["assumptions","Assumptions"],["openQuestions","Open questions"]],Gi=Object.fromEntries(nj);function sj(e,t){const s=new Set(e.map(o=>o.source).filter(Boolean));return t.filter(o=>!s.has(o))}const ij=["architecture","convention","gotcha","dead-end","glossary","fact"],qp=["business-rule","product-decision","persona","ux-principle","pricing"],rj=[...ij,...qp],oj=e=>e.status==="confirmed"||e.status==="assumption";function aj(e,t){return iw(e,t.replace(/^\.\//,""),{segments:!0})}const lj={"business-rule":3,convention:3,"product-decision":2,architecture:2,gotcha:2,"dead-end":2,"ux-principle":2},cj=["business-rule","ux-principle","convention"],em=600,uj=e=>`flagged as possibly outdated by ${e}; the human is reviewing it`,dj=new Set("the and for with from into onto that this these those than then through use uses using via all any are was were will can should must not only also each when what where which who how per our your their its".split(" ")),tm=e=>new Set((e.toLowerCase().match(/[a-z0-9][a-z0-9_-]{2,}/g)??[]).filter(t=>!dj.has(t)));function Qp(e,t,s=4e3,o=()=>[]){const a=t.ticket?tm(`${t.ticket.title} ${t.ticket.body}`):new Set,c=new Set((t.tags??[]).map(p=>p.toLowerCase())),d=e.filter(oj).map(p=>{const k=[];let v=lj[p.kind]??1;for(const b of p.scope){const S=t.paths.find(I=>aj(b,I));if(S){v+=6,k.push(`path match ${b} (${S})`);break}}const x=p.tags.filter(b=>c.has(b.toLowerCase())||a.has(b.toLowerCase()));x.length&&(v+=3*x.length,k.push(`tag ${x.join(", ")}`));const j=[...tm(p.title)].filter(b=>a.has(b));return j.length&&(v+=j.length,k.push(`mentions ${j.slice(0,3).join(", ")}`)),t.trailKey&&p.sources.includes(`trail:${t.trailKey}`)&&(v+=3,k.push("same trail")),t.discovery&&qp.includes(p.kind)&&(v+=8,k.push("product context for discovery")),!k.length&&cj.includes(p.kind)&&!p.scope.length&&k.push(`${p.kind.replace("-"," ")} for the whole project`),{e:p,score:v,why:k}}).filter(p=>p.why.length>0).sort((p,k)=>k.score-p.score||p.e.id.localeCompare(k.e.id,void 0,{numeric:!0})),h=[];let m=0;for(const{e:p,why:k}of d){const v=p.body.length>em?`${p.body.slice(0,em)}…`:p.body;if(m+v.length>s&&h.length)break;m+=v.length;const x=o(p);h.push({id:p.id,title:p.title,kind:p.kind,status:p.status,body:v,why:k,...x.length?{mayBeOutdated:x}:{},...p.flag?{flagged:uj(p.flag.by)}:{}})}return h}const hj=new RegExp("`([^`\\s]+/[^`\\s]+)`|(?:^|[\\s(])/?((?:[\\w.-]+/)+[\\w.-]+)","gm");function Yp(e){const t=new Set;for(const s of e.matchAll(hj))t.add((s[1]??s[2]).replace(/^\.?\//,"").replace(/[.,;:]+$/,""));return[...t]}const fj=[{level:"high",label:"High risk"},{level:"medium",label:"Medium risk"},{level:"low",label:"Low risk"},{level:"none",label:"No category"}];function mj(e){return fj.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 pj=1/3;function oa(e,t=Date.now()){const s=e.expiresAt-t;return s<=0?"expired":s<=e.ttlMs*pj?"stalled":"live"}function gj(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 vj=e=>e.urgency==="fyi"||e.kind==="policy";function kj(e){const t=e.filter(([s,o])=>Zo.includes(s)&&wp(o));return Object.fromEntries(t)}const nm=e=>Number(e.slice(0,2))*60+Number(e.slice(3,5));function yj(e,t){const s=new Date(t),o=s.getHours()*60+s.getMinutes(),a=nm(e.from),c=nm(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 wj(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 xj(e,t){const s=e.focusUntil??0;if(s>t)return{kind:"manual",until:s};if(!e.focus||!yj(e.focus,t))return{kind:"off"};const o=wj(e.focus,t);return(e.focusOffUntil??0)>t?{kind:"paused",until:o}:{kind:"hours",until:o}}function jj(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=xj(o,s);return a.kind==="hours"?{...o,focusOffUntil:a.until}:o}default:return t}}const Sj=e=>({id:e.id,key:e.key,title:e.title,...e.archived?{archived:!0}:{}});function Nj(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 bj(e,t,s){const o=Date.now();return{id:e,key:t,...s,state:"open",blockedBy:[],comments:[],createdAt:o,updatedAt:o}}const Cj=(e,t)=>({...e,blockedBy:e.blockedBy.filter(s=>s!==t)}),$j=(e,t)=>{var s;return{...e,...(s=t.title)!=null&&s.trim()?{title:t.title.trim()}:{},...t.body!==void 0?{body:t.body}:{}}};function Tj(e){const{closeReason:t,closedAt:s,...o}=e;return{...o,state:"open"}}const Ej=["status","verification","checks","reviewOf","guide"];function Aj(e,t){const s={...e};for(const o of Ej)t[o]!==void 0&&(t[o]===null?delete s[o]:s[o]=t[o]);return t.confirm&&delete s.settingsUnconfirmed,s}function Ij(e,t){const s={...e};return t?s.archived=!0:delete s.archived,s}async function Jp(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(ke(ra(await e.read(a)).front.key).replace(/\D/g,""))||0));return Math.max(0,...s,...o)+1}const Xp="### [^\\n]* @ \\d{4}-\\d\\d-\\d\\dT",Zp=`## Comments\\s*$|${Xp}`,eg=`<!-- ${te.labelPrefix}:comments -->`,Mj=new RegExp(`^## Comments[ \\t]*\\n${eg}[ \\t]*$`,"m"),Rj=new RegExp(`^(?=${Xp})### `,"m"),vu=2,tg=e=>ta(ea(e,Zp)),sm=e=>Po(Us(e),Zp);function Lj(e,t){const s=(t>=vu?Mj:/^## Comments\s*$/m).exec(e);return s?[e.slice(0,s.index),e.slice(s.index+s[0].length)]:[e,""]}function im(e){const{front:t,body:s}=ra(e),o=Number(ke(t.format))||1,[a,c]=Lj(s,o),d=c.split(o>=vu?Rj:/^### /m).slice(1).map((k,v)=>{const x=k.indexOf(`
114
+ `),j=k.slice(0,x),b=j.lastIndexOf(" @ ");return{id:`c${v}`,author:j.slice(0,b<0?void 0:b).trim(),createdAt:b>=0&&Date.parse(j.slice(b+3))||0,body:sm(k.slice(x+1).trim())}}),h=ke(t.close_reason),m=qy.find(k=>k===ke(t.status)),p=kp(ke(t.verification));return{id:ke(t.id),key:`#${ke(t.id)}`,title:ke(t.title),type:ke(t.type)||"task",hitl:Vt(t.labels).includes(cu)||void 0,state:ke(t.state)==="closed"?"closed":"open",closeReason:h==="completed"||h==="not_planned"?h:void 0,assignee:ke(t.assignee)||void 0,...m?{status:m}:{},...p?{verification:p}:{},...t.checks!==void 0?{checks:Vt(t.checks)}:{},...ke(t.review_of)?{reviewOf:ke(t.review_of)}:{},...ke(t.guide)?{guide:ke(t.guide)}:{},blockedBy:Vt(t.blocked_by),body:sm(a.trim()),comments:d,createdAt:Ws(t.created),updatedAt:Ws(t.updated),closedAt:Ws(t.closed)||void 0}}function ng(e){const t={id:e.id,format:String(vu),title:e.title,type:e.type,labels:[Xo(e.type),...Wy(e.type)&&e.hitl?[cu]:[]],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:on(e.createdAt),updated:on(e.updatedAt),...e.closedAt?{closed:on(e.closedAt)}:{}},s=e.comments.length?`
115
+
116
+ ## Comments
117
+ ${eg}
118
+
119
+ ${e.comments.map(Oj).join(`
120
+
121
+ `)}`:"";return mu(t,tg(e.body)+s)}function Oj(e){return`### ${Hs(e.author)} @ ${on(e.createdAt)}
122
+
123
+ ${tg(e.body)}`}async function Pj(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 _j(e,t,s){const o=await Jp(e),a=bj(String(o),`#${o}`,s);return{path:`${t}/tickets/${a.id}.md`,text:ng({...a,updatedAt:Date.now()}),value:a}}async function Dj(e,t,s){const o=(await e.list()).filter(d=>d.includes("/decisions/")),a=Math.max(0,...o.map(d=>Xw(d.split("/").pop())))+1,c=Jw(`D-${a}`,t,s);return{path:`${t}/decisions/${c.id}.md`,text:Up(c),value:c}}const zj=/^([^/]+)\/decisions\/([^/]+)\.md$/,Bj=(e,t)=>e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,40)||`map-${t}`,sg=/^[A-Za-z0-9][A-Za-z0-9_-]*(?:\.[A-Za-z0-9_-]+)*$/;function cs(e){if(typeof e!="string"||e.length>128||!sg.test(e))throw new Error(`not a valid id: ${JSON.stringify(e)}`);return e}const Fj=e=>{const t=e.match(/^[^/]+\/tickets\/([^/]+)\.md$/);return!!t&&sg.test(t[1])};class Uj{constructor(t,s){le(this,"seen",new Map);le(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=>zj.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=Fc(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 Wj(e){const t=ke(e["model-matching"]);if(t!=="on"&&t!=="off")return;const s=kj(Vt(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 Hj(e){if(!e)return{};const t=Object.entries(e.tiers??{}).map(([s,o])=>`${s}=${o}`);return{"model-matching":e.enabled?"on":"off",...t.length?{"model-tiers":t}:{}}}function rm(e,t){const{front:s,body:o}=ra(t),a=kp(ke(s.verification)),c=Wj(s);return{id:e,key:ke(s.key)||e,title:ke(s.title)||e,mode:ke(s.mode)==="plan-only"||Vt(s.labels).includes(uu)?"plan-only":ds,...a?{verification:a}:{},...Vt(s.guides).length?{guides:Vt(s.guides)}:{},...c?{modelMatching:c}:{},...ke(s.archived)==="true"?{archived:!0}:{},sections:Aw(o),createdAt:Ws(s.created),updatedAt:Ws(s.updated)}}function Kj(e){var t;return mu({key:e.key,title:e.title,mode:e.mode,...e.verification?{verification:e.verification}:{},...(t=e.guides)!=null&&t.length?{guides:e.guides}:{},...Hj(e.modelMatching),...e.archived?{archived:"true"}:{},labels:[lu,...e.mode==="plan-only"?[uu]:[]],created:on(e.createdAt),updated:on(e.updatedAt)},Ew(e.sections))}function Vj(e,t){t.code!=="ENOENT"&&console.warn(`Teamtrail: decision ${e} can't be read: ${t.message}`)}class Gj{constructor(t,s=`./${te.dataDir}`){le(this,"kind","markdown");le(this,"label","Local markdown");le(this,"events",new Ks);le(this,"selfWrites",new Map);le(this,"external",new Uj(t=>this.fs.read(t),t=>this.events.emit(t)));le(this,"ticketPath",(t,s)=>`${cs(t)}/tickets/${cs(s)}.md`);le(this,"setMapArchived",(t,s)=>this.editMap(t,o=>Ij(o,s),{kind:"map.updated",mapId:t,at:Date.now()}));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 Pj(this.fs,t,s=>this.selfWrites.set(s,Date.now()))}async readMap(t){return rm(t,await this.fs.read(`${cs(t)}/map.md`))}async writeMap(t,s){await this.put(`${cs(t.id)}/map.md`,Kj(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=>Sj(await this.readMap(o))))}async loadMap(t){const s=await this.fs.list(),o=await this.readMap(t),a=s.filter(d=>d.startsWith(`${t}/tickets/`)&&Fj(d)),c=await Promise.all(a.map(async d=>im(await this.fs.read(d))));return{map:o,tickets:c.sort((d,h)=>d.createdAt-h.createdAt)}}async createMap(t){const s=await Jp(this.fs),o=Bj(t.title,s),a={id:o,key:`#${s}`,title:t.title,mode:t.mode??ds,...t.verification?{verification:t.verification}:{},sections:t.sections,createdAt:Date.now(),updatedAt:Date.now()};return await this.writeMap(a),this.events.emit({kind:"map.created",mapId:o,at:Date.now()}),a}async editMap(t,s,o){const a=await this.fs.read(`${cs(t)}/map.md`);await this.writeMap({...s(rm(t,a)),updatedAt:Date.now()},a),this.events.emit(o)}setMapMode(t,s){return this.editMap(t,o=>({...o,mode:s}),{kind:"map.mode",mapId:t,mode:s,at:Date.now()})}setMapMeta(t,s){return this.editMap(t,o=>Nj(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(()=>_j(this.fs,t,s));return this.events.emit({kind:"ticket.created",mapId:t,ticketId:o.id,at:Date.now()}),o}async addBlocking(t,s,o){await this.update(t,o,a=>a.blockedBy.includes(s)?a:{...a,blockedBy:[...a.blockedBy,s]}),this.events.emit({kind:"edge.added",mapId:t,blockerId:s,blockedId:o,at:Date.now()})}async update(t,s,o){const a=await this.fs.read(this.ticketPath(t,s)),c=im(a),d=o(c);d!==c&&await this.put(this.ticketPath(t,c.id),ng({...d,updatedAt:Date.now()}),a)}async removeBlocking(t,s,o){await this.update(t,o,a=>Cj(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=>$j(a,o)),this.events.emit({kind:"ticket.updated",mapId:t,ticketId:s,at:Date.now()})}async reopen(t,s){await this.update(t,s,Tj),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=>Aj(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=>Vj(a,h));if(!c)return;const d={...Fc(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 Dj(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=Up({...Fc(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 om extends Error{constructor(t,s,o,a){super(s),this.code=t,this.status=o,this.resetAt=a,this.name="TrackerError"}}const qj={github:"GitHub Issues",linear:"Linear"};async function xt(e,t,s){let o;try{o=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:s===void 0?void 0:JSON.stringify(s)})}catch{throw new om("offline","Lookout server unreachable; is `teamtrail` still running?")}const a=await o.json().catch(()=>({}));if(!o.ok)throw new om(a.code??"http",a.error??`request failed (${o.status})`,o.status,a.resetAt);return a}class Qj{constructor(t,s,o=""){le(this,"label");le(this,"location");le(this,"status",{state:"connecting",queued:0});le(this,"events",new Ks);le(this,"statusEvents",new Ks);le(this,"source");le(this,"listeners",0);le(this,"openEvents",t=>new EventSource(`${this.base}${t}`));le(this,"listMaps",()=>this.call("listMaps"));le(this,"loadMap",t=>this.call("loadMap",t));le(this,"createMap",t=>this.call("createMap",t));le(this,"setMapMode",(t,s)=>this.call("setMapMode",t,s));le(this,"setMapArchived",(t,s)=>this.call("setMapArchived",t,s));le(this,"setMapMeta",(t,s)=>this.call("setMapMeta",t,s));le(this,"updateMapSections",(t,s)=>this.call("updateMapSections",t,s));le(this,"createTicket",(t,s)=>this.call("createTicket",t,s));le(this,"addBlocking",(t,s,o)=>this.call("addBlocking",t,s,o));le(this,"removeBlocking",(t,s,o)=>this.call("removeBlocking",t,s,o));le(this,"editTicket",(t,s,o)=>this.call("editTicket",t,s,o));le(this,"reopen",(t,s)=>this.call("reopen",t,s));le(this,"assign",(t,s,o)=>this.call("assign",t,s,o));le(this,"comment",(t,s,o,a)=>this.call("comment",t,s,o,a));le(this,"close",(t,s,o)=>this.call("close",t,s,o));le(this,"setMeta",(t,s,o)=>this.call("setMeta",t,s,o));le(this,"listDecisions",t=>this.call("listDecisions",t));le(this,"createDecision",(t,s)=>this.call("createDecision",t,s));le(this,"markSuperseded",(t,s,o)=>this.call("markSuperseded",t,s,o));this.kind=t,this.base=s,this.label=qj[t],this.location=o}async call(t,...s){return(await xt(`${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 Yj(e){return{get:()=>xt(`${e}/trackers`,"GET"),test:t=>xt(`${e}/trackers/test`,"POST",t),connect:t=>xt(`${e}/trackers`,"PUT",t),forget:t=>xt(`${e}/trackers/credentials/${t}`,"DELETE"),githubRepos:()=>xt(`${e}/trackers/github/repos`,"GET"),githubSignIn:{start:()=>xt(`${e}/trackers/github/sign-in/start`,"POST"),poll:()=>xt(`${e}/trackers/github/sign-in/poll`,"POST"),cancel:()=>xt(`${e}/trackers/github/sign-in/cancel`,"POST"),signOut:()=>xt(`${e}/trackers/github/sign-in`,"DELETE")},linearTeams:t=>t?xt(`${e}/trackers/linear/teams`,"POST",{apiKey:t}):xt(`${e}/trackers/linear/teams`,"GET"),linearProjects:(t,s)=>s?xt(`${e}/trackers/linear/projects`,"POST",{apiKey:s,teamId:t}):xt(`${e}/trackers/linear/projects?team=${encodeURIComponent(t)}`,"GET")}}const Jj=[{id:"markdown",name:"Local markdown",status:"available"},{id:"github",name:"GitHub Issues",status:"available"},{id:"linear",name:"Linear",status:"available"}],ig=[{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"}],Xj=ig[0],Zj="https://github.com/teamtrailhq/teamtrail-guides",e0="https://raw.githubusercontent.com/teamtrailhq/teamtrail-guides/main",t0=`${Zj}/blob/main/CONTRIBUTING.md`,n0=e=>e.slice(0,9),s0=/[a-z][\w+.-]*:\/\/(?!(localhost|127\.0\.0\.1)(:\d+)?(\/|$|\s))/i,i0=/^[\w.-]+@[\w.-]+:/,r0=/^(@[\w.-]+\/)?[\w./-]+@[\w^~<>=*.-]+$/,o0=/(^|=)(npm|jsr|github|gitlab|bitbucket|git\+[a-z]+|https?):/i,a0=/^--?(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,l0={tar:/^-[A-Za-z]*[IF]/,zip:/^-TT|^--unzip-command/,make:/^-E|^--eval/,perl:/^-[A-Za-z]*M/};function c0(e,t){var s;if(s0.test(t)||i0.test(t))return"names a remote address, so it reaches the network";if(r0.test(t)&&!t.startsWith("-"))return`names a package to download (${t})`;if(o0.test(t))return`names a package from a registry (${t})`;if(a0.test(t))return`runs a command it's given (${t.split("=")[0]})`;if((s=l0[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(u0.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 u0=/\|\s*(sh|bash|zsh|dash|ksh|fish|pwsh|node|python\d*|perl|ruby)\b|\$\(|`|;|&&|\|\||\b(curl|wget)\s/;function d0(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 h0(e,t){const s=d0(e,t);if(s)return s;for(const o of t){const a=c0(e,o);if(a)return a}}const f0=/^(-c|-e|-E|-ex|-x|-r|-command|-Command|-EncodedCommand)$|^--(eval|exec|command|expr|execute|run)(=|$)/,m0=/(^|[\s|'"=])[a-z0-9-]+(\.[a-z0-9-]+)*\.[a-z]{2,}(:\d+)?\/\S*/i;function p0(e,t){const s=e.find(o=>{var a;return f0.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=>m0.test(o)))return"names an address, so it may reach the network"}const g0=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"]),v0=new Set(["-C","--git-dir","--work-tree","--namespace","--super-prefix"]);function k0(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(v0.has(o)){s.includes("=")||t++;continue}if(s.startsWith("-"))continue;const a=s.toLowerCase();return g0.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 y0=["--require","--import","--loader","--experimental-loader","--env-file","--input-type"],am={inline:"ep",value:"rC",long:["--eval","--print"],longValue:y0},w0={node:am,nodejs:am,bun:{inline:"e",value:"r",long:["--eval","--print"]},python:{inline:"c",value:"mWXQ",long:["--command"],stop:"-m"},pypy:{inline:"c",value:"mWXQ",long:[],stop:"-m"},ruby:{inline:"e",value:"rICEx",long:[]},perl:{inline:"eEMm",value:"IxCd",long:[]},php:{inline:"rBRFE",value:"dcfz",long:[]},lua:{inline:"e",value:"l",long:[]},luajit:{inline:"e",value:"lbj",long:[]},rscript:{inline:"e",value:"",long:["--expr"]},osascript:{inline:"e",value:"sl",long:[]}};function x0(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 j0(e,t){var a;if(/^data:|=data:/i.test(e))return"code";if(!e.startsWith("--"))return x0(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 S0(e,t){const s=w0[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=j0(a,s);if(c==="code")return"runs code given inline; point at a script in the repo instead";if(c==="takes-next"&&/^data:/i.test(t[o+1]??""))return"runs code given inline";c==="takes-next"&&o++}}const lm=e=>new RegExp(`^(?![-/~\\\\])(?!.*\\.\\.)(?![a-zA-Z]:)[\\w./-]+\\.(${e})$`),Ot={},ct=e=>e.split(/\s+/).filter(Boolean),N0={npm:{sub:ct("test t run run-script")},pnpm:{sub:ct("test t run")},yarn:{sub:ct("test run")},bun:{sub:ct("test run")},make:Ot,cargo:{sub:ct("test check clippy build fmt")},go:{sub:ct("test vet build")},deno:{sub:ct("test lint check")},node:{script:lm("[cm]?[jt]s"),sub:["--test"]},python:{script:lm("py"),modules:ct("pytest unittest mypy ruff black flake8 pylint"),exempt:["-c"]},pytest:{exempt:["-c"]},ruff:{sub:ct("check format")},mypy:Ot,pyright:Ot,black:{needs:["--check"]},flake8:Ot,pylint:Ot,tsc:Ot,eslint:{exempt:["-c"]},"pa11y-ci":Ot,prettier:{needs:ct("--check -c --list-different -l")},biome:{sub:ct("check lint ci")},jest:{exempt:["-c"]},vitest:Ot,mocha:Ot,playwright:{sub:["test"]},rubocop:Ot,rspec:{exempt:["-e"]},phpunit:Ot,phpstan:Ot,"golangci-lint":{sub:["run"]},swift:{sub:ct("test build")},dotnet:{sub:ct("test build")},mvn:{sub:ct("test verify compile")},gradle:{sub:ct("test check build")},gradlew:{sub:ct("test check build")},git:{sub:["diff"]}},b0=/^(\.\/)?node_modules\/\.bin\/([\w.-]+)$/;function C0(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 rg(e){var o;const t=(o=b0.exec(e.argv0))==null?void 0:o[2],s=N0[t??e.program];return s&&C0(s,e.args)?s:void 0}const $0=e=>!!rg(e),aa=e=>new Set(e.split(/\s+/).filter(Boolean)),T0=aa(`
124
+ sh bash zsh fish dash ksh mksh pdksh csh tcsh ash yash nu nushell xonsh elvish osh oil rc es ion
125
+ cmd powershell pwsh
126
+ `),E0=aa(`
127
+ curl wget nc ncat netcat socat telnet scp sftp ssh ssh-keyscan rsync ftp tftp aria2c websocat
128
+ openssl dig nslookup host ping ping6 traceroute whois nmap gh aws gcloud az kubectl
129
+ `),A0=aa("npx pnpx bunx uvx uv pipx docker podman nix nix-shell nix-env flatpak snap"),I0=aa(`
130
+ env xargs sudo doas su nohup nice ionice time timeout watch stdbuf chroot setsid caffeinate arch flock unbuffer
131
+ chronic firejail systemd-run strace ltrace gdb lldb exec eval command busybox toybox parallel script
132
+ awk gawk mawk nawk sed gsed vim nvim vi ex emacs expect
133
+ `),bo=["exec","x","dlx","install","i","add","ci","create","init","update","upgrade"],M0={npm:new Set(bo),pnpm:new Set(bo),yarn:new Set(bo),bun:new Set(bo),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 R0(e){const t=(e.split(/[\\/]/).pop()??"").toLowerCase().replace(/\.(exe|cmd|bat|com)$/,"");return t.replace(new RegExp("(?<=[a-z])[\\d.-]+$"),"")||t}const L0=e=>{var t;return((t=e.find(s=>!s.startsWith("-")))==null?void 0:t.toLowerCase())??""};function cm(e){const t=e.findIndex(s=>s.startsWith("-m"));if(!(t<0))return e[t]==="-m"?e[t+1]:e[t].slice(2)}const O0=new Set(["pip","ensurepip","pipx","uv","venv","http.server","webbrowser"]);function P0(e,t){var o;if(T0.has(e))return`runs a shell (${e}); name the program and its arguments instead`;if(E0.has(e))return`runs ${e}, which reaches the network`;if(A0.has(e))return`runs ${e}, which downloads and runs a package; use one installed in the repo`;if(I0.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=L0(t);if((o=M0[e])!=null&&o.has(s))return`runs ${e} ${s}, which downloads packages; use one installed in the repo`;if(e==="python"&&O0.has(cm(t)??""))return`runs python -m ${cm(t)}, which downloads or serves`;if(e==="find"&&t.some(a=>/^-(exec|execdir|ok|okdir|delete)$/.test(a)))return"runs find with -exec or -delete, which runs or removes other things"}function og(e){const t=e.run[0]??"";return{argv0:t,program:R0(t),args:e.run.slice(1)}}function _0(e){const{argv0:t,program:s,args:o}=og(e),a=rg({argv0:t,program:s,args:o}),c=[P0(s,o),S0(s,o),s==="git"?k0(o):void 0,h0(s,o),p0(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 D0="unknown program: Teamtrail can't tell what this runs";function z0(e){if(_0(e).length)return;const{argv0:t,program:s,args:o}=og(e);return $0({argv0:t,program:s,args:o})?void 0:D0}function B0(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))})}function F0(e){return[`<path d="M24 210Q26 162 72 152H150Q190 158 192 210Z" fill="${e.shell}"/>`,`<path d="M24 210Q26 162 72 152H84Q58 166 58 210Z" fill="${e.shade}"/>`,`<path d="M66 154Q108 160 160 154L156 162Q108 168 70 162Z" fill="${e.side}"/>`,`<path d="M88 152L122 196L156 152Z" fill="${e.orange}"/>`,`<path d="M88 152L122 196L112 152Z" fill="${e.orangeDark}"/>`,`<circle cx="122" cy="161" r="8" fill="${e.orangeDark}"/><circle cx="124" cy="159" r="3" fill="${e.orange}"/>`].join("")}const yc={x:112,w:15},wc={x:136,w:10};function um({x:e,w:t},s,o,a){const c=e+s;return[`<rect x="${c}" y="${94+o}" width="${t}" height="12" rx="${t>12?5:4}" fill="${a.glowLight}"/>`,`<rect x="${c}" y="${100+o}" width="${t}" height="6" rx="3" fill="${a.glow}"/>`,`<rect x="${c+t-6}" y="${96+o}" width="${t>12?3.5:2.5}" height="3.5" rx="1" fill="#fff"/>`].join("")}function dm({x:e,w:t},s){const o=t+3,a=t>12?6:5;return`<rect x="${e-2}" y="90" width="${o}" height="18" rx="${o/2.6}" fill="${s.glowLight}"/><rect x="${e-2+(o-a)/2}" y="96" width="${a}" height="6" rx="2" fill="${s.glass}"/>`}function U0(e,t){if(e==="closed")return[yc,wc].map(({x:a,w:c})=>`<rect x="${a}" y="100" width="${c}" height="4" rx="2" fill="${t.glow}"/>`).join("");if(e==="wide")return dm(yc,t)+dm(wc,t);const[s,o]=e==="aside"?[4,-5]:[0,0];return um(yc,s,o,t)+um(wc,s,o,t)}function W0(e,t){return e==="open"?`<rect x="124" y="114" width="16" height="9" rx="4.5" fill="${t.glowLight}"/><rect x="127" y="119" width="10" height="4" rx="2" fill="${t.glow}"/>`:e==="mid"?`<rect x="126" y="115" width="12" height="5" rx="2.5" fill="${t.glowLight}"/>`:e==="aside"?[0,1,2].map(s=>`<circle cx="${124+s*7}" cy="118" r="2.6" fill="${t.glow}"/>`).join(""):`<path d="M125 116q6 5 12 0" fill="none" stroke="${t.glow}" stroke-width="4" stroke-linecap="round"/>`}function H0({eyes:e,mouth:t},s){return U0(e,s)+W0(t,s)}function K0(e){return{shine:'<path d="M92 82h22l-14 20h-8z" fill="#fff" opacity=".08"/>',chin:[`<circle cx="100" cy="142" r="3" fill="${e.orange}"/>`,`<circle cx="109" cy="142" r="3" fill="${e.orangeDark}"/>`,[132,141,150].map(t=>`<rect x="${t}" y="139" width="5" height="7" rx="1.5" fill="${e.shellLight}"/>`).join("")].join(""),pine:`<path d="M125 42l8 11h-4l7 10h-22l7-10h-4z" fill="${e.hat}"/>`}}function V0(e,t,s,o){return[`<path d="M86 34L80 16" stroke="${o.band}" stroke-width="${s?6:4}" stroke-linecap="round"/>`,t?`<circle cx="79" cy="14" r="11" fill="${e}" opacity=".3"/>`:"",`<circle cx="79" cy="14" r="${s?8:6}" fill="${e}"/>`,t?'<circle cx="77" cy="12" r="2" fill="#fff3c4"/>':""].join("")}function G0({face:e,lamp:t,lit:s,simple:o,c:a}){const c=K0(a);return['<rect x="36" y="66" width="118" height="94" rx="22" fill="#000" opacity=".12"/>',`<path d="M50 96Q46 52 96 46" fill="none" stroke="${a.band}" stroke-width="8" stroke-linecap="round"/>`,`<path d="M44 78Q44 62 60 60L74 58V152L60 150Q44 148 44 132Z" fill="${a.side}"/>`,`<rect x="68" y="56" width="98" height="96" rx="20" fill="${a.shell}"/>`,`<rect x="72" y="60" width="8" height="84" rx="4" fill="${a.shellLight}"/>`,`<path d="M68 132H166V140Q166 152 152 152H82Q68 152 68 140Z" fill="${a.shade}"/>`,`<rect x="82" y="72" width="76" height="62" rx="16" fill="${a.frame}"/>`,`<rect x="86" y="76" width="70" height="55" rx="13" fill="${a.glass}"/>`,o?"":c.shine,e,o?"":c.chin,`<ellipse cx="50" cy="108" rx="13" ry="21" fill="${a.orangeDark}"/>`,`<ellipse cx="56" cy="108" rx="12" ry="20" fill="${a.orange}"/>`,`<ellipse cx="53" cy="104" rx="4" ry="11" fill="${a.orangeLight}"/>`,`<path d="M60 122Q64 146 88 148" fill="none" stroke="${a.band}" stroke-width="5" stroke-linecap="round"/>`,`<circle cx="90" cy="148" r="6" fill="${a.band}"/><circle cx="91.5" cy="146.5" r="2" fill="${a.orange}"/>`,V0(t,s,o,a),`<path d="M48 76Q46 30 104 28Q158 30 162 70Z" fill="${a.hat}"/>`,`<path d="M48 76Q46 34 88 29Q66 42 66 74Z" fill="${a.hatDark}"/>`,`<path d="M96 70Q96 40 126 36Q152 40 154 68Z" fill="${a.panel}"/>`,o?"":c.pine,`<path d="M150 82Q120 76 66 84L58 80Q56 72 64 70Q122 62 180 70Q190 76 182 84Z" fill="${a.brim}"/>`,'<path d="M70 84Q120 78 166 84L166 90Q120 84 70 90Z" fill="#000" opacity=".22"/>'].join("")}const q0={ground:"#4f8a48",groundLight:"#5d9a55",shell:"#eee7d3",shellLight:"#faf6ea",shade:"#c9bfa2",side:"#b3a98c",frame:"#a99f83",glass:"#13231e",glow:"#6fd197",glowLight:"#c2f2cf",orange:"#e07a2f",orangeLight:"#f29a55",orangeDark:"#a8481c",hat:"#8a5a38",hatDark:"#6b4630",brim:"#5a3a26",panel:"#ece2c6",band:"#3a4a43"},ag={on:"#ffb347",dim:"#a8501c",alert:"#ff5a48"},Q0={on:"#ffd166",dim:"#a8501c",alert:"#ff5a48"},Y0={circle:100,rounded:46,square:0},J0=.94;let X0=0;function Z0(e,{lamp:t=ag,simple:s=!1,shape:o="circle",colors:a=q0}={}){const c=a,d=e.light??"on",h=o==="circle"?J0:1,m=100*(1-h),p=`scout-clip-${++X0}`,k=G0({face:H0(e,c),lamp:t[d],lit:d!=="dim",simple:s,c});return[`<defs><clipPath id="${p}"><rect width="200" height="200" rx="${Y0[o]}"/></clipPath></defs>`,`<g clip-path="url(#${p})">`,`<rect width="200" height="200" fill="${c.ground}"/>`,`<circle cx="120" cy="88" r="74" fill="${c.groundLight}"/>`,`<g transform="translate(${m} ${m}) scale(${h})">${F0(c)}${k}</g>`,"</g>"].join("")}const lg={crt:{id:"crt",name:"Day",blurb:"Scout looking to the side: a cap, a headset with a mic, an antenna lamp and a neckerchief.",lamp:ag,wave:{bar:"#6f8a78",lead:"#c8581e"}},night:{id:"night",name:"Night",blurb:"The same Scout, with the antenna lamp burning brighter, for the night theme.",lamp:Q0,wave:{bar:"#66828d",lead:"#e8833a"}}},eS="crt",tS={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"}},nS={idle:"WATCHING",speaking:"TALKING",alert:"NEEDS YOU",thinking:"THINKING"},yn={msPerChar:55,mouthHoldMs:110,blinkEveryMs:5600,blinkMs:140,thinkingStepMs:520};function sS(e){return e?/[aeiouy]/i.test(e)?"open":/[a-z0-9]/i.test(e)?"mid":"rest":"rest"}function iS(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 rS(e,t,s){return Array.from({length:s},(o,a)=>{const c=t-(s-1-a);return c>=0&&c<e.length?iS(e[c],c):0})}function cg({face:e={eyes:"open",mouth:"rest"},variant:t="crt",size:s,simple:o,shape:a="circle",className:c}){const{eyes:d,mouth:h,light:m}=e,p=y.useMemo(()=>Z0({eyes:d,mouth:h,light:m},{lamp:lg[t].lamp,simple:o??s<40,shape:a}),[d,h,m,t,o,s,a]);return i.jsx("svg",{className:c,width:s,height:s,viewBox:"0 0 200 200","aria-hidden":"true",dangerouslySetInnerHTML:{__html:p}})}function oS(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),yn.blinkMs)},yn.blinkEveryMs);return()=>{clearInterval(a),o&&clearTimeout(o)}},[e]),t}const aS={xs:.8,sm:2,md:4,lg:6},lS=40,hm=20,fm="(prefers-reduced-motion: reduce)",cS=40,uS=350;function dS(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 hS=e=>e.length*yn.msPerChar,fS=(e,t)=>t&&(e.effective==="idle"||e.effective==="speaking"||e.effective==="alert");function mS(e,t,s,o){const a=tS[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/yn.msPerChar));const p=Math.floor(t/yn.mouthHoldMs)*Math.round(yn.mouthHoldMs/yn.msPerChar);d=sS(e.text[Math.min(e.text.length-1,p)])}let m=a.light;return e.effective==="thinking"&&!e.reduced&&Math.floor(t/yn.thinkingStepMs)%2===1&&(m="on"),{eyes:c,mouth:d,light:m,cursor:h}}function pS(e,t){const s=typeof e.size=="number"?e.size:aS[e.size],o=e.reduced?Math.min(e.text.length-1,hm-1):t;return{base:s,px:lS*s,bars:hm,waveCursor:o}}function gS(e,{label:t,speechDone:s,cursor:o,caption:a}){const c=e.talking&&s?"idle":e.effective,d=nS[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:vS(e,s,o)}}function vS(e,t,s){return e.talking?e.reduced||t?e.text:e.text.slice(0,s+1):""}function kS(){const[e,t]=y.useState(()=>{var s;return typeof window<"u"&&!!((s=window.matchMedia)!=null&&s.call(window,fm).matches)});return y.useEffect(()=>{var a;const s=(a=window.matchMedia)==null?void 0:a.call(window,fm);if(!s)return;const o=()=>t(s.matches);return o(),s.addEventListener("change",o),()=>s.removeEventListener("change",o)},[]),e}function yS(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 wS(e){const{key:t,talking:s,at:o}=e,a=o!==void 0,c=hS(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+uS);return()=>clearTimeout(j)},[s,t,c,a]);const p=s&&d!==t,k=yS(t,e.animate&&(p||e.thinking),p?cS:yn.thinkingStepMs),v=o??k,x=s&&(a?v>=c:d===t);return{t:v,speechDone:x}}const xS=e=>e*2,Kc=3.5;function jS(e,t,s){return(e??[]).map((o,a)=>{const c=(1+2*o)*.5;return{x:a*2,y:(Kc-c)/2,width:1,height:c,fill:a>=t-2&&o>0?s.lead:s.bar}})}function SS({heights:e,bars:t,unit:s,colors:o}){const a=xS(t);return i.jsx("svg",{className:`scout-wave${e?" on":""}`,width:a*s,height:Kc*s,viewBox:`0 0 ${a} ${Kc}`,"aria-hidden":"true",children:jS(e,t,o).map((c,d)=>i.jsx("rect",{...c},d))})}function ku({state:e="idle",size:t="md",speaking:s,variant:o=eS,framed:a,caption:c,label:d="Scout",onSpeakEnd:h,at:m,className:p,style:k}){const v=dS({state:e,size:t,speaking:s,framed:a},kS()),{text:x,effective:j,talking:b,reduced:S}=v,I=lg[o],O=!S&&!(m!==void 0),R=`${j}|${o}|${x}`,{t:z,speechDone:Z}=wS({key:R,text:x,talking:b,thinking:j==="thinking",animate:O,at:m,onSpeakEnd:h}),q=oS(fS(v,O)),H=b&&!Z,{eyes:re,mouth:Q,light:ve,cursor:ze}=mS(v,z,q,H),{base:$e,px:se,bars:D,waveCursor:J}=pS(v,ze),X=y.useMemo(()=>H?rS(x,J,D):null,[H,x,J,D]),{shownState:ce,status:K,ariaLabel:Y,showCaption:F,shown:T}=gS(v,{label:d,speechDone:Z,cursor:ze,caption:c}),_={...k,"--scout-u":`${$e}px`},ue=i.jsx("span",{className:"scout-sprite",children:i.jsx(cg,{face:{eyes:re,mouth:Q,light:ve},variant:o,size:se,simple:v.mini})});return v.framed?i.jsxs("figure",{className:`scout scout-panel scout-${ce} scout-v-${o} ${p??""}`,style:_,"data-state":ce,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(SS,{heights:X,bars:D,unit:$e,colors:I.wave})]}),F&&i.jsxs("p",{className:"scout-caption","aria-hidden":"true",children:[T,b&&!Z&&!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-${ce} ${p??""}`,style:_,role:"img","aria-label":Y,children:ue})}const jt="trail lead";function NS({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,jt,{via:"lookout"}),claim:m=>t("Claim",()=>Gf(e.adapter,o.current,m,{...h,assignee:jt})),release:m=>t("Release claim",()=>Ww(e.adapter,o.current,m,{...h,actor:jt})),releaseLease:m=>t("Release to queue",()=>e.leases.release(o.current,m,jt)),resolve:(m,p,k={})=>t("Resolve · record answer",async()=>{var x;const v=(x=a.current)==null?void 0:x.tickets.find(j=>j.id===m);v&&!v.assignee&&await Gf(e.adapter,o.current,m,{...h,assignee:jt}),await ex(e.adapter,o.current,m,{...h,answer:p,author:jt,decision:{...k,source:{kind:"lookout",label:"Ticket inspector"}}})}),supersede:(m,p)=>t(`Supersede ${m.id}`,async()=>{let k=m.id;if(m.derived){const{id:v,mapId:x,derived:j,supersededBy:b,...S}=m;k=(await fu(e.adapter,m.mapId,S,{appendToTrail:!1})).id}await Gw(e.adapter,m.mapId,k,{...p,decidedBy:jt,participants:[{id:jt}],source:{kind:"lookout",label:"Logbook"}})}),graduate:({unspecified:m,...p})=>t(`Promote to ticket · ${m}`,async()=>{const k=await nx(e.adapter,o.current,m,p);d({kind:"ticket",id:k.id})}),ruleOut:(m,p)=>t("Rule out of scope",async()=>{await sx(e.adapter,o.current,m,{...h,reason:p,author:jt,source:{kind:"lookout",label:"Ticket inspector"}}),d(null)}),setArchived:m=>t(m?"Archive trail":"Restore trail",async()=>{await ax(e.adapter,o.current,m),m&&s(void 0)}),setMode:m=>t(`Trail mode · ${m}`,()=>qw(e.adapter,o.current,m)),setModelMatching:m=>t(`Model matching · ${m.enabled?"on":"off"}`,()=>ix(e.adapter,o.current,m))}}const Ve=(...e)=>e.filter(Boolean).join(" "),Vs="item",bS=/^[0-9a-f]{6,64}$/;function ar(){const e=new URLSearchParams(location.search).get("project")??void 0;return e&&bS.test(e)?e:void 0}function je(e=ar()){return e?`${te.apiPrefix}/p/${e}`:te.apiPrefix}function CS(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 $S(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 Mw(e,{title:t.title,sections:{destination:t.destination,notes:t.notes,decisions:[],unspecified:[],outOfScope:[],...s.length?{assumptions:s}:{}},tickets:[{ref:"discovery",...tj}]});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 ug(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 un(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 dg(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),yu=e=>new Date(e).toTimeString().slice(0,5),TS=e=>`${qs(e)} ${yu(e)}`,hg=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`},lr=e=>e?new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",tr={research:"Research",prototype:"Prototype",junction:"Junction",task:"Task",execute:"Execute",review:"Review"},fg={decided:"Done",claimed:"Working",frontier:"Ready",blocked:"Backlog",parked:"Parked (plan-only)","out-of-scope":"Cancelled",verifying:"Verifying",rework:"Rework",held:"Blocked"},ES={decided:"done",claimed:"working",frontier:"ready",blocked:"backlog",parked:"parked","out-of-scope":"cancelled",verifying:"verifying",rework:"rework",held:"blocked"};function wu(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 AS=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]),tn=(e,t)=>e>>>t|e<<32-t;function IS(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 MS(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=tn(o[x-15],7)^tn(o[x-15],18)^o[x-15]>>>3,b=tn(o[x-2],17)^tn(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,k,v]=e;for(let x=0;x<64;x++){const j=v+(tn(m,6)^tn(m,11)^tn(m,25))+(m&p^~m&k)+AS[x]+o[x]>>>0,b=(tn(a,2)^tn(a,13)^tn(a,22))+(a&c^a&d^c&d)>>>0;[v,k,p,m,h,d,c,a]=[k,p,m,h+j>>>0,d,c,a,j+b>>>0]}[a,c,d,h,m,p,k,v].forEach((x,j)=>e[j]=e[j]+x>>>0)}function xc(e){const t=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),s=IS(e),o=new DataView(s.buffer),a=new Uint32Array(64);for(let h=0;h<s.length;h+=64)MS(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 RS(e,t){const s=new Uint8Array(64);s.set(e.length>64?xc(e):e);const o=new Uint8Array(64+t.length),a=new Uint8Array(96);for(let c=0;c<64;c++)o[c]=s[c]^54,a[c]=s[c]^92;return o.set(t,64),a.set(xc(o),64),xc(a)}const mg=e=>Array.from(e,t=>t.toString(16).padStart(2,"0")).join(""),LS=e=>new Uint8Array((e.match(/../g)??[]).map(t=>parseInt(t,16))),xu=`${te.slug}.session`;let Do;const OS=e=>{const t=e;return!!t&&typeof t.id=="string"&&typeof t.secret=="string"&&typeof t.verifier=="string"};function ju(){try{const e=JSON.parse(localStorage.getItem(xu)??"null");return OS(e)?e:Do}catch{return Do}}function PS(e){Do=e;try{localStorage.setItem(xu,JSON.stringify(e))}catch{}}function pg(){Do=void 0;try{localStorage.removeItem(xu)}catch{}}let Su="unproven",jc;const Vc=new Set,gg=e=>{Su=e;for(const t of Vc)t(e)};function _S(e){return Vc.add(e),()=>void Vc.delete(e)}const DS=()=>Su==="proven",zS=()=>Su==="proven"&&gg("unproven");function BS(){const e=new Uint8Array(16);return crypto.getRandomValues(e),mg(e)}async function FS(){const e=ju();if(!e)return"unknown";const t=BS(),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 pg(),"unknown";const o=s!=null&&s.ok?(await s.json().catch(()=>({}))).proof:void 0,a=mg(RS(LS(e.verifier),new TextEncoder().encode(`${t}
134
+ ${location.origin}`)));return o===a?"proven":"failed"}function ua(){return jc??(jc=FS().then(e=>(jc=void 0,gg(e),e))),jc}const US=1e4;class vg{constructor(t=je(),s="/events"){le(this,"inner");le(this,"listeners",[]);le(this,"closed",!1);le(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(),zS(),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,US))}}function WS(){ua().then(e=>e==="unknown"&&location.reload())}let _t;const zo=new Set,nr=new Map,Bo=new Set,Fo=new Set;function kg(e){_t==null||_t.addEventListener(e,t=>{for(const s of nr.get(e)??[])s(t.data)})}function da(){if(!_t){_t=new vg,_t.onerror=()=>{for(const e of Fo)e();WS()},_t.addEventListener("open",()=>{for(const e of Bo)e()}),_t.onmessage=e=>{const t=JSON.parse(e.data).path;if(typeof t=="string")for(const s of zo)s(t)};for(const e of nr.keys())kg(e)}}function ha(){const e=[...nr.values()].some(t=>t.size>0);zo.size||e||Bo.size||Fo.size||(_t==null||_t.close(),_t=void 0)}function Nu(e){return zo.add(e),da(),()=>{zo.delete(e),ha()}}function ei(e,t){let s=nr.get(e);return s||(s=new Set,nr.set(e,s),kg(e)),s.add(t),da(),()=>{s.delete(t),ha()}}function hs(e){return Bo.add(e),da(),()=>{Bo.delete(e),ha()}}function HS(e){return Fo.add(e),da(),()=>{Fo.delete(e),ha()}}const bu=(e,t)=>`${e}/${t}`;let Gt={reached:!1,live:!1,tickets:{}},Gc=!1;const qc=new Set,Qc=new Set,KS=Zs();let Yc=0;const yg=new Map;let wg=0;function Uo(e){Gt=e;for(const t of qc)t()}function VS(e,t){const s=Object.fromEntries(e.map(o=>[bu(o.mapId,o.ticketId),o]));for(const[o,a]of yg)a>t&&Gt.tickets[o]&&(s[o]=Gt.tickets[o]);return s}function mm(){const e=KS.start(),t=Yc;fetch(`${je()}/verification/sync`).then(s=>s.ok?s.json():Promise.reject()).then(s=>e()&&Uo({reached:!0,live:!0,status:wg>t?Gt.status:s.status,tickets:VS(s.tickets,t)}),()=>Gt.reached&&Uo({...Gt,live:!1}))}function GS(e){const t=JSON.parse(e);if(t.kind==="evidence")for(const a of Qc)a();if(t.kind!=="sync")return;const s=t;wg=++Yc;const o={...Gt.tickets};for(const a of s.tickets){const c=bu(a.mapId,a.ticketId);o[c]=a,yg.set(c,Yc)}Uo({reached:!0,live:!0,status:s.status,tickets:o})}function pm(){Gc=!0,ei("verification",GS),HS(()=>Gt.reached&&Gt.live&&Uo({...Gt,live:!1})),hs(mm),mm()}const Qs={subscribe(e){return Gc||pm(),qc.add(e),()=>void qc.delete(e)},get:()=>Gt,onEvidence(e){return Gc||pm(),Qc.add(e),()=>void Qc.delete(e)},ticket:(e,t,s)=>e.tickets[bu(t,s)]};function qS(e){if(e!=null&&e.flags.length)return e.flags.some(t=>t.severity==="alert")?"alert":"warn"}const gm={onboarded:!1,tracker:"markdown",hitlTranscript:"summary",agent:Xj.id,github:{repo:""},linear:{team:""},briefing:{enabled:!0,awayMinutes:15},theme:"night"};function Cu(){try{const e={...gm,...JSON.parse(localStorage.getItem(Jo)??"{}")};return["markdown","github","linear"].includes(e.tracker)||(e.tracker="markdown"),e}catch{return gm}}function xg(e){e==="auto"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e}const Sc=new Map,Nc=e=>`${je()}/file?path=${encodeURIComponent(e)}`;async function bc(e,t){const s=await e.json().catch(()=>({})),o=new Error(s.error??`${t}: ${e.status}`);return e.status===409?Object.assign(o,{stale:!0}):e.status===404?Object.assign(o,{code:"ENOENT"}):o}const QS={async list(){return(await(await fetch(`${je()}/list`)).json()).files},async read(e){const t=await fetch(Nc(e));if(!t.ok)throw await bc(t,`read ${e}`);const s=await t.text(),o=t.headers.get("ETag");return o&&Sc.set(e,{text:s,etag:o}),s},async write(e,t,s){const o=(s==null?void 0:s.base)===void 0?void 0:Sc.get(e),a=o&&o.text===(s==null?void 0:s.base)?{"If-Match":o.etag}:{},c=await fetch(Nc(e),{method:"PUT",body:t,headers:a});if(!c.ok)throw await bc(c,`write ${e}`);Sc.delete(e)},async create(e,t){const s=await fetch(Nc(e),{method:"PUT",body:t,headers:{"If-None-Match":"*"}});if(s.status===412)return!1;if(!s.ok)throw await bc(s,`create ${e}`);return!0},watch(e){return Nu(e)}},YS=15*6e4;class JS{constructor(t){le(this,"leases",[]);le(this,"changes",new Ks);le(this,"logged",new Set);le(this,"since",Date.now()-YS);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:gj(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 XS(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 ZS(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 e1(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 vm(e,t){XS(e),ZS(t),e1(e)}function km(e){const t=s=>`${Jo}:${e}:${s}`;return{get:s=>localStorage.getItem(t(s)),set:(s,o)=>{try{localStorage.setItem(t(s),o)}catch{}}}}const t1=["markdown","github","linear"];function n1(){const e=new URLSearchParams(location.search).get("tracker");return e&&t1.includes(e)?e:Cu().tracker}function s1(e){let t,s;const o=new fx,a=new JS(o),c={},d=lx(je());if(e==="github"||e==="linear"){const p=new Qj(e,je());p.openEvents=k=>new vg(je(),k),t=p,s=fetch(`${je()}/trackers`).then(k=>k.json()).catch(()=>{}).then(k=>{p.location=(e==="github"?k==null?void 0:k.github.repo:[k==null?void 0:k.linear.teamKey,k==null?void 0:k.linear.projectName].filter(Boolean).join(" · "))||p.location;const v=km(`${e}:${p.location}`);c.presence=new Yf(v),o.ledger=new Jf(v),vm(o,a)})}else t=new Gj(QS,`./${te.dataDir}`),s=fetch(`${je()}/list`).then(p=>p.json()).catch(()=>({root:"default"})).then(({root:p})=>{const k=km(p);c.presence=new Yf(k),o.ledger=new Jf(k),vm(o,a)});const h=vx(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 ln=e=>e.status==="running",jg=e=>ln(e)&&!!e.waitingOn,i1={blocking:0,soon:1,fyi:2};function r1(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=>i1[d.urgency??"soon"];return[...o].sort((d,h)=>c(d)-c(h)||d.at-h.at)[0]}function Wo(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)}`}const o1=/^slack:([A-Z0-9]+)$/i;function Gn(e,t){var c;const s=(c=o1.exec(e))==null?void 0:c[1];if(!s)return e;if(t!=null&&t.owners.some(d=>d.id===s))return"you (Slack)";const o=t==null?void 0:t.allow.find(d=>d.id===s),a=(o==null?void 0:o.realName)||(o==null?void 0:o.name);return a?`${a} (Slack)`:"Slack user"}function us({n:e,urgent:t,pop:s,hideZero:o}){return i.jsx("span",{className:Ve("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:Ve("btn",e!=="default"&&e,t==="sm"&&"sm",s&&"on",o),...c})}function cn({as:e="div",tone:t,on:s,className:o,children:a,...c}){return i.jsx(e,{className:Ve("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 ft({on:e,title:t,sub:s,disabled:o,onClick:a}){return i.jsxs(cn,{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 Ie({children:e}){return i.jsx("div",{className:"empty",children:e})}function xn({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 Xe({label:e,children:t,className:s}){return i.jsxs("label",{className:Ve("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:Ve("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 Ue({as:e="span",variant:t="chip",hot:s,size:o,className:a,children:c,title:d}){return i.jsx(e,{className:Ve(t==="chip"?"chip-label":"mono-label",s&&"hot",o==="sm"&&(t==="chip"?"sm":"xs"),a),title:d,children:c})}const a1=e=>typeof e=="string"?{text:e}:e,l1=e=>Ve(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(a1);return!t.length&&!e.children?null:i.jsxs("span",{className:Ve("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:l1(s)||void 0,title:s.tip,children:s.text})]},o)),e.children]})}function $u(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:Ve("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 c1="M25.53 10.5 A11 11 0 1 1 16 5",u1="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:c1,fill:"none",stroke:"currentColor",strokeWidth:c,strokeLinecap:"butt"}),(e==="mark"||e==="action")&&i.jsx("path",{d:u1,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 Jc({parts:e,className:t,as:s="div"}){const o=e.filter(a=>a!=null&&a!==!1&&a!=="");return i.jsx(s,{className:Ve("meta",t),children:o.map((a,c)=>i.jsxs("span",{children:[c>0&&" · ",a]},c))})}const ym=()=>{const e=document.documentElement.dataset.theme;return e?e==="night":matchMedia("(prefers-color-scheme: dark)").matches};function Sg(){const[e,t]=y.useState(ym);return y.useEffect(()=>{const s=()=>t(ym()),o=matchMedia("(prefers-color-scheme: dark)");o.addEventListener("change",s);const a=new MutationObserver(s);return a.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{o.removeEventListener("change",s),a.disconnect()}},[]),e}function d1(){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 h1=15e3,wm=["pointerdown","pointermove","keydown","wheel","touchstart"];function f1(e,t,s,o){const[a,c]=y.useState(null),[d,h]=y.useState(!1),[m,p]=y.useState(!1),k=y.useRef(),v=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,H)=>{const re=b.current;return zx({snaps:Object.values(re.allSnaps),decisions:re.decisions,activity:re.activity,ledger:e.activity.ledger,since:Q=>{var ve;return q[Q]??H??((ve=re.allSnaps[Q])==null?void 0:ve.map.createdAt)??Date.now()},currentMapId:re.mapId,attention:S.current})},[e]),C=y.useCallback((q=Date.now())=>{var H;return(H=e.presence)==null?void 0:H.markSeen(b.current.maps.map(re=>re.id),q)},[e]),O=y.useCallback(()=>{const q=e.presence;if(!q)return;const H=q.lastSeenAny();if(H!==void 0&&Date.now()-H>=j){const re=q.snapshot();I(re,H).changed&&(k.current={seen:re,any:H},h(!0),s.enabled?c(re):p(!0))}C()},[e,j,s.enabled,I,C]);y.useEffect(()=>{!t.loaded||x.current||!e.presence||(x.current=!0,O())},[t.loaded,e,O]),y.useEffect(()=>{const q=()=>{const Q=Date.now()-v.current>=j;v.current=Date.now(),Q&&x.current&&document.visibilityState==="visible"&&O()},H=()=>{if(document.visibilityState!=="visible"){x.current&&C(Date.now()-v.current<j?Date.now():v.current);return}v.current=Date.now(),x.current&&O()};for(const Q of wm)window.addEventListener(Q,q,{passive:!0});document.addEventListener("visibilitychange",H);const re=setInterval(()=>{x.current&&document.visibilityState==="visible"&&C(v.current)},h1);return()=>{for(const Q of wm)window.removeEventListener(Q,q);document.removeEventListener("visibilitychange",H),clearInterval(re)}},[j,O,C]);const R=y.useMemo(()=>{var q;return a?I(a,(q=k.current)==null?void 0:q.any):void 0},[a,I,t.allSnaps,t.decisions,t.activity,o]),z=y.useMemo(()=>R?Wx(R):"",[R]);y.useEffect(()=>{a&&p(!1)},[a]);let Z="none";return m?Z="new":d&&(Z="seen"),{shown:a!==null,status:Z,briefing:R,line:z,open:()=>{const q=k.current;q&&c(q.seen)},dismiss:()=>c(null)}}function m1(e){const[t,s]=y.useState(e.leases.leases);return y.useEffect(()=>e.leases.subscribe(s),[e]),t}const p1="That changed while you were on it, so nothing was written. It is reloaded now: look again, then redo the change.";function g1(e){var Y;const[t,s]=y.useState([]),[o,a]=y.useState(),[c,d]=y.useState(),[h,m]=y.useState({}),[p,k]=y.useState({}),[v,x]=y.useState(!1),[j,b]=y.useState(e.activity.snapshot),[S,I]=y.useState(e.monitor.health),C=m1(e);y.useEffect(()=>e.monitor.subscribe(I),[e]);const[O,R]=y.useState(null),[z,Z]=y.useState(),[q,H]=y.useState(),re=y.useRef(),Q=y.useRef(),ve=y.useRef(new Set),ze=y.useRef();ze.current=c;const $e=y.useCallback(F=>{re.current=F,a(F),R(null)},[]),[se]=y.useState(Zs),D=y.useCallback(async()=>{var xe;const F=se.start(),T=await e.adapter.listMaps();let _=re.current;const ue=Q.current;ue&&T.some(pe=>pe.id===ue)?(Q.current=void 0,_=ue,_!==re.current&&$e(_)):(!_||!T.some(pe=>pe.id===_))&&(_=(xe=Gy(T)[0])==null?void 0:xe.id,$e(_));const[me,ye]=await Promise.all([Promise.all(T.map(pe=>e.adapter.loadMap(pe.id))),Promise.all(T.map(pe=>e.adapter.listDecisions(pe.id)))]);F()&&(s(T),m(Object.fromEntries(me.map(pe=>[pe.map.id,pe]))),k(Object.fromEntries(T.map((pe,Se)=>[pe.id,ye[Se]]))),x(!0),d(me.find(pe=>pe.map.id===_)))},[e,$e,se]);y.useEffect(()=>{let F,T=()=>{},_=()=>{},ue=!0;const me=()=>{clearTimeout(F),F=setTimeout(()=>void D().catch(ge=>Z(String(ge))),40)},ye=hs(me),xe=(ge,Be)=>ln(ge)&&e.activity.isRemote(ge.id)&&(!Be||!ge.mapId||ge.mapId===Be),pe=ge=>{var Be;return(Be=ze.current)==null?void 0:Be.tickets.find(Sn=>Sn.id===ge)},Se=ge=>{const Be=mx(ge,pe),Sn=ge.kind==="external.changed"&&e.activity.snapshot.sessions.some(fs=>xe(fs,ge.mapId)),ur=!("mapId"in ge)||!ge.mapId||ge.mapId===re.current||ge.kind==="map.created";Be&&!Sn&&ur&&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=>Z(String(ge))))}),()=>{ue=!1,T(),_(),ye(),clearTimeout(F)}},[e,D]),y.useEffect(()=>{o&&D().catch(F=>Z(String(F)))},[o,D]),y.useEffect(()=>{for(const F of j.sessions)F.mode!=="chart"||!F.mapId||!e.activity.isRemote(F.id)||ve.current.has(F.id)||(ve.current.add(F.id),!(F.status!=="running"&&Date.now()-(F.endedAt??0)>6e4)&&(Q.current=F.mapId,D().catch(T=>Z(String(T)))))},[j.sessions,e,D]);const J=(Y=j.pending[0])==null?void 0:Y.sessionId;y.useEffect(()=>{if(!J)return;const F=T=>e.activity.snapshot.sessions.some(_=>_.id===T&&ln(_));H(T=>F(T)?T:J)},[J,e]);const X=y.useCallback(async(F,T)=>{e.activity.push({source:"trail lead",agent:jt,level:"warn",text:F});try{Z(void 0),await T()}catch(_){const ue=_.stale===!0,me=ue?p1:_.message??String(_);Z(me),e.activity.push({source:"trail lead",agent:jt,level:"alert",text:`Rejected · ${me}`}),ue&&D().catch(ye=>Z(String(ye)))}},[e,D]),ce=y.useMemo(()=>NS({rt:e,guard:X,setMapId:$e,mapIdRef:re,snapRef:ze,setChatSession:H,setSelection:R}),[X,e,$e]),K=y.useMemo(()=>Object.values(h).flatMap(F=>Sx(F,p[F.map.id]??[])).sort((F,T)=>T.decidedAt-F.decidedAt),[h,p]);return{maps:t,allSnaps:h,mapId:o,snap:c,activity:j,health:S,selection:O,setSelection:R,error:z,chatSession:q,decisions:K,leases:C,loaded:v,actions:ce}}function Qt(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 v1(){const[e,t]=y.useState(Cu),s=y.useCallback(o=>{t(a=>{const c={...a,...o};return localStorage.setItem(Jo,JSON.stringify(c)),c})},[]);return[e,s]}function Tu(){return y.useSyncExternalStore(Qs.subscribe,Qs.get)}function k1({className:e,size:t=18}){return i.jsx("span",{className:e,"aria-hidden":"true",children:i.jsx(cg,{size:t,variant:Sg()?"night":"crt"})})}function De({as:e="section",className:t,style:s,frameless:o,children:a,...c}){return i.jsx(e,{className:Ve("panel",o&&"frameless",t),style:s,...c,children:a})}function Qn({tone:e,className:t,children:s,title:o}){return i.jsx("span",{className:Ve("pill",e,t),title:o,children:s})}function rn({label:e,value:t,layout:s="stack",urgent:o,title:a,className:c}){return i.jsxs("span",{className:Ve("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:Ve("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 Wn="#c8581e",y1={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:Wn,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:Wn})]}),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:Wn})]}),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:Wn,stroke:Wn})]}),tent:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 4L2.5 20h19z"}),i.jsx("path",{d:"M12 11l-4 9h8z",fill:Wn,stroke:Wn}),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:Wn})]})};function Ng({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:y1[e]})}function Tt({title:e,count:t,right:s,hot:o,sub:a,children:c,className:d,info:h,icon:m}){return i.jsxs("header",{className:Ve("sec-h",a&&"sub",d),children:[c,m&&i.jsx(Ng,{name:m}),e!==void 0&&i.jsx(Ue,{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 ut(e){const{value:t,options:s,onChange:o}=e,[a,c]=y.useState(!1),[d,h]=y.useState(0),[m,p]=y.useState(),k=y.useRef(null),v=y.useRef(null),x=y.useId(),j=s.find(C=>C.value===t);y.useLayoutEffect(()=>{if(!a||!k.current)return;const C=k.current.getBoundingClientRect();p({left:C.left,top:C.bottom+4,minWidth:C.width})},[a]),y.useEffect(()=>{if(!a)return;const C=R=>{var z,Z;R.target instanceof Node&&((z=v.current)!=null&&z.contains(R.target)||(Z=k.current)!=null&&Z.contains(R.target))||c(!1)},O=()=>c(!1);return document.addEventListener("mousedown",C),window.addEventListener("resize",O),window.addEventListener("scroll",O,!0),()=>{document.removeEventListener("mousedown",C),window.removeEventListener("resize",O),window.removeEventListener("scroll",O,!0)}},[a]),y.useEffect(()=>{var C,O;a&&((O=(C=v.current)==null?void 0:C.querySelector(`[data-i="${d}"]`))==null||O.scrollIntoView({block:"nearest"}))},[a,d]);const b=()=>{h(Math.max(0,s.findIndex(C=>C.value===t))),c(!0)},S=C=>{var R;const O=s[C];c(!1),(R=k.current)==null||R.focus(),O&&O.value!==t&&o(O.value)},I=C=>{if(!a){["ArrowDown","ArrowUp","Enter"," "].includes(C.key)&&(C.preventDefault(),b());return}const O=R=>h(z=>(z+R+s.length)%s.length);if(C.key==="ArrowDown")O(1);else if(C.key==="ArrowUp")O(-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 R=s.findIndex(z=>z.label.toLowerCase().startsWith(C.key.toLowerCase()));R>=0&&h(R);return}else return}C.preventDefault()};return i.jsxs(i.Fragment,{children:[i.jsxs("button",{ref:k,type:"button",className:Ve("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:v,id:x,className:"select-menu",role:"listbox",style:m,children:s.map((C,O)=>i.jsxs("li",{id:`${x}-${O}`,"data-i":O,role:"option","aria-selected":C.value===t,className:Ve(O===d&&"active"),onMouseEnter:()=>h(O),onMouseDown:R=>R.preventDefault(),onClick:()=>S(O),children:[i.jsx("span",{className:"select-label",children:C.label}),C.hint&&i.jsx("span",{className:"select-hint",children:C.hint})]},C.value))})]})}function w1(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 x1=350;function j1(){const[e,t]=y.useState(null);if(y.useEffect(()=>{let o=0,a=null;const c=()=>{window.clearTimeout(o),a=null,t(null)},d=k=>{const v=k.getAttribute("data-tip");if(!v)return;const x=k.getBoundingClientRect(),j=x.bottom+60>window.innerHeight;t({text:v,x:x.left+x.width/2,y:j?x.top-8:x.bottom+8,above:j,scout:k.hasAttribute("data-tip-scout")})},h=k=>{var j,b;const v=(b=(j=k.target)==null?void 0:j.closest)==null?void 0:b.call(j,"[data-tip], [title]");if(!v||v instanceof SVGElement&&!v.hasAttribute("data-tip"))return null;const x=v.getAttribute("title");return x&&(v.setAttribute("data-tip",x),v.removeAttribute("title")),v},m=k=>{if(k.pointerType==="touch")return;const v=h(k);v!==a&&(c(),v&&(a=v,o=window.setTimeout(()=>a===v&&d(v),k.type==="focusin"?0:x1)))},p=k=>{a&&!a.contains(k.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(ku,{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 bg(e){return e.bare?i.jsx("div",{className:`zone-b ${e.className??""}`,children:e.children}):i.jsxs(De,{className:`zone ${e.className??""}`,style:e.area?{gridArea:e.area}:void 0,children:[i.jsx(Tt,{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 Co(e){return i.jsx("li",{children:i.jsxs("button",{className:"bf-row",onClick:e.onClick,title:e.title,children:[i.jsx("span",{className:"key t-code",children:e.k}),i.jsx("span",{className:"t",children:e.text}),e.meta&&i.jsx("span",{className:"t-meta",children:e.meta})]})})}function qi(e){return i.jsxs(cn,{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 S1=864e5;function N1(e,t){const s=new Date(e),o=s.toTimeString().slice(0,5),a=new Date(t).toDateString(),c=new Date(t-S1).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 b1(e){const{briefing:t,bp:s,onClose:o}=e;y.useEffect(()=>{const v=x=>x.key==="Escape"&&o();return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[o]);const a=t==null?void 0:t.trails.flatMap(v=>v.waiting).sort((v,x)=>v.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=v=>{var x,j;return v.ticketId&&((j=(x=e.snaps[v.mapId])==null?void 0:x.tickets.find(b=>b.id===v.ticketId))==null?void 0:j.title)||v.text},p=v=>{var x,j;return v.ticketId&&((j=(x=e.snaps[v.mapId])==null?void 0:x.tickets.find(b=>b.id===v.ticketId))==null?void 0:j.key)||v.agent},k=v=>{const x=(C,O)=>i.jsx(Co,{k:C.key,text:C.title,meta:O,onClick:()=>e.onTicket(v.mapId,C.id)},C.id),j=(C,O)=>i.jsx(Co,{k:C.id,text:C.summary||C.answer,title:C.risk?`${C.question}
135
+
136
+ ${C.risk.reason}`:C.question,meta:O,onClick:()=>e.onDecision(C.id)},C.id),b=mj(v.agentDecisions).flatMap(C=>C.decisions.map(O=>j(O,C.label))),S=[i.jsx(zs,{title:"Done",children:v.done.map(C=>x(C))},"done"),i.jsx(zs,{title:"Ruled out",children:h?[]:v.ruledOut.map(C=>x(C))},"oos"),i.jsx(zs,{title:"Blocked",children:v.blocked.map(C=>x(C.ticket,`needs ${C.on.map(O=>O.key).join(", ")}`))},"blocked")],I=[i.jsx(zs,{title:"Waiting on you",urgent:!0,children:v.waiting.map(C=>i.jsx(Co,{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?[]:v.active.map(C=>{var R;const O=C.ticketId?(R=e.snaps[v.mapId])==null?void 0:R.tickets.find(z=>z.id===C.ticketId):void 0;return i.jsx(Co,{k:(O==null?void 0:O.key)??C.agent,text:O?`${O.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:v.key})," ",v.title]}),i.jsxs("div",{className:"bf-cols",children:[i.jsx("div",{children:S}),i.jsx("div",{children:I})]})]},v.mapId)};return i.jsx("div",{className:"scrim",onClick:o,children:i.jsxs(De,{as:"div",className:"dialog briefing",role:"dialog","aria-label":"While you were away",onClick:v=>v.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(Ue,{className:"bf-since",children:N1(t.since,t.now)}),i.jsx("button",{className:"icon-btn",onClick:o,"aria-label":"Close",children:"×"})]}),i.jsxs(cn,{className:"bf-scout",children:[i.jsx(ku,{size:h?1.1:1.3,speaking:e.line||"Nothing new since you were last here.",caption:!1,framed:!1}),i.jsxs("div",{children:[i.jsx("span",{className:"mono-label",children:"Scout"}),i.jsx("p",{children:e.line||"Nothing new since you were last here."})]})]}),t&&c&&t.trails.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"bf-tiles",children:[i.jsx(qi,{label:"Done",value:c.done,sub:c.ruledOut?`${c.ruledOut} ruled out`:void 0}),i.jsx(qi,{label:"Blocked",value:c.blocked,sub:c.blocked?"Needs your answer":void 0}),i.jsx(qi,{label:"Waiting on you",value:c.waiting,sub:C1(c.oldestWaitMs),urgent:c.waiting>0}),i.jsx(qi,{label:"Agent decisions",value:c.agentDecisions,className:"opt"}),i.jsx(qi,{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(k)})]}),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 C1(e){if(e!==void 0)return e<6e4?"Just asked":`Oldest ${qt(e)}`}function $1(e){const{brief:t,bp:s}=e;return i.jsx(b1,{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 T1={passed:"checks passed",failing:"checks failing",pending:"checks pending",unknown:"checks unknown",none:"no checks"};function E1({mapId:e,ticketId:t}){const s=Qs.ticket(Tu(),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:T1[s.checksSummary]}),i.jsx("span",{className:"when",children:A1(s)})]}),s.flags.map(a=>i.jsx(Qn,{className:`flag flag-${a.severity}`,title:a.text,children:a.kind},a.kind))]})}function A1(e){return e.error?"sync failed":e.syncedAt?hg(e.syncedAt):"not synced yet"}const I1={ok:"ok",failed:"error",stale:"syncing",unknown:"idle",off:"idle"};function M1({now:e}){const t=Tu();if(!t.reached)return null;const s=ux(t.live?t.status:null,e);return i.jsxs("span",{className:`tracker-chip pr-sync tone-${s.tone}`,title:s.title,children:[i.jsx(Ue,{size:"sm",children:"CI"}),i.jsx(si,{variant:"status",state:I1[s.tone],size:13,className:"sync-glyph"}),i.jsx("span",{className:"tl",children:s.label})]})}function Cg(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:Ve("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 R1={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 L1(e){const t=e.briefingStatus==="new";return i.jsx(Cg,{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:R1[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 O1=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"})]}),P1=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 _1({onToggle:e}){const t=Sg(),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?O1:P1})})}const D1={idle:"Idle",syncing:"Syncing",ok:"Synced",error:"Sync error"};function z1({label:e,health:t,now:s}){const o=[`${D1[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(Ue,{size:"sm",children:"Tracker"}),i.jsx(si,{variant:"status",state:t.status,size:13,className:"sync-glyph"}),i.jsx("span",{className:"tl",children:e})]})}const xm={"start-over":{text:e=>`Archive ${e.key} and start a new trail from its idea? The old map stays as history; its tickets and decisions don't carry over.`,confirm:"Start over"},archive:{text:e=>`Archive ${e.key}? It stays as history, read-only, and no agent takes work from it.`,confirm:"Archive"}};function B1(e){const{map:t}=e,[s,o]=y.useState();return t.archived?i.jsxs("button",{role:"menuitem",className:"trail-item act","data-tip":"Make it an active trail again: agents can take work from it",onClick:()=>(e.onArchive(!1),e.onDone()),children:["Restore ",t.key]}):s?i.jsxs("div",{className:"trail-confirm",role:"group",children:[i.jsx("p",{className:"t-meta",children:xm[s].text(t)}),i.jsxs("div",{className:"actions",children:[i.jsx(P,{variant:"primary",onClick:()=>{s==="start-over"?e.onStartOver():e.onArchive(!0),e.onDone()},children:xm[s].confirm}),i.jsx(P,{onClick:()=>o(void 0),children:"Cancel"})]})]}):i.jsxs(i.Fragment,{children:[i.jsxs("button",{role:"menuitem",className:"trail-item act","data-tip":"The map went wrong? Archive it and describe the idea again",onClick:()=>o("start-over"),children:["Start ",t.key," over…"]}),i.jsxs("button",{role:"menuitem",className:"trail-item act","data-tip":"Put the trail away as history",onClick:()=>o("archive"),children:["Archive ",t.key,"…"]})]})}function F1(e){const{map:t}=e.snap,s=Lp(e.snap);return i.jsxs("button",{role:"menuitem",className:`trail-item ${e.on?"on":""} ${t.archived?"archived":""}`,onClick:e.onSelect,children:[i.jsx("span",{className:"key",children:t.key}),i.jsx("span",{className:"mi-title",children:t.title}),i.jsxs("span",{className:"mi-progress",children:[s.decided,"/",s.total]}),i.jsx(us,{n:e.waiting,urgent:!!e.waiting,hideZero:!0})]})}function U1(e){var k;const[t,s]=y.useState(!1),o=y.useRef(null);y.useEffect(()=>{if(!t)return;const v=x=>{var j;(x instanceof KeyboardEvent?x.key==="Escape":!((j=o.current)!=null&&j.contains(x.target)))&&s(!1)};return window.addEventListener("mousedown",v),window.addEventListener("keydown",v),()=>{window.removeEventListener("mousedown",v),window.removeEventListener("keydown",v)}},[t]);const a=Object.values(e.snaps).sort((v,x)=>x.map.createdAt-v.map.createdAt),c=a.filter(v=>!v.map.archived),d=a.filter(v=>v.map.archived),h=v=>e.activity.pending.filter(x=>x.mapId===v).length,m=e.activity.pending.filter(v=>{var x;return v.mapId!==((x=e.map)==null?void 0:x.id)}).length,p=v=>{var x;return i.jsx(F1,{snap:v,on:v.map.id===((x=e.map)==null?void 0:x.id),waiting:h(v.map.id),onSelect:()=>{e.onSelectMap(v.map.id),s(!1)}},v.map.id)};return i.jsxs("div",{className:"trail-switcher",ref:o,children:[i.jsxs("button",{className:"trail-btn",onClick:()=>s(v=>!v),"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"}),((k=e.map)==null?void 0:k.archived)&&i.jsx("span",{className:"trail-archived",children:"archived"}),m>0&&i.jsx(us,{n:m,urgent:!0}),i.jsx("span",{className:"caret",children:"▾"})]}),t&&i.jsxs("div",{className:"trail-menu",role:"menu",children:[i.jsx(Ue,{variant:"plain",className:"menu-h",children:"Trails"}),c.map(p),i.jsx("button",{role:"menuitem",className:"trail-item new",onClick:()=>{s(!1),e.onNewTrail()},children:"+ New trail"}),d.length>0&&i.jsxs(i.Fragment,{children:[i.jsx(Ue,{variant:"plain",className:"menu-h",children:"Archived"}),d.map(p)]}),e.map&&e.onStartOver&&e.onArchive&&i.jsx("div",{className:"trail-acts",children:i.jsx(B1,{map:e.map,onStartOver:e.onStartOver,onArchive:e.onArchive,onDone:()=>s(!1)})})]})]})}function W1(e){const{map:t}=e,s=Qt(1e3),o=e.activity.pending.length,a=t&&e.snaps[t.id],c=a&&Lp(a),d=t&&Op(e.activity,t.id);return i.jsxs(De,{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(U1,{...e})]}),i.jsxs("div",{className:"h-dest",title:t==null?void 0:t.sections.destination,children:[i.jsx(Ue,{size:"sm",children:"Destination"}),(t==null?void 0:t.sections.destination)??"—"]})]}),i.jsxs("div",{className:"h-right",children:[i.jsx(z1,{label:e.trackerLabel,health:e.health,now:s}),i.jsx(M1,{now:s}),t&&c&&i.jsxs("span",{className:"trail-meta",children:[i.jsx(rn,{label:"Trail T+",value:dg(s-t.createdAt),title:"Trail elapsed time, since it was charted"}),i.jsx(rn,{label:"Done",value:`${c.decided}/${c.total}`}),d&&i.jsx(rn,{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",..._p(e.activity,t.id).map(h=>Pp[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(L1,{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(_1,{onToggle:e.onToggleTheme})]})]})}const $g=y.createContext(null);function ii(){const e=y.useContext($g);if(!e)throw new Error("useKnowledge needs a KnowledgeContext provider");return e}function H1({snap:e,t}){const s=ii();if(!s.entries.length||t.state==="closed")return null;const o=Qp(s.entries,{trailKey:e.map.key,ticket:{type:t.type,title:t.title,body:t.body},paths:Yp(`${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 $o(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:$o(void 0,t)});let a=s;return s.key!==e?a={key:e,shown:$o(void 0,t)}:s.shown.latest!==t&&(a={key:e,shown:$o(s.shown,t)}),a!==s&&o(a),{hash:a.shown.hash,changed:a.shown.hash!==a.shown.latest,reviewAgain:()=>o({key:e,shown:$o(void 0,t)})}}const K1={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 V1({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(Xe,{label:"Title",children:i.jsx("input",{value:a,onChange:k=>c(k.target.value)})}),i.jsx(Xe,{label:"Body",children:i.jsx("textarea",{rows:8,value:d,onChange:k=>h(k.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:K1[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(k=>k.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(k=>k&&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 G1={suggested:"Suggested",confirmed:"Confirmed",assumption:"Assumption",outdated:"Outdated"};function q1(){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",k=(S,I)=>I==="all"?!0:I==="review"?p(S):S.status===I,v=y.useMemo(()=>{const S=c.trim().toLowerCase();return e.entries.filter(I=>k(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=v.find(S=>S.id===h)??v[0],j=S=>e.entries.filter(I=>k(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(De,{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(ut,{compact:!0,"aria-label":"Kind",value:o,onChange:a,options:[{value:"",label:"Any kind"},...rj.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:v.length?v.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":G1[S.status]]})},S.id)):i.jsx(Ie,{children:t==="review"?"Nothing needs you":"No entries"})}),x?i.jsx(V1,{e:x}):i.jsx(Ie,{children:"Pick an entry"})]})]})})}function Eu({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 Q1=e=>{try{return JSON.parse(e)}catch{return}};function Tg(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?[Nu(h=>a(h)&&o())]:[],...Object.entries(c).map(([h,m])=>ei(h,p=>m(Q1(p))&&o()))];return o(),{reload:o,pushed:()=>t.pushed(),stop:()=>{s=!0;for(const h of d)h()}}}function mt(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??{}),k=Tg({load:()=>t.current.load(),show:v=>t.current.show(v),failed:()=>{var v,x;return(x=(v=t.current).failed)==null?void 0:x.call(v)},...m.changed?{changed:v=>{var x,j;return((j=(x=t.current).changed)==null?void 0:j.call(x,v))===!0}}:{},events:Object.fromEntries(p.map(v=>[v,x=>{var j,b;return((b=(j=t.current.events)==null?void 0:j[v])==null?void 0:b.call(j,x))===!0}]))});return s.current=k,()=>{k.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 Eg=`${je()}/knowledge`;async function jm(e,t){const s=await fetch(`${Eg}${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 Y1(){const e=await fetch(Eg);return e.ok?await e.json():null}function J1(e){const[t,s]=y.useState([]),[o,a]=y.useState({}),[c,d]=y.useState({}),[h,m]=y.useState(!1),[p,k]=y.useState(),{reload:v}=mt({load:Y1,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)=>jm("/call",{id:j,call:b,hash:S??c[j]}).then(()=>(k(void 0),v(),!0),I=>(k(I.message),v(),!1)),propose:j=>jm("/propose",j).then(b=>(v(),b.entry),b=>(k(b.message),void 0))}}const X1=["awaiting","blocked","trail.done","resolved"];async function Hn(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 Z1(e){const t=`${e}/slack`;return{get:()=>Hn(t),connectStart:s=>Hn(`${t}/connect/start`,"POST",{project:s}),connectPreview:s=>Hn(`${t}/connect/preview`,"POST",{code:s}),connectFinish:s=>Hn(`${t}/connect/finish`,"POST",{code:s}),connectCancel:()=>Hn(`${t}/connect/cancel`,"POST",{}),disconnect:()=>Hn(`${t}/connect`,"DELETE"),update:s=>Hn(`${t}/settings`,"PUT",s),members:()=>Hn(`${t}/members`).then(s=>s.members)}}const wn=Z1(je());function eN(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 tN=e=>new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});function nN({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 ",tN(e.at),"). ",e.message]})}function Xc(e){const[t,s]=y.useState(!1),o=()=>{s(!0),wn.connectStart(ar()).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 sN(e){return i.jsxs("div",{className:"test-line mentions-hint",children:[i.jsx("span",{children:"Reconnect to allow @Scout mentions: Slack needs one more permission for them."}),i.jsx(Xc,{again:!0,onError:e.onError})]})}function iN({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 rN(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 Sm({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 wn.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 oN(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(Xc,{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(rN,{small:!0,href:t.links.homeWeb,children:"Open Scout in Slack"}),i.jsx(Sm,{onRemoved:e.onChanged})]}):i.jsxs("div",{className:"c-actions",children:[!e.busy&&i.jsx(Xc,{again:t.legacy,onError:e.onError}),t.legacy&&i.jsx(Sm,{onRemoved:e.onChanged})]})}const aN={awaiting:"Awaiting you",blocked:"Blocked","trail.done":"Trail done",resolved:"Resolved"};function lN({s:e}){const[t,s]=cN(e);return i.jsxs("div",{className:`sync-line ${t}`,title:e.error,children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:s})]})}function cN(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 uN(e){const{s:t,back:s}=e,o=!!s.confirm&&!t.connected;return i.jsxs(cn,{className:hN(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:dN(t)}),t.connected&&i.jsx(lN,{s:t}),t.connected&&i.jsx("div",{className:"t-meta",children:"Scout answers in Slack only while this Teamtrail is running."}),t.delivery&&i.jsx(nN,{problem:t.delivery}),t.connected&&t.mentions===!1&&!o&&i.jsx(sN,{onError:e.onError}),!t.connected&&!o&&i.jsx(iN,{s:t,connecting:s.busy}),o&&i.jsx(eN,{who:s.confirm,onConnect:s.connect,onCancel:s.cancel}),e.error&&i.jsxs("div",{className:"test-line alert",children:["✕ ",e.error]}),!o&&i.jsx(oN,{s:t,busy:s.busy,onError:e.onError,onChanged:e.onChanged,onToggle:e.onToggle})]})}function dN(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 hN(e){const t=e.connected&&e.enabled?"active":"",s=e.connected?"":"open";return`connector ${t} ${s}`}function fN(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 mN(e){const[t,s]=y.useState(),[o,a]=y.useState();y.useEffect(()=>{wn.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(ft,{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 pN(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 k=c.has(p)?t.notify.events.filter(v=>v!==p):[...t.notify.events,p];s({notify:{events:k}})};return i.jsxs("div",{className:"sl-groups",children:[i.jsxs("div",{className:"sl-group",children:[i.jsx(Ue,{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(Ue,{variant:"plain",size:"sm",children:"Allowed users"}),i.jsx(mN,{value:t.allow,owners:t.owners,onChange:p=>s({allow:p})},t.state)]}),i.jsxs("div",{className:"sl-group",children:[i.jsx(Ue,{variant:"plain",size:"sm",children:"Notify"}),i.jsxs("div",{className:"choice-row compact",children:[i.jsx(ft,{on:!d,title:"DM to owner",onClick:()=>{a(!1),s({notify:{target:"dm",detail:"full"}})}}),i.jsx(ft,{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(Xe,{label:"Channel ID (invite @Scout there first)",children:i.jsx(fN,{value:t.notify.target,onSave:p=>s({notify:{target:p}})})}),i.jsxs("div",{className:"choice-row compact",children:[i.jsx(ft,{on:t.notify.detail==="full",title:"Full questions",onClick:()=>s({notify:{detail:"full"}})}),i.jsx(ft,{on:t.notify.detail==="titles-only",title:"Titles only",onClick:()=>s({notify:{detail:"titles-only"}})})]})]}),i.jsx("div",{className:"choice-row compact",children:X1.map(p=>i.jsx(ft,{on:c.has(p),title:aN[p],onClick:()=>m(p)},p))})]}),i.jsx(Jc,{className:"dim",parts:[`${t.command} decide`,`${t.command} status`,`${t.command} inbox`,"Save as decision on any message"]})]})}function gN(){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 Cc={code:gN()};function vN(e){const[t,s]=y.useState(),[o,a]=y.useState(),[c,d]=y.useState(),[h,m]=y.useState(!!Cc.code),p=v=>d(v.message);y.useEffect(()=>{const v=Cc.code;v&&(Cc.code=void 0,s(v),wn.connectPreview(v).then(a,p).finally(()=>m(!1)))},[]);const k=v=>{m(!0),a(void 0),v.then(e,p).finally(()=>m(!1))};return{busy:h,error:c,confirm:o,connect:()=>t&&k(wn.connectFinish(t)),cancel:()=>k(wn.connectCancel())}}function Au(e=0){const[t,s]=y.useState(),o=y.useCallback(()=>wn.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 kN(e){const[t,s]=Au(3e3),o=vN(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=>wn.update(m).then(s,()=>{});return i.jsxs("div",{ref:d,className:"slack-settings",children:[i.jsx(uN,{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(pN,{s:t,patch:m=>void h(m)})]})}function yN(e){if(e.legacy&&!e.connected)return{label:"Add Scout to Slack again",why:"Scout is now one Slack app; your own app no longer works"};if(e.connected&&e.state==="auth-error")return{label:"Slack disconnected",why:e.error??"Add Scout again"}}let Nm;function wN(){return Nm??(Nm=wn.get().then(e=>({owners:e.owners??[],allow:e.allow??[]}),()=>{})),Nm}function ri(){const[e,t]=y.useState();return y.useEffect(()=>{let s=!0;return wN().then(o=>s&&t(o)),()=>{s=!1}},[]),e}function xN(e){const{api:t,rt:s,brief:o}=e,{snap:a,actions:c}=t,[d]=Au(15e3),h=ii(),m=d?yN(d):void 0;return i.jsx(W1,{repo:e.repo,snaps:t.allSnaps,map:a==null?void 0:a.map,activity:t.activity,health:t.health,onNewTrail:e.onNewTrail,onStartOver:e.onStartOver,onArchive:c.setArchived,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 jN(e){const{m:t}=e,s=ri(),o=t.from==="human"?"human":"agent";return i.jsxs("div",{className:`msg from-${t.from} voice-${o}`,children:[i.jsx(V,{parts:[Gn(t.author,s),Kw(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 SN(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 NN({id:e,text:t}){const[s,o]=y.useState(),a=s!==e;return i.jsx(ku,{size:.6,framed:!1,state:a?"speaking":"alert",speaking:a?t.slice(0,60):void 0,onSpeakEnd:()=>o(e),className:"q-avatar"})}function bN(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(NN,{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 CN(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 $N(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(R=>R.id===s),k=t.chats.filter(R=>R.sessionId===s),v=r1(t.pending,s,c??e.questionId),x=new Set(t.pending.filter(R=>R.sessionId===s).map(R=>R.id)),j=k.find(R=>!!v&&R.questionId===v.id),b=k.filter(R=>R!==j),S=p?e.snaps[p.mapId]:void 0,I=p!=null&&p.ticketId?S==null?void 0:S.tickets.find(R=>R.id===p.ticketId):void 0;y.useEffect(()=>{const R=h.current;R==null||R.scrollTo({top:R.scrollHeight,behavior:"smooth"})},[b.length,v==null?void 0:v.id]),y.useEffect(()=>{var R;v&&!e.onBack&&((R=m.current)==null||R.focus({preventScroll:!0}))},[v==null?void 0:v.id,e.onBack]);const C=R=>{!v||!R.trim()||(e.onAnswer(v.id,R.trim()),a(""))},O=TN(p,!!v);return i.jsxs("div",{className:`comms ${v?"asking":""}`,children:[i.jsx(Tt,{title:"HITL line",right:p?i.jsx("span",{className:`status ${v?"urgent":""}`,children:O}):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(SN,{ticket:I,trail:S==null?void 0:S.map.title,agent:p.agent}),i.jsx("div",{className:"comms-log",ref:h,children:b.map(R=>i.jsx(jN,{m:R,stillOpen:!!R.questionId&&x.has(R.questionId),onAnswerThis:()=>d(R.questionId)},R.id))}),v&&i.jsx(bN,{q:v,chatId:j==null?void 0:j.id}),i.jsx(CN,{options:v==null?void 0:v.suggestions,onPick:C}),i.jsx(ma,{ref:m,className:"comms-input",value:o,onValueChange:a,onSubmit:C,disabled:!v,placeholder:v?"Answer":""})]}):i.jsx(Ie,{children:"No conversation"})]})}function TN(e,t){return e?t?"Your answer is needed":ln(e)?`${e.agent} is working…`:e.status==="done"?"Resolved · ticket closed":"Session ended":""}async function EN(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 AN({item:e}){const[t,s]=y.useState(!1),[o,a]=y.useState(),c=()=>{s(!0),a(void 0),EN(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 IN(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 MN({item:e}){const[t,s]=y.useState(!1),[o,a]=y.useState(),c=d=>{s(!0),a(void 0),IN(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 RN({item:e}){return e.kind==="integration"?i.jsx(AN,{item:e}):e.kind==="tracker-settings"&&e.ref.includes(":")?i.jsx(MN,{item:e}):null}const LN=/(\S*\/\S*|#\d+)/g;function ON({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(LN).map((o,a)=>a%2===1?i.jsx("span",{className:"t-code",children:o},a):o)]},t))}):null}const Ag={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"},PN={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"},_N=[{minutes:30,label:"30 min"},{minutes:120,label:"2 hours"},{minutes:1440,label:"Tomorrow"}],DN=["blocked","flag","stalled","policy","reroute","overlap","integration","model"];function Ig(e,t){return t||e.urgency==="blocking"?"urgent":DN.includes(e.kind)?"attention":"neutral"}const zN=[/^marked blocking$/,/^fyi\b/,/^soon\b/,/^waiting \d/,/^answer together/,/questions from /];function Mg(e){return e.reasons.filter(t=>!zN.some(s=>s.test(t)))}function BN(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`:Ag[t.kind],c=[];t.urgency==="blocking"&&c.push({text:"Blocking",urgent:!0,className:"urgency-tag"}),c.push({text:a,strong:!0});const d=o&&FN(t.title,o);return d&&c.push(d),e.otherTrail&&c.push((s==null?void 0:s.map.title)??t.mapId),c}function FN(e,t){if(!e.includes(t.key))return e.includes(t.title)?{text:t.key,code:!0}:`${t.key} ${t.title}`}function UN(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:[_N.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 WN=15e3;function HN(e){const{item:t}=e,s=t.title.split(`
141
+ `)[0],o=Mg(t),a=e.now-t.since<WN;return i.jsx(Ce,{as:"li",className:`att-item k-${t.kind} u-${t.urgency} ${e.selected?"sel":""} ${a?"incoming":""}`,edge:Ig(t,e.interrupting),selected:e.selected,title:s,titleText:t.title,context:i.jsx(V,{parts:BN({item:t,snap:e.snap,otherTrail:e.otherTrail})}),detail:o.length>0&&i.jsx(ON,{reasons:o}),detailText:o.join(`
142
+ `),trailing:un(e.now-t.since),onOpen:e.onOpen,actions:i.jsx(UN,{title:t.title,canDismiss:vj(t),onSnooze:e.onSnooze,onDismiss:e.onDismiss}),below:i.jsx(RN,{item:t})})}function KN(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 VN={question:"inbox-list",approval:"inbox-list approvals"};function GN(e){const{batch:t}=e,s=t.items.length>1,o=t.kind==="question"?"answer together":"review together",a=[`${t.items.length} ${PN[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 ${VN[t.kind]??""}`,children:e.children})]})}function qN(e,t){e.ticketId?t.openTicket(e.mapId,e.ticketId):t.selectTrail(e.mapId)}function Rg(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 qN(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 QN(e){const t=Qt(1e3),{view:s}=e;if(!s.items.length)return i.jsx(xn,{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:KN(s.items).map(h=>{var m;return i.jsx(GN,{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(HN,{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:()=>Rg(p,e.handlers),onSnooze:k=>e.onSnooze(p.id,k),onDismiss:()=>e.onDismiss(p.id)},p.id))},h.key)})})}const bm={label:"Focus for 1 hour",change:{kind:"for",minutes:60}};function YN(e){switch(e.kind){case"manual":case"hours":return[{label:"End focus now",change:{kind:"end"},primary:!0}];case"paused":return[{label:"Resume quiet hours",change:{kind:"resume"},primary:!0},bm];case"off":return[{...bm,primary:!0},{label:"Focus for 3 hours",change:{kind:"for",minutes:180}}];default:return e}}const Cm=e=>la(e).slice(0,5),JN=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function XN(e){const t=`${e.items.length} waiting on you`;return e.heldBack===0?`Nothing held back · ${t}`:`${JN(e.heldBack,"item")} would interrupt you · ${t}`}function $c(e){const t=e.prefs.focus;return t?`Quiet hours ${t.from}–${t.to}`:"No quiet hours set"}const $m=e=>`Items scoring ${e.policy.value.interrupt} or more interrupt you · ${e.items.length} waiting on you`;function ZN(e){const t=e.focus;switch(t.kind){case"manual":case"hours":{const s=Cm(t.until),o=t.kind==="manual"?"Switched on here":$c(e);return{word:"on",until:s,on:!0,title:`Focus is on until ${s}`,reason:o,detail:XN(e)}}case"paused":{const s=Cm(t.until),o=`Quiet hours paused until ${s}`;return{word:"paused",until:s,on:!1,title:o,reason:$c(e),detail:$m(e)}}case"off":return{word:"off",until:"",on:!1,title:"Focus is off",reason:$c(e),detail:$m(e)};default:return t}}const eb="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 tb(e){const{view:t}=e,s=ZN(t),o=t.focus.kind,a=i.jsxs("span",{className:Ve("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(Cg,{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:eb})]}),i.jsx(V,{parts:[s.reason]}),i.jsx(V,{className:"focus-held",parts:[s.detail]}),i.jsxs("div",{className:"focus-panel-actions",children:[YN(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 nb(e){const{view:t}=e,s=t.interrupting.length;return i.jsxs("span",{className:"attention-head",children:[i.jsx(tb,{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 Lg=`${je()}/attention`,sb=250;async function Tm(e,t,s){var c;const o=await fetch(`${Lg}${e}`,{method:t,headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),a=await o.json().catch(()=>({}));if(!o.ok)throw new Error(((c=a.errors)==null?void 0:c.join("; "))??a.error??`HTTP ${o.status}`);return a}function Og(e){const[t,s]=y.useState(),[o,a]=y.useState(),[c]=y.useState(Zs),d=y.useCallback(()=>{const m=c.start();fetch(Lg).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,sb);return()=>clearTimeout(m)},[d,e]);const h=(m,p)=>void Tm(m,"POST",p).then(()=>(a(void 0),d()),k=>a(k.message));return{view:t,error:o,snooze:(m,p)=>h("/snooze",{id:m,minutes:p}),dismiss:m=>h("/dismiss",{id:m}),savePrefs:m=>Tm("/prefs","PUT",m).then(()=>(a(void 0),d(),!0),p=>(a(p.message),!1))}}function ib(e){return e.prefs.channel!=="browser"?!1:typeof Notification<"u"&&Notification.permission==="granted"}function rb(e){const t=new Notification(`${te.name} · needs you`,{body:e.title,tag:e.id});t.onclick=()=>{window.focus(),t.close()}}function ob(e){const t=y.useRef();y.useEffect(()=>{if(!e)return;const s=new Set(e.interrupting),o=t.current;if(t.current=s,!(!o||!ib(e)))for(const a of e.items)s.has(a.id)&&!o.has(a.id)&&rb(a)},[e])}function ab(e){const t=Qt(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:un(t-s.at),onOpen:()=>e.onOpen(s.mapId,s.ticketId)},`${s.mapId}/${s.ticketId}`)})}):null}function Em({activity:e}){const t=Qt(1e3),s=wx(e);return i.jsxs("div",{className:"hitl-readout",children:[i.jsx(rn,{layout:"inline",label:"Oldest",value:s.oldestAt?qt(t-s.oldestAt):"—",urgent:!!s.oldestAt&&t-s.oldestAt>6e4,title:"Oldest open question"}),i.jsx(rn,{layout:"inline",label:"Avg wait",value:s.avgWaitMs!==void 0?qt(s.avgWaitMs):"—",title:`Average wait over ${s.answered} answered questions`}),i.jsx(rn,{layout:"inline",label:"Answered",value:s.answered})]})}function lb(e){const t=Qt(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:un(t-s.at),onOpen:()=>e.onOpen(s.sessionId,s.ticketId)},s.id)})}):i.jsx(xn,{title:"Nothing waiting on you",hint:"When an agent needs your call, its question lands here."})}const cb={pass:"Passed",fail:"Failed",error:"Could not run",interrupted:"Interrupted"},sr={off:"Off",checks:"Checks","checks+review":"Checks + review","checks+review+human":"Checks + review + you"},Pg={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."},ub=e=>e.exitCode===0&&!e.timedOut&&!e.error;async function Am(e){const t=await e.json().catch(()=>({}));if(!e.ok)throw new Error(t.error??`HTTP ${e.status}`);return t}const To=`${je()}/verification`,cr={ticket:(e,t)=>fetch(`${To}/ticket?mapId=${encodeURIComponent(e)}&ticketId=${encodeURIComponent(t)}`).then(s=>s.ok?s.json():void 0,()=>{}),inbox:()=>fetch(`${To}/inbox`).then(e=>e.ok?e.json().then(t=>t.items):[],()=>[]),log:e=>fetch(`${To}/log?path=${encodeURIComponent(e)}`).then(t=>Am(t)),act:e=>fetch(`${To}/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(t=>Am(t))};function db(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}=mt({version:o,load:cr.inbox,show:s});return y.useEffect(()=>Qs.onEvidence(a),[a]),t}function hb(e,t){return{...e,items:e.items.filter(s=>!(s.kind==="brief"&&s.mapId===t))}}function fb(e){var h;const t=[...e.activity.pending].sort((m,p)=>m.at-p.at),s=db(e.snaps),o=(h=e.attention)==null?void 0:h.view,a=o&&e.briefShown?hb(o,e.currentMapId):o,c=a?a.items.length:t.length+s.length,d=i.jsx(Tt,{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(Em,{activity:e.activity}),i.jsx(QN,{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(Em,{activity:e.activity}),i.jsx(ab,{items:s,snaps:e.snaps,currentMapId:e.currentMapId,onOpen:e.onOpenTicket}),(t.length>0||!s.length)&&i.jsx(lb,{items:t,snaps:e.snaps,currentMapId:e.currentMapId,selected:e.sessionId,onOpen:e.onOpenQuestion})]})}function mb(e){const[t,s]=y.useState("list"),[o,a]=y.useState();y.useEffect(()=>{e.convRequest&&s("conv")},[e.convRequest]);const c=(k,v)=>{e.onOpen(k,v),s("conv")},d=k=>{const v=e.activity.pending.find(x=>x.id===k);v&&(a(v.id),c(v.sessionId,v.ticketId))},h=i.jsx(fb,{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($N,{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(De,{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(k=>k.id===e.sessionId);return i.jsxs(De,{className:`zone inbox split ${p?"has-conv":""}`,style:{gridArea:"inbox"},children:[i.jsx(Tt,{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 pb(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(jg).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(Tt,{title:"Up next",count:i.jsx("span",{className:"n mono-label",children:a.length})}),!t&&i.jsx(Ie,{children:"Ready tickets show here"}),t&&!a.length&&i.jsx(Ie,{children:"Nothing ready"}),t&&a.length>0&&i.jsx("ul",{className:"ticket-list",children:a.map(m=>{const k={state:s.get(m.id),waiting:c.has(m.id),assignee:m.assignee,hitl:rr(m)==="hitl"},v=gb(k);return i.jsx("li",{className:`${d===m.id?"sel":""} st-${vb(k)}`,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:v})]})},m.id)})})]})}function gb(e){if(e.waiting)return"waiting on you";if(e.state==="claimed")return e.assignee??"claimed";const t=fg[e.state].toLowerCase();return e.hitl?`${t}, needs you`:t}function vb(e){return e.waiting?"waiting":e.state==="frontier"&&e.hitl?"attention":e.state}function kb(e){const{api:t,nav:s}=e;return i.jsx(mb,{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(pb,{snap:t.snap,sessions:e.scoped.sessions,selection:t.selection,onSelect:s.select}),above:e.above})}function Ho({command:e,label:t="Copy"}){const[s,o]=y.useState(!1);return i.jsxs("span",{className:"agent-cmd",children:[i.jsx("code",{children:e}),i.jsx("button",{type:"button",className:"btn sm","data-tip":"Copy, then paste it in Claude Code or Codex",onClick:()=>void navigator.clipboard.writeText(e).then(()=>{o(!0),setTimeout(()=>o(!1),1500)}),children:s?"Copied":t})]})}const Eo=[{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"}],yb=9e3;function wb(){const[e,t]=y.useState(0),[s,o]=y.useState(!1);y.useEffect(()=>{if(s)return;const c=setInterval(()=>t(d=>(d+1)%Eo.length),yb);return()=>clearInterval(c)},[s]);const a=Eo[e];return i.jsxs("div",{className:"command-bar real",children:[i.jsx(Ng,{name:"map"}),i.jsx(Ue,{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(Ho,{command:a.command})]},e),i.jsxs("button",{type:"button",className:"link hint-next","data-tip":"Next hint","aria-label":"Next hint",onClick:()=>t(c=>(c+1)%Eo.length),children:[e+1,"/",Eo.length," ›"]})]})}function xb(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(ft,{on:e.value===s.v,title:s.title,onClick:()=>e.onChange(s.v)},s.v))})}function jb({seed:e,onClose:t,tracker:s,onCreate:o}){const[a,c]=y.useState(),[d,h]=y.useState(!1),[m,p]=y.useState(),[k,v]=y.useState((e==null?void 0:e.title)??""),[x,j]=y.useState((e==null?void 0:e.destination)??""),[b,S]=y.useState((e==null?void 0:e.notes)??""),[I,C]=y.useState((e==null?void 0:e.assumptions.join(`
144
+ `))??""),O=[k.trim(),x.trim(),b.trim()].filter(Boolean).join(". ").replace(/"/g,"'");return y.useEffect(()=>{const R=z=>z.key==="Escape"&&t();return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[t]),i.jsx("div",{className:"scrim",onClick:t,children:i.jsxs(De,{as:"div",className:"dialog",onClick:R=>R.stopPropagation(),children:[i.jsx("header",{children:i.jsx("h2",{className:"t-heading caps",children:e?"Start over":"New trail"})}),i.jsx(Xe,{label:"Title",children:i.jsx("input",{value:k,onChange:R=>v(R.target.value),autoFocus:!0})}),i.jsx(Xe,{label:"Destination",children:i.jsx("textarea",{rows:3,value:x,onChange:R=>j(R.target.value),placeholder:"What is true when this trail is done?"})}),i.jsx(Xe,{label:"Notes",children:i.jsx("textarea",{rows:2,value:b,onChange:R=>S(R.target.value)})}),i.jsx(Xe,{label:"Assumptions (optional, one per line)",children:i.jsx("textarea",{className:"new-trail-assumptions",rows:2,value:I,onChange:R=>C(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 ",s,"."]}),i.jsx(Ho,{command:`/scout new "${O||"your idea"}"`,label:"Copy command"})]}),a?i.jsxs("div",{className:"agent-draft created",children:[i.jsxs("span",{children:["Trail ",a," is on the map, starting with discovery. To get it moving, run this in Claude Code or Codex:"]}),i.jsx(Ho,{command:"/scout resume",label:"Copy command"})]}):m&&i.jsx("p",{className:"vf-err",children:m}),i.jsxs("footer",{children:[i.jsx(P,{variant:"ghost",onClick:t,children:"Close"}),!a&&i.jsx(P,{variant:"primary",disabled:d||!k.trim()||!x.trim(),"data-tip":"Put the trail on the map now; any agent picks it up with /scout resume",onClick:()=>{h(!0);const R=I.split(`
145
+ `).map(z=>z.trim());o({title:k.trim(),destination:x.trim(),notes:b.trim(),assumptions:R.filter(Boolean)}).then(z=>c(z.key)).catch(z=>p(z.message)).finally(()=>h(!1))},children:"Create trail"})]})]})})}const Sb=e=>({title:e.title,destination:e.sections.destination,notes:e.sections.notes,assumptions:(e.sections.assumptions??[]).filter(t=>t.status!=="invalidated").map(t=>t.text)});function Nb(e){return i.jsx(jb,{seed:e.seed,onClose:e.onClose,tracker:e.rt.adapter.label,onCreate:async t=>{const s=await $S(e.rt.adapter,t);return e.onCreated(s.id),s}})}function bb(e,t){const[s,o]=y.useState(!1);return{open:()=>o(!0),startOver:d=>void t.actions.setArchived(!0).then(()=>o(Sb(d))),dialog:s&&i.jsx(Nb,{rt:e,seed:typeof s=="object"?s:void 0,onClose:()=>o(!1),onCreated:d=>t.actions.selectMap(d)})}}const Cb={gh:"your gh login",GITHUB_TOKEN:"GITHUB_TOKEN",GH_TOKEN:"GH_TOKEN",stored:"a saved token","signed-in":"your GitHub sign-in",LINEAR_API_KEY:"LINEAR_API_KEY"},Iu=e=>Cb[e];function Mu(e){var t;return((t=e.account)==null?void 0:t.kind)==="user"?e.account.login:void 0}const Tc=e=>!!e.auth&&!!Mu(e);function _g(e,t){const s=Mu(e);return!e.auth||!s?void 0:`Will use ${t||"the repo you pick"} as ${s} (${Iu(e.auth)})`}function $b(e){if(!e.repo)return;const t=Mu(e),s=t?` as ${t}`:"",o=e.auth?`, using ${Iu(e.auth)}`:"";return`Connected to ${e.repo}${s}${o}`}function Tb(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 Eb(e){const{gh:t}=e;if(!t.auth)return null;const s=_g(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 Ab=/^[\w.-]+\/[\w.-]+$/;function Ib(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=Ab.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 Im(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&&Tb(t,e.now),!s&&"Checked when you connect"]}),onOpen:e.onPick})}const Mb=40;function Mm(e){const[t,s]=y.useState(""),o=y.useMemo(()=>Date.now(),[]),a=y.useMemo(()=>new Set(e.repos.map(k=>k.fullName)),[e.repos]),{shown:c,matches:d,typed:h}=Ib({repos:e.repos,detected:e.detected,query:t,limit:Mb}),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:k=>s(k.target.value)})]}),i.jsxs("ul",{className:"repo-list","aria-label":"Repositories",children:[h&&i.jsx(Im,{repo:{fullName:h,private:!1},detected:h===e.detected,listed:!1,selected:h===e.value,now:o,onPick:()=>e.onChange(h)}),c.map(k=>i.jsx(Im,{repo:k,detected:k.fullName===e.detected,listed:a.has(k.fullName),selected:k.fullName===e.value,now:o,onPick:()=>e.onChange(k.fullName)},k.fullName))]}),i.jsx(V,{parts:[!d&&!h&&"No repo matches",m,p]})]})}function Rb(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(Mm,{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($u,{what:"Couldn't list your repos",reason:t.error,onRetry:e.onRetry}),i.jsx(Mm,{repos:[],truncated:!1,detected:e.detected,value:e.value,onChange:e.onChange})]});default:return t}}const Lb={stored:"Saved token",gh:"gh CLI",GITHUB_TOKEN:"$GITHUB_TOKEN",GH_TOKEN:"$GH_TOKEN","signed-in":"Signed in with GitHub",LINEAR_API_KEY:"$LINEAR_API_KEY"},Xi=e=>e==="github"||e==="linear";function Dg(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:Lb[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 Ob(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 _b(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 Dt=Yj(je());function Zi(e,t){e({tracker:t});const s=new URL(location.href);s.searchParams.delete("tracker"),location.href=s.toString()}function Db(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 Dt.githubSignIn.poll().then(async h=>{c&&(h.kind==="signed-in"&&await o.current(),c&&s(_b(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 Dt.githubSignIn.cancel().catch(()=>{})},[a]),{state:t,start(){s({kind:"starting"}),Dt.githubSignIn.start().then(c=>s(Pb(c)),c=>s({kind:"ended",reason:c.message}))},cancel(){s({kind:"idle"})}}}function zb(e){const{state:t,start:s,cancel:o}=Db(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(Ob,{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 Bb(e){var d,h;const{gh:t}=e,s=t.auth&&((d=t.account)==null?void 0:d.kind)==="unknown"?`Found ${Iu(t.auth)}, but GitHub didn't accept it`:"",o=((h=t.account)==null?void 0:h.kind)==="unknown"?t.account.error:"",a=t.auth==="GITHUB_TOKEN"||t.auth==="GH_TOKEN",c=t.signIn.available&&!a;return i.jsxs(i.Fragment,{children:[s&&i.jsx(V,{parts:[s,o]}),c&&i.jsx(zb,{onSignedIn:e.onSignedIn}),c&&i.jsx("span",{className:"t-label gh-or",children:"Or paste a token"}),i.jsx(Dg,{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 zg({r:e}){var o,a;if(!e)return null;if(!e.ok)return i.jsxs("div",{className:"test-line alert",children:["✕ ",e.error]});const t=(o=e.rate)!=null&&o.limit?`${(a=e.rate.remaining)==null?void 0:a.toLocaleString()}/${e.rate.limit.toLocaleString()} req`:"";let s="";return e.canWrite===!1?s="read-only":e.canWrite&&(s="read/write"),i.jsxs("div",{className:"test-line ok",children:["✓ ",[e.account,e.target,s,t].filter(Boolean).join(" · ")]})}function Ru(e){const[t,s]=y.useState(),[o,a]=y.useState(0);y.useEffect(()=>{if(s(void 0),!e.enabled)return;let 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 Fb(e){const{value:t,retry:s}=Ru({enabled:e.enabled,key:e.auth??"",load:()=>Dt.githubRepos(),failed:o=>({kind:"error",error:o})});return{list:t,retry:s}}function Bg(e){const t=e.s.github,s=Tc(t),[o,a]=y.useState(!s),[c,d]=y.useState(t.repo??t.detectedRepo??""),[h,m]=y.useState(""),[p,k]=y.useState(),[v,x]=y.useState(!1),{list:j,retry:b}=Fb({enabled:!o,auth:t.auth});y.useEffect(()=>{s&&!h&&a(!1)},[s]);const S=async()=>{x(!0),k(void 0);try{await Dt.connect({active:"github",github:{repo:c,token:o?h:void 0}}),e.onConnected()}catch(z){k({ok:!1,error:z.message}),x(!1)}},I=async()=>{const z=await e.reload();z&&Tc(z.github)&&a(!1)},C=async()=>{await Dt.githubSignIn.signOut().catch(()=>{});const z=await e.reload();a(!z||!Tc(z.github))},R=!!c&&!(!o&&!j)&&(!o||!!h||s);return i.jsxs("div",{className:"card inset tracker-setup",children:[o?i.jsx(Bb,{gh:t,token:h,onToken:m,repo:c,onRepo:d,onSignedIn:I}):i.jsxs(i.Fragment,{children:[i.jsx(Eb,{gh:t,repo:c,onUseAnother:()=>a(!0),onSignOut:()=>void C()}),i.jsx(Rb,{list:j,detected:t.detectedRepo,value:c,onChange:d,onRetry:b})]}),i.jsx(zg,{r:p}),i.jsx("footer",{children:i.jsx("button",{type:"button",className:"btn primary",disabled:v||!R,onClick:()=>void S(),children:v?"Connecting…":"Connect"})})]})}function Ub(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 Wb={LINEAR_API_KEY:"LINEAR_API_KEY",stored:"a saved key"},Lu=e=>Wb[e]??e;function va(e){return(e==null?void 0:e.kind)==="user"?e:void 0}const Hb=e=>!!e.auth&&!!va(e.viewer);function Fg(e,t){if(e)return t?`${e} / ${t}`:e}function Ug(e){const t=va(e.viewer);if(!t)return;const s=Fg(e.team,e.project)??"the team you pick",o=e.source?` (${Lu(e.source)})`:"";return`Will use ${s} in ${t.orgName} as ${t.name}${o}`}function Kb(e){const t=Fg(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 ${Lu(e.auth)}`:"";return`Connected to ${t}${a}${c}${d}`}function Vb(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 Gb(e){var a,c;const{ln:t}=e,s=t.auth&&((a=t.viewer)==null?void 0:a.kind)==="unknown"?`Found ${Lu(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(Dg,{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 qb(e){const{list:t}=e;if(!t)return i.jsx(ni,{label:"Loading projects…"});if(t.kind==="error")return i.jsx($u,{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(ut,{"aria-label":"Project",value:e.value,onChange:e.onChange,options:s})]})}function Qb(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 Yb(e,t){return t&&e.some(s=>s.id===t)?t:e.length===1?e[0].id:void 0}function Jb(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},Vb(t,e.now)]}),onOpen:e.onPick})}const Xb=40;function Zb(e){const[t,s]=y.useState(""),o=y.useMemo(()=>Date.now(),[]),{shown:a,matches:c}=Qb({teams:e.teams,query:t,limit:Xb}),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(Jb,{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 eC(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(Zb,{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($u,{what:"Couldn't list your teams",reason:t.error,onRetry:e.onRetry});default:return t}}function tC(e,t){const[s,o]=y.useState(e);return y.useEffect(()=>{const a=setTimeout(()=>o(e),t);return()=>clearTimeout(a)},[e,t]),s}function nC(e){const{value:t,retry:s}=Ru({enabled:e.enabled&&!!e.teamId,key:`${e.teamId}
146
+ ${e.apiKey??""}`,load:()=>Dt.linearProjects(e.teamId,e.apiKey),failed:o=>({kind:"error",error:o})});return{list:t,retry:s}}function sC(e){const{value:t,retry:s}=Ru({enabled:e.enabled,key:e.apiKey??"",load:()=>Dt.linearTeams(e.apiKey),failed:o=>({kind:"error",error:o})});return{list:t,retry:s}}function iC(e){const t=tC(e.apiKey.trim(),400),s=e.paste&&t?t:void 0,o=e.paste?!!t:!!e.ln.auth,a=sC({enabled:o,apiKey:s}),c=nC({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,k=o&&!!e.teamId&&!h;return{enabled:o,list:d,teams:m,projects:h,loading:p||k,retryTeams:a.retry,retryProjects:c.retry}}function Wg(e){var se;const t=e.s.linear,s=Hb(t),[o,a]=y.useState(!s),[c,d]=y.useState(""),[h,m]=y.useState(t.teamId??""),[p,k]=y.useState(t.projectId??""),[v,x]=y.useState(),[j,b]=y.useState(!1),{enabled:S,list:I,teams:C,projects:O,loading:R,retryTeams:z,retryProjects:Z}=iC({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(Yb(I.teams,t.teamId)??"")},[I]);const q=C.find(D=>D.id===h),H=(O==null?void 0:O.kind)==="ok"?O.projects.find(D=>D.id===p):void 0,re=(I==null?void 0:I.kind)==="ok"?I.viewer:t.viewer,Q=o?null:t.auth,ve=Ug({viewer:re,team:q==null?void 0:q.name,project:H==null?void 0:H.name,source:Q}),ze=async()=>{if(q){b(!0),x(void 0);try{await Dt.connect({active:"linear",linear:{teamId:q.id,teamKey:q.key,teamName:q.name,projectId:H==null?void 0:H.id,projectName:H==null?void 0:H.name,apiKey:o?c.trim():void 0}}),e.onConnected()}catch(D){x({ok:!1,error:D.message}),b(!1)}}},$e=D=>{m(D),k("")};return i.jsxs("div",{className:"card inset tracker-setup linear-setup",children:[o&&i.jsx(Gb,{ln:t,apiKey:c,onKey:d}),i.jsx(Ub,{line:ve,email:(se=va(re))==null?void 0:se.email,onUseAnother:o?void 0:()=>a(!0)}),S&&i.jsx(eC,{list:I,value:h,onChange:$e,onRetry:z}),q&&i.jsx(qb,{list:O,value:p,onChange:k,onRetry:Z}),i.jsx(zg,{r:v}),i.jsx("footer",{children:i.jsx("button",{type:"button",className:"btn primary",disabled:j||R||!q,onClick:()=>void ze(),children:j?"Connecting…":"Connect"})})]})}function rC(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 oC(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 aC(e){const{id:t,active:s,s:o}=e,a=Xi(t),c=s&&o?lC(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:oC(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:cC(t,o)}):null}function lC(e,t){if(e==="github")return $b(t.github);if(e==="linear")return Kb(t.linear)}function cC(e,t){return e==="github"?t.github.repo:[t.linear.teamKey,t.linear.projectName].filter(Boolean).join(" · ")}function uC({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]=dC(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 dC(e,t){switch(e.state){case"online":return["ok",`Online · synced ${hg(e.lastSyncAt)}${t}`];case"offline":return["warn",`Offline${t}`];case"rate-limited":return["warn",`Rate limited · resumes ${lr(e.resetAt)}${t}`];case"auth-error":return["alert",`Credentials rejected${t}`];default:return["",`Connecting${t}`]}}function hC(e){const{id:t,active:s,configured:o,s:a}=e,c=Xi(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(aC,{id:t,active:s,configured:o,location:e.location,s:a}),c&&s&&i.jsx(uC,{status:a==null?void 0:a[t].status}),i.jsx(rC,{canSwitch:!s&&(!c||o),remote:c,usable:d,configured:o,open:e.open,onSwitch:e.onSwitch,onToggle:e.onToggle})]})}function Hg(e=0){const[t,s]=y.useState(),o=y.useCallback(()=>Dt.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 fC(e){const[t,,s]=Hg(5e3),[o,a]=y.useState(null),c=async h=>{t&&(h==="markdown"||Xi(h))&&await Dt.connect({active:h==="markdown"?"markdown":h,...h==="github"&&t.github.repo?{github:{repo:t.github.repo}}:{},...h==="linear"&&t.linear.teamId?{linear:{teamId:t.linear.teamId,teamKey:t.linear.teamKey,teamName:t.linear.teamName,projectId:t.linear.projectId,projectName:t.linear.projectName}}:{}}).catch(()=>{}),Zi(e.update,h)},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:Jj.map(h=>{const m=h.id;return i.jsx(hC,{id:m,name:h.name,active:m===e.activeTracker,configured:Xi(m)&&d[m],open:o===m,location:e.location,s:t,onSwitch:()=>void c(m),onToggle:()=>Xi(m)&&a(o===m?null:m)},h.id)})}),t&&o==="github"&&i.jsx(Bg,{s:t,reload:s,onConnected:()=>Zi(e.update,"github")}),t&&o==="linear"&&i.jsx(Wg,{s:t,onConnected:()=>Zi(e.update,"linear")})]})}function mC(e,t){const s=e==null?void 0:e.github,o=e==null?void 0:e.linear,a=s&&t!=="github"?_g(s,s.repo??s.detectedRepo):void 0,c=o&&t!=="linear"?Ug({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 Me(e){return i.jsxs("section",{className:"set-sec",children:[i.jsx(Ue,{as:"h4",children:e.title}),e.children]})}function Kg(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(ft,{on:e.value===s.v,title:s.title,onClick:()=>e.onChange(s.v)},s.v))})}const pC={github:"Checking for a GitHub login…",linear:"Checking for a Linear key…"};function gC(e){var I;const{prefs:t,update:s}=e,[o,,a]=Hg(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 k=mC(o??void 0,t.tracker),v=t.tracker==="github"||t.tracker==="linear",x=v&&(o==null?void 0:o.active)===t.tracker,j=v&&!x,b=C=>{s({onboarded:!0}),Zi(s,C)},S=async()=>{d(!0);const C=o&&!o.pending;t.tracker==="markdown"&&C&&await Dt.connect({active:"markdown"}).catch(()=>{}),s({onboarded:!0}),t.tracker!==e.activeTracker&&Zi(s,t.tracker)};return i.jsx("div",{className:"scrim",children:i.jsxs(De,{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(k1,{className:"voice-badge",size:22}),"Where should your trails live?"]}),i.jsxs(Me,{title:"Tracker",children:[i.jsx("div",{className:"choice-row",children:k.map(C=>i.jsx(ft,{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&&v&&i.jsx(ni,{label:pC[t.tracker]??"Checking…"}),o&&t.tracker==="github"&&!x&&i.jsx(Bg,{s:o,reload:a,onConnected:()=>b("github")}),o&&t.tracker==="linear"&&!x&&i.jsx(Wg,{s:o,onConnected:()=>b("linear")})]}),i.jsx(Me,{title:"HITL transcript",children:i.jsx(Kg,{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 ir=[{id:"trail",label:"This trail",intro:"How agents work on the trail on screen: its mode, the checks that prove work done, models and guides.",sections:[{id:"mode",title:"Trail mode"},{id:"verification",title:"Verification"},{id:"models",title:"Model matching"},{id:"team",title:"Team"}]},{id:"project",label:"Project",intro:"Where this repo keeps its trails, and the rules every agent working in it follows.",sections:[{id:"approvals",title:"Approvals"},{id:"tracker",title:"Tracker"},{id:"workspaces",title:"Workspaces"},{id:"remote-agents",title:"Remote agents"},{id:"policy",title:"Risk policy"},{id:"guides",title:"Guides"},{id:"labels",title:"Labels"}]},{id:"alerts",label:"Attention & alerts",intro:"What interrupts you, where questions reach you, and what Scout tells you when you come back.",sections:[{id:"attention",title:"Attention"},{id:"slack",title:"Slack"},{id:"trip-report",title:"Trip report"}]},{id:"you",label:"You",intro:"How the Lookout looks and reads for you, and the browsers and devices signed in to it.",sections:[{id:"appearance",title:"Appearance"},{id:"transcript",title:"HITL transcript"},{id:"agent",title:"Agent"},{id:"devices",title:"Browsers & devices"}]},{id:"projects",label:"All projects",intro:"Every repo this Lookout knows, so you can switch between them from the header.",sections:[{id:"projects",title:"Projects"}]},{id:"about",label:"About",intro:"What Teamtrail is, and what changed in each release.",sections:[{id:"changelog",title:"Changelog"}]}];function Vg(e){if(e===null)return null;const t=ir.find(a=>a.id===e);if(t)return{group:t.id};const s=ir.find(a=>a.sections.some(c=>c.id===e));if(!s)return{};const o=s.sections.find(a=>a.id===e);return{group:s.id,section:o==null?void 0:o.id}}function vC(){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 Rm={from:"18:00",to:"09:00"};function kC(e){const t=e.focus!==void 0,s=e.focus??Rm;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:Rm),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 yC=[{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 wC(){typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()}function xC(){const{view:e,error:t,savePrefs:s}=Og(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(Me,{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(ut,{compact:!0,"aria-label":"Interrupt me by",value:e.prefs.channel,options:yC,onChange:h=>{h==="browser"&&wC(),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(kC,{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 jC=[5,15,30,60];function SC(e){const{value:t}=e;return i.jsxs("div",{className:"choice-row compact",children:[i.jsx(ft,{on:!t.enabled,title:"Off",onClick:()=>e.onChange({...t,enabled:!1})}),jC.map(s=>i.jsx(ft,{on:t.enabled&&t.awayMinutes===s,title:`Away ${s} min`,onClick:()=>e.onChange({enabled:!0,awayMinutes:s})},s))]})}const NC={repo:"Committed to the repo",machine:"Only on this machine",browser:"Only in this browser"};function qe(e){const t=e.storage&&NC[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 bC(e){const[t]=Au();return t?i.jsx(Me,{title:"Slack",children:i.jsx(kN,{focus:e.focus})}):null}function CC({data:e,route:t}){return i.jsxs(i.Fragment,{children:[i.jsx(qe,{id:"attention",storage:"repo",children:i.jsx(xC,{})}),i.jsx(qe,{id:"slack",storage:"machine",children:i.jsx(bC,{focus:t.section==="slack"})}),i.jsx(qe,{id:"trip-report",storage:"browser",children:i.jsx(Me,{title:"Trip report",children:i.jsx(SC,{value:e.prefs.briefing,onChange:s=>e.update({briefing:s})})})})]})}const $C=[{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"]}],TC=[{version:"0.20.0",date:"2026-11-04",items:["Separate workspaces: switch on Settings → Workspaces and each ticket an agent claims gets its own copy of the repo on its own branch, so agents working at the same time don’t step on each other. When the work is done you get the branch to review; MILOOPS never merges or pushes for you","Warnings before a clash: agents say which files they expect to change. When two of them plan to change the same files, the second one is warned, and you see it in Waiting on you; open it to release either claim","When two agents’ branches did change the same files, Waiting on you suggests a ticket to bring the work together. One click adds it, waiting on both tickets, with the files listed","The ticket inspector shows which files an agent expects to change and the branch it works on","Fix: an execute ticket marked as needing you keeps that mark when saved to local files, GitHub Issues or Linear"]},{version:"0.19.0",date:"2026-11-04",items:["Risk policy: you decide what always needs you, such as database changes, logins and permissions, billing, deleting data or new dependencies (Settings → Risk policy). Agents can no longer make those calls on their own; they ask you. Their other decisions are labelled by risk in the briefing, and work that touched risky files without asking comes to you to check","One ranked list of everything that needs you in Waiting on you: questions, approvals, blocked work, briefs, knowledge and new plans, most important first, each with the reason (for example “blocks 3 tickets” or “claude-02 is waiting”). Related items are grouped so you answer them together; snooze what can wait","Fewer interruptions: agents say how urgent a question is, and only urgent items notify you (browser or Slack). Focus for an hour from the header, set quiet hours in Settings → Attention, and the rest waits in the list and the digest","Plans that adapt: missions list the assumptions they rely on, starting with the ones in the discovery brief. When an agent finds one is wrong, it shows the evidence and proposes a new plan; the tickets it would change are paused, the map previews the change, and nothing happens until you approve","Challenge the destination: an agent can tell you the work already exists, the mission targets the wrong problem, or it should be rescoped, with evidence and a suggested new goal","Assumptions on the Plan tab (confirm the ones you know are true) and an assumptions field when you create a mission","Fix: when an agent asks two questions at once, your answer goes to the one you opened; the inbox stats line no longer gets covered by the list"]},{version:"0.18.0",date:"2026-11-04",items:["Acceptance criteria: agents write down what done means before they start (required on missions with a discovery brief). When they finish, each point needs proof: one of your checks, a named test, the pull request, or your sign-off","Work whose criteria lack proof goes back with the reason; points only you can confirm come to your inbox to sign off","Business rules from your project knowledge are suggested as criteria, and the ticket shows any rule no criterion covers yet. Confirm a ticket’s criteria in the inspector","Cross-vendor review: when Claude and Codex agents both run, each reviews the other’s work first","Fix: answers from the command center could hang when too many live updates were open; all updates now share one connection"]},{version:"0.17.0",date:"2026-11-03",items:["Discovery brief: new missions start with an agent mapping the existing system (files, conventions, data and API impact, risks, assumptions, product context). Implementation tickets wait until you accept the brief or ask for changes, from the banner over the map or the card in Communication","Create mission: start a mission from the New mission dialog without a terminal; any agent picks it up with /milo resume","Knowledge: what agents need to know about your codebase and product (architecture, conventions, gotchas, dead ends, business rules, personas, UX principles, pricing). Agents propose, you confirm, keep as an assumption or retire. Confirmed entries reach agents with every claim, picked for the ticket with the reason, and the inspector shows what an agent gets","Knowledge about specific files is flagged for re-confirmation when those files change","Save decisions, cancelled tickets (as dead ends) and brief sections as knowledge in one click; seed it from a document with miloops knowledge import <file.md>"]},{version:"0.16.0",date:"2026-11-03",items:["Mission report (Mission plan → Report): tickets done, mission and median ticket lead time, your interventions, rework, review results and cost per verified ticket. Hover any number to see how it is computed; export it as markdown","Agents report the same numbers in one line from the status tool","Agents use missions for big work only, and decide routine calls themselves, keeping each one as a decision record you can review or reverse; they ask you when the call changes product behaviour, data, security, billing, a public API or the schema","Decisions: filter by who made the call, agents on their own or people. The briefing now counts only the calls agents made themselves, not your answers they recorded"]},{version:"0.15.0",date:"2026-10-31",items:["Verification in the ticket inspector: the level that applies and where it comes from, every attempt newest first with the git evidence (base → head, files changed, flags), its checks, exit codes, durations and the failing output, and the full log on demand","Verifying, Rework and Blocked on the map, in the legend and as status counters on missions that verify completions","Operator calls on a verifying or blocked ticket: Approve, Re-run checks, Send to rework with a note, Accept anyway and Unblock. Overrides need a reason, and each call is kept as a verdict next to the attempts and in the mission history. Approve asks for a re-run when the code changed since the checks passed","Set the verification level of a mission (Settings → Verification) or of one ticket (inspector). Only you can change it; agents cannot","The inspector updates live while checks run","Independent review: at Checks + review, a passing completion gets a review ticket that another agent takes and answers with PASS, FAIL (with findings) or NEEDS_HUMAN. The agent that did the work is never given its own review","Waiting on you lists reviewed work to approve (Checks + review + you) and held tickets, and Slack posts them with Approve and Rework… buttons","Agents can name their pull request in `report_completion` (`pr`); PR and CI tracking then follows that PR first"]},{version:"0.14.0",date:"2026-10-31",items:["Ticket lifecycle in plain words: Ready, Backlog, Working, Done and Cancelled (with Verifying, Rework and Blocked to come with verification)","Every claim, release, return to queue, resolution and rule-out goes through one lifecycle engine that records who, why and when in `.miloops/.events/<mission>.jsonl` (local history, never committed)","Settings → Verification shows the checks in `.miloops/verification.json`: argv commands with timeouts, run without a shell, secrets kept out of their environment. Read-only","Completion is a claim: on missions started with `verification.json` present, an execute or task ticket is only done once its checks pass. A failed check sends it back for Rework with the failing output (agents see it in close_ticket, next_ticket and claim_ticket, and rework comes first in the queue); after 3 failed attempts, or when the checks cannot run, it waits on you as Blocked","New MCP tools `report_completion` and `verification_status`; missions started before verification, and research, grilling and prototype tickets, close exactly as before","Git evidence, no GitHub needed: each claim records HEAD and the uncommitted state, and each completion lists the files changed since then. It flags no changes, overlap with another active ticket, a branch switch or reset, and edits to `verification.json` (which send the ticket to you as Blocked). A pass on code that changed while its checks ran is re-run","Pull request and CI evidence: with `verification.json` and a GitHub token (Settings, `GITHUB_TOKEN` or `gh auth login`), the command center finds each ticket’s PR (its branch `miloops-<mission>-<ticket>`, a `miloops:<mission>#<ticket>` line in the PR body, or a link you set) and flags mismatches: done with the PR still open, PR merged while the ticket is in progress, PR closed unmerged, required checks failing or unknown, PR head not the verified commit. Flags never change a ticket. A CI chip in the header shows sync health and never shows synced after a failed sync"]},{version:"0.13.0",date:"2026-10-31",items:["Crash recovery for claims: an agent’s claim is a lease (15 min by default) that every tool call renews, including waits on your answer","When an agent crashes or goes silent, its ticket goes back to the queue on its own, and the activity log says so; the next agent picks it up from next_ticket or claim_ticket","The returned ticket keeps a handoff comment with the previous agent’s progress notes and decisions, so the next agent resumes instead of starting over","Stalled state on the map, in sessions and in the ticket inspector when a lease is about to run out, with a Release to queue action","Works with GitHub and Linear: the return is an ordinary comment + unassign, queued in the offline outbox like any other write","Set the lease with `miloops mcp --lease-minutes <n>` or `MILOOPS_LEASE_MINUTES`"]},{version:"0.12.0",date:"2026-10-31",items:["Slack: your own MILO app, created from a manifest and connected from your machine over Socket Mode in five guided steps (Settings → Slack or `miloops connect slack`)","Tokens stay in your local credential store next to the GitHub and Linear ones; nothing passes through MILOOPS servers","Agent questions arrive as a Slack DM with answer buttons and a Reply… box; answering there resolves the item in Waiting on you, and answering in the command center closes the DM","Save as decision on any message, or `/milo decide`: the form is prefilled with a summary of the thread, and the decision is recorded with a permalink, resolving the related ticket by default","`/milo status` and `/milo inbox` for the mission at a glance; DMs when a ticket is blocked or a mission is done","Allowed users, notification target and events in Settings → Slack","Slack setup without Paste clicks: press ⌘V / Ctrl+V anywhere, or in Chrome just come back to the tab after copying; pasting the app token opens the install page; MILO recognises you by your git email, so there is nothing to claim in Slack"]},{version:"0.11.0",date:"2026-10-31",items:["GitHub Issues tracker: missions are labelled issues, tickets are sub-issues, blocking uses native issue dependencies",'Linear tracker: missions are labelled issues in a team (optionally one project), tickets are sub-issues, blocking uses "blocks" relations',"Two-way sync: tickets, status, claims, comments, blockers and decisions written from MILOOPS land in the tracker; changes made there show up within seconds","Decisions are posted as comments on their ticket and listed in the mission","Connect from Settings with Test connection; GitHub reuses your gh login or GITHUB_TOKEN, Linear takes a personal API key","Tokens stay on your machine: kept by the local server, never sent to the browser or anywhere else","Offline and rate limits: changes queue and send in order when the tracker answers again; the connector shows status, queue and remaining requests","Connected agents (MCP) work on the active tracker: with GitHub or Linear connected, their missions, claims and decisions land there, and their sessions show live in the command center"]},{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"]},...$C],EC=[{area:"Teamtrail Cloud",items:["Agents that run in the cloud, steered from the same Lookout"]}],AC=[{version:"0.32.0",date:"2026-11-13",items:["Scout has a new look: a scout companion with a cap, a headset and an antenna, looking out along the trail"]},{version:"0.31.1",date:"2026-11-13",items:["An archived trail’s held work and changes waiting for your approval stay in your queue"]},{version:"0.31.0",date:"2026-11-13",items:["Start a trail over: the trail menu archives the map that went wrong and opens New trail with its idea filled in","Archive a trail you are done with, or restore it: it stays as history, and no agent takes work from it","The empty map looks like every other empty zone, with New trail and the agent command under it"]},{version:"0.30.0",date:"2026-11-12",items:["Ask Scout more in Slack: “what's blocking #12?”, “what did we decide about retention?”, “who's working?”, as @Scout, a DM or /scout ticket, decisions and who","In a channel, the answers are seen only by you"]},{version:"0.29.3",date:"2026-11-12",items:["@Scout inbox and status in a channel now show up right away, seen only by you"]},{version:"0.29.2",date:"2026-11-12",items:["The Activity log reads in one style: a coloured bar marks what needs you (red), what went well (green) and what is held up (amber), and Slack answers show who gave them"]},{version:"0.29.1",date:"2026-11-12",items:["Scout says in Slack that it needs Teamtrail running on your computer, and how to start it, when it can’t reach yours","Ask Scout in your own words: “@Scout what’s in my inbox?” or “status of Slack live test” work, in a channel or a DM"]},{version:"0.29.0",date:"2026-11-12",items:["Ask Scout in Slack: @Scout inbox or @Scout status in a channel answers only you, or DM Scout; if you added Scout before, Settings asks you to reconnect once","A question your agent waits on gets its own Slack message with answer buttons, even right after it asked another one","Scout can be installed straight from Slack (scout.teamtrail.app/install-slack); each person then connects in Settings → Slack"]},{version:"0.28.0",date:"2026-11-12",items:["Scout is now one Slack app: Settings → Slack → Add Scout to Slack, no app to create and no tokens to paste","You confirm which Slack account becomes Scout’s owner before it connects; if you made your own Slack app before, add Scout again","High-risk calls are answered in the Lookout only, and so is approving an agent’s request to change your settings: Slack shows Open in Lookout, and Decline still works there"]},{version:"0.27.3",date:"2026-11-11",items:["On Linux, the Lookout sees every change an agent makes to a ticket again, not only the first: a claimed ticket no longer stays in the queue as waiting"]},{version:"0.27.2",date:"2026-11-11",items:["Settings, briefs, criteria, guides, reroutes and the other panels stay current through reconnects, and a GitHub or Linear map updates live again"]},{version:"0.27.1",date:"2026-11-11",items:["The map and the queue no longer miss a change made while the Lookout was loading or reconnecting"]},{version:"0.27.0",date:"2026-11-11",items:["Teamtrail opens your browser ready to sign in with one click; `teamtrail pair` does the same for another tab"]},{version:"0.26.2",date:"2026-11-11",items:["The Lookout shows the new teamtrail. wordmark"]},{version:"0.26.1",date:"2026-11-11",items:["A refreshed logo: the trail’s destination is larger, and there are light and dark versions that follow your theme"]},{version:"0.26.0",date:"2026-11-11",items:["The Lookout asks you to sign in: open the link `teamtrail` prints, and pair your phone with a QR code (again after each restart)","Your answers count only when you give them in the Lookout or Slack, and skipping discovery or changing a trail’s mode or destination waits for your Approve","Check commands, briefs, criteria and other trusted settings run only once you approve them on this machine, in Settings → Approvals","Changes made to trail files outside Teamtrail have no effect until you accept them"]},{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"]},...TC];function IC(){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(Me,{title:"Next",children:EC.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))}),AC.map(e=>i.jsx(Me,{title:`${e.version} · ${e.date}`,children:i.jsx("ul",{children:e.items.map(t=>i.jsx("li",{children:t},t))})},e.version))]})}function Gg(){const[e,t]=y.useState();return y.useEffect(()=>{fetch(`${je()}/machine`).then(s=>s.ok?s.json():void 0).then(s=>t(s==null?void 0:s.local),()=>t(void 0))},[]),e}const Lm={checks:"Completions run these commands on this machine",catalogs:"Guides can then be searched for and added from these addresses",policy:"Agents may then decide these alone",brief:"Implementation tickets of the trail open up",criteria:"These criteria define done for the ticket",knowledge:"Agents get it as trusted context with their claims",level:"Completions on it are checked this much",type:"The trail's level applies to a ticket by its type",state:"Accepting signs it as yours on this machine: gates then read the file as it is",discovery:"Agents may claim its implementation tickets without a discovery brief, and criteria are no longer required"},Om={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 qg(e){return e.kind==="state"?MC(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 MC(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 RC="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 LC(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 OC=["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 PC(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(`
147
+ `)}),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 _C(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 DC=e=>e.files??(e.file?[e.file]:[]);function zC(e){const{item:t}=e,[s,o]=y.useState(!1),a=DC(t),c=t.revert??"restore";return i.jsx(Ce,{as:"li",className:"ap-row",edge:"attention",title:t.title,context:i.jsx(V,{parts:[qg(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(`
148
+ `)}),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(_C,{files:a,busy:e.busy,onDelete:()=>(o(!1),e.onRevert(a)),onCancel:()=>o(!1)})]})})}function BC(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 FC(e){const{item:t}=e,s=t.committed===!1,o=t.kind==="catalogs"?[...t.lines,""]:[],a=s?[...o,...t.content.split(`
149
+ `)]:t.lines;return i.jsx(Ce,{as:"li",className:"ap-row",edge:"attention",title:t.title,context:i.jsx(V,{parts:[qg(t)]}),detail:Lm[t.kind],detailText:Lm[t.kind],below:i.jsxs("div",{className:"ap-below",children:[i.jsx("pre",{className:"ap-lines t-code",children:a.join(`
150
+ `)}),Om[t.kind]&&i.jsx("p",{className:"ap-note t-meta",children:Om[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 Pm(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 Ec=async e=>e.ok?await e.json():void 0;async function _m(){var p;const[e,t,s]=await Promise.all(["/trust","/trackers","/trackers/legacy-outbox"].map(k=>fetch(`${je()}${k}`))),o=await Ec(e);if(!o)return null;const{items:a}=o,c=(p=await Ec(t))==null?void 0:p.pending,d=await Ec(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 UC=(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 WC(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 HC(){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 _m().then(b,()=>b(null))},[d]),p=y.useCallback(async()=>{if(c.current)return;const j=h.current,b=await _m().catch(()=>null),S=a.current;h.current!==j||S===void 0||(!b||!S||!UC(b,S))&&o(!0)},[]);y.useEffect(()=>void m(),[m]),y.useEffect(()=>Nu(j=>void(j.startsWith(".")||p())),[p]),y.useEffect(()=>hs(()=>void p()),[p]);const k=y.useCallback(async j=>{c.current++;try{const b=await j();return await m(),b}finally{c.current--}},[m]),v=y.useCallback(async j=>WC(await k(()=>Pm("/trust/approve",{items:j.map(b=>({key:b.key,hash:b.hash}))}))),[k]),x=y.useCallback(async(j,b)=>{await k(()=>Pm(j,b))},[k]);return{view:e,changed:s,load:m,approve:v,act:x}}function KC(){const{view:e,changed:t,load:s,approve:o,act:a}=HC(),c=Gg()!==!1,[d,h]=y.useState(!1),[m,p]=y.useState();if(!e)return null;const k=C=>{h(!0),p(void 0),C.then(O=>(h(!1),p(O??void 0)),O=>(h(!1),p(O.message)))},{items:v,tracker:x,oldQueue:j}=e,b=C=>!C.alone&&(C.kind==="state"?e.stateFirstRun&&C.standing==="elsewhere":e.firstRun),S=v.filter(C=>C.committed!==!1&&b(C)),I=v.length+(x?1:0)+(j?1:0);return i.jsxs(Me,{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:LC(S.length)}),v.some(C=>C.kind==="state")&&i.jsx("p",{className:"ap-note t-meta",children:RC}),I>0&&i.jsxs("ul",{className:"ap-list",children:[x&&i.jsx(BC,{tracker:x,busy:d,local:c,onDecide:C=>k(a("/trackers/approval",{use:C,target:x.target}))}),j&&i.jsx(PC,{queue:j,busy:d,local:c,onDecide:C=>k(a("/trackers/legacy-outbox",{action:C?"send":"discard",writes:j.writes}))}),v.map(C=>C.kind==="state"?i.jsx(zC,{item:C,busy:d,local:c,onAccept:()=>k(o([C])),onRevert:O=>k(a("/trust/revert",{key:C.key,hash:C.hash,remove:O}))},C.key):i.jsx(FC,{item:C,busy:d,local:c,onApprove:()=>k(o([C]))},C.key))]}),c&&S.length>1&&i.jsxs(P,{disabled:d||t,onClick:()=>k(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:OC})]})}function Qg(e){return i.jsx("ul",{className:"checklist-answers",children:e.answers.map(t=>i.jsxs("li",{className:t.done?"done":"not-done",children:[i.jsx("span",{className:"mark","aria-label":t.done?"Done":"Not done",children:t.done?"✓":"–"}),i.jsx("span",{className:"t-body",children:t.item}),t.note&&i.jsx("span",{className:"t-meta note",children:t.note})]},t.item))})}const Yg=`${te.apiPrefix}`;async function Jg(e){const t=await e.json().catch(()=>({}));if(!e.ok)throw new Error(t.error??`Request failed (${e.status})`);return t}const Ko=async e=>Jg(await fetch(`${Yg}${e}`)),Xg=async(e,t)=>Jg(await fetch(`${Yg}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}));let Zg;const Ro=new Set;let Vn;function Zc(e){Zg=e;for(const t of Ro)t()}function ev(e){Vn==null||Vn.pushed(),Zc(e)}const VC=()=>Zg;function GC(e){return Ro.add(e),Vn??(Vn=Tg({load:()=>Ko("/guides"),show:Zc,failed:()=>Zc(null),changed:t=>t.includes("guides")})),()=>{Ro.delete(e),!Ro.size&&(Vn==null||Vn.stop(),Vn=void 0)}}function jn(){const e=y.useSyncExternalStore(GC,VC),t=y.useCallback(async(o,a)=>{try{ev(await Xg(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 qC(e){var h;const{view:t,find:s}=jn(),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:Ve("guide-chip",a&&"off"),"data-guide-id":e.id,title:d,children:c})}const QC={active:"Active",unapproved:"New, waiting for your approval",tampered:"Changed since you approved it",invalid:"Can't be used"},YC={active:"Approved",unapproved:"Not approved yet",tampered:"Changed since you approved it",invalid:"Can't be used"},eu=e=>{var t;return e.origin==="local"&&(!((t=e.lock)!=null&&t.source)||e.lock.source==="local")};function JC(e){return eu(e)?{text:YC[e.status],strong:e.status==="active"}:e.status==="active"?void 0:QC[e.status]}function Vo(e){try{return new URL(e).host}catch{return e}}function XC(e){var s;if(e.origin==="builtin")return"Built in";const t=(s=e.lock)==null?void 0:s.source;return!t||t==="local"?e.overridesBuiltin?"Local, replaces the built-in":"Local":`From ${Vo(t.registry)}`}const Ou=e=>e.map(t=>/\s/.test(t)?JSON.stringify(t):t).join(" "),Dm=3;function ZC(e,t){return e.length<=Math.max(t,Dm+1)?e:`${e.slice(0,Math.max(t-1,Dm)).trimEnd()}…`}function tv(e){return e===e0?"Verified":`Verified by ${Vo(e)}'s catalog`}function nv(e,t){return e.builtin?{text:"Built in",strong:!0}:e.verified?{text:tv(t),strong:!0}:"Not reviewed"}function e$(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"?tv(o.registry):"Verified",strong:!0,tip:s}}var t$=pp();function sv(e){return z0(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 n$(e){var x;const{preview:t}=e,{act:s,find:o}=jn(),[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 k=((x=o(m))==null?void 0:x.pendingChecks)??a.pending,v=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:k.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}.`}),k.map(j=>{var b,S,I;return i.jsxs("span",{className:"guide-check",children:[i.jsxs("code",{className:"t-code",children:[j,": ",Ou(((S=(b=t.guide)==null?void 0:b.proposedChecks[j])==null?void 0:S.run)??[])]}),i.jsx(sv,{name:j,spec:((I=t.guide)==null?void 0:I.proposedChecks[j])??{run:[]},onApprove:(C,O)=>void v(C,O)})]},j)}),d&&i.jsx("span",{className:"vf-err",children:d})]})}function s$(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 iv(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(s$,{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,": ",Ou(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 i$(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 r$(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}`,nv(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(iv,{p:s}),s&&i.jsx(i$,{repo:s.repo,id:t.id,version:t.version}),s&&i.jsx(n$,{preview:s,installed:e.installed,add:e.add})]})}function o$(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,nv(t,e.catalogUrl),t.reported&&"Reported"]}),detail:t.summary,trailing:e.installed&&`installed ${e.installed}`,onOpen:e.onOpen})})}const zm=e=>e?`registry=${encodeURIComponent(e)}`:"";function a$(e){const[t,s]=y.useState(),[o,a]=y.useState();y.useEffect(()=>{let h=!0;return s(void 0),a(void 0),Ko(`/guides/catalog?${zm(e)}`).then(m=>h&&s(m),m=>h&&a(m.message)),()=>{h=!1}},[e]);const c=y.useCallback(h=>Ko(`/guides/catalog/preview?${zm(e)}&id=${encodeURIComponent(h)}`),[e]),d=y.useCallback(async(h,m)=>{const p=await Xg("/guides/catalog/add",{registry:e,id:h,sha256:m});return ev(p),p.installed},[e]);return{index:t,error:o,preview:c,add:d}}function l$(e){var S,I;const[t,s]=y.useState(((S=e.registries[0])==null?void 0:S.name)??""),o=a$(t||void 0),{find:a}=jn(),[c,d]=y.useState(""),[h,m]=y.useState(!0),[p,k]=y.useState(),v=o.index?B0({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 O,R,z;return((O=a(C))==null?void 0:O.origin)==="local"?(z=(R=a(C))==null?void 0:R.guide)==null?void 0:z.version:void 0},b=e.registries.find(C=>C.name===t);return t$.createPortal(i.jsx("div",{className:"scrim catalog-scrim",onClick:C=>{C.stopPropagation(),e.onClose()},children:i.jsxs(De,{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(ut,{compact:!0,"aria-label":"Catalog",value:t,options:e.registries.map(C=>({value:C.name,label:`${C.name} · ${Vo(C.url)}`,hint:C.url})),onChange:s}),i.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})]}),b&&e.registries.length===1&&i.jsx(V,{parts:[`Catalog ${b.name}`,{text:Vo(b.url),code:!0}]}),x?i.jsx(r$,{entry:x,catalogUrl:(b==null?void 0:b.url)??"",installed:j(x.id),preview:o.preview,add:o.add,onBack:()=>k(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(Ie,{children:"Reading the catalog…"}),o.index&&!v.length&&i.jsx(Ie,{children:"No guides match."}),i.jsx("ul",{className:"catalog-list",children:v.map(C=>i.jsx(o$,{entry:C,catalogUrl:(b==null?void 0:b.url)??"",installed:j(C.id),onOpen:()=>k(C.id)},C.id))})]})]})}),document.body)}function c$(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,": ",Ou(c.run)]}),d&&o&&i.jsx(sv,{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 u$(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(iv,{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 d$="A file in guides/ replaces this built-in once you approve it; until then the built-in is used";function h$(e){var t,s;return e.override?d$:e.status==="unapproved"?(t=e.guide)==null?void 0:t.summary:e.reason??((s=e.guide)==null?void 0:s.summary)}function rv(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},XC(t),e$(t),JC(t),t.guide&&f$(t.guide.checklist.length)]}),detail:h$(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(u$,{r:o,busy:e.busy,onApprove:h=>e.onAct("/guides/approve",{id:s,sha256:h})}),i.jsx(c$,{r:t,busy:e.busy,onApprove:(h,m)=>e.onAct("/guides/checks/approve",{id:s,name:h,acknowledged:m})})]})})})}const f$=e=>e===1?"1 checklist item":`${e} checklist items`;function m$(e){return i.jsxs(Me,{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(rv,{r:t,busy:e.busy,onAct:e.onAct},t.id))}):i.jsx(Ie,{children:"No guides of your own yet."}),e.error&&i.jsx("span",{className:"vf-err",children:e.error}),i.jsxs("p",{className:"t-meta guides-share",children:["Useful beyond your team? Check it with ",i.jsxs("code",{className:"t-code",children:[te.slug," guides lint"]})," and"," ",i.jsx("a",{href:t0,target:"_blank",rel:"noreferrer",children:"share it in the public catalog"}),"."]})]})}function p$(e){const{view:t,act:s}=jn(),[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 k=x=>(j,b)=>{d(!0),s(j,b).then(S=>{a(S?{own:x,message:S}:void 0),d(!1)})},v=x=>o&&o.own===x?o.message:void 0;return i.jsxs("div",{className:"guides-section",ref:p,children:[i.jsxs(Me,{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=>!eu(x)).map(x=>i.jsx(rv,{r:x,busy:c,onAct:k(!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))}),v(!1)&&i.jsx("span",{className:"vf-err",children:v(!1)})]}),i.jsx(m$,{guides:t.guides.filter(eu),busy:c,onAct:k(!0),error:v(!0)}),h&&i.jsx(l$,{registries:t.registries,onClose:()=>m(!1)})]})}function g$(e){const{view:t,act:s}=jn(),[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(k=>k!==m):[...c,m];a(void 0),s("/guides/team",{mapId:e.map.id,guides:p}).then(a)};return i.jsxs(Me,{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 v$(e,t){const[s,o]=y.useState(),a=`/guides/checklist?mapId=${encodeURIComponent(e)}&ticketId=${encodeURIComponent(t)}`;return mt({view:a,load:()=>Ko(a),show:c=>o(c.checklist),failed:()=>o(null),changed:c=>c.endsWith("checklist.json")}),s}function k$(e){const t=v$(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,lr(t.at),s?`${s} not done`:"all done"]}),i.jsx(Qg,{answers:t.answers})]})}const Bm="";function y$(e){const{view:t,act:s}=jn(),[o,a]=y.useState();if(!t)return null;const c=e.ticket,d=t.guides.filter(p=>{var k;return p.status==="active"&&((k=p.guide)==null?void 0:k.handles.types.includes(c.type))}),h=[{value:Bm,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(ut,{compact:!0,"aria-label":"Ticket guide",value:c.guide??Bm,options:h,onChange:m}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function w$(e){const{view:t,find:s}=jn();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 x$(e){const{view:t}=jn(),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(y$,{mapId:e.mapId,ticket:s}):s.guide&&i.jsx(qC,{id:s.guide})]}),s.guide&&i.jsx(w$,{id:s.guide}),i.jsx(k$,{mapId:e.mapId,ticketId:s.id})]})}function j$(e){var m;const{view:t,find:s}=jn();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 ov="0.32.0-next.46",tu="<endpoint>",Pu=vp(ov,["mcp","--http"]);function S$(e,t){const s=vp(ov,["connect",e,"--url"]),o=t===tu?t:gp(t);return`read -rs ${te.tokenEnv} && export ${te.tokenEnv}
151
+ ${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 b$({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:Pu,code:!0}]})})]})}function C$(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(k=>k.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 $$(){return i.jsx(Me,{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 T$(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 E$(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 ${Wo(s.createdAt,t)}`,s.lastUsedAt?`Last used ${Wo(s.lastUsedAt,t)}`:"Never used"]}),below:i.jsx(T$,{name:s.name,onRevoke:()=>e.onRevoke(s.id)})},s.id))})}function Ac(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 A$=[{id:"claude",label:"Claude Code"},{id:"codex",label:"Codex"}];function I$(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(Ac,{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(Ue,{children:"Start the server for remote agents"})}),i.jsx(Ac,{label:"Start command",value:Pu,copyLabel:"Copy command"})]}),i.jsxs("div",{className:"ra-reveal-head",children:[i.jsx(Ue,{children:"Run on the agent's machine"}),i.jsx("span",{className:"ra-clients",children:A$.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(Ac,{label:"Connect command",value:S$(t,e.endpoint??tu),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 ${tu}.`,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 av=`${je()}/remote-agents`;async function Fm(e,t){const s=await fetch(`${av}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return{ok:s.ok,reply:await s.json()}}async function M$(){const e=await fetch(av);return e.ok?await e.json():(await e.json().catch(()=>({}))).elsewhere?"elsewhere":null}function R$(){const[e,t]=y.useState(),[s,o]=y.useState(),{pushed:a}=mt({load:M$,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:k}=await Fm("/tokens",{name:m});if(!p||!k.token||!k.created)return k.error??"The token could not be created.";c(k),o({token:k.token,name:k.created.name})},[c]),h=y.useCallback(async m=>{const{ok:p,reply:k}=await Fm("/tokens/revoke",{id:m});return k.tokens&&c(k),p?void 0:k.error??"The token could not be revoked."},[c]);return{view:e,created:s,dismissCreated:()=>o(void 0),create:d,revoke:h}}function L$(){var d;const{view:e,created:t,dismissCreated:s,create:o,revoke:a}=R$();if(!e)return null;if(e==="elsewhere")return i.jsx($$,{});const c=(d=e.endpoints.find(h=>h.kind==="standalone"))==null?void 0:d.url;return i.jsxs(Me,{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(b$,{endpoints:e.endpoints}),t&&i.jsx(I$,{created:t,endpoint:c,onDone:s}),i.jsx(E$,{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(C$,{onCreate:o}),i.jsxs("div",{className:"ra-notes",children:[i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"Before you open it to other machines."})," The connection is plain HTTP. Run ",i.jsx("code",{children:Pu}),", which serves the agent tools and nothing else, and put that port behind HTTPS with a reverse proxy or a tunnel. The Lookout's own port is not for sharing: its agent endpoint answers this machine only. A token only ever opens the agent tools, never the Lookout, which signs in browsers, not agents."]}),i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"What a remote agent can't do."})," Speak for you: it can't answer a question, skip discovery, change the trail's mode or destination, or close a ticket that needs you before you've answered here or in Slack. And its files aren't on this machine, so it gets no worktree, and on trails with verification its finished work comes to you to review instead of running the checks here."]}),i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"How far to trust one."})," The risk policy only sees what an agent declares: a call is held for you when the agent names a high-risk category or touches files your path rules cover. An agent that declares nothing isn't caught. Give an agent you don't fully trust only trails with verification on, where its finished work comes to you."]}),i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"What it does as you."})," With GitHub Issues or Linear as the tracker, everything a remote agent writes (tickets, comments, closing) goes to the tracker with your credentials, like the agents here."]})]})]})}const Um={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"},O$={low:"the agent decides",medium:"the agent decides and records it",high:"you decide"},P$=e=>e[0].toUpperCase()+e.slice(1),nu=zp.map(e=>({value:e,label:P$(e),hint:O$[e]}));function _$(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(ut,{compact:!0,"aria-label":`${m.glob} risk`,value:m.level,options:nu,onChange:k=>d(c.map((v,x)=>x===p?{...v,level:k}:v))}),i.jsx("button",{className:"icon-btn","aria-label":`Remove ${m.glob}`,onClick:()=>d(c.filter((k,v)=>v!==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(ut,{compact:!0,"aria-label":"New pattern risk",value:o,options:nu,onChange:a}),i.jsx(P,{onClick:h,disabled:!t.trim(),children:"Add"})]})]})}const lv=`${je()}/policy`;async function D$(){const e=await fetch(lv);return e.ok?await e.json():null}function z$(){const[e,t]=y.useState(),{pushed:s}=mt({load:D$,show:t,failed:()=>t(null),changed:a=>a.endsWith("policy.json")}),o=y.useCallback(async a=>{const c=await fetch(lv,{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 B$(){const{view:e,save:t}=z$(),[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(Me,{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:Dp.map(d=>i.jsxs("label",{className:"risk-row",children:[i.jsx("span",{children:Um[d]}),i.jsx(ut,{compact:!0,"aria-label":`${Um[d]} risk`,value:e.policy.categories[d],options:nu,onChange:h=>c({...e.policy,categories:{...e.policy.categories,[d]:h}})})]},d))}),i.jsx(_$,{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 su=`${je()}/workspaces`;async function F$(){const e=await fetch(su);return e.ok?await e.json():null}function cv(){const[e,t]=y.useState(),{pushed:s}=mt({load:F$,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(su,{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(`${su}/remove`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:d,ticketId:h,force:m})}),k=await p.json();return p.ok?(o(k),{}):{error:k.error??`Removing failed (${p.status})`,dirty:k.dirty??!1}},[o]);return{view:e,save:a,remove:c}}function uv(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(k=>({error:k.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 U$(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(uv,{onRemove:s=>e.onRemove(t.mapId,t.ticketId,s)})},`${t.mapId}/${t.ticketId}`))}):null}function W$(e){const{view:t,remove:s}=cv(),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(uv,{label:"Remove workspace",onRemove:a=>s(e.mapId,e.ticketId,a)})]})}function H$(){const{view:e,save:t,remove:s}=cv(),[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(Me,{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},Wm(e.workspaces.filter(h=>h.active).length,"active"),Wm(e.workspaces.filter(h=>!h.active).length,"finished")]}),i.jsx(U$,{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 Wm=(e,t)=>`${e} ${t}`;function K$({data:e,route:t}){return i.jsxs(i.Fragment,{children:[i.jsx(qe,{id:"approvals",storage:"machine",children:i.jsx(KC,{})}),i.jsx(qe,{id:"tracker",children:i.jsx(Me,{title:"Tracker",children:i.jsx(fC,{activeTracker:e.activeTracker,location:e.location,update:e.update})})}),i.jsx(qe,{id:"workspaces",storage:"repo",children:i.jsx(H$,{})}),i.jsx(qe,{id:"remote-agents",storage:"machine",children:i.jsx(L$,{})}),i.jsx(qe,{id:"policy",storage:"repo",children:i.jsx(B$,{})}),i.jsx(qe,{id:"guides",storage:"repo",children:i.jsx(p$,{focus:t.section==="guides"})}),i.jsx(qe,{id:"labels",children:i.jsx(Me,{title:"Labels",children:i.jsxs("div",{className:"label-codes",children:[i.jsx("code",{children:lu}),i.jsxs("code",{children:[te.labelPrefix,":<type>"]}),i.jsx("code",{children:cu}),i.jsx("code",{children:uu})]})})})]})}const iu=`${te.apiPrefix}/projects`;async function Ao(e,t,s){const o=await fetch(`${iu}${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:iu,add:e=>Ao("","POST",{path:e}),remove:e=>Ao(`/${e}`,"DELETE"),setAutoRegister:e=>Ao("/settings","PUT",{autoRegister:e}),answer:(e,t)=>Ao(`/${e}/answer`,"POST",t),async briefing(e){const t=await fetch(`${iu}/briefing?since=${e}`);return t.ok?await t.json():void 0}};function dv(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 V$(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(Tt,{title:"While you were away",count:t.length,info:`What changed in each project since ${un(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 G$(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 q$(e){const{item:t}=e,s=Mg(t),o=t.kind==="question"&&t.agent?`${t.agent} asks`:Ag[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:Ig(t,t.interrupting),title:t.title.split(`
152
+ `)[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(`
153
+ `),trailing:un(e.now-t.since),onOpen:e.onOpen,below:e.onAnswer&&i.jsx(G$,{onAnswer:e.onAnswer})})}function Q$(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(Tt,{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(xn,{title:"Nothing needs you",hint:"Agents in every project can keep going."}),i.jsx("ul",{className:"pj-list",children:t.map(o=>i.jsx(q$,{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 Ic=(e,t,s=`${t}s`)=>`${e} ${e===1?t:s}`;function Y$(e){return e.interrupting>0?"urgent":e.phases.blocked+e.phases.rework+e.flags+e.stalled>0||e.state.kind==="missing"?"attention":"neutral"}function J$(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(Ic(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(Ic(e.flags,"PR flag")),e.stalled&&t.push(Ic(e.stalled,"stalled claim")),t.length||t.push(e.trails?"Nothing waiting":"No trails yet");const d=X$(e.tracker);return d&&t.push(d),t}function X$(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 Z$(e){var t;return e.state.kind==="elsewhere"?e.state.url?`Served by another Lookout · ${e.state.url}`:"Served by another Teamtrail on this machine":((t=e.top)==null?void 0:t.title)??e.note??e.path}function Go(e,t,s){if(e.state.kind!=="missing"){if(e.state.kind==="elsewhere"){const o=e.state.url?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=CS({id:e.id,home:t,tracker:e.tracker.kind,item:s})}}function hv(e){const{p:t}=e,s=Z$(t);return i.jsx(Ce,{as:"li",className:`project-card st-${t.state.kind}`,edge:Y$(t),selected:e.current,title:t.name,titleText:t.path,context:i.jsx(V,{parts:J$(t)}),detail:s,detailText:s,trailing:t.lastActivity?un(e.now-t.lastActivity):void 0,onOpen:e.onOpen})}const fv=`${Jo}:projects:seen`,Hm=24*36e5;function e2(e){try{const t=Number(localStorage.getItem(fv));return t>0?t:e-Hm}catch{return e-Hm}}function t2(e){try{localStorage.setItem(fv,String(e))}catch{}}function n2(){const[e,t]=y.useState();return y.useEffect(()=>{const s=Date.now();return Ys.briefing(e2(s)).then(t).catch(()=>{}),()=>t2(s)},[]),e}function s2(e){const{view:t,reload:s}=e.projects,o=Qt(15e3),a=n2();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=ar()??t.home,d=m=>{const p=t.projects.find(k=>k.id===m);(p==null?void 0:p.id)===c?e.onClose():p&&Go(p,t.home)},h=(m,p)=>{const k=t.projects.find(v=>v.id===m);if(k){if(k.id!==c)return Go(k,t.home,p);e.onClose(),e.onItemHere(p)}};return i.jsxs(De,{className:`zone decisions-view projects-view dv-${e.bp}`,children:[i.jsxs("header",{className:"dv-head",children:[i.jsx(Ue,{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(Q$,{view:t,now:o,onOpen:h,onAnswered:s}),i.jsxs("section",{className:"pj-section pj-projects",children:[i.jsx(Tt,{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(hv,{p:m,current:m.id===c,now:o,onOpen:m.state.kind==="missing"?void 0:()=>d(m.id)},m.id))}),i.jsx(dv,{onAdded:s})]}),i.jsx(V$,{briefing:a,now:o,onOpen:d})]})]})}function i2(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=ar()??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(Ue,{variant:"plain",className:"menu-h",children:"Projects"}),a.projects.map(h=>i.jsxs("button",{role:"menuitem",className:`trail-item ${h.id===c?"on":""} st-${h.state.kind}`,disabled:h.state.kind==="missing",onClick:()=>{s(!1),h.id!==c&&Go(h,a.home)},children:[i.jsx("span",{className:"mi-title",children:h.name}),i.jsx("span",{className:"mi-progress",children:r2(h.state.kind)}),i.jsx(us,{n:h.needsYou,urgent:h.interrupting>0,hideZero:!0})]},h.id))]})]})}function r2(e){return e==="missing"?"missing":e==="elsewhere"?"other Lookout":""}function o2(e){const t=Qt(15e3),{view:s}=e.projects;if(!s||!e.projects.many)return null;const o=ar()??s.home;return i.jsxs("section",{className:"phone-projects",children:[i.jsx(Tt,{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(hv,{p:a,current:!1,now:t,onOpen:a.state.kind==="missing"?void 0:()=>Go(a,s.home)},a.id))})]})}async function a2(){const e=await fetch(Ys.url);return e.ok?await e.json():void 0}function mv(){const[e,t]=y.useState(),{reload:s,pushed:o}=mt({load:a2,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 l2=e=>[e.home&&{text:"This Lookout",strong:!0},e.state.kind==="missing"&&"Missing",{text:e.path,code:!0}];function c2(){const{view:e,reload:t}=mv(),[s,o]=y.useState();if(!e)return null;const a=c=>{o(void 0),c.then(t,d=>o(d.message))};return i.jsxs(Me,{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:l2(c)}),actions:!c.home&&i.jsx(P,{size:"sm",variant:"ghost",onClick:()=>a(Ys.remove(c.id)),children:"Remove"})},c.id))}),i.jsx(dv,{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 u2=`${te.apiPrefix}/models`;async function d2(){const e=await fetch(u2);return e.ok?await e.json():null}function _u(){const[e,t]=y.useState();return mt({load:d2,show:t,failed:()=>t(null),changed:s=>s.endsWith("models.json")||s.endsWith("map.md")||s.includes("/tickets/"),events:{attention:()=>!0}}),e}function h2({mapId:e,ticketId:t}){const s=_u(),o=s==null?void 0:s.waiting.find(a=>a.mapId===e&&a.ticketId===t);return o?i.jsx(Ce,{className:"model-wait d-section",edge:"attention",title:`Needs a ${o.tier} model`,context:i.jsx(V,{parts:[`Connected agents run ${o.best} at most`]}),detail:`Connect an agent on a ${o.tier} model, or have one claim ${o.ticketKey} by key.`}):null}function f2({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 pv={fast:"Fast",balanced:"Balanced",strongest:"Strongest"},m2={fast:"Haiku, mini and nano models",balanced:"Sonnet, GPT-4 models",strongest:"Opus, GPT-5 and o-series models"},p2=Oo.map(e=>({value:e,label:pv[e],hint:m2[e]}));function g2(e){return i.jsx("div",{className:"tier-grid",children:Zo.map(t=>{const s=e.tiers[t],o=hu[t];return i.jsxs("div",{className:"tier-row",children:[i.jsx("span",{children:tr[t]}),i.jsx(ut,{compact:!0,"aria-label":`${tr[t]} tickets' model`,className:`tier-select tier-${t}`,value:s,options:p2,onChange:a=>e.onChange(t,a)}),i.jsx(V,{className:"tier-hint",parts:[s!==o&&`default ${pv[o].toLowerCase()}`,e.hints[t]]})]},t)})})}const Io=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function v2({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:an(t.medianLeadMs)}),context:i.jsx(V,{parts:[`${t.done} of ${Io(t.tickets,"ticket")} done`,t.cancelled>0&&`${t.cancelled} cancelled`,Io(t.reworkCycles,"rework"),`reviews ${t.reviews.passed} passed, ${t.reviews.failed} failed`,t.answers>0&&Io(t.answers,"question")]}),detail:t.findings.raised>0?`As reviewer: ${t.findings.upheld} of ${Io(t.findings.raised,"finding")} upheld`:void 0},t.key))}):i.jsx(Ie,{children:"No claimed tickets yet"})}function gv(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 k2=[{id:"byVendor",title:"By vendor"},{id:"byAgent",title:"By agent"},{id:"byType",title:"By ticket type"}];function y2({api:e,bp:t,onClose:s}){const[o,a]=y.useState("byVendor"),c=y.useMemo(()=>Object.values(e.allSnaps),[e.allSnaps]),d=gv(c),h=e.activity.answered,m=y.useMemo(()=>Gp(c.map(p=>({snap:p,journal:d[p.map.id]??[],answered:h}))),[c,d,h]);return y.useEffect(()=>{const p=k=>k.key==="Escape"&&s();return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[s]),i.jsxs(De,{className:`zone decisions-view perf-view dv-${t}`,children:[i.jsxs("header",{className:"dv-head",children:[i.jsx(Ue,{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(Ue,{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(Ie,{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:k2.map(p=>i.jsx(ft,{on:o===p.id,title:p.title,onClick:()=>a(p.id)},p.id))}),i.jsx(v2,{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 w2(e,t){const s=gv(e);return y.useMemo(()=>{var c;const o=Gp(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 ${an(d.medianLeadMs)}`,d.reworkCycles>0&&`${d.reworkCycles} back to rework`,h];a[d.key]=m.filter(Boolean).join(" · ")}return a},[e,s,t])}function x2(e){var d,h;const t=_u(),s=w2(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(Me,{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(g2,{tiers:Jy(o),hints:s,onChange:(m,p)=>{const k={...c,[m]:p};p===hu[m]&&delete k[m],e.onChange({enabled:!0,tiers:k})}}),a&&i.jsx("span",{className:"set-hint t-meta",children:"Changes apply to the next claim; nothing running is interrupted."}),i.jsx(f2,{view:t})]})}function Ji(e,t){const s=new URL(e);return s.searchParams.delete("settings"),t&&s.searchParams.set("settings",t.section??t.group??""),s.toString()}async function j2(){const e=await fetch(`${je()}/verification/config`);return e.ok?await e.json():null}function S2(){const[e,t]=y.useState();return mt({load:j2,show:t,failed:()=>t(null),changed:s=>s.endsWith("verification.json"),events:{attention:()=>!0}}),e}const Km=`{
154
+ "v": 1,
155
+ "checks": {
156
+ "test": { "run": ["npm", "test"] },
157
+ "lint": { "run": ["npm", "run", "lint"] }
158
+ },
159
+ "run": ["test", "lint"]
160
+ }
161
+ `;function N2({file:e}){const[t,s]=y.useState(!1),o=()=>void navigator.clipboard.writeText(Km).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:Km}),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 b2(e){var p;const t=S2(),[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??Ip).appliesTo.join(" and ");return i.jsxs(Me,{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:du.map(k=>i.jsx(ft,{on:h===k,title:sr[k],sub:Pg[k],onClick:()=>{o(void 0),cr.act({action:"level",mapId:a.id,level:k,by:jt}).catch(v=>o(v.message))}},k))}),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(k=>i.jsx("li",{children:k},k))})]}),((p=t.approval)==null?void 0:p.waiting)&&i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:["Its commands don't run on this machine until you approve them."," ",i.jsx("a",{href:Ji(location.href,{group:"project",section:"approvals"}),children:"Review the commands"})]})]}),!t.exists&&i.jsx(N2,{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 ${sr[c.default]}`,`${c.maxAttempts} attempts before it waits for you`,c.failFast&&"Stops at the first failure"]}),i.jsx("div",{className:"vf-checks",children:Object.entries(c.checks).map(([k,v])=>i.jsxs("div",{className:"vf-check",children:[i.jsx("span",{className:"t-code",children:c.run.includes(k)?k:`${k} (on request)`}),i.jsx("code",{children:v.run.join(" ")}),i.jsxs("span",{className:"dim",children:[v.timeoutSec," s",v.cwd&&v.cwd!=="."?` · in ${v.cwd}`:""]})]},k))})]}),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 C2({data:e}){const{map:t}=e;return i.jsxs(i.Fragment,{children:[t?i.jsx(qe,{id:"mode",children:i.jsx(Me,{title:`Trail ${t.key}`,children:i.jsx(xb,{value:t.mode,onChange:e.onMapMode})})}):i.jsx(Ie,{children:"Chart or pick a trail to set its mode, model matching and team."}),i.jsx(qe,{id:"verification",storage:"repo",children:i.jsx(b2,{map:t})}),i.jsx(qe,{id:"models",children:i.jsx(x2,{map:t,snaps:e.snaps,answered:e.answered,onChange:e.onModelMatching})}),t&&i.jsx(qe,{id:"team",children:i.jsx(g$,{map:t})})]})}const Vm=10,vv=[0,10,16,26,18,24,16,18,22,22,26],kv=[0,1,1,1,2,2,4,4,4,5,5];function yv(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 $2=e=>vv[e],T2=e=>kv[e],wv=e=>Math.floor(yv(e)/8)-vv[e]*kv[e],xv=e=>e<10?8:16;function E2(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 ru(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 A2(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]=ru(t[a],s),a+1<t.length&&(t[a]^=t[a+1]);s=ru(s,2)}return t}function I2(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]^=ru(c,a))}return s}function M2(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,xv(t));for(const d of e)o(d,8);const a=wv(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 R2(e,t){const s=M2(e,t),o=T2(t),a=$2(t),c=Math.floor(yv(t)/8),d=o-c%o,h=Math.floor(c/o),m=A2(a),p=[];for(let v=0,x=0;v<o;v++){const j=s.slice(x,x+h-a+(v<d?0:1));x+=j.length;const b=I2(j,m);v<d&&j.push(0),p.push([...j,...b])}const k=[];for(let v=0;v<p[0].length;v++)for(let x=0;x<p.length;x++)(v!==h-a||x>=d)&&k.push(p[x][v]);return k}const L2=[(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 Mc(e,t){const s=L2[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 Gm(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 O2(e){let t=0,s=0;for(let a=0;a<e.size;a++)t+=Gm(e.dark[a]),t+=Gm(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 sn=(e,t)=>(e>>>t&1)!==0;function St(e,t,s,o){e.dark[s][t]=o,e.fixed[s][t]=!0}function Rc(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&&St(e,c,d,h!==2&&h!==4)}}function P2(e,t,s){for(let o=-2;o<=2;o++)for(let a=-2;a<=2;a++)St(e,t+a,s+o,Math.max(Math.abs(a),Math.abs(o))!==1)}function ou(e,t){const s=0|t;let o=s;for(let c=0;c<10;c++)o=o<<1^(o>>>9)*1335;const a=(s<<10|o)^21522;for(let c=0;c<=5;c++)St(e,8,c,sn(a,c));St(e,8,7,sn(a,6)),St(e,8,8,sn(a,7)),St(e,7,8,sn(a,8));for(let c=9;c<15;c++)St(e,14-c,8,sn(a,c));for(let c=0;c<8;c++)St(e,e.size-1-c,8,sn(a,c));for(let c=8;c<15;c++)St(e,8,e.size-15+c,sn(a,c));St(e,8,e.size-8,!0)}function _2(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);St(e,c,d,sn(o,a)),St(e,d,c,sn(o,a))}}function D2(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++)St(o,6,d,d%2===0),St(o,d,6,d%2===0);Rc(o,3,3),Rc(o,t-4,3),Rc(o,3,t-4);const a=E2(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||P2(o,a[d],a[h]);return ou(o,0),_2(o,e),o}function z2(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 B2(e,t){let s=0;for(const[o,a]of z2(e.size))e.fixed[a][o]||s>=t.length*8||(e.dark[a][o]=sn(t[s>>>3],7-(s&7)),s++)}function F2(e){const t=new TextEncoder().encode(e);let s=1;for(;s<=Vm&&4+xv(s)+t.length*8>wv(s)*8;)s++;if(s>Vm)return;const o=D2(s);B2(o,R2(t,s));let a=0,c=1/0;for(let d=0;d<8;d++){Mc(o,d),ou(o,d);const h=O2(o);h<c&&([a,c]=[d,h]),Mc(o,d)}return Mc(o,a),ou(o,a),o.dark}const Lc=4;function U2(e){const t=F2(e.text);if(!t)return null;const s=t.length+Lc*2,o=t.flatMap((a,c)=>a.map((d,h)=>d?`M${h+Lc} ${c+Lc}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 W2(e){const t=Qt(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(U2,{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 H2(e){const[t,s]=y.useState();return e.device?i.jsx(W2,{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 K2(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 V2={machine:"This machine",device:"Another device"};function G2(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:[V2[s.kind],s.via==="opened-page"?`From the page ${te.name} opened`:void 0,s.via==="opened-page"?{text:n0(s.id),code:!0}:void 0,`Paired ${Wo(s.pairedAt,t)}`,`Last used ${Wo(s.lastUsedAt,t)}`]}),below:s.current?void 0:i.jsx(K2,{name:s.name,onRevoke:()=>e.onRevoke(s.id)})},s.id))})}function q2(){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 jv=`${te.apiPrefix}/sign-in`;async function Oc(e,t={}){const s=await fetch(`${jv}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return{ok:s.ok,reply:await s.json().catch(()=>({}))}}function Q2(){const[e,t]=y.useState(),[s,o]=y.useState(),a=y.useCallback(()=>{fetch(`${jv}/sessions`).then(async m=>m.ok?await m.json():(await m.json().catch(()=>({}))).elsewhere?"elsewhere":null).then(t,()=>t(null))},[]);y.useEffect(a,[a]);const c=y.useCallback(async()=>{const{ok:m,reply:p}=await Oc("/codes");if(!m)return p.error??"No code could be made.";o(p)},[]),d=y.useCallback(async m=>{const{ok:p,reply:k}=await Oc("/revoke",{id:m});return a(),p?void 0:k.error??"That browser could not be revoked."},[a]),h=y.useCallback(async()=>{await Oc("/sign-out"),pg(),location.reload()},[]);return{view:e,device:s,closeDevice:()=>(o(void 0),a()),pairDevice:c,revoke:d,signOut:h}}function Y2(){const{view:e,device:t,closeDevice:s,pairDevice:o,revoke:a,signOut:c}=Q2();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(Me,{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(Me,{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(G2,{sessions:e.sessions,onRevoke:a}),i.jsx(H2,{lan:e.lan,device:t,onPair:o,onDone:s}),d,i.jsx(q2,{})]})}function J2(){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(De,{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 Du(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&&PS({id:s.id,secret:s.session,verifier:s.verifier})}function X2(e){const[t,s]=y.useState(!1),o=async()=>{s(!0);const a=await Du(e.code);if(!a)return location.reload();s(!1),e.onFailed(a)};return i.jsxs("div",{className:"pair-confirm",children:[i.jsxs("p",{className:"t-body pair-step",children:["This link signs this browser in to the Lookout. Use it only if it came to you from"," ",i.jsx("code",{className:"t-code",children: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 qm(){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 Du(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 Qm(){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 Z2(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(Qm,{}):i.jsx(qm,{}),e.local?i.jsx(qm,{}):i.jsx(Qm,{})]})}function eT(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(De,{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(X2,{code:o,onFailed:h}):i.jsx(Z2,{local:e.local})]})})}function Ym(){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 Jm(){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 tT(){if(!ju())return Jm();const e=await ua();return e==="proven"?{kind:"signed-in"}:e==="unknown"?Jm():{kind:"not-running"}}function nT(){const[e,t]=y.useState({kind:"checking"});return y.useEffect(()=>void tT().then(t),[]),y.useEffect(()=>_S(s=>s==="failed"&&t({kind:"not-running"})),[]),e}function sT({children:e}){const t=nT(),[s,o]=y.useState(Ym);return y.useEffect(()=>{const a=()=>o(c=>Ym()??c);return window.addEventListener("hashchange",a),()=>window.removeEventListener("hashchange",a)},[]),y.useEffect(()=>{t.kind==="signed-in"&&s&&Du(s)},[t.kind,s]),t.kind==="checking"?null:t.kind==="signed-out"?i.jsx(eT,{local:t.local,code:s}):t.kind==="not-running"?i.jsx(J2,{}):i.jsx(i.Fragment,{children:e})}const iT=[{value:"auto",title:"Match my system"},{value:"day",title:"Day"},{value:"night",title:"Night"}];function rT(e){return i.jsx("div",{className:"choice-row compact",children:iT.map(t=>i.jsx(ft,{on:e.value===t.value,title:t.title,onClick:()=>e.onChange(t.value)},t.value))})}function oT({data:e}){const{prefs:t,update:s}=e;return i.jsxs(i.Fragment,{children:[i.jsx(qe,{id:"appearance",storage:"browser",children:i.jsx(Me,{title:"Appearance",children:i.jsx(rT,{value:t.theme,onChange:o=>s({theme:o})})})}),i.jsx(qe,{id:"transcript",storage:"browser",children:i.jsx(Me,{title:"HITL transcript",children:i.jsx(Kg,{value:t.hitlTranscript,onChange:o=>s({hitlTranscript:o})})})}),i.jsx(qe,{id:"agent",children:i.jsx(Me,{title:"Agent",children:i.jsx("div",{className:"choice-row",children:ig.map(o=>i.jsx(ft,{on:o.status==="primary",disabled:o.status!=="primary",title:o.name},o.id))})})}),i.jsx(qe,{id:"devices",storage:"machine",children:i.jsx(Y2,{})})]})}function aT(e){const{data:t,route:s}=e;switch(e.group){case"trail":return i.jsx(C2,{data:t});case"project":return i.jsx(K$,{data:t,route:s});case"alerts":return i.jsx(CC,{data:t,route:s});case"you":return i.jsx(oT,{data:t});case"projects":return i.jsx(qe,{id:"projects",storage:"machine",children:i.jsx(c2,{})});case"about":return i.jsx(qe,{id:"changelog",children:i.jsx(IC,{})});default:return e.group}}function lT(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(aT,{group:t.id,data:e.data,route:s})]})})}function cT(e){return i.jsx("nav",{className:"sp-nav","aria-label":"Settings groups",children:i.jsx("ul",{children:ir.map(t=>{const s=t.id===e.current;return i.jsx(Ce,{as:"li",className:"sp-nav-row",selected:s,current:s?"page":void 0,title:t.label,context:i.jsx(V,{parts:t.sections.map(o=>o.title)}),trailing:e.drill&&"›",onOpen:()=>e.onPick(t.id)},t.id)})})})}function uT(e,t){return e.group?ir.find(s=>s.id===e.group):t==="mobile"?void 0:ir[0]}const dT={page:"Back to the Lookout",list:"Lookout",group:"Settings"},hT=(e,t)=>e?t?"group":"list":"page";function fT(e){const{bp:t,route:s}=e,o=t==="mobile",a=uT(s,t),c=hT(o,!!a),d=Gg()===!1,h=()=>c==="group"?e.onShow({}):e.onClose();y.useEffect(()=>{const k=v=>{v.key!=="Escape"||v.defaultPrevented||document.querySelector(".scrim")||(c==="group"?e.onShow({}):e.onClose())};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[c,e]);const m=k=>e.onShow({group:k}),p=c!=="group"&&i.jsx(cT,{current:a==null?void 0:a.id,onPick:m,drill:o});return i.jsxs(De,{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:["‹ ",dT[c]]}),c!=="group"&&i.jsx(Ue,{as:"h2",children:"Settings"}),!o&&i.jsx("span",{className:"dv-head-right t-meta",children:"Esc"})]}),d&&i.jsx(vC,{}),i.jsxs("div",{className:"sp-body",children:[p,a&&i.jsx(lT,{group:a,data:e.data,route:s})]})]})}function mT(e){var a;const{rt:t,api:s,settings:o}=e;return o.route?i.jsx(fT,{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 pT(e){return i.jsxs(De,{className:"zone side",style:{gridArea:"inspector"},children:[i.jsx(w1,{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 Sv(e){return e.filter(t=>t.state!=="out-of-scope").map(t=>({x:t.x,y:t.y,w:Ke,h:Qe}))}function gT(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 vT=6;function kT(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(vT,Xm(c,d)/2,Xm(d,h)/2),p=Zm(d,c,m),k=Zm(d,h,m);s+=`L${p.x} ${p.y}Q${d.x} ${d.y} ${k.x} ${k.y}`}const o=t[t.length-1];return`${s}L${o.x} ${o.y}`}function Xm(e,t){return Math.abs(e.x-t.x)+Math.abs(e.y-t.y)}function Zm(e,t,s){return{x:e.x+Math.sign(t.x-e.x)*s,y:e.y+Math.sign(t.y-e.y)*s}}function qo(e){const t=e.direction==="TB",s=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 kT(yT({a:o,b:a,obstacles:c,gap:e.gap}).map(s))}function yT({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(k=>p>k.y-8&&p<k.y+k.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=gT({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 wT(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 xT(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=Sv(e.nodes);return o.map(c=>{if(e.direction==="LR"){const m={x:c.x+Ke,y:c.y+Qe/2},p={x:t.x-30,y:t.y};return qo({direction:"LR",a:m,b:p,obstacles:a,gap:96})}const d={x:c.x+Ke/2,y:c.y+Qe},h={x:t.x,y:t.y-30};return qo({direction:"TB",a:d,b:h,obstacles:a,gap:48})})}function jT({x:e,y:t,text:s}){const o=s!=null&&s.trim()?`Destination
162
+ ${s.trim()}`:`Destination
163
+ 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 ST({trails:e}){return e.map(t=>i.jsx("path",{className:"edge edge-open edge-destination",d:t},t))}function NT(){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 bT(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 CT(e,t){const s=kx({...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 ep={LR:130,TB:68};function $T(e){const{direction:t,from:s,to:o,cards:a}=e;if(t==="LR"){const h={x:s.x+Ke,y:s.y+Qe/2},m={x:o.x,y:o.y+Qe/2};return qo({direction:t,a:h,b:m,obstacles:a,gap:ep.LR})}const c={x:s.x+Ke/2,y:s.y+Qe},d={x:o.x+Ke/2,y:o.y};return qo({direction:t,a:c,b:d,obstacles:a,gap:ep.TB})}function TT(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:$T({direction:o,from:t,to:s,cards:e.cards})})}function ET(e){const{snap:t,tickets:s,direction:o,preview:a}=e,c=y.useMemo(()=>CT(t,s),[t,s]),d=y.useMemo(()=>Sv(e.nodes),[e.nodes]);return e.edges.map(({from:h,to:m})=>{const p=Qo(h.ticket.id,m.ticket.id);return i.jsx(TT,{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 zu=24,AT=13,IT=9.5;function MT(e){const t=e.guide;return i.jsx("g",{className:"meta",transform:`translate(${zu} ${e.y})`,children:e.chips.map((s,o)=>{const a=s.kind==="guide"?t:void 0;return i.jsxs("g",{className:Ve("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:AT,rx:3}),i.jsx("text",{x:(s.w-s.textW)/2,y:IT,textLength:s.textW,lengthAdjust:"spacingAndGlyphs",children:s.text})]},o)})})}const Nv=5,RT={sans:"9.5px 'Figtree Variable', system-ui, sans-serif",mono:"8.55px 'JetBrains Mono Variable', ui-monospace, monospace"};let Qi;function LT(){if(Qi!==void 0)return Qi;try{Qi=typeof document>"u"?null:document.createElement("canvas").getContext("2d")}catch{Qi=null}return Qi}function OT(e,t="sans"){const s=LT();return s?(s.font=RT[t],s.measureText(e).width*1.04):e.length*Nv}const tp=4,np=3,PT=6;function _T(e){var v;const t=Ke-zu-8-(e.reserve??0),s=((v=e.state)==null?void 0:v.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*tp-(o.length-1)*np,c=x=>OT(x.text,x.kind==="key"?"mono":"sans"),d=o.filter(x=>x.kind!=="guide").reduce((x,j)=>x+c(j),0),h=Math.max(PT,Math.floor((a-d)/Nv)),m=o.map(x=>x.kind==="guide"?{...x,text:ZC(x.text,h)}:x),p=Math.min(1,a/m.reduce((x,j)=>x+c(j),0));let k=0;return m.map(x=>{const j=c(x)*p,b={...x,x:k,w:j+2*tp,textW:j};return k+=b.w+np,b})}function DT(e,t,s){const o=e.state==="frontier"||e.state==="rework";if(!(!t||s||e.ticket.assignee||!o))return t}function zT(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 BT({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 FT={claimed:"working",verifying:"working",frontier:"ready",blocked:"backlog",parked:"backlog",decided:"done","out-of-scope":"cancelled",rework:"attention",held:"attention"};function UT(e){const t=FT[e.state];return t==="done"||t==="cancelled"?t:e.attention?"attention":e.live?"working":t}function WT({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:Qe/2,x2:Ke-8,y2:Qe/2}),s&&i.jsx("text",{className:"reroute-tag",x:Ke-8,y:Qe-7,textAnchor:"end",children:s}),t&&i.jsx("text",{className:"freeze",x:Ke-(s?58:8),y:Qe-7,textAnchor:"end",children:"❄"})]})}function HT(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:ES[t.state],tone:""}}function KT({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 VT(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 GT=26;function qT({n:e,session:t,stalled:s,flag:o,selected:a,onSelect:c,mark:d,frozen:h,needs:m}){const p=e.ticket,k=VT(p.title,GT),v=rr(p)==="hitl",x=!!(t!=null&&t.waitingOn),j=!!d&&d!=="unchanged",b=DT(e,m,!!t),S=j$(p.guide),I=j?void 0:HT({n:e,session:t,waiting:x,stalled:s,wait:b,step:!S}),C=v&&!j&&(p.type==="task"||p.type==="execute"),O=x||!!s||!!b||C&&e.state==="frontier",R=UT({state:e.state,live:!!t,attention:O}),z=tr[p.type],Z=(j&&d!=="cancelled"?44:0)+(h?12:0),q=_T({key:p.key,type:z,guide:S==null?void 0:S.name,state:I==null?void 0:I.text,needsYou:C,reserve:Z}),H=k.length>1?19:24;return i.jsxs("g",{className:zT({n:e,tone:R,hitl:v,selected:a,live:!!t,waiting:x,stalled:s,mark:d,frozen:h}),style:{transform:`translate(${e.x}px, ${e.y}px)`},onClick:re=>{re.stopPropagation(),c({kind:"ticket",id:p.id})},children:[i.jsx(BT,{wait:b,session:t}),i.jsx("rect",{className:"ring",x:-3.5,y:-3.5,width:Ke+7,height:Qe+7,rx:9}),i.jsx("rect",{className:"card",x:.5,y:.5,width:Ke-1,height:Qe-1,rx:6}),i.jsx(KT,{tone:R,cy:H-4}),k.map((re,Q)=>i.jsx("text",{className:"title",x:zu,y:H+Q*14,children:re},Q)),i.jsx(MT,{chips:q,y:H+k.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(WT,{mark:d,frozen:h})]})}const sp=.72;function QT(e){const{fit:t,nodes:s,size:o,pad:a}=e;if(t.k>=sp)return t;const c=s.find(h=>h.state==="claimed")??s.find(h=>h.state==="frontier")??s[0];if(!c)return t;const d=sp;return{k:d,x:o.w/2-(c.x+a+Ke/2)*d,y:o.h/2-(c.y+a+Qe/2)*d}}function YT(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 nt=280,ip=4,JT=220,Fs=e=>Math.round(e/ip)*ip;function XT(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 Pc(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 ZT(e){const{width:t,height:s,nodes:o}=e,a=XT(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+Qe+28),h=(t+nt*2)*(s+nt*2),m=Array.from({length:Math.round(h/9e4)},()=>Pc(a,c(-nt,t+nt),c(-nt,s+nt),c(160,360))).flat(),p=[...Pc(a,t+nt*.55,s+nt*.55,300),...Pc(a,-nt*.5,-nt*.45,220)],k=[],v=(x,j,b)=>{k.length<JT&&d(j,b)&&k.push({sprite:x,x:Fs(j),y:Fs(b)})};for(let x=0;x<Math.round(h/3e4);x++){const j=c(-nt,t+nt),b=c(-nt,s+nt),S=3+Math.floor(a()*5);for(let I=0;I<S;I++)v(a()<.65?"pine":"oak",j+c(-70,70),b+c(-44,44))}for(let x=0;x<Math.round(h/45e3);x++)v(a()<.4?"rock":"tuft",c(-nt,t+nt),c(-nt,s+nt));return k.sort((x,j)=>x.y-j.y),{grass:m,water:p,items:k}}const bv={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 eE({name:e}){return i.jsx("symbol",{id:`terrain-${e}`,overflow:"visible",children:bv[e]})}const tE=Object.keys(bv),nE=y.memo(function(t){const{seed:s,width:o,height:a,nodes:c}=t,d=y.useMemo(()=>ZT({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:tE.map(h=>i.jsx(eE,{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))]})}),sE=380;function iE(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,k=t?c.find(C=>C.ticket.id===t):void 0;if(!k||!s.w)return;p();const v=Math.min(1.4,Math.max(h.k,1.05)),x={k:v,x:s.w/2-(d+k.x+Ke/2)*v,y:s.h/2-(d+k.y+Qe/2)*v};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return m(x);const j=h,b=performance.now();let S=0;const I=C=>{const O=Math.min(1,(C-b)/sE),R=1-(1-O)**3;m({k:j.k+(x.k-j.k)*R,x:j.x+(x.x-j.x)*R,y:j.y+(x.y-j.y)*R}),O<1&&(S=requestAnimationFrame(I))};return S=requestAnimationFrame(I),()=>cancelAnimationFrame(S)},[t])}function rE(e,t){const s=y.useRef(t);s.current=t,y.useEffect(()=>{const o=e.current;if(!o)return;const a=p=>{const k=o.getBoundingClientRect();return{x:p.clientX-k.left,y:p.clientY-k.top}},c=p=>{p.preventDefault();const k=p.ctrlKey?.01:.0015;s.current(Math.exp(-p.deltaY*k),a(p))};let d=1;const h=p=>{p.preventDefault(),d=1},m=p=>{p.preventDefault();const k=p;s.current(k.scale/d,a(k)),d=k.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 rp(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 nn=32,oE=1.8;function aE(e){var se;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(([X])=>m({w:X.contentRect.width,h:X.contentRect.height}));return J.observe(D),()=>J.disconnect()},[]);const p=y.useMemo(()=>{const D=Wf(c,"LR",t.map.mode),J=Wf(c,"TB",t.map.mode),X=ce=>Math.min(h.w/(ce.width+nn*2),h.h/(ce.height+nn*2+16));return X(D)*oE>=X(J)?D:J},[c,t.map.mode,h.w,h.h]),k=(D,J)=>Math.min(1.25,Math.max(e.minFit??0,Math.min(h.w/D,h.h/J))),v=y.useMemo(()=>{const D=p.width+nn*2,J=p.height+nn*2+16,ce=p.nodes.some(Y=>Y.state==="out-of-scope")&&h.h?Math.max(0,h.h/k(D,J)-J):0;if(!ce)return{...p,slack:ce};const K=new Map(p.nodes.map(Y=>[Y,{...Y,y:Y.y+(Y.state==="out-of-scope"?ce:ce/2)}]));return{...p,slack:ce,nodes:[...K.values()],edges:p.edges.map(Y=>({from:K.get(Y.from),to:K.get(Y.to)})),quarantineY:p.quarantineY+ce,height:p.height+ce}},[p,h.w,h.h,e.minFit]),x=wT(v),j=x.right+nn*2,b=x.bottom+nn*2+16,S=()=>{const D=k(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}),O=y.useRef(!1);y.useEffect(()=>{O.current=!1},[t.map.id]),y.useEffect(()=>{!O.current&&h.w&&C(QT({fit:S(),nodes:v.nodes,size:h,pad:nn}))},[h.w,h.h,j,b,t.map.id]);const R=y.useRef(new Map),z=y.useRef(null),Z=D=>{const J=d.current.getBoundingClientRect();return{x:D.clientX-J.left,y:D.clientY-J.top}},q=()=>{var ce;const D=[...R.current.values()],J=D.length>1?{x:(D[0].x+D[1].x)/2,y:(D[0].y+D[1].y)/2}:D[0],X=D.length>1?Math.hypot(D[0].x-D[1].x,D[0].y-D[1].y):0;z.current={view:I,dist:X,mid:J,moved:((ce=z.current)==null?void 0:ce.moved)??!1}};rE(d,(D,J)=>{O.current=!0,C(X=>rp(X,X.k*D,J))});const H=Qt(5e3),re=wu(e.leases,t.map.id),Q=Tu(),ve=(se=_u())==null?void 0:se.waiting,ze=new Map(e.sessions.filter(D=>ln(D)&&D.ticketId).map(D=>[D.ticketId,D])),$e=(s==null?void 0:s.kind)==="ticket"?s.id:void 0;return iE({selId:$e,nodes:v.nodes,size:h,pad:nn,view:I,setView:C,onFocus:()=>O.current=!0}),i.jsxs("div",{className:"graph-box",ref:d,onPointerDown:D=>{R.current.set(D.pointerId,Z(D)),R.current.size===1&&(z.current=null),q()},onPointerMove:D=>{var ce;if(!R.current.has(D.pointerId)||!z.current)return;R.current.set(D.pointerId,Z(D));const J=z.current,X=[...R.current.values()];if(X.length>1){const K={x:(X[0].x+X[1].x)/2,y:(X[0].y+X[1].y)/2},Y=Math.hypot(X[0].x-X[1].x,X[0].y-X[1].y),F=rp(J.view,J.view.k*Y/(J.dist||Y),J.mid);C({...F,x:F.x+K.x-J.mid.x,y:F.y+K.y-J.mid.y}),J.moved=!0}else{const K=X[0].x-J.mid.x,Y=X[0].y-J.mid.y;if(!J.moved&&Math.hypot(K,Y)<5)return;J.moved||(ce=d.current)==null||ce.setPointerCapture(D.pointerId),J.moved=!0,C({...J.view,x:J.view.x+K,y:J.view.y+Y})}O.current=!0},onPointerUp:D=>{R.current.delete(D.pointerId),R.current.size&&q()},onPointerCancel:D=>R.current.delete(D.pointerId),onClickCapture:D=>{var J;(J=z.current)!=null&&J.moved&&(D.stopPropagation(),z.current=null)},children:[i.jsxs("svg",{className:"graph",width:h.w,height:h.h,onClick:()=>o(null),children:[i.jsx(NT,{}),i.jsx("g",{transform:`translate(${I.x} ${I.y}) scale(${I.k})`,children:i.jsxs("g",{transform:`translate(${nn} ${nn})`,children:[i.jsx(nE,{seed:t.map.id,width:j,height:b,nodes:v.nodes}),i.jsx(YT,{y:v.quarantineY,width:v.width,height:v.quarantineH,nodes:v.nodes}),i.jsx(ET,{snap:t,tickets:c,direction:v.direction,nodes:v.nodes,edges:v.edges,preview:a}),i.jsx(ST,{trails:xT(v,x)}),v.nodes.length>0&&i.jsx(jT,{x:x.x,y:x.y,text:t.map.sections.destination}),v.nodes.map(D=>{var J;return i.jsx(qT,{n:D,session:ze.get(D.ticket.id),stalled:!!re.get(D.ticket.id)&&oa(re.get(D.ticket.id),H)!=="live",flag:qS(Qs.ticket(Q,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(X=>X.mapId===t.map.id&&X.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(),O.current=!0,C(S())},children:"Fit"})]})}const _c=[["decided","Done"],["claimed","Working"],["frontier","Ready"],["blocked","Backlog"],["parked","Parked"],["out-of-scope","Cancelled"]],op=[["verifying","Verifying"],["rework","Rework"],["held","Blocked"]];function lE({snap:e,sessions:t}){const s=Rp(e),o=p=>s[p],a=t.filter(jg).length,c=yx(e),d=Math.max(1,...c.map(p=>p.open+p.closed)),m=(e.map.verification??"off")!=="off"||op.some(([p])=>o(p))?[..._c.slice(0,2),...op,..._c.slice(2)]:_c;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(Ue,{as:"h3",children:"Status"}),i.jsxs("span",{className:"t-meta",children:[s.total," tickets"]})]}),i.jsxs("ul",{children:[m.map(([p,k])=>i.jsxs("li",{className:`st-${p} ${o(p)?"":"zero"}`,children:[i.jsx("i",{}),i.jsx("span",{children:k}),i.jsx("b",{children:o(p)})]},p)),i.jsxs("li",{className:`st-waiting ${a?"":"zero"}`,children:[i.jsx("i",{}),i.jsx("span",{children:"Waiting on you"}),i.jsx("b",{children:a})]})]})]}),i.jsxs("div",{className:"sp-block sp-col",children:[i.jsx("span",{className:"t-label",children:"Type mix"}),i.jsx("ul",{className:"mix",children:c.map(p=>i.jsxs("li",{title:`${p.type}: ${p.closed} closed, ${p.open} open`,children:[i.jsx("span",{className:"t-meta",children:tr[p.type]}),i.jsxs("span",{className:"mix-bar",children:[i.jsx("i",{className:"closed",style:{width:`${p.closed/d*100}%`}}),i.jsx("i",{className:"open",style:{width:`${p.open/d*100}%`}})]}),i.jsx("b",{children:p.open+p.closed})]},p.type))})]})]})}function cE(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(lE,{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 dE(e){var o,a;const{snap:t,selection:s}=e.api;return i.jsxs(De,{as:"main",className:"zone map-zone",style:{gridArea:"map"},children:[t&&i.jsx(wb,{}),(o=e.trail)==null?void 0:o.banner,i.jsxs("div",{className:"map-area",children:[t&&!e.compact&&i.jsx(cE,{snap:t,sessions:e.sessions}),t?i.jsx(aE,{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(xn,{title:"No trail yet",hint:"Describe your idea here, or start it in Claude Code or Codex. Scout frames it with you, then your agents get to work."}),i.jsx("div",{className:"actions",children:i.jsx(P,{variant:"primary",onClick:e.onNewTrail,"data-tip":"Describe the idea and create the trail",children:"New trail…"})}),i.jsx(Ho,{command:'/scout new "your idea"'})]}),t&&e.compact&&i.jsx(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 fE(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 mE(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(De,{className:"zone",children:e.ticket}),activity:i.jsx(De,{className:"zone",children:e.activity}),plan:e.plan};return i.jsx("main",{className:"phone-view",children:e.decisions||t[e.tab]})}const ap={settingsPage:!0},lp=()=>Vg(new URLSearchParams(location.search).get("settings")),cp=()=>{var e;return!!((e=history.state)!=null&&e.settingsPage)};function pE(){const[e,t]=y.useState(lp);y.useEffect(()=>{e&&!cp()&&(history.replaceState(null,"",Ji(location.href,null)),history.pushState(ap,"",Ji(location.href,e)));const c=()=>t(lp());return window.addEventListener("popstate",c),()=>window.removeEventListener("popstate",c)},[]);const s=c=>{const d=Ji(location.href,c);e?history.replaceState(history.state,"",d):history.pushState(ap,"",d),t(c)},o=()=>{e&&(t(null),cp()?history.back():history.replaceState(null,"",Ji(location.href,null)))},a=c=>s(Vg(c??"")??{});return{route:e,open:a,show:s,close:o,toggle:()=>e?o():a()}}function gE(e,t){const{activity:s,selection:o,setSelection:a,actions:c}=e,[d,h]=y.useState("ticket"),[m,p]=y.useState("home"),[k,v]=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(H=>H.id===e.chatSession);!o&&(q!=null&&q.ticketId)&&q.mapId===e.mapId&&a({kind:"ticket",id:q.ticketId})},[e.chatSession,e.mapId]);const O=q=>{a(q),q&&(t==="laptop"&&h("ticket"),t==="mobile"&&p("ticket"))},R=(q,H,re)=>{re&&re!==e.mapId&&c.selectMap(re),c.openChat(q);const Q=s.sessions.find(ve=>ve.id===q);H&&(Q==null?void 0:Q.mapId)===(re??e.mapId)&&a({kind:"ticket",id:H}),t==="mobile"&&(p("home"),v(ve=>ve+1))};return{sideTab:d,setSideTab:h,phoneTab:m,setPhoneTab:p,convRequest:k,decisionsView:x,setDecisionsView:j,openDecisions:I,statsOpen:b,setStatsOpen:S,toggleStats:C,select:O,openChat:R,showChat:(q,H,re)=>{R(q,H,re),v(Q=>Q+1)},openTicket:(q,H)=>{q!==e.mapId&&c.selectMap(q),a({kind:"ticket",id:H}),j(null),t==="laptop"&&h("ticket"),t==="mobile"&&p("ticket")}}}function vE(e,t){y.useEffect(()=>{document.title=`${te.name}: ${e?`(${e}) `:""}${t??"No trail"}`},[e,t])}function kE(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 yE(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 wE({text:e}){return e.trim()?i.jsx("div",{className:"brief-prose",children:e.split(`
164
+ `).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(Ie,{children:"Not covered"})}const up=["summary","productContext","existing","conventions","dataModel","api","risks"];function xE(e){const{brief:t}=e,[s,o]=y.useState(!1),[a,c]=y.useState("");y.useEffect(()=>{const p=k=>k.key==="Escape"&&e.onClose();return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[e]);const d=t.sections,h=up.filter(p=>d[p].trim()),m=up.filter(p=>!d[p].trim());return i.jsx("div",{className:"scrim",onClick:e.onClose,children:i.jsxs(De,{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:jE(t)})]}),i.jsxs("div",{className:"brief-body",children:[h.map(p=>i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:Gi[p]}),i.jsx(wE,{text:d[p]}),(p==="conventions"||p==="productContext")&&d[p].trim()&&i.jsx(Eu,{draft:()=>({title:`${Gi[p]}: ${d[p].split(`
165
+ `)[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:Gi.assumptions}),d.assumptions.length?i.jsx("ul",{className:"item-list",children:d.assumptions.map(p=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:p.text}),i.jsx(V,{parts:[{text:p.id,code:!0}]})]},p.id))}):i.jsx(Ie,{children:"None listed"})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:Gi.openQuestions}),d.openQuestions.length?i.jsx("ul",{className:"brief-list",children:d.openQuestions.map(p=>i.jsx("li",{children:p},p))}):i.jsx(Ie,{children:"None"})]}),m.length>0&&i.jsxs("p",{className:"t-meta brief-empty",children:["Nothing noted on ",m.map(p=>Gi[p].toLowerCase()).join(", "),"."]}),t.note&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Your last request"}),i.jsx("p",{children:t.note})]})]}),s&&i.jsx(Xe,{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 jE(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(`${un(Date.now()-e.submittedAt)} ago`),t.join(" · ")}function SE({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(`
166
+ `)[0],detailText:e.sections.summary,onOpen:t})})}const NE={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 bE({brief:e,onReview:t}){if(e.status==="accepted")return null;const[s,o]=NE[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 Cv=`${je()}/briefs`;async function CE(e){if(!e)return{brief:null};const t=await fetch(`${Cv}?mapId=${encodeURIComponent(e)}`);return t.ok?await t.json():{brief:null}}function $E(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}=mt({view:t,version:e==null?void 0:e.tickets.reduce((x,j)=>Math.max(x,j.updatedAt),e.map.updatedAt),load:()=>CE(t),show:x=>{o(x.brief),h(x.hash)},failed:()=>o(null),changed:x=>x.startsWith("briefs/")}),k=(x,j,b)=>fetch(`${Cv}/${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)}),v=(x,j,b)=>k(x,j,b).then(()=>!0,S=>(c(S.message),m(),!1));return{brief:s,error:a,hash:d,accept:x=>v("accept",void 0,x),requestChanges:x=>v("request-changes",x)}}function TE(e){const t=$E(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(`
167
+ `):"",banner:c&&i.jsx(bE,{brief:c,onReview:a}),inboxCard:c&&i.jsx(SE,{brief:c,onReview:a}),dialog:c&&s&&i.jsx(xE,{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 EE(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 AE=e=>e.changes.flatMap(t=>"ticket"in t?[t.ticket]:[]);function IE(e,t){const s=new Set(AE(t));return e.tickets.filter(o=>s.has(o.id)&&o.updatedAt>t.at).map(o=>({key:o.key,title:o.title,what:ME(o)}))}function ME(e){return e.state==="closed"?"closed":e.assignee?`claimed by ${e.assignee}`:"changed"}function RE({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 LE={"already-exists":"The work already exists","wrong-problem":"The trail targets the wrong problem",rescope:"The trail should be rescoped"},$v="Dismissed by the trail lead. Carry on with the current plan.",OE="Declined by the trail lead.";function PE(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 _E(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:DE(e)};case"rewire":return{verb:"Rewire",text:t(e.ticket),detail:zE(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 DE(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 zE(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 BE=new Set(["cancel_ticket","update_destination"]);function FE(e){const{change:t,name:s}=e,o=_E(t,s),a=PE(t,e.by);return i.jsx(Ce,{as:"li",className:`reroute-change op-${t.op}`,edge:BE.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(RE,{parts:a}):void 0})}function UE(e){const{reason:t,destination:s}=e;return i.jsxs("section",{className:"reroute-destination",children:[t&&i.jsx("p",{className:"reroute-destination-why",children:LE[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 WE(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 HE(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 KE(e){var O,R;const{reroute:t,snap:s}=e,[o,a]=y.useState(""),[c,d]=y.useState(!1);y.useEffect(()=>{const z=Z=>Z.key==="Escape"&&e.onClose();return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[e]);const h=HE(s,t.changes),m=new Map(s.tickets.map(z=>[z.id,`${z.key} ${z.title}`])),p=z=>m.get(z)??h(z),k=s.map.sections.assumptions??[],v=t.invalidates.map(z=>k.find(Z=>Z.id===z)??{id:z,text:""}),x=t.status==="pending",j=x?IE(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(De,{as:"div",className:"dialog reroute-dialog",onClick:z=>z.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}`,`${un(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(UE,{reason:t.destinationReason,destination:(O=t.diff)==null?void 0:O.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})]}),v.length>0&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Assumptions it invalidates"}),i.jsx("ul",{className:"item-list",children:v.map(z=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:z.text}),i.jsx(V,{parts:[{text:z.id,code:!0}]})]},z.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((z,Z)=>i.jsx(FE,{change:z,by:t.by,name:p},Z))})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Closed until you decide"}),t.wide&&i.jsxs("p",{className:"t-meta",children:["It touches ",t.wide.touched," of ",t.wide.open," open tickets, so it freezes none: the current plan stands until you decide."]}),(R=t.frozen)!=null&&R.length?i.jsx("ul",{className:"item-list",children:t.frozen.map(z=>i.jsx("li",{className:"item-text",children:p(z)},z))}):i.jsx(Ie,{children:"No tickets closed"})]}),t.note&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Your note"}),i.jsx("p",{children:t.note})]})]}),j.length>0&&i.jsx(WE,{changed:j,seen:c,onSeen:d}),x&&i.jsx(Xe,{label:"Note for the agent (required to reject)",children:i.jsx("textarea",{rows:2,value:o,onChange:z=>a(z.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?OE:$v),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 Tv=`${je()}/reroutes`;async function VE(e){if(!e)return[];const t=await fetch(`${Tv}?map=${encodeURIComponent(e)}`);return t.ok?(await t.json()).reroutes:[]}function GE(e){const t=e==null?void 0:e.map.id,[s,o]=y.useState([]),[a,c]=y.useState(),{reload:d}=mt({view:t,version:e==null?void 0:e.tickets.reduce((m,p)=>Math.max(m,p.updatedAt),e.map.updatedAt),load:()=>VE(t),show:o,failed:()=>o([]),events:{reroute:m=>(m==null?void 0:m.mapId)===t}}),h=async(m,p,k)=>{var b,S;const v=await fetch(`${Tv}/${m}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,id:p,note:k,hash:(b=s.find(I=>I.id===p))==null?void 0:b.hash})}),x=await v.json().catch(()=>({}));if(v.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 ${v.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 qE(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 QE(e,t){const s=GE(e),[o,a]=y.useState(),c=qE(s.reroutes,o),d=s.reroutes.find(v=>v.id===c.id),h=d!=null&&d.diff?d:s.pending,m=()=>{a(void 0),s.clearError()},p=v=>v&&m(),k=s.pending;return{banner:k&&i.jsx(EE,{reroute:k,onReview:()=>a(k.id),onDismiss:()=>void s.reject(k.id,$v)}),preview:e&&(h!=null&&h.diff)?bT(e,h.diff,h.frozen):void 0,openReroute:(v,x)=>{v!==(e==null?void 0:e.map.id)&&(t==null||t(v)),a(x)},dialog:e&&d&&i.jsx(KE,{reroute:d,replaced:c.replaced,snap:e,error:s.error,onApprove:v=>void s.approve(d.id,v||void 0).then(p),onReject:v=>void s.reject(d.id,v).then(p),onClose:m},d.id)}}function YE(e,t){const s=TE(e),o=QE(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 JE(){const e=new URL(location.href);e.searchParams.has(Vs)&&(e.searchParams.delete(Vs),history.replaceState(history.state,"",e))}function XE(e,t){return e.kind!=="question"||t.pending.some(s=>s.id===e.ref)}function ZE(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(k=>k.id===t);if(m&&!XE(m,c)||(s(void 0),JE(),!m))return;Rg(m,{...d,openQuestion:k=>{const v=c.pending.find(x=>x.id===k);v&&h(v.sessionId,v.ticketId)}})},[t,o,a,c,d,h]),{request:y.useCallback(m=>s(m),[])}}function eA(e){const{api:t,nav:s}=e,o=Og(t.allSnaps);ob(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=ZE({loaded:t.loaded,view:d,activity:t.activity,handlers:c,showChat:s.showChat}),m=d&&i.jsx(nb,{view:d,onFocus:p=>void o.savePrefs(jj(d.prefs,p,Date.now())),onSettings:e.openFocusSettings});return{attention:o,handlers:c,header:m,link:h}}async function tA(){const e=await fetch(`${je()}/signed-state`);return e.ok?await e.json():null}function nA(){const[e,t]=y.useState();return mt({load:tA,show:t,failed:()=>t(null),changed:s=>s.endsWith("map.md")||s.includes("/tickets/")||s.includes("/decisions/")}),e}const sA={ticket:"held until you accept or revert it",decision:"what you see is what was signed here, until you accept or revert it"};function iA(e){return e[0]==="added"?"added outside Teamtrail":e.map(t=>t==="words"?"its words":t).join(", ")}function Ev({mapId:e,kind:t,id:s}){const o=nA(),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:[`${iA(c.fields)} · ${sA[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 rA({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 oA(e){const{d:t,snap:s}=e,o=ri(),[a,c]=y.useState(!1),[d,h]=y.useState(""),[m,p]=y.useState("");y.useEffect(()=>{c(!1),h(""),p("")},[t.id,t.mapId]);const k=Zw(e.all.filter(S=>S.mapId===t.mapId),t.id),v=or(t),x=t.ticketId?s==null?void 0:s.tickets.find(S=>S.id===t.ticketId):void 0,j=Date.now(),b=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:[TS(t.decidedAt),`${un(j-t.decidedAt)} ago`]})]}),i.jsx("h3",{className:"t-heading",children:t.question}),i.jsx(Ev,{mapId:t.mapId,kind:"decision",id:t.id}),i.jsx(rA,{d:t}),i.jsxs("div",{className:"resolution",children:[i.jsx(Jc,{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," ",(x==null?void 0:x.title)??""," · open in trail ›"]}):"—"}),i.jsx("dt",{children:"Decided by"}),i.jsx("dd",{children:[Gn(t.decidedBy,o),Ap(t)].filter(Boolean).join(", ")}),t.participants.length>1&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Participants"}),i.jsx("dd",{children:t.participants.map(S=>S.name??S.id).join(", ")})]}),i.jsx("dt",{children:"Source"}),i.jsxs("dd",{children:[qn[t.source.kind].label,b&&i.jsxs(i.Fragment,{children:[" · ",i.jsx("a",{href:b,target:"_blank",rel:"noreferrer",children:t.source.label??"link"})]}),!b&&t.source.label&&` · ${t.source.label}`,t.source.ref&&i.jsxs("span",{className:"ref",children:[" ",t.source.ref]})]})]}),t.alternatives.length>0&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Alternatives"}),i.jsx("ul",{className:"dv-alts",children:t.alternatives.map(S=>i.jsx("li",{children:S},S))})]}),t.rationale&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Rationale"}),i.jsx("p",{children:t.rationale})]}),k.length>1&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Supersession"}),i.jsx("ol",{className:"dv-chain",children:k.map(S=>i.jsx("li",{className:`${S.id===t.id?"cur":""} ${S.supersededBy?"old":"live"}`,children:i.jsxs("button",{onClick:()=>e.onSelect(S.id),children:[i.jsx("i",{}),i.jsx("span",{className:"id",children:S.id}),i.jsx("span",{className:"a",children:S.summary}),i.jsx(V,{parts:[Gn(S.decidedBy,o),qs(S.decidedAt)]})]})},S.id))})]}),i.jsxs("div",{className:"actions",children:[i.jsx(Eu,{draft:()=>({title:t.summary||t.question,body:[t.answer,t.rationale&&`Why: ${t.rationale}`].filter(Boolean).join(`
168
+
169
+ `),kind:"product-decision",sources:[`decision:${t.id}`,...t.ticketKey?[`ticket:${t.ticketKey}`]:[]]})}),v==="active"&&!t.postedBy&&i.jsx(P,{on:a,onClick:()=>c(S=>!S),"data-tip":"Replace this decision with a new answer. Both stay on record",children:"Supersede…"})]}),a&&i.jsxs(cn,{as:"form",tone:"inset",className:"inline-form",onSubmit:S=>{S.preventDefault(),d.trim()&&(e.onSupersede(t,{answer:d.trim(),rationale:m.trim(),alternatives:[t.summary]}),c(!1))},children:[i.jsx(Xe,{label:"New decision",children:i.jsx("textarea",{rows:3,value:d,onChange:S=>h(S.target.value),autoFocus:!0})}),i.jsx(Xe,{label:"Rationale",children:i.jsx("input",{value:m,onChange:S=>p(S.target.value)})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(P,{variant:"ghost",onClick:()=>c(!1),children:"Cancel"}),i.jsx(P,{type:"submit",variant:"primary",disabled:!d.trim(),children:"Supersede"})]})]}),i.jsxs("div",{className:"dv-sec",children:[i.jsxs("h4",{className:"mono-label",children:["Transcript ",i.jsx("span",{className:"n",children:t.transcript.length})]}),t.transcript.length?i.jsx("div",{className:"dv-transcript comms-log",children:t.transcript.map((S,I)=>i.jsxs("div",{className:`msg from-${S.from} voice-${S.from==="human"?"human":"agent"}`,children:[i.jsx(Jc,{parts:[Gn(S.author,o),yu(S.at)]}),i.jsx("div",{className:"msg-text",children:S.text})]},I))}):i.jsx(Ie,{children:"None recorded"})]})]})}function Pt(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 aA(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(ut,{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(ut,{compact:!0,"aria-label":"Source",value:t.source??"",onChange:c=>s({source:c||void 0}),options:[{value:"",label:"All sources"},..._o.map(c=>({value:c,label:qn[c].label}))]}),i.jsx(ut,{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(ut,{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(Pt,{on:!t.mapId,label:"All trails",n:o.length,onClick:()=>s({mapId:void 0})}),e.trails.map(c=>i.jsx(Pt,{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(Pt,{on:!t.source,label:"All",n:o.length,onClick:()=>s({source:void 0})}),_o.map(c=>i.jsx(Pt,{cls:`src-${c}`,on:t.source===c,label:qn[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(Pt,{on:!t.madeBy,label:"Anyone",n:o.length,onClick:()=>s({madeBy:void 0})}),i.jsx(Pt,{on:t.madeBy==="agent",label:"Agents, on their own",n:a(c=>er(c)==="agent"),onClick:()=>s({madeBy:t.madeBy==="agent"?void 0:"agent"})}),i.jsx(Pt,{on:t.madeBy==="human",label:"People",n:a(c=>er(c)==="human"),onClick:()=>s({madeBy:t.madeBy==="human"?void 0:"human"})})]}),i.jsx("h3",{className:"mono-label",children:"Decided by"}),i.jsxs("ul",{children:[i.jsx(Pt,{on:!t.decidedBy,label:"Anyone",n:o.length,onClick:()=>s({decidedBy:void 0})}),e.people.map(c=>i.jsx(Pt,{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(Pt,{on:!t.status,label:"Any",n:o.length,onClick:()=>s({status:void 0})}),i.jsx(Pt,{on:t.status==="active",label:"Active",n:a(c=>!c.supersededBy),onClick:()=>s({status:t.status==="active"?void 0:"active"})}),i.jsx(Pt,{on:t.status==="superseded",label:"Superseded",n:a(c=>!!c.supersededBy),onClick:()=>s({status:t.status==="superseded"?void 0:"superseded"})})]})]})}function lA(e){if(or(e)==="superseded")return`Replaced by ${e.supersededBy}`;if(e.supersedes)return`Replaces ${e.supersedes}`}function cA(e){const{d:t}=e,s=ri(),o=or(t);return i.jsxs(i.Fragment,{children:[e.newDay&&i.jsx("li",{className:"dv-day t-label",children:qs(t.decidedAt)}),i.jsx(Ce,{as:"li",className:`dv-row ${o}`,selected:e.on,onOpen:e.onClick,title:t.question,titleText:t.question,trailing:yu(t.decidedAt),context:i.jsx(V,{parts:[{text:t.id,code:!0},t.ticketKey&&{text:t.ticketKey,code:!0},e.showTrail&&e.trail,Gn(t.decidedBy,s),Ap(t)??qn[t.source.kind].label,lA(t)]}),detail:t.summary,detailText:t.summary})]})}function uA(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(cA,{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(Ie,{children:"No decisions"})})}function dA({stats:e}){return i.jsxs("span",{className:"dv-readouts",children:[i.jsx(rn,{layout:"start",label:"Active",value:e.active}),i.jsx(rn,{layout:"start",label:"Superseded",value:e.superseded}),i.jsx(rn,{layout:"start",label:"Last 24h",value:e.last24h}),i.jsx(rn,{layout:"start",label:"Human",value:`${e.total?Math.round(e.human/e.total*100):0}%`}),i.jsx(V,{className:"dv-src-mix",parts:_o.filter(t=>e.bySource[t]).map(t=>`${qn[t].label} ${e.bySource[t]}`)})]})}function hA(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 fA(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 O=R=>{R.key==="Escape"&&(s==="mobile"&&d?h(void 0):e.onClose())};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[s,d,e]);const k=y.useMemo(()=>Nx(o,a),[o,a]),v=y.useMemo(()=>bx(o),[o]),x=o.find(O=>O.id===d&&(!a.mapId||O.mapId===a.mapId))??(s==="mobile"?void 0:k[0]),j=y.useMemo(()=>Object.values(t.allSnaps).sort((O,R)=>R.map.createdAt-O.map.createdAt),[t.allSnaps]),b=y.useMemo(()=>[...new Set(o.map(O=>O.decidedBy))].sort(),[o]),S=O=>c(R=>({...R,...O})),I=()=>{const O=Object.fromEntries(j.map(R=>[R.map.id,{key:R.map.key,title:R.map.title}]));ug(`${te.slug}-decisions-${qs(Date.now())}.md`,_x(k,O,{title:`${te.name} decisions`}))},C=s==="mobile"&&!!x;return i.jsxs(De,{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(Ue,{as:"h2",children:["Decisions ",k.length!==o.length&&i.jsx("span",{className:"n",children:`${k.length}/${o.length}`})]}),s!=="mobile"&&i.jsx(dA,{stats:v}),i.jsxs("span",{className:"dv-head-right",children:[!C&&i.jsx(P,{onClick:I,disabled:!k.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(hA,{filter:a,set:S,showToggle:s!=="wide",filtersOpen:m,onToggle:()=>p(O=>!O)}),i.jsxs("div",{className:"dv-body",children:[(s==="wide"||m&&!C)&&i.jsx(aA,{filter:a,set:S,all:o,trails:j,people:b,compact:s!=="wide"}),!C&&i.jsx(uA,{rows:k,current:x,snaps:t.allSnaps,showTrail:s==="wide",onSelect:h}),(s!=="mobile"||x)&&i.jsx("div",{className:"dv-detail",children:x?i.jsx(oA,{d:x,all:o,snap:t.allSnaps[x.mapId],onSelect:h,onOpenTicket:e.onOpenTicket,onSupersede:t.actions.supersede}):i.jsx(Ie,{children:"No decision selected"})})]})]})}function mA({api:e,bp:t,nav:s}){return s.statsOpen?i.jsx(y2,{api:e,bp:t,onClose:()=>s.setStatsOpen(!1)}):s.decisionsView?i.jsx(fA,{api:e,bp:t,focus:s.decisionsView.focus,onClose:()=>s.setDecisionsView(null),onOpenTicket:s.openTicket}):null}function pA(e,t,s){const o=mv(),[a,c]=y.useState(()=>new URLSearchParams(location.search).has("projects")),d=a&&o.many&&i.jsx(s2,{projects:o,bp:e,onClose:()=>c(!1),onItemHere:s});return{projects:o,overview:d,openOverview:()=>{t.setDecisionsView(null),t.setStatsOpen(!1),c(!0)}}}const gA={"asks-you":"urgent",answered:"good",launched:"good",done:"good",verified:"good","checks-failed":"attention",stalled:"attention",disconnected:"attention",problem:"attention"};function vA(e){if(e.kind)return gA[e.kind];if(e.signal){if(e.level==="alert")return"urgent";if(e.level==="ok")return"good"}}function Av({activity:e,onTicket:t}){const s=ri(),o=e.feed.slice(-120).reverse();return o.length?i.jsx("div",{className:"log",children:o.map(a=>i.jsxs("div",{className:`log-row src-${a.source.replace(" ","-")} edge-${vA(a)??"none"}`,onClick:()=>a.ticketId&&t(a.ticketId),children:[i.jsx("span",{className:"t t-meta",children:la(a.at)}),i.jsx("span",{className:"src t-meta",children:Gn(a.agent??a.source,s)}),i.jsxs("span",{className:"msg",title:a.tag?`${a.tag} · ${a.text}`:a.text,children:[a.tag&&i.jsxs("span",{className:"tag t-meta",children:[a.tag," · "]}),a.text]})]},a.id))}):i.jsx(xn,{title:"Nothing has happened yet",hint:"Claims, steps, questions and decisions appear here as agents work."})}function dp({lease:e,now:t}){if(!e)return null;const s=oa(e,t);if(s==="live")return null;const o=e.expiresAt-t;return i.jsxs(Qn,{tone:"amber",className:"stalled",title:`No activity from ${e.agent}; the ticket returns to the queue when the lease runs out`,children:["stalled · ",s==="expired"?"returning":qt(o)]})}function kA({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:yA(o+1,t)},o))})}function yA(e,t){return e<t?"done":e===t?"cur":""}function Iv({snap:e,activity:t,leases:s,onSelect:o,onOpenChat:a}){var x;const c=Qt(1e3),d=t.sessions.filter(ln),h=new Set(d.map(j=>j.ticketId)),m=wu(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(Ie,{children:"No agent on a ticket"});const k=j=>!!j&&oa(j,c)!=="live",v=!!((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?rr(b)==="hitl":!1,I=b&&m.get(b.id);return i.jsx(Ce,{as:"li",className:j.waitingOn?"waiting":void 0,edge:wA(j,k(I)),title:SA(b,j.mode)||j.agent,context:i.jsx(V,{parts:[{text:j.agent,strong:!0},v&&xA(j),j.waitingOn?{text:"Waiting on you",urgent:!0}:`${j.mode} · ${j.stepLabel.toLowerCase()}`,S&&!j.waitingOn&&"with you",jA(j)],children:i.jsx(dp,{lease:I,now:c})}),trailing:dg(c-j.startedAt),below:i.jsx(kA,{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:k(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(dp,{lease:m.get(j.id),now:c})}),onOpen:()=>o({kind:"ticket",id:j.id})},j.id))]})}function wA(e,t){return e.waitingOn?"urgent":t?"attention":"neutral"}function xA(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 jA(e){if(e.usage)return`${ca(xx(e))} tok · ${Gs(e.usage.costUsd)}`}function SA(e,t){return e?`${e.key} ${e.title}`:t==="chart"?"Charting trail":""}function Mv({activity:e,snap:t,running:s,usage:o=!0}){const a=Op(e,t==null?void 0:t.map.id),c=_p(e,t==null?void 0:t.map.id),d=new Set(e.sessions.filter(ln).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(Tt,{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=>Pp[m].text)].join(`
170
+ `),children:[i.jsx("span",{className:"mono-label",children:"Trail"})," ",ca(a.inputTokens+a.outputTokens)," tok · ",Gs(a.costUsd)]}):void 0})}function NA(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 bA={running:"Working",done:"Done",failed:"Stopped"};function Rv({activity:e,snap:t}){const s=NA(e);if(!s)return i.jsx(xn,{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=na[s.mode],c=s.waitingOn?"Waiting on you":bA[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 k="";return p?k="done":m===s.step&&(k="cur"),i.jsxs("li",{className:k,children:[i.jsx("i",{}),i.jsxs("span",{children:[String(m).padStart(2,"0")," ",d]})]},d)})})]})}function hp(e){return i.jsxs("div",{className:"zone-b activity-stack",children:[i.jsx(Rv,{activity:e.activity,snap:e.snap}),i.jsx(Mv,{activity:e.activity,snap:e.snap,running:e.activity.sessions.filter(ln).length}),i.jsx(Iv,{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(Tt,{sub:!0,title:"Activity log"}),i.jsx(Av,{activity:e.activity,onTicket:e.onTicket})]})}function CA(e){return i.jsx(bg,{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(Av,{activity:e.activity,onTicket:e.onTicket})})}function $A(e){var o;const t=e.activity.sessions.filter(ln).length,s=!e.activity.sessions.length&&!((o=e.snap)!=null&&o.tickets.some(a=>a.state==="open"&&a.assignee));return i.jsxs(De,{className:"zone step-zone",style:{gridArea:"step"},children:[i.jsx(Tt,{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(Rv,{activity:e.activity,snap:e.snap}),!s&&i.jsxs(i.Fragment,{children:[i.jsx(Mv,{activity:e.activity,snap:e.snap,running:t,usage:!1}),i.jsx(Iv,{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 TA(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 EA(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 AA(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(EA,{proposal:t,canAccept:!s.changed,onAccept:()=>c("accept"),onDismiss:()=>c("dismiss")}),o&&i.jsx("p",{className:"vf-err",children:o})]})}async function Lv(e){return e?e.ok?void 0:(await e.json().catch(()=>({}))).error??`HTTP ${e.status}`:"Could not reach the Lookout"}const Ov=`${je()}/criteria`;async function IA(e){if(!e)return[];const t=await fetch(`${Ov}?mapId=${encodeURIComponent(e)}`);return t.ok?(await t.json()).tickets:[]}function MA(e){const[t,s]=y.useState([]),{reload:o}=mt({view:e,load:()=>IA(e),show:s,failed:()=>s([]),changed:c=>c.startsWith("criteria/")});return{tickets:t,confirm:c=>fetch(`${Ov}/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,...c})}).catch(()=>{}).then(async d=>{const h=await Lv(d);return o(),h})}}const Pv=`${je()}/criteria-proposals`;async function RA(e){if(!e)return[];const t=await fetch(`${Pv}?mapId=${encodeURIComponent(e)}`);return t.ok?(await t.json()).proposals:[]}function LA(e){const[t,s]=y.useState([]),{reload:o}=mt({view:e,load:()=>RA(e),show:s,failed:()=>s([]),events:{"criteria-proposals":c=>(c==null?void 0:c.mapId)===e}});return{proposals:t,decide:(c,d)=>fetch(`${Pv}/${c}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,...d})}).catch(()=>{}).then(async h=>{const m=await Lv(h);return o(),m})}}function OA({snap:e,t}){const{tickets:s,confirm:o}=MA(e.map.id),a=LA(e.map.id),c=a.proposals.find(v=>v.ticketId===t.id),d=ii(),h=s.find(v=>v.ticketId===t.id),m=(h==null?void 0:h.criteria)??[],k=Qp(d.entries,{trailKey:e.map.key,ticket:{type:t.type,title:t.title,body:t.body},paths:Yp(`${t.body}
171
+ ${d.briefText}`)}).filter(v=>v.kind==="business-rule").filter(v=>sj(m,[v.id]).length);return!m.length&&!k.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(v=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:v.text}),i.jsx(V,{parts:[{text:v.id,code:!0},v.kind.replace("-"," "),v.source&&`from ${v.source}`]})]},v.id))}),c&&i.jsx(AA,{proposal:c,decide:(v,x)=>a.decide(v,{title:e.map.title,ticketId:t.id,hash:x})}),k.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:k.map(v=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:v.title}),i.jsx(V,{parts:[{text:v.id,code:!0},"business rule"]})]},v.id))})]}),m.length>0&&t.state==="open"&&i.jsx(TA,{ticketId:t.id,hash:h==null?void 0:h.hash,confirmed:!!(h!=null&&h.confirmed),confirm:(v,x)=>o({title:e.map.title,ticketId:t.id,ticketKey:t.key,confirmed:v,hash:x})})]})}const Yo="";function PA(e){const t=du.map(o=>({value:o,label:sr[o],hint:Pg[o]})),s=[..._A(e),...t];return i.jsx(ut,{compact:!0,className:"vf-level","aria-label":"Verification level",value:e.value??Yo,options:s,onChange:o=>e.onChange(o===Yo?null:o)})}function _A(e){return e.inherit!==void 0?[{value:Yo,label:e.inherit,hint:"Use the trail’s level for this ticket."}]:e.value===void 0?[{value:Yo,label:"Off (not set)"}]:[]}function DA({check:e}){const t=ub(e),[s,o]=y.useState(),[a,c]=y.useState(),d=zA(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:()=>cr.log(e.log).then(h=>o(h.clipped?`[earlier output not shown]
172
+ ${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 zA(e){return e.error?"did not start":e.timedOut?"timed out":`exit ${e.exitCode??e.signal??"?"}`}const fp=e=>(e==null?void 0:e.slice(0,8))??"none",mp=e=>e===null?"·":String(e);function BA({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?`${fp(t.base.head)} → `:""}${fp(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(`
173
+ `),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":`+${mp(c.add)} −${mp(c.del)}`,c.dirtyAtClaim?" · dirty at claim":""]})]},c.path))})]})]})}function FA({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:cb[e.result]}),i.jsx(V,{parts:[{text:e.id,code:!0},e.agent,lr(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:UA(s),children:s},s))}),i.jsx(BA,{attempt:e}),e.checks.map(s=>i.jsx(DA,{check:s},s.name))]})}function UA(e){return e.includes(" ✓ ")?"ok":e.includes(" ✗ ")?"bad":e.includes(" ? ")?"claimed":"wait"}const WA={PASS:"Passed",FAIL:"Sent back",NEEDS_HUMAN:"Needs you"};function HA({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":WA[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}`,lr(e.at)]}),i.jsx("p",{children:e.summary}),e.findings.length>0&&i.jsx("ul",{className:"vf-findings",children:e.findings.map((o,a)=>i.jsxs("li",{className:`sev-${o.severity}`,children:[o.path&&i.jsx("code",{children:o.line?`${o.path}:${o.line}`:o.path})," ",o.text]},a))}),s&&s.length>0&&i.jsx(Qg,{answers:s})]})}function KA(e,t,s){const[o,a]=y.useState(),c=`${e}/${t}`;y.useEffect(()=>a(void 0),[c]);const{reload:d}=mt({view:c,version:s,load:()=>cr.ticket(e,t),show:a});return y.useEffect(()=>Qs.onEvidence(d),[d]),{data:o,reload:d}}const Dc={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 VA(e){const[t,s]=y.useState(),[o,a]=y.useState(""),[c,d]=y.useState("rework"),{state:h,submitted:m,running:p,act:k}=e;if(p||h!=="verifying"&&h!=="held")return null;const v=j=>{s(t===j?void 0:j),a("")},x=j=>{j.preventDefault(),!(!t||!o.trim())&&(k({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 k({action:"approve"}),"data-tip":"Checks passed: approve and close the ticket",children:"Approve"}),m&&i.jsx(P,{onClick:()=>void k({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:()=>v("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:()=>v("accept"),"data-tip":"Close it as done despite the failing checks",children:"Accept anyway…"}),i.jsx(P,{on:t==="unblock",onClick:()=>v("unblock"),"data-tip":"Put it back in the queue without running checks",children:"Unblock…"})]})]}),t&&i.jsxs(cn,{as:"form",tone:"inset",className:"inline-form",onSubmit:x,children:[i.jsx(Xe,{label:Dc[t].label,children:i.jsx("textarea",{rows:2,value:o,onChange:j=>a(j.target.value),autoFocus:!0})}),t==="unblock"&&i.jsx(Xe,{label:"Back to",children:i.jsx(ut,{"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:Dc[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:Dc[t].submit})]})]})]})}const GA={ticket:"set on this ticket",trail:"from the trail",none:"not set"},qA=new Set(["verifying","rework","held"]);function QA(e){const{mapId:t,ticket:s,state:o}=e,{data:a,reload:c}=KA(t,s.id,s.updatedAt),[d,h]=y.useState();if(!a||a.level.level==="off"&&!a.attempts.length&&!qA.has(o))return null;const m=k=>(h(void 0),cr.act({...k,mapId:t,ticketId:s.id,by:jt}).then(c,v=>h(v.message))),p=a.running;return i.jsxs("section",{className:"vf-panel",children:[i.jsxs("div",{className:"vf-head",children:[i.jsx(Ue,{as:"h4",children:"Verification"}),i.jsx(V,{parts:[sr[a.level.level],GA[a.level.source]]}),s.state==="open"&&i.jsx(PA,{value:s.verification,inherit:`Trail (${sr[e.trail??"off"]})`,onChange:k=>void m({action:"level",level:k})})]}),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 ",lr(p.startedAt)]})]}),i.jsx(VA,{state:o,submitted:a.attempts.length>0,running:!!p,act:m}),d&&i.jsx("p",{className:"vf-err",children:d}),a.verdicts.map(k=>i.jsx(HA,{verdict:k},k.id)),a.attempts.map((k,v)=>i.jsx(FA,{attempt:k,latest:v===0},k.id)),!a.attempts.length&&!p&&i.jsx(V,{parts:[`Checks: ${a.level.checks.join(", ")||"none"}`,"run when the ticket is submitted"]})]})}function YA({lease:e,onRelease:t}){const s=Qt(1e3),o=oa(e,s),a=o==="live";return i.jsxs("div",{className:`lease lease-${o} edge-note ${a?"":"edge-attention"}`,children:[i.jsxs("div",{className:"edge-note-head",children:[i.jsx(V,{parts:[{text:`Claimed by ${e.agent}`,strong:!0},`active ${un(s-e.renewedAt)} ago`]}),!a&&i.jsx(Qn,{tone:"amber",children:"Stalled"})]}),i.jsx("p",{className:"t-meta lease-line",children:JA(o,XA(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 JA(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 XA(e){const t=e/864e5;return t>=2?`${Math.round(t)} days`:qt(Math.max(0,e))}function ZA({comments:e}){const t=ri();if(!e.length)return null;const s=e.length>1?"s":"";return i.jsxs("details",{className:"comments",children:[i.jsxs("summary",{className:"t-label",children:[e.length," other comment",s]}),e.map(o=>i.jsxs("div",{className:"comment",children:[i.jsx(V,{parts:[{text:Gn(o.author,t),strong:!0}]}),i.jsx("div",{className:"c-body",children:o.body.replace(/\*\*/g,"")})]},o.id))]})}function eI({resolution:e,decisions:t,onOpenDecision:s}){const o=ri(),a=t.find(h=>!h.supersededBy)??t[0],c=e.body.startsWith("**Ruled")?"ruled out":"resolution",d=t.length>1?` · ${t.length} in chain`:"";return i.jsxs("div",{className:"resolution edge-note edge-done",children:[i.jsxs("div",{className:"edge-note-head",children:[i.jsx(V,{parts:[{text:Gn(e.author,o),strong:!0},c]}),a&&s&&i.jsxs("button",{className:"link t-meta",onClick:()=>s(a.id),children:[a.id,d," ›"]})]}),i.jsx("p",{children:e.body.replace(/^\*\*[^*]+\*\*\s*/,"")})]})}function tI(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 nI(e){return e.replace(/\s*Part of trail \S+\.\s*$/,"").trim()}function sI({t:e,state:t,tickets:s}){const o=new Map(s.map(p=>[p.id,p])),a=p=>{var k;return((k=o.get(p))==null?void 0:k.key)??p},c=e.blockedBy.map(p=>{var k;return`${a(p)}${((k=o.get(p))==null?void 0:k.state)==="closed"?" ✓":""}`}).join(", "),d=s.filter(p=>p.blockedBy.includes(e.id)).map(p=>p.key).join(", "),h=[["Type",tr[e.type]],["Assignee",e.assignee],["Blocked by",c],["Blocks",d],["Reviews",e.reviewOf&&a(e.reviewOf)]],m=rr(e)==="hitl";return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"d-head",children:[i.jsx("span",{className:"key t-code",children:e.key}),i.jsx(Qn,{tone:"state",className:`st-${t}`,children:fg[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,k])=>[i.jsx("dt",{className:"t-label",children:p},`${p}-k`),i.jsx("dd",{children:k},`${p}-v`)])})]})}function iI(e){const{snap:t,api:s,form:o,setForm:a}=e,{actions:c}=s,[d,h]=y.useState(""),[m,p]=y.useState(""),[k,v]=y.useState(""),[x,j]=y.useState("Not needed to reach the destination."),b=t.tickets.find(H=>H.id===e.id);if(!b)return i.jsx(Ie,{children:"Ticket not found."});const S=Js(t.tickets,t.map.mode).get(b.id),I=e.sessions.find(H=>H.ticketId===b.id&&ln(H)),C=b.assignee===jt,O=b.state==="open"?wu(s.leases,t.map.id).get(b.id):void 0,R=[...b.comments].reverse().find(H=>/^\*\*(Resolution|Ruled out of scope)\*\*/.test(H.body)),z=b.comments.filter(H=>H!==R),Z=nI(b.body),q=s.decisions.filter(H=>H.mapId===t.map.id&&H.ticketId===b.id);return i.jsxs("div",{className:"detail",children:[i.jsx(sI,{t:b,state:S,tickets:t.tickets}),i.jsx(Ev,{mapId:t.map.id,kind:"ticket",id:b.id}),Z&&i.jsxs("section",{className:"d-section ticket-body",children:[i.jsx("span",{className:"t-label",children:"Description"}),i.jsx("p",{className:"body",children:Z})]}),i.jsx(h2,{mapId:t.map.id,ticketId:b.id}),i.jsx(E1,{mapId:t.map.id,ticketId:b.id}),i.jsx(x$,{mapId:t.map.id,ticket:b}),i.jsx(OA,{snap:t,t:b}),i.jsx(H1,{snap:t,t:b}),b.closeReason==="not_planned"&&i.jsx(Eu,{label:"Save as dead end",draft:()=>{var H;return{title:`Ruled out: ${b.title}`,body:((H=b.comments.at(-1))==null?void 0:H.body)??b.body,kind:"dead-end",sources:[`trail:${t.map.key}`,`ticket:${b.key}`]}}}),O&&i.jsx(YA,{lease:O,onRelease:()=>c.releaseLease(b.id)}),!O&&i.jsx(W$,{mapId:t.map.id,ticketId:b.id}),i.jsx(QA,{mapId:t.map.id,trail:t.map.verification,ticket:b,state:S}),i.jsx(tI,{t:b,state:S,session:I,mine:C,form:o,setForm:a,actions:c,onOpenChat:e.onOpenChat}),o==="resolve"&&i.jsxs(cn,{as:"form",tone:"inset",className:"inline-form",onSubmit:H=>{H.preventDefault(),d.trim()&&(c.resolve(b.id,d.trim(),{rationale:m.trim(),alternatives:k.split(`
174
+ `).map(re=>re.trim()).filter(Boolean)}),a(null),h(""),p(""),v(""))},children:[i.jsx(Xe,{label:"Resolution",children:i.jsx("textarea",{rows:3,value:d,onChange:H=>h(H.target.value),autoFocus:!0})}),i.jsx(Xe,{label:"Rationale",children:i.jsx("input",{value:m,onChange:H=>p(H.target.value)})}),i.jsx(Xe,{label:"Alternatives considered",children:i.jsx("textarea",{rows:2,value:k,onChange:H=>v(H.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(cn,{as:"form",tone:"inset",className:"inline-form",onSubmit:H=>{H.preventDefault(),c.ruleOut({ticketId:b.id},x),a(null)},children:[i.jsx(Xe,{label:"Reason",children:i.jsx("input",{value:x,onChange:H=>j(H.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"})]})]}),R&&i.jsx(eI,{resolution:R,decisions:q,onOpenDecision:e.onOpenDecision}),i.jsx(ZA,{comments:z})]})}function rI({snap:e,item:t,api:s}){const o=Tp(e.map.mode),[a,c]=y.useState("research"),[d,h]=y.useState(t),[m,p]=y.useState(!1),[k,v]=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(cn,{as:"form",tone:"inset",className:"inline-form",onSubmit:S=>{S.preventDefault(),s.actions.graduate({unspecified:t,type:a,title:d,blockedBy:k,hitl:m})},children:[i.jsx(Xe,{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)),Qy.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 ${k.includes(S.id)?"on":""}`,onClick:()=>v(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(cn,{as:"form",tone:"inset",className:"inline-form",onSubmit:S=>{S.preventDefault(),s.actions.ruleOut({unspecified:t},x)},children:[i.jsx(Xe,{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 oI({api:e,sessions:t,bare:s,onOpenChat:o,onOpenDecision:a}){const{snap:c,selection:d,actions:h}=e,[m,p]=y.useState(null),k=aI(d);y.useEffect(()=>p(null),[k]);let v;return c?d?d.kind==="unspecified"?v=i.jsx(rI,{snap:c,item:d.item,api:e}):v=i.jsx(iI,{snap:c,id:d.id,api:e,sessions:t,form:m,setForm:p,onOpenChat:o??h.openChat,onOpenDecision:a}):v=i.jsx(xn,{title:"No ticket selected",hint:"Pick a ticket on the map: what it is, who has it, what blocks it, and its decision."}):v=i.jsx(xn,{title:"No trail yet",hint:"Once there's a trail, pick a ticket on the map to see it here."}),i.jsx(bg,{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:v})}function aI(e){return(e==null?void 0:e.kind)==="ticket"?e.id:(e==null?void 0:e.kind)==="unspecified"?e.item:""}const lI={holding:"Holding",challenged:"Challenged",invalidated:"Invalidated",confirmed:"Confirmed"};function cI(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 uI(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},lI[t.status],cI(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 dI(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 hI({snap:e,onSelect:t}){const{confirm:s,busy:o,error:a}=dI(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(uI,{a:d,snap:e,onSelect:t,onConfirm:h?()=>void s(d.id,d.text):void 0,busy:o===d.id},d.id)})})]}):i.jsx(Ie,{children:"None yet. They come from the accepted discovery brief or the trail's start."})}function fI(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 mI(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 pI({snap:e,activity:t,onTicket:s}){const o=mI(e),a=t.usageByMap[e.map.id],c=y.useMemo(()=>Wp({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",an(c.trailLeadMs),"Trail lead time: from when the trail was charted to its last done ticket"],["Median ticket",an(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,k])=>i.jsxs("li",{"data-tip":k,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:()=>ug(`${e.map.key.replace("#","trail-")}-report.md`,Vx(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"?an(m.leadMs):m.outcome})]})},m.id))}):i.jsx(Ie,{children:"No tickets yet"})]})}function gI({tab:e,snap:t,selection:s,onSelect:o,activity:a}){const c=t.map.sections;switch(e){case"report":return a?i.jsx(pI,{snap:t,activity:a,onTicket:d=>o({kind:"ticket",id:d})}):i.jsx(Ie,{children:"No activity yet"});case"assumptions":return i.jsx(hI,{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(Ie,{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(Ie,{children:"None"});case"oos":return c.outOfScope.length?i.jsx("ul",{className:"row-list oos",children:c.outOfScope.map(d=>{const h=fI(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(Ie,{children:"None"});case"notes":return i.jsx("p",{className:"notes t-body",children:c.notes||"No notes yet."});default:return e}}function vI({snap:e,selection:t,onSelect:s,bare:o,onAudit:a,activity:c}){var v;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:(v=m==null?void 0:m.assumptions)==null?void 0:v.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"}],k=e?i.jsx(gI,{tab:d,snap:e,selection:t,onSelect:s,activity:c}):i.jsx(xn,{title:"No plan yet",hint:"Open questions, decisions, what's ruled out, notes and the trail report collect here."});return i.jsxs(De,{className:`zone sections ${o?"bare":""}`,style:o?void 0:{gridArea:"plan"},children:[!o&&i.jsx(Tt,{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(ut,{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:k})]})}function kI(){var J;const e=y.useMemo(()=>s1(n1()),[]),t=g1(e),{snap:s,activity:o,selection:a,actions:c}=t,[d,h]=v1();y.useEffect(()=>xg(d.theme),[d.theme]);const m=pE(),p=bb(e,t),k=kE(e.kind),v=d1(),x=o.pending.length,j=yE(o,t.mapId);vE(x,s==null?void 0:s.map.title);const b=gE(t,v),S=YE(s,c.selectMap),I=J1(S.briefText),C=eA({api:t,nav:b,knowledge:I,reviewBrief:S.review,openReroute:X=>S.openReroute(X.mapId,X.ref),openGuides:()=>m.open("guides"),openConnector:X=>m.open(X),openApprovals:()=>m.open("approvals"),openFocusSettings:()=>m.open("attention")}),O=f1(e,t,d.briefing,(J=C.attention.view)==null?void 0:J.items),R=i.jsx(kb,{api:t,nav:b,bp:v,scoped:j,attn:C,above:S.inboxCard}),z=i.jsx(dE,{api:t,sessions:j.sessions,onSelect:b.select,onNewTrail:p.open,compact:v==="mobile",minFit:v==="mobile"?.7:0,trail:S}),Z=X=>i.jsx(oI,{api:t,sessions:j.sessions,bare:X,onOpenChat:ce=>b.openChat(ce),onOpenDecision:b.openDecisions}),q={activity:j,snap:s,leases:t.leases,onTicket:X=>b.select({kind:"ticket",id:X}),onOpenChat:X=>b.openChat(X)},H=X=>i.jsx(vI,{snap:s,selection:a,onSelect:b.select,bare:X,onAudit:()=>b.openDecisions(),activity:j}),{projects:re,overview:Q,openOverview:ve}=pA(v,b,C.link.request),ze=m.route&&i.jsx(mT,{rt:e,api:t,bp:v,prefs:d,update:h,settings:m}),$e=(b.statsOpen||b.decisionsView)&&i.jsx(mA,{api:t,bp:v,nav:b}),se=ze||Q||$e,D=O.shown&&i.jsx($1,{brief:O,snaps:t.allSnaps,bp:v,openTicket:b.openTicket,openChat:b.openChat,openDecisions:b.openDecisions,closeDecisions:()=>b.setDecisionsView(null),showPhoneHome:()=>b.setPhoneTab("home")});return i.jsx($g.Provider,{value:I,children:i.jsxs("div",{className:`app bp-${v}`,children:[i.jsx(xN,{api:t,rt:e,repo:i.jsx(i2,{repo:k,projects:re,onOverview:ve}),brief:O,attention:C.header,decisionsOpen:!!b.decisionsView,onDecisions:()=>{m.close(),b.decisionsView?b.setDecisionsView(null):b.openDecisions()},onStats:()=>{m.close(),b.toggleStats()},onNewTrail:p.open,onStartOver:()=>s&&p.startOver(s.map),onSettings:m.toggle,onSlack:()=>m.open("slack"),onToggleTheme:X=>h({theme:X?"night":"day"})}),v==="wide"&&i.jsxs(i.Fragment,{children:[R,z,Z(!1),i.jsx($A,{...q}),i.jsx(CA,{...q}),H(!1),se]}),v==="laptop"&&i.jsxs(i.Fragment,{children:[R,z,i.jsx(pT,{tab:b.sideTab,onTab:b.setSideTab,unspecified:s==null?void 0:s.map.sections.unspecified.length,ticket:Z(!0),activity:i.jsx(hp,{...q}),plan:H(!0)}),se]}),v==="mobile"&&i.jsxs(i.Fragment,{children:[i.jsx(mE,{tab:b.phoneTab,decisions:se,inbox:R,projects:re.many&&i.jsx(o2,{projects:re,onOverview:ve}),map:z,ticket:Z(!0),activity:i.jsx(hp,{...q}),plan:H(!0)}),i.jsx(fE,{tab:b.phoneTab,covered:!!se,pending:x,onPick:X=>{m.close(),b.setPhoneTab(X),b.setDecisionsView(null)}})]}),D,S.dialog,t.error&&i.jsx("div",{className:"error-toast",children:t.error}),p.dialog,!d.onboarded&&i.jsx(gC,{prefs:d,update:h,activeTracker:e.kind}),i.jsx(q1,{})]})})}const yI="X-Teamtrail-Session";function wI(e){return typeof e=="string"?e:e instanceof URL?e.href:e.url}function xI(e){const t=new URL(wI(e),location.href),s=te.apiPrefix;return t.origin===location.origin&&(t.pathname===s||t.pathname.startsWith(`${s}/`))}function jI(){const e=window.fetch.bind(window);window.fetch=(t,s)=>{const o=DS()?ju():void 0;if(!o||!xI(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(yI,o.secret),e(t,{...s,headers:a})}}xg(Cu().theme);jI();Uy.createRoot(document.getElementById("root")).render(i.jsxs(sT,{children:[i.jsx(kI,{}),i.jsx(j1,{})]}));