teamtrail 0.7.0-next.22 → 0.7.0-next.26
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.
- package/README.md +1 -1
- package/dist/app/assets/index-DsdFwtTC.js +148 -0
- package/dist/app/assets/{index-DO8pWv0g.css → index-jHW7ufHa.css} +1 -1
- package/dist/app/index.html +2 -2
- package/dist/cli.js +21712 -18958
- package/package.json +1 -1
- package/dist/app/assets/index-By1waldt.js +0 -146
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
var Vg=Object.defineProperty;var Kg=(e,n,r)=>n in e?Vg(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r;var ue=(e,n,r)=>Kg(e,typeof n!="symbol"?n+"":n,r);(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))o(l);new MutationObserver(l=>{for(const c of l)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 r(l){const c={};return l.integrity&&(c.integrity=l.integrity),l.referrerPolicy&&(c.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?c.credentials="include":l.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function o(l){if(l.ep)return;l.ep=!0;const c=r(l);fetch(l.href,c)}})();var El={exports:{}},$i={},Ml={exports:{}},ye={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react.production.min.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var yf;function Gg(){if(yf)return ye;yf=1;var e=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),d=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),v=Symbol.iterator;function j(T){return T===null||typeof T!="object"?null:(T=v&&T[v]||T["@@iterator"],typeof T=="function"?T:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},E=Object.assign,N={};function $(T,_,he){this.props=T,this.context=_,this.refs=N,this.updater=he||w}$.prototype.isReactComponent={},$.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")},$.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function I(){}I.prototype=$.prototype;function R(T,_,he){this.props=T,this.context=_,this.refs=N,this.updater=he||w}var O=R.prototype=new I;O.constructor=R,E(O,$.prototype),O.isPureReactComponent=!0;var te=Array.isArray,se=Object.prototype.hasOwnProperty,F={current:null},ie={key:!0,ref:!0,__self:!0,__source:!0};function oe(T,_,he){var pe,de={},we=null,me=null;if(_!=null)for(pe in _.ref!==void 0&&(me=_.ref),_.key!==void 0&&(we=""+_.key),_)se.call(_,pe)&&!ie.hasOwnProperty(pe)&&(de[pe]=_[pe]);var ke=arguments.length-2;if(ke===1)de.children=he;else if(1<ke){for(var Te=Array(ke),ct=0;ct<ke;ct++)Te[ct]=arguments[ct+2];de.children=Te}if(T&&T.defaultProps)for(pe in ke=T.defaultProps,ke)de[pe]===void 0&&(de[pe]=ke[pe]);return{$$typeof:e,type:T,key:we,ref:me,props:de,_owner:F.current}}function G(T,_){return{$$typeof:e,type:T.type,key:_,ref:T.ref,props:T.props,_owner:T._owner}}function ge(T){return typeof T=="object"&&T!==null&&T.$$typeof===e}function He(T){var _={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(he){return _[he]})}var $e=/\/+/g;function X(T,_){return typeof T=="object"&&T!==null&&T.key!=null?He(""+T.key):_.toString(36)}function P(T,_,he,pe,de){var we=typeof T;(we==="undefined"||we==="boolean")&&(T=null);var me=!1;if(T===null)me=!0;else switch(we){case"string":case"number":me=!0;break;case"object":switch(T.$$typeof){case e:case n:me=!0}}if(me)return me=T,de=de(me),T=pe===""?"."+X(me,0):pe,te(de)?(he="",T!=null&&(he=T.replace($e,"$&/")+"/"),P(de,_,he,"",function(ct){return ct})):de!=null&&(ge(de)&&(de=G(de,he+(!de.key||me&&me.key===de.key?"":(""+de.key).replace($e,"$&/")+"/")+T)),_.push(de)),1;if(me=0,pe=pe===""?".":pe+":",te(T))for(var ke=0;ke<T.length;ke++){we=T[ke];var Te=pe+X(we,ke);me+=P(we,_,he,Te,de)}else if(Te=j(T),typeof Te=="function")for(T=Te.call(T),ke=0;!(we=T.next()).done;)we=we.value,Te=pe+X(we,ke++),me+=P(we,_,he,Te,de);else if(we==="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 me}function Q(T,_,he){if(T==null)return T;var pe=[],de=0;return P(T,pe,"","",function(we){return _.call(he,we,de++)}),pe}function q(T){if(T._status===-1){var _=T._result;_=_(),_.then(function(he){(T._status===0||T._status===-1)&&(T._status=1,T._result=he)},function(he){(T._status===0||T._status===-1)&&(T._status=2,T._result=he)}),T._status===-1&&(T._status=0,T._result=_)}if(T._status===1)return T._result.default;throw T._result}var ae={current:null},H={transition:null},D={ReactCurrentDispatcher:ae,ReactCurrentBatchConfig:H,ReactCurrentOwner:F};function U(){throw Error("act(...) is not supported in production builds of React.")}return ye.Children={map:Q,forEach:function(T,_,he){Q(T,function(){_.apply(this,arguments)},he)},count:function(T){var _=0;return Q(T,function(){_++}),_},toArray:function(T){return Q(T,function(_){return _})||[]},only:function(T){if(!ge(T))throw Error("React.Children.only expected to receive a single React element child.");return T}},ye.Component=$,ye.Fragment=r,ye.Profiler=l,ye.PureComponent=R,ye.StrictMode=o,ye.Suspense=g,ye.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=D,ye.act=U,ye.cloneElement=function(T,_,he){if(T==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+T+".");var pe=E({},T.props),de=T.key,we=T.ref,me=T._owner;if(_!=null){if(_.ref!==void 0&&(we=_.ref,me=F.current),_.key!==void 0&&(de=""+_.key),T.type&&T.type.defaultProps)var ke=T.type.defaultProps;for(Te in _)se.call(_,Te)&&!ie.hasOwnProperty(Te)&&(pe[Te]=_[Te]===void 0&&ke!==void 0?ke[Te]:_[Te])}var Te=arguments.length-2;if(Te===1)pe.children=he;else if(1<Te){ke=Array(Te);for(var ct=0;ct<Te;ct++)ke[ct]=arguments[ct+2];pe.children=ke}return{$$typeof:e,type:T.type,key:de,ref:we,props:pe,_owner:me}},ye.createContext=function(T){return T={$$typeof:d,_currentValue:T,_currentValue2:T,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},T.Provider={$$typeof:c,_context:T},T.Consumer=T},ye.createElement=oe,ye.createFactory=function(T){var _=oe.bind(null,T);return _.type=T,_},ye.createRef=function(){return{current:null}},ye.forwardRef=function(T){return{$$typeof:h,render:T}},ye.isValidElement=ge,ye.lazy=function(T){return{$$typeof:y,_payload:{_status:-1,_result:T},_init:q}},ye.memo=function(T,_){return{$$typeof:m,type:T,compare:_===void 0?null:_}},ye.startTransition=function(T){var _=H.transition;H.transition={};try{T()}finally{H.transition=_}},ye.unstable_act=U,ye.useCallback=function(T,_){return ae.current.useCallback(T,_)},ye.useContext=function(T){return ae.current.useContext(T)},ye.useDebugValue=function(){},ye.useDeferredValue=function(T){return ae.current.useDeferredValue(T)},ye.useEffect=function(T,_){return ae.current.useEffect(T,_)},ye.useId=function(){return ae.current.useId()},ye.useImperativeHandle=function(T,_,he){return ae.current.useImperativeHandle(T,_,he)},ye.useInsertionEffect=function(T,_){return ae.current.useInsertionEffect(T,_)},ye.useLayoutEffect=function(T,_){return ae.current.useLayoutEffect(T,_)},ye.useMemo=function(T,_){return ae.current.useMemo(T,_)},ye.useReducer=function(T,_,he){return ae.current.useReducer(T,_,he)},ye.useRef=function(T){return ae.current.useRef(T)},ye.useState=function(T){return ae.current.useState(T)},ye.useSyncExternalStore=function(T,_,he){return ae.current.useSyncExternalStore(T,_,he)},ye.useTransition=function(){return ae.current.useTransition()},ye.version="18.3.1",ye}var xf;function ec(){return xf||(xf=1,Ml.exports=Gg()),Ml.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 wf;function Qg(){if(wf)return $i;wf=1;var e=ec(),n=Symbol.for("react.element"),r=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,l=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function d(h,g,m){var y,v={},j=null,w=null;m!==void 0&&(j=""+m),g.key!==void 0&&(j=""+g.key),g.ref!==void 0&&(w=g.ref);for(y in g)o.call(g,y)&&!c.hasOwnProperty(y)&&(v[y]=g[y]);if(h&&h.defaultProps)for(y in g=h.defaultProps,g)v[y]===void 0&&(v[y]=g[y]);return{$$typeof:n,type:h,key:j,ref:w,props:v,_owner:l.current}}return $i.Fragment=r,$i.jsx=d,$i.jsxs=d,$i}var jf;function qg(){return jf||(jf=1,El.exports=Qg()),El.exports}var i=qg(),Xr={},Il={exports:{}},kt={},Al={exports:{}},Ol={};/**
|
|
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 Sf;function Yg(){return Sf||(Sf=1,(function(e){function n(H,D){var U=H.length;H.push(D);e:for(;0<U;){var T=U-1>>>1,_=H[T];if(0<l(_,D))H[T]=D,H[U]=_,U=T;else break e}}function r(H){return H.length===0?null:H[0]}function o(H){if(H.length===0)return null;var D=H[0],U=H.pop();if(U!==D){H[0]=U;e:for(var T=0,_=H.length,he=_>>>1;T<he;){var pe=2*(T+1)-1,de=H[pe],we=pe+1,me=H[we];if(0>l(de,U))we<_&&0>l(me,de)?(H[T]=me,H[we]=U,T=we):(H[T]=de,H[pe]=U,T=pe);else if(we<_&&0>l(me,U))H[T]=me,H[we]=U,T=we;else break e}}return D}function l(H,D){var U=H.sortIndex-D.sortIndex;return U!==0?U:H.id-D.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 g=[],m=[],y=1,v=null,j=3,w=!1,E=!1,N=!1,$=typeof setTimeout=="function"?setTimeout:null,I=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function O(H){for(var D=r(m);D!==null;){if(D.callback===null)o(m);else if(D.startTime<=H)o(m),D.sortIndex=D.expirationTime,n(g,D);else break;D=r(m)}}function te(H){if(N=!1,O(H),!E)if(r(g)!==null)E=!0,q(se);else{var D=r(m);D!==null&&ae(te,D.startTime-H)}}function se(H,D){E=!1,N&&(N=!1,I(oe),oe=-1),w=!0;var U=j;try{for(O(D),v=r(g);v!==null&&(!(v.expirationTime>D)||H&&!He());){var T=v.callback;if(typeof T=="function"){v.callback=null,j=v.priorityLevel;var _=T(v.expirationTime<=D);D=e.unstable_now(),typeof _=="function"?v.callback=_:v===r(g)&&o(g),O(D)}else o(g);v=r(g)}if(v!==null)var he=!0;else{var pe=r(m);pe!==null&&ae(te,pe.startTime-D),he=!1}return he}finally{v=null,j=U,w=!1}}var F=!1,ie=null,oe=-1,G=5,ge=-1;function He(){return!(e.unstable_now()-ge<G)}function $e(){if(ie!==null){var H=e.unstable_now();ge=H;var D=!0;try{D=ie(!0,H)}finally{D?X():(F=!1,ie=null)}}else F=!1}var X;if(typeof R=="function")X=function(){R($e)};else if(typeof MessageChannel<"u"){var P=new MessageChannel,Q=P.port2;P.port1.onmessage=$e,X=function(){Q.postMessage(null)}}else X=function(){$($e,0)};function q(H){ie=H,F||(F=!0,X())}function ae(H,D){oe=$(function(){H(e.unstable_now())},D)}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(H){H.callback=null},e.unstable_continueExecution=function(){E||w||(E=!0,q(se))},e.unstable_forceFrameRate=function(H){0>H||125<H?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):G=0<H?Math.floor(1e3/H):5},e.unstable_getCurrentPriorityLevel=function(){return j},e.unstable_getFirstCallbackNode=function(){return r(g)},e.unstable_next=function(H){switch(j){case 1:case 2:case 3:var D=3;break;default:D=j}var U=j;j=D;try{return H()}finally{j=U}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(H,D){switch(H){case 1:case 2:case 3:case 4:case 5:break;default:H=3}var U=j;j=H;try{return D()}finally{j=U}},e.unstable_scheduleCallback=function(H,D,U){var T=e.unstable_now();switch(typeof U=="object"&&U!==null?(U=U.delay,U=typeof U=="number"&&0<U?T+U:T):U=T,H){case 1:var _=-1;break;case 2:_=250;break;case 5:_=1073741823;break;case 4:_=1e4;break;default:_=5e3}return _=U+_,H={id:y++,callback:D,priorityLevel:H,startTime:U,expirationTime:_,sortIndex:-1},U>T?(H.sortIndex=U,n(m,H),r(g)===null&&H===r(m)&&(N?(I(oe),oe=-1):N=!0,ae(te,U-T))):(H.sortIndex=_,n(g,H),E||w||(E=!0,q(se))),H},e.unstable_shouldYield=He,e.unstable_wrapCallback=function(H){var D=j;return function(){var U=j;j=D;try{return H.apply(this,arguments)}finally{j=U}}}})(Ol)),Ol}var Nf;function Jg(){return Nf||(Nf=1,Al.exports=Yg()),Al.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 Xg(){if(bf)return kt;bf=1;var e=ec(),n=Jg();function r(t){for(var s="https://reactjs.org/docs/error-decoder.html?invariant="+t,a=1;a<arguments.length;a++)s+="&args[]="+encodeURIComponent(arguments[a]);return"Minified React error #"+t+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var o=new Set,l={};function c(t,s){d(t,s),d(t+"Capture",s)}function d(t,s){for(l[t]=s,t=0;t<s.length;t++)o.add(s[t])}var h=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),g=Object.prototype.hasOwnProperty,m=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,y={},v={};function j(t){return g.call(v,t)?!0:g.call(y,t)?!1:m.test(t)?v[t]=!0:(y[t]=!0,!1)}function w(t,s,a,u){if(a!==null&&a.type===0)return!1;switch(typeof s){case"function":case"symbol":return!0;case"boolean":return u?!1:a!==null?!a.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function E(t,s,a,u){if(s===null||typeof s>"u"||w(t,s,a,u))return!0;if(u)return!1;if(a!==null)switch(a.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function N(t,s,a,u,f,p,k){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=u,this.attributeNamespace=f,this.mustUseProperty=a,this.propertyName=t,this.type=s,this.sanitizeURL=p,this.removeEmptyString=k}var $={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){$[t]=new N(t,0,!1,t,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var s=t[0];$[s]=new N(s,1,!1,t[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(t){$[t]=new N(t,2,!1,t.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){$[t]=new N(t,2,!1,t,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(t){$[t]=new N(t,3,!1,t.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(t){$[t]=new N(t,3,!0,t,null,!1,!1)}),["capture","download"].forEach(function(t){$[t]=new N(t,4,!1,t,null,!1,!1)}),["cols","rows","size","span"].forEach(function(t){$[t]=new N(t,6,!1,t,null,!1,!1)}),["rowSpan","start"].forEach(function(t){$[t]=new N(t,5,!1,t.toLowerCase(),null,!1,!1)});var I=/[\-:]([a-z])/g;function R(t){return t[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(t){var s=t.replace(I,R);$[s]=new N(s,1,!1,t,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var s=t.replace(I,R);$[s]=new N(s,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(t){var s=t.replace(I,R);$[s]=new N(s,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(t){$[t]=new N(t,1,!1,t.toLowerCase(),null,!1,!1)}),$.xlinkHref=new N("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(t){$[t]=new N(t,1,!1,t.toLowerCase(),null,!0,!0)});function O(t,s,a,u){var f=$.hasOwnProperty(s)?$[s]:null;(f!==null?f.type!==0:u||!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(E(s,a,f,u)&&(a=null),u||f===null?j(s)&&(a===null?t.removeAttribute(s):t.setAttribute(s,""+a)):f.mustUseProperty?t[f.propertyName]=a===null?f.type===3?!1:"":a:(s=f.attributeName,u=f.attributeNamespace,a===null?t.removeAttribute(s):(f=f.type,a=f===3||f===4&&a===!0?"":""+a,u?t.setAttributeNS(u,s,a):t.setAttribute(s,a))))}var te=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,se=Symbol.for("react.element"),F=Symbol.for("react.portal"),ie=Symbol.for("react.fragment"),oe=Symbol.for("react.strict_mode"),G=Symbol.for("react.profiler"),ge=Symbol.for("react.provider"),He=Symbol.for("react.context"),$e=Symbol.for("react.forward_ref"),X=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),Q=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),ae=Symbol.for("react.offscreen"),H=Symbol.iterator;function D(t){return t===null||typeof t!="object"?null:(t=H&&t[H]||t["@@iterator"],typeof t=="function"?t:null)}var U=Object.assign,T;function _(t){if(T===void 0)try{throw Error()}catch(a){var s=a.stack.trim().match(/\n( *(at )?)/);T=s&&s[1]||""}return`
|
|
34
|
+
`+T+t}var he=!1;function pe(t,s){if(!t||he)return"";he=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(s)if(s=function(){throw Error()},Object.defineProperty(s.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(s,[])}catch(L){var u=L}Reflect.construct(t,[],s)}else{try{s.call()}catch(L){u=L}t.call(s.prototype)}else{try{throw Error()}catch(L){u=L}t()}}catch(L){if(L&&u&&typeof L.stack=="string"){for(var f=L.stack.split(`
|
|
35
|
+
`),p=u.stack.split(`
|
|
36
|
+
`),k=f.length-1,S=p.length-1;1<=k&&0<=S&&f[k]!==p[S];)S--;for(;1<=k&&0<=S;k--,S--)if(f[k]!==p[S]){if(k!==1||S!==1)do if(k--,S--,0>S||f[k]!==p[S]){var b=`
|
|
37
|
+
`+f[k].replace(" at new "," at ");return t.displayName&&b.includes("<anonymous>")&&(b=b.replace("<anonymous>",t.displayName)),b}while(1<=k&&0<=S);break}}}finally{he=!1,Error.prepareStackTrace=a}return(t=t?t.displayName||t.name:"")?_(t):""}function de(t){switch(t.tag){case 5:return _(t.type);case 16:return _("Lazy");case 13:return _("Suspense");case 19:return _("SuspenseList");case 0:case 2:case 15:return t=pe(t.type,!1),t;case 11:return t=pe(t.type.render,!1),t;case 1:return t=pe(t.type,!0),t;default:return""}}function we(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case ie:return"Fragment";case F:return"Portal";case G:return"Profiler";case oe:return"StrictMode";case X:return"Suspense";case P:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case He:return(t.displayName||"Context")+".Consumer";case ge:return(t._context.displayName||"Context")+".Provider";case $e:var s=t.render;return t=t.displayName,t||(t=s.displayName||s.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Q:return s=t.displayName||null,s!==null?s:we(t.type)||"Memo";case q:s=t._payload,t=t._init;try{return we(t(s))}catch{}}return null}function me(t){var s=t.type;switch(t.tag){case 24:return"Cache";case 9:return(s.displayName||"Context")+".Consumer";case 10:return(s._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=s.render,t=t.displayName||t.name||"",s.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return s;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return we(s);case 8:return s===oe?"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 s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s}return null}function ke(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function Te(t){var s=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function ct(t){var s=Te(t)?"checked":"value",a=Object.getOwnPropertyDescriptor(t.constructor.prototype,s),u=""+t[s];if(!t.hasOwnProperty(s)&&typeof a<"u"&&typeof a.get=="function"&&typeof a.set=="function"){var f=a.get,p=a.set;return Object.defineProperty(t,s,{configurable:!0,get:function(){return f.call(this)},set:function(k){u=""+k,p.call(this,k)}}),Object.defineProperty(t,s,{enumerable:a.enumerable}),{getValue:function(){return u},setValue:function(k){u=""+k},stopTracking:function(){t._valueTracker=null,delete t[s]}}}}function ts(t){t._valueTracker||(t._valueTracker=ct(t))}function Nc(t){if(!t)return!1;var s=t._valueTracker;if(!s)return!0;var a=s.getValue(),u="";return t&&(u=Te(t)?t.checked?"true":"false":t.value),t=u,t!==a?(s.setValue(t),!0):!1}function Wi(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function _o(t,s){var a=s.checked;return U({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:a??t._wrapperState.initialChecked})}function bc(t,s){var a=s.defaultValue==null?"":s.defaultValue,u=s.checked!=null?s.checked:s.defaultChecked;a=ke(s.value!=null?s.value:a),t._wrapperState={initialChecked:u,initialValue:a,controlled:s.type==="checkbox"||s.type==="radio"?s.checked!=null:s.value!=null}}function Cc(t,s){s=s.checked,s!=null&&O(t,"checked",s,!1)}function Po(t,s){Cc(t,s);var a=ke(s.value),u=s.type;if(a!=null)u==="number"?(a===0&&t.value===""||t.value!=a)&&(t.value=""+a):t.value!==""+a&&(t.value=""+a);else if(u==="submit"||u==="reset"){t.removeAttribute("value");return}s.hasOwnProperty("value")?Do(t,s.type,a):s.hasOwnProperty("defaultValue")&&Do(t,s.type,ke(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(t.defaultChecked=!!s.defaultChecked)}function $c(t,s,a){if(s.hasOwnProperty("value")||s.hasOwnProperty("defaultValue")){var u=s.type;if(!(u!=="submit"&&u!=="reset"||s.value!==void 0&&s.value!==null))return;s=""+t._wrapperState.initialValue,a||s===t.value||(t.value=s),t.defaultValue=s}a=t.name,a!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,a!==""&&(t.name=a)}function Do(t,s,a){(s!=="number"||Wi(t.ownerDocument)!==t)&&(a==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+a&&(t.defaultValue=""+a))}var Us=Array.isArray;function ns(t,s,a,u){if(t=t.options,s){s={};for(var f=0;f<a.length;f++)s["$"+a[f]]=!0;for(a=0;a<t.length;a++)f=s.hasOwnProperty("$"+t[a].value),t[a].selected!==f&&(t[a].selected=f),f&&u&&(t[a].defaultSelected=!0)}else{for(a=""+ke(a),s=null,f=0;f<t.length;f++){if(t[f].value===a){t[f].selected=!0,u&&(t[f].defaultSelected=!0);return}s!==null||t[f].disabled||(s=t[f])}s!==null&&(s.selected=!0)}}function Bo(t,s){if(s.dangerouslySetInnerHTML!=null)throw Error(r(91));return U({},s,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function Tc(t,s){var a=s.value;if(a==null){if(a=s.children,s=s.defaultValue,a!=null){if(s!=null)throw Error(r(92));if(Us(a)){if(1<a.length)throw Error(r(93));a=a[0]}s=a}s==null&&(s=""),a=s}t._wrapperState={initialValue:ke(a)}}function Ec(t,s){var a=ke(s.value),u=ke(s.defaultValue);a!=null&&(a=""+a,a!==t.value&&(t.value=a),s.defaultValue==null&&t.defaultValue!==a&&(t.defaultValue=a)),u!=null&&(t.defaultValue=""+u)}function Mc(t){var s=t.textContent;s===t._wrapperState.initialValue&&s!==""&&s!==null&&(t.value=s)}function Ic(t){switch(t){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 zo(t,s){return t==null||t==="http://www.w3.org/1999/xhtml"?Ic(s):t==="http://www.w3.org/2000/svg"&&s==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var Hi,Ac=(function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(s,a,u,f){MSApp.execUnsafeLocalFunction(function(){return t(s,a,u,f)})}:t})(function(t,s){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=s;else{for(Hi=Hi||document.createElement("div"),Hi.innerHTML="<svg>"+s.valueOf().toString()+"</svg>",s=Hi.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;s.firstChild;)t.appendChild(s.firstChild)}});function Ws(t,s){if(s){var a=t.firstChild;if(a&&a===t.lastChild&&a.nodeType===3){a.nodeValue=s;return}}t.textContent=s}var Hs={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},qm=["Webkit","ms","Moz","O"];Object.keys(Hs).forEach(function(t){qm.forEach(function(s){s=s+t.charAt(0).toUpperCase()+t.substring(1),Hs[s]=Hs[t]})});function Oc(t,s,a){return s==null||typeof s=="boolean"||s===""?"":a||typeof s!="number"||s===0||Hs.hasOwnProperty(t)&&Hs[t]?(""+s).trim():s+"px"}function Lc(t,s){t=t.style;for(var a in s)if(s.hasOwnProperty(a)){var u=a.indexOf("--")===0,f=Oc(a,s[a],u);a==="float"&&(a="cssFloat"),u?t.setProperty(a,f):t[a]=f}}var Ym=U({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Fo(t,s){if(s){if(Ym[t]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(r(137,t));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(r(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(r(61))}if(s.style!=null&&typeof s.style!="object")throw Error(r(62))}}function Uo(t,s){if(t.indexOf("-")===-1)return typeof s.is=="string";switch(t){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 Wo=null;function Ho(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Vo=null,ss=null,is=null;function Rc(t){if(t=fi(t)){if(typeof Vo!="function")throw Error(r(280));var s=t.stateNode;s&&(s=hr(s),Vo(t.stateNode,t.type,s))}}function _c(t){ss?is?is.push(t):is=[t]:ss=t}function Pc(){if(ss){var t=ss,s=is;if(is=ss=null,Rc(t),s)for(t=0;t<s.length;t++)Rc(s[t])}}function Dc(t,s){return t(s)}function Bc(){}var Ko=!1;function zc(t,s,a){if(Ko)return t(s,a);Ko=!0;try{return Dc(t,s,a)}finally{Ko=!1,(ss!==null||is!==null)&&(Bc(),Pc())}}function Vs(t,s){var a=t.stateNode;if(a===null)return null;var u=hr(a);if(u===null)return null;a=u[s];e:switch(s){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)||(t=t.type,u=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!u;break e;default:t=!1}if(t)return null;if(a&&typeof a!="function")throw Error(r(231,s,typeof a));return a}var Go=!1;if(h)try{var Ks={};Object.defineProperty(Ks,"passive",{get:function(){Go=!0}}),window.addEventListener("test",Ks,Ks),window.removeEventListener("test",Ks,Ks)}catch{Go=!1}function Jm(t,s,a,u,f,p,k,S,b){var L=Array.prototype.slice.call(arguments,3);try{s.apply(a,L)}catch(z){this.onError(z)}}var Gs=!1,Vi=null,Ki=!1,Qo=null,Xm={onError:function(t){Gs=!0,Vi=t}};function Zm(t,s,a,u,f,p,k,S,b){Gs=!1,Vi=null,Jm.apply(Xm,arguments)}function ep(t,s,a,u,f,p,k,S,b){if(Zm.apply(this,arguments),Gs){if(Gs){var L=Vi;Gs=!1,Vi=null}else throw Error(r(198));Ki||(Ki=!0,Qo=L)}}function Bn(t){var s=t,a=t;if(t.alternate)for(;s.return;)s=s.return;else{t=s;do s=t,(s.flags&4098)!==0&&(a=s.return),t=s.return;while(t)}return s.tag===3?a:null}function Fc(t){if(t.tag===13){var s=t.memoizedState;if(s===null&&(t=t.alternate,t!==null&&(s=t.memoizedState)),s!==null)return s.dehydrated}return null}function Uc(t){if(Bn(t)!==t)throw Error(r(188))}function tp(t){var s=t.alternate;if(!s){if(s=Bn(t),s===null)throw Error(r(188));return s!==t?null:t}for(var a=t,u=s;;){var f=a.return;if(f===null)break;var p=f.alternate;if(p===null){if(u=f.return,u!==null){a=u;continue}break}if(f.child===p.child){for(p=f.child;p;){if(p===a)return Uc(f),t;if(p===u)return Uc(f),s;p=p.sibling}throw Error(r(188))}if(a.return!==u.return)a=f,u=p;else{for(var k=!1,S=f.child;S;){if(S===a){k=!0,a=f,u=p;break}if(S===u){k=!0,u=f,a=p;break}S=S.sibling}if(!k){for(S=p.child;S;){if(S===a){k=!0,a=p,u=f;break}if(S===u){k=!0,u=p,a=f;break}S=S.sibling}if(!k)throw Error(r(189))}}if(a.alternate!==u)throw Error(r(190))}if(a.tag!==3)throw Error(r(188));return a.stateNode.current===a?t:s}function Wc(t){return t=tp(t),t!==null?Hc(t):null}function Hc(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var s=Hc(t);if(s!==null)return s;t=t.sibling}return null}var Vc=n.unstable_scheduleCallback,Kc=n.unstable_cancelCallback,np=n.unstable_shouldYield,sp=n.unstable_requestPaint,Fe=n.unstable_now,ip=n.unstable_getCurrentPriorityLevel,qo=n.unstable_ImmediatePriority,Gc=n.unstable_UserBlockingPriority,Gi=n.unstable_NormalPriority,rp=n.unstable_LowPriority,Qc=n.unstable_IdlePriority,Qi=null,Ut=null;function op(t){if(Ut&&typeof Ut.onCommitFiberRoot=="function")try{Ut.onCommitFiberRoot(Qi,t,void 0,(t.current.flags&128)===128)}catch{}}var Ot=Math.clz32?Math.clz32:cp,ap=Math.log,lp=Math.LN2;function cp(t){return t>>>=0,t===0?32:31-(ap(t)/lp|0)|0}var qi=64,Yi=4194304;function Qs(t){switch(t&-t){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 t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function Ji(t,s){var a=t.pendingLanes;if(a===0)return 0;var u=0,f=t.suspendedLanes,p=t.pingedLanes,k=a&268435455;if(k!==0){var S=k&~f;S!==0?u=Qs(S):(p&=k,p!==0&&(u=Qs(p)))}else k=a&~f,k!==0?u=Qs(k):p!==0&&(u=Qs(p));if(u===0)return 0;if(s!==0&&s!==u&&(s&f)===0&&(f=u&-u,p=s&-s,f>=p||f===16&&(p&4194240)!==0))return s;if((u&4)!==0&&(u|=a&16),s=t.entangledLanes,s!==0)for(t=t.entanglements,s&=u;0<s;)a=31-Ot(s),f=1<<a,u|=t[a],s&=~f;return u}function up(t,s){switch(t){case 1:case 2:case 4:return s+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 s+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 dp(t,s){for(var a=t.suspendedLanes,u=t.pingedLanes,f=t.expirationTimes,p=t.pendingLanes;0<p;){var k=31-Ot(p),S=1<<k,b=f[k];b===-1?((S&a)===0||(S&u)!==0)&&(f[k]=up(S,s)):b<=s&&(t.expiredLanes|=S),p&=~S}}function Yo(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function qc(){var t=qi;return qi<<=1,(qi&4194240)===0&&(qi=64),t}function Jo(t){for(var s=[],a=0;31>a;a++)s.push(t);return s}function qs(t,s,a){t.pendingLanes|=s,s!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,s=31-Ot(s),t[s]=a}function fp(t,s){var a=t.pendingLanes&~s;t.pendingLanes=s,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=s,t.mutableReadLanes&=s,t.entangledLanes&=s,s=t.entanglements;var u=t.eventTimes;for(t=t.expirationTimes;0<a;){var f=31-Ot(a),p=1<<f;s[f]=0,u[f]=-1,t[f]=-1,a&=~p}}function Xo(t,s){var a=t.entangledLanes|=s;for(t=t.entanglements;a;){var u=31-Ot(a),f=1<<u;f&s|t[u]&s&&(t[u]|=s),a&=~f}}var be=0;function Yc(t){return t&=-t,1<t?4<t?(t&268435455)!==0?16:536870912:4:1}var Jc,Zo,Xc,Zc,eu,ea=!1,Xi=[],mn=null,pn=null,gn=null,Ys=new Map,Js=new Map,vn=[],hp="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 tu(t,s){switch(t){case"focusin":case"focusout":mn=null;break;case"dragenter":case"dragleave":pn=null;break;case"mouseover":case"mouseout":gn=null;break;case"pointerover":case"pointerout":Ys.delete(s.pointerId);break;case"gotpointercapture":case"lostpointercapture":Js.delete(s.pointerId)}}function Xs(t,s,a,u,f,p){return t===null||t.nativeEvent!==p?(t={blockedOn:s,domEventName:a,eventSystemFlags:u,nativeEvent:p,targetContainers:[f]},s!==null&&(s=fi(s),s!==null&&Zo(s)),t):(t.eventSystemFlags|=u,s=t.targetContainers,f!==null&&s.indexOf(f)===-1&&s.push(f),t)}function mp(t,s,a,u,f){switch(s){case"focusin":return mn=Xs(mn,t,s,a,u,f),!0;case"dragenter":return pn=Xs(pn,t,s,a,u,f),!0;case"mouseover":return gn=Xs(gn,t,s,a,u,f),!0;case"pointerover":var p=f.pointerId;return Ys.set(p,Xs(Ys.get(p)||null,t,s,a,u,f)),!0;case"gotpointercapture":return p=f.pointerId,Js.set(p,Xs(Js.get(p)||null,t,s,a,u,f)),!0}return!1}function nu(t){var s=zn(t.target);if(s!==null){var a=Bn(s);if(a!==null){if(s=a.tag,s===13){if(s=Fc(a),s!==null){t.blockedOn=s,eu(t.priority,function(){Xc(a)});return}}else if(s===3&&a.stateNode.current.memoizedState.isDehydrated){t.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}t.blockedOn=null}function Zi(t){if(t.blockedOn!==null)return!1;for(var s=t.targetContainers;0<s.length;){var a=na(t.domEventName,t.eventSystemFlags,s[0],t.nativeEvent);if(a===null){a=t.nativeEvent;var u=new a.constructor(a.type,a);Wo=u,a.target.dispatchEvent(u),Wo=null}else return s=fi(a),s!==null&&Zo(s),t.blockedOn=a,!1;s.shift()}return!0}function su(t,s,a){Zi(t)&&a.delete(s)}function pp(){ea=!1,mn!==null&&Zi(mn)&&(mn=null),pn!==null&&Zi(pn)&&(pn=null),gn!==null&&Zi(gn)&&(gn=null),Ys.forEach(su),Js.forEach(su)}function Zs(t,s){t.blockedOn===s&&(t.blockedOn=null,ea||(ea=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,pp)))}function ei(t){function s(f){return Zs(f,t)}if(0<Xi.length){Zs(Xi[0],t);for(var a=1;a<Xi.length;a++){var u=Xi[a];u.blockedOn===t&&(u.blockedOn=null)}}for(mn!==null&&Zs(mn,t),pn!==null&&Zs(pn,t),gn!==null&&Zs(gn,t),Ys.forEach(s),Js.forEach(s),a=0;a<vn.length;a++)u=vn[a],u.blockedOn===t&&(u.blockedOn=null);for(;0<vn.length&&(a=vn[0],a.blockedOn===null);)nu(a),a.blockedOn===null&&vn.shift()}var rs=te.ReactCurrentBatchConfig,er=!0;function gp(t,s,a,u){var f=be,p=rs.transition;rs.transition=null;try{be=1,ta(t,s,a,u)}finally{be=f,rs.transition=p}}function vp(t,s,a,u){var f=be,p=rs.transition;rs.transition=null;try{be=4,ta(t,s,a,u)}finally{be=f,rs.transition=p}}function ta(t,s,a,u){if(er){var f=na(t,s,a,u);if(f===null)ya(t,s,u,tr,a),tu(t,u);else if(mp(f,t,s,a,u))u.stopPropagation();else if(tu(t,u),s&4&&-1<hp.indexOf(t)){for(;f!==null;){var p=fi(f);if(p!==null&&Jc(p),p=na(t,s,a,u),p===null&&ya(t,s,u,tr,a),p===f)break;f=p}f!==null&&u.stopPropagation()}else ya(t,s,u,null,a)}}var tr=null;function na(t,s,a,u){if(tr=null,t=Ho(u),t=zn(t),t!==null)if(s=Bn(t),s===null)t=null;else if(a=s.tag,a===13){if(t=Fc(s),t!==null)return t;t=null}else if(a===3){if(s.stateNode.current.memoizedState.isDehydrated)return s.tag===3?s.stateNode.containerInfo:null;t=null}else s!==t&&(t=null);return tr=t,null}function iu(t){switch(t){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(ip()){case qo:return 1;case Gc:return 4;case Gi:case rp:return 16;case Qc:return 536870912;default:return 16}default:return 16}}var kn=null,sa=null,nr=null;function ru(){if(nr)return nr;var t,s=sa,a=s.length,u,f="value"in kn?kn.value:kn.textContent,p=f.length;for(t=0;t<a&&s[t]===f[t];t++);var k=a-t;for(u=1;u<=k&&s[a-u]===f[p-u];u++);return nr=f.slice(t,1<u?1-u:void 0)}function sr(t){var s=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&s===13&&(t=13)):t=s,t===10&&(t=13),32<=t||t===13?t:0}function ir(){return!0}function ou(){return!1}function xt(t){function s(a,u,f,p,k){this._reactName=a,this._targetInst=f,this.type=u,this.nativeEvent=p,this.target=k,this.currentTarget=null;for(var S in t)t.hasOwnProperty(S)&&(a=t[S],this[S]=a?a(p):p[S]);return this.isDefaultPrevented=(p.defaultPrevented!=null?p.defaultPrevented:p.returnValue===!1)?ir:ou,this.isPropagationStopped=ou,this}return U(s.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=ir)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=ir)},persist:function(){},isPersistent:ir}),s}var os={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ia=xt(os),ti=U({},os,{view:0,detail:0}),kp=xt(ti),ra,oa,ni,rr=U({},ti,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:la,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==ni&&(ni&&t.type==="mousemove"?(ra=t.screenX-ni.screenX,oa=t.screenY-ni.screenY):oa=ra=0,ni=t),ra)},movementY:function(t){return"movementY"in t?t.movementY:oa}}),au=xt(rr),yp=U({},rr,{dataTransfer:0}),xp=xt(yp),wp=U({},ti,{relatedTarget:0}),aa=xt(wp),jp=U({},os,{animationName:0,elapsedTime:0,pseudoElement:0}),Sp=xt(jp),Np=U({},os,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),bp=xt(Np),Cp=U({},os,{data:0}),lu=xt(Cp),$p={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Tp={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"},Ep={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Mp(t){var s=this.nativeEvent;return s.getModifierState?s.getModifierState(t):(t=Ep[t])?!!s[t]:!1}function la(){return Mp}var Ip=U({},ti,{key:function(t){if(t.key){var s=$p[t.key]||t.key;if(s!=="Unidentified")return s}return t.type==="keypress"?(t=sr(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?Tp[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:la,charCode:function(t){return t.type==="keypress"?sr(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?sr(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),Ap=xt(Ip),Op=U({},rr,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),cu=xt(Op),Lp=U({},ti,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:la}),Rp=xt(Lp),_p=U({},os,{propertyName:0,elapsedTime:0,pseudoElement:0}),Pp=xt(_p),Dp=U({},rr,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),Bp=xt(Dp),zp=[9,13,27,32],ca=h&&"CompositionEvent"in window,si=null;h&&"documentMode"in document&&(si=document.documentMode);var Fp=h&&"TextEvent"in window&&!si,uu=h&&(!ca||si&&8<si&&11>=si),du=" ",fu=!1;function hu(t,s){switch(t){case"keyup":return zp.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function mu(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var as=!1;function Up(t,s){switch(t){case"compositionend":return mu(s);case"keypress":return s.which!==32?null:(fu=!0,du);case"textInput":return t=s.data,t===du&&fu?null:t;default:return null}}function Wp(t,s){if(as)return t==="compositionend"||!ca&&hu(t,s)?(t=ru(),nr=sa=kn=null,as=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1<s.char.length)return s.char;if(s.which)return String.fromCharCode(s.which)}return null;case"compositionend":return uu&&s.locale!=="ko"?null:s.data;default:return null}}var Hp={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 pu(t){var s=t&&t.nodeName&&t.nodeName.toLowerCase();return s==="input"?!!Hp[t.type]:s==="textarea"}function gu(t,s,a,u){_c(u),s=ur(s,"onChange"),0<s.length&&(a=new ia("onChange","change",null,a,u),t.push({event:a,listeners:s}))}var ii=null,ri=null;function Vp(t){Lu(t,0)}function or(t){var s=fs(t);if(Nc(s))return t}function Kp(t,s){if(t==="change")return s}var vu=!1;if(h){var ua;if(h){var da="oninput"in document;if(!da){var ku=document.createElement("div");ku.setAttribute("oninput","return;"),da=typeof ku.oninput=="function"}ua=da}else ua=!1;vu=ua&&(!document.documentMode||9<document.documentMode)}function yu(){ii&&(ii.detachEvent("onpropertychange",xu),ri=ii=null)}function xu(t){if(t.propertyName==="value"&&or(ri)){var s=[];gu(s,ri,t,Ho(t)),zc(Vp,s)}}function Gp(t,s,a){t==="focusin"?(yu(),ii=s,ri=a,ii.attachEvent("onpropertychange",xu)):t==="focusout"&&yu()}function Qp(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return or(ri)}function qp(t,s){if(t==="click")return or(s)}function Yp(t,s){if(t==="input"||t==="change")return or(s)}function Jp(t,s){return t===s&&(t!==0||1/t===1/s)||t!==t&&s!==s}var Lt=typeof Object.is=="function"?Object.is:Jp;function oi(t,s){if(Lt(t,s))return!0;if(typeof t!="object"||t===null||typeof s!="object"||s===null)return!1;var a=Object.keys(t),u=Object.keys(s);if(a.length!==u.length)return!1;for(u=0;u<a.length;u++){var f=a[u];if(!g.call(s,f)||!Lt(t[f],s[f]))return!1}return!0}function wu(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function ju(t,s){var a=wu(t);t=0;for(var u;a;){if(a.nodeType===3){if(u=t+a.textContent.length,t<=s&&u>=s)return{node:a,offset:s-t};t=u}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=wu(a)}}function Su(t,s){return t&&s?t===s?!0:t&&t.nodeType===3?!1:s&&s.nodeType===3?Su(t,s.parentNode):"contains"in t?t.contains(s):t.compareDocumentPosition?!!(t.compareDocumentPosition(s)&16):!1:!1}function Nu(){for(var t=window,s=Wi();s instanceof t.HTMLIFrameElement;){try{var a=typeof s.contentWindow.location.href=="string"}catch{a=!1}if(a)t=s.contentWindow;else break;s=Wi(t.document)}return s}function fa(t){var s=t&&t.nodeName&&t.nodeName.toLowerCase();return s&&(s==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||s==="textarea"||t.contentEditable==="true")}function Xp(t){var s=Nu(),a=t.focusedElem,u=t.selectionRange;if(s!==a&&a&&a.ownerDocument&&Su(a.ownerDocument.documentElement,a)){if(u!==null&&fa(a)){if(s=u.start,t=u.end,t===void 0&&(t=s),"selectionStart"in a)a.selectionStart=s,a.selectionEnd=Math.min(t,a.value.length);else if(t=(s=a.ownerDocument||document)&&s.defaultView||window,t.getSelection){t=t.getSelection();var f=a.textContent.length,p=Math.min(u.start,f);u=u.end===void 0?p:Math.min(u.end,f),!t.extend&&p>u&&(f=u,u=p,p=f),f=ju(a,p);var k=ju(a,u);f&&k&&(t.rangeCount!==1||t.anchorNode!==f.node||t.anchorOffset!==f.offset||t.focusNode!==k.node||t.focusOffset!==k.offset)&&(s=s.createRange(),s.setStart(f.node,f.offset),t.removeAllRanges(),p>u?(t.addRange(s),t.extend(k.node,k.offset)):(s.setEnd(k.node,k.offset),t.addRange(s)))}}for(s=[],t=a;t=t.parentNode;)t.nodeType===1&&s.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof a.focus=="function"&&a.focus(),a=0;a<s.length;a++)t=s[a],t.element.scrollLeft=t.left,t.element.scrollTop=t.top}}var Zp=h&&"documentMode"in document&&11>=document.documentMode,ls=null,ha=null,ai=null,ma=!1;function bu(t,s,a){var u=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;ma||ls==null||ls!==Wi(u)||(u=ls,"selectionStart"in u&&fa(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}),ai&&oi(ai,u)||(ai=u,u=ur(ha,"onSelect"),0<u.length&&(s=new ia("onSelect","select",null,s,a),t.push({event:s,listeners:u}),s.target=ls)))}function ar(t,s){var a={};return a[t.toLowerCase()]=s.toLowerCase(),a["Webkit"+t]="webkit"+s,a["Moz"+t]="moz"+s,a}var cs={animationend:ar("Animation","AnimationEnd"),animationiteration:ar("Animation","AnimationIteration"),animationstart:ar("Animation","AnimationStart"),transitionend:ar("Transition","TransitionEnd")},pa={},Cu={};h&&(Cu=document.createElement("div").style,"AnimationEvent"in window||(delete cs.animationend.animation,delete cs.animationiteration.animation,delete cs.animationstart.animation),"TransitionEvent"in window||delete cs.transitionend.transition);function lr(t){if(pa[t])return pa[t];if(!cs[t])return t;var s=cs[t],a;for(a in s)if(s.hasOwnProperty(a)&&a in Cu)return pa[t]=s[a];return t}var $u=lr("animationend"),Tu=lr("animationiteration"),Eu=lr("animationstart"),Mu=lr("transitionend"),Iu=new Map,Au="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 yn(t,s){Iu.set(t,s),c(s,[t])}for(var ga=0;ga<Au.length;ga++){var va=Au[ga],eg=va.toLowerCase(),tg=va[0].toUpperCase()+va.slice(1);yn(eg,"on"+tg)}yn($u,"onAnimationEnd"),yn(Tu,"onAnimationIteration"),yn(Eu,"onAnimationStart"),yn("dblclick","onDoubleClick"),yn("focusin","onFocus"),yn("focusout","onBlur"),yn(Mu,"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 li="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(" "),ng=new Set("cancel close invalid load scroll toggle".split(" ").concat(li));function Ou(t,s,a){var u=t.type||"unknown-event";t.currentTarget=a,ep(u,s,void 0,t),t.currentTarget=null}function Lu(t,s){s=(s&4)!==0;for(var a=0;a<t.length;a++){var u=t[a],f=u.event;u=u.listeners;e:{var p=void 0;if(s)for(var k=u.length-1;0<=k;k--){var S=u[k],b=S.instance,L=S.currentTarget;if(S=S.listener,b!==p&&f.isPropagationStopped())break e;Ou(f,S,L),p=b}else for(k=0;k<u.length;k++){if(S=u[k],b=S.instance,L=S.currentTarget,S=S.listener,b!==p&&f.isPropagationStopped())break e;Ou(f,S,L),p=b}}}if(Ki)throw t=Qo,Ki=!1,Qo=null,t}function Ie(t,s){var a=s[ba];a===void 0&&(a=s[ba]=new Set);var u=t+"__bubble";a.has(u)||(Ru(s,t,2,!1),a.add(u))}function ka(t,s,a){var u=0;s&&(u|=4),Ru(a,t,u,s)}var cr="_reactListening"+Math.random().toString(36).slice(2);function ci(t){if(!t[cr]){t[cr]=!0,o.forEach(function(a){a!=="selectionchange"&&(ng.has(a)||ka(a,!1,t),ka(a,!0,t))});var s=t.nodeType===9?t:t.ownerDocument;s===null||s[cr]||(s[cr]=!0,ka("selectionchange",!1,s))}}function Ru(t,s,a,u){switch(iu(s)){case 1:var f=gp;break;case 4:f=vp;break;default:f=ta}a=f.bind(null,s,a,t),f=void 0,!Go||s!=="touchstart"&&s!=="touchmove"&&s!=="wheel"||(f=!0),u?f!==void 0?t.addEventListener(s,a,{capture:!0,passive:f}):t.addEventListener(s,a,!0):f!==void 0?t.addEventListener(s,a,{passive:f}):t.addEventListener(s,a,!1)}function ya(t,s,a,u,f){var p=u;if((s&1)===0&&(s&2)===0&&u!==null)e:for(;;){if(u===null)return;var k=u.tag;if(k===3||k===4){var S=u.stateNode.containerInfo;if(S===f||S.nodeType===8&&S.parentNode===f)break;if(k===4)for(k=u.return;k!==null;){var b=k.tag;if((b===3||b===4)&&(b=k.stateNode.containerInfo,b===f||b.nodeType===8&&b.parentNode===f))return;k=k.return}for(;S!==null;){if(k=zn(S),k===null)return;if(b=k.tag,b===5||b===6){u=p=k;continue e}S=S.parentNode}}u=u.return}zc(function(){var L=p,z=Ho(a),W=[];e:{var B=Iu.get(t);if(B!==void 0){var Y=ia,Z=t;switch(t){case"keypress":if(sr(a)===0)break e;case"keydown":case"keyup":Y=Ap;break;case"focusin":Z="focus",Y=aa;break;case"focusout":Z="blur",Y=aa;break;case"beforeblur":case"afterblur":Y=aa;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Y=au;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Y=xp;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Y=Rp;break;case $u:case Tu:case Eu:Y=Sp;break;case Mu:Y=Pp;break;case"scroll":Y=kp;break;case"wheel":Y=Bp;break;case"copy":case"cut":case"paste":Y=bp;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Y=cu}var ee=(s&4)!==0,Ue=!ee&&t==="scroll",M=ee?B!==null?B+"Capture":null:B;ee=[];for(var C=L,A;C!==null;){A=C;var V=A.stateNode;if(A.tag===5&&V!==null&&(A=V,M!==null&&(V=Vs(C,M),V!=null&&ee.push(ui(C,V,A)))),Ue)break;C=C.return}0<ee.length&&(B=new Y(B,Z,null,a,z),W.push({event:B,listeners:ee}))}}if((s&7)===0){e:{if(B=t==="mouseover"||t==="pointerover",Y=t==="mouseout"||t==="pointerout",B&&a!==Wo&&(Z=a.relatedTarget||a.fromElement)&&(zn(Z)||Z[tn]))break e;if((Y||B)&&(B=z.window===z?z:(B=z.ownerDocument)?B.defaultView||B.parentWindow:window,Y?(Z=a.relatedTarget||a.toElement,Y=L,Z=Z?zn(Z):null,Z!==null&&(Ue=Bn(Z),Z!==Ue||Z.tag!==5&&Z.tag!==6)&&(Z=null)):(Y=null,Z=L),Y!==Z)){if(ee=au,V="onMouseLeave",M="onMouseEnter",C="mouse",(t==="pointerout"||t==="pointerover")&&(ee=cu,V="onPointerLeave",M="onPointerEnter",C="pointer"),Ue=Y==null?B:fs(Y),A=Z==null?B:fs(Z),B=new ee(V,C+"leave",Y,a,z),B.target=Ue,B.relatedTarget=A,V=null,zn(z)===L&&(ee=new ee(M,C+"enter",Z,a,z),ee.target=A,ee.relatedTarget=Ue,V=ee),Ue=V,Y&&Z)t:{for(ee=Y,M=Z,C=0,A=ee;A;A=us(A))C++;for(A=0,V=M;V;V=us(V))A++;for(;0<C-A;)ee=us(ee),C--;for(;0<A-C;)M=us(M),A--;for(;C--;){if(ee===M||M!==null&&ee===M.alternate)break t;ee=us(ee),M=us(M)}ee=null}else ee=null;Y!==null&&_u(W,B,Y,ee,!1),Z!==null&&Ue!==null&&_u(W,Ue,Z,ee,!0)}}e:{if(B=L?fs(L):window,Y=B.nodeName&&B.nodeName.toLowerCase(),Y==="select"||Y==="input"&&B.type==="file")var ne=Kp;else if(pu(B))if(vu)ne=Yp;else{ne=Qp;var le=Gp}else(Y=B.nodeName)&&Y.toLowerCase()==="input"&&(B.type==="checkbox"||B.type==="radio")&&(ne=qp);if(ne&&(ne=ne(t,L))){gu(W,ne,a,z);break e}le&&le(t,B,L),t==="focusout"&&(le=B._wrapperState)&&le.controlled&&B.type==="number"&&Do(B,"number",B.value)}switch(le=L?fs(L):window,t){case"focusin":(pu(le)||le.contentEditable==="true")&&(ls=le,ha=L,ai=null);break;case"focusout":ai=ha=ls=null;break;case"mousedown":ma=!0;break;case"contextmenu":case"mouseup":case"dragend":ma=!1,bu(W,a,z);break;case"selectionchange":if(Zp)break;case"keydown":case"keyup":bu(W,a,z)}var ce;if(ca)e:{switch(t){case"compositionstart":var fe="onCompositionStart";break e;case"compositionend":fe="onCompositionEnd";break e;case"compositionupdate":fe="onCompositionUpdate";break e}fe=void 0}else as?hu(t,a)&&(fe="onCompositionEnd"):t==="keydown"&&a.keyCode===229&&(fe="onCompositionStart");fe&&(uu&&a.locale!=="ko"&&(as||fe!=="onCompositionStart"?fe==="onCompositionEnd"&&as&&(ce=ru()):(kn=z,sa="value"in kn?kn.value:kn.textContent,as=!0)),le=ur(L,fe),0<le.length&&(fe=new lu(fe,t,null,a,z),W.push({event:fe,listeners:le}),ce?fe.data=ce:(ce=mu(a),ce!==null&&(fe.data=ce)))),(ce=Fp?Up(t,a):Wp(t,a))&&(L=ur(L,"onBeforeInput"),0<L.length&&(z=new lu("onBeforeInput","beforeinput",null,a,z),W.push({event:z,listeners:L}),z.data=ce))}Lu(W,s)})}function ui(t,s,a){return{instance:t,listener:s,currentTarget:a}}function ur(t,s){for(var a=s+"Capture",u=[];t!==null;){var f=t,p=f.stateNode;f.tag===5&&p!==null&&(f=p,p=Vs(t,a),p!=null&&u.unshift(ui(t,p,f)),p=Vs(t,s),p!=null&&u.push(ui(t,p,f))),t=t.return}return u}function us(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5);return t||null}function _u(t,s,a,u,f){for(var p=s._reactName,k=[];a!==null&&a!==u;){var S=a,b=S.alternate,L=S.stateNode;if(b!==null&&b===u)break;S.tag===5&&L!==null&&(S=L,f?(b=Vs(a,p),b!=null&&k.unshift(ui(a,b,S))):f||(b=Vs(a,p),b!=null&&k.push(ui(a,b,S)))),a=a.return}k.length!==0&&t.push({event:s,listeners:k})}var sg=/\r\n?/g,ig=/\u0000|\uFFFD/g;function Pu(t){return(typeof t=="string"?t:""+t).replace(sg,`
|
|
38
|
+
`).replace(ig,"")}function dr(t,s,a){if(s=Pu(s),Pu(t)!==s&&a)throw Error(r(425))}function fr(){}var xa=null,wa=null;function ja(t,s){return t==="textarea"||t==="noscript"||typeof s.children=="string"||typeof s.children=="number"||typeof s.dangerouslySetInnerHTML=="object"&&s.dangerouslySetInnerHTML!==null&&s.dangerouslySetInnerHTML.__html!=null}var Sa=typeof setTimeout=="function"?setTimeout:void 0,rg=typeof clearTimeout=="function"?clearTimeout:void 0,Du=typeof Promise=="function"?Promise:void 0,og=typeof queueMicrotask=="function"?queueMicrotask:typeof Du<"u"?function(t){return Du.resolve(null).then(t).catch(ag)}:Sa;function ag(t){setTimeout(function(){throw t})}function Na(t,s){var a=s,u=0;do{var f=a.nextSibling;if(t.removeChild(a),f&&f.nodeType===8)if(a=f.data,a==="/$"){if(u===0){t.removeChild(f),ei(s);return}u--}else a!=="$"&&a!=="$?"&&a!=="$!"||u++;a=f}while(a);ei(s)}function xn(t){for(;t!=null;t=t.nextSibling){var s=t.nodeType;if(s===1||s===3)break;if(s===8){if(s=t.data,s==="$"||s==="$!"||s==="$?")break;if(s==="/$")return null}}return t}function Bu(t){t=t.previousSibling;for(var s=0;t;){if(t.nodeType===8){var a=t.data;if(a==="$"||a==="$!"||a==="$?"){if(s===0)return t;s--}else a==="/$"&&s++}t=t.previousSibling}return null}var ds=Math.random().toString(36).slice(2),Wt="__reactFiber$"+ds,di="__reactProps$"+ds,tn="__reactContainer$"+ds,ba="__reactEvents$"+ds,lg="__reactListeners$"+ds,cg="__reactHandles$"+ds;function zn(t){var s=t[Wt];if(s)return s;for(var a=t.parentNode;a;){if(s=a[tn]||a[Wt]){if(a=s.alternate,s.child!==null||a!==null&&a.child!==null)for(t=Bu(t);t!==null;){if(a=t[Wt])return a;t=Bu(t)}return s}t=a,a=t.parentNode}return null}function fi(t){return t=t[Wt]||t[tn],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function fs(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(r(33))}function hr(t){return t[di]||null}var Ca=[],hs=-1;function wn(t){return{current:t}}function Ae(t){0>hs||(t.current=Ca[hs],Ca[hs]=null,hs--)}function Me(t,s){hs++,Ca[hs]=t.current,t.current=s}var jn={},it=wn(jn),ht=wn(!1),Fn=jn;function ms(t,s){var a=t.type.contextTypes;if(!a)return jn;var u=t.stateNode;if(u&&u.__reactInternalMemoizedUnmaskedChildContext===s)return u.__reactInternalMemoizedMaskedChildContext;var f={},p;for(p in a)f[p]=s[p];return u&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=s,t.__reactInternalMemoizedMaskedChildContext=f),f}function mt(t){return t=t.childContextTypes,t!=null}function mr(){Ae(ht),Ae(it)}function zu(t,s,a){if(it.current!==jn)throw Error(r(168));Me(it,s),Me(ht,a)}function Fu(t,s,a){var u=t.stateNode;if(s=s.childContextTypes,typeof u.getChildContext!="function")return a;u=u.getChildContext();for(var f in u)if(!(f in s))throw Error(r(108,me(t)||"Unknown",f));return U({},a,u)}function pr(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||jn,Fn=it.current,Me(it,t),Me(ht,ht.current),!0}function Uu(t,s,a){var u=t.stateNode;if(!u)throw Error(r(169));a?(t=Fu(t,s,Fn),u.__reactInternalMemoizedMergedChildContext=t,Ae(ht),Ae(it),Me(it,t)):Ae(ht),Me(ht,a)}var nn=null,gr=!1,$a=!1;function Wu(t){nn===null?nn=[t]:nn.push(t)}function ug(t){gr=!0,Wu(t)}function Sn(){if(!$a&&nn!==null){$a=!0;var t=0,s=be;try{var a=nn;for(be=1;t<a.length;t++){var u=a[t];do u=u(!0);while(u!==null)}nn=null,gr=!1}catch(f){throw nn!==null&&(nn=nn.slice(t+1)),Vc(qo,Sn),f}finally{be=s,$a=!1}}return null}var ps=[],gs=0,vr=null,kr=0,bt=[],Ct=0,Un=null,sn=1,rn="";function Wn(t,s){ps[gs++]=kr,ps[gs++]=vr,vr=t,kr=s}function Hu(t,s,a){bt[Ct++]=sn,bt[Ct++]=rn,bt[Ct++]=Un,Un=t;var u=sn;t=rn;var f=32-Ot(u)-1;u&=~(1<<f),a+=1;var p=32-Ot(s)+f;if(30<p){var k=f-f%5;p=(u&(1<<k)-1).toString(32),u>>=k,f-=k,sn=1<<32-Ot(s)+f|a<<f|u,rn=p+t}else sn=1<<p|a<<f|u,rn=t}function Ta(t){t.return!==null&&(Wn(t,1),Hu(t,1,0))}function Ea(t){for(;t===vr;)vr=ps[--gs],ps[gs]=null,kr=ps[--gs],ps[gs]=null;for(;t===Un;)Un=bt[--Ct],bt[Ct]=null,rn=bt[--Ct],bt[Ct]=null,sn=bt[--Ct],bt[Ct]=null}var wt=null,jt=null,Oe=!1,Rt=null;function Vu(t,s){var a=Mt(5,null,null,0);a.elementType="DELETED",a.stateNode=s,a.return=t,s=t.deletions,s===null?(t.deletions=[a],t.flags|=16):s.push(a)}function Ku(t,s){switch(t.tag){case 5:var a=t.type;return s=s.nodeType!==1||a.toLowerCase()!==s.nodeName.toLowerCase()?null:s,s!==null?(t.stateNode=s,wt=t,jt=xn(s.firstChild),!0):!1;case 6:return s=t.pendingProps===""||s.nodeType!==3?null:s,s!==null?(t.stateNode=s,wt=t,jt=null,!0):!1;case 13:return s=s.nodeType!==8?null:s,s!==null?(a=Un!==null?{id:sn,overflow:rn}:null,t.memoizedState={dehydrated:s,treeContext:a,retryLane:1073741824},a=Mt(18,null,null,0),a.stateNode=s,a.return=t,t.child=a,wt=t,jt=null,!0):!1;default:return!1}}function Ma(t){return(t.mode&1)!==0&&(t.flags&128)===0}function Ia(t){if(Oe){var s=jt;if(s){var a=s;if(!Ku(t,s)){if(Ma(t))throw Error(r(418));s=xn(a.nextSibling);var u=wt;s&&Ku(t,s)?Vu(u,a):(t.flags=t.flags&-4097|2,Oe=!1,wt=t)}}else{if(Ma(t))throw Error(r(418));t.flags=t.flags&-4097|2,Oe=!1,wt=t}}}function Gu(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;wt=t}function yr(t){if(t!==wt)return!1;if(!Oe)return Gu(t),Oe=!0,!1;var s;if((s=t.tag!==3)&&!(s=t.tag!==5)&&(s=t.type,s=s!=="head"&&s!=="body"&&!ja(t.type,t.memoizedProps)),s&&(s=jt)){if(Ma(t))throw Qu(),Error(r(418));for(;s;)Vu(t,s),s=xn(s.nextSibling)}if(Gu(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(r(317));e:{for(t=t.nextSibling,s=0;t;){if(t.nodeType===8){var a=t.data;if(a==="/$"){if(s===0){jt=xn(t.nextSibling);break e}s--}else a!=="$"&&a!=="$!"&&a!=="$?"||s++}t=t.nextSibling}jt=null}}else jt=wt?xn(t.stateNode.nextSibling):null;return!0}function Qu(){for(var t=jt;t;)t=xn(t.nextSibling)}function vs(){jt=wt=null,Oe=!1}function Aa(t){Rt===null?Rt=[t]:Rt.push(t)}var dg=te.ReactCurrentBatchConfig;function hi(t,s,a){if(t=a.ref,t!==null&&typeof t!="function"&&typeof t!="object"){if(a._owner){if(a=a._owner,a){if(a.tag!==1)throw Error(r(309));var u=a.stateNode}if(!u)throw Error(r(147,t));var f=u,p=""+t;return s!==null&&s.ref!==null&&typeof s.ref=="function"&&s.ref._stringRef===p?s.ref:(s=function(k){var S=f.refs;k===null?delete S[p]:S[p]=k},s._stringRef=p,s)}if(typeof t!="string")throw Error(r(284));if(!a._owner)throw Error(r(290,t))}return t}function xr(t,s){throw t=Object.prototype.toString.call(s),Error(r(31,t==="[object Object]"?"object with keys {"+Object.keys(s).join(", ")+"}":t))}function qu(t){var s=t._init;return s(t._payload)}function Yu(t){function s(M,C){if(t){var A=M.deletions;A===null?(M.deletions=[C],M.flags|=16):A.push(C)}}function a(M,C){if(!t)return null;for(;C!==null;)s(M,C),C=C.sibling;return null}function u(M,C){for(M=new Map;C!==null;)C.key!==null?M.set(C.key,C):M.set(C.index,C),C=C.sibling;return M}function f(M,C){return M=In(M,C),M.index=0,M.sibling=null,M}function p(M,C,A){return M.index=A,t?(A=M.alternate,A!==null?(A=A.index,A<C?(M.flags|=2,C):A):(M.flags|=2,C)):(M.flags|=1048576,C)}function k(M){return t&&M.alternate===null&&(M.flags|=2),M}function S(M,C,A,V){return C===null||C.tag!==6?(C=Sl(A,M.mode,V),C.return=M,C):(C=f(C,A),C.return=M,C)}function b(M,C,A,V){var ne=A.type;return ne===ie?z(M,C,A.props.children,V,A.key):C!==null&&(C.elementType===ne||typeof ne=="object"&&ne!==null&&ne.$$typeof===q&&qu(ne)===C.type)?(V=f(C,A.props),V.ref=hi(M,C,A),V.return=M,V):(V=Hr(A.type,A.key,A.props,null,M.mode,V),V.ref=hi(M,C,A),V.return=M,V)}function L(M,C,A,V){return C===null||C.tag!==4||C.stateNode.containerInfo!==A.containerInfo||C.stateNode.implementation!==A.implementation?(C=Nl(A,M.mode,V),C.return=M,C):(C=f(C,A.children||[]),C.return=M,C)}function z(M,C,A,V,ne){return C===null||C.tag!==7?(C=Jn(A,M.mode,V,ne),C.return=M,C):(C=f(C,A),C.return=M,C)}function W(M,C,A){if(typeof C=="string"&&C!==""||typeof C=="number")return C=Sl(""+C,M.mode,A),C.return=M,C;if(typeof C=="object"&&C!==null){switch(C.$$typeof){case se:return A=Hr(C.type,C.key,C.props,null,M.mode,A),A.ref=hi(M,null,C),A.return=M,A;case F:return C=Nl(C,M.mode,A),C.return=M,C;case q:var V=C._init;return W(M,V(C._payload),A)}if(Us(C)||D(C))return C=Jn(C,M.mode,A,null),C.return=M,C;xr(M,C)}return null}function B(M,C,A,V){var ne=C!==null?C.key:null;if(typeof A=="string"&&A!==""||typeof A=="number")return ne!==null?null:S(M,C,""+A,V);if(typeof A=="object"&&A!==null){switch(A.$$typeof){case se:return A.key===ne?b(M,C,A,V):null;case F:return A.key===ne?L(M,C,A,V):null;case q:return ne=A._init,B(M,C,ne(A._payload),V)}if(Us(A)||D(A))return ne!==null?null:z(M,C,A,V,null);xr(M,A)}return null}function Y(M,C,A,V,ne){if(typeof V=="string"&&V!==""||typeof V=="number")return M=M.get(A)||null,S(C,M,""+V,ne);if(typeof V=="object"&&V!==null){switch(V.$$typeof){case se:return M=M.get(V.key===null?A:V.key)||null,b(C,M,V,ne);case F:return M=M.get(V.key===null?A:V.key)||null,L(C,M,V,ne);case q:var le=V._init;return Y(M,C,A,le(V._payload),ne)}if(Us(V)||D(V))return M=M.get(A)||null,z(C,M,V,ne,null);xr(C,V)}return null}function Z(M,C,A,V){for(var ne=null,le=null,ce=C,fe=C=0,Ze=null;ce!==null&&fe<A.length;fe++){ce.index>fe?(Ze=ce,ce=null):Ze=ce.sibling;var Se=B(M,ce,A[fe],V);if(Se===null){ce===null&&(ce=Ze);break}t&&ce&&Se.alternate===null&&s(M,ce),C=p(Se,C,fe),le===null?ne=Se:le.sibling=Se,le=Se,ce=Ze}if(fe===A.length)return a(M,ce),Oe&&Wn(M,fe),ne;if(ce===null){for(;fe<A.length;fe++)ce=W(M,A[fe],V),ce!==null&&(C=p(ce,C,fe),le===null?ne=ce:le.sibling=ce,le=ce);return Oe&&Wn(M,fe),ne}for(ce=u(M,ce);fe<A.length;fe++)Ze=Y(ce,M,fe,A[fe],V),Ze!==null&&(t&&Ze.alternate!==null&&ce.delete(Ze.key===null?fe:Ze.key),C=p(Ze,C,fe),le===null?ne=Ze:le.sibling=Ze,le=Ze);return t&&ce.forEach(function(An){return s(M,An)}),Oe&&Wn(M,fe),ne}function ee(M,C,A,V){var ne=D(A);if(typeof ne!="function")throw Error(r(150));if(A=ne.call(A),A==null)throw Error(r(151));for(var le=ne=null,ce=C,fe=C=0,Ze=null,Se=A.next();ce!==null&&!Se.done;fe++,Se=A.next()){ce.index>fe?(Ze=ce,ce=null):Ze=ce.sibling;var An=B(M,ce,Se.value,V);if(An===null){ce===null&&(ce=Ze);break}t&&ce&&An.alternate===null&&s(M,ce),C=p(An,C,fe),le===null?ne=An:le.sibling=An,le=An,ce=Ze}if(Se.done)return a(M,ce),Oe&&Wn(M,fe),ne;if(ce===null){for(;!Se.done;fe++,Se=A.next())Se=W(M,Se.value,V),Se!==null&&(C=p(Se,C,fe),le===null?ne=Se:le.sibling=Se,le=Se);return Oe&&Wn(M,fe),ne}for(ce=u(M,ce);!Se.done;fe++,Se=A.next())Se=Y(ce,M,fe,Se.value,V),Se!==null&&(t&&Se.alternate!==null&&ce.delete(Se.key===null?fe:Se.key),C=p(Se,C,fe),le===null?ne=Se:le.sibling=Se,le=Se);return t&&ce.forEach(function(Hg){return s(M,Hg)}),Oe&&Wn(M,fe),ne}function Ue(M,C,A,V){if(typeof A=="object"&&A!==null&&A.type===ie&&A.key===null&&(A=A.props.children),typeof A=="object"&&A!==null){switch(A.$$typeof){case se:e:{for(var ne=A.key,le=C;le!==null;){if(le.key===ne){if(ne=A.type,ne===ie){if(le.tag===7){a(M,le.sibling),C=f(le,A.props.children),C.return=M,M=C;break e}}else if(le.elementType===ne||typeof ne=="object"&&ne!==null&&ne.$$typeof===q&&qu(ne)===le.type){a(M,le.sibling),C=f(le,A.props),C.ref=hi(M,le,A),C.return=M,M=C;break e}a(M,le);break}else s(M,le);le=le.sibling}A.type===ie?(C=Jn(A.props.children,M.mode,V,A.key),C.return=M,M=C):(V=Hr(A.type,A.key,A.props,null,M.mode,V),V.ref=hi(M,C,A),V.return=M,M=V)}return k(M);case F:e:{for(le=A.key;C!==null;){if(C.key===le)if(C.tag===4&&C.stateNode.containerInfo===A.containerInfo&&C.stateNode.implementation===A.implementation){a(M,C.sibling),C=f(C,A.children||[]),C.return=M,M=C;break e}else{a(M,C);break}else s(M,C);C=C.sibling}C=Nl(A,M.mode,V),C.return=M,M=C}return k(M);case q:return le=A._init,Ue(M,C,le(A._payload),V)}if(Us(A))return Z(M,C,A,V);if(D(A))return ee(M,C,A,V);xr(M,A)}return typeof A=="string"&&A!==""||typeof A=="number"?(A=""+A,C!==null&&C.tag===6?(a(M,C.sibling),C=f(C,A),C.return=M,M=C):(a(M,C),C=Sl(A,M.mode,V),C.return=M,M=C),k(M)):a(M,C)}return Ue}var ks=Yu(!0),Ju=Yu(!1),wr=wn(null),jr=null,ys=null,Oa=null;function La(){Oa=ys=jr=null}function Ra(t){var s=wr.current;Ae(wr),t._currentValue=s}function _a(t,s,a){for(;t!==null;){var u=t.alternate;if((t.childLanes&s)!==s?(t.childLanes|=s,u!==null&&(u.childLanes|=s)):u!==null&&(u.childLanes&s)!==s&&(u.childLanes|=s),t===a)break;t=t.return}}function xs(t,s){jr=t,Oa=ys=null,t=t.dependencies,t!==null&&t.firstContext!==null&&((t.lanes&s)!==0&&(pt=!0),t.firstContext=null)}function $t(t){var s=t._currentValue;if(Oa!==t)if(t={context:t,memoizedValue:s,next:null},ys===null){if(jr===null)throw Error(r(308));ys=t,jr.dependencies={lanes:0,firstContext:t}}else ys=ys.next=t;return s}var Hn=null;function Pa(t){Hn===null?Hn=[t]:Hn.push(t)}function Xu(t,s,a,u){var f=s.interleaved;return f===null?(a.next=a,Pa(s)):(a.next=f.next,f.next=a),s.interleaved=a,on(t,u)}function on(t,s){t.lanes|=s;var a=t.alternate;for(a!==null&&(a.lanes|=s),a=t,t=t.return;t!==null;)t.childLanes|=s,a=t.alternate,a!==null&&(a.childLanes|=s),a=t,t=t.return;return a.tag===3?a.stateNode:null}var Nn=!1;function Da(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Zu(t,s){t=t.updateQueue,s.updateQueue===t&&(s.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function an(t,s){return{eventTime:t,lane:s,tag:0,payload:null,callback:null,next:null}}function bn(t,s,a){var u=t.updateQueue;if(u===null)return null;if(u=u.shared,(je&2)!==0){var f=u.pending;return f===null?s.next=s:(s.next=f.next,f.next=s),u.pending=s,on(t,a)}return f=u.interleaved,f===null?(s.next=s,Pa(u)):(s.next=f.next,f.next=s),u.interleaved=s,on(t,a)}function Sr(t,s,a){if(s=s.updateQueue,s!==null&&(s=s.shared,(a&4194240)!==0)){var u=s.lanes;u&=t.pendingLanes,a|=u,s.lanes=a,Xo(t,a)}}function ed(t,s){var a=t.updateQueue,u=t.alternate;if(u!==null&&(u=u.updateQueue,a===u)){var f=null,p=null;if(a=a.firstBaseUpdate,a!==null){do{var k={eventTime:a.eventTime,lane:a.lane,tag:a.tag,payload:a.payload,callback:a.callback,next:null};p===null?f=p=k:p=p.next=k,a=a.next}while(a!==null);p===null?f=p=s:p=p.next=s}else f=p=s;a={baseState:u.baseState,firstBaseUpdate:f,lastBaseUpdate:p,shared:u.shared,effects:u.effects},t.updateQueue=a;return}t=a.lastBaseUpdate,t===null?a.firstBaseUpdate=s:t.next=s,a.lastBaseUpdate=s}function Nr(t,s,a,u){var f=t.updateQueue;Nn=!1;var p=f.firstBaseUpdate,k=f.lastBaseUpdate,S=f.shared.pending;if(S!==null){f.shared.pending=null;var b=S,L=b.next;b.next=null,k===null?p=L:k.next=L,k=b;var z=t.alternate;z!==null&&(z=z.updateQueue,S=z.lastBaseUpdate,S!==k&&(S===null?z.firstBaseUpdate=L:S.next=L,z.lastBaseUpdate=b))}if(p!==null){var W=f.baseState;k=0,z=L=b=null,S=p;do{var B=S.lane,Y=S.eventTime;if((u&B)===B){z!==null&&(z=z.next={eventTime:Y,lane:0,tag:S.tag,payload:S.payload,callback:S.callback,next:null});e:{var Z=t,ee=S;switch(B=s,Y=a,ee.tag){case 1:if(Z=ee.payload,typeof Z=="function"){W=Z.call(Y,W,B);break e}W=Z;break e;case 3:Z.flags=Z.flags&-65537|128;case 0:if(Z=ee.payload,B=typeof Z=="function"?Z.call(Y,W,B):Z,B==null)break e;W=U({},W,B);break e;case 2:Nn=!0}}S.callback!==null&&S.lane!==0&&(t.flags|=64,B=f.effects,B===null?f.effects=[S]:B.push(S))}else Y={eventTime:Y,lane:B,tag:S.tag,payload:S.payload,callback:S.callback,next:null},z===null?(L=z=Y,b=W):z=z.next=Y,k|=B;if(S=S.next,S===null){if(S=f.shared.pending,S===null)break;B=S,S=B.next,B.next=null,f.lastBaseUpdate=B,f.shared.pending=null}}while(!0);if(z===null&&(b=W),f.baseState=b,f.firstBaseUpdate=L,f.lastBaseUpdate=z,s=f.shared.interleaved,s!==null){f=s;do k|=f.lane,f=f.next;while(f!==s)}else p===null&&(f.shared.lanes=0);Gn|=k,t.lanes=k,t.memoizedState=W}}function td(t,s,a){if(t=s.effects,s.effects=null,t!==null)for(s=0;s<t.length;s++){var u=t[s],f=u.callback;if(f!==null){if(u.callback=null,u=a,typeof f!="function")throw Error(r(191,f));f.call(u)}}}var mi={},Ht=wn(mi),pi=wn(mi),gi=wn(mi);function Vn(t){if(t===mi)throw Error(r(174));return t}function Ba(t,s){switch(Me(gi,s),Me(pi,t),Me(Ht,mi),t=s.nodeType,t){case 9:case 11:s=(s=s.documentElement)?s.namespaceURI:zo(null,"");break;default:t=t===8?s.parentNode:s,s=t.namespaceURI||null,t=t.tagName,s=zo(s,t)}Ae(Ht),Me(Ht,s)}function ws(){Ae(Ht),Ae(pi),Ae(gi)}function nd(t){Vn(gi.current);var s=Vn(Ht.current),a=zo(s,t.type);s!==a&&(Me(pi,t),Me(Ht,a))}function za(t){pi.current===t&&(Ae(Ht),Ae(pi))}var Re=wn(0);function br(t){for(var s=t;s!==null;){if(s.tag===13){var a=s.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||a.data==="$?"||a.data==="$!"))return s}else if(s.tag===19&&s.memoizedProps.revealOrder!==void 0){if((s.flags&128)!==0)return s}else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break;for(;s.sibling===null;){if(s.return===null||s.return===t)return null;s=s.return}s.sibling.return=s.return,s=s.sibling}return null}var Fa=[];function Ua(){for(var t=0;t<Fa.length;t++)Fa[t]._workInProgressVersionPrimary=null;Fa.length=0}var Cr=te.ReactCurrentDispatcher,Wa=te.ReactCurrentBatchConfig,Kn=0,_e=null,Ge=null,Je=null,$r=!1,vi=!1,ki=0,fg=0;function rt(){throw Error(r(321))}function Ha(t,s){if(s===null)return!1;for(var a=0;a<s.length&&a<t.length;a++)if(!Lt(t[a],s[a]))return!1;return!0}function Va(t,s,a,u,f,p){if(Kn=p,_e=s,s.memoizedState=null,s.updateQueue=null,s.lanes=0,Cr.current=t===null||t.memoizedState===null?gg:vg,t=a(u,f),vi){p=0;do{if(vi=!1,ki=0,25<=p)throw Error(r(301));p+=1,Je=Ge=null,s.updateQueue=null,Cr.current=kg,t=a(u,f)}while(vi)}if(Cr.current=Mr,s=Ge!==null&&Ge.next!==null,Kn=0,Je=Ge=_e=null,$r=!1,s)throw Error(r(300));return t}function Ka(){var t=ki!==0;return ki=0,t}function Vt(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Je===null?_e.memoizedState=Je=t:Je=Je.next=t,Je}function Tt(){if(Ge===null){var t=_e.alternate;t=t!==null?t.memoizedState:null}else t=Ge.next;var s=Je===null?_e.memoizedState:Je.next;if(s!==null)Je=s,Ge=t;else{if(t===null)throw Error(r(310));Ge=t,t={memoizedState:Ge.memoizedState,baseState:Ge.baseState,baseQueue:Ge.baseQueue,queue:Ge.queue,next:null},Je===null?_e.memoizedState=Je=t:Je=Je.next=t}return Je}function yi(t,s){return typeof s=="function"?s(t):s}function Ga(t){var s=Tt(),a=s.queue;if(a===null)throw Error(r(311));a.lastRenderedReducer=t;var u=Ge,f=u.baseQueue,p=a.pending;if(p!==null){if(f!==null){var k=f.next;f.next=p.next,p.next=k}u.baseQueue=f=p,a.pending=null}if(f!==null){p=f.next,u=u.baseState;var S=k=null,b=null,L=p;do{var z=L.lane;if((Kn&z)===z)b!==null&&(b=b.next={lane:0,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null}),u=L.hasEagerState?L.eagerState:t(u,L.action);else{var W={lane:z,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null};b===null?(S=b=W,k=u):b=b.next=W,_e.lanes|=z,Gn|=z}L=L.next}while(L!==null&&L!==p);b===null?k=u:b.next=S,Lt(u,s.memoizedState)||(pt=!0),s.memoizedState=u,s.baseState=k,s.baseQueue=b,a.lastRenderedState=u}if(t=a.interleaved,t!==null){f=t;do p=f.lane,_e.lanes|=p,Gn|=p,f=f.next;while(f!==t)}else f===null&&(a.lanes=0);return[s.memoizedState,a.dispatch]}function Qa(t){var s=Tt(),a=s.queue;if(a===null)throw Error(r(311));a.lastRenderedReducer=t;var u=a.dispatch,f=a.pending,p=s.memoizedState;if(f!==null){a.pending=null;var k=f=f.next;do p=t(p,k.action),k=k.next;while(k!==f);Lt(p,s.memoizedState)||(pt=!0),s.memoizedState=p,s.baseQueue===null&&(s.baseState=p),a.lastRenderedState=p}return[p,u]}function sd(){}function id(t,s){var a=_e,u=Tt(),f=s(),p=!Lt(u.memoizedState,f);if(p&&(u.memoizedState=f,pt=!0),u=u.queue,qa(ad.bind(null,a,u,t),[t]),u.getSnapshot!==s||p||Je!==null&&Je.memoizedState.tag&1){if(a.flags|=2048,xi(9,od.bind(null,a,u,f,s),void 0,null),Xe===null)throw Error(r(349));(Kn&30)!==0||rd(a,s,f)}return f}function rd(t,s,a){t.flags|=16384,t={getSnapshot:s,value:a},s=_e.updateQueue,s===null?(s={lastEffect:null,stores:null},_e.updateQueue=s,s.stores=[t]):(a=s.stores,a===null?s.stores=[t]:a.push(t))}function od(t,s,a,u){s.value=a,s.getSnapshot=u,ld(s)&&cd(t)}function ad(t,s,a){return a(function(){ld(s)&&cd(t)})}function ld(t){var s=t.getSnapshot;t=t.value;try{var a=s();return!Lt(t,a)}catch{return!0}}function cd(t){var s=on(t,1);s!==null&&Bt(s,t,1,-1)}function ud(t){var s=Vt();return typeof t=="function"&&(t=t()),s.memoizedState=s.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:yi,lastRenderedState:t},s.queue=t,t=t.dispatch=pg.bind(null,_e,t),[s.memoizedState,t]}function xi(t,s,a,u){return t={tag:t,create:s,destroy:a,deps:u,next:null},s=_e.updateQueue,s===null?(s={lastEffect:null,stores:null},_e.updateQueue=s,s.lastEffect=t.next=t):(a=s.lastEffect,a===null?s.lastEffect=t.next=t:(u=a.next,a.next=t,t.next=u,s.lastEffect=t)),t}function dd(){return Tt().memoizedState}function Tr(t,s,a,u){var f=Vt();_e.flags|=t,f.memoizedState=xi(1|s,a,void 0,u===void 0?null:u)}function Er(t,s,a,u){var f=Tt();u=u===void 0?null:u;var p=void 0;if(Ge!==null){var k=Ge.memoizedState;if(p=k.destroy,u!==null&&Ha(u,k.deps)){f.memoizedState=xi(s,a,p,u);return}}_e.flags|=t,f.memoizedState=xi(1|s,a,p,u)}function fd(t,s){return Tr(8390656,8,t,s)}function qa(t,s){return Er(2048,8,t,s)}function hd(t,s){return Er(4,2,t,s)}function md(t,s){return Er(4,4,t,s)}function pd(t,s){if(typeof s=="function")return t=t(),s(t),function(){s(null)};if(s!=null)return t=t(),s.current=t,function(){s.current=null}}function gd(t,s,a){return a=a!=null?a.concat([t]):null,Er(4,4,pd.bind(null,s,t),a)}function Ya(){}function vd(t,s){var a=Tt();s=s===void 0?null:s;var u=a.memoizedState;return u!==null&&s!==null&&Ha(s,u[1])?u[0]:(a.memoizedState=[t,s],t)}function kd(t,s){var a=Tt();s=s===void 0?null:s;var u=a.memoizedState;return u!==null&&s!==null&&Ha(s,u[1])?u[0]:(t=t(),a.memoizedState=[t,s],t)}function yd(t,s,a){return(Kn&21)===0?(t.baseState&&(t.baseState=!1,pt=!0),t.memoizedState=a):(Lt(a,s)||(a=qc(),_e.lanes|=a,Gn|=a,t.baseState=!0),s)}function hg(t,s){var a=be;be=a!==0&&4>a?a:4,t(!0);var u=Wa.transition;Wa.transition={};try{t(!1),s()}finally{be=a,Wa.transition=u}}function xd(){return Tt().memoizedState}function mg(t,s,a){var u=En(t);if(a={lane:u,action:a,hasEagerState:!1,eagerState:null,next:null},wd(t))jd(s,a);else if(a=Xu(t,s,a,u),a!==null){var f=dt();Bt(a,t,u,f),Sd(a,s,u)}}function pg(t,s,a){var u=En(t),f={lane:u,action:a,hasEagerState:!1,eagerState:null,next:null};if(wd(t))jd(s,f);else{var p=t.alternate;if(t.lanes===0&&(p===null||p.lanes===0)&&(p=s.lastRenderedReducer,p!==null))try{var k=s.lastRenderedState,S=p(k,a);if(f.hasEagerState=!0,f.eagerState=S,Lt(S,k)){var b=s.interleaved;b===null?(f.next=f,Pa(s)):(f.next=b.next,b.next=f),s.interleaved=f;return}}catch{}finally{}a=Xu(t,s,f,u),a!==null&&(f=dt(),Bt(a,t,u,f),Sd(a,s,u))}}function wd(t){var s=t.alternate;return t===_e||s!==null&&s===_e}function jd(t,s){vi=$r=!0;var a=t.pending;a===null?s.next=s:(s.next=a.next,a.next=s),t.pending=s}function Sd(t,s,a){if((a&4194240)!==0){var u=s.lanes;u&=t.pendingLanes,a|=u,s.lanes=a,Xo(t,a)}}var Mr={readContext:$t,useCallback:rt,useContext:rt,useEffect:rt,useImperativeHandle:rt,useInsertionEffect:rt,useLayoutEffect:rt,useMemo:rt,useReducer:rt,useRef:rt,useState:rt,useDebugValue:rt,useDeferredValue:rt,useTransition:rt,useMutableSource:rt,useSyncExternalStore:rt,useId:rt,unstable_isNewReconciler:!1},gg={readContext:$t,useCallback:function(t,s){return Vt().memoizedState=[t,s===void 0?null:s],t},useContext:$t,useEffect:fd,useImperativeHandle:function(t,s,a){return a=a!=null?a.concat([t]):null,Tr(4194308,4,pd.bind(null,s,t),a)},useLayoutEffect:function(t,s){return Tr(4194308,4,t,s)},useInsertionEffect:function(t,s){return Tr(4,2,t,s)},useMemo:function(t,s){var a=Vt();return s=s===void 0?null:s,t=t(),a.memoizedState=[t,s],t},useReducer:function(t,s,a){var u=Vt();return s=a!==void 0?a(s):s,u.memoizedState=u.baseState=s,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:s},u.queue=t,t=t.dispatch=mg.bind(null,_e,t),[u.memoizedState,t]},useRef:function(t){var s=Vt();return t={current:t},s.memoizedState=t},useState:ud,useDebugValue:Ya,useDeferredValue:function(t){return Vt().memoizedState=t},useTransition:function(){var t=ud(!1),s=t[0];return t=hg.bind(null,t[1]),Vt().memoizedState=t,[s,t]},useMutableSource:function(){},useSyncExternalStore:function(t,s,a){var u=_e,f=Vt();if(Oe){if(a===void 0)throw Error(r(407));a=a()}else{if(a=s(),Xe===null)throw Error(r(349));(Kn&30)!==0||rd(u,s,a)}f.memoizedState=a;var p={value:a,getSnapshot:s};return f.queue=p,fd(ad.bind(null,u,p,t),[t]),u.flags|=2048,xi(9,od.bind(null,u,p,a,s),void 0,null),a},useId:function(){var t=Vt(),s=Xe.identifierPrefix;if(Oe){var a=rn,u=sn;a=(u&~(1<<32-Ot(u)-1)).toString(32)+a,s=":"+s+"R"+a,a=ki++,0<a&&(s+="H"+a.toString(32)),s+=":"}else a=fg++,s=":"+s+"r"+a.toString(32)+":";return t.memoizedState=s},unstable_isNewReconciler:!1},vg={readContext:$t,useCallback:vd,useContext:$t,useEffect:qa,useImperativeHandle:gd,useInsertionEffect:hd,useLayoutEffect:md,useMemo:kd,useReducer:Ga,useRef:dd,useState:function(){return Ga(yi)},useDebugValue:Ya,useDeferredValue:function(t){var s=Tt();return yd(s,Ge.memoizedState,t)},useTransition:function(){var t=Ga(yi)[0],s=Tt().memoizedState;return[t,s]},useMutableSource:sd,useSyncExternalStore:id,useId:xd,unstable_isNewReconciler:!1},kg={readContext:$t,useCallback:vd,useContext:$t,useEffect:qa,useImperativeHandle:gd,useInsertionEffect:hd,useLayoutEffect:md,useMemo:kd,useReducer:Qa,useRef:dd,useState:function(){return Qa(yi)},useDebugValue:Ya,useDeferredValue:function(t){var s=Tt();return Ge===null?s.memoizedState=t:yd(s,Ge.memoizedState,t)},useTransition:function(){var t=Qa(yi)[0],s=Tt().memoizedState;return[t,s]},useMutableSource:sd,useSyncExternalStore:id,useId:xd,unstable_isNewReconciler:!1};function _t(t,s){if(t&&t.defaultProps){s=U({},s),t=t.defaultProps;for(var a in t)s[a]===void 0&&(s[a]=t[a]);return s}return s}function Ja(t,s,a,u){s=t.memoizedState,a=a(u,s),a=a==null?s:U({},s,a),t.memoizedState=a,t.lanes===0&&(t.updateQueue.baseState=a)}var Ir={isMounted:function(t){return(t=t._reactInternals)?Bn(t)===t:!1},enqueueSetState:function(t,s,a){t=t._reactInternals;var u=dt(),f=En(t),p=an(u,f);p.payload=s,a!=null&&(p.callback=a),s=bn(t,p,f),s!==null&&(Bt(s,t,f,u),Sr(s,t,f))},enqueueReplaceState:function(t,s,a){t=t._reactInternals;var u=dt(),f=En(t),p=an(u,f);p.tag=1,p.payload=s,a!=null&&(p.callback=a),s=bn(t,p,f),s!==null&&(Bt(s,t,f,u),Sr(s,t,f))},enqueueForceUpdate:function(t,s){t=t._reactInternals;var a=dt(),u=En(t),f=an(a,u);f.tag=2,s!=null&&(f.callback=s),s=bn(t,f,u),s!==null&&(Bt(s,t,u,a),Sr(s,t,u))}};function Nd(t,s,a,u,f,p,k){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(u,p,k):s.prototype&&s.prototype.isPureReactComponent?!oi(a,u)||!oi(f,p):!0}function bd(t,s,a){var u=!1,f=jn,p=s.contextType;return typeof p=="object"&&p!==null?p=$t(p):(f=mt(s)?Fn:it.current,u=s.contextTypes,p=(u=u!=null)?ms(t,f):jn),s=new s(a,p),t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,s.updater=Ir,t.stateNode=s,s._reactInternals=t,u&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=f,t.__reactInternalMemoizedMaskedChildContext=p),s}function Cd(t,s,a,u){t=s.state,typeof s.componentWillReceiveProps=="function"&&s.componentWillReceiveProps(a,u),typeof s.UNSAFE_componentWillReceiveProps=="function"&&s.UNSAFE_componentWillReceiveProps(a,u),s.state!==t&&Ir.enqueueReplaceState(s,s.state,null)}function Xa(t,s,a,u){var f=t.stateNode;f.props=a,f.state=t.memoizedState,f.refs={},Da(t);var p=s.contextType;typeof p=="object"&&p!==null?f.context=$t(p):(p=mt(s)?Fn:it.current,f.context=ms(t,p)),f.state=t.memoizedState,p=s.getDerivedStateFromProps,typeof p=="function"&&(Ja(t,s,p,a),f.state=t.memoizedState),typeof s.getDerivedStateFromProps=="function"||typeof f.getSnapshotBeforeUpdate=="function"||typeof f.UNSAFE_componentWillMount!="function"&&typeof f.componentWillMount!="function"||(s=f.state,typeof f.componentWillMount=="function"&&f.componentWillMount(),typeof f.UNSAFE_componentWillMount=="function"&&f.UNSAFE_componentWillMount(),s!==f.state&&Ir.enqueueReplaceState(f,f.state,null),Nr(t,a,f,u),f.state=t.memoizedState),typeof f.componentDidMount=="function"&&(t.flags|=4194308)}function js(t,s){try{var a="",u=s;do a+=de(u),u=u.return;while(u);var f=a}catch(p){f=`
|
|
39
|
+
Error generating stack: `+p.message+`
|
|
40
|
+
`+p.stack}return{value:t,source:s,stack:f,digest:null}}function Za(t,s,a){return{value:t,source:null,stack:a??null,digest:s??null}}function el(t,s){try{console.error(s.value)}catch(a){setTimeout(function(){throw a})}}var yg=typeof WeakMap=="function"?WeakMap:Map;function $d(t,s,a){a=an(-1,a),a.tag=3,a.payload={element:null};var u=s.value;return a.callback=function(){Dr||(Dr=!0,pl=u),el(t,s)},a}function Td(t,s,a){a=an(-1,a),a.tag=3;var u=t.type.getDerivedStateFromError;if(typeof u=="function"){var f=s.value;a.payload=function(){return u(f)},a.callback=function(){el(t,s)}}var p=t.stateNode;return p!==null&&typeof p.componentDidCatch=="function"&&(a.callback=function(){el(t,s),typeof u!="function"&&($n===null?$n=new Set([this]):$n.add(this));var k=s.stack;this.componentDidCatch(s.value,{componentStack:k!==null?k:""})}),a}function Ed(t,s,a){var u=t.pingCache;if(u===null){u=t.pingCache=new yg;var f=new Set;u.set(s,f)}else f=u.get(s),f===void 0&&(f=new Set,u.set(s,f));f.has(a)||(f.add(a),t=Og.bind(null,t,s,a),s.then(t,t))}function Md(t){do{var s;if((s=t.tag===13)&&(s=t.memoizedState,s=s!==null?s.dehydrated!==null:!0),s)return t;t=t.return}while(t!==null);return null}function Id(t,s,a,u,f){return(t.mode&1)===0?(t===s?t.flags|=65536:(t.flags|=128,a.flags|=131072,a.flags&=-52805,a.tag===1&&(a.alternate===null?a.tag=17:(s=an(-1,1),s.tag=2,bn(a,s,1))),a.lanes|=1),t):(t.flags|=65536,t.lanes=f,t)}var xg=te.ReactCurrentOwner,pt=!1;function ut(t,s,a,u){s.child=t===null?Ju(s,null,a,u):ks(s,t.child,a,u)}function Ad(t,s,a,u,f){a=a.render;var p=s.ref;return xs(s,f),u=Va(t,s,a,u,p,f),a=Ka(),t!==null&&!pt?(s.updateQueue=t.updateQueue,s.flags&=-2053,t.lanes&=~f,ln(t,s,f)):(Oe&&a&&Ta(s),s.flags|=1,ut(t,s,u,f),s.child)}function Od(t,s,a,u,f){if(t===null){var p=a.type;return typeof p=="function"&&!jl(p)&&p.defaultProps===void 0&&a.compare===null&&a.defaultProps===void 0?(s.tag=15,s.type=p,Ld(t,s,p,u,f)):(t=Hr(a.type,null,u,s,s.mode,f),t.ref=s.ref,t.return=s,s.child=t)}if(p=t.child,(t.lanes&f)===0){var k=p.memoizedProps;if(a=a.compare,a=a!==null?a:oi,a(k,u)&&t.ref===s.ref)return ln(t,s,f)}return s.flags|=1,t=In(p,u),t.ref=s.ref,t.return=s,s.child=t}function Ld(t,s,a,u,f){if(t!==null){var p=t.memoizedProps;if(oi(p,u)&&t.ref===s.ref)if(pt=!1,s.pendingProps=u=p,(t.lanes&f)!==0)(t.flags&131072)!==0&&(pt=!0);else return s.lanes=t.lanes,ln(t,s,f)}return tl(t,s,a,u,f)}function Rd(t,s,a){var u=s.pendingProps,f=u.children,p=t!==null?t.memoizedState:null;if(u.mode==="hidden")if((s.mode&1)===0)s.memoizedState={baseLanes:0,cachePool:null,transitions:null},Me(Ns,St),St|=a;else{if((a&1073741824)===0)return t=p!==null?p.baseLanes|a:a,s.lanes=s.childLanes=1073741824,s.memoizedState={baseLanes:t,cachePool:null,transitions:null},s.updateQueue=null,Me(Ns,St),St|=t,null;s.memoizedState={baseLanes:0,cachePool:null,transitions:null},u=p!==null?p.baseLanes:a,Me(Ns,St),St|=u}else p!==null?(u=p.baseLanes|a,s.memoizedState=null):u=a,Me(Ns,St),St|=u;return ut(t,s,f,a),s.child}function _d(t,s){var a=s.ref;(t===null&&a!==null||t!==null&&t.ref!==a)&&(s.flags|=512,s.flags|=2097152)}function tl(t,s,a,u,f){var p=mt(a)?Fn:it.current;return p=ms(s,p),xs(s,f),a=Va(t,s,a,u,p,f),u=Ka(),t!==null&&!pt?(s.updateQueue=t.updateQueue,s.flags&=-2053,t.lanes&=~f,ln(t,s,f)):(Oe&&u&&Ta(s),s.flags|=1,ut(t,s,a,f),s.child)}function Pd(t,s,a,u,f){if(mt(a)){var p=!0;pr(s)}else p=!1;if(xs(s,f),s.stateNode===null)Or(t,s),bd(s,a,u),Xa(s,a,u,f),u=!0;else if(t===null){var k=s.stateNode,S=s.memoizedProps;k.props=S;var b=k.context,L=a.contextType;typeof L=="object"&&L!==null?L=$t(L):(L=mt(a)?Fn:it.current,L=ms(s,L));var z=a.getDerivedStateFromProps,W=typeof z=="function"||typeof k.getSnapshotBeforeUpdate=="function";W||typeof k.UNSAFE_componentWillReceiveProps!="function"&&typeof k.componentWillReceiveProps!="function"||(S!==u||b!==L)&&Cd(s,k,u,L),Nn=!1;var B=s.memoizedState;k.state=B,Nr(s,u,k,f),b=s.memoizedState,S!==u||B!==b||ht.current||Nn?(typeof z=="function"&&(Ja(s,a,z,u),b=s.memoizedState),(S=Nn||Nd(s,a,S,u,B,b,L))?(W||typeof k.UNSAFE_componentWillMount!="function"&&typeof k.componentWillMount!="function"||(typeof k.componentWillMount=="function"&&k.componentWillMount(),typeof k.UNSAFE_componentWillMount=="function"&&k.UNSAFE_componentWillMount()),typeof k.componentDidMount=="function"&&(s.flags|=4194308)):(typeof k.componentDidMount=="function"&&(s.flags|=4194308),s.memoizedProps=u,s.memoizedState=b),k.props=u,k.state=b,k.context=L,u=S):(typeof k.componentDidMount=="function"&&(s.flags|=4194308),u=!1)}else{k=s.stateNode,Zu(t,s),S=s.memoizedProps,L=s.type===s.elementType?S:_t(s.type,S),k.props=L,W=s.pendingProps,B=k.context,b=a.contextType,typeof b=="object"&&b!==null?b=$t(b):(b=mt(a)?Fn:it.current,b=ms(s,b));var Y=a.getDerivedStateFromProps;(z=typeof Y=="function"||typeof k.getSnapshotBeforeUpdate=="function")||typeof k.UNSAFE_componentWillReceiveProps!="function"&&typeof k.componentWillReceiveProps!="function"||(S!==W||B!==b)&&Cd(s,k,u,b),Nn=!1,B=s.memoizedState,k.state=B,Nr(s,u,k,f);var Z=s.memoizedState;S!==W||B!==Z||ht.current||Nn?(typeof Y=="function"&&(Ja(s,a,Y,u),Z=s.memoizedState),(L=Nn||Nd(s,a,L,u,B,Z,b)||!1)?(z||typeof k.UNSAFE_componentWillUpdate!="function"&&typeof k.componentWillUpdate!="function"||(typeof k.componentWillUpdate=="function"&&k.componentWillUpdate(u,Z,b),typeof k.UNSAFE_componentWillUpdate=="function"&&k.UNSAFE_componentWillUpdate(u,Z,b)),typeof k.componentDidUpdate=="function"&&(s.flags|=4),typeof k.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof k.componentDidUpdate!="function"||S===t.memoizedProps&&B===t.memoizedState||(s.flags|=4),typeof k.getSnapshotBeforeUpdate!="function"||S===t.memoizedProps&&B===t.memoizedState||(s.flags|=1024),s.memoizedProps=u,s.memoizedState=Z),k.props=u,k.state=Z,k.context=b,u=L):(typeof k.componentDidUpdate!="function"||S===t.memoizedProps&&B===t.memoizedState||(s.flags|=4),typeof k.getSnapshotBeforeUpdate!="function"||S===t.memoizedProps&&B===t.memoizedState||(s.flags|=1024),u=!1)}return nl(t,s,a,u,p,f)}function nl(t,s,a,u,f,p){_d(t,s);var k=(s.flags&128)!==0;if(!u&&!k)return f&&Uu(s,a,!1),ln(t,s,p);u=s.stateNode,xg.current=s;var S=k&&typeof a.getDerivedStateFromError!="function"?null:u.render();return s.flags|=1,t!==null&&k?(s.child=ks(s,t.child,null,p),s.child=ks(s,null,S,p)):ut(t,s,S,p),s.memoizedState=u.state,f&&Uu(s,a,!0),s.child}function Dd(t){var s=t.stateNode;s.pendingContext?zu(t,s.pendingContext,s.pendingContext!==s.context):s.context&&zu(t,s.context,!1),Ba(t,s.containerInfo)}function Bd(t,s,a,u,f){return vs(),Aa(f),s.flags|=256,ut(t,s,a,u),s.child}var sl={dehydrated:null,treeContext:null,retryLane:0};function il(t){return{baseLanes:t,cachePool:null,transitions:null}}function zd(t,s,a){var u=s.pendingProps,f=Re.current,p=!1,k=(s.flags&128)!==0,S;if((S=k)||(S=t!==null&&t.memoizedState===null?!1:(f&2)!==0),S?(p=!0,s.flags&=-129):(t===null||t.memoizedState!==null)&&(f|=1),Me(Re,f&1),t===null)return Ia(s),t=s.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?((s.mode&1)===0?s.lanes=1:t.data==="$!"?s.lanes=8:s.lanes=1073741824,null):(k=u.children,t=u.fallback,p?(u=s.mode,p=s.child,k={mode:"hidden",children:k},(u&1)===0&&p!==null?(p.childLanes=0,p.pendingProps=k):p=Vr(k,u,0,null),t=Jn(t,u,a,null),p.return=s,t.return=s,p.sibling=t,s.child=p,s.child.memoizedState=il(a),s.memoizedState=sl,t):rl(s,k));if(f=t.memoizedState,f!==null&&(S=f.dehydrated,S!==null))return wg(t,s,k,u,S,f,a);if(p){p=u.fallback,k=s.mode,f=t.child,S=f.sibling;var b={mode:"hidden",children:u.children};return(k&1)===0&&s.child!==f?(u=s.child,u.childLanes=0,u.pendingProps=b,s.deletions=null):(u=In(f,b),u.subtreeFlags=f.subtreeFlags&14680064),S!==null?p=In(S,p):(p=Jn(p,k,a,null),p.flags|=2),p.return=s,u.return=s,u.sibling=p,s.child=u,u=p,p=s.child,k=t.child.memoizedState,k=k===null?il(a):{baseLanes:k.baseLanes|a,cachePool:null,transitions:k.transitions},p.memoizedState=k,p.childLanes=t.childLanes&~a,s.memoizedState=sl,u}return p=t.child,t=p.sibling,u=In(p,{mode:"visible",children:u.children}),(s.mode&1)===0&&(u.lanes=a),u.return=s,u.sibling=null,t!==null&&(a=s.deletions,a===null?(s.deletions=[t],s.flags|=16):a.push(t)),s.child=u,s.memoizedState=null,u}function rl(t,s){return s=Vr({mode:"visible",children:s},t.mode,0,null),s.return=t,t.child=s}function Ar(t,s,a,u){return u!==null&&Aa(u),ks(s,t.child,null,a),t=rl(s,s.pendingProps.children),t.flags|=2,s.memoizedState=null,t}function wg(t,s,a,u,f,p,k){if(a)return s.flags&256?(s.flags&=-257,u=Za(Error(r(422))),Ar(t,s,k,u)):s.memoizedState!==null?(s.child=t.child,s.flags|=128,null):(p=u.fallback,f=s.mode,u=Vr({mode:"visible",children:u.children},f,0,null),p=Jn(p,f,k,null),p.flags|=2,u.return=s,p.return=s,u.sibling=p,s.child=u,(s.mode&1)!==0&&ks(s,t.child,null,k),s.child.memoizedState=il(k),s.memoizedState=sl,p);if((s.mode&1)===0)return Ar(t,s,k,null);if(f.data==="$!"){if(u=f.nextSibling&&f.nextSibling.dataset,u)var S=u.dgst;return u=S,p=Error(r(419)),u=Za(p,u,void 0),Ar(t,s,k,u)}if(S=(k&t.childLanes)!==0,pt||S){if(u=Xe,u!==null){switch(k&-k){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|k))!==0?0:f,f!==0&&f!==p.retryLane&&(p.retryLane=f,on(t,f),Bt(u,t,f,-1))}return wl(),u=Za(Error(r(421))),Ar(t,s,k,u)}return f.data==="$?"?(s.flags|=128,s.child=t.child,s=Lg.bind(null,t),f._reactRetry=s,null):(t=p.treeContext,jt=xn(f.nextSibling),wt=s,Oe=!0,Rt=null,t!==null&&(bt[Ct++]=sn,bt[Ct++]=rn,bt[Ct++]=Un,sn=t.id,rn=t.overflow,Un=s),s=rl(s,u.children),s.flags|=4096,s)}function Fd(t,s,a){t.lanes|=s;var u=t.alternate;u!==null&&(u.lanes|=s),_a(t.return,s,a)}function ol(t,s,a,u,f){var p=t.memoizedState;p===null?t.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:u,tail:a,tailMode:f}:(p.isBackwards=s,p.rendering=null,p.renderingStartTime=0,p.last=u,p.tail=a,p.tailMode=f)}function Ud(t,s,a){var u=s.pendingProps,f=u.revealOrder,p=u.tail;if(ut(t,s,u.children,a),u=Re.current,(u&2)!==0)u=u&1|2,s.flags|=128;else{if(t!==null&&(t.flags&128)!==0)e:for(t=s.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&Fd(t,a,s);else if(t.tag===19)Fd(t,a,s);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===s)break e;for(;t.sibling===null;){if(t.return===null||t.return===s)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}u&=1}if(Me(Re,u),(s.mode&1)===0)s.memoizedState=null;else switch(f){case"forwards":for(a=s.child,f=null;a!==null;)t=a.alternate,t!==null&&br(t)===null&&(f=a),a=a.sibling;a=f,a===null?(f=s.child,s.child=null):(f=a.sibling,a.sibling=null),ol(s,!1,f,a,p);break;case"backwards":for(a=null,f=s.child,s.child=null;f!==null;){if(t=f.alternate,t!==null&&br(t)===null){s.child=f;break}t=f.sibling,f.sibling=a,a=f,f=t}ol(s,!0,a,null,p);break;case"together":ol(s,!1,null,null,void 0);break;default:s.memoizedState=null}return s.child}function Or(t,s){(s.mode&1)===0&&t!==null&&(t.alternate=null,s.alternate=null,s.flags|=2)}function ln(t,s,a){if(t!==null&&(s.dependencies=t.dependencies),Gn|=s.lanes,(a&s.childLanes)===0)return null;if(t!==null&&s.child!==t.child)throw Error(r(153));if(s.child!==null){for(t=s.child,a=In(t,t.pendingProps),s.child=a,a.return=s;t.sibling!==null;)t=t.sibling,a=a.sibling=In(t,t.pendingProps),a.return=s;a.sibling=null}return s.child}function jg(t,s,a){switch(s.tag){case 3:Dd(s),vs();break;case 5:nd(s);break;case 1:mt(s.type)&&pr(s);break;case 4:Ba(s,s.stateNode.containerInfo);break;case 10:var u=s.type._context,f=s.memoizedProps.value;Me(wr,u._currentValue),u._currentValue=f;break;case 13:if(u=s.memoizedState,u!==null)return u.dehydrated!==null?(Me(Re,Re.current&1),s.flags|=128,null):(a&s.child.childLanes)!==0?zd(t,s,a):(Me(Re,Re.current&1),t=ln(t,s,a),t!==null?t.sibling:null);Me(Re,Re.current&1);break;case 19:if(u=(a&s.childLanes)!==0,(t.flags&128)!==0){if(u)return Ud(t,s,a);s.flags|=128}if(f=s.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),Me(Re,Re.current),u)break;return null;case 22:case 23:return s.lanes=0,Rd(t,s,a)}return ln(t,s,a)}var Wd,al,Hd,Vd;Wd=function(t,s){for(var a=s.child;a!==null;){if(a.tag===5||a.tag===6)t.appendChild(a.stateNode);else if(a.tag!==4&&a.child!==null){a.child.return=a,a=a.child;continue}if(a===s)break;for(;a.sibling===null;){if(a.return===null||a.return===s)return;a=a.return}a.sibling.return=a.return,a=a.sibling}},al=function(){},Hd=function(t,s,a,u){var f=t.memoizedProps;if(f!==u){t=s.stateNode,Vn(Ht.current);var p=null;switch(a){case"input":f=_o(t,f),u=_o(t,u),p=[];break;case"select":f=U({},f,{value:void 0}),u=U({},u,{value:void 0}),p=[];break;case"textarea":f=Bo(t,f),u=Bo(t,u),p=[];break;default:typeof f.onClick!="function"&&typeof u.onClick=="function"&&(t.onclick=fr)}Fo(a,u);var k;a=null;for(L in f)if(!u.hasOwnProperty(L)&&f.hasOwnProperty(L)&&f[L]!=null)if(L==="style"){var S=f[L];for(k in S)S.hasOwnProperty(k)&&(a||(a={}),a[k]="")}else L!=="dangerouslySetInnerHTML"&&L!=="children"&&L!=="suppressContentEditableWarning"&&L!=="suppressHydrationWarning"&&L!=="autoFocus"&&(l.hasOwnProperty(L)?p||(p=[]):(p=p||[]).push(L,null));for(L in u){var b=u[L];if(S=f!=null?f[L]:void 0,u.hasOwnProperty(L)&&b!==S&&(b!=null||S!=null))if(L==="style")if(S){for(k in S)!S.hasOwnProperty(k)||b&&b.hasOwnProperty(k)||(a||(a={}),a[k]="");for(k in b)b.hasOwnProperty(k)&&S[k]!==b[k]&&(a||(a={}),a[k]=b[k])}else a||(p||(p=[]),p.push(L,a)),a=b;else L==="dangerouslySetInnerHTML"?(b=b?b.__html:void 0,S=S?S.__html:void 0,b!=null&&S!==b&&(p=p||[]).push(L,b)):L==="children"?typeof b!="string"&&typeof b!="number"||(p=p||[]).push(L,""+b):L!=="suppressContentEditableWarning"&&L!=="suppressHydrationWarning"&&(l.hasOwnProperty(L)?(b!=null&&L==="onScroll"&&Ie("scroll",t),p||S===b||(p=[])):(p=p||[]).push(L,b))}a&&(p=p||[]).push("style",a);var L=p;(s.updateQueue=L)&&(s.flags|=4)}},Vd=function(t,s,a,u){a!==u&&(s.flags|=4)};function wi(t,s){if(!Oe)switch(t.tailMode){case"hidden":s=t.tail;for(var a=null;s!==null;)s.alternate!==null&&(a=s),s=s.sibling;a===null?t.tail=null:a.sibling=null;break;case"collapsed":a=t.tail;for(var u=null;a!==null;)a.alternate!==null&&(u=a),a=a.sibling;u===null?s||t.tail===null?t.tail=null:t.tail.sibling=null:u.sibling=null}}function ot(t){var s=t.alternate!==null&&t.alternate.child===t.child,a=0,u=0;if(s)for(var f=t.child;f!==null;)a|=f.lanes|f.childLanes,u|=f.subtreeFlags&14680064,u|=f.flags&14680064,f.return=t,f=f.sibling;else for(f=t.child;f!==null;)a|=f.lanes|f.childLanes,u|=f.subtreeFlags,u|=f.flags,f.return=t,f=f.sibling;return t.subtreeFlags|=u,t.childLanes=a,s}function Sg(t,s,a){var u=s.pendingProps;switch(Ea(s),s.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ot(s),null;case 1:return mt(s.type)&&mr(),ot(s),null;case 3:return u=s.stateNode,ws(),Ae(ht),Ae(it),Ua(),u.pendingContext&&(u.context=u.pendingContext,u.pendingContext=null),(t===null||t.child===null)&&(yr(s)?s.flags|=4:t===null||t.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,Rt!==null&&(kl(Rt),Rt=null))),al(t,s),ot(s),null;case 5:za(s);var f=Vn(gi.current);if(a=s.type,t!==null&&s.stateNode!=null)Hd(t,s,a,u,f),t.ref!==s.ref&&(s.flags|=512,s.flags|=2097152);else{if(!u){if(s.stateNode===null)throw Error(r(166));return ot(s),null}if(t=Vn(Ht.current),yr(s)){u=s.stateNode,a=s.type;var p=s.memoizedProps;switch(u[Wt]=s,u[di]=p,t=(s.mode&1)!==0,a){case"dialog":Ie("cancel",u),Ie("close",u);break;case"iframe":case"object":case"embed":Ie("load",u);break;case"video":case"audio":for(f=0;f<li.length;f++)Ie(li[f],u);break;case"source":Ie("error",u);break;case"img":case"image":case"link":Ie("error",u),Ie("load",u);break;case"details":Ie("toggle",u);break;case"input":bc(u,p),Ie("invalid",u);break;case"select":u._wrapperState={wasMultiple:!!p.multiple},Ie("invalid",u);break;case"textarea":Tc(u,p),Ie("invalid",u)}Fo(a,p),f=null;for(var k in p)if(p.hasOwnProperty(k)){var S=p[k];k==="children"?typeof S=="string"?u.textContent!==S&&(p.suppressHydrationWarning!==!0&&dr(u.textContent,S,t),f=["children",S]):typeof S=="number"&&u.textContent!==""+S&&(p.suppressHydrationWarning!==!0&&dr(u.textContent,S,t),f=["children",""+S]):l.hasOwnProperty(k)&&S!=null&&k==="onScroll"&&Ie("scroll",u)}switch(a){case"input":ts(u),$c(u,p,!0);break;case"textarea":ts(u),Mc(u);break;case"select":case"option":break;default:typeof p.onClick=="function"&&(u.onclick=fr)}u=f,s.updateQueue=u,u!==null&&(s.flags|=4)}else{k=f.nodeType===9?f:f.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=Ic(a)),t==="http://www.w3.org/1999/xhtml"?a==="script"?(t=k.createElement("div"),t.innerHTML="<script><\/script>",t=t.removeChild(t.firstChild)):typeof u.is=="string"?t=k.createElement(a,{is:u.is}):(t=k.createElement(a),a==="select"&&(k=t,u.multiple?k.multiple=!0:u.size&&(k.size=u.size))):t=k.createElementNS(t,a),t[Wt]=s,t[di]=u,Wd(t,s,!1,!1),s.stateNode=t;e:{switch(k=Uo(a,u),a){case"dialog":Ie("cancel",t),Ie("close",t),f=u;break;case"iframe":case"object":case"embed":Ie("load",t),f=u;break;case"video":case"audio":for(f=0;f<li.length;f++)Ie(li[f],t);f=u;break;case"source":Ie("error",t),f=u;break;case"img":case"image":case"link":Ie("error",t),Ie("load",t),f=u;break;case"details":Ie("toggle",t),f=u;break;case"input":bc(t,u),f=_o(t,u),Ie("invalid",t);break;case"option":f=u;break;case"select":t._wrapperState={wasMultiple:!!u.multiple},f=U({},u,{value:void 0}),Ie("invalid",t);break;case"textarea":Tc(t,u),f=Bo(t,u),Ie("invalid",t);break;default:f=u}Fo(a,f),S=f;for(p in S)if(S.hasOwnProperty(p)){var b=S[p];p==="style"?Lc(t,b):p==="dangerouslySetInnerHTML"?(b=b?b.__html:void 0,b!=null&&Ac(t,b)):p==="children"?typeof b=="string"?(a!=="textarea"||b!=="")&&Ws(t,b):typeof b=="number"&&Ws(t,""+b):p!=="suppressContentEditableWarning"&&p!=="suppressHydrationWarning"&&p!=="autoFocus"&&(l.hasOwnProperty(p)?b!=null&&p==="onScroll"&&Ie("scroll",t):b!=null&&O(t,p,b,k))}switch(a){case"input":ts(t),$c(t,u,!1);break;case"textarea":ts(t),Mc(t);break;case"option":u.value!=null&&t.setAttribute("value",""+ke(u.value));break;case"select":t.multiple=!!u.multiple,p=u.value,p!=null?ns(t,!!u.multiple,p,!1):u.defaultValue!=null&&ns(t,!!u.multiple,u.defaultValue,!0);break;default:typeof f.onClick=="function"&&(t.onclick=fr)}switch(a){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}}u&&(s.flags|=4)}s.ref!==null&&(s.flags|=512,s.flags|=2097152)}return ot(s),null;case 6:if(t&&s.stateNode!=null)Vd(t,s,t.memoizedProps,u);else{if(typeof u!="string"&&s.stateNode===null)throw Error(r(166));if(a=Vn(gi.current),Vn(Ht.current),yr(s)){if(u=s.stateNode,a=s.memoizedProps,u[Wt]=s,(p=u.nodeValue!==a)&&(t=wt,t!==null))switch(t.tag){case 3:dr(u.nodeValue,a,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&dr(u.nodeValue,a,(t.mode&1)!==0)}p&&(s.flags|=4)}else u=(a.nodeType===9?a:a.ownerDocument).createTextNode(u),u[Wt]=s,s.stateNode=u}return ot(s),null;case 13:if(Ae(Re),u=s.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(Oe&&jt!==null&&(s.mode&1)!==0&&(s.flags&128)===0)Qu(),vs(),s.flags|=98560,p=!1;else if(p=yr(s),u!==null&&u.dehydrated!==null){if(t===null){if(!p)throw Error(r(318));if(p=s.memoizedState,p=p!==null?p.dehydrated:null,!p)throw Error(r(317));p[Wt]=s}else vs(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;ot(s),p=!1}else Rt!==null&&(kl(Rt),Rt=null),p=!0;if(!p)return s.flags&65536?s:null}return(s.flags&128)!==0?(s.lanes=a,s):(u=u!==null,u!==(t!==null&&t.memoizedState!==null)&&u&&(s.child.flags|=8192,(s.mode&1)!==0&&(t===null||(Re.current&1)!==0?Qe===0&&(Qe=3):wl())),s.updateQueue!==null&&(s.flags|=4),ot(s),null);case 4:return ws(),al(t,s),t===null&&ci(s.stateNode.containerInfo),ot(s),null;case 10:return Ra(s.type._context),ot(s),null;case 17:return mt(s.type)&&mr(),ot(s),null;case 19:if(Ae(Re),p=s.memoizedState,p===null)return ot(s),null;if(u=(s.flags&128)!==0,k=p.rendering,k===null)if(u)wi(p,!1);else{if(Qe!==0||t!==null&&(t.flags&128)!==0)for(t=s.child;t!==null;){if(k=br(t),k!==null){for(s.flags|=128,wi(p,!1),u=k.updateQueue,u!==null&&(s.updateQueue=u,s.flags|=4),s.subtreeFlags=0,u=a,a=s.child;a!==null;)p=a,t=u,p.flags&=14680066,k=p.alternate,k===null?(p.childLanes=0,p.lanes=t,p.child=null,p.subtreeFlags=0,p.memoizedProps=null,p.memoizedState=null,p.updateQueue=null,p.dependencies=null,p.stateNode=null):(p.childLanes=k.childLanes,p.lanes=k.lanes,p.child=k.child,p.subtreeFlags=0,p.deletions=null,p.memoizedProps=k.memoizedProps,p.memoizedState=k.memoizedState,p.updateQueue=k.updateQueue,p.type=k.type,t=k.dependencies,p.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),a=a.sibling;return Me(Re,Re.current&1|2),s.child}t=t.sibling}p.tail!==null&&Fe()>bs&&(s.flags|=128,u=!0,wi(p,!1),s.lanes=4194304)}else{if(!u)if(t=br(k),t!==null){if(s.flags|=128,u=!0,a=t.updateQueue,a!==null&&(s.updateQueue=a,s.flags|=4),wi(p,!0),p.tail===null&&p.tailMode==="hidden"&&!k.alternate&&!Oe)return ot(s),null}else 2*Fe()-p.renderingStartTime>bs&&a!==1073741824&&(s.flags|=128,u=!0,wi(p,!1),s.lanes=4194304);p.isBackwards?(k.sibling=s.child,s.child=k):(a=p.last,a!==null?a.sibling=k:s.child=k,p.last=k)}return p.tail!==null?(s=p.tail,p.rendering=s,p.tail=s.sibling,p.renderingStartTime=Fe(),s.sibling=null,a=Re.current,Me(Re,u?a&1|2:a&1),s):(ot(s),null);case 22:case 23:return xl(),u=s.memoizedState!==null,t!==null&&t.memoizedState!==null!==u&&(s.flags|=8192),u&&(s.mode&1)!==0?(St&1073741824)!==0&&(ot(s),s.subtreeFlags&6&&(s.flags|=8192)):ot(s),null;case 24:return null;case 25:return null}throw Error(r(156,s.tag))}function Ng(t,s){switch(Ea(s),s.tag){case 1:return mt(s.type)&&mr(),t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 3:return ws(),Ae(ht),Ae(it),Ua(),t=s.flags,(t&65536)!==0&&(t&128)===0?(s.flags=t&-65537|128,s):null;case 5:return za(s),null;case 13:if(Ae(Re),t=s.memoizedState,t!==null&&t.dehydrated!==null){if(s.alternate===null)throw Error(r(340));vs()}return t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 19:return Ae(Re),null;case 4:return ws(),null;case 10:return Ra(s.type._context),null;case 22:case 23:return xl(),null;case 24:return null;default:return null}}var Lr=!1,at=!1,bg=typeof WeakSet=="function"?WeakSet:Set,J=null;function Ss(t,s){var a=t.ref;if(a!==null)if(typeof a=="function")try{a(null)}catch(u){Pe(t,s,u)}else a.current=null}function ll(t,s,a){try{a()}catch(u){Pe(t,s,u)}}var Kd=!1;function Cg(t,s){if(xa=er,t=Nu(),fa(t)){if("selectionStart"in t)var a={start:t.selectionStart,end:t.selectionEnd};else e:{a=(a=t.ownerDocument)&&a.defaultView||window;var u=a.getSelection&&a.getSelection();if(u&&u.rangeCount!==0){a=u.anchorNode;var f=u.anchorOffset,p=u.focusNode;u=u.focusOffset;try{a.nodeType,p.nodeType}catch{a=null;break e}var k=0,S=-1,b=-1,L=0,z=0,W=t,B=null;t:for(;;){for(var Y;W!==a||f!==0&&W.nodeType!==3||(S=k+f),W!==p||u!==0&&W.nodeType!==3||(b=k+u),W.nodeType===3&&(k+=W.nodeValue.length),(Y=W.firstChild)!==null;)B=W,W=Y;for(;;){if(W===t)break t;if(B===a&&++L===f&&(S=k),B===p&&++z===u&&(b=k),(Y=W.nextSibling)!==null)break;W=B,B=W.parentNode}W=Y}a=S===-1||b===-1?null:{start:S,end:b}}else a=null}a=a||{start:0,end:0}}else a=null;for(wa={focusedElem:t,selectionRange:a},er=!1,J=s;J!==null;)if(s=J,t=s.child,(s.subtreeFlags&1028)!==0&&t!==null)t.return=s,J=t;else for(;J!==null;){s=J;try{var Z=s.alternate;if((s.flags&1024)!==0)switch(s.tag){case 0:case 11:case 15:break;case 1:if(Z!==null){var ee=Z.memoizedProps,Ue=Z.memoizedState,M=s.stateNode,C=M.getSnapshotBeforeUpdate(s.elementType===s.type?ee:_t(s.type,ee),Ue);M.__reactInternalSnapshotBeforeUpdate=C}break;case 3:var A=s.stateNode.containerInfo;A.nodeType===1?A.textContent="":A.nodeType===9&&A.documentElement&&A.removeChild(A.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(V){Pe(s,s.return,V)}if(t=s.sibling,t!==null){t.return=s.return,J=t;break}J=s.return}return Z=Kd,Kd=!1,Z}function ji(t,s,a){var u=s.updateQueue;if(u=u!==null?u.lastEffect:null,u!==null){var f=u=u.next;do{if((f.tag&t)===t){var p=f.destroy;f.destroy=void 0,p!==void 0&&ll(s,a,p)}f=f.next}while(f!==u)}}function Rr(t,s){if(s=s.updateQueue,s=s!==null?s.lastEffect:null,s!==null){var a=s=s.next;do{if((a.tag&t)===t){var u=a.create;a.destroy=u()}a=a.next}while(a!==s)}}function cl(t){var s=t.ref;if(s!==null){var a=t.stateNode;switch(t.tag){case 5:t=a;break;default:t=a}typeof s=="function"?s(t):s.current=t}}function Gd(t){var s=t.alternate;s!==null&&(t.alternate=null,Gd(s)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(s=t.stateNode,s!==null&&(delete s[Wt],delete s[di],delete s[ba],delete s[lg],delete s[cg])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function Qd(t){return t.tag===5||t.tag===3||t.tag===4}function qd(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||Qd(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function ul(t,s,a){var u=t.tag;if(u===5||u===6)t=t.stateNode,s?a.nodeType===8?a.parentNode.insertBefore(t,s):a.insertBefore(t,s):(a.nodeType===8?(s=a.parentNode,s.insertBefore(t,a)):(s=a,s.appendChild(t)),a=a._reactRootContainer,a!=null||s.onclick!==null||(s.onclick=fr));else if(u!==4&&(t=t.child,t!==null))for(ul(t,s,a),t=t.sibling;t!==null;)ul(t,s,a),t=t.sibling}function dl(t,s,a){var u=t.tag;if(u===5||u===6)t=t.stateNode,s?a.insertBefore(t,s):a.appendChild(t);else if(u!==4&&(t=t.child,t!==null))for(dl(t,s,a),t=t.sibling;t!==null;)dl(t,s,a),t=t.sibling}var nt=null,Pt=!1;function Cn(t,s,a){for(a=a.child;a!==null;)Yd(t,s,a),a=a.sibling}function Yd(t,s,a){if(Ut&&typeof Ut.onCommitFiberUnmount=="function")try{Ut.onCommitFiberUnmount(Qi,a)}catch{}switch(a.tag){case 5:at||Ss(a,s);case 6:var u=nt,f=Pt;nt=null,Cn(t,s,a),nt=u,Pt=f,nt!==null&&(Pt?(t=nt,a=a.stateNode,t.nodeType===8?t.parentNode.removeChild(a):t.removeChild(a)):nt.removeChild(a.stateNode));break;case 18:nt!==null&&(Pt?(t=nt,a=a.stateNode,t.nodeType===8?Na(t.parentNode,a):t.nodeType===1&&Na(t,a),ei(t)):Na(nt,a.stateNode));break;case 4:u=nt,f=Pt,nt=a.stateNode.containerInfo,Pt=!0,Cn(t,s,a),nt=u,Pt=f;break;case 0:case 11:case 14:case 15:if(!at&&(u=a.updateQueue,u!==null&&(u=u.lastEffect,u!==null))){f=u=u.next;do{var p=f,k=p.destroy;p=p.tag,k!==void 0&&((p&2)!==0||(p&4)!==0)&&ll(a,s,k),f=f.next}while(f!==u)}Cn(t,s,a);break;case 1:if(!at&&(Ss(a,s),u=a.stateNode,typeof u.componentWillUnmount=="function"))try{u.props=a.memoizedProps,u.state=a.memoizedState,u.componentWillUnmount()}catch(S){Pe(a,s,S)}Cn(t,s,a);break;case 21:Cn(t,s,a);break;case 22:a.mode&1?(at=(u=at)||a.memoizedState!==null,Cn(t,s,a),at=u):Cn(t,s,a);break;default:Cn(t,s,a)}}function Jd(t){var s=t.updateQueue;if(s!==null){t.updateQueue=null;var a=t.stateNode;a===null&&(a=t.stateNode=new bg),s.forEach(function(u){var f=Rg.bind(null,t,u);a.has(u)||(a.add(u),u.then(f,f))})}}function Dt(t,s){var a=s.deletions;if(a!==null)for(var u=0;u<a.length;u++){var f=a[u];try{var p=t,k=s,S=k;e:for(;S!==null;){switch(S.tag){case 5:nt=S.stateNode,Pt=!1;break e;case 3:nt=S.stateNode.containerInfo,Pt=!0;break e;case 4:nt=S.stateNode.containerInfo,Pt=!0;break e}S=S.return}if(nt===null)throw Error(r(160));Yd(p,k,f),nt=null,Pt=!1;var b=f.alternate;b!==null&&(b.return=null),f.return=null}catch(L){Pe(f,s,L)}}if(s.subtreeFlags&12854)for(s=s.child;s!==null;)Xd(s,t),s=s.sibling}function Xd(t,s){var a=t.alternate,u=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(Dt(s,t),Kt(t),u&4){try{ji(3,t,t.return),Rr(3,t)}catch(ee){Pe(t,t.return,ee)}try{ji(5,t,t.return)}catch(ee){Pe(t,t.return,ee)}}break;case 1:Dt(s,t),Kt(t),u&512&&a!==null&&Ss(a,a.return);break;case 5:if(Dt(s,t),Kt(t),u&512&&a!==null&&Ss(a,a.return),t.flags&32){var f=t.stateNode;try{Ws(f,"")}catch(ee){Pe(t,t.return,ee)}}if(u&4&&(f=t.stateNode,f!=null)){var p=t.memoizedProps,k=a!==null?a.memoizedProps:p,S=t.type,b=t.updateQueue;if(t.updateQueue=null,b!==null)try{S==="input"&&p.type==="radio"&&p.name!=null&&Cc(f,p),Uo(S,k);var L=Uo(S,p);for(k=0;k<b.length;k+=2){var z=b[k],W=b[k+1];z==="style"?Lc(f,W):z==="dangerouslySetInnerHTML"?Ac(f,W):z==="children"?Ws(f,W):O(f,z,W,L)}switch(S){case"input":Po(f,p);break;case"textarea":Ec(f,p);break;case"select":var B=f._wrapperState.wasMultiple;f._wrapperState.wasMultiple=!!p.multiple;var Y=p.value;Y!=null?ns(f,!!p.multiple,Y,!1):B!==!!p.multiple&&(p.defaultValue!=null?ns(f,!!p.multiple,p.defaultValue,!0):ns(f,!!p.multiple,p.multiple?[]:"",!1))}f[di]=p}catch(ee){Pe(t,t.return,ee)}}break;case 6:if(Dt(s,t),Kt(t),u&4){if(t.stateNode===null)throw Error(r(162));f=t.stateNode,p=t.memoizedProps;try{f.nodeValue=p}catch(ee){Pe(t,t.return,ee)}}break;case 3:if(Dt(s,t),Kt(t),u&4&&a!==null&&a.memoizedState.isDehydrated)try{ei(s.containerInfo)}catch(ee){Pe(t,t.return,ee)}break;case 4:Dt(s,t),Kt(t);break;case 13:Dt(s,t),Kt(t),f=t.child,f.flags&8192&&(p=f.memoizedState!==null,f.stateNode.isHidden=p,!p||f.alternate!==null&&f.alternate.memoizedState!==null||(ml=Fe())),u&4&&Jd(t);break;case 22:if(z=a!==null&&a.memoizedState!==null,t.mode&1?(at=(L=at)||z,Dt(s,t),at=L):Dt(s,t),Kt(t),u&8192){if(L=t.memoizedState!==null,(t.stateNode.isHidden=L)&&!z&&(t.mode&1)!==0)for(J=t,z=t.child;z!==null;){for(W=J=z;J!==null;){switch(B=J,Y=B.child,B.tag){case 0:case 11:case 14:case 15:ji(4,B,B.return);break;case 1:Ss(B,B.return);var Z=B.stateNode;if(typeof Z.componentWillUnmount=="function"){u=B,a=B.return;try{s=u,Z.props=s.memoizedProps,Z.state=s.memoizedState,Z.componentWillUnmount()}catch(ee){Pe(u,a,ee)}}break;case 5:Ss(B,B.return);break;case 22:if(B.memoizedState!==null){tf(W);continue}}Y!==null?(Y.return=B,J=Y):tf(W)}z=z.sibling}e:for(z=null,W=t;;){if(W.tag===5){if(z===null){z=W;try{f=W.stateNode,L?(p=f.style,typeof p.setProperty=="function"?p.setProperty("display","none","important"):p.display="none"):(S=W.stateNode,b=W.memoizedProps.style,k=b!=null&&b.hasOwnProperty("display")?b.display:null,S.style.display=Oc("display",k))}catch(ee){Pe(t,t.return,ee)}}}else if(W.tag===6){if(z===null)try{W.stateNode.nodeValue=L?"":W.memoizedProps}catch(ee){Pe(t,t.return,ee)}}else if((W.tag!==22&&W.tag!==23||W.memoizedState===null||W===t)&&W.child!==null){W.child.return=W,W=W.child;continue}if(W===t)break e;for(;W.sibling===null;){if(W.return===null||W.return===t)break e;z===W&&(z=null),W=W.return}z===W&&(z=null),W.sibling.return=W.return,W=W.sibling}}break;case 19:Dt(s,t),Kt(t),u&4&&Jd(t);break;case 21:break;default:Dt(s,t),Kt(t)}}function Kt(t){var s=t.flags;if(s&2){try{e:{for(var a=t.return;a!==null;){if(Qd(a)){var u=a;break e}a=a.return}throw Error(r(160))}switch(u.tag){case 5:var f=u.stateNode;u.flags&32&&(Ws(f,""),u.flags&=-33);var p=qd(t);dl(t,p,f);break;case 3:case 4:var k=u.stateNode.containerInfo,S=qd(t);ul(t,S,k);break;default:throw Error(r(161))}}catch(b){Pe(t,t.return,b)}t.flags&=-3}s&4096&&(t.flags&=-4097)}function $g(t,s,a){J=t,Zd(t)}function Zd(t,s,a){for(var u=(t.mode&1)!==0;J!==null;){var f=J,p=f.child;if(f.tag===22&&u){var k=f.memoizedState!==null||Lr;if(!k){var S=f.alternate,b=S!==null&&S.memoizedState!==null||at;S=Lr;var L=at;if(Lr=k,(at=b)&&!L)for(J=f;J!==null;)k=J,b=k.child,k.tag===22&&k.memoizedState!==null?nf(f):b!==null?(b.return=k,J=b):nf(f);for(;p!==null;)J=p,Zd(p),p=p.sibling;J=f,Lr=S,at=L}ef(t)}else(f.subtreeFlags&8772)!==0&&p!==null?(p.return=f,J=p):ef(t)}}function ef(t){for(;J!==null;){var s=J;if((s.flags&8772)!==0){var a=s.alternate;try{if((s.flags&8772)!==0)switch(s.tag){case 0:case 11:case 15:at||Rr(5,s);break;case 1:var u=s.stateNode;if(s.flags&4&&!at)if(a===null)u.componentDidMount();else{var f=s.elementType===s.type?a.memoizedProps:_t(s.type,a.memoizedProps);u.componentDidUpdate(f,a.memoizedState,u.__reactInternalSnapshotBeforeUpdate)}var p=s.updateQueue;p!==null&&td(s,p,u);break;case 3:var k=s.updateQueue;if(k!==null){if(a=null,s.child!==null)switch(s.child.tag){case 5:a=s.child.stateNode;break;case 1:a=s.child.stateNode}td(s,k,a)}break;case 5:var S=s.stateNode;if(a===null&&s.flags&4){a=S;var b=s.memoizedProps;switch(s.type){case"button":case"input":case"select":case"textarea":b.autoFocus&&a.focus();break;case"img":b.src&&(a.src=b.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(s.memoizedState===null){var L=s.alternate;if(L!==null){var z=L.memoizedState;if(z!==null){var W=z.dehydrated;W!==null&&ei(W)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(r(163))}at||s.flags&512&&cl(s)}catch(B){Pe(s,s.return,B)}}if(s===t){J=null;break}if(a=s.sibling,a!==null){a.return=s.return,J=a;break}J=s.return}}function tf(t){for(;J!==null;){var s=J;if(s===t){J=null;break}var a=s.sibling;if(a!==null){a.return=s.return,J=a;break}J=s.return}}function nf(t){for(;J!==null;){var s=J;try{switch(s.tag){case 0:case 11:case 15:var a=s.return;try{Rr(4,s)}catch(b){Pe(s,a,b)}break;case 1:var u=s.stateNode;if(typeof u.componentDidMount=="function"){var f=s.return;try{u.componentDidMount()}catch(b){Pe(s,f,b)}}var p=s.return;try{cl(s)}catch(b){Pe(s,p,b)}break;case 5:var k=s.return;try{cl(s)}catch(b){Pe(s,k,b)}}}catch(b){Pe(s,s.return,b)}if(s===t){J=null;break}var S=s.sibling;if(S!==null){S.return=s.return,J=S;break}J=s.return}}var Tg=Math.ceil,_r=te.ReactCurrentDispatcher,fl=te.ReactCurrentOwner,Et=te.ReactCurrentBatchConfig,je=0,Xe=null,Ve=null,st=0,St=0,Ns=wn(0),Qe=0,Si=null,Gn=0,Pr=0,hl=0,Ni=null,gt=null,ml=0,bs=1/0,cn=null,Dr=!1,pl=null,$n=null,Br=!1,Tn=null,zr=0,bi=0,gl=null,Fr=-1,Ur=0;function dt(){return(je&6)!==0?Fe():Fr!==-1?Fr:Fr=Fe()}function En(t){return(t.mode&1)===0?1:(je&2)!==0&&st!==0?st&-st:dg.transition!==null?(Ur===0&&(Ur=qc()),Ur):(t=be,t!==0||(t=window.event,t=t===void 0?16:iu(t.type)),t)}function Bt(t,s,a,u){if(50<bi)throw bi=0,gl=null,Error(r(185));qs(t,a,u),((je&2)===0||t!==Xe)&&(t===Xe&&((je&2)===0&&(Pr|=a),Qe===4&&Mn(t,st)),vt(t,u),a===1&&je===0&&(s.mode&1)===0&&(bs=Fe()+500,gr&&Sn()))}function vt(t,s){var a=t.callbackNode;dp(t,s);var u=Ji(t,t===Xe?st:0);if(u===0)a!==null&&Kc(a),t.callbackNode=null,t.callbackPriority=0;else if(s=u&-u,t.callbackPriority!==s){if(a!=null&&Kc(a),s===1)t.tag===0?ug(rf.bind(null,t)):Wu(rf.bind(null,t)),og(function(){(je&6)===0&&Sn()}),a=null;else{switch(Yc(u)){case 1:a=qo;break;case 4:a=Gc;break;case 16:a=Gi;break;case 536870912:a=Qc;break;default:a=Gi}a=hf(a,sf.bind(null,t))}t.callbackPriority=s,t.callbackNode=a}}function sf(t,s){if(Fr=-1,Ur=0,(je&6)!==0)throw Error(r(327));var a=t.callbackNode;if(Cs()&&t.callbackNode!==a)return null;var u=Ji(t,t===Xe?st:0);if(u===0)return null;if((u&30)!==0||(u&t.expiredLanes)!==0||s)s=Wr(t,u);else{s=u;var f=je;je|=2;var p=af();(Xe!==t||st!==s)&&(cn=null,bs=Fe()+500,qn(t,s));do try{Ig();break}catch(S){of(t,S)}while(!0);La(),_r.current=p,je=f,Ve!==null?s=0:(Xe=null,st=0,s=Qe)}if(s!==0){if(s===2&&(f=Yo(t),f!==0&&(u=f,s=vl(t,f))),s===1)throw a=Si,qn(t,0),Mn(t,u),vt(t,Fe()),a;if(s===6)Mn(t,u);else{if(f=t.current.alternate,(u&30)===0&&!Eg(f)&&(s=Wr(t,u),s===2&&(p=Yo(t),p!==0&&(u=p,s=vl(t,p))),s===1))throw a=Si,qn(t,0),Mn(t,u),vt(t,Fe()),a;switch(t.finishedWork=f,t.finishedLanes=u,s){case 0:case 1:throw Error(r(345));case 2:Yn(t,gt,cn);break;case 3:if(Mn(t,u),(u&130023424)===u&&(s=ml+500-Fe(),10<s)){if(Ji(t,0)!==0)break;if(f=t.suspendedLanes,(f&u)!==u){dt(),t.pingedLanes|=t.suspendedLanes&f;break}t.timeoutHandle=Sa(Yn.bind(null,t,gt,cn),s);break}Yn(t,gt,cn);break;case 4:if(Mn(t,u),(u&4194240)===u)break;for(s=t.eventTimes,f=-1;0<u;){var k=31-Ot(u);p=1<<k,k=s[k],k>f&&(f=k),u&=~p}if(u=f,u=Fe()-u,u=(120>u?120:480>u?480:1080>u?1080:1920>u?1920:3e3>u?3e3:4320>u?4320:1960*Tg(u/1960))-u,10<u){t.timeoutHandle=Sa(Yn.bind(null,t,gt,cn),u);break}Yn(t,gt,cn);break;case 5:Yn(t,gt,cn);break;default:throw Error(r(329))}}}return vt(t,Fe()),t.callbackNode===a?sf.bind(null,t):null}function vl(t,s){var a=Ni;return t.current.memoizedState.isDehydrated&&(qn(t,s).flags|=256),t=Wr(t,s),t!==2&&(s=gt,gt=a,s!==null&&kl(s)),t}function kl(t){gt===null?gt=t:gt.push.apply(gt,t)}function Eg(t){for(var s=t;;){if(s.flags&16384){var a=s.updateQueue;if(a!==null&&(a=a.stores,a!==null))for(var u=0;u<a.length;u++){var f=a[u],p=f.getSnapshot;f=f.value;try{if(!Lt(p(),f))return!1}catch{return!1}}}if(a=s.child,s.subtreeFlags&16384&&a!==null)a.return=s,s=a;else{if(s===t)break;for(;s.sibling===null;){if(s.return===null||s.return===t)return!0;s=s.return}s.sibling.return=s.return,s=s.sibling}}return!0}function Mn(t,s){for(s&=~hl,s&=~Pr,t.suspendedLanes|=s,t.pingedLanes&=~s,t=t.expirationTimes;0<s;){var a=31-Ot(s),u=1<<a;t[a]=-1,s&=~u}}function rf(t){if((je&6)!==0)throw Error(r(327));Cs();var s=Ji(t,0);if((s&1)===0)return vt(t,Fe()),null;var a=Wr(t,s);if(t.tag!==0&&a===2){var u=Yo(t);u!==0&&(s=u,a=vl(t,u))}if(a===1)throw a=Si,qn(t,0),Mn(t,s),vt(t,Fe()),a;if(a===6)throw Error(r(345));return t.finishedWork=t.current.alternate,t.finishedLanes=s,Yn(t,gt,cn),vt(t,Fe()),null}function yl(t,s){var a=je;je|=1;try{return t(s)}finally{je=a,je===0&&(bs=Fe()+500,gr&&Sn())}}function Qn(t){Tn!==null&&Tn.tag===0&&(je&6)===0&&Cs();var s=je;je|=1;var a=Et.transition,u=be;try{if(Et.transition=null,be=1,t)return t()}finally{be=u,Et.transition=a,je=s,(je&6)===0&&Sn()}}function xl(){St=Ns.current,Ae(Ns)}function qn(t,s){t.finishedWork=null,t.finishedLanes=0;var a=t.timeoutHandle;if(a!==-1&&(t.timeoutHandle=-1,rg(a)),Ve!==null)for(a=Ve.return;a!==null;){var u=a;switch(Ea(u),u.tag){case 1:u=u.type.childContextTypes,u!=null&&mr();break;case 3:ws(),Ae(ht),Ae(it),Ua();break;case 5:za(u);break;case 4:ws();break;case 13:Ae(Re);break;case 19:Ae(Re);break;case 10:Ra(u.type._context);break;case 22:case 23:xl()}a=a.return}if(Xe=t,Ve=t=In(t.current,null),st=St=s,Qe=0,Si=null,hl=Pr=Gn=0,gt=Ni=null,Hn!==null){for(s=0;s<Hn.length;s++)if(a=Hn[s],u=a.interleaved,u!==null){a.interleaved=null;var f=u.next,p=a.pending;if(p!==null){var k=p.next;p.next=f,u.next=k}a.pending=u}Hn=null}return t}function of(t,s){do{var a=Ve;try{if(La(),Cr.current=Mr,$r){for(var u=_e.memoizedState;u!==null;){var f=u.queue;f!==null&&(f.pending=null),u=u.next}$r=!1}if(Kn=0,Je=Ge=_e=null,vi=!1,ki=0,fl.current=null,a===null||a.return===null){Qe=1,Si=s,Ve=null;break}e:{var p=t,k=a.return,S=a,b=s;if(s=st,S.flags|=32768,b!==null&&typeof b=="object"&&typeof b.then=="function"){var L=b,z=S,W=z.tag;if((z.mode&1)===0&&(W===0||W===11||W===15)){var B=z.alternate;B?(z.updateQueue=B.updateQueue,z.memoizedState=B.memoizedState,z.lanes=B.lanes):(z.updateQueue=null,z.memoizedState=null)}var Y=Md(k);if(Y!==null){Y.flags&=-257,Id(Y,k,S,p,s),Y.mode&1&&Ed(p,L,s),s=Y,b=L;var Z=s.updateQueue;if(Z===null){var ee=new Set;ee.add(b),s.updateQueue=ee}else Z.add(b);break e}else{if((s&1)===0){Ed(p,L,s),wl();break e}b=Error(r(426))}}else if(Oe&&S.mode&1){var Ue=Md(k);if(Ue!==null){(Ue.flags&65536)===0&&(Ue.flags|=256),Id(Ue,k,S,p,s),Aa(js(b,S));break e}}p=b=js(b,S),Qe!==4&&(Qe=2),Ni===null?Ni=[p]:Ni.push(p),p=k;do{switch(p.tag){case 3:p.flags|=65536,s&=-s,p.lanes|=s;var M=$d(p,b,s);ed(p,M);break e;case 1:S=b;var C=p.type,A=p.stateNode;if((p.flags&128)===0&&(typeof C.getDerivedStateFromError=="function"||A!==null&&typeof A.componentDidCatch=="function"&&($n===null||!$n.has(A)))){p.flags|=65536,s&=-s,p.lanes|=s;var V=Td(p,S,s);ed(p,V);break e}}p=p.return}while(p!==null)}cf(a)}catch(ne){s=ne,Ve===a&&a!==null&&(Ve=a=a.return);continue}break}while(!0)}function af(){var t=_r.current;return _r.current=Mr,t===null?Mr:t}function wl(){(Qe===0||Qe===3||Qe===2)&&(Qe=4),Xe===null||(Gn&268435455)===0&&(Pr&268435455)===0||Mn(Xe,st)}function Wr(t,s){var a=je;je|=2;var u=af();(Xe!==t||st!==s)&&(cn=null,qn(t,s));do try{Mg();break}catch(f){of(t,f)}while(!0);if(La(),je=a,_r.current=u,Ve!==null)throw Error(r(261));return Xe=null,st=0,Qe}function Mg(){for(;Ve!==null;)lf(Ve)}function Ig(){for(;Ve!==null&&!np();)lf(Ve)}function lf(t){var s=ff(t.alternate,t,St);t.memoizedProps=t.pendingProps,s===null?cf(t):Ve=s,fl.current=null}function cf(t){var s=t;do{var a=s.alternate;if(t=s.return,(s.flags&32768)===0){if(a=Sg(a,s,St),a!==null){Ve=a;return}}else{if(a=Ng(a,s),a!==null){a.flags&=32767,Ve=a;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{Qe=6,Ve=null;return}}if(s=s.sibling,s!==null){Ve=s;return}Ve=s=t}while(s!==null);Qe===0&&(Qe=5)}function Yn(t,s,a){var u=be,f=Et.transition;try{Et.transition=null,be=1,Ag(t,s,a,u)}finally{Et.transition=f,be=u}return null}function Ag(t,s,a,u){do Cs();while(Tn!==null);if((je&6)!==0)throw Error(r(327));a=t.finishedWork;var f=t.finishedLanes;if(a===null)return null;if(t.finishedWork=null,t.finishedLanes=0,a===t.current)throw Error(r(177));t.callbackNode=null,t.callbackPriority=0;var p=a.lanes|a.childLanes;if(fp(t,p),t===Xe&&(Ve=Xe=null,st=0),(a.subtreeFlags&2064)===0&&(a.flags&2064)===0||Br||(Br=!0,hf(Gi,function(){return Cs(),null})),p=(a.flags&15990)!==0,(a.subtreeFlags&15990)!==0||p){p=Et.transition,Et.transition=null;var k=be;be=1;var S=je;je|=4,fl.current=null,Cg(t,a),Xd(a,t),Xp(wa),er=!!xa,wa=xa=null,t.current=a,$g(a),sp(),je=S,be=k,Et.transition=p}else t.current=a;if(Br&&(Br=!1,Tn=t,zr=f),p=t.pendingLanes,p===0&&($n=null),op(a.stateNode),vt(t,Fe()),s!==null)for(u=t.onRecoverableError,a=0;a<s.length;a++)f=s[a],u(f.value,{componentStack:f.stack,digest:f.digest});if(Dr)throw Dr=!1,t=pl,pl=null,t;return(zr&1)!==0&&t.tag!==0&&Cs(),p=t.pendingLanes,(p&1)!==0?t===gl?bi++:(bi=0,gl=t):bi=0,Sn(),null}function Cs(){if(Tn!==null){var t=Yc(zr),s=Et.transition,a=be;try{if(Et.transition=null,be=16>t?16:t,Tn===null)var u=!1;else{if(t=Tn,Tn=null,zr=0,(je&6)!==0)throw Error(r(331));var f=je;for(je|=4,J=t.current;J!==null;){var p=J,k=p.child;if((J.flags&16)!==0){var S=p.deletions;if(S!==null){for(var b=0;b<S.length;b++){var L=S[b];for(J=L;J!==null;){var z=J;switch(z.tag){case 0:case 11:case 15:ji(8,z,p)}var W=z.child;if(W!==null)W.return=z,J=W;else for(;J!==null;){z=J;var B=z.sibling,Y=z.return;if(Gd(z),z===L){J=null;break}if(B!==null){B.return=Y,J=B;break}J=Y}}}var Z=p.alternate;if(Z!==null){var ee=Z.child;if(ee!==null){Z.child=null;do{var Ue=ee.sibling;ee.sibling=null,ee=Ue}while(ee!==null)}}J=p}}if((p.subtreeFlags&2064)!==0&&k!==null)k.return=p,J=k;else e:for(;J!==null;){if(p=J,(p.flags&2048)!==0)switch(p.tag){case 0:case 11:case 15:ji(9,p,p.return)}var M=p.sibling;if(M!==null){M.return=p.return,J=M;break e}J=p.return}}var C=t.current;for(J=C;J!==null;){k=J;var A=k.child;if((k.subtreeFlags&2064)!==0&&A!==null)A.return=k,J=A;else e:for(k=C;J!==null;){if(S=J,(S.flags&2048)!==0)try{switch(S.tag){case 0:case 11:case 15:Rr(9,S)}}catch(ne){Pe(S,S.return,ne)}if(S===k){J=null;break e}var V=S.sibling;if(V!==null){V.return=S.return,J=V;break e}J=S.return}}if(je=f,Sn(),Ut&&typeof Ut.onPostCommitFiberRoot=="function")try{Ut.onPostCommitFiberRoot(Qi,t)}catch{}u=!0}return u}finally{be=a,Et.transition=s}}return!1}function uf(t,s,a){s=js(a,s),s=$d(t,s,1),t=bn(t,s,1),s=dt(),t!==null&&(qs(t,1,s),vt(t,s))}function Pe(t,s,a){if(t.tag===3)uf(t,t,a);else for(;s!==null;){if(s.tag===3){uf(s,t,a);break}else if(s.tag===1){var u=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&($n===null||!$n.has(u))){t=js(a,t),t=Td(s,t,1),s=bn(s,t,1),t=dt(),s!==null&&(qs(s,1,t),vt(s,t));break}}s=s.return}}function Og(t,s,a){var u=t.pingCache;u!==null&&u.delete(s),s=dt(),t.pingedLanes|=t.suspendedLanes&a,Xe===t&&(st&a)===a&&(Qe===4||Qe===3&&(st&130023424)===st&&500>Fe()-ml?qn(t,0):hl|=a),vt(t,s)}function df(t,s){s===0&&((t.mode&1)===0?s=1:(s=Yi,Yi<<=1,(Yi&130023424)===0&&(Yi=4194304)));var a=dt();t=on(t,s),t!==null&&(qs(t,s,a),vt(t,a))}function Lg(t){var s=t.memoizedState,a=0;s!==null&&(a=s.retryLane),df(t,a)}function Rg(t,s){var a=0;switch(t.tag){case 13:var u=t.stateNode,f=t.memoizedState;f!==null&&(a=f.retryLane);break;case 19:u=t.stateNode;break;default:throw Error(r(314))}u!==null&&u.delete(s),df(t,a)}var ff;ff=function(t,s,a){if(t!==null)if(t.memoizedProps!==s.pendingProps||ht.current)pt=!0;else{if((t.lanes&a)===0&&(s.flags&128)===0)return pt=!1,jg(t,s,a);pt=(t.flags&131072)!==0}else pt=!1,Oe&&(s.flags&1048576)!==0&&Hu(s,kr,s.index);switch(s.lanes=0,s.tag){case 2:var u=s.type;Or(t,s),t=s.pendingProps;var f=ms(s,it.current);xs(s,a),f=Va(null,s,u,t,f,a);var p=Ka();return s.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(s.tag=1,s.memoizedState=null,s.updateQueue=null,mt(u)?(p=!0,pr(s)):p=!1,s.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,Da(s),f.updater=Ir,s.stateNode=f,f._reactInternals=s,Xa(s,u,t,a),s=nl(null,s,u,!0,p,a)):(s.tag=0,Oe&&p&&Ta(s),ut(null,s,f,a),s=s.child),s;case 16:u=s.elementType;e:{switch(Or(t,s),t=s.pendingProps,f=u._init,u=f(u._payload),s.type=u,f=s.tag=Pg(u),t=_t(u,t),f){case 0:s=tl(null,s,u,t,a);break e;case 1:s=Pd(null,s,u,t,a);break e;case 11:s=Ad(null,s,u,t,a);break e;case 14:s=Od(null,s,u,_t(u.type,t),a);break e}throw Error(r(306,u,""))}return s;case 0:return u=s.type,f=s.pendingProps,f=s.elementType===u?f:_t(u,f),tl(t,s,u,f,a);case 1:return u=s.type,f=s.pendingProps,f=s.elementType===u?f:_t(u,f),Pd(t,s,u,f,a);case 3:e:{if(Dd(s),t===null)throw Error(r(387));u=s.pendingProps,p=s.memoizedState,f=p.element,Zu(t,s),Nr(s,u,null,a);var k=s.memoizedState;if(u=k.element,p.isDehydrated)if(p={element:u,isDehydrated:!1,cache:k.cache,pendingSuspenseBoundaries:k.pendingSuspenseBoundaries,transitions:k.transitions},s.updateQueue.baseState=p,s.memoizedState=p,s.flags&256){f=js(Error(r(423)),s),s=Bd(t,s,u,a,f);break e}else if(u!==f){f=js(Error(r(424)),s),s=Bd(t,s,u,a,f);break e}else for(jt=xn(s.stateNode.containerInfo.firstChild),wt=s,Oe=!0,Rt=null,a=Ju(s,null,u,a),s.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(vs(),u===f){s=ln(t,s,a);break e}ut(t,s,u,a)}s=s.child}return s;case 5:return nd(s),t===null&&Ia(s),u=s.type,f=s.pendingProps,p=t!==null?t.memoizedProps:null,k=f.children,ja(u,f)?k=null:p!==null&&ja(u,p)&&(s.flags|=32),_d(t,s),ut(t,s,k,a),s.child;case 6:return t===null&&Ia(s),null;case 13:return zd(t,s,a);case 4:return Ba(s,s.stateNode.containerInfo),u=s.pendingProps,t===null?s.child=ks(s,null,u,a):ut(t,s,u,a),s.child;case 11:return u=s.type,f=s.pendingProps,f=s.elementType===u?f:_t(u,f),Ad(t,s,u,f,a);case 7:return ut(t,s,s.pendingProps,a),s.child;case 8:return ut(t,s,s.pendingProps.children,a),s.child;case 12:return ut(t,s,s.pendingProps.children,a),s.child;case 10:e:{if(u=s.type._context,f=s.pendingProps,p=s.memoizedProps,k=f.value,Me(wr,u._currentValue),u._currentValue=k,p!==null)if(Lt(p.value,k)){if(p.children===f.children&&!ht.current){s=ln(t,s,a);break e}}else for(p=s.child,p!==null&&(p.return=s);p!==null;){var S=p.dependencies;if(S!==null){k=p.child;for(var b=S.firstContext;b!==null;){if(b.context===u){if(p.tag===1){b=an(-1,a&-a),b.tag=2;var L=p.updateQueue;if(L!==null){L=L.shared;var z=L.pending;z===null?b.next=b:(b.next=z.next,z.next=b),L.pending=b}}p.lanes|=a,b=p.alternate,b!==null&&(b.lanes|=a),_a(p.return,a,s),S.lanes|=a;break}b=b.next}}else if(p.tag===10)k=p.type===s.type?null:p.child;else if(p.tag===18){if(k=p.return,k===null)throw Error(r(341));k.lanes|=a,S=k.alternate,S!==null&&(S.lanes|=a),_a(k,a,s),k=p.sibling}else k=p.child;if(k!==null)k.return=p;else for(k=p;k!==null;){if(k===s){k=null;break}if(p=k.sibling,p!==null){p.return=k.return,k=p;break}k=k.return}p=k}ut(t,s,f.children,a),s=s.child}return s;case 9:return f=s.type,u=s.pendingProps.children,xs(s,a),f=$t(f),u=u(f),s.flags|=1,ut(t,s,u,a),s.child;case 14:return u=s.type,f=_t(u,s.pendingProps),f=_t(u.type,f),Od(t,s,u,f,a);case 15:return Ld(t,s,s.type,s.pendingProps,a);case 17:return u=s.type,f=s.pendingProps,f=s.elementType===u?f:_t(u,f),Or(t,s),s.tag=1,mt(u)?(t=!0,pr(s)):t=!1,xs(s,a),bd(s,u,f),Xa(s,u,f,a),nl(null,s,u,!0,t,a);case 19:return Ud(t,s,a);case 22:return Rd(t,s,a)}throw Error(r(156,s.tag))};function hf(t,s){return Vc(t,s)}function _g(t,s,a,u){this.tag=t,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=s,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 Mt(t,s,a,u){return new _g(t,s,a,u)}function jl(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Pg(t){if(typeof t=="function")return jl(t)?1:0;if(t!=null){if(t=t.$$typeof,t===$e)return 11;if(t===Q)return 14}return 2}function In(t,s){var a=t.alternate;return a===null?(a=Mt(t.tag,s,t.key,t.mode),a.elementType=t.elementType,a.type=t.type,a.stateNode=t.stateNode,a.alternate=t,t.alternate=a):(a.pendingProps=s,a.type=t.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=t.flags&14680064,a.childLanes=t.childLanes,a.lanes=t.lanes,a.child=t.child,a.memoizedProps=t.memoizedProps,a.memoizedState=t.memoizedState,a.updateQueue=t.updateQueue,s=t.dependencies,a.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},a.sibling=t.sibling,a.index=t.index,a.ref=t.ref,a}function Hr(t,s,a,u,f,p){var k=2;if(u=t,typeof t=="function")jl(t)&&(k=1);else if(typeof t=="string")k=5;else e:switch(t){case ie:return Jn(a.children,f,p,s);case oe:k=8,f|=8;break;case G:return t=Mt(12,a,s,f|2),t.elementType=G,t.lanes=p,t;case X:return t=Mt(13,a,s,f),t.elementType=X,t.lanes=p,t;case P:return t=Mt(19,a,s,f),t.elementType=P,t.lanes=p,t;case ae:return Vr(a,f,p,s);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case ge:k=10;break e;case He:k=9;break e;case $e:k=11;break e;case Q:k=14;break e;case q:k=16,u=null;break e}throw Error(r(130,t==null?t:typeof t,""))}return s=Mt(k,a,s,f),s.elementType=t,s.type=u,s.lanes=p,s}function Jn(t,s,a,u){return t=Mt(7,t,u,s),t.lanes=a,t}function Vr(t,s,a,u){return t=Mt(22,t,u,s),t.elementType=ae,t.lanes=a,t.stateNode={isHidden:!1},t}function Sl(t,s,a){return t=Mt(6,t,null,s),t.lanes=a,t}function Nl(t,s,a){return s=Mt(4,t.children!==null?t.children:[],t.key,s),s.lanes=a,s.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},s}function Dg(t,s,a,u,f){this.tag=s,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Jo(0),this.expirationTimes=Jo(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Jo(0),this.identifierPrefix=u,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function bl(t,s,a,u,f,p,k,S,b){return t=new Dg(t,s,a,S,b),s===1?(s=1,p===!0&&(s|=8)):s=0,p=Mt(3,null,null,s),t.current=p,p.stateNode=t,p.memoizedState={element:u,isDehydrated:a,cache:null,transitions:null,pendingSuspenseBoundaries:null},Da(p),t}function Bg(t,s,a){var u=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:F,key:u==null?null:""+u,children:t,containerInfo:s,implementation:a}}function mf(t){if(!t)return jn;t=t._reactInternals;e:{if(Bn(t)!==t||t.tag!==1)throw Error(r(170));var s=t;do{switch(s.tag){case 3:s=s.stateNode.context;break e;case 1:if(mt(s.type)){s=s.stateNode.__reactInternalMemoizedMergedChildContext;break e}}s=s.return}while(s!==null);throw Error(r(171))}if(t.tag===1){var a=t.type;if(mt(a))return Fu(t,a,s)}return s}function pf(t,s,a,u,f,p,k,S,b){return t=bl(a,u,!0,t,f,p,k,S,b),t.context=mf(null),a=t.current,u=dt(),f=En(a),p=an(u,f),p.callback=s??null,bn(a,p,f),t.current.lanes=f,qs(t,f,u),vt(t,u),t}function Kr(t,s,a,u){var f=s.current,p=dt(),k=En(f);return a=mf(a),s.context===null?s.context=a:s.pendingContext=a,s=an(p,k),s.payload={element:t},u=u===void 0?null:u,u!==null&&(s.callback=u),t=bn(f,s,k),t!==null&&(Bt(t,f,k,p),Sr(t,f,k)),k}function Gr(t){if(t=t.current,!t.child)return null;switch(t.child.tag){case 5:return t.child.stateNode;default:return t.child.stateNode}}function gf(t,s){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var a=t.retryLane;t.retryLane=a!==0&&a<s?a:s}}function Cl(t,s){gf(t,s),(t=t.alternate)&&gf(t,s)}function zg(){return null}var vf=typeof reportError=="function"?reportError:function(t){console.error(t)};function $l(t){this._internalRoot=t}Qr.prototype.render=$l.prototype.render=function(t){var s=this._internalRoot;if(s===null)throw Error(r(409));Kr(t,s,null,null)},Qr.prototype.unmount=$l.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var s=t.containerInfo;Qn(function(){Kr(null,t,null,null)}),s[tn]=null}};function Qr(t){this._internalRoot=t}Qr.prototype.unstable_scheduleHydration=function(t){if(t){var s=Zc();t={blockedOn:null,target:t,priority:s};for(var a=0;a<vn.length&&s!==0&&s<vn[a].priority;a++);vn.splice(a,0,t),a===0&&nu(t)}};function Tl(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function qr(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function kf(){}function Fg(t,s,a,u,f){if(f){if(typeof u=="function"){var p=u;u=function(){var L=Gr(k);p.call(L)}}var k=pf(s,u,t,0,null,!1,!1,"",kf);return t._reactRootContainer=k,t[tn]=k.current,ci(t.nodeType===8?t.parentNode:t),Qn(),k}for(;f=t.lastChild;)t.removeChild(f);if(typeof u=="function"){var S=u;u=function(){var L=Gr(b);S.call(L)}}var b=bl(t,0,!1,null,null,!1,!1,"",kf);return t._reactRootContainer=b,t[tn]=b.current,ci(t.nodeType===8?t.parentNode:t),Qn(function(){Kr(s,b,a,u)}),b}function Yr(t,s,a,u,f){var p=a._reactRootContainer;if(p){var k=p;if(typeof f=="function"){var S=f;f=function(){var b=Gr(k);S.call(b)}}Kr(s,k,t,f)}else k=Fg(a,s,t,f,u);return Gr(k)}Jc=function(t){switch(t.tag){case 3:var s=t.stateNode;if(s.current.memoizedState.isDehydrated){var a=Qs(s.pendingLanes);a!==0&&(Xo(s,a|1),vt(s,Fe()),(je&6)===0&&(bs=Fe()+500,Sn()))}break;case 13:Qn(function(){var u=on(t,1);if(u!==null){var f=dt();Bt(u,t,1,f)}}),Cl(t,1)}},Zo=function(t){if(t.tag===13){var s=on(t,134217728);if(s!==null){var a=dt();Bt(s,t,134217728,a)}Cl(t,134217728)}},Xc=function(t){if(t.tag===13){var s=En(t),a=on(t,s);if(a!==null){var u=dt();Bt(a,t,s,u)}Cl(t,s)}},Zc=function(){return be},eu=function(t,s){var a=be;try{return be=t,s()}finally{be=a}},Vo=function(t,s,a){switch(s){case"input":if(Po(t,a),s=a.name,a.type==="radio"&&s!=null){for(a=t;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll("input[name="+JSON.stringify(""+s)+'][type="radio"]'),s=0;s<a.length;s++){var u=a[s];if(u!==t&&u.form===t.form){var f=hr(u);if(!f)throw Error(r(90));Nc(u),Po(u,f)}}}break;case"textarea":Ec(t,a);break;case"select":s=a.value,s!=null&&ns(t,!!a.multiple,s,!1)}},Dc=yl,Bc=Qn;var Ug={usingClientEntryPoint:!1,Events:[fi,fs,hr,_c,Pc,yl]},Ci={findFiberByHostInstance:zn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Wg={bundleType:Ci.bundleType,version:Ci.version,rendererPackageName:Ci.rendererPackageName,rendererConfig:Ci.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:te.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=Wc(t),t===null?null:t.stateNode},findFiberByHostInstance:Ci.findFiberByHostInstance||zg,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 Jr=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Jr.isDisabled&&Jr.supportsFiber)try{Qi=Jr.inject(Wg),Ut=Jr}catch{}}return kt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Ug,kt.createPortal=function(t,s){var a=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Tl(s))throw Error(r(200));return Bg(t,s,null,a)},kt.createRoot=function(t,s){if(!Tl(t))throw Error(r(299));var a=!1,u="",f=vf;return s!=null&&(s.unstable_strictMode===!0&&(a=!0),s.identifierPrefix!==void 0&&(u=s.identifierPrefix),s.onRecoverableError!==void 0&&(f=s.onRecoverableError)),s=bl(t,1,!1,null,null,a,!1,u,f),t[tn]=s.current,ci(t.nodeType===8?t.parentNode:t),new $l(s)},kt.findDOMNode=function(t){if(t==null)return null;if(t.nodeType===1)return t;var s=t._reactInternals;if(s===void 0)throw typeof t.render=="function"?Error(r(188)):(t=Object.keys(t).join(","),Error(r(268,t)));return t=Wc(s),t=t===null?null:t.stateNode,t},kt.flushSync=function(t){return Qn(t)},kt.hydrate=function(t,s,a){if(!qr(s))throw Error(r(200));return Yr(null,t,s,!0,a)},kt.hydrateRoot=function(t,s,a){if(!Tl(t))throw Error(r(405));var u=a!=null&&a.hydratedSources||null,f=!1,p="",k=vf;if(a!=null&&(a.unstable_strictMode===!0&&(f=!0),a.identifierPrefix!==void 0&&(p=a.identifierPrefix),a.onRecoverableError!==void 0&&(k=a.onRecoverableError)),s=pf(s,null,t,1,a??null,f,!1,p,k),t[tn]=s.current,ci(t),u)for(t=0;t<u.length;t++)a=u[t],f=a._getVersion,f=f(a._source),s.mutableSourceEagerHydrationData==null?s.mutableSourceEagerHydrationData=[a,f]:s.mutableSourceEagerHydrationData.push(a,f);return new Qr(s)},kt.render=function(t,s,a){if(!qr(s))throw Error(r(200));return Yr(null,t,s,!1,a)},kt.unmountComponentAtNode=function(t){if(!qr(t))throw Error(r(40));return t._reactRootContainer?(Qn(function(){Yr(null,null,t,!1,function(){t._reactRootContainer=null,t[tn]=null})}),!0):!1},kt.unstable_batchedUpdates=yl,kt.unstable_renderSubtreeIntoContainer=function(t,s,a,u){if(!qr(a))throw Error(r(200));if(t==null||t._reactInternals===void 0)throw Error(r(38));return Yr(t,s,a,!1,u)},kt.version="18.3.1-next-f1338f8080-20240426",kt}var Cf;function Ch(){if(Cf)return Il.exports;Cf=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(n){console.error(n)}}return e(),Il.exports=Xg(),Il.exports}var $f;function Zg(){if($f)return Xr;$f=1;var e=Ch();return Xr.createRoot=e.createRoot,Xr.hydrateRoot=e.hydrateRoot,Xr}var ev=Zg(),x=ec();const Ms="teamtrail",ve={slug:Ms,name:"Teamtrail",category:"The trail map for AI coding agents",tagline:"You pick the destination. Your agents walk the trail.",assistant:{name:"Scout"},labelPrefix:Ms,dataDir:`.${Ms}`,apiPrefix:`/__${Ms}`,noRegisterEnv:`${Ms.toUpperCase()}_NO_REGISTER`},No=`${Ms}.prefs`,bo=e=>`${ve.labelPrefix}:${e}`,tc=bo("map"),nc=bo("hitl"),tv=e=>e==="task"||e==="execute",sc=bo("plan-only"),fo=["research","prototype","junction","task","execute"],Co=[...fo,"review"],es="plan+execute",nv=["verifying","rework","blocked"],ic=["off","checks","checks+review","checks+review+human"],$h=e=>ic.find(n=>n===e);function Pi(e){return e.type==="junction"||e.type==="prototype"?"hitl":e.type==="research"?"afk":e.hitl?"hitl":"afk"}const sv=["task","execute"];function Th(e,n,r=es){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":r==="plan-only"&&e.type==="execute"?"parked":e.blockedBy.some(l=>{var c;return((c=n.get(l))==null?void 0:c.state)==="open"})?"blocked":"frontier"}function Bs(e,n=es){const r=new Map(e.map(o=>[o.id,o]));return new Map(e.map(o=>[o.id,Th(o,r,n)]))}const Ee=200,Ce=56;function Tf(e,n="LR",r=es){var $e;const o=n==="LR"?330:124,l=n==="LR"?112:262,c=Bs(e,r),d=new Map(e.map(X=>[X.id,X])),h=new Map,g=new Set,m=X=>{if(h.has(X))return h.get(X);if(g.has(X))return 0;g.add(X);const P=d.get(X),Q=P&&P.blockedBy.length?1+Math.max(...P.blockedBy.filter(q=>d.has(q)).map(m),-1):0;return g.delete(X),h.set(X,Q),Q},y=e.filter(X=>c.get(X.id)!=="out-of-scope"),v=e.filter(X=>c.get(X.id)==="out-of-scope"),j=[];for(const X of y)(j[$e=m(X.id)]??(j[$e]=[])).push(X);const w=[],E=new Map;let N=0;j.forEach(X=>{X&&(X.sort((P,Q)=>{const q=ae=>{const H=ae.blockedBy.map(D=>E.get(D)).filter(D=>D!==void 0);return H.length?H.reduce((D,U)=>D+U,0)/H.length:ae.createdAt/1e12};return q(P)-q(Q)||P.createdAt-Q.createdAt}),N=Math.max(N,X.length),X.forEach((P,Q)=>E.set(P.id,Q)))}),j.forEach((X,P)=>{if(!X)return;const Q=(N-X.length)*l/2;X.forEach((q,ae)=>{const H=P*o,D=Q+ae*l;w.push({ticket:q,state:c.get(q.id),layer:P,x:n==="LR"?H:D,y:n==="LR"?D:H})})});const I=Math.max(j.length,1)*o-(o-(n==="LR"?Ee:Ce)),R=Math.max(N,1)*l-(l-(n==="LR"?Ce:Ee)),O=n==="LR"?I:R,te=n==="LR"?R:I,se=te+54,F=Math.max(1,Math.floor((O+24)/(Ee+24)));v.forEach((X,P)=>{w.push({ticket:X,state:"out-of-scope",layer:-1,x:P%F*(Ee+24),y:se+Math.floor(P/F)*(Ce+16)})});const ie=[],oe=new Map(w.map(X=>[X.ticket.id,X]));for(const X of w)for(const P of X.ticket.blockedBy){const Q=oe.get(P);Q&&ie.push({from:Q,to:X})}const G=Math.ceil(v.length/F),ge=Math.max(O,Math.min(v.length,F)*(Ee+24)-24),He=v.length?se+G*(Ce+16)-16:te;return{direction:n,nodes:w,edges:ie,width:ge,graphH:te,quarantineY:se,height:He,quarantineH:G*(Ce+16)+24}}const Eh=["fast","balanced","strongest"],Mh=e=>Eh.includes(e),rc={research:"fast",task:"balanced",execute:"balanced",junction:"strongest",prototype:"strongest",review:"strongest"};function iv(e,n){var r,o;return((o=(r=n.modelMatching)==null?void 0:r.tiers)==null?void 0:o[e.type])??rc[e.type]}function rv(e){return Object.fromEntries(Co.map(n=>[n,iv({type:n},e)]))}const ov=["holding","challenged","invalidated","confirmed"],av=e=>ov.includes(e),Ih=ve.labelPrefix,lv=new RegExp(`^-\\s+(?:\\[([a-z]+)\\]\\s+)?(.*?)\\s*(?:<!-- ${Ih}:asm (\\{.*\\}) -->)?\\s*$`),cv=1e3,uv=e=>e.replace(/--/g,"-\\u002d"),dv=e=>e.replace(/\s*\n\s*/g," ").trim();function fv(e){const n={id:e.id,tickets:e.tickets,...e.source?{source:e.source}:{},...e.challenge?{challenge:{...e.challenge,evidence:e.challenge.evidence.slice(0,cv)}}:{},...e.decidedBy?{decidedBy:e.decidedBy}:{}};return`- [${e.status}] ${dv(e.text)} <!-- ${Ih}:asm ${uv(JSON.stringify(n))} -->`}function hv(e){const n=e.map(mv);let r=Math.max(0,...n.map(o=>gv(o.id)))+1;return n.map(o=>o.id?o:{...o,id:`S-${r++}`})}function mv(e){const n=e.match(lv),r=n==null?void 0:n[1],o=(n==null?void 0:n[2])??e.replace(/^-\s+/,""),l=pv(n==null?void 0:n[3]);return{id:l.id??"",text:o,status:av(r)?r:"holding",tickets:Array.isArray(l.tickets)?l.tickets.map(String):[],...l.source?{source:l.source}:{},...l.challenge?{challenge:l.challenge}:{},...l.decidedBy?{decidedBy:l.decidedBy}:{}}}function pv(e){if(!e)return{};try{const n=JSON.parse(e);return n&&typeof n=="object"?n:{}}catch{return{}}}function gv(e){const n=e==null?void 0:e.match(/^S-(\d+)$/);return n?Number(n[1]):0}const Ah=[["destination","Destination"],["notes","Notes"],["assumptions","Assumptions"],["decisions","Decisions so far"],["unspecified","Not yet specified"],["outOfScope","Out of scope"]],vv=Object.fromEntries(Ah),kv=/^-\s+(?:\[?([#A-Z0-9-]+)\]?:?\s+)?(.*)$/;function yv(e){var o;const n=l=>l.length?l.map(c=>`- ${c}`).join(`
|
|
41
|
+
`):"_None yet._",r=l=>l.length?l.map(c=>`- ${c.ticketKey?`${c.ticketKey}: `:""}${c.text}`).join(`
|
|
42
|
+
`):"_None yet._";return[`## Destination
|
|
43
|
+
|
|
44
|
+
${e.destination.trim()}`,`## Notes
|
|
45
|
+
|
|
46
|
+
${e.notes.trim()||"_None yet._"}`,...(o=e.assumptions)!=null&&o.length?[`## Assumptions
|
|
47
|
+
|
|
48
|
+
${e.assumptions.map(fv).join(`
|
|
49
|
+
`)}`]:[],`## Decisions so far
|
|
50
|
+
|
|
51
|
+
${r(e.decisions)}`,`## Not yet specified
|
|
52
|
+
|
|
53
|
+
${n(e.unspecified)}`,`## Out of scope
|
|
54
|
+
|
|
55
|
+
${n(e.outOfScope)}`].join(`
|
|
56
|
+
|
|
57
|
+
`)+`
|
|
58
|
+
`}function xv(e){var o;const n={destination:"",notes:"",decisions:[],unspecified:[],outOfScope:[]},r=e.split(/^##\s+/m).slice(1);for(const l of r){const c=l.indexOf(`
|
|
59
|
+
`),d=l.slice(0,c===-1?void 0:c).trim().toLowerCase(),h=(c===-1?"":l.slice(c+1)).trim(),g=(o=Ah.find(([,v])=>v.toLowerCase()===d))==null?void 0:o[0];if(!g)continue;const m=/^_none yet\._$/i.test(h),y=m?[]:h.split(`
|
|
60
|
+
`).map(v=>v.trim()).filter(v=>v.startsWith("- "));g==="destination"?n.destination=h:g==="notes"?n.notes=m?"":h:g==="assumptions"?n.assumptions=hv(y):g==="decisions"?n.decisions=y.map(v=>{const j=v.match(kv);return j&&j[1]&&/\d/.test(j[1])?{ticketKey:j[1],text:j[2]}:{text:v.slice(2)}}):n[g]=y.map(v=>v.slice(2))}return n}const $o={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"]},wv=(e,n)=>`${e[0].toUpperCase()}${e.slice(1)} ${n}/${$o[e].length}`;async function jv(e,n,r={}){var d,h,g;const o=Sv(n,n.mode??es),l=await e.createMap({title:o.title,mode:o.mode,sections:o.sections,...o.verification?{verification:o.verification}:{}});await((d=r.onMapCreated)==null?void 0:d.call(r,l));const c=new Map;for(const m of o.tickets){const y=await e.createTicket(l.id,{title:m.title,type:m.type,hitl:m.hitl,body:`${m.body}
|
|
61
|
+
|
|
62
|
+
Part of trail ${l.key}.`});c.set(m.ref,y),await((h=r.onTicketCreated)==null?void 0:h.call(r,y,m.ref))}for(const m of o.tickets)for(const y of m.blockedBy??[]){const v=c.get(y),j=c.get(m.ref);v&&(await e.addBlocking(l.id,v.id,j.id),await((g=r.onEdgeWired)==null?void 0:g.call(r,v,j)))}return{map:l,tickets:[...c.values()]}}function Sv(e,n){if(n==="plan+execute")return{...e,mode:n};const r=new Map(e.tickets.filter(l=>l.type==="execute").map(l=>[l.ref,l.blockedBy??[]])),o=l=>l.flatMap(c=>r.has(c)?o(r.get(c)):[c]);return{...e,mode:n,tickets:e.tickets.filter(l=>!r.has(l.ref)).map(l=>({...l,blockedBy:[...new Set(o(l.blockedBy??[]))]}))}}class Nv{constructor(){ue(this,"tails",new Map)}run(n,r){const l=(this.tails.get(n)??Promise.resolve()).catch(()=>{}).then(r);return this.tails.set(n,l),l.finally(()=>this.tails.get(n)===l&&this.tails.delete(n)).catch(()=>{}),l}}class Be extends Error{}const bv={frontier:"ready",blocked:"backlog",parked:"backlog",claimed:"working",verifying:"verifying",rework:"rework",held:"blocked",decided:"done","out-of-scope":"cancelled"};function Cv(e,n,r=es){return bv[Th(e,n,r)]}const $v=["backlog","ready","working","verifying","rework","blocked"],Ti=["agent","trail lead"],Tv=[{event:"claim",from:["ready","rework"],to:["working"],actors:Ti},{event:"release",from:["working"],to:["ready","rework"],actors:Ti},{event:"expire",from:["working"],to:["ready","rework"],actors:["engine","trail lead"]},{event:"complete",from:["backlog","ready","working","rework"],to:["done"],actors:Ti},{event:"submit",from:["working"],to:["verifying"],actors:Ti},{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:$v,to:["cancelled"],actors:[...Ti,"engine"]},{event:"reopen",from:["done","cancelled"],to:["ready"],actors:["trail lead"]}],Ev=e=>Tv.find(n=>n.event===e),Mv=new Nv;function Iv(e,n,r){if(r){if(!e.to.includes(r))throw new Be(`${e.event} cannot lead to ${r}`);return r}if(e.to.length===1)return e.to[0];if(e.event==="release"||e.event==="expire")return n.status==="rework"?"rework":"ready";throw new Be(`${e.event} needs a target: ${e.to.join(" or ")}`)}async function Av(e,n,r,o){const{to:l,actor:c}=o,d=async h=>{(r.status??null)!==h&&await e.setMeta(n,r.id,{status:h})};switch(l){case"working":r.assignee!==c&&await e.assign(n,r.id,c);return;case"ready":case"rework":r.state==="closed"&&await e.reopen(n,r.id),await d(l==="rework"?"rework":null),r.assignee&&await e.assign(n,r.id,null);return;case"verifying":case"blocked":await d(l);return;case"done":case"cancelled":await d(null),await e.close(n,r.id,l==="done"?"completed":"not_planned");return;case"backlog":throw new Be("backlog follows from blockers; no transition leads there")}}function To(e,n,r,o){return Mv.run(`${n}/${r}`,async()=>{var m;const l=await e.loadMap(n),c=l.tickets.find(y=>y.id===r);if(!c)throw new Be(`ticket ${r} not found`);const d=Cv(c,new Map(l.tickets.map(y=>[y.id,y])),l.map.mode);if(o.expect&&d!==o.expect)throw new Be(`${c.key} changed: it is ${d} now`);const h=Ev(o.event);if(!h.from.includes(d))throw new Be(`${c.key} is ${d}; ${o.event} needs ${h.from.join(" or ")}`);if(!h.actors.includes(o.actorKind))throw new Be(`${o.event} is not for ${o.actorKind}s`);const g=Iv(h,c,o.to);await Av(e,n,c,{to:g,actor:o.actor});try{await((m=o.journal)==null?void 0:m.append({v:1,kind:"transition",at:Date.now(),mapId:n,ticketId:r,ticketKey:c.key,event:o.event,from:d,to:g,actor:o.actor,actorKind:o.actorKind,...o.reason?{reason:o.reason}:{},...o.sessionId?{sessionId:o.sessionId}:{}}))}catch{}return{ticket:c,from:d,to:g}})}async function Ef(e,n,r,o){const{assignee:l}=o,c=await e.loadMap(n),d=c.tickets.find(y=>y.id===r);if(!d)throw new Be(`ticket ${r} not found`);const h=Bs(c.tickets,c.map.mode).get(r);if(h!=="frontier"&&h!=="rework")throw new Be(`${d.key} is ${h}, not on the frontier`);await To(e,n,r,{event:"claim",actor:l,actorKind:o.actorKind??"agent",reason:o.reason,sessionId:o.sessionId,journal:o.journal});const m=(await e.loadMap(n)).tickets.find(y=>y.id===r);if(m.assignee!==l)throw new Be(`${d.key} was claimed by ${m.assignee}`);return m}async function Ov(e,n,r,o={}){const c=(await e.loadMap(n)).tickets.find(d=>d.id===r);if(!c)throw new Be(`ticket ${r} not found`);await To(e,n,r,{event:"release",actor:o.actor??c.assignee??"trail lead",actorKind:o.actorKind??"agent",reason:o.reason,sessionId:o.sessionId,journal:o.journal})}async function oc(e,n,r,o={}){if(r.source.ref){const c=(await e.listDecisions(n)).find(d=>d.source.kind===r.source.kind&&d.source.ref===r.source.ref);if(c)return c}const l=await e.createDecision(n,r);if(o.appendToTrail??!0){const c=await e.loadMap(n);await e.updateMapSections(n,{decisions:[...c.map.sections.decisions,{ticketId:l.ticketId,ticketKey:l.ticketKey,text:o.trailLine??l.summary}]})}return l}async function Lv(e,n,r,o){const c=(await e.listDecisions(n)).find(v=>v.id===r);if(!c)throw new Be(`decision ${r} not found`);if(c.supersededBy)throw new Be(`${c.id} is already superseded by ${c.supersededBy}`);const d=await e.createDecision(n,{ticketId:c.ticketId,ticketKey:c.ticketKey,...o,question:o.question??c.question,supersedes:c.id});await e.markSuperseded(n,c.id,d.id);const g=(await e.loadMap(n)).map.sections.decisions,m=g.findIndex(v=>v.text===c.summary||!!c.ticketId&&v.ticketId===c.ticketId||!!c.ticketKey&&v.ticketKey===c.ticketKey),y={ticketId:d.ticketId,ticketKey:d.ticketKey,text:d.summary};return await e.updateMapSections(n,{decisions:m<0?[...g,y]:g.map((v,j)=>j===m?y:v)}),d}async function Rv(e,n,r){await e.setMapMode(n,r)}function Oh(e){return e==="plan-only"?fo.filter(n=>n!=="execute"):fo}function _v(e,n){if(!Oh(e).includes(n))throw new Be(`${n} tickets are disabled on plan-only maps`)}const Ln={lookout:{label:"Lookout",code:"CMD"},agent:{label:"Agent",code:"AGT"},slack:{label:"Slack",code:"SLK"},tracker:{label:"Tracker",code:"TRK"}},ho=Object.keys(Ln),Pv=e=>e in Ln,Li=e=>e.source.kind==="agent"&&e.decidedBy!=="trail lead"&&!e.decidedBy.startsWith("slack:")?"agent":"human",Di=e=>e.supersededBy?"superseded":"active";function Eo(e){const n=e.replace(/\s+/g," ").trim(),r=n.match(/^(.{20,180}?[.!?])(\s|$)/);return r?r[1]:n.slice(0,180)}function Dv(e,n,r){var o;return{...r,id:e,mapId:n,decidedAt:r.decidedAt??Date.now(),summary:((o=r.summary)==null?void 0:o.trim())||Eo(r.answer),alternatives:r.alternatives??[],rationale:r.rationale??"",participants:r.participants??[{id:r.decidedBy}],transcript:r.transcript??[]}}const Bv=e=>Number(e.replace(/\D/g,""))||0;function zv(e,n){const r=new Map(e.map(d=>[d.id,d])),o=new Set;let l=r.get(n);for(;l!=null&&l.supersedes&&r.has(l.supersedes)&&!o.has(l.id);)o.add(l.id),l=r.get(l.supersedes);const c=[];o.clear();for(let d=l;d&&!o.has(d.id);d=d.supersededBy?r.get(d.supersededBy):void 0)o.add(d.id),c.push(d);return c}async function Fv(e,n,r,o){var h;const c=(await e.loadMap(n)).tickets.find(g=>g.id===r);if(!c)throw new Be(`ticket ${r} not found`);if(c.state==="closed")throw new Be(`${c.key} is already closed`);o.transcript&&await e.comment(n,r,o.author,`**HITL transcript**
|
|
63
|
+
|
|
64
|
+
${o.transcript}`),await e.comment(n,r,o.author,`**Resolution**
|
|
65
|
+
|
|
66
|
+
${o.answer}`),await To(e,n,r,{event:o.event??"complete",actor:o.actor??o.author,actorKind:o.actorKind??"agent",sessionId:o.sessionId,reason:o.reason,journal:o.journal,...o.event&&o.event!=="complete"?{to:"done"}:{}});const d=o.decision??{};return await oc(e,n,{ticketId:c.id,ticketKey:c.key,question:d.question??c.title,answer:o.answer,summary:o.summary??Eo(o.answer),alternatives:d.alternatives,rationale:d.rationale,decidedBy:d.decidedBy??o.author,participants:d.participants,source:d.source??{kind:"agent",label:o.author},transcript:d.transcript,...d.risk?{risk:d.risk}:{},...(h=d.assumes)!=null&&h.length?{assumes:d.assumes}:{}},{trailLine:o.trailLine}),c}async function Uv(e,n,r,o){const l=await e.loadMap(n);if(!l.map.sections.unspecified.includes(r))throw new Be(`"${r}" is not in Not yet specified`);_v(l.map.mode,o.type);const c=await e.createTicket(n,{title:o.title??r,type:o.type,hitl:o.hitl,body:`${o.body??`Promoted from Not yet specified: ${r}`}
|
|
67
|
+
|
|
68
|
+
Part of trail ${l.map.key}.`});for(const h of o.blockedBy??[])await e.addBlocking(n,h,c.id);const d=await e.loadMap(n);return await e.updateMapSections(n,{unspecified:d.map.sections.unspecified.filter(h=>h!==r)}),c}async function Wv(e,n,r,o){const l=await e.loadMap(n),{unspecified:c,outOfScope:d}=l.map.sections;if("unspecified"in r){if(!c.includes(r.unspecified))throw new Be(`"${r.unspecified}" is not in Not yet specified`);await e.updateMapSections(n,{unspecified:c.filter(m=>m!==r.unspecified),outOfScope:[...d,`${r.unspecified} — ${o.reason}`]});return}const h=l.tickets.find(m=>m.id===r.ticketId);if(!h)throw new Be(`ticket ${r.ticketId} not found`);await e.comment(n,h.id,o.author,`**Ruled out of scope**
|
|
69
|
+
|
|
70
|
+
${o.reason}`),await To(e,n,h.id,{event:"cancel",actor:o.author,actorKind:o.actorKind??"agent",reason:o.reason,sessionId:o.sessionId,journal:o.journal}),await oc(e,n,{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 g=await e.loadMap(n);await e.updateMapSections(n,{outOfScope:[...g.map.sections.outOfScope,`${h.key} ${h.title} — ${o.reason}`]})}async function Hv(e,n,r,o){r&&Vv(r),await e.setMapMeta(n,{modelMatching:r&&Kv(r)})}function Vv(e){if(typeof e.enabled!="boolean")throw new Be('"enabled" must be true or false');for(const[n,r]of Object.entries(e.tiers??{})){if(!Co.includes(n))throw new Be(`unknown ticket type "${n}"`);if(!Mh(r))throw new Be(`"${n}" must be fast, balanced or strongest`)}}function Kv(e){const n=Object.fromEntries(Object.entries(e.tiers??{}).filter(([,r])=>r));return Object.keys(n).length?{enabled:e.enabled,tiers:n}:{enabled:e.enabled}}function Gv(e){return{async append(n){await fetch(`${e}/journal`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}}}const Lh={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(Lh));const Qv=2*6e4,Ll=e=>e<6e4?`${Math.round(e/1e3)}s`:`${Math.round(e/6e4)}m`;function qv(e,n){if(!e)return{tone:"unknown",label:"PR sync ?",title:"PR/CI sync state unavailable"};const r=e.repo?` · ${e.repo}`:"",o=e.lastOkAt?`last ok ${Ll(n-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"}${r}
|
|
71
|
+
${o}`}:e.state==="rate-limited"?{tone:"failed",label:"PR sync paused",title:`Rate limited${r}; retrying ${e.nextAt?`in ${Ll(Math.max(0,e.nextAt-n))}`:"later"}
|
|
72
|
+
${o}`}:!e.lastOkAt||e.lastOkAt!==e.lastAttemptAt||e.nextAt!==void 0&&n>e.nextAt+Qv?{tone:"stale",label:"PR sync stale",title:`No recent sync${r}
|
|
73
|
+
${o}`}:{tone:"ok",label:`PR sync ${Ll(n-e.lastOkAt)}`,title:`PR/CI synced${r}, ${o}`}}class Os{constructor(){ue(this,"listeners",new Set)}on(n){return this.listeners.add(n),()=>this.listeners.delete(n)}emit(n){for(const r of[...this.listeners])r(n)}}let Yv=0;const lo=(e="id")=>`${e}_${Date.now().toString(36)}${(Yv++).toString(36)}`,Fl=(e,n)=>({inputTokens:((e==null?void 0:e.inputTokens)??0)+n.inputTokens,outputTokens:((e==null?void 0:e.outputTokens)??0)+n.outputTokens,costUsd:((e==null?void 0:e.costUsd)??0)+n.costUsd,...e!=null&&e.cachedInputTokens||n.cachedInputTokens?{cachedInputTokens:((e==null?void 0:e.cachedInputTokens)??0)+(n.cachedInputTokens??0)}:{}}),Rh=(e,n)=>({inputTokens:e.inputTokens-((n==null?void 0:n.inputTokens)??0),outputTokens:e.outputTokens-((n==null?void 0:n.outputTokens)??0),costUsd:e.costUsd-((n==null?void 0:n.costUsd)??0),...e.cachedInputTokens||n!=null&&n.cachedInputTokens?{cachedInputTokens:(e.cachedInputTokens??0)-((n==null?void 0:n.cachedInputTokens)??0)}:{}});function Jv(e,n,r){const o=()=>e.find(n.id)??n,l=c=>e.push({source:"session",sessionId:n.id,agent:n.agent,...c});return{id:n.id,get info(){return o()},step(c,d,h){const g=$o[r][c-1];e.patchSession(n.id,{step:c,stepLabel:g,...h?{ticketId:h}:{}}),l({tag:wv(r,c),level:"step",text:d?`${g}: ${d}`:g,ticketId:h??o().ticketId})},log(c,d="info"){l({level:d,text:c,ticketId:o().ticketId})},say(c){e.chat({sessionId:n.id,ticketId:o().ticketId,from:"agent",author:n.agent,text:c})},ask(c,d,h){var m;const g={id:lo("q"),sessionId:n.id,mapId:n.mapId,ticketId:o().ticketId,agent:n.agent,text:c,suggestions:d,at:Date.now(),...h!=null&&h.urgency?{urgency:h.urgency}:{},...(m=h==null?void 0:h.blocks)!=null&&m.length?{blocks:h.blocks}:{}};return e.chat({sessionId:n.id,ticketId:g.ticketId,from:"agent",author:n.agent,text:c,questionId:g.id}),e.addPending(g),e.patchSession(n.id,{waitingOn:g.id}),l({level:"alert",ticketId:g.ticketId,text:"Decision request · waiting on you",signal:!0}),e.awaitAnswer(g.id)},done(c=!0,d,h){e.patchSession(n.id,{status:c?"done":"failed",endedAt:Date.now(),waitingOn:void 0}),e.dropPending(n.id),l({level:c?"ok":"alert",text:d??(c?"Session closed":"Session aborted"),signal:h==null?void 0:h.signal})},bindMap(c){var h;const d=o().usage;d&&(e.addMapUsage(c,d),(h=e.ledger())==null||h.add(c,d,n.id)),e.patchSession(n.id,{mapId:c})},usage(c){var g;const d=o().mapId;(g=e.ledger())==null||g.add(d,c,n.id),e.addMapUsage(d,c);const h=o().usage;e.patchSession(n.id,{usage:{...Fl(h,c),source:c.source??(h==null?void 0:h.source)}})},setUsage(c){var y;const d=o().usage,h=Rh(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 m=o().mapId;(h.inputTokens>0||h.outputTokens>0||h.costUsd>0)&&((y=e.ledger())==null||y.add(m,h,n.id)),e.addMapUsage(m,h),e.patchSession(n.id,{usage:c})},setModel(c,d){const h=o();h.model===c&&h.tier===d||e.patchSession(n.id,{model:c,tier:d})}}}class Xv{constructor(n=400,r){ue(this,"state",{sessions:[],feed:[],chats:[],pending:[],answered:[],usageByMap:{}});ue(this,"changes",new Os);ue(this,"resolvers",new Map);ue(this,"remote",new Map);ue(this,"remoteAnswer");ue(this,"host",{find:n=>this.state.sessions.find(r=>r.id===n),patchSession:(n,r)=>this.patchSession(n,r),push:n=>void this.push(n),chat:n=>this.chat(n),addPending:n=>this.set({pending:[...this.state.pending,n]}),dropPending:n=>{this.state.pending.filter(o=>o.sessionId===n).length&&this.set({pending:this.state.pending.filter(o=>o.sessionId!==n)})},awaitAnswer:n=>new Promise(r=>this.resolvers.set(n,r)),addMapUsage:(n,r)=>{this.state={...this.state,usageByMap:{...this.state.usageByMap,[n]:Fl(this.state.usageByMap[n],r)}}},ledger:()=>this.ledger});this.maxFeed=n,this.ledger=r}get snapshot(){return this.state}subscribe(n){return this.changes.on(n)}set(n){this.state={...this.state,...n},this.changes.emit(this.state)}push(n){const r={id:lo("f"),at:n.at??Date.now(),...n};return r.source==="system"&&!r.agent&&(r.agent=ve.assistant.name),this.set({feed:[...this.state.feed,r].slice(-this.maxFeed)}),r}patchSession(n,r){this.set({sessions:this.state.sessions.map(o=>o.id===n?{...o,...r}:o)})}chat(n){this.set({chats:[...this.state.chats,{id:lo("m"),at:Date.now(),...n}].slice(-600)})}answer(n,r,o){const l=this.state.pending.find(h=>h.id===n),c=this.resolvers.get(n),d=!!l&&this.remote.has(l.sessionId)&&!!this.remoteAnswer;return!l||!c&&!d?!1:(this.resolvers.delete(n),this.chat({sessionId:l.sessionId,ticketId:l.ticketId,from:"human",author:o,text:r}),this.set({pending:this.state.pending.filter(h=>h.id!==n),answered:[...this.state.answered,{id:l.id,mapId:l.mapId,sessionId:l.sessionId,agent:l.agent,askedAt:l.at,answeredAt:Date.now()}].slice(-200)}),this.patchSession(l.sessionId,{waitingOn:void 0}),this.push({source:"trail lead",agent:o,level:"ok",ticketId:l.ticketId,sessionId:l.sessionId,text:`Answered ${l.agent}`}),c?c(r):this.remoteAnswer(l,r,o),!0)}syncRemote(n){var m;const{session:r}=n,o=r.id;if(!this.remote.has(o)&&this.state.sessions.some(y=>y.id===o))return;const l=this.remote.get(o);this.remote.set(o,r.mapId?r.usage:l);let c=this.state.usageByMap;if(r.usage&&r.mapId){const y=Rh(r.usage,l);(y.inputTokens||y.outputTokens||y.costUsd)&&(c={...c,[r.mapId]:Fl(c[r.mapId],y)}),(m=this.ledger)==null||m.addTotal(r.mapId,o,r.usage)}const d=y=>y.filter(v=>v.sessionId!==o),h=new Set(this.state.answered.map(y=>y.id)),g=this.state.sessions.some(y=>y.id===o)?this.state.sessions.map(y=>y.id===o?r:y):[...this.state.sessions,r].slice(-24);this.set({sessions:g,chats:[...d(this.state.chats),...n.chats].sort((y,v)=>y.at-v.at).slice(-600),pending:[...d(this.state.pending),...n.pending],answered:[...this.state.answered,...n.answered.filter(y=>!h.has(y.id))].sort((y,v)=>y.answeredAt-v.answeredAt).slice(-200),feed:[...this.state.feed.filter(y=>y.sessionId!==o),...n.feed].sort((y,v)=>y.at-v.at).slice(-this.maxFeed),usageByMap:c})}isRemote(n){return this.remote.has(n)}startSession(n){const r={...n,id:n.id??lo("s"),step:0,total:$o[n.mode].length,stepLabel:"BOOT",status:"running",startedAt:Date.now()};this.set({sessions:[...this.state.sessions,r].slice(-24)});const o=Jv(this.host,r,n.mode);return this.push({source:"session",sessionId:r.id,agent:r.agent,level:"info",text:`Session opened · ${n.mode}`}),o}}function Zv(e,n){const r=o=>{var l;return((l=n(o))==null?void 0:l.key)??o};switch(e.kind){case"map.created":return{source:"tracker",level:"ok",text:`Trail created · label ${tc}`};case"map.updated":return{source:"tracker",level:"info",text:`Trail updated${e.section?` · ${vv[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 ${r(e.ticketId)}`};case"ticket.claimed":return{source:"tracker",level:"warn",ticketId:e.ticketId,text:`Assigned ${r(e.ticketId)} to ${e.assignee}`};case"ticket.released":return{source:"tracker",level:"info",ticketId:e.ticketId,text:`Unassigned ${r(e.ticketId)}`};case"ticket.closed":return{source:"tracker",level:e.reason==="completed"?"ok":"alert",ticketId:e.ticketId,text:`Closed ${r(e.ticketId)} · ${e.reason==="completed"?"completed":"not planned"}`};case"ticket.commented":return{source:"tracker",level:"info",ticketId:e.ticketId,text:`Comment on ${r(e.ticketId)}`};case"edge.added":return{source:"tracker",level:"info",ticketId:e.blockedId,text:`${r(e.blockerId)} blocks ${r(e.blockedId)}`};case"edge.removed":return{source:"tracker",level:"info",ticketId:e.blockedId,text:`${r(e.blockerId)} no longer blocks ${r(e.blockedId)}`};case"decision.recorded":return{source:"tracker",level:"ok",ticketId:e.ticketId,text:`Decision ${e.decisionId} recorded${e.ticketId?` · ${r(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 ek=new Set(["createMap","setMapMode","setMapMeta","updateMapSections","createTicket","addBlocking","removeBlocking","editTicket","reopen","assign","comment","close","setMeta","createDecision","markSuperseded"]),tk=5*6e4;function nk(e){let n={status:"idle",inflight:0,writes:0,errors:0,events:[]};const r=new Os,o=c=>{n={...n,...c},r.emit(n)};return e.subscribe(c=>{const d=c.at-tk;o({events:[...n.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 g=Reflect.get(c,d,h);return typeof g!="function"?g:ek.has(d)?async(...m)=>{const y=Date.now();o({inflight:n.inflight+1,status:"syncing"});try{const v=await g.apply(c,m),j=n.inflight-1;return o({inflight:j,writes:n.writes+1,lastWriteMs:Date.now()-y,lastWriteAt:Date.now(),status:j?"syncing":"ok",lastError:void 0}),v}catch(v){const j=n.inflight-1;throw o({inflight:j,errors:n.errors+1,status:"error",lastError:String(v.message??v)}),v}}:g.bind(c)}}),get health(){return n},subscribe:c=>r.on(c)}}function _h(e){const n={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 r of Bs(e.tickets,e.map.mode).values())n[r]++;return n.resolvedPct=n.total?Math.round((n.decided+n["out-of-scope"])/n.total*100):0,n}function Ph(e){const n=_h(e);return{decided:n.decided,total:n.total-n["out-of-scope"]}}function sk(e){return fo.map(n=>{const r=e.tickets.filter(o=>o.type===n);return{type:n,open:r.filter(o=>o.state==="open").length,closed:r.filter(o=>o.state==="closed").length}}).filter(n=>n.open+n.closed>0)}function ik(e,n){const r=e.pending.filter(l=>!0),o=e.answered.filter(l=>!0);return{open:r.length,oldestAt:r.length?Math.min(...r.map(l=>l.at)):void 0,answered:o.length,avgWaitMs:o.length?o.reduce((l,c)=>l+(c.answeredAt-c.askedAt),0)/o.length:void 0}}function Dh(e,n){return n&&e.usageByMap[n]||{inputTokens:0,outputTokens:0,costUsd:0}}const rk=e=>e.usage?e.usage.inputTokens+e.usage.outputTokens:0,Bh={"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 zh(e,n){var o;const r=new Set;for(const l of e.sessions)n&&l.mapId===n&&((o=l.usage)!=null&&o.source)&&r.add(l.usage.source);return[...r].sort()}function ok(e,n){const r=new Set(n.map(l=>l.ticketId).filter(Boolean)),o=e.tickets.filter(l=>l.state==="closed"&&l.closeReason==="completed"&&!r.has(l.id)).map(l=>{var y;const c=[...l.comments].reverse().find(v=>v.body.startsWith("**Resolution**")),d=c?c.body.replace(/^\*\*Resolution\*\*\s*/,""):((y=e.map.sections.decisions.find(v=>v.ticketId===l.id||v.ticketKey===l.key))==null?void 0:y.text)??"",h=(c==null?void 0:c.author)??l.assignee??"unknown",g=l.comments.find(v=>v.body.startsWith("**HITL transcript**")),m=g?g.body.replace(/^\*\*HITL transcript\*\*\s*/,"").split(/\n\n(?=\*\*[^*]+:\*\* )/).map(v=>v.match(/^\*\*([^*]+):\*\* ([\s\S]*)$/)).filter(v=>!!v).map(v=>({from:v[1]===h?"agent":"human",author:v[1],text:v[2].trim(),at:g.createdAt})):[];return{id:`T${l.key}`,mapId:e.map.id,ticketId:l.id,ticketKey:l.key,question:l.title,answer:d,summary:Eo(d),alternatives:[],rationale:"",decidedBy:h,decidedAt:l.closedAt??(c==null?void 0:c.createdAt)??l.updatedAt,participants:[...new Set([h,...m.map(v=>v.author)])].map(v=>({id:v})),source:{kind:"tracker",ref:`${e.map.id}/tickets/${l.id}`,label:`${l.key} resolution comment`},transcript:m,derived:!0}});return[...n,...o].sort((l,c)=>c.decidedAt-l.decidedAt)}function ak(e,n){var o;const r=(o=n.query)==null?void 0:o.trim().toLowerCase();return e.filter(l=>(!n.mapId||l.mapId===n.mapId)&&(!n.source||l.source.kind===n.source)&&(!n.decidedBy||l.decidedBy===n.decidedBy)&&(!n.madeBy||Li(l)===n.madeBy)&&(!n.status||Di(l)===n.status)&&(!r||[l.id,l.ticketKey,l.question,l.answer,l.summary,l.rationale,l.decidedBy,...l.alternatives,...l.transcript.map(c=>c.text)].join(`
|
|
74
|
+
`).toLowerCase().includes(r)))}function lk(e,n=Date.now()){const r=Object.fromEntries(ho.map(d=>[d,0]));let o=0,l=0,c=0;for(const d of e)r[d.source.kind]++,d.supersededBy&&o++,n-d.decidedAt<864e5&&l++,(Li(d)==="human"||d.transcript.some(h=>h.from==="human"))&&c++;return{total:e.length,active:e.length-o,superseded:o,last24h:l,human:c,bySource:r}}function Mo(e){const n=e.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);if(!n)return{front:{},body:e};const r={};for(const o of n[1].split(`
|
|
75
|
+
`)){const l=o.indexOf(":");if(l<0)continue;const c=o.slice(0,l).trim(),d=o.slice(l+1).trim();r[c]=d.startsWith("[")?uk(d.slice(1,-1)).map(If).filter(Boolean):If(d)}return{front:r,body:n[2]}}const ck=e=>e===""||/^[\s#&*!|>'"%@`[\]{},?:-]|[:#]\s|\s$|,/.test(e)||/^(true|false|null|~|\d[\d.e+-]*)$/i.test(e),Mf=e=>ck(e)?JSON.stringify(e):e;function If(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 uk(e){const n=[];let r="",o=!1;for(const l of e)l==='"'&&(o=!o),l===","&&!o?(n.push(r.trim()),r=""):r+=l;return r.trim()&&n.push(r.trim()),n}function ac(e,n){return`---
|
|
76
|
+
${Object.entries(e).map(([o,l])=>`${o}: ${Array.isArray(l)?`[${l.map(Mf).join(", ")}]`:Mf(l)}`).join(`
|
|
77
|
+
`)}
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
${n.trim()}
|
|
81
|
+
`}const xe=e=>Array.isArray(e)?e.join(","):e??"";function zt(e){return Array.isArray(e)?e:e?[e]:[]}const As=e=>Date.parse(xe(e))||0,Qt=e=>new Date(e).toISOString(),Fh=["schema","breaking-api","auth-permissions","billing","data-deletion","product-behaviour","dependencies"],Uh=["low","medium","high"],dk=e=>Fh.includes(e),fk=e=>Uh.includes(e);function hk(e){return e?{risk:e.level,...e.category?{risk_category:e.category}:{},risk_reason:e.reason}:{}}function mk(e){const n=xe(e.risk);if(!fk(n))return{};const r=xe(e.risk_category);return{risk:{level:n,...dk(r)?{category:r}:{},reason:xe(e.risk_reason)}}}const pk=["Question","Decision","Summary","Alternatives","Rationale","Transcript"],gk=e=>e.name?`${e.id}|${e.name}`:e.id,vk=e=>{const n=e.indexOf("|");return n<0?{id:e}:{id:e.slice(0,n),name:e.slice(n+1)}};function Af(e){var c;const n={id:e.id,trail:e.mapId,...e.ticketId?{ticket:e.ticketId,ticket_key:e.ticketKey??""}:{},decided_by:e.decidedBy,decided_at:Qt(e.decidedAt),participants:e.participants.map(gk),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}:{},...hk(e.risk),...(c=e.assumes)!=null&&c.length?{assumes:e.assumes}:{}},r=d=>d.length?d.map(h=>`- ${h}`).join(`
|
|
82
|
+
`):"_None._",o=e.transcript.length?e.transcript.map(d=>`### ${d.author} · ${d.from} @ ${Qt(d.at)}
|
|
83
|
+
|
|
84
|
+
${d.text.trim()}`).join(`
|
|
85
|
+
|
|
86
|
+
`):"_None._",l=[`## Question
|
|
87
|
+
|
|
88
|
+
${e.question.trim()}`,`## Decision
|
|
89
|
+
|
|
90
|
+
${e.answer.trim()}`,`## Summary
|
|
91
|
+
|
|
92
|
+
${e.summary.trim()}`,`## Alternatives
|
|
93
|
+
|
|
94
|
+
${r(e.alternatives)}`,`## Rationale
|
|
95
|
+
|
|
96
|
+
${e.rationale.trim()||"_None._"}`,`## Transcript
|
|
97
|
+
|
|
98
|
+
${o}`].join(`
|
|
99
|
+
|
|
100
|
+
`);return ac(n,l)}function Ul(e){const{front:n,body:r}=Mo(e),o={},l=new RegExp(`^## (${pk.join("|")})\\s*$`,"gm"),c=[...r.matchAll(l)];c.forEach((v,j)=>{var E;const w=r.slice(v.index+v[0].length,((E=c[j+1])==null?void 0:E.index)??r.length).trim();o[v[1]]=/^_none\._$/i.test(w)?"":w});const d=(o.Transcript??"").split(/^### /m).slice(1).map(v=>{const j=v.indexOf(`
|
|
101
|
+
`),w=j<0?v:v.slice(0,j),[E,N=""]=w.split(" @ "),[$,I="agent"]=E.split(" · ");return{author:$.trim(),from:["agent","human","system"].includes(I.trim())?I.trim():"agent",at:Date.parse(N)||0,text:j<0?"":v.slice(j+1).trim()}}),h=xe(n.source),g=zt(n.source_meta),m={kind:Pv(h)?h:"tracker",...xe(n.source_ref)?{ref:xe(n.source_ref)}:{},...xe(n.source_url)?{url:xe(n.source_url)}:{},...xe(n.source_label)?{label:xe(n.source_label)}:{},...g.length?{meta:Object.fromEntries(g.map(v=>[v.slice(0,v.indexOf("=")),v.slice(v.indexOf("=")+1)]))}:{}},y=o.Decision??"";return{id:xe(n.id),mapId:xe(n.trail),ticketId:xe(n.ticket)||void 0,ticketKey:xe(n.ticket_key)||void 0,question:o.Question??"",answer:y,summary:o.Summary||Eo(y),alternatives:(o.Alternatives??"").split(`
|
|
102
|
+
`).map(v=>v.trim()).filter(v=>v.startsWith("- ")).map(v=>v.slice(2)),rationale:o.Rationale??"",decidedBy:xe(n.decided_by),decidedAt:As(n.decided_at),participants:zt(n.participants).map(vk),source:m,supersedes:xe(n.supersedes)||void 0,supersededBy:xe(n.superseded_by)||void 0,...zt(n.assumes).length?{assumes:zt(n.assumes)}:{},transcript:d,...mk(n)}}function kk(e){return e.url?` · [${e.label??"link"}](${e.url})`:e.label?` · ${e.label}`:""}function yk(e,n,r={}){const o=[`# ${r.title??"Decisions"}`,"",`Exported ${Qt(r.now??Date.now())} · ${e.length} decisions`],l=new Map;for(const c of e)l.set(c.mapId,[...l.get(c.mapId)??[],c]);for(const[c,d]of l){const h=n[c];o.push("",`## Trail ${h?`${h.key} ${h.title}`:c}`);for(const g of d){const m=Ln[g.source.kind].label;o.push("",`### ${g.id}${g.ticketKey?` · ${g.ticketKey}`:""} · ${g.question}`,"",`- **Status:** ${Di(g)}${g.supersededBy?` (superseded by ${g.supersededBy})`:""}${g.supersedes?` · supersedes ${g.supersedes}`:""}`,`- **Decided by:** ${g.decidedBy} · ${Qt(g.decidedAt)}`,`- **Source:** ${m}${kk(g.source)}`,...g.participants.length?[`- **Participants:** ${g.participants.map(y=>y.name??y.id).join(", ")}`]:[],"",`**Decision:** ${g.answer}`,...g.alternatives.length?["","**Alternatives:**",...g.alternatives.map(y=>`- ${y}`)]:[],...g.rationale?["",`**Rationale:** ${g.rationale}`]:[],...g.transcript.length?["","<details><summary>Transcript</summary>","",...g.transcript.map(y=>`> **${y.author}:** ${y.text.replace(/\n/g,`
|
|
103
|
+
> `)}
|
|
104
|
+
>`),"","</details>"]:[])}}return o.join(`
|
|
105
|
+
`)+`
|
|
106
|
+
`}function Wl(e,n,r){try{const o=e.get(n);return o?JSON.parse(o):r}catch{return r}}class Of{constructor(n,r="presence"){ue(this,"seen");this.store=n,this.key=r,this.seen=Wl(n,r,{})}snapshot(){return{...this.seen}}lastSeen(n){return this.seen[n]}lastSeenAny(){const n=Object.values(this.seen);return n.length?Math.max(...n):void 0}markSeen(n,r=Date.now()){let o=!1;for(const l of n)(this.seen[l]??0)>=r||(this.seen[l]=r,o=!0);o&&this.store.set(this.key,JSON.stringify(this.seen))}}const Rl=5*6e4,xk=14*864e5;class Lf{constructor(n,r="usage"){ue(this,"buckets");ue(this,"dirty",!1);ue(this,"timer");ue(this,"totals");this.store=n,this.key=r,this.buckets=Wl(n,r,{}),this.totals=Wl(n,`${r}.totals`,{})}addTotal(n,r,o,l=Date.now()){const c=this.totals[r],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[r]={...o,at:l},d.inputTokens>0||d.outputTokens>0||d.costUsd>0?this.add(n,d,r,l):this.save()}add(n,r,o,l=Date.now()){var g;if(!n)return;const c=Math.floor(l/Rl)*Rl,d=(g=this.buckets)[n]??(g[n]=[]);let h=d.find(m=>m.at===c);h||(h={at:c,i:0,o:0,c:0,s:[]},d.push(h),d.sort((m,y)=>m.at-y.at)),h.i+=r.inputTokens,h.o+=r.outputTokens,h.c+=r.costUsd,h.s.includes(o)||h.s.push(o),this.save()}since(n,r){const o={inputTokens:0,outputTokens:0,costUsd:0,sessions:0},l=new Set;for(const c of this.buckets[n]??[])c.at+Rl<=r||(o.inputTokens+=c.i,o.outputTokens+=c.o,o.costUsd+=c.c,c.s.forEach(d=>l.add(d)));return o.sessions=l.size,o}save(){this.dirty=!0,!this.timer&&(this.timer=setTimeout(()=>{if(this.timer=void 0,!this.dirty)return;this.dirty=!1;const n=Date.now()-xk;for(const r of Object.keys(this.buckets))this.buckets[r]=this.buckets[r].filter(o=>o.at>=n);for(const[r,o]of Object.entries(this.totals))o.at<n&&delete this.totals[r];this.store.set(this.key,JSON.stringify(this.buckets)),this.store.set(`${this.key}.totals`,JSON.stringify(this.totals))},2e3))}}function wk(e){const n=e.now??Date.now(),r=e.snaps.map(d=>{var oe;const h=d.map.id,g=e.since(h),m=G=>!!G&&G>=g,y=Bs(d.tickets,d.map.mode),v=new Map(d.tickets.map(G=>[G.id,G])),j=(e.attention??[]).filter(G=>G.mapId===h),w=jk(e.activity.pending.filter(G=>G.mapId===h),j),E=new Set(w.map(G=>G.ticketId)),N=G=>G.state==="open"&&(E.has(G.id)||Pi(G)==="hitl"),$=d.tickets.filter(G=>y.get(G.id)==="blocked").map(G=>({ticket:G,on:G.blockedBy.map(ge=>v.get(ge)).filter(ge=>!!ge&&N(ge))})).filter(G=>G.on.length),I=e.decisions.filter(G=>G.mapId===h&&m(G.decidedAt)).sort((G,ge)=>ge.decidedAt-G.decidedAt),R=d.tickets.filter(G=>G.state==="closed"&&m(G.closedAt)).sort((G,ge)=>(G.closedAt??0)-(ge.closedAt??0)),O=R.filter(G=>G.closeReason==="completed"),te=R.filter(G=>G.closeReason==="not_planned"),se=d.tickets.filter(G=>m(G.createdAt)),F=((oe=e.ledger)==null?void 0:oe.since(h,g))??{inputTokens:0,outputTokens:0,costUsd:0,sessions:0},ie=e.activity.sessions.filter(G=>G.mapId===h&&G.status==="running");return{mapId:h,key:d.map.key,title:d.map.title,since:g,done:O,ruledOut:te,opened:se,blocked:$,waiting:w,needsYou:j,decisions:I,agentDecisions:I.filter(G=>Li(G)==="agent"),usage:F,active:ie,changed:!!(R.length||se.length||I.length||w.some(G=>m(G.at))||F.costUsd>0)}}),o=r.filter(d=>d.changed||d.waiting.length).sort((d,h)=>+(h.mapId===e.currentMapId)-+(d.mapId===e.currentMapId)),l=d=>o.reduce((h,g)=>h+g[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)):n,now:n,trails:o,totals:{done:l("done"),ruledOut:l("ruledOut"),blocked:l("blocked"),waiting:l("waiting"),oldestWaitMs:c===void 0?void 0:n-c,agentDecisions:l("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:l("active")},changed:r.some(d=>d.changed)}}function jk(e,n){const r=new Map(n.filter(l=>l.kind==="question").map((l,c)=>[l.ref,c])),o=l=>r.get(l.id)??Number.MAX_SAFE_INTEGER;return[...e].sort((l,c)=>o(l)-o(c)||l.at-c.at)}const Ii=(e,n,r=`${n}s`)=>`${e} ${e===1?n:r}`;function Sk(e){return e.trails.flatMap(n=>{const r=new Set(n.waiting.map(o=>o.ticketId));return n.blocked.filter(o=>o.on.some(l=>r.has(l.id)))})}function Nk(e){return e.length===1?`, and it holds up ${e[0].ticket.title.replace(/^./,n=>n.toLowerCase())}`:e.length>1?`, holding up ${Ii(e.length,"ticket")}`:""}function bk(e,n=new Date(e.now).getHours()){const r=e.totals,l=e.now-e.since>=6*36e5&&n>=5&&n<12?"Good morning.":"Welcome back.",c=[];if(r.done&&c.push(`${Ii(r.done,"ticket")} ${r.done===1?"is":"are"} done.`),r.agentDecisions&&c.push(`Agents made ${Ii(r.agentDecisions,"decision")}.`),r.waiting){const d=Nk(Sk(e));c.push(`${Ii(r.waiting,"decision")} ${r.waiting===1?"is":"are"} waiting on you${d}.`)}else c.push("Nothing is waiting on you.");return!r.done&&!r.agentDecisions&&r.ruledOut&&c.unshift(`${Ii(r.ruledOut,"ticket")} ruled out of scope.`),[l,...c].join(" ")}const Ck=e=>{if(!e.length)return;const n=[...e].sort((o,l)=>o-l),r=Math.floor(n.length/2);return n.length%2?n[r]:Math.round((n[r-1]+n[r])/2)};function $k(e){return e.state==="open"?"open":e.closeReason==="not_planned"?"cancelled":"done"}function Wh({snap:e,journal:n,answered:r,usage:o}){const l=e.map.id,c=n.filter(N=>N.mapId===l).sort((N,$)=>N.at-$.at),d=new Map;for(const N of c)d.set(N.ticketId,[...d.get(N.ticketId)??[],N]);const h=e.tickets.filter(N=>N.type!=="review").map(N=>{var te;const $=d.get(N.id)??[],I=$k(N),R=(te=$.find(se=>se.event==="claim"))==null?void 0:te.at,O=I==="done"?N.closedAt:void 0;return{id:N.id,key:N.key,title:N.title,type:N.type,outcome:I,claimedAt:R,doneAt:O,leadMs:O&&R&&O>=R?O-R:void 0,reworks:$.filter(se=>se.to==="rework").length,reviews:{passed:$.filter(se=>se.event==="review.pass").length,failed:$.filter(se=>se.event==="review.fail").length,needsHuman:$.filter(se=>se.event==="review.needs_human").length},operatorActions:$.filter(se=>se.actorKind==="trail lead").length}}),g=h.filter(N=>N.outcome==="done"),m=Math.max(0,...g.map(N=>N.doneAt??0)),y=c.filter(N=>N.actorKind==="trail lead"),v=new Set(r.filter(N=>N.mapId===l).map(N=>N.id)).size,j=y.length,w=N=>h.reduce(($,I)=>$+N(I),0),E=(o==null?void 0:o.costUsd)??0;return{mapId:l,tickets:h,done:g.length,cancelled:h.filter(N=>N.outcome==="cancelled").length,open:h.filter(N=>N.outcome==="open").length,trailLeadMs:m&&m>=e.map.createdAt?m-e.map.createdAt:void 0,medianLeadMs:Ck(g.flatMap(N=>N.leadMs===void 0?[]:[N.leadMs])),interventions:{answers:v,operatorActions:j,reworkRequested:y.filter(N=>N.event==="reject").length,total:v+j},rework:{tickets:h.filter(N=>N.reworks>0).length,cycles:w(N=>N.reworks)},reviews:{passed:w(N=>N.reviews.passed),failed:w(N=>N.reviews.failed),needsHuman:w(N=>N.reviews.needsHuman)},spend:{costUsd:Math.round(E*1e4)/1e4,tokens:((o==null?void 0:o.inputTokens)??0)+((o==null?void 0:o.outputTokens)??0),perVerifiedTicketUsd:g.length&&E?Math.round(E/g.length*1e4)/1e4:void 0}}}const _l=e=>e.split("-")[0];function Jt(e){if(e===void 0)return"—";const n=Math.round(e/6e4);if(n<90)return`${n} min`;const r=e/36e5;return r<48?`${Math.round(r*10)/10} h`:`${Math.round(r/24*10)/10} d`}const Rf=e=>e===void 0?"—":`$${e.toFixed(e<1?4:2)}`;function Tk(e,n,r=Date.now()){const o=e.interventions;return[`# Trail report: ${n}`,"",`_Generated ${new Date(r).toISOString()} by Teamtrail._`,"","| Measure | Value |","| --- | --- |",`| Tickets done / cancelled / open | ${e.done} / ${e.cancelled} / ${e.open} |`,`| Trail lead time (created → last done) | ${Jt(e.trailLeadMs)} |`,`| Median ticket lead time (claim → done) | ${Jt(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 | ${Rf(e.spend.costUsd)} · ${e.spend.tokens.toLocaleString("en-US")} tokens |`,`| Cost per verified ticket | ${Rf(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} | ${Jt(c.leadMs)} | ${c.reworks} | ${c.reviews.passed}/${c.reviews.failed} | ${c.operatorActions} |`),""].join(`
|
|
107
|
+
`)}const lc=5,Hh=1.5,Ek=15,Zr=e=>Math.round(e*100);function Mk(e){const n=e.filter(d=>d.findings.raised>=lc).sort((d,h)=>h.findings.upheld/h.findings.raised-d.findings.upheld/d.findings.raised||d.key.localeCompare(h.key));if(n.length<2)return[];const[r,o]=[n[0],n[n.length-1]],[l,c]=[r.findings.upheld/r.findings.raised,o.findings.upheld/o.findings.raised];return Zr(l)-Zr(c)<Ek?[]:[{id:"review-findings",text:`${r.key} review findings upheld ${Zr(l)}% vs ${o.key} ${Zr(c)}%`,because:`${r.findings.upheld} of ${r.findings.raised} and ${o.findings.upheld} of ${o.findings.raised} failed reviews stood; a finding is overruled when you accept the work anyway`}]}function Ik(e){const n=c=>c.reworkCycles/c.tickets,r=e.filter(c=>c.tickets>=lc).sort((c,d)=>n(c)-n(d)||c.key.localeCompare(d.key));if(r.length<2)return[];const[o,l]=[r[0],r[r.length-1]];return n(l)-n(o)<.2||n(l)<n(o)*Hh?[]:[{id:"rework",text:`${l.key} work goes back to rework more: ${n(l).toFixed(1)} times per ticket vs ${o.key} ${n(o).toFixed(1)}`,because:`${l.reworkCycles} cycles on ${l.tickets} tickets, and ${o.reworkCycles} on ${o.tickets}`}]}function Ak(e,n){const r=d=>d.medianLeadMs??0,o=n.filter(d=>d.done>=lc&&d.medianLeadMs!==void 0).sort((d,h)=>r(d)-r(h)||d.key.localeCompare(h.key));if(o.length<2)return[];const[l,c]=[o[0],o[o.length-1]];return r(c)<r(l)*Hh?[]:[{id:`speed-${e}`,text:`${e} tickets: ${l.key} is faster, ${Jt(l.medianLeadMs)} vs ${c.key} ${Jt(c.medianLeadMs)}`,because:`Median first claim to done, over ${l.done} and ${c.done} done tickets`}]}function Ok(e){const n=Object.keys(e.byTypeAndVendor).sort();return[...Mk(e.byVendor),...Ik(e.byVendor),...n.flatMap(r=>Ak(r,e.byTypeAndVendor[r]))]}const Lk=e=>{if(!e.length)return;const n=[...e].sort((o,l)=>o-l),r=Math.floor(n.length/2);return n.length%2?n[r]:Math.round((n[r-1]+n[r])/2)},Vh=e=>{var n;return(n=e.filter(r=>r.event==="claim"&&r.actorKind==="agent").at(-1))==null?void 0:n.actor},Hl=(e,n,r)=>e.filter(o=>o.mapId===n&&o.ticketId===r).sort((o,l)=>o.at-l.at);function Rk(e,n){return e.tickets.flatMap(r=>{var v;if(r.type!=="review"||!r.reviewOf)return[];const o=Hl(n,e.map.id,r.id),l=Vh(o);if(!l)return[];const c=((v=o.filter(j=>j.event==="claim").at(-1))==null?void 0:v.at)??0,d=Hl(n,e.map.id,r.reviewOf),h=d.findIndex(j=>j.at>=c&&j.event.startsWith("review."));if(h<0||d[h].event!=="review.fail")return[];const g=d.slice(h+1),m=g.findIndex(j=>j.event.startsWith("review.")),y=m<0?g:g.slice(0,m);return[{reviewer:l,upheld:!y.some(j=>j.event==="accept"&&j.actorKind==="trail lead")}]})}function _k(e,n){var o;const r=(o=e.tickets.find(l=>l.id===n))==null?void 0:o.assignee;return r&&/^[a-z]+-\d+$/.test(r)?r:void 0}function Kh(e,n){const r=l=>n.reduce((c,{ticket:d})=>c+l(d),0),o=l=>n.filter(c=>c.ticket.outcome===l).length;return{key:e,tickets:n.length,done:o("done"),cancelled:o("cancelled"),open:o("open"),medianLeadMs:Lk(n.flatMap(({ticket:l})=>l.leadMs===void 0?[]:[l.leadMs])),reworkCycles:r(l=>l.reworks),reviews:{passed:r(l=>l.reviews.passed),failed:r(l=>l.reviews.failed),needsHuman:r(l=>l.reviews.needsHuman)},answers:0,findings:{raised:0,upheld:0}}}function eo(e,n){const r=new Map;for(const o of e){const l=n(o);l&&r.set(l,[...r.get(l)??[],o])}return new Map([...r].map(([o,l])=>[o,Kh(o,l)]))}const Vl=(e,n)=>{const r=e.get(n)??Kh(n,[]);return e.set(n,r),r};function _f(e,n,r){const o=Vl(e,n);o.findings.raised+=1,r&&(o.findings.upheld+=1)}const to=e=>[...e.values()].sort((n,r)=>r.tickets-n.tickets||n.key.localeCompare(r.key));function Gh(e){const n=e.flatMap(({snap:m,journal:y,answered:v,usage:j})=>Wh({snap:m,journal:y,answered:v,usage:j}).tickets.map(w=>({ticket:w,agent:Vh(Hl(y,m.map.id,w.id))??_k(m,w.id)}))),r=m=>m.agent?_l(m.agent):void 0,o=eo(n,m=>m.agent),l=eo(n,r),c=eo(n,m=>m.ticket.type),d=new Set;for(const{snap:m,journal:y,answered:v}of e){for(const j of v){const w=`${j.mapId}/${j.id}`;j.mapId!==m.map.id||d.has(w)||(d.add(w),Vl(o,j.agent).answers+=1,Vl(l,_l(j.agent)).answers+=1)}for(const j of Rk(m,y))_f(o,j.reviewer,j.upheld),_f(l,_l(j.reviewer),j.upheld)}const h=Object.fromEntries([...c.keys()].map(m=>[m,to(eo(n.filter(y=>y.ticket.type===m),r))])),g={trails:e.length,tickets:n.length,byAgent:to(o),byVendor:to(l),byType:to(c),byTypeAndVendor:h};return{...g,recommendations:Ok(g)}}const Pk={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(`
|
|
108
|
+
`)},Dk=[["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"]],Ei=Object.fromEntries(Dk);function Bk(e,n){const r=new Set(e.map(o=>o.source).filter(Boolean));return n.filter(o=>!r.has(o))}const zk=["architecture","convention","gotcha","dead-end","glossary","fact"],Qh=["business-rule","product-decision","persona","ux-principle","pricing"],Fk=[...zk,...Qh],Uk=e=>e.status==="confirmed"||e.status==="assumption";function Wk(e,n){const r=e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*\//g,"§DIRS§").replace(/\*\*/g,"§DEEP§").replace(/\*/g,"[^/]*").replace(/§DIRS§/g,"(?:.*/)?").replace(/§DEEP§/g,".*");return new RegExp(`^${r}$`).test(n.replace(/^\.\//,""))}const Hk={"business-rule":3,convention:3,"product-decision":2,architecture:2,gotcha:2,"dead-end":2,"ux-principle":2},Vk=["business-rule","ux-principle","convention"],Pf=600,Kk=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(" ")),Df=e=>new Set((e.toLowerCase().match(/[a-z0-9][a-z0-9_-]{2,}/g)??[]).filter(n=>!Kk.has(n)));function qh(e,n,r=4e3,o=()=>[]){const l=n.ticket?Df(`${n.ticket.title} ${n.ticket.body}`):new Set,c=new Set((n.tags??[]).map(m=>m.toLowerCase())),d=e.filter(Uk).map(m=>{const y=[];let v=Hk[m.kind]??1;for(const E of m.scope){const N=n.paths.find($=>Wk(E,$));if(N){v+=6,y.push(`path match ${E} (${N})`);break}}const j=m.tags.filter(E=>c.has(E.toLowerCase())||l.has(E.toLowerCase()));j.length&&(v+=3*j.length,y.push(`tag ${j.join(", ")}`));const w=[...Df(m.title)].filter(E=>l.has(E));return w.length&&(v+=w.length,y.push(`mentions ${w.slice(0,3).join(", ")}`)),n.trailKey&&m.sources.includes(`trail:${n.trailKey}`)&&(v+=3,y.push("same trail")),n.discovery&&Qh.includes(m.kind)&&(v+=8,y.push("product context for discovery")),!y.length&&Vk.includes(m.kind)&&!m.scope.length&&y.push(`${m.kind.replace("-"," ")} for the whole project`),{e:m,score:v,why:y}}).filter(m=>m.why.length>0).sort((m,y)=>y.score-m.score||m.e.id.localeCompare(y.e.id,void 0,{numeric:!0})),h=[];let g=0;for(const{e:m,why:y}of d){const v=m.body.length>Pf?`${m.body.slice(0,Pf)}…`:m.body;if(g+v.length>r&&h.length)break;g+=v.length;const j=o(m);h.push({id:m.id,title:m.title,kind:m.kind,status:m.status,body:v,why:y,...j.length?{mayBeOutdated:j}:{},...m.flag?{flagged:m.flag.reason}:{}})}return h}const Gk=new RegExp("`([^`\\s]+/[^`\\s]+)`|(?:^|[\\s(])/?((?:[\\w.-]+/)+[\\w.-]+)","gm");function Yh(e){const n=new Set;for(const r of e.matchAll(Gk))n.add((r[1]??r[2]).replace(/^\.?\//,"").replace(/[.,;:]+$/,""));return[...n]}const Qk=[{level:"high",label:"High risk"},{level:"medium",label:"Medium risk"},{level:"low",label:"Low risk"},{level:"none",label:"No category"}];function qk(e){return Qk.map(n=>({...n,decisions:e.filter(r=>{var o;return(((o=r.risk)==null?void 0:o.level)??"none")===n.level})})).filter(n=>n.decisions.length)}const Yk=1/3;function Io(e,n=Date.now()){const r=e.expiresAt-n;return r<=0?"expired":r<=e.ttlMs*Yk?"stalled":"live"}function Jk(e){var n;return((n=e.returned)==null?void 0:n.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 Xk=e=>e.urgency==="fyi"||e.kind==="policy";function Zk(e,n){var o;const r={...e};return n.verification===null?delete r.verification:n.verification&&(r.verification=n.verification),n.guides===null||((o=n.guides)==null?void 0:o.length)===0?delete r.guides:n.guides&&(r.guides=n.guides),n.modelMatching===null?delete r.modelMatching:n.modelMatching&&(r.modelMatching=n.modelMatching),r}function ey(e,n,r){const o=Date.now();return{id:e,key:n,...r,state:"open",blockedBy:[],comments:[],createdAt:o,updatedAt:o}}const ty=(e,n)=>({...e,blockedBy:e.blockedBy.filter(r=>r!==n)}),ny=(e,n)=>{var r;return{...e,...(r=n.title)!=null&&r.trim()?{title:n.title.trim()}:{},...n.body!==void 0?{body:n.body}:{}}};function sy(e){const{closeReason:n,closedAt:r,...o}=e;return{...o,state:"open"}}const iy=["status","verification","checks","reviewOf","guide"];function ry(e,n){const r={...e};for(const o of iy)n[o]!==void 0&&(n[o]===null?delete r[o]:r[o]=n[o]);return r}const oy=/^([^/]+)\/decisions\/([^/]+)\.md$/,ay=(e,n)=>e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,40)||`map-${n}`;class ly{constructor(n,r){ue(this,"seen",new Map);ue(this,"pending",new Map);this.read=n,this.emit=r}knows(n){return this.seen.has(n)}remember(n,r,o){this.seen.set(n,{text:r,supersededBy:o})}queue(n){const r=n.split("/")[0],o=this.pending.get(r)??{paths:new Set,timer:setTimeout(()=>void this.flush(r),250)};o.paths.add(n),this.pending.set(r,o)}async flush(n){const r=this.pending.get(n);if(this.pending.delete(n),!r)return;const o=[...r.paths].filter(d=>oy.test(d)),l=[];for(const d of o){const h=await this.read(d).catch(()=>""),g=this.seen.get(d);if(!h||(g==null?void 0:g.text)===h)continue;const m=Ul(h);this.seen.set(d,{text:h,supersededBy:m.supersededBy}),g?m.supersededBy&&m.supersededBy!==g.supersededBy&&l.push({kind:"decision.superseded",mapId:n,decisionId:m.id,supersededBy:m.supersededBy,external:!0,at:Date.now()}):l.push({kind:"decision.recorded",mapId:n,decisionId:m.id,ticketId:m.ticketId,external:!0,at:Date.now()})}o.length?!l.length&&o.length<r.paths.size&&l.push({kind:"external.changed",mapId:n,at:Date.now()}):l.push({kind:"external.changed",mapId:n,at:Date.now()});const c=d=>d.kind==="decision.recorded"?0:1;l.sort((d,h)=>c(d)-c(h));for(const d of l)this.emit(d)}}function cy(e){const n=e.filter(([r,o])=>Co.includes(r)&&Mh(o));return Object.fromEntries(n)}function uy(e){const n=xe(e["model-matching"]);if(n!=="on"&&n!=="off")return;const r=cy(zt(e["model-tiers"]).map(o=>o.split("=").map(l=>l.trim())));return Object.keys(r).length?{enabled:n==="on",tiers:r}:{enabled:n==="on"}}function dy(e){if(!e)return{};const n=Object.entries(e.tiers??{}).map(([r,o])=>`${r}=${o}`);return{"model-matching":e.enabled?"on":"off",...n.length?{"model-tiers":n}:{}}}function fy(e,n){const{front:r,body:o}=Mo(n),l=$h(xe(r.verification)),c=uy(r);return{id:e,key:xe(r.key)||e,title:xe(r.title)||e,mode:xe(r.mode)==="plan-only"||zt(r.labels).includes(sc)?"plan-only":es,...l?{verification:l}:{},...zt(r.guides).length?{guides:zt(r.guides)}:{},...c?{modelMatching:c}:{},sections:xv(o),createdAt:As(r.created),updatedAt:As(r.updated)}}function hy(e){var n;return ac({key:e.key,title:e.title,mode:e.mode,...e.verification?{verification:e.verification}:{},...(n=e.guides)!=null&&n.length?{guides:e.guides}:{},...dy(e.modelMatching),labels:[tc,...e.mode==="plan-only"?[sc]:[]],created:Qt(e.createdAt),updated:Qt(e.updatedAt)},yv(e.sections))}async function Bf(e){const n=await e.list(),r=n.filter(l=>!l.includes("/decisions/")).map(l=>{var c;return Number(((c=l.match(/(\d+)\.md$/))==null?void 0:c[1])??0)}),o=await Promise.all(n.filter(l=>l.endsWith("/map.md")).map(async l=>Number(xe(Mo(await e.read(l)).front.key).replace(/\D/g,""))||0));return Math.max(0,...r,...o)+1}function zf(e){const{front:n,body:r}=Mo(e),[o,l=""]=r.split(/^## Comments\s*$/m),c=l.split(/^### /m).slice(1).map((m,y)=>{const v=m.indexOf(`
|
|
109
|
+
`),[j,w]=m.slice(0,v).split(" @ ");return{id:`c${y}`,author:j.trim(),createdAt:Date.parse(w)||0,body:m.slice(v+1).trim()}}),d=xe(n.close_reason),h=nv.find(m=>m===xe(n.status)),g=$h(xe(n.verification));return{id:xe(n.id),key:`#${xe(n.id)}`,title:xe(n.title),type:xe(n.type)||"task",hitl:zt(n.labels).includes(nc)||void 0,state:xe(n.state)==="closed"?"closed":"open",closeReason:d==="completed"||d==="not_planned"?d:void 0,assignee:xe(n.assignee)||void 0,...h?{status:h}:{},...g?{verification:g}:{},...n.checks!==void 0?{checks:zt(n.checks)}:{},...xe(n.review_of)?{reviewOf:xe(n.review_of)}:{},...xe(n.guide)?{guide:xe(n.guide)}:{},blockedBy:zt(n.blocked_by),body:o.trim(),comments:c,createdAt:As(n.created),updatedAt:As(n.updated),closedAt:As(n.closed)||void 0}}function my(e){const n={id:e.id,title:e.title,type:e.type,labels:[bo(e.type),...tv(e.type)&&e.hitl?[nc]:[]],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:Qt(e.createdAt),updated:Qt(e.updatedAt),...e.closedAt?{closed:Qt(e.closedAt)}:{}},r=e.comments.length?`
|
|
110
|
+
|
|
111
|
+
## Comments
|
|
112
|
+
|
|
113
|
+
${e.comments.map(o=>`### ${o.author} @ ${Qt(o.createdAt)}
|
|
114
|
+
|
|
115
|
+
${o.body}`).join(`
|
|
116
|
+
|
|
117
|
+
`)}`:"";return ac(n,e.body+r)}class py{constructor(n,r=`./${ve.dataDir}`){ue(this,"kind","markdown");ue(this,"label","Local markdown");ue(this,"events",new Os);ue(this,"selfWrites",new Map);ue(this,"external",new ly(n=>this.fs.read(n),n=>this.events.emit(n)));var o;this.fs=n,this.location=r,(o=n.watch)==null||o.call(n,l=>{const c=this.selfWrites.get(l);c&&Date.now()-c<1500||this.external.queue(l)})}async put(n,r){this.selfWrites.set(n,Date.now()),await this.fs.write(n,r)}async readMap(n){return fy(n,await this.fs.read(`${n}/map.md`))}async writeMap(n){await this.put(`${n.id}/map.md`,hy(n))}async readTicket(n,r){return zf(await this.fs.read(`${n}/tickets/${r}.md`))}async writeTicket(n,r){await this.put(`${n}/tickets/${r.id}.md`,my({...r,updatedAt:Date.now()}))}async listMaps(){const r=(await this.fs.list()).filter(o=>/^[^/]+\/map\.md$/.test(o)).map(o=>o.split("/")[0]);return Promise.all(r.map(async o=>{const l=await this.readMap(o);return{id:o,key:l.key,title:l.title}}))}async loadMap(n){const r=await this.fs.list(),o=await this.readMap(n),l=r.filter(d=>d.startsWith(`${n}/tickets/`)),c=await Promise.all(l.map(async d=>zf(await this.fs.read(d))));return{map:o,tickets:c.sort((d,h)=>d.createdAt-h.createdAt)}}async createMap(n){const r=await Bf(this.fs),o=ay(n.title,r),l={id:o,key:`#${r}`,title:n.title,mode:n.mode??es,...n.verification?{verification:n.verification}:{},sections:n.sections,createdAt:Date.now(),updatedAt:Date.now()};return await this.writeMap(l),this.events.emit({kind:"map.created",mapId:o,at:Date.now()}),l}async editMap(n,r,o){await this.writeMap({...r(await this.readMap(n)),updatedAt:Date.now()}),this.events.emit(o)}setMapMode(n,r){return this.editMap(n,o=>({...o,mode:r}),{kind:"map.mode",mapId:n,mode:r,at:Date.now()})}setMapMeta(n,r){return this.editMap(n,o=>Zk(o,r),{kind:"map.updated",mapId:n,at:Date.now()})}updateMapSections(n,r){const o=Object.keys(r)[0];return this.editMap(n,l=>({...l,sections:{...l.sections,...r}}),{kind:"map.updated",mapId:n,section:o,at:Date.now()})}async createTicket(n,r){const o=await Bf(this.fs),l=ey(String(o),`#${o}`,r);return await this.writeTicket(n,l),this.events.emit({kind:"ticket.created",mapId:n,ticketId:l.id,at:Date.now()}),l}async addBlocking(n,r,o){const l=await this.readTicket(n,o);l.blockedBy.includes(r)||await this.writeTicket(n,{...l,blockedBy:[...l.blockedBy,r]}),this.events.emit({kind:"edge.added",mapId:n,blockerId:r,blockedId:o,at:Date.now()})}async update(n,r,o){await this.writeTicket(n,o(await this.readTicket(n,r)))}async removeBlocking(n,r,o){await this.update(n,o,l=>ty(l,r)),this.events.emit({kind:"edge.removed",mapId:n,blockerId:r,blockedId:o,at:Date.now()})}async editTicket(n,r,o){await this.update(n,r,l=>ny(l,o)),this.events.emit({kind:"ticket.updated",mapId:n,ticketId:r,at:Date.now()})}async reopen(n,r){await this.update(n,r,sy),this.events.emit({kind:"ticket.updated",mapId:n,ticketId:r,at:Date.now()})}async assign(n,r,o){await this.update(n,r,l=>({...l,assignee:o??void 0})),this.events.emit(o?{kind:"ticket.claimed",mapId:n,ticketId:r,assignee:o,at:Date.now()}:{kind:"ticket.released",mapId:n,ticketId:r,at:Date.now()})}async comment(n,r,o,l){await this.update(n,r,c=>({...c,comments:[...c.comments,{id:`c${c.comments.length}`,author:o,body:l,createdAt:Date.now()}]})),this.events.emit({kind:"ticket.commented",mapId:n,ticketId:r,at:Date.now()})}async close(n,r,o){await this.update(n,r,l=>({...l,state:"closed",closeReason:o,closedAt:Date.now()})),this.events.emit({kind:"ticket.closed",mapId:n,ticketId:r,reason:o,at:Date.now()})}async setMeta(n,r,o){await this.update(n,r,l=>ry(l,o)),this.events.emit({kind:"ticket.updated",mapId:n,ticketId:r,at:Date.now()})}async listDecisions(n){const r=(await this.fs.list()).filter(o=>o.startsWith(`${n}/decisions/`));return Promise.all(r.map(async o=>{const l=await this.fs.read(o),c={...Ul(l),mapId:n};return this.external.knows(o)||this.external.remember(o,l,c.supersededBy),c}))}async createDecision(n,r){const o=(await this.fs.list()).filter(h=>h.includes("/decisions/")),l=Math.max(0,...o.map(h=>Bv(h.split("/").pop())))+1,c=Dv(`D-${l}`,n,r),d=Af(c);return this.external.remember(`${n}/decisions/${c.id}.md`,d),await this.put(`${n}/decisions/${c.id}.md`,d),this.events.emit({kind:"decision.recorded",mapId:n,decisionId:c.id,ticketId:c.ticketId,at:Date.now()}),c}async markSuperseded(n,r,o){const l=`${n}/decisions/${r}.md`,c=Ul(await this.fs.read(l)),d=Af({...c,mapId:n,supersededBy:o});this.external.remember(l,d,o),await this.put(l,d),this.events.emit({kind:"decision.superseded",mapId:n,decisionId:r,supersededBy:o,at:Date.now()})}subscribe(n){return this.events.on(n)}}class Ff extends Error{constructor(n,r,o,l){super(r),this.code=n,this.status=o,this.resetAt=l,this.name="TrackerError"}}const gy={github:"GitHub Issues",linear:"Linear"};async function Ai(e,n,r){let o;try{o=await fetch(e,{method:n,headers:{"Content-Type":"application/json"},body:r===void 0?void 0:JSON.stringify(r)})}catch{throw new Ff("offline","Lookout server unreachable; is `teamtrail` still running?")}const l=await o.json().catch(()=>({}));if(!o.ok)throw new Ff(l.code??"http",l.error??`request failed (${o.status})`,o.status,l.resetAt);return l}class vy{constructor(n,r,o=""){ue(this,"label");ue(this,"location");ue(this,"status",{state:"connecting",queued:0});ue(this,"events",new Os);ue(this,"statusEvents",new Os);ue(this,"source");ue(this,"listeners",0);ue(this,"listMaps",()=>this.call("listMaps"));ue(this,"loadMap",n=>this.call("loadMap",n));ue(this,"createMap",n=>this.call("createMap",n));ue(this,"setMapMode",(n,r)=>this.call("setMapMode",n,r));ue(this,"setMapMeta",(n,r)=>this.call("setMapMeta",n,r));ue(this,"updateMapSections",(n,r)=>this.call("updateMapSections",n,r));ue(this,"createTicket",(n,r)=>this.call("createTicket",n,r));ue(this,"addBlocking",(n,r,o)=>this.call("addBlocking",n,r,o));ue(this,"removeBlocking",(n,r,o)=>this.call("removeBlocking",n,r,o));ue(this,"editTicket",(n,r,o)=>this.call("editTicket",n,r,o));ue(this,"reopen",(n,r)=>this.call("reopen",n,r));ue(this,"assign",(n,r,o)=>this.call("assign",n,r,o));ue(this,"comment",(n,r,o,l)=>this.call("comment",n,r,o,l));ue(this,"close",(n,r,o)=>this.call("close",n,r,o));ue(this,"setMeta",(n,r,o)=>this.call("setMeta",n,r,o));ue(this,"listDecisions",n=>this.call("listDecisions",n));ue(this,"createDecision",(n,r)=>this.call("createDecision",n,r));ue(this,"markSuperseded",(n,r,o)=>this.call("markSuperseded",n,r,o));this.kind=n,this.base=r,this.label=gy[n],this.location=o}async call(n,...r){return(await Ai(`${this.base}/tracker/${this.kind}/call`,"POST",{method:n,args:r})).result}open(){const n=new EventSource(`${this.base}/tracker/${this.kind}/events`);n.onmessage=r=>this.events.emit(JSON.parse(r.data)),n.addEventListener("status",r=>{const o=JSON.parse(r.data);o.location&&(this.location=o.location),this.status=o,this.statusEvents.emit(o)}),n.onerror=()=>{this.status.state!=="offline"&&(this.status={...this.status,state:"offline",error:"Lookout server unreachable"},this.statusEvents.emit(this.status))},this.source=n}subscribe(n){const r=this.events.on(n);return++this.listeners===1&&this.open(),()=>{var o;r(),--this.listeners===0&&((o=this.source)==null||o.close(),this.source=void 0)}}onStatus(n){return this.statusEvents.on(n)}}function ky(e){return{get:()=>Ai(`${e}/trackers`,"GET"),test:n=>Ai(`${e}/trackers/test`,"POST",n),connect:n=>Ai(`${e}/trackers`,"PUT",n),forget:n=>Ai(`${e}/trackers/credentials/${n}`,"DELETE")}}const yy=[{id:"markdown",name:"Local markdown",status:"available"},{id:"github",name:"GitHub Issues",status:"available"},{id:"linear",name:"Linear",status:"available"}],Jh=[{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"}],xy=Jh[0];function wy(e,n={}){const r=(n.query??"").toLowerCase().split(/\s+/).filter(Boolean);return e.guides.filter(o=>{if(n.verifiedOnly&&!o.verified&&!o.builtin)return!1;const l=[o.id,o.name??"",o.summary,o.author].join(" ").toLowerCase();return r.every(c=>l.includes(c))})}const jy={ink:"#16302a",shellLight:"#f6f1e2",shell:"#eae3cf",shellShade:"#c8bea2",frame:"#b4aa8f",glass:"#14241f",scan:"#18302a",glow:"#6fbf8f",glowLight:"#b4e8c0",cup:"#b9562a",cupLight:"#d67a45",cupDark:"#8a3d1d",band:"#8f9690",hat:"#8a5a38",visor:"#6b4630",panel:"#e6dcc0",button:"#c8581e"},Xh={on:"#e2711d",dim:"#a8501c",alert:"#ff5a48"},Sy={on:"#ffd166",dim:"#a8501c",alert:"#ff5a48"},De=([e,n,r,o],l,c=.35)=>`<rect x="${e}" y="${n}" width="${r}" height="${o}" rx="${c}" fill="${l}"/>`;function Uf(e,n,r){if(n==="closed")return De([e,17,3,1],r.glow);if(n==="wide")return De([e,15,3,3],r.glowLight)+De([e+1,16,1,1],r.glass,.2);const o=n==="aside"?e+1:e;return De([o,16,3,1.1],r.glow)+De([o,17,3,1],r.glowLight)}function Ny(e,n){return e==="open"?De([13,20,6,1.1],n.glowLight)+De([15,21,2,1],n.glow):e==="mid"?De([14,20,4,1],n.glowLight):De(e==="aside"?[17,20,2,1]:[15,20,2,1],n.glow)}const by=[13,15,17,19,21,23];function Cy(e){return[by.map(n=>De([9.2,n,13.6,1],e.scan,0)).join(""),De([10,13,2,1],e.frame,.2),De([10,14,1,1],e.frame,.2),De([10,25.2,1,1],e.button,.2),De([11.2,25.2,1,1],e.cupDark,.2),[17,19,21].map(n=>De([n,25.2,1,1.6],e.shellLight,.2)+De([n,25.2,1,.8],e.frame,.2)).join("")].join("")}function Wf(e,n,r){return[`<rect x="${e}" y="15" width="5.4" height="11" rx="1.7" fill="${n.cup}" ${r}/>`,De([e+1,16,1.2,9],n.cupLight,.5),De([e+3.6,16,.9,9],n.cupDark,.4)].join("")}function $y(e,{lamp:n=Xh,simple:r=!1,colors:o=jy}={}){const l=o,c=r?"open":e.eyes,d=r?"rest":e.mouth,h=`stroke="${l.ink}" stroke-width=".9" stroke-linejoin="round"`;return['<g transform="scale(6.25)">',`<path d="M3 16.5Q3 6 16 5.5Q29 6 29 16.5" fill="none" stroke="${l.ink}" stroke-width="3"/>`,`<path d="M3 16.5Q3 6 16 5.5Q29 6 29 16.5" fill="none" stroke="${l.band}" stroke-width="1.5"/>`,Wf(.6,l,h),Wf(26,l,h),`<path d="M8 9H24Q26 9 26 11V25L23.5 28.5H8.5L6 25V11Q6 9 8 9Z" fill="${l.shell}" ${h}/>`,`<path d="M6.5 25H25.5L23.3 28H8.7Z" fill="${l.shellShade}"/>`,De([6.6,10,1.6,15],l.shellLight,.6),De([8.4,11,15.2,13.6],l.frame,1.3),De([9,11.6,14,12.4],l.glass,1),r?"":Cy(l),Uf(11,c,l),Uf(18,c,l),Ny(d,l),`<path d="M6.5 10.5Q5.8 3.5 16 3.100Q26.2 3.5 25.5 10.5Z" fill="${l.hat}" ${h}/>`,`<path d="M10.5 9.5Q10.3 4.9 16 4.5Q21.7 4.9 21.5 9.5Z" fill="${l.panel}" stroke="${l.ink}" stroke-width=".5"/>`,r?"":`<path d="M16 5.400l1.2 1.7h-.6l1 1.5h-3.2l1-1.5h-.6z" fill="${l.hat}"/>`,`<path d="M6.3 9.8Q16 7.9 25.7 9.8Q27.2 12 25 12.600Q16 10.9 7 12.600Q4.8 12 6.3 9.8Z" fill="${l.visor}" ${h}/>`,`<circle cx="16" cy="2.600" r="1.3" fill="${n[e.light??"on"]}" stroke="${l.ink}" stroke-width=".7"/>`,"</g>"].join("")}const Zh={crt:{id:"crt",name:"Day",blurb:"The original CRT head with ear cups and a baseball cap.",lamp:Xh,wave:{bar:"#6f8a78",lead:"#c8581e"}},night:{id:"night",name:"Night",blurb:"The same Scout, with the cap lamp burning bright, for the night theme.",lamp:Sy,wave:{bar:"#66828d",lead:"#e8833a"}}},Ty="crt",Ey={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"}},My={idle:"WATCHING",speaking:"TALKING",alert:"NEEDS YOU",thinking:"THINKING"},un={msPerChar:55,mouthHoldMs:110,blinkEveryMs:5600,blinkMs:140,thinkingStepMs:520};function Iy(e){return e?/[aeiouy]/i.test(e)?"open":/[a-z0-9]/i.test(e)?"mid":"rest":"rest"}function Ay(e,n){return!e||!/[a-z0-9]/i.test(e)?0:/[aeiou]/i.test(e)?2+(e.charCodeAt(0)+n)%2:1+(e.charCodeAt(0)*7+n)%2}function Oy(e,n,r){return Array.from({length:r},(o,l)=>{const c=n-(r-1-l);return c>=0&&c<e.length?Ay(e[c],c):0})}function em({face:e={eyes:"open",mouth:"rest"},variant:n="crt",size:r,simple:o,className:l}){const{eyes:c,mouth:d,light:h}=e,g=x.useMemo(()=>$y({eyes:c,mouth:d,light:h},{lamp:Zh[n].lamp,simple:o??r<28}),[c,d,h,n,o,r]);return i.jsx("svg",{className:l,width:r,height:r,viewBox:"0 0 200 200","aria-hidden":"true",dangerouslySetInnerHTML:{__html:g}})}function Ly(e){const[n,r]=x.useState(!1);return x.useEffect(()=>{if(!e){r(!1);return}let o;const l=setInterval(()=>{r(!0),o=setTimeout(()=>r(!1),un.blinkMs)},un.blinkEveryMs);return()=>{clearInterval(l),o&&clearTimeout(o)}},[e]),n}const Ry={xs:.8,sm:2,md:4,lg:6},_y=40,Hf=20,Vf="(prefers-reduced-motion: reduce)",Py=40,Dy=350;function By(e,n){var h;const r=e.size??"md",o=e.state??"idle",l=((h=e.speaking)==null?void 0:h.trim())??"",c=l&&(o==="idle"||o==="speaking")?"speaking":o,d=r==="xs";return{size:r,text:l,effective:c,talking:c==="speaking"&&l.length>0,mini:d,framed:e.framed??!d,reduced:n||d}}const zy=e=>e.length*un.msPerChar,Fy=(e,n)=>n&&(e.effective==="idle"||e.effective==="speaking"||e.effective==="alert");function Uy(e,n,r,o){const l=Ey[e.effective],c=r?"closed":l.eyes;let d=l.mouth,h=e.text.length-1;if(o)if(e.reduced)d="open";else{h=Math.min(e.text.length-1,Math.floor(n/un.msPerChar));const m=Math.floor(n/un.mouthHoldMs)*Math.round(un.mouthHoldMs/un.msPerChar);d=Iy(e.text[Math.min(e.text.length-1,m)])}let g=l.light;return e.effective==="thinking"&&!e.reduced&&Math.floor(n/un.thinkingStepMs)%2===1&&(g="on"),{eyes:c,mouth:d,light:g,cursor:h}}function Wy(e,n){const r=typeof e.size=="number"?e.size:Ry[e.size],o=e.reduced?Math.min(e.text.length-1,Hf-1):n;return{base:r,px:_y*r,bars:Hf,waveCursor:o}}function Hy(e,{label:n,speechDone:r,cursor:o,caption:l}){const c=e.talking&&r?"idle":e.effective,d=My[c],h=e.size==="md"||e.size==="lg"||typeof e.size=="number"&&e.size>=4;return{shownState:c,status:d,ariaLabel:`${n}, ${d.toLowerCase()}`,showCaption:l??h,shown:Vy(e,r,o)}}function Vy(e,n,r){return e.talking?e.reduced||n?e.text:e.text.slice(0,r+1):""}function Ky(){const[e,n]=x.useState(()=>{var r;return typeof window<"u"&&!!((r=window.matchMedia)!=null&&r.call(window,Vf).matches)});return x.useEffect(()=>{var l;const r=(l=window.matchMedia)==null?void 0:l.call(window,Vf);if(!r)return;const o=()=>n(r.matches);return o(),r.addEventListener("change",o),()=>r.removeEventListener("change",o)},[]),e}function Gy(e,n,r){const[o,l]=x.useState(0);return x.useEffect(()=>{if(l(0),!n)return;const c=performance.now(),d=setInterval(()=>l(performance.now()-c),r);return()=>clearInterval(d)},[e,n,r]),o}function Qy(e){const{key:n,talking:r,at:o}=e,l=o!==void 0,c=zy(e.text),[d,h]=x.useState(""),g=x.useRef(e.onSpeakEnd);g.current=e.onSpeakEnd,x.useEffect(()=>{if(!r||l)return;const w=setTimeout(()=>{var E;h(n),(E=g.current)==null||E.call(g)},c+Dy);return()=>clearTimeout(w)},[r,n,c,l]);const m=r&&d!==n,y=Gy(n,e.animate&&(m||e.thinking),m?Py:un.thinkingStepMs),v=o??y,j=r&&(l?v>=c:d===n);return{t:v,speechDone:j}}const qy=e=>e*2,Kl=3.5;function Yy(e,n,r){return(e??[]).map((o,l)=>{const c=(1+2*o)*.5;return{x:l*2,y:(Kl-c)/2,width:1,height:c,fill:l>=n-2&&o>0?r.lead:r.bar}})}function Jy({heights:e,bars:n,unit:r,colors:o}){const l=qy(n);return i.jsx("svg",{className:`scout-wave${e?" on":""}`,width:l*r,height:Kl*r,viewBox:`0 0 ${l} ${Kl}`,"aria-hidden":"true",children:Yy(e,n,o).map((c,d)=>i.jsx("rect",{...c},d))})}function Bi({state:e="idle",size:n="md",speaking:r,variant:o=Ty,framed:l,caption:c,label:d="Scout",onSpeakEnd:h,at:g,className:m,style:y}){const v=By({state:e,size:n,speaking:r,framed:l},Ky()),{text:j,effective:w,talking:E,reduced:N}=v,$=Zh[o],R=!N&&!(g!==void 0),O=`${w}|${o}|${j}`,{t:te,speechDone:se}=Qy({key:O,text:j,talking:E,thinking:w==="thinking",animate:R,at:g,onSpeakEnd:h}),F=Ly(Fy(v,R)),ie=E&&!se,{eyes:oe,mouth:G,light:ge,cursor:He}=Uy(v,te,F,ie),{base:$e,px:X,bars:P,waveCursor:Q}=Wy(v,He),q=x.useMemo(()=>ie?Oy(j,Q,P):null,[ie,j,Q,P]),{shownState:ae,status:H,ariaLabel:D,showCaption:U,shown:T}=Hy(v,{label:d,speechDone:se,cursor:He,caption:c}),_={...y,"--scout-u":`${$e}px`},he=i.jsx("span",{className:"scout-sprite",children:i.jsx(em,{face:{eyes:oe,mouth:G,light:ge},variant:o,size:X,simple:v.mini})});return v.framed?i.jsxs("figure",{className:`scout scout-panel scout-${ae} scout-v-${o} ${m??""}`,style:_,"data-state":ae,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:H})]}),i.jsxs("div",{className:"scout-feed",role:"img","aria-label":D,children:[he,i.jsx(Jy,{heights:q,bars:P,unit:$e,colors:$.wave})]}),U&&i.jsxs("p",{className:"scout-caption","aria-hidden":"true",children:[T,E&&!se&&!N&&i.jsx("span",{className:"scout-caret",children:"_"})]}),j&&i.jsx("span",{className:"scout-sr","aria-live":"polite",children:j})]}):i.jsx("span",{className:`scout scout-bare scout-${ae} ${m??""}`,style:_,role:"img","aria-label":D,children:he})}function Xy(){return['<rect x="1" y="1" width="198" height="198" rx="44" fill="#17211c" stroke="var(--tt-logo-edge, #17211c)" stroke-width="2"/>','<g transform="translate(32 32) scale(.68)">','<path d="M58 8L104 0V132Q104 150 124 150H150V196H112Q58 196 58 142Z" fill="#8fbf84"/>','<path d="M14 58H150V102H14Z" fill="#8fbf84"/>','<circle cx="182" cy="173" r="23" fill="#e8833a"/>',"</g>"].join("")}function Zy(){return['<g transform="translate(-3 2) scale(.98)">','<path d="M58 8L104 0V132Q104 150 124 150H150V196H112Q58 196 58 142Z" fill="#5f9658"/>','<path d="M14 58H150V102H14Z" fill="#5f9658"/>','<circle cx="182" cy="173" r="23" fill="#e8833a"/>',"</g>"].join("")}function ex({size:e=40,bare:n,className:r}){const o=x.useMemo(()=>n?Zy():Xy(),[n]);return i.jsx("svg",{className:r,width:e,height:e,viewBox:"0 0 200 200",role:"img","aria-label":"Teamtrail",dangerouslySetInnerHTML:{__html:o}})}const yt="trail lead";function tx({rt:e,guard:n,setMapId:r,mapIdRef:o,snapRef:l,setChatSession:c,setSelection:d}){const h={actorKind:"trail lead",journal:e.journal};return{selectMap:g=>r(g),openChat:g=>c(g),answer:(g,m)=>e.activity.answer(g,m,yt),claim:g=>n("Claim",()=>Ef(e.adapter,o.current,g,{...h,assignee:yt})),release:g=>n("Release claim",()=>Ov(e.adapter,o.current,g,{...h,actor:yt})),releaseLease:g=>n("Release to queue",()=>e.leases.release(o.current,g,yt)),resolve:(g,m,y={})=>n("Resolve · record answer",async()=>{var j;const v=(j=l.current)==null?void 0:j.tickets.find(w=>w.id===g);v&&!v.assignee&&await Ef(e.adapter,o.current,g,{...h,assignee:yt}),await Fv(e.adapter,o.current,g,{...h,answer:m,author:yt,decision:{...y,source:{kind:"lookout",label:"Ticket inspector"}}})}),supersede:(g,m)=>n(`Supersede ${g.id}`,async()=>{let y=g.id;if(g.derived){const{id:v,mapId:j,derived:w,supersededBy:E,...N}=g;y=(await oc(e.adapter,g.mapId,N,{appendToTrail:!1})).id}await Lv(e.adapter,g.mapId,y,{...m,decidedBy:yt,participants:[{id:yt}],source:{kind:"lookout",label:"Logbook"}})}),graduate:({unspecified:g,...m})=>n(`Promote to ticket · ${g}`,async()=>{const y=await Uv(e.adapter,o.current,g,m);d({kind:"ticket",id:y.id})}),ruleOut:(g,m)=>n("Rule out of scope",async()=>{await Wv(e.adapter,o.current,g,{...h,reason:m,author:yt,source:{kind:"lookout",label:"Ticket inspector"}}),d(null)}),setMode:g=>n(`Trail mode · ${g}`,()=>Rv(e.adapter,o.current,g)),setModelMatching:g=>n(`Model matching · ${g.enabled?"on":"off"}`,()=>Hv(e.adapter,o.current,g))}}const tt=(...e)=>e.filter(Boolean).join(" "),Ls="item",nx=/^[0-9a-f]{6,64}$/;function Ao(){const e=new URLSearchParams(location.search).get("project")??void 0;return e&&nx.test(e)?e:void 0}function Ne(e=Ao()){return e?`${ve.apiPrefix}/p/${e}`:ve.apiPrefix}function sx(e){const n=new URLSearchParams(location.search);for(const o of["projects","project","tracker",Ls])n.delete(o);e.item&&n.set(Ls,e.item),e.id&&e.id!==e.home&&n.set("project",e.id),e.id&&e.id!==e.home&&e.tracker&&n.set("tracker",e.tracker);const r=n.toString();return`${location.pathname}${r?`?${r}`:""}`}async function ix(e,n){var c;const r=(n.assumptions??[]).map((d,h)=>({id:`S-${h+1}`,text:d,status:"holding",tickets:[]})),{map:o,tickets:l}=await jv(e,{title:n.title,sections:{destination:n.destination,notes:n.notes,decisions:[],unspecified:[],outOfScope:[],...r.length?{assumptions:r}:{}},tickets:[{ref:"discovery",...Pk}]});return await fetch(`${Ne()}/briefs/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:o.id,ticketId:(c=l[0])==null?void 0:c.id})}),o}function tm(e,n){const r=URL.createObjectURL(new Blob([n],{type:"text/markdown;charset=utf-8"}));Object.assign(document.createElement("a"),{href:r,download:e}).click(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}function Zt(e){const n=Math.max(0,Math.floor(e/1e3));return n<60?`${n}s`:n<3600?`${Math.floor(n/60)}m`:`${Math.floor(n/3600)}h`}function nm(e){const n=Math.max(0,Math.floor(e/1e3)),r=o=>String(o).padStart(2,"0");return`${r(Math.floor(n/3600))}:${r(Math.floor(n%3600/60))}:${r(n%60)}`}const cc=e=>new Date(e).toTimeString().slice(0,8);function Ft(e){if(e<1e3)return`${Math.round(e)}ms`;const n=Math.round(e/1e3);return n<60?`${n}s`:n<3600?`${Math.floor(n/60)}m ${String(n%60).padStart(2,"0")}s`:`${Math.floor(n/3600)}h ${String(Math.floor(n%3600/60)).padStart(2,"0")}m`}function Oo(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}const Rs=e=>`$${e<10?e.toFixed(2):e.toFixed(1)}`,_s=e=>new Date(e).toISOString().slice(0,10),uc=e=>new Date(e).toTimeString().slice(0,5),rx=e=>`${_s(e)} ${uc(e)}`,sm=e=>{if(!e)return"";const n=Math.max(0,Math.round((Date.now()-e)/1e3));return n<60?`${n}s ago`:`${Math.round(n/60)}m ago`},zi=e=>e?new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",mo={research:"Research",prototype:"Prototype",junction:"Junction",task:"Task",execute:"Execute",review:"Review"},im={decided:"Done",claimed:"Working",frontier:"Ready",blocked:"Backlog",parked:"Parked (plan-only)","out-of-scope":"Cancelled",verifying:"Verifying",rework:"Rework",held:"Blocked"},ox={decided:"done",claimed:"working",frontier:"ready",blocked:"backlog",parked:"parked","out-of-scope":"cancelled",verifying:"verifying",rework:"rework",held:"blocked"};function dc(e,n){return new Map((e??[]).filter(r=>r.mapId===n&&!r.returned).map(r=>[r.ticketId,r]))}const fc=(e,n)=>`${e}/${n}`;let dn={reached:!1,live:!1,tickets:{}},Gl=!1;const Ql=new Set,ql=new Set;function po(e){dn=e;for(const n of Ql)n()}function Kf(){fetch(`${Ne()}/verification/sync`).then(e=>e.ok?e.json():Promise.reject()).then(e=>po({reached:!0,live:!0,status:e.status,tickets:Object.fromEntries(e.tickets.map(n=>[fc(n.mapId,n.ticketId),n]))}),()=>dn.reached&&po({...dn,live:!1}))}function Gf(){Gl=!0,Kf();const e=new EventSource(`${Ne()}/events`);e.addEventListener("verification",n=>{const r=JSON.parse(n.data);if(r.kind==="evidence")for(const l of ql)l();if(r.kind!=="sync")return;const o={...dn.tickets};for(const l of r.tickets)o[fc(l.mapId,l.ticketId)]=l;po({reached:!0,live:!0,status:r.status,tickets:o})}),e.addEventListener("error",()=>dn.reached&&dn.live&&po({...dn,live:!1})),e.addEventListener("open",()=>dn.reached&&Kf())}const Ps={subscribe(e){return Gl||Gf(),Ql.add(e),()=>void Ql.delete(e)},get:()=>dn,onEvidence(e){return Gl||Gf(),ql.add(e),()=>void ql.delete(e)},ticket:(e,n,r)=>e.tickets[fc(n,r)]};function ax(e){if(e!=null&&e.flags.length)return e.flags.some(n=>n.severity==="alert")?"alert":"warn"}const Qf={onboarded:!1,tracker:"markdown",hitlTranscript:"summary",agent:xy.id,github:{repo:""},linear:{team:""},briefing:{enabled:!0,awayMinutes:15},theme:"night"};function hc(){try{const e={...Qf,...JSON.parse(localStorage.getItem(No)??"{}")};return["markdown","github","linear"].includes(e.tracker)||(e.tracker="markdown"),e}catch{return Qf}}function rm(e){e==="auto"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e}const lx=15*6e4;class cx{constructor(n){ue(this,"leases",[]);ue(this,"changes",new Os);ue(this,"logged",new Set);ue(this,"since",Date.now()-lx);this.activity=n}subscribe(n){return this.changes.on(n)}set(n){var r;this.leases=n;for(const o of n){const l=`${o.mapId}/${o.ticketId}/${(r=o.returned)==null?void 0:r.at}`;!o.returned||o.returned.at<this.since||this.logged.has(l)||(this.logged.add(l),this.activity.push({source:"system",level:"warn",ticketId:o.ticketId,text:Jk(o)}))}this.changes.emit(n)}async release(n,r,o){const l=await fetch(`${Ne()}/agents/leases/release`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:n,ticketId:r,by:o})});if(!l.ok)throw new Error((await l.json().catch(()=>({}))).error??`HTTP ${l.status}`)}}let qt;const go=new Set,Ri=new Map;function om(e){qt==null||qt.addEventListener(e,n=>{for(const r of Ri.get(e)??[])r(n.data)})}function am(){if(!qt){qt=new EventSource(`${Ne()}/events`),qt.onmessage=e=>{const n=JSON.parse(e.data).path;if(typeof n=="string")for(const r of go)r(n)};for(const e of Ri.keys())om(e)}}function lm(){const e=[...Ri.values()].some(n=>n.size>0);go.size||e||(qt==null||qt.close(),qt=void 0)}function fn(e){return go.add(e),am(),()=>{go.delete(e),lm()}}function Lo(e,n){let r=Ri.get(e);return r||(r=new Set,Ri.set(e,r),om(e)),r.add(n),am(),()=>{r.delete(n),lm()}}function ux(e,n){return Lo(e,r=>n(JSON.parse(r)))}const dx={async list(){return(await(await fetch(`${Ne()}/list`)).json()).files},async read(e){const n=await fetch(`${Ne()}/file?path=${encodeURIComponent(e)}`);if(!n.ok)throw new Error(`read ${e}: ${n.status}`);return n.text()},async write(e,n){const r=await fetch(`${Ne()}/file?path=${encodeURIComponent(e)}`,{method:"PUT",body:n});if(!r.ok)throw new Error(`write ${e}: ${r.status}`)},watch(e){return fn(e)}};function qf(e,n){e.remoteAnswer=(o,l,c)=>{fetch(`${Ne()}/agents/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:o.sessionId,questionId:o.id,text:l,author:c})}).then(async d=>{if(!d.ok)throw new Error((await d.json().catch(()=>({}))).error??`HTTP ${d.status}`)}).catch(d=>e.push({source:"system",level:"alert",sessionId:o.sessionId,text:`Answer not delivered to ${o.agent} · ${d.message}`}))};const r=new EventSource(`${Ne()}/events`);r.addEventListener("agent",o=>e.syncRemote(JSON.parse(o.data))),r.addEventListener("leases",o=>n.set(JSON.parse(o.data).leases)),fetch(`${Ne()}/agents/leases`).then(o=>o.ok?o.json():{leases:[]}).then(({leases:o})=>n.set(o)).catch(()=>{}),fetch(`${Ne()}/agents`).then(o=>o.ok?o.json():{sessions:[]}).then(({sessions:o})=>[...o].reverse().forEach(l=>e.syncRemote(l))).catch(()=>{})}function Yf(e){const n=r=>`${No}:${e}:${r}`;return{get:r=>localStorage.getItem(n(r)),set:(r,o)=>{try{localStorage.setItem(n(r),o)}catch{}}}}const fx=["markdown","github","linear"];function hx(){const e=new URLSearchParams(location.search).get("tracker");return e&&fx.includes(e)?e:hc().tracker}function mx(e){let n,r;const o=new Xv,l=new cx(o),c={},d=Gv(Ne());if(e==="github"||e==="linear"){const m=new vy(e,Ne());n=m,r=fetch(`${Ne()}/trackers`).then(y=>y.json()).catch(()=>{}).then(y=>{m.location=(e==="github"?y==null?void 0:y.github.repo:[y==null?void 0:y.linear.teamKey,y==null?void 0:y.linear.projectName].filter(Boolean).join(" · "))||m.location;const v=Yf(`${e}:${m.location}`);c.presence=new Of(v),o.ledger=new Lf(v),qf(o,l)})}else n=new py(dx,`./${ve.dataDir}`),r=fetch(`${Ne()}/list`).then(m=>m.json()).catch(()=>({root:"default"})).then(({root:m})=>{const y=Yf(m);c.presence=new Of(y),o.ledger=new Lf(y),qf(o,l)});const h=nk(n),g=h.adapter;return{kind:e,ready:r,get presence(){return c.presence},adapter:g,journal:d,monitor:h,activity:o,leases:l}}const Xt=e=>e.status==="running",cm=e=>Xt(e)&&!!e.waitingOn,px={blocking:0,soon:1,fyi:2};function gx(e,n,r){const o=e.filter(d=>d.sessionId===n),l=o.find(d=>d.id===r);if(l)return l;const c=d=>px[d.urgency??"soon"];return[...o].sort((d,h)=>c(d)-c(h)||d.at-h.at)[0]}function Zn({n:e,urgent:n,pop:r,hideZero:o}){return i.jsx("span",{className:tt("badge",n&&"urgent",r&&n&&"pop",o&&!e&&"zero"),children:o&&!e?"":e})}function K({variant:e="default",size:n="md",on:r,className:o,type:l,...c}){return i.jsx("button",{type:l??"button",className:tt("btn",e!=="default"&&e,n==="sm"&&"sm",r&&"on",o),...c})}function At({as:e="div",tone:n,on:r,className:o,children:l,...c}){return i.jsx(e,{className:tt("card",n,r&&"on",o),...c,children:l})}function ft({on:e,title:n,sub:r,disabled:o,onClick:l}){return i.jsxs(At,{as:"button",type:"button",className:"choice",on:e,disabled:o,onClick:l,children:[i.jsx("b",{className:"choice-title t-row-title",children:n}),r&&i.jsx("span",{className:"c-sub",children:r})]})}function Le({children:e}){return i.jsx("div",{className:"empty",children:e})}const Jf=()=>{const e=document.documentElement.dataset.theme;return e?e==="night":matchMedia("(prefers-color-scheme: dark)").matches};function Ro(){const[e,n]=x.useState(Jf);return x.useEffect(()=>{const r=()=>n(Jf()),o=matchMedia("(prefers-color-scheme: dark)");o.addEventListener("change",r);const l=new MutationObserver(r);return l.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{o.removeEventListener("change",r),l.disconnect()}},[]),e}function vx(){const e=()=>window.innerWidth>=1440?"wide":window.innerWidth>=1024?"laptop":"mobile",[n,r]=x.useState(e);return x.useEffect(()=>{const o=()=>r(e());return window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)},[]),n}const kx=15e3,Xf=["pointerdown","pointermove","keydown","wheel","touchstart"];function yx(e,n,r,o){const[l,c]=x.useState(null),[d,h]=x.useState(!1),[g,m]=x.useState(!1),y=x.useRef(),v=x.useRef(Date.now()),j=x.useRef(!1),w=r.awayMinutes*6e4,E=x.useRef(n);E.current=n;const N=x.useRef(o);N.current=o;const $=x.useCallback((F,ie)=>{const oe=E.current;return wk({snaps:Object.values(oe.allSnaps),decisions:oe.decisions,activity:oe.activity,ledger:e.activity.ledger,since:G=>{var ge;return F[G]??ie??((ge=oe.allSnaps[G])==null?void 0:ge.map.createdAt)??Date.now()},currentMapId:oe.mapId,attention:N.current})},[e]),I=x.useCallback((F=Date.now())=>{var ie;return(ie=e.presence)==null?void 0:ie.markSeen(E.current.maps.map(oe=>oe.id),F)},[e]),R=x.useCallback(()=>{const F=e.presence;if(!F)return;const ie=F.lastSeenAny();if(ie!==void 0&&Date.now()-ie>=w){const oe=F.snapshot();$(oe,ie).changed&&(y.current={seen:oe,any:ie},h(!0),r.enabled?c(oe):m(!0))}I()},[e,w,r.enabled,$,I]);x.useEffect(()=>{!n.loaded||j.current||!e.presence||(j.current=!0,R())},[n.loaded,e,R]),x.useEffect(()=>{const F=()=>{const G=Date.now()-v.current>=w;v.current=Date.now(),G&&j.current&&document.visibilityState==="visible"&&R()},ie=()=>{if(document.visibilityState!=="visible"){j.current&&I(Date.now()-v.current<w?Date.now():v.current);return}v.current=Date.now(),j.current&&R()};for(const G of Xf)window.addEventListener(G,F,{passive:!0});document.addEventListener("visibilitychange",ie);const oe=setInterval(()=>{j.current&&document.visibilityState==="visible"&&I(v.current)},kx);return()=>{for(const G of Xf)window.removeEventListener(G,F);document.removeEventListener("visibilitychange",ie),clearInterval(oe)}},[w,R,I]);const O=x.useMemo(()=>{var F;return l?$(l,(F=y.current)==null?void 0:F.any):void 0},[l,$,n.allSnaps,n.decisions,n.activity,o]),te=x.useMemo(()=>O?bk(O):"",[O]);x.useEffect(()=>{l&&m(!1)},[l]);let se="none";return g?se="new":d&&(se="seen"),{shown:l!==null,status:se,briefing:O,line:te,open:()=>{const F=y.current;F&&c(F.seen)},dismiss:()=>c(null)}}function xx(e){const[n,r]=x.useState(e.leases.leases);return x.useEffect(()=>e.leases.subscribe(r),[e]),n}function wx(e){var H;const[n,r]=x.useState([]),[o,l]=x.useState(),[c,d]=x.useState(),[h,g]=x.useState({}),[m,y]=x.useState({}),[v,j]=x.useState(!1),[w,E]=x.useState(e.activity.snapshot),[N,$]=x.useState(e.monitor.health),I=xx(e);x.useEffect(()=>e.monitor.subscribe($),[e]);const[R,O]=x.useState(null),[te,se]=x.useState(),[F,ie]=x.useState(),oe=x.useRef(),G=x.useRef(),ge=x.useRef(new Set),He=x.useRef();He.current=c;const $e=x.useCallback(D=>{oe.current=D,l(D),O(null)},[]),X=x.useCallback(async()=>{var pe;const D=await e.adapter.listMaps();r(D);let U=oe.current;const T=G.current;T&&D.some(de=>de.id===T)?(G.current=void 0,U=T,U!==oe.current&&$e(U)):(!U||!D.some(de=>de.id===U))&&(U=(pe=D[0])==null?void 0:pe.id,$e(U));const[_,he]=await Promise.all([Promise.all(D.map(de=>e.adapter.loadMap(de.id))),Promise.all(D.map(de=>e.adapter.listDecisions(de.id)))]);g(Object.fromEntries(_.map(de=>[de.map.id,de]))),y(Object.fromEntries(D.map((de,we)=>[de.id,he[we]]))),j(!0),d(_.find(de=>de.map.id===U))},[e,$e]);x.useEffect(()=>{let D,U=()=>{},T=()=>{},_=!0;const he=()=>{clearTimeout(D),D=setTimeout(()=>void X().catch(me=>se(String(me))),40)},pe=(me,ke)=>Xt(me)&&e.activity.isRemote(me.id)&&(!ke||!me.mapId||me.mapId===ke),de=me=>{var ke;return(ke=He.current)==null?void 0:ke.tickets.find(Te=>Te.id===me)},we=me=>{const ke=Zv(me,de),Te=me.kind==="external.changed"&&e.activity.snapshot.sessions.some(ts=>pe(ts,me.mapId)),ct=!("mapId"in me)||!me.mapId||me.mapId===oe.current||me.kind==="map.created";ke&&!Te&&ct&&e.activity.push(ke),he()};return e.ready.then(()=>{_&&(U=e.adapter.subscribe(we),T=e.activity.subscribe(E),e.activity.push({source:"system",level:"ok",text:`Online · tracker ${e.adapter.label.toLowerCase()} · ${e.adapter.location}`}),X().catch(me=>se(String(me))))}),()=>{_=!1,U(),T(),clearTimeout(D)}},[e,X]),x.useEffect(()=>{o&&e.adapter.loadMap(o).then(d)},[o,e]),x.useEffect(()=>{for(const D of w.sessions)D.mode!=="chart"||!D.mapId||!e.activity.isRemote(D.id)||ge.current.has(D.id)||(ge.current.add(D.id),!(D.status!=="running"&&Date.now()-(D.endedAt??0)>6e4)&&(G.current=D.mapId,X().catch(U=>se(String(U)))))},[w.sessions,e,X]);const P=(H=w.pending[0])==null?void 0:H.sessionId;x.useEffect(()=>{if(!P)return;const D=U=>e.activity.snapshot.sessions.some(T=>T.id===U&&Xt(T));ie(U=>D(U)?U:P)},[P,e]);const Q=x.useCallback(async(D,U)=>{e.activity.push({source:"trail lead",agent:yt,level:"warn",text:D});try{se(void 0),await U()}catch(T){const _=T.message??String(T);se(_),e.activity.push({source:"trail lead",agent:yt,level:"alert",text:`Rejected · ${_}`})}},[e]),q=x.useMemo(()=>tx({rt:e,guard:Q,setMapId:$e,mapIdRef:oe,snapRef:He,setChatSession:ie,setSelection:O}),[Q,e,$e]),ae=x.useMemo(()=>Object.values(h).flatMap(D=>ok(D,m[D.map.id]??[])).sort((D,U)=>U.decidedAt-D.decidedAt),[h,m]);return{maps:n,allSnaps:h,mapId:o,snap:c,activity:w,health:N,selection:R,setSelection:O,error:te,chatSession:F,decisions:ae,leases:I,loaded:v,actions:q}}function en(e=1e3){const[n,r]=x.useState(Date.now());return x.useEffect(()=>{const o=setInterval(()=>r(Date.now()),e);return()=>clearInterval(o)},[e]),n}function jx(){const[e,n]=x.useState(hc),r=x.useCallback(o=>{n(l=>{const c={...l,...o};return localStorage.setItem(No,JSON.stringify(c)),c})},[]);return[e,r]}function mc(){return x.useSyncExternalStore(Ps.subscribe,Ps.get)}function pc({className:e,size:n=18}){return i.jsx("span",{className:e,"aria-hidden":"true",children:i.jsx(em,{size:n,variant:Ro()?"night":"crt"})})}function Rn({title:e,hint:n,art:r}){return i.jsxs("div",{className:r?"empty-state has-art":"empty-state",children:[r??i.jsx(pc,{className:"es-mark"}),i.jsxs("div",{className:"es-words",children:[i.jsx("span",{className:"es-title",children:e}),n&&i.jsx("span",{className:"es-hint",children:n})]})]})}function qe({label:e,children:n,className:r}){return i.jsxs("label",{className:tt("field",r),children:[e,n]})}const gc=x.forwardRef(function({value:n,onValueChange:r,onSubmit:o,action:l="Send",actionDisabled:c,className:d,...h},g){return i.jsxs("form",{className:tt("input-row",d),onSubmit:m=>{m.preventDefault(),o(n)},children:[i.jsx("textarea",{ref:g,rows:1,value:n,onChange:m=>r(m.target.value),onKeyDown:m=>{m.key==="Enter"&&!m.shiftKey&&(m.preventDefault(),o(n))},...h}),i.jsx(K,{type:"submit",variant:"primary",disabled:c??(h.disabled||!n.trim()),children:l})]})});function Fi({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 Ye({as:e="span",variant:n="chip",hot:r,size:o,className:l,children:c,title:d}){return i.jsx(e,{className:tt(n==="chip"?"chip-label":"mono-label",r&&"hot",o==="sm"&&(n==="chip"?"sm":"xs"),l),title:d,children:c})}const Sx="M25.53 10.5 A11 11 0 1 1 16 5",Nx="M20 5 L14.6 1.6 L14.6 8.4 Z";function zs({variant:e="mark",state:n="ok",size:r=20,className:o="",title:l}){const c=r<=14?3:2.4;return i.jsxs("svg",{className:`scout-mark mm-${e} mm-${n} ${o}`,viewBox:"0 0 32 32",width:r,height:r,role:l?"img":void 0,"aria-label":l,"aria-hidden":l?void 0:!0,children:[e==="status"||e==="alert"?i.jsx("circle",{cx:"16",cy:"16",r:"11",fill:"none",stroke:"currentColor",strokeWidth:c,strokeDasharray:n==="syncing"?"5 3.6":void 0}):i.jsx("path",{d:Sx,fill:"none",stroke:"currentColor",strokeWidth:c,strokeLinecap:"butt"}),(e==="mark"||e==="action")&&i.jsx("path",{d:Nx,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"&&(n==="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 vo({parts:e,className:n,as:r="div"}){const o=e.filter(l=>l!=null&&l!==!1&&l!=="");return i.jsx(r,{className:tt("meta",n),children:o.map((l,c)=>i.jsxs("span",{children:[c>0&&" · ",l]},c))})}const bx=e=>typeof e=="string"?{text:e}:e,Cx=e=>tt(e.code&&"t-code",e.strong&&"strong",e.urgent&&"urgent",e.className);function re(e){const n=e.parts.filter(r=>!!r&&(typeof r=="string"||!!r.text)).map(bx);return!n.length&&!e.children?null:i.jsxs("span",{className:tt("meta-line t-meta",e.className),children:[n.map((r,o)=>i.jsxs("span",{children:[o>0&&i.jsx("span",{className:"sep",children:" · "}),i.jsx("span",{className:Cx(r)||void 0,title:r.tip,children:r.text})]},o)),e.children]})}function $x({size:e=40,className:n}){return i.jsx(ex,{size:e,className:n})}function We({as:e="section",className:n,style:r,frameless:o,children:l,...c}){return i.jsx(e,{className:tt("panel",o&&"frameless",n),style:r,...c,children:l})}function Dn({tone:e,className:n,children:r,title:o}){return i.jsx("span",{className:tt("pill",e,n),title:o,children:r})}function Yt({label:e,value:n,layout:r="stack",urgent:o,title:l,className:c}){return i.jsxs("span",{className:tt("readout",r!=="stack"&&r,o&&"urgent",c),title:l,children:[i.jsx("span",{className:"mono-label",children:e}),r==="inline"&&" ",i.jsx("b",{children:n})]})}function ze(e){const{as:n="div",edge:r="neutral"}=e,o=e.onOpen?"button":"div";return i.jsxs(n,{className:tt("ds-row",`edge-${r}`,e.selected&&"on",e.className),children:[i.jsxs(o,{className:"ds-row-main",...e.onOpen?{type:"button",onClick:e.onOpen}:{},title:e.titleText,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 On="#c8581e",Tx={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:On,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:On})]}),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:On})]}),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:On,stroke:On})]}),tent:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 4L2.5 20h19z"}),i.jsx("path",{d:"M12 11l-4 9h8z",fill:On,stroke:On}),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:On})]})};function um({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:Tx[e]})}function Nt({title:e,count:n,right:r,hot:o,sub:l,children:c,className:d,info:h,icon:g}){return i.jsxs("header",{className:tt("sec-h",l&&"sub",d),children:[c,g&&i.jsx(um,{name:g}),e!==void 0&&i.jsx(Ye,{as:l?"h3":"h2",hot:o,children:e}),h&&i.jsx(Fi,{text:h}),n,r!==void 0&&i.jsx("span",{className:"sec-h-right",children:r})]})}function lt(e){const{value:n,options:r,onChange:o}=e,[l,c]=x.useState(!1),[d,h]=x.useState(0),[g,m]=x.useState(),y=x.useRef(null),v=x.useRef(null),j=x.useId(),w=r.find(I=>I.value===n);x.useLayoutEffect(()=>{if(!l||!y.current)return;const I=y.current.getBoundingClientRect();m({left:I.left,top:I.bottom+4,minWidth:I.width})},[l]),x.useEffect(()=>{if(!l)return;const I=O=>{var te,se;O.target instanceof Node&&((te=v.current)!=null&&te.contains(O.target)||(se=y.current)!=null&&se.contains(O.target))||c(!1)},R=()=>c(!1);return document.addEventListener("mousedown",I),window.addEventListener("resize",R),window.addEventListener("scroll",R,!0),()=>{document.removeEventListener("mousedown",I),window.removeEventListener("resize",R),window.removeEventListener("scroll",R,!0)}},[l]),x.useEffect(()=>{var I,R;l&&((R=(I=v.current)==null?void 0:I.querySelector(`[data-i="${d}"]`))==null||R.scrollIntoView({block:"nearest"}))},[l,d]);const E=()=>{h(Math.max(0,r.findIndex(I=>I.value===n))),c(!0)},N=I=>{var O;const R=r[I];c(!1),(O=y.current)==null||O.focus(),R&&R.value!==n&&o(R.value)},$=I=>{if(!l){["ArrowDown","ArrowUp","Enter"," "].includes(I.key)&&(I.preventDefault(),E());return}const R=O=>h(te=>(te+O+r.length)%r.length);if(I.key==="ArrowDown")R(1);else if(I.key==="ArrowUp")R(-1);else if(I.key==="Home")h(0);else if(I.key==="End")h(r.length-1);else if(I.key==="Enter"||I.key===" ")N(d);else{if(I.key==="Escape"||I.key==="Tab")return c(!1);if(I.key.length===1){const O=r.findIndex(te=>te.label.toLowerCase().startsWith(I.key.toLowerCase()));O>=0&&h(O);return}else return}I.preventDefault()};return i.jsxs(i.Fragment,{children:[i.jsxs("button",{ref:y,type:"button",className:tt("select",e.compact&&"compact",l&&"open",e.className),role:"combobox","aria-haspopup":"listbox","aria-expanded":l,"aria-controls":j,"aria-label":e["aria-label"],"aria-activedescendant":l?`${j}-${d}`:void 0,disabled:e.disabled,onClick:()=>l?c(!1):E(),onKeyDown:$,children:[i.jsx("span",{className:"select-value",children:(w==null?void 0:w.label)??"—"}),i.jsx("span",{className:"select-caret","aria-hidden":"true"})]}),l&&g&&i.jsx("ul",{ref:v,id:j,className:"select-menu",role:"listbox",style:g,children:r.map((I,R)=>i.jsxs("li",{id:`${j}-${R}`,"data-i":R,role:"option","aria-selected":I.value===n,className:tt(R===d&&"active"),onMouseEnter:()=>h(R),onMouseDown:O=>O.preventDefault(),onClick:()=>N(R),children:[i.jsx("span",{className:"select-label",children:I.label}),I.hint&&i.jsx("span",{className:"select-hint",children:I.hint})]},I.value))})]})}function vc(e){return i.jsx("div",{className:`tabs ${e.className??""}`,role:"tablist",children:e.items.map(n=>i.jsxs("button",{role:"tab","aria-selected":e.value===n.id,className:`tab ${e.value===n.id?"on":""}`,onClick:()=>e.onChange(n.id),children:[n.label,n.n!==void 0&&i.jsx("span",{className:"n",children:n.n})]},n.id))})}const Ex=350;function Mx(){const[e,n]=x.useState(null);if(x.useEffect(()=>{let o=0,l=null;const c=()=>{window.clearTimeout(o),l=null,n(null)},d=y=>{const v=y.getAttribute("data-tip");if(!v)return;const j=y.getBoundingClientRect(),w=j.bottom+60>window.innerHeight;n({text:v,x:j.left+j.width/2,y:w?j.top-8:j.bottom+8,above:w,scout:y.hasAttribute("data-tip-scout")})},h=y=>{var w,E;const v=(E=(w=y.target)==null?void 0:w.closest)==null?void 0:E.call(w,"[data-tip], [title]");if(!v||v instanceof SVGElement)return null;const j=v.getAttribute("title");return j&&(v.setAttribute("data-tip",j),v.removeAttribute("title")),v},g=y=>{if(y.pointerType==="touch")return;const v=h(y);v!==l&&(c(),v&&(l=v,o=window.setTimeout(()=>l===v&&d(v),y.type==="focusin"?0:Ex)))},m=y=>{l&&!l.contains(y.relatedTarget)&&c()};return document.addEventListener("pointerover",g),document.addEventListener("pointerout",m),document.addEventListener("focusin",g),document.addEventListener("focusout",c),document.addEventListener("pointerdown",c),window.addEventListener("scroll",c,!0),window.addEventListener("keydown",c),()=>{c(),document.removeEventListener("pointerover",g),document.removeEventListener("pointerout",m),document.removeEventListener("focusin",g),document.removeEventListener("focusout",c),document.removeEventListener("pointerdown",c),window.removeEventListener("scroll",c,!0),window.removeEventListener("keydown",c)}},[]),!e)return null;const r=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(Bi,{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:r,top:e.y,transform:`translate(-50%, ${e.above?"-100%":"0"})`},children:e.text})}function dm({as:e="span",className:n}){return i.jsx(e,{className:n,children:ve.name})}function fm(e){return e.bare?i.jsx("div",{className:`zone-b ${e.className??""}`,children:e.children}):i.jsxs(We,{className:`zone ${e.className??""}`,style:e.area?{gridArea:e.area}:void 0,children:[i.jsx(Nt,{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 $s(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 no(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 Mi(e){return i.jsxs(At,{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(re,{parts:[],children:e.sub})]})}const Ix=864e5;function Ax(e,n){const r=new Date(e),o=r.toTimeString().slice(0,5),l=new Date(n).toDateString(),c=new Date(n-Ix).toDateString();let d=` ${r.toLocaleDateString(void 0,{month:"short",day:"numeric"})}`;return r.toDateString()===l?d="":r.toDateString()===c&&(d=" yesterday"),`Since ${o}${d} · ${Ft(n-e)}`}function Ox(e){const{briefing:n,bp:r,onClose:o}=e;x.useEffect(()=>{const v=j=>j.key==="Escape"&&o();return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[o]);const l=n==null?void 0:n.trails.flatMap(v=>v.waiting).sort((v,j)=>v.at-j.at)[0],c=n==null?void 0:n.totals,d=((n==null?void 0:n.trails.length)??0)>1,h=r==="mobile",g=v=>{var j,w;return v.ticketId&&((w=(j=e.snaps[v.mapId])==null?void 0:j.tickets.find(E=>E.id===v.ticketId))==null?void 0:w.title)||v.text},m=v=>{var j,w;return v.ticketId&&((w=(j=e.snaps[v.mapId])==null?void 0:j.tickets.find(E=>E.id===v.ticketId))==null?void 0:w.key)||v.agent},y=v=>{const j=(I,R)=>i.jsx(no,{k:I.key,text:I.title,meta:R,onClick:()=>e.onTicket(v.mapId,I.id)},I.id),w=(I,R)=>i.jsx(no,{k:I.id,text:I.summary||I.answer,title:I.risk?`${I.question}
|
|
118
|
+
|
|
119
|
+
${I.risk.reason}`:I.question,meta:R,onClick:()=>e.onDecision(I.id)},I.id),E=qk(v.agentDecisions).flatMap(I=>I.decisions.map(R=>w(R,I.label))),N=[i.jsx($s,{title:"Done",children:v.done.map(I=>j(I))},"done"),i.jsx($s,{title:"Ruled out",children:h?[]:v.ruledOut.map(I=>j(I))},"oos"),i.jsx($s,{title:"Blocked",children:v.blocked.map(I=>j(I.ticket,`needs ${I.on.map(R=>R.key).join(", ")}`))},"blocked")],$=[i.jsx($s,{title:"Waiting on you",urgent:!0,children:v.waiting.map(I=>i.jsx(no,{k:m(I),text:g(I),meta:n.now-I.at<6e4?"now":Ft(n.now-I.at),title:I.text,onClick:()=>e.onAnswer(I)},I.id))},"waiting"),i.jsx($s,{title:"Agent decisions",children:h?[]:E},"agent"),i.jsx($s,{title:"Active sessions",children:h?[]:v.active.map(I=>{var O;const R=I.ticketId?(O=e.snaps[v.mapId])==null?void 0:O.tickets.find(te=>te.id===I.ticketId):void 0;return i.jsx(no,{k:(R==null?void 0:R.key)??I.agent,text:R?`${R.title} · ${I.stepLabel}`:I.stepLabel,meta:`${I.step}/${I.total}`,onClick:()=>e.onSession(I)},I.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:N}),i.jsx("div",{children:$})]})]},v.mapId)};return i.jsx("div",{className:"scrim",onClick:o,children:i.jsxs(We,{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"}),n&&n.trails.length>0&&i.jsx(Ye,{className:"bf-since",children:Ax(n.since,n.now)}),i.jsx("button",{className:"icon-btn",onClick:o,"aria-label":"Close",children:"×"})]}),i.jsxs(At,{className:"bf-scout",children:[i.jsx(Bi,{size:h?2:"sm",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."})]})]}),n&&c&&n.trails.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"bf-tiles",children:[i.jsx(Mi,{label:"Done",value:c.done,sub:c.ruledOut?`${c.ruledOut} ruled out`:void 0}),i.jsx(Mi,{label:"Blocked",value:c.blocked,sub:c.blocked?"Needs your answer":void 0}),i.jsx(Mi,{label:"Waiting on you",value:c.waiting,sub:Lx(c.oldestWaitMs),urgent:c.waiting>0}),i.jsx(Mi,{label:"Agent decisions",value:c.agentDecisions,className:"opt"}),i.jsx(Mi,{label:"Spend",value:Rs(c.usage.costUsd),sub:`${Oo(c.usage.inputTokens+c.usage.outputTokens)} tokens · ${c.usage.sessions} sessions${c.active?` · ${c.active} active`:""}`})]}),i.jsx("div",{className:"bf-body",children:n.trails.map(y)})]}),i.jsxs("footer",{children:[i.jsx(K,{onClick:o,children:"Dismiss"}),l?i.jsxs(K,{variant:"urgent",onClick:()=>e.onAnswer(l),children:[i.jsx(zs,{variant:"alert",size:13}),"Answer first decision"]}):i.jsx(K,{variant:"primary",onClick:e.onResume,children:"Resume trail"})]})]})})}function Lx(e){if(e!==void 0)return e<6e4?"Just asked":`Oldest ${Ft(e)}`}function Rx(e){const{brief:n,bp:r}=e;return i.jsx(Ox,{briefing:n.briefing,line:n.line,snaps:e.snaps,bp:r,onClose:n.dismiss,onTicket:(o,l)=>{n.dismiss(),e.openTicket(o,l)},onAnswer:o=>{n.dismiss(),e.closeDecisions(),e.openChat(o.sessionId,o.ticketId,o.mapId)},onSession:o=>{n.dismiss(),e.closeDecisions(),e.openChat(o.id,o.ticketId,o.mapId)},onDecision:o=>{n.dismiss(),e.openDecisions(o)},onResume:()=>{n.dismiss(),e.closeDecisions(),r==="mobile"&&e.showPhoneHome()}})}const _x={passed:"checks passed",failing:"checks failing",pending:"checks pending",unknown:"checks unknown",none:"no checks"};function Px({mapId:e,ticketId:n}){const r=Ps.ticket(mc(),e,n);if(!r)return null;const o=r.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}
|
|
120
|
+
${o.headRef}`:void 0,children:[o?i.jsxs("a",{href:o.url,target:"_blank",rel:"noreferrer noopener",children:["PR #",o.number," · ",o.state,o.draft?" · draft":""]}):`PR #${r.link.number}`,i.jsx("span",{className:`ci ci-${r.checksSummary}`,children:_x[r.checksSummary]}),i.jsx("span",{className:"when",children:Dx(r)})]}),r.flags.map(l=>i.jsx(Dn,{className:`flag flag-${l.severity}`,title:l.text,children:l.kind},l.kind))]})}function Dx(e){return e.error?"sync failed":e.syncedAt?sm(e.syncedAt):"not synced yet"}const Bx={ok:"ok",failed:"error",stale:"syncing",unknown:"idle",off:"idle"};function zx({now:e}){const n=mc();if(!n.reached)return null;const r=qv(n.live?n.status:null,e);return i.jsxs("span",{className:`tracker-chip pr-sync tone-${r.tone}`,title:r.title,children:[i.jsx(Ye,{size:"sm",children:"CI"}),i.jsx(zs,{variant:"status",state:Bx[r.tone],size:13,className:"sync-glyph"}),i.jsx("span",{className:"tl",children:r.label})]})}function Fx(e){const[n,r]=x.useState(!1),o=x.useRef(null);return x.useEffect(()=>{if(!n)return;const l=c=>{var h;(c instanceof KeyboardEvent?c.key==="Escape":!((h=o.current)!=null&&h.contains(c.target)))&&r(!1)};return window.addEventListener("mousedown",l),window.addEventListener("keydown",l),()=>{window.removeEventListener("mousedown",l),window.removeEventListener("keydown",l)}},[n]),i.jsxs("div",{className:"header-menu",ref:o,children:[i.jsxs(K,{variant:"ghost","aria-haspopup":"menu","aria-expanded":n,on:n,onClick:()=>r(!n),children:[e.label," ",e.badge," ",i.jsx("span",{className:"caret",children:"▾"})]}),n&&i.jsx("div",{className:"header-menu-list",role:"menu",children:e.children(()=>r(!1))})]})}const Ux={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 Wx(e){const n=e.briefingStatus==="new";return i.jsx(Fx,{label:"Records",badge:i.jsxs(i.Fragment,{children:[e.knowledge>0&&i.jsx("span",{className:"n hot",children:e.knowledge}),n&&i.jsx("span",{className:"new-dot","aria-label":"new trip report"})]}),children:r=>i.jsxs(i.Fragment,{children:[i.jsxs("button",{role:"menuitem",className:"header-menu-item",disabled:e.briefingStatus==="none"&&!e.briefingOpen,title:Ux[e.briefingStatus],onClick:()=>{r(),e.onBriefing()},children:[i.jsx("span",{children:"Trip report"}),n&&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:()=>{r(),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:()=>{r(),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:()=>{r(),e.onStats()},children:i.jsx("span",{children:"Trail stats"})})]})})}const Hx=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"})]}),Vx=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 Kx({onToggle:e}){const n=Ro(),r=n?"Switch to the day theme":"Switch to the night theme";return i.jsx(K,{variant:"ghost",className:"icon-only","aria-label":r,"data-tip":r,onClick:()=>e(!n),children:i.jsx("svg",{viewBox:"0 0 18 18",width:"16",height:"16","aria-hidden":"true",children:n?Hx:Vx})})}const Gx={idle:"Idle",syncing:"Syncing",ok:"Synced",error:"Sync error"};function Qx({label:e,health:n,now:r}){const o=[`${Gx[n.status]} · ${n.writes} writes · ${n.errors} errors`,n.lastWriteAt?`Last write ${Ft(n.lastWriteMs??0)}, ${Ft(r-n.lastWriteAt)} ago`:"No writes yet",n.lastError].filter(Boolean).join(`
|
|
121
|
+
`);return i.jsxs("span",{className:`tracker-chip sync-${n.status}`,title:o,children:[i.jsx(Ye,{size:"sm",children:"Tracker"}),i.jsx(zs,{variant:"status",state:n.status,size:13,className:"sync-glyph"}),i.jsx("span",{className:"tl",children:e})]})}function qx(e){const[n,r]=x.useState(!1),o=x.useRef(null);x.useEffect(()=>{if(!n)return;const h=g=>{var m;(g instanceof KeyboardEvent?g.key==="Escape":!((m=o.current)!=null&&m.contains(g.target)))&&r(!1)};return window.addEventListener("mousedown",h),window.addEventListener("keydown",h),()=>{window.removeEventListener("mousedown",h),window.removeEventListener("keydown",h)}},[n]);const l=Object.values(e.snaps).sort((h,g)=>g.map.createdAt-h.map.createdAt),c=h=>e.activity.pending.filter(g=>g.mapId===h).length,d=e.activity.pending.filter(h=>{var g;return h.mapId!==((g=e.map)==null?void 0:g.id)}).length;return i.jsxs("div",{className:"trail-switcher",ref:o,children:[i.jsxs("button",{className:"trail-btn",onClick:()=>r(h=>!h),"aria-haspopup":"menu","aria-expanded":n,"data-tip":"Switch trail, or start a new one",children:[i.jsx("span",{className:"trail-title",children:e.map?`${e.map.key} ${e.map.title}`:"No trail"}),d>0&&i.jsx(Zn,{n:d,urgent:!0}),i.jsx("span",{className:"caret",children:"▾"})]}),n&&i.jsxs("div",{className:"trail-menu",role:"menu",children:[i.jsx(Ye,{variant:"plain",className:"menu-h",children:"Trails"}),l.map(h=>{var y;const g=Ph(h),m=c(h.map.id);return i.jsxs("button",{role:"menuitem",className:`trail-item ${h.map.id===((y=e.map)==null?void 0:y.id)?"on":""}`,onClick:()=>{e.onSelectMap(h.map.id),r(!1)},children:[i.jsx("span",{className:"key",children:h.map.key}),i.jsx("span",{className:"mi-title",children:h.map.title}),i.jsxs("span",{className:"mi-progress",children:[g.decided,"/",g.total]}),i.jsx(Zn,{n:m,urgent:!!m,hideZero:!0})]},h.map.id)}),i.jsx("button",{role:"menuitem",className:"trail-item new",onClick:()=>{r(!1),e.onNewTrail()},children:"+ New trail"})]})]})}function Yx(e){const{map:n}=e,r=en(1e3),o=e.activity.pending.length,l=n&&e.snaps[n.id],c=l&&Ph(l),d=n&&Dh(e.activity,n.id);return i.jsxs(We,{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(qx,{...e})]}),i.jsxs("div",{className:"h-dest",title:n==null?void 0:n.sections.destination,children:[i.jsx(Ye,{size:"sm",children:"Destination"}),(n==null?void 0:n.sections.destination)??"—"]})]}),i.jsxs("div",{className:"h-right",children:[i.jsx(Qx,{label:e.trackerLabel,health:e.health,now:r}),i.jsx(zx,{now:r}),n&&c&&i.jsxs("span",{className:"trail-meta",children:[i.jsx(Yt,{label:"Trail T+",value:nm(r-n.createdAt),title:"Trail elapsed time, since it was charted"}),i.jsx(Yt,{label:"Done",value:`${c.decided}/${c.total}`}),d&&i.jsx(Yt,{className:"spend",label:"Spent",value:`${Rs(d.costUsd)} · ${Oo(d.inputTokens+d.outputTokens)} tok`,title:["Model spend and tokens for this trail, across every session",...zh(e.activity,n.id).map(h=>Bh[h].text)].join(`
|
|
122
|
+
`)})]}),e.attention,!e.attention&&o>0&&i.jsxs("span",{className:"waiting-chip",title:`${o} waiting on you`,children:[i.jsx(zs,{variant:"alert",size:14}),i.jsx("b",{children:o}),i.jsx("span",{className:"wl",children:" waiting on you"})]}),e.slackAlert&&i.jsx(K,{size:"sm",variant:"urgent",onClick:e.onSlack,title:e.slackAlert,children:"Slack disconnected"}),n&&i.jsx(K,{variant:"ghost",className:"mode-chip",onClick:e.onToggleMode,"data-tip":n.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:n.mode==="plan-only"?"Plan only":"Plan + execute"}),i.jsx(Wx,{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(Kx,{onToggle:e.onToggleTheme}),i.jsx(K,{variant:"ghost",onClick:e.onSettings,"data-tip":"Tracker, verification, appearance and integrations",children:"Settings"})]})]})}const hm=x.createContext(null);function Fs(){const e=x.useContext(hm);if(!e)throw new Error("useKnowledge needs a KnowledgeContext provider");return e}function Jx({snap:e,t:n}){const r=Fs();if(!r.entries.length||n.state==="closed")return null;const o=qh(r.entries,{trailKey:e.map.key,ticket:{type:n.type,title:n.title,body:n.body},paths:Yh(`${n.body}
|
|
123
|
+
${r.briefText}`)},4e3,l=>r.stale[l.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(l=>i.jsxs("li",{children:[i.jsx("button",{className:"item-text kn-open",onClick:()=>r.setOpen(!0),"data-tip":l.why.join(" · "),children:l.title}),i.jsx(re,{parts:[{text:l.id,code:!0},l.status==="assumption"&&"assumption",l.mayBeOutdated&&{text:"may be outdated",className:"warn"}]})]},l.id))})]})}const Xx={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 Zx({e}){const n=Fs(),[r,o]=x.useState(!1),[l,c]=x.useState(e.title),[d,h]=x.useState(e.body);x.useEffect(()=>{o(!1),c(e.title),h(e.body)},[e.id,e.title,e.body]);const g=n.stale[e.id];return i.jsxs("div",{className:"kn-detail",children:[i.jsx(re,{parts:[{text:e.id,code:!0},e.kind.replace("-"," "),e.status]}),r?i.jsxs(i.Fragment,{children:[i.jsx(qe,{label:"Title",children:i.jsx("input",{value:l,onChange:m=>c(m.target.value)})}),i.jsx(qe,{label:"Body",children:i.jsx("textarea",{rows:8,value:d,onChange:m=>h(m.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:Xx[e.status]}),e.flag&&i.jsxs("p",{className:"kn-warn",children:["Flagged by ",e.flag.by,": ",e.flag.reason]}),g&&e.status!=="outdated"&&i.jsxs("p",{className:"kn-warn",children:["May be outdated: ",g.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(m=>m.path).join(", ")})]})]}),n.error&&i.jsx("p",{className:"vf-err",children:n.error}),i.jsx("div",{className:"actions",children:r?i.jsxs(i.Fragment,{children:[i.jsx(K,{variant:"ghost",onClick:()=>o(!1),children:"Cancel"}),i.jsx(K,{variant:"primary",disabled:!l.trim(),onClick:()=>void n.call(e.id,{kind:"edit",title:l,body:d}).then(m=>m&&o(!1)),children:"Save"})]}):i.jsxs(i.Fragment,{children:[(e.status!=="confirmed"||g)&&i.jsx(K,{variant:"primary",onClick:()=>void n.call(e.id,{kind:"confirm"}),children:e.status==="confirmed"?"Re-confirm":"Confirm"}),e.status!=="assumption"&&e.status!=="outdated"&&i.jsx(K,{onClick:()=>void n.call(e.id,{kind:"assumption"}),children:"Keep as assumption"}),e.flag&&i.jsx(K,{onClick:()=>void n.call(e.id,{kind:"resolve-flag"}),children:"Resolve flag"}),i.jsx(K,{variant:"ghost",onClick:()=>o(!0),children:"Edit"}),e.status!=="outdated"&&i.jsx(K,{variant:"ghost",onClick:()=>void n.call(e.id,{kind:"outdated"}),children:"Mark outdated"})]})})]})}const ew={suggested:"Suggested",confirmed:"Confirmed",assumption:"Assumption",outdated:"Outdated"};function tw(){const e=Fs(),[n,r]=x.useState("review"),[o,l]=x.useState(""),[c,d]=x.useState(""),[h,g]=x.useState();x.useEffect(()=>{if(!e.open)return;const N=$=>$.key==="Escape"&&e.setOpen(!1);return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[e]);const m=N=>N.status==="suggested"||!!N.flag||!!e.stale[N.id]&&N.status!=="outdated",y=(N,$)=>$==="all"?!0:$==="review"?m(N):N.status===$,v=x.useMemo(()=>{const N=c.trim().toLowerCase();return e.entries.filter($=>y($,n)&&(!o||$.kind===o)&&(!N||`${$.id} ${$.title} ${$.body} ${$.tags.join(" ")}`.toLowerCase().includes(N)))},[e.entries,e.stale,n,o,c]);if(!e.open)return null;const j=v.find(N=>N.id===h)??v[0],w=N=>e.entries.filter($=>y($,N)).length,E=[["review","Needs you"],["confirmed","Confirmed"],["assumption","Assumptions"],["outdated","Outdated"],["all","All"]];return i.jsx("div",{className:"scrim",onClick:()=>e.setOpen(!1),children:i.jsxs(We,{as:"div",className:"dialog knowledge-view",onClick:N=>N.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:"Field guide"}),i.jsx(Fi,{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:[E.map(([N,$])=>i.jsxs("button",{className:`chip ${n===N?"on":""}`,onClick:()=>r(N),children:[$," ",i.jsx("span",{className:"n",children:w(N)})]},N)),i.jsx(lt,{compact:!0,"aria-label":"Kind",value:o,onChange:l,options:[{value:"",label:"Any kind"},...Fk.map(N=>({value:N,label:N.replace("-"," ")}))]}),i.jsx("input",{className:"kn-search",placeholder:"Search",value:c,onChange:N=>d(N.target.value)})]}),i.jsxs("div",{className:"kn-body-grid",children:[i.jsx("ul",{className:"kn-list",children:v.length?v.map(N=>i.jsx(ze,{as:"li",className:`kn-row st-${N.status}`,edge:m(N)?"attention":"neutral",selected:N===j,onOpen:()=>g(N.id),title:N.title,titleText:N.title,context:i.jsx(re,{parts:[{text:N.id,code:!0},N.kind.replace("-"," "),m(N)&&N.status!=="suggested"?"Needs a check":ew[N.status]]})},N.id)):i.jsx(Le,{children:n==="review"?"Nothing needs you":"No entries"})}),j?i.jsx(Zx,{e:j}):i.jsx(Le,{children:"Pick an entry"})]})]})})}function kc({draft:e,label:n="Save as knowledge"}){const r=Fs(),[o,l]=x.useState();return o?i.jsxs(K,{size:"sm",variant:"ghost",onClick:()=>r.setOpen(!0),"data-tip":"Open it in the field guide to confirm it",children:["Saved as ",o]}):i.jsx(K,{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 r.propose(e()).then(c=>c&&l(c.id)),children:n})}const mm=`${Ne()}/knowledge`;async function Zf(e,n){const r=await fetch(`${mm}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),o=await r.json().catch(()=>({}));if(!r.ok)throw new Error(o.error??`HTTP ${r.status}`);return o}function nw(e){const[n,r]=x.useState([]),[o,l]=x.useState({}),[c,d]=x.useState(!1),[h,g]=x.useState(),m=x.useCallback(()=>{fetch(mm).then(v=>v.ok?v.json():null).then(v=>{v&&(r(v.entries),l(v.stale))}).catch(()=>{})},[]);x.useEffect(()=>(m(),fn(v=>v.startsWith("knowledge/")&&m())),[m]);const y=x.useMemo(()=>n.filter(v=>v.status==="suggested"||v.flag||o[v.id]&&v.status!=="outdated").length,[n,o]);return{entries:n,stale:o,briefText:e,attention:y,open:c,setOpen:d,error:h,call:(v,j)=>Zf("/call",{id:v,call:j}).then(()=>(g(void 0),m(),!0),w=>(g(w.message),!1)),propose:v=>Zf("/propose",v).then(j=>(m(),j.entry),j=>(g(j.message),void 0))}}function Yl(e){const[n,r]=x.useState(!1),[o,l]=x.useState(""),c=async()=>{let d="";try{d=await navigator.clipboard.readText()}catch{r(!0);return}d.trim()?e.onToken(d,!0):r(!0)};return i.jsxs("div",{className:"sl-paste",children:[i.jsx(K,{variant:"primary",disabled:e.busy,onClick:()=>void c(),children:e.busy?"Checking…":"Paste"}),n?i.jsxs("form",{className:"sl-paste-field",onSubmit:d=>{d.preventDefault(),e.onToken(o,!0),l("")},children:[i.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,autoFocus:!0,value:o,placeholder:e.placeholder,"aria-label":"Token",onChange:d=>l(d.target.value)}),i.jsx(K,{type:"submit",disabled:e.busy||!o.trim(),children:"Save"})]}):i.jsx("button",{type:"button",className:"link",onClick:()=>r(!0),children:"Type it instead"})]})}const sw=["awaiting","blocked","trail.done","resolved"],iw=["commands","chat:write","im:write","channels:history","groups:history","im:history","mpim:history","users:read"],rw=["users:read.email"],ow="save_decision",aw=`/${ve.assistant.name.toLowerCase()}`;function lw(e={}){const n=ve.assistant.name;return{display_information:{name:n,description:`${ve.name} decisions and agent questions`,background_color:"#1b2226"},features:{app_home:{home_tab_enabled:!0,messages_tab_enabled:!0,messages_tab_read_only_enabled:!1},bot_user:{display_name:n,always_online:!0},slash_commands:[{command:e.command??aw,description:"Record a decision, check a trail, answer agents",usage_hint:"decide [text] | status [trail] | inbox | help",should_escape:!1}],shortcuts:[{name:"Save as decision",type:"message",callback_id:ow,description:`Record this thread as a ${ve.name} decision`}]},oauth_config:{scopes:{bot:[...iw,...rw]}},settings:{event_subscriptions:{bot_events:["app_home_opened"]},interactivity:{is_enabled:!0},org_deploy_enabled:!1,socket_mode_enabled:!0,token_rotation_enabled:!1}}}const cw={create:e=>`https://api.slack.com/apps?new_app=1&manifest_json=${encodeURIComponent(JSON.stringify(lw({command:e})))}`,app:e=>`https://api.slack.com/apps/${e}/general`,install:e=>`https://api.slack.com/apps/${e}/install-on-team`,home:(e,n)=>`slack://app?team=${e}&id=${n}&tab=home`,homeWeb:(e,n)=>`https://slack.com/app_redirect?app=${n}&team=${e}`};function uw(e){const n=e.trim().match(/^xapp-\d+-(A[A-Z0-9]+)-/);return n==null?void 0:n[1]}async function Xn(e,n="GET",r){const o=await fetch(e,{method:n,headers:{"Content-Type":"application/json"},body:r===void 0?void 0:JSON.stringify(r)}),l=await o.json().catch(()=>({}));if(!o.ok&&!l.status)throw new Error(l.error??`request failed (${o.status})`);return l}function dw(e){const n=`${e}/slack`;return{get:()=>Xn(n),created:()=>Xn(`${n}/created`,"POST",{}),token:r=>Xn(`${n}/token`,"POST",{token:r}),update:r=>Xn(`${n}/settings`,"PUT",r),resetOwner:()=>Xn(`${n}/owner/reset`,"POST",{}),members:()=>Xn(`${n}/members`).then(r=>r.members),remove:()=>Xn(n,"DELETE")}}const _n=dw(Ne());function fw(e){const[n,r]=x.useState(!1),[o,l]=x.useState(),c=d=>{r(!0),_n.token(d).then(h=>{r(!1),l(h.ok?void 0:h.error),e.set(h.status)},h=>{r(!1),l(h.message)})};return i.jsxs(i.Fragment,{children:[i.jsx(Yl,{busy:n,placeholder:"xapp-… or xoxb-…",onToken:c}),o&&i.jsxs("div",{className:"test-line alert",children:["✕ ",o]})]})}function hw({onRemoved:e}){const[n,r]=x.useState(!1);if(!n)return i.jsx(K,{size:"sm",variant:"ghost",onClick:()=>r(!0),children:"Remove"});const o=()=>void _n.remove().then(l=>{r(!1),e(l)},()=>{});return i.jsxs(i.Fragment,{children:[i.jsx(K,{size:"sm",variant:"danger",onClick:o,children:"Remove tokens and settings"}),i.jsx(K,{size:"sm",variant:"ghost",onClick:()=>r(!1),children:"Keep"})]})}const mw={awaiting:"Awaiting you",blocked:"Blocked","trail.done":"Trail done",resolved:"Resolved"};function pm({s:e}){const[n,r]=pw(e);return i.jsxs("div",{className:`sync-line ${n}`,title:e.error,children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:r})]})}function pw(e){switch(e.state){case"online":return["ok","Online"];case"connecting":return["","Connecting"];case"offline":return["warn","Offline · reconnecting"];case"auth-error":return["alert","Disconnected · Slack rejected the tokens"];case"elsewhere":{const n=e.heldBy?` (${e.heldBy})`:"";return["warn",`Connected from another ${ve.slug}${n}`]}case"unsupported":return["alert",e.error??"Not supported here"];default:return["",e.step==="done"?"Off":"Not connected"]}}function gw(e){const{s:n,setup:r}=e,o=n.step==="done";return i.jsxs(At,{className:kw(n,r),children:[i.jsxs("div",{className:"card-row",children:[i.jsx("b",{className:"choice-title t-row-title",children:"Scout app"}),o&&i.jsx(Dn,{className:n.enabled?"on":"",children:n.enabled?"On":"Off"})]}),o&&i.jsx("div",{className:"c-loc",children:vw(n)}),o&&i.jsx(pm,{s:n}),!o&&n.step===1&&!r&&i.jsx("p",{className:"sl-lead",children:"Answer agents and save threads as decisions from Slack. Your own Slack app, connected from this machine; tokens stay in your local credential store."}),i.jsxs("div",{className:"c-actions",children:[!o&&!r&&i.jsx(K,{size:"sm",variant:"primary",onClick:()=>e.onSetup(!0),children:n.step===1?"Connect":`Resume at step ${n.step}`}),o&&i.jsx(K,{size:"sm",on:n.enabled,onClick:e.onToggle,children:n.enabled?"Turn off":"Turn on"}),o&&n.state==="auth-error"&&i.jsx(K,{size:"sm",variant:"primary",onClick:()=>e.onSetup(!0),children:"Reconnect"}),n.step!==1&&i.jsx(hw,{onRemoved:e.onRemoved})]})]})}function vw(e){var r,o,l;const n=(o=(r=e.workspace)==null?void 0:r.url)==null?void 0:o.replace(/^https?:\/\/|\/$/g,"");return[(l=e.workspace)==null?void 0:l.name,n,e.setup.appId].filter(Boolean).join(" · ")}function kw(e,n){const r=e.step==="done";return`connector ${r&&e.enabled?"active":""} ${n||!r?"open":""}`}function yw(e){const[n,r]=x.useState(e.value==="dm"?"":e.value),o=/^[CG][A-Z0-9]{6,}$/.test(n.trim());return i.jsxs("form",{className:"sl-paste-field",onSubmit:l=>{l.preventDefault(),o&&e.onSave(n.trim())},children:[i.jsx("input",{value:n,spellCheck:!1,placeholder:"Channel ID, e.g. C0123ABCD","aria-label":"Channel ID",onChange:l=>r(l.target.value)}),i.jsx(K,{type:"submit",disabled:!o||n.trim()===e.value,children:"Save"})]})}function xw(e){const[n,r]=x.useState(),[o,l]=x.useState();x.useEffect(()=>{_n.members().then(r,h=>l(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]}):n?i.jsx("div",{className:"choice-row compact sl-members",children:n.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(g=>g.id!==h.id):[...e.value,h])},h.id))}):i.jsx("span",{className:"t-meta",children:"Loading members…"})}function ww(e){const{s:n,patch:r}=e,[o,l]=x.useState(!1),c=new Set(n.notify.events),d=o||n.notify.target!=="dm",h=n.owners[0],g=m=>{const y=c.has(m)?n.notify.events.filter(v=>v!==m):[...n.notify.events,m];r({notify:{events:y}})};return i.jsxs("div",{className:"sl-groups",children:[i.jsxs("div",{className:"sl-group",children:[i.jsx(Ye,{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)]}),(h==null?void 0:h.via)==="git-email"&&i.jsx("span",{className:"t-meta",children:"Matched your git email"}),i.jsx("button",{type:"button",className:"link",onClick:()=>void _n.resetOwner().then(e.set,()=>{}),children:"Not you? Reset"})]})]}),i.jsxs("div",{className:"sl-group",children:[i.jsx(Ye,{variant:"plain",size:"sm",children:"Allowed users"}),i.jsx(xw,{value:n.allow,owners:n.owners,onChange:m=>r({allow:m})})]}),i.jsxs("div",{className:"sl-group",children:[i.jsx(Ye,{variant:"plain",size:"sm",children:"Notify"}),i.jsxs("div",{className:"choice-row compact",children:[i.jsx(ft,{on:!d,title:"DM to owner",onClick:()=>{l(!1),r({notify:{target:"dm",detail:"full"}})}}),i.jsx(ft,{on:d,title:"Channel",sub:n.notify.target!=="dm"?n.notify.target:void 0,onClick:()=>l(!0)})]}),d&&i.jsxs(i.Fragment,{children:[i.jsx(qe,{label:"Channel ID (invite @Scout there first)",children:i.jsx(yw,{value:n.notify.target,onSave:m=>r({notify:{target:m}})})}),i.jsxs("div",{className:"choice-row compact",children:[i.jsx(ft,{on:n.notify.detail==="full",title:"Full questions",onClick:()=>r({notify:{detail:"full"}})}),i.jsx(ft,{on:n.notify.detail==="titles-only",title:"Titles only",onClick:()=>r({notify:{detail:"titles-only"}})})]})]}),i.jsx("div",{className:"choice-row compact",children:sw.map(m=>i.jsx(ft,{on:c.has(m),title:mw[m],onClick:()=>g(m)},m))})]}),i.jsx(vo,{className:"dim",parts:[`${n.command} decide`,`${n.command} status`,`${n.command} inbox`,"Save as decision on any message"]})]})}function so(e){return i.jsx("a",{className:`btn ${e.primary?"primary":""}`,href:e.href,target:"_blank",rel:"noreferrer",onClick:e.onClick,children:e.children})}function jw({s:e,n}){const r=Sw(e,n);return r?i.jsx("span",{className:"t-meta",children:r}):null}function Sw(e,n){var o;if(n===3)return e.setup.appId&&`app ${e.setup.appId}`;if(n===4)return e.workspace&&`${e.workspace.name} · @${((o=e.bot)==null?void 0:o.name)??"scout"}`;const r=e.owners[0];if(n===5&&r){const l=r.via==="git-email"?" · git email":"";return`owner ${r.name??r.id}${l}`}}const eh=[{n:1,title:"Create app"},{n:2,title:"Workspace"},{n:3,title:"App token"},{n:4,title:"Install"},{n:5,title:"Claim"}],yc=(e,n)=>e===n||e===2&&n===3,gm=(e,n)=>e==="done"||typeof e=="number"&&n<e&&!yc(e,n);function th(e,n){return gm(e,n)?"done":yc(e,n)?"cur":""}const Nw=/^(xapp-|xoxb-|xoxp-|xoxe)/,bw=typeof navigator<"u"&&/Mac|iP(hone|ad)/.test(navigator.platform)?"⌘V":"Ctrl+V";function Cw(e){const n=x.useRef(e);n.current=e;const[r,o]=x.useState(!1);return x.useEffect(()=>{let l="";const c=(g,m)=>{const y=g.trim();return!Nw.test(y)||!m&&y===l?!1:(l=y,n.current(y,m),!0)},d=g=>{var m;c(((m=g.clipboardData)==null?void 0:m.getData("text"))??"",!0)&&g.preventDefault()},h=async()=>{if(document.visibilityState==="visible")try{const g=await navigator.permissions.query({name:"clipboard-read"});o(g.state==="granted"),g.state==="granted"&&c(await navigator.clipboard.readText(),!1)}catch{}};return h(),document.addEventListener("paste",d),window.addEventListener("focus",h),document.addEventListener("visibilitychange",h),()=>{document.removeEventListener("paste",d),window.removeEventListener("focus",h),document.removeEventListener("visibilitychange",h)}},[]),r}function $w(e){var N;const{s:n,set:r}=e,[o,l]=x.useState(),[c,d]=x.useState(!1),[h,g]=x.useState(!1),m=($,I)=>{const R=uw($);I&&R&&!n.setup.botToken&&window.open(cw.install(R),"_blank")&&g(!0),d(!0),_n.token($).catch(O=>({ok:!1,error:O.message,status:n})).then(O=>{d(!1),l(O),r(O.status)})},v=Cw(m)?"come back to this tab":`press ${bw} here`,j=n.step,w=$=>{if(!o)return null;const I=!o.ok&&$===4==(j===4);return o.kind===($===4?"bot":"app")||I?i.jsx("div",{className:`test-line ${o.ok?"ok":"alert"}`,children:Tw(o)}):null},E={1:i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:["Slack opens with the Scout app filled in from a manifest: the ",n.command," command, Save as decision, and Socket Mode. Nothing is hosted by ",ve.name,"."]}),i.jsx("div",{className:"sl-actions",children:i.jsx(so,{primary:!0,href:n.links.create,onClick:()=>void _n.created().then(r,()=>{}),children:"Create Slack app"})})]}),2:i.jsxs("p",{children:["In Slack: pick the workspace → ",i.jsx("b",{children:"Next"})," → ",i.jsx("b",{children:"Create"}),"."]}),3:i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:["On the page Slack just opened: ",i.jsx("b",{children:"App-Level Tokens"})," → ",i.jsx("b",{children:"Generate Token and Scopes"})," → name it"," ",i.jsx("code",{children:"teamtrail"})," → add ",i.jsx("code",{children:"connections:write"})," → ",i.jsx("b",{children:"Generate"})," → ",i.jsx("b",{children:"Copy"}),", then ",v,"."]}),i.jsx("div",{className:"sl-actions",children:i.jsx(Yl,{busy:c,placeholder:"xapp-…",onToken:m})}),w(3),i.jsx(vo,{className:"dim",parts:["Waiting for the app-level token",n.links.create&&i.jsx("a",{href:n.links.create,target:"_blank",rel:"noreferrer",children:"Open the manifest again"},"again")]})]}),4:i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:[h?"Slack's install page is open in a new tab: ":i.jsxs(i.Fragment,{children:[i.jsx("b",{children:"Install to workspace"})," →"," "]}),i.jsx("b",{children:"Allow"})," → copy the ",i.jsx("b",{children:"Bot User OAuth Token"})," (starts with ",i.jsx("code",{children:"xoxb-"}),"), then ",v,"."]}),i.jsxs("div",{className:"sl-actions",children:[i.jsx(so,{primary:!h,href:n.links.install,children:h?"Open install page again":"Install to workspace"}),i.jsx(Yl,{busy:c,placeholder:"xoxb-…",onToken:m})]}),w(4)]}),5:i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:["Your git email doesn't match a member of ",((N=n.workspace)==null?void 0:N.name)??"the workspace",", so tell Scout who you are: open its Home tab in Slack and click ",i.jsx("b",{children:"This is me"}),". Scout sends you a DM, and questions from agents arrive there."]}),i.jsxs("div",{className:"sl-actions",children:[i.jsx(so,{primary:!0,href:n.links.home,children:"Open Scout in Slack"}),n.links.homeWeb&&i.jsx(so,{href:n.links.homeWeb,children:"Open in browser"})]}),i.jsx(pm,{s:n})]})};return i.jsxs(At,{tone:"inset",className:"slack-setup",children:[i.jsx("ol",{className:"pipeline sl-pipeline","aria-label":"Slack setup",children:eh.map($=>i.jsxs("li",{className:th(j,$.n),children:[i.jsx("i",{}),i.jsxs("span",{children:[$.n," ",$.title]})]},$.n))}),i.jsx("ol",{className:"sl-steps",children:eh.map($=>{const I=gm(j,$.n),R=yc(j,$.n);return i.jsxs("li",{className:th(j,$.n),children:[i.jsxs("div",{className:"sl-step-h",children:[i.jsx("span",{className:"sl-n",children:I?"✓":$.n}),i.jsx("b",{children:$.title}),I&&i.jsx(jw,{s:n,n:$.n})]}),R&&i.jsx("div",{className:"sl-step-b",children:E[$.n]})]},$.n)})})]})}function Tw(e){var n,r;return e.ok?e.kind==="app"?`✓ Socket Mode reachable · app ${e.status.setup.appId}`:`✓ Installed in ${(n=e.status.workspace)==null?void 0:n.name} as @${((r=e.status.bot)==null?void 0:r.name)??"scout"}`:`✕ ${e.error}`}function xc(e=0){const[n,r]=x.useState(),o=x.useCallback(()=>_n.get().then(r,()=>r(null)),[]);return x.useEffect(()=>{if(o(),!e)return;const l=setInterval(()=>void o(),e);return()=>clearInterval(l)},[o,e]),[n,r]}function Ew(e){const[n,r]=xc(3e3),[o,l]=x.useState(!1),c=x.useRef(null);if(x.useEffect(()=>{var g;e.focus&&n&&((g=c.current)==null||g.scrollIntoView({block:"start"}))},[e.focus,!!n]),!n)return null;const d=n.step==="done",h=g=>_n.update(g).then(r,()=>{});return i.jsxs("div",{ref:c,className:"slack-settings",children:[i.jsx(gw,{s:n,setup:o,onSetup:l,onToggle:()=>void h({enabled:!n.enabled}),onRemoved:g=>{r(g),l(!1)}}),!d&&(o||n.step!==1)&&i.jsx($w,{s:n,set:r}),o&&d&&n.state==="auth-error"&&i.jsxs(At,{tone:"inset",className:"slack-setup",children:[i.jsx("p",{children:"Generate a new app-level token or reinstall the app, then paste the new token. Settings and the owner are kept."}),i.jsx(fw,{set:r})]}),d&&i.jsx(ww,{s:n,set:r,patch:g=>void h(g)})]})}function Mw(e){const{api:n,rt:r,brief:o}=e,{snap:l,actions:c}=n,[d]=xc(15e3),h=Fs(),g=d!=null&&d.enabled&&d.state==="auth-error"?d.error??"Slack rejected the tokens":void 0;return i.jsx(Yx,{repo:e.repo,snaps:n.allSnaps,map:l==null?void 0:l.map,activity:n.activity,health:n.health,onNewTrail:e.onNewTrail,trackerLabel:r.adapter.label.toLowerCase(),onSelectMap:c.selectMap,onToggleMode:()=>l&&c.setMode(l.map.mode==="plan-only"?"plan+execute":"plan-only"),onSettings:()=>e.onSettings("top"),onToggleTheme:e.onToggleTheme,attention:e.attention,slackAlert:g,onSlack:()=>e.onSettings("slack"),decisions:n.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 Iw(e){const{m:n}=e,r=n.from==="human"?"human":"agent";return i.jsxs("div",{className:`msg from-${n.from} voice-${r}`,children:[i.jsx(re,{parts:[n.author,cc(n.at)]}),i.jsx("div",{className:"msg-text",children:n.text}),e.stillOpen&&i.jsx("button",{className:"answer-this t-meta",onClick:e.onAnswerThis,children:"Answer this"})]})}function Aw(e){const{ticket:n}=e;return i.jsxs("div",{className:"comms-ticket",children:[i.jsxs("div",{className:"t-title",title:n&&`${n.key} ${n.title}`,children:[i.jsx("span",{className:"key",children:n==null?void 0:n.key})," ",n==null?void 0:n.title]}),i.jsx(re,{parts:[e.trail,e.agent]})]})}function Ow({id:e,text:n}){const[r,o]=x.useState(),l=r!==e;return i.jsx(Bi,{size:1,framed:!1,state:l?"speaking":"alert",speaking:l?n.slice(0,60):void 0,onSpeakEnd:()=>o(e),className:"q-avatar"})}function Lw(e){const{q:n}=e;return i.jsxs("div",{className:"msg open-q",children:[i.jsx(re,{parts:[n.agent,cc(n.at)]}),i.jsx(Ow,{id:e.chatId??n.id,text:n.text}),i.jsx("div",{className:"msg-text",children:n.text})]})}function Rw(e){var n;return(n=e.options)!=null&&n.length?i.jsx("div",{className:"suggest",children:e.options.map(r=>i.jsx("button",{className:"chip",onClick:()=>e.onPick(r),children:r},r))}):null}function _w(e){const{activity:n,sessionId:r}=e,[o,l]=x.useState(""),[c,d]=x.useState(),h=x.useRef(null),g=x.useRef(null),m=n.sessions.find(O=>O.id===r),y=n.chats.filter(O=>O.sessionId===r),v=gx(n.pending,r,c??e.questionId),j=new Set(n.pending.filter(O=>O.sessionId===r).map(O=>O.id)),w=y.find(O=>!!v&&O.questionId===v.id),E=y.filter(O=>O!==w),N=m?e.snaps[m.mapId]:void 0,$=m!=null&&m.ticketId?N==null?void 0:N.tickets.find(O=>O.id===m.ticketId):void 0;x.useEffect(()=>{const O=h.current;O==null||O.scrollTo({top:O.scrollHeight,behavior:"smooth"})},[E.length,v==null?void 0:v.id]),x.useEffect(()=>{var O;v&&!e.onBack&&((O=g.current)==null||O.focus({preventScroll:!0}))},[v==null?void 0:v.id,e.onBack]);const I=O=>{!v||!O.trim()||(e.onAnswer(v.id,O.trim()),l(""))},R=Pw(m,!!v);return i.jsxs("div",{className:`comms ${v?"asking":""}`,children:[i.jsx(Nt,{title:"HITL line",right:m?i.jsx("span",{className:`status ${v?"urgent":""}`,children:R}):void 0,children:e.onBack&&i.jsx("button",{className:"back",onClick:e.onBack,"aria-label":"Back to inbox",children:"‹ Inbox"})}),m?i.jsxs(i.Fragment,{children:[i.jsx(Aw,{ticket:$,trail:N==null?void 0:N.map.title,agent:m.agent}),i.jsx("div",{className:"comms-log",ref:h,children:E.map(O=>i.jsx(Iw,{m:O,stillOpen:!!O.questionId&&j.has(O.questionId),onAnswerThis:()=>d(O.questionId)},O.id))}),v&&i.jsx(Lw,{q:v,chatId:w==null?void 0:w.id}),i.jsx(Rw,{options:v==null?void 0:v.suggestions,onPick:I}),i.jsx(gc,{ref:g,className:"comms-input",value:o,onValueChange:l,onSubmit:I,disabled:!v,placeholder:v?"Answer":""})]}):i.jsx(Le,{children:"No conversation"})]})}function Pw(e,n){return e?n?"Your answer is needed":Xt(e)?`${e.agent} is working…`:e.status==="done"?"Resolved · ticket closed":"Session ended":""}async function Dw(e){const[n,r]=e.ref.split("+"),o=await fetch(`${Ne()}/workspaces/integration`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e.mapId,a:n,b:r})});return o.ok?void 0:(await o.json().catch(()=>({}))).error??`Adding failed (${o.status})`}function Bw({item:e}){const[n,r]=x.useState(!1),[o,l]=x.useState(),c=()=>{r(!0),l(void 0),Dw(e).then(l,d=>l(d.message)).finally(()=>r(!1))};return i.jsxs("div",{className:"att-action",children:[i.jsx(K,{size:"sm",className:"integration-add",disabled:n,onClick:c,children:n?"Adding…":"Add integration ticket"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}const zw=/(\S*\/\S*|#\d+)/g;function Fw({reasons:e}){return e.length?i.jsx("span",{className:"reason-line",children:e.map((n,r)=>i.jsxs("span",{children:[r>0&&i.jsx("span",{className:"sep",children:" · "}),n.split(zw).map((o,l)=>l%2===1?i.jsx("span",{className:"t-code",children:o},l):o)]},n))}):null}const vm={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",model:"Model"},Uw={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",model:"tickets waiting for a model"},Ww=[{minutes:30,label:"30 min"},{minutes:120,label:"2 hours"},{minutes:1440,label:"Tomorrow"}],Hw=["blocked","flag","stalled","policy","reroute","overlap","integration","model"];function km(e,n){return n||e.urgency==="blocking"?"urgent":Hw.includes(e.kind)?"attention":"neutral"}const Vw=[/^marked blocking$/,/^fyi\b/,/^soon\b/,/^waiting \d/,/^answer together/,/questions from /];function ym(e){return e.reasons.filter(n=>!Vw.some(r=>r.test(n)))}function Kw(e){const{item:n,snap:r}=e,o=r==null?void 0:r.tickets.find(h=>h.id===n.ticketId),l=n.kind==="question"&&n.agent?`${n.agent} asks`:vm[n.kind],c=[];n.urgency==="blocking"&&c.push({text:"Blocking",urgent:!0,className:"urgency-tag"}),c.push({text:l,strong:!0});const d=o&&Gw(n.title,o);return d&&c.push(d),e.otherTrail&&c.push((r==null?void 0:r.map.title)??n.mapId),c}function Gw(e,n){if(!e.includes(n.key))return e.includes(n.title)?{text:n.key,code:!0}:`${n.key} ${n.title}`}function Qw(e){const[n,r]=x.useState(!1),o=l=>{r(!1),l()};return i.jsxs("span",{className:"snooze",children:[i.jsx("button",{type:"button",className:"snooze-btn","aria-expanded":n,"aria-label":`Later: ${e.title}`,onClick:()=>r(!n),children:"Later"}),n&&i.jsxs("span",{className:"snooze-menu",role:"menu",children:[Ww.map(l=>i.jsx("button",{type:"button",role:"menuitem",onClick:()=>o(()=>e.onSnooze(l.minutes)),children:l.label},l.minutes)),e.canDismiss&&i.jsx("button",{type:"button",role:"menuitem",onClick:()=>o(e.onDismiss),children:"Set aside"})]})]})}const qw=15e3;function Yw(e){const{item:n}=e,r=n.title.split(`
|
|
124
|
+
`)[0],o=ym(n),l=e.now-n.since<qw;return i.jsx(ze,{as:"li",className:`att-item k-${n.kind} u-${n.urgency} ${e.selected?"sel":""} ${l?"incoming":""}`,edge:km(n,e.interrupting),selected:e.selected,title:r,titleText:n.title,context:i.jsx(re,{parts:Kw({item:n,snap:e.snap,otherTrail:e.otherTrail})}),detail:o.length>0&&i.jsx(Fw,{reasons:o}),detailText:o.join(`
|
|
125
|
+
`),trailing:Zt(e.now-n.since),onOpen:e.onOpen,actions:i.jsx(Qw,{title:n.title,canDismiss:Xk(n),onSnooze:e.onSnooze,onDismiss:e.onDismiss}),below:n.kind==="integration"&&i.jsx(Bw,{item:n})})}function Jw(e){const n=[];for(const r of e){const o=n.at(-1);(o==null?void 0:o.key)===r.batchKey?o.items.push(r):n.push({key:r.batchKey,kind:r.kind,mapId:r.mapId,items:[r]})}return n}const Xw={question:"inbox-list",approval:"inbox-list approvals"};function Zw(e){const{batch:n}=e,r=n.items.length>1,o=n.kind==="question"?"answer together":"review together",l=[`${n.items.length} ${Uw[n.kind]}`,e.trail,o].filter(Boolean);return i.jsxs("div",{className:`att-batch ${r?"many":""}`,children:[r&&i.jsx("span",{className:"batch-head t-label",children:l.join(" · ")}),i.jsx("ul",{className:`att-list ${Xw[n.kind]??""}`,children:e.children})]})}function ej(e,n){e.ticketId?n.openTicket(e.mapId,e.ticketId):n.selectTrail(e.mapId)}function xm(e,n){switch(e.kind){case"question":return n.openQuestion(e.ref);case"approval":case"blocked":case"policy":case"flag":case"stalled":case"hitl-ready":case"overlap":case"integration":case"model":return ej(e,n);case"knowledge":return n.openKnowledge();case"brief":return n.openBrief(e.mapId);case"reroute":case"reroute-suggested":return n.openReroute(e);case"guide":case"guide-checks":return n.openGuides();default:return e.kind}}function tj(e){const n=en(1e3),{view:r}=e;if(!r.items.length)return i.jsx(Rn,{title:"Nothing waiting on you",hint:r.hidden?`${r.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,l=h=>o&&h!==e.currentMapId,c=new Set(r.interrupting),d=h=>{var g;return(g=e.pending.find(m=>m.id===h))==null?void 0:g.sessionId};return i.jsx("div",{className:"attention-queue",children:Jw(r.items).map(h=>{var g;return i.jsx(Zw,{batch:h,trail:l(h.mapId)?(g=e.snaps[h.mapId])==null?void 0:g.map.title:void 0,children:h.items.map(m=>i.jsx(Yw,{item:m,snap:e.snaps[m.mapId],otherTrail:l(m.mapId)&&h.items.length<2,selected:m.kind==="question"&&d(m.ref)===e.selected,interrupting:c.has(m.id),now:n,onOpen:()=>xm(m,e.handlers),onSnooze:y=>e.onSnooze(m.id,y),onDismiss:()=>e.onDismiss(m.id)},m.id))},h.key)})})}const nj=60*6e4;function sj(e){const{view:n}=e,r=(n.prefs.focusUntil??0)>Date.now(),o=n.interrupting.length,l=n.focused?"Focus is on: nothing interrupts you. Everything still waits in Waiting on you. Click to end focus.":"Focus for an hour: nothing interrupts you, everything still waits in Waiting on you.";return i.jsxs("span",{className:"attention-head",children:[i.jsx(K,{variant:"ghost",className:"focus-btn",on:n.focused,"aria-pressed":n.focused,"data-tip":l,onClick:()=>e.onFocus(r?void 0:Date.now()+nj),children:"Focus"}),o>0&&i.jsxs("span",{className:"waiting-chip interrupting",title:`${o} need you now`,children:[i.jsx(zs,{variant:"alert",size:14}),i.jsx("b",{children:o}),i.jsx("span",{className:"wl",children:" need you now"})]})]})}const wm=`${Ne()}/attention`,ij=250;async function nh(e,n,r){var c;const o=await fetch(`${wm}${e}`,{method:n,headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),l=await o.json().catch(()=>({}));if(!o.ok)throw new Error(((c=l.errors)==null?void 0:c.join("; "))??l.error??`HTTP ${o.status}`);return l}function jm(e){const[n,r]=x.useState(),[o,l]=x.useState(),c=x.useCallback(()=>{fetch(wm).then(h=>h.ok?h.json():void 0).then(h=>h&&r(h)).catch(()=>{})},[]);x.useEffect(()=>Lo("attention",h=>r(JSON.parse(h))),[]),x.useEffect(()=>{const h=setTimeout(c,ij);return()=>clearTimeout(h)},[c,e]);const d=(h,g)=>void nh(h,"POST",g).then(()=>(l(void 0),c()),m=>l(m.message));return{view:n,error:o,snooze:(h,g)=>d("/snooze",{id:h,minutes:g}),dismiss:h=>d("/dismiss",{id:h}),savePrefs:h=>nh("/prefs","PUT",h).then(()=>(l(void 0),c(),!0),g=>(l(g.message),!1))}}function rj(e){return e.prefs.channel!=="browser"?!1:typeof Notification<"u"&&Notification.permission==="granted"}function oj(e){const n=new Notification(`${ve.name} · needs you`,{body:e.title,tag:e.id});n.onclick=()=>{window.focus(),n.close()}}function aj(e){const n=x.useRef();x.useEffect(()=>{if(!e)return;const r=new Set(e.interrupting),o=n.current;if(n.current=r,!(!o||!rj(e)))for(const l of e.items)r.has(l.id)&&!o.has(l.id)&&oj(l)},[e])}function lj(e){const n=en(1e3);return e.items.length?i.jsx("ul",{className:"inbox-list approvals",children:e.items.map(r=>{var c;const o=r.kind!=="approve",l=r.mapId!==e.currentMapId?(c=e.snaps[r.mapId])==null?void 0:c.map.title:void 0;return i.jsx(ze,{as:"li",edge:o?"attention":"neutral",title:`${o?"Decide":"Approve"}: ${r.title}`,context:i.jsx(re,{parts:[o?"Held":"Verified",{text:r.ticketKey,code:!0},l]}),detail:r.reason,detailText:r.reason,trailing:Zt(n-r.at),onOpen:()=>e.onOpen(r.mapId,r.ticketId)},`${r.mapId}/${r.ticketId}`)})}):null}function sh({activity:e}){const n=en(1e3),r=ik(e);return i.jsxs("div",{className:"hitl-readout",children:[i.jsx(Yt,{layout:"inline",label:"Oldest",value:r.oldestAt?Ft(n-r.oldestAt):"—",urgent:!!r.oldestAt&&n-r.oldestAt>6e4,title:"Oldest open question"}),i.jsx(Yt,{layout:"inline",label:"Avg wait",value:r.avgWaitMs!==void 0?Ft(r.avgWaitMs):"—",title:`Average wait over ${r.answered} answered questions`}),i.jsx(Yt,{layout:"inline",label:"Answered",value:r.answered})]})}function cj(e){const n=en(1e3);return e.items.length?i.jsx("ul",{className:"inbox-list",children:e.items.map(r=>{const o=e.snaps[r.mapId],l=o==null?void 0:o.tickets.find(h=>h.id===r.ticketId),c=r.mapId!==e.currentMapId?o==null?void 0:o.map.title:void 0,d=r.text.split(`
|
|
126
|
+
`)[0];return i.jsx(ze,{as:"li",className:r.sessionId===e.selected?"sel":void 0,edge:r.urgency==="blocking"?"urgent":"neutral",selected:r.sessionId===e.selected,title:d,titleText:r.text,context:i.jsx(re,{parts:[r.urgency==="blocking"&&{text:"Blocking",urgent:!0},`${r.agent} asks`,l&&{text:l.key,code:!0},l==null?void 0:l.title,c]}),trailing:Zt(n-r.at),onOpen:()=>e.onOpen(r.sessionId,r.ticketId)},r.id)})}):i.jsx(Rn,{title:"Nothing waiting on you",hint:"When an agent needs your call, its question lands here."})}const uj={pass:"Passed",fail:"Failed",error:"Could not run",interrupted:"Interrupted"},_i={off:"Off",checks:"Checks","checks+review":"Checks + review","checks+review+human":"Checks + review + you"},Sm={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."},dj=e=>e.exitCode===0&&!e.timedOut&&!e.error;async function ih(e){const n=await e.json().catch(()=>({}));if(!e.ok)throw new Error(n.error??`HTTP ${e.status}`);return n}const io=`${Ne()}/verification`,Ui={ticket:(e,n)=>fetch(`${io}/ticket?mapId=${encodeURIComponent(e)}&ticketId=${encodeURIComponent(n)}`).then(r=>r.ok?r.json():void 0,()=>{}),inbox:()=>fetch(`${io}/inbox`).then(e=>e.ok?e.json().then(n=>n.items):[],()=>[]),log:e=>fetch(`${io}/log?path=${encodeURIComponent(e)}`).then(n=>ih(n)),act:e=>fetch(`${io}/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(n=>ih(n))};function fj(e){const[n,r]=x.useState([]),o=Object.values(e).map(l=>l.tickets.map(c=>`${c.id}:${c.state}:${c.status??""}`).join()).join("|");return x.useEffect(()=>{let l=!0;const c=()=>void Ui.inbox().then(h=>l&&r(h));c();const d=Ps.onEvidence(c);return()=>{l=!1,d()}},[o]),n}function hj(e,n){return{...e,items:e.items.filter(r=>!(r.kind==="brief"&&r.mapId===n))}}function mj(e){var h;const n=[...e.activity.pending].sort((g,m)=>g.at-m.at),r=fj(e.snaps),o=(h=e.attention)==null?void 0:h.view,l=o&&e.briefShown?hj(o,e.currentMapId):o,c=l?l.items.length:n.length+r.length,d=i.jsx(Nt,{hot:c>0,title:i.jsxs(i.Fragment,{children:[c>0&&i.jsx(zs,{variant:"alert",size:12}),"Waiting on you"]}),count:i.jsx(Zn,{n:c,urgent:c>0,pop:!0},c)});return l&&e.attention&&e.handlers?i.jsxs("div",{className:"inbox-part",children:[d,i.jsx(sh,{activity:e.activity}),i.jsx(tj,{view:l,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(sh,{activity:e.activity}),i.jsx(lj,{items:r,snaps:e.snaps,currentMapId:e.currentMapId,onOpen:e.onOpenTicket}),(n.length>0||!r.length)&&i.jsx(cj,{items:n,snaps:e.snaps,currentMapId:e.currentMapId,selected:e.sessionId,onOpen:e.onOpenQuestion})]})}function pj(e){const[n,r]=x.useState("list"),[o,l]=x.useState();x.useEffect(()=>{e.convRequest&&r("conv")},[e.convRequest]);const c=(y,v)=>{e.onOpen(y,v),r("conv")},d=y=>{const v=e.activity.pending.find(j=>j.id===y);v&&(l(v.id),c(v.sessionId,v.ticketId))},h=i.jsx(mj,{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}),g=i.jsx(_w,{activity:e.activity,snaps:e.snaps,sessionId:e.sessionId,questionId:o,onAnswer:e.onAnswer,onBack:e.layout==="stack"?()=>r("list"):void 0});if(e.layout==="stack")return i.jsx(We,{className:"zone inbox stack",children:n==="conv"&&e.sessionId?g:i.jsxs("div",{className:"stack-scroll",children:[e.above,h,e.below]})});const m=!!e.activity.sessions.find(y=>y.id===e.sessionId);return i.jsxs(We,{className:`zone inbox split ${m?"has-conv":""}`,style:{gridArea:"inbox"},children:[i.jsx(Nt,{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,m&&g,e.below]})}function gj(e){var h;const{snap:n}=e,r=n?Bs(n.tickets,n.map.mode):new Map,o={claimed:0,frontier:1},l=((n==null?void 0:n.tickets)??[]).filter(g=>o[r.get(g.id)]!==void 0).sort((g,m)=>o[r.get(g.id)]-o[r.get(m.id)]),c=new Set(e.sessions.filter(cm).map(g=>g.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(Nt,{title:"Up next",count:i.jsx("span",{className:"n mono-label",children:l.length})}),!n&&i.jsx(Le,{children:"Ready tickets show here"}),n&&!l.length&&i.jsx(Le,{children:"Nothing ready"}),n&&l.length>0&&i.jsx("ul",{className:"ticket-list",children:l.map(g=>{const m=r.get(g.id),y=vj({state:m,waiting:c.has(g.id),assignee:g.assignee,hitl:Pi(g)==="hitl"});return i.jsx("li",{className:`${d===g.id?"sel":""} st-${c.has(g.id)?"waiting":m}`,children:i.jsxs("button",{onClick:()=>e.onSelect({kind:"ticket",id:g.id}),children:[i.jsx("i",{className:"dot"}),i.jsx("span",{className:"key t-code",children:g.key}),i.jsx("span",{className:"ttl t-body",children:g.title}),i.jsx("span",{className:"st-text t-meta",children:y})]})},g.id)})})]})}function vj(e){if(e.waiting)return"waiting on you";if(e.state==="claimed")return e.assignee??"claimed";const n=im[e.state].toLowerCase();return e.hitl?`${n}, needs you`:n}function kj(e){const{api:n,nav:r}=e;return i.jsx(pj,{activity:n.activity,snaps:n.allSnaps,currentMapId:n.mapId,sessionId:n.chatSession,layout:e.bp==="mobile"?"stack":"split",convRequest:r.convRequest,onOpen:r.openChat,onAnswer:n.actions.answer,onOpenTicket:r.openTicket,attention:e.attn.attention,handlers:e.attn.handlers,below:i.jsx(gj,{snap:n.snap,sessions:e.scoped.sessions,selection:n.selection,onSelect:r.select}),above:e.above})}function ko({command:e,label:n="Copy"}){const[r,o]=x.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:r?"Copied":n})]})}const ro=[{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"}],yj=9e3;function xj(){const[e,n]=x.useState(0),[r,o]=x.useState(!1);x.useEffect(()=>{if(r)return;const c=setInterval(()=>n(d=>(d+1)%ro.length),yj);return()=>clearInterval(c)},[r]);const l=ro[e];return i.jsxs("div",{className:"command-bar real",children:[i.jsx(um,{name:"map"}),i.jsx(Ye,{as:"h2",className:"zone-title-label",children:"Trail map"}),i.jsx(Fi,{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:l.text}),l.command&&i.jsx(ko,{command:l.command})]},e),i.jsxs("button",{type:"button",className:"link hint-next","data-tip":"Next hint","aria-label":"Next hint",onClick:()=>n(c=>(c+1)%ro.length),children:[e+1,"/",ro.length," ›"]})]})}function wj(e){const n=[{v:"plan+execute",title:"Plan + execute"},{v:"plan-only",title:"Plan only"}];return i.jsx("div",{className:"choice-row",children:n.map(r=>i.jsx(ft,{on:e.value===r.v,title:r.title,onClick:()=>e.onChange(r.v)},r.v))})}function jj({onClose:e,tracker:n,onCreate:r}){const[o,l]=x.useState(),[c,d]=x.useState(!1),[h,g]=x.useState(),[m,y]=x.useState(""),[v,j]=x.useState(""),[w,E]=x.useState(""),[N,$]=x.useState(""),I=[m.trim(),v.trim(),w.trim()].filter(Boolean).join(". ").replace(/"/g,"'");return x.useEffect(()=>{const R=O=>O.key==="Escape"&&e();return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[e]),i.jsx("div",{className:"scrim",onClick:e,children:i.jsxs(We,{as:"div",className:"dialog",onClick:R=>R.stopPropagation(),children:[i.jsx("header",{children:i.jsx("h2",{className:"t-heading caps",children:"New trail"})}),i.jsx(qe,{label:"Title",children:i.jsx("input",{value:m,onChange:R=>y(R.target.value),autoFocus:!0})}),i.jsx(qe,{label:"Destination",children:i.jsx("textarea",{rows:3,value:v,onChange:R=>j(R.target.value),placeholder:"What is true when this trail is done?"})}),i.jsx(qe,{label:"Notes",children:i.jsx("textarea",{rows:2,value:w,onChange:R=>E(R.target.value)})}),i.jsx(qe,{label:"Assumptions (optional, one per line)",children:i.jsx("textarea",{className:"new-trail-assumptions",rows:2,value:N,onChange:R=>$(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 ",n,"."]}),i.jsx(ko,{command:`/scout new "${I||"your idea"}"`,label:"Copy command"})]}),o?i.jsxs("div",{className:"agent-draft created",children:[i.jsxs("span",{children:["Trail ",o," is on the map, starting with discovery. To get it moving, run this in Claude Code or Codex:"]}),i.jsx(ko,{command:"/scout resume",label:"Copy command"})]}):h&&i.jsx("p",{className:"vf-err",children:h}),i.jsxs("footer",{children:[i.jsx(K,{variant:"ghost",onClick:e,children:"Close"}),!o&&i.jsx(K,{variant:"primary",disabled:c||!m.trim()||!v.trim(),"data-tip":"Put the trail on the map now; any agent picks it up with /scout resume",onClick:()=>{d(!0);const R=N.split(`
|
|
127
|
+
`).map(O=>O.trim());r({title:m.trim(),destination:v.trim(),notes:w.trim(),assumptions:R.filter(Boolean)}).then(O=>l(O.key)).catch(O=>g(O.message)).finally(()=>d(!1))},children:"Create trail"})]})]})})}const rh=["Ready when you are","What's the next big idea?","I keep the party on the trail","Describe it, I frame it"],Sj=5e3;function Nj(){const e=Ro(),[n,r]=x.useState(0),[o,l]=x.useState(!0);return x.useEffect(()=>{if(o)return;const c=setTimeout(()=>{r(d=>(d+1)%rh.length),l(!0)},Sj);return()=>clearTimeout(c)},[o]),i.jsxs("div",{className:"floating-scout","aria-hidden":"true",children:[i.jsx(Bi,{variant:e?"night":"crt",size:3,framed:!1,speaking:o?rh[n]:void 0,onSpeakEnd:()=>l(!1),className:"fm-avatar"}),i.jsx("span",{className:"fm-shadow"})]})}function bj(e){return i.jsx(jj,{onClose:e.onClose,tracker:e.rt.adapter.label,onCreate:async n=>{const r=await ix(e.rt.adapter,n);return e.onCreated(r.id),r}})}const Cj={stored:"Saved token",gh:"gh CLI",GITHUB_TOKEN:"$GITHUB_TOKEN",GH_TOKEN:"$GH_TOKEN",LINEAR_API_KEY:"$LINEAR_API_KEY"},co=e=>e==="github"||e==="linear";function Nm(e){const[n,r]=x.useState(!e.source);return e.source&&!n?i.jsxs("div",{className:"ts-auth",children:[i.jsx("span",{className:"mono-label",children:e.label}),i.jsx("span",{className:"pill on",children:Cj[e.source]}),i.jsx("button",{type:"button",className:"btn ghost sm",onClick:()=>r(!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 bm({r:e}){var o,l;if(!e)return null;if(!e.ok)return i.jsxs("div",{className:"test-line alert",children:["✕ ",e.error]});const n=(o=e.rate)!=null&&o.limit?`${(l=e.rate.remaining)==null?void 0:l.toLocaleString()}/${e.rate.limit.toLocaleString()} req`:"";let r="";return e.canWrite===!1?r="read-only":e.canWrite&&(r="read/write"),i.jsxs("div",{className:"test-line ok",children:["✓ ",[e.account,e.target,r,n].filter(Boolean).join(" · ")]})}const Pn=ky(Ne());function Oi(e,n){e({tracker:n});const r=new URL(location.href);r.searchParams.delete("tracker"),location.href=r.toString()}function Cm(e){const n=e.s.github,[r,o]=x.useState(n.repo??n.detectedRepo??""),[l,c]=x.useState(""),[d,h]=x.useState(),[g,m]=x.useState(),y=x.useCallback(async()=>{m("test"),h(await Pn.test({kind:"github",repo:r,token:l||void 0}).catch(j=>({ok:!1,error:j.message}))),m(void 0)},[r,l]);x.useEffect(()=>{n.auth&&r&&y()},[]);const v=async()=>{m("connect");try{await Pn.connect({active:"github",github:{repo:r,token:l||void 0}}),e.onConnected()}catch(j){h({ok:!1,error:j.message}),m(void 0)}};return i.jsxs("div",{className:"card inset tracker-setup",children:[i.jsxs("label",{className:"field",children:["Repository",i.jsx("input",{value:r,placeholder:"owner/name",spellCheck:!1,onChange:j=>o(j.target.value.trim())})]}),i.jsx(Nm,{source:n.auth,value:l,onChange:c,label:"Token",placeholder:"ghp_… or github_pat_…",link:{href:"https://github.com/settings/personal-access-tokens/new",text:"New token"}}),i.jsx(bm,{r:d}),i.jsxs("footer",{children:[i.jsx("button",{type:"button",className:"btn",disabled:!!g||!r,onClick:()=>void y(),children:g==="test"?"Testing…":"Test connection"}),i.jsx("button",{type:"button",className:"btn primary",disabled:!!g||!r||!n.auth&&!l,onClick:()=>void v(),children:g==="connect"?"Connecting…":"Connect"})]})]})}function $m(e){var R;const n=e.s.linear,[r,o]=x.useState(""),[l,c]=x.useState(n.teamId??""),[d,h]=x.useState(n.projectId??""),[g,m]=x.useState(),[y,v]=x.useState([]),[j,w]=x.useState(),E=x.useCallback(async(O=l)=>{w("test");const te=await Pn.test({kind:"linear",apiKey:r||void 0,teamId:O||void 0}).catch(se=>({ok:!1,error:se.message}));m(te),te.teams&&(v(te.teams),!O&&te.teams.length===1&&c(te.teams[0].id)),w(void 0)},[r,l]);x.useEffect(()=>{n.auth&&E()},[]);const N=y.find(O=>O.id===l),$=(R=g==null?void 0:g.projects)==null?void 0:R.find(O=>O.id===d),I=async()=>{if(N){w("connect");try{await Pn.connect({active:"linear",linear:{teamId:N.id,teamKey:N.key,teamName:N.name,projectId:$==null?void 0:$.id,projectName:$==null?void 0:$.name,apiKey:r||void 0}}),e.onConnected()}catch(O){m({ok:!1,error:O.message}),w(void 0)}}};return i.jsxs("div",{className:"card inset tracker-setup",children:[i.jsx(Nm,{source:n.auth,value:r,onChange:o,label:"API key",placeholder:"lin_api_…",link:{href:"https://linear.app/settings/account/security",text:"New key"}}),y.length>0&&i.jsxs("div",{className:"ts-row",children:[i.jsxs("label",{className:"field",children:["Team",i.jsx(lt,{"aria-label":"Team",value:l,onChange:O=>{c(O),h(""),E(O)},options:[...l?[]:[{value:"",label:"Choose…"}],...y.map(O=>({value:O.id,label:`${O.key} · ${O.name}`}))]})]}),i.jsxs("label",{className:"field",children:["Project",i.jsx(lt,{"aria-label":"Project",value:d,onChange:h,disabled:!(g!=null&&g.projects),options:[{value:"",label:"All projects"},...((g==null?void 0:g.projects)??[]).map(O=>({value:O.id,label:O.name}))]})]})]}),i.jsx(bm,{r:g}),i.jsxs("footer",{children:[i.jsx("button",{type:"button",className:"btn",disabled:!!j||!n.auth&&!r,onClick:()=>void E(),children:j==="test"?"Testing…":"Test connection"}),i.jsx("button",{type:"button",className:"btn primary",disabled:!!j||!N,onClick:()=>void I(),children:j==="connect"?"Connecting…":"Connect"})]})]})}function $j(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 Tj({status:e}){var c,d;if(!e)return null;const n=(c=e.rate)!=null&&c.limit?`${((d=e.rate.remaining)==null?void 0:d.toLocaleString())??"?"}/${e.rate.limit.toLocaleString()} req`:"",r=e.queued?` · ${e.queued} queued`:"",[o,l]=Ej(e,r);return i.jsxs("div",{className:`sync-line ${o}`,title:e.error,children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:l}),n&&i.jsx("span",{className:"rate",children:n})]})}function Ej(e,n){switch(e.state){case"online":return["ok",`Online · synced ${sm(e.lastSyncAt)}${n}`];case"offline":return["warn",`Offline${n}`];case"rate-limited":return["warn",`Rate limited · resumes ${zi(e.resetAt)}${n}`];case"auth-error":return["alert",`Credentials rejected${n}`];default:return["",`Connecting${n}`]}}function Mj(e){const{id:n,active:r,configured:o,s:l}=e,c=co(n),d=!c||!!l,h=["card connector",r?"active":"",d?"":"disabled",e.open?"open":""],g=(n==="markdown"||c)&&r,m=c&&!r&&o&&l?Ij(n,l):void 0;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}),r&&i.jsx("span",{className:"pill on",children:"Active"})]}),g&&i.jsx("div",{className:"c-loc",children:e.location}),m!==void 0&&i.jsx("div",{className:"c-loc",children:m}),c&&r&&i.jsx(Tj,{status:l==null?void 0:l[n].status}),i.jsx($j,{canSwitch:!r&&(!c||o),remote:c,usable:d,configured:o,open:e.open,onSwitch:e.onSwitch,onToggle:e.onToggle})]})}function Ij(e,n){return e==="github"?n.github.repo:[n.linear.teamKey,n.linear.projectName].filter(Boolean).join(" · ")}function Tm(e=0){const[n,r]=x.useState(),o=x.useCallback(()=>Pn.get().then(r,()=>r(null)),[]);return x.useEffect(()=>{if(o(),!e)return;const l=setInterval(()=>void o(),e);return()=>clearInterval(l)},[o,e]),[n,r,o]}function Aj(e){const[n]=Tm(5e3),[r,o]=x.useState(null),l=async d=>{n&&(d==="markdown"||co(d))&&await Pn.connect({active:d==="markdown"?"markdown":d,...d==="github"&&n.github.repo?{github:{repo:n.github.repo}}:{},...d==="linear"&&n.linear.teamId?{linear:{teamId:n.linear.teamId,teamKey:n.linear.teamKey,teamName:n.linear.teamName,projectId:n.linear.projectId,projectName:n.linear.projectName}}:{}}).catch(()=>{}),Oi(e.update,d)},c=x.useMemo(()=>({github:!!(n!=null&&n.github.repo),linear:!!(n!=null&&n.linear.teamId)}),[n]);return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"connectors",children:yy.map(d=>{const h=d.id;return i.jsx(Mj,{id:h,name:d.name,active:h===e.activeTracker,configured:co(h)&&c[h],open:r===h,location:e.location,s:n,onSwitch:()=>void l(h),onToggle:()=>co(h)&&o(r===h?null:h)},d.id)})}),n&&r==="github"&&i.jsx(Cm,{s:n,onConnected:()=>Oi(e.update,"github")}),n&&r==="linear"&&i.jsx($m,{s:n,onConnected:()=>Oi(e.update,"linear")})]})}function Ke(e){return i.jsxs("section",{className:"set-sec",children:[i.jsx(Ye,{as:"h4",children:e.title}),e.children]})}function Em(e){const n=[{v:"summary",title:"Summary"},{v:"full",title:"Full transcript"}];return i.jsx("div",{className:"choice-row",children:n.map(r=>i.jsx(ft,{on:e.value===r.v,title:r.title,onClick:()=>e.onChange(r.v)},r.v))})}function Oj(e){const{prefs:n,update:r}=e,[o]=Tm(),[l,c]=x.useState(),[d,h]=x.useState(!1),g=o!=null&&o.github.auth?o.github.repo??o.github.detectedRepo:void 0,m=[{id:"markdown",title:"Local markdown",sub:"Files in .teamtrail/ in this repo"},{id:"github",title:"GitHub Issues",sub:"Trails as labelled issues in your repo"},{id:"linear",title:"Linear",sub:"Trails and tickets in your Linear team"}],y=n.tracker==="github"&&!g||n.tracker==="linear",v=w=>{r({onboarded:!0}),Oi(r,w)},j=async()=>{if(n.tracker==="github"&&g){h(!0);try{await Pn.connect({active:"github",github:{repo:g}})}catch(w){c(w.message),h(!1);return}}else n.tracker==="markdown"&&o&&await Pn.connect({active:"markdown"}).catch(()=>{});r({onboarded:!0}),n.tracker!==e.activeTracker&&Oi(r,n.tracker)};return i.jsx("div",{className:"scrim",children:i.jsxs(We,{as:"div",className:"dialog onboarding",children:[i.jsxs("div",{className:"onb-brand",children:[i.jsx($x,{size:64}),i.jsx(dm,{as:"div",className:"onb-title"})]}),i.jsx("div",{className:"onb-cat mono-label",children:ve.category}),i.jsx("p",{className:"onb-tagline",children:ve.tagline}),i.jsxs("p",{className:"scout-line",children:[i.jsxs(Ye,{children:[i.jsx(pc,{className:"voice-badge"})," ",ve.assistant.name]})," ","Where should your trails live?"]}),i.jsxs(Ke,{title:"Tracker",children:[i.jsx("div",{className:"choice-row",children:m.map(w=>i.jsx(ft,{on:n.tracker===w.id,title:w.title,sub:w.sub,onClick:()=>r({tracker:w.id})},w.id))}),o&&n.tracker==="github"&&!g&&i.jsx(Cm,{s:o,onConnected:()=>v("github")}),o&&n.tracker==="linear"&&i.jsx($m,{s:o,onConnected:()=>v("linear")}),l&&i.jsxs("div",{className:"test-line alert",children:["✕ ",l]})]}),i.jsx(Ke,{title:"HITL transcript",children:i.jsx(Em,{value:n.hitlTranscript,onChange:w=>r({hitlTranscript:w})})}),i.jsx("footer",{children:i.jsx(K,{variant:"primary",disabled:d||y,onClick:()=>void j(),children:"Get started"})})]})})}function Mm(e){return i.jsx("ul",{className:"checklist-answers",children:e.answers.map(n=>i.jsxs("li",{className:n.done?"done":"not-done",children:[i.jsx("span",{className:"mark","aria-label":n.done?"Done":"Not done",children:n.done?"✓":"–"}),i.jsx("span",{className:"t-body",children:n.item}),n.note&&i.jsx("span",{className:"t-meta note",children:n.note})]},n.item))})}const Im=`${ve.apiPrefix}`;async function Am(e){const n=await e.json().catch(()=>({}));if(!e.ok)throw new Error(n.error??`Request failed (${e.status})`);return n}const yo=async e=>Am(await fetch(`${Im}${e}`)),Om=async(e,n)=>Am(await fetch(`${Im}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}));let Lm;const uo=new Set;let Ts;function xo(e){Lm=e;for(const n of uo)n()}function oh(){yo("/guides").then(xo,()=>xo(null))}const Lj=()=>Lm;function Rj(e){return uo.add(e),Ts||(oh(),Ts=fn(n=>{n.includes("guides")&&oh()})),()=>{uo.delete(e),!uo.size&&(Ts==null||Ts(),Ts=void 0)}}function hn(){const e=x.useSyncExternalStore(Rj,Lj),n=x.useCallback(async(o,l)=>{try{xo(await Om(o,l));return}catch(c){return c.message}},[]),r=x.useCallback(o=>o?e==null?void 0:e.guides.find(l=>l.id===o):void 0,[e]);return{view:e,act:n,find:r}}function _j(e){var h;const{view:n,find:r}=hn(),o=r(e.id),l=n!=null&&(o==null?void 0:o.status)!=="active",c=((h=o==null?void 0:o.guide)==null?void 0:h.name)??e.id,d=l?`${c}: ${(o==null?void 0:o.reason)??"not installed"}`:`Guide: ${c}`;return i.jsx("span",{className:tt("guide-chip",l&&"off"),"data-guide-id":e.id,title:d,children:c})}function Pj(e){var c,d;const{view:n,find:r}=hn(),o=r(e.id),l=n!=null&&(o==null?void 0:o.status)!=="active";return i.jsxs("text",{className:tt("guide-chip","guide-tag",l&&"off"),"data-guide-id":e.id,x:2,y:-5,children:[i.jsx("title",{children:l?`${e.id}: ${(o==null?void 0:o.reason)??"not installed"}`:`Guide: ${((c=o==null?void 0:o.guide)==null?void 0:c.name)??e.id}`}),((d=o==null?void 0:o.guide)==null?void 0:d.name)??e.id]})}var Dj=Ch();const Bj={active:"Active",unapproved:"New, waiting for your approval",tampered:"Changed since you approved it",invalid:"Can't be used"};function zj(e){var r;if(e.origin==="builtin")return"Built in";const n=(r=e.lock)==null?void 0:r.source;if(!n||n==="local")return e.overridesBuiltin?"Local file, replaces the built-in":"Local file";try{return`From ${new URL(n.registry).host}`}catch{return"From a catalog"}}const wc=e=>e.map(n=>/\s/.test(n)?JSON.stringify(n):n).join(" ");function Fj(e){var j;const{preview:n}=e,{act:r,find:o}=hn(),[l,c]=x.useState({kind:"ready"}),[d,h]=x.useState(),g=n.entry.id,m=async()=>{h(void 0),c({kind:"adding"});try{c({kind:"added",pending:(await e.add(g)).pendingChecks})}catch(w){h(w.message),c({kind:"ready"})}};if(n.entry.builtin)return i.jsxs("span",{className:"t-meta",children:["Built into ",ve.name,": already available to every trail, nothing to add."]});if(l.kind!=="added"){const w=e.installed===n.entry.version,E=e.installed?"Update guide":"Add guide";return i.jsxs("div",{className:"add-guide",children:[!n.ok&&i.jsx("span",{className:"t-meta",children:"The safety lint found errors, so this guide can't be added."}),i.jsx(K,{variant:"primary",disabled:!n.ok||w||l.kind==="adding",onClick:()=>void m(),children:w?"Added":E}),d&&i.jsx("span",{className:"vf-err",children:d})]})}const y=((j=o(g))==null?void 0:j.pendingChecks)??l.pending,v=async w=>h(await r("/guides/checks/approve",{id:g,name:w}));return i.jsxs("div",{className:"add-guide",children:[i.jsx("p",{className:"t-body",children:y.length?`Added ${g} ${n.entry.version}. Approve each command it proposes; none runs until you do.`:`Added ${g} ${n.entry.version}. Agents get its instructions on tickets that ask for ${g}.`}),y.map(w=>{var E,N;return i.jsxs("span",{className:"guide-check",children:[i.jsxs("code",{className:"t-code",children:[w,": ",wc(((N=(E=n.guide)==null?void 0:E.proposedChecks[w])==null?void 0:N.run)??[])]}),i.jsxs(K,{size:"sm",onClick:()=>void v(w),children:["Approve check ",w]})]},w)}),d&&i.jsx("span",{className:"vf-err",children:d})]})}function Uj(e){return e.findings.length?i.jsx("ul",{className:"vf-findings guide-findings",children:e.findings.map((n,r)=>i.jsxs("li",{className:`sev-${n.level}`,children:[i.jsxs("code",{className:"t-code",children:["line ",n.line]})," ",n.message," ",i.jsxs("span",{className:"t-meta",children:["(",n.rule,")"]})]},r))}):i.jsx("p",{className:"t-meta",children:"The safety lint found nothing."})}function Wj(e){var o,l;const{p:n}=e,r=Object.entries(((o=n.guide)==null?void 0:o.proposedChecks)??{});return i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"t-label",children:"Safety lint"}),i.jsx(Uj,{findings:n.findings}),n.guide&&n.guide.checklist.length>0&&i.jsx("span",{className:"t-label",children:"Checklist"}),n.guide&&i.jsx("ul",{className:"catalog-checklist t-body",children:n.guide.checklist.map(c=>i.jsx("li",{children:c},c))}),r.length>0&&i.jsx("span",{className:"t-label",children:"Commands it proposes"}),r.map(([c,d])=>i.jsxs("code",{className:"t-code guide-check",children:[c,": ",wc(d.run)]},c)),i.jsx("span",{className:"t-label",children:"Instructions"}),i.jsx("pre",{className:"guide-preview",children:((l=n.guide)==null?void 0:l.instructions)??n.text})]})}function Hj(e){if(!e.repo)return null;const n=encodeURIComponent(`Report: ${e.id} ${e.version}`),r=`${e.repo.replace(/\/+$/,"")}/issues/new?template=report-guide.yml&title=${n}`;return i.jsx("a",{className:"report-link t-meta",href:r,target:"_blank",rel:"noreferrer",children:"Report this guide"})}function Vj(e){const n=e.entry,[r,o]=x.useState(),[l,c]=x.useState();return x.useEffect(()=>{e.preview(n.id).then(o,d=>c(d.message))},[n.id]),i.jsxs("div",{className:"catalog-entry",children:[i.jsx(K,{size:"sm",variant:"ghost",onClick:e.onBack,children:"← All guides"}),i.jsx("h3",{className:"t-title",children:n.name??n.id}),i.jsx(re,{parts:[{text:n.id,code:!0},n.version,`by ${n.author}`,Kj(n),n.reviewedBy.length>0&&`reviewed by ${n.reviewedBy.join(", ")}`]}),i.jsx("p",{className:"t-body",children:n.summary}),n.history.length>0&&i.jsx("ul",{className:"catalog-history",children:n.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.reviewer&&` · reviewed by ${d.reviewer}`]},`${d.version}-${d.commit}`))}),l&&i.jsx("span",{className:"vf-err",children:l}),r&&i.jsx(Wj,{p:r}),r&&i.jsx(Hj,{repo:r.repo,id:n.id,version:n.version}),r&&i.jsx(Fj,{preview:r,installed:e.installed,add:e.add})]})}function Kj(e){return e.builtin?{text:"Built in",strong:!0}:e.verified?{text:"Verified",strong:!0}:"Not reviewed"}function Gj(e){const n=e.entry;return i.jsx("li",{className:"catalog-row","data-guide-id":n.id,children:i.jsx(ze,{title:n.name??n.id,context:i.jsx(re,{parts:[{text:n.id,code:!0},n.version,n.author,Qj(n),n.reported&&"Reported"]}),detail:n.summary,trailing:e.installed&&`installed ${e.installed}`,onOpen:e.onOpen})})}function Qj(e){return e.builtin?{text:"Built in",strong:!0}:e.verified?{text:"Verified",strong:!0}:"Not reviewed"}const ah=e=>e?`registry=${encodeURIComponent(e)}`:"";function qj(e){const[n,r]=x.useState(),[o,l]=x.useState();x.useEffect(()=>{let h=!0;return r(void 0),l(void 0),yo(`/guides/catalog?${ah(e)}`).then(g=>h&&r(g),g=>h&&l(g.message)),()=>{h=!1}},[e]);const c=x.useCallback(h=>yo(`/guides/catalog/preview?${ah(e)}&id=${encodeURIComponent(h)}`),[e]),d=x.useCallback(async h=>{const g=await Om("/guides/catalog/add",{registry:e,id:h});return xo(g),g.installed},[e]);return{index:n,error:o,preview:c,add:d}}function Yj(e){var E,N;const[n,r]=x.useState(((E=e.registries[0])==null?void 0:E.name)??""),o=qj(n||void 0),{find:l}=hn(),[c,d]=x.useState(""),[h,g]=x.useState(!0),[m,y]=x.useState(),v=o.index?wy({guides:o.index.guides},{query:c,verifiedOnly:h}):[],j=(N=o.index)==null?void 0:N.guides.find($=>$.id===m),w=$=>{var I,R,O;return((I=l($))==null?void 0:I.origin)==="local"?(O=(R=l($))==null?void 0:R.guide)==null?void 0:O.version:void 0};return Dj.createPortal(i.jsx("div",{className:"scrim catalog-scrim",onClick:$=>{$.stopPropagation(),e.onClose()},children:i.jsxs(We,{as:"div",className:"dialog catalog-dialog",onClick:$=>$.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h3",{className:"t-title",children:"Guide catalog"}),e.registries.length>1&&i.jsx(lt,{compact:!0,"aria-label":"Catalog",value:n,options:e.registries.map($=>({value:$.name,label:$.name,hint:$.url})),onChange:r}),i.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})]}),j?i.jsx(Vj,{entry:j,installed:w(j.id),preview:o.preview,add:o.add,onBack:()=>y(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:$=>d($.target.value)}),i.jsx(K,{size:"sm",on:h,"aria-pressed":h,onClick:()=>g($=>!$),children:"Verified only"})]}),o.error&&i.jsx("span",{className:"vf-err",children:o.error}),!o.index&&!o.error&&i.jsx(Le,{children:"Reading the catalog…"}),o.index&&!v.length&&i.jsx(Le,{children:"No guides match."}),i.jsx("ul",{className:"catalog-list",children:v.map($=>i.jsx(Gj,{entry:$,installed:w($.id),onOpen:()=>y($.id)},$.id))})]})]})}),document.body)}function Jj(e){const n=e.r.guide;if(!n)return null;const r=Object.entries(n.proposedChecks);if(!n.requiresChecks.length&&!r.length)return null;const o=e.r.status==="active";return i.jsxs("div",{className:"guide-checks",children:[n.requiresChecks.length>0&&i.jsxs("span",{className:"t-meta",children:["Adds checks ",i.jsx("code",{className:"t-code",children:n.requiresChecks.join(", ")})," to its tickets"]}),r.map(([l,c])=>{const d=e.r.pendingChecks.includes(l);return i.jsxs("span",{className:"guide-check",children:[i.jsxs("code",{className:"t-code",children:[l,": ",wc(c.run)]}),d&&o&&i.jsxs(K,{size:"sm",disabled:e.busy,onClick:()=>e.onApprove(l),children:["Approve check ",l]}),d&&!o&&i.jsx("span",{className:"t-meta",children:"approve the guide first"}),!d&&i.jsx("span",{className:"t-meta",children:"approved"})]},l)})]})}function Xj(e){var d;const{r:n}=e,r=n.id,o=n.status!=="active"||n.pendingChecks.length>0,l=(n.status==="unapproved"||n.status==="tampered")&&!!n.guide,c=n.guide?`${n.guide.name} ${n.guide.version}`:r;return i.jsx("li",{className:"guide-row","data-guide-id":r,children:i.jsx(ze,{edge:o?"attention":"neutral",title:c,context:i.jsx(re,{parts:[{text:r,code:!0},zj(n),n.status!=="active"&&Bj[n.status],n.guide&&Zj(n.guide.checklist.length)]}),detail:n.reason??((d=n.guide)==null?void 0:d.summary),actions:n.origin==="local"&&i.jsxs(K,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>e.onAct("/guides/remove",{id:r}),children:["Remove guide ",r]}),below:i.jsxs(i.Fragment,{children:[l&&i.jsxs(K,{size:"sm",disabled:e.busy,onClick:()=>e.onAct("/guides/approve",{id:r}),children:["Approve guide ",r]}),i.jsx(Jj,{r:n,busy:e.busy,onApprove:h=>e.onAct("/guides/checks/approve",{id:r,name:h})})]})})})}const Zj=e=>e===1?"1 checklist item":`${e} checklist items`;function e0(e){const{view:n,act:r}=hn(),[o,l]=x.useState(),[c,d]=x.useState(!1),[h,g]=x.useState(!1),m=x.useRef(null);if(x.useEffect(()=>{var v;e.focus&&n&&((v=m.current)==null||v.scrollIntoView({block:"start"}))},[e.focus,!!n]),!n)return null;const y=async(v,j)=>{d(!0),l(await r(v,j)),d(!1)};return i.jsxs("div",{className:"guides-section",ref:m,children:[i.jsxs(Ke,{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:n.guides.map(v=>i.jsx(Xj,{r:v,busy:c,onAct:(j,w)=>void y(j,w)},v.id))}),i.jsxs("div",{className:"guides-foot",children:[i.jsx(K,{size:"sm",onClick:()=>g(!0),children:"Browse guides"}),i.jsx(re,{parts:[{text:`${ve.dataDir}/guides/`,code:!0},{text:"guides.lock.json",code:!0}]})]}),n.configErrors.length>0&&i.jsx("ul",{className:"vf-errors",children:n.configErrors.map(v=>i.jsx("li",{children:v},v))}),o&&i.jsx("span",{className:"vf-err",children:o})]}),h&&i.jsx(Yj,{registries:n.registries,onClose:()=>g(!1)})]})}function t0(e){const{view:n,act:r}=hn(),[o,l]=x.useState();if(!n)return null;const c=e.map.guides??[],d=n.guides.filter(g=>g.status==="active"&&g.guide),h=g=>{const m=c.includes(g)?c.filter(y=>y!==g):[...c,g];l(void 0),r("/guides/team",{mapId:e.map.id,guides:m}).then(l)};return i.jsxs(Ke,{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(g=>{const m=c.includes(g.id);return i.jsx(K,{size:"sm",on:m,"aria-pressed":m,title:g.guide.summary,onClick:()=>h(g.id),children:g.guide.name},g.id)})}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function n0(e,n){const[r,o]=x.useState();return x.useEffect(()=>{const l=`/guides/checklist?mapId=${encodeURIComponent(e)}&ticketId=${encodeURIComponent(n)}`,c=()=>yo(l).then(d=>o(d.checklist),()=>o(null));return c(),fn(d=>{d.endsWith("checklist.json")&&c()})},[e,n]),r}function s0(e){const n=n0(e.mapId,e.ticketId);if(!n)return null;const r=n.answers.filter(o=>!o.done).length;return i.jsxs("div",{className:"checklist-panel",children:[i.jsx(re,{parts:[`${n.guide.id} ${n.guide.version} checklist`,n.by,zi(n.at),r?`${r} not done`:"all done"]}),i.jsx(Mm,{answers:n.answers})]})}const lh="";function i0(e){const{view:n,act:r}=hn(),[o,l]=x.useState();if(!n)return null;const c=e.ticket,d=n.guides.filter(m=>{var y;return m.status==="active"&&((y=m.guide)==null?void 0:y.handles.types.includes(c.type))}),h=[{value:lh,label:"No guide"},...d.map(m=>({value:m.id,label:m.guide.name,hint:m.guide.summary}))];c.guide&&!d.some(m=>m.id===c.guide)&&h.push({value:c.guide,label:c.guide});const g=m=>{l(void 0),r("/guides/ticket",{mapId:e.mapId,ticketId:c.id,guide:m||null}).then(l)};return i.jsxs("span",{className:"guide-picker",children:[i.jsx(lt,{compact:!0,"aria-label":"Ticket guide",value:c.guide??lh,options:h,onChange:g}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function r0(e){const{view:n,find:r}=hn();if(!n)return null;const o=r(e.id);if((o==null?void 0:o.status)==="active")return null;const l=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: ",l,". Claims get no guide instructions until you approve it in Settings → Guides."]})}function o0(e){const{view:n}=hn(),r=e.ticket;return!n||r.state!=="open"&&!r.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"}),r.state==="open"?i.jsx(i0,{mapId:e.mapId,ticket:r}):r.guide&&i.jsx(_j,{id:r.guide})]}),r.guide&&i.jsx(r0,{id:r.guide}),i.jsx(s0,{mapId:e.mapId,ticketId:r.id})]})}const ch={from:"18:00",to:"09:00"};function a0(e){const n=e.focus!==void 0,r=e.focus??ch;return i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Quiet hours"}),i.jsx(K,{size:"sm",on:n,"aria-pressed":n,onClick:()=>e.onChange(n?void 0:ch),children:n?"On":"Off"}),n&&i.jsxs(i.Fragment,{children:[i.jsx("input",{type:"time","aria-label":"Quiet from",value:r.from,onChange:o=>o.target.value&&e.onChange({...r,from:o.target.value})}),i.jsx("span",{className:"t-meta",children:"to"}),i.jsx("input",{type:"time","aria-label":"Quiet until",value:r.to,onChange:o=>o.target.value&&e.onChange({...r,to:o.target.value})})]})]})}const l0=[{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 c0(){typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()}function u0(){const{view:e,error:n,savePrefs:r}=jm(0);if(!e)return null;const o=e.policy.value,l=`${ve.dataDir}/attention.json`,c=h=>void r({...e.prefs,...h}),d=typeof Notification<"u"&&Notification.permission==="denied";return i.jsxs(Ke,{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(lt,{compact:!0,"aria-label":"Interrupt me by",value:e.prefs.channel,options:l0,onChange:h=>{h==="browser"&&c0(),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(a0,{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:[l,": ",h]},h))}),i.jsx(re,{className:"set-hint",parts:[e.policy.exists?{text:l,code:!0}:"Team defaults",`interrupt at ${o.interrupt}`,o.digestMinutes?`Slack digest every ${o.digestMinutes} min`:"Slack digest off"]}),n&&i.jsx("span",{className:"vf-err",children:n})]})}const d0=[5,15,30,60];function f0(e){const{value:n}=e;return i.jsxs("div",{className:"choice-row compact",children:[i.jsx(ft,{on:!n.enabled,title:"Off",onClick:()=>e.onChange({...n,enabled:!1})}),d0.map(r=>i.jsx(ft,{on:n.enabled&&n.awayMinutes===r,title:`Away ${r} min`,onClick:()=>e.onChange({enabled:!0,awayMinutes:r})},r))]})}const h0=[{version:"0.10.0",date:"2026-10-31",items:["MCP server in the miloops package: `claude mcp add miloops -- npx -y miloops-cli mcp`, or the same for Codex","Connected agents start and resume missions, claim ready tickets, report steps, tokens and spend, close tickets and record decisions, live in the command center","Agent questions land in Waiting on you and the agent waits for your answer; answer in the command center or in the agent chat","/milo new, resume, status and inbox commands for Claude Code (and as a Codex prompt); `miloops connect claude|codex` sets them up","The command center follows a mission an agent just charted; sessions of agents that quit show as disconnected"]},{version:"0.9.0",date:"2026-10-31",items:["While you were away: MILO briefs you when you open the app or come back after being away: tickets done, now blocked, decisions waiting on you, agent decisions, spend and tokens since, active sessions","Briefing shows on return after 15 minutes hidden or idle; change the threshold or turn it off in Settings; reopen it from the header","Last seen per mission and usage over time are kept locally, so the briefing survives a reload","Mission title shows in full at laptop width; header readouts collapse to glyph and count","Prototype reviews link a real preview build and ask about the spike results"]},{version:"0.8.0",date:"2026-10-31",items:["Decisions: every decision across missions, newest first, with question, decision, alternatives, rationale, who decided and the full transcript","Filter decisions by mission, source, who decided and status; search; export to markdown","Supersede a decision; the chain stays visible on every record and in the mission","Decision records stored as markdown next to each mission and served by the local API with a live event stream","Resolve form: rationale and alternatives considered"]},{version:"0.7.0",date:"2026-10-31",items:["New type: Chakra Petch, Share Tech Mono and Barlow","Calmer palette; bright colour only for warnings and waiting on you","MILO mark, also used for status, action and alert glyphs","Dot-matrix signals for new decision requests and mission launches","Separate type voices for operators and agents","One-command install: npm i -g miloops-cli, then miloops in any repo","Packages renamed to @miloops-hq/core and @miloops-hq/command-center"]},{version:"0.6.0",date:"2026-10-31",items:["Named MILOOPS; MILO speaks for the platform in the activity log and onboarding","Tracker sync status, last-write latency and event pulse","Inbox: oldest question age and average wait","Critical path, decided per hour with burndown, type mix","Per-session tokens and cost, mission totals, claims per agent"]},{version:"0.5.0",date:"2026-10-31",items:["Status counters and resolution bar on the map","Current step tracker with step pipeline","Sessions with live timers","Activity log with time and source columns","Out-of-scope quarantine zone on the map"]},{version:"0.4.0",date:"2026-10-31",items:["Missions: switcher with progress and waiting count, New mission in the switcher","Inbox collects questions from every mission","Elapsed time and progress per mission","Responsive layout with progressive disclosure (wide, laptop, phone)","Map graph pans and zooms by drag, pinch and wheel","Changelog"]},{version:"0.3.0",date:"2026-10-31",items:["Fixed-zone layout","Plan + execute and plan-only mission modes","Execute tickets"]},{version:"0.2.0",date:"2026-10-31",items:["Local markdown tracker (default)","Onboarding","HITL transcript: summary or full","Settings with tracker connectors"]},{version:"0.1.0",date:"2026-10-31",items:["Live map graph","HITL vs AFK tickets","In-window HITL conversations","Demo tracker with simulated sessions"]}],m0=[{area:"Teamtrail Cloud",items:["Agents that run in the cloud, steered from the same Lookout"]}],p0=[{version:"0.23.0",date:"2026-11-08",items:["Match work to models: switch it on for a trail in Settings and each agent gets the tickets that fit the model it runs on, research on fast models and junctions on the strongest. You set the tier per ticket type; Teamtrail never switches a model, and a ticket no connected agent is strong enough for waits in your queue","Guides: a ticket can ask for a reviewer, QA, security, docs or architect, and the agent that claims it gets that guide’s instructions and a checklist it must answer before the work counts as done. Pick a trail’s team and each ticket’s guide in the Lookout, and add more guides from a moderated catalog in Settings → Guides. A guide can add checks but never remove one, its commands only run after you approve them, and a guide file edited after you approved it is switched off until you look at it again","Records has a new Trail stats view: delivery across every trail, by vendor, agent and ticket type, with plain observations from your own numbers. Teamtrail doesn't route work from them","MILOOPS is now Teamtrail. Missions are trails, the command center is the Lookout, MILO is Scout, and `/milo` is `/scout`","More room for the map: the summary of counts now slides up from a tab when you want it","A new day and night look, starting in night, with an Appearance setting to switch to day or follow your system","The map is now a landscape: tickets are trail signs, the trail shows what is walked and what is ahead, and an X marks the destination","A new greeting when you start `teamtrail` in a terminal","A new logo, a t whose stem runs along a trail to a node, and a new look for Scout: the original CRT head with ear cups and a baseball cap, with a lamp on the cap at night. No more pixel art, and new fonts too","All projects: every repo you supervise in one view, with one list of what needs you across them and what changed while you were away. Answer an agent's question in any repo from there, and switch projects from the header. Agents add their repo when they connect (`--no-register` opts out), or add one with `teamtrail projects add`"]},{version:"0.22.0",date:"2026-11-05",items:["A calmer, clearer command center: every list now reads the same way, what it is first, then one quiet line of context, and details when you want them","Red now only means something needs you now; other states show as a thin edge instead of colored text everywhere","The open question in a conversation can no longer be hidden by its suggested answers, and the phone header no longer runs off the side"]},{version:"0.21.0",date:"2026-11-05",items:["New plans can now edit a ticket, remove a dependency and reopen finished work, instead of working around it","Slack digests follow the team's digest setting (digestMinutes in attention.json); 0 turns them off, and everything still waits in Waiting on you","Remove a finished task's workspace from Settings → Workspaces or the ticket; the branch stays, and MILOOPS asks before discarding uncommitted changes"]},{version:"0.20.0",date:"2026-11-04",items:["Separate workspaces: switch on Settings → Workspaces and each ticket an agent claims gets its own copy of the repo on its own branch, so agents working at the same time don’t step on each other. When the work is done you get the branch to review; MILOOPS never merges or pushes for you","Warnings before a clash: agents say which files they expect to change. When two of them plan to change the same files, the second one is warned, and you see it in Waiting on you; open it to release either claim","When two agents’ branches did change the same files, Waiting on you suggests a ticket to bring the work together. One click adds it, waiting on both tickets, with the files listed","The ticket inspector shows which files an agent expects to change and the branch it works on","Fix: an execute ticket marked as needing you keeps that mark when saved to local files, GitHub Issues or Linear"]},{version:"0.19.0",date:"2026-11-04",items:["Risk policy: you decide what always needs you, such as database changes, logins and permissions, billing, deleting data or new dependencies (Settings → Risk policy). Agents can no longer make those calls on their own; they ask you. Their other decisions are labelled by risk in the briefing, and work that touched risky files without asking comes to you to check","One ranked list of everything that needs you in Waiting on you: questions, approvals, blocked work, briefs, knowledge and new plans, most important first, each with the reason (for example “blocks 3 tickets” or “claude-02 is waiting”). Related items are grouped so you answer them together; snooze what can wait","Fewer interruptions: agents say how urgent a question is, and only urgent items notify you (browser or Slack). Focus for an hour from the header, set quiet hours in Settings → Attention, and the rest waits in the list and the digest","Plans that adapt: missions list the assumptions they rely on, starting with the ones in the discovery brief. When an agent finds one is wrong, it shows the evidence and proposes a new plan; the tickets it would change are paused, the map previews the change, and nothing happens until you approve","Challenge the destination: an agent can tell you the work already exists, the mission targets the wrong problem, or it should be rescoped, with evidence and a suggested new goal","Assumptions on the Plan tab (confirm the ones you know are true) and an assumptions field when you create a mission","Fix: when an agent asks two questions at once, your answer goes to the one you opened; the inbox stats line no longer gets covered by the list"]},{version:"0.18.0",date:"2026-11-04",items:["Acceptance criteria: agents write down what done means before they start (required on missions with a discovery brief). When they finish, each point needs proof: one of your checks, a named test, the pull request, or your sign-off","Work whose criteria lack proof goes back with the reason; points only you can confirm come to your inbox to sign off","Business rules from your project knowledge are suggested as criteria, and the ticket shows any rule no criterion covers yet. Confirm a ticket’s criteria in the inspector","Cross-vendor review: when Claude and Codex agents both run, each reviews the other’s work first","Fix: answers from the command center could hang when too many live updates were open; all updates now share one connection"]},{version:"0.17.0",date:"2026-11-03",items:["Discovery brief: new missions start with an agent mapping the existing system (files, conventions, data and API impact, risks, assumptions, product context). Implementation tickets wait until you accept the brief or ask for changes, from the banner over the map or the card in Communication","Create mission: start a mission from the New mission dialog without a terminal; any agent picks it up with /milo resume","Knowledge: what agents need to know about your codebase and product (architecture, conventions, gotchas, dead ends, business rules, personas, UX principles, pricing). Agents propose, you confirm, keep as an assumption or retire. Confirmed entries reach agents with every claim, picked for the ticket with the reason, and the inspector shows what an agent gets","Knowledge about specific files is flagged for re-confirmation when those files change","Save decisions, cancelled tickets (as dead ends) and brief sections as knowledge in one click; seed it from a document with miloops knowledge import <file.md>"]},{version:"0.16.0",date:"2026-11-03",items:["Mission report (Mission plan → Report): tickets done, mission and median ticket lead time, your interventions, rework, review results and cost per verified ticket. Hover any number to see how it is computed; export it as markdown","Agents report the same numbers in one line from the status tool","Agents use missions for big work only, and decide routine calls themselves, keeping each one as a decision record you can review or reverse; they ask you when the call changes product behaviour, data, security, billing, a public API or the schema","Decisions: filter by who made the call, agents on their own or people. The briefing now counts only the calls agents made themselves, not your answers they recorded"]},{version:"0.15.0",date:"2026-10-31",items:["Verification in the ticket inspector: the level that applies and where it comes from, every attempt newest first with the git evidence (base → head, files changed, flags), its checks, exit codes, durations and the failing output, and the full log on demand","Verifying, Rework and Blocked on the map, in the legend and as status counters on missions that verify completions","Operator calls on a verifying or blocked ticket: Approve, Re-run checks, Send to rework with a note, Accept anyway and Unblock. Overrides need a reason, and each call is kept as a verdict next to the attempts and in the mission history. Approve asks for a re-run when the code changed since the checks passed","Set the verification level of a mission (Settings → Verification) or of one ticket (inspector). Only you can change it; agents cannot","The inspector updates live while checks run","Independent review: at Checks + review, a passing completion gets a review ticket that another agent takes and answers with PASS, FAIL (with findings) or NEEDS_HUMAN. The agent that did the work is never given its own review","Waiting on you lists reviewed work to approve (Checks + review + you) and held tickets, and Slack posts them with Approve and Rework… buttons","Agents can name their pull request in `report_completion` (`pr`); PR and CI tracking then follows that PR first"]},{version:"0.14.0",date:"2026-10-31",items:["Ticket lifecycle in plain words: Ready, Backlog, Working, Done and Cancelled (with Verifying, Rework and Blocked to come with verification)","Every claim, release, return to queue, resolution and rule-out goes through one lifecycle engine that records who, why and when in `.miloops/.events/<mission>.jsonl` (local history, never committed)","Settings → Verification shows the checks in `.miloops/verification.json`: argv commands with timeouts, run without a shell, secrets kept out of their environment. Read-only","Completion is a claim: on missions started with `verification.json` present, an execute or task ticket is only done once its checks pass. A failed check sends it back for Rework with the failing output (agents see it in close_ticket, next_ticket and claim_ticket, and rework comes first in the queue); after 3 failed attempts, or when the checks cannot run, it waits on you as Blocked","New MCP tools `report_completion` and `verification_status`; missions started before verification, and research, grilling and prototype tickets, close exactly as before","Git evidence, no GitHub needed: each claim records HEAD and the uncommitted state, and each completion lists the files changed since then. It flags no changes, overlap with another active ticket, a branch switch or reset, and edits to `verification.json` (which send the ticket to you as Blocked). A pass on code that changed while its checks ran is re-run","Pull request and CI evidence: with `verification.json` and a GitHub token (Settings, `GITHUB_TOKEN` or `gh auth login`), the command center finds each ticket’s PR (its branch `miloops-<mission>-<ticket>`, a `miloops:<mission>#<ticket>` line in the PR body, or a link you set) and flags mismatches: done with the PR still open, PR merged while the ticket is in progress, PR closed unmerged, required checks failing or unknown, PR head not the verified commit. Flags never change a ticket. A CI chip in the header shows sync health and never shows synced after a failed sync"]},{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"]},...h0];function g0(){return i.jsxs("div",{className:"changelog",children:[i.jsxs("div",{className:"about",children:[i.jsx(dm,{className:"about-name"}),i.jsx("span",{className:"mono-label",children:ve.category}),i.jsx("p",{className:"onb-tagline",children:ve.tagline}),i.jsx(re,{parts:[ve.assistant.name]})]}),i.jsx(Ke,{title:"Next",children:m0.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(n=>i.jsx("li",{children:n},n))})]},e.area))}),p0.map(e=>i.jsx(Ke,{title:`${e.version} · ${e.date}`,children:i.jsx("ul",{children:e.items.map(n=>i.jsx("li",{children:n},n))})},e.version))]})}const v0=`${ve.apiPrefix}/models`;function jc(){const[e,n]=x.useState(),r=x.useCallback(()=>{fetch(v0).then(o=>o.ok?o.json():null).then(n,()=>n(null))},[]);return x.useEffect(()=>{r();const o=fn(c=>{(c.endsWith("models.json")||c.endsWith("map.md")||c.includes("/tickets/"))&&r()}),l=Lo("attention",r);return()=>{o(),l()}},[r]),e}function k0({mapId:e,ticketId:n}){const r=jc(),o=r==null?void 0:r.waiting.find(l=>l.mapId===e&&l.ticketId===n);return o?i.jsx(ze,{className:"model-wait d-section",edge:"attention",title:`Needs a ${o.tier} model`,context:i.jsx(re,{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 y0({view:e}){if(!e)return null;const n=`${ve.dataDir}/${e.file}`,r=Object.keys(e.models).length,o=e.agents.map(l=>`${l.agent} ${l.tier}`).join(", ");return i.jsxs(i.Fragment,{children:[i.jsx(re,{className:"set-hint",parts:[{text:n,code:!0},e.exists?`${r} of your own models`:"add new or custom models here","unknown models count as balanced"]}),o&&i.jsx(re,{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:[n," has errors, so only the built-in models count until it is fixed."]})]}),i.jsx("ul",{className:"vf-errors",children:e.errors.map(l=>i.jsx("li",{children:l},l))})]})]})}const Rm={fast:"Fast",balanced:"Balanced",strongest:"Strongest"},x0={fast:"Haiku, mini and nano models",balanced:"Sonnet, GPT-4 models",strongest:"Opus, GPT-5 and o-series models"},w0=Eh.map(e=>({value:e,label:Rm[e],hint:x0[e]}));function j0(e){return i.jsx("div",{className:"tier-grid",children:Co.map(n=>{const r=e.tiers[n],o=rc[n];return i.jsxs("div",{className:"tier-row",children:[i.jsx("span",{children:mo[n]}),i.jsx(lt,{compact:!0,"aria-label":`${mo[n]} tickets' model`,className:`tier-select tier-${n}`,value:r,options:w0,onChange:l=>e.onChange(n,l)}),i.jsx(re,{className:"tier-hint",parts:[r!==o&&`default ${Rm[o].toLowerCase()}`,e.hints[n]]})]},n)})})}const oo=(e,n)=>`${e} ${n}${e===1?"":"s"}`;function S0({rows:e}){return e.length?i.jsx("ul",{className:"perf-rows",children:e.map(n=>i.jsx(ze,{as:"li",className:"perf-row",title:n.key,trailing:i.jsx("span",{title:"Median time from first claim to done",children:Jt(n.medianLeadMs)}),context:i.jsx(re,{parts:[`${n.done} of ${oo(n.tickets,"ticket")} done`,n.cancelled>0&&`${n.cancelled} cancelled`,oo(n.reworkCycles,"rework"),`reviews ${n.reviews.passed} passed, ${n.reviews.failed} failed`,n.answers>0&&oo(n.answers,"question")]}),detail:n.findings.raised>0?`As reviewer: ${n.findings.upheld} of ${oo(n.findings.raised,"finding")} upheld`:void 0},n.key))}):i.jsx(Le,{children:"No claimed tickets yet"})}function _m(e){const[n,r]=x.useState({}),o=e.map(l=>`${l.map.id}:${l.tickets.reduce((c,d)=>Math.max(c,d.updatedAt),0)}`).join();return x.useEffect(()=>{let l=!0;return Promise.all(e.map(async c=>{const d=await fetch(`${Ne()}/journal?mapId=${encodeURIComponent(c.map.id)}`).catch(()=>{}),h=d!=null&&d.ok?await d.json():{entries:[]};return[c.map.id,h.entries]})).then(c=>{l&&r(Object.fromEntries(c))}),()=>{l=!1}},[o]),n}const N0=[{id:"byVendor",title:"By vendor"},{id:"byAgent",title:"By agent"},{id:"byType",title:"By ticket type"}];function b0({api:e,bp:n,onClose:r}){const[o,l]=x.useState("byVendor"),c=x.useMemo(()=>Object.values(e.allSnaps),[e.allSnaps]),d=_m(c),h=e.activity.answered,g=x.useMemo(()=>Gh(c.map(m=>({snap:m,journal:d[m.map.id]??[],answered:h}))),[c,d,h]);return x.useEffect(()=>{const m=y=>y.key==="Escape"&&r();return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[r]),i.jsxs(We,{className:`zone decisions-view perf-view dv-${n}`,children:[i.jsxs("header",{className:"dv-head",children:[i.jsx(Ye,{as:"h2",children:"Trail stats"}),i.jsx(re,{parts:[`${g.trails} trails`,`${g.tickets} tickets`]}),i.jsx("span",{className:"dv-head-right",children:i.jsx("button",{className:"icon-btn",onClick:r,"aria-label":"Close",children:"×"})})]}),i.jsxs("div",{className:"perf-body",children:[i.jsxs("section",{className:"perf-section",children:[i.jsx(Ye,{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."}),g.recommendations.length?i.jsx("ul",{className:"perf-recs",children:g.recommendations.map(m=>i.jsxs("li",{title:m.because,children:[i.jsx("span",{children:m.text}),i.jsx("span",{className:"t-meta",children:m.because})]},m.id))}):i.jsx(Le,{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:N0.map(m=>i.jsx(ft,{on:o===m.id,title:m.title,onClick:()=>l(m.id)},m.id))}),i.jsx(S0,{rows:g[o]}),i.jsx("p",{className:"perf-note t-meta",children:"Spend is tracked per trail, so it isn't split by agent here."})]})]})]})}function C0(e,n){const r=_m(e);return x.useMemo(()=>{var c;const o=Gh(e.map(d=>({snap:d,journal:r[d.map.id]??[],answered:n}))),l={};for(const d of o.byType){if(!d.done)continue;const h=(c=o.recommendations.find(m=>m.id===`speed-${d.key}`))==null?void 0:c.text,g=[`Trail stats: ${d.done} done`,d.medianLeadMs!==void 0&&`median ${Jt(d.medianLeadMs)}`,d.reworkCycles>0&&`${d.reworkCycles} back to rework`,h];l[d.key]=g.filter(Boolean).join(" · ")}return l},[e,r,n])}function $0(e){var d,h;const n=jc(),r=C0(e.snaps,e.answered),o=e.map;if(!o)return null;const l=!!((d=o.modelMatching)!=null&&d.enabled),c=((h=o.modelMatching)==null?void 0:h.tiers)??{};return i.jsxs(Ke,{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(K,{size:"sm",on:l,"aria-pressed":l,className:"model-matching-toggle",onClick:()=>e.onChange({...o.modelMatching,enabled:!l}),children:l?"On":"Off"})]}),l&&i.jsx(j0,{tiers:rv(o),hints:r,onChange:(g,m)=>{const y={...c,[g]:m};m===rc[g]&&delete y[g],e.onChange({enabled:!0,tiers:y})}}),l&&i.jsx("span",{className:"set-hint t-meta",children:"Changes apply to the next claim; nothing running is interrupted."}),i.jsx(y0,{view:n})]})}const Jl=`${ve.apiPrefix}/projects`;async function ao(e,n,r){const o=await fetch(`${Jl}${e}`,{method:n,headers:{"Content-Type":"application/json"},body:r===void 0?void 0:JSON.stringify(r)}),l=await o.json().catch(()=>({}));if(!o.ok)throw new Error(l.error??`HTTP ${o.status}`);return l}const Ds={url:Jl,add:e=>ao("","POST",{path:e}),remove:e=>ao(`/${e}`,"DELETE"),setAutoRegister:e=>ao("/settings","PUT",{autoRegister:e}),answer:(e,n)=>ao(`/${e}/answer`,"POST",n),async briefing(e){const n=await fetch(`${Jl}/briefing?since=${e}`);return n.ok?await n.json():void 0}};function Pm(e){const[n,r]=x.useState(""),[o,l]=x.useState(),c=d=>{d.trim()&&(l(void 0),Ds.add(d.trim()).then(()=>(r(""),e.onAdded()),h=>l(h.message)))};return i.jsxs("div",{className:"pj-add",children:[i.jsx(gc,{value:n,onValueChange:r,onSubmit:c,action:"Add project",placeholder:`/path/to/repo (a ${ve.dataDir} folder is created if missing)`,"aria-label":"Repo path",className:"t-code"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}const Es=(e,n)=>e>0&&`${e} ${n}`;function T0(e){var r;const n=((r=e.briefing)==null?void 0:r.projects)??[];return!e.briefing||!n.length?null:i.jsxs("section",{className:"pj-section pj-briefing",children:[i.jsx(Nt,{title:"While you were away",count:n.length,info:`What changed in each project since ${Zt(e.now-e.briefing.since)} ago`}),i.jsx("ul",{className:"pj-list",children:n.map(({projectId:o,project:l,briefing:c})=>i.jsx(ze,{as:"li",edge:c.totals.waiting>0?"attention":"neutral",title:l,context:i.jsx(re,{parts:[Es(c.totals.done,"done"),Es(c.trails.reduce((d,h)=>d+h.opened.length,0),"new tickets"),Es(c.totals.agentDecisions,"agent decisions"),Es(c.totals.waiting,"waiting on you"),Es(c.totals.ruledOut,"ruled out"),Es(c.totals.active,"agents active")]}),onOpen:()=>e.onOpen(o)},o))})]})}function E0(e){const[n,r]=x.useState(""),[o,l]=x.useState(!1),[c,d]=x.useState(),h=g=>{!g.trim()||o||(l(!0),d(void 0),e.onAnswer(g.trim()).then(()=>r(""),m=>d(m.message)).finally(()=>l(!1)))};return i.jsxs("div",{className:"pj-answer",children:[i.jsx(gc,{value:n,onValueChange:r,onSubmit:h,action:"Answer",disabled:o,placeholder:"Your answer","aria-label":"Your answer"}),c&&i.jsx("span",{className:"vf-err",children:c})]})}function M0(e){const{item:n}=e,r=ym(n),o=n.kind==="question"&&n.agent?`${n.agent} asks`:vm[n.kind],l=n.urgency==="blocking"&&{text:"Blocking",urgent:!0,className:"urgency-tag"};return i.jsx(ze,{as:"li",className:`att-item pj-item k-${n.kind}`,edge:km(n,n.interrupting),title:n.title.split(`
|
|
128
|
+
`)[0],titleText:n.title,context:i.jsx(re,{parts:[l,{text:n.project,strong:!0},o]}),detail:r.length>0&&r.join(" · "),detailText:r.join(`
|
|
129
|
+
`),trailing:Zt(e.now-n.since),onOpen:e.onOpen,below:e.onAnswer&&i.jsx(E0,{onAnswer:e.onAnswer})})}function I0(e){const n=e.view.attention,r=o=>{var l;return((l=e.view.projects.find(c=>c.id===o))==null?void 0:l.state.kind)!=="missing"};return i.jsxs("section",{className:"pj-section pj-attention",children:[i.jsx(Nt,{title:"Needs you",count:n.length,hot:n.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."}),n.length===0&&i.jsx(Rn,{title:"Nothing needs you",hint:"Agents in every project can keep going."}),i.jsx("ul",{className:"pj-list",children:n.map(o=>i.jsx(M0,{item:o,now:e.now,onOpen:()=>e.onOpen(o.projectId,o.id),onAnswer:o.kind==="question"&&r(o.projectId)?l=>Ds.answer(o.projectId,{questionId:o.ref,text:l}).then(e.onAnswered):void 0},`${o.projectId}/${o.id}`))})]})}const Pl=(e,n,r=`${n}s`)=>`${e} ${e===1?n:r}`;function A0(e){return e.interrupting>0?"urgent":e.phases.blocked+e.phases.rework+e.flags+e.stalled>0||e.state.kind==="missing"?"attention":"neutral"}function O0(e){if(e.state.kind==="missing")return[{text:"Missing",strong:!0},{text:e.path,code:!0}];const n=[];e.needsYou&&n.push({text:`${e.needsYou} ${e.needsYou===1?"needs":"need"} you`,strong:!0,urgent:e.interrupting>0}),e.agents&&n.push(Pl(e.agents,"agent"));const{working:r,verifying:o,rework:l,blocked:c}=e.phases;return r&&n.push(`${r} working`),o&&n.push(`${o} verifying`),l&&n.push(`${l} rework`),c&&n.push(`${c} blocked`),e.flags&&n.push(Pl(e.flags,"PR flag")),e.stalled&&n.push(Pl(e.stalled,"stalled claim")),n.length||n.push(e.trails?"Nothing waiting":"No trails yet"),n}function L0(e){var n;return e.state.kind==="elsewhere"?`Served by another Lookout · ${e.state.url}`:((n=e.top)==null?void 0:n.title)??e.note??e.path}function wo(e,n,r){if(e.state.kind!=="missing"){if(e.state.kind==="elsewhere"){const o=new URL(e.state.url);r&&o.searchParams.set(Ls,r),window.open(o.toString(),"_blank","noopener");return}location.href=sx({id:e.id,home:n,tracker:e.tracker.kind,item:r})}}function Dm(e){const{p:n}=e,r=L0(n);return i.jsx(ze,{as:"li",className:`project-card st-${n.state.kind}`,edge:A0(n),selected:e.current,title:n.name,titleText:n.path,context:i.jsx(re,{parts:O0(n)}),detail:r,detailText:r,trailing:n.lastActivity?Zt(e.now-n.lastActivity):void 0,onOpen:e.onOpen})}const Bm=`${No}:projects:seen`,uh=24*36e5;function R0(e){try{const n=Number(localStorage.getItem(Bm));return n>0?n:e-uh}catch{return e-uh}}function _0(e){try{localStorage.setItem(Bm,String(e))}catch{}}function P0(){const[e,n]=x.useState();return x.useEffect(()=>{const r=Date.now();return Ds.briefing(R0(r)).then(n).catch(()=>{}),()=>_0(r)},[]),e}function D0(e){const{view:n,reload:r}=e.projects,o=en(15e3),l=P0();if(x.useEffect(()=>{const g=m=>m.key==="Escape"&&e.onClose();return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[e]),!n)return null;const c=Ao()??n.home,d=g=>{const m=n.projects.find(y=>y.id===g);(m==null?void 0:m.id)===c?e.onClose():m&&wo(m,n.home)},h=(g,m)=>{const y=n.projects.find(v=>v.id===g);if(y){if(y.id!==c)return wo(y,n.home,m);e.onClose(),e.onItemHere(m)}};return i.jsxs(We,{className:`zone decisions-view projects-view dv-${e.bp}`,children:[i.jsxs("header",{className:"dv-head",children:[i.jsx(Ye,{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(I0,{view:n,now:o,onOpen:h,onAnswered:r}),i.jsxs("section",{className:"pj-section pj-projects",children:[i.jsx(Nt,{title:"Projects",count:n.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:n.projects.map(g=>i.jsx(Dm,{p:g,current:g.id===c,now:o,onOpen:g.state.kind==="missing"?void 0:()=>d(g.id)},g.id))}),i.jsx(Pm,{onAdded:r})]}),i.jsx(T0,{briefing:l,now:o,onOpen:d})]})]})}function B0(e){const[n,r]=x.useState(!1),o=x.useRef(null);x.useEffect(()=>{if(!n)return;const h=g=>{var m;(g instanceof KeyboardEvent?g.key==="Escape":!((m=o.current)!=null&&m.contains(g.target)))&&r(!1)};return window.addEventListener("mousedown",h),window.addEventListener("keydown",h),()=>{window.removeEventListener("mousedown",h),window.removeEventListener("keydown",h)}},[n]);const{view:l}=e.projects;if(!l||!e.projects.many)return i.jsx("span",{className:"repo",children:e.repo});const c=Ao()??l.home,d=l.projects.filter(h=>h.id!==c).reduce((h,g)=>h+g.interrupting,0);return i.jsxs("div",{className:"project-switcher",ref:o,children:[i.jsxs("button",{className:"project-btn repo",onClick:()=>r(h=>!h),"aria-haspopup":"menu","aria-expanded":n,"data-tip":"Switch project, or see all of them",children:[i.jsx("span",{className:"project-name",children:e.repo}),d>0&&i.jsx(Zn,{n:d,urgent:!0}),i.jsx("span",{className:"caret",children:"▾"})]}),n&&i.jsxs("div",{className:"trail-menu",role:"menu",children:[i.jsxs("button",{role:"menuitem",className:"trail-item all-projects",onClick:()=>{r(!1),e.onOverview()},children:[i.jsx("span",{className:"mi-title",children:"All projects"}),i.jsx(Zn,{n:l.attention.length,urgent:l.attention.some(h=>h.interrupting),hideZero:!0})]}),i.jsx(Ye,{variant:"plain",className:"menu-h",children:"Projects"}),l.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:()=>{r(!1),h.id!==c&&wo(h,l.home)},children:[i.jsx("span",{className:"mi-title",children:h.name}),i.jsx("span",{className:"mi-progress",children:z0(h.state.kind)}),i.jsx(Zn,{n:h.needsYou,urgent:h.interrupting>0,hideZero:!0})]},h.id))]})]})}function z0(e){return e==="missing"?"missing":e==="elsewhere"?"other Lookout":""}function F0(e){const n=en(15e3),{view:r}=e.projects;if(!r||!e.projects.many)return null;const o=Ao()??r.home;return i.jsxs("section",{className:"phone-projects",children:[i.jsx(Nt,{title:"Projects",count:r.projects.length,right:i.jsx(K,{size:"sm",variant:"ghost",onClick:e.onOverview,children:"All projects"})}),i.jsx("ul",{className:"pj-list",children:r.projects.filter(l=>l.id!==o).map(l=>i.jsx(Dm,{p:l,current:!1,now:n,onOpen:l.state.kind==="missing"?void 0:()=>wo(l,r.home)},l.id))})]})}function zm(){const[e,n]=x.useState(),r=x.useCallback(()=>{fetch(Ds.url).then(o=>o.ok?o.json():void 0).then(o=>o&&n(o)).catch(()=>{})},[]);return x.useEffect(()=>Lo("projects",o=>n(JSON.parse(o))),[]),x.useEffect(r,[r]),{view:e,many:((e==null?void 0:e.projects.length)??0)>1,reload:r}}const U0=e=>[e.home&&{text:"This Lookout",strong:!0},e.state.kind==="missing"&&"Missing",{text:e.path,code:!0}];function W0(){const{view:e,reload:n}=zm(),[r,o]=x.useState();if(!e)return null;const l=c=>{o(void 0),c.then(n,d=>o(d.message))};return i.jsxs(Ke,{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(ze,{as:"li",edge:c.state.kind==="missing"?"attention":"neutral",title:c.name,context:i.jsx(re,{parts:U0(c)}),actions:!c.home&&i.jsx(K,{size:"sm",variant:"ghost",onClick:()=>l(Ds.remove(c.id)),children:"Remove"})},c.id))}),i.jsx(Pm,{onAdded:n}),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(K,{size:"sm",on:e.autoRegister,"aria-pressed":e.autoRegister,className:"auto-register-toggle",onClick:()=>l(Ds.setAutoRegister(!e.autoRegister)),children:e.autoRegister?"On":"Off"})]}),i.jsx(re,{className:"set-hint",parts:[{text:`${ve.slug} projects add <path>`,code:!0},`--no-register or ${ve.noRegisterEnv} opts one agent out`]}),r&&i.jsx("span",{className:"vf-err",children:r})]})}const dh={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"},H0={low:"the agent decides",medium:"the agent decides and records it",high:"you decide"},V0=e=>e[0].toUpperCase()+e.slice(1),Xl=Uh.map(e=>({value:e,label:V0(e),hint:H0[e]}));function K0(e){const[n,r]=x.useState(""),[o,l]=x.useState("high"),{rules:c,onChange:d}=e,h=()=>{const g=n.trim();!g||c.some(m=>m.glob===g)||(d([...c,{glob:g,level:o}]),r(""))};return i.jsxs("div",{className:"risk-paths",children:[i.jsx("span",{className:"mono-label",children:"Files"}),c.map((g,m)=>i.jsxs("div",{className:"risk-row",children:[i.jsx("code",{children:g.glob}),i.jsx(lt,{compact:!0,"aria-label":`${g.glob} risk`,value:g.level,options:Xl,onChange:y=>d(c.map((v,j)=>j===m?{...v,level:y}:v))}),i.jsx("button",{className:"icon-btn","aria-label":`Remove ${g.glob}`,onClick:()=>d(c.filter((y,v)=>v!==m)),children:"×"})]},g.glob)),i.jsxs("div",{className:"risk-row",children:[i.jsx("input",{value:n,placeholder:"src/payments/**","aria-label":"New file pattern",onChange:g=>r(g.target.value),onKeyDown:g=>g.key==="Enter"&&h()}),i.jsx(lt,{compact:!0,"aria-label":"New pattern risk",value:o,options:Xl,onChange:l}),i.jsx(K,{onClick:h,disabled:!n.trim(),children:"Add"})]})]})}const Fm=`${Ne()}/policy`;async function G0(){const e=await fetch(Fm);return e.ok?await e.json():null}function Q0(){const[e,n]=x.useState(),r=x.useCallback(()=>{G0().then(n,()=>n(null))},[]);x.useEffect(()=>(r(),fn(l=>{l.endsWith("policy.json")&&r()})),[r]);const o=x.useCallback(async l=>{const c=await fetch(Fm,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)}),d=await c.json();if(!c.ok)return d.error??`Saving failed (${c.status})`;n(d)},[]);return{view:e,save:o}}function q0(){const{view:e,save:n}=Q0(),[r,o]=x.useState();if(!e)return null;const l=`${ve.dataDir}/policy.json`,c=d=>{o(void 0),n(d).then(o,h=>o(h.message))};return i.jsxs(Ke,{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:Fh.map(d=>i.jsxs("label",{className:"risk-row",children:[i.jsx("span",{children:dh[d]}),i.jsx(lt,{compact:!0,"aria-label":`${dh[d]} risk`,value:e.policy.categories[d],options:Xl,onChange:h=>c({...e.policy,categories:{...e.policy.categories,[d]:h}})})]},d))}),i.jsx(K0,{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:[l," 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 ",l,", so your team shares it."]}),r&&i.jsx("span",{className:"vf-err",children:r})]})}function Y0(e){const[n]=xc();return n?i.jsx(Ke,{title:"Slack",children:i.jsx(Ew,{focus:e.focus})}):null}const J0=[{value:"auto",title:"Match my system"},{value:"day",title:"Day"},{value:"night",title:"Night"}];function X0(e){return i.jsx("div",{className:"choice-row compact",children:J0.map(n=>i.jsx(ft,{on:e.value===n.value,title:n.title,onClick:()=>e.onChange(n.value)},n.value))})}function Z0(){const[e,n]=x.useState();return x.useEffect(()=>{let r=!0;return fetch(`${Ne()}/verification/config`).then(o=>o.ok?o.json():null).then(o=>r&&n(o),()=>r&&n(null)),()=>{r=!1}},[]),e}const fh=`{
|
|
130
|
+
"v": 1,
|
|
131
|
+
"checks": {
|
|
132
|
+
"test": { "run": ["npm", "test"] },
|
|
133
|
+
"lint": { "run": ["npm", "run", "lint"] }
|
|
134
|
+
},
|
|
135
|
+
"run": ["test", "lint"]
|
|
136
|
+
}
|
|
137
|
+
`;function e1({file:e}){const[n,r]=x.useState(!1),o=()=>void navigator.clipboard.writeText(fh).then(()=>{r(!0),setTimeout(()=>r(!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:fh}),i.jsx(K,{size:"sm",variant:"ghost",onClick:o,children:n?"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 t1(e){const n=Z0(),[r,o]=x.useState();if(!n)return null;const l=e.map,c=n.config,d=`${ve.dataDir}/${n.file}`,h=(l==null?void 0:l.verification)??"off",g=(c??Lh).appliesTo.join(" and ");return i.jsxs(Ke,{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"," ",g," tickets. Research, junction and prototype tickets close as soon as they are answered."]}),l&&i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"set-field-label",children:["How much checking for trail ",l.key]}),i.jsx("div",{className:"choice-row vf-levels",children:ic.map(m=>i.jsx(ft,{on:h===m,title:_i[m],sub:Sm[m],onClick:()=>{o(void 0),Ui.act({action:"level",mapId:l.id,level:m,by:yt}).catch(y=>o(y.message))}},m))}),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."})]}),r&&i.jsx("span",{className:"vf-err",children:r})]}),n.errors.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line alert",title:n.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:n.errors.map(m=>i.jsx("li",{children:m},m))})]}),!n.exists&&i.jsx(e1,{file:d}),c&&n.exists&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line ok",title:n.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(re,{className:"set-hint",parts:[`New trails start at ${_i[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(([m,y])=>i.jsxs("div",{className:"vf-check",children:[i.jsx("span",{className:"t-code",children:c.run.includes(m)?m:`${m} (on request)`}),i.jsx("code",{children:y.run.join(" ")}),i.jsxs("span",{className:"dim",children:[y.timeoutSec," s",y.cwd&&y.cwd!=="."?` · in ${y.cwd}`:""]})]},m))})]}),i.jsxs("span",{className:"set-hint t-meta",children:["Teamtrail never edits ",d,". Change checks in the repo, so no agent can change what verifies its own work."]})]})}const Zl=`${Ne()}/workspaces`;async function n1(){const e=await fetch(Zl);return e.ok?await e.json():null}function Um(){const[e,n]=x.useState(),r=x.useCallback(()=>{n1().then(n,()=>n(null))},[]);x.useEffect(()=>(r(),fn(c=>{(c.endsWith("workspaces.json")||c.includes("workspaces/")||c.includes("leases/"))&&r()})),[r]);const o=x.useCallback(async c=>{const d=await fetch(Zl,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)}),h=await d.json();if(!d.ok)return h.error??`Saving failed (${d.status})`;n(h)},[]),l=x.useCallback(async(c,d,h=!1)=>{const g=await fetch(`${Zl}/remove`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:c,ticketId:d,force:h})}),m=await g.json();return g.ok?(n(m),{}):{error:m.error??`Removing failed (${g.status})`,dirty:m.dirty??!1}},[]);return{view:e,save:o,remove:l}}function Wm(e){const[n,r]=x.useState(!1),[o,l]=x.useState(),[c,d]=x.useState(!1),h=async g=>{d(!0),l(void 0);const m=await e.onRemove(g).catch(y=>({error:y.message,dirty:!1}));d(!1),r(!!m.dirty&&!g),m.dirty||l(m.error)};return n?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(K,{size:"sm",disabled:c,onClick:()=>h(!0),children:"Remove anyway"}),i.jsx(K,{size:"sm",variant:"ghost",onClick:()=>r(!1),children:"Keep"})]}):i.jsxs("span",{className:"ws-remove",children:[i.jsx(K,{size:"sm",disabled:c,onClick:()=>h(!1),children:e.label??"Remove"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function s1(e){return e.rows.length?i.jsx("ul",{className:"ws-list",children:e.rows.map(n=>i.jsx(ze,{as:"li",className:`ws-row ${n.active?"active":"finished"}`,title:i.jsx("span",{className:"t-code",children:n.branch}),titleText:n.branch,context:i.jsx(re,{parts:[{text:n.ticketKey,code:!0},n.active?`Active · ${n.agent}`:"Finished"]}),detail:i.jsx("span",{className:"t-code",children:n.path}),detailText:n.path,below:n.active?void 0:i.jsx(Wm,{onRemove:r=>e.onRemove(n.mapId,n.ticketId,r)})},`${n.mapId}/${n.ticketId}`))}):null}function i1(e){const{view:n,remove:r}=Um(),o=n==null?void 0:n.workspaces.find(l=>l.mapId===e.mapId&&l.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(Wm,{label:"Remove workspace",onRemove:l=>r(e.mapId,e.ticketId,l)})]})}function r1(){const{view:e,save:n,remove:r}=Um(),[o,l]=x.useState();if(!e)return null;const c=e.settings.worktrees,d=()=>{l(void 0),n({...e.settings,worktrees:!c}).then(l,h=>l(h.message))};return i.jsxs(Ke,{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; ",ve.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(K,{size:"sm",on:c,"aria-pressed":c,className:"worktrees-toggle",onClick:d,children:c?"On":"Off"})]}),i.jsx(re,{className:"set-hint",parts:[{text:`${ve.dataDir}/workspaces.json`,code:!0},hh(e.workspaces.filter(h=>h.active).length,"active"),hh(e.workspaces.filter(h=>!h.active).length,"finished")]}),i.jsx(s1,{rows:e.workspaces,onRemove:r}),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 hh=(e,n)=>`${e} ${n}`;function o1(e){const{prefs:n,update:r}=e,[o,l]=x.useState(e.initialTab??"settings");return x.useEffect(()=>{const c=d=>d.key==="Escape"&&e.onClose();return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[e]),i.jsx("div",{className:"scrim",onClick:e.onClose,children:i.jsxs(We,{as:"div",className:"dialog settings",onClick:c=>c.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx(vc,{value:o,onChange:l,items:[{id:"settings",label:"Settings"},{id:"changelog",label:"Changelog"}]}),i.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})]}),o==="changelog"?i.jsx(g0,{}):i.jsxs(i.Fragment,{children:[e.map&&i.jsx(Ke,{title:`Trail ${e.map.key}`,children:i.jsx(wj,{value:e.map.mode,onChange:e.onMapMode})}),i.jsx(Ke,{title:"Tracker",children:i.jsx(Aj,{activeTracker:e.activeTracker,location:e.location,update:r})}),i.jsx(Y0,{focus:e.focus==="slack"}),i.jsx(t1,{map:e.map}),i.jsx($0,{map:e.map,snaps:e.snaps,answered:e.answered,onChange:e.onModelMatching}),i.jsx(q0,{}),i.jsx(u0,{}),i.jsx(r1,{}),i.jsx(W0,{}),i.jsx(e0,{focus:e.focus==="guides"}),e.map&&i.jsx(t0,{map:e.map}),i.jsx(Ke,{title:"Labels",children:i.jsxs("div",{className:"label-codes",children:[i.jsx("code",{children:tc}),i.jsxs("code",{children:[ve.labelPrefix,":<type>"]}),i.jsx("code",{children:nc}),i.jsx("code",{children:sc})]})}),i.jsx(Ke,{title:"HITL transcript",children:i.jsx(Em,{value:n.hitlTranscript,onChange:c=>r({hitlTranscript:c})})}),i.jsx(Ke,{title:"Appearance",children:i.jsx(X0,{value:n.theme,onChange:c=>r({theme:c})})}),i.jsx(Ke,{title:"Trip report",children:i.jsx(f0,{value:n.briefing,onChange:c=>r({briefing:c})})}),i.jsx(Ke,{title:"Agent",children:i.jsx("div",{className:"choice-row",children:Jh.map(c=>i.jsx(ft,{on:c.status==="primary",disabled:c.status!=="primary",title:c.name},c.id))})})]})]})})}function a1(){const e=new URLSearchParams(location.search).get("settings");return e==="slack"||e==="guides"?e:!1}function l1(){const e=new URL(location.href);e.searchParams.has("settings")&&(e.searchParams.delete("settings"),history.replaceState(null,"",e))}function c1(e){var o;const{rt:n,api:r}=e;return i.jsx(o1,{prefs:e.prefs,update:e.update,activeTracker:n.kind,location:n.adapter.location,map:(o=r.snap)==null?void 0:o.map,onMapMode:r.actions.setMode,snaps:Object.values(r.allSnaps),answered:r.activity.answered,onModelMatching:r.actions.setModelMatching,focus:e.focus==="top"?void 0:e.focus,onClose:()=>{e.onClose(),l1()}})}function u1(e){return i.jsxs(We,{className:"zone side",style:{gridArea:"inspector"},children:[i.jsx(vc,{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]]})}const Sc=13;function d1(e,n,r){if(e==="LR"){const g=n.x+Ee+Sc,m=n.y+Ce/2,y=r.x-2,v=r.y+Ce/2,j=y-g;if(m===v)return`M${g} ${m}C${g+j*.3} ${m-16} ${g+j*.7} ${m+16} ${y} ${v}`;const w=(g+y)/2;return`M${g} ${m}C${w} ${m} ${w} ${v} ${y} ${v}`}const o=n.x+Ee/2,l=n.y+Ce,c=r.x+Ee/2,d=r.y-4,h=(l+d)/2;return`M${o} ${l}C${o} ${h} ${c} ${h} ${c} ${d}`}function f1(e){if(e.direction==="LR"){const r=e.width+96;return{x:r,y:e.graphH/2,right:r+60,bottom:e.height}}const n=e.graphH+76;return{x:e.width/2,y:n,right:e.width,bottom:Math.max(e.height,n+70)}}function h1(e,n){const r=new Set(e.edges.map(l=>l.from));return e.nodes.filter(l=>l.state!=="out-of-scope"&&!r.has(l)).map(l=>{if(e.direction==="LR"){const m=l.x+Ee+Sc,y=l.y+Ce/2,v=n.x-44,j=(m+v)/2;return`M${m} ${y}C${j} ${y} ${j} ${n.y} ${v} ${n.y}`}const c=l.x+Ee/2,d=l.y+Ce+16,h=n.y-44,g=(d+h)/2;return`M${c} ${d}C${c} ${g} ${n.x} ${g} ${n.x} ${h}`})}function m1({x:e,y:n}){return i.jsxs("g",{className:"destination",transform:`translate(${e} ${n})`,"aria-label":"Destination",children:[i.jsx("path",{className:"x-stroke",d:"M-32 -35 C-20 -22 4 8 33 36"}),i.jsx("path",{className:"x-stroke",d:"M35 -33 C14 -18 -12 10 -35 37"}),i.jsx("path",{className:"x-sketch",d:"M-29 -29 C-14 -13 8 8 28 29 M30 -28 C12 -13 -8 6 -29 31"}),i.jsx("text",{y:58,textAnchor:"middle",children:"Destination"})]})}function p1({trails:e}){return e.map(n=>i.jsxs("g",{children:[i.jsx("path",{className:"edge-path",d:n}),i.jsx("path",{className:"edge edge-open",d:n})]},n))}function g1(){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:"sign-grain",width:"200",height:"9",patternUnits:"userSpaceOnUse",children:i.jsx("rect",{y:"8",width:"200",height:"1",fill:"var(--sign-grain)"})}),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(--line)",strokeWidth:"2"})}),i.jsx("pattern",{id:"hatch-dim",width:"6",height:"6",patternUnits:"userSpaceOnUse",patternTransform:"rotate(45)",children:i.jsx("line",{x1:"0",y1:"0",x2:"0",y2:"6",stroke:"var(--sign-grain)",strokeWidth:"1.5"})})]})}function v1(e){const{from:n,to:r,direction:o}=e,c=["edge",n.ticket.state!=="open"?"edge-done":"edge-open",e.added?"edge-added":"",e.removed?"edge-removed":""],d=d1(o,n,r);return i.jsxs(i.Fragment,{children:[i.jsx("path",{className:"edge-path",d}),i.jsx("path",{className:c.join(" "),d})]})}function k1(e,n,r){const o=e.state==="frontier"||e.state==="rework";if(!(!n||r||e.ticket.assignee||!o))return n}function y1({wait:e}){return e?i.jsx("title",{children:`Needs a ${e} model: no connected agent runs one`}):null}function x1({mark:e,frozen:n}){const r=e&&e!=="unchanged"&&e!=="cancelled"?e:void 0;return i.jsxs(i.Fragment,{children:[e==="cancelled"&&i.jsx("line",{className:"strike",x1:8,y1:Ce/2,x2:Ee-8,y2:Ce/2}),r&&i.jsx("text",{className:"reroute-tag",x:Ee-8,y:Ce-8,textAnchor:"end",children:r}),n&&i.jsx("text",{className:"freeze",x:Ee-(r?58:8),y:Ce-8,textAnchor:"end",children:"❄"})]})}function w1(e,n,r=2){const o=e.split(/\s+/),l=[];let c="";for(const d of o)(c+" "+d).trim().length>n?(l.push(c.trim()),c=d):c+=" "+d;if(l.push(c.trim()),l.length>r){const d=l.slice(0,r);return d[r-1]=d[r-1].slice(0,n-1)+"…",d}return l}const j1=`M${Ee} 0L${Ee+Sc} ${Ce/2}L${Ee} ${Ce}z`;function S1({n:e,session:n,stalled:r,flag:o,selected:l,onSelect:c,mark:d,frozen:h,needs:g}){const m=e.ticket,y=w1(m.title,29),v=Pi(m)==="hitl",j=!!(n!=null&&n.waitingOn),w=!!d&&d!=="unchanged",E=k1(e,g,!!n),N=w?void 0:b1(e,{waiting:j,stalled:r,wait:E}),$=v&&!w&&(m.type==="task"||m.type==="execute"),I={hitl:v,selected:l,live:!!n,waiting:j,stalled:r,mark:d,frozen:h};return i.jsxs("g",{className:N1(e,I),style:{transform:`translate(${e.x}px, ${e.y}px)`},onClick:R=>{R.stopPropagation(),c({kind:"ticket",id:m.id})},children:[i.jsx(y1,{wait:E}),j&&i.jsx("rect",{className:"alarm",x:-6,y:-6,width:Ee+12,height:Ce+12}),i.jsx("rect",{className:"post",x:Ee/2-6,y:Ce,width:12,height:12}),i.jsx("rect",{className:"tuft",x:Ee/2-11,y:Ce+12,width:22,height:3}),i.jsx("path",{className:"body tip",d:j1}),i.jsx("rect",{className:"body",width:Ee,height:Ce}),i.jsx("rect",{width:Ee,height:Ce,fill:"url(#sign-grain)"}),(e.state==="blocked"||e.state==="parked")&&i.jsx("rect",{width:Ee,height:Ce,fill:"url(#hatch-dim)"}),e.state==="out-of-scope"&&i.jsx("rect",{width:Ee,height:Ce,fill:"url(#hatch-oos)"}),i.jsx("rect",{className:"edge-bar",width:4,height:Ce}),y.map((R,O)=>i.jsx("text",{className:"title",x:12,y:19+O*14,children:R},O)),i.jsxs("text",{className:"meta",x:12,y:Ce-8,children:[i.jsx("tspan",{className:"key",children:m.key}),i.jsxs("tspan",{children:[" · ",m.type]}),N&&i.jsxs("tspan",{className:N.tone,children:[" · ",N.text]}),$&&i.jsx("tspan",{children:" · needs you"})]}),o&&i.jsx("circle",{className:`pr-flag-dot ${o}`,cx:Ee-2,cy:2,r:4}),i.jsx(x1,{mark:d,frozen:h}),m.guide&&i.jsx(Pj,{id:m.guide}),n&&!j&&i.jsxs("text",{className:"live-tag",x:Ee,y:Ce+13,textAnchor:"end",children:[n.agent," · step ",n.step,"/",n.total," · ",n.stepLabel.toLowerCase()]})]})}function N1(e,n){const r=["node",`st-${e.state}`,n.hitl?"hitl":"afk"];return n.selected&&r.push("sel"),n.live&&r.push("live"),n.waiting&&r.push("waiting"),n.stalled&&!n.waiting&&r.push("stalled"),n.mark&&r.push(`mark-${n.mark}`),n.frozen&&r.push("frozen"),r.join(" ")}function b1(e,n){const r=e.ticket.assignee;return n.waiting?{text:"waiting on you",tone:"urgent"}:n.stalled?{text:`stalled · ${r}`,tone:"warn"}:n.wait?{text:`needs ${n.wait}`,tone:"warn"}:e.state==="claimed"?{text:r??"working",tone:"agent"}:{text:ox[e.state],tone:""}}const jo=(e,n)=>`${e}>${n}`;function C1(e,n,r=[]){const o=new Map(e.tickets.map(c=>[c.id,c]));return{tickets:n.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(n.nodes.map(c=>[c.id,c.mark])),newEdges:new Set(n.nodes.flatMap(c=>c.newEdges.map(d=>jo(d,c.id)))),removedEdges:new Set(n.nodes.flatMap(c=>(c.removedEdges??[]).map(d=>jo(d,c.id)))),frozen:new Set(r)}}const mh=.72;function $1(e){const{fit:n,nodes:r,size:o,pad:l}=e;if(n.k>=mh)return n;const c=r.find(h=>h.state==="claimed")??r.find(h=>h.state==="frontier")??r[0];if(!c)return n;const d=mh;return{k:d,x:o.w/2-(c.x+l+Ee/2)*d,y:o.h/2-(c.y+l+Ce/2)*d}}function T1({y:e,width:n,height:r}){return i.jsxs("g",{className:"quarantine",children:[i.jsx("rect",{x:-20,y:e-30,width:n+40,height:r+18,fill:"url(#hatch-oos)"}),i.jsx("text",{x:-12,y:e-14,children:"Out of scope"})]})}const et=280,ph=4,E1=220,Is=e=>Math.round(e/ph)*ph;function M1(e){let n=2166136261;for(const r of e)n=Math.imul(n^r.charCodeAt(0),16777619);return()=>{n=n+1831565813|0;let r=Math.imul(n^n>>>15,1|n);return r=r+Math.imul(r^r>>>7,61|r)^r,((r^r>>>14)>>>0)/4294967296}}function Dl(e,n,r,o){return Array.from({length:6},()=>{const l=o*(.5+e()*.7),c=o*(.3+e()*.4);return{x:Is(n+(e()-.5)*o*.8-l/2),y:Is(r+(e()-.5)*o*.5-c/2),w:Is(l),h:Is(c)}})}function I1(e){const{width:n,height:r,nodes:o}=e,l=M1(e.seed),c=(j,w)=>j+l()*(w-j),d=(j,w)=>!o.some(E=>j>E.x-52&&j<E.x+Ee+28&&w>E.y-52&&w<E.y+Ce+28),h=(n+et*2)*(r+et*2),g=Array.from({length:Math.round(h/9e4)},()=>Dl(l,c(-et,n+et),c(-et,r+et),c(160,360))).flat(),m=[...Dl(l,n+et*.55,r+et*.55,300),...Dl(l,-et*.5,-et*.45,220)],y=[],v=(j,w,E)=>{y.length<E1&&d(w,E)&&y.push({sprite:j,x:Is(w),y:Is(E)})};for(let j=0;j<Math.round(h/3e4);j++){const w=c(-et,n+et),E=c(-et,r+et),N=3+Math.floor(l()*5);for(let $=0;$<N;$++)v(l()<.65?"pine":"oak",w+c(-70,70),E+c(-44,44))}for(let j=0;j<Math.round(h/45e3);j++)v(l()<.4?"rock":"tuft",c(-et,n+et),c(-et,r+et));return y.sort((j,w)=>j.y-w.y),{grass:g,water:m,items:y}}const Hm={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 A1({name:e}){return i.jsx("symbol",{id:`terrain-${e}`,overflow:"visible",children:Hm[e]})}const O1=Object.keys(Hm),L1=x.memo(function(n){const{seed:r,width:o,height:l,nodes:c}=n,d=x.useMemo(()=>I1({seed:r,width:o,height:l,nodes:c}),[r,o,l,c]);return i.jsxs("g",{className:"terrain","aria-hidden":"true",children:[i.jsx("defs",{children:O1.map(h=>i.jsx(A1,{name:h},h))}),d.grass.map((h,g)=>i.jsx("rect",{x:h.x,y:h.y,width:h.w,height:h.h,fill:"var(--map-grass)"},g)),d.water.map((h,g)=>i.jsx("rect",{x:h.x,y:h.y,width:h.w,height:h.h,fill:"var(--map-water)"},g)),i.jsx("rect",{x:-4e3,y:-4e3,width:o+8e3,height:l+8e3,fill:"url(#map-grid)"}),d.items.map((h,g)=>i.jsx("use",{href:`#terrain-${h.sprite}`,x:h.x,y:h.y},g))]})}),R1=380;function _1(e){const{selId:n,size:r}=e,o=x.useRef(e);o.current=e;const l=x.useRef(!0);x.useEffect(()=>{if(l.current){l.current=!1;return}const{nodes:c,pad:d,view:h,setView:g,onFocus:m}=o.current,y=n?c.find(I=>I.ticket.id===n):void 0;if(!y||!r.w)return;m();const v=Math.min(1.4,Math.max(h.k,1.05)),j={k:v,x:r.w/2-(d+y.x+Ee/2)*v,y:r.h/2-(d+y.y+Ce/2)*v};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return g(j);const w=h,E=performance.now();let N=0;const $=I=>{const R=Math.min(1,(I-E)/R1),O=1-(1-R)**3;g({k:w.k+(j.k-w.k)*O,x:w.x+(j.x-w.x)*O,y:w.y+(j.y-w.y)*O}),R<1&&(N=requestAnimationFrame($))};return N=requestAnimationFrame($),()=>cancelAnimationFrame(N)},[n])}function P1(e,n){const r=x.useRef(n);r.current=n,x.useEffect(()=>{const o=e.current;if(!o)return;const l=m=>{const y=o.getBoundingClientRect();return{x:m.clientX-y.left,y:m.clientY-y.top}},c=m=>{m.preventDefault();const y=m.ctrlKey?.01:.0015;r.current(Math.exp(-m.deltaY*y),l(m))};let d=1;const h=m=>{m.preventDefault(),d=1},g=m=>{m.preventDefault();const y=m;r.current(y.scale/d,l(y)),d=y.scale};return o.addEventListener("wheel",c,{passive:!1}),o.addEventListener("gesturestart",h,{passive:!1}),o.addEventListener("gesturechange",g,{passive:!1}),()=>{o.removeEventListener("wheel",c),o.removeEventListener("gesturestart",h),o.removeEventListener("gesturechange",g)}},[e])}function gh(e,n,r){const o=Math.min(3,Math.max(.2,n));return{k:o,x:r.x-(r.x-e.x)*o/e.k,y:r.y-(r.y-e.y)*o/e.k}}const Gt=32,D1=1.8;function B1(e){var X;const{snap:n,selection:r,onSelect:o,preview:l}=e,c=(l==null?void 0:l.tickets)??n.tickets,d=x.useRef(null),[h,g]=x.useState({w:0,h:0});x.useEffect(()=>{const P=d.current;if(!P)return;const Q=new ResizeObserver(([q])=>g({w:q.contentRect.width,h:q.contentRect.height}));return Q.observe(P),()=>Q.disconnect()},[]);const m=x.useMemo(()=>{const P=Tf(c,"LR",n.map.mode),Q=Tf(c,"TB",n.map.mode),q=ae=>Math.min(h.w/(ae.width+Gt*2),h.h/(ae.height+Gt*2+16));return q(P)*D1>=q(Q)?P:Q},[c,n.map.mode,h.w,h.h]),y=(P,Q)=>Math.min(1.25,Math.max(e.minFit??0,Math.min(h.w/P,h.h/Q))),v=x.useMemo(()=>{const P=m.width+Gt*2,Q=m.height+Gt*2+16,ae=m.nodes.some(D=>D.state==="out-of-scope")&&h.h?Math.max(0,h.h/y(P,Q)-Q):0;if(!ae)return{...m,slack:ae};const H=new Map(m.nodes.map(D=>[D,{...D,y:D.y+(D.state==="out-of-scope"?ae:ae/2)}]));return{...m,slack:ae,nodes:[...H.values()],edges:m.edges.map(D=>({from:H.get(D.from),to:H.get(D.to)})),quarantineY:m.quarantineY+ae,height:m.height+ae}},[m,h.w,h.h,e.minFit]),j=f1(v),w=j.right+Gt*2,E=j.bottom+Gt*2+16,N=()=>{const P=y(w,E);return{k:P,x:Math.max(0,(h.w-w*P)/2),y:Math.max(0,(h.h-E*P)/2)}},[$,I]=x.useState({k:1,x:0,y:0}),R=x.useRef(!1);x.useEffect(()=>{R.current=!1},[n.map.id]),x.useEffect(()=>{!R.current&&h.w&&I($1({fit:N(),nodes:v.nodes,size:h,pad:Gt}))},[h.w,h.h,w,E,n.map.id]);const O=x.useRef(new Map),te=x.useRef(null),se=P=>{const Q=d.current.getBoundingClientRect();return{x:P.clientX-Q.left,y:P.clientY-Q.top}},F=()=>{var ae;const P=[...O.current.values()],Q=P.length>1?{x:(P[0].x+P[1].x)/2,y:(P[0].y+P[1].y)/2}:P[0],q=P.length>1?Math.hypot(P[0].x-P[1].x,P[0].y-P[1].y):0;te.current={view:$,dist:q,mid:Q,moved:((ae=te.current)==null?void 0:ae.moved)??!1}};P1(d,(P,Q)=>{R.current=!0,I(q=>gh(q,q.k*P,Q))});const ie=en(5e3),oe=dc(e.leases,n.map.id),G=mc(),ge=(X=jc())==null?void 0:X.waiting,He=new Map(e.sessions.filter(P=>Xt(P)&&P.ticketId).map(P=>[P.ticketId,P])),$e=(r==null?void 0:r.kind)==="ticket"?r.id:void 0;return _1({selId:$e,nodes:v.nodes,size:h,pad:Gt,view:$,setView:I,onFocus:()=>R.current=!0}),i.jsxs("div",{className:"graph-box",ref:d,onPointerDown:P=>{O.current.set(P.pointerId,se(P)),O.current.size===1&&(te.current=null),F()},onPointerMove:P=>{var ae;if(!O.current.has(P.pointerId)||!te.current)return;O.current.set(P.pointerId,se(P));const Q=te.current,q=[...O.current.values()];if(q.length>1){const H={x:(q[0].x+q[1].x)/2,y:(q[0].y+q[1].y)/2},D=Math.hypot(q[0].x-q[1].x,q[0].y-q[1].y),U=gh(Q.view,Q.view.k*D/(Q.dist||D),Q.mid);I({...U,x:U.x+H.x-Q.mid.x,y:U.y+H.y-Q.mid.y}),Q.moved=!0}else{const H=q[0].x-Q.mid.x,D=q[0].y-Q.mid.y;if(!Q.moved&&Math.hypot(H,D)<5)return;Q.moved||(ae=d.current)==null||ae.setPointerCapture(P.pointerId),Q.moved=!0,I({...Q.view,x:Q.view.x+H,y:Q.view.y+D})}R.current=!0},onPointerUp:P=>{O.current.delete(P.pointerId),O.current.size&&F()},onPointerCancel:P=>O.current.delete(P.pointerId),onClickCapture:P=>{var Q;(Q=te.current)!=null&&Q.moved&&(P.stopPropagation(),te.current=null)},children:[i.jsxs("svg",{className:"graph",width:h.w,height:h.h,onClick:()=>o(null),children:[i.jsx(g1,{}),i.jsx("g",{transform:`translate(${$.x} ${$.y}) scale(${$.k})`,children:i.jsxs("g",{transform:`translate(${Gt} ${Gt})`,children:[i.jsx(L1,{seed:n.map.id,width:w,height:E,nodes:v.nodes}),v.nodes.some(P=>P.state==="out-of-scope")&&i.jsx(T1,{y:v.quarantineY,width:v.width,height:v.quarantineH}),v.edges.map(({from:P,to:Q})=>i.jsx(v1,{from:P,to:Q,direction:v.direction,added:l==null?void 0:l.newEdges.has(jo(P.ticket.id,Q.ticket.id)),removed:l==null?void 0:l.removedEdges.has(jo(P.ticket.id,Q.ticket.id))},`${P.ticket.id}-${Q.ticket.id}`)),i.jsx(p1,{trails:h1(v,j)}),v.nodes.length>0&&i.jsx(m1,{x:j.x,y:j.y}),v.nodes.map(P=>{var Q;return i.jsx(S1,{n:P,session:He.get(P.ticket.id),stalled:!!oe.get(P.ticket.id)&&Io(oe.get(P.ticket.id),ie)!=="live",flag:ax(Ps.ticket(G,n.map.id,P.ticket.id)),selected:$e===P.ticket.id,onSelect:o,mark:l==null?void 0:l.marks.get(P.ticket.id),frozen:l==null?void 0:l.frozen.has(P.ticket.id),needs:(Q=ge==null?void 0:ge.find(q=>q.mapId===n.map.id&&q.ticketId===P.ticket.id))==null?void 0:Q.tier},P.ticket.id)})]})})]}),i.jsx("button",{className:"btn sm fit-btn","data-tip":"Fit the whole trail in view",onPointerDown:P=>P.stopPropagation(),onClick:P=>{P.stopPropagation(),R.current=!0,I(N())},children:"Fit"})]})}const Bl=[["decided","Done"],["claimed","Working"],["frontier","Ready"],["blocked","Backlog"],["parked","Parked"],["out-of-scope","Cancelled"]],vh=[["verifying","Verifying"],["rework","Rework"],["held","Blocked"]];function z1({snap:e,sessions:n}){const r=_h(e),o=m=>r[m],l=n.filter(cm).length,c=sk(e),d=Math.max(1,...c.map(m=>m.open+m.closed)),g=(e.map.verification??"off")!=="off"||vh.some(([m])=>o(m))?[...Bl.slice(0,2),...vh,...Bl.slice(2)]:Bl;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(Ye,{as:"h3",children:"Status"}),i.jsxs("span",{className:"t-meta",children:[r.total," tickets"]})]}),i.jsxs("ul",{children:[g.map(([m,y])=>i.jsxs("li",{className:`st-${m} ${o(m)?"":"zero"}`,children:[i.jsx("i",{}),i.jsx("span",{children:y}),i.jsx("b",{children:o(m)})]},m)),i.jsxs("li",{className:`st-waiting ${l?"":"zero"}`,children:[i.jsx("i",{}),i.jsx("span",{children:"Waiting on you"}),i.jsx("b",{children:l})]})]})]}),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(m=>i.jsxs("li",{title:`${m.type}: ${m.closed} closed, ${m.open} open`,children:[i.jsx("span",{className:"t-meta",children:mo[m.type]}),i.jsxs("span",{className:"mix-bar",children:[i.jsx("i",{className:"closed",style:{width:`${m.closed/d*100}%`}}),i.jsx("i",{className:"open",style:{width:`${m.open/d*100}%`}})]}),i.jsx("b",{children:m.open+m.closed})]},m.type))})]})]})}function F1(e){const[n,r]=x.useState(!1);return i.jsxs("div",{className:n?"status-drawer open":"status-drawer",children:[i.jsxs("button",{type:"button",className:"status-toggle","aria-expanded":n,onPointerDown:o=>o.stopPropagation(),onClick:()=>r(!n),children:["Summary ",i.jsx("span",{className:"caret",children:n?"▾":"▴"})]}),i.jsx(z1,{snap:e.snap,sessions:e.sessions})]})}function U1({planOnly:e,verifies:n}){const r=[["frontier","Ready"],["claimed","Working"],...n?[["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:[r.map(([o,l])=>i.jsxs("span",{className:`lg st-${o}`,children:[i.jsx("i",{}),l]},o)),i.jsx("span",{className:"lg hitl",children:"● needs human"})]})}function W1(e){var o,l;const{snap:n,selection:r}=e.api;return i.jsxs(We,{as:"main",className:"zone map-zone",style:{gridArea:"map"},children:[n&&i.jsx(xj,{}),(o=e.trail)==null?void 0:o.banner,i.jsxs("div",{className:"map-area",children:[n&&!e.compact&&i.jsx(F1,{snap:n,sessions:e.sessions}),n?i.jsx(B1,{snap:n,sessions:e.sessions,leases:e.api.leases,selection:r,onSelect:e.onSelect,minFit:e.minFit,preview:(l=e.trail)==null?void 0:l.preview}):i.jsxs("div",{className:"nomap",children:[i.jsx(Nj,{}),i.jsx("h2",{children:"No trail"}),i.jsx("p",{className:"nomap-lede",children:"Describe your idea and create the trail here, or start it in your agent's chat. Scout frames it with you, then your agents get to work."}),i.jsx("div",{className:"actions",children:i.jsx(K,{variant:"primary",onClick:e.onNewTrail,"data-tip":"Describe the idea and create the trail",children:"New trail…"})}),i.jsx(ko,{command:'/scout new "your idea"'})]}),n&&e.compact&&i.jsx(U1,{planOnly:n.map.mode==="plan-only",verifies:(n.map.verification??"off")!=="off"})]})]})}const H1=[["home","Inbox"],["map","Map"],["ticket","Ticket"],["activity","Activity"],["plan","Plan"]];function V1(e){const{tab:n,covered:r,pending:o}=e;return i.jsx("nav",{className:"tabbar",children:H1.map(([l,c])=>i.jsxs("button",{className:n===l&&!r?"on":"",onClick:()=>e.onPick(l),children:[c,l==="home"&&o>0&&i.jsx(Zn,{n:o,urgent:!0,pop:!0},o)]},l))})}function K1(e){const n={home:e.projects?i.jsxs("div",{className:"phone-home",children:[e.projects,e.inbox]}):e.inbox,map:e.map,ticket:i.jsx(We,{className:"zone",children:e.ticket}),activity:i.jsx(We,{className:"zone",children:e.activity}),plan:e.plan};return i.jsx("main",{className:"phone-view",children:e.decisions||n[e.tab]})}function G1(e,n){const{activity:r,selection:o,setSelection:l,actions:c}=e,[d,h]=x.useState("ticket"),[g,m]=x.useState("home"),[y,v]=x.useState(0),[j,w]=x.useState(null),[E,N]=x.useState(!1),$=F=>{N(!1),w({focus:F})},I=()=>{w(null),N(F=>!F)};x.useEffect(()=>{const F=r.sessions.find(ie=>ie.id===e.chatSession);!o&&(F!=null&&F.ticketId)&&F.mapId===e.mapId&&l({kind:"ticket",id:F.ticketId})},[e.chatSession,e.mapId]);const R=F=>{l(F),F&&(n==="laptop"&&h("ticket"),n==="mobile"&&m("ticket"))},O=(F,ie,oe)=>{oe&&oe!==e.mapId&&c.selectMap(oe),c.openChat(F);const G=r.sessions.find(ge=>ge.id===F);ie&&(G==null?void 0:G.mapId)===(oe??e.mapId)&&l({kind:"ticket",id:ie}),n==="mobile"&&(m("home"),v(ge=>ge+1))};return{sideTab:d,setSideTab:h,phoneTab:g,setPhoneTab:m,convRequest:y,decisionsView:j,setDecisionsView:w,openDecisions:$,statsOpen:E,setStatsOpen:N,toggleStats:I,select:R,openChat:O,showChat:(F,ie,oe)=>{O(F,ie,oe),v(G=>G+1)},openTicket:(F,ie)=>{F!==e.mapId&&c.selectMap(F),l({kind:"ticket",id:ie}),w(null),n==="laptop"&&h("ticket"),n==="mobile"&&m("ticket")}}}function Q1(e,n){x.useEffect(()=>{document.title=`${ve.name}: ${e?`(${e}) `:""}${n??"No trail"}`},[e,n])}function q1(e){const[n,r]=x.useState("…");return x.useEffect(()=>{fetch(`${Ne()}/list`).then(o=>o.json()).then(o=>{var c;const l=o.root.split("/").filter(Boolean);r((c=l[l.length-1])!=null&&c.startsWith(".")?l[l.length-2]??"repo":l[l.length-1]??"repo")}).catch(()=>r("repo"))},[e]),n}function Y1(e,n){return x.useMemo(()=>{const r=e.sessions.filter(l=>l.mapId===n),o=new Set(e.sessions.filter(l=>l.mapId!==n).map(l=>l.id));return{...e,sessions:r,feed:e.feed.filter(l=>!l.sessionId||!o.has(l.sessionId))}},[e,n])}function J1({text:e}){return e.trim()?i.jsx("div",{className:"brief-prose",children:e.split(`
|
|
138
|
+
`).map((n,r)=>i.jsx("p",{children:n.split(/(`[^`]+`|\/?\b[\w.-]+\/[\w./-]+\b)/g).map((o,l)=>l%2===1?i.jsx("code",{children:o.replace(/`/g,"")},l):o)},r))}):i.jsx(Le,{children:"Not covered"})}const kh=["summary","productContext","existing","conventions","dataModel","api","risks"];function X1(e){const{brief:n}=e,[r,o]=x.useState(!1),[l,c]=x.useState("");x.useEffect(()=>{const m=y=>y.key==="Escape"&&e.onClose();return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[e]);const d=n.sections,h=kh.filter(m=>d[m].trim()),g=kh.filter(m=>!d[m].trim());return i.jsx("div",{className:"scrim",onClick:e.onClose,children:i.jsxs(We,{as:"div",className:"dialog brief-dialog",onClick:m=>m.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:"Discovery brief"}),i.jsx("span",{className:"t-meta",children:Z1(n)})]}),i.jsxs("div",{className:"brief-body",children:[h.map(m=>i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:Ei[m]}),i.jsx(J1,{text:d[m]}),(m==="conventions"||m==="productContext")&&d[m].trim()&&i.jsx(kc,{draft:()=>({title:`${Ei[m]}: ${d[m].split(`
|
|
139
|
+
`)[0].slice(0,80)}`,body:d[m],kind:m==="conventions"?"convention":"business-rule",sources:[`brief:${n.mapId}`]})})]},m)),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:Ei.assumptions}),d.assumptions.length?i.jsx("ul",{className:"item-list",children:d.assumptions.map(m=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:m.text}),i.jsx(re,{parts:[{text:m.id,code:!0}]})]},m.id))}):i.jsx(Le,{children:"None listed"})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:Ei.openQuestions}),d.openQuestions.length?i.jsx("ul",{className:"brief-list",children:d.openQuestions.map(m=>i.jsx("li",{children:m},m))}):i.jsx(Le,{children:"None"})]}),g.length>0&&i.jsxs("p",{className:"t-meta brief-empty",children:["Nothing noted on ",g.map(m=>Ei[m].toLowerCase()).join(", "),"."]}),n.note&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Your last request"}),i.jsx("p",{children:n.note})]})]}),r&&i.jsx(qe,{label:"What should change?",children:i.jsx("textarea",{rows:3,value:l,onChange:m=>c(m.target.value),autoFocus:!0})}),e.error&&i.jsx("p",{className:"urgent-text",children:e.error}),i.jsxs("div",{className:"actions",children:[n.status==="submitted"&&!r&&i.jsxs(i.Fragment,{children:[i.jsx(K,{onClick:()=>o(!0),children:"Request changes"}),i.jsx(K,{variant:"primary",onClick:e.onAccept,children:"Accept brief"})]}),r&&i.jsxs(i.Fragment,{children:[i.jsx(K,{variant:"ghost",onClick:()=>o(!1),children:"Back"}),i.jsx(K,{variant:"primary",disabled:!l.trim(),onClick:()=>e.onRequestChanges(l.trim()),children:"Send to the agent"})]}),i.jsx(K,{variant:"ghost",onClick:e.onClose,children:"Close"})]})]})})}function Z1(e){if(e.status==="draft")return"Not submitted yet";const n=[e.status.replace("-"," ")];return e.author&&n.push(`by ${e.author}`),e.submittedAt&&n.push(`${Zt(Date.now()-e.submittedAt)} ago`),n.join(" · ")}function eS({brief:e,onReview:n}){return e.status!=="submitted"?null:i.jsx("div",{className:"brief-card",children:i.jsx(ze,{edge:"attention",title:"Discovery brief ready for your review",context:i.jsx(re,{parts:["Discovery brief",e.author&&`by ${e.author}`]}),detail:e.sections.summary.split(`
|
|
140
|
+
`)[0],detailText:e.sections.summary,onOpen:n})})}const tS={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 nS({brief:e,onReview:n}){if(e.status==="accepted")return null;const[r,o]=tS[e.status],l=e.status==="submitted"?"edge-attention":"edge-neutral";return i.jsxs("div",{className:`discovery-banner map-banner ${l} st-${e.status}`,role:"status",children:[i.jsxs("span",{className:"mb-text",children:[i.jsx("span",{className:"mb-lead",children:r}),i.jsx("span",{className:"t-meta",children:o})]}),i.jsx(Fi,{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(K,{size:"sm",variant:e.status==="submitted"?"primary":"ghost",onClick:n,children:e.status==="submitted"?"Review brief":"Open brief"})]})}const yh=`${Ne()}/briefs`;function sS(e){const n=e==null?void 0:e.map.id,[r,o]=x.useState(null),[l,c]=x.useState(),d=x.useCallback(()=>{if(!n)return o(null);fetch(`${yh}?mapId=${encodeURIComponent(n)}`).then(y=>y.ok?y.json():{brief:null}).then(y=>o(y.brief)).catch(()=>o(null))},[n]),h=e==null?void 0:e.tickets.reduce((y,v)=>Math.max(y,v.updatedAt),e.map.updatedAt);x.useEffect(d,[d,h]),x.useEffect(()=>fn(y=>y.startsWith("briefs/")&&d()),[d]);const g=(y,v)=>fetch(`${yh}/${y}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:n,note:v})}).then(async j=>{const w=await j.json().catch(()=>({}));if(!j.ok||!w.brief)throw new Error(w.error??`HTTP ${j.status}`);c(void 0),o(w.brief)}),m=(y,v)=>g(y,v).then(()=>!0,j=>(c(j.message),!1));return{brief:r,error:l,accept:()=>m("accept"),requestChanges:y=>m("request-changes",y)}}function iS(e){const n=sS(e),[r,o]=x.useState(!1),l=()=>o(!0),c=n.brief,d=c==null?void 0:c.sections;return{review:l,briefText:d?[d.existing,d.conventions,d.dataModel,d.api].join(`
|
|
141
|
+
`):"",banner:c&&i.jsx(nS,{brief:c,onReview:l}),inboxCard:c&&i.jsx(eS,{brief:c,onReview:l}),dialog:c&&r&&i.jsx(X1,{brief:c,error:n.error,onAccept:()=>void n.accept().then(h=>h&&o(!1)),onRequestChanges:h=>void n.requestChanges(h).then(g=>g&&o(!1)),onClose:()=>o(!1)})}}function rS({reroute:e,onReview:n}){var h;const r=e.kind==="challenge-destination",o=((h=e.frozen)==null?void 0:h.length)??0,l=r?"wrong mountain?":"proposes a new plan",c=o?` ${o} ticket${o===1?" is":"s are"} closed until you decide.`:"",d=`${e.reason.replace(/\.$/,"")}.${c}`;return i.jsxs("div",{className:"reroute-banner map-banner edge-attention",role:"status",title:d,children:[i.jsxs("span",{className:"mb-text",children:[i.jsxs("span",{className:"mb-lead",children:[e.by," ",l]}),i.jsx("span",{className:"t-meta",children:d})]}),i.jsx(Fi,{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(K,{size:"sm",variant:"primary",onClick:n,children:"Review"})]})}const oS={"already-exists":"The work already exists","wrong-problem":"The trail targets the wrong problem",rescope:"The trail should be rescoped"};function aS(e,n){var r;switch(e.op){case"add_ticket":{const o=(r=e.blockedBy)!=null&&r.length?`after ${e.blockedBy.map(n).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:n(e.ticket),detail:e.reason};case"edit_ticket":return{verb:"Revise",text:n(e.ticket),detail:e.title?`New title: ${e.title}`:"New description"};case"rewire":return{verb:"Rewire",text:n(e.ticket),detail:lS(e,n)};case"supersede_decision":return{verb:"Supersede",text:e.decision,detail:`${e.answer}. ${e.rationale}`};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:n(e.ticket),detail:`Back in the queue: ${e.reason}`};default:return e}}function lS(e,n){var o,l;return[...(o=e.addBlockedBy)!=null&&o.length?[`now also after ${e.addBlockedBy.map(n).join(", ")}`]:[],...(l=e.removeBlockedBy)!=null&&l.length?[`no longer after ${e.removeBlockedBy.map(n).join(", ")}`]:[]].join(" · ")}const cS=new Set(["cancel_ticket","update_destination"]);function uS({change:e,name:n}){const r=aS(e,n);return i.jsx(ze,{as:"li",className:`reroute-change op-${e.op}`,edge:cS.has(e.op)?"attention":"neutral",title:r.text,titleText:r.text,context:i.jsx(re,{parts:[{text:r.verb,strong:!0}]}),detail:r.detail,detailText:r.detail})}function dS(e){const{reason:n,destination:r}=e;return i.jsxs("section",{className:"reroute-destination",children:[n&&i.jsx("p",{className:"reroute-destination-why",children:oS[n]}),r&&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:r.before||"—"})]}),i.jsxs("div",{children:[i.jsx("span",{className:"mono-label",children:"Suggested destination"}),i.jsx("p",{className:"after",children:r.after})]})]})]})}function fS(e,n){const r=new Map(e.tickets.map(l=>[l.id,l.key])),o=new Map(n.flatMap(l=>l.op==="add_ticket"?[[l.ref,l.title]]:[]));return l=>{const c=r.get(l);if(c)return c;const d=o.get(l);return d?`new: ${d}`:l}}function hS(e){var j,w;const{reroute:n,snap:r}=e,[o,l]=x.useState("");x.useEffect(()=>{const E=N=>N.key==="Escape"&&e.onClose();return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[e]);const c=fS(r,n.changes),d=new Map(r.tickets.map(E=>[E.id,`${E.key} ${E.title}`])),h=E=>d.get(E)??c(E),g=r.map.sections.assumptions??[],m=n.invalidates.map(E=>g.find(N=>N.id===E)??{id:E,text:""}),y=n.status==="pending",v=n.kind==="challenge-destination";return i.jsx("div",{className:"scrim",onClick:e.onClose,children:i.jsxs(We,{as:"div",className:"dialog reroute-dialog",onClick:E=>E.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:v?"Destination challenged":"Reroute proposal"}),i.jsx(re,{parts:[{text:n.id,code:!0},n.status,`by ${n.by}`,`${Zt(Date.now()-n.at)} ago`]})]}),i.jsxs("div",{className:"reroute-body",children:[v&&i.jsx(dS,{reason:n.destinationReason,destination:(j=n.diff)==null?void 0:j.destination}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Why"}),i.jsx("p",{children:n.reason})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Evidence"}),i.jsx("p",{className:"reroute-evidence",children:n.evidence})]}),m.length>0&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Assumptions it invalidates"}),i.jsx("ul",{className:"item-list",children:m.map(E=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:E.text}),i.jsx(re,{parts:[{text:E.id,code:!0}]})]},E.id))})]}),i.jsxs("section",{children:[i.jsxs("h3",{className:"mono-label",children:["Changes · ",n.changes.length]}),i.jsx("ul",{className:"reroute-changes row-list",children:n.changes.map((E,N)=>i.jsx(uS,{change:E,name:h},N))})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Closed until you decide"}),(w=n.frozen)!=null&&w.length?i.jsx("ul",{className:"item-list",children:n.frozen.map(E=>i.jsx("li",{className:"item-text",children:h(E)},E))}):i.jsx(Le,{children:"No tickets closed"})]}),n.note&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Your note"}),i.jsx("p",{children:n.note})]})]}),y&&i.jsx(qe,{label:"Note for the agent (required to reject)",children:i.jsx("textarea",{rows:2,value:o,onChange:E=>l(E.target.value)})}),e.error&&i.jsx("p",{className:"urgent-text",children:e.error}),i.jsxs("div",{className:"actions",children:[y&&i.jsxs(i.Fragment,{children:[i.jsx(K,{className:"reroute-reject",disabled:!o.trim(),onClick:()=>e.onReject(o.trim()),children:"Reject"}),i.jsx(K,{className:"reroute-approve",variant:"primary",onClick:()=>e.onApprove(o.trim()),children:"Approve and apply"})]}),i.jsx(K,{variant:"ghost",onClick:e.onClose,children:"Close"})]})]})})}const xh=`${Ne()}/reroutes`;function mS(e){const n=e==null?void 0:e.map.id,[r,o]=x.useState([]),[l,c]=x.useState(),d=x.useCallback(()=>{if(!n)return o([]);fetch(`${xh}?map=${encodeURIComponent(n)}`).then(m=>m.ok?m.json():{reroutes:[]}).then(m=>o(m.reroutes)).catch(()=>o([]))},[n]),h=e==null?void 0:e.tickets.reduce((m,y)=>Math.max(m,y.updatedAt),e.map.updatedAt);x.useEffect(d,[d,h]),x.useEffect(()=>ux("reroute",m=>{m.mapId===n&&d()}),[d,n]);const g=async(m,y,v)=>{var N;const j=await fetch(`${xh}/${m}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:n,id:y,note:v})}),w=await j.json().catch(()=>({}));if(j.ok)return c(void 0),d(),!0;const E=(N=w.errors)==null?void 0:N.map($=>$.message).join("; ");return c([w.error??`HTTP ${j.status}`,E].filter(Boolean).join(": ")),!1};return{reroutes:r,pending:r.find(m=>m.status==="pending"),error:l,clearError:()=>c(void 0),approve:(m,y)=>g("approve",m,y),reject:(m,y)=>g("reject",m,y)}}function pS(e,n){const r=mS(e),[o,l]=x.useState(),c=r.reroutes.find(m=>m.id===o),d=c!=null&&c.diff?c:r.pending,h=()=>{l(void 0),r.clearError()},g=m=>m&&h();return{banner:r.pending&&i.jsx(rS,{reroute:r.pending,onReview:()=>{var m;return l((m=r.pending)==null?void 0:m.id)}}),preview:e&&(d!=null&&d.diff)?C1(e,d.diff,d.frozen):void 0,openReroute:(m,y)=>{m!==(e==null?void 0:e.map.id)&&(n==null||n(m)),l(y)},dialog:e&&c&&i.jsx(hS,{reroute:c,snap:e,error:r.error,onApprove:m=>void r.approve(c.id,m||void 0).then(g),onReject:m=>void r.reject(c.id,m).then(g),onClose:h})}}function gS(e,n){const r=iS(e),o=pS(e,n);return{briefText:r.briefText,inboxCard:r.inboxCard,review:r.review,banner:i.jsxs(i.Fragment,{children:[r.banner,o.banner]}),preview:o.preview,openReroute:o.openReroute,dialog:i.jsxs(i.Fragment,{children:[r.dialog,o.dialog]})}}function vS(){const e=new URL(location.href);e.searchParams.has(Ls)&&(e.searchParams.delete(Ls),history.replaceState(history.state,"",e))}function kS(e,n){return e.kind!=="question"||n.pending.some(r=>r.id===e.ref)}function yS(e){const[n,r]=x.useState(()=>new URLSearchParams(location.search).get(Ls)??void 0),{loaded:o,view:l,activity:c,handlers:d,showChat:h}=e;return x.useEffect(()=>{if(!n||!o||!l)return;const g=l.items.find(y=>y.id===n);if(g&&!kS(g,c)||(r(void 0),vS(),!g))return;xm(g,{...d,openQuestion:y=>{const v=c.pending.find(j=>j.id===y);v&&h(v.sessionId,v.ticketId)}})},[n,o,l,c,d,h]),{request:x.useCallback(g=>r(g),[])}}function xS(e){const{api:n,nav:r}=e,o=jm(n.allSnaps);aj(o.view);const l=m=>m&&n.actions.selectMap(m),c={openTicket:r.openTicket,openKnowledge:()=>e.knowledge.setOpen(!0),openBrief:m=>m===n.mapId?e.reviewBrief():l(m),openReroute:e.openReroute??(m=>m.ticketId?r.openTicket(m.mapId,m.ticketId):l(m.mapId)),selectTrail:l,openGuides:e.openGuides},d=o.view,h=yS({loaded:n.loaded,view:d,activity:n.activity,handlers:c,showChat:r.showChat});return{attention:o,handlers:c,header:d&&i.jsx(sj,{view:d,onFocus:m=>void o.savePrefs({...d.prefs,focusUntil:m})}),link:h}}function wS(e){const{d:n,snap:r}=e,[o,l]=x.useState(!1),[c,d]=x.useState(""),[h,g]=x.useState("");x.useEffect(()=>{l(!1),d(""),g("")},[n.id,n.mapId]);const m=zv(e.all.filter(w=>w.mapId===n.mapId),n.id),y=Di(n),v=n.ticketId?r==null?void 0:r.tickets.find(w=>w.id===n.ticketId):void 0,j=Date.now();return i.jsxs("div",{className:"detail dv-d",children:[i.jsxs("div",{className:"d-head",children:[i.jsx("span",{className:"key",children:n.id}),i.jsx(Dn,{tone:"state",className:`dv-st-${y}`,children:y}),i.jsx(re,{parts:[rx(n.decidedAt),`${Zt(j-n.decidedAt)} ago`]})]}),i.jsx("h3",{className:"t-heading",children:n.question}),i.jsxs("div",{className:"resolution",children:[i.jsx(vo,{parts:["Decision"]}),i.jsx("p",{children:n.answer})]}),i.jsxs("dl",{className:"facts",children:[i.jsx("dt",{children:"Trail"}),i.jsx("dd",{children:r?`${r.map.key} ${r.map.title}`:n.mapId}),i.jsx("dt",{children:"Ticket"}),i.jsx("dd",{children:n.ticketId?i.jsxs("button",{className:"link",onClick:()=>e.onOpenTicket(n.mapId,n.ticketId),children:[n.ticketKey," ",(v==null?void 0:v.title)??""," · open in trail ›"]}):"—"}),i.jsx("dt",{children:"Decided by"}),i.jsx("dd",{children:n.decidedBy}),n.participants.length>1&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Participants"}),i.jsx("dd",{children:n.participants.map(w=>w.name??w.id).join(", ")})]}),i.jsx("dt",{children:"Source"}),i.jsxs("dd",{children:[Ln[n.source.kind].label,n.source.url&&i.jsxs(i.Fragment,{children:[" · ",i.jsx("a",{href:n.source.url,target:"_blank",rel:"noreferrer",children:n.source.label??"link"})]}),!n.source.url&&n.source.label&&` · ${n.source.label}`,n.source.ref&&i.jsxs("span",{className:"ref",children:[" ",n.source.ref]})]})]}),n.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:n.alternatives.map(w=>i.jsx("li",{children:w},w))})]}),n.rationale&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Rationale"}),i.jsx("p",{children:n.rationale})]}),m.length>1&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Supersession"}),i.jsx("ol",{className:"dv-chain",children:m.map(w=>i.jsx("li",{className:`${w.id===n.id?"cur":""} ${w.supersededBy?"old":"live"}`,children:i.jsxs("button",{onClick:()=>e.onSelect(w.id),children:[i.jsx("i",{}),i.jsx("span",{className:"id",children:w.id}),i.jsx("span",{className:"a",children:w.summary}),i.jsx(re,{parts:[w.decidedBy,_s(w.decidedAt)]})]})},w.id))})]}),i.jsxs("div",{className:"actions",children:[i.jsx(kc,{draft:()=>({title:n.summary||n.question,body:[n.answer,n.rationale&&`Why: ${n.rationale}`].filter(Boolean).join(`
|
|
142
|
+
|
|
143
|
+
`),kind:"product-decision",sources:[`decision:${n.id}`,...n.ticketKey?[`ticket:${n.ticketKey}`]:[]]})}),y==="active"&&i.jsx(K,{on:o,onClick:()=>l(w=>!w),"data-tip":"Replace this decision with a new answer. Both stay on record",children:"Supersede…"})]}),o&&i.jsxs(At,{as:"form",tone:"inset",className:"inline-form",onSubmit:w=>{w.preventDefault(),c.trim()&&(e.onSupersede(n,{answer:c.trim(),rationale:h.trim(),alternatives:[n.summary]}),l(!1))},children:[i.jsx(qe,{label:"New decision",children:i.jsx("textarea",{rows:3,value:c,onChange:w=>d(w.target.value),autoFocus:!0})}),i.jsx(qe,{label:"Rationale",children:i.jsx("input",{value:h,onChange:w=>g(w.target.value)})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(K,{variant:"ghost",onClick:()=>l(!1),children:"Cancel"}),i.jsx(K,{type:"submit",variant:"primary",disabled:!c.trim(),children:"Supersede"})]})]}),i.jsxs("div",{className:"dv-sec",children:[i.jsxs("h4",{className:"mono-label",children:["Transcript ",i.jsx("span",{className:"n",children:n.transcript.length})]}),n.transcript.length?i.jsx("div",{className:"dv-transcript comms-log",children:n.transcript.map((w,E)=>i.jsxs("div",{className:`msg from-${w.from} voice-${w.from==="human"?"human":"agent"}`,children:[i.jsx(vo,{parts:[w.author,uc(w.at)]}),i.jsx("div",{className:"msg-text",children:w.text})]},E))}):i.jsx(Le,{children:"None recorded"})]})]})}function It(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 jS(e){const{filter:n,set:r,all:o}=e,l=c=>o.filter(c).length;return e.compact?i.jsxs("div",{className:"dv-filters compact",children:[i.jsx(lt,{compact:!0,"aria-label":"Trail",value:n.mapId??"",onChange:c=>r({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(lt,{compact:!0,"aria-label":"Source",value:n.source??"",onChange:c=>r({source:c||void 0}),options:[{value:"",label:"All sources"},...ho.map(c=>({value:c,label:Ln[c].label}))]}),i.jsx(lt,{compact:!0,"aria-label":"Decided by",value:n.decidedBy??"",onChange:c=>r({decidedBy:c||void 0}),options:[{value:"",label:"Anyone"},...e.people.map(c=>({value:c,label:c}))]}),i.jsx(lt,{compact:!0,"aria-label":"Status",value:n.status??"",onChange:c=>r({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(It,{on:!n.mapId,label:"All trails",n:o.length,onClick:()=>r({mapId:void 0})}),e.trails.map(c=>i.jsx(It,{on:n.mapId===c.map.id,label:`${c.map.key} ${c.map.title}`,n:l(d=>d.mapId===c.map.id),onClick:()=>r({mapId:c.map.id})},c.map.id))]}),i.jsx("h3",{className:"mono-label",children:"Source"}),i.jsxs("ul",{children:[i.jsx(It,{on:!n.source,label:"All",n:o.length,onClick:()=>r({source:void 0})}),ho.map(c=>i.jsx(It,{cls:`src-${c}`,on:n.source===c,label:Ln[c].label,n:l(d=>d.source.kind===c),onClick:()=>r({source:n.source===c?void 0:c})},c))]}),i.jsx("h3",{className:"mono-label",children:"Made by"}),i.jsxs("ul",{children:[i.jsx(It,{on:!n.madeBy,label:"Anyone",n:o.length,onClick:()=>r({madeBy:void 0})}),i.jsx(It,{on:n.madeBy==="agent",label:"Agents, on their own",n:l(c=>Li(c)==="agent"),onClick:()=>r({madeBy:n.madeBy==="agent"?void 0:"agent"})}),i.jsx(It,{on:n.madeBy==="human",label:"People",n:l(c=>Li(c)==="human"),onClick:()=>r({madeBy:n.madeBy==="human"?void 0:"human"})})]}),i.jsx("h3",{className:"mono-label",children:"Decided by"}),i.jsxs("ul",{children:[i.jsx(It,{on:!n.decidedBy,label:"Anyone",n:o.length,onClick:()=>r({decidedBy:void 0})}),e.people.map(c=>i.jsx(It,{on:n.decidedBy===c,label:c,n:l(d=>d.decidedBy===c),onClick:()=>r({decidedBy:n.decidedBy===c?void 0:c})},c))]}),i.jsx("h3",{className:"mono-label",children:"Status"}),i.jsxs("ul",{children:[i.jsx(It,{on:!n.status,label:"Any",n:o.length,onClick:()=>r({status:void 0})}),i.jsx(It,{on:n.status==="active",label:"Active",n:l(c=>!c.supersededBy),onClick:()=>r({status:n.status==="active"?void 0:"active"})}),i.jsx(It,{on:n.status==="superseded",label:"Superseded",n:l(c=>!!c.supersededBy),onClick:()=>r({status:n.status==="superseded"?void 0:"superseded"})})]})]})}function SS(e){if(Di(e)==="superseded")return`Replaced by ${e.supersededBy}`;if(e.supersedes)return`Replaces ${e.supersedes}`}function NS(e){const{d:n}=e,r=Di(n);return i.jsxs(i.Fragment,{children:[e.newDay&&i.jsx("li",{className:"dv-day t-label",children:_s(n.decidedAt)}),i.jsx(ze,{as:"li",className:`dv-row ${r}`,selected:e.on,onOpen:e.onClick,title:n.question,titleText:n.question,trailing:uc(n.decidedAt),context:i.jsx(re,{parts:[{text:n.id,code:!0},n.ticketKey&&{text:n.ticketKey,code:!0},e.showTrail&&e.trail,n.decidedBy,Ln[n.source.kind].label,SS(n)]}),detail:n.summary,detailText:n.summary})]})}function bS(e){const{rows:n,current:r}=e;return i.jsx("ol",{className:"dv-list","aria-label":"Logbook",children:n.length?n.map((o,l)=>{var c;return i.jsx(NS,{d:o,newDay:l===0||_s(n[l-1].decidedAt)!==_s(o.decidedAt),trail:(c=e.snaps[o.mapId])==null?void 0:c.map.key,on:(r==null?void 0:r.id)===o.id&&r.mapId===o.mapId,showTrail:e.showTrail,onClick:()=>e.onSelect(o.id)},`${o.mapId}:${o.id}`)}):i.jsx(Le,{children:"No decisions"})})}function CS({stats:e}){return i.jsxs("span",{className:"dv-readouts",children:[i.jsx(Yt,{layout:"start",label:"Active",value:e.active}),i.jsx(Yt,{layout:"start",label:"Superseded",value:e.superseded}),i.jsx(Yt,{layout:"start",label:"Last 24h",value:e.last24h}),i.jsx(Yt,{layout:"start",label:"Human",value:`${e.total?Math.round(e.human/e.total*100):0}%`}),i.jsx(re,{className:"dv-src-mix",parts:ho.filter(n=>e.bySource[n]).map(n=>`${Ln[n].label} ${e.bySource[n]}`)})]})}function $S(e){const{filter:n}=e,o=Object.values(n).filter(Boolean).length-(n.query?1:0),l=e.filtersOpen||o>0;return i.jsxs("div",{className:"dv-search",children:[i.jsx("input",{type:"search",placeholder:"Search decisions",value:n.query??"",onChange:c=>e.set({query:c.target.value})}),e.showToggle&&i.jsxs("button",{className:`chip ${l?"on":""}`,onClick:e.onToggle,children:["Filters",o>0?` · ${o}`:""]})]})}function TS(e){const{api:n,bp:r}=e,o=n.decisions,[l,c]=x.useState({}),[d,h]=x.useState(e.focus),[g,m]=x.useState(!1);x.useEffect(()=>h(e.focus),[e.focus]),x.useEffect(()=>{const R=O=>{O.key==="Escape"&&(r==="mobile"&&d?h(void 0):e.onClose())};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[r,d,e]);const y=x.useMemo(()=>ak(o,l),[o,l]),v=x.useMemo(()=>lk(o),[o]),j=o.find(R=>R.id===d&&(!l.mapId||R.mapId===l.mapId))??(r==="mobile"?void 0:y[0]),w=x.useMemo(()=>Object.values(n.allSnaps).sort((R,O)=>O.map.createdAt-R.map.createdAt),[n.allSnaps]),E=x.useMemo(()=>[...new Set(o.map(R=>R.decidedBy))].sort(),[o]),N=R=>c(O=>({...O,...R})),$=()=>{const R=Object.fromEntries(w.map(O=>[O.map.id,{key:O.map.key,title:O.map.title}]));tm(`${ve.slug}-decisions-${_s(Date.now())}.md`,yk(y,R,{title:`${ve.name} decisions`}))},I=r==="mobile"&&!!j;return i.jsxs(We,{className:`zone decisions-view dv-${r}`,children:[i.jsxs("header",{className:"dv-head",children:[I?i.jsx("button",{className:"back",onClick:()=>h(void 0),children:"‹ Decisions"}):i.jsxs(Ye,{as:"h2",children:["Decisions ",y.length!==o.length&&i.jsx("span",{className:"n",children:`${y.length}/${o.length}`})]}),r!=="mobile"&&i.jsx(CS,{stats:v}),i.jsxs("span",{className:"dv-head-right",children:[!I&&i.jsx(K,{onClick:$,disabled:!y.length,title:"Export the filtered list as markdown",children:"Export .md"}),i.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})]})]}),!I&&i.jsx($S,{filter:l,set:N,showToggle:r!=="wide",filtersOpen:g,onToggle:()=>m(R=>!R)}),i.jsxs("div",{className:"dv-body",children:[(r==="wide"||g&&!I)&&i.jsx(jS,{filter:l,set:N,all:o,trails:w,people:E,compact:r!=="wide"}),!I&&i.jsx(bS,{rows:y,current:j,snaps:n.allSnaps,showTrail:r==="wide",onSelect:h}),(r!=="mobile"||j)&&i.jsx("div",{className:"dv-detail",children:j?i.jsx(wS,{d:j,all:o,snap:n.allSnaps[j.mapId],onSelect:h,onOpenTicket:e.onOpenTicket,onSupersede:n.actions.supersede}):i.jsx(Le,{children:"No decision selected"})})]})]})}function ES({api:e,bp:n,nav:r}){return r.statsOpen?i.jsx(b0,{api:e,bp:n,onClose:()=>r.setStatsOpen(!1)}):r.decisionsView?i.jsx(TS,{api:e,bp:n,focus:r.decisionsView.focus,onClose:()=>r.setDecisionsView(null),onOpenTicket:r.openTicket}):null}function MS(e,n,r){const o=zm(),[l,c]=x.useState(()=>new URLSearchParams(location.search).has("projects")),d=l&&o.many&&i.jsx(D0,{projects:o,bp:e,onClose:()=>c(!1),onItemHere:r});return{projects:o,overview:d,openOverview:()=>{n.setDecisionsView(null),n.setStatsOpen(!1),c(!0)}}}function Vm({activity:e,onTicket:n}){const r=e.feed.slice(-120).reverse();return r.length?i.jsx("div",{className:"log",children:r.map(o=>i.jsxs("div",{className:`log-row lv-${o.level} src-${o.source} ${o.signal?"signal":""}`,onClick:()=>o.ticketId&&n(o.ticketId),children:[i.jsx("span",{className:"t t-meta",children:cc(o.at)}),i.jsxs("span",{className:"src t-meta",children:[o.source==="system"&&i.jsx(pc,{className:"voice-badge"}),o.agent??o.source]}),i.jsxs("span",{className:"msg",children:[o.tag&&i.jsxs("span",{className:"tag t-meta",children:[o.tag," · "]}),o.text]})]},o.id))}):i.jsx(Rn,{title:"Nothing has happened yet",hint:"Claims, steps, questions and decisions appear here as agents work."})}function wh({lease:e,now:n}){if(!e)return null;const r=Io(e,n);if(r==="live")return null;const o=e.expiresAt-n;return i.jsxs(Dn,{tone:"amber",className:"stalled",title:`No activity from ${e.agent}; the ticket returns to the queue when the lease runs out`,children:["stalled · ",r==="expired"?"returning":Ft(o)]})}function IS({total:e,step:n}){return i.jsx("span",{className:"segs","aria-label":`Step ${n} of ${e}`,children:Array.from({length:e},(r,o)=>i.jsx("i",{className:AS(o+1,n)},o))})}function AS(e,n){return e<n?"done":e===n?"cur":""}function Km({snap:e,activity:n,leases:r,onSelect:o,onOpenChat:l}){var j;const c=en(1e3),d=n.sessions.filter(Xt),h=new Set(d.map(w=>w.ticketId)),g=dc(r,e==null?void 0:e.map.id),m=(e==null?void 0:e.tickets.filter(w=>w.state==="open"&&w.assignee&&!h.has(w.id)))??[];if(!d.length&&!m.length)return i.jsx(Le,{children:"No agent on a ticket"});const y=w=>!!w&&Io(w,c)!=="live",v=!!((j=e==null?void 0:e.map.modelMatching)!=null&&j.enabled);return i.jsxs("ul",{className:"sessions-list",children:[d.map(w=>{const E=e==null?void 0:e.tickets.find(I=>I.id===w.ticketId),N=E?Pi(E)==="hitl":!1,$=E&&g.get(E.id);return i.jsx(ze,{as:"li",className:w.waitingOn?"waiting":void 0,edge:OS(w,y($)),title:_S(E,w.mode)||w.agent,context:i.jsx(re,{parts:[{text:w.agent,strong:!0},v&&LS(w),w.waitingOn?{text:"Waiting on you",urgent:!0}:`${w.mode} · ${w.stepLabel.toLowerCase()}`,N&&!w.waitingOn&&"with you",RS(w)],children:i.jsx(wh,{lease:$,now:c})}),trailing:nm(c-w.startedAt),below:i.jsx(IS,{total:w.total,step:w.step}),onOpen:()=>{E&&o({kind:"ticket",id:E.id}),N&&l(w.id)}},w.id)}),m.map(w=>i.jsx(ze,{as:"li",className:"claim",edge:y(g.get(w.id))?"attention":"neutral",title:`${w.key} ${w.title}`,context:i.jsx(re,{parts:[{text:w.assignee??"",strong:!0},"claimed, no live session"],children:i.jsx(wh,{lease:g.get(w.id),now:c})}),onOpen:()=>o({kind:"ticket",id:w.id})},w.id))]})}function OS(e,n){return e.waitingOn?"urgent":n?"attention":"neutral"}function LS(e){const n=e.model?`Runs ${e.model}`:"No model reported, so it counts as balanced";return{text:e.tier??"balanced",tip:n,className:"session-tier"}}function RS(e){if(e.usage)return`${Oo(rk(e))} tok · ${Rs(e.usage.costUsd)}`}function _S(e,n){return e?`${e.key} ${e.title}`:n==="chart"?"Charting trail":""}function Gm({activity:e,snap:n,running:r,usage:o=!0}){const l=Dh(e,n==null?void 0:n.map.id),c=zh(e,n==null?void 0:n.map.id),d=new Set(e.sessions.filter(Xt).map(g=>g.ticketId)),h=(n==null?void 0:n.tickets.filter(g=>g.state==="open"&&g.assignee&&!d.has(g.id)).length)??0;return i.jsx(Nt,{sub:!0,className:"sessions-head",title:i.jsxs(i.Fragment,{children:["Agents on tickets ",i.jsx("span",{className:"n",children:r+h})]}),right:o?i.jsxs("span",{className:"usage",title:["Model usage for this trail, all sessions",...c.map(g=>Bh[g].text)].join(`
|
|
144
|
+
`),children:[i.jsx("span",{className:"mono-label",children:"Trail"})," ",Oo(l.inputTokens+l.outputTokens)," tok · ",Rs(l.costUsd)]}):void 0})}function PS(e){const n=[...e.feed].reverse().find(r=>r.level==="step"&&r.sessionId);return n?e.sessions.find(r=>r.id===n.sessionId):void 0}const DS={running:"Working",done:"Done",failed:"Stopped"};function Qm({activity:e,snap:n}){const r=Ro(),o=PS(e);if(!o)return i.jsx(Rn,{art:i.jsx(Bi,{size:1,framed:!1,variant:r?"night":"crt",label:"Scout"}),title:"No agent working yet",hint:"Run /scout resume in Claude Code or Codex. Each step an agent reports shows here."});const l=o.ticketId?n==null?void 0:n.tickets.find(h=>h.id===o.ticketId):void 0,c=$o[o.mode],d=o.waitingOn?"Waiting on you":DS[o.status];return i.jsxs("div",{className:`step-tracker ${o.waitingOn?"waiting":""}`,children:[i.jsxs("div",{className:"st-meta",children:[i.jsx(re,{parts:[{text:o.agent,strong:!0},`${o.mode}, step ${o.step} of ${o.total}`]}),i.jsx("span",{className:`t-label st-status ${o.waitingOn?"urgent":""}`,children:d})]}),i.jsxs("div",{className:"st-big",children:[o.stepLabel,l&&i.jsxs("span",{className:"st-key",children:[" ",l.key]})]}),l&&i.jsx("div",{className:"st-ticket t-meta",children:l.title}),i.jsx("ol",{className:"pipeline",children:c.map((h,g)=>{const m=g+1,y=m<o.step||m===o.step&&o.status==="done";let v="";return y?v="done":m===o.step&&(v="cur"),i.jsxs("li",{className:v,children:[i.jsx("i",{}),i.jsxs("span",{children:[String(m).padStart(2,"0")," ",h]})]},h)})})]})}function jh(e){return i.jsxs("div",{className:"zone-b activity-stack",children:[i.jsx(Qm,{activity:e.activity,snap:e.snap}),i.jsx(Gm,{activity:e.activity,snap:e.snap,running:e.activity.sessions.filter(Xt).length}),i.jsx(Km,{snap:e.snap,activity:e.activity,leases:e.leases,onSelect:n=>(n==null?void 0:n.kind)==="ticket"&&e.onTicket(n.id),onOpenChat:e.onOpenChat}),i.jsx(Nt,{sub:!0,title:"Activity log"}),i.jsx(Vm,{activity:e.activity,onTicket:e.onTicket})]})}function BS(e){return i.jsx(fm,{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(Vm,{activity:e.activity,onTicket:e.onTicket})})}function zS(e){var o;const n=e.activity.sessions.filter(Xt).length,r=!e.activity.sessions.length&&!((o=e.snap)!=null&&o.tickets.some(l=>l.state==="open"&&l.assignee));return i.jsxs(We,{className:"zone step-zone",style:{gridArea:"step"},children:[i.jsx(Nt,{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(Qm,{activity:e.activity,snap:e.snap}),!r&&i.jsxs(i.Fragment,{children:[i.jsx(Gm,{activity:e.activity,snap:e.snap,running:n,usage:!1}),i.jsx(Km,{snap:e.snap,activity:e.activity,leases:e.leases,onSelect:l=>(l==null?void 0:l.kind)==="ticket"&&e.onTicket(l.id),onOpenChat:e.onOpenChat})]})]})]})}const Sh=`${Ne()}/criteria`;function FS(e){const[n,r]=x.useState([]),o=x.useCallback(()=>{if(!e)return r([]);fetch(`${Sh}?mapId=${encodeURIComponent(e)}`).then(c=>c.ok?c.json():{tickets:[]}).then(c=>r(c.tickets)).catch(()=>r([]))},[e]);return x.useEffect(()=>(o(),fn(c=>c.startsWith("criteria/")&&o())),[o]),{tickets:n,confirm:c=>fetch(`${Sh}/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,...c})}).then(o)}}function US({snap:e,t:n}){const{tickets:r,confirm:o}=FS(e.map.id),l=Fs(),c=r.find(m=>m.ticketId===n.id),d=(c==null?void 0:c.criteria)??[],g=qh(l.entries,{trailKey:e.map.key,ticket:{type:n.type,title:n.title,body:n.body},paths:Yh(`${n.body}
|
|
145
|
+
${l.briefText}`)}).filter(m=>m.kind==="business-rule").filter(m=>Bk(d,[m.id]).length);return!d.length&&!g.length?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 · ",d.length,(c==null?void 0:c.confirmed)&&i.jsx("span",{className:"ok-text",children:" · confirmed by you"})]}),d.length>0&&i.jsx("ul",{className:"criteria-list item-list",children:d.map(m=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:m.text}),i.jsx(re,{parts:[{text:m.id,code:!0},m.kind.replace("-"," "),m.source&&`from ${m.source}`]})]},m.id))}),g.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:g.map(m=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:m.title}),i.jsx(re,{parts:[{text:m.id,code:!0},"business rule"]})]},m.id))})]}),d.length>0&&n.state==="open"&&i.jsx(K,{size:"sm",variant:c!=null&&c.confirmed?"ghost":"default","data-tip":c!=null&&c.confirmed?"Take your confirmation back":"Agree that these criteria define done for this ticket",onClick:()=>void o({title:e.map.title,ticketId:n.id,ticketKey:n.key,confirmed:!(c!=null&&c.confirmed)}),children:c!=null&&c.confirmed?"Unconfirm":"Confirm criteria"})]})}const So="";function WS(e){const n=ic.map(o=>({value:o,label:_i[o],hint:Sm[o]})),r=[...HS(e),...n];return i.jsx(lt,{compact:!0,className:"vf-level","aria-label":"Verification level",value:e.value??So,options:r,onChange:o=>e.onChange(o===So?null:o)})}function HS(e){return e.inherit!==void 0?[{value:So,label:e.inherit,hint:"Use the trail’s level for this ticket."}]:e.value===void 0?[{value:So,label:"Off (not set)"}]:[]}function VS({check:e}){const n=dj(e),[r,o]=x.useState(),[l,c]=x.useState(),d=KS(e);return i.jsxs("details",{className:`vf-row ${n?"ok":"bad"}`,open:!n,children:[i.jsxs("summary",{children:[i.jsx("span",{className:"vf-mark",children:n?"✓":"✕"}),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:Ft(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:r??(e.tail||"No output.")}),i.jsxs("div",{className:"vf-log-line",children:[r===void 0&&i.jsx("button",{className:"link",onClick:()=>Ui.log(e.log).then(h=>o(h.clipped?`[earlier output not shown]
|
|
146
|
+
${h.text}`:h.text),h=>c(h.message)),children:"Full log ›"}),e.truncated&&i.jsx("span",{className:"dim",children:"log capped at 1 MB"}),l&&i.jsx("span",{className:"vf-err",children:l})]})]})}function KS(e){return e.error?"did not start":e.timedOut?"timed out":`exit ${e.exitCode??e.signal??"?"}`}const Nh=e=>(e==null?void 0:e.slice(0,8))??"none",bh=e=>e===null?"·":String(e);function GS({attempt:e}){const n=e.git;if(!n)return null;const{files:r,add:o,del:l}=n.stats;return i.jsxs("div",{className:"vf-git",children:[i.jsx(re,{parts:[n.tree?{text:`${n.base?`${Nh(n.base.head)} → `:""}${Nh(n.tree.head)}`,code:!0}:"not a git repo",n.tree&&{text:n.tree.branch??"detached HEAD",code:!!n.tree.branch},n.tree&&`${r} file${r===1?"":"s"} +${o} −${l}`]}),n.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(`
|
|
147
|
+
`),children:[i.jsx("span",{className:"t-code",children:c.kind})," ",c.message]},c.kind)}),n.changed.length>0&&i.jsxs("details",{className:"vf-files",children:[i.jsx("summary",{className:"t-label",children:"Changed files"}),i.jsx("ul",{children:n.changed.map(c=>i.jsxs("li",{children:[i.jsx("code",{children:c.path}),i.jsxs("span",{className:"dim",children:[c.untracked?"new":`+${bh(c.add)} −${bh(c.del)}`,c.dirtyAtClaim?" · dirty at claim":""]})]},c.path))})]})]})}function QS({attempt:e,latest:n}){return i.jsxs("details",{className:`vf-attempt r-${e.result}`,open:n,children:[i.jsxs("summary",{children:[i.jsx(Dn,{tone:"state",className:`r-${e.result}`,children:uj[e.result]}),i.jsx(re,{parts:[{text:e.id,code:!0},e.agent,zi(e.submittedAt),Ft(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(r=>i.jsx("li",{className:qS(r),children:r},r))}),i.jsx(GS,{attempt:e}),e.checks.map(r=>i.jsx(VS,{check:r},r.name))]})}function qS(e){return e.includes(" ✓ ")?"ok":e.includes(" ✗ ")?"bad":"wait"}const YS={PASS:"Passed",FAIL:"Sent back",NEEDS_HUMAN:"Needs you"};function JS({verdict:e}){const{guide:n,checklist:r}=e;return i.jsxs("div",{className:`vf-verdict v-${e.verdict.toLowerCase()}`,children:[i.jsx(re,{parts:[{text:e.byKind==="trail lead"&&e.verdict==="PASS"?"Approved":YS[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)}`,n&&`as ${n.id} ${n.version}`,`on ${e.attemptId}`,zi(e.at)]}),i.jsx("p",{children:e.summary}),e.findings.length>0&&i.jsx("ul",{className:"vf-findings",children:e.findings.map((o,l)=>i.jsxs("li",{className:`sev-${o.severity}`,children:[o.path&&i.jsx("code",{children:o.line?`${o.path}:${o.line}`:o.path})," ",o.text]},l))}),r&&r.length>0&&i.jsx(Mm,{answers:r})]})}function XS(e,n,r){const[o,l]=x.useState(),c=x.useCallback(()=>{Ui.ticket(e,n).then(l)},[e,n]);return x.useEffect(()=>(l(void 0),c(),Ps.onEvidence(c)),[c]),x.useEffect(c,[c,r]),{data:o,reload:c}}const zl={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 ZS(e){const[n,r]=x.useState(),[o,l]=x.useState(""),[c,d]=x.useState("rework"),{state:h,submitted:g,running:m,act:y}=e;if(m||h!=="verifying"&&h!=="held")return null;const v=w=>{r(n===w?void 0:w),l("")},j=w=>{w.preventDefault(),!(!n||!o.trim())&&(y({action:n,reason:o.trim(),...n==="unblock"?{to:c}:{}}),r(void 0))};return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"actions vf-actions",children:[h==="verifying"&&g&&i.jsx(K,{variant:"primary",onClick:()=>void y({action:"approve"}),"data-tip":"Checks passed: approve and close the ticket",children:"Approve"}),g&&i.jsx(K,{onClick:()=>void y({action:"rerun"}),"data-tip":"Run the repo's checks again on the current code",children:"Re-run checks"}),i.jsx(K,{on:n==="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(K,{on:n==="accept",onClick:()=>v("accept"),"data-tip":"Close it as done despite the failing checks",children:"Accept anyway…"}),i.jsx(K,{on:n==="unblock",onClick:()=>v("unblock"),"data-tip":"Put it back in the queue without running checks",children:"Unblock…"})]})]}),n&&i.jsxs(At,{as:"form",tone:"inset",className:"inline-form",onSubmit:j,children:[i.jsx(qe,{label:zl[n].label,children:i.jsx("textarea",{rows:2,value:o,onChange:w=>l(w.target.value),autoFocus:!0})}),n==="unblock"&&i.jsx(qe,{label:"Back to",children:i.jsx(lt,{"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:zl[n].hint}),i.jsxs("div",{className:"form-actions",children:[i.jsx(K,{variant:"ghost",onClick:()=>r(void 0),children:"Cancel"}),i.jsx(K,{type:"submit",variant:n==="accept"?"danger":"primary",disabled:!o.trim(),children:zl[n].submit})]})]})]})}const eN={ticket:"set on this ticket",trail:"from the trail",none:"not set"},tN=new Set(["verifying","rework","held"]);function nN(e){const{mapId:n,ticket:r,state:o}=e,{data:l,reload:c}=XS(n,r.id,r.updatedAt),[d,h]=x.useState();if(!l||l.level.level==="off"&&!l.attempts.length&&!tN.has(o))return null;const g=y=>(h(void 0),Ui.act({...y,mapId:n,ticketId:r.id,by:yt}).then(c,v=>h(v.message))),m=l.running;return i.jsxs("section",{className:"vf-panel",children:[i.jsxs("div",{className:"vf-head",children:[i.jsx(Ye,{as:"h4",children:"Verification"}),i.jsx(re,{parts:[_i[l.level.level],eN[l.level.source]]}),r.state==="open"&&i.jsx(WS,{value:r.verification,inherit:`Trail (${_i[e.trail??"off"]})`,onChange:y=>void g({action:"level",level:y})})]}),m&&i.jsxs("div",{className:"sync-line vf-running",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:["Checking ",m.id," for ",m.agent," · since ",zi(m.startedAt)]})]}),i.jsx(ZS,{state:o,submitted:l.attempts.length>0,running:!!m,act:g}),d&&i.jsx("p",{className:"vf-err",children:d}),l.verdicts.map(y=>i.jsx(JS,{verdict:y},y.id)),l.attempts.map((y,v)=>i.jsx(QS,{attempt:y,latest:v===0},y.id)),!l.attempts.length&&!m&&i.jsx(re,{parts:[`Checks: ${l.level.checks.join(", ")||"none"}`,"run when the ticket is submitted"]})]})}function sN({lease:e,onRelease:n}){const r=en(1e3),o=Io(e,r),l=o==="live";return i.jsxs("div",{className:`lease lease-${o} edge-note ${l?"":"edge-attention"}`,children:[i.jsxs("div",{className:"edge-note-head",children:[i.jsx(re,{parts:[{text:`Claimed by ${e.agent}`,strong:!0},`active ${Zt(r-e.renewedAt)} ago`]}),!l&&i.jsx(Dn,{tone:"amber",children:"Stalled"})]}),i.jsx("p",{className:"t-meta lease-line",children:iN(o,rN(e.expiresAt-r))}),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(K,{variant:l?"default":"urgent",onClick:n,children:"Release to queue"})})]})}function iN(e,n){return e==="expired"?"Lease expired, going back to the queue":e==="stalled"?`The agent went quiet. Back in the queue in ${n}.`:`Back in the queue after ${n} without activity.`}function rN(e){const n=e/864e5;return n>=2?`${Math.round(n)} days`:Ft(Math.max(0,e))}function oN({comments:e}){if(!e.length)return null;const n=e.length>1?"s":"";return i.jsxs("details",{className:"comments",children:[i.jsxs("summary",{className:"t-label",children:[e.length," other comment",n]}),e.map(r=>i.jsxs("div",{className:"comment",children:[i.jsx(re,{parts:[{text:r.author,strong:!0}]}),i.jsx("div",{className:"c-body",children:r.body.replace(/\*\*/g,"")})]},r.id))]})}function aN({resolution:e,decisions:n,onOpenDecision:r}){const o=n.find(d=>!d.supersededBy)??n[0],l=e.body.startsWith("**Ruled")?"ruled out":"resolution",c=n.length>1?` · ${n.length} in chain`:"";return i.jsxs("div",{className:"resolution edge-note edge-done",children:[i.jsxs("div",{className:"edge-note-head",children:[i.jsx(re,{parts:[{text:e.author,strong:!0},l]}),o&&r&&i.jsxs("button",{className:"link t-meta",onClick:()=>r(o.id),children:[o.id,c," ›"]})]}),i.jsx("p",{children:e.body.replace(/^\*\*[^*]+\*\*\s*/,"")})]})}function lN(e){const{t:n,state:r,session:o,mine:l,form:c,setForm:d,actions:h,onOpenChat:g}=e;return i.jsxs("div",{className:"actions",children:[o&&i.jsx(K,{variant:o.waitingOn?"urgent":"default",onClick:()=>g(o.id),"data-tip":o.waitingOn?"The agent is waiting for your answer":"Open the conversation with this agent",children:o.waitingOn?"Answer":"Conversation"}),r==="frontier"&&i.jsx(K,{onClick:()=>h.claim(n.id),"data-tip":"Take this ticket yourself, so no agent picks it up",children:"Claim"}),(r==="frontier"||r==="claimed"&&l)&&i.jsx(K,{on:c==="resolve",onClick:()=>d(c==="resolve"?null:"resolve"),"data-tip":"Answer it yourself and close the ticket, with a decision record",children:"Resolve…"}),l&&r==="claimed"&&i.jsx(K,{onClick:()=>h.release(n.id),"data-tip":"Give the ticket back to the queue",children:"Release"}),(r==="frontier"||r==="blocked"||r==="parked")&&i.jsx(K,{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 cN({t:e,state:n,tickets:r}){const o=new Map(r.map(m=>[m.id,m])),l=m=>{var y;return((y=o.get(m))==null?void 0:y.key)??m},c=e.blockedBy.map(m=>{var y;return`${l(m)}${((y=o.get(m))==null?void 0:y.state)==="closed"?" ✓":""}`}).join(", "),d=r.filter(m=>m.blockedBy.includes(e.id)).map(m=>m.key).join(", "),h=[["Type",mo[e.type]],["Assignee",e.assignee],["Blocked by",c],["Blocks",d],["Reviews",e.reviewOf&&l(e.reviewOf)]],g=Pi(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(Dn,{tone:"state",className:`st-${n}`,children:im[n]}),i.jsx("span",{className:"d-att t-meta","data-tip":g?"A person takes this one":"An agent takes this alone",children:g?"Needs a person":"Agent work"})]}),i.jsx("h3",{className:"t-heading",children:e.title}),i.jsx("dl",{className:"facts",children:h.filter(([,m])=>m).flatMap(([m,y])=>[i.jsx("dt",{className:"t-label",children:m},`${m}-k`),i.jsx("dd",{children:y},`${m}-v`)])})]})}function uN(e){const{snap:n,api:r,form:o,setForm:l}=e,{actions:c}=r,[d,h]=x.useState(""),[g,m]=x.useState(""),[y,v]=x.useState(""),[j,w]=x.useState("Not needed to reach the destination."),E=n.tickets.find(F=>F.id===e.id);if(!E)return i.jsx(Le,{children:"Ticket not found."});const N=Bs(n.tickets,n.map.mode).get(E.id),$=e.sessions.find(F=>F.ticketId===E.id&&Xt(F)),I=E.assignee===yt,R=E.state==="open"?dc(r.leases,n.map.id).get(E.id):void 0,O=[...E.comments].reverse().find(F=>/^\*\*(Resolution|Ruled out of scope)\*\*/.test(F.body)),te=E.comments.filter(F=>F!==O),se=r.decisions.filter(F=>F.mapId===n.map.id&&F.ticketId===E.id);return i.jsxs("div",{className:"detail",children:[i.jsx(cN,{t:E,state:N,tickets:n.tickets}),i.jsx(k0,{mapId:n.map.id,ticketId:E.id}),i.jsx(Px,{mapId:n.map.id,ticketId:E.id}),i.jsx(o0,{mapId:n.map.id,ticket:E}),i.jsx(US,{snap:n,t:E}),i.jsx(Jx,{snap:n,t:E}),E.closeReason==="not_planned"&&i.jsx(kc,{label:"Save as dead end",draft:()=>{var F;return{title:`Ruled out: ${E.title}`,body:((F=E.comments.at(-1))==null?void 0:F.body)??E.body,kind:"dead-end",sources:[`trail:${n.map.key}`,`ticket:${E.key}`]}}}),R&&i.jsx(sN,{lease:R,onRelease:()=>c.releaseLease(E.id)}),!R&&i.jsx(i1,{mapId:n.map.id,ticketId:E.id}),i.jsx(nN,{mapId:n.map.id,trail:n.map.verification,ticket:E,state:N}),i.jsx(lN,{t:E,state:N,session:$,mine:I,form:o,setForm:l,actions:c,onOpenChat:e.onOpenChat}),o==="resolve"&&i.jsxs(At,{as:"form",tone:"inset",className:"inline-form",onSubmit:F=>{F.preventDefault(),d.trim()&&(c.resolve(E.id,d.trim(),{rationale:g.trim(),alternatives:y.split(`
|
|
148
|
+
`).map(ie=>ie.trim()).filter(Boolean)}),l(null),h(""),m(""),v(""))},children:[i.jsx(qe,{label:"Resolution",children:i.jsx("textarea",{rows:3,value:d,onChange:F=>h(F.target.value),autoFocus:!0})}),i.jsx(qe,{label:"Rationale",children:i.jsx("input",{value:g,onChange:F=>m(F.target.value)})}),i.jsx(qe,{label:"Alternatives considered",children:i.jsx("textarea",{rows:2,value:y,onChange:F=>v(F.target.value),placeholder:"One per line"})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(K,{variant:"ghost",onClick:()=>l(null),children:"Cancel"}),i.jsx(K,{type:"submit",variant:"primary",disabled:!d.trim(),children:"Resolve"})]})]}),o==="rule"&&i.jsxs(At,{as:"form",tone:"inset",className:"inline-form",onSubmit:F=>{F.preventDefault(),c.ruleOut({ticketId:E.id},j),l(null)},children:[i.jsx(qe,{label:"Reason",children:i.jsx("input",{value:j,onChange:F=>w(F.target.value),autoFocus:!0})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(K,{variant:"ghost",onClick:()=>l(null),children:"Cancel"}),i.jsx(K,{type:"submit",variant:"danger",children:"Rule out"})]})]}),O&&i.jsx(aN,{resolution:O,decisions:se,onOpenDecision:e.onOpenDecision}),i.jsx("p",{className:"body",children:E.body}),i.jsx(oN,{comments:te})]})}function dN({snap:e,item:n,api:r}){const o=Oh(e.map.mode),[l,c]=x.useState("research"),[d,h]=x.useState(n),[g,m]=x.useState(!1),[y,v]=x.useState([]),[j,w]=x.useState("Not needed to reach the destination.");x.useEffect(()=>h(n),[n]);const E=e.tickets.filter(N=>N.state==="open");return i.jsxs("div",{className:"detail",children:[i.jsx("div",{className:"d-head",children:i.jsx(Dn,{tone:"state",className:"st-unspecified",children:"Not yet specified"})}),i.jsx("h3",{className:"t-heading",children:n}),i.jsxs(At,{as:"form",tone:"inset",className:"inline-form",onSubmit:N=>{N.preventDefault(),r.actions.graduate({unspecified:n,type:l,title:d,blockedBy:y,hitl:g})},children:[i.jsx(qe,{label:"Title",children:i.jsx("input",{value:d,onChange:N=>h(N.target.value)})}),i.jsxs("div",{className:"chips",children:[o.map(N=>i.jsx("button",{type:"button",className:`chip ${l===N?"on":""}`,onClick:()=>c(N),children:N},N)),sv.includes(l)&&i.jsx("button",{type:"button",className:`chip ${g?"on":""}`,onClick:()=>m(N=>!N),children:"needs human"})]}),i.jsx("span",{className:"field",children:"Blocked by"}),i.jsx("div",{className:"chips",children:E.map(N=>i.jsx("button",{type:"button",className:`chip ${y.includes(N.id)?"on":""}`,onClick:()=>v($=>$.includes(N.id)?$.filter(I=>I!==N.id):[...$,N.id]),children:N.key},N.id))}),i.jsx("div",{className:"form-actions",children:i.jsx(K,{type:"submit",variant:"primary",children:"Promote to ticket"})})]}),i.jsxs(At,{as:"form",tone:"inset",className:"inline-form",onSubmit:N=>{N.preventDefault(),r.actions.ruleOut({unspecified:n},j)},children:[i.jsx(qe,{label:"Reason",children:i.jsx("input",{value:j,onChange:N=>w(N.target.value)})}),i.jsx("div",{className:"form-actions",children:i.jsx(K,{type:"submit",variant:"danger",children:"Rule out"})})]})]})}function fN({api:e,sessions:n,bare:r,onOpenChat:o,onOpenDecision:l}){const{snap:c,selection:d,actions:h}=e,[g,m]=x.useState(null),y=hN(d);x.useEffect(()=>m(null),[y]);let v;return c?d?d.kind==="unspecified"?v=i.jsx(dN,{snap:c,item:d.item,api:e}):v=i.jsx(uN,{snap:c,id:d.id,api:e,sessions:n,form:g,setForm:m,onOpenChat:o??h.openChat,onOpenDecision:l}):v=i.jsx(Rn,{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(Rn,{title:"No trail yet",hint:"Once there's a trail, pick a ticket on the map to see it here."}),i.jsx(fm,{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:r,children:v})}function hN(e){return(e==null?void 0:e.kind)==="ticket"?e.id:(e==null?void 0:e.kind)==="unspecified"?e.item:""}const mN={holding:"Holding",challenged:"Challenged",invalidated:"Invalidated",confirmed:"Confirmed"};function pN(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 gN(e){const{a:n,snap:r}=e,o=n.tickets.flatMap(c=>r.tickets.filter(d=>d.id===c)),l=n.challenge&&`${n.challenge.by}: ${n.challenge.evidence}`;return i.jsx(ze,{as:"li",className:`assumption st-${n.status}`,edge:n.status==="challenged"?"attention":"neutral",title:n.text,titleText:n.text,context:i.jsx(re,{parts:[{text:n.id,code:!0},mN[n.status],pN(n)],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:l,detailText:l,trailing:e.onConfirm&&i.jsx(K,{size:"sm",variant:"ghost",disabled:e.busy,onClick:e.onConfirm,children:"Confirm"})})}function vN(e){const[n,r]=x.useState(),[o,l]=x.useState();return{confirm:async d=>{l(d);const h=await fetch(`${Ne()}/assumptions/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,id:d})}).catch(()=>{});if(l(void 0),h!=null&&h.ok)return r(void 0);const g=await(h==null?void 0:h.json().catch(()=>({})));r((g==null?void 0:g.error)??"Could not confirm it; is the Lookout connected?")},busy:o,error:n}}function kN({snap:e,onSelect:n}){const{confirm:r,busy:o,error:l}=vN(e.map.id),c=e.map.sections.assumptions??[];return c.length?i.jsxs(i.Fragment,{children:[l&&i.jsx("p",{className:"urgent-text",children:l}),i.jsx("ul",{className:"assumptions row-list",children:c.map(d=>{const h=d.status==="holding"||d.status==="challenged";return i.jsx(gN,{a:d,snap:e,onSelect:n,onConfirm:h?()=>void r(d.id):void 0,busy:o===d.id},d.id)})})]}):i.jsx(Le,{children:"None yet. They come from the accepted discovery brief or the trail's start."})}function yN(e){const[n,r]=x.useState([]),o=e==null?void 0:e.map.id,l=(e==null?void 0:e.tickets.reduce((c,d)=>Math.max(c,d.updatedAt),e.map.updatedAt))??0;return x.useEffect(()=>{if(!o)return;let c=!0;return fetch(`${Ne()}/journal?mapId=${encodeURIComponent(o)}`).then(d=>d.ok?d.json():{entries:[]}).then(d=>c&&r(d.entries)).catch(()=>c&&r([])),()=>{c=!1}},[o,l]),n}function xN({snap:e,activity:n,onTicket:r}){const o=yN(e),l=n.usageByMap[e.map.id],c=x.useMemo(()=>Wh({snap:e,journal:o,answered:n.answered,usage:l}),[e,o,n.answered,l]),d=c.interventions,h=[["Done",`${c.done}`,`${c.done} done · ${c.cancelled} cancelled · ${c.open} open`],["Lead time",Jt(c.trailLeadMs),"Trail lead time: from when the trail was charted to its last done ticket"],["Median ticket",Jt(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?"—":Rs(c.spend.perVerifiedTicketUsd),`Cost per verified ticket: trail spend ${Rs(c.spend.costUsd)} ÷ ${c.done} done tickets`]];return i.jsxs("div",{className:"report",children:[i.jsx("ul",{className:"report-stats",children:h.map(([g,m,y])=>i.jsxs("li",{"data-tip":y,children:[i.jsx("span",{className:"mono-label",children:g}),i.jsx("b",{children:m})]},g))}),i.jsxs("div",{className:"report-bar",children:[i.jsx("span",{className:"mono-label",children:"Tickets"}),i.jsx(K,{size:"sm",variant:"ghost","data-tip":"Download this report as markdown",onClick:()=>tm(`${e.map.key.replace("#","trail-")}-report.md`,Tk(c,e.map.title)),children:"Export markdown"})]}),c.tickets.length?i.jsx("ul",{className:"list report-tickets",children:c.tickets.map(g=>i.jsx("li",{className:`out-${g.outcome}`,children:i.jsxs("button",{onClick:()=>r(g.id),"data-tip":`${g.outcome} · rework ${g.reworks} · reviews ${g.reviews.passed}/${g.reviews.failed} · your calls ${g.operatorActions}`,children:[i.jsx("span",{className:"key",children:g.key}),i.jsx("span",{className:"ttl",children:g.title}),i.jsx("span",{className:"lead",children:g.outcome==="done"?Jt(g.leadMs):g.outcome})]})},g.id))}):i.jsx(Le,{children:"No tickets yet"})]})}function wN({tab:e,snap:n,selection:r,onSelect:o,activity:l}){const c=n.map.sections;switch(e){case"report":return l?i.jsx(xN,{snap:n,activity:l,onTicket:d=>o({kind:"ticket",id:d})}):i.jsx(Le,{children:"No activity yet"});case"assumptions":return i.jsx(kN,{snap:n,onSelect:o});case"decisions":return c.decisions.length?i.jsx("ol",{className:"row-list decisions",children:[...c.decisions].reverse().map((d,h)=>i.jsx(ze,{as:"li",title:d.text,titleText:d.text,context:d.ticketKey&&i.jsx(re,{parts:[{text:d.ticketKey,code:!0}]}),onOpen:d.ticketId?()=>o({kind:"ticket",id:d.ticketId}):void 0},`${d.ticketKey}-${h}`))}):i.jsx(Le,{children:"None"});case"unspecified":return c.unspecified.length?i.jsx("ul",{className:"row-list unspecified",children:c.unspecified.map(d=>i.jsx(ze,{as:"li",title:d,titleText:d,selected:(r==null?void 0:r.kind)==="unspecified"&&r.item===d,onOpen:()=>o({kind:"unspecified",item:d})},d))}):i.jsx(Le,{children:"None"});case"oos":return c.outOfScope.length?i.jsx("ul",{className:"row-list oos",children:c.outOfScope.map(d=>i.jsx(ze,{as:"li",title:d,titleText:d},d))}):i.jsx(Le,{children:"None"});case"notes":return i.jsx("p",{className:"notes t-body",children:c.notes||"No notes yet."});default:return e}}function jN({snap:e,selection:n,onSelect:r,bare:o,onAudit:l,activity:c}){var v;const[d,h]=x.useState("unspecified"),g=e==null?void 0:e.map.sections,m=[{id:"unspecified",label:"Not yet specified",n:g==null?void 0:g.unspecified.length},{id:"assumptions",label:"Assumptions",n:(v=g==null?void 0:g.assumptions)==null?void 0:v.length},{id:"decisions",label:"Decisions",n:g==null?void 0:g.decisions.length},{id:"oos",label:"Out of scope",n:g==null?void 0:g.outOfScope.length},{id:"notes",label:"Notes"},{id:"report",label:"Report"}],y=e?i.jsx(wN,{tab:d,snap:e,selection:n,onSelect:r,activity:c}):i.jsx(Rn,{title:"No plan yet",hint:"Open questions, decisions, what's ruled out, notes and the trail report collect here."});return i.jsxs(We,{className:`zone sections ${o?"bare":""}`,style:o?void 0:{gridArea:"plan"},children:[!o&&i.jsx(Nt,{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(vc,{className:"sub",value:d,onChange:h,items:m}),d==="decisions"&&l&&i.jsx("button",{className:"link",onClick:l,children:"Audit ›"})]}),i.jsx("div",{className:"zone-b",children:y})]})}function SN(){var Q;const e=x.useMemo(()=>mx(hx()),[]),n=wx(e),{snap:r,activity:o,selection:l,actions:c}=n,[d,h]=jx();x.useEffect(()=>rm(d.theme),[d.theme]);const[g,m]=x.useState(a1),[y,v]=x.useState(!1),j=q1(e.kind),w=vx(),E=o.pending.length,N=Y1(o,n.mapId);Q1(E,r==null?void 0:r.map.title);const $=G1(n,w),I=gS(r,c.selectMap),R=nw(I.briefText),O=xS({api:n,nav:$,knowledge:R,reviewBrief:I.review,openReroute:q=>I.openReroute(q.mapId,q.ref),openGuides:()=>m("guides")}),te=yx(e,n,d.briefing,(Q=O.attention.view)==null?void 0:Q.items),se=i.jsx(kj,{api:n,nav:$,bp:w,scoped:N,attn:O,above:I.inboxCard}),F=i.jsx(W1,{api:n,sessions:N.sessions,onSelect:$.select,onNewTrail:()=>v(!0),compact:w==="mobile",minFit:w==="mobile"?.7:0,trail:I}),ie=q=>i.jsx(fN,{api:n,sessions:N.sessions,bare:q,onOpenChat:ae=>$.openChat(ae),onOpenDecision:$.openDecisions}),oe={activity:N,snap:r,leases:n.leases,onTicket:q=>$.select({kind:"ticket",id:q}),onOpenChat:q=>$.openChat(q)},G=q=>i.jsx(jN,{snap:r,selection:l,onSelect:$.select,bare:q,onAudit:()=>$.openDecisions(),activity:N}),{projects:ge,overview:He,openOverview:$e}=MS(w,$,O.link.request),X=He||($.statsOpen||$.decisionsView)&&i.jsx(ES,{api:n,bp:w,nav:$}),P=te.shown&&i.jsx(Rx,{brief:te,snaps:n.allSnaps,bp:w,openTicket:$.openTicket,openChat:$.openChat,openDecisions:$.openDecisions,closeDecisions:()=>$.setDecisionsView(null),showPhoneHome:()=>$.setPhoneTab("home")});return i.jsx(hm.Provider,{value:R,children:i.jsxs("div",{className:`app bp-${w}`,children:[i.jsx(Mw,{api:n,rt:e,repo:i.jsx(B0,{repo:j,projects:ge,onOverview:$e}),brief:te,attention:O.header,decisionsOpen:!!$.decisionsView,onDecisions:()=>$.decisionsView?$.setDecisionsView(null):$.openDecisions(),onStats:$.toggleStats,onNewTrail:()=>v(!0),onSettings:m,onToggleTheme:q=>h({theme:q?"night":"day"})}),w==="wide"&&i.jsxs(i.Fragment,{children:[se,F,ie(!1),i.jsx(zS,{...oe}),i.jsx(BS,{...oe}),G(!1),X]}),w==="laptop"&&i.jsxs(i.Fragment,{children:[se,F,i.jsx(u1,{tab:$.sideTab,onTab:$.setSideTab,unspecified:r==null?void 0:r.map.sections.unspecified.length,ticket:ie(!0),activity:i.jsx(jh,{...oe}),plan:G(!0)}),X]}),w==="mobile"&&i.jsxs(i.Fragment,{children:[i.jsx(K1,{tab:$.phoneTab,decisions:X,inbox:se,projects:ge.many&&i.jsx(F0,{projects:ge,onOverview:$e}),map:F,ticket:ie(!0),activity:i.jsx(jh,{...oe}),plan:G(!0)}),i.jsx(V1,{tab:$.phoneTab,covered:!!X,pending:E,onPick:q=>{$.setPhoneTab(q),$.setDecisionsView(null)}})]}),P,I.dialog,n.error&&i.jsx("div",{className:"error-toast",children:n.error}),g&&i.jsx(c1,{rt:e,api:n,prefs:d,update:h,focus:g,onClose:()=>m(!1)}),y&&i.jsx(bj,{rt:e,onClose:()=>v(!1),onCreated:q=>c.selectMap(q)}),!d.onboarded&&i.jsx(Oj,{prefs:d,update:h,activeTracker:e.kind}),i.jsx(tw,{})]})})}rm(hc().theme);ev.createRoot(document.getElementById("root")).render(i.jsxs(i.Fragment,{children:[i.jsx(SN,{}),i.jsx(Mx,{})]}));
|