teamtrail 0.7.0-next.31 → 0.7.0-next.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
var Cv=Object.defineProperty;var $v=(e,t,r)=>t in e?Cv(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var ue=(e,t,r)=>$v(e,typeof t!="symbol"?t+"":t,r);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.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 Ol={exports:{}},Mi={},Pl={exports:{}},ke={};/**
|
|
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 Ih;function Tv(){if(Ih)return ke;Ih=1;var e=Symbol.for("react.element"),t=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"),v=Symbol.for("react.lazy"),w=Symbol.iterator;function x($){return $===null||typeof $!="object"?null:($=w&&$[w]||$["@@iterator"],typeof $=="function"?$:null)}var j={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},T=Object.assign,S={};function E($,D,fe){this.props=$,this.context=D,this.refs=S,this.updater=fe||j}E.prototype.isReactComponent={},E.prototype.setState=function($,D){if(typeof $!="object"&&typeof $!="function"&&$!=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,$,D,"setState")},E.prototype.forceUpdate=function($){this.updater.enqueueForceUpdate(this,$,"forceUpdate")};function M(){}M.prototype=E.prototype;function R($,D,fe){this.props=$,this.context=D,this.refs=S,this.updater=fe||j}var O=R.prototype=new M;O.constructor=R,T(O,E.prototype),O.isPureReactComponent=!0;var X=Array.isArray,se=Object.prototype.hasOwnProperty,_={current:null},Q={key:!0,ref:!0,__self:!0,__source:!0};function oe($,D,fe){var pe,de={},xe=null,me=null;if(D!=null)for(pe in D.ref!==void 0&&(me=D.ref),D.key!==void 0&&(xe=""+D.key),D)se.call(D,pe)&&!Q.hasOwnProperty(pe)&&(de[pe]=D[pe]);var ye=arguments.length-2;if(ye===1)de.children=fe;else if(1<ye){for(var $e=Array(ye),ct=0;ct<ye;ct++)$e[ct]=arguments[ct+2];de.children=$e}if($&&$.defaultProps)for(pe in ye=$.defaultProps,ye)de[pe]===void 0&&(de[pe]=ye[pe]);return{$$typeof:e,type:$,key:xe,ref:me,props:de,_owner:_.current}}function G($,D){return{$$typeof:e,type:$.type,key:D,ref:$.ref,props:$.props,_owner:$._owner}}function ge($){return typeof $=="object"&&$!==null&&$.$$typeof===e}function Re($){var D={"=":"=0",":":"=2"};return"$"+$.replace(/[=:]/g,function(fe){return D[fe]})}var be=/\/+/g;function te($,D){return typeof $=="object"&&$!==null&&$.key!=null?Re(""+$.key):D.toString(36)}function P($,D,fe,pe,de){var xe=typeof $;(xe==="undefined"||xe==="boolean")&&($=null);var me=!1;if($===null)me=!0;else switch(xe){case"string":case"number":me=!0;break;case"object":switch($.$$typeof){case e:case t:me=!0}}if(me)return me=$,de=de(me),$=pe===""?"."+te(me,0):pe,X(de)?(fe="",$!=null&&(fe=$.replace(be,"$&/")+"/"),P(de,D,fe,"",function(ct){return ct})):de!=null&&(ge(de)&&(de=G(de,fe+(!de.key||me&&me.key===de.key?"":(""+de.key).replace(be,"$&/")+"/")+$)),D.push(de)),1;if(me=0,pe=pe===""?".":pe+":",X($))for(var ye=0;ye<$.length;ye++){xe=$[ye];var $e=pe+te(xe,ye);me+=P(xe,D,fe,$e,de)}else if($e=x($),typeof $e=="function")for($=$e.call($),ye=0;!(xe=$.next()).done;)xe=xe.value,$e=pe+te(xe,ye++),me+=P(xe,D,fe,$e,de);else if(xe==="object")throw D=String($),Error("Objects are not valid as a React child (found: "+(D==="[object Object]"?"object with keys {"+Object.keys($).join(", ")+"}":D)+"). If you meant to render a collection of children, use an array instead.");return me}function Y($,D,fe){if($==null)return $;var pe=[],de=0;return P($,pe,"","",function(xe){return D.call(fe,xe,de++)}),pe}function ae($){if($._status===-1){var D=$._result;D=D(),D.then(function(fe){($._status===0||$._status===-1)&&($._status=1,$._result=fe)},function(fe){($._status===0||$._status===-1)&&($._status=2,$._result=fe)}),$._status===-1&&($._status=0,$._result=D)}if($._status===1)return $._result.default;throw $._result}var Z={current:null},U={transition:null},B={ReactCurrentDispatcher:Z,ReactCurrentBatchConfig:U,ReactCurrentOwner:_};function H(){throw Error("act(...) is not supported in production builds of React.")}return ke.Children={map:Y,forEach:function($,D,fe){Y($,function(){D.apply(this,arguments)},fe)},count:function($){var D=0;return Y($,function(){D++}),D},toArray:function($){return Y($,function(D){return D})||[]},only:function($){if(!ge($))throw Error("React.Children.only expected to receive a single React element child.");return $}},ke.Component=E,ke.Fragment=r,ke.Profiler=l,ke.PureComponent=R,ke.StrictMode=o,ke.Suspense=g,ke.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=B,ke.act=H,ke.cloneElement=function($,D,fe){if($==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+$+".");var pe=T({},$.props),de=$.key,xe=$.ref,me=$._owner;if(D!=null){if(D.ref!==void 0&&(xe=D.ref,me=_.current),D.key!==void 0&&(de=""+D.key),$.type&&$.type.defaultProps)var ye=$.type.defaultProps;for($e in D)se.call(D,$e)&&!Q.hasOwnProperty($e)&&(pe[$e]=D[$e]===void 0&&ye!==void 0?ye[$e]:D[$e])}var $e=arguments.length-2;if($e===1)pe.children=fe;else if(1<$e){ye=Array($e);for(var ct=0;ct<$e;ct++)ye[ct]=arguments[ct+2];pe.children=ye}return{$$typeof:e,type:$.type,key:de,ref:xe,props:pe,_owner:me}},ke.createContext=function($){return $={$$typeof:d,_currentValue:$,_currentValue2:$,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},$.Provider={$$typeof:c,_context:$},$.Consumer=$},ke.createElement=oe,ke.createFactory=function($){var D=oe.bind(null,$);return D.type=$,D},ke.createRef=function(){return{current:null}},ke.forwardRef=function($){return{$$typeof:h,render:$}},ke.isValidElement=ge,ke.lazy=function($){return{$$typeof:v,_payload:{_status:-1,_result:$},_init:ae}},ke.memo=function($,D){return{$$typeof:m,type:$,compare:D===void 0?null:D}},ke.startTransition=function($){var D=U.transition;U.transition={};try{$()}finally{U.transition=D}},ke.unstable_act=H,ke.useCallback=function($,D){return Z.current.useCallback($,D)},ke.useContext=function($){return Z.current.useContext($)},ke.useDebugValue=function(){},ke.useDeferredValue=function($){return Z.current.useDeferredValue($)},ke.useEffect=function($,D){return Z.current.useEffect($,D)},ke.useId=function(){return Z.current.useId()},ke.useImperativeHandle=function($,D,fe){return Z.current.useImperativeHandle($,D,fe)},ke.useInsertionEffect=function($,D){return Z.current.useInsertionEffect($,D)},ke.useLayoutEffect=function($,D){return Z.current.useLayoutEffect($,D)},ke.useMemo=function($,D){return Z.current.useMemo($,D)},ke.useReducer=function($,D,fe){return Z.current.useReducer($,D,fe)},ke.useRef=function($){return Z.current.useRef($)},ke.useState=function($){return Z.current.useState($)},ke.useSyncExternalStore=function($,D,fe){return Z.current.useSyncExternalStore($,D,fe)},ke.useTransition=function(){return Z.current.useTransition()},ke.version="18.3.1",ke}var Mh;function uc(){return Mh||(Mh=1,Pl.exports=Tv()),Pl.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 Ah;function Ev(){if(Ah)return Mi;Ah=1;var e=uc(),t=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 v,w={},x=null,j=null;m!==void 0&&(x=""+m),g.key!==void 0&&(x=""+g.key),g.ref!==void 0&&(j=g.ref);for(v in g)o.call(g,v)&&!c.hasOwnProperty(v)&&(w[v]=g[v]);if(h&&h.defaultProps)for(v in g=h.defaultProps,g)w[v]===void 0&&(w[v]=g[v]);return{$$typeof:t,type:h,key:x,ref:j,props:w,_owner:l.current}}return Mi.Fragment=r,Mi.jsx=d,Mi.jsxs=d,Mi}var Lh;function Iv(){return Lh||(Lh=1,Ol.exports=Ev()),Ol.exports}var i=Iv(),no={},_l={exports:{}},kt={},Dl={exports:{}},Bl={};/**
|
|
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 Rh;function Mv(){return Rh||(Rh=1,(function(e){function t(U,B){var H=U.length;U.push(B);e:for(;0<H;){var $=H-1>>>1,D=U[$];if(0<l(D,B))U[$]=B,U[H]=D,H=$;else break e}}function r(U){return U.length===0?null:U[0]}function o(U){if(U.length===0)return null;var B=U[0],H=U.pop();if(H!==B){U[0]=H;e:for(var $=0,D=U.length,fe=D>>>1;$<fe;){var pe=2*($+1)-1,de=U[pe],xe=pe+1,me=U[xe];if(0>l(de,H))xe<D&&0>l(me,de)?(U[$]=me,U[xe]=H,$=xe):(U[$]=de,U[pe]=H,$=pe);else if(xe<D&&0>l(me,H))U[$]=me,U[xe]=H,$=xe;else break e}}return B}function l(U,B){var H=U.sortIndex-B.sortIndex;return H!==0?H:U.id-B.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=[],v=1,w=null,x=3,j=!1,T=!1,S=!1,E=typeof setTimeout=="function"?setTimeout:null,M=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(U){for(var B=r(m);B!==null;){if(B.callback===null)o(m);else if(B.startTime<=U)o(m),B.sortIndex=B.expirationTime,t(g,B);else break;B=r(m)}}function X(U){if(S=!1,O(U),!T)if(r(g)!==null)T=!0,ae(se);else{var B=r(m);B!==null&&Z(X,B.startTime-U)}}function se(U,B){T=!1,S&&(S=!1,M(oe),oe=-1),j=!0;var H=x;try{for(O(B),w=r(g);w!==null&&(!(w.expirationTime>B)||U&&!Re());){var $=w.callback;if(typeof $=="function"){w.callback=null,x=w.priorityLevel;var D=$(w.expirationTime<=B);B=e.unstable_now(),typeof D=="function"?w.callback=D:w===r(g)&&o(g),O(B)}else o(g);w=r(g)}if(w!==null)var fe=!0;else{var pe=r(m);pe!==null&&Z(X,pe.startTime-B),fe=!1}return fe}finally{w=null,x=H,j=!1}}var _=!1,Q=null,oe=-1,G=5,ge=-1;function Re(){return!(e.unstable_now()-ge<G)}function be(){if(Q!==null){var U=e.unstable_now();ge=U;var B=!0;try{B=Q(!0,U)}finally{B?te():(_=!1,Q=null)}}else _=!1}var te;if(typeof R=="function")te=function(){R(be)};else if(typeof MessageChannel<"u"){var P=new MessageChannel,Y=P.port2;P.port1.onmessage=be,te=function(){Y.postMessage(null)}}else te=function(){E(be,0)};function ae(U){Q=U,_||(_=!0,te())}function Z(U,B){oe=E(function(){U(e.unstable_now())},B)}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(U){U.callback=null},e.unstable_continueExecution=function(){T||j||(T=!0,ae(se))},e.unstable_forceFrameRate=function(U){0>U||125<U?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):G=0<U?Math.floor(1e3/U):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_getFirstCallbackNode=function(){return r(g)},e.unstable_next=function(U){switch(x){case 1:case 2:case 3:var B=3;break;default:B=x}var H=x;x=B;try{return U()}finally{x=H}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(U,B){switch(U){case 1:case 2:case 3:case 4:case 5:break;default:U=3}var H=x;x=U;try{return B()}finally{x=H}},e.unstable_scheduleCallback=function(U,B,H){var $=e.unstable_now();switch(typeof H=="object"&&H!==null?(H=H.delay,H=typeof H=="number"&&0<H?$+H:$):H=$,U){case 1:var D=-1;break;case 2:D=250;break;case 5:D=1073741823;break;case 4:D=1e4;break;default:D=5e3}return D=H+D,U={id:v++,callback:B,priorityLevel:U,startTime:H,expirationTime:D,sortIndex:-1},H>$?(U.sortIndex=H,t(m,U),r(g)===null&&U===r(m)&&(S?(M(oe),oe=-1):S=!0,Z(X,H-$))):(U.sortIndex=D,t(g,U),T||j||(T=!0,ae(se))),U},e.unstable_shouldYield=Re,e.unstable_wrapCallback=function(U){var B=x;return function(){var H=x;x=B;try{return U.apply(this,arguments)}finally{x=H}}}})(Bl)),Bl}var Oh;function Av(){return Oh||(Oh=1,Dl.exports=Mv()),Dl.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 Ph;function Lv(){if(Ph)return kt;Ph=1;var e=uc(),t=Av();function r(n){for(var s="https://reactjs.org/docs/error-decoder.html?invariant="+n,a=1;a<arguments.length;a++)s+="&args[]="+encodeURIComponent(arguments[a]);return"Minified React error #"+n+"; 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(n,s){d(n,s),d(n+"Capture",s)}function d(n,s){for(l[n]=s,n=0;n<s.length;n++)o.add(s[n])}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]*$/,v={},w={};function x(n){return g.call(w,n)?!0:g.call(v,n)?!1:m.test(n)?w[n]=!0:(v[n]=!0,!1)}function j(n,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:(n=n.toLowerCase().slice(0,5),n!=="data-"&&n!=="aria-");default:return!1}}function T(n,s,a,u){if(s===null||typeof s>"u"||j(n,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 S(n,s,a,u,f,p,y){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=u,this.attributeNamespace=f,this.mustUseProperty=a,this.propertyName=n,this.type=s,this.sanitizeURL=p,this.removeEmptyString=y}var E={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(n){E[n]=new S(n,0,!1,n,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(n){var s=n[0];E[s]=new S(s,1,!1,n[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(n){E[n]=new S(n,2,!1,n.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(n){E[n]=new S(n,2,!1,n,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(n){E[n]=new S(n,3,!1,n.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(n){E[n]=new S(n,3,!0,n,null,!1,!1)}),["capture","download"].forEach(function(n){E[n]=new S(n,4,!1,n,null,!1,!1)}),["cols","rows","size","span"].forEach(function(n){E[n]=new S(n,6,!1,n,null,!1,!1)}),["rowSpan","start"].forEach(function(n){E[n]=new S(n,5,!1,n.toLowerCase(),null,!1,!1)});var M=/[\-:]([a-z])/g;function R(n){return n[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(n){var s=n.replace(M,R);E[s]=new S(s,1,!1,n,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(n){var s=n.replace(M,R);E[s]=new S(s,1,!1,n,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(n){var s=n.replace(M,R);E[s]=new S(s,1,!1,n,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(n){E[n]=new S(n,1,!1,n.toLowerCase(),null,!1,!1)}),E.xlinkHref=new S("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(n){E[n]=new S(n,1,!1,n.toLowerCase(),null,!0,!0)});function O(n,s,a,u){var f=E.hasOwnProperty(s)?E[s]:null;(f!==null?f.type!==0:u||!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(T(s,a,f,u)&&(a=null),u||f===null?x(s)&&(a===null?n.removeAttribute(s):n.setAttribute(s,""+a)):f.mustUseProperty?n[f.propertyName]=a===null?f.type===3?!1:"":a:(s=f.attributeName,u=f.attributeNamespace,a===null?n.removeAttribute(s):(f=f.type,a=f===3||f===4&&a===!0?"":""+a,u?n.setAttributeNS(u,s,a):n.setAttribute(s,a))))}var X=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,se=Symbol.for("react.element"),_=Symbol.for("react.portal"),Q=Symbol.for("react.fragment"),oe=Symbol.for("react.strict_mode"),G=Symbol.for("react.profiler"),ge=Symbol.for("react.provider"),Re=Symbol.for("react.context"),be=Symbol.for("react.forward_ref"),te=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),Y=Symbol.for("react.memo"),ae=Symbol.for("react.lazy"),Z=Symbol.for("react.offscreen"),U=Symbol.iterator;function B(n){return n===null||typeof n!="object"?null:(n=U&&n[U]||n["@@iterator"],typeof n=="function"?n:null)}var H=Object.assign,$;function D(n){if($===void 0)try{throw Error()}catch(a){var s=a.stack.trim().match(/\n( *(at )?)/);$=s&&s[1]||""}return`
|
|
34
|
+
`+$+n}var fe=!1;function pe(n,s){if(!n||fe)return"";fe=!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(n,[],s)}else{try{s.call()}catch(L){u=L}n.call(s.prototype)}else{try{throw Error()}catch(L){u=L}n()}}catch(L){if(L&&u&&typeof L.stack=="string"){for(var f=L.stack.split(`
|
|
35
|
+
`),p=u.stack.split(`
|
|
36
|
+
`),y=f.length-1,N=p.length-1;1<=y&&0<=N&&f[y]!==p[N];)N--;for(;1<=y&&0<=N;y--,N--)if(f[y]!==p[N]){if(y!==1||N!==1)do if(y--,N--,0>N||f[y]!==p[N]){var b=`
|
|
37
|
+
`+f[y].replace(" at new "," at ");return n.displayName&&b.includes("<anonymous>")&&(b=b.replace("<anonymous>",n.displayName)),b}while(1<=y&&0<=N);break}}}finally{fe=!1,Error.prepareStackTrace=a}return(n=n?n.displayName||n.name:"")?D(n):""}function de(n){switch(n.tag){case 5:return D(n.type);case 16:return D("Lazy");case 13:return D("Suspense");case 19:return D("SuspenseList");case 0:case 2:case 15:return n=pe(n.type,!1),n;case 11:return n=pe(n.type.render,!1),n;case 1:return n=pe(n.type,!0),n;default:return""}}function xe(n){if(n==null)return null;if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case Q:return"Fragment";case _:return"Portal";case G:return"Profiler";case oe:return"StrictMode";case te:return"Suspense";case P:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case Re:return(n.displayName||"Context")+".Consumer";case ge:return(n._context.displayName||"Context")+".Provider";case be:var s=n.render;return n=n.displayName,n||(n=s.displayName||s.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case Y:return s=n.displayName||null,s!==null?s:xe(n.type)||"Memo";case ae:s=n._payload,n=n._init;try{return xe(n(s))}catch{}}return null}function me(n){var s=n.type;switch(n.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 n=s.render,n=n.displayName||n.name||"",s.displayName||(n!==""?"ForwardRef("+n+")":"ForwardRef");case 7:return"Fragment";case 5:return s;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return xe(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 ye(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function $e(n){var s=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function ct(n){var s=$e(n)?"checked":"value",a=Object.getOwnPropertyDescriptor(n.constructor.prototype,s),u=""+n[s];if(!n.hasOwnProperty(s)&&typeof a<"u"&&typeof a.get=="function"&&typeof a.set=="function"){var f=a.get,p=a.set;return Object.defineProperty(n,s,{configurable:!0,get:function(){return f.call(this)},set:function(y){u=""+y,p.call(this,y)}}),Object.defineProperty(n,s,{enumerable:a.enumerable}),{getValue:function(){return u},setValue:function(y){u=""+y},stopTracking:function(){n._valueTracker=null,delete n[s]}}}}function ss(n){n._valueTracker||(n._valueTracker=ct(n))}function Pc(n){if(!n)return!1;var s=n._valueTracker;if(!s)return!0;var a=s.getValue(),u="";return n&&(u=$e(n)?n.checked?"true":"false":n.value),n=u,n!==a?(s.setValue(n),!0):!1}function Gi(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}function Uo(n,s){var a=s.checked;return H({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:a??n._wrapperState.initialChecked})}function _c(n,s){var a=s.defaultValue==null?"":s.defaultValue,u=s.checked!=null?s.checked:s.defaultChecked;a=ye(s.value!=null?s.value:a),n._wrapperState={initialChecked:u,initialValue:a,controlled:s.type==="checkbox"||s.type==="radio"?s.checked!=null:s.value!=null}}function Dc(n,s){s=s.checked,s!=null&&O(n,"checked",s,!1)}function Ho(n,s){Dc(n,s);var a=ye(s.value),u=s.type;if(a!=null)u==="number"?(a===0&&n.value===""||n.value!=a)&&(n.value=""+a):n.value!==""+a&&(n.value=""+a);else if(u==="submit"||u==="reset"){n.removeAttribute("value");return}s.hasOwnProperty("value")?Wo(n,s.type,a):s.hasOwnProperty("defaultValue")&&Wo(n,s.type,ye(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(n.defaultChecked=!!s.defaultChecked)}function Bc(n,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=""+n._wrapperState.initialValue,a||s===n.value||(n.value=s),n.defaultValue=s}a=n.name,a!==""&&(n.name=""),n.defaultChecked=!!n._wrapperState.initialChecked,a!==""&&(n.name=a)}function Wo(n,s,a){(s!=="number"||Gi(n.ownerDocument)!==n)&&(a==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+a&&(n.defaultValue=""+a))}var Vs=Array.isArray;function is(n,s,a,u){if(n=n.options,s){s={};for(var f=0;f<a.length;f++)s["$"+a[f]]=!0;for(a=0;a<n.length;a++)f=s.hasOwnProperty("$"+n[a].value),n[a].selected!==f&&(n[a].selected=f),f&&u&&(n[a].defaultSelected=!0)}else{for(a=""+ye(a),s=null,f=0;f<n.length;f++){if(n[f].value===a){n[f].selected=!0,u&&(n[f].defaultSelected=!0);return}s!==null||n[f].disabled||(s=n[f])}s!==null&&(s.selected=!0)}}function Ko(n,s){if(s.dangerouslySetInnerHTML!=null)throw Error(r(91));return H({},s,{value:void 0,defaultValue:void 0,children:""+n._wrapperState.initialValue})}function zc(n,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(Vs(a)){if(1<a.length)throw Error(r(93));a=a[0]}s=a}s==null&&(s=""),a=s}n._wrapperState={initialValue:ye(a)}}function Fc(n,s){var a=ye(s.value),u=ye(s.defaultValue);a!=null&&(a=""+a,a!==n.value&&(n.value=a),s.defaultValue==null&&n.defaultValue!==a&&(n.defaultValue=a)),u!=null&&(n.defaultValue=""+u)}function Uc(n){var s=n.textContent;s===n._wrapperState.initialValue&&s!==""&&s!==null&&(n.value=s)}function Hc(n){switch(n){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Vo(n,s){return n==null||n==="http://www.w3.org/1999/xhtml"?Hc(s):n==="http://www.w3.org/2000/svg"&&s==="foreignObject"?"http://www.w3.org/1999/xhtml":n}var qi,Wc=(function(n){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(s,a,u,f){MSApp.execUnsafeLocalFunction(function(){return n(s,a,u,f)})}:n})(function(n,s){if(n.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in n)n.innerHTML=s;else{for(qi=qi||document.createElement("div"),qi.innerHTML="<svg>"+s.valueOf().toString()+"</svg>",s=qi.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;s.firstChild;)n.appendChild(s.firstChild)}});function Gs(n,s){if(s){var a=n.firstChild;if(a&&a===n.lastChild&&a.nodeType===3){a.nodeValue=s;return}}n.textContent=s}var qs={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},Ip=["Webkit","ms","Moz","O"];Object.keys(qs).forEach(function(n){Ip.forEach(function(s){s=s+n.charAt(0).toUpperCase()+n.substring(1),qs[s]=qs[n]})});function Kc(n,s,a){return s==null||typeof s=="boolean"||s===""?"":a||typeof s!="number"||s===0||qs.hasOwnProperty(n)&&qs[n]?(""+s).trim():s+"px"}function Vc(n,s){n=n.style;for(var a in s)if(s.hasOwnProperty(a)){var u=a.indexOf("--")===0,f=Kc(a,s[a],u);a==="float"&&(a="cssFloat"),u?n.setProperty(a,f):n[a]=f}}var Mp=H({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 Go(n,s){if(s){if(Mp[n]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(r(137,n));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 qo(n,s){if(n.indexOf("-")===-1)return typeof s.is=="string";switch(n){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Qo=null;function Yo(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var Jo=null,rs=null,os=null;function Gc(n){if(n=gi(n)){if(typeof Jo!="function")throw Error(r(280));var s=n.stateNode;s&&(s=vr(s),Jo(n.stateNode,n.type,s))}}function qc(n){rs?os?os.push(n):os=[n]:rs=n}function Qc(){if(rs){var n=rs,s=os;if(os=rs=null,Gc(n),s)for(n=0;n<s.length;n++)Gc(s[n])}}function Yc(n,s){return n(s)}function Jc(){}var Xo=!1;function Xc(n,s,a){if(Xo)return n(s,a);Xo=!0;try{return Yc(n,s,a)}finally{Xo=!1,(rs!==null||os!==null)&&(Jc(),Qc())}}function Qs(n,s){var a=n.stateNode;if(a===null)return null;var u=vr(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)||(n=n.type,u=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!u;break e;default:n=!1}if(n)return null;if(a&&typeof a!="function")throw Error(r(231,s,typeof a));return a}var Zo=!1;if(h)try{var Ys={};Object.defineProperty(Ys,"passive",{get:function(){Zo=!0}}),window.addEventListener("test",Ys,Ys),window.removeEventListener("test",Ys,Ys)}catch{Zo=!1}function Ap(n,s,a,u,f,p,y,N,b){var L=Array.prototype.slice.call(arguments,3);try{s.apply(a,L)}catch(F){this.onError(F)}}var Js=!1,Qi=null,Yi=!1,ea=null,Lp={onError:function(n){Js=!0,Qi=n}};function Rp(n,s,a,u,f,p,y,N,b){Js=!1,Qi=null,Ap.apply(Lp,arguments)}function Op(n,s,a,u,f,p,y,N,b){if(Rp.apply(this,arguments),Js){if(Js){var L=Qi;Js=!1,Qi=null}else throw Error(r(198));Yi||(Yi=!0,ea=L)}}function Fn(n){var s=n,a=n;if(n.alternate)for(;s.return;)s=s.return;else{n=s;do s=n,(s.flags&4098)!==0&&(a=s.return),n=s.return;while(n)}return s.tag===3?a:null}function Zc(n){if(n.tag===13){var s=n.memoizedState;if(s===null&&(n=n.alternate,n!==null&&(s=n.memoizedState)),s!==null)return s.dehydrated}return null}function eu(n){if(Fn(n)!==n)throw Error(r(188))}function Pp(n){var s=n.alternate;if(!s){if(s=Fn(n),s===null)throw Error(r(188));return s!==n?null:n}for(var a=n,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 eu(f),n;if(p===u)return eu(f),s;p=p.sibling}throw Error(r(188))}if(a.return!==u.return)a=f,u=p;else{for(var y=!1,N=f.child;N;){if(N===a){y=!0,a=f,u=p;break}if(N===u){y=!0,u=f,a=p;break}N=N.sibling}if(!y){for(N=p.child;N;){if(N===a){y=!0,a=p,u=f;break}if(N===u){y=!0,u=p,a=f;break}N=N.sibling}if(!y)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?n:s}function tu(n){return n=Pp(n),n!==null?nu(n):null}function nu(n){if(n.tag===5||n.tag===6)return n;for(n=n.child;n!==null;){var s=nu(n);if(s!==null)return s;n=n.sibling}return null}var su=t.unstable_scheduleCallback,iu=t.unstable_cancelCallback,_p=t.unstable_shouldYield,Dp=t.unstable_requestPaint,ze=t.unstable_now,Bp=t.unstable_getCurrentPriorityLevel,ta=t.unstable_ImmediatePriority,ru=t.unstable_UserBlockingPriority,Ji=t.unstable_NormalPriority,zp=t.unstable_LowPriority,ou=t.unstable_IdlePriority,Xi=null,Kt=null;function Fp(n){if(Kt&&typeof Kt.onCommitFiberRoot=="function")try{Kt.onCommitFiberRoot(Xi,n,void 0,(n.current.flags&128)===128)}catch{}}var Pt=Math.clz32?Math.clz32:Wp,Up=Math.log,Hp=Math.LN2;function Wp(n){return n>>>=0,n===0?32:31-(Up(n)/Hp|0)|0}var Zi=64,er=4194304;function Xs(n){switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return n&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return n}}function tr(n,s){var a=n.pendingLanes;if(a===0)return 0;var u=0,f=n.suspendedLanes,p=n.pingedLanes,y=a&268435455;if(y!==0){var N=y&~f;N!==0?u=Xs(N):(p&=y,p!==0&&(u=Xs(p)))}else y=a&~f,y!==0?u=Xs(y):p!==0&&(u=Xs(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=n.entangledLanes,s!==0)for(n=n.entanglements,s&=u;0<s;)a=31-Pt(s),f=1<<a,u|=n[a],s&=~f;return u}function Kp(n,s){switch(n){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 Vp(n,s){for(var a=n.suspendedLanes,u=n.pingedLanes,f=n.expirationTimes,p=n.pendingLanes;0<p;){var y=31-Pt(p),N=1<<y,b=f[y];b===-1?((N&a)===0||(N&u)!==0)&&(f[y]=Kp(N,s)):b<=s&&(n.expiredLanes|=N),p&=~N}}function na(n){return n=n.pendingLanes&-1073741825,n!==0?n:n&1073741824?1073741824:0}function au(){var n=Zi;return Zi<<=1,(Zi&4194240)===0&&(Zi=64),n}function sa(n){for(var s=[],a=0;31>a;a++)s.push(n);return s}function Zs(n,s,a){n.pendingLanes|=s,s!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,s=31-Pt(s),n[s]=a}function Gp(n,s){var a=n.pendingLanes&~s;n.pendingLanes=s,n.suspendedLanes=0,n.pingedLanes=0,n.expiredLanes&=s,n.mutableReadLanes&=s,n.entangledLanes&=s,s=n.entanglements;var u=n.eventTimes;for(n=n.expirationTimes;0<a;){var f=31-Pt(a),p=1<<f;s[f]=0,u[f]=-1,n[f]=-1,a&=~p}}function ia(n,s){var a=n.entangledLanes|=s;for(n=n.entanglements;a;){var u=31-Pt(a),f=1<<u;f&s|n[u]&s&&(n[u]|=s),a&=~f}}var Ce=0;function lu(n){return n&=-n,1<n?4<n?(n&268435455)!==0?16:536870912:4:1}var cu,ra,uu,du,hu,oa=!1,nr=[],vn=null,yn=null,kn=null,ei=new Map,ti=new Map,wn=[],qp="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 fu(n,s){switch(n){case"focusin":case"focusout":vn=null;break;case"dragenter":case"dragleave":yn=null;break;case"mouseover":case"mouseout":kn=null;break;case"pointerover":case"pointerout":ei.delete(s.pointerId);break;case"gotpointercapture":case"lostpointercapture":ti.delete(s.pointerId)}}function ni(n,s,a,u,f,p){return n===null||n.nativeEvent!==p?(n={blockedOn:s,domEventName:a,eventSystemFlags:u,nativeEvent:p,targetContainers:[f]},s!==null&&(s=gi(s),s!==null&&ra(s)),n):(n.eventSystemFlags|=u,s=n.targetContainers,f!==null&&s.indexOf(f)===-1&&s.push(f),n)}function Qp(n,s,a,u,f){switch(s){case"focusin":return vn=ni(vn,n,s,a,u,f),!0;case"dragenter":return yn=ni(yn,n,s,a,u,f),!0;case"mouseover":return kn=ni(kn,n,s,a,u,f),!0;case"pointerover":var p=f.pointerId;return ei.set(p,ni(ei.get(p)||null,n,s,a,u,f)),!0;case"gotpointercapture":return p=f.pointerId,ti.set(p,ni(ti.get(p)||null,n,s,a,u,f)),!0}return!1}function mu(n){var s=Un(n.target);if(s!==null){var a=Fn(s);if(a!==null){if(s=a.tag,s===13){if(s=Zc(a),s!==null){n.blockedOn=s,hu(n.priority,function(){uu(a)});return}}else if(s===3&&a.stateNode.current.memoizedState.isDehydrated){n.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}n.blockedOn=null}function sr(n){if(n.blockedOn!==null)return!1;for(var s=n.targetContainers;0<s.length;){var a=la(n.domEventName,n.eventSystemFlags,s[0],n.nativeEvent);if(a===null){a=n.nativeEvent;var u=new a.constructor(a.type,a);Qo=u,a.target.dispatchEvent(u),Qo=null}else return s=gi(a),s!==null&&ra(s),n.blockedOn=a,!1;s.shift()}return!0}function pu(n,s,a){sr(n)&&a.delete(s)}function Yp(){oa=!1,vn!==null&&sr(vn)&&(vn=null),yn!==null&&sr(yn)&&(yn=null),kn!==null&&sr(kn)&&(kn=null),ei.forEach(pu),ti.forEach(pu)}function si(n,s){n.blockedOn===s&&(n.blockedOn=null,oa||(oa=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Yp)))}function ii(n){function s(f){return si(f,n)}if(0<nr.length){si(nr[0],n);for(var a=1;a<nr.length;a++){var u=nr[a];u.blockedOn===n&&(u.blockedOn=null)}}for(vn!==null&&si(vn,n),yn!==null&&si(yn,n),kn!==null&&si(kn,n),ei.forEach(s),ti.forEach(s),a=0;a<wn.length;a++)u=wn[a],u.blockedOn===n&&(u.blockedOn=null);for(;0<wn.length&&(a=wn[0],a.blockedOn===null);)mu(a),a.blockedOn===null&&wn.shift()}var as=X.ReactCurrentBatchConfig,ir=!0;function Jp(n,s,a,u){var f=Ce,p=as.transition;as.transition=null;try{Ce=1,aa(n,s,a,u)}finally{Ce=f,as.transition=p}}function Xp(n,s,a,u){var f=Ce,p=as.transition;as.transition=null;try{Ce=4,aa(n,s,a,u)}finally{Ce=f,as.transition=p}}function aa(n,s,a,u){if(ir){var f=la(n,s,a,u);if(f===null)ba(n,s,u,rr,a),fu(n,u);else if(Qp(f,n,s,a,u))u.stopPropagation();else if(fu(n,u),s&4&&-1<qp.indexOf(n)){for(;f!==null;){var p=gi(f);if(p!==null&&cu(p),p=la(n,s,a,u),p===null&&ba(n,s,u,rr,a),p===f)break;f=p}f!==null&&u.stopPropagation()}else ba(n,s,u,null,a)}}var rr=null;function la(n,s,a,u){if(rr=null,n=Yo(u),n=Un(n),n!==null)if(s=Fn(n),s===null)n=null;else if(a=s.tag,a===13){if(n=Zc(s),n!==null)return n;n=null}else if(a===3){if(s.stateNode.current.memoizedState.isDehydrated)return s.tag===3?s.stateNode.containerInfo:null;n=null}else s!==n&&(n=null);return rr=n,null}function gu(n){switch(n){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Bp()){case ta:return 1;case ru:return 4;case Ji:case zp:return 16;case ou:return 536870912;default:return 16}default:return 16}}var xn=null,ca=null,or=null;function vu(){if(or)return or;var n,s=ca,a=s.length,u,f="value"in xn?xn.value:xn.textContent,p=f.length;for(n=0;n<a&&s[n]===f[n];n++);var y=a-n;for(u=1;u<=y&&s[a-u]===f[p-u];u++);return or=f.slice(n,1<u?1-u:void 0)}function ar(n){var s=n.keyCode;return"charCode"in n?(n=n.charCode,n===0&&s===13&&(n=13)):n=s,n===10&&(n=13),32<=n||n===13?n:0}function lr(){return!0}function yu(){return!1}function jt(n){function s(a,u,f,p,y){this._reactName=a,this._targetInst=f,this.type=u,this.nativeEvent=p,this.target=y,this.currentTarget=null;for(var N in n)n.hasOwnProperty(N)&&(a=n[N],this[N]=a?a(p):p[N]);return this.isDefaultPrevented=(p.defaultPrevented!=null?p.defaultPrevented:p.returnValue===!1)?lr:yu,this.isPropagationStopped=yu,this}return H(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=lr)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=lr)},persist:function(){},isPersistent:lr}),s}var ls={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ua=jt(ls),ri=H({},ls,{view:0,detail:0}),Zp=jt(ri),da,ha,oi,cr=H({},ri,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ma,button:0,buttons:0,relatedTarget:function(n){return n.relatedTarget===void 0?n.fromElement===n.srcElement?n.toElement:n.fromElement:n.relatedTarget},movementX:function(n){return"movementX"in n?n.movementX:(n!==oi&&(oi&&n.type==="mousemove"?(da=n.screenX-oi.screenX,ha=n.screenY-oi.screenY):ha=da=0,oi=n),da)},movementY:function(n){return"movementY"in n?n.movementY:ha}}),ku=jt(cr),eg=H({},cr,{dataTransfer:0}),tg=jt(eg),ng=H({},ri,{relatedTarget:0}),fa=jt(ng),sg=H({},ls,{animationName:0,elapsedTime:0,pseudoElement:0}),ig=jt(sg),rg=H({},ls,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),og=jt(rg),ag=H({},ls,{data:0}),wu=jt(ag),lg={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},cg={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"},ug={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function dg(n){var s=this.nativeEvent;return s.getModifierState?s.getModifierState(n):(n=ug[n])?!!s[n]:!1}function ma(){return dg}var hg=H({},ri,{key:function(n){if(n.key){var s=lg[n.key]||n.key;if(s!=="Unidentified")return s}return n.type==="keypress"?(n=ar(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?cg[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ma,charCode:function(n){return n.type==="keypress"?ar(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?ar(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),fg=jt(hg),mg=H({},cr,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),xu=jt(mg),pg=H({},ri,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ma}),gg=jt(pg),vg=H({},ls,{propertyName:0,elapsedTime:0,pseudoElement:0}),yg=jt(vg),kg=H({},cr,{deltaX:function(n){return"deltaX"in n?n.deltaX:"wheelDeltaX"in n?-n.wheelDeltaX:0},deltaY:function(n){return"deltaY"in n?n.deltaY:"wheelDeltaY"in n?-n.wheelDeltaY:"wheelDelta"in n?-n.wheelDelta:0},deltaZ:0,deltaMode:0}),wg=jt(kg),xg=[9,13,27,32],pa=h&&"CompositionEvent"in window,ai=null;h&&"documentMode"in document&&(ai=document.documentMode);var jg=h&&"TextEvent"in window&&!ai,ju=h&&(!pa||ai&&8<ai&&11>=ai),Su=" ",Nu=!1;function bu(n,s){switch(n){case"keyup":return xg.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Cu(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var cs=!1;function Sg(n,s){switch(n){case"compositionend":return Cu(s);case"keypress":return s.which!==32?null:(Nu=!0,Su);case"textInput":return n=s.data,n===Su&&Nu?null:n;default:return null}}function Ng(n,s){if(cs)return n==="compositionend"||!pa&&bu(n,s)?(n=vu(),or=ca=xn=null,cs=!1,n):null;switch(n){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 ju&&s.locale!=="ko"?null:s.data;default:return null}}var bg={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 $u(n){var s=n&&n.nodeName&&n.nodeName.toLowerCase();return s==="input"?!!bg[n.type]:s==="textarea"}function Tu(n,s,a,u){qc(u),s=mr(s,"onChange"),0<s.length&&(a=new ua("onChange","change",null,a,u),n.push({event:a,listeners:s}))}var li=null,ci=null;function Cg(n){Vu(n,0)}function ur(n){var s=ms(n);if(Pc(s))return n}function $g(n,s){if(n==="change")return s}var Eu=!1;if(h){var ga;if(h){var va="oninput"in document;if(!va){var Iu=document.createElement("div");Iu.setAttribute("oninput","return;"),va=typeof Iu.oninput=="function"}ga=va}else ga=!1;Eu=ga&&(!document.documentMode||9<document.documentMode)}function Mu(){li&&(li.detachEvent("onpropertychange",Au),ci=li=null)}function Au(n){if(n.propertyName==="value"&&ur(ci)){var s=[];Tu(s,ci,n,Yo(n)),Xc(Cg,s)}}function Tg(n,s,a){n==="focusin"?(Mu(),li=s,ci=a,li.attachEvent("onpropertychange",Au)):n==="focusout"&&Mu()}function Eg(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return ur(ci)}function Ig(n,s){if(n==="click")return ur(s)}function Mg(n,s){if(n==="input"||n==="change")return ur(s)}function Ag(n,s){return n===s&&(n!==0||1/n===1/s)||n!==n&&s!==s}var _t=typeof Object.is=="function"?Object.is:Ag;function ui(n,s){if(_t(n,s))return!0;if(typeof n!="object"||n===null||typeof s!="object"||s===null)return!1;var a=Object.keys(n),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)||!_t(n[f],s[f]))return!1}return!0}function Lu(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function Ru(n,s){var a=Lu(n);n=0;for(var u;a;){if(a.nodeType===3){if(u=n+a.textContent.length,n<=s&&u>=s)return{node:a,offset:s-n};n=u}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Lu(a)}}function Ou(n,s){return n&&s?n===s?!0:n&&n.nodeType===3?!1:s&&s.nodeType===3?Ou(n,s.parentNode):"contains"in n?n.contains(s):n.compareDocumentPosition?!!(n.compareDocumentPosition(s)&16):!1:!1}function Pu(){for(var n=window,s=Gi();s instanceof n.HTMLIFrameElement;){try{var a=typeof s.contentWindow.location.href=="string"}catch{a=!1}if(a)n=s.contentWindow;else break;s=Gi(n.document)}return s}function ya(n){var s=n&&n.nodeName&&n.nodeName.toLowerCase();return s&&(s==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||s==="textarea"||n.contentEditable==="true")}function Lg(n){var s=Pu(),a=n.focusedElem,u=n.selectionRange;if(s!==a&&a&&a.ownerDocument&&Ou(a.ownerDocument.documentElement,a)){if(u!==null&&ya(a)){if(s=u.start,n=u.end,n===void 0&&(n=s),"selectionStart"in a)a.selectionStart=s,a.selectionEnd=Math.min(n,a.value.length);else if(n=(s=a.ownerDocument||document)&&s.defaultView||window,n.getSelection){n=n.getSelection();var f=a.textContent.length,p=Math.min(u.start,f);u=u.end===void 0?p:Math.min(u.end,f),!n.extend&&p>u&&(f=u,u=p,p=f),f=Ru(a,p);var y=Ru(a,u);f&&y&&(n.rangeCount!==1||n.anchorNode!==f.node||n.anchorOffset!==f.offset||n.focusNode!==y.node||n.focusOffset!==y.offset)&&(s=s.createRange(),s.setStart(f.node,f.offset),n.removeAllRanges(),p>u?(n.addRange(s),n.extend(y.node,y.offset)):(s.setEnd(y.node,y.offset),n.addRange(s)))}}for(s=[],n=a;n=n.parentNode;)n.nodeType===1&&s.push({element:n,left:n.scrollLeft,top:n.scrollTop});for(typeof a.focus=="function"&&a.focus(),a=0;a<s.length;a++)n=s[a],n.element.scrollLeft=n.left,n.element.scrollTop=n.top}}var Rg=h&&"documentMode"in document&&11>=document.documentMode,us=null,ka=null,di=null,wa=!1;function _u(n,s,a){var u=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;wa||us==null||us!==Gi(u)||(u=us,"selectionStart"in u&&ya(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}),di&&ui(di,u)||(di=u,u=mr(ka,"onSelect"),0<u.length&&(s=new ua("onSelect","select",null,s,a),n.push({event:s,listeners:u}),s.target=us)))}function dr(n,s){var a={};return a[n.toLowerCase()]=s.toLowerCase(),a["Webkit"+n]="webkit"+s,a["Moz"+n]="moz"+s,a}var ds={animationend:dr("Animation","AnimationEnd"),animationiteration:dr("Animation","AnimationIteration"),animationstart:dr("Animation","AnimationStart"),transitionend:dr("Transition","TransitionEnd")},xa={},Du={};h&&(Du=document.createElement("div").style,"AnimationEvent"in window||(delete ds.animationend.animation,delete ds.animationiteration.animation,delete ds.animationstart.animation),"TransitionEvent"in window||delete ds.transitionend.transition);function hr(n){if(xa[n])return xa[n];if(!ds[n])return n;var s=ds[n],a;for(a in s)if(s.hasOwnProperty(a)&&a in Du)return xa[n]=s[a];return n}var Bu=hr("animationend"),zu=hr("animationiteration"),Fu=hr("animationstart"),Uu=hr("transitionend"),Hu=new Map,Wu="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 jn(n,s){Hu.set(n,s),c(s,[n])}for(var ja=0;ja<Wu.length;ja++){var Sa=Wu[ja],Og=Sa.toLowerCase(),Pg=Sa[0].toUpperCase()+Sa.slice(1);jn(Og,"on"+Pg)}jn(Bu,"onAnimationEnd"),jn(zu,"onAnimationIteration"),jn(Fu,"onAnimationStart"),jn("dblclick","onDoubleClick"),jn("focusin","onFocus"),jn("focusout","onBlur"),jn(Uu,"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 hi="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(" "),_g=new Set("cancel close invalid load scroll toggle".split(" ").concat(hi));function Ku(n,s,a){var u=n.type||"unknown-event";n.currentTarget=a,Op(u,s,void 0,n),n.currentTarget=null}function Vu(n,s){s=(s&4)!==0;for(var a=0;a<n.length;a++){var u=n[a],f=u.event;u=u.listeners;e:{var p=void 0;if(s)for(var y=u.length-1;0<=y;y--){var N=u[y],b=N.instance,L=N.currentTarget;if(N=N.listener,b!==p&&f.isPropagationStopped())break e;Ku(f,N,L),p=b}else for(y=0;y<u.length;y++){if(N=u[y],b=N.instance,L=N.currentTarget,N=N.listener,b!==p&&f.isPropagationStopped())break e;Ku(f,N,L),p=b}}}if(Yi)throw n=ea,Yi=!1,ea=null,n}function Ie(n,s){var a=s[Ma];a===void 0&&(a=s[Ma]=new Set);var u=n+"__bubble";a.has(u)||(Gu(s,n,2,!1),a.add(u))}function Na(n,s,a){var u=0;s&&(u|=4),Gu(a,n,u,s)}var fr="_reactListening"+Math.random().toString(36).slice(2);function fi(n){if(!n[fr]){n[fr]=!0,o.forEach(function(a){a!=="selectionchange"&&(_g.has(a)||Na(a,!1,n),Na(a,!0,n))});var s=n.nodeType===9?n:n.ownerDocument;s===null||s[fr]||(s[fr]=!0,Na("selectionchange",!1,s))}}function Gu(n,s,a,u){switch(gu(s)){case 1:var f=Jp;break;case 4:f=Xp;break;default:f=aa}a=f.bind(null,s,a,n),f=void 0,!Zo||s!=="touchstart"&&s!=="touchmove"&&s!=="wheel"||(f=!0),u?f!==void 0?n.addEventListener(s,a,{capture:!0,passive:f}):n.addEventListener(s,a,!0):f!==void 0?n.addEventListener(s,a,{passive:f}):n.addEventListener(s,a,!1)}function ba(n,s,a,u,f){var p=u;if((s&1)===0&&(s&2)===0&&u!==null)e:for(;;){if(u===null)return;var y=u.tag;if(y===3||y===4){var N=u.stateNode.containerInfo;if(N===f||N.nodeType===8&&N.parentNode===f)break;if(y===4)for(y=u.return;y!==null;){var b=y.tag;if((b===3||b===4)&&(b=y.stateNode.containerInfo,b===f||b.nodeType===8&&b.parentNode===f))return;y=y.return}for(;N!==null;){if(y=Un(N),y===null)return;if(b=y.tag,b===5||b===6){u=p=y;continue e}N=N.parentNode}}u=u.return}Xc(function(){var L=p,F=Yo(a),W=[];e:{var z=Hu.get(n);if(z!==void 0){var J=ua,ne=n;switch(n){case"keypress":if(ar(a)===0)break e;case"keydown":case"keyup":J=fg;break;case"focusin":ne="focus",J=fa;break;case"focusout":ne="blur",J=fa;break;case"beforeblur":case"afterblur":J=fa;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":J=ku;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":J=tg;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":J=gg;break;case Bu:case zu:case Fu:J=ig;break;case Uu:J=yg;break;case"scroll":J=Zp;break;case"wheel":J=wg;break;case"copy":case"cut":case"paste":J=og;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":J=xu}var ie=(s&4)!==0,Fe=!ie&&n==="scroll",I=ie?z!==null?z+"Capture":null:z;ie=[];for(var C=L,A;C!==null;){A=C;var V=A.stateNode;if(A.tag===5&&V!==null&&(A=V,I!==null&&(V=Qs(C,I),V!=null&&ie.push(mi(C,V,A)))),Fe)break;C=C.return}0<ie.length&&(z=new J(z,ne,null,a,F),W.push({event:z,listeners:ie}))}}if((s&7)===0){e:{if(z=n==="mouseover"||n==="pointerover",J=n==="mouseout"||n==="pointerout",z&&a!==Qo&&(ne=a.relatedTarget||a.fromElement)&&(Un(ne)||ne[rn]))break e;if((J||z)&&(z=F.window===F?F:(z=F.ownerDocument)?z.defaultView||z.parentWindow:window,J?(ne=a.relatedTarget||a.toElement,J=L,ne=ne?Un(ne):null,ne!==null&&(Fe=Fn(ne),ne!==Fe||ne.tag!==5&&ne.tag!==6)&&(ne=null)):(J=null,ne=L),J!==ne)){if(ie=ku,V="onMouseLeave",I="onMouseEnter",C="mouse",(n==="pointerout"||n==="pointerover")&&(ie=xu,V="onPointerLeave",I="onPointerEnter",C="pointer"),Fe=J==null?z:ms(J),A=ne==null?z:ms(ne),z=new ie(V,C+"leave",J,a,F),z.target=Fe,z.relatedTarget=A,V=null,Un(F)===L&&(ie=new ie(I,C+"enter",ne,a,F),ie.target=A,ie.relatedTarget=Fe,V=ie),Fe=V,J&&ne)t:{for(ie=J,I=ne,C=0,A=ie;A;A=hs(A))C++;for(A=0,V=I;V;V=hs(V))A++;for(;0<C-A;)ie=hs(ie),C--;for(;0<A-C;)I=hs(I),A--;for(;C--;){if(ie===I||I!==null&&ie===I.alternate)break t;ie=hs(ie),I=hs(I)}ie=null}else ie=null;J!==null&&qu(W,z,J,ie,!1),ne!==null&&Fe!==null&&qu(W,Fe,ne,ie,!0)}}e:{if(z=L?ms(L):window,J=z.nodeName&&z.nodeName.toLowerCase(),J==="select"||J==="input"&&z.type==="file")var re=$g;else if($u(z))if(Eu)re=Mg;else{re=Eg;var le=Tg}else(J=z.nodeName)&&J.toLowerCase()==="input"&&(z.type==="checkbox"||z.type==="radio")&&(re=Ig);if(re&&(re=re(n,L))){Tu(W,re,a,F);break e}le&&le(n,z,L),n==="focusout"&&(le=z._wrapperState)&&le.controlled&&z.type==="number"&&Wo(z,"number",z.value)}switch(le=L?ms(L):window,n){case"focusin":($u(le)||le.contentEditable==="true")&&(us=le,ka=L,di=null);break;case"focusout":di=ka=us=null;break;case"mousedown":wa=!0;break;case"contextmenu":case"mouseup":case"dragend":wa=!1,_u(W,a,F);break;case"selectionchange":if(Rg)break;case"keydown":case"keyup":_u(W,a,F)}var ce;if(pa)e:{switch(n){case"compositionstart":var he="onCompositionStart";break e;case"compositionend":he="onCompositionEnd";break e;case"compositionupdate":he="onCompositionUpdate";break e}he=void 0}else cs?bu(n,a)&&(he="onCompositionEnd"):n==="keydown"&&a.keyCode===229&&(he="onCompositionStart");he&&(ju&&a.locale!=="ko"&&(cs||he!=="onCompositionStart"?he==="onCompositionEnd"&&cs&&(ce=vu()):(xn=F,ca="value"in xn?xn.value:xn.textContent,cs=!0)),le=mr(L,he),0<le.length&&(he=new wu(he,n,null,a,F),W.push({event:he,listeners:le}),ce?he.data=ce:(ce=Cu(a),ce!==null&&(he.data=ce)))),(ce=jg?Sg(n,a):Ng(n,a))&&(L=mr(L,"onBeforeInput"),0<L.length&&(F=new wu("onBeforeInput","beforeinput",null,a,F),W.push({event:F,listeners:L}),F.data=ce))}Vu(W,s)})}function mi(n,s,a){return{instance:n,listener:s,currentTarget:a}}function mr(n,s){for(var a=s+"Capture",u=[];n!==null;){var f=n,p=f.stateNode;f.tag===5&&p!==null&&(f=p,p=Qs(n,a),p!=null&&u.unshift(mi(n,p,f)),p=Qs(n,s),p!=null&&u.push(mi(n,p,f))),n=n.return}return u}function hs(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5);return n||null}function qu(n,s,a,u,f){for(var p=s._reactName,y=[];a!==null&&a!==u;){var N=a,b=N.alternate,L=N.stateNode;if(b!==null&&b===u)break;N.tag===5&&L!==null&&(N=L,f?(b=Qs(a,p),b!=null&&y.unshift(mi(a,b,N))):f||(b=Qs(a,p),b!=null&&y.push(mi(a,b,N)))),a=a.return}y.length!==0&&n.push({event:s,listeners:y})}var Dg=/\r\n?/g,Bg=/\u0000|\uFFFD/g;function Qu(n){return(typeof n=="string"?n:""+n).replace(Dg,`
|
|
38
|
+
`).replace(Bg,"")}function pr(n,s,a){if(s=Qu(s),Qu(n)!==s&&a)throw Error(r(425))}function gr(){}var Ca=null,$a=null;function Ta(n,s){return n==="textarea"||n==="noscript"||typeof s.children=="string"||typeof s.children=="number"||typeof s.dangerouslySetInnerHTML=="object"&&s.dangerouslySetInnerHTML!==null&&s.dangerouslySetInnerHTML.__html!=null}var Ea=typeof setTimeout=="function"?setTimeout:void 0,zg=typeof clearTimeout=="function"?clearTimeout:void 0,Yu=typeof Promise=="function"?Promise:void 0,Fg=typeof queueMicrotask=="function"?queueMicrotask:typeof Yu<"u"?function(n){return Yu.resolve(null).then(n).catch(Ug)}:Ea;function Ug(n){setTimeout(function(){throw n})}function Ia(n,s){var a=s,u=0;do{var f=a.nextSibling;if(n.removeChild(a),f&&f.nodeType===8)if(a=f.data,a==="/$"){if(u===0){n.removeChild(f),ii(s);return}u--}else a!=="$"&&a!=="$?"&&a!=="$!"||u++;a=f}while(a);ii(s)}function Sn(n){for(;n!=null;n=n.nextSibling){var s=n.nodeType;if(s===1||s===3)break;if(s===8){if(s=n.data,s==="$"||s==="$!"||s==="$?")break;if(s==="/$")return null}}return n}function Ju(n){n=n.previousSibling;for(var s=0;n;){if(n.nodeType===8){var a=n.data;if(a==="$"||a==="$!"||a==="$?"){if(s===0)return n;s--}else a==="/$"&&s++}n=n.previousSibling}return null}var fs=Math.random().toString(36).slice(2),Vt="__reactFiber$"+fs,pi="__reactProps$"+fs,rn="__reactContainer$"+fs,Ma="__reactEvents$"+fs,Hg="__reactListeners$"+fs,Wg="__reactHandles$"+fs;function Un(n){var s=n[Vt];if(s)return s;for(var a=n.parentNode;a;){if(s=a[rn]||a[Vt]){if(a=s.alternate,s.child!==null||a!==null&&a.child!==null)for(n=Ju(n);n!==null;){if(a=n[Vt])return a;n=Ju(n)}return s}n=a,a=n.parentNode}return null}function gi(n){return n=n[Vt]||n[rn],!n||n.tag!==5&&n.tag!==6&&n.tag!==13&&n.tag!==3?null:n}function ms(n){if(n.tag===5||n.tag===6)return n.stateNode;throw Error(r(33))}function vr(n){return n[pi]||null}var Aa=[],ps=-1;function Nn(n){return{current:n}}function Me(n){0>ps||(n.current=Aa[ps],Aa[ps]=null,ps--)}function Te(n,s){ps++,Aa[ps]=n.current,n.current=s}var bn={},rt=Nn(bn),mt=Nn(!1),Hn=bn;function gs(n,s){var a=n.type.contextTypes;if(!a)return bn;var u=n.stateNode;if(u&&u.__reactInternalMemoizedUnmaskedChildContext===s)return u.__reactInternalMemoizedMaskedChildContext;var f={},p;for(p in a)f[p]=s[p];return u&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=s,n.__reactInternalMemoizedMaskedChildContext=f),f}function pt(n){return n=n.childContextTypes,n!=null}function yr(){Me(mt),Me(rt)}function Xu(n,s,a){if(rt.current!==bn)throw Error(r(168));Te(rt,s),Te(mt,a)}function Zu(n,s,a){var u=n.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(n)||"Unknown",f));return H({},a,u)}function kr(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||bn,Hn=rt.current,Te(rt,n),Te(mt,mt.current),!0}function ed(n,s,a){var u=n.stateNode;if(!u)throw Error(r(169));a?(n=Zu(n,s,Hn),u.__reactInternalMemoizedMergedChildContext=n,Me(mt),Me(rt),Te(rt,n)):Me(mt),Te(mt,a)}var on=null,wr=!1,La=!1;function td(n){on===null?on=[n]:on.push(n)}function Kg(n){wr=!0,td(n)}function Cn(){if(!La&&on!==null){La=!0;var n=0,s=Ce;try{var a=on;for(Ce=1;n<a.length;n++){var u=a[n];do u=u(!0);while(u!==null)}on=null,wr=!1}catch(f){throw on!==null&&(on=on.slice(n+1)),su(ta,Cn),f}finally{Ce=s,La=!1}}return null}var vs=[],ys=0,xr=null,jr=0,$t=[],Tt=0,Wn=null,an=1,ln="";function Kn(n,s){vs[ys++]=jr,vs[ys++]=xr,xr=n,jr=s}function nd(n,s,a){$t[Tt++]=an,$t[Tt++]=ln,$t[Tt++]=Wn,Wn=n;var u=an;n=ln;var f=32-Pt(u)-1;u&=~(1<<f),a+=1;var p=32-Pt(s)+f;if(30<p){var y=f-f%5;p=(u&(1<<y)-1).toString(32),u>>=y,f-=y,an=1<<32-Pt(s)+f|a<<f|u,ln=p+n}else an=1<<p|a<<f|u,ln=n}function Ra(n){n.return!==null&&(Kn(n,1),nd(n,1,0))}function Oa(n){for(;n===xr;)xr=vs[--ys],vs[ys]=null,jr=vs[--ys],vs[ys]=null;for(;n===Wn;)Wn=$t[--Tt],$t[Tt]=null,ln=$t[--Tt],$t[Tt]=null,an=$t[--Tt],$t[Tt]=null}var St=null,Nt=null,Le=!1,Dt=null;function sd(n,s){var a=At(5,null,null,0);a.elementType="DELETED",a.stateNode=s,a.return=n,s=n.deletions,s===null?(n.deletions=[a],n.flags|=16):s.push(a)}function id(n,s){switch(n.tag){case 5:var a=n.type;return s=s.nodeType!==1||a.toLowerCase()!==s.nodeName.toLowerCase()?null:s,s!==null?(n.stateNode=s,St=n,Nt=Sn(s.firstChild),!0):!1;case 6:return s=n.pendingProps===""||s.nodeType!==3?null:s,s!==null?(n.stateNode=s,St=n,Nt=null,!0):!1;case 13:return s=s.nodeType!==8?null:s,s!==null?(a=Wn!==null?{id:an,overflow:ln}:null,n.memoizedState={dehydrated:s,treeContext:a,retryLane:1073741824},a=At(18,null,null,0),a.stateNode=s,a.return=n,n.child=a,St=n,Nt=null,!0):!1;default:return!1}}function Pa(n){return(n.mode&1)!==0&&(n.flags&128)===0}function _a(n){if(Le){var s=Nt;if(s){var a=s;if(!id(n,s)){if(Pa(n))throw Error(r(418));s=Sn(a.nextSibling);var u=St;s&&id(n,s)?sd(u,a):(n.flags=n.flags&-4097|2,Le=!1,St=n)}}else{if(Pa(n))throw Error(r(418));n.flags=n.flags&-4097|2,Le=!1,St=n}}}function rd(n){for(n=n.return;n!==null&&n.tag!==5&&n.tag!==3&&n.tag!==13;)n=n.return;St=n}function Sr(n){if(n!==St)return!1;if(!Le)return rd(n),Le=!0,!1;var s;if((s=n.tag!==3)&&!(s=n.tag!==5)&&(s=n.type,s=s!=="head"&&s!=="body"&&!Ta(n.type,n.memoizedProps)),s&&(s=Nt)){if(Pa(n))throw od(),Error(r(418));for(;s;)sd(n,s),s=Sn(s.nextSibling)}if(rd(n),n.tag===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(r(317));e:{for(n=n.nextSibling,s=0;n;){if(n.nodeType===8){var a=n.data;if(a==="/$"){if(s===0){Nt=Sn(n.nextSibling);break e}s--}else a!=="$"&&a!=="$!"&&a!=="$?"||s++}n=n.nextSibling}Nt=null}}else Nt=St?Sn(n.stateNode.nextSibling):null;return!0}function od(){for(var n=Nt;n;)n=Sn(n.nextSibling)}function ks(){Nt=St=null,Le=!1}function Da(n){Dt===null?Dt=[n]:Dt.push(n)}var Vg=X.ReactCurrentBatchConfig;function vi(n,s,a){if(n=a.ref,n!==null&&typeof n!="function"&&typeof n!="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,n));var f=u,p=""+n;return s!==null&&s.ref!==null&&typeof s.ref=="function"&&s.ref._stringRef===p?s.ref:(s=function(y){var N=f.refs;y===null?delete N[p]:N[p]=y},s._stringRef=p,s)}if(typeof n!="string")throw Error(r(284));if(!a._owner)throw Error(r(290,n))}return n}function Nr(n,s){throw n=Object.prototype.toString.call(s),Error(r(31,n==="[object Object]"?"object with keys {"+Object.keys(s).join(", ")+"}":n))}function ad(n){var s=n._init;return s(n._payload)}function ld(n){function s(I,C){if(n){var A=I.deletions;A===null?(I.deletions=[C],I.flags|=16):A.push(C)}}function a(I,C){if(!n)return null;for(;C!==null;)s(I,C),C=C.sibling;return null}function u(I,C){for(I=new Map;C!==null;)C.key!==null?I.set(C.key,C):I.set(C.index,C),C=C.sibling;return I}function f(I,C){return I=Rn(I,C),I.index=0,I.sibling=null,I}function p(I,C,A){return I.index=A,n?(A=I.alternate,A!==null?(A=A.index,A<C?(I.flags|=2,C):A):(I.flags|=2,C)):(I.flags|=1048576,C)}function y(I){return n&&I.alternate===null&&(I.flags|=2),I}function N(I,C,A,V){return C===null||C.tag!==6?(C=El(A,I.mode,V),C.return=I,C):(C=f(C,A),C.return=I,C)}function b(I,C,A,V){var re=A.type;return re===Q?F(I,C,A.props.children,V,A.key):C!==null&&(C.elementType===re||typeof re=="object"&&re!==null&&re.$$typeof===ae&&ad(re)===C.type)?(V=f(C,A.props),V.ref=vi(I,C,A),V.return=I,V):(V=qr(A.type,A.key,A.props,null,I.mode,V),V.ref=vi(I,C,A),V.return=I,V)}function L(I,C,A,V){return C===null||C.tag!==4||C.stateNode.containerInfo!==A.containerInfo||C.stateNode.implementation!==A.implementation?(C=Il(A,I.mode,V),C.return=I,C):(C=f(C,A.children||[]),C.return=I,C)}function F(I,C,A,V,re){return C===null||C.tag!==7?(C=Zn(A,I.mode,V,re),C.return=I,C):(C=f(C,A),C.return=I,C)}function W(I,C,A){if(typeof C=="string"&&C!==""||typeof C=="number")return C=El(""+C,I.mode,A),C.return=I,C;if(typeof C=="object"&&C!==null){switch(C.$$typeof){case se:return A=qr(C.type,C.key,C.props,null,I.mode,A),A.ref=vi(I,null,C),A.return=I,A;case _:return C=Il(C,I.mode,A),C.return=I,C;case ae:var V=C._init;return W(I,V(C._payload),A)}if(Vs(C)||B(C))return C=Zn(C,I.mode,A,null),C.return=I,C;Nr(I,C)}return null}function z(I,C,A,V){var re=C!==null?C.key:null;if(typeof A=="string"&&A!==""||typeof A=="number")return re!==null?null:N(I,C,""+A,V);if(typeof A=="object"&&A!==null){switch(A.$$typeof){case se:return A.key===re?b(I,C,A,V):null;case _:return A.key===re?L(I,C,A,V):null;case ae:return re=A._init,z(I,C,re(A._payload),V)}if(Vs(A)||B(A))return re!==null?null:F(I,C,A,V,null);Nr(I,A)}return null}function J(I,C,A,V,re){if(typeof V=="string"&&V!==""||typeof V=="number")return I=I.get(A)||null,N(C,I,""+V,re);if(typeof V=="object"&&V!==null){switch(V.$$typeof){case se:return I=I.get(V.key===null?A:V.key)||null,b(C,I,V,re);case _:return I=I.get(V.key===null?A:V.key)||null,L(C,I,V,re);case ae:var le=V._init;return J(I,C,A,le(V._payload),re)}if(Vs(V)||B(V))return I=I.get(A)||null,F(C,I,V,re,null);Nr(C,V)}return null}function ne(I,C,A,V){for(var re=null,le=null,ce=C,he=C=0,et=null;ce!==null&&he<A.length;he++){ce.index>he?(et=ce,ce=null):et=ce.sibling;var Se=z(I,ce,A[he],V);if(Se===null){ce===null&&(ce=et);break}n&&ce&&Se.alternate===null&&s(I,ce),C=p(Se,C,he),le===null?re=Se:le.sibling=Se,le=Se,ce=et}if(he===A.length)return a(I,ce),Le&&Kn(I,he),re;if(ce===null){for(;he<A.length;he++)ce=W(I,A[he],V),ce!==null&&(C=p(ce,C,he),le===null?re=ce:le.sibling=ce,le=ce);return Le&&Kn(I,he),re}for(ce=u(I,ce);he<A.length;he++)et=J(ce,I,he,A[he],V),et!==null&&(n&&et.alternate!==null&&ce.delete(et.key===null?he:et.key),C=p(et,C,he),le===null?re=et:le.sibling=et,le=et);return n&&ce.forEach(function(On){return s(I,On)}),Le&&Kn(I,he),re}function ie(I,C,A,V){var re=B(A);if(typeof re!="function")throw Error(r(150));if(A=re.call(A),A==null)throw Error(r(151));for(var le=re=null,ce=C,he=C=0,et=null,Se=A.next();ce!==null&&!Se.done;he++,Se=A.next()){ce.index>he?(et=ce,ce=null):et=ce.sibling;var On=z(I,ce,Se.value,V);if(On===null){ce===null&&(ce=et);break}n&&ce&&On.alternate===null&&s(I,ce),C=p(On,C,he),le===null?re=On:le.sibling=On,le=On,ce=et}if(Se.done)return a(I,ce),Le&&Kn(I,he),re;if(ce===null){for(;!Se.done;he++,Se=A.next())Se=W(I,Se.value,V),Se!==null&&(C=p(Se,C,he),le===null?re=Se:le.sibling=Se,le=Se);return Le&&Kn(I,he),re}for(ce=u(I,ce);!Se.done;he++,Se=A.next())Se=J(ce,I,he,Se.value,V),Se!==null&&(n&&Se.alternate!==null&&ce.delete(Se.key===null?he:Se.key),C=p(Se,C,he),le===null?re=Se:le.sibling=Se,le=Se);return n&&ce.forEach(function(bv){return s(I,bv)}),Le&&Kn(I,he),re}function Fe(I,C,A,V){if(typeof A=="object"&&A!==null&&A.type===Q&&A.key===null&&(A=A.props.children),typeof A=="object"&&A!==null){switch(A.$$typeof){case se:e:{for(var re=A.key,le=C;le!==null;){if(le.key===re){if(re=A.type,re===Q){if(le.tag===7){a(I,le.sibling),C=f(le,A.props.children),C.return=I,I=C;break e}}else if(le.elementType===re||typeof re=="object"&&re!==null&&re.$$typeof===ae&&ad(re)===le.type){a(I,le.sibling),C=f(le,A.props),C.ref=vi(I,le,A),C.return=I,I=C;break e}a(I,le);break}else s(I,le);le=le.sibling}A.type===Q?(C=Zn(A.props.children,I.mode,V,A.key),C.return=I,I=C):(V=qr(A.type,A.key,A.props,null,I.mode,V),V.ref=vi(I,C,A),V.return=I,I=V)}return y(I);case _: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(I,C.sibling),C=f(C,A.children||[]),C.return=I,I=C;break e}else{a(I,C);break}else s(I,C);C=C.sibling}C=Il(A,I.mode,V),C.return=I,I=C}return y(I);case ae:return le=A._init,Fe(I,C,le(A._payload),V)}if(Vs(A))return ne(I,C,A,V);if(B(A))return ie(I,C,A,V);Nr(I,A)}return typeof A=="string"&&A!==""||typeof A=="number"?(A=""+A,C!==null&&C.tag===6?(a(I,C.sibling),C=f(C,A),C.return=I,I=C):(a(I,C),C=El(A,I.mode,V),C.return=I,I=C),y(I)):a(I,C)}return Fe}var ws=ld(!0),cd=ld(!1),br=Nn(null),Cr=null,xs=null,Ba=null;function za(){Ba=xs=Cr=null}function Fa(n){var s=br.current;Me(br),n._currentValue=s}function Ua(n,s,a){for(;n!==null;){var u=n.alternate;if((n.childLanes&s)!==s?(n.childLanes|=s,u!==null&&(u.childLanes|=s)):u!==null&&(u.childLanes&s)!==s&&(u.childLanes|=s),n===a)break;n=n.return}}function js(n,s){Cr=n,Ba=xs=null,n=n.dependencies,n!==null&&n.firstContext!==null&&((n.lanes&s)!==0&&(gt=!0),n.firstContext=null)}function Et(n){var s=n._currentValue;if(Ba!==n)if(n={context:n,memoizedValue:s,next:null},xs===null){if(Cr===null)throw Error(r(308));xs=n,Cr.dependencies={lanes:0,firstContext:n}}else xs=xs.next=n;return s}var Vn=null;function Ha(n){Vn===null?Vn=[n]:Vn.push(n)}function ud(n,s,a,u){var f=s.interleaved;return f===null?(a.next=a,Ha(s)):(a.next=f.next,f.next=a),s.interleaved=a,cn(n,u)}function cn(n,s){n.lanes|=s;var a=n.alternate;for(a!==null&&(a.lanes|=s),a=n,n=n.return;n!==null;)n.childLanes|=s,a=n.alternate,a!==null&&(a.childLanes|=s),a=n,n=n.return;return a.tag===3?a.stateNode:null}var $n=!1;function Wa(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function dd(n,s){n=n.updateQueue,s.updateQueue===n&&(s.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,effects:n.effects})}function un(n,s){return{eventTime:n,lane:s,tag:0,payload:null,callback:null,next:null}}function Tn(n,s,a){var u=n.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,cn(n,a)}return f=u.interleaved,f===null?(s.next=s,Ha(u)):(s.next=f.next,f.next=s),u.interleaved=s,cn(n,a)}function $r(n,s,a){if(s=s.updateQueue,s!==null&&(s=s.shared,(a&4194240)!==0)){var u=s.lanes;u&=n.pendingLanes,a|=u,s.lanes=a,ia(n,a)}}function hd(n,s){var a=n.updateQueue,u=n.alternate;if(u!==null&&(u=u.updateQueue,a===u)){var f=null,p=null;if(a=a.firstBaseUpdate,a!==null){do{var y={eventTime:a.eventTime,lane:a.lane,tag:a.tag,payload:a.payload,callback:a.callback,next:null};p===null?f=p=y:p=p.next=y,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},n.updateQueue=a;return}n=a.lastBaseUpdate,n===null?a.firstBaseUpdate=s:n.next=s,a.lastBaseUpdate=s}function Tr(n,s,a,u){var f=n.updateQueue;$n=!1;var p=f.firstBaseUpdate,y=f.lastBaseUpdate,N=f.shared.pending;if(N!==null){f.shared.pending=null;var b=N,L=b.next;b.next=null,y===null?p=L:y.next=L,y=b;var F=n.alternate;F!==null&&(F=F.updateQueue,N=F.lastBaseUpdate,N!==y&&(N===null?F.firstBaseUpdate=L:N.next=L,F.lastBaseUpdate=b))}if(p!==null){var W=f.baseState;y=0,F=L=b=null,N=p;do{var z=N.lane,J=N.eventTime;if((u&z)===z){F!==null&&(F=F.next={eventTime:J,lane:0,tag:N.tag,payload:N.payload,callback:N.callback,next:null});e:{var ne=n,ie=N;switch(z=s,J=a,ie.tag){case 1:if(ne=ie.payload,typeof ne=="function"){W=ne.call(J,W,z);break e}W=ne;break e;case 3:ne.flags=ne.flags&-65537|128;case 0:if(ne=ie.payload,z=typeof ne=="function"?ne.call(J,W,z):ne,z==null)break e;W=H({},W,z);break e;case 2:$n=!0}}N.callback!==null&&N.lane!==0&&(n.flags|=64,z=f.effects,z===null?f.effects=[N]:z.push(N))}else J={eventTime:J,lane:z,tag:N.tag,payload:N.payload,callback:N.callback,next:null},F===null?(L=F=J,b=W):F=F.next=J,y|=z;if(N=N.next,N===null){if(N=f.shared.pending,N===null)break;z=N,N=z.next,z.next=null,f.lastBaseUpdate=z,f.shared.pending=null}}while(!0);if(F===null&&(b=W),f.baseState=b,f.firstBaseUpdate=L,f.lastBaseUpdate=F,s=f.shared.interleaved,s!==null){f=s;do y|=f.lane,f=f.next;while(f!==s)}else p===null&&(f.shared.lanes=0);Qn|=y,n.lanes=y,n.memoizedState=W}}function fd(n,s,a){if(n=s.effects,s.effects=null,n!==null)for(s=0;s<n.length;s++){var u=n[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 yi={},Gt=Nn(yi),ki=Nn(yi),wi=Nn(yi);function Gn(n){if(n===yi)throw Error(r(174));return n}function Ka(n,s){switch(Te(wi,s),Te(ki,n),Te(Gt,yi),n=s.nodeType,n){case 9:case 11:s=(s=s.documentElement)?s.namespaceURI:Vo(null,"");break;default:n=n===8?s.parentNode:s,s=n.namespaceURI||null,n=n.tagName,s=Vo(s,n)}Me(Gt),Te(Gt,s)}function Ss(){Me(Gt),Me(ki),Me(wi)}function md(n){Gn(wi.current);var s=Gn(Gt.current),a=Vo(s,n.type);s!==a&&(Te(ki,n),Te(Gt,a))}function Va(n){ki.current===n&&(Me(Gt),Me(ki))}var Oe=Nn(0);function Er(n){for(var s=n;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===n)break;for(;s.sibling===null;){if(s.return===null||s.return===n)return null;s=s.return}s.sibling.return=s.return,s=s.sibling}return null}var Ga=[];function qa(){for(var n=0;n<Ga.length;n++)Ga[n]._workInProgressVersionPrimary=null;Ga.length=0}var Ir=X.ReactCurrentDispatcher,Qa=X.ReactCurrentBatchConfig,qn=0,Pe=null,qe=null,Xe=null,Mr=!1,xi=!1,ji=0,Gg=0;function ot(){throw Error(r(321))}function Ya(n,s){if(s===null)return!1;for(var a=0;a<s.length&&a<n.length;a++)if(!_t(n[a],s[a]))return!1;return!0}function Ja(n,s,a,u,f,p){if(qn=p,Pe=s,s.memoizedState=null,s.updateQueue=null,s.lanes=0,Ir.current=n===null||n.memoizedState===null?Jg:Xg,n=a(u,f),xi){p=0;do{if(xi=!1,ji=0,25<=p)throw Error(r(301));p+=1,Xe=qe=null,s.updateQueue=null,Ir.current=Zg,n=a(u,f)}while(xi)}if(Ir.current=Rr,s=qe!==null&&qe.next!==null,qn=0,Xe=qe=Pe=null,Mr=!1,s)throw Error(r(300));return n}function Xa(){var n=ji!==0;return ji=0,n}function qt(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Xe===null?Pe.memoizedState=Xe=n:Xe=Xe.next=n,Xe}function It(){if(qe===null){var n=Pe.alternate;n=n!==null?n.memoizedState:null}else n=qe.next;var s=Xe===null?Pe.memoizedState:Xe.next;if(s!==null)Xe=s,qe=n;else{if(n===null)throw Error(r(310));qe=n,n={memoizedState:qe.memoizedState,baseState:qe.baseState,baseQueue:qe.baseQueue,queue:qe.queue,next:null},Xe===null?Pe.memoizedState=Xe=n:Xe=Xe.next=n}return Xe}function Si(n,s){return typeof s=="function"?s(n):s}function Za(n){var s=It(),a=s.queue;if(a===null)throw Error(r(311));a.lastRenderedReducer=n;var u=qe,f=u.baseQueue,p=a.pending;if(p!==null){if(f!==null){var y=f.next;f.next=p.next,p.next=y}u.baseQueue=f=p,a.pending=null}if(f!==null){p=f.next,u=u.baseState;var N=y=null,b=null,L=p;do{var F=L.lane;if((qn&F)===F)b!==null&&(b=b.next={lane:0,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null}),u=L.hasEagerState?L.eagerState:n(u,L.action);else{var W={lane:F,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null};b===null?(N=b=W,y=u):b=b.next=W,Pe.lanes|=F,Qn|=F}L=L.next}while(L!==null&&L!==p);b===null?y=u:b.next=N,_t(u,s.memoizedState)||(gt=!0),s.memoizedState=u,s.baseState=y,s.baseQueue=b,a.lastRenderedState=u}if(n=a.interleaved,n!==null){f=n;do p=f.lane,Pe.lanes|=p,Qn|=p,f=f.next;while(f!==n)}else f===null&&(a.lanes=0);return[s.memoizedState,a.dispatch]}function el(n){var s=It(),a=s.queue;if(a===null)throw Error(r(311));a.lastRenderedReducer=n;var u=a.dispatch,f=a.pending,p=s.memoizedState;if(f!==null){a.pending=null;var y=f=f.next;do p=n(p,y.action),y=y.next;while(y!==f);_t(p,s.memoizedState)||(gt=!0),s.memoizedState=p,s.baseQueue===null&&(s.baseState=p),a.lastRenderedState=p}return[p,u]}function pd(){}function gd(n,s){var a=Pe,u=It(),f=s(),p=!_t(u.memoizedState,f);if(p&&(u.memoizedState=f,gt=!0),u=u.queue,tl(kd.bind(null,a,u,n),[n]),u.getSnapshot!==s||p||Xe!==null&&Xe.memoizedState.tag&1){if(a.flags|=2048,Ni(9,yd.bind(null,a,u,f,s),void 0,null),Ze===null)throw Error(r(349));(qn&30)!==0||vd(a,s,f)}return f}function vd(n,s,a){n.flags|=16384,n={getSnapshot:s,value:a},s=Pe.updateQueue,s===null?(s={lastEffect:null,stores:null},Pe.updateQueue=s,s.stores=[n]):(a=s.stores,a===null?s.stores=[n]:a.push(n))}function yd(n,s,a,u){s.value=a,s.getSnapshot=u,wd(s)&&xd(n)}function kd(n,s,a){return a(function(){wd(s)&&xd(n)})}function wd(n){var s=n.getSnapshot;n=n.value;try{var a=s();return!_t(n,a)}catch{return!0}}function xd(n){var s=cn(n,1);s!==null&&Ut(s,n,1,-1)}function jd(n){var s=qt();return typeof n=="function"&&(n=n()),s.memoizedState=s.baseState=n,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Si,lastRenderedState:n},s.queue=n,n=n.dispatch=Yg.bind(null,Pe,n),[s.memoizedState,n]}function Ni(n,s,a,u){return n={tag:n,create:s,destroy:a,deps:u,next:null},s=Pe.updateQueue,s===null?(s={lastEffect:null,stores:null},Pe.updateQueue=s,s.lastEffect=n.next=n):(a=s.lastEffect,a===null?s.lastEffect=n.next=n:(u=a.next,a.next=n,n.next=u,s.lastEffect=n)),n}function Sd(){return It().memoizedState}function Ar(n,s,a,u){var f=qt();Pe.flags|=n,f.memoizedState=Ni(1|s,a,void 0,u===void 0?null:u)}function Lr(n,s,a,u){var f=It();u=u===void 0?null:u;var p=void 0;if(qe!==null){var y=qe.memoizedState;if(p=y.destroy,u!==null&&Ya(u,y.deps)){f.memoizedState=Ni(s,a,p,u);return}}Pe.flags|=n,f.memoizedState=Ni(1|s,a,p,u)}function Nd(n,s){return Ar(8390656,8,n,s)}function tl(n,s){return Lr(2048,8,n,s)}function bd(n,s){return Lr(4,2,n,s)}function Cd(n,s){return Lr(4,4,n,s)}function $d(n,s){if(typeof s=="function")return n=n(),s(n),function(){s(null)};if(s!=null)return n=n(),s.current=n,function(){s.current=null}}function Td(n,s,a){return a=a!=null?a.concat([n]):null,Lr(4,4,$d.bind(null,s,n),a)}function nl(){}function Ed(n,s){var a=It();s=s===void 0?null:s;var u=a.memoizedState;return u!==null&&s!==null&&Ya(s,u[1])?u[0]:(a.memoizedState=[n,s],n)}function Id(n,s){var a=It();s=s===void 0?null:s;var u=a.memoizedState;return u!==null&&s!==null&&Ya(s,u[1])?u[0]:(n=n(),a.memoizedState=[n,s],n)}function Md(n,s,a){return(qn&21)===0?(n.baseState&&(n.baseState=!1,gt=!0),n.memoizedState=a):(_t(a,s)||(a=au(),Pe.lanes|=a,Qn|=a,n.baseState=!0),s)}function qg(n,s){var a=Ce;Ce=a!==0&&4>a?a:4,n(!0);var u=Qa.transition;Qa.transition={};try{n(!1),s()}finally{Ce=a,Qa.transition=u}}function Ad(){return It().memoizedState}function Qg(n,s,a){var u=An(n);if(a={lane:u,action:a,hasEagerState:!1,eagerState:null,next:null},Ld(n))Rd(s,a);else if(a=ud(n,s,a,u),a!==null){var f=dt();Ut(a,n,u,f),Od(a,s,u)}}function Yg(n,s,a){var u=An(n),f={lane:u,action:a,hasEagerState:!1,eagerState:null,next:null};if(Ld(n))Rd(s,f);else{var p=n.alternate;if(n.lanes===0&&(p===null||p.lanes===0)&&(p=s.lastRenderedReducer,p!==null))try{var y=s.lastRenderedState,N=p(y,a);if(f.hasEagerState=!0,f.eagerState=N,_t(N,y)){var b=s.interleaved;b===null?(f.next=f,Ha(s)):(f.next=b.next,b.next=f),s.interleaved=f;return}}catch{}finally{}a=ud(n,s,f,u),a!==null&&(f=dt(),Ut(a,n,u,f),Od(a,s,u))}}function Ld(n){var s=n.alternate;return n===Pe||s!==null&&s===Pe}function Rd(n,s){xi=Mr=!0;var a=n.pending;a===null?s.next=s:(s.next=a.next,a.next=s),n.pending=s}function Od(n,s,a){if((a&4194240)!==0){var u=s.lanes;u&=n.pendingLanes,a|=u,s.lanes=a,ia(n,a)}}var Rr={readContext:Et,useCallback:ot,useContext:ot,useEffect:ot,useImperativeHandle:ot,useInsertionEffect:ot,useLayoutEffect:ot,useMemo:ot,useReducer:ot,useRef:ot,useState:ot,useDebugValue:ot,useDeferredValue:ot,useTransition:ot,useMutableSource:ot,useSyncExternalStore:ot,useId:ot,unstable_isNewReconciler:!1},Jg={readContext:Et,useCallback:function(n,s){return qt().memoizedState=[n,s===void 0?null:s],n},useContext:Et,useEffect:Nd,useImperativeHandle:function(n,s,a){return a=a!=null?a.concat([n]):null,Ar(4194308,4,$d.bind(null,s,n),a)},useLayoutEffect:function(n,s){return Ar(4194308,4,n,s)},useInsertionEffect:function(n,s){return Ar(4,2,n,s)},useMemo:function(n,s){var a=qt();return s=s===void 0?null:s,n=n(),a.memoizedState=[n,s],n},useReducer:function(n,s,a){var u=qt();return s=a!==void 0?a(s):s,u.memoizedState=u.baseState=s,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:s},u.queue=n,n=n.dispatch=Qg.bind(null,Pe,n),[u.memoizedState,n]},useRef:function(n){var s=qt();return n={current:n},s.memoizedState=n},useState:jd,useDebugValue:nl,useDeferredValue:function(n){return qt().memoizedState=n},useTransition:function(){var n=jd(!1),s=n[0];return n=qg.bind(null,n[1]),qt().memoizedState=n,[s,n]},useMutableSource:function(){},useSyncExternalStore:function(n,s,a){var u=Pe,f=qt();if(Le){if(a===void 0)throw Error(r(407));a=a()}else{if(a=s(),Ze===null)throw Error(r(349));(qn&30)!==0||vd(u,s,a)}f.memoizedState=a;var p={value:a,getSnapshot:s};return f.queue=p,Nd(kd.bind(null,u,p,n),[n]),u.flags|=2048,Ni(9,yd.bind(null,u,p,a,s),void 0,null),a},useId:function(){var n=qt(),s=Ze.identifierPrefix;if(Le){var a=ln,u=an;a=(u&~(1<<32-Pt(u)-1)).toString(32)+a,s=":"+s+"R"+a,a=ji++,0<a&&(s+="H"+a.toString(32)),s+=":"}else a=Gg++,s=":"+s+"r"+a.toString(32)+":";return n.memoizedState=s},unstable_isNewReconciler:!1},Xg={readContext:Et,useCallback:Ed,useContext:Et,useEffect:tl,useImperativeHandle:Td,useInsertionEffect:bd,useLayoutEffect:Cd,useMemo:Id,useReducer:Za,useRef:Sd,useState:function(){return Za(Si)},useDebugValue:nl,useDeferredValue:function(n){var s=It();return Md(s,qe.memoizedState,n)},useTransition:function(){var n=Za(Si)[0],s=It().memoizedState;return[n,s]},useMutableSource:pd,useSyncExternalStore:gd,useId:Ad,unstable_isNewReconciler:!1},Zg={readContext:Et,useCallback:Ed,useContext:Et,useEffect:tl,useImperativeHandle:Td,useInsertionEffect:bd,useLayoutEffect:Cd,useMemo:Id,useReducer:el,useRef:Sd,useState:function(){return el(Si)},useDebugValue:nl,useDeferredValue:function(n){var s=It();return qe===null?s.memoizedState=n:Md(s,qe.memoizedState,n)},useTransition:function(){var n=el(Si)[0],s=It().memoizedState;return[n,s]},useMutableSource:pd,useSyncExternalStore:gd,useId:Ad,unstable_isNewReconciler:!1};function Bt(n,s){if(n&&n.defaultProps){s=H({},s),n=n.defaultProps;for(var a in n)s[a]===void 0&&(s[a]=n[a]);return s}return s}function sl(n,s,a,u){s=n.memoizedState,a=a(u,s),a=a==null?s:H({},s,a),n.memoizedState=a,n.lanes===0&&(n.updateQueue.baseState=a)}var Or={isMounted:function(n){return(n=n._reactInternals)?Fn(n)===n:!1},enqueueSetState:function(n,s,a){n=n._reactInternals;var u=dt(),f=An(n),p=un(u,f);p.payload=s,a!=null&&(p.callback=a),s=Tn(n,p,f),s!==null&&(Ut(s,n,f,u),$r(s,n,f))},enqueueReplaceState:function(n,s,a){n=n._reactInternals;var u=dt(),f=An(n),p=un(u,f);p.tag=1,p.payload=s,a!=null&&(p.callback=a),s=Tn(n,p,f),s!==null&&(Ut(s,n,f,u),$r(s,n,f))},enqueueForceUpdate:function(n,s){n=n._reactInternals;var a=dt(),u=An(n),f=un(a,u);f.tag=2,s!=null&&(f.callback=s),s=Tn(n,f,u),s!==null&&(Ut(s,n,u,a),$r(s,n,u))}};function Pd(n,s,a,u,f,p,y){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(u,p,y):s.prototype&&s.prototype.isPureReactComponent?!ui(a,u)||!ui(f,p):!0}function _d(n,s,a){var u=!1,f=bn,p=s.contextType;return typeof p=="object"&&p!==null?p=Et(p):(f=pt(s)?Hn:rt.current,u=s.contextTypes,p=(u=u!=null)?gs(n,f):bn),s=new s(a,p),n.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,s.updater=Or,n.stateNode=s,s._reactInternals=n,u&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=f,n.__reactInternalMemoizedMaskedChildContext=p),s}function Dd(n,s,a,u){n=s.state,typeof s.componentWillReceiveProps=="function"&&s.componentWillReceiveProps(a,u),typeof s.UNSAFE_componentWillReceiveProps=="function"&&s.UNSAFE_componentWillReceiveProps(a,u),s.state!==n&&Or.enqueueReplaceState(s,s.state,null)}function il(n,s,a,u){var f=n.stateNode;f.props=a,f.state=n.memoizedState,f.refs={},Wa(n);var p=s.contextType;typeof p=="object"&&p!==null?f.context=Et(p):(p=pt(s)?Hn:rt.current,f.context=gs(n,p)),f.state=n.memoizedState,p=s.getDerivedStateFromProps,typeof p=="function"&&(sl(n,s,p,a),f.state=n.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&&Or.enqueueReplaceState(f,f.state,null),Tr(n,a,f,u),f.state=n.memoizedState),typeof f.componentDidMount=="function"&&(n.flags|=4194308)}function Ns(n,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:n,source:s,stack:f,digest:null}}function rl(n,s,a){return{value:n,source:null,stack:a??null,digest:s??null}}function ol(n,s){try{console.error(s.value)}catch(a){setTimeout(function(){throw a})}}var ev=typeof WeakMap=="function"?WeakMap:Map;function Bd(n,s,a){a=un(-1,a),a.tag=3,a.payload={element:null};var u=s.value;return a.callback=function(){Ur||(Ur=!0,xl=u),ol(n,s)},a}function zd(n,s,a){a=un(-1,a),a.tag=3;var u=n.type.getDerivedStateFromError;if(typeof u=="function"){var f=s.value;a.payload=function(){return u(f)},a.callback=function(){ol(n,s)}}var p=n.stateNode;return p!==null&&typeof p.componentDidCatch=="function"&&(a.callback=function(){ol(n,s),typeof u!="function"&&(In===null?In=new Set([this]):In.add(this));var y=s.stack;this.componentDidCatch(s.value,{componentStack:y!==null?y:""})}),a}function Fd(n,s,a){var u=n.pingCache;if(u===null){u=n.pingCache=new ev;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),n=mv.bind(null,n,s,a),s.then(n,n))}function Ud(n){do{var s;if((s=n.tag===13)&&(s=n.memoizedState,s=s!==null?s.dehydrated!==null:!0),s)return n;n=n.return}while(n!==null);return null}function Hd(n,s,a,u,f){return(n.mode&1)===0?(n===s?n.flags|=65536:(n.flags|=128,a.flags|=131072,a.flags&=-52805,a.tag===1&&(a.alternate===null?a.tag=17:(s=un(-1,1),s.tag=2,Tn(a,s,1))),a.lanes|=1),n):(n.flags|=65536,n.lanes=f,n)}var tv=X.ReactCurrentOwner,gt=!1;function ut(n,s,a,u){s.child=n===null?cd(s,null,a,u):ws(s,n.child,a,u)}function Wd(n,s,a,u,f){a=a.render;var p=s.ref;return js(s,f),u=Ja(n,s,a,u,p,f),a=Xa(),n!==null&&!gt?(s.updateQueue=n.updateQueue,s.flags&=-2053,n.lanes&=~f,dn(n,s,f)):(Le&&a&&Ra(s),s.flags|=1,ut(n,s,u,f),s.child)}function Kd(n,s,a,u,f){if(n===null){var p=a.type;return typeof p=="function"&&!Tl(p)&&p.defaultProps===void 0&&a.compare===null&&a.defaultProps===void 0?(s.tag=15,s.type=p,Vd(n,s,p,u,f)):(n=qr(a.type,null,u,s,s.mode,f),n.ref=s.ref,n.return=s,s.child=n)}if(p=n.child,(n.lanes&f)===0){var y=p.memoizedProps;if(a=a.compare,a=a!==null?a:ui,a(y,u)&&n.ref===s.ref)return dn(n,s,f)}return s.flags|=1,n=Rn(p,u),n.ref=s.ref,n.return=s,s.child=n}function Vd(n,s,a,u,f){if(n!==null){var p=n.memoizedProps;if(ui(p,u)&&n.ref===s.ref)if(gt=!1,s.pendingProps=u=p,(n.lanes&f)!==0)(n.flags&131072)!==0&&(gt=!0);else return s.lanes=n.lanes,dn(n,s,f)}return al(n,s,a,u,f)}function Gd(n,s,a){var u=s.pendingProps,f=u.children,p=n!==null?n.memoizedState:null;if(u.mode==="hidden")if((s.mode&1)===0)s.memoizedState={baseLanes:0,cachePool:null,transitions:null},Te(Cs,bt),bt|=a;else{if((a&1073741824)===0)return n=p!==null?p.baseLanes|a:a,s.lanes=s.childLanes=1073741824,s.memoizedState={baseLanes:n,cachePool:null,transitions:null},s.updateQueue=null,Te(Cs,bt),bt|=n,null;s.memoizedState={baseLanes:0,cachePool:null,transitions:null},u=p!==null?p.baseLanes:a,Te(Cs,bt),bt|=u}else p!==null?(u=p.baseLanes|a,s.memoizedState=null):u=a,Te(Cs,bt),bt|=u;return ut(n,s,f,a),s.child}function qd(n,s){var a=s.ref;(n===null&&a!==null||n!==null&&n.ref!==a)&&(s.flags|=512,s.flags|=2097152)}function al(n,s,a,u,f){var p=pt(a)?Hn:rt.current;return p=gs(s,p),js(s,f),a=Ja(n,s,a,u,p,f),u=Xa(),n!==null&&!gt?(s.updateQueue=n.updateQueue,s.flags&=-2053,n.lanes&=~f,dn(n,s,f)):(Le&&u&&Ra(s),s.flags|=1,ut(n,s,a,f),s.child)}function Qd(n,s,a,u,f){if(pt(a)){var p=!0;kr(s)}else p=!1;if(js(s,f),s.stateNode===null)_r(n,s),_d(s,a,u),il(s,a,u,f),u=!0;else if(n===null){var y=s.stateNode,N=s.memoizedProps;y.props=N;var b=y.context,L=a.contextType;typeof L=="object"&&L!==null?L=Et(L):(L=pt(a)?Hn:rt.current,L=gs(s,L));var F=a.getDerivedStateFromProps,W=typeof F=="function"||typeof y.getSnapshotBeforeUpdate=="function";W||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(N!==u||b!==L)&&Dd(s,y,u,L),$n=!1;var z=s.memoizedState;y.state=z,Tr(s,u,y,f),b=s.memoizedState,N!==u||z!==b||mt.current||$n?(typeof F=="function"&&(sl(s,a,F,u),b=s.memoizedState),(N=$n||Pd(s,a,N,u,z,b,L))?(W||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount()),typeof y.componentDidMount=="function"&&(s.flags|=4194308)):(typeof y.componentDidMount=="function"&&(s.flags|=4194308),s.memoizedProps=u,s.memoizedState=b),y.props=u,y.state=b,y.context=L,u=N):(typeof y.componentDidMount=="function"&&(s.flags|=4194308),u=!1)}else{y=s.stateNode,dd(n,s),N=s.memoizedProps,L=s.type===s.elementType?N:Bt(s.type,N),y.props=L,W=s.pendingProps,z=y.context,b=a.contextType,typeof b=="object"&&b!==null?b=Et(b):(b=pt(a)?Hn:rt.current,b=gs(s,b));var J=a.getDerivedStateFromProps;(F=typeof J=="function"||typeof y.getSnapshotBeforeUpdate=="function")||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(N!==W||z!==b)&&Dd(s,y,u,b),$n=!1,z=s.memoizedState,y.state=z,Tr(s,u,y,f);var ne=s.memoizedState;N!==W||z!==ne||mt.current||$n?(typeof J=="function"&&(sl(s,a,J,u),ne=s.memoizedState),(L=$n||Pd(s,a,L,u,z,ne,b)||!1)?(F||typeof y.UNSAFE_componentWillUpdate!="function"&&typeof y.componentWillUpdate!="function"||(typeof y.componentWillUpdate=="function"&&y.componentWillUpdate(u,ne,b),typeof y.UNSAFE_componentWillUpdate=="function"&&y.UNSAFE_componentWillUpdate(u,ne,b)),typeof y.componentDidUpdate=="function"&&(s.flags|=4),typeof y.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof y.componentDidUpdate!="function"||N===n.memoizedProps&&z===n.memoizedState||(s.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||N===n.memoizedProps&&z===n.memoizedState||(s.flags|=1024),s.memoizedProps=u,s.memoizedState=ne),y.props=u,y.state=ne,y.context=b,u=L):(typeof y.componentDidUpdate!="function"||N===n.memoizedProps&&z===n.memoizedState||(s.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||N===n.memoizedProps&&z===n.memoizedState||(s.flags|=1024),u=!1)}return ll(n,s,a,u,p,f)}function ll(n,s,a,u,f,p){qd(n,s);var y=(s.flags&128)!==0;if(!u&&!y)return f&&ed(s,a,!1),dn(n,s,p);u=s.stateNode,tv.current=s;var N=y&&typeof a.getDerivedStateFromError!="function"?null:u.render();return s.flags|=1,n!==null&&y?(s.child=ws(s,n.child,null,p),s.child=ws(s,null,N,p)):ut(n,s,N,p),s.memoizedState=u.state,f&&ed(s,a,!0),s.child}function Yd(n){var s=n.stateNode;s.pendingContext?Xu(n,s.pendingContext,s.pendingContext!==s.context):s.context&&Xu(n,s.context,!1),Ka(n,s.containerInfo)}function Jd(n,s,a,u,f){return ks(),Da(f),s.flags|=256,ut(n,s,a,u),s.child}var cl={dehydrated:null,treeContext:null,retryLane:0};function ul(n){return{baseLanes:n,cachePool:null,transitions:null}}function Xd(n,s,a){var u=s.pendingProps,f=Oe.current,p=!1,y=(s.flags&128)!==0,N;if((N=y)||(N=n!==null&&n.memoizedState===null?!1:(f&2)!==0),N?(p=!0,s.flags&=-129):(n===null||n.memoizedState!==null)&&(f|=1),Te(Oe,f&1),n===null)return _a(s),n=s.memoizedState,n!==null&&(n=n.dehydrated,n!==null)?((s.mode&1)===0?s.lanes=1:n.data==="$!"?s.lanes=8:s.lanes=1073741824,null):(y=u.children,n=u.fallback,p?(u=s.mode,p=s.child,y={mode:"hidden",children:y},(u&1)===0&&p!==null?(p.childLanes=0,p.pendingProps=y):p=Qr(y,u,0,null),n=Zn(n,u,a,null),p.return=s,n.return=s,p.sibling=n,s.child=p,s.child.memoizedState=ul(a),s.memoizedState=cl,n):dl(s,y));if(f=n.memoizedState,f!==null&&(N=f.dehydrated,N!==null))return nv(n,s,y,u,N,f,a);if(p){p=u.fallback,y=s.mode,f=n.child,N=f.sibling;var b={mode:"hidden",children:u.children};return(y&1)===0&&s.child!==f?(u=s.child,u.childLanes=0,u.pendingProps=b,s.deletions=null):(u=Rn(f,b),u.subtreeFlags=f.subtreeFlags&14680064),N!==null?p=Rn(N,p):(p=Zn(p,y,a,null),p.flags|=2),p.return=s,u.return=s,u.sibling=p,s.child=u,u=p,p=s.child,y=n.child.memoizedState,y=y===null?ul(a):{baseLanes:y.baseLanes|a,cachePool:null,transitions:y.transitions},p.memoizedState=y,p.childLanes=n.childLanes&~a,s.memoizedState=cl,u}return p=n.child,n=p.sibling,u=Rn(p,{mode:"visible",children:u.children}),(s.mode&1)===0&&(u.lanes=a),u.return=s,u.sibling=null,n!==null&&(a=s.deletions,a===null?(s.deletions=[n],s.flags|=16):a.push(n)),s.child=u,s.memoizedState=null,u}function dl(n,s){return s=Qr({mode:"visible",children:s},n.mode,0,null),s.return=n,n.child=s}function Pr(n,s,a,u){return u!==null&&Da(u),ws(s,n.child,null,a),n=dl(s,s.pendingProps.children),n.flags|=2,s.memoizedState=null,n}function nv(n,s,a,u,f,p,y){if(a)return s.flags&256?(s.flags&=-257,u=rl(Error(r(422))),Pr(n,s,y,u)):s.memoizedState!==null?(s.child=n.child,s.flags|=128,null):(p=u.fallback,f=s.mode,u=Qr({mode:"visible",children:u.children},f,0,null),p=Zn(p,f,y,null),p.flags|=2,u.return=s,p.return=s,u.sibling=p,s.child=u,(s.mode&1)!==0&&ws(s,n.child,null,y),s.child.memoizedState=ul(y),s.memoizedState=cl,p);if((s.mode&1)===0)return Pr(n,s,y,null);if(f.data==="$!"){if(u=f.nextSibling&&f.nextSibling.dataset,u)var N=u.dgst;return u=N,p=Error(r(419)),u=rl(p,u,void 0),Pr(n,s,y,u)}if(N=(y&n.childLanes)!==0,gt||N){if(u=Ze,u!==null){switch(y&-y){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|y))!==0?0:f,f!==0&&f!==p.retryLane&&(p.retryLane=f,cn(n,f),Ut(u,n,f,-1))}return $l(),u=rl(Error(r(421))),Pr(n,s,y,u)}return f.data==="$?"?(s.flags|=128,s.child=n.child,s=pv.bind(null,n),f._reactRetry=s,null):(n=p.treeContext,Nt=Sn(f.nextSibling),St=s,Le=!0,Dt=null,n!==null&&($t[Tt++]=an,$t[Tt++]=ln,$t[Tt++]=Wn,an=n.id,ln=n.overflow,Wn=s),s=dl(s,u.children),s.flags|=4096,s)}function Zd(n,s,a){n.lanes|=s;var u=n.alternate;u!==null&&(u.lanes|=s),Ua(n.return,s,a)}function hl(n,s,a,u,f){var p=n.memoizedState;p===null?n.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 eh(n,s,a){var u=s.pendingProps,f=u.revealOrder,p=u.tail;if(ut(n,s,u.children,a),u=Oe.current,(u&2)!==0)u=u&1|2,s.flags|=128;else{if(n!==null&&(n.flags&128)!==0)e:for(n=s.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&Zd(n,a,s);else if(n.tag===19)Zd(n,a,s);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===s)break e;for(;n.sibling===null;){if(n.return===null||n.return===s)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}u&=1}if(Te(Oe,u),(s.mode&1)===0)s.memoizedState=null;else switch(f){case"forwards":for(a=s.child,f=null;a!==null;)n=a.alternate,n!==null&&Er(n)===null&&(f=a),a=a.sibling;a=f,a===null?(f=s.child,s.child=null):(f=a.sibling,a.sibling=null),hl(s,!1,f,a,p);break;case"backwards":for(a=null,f=s.child,s.child=null;f!==null;){if(n=f.alternate,n!==null&&Er(n)===null){s.child=f;break}n=f.sibling,f.sibling=a,a=f,f=n}hl(s,!0,a,null,p);break;case"together":hl(s,!1,null,null,void 0);break;default:s.memoizedState=null}return s.child}function _r(n,s){(s.mode&1)===0&&n!==null&&(n.alternate=null,s.alternate=null,s.flags|=2)}function dn(n,s,a){if(n!==null&&(s.dependencies=n.dependencies),Qn|=s.lanes,(a&s.childLanes)===0)return null;if(n!==null&&s.child!==n.child)throw Error(r(153));if(s.child!==null){for(n=s.child,a=Rn(n,n.pendingProps),s.child=a,a.return=s;n.sibling!==null;)n=n.sibling,a=a.sibling=Rn(n,n.pendingProps),a.return=s;a.sibling=null}return s.child}function sv(n,s,a){switch(s.tag){case 3:Yd(s),ks();break;case 5:md(s);break;case 1:pt(s.type)&&kr(s);break;case 4:Ka(s,s.stateNode.containerInfo);break;case 10:var u=s.type._context,f=s.memoizedProps.value;Te(br,u._currentValue),u._currentValue=f;break;case 13:if(u=s.memoizedState,u!==null)return u.dehydrated!==null?(Te(Oe,Oe.current&1),s.flags|=128,null):(a&s.child.childLanes)!==0?Xd(n,s,a):(Te(Oe,Oe.current&1),n=dn(n,s,a),n!==null?n.sibling:null);Te(Oe,Oe.current&1);break;case 19:if(u=(a&s.childLanes)!==0,(n.flags&128)!==0){if(u)return eh(n,s,a);s.flags|=128}if(f=s.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),Te(Oe,Oe.current),u)break;return null;case 22:case 23:return s.lanes=0,Gd(n,s,a)}return dn(n,s,a)}var th,fl,nh,sh;th=function(n,s){for(var a=s.child;a!==null;){if(a.tag===5||a.tag===6)n.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}},fl=function(){},nh=function(n,s,a,u){var f=n.memoizedProps;if(f!==u){n=s.stateNode,Gn(Gt.current);var p=null;switch(a){case"input":f=Uo(n,f),u=Uo(n,u),p=[];break;case"select":f=H({},f,{value:void 0}),u=H({},u,{value:void 0}),p=[];break;case"textarea":f=Ko(n,f),u=Ko(n,u),p=[];break;default:typeof f.onClick!="function"&&typeof u.onClick=="function"&&(n.onclick=gr)}Go(a,u);var y;a=null;for(L in f)if(!u.hasOwnProperty(L)&&f.hasOwnProperty(L)&&f[L]!=null)if(L==="style"){var N=f[L];for(y in N)N.hasOwnProperty(y)&&(a||(a={}),a[y]="")}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(N=f!=null?f[L]:void 0,u.hasOwnProperty(L)&&b!==N&&(b!=null||N!=null))if(L==="style")if(N){for(y in N)!N.hasOwnProperty(y)||b&&b.hasOwnProperty(y)||(a||(a={}),a[y]="");for(y in b)b.hasOwnProperty(y)&&N[y]!==b[y]&&(a||(a={}),a[y]=b[y])}else a||(p||(p=[]),p.push(L,a)),a=b;else L==="dangerouslySetInnerHTML"?(b=b?b.__html:void 0,N=N?N.__html:void 0,b!=null&&N!==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",n),p||N===b||(p=[])):(p=p||[]).push(L,b))}a&&(p=p||[]).push("style",a);var L=p;(s.updateQueue=L)&&(s.flags|=4)}},sh=function(n,s,a,u){a!==u&&(s.flags|=4)};function bi(n,s){if(!Le)switch(n.tailMode){case"hidden":s=n.tail;for(var a=null;s!==null;)s.alternate!==null&&(a=s),s=s.sibling;a===null?n.tail=null:a.sibling=null;break;case"collapsed":a=n.tail;for(var u=null;a!==null;)a.alternate!==null&&(u=a),a=a.sibling;u===null?s||n.tail===null?n.tail=null:n.tail.sibling=null:u.sibling=null}}function at(n){var s=n.alternate!==null&&n.alternate.child===n.child,a=0,u=0;if(s)for(var f=n.child;f!==null;)a|=f.lanes|f.childLanes,u|=f.subtreeFlags&14680064,u|=f.flags&14680064,f.return=n,f=f.sibling;else for(f=n.child;f!==null;)a|=f.lanes|f.childLanes,u|=f.subtreeFlags,u|=f.flags,f.return=n,f=f.sibling;return n.subtreeFlags|=u,n.childLanes=a,s}function iv(n,s,a){var u=s.pendingProps;switch(Oa(s),s.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return at(s),null;case 1:return pt(s.type)&&yr(),at(s),null;case 3:return u=s.stateNode,Ss(),Me(mt),Me(rt),qa(),u.pendingContext&&(u.context=u.pendingContext,u.pendingContext=null),(n===null||n.child===null)&&(Sr(s)?s.flags|=4:n===null||n.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,Dt!==null&&(Nl(Dt),Dt=null))),fl(n,s),at(s),null;case 5:Va(s);var f=Gn(wi.current);if(a=s.type,n!==null&&s.stateNode!=null)nh(n,s,a,u,f),n.ref!==s.ref&&(s.flags|=512,s.flags|=2097152);else{if(!u){if(s.stateNode===null)throw Error(r(166));return at(s),null}if(n=Gn(Gt.current),Sr(s)){u=s.stateNode,a=s.type;var p=s.memoizedProps;switch(u[Vt]=s,u[pi]=p,n=(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<hi.length;f++)Ie(hi[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":_c(u,p),Ie("invalid",u);break;case"select":u._wrapperState={wasMultiple:!!p.multiple},Ie("invalid",u);break;case"textarea":zc(u,p),Ie("invalid",u)}Go(a,p),f=null;for(var y in p)if(p.hasOwnProperty(y)){var N=p[y];y==="children"?typeof N=="string"?u.textContent!==N&&(p.suppressHydrationWarning!==!0&&pr(u.textContent,N,n),f=["children",N]):typeof N=="number"&&u.textContent!==""+N&&(p.suppressHydrationWarning!==!0&&pr(u.textContent,N,n),f=["children",""+N]):l.hasOwnProperty(y)&&N!=null&&y==="onScroll"&&Ie("scroll",u)}switch(a){case"input":ss(u),Bc(u,p,!0);break;case"textarea":ss(u),Uc(u);break;case"select":case"option":break;default:typeof p.onClick=="function"&&(u.onclick=gr)}u=f,s.updateQueue=u,u!==null&&(s.flags|=4)}else{y=f.nodeType===9?f:f.ownerDocument,n==="http://www.w3.org/1999/xhtml"&&(n=Hc(a)),n==="http://www.w3.org/1999/xhtml"?a==="script"?(n=y.createElement("div"),n.innerHTML="<script><\/script>",n=n.removeChild(n.firstChild)):typeof u.is=="string"?n=y.createElement(a,{is:u.is}):(n=y.createElement(a),a==="select"&&(y=n,u.multiple?y.multiple=!0:u.size&&(y.size=u.size))):n=y.createElementNS(n,a),n[Vt]=s,n[pi]=u,th(n,s,!1,!1),s.stateNode=n;e:{switch(y=qo(a,u),a){case"dialog":Ie("cancel",n),Ie("close",n),f=u;break;case"iframe":case"object":case"embed":Ie("load",n),f=u;break;case"video":case"audio":for(f=0;f<hi.length;f++)Ie(hi[f],n);f=u;break;case"source":Ie("error",n),f=u;break;case"img":case"image":case"link":Ie("error",n),Ie("load",n),f=u;break;case"details":Ie("toggle",n),f=u;break;case"input":_c(n,u),f=Uo(n,u),Ie("invalid",n);break;case"option":f=u;break;case"select":n._wrapperState={wasMultiple:!!u.multiple},f=H({},u,{value:void 0}),Ie("invalid",n);break;case"textarea":zc(n,u),f=Ko(n,u),Ie("invalid",n);break;default:f=u}Go(a,f),N=f;for(p in N)if(N.hasOwnProperty(p)){var b=N[p];p==="style"?Vc(n,b):p==="dangerouslySetInnerHTML"?(b=b?b.__html:void 0,b!=null&&Wc(n,b)):p==="children"?typeof b=="string"?(a!=="textarea"||b!=="")&&Gs(n,b):typeof b=="number"&&Gs(n,""+b):p!=="suppressContentEditableWarning"&&p!=="suppressHydrationWarning"&&p!=="autoFocus"&&(l.hasOwnProperty(p)?b!=null&&p==="onScroll"&&Ie("scroll",n):b!=null&&O(n,p,b,y))}switch(a){case"input":ss(n),Bc(n,u,!1);break;case"textarea":ss(n),Uc(n);break;case"option":u.value!=null&&n.setAttribute("value",""+ye(u.value));break;case"select":n.multiple=!!u.multiple,p=u.value,p!=null?is(n,!!u.multiple,p,!1):u.defaultValue!=null&&is(n,!!u.multiple,u.defaultValue,!0);break;default:typeof f.onClick=="function"&&(n.onclick=gr)}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 at(s),null;case 6:if(n&&s.stateNode!=null)sh(n,s,n.memoizedProps,u);else{if(typeof u!="string"&&s.stateNode===null)throw Error(r(166));if(a=Gn(wi.current),Gn(Gt.current),Sr(s)){if(u=s.stateNode,a=s.memoizedProps,u[Vt]=s,(p=u.nodeValue!==a)&&(n=St,n!==null))switch(n.tag){case 3:pr(u.nodeValue,a,(n.mode&1)!==0);break;case 5:n.memoizedProps.suppressHydrationWarning!==!0&&pr(u.nodeValue,a,(n.mode&1)!==0)}p&&(s.flags|=4)}else u=(a.nodeType===9?a:a.ownerDocument).createTextNode(u),u[Vt]=s,s.stateNode=u}return at(s),null;case 13:if(Me(Oe),u=s.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(Le&&Nt!==null&&(s.mode&1)!==0&&(s.flags&128)===0)od(),ks(),s.flags|=98560,p=!1;else if(p=Sr(s),u!==null&&u.dehydrated!==null){if(n===null){if(!p)throw Error(r(318));if(p=s.memoizedState,p=p!==null?p.dehydrated:null,!p)throw Error(r(317));p[Vt]=s}else ks(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;at(s),p=!1}else Dt!==null&&(Nl(Dt),Dt=null),p=!0;if(!p)return s.flags&65536?s:null}return(s.flags&128)!==0?(s.lanes=a,s):(u=u!==null,u!==(n!==null&&n.memoizedState!==null)&&u&&(s.child.flags|=8192,(s.mode&1)!==0&&(n===null||(Oe.current&1)!==0?Qe===0&&(Qe=3):$l())),s.updateQueue!==null&&(s.flags|=4),at(s),null);case 4:return Ss(),fl(n,s),n===null&&fi(s.stateNode.containerInfo),at(s),null;case 10:return Fa(s.type._context),at(s),null;case 17:return pt(s.type)&&yr(),at(s),null;case 19:if(Me(Oe),p=s.memoizedState,p===null)return at(s),null;if(u=(s.flags&128)!==0,y=p.rendering,y===null)if(u)bi(p,!1);else{if(Qe!==0||n!==null&&(n.flags&128)!==0)for(n=s.child;n!==null;){if(y=Er(n),y!==null){for(s.flags|=128,bi(p,!1),u=y.updateQueue,u!==null&&(s.updateQueue=u,s.flags|=4),s.subtreeFlags=0,u=a,a=s.child;a!==null;)p=a,n=u,p.flags&=14680066,y=p.alternate,y===null?(p.childLanes=0,p.lanes=n,p.child=null,p.subtreeFlags=0,p.memoizedProps=null,p.memoizedState=null,p.updateQueue=null,p.dependencies=null,p.stateNode=null):(p.childLanes=y.childLanes,p.lanes=y.lanes,p.child=y.child,p.subtreeFlags=0,p.deletions=null,p.memoizedProps=y.memoizedProps,p.memoizedState=y.memoizedState,p.updateQueue=y.updateQueue,p.type=y.type,n=y.dependencies,p.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),a=a.sibling;return Te(Oe,Oe.current&1|2),s.child}n=n.sibling}p.tail!==null&&ze()>$s&&(s.flags|=128,u=!0,bi(p,!1),s.lanes=4194304)}else{if(!u)if(n=Er(y),n!==null){if(s.flags|=128,u=!0,a=n.updateQueue,a!==null&&(s.updateQueue=a,s.flags|=4),bi(p,!0),p.tail===null&&p.tailMode==="hidden"&&!y.alternate&&!Le)return at(s),null}else 2*ze()-p.renderingStartTime>$s&&a!==1073741824&&(s.flags|=128,u=!0,bi(p,!1),s.lanes=4194304);p.isBackwards?(y.sibling=s.child,s.child=y):(a=p.last,a!==null?a.sibling=y:s.child=y,p.last=y)}return p.tail!==null?(s=p.tail,p.rendering=s,p.tail=s.sibling,p.renderingStartTime=ze(),s.sibling=null,a=Oe.current,Te(Oe,u?a&1|2:a&1),s):(at(s),null);case 22:case 23:return Cl(),u=s.memoizedState!==null,n!==null&&n.memoizedState!==null!==u&&(s.flags|=8192),u&&(s.mode&1)!==0?(bt&1073741824)!==0&&(at(s),s.subtreeFlags&6&&(s.flags|=8192)):at(s),null;case 24:return null;case 25:return null}throw Error(r(156,s.tag))}function rv(n,s){switch(Oa(s),s.tag){case 1:return pt(s.type)&&yr(),n=s.flags,n&65536?(s.flags=n&-65537|128,s):null;case 3:return Ss(),Me(mt),Me(rt),qa(),n=s.flags,(n&65536)!==0&&(n&128)===0?(s.flags=n&-65537|128,s):null;case 5:return Va(s),null;case 13:if(Me(Oe),n=s.memoizedState,n!==null&&n.dehydrated!==null){if(s.alternate===null)throw Error(r(340));ks()}return n=s.flags,n&65536?(s.flags=n&-65537|128,s):null;case 19:return Me(Oe),null;case 4:return Ss(),null;case 10:return Fa(s.type._context),null;case 22:case 23:return Cl(),null;case 24:return null;default:return null}}var Dr=!1,lt=!1,ov=typeof WeakSet=="function"?WeakSet:Set,ee=null;function bs(n,s){var a=n.ref;if(a!==null)if(typeof a=="function")try{a(null)}catch(u){_e(n,s,u)}else a.current=null}function ml(n,s,a){try{a()}catch(u){_e(n,s,u)}}var ih=!1;function av(n,s){if(Ca=ir,n=Pu(),ya(n)){if("selectionStart"in n)var a={start:n.selectionStart,end:n.selectionEnd};else e:{a=(a=n.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 y=0,N=-1,b=-1,L=0,F=0,W=n,z=null;t:for(;;){for(var J;W!==a||f!==0&&W.nodeType!==3||(N=y+f),W!==p||u!==0&&W.nodeType!==3||(b=y+u),W.nodeType===3&&(y+=W.nodeValue.length),(J=W.firstChild)!==null;)z=W,W=J;for(;;){if(W===n)break t;if(z===a&&++L===f&&(N=y),z===p&&++F===u&&(b=y),(J=W.nextSibling)!==null)break;W=z,z=W.parentNode}W=J}a=N===-1||b===-1?null:{start:N,end:b}}else a=null}a=a||{start:0,end:0}}else a=null;for($a={focusedElem:n,selectionRange:a},ir=!1,ee=s;ee!==null;)if(s=ee,n=s.child,(s.subtreeFlags&1028)!==0&&n!==null)n.return=s,ee=n;else for(;ee!==null;){s=ee;try{var ne=s.alternate;if((s.flags&1024)!==0)switch(s.tag){case 0:case 11:case 15:break;case 1:if(ne!==null){var ie=ne.memoizedProps,Fe=ne.memoizedState,I=s.stateNode,C=I.getSnapshotBeforeUpdate(s.elementType===s.type?ie:Bt(s.type,ie),Fe);I.__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){_e(s,s.return,V)}if(n=s.sibling,n!==null){n.return=s.return,ee=n;break}ee=s.return}return ne=ih,ih=!1,ne}function Ci(n,s,a){var u=s.updateQueue;if(u=u!==null?u.lastEffect:null,u!==null){var f=u=u.next;do{if((f.tag&n)===n){var p=f.destroy;f.destroy=void 0,p!==void 0&&ml(s,a,p)}f=f.next}while(f!==u)}}function Br(n,s){if(s=s.updateQueue,s=s!==null?s.lastEffect:null,s!==null){var a=s=s.next;do{if((a.tag&n)===n){var u=a.create;a.destroy=u()}a=a.next}while(a!==s)}}function pl(n){var s=n.ref;if(s!==null){var a=n.stateNode;switch(n.tag){case 5:n=a;break;default:n=a}typeof s=="function"?s(n):s.current=n}}function rh(n){var s=n.alternate;s!==null&&(n.alternate=null,rh(s)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(s=n.stateNode,s!==null&&(delete s[Vt],delete s[pi],delete s[Ma],delete s[Hg],delete s[Wg])),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}function oh(n){return n.tag===5||n.tag===3||n.tag===4}function ah(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||oh(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function gl(n,s,a){var u=n.tag;if(u===5||u===6)n=n.stateNode,s?a.nodeType===8?a.parentNode.insertBefore(n,s):a.insertBefore(n,s):(a.nodeType===8?(s=a.parentNode,s.insertBefore(n,a)):(s=a,s.appendChild(n)),a=a._reactRootContainer,a!=null||s.onclick!==null||(s.onclick=gr));else if(u!==4&&(n=n.child,n!==null))for(gl(n,s,a),n=n.sibling;n!==null;)gl(n,s,a),n=n.sibling}function vl(n,s,a){var u=n.tag;if(u===5||u===6)n=n.stateNode,s?a.insertBefore(n,s):a.appendChild(n);else if(u!==4&&(n=n.child,n!==null))for(vl(n,s,a),n=n.sibling;n!==null;)vl(n,s,a),n=n.sibling}var nt=null,zt=!1;function En(n,s,a){for(a=a.child;a!==null;)lh(n,s,a),a=a.sibling}function lh(n,s,a){if(Kt&&typeof Kt.onCommitFiberUnmount=="function")try{Kt.onCommitFiberUnmount(Xi,a)}catch{}switch(a.tag){case 5:lt||bs(a,s);case 6:var u=nt,f=zt;nt=null,En(n,s,a),nt=u,zt=f,nt!==null&&(zt?(n=nt,a=a.stateNode,n.nodeType===8?n.parentNode.removeChild(a):n.removeChild(a)):nt.removeChild(a.stateNode));break;case 18:nt!==null&&(zt?(n=nt,a=a.stateNode,n.nodeType===8?Ia(n.parentNode,a):n.nodeType===1&&Ia(n,a),ii(n)):Ia(nt,a.stateNode));break;case 4:u=nt,f=zt,nt=a.stateNode.containerInfo,zt=!0,En(n,s,a),nt=u,zt=f;break;case 0:case 11:case 14:case 15:if(!lt&&(u=a.updateQueue,u!==null&&(u=u.lastEffect,u!==null))){f=u=u.next;do{var p=f,y=p.destroy;p=p.tag,y!==void 0&&((p&2)!==0||(p&4)!==0)&&ml(a,s,y),f=f.next}while(f!==u)}En(n,s,a);break;case 1:if(!lt&&(bs(a,s),u=a.stateNode,typeof u.componentWillUnmount=="function"))try{u.props=a.memoizedProps,u.state=a.memoizedState,u.componentWillUnmount()}catch(N){_e(a,s,N)}En(n,s,a);break;case 21:En(n,s,a);break;case 22:a.mode&1?(lt=(u=lt)||a.memoizedState!==null,En(n,s,a),lt=u):En(n,s,a);break;default:En(n,s,a)}}function ch(n){var s=n.updateQueue;if(s!==null){n.updateQueue=null;var a=n.stateNode;a===null&&(a=n.stateNode=new ov),s.forEach(function(u){var f=gv.bind(null,n,u);a.has(u)||(a.add(u),u.then(f,f))})}}function Ft(n,s){var a=s.deletions;if(a!==null)for(var u=0;u<a.length;u++){var f=a[u];try{var p=n,y=s,N=y;e:for(;N!==null;){switch(N.tag){case 5:nt=N.stateNode,zt=!1;break e;case 3:nt=N.stateNode.containerInfo,zt=!0;break e;case 4:nt=N.stateNode.containerInfo,zt=!0;break e}N=N.return}if(nt===null)throw Error(r(160));lh(p,y,f),nt=null,zt=!1;var b=f.alternate;b!==null&&(b.return=null),f.return=null}catch(L){_e(f,s,L)}}if(s.subtreeFlags&12854)for(s=s.child;s!==null;)uh(s,n),s=s.sibling}function uh(n,s){var a=n.alternate,u=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:if(Ft(s,n),Qt(n),u&4){try{Ci(3,n,n.return),Br(3,n)}catch(ie){_e(n,n.return,ie)}try{Ci(5,n,n.return)}catch(ie){_e(n,n.return,ie)}}break;case 1:Ft(s,n),Qt(n),u&512&&a!==null&&bs(a,a.return);break;case 5:if(Ft(s,n),Qt(n),u&512&&a!==null&&bs(a,a.return),n.flags&32){var f=n.stateNode;try{Gs(f,"")}catch(ie){_e(n,n.return,ie)}}if(u&4&&(f=n.stateNode,f!=null)){var p=n.memoizedProps,y=a!==null?a.memoizedProps:p,N=n.type,b=n.updateQueue;if(n.updateQueue=null,b!==null)try{N==="input"&&p.type==="radio"&&p.name!=null&&Dc(f,p),qo(N,y);var L=qo(N,p);for(y=0;y<b.length;y+=2){var F=b[y],W=b[y+1];F==="style"?Vc(f,W):F==="dangerouslySetInnerHTML"?Wc(f,W):F==="children"?Gs(f,W):O(f,F,W,L)}switch(N){case"input":Ho(f,p);break;case"textarea":Fc(f,p);break;case"select":var z=f._wrapperState.wasMultiple;f._wrapperState.wasMultiple=!!p.multiple;var J=p.value;J!=null?is(f,!!p.multiple,J,!1):z!==!!p.multiple&&(p.defaultValue!=null?is(f,!!p.multiple,p.defaultValue,!0):is(f,!!p.multiple,p.multiple?[]:"",!1))}f[pi]=p}catch(ie){_e(n,n.return,ie)}}break;case 6:if(Ft(s,n),Qt(n),u&4){if(n.stateNode===null)throw Error(r(162));f=n.stateNode,p=n.memoizedProps;try{f.nodeValue=p}catch(ie){_e(n,n.return,ie)}}break;case 3:if(Ft(s,n),Qt(n),u&4&&a!==null&&a.memoizedState.isDehydrated)try{ii(s.containerInfo)}catch(ie){_e(n,n.return,ie)}break;case 4:Ft(s,n),Qt(n);break;case 13:Ft(s,n),Qt(n),f=n.child,f.flags&8192&&(p=f.memoizedState!==null,f.stateNode.isHidden=p,!p||f.alternate!==null&&f.alternate.memoizedState!==null||(wl=ze())),u&4&&ch(n);break;case 22:if(F=a!==null&&a.memoizedState!==null,n.mode&1?(lt=(L=lt)||F,Ft(s,n),lt=L):Ft(s,n),Qt(n),u&8192){if(L=n.memoizedState!==null,(n.stateNode.isHidden=L)&&!F&&(n.mode&1)!==0)for(ee=n,F=n.child;F!==null;){for(W=ee=F;ee!==null;){switch(z=ee,J=z.child,z.tag){case 0:case 11:case 14:case 15:Ci(4,z,z.return);break;case 1:bs(z,z.return);var ne=z.stateNode;if(typeof ne.componentWillUnmount=="function"){u=z,a=z.return;try{s=u,ne.props=s.memoizedProps,ne.state=s.memoizedState,ne.componentWillUnmount()}catch(ie){_e(u,a,ie)}}break;case 5:bs(z,z.return);break;case 22:if(z.memoizedState!==null){fh(W);continue}}J!==null?(J.return=z,ee=J):fh(W)}F=F.sibling}e:for(F=null,W=n;;){if(W.tag===5){if(F===null){F=W;try{f=W.stateNode,L?(p=f.style,typeof p.setProperty=="function"?p.setProperty("display","none","important"):p.display="none"):(N=W.stateNode,b=W.memoizedProps.style,y=b!=null&&b.hasOwnProperty("display")?b.display:null,N.style.display=Kc("display",y))}catch(ie){_e(n,n.return,ie)}}}else if(W.tag===6){if(F===null)try{W.stateNode.nodeValue=L?"":W.memoizedProps}catch(ie){_e(n,n.return,ie)}}else if((W.tag!==22&&W.tag!==23||W.memoizedState===null||W===n)&&W.child!==null){W.child.return=W,W=W.child;continue}if(W===n)break e;for(;W.sibling===null;){if(W.return===null||W.return===n)break e;F===W&&(F=null),W=W.return}F===W&&(F=null),W.sibling.return=W.return,W=W.sibling}}break;case 19:Ft(s,n),Qt(n),u&4&&ch(n);break;case 21:break;default:Ft(s,n),Qt(n)}}function Qt(n){var s=n.flags;if(s&2){try{e:{for(var a=n.return;a!==null;){if(oh(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&&(Gs(f,""),u.flags&=-33);var p=ah(n);vl(n,p,f);break;case 3:case 4:var y=u.stateNode.containerInfo,N=ah(n);gl(n,N,y);break;default:throw Error(r(161))}}catch(b){_e(n,n.return,b)}n.flags&=-3}s&4096&&(n.flags&=-4097)}function lv(n,s,a){ee=n,dh(n)}function dh(n,s,a){for(var u=(n.mode&1)!==0;ee!==null;){var f=ee,p=f.child;if(f.tag===22&&u){var y=f.memoizedState!==null||Dr;if(!y){var N=f.alternate,b=N!==null&&N.memoizedState!==null||lt;N=Dr;var L=lt;if(Dr=y,(lt=b)&&!L)for(ee=f;ee!==null;)y=ee,b=y.child,y.tag===22&&y.memoizedState!==null?mh(f):b!==null?(b.return=y,ee=b):mh(f);for(;p!==null;)ee=p,dh(p),p=p.sibling;ee=f,Dr=N,lt=L}hh(n)}else(f.subtreeFlags&8772)!==0&&p!==null?(p.return=f,ee=p):hh(n)}}function hh(n){for(;ee!==null;){var s=ee;if((s.flags&8772)!==0){var a=s.alternate;try{if((s.flags&8772)!==0)switch(s.tag){case 0:case 11:case 15:lt||Br(5,s);break;case 1:var u=s.stateNode;if(s.flags&4&&!lt)if(a===null)u.componentDidMount();else{var f=s.elementType===s.type?a.memoizedProps:Bt(s.type,a.memoizedProps);u.componentDidUpdate(f,a.memoizedState,u.__reactInternalSnapshotBeforeUpdate)}var p=s.updateQueue;p!==null&&fd(s,p,u);break;case 3:var y=s.updateQueue;if(y!==null){if(a=null,s.child!==null)switch(s.child.tag){case 5:a=s.child.stateNode;break;case 1:a=s.child.stateNode}fd(s,y,a)}break;case 5:var N=s.stateNode;if(a===null&&s.flags&4){a=N;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 F=L.memoizedState;if(F!==null){var W=F.dehydrated;W!==null&&ii(W)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(r(163))}lt||s.flags&512&&pl(s)}catch(z){_e(s,s.return,z)}}if(s===n){ee=null;break}if(a=s.sibling,a!==null){a.return=s.return,ee=a;break}ee=s.return}}function fh(n){for(;ee!==null;){var s=ee;if(s===n){ee=null;break}var a=s.sibling;if(a!==null){a.return=s.return,ee=a;break}ee=s.return}}function mh(n){for(;ee!==null;){var s=ee;try{switch(s.tag){case 0:case 11:case 15:var a=s.return;try{Br(4,s)}catch(b){_e(s,a,b)}break;case 1:var u=s.stateNode;if(typeof u.componentDidMount=="function"){var f=s.return;try{u.componentDidMount()}catch(b){_e(s,f,b)}}var p=s.return;try{pl(s)}catch(b){_e(s,p,b)}break;case 5:var y=s.return;try{pl(s)}catch(b){_e(s,y,b)}}}catch(b){_e(s,s.return,b)}if(s===n){ee=null;break}var N=s.sibling;if(N!==null){N.return=s.return,ee=N;break}ee=s.return}}var cv=Math.ceil,zr=X.ReactCurrentDispatcher,yl=X.ReactCurrentOwner,Mt=X.ReactCurrentBatchConfig,je=0,Ze=null,Ve=null,st=0,bt=0,Cs=Nn(0),Qe=0,$i=null,Qn=0,Fr=0,kl=0,Ti=null,vt=null,wl=0,$s=1/0,hn=null,Ur=!1,xl=null,In=null,Hr=!1,Mn=null,Wr=0,Ei=0,jl=null,Kr=-1,Vr=0;function dt(){return(je&6)!==0?ze():Kr!==-1?Kr:Kr=ze()}function An(n){return(n.mode&1)===0?1:(je&2)!==0&&st!==0?st&-st:Vg.transition!==null?(Vr===0&&(Vr=au()),Vr):(n=Ce,n!==0||(n=window.event,n=n===void 0?16:gu(n.type)),n)}function Ut(n,s,a,u){if(50<Ei)throw Ei=0,jl=null,Error(r(185));Zs(n,a,u),((je&2)===0||n!==Ze)&&(n===Ze&&((je&2)===0&&(Fr|=a),Qe===4&&Ln(n,st)),yt(n,u),a===1&&je===0&&(s.mode&1)===0&&($s=ze()+500,wr&&Cn()))}function yt(n,s){var a=n.callbackNode;Vp(n,s);var u=tr(n,n===Ze?st:0);if(u===0)a!==null&&iu(a),n.callbackNode=null,n.callbackPriority=0;else if(s=u&-u,n.callbackPriority!==s){if(a!=null&&iu(a),s===1)n.tag===0?Kg(gh.bind(null,n)):td(gh.bind(null,n)),Fg(function(){(je&6)===0&&Cn()}),a=null;else{switch(lu(u)){case 1:a=ta;break;case 4:a=ru;break;case 16:a=Ji;break;case 536870912:a=ou;break;default:a=Ji}a=Nh(a,ph.bind(null,n))}n.callbackPriority=s,n.callbackNode=a}}function ph(n,s){if(Kr=-1,Vr=0,(je&6)!==0)throw Error(r(327));var a=n.callbackNode;if(Ts()&&n.callbackNode!==a)return null;var u=tr(n,n===Ze?st:0);if(u===0)return null;if((u&30)!==0||(u&n.expiredLanes)!==0||s)s=Gr(n,u);else{s=u;var f=je;je|=2;var p=yh();(Ze!==n||st!==s)&&(hn=null,$s=ze()+500,Jn(n,s));do try{hv();break}catch(N){vh(n,N)}while(!0);za(),zr.current=p,je=f,Ve!==null?s=0:(Ze=null,st=0,s=Qe)}if(s!==0){if(s===2&&(f=na(n),f!==0&&(u=f,s=Sl(n,f))),s===1)throw a=$i,Jn(n,0),Ln(n,u),yt(n,ze()),a;if(s===6)Ln(n,u);else{if(f=n.current.alternate,(u&30)===0&&!uv(f)&&(s=Gr(n,u),s===2&&(p=na(n),p!==0&&(u=p,s=Sl(n,p))),s===1))throw a=$i,Jn(n,0),Ln(n,u),yt(n,ze()),a;switch(n.finishedWork=f,n.finishedLanes=u,s){case 0:case 1:throw Error(r(345));case 2:Xn(n,vt,hn);break;case 3:if(Ln(n,u),(u&130023424)===u&&(s=wl+500-ze(),10<s)){if(tr(n,0)!==0)break;if(f=n.suspendedLanes,(f&u)!==u){dt(),n.pingedLanes|=n.suspendedLanes&f;break}n.timeoutHandle=Ea(Xn.bind(null,n,vt,hn),s);break}Xn(n,vt,hn);break;case 4:if(Ln(n,u),(u&4194240)===u)break;for(s=n.eventTimes,f=-1;0<u;){var y=31-Pt(u);p=1<<y,y=s[y],y>f&&(f=y),u&=~p}if(u=f,u=ze()-u,u=(120>u?120:480>u?480:1080>u?1080:1920>u?1920:3e3>u?3e3:4320>u?4320:1960*cv(u/1960))-u,10<u){n.timeoutHandle=Ea(Xn.bind(null,n,vt,hn),u);break}Xn(n,vt,hn);break;case 5:Xn(n,vt,hn);break;default:throw Error(r(329))}}}return yt(n,ze()),n.callbackNode===a?ph.bind(null,n):null}function Sl(n,s){var a=Ti;return n.current.memoizedState.isDehydrated&&(Jn(n,s).flags|=256),n=Gr(n,s),n!==2&&(s=vt,vt=a,s!==null&&Nl(s)),n}function Nl(n){vt===null?vt=n:vt.push.apply(vt,n)}function uv(n){for(var s=n;;){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(!_t(p(),f))return!1}catch{return!1}}}if(a=s.child,s.subtreeFlags&16384&&a!==null)a.return=s,s=a;else{if(s===n)break;for(;s.sibling===null;){if(s.return===null||s.return===n)return!0;s=s.return}s.sibling.return=s.return,s=s.sibling}}return!0}function Ln(n,s){for(s&=~kl,s&=~Fr,n.suspendedLanes|=s,n.pingedLanes&=~s,n=n.expirationTimes;0<s;){var a=31-Pt(s),u=1<<a;n[a]=-1,s&=~u}}function gh(n){if((je&6)!==0)throw Error(r(327));Ts();var s=tr(n,0);if((s&1)===0)return yt(n,ze()),null;var a=Gr(n,s);if(n.tag!==0&&a===2){var u=na(n);u!==0&&(s=u,a=Sl(n,u))}if(a===1)throw a=$i,Jn(n,0),Ln(n,s),yt(n,ze()),a;if(a===6)throw Error(r(345));return n.finishedWork=n.current.alternate,n.finishedLanes=s,Xn(n,vt,hn),yt(n,ze()),null}function bl(n,s){var a=je;je|=1;try{return n(s)}finally{je=a,je===0&&($s=ze()+500,wr&&Cn())}}function Yn(n){Mn!==null&&Mn.tag===0&&(je&6)===0&&Ts();var s=je;je|=1;var a=Mt.transition,u=Ce;try{if(Mt.transition=null,Ce=1,n)return n()}finally{Ce=u,Mt.transition=a,je=s,(je&6)===0&&Cn()}}function Cl(){bt=Cs.current,Me(Cs)}function Jn(n,s){n.finishedWork=null,n.finishedLanes=0;var a=n.timeoutHandle;if(a!==-1&&(n.timeoutHandle=-1,zg(a)),Ve!==null)for(a=Ve.return;a!==null;){var u=a;switch(Oa(u),u.tag){case 1:u=u.type.childContextTypes,u!=null&&yr();break;case 3:Ss(),Me(mt),Me(rt),qa();break;case 5:Va(u);break;case 4:Ss();break;case 13:Me(Oe);break;case 19:Me(Oe);break;case 10:Fa(u.type._context);break;case 22:case 23:Cl()}a=a.return}if(Ze=n,Ve=n=Rn(n.current,null),st=bt=s,Qe=0,$i=null,kl=Fr=Qn=0,vt=Ti=null,Vn!==null){for(s=0;s<Vn.length;s++)if(a=Vn[s],u=a.interleaved,u!==null){a.interleaved=null;var f=u.next,p=a.pending;if(p!==null){var y=p.next;p.next=f,u.next=y}a.pending=u}Vn=null}return n}function vh(n,s){do{var a=Ve;try{if(za(),Ir.current=Rr,Mr){for(var u=Pe.memoizedState;u!==null;){var f=u.queue;f!==null&&(f.pending=null),u=u.next}Mr=!1}if(qn=0,Xe=qe=Pe=null,xi=!1,ji=0,yl.current=null,a===null||a.return===null){Qe=1,$i=s,Ve=null;break}e:{var p=n,y=a.return,N=a,b=s;if(s=st,N.flags|=32768,b!==null&&typeof b=="object"&&typeof b.then=="function"){var L=b,F=N,W=F.tag;if((F.mode&1)===0&&(W===0||W===11||W===15)){var z=F.alternate;z?(F.updateQueue=z.updateQueue,F.memoizedState=z.memoizedState,F.lanes=z.lanes):(F.updateQueue=null,F.memoizedState=null)}var J=Ud(y);if(J!==null){J.flags&=-257,Hd(J,y,N,p,s),J.mode&1&&Fd(p,L,s),s=J,b=L;var ne=s.updateQueue;if(ne===null){var ie=new Set;ie.add(b),s.updateQueue=ie}else ne.add(b);break e}else{if((s&1)===0){Fd(p,L,s),$l();break e}b=Error(r(426))}}else if(Le&&N.mode&1){var Fe=Ud(y);if(Fe!==null){(Fe.flags&65536)===0&&(Fe.flags|=256),Hd(Fe,y,N,p,s),Da(Ns(b,N));break e}}p=b=Ns(b,N),Qe!==4&&(Qe=2),Ti===null?Ti=[p]:Ti.push(p),p=y;do{switch(p.tag){case 3:p.flags|=65536,s&=-s,p.lanes|=s;var I=Bd(p,b,s);hd(p,I);break e;case 1:N=b;var C=p.type,A=p.stateNode;if((p.flags&128)===0&&(typeof C.getDerivedStateFromError=="function"||A!==null&&typeof A.componentDidCatch=="function"&&(In===null||!In.has(A)))){p.flags|=65536,s&=-s,p.lanes|=s;var V=zd(p,N,s);hd(p,V);break e}}p=p.return}while(p!==null)}wh(a)}catch(re){s=re,Ve===a&&a!==null&&(Ve=a=a.return);continue}break}while(!0)}function yh(){var n=zr.current;return zr.current=Rr,n===null?Rr:n}function $l(){(Qe===0||Qe===3||Qe===2)&&(Qe=4),Ze===null||(Qn&268435455)===0&&(Fr&268435455)===0||Ln(Ze,st)}function Gr(n,s){var a=je;je|=2;var u=yh();(Ze!==n||st!==s)&&(hn=null,Jn(n,s));do try{dv();break}catch(f){vh(n,f)}while(!0);if(za(),je=a,zr.current=u,Ve!==null)throw Error(r(261));return Ze=null,st=0,Qe}function dv(){for(;Ve!==null;)kh(Ve)}function hv(){for(;Ve!==null&&!_p();)kh(Ve)}function kh(n){var s=Sh(n.alternate,n,bt);n.memoizedProps=n.pendingProps,s===null?wh(n):Ve=s,yl.current=null}function wh(n){var s=n;do{var a=s.alternate;if(n=s.return,(s.flags&32768)===0){if(a=iv(a,s,bt),a!==null){Ve=a;return}}else{if(a=rv(a,s),a!==null){a.flags&=32767,Ve=a;return}if(n!==null)n.flags|=32768,n.subtreeFlags=0,n.deletions=null;else{Qe=6,Ve=null;return}}if(s=s.sibling,s!==null){Ve=s;return}Ve=s=n}while(s!==null);Qe===0&&(Qe=5)}function Xn(n,s,a){var u=Ce,f=Mt.transition;try{Mt.transition=null,Ce=1,fv(n,s,a,u)}finally{Mt.transition=f,Ce=u}return null}function fv(n,s,a,u){do Ts();while(Mn!==null);if((je&6)!==0)throw Error(r(327));a=n.finishedWork;var f=n.finishedLanes;if(a===null)return null;if(n.finishedWork=null,n.finishedLanes=0,a===n.current)throw Error(r(177));n.callbackNode=null,n.callbackPriority=0;var p=a.lanes|a.childLanes;if(Gp(n,p),n===Ze&&(Ve=Ze=null,st=0),(a.subtreeFlags&2064)===0&&(a.flags&2064)===0||Hr||(Hr=!0,Nh(Ji,function(){return Ts(),null})),p=(a.flags&15990)!==0,(a.subtreeFlags&15990)!==0||p){p=Mt.transition,Mt.transition=null;var y=Ce;Ce=1;var N=je;je|=4,yl.current=null,av(n,a),uh(a,n),Lg($a),ir=!!Ca,$a=Ca=null,n.current=a,lv(a),Dp(),je=N,Ce=y,Mt.transition=p}else n.current=a;if(Hr&&(Hr=!1,Mn=n,Wr=f),p=n.pendingLanes,p===0&&(In=null),Fp(a.stateNode),yt(n,ze()),s!==null)for(u=n.onRecoverableError,a=0;a<s.length;a++)f=s[a],u(f.value,{componentStack:f.stack,digest:f.digest});if(Ur)throw Ur=!1,n=xl,xl=null,n;return(Wr&1)!==0&&n.tag!==0&&Ts(),p=n.pendingLanes,(p&1)!==0?n===jl?Ei++:(Ei=0,jl=n):Ei=0,Cn(),null}function Ts(){if(Mn!==null){var n=lu(Wr),s=Mt.transition,a=Ce;try{if(Mt.transition=null,Ce=16>n?16:n,Mn===null)var u=!1;else{if(n=Mn,Mn=null,Wr=0,(je&6)!==0)throw Error(r(331));var f=je;for(je|=4,ee=n.current;ee!==null;){var p=ee,y=p.child;if((ee.flags&16)!==0){var N=p.deletions;if(N!==null){for(var b=0;b<N.length;b++){var L=N[b];for(ee=L;ee!==null;){var F=ee;switch(F.tag){case 0:case 11:case 15:Ci(8,F,p)}var W=F.child;if(W!==null)W.return=F,ee=W;else for(;ee!==null;){F=ee;var z=F.sibling,J=F.return;if(rh(F),F===L){ee=null;break}if(z!==null){z.return=J,ee=z;break}ee=J}}}var ne=p.alternate;if(ne!==null){var ie=ne.child;if(ie!==null){ne.child=null;do{var Fe=ie.sibling;ie.sibling=null,ie=Fe}while(ie!==null)}}ee=p}}if((p.subtreeFlags&2064)!==0&&y!==null)y.return=p,ee=y;else e:for(;ee!==null;){if(p=ee,(p.flags&2048)!==0)switch(p.tag){case 0:case 11:case 15:Ci(9,p,p.return)}var I=p.sibling;if(I!==null){I.return=p.return,ee=I;break e}ee=p.return}}var C=n.current;for(ee=C;ee!==null;){y=ee;var A=y.child;if((y.subtreeFlags&2064)!==0&&A!==null)A.return=y,ee=A;else e:for(y=C;ee!==null;){if(N=ee,(N.flags&2048)!==0)try{switch(N.tag){case 0:case 11:case 15:Br(9,N)}}catch(re){_e(N,N.return,re)}if(N===y){ee=null;break e}var V=N.sibling;if(V!==null){V.return=N.return,ee=V;break e}ee=N.return}}if(je=f,Cn(),Kt&&typeof Kt.onPostCommitFiberRoot=="function")try{Kt.onPostCommitFiberRoot(Xi,n)}catch{}u=!0}return u}finally{Ce=a,Mt.transition=s}}return!1}function xh(n,s,a){s=Ns(a,s),s=Bd(n,s,1),n=Tn(n,s,1),s=dt(),n!==null&&(Zs(n,1,s),yt(n,s))}function _e(n,s,a){if(n.tag===3)xh(n,n,a);else for(;s!==null;){if(s.tag===3){xh(s,n,a);break}else if(s.tag===1){var u=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(In===null||!In.has(u))){n=Ns(a,n),n=zd(s,n,1),s=Tn(s,n,1),n=dt(),s!==null&&(Zs(s,1,n),yt(s,n));break}}s=s.return}}function mv(n,s,a){var u=n.pingCache;u!==null&&u.delete(s),s=dt(),n.pingedLanes|=n.suspendedLanes&a,Ze===n&&(st&a)===a&&(Qe===4||Qe===3&&(st&130023424)===st&&500>ze()-wl?Jn(n,0):kl|=a),yt(n,s)}function jh(n,s){s===0&&((n.mode&1)===0?s=1:(s=er,er<<=1,(er&130023424)===0&&(er=4194304)));var a=dt();n=cn(n,s),n!==null&&(Zs(n,s,a),yt(n,a))}function pv(n){var s=n.memoizedState,a=0;s!==null&&(a=s.retryLane),jh(n,a)}function gv(n,s){var a=0;switch(n.tag){case 13:var u=n.stateNode,f=n.memoizedState;f!==null&&(a=f.retryLane);break;case 19:u=n.stateNode;break;default:throw Error(r(314))}u!==null&&u.delete(s),jh(n,a)}var Sh;Sh=function(n,s,a){if(n!==null)if(n.memoizedProps!==s.pendingProps||mt.current)gt=!0;else{if((n.lanes&a)===0&&(s.flags&128)===0)return gt=!1,sv(n,s,a);gt=(n.flags&131072)!==0}else gt=!1,Le&&(s.flags&1048576)!==0&&nd(s,jr,s.index);switch(s.lanes=0,s.tag){case 2:var u=s.type;_r(n,s),n=s.pendingProps;var f=gs(s,rt.current);js(s,a),f=Ja(null,s,u,n,f,a);var p=Xa();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,pt(u)?(p=!0,kr(s)):p=!1,s.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,Wa(s),f.updater=Or,s.stateNode=f,f._reactInternals=s,il(s,u,n,a),s=ll(null,s,u,!0,p,a)):(s.tag=0,Le&&p&&Ra(s),ut(null,s,f,a),s=s.child),s;case 16:u=s.elementType;e:{switch(_r(n,s),n=s.pendingProps,f=u._init,u=f(u._payload),s.type=u,f=s.tag=yv(u),n=Bt(u,n),f){case 0:s=al(null,s,u,n,a);break e;case 1:s=Qd(null,s,u,n,a);break e;case 11:s=Wd(null,s,u,n,a);break e;case 14:s=Kd(null,s,u,Bt(u.type,n),a);break e}throw Error(r(306,u,""))}return s;case 0:return u=s.type,f=s.pendingProps,f=s.elementType===u?f:Bt(u,f),al(n,s,u,f,a);case 1:return u=s.type,f=s.pendingProps,f=s.elementType===u?f:Bt(u,f),Qd(n,s,u,f,a);case 3:e:{if(Yd(s),n===null)throw Error(r(387));u=s.pendingProps,p=s.memoizedState,f=p.element,dd(n,s),Tr(s,u,null,a);var y=s.memoizedState;if(u=y.element,p.isDehydrated)if(p={element:u,isDehydrated:!1,cache:y.cache,pendingSuspenseBoundaries:y.pendingSuspenseBoundaries,transitions:y.transitions},s.updateQueue.baseState=p,s.memoizedState=p,s.flags&256){f=Ns(Error(r(423)),s),s=Jd(n,s,u,a,f);break e}else if(u!==f){f=Ns(Error(r(424)),s),s=Jd(n,s,u,a,f);break e}else for(Nt=Sn(s.stateNode.containerInfo.firstChild),St=s,Le=!0,Dt=null,a=cd(s,null,u,a),s.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(ks(),u===f){s=dn(n,s,a);break e}ut(n,s,u,a)}s=s.child}return s;case 5:return md(s),n===null&&_a(s),u=s.type,f=s.pendingProps,p=n!==null?n.memoizedProps:null,y=f.children,Ta(u,f)?y=null:p!==null&&Ta(u,p)&&(s.flags|=32),qd(n,s),ut(n,s,y,a),s.child;case 6:return n===null&&_a(s),null;case 13:return Xd(n,s,a);case 4:return Ka(s,s.stateNode.containerInfo),u=s.pendingProps,n===null?s.child=ws(s,null,u,a):ut(n,s,u,a),s.child;case 11:return u=s.type,f=s.pendingProps,f=s.elementType===u?f:Bt(u,f),Wd(n,s,u,f,a);case 7:return ut(n,s,s.pendingProps,a),s.child;case 8:return ut(n,s,s.pendingProps.children,a),s.child;case 12:return ut(n,s,s.pendingProps.children,a),s.child;case 10:e:{if(u=s.type._context,f=s.pendingProps,p=s.memoizedProps,y=f.value,Te(br,u._currentValue),u._currentValue=y,p!==null)if(_t(p.value,y)){if(p.children===f.children&&!mt.current){s=dn(n,s,a);break e}}else for(p=s.child,p!==null&&(p.return=s);p!==null;){var N=p.dependencies;if(N!==null){y=p.child;for(var b=N.firstContext;b!==null;){if(b.context===u){if(p.tag===1){b=un(-1,a&-a),b.tag=2;var L=p.updateQueue;if(L!==null){L=L.shared;var F=L.pending;F===null?b.next=b:(b.next=F.next,F.next=b),L.pending=b}}p.lanes|=a,b=p.alternate,b!==null&&(b.lanes|=a),Ua(p.return,a,s),N.lanes|=a;break}b=b.next}}else if(p.tag===10)y=p.type===s.type?null:p.child;else if(p.tag===18){if(y=p.return,y===null)throw Error(r(341));y.lanes|=a,N=y.alternate,N!==null&&(N.lanes|=a),Ua(y,a,s),y=p.sibling}else y=p.child;if(y!==null)y.return=p;else for(y=p;y!==null;){if(y===s){y=null;break}if(p=y.sibling,p!==null){p.return=y.return,y=p;break}y=y.return}p=y}ut(n,s,f.children,a),s=s.child}return s;case 9:return f=s.type,u=s.pendingProps.children,js(s,a),f=Et(f),u=u(f),s.flags|=1,ut(n,s,u,a),s.child;case 14:return u=s.type,f=Bt(u,s.pendingProps),f=Bt(u.type,f),Kd(n,s,u,f,a);case 15:return Vd(n,s,s.type,s.pendingProps,a);case 17:return u=s.type,f=s.pendingProps,f=s.elementType===u?f:Bt(u,f),_r(n,s),s.tag=1,pt(u)?(n=!0,kr(s)):n=!1,js(s,a),_d(s,u,f),il(s,u,f,a),ll(null,s,u,!0,n,a);case 19:return eh(n,s,a);case 22:return Gd(n,s,a)}throw Error(r(156,s.tag))};function Nh(n,s){return su(n,s)}function vv(n,s,a,u){this.tag=n,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 At(n,s,a,u){return new vv(n,s,a,u)}function Tl(n){return n=n.prototype,!(!n||!n.isReactComponent)}function yv(n){if(typeof n=="function")return Tl(n)?1:0;if(n!=null){if(n=n.$$typeof,n===be)return 11;if(n===Y)return 14}return 2}function Rn(n,s){var a=n.alternate;return a===null?(a=At(n.tag,s,n.key,n.mode),a.elementType=n.elementType,a.type=n.type,a.stateNode=n.stateNode,a.alternate=n,n.alternate=a):(a.pendingProps=s,a.type=n.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=n.flags&14680064,a.childLanes=n.childLanes,a.lanes=n.lanes,a.child=n.child,a.memoizedProps=n.memoizedProps,a.memoizedState=n.memoizedState,a.updateQueue=n.updateQueue,s=n.dependencies,a.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},a.sibling=n.sibling,a.index=n.index,a.ref=n.ref,a}function qr(n,s,a,u,f,p){var y=2;if(u=n,typeof n=="function")Tl(n)&&(y=1);else if(typeof n=="string")y=5;else e:switch(n){case Q:return Zn(a.children,f,p,s);case oe:y=8,f|=8;break;case G:return n=At(12,a,s,f|2),n.elementType=G,n.lanes=p,n;case te:return n=At(13,a,s,f),n.elementType=te,n.lanes=p,n;case P:return n=At(19,a,s,f),n.elementType=P,n.lanes=p,n;case Z:return Qr(a,f,p,s);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case ge:y=10;break e;case Re:y=9;break e;case be:y=11;break e;case Y:y=14;break e;case ae:y=16,u=null;break e}throw Error(r(130,n==null?n:typeof n,""))}return s=At(y,a,s,f),s.elementType=n,s.type=u,s.lanes=p,s}function Zn(n,s,a,u){return n=At(7,n,u,s),n.lanes=a,n}function Qr(n,s,a,u){return n=At(22,n,u,s),n.elementType=Z,n.lanes=a,n.stateNode={isHidden:!1},n}function El(n,s,a){return n=At(6,n,null,s),n.lanes=a,n}function Il(n,s,a){return s=At(4,n.children!==null?n.children:[],n.key,s),s.lanes=a,s.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},s}function kv(n,s,a,u,f){this.tag=s,this.containerInfo=n,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=sa(0),this.expirationTimes=sa(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=sa(0),this.identifierPrefix=u,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function Ml(n,s,a,u,f,p,y,N,b){return n=new kv(n,s,a,N,b),s===1?(s=1,p===!0&&(s|=8)):s=0,p=At(3,null,null,s),n.current=p,p.stateNode=n,p.memoizedState={element:u,isDehydrated:a,cache:null,transitions:null,pendingSuspenseBoundaries:null},Wa(p),n}function wv(n,s,a){var u=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:_,key:u==null?null:""+u,children:n,containerInfo:s,implementation:a}}function bh(n){if(!n)return bn;n=n._reactInternals;e:{if(Fn(n)!==n||n.tag!==1)throw Error(r(170));var s=n;do{switch(s.tag){case 3:s=s.stateNode.context;break e;case 1:if(pt(s.type)){s=s.stateNode.__reactInternalMemoizedMergedChildContext;break e}}s=s.return}while(s!==null);throw Error(r(171))}if(n.tag===1){var a=n.type;if(pt(a))return Zu(n,a,s)}return s}function Ch(n,s,a,u,f,p,y,N,b){return n=Ml(a,u,!0,n,f,p,y,N,b),n.context=bh(null),a=n.current,u=dt(),f=An(a),p=un(u,f),p.callback=s??null,Tn(a,p,f),n.current.lanes=f,Zs(n,f,u),yt(n,u),n}function Yr(n,s,a,u){var f=s.current,p=dt(),y=An(f);return a=bh(a),s.context===null?s.context=a:s.pendingContext=a,s=un(p,y),s.payload={element:n},u=u===void 0?null:u,u!==null&&(s.callback=u),n=Tn(f,s,y),n!==null&&(Ut(n,f,y,p),$r(n,f,y)),y}function Jr(n){if(n=n.current,!n.child)return null;switch(n.child.tag){case 5:return n.child.stateNode;default:return n.child.stateNode}}function $h(n,s){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var a=n.retryLane;n.retryLane=a!==0&&a<s?a:s}}function Al(n,s){$h(n,s),(n=n.alternate)&&$h(n,s)}function xv(){return null}var Th=typeof reportError=="function"?reportError:function(n){console.error(n)};function Ll(n){this._internalRoot=n}Xr.prototype.render=Ll.prototype.render=function(n){var s=this._internalRoot;if(s===null)throw Error(r(409));Yr(n,s,null,null)},Xr.prototype.unmount=Ll.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var s=n.containerInfo;Yn(function(){Yr(null,n,null,null)}),s[rn]=null}};function Xr(n){this._internalRoot=n}Xr.prototype.unstable_scheduleHydration=function(n){if(n){var s=du();n={blockedOn:null,target:n,priority:s};for(var a=0;a<wn.length&&s!==0&&s<wn[a].priority;a++);wn.splice(a,0,n),a===0&&mu(n)}};function Rl(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function Zr(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11&&(n.nodeType!==8||n.nodeValue!==" react-mount-point-unstable "))}function Eh(){}function jv(n,s,a,u,f){if(f){if(typeof u=="function"){var p=u;u=function(){var L=Jr(y);p.call(L)}}var y=Ch(s,u,n,0,null,!1,!1,"",Eh);return n._reactRootContainer=y,n[rn]=y.current,fi(n.nodeType===8?n.parentNode:n),Yn(),y}for(;f=n.lastChild;)n.removeChild(f);if(typeof u=="function"){var N=u;u=function(){var L=Jr(b);N.call(L)}}var b=Ml(n,0,!1,null,null,!1,!1,"",Eh);return n._reactRootContainer=b,n[rn]=b.current,fi(n.nodeType===8?n.parentNode:n),Yn(function(){Yr(s,b,a,u)}),b}function eo(n,s,a,u,f){var p=a._reactRootContainer;if(p){var y=p;if(typeof f=="function"){var N=f;f=function(){var b=Jr(y);N.call(b)}}Yr(s,y,n,f)}else y=jv(a,s,n,f,u);return Jr(y)}cu=function(n){switch(n.tag){case 3:var s=n.stateNode;if(s.current.memoizedState.isDehydrated){var a=Xs(s.pendingLanes);a!==0&&(ia(s,a|1),yt(s,ze()),(je&6)===0&&($s=ze()+500,Cn()))}break;case 13:Yn(function(){var u=cn(n,1);if(u!==null){var f=dt();Ut(u,n,1,f)}}),Al(n,1)}},ra=function(n){if(n.tag===13){var s=cn(n,134217728);if(s!==null){var a=dt();Ut(s,n,134217728,a)}Al(n,134217728)}},uu=function(n){if(n.tag===13){var s=An(n),a=cn(n,s);if(a!==null){var u=dt();Ut(a,n,s,u)}Al(n,s)}},du=function(){return Ce},hu=function(n,s){var a=Ce;try{return Ce=n,s()}finally{Ce=a}},Jo=function(n,s,a){switch(s){case"input":if(Ho(n,a),s=a.name,a.type==="radio"&&s!=null){for(a=n;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!==n&&u.form===n.form){var f=vr(u);if(!f)throw Error(r(90));Pc(u),Ho(u,f)}}}break;case"textarea":Fc(n,a);break;case"select":s=a.value,s!=null&&is(n,!!a.multiple,s,!1)}},Yc=bl,Jc=Yn;var Sv={usingClientEntryPoint:!1,Events:[gi,ms,vr,qc,Qc,bl]},Ii={findFiberByHostInstance:Un,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Nv={bundleType:Ii.bundleType,version:Ii.version,rendererPackageName:Ii.rendererPackageName,rendererConfig:Ii.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:X.ReactCurrentDispatcher,findHostInstanceByFiber:function(n){return n=tu(n),n===null?null:n.stateNode},findFiberByHostInstance:Ii.findFiberByHostInstance||xv,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 to=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!to.isDisabled&&to.supportsFiber)try{Xi=to.inject(Nv),Kt=to}catch{}}return kt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Sv,kt.createPortal=function(n,s){var a=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Rl(s))throw Error(r(200));return wv(n,s,null,a)},kt.createRoot=function(n,s){if(!Rl(n))throw Error(r(299));var a=!1,u="",f=Th;return s!=null&&(s.unstable_strictMode===!0&&(a=!0),s.identifierPrefix!==void 0&&(u=s.identifierPrefix),s.onRecoverableError!==void 0&&(f=s.onRecoverableError)),s=Ml(n,1,!1,null,null,a,!1,u,f),n[rn]=s.current,fi(n.nodeType===8?n.parentNode:n),new Ll(s)},kt.findDOMNode=function(n){if(n==null)return null;if(n.nodeType===1)return n;var s=n._reactInternals;if(s===void 0)throw typeof n.render=="function"?Error(r(188)):(n=Object.keys(n).join(","),Error(r(268,n)));return n=tu(s),n=n===null?null:n.stateNode,n},kt.flushSync=function(n){return Yn(n)},kt.hydrate=function(n,s,a){if(!Zr(s))throw Error(r(200));return eo(null,n,s,!0,a)},kt.hydrateRoot=function(n,s,a){if(!Rl(n))throw Error(r(405));var u=a!=null&&a.hydratedSources||null,f=!1,p="",y=Th;if(a!=null&&(a.unstable_strictMode===!0&&(f=!0),a.identifierPrefix!==void 0&&(p=a.identifierPrefix),a.onRecoverableError!==void 0&&(y=a.onRecoverableError)),s=Ch(s,null,n,1,a??null,f,!1,p,y),n[rn]=s.current,fi(n),u)for(n=0;n<u.length;n++)a=u[n],f=a._getVersion,f=f(a._source),s.mutableSourceEagerHydrationData==null?s.mutableSourceEagerHydrationData=[a,f]:s.mutableSourceEagerHydrationData.push(a,f);return new Xr(s)},kt.render=function(n,s,a){if(!Zr(s))throw Error(r(200));return eo(null,n,s,!1,a)},kt.unmountComponentAtNode=function(n){if(!Zr(n))throw Error(r(40));return n._reactRootContainer?(Yn(function(){eo(null,null,n,!1,function(){n._reactRootContainer=null,n[rn]=null})}),!0):!1},kt.unstable_batchedUpdates=bl,kt.unstable_renderSubtreeIntoContainer=function(n,s,a,u){if(!Zr(a))throw Error(r(200));if(n==null||n._reactInternals===void 0)throw Error(r(38));return eo(n,s,a,!1,u)},kt.version="18.3.1-next-f1338f8080-20240426",kt}var _h;function Xf(){if(_h)return _l.exports;_h=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),_l.exports=Lv(),_l.exports}var Dh;function Rv(){if(Dh)return no;Dh=1;var e=Xf();return no.createRoot=e.createRoot,no.hydrateRoot=e.hydrateRoot,no}var Ov=Rv(),k=uc();const As="teamtrail",ve={slug:As,name:"Teamtrail",category:"The trail map for AI coding agents",tagline:"You pick the destination. Your agents walk the trail.",assistant:{name:"Scout"},labelPrefix:As,dataDir:`.${As}`,apiPrefix:`/__${As}`,noRegisterEnv:`${As.toUpperCase()}_NO_REGISTER`},To=`${As}.prefs`,Eo=e=>`${ve.labelPrefix}:${e}`,dc=Eo("map"),hc=Eo("hitl"),Pv=e=>e==="task"||e==="execute",fc=Eo("plan-only"),go=["research","prototype","junction","task","execute"],Io=[...go,"review"],ns="plan+execute",_v=["verifying","rework","blocked"],mc=["off","checks","checks+review","checks+review+human"],Zf=e=>mc.find(t=>t===e);function Hi(e){return e.type==="junction"||e.type==="prototype"?"hitl":e.type==="research"?"afk":e.hitl?"hitl":"afk"}const Dv=["task","execute"];function em(e,t,r=ns){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=t.get(l))==null?void 0:c.state)==="open"})?"blocked":"frontier"}function Fs(e,t=ns){const r=new Map(e.map(o=>[o.id,o]));return new Map(e.map(o=>[o.id,em(o,r,t)]))}const Ue=200,Ge=56;function Bh(e,t="LR",r=ns){var be;const o=t==="LR"?330:124,l=t==="LR"?112:262,c=Fs(e,r),d=new Map(e.map(te=>[te.id,te])),h=new Map,g=new Set,m=te=>{if(h.has(te))return h.get(te);if(g.has(te))return 0;g.add(te);const P=d.get(te),Y=P&&P.blockedBy.length?1+Math.max(...P.blockedBy.filter(ae=>d.has(ae)).map(m),-1):0;return g.delete(te),h.set(te,Y),Y},v=e.filter(te=>c.get(te.id)!=="out-of-scope"),w=e.filter(te=>c.get(te.id)==="out-of-scope"),x=[];for(const te of v)(x[be=m(te.id)]??(x[be]=[])).push(te);const j=[],T=new Map;let S=0;x.forEach(te=>{te&&(te.sort((P,Y)=>{const ae=Z=>{const U=Z.blockedBy.map(B=>T.get(B)).filter(B=>B!==void 0);return U.length?U.reduce((B,H)=>B+H,0)/U.length:Z.createdAt/1e12};return ae(P)-ae(Y)||P.createdAt-Y.createdAt}),S=Math.max(S,te.length),te.forEach((P,Y)=>T.set(P.id,Y)))}),x.forEach((te,P)=>{if(!te)return;const Y=(S-te.length)*l/2;te.forEach((ae,Z)=>{const U=P*o,B=Y+Z*l;j.push({ticket:ae,state:c.get(ae.id),layer:P,x:t==="LR"?U:B,y:t==="LR"?B:U})})});const M=Math.max(x.length,1)*o-(o-(t==="LR"?Ue:Ge)),R=Math.max(S,1)*l-(l-(t==="LR"?Ge:Ue)),O=t==="LR"?M:R,X=t==="LR"?R:M,se=X+54,_=Math.max(1,Math.floor((O+24)/(Ue+24)));w.forEach((te,P)=>{j.push({ticket:te,state:"out-of-scope",layer:-1,x:P%_*(Ue+24),y:se+Math.floor(P/_)*(Ge+16)})});const Q=[],oe=new Map(j.map(te=>[te.ticket.id,te]));for(const te of j)for(const P of te.ticket.blockedBy){const Y=oe.get(P);Y&&Q.push({from:Y,to:te})}const G=Math.ceil(w.length/_),ge=Math.max(O,Math.min(w.length,_)*(Ue+24)-24),Re=w.length?se+G*(Ge+16)-16:X;return{direction:t,nodes:j,edges:Q,width:ge,graphH:X,quarantineY:se,height:Re,quarantineH:G*(Ge+16)+24}}const tm=["fast","balanced","strongest"],nm=e=>tm.includes(e),pc={research:"fast",task:"balanced",execute:"balanced",junction:"strongest",prototype:"strongest",review:"strongest"};function Bv(e,t){var r,o;return((o=(r=t.modelMatching)==null?void 0:r.tiers)==null?void 0:o[e.type])??pc[e.type]}function zv(e){return Object.fromEntries(Io.map(t=>[t,Bv({type:t},e)]))}const Fv=["holding","challenged","invalidated","confirmed"],Uv=e=>Fv.includes(e),sm=ve.labelPrefix,Hv=new RegExp(`^-\\s+(?:\\[([a-z]+)\\]\\s+)?(.*?)\\s*(?:<!-- ${sm}:asm (\\{.*\\}) -->)?\\s*$`),Wv=1e3,Kv=e=>e.replace(/--/g,"-\\u002d"),Vv=e=>e.replace(/\s*\n\s*/g," ").trim();function Gv(e){const t={id:e.id,tickets:e.tickets,...e.source?{source:e.source}:{},...e.challenge?{challenge:{...e.challenge,evidence:e.challenge.evidence.slice(0,Wv)}}:{},...e.decidedBy?{decidedBy:e.decidedBy}:{}};return`- [${e.status}] ${Vv(e.text)} <!-- ${sm}:asm ${Kv(JSON.stringify(t))} -->`}function qv(e){const t=e.map(Qv);let r=Math.max(0,...t.map(o=>Jv(o.id)))+1;return t.map(o=>o.id?o:{...o,id:`S-${r++}`})}function Qv(e){const t=e.match(Hv),r=t==null?void 0:t[1],o=(t==null?void 0:t[2])??e.replace(/^-\s+/,""),l=Yv(t==null?void 0:t[3]);return{id:l.id??"",text:o,status:Uv(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 Yv(e){if(!e)return{};try{const t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}function Jv(e){const t=e==null?void 0:e.match(/^S-(\d+)$/);return t?Number(t[1]):0}const im=[["destination","Destination"],["notes","Notes"],["assumptions","Assumptions"],["decisions","Decisions so far"],["unspecified","Not yet specified"],["outOfScope","Out of scope"]],Xv=Object.fromEntries(im),Zv=/^-\s+(?:\[?([#A-Z0-9-]+)\]?:?\s+)?(.*)$/;function ey(e){var o;const t=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(Gv).join(`
|
|
49
|
+
`)}`]:[],`## Decisions so far
|
|
50
|
+
|
|
51
|
+
${r(e.decisions)}`,`## Not yet specified
|
|
52
|
+
|
|
53
|
+
${t(e.unspecified)}`,`## Out of scope
|
|
54
|
+
|
|
55
|
+
${t(e.outOfScope)}`].join(`
|
|
56
|
+
|
|
57
|
+
`)+`
|
|
58
|
+
`}function ty(e){var o;const t={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=im.find(([,w])=>w.toLowerCase()===d))==null?void 0:o[0];if(!g)continue;const m=/^_none yet\._$/i.test(h),v=m?[]:h.split(`
|
|
60
|
+
`).map(w=>w.trim()).filter(w=>w.startsWith("- "));g==="destination"?t.destination=h:g==="notes"?t.notes=m?"":h:g==="assumptions"?t.assumptions=qv(v):g==="decisions"?t.decisions=v.map(w=>{const x=w.match(Zv);return x&&x[1]&&/\d/.test(x[1])?{ticketKey:x[1],text:x[2]}:{text:w.slice(2)}}):t[g]=v.map(w=>w.slice(2))}return t}const Mo={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"]},ny=(e,t)=>`${e[0].toUpperCase()}${e.slice(1)} ${t}/${Mo[e].length}`;async function sy(e,t,r={}){var d,h,g;const o=iy(t,t.mode??ns),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 v=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,v),await((h=r.onTicketCreated)==null?void 0:h.call(r,v,m.ref))}for(const m of o.tickets)for(const v of m.blockedBy??[]){const w=c.get(v),x=c.get(m.ref);w&&(await e.addBlocking(l.id,w.id,x.id),await((g=r.onEdgeWired)==null?void 0:g.call(r,w,x)))}return{map:l,tickets:[...c.values()]}}function iy(e,t){if(t==="plan+execute")return{...e,mode:t};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:t,tickets:e.tickets.filter(l=>!r.has(l.ref)).map(l=>({...l,blockedBy:[...new Set(o(l.blockedBy??[]))]}))}}class ry{constructor(){ue(this,"tails",new Map)}run(t,r){const l=(this.tails.get(t)??Promise.resolve()).catch(()=>{}).then(r);return this.tails.set(t,l),l.finally(()=>this.tails.get(t)===l&&this.tails.delete(t)).catch(()=>{}),l}}class Be extends Error{}const oy={frontier:"ready",blocked:"backlog",parked:"backlog",claimed:"working",verifying:"verifying",rework:"rework",held:"blocked",decided:"done","out-of-scope":"cancelled"};function ay(e,t,r=ns){return oy[em(e,t,r)]}const ly=["backlog","ready","working","verifying","rework","blocked"],Ai=["agent","trail lead"],cy=[{event:"claim",from:["ready","rework"],to:["working"],actors:Ai},{event:"release",from:["working"],to:["ready","rework"],actors:Ai},{event:"expire",from:["working"],to:["ready","rework"],actors:["engine","trail lead"]},{event:"complete",from:["backlog","ready","working","rework"],to:["done"],actors:Ai},{event:"submit",from:["working"],to:["verifying"],actors:Ai},{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:ly,to:["cancelled"],actors:[...Ai,"engine"]},{event:"reopen",from:["done","cancelled"],to:["ready"],actors:["trail lead"]}],uy=e=>cy.find(t=>t.event===e),dy=new ry;function hy(e,t,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 t.status==="rework"?"rework":"ready";throw new Be(`${e.event} needs a target: ${e.to.join(" or ")}`)}async function fy(e,t,r,o){const{to:l,actor:c}=o,d=async h=>{(r.status??null)!==h&&await e.setMeta(t,r.id,{status:h})};switch(l){case"working":r.assignee!==c&&await e.assign(t,r.id,c);return;case"ready":case"rework":r.state==="closed"&&await e.reopen(t,r.id),await d(l==="rework"?"rework":null),r.assignee&&await e.assign(t,r.id,null);return;case"verifying":case"blocked":await d(l);return;case"done":case"cancelled":await d(null),await e.close(t,r.id,l==="done"?"completed":"not_planned");return;case"backlog":throw new Be("backlog follows from blockers; no transition leads there")}}function Ao(e,t,r,o){return dy.run(`${t}/${r}`,async()=>{var m;const l=await e.loadMap(t),c=l.tickets.find(v=>v.id===r);if(!c)throw new Be(`ticket ${r} not found`);const d=ay(c,new Map(l.tickets.map(v=>[v.id,v])),l.map.mode);if(o.expect&&d!==o.expect)throw new Be(`${c.key} changed: it is ${d} now`);const h=uy(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=hy(h,c,o.to);await fy(e,t,c,{to:g,actor:o.actor});try{await((m=o.journal)==null?void 0:m.append({v:1,kind:"transition",at:Date.now(),mapId:t,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 zh(e,t,r,o){const{assignee:l}=o,c=await e.loadMap(t),d=c.tickets.find(v=>v.id===r);if(!d)throw new Be(`ticket ${r} not found`);const h=Fs(c.tickets,c.map.mode).get(r);if(h!=="frontier"&&h!=="rework")throw new Be(`${d.key} is ${h}, not on the frontier`);await Ao(e,t,r,{event:"claim",actor:l,actorKind:o.actorKind??"agent",reason:o.reason,sessionId:o.sessionId,journal:o.journal});const m=(await e.loadMap(t)).tickets.find(v=>v.id===r);if(m.assignee!==l)throw new Be(`${d.key} was claimed by ${m.assignee}`);return m}async function my(e,t,r,o={}){const c=(await e.loadMap(t)).tickets.find(d=>d.id===r);if(!c)throw new Be(`ticket ${r} not found`);await Ao(e,t,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 gc(e,t,r,o={}){if(r.source.ref){const c=(await e.listDecisions(t)).find(d=>d.source.kind===r.source.kind&&d.source.ref===r.source.ref);if(c)return c}const l=await e.createDecision(t,r);if(o.appendToTrail??!0){const c=await e.loadMap(t);await e.updateMapSections(t,{decisions:[...c.map.sections.decisions,{ticketId:l.ticketId,ticketKey:l.ticketKey,text:o.trailLine??l.summary}]})}return l}async function py(e,t,r,o){const c=(await e.listDecisions(t)).find(w=>w.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(t,{ticketId:c.ticketId,ticketKey:c.ticketKey,...o,question:o.question??c.question,supersedes:c.id});await e.markSuperseded(t,c.id,d.id);const g=(await e.loadMap(t)).map.sections.decisions,m=g.findIndex(w=>w.text===c.summary||!!c.ticketId&&w.ticketId===c.ticketId||!!c.ticketKey&&w.ticketKey===c.ticketKey),v={ticketId:d.ticketId,ticketKey:d.ticketKey,text:d.summary};return await e.updateMapSections(t,{decisions:m<0?[...g,v]:g.map((w,x)=>x===m?v:w)}),d}async function gy(e,t,r){await e.setMapMode(t,r)}function rm(e){return e==="plan-only"?go.filter(t=>t!=="execute"):go}function vy(e,t){if(!rm(e).includes(t))throw new Be(`${t} tickets are disabled on plan-only maps`)}const _n={lookout:{label:"Lookout",code:"CMD"},agent:{label:"Agent",code:"AGT"},slack:{label:"Slack",code:"SLK"},tracker:{label:"Tracker",code:"TRK"}},vo=Object.keys(_n),yy=e=>e in _n,Di=e=>e.source.kind==="agent"&&e.decidedBy!=="trail lead"&&!e.decidedBy.startsWith("slack:")?"agent":"human",Wi=e=>e.supersededBy?"superseded":"active";function Lo(e){const t=e.replace(/\s+/g," ").trim(),r=t.match(/^(.{20,180}?[.!?])(\s|$)/);return r?r[1]:t.slice(0,180)}function ky(e,t,r){var o;return{...r,id:e,mapId:t,decidedAt:r.decidedAt??Date.now(),summary:((o=r.summary)==null?void 0:o.trim())||Lo(r.answer),alternatives:r.alternatives??[],rationale:r.rationale??"",participants:r.participants??[{id:r.decidedBy}],transcript:r.transcript??[]}}const wy=e=>Number(e.replace(/\D/g,""))||0;function xy(e,t){const r=new Map(e.map(d=>[d.id,d])),o=new Set;let l=r.get(t);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 jy(e,t,r,o){var h;const c=(await e.loadMap(t)).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(t,r,o.author,`**HITL transcript**
|
|
63
|
+
|
|
64
|
+
${o.transcript}`),await e.comment(t,r,o.author,`**Resolution**
|
|
65
|
+
|
|
66
|
+
${o.answer}`),await Ao(e,t,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 gc(e,t,{ticketId:c.id,ticketKey:c.key,question:d.question??c.title,answer:o.answer,summary:o.summary??Lo(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 Sy(e,t,r,o){const l=await e.loadMap(t);if(!l.map.sections.unspecified.includes(r))throw new Be(`"${r}" is not in Not yet specified`);vy(l.map.mode,o.type);const c=await e.createTicket(t,{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(t,h,c.id);const d=await e.loadMap(t);return await e.updateMapSections(t,{unspecified:d.map.sections.unspecified.filter(h=>h!==r)}),c}async function Ny(e,t,r,o){const l=await e.loadMap(t),{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(t,{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(t,h.id,o.author,`**Ruled out of scope**
|
|
69
|
+
|
|
70
|
+
${o.reason}`),await Ao(e,t,h.id,{event:"cancel",actor:o.author,actorKind:o.actorKind??"agent",reason:o.reason,sessionId:o.sessionId,journal:o.journal}),await gc(e,t,{ticketId:h.id,ticketKey:h.key,question:h.title,answer:`Out of scope: ${o.reason}`,decidedBy:o.author,source:o.source??{kind:"agent",label:o.author}},{appendToTrail:!1});const g=await e.loadMap(t);await e.updateMapSections(t,{outOfScope:[...g.map.sections.outOfScope,`${h.key} ${h.title} — ${o.reason}`]})}async function by(e,t,r,o){r&&Cy(r),await e.setMapMeta(t,{modelMatching:r&&$y(r)})}function Cy(e){if(typeof e.enabled!="boolean")throw new Be('"enabled" must be true or false');for(const[t,r]of Object.entries(e.tiers??{})){if(!Io.includes(t))throw new Be(`unknown ticket type "${t}"`);if(!nm(r))throw new Be(`"${t}" must be fast, balanced or strongest`)}}function $y(e){const t=Object.fromEntries(Object.entries(e.tiers??{}).filter(([,r])=>r));return Object.keys(t).length?{enabled:e.enabled,tiers:t}:{enabled:e.enabled}}function Ty(e){return{async append(t){await fetch(`${e}/journal`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}}}const om={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(om));const Ey=2*6e4,zl=e=>e<6e4?`${Math.round(e/1e3)}s`:`${Math.round(e/6e4)}m`;function Iy(e,t){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 ${zl(t-e.lastOkAt)} ago`:"never synced";return e.state==="off"?{tone:"off",label:"PR sync off",title:`PR/CI sync off: ${e.reason??"disabled"}`}:e.state==="failed"?{tone:"failed",label:"PR sync failed",title:`${e.reason??"sync failed"}${r}
|
|
71
|
+
${o}`}:e.state==="rate-limited"?{tone:"failed",label:"PR sync paused",title:`Rate limited${r}; retrying ${e.nextAt?`in ${zl(Math.max(0,e.nextAt-t))}`:"later"}
|
|
72
|
+
${o}`}:!e.lastOkAt||e.lastOkAt!==e.lastAttemptAt||e.nextAt!==void 0&&t>e.nextAt+Ey?{tone:"stale",label:"PR sync stale",title:`No recent sync${r}
|
|
73
|
+
${o}`}:{tone:"ok",label:`PR sync ${zl(t-e.lastOkAt)}`,title:`PR/CI synced${r}, ${o}`}}class Os{constructor(){ue(this,"listeners",new Set)}on(t){return this.listeners.add(t),()=>this.listeners.delete(t)}emit(t){for(const r of[...this.listeners])r(t)}}let My=0;const mo=(e="id")=>`${e}_${Date.now().toString(36)}${(My++).toString(36)}`,Ql=(e,t)=>({inputTokens:((e==null?void 0:e.inputTokens)??0)+t.inputTokens,outputTokens:((e==null?void 0:e.outputTokens)??0)+t.outputTokens,costUsd:((e==null?void 0:e.costUsd)??0)+t.costUsd,...e!=null&&e.cachedInputTokens||t.cachedInputTokens?{cachedInputTokens:((e==null?void 0:e.cachedInputTokens)??0)+(t.cachedInputTokens??0)}:{}}),am=(e,t)=>({inputTokens:e.inputTokens-((t==null?void 0:t.inputTokens)??0),outputTokens:e.outputTokens-((t==null?void 0:t.outputTokens)??0),costUsd:e.costUsd-((t==null?void 0:t.costUsd)??0),...e.cachedInputTokens||t!=null&&t.cachedInputTokens?{cachedInputTokens:(e.cachedInputTokens??0)-((t==null?void 0:t.cachedInputTokens)??0)}:{}});function Ay(e,t,r){const o=()=>e.find(t.id)??t,l=c=>e.push({source:"session",sessionId:t.id,agent:t.agent,...c});return{id:t.id,get info(){return o()},step(c,d,h){const g=Mo[r][c-1];e.patchSession(t.id,{step:c,stepLabel:g,...h?{ticketId:h}:{}}),l({tag:ny(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:t.id,ticketId:o().ticketId,from:"agent",author:t.agent,text:c})},ask(c,d,h){var m;const g={id:mo("q"),sessionId:t.id,mapId:t.mapId,ticketId:o().ticketId,agent:t.agent,text:c,suggestions:d,at:Date.now(),...h!=null&&h.urgency?{urgency:h.urgency}:{},...(m=h==null?void 0:h.blocks)!=null&&m.length?{blocks:h.blocks}:{}};return e.chat({sessionId:t.id,ticketId:g.ticketId,from:"agent",author:t.agent,text:c,questionId:g.id}),e.addPending(g),e.patchSession(t.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(t.id,{status:c?"done":"failed",endedAt:Date.now(),waitingOn:void 0}),e.dropPending(t.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,t.id)),e.patchSession(t.id,{mapId:c})},usage(c){var g;const d=o().mapId;(g=e.ledger())==null||g.add(d,c,t.id),e.addMapUsage(d,c);const h=o().usage;e.patchSession(t.id,{usage:{...Ql(h,c),source:c.source??(h==null?void 0:h.source)}})},setUsage(c){var v;const d=o().usage,h=am(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)&&((v=e.ledger())==null||v.add(m,h,t.id)),e.addMapUsage(m,h),e.patchSession(t.id,{usage:c})},setModel(c,d){const h=o();h.model===c&&h.tier===d||e.patchSession(t.id,{model:c,tier:d})}}}class Ly{constructor(t=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:t=>this.state.sessions.find(r=>r.id===t),patchSession:(t,r)=>this.patchSession(t,r),push:t=>void this.push(t),chat:t=>this.chat(t),addPending:t=>this.set({pending:[...this.state.pending,t]}),dropPending:t=>{this.state.pending.filter(o=>o.sessionId===t).length&&this.set({pending:this.state.pending.filter(o=>o.sessionId!==t)})},awaitAnswer:t=>new Promise(r=>this.resolvers.set(t,r)),addMapUsage:(t,r)=>{this.state={...this.state,usageByMap:{...this.state.usageByMap,[t]:Ql(this.state.usageByMap[t],r)}}},ledger:()=>this.ledger});this.maxFeed=t,this.ledger=r}get snapshot(){return this.state}subscribe(t){return this.changes.on(t)}set(t){this.state={...this.state,...t},this.changes.emit(this.state)}push(t){const r={id:mo("f"),at:t.at??Date.now(),...t};return r.source==="system"&&!r.agent&&(r.agent=ve.assistant.name),this.set({feed:[...this.state.feed,r].slice(-this.maxFeed)}),r}patchSession(t,r){this.set({sessions:this.state.sessions.map(o=>o.id===t?{...o,...r}:o)})}chat(t){this.set({chats:[...this.state.chats,{id:mo("m"),at:Date.now(),...t}].slice(-600)})}answer(t,r,o){const l=this.state.pending.find(h=>h.id===t),c=this.resolvers.get(t),d=!!l&&this.remote.has(l.sessionId)&&!!this.remoteAnswer;return!l||!c&&!d?!1:(this.resolvers.delete(t),this.chat({sessionId:l.sessionId,ticketId:l.ticketId,from:"human",author:o,text:r}),this.set({pending:this.state.pending.filter(h=>h.id!==t),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(t){var m;const{session:r}=t,o=r.id;if(!this.remote.has(o)&&this.state.sessions.some(v=>v.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 v=am(r.usage,l);(v.inputTokens||v.outputTokens||v.costUsd)&&(c={...c,[r.mapId]:Ql(c[r.mapId],v)}),(m=this.ledger)==null||m.addTotal(r.mapId,o,r.usage)}const d=v=>v.filter(w=>w.sessionId!==o),h=new Set(this.state.answered.map(v=>v.id)),g=this.state.sessions.some(v=>v.id===o)?this.state.sessions.map(v=>v.id===o?r:v):[...this.state.sessions,r].slice(-24);this.set({sessions:g,chats:[...d(this.state.chats),...t.chats].sort((v,w)=>v.at-w.at).slice(-600),pending:[...d(this.state.pending),...t.pending],answered:[...this.state.answered,...t.answered.filter(v=>!h.has(v.id))].sort((v,w)=>v.answeredAt-w.answeredAt).slice(-200),feed:[...this.state.feed.filter(v=>v.sessionId!==o),...t.feed].sort((v,w)=>v.at-w.at).slice(-this.maxFeed),usageByMap:c})}isRemote(t){return this.remote.has(t)}startSession(t){const r={...t,id:t.id??mo("s"),step:0,total:Mo[t.mode].length,stepLabel:"BOOT",status:"running",startedAt:Date.now()};this.set({sessions:[...this.state.sessions,r].slice(-24)});const o=Ay(this.host,r,t.mode);return this.push({source:"session",sessionId:r.id,agent:r.agent,level:"info",text:`Session opened · ${t.mode}`}),o}}function Ry(e,t){const r=o=>{var l;return((l=t(o))==null?void 0:l.key)??o};switch(e.kind){case"map.created":return{source:"tracker",level:"ok",text:`Trail created · label ${dc}`};case"map.updated":return{source:"tracker",level:"info",text:`Trail updated${e.section?` · ${Xv[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 Oy=new Set(["createMap","setMapMode","setMapMeta","updateMapSections","createTicket","addBlocking","removeBlocking","editTicket","reopen","assign","comment","close","setMeta","createDecision","markSuperseded"]),Py=5*6e4;function _y(e){let t={status:"idle",inflight:0,writes:0,errors:0,events:[]};const r=new Os,o=c=>{t={...t,...c},r.emit(t)};return e.subscribe(c=>{const d=c.at-Py;o({events:[...t.events.filter(h=>h.at>=d),{at:c.at,external:c.kind==="external.changed"||"external"in c&&!!c.external}]})}),{adapter:new Proxy(e,{get(c,d,h){const g=Reflect.get(c,d,h);return typeof g!="function"?g:Oy.has(d)?async(...m)=>{const v=Date.now();o({inflight:t.inflight+1,status:"syncing"});try{const w=await g.apply(c,m),x=t.inflight-1;return o({inflight:x,writes:t.writes+1,lastWriteMs:Date.now()-v,lastWriteAt:Date.now(),status:x?"syncing":"ok",lastError:void 0}),w}catch(w){const x=t.inflight-1;throw o({inflight:x,errors:t.errors+1,status:"error",lastError:String(w.message??w)}),w}}:g.bind(c)}}),get health(){return t},subscribe:c=>r.on(c)}}function lm(e){const t={decided:0,claimed:0,frontier:0,blocked:0,parked:0,"out-of-scope":0,verifying:0,rework:0,held:0,total:e.tickets.length,resolvedPct:0};for(const r of Fs(e.tickets,e.map.mode).values())t[r]++;return t.resolvedPct=t.total?Math.round((t.decided+t["out-of-scope"])/t.total*100):0,t}function cm(e){const t=lm(e);return{decided:t.decided,total:t.total-t["out-of-scope"]}}function Dy(e){const t=new Map(e.tickets.filter(d=>d.state==="open").map(d=>[d.id,d])),r=new Map,o=new Set,l=d=>{if(r.has(d))return r.get(d);if(o.has(d))return[];o.add(d);const h=t.get(d);let g=[];for(const v of h.blockedBy)if(t.has(v)){const w=l(v);w.length>g.length&&(g=w)}o.delete(d);const m=[...g,h];return r.set(d,m),m};let c=[];for(const d of t.keys()){const h=l(d);h.length>c.length&&(c=h)}return c}function By(e){return go.map(t=>{const r=e.tickets.filter(o=>o.type===t);return{type:t,open:r.filter(o=>o.state==="open").length,closed:r.filter(o=>o.state==="closed").length}}).filter(t=>t.open+t.closed>0)}function zy(e,t){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 um(e,t){return t&&e.usageByMap[t]||{inputTokens:0,outputTokens:0,costUsd:0}}const Fy=e=>e.usage?e.usage.inputTokens+e.usage.outputTokens:0,dm={"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 hm(e,t){var o;const r=new Set;for(const l of e.sessions)t&&l.mapId===t&&((o=l.usage)!=null&&o.source)&&r.add(l.usage.source);return[...r].sort()}function Uy(e,t){const r=new Set(t.map(l=>l.ticketId).filter(Boolean)),o=e.tickets.filter(l=>l.state==="closed"&&l.closeReason==="completed"&&!r.has(l.id)).map(l=>{var v;const c=[...l.comments].reverse().find(w=>w.body.startsWith("**Resolution**")),d=c?c.body.replace(/^\*\*Resolution\*\*\s*/,""):((v=e.map.sections.decisions.find(w=>w.ticketId===l.id||w.ticketKey===l.key))==null?void 0:v.text)??"",h=(c==null?void 0:c.author)??l.assignee??"unknown",g=l.comments.find(w=>w.body.startsWith("**HITL transcript**")),m=g?g.body.replace(/^\*\*HITL transcript\*\*\s*/,"").split(/\n\n(?=\*\*[^*]+:\*\* )/).map(w=>w.match(/^\*\*([^*]+):\*\* ([\s\S]*)$/)).filter(w=>!!w).map(w=>({from:w[1]===h?"agent":"human",author:w[1],text:w[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:Lo(d),alternatives:[],rationale:"",decidedBy:h,decidedAt:l.closedAt??(c==null?void 0:c.createdAt)??l.updatedAt,participants:[...new Set([h,...m.map(w=>w.author)])].map(w=>({id:w})),source:{kind:"tracker",ref:`${e.map.id}/tickets/${l.id}`,label:`${l.key} resolution comment`},transcript:m,derived:!0}});return[...t,...o].sort((l,c)=>c.decidedAt-l.decidedAt)}function Hy(e,t){var o;const r=(o=t.query)==null?void 0:o.trim().toLowerCase();return e.filter(l=>(!t.mapId||l.mapId===t.mapId)&&(!t.source||l.source.kind===t.source)&&(!t.decidedBy||l.decidedBy===t.decidedBy)&&(!t.madeBy||Di(l)===t.madeBy)&&(!t.status||Wi(l)===t.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 Wy(e,t=Date.now()){const r=Object.fromEntries(vo.map(d=>[d,0]));let o=0,l=0,c=0;for(const d of e)r[d.source.kind]++,d.supersededBy&&o++,t-d.decidedAt<864e5&&l++,(Di(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 Ro(e){const t=e.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);if(!t)return{front:{},body:e};const r={};for(const o of t[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("[")?Vy(d.slice(1,-1)).map(Uh).filter(Boolean):Uh(d)}return{front:r,body:t[2]}}const Ky=e=>e===""||/^[\s#&*!|>'"%@`[\]{},?:-]|[:#]\s|\s$|,/.test(e)||/^(true|false|null|~|\d[\d.e+-]*)$/i.test(e),Fh=e=>Ky(e)?JSON.stringify(e):e;function Uh(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 Vy(e){const t=[];let r="",o=!1;for(const l of e)l==='"'&&(o=!o),l===","&&!o?(t.push(r.trim()),r=""):r+=l;return r.trim()&&t.push(r.trim()),t}function vc(e,t){return`---
|
|
76
|
+
${Object.entries(e).map(([o,l])=>`${o}: ${Array.isArray(l)?`[${l.map(Fh).join(", ")}]`:Fh(l)}`).join(`
|
|
77
|
+
`)}
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
${t.trim()}
|
|
81
|
+
`}const we=e=>Array.isArray(e)?e.join(","):e??"";function Ht(e){return Array.isArray(e)?e:e?[e]:[]}const Rs=e=>Date.parse(we(e))||0,Jt=e=>new Date(e).toISOString(),fm=["schema","breaking-api","auth-permissions","billing","data-deletion","product-behaviour","dependencies"],mm=["low","medium","high"],Gy=e=>fm.includes(e),qy=e=>mm.includes(e);function Qy(e){return e?{risk:e.level,...e.category?{risk_category:e.category}:{},risk_reason:e.reason}:{}}function Yy(e){const t=we(e.risk);if(!qy(t))return{};const r=we(e.risk_category);return{risk:{level:t,...Gy(r)?{category:r}:{},reason:we(e.risk_reason)}}}const Jy=["Question","Decision","Summary","Alternatives","Rationale","Transcript"],Xy=e=>e.name?`${e.id}|${e.name}`:e.id,Zy=e=>{const t=e.indexOf("|");return t<0?{id:e}:{id:e.slice(0,t),name:e.slice(t+1)}};function Hh(e){var c;const t={id:e.id,trail:e.mapId,...e.ticketId?{ticket:e.ticketId,ticket_key:e.ticketKey??""}:{},decided_by:e.decidedBy,decided_at:Jt(e.decidedAt),participants:e.participants.map(Xy),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}:{},...Qy(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} @ ${Jt(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 vc(t,l)}function Yl(e){const{front:t,body:r}=Ro(e),o={},l=new RegExp(`^## (${Jy.join("|")})\\s*$`,"gm"),c=[...r.matchAll(l)];c.forEach((w,x)=>{var T;const j=r.slice(w.index+w[0].length,((T=c[x+1])==null?void 0:T.index)??r.length).trim();o[w[1]]=/^_none\._$/i.test(j)?"":j});const d=(o.Transcript??"").split(/^### /m).slice(1).map(w=>{const x=w.indexOf(`
|
|
101
|
+
`),j=x<0?w:w.slice(0,x),[T,S=""]=j.split(" @ "),[E,M="agent"]=T.split(" · ");return{author:E.trim(),from:["agent","human","system"].includes(M.trim())?M.trim():"agent",at:Date.parse(S)||0,text:x<0?"":w.slice(x+1).trim()}}),h=we(t.source),g=Ht(t.source_meta),m={kind:yy(h)?h:"tracker",...we(t.source_ref)?{ref:we(t.source_ref)}:{},...we(t.source_url)?{url:we(t.source_url)}:{},...we(t.source_label)?{label:we(t.source_label)}:{},...g.length?{meta:Object.fromEntries(g.map(w=>[w.slice(0,w.indexOf("=")),w.slice(w.indexOf("=")+1)]))}:{}},v=o.Decision??"";return{id:we(t.id),mapId:we(t.trail),ticketId:we(t.ticket)||void 0,ticketKey:we(t.ticket_key)||void 0,question:o.Question??"",answer:v,summary:o.Summary||Lo(v),alternatives:(o.Alternatives??"").split(`
|
|
102
|
+
`).map(w=>w.trim()).filter(w=>w.startsWith("- ")).map(w=>w.slice(2)),rationale:o.Rationale??"",decidedBy:we(t.decided_by),decidedAt:Rs(t.decided_at),participants:Ht(t.participants).map(Zy),source:m,supersedes:we(t.supersedes)||void 0,supersededBy:we(t.superseded_by)||void 0,...Ht(t.assumes).length?{assumes:Ht(t.assumes)}:{},transcript:d,...Yy(t)}}function ek(e){return e.url?` · [${e.label??"link"}](${e.url})`:e.label?` · ${e.label}`:""}function tk(e,t,r={}){const o=[`# ${r.title??"Decisions"}`,"",`Exported ${Jt(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=t[c];o.push("",`## Trail ${h?`${h.key} ${h.title}`:c}`);for(const g of d){const m=_n[g.source.kind].label;o.push("",`### ${g.id}${g.ticketKey?` · ${g.ticketKey}`:""} · ${g.question}`,"",`- **Status:** ${Wi(g)}${g.supersededBy?` (superseded by ${g.supersededBy})`:""}${g.supersedes?` · supersedes ${g.supersedes}`:""}`,`- **Decided by:** ${g.decidedBy} · ${Jt(g.decidedAt)}`,`- **Source:** ${m}${ek(g.source)}`,...g.participants.length?[`- **Participants:** ${g.participants.map(v=>v.name??v.id).join(", ")}`]:[],"",`**Decision:** ${g.answer}`,...g.alternatives.length?["","**Alternatives:**",...g.alternatives.map(v=>`- ${v}`)]:[],...g.rationale?["",`**Rationale:** ${g.rationale}`]:[],...g.transcript.length?["","<details><summary>Transcript</summary>","",...g.transcript.map(v=>`> **${v.author}:** ${v.text.replace(/\n/g,`
|
|
103
|
+
> `)}
|
|
104
|
+
>`),"","</details>"]:[])}}return o.join(`
|
|
105
|
+
`)+`
|
|
106
|
+
`}function Jl(e,t,r){try{const o=e.get(t);return o?JSON.parse(o):r}catch{return r}}class Wh{constructor(t,r="presence"){ue(this,"seen");this.store=t,this.key=r,this.seen=Jl(t,r,{})}snapshot(){return{...this.seen}}lastSeen(t){return this.seen[t]}lastSeenAny(){const t=Object.values(this.seen);return t.length?Math.max(...t):void 0}markSeen(t,r=Date.now()){let o=!1;for(const l of t)(this.seen[l]??0)>=r||(this.seen[l]=r,o=!0);o&&this.store.set(this.key,JSON.stringify(this.seen))}}const Fl=5*6e4,nk=14*864e5;class Kh{constructor(t,r="usage"){ue(this,"buckets");ue(this,"dirty",!1);ue(this,"timer");ue(this,"totals");this.store=t,this.key=r,this.buckets=Jl(t,r,{}),this.totals=Jl(t,`${r}.totals`,{})}addTotal(t,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(t,d,r,l):this.save()}add(t,r,o,l=Date.now()){var g;if(!t)return;const c=Math.floor(l/Fl)*Fl,d=(g=this.buckets)[t]??(g[t]=[]);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,v)=>m.at-v.at)),h.i+=r.inputTokens,h.o+=r.outputTokens,h.c+=r.costUsd,h.s.includes(o)||h.s.push(o),this.save()}since(t,r){const o={inputTokens:0,outputTokens:0,costUsd:0,sessions:0},l=new Set;for(const c of this.buckets[t]??[])c.at+Fl<=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 t=Date.now()-nk;for(const r of Object.keys(this.buckets))this.buckets[r]=this.buckets[r].filter(o=>o.at>=t);for(const[r,o]of Object.entries(this.totals))o.at<t&&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 sk(e){const t=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,v=Fs(d.tickets,d.map.mode),w=new Map(d.tickets.map(G=>[G.id,G])),x=(e.attention??[]).filter(G=>G.mapId===h),j=ik(e.activity.pending.filter(G=>G.mapId===h),x),T=new Set(j.map(G=>G.ticketId)),S=G=>G.state==="open"&&(T.has(G.id)||Hi(G)==="hitl"),E=d.tickets.filter(G=>v.get(G.id)==="blocked").map(G=>({ticket:G,on:G.blockedBy.map(ge=>w.get(ge)).filter(ge=>!!ge&&S(ge))})).filter(G=>G.on.length),M=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"),X=R.filter(G=>G.closeReason==="not_planned"),se=d.tickets.filter(G=>m(G.createdAt)),_=((oe=e.ledger)==null?void 0:oe.since(h,g))??{inputTokens:0,outputTokens:0,costUsd:0,sessions:0},Q=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:X,opened:se,blocked:E,waiting:j,needsYou:x,decisions:M,agentDecisions:M.filter(G=>Di(G)==="agent"),usage:_,active:Q,changed:!!(R.length||se.length||M.length||j.some(G=>m(G.at))||_.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)):t,now:t,trails:o,totals:{done:l("done"),ruledOut:l("ruledOut"),blocked:l("blocked"),waiting:l("waiting"),oldestWaitMs:c===void 0?void 0:t-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 ik(e,t){const r=new Map(t.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 Oi=(e,t,r=`${t}s`)=>`${e} ${e===1?t:r}`;function rk(e){return e.trails.flatMap(t=>{const r=new Set(t.waiting.map(o=>o.ticketId));return t.blocked.filter(o=>o.on.some(l=>r.has(l.id)))})}function ok(e){return e.length===1?`, and it holds up ${e[0].ticket.title.replace(/^./,t=>t.toLowerCase())}`:e.length>1?`, holding up ${Oi(e.length,"ticket")}`:""}function ak(e,t=new Date(e.now).getHours()){const r=e.totals,l=e.now-e.since>=6*36e5&&t>=5&&t<12?"Good morning.":"Welcome back.",c=[];if(r.done&&c.push(`${Oi(r.done,"ticket")} ${r.done===1?"is":"are"} done.`),r.agentDecisions&&c.push(`Agents made ${Oi(r.agentDecisions,"decision")}.`),r.waiting){const d=ok(rk(e));c.push(`${Oi(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(`${Oi(r.ruledOut,"ticket")} ruled out of scope.`),[l,...c].join(" ")}const lk=e=>{if(!e.length)return;const t=[...e].sort((o,l)=>o-l),r=Math.floor(t.length/2);return t.length%2?t[r]:Math.round((t[r-1]+t[r])/2)};function ck(e){return e.state==="open"?"open":e.closeReason==="not_planned"?"cancelled":"done"}function pm({snap:e,journal:t,answered:r,usage:o}){const l=e.map.id,c=t.filter(S=>S.mapId===l).sort((S,E)=>S.at-E.at),d=new Map;for(const S of c)d.set(S.ticketId,[...d.get(S.ticketId)??[],S]);const h=e.tickets.filter(S=>S.type!=="review").map(S=>{var X;const E=d.get(S.id)??[],M=ck(S),R=(X=E.find(se=>se.event==="claim"))==null?void 0:X.at,O=M==="done"?S.closedAt:void 0;return{id:S.id,key:S.key,title:S.title,type:S.type,outcome:M,claimedAt:R,doneAt:O,leadMs:O&&R&&O>=R?O-R:void 0,reworks:E.filter(se=>se.to==="rework").length,reviews:{passed:E.filter(se=>se.event==="review.pass").length,failed:E.filter(se=>se.event==="review.fail").length,needsHuman:E.filter(se=>se.event==="review.needs_human").length},operatorActions:E.filter(se=>se.actorKind==="trail lead").length}}),g=h.filter(S=>S.outcome==="done"),m=Math.max(0,...g.map(S=>S.doneAt??0)),v=c.filter(S=>S.actorKind==="trail lead"),w=new Set(r.filter(S=>S.mapId===l).map(S=>S.id)).size,x=v.length,j=S=>h.reduce((E,M)=>E+S(M),0),T=(o==null?void 0:o.costUsd)??0;return{mapId:l,tickets:h,done:g.length,cancelled:h.filter(S=>S.outcome==="cancelled").length,open:h.filter(S=>S.outcome==="open").length,trailLeadMs:m&&m>=e.map.createdAt?m-e.map.createdAt:void 0,medianLeadMs:lk(g.flatMap(S=>S.leadMs===void 0?[]:[S.leadMs])),interventions:{answers:w,operatorActions:x,reworkRequested:v.filter(S=>S.event==="reject").length,total:w+x},rework:{tickets:h.filter(S=>S.reworks>0).length,cycles:j(S=>S.reworks)},reviews:{passed:j(S=>S.reviews.passed),failed:j(S=>S.reviews.failed),needsHuman:j(S=>S.reviews.needsHuman)},spend:{costUsd:Math.round(T*1e4)/1e4,tokens:((o==null?void 0:o.inputTokens)??0)+((o==null?void 0:o.outputTokens)??0),perVerifiedTicketUsd:g.length&&T?Math.round(T/g.length*1e4)/1e4:void 0}}}const Ul=e=>e.split("-")[0];function en(e){if(e===void 0)return"—";const t=Math.round(e/6e4);if(t<90)return`${t} min`;const r=e/36e5;return r<48?`${Math.round(r*10)/10} h`:`${Math.round(r/24*10)/10} d`}const Vh=e=>e===void 0?"—":`$${e.toFixed(e<1?4:2)}`;function uk(e,t,r=Date.now()){const o=e.interventions;return[`# Trail report: ${t}`,"",`_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) | ${en(e.trailLeadMs)} |`,`| Median ticket lead time (claim → done) | ${en(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 | ${Vh(e.spend.costUsd)} · ${e.spend.tokens.toLocaleString("en-US")} tokens |`,`| Cost per verified ticket | ${Vh(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} | ${en(c.leadMs)} | ${c.reworks} | ${c.reviews.passed}/${c.reviews.failed} | ${c.operatorActions} |`),""].join(`
|
|
107
|
+
`)}const yc=5,gm=1.5,dk=15,so=e=>Math.round(e*100);function hk(e){const t=e.filter(d=>d.findings.raised>=yc).sort((d,h)=>h.findings.upheld/h.findings.raised-d.findings.upheld/d.findings.raised||d.key.localeCompare(h.key));if(t.length<2)return[];const[r,o]=[t[0],t[t.length-1]],[l,c]=[r.findings.upheld/r.findings.raised,o.findings.upheld/o.findings.raised];return so(l)-so(c)<dk?[]:[{id:"review-findings",text:`${r.key} review findings upheld ${so(l)}% vs ${o.key} ${so(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 fk(e){const t=c=>c.reworkCycles/c.tickets,r=e.filter(c=>c.tickets>=yc).sort((c,d)=>t(c)-t(d)||c.key.localeCompare(d.key));if(r.length<2)return[];const[o,l]=[r[0],r[r.length-1]];return t(l)-t(o)<.2||t(l)<t(o)*gm?[]:[{id:"rework",text:`${l.key} work goes back to rework more: ${t(l).toFixed(1)} times per ticket vs ${o.key} ${t(o).toFixed(1)}`,because:`${l.reworkCycles} cycles on ${l.tickets} tickets, and ${o.reworkCycles} on ${o.tickets}`}]}function mk(e,t){const r=d=>d.medianLeadMs??0,o=t.filter(d=>d.done>=yc&&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)*gm?[]:[{id:`speed-${e}`,text:`${e} tickets: ${l.key} is faster, ${en(l.medianLeadMs)} vs ${c.key} ${en(c.medianLeadMs)}`,because:`Median first claim to done, over ${l.done} and ${c.done} done tickets`}]}function pk(e){const t=Object.keys(e.byTypeAndVendor).sort();return[...hk(e.byVendor),...fk(e.byVendor),...t.flatMap(r=>mk(r,e.byTypeAndVendor[r]))]}const gk=e=>{if(!e.length)return;const t=[...e].sort((o,l)=>o-l),r=Math.floor(t.length/2);return t.length%2?t[r]:Math.round((t[r-1]+t[r])/2)},vm=e=>{var t;return(t=e.filter(r=>r.event==="claim"&&r.actorKind==="agent").at(-1))==null?void 0:t.actor},Xl=(e,t,r)=>e.filter(o=>o.mapId===t&&o.ticketId===r).sort((o,l)=>o.at-l.at);function vk(e,t){return e.tickets.flatMap(r=>{var w;if(r.type!=="review"||!r.reviewOf)return[];const o=Xl(t,e.map.id,r.id),l=vm(o);if(!l)return[];const c=((w=o.filter(x=>x.event==="claim").at(-1))==null?void 0:w.at)??0,d=Xl(t,e.map.id,r.reviewOf),h=d.findIndex(x=>x.at>=c&&x.event.startsWith("review."));if(h<0||d[h].event!=="review.fail")return[];const g=d.slice(h+1),m=g.findIndex(x=>x.event.startsWith("review.")),v=m<0?g:g.slice(0,m);return[{reviewer:l,upheld:!v.some(x=>x.event==="accept"&&x.actorKind==="trail lead")}]})}function yk(e,t){var o;const r=(o=e.tickets.find(l=>l.id===t))==null?void 0:o.assignee;return r&&/^[a-z]+-\d+$/.test(r)?r:void 0}function ym(e,t){const r=l=>t.reduce((c,{ticket:d})=>c+l(d),0),o=l=>t.filter(c=>c.ticket.outcome===l).length;return{key:e,tickets:t.length,done:o("done"),cancelled:o("cancelled"),open:o("open"),medianLeadMs:gk(t.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 io(e,t){const r=new Map;for(const o of e){const l=t(o);l&&r.set(l,[...r.get(l)??[],o])}return new Map([...r].map(([o,l])=>[o,ym(o,l)]))}const Zl=(e,t)=>{const r=e.get(t)??ym(t,[]);return e.set(t,r),r};function Gh(e,t,r){const o=Zl(e,t);o.findings.raised+=1,r&&(o.findings.upheld+=1)}const ro=e=>[...e.values()].sort((t,r)=>r.tickets-t.tickets||t.key.localeCompare(r.key));function km(e){const t=e.flatMap(({snap:m,journal:v,answered:w,usage:x})=>pm({snap:m,journal:v,answered:w,usage:x}).tickets.map(j=>({ticket:j,agent:vm(Xl(v,m.map.id,j.id))??yk(m,j.id)}))),r=m=>m.agent?Ul(m.agent):void 0,o=io(t,m=>m.agent),l=io(t,r),c=io(t,m=>m.ticket.type),d=new Set;for(const{snap:m,journal:v,answered:w}of e){for(const x of w){const j=`${x.mapId}/${x.id}`;x.mapId!==m.map.id||d.has(j)||(d.add(j),Zl(o,x.agent).answers+=1,Zl(l,Ul(x.agent)).answers+=1)}for(const x of vk(m,v))Gh(o,x.reviewer,x.upheld),Gh(l,Ul(x.reviewer),x.upheld)}const h=Object.fromEntries([...c.keys()].map(m=>[m,ro(io(t.filter(v=>v.ticket.type===m),r))])),g={trails:e.length,tickets:t.length,byAgent:ro(o),byVendor:ro(l),byType:ro(c),byTypeAndVendor:h};return{...g,recommendations:pk(g)}}const kk={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
|
+
`)},wk=[["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"]],Li=Object.fromEntries(wk);function xk(e,t){const r=new Set(e.map(o=>o.source).filter(Boolean));return t.filter(o=>!r.has(o))}const jk=["architecture","convention","gotcha","dead-end","glossary","fact"],wm=["business-rule","product-decision","persona","ux-principle","pricing"],Sk=[...jk,...wm],Nk=e=>e.status==="confirmed"||e.status==="assumption";function bk(e,t){const r=e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*\//g,"§DIRS§").replace(/\*\*/g,"§DEEP§").replace(/\*/g,"[^/]*").replace(/§DIRS§/g,"(?:.*/)?").replace(/§DEEP§/g,".*");return new RegExp(`^${r}$`).test(t.replace(/^\.\//,""))}const Ck={"business-rule":3,convention:3,"product-decision":2,architecture:2,gotcha:2,"dead-end":2,"ux-principle":2},$k=["business-rule","ux-principle","convention"],qh=600,Tk=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(" ")),Qh=e=>new Set((e.toLowerCase().match(/[a-z0-9][a-z0-9_-]{2,}/g)??[]).filter(t=>!Tk.has(t)));function xm(e,t,r=4e3,o=()=>[]){const l=t.ticket?Qh(`${t.ticket.title} ${t.ticket.body}`):new Set,c=new Set((t.tags??[]).map(m=>m.toLowerCase())),d=e.filter(Nk).map(m=>{const v=[];let w=Ck[m.kind]??1;for(const T of m.scope){const S=t.paths.find(E=>bk(T,E));if(S){w+=6,v.push(`path match ${T} (${S})`);break}}const x=m.tags.filter(T=>c.has(T.toLowerCase())||l.has(T.toLowerCase()));x.length&&(w+=3*x.length,v.push(`tag ${x.join(", ")}`));const j=[...Qh(m.title)].filter(T=>l.has(T));return j.length&&(w+=j.length,v.push(`mentions ${j.slice(0,3).join(", ")}`)),t.trailKey&&m.sources.includes(`trail:${t.trailKey}`)&&(w+=3,v.push("same trail")),t.discovery&&wm.includes(m.kind)&&(w+=8,v.push("product context for discovery")),!v.length&&$k.includes(m.kind)&&!m.scope.length&&v.push(`${m.kind.replace("-"," ")} for the whole project`),{e:m,score:w,why:v}}).filter(m=>m.why.length>0).sort((m,v)=>v.score-m.score||m.e.id.localeCompare(v.e.id,void 0,{numeric:!0})),h=[];let g=0;for(const{e:m,why:v}of d){const w=m.body.length>qh?`${m.body.slice(0,qh)}…`:m.body;if(g+w.length>r&&h.length)break;g+=w.length;const x=o(m);h.push({id:m.id,title:m.title,kind:m.kind,status:m.status,body:w,why:v,...x.length?{mayBeOutdated:x}:{},...m.flag?{flagged:m.flag.reason}:{}})}return h}const Ek=new RegExp("`([^`\\s]+/[^`\\s]+)`|(?:^|[\\s(])/?((?:[\\w.-]+/)+[\\w.-]+)","gm");function jm(e){const t=new Set;for(const r of e.matchAll(Ek))t.add((r[1]??r[2]).replace(/^\.?\//,"").replace(/[.,;:]+$/,""));return[...t]}const Ik=[{level:"high",label:"High risk"},{level:"medium",label:"Medium risk"},{level:"low",label:"Low risk"},{level:"none",label:"No category"}];function Mk(e){return Ik.map(t=>({...t,decisions:e.filter(r=>{var o;return(((o=r.risk)==null?void 0:o.level)??"none")===t.level})})).filter(t=>t.decisions.length)}const Ak=1/3;function Oo(e,t=Date.now()){const r=e.expiresAt-t;return r<=0?"expired":r<=e.ttlMs*Ak?"stalled":"live"}function Lk(e){var t;return((t=e.returned)==null?void 0:t.reason)==="trail lead"?`${e.ticketKey} returned to queue · claim of ${e.agent} released by ${e.returned.by}`:`${e.ticketKey} returned to queue after ${e.agent} went silent`}const Rk=e=>e.urgency==="fyi"||e.kind==="policy",Yh=e=>Number(e.slice(0,2))*60+Number(e.slice(3,5));function Ok(e,t){const r=new Date(t),o=r.getHours()*60+r.getMinutes(),l=Yh(e.from),c=Yh(e.to),d=c<=l;if(!(d?o>=l||o<c:o>=l&&o<c))return!1;if(!e.days)return!0;const g=d&&o<c,m=(r.getDay()+(g?6:0))%7;return e.days.includes(m)}function Pk(e,t){const r=new Date(t);return r.setHours(Number(e.to.slice(0,2)),Number(e.to.slice(3,5)),0,0),r.getTime()<=t&&r.setDate(r.getDate()+1),r.getTime()}function _k(e,t){const r=e.focusUntil??0;if(r>t)return{kind:"manual",until:r};if(!e.focus||!Ok(e.focus,t))return{kind:"off"};const o=Pk(e.focus,t);return(e.focusOffUntil??0)>t?{kind:"paused",until:o}:{kind:"hours",until:o}}function Dk(e,t,r){const o={...e};switch(delete o.focusUntil,delete o.focusOffUntil,t.kind){case"for":return{...o,focusUntil:r+t.minutes*6e4};case"resume":return o;case"end":{const l=_k(o,r);return l.kind==="hours"?{...o,focusOffUntil:l.until}:o}default:return t}}function Bk(e,t){var o;const r={...e};return t.verification===null?delete r.verification:t.verification&&(r.verification=t.verification),t.guides===null||((o=t.guides)==null?void 0:o.length)===0?delete r.guides:t.guides&&(r.guides=t.guides),t.modelMatching===null?delete r.modelMatching:t.modelMatching&&(r.modelMatching=t.modelMatching),r}function zk(e,t,r){const o=Date.now();return{id:e,key:t,...r,state:"open",blockedBy:[],comments:[],createdAt:o,updatedAt:o}}const Fk=(e,t)=>({...e,blockedBy:e.blockedBy.filter(r=>r!==t)}),Uk=(e,t)=>{var r;return{...e,...(r=t.title)!=null&&r.trim()?{title:t.title.trim()}:{},...t.body!==void 0?{body:t.body}:{}}};function Hk(e){const{closeReason:t,closedAt:r,...o}=e;return{...o,state:"open"}}const Wk=["status","verification","checks","reviewOf","guide"];function Kk(e,t){const r={...e};for(const o of Wk)t[o]!==void 0&&(t[o]===null?delete r[o]:r[o]=t[o]);return r}const Vk=/^([^/]+)\/decisions\/([^/]+)\.md$/,Gk=(e,t)=>e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,40)||`map-${t}`;class qk{constructor(t,r){ue(this,"seen",new Map);ue(this,"pending",new Map);this.read=t,this.emit=r}knows(t){return this.seen.has(t)}remember(t,r,o){this.seen.set(t,{text:r,supersededBy:o})}queue(t){const r=t.split("/")[0],o=this.pending.get(r)??{paths:new Set,timer:setTimeout(()=>void this.flush(r),250)};o.paths.add(t),this.pending.set(r,o)}async flush(t){const r=this.pending.get(t);if(this.pending.delete(t),!r)return;const o=[...r.paths].filter(d=>Vk.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=Yl(h);this.seen.set(d,{text:h,supersededBy:m.supersededBy}),g?m.supersededBy&&m.supersededBy!==g.supersededBy&&l.push({kind:"decision.superseded",mapId:t,decisionId:m.id,supersededBy:m.supersededBy,external:!0,at:Date.now()}):l.push({kind:"decision.recorded",mapId:t,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:t,at:Date.now()}):l.push({kind:"external.changed",mapId:t,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 Qk(e){const t=e.filter(([r,o])=>Io.includes(r)&&nm(o));return Object.fromEntries(t)}function Yk(e){const t=we(e["model-matching"]);if(t!=="on"&&t!=="off")return;const r=Qk(Ht(e["model-tiers"]).map(o=>o.split("=").map(l=>l.trim())));return Object.keys(r).length?{enabled:t==="on",tiers:r}:{enabled:t==="on"}}function Jk(e){if(!e)return{};const t=Object.entries(e.tiers??{}).map(([r,o])=>`${r}=${o}`);return{"model-matching":e.enabled?"on":"off",...t.length?{"model-tiers":t}:{}}}function Xk(e,t){const{front:r,body:o}=Ro(t),l=Zf(we(r.verification)),c=Yk(r);return{id:e,key:we(r.key)||e,title:we(r.title)||e,mode:we(r.mode)==="plan-only"||Ht(r.labels).includes(fc)?"plan-only":ns,...l?{verification:l}:{},...Ht(r.guides).length?{guides:Ht(r.guides)}:{},...c?{modelMatching:c}:{},sections:ty(o),createdAt:Rs(r.created),updatedAt:Rs(r.updated)}}function Zk(e){var t;return vc({key:e.key,title:e.title,mode:e.mode,...e.verification?{verification:e.verification}:{},...(t=e.guides)!=null&&t.length?{guides:e.guides}:{},...Jk(e.modelMatching),labels:[dc,...e.mode==="plan-only"?[fc]:[]],created:Jt(e.createdAt),updated:Jt(e.updatedAt)},ey(e.sections))}async function Jh(e){const t=await e.list(),r=t.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(t.filter(l=>l.endsWith("/map.md")).map(async l=>Number(we(Ro(await e.read(l)).front.key).replace(/\D/g,""))||0));return Math.max(0,...r,...o)+1}function Xh(e){const{front:t,body:r}=Ro(e),[o,l=""]=r.split(/^## Comments\s*$/m),c=l.split(/^### /m).slice(1).map((m,v)=>{const w=m.indexOf(`
|
|
109
|
+
`),[x,j]=m.slice(0,w).split(" @ ");return{id:`c${v}`,author:x.trim(),createdAt:Date.parse(j)||0,body:m.slice(w+1).trim()}}),d=we(t.close_reason),h=_v.find(m=>m===we(t.status)),g=Zf(we(t.verification));return{id:we(t.id),key:`#${we(t.id)}`,title:we(t.title),type:we(t.type)||"task",hitl:Ht(t.labels).includes(hc)||void 0,state:we(t.state)==="closed"?"closed":"open",closeReason:d==="completed"||d==="not_planned"?d:void 0,assignee:we(t.assignee)||void 0,...h?{status:h}:{},...g?{verification:g}:{},...t.checks!==void 0?{checks:Ht(t.checks)}:{},...we(t.review_of)?{reviewOf:we(t.review_of)}:{},...we(t.guide)?{guide:we(t.guide)}:{},blockedBy:Ht(t.blocked_by),body:o.trim(),comments:c,createdAt:Rs(t.created),updatedAt:Rs(t.updated),closedAt:Rs(t.closed)||void 0}}function ew(e){const t={id:e.id,title:e.title,type:e.type,labels:[Eo(e.type),...Pv(e.type)&&e.hitl?[hc]:[]],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:Jt(e.createdAt),updated:Jt(e.updatedAt),...e.closedAt?{closed:Jt(e.closedAt)}:{}},r=e.comments.length?`
|
|
110
|
+
|
|
111
|
+
## Comments
|
|
112
|
+
|
|
113
|
+
${e.comments.map(o=>`### ${o.author} @ ${Jt(o.createdAt)}
|
|
114
|
+
|
|
115
|
+
${o.body}`).join(`
|
|
116
|
+
|
|
117
|
+
`)}`:"";return vc(t,e.body+r)}class tw{constructor(t,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 qk(t=>this.fs.read(t),t=>this.events.emit(t)));var o;this.fs=t,this.location=r,(o=t.watch)==null||o.call(t,l=>{const c=this.selfWrites.get(l);c&&Date.now()-c<1500||this.external.queue(l)})}async put(t,r){this.selfWrites.set(t,Date.now()),await this.fs.write(t,r)}async readMap(t){return Xk(t,await this.fs.read(`${t}/map.md`))}async writeMap(t){await this.put(`${t.id}/map.md`,Zk(t))}async readTicket(t,r){return Xh(await this.fs.read(`${t}/tickets/${r}.md`))}async writeTicket(t,r){await this.put(`${t}/tickets/${r.id}.md`,ew({...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(t){const r=await this.fs.list(),o=await this.readMap(t),l=r.filter(d=>d.startsWith(`${t}/tickets/`)),c=await Promise.all(l.map(async d=>Xh(await this.fs.read(d))));return{map:o,tickets:c.sort((d,h)=>d.createdAt-h.createdAt)}}async createMap(t){const r=await Jh(this.fs),o=Gk(t.title,r),l={id:o,key:`#${r}`,title:t.title,mode:t.mode??ns,...t.verification?{verification:t.verification}:{},sections:t.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(t,r,o){await this.writeMap({...r(await this.readMap(t)),updatedAt:Date.now()}),this.events.emit(o)}setMapMode(t,r){return this.editMap(t,o=>({...o,mode:r}),{kind:"map.mode",mapId:t,mode:r,at:Date.now()})}setMapMeta(t,r){return this.editMap(t,o=>Bk(o,r),{kind:"map.updated",mapId:t,at:Date.now()})}updateMapSections(t,r){const o=Object.keys(r)[0];return this.editMap(t,l=>({...l,sections:{...l.sections,...r}}),{kind:"map.updated",mapId:t,section:o,at:Date.now()})}async createTicket(t,r){const o=await Jh(this.fs),l=zk(String(o),`#${o}`,r);return await this.writeTicket(t,l),this.events.emit({kind:"ticket.created",mapId:t,ticketId:l.id,at:Date.now()}),l}async addBlocking(t,r,o){const l=await this.readTicket(t,o);l.blockedBy.includes(r)||await this.writeTicket(t,{...l,blockedBy:[...l.blockedBy,r]}),this.events.emit({kind:"edge.added",mapId:t,blockerId:r,blockedId:o,at:Date.now()})}async update(t,r,o){await this.writeTicket(t,o(await this.readTicket(t,r)))}async removeBlocking(t,r,o){await this.update(t,o,l=>Fk(l,r)),this.events.emit({kind:"edge.removed",mapId:t,blockerId:r,blockedId:o,at:Date.now()})}async editTicket(t,r,o){await this.update(t,r,l=>Uk(l,o)),this.events.emit({kind:"ticket.updated",mapId:t,ticketId:r,at:Date.now()})}async reopen(t,r){await this.update(t,r,Hk),this.events.emit({kind:"ticket.updated",mapId:t,ticketId:r,at:Date.now()})}async assign(t,r,o){await this.update(t,r,l=>({...l,assignee:o??void 0})),this.events.emit(o?{kind:"ticket.claimed",mapId:t,ticketId:r,assignee:o,at:Date.now()}:{kind:"ticket.released",mapId:t,ticketId:r,at:Date.now()})}async comment(t,r,o,l){await this.update(t,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:t,ticketId:r,at:Date.now()})}async close(t,r,o){await this.update(t,r,l=>({...l,state:"closed",closeReason:o,closedAt:Date.now()})),this.events.emit({kind:"ticket.closed",mapId:t,ticketId:r,reason:o,at:Date.now()})}async setMeta(t,r,o){await this.update(t,r,l=>Kk(l,o)),this.events.emit({kind:"ticket.updated",mapId:t,ticketId:r,at:Date.now()})}async listDecisions(t){const r=(await this.fs.list()).filter(o=>o.startsWith(`${t}/decisions/`));return Promise.all(r.map(async o=>{const l=await this.fs.read(o),c={...Yl(l),mapId:t};return this.external.knows(o)||this.external.remember(o,l,c.supersededBy),c}))}async createDecision(t,r){const o=(await this.fs.list()).filter(h=>h.includes("/decisions/")),l=Math.max(0,...o.map(h=>wy(h.split("/").pop())))+1,c=ky(`D-${l}`,t,r),d=Hh(c);return this.external.remember(`${t}/decisions/${c.id}.md`,d),await this.put(`${t}/decisions/${c.id}.md`,d),this.events.emit({kind:"decision.recorded",mapId:t,decisionId:c.id,ticketId:c.ticketId,at:Date.now()}),c}async markSuperseded(t,r,o){const l=`${t}/decisions/${r}.md`,c=Yl(await this.fs.read(l)),d=Hh({...c,mapId:t,supersededBy:o});this.external.remember(l,d,o),await this.put(l,d),this.events.emit({kind:"decision.superseded",mapId:t,decisionId:r,supersededBy:o,at:Date.now()})}subscribe(t){return this.events.on(t)}}class Zh extends Error{constructor(t,r,o,l){super(r),this.code=t,this.status=o,this.resetAt=l,this.name="TrackerError"}}const nw={github:"GitHub Issues",linear:"Linear"};async function wt(e,t,r){let o;try{o=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:r===void 0?void 0:JSON.stringify(r)})}catch{throw new Zh("offline","Lookout server unreachable; is `teamtrail` still running?")}const l=await o.json().catch(()=>({}));if(!o.ok)throw new Zh(l.code??"http",l.error??`request failed (${o.status})`,o.status,l.resetAt);return l}class sw{constructor(t,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",t=>this.call("loadMap",t));ue(this,"createMap",t=>this.call("createMap",t));ue(this,"setMapMode",(t,r)=>this.call("setMapMode",t,r));ue(this,"setMapMeta",(t,r)=>this.call("setMapMeta",t,r));ue(this,"updateMapSections",(t,r)=>this.call("updateMapSections",t,r));ue(this,"createTicket",(t,r)=>this.call("createTicket",t,r));ue(this,"addBlocking",(t,r,o)=>this.call("addBlocking",t,r,o));ue(this,"removeBlocking",(t,r,o)=>this.call("removeBlocking",t,r,o));ue(this,"editTicket",(t,r,o)=>this.call("editTicket",t,r,o));ue(this,"reopen",(t,r)=>this.call("reopen",t,r));ue(this,"assign",(t,r,o)=>this.call("assign",t,r,o));ue(this,"comment",(t,r,o,l)=>this.call("comment",t,r,o,l));ue(this,"close",(t,r,o)=>this.call("close",t,r,o));ue(this,"setMeta",(t,r,o)=>this.call("setMeta",t,r,o));ue(this,"listDecisions",t=>this.call("listDecisions",t));ue(this,"createDecision",(t,r)=>this.call("createDecision",t,r));ue(this,"markSuperseded",(t,r,o)=>this.call("markSuperseded",t,r,o));this.kind=t,this.base=r,this.label=nw[t],this.location=o}async call(t,...r){return(await wt(`${this.base}/tracker/${this.kind}/call`,"POST",{method:t,args:r})).result}open(){const t=new EventSource(`${this.base}/tracker/${this.kind}/events`);t.onmessage=r=>this.events.emit(JSON.parse(r.data)),t.addEventListener("status",r=>{const o=JSON.parse(r.data);o.location&&(this.location=o.location),this.status=o,this.statusEvents.emit(o)}),t.onerror=()=>{this.status.state!=="offline"&&(this.status={...this.status,state:"offline",error:"Lookout server unreachable"},this.statusEvents.emit(this.status))},this.source=t}subscribe(t){const r=this.events.on(t);return++this.listeners===1&&this.open(),()=>{var o;r(),--this.listeners===0&&((o=this.source)==null||o.close(),this.source=void 0)}}onStatus(t){return this.statusEvents.on(t)}}function iw(e){return{get:()=>wt(`${e}/trackers`,"GET"),test:t=>wt(`${e}/trackers/test`,"POST",t),connect:t=>wt(`${e}/trackers`,"PUT",t),forget:t=>wt(`${e}/trackers/credentials/${t}`,"DELETE"),githubRepos:()=>wt(`${e}/trackers/github/repos`,"GET"),githubSignIn:{start:()=>wt(`${e}/trackers/github/sign-in/start`,"POST"),poll:()=>wt(`${e}/trackers/github/sign-in/poll`,"POST"),cancel:()=>wt(`${e}/trackers/github/sign-in/cancel`,"POST"),signOut:()=>wt(`${e}/trackers/github/sign-in`,"DELETE")},linearTeams:t=>t?wt(`${e}/trackers/linear/teams`,"POST",{apiKey:t}):wt(`${e}/trackers/linear/teams`,"GET"),linearProjects:(t,r)=>r?wt(`${e}/trackers/linear/projects`,"POST",{apiKey:r,teamId:t}):wt(`${e}/trackers/linear/projects?team=${encodeURIComponent(t)}`,"GET")}}const rw=[{id:"markdown",name:"Local markdown",status:"available"},{id:"github",name:"GitHub Issues",status:"available"},{id:"linear",name:"Linear",status:"available"}],Sm=[{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"}],ow=Sm[0],aw="https://github.com/teamtrailhq/teamtrail-guides",lw=`${aw}/blob/main/CONTRIBUTING.md`;function cw(e,t={}){const r=(t.query??"").toLowerCase().split(/\s+/).filter(Boolean);return e.guides.filter(o=>{if(t.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 uw={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"},Nm={on:"#e2711d",dim:"#a8501c",alert:"#ff5a48"},dw={on:"#ffd166",dim:"#a8501c",alert:"#ff5a48"},De=([e,t,r,o],l,c=.35)=>`<rect x="${e}" y="${t}" width="${r}" height="${o}" rx="${c}" fill="${l}"/>`;function ef(e,t,r){if(t==="closed")return De([e,17,3,1],r.glow);if(t==="wide")return De([e,15,3,3],r.glowLight)+De([e+1,16,1,1],r.glass,.2);const o=t==="aside"?e+1:e;return De([o,16,3,1.1],r.glow)+De([o,17,3,1],r.glowLight)}function hw(e,t){return e==="open"?De([13,20,6,1.1],t.glowLight)+De([15,21,2,1],t.glow):e==="mid"?De([14,20,4,1],t.glowLight):De(e==="aside"?[17,20,2,1]:[15,20,2,1],t.glow)}const fw=[13,15,17,19,21,23];function mw(e){return[fw.map(t=>De([9.2,t,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(t=>De([t,25.2,1,1.6],e.shellLight,.2)+De([t,25.2,1,.8],e.frame,.2)).join("")].join("")}function tf(e,t,r){return[`<rect x="${e}" y="15" width="5.4" height="11" rx="1.7" fill="${t.cup}" ${r}/>`,De([e+1,16,1.2,9],t.cupLight,.5),De([e+3.6,16,.9,9],t.cupDark,.4)].join("")}function pw(e,{lamp:t=Nm,simple:r=!1,colors:o=uw}={}){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"/>`,tf(.6,l,h),tf(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?"":mw(l),ef(11,c,l),ef(18,c,l),hw(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="${t[e.light??"on"]}" stroke="${l.ink}" stroke-width=".7"/>`,"</g>"].join("")}const bm={crt:{id:"crt",name:"Day",blurb:"The original CRT head with ear cups and a baseball cap.",lamp:Nm,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:dw,wave:{bar:"#66828d",lead:"#e8833a"}}},gw="crt",vw={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"}},yw={idle:"WATCHING",speaking:"TALKING",alert:"NEEDS YOU",thinking:"THINKING"},fn={msPerChar:55,mouthHoldMs:110,blinkEveryMs:5600,blinkMs:140,thinkingStepMs:520};function kw(e){return e?/[aeiouy]/i.test(e)?"open":/[a-z0-9]/i.test(e)?"mid":"rest":"rest"}function ww(e,t){return!e||!/[a-z0-9]/i.test(e)?0:/[aeiou]/i.test(e)?2+(e.charCodeAt(0)+t)%2:1+(e.charCodeAt(0)*7+t)%2}function xw(e,t,r){return Array.from({length:r},(o,l)=>{const c=t-(r-1-l);return c>=0&&c<e.length?ww(e[c],c):0})}function Cm({face:e={eyes:"open",mouth:"rest"},variant:t="crt",size:r,simple:o,className:l}){const{eyes:c,mouth:d,light:h}=e,g=k.useMemo(()=>pw({eyes:c,mouth:d,light:h},{lamp:bm[t].lamp,simple:o??r<28}),[c,d,h,t,o,r]);return i.jsx("svg",{className:l,width:r,height:r,viewBox:"0 0 200 200","aria-hidden":"true",dangerouslySetInnerHTML:{__html:g}})}function jw(e){const[t,r]=k.useState(!1);return k.useEffect(()=>{if(!e){r(!1);return}let o;const l=setInterval(()=>{r(!0),o=setTimeout(()=>r(!1),fn.blinkMs)},fn.blinkEveryMs);return()=>{clearInterval(l),o&&clearTimeout(o)}},[e]),t}const Sw={xs:.8,sm:2,md:4,lg:6},Nw=40,nf=20,sf="(prefers-reduced-motion: reduce)",bw=40,Cw=350;function $w(e,t){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:t||d}}const Tw=e=>e.length*fn.msPerChar,Ew=(e,t)=>t&&(e.effective==="idle"||e.effective==="speaking"||e.effective==="alert");function Iw(e,t,r,o){const l=vw[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(t/fn.msPerChar));const m=Math.floor(t/fn.mouthHoldMs)*Math.round(fn.mouthHoldMs/fn.msPerChar);d=kw(e.text[Math.min(e.text.length-1,m)])}let g=l.light;return e.effective==="thinking"&&!e.reduced&&Math.floor(t/fn.thinkingStepMs)%2===1&&(g="on"),{eyes:c,mouth:d,light:g,cursor:h}}function Mw(e,t){const r=typeof e.size=="number"?e.size:Sw[e.size],o=e.reduced?Math.min(e.text.length-1,nf-1):t;return{base:r,px:Nw*r,bars:nf,waveCursor:o}}function Aw(e,{label:t,speechDone:r,cursor:o,caption:l}){const c=e.talking&&r?"idle":e.effective,d=yw[c],h=e.size==="md"||e.size==="lg"||typeof e.size=="number"&&e.size>=4;return{shownState:c,status:d,ariaLabel:`${t}, ${d.toLowerCase()}`,showCaption:l??h,shown:Lw(e,r,o)}}function Lw(e,t,r){return e.talking?e.reduced||t?e.text:e.text.slice(0,r+1):""}function Rw(){const[e,t]=k.useState(()=>{var r;return typeof window<"u"&&!!((r=window.matchMedia)!=null&&r.call(window,sf).matches)});return k.useEffect(()=>{var l;const r=(l=window.matchMedia)==null?void 0:l.call(window,sf);if(!r)return;const o=()=>t(r.matches);return o(),r.addEventListener("change",o),()=>r.removeEventListener("change",o)},[]),e}function Ow(e,t,r){const[o,l]=k.useState(0);return k.useEffect(()=>{if(l(0),!t)return;const c=performance.now(),d=setInterval(()=>l(performance.now()-c),r);return()=>clearInterval(d)},[e,t,r]),o}function Pw(e){const{key:t,talking:r,at:o}=e,l=o!==void 0,c=Tw(e.text),[d,h]=k.useState(""),g=k.useRef(e.onSpeakEnd);g.current=e.onSpeakEnd,k.useEffect(()=>{if(!r||l)return;const j=setTimeout(()=>{var T;h(t),(T=g.current)==null||T.call(g)},c+Cw);return()=>clearTimeout(j)},[r,t,c,l]);const m=r&&d!==t,v=Ow(t,e.animate&&(m||e.thinking),m?bw:fn.thinkingStepMs),w=o??v,x=r&&(l?w>=c:d===t);return{t:w,speechDone:x}}const _w=e=>e*2,ec=3.5;function Dw(e,t,r){return(e??[]).map((o,l)=>{const c=(1+2*o)*.5;return{x:l*2,y:(ec-c)/2,width:1,height:c,fill:l>=t-2&&o>0?r.lead:r.bar}})}function Bw({heights:e,bars:t,unit:r,colors:o}){const l=_w(t);return i.jsx("svg",{className:`scout-wave${e?" on":""}`,width:l*r,height:ec*r,viewBox:`0 0 ${l} ${ec}`,"aria-hidden":"true",children:Dw(e,t,o).map((c,d)=>i.jsx("rect",{...c},d))})}function Po({state:e="idle",size:t="md",speaking:r,variant:o=gw,framed:l,caption:c,label:d="Scout",onSpeakEnd:h,at:g,className:m,style:v}){const w=$w({state:e,size:t,speaking:r,framed:l},Rw()),{text:x,effective:j,talking:T,reduced:S}=w,E=bm[o],R=!S&&!(g!==void 0),O=`${j}|${o}|${x}`,{t:X,speechDone:se}=Pw({key:O,text:x,talking:T,thinking:j==="thinking",animate:R,at:g,onSpeakEnd:h}),_=jw(Ew(w,R)),Q=T&&!se,{eyes:oe,mouth:G,light:ge,cursor:Re}=Iw(w,X,_,Q),{base:be,px:te,bars:P,waveCursor:Y}=Mw(w,Re),ae=k.useMemo(()=>Q?xw(x,Y,P):null,[Q,x,Y,P]),{shownState:Z,status:U,ariaLabel:B,showCaption:H,shown:$}=Aw(w,{label:d,speechDone:se,cursor:Re,caption:c}),D={...v,"--scout-u":`${be}px`},fe=i.jsx("span",{className:"scout-sprite",children:i.jsx(Cm,{face:{eyes:oe,mouth:G,light:ge},variant:o,size:te,simple:w.mini})});return w.framed?i.jsxs("figure",{className:`scout scout-panel scout-${Z} scout-v-${o} ${m??""}`,style:D,"data-state":Z,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:U})]}),i.jsxs("div",{className:"scout-feed",role:"img","aria-label":B,children:[fe,i.jsx(Bw,{heights:ae,bars:P,unit:be,colors:E.wave})]}),H&&i.jsxs("p",{className:"scout-caption","aria-hidden":"true",children:[$,T&&!se&&!S&&i.jsx("span",{className:"scout-caret",children:"_"})]}),x&&i.jsx("span",{className:"scout-sr","aria-live":"polite",children:x})]}):i.jsx("span",{className:`scout scout-bare scout-${Z} ${m??""}`,style:D,role:"img","aria-label":B,children:fe})}function zw(){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 Fw(){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 Uw({size:e=40,bare:t,className:r}){const o=k.useMemo(()=>t?Fw():zw(),[t]);return i.jsx("svg",{className:r,width:e,height:e,viewBox:"0 0 200 200",role:"img","aria-label":"Teamtrail",dangerouslySetInnerHTML:{__html:o}})}const xt="trail lead";function Hw({rt:e,guard:t,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,xt),claim:g=>t("Claim",()=>zh(e.adapter,o.current,g,{...h,assignee:xt})),release:g=>t("Release claim",()=>my(e.adapter,o.current,g,{...h,actor:xt})),releaseLease:g=>t("Release to queue",()=>e.leases.release(o.current,g,xt)),resolve:(g,m,v={})=>t("Resolve · record answer",async()=>{var x;const w=(x=l.current)==null?void 0:x.tickets.find(j=>j.id===g);w&&!w.assignee&&await zh(e.adapter,o.current,g,{...h,assignee:xt}),await jy(e.adapter,o.current,g,{...h,answer:m,author:xt,decision:{...v,source:{kind:"lookout",label:"Ticket inspector"}}})}),supersede:(g,m)=>t(`Supersede ${g.id}`,async()=>{let v=g.id;if(g.derived){const{id:w,mapId:x,derived:j,supersededBy:T,...S}=g;v=(await gc(e.adapter,g.mapId,S,{appendToTrail:!1})).id}await py(e.adapter,g.mapId,v,{...m,decidedBy:xt,participants:[{id:xt}],source:{kind:"lookout",label:"Logbook"}})}),graduate:({unspecified:g,...m})=>t(`Promote to ticket · ${g}`,async()=>{const v=await Sy(e.adapter,o.current,g,m);d({kind:"ticket",id:v.id})}),ruleOut:(g,m)=>t("Rule out of scope",async()=>{await Ny(e.adapter,o.current,g,{...h,reason:m,author:xt,source:{kind:"lookout",label:"Ticket inspector"}}),d(null)}),setMode:g=>t(`Trail mode · ${g}`,()=>gy(e.adapter,o.current,g)),setModelMatching:g=>t(`Model matching · ${g.enabled?"on":"off"}`,()=>by(e.adapter,o.current,g))}}const We=(...e)=>e.filter(Boolean).join(" "),Ps="item",Ww=/^[0-9a-f]{6,64}$/;function _o(){const e=new URLSearchParams(location.search).get("project")??void 0;return e&&Ww.test(e)?e:void 0}function Ne(e=_o()){return e?`${ve.apiPrefix}/p/${e}`:ve.apiPrefix}function Kw(e){const t=new URLSearchParams(location.search);for(const o of["projects","project","tracker",Ps])t.delete(o);e.item&&t.set(Ps,e.item),e.id&&e.id!==e.home&&t.set("project",e.id),e.id&&e.id!==e.home&&e.tracker&&t.set("tracker",e.tracker);const r=t.toString();return`${location.pathname}${r?`?${r}`:""}`}async function Vw(e,t){var c;const r=(t.assumptions??[]).map((d,h)=>({id:`S-${h+1}`,text:d,status:"holding",tickets:[]})),{map:o,tickets:l}=await sy(e,{title:t.title,sections:{destination:t.destination,notes:t.notes,decisions:[],unspecified:[],outOfScope:[],...r.length?{assumptions:r}:{}},tickets:[{ref:"discovery",...kk}]});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 $m(e,t){const r=URL.createObjectURL(new Blob([t],{type:"text/markdown;charset=utf-8"}));Object.assign(document.createElement("a"),{href:r,download:e}).click(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}function nn(e){const t=Math.max(0,Math.floor(e/1e3));return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:`${Math.floor(t/3600)}h`}function Tm(e){const t=Math.max(0,Math.floor(e/1e3)),r=o=>String(o).padStart(2,"0");return`${r(Math.floor(t/3600))}:${r(Math.floor(t%3600/60))}:${r(t%60)}`}const Do=e=>new Date(e).toTimeString().slice(0,8);function Wt(e){if(e<1e3)return`${Math.round(e)}ms`;const t=Math.round(e/1e3);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m ${String(t%60).padStart(2,"0")}s`:`${Math.floor(t/3600)}h ${String(Math.floor(t%3600/60)).padStart(2,"0")}m`}function Bo(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}const _s=e=>`$${e<10?e.toFixed(2):e.toFixed(1)}`,Ds=e=>new Date(e).toISOString().slice(0,10),kc=e=>new Date(e).toTimeString().slice(0,5),Gw=e=>`${Ds(e)} ${kc(e)}`,Em=e=>{if(!e)return"";const t=Math.max(0,Math.round((Date.now()-e)/1e3));return t<60?`${t}s ago`:`${Math.round(t/60)}m ago`},Ki=e=>e?new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",Bi={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"},qw={decided:"done",claimed:"working",frontier:"ready",blocked:"backlog",parked:"parked","out-of-scope":"cancelled",verifying:"verifying",rework:"rework",held:"blocked"};function wc(e,t){return new Map((e??[]).filter(r=>r.mapId===t&&!r.returned).map(r=>[r.ticketId,r]))}const xc=(e,t)=>`${e}/${t}`;let mn={reached:!1,live:!1,tickets:{}},tc=!1;const nc=new Set,sc=new Set;function yo(e){mn=e;for(const t of nc)t()}function rf(){fetch(`${Ne()}/verification/sync`).then(e=>e.ok?e.json():Promise.reject()).then(e=>yo({reached:!0,live:!0,status:e.status,tickets:Object.fromEntries(e.tickets.map(t=>[xc(t.mapId,t.ticketId),t]))}),()=>mn.reached&&yo({...mn,live:!1}))}function of(){tc=!0,rf();const e=new EventSource(`${Ne()}/events`);e.addEventListener("verification",t=>{const r=JSON.parse(t.data);if(r.kind==="evidence")for(const l of sc)l();if(r.kind!=="sync")return;const o={...mn.tickets};for(const l of r.tickets)o[xc(l.mapId,l.ticketId)]=l;yo({reached:!0,live:!0,status:r.status,tickets:o})}),e.addEventListener("error",()=>mn.reached&&mn.live&&yo({...mn,live:!1})),e.addEventListener("open",()=>mn.reached&&rf())}const Bs={subscribe(e){return tc||of(),nc.add(e),()=>void nc.delete(e)},get:()=>mn,onEvidence(e){return tc||of(),sc.add(e),()=>void sc.delete(e)},ticket:(e,t,r)=>e.tickets[xc(t,r)]};function Qw(e){if(e!=null&&e.flags.length)return e.flags.some(t=>t.severity==="alert")?"alert":"warn"}const af={onboarded:!1,tracker:"markdown",hitlTranscript:"summary",agent:ow.id,github:{repo:""},linear:{team:""},briefing:{enabled:!0,awayMinutes:15},theme:"night"};function jc(){try{const e={...af,...JSON.parse(localStorage.getItem(To)??"{}")};return["markdown","github","linear"].includes(e.tracker)||(e.tracker="markdown"),e}catch{return af}}function Mm(e){e==="auto"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e}const Yw=15*6e4;class Jw{constructor(t){ue(this,"leases",[]);ue(this,"changes",new Os);ue(this,"logged",new Set);ue(this,"since",Date.now()-Yw);this.activity=t}subscribe(t){return this.changes.on(t)}set(t){var r;this.leases=t;for(const o of t){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:Lk(o)}))}this.changes.emit(t)}async release(t,r,o){const l=await fetch(`${Ne()}/agents/leases/release`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,ticketId:r,by:o})});if(!l.ok)throw new Error((await l.json().catch(()=>({}))).error??`HTTP ${l.status}`)}}let Xt;const ko=new Set,zi=new Map;function Am(e){Xt==null||Xt.addEventListener(e,t=>{for(const r of zi.get(e)??[])r(t.data)})}function Lm(){if(!Xt){Xt=new EventSource(`${Ne()}/events`),Xt.onmessage=e=>{const t=JSON.parse(e.data).path;if(typeof t=="string")for(const r of ko)r(t)};for(const e of zi.keys())Am(e)}}function Rm(){const e=[...zi.values()].some(t=>t.size>0);ko.size||e||(Xt==null||Xt.close(),Xt=void 0)}function pn(e){return ko.add(e),Lm(),()=>{ko.delete(e),Rm()}}function zo(e,t){let r=zi.get(e);return r||(r=new Set,zi.set(e,r),Am(e)),r.add(t),Lm(),()=>{r.delete(t),Rm()}}function Xw(e,t){return zo(e,r=>t(JSON.parse(r)))}const Zw={async list(){return(await(await fetch(`${Ne()}/list`)).json()).files},async read(e){const t=await fetch(`${Ne()}/file?path=${encodeURIComponent(e)}`);if(!t.ok)throw new Error(`read ${e}: ${t.status}`);return t.text()},async write(e,t){const r=await fetch(`${Ne()}/file?path=${encodeURIComponent(e)}`,{method:"PUT",body:t});if(!r.ok)throw new Error(`write ${e}: ${r.status}`)},watch(e){return pn(e)}};function lf(e,t){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=>t.set(JSON.parse(o.data).leases)),fetch(`${Ne()}/agents/leases`).then(o=>o.ok?o.json():{leases:[]}).then(({leases:o})=>t.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 cf(e){const t=r=>`${To}:${e}:${r}`;return{get:r=>localStorage.getItem(t(r)),set:(r,o)=>{try{localStorage.setItem(t(r),o)}catch{}}}}const ex=["markdown","github","linear"];function tx(){const e=new URLSearchParams(location.search).get("tracker");return e&&ex.includes(e)?e:jc().tracker}function nx(e){let t,r;const o=new Ly,l=new Jw(o),c={},d=Ty(Ne());if(e==="github"||e==="linear"){const m=new sw(e,Ne());t=m,r=fetch(`${Ne()}/trackers`).then(v=>v.json()).catch(()=>{}).then(v=>{m.location=(e==="github"?v==null?void 0:v.github.repo:[v==null?void 0:v.linear.teamKey,v==null?void 0:v.linear.projectName].filter(Boolean).join(" · "))||m.location;const w=cf(`${e}:${m.location}`);c.presence=new Wh(w),o.ledger=new Kh(w),lf(o,l)})}else t=new tw(Zw,`./${ve.dataDir}`),r=fetch(`${Ne()}/list`).then(m=>m.json()).catch(()=>({root:"default"})).then(({root:m})=>{const v=cf(m);c.presence=new Wh(v),o.ledger=new Kh(v),lf(o,l)});const h=_y(t),g=h.adapter;return{kind:e,ready:r,get presence(){return c.presence},adapter:g,journal:d,monitor:h,activity:o,leases:l}}const tn=e=>e.status==="running",Om=e=>tn(e)&&!!e.waitingOn,sx={blocking:0,soon:1,fyi:2};function ix(e,t,r){const o=e.filter(d=>d.sessionId===t),l=o.find(d=>d.id===r);if(l)return l;const c=d=>sx[d.urgency??"soon"];return[...o].sort((d,h)=>c(d)-c(h)||d.at-h.at)[0]}function ts({n:e,urgent:t,pop:r,hideZero:o}){return i.jsx("span",{className:We("badge",t&&"urgent",r&&t&&"pop",o&&!e&&"zero"),children:o&&!e?"":e})}function K({variant:e="default",size:t="md",on:r,className:o,type:l,...c}){return i.jsx("button",{type:l??"button",className:We("btn",e!=="default"&&e,t==="sm"&&"sm",r&&"on",o),...c})}function Ot({as:e="div",tone:t,on:r,className:o,children:l,...c}){return i.jsx(e,{className:We("card",t,r&&"on",o),...c,children:l})}function ht({on:e,title:t,sub:r,disabled:o,onClick:l}){return i.jsxs(Ot,{as:"button",type:"button",className:"choice",on:e,disabled:o,onClick:l,children:[i.jsx("b",{className:"choice-title t-row-title",children:t}),r&&i.jsx("span",{className:"c-sub",children:r})]})}function Ee({children:e}){return i.jsx("div",{className:"empty",children:e})}function Dn({title:e,hint:t,art:r}){return i.jsxs("div",{className:r?"empty-state has-art":"empty-state",children:[r,i.jsxs("div",{className:"es-words",children:[i.jsx("span",{className:"es-title",children:e}),t&&i.jsx("span",{className:"es-hint",children:t})]})]})}function Ye({label:e,children:t,className:r}){return i.jsxs("label",{className:We("field",r),children:[e,t]})}const Sc=k.forwardRef(function({value:t,onValueChange:r,onSubmit:o,action:l="Send",actionDisabled:c,className:d,...h},g){return i.jsxs("form",{className:We("input-row",d),onSubmit:m=>{m.preventDefault(),o(t)},children:[i.jsx("textarea",{ref:g,rows:1,value:t,onChange:m=>r(m.target.value),onKeyDown:m=>{m.key==="Enter"&&!m.shiftKey&&(m.preventDefault(),o(t))},...h}),i.jsx(K,{type:"submit",variant:"primary",disabled:c??(h.disabled||!t.trim()),children:l})]})});function Us({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 Je({as:e="span",variant:t="chip",hot:r,size:o,className:l,children:c,title:d}){return i.jsx(e,{className:We(t==="chip"?"chip-label":"mono-label",r&&"hot",o==="sm"&&(t==="chip"?"sm":"xs"),l),title:d,children:c})}const rx=e=>typeof e=="string"?{text:e}:e,ox=e=>We(e.code&&"t-code",e.strong&&"strong",e.urgent&&"urgent",e.className);function q(e){const t=e.parts.filter(r=>!!r&&(typeof r=="string"||!!r.text)).map(rx);return!t.length&&!e.children?null:i.jsxs("span",{className:We("meta-line t-meta",e.className),children:[t.map((r,o)=>i.jsxs("span",{children:[o>0&&i.jsx("span",{className:"sep",children:" · "}),i.jsx("span",{className:ox(r)||void 0,title:r.tip,children:r.text})]},o)),e.children]})}function Nc(e){return i.jsxs("div",{className:"ds-load-failed",role:"alert",children:[i.jsx(q,{parts:[e.what,e.reason]}),i.jsx(K,{size:"sm",variant:"ghost",onClick:e.onRetry,children:"Retry"})]})}function Hs(e){const t=Array.from({length:e.rows??0},(r,o)=>o);return i.jsxs("div",{className:We("ds-loading",e.className),role:"status","aria-live":"polite",children:[i.jsxs("span",{className:"ds-loading-line t-meta",children:[i.jsx("span",{className:"ds-spinner","aria-hidden":"true"}),e.label]}),t.length>0&&i.jsx("ul",{className:"ds-skeleton-list","aria-hidden":"true",children:t.map(r=>i.jsxs("li",{className:"ds-skeleton-row",children:[i.jsx("span",{className:"ds-skeleton-bar title"}),i.jsx("span",{className:"ds-skeleton-bar meta"})]},r))})]})}const ax="M25.53 10.5 A11 11 0 1 1 16 5",lx="M20 5 L14.6 1.6 L14.6 8.4 Z";function Ws({variant:e="mark",state:t="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-${t} ${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:t==="syncing"?"5 3.6":void 0}):i.jsx("path",{d:ax,fill:"none",stroke:"currentColor",strokeWidth:c,strokeLinecap:"butt"}),(e==="mark"||e==="action")&&i.jsx("path",{d:lx,fill:"currentColor"}),e==="action"&&i.jsx("path",{d:"M13 11 L21.5 16 L13 21 Z",fill:"currentColor"}),(e==="mark"||e==="voice")&&i.jsx("circle",{cx:"16",cy:"16",r:e==="voice"?4:3.4,fill:"currentColor"}),e==="status"&&(t==="idle"?i.jsx("circle",{cx:"16",cy:"16",r:"3.4",fill:"none",stroke:"currentColor",strokeWidth:"1.6"}):i.jsx("circle",{cx:"16",cy:"16",r:"4.2",fill:"currentColor"})),e==="alert"&&i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"14.4",y:"8.5",width:"3.2",height:"9.5",fill:"currentColor"}),i.jsx("rect",{x:"14.4",y:"20.5",width:"3.2",height:"3.2",fill:"currentColor"})]})]})}function wo({parts:e,className:t,as:r="div"}){const o=e.filter(l=>l!=null&&l!==!1&&l!=="");return i.jsx(r,{className:We("meta",t),children:o.map((l,c)=>i.jsxs("span",{children:[c>0&&" · ",l]},c))})}function cx({size:e=40,bare:t,className:r}){return i.jsx(Uw,{size:e,bare:t,className:r})}const uf=()=>{const e=document.documentElement.dataset.theme;return e?e==="night":matchMedia("(prefers-color-scheme: dark)").matches};function bc(){const[e,t]=k.useState(uf);return k.useEffect(()=>{const r=()=>t(uf()),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 ux(){const e=()=>window.innerWidth>=1440?"wide":window.innerWidth>=1024?"laptop":"mobile",[t,r]=k.useState(e);return k.useEffect(()=>{const o=()=>r(e());return window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)},[]),t}const dx=15e3,df=["pointerdown","pointermove","keydown","wheel","touchstart"];function hx(e,t,r,o){const[l,c]=k.useState(null),[d,h]=k.useState(!1),[g,m]=k.useState(!1),v=k.useRef(),w=k.useRef(Date.now()),x=k.useRef(!1),j=r.awayMinutes*6e4,T=k.useRef(t);T.current=t;const S=k.useRef(o);S.current=o;const E=k.useCallback((_,Q)=>{const oe=T.current;return sk({snaps:Object.values(oe.allSnaps),decisions:oe.decisions,activity:oe.activity,ledger:e.activity.ledger,since:G=>{var ge;return _[G]??Q??((ge=oe.allSnaps[G])==null?void 0:ge.map.createdAt)??Date.now()},currentMapId:oe.mapId,attention:S.current})},[e]),M=k.useCallback((_=Date.now())=>{var Q;return(Q=e.presence)==null?void 0:Q.markSeen(T.current.maps.map(oe=>oe.id),_)},[e]),R=k.useCallback(()=>{const _=e.presence;if(!_)return;const Q=_.lastSeenAny();if(Q!==void 0&&Date.now()-Q>=j){const oe=_.snapshot();E(oe,Q).changed&&(v.current={seen:oe,any:Q},h(!0),r.enabled?c(oe):m(!0))}M()},[e,j,r.enabled,E,M]);k.useEffect(()=>{!t.loaded||x.current||!e.presence||(x.current=!0,R())},[t.loaded,e,R]),k.useEffect(()=>{const _=()=>{const G=Date.now()-w.current>=j;w.current=Date.now(),G&&x.current&&document.visibilityState==="visible"&&R()},Q=()=>{if(document.visibilityState!=="visible"){x.current&&M(Date.now()-w.current<j?Date.now():w.current);return}w.current=Date.now(),x.current&&R()};for(const G of df)window.addEventListener(G,_,{passive:!0});document.addEventListener("visibilitychange",Q);const oe=setInterval(()=>{x.current&&document.visibilityState==="visible"&&M(w.current)},dx);return()=>{for(const G of df)window.removeEventListener(G,_);document.removeEventListener("visibilitychange",Q),clearInterval(oe)}},[j,R,M]);const O=k.useMemo(()=>{var _;return l?E(l,(_=v.current)==null?void 0:_.any):void 0},[l,E,t.allSnaps,t.decisions,t.activity,o]),X=k.useMemo(()=>O?ak(O):"",[O]);k.useEffect(()=>{l&&m(!1)},[l]);let se="none";return g?se="new":d&&(se="seen"),{shown:l!==null,status:se,briefing:O,line:X,open:()=>{const _=v.current;_&&c(_.seen)},dismiss:()=>c(null)}}function fx(e){const[t,r]=k.useState(e.leases.leases);return k.useEffect(()=>e.leases.subscribe(r),[e]),t}function mx(e){var U;const[t,r]=k.useState([]),[o,l]=k.useState(),[c,d]=k.useState(),[h,g]=k.useState({}),[m,v]=k.useState({}),[w,x]=k.useState(!1),[j,T]=k.useState(e.activity.snapshot),[S,E]=k.useState(e.monitor.health),M=fx(e);k.useEffect(()=>e.monitor.subscribe(E),[e]);const[R,O]=k.useState(null),[X,se]=k.useState(),[_,Q]=k.useState(),oe=k.useRef(),G=k.useRef(),ge=k.useRef(new Set),Re=k.useRef();Re.current=c;const be=k.useCallback(B=>{oe.current=B,l(B),O(null)},[]),te=k.useCallback(async()=>{var pe;const B=await e.adapter.listMaps();r(B);let H=oe.current;const $=G.current;$&&B.some(de=>de.id===$)?(G.current=void 0,H=$,H!==oe.current&&be(H)):(!H||!B.some(de=>de.id===H))&&(H=(pe=B[0])==null?void 0:pe.id,be(H));const[D,fe]=await Promise.all([Promise.all(B.map(de=>e.adapter.loadMap(de.id))),Promise.all(B.map(de=>e.adapter.listDecisions(de.id)))]);g(Object.fromEntries(D.map(de=>[de.map.id,de]))),v(Object.fromEntries(B.map((de,xe)=>[de.id,fe[xe]]))),x(!0),d(D.find(de=>de.map.id===H))},[e,be]);k.useEffect(()=>{let B,H=()=>{},$=()=>{},D=!0;const fe=()=>{clearTimeout(B),B=setTimeout(()=>void te().catch(me=>se(String(me))),40)},pe=(me,ye)=>tn(me)&&e.activity.isRemote(me.id)&&(!ye||!me.mapId||me.mapId===ye),de=me=>{var ye;return(ye=Re.current)==null?void 0:ye.tickets.find($e=>$e.id===me)},xe=me=>{const ye=Ry(me,de),$e=me.kind==="external.changed"&&e.activity.snapshot.sessions.some(ss=>pe(ss,me.mapId)),ct=!("mapId"in me)||!me.mapId||me.mapId===oe.current||me.kind==="map.created";ye&&!$e&&ct&&e.activity.push(ye),fe()};return e.ready.then(()=>{D&&(H=e.adapter.subscribe(xe),$=e.activity.subscribe(T),e.activity.push({source:"system",level:"ok",text:`Online · tracker ${e.adapter.label.toLowerCase()} · ${e.adapter.location}`}),te().catch(me=>se(String(me))))}),()=>{D=!1,H(),$(),clearTimeout(B)}},[e,te]),k.useEffect(()=>{o&&e.adapter.loadMap(o).then(d)},[o,e]),k.useEffect(()=>{for(const B of j.sessions)B.mode!=="chart"||!B.mapId||!e.activity.isRemote(B.id)||ge.current.has(B.id)||(ge.current.add(B.id),!(B.status!=="running"&&Date.now()-(B.endedAt??0)>6e4)&&(G.current=B.mapId,te().catch(H=>se(String(H)))))},[j.sessions,e,te]);const P=(U=j.pending[0])==null?void 0:U.sessionId;k.useEffect(()=>{if(!P)return;const B=H=>e.activity.snapshot.sessions.some($=>$.id===H&&tn($));Q(H=>B(H)?H:P)},[P,e]);const Y=k.useCallback(async(B,H)=>{e.activity.push({source:"trail lead",agent:xt,level:"warn",text:B});try{se(void 0),await H()}catch($){const D=$.message??String($);se(D),e.activity.push({source:"trail lead",agent:xt,level:"alert",text:`Rejected · ${D}`})}},[e]),ae=k.useMemo(()=>Hw({rt:e,guard:Y,setMapId:be,mapIdRef:oe,snapRef:Re,setChatSession:Q,setSelection:O}),[Y,e,be]),Z=k.useMemo(()=>Object.values(h).flatMap(B=>Uy(B,m[B.map.id]??[])).sort((B,H)=>H.decidedAt-B.decidedAt),[h,m]);return{maps:t,allSnaps:h,mapId:o,snap:c,activity:j,health:S,selection:R,setSelection:O,error:X,chatSession:_,decisions:Z,leases:M,loaded:w,actions:ae}}function sn(e=1e3){const[t,r]=k.useState(Date.now());return k.useEffect(()=>{const o=setInterval(()=>r(Date.now()),e);return()=>clearInterval(o)},[e]),t}function px(){const[e,t]=k.useState(jc),r=k.useCallback(o=>{t(l=>{const c={...l,...o};return localStorage.setItem(To,JSON.stringify(c)),c})},[]);return[e,r]}function Cc(){return k.useSyncExternalStore(Bs.subscribe,Bs.get)}function Pm({className:e,size:t=18}){return i.jsx("span",{className:e,"aria-hidden":"true",children:i.jsx(Cm,{size:t,variant:bc()?"night":"crt"})})}function Ke({as:e="section",className:t,style:r,frameless:o,children:l,...c}){return i.jsx(e,{className:We("panel",o&&"frameless",t),style:r,...c,children:l})}function zn({tone:e,className:t,children:r,title:o}){return i.jsx("span",{className:We("pill",e,t),title:o,children:r})}function Zt({label:e,value:t,layout:r="stack",urgent:o,title:l,className:c}){return i.jsxs("span",{className:We("readout",r!=="stack"&&r,o&&"urgent",c),title:l,children:[i.jsx("span",{className:"mono-label",children:e}),r==="inline"&&" ",i.jsx("b",{children:t})]})}function Ae(e){const{as:t="div",edge:r="neutral"}=e,o=e.onOpen?"button":"div";return i.jsxs(t,{className:We("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,"aria-current":e.current,children:[i.jsxs("span",{className:"ds-row-top",children:[i.jsx("span",{className:"ds-row-title t-row-title",children:e.title}),e.trailing&&i.jsx("span",{className:"ds-row-trail t-meta",children:e.trailing})]}),e.context&&i.jsx("span",{className:"ds-row-context",children:e.context}),e.detail&&i.jsx("span",{className:"ds-row-detail t-meta",title:e.detailText,children:e.detail})]}),e.actions&&i.jsx("span",{className:"ds-row-actions",children:e.actions}),e.below&&i.jsx("div",{className:"ds-row-below",children:e.below})]})}const Pn="#c8581e",gx={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:Pn,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:Pn})]}),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:Pn})]}),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:Pn,stroke:Pn})]}),tent:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 4L2.5 20h19z"}),i.jsx("path",{d:"M12 11l-4 9h8z",fill:Pn,stroke:Pn}),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:Pn})]})};function _m({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:gx[e]})}function Ct({title:e,count:t,right:r,hot:o,sub:l,children:c,className:d,info:h,icon:g}){return i.jsxs("header",{className:We("sec-h",l&&"sub",d),children:[c,g&&i.jsx(_m,{name:g}),e!==void 0&&i.jsx(Je,{as:l?"h3":"h2",hot:o,children:e}),h&&i.jsx(Us,{text:h}),t,r!==void 0&&i.jsx("span",{className:"sec-h-right",children:r})]})}function ft(e){const{value:t,options:r,onChange:o}=e,[l,c]=k.useState(!1),[d,h]=k.useState(0),[g,m]=k.useState(),v=k.useRef(null),w=k.useRef(null),x=k.useId(),j=r.find(M=>M.value===t);k.useLayoutEffect(()=>{if(!l||!v.current)return;const M=v.current.getBoundingClientRect();m({left:M.left,top:M.bottom+4,minWidth:M.width})},[l]),k.useEffect(()=>{if(!l)return;const M=O=>{var X,se;O.target instanceof Node&&((X=w.current)!=null&&X.contains(O.target)||(se=v.current)!=null&&se.contains(O.target))||c(!1)},R=()=>c(!1);return document.addEventListener("mousedown",M),window.addEventListener("resize",R),window.addEventListener("scroll",R,!0),()=>{document.removeEventListener("mousedown",M),window.removeEventListener("resize",R),window.removeEventListener("scroll",R,!0)}},[l]),k.useEffect(()=>{var M,R;l&&((R=(M=w.current)==null?void 0:M.querySelector(`[data-i="${d}"]`))==null||R.scrollIntoView({block:"nearest"}))},[l,d]);const T=()=>{h(Math.max(0,r.findIndex(M=>M.value===t))),c(!0)},S=M=>{var O;const R=r[M];c(!1),(O=v.current)==null||O.focus(),R&&R.value!==t&&o(R.value)},E=M=>{if(!l){["ArrowDown","ArrowUp","Enter"," "].includes(M.key)&&(M.preventDefault(),T());return}const R=O=>h(X=>(X+O+r.length)%r.length);if(M.key==="ArrowDown")R(1);else if(M.key==="ArrowUp")R(-1);else if(M.key==="Home")h(0);else if(M.key==="End")h(r.length-1);else if(M.key==="Enter"||M.key===" ")S(d);else{if(M.key==="Escape"||M.key==="Tab")return c(!1);if(M.key.length===1){const O=r.findIndex(X=>X.label.toLowerCase().startsWith(M.key.toLowerCase()));O>=0&&h(O);return}else return}M.preventDefault()};return i.jsxs(i.Fragment,{children:[i.jsxs("button",{ref:v,type:"button",className:We("select",e.compact&&"compact",l&&"open",e.className),role:"combobox","aria-haspopup":"listbox","aria-expanded":l,"aria-controls":x,"aria-label":e["aria-label"],"aria-activedescendant":l?`${x}-${d}`:void 0,disabled:e.disabled,onClick:()=>l?c(!1):T(),onKeyDown:E,children:[i.jsx("span",{className:"select-value",children:(j==null?void 0:j.label)??"—"}),i.jsx("span",{className:"select-caret","aria-hidden":"true"})]}),l&&g&&i.jsx("ul",{ref:w,id:x,className:"select-menu",role:"listbox",style:g,children:r.map((M,R)=>i.jsxs("li",{id:`${x}-${R}`,"data-i":R,role:"option","aria-selected":M.value===t,className:We(R===d&&"active"),onMouseEnter:()=>h(R),onMouseDown:O=>O.preventDefault(),onClick:()=>S(R),children:[i.jsx("span",{className:"select-label",children:M.label}),M.hint&&i.jsx("span",{className:"select-hint",children:M.hint})]},M.value))})]})}function Dm(e){return i.jsx("div",{className:`tabs ${e.className??""}`,role:"tablist",children:e.items.map(t=>i.jsxs("button",{role:"tab","aria-selected":e.value===t.id,className:`tab ${e.value===t.id?"on":""}`,onClick:()=>e.onChange(t.id),children:[t.label,t.n!==void 0&&i.jsx("span",{className:"n",children:t.n})]},t.id))})}const vx=350;function yx(){const[e,t]=k.useState(null);if(k.useEffect(()=>{let o=0,l=null;const c=()=>{window.clearTimeout(o),l=null,t(null)},d=v=>{const w=v.getAttribute("data-tip");if(!w)return;const x=v.getBoundingClientRect(),j=x.bottom+60>window.innerHeight;t({text:w,x:x.left+x.width/2,y:j?x.top-8:x.bottom+8,above:j,scout:v.hasAttribute("data-tip-scout")})},h=v=>{var j,T;const w=(T=(j=v.target)==null?void 0:j.closest)==null?void 0:T.call(j,"[data-tip], [title]");if(!w||w instanceof SVGElement)return null;const x=w.getAttribute("title");return x&&(w.setAttribute("data-tip",x),w.removeAttribute("title")),w},g=v=>{if(v.pointerType==="touch")return;const w=h(v);w!==l&&(c(),w&&(l=w,o=window.setTimeout(()=>l===w&&d(w),v.type==="focusin"?0:vx)))},m=v=>{l&&!l.contains(v.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(Po,{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 Bm({as:e="span",className:t}){return i.jsx(e,{className:t,children:ve.name})}function zm(e){return e.bare?i.jsx("div",{className:`zone-b ${e.className??""}`,children:e.children}):i.jsxs(Ke,{className:`zone ${e.className??""}`,style:e.area?{gridArea:e.area}:void 0,children:[i.jsx(Ct,{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 Es(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 oo(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 Ri(e){return i.jsxs(Ot,{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(q,{parts:[],children:e.sub})]})}const kx=864e5;function wx(e,t){const r=new Date(e),o=r.toTimeString().slice(0,5),l=new Date(t).toDateString(),c=new Date(t-kx).toDateString();let d=` ${r.toLocaleDateString(void 0,{month:"short",day:"numeric"})}`;return r.toDateString()===l?d="":r.toDateString()===c&&(d=" yesterday"),`Since ${o}${d} · ${Wt(t-e)}`}function xx(e){const{briefing:t,bp:r,onClose:o}=e;k.useEffect(()=>{const w=x=>x.key==="Escape"&&o();return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[o]);const l=t==null?void 0:t.trails.flatMap(w=>w.waiting).sort((w,x)=>w.at-x.at)[0],c=t==null?void 0:t.totals,d=((t==null?void 0:t.trails.length)??0)>1,h=r==="mobile",g=w=>{var x,j;return w.ticketId&&((j=(x=e.snaps[w.mapId])==null?void 0:x.tickets.find(T=>T.id===w.ticketId))==null?void 0:j.title)||w.text},m=w=>{var x,j;return w.ticketId&&((j=(x=e.snaps[w.mapId])==null?void 0:x.tickets.find(T=>T.id===w.ticketId))==null?void 0:j.key)||w.agent},v=w=>{const x=(M,R)=>i.jsx(oo,{k:M.key,text:M.title,meta:R,onClick:()=>e.onTicket(w.mapId,M.id)},M.id),j=(M,R)=>i.jsx(oo,{k:M.id,text:M.summary||M.answer,title:M.risk?`${M.question}
|
|
118
|
+
|
|
119
|
+
${M.risk.reason}`:M.question,meta:R,onClick:()=>e.onDecision(M.id)},M.id),T=Mk(w.agentDecisions).flatMap(M=>M.decisions.map(R=>j(R,M.label))),S=[i.jsx(Es,{title:"Done",children:w.done.map(M=>x(M))},"done"),i.jsx(Es,{title:"Ruled out",children:h?[]:w.ruledOut.map(M=>x(M))},"oos"),i.jsx(Es,{title:"Blocked",children:w.blocked.map(M=>x(M.ticket,`needs ${M.on.map(R=>R.key).join(", ")}`))},"blocked")],E=[i.jsx(Es,{title:"Waiting on you",urgent:!0,children:w.waiting.map(M=>i.jsx(oo,{k:m(M),text:g(M),meta:t.now-M.at<6e4?"now":Wt(t.now-M.at),title:M.text,onClick:()=>e.onAnswer(M)},M.id))},"waiting"),i.jsx(Es,{title:"Agent decisions",children:h?[]:T},"agent"),i.jsx(Es,{title:"Active sessions",children:h?[]:w.active.map(M=>{var O;const R=M.ticketId?(O=e.snaps[w.mapId])==null?void 0:O.tickets.find(X=>X.id===M.ticketId):void 0;return i.jsx(oo,{k:(R==null?void 0:R.key)??M.agent,text:R?`${R.title} · ${M.stepLabel}`:M.stepLabel,meta:`${M.step}/${M.total}`,onClick:()=>e.onSession(M)},M.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:w.key})," ",w.title]}),i.jsxs("div",{className:"bf-cols",children:[i.jsx("div",{children:S}),i.jsx("div",{children:E})]})]},w.mapId)};return i.jsx("div",{className:"scrim",onClick:o,children:i.jsxs(Ke,{as:"div",className:"dialog briefing",role:"dialog","aria-label":"While you were away",onClick:w=>w.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:"While you were away"}),t&&t.trails.length>0&&i.jsx(Je,{className:"bf-since",children:wx(t.since,t.now)}),i.jsx("button",{className:"icon-btn",onClick:o,"aria-label":"Close",children:"×"})]}),i.jsxs(Ot,{className:"bf-scout",children:[i.jsx(Po,{size:h?1.1:1.3,speaking:e.line||"Nothing new since you were last here.",caption:!1,framed:!1}),i.jsxs("div",{children:[i.jsx("span",{className:"mono-label",children:"Scout"}),i.jsx("p",{children:e.line||"Nothing new since you were last here."})]})]}),t&&c&&t.trails.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"bf-tiles",children:[i.jsx(Ri,{label:"Done",value:c.done,sub:c.ruledOut?`${c.ruledOut} ruled out`:void 0}),i.jsx(Ri,{label:"Blocked",value:c.blocked,sub:c.blocked?"Needs your answer":void 0}),i.jsx(Ri,{label:"Waiting on you",value:c.waiting,sub:jx(c.oldestWaitMs),urgent:c.waiting>0}),i.jsx(Ri,{label:"Agent decisions",value:c.agentDecisions,className:"opt"}),i.jsx(Ri,{label:"Spend",value:_s(c.usage.costUsd),sub:`${Bo(c.usage.inputTokens+c.usage.outputTokens)} tokens · ${c.usage.sessions} sessions${c.active?` · ${c.active} active`:""}`})]}),i.jsx("div",{className:"bf-body",children:t.trails.map(v)})]}),i.jsxs("footer",{children:[i.jsx(K,{onClick:o,children:"Dismiss"}),l?i.jsxs(K,{variant:"urgent",onClick:()=>e.onAnswer(l),children:[i.jsx(Ws,{variant:"alert",size:13}),"Answer first decision"]}):i.jsx(K,{variant:"primary",onClick:e.onResume,children:"Resume trail"})]})]})})}function jx(e){if(e!==void 0)return e<6e4?"Just asked":`Oldest ${Wt(e)}`}function Sx(e){const{brief:t,bp:r}=e;return i.jsx(xx,{briefing:t.briefing,line:t.line,snaps:e.snaps,bp:r,onClose:t.dismiss,onTicket:(o,l)=>{t.dismiss(),e.openTicket(o,l)},onAnswer:o=>{t.dismiss(),e.closeDecisions(),e.openChat(o.sessionId,o.ticketId,o.mapId)},onSession:o=>{t.dismiss(),e.closeDecisions(),e.openChat(o.id,o.ticketId,o.mapId)},onDecision:o=>{t.dismiss(),e.openDecisions(o)},onResume:()=>{t.dismiss(),e.closeDecisions(),r==="mobile"&&e.showPhoneHome()}})}const Nx={passed:"checks passed",failing:"checks failing",pending:"checks pending",unknown:"checks unknown",none:"no checks"};function bx({mapId:e,ticketId:t}){const r=Bs.ticket(Cc(),e,t);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:Nx[r.checksSummary]}),i.jsx("span",{className:"when",children:Cx(r)})]}),r.flags.map(l=>i.jsx(zn,{className:`flag flag-${l.severity}`,title:l.text,children:l.kind},l.kind))]})}function Cx(e){return e.error?"sync failed":e.syncedAt?Em(e.syncedAt):"not synced yet"}const $x={ok:"ok",failed:"error",stale:"syncing",unknown:"idle",off:"idle"};function Tx({now:e}){const t=Cc();if(!t.reached)return null;const r=Iy(t.live?t.status:null,e);return i.jsxs("span",{className:`tracker-chip pr-sync tone-${r.tone}`,title:r.title,children:[i.jsx(Je,{size:"sm",children:"CI"}),i.jsx(Ws,{variant:"status",state:$x[r.tone],size:13,className:"sync-glyph"}),i.jsx("span",{className:"tl",children:r.label})]})}function Fm(e){const t=e.role??"menu",[r,o]=k.useState(!1),l=k.useRef(null);return k.useEffect(()=>{if(!r)return;const c=d=>{var g;(d instanceof KeyboardEvent?d.key==="Escape":!((g=l.current)!=null&&g.contains(d.target)))&&o(!1)};return window.addEventListener("mousedown",c),window.addEventListener("keydown",c),()=>{window.removeEventListener("mousedown",c),window.removeEventListener("keydown",c)}},[r]),i.jsxs("div",{className:We("header-menu",e.className),ref:l,children:[i.jsxs(K,{variant:"ghost","aria-haspopup":t,"aria-label":e.ariaLabel,"aria-expanded":r,on:r,"data-tip":r?void 0:e.tip,onClick:()=>o(!r),children:[e.label," ",e.badge," ",i.jsx("span",{className:"caret",children:"▾"})]}),r&&i.jsx("div",{className:"header-menu-list",role:t,children:e.children(()=>o(!1))})]})}const Ex={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 Ix(e){const t=e.briefingStatus==="new";return i.jsx(Fm,{label:"Records",badge:i.jsxs(i.Fragment,{children:[e.knowledge>0&&i.jsx("span",{className:"n hot",children:e.knowledge}),t&&i.jsx("span",{className:"new-dot","aria-label":"new trip report"})]}),children:r=>i.jsxs(i.Fragment,{children:[i.jsxs("button",{role:"menuitem",className:"header-menu-item",disabled:e.briefingStatus==="none"&&!e.briefingOpen,title:Ex[e.briefingStatus],onClick:()=>{r(),e.onBriefing()},children:[i.jsx("span",{children:"Trip report"}),t&&i.jsx("span",{className:"new-dot","aria-label":"new"})]}),i.jsxs("button",{role:"menuitem",className:"header-menu-item knowledge-btn",title:"What agents know about this codebase and product. Review suggestions, flags and stale entries",onClick:()=>{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 Mx=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"})]}),Ax=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 Lx({onToggle:e}){const t=bc(),r=t?"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(!t),children:i.jsx("svg",{viewBox:"0 0 18 18",width:"16",height:"16","aria-hidden":"true",children:t?Mx:Ax})})}const Rx={idle:"Idle",syncing:"Syncing",ok:"Synced",error:"Sync error"};function Ox({label:e,health:t,now:r}){const o=[`${Rx[t.status]} · ${t.writes} writes · ${t.errors} errors`,t.lastWriteAt?`Last write ${Wt(t.lastWriteMs??0)}, ${Wt(r-t.lastWriteAt)} ago`:"No writes yet",t.lastError].filter(Boolean).join(`
|
|
121
|
+
`);return i.jsxs("span",{className:`tracker-chip sync-${t.status}`,title:o,children:[i.jsx(Je,{size:"sm",children:"Tracker"}),i.jsx(Ws,{variant:"status",state:t.status,size:13,className:"sync-glyph"}),i.jsx("span",{className:"tl",children:e})]})}function Px(e){const[t,r]=k.useState(!1),o=k.useRef(null);k.useEffect(()=>{if(!t)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)}},[t]);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":t,"data-tip":"Switch trail, or start a new one",children:[i.jsx("span",{className:"trail-title",children:e.map?`${e.map.key} ${e.map.title}`:"No trail"}),d>0&&i.jsx(ts,{n:d,urgent:!0}),i.jsx("span",{className:"caret",children:"▾"})]}),t&&i.jsxs("div",{className:"trail-menu",role:"menu",children:[i.jsx(Je,{variant:"plain",className:"menu-h",children:"Trails"}),l.map(h=>{var v;const g=cm(h),m=c(h.map.id);return i.jsxs("button",{role:"menuitem",className:`trail-item ${h.map.id===((v=e.map)==null?void 0:v.id)?"on":""}`,onClick:()=>{e.onSelectMap(h.map.id),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(ts,{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 _x(e){const{map:t}=e,r=sn(1e3),o=e.activity.pending.length,l=t&&e.snaps[t.id],c=l&&cm(l),d=t&&um(e.activity,t.id);return i.jsxs(Ke,{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(Px,{...e})]}),i.jsxs("div",{className:"h-dest",title:t==null?void 0:t.sections.destination,children:[i.jsx(Je,{size:"sm",children:"Destination"}),(t==null?void 0:t.sections.destination)??"—"]})]}),i.jsxs("div",{className:"h-right",children:[i.jsx(Ox,{label:e.trackerLabel,health:e.health,now:r}),i.jsx(Tx,{now:r}),t&&c&&i.jsxs("span",{className:"trail-meta",children:[i.jsx(Zt,{label:"Trail T+",value:Tm(r-t.createdAt),title:"Trail elapsed time, since it was charted"}),i.jsx(Zt,{label:"Done",value:`${c.decided}/${c.total}`}),d&&i.jsx(Zt,{className:"spend",label:"Spent",value:`${_s(d.costUsd)} · ${Bo(d.inputTokens+d.outputTokens)} tok`,title:["Model spend and tokens for this trail, across every session",...hm(e.activity,t.id).map(h=>dm[h].text)].join(`
|
|
122
|
+
`)})]}),e.attention,!e.attention&&o>0&&i.jsxs("span",{className:"waiting-chip",title:`${o} waiting on you`,children:[i.jsx(Ws,{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"}),t&&i.jsx(K,{variant:"ghost",className:"mode-chip",onClick:e.onToggleMode,"data-tip":t.mode==="plan-only"?"Plan only: agents research and decide, but no execute tickets run. Click to switch to Plan + execute.":"Plan + execute: agents decide, then build what was decided. Click to switch to Plan only, which parks execute tickets.",children:t.mode==="plan-only"?"Plan only":"Plan + execute"}),i.jsx(Ix,{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(K,{variant:"ghost",onClick:e.onSettings,"data-tip":"Tracker, verification, appearance and integrations",children:"Settings"}),i.jsx(Lx,{onToggle:e.onToggleTheme})]})]})}const Um=k.createContext(null);function Ks(){const e=k.useContext(Um);if(!e)throw new Error("useKnowledge needs a KnowledgeContext provider");return e}function Dx({snap:e,t}){const r=Ks();if(!r.entries.length||t.state==="closed")return null;const o=xm(r.entries,{trailKey:e.map.key,ticket:{type:t.type,title:t.title,body:t.body},paths:jm(`${t.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(q,{parts:[{text:l.id,code:!0},l.status==="assumption"&&"assumption",l.mayBeOutdated&&{text:"may be outdated",className:"warn"}]})]},l.id))})]})}const Bx={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 t=Ks(),[r,o]=k.useState(!1),[l,c]=k.useState(e.title),[d,h]=k.useState(e.body);k.useEffect(()=>{o(!1),c(e.title),h(e.body)},[e.id,e.title,e.body]);const g=t.stale[e.id];return i.jsxs("div",{className:"kn-detail",children:[i.jsx(q,{parts:[{text:e.id,code:!0},e.kind.replace("-"," "),e.status]}),r?i.jsxs(i.Fragment,{children:[i.jsx(Ye,{label:"Title",children:i.jsx("input",{value:l,onChange:m=>c(m.target.value)})}),i.jsx(Ye,{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:Bx[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(", ")})]})]}),t.error&&i.jsx("p",{className:"vf-err",children:t.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 t.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 t.call(e.id,{kind:"confirm"}),children:e.status==="confirmed"?"Re-confirm":"Confirm"}),e.status!=="assumption"&&e.status!=="outdated"&&i.jsx(K,{onClick:()=>void t.call(e.id,{kind:"assumption"}),children:"Keep as assumption"}),e.flag&&i.jsx(K,{onClick:()=>void t.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 t.call(e.id,{kind:"outdated"}),children:"Mark outdated"})]})})]})}const Fx={suggested:"Suggested",confirmed:"Confirmed",assumption:"Assumption",outdated:"Outdated"};function Ux(){const e=Ks(),[t,r]=k.useState("review"),[o,l]=k.useState(""),[c,d]=k.useState(""),[h,g]=k.useState();k.useEffect(()=>{if(!e.open)return;const S=E=>E.key==="Escape"&&e.setOpen(!1);return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[e]);const m=S=>S.status==="suggested"||!!S.flag||!!e.stale[S.id]&&S.status!=="outdated",v=(S,E)=>E==="all"?!0:E==="review"?m(S):S.status===E,w=k.useMemo(()=>{const S=c.trim().toLowerCase();return e.entries.filter(E=>v(E,t)&&(!o||E.kind===o)&&(!S||`${E.id} ${E.title} ${E.body} ${E.tags.join(" ")}`.toLowerCase().includes(S)))},[e.entries,e.stale,t,o,c]);if(!e.open)return null;const x=w.find(S=>S.id===h)??w[0],j=S=>e.entries.filter(E=>v(E,S)).length,T=[["review","Needs you"],["confirmed","Confirmed"],["assumption","Assumptions"],["outdated","Outdated"],["all","All"]];return i.jsx("div",{className:"scrim",onClick:()=>e.setOpen(!1),children:i.jsxs(Ke,{as:"div",className:"dialog knowledge-view",onClick:S=>S.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:"Field guide"}),i.jsx(Us,{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:[T.map(([S,E])=>i.jsxs("button",{className:`chip ${t===S?"on":""}`,onClick:()=>r(S),children:[E," ",i.jsx("span",{className:"n",children:j(S)})]},S)),i.jsx(ft,{compact:!0,"aria-label":"Kind",value:o,onChange:l,options:[{value:"",label:"Any kind"},...Sk.map(S=>({value:S,label:S.replace("-"," ")}))]}),i.jsx("input",{className:"kn-search",placeholder:"Search",value:c,onChange:S=>d(S.target.value)})]}),i.jsxs("div",{className:"kn-body-grid",children:[i.jsx("ul",{className:"kn-list",children:w.length?w.map(S=>i.jsx(Ae,{as:"li",className:`kn-row st-${S.status}`,edge:m(S)?"attention":"neutral",selected:S===x,onOpen:()=>g(S.id),title:S.title,titleText:S.title,context:i.jsx(q,{parts:[{text:S.id,code:!0},S.kind.replace("-"," "),m(S)&&S.status!=="suggested"?"Needs a check":Fx[S.status]]})},S.id)):i.jsx(Ee,{children:t==="review"?"Nothing needs you":"No entries"})}),x?i.jsx(zx,{e:x}):i.jsx(Ee,{children:"Pick an entry"})]})]})})}function $c({draft:e,label:t="Save as knowledge"}){const r=Ks(),[o,l]=k.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:t})}const Hm=`${Ne()}/knowledge`;async function hf(e,t){const r=await fetch(`${Hm}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),o=await r.json().catch(()=>({}));if(!r.ok)throw new Error(o.error??`HTTP ${r.status}`);return o}function Hx(e){const[t,r]=k.useState([]),[o,l]=k.useState({}),[c,d]=k.useState(!1),[h,g]=k.useState(),m=k.useCallback(()=>{fetch(Hm).then(w=>w.ok?w.json():null).then(w=>{w&&(r(w.entries),l(w.stale))}).catch(()=>{})},[]);k.useEffect(()=>(m(),pn(w=>w.startsWith("knowledge/")&&m())),[m]);const v=k.useMemo(()=>t.filter(w=>w.status==="suggested"||w.flag||o[w.id]&&w.status!=="outdated").length,[t,o]);return{entries:t,stale:o,briefText:e,attention:v,open:c,setOpen:d,error:h,call:(w,x)=>hf("/call",{id:w,call:x}).then(()=>(g(void 0),m(),!0),j=>(g(j.message),!1)),propose:w=>hf("/propose",w).then(x=>(m(),x.entry),x=>(g(x.message),void 0))}}function ic(e){const[t,r]=k.useState(!1),[o,l]=k.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"}),t?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 Wx=["awaiting","blocked","trail.done","resolved"],Kx=["commands","chat:write","im:write","channels:history","groups:history","im:history","mpim:history","users:read"],Vx=["users:read.email"],Gx="save_decision",qx=`/${ve.assistant.name.toLowerCase()}`;function Qx(e={}){const t=ve.assistant.name;return{display_information:{name:t,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:t,always_online:!0},slash_commands:[{command:e.command??qx,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:Gx,description:`Record this thread as a ${ve.name} decision`}]},oauth_config:{scopes:{bot:[...Kx,...Vx]}},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 Yx={create:e=>`https://api.slack.com/apps?new_app=1&manifest_json=${encodeURIComponent(JSON.stringify(Qx({command:e})))}`,app:e=>`https://api.slack.com/apps/${e}/general`,install:e=>`https://api.slack.com/apps/${e}/install-on-team`,home:(e,t)=>`slack://app?team=${e}&id=${t}&tab=home`,homeWeb:(e,t)=>`https://slack.com/app_redirect?app=${t}&team=${e}`};function Jx(e){const t=e.trim().match(/^xapp-\d+-(A[A-Z0-9]+)-/);return t==null?void 0:t[1]}async function es(e,t="GET",r){const o=await fetch(e,{method:t,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 Xx(e){const t=`${e}/slack`;return{get:()=>es(t),created:()=>es(`${t}/created`,"POST",{}),token:r=>es(`${t}/token`,"POST",{token:r}),update:r=>es(`${t}/settings`,"PUT",r),resetOwner:()=>es(`${t}/owner/reset`,"POST",{}),members:()=>es(`${t}/members`).then(r=>r.members),remove:()=>es(t,"DELETE")}}const Bn=Xx(Ne());function Zx(e){const[t,r]=k.useState(!1),[o,l]=k.useState(),c=d=>{r(!0),Bn.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(ic,{busy:t,placeholder:"xapp-… or xoxb-…",onToken:c}),o&&i.jsxs("div",{className:"test-line alert",children:["✕ ",o]})]})}function ej({onRemoved:e}){const[t,r]=k.useState(!1);if(!t)return i.jsx(K,{size:"sm",variant:"ghost",onClick:()=>r(!0),children:"Remove"});const o=()=>void Bn.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 tj={awaiting:"Awaiting you",blocked:"Blocked","trail.done":"Trail done",resolved:"Resolved"};function Wm({s:e}){const[t,r]=nj(e);return i.jsxs("div",{className:`sync-line ${t}`,title:e.error,children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:r})]})}function nj(e){switch(e.state){case"online":return["ok","Online"];case"connecting":return["","Connecting"];case"offline":return["warn","Offline · reconnecting"];case"auth-error":return["alert","Disconnected · Slack rejected the tokens"];case"elsewhere":{const t=e.heldBy?` (${e.heldBy})`:"";return["warn",`Connected from another ${ve.slug}${t}`]}case"unsupported":return["alert",e.error??"Not supported here"];default:return["",e.step==="done"?"Off":"Not connected"]}}function sj(e){const{s:t,setup:r}=e,o=t.step==="done";return i.jsxs(Ot,{className:rj(t,r),children:[i.jsxs("div",{className:"card-row",children:[i.jsx("b",{className:"choice-title t-row-title",children:"Your Scout app"}),o&&i.jsx(zn,{className:t.enabled?"on":"",children:t.enabled?"On":"Off"})]}),o&&i.jsx("div",{className:"c-loc",children:ij(t)}),o&&i.jsx(Wm,{s:t}),!o&&t.step===1&&!r&&i.jsx("p",{className:"sl-lead",children:"Answer agents and save threads as decisions from Slack. You create your own Scout app in your workspace; it runs from this machine and its tokens stay in your local credential store."}),i.jsxs("div",{className:"c-actions",children:[!o&&!r&&i.jsx(K,{size:"sm",variant:"primary",onClick:()=>e.onSetup(!0),children:t.step===1?"Connect":`Resume at step ${t.step}`}),o&&i.jsx(K,{size:"sm",on:t.enabled,onClick:e.onToggle,children:t.enabled?"Turn off":"Turn on"}),o&&t.state==="auth-error"&&i.jsx(K,{size:"sm",variant:"primary",onClick:()=>e.onSetup(!0),children:"Reconnect"}),t.step!==1&&i.jsx(ej,{onRemoved:e.onRemoved})]})]})}function ij(e){var r,o,l;const t=(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,t,e.setup.appId].filter(Boolean).join(" · ")}function rj(e,t){const r=e.step==="done";return`connector ${r&&e.enabled?"active":""} ${t||!r?"open":""}`}function oj(e){const[t,r]=k.useState(e.value==="dm"?"":e.value),o=/^[CG][A-Z0-9]{6,}$/.test(t.trim());return i.jsxs("form",{className:"sl-paste-field",onSubmit:l=>{l.preventDefault(),o&&e.onSave(t.trim())},children:[i.jsx("input",{value:t,spellCheck:!1,placeholder:"Channel ID, e.g. C0123ABCD","aria-label":"Channel ID",onChange:l=>r(l.target.value)}),i.jsx(K,{type:"submit",disabled:!o||t.trim()===e.value,children:"Save"})]})}function aj(e){const[t,r]=k.useState(),[o,l]=k.useState();k.useEffect(()=>{Bn.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]}):t?i.jsx("div",{className:"choice-row compact sl-members",children:t.map(h=>i.jsx(ht,{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 lj(e){const{s:t,patch:r}=e,[o,l]=k.useState(!1),c=new Set(t.notify.events),d=o||t.notify.target!=="dm",h=t.owners[0],g=m=>{const v=c.has(m)?t.notify.events.filter(w=>w!==m):[...t.notify.events,m];r({notify:{events:v}})};return i.jsxs("div",{className:"sl-groups",children:[i.jsxs("div",{className:"sl-group",children:[i.jsx(Je,{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 Bn.resetOwner().then(e.set,()=>{}),children:"Not you? Reset"})]})]}),i.jsxs("div",{className:"sl-group",children:[i.jsx(Je,{variant:"plain",size:"sm",children:"Allowed users"}),i.jsx(aj,{value:t.allow,owners:t.owners,onChange:m=>r({allow:m})})]}),i.jsxs("div",{className:"sl-group",children:[i.jsx(Je,{variant:"plain",size:"sm",children:"Notify"}),i.jsxs("div",{className:"choice-row compact",children:[i.jsx(ht,{on:!d,title:"DM to owner",onClick:()=>{l(!1),r({notify:{target:"dm",detail:"full"}})}}),i.jsx(ht,{on:d,title:"Channel",sub:t.notify.target!=="dm"?t.notify.target:void 0,onClick:()=>l(!0)})]}),d&&i.jsxs(i.Fragment,{children:[i.jsx(Ye,{label:"Channel ID (invite @Scout there first)",children:i.jsx(oj,{value:t.notify.target,onSave:m=>r({notify:{target:m}})})}),i.jsxs("div",{className:"choice-row compact",children:[i.jsx(ht,{on:t.notify.detail==="full",title:"Full questions",onClick:()=>r({notify:{detail:"full"}})}),i.jsx(ht,{on:t.notify.detail==="titles-only",title:"Titles only",onClick:()=>r({notify:{detail:"titles-only"}})})]})]}),i.jsx("div",{className:"choice-row compact",children:Wx.map(m=>i.jsx(ht,{on:c.has(m),title:tj[m],onClick:()=>g(m)},m))})]}),i.jsx(wo,{className:"dim",parts:[`${t.command} decide`,`${t.command} status`,`${t.command} inbox`,"Save as decision on any message"]})]})}function ao(e){return i.jsx("a",{className:`btn ${e.primary?"primary":""}`,href:e.href,target:"_blank",rel:"noreferrer",onClick:e.onClick,children:e.children})}function cj({s:e,n:t}){const r=uj(e,t);return r?i.jsx("span",{className:"t-meta",children:r}):null}function uj(e,t){var o;if(t===3)return e.setup.appId&&`app ${e.setup.appId}`;if(t===4)return e.workspace&&`${e.workspace.name} · @${((o=e.bot)==null?void 0:o.name)??"scout"}`;const r=e.owners[0];if(t===5&&r){const l=r.via==="git-email"?" · git email":"";return`owner ${r.name??r.id}${l}`}}const ff=[{n:1,title:"Create your app"},{n:2,title:"Workspace"},{n:3,title:"App token"},{n:4,title:"Install"},{n:5,title:"Claim"}],Tc=(e,t)=>e===t||e===2&&t===3,Km=(e,t)=>e==="done"||typeof e=="number"&&t<e&&!Tc(e,t);function mf(e,t){return Km(e,t)?"done":Tc(e,t)?"cur":""}const dj=/^(xapp-|xoxb-|xoxp-|xoxe)/,hj=typeof navigator<"u"&&/Mac|iP(hone|ad)/.test(navigator.platform)?"⌘V":"Ctrl+V";function fj(e){const t=k.useRef(e);t.current=e;const[r,o]=k.useState(!1);return k.useEffect(()=>{let l="";const c=(g,m)=>{const v=g.trim();return!dj.test(v)||!m&&v===l?!1:(l=v,t.current(v,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 mj(e){var S;const{s:t,set:r}=e,[o,l]=k.useState(),[c,d]=k.useState(!1),[h,g]=k.useState(!1),m=(E,M)=>{const R=Jx(E);M&&R&&!t.setup.botToken&&window.open(Yx.install(R),"_blank")&&g(!0),d(!0),Bn.token(E).catch(O=>({ok:!1,error:O.message,status:t})).then(O=>{d(!1),l(O),r(O.status)})},w=fj(m)?"come back to this tab":`press ${hj} here`,x=t.step,j=E=>{if(!o)return null;const M=!o.ok&&E===4==(x===4);return o.kind===(E===4?"bot":"app")||M?i.jsx("div",{className:`test-line ${o.ok?"ok":"alert"}`,children:pj(o)}):null},T={1:i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:["Create your app in Slack. It opens filled in from a manifest, so your app already has the ",t.command," command, Save as decision and Socket Mode."]}),i.jsx("div",{className:"sl-actions",children:i.jsx(ao,{primary:!0,href:t.links.create,onClick:()=>void Bn.created().then(r,()=>{}),children:"Create your Slack app"})})]}),2:i.jsxs("p",{children:["In Slack: pick your workspace → ",i.jsx("b",{children:"Next"})," → ",i.jsx("b",{children:"Create"}),". Your app lives in the workspace you pick."]}),3:i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:["Give your app a token so Scout can connect from this machine. On the page Slack just opened:"," ",i.jsx("b",{children:"App-Level Tokens"})," → ",i.jsx("b",{children:"Generate Token and Scopes"})," → name it ",i.jsx("code",{children:"teamtrail"})," → add"," ",i.jsx("code",{children:"connections:write"})," → ",i.jsx("b",{children:"Generate"})," → ",i.jsx("b",{children:"Copy"}),", then ",w,"."]}),i.jsx("div",{className:"sl-actions",children:i.jsx(ic,{busy:c,placeholder:"xapp-…",onToken:m})}),j(3),i.jsx(wo,{className:"dim",parts:["Waiting for the app-level token",t.links.create&&i.jsx("a",{href:t.links.create,target:"_blank",rel:"noreferrer",children:"Open the manifest again"},"again")]})]}),4:i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:["Install your app so Scout can post and DM you."," ",h?"Slack's install page is open in a new tab: ":i.jsxs(i.Fragment,{children:[i.jsx("b",{children:"Install to workspace"})," →"," "]}),i.jsx("b",{children:"Allow"})," → copy the ",i.jsx("b",{children:"Bot User OAuth Token"})," (starts with ",i.jsx("code",{children:"xoxb-"}),"), then ",w,"."]}),i.jsxs("div",{className:"sl-actions",children:[i.jsx(ao,{primary:!h,href:t.links.install,children:h?"Open install page again":"Install to workspace"}),i.jsx(ic,{busy:c,placeholder:"xoxb-…",onToken:m})]}),j(4)]}),5:i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:["Your git email doesn't match a member of ",((S=t.workspace)==null?void 0:S.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(ao,{primary:!0,href:t.links.home,children:"Open Scout in Slack"}),t.links.homeWeb&&i.jsx(ao,{href:t.links.homeWeb,children:"Open in browser"})]}),i.jsx(Wm,{s:t})]})};return i.jsxs(Ot,{tone:"inset",className:"slack-setup",children:[i.jsxs("p",{className:"sl-own",children:["You create your own Scout app in your Slack workspace. It runs from this machine over Socket Mode; nothing goes through ",ve.name,". Prefer one click? Add to Slack is coming with ",ve.name," Cloud."]}),i.jsx("ol",{className:"pipeline sl-pipeline","aria-label":"Slack setup",children:ff.map(E=>i.jsxs("li",{className:mf(x,E.n),children:[i.jsx("i",{}),i.jsxs("span",{children:[E.n," ",E.title]})]},E.n))}),i.jsx("ol",{className:"sl-steps",children:ff.map(E=>{const M=Km(x,E.n),R=Tc(x,E.n);return i.jsxs("li",{className:mf(x,E.n),children:[i.jsxs("div",{className:"sl-step-h",children:[i.jsx("span",{className:"sl-n",children:M?"✓":E.n}),i.jsx("b",{children:E.title}),M&&i.jsx(cj,{s:t,n:E.n})]}),R&&i.jsx("div",{className:"sl-step-b",children:T[E.n]})]},E.n)})})]})}function pj(e){var t,r;return e.ok?e.kind==="app"?`✓ Socket Mode reachable · app ${e.status.setup.appId}`:`✓ Installed in ${(t=e.status.workspace)==null?void 0:t.name} as @${((r=e.status.bot)==null?void 0:r.name)??"scout"}`:`✕ ${e.error}`}function Ec(e=0){const[t,r]=k.useState(),o=k.useCallback(()=>Bn.get().then(r,()=>r(null)),[]);return k.useEffect(()=>{if(o(),!e)return;const l=setInterval(()=>void o(),e);return()=>clearInterval(l)},[o,e]),[t,r]}function gj(e){const[t,r]=Ec(3e3),[o,l]=k.useState(!1),c=k.useRef(null);if(k.useEffect(()=>{var g;e.focus&&t&&((g=c.current)==null||g.scrollIntoView({block:"start"}))},[e.focus,!!t]),!t)return null;const d=t.step==="done",h=g=>Bn.update(g).then(r,()=>{});return i.jsxs("div",{ref:c,className:"slack-settings",children:[i.jsx(sj,{s:t,setup:o,onSetup:l,onToggle:()=>void h({enabled:!t.enabled}),onRemoved:g=>{r(g),l(!1)}}),!d&&(o||t.step!==1)&&i.jsx(mj,{s:t,set:r}),o&&d&&t.state==="auth-error"&&i.jsxs(Ot,{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(Zx,{set:r})]}),d&&i.jsx(lj,{s:t,set:r,patch:g=>void h(g)})]})}function vj(e){const{api:t,rt:r,brief:o}=e,{snap:l,actions:c}=t,[d]=Ec(15e3),h=Ks(),g=d!=null&&d.enabled&&d.state==="auth-error"?d.error??"Slack rejected the tokens":void 0;return i.jsx(_x,{repo:e.repo,snaps:t.allSnaps,map:l==null?void 0:l.map,activity:t.activity,health:t.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,onToggleTheme:e.onToggleTheme,attention:e.attention,slackAlert:g,onSlack:e.onSlack,decisions:t.decisions.length,decisionsOpen:e.decisionsOpen,onDecisions:e.onDecisions,onStats:e.onStats,knowledge:h.attention,knowledgeOpen:h.open,onKnowledge:()=>h.setOpen(!h.open),briefingOpen:o.shown,briefingStatus:o.status,onBriefing:()=>o.shown?o.dismiss():o.open()})}function yj(e){const{m:t}=e,r=t.from==="human"?"human":"agent";return i.jsxs("div",{className:`msg from-${t.from} voice-${r}`,children:[i.jsx(q,{parts:[t.author,Do(t.at)]}),i.jsx("div",{className:"msg-text",children:t.text}),e.stillOpen&&i.jsx("button",{className:"answer-this t-meta",onClick:e.onAnswerThis,children:"Answer this"})]})}function kj(e){const{ticket:t}=e;return i.jsxs("div",{className:"comms-ticket",children:[i.jsxs("div",{className:"t-title",title:t&&`${t.key} ${t.title}`,children:[i.jsx("span",{className:"key",children:t==null?void 0:t.key})," ",t==null?void 0:t.title]}),i.jsx(q,{parts:[e.trail,e.agent]})]})}function wj({id:e,text:t}){const[r,o]=k.useState(),l=r!==e;return i.jsx(Po,{size:1,framed:!1,state:l?"speaking":"alert",speaking:l?t.slice(0,60):void 0,onSpeakEnd:()=>o(e),className:"q-avatar"})}function xj(e){const{q:t}=e;return i.jsxs("div",{className:"msg open-q",children:[i.jsx(q,{parts:[t.agent,Do(t.at)]}),i.jsx(wj,{id:e.chatId??t.id,text:t.text}),i.jsx("div",{className:"msg-text",children:t.text})]})}function jj(e){var t;return(t=e.options)!=null&&t.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 Sj(e){const{activity:t,sessionId:r}=e,[o,l]=k.useState(""),[c,d]=k.useState(),h=k.useRef(null),g=k.useRef(null),m=t.sessions.find(O=>O.id===r),v=t.chats.filter(O=>O.sessionId===r),w=ix(t.pending,r,c??e.questionId),x=new Set(t.pending.filter(O=>O.sessionId===r).map(O=>O.id)),j=v.find(O=>!!w&&O.questionId===w.id),T=v.filter(O=>O!==j),S=m?e.snaps[m.mapId]:void 0,E=m!=null&&m.ticketId?S==null?void 0:S.tickets.find(O=>O.id===m.ticketId):void 0;k.useEffect(()=>{const O=h.current;O==null||O.scrollTo({top:O.scrollHeight,behavior:"smooth"})},[T.length,w==null?void 0:w.id]),k.useEffect(()=>{var O;w&&!e.onBack&&((O=g.current)==null||O.focus({preventScroll:!0}))},[w==null?void 0:w.id,e.onBack]);const M=O=>{!w||!O.trim()||(e.onAnswer(w.id,O.trim()),l(""))},R=Nj(m,!!w);return i.jsxs("div",{className:`comms ${w?"asking":""}`,children:[i.jsx(Ct,{title:"HITL line",right:m?i.jsx("span",{className:`status ${w?"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(kj,{ticket:E,trail:S==null?void 0:S.map.title,agent:m.agent}),i.jsx("div",{className:"comms-log",ref:h,children:T.map(O=>i.jsx(yj,{m:O,stillOpen:!!O.questionId&&x.has(O.questionId),onAnswerThis:()=>d(O.questionId)},O.id))}),w&&i.jsx(xj,{q:w,chatId:j==null?void 0:j.id}),i.jsx(jj,{options:w==null?void 0:w.suggestions,onPick:M}),i.jsx(Sc,{ref:g,className:"comms-input",value:o,onValueChange:l,onSubmit:M,disabled:!w,placeholder:w?"Answer":""})]}):i.jsx(Ee,{children:"No conversation"})]})}function Nj(e,t){return e?t?"Your answer is needed":tn(e)?`${e.agent} is working…`:e.status==="done"?"Resolved · ticket closed":"Session ended":""}async function bj(e){const[t,r]=e.ref.split("+"),o=await fetch(`${Ne()}/workspaces/integration`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e.mapId,a:t,b:r})});return o.ok?void 0:(await o.json().catch(()=>({}))).error??`Adding failed (${o.status})`}function Cj({item:e}){const[t,r]=k.useState(!1),[o,l]=k.useState(),c=()=>{r(!0),l(void 0),bj(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:t,onClick:c,children:t?"Adding…":"Add integration ticket"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}const $j=/(\S*\/\S*|#\d+)/g;function Tj({reasons:e}){return e.length?i.jsx("span",{className:"reason-line",children:e.map((t,r)=>i.jsxs("span",{children:[r>0&&i.jsx("span",{className:"sep",children:" · "}),t.split($j).map((o,l)=>l%2===1?i.jsx("span",{className:"t-code",children:o},l):o)]},t))}):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"},Ej={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"},Ij=[{minutes:30,label:"30 min"},{minutes:120,label:"2 hours"},{minutes:1440,label:"Tomorrow"}],Mj=["blocked","flag","stalled","policy","reroute","overlap","integration","model"];function Gm(e,t){return t||e.urgency==="blocking"?"urgent":Mj.includes(e.kind)?"attention":"neutral"}const Aj=[/^marked blocking$/,/^fyi\b/,/^soon\b/,/^waiting \d/,/^answer together/,/questions from /];function qm(e){return e.reasons.filter(t=>!Aj.some(r=>r.test(t)))}function Lj(e){const{item:t,snap:r}=e,o=r==null?void 0:r.tickets.find(h=>h.id===t.ticketId),l=t.kind==="question"&&t.agent?`${t.agent} asks`:Vm[t.kind],c=[];t.urgency==="blocking"&&c.push({text:"Blocking",urgent:!0,className:"urgency-tag"}),c.push({text:l,strong:!0});const d=o&&Rj(t.title,o);return d&&c.push(d),e.otherTrail&&c.push((r==null?void 0:r.map.title)??t.mapId),c}function Rj(e,t){if(!e.includes(t.key))return e.includes(t.title)?{text:t.key,code:!0}:`${t.key} ${t.title}`}function Oj(e){const[t,r]=k.useState(!1),o=l=>{r(!1),l()};return i.jsxs("span",{className:"snooze",children:[i.jsx("button",{type:"button",className:"snooze-btn","aria-expanded":t,"aria-label":`Later: ${e.title}`,onClick:()=>r(!t),children:"Later"}),t&&i.jsxs("span",{className:"snooze-menu",role:"menu",children:[Ij.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 Pj=15e3;function _j(e){const{item:t}=e,r=t.title.split(`
|
|
124
|
+
`)[0],o=qm(t),l=e.now-t.since<Pj;return i.jsx(Ae,{as:"li",className:`att-item k-${t.kind} u-${t.urgency} ${e.selected?"sel":""} ${l?"incoming":""}`,edge:Gm(t,e.interrupting),selected:e.selected,title:r,titleText:t.title,context:i.jsx(q,{parts:Lj({item:t,snap:e.snap,otherTrail:e.otherTrail})}),detail:o.length>0&&i.jsx(Tj,{reasons:o}),detailText:o.join(`
|
|
125
|
+
`),trailing:nn(e.now-t.since),onOpen:e.onOpen,actions:i.jsx(Oj,{title:t.title,canDismiss:Rk(t),onSnooze:e.onSnooze,onDismiss:e.onDismiss}),below:t.kind==="integration"&&i.jsx(Cj,{item:t})})}function Dj(e){const t=[];for(const r of e){const o=t.at(-1);(o==null?void 0:o.key)===r.batchKey?o.items.push(r):t.push({key:r.batchKey,kind:r.kind,mapId:r.mapId,items:[r]})}return t}const Bj={question:"inbox-list",approval:"inbox-list approvals"};function zj(e){const{batch:t}=e,r=t.items.length>1,o=t.kind==="question"?"answer together":"review together",l=[`${t.items.length} ${Ej[t.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 ${Bj[t.kind]??""}`,children:e.children})]})}function Fj(e,t){e.ticketId?t.openTicket(e.mapId,e.ticketId):t.selectTrail(e.mapId)}function Qm(e,t){switch(e.kind){case"question":return t.openQuestion(e.ref);case"approval":case"blocked":case"policy":case"flag":case"stalled":case"hitl-ready":case"overlap":case"integration":case"model":return Fj(e,t);case"knowledge":return t.openKnowledge();case"brief":return t.openBrief(e.mapId);case"reroute":case"reroute-suggested":return t.openReroute(e);case"guide":case"guide-checks":return t.openGuides();default:return e.kind}}function Uj(e){const t=sn(1e3),{view:r}=e;if(!r.items.length)return i.jsx(Dn,{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:Dj(r.items).map(h=>{var g;return i.jsx(zj,{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(_j,{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:t,onOpen:()=>Qm(m,e.handlers),onSnooze:v=>e.onSnooze(m.id,v),onDismiss:()=>e.onDismiss(m.id)},m.id))},h.key)})})}const pf={label:"Focus for 1 hour",change:{kind:"for",minutes:60}};function Hj(e){switch(e.kind){case"manual":case"hours":return[{label:"End focus now",change:{kind:"end"},primary:!0}];case"paused":return[{label:"Resume quiet hours",change:{kind:"resume"},primary:!0},pf];case"off":return[{...pf,primary:!0},{label:"Focus for 3 hours",change:{kind:"for",minutes:180}}];default:return e}}const gf=e=>Do(e).slice(0,5),Wj=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function Kj(e){const t=`${e.items.length} waiting on you`;return e.heldBack===0?`Nothing held back · ${t}`:`${Wj(e.heldBack,"item")} would interrupt you · ${t}`}function Hl(e){const t=e.prefs.focus;return t?`Quiet hours ${t.from}–${t.to}`:"No quiet hours set"}const vf=e=>`Items scoring ${e.policy.value.interrupt} or more interrupt you · ${e.items.length} waiting on you`;function Vj(e){const t=e.focus;switch(t.kind){case"manual":case"hours":{const r=gf(t.until),o=t.kind==="manual"?"Switched on here":Hl(e);return{word:"on",until:r,on:!0,title:`Focus is on until ${r}`,reason:o,detail:Kj(e)}}case"paused":{const r=gf(t.until),o=`Quiet hours paused until ${r}`;return{word:"paused",until:r,on:!1,title:o,reason:Hl(e),detail:vf(e)}}case"off":return{word:"off",until:"",on:!1,title:"Focus is off",reason:Hl(e),detail:vf(e)};default:return t}}const Gj="Focus holds back interruptions: no browser notifications or Slack messages, even for urgent items. Nothing is answered or dropped: everything still waits in Waiting on you and the Slack digest. Quiet hours turn it on every day; you can also focus for a while or end it early. This stays on this machine.";function qj(e){const{view:t}=e,r=Vj(t),o=t.focus.kind,l=i.jsxs("span",{className:We("focus-state",`focus-${o}`),children:[i.jsx("i",{className:"focus-dot","aria-hidden":"true"}),i.jsxs("span",{className:"focus-label",children:["Focus",i.jsxs("span",{className:"focus-word",children:[" ",r.word]})]}),r.until&&i.jsxs("span",{className:"focus-until",children:[i.jsx("span",{className:"sep",children:" · "}),i.jsx("span",{className:"focus-until-word",children:"until "}),r.until]})]});return i.jsx(Fm,{className:"focus-menu",label:l,role:"dialog",tip:r.title,ariaLabel:r.title,children:c=>i.jsxs("div",{className:"focus-panel","aria-label":"Focus",children:[i.jsxs("div",{className:"focus-panel-head",children:[i.jsx("span",{className:"t-row-title",children:r.title}),i.jsx(Us,{text:Gj})]}),i.jsx(q,{parts:[r.reason]}),i.jsx(q,{className:"focus-held",parts:[r.detail]}),i.jsxs("div",{className:"focus-panel-actions",children:[Hj(t.focus).map(d=>i.jsx(K,{size:"sm",variant:d.primary?"primary":"default",onClick:()=>{c(),e.onChange(d.change)},children:d.label},d.label)),i.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{c(),e.onSettings()},children:"Quiet hours"})]})]})})}function Qj(e){const{view:t}=e,r=t.interrupting.length;return i.jsxs("span",{className:"attention-head",children:[i.jsx(qj,{view:t,onChange:e.onFocus,onSettings:e.onSettings}),r>0&&i.jsxs("span",{className:"waiting-chip interrupting",title:`${r} need you now`,children:[i.jsx(Ws,{variant:"alert",size:14}),i.jsx("b",{children:r}),i.jsx("span",{className:"wl",children:" need you now"})]})]})}const Ym=`${Ne()}/attention`,Yj=250;async function yf(e,t,r){var c;const o=await fetch(`${Ym}${e}`,{method:t,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[t,r]=k.useState(),[o,l]=k.useState(),c=k.useCallback(()=>{fetch(Ym).then(h=>h.ok?h.json():void 0).then(h=>h&&r(h)).catch(()=>{})},[]);k.useEffect(()=>zo("attention",h=>r(JSON.parse(h))),[]),k.useEffect(()=>{const h=setTimeout(c,Yj);return()=>clearTimeout(h)},[c,e]);const d=(h,g)=>void yf(h,"POST",g).then(()=>(l(void 0),c()),m=>l(m.message));return{view:t,error:o,snooze:(h,g)=>d("/snooze",{id:h,minutes:g}),dismiss:h=>d("/dismiss",{id:h}),savePrefs:h=>yf("/prefs","PUT",h).then(()=>(l(void 0),c(),!0),g=>(l(g.message),!1))}}function Jj(e){return e.prefs.channel!=="browser"?!1:typeof Notification<"u"&&Notification.permission==="granted"}function Xj(e){const t=new Notification(`${ve.name} · needs you`,{body:e.title,tag:e.id});t.onclick=()=>{window.focus(),t.close()}}function Zj(e){const t=k.useRef();k.useEffect(()=>{if(!e)return;const r=new Set(e.interrupting),o=t.current;if(t.current=r,!(!o||!Jj(e)))for(const l of e.items)r.has(l.id)&&!o.has(l.id)&&Xj(l)},[e])}function e0(e){const t=sn(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(Ae,{as:"li",edge:o?"attention":"neutral",title:`${o?"Decide":"Approve"}: ${r.title}`,context:i.jsx(q,{parts:[o?"Held":"Verified",{text:r.ticketKey,code:!0},l]}),detail:r.reason,detailText:r.reason,trailing:nn(t-r.at),onOpen:()=>e.onOpen(r.mapId,r.ticketId)},`${r.mapId}/${r.ticketId}`)})}):null}function kf({activity:e}){const t=sn(1e3),r=zy(e);return i.jsxs("div",{className:"hitl-readout",children:[i.jsx(Zt,{layout:"inline",label:"Oldest",value:r.oldestAt?Wt(t-r.oldestAt):"—",urgent:!!r.oldestAt&&t-r.oldestAt>6e4,title:"Oldest open question"}),i.jsx(Zt,{layout:"inline",label:"Avg wait",value:r.avgWaitMs!==void 0?Wt(r.avgWaitMs):"—",title:`Average wait over ${r.answered} answered questions`}),i.jsx(Zt,{layout:"inline",label:"Answered",value:r.answered})]})}function t0(e){const t=sn(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(Ae,{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(q,{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:nn(t-r.at),onOpen:()=>e.onOpen(r.sessionId,r.ticketId)},r.id)})}):i.jsx(Dn,{title:"Nothing waiting on you",hint:"When an agent needs your call, its question lands here."})}const n0={pass:"Passed",fail:"Failed",error:"Could not run",interrupted:"Interrupted"},Fi={off:"Off",checks:"Checks","checks+review":"Checks + review","checks+review+human":"Checks + review + you"},Xm={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."},s0=e=>e.exitCode===0&&!e.timedOut&&!e.error;async function wf(e){const t=await e.json().catch(()=>({}));if(!e.ok)throw new Error(t.error??`HTTP ${e.status}`);return t}const lo=`${Ne()}/verification`,Vi={ticket:(e,t)=>fetch(`${lo}/ticket?mapId=${encodeURIComponent(e)}&ticketId=${encodeURIComponent(t)}`).then(r=>r.ok?r.json():void 0,()=>{}),inbox:()=>fetch(`${lo}/inbox`).then(e=>e.ok?e.json().then(t=>t.items):[],()=>[]),log:e=>fetch(`${lo}/log?path=${encodeURIComponent(e)}`).then(t=>wf(t)),act:e=>fetch(`${lo}/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(t=>wf(t))};function i0(e){const[t,r]=k.useState([]),o=Object.values(e).map(l=>l.tickets.map(c=>`${c.id}:${c.state}:${c.status??""}`).join()).join("|");return k.useEffect(()=>{let l=!0;const c=()=>void Vi.inbox().then(h=>l&&r(h));c();const d=Bs.onEvidence(c);return()=>{l=!1,d()}},[o]),t}function r0(e,t){return{...e,items:e.items.filter(r=>!(r.kind==="brief"&&r.mapId===t))}}function o0(e){var h;const t=[...e.activity.pending].sort((g,m)=>g.at-m.at),r=i0(e.snaps),o=(h=e.attention)==null?void 0:h.view,l=o&&e.briefShown?r0(o,e.currentMapId):o,c=l?l.items.length:t.length+r.length,d=i.jsx(Ct,{hot:c>0,title:i.jsxs(i.Fragment,{children:[c>0&&i.jsx(Ws,{variant:"alert",size:12}),"Waiting on you"]}),count:i.jsx(ts,{n:c,urgent:c>0,pop:!0},c)});return l&&e.attention&&e.handlers?i.jsxs("div",{className:"inbox-part",children:[d,i.jsx(kf,{activity:e.activity}),i.jsx(Uj,{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(kf,{activity:e.activity}),i.jsx(e0,{items:r,snaps:e.snaps,currentMapId:e.currentMapId,onOpen:e.onOpenTicket}),(t.length>0||!r.length)&&i.jsx(t0,{items:t,snaps:e.snaps,currentMapId:e.currentMapId,selected:e.sessionId,onOpen:e.onOpenQuestion})]})}function a0(e){const[t,r]=k.useState("list"),[o,l]=k.useState();k.useEffect(()=>{e.convRequest&&r("conv")},[e.convRequest]);const c=(v,w)=>{e.onOpen(v,w),r("conv")},d=v=>{const w=e.activity.pending.find(x=>x.id===v);w&&(l(w.id),c(w.sessionId,w.ticketId))},h=i.jsx(o0,{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(Sj,{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(Ke,{className:"zone inbox stack",children:t==="conv"&&e.sessionId?g:i.jsxs("div",{className:"stack-scroll",children:[e.above,h,e.below]})});const m=!!e.activity.sessions.find(v=>v.id===e.sessionId);return i.jsxs(Ke,{className:`zone inbox split ${m?"has-conv":""}`,style:{gridArea:"inbox"},children:[i.jsx(Ct,{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 l0(e){var h;const{snap:t}=e,r=t?Fs(t.tickets,t.map.mode):new Map,o={claimed:0,frontier:1},l=((t==null?void 0:t.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(Om).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(Ct,{title:"Up next",count:i.jsx("span",{className:"n mono-label",children:l.length})}),!t&&i.jsx(Ee,{children:"Ready tickets show here"}),t&&!l.length&&i.jsx(Ee,{children:"Nothing ready"}),t&&l.length>0&&i.jsx("ul",{className:"ticket-list",children:l.map(g=>{const v={state:r.get(g.id),waiting:c.has(g.id),assignee:g.assignee,hitl:Hi(g)==="hitl"},w=c0(v);return i.jsx("li",{className:`${d===g.id?"sel":""} st-${u0(v)}`,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:w})]})},g.id)})})]})}function c0(e){if(e.waiting)return"waiting on you";if(e.state==="claimed")return e.assignee??"claimed";const t=Im[e.state].toLowerCase();return e.hitl?`${t}, needs you`:t}function u0(e){return e.waiting?"waiting":e.state==="frontier"&&e.hitl?"attention":e.state}function d0(e){const{api:t,nav:r}=e;return i.jsx(a0,{activity:t.activity,snaps:t.allSnaps,currentMapId:t.mapId,sessionId:t.chatSession,layout:e.bp==="mobile"?"stack":"split",convRequest:r.convRequest,onOpen:r.openChat,onAnswer:t.actions.answer,onOpenTicket:r.openTicket,attention:e.attn.attention,handlers:e.attn.handlers,below:i.jsx(l0,{snap:t.snap,sessions:e.scoped.sessions,selection:t.selection,onSelect:r.select}),above:e.above})}function xo({command:e,label:t="Copy"}){const[r,o]=k.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":t})]})}const co=[{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"}],h0=9e3;function f0(){const[e,t]=k.useState(0),[r,o]=k.useState(!1);k.useEffect(()=>{if(r)return;const c=setInterval(()=>t(d=>(d+1)%co.length),h0);return()=>clearInterval(c)},[r]);const l=co[e];return i.jsxs("div",{className:"command-bar real",children:[i.jsx(_m,{name:"map"}),i.jsx(Je,{as:"h2",className:"zone-title-label",children:"Trail map"}),i.jsx(Us,{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(xo,{command:l.command})]},e),i.jsxs("button",{type:"button",className:"link hint-next","data-tip":"Next hint","aria-label":"Next hint",onClick:()=>t(c=>(c+1)%co.length),children:[e+1,"/",co.length," ›"]})]})}function m0(e){const t=[{v:"plan+execute",title:"Plan + execute"},{v:"plan-only",title:"Plan only"}];return i.jsx("div",{className:"choice-row",children:t.map(r=>i.jsx(ht,{on:e.value===r.v,title:r.title,onClick:()=>e.onChange(r.v)},r.v))})}function p0({onClose:e,tracker:t,onCreate:r}){const[o,l]=k.useState(),[c,d]=k.useState(!1),[h,g]=k.useState(),[m,v]=k.useState(""),[w,x]=k.useState(""),[j,T]=k.useState(""),[S,E]=k.useState(""),M=[m.trim(),w.trim(),j.trim()].filter(Boolean).join(". ").replace(/"/g,"'");return k.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(Ke,{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(Ye,{label:"Title",children:i.jsx("input",{value:m,onChange:R=>v(R.target.value),autoFocus:!0})}),i.jsx(Ye,{label:"Destination",children:i.jsx("textarea",{rows:3,value:w,onChange:R=>x(R.target.value),placeholder:"What is true when this trail is done?"})}),i.jsx(Ye,{label:"Notes",children:i.jsx("textarea",{rows:2,value:j,onChange:R=>T(R.target.value)})}),i.jsx(Ye,{label:"Assumptions (optional, one per line)",children:i.jsx("textarea",{className:"new-trail-assumptions",rows:2,value:S,onChange:R=>E(R.target.value),placeholder:"What the plan takes for granted, e.g. The v2 API supports batch writes"})}),i.jsxs("div",{className:"agent-draft",children:[i.jsxs("span",{className:"dim",children:["Paste this in Claude Code or Codex. Scout frames the trail with you there, then charts it here in ",t,"."]}),i.jsx(xo,{command:`/scout new "${M||"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(xo,{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()||!w.trim(),"data-tip":"Put the trail on the map now; any agent picks it up with /scout resume",onClick:()=>{d(!0);const R=S.split(`
|
|
127
|
+
`).map(O=>O.trim());r({title:m.trim(),destination:w.trim(),notes:j.trim(),assumptions:R.filter(Boolean)}).then(O=>l(O.key)).catch(O=>g(O.message)).finally(()=>d(!1))},children:"Create trail"})]})]})})}const xf=["Ready when you are","What's the next big idea?","I keep the party on the trail","Describe it, I frame it"],g0=5e3;function v0(){const e=bc(),[t,r]=k.useState(0),[o,l]=k.useState(!0);return k.useEffect(()=>{if(o)return;const c=setTimeout(()=>{r(d=>(d+1)%xf.length),l(!0)},g0);return()=>clearTimeout(c)},[o]),i.jsxs("div",{className:"floating-scout","aria-hidden":"true",children:[i.jsx(Po,{variant:e?"night":"crt",size:3,framed:!1,speaking:o?xf[t]:void 0,onSpeakEnd:()=>l(!1),className:"fm-avatar"}),i.jsx("span",{className:"fm-shadow"})]})}function y0(e){return i.jsx(p0,{onClose:e.onClose,tracker:e.rt.adapter.label,onCreate:async t=>{const r=await Vw(e.rt.adapter,t);return e.onCreated(r.id),r}})}const k0={gh:"your gh login",GITHUB_TOKEN:"GITHUB_TOKEN",GH_TOKEN:"GH_TOKEN",stored:"a saved token","signed-in":"your GitHub sign-in",LINEAR_API_KEY:"LINEAR_API_KEY"},Ic=e=>k0[e];function Mc(e){var t;return((t=e.account)==null?void 0:t.kind)==="user"?e.account.login:void 0}const Wl=e=>!!e.auth&&!!Mc(e);function Zm(e,t){const r=Mc(e);return!e.auth||!r?void 0:`Will use ${t||"the repo you pick"} as ${r} (${Ic(e.auth)})`}function w0(e){if(!e.repo)return;const t=Mc(e),r=t?` as ${t}`:"",o=e.auth?`, using ${Ic(e.auth)}`:"";return`Connected to ${e.repo}${r}${o}`}function x0(e,t){if(!e.pushedAt)return;const r=Math.floor((t-Date.parse(e.pushedAt))/864e5);return r<1?"Pushed today":r<60?`Pushed ${r}d ago`:`Pushed ${Math.floor(r/30)}mo ago`}function j0(e){const{gh:t}=e;if(!t.auth)return null;const r=Zm(t,e.repo);return i.jsxs("div",{className:"gh-identity",children:[r&&i.jsx("span",{className:"t-body",children:r}),i.jsxs("span",{className:"gh-identity-actions",children:[i.jsx("button",{type:"button",className:"btn ghost sm",onClick:e.onUseAnother,children:"Use another token"}),t.auth==="signed-in"&&i.jsx("button",{type:"button",className:"btn ghost sm",onClick:e.onSignOut,children:"Sign out"})]})]})}const S0=/^[\w.-]+\/[\w.-]+$/;function N0(e){const t=e.query.trim().toLowerCase(),o=!!e.detected&&e.repos.every(g=>g.fullName!==e.detected)?[{fullName:e.detected,private:!1},...e.repos]:e.repos,l=[...o.filter(g=>g.fullName===e.detected),...o.filter(g=>g.fullName!==e.detected)],c=t?l.filter(g=>g.fullName.toLowerCase().includes(t)):l,h=S0.test(e.query.trim())&&c.every(g=>g.fullName.toLowerCase()!==t)?e.query.trim():void 0;return{shown:c.slice(0,e.limit),matches:c.length,typed:h}}function jf(e){const{repo:t,listed:r}=e,o=t.private?"Private":"Public";return i.jsx(Ae,{as:"li",className:"repo-row",selected:e.selected,title:i.jsx("span",{className:"t-code",children:t.fullName}),context:i.jsx(q,{parts:[e.detected&&{text:"This project's repo",strong:!0},r&&o,r&&x0(t,e.now),!r&&"Checked when you connect"]}),onOpen:e.onPick})}const b0=40;function Sf(e){const[t,r]=k.useState(""),o=k.useMemo(()=>Date.now(),[]),l=k.useMemo(()=>new Set(e.repos.map(v=>v.fullName)),[e.repos]),{shown:c,matches:d,typed:h}=N0({repos:e.repos,detected:e.detected,query:t,limit:b0}),g=d>c.length?`${d-c.length} more: type to narrow`:"",m=e.truncated?`Your ${e.repos.length} most recently pushed repos`:"";return i.jsxs("div",{className:"repo-picker",children:[i.jsxs("label",{className:"field",children:["Repository",i.jsx("input",{value:t,placeholder:"Search your repos, or type owner/name",spellCheck:!1,"aria-label":"Search repositories",onChange:v=>r(v.target.value)})]}),i.jsxs("ul",{className:"repo-list","aria-label":"Repositories",children:[h&&i.jsx(jf,{repo:{fullName:h,private:!1},detected:h===e.detected,listed:!1,selected:h===e.value,now:o,onPick:()=>e.onChange(h)}),c.map(v=>i.jsx(jf,{repo:v,detected:v.fullName===e.detected,listed:l.has(v.fullName),selected:v.fullName===e.value,now:o,onPick:()=>e.onChange(v.fullName)},v.fullName))]}),i.jsx(q,{parts:[!d&&!h&&"No repo matches",g,m]})]})}function C0(e){const{list:t}=e;if(!t)return i.jsx(Hs,{label:"Loading your repos…",rows:3,className:"picker-loading"});switch(t.kind){case"ok":return i.jsx(Sf,{repos:t.repos,truncated:t.truncated,detected:t.detectedRepo??e.detected,value:e.value,onChange:e.onChange});case"no-token":return i.jsx(q,{parts:["No GitHub token found"]});case"error":return i.jsxs(i.Fragment,{children:[i.jsx(Nc,{what:"Couldn't list your repos",reason:t.error,onRetry:e.onRetry}),i.jsx(Sf,{repos:[],truncated:!1,detected:e.detected,value:e.value,onChange:e.onChange})]});default:return t}}const $0={stored:"Saved token",gh:"gh CLI",GITHUB_TOKEN:"$GITHUB_TOKEN",GH_TOKEN:"$GH_TOKEN","signed-in":"Signed in with GitHub",LINEAR_API_KEY:"$LINEAR_API_KEY"},Pi=e=>e==="github"||e==="linear";function ep(e){const[t,r]=k.useState(!e.source);return e.source&&!t?i.jsxs("div",{className:"ts-auth",children:[i.jsx("span",{className:"mono-label",children:e.label}),i.jsx("span",{className:"pill on",children:$0[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 T0(e){const[t,r]=k.useState(!1),o=()=>{var l;return void((l=navigator.clipboard)==null?void 0:l.writeText(e.code).then(()=>r(!0),()=>{}))};return i.jsxs("div",{className:"gh-device",children:[i.jsx("span",{className:"t-label",children:"Enter this code on GitHub"}),i.jsxs("div",{className:"gh-device-row",children:[i.jsx("code",{className:"gh-device-code t-code","aria-label":"Your code",children:e.code}),i.jsx(K,{size:"sm",variant:"ghost",onClick:o,children:t?"Copied":"Copy"})]}),i.jsxs("div",{className:"gh-device-row",children:[i.jsx("a",{className:"btn primary",href:e.href,target:"_blank",rel:"noreferrer",onClick:o,children:"Open GitHub"}),i.jsx(K,{size:"sm",variant:"ghost",onClick:e.onCancel,children:"Cancel"})]}),i.jsx(Hs,{label:"Waiting for you to approve on GitHub…"})]})}function E0(e){switch(e.kind){case"code":return{kind:"code",userCode:e.userCode,verificationUri:e.verificationUri,interval:e.interval,asked:0};case"unavailable":return{kind:"ended",reason:"Sign in with GitHub isn’t set up in this build"};case"error":return{kind:"ended",reason:e.error};default:return e}}function I0(e,t){switch(t.kind){case"waiting":return{...e,interval:t.interval,asked:e.asked+1};case"signed-in":return{kind:"idle"};case"expired":return{kind:"ended",reason:"The code expired before it was approved"};case"denied":return{kind:"ended",reason:"The sign-in was declined on GitHub"};case"none":return{kind:"ended",reason:"The sign-in was stopped"};case"error":return{kind:"ended",reason:t.error};default:return t}}const Rt=iw(Ne());function _i(e,t){e({tracker:t});const r=new URL(location.href);r.searchParams.delete("tracker"),location.href=r.toString()}function M0(e){const[t,r]=k.useState({kind:"idle"}),o=k.useRef(e);o.current=e;const l=t.kind==="code";return k.useEffect(()=>{if(t.kind!=="code")return;let c=!0;const d=setTimeout(()=>void Rt.githubSignIn.poll().then(async h=>{c&&(h.kind==="signed-in"&&await o.current(),c&&r(I0(t,h)))},h=>c&&r({kind:"ended",reason:h.message})),Math.max(t.interval,1)*1e3);return()=>{c=!1,clearTimeout(d)}},[t]),k.useEffect(()=>{if(l)return()=>void Rt.githubSignIn.cancel().catch(()=>{})},[l]),{state:t,start(){r({kind:"starting"}),Rt.githubSignIn.start().then(c=>r(E0(c)),c=>r({kind:"ended",reason:c.message}))},cancel(){r({kind:"idle"})}}}function A0(e){const{state:t,start:r,cancel:o}=M0(e.onSignedIn);switch(t.kind){case"idle":return i.jsxs("div",{className:"gh-sign-in",children:[i.jsx(K,{variant:"primary",onClick:r,children:"Sign in with GitHub"}),i.jsx(q,{parts:["No gh login or token needed","the token stays on this machine"]})]});case"starting":return i.jsx(Hs,{label:"Asking GitHub for a code…"});case"code":return i.jsx(T0,{code:t.userCode,href:t.verificationUri,onCancel:o});case"ended":return i.jsxs("div",{className:"gh-sign-in",children:[i.jsx(K,{onClick:r,children:"Try again"}),i.jsx(q,{parts:["Didn't sign in",t.reason]})]});default:return t}}function L0(e){var d,h;const{gh:t}=e,r=t.auth&&((d=t.account)==null?void 0:d.kind)==="unknown"?`Found ${Ic(t.auth)}, but GitHub didn't accept it`:"",o=((h=t.account)==null?void 0:h.kind)==="unknown"?t.account.error:"",l=t.auth==="GITHUB_TOKEN"||t.auth==="GH_TOKEN",c=t.signIn.available&&!l;return i.jsxs(i.Fragment,{children:[r&&i.jsx(q,{parts:[r,o]}),c&&i.jsx(A0,{onSignedIn:e.onSignedIn}),c&&i.jsx("span",{className:"t-label gh-or",children:"Or paste a token"}),i.jsx(ep,{source:null,value:e.token,onChange:e.onToken,label:"Token",placeholder:"ghp_… or github_pat_…",link:{href:"https://github.com/settings/personal-access-tokens/new",text:"New token"}}),i.jsxs("span",{className:"t-meta",children:["Or run ",i.jsx("code",{className:"t-code",children:"gh auth login"})," in a terminal; this finds it in a few seconds."]}),i.jsxs("label",{className:"field",children:["Repository",i.jsx("input",{value:e.repo,placeholder:"owner/name",spellCheck:!1,onChange:g=>e.onRepo(g.target.value.trim())})]})]})}function tp({r:e}){var o,l;if(!e)return null;if(!e.ok)return i.jsxs("div",{className:"test-line alert",children:["✕ ",e.error]});const t=(o=e.rate)!=null&&o.limit?`${(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,t].filter(Boolean).join(" · ")]})}function Ac(e){const[t,r]=k.useState(),[o,l]=k.useState(0);k.useEffect(()=>{if(r(void 0),!e.enabled)return;let d=!0;return e.load().then(h=>d&&r(h),h=>d&&r(e.failed(h.message))),()=>{d=!1}},[e.enabled,e.key,o]);const c=k.useCallback(()=>l(d=>d+1),[]);return{value:t,retry:c}}function R0(e){const{value:t,retry:r}=Ac({enabled:e.enabled,key:e.auth??"",load:()=>Rt.githubRepos(),failed:o=>({kind:"error",error:o})});return{list:t,retry:r}}function np(e){const t=e.s.github,r=Wl(t),[o,l]=k.useState(!r),[c,d]=k.useState(t.repo??t.detectedRepo??""),[h,g]=k.useState(""),[m,v]=k.useState(),[w,x]=k.useState(!1),{list:j,retry:T}=R0({enabled:!o,auth:t.auth});k.useEffect(()=>{r&&!h&&l(!1)},[r]);const S=async()=>{x(!0),v(void 0);try{await Rt.connect({active:"github",github:{repo:c,token:o?h:void 0}}),e.onConnected()}catch(X){v({ok:!1,error:X.message}),x(!1)}},E=async()=>{const X=await e.reload();X&&Wl(X.github)&&l(!1)},M=async()=>{await Rt.githubSignIn.signOut().catch(()=>{});const X=await e.reload();l(!X||!Wl(X.github))},O=!!c&&!(!o&&!j)&&(!o||!!h||r);return i.jsxs("div",{className:"card inset tracker-setup",children:[o?i.jsx(L0,{gh:t,token:h,onToken:g,repo:c,onRepo:d,onSignedIn:E}):i.jsxs(i.Fragment,{children:[i.jsx(j0,{gh:t,repo:c,onUseAnother:()=>l(!0),onSignOut:()=>void M()}),i.jsx(C0,{list:j,detected:t.detectedRepo,value:c,onChange:d,onRetry:T})]}),i.jsx(tp,{r:m}),i.jsx("footer",{children:i.jsx("button",{type:"button",className:"btn primary",disabled:w||!O,onClick:()=>void S(),children:w?"Connecting…":"Connect"})})]})}function O0(e){return e.line?i.jsxs("div",{className:"gh-identity",children:[i.jsxs("div",{className:"ln-who",children:[i.jsx("span",{className:"t-body",children:e.line}),e.email&&i.jsx(q,{parts:[e.email]})]}),e.onUseAnother&&i.jsx("button",{type:"button",className:"btn ghost sm",onClick:e.onUseAnother,children:"Use another key"})]}):null}const P0={LINEAR_API_KEY:"LINEAR_API_KEY",stored:"a saved key"},Lc=e=>P0[e]??e;function Fo(e){return(e==null?void 0:e.kind)==="user"?e:void 0}const _0=e=>!!e.auth&&!!Fo(e.viewer);function sp(e,t){if(e)return t?`${e} / ${t}`:e}function ip(e){const t=Fo(e.viewer);if(!t)return;const r=sp(e.team,e.project)??"the team you pick",o=e.source?` (${Lc(e.source)})`:"";return`Will use ${r} in ${t.orgName} as ${t.name}${o}`}function D0(e){const t=sp(e.teamName??e.teamKey,e.projectName);if(!e.teamId||!t)return;const r=Fo(e.viewer),o=e.orgName??(r==null?void 0:r.orgName),l=o?` in ${o}`:"",c=r?` as ${r.name}`:"",d=e.auth?`, using ${Lc(e.auth)}`:"";return`Connected to ${t}${l}${c}${d}`}function B0(e,t){if(!e.activeAt)return"No issues yet";const r=Math.floor((t-Date.parse(e.activeAt))/864e5);return r<1?"Active today":r<60?`Active ${r}d ago`:`Active ${Math.floor(r/30)}mo ago`}function z0(e){var l,c;const{ln:t}=e,r=t.auth&&((l=t.viewer)==null?void 0:l.kind)==="unknown"?`Found ${Lc(t.auth)}, but Linear didn't accept it`:"",o=((c=t.viewer)==null?void 0:c.kind)==="unknown"?t.viewer.error:"";return i.jsxs(i.Fragment,{children:[r&&i.jsx(q,{parts:[r,o]}),i.jsx(ep,{source:null,value:e.apiKey,onChange:e.onKey,label:"API key",placeholder:"lin_api_…",link:{href:"https://linear.app/settings/account/security",text:"New key"}}),i.jsxs("span",{className:"t-meta",children:["Or set ",i.jsx("code",{className:"t-code",children:"LINEAR_API_KEY"})," before starting Teamtrail."]})]})}function F0(e){const{list:t}=e;if(!t)return i.jsx(Hs,{label:"Loading projects…"});if(t.kind==="error")return i.jsx(Nc,{what:"Couldn't list the team's projects",reason:t.error,onRetry:e.onRetry});if(t.kind!=="ok"||!t.projects.length)return null;const r=[{value:"",label:"All projects"},...t.projects.map(o=>({value:o.id,label:o.state?`${o.name} · ${o.state}`:o.name}))];return i.jsxs("label",{className:"field",children:["Project (optional)",i.jsx(ft,{"aria-label":"Project",value:e.value,onChange:e.onChange,options:r})]})}function U0(e){const t=e.query.trim().toLowerCase(),r=t?e.teams.filter(o=>o.key.toLowerCase().includes(t)||o.name.toLowerCase().includes(t)):e.teams;return{shown:r.slice(0,e.limit),matches:r.length}}function H0(e,t){return t&&e.some(r=>r.id===t)?t:e.length===1?e[0].id:void 0}function W0(e){const{team:t}=e;return i.jsx(Ae,{as:"li",className:"repo-row team-row",selected:e.selected,title:t.name,context:i.jsx(q,{parts:[{text:t.key,code:!0},B0(t,e.now)]}),onOpen:e.onPick})}const K0=40;function V0(e){const[t,r]=k.useState(""),o=k.useMemo(()=>Date.now(),[]),{shown:l,matches:c}=U0({teams:e.teams,query:t,limit:K0}),d=c>l.length?`${c-l.length} more: type to narrow`:"",h=e.truncated?`The first ${e.teams.length} teams`:"",g=e.value?"":"Pick the team your trails go in";return i.jsxs("div",{className:"repo-picker",children:[i.jsxs("label",{className:"field",children:["Team",i.jsx("input",{value:t,placeholder:"Search your teams by key or name",spellCheck:!1,"aria-label":"Search teams",onChange:m=>r(m.target.value)})]}),i.jsx("ul",{className:"repo-list","aria-label":"Teams",children:l.map(m=>i.jsx(W0,{team:m,selected:m.id===e.value,now:o,onPick:()=>e.onChange(m.id)},m.id))}),i.jsx(q,{parts:[!c&&"No team matches",g,d,h]})]})}function G0(e){const{list:t}=e;if(!t)return i.jsx(Hs,{label:"Loading teams…",rows:3,className:"picker-loading"});switch(t.kind){case"ok":return i.jsx(V0,{teams:t.teams,truncated:t.truncated,value:e.value,onChange:e.onChange});case"no-key":return i.jsx(q,{parts:["Paste a Linear API key to list your teams"]});case"error":return i.jsx(Nc,{what:"Couldn't list your teams",reason:t.error,onRetry:e.onRetry});default:return t}}function q0(e,t){const[r,o]=k.useState(e);return k.useEffect(()=>{const l=setTimeout(()=>o(e),t);return()=>clearTimeout(l)},[e,t]),r}function Q0(e){const{value:t,retry:r}=Ac({enabled:e.enabled&&!!e.teamId,key:`${e.teamId}
|
|
128
|
+
${e.apiKey??""}`,load:()=>Rt.linearProjects(e.teamId,e.apiKey),failed:o=>({kind:"error",error:o})});return{list:t,retry:r}}function Y0(e){const{value:t,retry:r}=Ac({enabled:e.enabled,key:e.apiKey??"",load:()=>Rt.linearTeams(e.apiKey),failed:o=>({kind:"error",error:o})});return{list:t,retry:r}}function J0(e){const t=q0(e.apiKey.trim(),400),r=e.paste&&t?t:void 0,o=e.paste?!!t:!!e.ln.auth,l=Y0({enabled:o,apiKey:r}),c=Q0({teamId:e.teamId,apiKey:r,enabled:o}),d=l.list,h=c.list,g=(d==null?void 0:d.kind)==="ok"?d.teams:[],m=o&&!d,v=o&&!!e.teamId&&!h;return{enabled:o,list:d,teams:g,projects:h,loading:m||v,retryTeams:l.retry,retryProjects:c.retry}}function rp(e){var te;const t=e.s.linear,r=_0(t),[o,l]=k.useState(!r),[c,d]=k.useState(""),[h,g]=k.useState(t.teamId??""),[m,v]=k.useState(t.projectId??""),[w,x]=k.useState(),[j,T]=k.useState(!1),{enabled:S,list:E,teams:M,projects:R,loading:O,retryTeams:X,retryProjects:se}=J0({ln:t,paste:o,apiKey:c,teamId:h});k.useEffect(()=>{r&&!c&&l(!1)},[r]),k.useEffect(()=>{(E==null?void 0:E.kind)==="ok"&&g(H0(E.teams,t.teamId)??"")},[E]);const _=M.find(P=>P.id===h),Q=(R==null?void 0:R.kind)==="ok"?R.projects.find(P=>P.id===m):void 0,oe=(E==null?void 0:E.kind)==="ok"?E.viewer:t.viewer,G=o?null:t.auth,ge=ip({viewer:oe,team:_==null?void 0:_.name,project:Q==null?void 0:Q.name,source:G}),Re=async()=>{if(_){T(!0),x(void 0);try{await Rt.connect({active:"linear",linear:{teamId:_.id,teamKey:_.key,teamName:_.name,projectId:Q==null?void 0:Q.id,projectName:Q==null?void 0:Q.name,apiKey:o?c.trim():void 0}}),e.onConnected()}catch(P){x({ok:!1,error:P.message}),T(!1)}}},be=P=>{g(P),v("")};return i.jsxs("div",{className:"card inset tracker-setup linear-setup",children:[o&&i.jsx(z0,{ln:t,apiKey:c,onKey:d}),i.jsx(O0,{line:ge,email:(te=Fo(oe))==null?void 0:te.email,onUseAnother:o?void 0:()=>l(!0)}),S&&i.jsx(G0,{list:E,value:h,onChange:be,onRetry:X}),_&&i.jsx(F0,{list:R,value:m,onChange:v,onRetry:se}),i.jsx(tp,{r:w}),i.jsx("footer",{children:i.jsx("button",{type:"button",className:"btn primary",disabled:j||O||!_,onClick:()=>void Re(),children:j?"Connecting…":"Connect"})})]})}function X0(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 Z0(e){const{id:t,active:r,s:o}=e,l=Pi(t),c=r&&o?eS(t,o):void 0;return c?i.jsx(q,{className:"c-who",parts:[c]}):r&&(t==="markdown"||l)?i.jsx("div",{className:"c-loc",children:e.location}):l&&e.configured&&o?i.jsx("div",{className:"c-loc",children:tS(t,o)}):null}function eS(e,t){if(e==="github")return w0(t.github);if(e==="linear")return D0(t.linear)}function tS(e,t){return e==="github"?t.github.repo:[t.linear.teamKey,t.linear.projectName].filter(Boolean).join(" · ")}function nS({status:e}){var c,d;if(!e)return null;const t=(c=e.rate)!=null&&c.limit?`${((d=e.rate.remaining)==null?void 0:d.toLocaleString())??"?"}/${e.rate.limit.toLocaleString()} req`:"",r=e.queued?` · ${e.queued} queued`:"",[o,l]=sS(e,r);return i.jsxs("div",{className:`sync-line ${o}`,title:e.error,children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:l}),t&&i.jsx("span",{className:"rate",children:t})]})}function sS(e,t){switch(e.state){case"online":return["ok",`Online · synced ${Em(e.lastSyncAt)}${t}`];case"offline":return["warn",`Offline${t}`];case"rate-limited":return["warn",`Rate limited · resumes ${Ki(e.resetAt)}${t}`];case"auth-error":return["alert",`Credentials rejected${t}`];default:return["",`Connecting${t}`]}}function iS(e){const{id:t,active:r,configured:o,s:l}=e,c=Pi(t),d=!c||!!l,h=["card connector",r?"active":"",d?"":"disabled",e.open?"open":""];return i.jsxs("div",{className:h.join(" "),children:[i.jsxs("div",{className:"card-row",children:[i.jsx("b",{className:"choice-title t-row-title",children:e.name}),r&&i.jsx("span",{className:"pill on",children:"Active"})]}),i.jsx(Z0,{id:t,active:r,configured:o,location:e.location,s:l}),c&&r&&i.jsx(nS,{status:l==null?void 0:l[t].status}),i.jsx(X0,{canSwitch:!r&&(!c||o),remote:c,usable:d,configured:o,open:e.open,onSwitch:e.onSwitch,onToggle:e.onToggle})]})}function op(e=0){const[t,r]=k.useState(),o=k.useCallback(()=>Rt.get().then(l=>(r(l),l),()=>(r(null),void 0)),[]);return k.useEffect(()=>{if(o(),!e)return;const l=setInterval(()=>void o(),e);return()=>clearInterval(l)},[o,e]),[t,r,o]}function rS(e){const[t,,r]=op(5e3),[o,l]=k.useState(null),c=async h=>{t&&(h==="markdown"||Pi(h))&&await Rt.connect({active:h==="markdown"?"markdown":h,...h==="github"&&t.github.repo?{github:{repo:t.github.repo}}:{},...h==="linear"&&t.linear.teamId?{linear:{teamId:t.linear.teamId,teamKey:t.linear.teamKey,teamName:t.linear.teamName,projectId:t.linear.projectId,projectName:t.linear.projectName}}:{}}).catch(()=>{}),_i(e.update,h)},d=k.useMemo(()=>({github:!!(t!=null&&t.github.repo),linear:!!(t!=null&&t.linear.teamId)}),[t]);return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"connectors",children:rw.map(h=>{const g=h.id;return i.jsx(iS,{id:g,name:h.name,active:g===e.activeTracker,configured:Pi(g)&&d[g],open:o===g,location:e.location,s:t,onSwitch:()=>void c(g),onToggle:()=>Pi(g)&&l(o===g?null:g)},h.id)})}),t&&o==="github"&&i.jsx(np,{s:t,reload:r,onConnected:()=>_i(e.update,"github")}),t&&o==="linear"&&i.jsx(rp,{s:t,onConnected:()=>_i(e.update,"linear")})]})}function oS(e,t){const r=e==null?void 0:e.github,o=e==null?void 0:e.linear,l=r&&t!=="github"?Zm(r,r.repo??r.detectedRepo):void 0,c=o&&t!=="linear"?ip({viewer:o.viewer,team:o.teamName,project:o.projectName,source:o.auth}):void 0;return[{id:"markdown",title:"Local markdown",sub:"Files in .teamtrail/ in this repo"},{id:"github",title:"GitHub Issues",sub:l??"Trails as labelled issues in your repo"},{id:"linear",title:"Linear",sub:c??"Trails and tickets in your Linear team"}]}function He(e){return i.jsxs("section",{className:"set-sec",children:[i.jsx(Je,{as:"h4",children:e.title}),e.children]})}function ap(e){const t=[{v:"summary",title:"Summary"},{v:"full",title:"Full transcript"}];return i.jsx("div",{className:"choice-row",children:t.map(r=>i.jsx(ht,{on:e.value===r.v,title:r.title,onClick:()=>e.onChange(r.v)},r.v))})}const aS={github:"Checking for a GitHub login…",linear:"Checking for a Linear key…"};function lS(e){const{prefs:t,update:r}=e,[o,,l]=op(5e3),[c,d]=k.useState(!1),h=oS(o??void 0,t.tracker),g=t.tracker==="github"||t.tracker==="linear",m=g&&(o==null?void 0:o.active)===t.tracker,v=g&&!m,w=j=>{r({onboarded:!0}),_i(r,j)},x=async()=>{d(!0),t.tracker==="markdown"&&o&&await Rt.connect({active:"markdown"}).catch(()=>{}),r({onboarded:!0}),t.tracker!==e.activeTracker&&_i(r,t.tracker)};return i.jsx("div",{className:"scrim",children:i.jsxs(Ke,{as:"div",className:"dialog onboarding",children:[i.jsxs("div",{className:"onb-brand",children:[i.jsx(cx,{size:22,bare:!0}),i.jsx(Bm,{className:"onb-title"})]}),i.jsxs("h2",{className:"onb-question t-heading",children:[i.jsx(Pm,{className:"voice-badge",size:22}),"Where should your trails live?"]}),i.jsxs(He,{title:"Tracker",children:[i.jsx("div",{className:"choice-row",children:h.map(j=>i.jsx(ht,{on:t.tracker===j.id,title:j.title,sub:j.sub,onClick:()=>r({tracker:j.id})},j.id))}),o===void 0&&g&&i.jsx(Hs,{label:aS[t.tracker]??"Checking…"}),o&&t.tracker==="github"&&!m&&i.jsx(np,{s:o,reload:l,onConnected:()=>w("github")}),o&&t.tracker==="linear"&&!m&&i.jsx(rp,{s:o,onConnected:()=>w("linear")})]}),i.jsx(He,{title:"HITL transcript",children:i.jsx(ap,{value:t.hitlTranscript,onChange:j=>r({hitlTranscript:j})})}),i.jsx("footer",{children:i.jsx(K,{variant:"primary",disabled:c||v,onClick:()=>void x(),children:"Get started"})})]})})}const Ui=[{id:"trail",label:"This trail",intro:"How agents work on the trail on screen: its mode, the checks that prove work done, models and guides.",sections:[{id:"mode",title:"Trail mode"},{id:"verification",title:"Verification"},{id:"models",title:"Model matching"},{id:"team",title:"Team"}]},{id:"project",label:"Project",intro:"Where this repo keeps its trails, and the rules every agent working in it follows.",sections:[{id:"tracker",title:"Tracker"},{id:"workspaces",title:"Workspaces"},{id:"policy",title:"Risk policy"},{id:"guides",title:"Guides"},{id:"labels",title:"Labels"}]},{id:"alerts",label:"Attention & alerts",intro:"What interrupts you, where questions reach you, and what Scout tells you when you come back.",sections:[{id:"attention",title:"Attention"},{id:"slack",title:"Slack"},{id:"trip-report",title:"Trip report"}]},{id:"you",label:"You",intro:"How the Lookout looks and reads for you.",sections:[{id:"appearance",title:"Appearance"},{id:"transcript",title:"HITL transcript"},{id:"agent",title:"Agent"}]},{id:"projects",label:"All projects",intro:"Every repo this Lookout knows, so you can switch between them from the header.",sections:[{id:"projects",title:"Projects"}]},{id:"about",label:"About",intro:"What Teamtrail is, and what changed in each release.",sections:[{id:"changelog",title:"Changelog"}]}];function lp(e){if(e===null)return null;const t=Ui.find(l=>l.id===e);if(t)return{group:t.id};const r=Ui.find(l=>l.sections.some(c=>c.id===e));if(!r)return{};const o=r.sections.find(l=>l.id===e);return{group:r.id,section:o==null?void 0:o.id}}const Nf={from:"18:00",to:"09:00"};function cS(e){const t=e.focus!==void 0,r=e.focus??Nf;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:t,"aria-pressed":t,onClick:()=>e.onChange(t?void 0:Nf),children:t?"On":"Off"}),t&&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 uS=[{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 dS(){typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()}function hS(){const{view:e,error:t,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(He,{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(ft,{compact:!0,"aria-label":"Interrupt me by",value:e.prefs.channel,options:uS,onChange:h=>{h==="browser"&&dS(),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(cS,{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(q,{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"]}),t&&i.jsx("span",{className:"vf-err",children:t})]})}const fS=[5,15,30,60];function mS(e){const{value:t}=e;return i.jsxs("div",{className:"choice-row compact",children:[i.jsx(ht,{on:!t.enabled,title:"Off",onClick:()=>e.onChange({...t,enabled:!1})}),fS.map(r=>i.jsx(ht,{on:t.enabled&&t.awayMinutes===r,title:`Away ${r} min`,onClick:()=>e.onChange({enabled:!0,awayMinutes:r})},r))]})}const pS={repo:"Committed to the repo",machine:"Only on this machine",browser:"Only in this browser"};function it(e){const t=e.storage&&pS[e.storage];return i.jsxs("div",{className:"sp-slot",id:`settings-${e.id}`,children:[e.children,t&&i.jsx(q,{className:"sp-where",parts:[t]})]})}function gS(e){const[t]=Ec();return t?i.jsx(He,{title:"Slack",children:i.jsx(gj,{focus:e.focus})}):null}function vS({data:e,route:t}){return i.jsxs(i.Fragment,{children:[i.jsx(it,{id:"attention",storage:"repo",children:i.jsx(hS,{})}),i.jsx(it,{id:"slack",storage:"machine",children:i.jsx(gS,{focus:t.section==="slack"})}),i.jsx(it,{id:"trip-report",storage:"browser",children:i.jsx(He,{title:"Trip report",children:i.jsx(mS,{value:e.prefs.briefing,onChange:r=>e.update({briefing:r})})})})]})}const yS=[{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"]}],kS=[{area:"Polish",items:["Settings → Guides shows whether a guide you added from the catalog was Verified or Not reviewed, saved when you added it, so no network is needed","Settings is now its own page instead of a big dialog: pick This trail, Project, Attention & alerts, You, All projects or About on the left, and each says whether it is committed to the repo or kept on this machine. The address shows where you are, so you can link to a section, and Back or Esc returns to the Lookout","A ticket's guide now sits in its map sign's quiet line, next to the type and state, instead of floating above the sign; hover it for the full name and version",'Onboarding opens calmer: a small logo and one question, "Where should your trails live?"',"Tickets on the trail map are flat cards: a status dot, the title and one quiet line with the key, type, guide and who is on it. Thin elbow lines join them, and the landscape underneath is quieter","Working looks the same everywhere: green, as on the map, in Up next, the ticket pill, the activity steps and the legend. Ready is grey and done steps back; red still only means it needs you now",'The header always shows whether focus is on: "Focus on · until 12:00" or "Focus off". Click it to see what it holds back, focus for an hour, or end focus now, even during your quiet hours, which then pause until they would have ended. It stays on this machine',"Settings → Slack says plainly that you create your own Scout app in your Slack workspace, running from this machine with nothing going through Teamtrail, and each step says what you do in Slack and why. One-click Add to Slack is coming with Teamtrail Cloud","Info icons are square, like the panels and their tooltips"]},{area:"Guides",items:["Write your own guide: `teamtrail guides new <id>` starts one from a template that passes the safety lint. Settings → Guides → Write your own lists your team's guides as Local, Not approved yet or Approved; agents can use one once you approve it, and again after every edit","Share a guide you wrote with everyone: `teamtrail guides lint` checks it, and Write your own links to how to send it to the public catalog","`teamtrail guides add <id>` now looks in every catalog in guides.json, in order, and says which one the guide came from. An id in more than one catalog is refused until you name it, like `ours/perf`",'Catalogs you list in guides.json now add to the official one instead of replacing it; `"official": false` leaves it out']},{area:"Trackers",items:["Sign in with GitHub: no gh login or token needed. GitHub Issues setup shows a code, Open GitHub takes you to enter it, and once you approve, the picker shows your repos as you. The token stays in your own config folder (never the repo), and Sign out forgets it","Tracker setup shows a calm loading state while it looks up your account, repos, Linear teams and projects: placeholder rows and a quiet line instead of an empty list. Connect waits until they arrive, and a lookup that fails says why with a Retry",'GitHub Issues no longer connects the moment you choose it. Onboarding and Settings → Tracker show the account and repo first ("Will use owner/name as you (your gh login)"), let you pick any repo you can push or triage in, or type owner/name, and connect only when you press Connect. Each project in All projects keeps its own repo, and the overview row says where its issues live',`Linear works the same way: once a Linear API key is found or pasted, onboarding and Settings → Tracker say whose it is ("Will use Engineering in Octo Inc as you"), list the teams it can access with a search box and how recently each was active, and offer an optional project. The team saved for this project is picked again, or the only team; otherwise you pick one. Nothing connects until you press Connect, a team the key can't read is refused without switching, and All projects shows "Linear: ENG in Octo Inc"`]},{area:"Teamtrail Cloud",items:["Agents that run in the cloud, steered from the same Lookout"]}],wS=[{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"]},...yS];function xS(){return i.jsxs("div",{className:"changelog",children:[i.jsxs("div",{className:"about",children:[i.jsx(Bm,{className:"about-name"}),i.jsx("span",{className:"mono-label",children:ve.category}),i.jsx("p",{className:"onb-tagline",children:ve.tagline}),i.jsx(q,{parts:[ve.assistant.name]})]}),i.jsx(He,{title:"Next",children:kS.map(e=>i.jsxs("div",{className:"cl-row",children:[i.jsx("span",{className:"mono-label",children:e.area}),i.jsx("ul",{children:e.items.map(t=>i.jsx("li",{children:t},t))})]},e.area))}),wS.map(e=>i.jsx(He,{title:`${e.version} · ${e.date}`,children:i.jsx("ul",{children:e.items.map(t=>i.jsx("li",{children:t},t))})},e.version))]})}function cp(e){return i.jsx("ul",{className:"checklist-answers",children:e.answers.map(t=>i.jsxs("li",{className:t.done?"done":"not-done",children:[i.jsx("span",{className:"mark","aria-label":t.done?"Done":"Not done",children:t.done?"✓":"–"}),i.jsx("span",{className:"t-body",children:t.item}),t.note&&i.jsx("span",{className:"t-meta note",children:t.note})]},t.item))})}const up=`${ve.apiPrefix}`;async function dp(e){const t=await e.json().catch(()=>({}));if(!e.ok)throw new Error(t.error??`Request failed (${e.status})`);return t}const jo=async e=>dp(await fetch(`${up}${e}`)),hp=async(e,t)=>dp(await fetch(`${up}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}));let fp;const po=new Set;let Is;function So(e){fp=e;for(const t of po)t()}function bf(){jo("/guides").then(So,()=>So(null))}const jS=()=>fp;function SS(e){return po.add(e),Is||(bf(),Is=pn(t=>{t.includes("guides")&&bf()})),()=>{po.delete(e),!po.size&&(Is==null||Is(),Is=void 0)}}function gn(){const e=k.useSyncExternalStore(SS,jS),t=k.useCallback(async(o,l)=>{try{So(await hp(o,l));return}catch(c){return c.message}},[]),r=k.useCallback(o=>o?e==null?void 0:e.guides.find(l=>l.id===o):void 0,[e]);return{view:e,act:t,find:r}}function NS(e){var h;const{view:t,find:r}=gn(),o=r(e.id),l=t!=null&&(o==null?void 0:o.status)!=="active",c=((h=o==null?void 0:o.guide)==null?void 0:h.name)??e.id,d=l?`${c}: ${(o==null?void 0:o.reason)??"not installed"}`:`Guide: ${c}`;return i.jsx("span",{className:We("guide-chip",l&&"off"),"data-guide-id":e.id,title:d,children:c})}const bS={active:"Active",unapproved:"New, waiting for your approval",tampered:"Changed since you approved it",invalid:"Can't be used"},CS={active:"Approved",unapproved:"Not approved yet",tampered:"Changed since you approved it",invalid:"Can't be used"},rc=e=>{var t;return e.origin==="local"&&(!((t=e.lock)!=null&&t.source)||e.lock.source==="local")};function $S(e){return rc(e)?{text:CS[e.status],strong:e.status==="active"}:e.status==="active"?void 0:bS[e.status]}function TS(e){var r;if(e.origin==="builtin")return"Built in";const t=(r=e.lock)==null?void 0:r.source;if(!t||t==="local")return e.overridesBuiltin?"Local, replaces the built-in":"Local";try{return`From ${new URL(t.registry).host}`}catch{return"From a catalog"}}const Rc=e=>e.map(t=>/\s/.test(t)?JSON.stringify(t):t).join(" "),Cf=3;function ES(e,t){return e.length<=Math.max(t,Cf+1)?e:`${e.slice(0,Math.max(t-1,Cf)).trimEnd()}…`}function IS(e){var o;const t=(o=e.lock)==null?void 0:o.review;return!t||e.status!=="active"?void 0:t.verified?{text:"Verified",strong:!0,tip:t.reviewedBy.length>0?`Reviewed by ${t.reviewedBy.join(", ")}`:void 0}:"Not reviewed"}function MS(e){const t=e.guide;return t?i.jsxs("tspan",{className:We("guide",t.off&&"off"),"data-guide-id":t.id,children:[i.jsx("title",{children:t.tip})," · ",e.text??t.name]}):null}var AS=Xf();function LS(e){var x;const{preview:t}=e,{act:r,find:o}=gn(),[l,c]=k.useState({kind:"ready"}),[d,h]=k.useState(),g=t.entry.id,m=async()=>{h(void 0),c({kind:"adding"});try{c({kind:"added",pending:(await e.add(g)).pendingChecks})}catch(j){h(j.message),c({kind:"ready"})}};if(t.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 j=e.installed===t.entry.version,T=e.installed?"Update guide":"Add guide";return i.jsxs("div",{className:"add-guide",children:[!t.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:!t.ok||j||l.kind==="adding",onClick:()=>void m(),children:j?"Added":T}),d&&i.jsx("span",{className:"vf-err",children:d})]})}const v=((x=o(g))==null?void 0:x.pendingChecks)??l.pending,w=async j=>h(await r("/guides/checks/approve",{id:g,name:j}));return i.jsxs("div",{className:"add-guide",children:[i.jsx("p",{className:"t-body",children:v.length?`Added ${g} ${t.entry.version}. Approve each command it proposes; none runs until you do.`:`Added ${g} ${t.entry.version}. Agents get its instructions on tickets that ask for ${g}.`}),v.map(j=>{var T,S;return i.jsxs("span",{className:"guide-check",children:[i.jsxs("code",{className:"t-code",children:[j,": ",Rc(((S=(T=t.guide)==null?void 0:T.proposedChecks[j])==null?void 0:S.run)??[])]}),i.jsxs(K,{size:"sm",onClick:()=>void w(j),children:["Approve check ",j]})]},j)}),d&&i.jsx("span",{className:"vf-err",children:d})]})}function RS(e){return e.findings.length?i.jsx("ul",{className:"vf-findings guide-findings",children:e.findings.map((t,r)=>i.jsxs("li",{className:`sev-${t.level}`,children:[i.jsxs("code",{className:"t-code",children:["line ",t.line]})," ",t.message," ",i.jsxs("span",{className:"t-meta",children:["(",t.rule,")"]})]},r))}):i.jsx("p",{className:"t-meta",children:"The safety lint found nothing."})}function OS(e){var o,l;const{p:t}=e,r=Object.entries(((o=t.guide)==null?void 0:o.proposedChecks)??{});return i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"t-label",children:"Safety lint"}),i.jsx(RS,{findings:t.findings}),t.guide&&t.guide.checklist.length>0&&i.jsx("span",{className:"t-label",children:"Checklist"}),t.guide&&i.jsx("ul",{className:"catalog-checklist t-body",children:t.guide.checklist.map(c=>i.jsx("li",{children:c},c))}),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,": ",Rc(d.run)]},c)),i.jsx("span",{className:"t-label",children:"Instructions"}),i.jsx("pre",{className:"guide-preview",children:((l=t.guide)==null?void 0:l.instructions)??t.text})]})}function PS(e){if(!e.repo)return null;const t=encodeURIComponent(`Report: ${e.id} ${e.version}`),r=`${e.repo.replace(/\/+$/,"")}/issues/new?template=report-guide.yml&title=${t}`;return i.jsx("a",{className:"report-link t-meta",href:r,target:"_blank",rel:"noreferrer",children:"Report this guide"})}function _S(e){const t=e.entry,[r,o]=k.useState(),[l,c]=k.useState();return k.useEffect(()=>{e.preview(t.id).then(o,d=>c(d.message))},[t.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:t.name??t.id}),i.jsx(q,{parts:[{text:t.id,code:!0},t.version,`by ${t.author}`,DS(t),t.reviewedBy.length>0&&`reviewed by ${t.reviewedBy.join(", ")}`]}),i.jsx("p",{className:"t-body",children:t.summary}),t.history.length>0&&i.jsx("ul",{className:"catalog-history",children:t.history.map(d=>i.jsxs("li",{className:"t-meta",children:[d.version," · ",i.jsx("code",{className:"t-code",children:d.commit.slice(0,8)})," · ",d.at.slice(0,10),d.reviewer&&` · reviewed by ${d.reviewer}`]},`${d.version}-${d.commit}`))}),l&&i.jsx("span",{className:"vf-err",children:l}),r&&i.jsx(OS,{p:r}),r&&i.jsx(PS,{repo:r.repo,id:t.id,version:t.version}),r&&i.jsx(LS,{preview:r,installed:e.installed,add:e.add})]})}function DS(e){return e.builtin?{text:"Built in",strong:!0}:e.verified?{text:"Verified",strong:!0}:"Not reviewed"}function BS(e){const t=e.entry;return i.jsx("li",{className:"catalog-row","data-guide-id":t.id,children:i.jsx(Ae,{title:t.name??t.id,context:i.jsx(q,{parts:[{text:t.id,code:!0},t.version,t.author,zS(t),t.reported&&"Reported"]}),detail:t.summary,trailing:e.installed&&`installed ${e.installed}`,onOpen:e.onOpen})})}function zS(e){return e.builtin?{text:"Built in",strong:!0}:e.verified?{text:"Verified",strong:!0}:"Not reviewed"}const $f=e=>e?`registry=${encodeURIComponent(e)}`:"";function FS(e){const[t,r]=k.useState(),[o,l]=k.useState();k.useEffect(()=>{let h=!0;return r(void 0),l(void 0),jo(`/guides/catalog?${$f(e)}`).then(g=>h&&r(g),g=>h&&l(g.message)),()=>{h=!1}},[e]);const c=k.useCallback(h=>jo(`/guides/catalog/preview?${$f(e)}&id=${encodeURIComponent(h)}`),[e]),d=k.useCallback(async h=>{const g=await hp("/guides/catalog/add",{registry:e,id:h});return So(g),g.installed},[e]);return{index:t,error:o,preview:c,add:d}}function US(e){var T,S;const[t,r]=k.useState(((T=e.registries[0])==null?void 0:T.name)??""),o=FS(t||void 0),{find:l}=gn(),[c,d]=k.useState(""),[h,g]=k.useState(!0),[m,v]=k.useState(),w=o.index?cw({guides:o.index.guides},{query:c,verifiedOnly:h}):[],x=(S=o.index)==null?void 0:S.guides.find(E=>E.id===m),j=E=>{var M,R,O;return((M=l(E))==null?void 0:M.origin)==="local"?(O=(R=l(E))==null?void 0:R.guide)==null?void 0:O.version:void 0};return AS.createPortal(i.jsx("div",{className:"scrim catalog-scrim",onClick:E=>{E.stopPropagation(),e.onClose()},children:i.jsxs(Ke,{as:"div",className:"dialog catalog-dialog",onClick:E=>E.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h3",{className:"t-title",children:"Guide catalog"}),e.registries.length>1&&i.jsx(ft,{compact:!0,"aria-label":"Catalog",value:t,options:e.registries.map(E=>({value:E.name,label:E.name,hint:E.url})),onChange:r}),i.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})]}),x?i.jsx(_S,{entry:x,installed:j(x.id),preview:o.preview,add:o.add,onBack:()=>v(void 0)}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"catalog-filters",children:[i.jsx("input",{className:"catalog-search",placeholder:"Search guides","aria-label":"Search guides",value:c,onChange:E=>d(E.target.value)}),i.jsx(K,{size:"sm",on:h,"aria-pressed":h,onClick:()=>g(E=>!E),children:"Verified only"})]}),o.error&&i.jsx("span",{className:"vf-err",children:o.error}),!o.index&&!o.error&&i.jsx(Ee,{children:"Reading the catalog…"}),o.index&&!w.length&&i.jsx(Ee,{children:"No guides match."}),i.jsx("ul",{className:"catalog-list",children:w.map(E=>i.jsx(BS,{entry:E,installed:j(E.id),onOpen:()=>v(E.id)},E.id))})]})]})}),document.body)}function HS(e){const t=e.r.guide;if(!t)return null;const r=Object.entries(t.proposedChecks);if(!t.requiresChecks.length&&!r.length)return null;const o=e.r.status==="active";return i.jsxs("div",{className:"guide-checks",children:[t.requiresChecks.length>0&&i.jsxs("span",{className:"t-meta",children:["Adds checks ",i.jsx("code",{className:"t-code",children:t.requiresChecks.join(", ")})," to its tickets"]}),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,": ",Rc(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 mp(e){var d,h;const{r:t}=e,r=t.id,o=t.status!=="active"||t.pendingChecks.length>0,l=(t.status==="unapproved"||t.status==="tampered")&&!!t.guide,c=t.guide?`${t.guide.name} ${t.guide.version}`:r;return i.jsx("li",{className:"guide-row","data-guide-id":r,children:i.jsx(Ae,{edge:o?"attention":"neutral",title:c,context:i.jsx(q,{parts:[{text:r,code:!0},TS(t),IS(t),$S(t),t.guide&&WS(t.guide.checklist.length)]}),detail:t.status==="unapproved"?(d=t.guide)==null?void 0:d.summary:t.reason??((h=t.guide)==null?void 0:h.summary),actions:t.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.jsx(K,{size:"sm","aria-label":`Approve guide ${r}`,disabled:e.busy,onClick:()=>e.onAct("/guides/approve",{id:r}),children:"Approve"}),i.jsx(HS,{r:t,busy:e.busy,onApprove:g=>e.onAct("/guides/checks/approve",{id:r,name:g})})]})})})}const WS=e=>e===1?"1 checklist item":`${e} checklist items`;function KS(e){return i.jsxs(He,{title:"Write your own",children:[i.jsxs("p",{className:"vf-intro",children:["Write a guide for your team in your repo with ",i.jsxs("code",{className:"t-code",children:[ve.slug," guides new <id>"]}),". It starts from a template in ",i.jsxs("code",{className:"t-code",children:[ve.dataDir,"/guides/"]})," that passes the safety lint. Fill in the instructions and checklist, then approve it here: agents can only use it once you have, and again after every edit."]}),e.guides.length>0?i.jsx("ul",{className:"guides-list own-guides",children:e.guides.map(t=>i.jsx(mp,{r:t,busy:e.busy,onAct:e.onAct},t.id))}):i.jsx(Ee,{children:"No guides of your own yet."}),e.error&&i.jsx("span",{className:"vf-err",children:e.error}),i.jsxs("p",{className:"t-meta guides-share",children:["Useful beyond your team? Check it with ",i.jsxs("code",{className:"t-code",children:[ve.slug," guides lint"]})," and"," ",i.jsx("a",{href:lw,target:"_blank",rel:"noreferrer",children:"share it in the public catalog"}),"."]})]})}function VS(e){const{view:t,act:r}=gn(),[o,l]=k.useState(),[c,d]=k.useState(!1),[h,g]=k.useState(!1),m=k.useRef(null);if(k.useEffect(()=>{var x;e.focus&&t&&((x=m.current)==null||x.scrollIntoView({block:"start"}))},[e.focus,!!t]),!t)return null;const v=x=>(j,T)=>{d(!0),r(j,T).then(S=>{l(S?{own:x,message:S}:void 0),d(!1)})},w=x=>o&&o.own===x?o.message:void 0;return i.jsxs("div",{className:"guides-section",ref:m,children:[i.jsxs(He,{title:"Guides",children:[i.jsx("p",{className:"vf-intro",children:"Guides give an agent instructions and a checklist for the tickets that ask for them. A guide can add checks, never remove them, and its commands only run once you approve them."}),i.jsx("ul",{className:"guides-list",children:t.guides.filter(x=>!rc(x)).map(x=>i.jsx(mp,{r:x,busy:c,onAct:v(!1)},x.id))}),i.jsxs("div",{className:"guides-foot",children:[i.jsx(K,{size:"sm",onClick:()=>g(!0),children:"Browse guides"}),i.jsx(q,{parts:[{text:`${ve.dataDir}/guides/`,code:!0},{text:"guides.lock.json",code:!0}]})]}),t.configErrors.length>0&&i.jsx("ul",{className:"vf-errors",children:t.configErrors.map(x=>i.jsx("li",{children:x},x))}),w(!1)&&i.jsx("span",{className:"vf-err",children:w(!1)})]}),i.jsx(KS,{guides:t.guides.filter(rc),busy:c,onAct:v(!0),error:w(!0)}),h&&i.jsx(US,{registries:t.registries,onClose:()=>g(!1)})]})}function GS(e){const{view:t,act:r}=gn(),[o,l]=k.useState();if(!t)return null;const c=e.map.guides??[],d=t.guides.filter(g=>g.status==="active"&&g.guide),h=g=>{const m=c.includes(g)?c.filter(v=>v!==g):[...c,g];l(void 0),r("/guides/team",{mapId:e.map.id,guides:m}).then(l)};return i.jsxs(He,{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 qS(e,t){const[r,o]=k.useState();return k.useEffect(()=>{const l=`/guides/checklist?mapId=${encodeURIComponent(e)}&ticketId=${encodeURIComponent(t)}`,c=()=>jo(l).then(d=>o(d.checklist),()=>o(null));return c(),pn(d=>{d.endsWith("checklist.json")&&c()})},[e,t]),r}function QS(e){const t=qS(e.mapId,e.ticketId);if(!t)return null;const r=t.answers.filter(o=>!o.done).length;return i.jsxs("div",{className:"checklist-panel",children:[i.jsx(q,{parts:[`${t.guide.id} ${t.guide.version} checklist`,t.by,Ki(t.at),r?`${r} not done`:"all done"]}),i.jsx(cp,{answers:t.answers})]})}const Tf="";function YS(e){const{view:t,act:r}=gn(),[o,l]=k.useState();if(!t)return null;const c=e.ticket,d=t.guides.filter(m=>{var v;return m.status==="active"&&((v=m.guide)==null?void 0:v.handles.types.includes(c.type))}),h=[{value:Tf,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(ft,{compact:!0,"aria-label":"Ticket guide",value:c.guide??Tf,options:h,onChange:g}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function JS(e){const{view:t,find:r}=gn();if(!t)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 XS(e){const{view:t}=gn(),r=e.ticket;return!t||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(YS,{mapId:e.mapId,ticket:r}):r.guide&&i.jsx(NS,{id:r.guide})]}),r.guide&&i.jsx(JS,{id:r.guide}),i.jsx(QS,{mapId:e.mapId,ticketId:r.id})]})}function ZS(e){var g;const{view:t,find:r}=gn();if(!e)return;const o=r(e),l=t!=null&&(o==null?void 0:o.status)!=="active",c=((g=o==null?void 0:o.guide)==null?void 0:g.name)??e,d=o!=null&&o.guide?`${c} ${o.guide.version}`:c,h=l?`Guide ${d}: ${(o==null?void 0:o.reason)??"not installed"}`:`Guide: ${d}`;return{id:e,name:c,tip:h,off:l}}const Ef={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"},eN={low:"the agent decides",medium:"the agent decides and records it",high:"you decide"},tN=e=>e[0].toUpperCase()+e.slice(1),oc=mm.map(e=>({value:e,label:tN(e),hint:eN[e]}));function nN(e){const[t,r]=k.useState(""),[o,l]=k.useState("high"),{rules:c,onChange:d}=e,h=()=>{const g=t.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(ft,{compact:!0,"aria-label":`${g.glob} risk`,value:g.level,options:oc,onChange:v=>d(c.map((w,x)=>x===m?{...w,level:v}:w))}),i.jsx("button",{className:"icon-btn","aria-label":`Remove ${g.glob}`,onClick:()=>d(c.filter((v,w)=>w!==m)),children:"×"})]},g.glob)),i.jsxs("div",{className:"risk-row",children:[i.jsx("input",{value:t,placeholder:"src/payments/**","aria-label":"New file pattern",onChange:g=>r(g.target.value),onKeyDown:g=>g.key==="Enter"&&h()}),i.jsx(ft,{compact:!0,"aria-label":"New pattern risk",value:o,options:oc,onChange:l}),i.jsx(K,{onClick:h,disabled:!t.trim(),children:"Add"})]})]})}const pp=`${Ne()}/policy`;async function sN(){const e=await fetch(pp);return e.ok?await e.json():null}function iN(){const[e,t]=k.useState(),r=k.useCallback(()=>{sN().then(t,()=>t(null))},[]);k.useEffect(()=>(r(),pn(l=>{l.endsWith("policy.json")&&r()})),[r]);const o=k.useCallback(async l=>{const c=await fetch(pp,{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})`;t(d)},[]);return{view:e,save:o}}function rN(){const{view:e,save:t}=iN(),[r,o]=k.useState();if(!e)return null;const l=`${ve.dataDir}/policy.json`,c=d=>{o(void 0),t(d).then(o,h=>o(h.message))};return i.jsxs(He,{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:fm.map(d=>i.jsxs("label",{className:"risk-row",children:[i.jsx("span",{children:Ef[d]}),i.jsx(ft,{compact:!0,"aria-label":`${Ef[d]} risk`,value:e.policy.categories[d],options:oc,onChange:h=>c({...e.policy,categories:{...e.policy.categories,[d]:h}})})]},d))}),i.jsx(nN,{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})]})}const ac=`${Ne()}/workspaces`;async function oN(){const e=await fetch(ac);return e.ok?await e.json():null}function gp(){const[e,t]=k.useState(),r=k.useCallback(()=>{oN().then(t,()=>t(null))},[]);k.useEffect(()=>(r(),pn(c=>{(c.endsWith("workspaces.json")||c.includes("workspaces/")||c.includes("leases/"))&&r()})),[r]);const o=k.useCallback(async c=>{const d=await fetch(ac,{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})`;t(h)},[]),l=k.useCallback(async(c,d,h=!1)=>{const g=await fetch(`${ac}/remove`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:c,ticketId:d,force:h})}),m=await g.json();return g.ok?(t(m),{}):{error:m.error??`Removing failed (${g.status})`,dirty:m.dirty??!1}},[]);return{view:e,save:o,remove:l}}function vp(e){const[t,r]=k.useState(!1),[o,l]=k.useState(),[c,d]=k.useState(!1),h=async g=>{d(!0),l(void 0);const m=await e.onRemove(g).catch(v=>({error:v.message,dirty:!1}));d(!1),r(!!m.dirty&&!g),m.dirty||l(m.error)};return t?i.jsxs("span",{className:"ws-remove ask",children:[i.jsx("span",{className:"vf-err",children:"Uncommitted changes in this workspace will be lost."}),i.jsx(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 aN(e){return e.rows.length?i.jsx("ul",{className:"ws-list",children:e.rows.map(t=>i.jsx(Ae,{as:"li",className:`ws-row ${t.active?"active":"finished"}`,title:i.jsx("span",{className:"t-code",children:t.branch}),titleText:t.branch,context:i.jsx(q,{parts:[{text:t.ticketKey,code:!0},t.active?`Active · ${t.agent}`:"Finished"]}),detail:i.jsx("span",{className:"t-code",children:t.path}),detailText:t.path,below:t.active?void 0:i.jsx(vp,{onRemove:r=>e.onRemove(t.mapId,t.ticketId,r)})},`${t.mapId}/${t.ticketId}`))}):null}function lN(e){const{view:t,remove:r}=gp(),o=t==null?void 0:t.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(vp,{label:"Remove workspace",onRemove:l=>r(e.mapId,e.ticketId,l)})]})}function cN(){const{view:e,save:t,remove:r}=gp(),[o,l]=k.useState();if(!e)return null;const c=e.settings.worktrees,d=()=>{l(void 0),t({...e.settings,worktrees:!c}).then(l,h=>l(h.message))};return i.jsxs(He,{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(q,{className:"set-hint",parts:[{text:`${ve.dataDir}/workspaces.json`,code:!0},If(e.workspaces.filter(h=>h.active).length,"active"),If(e.workspaces.filter(h=>!h.active).length,"finished")]}),i.jsx(aN,{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 If=(e,t)=>`${e} ${t}`;function uN({data:e,route:t}){return i.jsxs(i.Fragment,{children:[i.jsx(it,{id:"tracker",children:i.jsx(He,{title:"Tracker",children:i.jsx(rS,{activeTracker:e.activeTracker,location:e.location,update:e.update})})}),i.jsx(it,{id:"workspaces",storage:"repo",children:i.jsx(cN,{})}),i.jsx(it,{id:"policy",storage:"repo",children:i.jsx(rN,{})}),i.jsx(it,{id:"guides",storage:"repo",children:i.jsx(VS,{focus:t.section==="guides"})}),i.jsx(it,{id:"labels",children:i.jsx(He,{title:"Labels",children:i.jsxs("div",{className:"label-codes",children:[i.jsx("code",{children:dc}),i.jsxs("code",{children:[ve.labelPrefix,":<type>"]}),i.jsx("code",{children:hc}),i.jsx("code",{children:fc})]})})})]})}const lc=`${ve.apiPrefix}/projects`;async function uo(e,t,r){const o=await fetch(`${lc}${e}`,{method:t,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 zs={url:lc,add:e=>uo("","POST",{path:e}),remove:e=>uo(`/${e}`,"DELETE"),setAutoRegister:e=>uo("/settings","PUT",{autoRegister:e}),answer:(e,t)=>uo(`/${e}/answer`,"POST",t),async briefing(e){const t=await fetch(`${lc}/briefing?since=${e}`);return t.ok?await t.json():void 0}};function yp(e){const[t,r]=k.useState(""),[o,l]=k.useState(),c=d=>{d.trim()&&(l(void 0),zs.add(d.trim()).then(()=>(r(""),e.onAdded()),h=>l(h.message)))};return i.jsxs("div",{className:"pj-add",children:[i.jsx(Sc,{value:t,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 Ms=(e,t)=>e>0&&`${e} ${t}`;function dN(e){var r;const t=((r=e.briefing)==null?void 0:r.projects)??[];return!e.briefing||!t.length?null:i.jsxs("section",{className:"pj-section pj-briefing",children:[i.jsx(Ct,{title:"While you were away",count:t.length,info:`What changed in each project since ${nn(e.now-e.briefing.since)} ago`}),i.jsx("ul",{className:"pj-list",children:t.map(({projectId:o,project:l,briefing:c})=>i.jsx(Ae,{as:"li",edge:c.totals.waiting>0?"attention":"neutral",title:l,context:i.jsx(q,{parts:[Ms(c.totals.done,"done"),Ms(c.trails.reduce((d,h)=>d+h.opened.length,0),"new tickets"),Ms(c.totals.agentDecisions,"agent decisions"),Ms(c.totals.waiting,"waiting on you"),Ms(c.totals.ruledOut,"ruled out"),Ms(c.totals.active,"agents active")]}),onOpen:()=>e.onOpen(o)},o))})]})}function hN(e){const[t,r]=k.useState(""),[o,l]=k.useState(!1),[c,d]=k.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(Sc,{value:t,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 fN(e){const{item:t}=e,r=qm(t),o=t.kind==="question"&&t.agent?`${t.agent} asks`:Vm[t.kind],l=t.urgency==="blocking"&&{text:"Blocking",urgent:!0,className:"urgency-tag"};return i.jsx(Ae,{as:"li",className:`att-item pj-item k-${t.kind}`,edge:Gm(t,t.interrupting),title:t.title.split(`
|
|
129
|
+
`)[0],titleText:t.title,context:i.jsx(q,{parts:[l,{text:t.project,strong:!0},o]}),detail:r.length>0&&r.join(" · "),detailText:r.join(`
|
|
130
|
+
`),trailing:nn(e.now-t.since),onOpen:e.onOpen,below:e.onAnswer&&i.jsx(hN,{onAnswer:e.onAnswer})})}function mN(e){const t=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(Ct,{title:"Needs you",count:t.length,hot:t.some(o=>o.interrupting),info:"One queue across projects, ranked the way each project ranks its own. Answer questions here; the agent in that repo gets the answer."}),t.length===0&&i.jsx(Dn,{title:"Nothing needs you",hint:"Agents in every project can keep going."}),i.jsx("ul",{className:"pj-list",children:t.map(o=>i.jsx(fN,{item:o,now:e.now,onOpen:()=>e.onOpen(o.projectId,o.id),onAnswer:o.kind==="question"&&r(o.projectId)?l=>zs.answer(o.projectId,{questionId:o.ref,text:l}).then(e.onAnswered):void 0},`${o.projectId}/${o.id}`))})]})}const Kl=(e,t,r=`${t}s`)=>`${e} ${e===1?t:r}`;function pN(e){return e.interrupting>0?"urgent":e.phases.blocked+e.phases.rework+e.flags+e.stalled>0||e.state.kind==="missing"?"attention":"neutral"}function gN(e){if(e.state.kind==="missing")return[{text:"Missing",strong:!0},{text:e.path,code:!0}];const t=[];e.needsYou&&t.push({text:`${e.needsYou} ${e.needsYou===1?"needs":"need"} you`,strong:!0,urgent:e.interrupting>0}),e.agents&&t.push(Kl(e.agents,"agent"));const{working:r,verifying:o,rework:l,blocked:c}=e.phases;r&&t.push(`${r} working`),o&&t.push(`${o} verifying`),l&&t.push(`${l} rework`),c&&t.push(`${c} blocked`),e.flags&&t.push(Kl(e.flags,"PR flag")),e.stalled&&t.push(Kl(e.stalled,"stalled claim")),t.length||t.push(e.trails?"Nothing waiting":"No trails yet");const d=vN(e.tracker);return d&&t.push(d),t}function vN(e){if(e.kind==="github"&&e.repo)return`Issues in ${e.repo}`;if(!(e.kind!=="linear"||!e.team))return e.org?`Linear: ${e.team} in ${e.org}`:`Linear: ${e.team}`}function yN(e){var t;return e.state.kind==="elsewhere"?`Served by another Lookout · ${e.state.url}`:((t=e.top)==null?void 0:t.title)??e.note??e.path}function No(e,t,r){if(e.state.kind!=="missing"){if(e.state.kind==="elsewhere"){const o=new URL(e.state.url);r&&o.searchParams.set(Ps,r),window.open(o.toString(),"_blank","noopener");return}location.href=Kw({id:e.id,home:t,tracker:e.tracker.kind,item:r})}}function kp(e){const{p:t}=e,r=yN(t);return i.jsx(Ae,{as:"li",className:`project-card st-${t.state.kind}`,edge:pN(t),selected:e.current,title:t.name,titleText:t.path,context:i.jsx(q,{parts:gN(t)}),detail:r,detailText:r,trailing:t.lastActivity?nn(e.now-t.lastActivity):void 0,onOpen:e.onOpen})}const wp=`${To}:projects:seen`,Mf=24*36e5;function kN(e){try{const t=Number(localStorage.getItem(wp));return t>0?t:e-Mf}catch{return e-Mf}}function wN(e){try{localStorage.setItem(wp,String(e))}catch{}}function xN(){const[e,t]=k.useState();return k.useEffect(()=>{const r=Date.now();return zs.briefing(kN(r)).then(t).catch(()=>{}),()=>wN(r)},[]),e}function jN(e){const{view:t,reload:r}=e.projects,o=sn(15e3),l=xN();if(k.useEffect(()=>{const g=m=>m.key==="Escape"&&e.onClose();return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[e]),!t)return null;const c=_o()??t.home,d=g=>{const m=t.projects.find(v=>v.id===g);(m==null?void 0:m.id)===c?e.onClose():m&&No(m,t.home)},h=(g,m)=>{const v=t.projects.find(w=>w.id===g);if(v){if(v.id!==c)return No(v,t.home,m);e.onClose(),e.onItemHere(m)}};return i.jsxs(Ke,{className:`zone decisions-view projects-view dv-${e.bp}`,children:[i.jsxs("header",{className:"dv-head",children:[i.jsx(Je,{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(mN,{view:t,now:o,onOpen:h,onAnswered:r}),i.jsxs("section",{className:"pj-section pj-projects",children:[i.jsx(Ct,{title:"Projects",count:t.projects.length,info:"Each repo registered on this machine, read from its own files. Nothing leaves your machine."}),i.jsx("ul",{className:"pj-list",children:t.projects.map(g=>i.jsx(kp,{p:g,current:g.id===c,now:o,onOpen:g.state.kind==="missing"?void 0:()=>d(g.id)},g.id))}),i.jsx(yp,{onAdded:r})]}),i.jsx(dN,{briefing:l,now:o,onOpen:d})]})]})}function SN(e){const[t,r]=k.useState(!1),o=k.useRef(null);k.useEffect(()=>{if(!t)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)}},[t]);const{view:l}=e.projects;if(!l||!e.projects.many)return i.jsx("span",{className:"repo",children:e.repo});const c=_o()??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":t,"data-tip":"Switch project, or see all of them",children:[i.jsx("span",{className:"project-name",children:e.repo}),d>0&&i.jsx(ts,{n:d,urgent:!0}),i.jsx("span",{className:"caret",children:"▾"})]}),t&&i.jsxs("div",{className:"trail-menu",role:"menu",children:[i.jsxs("button",{role:"menuitem",className:"trail-item all-projects",onClick:()=>{r(!1),e.onOverview()},children:[i.jsx("span",{className:"mi-title",children:"All projects"}),i.jsx(ts,{n:l.attention.length,urgent:l.attention.some(h=>h.interrupting),hideZero:!0})]}),i.jsx(Je,{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&&No(h,l.home)},children:[i.jsx("span",{className:"mi-title",children:h.name}),i.jsx("span",{className:"mi-progress",children:NN(h.state.kind)}),i.jsx(ts,{n:h.needsYou,urgent:h.interrupting>0,hideZero:!0})]},h.id))]})]})}function NN(e){return e==="missing"?"missing":e==="elsewhere"?"other Lookout":""}function bN(e){const t=sn(15e3),{view:r}=e.projects;if(!r||!e.projects.many)return null;const o=_o()??r.home;return i.jsxs("section",{className:"phone-projects",children:[i.jsx(Ct,{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(kp,{p:l,current:!1,now:t,onOpen:l.state.kind==="missing"?void 0:()=>No(l,r.home)},l.id))})]})}function xp(){const[e,t]=k.useState(),r=k.useCallback(()=>{fetch(zs.url).then(o=>o.ok?o.json():void 0).then(o=>o&&t(o)).catch(()=>{})},[]);return k.useEffect(()=>zo("projects",o=>t(JSON.parse(o))),[]),k.useEffect(r,[r]),{view:e,many:((e==null?void 0:e.projects.length)??0)>1,reload:r}}const CN=e=>[e.home&&{text:"This Lookout",strong:!0},e.state.kind==="missing"&&"Missing",{text:e.path,code:!0}];function $N(){const{view:e,reload:t}=xp(),[r,o]=k.useState();if(!e)return null;const l=c=>{o(void 0),c.then(t,d=>o(d.message))};return i.jsxs(He,{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(Ae,{as:"li",edge:c.state.kind==="missing"?"attention":"neutral",title:c.name,context:i.jsx(q,{parts:CN(c)}),actions:!c.home&&i.jsx(K,{size:"sm",variant:"ghost",onClick:()=>l(zs.remove(c.id)),children:"Remove"})},c.id))}),i.jsx(yp,{onAdded:t}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Agents add their repo when they connect"}),i.jsx(K,{size:"sm",on:e.autoRegister,"aria-pressed":e.autoRegister,className:"auto-register-toggle",onClick:()=>l(zs.setAutoRegister(!e.autoRegister)),children:e.autoRegister?"On":"Off"})]}),i.jsx(q,{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 TN=`${ve.apiPrefix}/models`;function Oc(){const[e,t]=k.useState(),r=k.useCallback(()=>{fetch(TN).then(o=>o.ok?o.json():null).then(t,()=>t(null))},[]);return k.useEffect(()=>{r();const o=pn(c=>{(c.endsWith("models.json")||c.endsWith("map.md")||c.includes("/tickets/"))&&r()}),l=zo("attention",r);return()=>{o(),l()}},[r]),e}function EN({mapId:e,ticketId:t}){const r=Oc(),o=r==null?void 0:r.waiting.find(l=>l.mapId===e&&l.ticketId===t);return o?i.jsx(Ae,{className:"model-wait d-section",edge:"attention",title:`Needs a ${o.tier} model`,context:i.jsx(q,{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 IN({view:e}){if(!e)return null;const t=`${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(q,{className:"set-hint",parts:[{text:t,code:!0},e.exists?`${r} of your own models`:"add new or custom models here","unknown models count as balanced"]}),o&&i.jsx(q,{className:"set-hint models-connected",parts:[`Connected now: ${o}`]}),e.errors.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[t," has errors, so only the built-in models count until it is fixed."]})]}),i.jsx("ul",{className:"vf-errors",children:e.errors.map(l=>i.jsx("li",{children:l},l))})]})]})}const jp={fast:"Fast",balanced:"Balanced",strongest:"Strongest"},MN={fast:"Haiku, mini and nano models",balanced:"Sonnet, GPT-4 models",strongest:"Opus, GPT-5 and o-series models"},AN=tm.map(e=>({value:e,label:jp[e],hint:MN[e]}));function LN(e){return i.jsx("div",{className:"tier-grid",children:Io.map(t=>{const r=e.tiers[t],o=pc[t];return i.jsxs("div",{className:"tier-row",children:[i.jsx("span",{children:Bi[t]}),i.jsx(ft,{compact:!0,"aria-label":`${Bi[t]} tickets' model`,className:`tier-select tier-${t}`,value:r,options:AN,onChange:l=>e.onChange(t,l)}),i.jsx(q,{className:"tier-hint",parts:[r!==o&&`default ${jp[o].toLowerCase()}`,e.hints[t]]})]},t)})})}const ho=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function RN({rows:e}){return e.length?i.jsx("ul",{className:"perf-rows",children:e.map(t=>i.jsx(Ae,{as:"li",className:"perf-row",title:t.key,trailing:i.jsx("span",{title:"Median time from first claim to done",children:en(t.medianLeadMs)}),context:i.jsx(q,{parts:[`${t.done} of ${ho(t.tickets,"ticket")} done`,t.cancelled>0&&`${t.cancelled} cancelled`,ho(t.reworkCycles,"rework"),`reviews ${t.reviews.passed} passed, ${t.reviews.failed} failed`,t.answers>0&&ho(t.answers,"question")]}),detail:t.findings.raised>0?`As reviewer: ${t.findings.upheld} of ${ho(t.findings.raised,"finding")} upheld`:void 0},t.key))}):i.jsx(Ee,{children:"No claimed tickets yet"})}function Sp(e){const[t,r]=k.useState({}),o=e.map(l=>`${l.map.id}:${l.tickets.reduce((c,d)=>Math.max(c,d.updatedAt),0)}`).join();return k.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]),t}const ON=[{id:"byVendor",title:"By vendor"},{id:"byAgent",title:"By agent"},{id:"byType",title:"By ticket type"}];function PN({api:e,bp:t,onClose:r}){const[o,l]=k.useState("byVendor"),c=k.useMemo(()=>Object.values(e.allSnaps),[e.allSnaps]),d=Sp(c),h=e.activity.answered,g=k.useMemo(()=>km(c.map(m=>({snap:m,journal:d[m.map.id]??[],answered:h}))),[c,d,h]);return k.useEffect(()=>{const m=v=>v.key==="Escape"&&r();return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[r]),i.jsxs(Ke,{className:`zone decisions-view perf-view dv-${t}`,children:[i.jsxs("header",{className:"dv-head",children:[i.jsx(Je,{as:"h2",children:"Trail stats"}),i.jsx(q,{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(Je,{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(Ee,{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:ON.map(m=>i.jsx(ht,{on:o===m.id,title:m.title,onClick:()=>l(m.id)},m.id))}),i.jsx(RN,{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 _N(e,t){const r=Sp(e);return k.useMemo(()=>{var c;const o=km(e.map(d=>({snap:d,journal:r[d.map.id]??[],answered:t}))),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 ${en(d.medianLeadMs)}`,d.reworkCycles>0&&`${d.reworkCycles} back to rework`,h];l[d.key]=g.filter(Boolean).join(" · ")}return l},[e,r,t])}function DN(e){var d,h;const t=Oc(),r=_N(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(He,{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(LN,{tiers:zv(o),hints:r,onChange:(g,m)=>{const v={...c,[g]:m};m===pc[g]&&delete v[g],e.onChange({enabled:!0,tiers:v})}}),l&&i.jsx("span",{className:"set-hint t-meta",children:"Changes apply to the next claim; nothing running is interrupted."}),i.jsx(IN,{view:t})]})}function BN(){const[e,t]=k.useState();return k.useEffect(()=>{let r=!0;return fetch(`${Ne()}/verification/config`).then(o=>o.ok?o.json():null).then(o=>r&&t(o),()=>r&&t(null)),()=>{r=!1}},[]),e}const Af=`{
|
|
131
|
+
"v": 1,
|
|
132
|
+
"checks": {
|
|
133
|
+
"test": { "run": ["npm", "test"] },
|
|
134
|
+
"lint": { "run": ["npm", "run", "lint"] }
|
|
135
|
+
},
|
|
136
|
+
"run": ["test", "lint"]
|
|
137
|
+
}
|
|
138
|
+
`;function zN({file:e}){const[t,r]=k.useState(!1),o=()=>void navigator.clipboard.writeText(Af).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:Af}),i.jsx(K,{size:"sm",variant:"ghost",onClick:o,children:t?"Copied":"Copy"})]}),i.jsxs("p",{className:"dim",children:[i.jsx("code",{children:"run"})," lists the checks that run on every completion. Each ",i.jsx("code",{children:"run"})," command is a list of words, not a shell line. Until the file exists, levels above Off can’t run their checks, so those completions stop and wait for you."]})]})}function FN(e){const t=BN(),[r,o]=k.useState();if(!t)return null;const l=e.map,c=t.config,d=`${ve.dataDir}/${t.file}`,h=(l==null?void 0:l.verification)??"off",g=(c??om).appliesTo.join(" and ");return i.jsxs(He,{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:mc.map(m=>i.jsx(ht,{on:h===m,title:Fi[m],sub:Xm[m],onClick:()=>{o(void 0),Vi.act({action:"level",mapId:l.id,level:m,by:xt}).catch(v=>o(v.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})]}),t.errors.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line alert",title:t.hash,children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[d," has errors. Completions that need checks wait for you until it is fixed."]})]}),i.jsx("ul",{className:"vf-errors",children:t.errors.map(m=>i.jsx("li",{children:m},m))})]}),!t.exists&&i.jsx(zN,{file:d}),c&&t.exists&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line ok",title:t.hash,children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[i.jsx("span",{className:"t-code",children:d})," · ",c.run.length," checks run on every completion"]})]}),i.jsx(q,{className:"set-hint",parts:[`New trails start at ${Fi[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,v])=>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:v.run.join(" ")}),i.jsxs("span",{className:"dim",children:[v.timeoutSec," s",v.cwd&&v.cwd!=="."?` · in ${v.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."]})]})}function UN({data:e}){const{map:t}=e;return i.jsxs(i.Fragment,{children:[t?i.jsx(it,{id:"mode",children:i.jsx(He,{title:`Trail ${t.key}`,children:i.jsx(m0,{value:t.mode,onChange:e.onMapMode})})}):i.jsx(Ee,{children:"Chart or pick a trail to set its mode, model matching and team."}),i.jsx(it,{id:"verification",storage:"repo",children:i.jsx(FN,{map:t})}),i.jsx(it,{id:"models",children:i.jsx(DN,{map:t,snaps:e.snaps,answered:e.answered,onChange:e.onModelMatching})}),t&&i.jsx(it,{id:"team",children:i.jsx(GS,{map:t})})]})}const HN=[{value:"auto",title:"Match my system"},{value:"day",title:"Day"},{value:"night",title:"Night"}];function WN(e){return i.jsx("div",{className:"choice-row compact",children:HN.map(t=>i.jsx(ht,{on:e.value===t.value,title:t.title,onClick:()=>e.onChange(t.value)},t.value))})}function KN({data:e}){const{prefs:t,update:r}=e;return i.jsxs(i.Fragment,{children:[i.jsx(it,{id:"appearance",storage:"browser",children:i.jsx(He,{title:"Appearance",children:i.jsx(WN,{value:t.theme,onChange:o=>r({theme:o})})})}),i.jsx(it,{id:"transcript",storage:"browser",children:i.jsx(He,{title:"HITL transcript",children:i.jsx(ap,{value:t.hitlTranscript,onChange:o=>r({hitlTranscript:o})})})}),i.jsx(it,{id:"agent",children:i.jsx(He,{title:"Agent",children:i.jsx("div",{className:"choice-row",children:Sm.map(o=>i.jsx(ht,{on:o.status==="primary",disabled:o.status!=="primary",title:o.name},o.id))})})})]})}function VN(e){const{data:t,route:r}=e;switch(e.group){case"trail":return i.jsx(UN,{data:t});case"project":return i.jsx(uN,{data:t,route:r});case"alerts":return i.jsx(vS,{data:t,route:r});case"you":return i.jsx(KN,{data:t});case"projects":return i.jsx(it,{id:"projects",storage:"machine",children:i.jsx($N,{})});case"about":return i.jsx(it,{id:"changelog",children:i.jsx(xS,{})});default:return e.group}}function GN(e){const{group:t,route:r}=e,o=k.useRef(null),l=k.useRef(null);return k.useEffect(()=>{var d,h;(d=o.current)==null||d.focus({preventScroll:!0});const c=r.section&&document.getElementById(`settings-${r.section}`);c?c.scrollIntoView({block:"start"}):(h=l.current)==null||h.scrollTo({top:0})},[t.id,r.section]),i.jsx("div",{className:"sp-pane",ref:l,children:i.jsxs("div",{className:"sp-pane-in",children:[i.jsxs("header",{className:"sp-pane-head",children:[i.jsx("h2",{className:"sp-title t-title",ref:o,tabIndex:-1,children:t.label}),i.jsx("p",{className:"sp-intro t-meta",children:t.intro})]}),i.jsx(VN,{group:t.id,data:e.data,route:r})]})})}function qN(e){return i.jsx("nav",{className:"sp-nav","aria-label":"Settings groups",children:i.jsx("ul",{children:Ui.map(t=>{const r=t.id===e.current;return i.jsx(Ae,{as:"li",className:"sp-nav-row",selected:r,current:r?"page":void 0,title:t.label,context:i.jsx(q,{parts:t.sections.map(o=>o.title)}),trailing:e.drill&&"›",onOpen:()=>e.onPick(t.id)},t.id)})})})}function QN(e,t){return e.group?Ui.find(r=>r.id===e.group):t==="mobile"?void 0:Ui[0]}const YN={page:"Back to the Lookout",list:"Lookout",group:"Settings"},JN=(e,t)=>e?t?"group":"list":"page";function XN(e){const{bp:t,route:r}=e,o=t==="mobile",l=QN(r,t),c=JN(o,!!l),d=()=>c==="group"?e.onShow({}):e.onClose();k.useEffect(()=>{const m=v=>{v.key!=="Escape"||v.defaultPrevented||document.querySelector(".scrim")||(c==="group"?e.onShow({}):e.onClose())};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[c,e]);const h=m=>e.onShow({group:m}),g=c!=="group"&&i.jsx(qN,{current:l==null?void 0:l.id,onPick:h,drill:o});return i.jsxs(Ke,{className:`zone decisions-view settings-page sp-${t}`,"aria-label":"Settings",children:[i.jsxs("header",{className:"dv-head",children:[i.jsxs("button",{className:"back",onClick:d,children:["‹ ",YN[c]]}),c!=="group"&&i.jsx(Je,{as:"h2",children:"Settings"}),!o&&i.jsx("span",{className:"dv-head-right t-meta",children:"Esc"})]}),i.jsxs("div",{className:"sp-body",children:[g,l&&i.jsx(GN,{group:l,data:e.data,route:r})]})]})}function fo(e,t){const r=new URL(e);return r.searchParams.delete("settings"),t&&r.searchParams.set("settings",t.section??t.group??""),r.toString()}function ZN(e){var l;const{rt:t,api:r,settings:o}=e;return o.route?i.jsx(XN,{bp:e.bp,route:o.route,onShow:o.show,onClose:o.close,data:{prefs:e.prefs,update:e.update,activeTracker:t.kind,location:t.adapter.location,map:(l=r.snap)==null?void 0:l.map,onMapMode:r.actions.setMode,snaps:Object.values(r.allSnaps),answered:r.activity.answered,onModelMatching:r.actions.setModelMatching}}):null}function e1(e){return i.jsxs(Ke,{className:"zone side",style:{gridArea:"inspector"},children:[i.jsx(Dm,{className:"zone-tabs",value:e.tab,onChange:e.onTab,items:[{id:"ticket",label:"Ticket"},{id:"activity",label:"Activity"},{id:"plan",label:"Plan",n:e.unspecified}]}),{ticket:e.ticket,activity:e.activity,plan:e.plan}[e.tab]]})}function Np(e){return e.filter(t=>t.state!=="out-of-scope").map(t=>({x:t.x,y:t.y,w:Ue,h:Ge}))}function t1(e){const{obstacles:t,from:r,to:o,clear:l}=e,c=t.flatMap(h=>[h.y-28,h.y+h.h+28]).filter(l),d=h=>Math.abs(h-r)+Math.abs(h-o);return c.reduce((h,g)=>d(g)<d(h)?g:h,c[0]??r)}const n1=6;function s1(e){const t=e.filter((l,c)=>c===0||l.x!==e[c-1].x||l.y!==e[c-1].y);let r=`M${t[0].x} ${t[0].y}`;for(let l=1;l<t.length-1;l++){const[c,d,h]=[t[l-1],t[l],t[l+1]],g=Math.min(n1,Lf(c,d)/2,Lf(d,h)/2),m=Rf(d,c,g),v=Rf(d,h,g);r+=`L${m.x} ${m.y}Q${d.x} ${d.y} ${v.x} ${v.y}`}const o=t[t.length-1];return`${r}L${o.x} ${o.y}`}function Lf(e,t){return Math.abs(e.x-t.x)+Math.abs(e.y-t.y)}function Rf(e,t,r){return{x:e.x+Math.sign(t.x-e.x)*r,y:e.y+Math.sign(t.y-e.y)*r}}function bo(e){const t=e.direction==="TB",r=d=>t?{x:d.y,y:d.x}:d,o=r(e.a),l=r(e.b),c=e.obstacles.map(d=>t?{x:d.y,y:d.x,w:d.h,h:d.w}:d);return s1(i1({a:o,b:l,obstacles:c,gap:e.gap}).map(r))}function i1({a:e,b:t,obstacles:r,gap:o}){const l=r.filter(m=>m.x+m.w>e.x+1&&m.x<t.x-1),c=m=>!l.some(v=>m>v.y-8&&m<v.y+v.h+8),d=Math.min(e.x+o/2,(e.x+t.x)/2),h=Math.max(t.x-o/2,(e.x+t.x)/2);if(c(e.y))return[e,{x:h,y:e.y},{x:h,y:t.y},t];if(c(t.y))return[e,{x:d,y:e.y},{x:d,y:t.y},t];const g=t1({obstacles:l,from:e.y,to:t.y,clear:c});return[e,{x:d,y:e.y},{x:d,y:g},{x:h,y:g},{x:h,y:t.y},t]}function r1(e){if(e.direction==="LR"){const r=e.width+96;return{x:r,y:e.graphH/2,right:r+60,bottom:e.height}}const t=e.graphH+76;return{x:e.width/2,y:t,right:e.width,bottom:Math.max(e.height,t+70)}}function o1(e,t){const r=new Set(e.edges.map(c=>c.from)),o=e.nodes.filter(c=>c.state!=="out-of-scope"&&!r.has(c)),l=Np(e.nodes);return o.map(c=>{if(e.direction==="LR"){const g={x:c.x+Ue,y:c.y+Ge/2},m={x:t.x-44,y:t.y};return bo({direction:"LR",a:g,b:m,obstacles:l,gap:96})}const d={x:c.x+Ue/2,y:c.y+Ge},h={x:t.x,y:t.y-44};return bo({direction:"TB",a:d,b:h,obstacles:l,gap:48})})}function a1({x:e,y:t}){return i.jsxs("g",{className:"destination",transform:`translate(${e} ${t})`,"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 l1({trails:e}){return e.map(t=>i.jsx("path",{className:"edge edge-open edge-destination",d:t},t))}function c1(){return i.jsxs("defs",{children:[i.jsx("pattern",{id:"map-grid",width:"40",height:"40",patternUnits:"userSpaceOnUse",children:i.jsx("path",{d:"M40 0H0V40",fill:"none",stroke:"var(--map-grid)",strokeWidth:"1"})}),i.jsx("pattern",{id:"hatch-oos",width:"10",height:"10",patternUnits:"userSpaceOnUse",patternTransform:"rotate(45)",children:i.jsx("line",{x1:"0",y1:"0",x2:"0",y2:"10",stroke:"var(--line)",strokeWidth:"1"})})]})}const Co=(e,t)=>`${e}>${t}`;function u1(e,t,r=[]){const o=new Map(e.tickets.map(c=>[c.id,c]));return{tickets:t.nodes.map(c=>{const d=o.get(c.id);return d?{...d,blockedBy:[...c.blockedBy,...c.removedEdges??[]]}:{id:c.id,key:"+",title:c.title,type:c.type,body:"",state:"open",blockedBy:c.blockedBy,comments:[],createdAt:e.map.updatedAt,updatedAt:e.map.updatedAt}}),marks:new Map(t.nodes.map(c=>[c.id,c.mark])),newEdges:new Set(t.nodes.flatMap(c=>c.newEdges.map(d=>Co(d,c.id)))),removedEdges:new Set(t.nodes.flatMap(c=>(c.removedEdges??[]).map(d=>Co(d,c.id)))),frozen:new Set(r)}}function d1(e,t){const r=Dy({...e,tickets:t}),o=new Set;for(let l=1;l<r.length;l++)o.add(Co(r[l-1].id,r[l].id));return o}const Of={LR:130,TB:68};function h1(e){const{direction:t,from:r,to:o,cards:l}=e;if(t==="LR"){const h={x:r.x+Ue,y:r.y+Ge/2},g={x:o.x,y:o.y+Ge/2};return bo({direction:t,a:h,b:g,obstacles:l,gap:Of.LR})}const c={x:r.x+Ue/2,y:r.y+Ge},d={x:o.x+Ue/2,y:o.y};return bo({direction:t,a:c,b:d,obstacles:l,gap:Of.TB})}function f1(e){const{from:t,to:r,direction:o}=e,c=["edge",t.ticket.state!=="open"?"edge-done":"edge-open"];return e.critical&&c.push("edge-critical"),e.added&&c.push("edge-added"),e.removed&&c.push("edge-removed"),i.jsx("path",{className:c.join(" "),d:h1({direction:o,from:t,to:r,cards:e.cards})})}function m1(e){const{snap:t,tickets:r,direction:o,preview:l}=e,c=k.useMemo(()=>d1(t,r),[t,r]),d=k.useMemo(()=>Np(e.nodes),[e.nodes]);return e.edges.map(({from:h,to:g})=>{const m=Co(h.ticket.id,g.ticket.id);return i.jsx(f1,{from:h,to:g,direction:o,cards:d,critical:c.has(m),added:l==null?void 0:l.newEdges.has(m),removed:l==null?void 0:l.removedEdges.has(m)},m)})}const cc=24,Pf=31,p1=Ue-cc-10,g1=9;function v1(e){const t=e.parts.filter(Boolean).join(" · ").length,r=e.guide===void 0?void 0:ES(e.guide,Math.max(g1,Pf-t-3)),l=(r===void 0?t:t+3+r.length)>Pf?{textLength:p1,lengthAdjust:"spacingAndGlyphs"}:{};return{guideText:r,squeeze:l}}function y1(e,t,r){const o=e.state==="frontier"||e.state==="rework";if(!(!t||r||e.ticket.assignee||!o))return t}function k1(e){const t=["node",`st-${e.n.state}`,`tone-${e.tone}`,e.hitl?"hitl":"afk"];return e.selected&&t.push("sel"),e.live&&t.push("live"),e.waiting&&t.push("waiting"),e.stalled&&!e.waiting&&t.push("stalled"),e.mark&&t.push(`mark-${e.mark}`),e.frozen&&t.push("frozen"),t.join(" ")}function w1({wait:e,session:t}){return e?i.jsx("title",{children:`Needs a ${e} model: no connected agent runs one`}):t?i.jsx("title",{children:`${t.agent} · step ${t.step}/${t.total} · ${t.stepLabel.toLowerCase()}`}):null}const x1={claimed:"working",verifying:"working",frontier:"ready",blocked:"backlog",parked:"backlog",decided:"done","out-of-scope":"cancelled",rework:"attention",held:"attention"};function j1(e){const t=x1[e.state];return t==="done"||t==="cancelled"?t:e.attention?"attention":e.live?"working":t}function S1({mark:e,frozen:t}){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:Ge/2,x2:Ue-8,y2:Ge/2}),r&&i.jsx("text",{className:"reroute-tag",x:Ue-8,y:Ge-7,textAnchor:"end",children:r}),t&&i.jsx("text",{className:"freeze",x:Ue-(r?58:8),y:Ge-7,textAnchor:"end",children:"❄"})]})}function N1(e){const{n:t,session:r}=e,o=t.ticket.assignee;return e.waiting?{text:"waiting on you",tone:"urgent"}:e.stalled?{text:`stalled · ${o}`,tone:"warn"}:e.wait?{text:`needs ${e.wait}`,tone:"warn"}:r&&e.step?{text:`${r.agent} · step ${r.step}/${r.total}`,tone:"agent"}:r?{text:r.agent,tone:"agent"}:t.state==="claimed"?{text:o??"working",tone:"agent"}:{text:qw[t.state],tone:""}}function b1({tone:e,cy:t}){return e==="done"?i.jsx("path",{className:"dot dot-done",d:`M10 ${t}l2.5 2.5 4.5 -5`}):i.jsx("circle",{className:`dot dot-${e}`,cx:13,cy:t,r:e==="backlog"?3:3.5})}function C1(e,t,r=2){const o=e.split(/\s+/),l=[];let c="";for(const d of o)(c+" "+d).trim().length>t?(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,t-1)+"…",d}return l}const $1=26;function T1({n:e,session:t,stalled:r,flag:o,selected:l,onSelect:c,mark:d,frozen:h,needs:g}){const m=e.ticket,v=C1(m.title,$1),w=Hi(m)==="hitl",x=!!(t!=null&&t.waitingOn),j=!!d&&d!=="unchanged",T=y1(e,g,!!t),S=ZS(m.guide),E=j?void 0:N1({n:e,session:t,waiting:x,stalled:r,wait:T,step:!S}),M=w&&!j&&(m.type==="task"||m.type==="execute"),R=x||!!r||!!T||M&&e.state==="frontier",O=j1({state:e.state,live:!!t,attention:R}),X=Bi[m.type],se=v1({parts:[m.key,X,E==null?void 0:E.text,M&&"needs you"],guide:S==null?void 0:S.name}),_=v.length>1?19:24;return i.jsxs("g",{className:k1({n:e,tone:O,hitl:w,selected:l,live:!!t,waiting:x,stalled:r,mark:d,frozen:h}),style:{transform:`translate(${e.x}px, ${e.y}px)`},onClick:Q=>{Q.stopPropagation(),c({kind:"ticket",id:m.id})},children:[i.jsx(w1,{wait:T,session:t}),i.jsx("rect",{className:"ring",x:-3.5,y:-3.5,width:Ue+7,height:Ge+7,rx:9}),i.jsx("rect",{className:"card",x:.5,y:.5,width:Ue-1,height:Ge-1,rx:6}),i.jsx(b1,{tone:O,cy:_-4}),v.map((Q,oe)=>i.jsx("text",{className:"title",x:cc,y:_+oe*14,children:Q},oe)),i.jsxs("text",{className:"meta",x:cc,y:_+v.length*14+2,...se.squeeze,children:[i.jsx("tspan",{className:"key",children:m.key}),i.jsxs("tspan",{children:[" · ",X]}),i.jsx(MS,{guide:S,text:se.guideText}),E&&i.jsxs("tspan",{className:E.tone,children:[" · ",E.text]}),M&&i.jsx("tspan",{children:" · needs you"})]}),o&&i.jsx("circle",{className:`pr-flag-dot ${o}`,cx:Ue-2,cy:2,r:4}),i.jsx(S1,{mark:d,frozen:h})]})}const _f=.72;function E1(e){const{fit:t,nodes:r,size:o,pad:l}=e;if(t.k>=_f)return t;const c=r.find(h=>h.state==="claimed")??r.find(h=>h.state==="frontier")??r[0];if(!c)return t;const d=_f;return{k:d,x:o.w/2-(c.x+l+Ue/2)*d,y:o.h/2-(c.y+l+Ge/2)*d}}function I1({y:e,width:t,height:r}){return i.jsxs("g",{className:"quarantine",children:[i.jsx("rect",{x:-20,y:e-30,width:t+40,height:r+18,fill:"url(#hatch-oos)"}),i.jsx("text",{x:-12,y:e-14,children:"Out of scope"})]})}const tt=280,Df=4,M1=220,Ls=e=>Math.round(e/Df)*Df;function A1(e){let t=2166136261;for(const r of e)t=Math.imul(t^r.charCodeAt(0),16777619);return()=>{t=t+1831565813|0;let r=Math.imul(t^t>>>15,1|t);return r=r+Math.imul(r^r>>>7,61|r)^r,((r^r>>>14)>>>0)/4294967296}}function Vl(e,t,r,o){return Array.from({length:6},()=>{const l=o*(.5+e()*.7),c=o*(.3+e()*.4);return{x:Ls(t+(e()-.5)*o*.8-l/2),y:Ls(r+(e()-.5)*o*.5-c/2),w:Ls(l),h:Ls(c)}})}function L1(e){const{width:t,height:r,nodes:o}=e,l=A1(e.seed),c=(x,j)=>x+l()*(j-x),d=(x,j)=>!o.some(T=>x>T.x-52&&x<T.x+Ue+28&&j>T.y-52&&j<T.y+Ge+28),h=(t+tt*2)*(r+tt*2),g=Array.from({length:Math.round(h/9e4)},()=>Vl(l,c(-tt,t+tt),c(-tt,r+tt),c(160,360))).flat(),m=[...Vl(l,t+tt*.55,r+tt*.55,300),...Vl(l,-tt*.5,-tt*.45,220)],v=[],w=(x,j,T)=>{v.length<M1&&d(j,T)&&v.push({sprite:x,x:Ls(j),y:Ls(T)})};for(let x=0;x<Math.round(h/3e4);x++){const j=c(-tt,t+tt),T=c(-tt,r+tt),S=3+Math.floor(l()*5);for(let E=0;E<S;E++)w(l()<.65?"pine":"oak",j+c(-70,70),T+c(-44,44))}for(let x=0;x<Math.round(h/45e3);x++)w(l()<.4?"rock":"tuft",c(-tt,t+tt),c(-tt,r+tt));return v.sort((x,j)=>x.y-j.y),{grass:g,water:m,items:v}}const bp={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 R1({name:e}){return i.jsx("symbol",{id:`terrain-${e}`,overflow:"visible",children:bp[e]})}const O1=Object.keys(bp),P1=k.memo(function(t){const{seed:r,width:o,height:l,nodes:c}=t,d=k.useMemo(()=>L1({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(R1,{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))]})}),_1=380;function D1(e){const{selId:t,size:r}=e,o=k.useRef(e);o.current=e;const l=k.useRef(!0);k.useEffect(()=>{if(l.current){l.current=!1;return}const{nodes:c,pad:d,view:h,setView:g,onFocus:m}=o.current,v=t?c.find(M=>M.ticket.id===t):void 0;if(!v||!r.w)return;m();const w=Math.min(1.4,Math.max(h.k,1.05)),x={k:w,x:r.w/2-(d+v.x+Ue/2)*w,y:r.h/2-(d+v.y+Ge/2)*w};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return g(x);const j=h,T=performance.now();let S=0;const E=M=>{const R=Math.min(1,(M-T)/_1),O=1-(1-R)**3;g({k:j.k+(x.k-j.k)*O,x:j.x+(x.x-j.x)*O,y:j.y+(x.y-j.y)*O}),R<1&&(S=requestAnimationFrame(E))};return S=requestAnimationFrame(E),()=>cancelAnimationFrame(S)},[t])}function B1(e,t){const r=k.useRef(t);r.current=t,k.useEffect(()=>{const o=e.current;if(!o)return;const l=m=>{const v=o.getBoundingClientRect();return{x:m.clientX-v.left,y:m.clientY-v.top}},c=m=>{m.preventDefault();const v=m.ctrlKey?.01:.0015;r.current(Math.exp(-m.deltaY*v),l(m))};let d=1;const h=m=>{m.preventDefault(),d=1},g=m=>{m.preventDefault();const v=m;r.current(v.scale/d,l(v)),d=v.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 Bf(e,t,r){const o=Math.min(3,Math.max(.2,t));return{k:o,x:r.x-(r.x-e.x)*o/e.k,y:r.y-(r.y-e.y)*o/e.k}}const Yt=32,z1=1.8;function F1(e){var te;const{snap:t,selection:r,onSelect:o,preview:l}=e,c=(l==null?void 0:l.tickets)??t.tickets,d=k.useRef(null),[h,g]=k.useState({w:0,h:0});k.useEffect(()=>{const P=d.current;if(!P)return;const Y=new ResizeObserver(([ae])=>g({w:ae.contentRect.width,h:ae.contentRect.height}));return Y.observe(P),()=>Y.disconnect()},[]);const m=k.useMemo(()=>{const P=Bh(c,"LR",t.map.mode),Y=Bh(c,"TB",t.map.mode),ae=Z=>Math.min(h.w/(Z.width+Yt*2),h.h/(Z.height+Yt*2+16));return ae(P)*z1>=ae(Y)?P:Y},[c,t.map.mode,h.w,h.h]),v=(P,Y)=>Math.min(1.25,Math.max(e.minFit??0,Math.min(h.w/P,h.h/Y))),w=k.useMemo(()=>{const P=m.width+Yt*2,Y=m.height+Yt*2+16,Z=m.nodes.some(B=>B.state==="out-of-scope")&&h.h?Math.max(0,h.h/v(P,Y)-Y):0;if(!Z)return{...m,slack:Z};const U=new Map(m.nodes.map(B=>[B,{...B,y:B.y+(B.state==="out-of-scope"?Z:Z/2)}]));return{...m,slack:Z,nodes:[...U.values()],edges:m.edges.map(B=>({from:U.get(B.from),to:U.get(B.to)})),quarantineY:m.quarantineY+Z,height:m.height+Z}},[m,h.w,h.h,e.minFit]),x=r1(w),j=x.right+Yt*2,T=x.bottom+Yt*2+16,S=()=>{const P=v(j,T);return{k:P,x:Math.max(0,(h.w-j*P)/2),y:Math.max(0,(h.h-T*P)/2)}},[E,M]=k.useState({k:1,x:0,y:0}),R=k.useRef(!1);k.useEffect(()=>{R.current=!1},[t.map.id]),k.useEffect(()=>{!R.current&&h.w&&M(E1({fit:S(),nodes:w.nodes,size:h,pad:Yt}))},[h.w,h.h,j,T,t.map.id]);const O=k.useRef(new Map),X=k.useRef(null),se=P=>{const Y=d.current.getBoundingClientRect();return{x:P.clientX-Y.left,y:P.clientY-Y.top}},_=()=>{var Z;const P=[...O.current.values()],Y=P.length>1?{x:(P[0].x+P[1].x)/2,y:(P[0].y+P[1].y)/2}:P[0],ae=P.length>1?Math.hypot(P[0].x-P[1].x,P[0].y-P[1].y):0;X.current={view:E,dist:ae,mid:Y,moved:((Z=X.current)==null?void 0:Z.moved)??!1}};B1(d,(P,Y)=>{R.current=!0,M(ae=>Bf(ae,ae.k*P,Y))});const Q=sn(5e3),oe=wc(e.leases,t.map.id),G=Cc(),ge=(te=Oc())==null?void 0:te.waiting,Re=new Map(e.sessions.filter(P=>tn(P)&&P.ticketId).map(P=>[P.ticketId,P])),be=(r==null?void 0:r.kind)==="ticket"?r.id:void 0;return D1({selId:be,nodes:w.nodes,size:h,pad:Yt,view:E,setView:M,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&&(X.current=null),_()},onPointerMove:P=>{var Z;if(!O.current.has(P.pointerId)||!X.current)return;O.current.set(P.pointerId,se(P));const Y=X.current,ae=[...O.current.values()];if(ae.length>1){const U={x:(ae[0].x+ae[1].x)/2,y:(ae[0].y+ae[1].y)/2},B=Math.hypot(ae[0].x-ae[1].x,ae[0].y-ae[1].y),H=Bf(Y.view,Y.view.k*B/(Y.dist||B),Y.mid);M({...H,x:H.x+U.x-Y.mid.x,y:H.y+U.y-Y.mid.y}),Y.moved=!0}else{const U=ae[0].x-Y.mid.x,B=ae[0].y-Y.mid.y;if(!Y.moved&&Math.hypot(U,B)<5)return;Y.moved||(Z=d.current)==null||Z.setPointerCapture(P.pointerId),Y.moved=!0,M({...Y.view,x:Y.view.x+U,y:Y.view.y+B})}R.current=!0},onPointerUp:P=>{O.current.delete(P.pointerId),O.current.size&&_()},onPointerCancel:P=>O.current.delete(P.pointerId),onClickCapture:P=>{var Y;(Y=X.current)!=null&&Y.moved&&(P.stopPropagation(),X.current=null)},children:[i.jsxs("svg",{className:"graph",width:h.w,height:h.h,onClick:()=>o(null),children:[i.jsx(c1,{}),i.jsx("g",{transform:`translate(${E.x} ${E.y}) scale(${E.k})`,children:i.jsxs("g",{transform:`translate(${Yt} ${Yt})`,children:[i.jsx(P1,{seed:t.map.id,width:j,height:T,nodes:w.nodes}),w.nodes.some(P=>P.state==="out-of-scope")&&i.jsx(I1,{y:w.quarantineY,width:w.width,height:w.quarantineH}),i.jsx(m1,{snap:t,tickets:c,direction:w.direction,nodes:w.nodes,edges:w.edges,preview:l}),i.jsx(l1,{trails:o1(w,x)}),w.nodes.length>0&&i.jsx(a1,{x:x.x,y:x.y}),w.nodes.map(P=>{var Y;return i.jsx(T1,{n:P,session:Re.get(P.ticket.id),stalled:!!oe.get(P.ticket.id)&&Oo(oe.get(P.ticket.id),Q)!=="live",flag:Qw(Bs.ticket(G,t.map.id,P.ticket.id)),selected:be===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:(Y=ge==null?void 0:ge.find(ae=>ae.mapId===t.map.id&&ae.ticketId===P.ticket.id))==null?void 0:Y.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,M(S())},children:"Fit"})]})}const Gl=[["decided","Done"],["claimed","Working"],["frontier","Ready"],["blocked","Backlog"],["parked","Parked"],["out-of-scope","Cancelled"]],zf=[["verifying","Verifying"],["rework","Rework"],["held","Blocked"]];function U1({snap:e,sessions:t}){const r=lm(e),o=m=>r[m],l=t.filter(Om).length,c=By(e),d=Math.max(1,...c.map(m=>m.open+m.closed)),g=(e.map.verification??"off")!=="off"||zf.some(([m])=>o(m))?[...Gl.slice(0,2),...zf,...Gl.slice(2)]:Gl;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(Je,{as:"h3",children:"Status"}),i.jsxs("span",{className:"t-meta",children:[r.total," tickets"]})]}),i.jsxs("ul",{children:[g.map(([m,v])=>i.jsxs("li",{className:`st-${m} ${o(m)?"":"zero"}`,children:[i.jsx("i",{}),i.jsx("span",{children:v}),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:Bi[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 H1(e){const[t,r]=k.useState(!1);return i.jsxs("div",{className:t?"status-drawer open":"status-drawer",children:[i.jsxs("button",{type:"button",className:"status-toggle","aria-expanded":t,onPointerDown:o=>o.stopPropagation(),onClick:()=>r(!t),children:["Summary ",i.jsx("span",{className:"caret",children:t?"▾":"▴"})]}),i.jsx(U1,{snap:e.snap,sessions:e.sessions})]})}function W1({planOnly:e,verifies:t}){const r=[["frontier","Ready"],["claimed","Working"],...t?[["verifying","Verifying"],["rework","Rework"],["held","Blocked"]]:[],["stalled","Stalled"],["blocked","Backlog"],["decided","Done"],...e?[["parked","Parked"]]:[],["out-of-scope","Cancelled"],["waiting","Waiting on you"]];return i.jsxs("div",{className:"legend",children:[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 K1(e){var o,l;const{snap:t,selection:r}=e.api;return i.jsxs(Ke,{as:"main",className:"zone map-zone",style:{gridArea:"map"},children:[t&&i.jsx(f0,{}),(o=e.trail)==null?void 0:o.banner,i.jsxs("div",{className:"map-area",children:[t&&!e.compact&&i.jsx(H1,{snap:t,sessions:e.sessions}),t?i.jsx(F1,{snap:t,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(v0,{}),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(xo,{command:'/scout new "your idea"'})]}),t&&e.compact&&i.jsx(W1,{planOnly:t.map.mode==="plan-only",verifies:(t.map.verification??"off")!=="off"})]})]})}const V1=[["home","Inbox"],["map","Map"],["ticket","Ticket"],["activity","Activity"],["plan","Plan"]];function G1(e){const{tab:t,covered:r,pending:o}=e;return i.jsx("nav",{className:"tabbar",children:V1.map(([l,c])=>i.jsxs("button",{className:t===l&&!r?"on":"",onClick:()=>e.onPick(l),children:[c,l==="home"&&o>0&&i.jsx(ts,{n:o,urgent:!0,pop:!0},o)]},l))})}function q1(e){const t={home:e.projects?i.jsxs("div",{className:"phone-home",children:[e.projects,e.inbox]}):e.inbox,map:e.map,ticket:i.jsx(Ke,{className:"zone",children:e.ticket}),activity:i.jsx(Ke,{className:"zone",children:e.activity}),plan:e.plan};return i.jsx("main",{className:"phone-view",children:e.decisions||t[e.tab]})}const Ff={settingsPage:!0},Uf=()=>lp(new URLSearchParams(location.search).get("settings")),Hf=()=>{var e;return!!((e=history.state)!=null&&e.settingsPage)};function Q1(){const[e,t]=k.useState(Uf);k.useEffect(()=>{e&&!Hf()&&(history.replaceState(null,"",fo(location.href,null)),history.pushState(Ff,"",fo(location.href,e)));const c=()=>t(Uf());return window.addEventListener("popstate",c),()=>window.removeEventListener("popstate",c)},[]);const r=c=>{const d=fo(location.href,c);e?history.replaceState(history.state,"",d):history.pushState(Ff,"",d),t(c)},o=()=>{e&&(t(null),Hf()?history.back():history.replaceState(null,"",fo(location.href,null)))},l=c=>r(lp(c??"")??{});return{route:e,open:l,show:r,close:o,toggle:()=>e?o():l()}}function Y1(e,t){const{activity:r,selection:o,setSelection:l,actions:c}=e,[d,h]=k.useState("ticket"),[g,m]=k.useState("home"),[v,w]=k.useState(0),[x,j]=k.useState(null),[T,S]=k.useState(!1),E=_=>{S(!1),j({focus:_})},M=()=>{j(null),S(_=>!_)};k.useEffect(()=>{const _=r.sessions.find(Q=>Q.id===e.chatSession);!o&&(_!=null&&_.ticketId)&&_.mapId===e.mapId&&l({kind:"ticket",id:_.ticketId})},[e.chatSession,e.mapId]);const R=_=>{l(_),_&&(t==="laptop"&&h("ticket"),t==="mobile"&&m("ticket"))},O=(_,Q,oe)=>{oe&&oe!==e.mapId&&c.selectMap(oe),c.openChat(_);const G=r.sessions.find(ge=>ge.id===_);Q&&(G==null?void 0:G.mapId)===(oe??e.mapId)&&l({kind:"ticket",id:Q}),t==="mobile"&&(m("home"),w(ge=>ge+1))};return{sideTab:d,setSideTab:h,phoneTab:g,setPhoneTab:m,convRequest:v,decisionsView:x,setDecisionsView:j,openDecisions:E,statsOpen:T,setStatsOpen:S,toggleStats:M,select:R,openChat:O,showChat:(_,Q,oe)=>{O(_,Q,oe),w(G=>G+1)},openTicket:(_,Q)=>{_!==e.mapId&&c.selectMap(_),l({kind:"ticket",id:Q}),j(null),t==="laptop"&&h("ticket"),t==="mobile"&&m("ticket")}}}function J1(e,t){k.useEffect(()=>{document.title=`${ve.name}: ${e?`(${e}) `:""}${t??"No trail"}`},[e,t])}function X1(e){const[t,r]=k.useState("…");return k.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]),t}function Z1(e,t){return k.useMemo(()=>{const r=e.sessions.filter(l=>l.mapId===t),o=new Set(e.sessions.filter(l=>l.mapId!==t).map(l=>l.id));return{...e,sessions:r,feed:e.feed.filter(l=>!l.sessionId||!o.has(l.sessionId))}},[e,t])}function eb({text:e}){return e.trim()?i.jsx("div",{className:"brief-prose",children:e.split(`
|
|
139
|
+
`).map((t,r)=>i.jsx("p",{children:t.split(/(`[^`]+`|\/?\b[\w.-]+\/[\w./-]+\b)/g).map((o,l)=>l%2===1?i.jsx("code",{children:o.replace(/`/g,"")},l):o)},r))}):i.jsx(Ee,{children:"Not covered"})}const Wf=["summary","productContext","existing","conventions","dataModel","api","risks"];function tb(e){const{brief:t}=e,[r,o]=k.useState(!1),[l,c]=k.useState("");k.useEffect(()=>{const m=v=>v.key==="Escape"&&e.onClose();return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[e]);const d=t.sections,h=Wf.filter(m=>d[m].trim()),g=Wf.filter(m=>!d[m].trim());return i.jsx("div",{className:"scrim",onClick:e.onClose,children:i.jsxs(Ke,{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:nb(t)})]}),i.jsxs("div",{className:"brief-body",children:[h.map(m=>i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:Li[m]}),i.jsx(eb,{text:d[m]}),(m==="conventions"||m==="productContext")&&d[m].trim()&&i.jsx($c,{draft:()=>({title:`${Li[m]}: ${d[m].split(`
|
|
140
|
+
`)[0].slice(0,80)}`,body:d[m],kind:m==="conventions"?"convention":"business-rule",sources:[`brief:${t.mapId}`]})})]},m)),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:Li.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(q,{parts:[{text:m.id,code:!0}]})]},m.id))}):i.jsx(Ee,{children:"None listed"})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:Li.openQuestions}),d.openQuestions.length?i.jsx("ul",{className:"brief-list",children:d.openQuestions.map(m=>i.jsx("li",{children:m},m))}):i.jsx(Ee,{children:"None"})]}),g.length>0&&i.jsxs("p",{className:"t-meta brief-empty",children:["Nothing noted on ",g.map(m=>Li[m].toLowerCase()).join(", "),"."]}),t.note&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Your last request"}),i.jsx("p",{children:t.note})]})]}),r&&i.jsx(Ye,{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:[t.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 nb(e){if(e.status==="draft")return"Not submitted yet";const t=[e.status.replace("-"," ")];return e.author&&t.push(`by ${e.author}`),e.submittedAt&&t.push(`${nn(Date.now()-e.submittedAt)} ago`),t.join(" · ")}function sb({brief:e,onReview:t}){return e.status!=="submitted"?null:i.jsx("div",{className:"brief-card",children:i.jsx(Ae,{edge:"attention",title:"Discovery brief ready for your review",context:i.jsx(q,{parts:["Discovery brief",e.author&&`by ${e.author}`]}),detail:e.sections.summary.split(`
|
|
141
|
+
`)[0],detailText:e.sections.summary,onOpen:t})})}const ib={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 rb({brief:e,onReview:t}){if(e.status==="accepted")return null;const[r,o]=ib[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(Us,{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:t,children:e.status==="submitted"?"Review brief":"Open brief"})]})}const Kf=`${Ne()}/briefs`;function ob(e){const t=e==null?void 0:e.map.id,[r,o]=k.useState(null),[l,c]=k.useState(),d=k.useCallback(()=>{if(!t)return o(null);fetch(`${Kf}?mapId=${encodeURIComponent(t)}`).then(v=>v.ok?v.json():{brief:null}).then(v=>o(v.brief)).catch(()=>o(null))},[t]),h=e==null?void 0:e.tickets.reduce((v,w)=>Math.max(v,w.updatedAt),e.map.updatedAt);k.useEffect(d,[d,h]),k.useEffect(()=>pn(v=>v.startsWith("briefs/")&&d()),[d]);const g=(v,w)=>fetch(`${Kf}/${v}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,note:w})}).then(async x=>{const j=await x.json().catch(()=>({}));if(!x.ok||!j.brief)throw new Error(j.error??`HTTP ${x.status}`);c(void 0),o(j.brief)}),m=(v,w)=>g(v,w).then(()=>!0,x=>(c(x.message),!1));return{brief:r,error:l,accept:()=>m("accept"),requestChanges:v=>m("request-changes",v)}}function ab(e){const t=ob(e),[r,o]=k.useState(!1),l=()=>o(!0),c=t.brief,d=c==null?void 0:c.sections;return{review:l,briefText:d?[d.existing,d.conventions,d.dataModel,d.api].join(`
|
|
142
|
+
`):"",banner:c&&i.jsx(rb,{brief:c,onReview:l}),inboxCard:c&&i.jsx(sb,{brief:c,onReview:l}),dialog:c&&r&&i.jsx(tb,{brief:c,error:t.error,onAccept:()=>void t.accept().then(h=>h&&o(!1)),onRequestChanges:h=>void t.requestChanges(h).then(g=>g&&o(!1)),onClose:()=>o(!1)})}}function lb({reroute:e,onReview:t}){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(Us,{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:t,children:"Review"})]})}const cb={"already-exists":"The work already exists","wrong-problem":"The trail targets the wrong problem",rescope:"The trail should be rescoped"};function ub(e,t){var r;switch(e.op){case"add_ticket":{const o=(r=e.blockedBy)!=null&&r.length?`after ${e.blockedBy.map(t).join(", ")}`:void 0;return{verb:"Add",text:e.title,detail:[`new ${e.type} ticket`,o].filter(Boolean).join(" · ")}}case"cancel_ticket":return{verb:"Cancel",text:t(e.ticket),detail:e.reason};case"edit_ticket":return{verb:"Revise",text:t(e.ticket),detail:e.title?`New title: ${e.title}`:"New description"};case"rewire":return{verb:"Rewire",text:t(e.ticket),detail:db(e,t)};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:t(e.ticket),detail:`Back in the queue: ${e.reason}`};default:return e}}function db(e,t){var o,l;return[...(o=e.addBlockedBy)!=null&&o.length?[`now also after ${e.addBlockedBy.map(t).join(", ")}`]:[],...(l=e.removeBlockedBy)!=null&&l.length?[`no longer after ${e.removeBlockedBy.map(t).join(", ")}`]:[]].join(" · ")}const hb=new Set(["cancel_ticket","update_destination"]);function fb({change:e,name:t}){const r=ub(e,t);return i.jsx(Ae,{as:"li",className:`reroute-change op-${e.op}`,edge:hb.has(e.op)?"attention":"neutral",title:r.text,titleText:r.text,context:i.jsx(q,{parts:[{text:r.verb,strong:!0}]}),detail:r.detail,detailText:r.detail})}function mb(e){const{reason:t,destination:r}=e;return i.jsxs("section",{className:"reroute-destination",children:[t&&i.jsx("p",{className:"reroute-destination-why",children:cb[t]}),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 pb(e,t){const r=new Map(e.tickets.map(l=>[l.id,l.key])),o=new Map(t.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 gb(e){var x,j;const{reroute:t,snap:r}=e,[o,l]=k.useState("");k.useEffect(()=>{const T=S=>S.key==="Escape"&&e.onClose();return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[e]);const c=pb(r,t.changes),d=new Map(r.tickets.map(T=>[T.id,`${T.key} ${T.title}`])),h=T=>d.get(T)??c(T),g=r.map.sections.assumptions??[],m=t.invalidates.map(T=>g.find(S=>S.id===T)??{id:T,text:""}),v=t.status==="pending",w=t.kind==="challenge-destination";return i.jsx("div",{className:"scrim",onClick:e.onClose,children:i.jsxs(Ke,{as:"div",className:"dialog reroute-dialog",onClick:T=>T.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:w?"Destination challenged":"Reroute proposal"}),i.jsx(q,{parts:[{text:t.id,code:!0},t.status,`by ${t.by}`,`${nn(Date.now()-t.at)} ago`]})]}),i.jsxs("div",{className:"reroute-body",children:[w&&i.jsx(mb,{reason:t.destinationReason,destination:(x=t.diff)==null?void 0:x.destination}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Why"}),i.jsx("p",{children:t.reason})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Evidence"}),i.jsx("p",{className:"reroute-evidence",children:t.evidence})]}),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(T=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:T.text}),i.jsx(q,{parts:[{text:T.id,code:!0}]})]},T.id))})]}),i.jsxs("section",{children:[i.jsxs("h3",{className:"mono-label",children:["Changes · ",t.changes.length]}),i.jsx("ul",{className:"reroute-changes row-list",children:t.changes.map((T,S)=>i.jsx(fb,{change:T,name:h},S))})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Closed until you decide"}),(j=t.frozen)!=null&&j.length?i.jsx("ul",{className:"item-list",children:t.frozen.map(T=>i.jsx("li",{className:"item-text",children:h(T)},T))}):i.jsx(Ee,{children:"No tickets closed"})]}),t.note&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Your note"}),i.jsx("p",{children:t.note})]})]}),v&&i.jsx(Ye,{label:"Note for the agent (required to reject)",children:i.jsx("textarea",{rows:2,value:o,onChange:T=>l(T.target.value)})}),e.error&&i.jsx("p",{className:"urgent-text",children:e.error}),i.jsxs("div",{className:"actions",children:[v&&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 Vf=`${Ne()}/reroutes`;function vb(e){const t=e==null?void 0:e.map.id,[r,o]=k.useState([]),[l,c]=k.useState(),d=k.useCallback(()=>{if(!t)return o([]);fetch(`${Vf}?map=${encodeURIComponent(t)}`).then(m=>m.ok?m.json():{reroutes:[]}).then(m=>o(m.reroutes)).catch(()=>o([]))},[t]),h=e==null?void 0:e.tickets.reduce((m,v)=>Math.max(m,v.updatedAt),e.map.updatedAt);k.useEffect(d,[d,h]),k.useEffect(()=>Xw("reroute",m=>{m.mapId===t&&d()}),[d,t]);const g=async(m,v,w)=>{var S;const x=await fetch(`${Vf}/${m}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,id:v,note:w})}),j=await x.json().catch(()=>({}));if(x.ok)return c(void 0),d(),!0;const T=(S=j.errors)==null?void 0:S.map(E=>E.message).join("; ");return c([j.error??`HTTP ${x.status}`,T].filter(Boolean).join(": ")),!1};return{reroutes:r,pending:r.find(m=>m.status==="pending"),error:l,clearError:()=>c(void 0),approve:(m,v)=>g("approve",m,v),reject:(m,v)=>g("reject",m,v)}}function yb(e,t){const r=vb(e),[o,l]=k.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(lb,{reroute:r.pending,onReview:()=>{var m;return l((m=r.pending)==null?void 0:m.id)}}),preview:e&&(d!=null&&d.diff)?u1(e,d.diff,d.frozen):void 0,openReroute:(m,v)=>{m!==(e==null?void 0:e.map.id)&&(t==null||t(m)),l(v)},dialog:e&&c&&i.jsx(gb,{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 kb(e,t){const r=ab(e),o=yb(e,t);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 wb(){const e=new URL(location.href);e.searchParams.has(Ps)&&(e.searchParams.delete(Ps),history.replaceState(history.state,"",e))}function xb(e,t){return e.kind!=="question"||t.pending.some(r=>r.id===e.ref)}function jb(e){const[t,r]=k.useState(()=>new URLSearchParams(location.search).get(Ps)??void 0),{loaded:o,view:l,activity:c,handlers:d,showChat:h}=e;return k.useEffect(()=>{if(!t||!o||!l)return;const g=l.items.find(v=>v.id===t);if(g&&!xb(g,c)||(r(void 0),wb(),!g))return;Qm(g,{...d,openQuestion:v=>{const w=c.pending.find(x=>x.id===v);w&&h(w.sessionId,w.ticketId)}})},[t,o,l,c,d,h]),{request:k.useCallback(g=>r(g),[])}}function Sb(e){const{api:t,nav:r}=e,o=Jm(t.allSnaps);Zj(o.view);const l=m=>m&&t.actions.selectMap(m),c={openTicket:r.openTicket,openKnowledge:()=>e.knowledge.setOpen(!0),openBrief:m=>m===t.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=jb({loaded:t.loaded,view:d,activity:t.activity,handlers:c,showChat:r.showChat}),g=d&&i.jsx(Qj,{view:d,onFocus:m=>void o.savePrefs(Dk(d.prefs,m,Date.now())),onSettings:e.openFocusSettings});return{attention:o,handlers:c,header:g,link:h}}function Nb(e){const{d:t,snap:r}=e,[o,l]=k.useState(!1),[c,d]=k.useState(""),[h,g]=k.useState("");k.useEffect(()=>{l(!1),d(""),g("")},[t.id,t.mapId]);const m=xy(e.all.filter(j=>j.mapId===t.mapId),t.id),v=Wi(t),w=t.ticketId?r==null?void 0:r.tickets.find(j=>j.id===t.ticketId):void 0,x=Date.now();return i.jsxs("div",{className:"detail dv-d",children:[i.jsxs("div",{className:"d-head",children:[i.jsx("span",{className:"key",children:t.id}),i.jsx(zn,{tone:"state",className:`dv-st-${v}`,children:v}),i.jsx(q,{parts:[Gw(t.decidedAt),`${nn(x-t.decidedAt)} ago`]})]}),i.jsx("h3",{className:"t-heading",children:t.question}),i.jsxs("div",{className:"resolution",children:[i.jsx(wo,{parts:["Decision"]}),i.jsx("p",{children:t.answer})]}),i.jsxs("dl",{className:"facts",children:[i.jsx("dt",{children:"Trail"}),i.jsx("dd",{children:r?`${r.map.key} ${r.map.title}`:t.mapId}),i.jsx("dt",{children:"Ticket"}),i.jsx("dd",{children:t.ticketId?i.jsxs("button",{className:"link",onClick:()=>e.onOpenTicket(t.mapId,t.ticketId),children:[t.ticketKey," ",(w==null?void 0:w.title)??""," · open in trail ›"]}):"—"}),i.jsx("dt",{children:"Decided by"}),i.jsx("dd",{children:t.decidedBy}),t.participants.length>1&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Participants"}),i.jsx("dd",{children:t.participants.map(j=>j.name??j.id).join(", ")})]}),i.jsx("dt",{children:"Source"}),i.jsxs("dd",{children:[_n[t.source.kind].label,t.source.url&&i.jsxs(i.Fragment,{children:[" · ",i.jsx("a",{href:t.source.url,target:"_blank",rel:"noreferrer",children:t.source.label??"link"})]}),!t.source.url&&t.source.label&&` · ${t.source.label}`,t.source.ref&&i.jsxs("span",{className:"ref",children:[" ",t.source.ref]})]})]}),t.alternatives.length>0&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Alternatives"}),i.jsx("ul",{className:"dv-alts",children:t.alternatives.map(j=>i.jsx("li",{children:j},j))})]}),t.rationale&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Rationale"}),i.jsx("p",{children:t.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(j=>i.jsx("li",{className:`${j.id===t.id?"cur":""} ${j.supersededBy?"old":"live"}`,children:i.jsxs("button",{onClick:()=>e.onSelect(j.id),children:[i.jsx("i",{}),i.jsx("span",{className:"id",children:j.id}),i.jsx("span",{className:"a",children:j.summary}),i.jsx(q,{parts:[j.decidedBy,Ds(j.decidedAt)]})]})},j.id))})]}),i.jsxs("div",{className:"actions",children:[i.jsx($c,{draft:()=>({title:t.summary||t.question,body:[t.answer,t.rationale&&`Why: ${t.rationale}`].filter(Boolean).join(`
|
|
143
|
+
|
|
144
|
+
`),kind:"product-decision",sources:[`decision:${t.id}`,...t.ticketKey?[`ticket:${t.ticketKey}`]:[]]})}),v==="active"&&i.jsx(K,{on:o,onClick:()=>l(j=>!j),"data-tip":"Replace this decision with a new answer. Both stay on record",children:"Supersede…"})]}),o&&i.jsxs(Ot,{as:"form",tone:"inset",className:"inline-form",onSubmit:j=>{j.preventDefault(),c.trim()&&(e.onSupersede(t,{answer:c.trim(),rationale:h.trim(),alternatives:[t.summary]}),l(!1))},children:[i.jsx(Ye,{label:"New decision",children:i.jsx("textarea",{rows:3,value:c,onChange:j=>d(j.target.value),autoFocus:!0})}),i.jsx(Ye,{label:"Rationale",children:i.jsx("input",{value:h,onChange:j=>g(j.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:t.transcript.length})]}),t.transcript.length?i.jsx("div",{className:"dv-transcript comms-log",children:t.transcript.map((j,T)=>i.jsxs("div",{className:`msg from-${j.from} voice-${j.from==="human"?"human":"agent"}`,children:[i.jsx(wo,{parts:[j.author,kc(j.at)]}),i.jsx("div",{className:"msg-text",children:j.text})]},T))}):i.jsx(Ee,{children:"None recorded"})]})]})}function Lt(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 bb(e){const{filter:t,set:r,all:o}=e,l=c=>o.filter(c).length;return e.compact?i.jsxs("div",{className:"dv-filters compact",children:[i.jsx(ft,{compact:!0,"aria-label":"Trail",value:t.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(ft,{compact:!0,"aria-label":"Source",value:t.source??"",onChange:c=>r({source:c||void 0}),options:[{value:"",label:"All sources"},...vo.map(c=>({value:c,label:_n[c].label}))]}),i.jsx(ft,{compact:!0,"aria-label":"Decided by",value:t.decidedBy??"",onChange:c=>r({decidedBy:c||void 0}),options:[{value:"",label:"Anyone"},...e.people.map(c=>({value:c,label:c}))]}),i.jsx(ft,{compact:!0,"aria-label":"Status",value:t.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(Lt,{on:!t.mapId,label:"All trails",n:o.length,onClick:()=>r({mapId:void 0})}),e.trails.map(c=>i.jsx(Lt,{on:t.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(Lt,{on:!t.source,label:"All",n:o.length,onClick:()=>r({source:void 0})}),vo.map(c=>i.jsx(Lt,{cls:`src-${c}`,on:t.source===c,label:_n[c].label,n:l(d=>d.source.kind===c),onClick:()=>r({source:t.source===c?void 0:c})},c))]}),i.jsx("h3",{className:"mono-label",children:"Made by"}),i.jsxs("ul",{children:[i.jsx(Lt,{on:!t.madeBy,label:"Anyone",n:o.length,onClick:()=>r({madeBy:void 0})}),i.jsx(Lt,{on:t.madeBy==="agent",label:"Agents, on their own",n:l(c=>Di(c)==="agent"),onClick:()=>r({madeBy:t.madeBy==="agent"?void 0:"agent"})}),i.jsx(Lt,{on:t.madeBy==="human",label:"People",n:l(c=>Di(c)==="human"),onClick:()=>r({madeBy:t.madeBy==="human"?void 0:"human"})})]}),i.jsx("h3",{className:"mono-label",children:"Decided by"}),i.jsxs("ul",{children:[i.jsx(Lt,{on:!t.decidedBy,label:"Anyone",n:o.length,onClick:()=>r({decidedBy:void 0})}),e.people.map(c=>i.jsx(Lt,{on:t.decidedBy===c,label:c,n:l(d=>d.decidedBy===c),onClick:()=>r({decidedBy:t.decidedBy===c?void 0:c})},c))]}),i.jsx("h3",{className:"mono-label",children:"Status"}),i.jsxs("ul",{children:[i.jsx(Lt,{on:!t.status,label:"Any",n:o.length,onClick:()=>r({status:void 0})}),i.jsx(Lt,{on:t.status==="active",label:"Active",n:l(c=>!c.supersededBy),onClick:()=>r({status:t.status==="active"?void 0:"active"})}),i.jsx(Lt,{on:t.status==="superseded",label:"Superseded",n:l(c=>!!c.supersededBy),onClick:()=>r({status:t.status==="superseded"?void 0:"superseded"})})]})]})}function Cb(e){if(Wi(e)==="superseded")return`Replaced by ${e.supersededBy}`;if(e.supersedes)return`Replaces ${e.supersedes}`}function $b(e){const{d:t}=e,r=Wi(t);return i.jsxs(i.Fragment,{children:[e.newDay&&i.jsx("li",{className:"dv-day t-label",children:Ds(t.decidedAt)}),i.jsx(Ae,{as:"li",className:`dv-row ${r}`,selected:e.on,onOpen:e.onClick,title:t.question,titleText:t.question,trailing:kc(t.decidedAt),context:i.jsx(q,{parts:[{text:t.id,code:!0},t.ticketKey&&{text:t.ticketKey,code:!0},e.showTrail&&e.trail,t.decidedBy,_n[t.source.kind].label,Cb(t)]}),detail:t.summary,detailText:t.summary})]})}function Tb(e){const{rows:t,current:r}=e;return i.jsx("ol",{className:"dv-list","aria-label":"Logbook",children:t.length?t.map((o,l)=>{var c;return i.jsx($b,{d:o,newDay:l===0||Ds(t[l-1].decidedAt)!==Ds(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(Ee,{children:"No decisions"})})}function Eb({stats:e}){return i.jsxs("span",{className:"dv-readouts",children:[i.jsx(Zt,{layout:"start",label:"Active",value:e.active}),i.jsx(Zt,{layout:"start",label:"Superseded",value:e.superseded}),i.jsx(Zt,{layout:"start",label:"Last 24h",value:e.last24h}),i.jsx(Zt,{layout:"start",label:"Human",value:`${e.total?Math.round(e.human/e.total*100):0}%`}),i.jsx(q,{className:"dv-src-mix",parts:vo.filter(t=>e.bySource[t]).map(t=>`${_n[t].label} ${e.bySource[t]}`)})]})}function Ib(e){const{filter:t}=e,o=Object.values(t).filter(Boolean).length-(t.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:t.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 Mb(e){const{api:t,bp:r}=e,o=t.decisions,[l,c]=k.useState({}),[d,h]=k.useState(e.focus),[g,m]=k.useState(!1);k.useEffect(()=>h(e.focus),[e.focus]),k.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 v=k.useMemo(()=>Hy(o,l),[o,l]),w=k.useMemo(()=>Wy(o),[o]),x=o.find(R=>R.id===d&&(!l.mapId||R.mapId===l.mapId))??(r==="mobile"?void 0:v[0]),j=k.useMemo(()=>Object.values(t.allSnaps).sort((R,O)=>O.map.createdAt-R.map.createdAt),[t.allSnaps]),T=k.useMemo(()=>[...new Set(o.map(R=>R.decidedBy))].sort(),[o]),S=R=>c(O=>({...O,...R})),E=()=>{const R=Object.fromEntries(j.map(O=>[O.map.id,{key:O.map.key,title:O.map.title}]));$m(`${ve.slug}-decisions-${Ds(Date.now())}.md`,tk(v,R,{title:`${ve.name} decisions`}))},M=r==="mobile"&&!!x;return i.jsxs(Ke,{className:`zone decisions-view dv-${r}`,children:[i.jsxs("header",{className:"dv-head",children:[M?i.jsx("button",{className:"back",onClick:()=>h(void 0),children:"‹ Decisions"}):i.jsxs(Je,{as:"h2",children:["Decisions ",v.length!==o.length&&i.jsx("span",{className:"n",children:`${v.length}/${o.length}`})]}),r!=="mobile"&&i.jsx(Eb,{stats:w}),i.jsxs("span",{className:"dv-head-right",children:[!M&&i.jsx(K,{onClick:E,disabled:!v.length,title:"Export the filtered list as markdown",children:"Export .md"}),i.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})]})]}),!M&&i.jsx(Ib,{filter:l,set:S,showToggle:r!=="wide",filtersOpen:g,onToggle:()=>m(R=>!R)}),i.jsxs("div",{className:"dv-body",children:[(r==="wide"||g&&!M)&&i.jsx(bb,{filter:l,set:S,all:o,trails:j,people:T,compact:r!=="wide"}),!M&&i.jsx(Tb,{rows:v,current:x,snaps:t.allSnaps,showTrail:r==="wide",onSelect:h}),(r!=="mobile"||x)&&i.jsx("div",{className:"dv-detail",children:x?i.jsx(Nb,{d:x,all:o,snap:t.allSnaps[x.mapId],onSelect:h,onOpenTicket:e.onOpenTicket,onSupersede:t.actions.supersede}):i.jsx(Ee,{children:"No decision selected"})})]})]})}function Ab({api:e,bp:t,nav:r}){return r.statsOpen?i.jsx(PN,{api:e,bp:t,onClose:()=>r.setStatsOpen(!1)}):r.decisionsView?i.jsx(Mb,{api:e,bp:t,focus:r.decisionsView.focus,onClose:()=>r.setDecisionsView(null),onOpenTicket:r.openTicket}):null}function Lb(e,t,r){const o=xp(),[l,c]=k.useState(()=>new URLSearchParams(location.search).has("projects")),d=l&&o.many&&i.jsx(jN,{projects:o,bp:e,onClose:()=>c(!1),onItemHere:r});return{projects:o,overview:d,openOverview:()=>{t.setDecisionsView(null),t.setStatsOpen(!1),c(!0)}}}function Cp({activity:e,onTicket:t}){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&&t(o.ticketId),children:[i.jsx("span",{className:"t t-meta",children:Do(o.at)}),i.jsxs("span",{className:"src t-meta",children:[o.source==="system"&&i.jsx(Pm,{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(Dn,{title:"Nothing has happened yet",hint:"Claims, steps, questions and decisions appear here as agents work."})}function Gf({lease:e,now:t}){if(!e)return null;const r=Oo(e,t);if(r==="live")return null;const o=e.expiresAt-t;return i.jsxs(zn,{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":Wt(o)]})}function Rb({total:e,step:t}){return i.jsx("span",{className:"segs","aria-label":`Step ${t} of ${e}`,children:Array.from({length:e},(r,o)=>i.jsx("i",{className:Ob(o+1,t)},o))})}function Ob(e,t){return e<t?"done":e===t?"cur":""}function $p({snap:e,activity:t,leases:r,onSelect:o,onOpenChat:l}){var x;const c=sn(1e3),d=t.sessions.filter(tn),h=new Set(d.map(j=>j.ticketId)),g=wc(r,e==null?void 0:e.map.id),m=(e==null?void 0:e.tickets.filter(j=>j.state==="open"&&j.assignee&&!h.has(j.id)))??[];if(!d.length&&!m.length)return i.jsx(Ee,{children:"No agent on a ticket"});const v=j=>!!j&&Oo(j,c)!=="live",w=!!((x=e==null?void 0:e.map.modelMatching)!=null&&x.enabled);return i.jsxs("ul",{className:"sessions-list",children:[d.map(j=>{const T=e==null?void 0:e.tickets.find(M=>M.id===j.ticketId),S=T?Hi(T)==="hitl":!1,E=T&&g.get(T.id);return i.jsx(Ae,{as:"li",className:j.waitingOn?"waiting":void 0,edge:Pb(j,v(E)),title:Bb(T,j.mode)||j.agent,context:i.jsx(q,{parts:[{text:j.agent,strong:!0},w&&_b(j),j.waitingOn?{text:"Waiting on you",urgent:!0}:`${j.mode} · ${j.stepLabel.toLowerCase()}`,S&&!j.waitingOn&&"with you",Db(j)],children:i.jsx(Gf,{lease:E,now:c})}),trailing:Tm(c-j.startedAt),below:i.jsx(Rb,{total:j.total,step:j.step}),onOpen:()=>{T&&o({kind:"ticket",id:T.id}),S&&l(j.id)}},j.id)}),m.map(j=>i.jsx(Ae,{as:"li",className:"claim",edge:v(g.get(j.id))?"attention":"neutral",title:`${j.key} ${j.title}`,context:i.jsx(q,{parts:[{text:j.assignee??"",strong:!0},"claimed, no live session"],children:i.jsx(Gf,{lease:g.get(j.id),now:c})}),onOpen:()=>o({kind:"ticket",id:j.id})},j.id))]})}function Pb(e,t){return e.waitingOn?"urgent":t?"attention":"neutral"}function _b(e){const t=e.model?`Runs ${e.model}`:"No model reported, so it counts as balanced";return{text:e.tier??"balanced",tip:t,className:"session-tier"}}function Db(e){if(e.usage)return`${Bo(Fy(e))} tok · ${_s(e.usage.costUsd)}`}function Bb(e,t){return e?`${e.key} ${e.title}`:t==="chart"?"Charting trail":""}function Tp({activity:e,snap:t,running:r,usage:o=!0}){const l=um(e,t==null?void 0:t.map.id),c=hm(e,t==null?void 0:t.map.id),d=new Set(e.sessions.filter(tn).map(g=>g.ticketId)),h=(t==null?void 0:t.tickets.filter(g=>g.state==="open"&&g.assignee&&!d.has(g.id)).length)??0;return i.jsx(Ct,{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=>dm[g].text)].join(`
|
|
145
|
+
`),children:[i.jsx("span",{className:"mono-label",children:"Trail"})," ",Bo(l.inputTokens+l.outputTokens)," tok · ",_s(l.costUsd)]}):void 0})}function zb(e){const t=[...e.feed].reverse().find(r=>r.level==="step"&&r.sessionId);return t?e.sessions.find(r=>r.id===t.sessionId):void 0}const Fb={running:"Working",done:"Done",failed:"Stopped"};function Ep({activity:e,snap:t}){const r=zb(e);if(!r)return i.jsx(Dn,{title:"No agent working yet",hint:"Run /scout resume in Claude Code or Codex. Each step an agent reports shows here."});const o=r.ticketId?t==null?void 0:t.tickets.find(d=>d.id===r.ticketId):void 0,l=Mo[r.mode],c=r.waitingOn?"Waiting on you":Fb[r.status];return i.jsxs("div",{className:`step-tracker ${r.waitingOn?"waiting":""}`,children:[i.jsxs("div",{className:"st-meta",children:[i.jsx(q,{parts:[{text:r.agent,strong:!0},`${r.mode}, step ${r.step} of ${r.total}`]}),i.jsx("span",{className:`t-label st-status ${r.waitingOn?"urgent":""}`,children:c})]}),i.jsxs("div",{className:"st-big",children:[r.stepLabel,o&&i.jsxs("span",{className:"st-key",children:[" ",o.key]})]}),o&&i.jsx("div",{className:"st-ticket t-meta",children:o.title}),i.jsx("ol",{className:"pipeline",children:l.map((d,h)=>{const g=h+1,m=g<r.step||g===r.step&&r.status==="done";let v="";return m?v="done":g===r.step&&(v="cur"),i.jsxs("li",{className:v,children:[i.jsx("i",{}),i.jsxs("span",{children:[String(g).padStart(2,"0")," ",d]})]},d)})})]})}function qf(e){return i.jsxs("div",{className:"zone-b activity-stack",children:[i.jsx(Ep,{activity:e.activity,snap:e.snap}),i.jsx(Tp,{activity:e.activity,snap:e.snap,running:e.activity.sessions.filter(tn).length}),i.jsx($p,{snap:e.snap,activity:e.activity,leases:e.leases,onSelect:t=>(t==null?void 0:t.kind)==="ticket"&&e.onTicket(t.id),onOpenChat:e.onOpenChat}),i.jsx(Ct,{sub:!0,title:"Activity log"}),i.jsx(Cp,{activity:e.activity,onTicket:e.onTicket})]})}function Ub(e){return i.jsx(zm,{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(Cp,{activity:e.activity,onTicket:e.onTicket})})}function Hb(e){var o;const t=e.activity.sessions.filter(tn).length,r=!e.activity.sessions.length&&!((o=e.snap)!=null&&o.tickets.some(l=>l.state==="open"&&l.assignee));return i.jsxs(Ke,{className:"zone step-zone",style:{gridArea:"step"},children:[i.jsx(Ct,{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(Ep,{activity:e.activity,snap:e.snap}),!r&&i.jsxs(i.Fragment,{children:[i.jsx(Tp,{activity:e.activity,snap:e.snap,running:t,usage:!1}),i.jsx($p,{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 Qf=`${Ne()}/criteria`;function Wb(e){const[t,r]=k.useState([]),o=k.useCallback(()=>{if(!e)return r([]);fetch(`${Qf}?mapId=${encodeURIComponent(e)}`).then(c=>c.ok?c.json():{tickets:[]}).then(c=>r(c.tickets)).catch(()=>r([]))},[e]);return k.useEffect(()=>(o(),pn(c=>c.startsWith("criteria/")&&o())),[o]),{tickets:t,confirm:c=>fetch(`${Qf}/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,...c})}).then(o)}}function Kb({snap:e,t}){const{tickets:r,confirm:o}=Wb(e.map.id),l=Ks(),c=r.find(m=>m.ticketId===t.id),d=(c==null?void 0:c.criteria)??[],g=xm(l.entries,{trailKey:e.map.key,ticket:{type:t.type,title:t.title,body:t.body},paths:jm(`${t.body}
|
|
146
|
+
${l.briefText}`)}).filter(m=>m.kind==="business-rule").filter(m=>xk(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(q,{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(q,{parts:[{text:m.id,code:!0},"business rule"]})]},m.id))})]}),d.length>0&&t.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:t.id,ticketKey:t.key,confirmed:!(c!=null&&c.confirmed)}),children:c!=null&&c.confirmed?"Unconfirm":"Confirm criteria"})]})}const $o="";function Vb(e){const t=mc.map(o=>({value:o,label:Fi[o],hint:Xm[o]})),r=[...Gb(e),...t];return i.jsx(ft,{compact:!0,className:"vf-level","aria-label":"Verification level",value:e.value??$o,options:r,onChange:o=>e.onChange(o===$o?null:o)})}function Gb(e){return e.inherit!==void 0?[{value:$o,label:e.inherit,hint:"Use the trail’s level for this ticket."}]:e.value===void 0?[{value:$o,label:"Off (not set)"}]:[]}function qb({check:e}){const t=s0(e),[r,o]=k.useState(),[l,c]=k.useState(),d=Qb(e);return i.jsxs("details",{className:`vf-row ${t?"ok":"bad"}`,open:!t,children:[i.jsxs("summary",{children:[i.jsx("span",{className:"vf-mark",children:t?"✓":"✕"}),i.jsx("span",{className:"t-code vf-name",children:e.name}),i.jsx("span",{className:"t-meta",children:d}),i.jsx("span",{className:"t-meta vf-dur",children:Wt(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:()=>Vi.log(e.log).then(h=>o(h.clipped?`[earlier output not shown]
|
|
147
|
+
${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 Qb(e){return e.error?"did not start":e.timedOut?"timed out":`exit ${e.exitCode??e.signal??"?"}`}const Yf=e=>(e==null?void 0:e.slice(0,8))??"none",Jf=e=>e===null?"·":String(e);function Yb({attempt:e}){const t=e.git;if(!t)return null;const{files:r,add:o,del:l}=t.stats;return i.jsxs("div",{className:"vf-git",children:[i.jsx(q,{parts:[t.tree?{text:`${t.base?`${Yf(t.base.head)} → `:""}${Yf(t.tree.head)}`,code:!0}:"not a git repo",t.tree&&{text:t.tree.branch??"detached HEAD",code:!!t.tree.branch},t.tree&&`${r} file${r===1?"":"s"} +${o} −${l}`]}),t.flags.filter(c=>c.kind!=="no-git").map(c=>{var d;return i.jsxs("p",{className:`vf-flag lv-${c.level}`,title:(d=c.files)==null?void 0:d.join(`
|
|
148
|
+
`),children:[i.jsx("span",{className:"t-code",children:c.kind})," ",c.message]},c.kind)}),t.changed.length>0&&i.jsxs("details",{className:"vf-files",children:[i.jsx("summary",{className:"t-label",children:"Changed files"}),i.jsx("ul",{children:t.changed.map(c=>i.jsxs("li",{children:[i.jsx("code",{children:c.path}),i.jsxs("span",{className:"dim",children:[c.untracked?"new":`+${Jf(c.add)} −${Jf(c.del)}`,c.dirtyAtClaim?" · dirty at claim":""]})]},c.path))})]})]})}function Jb({attempt:e,latest:t}){return i.jsxs("details",{className:`vf-attempt r-${e.result}`,open:t,children:[i.jsxs("summary",{children:[i.jsx(zn,{tone:"state",className:`r-${e.result}`,children:n0[e.result]}),i.jsx(q,{parts:[{text:e.id,code:!0},e.agent,Ki(e.submittedAt),Wt(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:Xb(r),children:r},r))}),i.jsx(Yb,{attempt:e}),e.checks.map(r=>i.jsx(qb,{check:r},r.name))]})}function Xb(e){return e.includes(" ✓ ")?"ok":e.includes(" ✗ ")?"bad":"wait"}const Zb={PASS:"Passed",FAIL:"Sent back",NEEDS_HUMAN:"Needs you"};function eC({verdict:e}){const{guide:t,checklist:r}=e;return i.jsxs("div",{className:`vf-verdict v-${e.verdict.toLowerCase()}`,children:[i.jsx(q,{parts:[{text:e.byKind==="trail lead"&&e.verdict==="PASS"?"Approved":Zb[e.verdict],strong:!0},{text:e.id,code:!0},e.byKind==="trail lead"?e.by:`review ${e.by}`,e.sessionId&&`session ${e.sessionId.slice(0,8)}`,t&&`as ${t.id} ${t.version}`,`on ${e.attemptId}`,Ki(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(cp,{answers:r})]})}function tC(e,t,r){const[o,l]=k.useState(),c=k.useCallback(()=>{Vi.ticket(e,t).then(l)},[e,t]);return k.useEffect(()=>(l(void 0),c(),Bs.onEvidence(c)),[c]),k.useEffect(c,[c,r]),{data:o,reload:c}}const ql={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 nC(e){const[t,r]=k.useState(),[o,l]=k.useState(""),[c,d]=k.useState("rework"),{state:h,submitted:g,running:m,act:v}=e;if(m||h!=="verifying"&&h!=="held")return null;const w=j=>{r(t===j?void 0:j),l("")},x=j=>{j.preventDefault(),!(!t||!o.trim())&&(v({action:t,reason:o.trim(),...t==="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 v({action:"approve"}),"data-tip":"Checks passed: approve and close the ticket",children:"Approve"}),g&&i.jsx(K,{onClick:()=>void v({action:"rerun"}),"data-tip":"Run the repo's checks again on the current code",children:"Re-run checks"}),i.jsx(K,{on:t==="rework",onClick:()=>w("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:t==="accept",onClick:()=>w("accept"),"data-tip":"Close it as done despite the failing checks",children:"Accept anyway…"}),i.jsx(K,{on:t==="unblock",onClick:()=>w("unblock"),"data-tip":"Put it back in the queue without running checks",children:"Unblock…"})]})]}),t&&i.jsxs(Ot,{as:"form",tone:"inset",className:"inline-form",onSubmit:x,children:[i.jsx(Ye,{label:ql[t].label,children:i.jsx("textarea",{rows:2,value:o,onChange:j=>l(j.target.value),autoFocus:!0})}),t==="unblock"&&i.jsx(Ye,{label:"Back to",children:i.jsx(ft,{"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:ql[t].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:t==="accept"?"danger":"primary",disabled:!o.trim(),children:ql[t].submit})]})]})]})}const sC={ticket:"set on this ticket",trail:"from the trail",none:"not set"},iC=new Set(["verifying","rework","held"]);function rC(e){const{mapId:t,ticket:r,state:o}=e,{data:l,reload:c}=tC(t,r.id,r.updatedAt),[d,h]=k.useState();if(!l||l.level.level==="off"&&!l.attempts.length&&!iC.has(o))return null;const g=v=>(h(void 0),Vi.act({...v,mapId:t,ticketId:r.id,by:xt}).then(c,w=>h(w.message))),m=l.running;return i.jsxs("section",{className:"vf-panel",children:[i.jsxs("div",{className:"vf-head",children:[i.jsx(Je,{as:"h4",children:"Verification"}),i.jsx(q,{parts:[Fi[l.level.level],sC[l.level.source]]}),r.state==="open"&&i.jsx(Vb,{value:r.verification,inherit:`Trail (${Fi[e.trail??"off"]})`,onChange:v=>void g({action:"level",level:v})})]}),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 ",Ki(m.startedAt)]})]}),i.jsx(nC,{state:o,submitted:l.attempts.length>0,running:!!m,act:g}),d&&i.jsx("p",{className:"vf-err",children:d}),l.verdicts.map(v=>i.jsx(eC,{verdict:v},v.id)),l.attempts.map((v,w)=>i.jsx(Jb,{attempt:v,latest:w===0},v.id)),!l.attempts.length&&!m&&i.jsx(q,{parts:[`Checks: ${l.level.checks.join(", ")||"none"}`,"run when the ticket is submitted"]})]})}function oC({lease:e,onRelease:t}){const r=sn(1e3),o=Oo(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(q,{parts:[{text:`Claimed by ${e.agent}`,strong:!0},`active ${nn(r-e.renewedAt)} ago`]}),!l&&i.jsx(zn,{tone:"amber",children:"Stalled"})]}),i.jsx("p",{className:"t-meta lease-line",children:aC(o,lC(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:t,children:"Release to queue"})})]})}function aC(e,t){return e==="expired"?"Lease expired, going back to the queue":e==="stalled"?`The agent went quiet. Back in the queue in ${t}.`:`Back in the queue after ${t} without activity.`}function lC(e){const t=e/864e5;return t>=2?`${Math.round(t)} days`:Wt(Math.max(0,e))}function cC({comments:e}){if(!e.length)return null;const t=e.length>1?"s":"";return i.jsxs("details",{className:"comments",children:[i.jsxs("summary",{className:"t-label",children:[e.length," other comment",t]}),e.map(r=>i.jsxs("div",{className:"comment",children:[i.jsx(q,{parts:[{text:r.author,strong:!0}]}),i.jsx("div",{className:"c-body",children:r.body.replace(/\*\*/g,"")})]},r.id))]})}function uC({resolution:e,decisions:t,onOpenDecision:r}){const o=t.find(d=>!d.supersededBy)??t[0],l=e.body.startsWith("**Ruled")?"ruled out":"resolution",c=t.length>1?` · ${t.length} in chain`:"";return i.jsxs("div",{className:"resolution edge-note edge-done",children:[i.jsxs("div",{className:"edge-note-head",children:[i.jsx(q,{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 dC(e){const{t,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(t.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(t.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 hC({t:e,state:t,tickets:r}){const o=new Map(r.map(m=>[m.id,m])),l=m=>{var v;return((v=o.get(m))==null?void 0:v.key)??m},c=e.blockedBy.map(m=>{var v;return`${l(m)}${((v=o.get(m))==null?void 0:v.state)==="closed"?" ✓":""}`}).join(", "),d=r.filter(m=>m.blockedBy.includes(e.id)).map(m=>m.key).join(", "),h=[["Type",Bi[e.type]],["Assignee",e.assignee],["Blocked by",c],["Blocks",d],["Reviews",e.reviewOf&&l(e.reviewOf)]],g=Hi(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(zn,{tone:"state",className:`st-${t}`,children:Im[t]}),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,v])=>[i.jsx("dt",{className:"t-label",children:m},`${m}-k`),i.jsx("dd",{children:v},`${m}-v`)])})]})}function fC(e){const{snap:t,api:r,form:o,setForm:l}=e,{actions:c}=r,[d,h]=k.useState(""),[g,m]=k.useState(""),[v,w]=k.useState(""),[x,j]=k.useState("Not needed to reach the destination."),T=t.tickets.find(_=>_.id===e.id);if(!T)return i.jsx(Ee,{children:"Ticket not found."});const S=Fs(t.tickets,t.map.mode).get(T.id),E=e.sessions.find(_=>_.ticketId===T.id&&tn(_)),M=T.assignee===xt,R=T.state==="open"?wc(r.leases,t.map.id).get(T.id):void 0,O=[...T.comments].reverse().find(_=>/^\*\*(Resolution|Ruled out of scope)\*\*/.test(_.body)),X=T.comments.filter(_=>_!==O),se=r.decisions.filter(_=>_.mapId===t.map.id&&_.ticketId===T.id);return i.jsxs("div",{className:"detail",children:[i.jsx(hC,{t:T,state:S,tickets:t.tickets}),i.jsx(EN,{mapId:t.map.id,ticketId:T.id}),i.jsx(bx,{mapId:t.map.id,ticketId:T.id}),i.jsx(XS,{mapId:t.map.id,ticket:T}),i.jsx(Kb,{snap:t,t:T}),i.jsx(Dx,{snap:t,t:T}),T.closeReason==="not_planned"&&i.jsx($c,{label:"Save as dead end",draft:()=>{var _;return{title:`Ruled out: ${T.title}`,body:((_=T.comments.at(-1))==null?void 0:_.body)??T.body,kind:"dead-end",sources:[`trail:${t.map.key}`,`ticket:${T.key}`]}}}),R&&i.jsx(oC,{lease:R,onRelease:()=>c.releaseLease(T.id)}),!R&&i.jsx(lN,{mapId:t.map.id,ticketId:T.id}),i.jsx(rC,{mapId:t.map.id,trail:t.map.verification,ticket:T,state:S}),i.jsx(dC,{t:T,state:S,session:E,mine:M,form:o,setForm:l,actions:c,onOpenChat:e.onOpenChat}),o==="resolve"&&i.jsxs(Ot,{as:"form",tone:"inset",className:"inline-form",onSubmit:_=>{_.preventDefault(),d.trim()&&(c.resolve(T.id,d.trim(),{rationale:g.trim(),alternatives:v.split(`
|
|
149
|
+
`).map(Q=>Q.trim()).filter(Boolean)}),l(null),h(""),m(""),w(""))},children:[i.jsx(Ye,{label:"Resolution",children:i.jsx("textarea",{rows:3,value:d,onChange:_=>h(_.target.value),autoFocus:!0})}),i.jsx(Ye,{label:"Rationale",children:i.jsx("input",{value:g,onChange:_=>m(_.target.value)})}),i.jsx(Ye,{label:"Alternatives considered",children:i.jsx("textarea",{rows:2,value:v,onChange:_=>w(_.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(Ot,{as:"form",tone:"inset",className:"inline-form",onSubmit:_=>{_.preventDefault(),c.ruleOut({ticketId:T.id},x),l(null)},children:[i.jsx(Ye,{label:"Reason",children:i.jsx("input",{value:x,onChange:_=>j(_.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(uC,{resolution:O,decisions:se,onOpenDecision:e.onOpenDecision}),i.jsx("p",{className:"body",children:T.body}),i.jsx(cC,{comments:X})]})}function mC({snap:e,item:t,api:r}){const o=rm(e.map.mode),[l,c]=k.useState("research"),[d,h]=k.useState(t),[g,m]=k.useState(!1),[v,w]=k.useState([]),[x,j]=k.useState("Not needed to reach the destination.");k.useEffect(()=>h(t),[t]);const T=e.tickets.filter(S=>S.state==="open");return i.jsxs("div",{className:"detail",children:[i.jsx("div",{className:"d-head",children:i.jsx(zn,{tone:"state",className:"st-unspecified",children:"Not yet specified"})}),i.jsx("h3",{className:"t-heading",children:t}),i.jsxs(Ot,{as:"form",tone:"inset",className:"inline-form",onSubmit:S=>{S.preventDefault(),r.actions.graduate({unspecified:t,type:l,title:d,blockedBy:v,hitl:g})},children:[i.jsx(Ye,{label:"Title",children:i.jsx("input",{value:d,onChange:S=>h(S.target.value)})}),i.jsxs("div",{className:"chips",children:[o.map(S=>i.jsx("button",{type:"button",className:`chip ${l===S?"on":""}`,onClick:()=>c(S),children:S},S)),Dv.includes(l)&&i.jsx("button",{type:"button",className:`chip ${g?"on":""}`,onClick:()=>m(S=>!S),children:"needs human"})]}),i.jsx("span",{className:"field",children:"Blocked by"}),i.jsx("div",{className:"chips",children:T.map(S=>i.jsx("button",{type:"button",className:`chip ${v.includes(S.id)?"on":""}`,onClick:()=>w(E=>E.includes(S.id)?E.filter(M=>M!==S.id):[...E,S.id]),children:S.key},S.id))}),i.jsx("div",{className:"form-actions",children:i.jsx(K,{type:"submit",variant:"primary",children:"Promote to ticket"})})]}),i.jsxs(Ot,{as:"form",tone:"inset",className:"inline-form",onSubmit:S=>{S.preventDefault(),r.actions.ruleOut({unspecified:t},x)},children:[i.jsx(Ye,{label:"Reason",children:i.jsx("input",{value:x,onChange:S=>j(S.target.value)})}),i.jsx("div",{className:"form-actions",children:i.jsx(K,{type:"submit",variant:"danger",children:"Rule out"})})]})]})}function pC({api:e,sessions:t,bare:r,onOpenChat:o,onOpenDecision:l}){const{snap:c,selection:d,actions:h}=e,[g,m]=k.useState(null),v=gC(d);k.useEffect(()=>m(null),[v]);let w;return c?d?d.kind==="unspecified"?w=i.jsx(mC,{snap:c,item:d.item,api:e}):w=i.jsx(fC,{snap:c,id:d.id,api:e,sessions:t,form:g,setForm:m,onOpenChat:o??h.openChat,onOpenDecision:l}):w=i.jsx(Dn,{title:"No ticket selected",hint:"Pick a ticket on the map: what it is, who has it, what blocks it, and its decision."}):w=i.jsx(Dn,{title:"No trail yet",hint:"Once there's a trail, pick a ticket on the map to see it here."}),i.jsx(zm,{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:w})}function gC(e){return(e==null?void 0:e.kind)==="ticket"?e.id:(e==null?void 0:e.kind)==="unspecified"?e.item:""}const vC={holding:"Holding",challenged:"Challenged",invalidated:"Invalidated",confirmed:"Confirmed"};function yC(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 kC(e){const{a:t,snap:r}=e,o=t.tickets.flatMap(c=>r.tickets.filter(d=>d.id===c)),l=t.challenge&&`${t.challenge.by}: ${t.challenge.evidence}`;return i.jsx(Ae,{as:"li",className:`assumption st-${t.status}`,edge:t.status==="challenged"?"attention":"neutral",title:t.text,titleText:t.text,context:i.jsx(q,{parts:[{text:t.id,code:!0},vC[t.status],yC(t)],children:o.length>0&&i.jsxs("span",{className:"assumption-tickets",children:[i.jsx("span",{className:"sep",children:" · "}),"relied on by",o.map(c=>i.jsx("button",{className:"link t-code",onClick:()=>e.onSelect({kind:"ticket",id:c.id}),children:c.key},c.id))]})}),detail:l,detailText:l,trailing:e.onConfirm&&i.jsx(K,{size:"sm",variant:"ghost",disabled:e.busy,onClick:e.onConfirm,children:"Confirm"})})}function wC(e){const[t,r]=k.useState(),[o,l]=k.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:t}}function xC({snap:e,onSelect:t}){const{confirm:r,busy:o,error:l}=wC(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(kC,{a:d,snap:e,onSelect:t,onConfirm:h?()=>void r(d.id):void 0,busy:o===d.id},d.id)})})]}):i.jsx(Ee,{children:"None yet. They come from the accepted discovery brief or the trail's start."})}function jC(e){const[t,r]=k.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 k.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]),t}function SC({snap:e,activity:t,onTicket:r}){const o=jC(e),l=t.usageByMap[e.map.id],c=k.useMemo(()=>pm({snap:e,journal:o,answered:t.answered,usage:l}),[e,o,t.answered,l]),d=c.interventions,h=[["Done",`${c.done}`,`${c.done} done · ${c.cancelled} cancelled · ${c.open} open`],["Lead time",en(c.trailLeadMs),"Trail lead time: from when the trail was charted to its last done ticket"],["Median ticket",en(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?"—":_s(c.spend.perVerifiedTicketUsd),`Cost per verified ticket: trail spend ${_s(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,v])=>i.jsxs("li",{"data-tip":v,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:()=>$m(`${e.map.key.replace("#","trail-")}-report.md`,uk(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"?en(g.leadMs):g.outcome})]})},g.id))}):i.jsx(Ee,{children:"No tickets yet"})]})}function NC({tab:e,snap:t,selection:r,onSelect:o,activity:l}){const c=t.map.sections;switch(e){case"report":return l?i.jsx(SC,{snap:t,activity:l,onTicket:d=>o({kind:"ticket",id:d})}):i.jsx(Ee,{children:"No activity yet"});case"assumptions":return i.jsx(xC,{snap:t,onSelect:o});case"decisions":return c.decisions.length?i.jsx("ol",{className:"row-list decisions",children:[...c.decisions].reverse().map((d,h)=>i.jsx(Ae,{as:"li",title:d.text,titleText:d.text,context:d.ticketKey&&i.jsx(q,{parts:[{text:d.ticketKey,code:!0}]}),onOpen:d.ticketId?()=>o({kind:"ticket",id:d.ticketId}):void 0},`${d.ticketKey}-${h}`))}):i.jsx(Ee,{children:"None"});case"unspecified":return c.unspecified.length?i.jsx("ul",{className:"row-list unspecified",children:c.unspecified.map(d=>i.jsx(Ae,{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(Ee,{children:"None"});case"oos":return c.outOfScope.length?i.jsx("ul",{className:"row-list oos",children:c.outOfScope.map(d=>i.jsx(Ae,{as:"li",title:d,titleText:d},d))}):i.jsx(Ee,{children:"None"});case"notes":return i.jsx("p",{className:"notes t-body",children:c.notes||"No notes yet."});default:return e}}function bC({snap:e,selection:t,onSelect:r,bare:o,onAudit:l,activity:c}){var w;const[d,h]=k.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:(w=g==null?void 0:g.assumptions)==null?void 0:w.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"}],v=e?i.jsx(NC,{tab:d,snap:e,selection:t,onSelect:r,activity:c}):i.jsx(Dn,{title:"No plan yet",hint:"Open questions, decisions, what's ruled out, notes and the trail report collect here."});return i.jsxs(Ke,{className:`zone sections ${o?"bare":""}`,style:o?void 0:{gridArea:"plan"},children:[!o&&i.jsx(Ct,{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(Dm,{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:v})]})}function CC(){var ae;const e=k.useMemo(()=>nx(tx()),[]),t=mx(e),{snap:r,activity:o,selection:l,actions:c}=t,[d,h]=px();k.useEffect(()=>Mm(d.theme),[d.theme]);const g=Q1(),[m,v]=k.useState(!1),w=X1(e.kind),x=ux(),j=o.pending.length,T=Z1(o,t.mapId);J1(j,r==null?void 0:r.map.title);const S=Y1(t,x),E=kb(r,c.selectMap),M=Hx(E.briefText),R=Sb({api:t,nav:S,knowledge:M,reviewBrief:E.review,openReroute:Z=>E.openReroute(Z.mapId,Z.ref),openGuides:()=>g.open("guides"),openFocusSettings:()=>g.open("attention")}),O=hx(e,t,d.briefing,(ae=R.attention.view)==null?void 0:ae.items),X=i.jsx(d0,{api:t,nav:S,bp:x,scoped:T,attn:R,above:E.inboxCard}),se=i.jsx(K1,{api:t,sessions:T.sessions,onSelect:S.select,onNewTrail:()=>v(!0),compact:x==="mobile",minFit:x==="mobile"?.7:0,trail:E}),_=Z=>i.jsx(pC,{api:t,sessions:T.sessions,bare:Z,onOpenChat:U=>S.openChat(U),onOpenDecision:S.openDecisions}),Q={activity:T,snap:r,leases:t.leases,onTicket:Z=>S.select({kind:"ticket",id:Z}),onOpenChat:Z=>S.openChat(Z)},oe=Z=>i.jsx(bC,{snap:r,selection:l,onSelect:S.select,bare:Z,onAudit:()=>S.openDecisions(),activity:T}),{projects:G,overview:ge,openOverview:Re}=Lb(x,S,R.link.request),be=g.route&&i.jsx(ZN,{rt:e,api:t,bp:x,prefs:d,update:h,settings:g}),te=(S.statsOpen||S.decisionsView)&&i.jsx(Ab,{api:t,bp:x,nav:S}),P=be||ge||te,Y=O.shown&&i.jsx(Sx,{brief:O,snaps:t.allSnaps,bp:x,openTicket:S.openTicket,openChat:S.openChat,openDecisions:S.openDecisions,closeDecisions:()=>S.setDecisionsView(null),showPhoneHome:()=>S.setPhoneTab("home")});return i.jsx(Um.Provider,{value:M,children:i.jsxs("div",{className:`app bp-${x}`,children:[i.jsx(vj,{api:t,rt:e,repo:i.jsx(SN,{repo:w,projects:G,onOverview:Re}),brief:O,attention:R.header,decisionsOpen:!!S.decisionsView,onDecisions:()=>{g.close(),S.decisionsView?S.setDecisionsView(null):S.openDecisions()},onStats:()=>{g.close(),S.toggleStats()},onNewTrail:()=>v(!0),onSettings:g.toggle,onSlack:()=>g.open("slack"),onToggleTheme:Z=>h({theme:Z?"night":"day"})}),x==="wide"&&i.jsxs(i.Fragment,{children:[X,se,_(!1),i.jsx(Hb,{...Q}),i.jsx(Ub,{...Q}),oe(!1),P]}),x==="laptop"&&i.jsxs(i.Fragment,{children:[X,se,i.jsx(e1,{tab:S.sideTab,onTab:S.setSideTab,unspecified:r==null?void 0:r.map.sections.unspecified.length,ticket:_(!0),activity:i.jsx(qf,{...Q}),plan:oe(!0)}),P]}),x==="mobile"&&i.jsxs(i.Fragment,{children:[i.jsx(q1,{tab:S.phoneTab,decisions:P,inbox:X,projects:G.many&&i.jsx(bN,{projects:G,onOverview:Re}),map:se,ticket:_(!0),activity:i.jsx(qf,{...Q}),plan:oe(!0)}),i.jsx(G1,{tab:S.phoneTab,covered:!!P,pending:j,onPick:Z=>{g.close(),S.setPhoneTab(Z),S.setDecisionsView(null)}})]}),Y,E.dialog,t.error&&i.jsx("div",{className:"error-toast",children:t.error}),m&&i.jsx(y0,{rt:e,onClose:()=>v(!1),onCreated:Z=>c.selectMap(Z)}),!d.onboarded&&i.jsx(lS,{prefs:d,update:h,activeTracker:e.kind}),i.jsx(Ux,{})]})})}Mm(jc().theme);Ov.createRoot(document.getElementById("root")).render(i.jsxs(i.Fragment,{children:[i.jsx(CC,{}),i.jsx(yx,{})]}));
|