teamtrail 0.7.0-next.29 → 0.7.0-next.30

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,148 @@
1
+ var uv=Object.defineProperty;var dv=(e,n,r)=>n in e?uv(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r;var ue=(e,n,r)=>dv(e,typeof n!="symbol"?n+"":n,r);(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))o(l);new MutationObserver(l=>{for(const c of l)if(c.type==="childList")for(const d of c.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&o(d)}).observe(document,{childList:!0,subtree:!0});function r(l){const c={};return l.integrity&&(c.integrity=l.integrity),l.referrerPolicy&&(c.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?c.credentials="include":l.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function o(l){if(l.ep)return;l.ep=!0;const c=r(l);fetch(l.href,c)}})();var Al={exports:{}},Ei={},Rl={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 Sf;function fv(){if(Sf)return ke;Sf=1;var e=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),d=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),k=Symbol.iterator;function w($){return $===null||typeof $!="object"?null:($=k&&$[k]||$["@@iterator"],typeof $=="function"?$:null)}var j={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},T=Object.assign,S={};function E($,_,he){this.props=$,this.context=_,this.refs=S,this.updater=he||j}E.prototype.isReactComponent={},E.prototype.setState=function($,_){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,$,_,"setState")},E.prototype.forceUpdate=function($){this.updater.enqueueForceUpdate(this,$,"forceUpdate")};function I(){}I.prototype=E.prototype;function O($,_,he){this.props=$,this.context=_,this.refs=S,this.updater=he||j}var R=O.prototype=new I;R.constructor=O,T(R,E.prototype),R.isPureReactComponent=!0;var X=Array.isArray,te=Object.prototype.hasOwnProperty,B={current:null},se={key:!0,ref:!0,__self:!0,__source:!0};function oe($,_,he){var pe,de={},we=null,me=null;if(_!=null)for(pe in _.ref!==void 0&&(me=_.ref),_.key!==void 0&&(we=""+_.key),_)te.call(_,pe)&&!se.hasOwnProperty(pe)&&(de[pe]=_[pe]);var ye=arguments.length-2;if(ye===1)de.children=he;else if(1<ye){for(var Ce=Array(ye),ut=0;ut<ye;ut++)Ce[ut]=arguments[ut+2];de.children=Ce}if($&&$.defaultProps)for(pe in ye=$.defaultProps,ye)de[pe]===void 0&&(de[pe]=ye[pe]);return{$$typeof:e,type:$,key:we,ref:me,props:de,_owner:B.current}}function G($,_){return{$$typeof:e,type:$.type,key:_,ref:$.ref,props:$.props,_owner:$._owner}}function ve($){return typeof $=="object"&&$!==null&&$.$$typeof===e}function Be($){var _={"=":"=0",":":"=2"};return"$"+$.replace(/[=:]/g,function(he){return _[he]})}var $e=/\/+/g;function ie($,_){return typeof $=="object"&&$!==null&&$.key!=null?Be(""+$.key):_.toString(36)}function D($,_,he,pe,de){var we=typeof $;(we==="undefined"||we==="boolean")&&($=null);var me=!1;if($===null)me=!0;else switch(we){case"string":case"number":me=!0;break;case"object":switch($.$$typeof){case e:case n:me=!0}}if(me)return me=$,de=de(me),$=pe===""?"."+ie(me,0):pe,X(de)?(he="",$!=null&&(he=$.replace($e,"$&/")+"/"),D(de,_,he,"",function(ut){return ut})):de!=null&&(ve(de)&&(de=G(de,he+(!de.key||me&&me.key===de.key?"":(""+de.key).replace($e,"$&/")+"/")+$)),_.push(de)),1;if(me=0,pe=pe===""?".":pe+":",X($))for(var ye=0;ye<$.length;ye++){we=$[ye];var Ce=pe+ie(we,ye);me+=D(we,_,he,Ce,de)}else if(Ce=w($),typeof Ce=="function")for($=Ce.call($),ye=0;!(we=$.next()).done;)we=we.value,Ce=pe+ie(we,ye++),me+=D(we,_,he,Ce,de);else if(we==="object")throw _=String($),Error("Objects are not valid as a React child (found: "+(_==="[object Object]"?"object with keys {"+Object.keys($).join(", ")+"}":_)+"). If you meant to render a collection of children, use an array instead.");return me}function q($,_,he){if($==null)return $;var pe=[],de=0;return D($,pe,"","",function(we){return _.call(he,we,de++)}),pe}function ae($){if($._status===-1){var _=$._result;_=_(),_.then(function(he){($._status===0||$._status===-1)&&($._status=1,$._result=he)},function(he){($._status===0||$._status===-1)&&($._status=2,$._result=he)}),$._status===-1&&($._status=0,$._result=_)}if($._status===1)return $._result.default;throw $._result}var Y={current:null},U={transition:null},P={ReactCurrentDispatcher:Y,ReactCurrentBatchConfig:U,ReactCurrentOwner:B};function W(){throw Error("act(...) is not supported in production builds of React.")}return ke.Children={map:q,forEach:function($,_,he){q($,function(){_.apply(this,arguments)},he)},count:function($){var _=0;return q($,function(){_++}),_},toArray:function($){return q($,function(_){return _})||[]},only:function($){if(!ve($))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=O,ke.StrictMode=o,ke.Suspense=g,ke.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=P,ke.act=W,ke.cloneElement=function($,_,he){if($==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+$+".");var pe=T({},$.props),de=$.key,we=$.ref,me=$._owner;if(_!=null){if(_.ref!==void 0&&(we=_.ref,me=B.current),_.key!==void 0&&(de=""+_.key),$.type&&$.type.defaultProps)var ye=$.type.defaultProps;for(Ce in _)te.call(_,Ce)&&!se.hasOwnProperty(Ce)&&(pe[Ce]=_[Ce]===void 0&&ye!==void 0?ye[Ce]:_[Ce])}var Ce=arguments.length-2;if(Ce===1)pe.children=he;else if(1<Ce){ye=Array(Ce);for(var ut=0;ut<Ce;ut++)ye[ut]=arguments[ut+2];pe.children=ye}return{$$typeof:e,type:$.type,key:de,ref:we,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 _=oe.bind(null,$);return _.type=$,_},ke.createRef=function(){return{current:null}},ke.forwardRef=function($){return{$$typeof:h,render:$}},ke.isValidElement=ve,ke.lazy=function($){return{$$typeof:v,_payload:{_status:-1,_result:$},_init:ae}},ke.memo=function($,_){return{$$typeof:m,type:$,compare:_===void 0?null:_}},ke.startTransition=function($){var _=U.transition;U.transition={};try{$()}finally{U.transition=_}},ke.unstable_act=W,ke.useCallback=function($,_){return Y.current.useCallback($,_)},ke.useContext=function($){return Y.current.useContext($)},ke.useDebugValue=function(){},ke.useDeferredValue=function($){return Y.current.useDeferredValue($)},ke.useEffect=function($,_){return Y.current.useEffect($,_)},ke.useId=function(){return Y.current.useId()},ke.useImperativeHandle=function($,_,he){return Y.current.useImperativeHandle($,_,he)},ke.useInsertionEffect=function($,_){return Y.current.useInsertionEffect($,_)},ke.useLayoutEffect=function($,_){return Y.current.useLayoutEffect($,_)},ke.useMemo=function($,_){return Y.current.useMemo($,_)},ke.useReducer=function($,_,he){return Y.current.useReducer($,_,he)},ke.useRef=function($){return Y.current.useRef($)},ke.useState=function($){return Y.current.useState($)},ke.useSyncExternalStore=function($,_,he){return Y.current.useSyncExternalStore($,_,he)},ke.useTransition=function(){return Y.current.useTransition()},ke.version="18.3.1",ke}var Nf;function ic(){return Nf||(Nf=1,Rl.exports=fv()),Rl.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 bf;function hv(){if(bf)return Ei;bf=1;var e=ic(),n=Symbol.for("react.element"),r=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,l=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function d(h,g,m){var v,k={},w=null,j=null;m!==void 0&&(w=""+m),g.key!==void 0&&(w=""+g.key),g.ref!==void 0&&(j=g.ref);for(v in g)o.call(g,v)&&!c.hasOwnProperty(v)&&(k[v]=g[v]);if(h&&h.defaultProps)for(v in g=h.defaultProps,g)k[v]===void 0&&(k[v]=g[v]);return{$$typeof:n,type:h,key:w,ref:j,props:k,_owner:l.current}}return Ei.Fragment=r,Ei.jsx=d,Ei.jsxs=d,Ei}var Cf;function mv(){return Cf||(Cf=1,Al.exports=hv()),Al.exports}var i=mv(),to={},Ll={exports:{}},kt={},Ol={exports:{}},_l={};/**
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 $f;function pv(){return $f||($f=1,(function(e){function n(U,P){var W=U.length;U.push(P);e:for(;0<W;){var $=W-1>>>1,_=U[$];if(0<l(_,P))U[$]=P,U[W]=_,W=$;else break e}}function r(U){return U.length===0?null:U[0]}function o(U){if(U.length===0)return null;var P=U[0],W=U.pop();if(W!==P){U[0]=W;e:for(var $=0,_=U.length,he=_>>>1;$<he;){var pe=2*($+1)-1,de=U[pe],we=pe+1,me=U[we];if(0>l(de,W))we<_&&0>l(me,de)?(U[$]=me,U[we]=W,$=we):(U[$]=de,U[pe]=W,$=pe);else if(we<_&&0>l(me,W))U[$]=me,U[we]=W,$=we;else break e}}return P}function l(U,P){var W=U.sortIndex-P.sortIndex;return W!==0?W:U.id-P.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,k=null,w=3,j=!1,T=!1,S=!1,E=typeof setTimeout=="function"?setTimeout:null,I=typeof clearTimeout=="function"?clearTimeout:null,O=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function R(U){for(var P=r(m);P!==null;){if(P.callback===null)o(m);else if(P.startTime<=U)o(m),P.sortIndex=P.expirationTime,n(g,P);else break;P=r(m)}}function X(U){if(S=!1,R(U),!T)if(r(g)!==null)T=!0,ae(te);else{var P=r(m);P!==null&&Y(X,P.startTime-U)}}function te(U,P){T=!1,S&&(S=!1,I(oe),oe=-1),j=!0;var W=w;try{for(R(P),k=r(g);k!==null&&(!(k.expirationTime>P)||U&&!Be());){var $=k.callback;if(typeof $=="function"){k.callback=null,w=k.priorityLevel;var _=$(k.expirationTime<=P);P=e.unstable_now(),typeof _=="function"?k.callback=_:k===r(g)&&o(g),R(P)}else o(g);k=r(g)}if(k!==null)var he=!0;else{var pe=r(m);pe!==null&&Y(X,pe.startTime-P),he=!1}return he}finally{k=null,w=W,j=!1}}var B=!1,se=null,oe=-1,G=5,ve=-1;function Be(){return!(e.unstable_now()-ve<G)}function $e(){if(se!==null){var U=e.unstable_now();ve=U;var P=!0;try{P=se(!0,U)}finally{P?ie():(B=!1,se=null)}}else B=!1}var ie;if(typeof O=="function")ie=function(){O($e)};else if(typeof MessageChannel<"u"){var D=new MessageChannel,q=D.port2;D.port1.onmessage=$e,ie=function(){q.postMessage(null)}}else ie=function(){E($e,0)};function ae(U){se=U,B||(B=!0,ie())}function Y(U,P){oe=E(function(){U(e.unstable_now())},P)}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(te))},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 w},e.unstable_getFirstCallbackNode=function(){return r(g)},e.unstable_next=function(U){switch(w){case 1:case 2:case 3:var P=3;break;default:P=w}var W=w;w=P;try{return U()}finally{w=W}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(U,P){switch(U){case 1:case 2:case 3:case 4:case 5:break;default:U=3}var W=w;w=U;try{return P()}finally{w=W}},e.unstable_scheduleCallback=function(U,P,W){var $=e.unstable_now();switch(typeof W=="object"&&W!==null?(W=W.delay,W=typeof W=="number"&&0<W?$+W:$):W=$,U){case 1:var _=-1;break;case 2:_=250;break;case 5:_=1073741823;break;case 4:_=1e4;break;default:_=5e3}return _=W+_,U={id:v++,callback:P,priorityLevel:U,startTime:W,expirationTime:_,sortIndex:-1},W>$?(U.sortIndex=W,n(m,U),r(g)===null&&U===r(m)&&(S?(I(oe),oe=-1):S=!0,Y(X,W-$))):(U.sortIndex=_,n(g,U),T||j||(T=!0,ae(te))),U},e.unstable_shouldYield=Be,e.unstable_wrapCallback=function(U){var P=w;return function(){var W=w;w=P;try{return U.apply(this,arguments)}finally{w=W}}}})(_l)),_l}var Tf;function gv(){return Tf||(Tf=1,Ol.exports=pv()),Ol.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 Ef;function vv(){if(Ef)return kt;Ef=1;var e=ic(),n=gv();function r(t){for(var s="https://reactjs.org/docs/error-decoder.html?invariant="+t,a=1;a<arguments.length;a++)s+="&args[]="+encodeURIComponent(arguments[a]);return"Minified React error #"+t+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var o=new Set,l={};function c(t,s){d(t,s),d(t+"Capture",s)}function d(t,s){for(l[t]=s,t=0;t<s.length;t++)o.add(s[t])}var h=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),g=Object.prototype.hasOwnProperty,m=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,v={},k={};function w(t){return g.call(k,t)?!0:g.call(v,t)?!1:m.test(t)?k[t]=!0:(v[t]=!0,!1)}function j(t,s,a,u){if(a!==null&&a.type===0)return!1;switch(typeof s){case"function":case"symbol":return!0;case"boolean":return u?!1:a!==null?!a.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function T(t,s,a,u){if(s===null||typeof s>"u"||j(t,s,a,u))return!0;if(u)return!1;if(a!==null)switch(a.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function S(t,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=t,this.type=s,this.sanitizeURL=p,this.removeEmptyString=y}var E={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){E[t]=new S(t,0,!1,t,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var s=t[0];E[s]=new S(s,1,!1,t[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(t){E[t]=new S(t,2,!1,t.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){E[t]=new S(t,2,!1,t,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){E[t]=new S(t,3,!1,t.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(t){E[t]=new S(t,3,!0,t,null,!1,!1)}),["capture","download"].forEach(function(t){E[t]=new S(t,4,!1,t,null,!1,!1)}),["cols","rows","size","span"].forEach(function(t){E[t]=new S(t,6,!1,t,null,!1,!1)}),["rowSpan","start"].forEach(function(t){E[t]=new S(t,5,!1,t.toLowerCase(),null,!1,!1)});var I=/[\-:]([a-z])/g;function O(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var s=t.replace(I,O);E[s]=new S(s,1,!1,t,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var s=t.replace(I,O);E[s]=new S(s,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(t){var s=t.replace(I,O);E[s]=new S(s,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(t){E[t]=new S(t,1,!1,t.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(t){E[t]=new S(t,1,!1,t.toLowerCase(),null,!0,!0)});function R(t,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?w(s)&&(a===null?t.removeAttribute(s):t.setAttribute(s,""+a)):f.mustUseProperty?t[f.propertyName]=a===null?f.type===3?!1:"":a:(s=f.attributeName,u=f.attributeNamespace,a===null?t.removeAttribute(s):(f=f.type,a=f===3||f===4&&a===!0?"":""+a,u?t.setAttributeNS(u,s,a):t.setAttribute(s,a))))}var X=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,te=Symbol.for("react.element"),B=Symbol.for("react.portal"),se=Symbol.for("react.fragment"),oe=Symbol.for("react.strict_mode"),G=Symbol.for("react.profiler"),ve=Symbol.for("react.provider"),Be=Symbol.for("react.context"),$e=Symbol.for("react.forward_ref"),ie=Symbol.for("react.suspense"),D=Symbol.for("react.suspense_list"),q=Symbol.for("react.memo"),ae=Symbol.for("react.lazy"),Y=Symbol.for("react.offscreen"),U=Symbol.iterator;function P(t){return t===null||typeof t!="object"?null:(t=U&&t[U]||t["@@iterator"],typeof t=="function"?t:null)}var W=Object.assign,$;function _(t){if($===void 0)try{throw Error()}catch(a){var s=a.stack.trim().match(/\n( *(at )?)/);$=s&&s[1]||""}return`
34
+ `+$+t}var he=!1;function pe(t,s){if(!t||he)return"";he=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(s)if(s=function(){throw Error()},Object.defineProperty(s.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(s,[])}catch(L){var u=L}Reflect.construct(t,[],s)}else{try{s.call()}catch(L){u=L}t.call(s.prototype)}else{try{throw Error()}catch(L){u=L}t()}}catch(L){if(L&&u&&typeof L.stack=="string"){for(var f=L.stack.split(`
35
+ `),p=u.stack.split(`
36
+ `),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 t.displayName&&b.includes("<anonymous>")&&(b=b.replace("<anonymous>",t.displayName)),b}while(1<=y&&0<=N);break}}}finally{he=!1,Error.prepareStackTrace=a}return(t=t?t.displayName||t.name:"")?_(t):""}function de(t){switch(t.tag){case 5:return _(t.type);case 16:return _("Lazy");case 13:return _("Suspense");case 19:return _("SuspenseList");case 0:case 2:case 15:return t=pe(t.type,!1),t;case 11:return t=pe(t.type.render,!1),t;case 1:return t=pe(t.type,!0),t;default:return""}}function we(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case se:return"Fragment";case B:return"Portal";case G:return"Profiler";case oe:return"StrictMode";case ie:return"Suspense";case D:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case Be:return(t.displayName||"Context")+".Consumer";case ve:return(t._context.displayName||"Context")+".Provider";case $e:var s=t.render;return t=t.displayName,t||(t=s.displayName||s.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case q:return s=t.displayName||null,s!==null?s:we(t.type)||"Memo";case ae:s=t._payload,t=t._init;try{return we(t(s))}catch{}}return null}function me(t){var s=t.type;switch(t.tag){case 24:return"Cache";case 9:return(s.displayName||"Context")+".Consumer";case 10:return(s._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=s.render,t=t.displayName||t.name||"",s.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return s;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return we(s);case 8:return s===oe?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s}return null}function ye(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function Ce(t){var s=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function ut(t){var s=Ce(t)?"checked":"value",a=Object.getOwnPropertyDescriptor(t.constructor.prototype,s),u=""+t[s];if(!t.hasOwnProperty(s)&&typeof a<"u"&&typeof a.get=="function"&&typeof a.set=="function"){var f=a.get,p=a.set;return Object.defineProperty(t,s,{configurable:!0,get:function(){return f.call(this)},set:function(y){u=""+y,p.call(this,y)}}),Object.defineProperty(t,s,{enumerable:a.enumerable}),{getValue:function(){return u},setValue:function(y){u=""+y},stopTracking:function(){t._valueTracker=null,delete t[s]}}}}function ns(t){t._valueTracker||(t._valueTracker=ut(t))}function Tc(t){if(!t)return!1;var s=t._valueTracker;if(!s)return!0;var a=s.getValue(),u="";return t&&(u=Ce(t)?t.checked?"true":"false":t.value),t=u,t!==a?(s.setValue(t),!0):!1}function Ki(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Bo(t,s){var a=s.checked;return W({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:a??t._wrapperState.initialChecked})}function Ec(t,s){var a=s.defaultValue==null?"":s.defaultValue,u=s.checked!=null?s.checked:s.defaultChecked;a=ye(s.value!=null?s.value:a),t._wrapperState={initialChecked:u,initialValue:a,controlled:s.type==="checkbox"||s.type==="radio"?s.checked!=null:s.value!=null}}function Mc(t,s){s=s.checked,s!=null&&R(t,"checked",s,!1)}function zo(t,s){Mc(t,s);var a=ye(s.value),u=s.type;if(a!=null)u==="number"?(a===0&&t.value===""||t.value!=a)&&(t.value=""+a):t.value!==""+a&&(t.value=""+a);else if(u==="submit"||u==="reset"){t.removeAttribute("value");return}s.hasOwnProperty("value")?Fo(t,s.type,a):s.hasOwnProperty("defaultValue")&&Fo(t,s.type,ye(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(t.defaultChecked=!!s.defaultChecked)}function Ic(t,s,a){if(s.hasOwnProperty("value")||s.hasOwnProperty("defaultValue")){var u=s.type;if(!(u!=="submit"&&u!=="reset"||s.value!==void 0&&s.value!==null))return;s=""+t._wrapperState.initialValue,a||s===t.value||(t.value=s),t.defaultValue=s}a=t.name,a!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,a!==""&&(t.name=a)}function Fo(t,s,a){(s!=="number"||Ki(t.ownerDocument)!==t)&&(a==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+a&&(t.defaultValue=""+a))}var Hs=Array.isArray;function ss(t,s,a,u){if(t=t.options,s){s={};for(var f=0;f<a.length;f++)s["$"+a[f]]=!0;for(a=0;a<t.length;a++)f=s.hasOwnProperty("$"+t[a].value),t[a].selected!==f&&(t[a].selected=f),f&&u&&(t[a].defaultSelected=!0)}else{for(a=""+ye(a),s=null,f=0;f<t.length;f++){if(t[f].value===a){t[f].selected=!0,u&&(t[f].defaultSelected=!0);return}s!==null||t[f].disabled||(s=t[f])}s!==null&&(s.selected=!0)}}function Uo(t,s){if(s.dangerouslySetInnerHTML!=null)throw Error(r(91));return W({},s,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function Ac(t,s){var a=s.value;if(a==null){if(a=s.children,s=s.defaultValue,a!=null){if(s!=null)throw Error(r(92));if(Hs(a)){if(1<a.length)throw Error(r(93));a=a[0]}s=a}s==null&&(s=""),a=s}t._wrapperState={initialValue:ye(a)}}function Rc(t,s){var a=ye(s.value),u=ye(s.defaultValue);a!=null&&(a=""+a,a!==t.value&&(t.value=a),s.defaultValue==null&&t.defaultValue!==a&&(t.defaultValue=a)),u!=null&&(t.defaultValue=""+u)}function Lc(t){var s=t.textContent;s===t._wrapperState.initialValue&&s!==""&&s!==null&&(t.value=s)}function Oc(t){switch(t){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Wo(t,s){return t==null||t==="http://www.w3.org/1999/xhtml"?Oc(s):t==="http://www.w3.org/2000/svg"&&s==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var Gi,_c=(function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(s,a,u,f){MSApp.execUnsafeLocalFunction(function(){return t(s,a,u,f)})}:t})(function(t,s){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=s;else{for(Gi=Gi||document.createElement("div"),Gi.innerHTML="<svg>"+s.valueOf().toString()+"</svg>",s=Gi.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;s.firstChild;)t.appendChild(s.firstChild)}});function Vs(t,s){if(s){var a=t.firstChild;if(a&&a===t.lastChild&&a.nodeType===3){a.nodeValue=s;return}}t.textContent=s}var Ks={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},mp=["Webkit","ms","Moz","O"];Object.keys(Ks).forEach(function(t){mp.forEach(function(s){s=s+t.charAt(0).toUpperCase()+t.substring(1),Ks[s]=Ks[t]})});function Pc(t,s,a){return s==null||typeof s=="boolean"||s===""?"":a||typeof s!="number"||s===0||Ks.hasOwnProperty(t)&&Ks[t]?(""+s).trim():s+"px"}function Dc(t,s){t=t.style;for(var a in s)if(s.hasOwnProperty(a)){var u=a.indexOf("--")===0,f=Pc(a,s[a],u);a==="float"&&(a="cssFloat"),u?t.setProperty(a,f):t[a]=f}}var pp=W({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 Ho(t,s){if(s){if(pp[t]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(r(137,t));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(r(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(r(61))}if(s.style!=null&&typeof s.style!="object")throw Error(r(62))}}function Vo(t,s){if(t.indexOf("-")===-1)return typeof s.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Ko=null;function Go(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var qo=null,is=null,rs=null;function Bc(t){if(t=mi(t)){if(typeof qo!="function")throw Error(r(280));var s=t.stateNode;s&&(s=gr(s),qo(t.stateNode,t.type,s))}}function zc(t){is?rs?rs.push(t):rs=[t]:is=t}function Fc(){if(is){var t=is,s=rs;if(rs=is=null,Bc(t),s)for(t=0;t<s.length;t++)Bc(s[t])}}function Uc(t,s){return t(s)}function Wc(){}var Qo=!1;function Hc(t,s,a){if(Qo)return t(s,a);Qo=!0;try{return Uc(t,s,a)}finally{Qo=!1,(is!==null||rs!==null)&&(Wc(),Fc())}}function Gs(t,s){var a=t.stateNode;if(a===null)return null;var u=gr(a);if(u===null)return null;a=u[s];e:switch(s){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(u=!u.disabled)||(t=t.type,u=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!u;break e;default:t=!1}if(t)return null;if(a&&typeof a!="function")throw Error(r(231,s,typeof a));return a}var Yo=!1;if(h)try{var qs={};Object.defineProperty(qs,"passive",{get:function(){Yo=!0}}),window.addEventListener("test",qs,qs),window.removeEventListener("test",qs,qs)}catch{Yo=!1}function gp(t,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 Qs=!1,qi=null,Qi=!1,Jo=null,vp={onError:function(t){Qs=!0,qi=t}};function yp(t,s,a,u,f,p,y,N,b){Qs=!1,qi=null,gp.apply(vp,arguments)}function kp(t,s,a,u,f,p,y,N,b){if(yp.apply(this,arguments),Qs){if(Qs){var L=qi;Qs=!1,qi=null}else throw Error(r(198));Qi||(Qi=!0,Jo=L)}}function Bn(t){var s=t,a=t;if(t.alternate)for(;s.return;)s=s.return;else{t=s;do s=t,(s.flags&4098)!==0&&(a=s.return),t=s.return;while(t)}return s.tag===3?a:null}function Vc(t){if(t.tag===13){var s=t.memoizedState;if(s===null&&(t=t.alternate,t!==null&&(s=t.memoizedState)),s!==null)return s.dehydrated}return null}function Kc(t){if(Bn(t)!==t)throw Error(r(188))}function xp(t){var s=t.alternate;if(!s){if(s=Bn(t),s===null)throw Error(r(188));return s!==t?null:t}for(var a=t,u=s;;){var f=a.return;if(f===null)break;var p=f.alternate;if(p===null){if(u=f.return,u!==null){a=u;continue}break}if(f.child===p.child){for(p=f.child;p;){if(p===a)return Kc(f),t;if(p===u)return Kc(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?t:s}function Gc(t){return t=xp(t),t!==null?qc(t):null}function qc(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var s=qc(t);if(s!==null)return s;t=t.sibling}return null}var Qc=n.unstable_scheduleCallback,Yc=n.unstable_cancelCallback,wp=n.unstable_shouldYield,jp=n.unstable_requestPaint,ze=n.unstable_now,Sp=n.unstable_getCurrentPriorityLevel,Xo=n.unstable_ImmediatePriority,Jc=n.unstable_UserBlockingPriority,Yi=n.unstable_NormalPriority,Np=n.unstable_LowPriority,Xc=n.unstable_IdlePriority,Ji=null,Wt=null;function bp(t){if(Wt&&typeof Wt.onCommitFiberRoot=="function")try{Wt.onCommitFiberRoot(Ji,t,void 0,(t.current.flags&128)===128)}catch{}}var Lt=Math.clz32?Math.clz32:Tp,Cp=Math.log,$p=Math.LN2;function Tp(t){return t>>>=0,t===0?32:31-(Cp(t)/$p|0)|0}var Xi=64,Zi=4194304;function Ys(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function er(t,s){var a=t.pendingLanes;if(a===0)return 0;var u=0,f=t.suspendedLanes,p=t.pingedLanes,y=a&268435455;if(y!==0){var N=y&~f;N!==0?u=Ys(N):(p&=y,p!==0&&(u=Ys(p)))}else y=a&~f,y!==0?u=Ys(y):p!==0&&(u=Ys(p));if(u===0)return 0;if(s!==0&&s!==u&&(s&f)===0&&(f=u&-u,p=s&-s,f>=p||f===16&&(p&4194240)!==0))return s;if((u&4)!==0&&(u|=a&16),s=t.entangledLanes,s!==0)for(t=t.entanglements,s&=u;0<s;)a=31-Lt(s),f=1<<a,u|=t[a],s&=~f;return u}function Ep(t,s){switch(t){case 1:case 2:case 4:return s+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return s+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Mp(t,s){for(var a=t.suspendedLanes,u=t.pingedLanes,f=t.expirationTimes,p=t.pendingLanes;0<p;){var y=31-Lt(p),N=1<<y,b=f[y];b===-1?((N&a)===0||(N&u)!==0)&&(f[y]=Ep(N,s)):b<=s&&(t.expiredLanes|=N),p&=~N}}function Zo(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function Zc(){var t=Xi;return Xi<<=1,(Xi&4194240)===0&&(Xi=64),t}function ea(t){for(var s=[],a=0;31>a;a++)s.push(t);return s}function Js(t,s,a){t.pendingLanes|=s,s!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,s=31-Lt(s),t[s]=a}function Ip(t,s){var a=t.pendingLanes&~s;t.pendingLanes=s,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=s,t.mutableReadLanes&=s,t.entangledLanes&=s,s=t.entanglements;var u=t.eventTimes;for(t=t.expirationTimes;0<a;){var f=31-Lt(a),p=1<<f;s[f]=0,u[f]=-1,t[f]=-1,a&=~p}}function ta(t,s){var a=t.entangledLanes|=s;for(t=t.entanglements;a;){var u=31-Lt(a),f=1<<u;f&s|t[u]&s&&(t[u]|=s),a&=~f}}var be=0;function eu(t){return t&=-t,1<t?4<t?(t&268435455)!==0?16:536870912:4:1}var tu,na,nu,su,iu,sa=!1,tr=[],pn=null,gn=null,vn=null,Xs=new Map,Zs=new Map,yn=[],Ap="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 ru(t,s){switch(t){case"focusin":case"focusout":pn=null;break;case"dragenter":case"dragleave":gn=null;break;case"mouseover":case"mouseout":vn=null;break;case"pointerover":case"pointerout":Xs.delete(s.pointerId);break;case"gotpointercapture":case"lostpointercapture":Zs.delete(s.pointerId)}}function ei(t,s,a,u,f,p){return t===null||t.nativeEvent!==p?(t={blockedOn:s,domEventName:a,eventSystemFlags:u,nativeEvent:p,targetContainers:[f]},s!==null&&(s=mi(s),s!==null&&na(s)),t):(t.eventSystemFlags|=u,s=t.targetContainers,f!==null&&s.indexOf(f)===-1&&s.push(f),t)}function Rp(t,s,a,u,f){switch(s){case"focusin":return pn=ei(pn,t,s,a,u,f),!0;case"dragenter":return gn=ei(gn,t,s,a,u,f),!0;case"mouseover":return vn=ei(vn,t,s,a,u,f),!0;case"pointerover":var p=f.pointerId;return Xs.set(p,ei(Xs.get(p)||null,t,s,a,u,f)),!0;case"gotpointercapture":return p=f.pointerId,Zs.set(p,ei(Zs.get(p)||null,t,s,a,u,f)),!0}return!1}function ou(t){var s=zn(t.target);if(s!==null){var a=Bn(s);if(a!==null){if(s=a.tag,s===13){if(s=Vc(a),s!==null){t.blockedOn=s,iu(t.priority,function(){nu(a)});return}}else if(s===3&&a.stateNode.current.memoizedState.isDehydrated){t.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}t.blockedOn=null}function nr(t){if(t.blockedOn!==null)return!1;for(var s=t.targetContainers;0<s.length;){var a=ra(t.domEventName,t.eventSystemFlags,s[0],t.nativeEvent);if(a===null){a=t.nativeEvent;var u=new a.constructor(a.type,a);Ko=u,a.target.dispatchEvent(u),Ko=null}else return s=mi(a),s!==null&&na(s),t.blockedOn=a,!1;s.shift()}return!0}function au(t,s,a){nr(t)&&a.delete(s)}function Lp(){sa=!1,pn!==null&&nr(pn)&&(pn=null),gn!==null&&nr(gn)&&(gn=null),vn!==null&&nr(vn)&&(vn=null),Xs.forEach(au),Zs.forEach(au)}function ti(t,s){t.blockedOn===s&&(t.blockedOn=null,sa||(sa=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,Lp)))}function ni(t){function s(f){return ti(f,t)}if(0<tr.length){ti(tr[0],t);for(var a=1;a<tr.length;a++){var u=tr[a];u.blockedOn===t&&(u.blockedOn=null)}}for(pn!==null&&ti(pn,t),gn!==null&&ti(gn,t),vn!==null&&ti(vn,t),Xs.forEach(s),Zs.forEach(s),a=0;a<yn.length;a++)u=yn[a],u.blockedOn===t&&(u.blockedOn=null);for(;0<yn.length&&(a=yn[0],a.blockedOn===null);)ou(a),a.blockedOn===null&&yn.shift()}var os=X.ReactCurrentBatchConfig,sr=!0;function Op(t,s,a,u){var f=be,p=os.transition;os.transition=null;try{be=1,ia(t,s,a,u)}finally{be=f,os.transition=p}}function _p(t,s,a,u){var f=be,p=os.transition;os.transition=null;try{be=4,ia(t,s,a,u)}finally{be=f,os.transition=p}}function ia(t,s,a,u){if(sr){var f=ra(t,s,a,u);if(f===null)ja(t,s,u,ir,a),ru(t,u);else if(Rp(f,t,s,a,u))u.stopPropagation();else if(ru(t,u),s&4&&-1<Ap.indexOf(t)){for(;f!==null;){var p=mi(f);if(p!==null&&tu(p),p=ra(t,s,a,u),p===null&&ja(t,s,u,ir,a),p===f)break;f=p}f!==null&&u.stopPropagation()}else ja(t,s,u,null,a)}}var ir=null;function ra(t,s,a,u){if(ir=null,t=Go(u),t=zn(t),t!==null)if(s=Bn(t),s===null)t=null;else if(a=s.tag,a===13){if(t=Vc(s),t!==null)return t;t=null}else if(a===3){if(s.stateNode.current.memoizedState.isDehydrated)return s.tag===3?s.stateNode.containerInfo:null;t=null}else s!==t&&(t=null);return ir=t,null}function lu(t){switch(t){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Sp()){case Xo:return 1;case Jc:return 4;case Yi:case Np:return 16;case Xc:return 536870912;default:return 16}default:return 16}}var kn=null,oa=null,rr=null;function cu(){if(rr)return rr;var t,s=oa,a=s.length,u,f="value"in kn?kn.value:kn.textContent,p=f.length;for(t=0;t<a&&s[t]===f[t];t++);var y=a-t;for(u=1;u<=y&&s[a-u]===f[p-u];u++);return rr=f.slice(t,1<u?1-u:void 0)}function or(t){var s=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&s===13&&(t=13)):t=s,t===10&&(t=13),32<=t||t===13?t:0}function ar(){return!0}function uu(){return!1}function wt(t){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 t)t.hasOwnProperty(N)&&(a=t[N],this[N]=a?a(p):p[N]);return this.isDefaultPrevented=(p.defaultPrevented!=null?p.defaultPrevented:p.returnValue===!1)?ar:uu,this.isPropagationStopped=uu,this}return W(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=ar)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=ar)},persist:function(){},isPersistent:ar}),s}var as={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},aa=wt(as),si=W({},as,{view:0,detail:0}),Pp=wt(si),la,ca,ii,lr=W({},si,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:da,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==ii&&(ii&&t.type==="mousemove"?(la=t.screenX-ii.screenX,ca=t.screenY-ii.screenY):ca=la=0,ii=t),la)},movementY:function(t){return"movementY"in t?t.movementY:ca}}),du=wt(lr),Dp=W({},lr,{dataTransfer:0}),Bp=wt(Dp),zp=W({},si,{relatedTarget:0}),ua=wt(zp),Fp=W({},as,{animationName:0,elapsedTime:0,pseudoElement:0}),Up=wt(Fp),Wp=W({},as,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),Hp=wt(Wp),Vp=W({},as,{data:0}),fu=wt(Vp),Kp={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Gp={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"},qp={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Qp(t){var s=this.nativeEvent;return s.getModifierState?s.getModifierState(t):(t=qp[t])?!!s[t]:!1}function da(){return Qp}var Yp=W({},si,{key:function(t){if(t.key){var s=Kp[t.key]||t.key;if(s!=="Unidentified")return s}return t.type==="keypress"?(t=or(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?Gp[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:da,charCode:function(t){return t.type==="keypress"?or(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?or(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),Jp=wt(Yp),Xp=W({},lr,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),hu=wt(Xp),Zp=W({},si,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:da}),eg=wt(Zp),tg=W({},as,{propertyName:0,elapsedTime:0,pseudoElement:0}),ng=wt(tg),sg=W({},lr,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),ig=wt(sg),rg=[9,13,27,32],fa=h&&"CompositionEvent"in window,ri=null;h&&"documentMode"in document&&(ri=document.documentMode);var og=h&&"TextEvent"in window&&!ri,mu=h&&(!fa||ri&&8<ri&&11>=ri),pu=" ",gu=!1;function vu(t,s){switch(t){case"keyup":return rg.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function yu(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var ls=!1;function ag(t,s){switch(t){case"compositionend":return yu(s);case"keypress":return s.which!==32?null:(gu=!0,pu);case"textInput":return t=s.data,t===pu&&gu?null:t;default:return null}}function lg(t,s){if(ls)return t==="compositionend"||!fa&&vu(t,s)?(t=cu(),rr=oa=kn=null,ls=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1<s.char.length)return s.char;if(s.which)return String.fromCharCode(s.which)}return null;case"compositionend":return mu&&s.locale!=="ko"?null:s.data;default:return null}}var cg={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 ku(t){var s=t&&t.nodeName&&t.nodeName.toLowerCase();return s==="input"?!!cg[t.type]:s==="textarea"}function xu(t,s,a,u){zc(u),s=hr(s,"onChange"),0<s.length&&(a=new aa("onChange","change",null,a,u),t.push({event:a,listeners:s}))}var oi=null,ai=null;function ug(t){Du(t,0)}function cr(t){var s=hs(t);if(Tc(s))return t}function dg(t,s){if(t==="change")return s}var wu=!1;if(h){var ha;if(h){var ma="oninput"in document;if(!ma){var ju=document.createElement("div");ju.setAttribute("oninput","return;"),ma=typeof ju.oninput=="function"}ha=ma}else ha=!1;wu=ha&&(!document.documentMode||9<document.documentMode)}function Su(){oi&&(oi.detachEvent("onpropertychange",Nu),ai=oi=null)}function Nu(t){if(t.propertyName==="value"&&cr(ai)){var s=[];xu(s,ai,t,Go(t)),Hc(ug,s)}}function fg(t,s,a){t==="focusin"?(Su(),oi=s,ai=a,oi.attachEvent("onpropertychange",Nu)):t==="focusout"&&Su()}function hg(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return cr(ai)}function mg(t,s){if(t==="click")return cr(s)}function pg(t,s){if(t==="input"||t==="change")return cr(s)}function gg(t,s){return t===s&&(t!==0||1/t===1/s)||t!==t&&s!==s}var Ot=typeof Object.is=="function"?Object.is:gg;function li(t,s){if(Ot(t,s))return!0;if(typeof t!="object"||t===null||typeof s!="object"||s===null)return!1;var a=Object.keys(t),u=Object.keys(s);if(a.length!==u.length)return!1;for(u=0;u<a.length;u++){var f=a[u];if(!g.call(s,f)||!Ot(t[f],s[f]))return!1}return!0}function bu(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function Cu(t,s){var a=bu(t);t=0;for(var u;a;){if(a.nodeType===3){if(u=t+a.textContent.length,t<=s&&u>=s)return{node:a,offset:s-t};t=u}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=bu(a)}}function $u(t,s){return t&&s?t===s?!0:t&&t.nodeType===3?!1:s&&s.nodeType===3?$u(t,s.parentNode):"contains"in t?t.contains(s):t.compareDocumentPosition?!!(t.compareDocumentPosition(s)&16):!1:!1}function Tu(){for(var t=window,s=Ki();s instanceof t.HTMLIFrameElement;){try{var a=typeof s.contentWindow.location.href=="string"}catch{a=!1}if(a)t=s.contentWindow;else break;s=Ki(t.document)}return s}function pa(t){var s=t&&t.nodeName&&t.nodeName.toLowerCase();return s&&(s==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||s==="textarea"||t.contentEditable==="true")}function vg(t){var s=Tu(),a=t.focusedElem,u=t.selectionRange;if(s!==a&&a&&a.ownerDocument&&$u(a.ownerDocument.documentElement,a)){if(u!==null&&pa(a)){if(s=u.start,t=u.end,t===void 0&&(t=s),"selectionStart"in a)a.selectionStart=s,a.selectionEnd=Math.min(t,a.value.length);else if(t=(s=a.ownerDocument||document)&&s.defaultView||window,t.getSelection){t=t.getSelection();var f=a.textContent.length,p=Math.min(u.start,f);u=u.end===void 0?p:Math.min(u.end,f),!t.extend&&p>u&&(f=u,u=p,p=f),f=Cu(a,p);var y=Cu(a,u);f&&y&&(t.rangeCount!==1||t.anchorNode!==f.node||t.anchorOffset!==f.offset||t.focusNode!==y.node||t.focusOffset!==y.offset)&&(s=s.createRange(),s.setStart(f.node,f.offset),t.removeAllRanges(),p>u?(t.addRange(s),t.extend(y.node,y.offset)):(s.setEnd(y.node,y.offset),t.addRange(s)))}}for(s=[],t=a;t=t.parentNode;)t.nodeType===1&&s.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof a.focus=="function"&&a.focus(),a=0;a<s.length;a++)t=s[a],t.element.scrollLeft=t.left,t.element.scrollTop=t.top}}var yg=h&&"documentMode"in document&&11>=document.documentMode,cs=null,ga=null,ci=null,va=!1;function Eu(t,s,a){var u=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;va||cs==null||cs!==Ki(u)||(u=cs,"selectionStart"in u&&pa(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}),ci&&li(ci,u)||(ci=u,u=hr(ga,"onSelect"),0<u.length&&(s=new aa("onSelect","select",null,s,a),t.push({event:s,listeners:u}),s.target=cs)))}function ur(t,s){var a={};return a[t.toLowerCase()]=s.toLowerCase(),a["Webkit"+t]="webkit"+s,a["Moz"+t]="moz"+s,a}var us={animationend:ur("Animation","AnimationEnd"),animationiteration:ur("Animation","AnimationIteration"),animationstart:ur("Animation","AnimationStart"),transitionend:ur("Transition","TransitionEnd")},ya={},Mu={};h&&(Mu=document.createElement("div").style,"AnimationEvent"in window||(delete us.animationend.animation,delete us.animationiteration.animation,delete us.animationstart.animation),"TransitionEvent"in window||delete us.transitionend.transition);function dr(t){if(ya[t])return ya[t];if(!us[t])return t;var s=us[t],a;for(a in s)if(s.hasOwnProperty(a)&&a in Mu)return ya[t]=s[a];return t}var Iu=dr("animationend"),Au=dr("animationiteration"),Ru=dr("animationstart"),Lu=dr("transitionend"),Ou=new Map,_u="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 xn(t,s){Ou.set(t,s),c(s,[t])}for(var ka=0;ka<_u.length;ka++){var xa=_u[ka],kg=xa.toLowerCase(),xg=xa[0].toUpperCase()+xa.slice(1);xn(kg,"on"+xg)}xn(Iu,"onAnimationEnd"),xn(Au,"onAnimationIteration"),xn(Ru,"onAnimationStart"),xn("dblclick","onDoubleClick"),xn("focusin","onFocus"),xn("focusout","onBlur"),xn(Lu,"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 ui="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(" "),wg=new Set("cancel close invalid load scroll toggle".split(" ").concat(ui));function Pu(t,s,a){var u=t.type||"unknown-event";t.currentTarget=a,kp(u,s,void 0,t),t.currentTarget=null}function Du(t,s){s=(s&4)!==0;for(var a=0;a<t.length;a++){var u=t[a],f=u.event;u=u.listeners;e:{var p=void 0;if(s)for(var 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;Pu(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;Pu(f,N,L),p=b}}}if(Qi)throw t=Jo,Qi=!1,Jo=null,t}function Ee(t,s){var a=s[Ta];a===void 0&&(a=s[Ta]=new Set);var u=t+"__bubble";a.has(u)||(Bu(s,t,2,!1),a.add(u))}function wa(t,s,a){var u=0;s&&(u|=4),Bu(a,t,u,s)}var fr="_reactListening"+Math.random().toString(36).slice(2);function di(t){if(!t[fr]){t[fr]=!0,o.forEach(function(a){a!=="selectionchange"&&(wg.has(a)||wa(a,!1,t),wa(a,!0,t))});var s=t.nodeType===9?t:t.ownerDocument;s===null||s[fr]||(s[fr]=!0,wa("selectionchange",!1,s))}}function Bu(t,s,a,u){switch(lu(s)){case 1:var f=Op;break;case 4:f=_p;break;default:f=ia}a=f.bind(null,s,a,t),f=void 0,!Yo||s!=="touchstart"&&s!=="touchmove"&&s!=="wheel"||(f=!0),u?f!==void 0?t.addEventListener(s,a,{capture:!0,passive:f}):t.addEventListener(s,a,!0):f!==void 0?t.addEventListener(s,a,{passive:f}):t.addEventListener(s,a,!1)}function ja(t,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=zn(N),y===null)return;if(b=y.tag,b===5||b===6){u=p=y;continue e}N=N.parentNode}}u=u.return}Hc(function(){var L=p,F=Go(a),H=[];e:{var z=Ou.get(t);if(z!==void 0){var Q=aa,Z=t;switch(t){case"keypress":if(or(a)===0)break e;case"keydown":case"keyup":Q=Jp;break;case"focusin":Z="focus",Q=ua;break;case"focusout":Z="blur",Q=ua;break;case"beforeblur":case"afterblur":Q=ua;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":Q=du;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Q=Bp;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Q=eg;break;case Iu:case Au:case Ru:Q=Up;break;case Lu:Q=ng;break;case"scroll":Q=Pp;break;case"wheel":Q=ig;break;case"copy":case"cut":case"paste":Q=Hp;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Q=hu}var ne=(s&4)!==0,Fe=!ne&&t==="scroll",M=ne?z!==null?z+"Capture":null:z;ne=[];for(var C=L,A;C!==null;){A=C;var V=A.stateNode;if(A.tag===5&&V!==null&&(A=V,M!==null&&(V=Gs(C,M),V!=null&&ne.push(fi(C,V,A)))),Fe)break;C=C.return}0<ne.length&&(z=new Q(z,Z,null,a,F),H.push({event:z,listeners:ne}))}}if((s&7)===0){e:{if(z=t==="mouseover"||t==="pointerover",Q=t==="mouseout"||t==="pointerout",z&&a!==Ko&&(Z=a.relatedTarget||a.fromElement)&&(zn(Z)||Z[nn]))break e;if((Q||z)&&(z=F.window===F?F:(z=F.ownerDocument)?z.defaultView||z.parentWindow:window,Q?(Z=a.relatedTarget||a.toElement,Q=L,Z=Z?zn(Z):null,Z!==null&&(Fe=Bn(Z),Z!==Fe||Z.tag!==5&&Z.tag!==6)&&(Z=null)):(Q=null,Z=L),Q!==Z)){if(ne=du,V="onMouseLeave",M="onMouseEnter",C="mouse",(t==="pointerout"||t==="pointerover")&&(ne=hu,V="onPointerLeave",M="onPointerEnter",C="pointer"),Fe=Q==null?z:hs(Q),A=Z==null?z:hs(Z),z=new ne(V,C+"leave",Q,a,F),z.target=Fe,z.relatedTarget=A,V=null,zn(F)===L&&(ne=new ne(M,C+"enter",Z,a,F),ne.target=A,ne.relatedTarget=Fe,V=ne),Fe=V,Q&&Z)t:{for(ne=Q,M=Z,C=0,A=ne;A;A=ds(A))C++;for(A=0,V=M;V;V=ds(V))A++;for(;0<C-A;)ne=ds(ne),C--;for(;0<A-C;)M=ds(M),A--;for(;C--;){if(ne===M||M!==null&&ne===M.alternate)break t;ne=ds(ne),M=ds(M)}ne=null}else ne=null;Q!==null&&zu(H,z,Q,ne,!1),Z!==null&&Fe!==null&&zu(H,Fe,Z,ne,!0)}}e:{if(z=L?hs(L):window,Q=z.nodeName&&z.nodeName.toLowerCase(),Q==="select"||Q==="input"&&z.type==="file")var re=dg;else if(ku(z))if(wu)re=pg;else{re=hg;var le=fg}else(Q=z.nodeName)&&Q.toLowerCase()==="input"&&(z.type==="checkbox"||z.type==="radio")&&(re=mg);if(re&&(re=re(t,L))){xu(H,re,a,F);break e}le&&le(t,z,L),t==="focusout"&&(le=z._wrapperState)&&le.controlled&&z.type==="number"&&Fo(z,"number",z.value)}switch(le=L?hs(L):window,t){case"focusin":(ku(le)||le.contentEditable==="true")&&(cs=le,ga=L,ci=null);break;case"focusout":ci=ga=cs=null;break;case"mousedown":va=!0;break;case"contextmenu":case"mouseup":case"dragend":va=!1,Eu(H,a,F);break;case"selectionchange":if(yg)break;case"keydown":case"keyup":Eu(H,a,F)}var ce;if(fa)e:{switch(t){case"compositionstart":var fe="onCompositionStart";break e;case"compositionend":fe="onCompositionEnd";break e;case"compositionupdate":fe="onCompositionUpdate";break e}fe=void 0}else ls?vu(t,a)&&(fe="onCompositionEnd"):t==="keydown"&&a.keyCode===229&&(fe="onCompositionStart");fe&&(mu&&a.locale!=="ko"&&(ls||fe!=="onCompositionStart"?fe==="onCompositionEnd"&&ls&&(ce=cu()):(kn=F,oa="value"in kn?kn.value:kn.textContent,ls=!0)),le=hr(L,fe),0<le.length&&(fe=new fu(fe,t,null,a,F),H.push({event:fe,listeners:le}),ce?fe.data=ce:(ce=yu(a),ce!==null&&(fe.data=ce)))),(ce=og?ag(t,a):lg(t,a))&&(L=hr(L,"onBeforeInput"),0<L.length&&(F=new fu("onBeforeInput","beforeinput",null,a,F),H.push({event:F,listeners:L}),F.data=ce))}Du(H,s)})}function fi(t,s,a){return{instance:t,listener:s,currentTarget:a}}function hr(t,s){for(var a=s+"Capture",u=[];t!==null;){var f=t,p=f.stateNode;f.tag===5&&p!==null&&(f=p,p=Gs(t,a),p!=null&&u.unshift(fi(t,p,f)),p=Gs(t,s),p!=null&&u.push(fi(t,p,f))),t=t.return}return u}function ds(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5);return t||null}function zu(t,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=Gs(a,p),b!=null&&y.unshift(fi(a,b,N))):f||(b=Gs(a,p),b!=null&&y.push(fi(a,b,N)))),a=a.return}y.length!==0&&t.push({event:s,listeners:y})}var jg=/\r\n?/g,Sg=/\u0000|\uFFFD/g;function Fu(t){return(typeof t=="string"?t:""+t).replace(jg,`
38
+ `).replace(Sg,"")}function mr(t,s,a){if(s=Fu(s),Fu(t)!==s&&a)throw Error(r(425))}function pr(){}var Sa=null,Na=null;function ba(t,s){return t==="textarea"||t==="noscript"||typeof s.children=="string"||typeof s.children=="number"||typeof s.dangerouslySetInnerHTML=="object"&&s.dangerouslySetInnerHTML!==null&&s.dangerouslySetInnerHTML.__html!=null}var Ca=typeof setTimeout=="function"?setTimeout:void 0,Ng=typeof clearTimeout=="function"?clearTimeout:void 0,Uu=typeof Promise=="function"?Promise:void 0,bg=typeof queueMicrotask=="function"?queueMicrotask:typeof Uu<"u"?function(t){return Uu.resolve(null).then(t).catch(Cg)}:Ca;function Cg(t){setTimeout(function(){throw t})}function $a(t,s){var a=s,u=0;do{var f=a.nextSibling;if(t.removeChild(a),f&&f.nodeType===8)if(a=f.data,a==="/$"){if(u===0){t.removeChild(f),ni(s);return}u--}else a!=="$"&&a!=="$?"&&a!=="$!"||u++;a=f}while(a);ni(s)}function wn(t){for(;t!=null;t=t.nextSibling){var s=t.nodeType;if(s===1||s===3)break;if(s===8){if(s=t.data,s==="$"||s==="$!"||s==="$?")break;if(s==="/$")return null}}return t}function Wu(t){t=t.previousSibling;for(var s=0;t;){if(t.nodeType===8){var a=t.data;if(a==="$"||a==="$!"||a==="$?"){if(s===0)return t;s--}else a==="/$"&&s++}t=t.previousSibling}return null}var fs=Math.random().toString(36).slice(2),Ht="__reactFiber$"+fs,hi="__reactProps$"+fs,nn="__reactContainer$"+fs,Ta="__reactEvents$"+fs,$g="__reactListeners$"+fs,Tg="__reactHandles$"+fs;function zn(t){var s=t[Ht];if(s)return s;for(var a=t.parentNode;a;){if(s=a[nn]||a[Ht]){if(a=s.alternate,s.child!==null||a!==null&&a.child!==null)for(t=Wu(t);t!==null;){if(a=t[Ht])return a;t=Wu(t)}return s}t=a,a=t.parentNode}return null}function mi(t){return t=t[Ht]||t[nn],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function hs(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(r(33))}function gr(t){return t[hi]||null}var Ea=[],ms=-1;function jn(t){return{current:t}}function Me(t){0>ms||(t.current=Ea[ms],Ea[ms]=null,ms--)}function Te(t,s){ms++,Ea[ms]=t.current,t.current=s}var Sn={},rt=jn(Sn),mt=jn(!1),Fn=Sn;function ps(t,s){var a=t.type.contextTypes;if(!a)return Sn;var u=t.stateNode;if(u&&u.__reactInternalMemoizedUnmaskedChildContext===s)return u.__reactInternalMemoizedMaskedChildContext;var f={},p;for(p in a)f[p]=s[p];return u&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=s,t.__reactInternalMemoizedMaskedChildContext=f),f}function pt(t){return t=t.childContextTypes,t!=null}function vr(){Me(mt),Me(rt)}function Hu(t,s,a){if(rt.current!==Sn)throw Error(r(168));Te(rt,s),Te(mt,a)}function Vu(t,s,a){var u=t.stateNode;if(s=s.childContextTypes,typeof u.getChildContext!="function")return a;u=u.getChildContext();for(var f in u)if(!(f in s))throw Error(r(108,me(t)||"Unknown",f));return W({},a,u)}function yr(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Sn,Fn=rt.current,Te(rt,t),Te(mt,mt.current),!0}function Ku(t,s,a){var u=t.stateNode;if(!u)throw Error(r(169));a?(t=Vu(t,s,Fn),u.__reactInternalMemoizedMergedChildContext=t,Me(mt),Me(rt),Te(rt,t)):Me(mt),Te(mt,a)}var sn=null,kr=!1,Ma=!1;function Gu(t){sn===null?sn=[t]:sn.push(t)}function Eg(t){kr=!0,Gu(t)}function Nn(){if(!Ma&&sn!==null){Ma=!0;var t=0,s=be;try{var a=sn;for(be=1;t<a.length;t++){var u=a[t];do u=u(!0);while(u!==null)}sn=null,kr=!1}catch(f){throw sn!==null&&(sn=sn.slice(t+1)),Qc(Xo,Nn),f}finally{be=s,Ma=!1}}return null}var gs=[],vs=0,xr=null,wr=0,Ct=[],$t=0,Un=null,rn=1,on="";function Wn(t,s){gs[vs++]=wr,gs[vs++]=xr,xr=t,wr=s}function qu(t,s,a){Ct[$t++]=rn,Ct[$t++]=on,Ct[$t++]=Un,Un=t;var u=rn;t=on;var f=32-Lt(u)-1;u&=~(1<<f),a+=1;var p=32-Lt(s)+f;if(30<p){var y=f-f%5;p=(u&(1<<y)-1).toString(32),u>>=y,f-=y,rn=1<<32-Lt(s)+f|a<<f|u,on=p+t}else rn=1<<p|a<<f|u,on=t}function Ia(t){t.return!==null&&(Wn(t,1),qu(t,1,0))}function Aa(t){for(;t===xr;)xr=gs[--vs],gs[vs]=null,wr=gs[--vs],gs[vs]=null;for(;t===Un;)Un=Ct[--$t],Ct[$t]=null,on=Ct[--$t],Ct[$t]=null,rn=Ct[--$t],Ct[$t]=null}var jt=null,St=null,Ae=!1,_t=null;function Qu(t,s){var a=It(5,null,null,0);a.elementType="DELETED",a.stateNode=s,a.return=t,s=t.deletions,s===null?(t.deletions=[a],t.flags|=16):s.push(a)}function Yu(t,s){switch(t.tag){case 5:var a=t.type;return s=s.nodeType!==1||a.toLowerCase()!==s.nodeName.toLowerCase()?null:s,s!==null?(t.stateNode=s,jt=t,St=wn(s.firstChild),!0):!1;case 6:return s=t.pendingProps===""||s.nodeType!==3?null:s,s!==null?(t.stateNode=s,jt=t,St=null,!0):!1;case 13:return s=s.nodeType!==8?null:s,s!==null?(a=Un!==null?{id:rn,overflow:on}:null,t.memoizedState={dehydrated:s,treeContext:a,retryLane:1073741824},a=It(18,null,null,0),a.stateNode=s,a.return=t,t.child=a,jt=t,St=null,!0):!1;default:return!1}}function Ra(t){return(t.mode&1)!==0&&(t.flags&128)===0}function La(t){if(Ae){var s=St;if(s){var a=s;if(!Yu(t,s)){if(Ra(t))throw Error(r(418));s=wn(a.nextSibling);var u=jt;s&&Yu(t,s)?Qu(u,a):(t.flags=t.flags&-4097|2,Ae=!1,jt=t)}}else{if(Ra(t))throw Error(r(418));t.flags=t.flags&-4097|2,Ae=!1,jt=t}}}function Ju(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;jt=t}function jr(t){if(t!==jt)return!1;if(!Ae)return Ju(t),Ae=!0,!1;var s;if((s=t.tag!==3)&&!(s=t.tag!==5)&&(s=t.type,s=s!=="head"&&s!=="body"&&!ba(t.type,t.memoizedProps)),s&&(s=St)){if(Ra(t))throw Xu(),Error(r(418));for(;s;)Qu(t,s),s=wn(s.nextSibling)}if(Ju(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(r(317));e:{for(t=t.nextSibling,s=0;t;){if(t.nodeType===8){var a=t.data;if(a==="/$"){if(s===0){St=wn(t.nextSibling);break e}s--}else a!=="$"&&a!=="$!"&&a!=="$?"||s++}t=t.nextSibling}St=null}}else St=jt?wn(t.stateNode.nextSibling):null;return!0}function Xu(){for(var t=St;t;)t=wn(t.nextSibling)}function ys(){St=jt=null,Ae=!1}function Oa(t){_t===null?_t=[t]:_t.push(t)}var Mg=X.ReactCurrentBatchConfig;function pi(t,s,a){if(t=a.ref,t!==null&&typeof t!="function"&&typeof t!="object"){if(a._owner){if(a=a._owner,a){if(a.tag!==1)throw Error(r(309));var u=a.stateNode}if(!u)throw Error(r(147,t));var f=u,p=""+t;return s!==null&&s.ref!==null&&typeof s.ref=="function"&&s.ref._stringRef===p?s.ref:(s=function(y){var N=f.refs;y===null?delete N[p]:N[p]=y},s._stringRef=p,s)}if(typeof t!="string")throw Error(r(284));if(!a._owner)throw Error(r(290,t))}return t}function Sr(t,s){throw t=Object.prototype.toString.call(s),Error(r(31,t==="[object Object]"?"object with keys {"+Object.keys(s).join(", ")+"}":t))}function Zu(t){var s=t._init;return s(t._payload)}function ed(t){function s(M,C){if(t){var A=M.deletions;A===null?(M.deletions=[C],M.flags|=16):A.push(C)}}function a(M,C){if(!t)return null;for(;C!==null;)s(M,C),C=C.sibling;return null}function u(M,C){for(M=new Map;C!==null;)C.key!==null?M.set(C.key,C):M.set(C.index,C),C=C.sibling;return M}function f(M,C){return M=An(M,C),M.index=0,M.sibling=null,M}function p(M,C,A){return M.index=A,t?(A=M.alternate,A!==null?(A=A.index,A<C?(M.flags|=2,C):A):(M.flags|=2,C)):(M.flags|=1048576,C)}function y(M){return t&&M.alternate===null&&(M.flags|=2),M}function N(M,C,A,V){return C===null||C.tag!==6?(C=Cl(A,M.mode,V),C.return=M,C):(C=f(C,A),C.return=M,C)}function b(M,C,A,V){var re=A.type;return re===se?F(M,C,A.props.children,V,A.key):C!==null&&(C.elementType===re||typeof re=="object"&&re!==null&&re.$$typeof===ae&&Zu(re)===C.type)?(V=f(C,A.props),V.ref=pi(M,C,A),V.return=M,V):(V=Gr(A.type,A.key,A.props,null,M.mode,V),V.ref=pi(M,C,A),V.return=M,V)}function L(M,C,A,V){return C===null||C.tag!==4||C.stateNode.containerInfo!==A.containerInfo||C.stateNode.implementation!==A.implementation?(C=$l(A,M.mode,V),C.return=M,C):(C=f(C,A.children||[]),C.return=M,C)}function F(M,C,A,V,re){return C===null||C.tag!==7?(C=Jn(A,M.mode,V,re),C.return=M,C):(C=f(C,A),C.return=M,C)}function H(M,C,A){if(typeof C=="string"&&C!==""||typeof C=="number")return C=Cl(""+C,M.mode,A),C.return=M,C;if(typeof C=="object"&&C!==null){switch(C.$$typeof){case te:return A=Gr(C.type,C.key,C.props,null,M.mode,A),A.ref=pi(M,null,C),A.return=M,A;case B:return C=$l(C,M.mode,A),C.return=M,C;case ae:var V=C._init;return H(M,V(C._payload),A)}if(Hs(C)||P(C))return C=Jn(C,M.mode,A,null),C.return=M,C;Sr(M,C)}return null}function z(M,C,A,V){var re=C!==null?C.key:null;if(typeof A=="string"&&A!==""||typeof A=="number")return re!==null?null:N(M,C,""+A,V);if(typeof A=="object"&&A!==null){switch(A.$$typeof){case te:return A.key===re?b(M,C,A,V):null;case B:return A.key===re?L(M,C,A,V):null;case ae:return re=A._init,z(M,C,re(A._payload),V)}if(Hs(A)||P(A))return re!==null?null:F(M,C,A,V,null);Sr(M,A)}return null}function Q(M,C,A,V,re){if(typeof V=="string"&&V!==""||typeof V=="number")return M=M.get(A)||null,N(C,M,""+V,re);if(typeof V=="object"&&V!==null){switch(V.$$typeof){case te:return M=M.get(V.key===null?A:V.key)||null,b(C,M,V,re);case B:return M=M.get(V.key===null?A:V.key)||null,L(C,M,V,re);case ae:var le=V._init;return Q(M,C,A,le(V._payload),re)}if(Hs(V)||P(V))return M=M.get(A)||null,F(C,M,V,re,null);Sr(C,V)}return null}function Z(M,C,A,V){for(var re=null,le=null,ce=C,fe=C=0,Ze=null;ce!==null&&fe<A.length;fe++){ce.index>fe?(Ze=ce,ce=null):Ze=ce.sibling;var Se=z(M,ce,A[fe],V);if(Se===null){ce===null&&(ce=Ze);break}t&&ce&&Se.alternate===null&&s(M,ce),C=p(Se,C,fe),le===null?re=Se:le.sibling=Se,le=Se,ce=Ze}if(fe===A.length)return a(M,ce),Ae&&Wn(M,fe),re;if(ce===null){for(;fe<A.length;fe++)ce=H(M,A[fe],V),ce!==null&&(C=p(ce,C,fe),le===null?re=ce:le.sibling=ce,le=ce);return Ae&&Wn(M,fe),re}for(ce=u(M,ce);fe<A.length;fe++)Ze=Q(ce,M,fe,A[fe],V),Ze!==null&&(t&&Ze.alternate!==null&&ce.delete(Ze.key===null?fe:Ze.key),C=p(Ze,C,fe),le===null?re=Ze:le.sibling=Ze,le=Ze);return t&&ce.forEach(function(Rn){return s(M,Rn)}),Ae&&Wn(M,fe),re}function ne(M,C,A,V){var re=P(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,fe=C=0,Ze=null,Se=A.next();ce!==null&&!Se.done;fe++,Se=A.next()){ce.index>fe?(Ze=ce,ce=null):Ze=ce.sibling;var Rn=z(M,ce,Se.value,V);if(Rn===null){ce===null&&(ce=Ze);break}t&&ce&&Rn.alternate===null&&s(M,ce),C=p(Rn,C,fe),le===null?re=Rn:le.sibling=Rn,le=Rn,ce=Ze}if(Se.done)return a(M,ce),Ae&&Wn(M,fe),re;if(ce===null){for(;!Se.done;fe++,Se=A.next())Se=H(M,Se.value,V),Se!==null&&(C=p(Se,C,fe),le===null?re=Se:le.sibling=Se,le=Se);return Ae&&Wn(M,fe),re}for(ce=u(M,ce);!Se.done;fe++,Se=A.next())Se=Q(ce,M,fe,Se.value,V),Se!==null&&(t&&Se.alternate!==null&&ce.delete(Se.key===null?fe:Se.key),C=p(Se,C,fe),le===null?re=Se:le.sibling=Se,le=Se);return t&&ce.forEach(function(cv){return s(M,cv)}),Ae&&Wn(M,fe),re}function Fe(M,C,A,V){if(typeof A=="object"&&A!==null&&A.type===se&&A.key===null&&(A=A.props.children),typeof A=="object"&&A!==null){switch(A.$$typeof){case te:e:{for(var re=A.key,le=C;le!==null;){if(le.key===re){if(re=A.type,re===se){if(le.tag===7){a(M,le.sibling),C=f(le,A.props.children),C.return=M,M=C;break e}}else if(le.elementType===re||typeof re=="object"&&re!==null&&re.$$typeof===ae&&Zu(re)===le.type){a(M,le.sibling),C=f(le,A.props),C.ref=pi(M,le,A),C.return=M,M=C;break e}a(M,le);break}else s(M,le);le=le.sibling}A.type===se?(C=Jn(A.props.children,M.mode,V,A.key),C.return=M,M=C):(V=Gr(A.type,A.key,A.props,null,M.mode,V),V.ref=pi(M,C,A),V.return=M,M=V)}return y(M);case B:e:{for(le=A.key;C!==null;){if(C.key===le)if(C.tag===4&&C.stateNode.containerInfo===A.containerInfo&&C.stateNode.implementation===A.implementation){a(M,C.sibling),C=f(C,A.children||[]),C.return=M,M=C;break e}else{a(M,C);break}else s(M,C);C=C.sibling}C=$l(A,M.mode,V),C.return=M,M=C}return y(M);case ae:return le=A._init,Fe(M,C,le(A._payload),V)}if(Hs(A))return Z(M,C,A,V);if(P(A))return ne(M,C,A,V);Sr(M,A)}return typeof A=="string"&&A!==""||typeof A=="number"?(A=""+A,C!==null&&C.tag===6?(a(M,C.sibling),C=f(C,A),C.return=M,M=C):(a(M,C),C=Cl(A,M.mode,V),C.return=M,M=C),y(M)):a(M,C)}return Fe}var ks=ed(!0),td=ed(!1),Nr=jn(null),br=null,xs=null,_a=null;function Pa(){_a=xs=br=null}function Da(t){var s=Nr.current;Me(Nr),t._currentValue=s}function Ba(t,s,a){for(;t!==null;){var u=t.alternate;if((t.childLanes&s)!==s?(t.childLanes|=s,u!==null&&(u.childLanes|=s)):u!==null&&(u.childLanes&s)!==s&&(u.childLanes|=s),t===a)break;t=t.return}}function ws(t,s){br=t,_a=xs=null,t=t.dependencies,t!==null&&t.firstContext!==null&&((t.lanes&s)!==0&&(gt=!0),t.firstContext=null)}function Tt(t){var s=t._currentValue;if(_a!==t)if(t={context:t,memoizedValue:s,next:null},xs===null){if(br===null)throw Error(r(308));xs=t,br.dependencies={lanes:0,firstContext:t}}else xs=xs.next=t;return s}var Hn=null;function za(t){Hn===null?Hn=[t]:Hn.push(t)}function nd(t,s,a,u){var f=s.interleaved;return f===null?(a.next=a,za(s)):(a.next=f.next,f.next=a),s.interleaved=a,an(t,u)}function an(t,s){t.lanes|=s;var a=t.alternate;for(a!==null&&(a.lanes|=s),a=t,t=t.return;t!==null;)t.childLanes|=s,a=t.alternate,a!==null&&(a.childLanes|=s),a=t,t=t.return;return a.tag===3?a.stateNode:null}var bn=!1;function Fa(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function sd(t,s){t=t.updateQueue,s.updateQueue===t&&(s.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function ln(t,s){return{eventTime:t,lane:s,tag:0,payload:null,callback:null,next:null}}function Cn(t,s,a){var u=t.updateQueue;if(u===null)return null;if(u=u.shared,(je&2)!==0){var f=u.pending;return f===null?s.next=s:(s.next=f.next,f.next=s),u.pending=s,an(t,a)}return f=u.interleaved,f===null?(s.next=s,za(u)):(s.next=f.next,f.next=s),u.interleaved=s,an(t,a)}function Cr(t,s,a){if(s=s.updateQueue,s!==null&&(s=s.shared,(a&4194240)!==0)){var u=s.lanes;u&=t.pendingLanes,a|=u,s.lanes=a,ta(t,a)}}function id(t,s){var a=t.updateQueue,u=t.alternate;if(u!==null&&(u=u.updateQueue,a===u)){var f=null,p=null;if(a=a.firstBaseUpdate,a!==null){do{var 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},t.updateQueue=a;return}t=a.lastBaseUpdate,t===null?a.firstBaseUpdate=s:t.next=s,a.lastBaseUpdate=s}function $r(t,s,a,u){var f=t.updateQueue;bn=!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=t.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 H=f.baseState;y=0,F=L=b=null,N=p;do{var z=N.lane,Q=N.eventTime;if((u&z)===z){F!==null&&(F=F.next={eventTime:Q,lane:0,tag:N.tag,payload:N.payload,callback:N.callback,next:null});e:{var Z=t,ne=N;switch(z=s,Q=a,ne.tag){case 1:if(Z=ne.payload,typeof Z=="function"){H=Z.call(Q,H,z);break e}H=Z;break e;case 3:Z.flags=Z.flags&-65537|128;case 0:if(Z=ne.payload,z=typeof Z=="function"?Z.call(Q,H,z):Z,z==null)break e;H=W({},H,z);break e;case 2:bn=!0}}N.callback!==null&&N.lane!==0&&(t.flags|=64,z=f.effects,z===null?f.effects=[N]:z.push(N))}else Q={eventTime:Q,lane:z,tag:N.tag,payload:N.payload,callback:N.callback,next:null},F===null?(L=F=Q,b=H):F=F.next=Q,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=H),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);Gn|=y,t.lanes=y,t.memoizedState=H}}function rd(t,s,a){if(t=s.effects,s.effects=null,t!==null)for(s=0;s<t.length;s++){var u=t[s],f=u.callback;if(f!==null){if(u.callback=null,u=a,typeof f!="function")throw Error(r(191,f));f.call(u)}}}var gi={},Vt=jn(gi),vi=jn(gi),yi=jn(gi);function Vn(t){if(t===gi)throw Error(r(174));return t}function Ua(t,s){switch(Te(yi,s),Te(vi,t),Te(Vt,gi),t=s.nodeType,t){case 9:case 11:s=(s=s.documentElement)?s.namespaceURI:Wo(null,"");break;default:t=t===8?s.parentNode:s,s=t.namespaceURI||null,t=t.tagName,s=Wo(s,t)}Me(Vt),Te(Vt,s)}function js(){Me(Vt),Me(vi),Me(yi)}function od(t){Vn(yi.current);var s=Vn(Vt.current),a=Wo(s,t.type);s!==a&&(Te(vi,t),Te(Vt,a))}function Wa(t){vi.current===t&&(Me(Vt),Me(vi))}var Le=jn(0);function Tr(t){for(var s=t;s!==null;){if(s.tag===13){var a=s.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||a.data==="$?"||a.data==="$!"))return s}else if(s.tag===19&&s.memoizedProps.revealOrder!==void 0){if((s.flags&128)!==0)return s}else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break;for(;s.sibling===null;){if(s.return===null||s.return===t)return null;s=s.return}s.sibling.return=s.return,s=s.sibling}return null}var Ha=[];function Va(){for(var t=0;t<Ha.length;t++)Ha[t]._workInProgressVersionPrimary=null;Ha.length=0}var Er=X.ReactCurrentDispatcher,Ka=X.ReactCurrentBatchConfig,Kn=0,Oe=null,qe=null,Je=null,Mr=!1,ki=!1,xi=0,Ig=0;function ot(){throw Error(r(321))}function Ga(t,s){if(s===null)return!1;for(var a=0;a<s.length&&a<t.length;a++)if(!Ot(t[a],s[a]))return!1;return!0}function qa(t,s,a,u,f,p){if(Kn=p,Oe=s,s.memoizedState=null,s.updateQueue=null,s.lanes=0,Er.current=t===null||t.memoizedState===null?Og:_g,t=a(u,f),ki){p=0;do{if(ki=!1,xi=0,25<=p)throw Error(r(301));p+=1,Je=qe=null,s.updateQueue=null,Er.current=Pg,t=a(u,f)}while(ki)}if(Er.current=Rr,s=qe!==null&&qe.next!==null,Kn=0,Je=qe=Oe=null,Mr=!1,s)throw Error(r(300));return t}function Qa(){var t=xi!==0;return xi=0,t}function Kt(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Je===null?Oe.memoizedState=Je=t:Je=Je.next=t,Je}function Et(){if(qe===null){var t=Oe.alternate;t=t!==null?t.memoizedState:null}else t=qe.next;var s=Je===null?Oe.memoizedState:Je.next;if(s!==null)Je=s,qe=t;else{if(t===null)throw Error(r(310));qe=t,t={memoizedState:qe.memoizedState,baseState:qe.baseState,baseQueue:qe.baseQueue,queue:qe.queue,next:null},Je===null?Oe.memoizedState=Je=t:Je=Je.next=t}return Je}function wi(t,s){return typeof s=="function"?s(t):s}function Ya(t){var s=Et(),a=s.queue;if(a===null)throw Error(r(311));a.lastRenderedReducer=t;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((Kn&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:t(u,L.action);else{var H={lane:F,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null};b===null?(N=b=H,y=u):b=b.next=H,Oe.lanes|=F,Gn|=F}L=L.next}while(L!==null&&L!==p);b===null?y=u:b.next=N,Ot(u,s.memoizedState)||(gt=!0),s.memoizedState=u,s.baseState=y,s.baseQueue=b,a.lastRenderedState=u}if(t=a.interleaved,t!==null){f=t;do p=f.lane,Oe.lanes|=p,Gn|=p,f=f.next;while(f!==t)}else f===null&&(a.lanes=0);return[s.memoizedState,a.dispatch]}function Ja(t){var s=Et(),a=s.queue;if(a===null)throw Error(r(311));a.lastRenderedReducer=t;var u=a.dispatch,f=a.pending,p=s.memoizedState;if(f!==null){a.pending=null;var y=f=f.next;do p=t(p,y.action),y=y.next;while(y!==f);Ot(p,s.memoizedState)||(gt=!0),s.memoizedState=p,s.baseQueue===null&&(s.baseState=p),a.lastRenderedState=p}return[p,u]}function ad(){}function ld(t,s){var a=Oe,u=Et(),f=s(),p=!Ot(u.memoizedState,f);if(p&&(u.memoizedState=f,gt=!0),u=u.queue,Xa(dd.bind(null,a,u,t),[t]),u.getSnapshot!==s||p||Je!==null&&Je.memoizedState.tag&1){if(a.flags|=2048,ji(9,ud.bind(null,a,u,f,s),void 0,null),Xe===null)throw Error(r(349));(Kn&30)!==0||cd(a,s,f)}return f}function cd(t,s,a){t.flags|=16384,t={getSnapshot:s,value:a},s=Oe.updateQueue,s===null?(s={lastEffect:null,stores:null},Oe.updateQueue=s,s.stores=[t]):(a=s.stores,a===null?s.stores=[t]:a.push(t))}function ud(t,s,a,u){s.value=a,s.getSnapshot=u,fd(s)&&hd(t)}function dd(t,s,a){return a(function(){fd(s)&&hd(t)})}function fd(t){var s=t.getSnapshot;t=t.value;try{var a=s();return!Ot(t,a)}catch{return!0}}function hd(t){var s=an(t,1);s!==null&&zt(s,t,1,-1)}function md(t){var s=Kt();return typeof t=="function"&&(t=t()),s.memoizedState=s.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:wi,lastRenderedState:t},s.queue=t,t=t.dispatch=Lg.bind(null,Oe,t),[s.memoizedState,t]}function ji(t,s,a,u){return t={tag:t,create:s,destroy:a,deps:u,next:null},s=Oe.updateQueue,s===null?(s={lastEffect:null,stores:null},Oe.updateQueue=s,s.lastEffect=t.next=t):(a=s.lastEffect,a===null?s.lastEffect=t.next=t:(u=a.next,a.next=t,t.next=u,s.lastEffect=t)),t}function pd(){return Et().memoizedState}function Ir(t,s,a,u){var f=Kt();Oe.flags|=t,f.memoizedState=ji(1|s,a,void 0,u===void 0?null:u)}function Ar(t,s,a,u){var f=Et();u=u===void 0?null:u;var p=void 0;if(qe!==null){var y=qe.memoizedState;if(p=y.destroy,u!==null&&Ga(u,y.deps)){f.memoizedState=ji(s,a,p,u);return}}Oe.flags|=t,f.memoizedState=ji(1|s,a,p,u)}function gd(t,s){return Ir(8390656,8,t,s)}function Xa(t,s){return Ar(2048,8,t,s)}function vd(t,s){return Ar(4,2,t,s)}function yd(t,s){return Ar(4,4,t,s)}function kd(t,s){if(typeof s=="function")return t=t(),s(t),function(){s(null)};if(s!=null)return t=t(),s.current=t,function(){s.current=null}}function xd(t,s,a){return a=a!=null?a.concat([t]):null,Ar(4,4,kd.bind(null,s,t),a)}function Za(){}function wd(t,s){var a=Et();s=s===void 0?null:s;var u=a.memoizedState;return u!==null&&s!==null&&Ga(s,u[1])?u[0]:(a.memoizedState=[t,s],t)}function jd(t,s){var a=Et();s=s===void 0?null:s;var u=a.memoizedState;return u!==null&&s!==null&&Ga(s,u[1])?u[0]:(t=t(),a.memoizedState=[t,s],t)}function Sd(t,s,a){return(Kn&21)===0?(t.baseState&&(t.baseState=!1,gt=!0),t.memoizedState=a):(Ot(a,s)||(a=Zc(),Oe.lanes|=a,Gn|=a,t.baseState=!0),s)}function Ag(t,s){var a=be;be=a!==0&&4>a?a:4,t(!0);var u=Ka.transition;Ka.transition={};try{t(!1),s()}finally{be=a,Ka.transition=u}}function Nd(){return Et().memoizedState}function Rg(t,s,a){var u=Mn(t);if(a={lane:u,action:a,hasEagerState:!1,eagerState:null,next:null},bd(t))Cd(s,a);else if(a=nd(t,s,a,u),a!==null){var f=ft();zt(a,t,u,f),$d(a,s,u)}}function Lg(t,s,a){var u=Mn(t),f={lane:u,action:a,hasEagerState:!1,eagerState:null,next:null};if(bd(t))Cd(s,f);else{var p=t.alternate;if(t.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,Ot(N,y)){var b=s.interleaved;b===null?(f.next=f,za(s)):(f.next=b.next,b.next=f),s.interleaved=f;return}}catch{}finally{}a=nd(t,s,f,u),a!==null&&(f=ft(),zt(a,t,u,f),$d(a,s,u))}}function bd(t){var s=t.alternate;return t===Oe||s!==null&&s===Oe}function Cd(t,s){ki=Mr=!0;var a=t.pending;a===null?s.next=s:(s.next=a.next,a.next=s),t.pending=s}function $d(t,s,a){if((a&4194240)!==0){var u=s.lanes;u&=t.pendingLanes,a|=u,s.lanes=a,ta(t,a)}}var Rr={readContext:Tt,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},Og={readContext:Tt,useCallback:function(t,s){return Kt().memoizedState=[t,s===void 0?null:s],t},useContext:Tt,useEffect:gd,useImperativeHandle:function(t,s,a){return a=a!=null?a.concat([t]):null,Ir(4194308,4,kd.bind(null,s,t),a)},useLayoutEffect:function(t,s){return Ir(4194308,4,t,s)},useInsertionEffect:function(t,s){return Ir(4,2,t,s)},useMemo:function(t,s){var a=Kt();return s=s===void 0?null:s,t=t(),a.memoizedState=[t,s],t},useReducer:function(t,s,a){var u=Kt();return s=a!==void 0?a(s):s,u.memoizedState=u.baseState=s,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:s},u.queue=t,t=t.dispatch=Rg.bind(null,Oe,t),[u.memoizedState,t]},useRef:function(t){var s=Kt();return t={current:t},s.memoizedState=t},useState:md,useDebugValue:Za,useDeferredValue:function(t){return Kt().memoizedState=t},useTransition:function(){var t=md(!1),s=t[0];return t=Ag.bind(null,t[1]),Kt().memoizedState=t,[s,t]},useMutableSource:function(){},useSyncExternalStore:function(t,s,a){var u=Oe,f=Kt();if(Ae){if(a===void 0)throw Error(r(407));a=a()}else{if(a=s(),Xe===null)throw Error(r(349));(Kn&30)!==0||cd(u,s,a)}f.memoizedState=a;var p={value:a,getSnapshot:s};return f.queue=p,gd(dd.bind(null,u,p,t),[t]),u.flags|=2048,ji(9,ud.bind(null,u,p,a,s),void 0,null),a},useId:function(){var t=Kt(),s=Xe.identifierPrefix;if(Ae){var a=on,u=rn;a=(u&~(1<<32-Lt(u)-1)).toString(32)+a,s=":"+s+"R"+a,a=xi++,0<a&&(s+="H"+a.toString(32)),s+=":"}else a=Ig++,s=":"+s+"r"+a.toString(32)+":";return t.memoizedState=s},unstable_isNewReconciler:!1},_g={readContext:Tt,useCallback:wd,useContext:Tt,useEffect:Xa,useImperativeHandle:xd,useInsertionEffect:vd,useLayoutEffect:yd,useMemo:jd,useReducer:Ya,useRef:pd,useState:function(){return Ya(wi)},useDebugValue:Za,useDeferredValue:function(t){var s=Et();return Sd(s,qe.memoizedState,t)},useTransition:function(){var t=Ya(wi)[0],s=Et().memoizedState;return[t,s]},useMutableSource:ad,useSyncExternalStore:ld,useId:Nd,unstable_isNewReconciler:!1},Pg={readContext:Tt,useCallback:wd,useContext:Tt,useEffect:Xa,useImperativeHandle:xd,useInsertionEffect:vd,useLayoutEffect:yd,useMemo:jd,useReducer:Ja,useRef:pd,useState:function(){return Ja(wi)},useDebugValue:Za,useDeferredValue:function(t){var s=Et();return qe===null?s.memoizedState=t:Sd(s,qe.memoizedState,t)},useTransition:function(){var t=Ja(wi)[0],s=Et().memoizedState;return[t,s]},useMutableSource:ad,useSyncExternalStore:ld,useId:Nd,unstable_isNewReconciler:!1};function Pt(t,s){if(t&&t.defaultProps){s=W({},s),t=t.defaultProps;for(var a in t)s[a]===void 0&&(s[a]=t[a]);return s}return s}function el(t,s,a,u){s=t.memoizedState,a=a(u,s),a=a==null?s:W({},s,a),t.memoizedState=a,t.lanes===0&&(t.updateQueue.baseState=a)}var Lr={isMounted:function(t){return(t=t._reactInternals)?Bn(t)===t:!1},enqueueSetState:function(t,s,a){t=t._reactInternals;var u=ft(),f=Mn(t),p=ln(u,f);p.payload=s,a!=null&&(p.callback=a),s=Cn(t,p,f),s!==null&&(zt(s,t,f,u),Cr(s,t,f))},enqueueReplaceState:function(t,s,a){t=t._reactInternals;var u=ft(),f=Mn(t),p=ln(u,f);p.tag=1,p.payload=s,a!=null&&(p.callback=a),s=Cn(t,p,f),s!==null&&(zt(s,t,f,u),Cr(s,t,f))},enqueueForceUpdate:function(t,s){t=t._reactInternals;var a=ft(),u=Mn(t),f=ln(a,u);f.tag=2,s!=null&&(f.callback=s),s=Cn(t,f,u),s!==null&&(zt(s,t,u,a),Cr(s,t,u))}};function Td(t,s,a,u,f,p,y){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(u,p,y):s.prototype&&s.prototype.isPureReactComponent?!li(a,u)||!li(f,p):!0}function Ed(t,s,a){var u=!1,f=Sn,p=s.contextType;return typeof p=="object"&&p!==null?p=Tt(p):(f=pt(s)?Fn:rt.current,u=s.contextTypes,p=(u=u!=null)?ps(t,f):Sn),s=new s(a,p),t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,s.updater=Lr,t.stateNode=s,s._reactInternals=t,u&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=f,t.__reactInternalMemoizedMaskedChildContext=p),s}function Md(t,s,a,u){t=s.state,typeof s.componentWillReceiveProps=="function"&&s.componentWillReceiveProps(a,u),typeof s.UNSAFE_componentWillReceiveProps=="function"&&s.UNSAFE_componentWillReceiveProps(a,u),s.state!==t&&Lr.enqueueReplaceState(s,s.state,null)}function tl(t,s,a,u){var f=t.stateNode;f.props=a,f.state=t.memoizedState,f.refs={},Fa(t);var p=s.contextType;typeof p=="object"&&p!==null?f.context=Tt(p):(p=pt(s)?Fn:rt.current,f.context=ps(t,p)),f.state=t.memoizedState,p=s.getDerivedStateFromProps,typeof p=="function"&&(el(t,s,p,a),f.state=t.memoizedState),typeof s.getDerivedStateFromProps=="function"||typeof f.getSnapshotBeforeUpdate=="function"||typeof f.UNSAFE_componentWillMount!="function"&&typeof f.componentWillMount!="function"||(s=f.state,typeof f.componentWillMount=="function"&&f.componentWillMount(),typeof f.UNSAFE_componentWillMount=="function"&&f.UNSAFE_componentWillMount(),s!==f.state&&Lr.enqueueReplaceState(f,f.state,null),$r(t,a,f,u),f.state=t.memoizedState),typeof f.componentDidMount=="function"&&(t.flags|=4194308)}function Ss(t,s){try{var a="",u=s;do a+=de(u),u=u.return;while(u);var f=a}catch(p){f=`
39
+ Error generating stack: `+p.message+`
40
+ `+p.stack}return{value:t,source:s,stack:f,digest:null}}function nl(t,s,a){return{value:t,source:null,stack:a??null,digest:s??null}}function sl(t,s){try{console.error(s.value)}catch(a){setTimeout(function(){throw a})}}var Dg=typeof WeakMap=="function"?WeakMap:Map;function Id(t,s,a){a=ln(-1,a),a.tag=3,a.payload={element:null};var u=s.value;return a.callback=function(){Fr||(Fr=!0,yl=u),sl(t,s)},a}function Ad(t,s,a){a=ln(-1,a),a.tag=3;var u=t.type.getDerivedStateFromError;if(typeof u=="function"){var f=s.value;a.payload=function(){return u(f)},a.callback=function(){sl(t,s)}}var p=t.stateNode;return p!==null&&typeof p.componentDidCatch=="function"&&(a.callback=function(){sl(t,s),typeof u!="function"&&(Tn===null?Tn=new Set([this]):Tn.add(this));var y=s.stack;this.componentDidCatch(s.value,{componentStack:y!==null?y:""})}),a}function Rd(t,s,a){var u=t.pingCache;if(u===null){u=t.pingCache=new Dg;var f=new Set;u.set(s,f)}else f=u.get(s),f===void 0&&(f=new Set,u.set(s,f));f.has(a)||(f.add(a),t=Xg.bind(null,t,s,a),s.then(t,t))}function Ld(t){do{var s;if((s=t.tag===13)&&(s=t.memoizedState,s=s!==null?s.dehydrated!==null:!0),s)return t;t=t.return}while(t!==null);return null}function Od(t,s,a,u,f){return(t.mode&1)===0?(t===s?t.flags|=65536:(t.flags|=128,a.flags|=131072,a.flags&=-52805,a.tag===1&&(a.alternate===null?a.tag=17:(s=ln(-1,1),s.tag=2,Cn(a,s,1))),a.lanes|=1),t):(t.flags|=65536,t.lanes=f,t)}var Bg=X.ReactCurrentOwner,gt=!1;function dt(t,s,a,u){s.child=t===null?td(s,null,a,u):ks(s,t.child,a,u)}function _d(t,s,a,u,f){a=a.render;var p=s.ref;return ws(s,f),u=qa(t,s,a,u,p,f),a=Qa(),t!==null&&!gt?(s.updateQueue=t.updateQueue,s.flags&=-2053,t.lanes&=~f,cn(t,s,f)):(Ae&&a&&Ia(s),s.flags|=1,dt(t,s,u,f),s.child)}function Pd(t,s,a,u,f){if(t===null){var p=a.type;return typeof p=="function"&&!bl(p)&&p.defaultProps===void 0&&a.compare===null&&a.defaultProps===void 0?(s.tag=15,s.type=p,Dd(t,s,p,u,f)):(t=Gr(a.type,null,u,s,s.mode,f),t.ref=s.ref,t.return=s,s.child=t)}if(p=t.child,(t.lanes&f)===0){var y=p.memoizedProps;if(a=a.compare,a=a!==null?a:li,a(y,u)&&t.ref===s.ref)return cn(t,s,f)}return s.flags|=1,t=An(p,u),t.ref=s.ref,t.return=s,s.child=t}function Dd(t,s,a,u,f){if(t!==null){var p=t.memoizedProps;if(li(p,u)&&t.ref===s.ref)if(gt=!1,s.pendingProps=u=p,(t.lanes&f)!==0)(t.flags&131072)!==0&&(gt=!0);else return s.lanes=t.lanes,cn(t,s,f)}return il(t,s,a,u,f)}function Bd(t,s,a){var u=s.pendingProps,f=u.children,p=t!==null?t.memoizedState:null;if(u.mode==="hidden")if((s.mode&1)===0)s.memoizedState={baseLanes:0,cachePool:null,transitions:null},Te(bs,Nt),Nt|=a;else{if((a&1073741824)===0)return t=p!==null?p.baseLanes|a:a,s.lanes=s.childLanes=1073741824,s.memoizedState={baseLanes:t,cachePool:null,transitions:null},s.updateQueue=null,Te(bs,Nt),Nt|=t,null;s.memoizedState={baseLanes:0,cachePool:null,transitions:null},u=p!==null?p.baseLanes:a,Te(bs,Nt),Nt|=u}else p!==null?(u=p.baseLanes|a,s.memoizedState=null):u=a,Te(bs,Nt),Nt|=u;return dt(t,s,f,a),s.child}function zd(t,s){var a=s.ref;(t===null&&a!==null||t!==null&&t.ref!==a)&&(s.flags|=512,s.flags|=2097152)}function il(t,s,a,u,f){var p=pt(a)?Fn:rt.current;return p=ps(s,p),ws(s,f),a=qa(t,s,a,u,p,f),u=Qa(),t!==null&&!gt?(s.updateQueue=t.updateQueue,s.flags&=-2053,t.lanes&=~f,cn(t,s,f)):(Ae&&u&&Ia(s),s.flags|=1,dt(t,s,a,f),s.child)}function Fd(t,s,a,u,f){if(pt(a)){var p=!0;yr(s)}else p=!1;if(ws(s,f),s.stateNode===null)_r(t,s),Ed(s,a,u),tl(s,a,u,f),u=!0;else if(t===null){var y=s.stateNode,N=s.memoizedProps;y.props=N;var b=y.context,L=a.contextType;typeof L=="object"&&L!==null?L=Tt(L):(L=pt(a)?Fn:rt.current,L=ps(s,L));var F=a.getDerivedStateFromProps,H=typeof F=="function"||typeof y.getSnapshotBeforeUpdate=="function";H||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(N!==u||b!==L)&&Md(s,y,u,L),bn=!1;var z=s.memoizedState;y.state=z,$r(s,u,y,f),b=s.memoizedState,N!==u||z!==b||mt.current||bn?(typeof F=="function"&&(el(s,a,F,u),b=s.memoizedState),(N=bn||Td(s,a,N,u,z,b,L))?(H||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,sd(t,s),N=s.memoizedProps,L=s.type===s.elementType?N:Pt(s.type,N),y.props=L,H=s.pendingProps,z=y.context,b=a.contextType,typeof b=="object"&&b!==null?b=Tt(b):(b=pt(a)?Fn:rt.current,b=ps(s,b));var Q=a.getDerivedStateFromProps;(F=typeof Q=="function"||typeof y.getSnapshotBeforeUpdate=="function")||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(N!==H||z!==b)&&Md(s,y,u,b),bn=!1,z=s.memoizedState,y.state=z,$r(s,u,y,f);var Z=s.memoizedState;N!==H||z!==Z||mt.current||bn?(typeof Q=="function"&&(el(s,a,Q,u),Z=s.memoizedState),(L=bn||Td(s,a,L,u,z,Z,b)||!1)?(F||typeof y.UNSAFE_componentWillUpdate!="function"&&typeof y.componentWillUpdate!="function"||(typeof y.componentWillUpdate=="function"&&y.componentWillUpdate(u,Z,b),typeof y.UNSAFE_componentWillUpdate=="function"&&y.UNSAFE_componentWillUpdate(u,Z,b)),typeof y.componentDidUpdate=="function"&&(s.flags|=4),typeof y.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof y.componentDidUpdate!="function"||N===t.memoizedProps&&z===t.memoizedState||(s.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||N===t.memoizedProps&&z===t.memoizedState||(s.flags|=1024),s.memoizedProps=u,s.memoizedState=Z),y.props=u,y.state=Z,y.context=b,u=L):(typeof y.componentDidUpdate!="function"||N===t.memoizedProps&&z===t.memoizedState||(s.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||N===t.memoizedProps&&z===t.memoizedState||(s.flags|=1024),u=!1)}return rl(t,s,a,u,p,f)}function rl(t,s,a,u,f,p){zd(t,s);var y=(s.flags&128)!==0;if(!u&&!y)return f&&Ku(s,a,!1),cn(t,s,p);u=s.stateNode,Bg.current=s;var N=y&&typeof a.getDerivedStateFromError!="function"?null:u.render();return s.flags|=1,t!==null&&y?(s.child=ks(s,t.child,null,p),s.child=ks(s,null,N,p)):dt(t,s,N,p),s.memoizedState=u.state,f&&Ku(s,a,!0),s.child}function Ud(t){var s=t.stateNode;s.pendingContext?Hu(t,s.pendingContext,s.pendingContext!==s.context):s.context&&Hu(t,s.context,!1),Ua(t,s.containerInfo)}function Wd(t,s,a,u,f){return ys(),Oa(f),s.flags|=256,dt(t,s,a,u),s.child}var ol={dehydrated:null,treeContext:null,retryLane:0};function al(t){return{baseLanes:t,cachePool:null,transitions:null}}function Hd(t,s,a){var u=s.pendingProps,f=Le.current,p=!1,y=(s.flags&128)!==0,N;if((N=y)||(N=t!==null&&t.memoizedState===null?!1:(f&2)!==0),N?(p=!0,s.flags&=-129):(t===null||t.memoizedState!==null)&&(f|=1),Te(Le,f&1),t===null)return La(s),t=s.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?((s.mode&1)===0?s.lanes=1:t.data==="$!"?s.lanes=8:s.lanes=1073741824,null):(y=u.children,t=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),t=Jn(t,u,a,null),p.return=s,t.return=s,p.sibling=t,s.child=p,s.child.memoizedState=al(a),s.memoizedState=ol,t):ll(s,y));if(f=t.memoizedState,f!==null&&(N=f.dehydrated,N!==null))return zg(t,s,y,u,N,f,a);if(p){p=u.fallback,y=s.mode,f=t.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=An(f,b),u.subtreeFlags=f.subtreeFlags&14680064),N!==null?p=An(N,p):(p=Jn(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=t.child.memoizedState,y=y===null?al(a):{baseLanes:y.baseLanes|a,cachePool:null,transitions:y.transitions},p.memoizedState=y,p.childLanes=t.childLanes&~a,s.memoizedState=ol,u}return p=t.child,t=p.sibling,u=An(p,{mode:"visible",children:u.children}),(s.mode&1)===0&&(u.lanes=a),u.return=s,u.sibling=null,t!==null&&(a=s.deletions,a===null?(s.deletions=[t],s.flags|=16):a.push(t)),s.child=u,s.memoizedState=null,u}function ll(t,s){return s=qr({mode:"visible",children:s},t.mode,0,null),s.return=t,t.child=s}function Or(t,s,a,u){return u!==null&&Oa(u),ks(s,t.child,null,a),t=ll(s,s.pendingProps.children),t.flags|=2,s.memoizedState=null,t}function zg(t,s,a,u,f,p,y){if(a)return s.flags&256?(s.flags&=-257,u=nl(Error(r(422))),Or(t,s,y,u)):s.memoizedState!==null?(s.child=t.child,s.flags|=128,null):(p=u.fallback,f=s.mode,u=qr({mode:"visible",children:u.children},f,0,null),p=Jn(p,f,y,null),p.flags|=2,u.return=s,p.return=s,u.sibling=p,s.child=u,(s.mode&1)!==0&&ks(s,t.child,null,y),s.child.memoizedState=al(y),s.memoizedState=ol,p);if((s.mode&1)===0)return Or(t,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=nl(p,u,void 0),Or(t,s,y,u)}if(N=(y&t.childLanes)!==0,gt||N){if(u=Xe,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,an(t,f),zt(u,t,f,-1))}return Nl(),u=nl(Error(r(421))),Or(t,s,y,u)}return f.data==="$?"?(s.flags|=128,s.child=t.child,s=Zg.bind(null,t),f._reactRetry=s,null):(t=p.treeContext,St=wn(f.nextSibling),jt=s,Ae=!0,_t=null,t!==null&&(Ct[$t++]=rn,Ct[$t++]=on,Ct[$t++]=Un,rn=t.id,on=t.overflow,Un=s),s=ll(s,u.children),s.flags|=4096,s)}function Vd(t,s,a){t.lanes|=s;var u=t.alternate;u!==null&&(u.lanes|=s),Ba(t.return,s,a)}function cl(t,s,a,u,f){var p=t.memoizedState;p===null?t.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:u,tail:a,tailMode:f}:(p.isBackwards=s,p.rendering=null,p.renderingStartTime=0,p.last=u,p.tail=a,p.tailMode=f)}function Kd(t,s,a){var u=s.pendingProps,f=u.revealOrder,p=u.tail;if(dt(t,s,u.children,a),u=Le.current,(u&2)!==0)u=u&1|2,s.flags|=128;else{if(t!==null&&(t.flags&128)!==0)e:for(t=s.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&Vd(t,a,s);else if(t.tag===19)Vd(t,a,s);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===s)break e;for(;t.sibling===null;){if(t.return===null||t.return===s)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}u&=1}if(Te(Le,u),(s.mode&1)===0)s.memoizedState=null;else switch(f){case"forwards":for(a=s.child,f=null;a!==null;)t=a.alternate,t!==null&&Tr(t)===null&&(f=a),a=a.sibling;a=f,a===null?(f=s.child,s.child=null):(f=a.sibling,a.sibling=null),cl(s,!1,f,a,p);break;case"backwards":for(a=null,f=s.child,s.child=null;f!==null;){if(t=f.alternate,t!==null&&Tr(t)===null){s.child=f;break}t=f.sibling,f.sibling=a,a=f,f=t}cl(s,!0,a,null,p);break;case"together":cl(s,!1,null,null,void 0);break;default:s.memoizedState=null}return s.child}function _r(t,s){(s.mode&1)===0&&t!==null&&(t.alternate=null,s.alternate=null,s.flags|=2)}function cn(t,s,a){if(t!==null&&(s.dependencies=t.dependencies),Gn|=s.lanes,(a&s.childLanes)===0)return null;if(t!==null&&s.child!==t.child)throw Error(r(153));if(s.child!==null){for(t=s.child,a=An(t,t.pendingProps),s.child=a,a.return=s;t.sibling!==null;)t=t.sibling,a=a.sibling=An(t,t.pendingProps),a.return=s;a.sibling=null}return s.child}function Fg(t,s,a){switch(s.tag){case 3:Ud(s),ys();break;case 5:od(s);break;case 1:pt(s.type)&&yr(s);break;case 4:Ua(s,s.stateNode.containerInfo);break;case 10:var u=s.type._context,f=s.memoizedProps.value;Te(Nr,u._currentValue),u._currentValue=f;break;case 13:if(u=s.memoizedState,u!==null)return u.dehydrated!==null?(Te(Le,Le.current&1),s.flags|=128,null):(a&s.child.childLanes)!==0?Hd(t,s,a):(Te(Le,Le.current&1),t=cn(t,s,a),t!==null?t.sibling:null);Te(Le,Le.current&1);break;case 19:if(u=(a&s.childLanes)!==0,(t.flags&128)!==0){if(u)return Kd(t,s,a);s.flags|=128}if(f=s.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),Te(Le,Le.current),u)break;return null;case 22:case 23:return s.lanes=0,Bd(t,s,a)}return cn(t,s,a)}var Gd,ul,qd,Qd;Gd=function(t,s){for(var a=s.child;a!==null;){if(a.tag===5||a.tag===6)t.appendChild(a.stateNode);else if(a.tag!==4&&a.child!==null){a.child.return=a,a=a.child;continue}if(a===s)break;for(;a.sibling===null;){if(a.return===null||a.return===s)return;a=a.return}a.sibling.return=a.return,a=a.sibling}},ul=function(){},qd=function(t,s,a,u){var f=t.memoizedProps;if(f!==u){t=s.stateNode,Vn(Vt.current);var p=null;switch(a){case"input":f=Bo(t,f),u=Bo(t,u),p=[];break;case"select":f=W({},f,{value:void 0}),u=W({},u,{value:void 0}),p=[];break;case"textarea":f=Uo(t,f),u=Uo(t,u),p=[];break;default:typeof f.onClick!="function"&&typeof u.onClick=="function"&&(t.onclick=pr)}Ho(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"&&Ee("scroll",t),p||N===b||(p=[])):(p=p||[]).push(L,b))}a&&(p=p||[]).push("style",a);var L=p;(s.updateQueue=L)&&(s.flags|=4)}},Qd=function(t,s,a,u){a!==u&&(s.flags|=4)};function Si(t,s){if(!Ae)switch(t.tailMode){case"hidden":s=t.tail;for(var a=null;s!==null;)s.alternate!==null&&(a=s),s=s.sibling;a===null?t.tail=null:a.sibling=null;break;case"collapsed":a=t.tail;for(var u=null;a!==null;)a.alternate!==null&&(u=a),a=a.sibling;u===null?s||t.tail===null?t.tail=null:t.tail.sibling=null:u.sibling=null}}function at(t){var s=t.alternate!==null&&t.alternate.child===t.child,a=0,u=0;if(s)for(var f=t.child;f!==null;)a|=f.lanes|f.childLanes,u|=f.subtreeFlags&14680064,u|=f.flags&14680064,f.return=t,f=f.sibling;else for(f=t.child;f!==null;)a|=f.lanes|f.childLanes,u|=f.subtreeFlags,u|=f.flags,f.return=t,f=f.sibling;return t.subtreeFlags|=u,t.childLanes=a,s}function Ug(t,s,a){var u=s.pendingProps;switch(Aa(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)&&vr(),at(s),null;case 3:return u=s.stateNode,js(),Me(mt),Me(rt),Va(),u.pendingContext&&(u.context=u.pendingContext,u.pendingContext=null),(t===null||t.child===null)&&(jr(s)?s.flags|=4:t===null||t.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,_t!==null&&(wl(_t),_t=null))),ul(t,s),at(s),null;case 5:Wa(s);var f=Vn(yi.current);if(a=s.type,t!==null&&s.stateNode!=null)qd(t,s,a,u,f),t.ref!==s.ref&&(s.flags|=512,s.flags|=2097152);else{if(!u){if(s.stateNode===null)throw Error(r(166));return at(s),null}if(t=Vn(Vt.current),jr(s)){u=s.stateNode,a=s.type;var p=s.memoizedProps;switch(u[Ht]=s,u[hi]=p,t=(s.mode&1)!==0,a){case"dialog":Ee("cancel",u),Ee("close",u);break;case"iframe":case"object":case"embed":Ee("load",u);break;case"video":case"audio":for(f=0;f<ui.length;f++)Ee(ui[f],u);break;case"source":Ee("error",u);break;case"img":case"image":case"link":Ee("error",u),Ee("load",u);break;case"details":Ee("toggle",u);break;case"input":Ec(u,p),Ee("invalid",u);break;case"select":u._wrapperState={wasMultiple:!!p.multiple},Ee("invalid",u);break;case"textarea":Ac(u,p),Ee("invalid",u)}Ho(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&&mr(u.textContent,N,t),f=["children",N]):typeof N=="number"&&u.textContent!==""+N&&(p.suppressHydrationWarning!==!0&&mr(u.textContent,N,t),f=["children",""+N]):l.hasOwnProperty(y)&&N!=null&&y==="onScroll"&&Ee("scroll",u)}switch(a){case"input":ns(u),Ic(u,p,!0);break;case"textarea":ns(u),Lc(u);break;case"select":case"option":break;default:typeof p.onClick=="function"&&(u.onclick=pr)}u=f,s.updateQueue=u,u!==null&&(s.flags|=4)}else{y=f.nodeType===9?f:f.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=Oc(a)),t==="http://www.w3.org/1999/xhtml"?a==="script"?(t=y.createElement("div"),t.innerHTML="<script><\/script>",t=t.removeChild(t.firstChild)):typeof u.is=="string"?t=y.createElement(a,{is:u.is}):(t=y.createElement(a),a==="select"&&(y=t,u.multiple?y.multiple=!0:u.size&&(y.size=u.size))):t=y.createElementNS(t,a),t[Ht]=s,t[hi]=u,Gd(t,s,!1,!1),s.stateNode=t;e:{switch(y=Vo(a,u),a){case"dialog":Ee("cancel",t),Ee("close",t),f=u;break;case"iframe":case"object":case"embed":Ee("load",t),f=u;break;case"video":case"audio":for(f=0;f<ui.length;f++)Ee(ui[f],t);f=u;break;case"source":Ee("error",t),f=u;break;case"img":case"image":case"link":Ee("error",t),Ee("load",t),f=u;break;case"details":Ee("toggle",t),f=u;break;case"input":Ec(t,u),f=Bo(t,u),Ee("invalid",t);break;case"option":f=u;break;case"select":t._wrapperState={wasMultiple:!!u.multiple},f=W({},u,{value:void 0}),Ee("invalid",t);break;case"textarea":Ac(t,u),f=Uo(t,u),Ee("invalid",t);break;default:f=u}Ho(a,f),N=f;for(p in N)if(N.hasOwnProperty(p)){var b=N[p];p==="style"?Dc(t,b):p==="dangerouslySetInnerHTML"?(b=b?b.__html:void 0,b!=null&&_c(t,b)):p==="children"?typeof b=="string"?(a!=="textarea"||b!=="")&&Vs(t,b):typeof b=="number"&&Vs(t,""+b):p!=="suppressContentEditableWarning"&&p!=="suppressHydrationWarning"&&p!=="autoFocus"&&(l.hasOwnProperty(p)?b!=null&&p==="onScroll"&&Ee("scroll",t):b!=null&&R(t,p,b,y))}switch(a){case"input":ns(t),Ic(t,u,!1);break;case"textarea":ns(t),Lc(t);break;case"option":u.value!=null&&t.setAttribute("value",""+ye(u.value));break;case"select":t.multiple=!!u.multiple,p=u.value,p!=null?ss(t,!!u.multiple,p,!1):u.defaultValue!=null&&ss(t,!!u.multiple,u.defaultValue,!0);break;default:typeof f.onClick=="function"&&(t.onclick=pr)}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(t&&s.stateNode!=null)Qd(t,s,t.memoizedProps,u);else{if(typeof u!="string"&&s.stateNode===null)throw Error(r(166));if(a=Vn(yi.current),Vn(Vt.current),jr(s)){if(u=s.stateNode,a=s.memoizedProps,u[Ht]=s,(p=u.nodeValue!==a)&&(t=jt,t!==null))switch(t.tag){case 3:mr(u.nodeValue,a,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&mr(u.nodeValue,a,(t.mode&1)!==0)}p&&(s.flags|=4)}else u=(a.nodeType===9?a:a.ownerDocument).createTextNode(u),u[Ht]=s,s.stateNode=u}return at(s),null;case 13:if(Me(Le),u=s.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(Ae&&St!==null&&(s.mode&1)!==0&&(s.flags&128)===0)Xu(),ys(),s.flags|=98560,p=!1;else if(p=jr(s),u!==null&&u.dehydrated!==null){if(t===null){if(!p)throw Error(r(318));if(p=s.memoizedState,p=p!==null?p.dehydrated:null,!p)throw Error(r(317));p[Ht]=s}else ys(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;at(s),p=!1}else _t!==null&&(wl(_t),_t=null),p=!0;if(!p)return s.flags&65536?s:null}return(s.flags&128)!==0?(s.lanes=a,s):(u=u!==null,u!==(t!==null&&t.memoizedState!==null)&&u&&(s.child.flags|=8192,(s.mode&1)!==0&&(t===null||(Le.current&1)!==0?Qe===0&&(Qe=3):Nl())),s.updateQueue!==null&&(s.flags|=4),at(s),null);case 4:return js(),ul(t,s),t===null&&di(s.stateNode.containerInfo),at(s),null;case 10:return Da(s.type._context),at(s),null;case 17:return pt(s.type)&&vr(),at(s),null;case 19:if(Me(Le),p=s.memoizedState,p===null)return at(s),null;if(u=(s.flags&128)!==0,y=p.rendering,y===null)if(u)Si(p,!1);else{if(Qe!==0||t!==null&&(t.flags&128)!==0)for(t=s.child;t!==null;){if(y=Tr(t),y!==null){for(s.flags|=128,Si(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,t=u,p.flags&=14680066,y=p.alternate,y===null?(p.childLanes=0,p.lanes=t,p.child=null,p.subtreeFlags=0,p.memoizedProps=null,p.memoizedState=null,p.updateQueue=null,p.dependencies=null,p.stateNode=null):(p.childLanes=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,t=y.dependencies,p.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),a=a.sibling;return Te(Le,Le.current&1|2),s.child}t=t.sibling}p.tail!==null&&ze()>Cs&&(s.flags|=128,u=!0,Si(p,!1),s.lanes=4194304)}else{if(!u)if(t=Tr(y),t!==null){if(s.flags|=128,u=!0,a=t.updateQueue,a!==null&&(s.updateQueue=a,s.flags|=4),Si(p,!0),p.tail===null&&p.tailMode==="hidden"&&!y.alternate&&!Ae)return at(s),null}else 2*ze()-p.renderingStartTime>Cs&&a!==1073741824&&(s.flags|=128,u=!0,Si(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=Le.current,Te(Le,u?a&1|2:a&1),s):(at(s),null);case 22:case 23:return Sl(),u=s.memoizedState!==null,t!==null&&t.memoizedState!==null!==u&&(s.flags|=8192),u&&(s.mode&1)!==0?(Nt&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 Wg(t,s){switch(Aa(s),s.tag){case 1:return pt(s.type)&&vr(),t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 3:return js(),Me(mt),Me(rt),Va(),t=s.flags,(t&65536)!==0&&(t&128)===0?(s.flags=t&-65537|128,s):null;case 5:return Wa(s),null;case 13:if(Me(Le),t=s.memoizedState,t!==null&&t.dehydrated!==null){if(s.alternate===null)throw Error(r(340));ys()}return t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 19:return Me(Le),null;case 4:return js(),null;case 10:return Da(s.type._context),null;case 22:case 23:return Sl(),null;case 24:return null;default:return null}}var Pr=!1,lt=!1,Hg=typeof WeakSet=="function"?WeakSet:Set,J=null;function Ns(t,s){var a=t.ref;if(a!==null)if(typeof a=="function")try{a(null)}catch(u){_e(t,s,u)}else a.current=null}function dl(t,s,a){try{a()}catch(u){_e(t,s,u)}}var Yd=!1;function Vg(t,s){if(Sa=sr,t=Tu(),pa(t)){if("selectionStart"in t)var a={start:t.selectionStart,end:t.selectionEnd};else e:{a=(a=t.ownerDocument)&&a.defaultView||window;var u=a.getSelection&&a.getSelection();if(u&&u.rangeCount!==0){a=u.anchorNode;var f=u.anchorOffset,p=u.focusNode;u=u.focusOffset;try{a.nodeType,p.nodeType}catch{a=null;break e}var y=0,N=-1,b=-1,L=0,F=0,H=t,z=null;t:for(;;){for(var Q;H!==a||f!==0&&H.nodeType!==3||(N=y+f),H!==p||u!==0&&H.nodeType!==3||(b=y+u),H.nodeType===3&&(y+=H.nodeValue.length),(Q=H.firstChild)!==null;)z=H,H=Q;for(;;){if(H===t)break t;if(z===a&&++L===f&&(N=y),z===p&&++F===u&&(b=y),(Q=H.nextSibling)!==null)break;H=z,z=H.parentNode}H=Q}a=N===-1||b===-1?null:{start:N,end:b}}else a=null}a=a||{start:0,end:0}}else a=null;for(Na={focusedElem:t,selectionRange:a},sr=!1,J=s;J!==null;)if(s=J,t=s.child,(s.subtreeFlags&1028)!==0&&t!==null)t.return=s,J=t;else for(;J!==null;){s=J;try{var Z=s.alternate;if((s.flags&1024)!==0)switch(s.tag){case 0:case 11:case 15:break;case 1:if(Z!==null){var ne=Z.memoizedProps,Fe=Z.memoizedState,M=s.stateNode,C=M.getSnapshotBeforeUpdate(s.elementType===s.type?ne:Pt(s.type,ne),Fe);M.__reactInternalSnapshotBeforeUpdate=C}break;case 3:var A=s.stateNode.containerInfo;A.nodeType===1?A.textContent="":A.nodeType===9&&A.documentElement&&A.removeChild(A.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(V){_e(s,s.return,V)}if(t=s.sibling,t!==null){t.return=s.return,J=t;break}J=s.return}return Z=Yd,Yd=!1,Z}function Ni(t,s,a){var u=s.updateQueue;if(u=u!==null?u.lastEffect:null,u!==null){var f=u=u.next;do{if((f.tag&t)===t){var p=f.destroy;f.destroy=void 0,p!==void 0&&dl(s,a,p)}f=f.next}while(f!==u)}}function Dr(t,s){if(s=s.updateQueue,s=s!==null?s.lastEffect:null,s!==null){var a=s=s.next;do{if((a.tag&t)===t){var u=a.create;a.destroy=u()}a=a.next}while(a!==s)}}function fl(t){var s=t.ref;if(s!==null){var a=t.stateNode;switch(t.tag){case 5:t=a;break;default:t=a}typeof s=="function"?s(t):s.current=t}}function Jd(t){var s=t.alternate;s!==null&&(t.alternate=null,Jd(s)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(s=t.stateNode,s!==null&&(delete s[Ht],delete s[hi],delete s[Ta],delete s[$g],delete s[Tg])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function Xd(t){return t.tag===5||t.tag===3||t.tag===4}function Zd(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||Xd(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function hl(t,s,a){var u=t.tag;if(u===5||u===6)t=t.stateNode,s?a.nodeType===8?a.parentNode.insertBefore(t,s):a.insertBefore(t,s):(a.nodeType===8?(s=a.parentNode,s.insertBefore(t,a)):(s=a,s.appendChild(t)),a=a._reactRootContainer,a!=null||s.onclick!==null||(s.onclick=pr));else if(u!==4&&(t=t.child,t!==null))for(hl(t,s,a),t=t.sibling;t!==null;)hl(t,s,a),t=t.sibling}function ml(t,s,a){var u=t.tag;if(u===5||u===6)t=t.stateNode,s?a.insertBefore(t,s):a.appendChild(t);else if(u!==4&&(t=t.child,t!==null))for(ml(t,s,a),t=t.sibling;t!==null;)ml(t,s,a),t=t.sibling}var nt=null,Dt=!1;function $n(t,s,a){for(a=a.child;a!==null;)ef(t,s,a),a=a.sibling}function ef(t,s,a){if(Wt&&typeof Wt.onCommitFiberUnmount=="function")try{Wt.onCommitFiberUnmount(Ji,a)}catch{}switch(a.tag){case 5:lt||Ns(a,s);case 6:var u=nt,f=Dt;nt=null,$n(t,s,a),nt=u,Dt=f,nt!==null&&(Dt?(t=nt,a=a.stateNode,t.nodeType===8?t.parentNode.removeChild(a):t.removeChild(a)):nt.removeChild(a.stateNode));break;case 18:nt!==null&&(Dt?(t=nt,a=a.stateNode,t.nodeType===8?$a(t.parentNode,a):t.nodeType===1&&$a(t,a),ni(t)):$a(nt,a.stateNode));break;case 4:u=nt,f=Dt,nt=a.stateNode.containerInfo,Dt=!0,$n(t,s,a),nt=u,Dt=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)&&dl(a,s,y),f=f.next}while(f!==u)}$n(t,s,a);break;case 1:if(!lt&&(Ns(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)}$n(t,s,a);break;case 21:$n(t,s,a);break;case 22:a.mode&1?(lt=(u=lt)||a.memoizedState!==null,$n(t,s,a),lt=u):$n(t,s,a);break;default:$n(t,s,a)}}function tf(t){var s=t.updateQueue;if(s!==null){t.updateQueue=null;var a=t.stateNode;a===null&&(a=t.stateNode=new Hg),s.forEach(function(u){var f=ev.bind(null,t,u);a.has(u)||(a.add(u),u.then(f,f))})}}function Bt(t,s){var a=s.deletions;if(a!==null)for(var u=0;u<a.length;u++){var f=a[u];try{var p=t,y=s,N=y;e:for(;N!==null;){switch(N.tag){case 5:nt=N.stateNode,Dt=!1;break e;case 3:nt=N.stateNode.containerInfo,Dt=!0;break e;case 4:nt=N.stateNode.containerInfo,Dt=!0;break e}N=N.return}if(nt===null)throw Error(r(160));ef(p,y,f),nt=null,Dt=!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;)nf(s,t),s=s.sibling}function nf(t,s){var a=t.alternate,u=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(Bt(s,t),Gt(t),u&4){try{Ni(3,t,t.return),Dr(3,t)}catch(ne){_e(t,t.return,ne)}try{Ni(5,t,t.return)}catch(ne){_e(t,t.return,ne)}}break;case 1:Bt(s,t),Gt(t),u&512&&a!==null&&Ns(a,a.return);break;case 5:if(Bt(s,t),Gt(t),u&512&&a!==null&&Ns(a,a.return),t.flags&32){var f=t.stateNode;try{Vs(f,"")}catch(ne){_e(t,t.return,ne)}}if(u&4&&(f=t.stateNode,f!=null)){var p=t.memoizedProps,y=a!==null?a.memoizedProps:p,N=t.type,b=t.updateQueue;if(t.updateQueue=null,b!==null)try{N==="input"&&p.type==="radio"&&p.name!=null&&Mc(f,p),Vo(N,y);var L=Vo(N,p);for(y=0;y<b.length;y+=2){var F=b[y],H=b[y+1];F==="style"?Dc(f,H):F==="dangerouslySetInnerHTML"?_c(f,H):F==="children"?Vs(f,H):R(f,F,H,L)}switch(N){case"input":zo(f,p);break;case"textarea":Rc(f,p);break;case"select":var z=f._wrapperState.wasMultiple;f._wrapperState.wasMultiple=!!p.multiple;var Q=p.value;Q!=null?ss(f,!!p.multiple,Q,!1):z!==!!p.multiple&&(p.defaultValue!=null?ss(f,!!p.multiple,p.defaultValue,!0):ss(f,!!p.multiple,p.multiple?[]:"",!1))}f[hi]=p}catch(ne){_e(t,t.return,ne)}}break;case 6:if(Bt(s,t),Gt(t),u&4){if(t.stateNode===null)throw Error(r(162));f=t.stateNode,p=t.memoizedProps;try{f.nodeValue=p}catch(ne){_e(t,t.return,ne)}}break;case 3:if(Bt(s,t),Gt(t),u&4&&a!==null&&a.memoizedState.isDehydrated)try{ni(s.containerInfo)}catch(ne){_e(t,t.return,ne)}break;case 4:Bt(s,t),Gt(t);break;case 13:Bt(s,t),Gt(t),f=t.child,f.flags&8192&&(p=f.memoizedState!==null,f.stateNode.isHidden=p,!p||f.alternate!==null&&f.alternate.memoizedState!==null||(vl=ze())),u&4&&tf(t);break;case 22:if(F=a!==null&&a.memoizedState!==null,t.mode&1?(lt=(L=lt)||F,Bt(s,t),lt=L):Bt(s,t),Gt(t),u&8192){if(L=t.memoizedState!==null,(t.stateNode.isHidden=L)&&!F&&(t.mode&1)!==0)for(J=t,F=t.child;F!==null;){for(H=J=F;J!==null;){switch(z=J,Q=z.child,z.tag){case 0:case 11:case 14:case 15:Ni(4,z,z.return);break;case 1:Ns(z,z.return);var Z=z.stateNode;if(typeof Z.componentWillUnmount=="function"){u=z,a=z.return;try{s=u,Z.props=s.memoizedProps,Z.state=s.memoizedState,Z.componentWillUnmount()}catch(ne){_e(u,a,ne)}}break;case 5:Ns(z,z.return);break;case 22:if(z.memoizedState!==null){of(H);continue}}Q!==null?(Q.return=z,J=Q):of(H)}F=F.sibling}e:for(F=null,H=t;;){if(H.tag===5){if(F===null){F=H;try{f=H.stateNode,L?(p=f.style,typeof p.setProperty=="function"?p.setProperty("display","none","important"):p.display="none"):(N=H.stateNode,b=H.memoizedProps.style,y=b!=null&&b.hasOwnProperty("display")?b.display:null,N.style.display=Pc("display",y))}catch(ne){_e(t,t.return,ne)}}}else if(H.tag===6){if(F===null)try{H.stateNode.nodeValue=L?"":H.memoizedProps}catch(ne){_e(t,t.return,ne)}}else if((H.tag!==22&&H.tag!==23||H.memoizedState===null||H===t)&&H.child!==null){H.child.return=H,H=H.child;continue}if(H===t)break e;for(;H.sibling===null;){if(H.return===null||H.return===t)break e;F===H&&(F=null),H=H.return}F===H&&(F=null),H.sibling.return=H.return,H=H.sibling}}break;case 19:Bt(s,t),Gt(t),u&4&&tf(t);break;case 21:break;default:Bt(s,t),Gt(t)}}function Gt(t){var s=t.flags;if(s&2){try{e:{for(var a=t.return;a!==null;){if(Xd(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&&(Vs(f,""),u.flags&=-33);var p=Zd(t);ml(t,p,f);break;case 3:case 4:var y=u.stateNode.containerInfo,N=Zd(t);hl(t,N,y);break;default:throw Error(r(161))}}catch(b){_e(t,t.return,b)}t.flags&=-3}s&4096&&(t.flags&=-4097)}function Kg(t,s,a){J=t,sf(t)}function sf(t,s,a){for(var u=(t.mode&1)!==0;J!==null;){var f=J,p=f.child;if(f.tag===22&&u){var y=f.memoizedState!==null||Pr;if(!y){var N=f.alternate,b=N!==null&&N.memoizedState!==null||lt;N=Pr;var L=lt;if(Pr=y,(lt=b)&&!L)for(J=f;J!==null;)y=J,b=y.child,y.tag===22&&y.memoizedState!==null?af(f):b!==null?(b.return=y,J=b):af(f);for(;p!==null;)J=p,sf(p),p=p.sibling;J=f,Pr=N,lt=L}rf(t)}else(f.subtreeFlags&8772)!==0&&p!==null?(p.return=f,J=p):rf(t)}}function rf(t){for(;J!==null;){var s=J;if((s.flags&8772)!==0){var a=s.alternate;try{if((s.flags&8772)!==0)switch(s.tag){case 0:case 11:case 15:lt||Dr(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:Pt(s.type,a.memoizedProps);u.componentDidUpdate(f,a.memoizedState,u.__reactInternalSnapshotBeforeUpdate)}var p=s.updateQueue;p!==null&&rd(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}rd(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 H=F.dehydrated;H!==null&&ni(H)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(r(163))}lt||s.flags&512&&fl(s)}catch(z){_e(s,s.return,z)}}if(s===t){J=null;break}if(a=s.sibling,a!==null){a.return=s.return,J=a;break}J=s.return}}function of(t){for(;J!==null;){var s=J;if(s===t){J=null;break}var a=s.sibling;if(a!==null){a.return=s.return,J=a;break}J=s.return}}function af(t){for(;J!==null;){var s=J;try{switch(s.tag){case 0:case 11:case 15:var a=s.return;try{Dr(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{fl(s)}catch(b){_e(s,p,b)}break;case 5:var y=s.return;try{fl(s)}catch(b){_e(s,y,b)}}}catch(b){_e(s,s.return,b)}if(s===t){J=null;break}var N=s.sibling;if(N!==null){N.return=s.return,J=N;break}J=s.return}}var Gg=Math.ceil,Br=X.ReactCurrentDispatcher,pl=X.ReactCurrentOwner,Mt=X.ReactCurrentBatchConfig,je=0,Xe=null,He=null,st=0,Nt=0,bs=jn(0),Qe=0,bi=null,Gn=0,zr=0,gl=0,Ci=null,vt=null,vl=0,Cs=1/0,un=null,Fr=!1,yl=null,Tn=null,Ur=!1,En=null,Wr=0,$i=0,kl=null,Hr=-1,Vr=0;function ft(){return(je&6)!==0?ze():Hr!==-1?Hr:Hr=ze()}function Mn(t){return(t.mode&1)===0?1:(je&2)!==0&&st!==0?st&-st:Mg.transition!==null?(Vr===0&&(Vr=Zc()),Vr):(t=be,t!==0||(t=window.event,t=t===void 0?16:lu(t.type)),t)}function zt(t,s,a,u){if(50<$i)throw $i=0,kl=null,Error(r(185));Js(t,a,u),((je&2)===0||t!==Xe)&&(t===Xe&&((je&2)===0&&(zr|=a),Qe===4&&In(t,st)),yt(t,u),a===1&&je===0&&(s.mode&1)===0&&(Cs=ze()+500,kr&&Nn()))}function yt(t,s){var a=t.callbackNode;Mp(t,s);var u=er(t,t===Xe?st:0);if(u===0)a!==null&&Yc(a),t.callbackNode=null,t.callbackPriority=0;else if(s=u&-u,t.callbackPriority!==s){if(a!=null&&Yc(a),s===1)t.tag===0?Eg(cf.bind(null,t)):Gu(cf.bind(null,t)),bg(function(){(je&6)===0&&Nn()}),a=null;else{switch(eu(u)){case 1:a=Xo;break;case 4:a=Jc;break;case 16:a=Yi;break;case 536870912:a=Xc;break;default:a=Yi}a=vf(a,lf.bind(null,t))}t.callbackPriority=s,t.callbackNode=a}}function lf(t,s){if(Hr=-1,Vr=0,(je&6)!==0)throw Error(r(327));var a=t.callbackNode;if($s()&&t.callbackNode!==a)return null;var u=er(t,t===Xe?st:0);if(u===0)return null;if((u&30)!==0||(u&t.expiredLanes)!==0||s)s=Kr(t,u);else{s=u;var f=je;je|=2;var p=df();(Xe!==t||st!==s)&&(un=null,Cs=ze()+500,Qn(t,s));do try{Yg();break}catch(N){uf(t,N)}while(!0);Pa(),Br.current=p,je=f,He!==null?s=0:(Xe=null,st=0,s=Qe)}if(s!==0){if(s===2&&(f=Zo(t),f!==0&&(u=f,s=xl(t,f))),s===1)throw a=bi,Qn(t,0),In(t,u),yt(t,ze()),a;if(s===6)In(t,u);else{if(f=t.current.alternate,(u&30)===0&&!qg(f)&&(s=Kr(t,u),s===2&&(p=Zo(t),p!==0&&(u=p,s=xl(t,p))),s===1))throw a=bi,Qn(t,0),In(t,u),yt(t,ze()),a;switch(t.finishedWork=f,t.finishedLanes=u,s){case 0:case 1:throw Error(r(345));case 2:Yn(t,vt,un);break;case 3:if(In(t,u),(u&130023424)===u&&(s=vl+500-ze(),10<s)){if(er(t,0)!==0)break;if(f=t.suspendedLanes,(f&u)!==u){ft(),t.pingedLanes|=t.suspendedLanes&f;break}t.timeoutHandle=Ca(Yn.bind(null,t,vt,un),s);break}Yn(t,vt,un);break;case 4:if(In(t,u),(u&4194240)===u)break;for(s=t.eventTimes,f=-1;0<u;){var y=31-Lt(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*Gg(u/1960))-u,10<u){t.timeoutHandle=Ca(Yn.bind(null,t,vt,un),u);break}Yn(t,vt,un);break;case 5:Yn(t,vt,un);break;default:throw Error(r(329))}}}return yt(t,ze()),t.callbackNode===a?lf.bind(null,t):null}function xl(t,s){var a=Ci;return t.current.memoizedState.isDehydrated&&(Qn(t,s).flags|=256),t=Kr(t,s),t!==2&&(s=vt,vt=a,s!==null&&wl(s)),t}function wl(t){vt===null?vt=t:vt.push.apply(vt,t)}function qg(t){for(var s=t;;){if(s.flags&16384){var a=s.updateQueue;if(a!==null&&(a=a.stores,a!==null))for(var u=0;u<a.length;u++){var f=a[u],p=f.getSnapshot;f=f.value;try{if(!Ot(p(),f))return!1}catch{return!1}}}if(a=s.child,s.subtreeFlags&16384&&a!==null)a.return=s,s=a;else{if(s===t)break;for(;s.sibling===null;){if(s.return===null||s.return===t)return!0;s=s.return}s.sibling.return=s.return,s=s.sibling}}return!0}function In(t,s){for(s&=~gl,s&=~zr,t.suspendedLanes|=s,t.pingedLanes&=~s,t=t.expirationTimes;0<s;){var a=31-Lt(s),u=1<<a;t[a]=-1,s&=~u}}function cf(t){if((je&6)!==0)throw Error(r(327));$s();var s=er(t,0);if((s&1)===0)return yt(t,ze()),null;var a=Kr(t,s);if(t.tag!==0&&a===2){var u=Zo(t);u!==0&&(s=u,a=xl(t,u))}if(a===1)throw a=bi,Qn(t,0),In(t,s),yt(t,ze()),a;if(a===6)throw Error(r(345));return t.finishedWork=t.current.alternate,t.finishedLanes=s,Yn(t,vt,un),yt(t,ze()),null}function jl(t,s){var a=je;je|=1;try{return t(s)}finally{je=a,je===0&&(Cs=ze()+500,kr&&Nn())}}function qn(t){En!==null&&En.tag===0&&(je&6)===0&&$s();var s=je;je|=1;var a=Mt.transition,u=be;try{if(Mt.transition=null,be=1,t)return t()}finally{be=u,Mt.transition=a,je=s,(je&6)===0&&Nn()}}function Sl(){Nt=bs.current,Me(bs)}function Qn(t,s){t.finishedWork=null,t.finishedLanes=0;var a=t.timeoutHandle;if(a!==-1&&(t.timeoutHandle=-1,Ng(a)),He!==null)for(a=He.return;a!==null;){var u=a;switch(Aa(u),u.tag){case 1:u=u.type.childContextTypes,u!=null&&vr();break;case 3:js(),Me(mt),Me(rt),Va();break;case 5:Wa(u);break;case 4:js();break;case 13:Me(Le);break;case 19:Me(Le);break;case 10:Da(u.type._context);break;case 22:case 23:Sl()}a=a.return}if(Xe=t,He=t=An(t.current,null),st=Nt=s,Qe=0,bi=null,gl=zr=Gn=0,vt=Ci=null,Hn!==null){for(s=0;s<Hn.length;s++)if(a=Hn[s],u=a.interleaved,u!==null){a.interleaved=null;var f=u.next,p=a.pending;if(p!==null){var y=p.next;p.next=f,u.next=y}a.pending=u}Hn=null}return t}function uf(t,s){do{var a=He;try{if(Pa(),Er.current=Rr,Mr){for(var u=Oe.memoizedState;u!==null;){var f=u.queue;f!==null&&(f.pending=null),u=u.next}Mr=!1}if(Kn=0,Je=qe=Oe=null,ki=!1,xi=0,pl.current=null,a===null||a.return===null){Qe=1,bi=s,He=null;break}e:{var p=t,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,H=F.tag;if((F.mode&1)===0&&(H===0||H===11||H===15)){var z=F.alternate;z?(F.updateQueue=z.updateQueue,F.memoizedState=z.memoizedState,F.lanes=z.lanes):(F.updateQueue=null,F.memoizedState=null)}var Q=Ld(y);if(Q!==null){Q.flags&=-257,Od(Q,y,N,p,s),Q.mode&1&&Rd(p,L,s),s=Q,b=L;var Z=s.updateQueue;if(Z===null){var ne=new Set;ne.add(b),s.updateQueue=ne}else Z.add(b);break e}else{if((s&1)===0){Rd(p,L,s),Nl();break e}b=Error(r(426))}}else if(Ae&&N.mode&1){var Fe=Ld(y);if(Fe!==null){(Fe.flags&65536)===0&&(Fe.flags|=256),Od(Fe,y,N,p,s),Oa(Ss(b,N));break e}}p=b=Ss(b,N),Qe!==4&&(Qe=2),Ci===null?Ci=[p]:Ci.push(p),p=y;do{switch(p.tag){case 3:p.flags|=65536,s&=-s,p.lanes|=s;var M=Id(p,b,s);id(p,M);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"&&(Tn===null||!Tn.has(A)))){p.flags|=65536,s&=-s,p.lanes|=s;var V=Ad(p,N,s);id(p,V);break e}}p=p.return}while(p!==null)}hf(a)}catch(re){s=re,He===a&&a!==null&&(He=a=a.return);continue}break}while(!0)}function df(){var t=Br.current;return Br.current=Rr,t===null?Rr:t}function Nl(){(Qe===0||Qe===3||Qe===2)&&(Qe=4),Xe===null||(Gn&268435455)===0&&(zr&268435455)===0||In(Xe,st)}function Kr(t,s){var a=je;je|=2;var u=df();(Xe!==t||st!==s)&&(un=null,Qn(t,s));do try{Qg();break}catch(f){uf(t,f)}while(!0);if(Pa(),je=a,Br.current=u,He!==null)throw Error(r(261));return Xe=null,st=0,Qe}function Qg(){for(;He!==null;)ff(He)}function Yg(){for(;He!==null&&!wp();)ff(He)}function ff(t){var s=gf(t.alternate,t,Nt);t.memoizedProps=t.pendingProps,s===null?hf(t):He=s,pl.current=null}function hf(t){var s=t;do{var a=s.alternate;if(t=s.return,(s.flags&32768)===0){if(a=Ug(a,s,Nt),a!==null){He=a;return}}else{if(a=Wg(a,s),a!==null){a.flags&=32767,He=a;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{Qe=6,He=null;return}}if(s=s.sibling,s!==null){He=s;return}He=s=t}while(s!==null);Qe===0&&(Qe=5)}function Yn(t,s,a){var u=be,f=Mt.transition;try{Mt.transition=null,be=1,Jg(t,s,a,u)}finally{Mt.transition=f,be=u}return null}function Jg(t,s,a,u){do $s();while(En!==null);if((je&6)!==0)throw Error(r(327));a=t.finishedWork;var f=t.finishedLanes;if(a===null)return null;if(t.finishedWork=null,t.finishedLanes=0,a===t.current)throw Error(r(177));t.callbackNode=null,t.callbackPriority=0;var p=a.lanes|a.childLanes;if(Ip(t,p),t===Xe&&(He=Xe=null,st=0),(a.subtreeFlags&2064)===0&&(a.flags&2064)===0||Ur||(Ur=!0,vf(Yi,function(){return $s(),null})),p=(a.flags&15990)!==0,(a.subtreeFlags&15990)!==0||p){p=Mt.transition,Mt.transition=null;var y=be;be=1;var N=je;je|=4,pl.current=null,Vg(t,a),nf(a,t),vg(Na),sr=!!Sa,Na=Sa=null,t.current=a,Kg(a),jp(),je=N,be=y,Mt.transition=p}else t.current=a;if(Ur&&(Ur=!1,En=t,Wr=f),p=t.pendingLanes,p===0&&(Tn=null),bp(a.stateNode),yt(t,ze()),s!==null)for(u=t.onRecoverableError,a=0;a<s.length;a++)f=s[a],u(f.value,{componentStack:f.stack,digest:f.digest});if(Fr)throw Fr=!1,t=yl,yl=null,t;return(Wr&1)!==0&&t.tag!==0&&$s(),p=t.pendingLanes,(p&1)!==0?t===kl?$i++:($i=0,kl=t):$i=0,Nn(),null}function $s(){if(En!==null){var t=eu(Wr),s=Mt.transition,a=be;try{if(Mt.transition=null,be=16>t?16:t,En===null)var u=!1;else{if(t=En,En=null,Wr=0,(je&6)!==0)throw Error(r(331));var f=je;for(je|=4,J=t.current;J!==null;){var p=J,y=p.child;if((J.flags&16)!==0){var N=p.deletions;if(N!==null){for(var b=0;b<N.length;b++){var L=N[b];for(J=L;J!==null;){var F=J;switch(F.tag){case 0:case 11:case 15:Ni(8,F,p)}var H=F.child;if(H!==null)H.return=F,J=H;else for(;J!==null;){F=J;var z=F.sibling,Q=F.return;if(Jd(F),F===L){J=null;break}if(z!==null){z.return=Q,J=z;break}J=Q}}}var Z=p.alternate;if(Z!==null){var ne=Z.child;if(ne!==null){Z.child=null;do{var Fe=ne.sibling;ne.sibling=null,ne=Fe}while(ne!==null)}}J=p}}if((p.subtreeFlags&2064)!==0&&y!==null)y.return=p,J=y;else e:for(;J!==null;){if(p=J,(p.flags&2048)!==0)switch(p.tag){case 0:case 11:case 15:Ni(9,p,p.return)}var M=p.sibling;if(M!==null){M.return=p.return,J=M;break e}J=p.return}}var C=t.current;for(J=C;J!==null;){y=J;var A=y.child;if((y.subtreeFlags&2064)!==0&&A!==null)A.return=y,J=A;else e:for(y=C;J!==null;){if(N=J,(N.flags&2048)!==0)try{switch(N.tag){case 0:case 11:case 15:Dr(9,N)}}catch(re){_e(N,N.return,re)}if(N===y){J=null;break e}var V=N.sibling;if(V!==null){V.return=N.return,J=V;break e}J=N.return}}if(je=f,Nn(),Wt&&typeof Wt.onPostCommitFiberRoot=="function")try{Wt.onPostCommitFiberRoot(Ji,t)}catch{}u=!0}return u}finally{be=a,Mt.transition=s}}return!1}function mf(t,s,a){s=Ss(a,s),s=Id(t,s,1),t=Cn(t,s,1),s=ft(),t!==null&&(Js(t,1,s),yt(t,s))}function _e(t,s,a){if(t.tag===3)mf(t,t,a);else for(;s!==null;){if(s.tag===3){mf(s,t,a);break}else if(s.tag===1){var u=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(Tn===null||!Tn.has(u))){t=Ss(a,t),t=Ad(s,t,1),s=Cn(s,t,1),t=ft(),s!==null&&(Js(s,1,t),yt(s,t));break}}s=s.return}}function Xg(t,s,a){var u=t.pingCache;u!==null&&u.delete(s),s=ft(),t.pingedLanes|=t.suspendedLanes&a,Xe===t&&(st&a)===a&&(Qe===4||Qe===3&&(st&130023424)===st&&500>ze()-vl?Qn(t,0):gl|=a),yt(t,s)}function pf(t,s){s===0&&((t.mode&1)===0?s=1:(s=Zi,Zi<<=1,(Zi&130023424)===0&&(Zi=4194304)));var a=ft();t=an(t,s),t!==null&&(Js(t,s,a),yt(t,a))}function Zg(t){var s=t.memoizedState,a=0;s!==null&&(a=s.retryLane),pf(t,a)}function ev(t,s){var a=0;switch(t.tag){case 13:var u=t.stateNode,f=t.memoizedState;f!==null&&(a=f.retryLane);break;case 19:u=t.stateNode;break;default:throw Error(r(314))}u!==null&&u.delete(s),pf(t,a)}var gf;gf=function(t,s,a){if(t!==null)if(t.memoizedProps!==s.pendingProps||mt.current)gt=!0;else{if((t.lanes&a)===0&&(s.flags&128)===0)return gt=!1,Fg(t,s,a);gt=(t.flags&131072)!==0}else gt=!1,Ae&&(s.flags&1048576)!==0&&qu(s,wr,s.index);switch(s.lanes=0,s.tag){case 2:var u=s.type;_r(t,s),t=s.pendingProps;var f=ps(s,rt.current);ws(s,a),f=qa(null,s,u,t,f,a);var p=Qa();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,yr(s)):p=!1,s.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,Fa(s),f.updater=Lr,s.stateNode=f,f._reactInternals=s,tl(s,u,t,a),s=rl(null,s,u,!0,p,a)):(s.tag=0,Ae&&p&&Ia(s),dt(null,s,f,a),s=s.child),s;case 16:u=s.elementType;e:{switch(_r(t,s),t=s.pendingProps,f=u._init,u=f(u._payload),s.type=u,f=s.tag=nv(u),t=Pt(u,t),f){case 0:s=il(null,s,u,t,a);break e;case 1:s=Fd(null,s,u,t,a);break e;case 11:s=_d(null,s,u,t,a);break e;case 14:s=Pd(null,s,u,Pt(u.type,t),a);break e}throw Error(r(306,u,""))}return s;case 0:return u=s.type,f=s.pendingProps,f=s.elementType===u?f:Pt(u,f),il(t,s,u,f,a);case 1:return u=s.type,f=s.pendingProps,f=s.elementType===u?f:Pt(u,f),Fd(t,s,u,f,a);case 3:e:{if(Ud(s),t===null)throw Error(r(387));u=s.pendingProps,p=s.memoizedState,f=p.element,sd(t,s),$r(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=Ss(Error(r(423)),s),s=Wd(t,s,u,a,f);break e}else if(u!==f){f=Ss(Error(r(424)),s),s=Wd(t,s,u,a,f);break e}else for(St=wn(s.stateNode.containerInfo.firstChild),jt=s,Ae=!0,_t=null,a=td(s,null,u,a),s.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(ys(),u===f){s=cn(t,s,a);break e}dt(t,s,u,a)}s=s.child}return s;case 5:return od(s),t===null&&La(s),u=s.type,f=s.pendingProps,p=t!==null?t.memoizedProps:null,y=f.children,ba(u,f)?y=null:p!==null&&ba(u,p)&&(s.flags|=32),zd(t,s),dt(t,s,y,a),s.child;case 6:return t===null&&La(s),null;case 13:return Hd(t,s,a);case 4:return Ua(s,s.stateNode.containerInfo),u=s.pendingProps,t===null?s.child=ks(s,null,u,a):dt(t,s,u,a),s.child;case 11:return u=s.type,f=s.pendingProps,f=s.elementType===u?f:Pt(u,f),_d(t,s,u,f,a);case 7:return dt(t,s,s.pendingProps,a),s.child;case 8:return dt(t,s,s.pendingProps.children,a),s.child;case 12:return dt(t,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(Nr,u._currentValue),u._currentValue=y,p!==null)if(Ot(p.value,y)){if(p.children===f.children&&!mt.current){s=cn(t,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=ln(-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),Ba(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),Ba(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}dt(t,s,f.children,a),s=s.child}return s;case 9:return f=s.type,u=s.pendingProps.children,ws(s,a),f=Tt(f),u=u(f),s.flags|=1,dt(t,s,u,a),s.child;case 14:return u=s.type,f=Pt(u,s.pendingProps),f=Pt(u.type,f),Pd(t,s,u,f,a);case 15:return Dd(t,s,s.type,s.pendingProps,a);case 17:return u=s.type,f=s.pendingProps,f=s.elementType===u?f:Pt(u,f),_r(t,s),s.tag=1,pt(u)?(t=!0,yr(s)):t=!1,ws(s,a),Ed(s,u,f),tl(s,u,f,a),rl(null,s,u,!0,t,a);case 19:return Kd(t,s,a);case 22:return Bd(t,s,a)}throw Error(r(156,s.tag))};function vf(t,s){return Qc(t,s)}function tv(t,s,a,u){this.tag=t,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=u,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function It(t,s,a,u){return new tv(t,s,a,u)}function bl(t){return t=t.prototype,!(!t||!t.isReactComponent)}function nv(t){if(typeof t=="function")return bl(t)?1:0;if(t!=null){if(t=t.$$typeof,t===$e)return 11;if(t===q)return 14}return 2}function An(t,s){var a=t.alternate;return a===null?(a=It(t.tag,s,t.key,t.mode),a.elementType=t.elementType,a.type=t.type,a.stateNode=t.stateNode,a.alternate=t,t.alternate=a):(a.pendingProps=s,a.type=t.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=t.flags&14680064,a.childLanes=t.childLanes,a.lanes=t.lanes,a.child=t.child,a.memoizedProps=t.memoizedProps,a.memoizedState=t.memoizedState,a.updateQueue=t.updateQueue,s=t.dependencies,a.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},a.sibling=t.sibling,a.index=t.index,a.ref=t.ref,a}function Gr(t,s,a,u,f,p){var y=2;if(u=t,typeof t=="function")bl(t)&&(y=1);else if(typeof t=="string")y=5;else e:switch(t){case se:return Jn(a.children,f,p,s);case oe:y=8,f|=8;break;case G:return t=It(12,a,s,f|2),t.elementType=G,t.lanes=p,t;case ie:return t=It(13,a,s,f),t.elementType=ie,t.lanes=p,t;case D:return t=It(19,a,s,f),t.elementType=D,t.lanes=p,t;case Y:return qr(a,f,p,s);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case ve:y=10;break e;case Be:y=9;break e;case $e:y=11;break e;case q:y=14;break e;case ae:y=16,u=null;break e}throw Error(r(130,t==null?t:typeof t,""))}return s=It(y,a,s,f),s.elementType=t,s.type=u,s.lanes=p,s}function Jn(t,s,a,u){return t=It(7,t,u,s),t.lanes=a,t}function qr(t,s,a,u){return t=It(22,t,u,s),t.elementType=Y,t.lanes=a,t.stateNode={isHidden:!1},t}function Cl(t,s,a){return t=It(6,t,null,s),t.lanes=a,t}function $l(t,s,a){return s=It(4,t.children!==null?t.children:[],t.key,s),s.lanes=a,s.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},s}function sv(t,s,a,u,f){this.tag=s,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=ea(0),this.expirationTimes=ea(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ea(0),this.identifierPrefix=u,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function Tl(t,s,a,u,f,p,y,N,b){return t=new sv(t,s,a,N,b),s===1?(s=1,p===!0&&(s|=8)):s=0,p=It(3,null,null,s),t.current=p,p.stateNode=t,p.memoizedState={element:u,isDehydrated:a,cache:null,transitions:null,pendingSuspenseBoundaries:null},Fa(p),t}function iv(t,s,a){var u=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:B,key:u==null?null:""+u,children:t,containerInfo:s,implementation:a}}function yf(t){if(!t)return Sn;t=t._reactInternals;e:{if(Bn(t)!==t||t.tag!==1)throw Error(r(170));var s=t;do{switch(s.tag){case 3:s=s.stateNode.context;break e;case 1:if(pt(s.type)){s=s.stateNode.__reactInternalMemoizedMergedChildContext;break e}}s=s.return}while(s!==null);throw Error(r(171))}if(t.tag===1){var a=t.type;if(pt(a))return Vu(t,a,s)}return s}function kf(t,s,a,u,f,p,y,N,b){return t=Tl(a,u,!0,t,f,p,y,N,b),t.context=yf(null),a=t.current,u=ft(),f=Mn(a),p=ln(u,f),p.callback=s??null,Cn(a,p,f),t.current.lanes=f,Js(t,f,u),yt(t,u),t}function Qr(t,s,a,u){var f=s.current,p=ft(),y=Mn(f);return a=yf(a),s.context===null?s.context=a:s.pendingContext=a,s=ln(p,y),s.payload={element:t},u=u===void 0?null:u,u!==null&&(s.callback=u),t=Cn(f,s,y),t!==null&&(zt(t,f,y,p),Cr(t,f,y)),y}function Yr(t){if(t=t.current,!t.child)return null;switch(t.child.tag){case 5:return t.child.stateNode;default:return t.child.stateNode}}function xf(t,s){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var a=t.retryLane;t.retryLane=a!==0&&a<s?a:s}}function El(t,s){xf(t,s),(t=t.alternate)&&xf(t,s)}function rv(){return null}var wf=typeof reportError=="function"?reportError:function(t){console.error(t)};function Ml(t){this._internalRoot=t}Jr.prototype.render=Ml.prototype.render=function(t){var s=this._internalRoot;if(s===null)throw Error(r(409));Qr(t,s,null,null)},Jr.prototype.unmount=Ml.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var s=t.containerInfo;qn(function(){Qr(null,t,null,null)}),s[nn]=null}};function Jr(t){this._internalRoot=t}Jr.prototype.unstable_scheduleHydration=function(t){if(t){var s=su();t={blockedOn:null,target:t,priority:s};for(var a=0;a<yn.length&&s!==0&&s<yn[a].priority;a++);yn.splice(a,0,t),a===0&&ou(t)}};function Il(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function Xr(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function jf(){}function ov(t,s,a,u,f){if(f){if(typeof u=="function"){var p=u;u=function(){var L=Yr(y);p.call(L)}}var y=kf(s,u,t,0,null,!1,!1,"",jf);return t._reactRootContainer=y,t[nn]=y.current,di(t.nodeType===8?t.parentNode:t),qn(),y}for(;f=t.lastChild;)t.removeChild(f);if(typeof u=="function"){var N=u;u=function(){var L=Yr(b);N.call(L)}}var b=Tl(t,0,!1,null,null,!1,!1,"",jf);return t._reactRootContainer=b,t[nn]=b.current,di(t.nodeType===8?t.parentNode:t),qn(function(){Qr(s,b,a,u)}),b}function Zr(t,s,a,u,f){var p=a._reactRootContainer;if(p){var y=p;if(typeof f=="function"){var N=f;f=function(){var b=Yr(y);N.call(b)}}Qr(s,y,t,f)}else y=ov(a,s,t,f,u);return Yr(y)}tu=function(t){switch(t.tag){case 3:var s=t.stateNode;if(s.current.memoizedState.isDehydrated){var a=Ys(s.pendingLanes);a!==0&&(ta(s,a|1),yt(s,ze()),(je&6)===0&&(Cs=ze()+500,Nn()))}break;case 13:qn(function(){var u=an(t,1);if(u!==null){var f=ft();zt(u,t,1,f)}}),El(t,1)}},na=function(t){if(t.tag===13){var s=an(t,134217728);if(s!==null){var a=ft();zt(s,t,134217728,a)}El(t,134217728)}},nu=function(t){if(t.tag===13){var s=Mn(t),a=an(t,s);if(a!==null){var u=ft();zt(a,t,s,u)}El(t,s)}},su=function(){return be},iu=function(t,s){var a=be;try{return be=t,s()}finally{be=a}},qo=function(t,s,a){switch(s){case"input":if(zo(t,a),s=a.name,a.type==="radio"&&s!=null){for(a=t;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll("input[name="+JSON.stringify(""+s)+'][type="radio"]'),s=0;s<a.length;s++){var u=a[s];if(u!==t&&u.form===t.form){var f=gr(u);if(!f)throw Error(r(90));Tc(u),zo(u,f)}}}break;case"textarea":Rc(t,a);break;case"select":s=a.value,s!=null&&ss(t,!!a.multiple,s,!1)}},Uc=jl,Wc=qn;var av={usingClientEntryPoint:!1,Events:[mi,hs,gr,zc,Fc,jl]},Ti={findFiberByHostInstance:zn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},lv={bundleType:Ti.bundleType,version:Ti.version,rendererPackageName:Ti.rendererPackageName,rendererConfig:Ti.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:X.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=Gc(t),t===null?null:t.stateNode},findFiberByHostInstance:Ti.findFiberByHostInstance||rv,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 eo=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!eo.isDisabled&&eo.supportsFiber)try{Ji=eo.inject(lv),Wt=eo}catch{}}return kt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=av,kt.createPortal=function(t,s){var a=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Il(s))throw Error(r(200));return iv(t,s,null,a)},kt.createRoot=function(t,s){if(!Il(t))throw Error(r(299));var a=!1,u="",f=wf;return s!=null&&(s.unstable_strictMode===!0&&(a=!0),s.identifierPrefix!==void 0&&(u=s.identifierPrefix),s.onRecoverableError!==void 0&&(f=s.onRecoverableError)),s=Tl(t,1,!1,null,null,a,!1,u,f),t[nn]=s.current,di(t.nodeType===8?t.parentNode:t),new Ml(s)},kt.findDOMNode=function(t){if(t==null)return null;if(t.nodeType===1)return t;var s=t._reactInternals;if(s===void 0)throw typeof t.render=="function"?Error(r(188)):(t=Object.keys(t).join(","),Error(r(268,t)));return t=Gc(s),t=t===null?null:t.stateNode,t},kt.flushSync=function(t){return qn(t)},kt.hydrate=function(t,s,a){if(!Xr(s))throw Error(r(200));return Zr(null,t,s,!0,a)},kt.hydrateRoot=function(t,s,a){if(!Il(t))throw Error(r(405));var u=a!=null&&a.hydratedSources||null,f=!1,p="",y=wf;if(a!=null&&(a.unstable_strictMode===!0&&(f=!0),a.identifierPrefix!==void 0&&(p=a.identifierPrefix),a.onRecoverableError!==void 0&&(y=a.onRecoverableError)),s=kf(s,null,t,1,a??null,f,!1,p,y),t[nn]=s.current,di(t),u)for(t=0;t<u.length;t++)a=u[t],f=a._getVersion,f=f(a._source),s.mutableSourceEagerHydrationData==null?s.mutableSourceEagerHydrationData=[a,f]:s.mutableSourceEagerHydrationData.push(a,f);return new Jr(s)},kt.render=function(t,s,a){if(!Xr(s))throw Error(r(200));return Zr(null,t,s,!1,a)},kt.unmountComponentAtNode=function(t){if(!Xr(t))throw Error(r(40));return t._reactRootContainer?(qn(function(){Zr(null,null,t,!1,function(){t._reactRootContainer=null,t[nn]=null})}),!0):!1},kt.unstable_batchedUpdates=jl,kt.unstable_renderSubtreeIntoContainer=function(t,s,a,u){if(!Xr(a))throw Error(r(200));if(t==null||t._reactInternals===void 0)throw Error(r(38));return Zr(t,s,a,!1,u)},kt.version="18.3.1-next-f1338f8080-20240426",kt}var Mf;function zh(){if(Mf)return Ll.exports;Mf=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(n){console.error(n)}}return e(),Ll.exports=vv(),Ll.exports}var If;function yv(){if(If)return to;If=1;var e=zh();return to.createRoot=e.createRoot,to.hydrateRoot=e.hydrateRoot,to}var kv=yv(),x=ic();const Is="teamtrail",ge={slug:Is,name:"Teamtrail",category:"The trail map for AI coding agents",tagline:"You pick the destination. Your agents walk the trail.",assistant:{name:"Scout"},labelPrefix:Is,dataDir:`.${Is}`,apiPrefix:`/__${Is}`,noRegisterEnv:`${Is.toUpperCase()}_NO_REGISTER`},$o=`${Is}.prefs`,To=e=>`${ge.labelPrefix}:${e}`,rc=To("map"),oc=To("hitl"),xv=e=>e==="task"||e==="execute",ac=To("plan-only"),po=["research","prototype","junction","task","execute"],Eo=[...po,"review"],ts="plan+execute",wv=["verifying","rework","blocked"],lc=["off","checks","checks+review","checks+review+human"],Fh=e=>lc.find(n=>n===e);function Fi(e){return e.type==="junction"||e.type==="prototype"?"hitl":e.type==="research"?"afk":e.hitl?"hitl":"afk"}const jv=["task","execute"];function Uh(e,n,r=ts){return e.state==="closed"?e.closeReason==="not_planned"?"out-of-scope":"decided":e.status==="verifying"?"verifying":e.status==="blocked"?"held":e.assignee?"claimed":e.status==="rework"?"rework":r==="plan-only"&&e.type==="execute"?"parked":e.blockedBy.some(l=>{var c;return((c=n.get(l))==null?void 0:c.state)==="open"})?"blocked":"frontier"}function Fs(e,n=ts){const r=new Map(e.map(o=>[o.id,o]));return new Map(e.map(o=>[o.id,Uh(o,r,n)]))}const Ue=200,Ve=56;function Af(e,n="LR",r=ts){var $e;const o=n==="LR"?330:124,l=n==="LR"?112:262,c=Fs(e,r),d=new Map(e.map(ie=>[ie.id,ie])),h=new Map,g=new Set,m=ie=>{if(h.has(ie))return h.get(ie);if(g.has(ie))return 0;g.add(ie);const D=d.get(ie),q=D&&D.blockedBy.length?1+Math.max(...D.blockedBy.filter(ae=>d.has(ae)).map(m),-1):0;return g.delete(ie),h.set(ie,q),q},v=e.filter(ie=>c.get(ie.id)!=="out-of-scope"),k=e.filter(ie=>c.get(ie.id)==="out-of-scope"),w=[];for(const ie of v)(w[$e=m(ie.id)]??(w[$e]=[])).push(ie);const j=[],T=new Map;let S=0;w.forEach(ie=>{ie&&(ie.sort((D,q)=>{const ae=Y=>{const U=Y.blockedBy.map(P=>T.get(P)).filter(P=>P!==void 0);return U.length?U.reduce((P,W)=>P+W,0)/U.length:Y.createdAt/1e12};return ae(D)-ae(q)||D.createdAt-q.createdAt}),S=Math.max(S,ie.length),ie.forEach((D,q)=>T.set(D.id,q)))}),w.forEach((ie,D)=>{if(!ie)return;const q=(S-ie.length)*l/2;ie.forEach((ae,Y)=>{const U=D*o,P=q+Y*l;j.push({ticket:ae,state:c.get(ae.id),layer:D,x:n==="LR"?U:P,y:n==="LR"?P:U})})});const I=Math.max(w.length,1)*o-(o-(n==="LR"?Ue:Ve)),O=Math.max(S,1)*l-(l-(n==="LR"?Ve:Ue)),R=n==="LR"?I:O,X=n==="LR"?O:I,te=X+54,B=Math.max(1,Math.floor((R+24)/(Ue+24)));k.forEach((ie,D)=>{j.push({ticket:ie,state:"out-of-scope",layer:-1,x:D%B*(Ue+24),y:te+Math.floor(D/B)*(Ve+16)})});const se=[],oe=new Map(j.map(ie=>[ie.ticket.id,ie]));for(const ie of j)for(const D of ie.ticket.blockedBy){const q=oe.get(D);q&&se.push({from:q,to:ie})}const G=Math.ceil(k.length/B),ve=Math.max(R,Math.min(k.length,B)*(Ue+24)-24),Be=k.length?te+G*(Ve+16)-16:X;return{direction:n,nodes:j,edges:se,width:ve,graphH:X,quarantineY:te,height:Be,quarantineH:G*(Ve+16)+24}}const Wh=["fast","balanced","strongest"],Hh=e=>Wh.includes(e),cc={research:"fast",task:"balanced",execute:"balanced",junction:"strongest",prototype:"strongest",review:"strongest"};function Sv(e,n){var r,o;return((o=(r=n.modelMatching)==null?void 0:r.tiers)==null?void 0:o[e.type])??cc[e.type]}function Nv(e){return Object.fromEntries(Eo.map(n=>[n,Sv({type:n},e)]))}const bv=["holding","challenged","invalidated","confirmed"],Cv=e=>bv.includes(e),Vh=ge.labelPrefix,$v=new RegExp(`^-\\s+(?:\\[([a-z]+)\\]\\s+)?(.*?)\\s*(?:<!-- ${Vh}:asm (\\{.*\\}) -->)?\\s*$`),Tv=1e3,Ev=e=>e.replace(/--/g,"-\\u002d"),Mv=e=>e.replace(/\s*\n\s*/g," ").trim();function Iv(e){const n={id:e.id,tickets:e.tickets,...e.source?{source:e.source}:{},...e.challenge?{challenge:{...e.challenge,evidence:e.challenge.evidence.slice(0,Tv)}}:{},...e.decidedBy?{decidedBy:e.decidedBy}:{}};return`- [${e.status}] ${Mv(e.text)} <!-- ${Vh}:asm ${Ev(JSON.stringify(n))} -->`}function Av(e){const n=e.map(Rv);let r=Math.max(0,...n.map(o=>Ov(o.id)))+1;return n.map(o=>o.id?o:{...o,id:`S-${r++}`})}function Rv(e){const n=e.match($v),r=n==null?void 0:n[1],o=(n==null?void 0:n[2])??e.replace(/^-\s+/,""),l=Lv(n==null?void 0:n[3]);return{id:l.id??"",text:o,status:Cv(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 Lv(e){if(!e)return{};try{const n=JSON.parse(e);return n&&typeof n=="object"?n:{}}catch{return{}}}function Ov(e){const n=e==null?void 0:e.match(/^S-(\d+)$/);return n?Number(n[1]):0}const Kh=[["destination","Destination"],["notes","Notes"],["assumptions","Assumptions"],["decisions","Decisions so far"],["unspecified","Not yet specified"],["outOfScope","Out of scope"]],_v=Object.fromEntries(Kh),Pv=/^-\s+(?:\[?([#A-Z0-9-]+)\]?:?\s+)?(.*)$/;function Dv(e){var o;const n=l=>l.length?l.map(c=>`- ${c}`).join(`
41
+ `):"_None yet._",r=l=>l.length?l.map(c=>`- ${c.ticketKey?`${c.ticketKey}: `:""}${c.text}`).join(`
42
+ `):"_None yet._";return[`## Destination
43
+
44
+ ${e.destination.trim()}`,`## Notes
45
+
46
+ ${e.notes.trim()||"_None yet._"}`,...(o=e.assumptions)!=null&&o.length?[`## Assumptions
47
+
48
+ ${e.assumptions.map(Iv).join(`
49
+ `)}`]:[],`## Decisions so far
50
+
51
+ ${r(e.decisions)}`,`## Not yet specified
52
+
53
+ ${n(e.unspecified)}`,`## Out of scope
54
+
55
+ ${n(e.outOfScope)}`].join(`
56
+
57
+ `)+`
58
+ `}function Bv(e){var o;const n={destination:"",notes:"",decisions:[],unspecified:[],outOfScope:[]},r=e.split(/^##\s+/m).slice(1);for(const l of r){const c=l.indexOf(`
59
+ `),d=l.slice(0,c===-1?void 0:c).trim().toLowerCase(),h=(c===-1?"":l.slice(c+1)).trim(),g=(o=Kh.find(([,k])=>k.toLowerCase()===d))==null?void 0:o[0];if(!g)continue;const m=/^_none yet\._$/i.test(h),v=m?[]:h.split(`
60
+ `).map(k=>k.trim()).filter(k=>k.startsWith("- "));g==="destination"?n.destination=h:g==="notes"?n.notes=m?"":h:g==="assumptions"?n.assumptions=Av(v):g==="decisions"?n.decisions=v.map(k=>{const w=k.match(Pv);return w&&w[1]&&/\d/.test(w[1])?{ticketKey:w[1],text:w[2]}:{text:k.slice(2)}}):n[g]=v.map(k=>k.slice(2))}return n}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"]},zv=(e,n)=>`${e[0].toUpperCase()}${e.slice(1)} ${n}/${Mo[e].length}`;async function Fv(e,n,r={}){var d,h,g;const o=Uv(n,n.mode??ts),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 k=c.get(v),w=c.get(m.ref);k&&(await e.addBlocking(l.id,k.id,w.id),await((g=r.onEdgeWired)==null?void 0:g.call(r,k,w)))}return{map:l,tickets:[...c.values()]}}function Uv(e,n){if(n==="plan+execute")return{...e,mode:n};const r=new Map(e.tickets.filter(l=>l.type==="execute").map(l=>[l.ref,l.blockedBy??[]])),o=l=>l.flatMap(c=>r.has(c)?o(r.get(c)):[c]);return{...e,mode:n,tickets:e.tickets.filter(l=>!r.has(l.ref)).map(l=>({...l,blockedBy:[...new Set(o(l.blockedBy??[]))]}))}}class Wv{constructor(){ue(this,"tails",new Map)}run(n,r){const l=(this.tails.get(n)??Promise.resolve()).catch(()=>{}).then(r);return this.tails.set(n,l),l.finally(()=>this.tails.get(n)===l&&this.tails.delete(n)).catch(()=>{}),l}}class De extends Error{}const Hv={frontier:"ready",blocked:"backlog",parked:"backlog",claimed:"working",verifying:"verifying",rework:"rework",held:"blocked",decided:"done","out-of-scope":"cancelled"};function Vv(e,n,r=ts){return Hv[Uh(e,n,r)]}const Kv=["backlog","ready","working","verifying","rework","blocked"],Mi=["agent","trail lead"],Gv=[{event:"claim",from:["ready","rework"],to:["working"],actors:Mi},{event:"release",from:["working"],to:["ready","rework"],actors:Mi},{event:"expire",from:["working"],to:["ready","rework"],actors:["engine","trail lead"]},{event:"complete",from:["backlog","ready","working","rework"],to:["done"],actors:Mi},{event:"submit",from:["working"],to:["verifying"],actors:Mi},{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:Kv,to:["cancelled"],actors:[...Mi,"engine"]},{event:"reopen",from:["done","cancelled"],to:["ready"],actors:["trail lead"]}],qv=e=>Gv.find(n=>n.event===e),Qv=new Wv;function Yv(e,n,r){if(r){if(!e.to.includes(r))throw new De(`${e.event} cannot lead to ${r}`);return r}if(e.to.length===1)return e.to[0];if(e.event==="release"||e.event==="expire")return n.status==="rework"?"rework":"ready";throw new De(`${e.event} needs a target: ${e.to.join(" or ")}`)}async function Jv(e,n,r,o){const{to:l,actor:c}=o,d=async h=>{(r.status??null)!==h&&await e.setMeta(n,r.id,{status:h})};switch(l){case"working":r.assignee!==c&&await e.assign(n,r.id,c);return;case"ready":case"rework":r.state==="closed"&&await e.reopen(n,r.id),await d(l==="rework"?"rework":null),r.assignee&&await e.assign(n,r.id,null);return;case"verifying":case"blocked":await d(l);return;case"done":case"cancelled":await d(null),await e.close(n,r.id,l==="done"?"completed":"not_planned");return;case"backlog":throw new De("backlog follows from blockers; no transition leads there")}}function Io(e,n,r,o){return Qv.run(`${n}/${r}`,async()=>{var m;const l=await e.loadMap(n),c=l.tickets.find(v=>v.id===r);if(!c)throw new De(`ticket ${r} not found`);const d=Vv(c,new Map(l.tickets.map(v=>[v.id,v])),l.map.mode);if(o.expect&&d!==o.expect)throw new De(`${c.key} changed: it is ${d} now`);const h=qv(o.event);if(!h.from.includes(d))throw new De(`${c.key} is ${d}; ${o.event} needs ${h.from.join(" or ")}`);if(!h.actors.includes(o.actorKind))throw new De(`${o.event} is not for ${o.actorKind}s`);const g=Yv(h,c,o.to);await Jv(e,n,c,{to:g,actor:o.actor});try{await((m=o.journal)==null?void 0:m.append({v:1,kind:"transition",at:Date.now(),mapId:n,ticketId:r,ticketKey:c.key,event:o.event,from:d,to:g,actor:o.actor,actorKind:o.actorKind,...o.reason?{reason:o.reason}:{},...o.sessionId?{sessionId:o.sessionId}:{}}))}catch{}return{ticket:c,from:d,to:g}})}async function Rf(e,n,r,o){const{assignee:l}=o,c=await e.loadMap(n),d=c.tickets.find(v=>v.id===r);if(!d)throw new De(`ticket ${r} not found`);const h=Fs(c.tickets,c.map.mode).get(r);if(h!=="frontier"&&h!=="rework")throw new De(`${d.key} is ${h}, not on the frontier`);await Io(e,n,r,{event:"claim",actor:l,actorKind:o.actorKind??"agent",reason:o.reason,sessionId:o.sessionId,journal:o.journal});const m=(await e.loadMap(n)).tickets.find(v=>v.id===r);if(m.assignee!==l)throw new De(`${d.key} was claimed by ${m.assignee}`);return m}async function Xv(e,n,r,o={}){const c=(await e.loadMap(n)).tickets.find(d=>d.id===r);if(!c)throw new De(`ticket ${r} not found`);await Io(e,n,r,{event:"release",actor:o.actor??c.assignee??"trail lead",actorKind:o.actorKind??"agent",reason:o.reason,sessionId:o.sessionId,journal:o.journal})}async function uc(e,n,r,o={}){if(r.source.ref){const c=(await e.listDecisions(n)).find(d=>d.source.kind===r.source.kind&&d.source.ref===r.source.ref);if(c)return c}const l=await e.createDecision(n,r);if(o.appendToTrail??!0){const c=await e.loadMap(n);await e.updateMapSections(n,{decisions:[...c.map.sections.decisions,{ticketId:l.ticketId,ticketKey:l.ticketKey,text:o.trailLine??l.summary}]})}return l}async function Zv(e,n,r,o){const c=(await e.listDecisions(n)).find(k=>k.id===r);if(!c)throw new De(`decision ${r} not found`);if(c.supersededBy)throw new De(`${c.id} is already superseded by ${c.supersededBy}`);const d=await e.createDecision(n,{ticketId:c.ticketId,ticketKey:c.ticketKey,...o,question:o.question??c.question,supersedes:c.id});await e.markSuperseded(n,c.id,d.id);const g=(await e.loadMap(n)).map.sections.decisions,m=g.findIndex(k=>k.text===c.summary||!!c.ticketId&&k.ticketId===c.ticketId||!!c.ticketKey&&k.ticketKey===c.ticketKey),v={ticketId:d.ticketId,ticketKey:d.ticketKey,text:d.summary};return await e.updateMapSections(n,{decisions:m<0?[...g,v]:g.map((k,w)=>w===m?v:k)}),d}async function ey(e,n,r){await e.setMapMode(n,r)}function Gh(e){return e==="plan-only"?po.filter(n=>n!=="execute"):po}function ty(e,n){if(!Gh(e).includes(n))throw new De(`${n} tickets are disabled on plan-only maps`)}const On={lookout:{label:"Lookout",code:"CMD"},agent:{label:"Agent",code:"AGT"},slack:{label:"Slack",code:"SLK"},tracker:{label:"Tracker",code:"TRK"}},go=Object.keys(On),ny=e=>e in On,_i=e=>e.source.kind==="agent"&&e.decidedBy!=="trail lead"&&!e.decidedBy.startsWith("slack:")?"agent":"human",Ui=e=>e.supersededBy?"superseded":"active";function Ao(e){const n=e.replace(/\s+/g," ").trim(),r=n.match(/^(.{20,180}?[.!?])(\s|$)/);return r?r[1]:n.slice(0,180)}function sy(e,n,r){var o;return{...r,id:e,mapId:n,decidedAt:r.decidedAt??Date.now(),summary:((o=r.summary)==null?void 0:o.trim())||Ao(r.answer),alternatives:r.alternatives??[],rationale:r.rationale??"",participants:r.participants??[{id:r.decidedBy}],transcript:r.transcript??[]}}const iy=e=>Number(e.replace(/\D/g,""))||0;function ry(e,n){const r=new Map(e.map(d=>[d.id,d])),o=new Set;let l=r.get(n);for(;l!=null&&l.supersedes&&r.has(l.supersedes)&&!o.has(l.id);)o.add(l.id),l=r.get(l.supersedes);const c=[];o.clear();for(let d=l;d&&!o.has(d.id);d=d.supersededBy?r.get(d.supersededBy):void 0)o.add(d.id),c.push(d);return c}async function oy(e,n,r,o){var h;const c=(await e.loadMap(n)).tickets.find(g=>g.id===r);if(!c)throw new De(`ticket ${r} not found`);if(c.state==="closed")throw new De(`${c.key} is already closed`);o.transcript&&await e.comment(n,r,o.author,`**HITL transcript**
63
+
64
+ ${o.transcript}`),await e.comment(n,r,o.author,`**Resolution**
65
+
66
+ ${o.answer}`),await Io(e,n,r,{event:o.event??"complete",actor:o.actor??o.author,actorKind:o.actorKind??"agent",sessionId:o.sessionId,reason:o.reason,journal:o.journal,...o.event&&o.event!=="complete"?{to:"done"}:{}});const d=o.decision??{};return await uc(e,n,{ticketId:c.id,ticketKey:c.key,question:d.question??c.title,answer:o.answer,summary:o.summary??Ao(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 ay(e,n,r,o){const l=await e.loadMap(n);if(!l.map.sections.unspecified.includes(r))throw new De(`"${r}" is not in Not yet specified`);ty(l.map.mode,o.type);const c=await e.createTicket(n,{title:o.title??r,type:o.type,hitl:o.hitl,body:`${o.body??`Promoted from Not yet specified: ${r}`}
67
+
68
+ Part of trail ${l.map.key}.`});for(const h of o.blockedBy??[])await e.addBlocking(n,h,c.id);const d=await e.loadMap(n);return await e.updateMapSections(n,{unspecified:d.map.sections.unspecified.filter(h=>h!==r)}),c}async function ly(e,n,r,o){const l=await e.loadMap(n),{unspecified:c,outOfScope:d}=l.map.sections;if("unspecified"in r){if(!c.includes(r.unspecified))throw new De(`"${r.unspecified}" is not in Not yet specified`);await e.updateMapSections(n,{unspecified:c.filter(m=>m!==r.unspecified),outOfScope:[...d,`${r.unspecified} — ${o.reason}`]});return}const h=l.tickets.find(m=>m.id===r.ticketId);if(!h)throw new De(`ticket ${r.ticketId} not found`);await e.comment(n,h.id,o.author,`**Ruled out of scope**
69
+
70
+ ${o.reason}`),await Io(e,n,h.id,{event:"cancel",actor:o.author,actorKind:o.actorKind??"agent",reason:o.reason,sessionId:o.sessionId,journal:o.journal}),await uc(e,n,{ticketId:h.id,ticketKey:h.key,question:h.title,answer:`Out of scope: ${o.reason}`,decidedBy:o.author,source:o.source??{kind:"agent",label:o.author}},{appendToTrail:!1});const g=await e.loadMap(n);await e.updateMapSections(n,{outOfScope:[...g.map.sections.outOfScope,`${h.key} ${h.title} — ${o.reason}`]})}async function cy(e,n,r,o){r&&uy(r),await e.setMapMeta(n,{modelMatching:r&&dy(r)})}function uy(e){if(typeof e.enabled!="boolean")throw new De('"enabled" must be true or false');for(const[n,r]of Object.entries(e.tiers??{})){if(!Eo.includes(n))throw new De(`unknown ticket type "${n}"`);if(!Hh(r))throw new De(`"${n}" must be fast, balanced or strongest`)}}function dy(e){const n=Object.fromEntries(Object.entries(e.tiers??{}).filter(([,r])=>r));return Object.keys(n).length?{enabled:e.enabled,tiers:n}:{enabled:e.enabled}}function fy(e){return{async append(n){await fetch(`${e}/journal`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}}}const qh={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(qh));const hy=2*6e4,Pl=e=>e<6e4?`${Math.round(e/1e3)}s`:`${Math.round(e/6e4)}m`;function my(e,n){if(!e)return{tone:"unknown",label:"PR sync ?",title:"PR/CI sync state unavailable"};const r=e.repo?` · ${e.repo}`:"",o=e.lastOkAt?`last ok ${Pl(n-e.lastOkAt)} ago`:"never synced";return e.state==="off"?{tone:"off",label:"PR sync off",title:`PR/CI sync off: ${e.reason??"disabled"}`}:e.state==="failed"?{tone:"failed",label:"PR sync failed",title:`${e.reason??"sync failed"}${r}
71
+ ${o}`}:e.state==="rate-limited"?{tone:"failed",label:"PR sync paused",title:`Rate limited${r}; retrying ${e.nextAt?`in ${Pl(Math.max(0,e.nextAt-n))}`:"later"}
72
+ ${o}`}:!e.lastOkAt||e.lastOkAt!==e.lastAttemptAt||e.nextAt!==void 0&&n>e.nextAt+hy?{tone:"stale",label:"PR sync stale",title:`No recent sync${r}
73
+ ${o}`}:{tone:"ok",label:`PR sync ${Pl(n-e.lastOkAt)}`,title:`PR/CI synced${r}, ${o}`}}class Os{constructor(){ue(this,"listeners",new Set)}on(n){return this.listeners.add(n),()=>this.listeners.delete(n)}emit(n){for(const r of[...this.listeners])r(n)}}let py=0;const ho=(e="id")=>`${e}_${Date.now().toString(36)}${(py++).toString(36)}`,Hl=(e,n)=>({inputTokens:((e==null?void 0:e.inputTokens)??0)+n.inputTokens,outputTokens:((e==null?void 0:e.outputTokens)??0)+n.outputTokens,costUsd:((e==null?void 0:e.costUsd)??0)+n.costUsd,...e!=null&&e.cachedInputTokens||n.cachedInputTokens?{cachedInputTokens:((e==null?void 0:e.cachedInputTokens)??0)+(n.cachedInputTokens??0)}:{}}),Qh=(e,n)=>({inputTokens:e.inputTokens-((n==null?void 0:n.inputTokens)??0),outputTokens:e.outputTokens-((n==null?void 0:n.outputTokens)??0),costUsd:e.costUsd-((n==null?void 0:n.costUsd)??0),...e.cachedInputTokens||n!=null&&n.cachedInputTokens?{cachedInputTokens:(e.cachedInputTokens??0)-((n==null?void 0:n.cachedInputTokens)??0)}:{}});function gy(e,n,r){const o=()=>e.find(n.id)??n,l=c=>e.push({source:"session",sessionId:n.id,agent:n.agent,...c});return{id:n.id,get info(){return o()},step(c,d,h){const g=Mo[r][c-1];e.patchSession(n.id,{step:c,stepLabel:g,...h?{ticketId:h}:{}}),l({tag:zv(r,c),level:"step",text:d?`${g}: ${d}`:g,ticketId:h??o().ticketId})},log(c,d="info"){l({level:d,text:c,ticketId:o().ticketId})},say(c){e.chat({sessionId:n.id,ticketId:o().ticketId,from:"agent",author:n.agent,text:c})},ask(c,d,h){var m;const g={id:ho("q"),sessionId:n.id,mapId:n.mapId,ticketId:o().ticketId,agent:n.agent,text:c,suggestions:d,at:Date.now(),...h!=null&&h.urgency?{urgency:h.urgency}:{},...(m=h==null?void 0:h.blocks)!=null&&m.length?{blocks:h.blocks}:{}};return e.chat({sessionId:n.id,ticketId:g.ticketId,from:"agent",author:n.agent,text:c,questionId:g.id}),e.addPending(g),e.patchSession(n.id,{waitingOn:g.id}),l({level:"alert",ticketId:g.ticketId,text:"Decision request · waiting on you",signal:!0}),e.awaitAnswer(g.id)},done(c=!0,d,h){e.patchSession(n.id,{status:c?"done":"failed",endedAt:Date.now(),waitingOn:void 0}),e.dropPending(n.id),l({level:c?"ok":"alert",text:d??(c?"Session closed":"Session aborted"),signal:h==null?void 0:h.signal})},bindMap(c){var h;const d=o().usage;d&&(e.addMapUsage(c,d),(h=e.ledger())==null||h.add(c,d,n.id)),e.patchSession(n.id,{mapId:c})},usage(c){var g;const d=o().mapId;(g=e.ledger())==null||g.add(d,c,n.id),e.addMapUsage(d,c);const h=o().usage;e.patchSession(n.id,{usage:{...Hl(h,c),source:c.source??(h==null?void 0:h.source)}})},setUsage(c){var v;const d=o().usage,h=Qh(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,n.id)),e.addMapUsage(m,h),e.patchSession(n.id,{usage:c})},setModel(c,d){const h=o();h.model===c&&h.tier===d||e.patchSession(n.id,{model:c,tier:d})}}}class vy{constructor(n=400,r){ue(this,"state",{sessions:[],feed:[],chats:[],pending:[],answered:[],usageByMap:{}});ue(this,"changes",new Os);ue(this,"resolvers",new Map);ue(this,"remote",new Map);ue(this,"remoteAnswer");ue(this,"host",{find:n=>this.state.sessions.find(r=>r.id===n),patchSession:(n,r)=>this.patchSession(n,r),push:n=>void this.push(n),chat:n=>this.chat(n),addPending:n=>this.set({pending:[...this.state.pending,n]}),dropPending:n=>{this.state.pending.filter(o=>o.sessionId===n).length&&this.set({pending:this.state.pending.filter(o=>o.sessionId!==n)})},awaitAnswer:n=>new Promise(r=>this.resolvers.set(n,r)),addMapUsage:(n,r)=>{this.state={...this.state,usageByMap:{...this.state.usageByMap,[n]:Hl(this.state.usageByMap[n],r)}}},ledger:()=>this.ledger});this.maxFeed=n,this.ledger=r}get snapshot(){return this.state}subscribe(n){return this.changes.on(n)}set(n){this.state={...this.state,...n},this.changes.emit(this.state)}push(n){const r={id:ho("f"),at:n.at??Date.now(),...n};return r.source==="system"&&!r.agent&&(r.agent=ge.assistant.name),this.set({feed:[...this.state.feed,r].slice(-this.maxFeed)}),r}patchSession(n,r){this.set({sessions:this.state.sessions.map(o=>o.id===n?{...o,...r}:o)})}chat(n){this.set({chats:[...this.state.chats,{id:ho("m"),at:Date.now(),...n}].slice(-600)})}answer(n,r,o){const l=this.state.pending.find(h=>h.id===n),c=this.resolvers.get(n),d=!!l&&this.remote.has(l.sessionId)&&!!this.remoteAnswer;return!l||!c&&!d?!1:(this.resolvers.delete(n),this.chat({sessionId:l.sessionId,ticketId:l.ticketId,from:"human",author:o,text:r}),this.set({pending:this.state.pending.filter(h=>h.id!==n),answered:[...this.state.answered,{id:l.id,mapId:l.mapId,sessionId:l.sessionId,agent:l.agent,askedAt:l.at,answeredAt:Date.now()}].slice(-200)}),this.patchSession(l.sessionId,{waitingOn:void 0}),this.push({source:"trail lead",agent:o,level:"ok",ticketId:l.ticketId,sessionId:l.sessionId,text:`Answered ${l.agent}`}),c?c(r):this.remoteAnswer(l,r,o),!0)}syncRemote(n){var m;const{session:r}=n,o=r.id;if(!this.remote.has(o)&&this.state.sessions.some(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=Qh(r.usage,l);(v.inputTokens||v.outputTokens||v.costUsd)&&(c={...c,[r.mapId]:Hl(c[r.mapId],v)}),(m=this.ledger)==null||m.addTotal(r.mapId,o,r.usage)}const d=v=>v.filter(k=>k.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),...n.chats].sort((v,k)=>v.at-k.at).slice(-600),pending:[...d(this.state.pending),...n.pending],answered:[...this.state.answered,...n.answered.filter(v=>!h.has(v.id))].sort((v,k)=>v.answeredAt-k.answeredAt).slice(-200),feed:[...this.state.feed.filter(v=>v.sessionId!==o),...n.feed].sort((v,k)=>v.at-k.at).slice(-this.maxFeed),usageByMap:c})}isRemote(n){return this.remote.has(n)}startSession(n){const r={...n,id:n.id??ho("s"),step:0,total:Mo[n.mode].length,stepLabel:"BOOT",status:"running",startedAt:Date.now()};this.set({sessions:[...this.state.sessions,r].slice(-24)});const o=gy(this.host,r,n.mode);return this.push({source:"session",sessionId:r.id,agent:r.agent,level:"info",text:`Session opened · ${n.mode}`}),o}}function yy(e,n){const r=o=>{var l;return((l=n(o))==null?void 0:l.key)??o};switch(e.kind){case"map.created":return{source:"tracker",level:"ok",text:`Trail created · label ${rc}`};case"map.updated":return{source:"tracker",level:"info",text:`Trail updated${e.section?` · ${_v[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 ky=new Set(["createMap","setMapMode","setMapMeta","updateMapSections","createTicket","addBlocking","removeBlocking","editTicket","reopen","assign","comment","close","setMeta","createDecision","markSuperseded"]),xy=5*6e4;function wy(e){let n={status:"idle",inflight:0,writes:0,errors:0,events:[]};const r=new Os,o=c=>{n={...n,...c},r.emit(n)};return e.subscribe(c=>{const d=c.at-xy;o({events:[...n.events.filter(h=>h.at>=d),{at:c.at,external:c.kind==="external.changed"||"external"in c&&!!c.external}]})}),{adapter:new Proxy(e,{get(c,d,h){const g=Reflect.get(c,d,h);return typeof g!="function"?g:ky.has(d)?async(...m)=>{const v=Date.now();o({inflight:n.inflight+1,status:"syncing"});try{const k=await g.apply(c,m),w=n.inflight-1;return o({inflight:w,writes:n.writes+1,lastWriteMs:Date.now()-v,lastWriteAt:Date.now(),status:w?"syncing":"ok",lastError:void 0}),k}catch(k){const w=n.inflight-1;throw o({inflight:w,errors:n.errors+1,status:"error",lastError:String(k.message??k)}),k}}:g.bind(c)}}),get health(){return n},subscribe:c=>r.on(c)}}function Yh(e){const n={decided:0,claimed:0,frontier:0,blocked:0,parked:0,"out-of-scope":0,verifying:0,rework:0,held:0,total:e.tickets.length,resolvedPct:0};for(const r of Fs(e.tickets,e.map.mode).values())n[r]++;return n.resolvedPct=n.total?Math.round((n.decided+n["out-of-scope"])/n.total*100):0,n}function Jh(e){const n=Yh(e);return{decided:n.decided,total:n.total-n["out-of-scope"]}}function jy(e){const n=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=n.get(d);let g=[];for(const v of h.blockedBy)if(n.has(v)){const k=l(v);k.length>g.length&&(g=k)}o.delete(d);const m=[...g,h];return r.set(d,m),m};let c=[];for(const d of n.keys()){const h=l(d);h.length>c.length&&(c=h)}return c}function Sy(e){return po.map(n=>{const r=e.tickets.filter(o=>o.type===n);return{type:n,open:r.filter(o=>o.state==="open").length,closed:r.filter(o=>o.state==="closed").length}}).filter(n=>n.open+n.closed>0)}function Ny(e,n){const r=e.pending.filter(l=>!0),o=e.answered.filter(l=>!0);return{open:r.length,oldestAt:r.length?Math.min(...r.map(l=>l.at)):void 0,answered:o.length,avgWaitMs:o.length?o.reduce((l,c)=>l+(c.answeredAt-c.askedAt),0)/o.length:void 0}}function Xh(e,n){return n&&e.usageByMap[n]||{inputTokens:0,outputTokens:0,costUsd:0}}const by=e=>e.usage?e.usage.inputTokens+e.usage.outputTokens:0,Zh={"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 em(e,n){var o;const r=new Set;for(const l of e.sessions)n&&l.mapId===n&&((o=l.usage)!=null&&o.source)&&r.add(l.usage.source);return[...r].sort()}function Cy(e,n){const r=new Set(n.map(l=>l.ticketId).filter(Boolean)),o=e.tickets.filter(l=>l.state==="closed"&&l.closeReason==="completed"&&!r.has(l.id)).map(l=>{var v;const c=[...l.comments].reverse().find(k=>k.body.startsWith("**Resolution**")),d=c?c.body.replace(/^\*\*Resolution\*\*\s*/,""):((v=e.map.sections.decisions.find(k=>k.ticketId===l.id||k.ticketKey===l.key))==null?void 0:v.text)??"",h=(c==null?void 0:c.author)??l.assignee??"unknown",g=l.comments.find(k=>k.body.startsWith("**HITL transcript**")),m=g?g.body.replace(/^\*\*HITL transcript\*\*\s*/,"").split(/\n\n(?=\*\*[^*]+:\*\* )/).map(k=>k.match(/^\*\*([^*]+):\*\* ([\s\S]*)$/)).filter(k=>!!k).map(k=>({from:k[1]===h?"agent":"human",author:k[1],text:k[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:Ao(d),alternatives:[],rationale:"",decidedBy:h,decidedAt:l.closedAt??(c==null?void 0:c.createdAt)??l.updatedAt,participants:[...new Set([h,...m.map(k=>k.author)])].map(k=>({id:k})),source:{kind:"tracker",ref:`${e.map.id}/tickets/${l.id}`,label:`${l.key} resolution comment`},transcript:m,derived:!0}});return[...n,...o].sort((l,c)=>c.decidedAt-l.decidedAt)}function $y(e,n){var o;const r=(o=n.query)==null?void 0:o.trim().toLowerCase();return e.filter(l=>(!n.mapId||l.mapId===n.mapId)&&(!n.source||l.source.kind===n.source)&&(!n.decidedBy||l.decidedBy===n.decidedBy)&&(!n.madeBy||_i(l)===n.madeBy)&&(!n.status||Ui(l)===n.status)&&(!r||[l.id,l.ticketKey,l.question,l.answer,l.summary,l.rationale,l.decidedBy,...l.alternatives,...l.transcript.map(c=>c.text)].join(`
74
+ `).toLowerCase().includes(r)))}function Ty(e,n=Date.now()){const r=Object.fromEntries(go.map(d=>[d,0]));let o=0,l=0,c=0;for(const d of e)r[d.source.kind]++,d.supersededBy&&o++,n-d.decidedAt<864e5&&l++,(_i(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 n=e.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);if(!n)return{front:{},body:e};const r={};for(const o of n[1].split(`
75
+ `)){const l=o.indexOf(":");if(l<0)continue;const c=o.slice(0,l).trim(),d=o.slice(l+1).trim();r[c]=d.startsWith("[")?My(d.slice(1,-1)).map(Of).filter(Boolean):Of(d)}return{front:r,body:n[2]}}const Ey=e=>e===""||/^[\s#&*!|>'"%@`[\]{},?:-]|[:#]\s|\s$|,/.test(e)||/^(true|false|null|~|\d[\d.e+-]*)$/i.test(e),Lf=e=>Ey(e)?JSON.stringify(e):e;function Of(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 My(e){const n=[];let r="",o=!1;for(const l of e)l==='"'&&(o=!o),l===","&&!o?(n.push(r.trim()),r=""):r+=l;return r.trim()&&n.push(r.trim()),n}function dc(e,n){return`---
76
+ ${Object.entries(e).map(([o,l])=>`${o}: ${Array.isArray(l)?`[${l.map(Lf).join(", ")}]`:Lf(l)}`).join(`
77
+ `)}
78
+ ---
79
+
80
+ ${n.trim()}
81
+ `}const xe=e=>Array.isArray(e)?e.join(","):e??"";function Ft(e){return Array.isArray(e)?e:e?[e]:[]}const Ls=e=>Date.parse(xe(e))||0,Qt=e=>new Date(e).toISOString(),tm=["schema","breaking-api","auth-permissions","billing","data-deletion","product-behaviour","dependencies"],nm=["low","medium","high"],Iy=e=>tm.includes(e),Ay=e=>nm.includes(e);function Ry(e){return e?{risk:e.level,...e.category?{risk_category:e.category}:{},risk_reason:e.reason}:{}}function Ly(e){const n=xe(e.risk);if(!Ay(n))return{};const r=xe(e.risk_category);return{risk:{level:n,...Iy(r)?{category:r}:{},reason:xe(e.risk_reason)}}}const Oy=["Question","Decision","Summary","Alternatives","Rationale","Transcript"],_y=e=>e.name?`${e.id}|${e.name}`:e.id,Py=e=>{const n=e.indexOf("|");return n<0?{id:e}:{id:e.slice(0,n),name:e.slice(n+1)}};function _f(e){var c;const n={id:e.id,trail:e.mapId,...e.ticketId?{ticket:e.ticketId,ticket_key:e.ticketKey??""}:{},decided_by:e.decidedBy,decided_at:Qt(e.decidedAt),participants:e.participants.map(_y),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}:{},...Ry(e.risk),...(c=e.assumes)!=null&&c.length?{assumes:e.assumes}:{}},r=d=>d.length?d.map(h=>`- ${h}`).join(`
82
+ `):"_None._",o=e.transcript.length?e.transcript.map(d=>`### ${d.author} · ${d.from} @ ${Qt(d.at)}
83
+
84
+ ${d.text.trim()}`).join(`
85
+
86
+ `):"_None._",l=[`## Question
87
+
88
+ ${e.question.trim()}`,`## Decision
89
+
90
+ ${e.answer.trim()}`,`## Summary
91
+
92
+ ${e.summary.trim()}`,`## Alternatives
93
+
94
+ ${r(e.alternatives)}`,`## Rationale
95
+
96
+ ${e.rationale.trim()||"_None._"}`,`## Transcript
97
+
98
+ ${o}`].join(`
99
+
100
+ `);return dc(n,l)}function Vl(e){const{front:n,body:r}=Ro(e),o={},l=new RegExp(`^## (${Oy.join("|")})\\s*$`,"gm"),c=[...r.matchAll(l)];c.forEach((k,w)=>{var T;const j=r.slice(k.index+k[0].length,((T=c[w+1])==null?void 0:T.index)??r.length).trim();o[k[1]]=/^_none\._$/i.test(j)?"":j});const d=(o.Transcript??"").split(/^### /m).slice(1).map(k=>{const w=k.indexOf(`
101
+ `),j=w<0?k:k.slice(0,w),[T,S=""]=j.split(" @ "),[E,I="agent"]=T.split(" · ");return{author:E.trim(),from:["agent","human","system"].includes(I.trim())?I.trim():"agent",at:Date.parse(S)||0,text:w<0?"":k.slice(w+1).trim()}}),h=xe(n.source),g=Ft(n.source_meta),m={kind:ny(h)?h:"tracker",...xe(n.source_ref)?{ref:xe(n.source_ref)}:{},...xe(n.source_url)?{url:xe(n.source_url)}:{},...xe(n.source_label)?{label:xe(n.source_label)}:{},...g.length?{meta:Object.fromEntries(g.map(k=>[k.slice(0,k.indexOf("=")),k.slice(k.indexOf("=")+1)]))}:{}},v=o.Decision??"";return{id:xe(n.id),mapId:xe(n.trail),ticketId:xe(n.ticket)||void 0,ticketKey:xe(n.ticket_key)||void 0,question:o.Question??"",answer:v,summary:o.Summary||Ao(v),alternatives:(o.Alternatives??"").split(`
102
+ `).map(k=>k.trim()).filter(k=>k.startsWith("- ")).map(k=>k.slice(2)),rationale:o.Rationale??"",decidedBy:xe(n.decided_by),decidedAt:Ls(n.decided_at),participants:Ft(n.participants).map(Py),source:m,supersedes:xe(n.supersedes)||void 0,supersededBy:xe(n.superseded_by)||void 0,...Ft(n.assumes).length?{assumes:Ft(n.assumes)}:{},transcript:d,...Ly(n)}}function Dy(e){return e.url?` · [${e.label??"link"}](${e.url})`:e.label?` · ${e.label}`:""}function By(e,n,r={}){const o=[`# ${r.title??"Decisions"}`,"",`Exported ${Qt(r.now??Date.now())} · ${e.length} decisions`],l=new Map;for(const c of e)l.set(c.mapId,[...l.get(c.mapId)??[],c]);for(const[c,d]of l){const h=n[c];o.push("",`## Trail ${h?`${h.key} ${h.title}`:c}`);for(const g of d){const m=On[g.source.kind].label;o.push("",`### ${g.id}${g.ticketKey?` · ${g.ticketKey}`:""} · ${g.question}`,"",`- **Status:** ${Ui(g)}${g.supersededBy?` (superseded by ${g.supersededBy})`:""}${g.supersedes?` · supersedes ${g.supersedes}`:""}`,`- **Decided by:** ${g.decidedBy} · ${Qt(g.decidedAt)}`,`- **Source:** ${m}${Dy(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 Kl(e,n,r){try{const o=e.get(n);return o?JSON.parse(o):r}catch{return r}}class Pf{constructor(n,r="presence"){ue(this,"seen");this.store=n,this.key=r,this.seen=Kl(n,r,{})}snapshot(){return{...this.seen}}lastSeen(n){return this.seen[n]}lastSeenAny(){const n=Object.values(this.seen);return n.length?Math.max(...n):void 0}markSeen(n,r=Date.now()){let o=!1;for(const l of n)(this.seen[l]??0)>=r||(this.seen[l]=r,o=!0);o&&this.store.set(this.key,JSON.stringify(this.seen))}}const Dl=5*6e4,zy=14*864e5;class Df{constructor(n,r="usage"){ue(this,"buckets");ue(this,"dirty",!1);ue(this,"timer");ue(this,"totals");this.store=n,this.key=r,this.buckets=Kl(n,r,{}),this.totals=Kl(n,`${r}.totals`,{})}addTotal(n,r,o,l=Date.now()){const c=this.totals[r],d={inputTokens:o.inputTokens-((c==null?void 0:c.inputTokens)??0),outputTokens:o.outputTokens-((c==null?void 0:c.outputTokens)??0),costUsd:o.costUsd-((c==null?void 0:c.costUsd)??0)};this.totals[r]={...o,at:l},d.inputTokens>0||d.outputTokens>0||d.costUsd>0?this.add(n,d,r,l):this.save()}add(n,r,o,l=Date.now()){var g;if(!n)return;const c=Math.floor(l/Dl)*Dl,d=(g=this.buckets)[n]??(g[n]=[]);let h=d.find(m=>m.at===c);h||(h={at:c,i:0,o:0,c:0,s:[]},d.push(h),d.sort((m,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(n,r){const o={inputTokens:0,outputTokens:0,costUsd:0,sessions:0},l=new Set;for(const c of this.buckets[n]??[])c.at+Dl<=r||(o.inputTokens+=c.i,o.outputTokens+=c.o,o.costUsd+=c.c,c.s.forEach(d=>l.add(d)));return o.sessions=l.size,o}save(){this.dirty=!0,!this.timer&&(this.timer=setTimeout(()=>{if(this.timer=void 0,!this.dirty)return;this.dirty=!1;const n=Date.now()-zy;for(const r of Object.keys(this.buckets))this.buckets[r]=this.buckets[r].filter(o=>o.at>=n);for(const[r,o]of Object.entries(this.totals))o.at<n&&delete this.totals[r];this.store.set(this.key,JSON.stringify(this.buckets)),this.store.set(`${this.key}.totals`,JSON.stringify(this.totals))},2e3))}}function Fy(e){const n=e.now??Date.now(),r=e.snaps.map(d=>{var oe;const h=d.map.id,g=e.since(h),m=G=>!!G&&G>=g,v=Fs(d.tickets,d.map.mode),k=new Map(d.tickets.map(G=>[G.id,G])),w=(e.attention??[]).filter(G=>G.mapId===h),j=Uy(e.activity.pending.filter(G=>G.mapId===h),w),T=new Set(j.map(G=>G.ticketId)),S=G=>G.state==="open"&&(T.has(G.id)||Fi(G)==="hitl"),E=d.tickets.filter(G=>v.get(G.id)==="blocked").map(G=>({ticket:G,on:G.blockedBy.map(ve=>k.get(ve)).filter(ve=>!!ve&&S(ve))})).filter(G=>G.on.length),I=e.decisions.filter(G=>G.mapId===h&&m(G.decidedAt)).sort((G,ve)=>ve.decidedAt-G.decidedAt),O=d.tickets.filter(G=>G.state==="closed"&&m(G.closedAt)).sort((G,ve)=>(G.closedAt??0)-(ve.closedAt??0)),R=O.filter(G=>G.closeReason==="completed"),X=O.filter(G=>G.closeReason==="not_planned"),te=d.tickets.filter(G=>m(G.createdAt)),B=((oe=e.ledger)==null?void 0:oe.since(h,g))??{inputTokens:0,outputTokens:0,costUsd:0,sessions:0},se=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:R,ruledOut:X,opened:te,blocked:E,waiting:j,needsYou:w,decisions:I,agentDecisions:I.filter(G=>_i(G)==="agent"),usage:B,active:se,changed:!!(O.length||te.length||I.length||j.some(G=>m(G.at))||B.costUsd>0)}}),o=r.filter(d=>d.changed||d.waiting.length).sort((d,h)=>+(h.mapId===e.currentMapId)-+(d.mapId===e.currentMapId)),l=d=>o.reduce((h,g)=>h+g[d].length,0),c=o.flatMap(d=>d.waiting).reduce((d,h)=>d===void 0||h.at<d?h.at:d,void 0);return{since:o.length?Math.min(...o.map(d=>d.since)):n,now:n,trails:o,totals:{done:l("done"),ruledOut:l("ruledOut"),blocked:l("blocked"),waiting:l("waiting"),oldestWaitMs:c===void 0?void 0:n-c,agentDecisions:l("agentDecisions"),usage:o.reduce((d,h)=>({inputTokens:d.inputTokens+h.usage.inputTokens,outputTokens:d.outputTokens+h.usage.outputTokens,costUsd:d.costUsd+h.usage.costUsd,sessions:d.sessions+h.usage.sessions}),{inputTokens:0,outputTokens:0,costUsd:0,sessions:0}),active:l("active")},changed:r.some(d=>d.changed)}}function Uy(e,n){const r=new Map(n.filter(l=>l.kind==="question").map((l,c)=>[l.ref,c])),o=l=>r.get(l.id)??Number.MAX_SAFE_INTEGER;return[...e].sort((l,c)=>o(l)-o(c)||l.at-c.at)}const Ri=(e,n,r=`${n}s`)=>`${e} ${e===1?n:r}`;function Wy(e){return e.trails.flatMap(n=>{const r=new Set(n.waiting.map(o=>o.ticketId));return n.blocked.filter(o=>o.on.some(l=>r.has(l.id)))})}function Hy(e){return e.length===1?`, and it holds up ${e[0].ticket.title.replace(/^./,n=>n.toLowerCase())}`:e.length>1?`, holding up ${Ri(e.length,"ticket")}`:""}function Vy(e,n=new Date(e.now).getHours()){const r=e.totals,l=e.now-e.since>=6*36e5&&n>=5&&n<12?"Good morning.":"Welcome back.",c=[];if(r.done&&c.push(`${Ri(r.done,"ticket")} ${r.done===1?"is":"are"} done.`),r.agentDecisions&&c.push(`Agents made ${Ri(r.agentDecisions,"decision")}.`),r.waiting){const d=Hy(Wy(e));c.push(`${Ri(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(`${Ri(r.ruledOut,"ticket")} ruled out of scope.`),[l,...c].join(" ")}const Ky=e=>{if(!e.length)return;const n=[...e].sort((o,l)=>o-l),r=Math.floor(n.length/2);return n.length%2?n[r]:Math.round((n[r-1]+n[r])/2)};function Gy(e){return e.state==="open"?"open":e.closeReason==="not_planned"?"cancelled":"done"}function sm({snap:e,journal:n,answered:r,usage:o}){const l=e.map.id,c=n.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)??[],I=Gy(S),O=(X=E.find(te=>te.event==="claim"))==null?void 0:X.at,R=I==="done"?S.closedAt:void 0;return{id:S.id,key:S.key,title:S.title,type:S.type,outcome:I,claimedAt:O,doneAt:R,leadMs:R&&O&&R>=O?R-O:void 0,reworks:E.filter(te=>te.to==="rework").length,reviews:{passed:E.filter(te=>te.event==="review.pass").length,failed:E.filter(te=>te.event==="review.fail").length,needsHuman:E.filter(te=>te.event==="review.needs_human").length},operatorActions:E.filter(te=>te.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"),k=new Set(r.filter(S=>S.mapId===l).map(S=>S.id)).size,w=v.length,j=S=>h.reduce((E,I)=>E+S(I),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:Ky(g.flatMap(S=>S.leadMs===void 0?[]:[S.leadMs])),interventions:{answers:k,operatorActions:w,reworkRequested:v.filter(S=>S.event==="reject").length,total:k+w},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 Bl=e=>e.split("-")[0];function Xt(e){if(e===void 0)return"—";const n=Math.round(e/6e4);if(n<90)return`${n} min`;const r=e/36e5;return r<48?`${Math.round(r*10)/10} h`:`${Math.round(r/24*10)/10} d`}const Bf=e=>e===void 0?"—":`$${e.toFixed(e<1?4:2)}`;function qy(e,n,r=Date.now()){const o=e.interventions;return[`# Trail report: ${n}`,"",`_Generated ${new Date(r).toISOString()} by Teamtrail._`,"","| Measure | Value |","| --- | --- |",`| Tickets done / cancelled / open | ${e.done} / ${e.cancelled} / ${e.open} |`,`| Trail lead time (created → last done) | ${Xt(e.trailLeadMs)} |`,`| Median ticket lead time (claim → done) | ${Xt(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 | ${Bf(e.spend.costUsd)} · ${e.spend.tokens.toLocaleString("en-US")} tokens |`,`| Cost per verified ticket | ${Bf(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} | ${Xt(c.leadMs)} | ${c.reworks} | ${c.reviews.passed}/${c.reviews.failed} | ${c.operatorActions} |`),""].join(`
107
+ `)}const fc=5,im=1.5,Qy=15,no=e=>Math.round(e*100);function Yy(e){const n=e.filter(d=>d.findings.raised>=fc).sort((d,h)=>h.findings.upheld/h.findings.raised-d.findings.upheld/d.findings.raised||d.key.localeCompare(h.key));if(n.length<2)return[];const[r,o]=[n[0],n[n.length-1]],[l,c]=[r.findings.upheld/r.findings.raised,o.findings.upheld/o.findings.raised];return no(l)-no(c)<Qy?[]:[{id:"review-findings",text:`${r.key} review findings upheld ${no(l)}% vs ${o.key} ${no(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 Jy(e){const n=c=>c.reworkCycles/c.tickets,r=e.filter(c=>c.tickets>=fc).sort((c,d)=>n(c)-n(d)||c.key.localeCompare(d.key));if(r.length<2)return[];const[o,l]=[r[0],r[r.length-1]];return n(l)-n(o)<.2||n(l)<n(o)*im?[]:[{id:"rework",text:`${l.key} work goes back to rework more: ${n(l).toFixed(1)} times per ticket vs ${o.key} ${n(o).toFixed(1)}`,because:`${l.reworkCycles} cycles on ${l.tickets} tickets, and ${o.reworkCycles} on ${o.tickets}`}]}function Xy(e,n){const r=d=>d.medianLeadMs??0,o=n.filter(d=>d.done>=fc&&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)*im?[]:[{id:`speed-${e}`,text:`${e} tickets: ${l.key} is faster, ${Xt(l.medianLeadMs)} vs ${c.key} ${Xt(c.medianLeadMs)}`,because:`Median first claim to done, over ${l.done} and ${c.done} done tickets`}]}function Zy(e){const n=Object.keys(e.byTypeAndVendor).sort();return[...Yy(e.byVendor),...Jy(e.byVendor),...n.flatMap(r=>Xy(r,e.byTypeAndVendor[r]))]}const ek=e=>{if(!e.length)return;const n=[...e].sort((o,l)=>o-l),r=Math.floor(n.length/2);return n.length%2?n[r]:Math.round((n[r-1]+n[r])/2)},rm=e=>{var n;return(n=e.filter(r=>r.event==="claim"&&r.actorKind==="agent").at(-1))==null?void 0:n.actor},Gl=(e,n,r)=>e.filter(o=>o.mapId===n&&o.ticketId===r).sort((o,l)=>o.at-l.at);function tk(e,n){return e.tickets.flatMap(r=>{var k;if(r.type!=="review"||!r.reviewOf)return[];const o=Gl(n,e.map.id,r.id),l=rm(o);if(!l)return[];const c=((k=o.filter(w=>w.event==="claim").at(-1))==null?void 0:k.at)??0,d=Gl(n,e.map.id,r.reviewOf),h=d.findIndex(w=>w.at>=c&&w.event.startsWith("review."));if(h<0||d[h].event!=="review.fail")return[];const g=d.slice(h+1),m=g.findIndex(w=>w.event.startsWith("review.")),v=m<0?g:g.slice(0,m);return[{reviewer:l,upheld:!v.some(w=>w.event==="accept"&&w.actorKind==="trail lead")}]})}function nk(e,n){var o;const r=(o=e.tickets.find(l=>l.id===n))==null?void 0:o.assignee;return r&&/^[a-z]+-\d+$/.test(r)?r:void 0}function om(e,n){const r=l=>n.reduce((c,{ticket:d})=>c+l(d),0),o=l=>n.filter(c=>c.ticket.outcome===l).length;return{key:e,tickets:n.length,done:o("done"),cancelled:o("cancelled"),open:o("open"),medianLeadMs:ek(n.flatMap(({ticket:l})=>l.leadMs===void 0?[]:[l.leadMs])),reworkCycles:r(l=>l.reworks),reviews:{passed:r(l=>l.reviews.passed),failed:r(l=>l.reviews.failed),needsHuman:r(l=>l.reviews.needsHuman)},answers:0,findings:{raised:0,upheld:0}}}function so(e,n){const r=new Map;for(const o of e){const l=n(o);l&&r.set(l,[...r.get(l)??[],o])}return new Map([...r].map(([o,l])=>[o,om(o,l)]))}const ql=(e,n)=>{const r=e.get(n)??om(n,[]);return e.set(n,r),r};function zf(e,n,r){const o=ql(e,n);o.findings.raised+=1,r&&(o.findings.upheld+=1)}const io=e=>[...e.values()].sort((n,r)=>r.tickets-n.tickets||n.key.localeCompare(r.key));function am(e){const n=e.flatMap(({snap:m,journal:v,answered:k,usage:w})=>sm({snap:m,journal:v,answered:k,usage:w}).tickets.map(j=>({ticket:j,agent:rm(Gl(v,m.map.id,j.id))??nk(m,j.id)}))),r=m=>m.agent?Bl(m.agent):void 0,o=so(n,m=>m.agent),l=so(n,r),c=so(n,m=>m.ticket.type),d=new Set;for(const{snap:m,journal:v,answered:k}of e){for(const w of k){const j=`${w.mapId}/${w.id}`;w.mapId!==m.map.id||d.has(j)||(d.add(j),ql(o,w.agent).answers+=1,ql(l,Bl(w.agent)).answers+=1)}for(const w of tk(m,v))zf(o,w.reviewer,w.upheld),zf(l,Bl(w.reviewer),w.upheld)}const h=Object.fromEntries([...c.keys()].map(m=>[m,io(so(n.filter(v=>v.ticket.type===m),r))])),g={trails:e.length,tickets:n.length,byAgent:io(o),byVendor:io(l),byType:io(c),byTypeAndVendor:h};return{...g,recommendations:Zy(g)}}const sk={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
+ `)},ik=[["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"]],Ii=Object.fromEntries(ik);function rk(e,n){const r=new Set(e.map(o=>o.source).filter(Boolean));return n.filter(o=>!r.has(o))}const ok=["architecture","convention","gotcha","dead-end","glossary","fact"],lm=["business-rule","product-decision","persona","ux-principle","pricing"],ak=[...ok,...lm],lk=e=>e.status==="confirmed"||e.status==="assumption";function ck(e,n){const r=e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*\//g,"§DIRS§").replace(/\*\*/g,"§DEEP§").replace(/\*/g,"[^/]*").replace(/§DIRS§/g,"(?:.*/)?").replace(/§DEEP§/g,".*");return new RegExp(`^${r}$`).test(n.replace(/^\.\//,""))}const uk={"business-rule":3,convention:3,"product-decision":2,architecture:2,gotcha:2,"dead-end":2,"ux-principle":2},dk=["business-rule","ux-principle","convention"],Ff=600,fk=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(" ")),Uf=e=>new Set((e.toLowerCase().match(/[a-z0-9][a-z0-9_-]{2,}/g)??[]).filter(n=>!fk.has(n)));function cm(e,n,r=4e3,o=()=>[]){const l=n.ticket?Uf(`${n.ticket.title} ${n.ticket.body}`):new Set,c=new Set((n.tags??[]).map(m=>m.toLowerCase())),d=e.filter(lk).map(m=>{const v=[];let k=uk[m.kind]??1;for(const T of m.scope){const S=n.paths.find(E=>ck(T,E));if(S){k+=6,v.push(`path match ${T} (${S})`);break}}const w=m.tags.filter(T=>c.has(T.toLowerCase())||l.has(T.toLowerCase()));w.length&&(k+=3*w.length,v.push(`tag ${w.join(", ")}`));const j=[...Uf(m.title)].filter(T=>l.has(T));return j.length&&(k+=j.length,v.push(`mentions ${j.slice(0,3).join(", ")}`)),n.trailKey&&m.sources.includes(`trail:${n.trailKey}`)&&(k+=3,v.push("same trail")),n.discovery&&lm.includes(m.kind)&&(k+=8,v.push("product context for discovery")),!v.length&&dk.includes(m.kind)&&!m.scope.length&&v.push(`${m.kind.replace("-"," ")} for the whole project`),{e:m,score:k,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 k=m.body.length>Ff?`${m.body.slice(0,Ff)}…`:m.body;if(g+k.length>r&&h.length)break;g+=k.length;const w=o(m);h.push({id:m.id,title:m.title,kind:m.kind,status:m.status,body:k,why:v,...w.length?{mayBeOutdated:w}:{},...m.flag?{flagged:m.flag.reason}:{}})}return h}const hk=new RegExp("`([^`\\s]+/[^`\\s]+)`|(?:^|[\\s(])/?((?:[\\w.-]+/)+[\\w.-]+)","gm");function um(e){const n=new Set;for(const r of e.matchAll(hk))n.add((r[1]??r[2]).replace(/^\.?\//,"").replace(/[.,;:]+$/,""));return[...n]}const mk=[{level:"high",label:"High risk"},{level:"medium",label:"Medium risk"},{level:"low",label:"Low risk"},{level:"none",label:"No category"}];function pk(e){return mk.map(n=>({...n,decisions:e.filter(r=>{var o;return(((o=r.risk)==null?void 0:o.level)??"none")===n.level})})).filter(n=>n.decisions.length)}const gk=1/3;function Lo(e,n=Date.now()){const r=e.expiresAt-n;return r<=0?"expired":r<=e.ttlMs*gk?"stalled":"live"}function vk(e){var n;return((n=e.returned)==null?void 0:n.reason)==="trail lead"?`${e.ticketKey} returned to queue · claim of ${e.agent} released by ${e.returned.by}`:`${e.ticketKey} returned to queue after ${e.agent} went silent`}const yk=e=>e.urgency==="fyi"||e.kind==="policy";function kk(e,n){var o;const r={...e};return n.verification===null?delete r.verification:n.verification&&(r.verification=n.verification),n.guides===null||((o=n.guides)==null?void 0:o.length)===0?delete r.guides:n.guides&&(r.guides=n.guides),n.modelMatching===null?delete r.modelMatching:n.modelMatching&&(r.modelMatching=n.modelMatching),r}function xk(e,n,r){const o=Date.now();return{id:e,key:n,...r,state:"open",blockedBy:[],comments:[],createdAt:o,updatedAt:o}}const wk=(e,n)=>({...e,blockedBy:e.blockedBy.filter(r=>r!==n)}),jk=(e,n)=>{var r;return{...e,...(r=n.title)!=null&&r.trim()?{title:n.title.trim()}:{},...n.body!==void 0?{body:n.body}:{}}};function Sk(e){const{closeReason:n,closedAt:r,...o}=e;return{...o,state:"open"}}const Nk=["status","verification","checks","reviewOf","guide"];function bk(e,n){const r={...e};for(const o of Nk)n[o]!==void 0&&(n[o]===null?delete r[o]:r[o]=n[o]);return r}const Ck=/^([^/]+)\/decisions\/([^/]+)\.md$/,$k=(e,n)=>e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,40)||`map-${n}`;class Tk{constructor(n,r){ue(this,"seen",new Map);ue(this,"pending",new Map);this.read=n,this.emit=r}knows(n){return this.seen.has(n)}remember(n,r,o){this.seen.set(n,{text:r,supersededBy:o})}queue(n){const r=n.split("/")[0],o=this.pending.get(r)??{paths:new Set,timer:setTimeout(()=>void this.flush(r),250)};o.paths.add(n),this.pending.set(r,o)}async flush(n){const r=this.pending.get(n);if(this.pending.delete(n),!r)return;const o=[...r.paths].filter(d=>Ck.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=Vl(h);this.seen.set(d,{text:h,supersededBy:m.supersededBy}),g?m.supersededBy&&m.supersededBy!==g.supersededBy&&l.push({kind:"decision.superseded",mapId:n,decisionId:m.id,supersededBy:m.supersededBy,external:!0,at:Date.now()}):l.push({kind:"decision.recorded",mapId:n,decisionId:m.id,ticketId:m.ticketId,external:!0,at:Date.now()})}o.length?!l.length&&o.length<r.paths.size&&l.push({kind:"external.changed",mapId:n,at:Date.now()}):l.push({kind:"external.changed",mapId:n,at:Date.now()});const c=d=>d.kind==="decision.recorded"?0:1;l.sort((d,h)=>c(d)-c(h));for(const d of l)this.emit(d)}}function Ek(e){const n=e.filter(([r,o])=>Eo.includes(r)&&Hh(o));return Object.fromEntries(n)}function Mk(e){const n=xe(e["model-matching"]);if(n!=="on"&&n!=="off")return;const r=Ek(Ft(e["model-tiers"]).map(o=>o.split("=").map(l=>l.trim())));return Object.keys(r).length?{enabled:n==="on",tiers:r}:{enabled:n==="on"}}function Ik(e){if(!e)return{};const n=Object.entries(e.tiers??{}).map(([r,o])=>`${r}=${o}`);return{"model-matching":e.enabled?"on":"off",...n.length?{"model-tiers":n}:{}}}function Ak(e,n){const{front:r,body:o}=Ro(n),l=Fh(xe(r.verification)),c=Mk(r);return{id:e,key:xe(r.key)||e,title:xe(r.title)||e,mode:xe(r.mode)==="plan-only"||Ft(r.labels).includes(ac)?"plan-only":ts,...l?{verification:l}:{},...Ft(r.guides).length?{guides:Ft(r.guides)}:{},...c?{modelMatching:c}:{},sections:Bv(o),createdAt:Ls(r.created),updatedAt:Ls(r.updated)}}function Rk(e){var n;return dc({key:e.key,title:e.title,mode:e.mode,...e.verification?{verification:e.verification}:{},...(n=e.guides)!=null&&n.length?{guides:e.guides}:{},...Ik(e.modelMatching),labels:[rc,...e.mode==="plan-only"?[ac]:[]],created:Qt(e.createdAt),updated:Qt(e.updatedAt)},Dv(e.sections))}async function Wf(e){const n=await e.list(),r=n.filter(l=>!l.includes("/decisions/")).map(l=>{var c;return Number(((c=l.match(/(\d+)\.md$/))==null?void 0:c[1])??0)}),o=await Promise.all(n.filter(l=>l.endsWith("/map.md")).map(async l=>Number(xe(Ro(await e.read(l)).front.key).replace(/\D/g,""))||0));return Math.max(0,...r,...o)+1}function Hf(e){const{front:n,body:r}=Ro(e),[o,l=""]=r.split(/^## Comments\s*$/m),c=l.split(/^### /m).slice(1).map((m,v)=>{const k=m.indexOf(`
109
+ `),[w,j]=m.slice(0,k).split(" @ ");return{id:`c${v}`,author:w.trim(),createdAt:Date.parse(j)||0,body:m.slice(k+1).trim()}}),d=xe(n.close_reason),h=wv.find(m=>m===xe(n.status)),g=Fh(xe(n.verification));return{id:xe(n.id),key:`#${xe(n.id)}`,title:xe(n.title),type:xe(n.type)||"task",hitl:Ft(n.labels).includes(oc)||void 0,state:xe(n.state)==="closed"?"closed":"open",closeReason:d==="completed"||d==="not_planned"?d:void 0,assignee:xe(n.assignee)||void 0,...h?{status:h}:{},...g?{verification:g}:{},...n.checks!==void 0?{checks:Ft(n.checks)}:{},...xe(n.review_of)?{reviewOf:xe(n.review_of)}:{},...xe(n.guide)?{guide:xe(n.guide)}:{},blockedBy:Ft(n.blocked_by),body:o.trim(),comments:c,createdAt:Ls(n.created),updatedAt:Ls(n.updated),closedAt:Ls(n.closed)||void 0}}function Lk(e){const n={id:e.id,title:e.title,type:e.type,labels:[To(e.type),...xv(e.type)&&e.hitl?[oc]:[]],state:e.state,close_reason:e.closeReason??"",assignee:e.assignee??"",...e.status?{status:e.status}:{},...e.verification?{verification:e.verification}:{},...e.checks?{checks:e.checks}:{},...e.reviewOf?{review_of:e.reviewOf}:{},...e.guide?{guide:e.guide}:{},blocked_by:e.blockedBy,created:Qt(e.createdAt),updated:Qt(e.updatedAt),...e.closedAt?{closed:Qt(e.closedAt)}:{}},r=e.comments.length?`
110
+
111
+ ## Comments
112
+
113
+ ${e.comments.map(o=>`### ${o.author} @ ${Qt(o.createdAt)}
114
+
115
+ ${o.body}`).join(`
116
+
117
+ `)}`:"";return dc(n,e.body+r)}class Ok{constructor(n,r=`./${ge.dataDir}`){ue(this,"kind","markdown");ue(this,"label","Local markdown");ue(this,"events",new Os);ue(this,"selfWrites",new Map);ue(this,"external",new Tk(n=>this.fs.read(n),n=>this.events.emit(n)));var o;this.fs=n,this.location=r,(o=n.watch)==null||o.call(n,l=>{const c=this.selfWrites.get(l);c&&Date.now()-c<1500||this.external.queue(l)})}async put(n,r){this.selfWrites.set(n,Date.now()),await this.fs.write(n,r)}async readMap(n){return Ak(n,await this.fs.read(`${n}/map.md`))}async writeMap(n){await this.put(`${n.id}/map.md`,Rk(n))}async readTicket(n,r){return Hf(await this.fs.read(`${n}/tickets/${r}.md`))}async writeTicket(n,r){await this.put(`${n}/tickets/${r.id}.md`,Lk({...r,updatedAt:Date.now()}))}async listMaps(){const r=(await this.fs.list()).filter(o=>/^[^/]+\/map\.md$/.test(o)).map(o=>o.split("/")[0]);return Promise.all(r.map(async o=>{const l=await this.readMap(o);return{id:o,key:l.key,title:l.title}}))}async loadMap(n){const r=await this.fs.list(),o=await this.readMap(n),l=r.filter(d=>d.startsWith(`${n}/tickets/`)),c=await Promise.all(l.map(async d=>Hf(await this.fs.read(d))));return{map:o,tickets:c.sort((d,h)=>d.createdAt-h.createdAt)}}async createMap(n){const r=await Wf(this.fs),o=$k(n.title,r),l={id:o,key:`#${r}`,title:n.title,mode:n.mode??ts,...n.verification?{verification:n.verification}:{},sections:n.sections,createdAt:Date.now(),updatedAt:Date.now()};return await this.writeMap(l),this.events.emit({kind:"map.created",mapId:o,at:Date.now()}),l}async editMap(n,r,o){await this.writeMap({...r(await this.readMap(n)),updatedAt:Date.now()}),this.events.emit(o)}setMapMode(n,r){return this.editMap(n,o=>({...o,mode:r}),{kind:"map.mode",mapId:n,mode:r,at:Date.now()})}setMapMeta(n,r){return this.editMap(n,o=>kk(o,r),{kind:"map.updated",mapId:n,at:Date.now()})}updateMapSections(n,r){const o=Object.keys(r)[0];return this.editMap(n,l=>({...l,sections:{...l.sections,...r}}),{kind:"map.updated",mapId:n,section:o,at:Date.now()})}async createTicket(n,r){const o=await Wf(this.fs),l=xk(String(o),`#${o}`,r);return await this.writeTicket(n,l),this.events.emit({kind:"ticket.created",mapId:n,ticketId:l.id,at:Date.now()}),l}async addBlocking(n,r,o){const l=await this.readTicket(n,o);l.blockedBy.includes(r)||await this.writeTicket(n,{...l,blockedBy:[...l.blockedBy,r]}),this.events.emit({kind:"edge.added",mapId:n,blockerId:r,blockedId:o,at:Date.now()})}async update(n,r,o){await this.writeTicket(n,o(await this.readTicket(n,r)))}async removeBlocking(n,r,o){await this.update(n,o,l=>wk(l,r)),this.events.emit({kind:"edge.removed",mapId:n,blockerId:r,blockedId:o,at:Date.now()})}async editTicket(n,r,o){await this.update(n,r,l=>jk(l,o)),this.events.emit({kind:"ticket.updated",mapId:n,ticketId:r,at:Date.now()})}async reopen(n,r){await this.update(n,r,Sk),this.events.emit({kind:"ticket.updated",mapId:n,ticketId:r,at:Date.now()})}async assign(n,r,o){await this.update(n,r,l=>({...l,assignee:o??void 0})),this.events.emit(o?{kind:"ticket.claimed",mapId:n,ticketId:r,assignee:o,at:Date.now()}:{kind:"ticket.released",mapId:n,ticketId:r,at:Date.now()})}async comment(n,r,o,l){await this.update(n,r,c=>({...c,comments:[...c.comments,{id:`c${c.comments.length}`,author:o,body:l,createdAt:Date.now()}]})),this.events.emit({kind:"ticket.commented",mapId:n,ticketId:r,at:Date.now()})}async close(n,r,o){await this.update(n,r,l=>({...l,state:"closed",closeReason:o,closedAt:Date.now()})),this.events.emit({kind:"ticket.closed",mapId:n,ticketId:r,reason:o,at:Date.now()})}async setMeta(n,r,o){await this.update(n,r,l=>bk(l,o)),this.events.emit({kind:"ticket.updated",mapId:n,ticketId:r,at:Date.now()})}async listDecisions(n){const r=(await this.fs.list()).filter(o=>o.startsWith(`${n}/decisions/`));return Promise.all(r.map(async o=>{const l=await this.fs.read(o),c={...Vl(l),mapId:n};return this.external.knows(o)||this.external.remember(o,l,c.supersededBy),c}))}async createDecision(n,r){const o=(await this.fs.list()).filter(h=>h.includes("/decisions/")),l=Math.max(0,...o.map(h=>iy(h.split("/").pop())))+1,c=sy(`D-${l}`,n,r),d=_f(c);return this.external.remember(`${n}/decisions/${c.id}.md`,d),await this.put(`${n}/decisions/${c.id}.md`,d),this.events.emit({kind:"decision.recorded",mapId:n,decisionId:c.id,ticketId:c.ticketId,at:Date.now()}),c}async markSuperseded(n,r,o){const l=`${n}/decisions/${r}.md`,c=Vl(await this.fs.read(l)),d=_f({...c,mapId:n,supersededBy:o});this.external.remember(l,d,o),await this.put(l,d),this.events.emit({kind:"decision.superseded",mapId:n,decisionId:r,supersededBy:o,at:Date.now()})}subscribe(n){return this.events.on(n)}}class Vf extends Error{constructor(n,r,o,l){super(r),this.code=n,this.status=o,this.resetAt=l,this.name="TrackerError"}}const _k={github:"GitHub Issues",linear:"Linear"};async function As(e,n,r){let o;try{o=await fetch(e,{method:n,headers:{"Content-Type":"application/json"},body:r===void 0?void 0:JSON.stringify(r)})}catch{throw new Vf("offline","Lookout server unreachable; is `teamtrail` still running?")}const l=await o.json().catch(()=>({}));if(!o.ok)throw new Vf(l.code??"http",l.error??`request failed (${o.status})`,o.status,l.resetAt);return l}class Pk{constructor(n,r,o=""){ue(this,"label");ue(this,"location");ue(this,"status",{state:"connecting",queued:0});ue(this,"events",new Os);ue(this,"statusEvents",new Os);ue(this,"source");ue(this,"listeners",0);ue(this,"listMaps",()=>this.call("listMaps"));ue(this,"loadMap",n=>this.call("loadMap",n));ue(this,"createMap",n=>this.call("createMap",n));ue(this,"setMapMode",(n,r)=>this.call("setMapMode",n,r));ue(this,"setMapMeta",(n,r)=>this.call("setMapMeta",n,r));ue(this,"updateMapSections",(n,r)=>this.call("updateMapSections",n,r));ue(this,"createTicket",(n,r)=>this.call("createTicket",n,r));ue(this,"addBlocking",(n,r,o)=>this.call("addBlocking",n,r,o));ue(this,"removeBlocking",(n,r,o)=>this.call("removeBlocking",n,r,o));ue(this,"editTicket",(n,r,o)=>this.call("editTicket",n,r,o));ue(this,"reopen",(n,r)=>this.call("reopen",n,r));ue(this,"assign",(n,r,o)=>this.call("assign",n,r,o));ue(this,"comment",(n,r,o,l)=>this.call("comment",n,r,o,l));ue(this,"close",(n,r,o)=>this.call("close",n,r,o));ue(this,"setMeta",(n,r,o)=>this.call("setMeta",n,r,o));ue(this,"listDecisions",n=>this.call("listDecisions",n));ue(this,"createDecision",(n,r)=>this.call("createDecision",n,r));ue(this,"markSuperseded",(n,r,o)=>this.call("markSuperseded",n,r,o));this.kind=n,this.base=r,this.label=_k[n],this.location=o}async call(n,...r){return(await As(`${this.base}/tracker/${this.kind}/call`,"POST",{method:n,args:r})).result}open(){const n=new EventSource(`${this.base}/tracker/${this.kind}/events`);n.onmessage=r=>this.events.emit(JSON.parse(r.data)),n.addEventListener("status",r=>{const o=JSON.parse(r.data);o.location&&(this.location=o.location),this.status=o,this.statusEvents.emit(o)}),n.onerror=()=>{this.status.state!=="offline"&&(this.status={...this.status,state:"offline",error:"Lookout server unreachable"},this.statusEvents.emit(this.status))},this.source=n}subscribe(n){const r=this.events.on(n);return++this.listeners===1&&this.open(),()=>{var o;r(),--this.listeners===0&&((o=this.source)==null||o.close(),this.source=void 0)}}onStatus(n){return this.statusEvents.on(n)}}function Dk(e){return{get:()=>As(`${e}/trackers`,"GET"),test:n=>As(`${e}/trackers/test`,"POST",n),connect:n=>As(`${e}/trackers`,"PUT",n),forget:n=>As(`${e}/trackers/credentials/${n}`,"DELETE"),githubRepos:()=>As(`${e}/trackers/github/repos`,"GET")}}const Bk=[{id:"markdown",name:"Local markdown",status:"available"},{id:"github",name:"GitHub Issues",status:"available"},{id:"linear",name:"Linear",status:"available"}],dm=[{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"}],zk=dm[0];function Fk(e,n={}){const r=(n.query??"").toLowerCase().split(/\s+/).filter(Boolean);return e.guides.filter(o=>{if(n.verifiedOnly&&!o.verified&&!o.builtin)return!1;const l=[o.id,o.name??"",o.summary,o.author].join(" ").toLowerCase();return r.every(c=>l.includes(c))})}const Uk={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"},fm={on:"#e2711d",dim:"#a8501c",alert:"#ff5a48"},Wk={on:"#ffd166",dim:"#a8501c",alert:"#ff5a48"},Pe=([e,n,r,o],l,c=.35)=>`<rect x="${e}" y="${n}" width="${r}" height="${o}" rx="${c}" fill="${l}"/>`;function Kf(e,n,r){if(n==="closed")return Pe([e,17,3,1],r.glow);if(n==="wide")return Pe([e,15,3,3],r.glowLight)+Pe([e+1,16,1,1],r.glass,.2);const o=n==="aside"?e+1:e;return Pe([o,16,3,1.1],r.glow)+Pe([o,17,3,1],r.glowLight)}function Hk(e,n){return e==="open"?Pe([13,20,6,1.1],n.glowLight)+Pe([15,21,2,1],n.glow):e==="mid"?Pe([14,20,4,1],n.glowLight):Pe(e==="aside"?[17,20,2,1]:[15,20,2,1],n.glow)}const Vk=[13,15,17,19,21,23];function Kk(e){return[Vk.map(n=>Pe([9.2,n,13.6,1],e.scan,0)).join(""),Pe([10,13,2,1],e.frame,.2),Pe([10,14,1,1],e.frame,.2),Pe([10,25.2,1,1],e.button,.2),Pe([11.2,25.2,1,1],e.cupDark,.2),[17,19,21].map(n=>Pe([n,25.2,1,1.6],e.shellLight,.2)+Pe([n,25.2,1,.8],e.frame,.2)).join("")].join("")}function Gf(e,n,r){return[`<rect x="${e}" y="15" width="5.4" height="11" rx="1.7" fill="${n.cup}" ${r}/>`,Pe([e+1,16,1.2,9],n.cupLight,.5),Pe([e+3.6,16,.9,9],n.cupDark,.4)].join("")}function Gk(e,{lamp:n=fm,simple:r=!1,colors:o=Uk}={}){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"/>`,Gf(.6,l,h),Gf(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}"/>`,Pe([6.6,10,1.6,15],l.shellLight,.6),Pe([8.4,11,15.2,13.6],l.frame,1.3),Pe([9,11.6,14,12.4],l.glass,1),r?"":Kk(l),Kf(11,c,l),Kf(18,c,l),Hk(d,l),`<path d="M6.5 10.5Q5.8 3.5 16 3.100Q26.2 3.5 25.5 10.5Z" fill="${l.hat}" ${h}/>`,`<path d="M10.5 9.5Q10.3 4.9 16 4.5Q21.7 4.9 21.5 9.5Z" fill="${l.panel}" stroke="${l.ink}" stroke-width=".5"/>`,r?"":`<path d="M16 5.400l1.2 1.7h-.6l1 1.5h-3.2l1-1.5h-.6z" fill="${l.hat}"/>`,`<path d="M6.3 9.8Q16 7.9 25.7 9.8Q27.2 12 25 12.600Q16 10.9 7 12.600Q4.8 12 6.3 9.8Z" fill="${l.visor}" ${h}/>`,`<circle cx="16" cy="2.600" r="1.3" fill="${n[e.light??"on"]}" stroke="${l.ink}" stroke-width=".7"/>`,"</g>"].join("")}const hm={crt:{id:"crt",name:"Day",blurb:"The original CRT head with ear cups and a baseball cap.",lamp:fm,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:Wk,wave:{bar:"#66828d",lead:"#e8833a"}}},qk="crt",Qk={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"}},Yk={idle:"WATCHING",speaking:"TALKING",alert:"NEEDS YOU",thinking:"THINKING"},dn={msPerChar:55,mouthHoldMs:110,blinkEveryMs:5600,blinkMs:140,thinkingStepMs:520};function Jk(e){return e?/[aeiouy]/i.test(e)?"open":/[a-z0-9]/i.test(e)?"mid":"rest":"rest"}function Xk(e,n){return!e||!/[a-z0-9]/i.test(e)?0:/[aeiou]/i.test(e)?2+(e.charCodeAt(0)+n)%2:1+(e.charCodeAt(0)*7+n)%2}function Zk(e,n,r){return Array.from({length:r},(o,l)=>{const c=n-(r-1-l);return c>=0&&c<e.length?Xk(e[c],c):0})}function mm({face:e={eyes:"open",mouth:"rest"},variant:n="crt",size:r,simple:o,className:l}){const{eyes:c,mouth:d,light:h}=e,g=x.useMemo(()=>Gk({eyes:c,mouth:d,light:h},{lamp:hm[n].lamp,simple:o??r<28}),[c,d,h,n,o,r]);return i.jsx("svg",{className:l,width:r,height:r,viewBox:"0 0 200 200","aria-hidden":"true",dangerouslySetInnerHTML:{__html:g}})}function ex(e){const[n,r]=x.useState(!1);return x.useEffect(()=>{if(!e){r(!1);return}let o;const l=setInterval(()=>{r(!0),o=setTimeout(()=>r(!1),dn.blinkMs)},dn.blinkEveryMs);return()=>{clearInterval(l),o&&clearTimeout(o)}},[e]),n}const tx={xs:.8,sm:2,md:4,lg:6},nx=40,qf=20,Qf="(prefers-reduced-motion: reduce)",sx=40,ix=350;function rx(e,n){var h;const r=e.size??"md",o=e.state??"idle",l=((h=e.speaking)==null?void 0:h.trim())??"",c=l&&(o==="idle"||o==="speaking")?"speaking":o,d=r==="xs";return{size:r,text:l,effective:c,talking:c==="speaking"&&l.length>0,mini:d,framed:e.framed??!d,reduced:n||d}}const ox=e=>e.length*dn.msPerChar,ax=(e,n)=>n&&(e.effective==="idle"||e.effective==="speaking"||e.effective==="alert");function lx(e,n,r,o){const l=Qk[e.effective],c=r?"closed":l.eyes;let d=l.mouth,h=e.text.length-1;if(o)if(e.reduced)d="open";else{h=Math.min(e.text.length-1,Math.floor(n/dn.msPerChar));const m=Math.floor(n/dn.mouthHoldMs)*Math.round(dn.mouthHoldMs/dn.msPerChar);d=Jk(e.text[Math.min(e.text.length-1,m)])}let g=l.light;return e.effective==="thinking"&&!e.reduced&&Math.floor(n/dn.thinkingStepMs)%2===1&&(g="on"),{eyes:c,mouth:d,light:g,cursor:h}}function cx(e,n){const r=typeof e.size=="number"?e.size:tx[e.size],o=e.reduced?Math.min(e.text.length-1,qf-1):n;return{base:r,px:nx*r,bars:qf,waveCursor:o}}function ux(e,{label:n,speechDone:r,cursor:o,caption:l}){const c=e.talking&&r?"idle":e.effective,d=Yk[c],h=e.size==="md"||e.size==="lg"||typeof e.size=="number"&&e.size>=4;return{shownState:c,status:d,ariaLabel:`${n}, ${d.toLowerCase()}`,showCaption:l??h,shown:dx(e,r,o)}}function dx(e,n,r){return e.talking?e.reduced||n?e.text:e.text.slice(0,r+1):""}function fx(){const[e,n]=x.useState(()=>{var r;return typeof window<"u"&&!!((r=window.matchMedia)!=null&&r.call(window,Qf).matches)});return x.useEffect(()=>{var l;const r=(l=window.matchMedia)==null?void 0:l.call(window,Qf);if(!r)return;const o=()=>n(r.matches);return o(),r.addEventListener("change",o),()=>r.removeEventListener("change",o)},[]),e}function hx(e,n,r){const[o,l]=x.useState(0);return x.useEffect(()=>{if(l(0),!n)return;const c=performance.now(),d=setInterval(()=>l(performance.now()-c),r);return()=>clearInterval(d)},[e,n,r]),o}function mx(e){const{key:n,talking:r,at:o}=e,l=o!==void 0,c=ox(e.text),[d,h]=x.useState(""),g=x.useRef(e.onSpeakEnd);g.current=e.onSpeakEnd,x.useEffect(()=>{if(!r||l)return;const j=setTimeout(()=>{var T;h(n),(T=g.current)==null||T.call(g)},c+ix);return()=>clearTimeout(j)},[r,n,c,l]);const m=r&&d!==n,v=hx(n,e.animate&&(m||e.thinking),m?sx:dn.thinkingStepMs),k=o??v,w=r&&(l?k>=c:d===n);return{t:k,speechDone:w}}const px=e=>e*2,Ql=3.5;function gx(e,n,r){return(e??[]).map((o,l)=>{const c=(1+2*o)*.5;return{x:l*2,y:(Ql-c)/2,width:1,height:c,fill:l>=n-2&&o>0?r.lead:r.bar}})}function vx({heights:e,bars:n,unit:r,colors:o}){const l=px(n);return i.jsx("svg",{className:`scout-wave${e?" on":""}`,width:l*r,height:Ql*r,viewBox:`0 0 ${l} ${Ql}`,"aria-hidden":"true",children:gx(e,n,o).map((c,d)=>i.jsx("rect",{...c},d))})}function Oo({state:e="idle",size:n="md",speaking:r,variant:o=qk,framed:l,caption:c,label:d="Scout",onSpeakEnd:h,at:g,className:m,style:v}){const k=rx({state:e,size:n,speaking:r,framed:l},fx()),{text:w,effective:j,talking:T,reduced:S}=k,E=hm[o],O=!S&&!(g!==void 0),R=`${j}|${o}|${w}`,{t:X,speechDone:te}=mx({key:R,text:w,talking:T,thinking:j==="thinking",animate:O,at:g,onSpeakEnd:h}),B=ex(ax(k,O)),se=T&&!te,{eyes:oe,mouth:G,light:ve,cursor:Be}=lx(k,X,B,se),{base:$e,px:ie,bars:D,waveCursor:q}=cx(k,Be),ae=x.useMemo(()=>se?Zk(w,q,D):null,[se,w,q,D]),{shownState:Y,status:U,ariaLabel:P,showCaption:W,shown:$}=ux(k,{label:d,speechDone:te,cursor:Be,caption:c}),_={...v,"--scout-u":`${$e}px`},he=i.jsx("span",{className:"scout-sprite",children:i.jsx(mm,{face:{eyes:oe,mouth:G,light:ve},variant:o,size:ie,simple:k.mini})});return k.framed?i.jsxs("figure",{className:`scout scout-panel scout-${Y} scout-v-${o} ${m??""}`,style:_,"data-state":Y,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":P,children:[he,i.jsx(vx,{heights:ae,bars:D,unit:$e,colors:E.wave})]}),W&&i.jsxs("p",{className:"scout-caption","aria-hidden":"true",children:[$,T&&!te&&!S&&i.jsx("span",{className:"scout-caret",children:"_"})]}),w&&i.jsx("span",{className:"scout-sr","aria-live":"polite",children:w})]}):i.jsx("span",{className:`scout scout-bare scout-${Y} ${m??""}`,style:_,role:"img","aria-label":P,children:he})}function yx(){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 kx(){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 xx({size:e=40,bare:n,className:r}){const o=x.useMemo(()=>n?kx():yx(),[n]);return i.jsx("svg",{className:r,width:e,height:e,viewBox:"0 0 200 200",role:"img","aria-label":"Teamtrail",dangerouslySetInnerHTML:{__html:o}})}const xt="trail lead";function wx({rt:e,guard:n,setMapId:r,mapIdRef:o,snapRef:l,setChatSession:c,setSelection:d}){const h={actorKind:"trail lead",journal:e.journal};return{selectMap:g=>r(g),openChat:g=>c(g),answer:(g,m)=>e.activity.answer(g,m,xt),claim:g=>n("Claim",()=>Rf(e.adapter,o.current,g,{...h,assignee:xt})),release:g=>n("Release claim",()=>Xv(e.adapter,o.current,g,{...h,actor:xt})),releaseLease:g=>n("Release to queue",()=>e.leases.release(o.current,g,xt)),resolve:(g,m,v={})=>n("Resolve · record answer",async()=>{var w;const k=(w=l.current)==null?void 0:w.tickets.find(j=>j.id===g);k&&!k.assignee&&await Rf(e.adapter,o.current,g,{...h,assignee:xt}),await oy(e.adapter,o.current,g,{...h,answer:m,author:xt,decision:{...v,source:{kind:"lookout",label:"Ticket inspector"}}})}),supersede:(g,m)=>n(`Supersede ${g.id}`,async()=>{let v=g.id;if(g.derived){const{id:k,mapId:w,derived:j,supersededBy:T,...S}=g;v=(await uc(e.adapter,g.mapId,S,{appendToTrail:!1})).id}await Zv(e.adapter,g.mapId,v,{...m,decidedBy:xt,participants:[{id:xt}],source:{kind:"lookout",label:"Logbook"}})}),graduate:({unspecified:g,...m})=>n(`Promote to ticket · ${g}`,async()=>{const v=await ay(e.adapter,o.current,g,m);d({kind:"ticket",id:v.id})}),ruleOut:(g,m)=>n("Rule out of scope",async()=>{await ly(e.adapter,o.current,g,{...h,reason:m,author:xt,source:{kind:"lookout",label:"Ticket inspector"}}),d(null)}),setMode:g=>n(`Trail mode · ${g}`,()=>ey(e.adapter,o.current,g)),setModelMatching:g=>n(`Model matching · ${g.enabled?"on":"off"}`,()=>cy(e.adapter,o.current,g))}}const tt=(...e)=>e.filter(Boolean).join(" "),_s="item",jx=/^[0-9a-f]{6,64}$/;function _o(){const e=new URLSearchParams(location.search).get("project")??void 0;return e&&jx.test(e)?e:void 0}function Ne(e=_o()){return e?`${ge.apiPrefix}/p/${e}`:ge.apiPrefix}function Sx(e){const n=new URLSearchParams(location.search);for(const o of["projects","project","tracker",_s])n.delete(o);e.item&&n.set(_s,e.item),e.id&&e.id!==e.home&&n.set("project",e.id),e.id&&e.id!==e.home&&e.tracker&&n.set("tracker",e.tracker);const r=n.toString();return`${location.pathname}${r?`?${r}`:""}`}async function Nx(e,n){var c;const r=(n.assumptions??[]).map((d,h)=>({id:`S-${h+1}`,text:d,status:"holding",tickets:[]})),{map:o,tickets:l}=await Fv(e,{title:n.title,sections:{destination:n.destination,notes:n.notes,decisions:[],unspecified:[],outOfScope:[],...r.length?{assumptions:r}:{}},tickets:[{ref:"discovery",...sk}]});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 pm(e,n){const r=URL.createObjectURL(new Blob([n],{type:"text/markdown;charset=utf-8"}));Object.assign(document.createElement("a"),{href:r,download:e}).click(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}function en(e){const n=Math.max(0,Math.floor(e/1e3));return n<60?`${n}s`:n<3600?`${Math.floor(n/60)}m`:`${Math.floor(n/3600)}h`}function gm(e){const n=Math.max(0,Math.floor(e/1e3)),r=o=>String(o).padStart(2,"0");return`${r(Math.floor(n/3600))}:${r(Math.floor(n%3600/60))}:${r(n%60)}`}const hc=e=>new Date(e).toTimeString().slice(0,8);function Ut(e){if(e<1e3)return`${Math.round(e)}ms`;const n=Math.round(e/1e3);return n<60?`${n}s`:n<3600?`${Math.floor(n/60)}m ${String(n%60).padStart(2,"0")}s`:`${Math.floor(n/3600)}h ${String(Math.floor(n%3600/60)).padStart(2,"0")}m`}function Po(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}const Ps=e=>`$${e<10?e.toFixed(2):e.toFixed(1)}`,Ds=e=>new Date(e).toISOString().slice(0,10),mc=e=>new Date(e).toTimeString().slice(0,5),bx=e=>`${Ds(e)} ${mc(e)}`,vm=e=>{if(!e)return"";const n=Math.max(0,Math.round((Date.now()-e)/1e3));return n<60?`${n}s ago`:`${Math.round(n/60)}m ago`},Wi=e=>e?new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",Pi={research:"Research",prototype:"Prototype",junction:"Junction",task:"Task",execute:"Execute",review:"Review"},ym={decided:"Done",claimed:"Working",frontier:"Ready",blocked:"Backlog",parked:"Parked (plan-only)","out-of-scope":"Cancelled",verifying:"Verifying",rework:"Rework",held:"Blocked"},Cx={decided:"done",claimed:"working",frontier:"ready",blocked:"backlog",parked:"parked","out-of-scope":"cancelled",verifying:"verifying",rework:"rework",held:"blocked"};function pc(e,n){return new Map((e??[]).filter(r=>r.mapId===n&&!r.returned).map(r=>[r.ticketId,r]))}const gc=(e,n)=>`${e}/${n}`;let fn={reached:!1,live:!1,tickets:{}},Yl=!1;const Jl=new Set,Xl=new Set;function vo(e){fn=e;for(const n of Jl)n()}function Yf(){fetch(`${Ne()}/verification/sync`).then(e=>e.ok?e.json():Promise.reject()).then(e=>vo({reached:!0,live:!0,status:e.status,tickets:Object.fromEntries(e.tickets.map(n=>[gc(n.mapId,n.ticketId),n]))}),()=>fn.reached&&vo({...fn,live:!1}))}function Jf(){Yl=!0,Yf();const e=new EventSource(`${Ne()}/events`);e.addEventListener("verification",n=>{const r=JSON.parse(n.data);if(r.kind==="evidence")for(const l of Xl)l();if(r.kind!=="sync")return;const o={...fn.tickets};for(const l of r.tickets)o[gc(l.mapId,l.ticketId)]=l;vo({reached:!0,live:!0,status:r.status,tickets:o})}),e.addEventListener("error",()=>fn.reached&&fn.live&&vo({...fn,live:!1})),e.addEventListener("open",()=>fn.reached&&Yf())}const Bs={subscribe(e){return Yl||Jf(),Jl.add(e),()=>void Jl.delete(e)},get:()=>fn,onEvidence(e){return Yl||Jf(),Xl.add(e),()=>void Xl.delete(e)},ticket:(e,n,r)=>e.tickets[gc(n,r)]};function $x(e){if(e!=null&&e.flags.length)return e.flags.some(n=>n.severity==="alert")?"alert":"warn"}const Xf={onboarded:!1,tracker:"markdown",hitlTranscript:"summary",agent:zk.id,github:{repo:""},linear:{team:""},briefing:{enabled:!0,awayMinutes:15},theme:"night"};function vc(){try{const e={...Xf,...JSON.parse(localStorage.getItem($o)??"{}")};return["markdown","github","linear"].includes(e.tracker)||(e.tracker="markdown"),e}catch{return Xf}}function km(e){e==="auto"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e}const Tx=15*6e4;class Ex{constructor(n){ue(this,"leases",[]);ue(this,"changes",new Os);ue(this,"logged",new Set);ue(this,"since",Date.now()-Tx);this.activity=n}subscribe(n){return this.changes.on(n)}set(n){var r;this.leases=n;for(const o of n){const l=`${o.mapId}/${o.ticketId}/${(r=o.returned)==null?void 0:r.at}`;!o.returned||o.returned.at<this.since||this.logged.has(l)||(this.logged.add(l),this.activity.push({source:"system",level:"warn",ticketId:o.ticketId,text:vk(o)}))}this.changes.emit(n)}async release(n,r,o){const l=await fetch(`${Ne()}/agents/leases/release`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:n,ticketId:r,by:o})});if(!l.ok)throw new Error((await l.json().catch(()=>({}))).error??`HTTP ${l.status}`)}}let Yt;const yo=new Set,Di=new Map;function xm(e){Yt==null||Yt.addEventListener(e,n=>{for(const r of Di.get(e)??[])r(n.data)})}function wm(){if(!Yt){Yt=new EventSource(`${Ne()}/events`),Yt.onmessage=e=>{const n=JSON.parse(e.data).path;if(typeof n=="string")for(const r of yo)r(n)};for(const e of Di.keys())xm(e)}}function jm(){const e=[...Di.values()].some(n=>n.size>0);yo.size||e||(Yt==null||Yt.close(),Yt=void 0)}function hn(e){return yo.add(e),wm(),()=>{yo.delete(e),jm()}}function Do(e,n){let r=Di.get(e);return r||(r=new Set,Di.set(e,r),xm(e)),r.add(n),wm(),()=>{r.delete(n),jm()}}function Mx(e,n){return Do(e,r=>n(JSON.parse(r)))}const Ix={async list(){return(await(await fetch(`${Ne()}/list`)).json()).files},async read(e){const n=await fetch(`${Ne()}/file?path=${encodeURIComponent(e)}`);if(!n.ok)throw new Error(`read ${e}: ${n.status}`);return n.text()},async write(e,n){const r=await fetch(`${Ne()}/file?path=${encodeURIComponent(e)}`,{method:"PUT",body:n});if(!r.ok)throw new Error(`write ${e}: ${r.status}`)},watch(e){return hn(e)}};function Zf(e,n){e.remoteAnswer=(o,l,c)=>{fetch(`${Ne()}/agents/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:o.sessionId,questionId:o.id,text:l,author:c})}).then(async d=>{if(!d.ok)throw new Error((await d.json().catch(()=>({}))).error??`HTTP ${d.status}`)}).catch(d=>e.push({source:"system",level:"alert",sessionId:o.sessionId,text:`Answer not delivered to ${o.agent} · ${d.message}`}))};const r=new EventSource(`${Ne()}/events`);r.addEventListener("agent",o=>e.syncRemote(JSON.parse(o.data))),r.addEventListener("leases",o=>n.set(JSON.parse(o.data).leases)),fetch(`${Ne()}/agents/leases`).then(o=>o.ok?o.json():{leases:[]}).then(({leases:o})=>n.set(o)).catch(()=>{}),fetch(`${Ne()}/agents`).then(o=>o.ok?o.json():{sessions:[]}).then(({sessions:o})=>[...o].reverse().forEach(l=>e.syncRemote(l))).catch(()=>{})}function eh(e){const n=r=>`${$o}:${e}:${r}`;return{get:r=>localStorage.getItem(n(r)),set:(r,o)=>{try{localStorage.setItem(n(r),o)}catch{}}}}const Ax=["markdown","github","linear"];function Rx(){const e=new URLSearchParams(location.search).get("tracker");return e&&Ax.includes(e)?e:vc().tracker}function Lx(e){let n,r;const o=new vy,l=new Ex(o),c={},d=fy(Ne());if(e==="github"||e==="linear"){const m=new Pk(e,Ne());n=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 k=eh(`${e}:${m.location}`);c.presence=new Pf(k),o.ledger=new Df(k),Zf(o,l)})}else n=new Ok(Ix,`./${ge.dataDir}`),r=fetch(`${Ne()}/list`).then(m=>m.json()).catch(()=>({root:"default"})).then(({root:m})=>{const v=eh(m);c.presence=new Pf(v),o.ledger=new Df(v),Zf(o,l)});const h=wy(n),g=h.adapter;return{kind:e,ready:r,get presence(){return c.presence},adapter:g,journal:d,monitor:h,activity:o,leases:l}}const Zt=e=>e.status==="running",Sm=e=>Zt(e)&&!!e.waitingOn,Ox={blocking:0,soon:1,fyi:2};function _x(e,n,r){const o=e.filter(d=>d.sessionId===n),l=o.find(d=>d.id===r);if(l)return l;const c=d=>Ox[d.urgency??"soon"];return[...o].sort((d,h)=>c(d)-c(h)||d.at-h.at)[0]}function Zn({n:e,urgent:n,pop:r,hideZero:o}){return i.jsx("span",{className:tt("badge",n&&"urgent",r&&n&&"pop",o&&!e&&"zero"),children:o&&!e?"":e})}function K({variant:e="default",size:n="md",on:r,className:o,type:l,...c}){return i.jsx("button",{type:l??"button",className:tt("btn",e!=="default"&&e,n==="sm"&&"sm",r&&"on",o),...c})}function Rt({as:e="div",tone:n,on:r,className:o,children:l,...c}){return i.jsx(e,{className:tt("card",n,r&&"on",o),...c,children:l})}function ht({on:e,title:n,sub:r,disabled:o,onClick:l}){return i.jsxs(Rt,{as:"button",type:"button",className:"choice",on:e,disabled:o,onClick:l,children:[i.jsx("b",{className:"choice-title t-row-title",children:n}),r&&i.jsx("span",{className:"c-sub",children:r})]})}function Ie({children:e}){return i.jsx("div",{className:"empty",children:e})}function _n({title:e,hint:n,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}),n&&i.jsx("span",{className:"es-hint",children:n})]})]})}function Ye({label:e,children:n,className:r}){return i.jsxs("label",{className:tt("field",r),children:[e,n]})}const yc=x.forwardRef(function({value:n,onValueChange:r,onSubmit:o,action:l="Send",actionDisabled:c,className:d,...h},g){return i.jsxs("form",{className:tt("input-row",d),onSubmit:m=>{m.preventDefault(),o(n)},children:[i.jsx("textarea",{ref:g,rows:1,value:n,onChange:m=>r(m.target.value),onKeyDown:m=>{m.key==="Enter"&&!m.shiftKey&&(m.preventDefault(),o(n))},...h}),i.jsx(K,{type:"submit",variant:"primary",disabled:c??(h.disabled||!n.trim()),children:l})]})});function Hi({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 Ke({as:e="span",variant:n="chip",hot:r,size:o,className:l,children:c,title:d}){return i.jsx(e,{className:tt(n==="chip"?"chip-label":"mono-label",r&&"hot",o==="sm"&&(n==="chip"?"sm":"xs"),l),title:d,children:c})}const Px="M25.53 10.5 A11 11 0 1 1 16 5",Dx="M20 5 L14.6 1.6 L14.6 8.4 Z";function Us({variant:e="mark",state:n="ok",size:r=20,className:o="",title:l}){const c=r<=14?3:2.4;return i.jsxs("svg",{className:`scout-mark mm-${e} mm-${n} ${o}`,viewBox:"0 0 32 32",width:r,height:r,role:l?"img":void 0,"aria-label":l,"aria-hidden":l?void 0:!0,children:[e==="status"||e==="alert"?i.jsx("circle",{cx:"16",cy:"16",r:"11",fill:"none",stroke:"currentColor",strokeWidth:c,strokeDasharray:n==="syncing"?"5 3.6":void 0}):i.jsx("path",{d:Px,fill:"none",stroke:"currentColor",strokeWidth:c,strokeLinecap:"butt"}),(e==="mark"||e==="action")&&i.jsx("path",{d:Dx,fill:"currentColor"}),e==="action"&&i.jsx("path",{d:"M13 11 L21.5 16 L13 21 Z",fill:"currentColor"}),(e==="mark"||e==="voice")&&i.jsx("circle",{cx:"16",cy:"16",r:e==="voice"?4:3.4,fill:"currentColor"}),e==="status"&&(n==="idle"?i.jsx("circle",{cx:"16",cy:"16",r:"3.4",fill:"none",stroke:"currentColor",strokeWidth:"1.6"}):i.jsx("circle",{cx:"16",cy:"16",r:"4.2",fill:"currentColor"})),e==="alert"&&i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"14.4",y:"8.5",width:"3.2",height:"9.5",fill:"currentColor"}),i.jsx("rect",{x:"14.4",y:"20.5",width:"3.2",height:"3.2",fill:"currentColor"})]})]})}function ko({parts:e,className:n,as:r="div"}){const o=e.filter(l=>l!=null&&l!==!1&&l!=="");return i.jsx(r,{className:tt("meta",n),children:o.map((l,c)=>i.jsxs("span",{children:[c>0&&" · ",l]},c))})}const Bx=e=>typeof e=="string"?{text:e}:e,zx=e=>tt(e.code&&"t-code",e.strong&&"strong",e.urgent&&"urgent",e.className);function ee(e){const n=e.parts.filter(r=>!!r&&(typeof r=="string"||!!r.text)).map(Bx);return!n.length&&!e.children?null:i.jsxs("span",{className:tt("meta-line t-meta",e.className),children:[n.map((r,o)=>i.jsxs("span",{children:[o>0&&i.jsx("span",{className:"sep",children:" · "}),i.jsx("span",{className:zx(r)||void 0,title:r.tip,children:r.text})]},o)),e.children]})}function Fx({size:e=40,className:n}){return i.jsx(xx,{size:e,className:n})}const th=()=>{const e=document.documentElement.dataset.theme;return e?e==="night":matchMedia("(prefers-color-scheme: dark)").matches};function kc(){const[e,n]=x.useState(th);return x.useEffect(()=>{const r=()=>n(th()),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",[n,r]=x.useState(e);return x.useEffect(()=>{const o=()=>r(e());return window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)},[]),n}const Wx=15e3,nh=["pointerdown","pointermove","keydown","wheel","touchstart"];function Hx(e,n,r,o){const[l,c]=x.useState(null),[d,h]=x.useState(!1),[g,m]=x.useState(!1),v=x.useRef(),k=x.useRef(Date.now()),w=x.useRef(!1),j=r.awayMinutes*6e4,T=x.useRef(n);T.current=n;const S=x.useRef(o);S.current=o;const E=x.useCallback((B,se)=>{const oe=T.current;return Fy({snaps:Object.values(oe.allSnaps),decisions:oe.decisions,activity:oe.activity,ledger:e.activity.ledger,since:G=>{var ve;return B[G]??se??((ve=oe.allSnaps[G])==null?void 0:ve.map.createdAt)??Date.now()},currentMapId:oe.mapId,attention:S.current})},[e]),I=x.useCallback((B=Date.now())=>{var se;return(se=e.presence)==null?void 0:se.markSeen(T.current.maps.map(oe=>oe.id),B)},[e]),O=x.useCallback(()=>{const B=e.presence;if(!B)return;const se=B.lastSeenAny();if(se!==void 0&&Date.now()-se>=j){const oe=B.snapshot();E(oe,se).changed&&(v.current={seen:oe,any:se},h(!0),r.enabled?c(oe):m(!0))}I()},[e,j,r.enabled,E,I]);x.useEffect(()=>{!n.loaded||w.current||!e.presence||(w.current=!0,O())},[n.loaded,e,O]),x.useEffect(()=>{const B=()=>{const G=Date.now()-k.current>=j;k.current=Date.now(),G&&w.current&&document.visibilityState==="visible"&&O()},se=()=>{if(document.visibilityState!=="visible"){w.current&&I(Date.now()-k.current<j?Date.now():k.current);return}k.current=Date.now(),w.current&&O()};for(const G of nh)window.addEventListener(G,B,{passive:!0});document.addEventListener("visibilitychange",se);const oe=setInterval(()=>{w.current&&document.visibilityState==="visible"&&I(k.current)},Wx);return()=>{for(const G of nh)window.removeEventListener(G,B);document.removeEventListener("visibilitychange",se),clearInterval(oe)}},[j,O,I]);const R=x.useMemo(()=>{var B;return l?E(l,(B=v.current)==null?void 0:B.any):void 0},[l,E,n.allSnaps,n.decisions,n.activity,o]),X=x.useMemo(()=>R?Vy(R):"",[R]);x.useEffect(()=>{l&&m(!1)},[l]);let te="none";return g?te="new":d&&(te="seen"),{shown:l!==null,status:te,briefing:R,line:X,open:()=>{const B=v.current;B&&c(B.seen)},dismiss:()=>c(null)}}function Vx(e){const[n,r]=x.useState(e.leases.leases);return x.useEffect(()=>e.leases.subscribe(r),[e]),n}function Kx(e){var U;const[n,r]=x.useState([]),[o,l]=x.useState(),[c,d]=x.useState(),[h,g]=x.useState({}),[m,v]=x.useState({}),[k,w]=x.useState(!1),[j,T]=x.useState(e.activity.snapshot),[S,E]=x.useState(e.monitor.health),I=Vx(e);x.useEffect(()=>e.monitor.subscribe(E),[e]);const[O,R]=x.useState(null),[X,te]=x.useState(),[B,se]=x.useState(),oe=x.useRef(),G=x.useRef(),ve=x.useRef(new Set),Be=x.useRef();Be.current=c;const $e=x.useCallback(P=>{oe.current=P,l(P),R(null)},[]),ie=x.useCallback(async()=>{var pe;const P=await e.adapter.listMaps();r(P);let W=oe.current;const $=G.current;$&&P.some(de=>de.id===$)?(G.current=void 0,W=$,W!==oe.current&&$e(W)):(!W||!P.some(de=>de.id===W))&&(W=(pe=P[0])==null?void 0:pe.id,$e(W));const[_,he]=await Promise.all([Promise.all(P.map(de=>e.adapter.loadMap(de.id))),Promise.all(P.map(de=>e.adapter.listDecisions(de.id)))]);g(Object.fromEntries(_.map(de=>[de.map.id,de]))),v(Object.fromEntries(P.map((de,we)=>[de.id,he[we]]))),w(!0),d(_.find(de=>de.map.id===W))},[e,$e]);x.useEffect(()=>{let P,W=()=>{},$=()=>{},_=!0;const he=()=>{clearTimeout(P),P=setTimeout(()=>void ie().catch(me=>te(String(me))),40)},pe=(me,ye)=>Zt(me)&&e.activity.isRemote(me.id)&&(!ye||!me.mapId||me.mapId===ye),de=me=>{var ye;return(ye=Be.current)==null?void 0:ye.tickets.find(Ce=>Ce.id===me)},we=me=>{const ye=yy(me,de),Ce=me.kind==="external.changed"&&e.activity.snapshot.sessions.some(ns=>pe(ns,me.mapId)),ut=!("mapId"in me)||!me.mapId||me.mapId===oe.current||me.kind==="map.created";ye&&!Ce&&ut&&e.activity.push(ye),he()};return e.ready.then(()=>{_&&(W=e.adapter.subscribe(we),$=e.activity.subscribe(T),e.activity.push({source:"system",level:"ok",text:`Online · tracker ${e.adapter.label.toLowerCase()} · ${e.adapter.location}`}),ie().catch(me=>te(String(me))))}),()=>{_=!1,W(),$(),clearTimeout(P)}},[e,ie]),x.useEffect(()=>{o&&e.adapter.loadMap(o).then(d)},[o,e]),x.useEffect(()=>{for(const P of j.sessions)P.mode!=="chart"||!P.mapId||!e.activity.isRemote(P.id)||ve.current.has(P.id)||(ve.current.add(P.id),!(P.status!=="running"&&Date.now()-(P.endedAt??0)>6e4)&&(G.current=P.mapId,ie().catch(W=>te(String(W)))))},[j.sessions,e,ie]);const D=(U=j.pending[0])==null?void 0:U.sessionId;x.useEffect(()=>{if(!D)return;const P=W=>e.activity.snapshot.sessions.some($=>$.id===W&&Zt($));se(W=>P(W)?W:D)},[D,e]);const q=x.useCallback(async(P,W)=>{e.activity.push({source:"trail lead",agent:xt,level:"warn",text:P});try{te(void 0),await W()}catch($){const _=$.message??String($);te(_),e.activity.push({source:"trail lead",agent:xt,level:"alert",text:`Rejected · ${_}`})}},[e]),ae=x.useMemo(()=>wx({rt:e,guard:q,setMapId:$e,mapIdRef:oe,snapRef:Be,setChatSession:se,setSelection:R}),[q,e,$e]),Y=x.useMemo(()=>Object.values(h).flatMap(P=>Cy(P,m[P.map.id]??[])).sort((P,W)=>W.decidedAt-P.decidedAt),[h,m]);return{maps:n,allSnaps:h,mapId:o,snap:c,activity:j,health:S,selection:O,setSelection:R,error:X,chatSession:B,decisions:Y,leases:I,loaded:k,actions:ae}}function tn(e=1e3){const[n,r]=x.useState(Date.now());return x.useEffect(()=>{const o=setInterval(()=>r(Date.now()),e);return()=>clearInterval(o)},[e]),n}function Gx(){const[e,n]=x.useState(vc),r=x.useCallback(o=>{n(l=>{const c={...l,...o};return localStorage.setItem($o,JSON.stringify(c)),c})},[]);return[e,r]}function xc(){return x.useSyncExternalStore(Bs.subscribe,Bs.get)}function Nm({className:e,size:n=18}){return i.jsx("span",{className:e,"aria-hidden":"true",children:i.jsx(mm,{size:n,variant:kc()?"night":"crt"})})}function We({as:e="section",className:n,style:r,frameless:o,children:l,...c}){return i.jsx(e,{className:tt("panel",o&&"frameless",n),style:r,...c,children:l})}function Dn({tone:e,className:n,children:r,title:o}){return i.jsx("span",{className:tt("pill",e,n),title:o,children:r})}function Jt({label:e,value:n,layout:r="stack",urgent:o,title:l,className:c}){return i.jsxs("span",{className:tt("readout",r!=="stack"&&r,o&&"urgent",c),title:l,children:[i.jsx("span",{className:"mono-label",children:e}),r==="inline"&&" ",i.jsx("b",{children:n})]})}function Re(e){const{as:n="div",edge:r="neutral"}=e,o=e.onOpen?"button":"div";return i.jsxs(n,{className:tt("ds-row",`edge-${r}`,e.selected&&"on",e.className),children:[i.jsxs(o,{className:"ds-row-main",...e.onOpen?{type:"button",onClick:e.onOpen}:{},title:e.titleText,"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 Ln="#c8581e",qx={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:Ln,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:Ln})]}),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:Ln})]}),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:Ln,stroke:Ln})]}),tent:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 4L2.5 20h19z"}),i.jsx("path",{d:"M12 11l-4 9h8z",fill:Ln,stroke:Ln}),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:Ln})]})};function bm({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:qx[e]})}function bt({title:e,count:n,right:r,hot:o,sub:l,children:c,className:d,info:h,icon:g}){return i.jsxs("header",{className:tt("sec-h",l&&"sub",d),children:[c,g&&i.jsx(bm,{name:g}),e!==void 0&&i.jsx(Ke,{as:l?"h3":"h2",hot:o,children:e}),h&&i.jsx(Hi,{text:h}),n,r!==void 0&&i.jsx("span",{className:"sec-h-right",children:r})]})}function ct(e){const{value:n,options:r,onChange:o}=e,[l,c]=x.useState(!1),[d,h]=x.useState(0),[g,m]=x.useState(),v=x.useRef(null),k=x.useRef(null),w=x.useId(),j=r.find(I=>I.value===n);x.useLayoutEffect(()=>{if(!l||!v.current)return;const I=v.current.getBoundingClientRect();m({left:I.left,top:I.bottom+4,minWidth:I.width})},[l]),x.useEffect(()=>{if(!l)return;const I=R=>{var X,te;R.target instanceof Node&&((X=k.current)!=null&&X.contains(R.target)||(te=v.current)!=null&&te.contains(R.target))||c(!1)},O=()=>c(!1);return document.addEventListener("mousedown",I),window.addEventListener("resize",O),window.addEventListener("scroll",O,!0),()=>{document.removeEventListener("mousedown",I),window.removeEventListener("resize",O),window.removeEventListener("scroll",O,!0)}},[l]),x.useEffect(()=>{var I,O;l&&((O=(I=k.current)==null?void 0:I.querySelector(`[data-i="${d}"]`))==null||O.scrollIntoView({block:"nearest"}))},[l,d]);const T=()=>{h(Math.max(0,r.findIndex(I=>I.value===n))),c(!0)},S=I=>{var R;const O=r[I];c(!1),(R=v.current)==null||R.focus(),O&&O.value!==n&&o(O.value)},E=I=>{if(!l){["ArrowDown","ArrowUp","Enter"," "].includes(I.key)&&(I.preventDefault(),T());return}const O=R=>h(X=>(X+R+r.length)%r.length);if(I.key==="ArrowDown")O(1);else if(I.key==="ArrowUp")O(-1);else if(I.key==="Home")h(0);else if(I.key==="End")h(r.length-1);else if(I.key==="Enter"||I.key===" ")S(d);else{if(I.key==="Escape"||I.key==="Tab")return c(!1);if(I.key.length===1){const R=r.findIndex(X=>X.label.toLowerCase().startsWith(I.key.toLowerCase()));R>=0&&h(R);return}else return}I.preventDefault()};return i.jsxs(i.Fragment,{children:[i.jsxs("button",{ref:v,type:"button",className:tt("select",e.compact&&"compact",l&&"open",e.className),role:"combobox","aria-haspopup":"listbox","aria-expanded":l,"aria-controls":w,"aria-label":e["aria-label"],"aria-activedescendant":l?`${w}-${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:k,id:w,className:"select-menu",role:"listbox",style:g,children:r.map((I,O)=>i.jsxs("li",{id:`${w}-${O}`,"data-i":O,role:"option","aria-selected":I.value===n,className:tt(O===d&&"active"),onMouseEnter:()=>h(O),onMouseDown:R=>R.preventDefault(),onClick:()=>S(O),children:[i.jsx("span",{className:"select-label",children:I.label}),I.hint&&i.jsx("span",{className:"select-hint",children:I.hint})]},I.value))})]})}function Cm(e){return i.jsx("div",{className:`tabs ${e.className??""}`,role:"tablist",children:e.items.map(n=>i.jsxs("button",{role:"tab","aria-selected":e.value===n.id,className:`tab ${e.value===n.id?"on":""}`,onClick:()=>e.onChange(n.id),children:[n.label,n.n!==void 0&&i.jsx("span",{className:"n",children:n.n})]},n.id))})}const Qx=350;function Yx(){const[e,n]=x.useState(null);if(x.useEffect(()=>{let o=0,l=null;const c=()=>{window.clearTimeout(o),l=null,n(null)},d=v=>{const k=v.getAttribute("data-tip");if(!k)return;const w=v.getBoundingClientRect(),j=w.bottom+60>window.innerHeight;n({text:k,x:w.left+w.width/2,y:j?w.top-8:w.bottom+8,above:j,scout:v.hasAttribute("data-tip-scout")})},h=v=>{var j,T;const k=(T=(j=v.target)==null?void 0:j.closest)==null?void 0:T.call(j,"[data-tip], [title]");if(!k||k instanceof SVGElement)return null;const w=k.getAttribute("title");return w&&(k.setAttribute("data-tip",w),k.removeAttribute("title")),k},g=v=>{if(v.pointerType==="touch")return;const k=h(v);k!==l&&(c(),k&&(l=k,o=window.setTimeout(()=>l===k&&d(k),v.type==="focusin"?0:Qx)))},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(Oo,{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 $m({as:e="span",className:n}){return i.jsx(e,{className:n,children:ge.name})}function Tm(e){return e.bare?i.jsx("div",{className:`zone-b ${e.className??""}`,children:e.children}):i.jsxs(We,{className:`zone ${e.className??""}`,style:e.area?{gridArea:e.area}:void 0,children:[i.jsx(bt,{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 Ts(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 ro(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 Ai(e){return i.jsxs(Rt,{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(ee,{parts:[],children:e.sub})]})}const Jx=864e5;function Xx(e,n){const r=new Date(e),o=r.toTimeString().slice(0,5),l=new Date(n).toDateString(),c=new Date(n-Jx).toDateString();let d=` ${r.toLocaleDateString(void 0,{month:"short",day:"numeric"})}`;return r.toDateString()===l?d="":r.toDateString()===c&&(d=" yesterday"),`Since ${o}${d} · ${Ut(n-e)}`}function Zx(e){const{briefing:n,bp:r,onClose:o}=e;x.useEffect(()=>{const k=w=>w.key==="Escape"&&o();return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[o]);const l=n==null?void 0:n.trails.flatMap(k=>k.waiting).sort((k,w)=>k.at-w.at)[0],c=n==null?void 0:n.totals,d=((n==null?void 0:n.trails.length)??0)>1,h=r==="mobile",g=k=>{var w,j;return k.ticketId&&((j=(w=e.snaps[k.mapId])==null?void 0:w.tickets.find(T=>T.id===k.ticketId))==null?void 0:j.title)||k.text},m=k=>{var w,j;return k.ticketId&&((j=(w=e.snaps[k.mapId])==null?void 0:w.tickets.find(T=>T.id===k.ticketId))==null?void 0:j.key)||k.agent},v=k=>{const w=(I,O)=>i.jsx(ro,{k:I.key,text:I.title,meta:O,onClick:()=>e.onTicket(k.mapId,I.id)},I.id),j=(I,O)=>i.jsx(ro,{k:I.id,text:I.summary||I.answer,title:I.risk?`${I.question}
118
+
119
+ ${I.risk.reason}`:I.question,meta:O,onClick:()=>e.onDecision(I.id)},I.id),T=pk(k.agentDecisions).flatMap(I=>I.decisions.map(O=>j(O,I.label))),S=[i.jsx(Ts,{title:"Done",children:k.done.map(I=>w(I))},"done"),i.jsx(Ts,{title:"Ruled out",children:h?[]:k.ruledOut.map(I=>w(I))},"oos"),i.jsx(Ts,{title:"Blocked",children:k.blocked.map(I=>w(I.ticket,`needs ${I.on.map(O=>O.key).join(", ")}`))},"blocked")],E=[i.jsx(Ts,{title:"Waiting on you",urgent:!0,children:k.waiting.map(I=>i.jsx(ro,{k:m(I),text:g(I),meta:n.now-I.at<6e4?"now":Ut(n.now-I.at),title:I.text,onClick:()=>e.onAnswer(I)},I.id))},"waiting"),i.jsx(Ts,{title:"Agent decisions",children:h?[]:T},"agent"),i.jsx(Ts,{title:"Active sessions",children:h?[]:k.active.map(I=>{var R;const O=I.ticketId?(R=e.snaps[k.mapId])==null?void 0:R.tickets.find(X=>X.id===I.ticketId):void 0;return i.jsx(ro,{k:(O==null?void 0:O.key)??I.agent,text:O?`${O.title} · ${I.stepLabel}`:I.stepLabel,meta:`${I.step}/${I.total}`,onClick:()=>e.onSession(I)},I.id)})},"active")];return i.jsxs("section",{className:"bf-trail",children:[d&&i.jsxs("div",{className:"bf-trail-h",children:[i.jsx("span",{className:"key",children:k.key})," ",k.title]}),i.jsxs("div",{className:"bf-cols",children:[i.jsx("div",{children:S}),i.jsx("div",{children:E})]})]},k.mapId)};return i.jsx("div",{className:"scrim",onClick:o,children:i.jsxs(We,{as:"div",className:"dialog briefing",role:"dialog","aria-label":"While you were away",onClick:k=>k.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:"While you were away"}),n&&n.trails.length>0&&i.jsx(Ke,{className:"bf-since",children:Xx(n.since,n.now)}),i.jsx("button",{className:"icon-btn",onClick:o,"aria-label":"Close",children:"×"})]}),i.jsxs(Rt,{className:"bf-scout",children:[i.jsx(Oo,{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."})]})]}),n&&c&&n.trails.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"bf-tiles",children:[i.jsx(Ai,{label:"Done",value:c.done,sub:c.ruledOut?`${c.ruledOut} ruled out`:void 0}),i.jsx(Ai,{label:"Blocked",value:c.blocked,sub:c.blocked?"Needs your answer":void 0}),i.jsx(Ai,{label:"Waiting on you",value:c.waiting,sub:ew(c.oldestWaitMs),urgent:c.waiting>0}),i.jsx(Ai,{label:"Agent decisions",value:c.agentDecisions,className:"opt"}),i.jsx(Ai,{label:"Spend",value:Ps(c.usage.costUsd),sub:`${Po(c.usage.inputTokens+c.usage.outputTokens)} tokens · ${c.usage.sessions} sessions${c.active?` · ${c.active} active`:""}`})]}),i.jsx("div",{className:"bf-body",children:n.trails.map(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(Us,{variant:"alert",size:13}),"Answer first decision"]}):i.jsx(K,{variant:"primary",onClick:e.onResume,children:"Resume trail"})]})]})})}function ew(e){if(e!==void 0)return e<6e4?"Just asked":`Oldest ${Ut(e)}`}function tw(e){const{brief:n,bp:r}=e;return i.jsx(Zx,{briefing:n.briefing,line:n.line,snaps:e.snaps,bp:r,onClose:n.dismiss,onTicket:(o,l)=>{n.dismiss(),e.openTicket(o,l)},onAnswer:o=>{n.dismiss(),e.closeDecisions(),e.openChat(o.sessionId,o.ticketId,o.mapId)},onSession:o=>{n.dismiss(),e.closeDecisions(),e.openChat(o.id,o.ticketId,o.mapId)},onDecision:o=>{n.dismiss(),e.openDecisions(o)},onResume:()=>{n.dismiss(),e.closeDecisions(),r==="mobile"&&e.showPhoneHome()}})}const nw={passed:"checks passed",failing:"checks failing",pending:"checks pending",unknown:"checks unknown",none:"no checks"};function sw({mapId:e,ticketId:n}){const r=Bs.ticket(xc(),e,n);if(!r)return null;const o=r.pr;return i.jsxs("div",{className:"pr-flags",children:[i.jsxs("span",{className:`pr-chip pr-${(o==null?void 0:o.state)??"unread"}`,title:o?`${o.title}
120
+ ${o.headRef}`:void 0,children:[o?i.jsxs("a",{href:o.url,target:"_blank",rel:"noreferrer noopener",children:["PR #",o.number," · ",o.state,o.draft?" · draft":""]}):`PR #${r.link.number}`,i.jsx("span",{className:`ci ci-${r.checksSummary}`,children:nw[r.checksSummary]}),i.jsx("span",{className:"when",children:iw(r)})]}),r.flags.map(l=>i.jsx(Dn,{className:`flag flag-${l.severity}`,title:l.text,children:l.kind},l.kind))]})}function iw(e){return e.error?"sync failed":e.syncedAt?vm(e.syncedAt):"not synced yet"}const rw={ok:"ok",failed:"error",stale:"syncing",unknown:"idle",off:"idle"};function ow({now:e}){const n=xc();if(!n.reached)return null;const r=my(n.live?n.status:null,e);return i.jsxs("span",{className:`tracker-chip pr-sync tone-${r.tone}`,title:r.title,children:[i.jsx(Ke,{size:"sm",children:"CI"}),i.jsx(Us,{variant:"status",state:rw[r.tone],size:13,className:"sync-glyph"}),i.jsx("span",{className:"tl",children:r.label})]})}function aw(e){const[n,r]=x.useState(!1),o=x.useRef(null);return x.useEffect(()=>{if(!n)return;const l=c=>{var h;(c instanceof KeyboardEvent?c.key==="Escape":!((h=o.current)!=null&&h.contains(c.target)))&&r(!1)};return window.addEventListener("mousedown",l),window.addEventListener("keydown",l),()=>{window.removeEventListener("mousedown",l),window.removeEventListener("keydown",l)}},[n]),i.jsxs("div",{className:"header-menu",ref:o,children:[i.jsxs(K,{variant:"ghost","aria-haspopup":"menu","aria-expanded":n,on:n,onClick:()=>r(!n),children:[e.label," ",e.badge," ",i.jsx("span",{className:"caret",children:"▾"})]}),n&&i.jsx("div",{className:"header-menu-list",role:"menu",children:e.children(()=>r(!1))})]})}const lw={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 cw(e){const n=e.briefingStatus==="new";return i.jsx(aw,{label:"Records",badge:i.jsxs(i.Fragment,{children:[e.knowledge>0&&i.jsx("span",{className:"n hot",children:e.knowledge}),n&&i.jsx("span",{className:"new-dot","aria-label":"new trip report"})]}),children:r=>i.jsxs(i.Fragment,{children:[i.jsxs("button",{role:"menuitem",className:"header-menu-item",disabled:e.briefingStatus==="none"&&!e.briefingOpen,title:lw[e.briefingStatus],onClick:()=>{r(),e.onBriefing()},children:[i.jsx("span",{children:"Trip report"}),n&&i.jsx("span",{className:"new-dot","aria-label":"new"})]}),i.jsxs("button",{role:"menuitem",className:"header-menu-item knowledge-btn",title:"What agents know about this codebase and product. Review suggestions, flags and stale entries",onClick:()=>{r(),e.onKnowledge()},children:[i.jsx("span",{children:"Field guide"}),e.knowledge>0&&i.jsx("span",{className:"n hot",children:e.knowledge})]}),i.jsxs("button",{role:"menuitem",className:"header-menu-item decisions-btn",title:"Every decision across your trails, with its reasoning. Search, filter and export",onClick:()=>{r(),e.onDecisions()},children:[i.jsx("span",{children:"Logbook"}),i.jsx("span",{className:"n",children:e.decisions})]}),i.jsx("button",{role:"menuitem",className:"header-menu-item stats-btn",title:"How your agents deliver across trails, by vendor, agent and ticket type.",onClick:()=>{r(),e.onStats()},children:i.jsx("span",{children:"Trail stats"})})]})})}const uw=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"})]}),dw=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 fw({onToggle:e}){const n=kc(),r=n?"Switch to the day theme":"Switch to the night theme";return i.jsx(K,{variant:"ghost",className:"icon-only","aria-label":r,"data-tip":r,onClick:()=>e(!n),children:i.jsx("svg",{viewBox:"0 0 18 18",width:"16",height:"16","aria-hidden":"true",children:n?uw:dw})})}const hw={idle:"Idle",syncing:"Syncing",ok:"Synced",error:"Sync error"};function mw({label:e,health:n,now:r}){const o=[`${hw[n.status]} · ${n.writes} writes · ${n.errors} errors`,n.lastWriteAt?`Last write ${Ut(n.lastWriteMs??0)}, ${Ut(r-n.lastWriteAt)} ago`:"No writes yet",n.lastError].filter(Boolean).join(`
121
+ `);return i.jsxs("span",{className:`tracker-chip sync-${n.status}`,title:o,children:[i.jsx(Ke,{size:"sm",children:"Tracker"}),i.jsx(Us,{variant:"status",state:n.status,size:13,className:"sync-glyph"}),i.jsx("span",{className:"tl",children:e})]})}function pw(e){const[n,r]=x.useState(!1),o=x.useRef(null);x.useEffect(()=>{if(!n)return;const h=g=>{var m;(g instanceof KeyboardEvent?g.key==="Escape":!((m=o.current)!=null&&m.contains(g.target)))&&r(!1)};return window.addEventListener("mousedown",h),window.addEventListener("keydown",h),()=>{window.removeEventListener("mousedown",h),window.removeEventListener("keydown",h)}},[n]);const l=Object.values(e.snaps).sort((h,g)=>g.map.createdAt-h.map.createdAt),c=h=>e.activity.pending.filter(g=>g.mapId===h).length,d=e.activity.pending.filter(h=>{var g;return h.mapId!==((g=e.map)==null?void 0:g.id)}).length;return i.jsxs("div",{className:"trail-switcher",ref:o,children:[i.jsxs("button",{className:"trail-btn",onClick:()=>r(h=>!h),"aria-haspopup":"menu","aria-expanded":n,"data-tip":"Switch trail, or start a new one",children:[i.jsx("span",{className:"trail-title",children:e.map?`${e.map.key} ${e.map.title}`:"No trail"}),d>0&&i.jsx(Zn,{n:d,urgent:!0}),i.jsx("span",{className:"caret",children:"▾"})]}),n&&i.jsxs("div",{className:"trail-menu",role:"menu",children:[i.jsx(Ke,{variant:"plain",className:"menu-h",children:"Trails"}),l.map(h=>{var v;const g=Jh(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(Zn,{n:m,urgent:!!m,hideZero:!0})]},h.map.id)}),i.jsx("button",{role:"menuitem",className:"trail-item new",onClick:()=>{r(!1),e.onNewTrail()},children:"+ New trail"})]})]})}function gw(e){const{map:n}=e,r=tn(1e3),o=e.activity.pending.length,l=n&&e.snaps[n.id],c=l&&Jh(l),d=n&&Xh(e.activity,n.id);return i.jsxs(We,{as:"header",className:"header",children:[i.jsxs("div",{className:"h-title",children:[i.jsxs("div",{className:"h-line1",children:[e.repo,i.jsx("span",{className:"sep",children:"/"}),i.jsx(pw,{...e})]}),i.jsxs("div",{className:"h-dest",title:n==null?void 0:n.sections.destination,children:[i.jsx(Ke,{size:"sm",children:"Destination"}),(n==null?void 0:n.sections.destination)??"—"]})]}),i.jsxs("div",{className:"h-right",children:[i.jsx(mw,{label:e.trackerLabel,health:e.health,now:r}),i.jsx(ow,{now:r}),n&&c&&i.jsxs("span",{className:"trail-meta",children:[i.jsx(Jt,{label:"Trail T+",value:gm(r-n.createdAt),title:"Trail elapsed time, since it was charted"}),i.jsx(Jt,{label:"Done",value:`${c.decided}/${c.total}`}),d&&i.jsx(Jt,{className:"spend",label:"Spent",value:`${Ps(d.costUsd)} · ${Po(d.inputTokens+d.outputTokens)} tok`,title:["Model spend and tokens for this trail, across every session",...em(e.activity,n.id).map(h=>Zh[h].text)].join(`
122
+ `)})]}),e.attention,!e.attention&&o>0&&i.jsxs("span",{className:"waiting-chip",title:`${o} waiting on you`,children:[i.jsx(Us,{variant:"alert",size:14}),i.jsx("b",{children:o}),i.jsx("span",{className:"wl",children:" waiting on you"})]}),e.slackAlert&&i.jsx(K,{size:"sm",variant:"urgent",onClick:e.onSlack,title:e.slackAlert,children:"Slack disconnected"}),n&&i.jsx(K,{variant:"ghost",className:"mode-chip",onClick:e.onToggleMode,"data-tip":n.mode==="plan-only"?"Plan only: agents research and decide, but no execute tickets run. Click to switch to Plan + execute.":"Plan + execute: agents decide, then build what was decided. Click to switch to Plan only, which parks execute tickets.",children:n.mode==="plan-only"?"Plan only":"Plan + execute"}),i.jsx(cw,{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(fw,{onToggle:e.onToggleTheme})]})]})}const Em=x.createContext(null);function Ws(){const e=x.useContext(Em);if(!e)throw new Error("useKnowledge needs a KnowledgeContext provider");return e}function vw({snap:e,t:n}){const r=Ws();if(!r.entries.length||n.state==="closed")return null;const o=cm(r.entries,{trailKey:e.map.key,ticket:{type:n.type,title:n.title,body:n.body},paths:um(`${n.body}
123
+ ${r.briefText}`)},4e3,l=>r.stale[l.id]??[]);return i.jsxs("div",{className:"kn-preview d-section",children:[i.jsxs("span",{className:"t-label","data-tip":"Picked by paths, words, trail and kind; confirmed entries and assumptions only",children:["Knowledge this agent gets · ",o.length]}),o.length>0&&i.jsx("ul",{className:"item-list inline",children:o.map(l=>i.jsxs("li",{children:[i.jsx("button",{className:"item-text kn-open",onClick:()=>r.setOpen(!0),"data-tip":l.why.join(" · "),children:l.title}),i.jsx(ee,{parts:[{text:l.id,code:!0},l.status==="assumption"&&"assumption",l.mayBeOutdated&&{text:"may be outdated",className:"warn"}]})]},l.id))})]})}const yw={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 kw({e}){const n=Ws(),[r,o]=x.useState(!1),[l,c]=x.useState(e.title),[d,h]=x.useState(e.body);x.useEffect(()=>{o(!1),c(e.title),h(e.body)},[e.id,e.title,e.body]);const g=n.stale[e.id];return i.jsxs("div",{className:"kn-detail",children:[i.jsx(ee,{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:yw[e.status]}),e.flag&&i.jsxs("p",{className:"kn-warn",children:["Flagged by ",e.flag.by,": ",e.flag.reason]}),g&&e.status!=="outdated"&&i.jsxs("p",{className:"kn-warn",children:["May be outdated: ",g.join(", ")," changed since it was confirmed. Re-confirm or edit it."]}),i.jsxs("dl",{className:"facts",children:[e.scope.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Applies to"}),i.jsx("dd",{children:e.scope.join(", ")})]}),e.tags.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Tags"}),i.jsx("dd",{children:e.tags.join(", ")})]}),i.jsx("dt",{children:"From"}),i.jsx("dd",{children:[e.createdBy,...e.sources].join(" · ")}),e.anchors.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"About files"}),i.jsx("dd",{children:e.anchors.map(m=>m.path).join(", ")})]})]}),n.error&&i.jsx("p",{className:"vf-err",children:n.error}),i.jsx("div",{className:"actions",children:r?i.jsxs(i.Fragment,{children:[i.jsx(K,{variant:"ghost",onClick:()=>o(!1),children:"Cancel"}),i.jsx(K,{variant:"primary",disabled:!l.trim(),onClick:()=>void n.call(e.id,{kind:"edit",title:l,body:d}).then(m=>m&&o(!1)),children:"Save"})]}):i.jsxs(i.Fragment,{children:[(e.status!=="confirmed"||g)&&i.jsx(K,{variant:"primary",onClick:()=>void n.call(e.id,{kind:"confirm"}),children:e.status==="confirmed"?"Re-confirm":"Confirm"}),e.status!=="assumption"&&e.status!=="outdated"&&i.jsx(K,{onClick:()=>void n.call(e.id,{kind:"assumption"}),children:"Keep as assumption"}),e.flag&&i.jsx(K,{onClick:()=>void n.call(e.id,{kind:"resolve-flag"}),children:"Resolve flag"}),i.jsx(K,{variant:"ghost",onClick:()=>o(!0),children:"Edit"}),e.status!=="outdated"&&i.jsx(K,{variant:"ghost",onClick:()=>void n.call(e.id,{kind:"outdated"}),children:"Mark outdated"})]})})]})}const xw={suggested:"Suggested",confirmed:"Confirmed",assumption:"Assumption",outdated:"Outdated"};function ww(){const e=Ws(),[n,r]=x.useState("review"),[o,l]=x.useState(""),[c,d]=x.useState(""),[h,g]=x.useState();x.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,k=x.useMemo(()=>{const S=c.trim().toLowerCase();return e.entries.filter(E=>v(E,n)&&(!o||E.kind===o)&&(!S||`${E.id} ${E.title} ${E.body} ${E.tags.join(" ")}`.toLowerCase().includes(S)))},[e.entries,e.stale,n,o,c]);if(!e.open)return null;const w=k.find(S=>S.id===h)??k[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(We,{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(Hi,{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 ${n===S?"on":""}`,onClick:()=>r(S),children:[E," ",i.jsx("span",{className:"n",children:j(S)})]},S)),i.jsx(ct,{compact:!0,"aria-label":"Kind",value:o,onChange:l,options:[{value:"",label:"Any kind"},...ak.map(S=>({value:S,label:S.replace("-"," ")}))]}),i.jsx("input",{className:"kn-search",placeholder:"Search",value:c,onChange:S=>d(S.target.value)})]}),i.jsxs("div",{className:"kn-body-grid",children:[i.jsx("ul",{className:"kn-list",children:k.length?k.map(S=>i.jsx(Re,{as:"li",className:`kn-row st-${S.status}`,edge:m(S)?"attention":"neutral",selected:S===w,onOpen:()=>g(S.id),title:S.title,titleText:S.title,context:i.jsx(ee,{parts:[{text:S.id,code:!0},S.kind.replace("-"," "),m(S)&&S.status!=="suggested"?"Needs a check":xw[S.status]]})},S.id)):i.jsx(Ie,{children:n==="review"?"Nothing needs you":"No entries"})}),w?i.jsx(kw,{e:w}):i.jsx(Ie,{children:"Pick an entry"})]})]})})}function wc({draft:e,label:n="Save as knowledge"}){const r=Ws(),[o,l]=x.useState();return o?i.jsxs(K,{size:"sm",variant:"ghost",onClick:()=>r.setOpen(!0),"data-tip":"Open it in the field guide to confirm it",children:["Saved as ",o]}):i.jsx(K,{size:"sm",variant:"ghost","data-tip":"Add it to the field guide as a suggestion; confirm it there and agents get it with related work",onClick:()=>void r.propose(e()).then(c=>c&&l(c.id)),children:n})}const Mm=`${Ne()}/knowledge`;async function sh(e,n){const r=await fetch(`${Mm}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),o=await r.json().catch(()=>({}));if(!r.ok)throw new Error(o.error??`HTTP ${r.status}`);return o}function jw(e){const[n,r]=x.useState([]),[o,l]=x.useState({}),[c,d]=x.useState(!1),[h,g]=x.useState(),m=x.useCallback(()=>{fetch(Mm).then(k=>k.ok?k.json():null).then(k=>{k&&(r(k.entries),l(k.stale))}).catch(()=>{})},[]);x.useEffect(()=>(m(),hn(k=>k.startsWith("knowledge/")&&m())),[m]);const v=x.useMemo(()=>n.filter(k=>k.status==="suggested"||k.flag||o[k.id]&&k.status!=="outdated").length,[n,o]);return{entries:n,stale:o,briefText:e,attention:v,open:c,setOpen:d,error:h,call:(k,w)=>sh("/call",{id:k,call:w}).then(()=>(g(void 0),m(),!0),j=>(g(j.message),!1)),propose:k=>sh("/propose",k).then(w=>(m(),w.entry),w=>(g(w.message),void 0))}}function Zl(e){const[n,r]=x.useState(!1),[o,l]=x.useState(""),c=async()=>{let d="";try{d=await navigator.clipboard.readText()}catch{r(!0);return}d.trim()?e.onToken(d,!0):r(!0)};return i.jsxs("div",{className:"sl-paste",children:[i.jsx(K,{variant:"primary",disabled:e.busy,onClick:()=>void c(),children:e.busy?"Checking…":"Paste"}),n?i.jsxs("form",{className:"sl-paste-field",onSubmit:d=>{d.preventDefault(),e.onToken(o,!0),l("")},children:[i.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,autoFocus:!0,value:o,placeholder:e.placeholder,"aria-label":"Token",onChange:d=>l(d.target.value)}),i.jsx(K,{type:"submit",disabled:e.busy||!o.trim(),children:"Save"})]}):i.jsx("button",{type:"button",className:"link",onClick:()=>r(!0),children:"Type it instead"})]})}const Sw=["awaiting","blocked","trail.done","resolved"],Nw=["commands","chat:write","im:write","channels:history","groups:history","im:history","mpim:history","users:read"],bw=["users:read.email"],Cw="save_decision",$w=`/${ge.assistant.name.toLowerCase()}`;function Tw(e={}){const n=ge.assistant.name;return{display_information:{name:n,description:`${ge.name} decisions and agent questions`,background_color:"#1b2226"},features:{app_home:{home_tab_enabled:!0,messages_tab_enabled:!0,messages_tab_read_only_enabled:!1},bot_user:{display_name:n,always_online:!0},slash_commands:[{command:e.command??$w,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:Cw,description:`Record this thread as a ${ge.name} decision`}]},oauth_config:{scopes:{bot:[...Nw,...bw]}},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 Ew={create:e=>`https://api.slack.com/apps?new_app=1&manifest_json=${encodeURIComponent(JSON.stringify(Tw({command:e})))}`,app:e=>`https://api.slack.com/apps/${e}/general`,install:e=>`https://api.slack.com/apps/${e}/install-on-team`,home:(e,n)=>`slack://app?team=${e}&id=${n}&tab=home`,homeWeb:(e,n)=>`https://slack.com/app_redirect?app=${n}&team=${e}`};function Mw(e){const n=e.trim().match(/^xapp-\d+-(A[A-Z0-9]+)-/);return n==null?void 0:n[1]}async function Xn(e,n="GET",r){const o=await fetch(e,{method:n,headers:{"Content-Type":"application/json"},body:r===void 0?void 0:JSON.stringify(r)}),l=await o.json().catch(()=>({}));if(!o.ok&&!l.status)throw new Error(l.error??`request failed (${o.status})`);return l}function Iw(e){const n=`${e}/slack`;return{get:()=>Xn(n),created:()=>Xn(`${n}/created`,"POST",{}),token:r=>Xn(`${n}/token`,"POST",{token:r}),update:r=>Xn(`${n}/settings`,"PUT",r),resetOwner:()=>Xn(`${n}/owner/reset`,"POST",{}),members:()=>Xn(`${n}/members`).then(r=>r.members),remove:()=>Xn(n,"DELETE")}}const Pn=Iw(Ne());function Aw(e){const[n,r]=x.useState(!1),[o,l]=x.useState(),c=d=>{r(!0),Pn.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(Zl,{busy:n,placeholder:"xapp-… or xoxb-…",onToken:c}),o&&i.jsxs("div",{className:"test-line alert",children:["✕ ",o]})]})}function Rw({onRemoved:e}){const[n,r]=x.useState(!1);if(!n)return i.jsx(K,{size:"sm",variant:"ghost",onClick:()=>r(!0),children:"Remove"});const o=()=>void Pn.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 Lw={awaiting:"Awaiting you",blocked:"Blocked","trail.done":"Trail done",resolved:"Resolved"};function Im({s:e}){const[n,r]=Ow(e);return i.jsxs("div",{className:`sync-line ${n}`,title:e.error,children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:r})]})}function Ow(e){switch(e.state){case"online":return["ok","Online"];case"connecting":return["","Connecting"];case"offline":return["warn","Offline · reconnecting"];case"auth-error":return["alert","Disconnected · Slack rejected the tokens"];case"elsewhere":{const n=e.heldBy?` (${e.heldBy})`:"";return["warn",`Connected from another ${ge.slug}${n}`]}case"unsupported":return["alert",e.error??"Not supported here"];default:return["",e.step==="done"?"Off":"Not connected"]}}function _w(e){const{s:n,setup:r}=e,o=n.step==="done";return i.jsxs(Rt,{className:Dw(n,r),children:[i.jsxs("div",{className:"card-row",children:[i.jsx("b",{className:"choice-title t-row-title",children:"Scout app"}),o&&i.jsx(Dn,{className:n.enabled?"on":"",children:n.enabled?"On":"Off"})]}),o&&i.jsx("div",{className:"c-loc",children:Pw(n)}),o&&i.jsx(Im,{s:n}),!o&&n.step===1&&!r&&i.jsx("p",{className:"sl-lead",children:"Answer agents and save threads as decisions from Slack. Your own Slack app, connected from this machine; tokens stay in your local credential store."}),i.jsxs("div",{className:"c-actions",children:[!o&&!r&&i.jsx(K,{size:"sm",variant:"primary",onClick:()=>e.onSetup(!0),children:n.step===1?"Connect":`Resume at step ${n.step}`}),o&&i.jsx(K,{size:"sm",on:n.enabled,onClick:e.onToggle,children:n.enabled?"Turn off":"Turn on"}),o&&n.state==="auth-error"&&i.jsx(K,{size:"sm",variant:"primary",onClick:()=>e.onSetup(!0),children:"Reconnect"}),n.step!==1&&i.jsx(Rw,{onRemoved:e.onRemoved})]})]})}function Pw(e){var r,o,l;const n=(o=(r=e.workspace)==null?void 0:r.url)==null?void 0:o.replace(/^https?:\/\/|\/$/g,"");return[(l=e.workspace)==null?void 0:l.name,n,e.setup.appId].filter(Boolean).join(" · ")}function Dw(e,n){const r=e.step==="done";return`connector ${r&&e.enabled?"active":""} ${n||!r?"open":""}`}function Bw(e){const[n,r]=x.useState(e.value==="dm"?"":e.value),o=/^[CG][A-Z0-9]{6,}$/.test(n.trim());return i.jsxs("form",{className:"sl-paste-field",onSubmit:l=>{l.preventDefault(),o&&e.onSave(n.trim())},children:[i.jsx("input",{value:n,spellCheck:!1,placeholder:"Channel ID, e.g. C0123ABCD","aria-label":"Channel ID",onChange:l=>r(l.target.value)}),i.jsx(K,{type:"submit",disabled:!o||n.trim()===e.value,children:"Save"})]})}function zw(e){const[n,r]=x.useState(),[o,l]=x.useState();x.useEffect(()=>{Pn.members().then(r,h=>l(h.message))},[]);const c=new Set(e.owners.map(h=>h.id)),d=new Set(e.value.map(h=>h.id));return o?i.jsxs("div",{className:"test-line alert",children:["✕ ",o]}):n?i.jsx("div",{className:"choice-row compact sl-members",children:n.map(h=>i.jsx(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 Fw(e){const{s:n,patch:r}=e,[o,l]=x.useState(!1),c=new Set(n.notify.events),d=o||n.notify.target!=="dm",h=n.owners[0],g=m=>{const v=c.has(m)?n.notify.events.filter(k=>k!==m):[...n.notify.events,m];r({notify:{events:v}})};return i.jsxs("div",{className:"sl-groups",children:[i.jsxs("div",{className:"sl-group",children:[i.jsx(Ke,{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 Pn.resetOwner().then(e.set,()=>{}),children:"Not you? Reset"})]})]}),i.jsxs("div",{className:"sl-group",children:[i.jsx(Ke,{variant:"plain",size:"sm",children:"Allowed users"}),i.jsx(zw,{value:n.allow,owners:n.owners,onChange:m=>r({allow:m})})]}),i.jsxs("div",{className:"sl-group",children:[i.jsx(Ke,{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:n.notify.target!=="dm"?n.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(Bw,{value:n.notify.target,onSave:m=>r({notify:{target:m}})})}),i.jsxs("div",{className:"choice-row compact",children:[i.jsx(ht,{on:n.notify.detail==="full",title:"Full questions",onClick:()=>r({notify:{detail:"full"}})}),i.jsx(ht,{on:n.notify.detail==="titles-only",title:"Titles only",onClick:()=>r({notify:{detail:"titles-only"}})})]})]}),i.jsx("div",{className:"choice-row compact",children:Sw.map(m=>i.jsx(ht,{on:c.has(m),title:Lw[m],onClick:()=>g(m)},m))})]}),i.jsx(ko,{className:"dim",parts:[`${n.command} decide`,`${n.command} status`,`${n.command} inbox`,"Save as decision on any message"]})]})}function oo(e){return i.jsx("a",{className:`btn ${e.primary?"primary":""}`,href:e.href,target:"_blank",rel:"noreferrer",onClick:e.onClick,children:e.children})}function Uw({s:e,n}){const r=Ww(e,n);return r?i.jsx("span",{className:"t-meta",children:r}):null}function Ww(e,n){var o;if(n===3)return e.setup.appId&&`app ${e.setup.appId}`;if(n===4)return e.workspace&&`${e.workspace.name} · @${((o=e.bot)==null?void 0:o.name)??"scout"}`;const r=e.owners[0];if(n===5&&r){const l=r.via==="git-email"?" · git email":"";return`owner ${r.name??r.id}${l}`}}const ih=[{n:1,title:"Create app"},{n:2,title:"Workspace"},{n:3,title:"App token"},{n:4,title:"Install"},{n:5,title:"Claim"}],jc=(e,n)=>e===n||e===2&&n===3,Am=(e,n)=>e==="done"||typeof e=="number"&&n<e&&!jc(e,n);function rh(e,n){return Am(e,n)?"done":jc(e,n)?"cur":""}const Hw=/^(xapp-|xoxb-|xoxp-|xoxe)/,Vw=typeof navigator<"u"&&/Mac|iP(hone|ad)/.test(navigator.platform)?"⌘V":"Ctrl+V";function Kw(e){const n=x.useRef(e);n.current=e;const[r,o]=x.useState(!1);return x.useEffect(()=>{let l="";const c=(g,m)=>{const v=g.trim();return!Hw.test(v)||!m&&v===l?!1:(l=v,n.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 Gw(e){var S;const{s:n,set:r}=e,[o,l]=x.useState(),[c,d]=x.useState(!1),[h,g]=x.useState(!1),m=(E,I)=>{const O=Mw(E);I&&O&&!n.setup.botToken&&window.open(Ew.install(O),"_blank")&&g(!0),d(!0),Pn.token(E).catch(R=>({ok:!1,error:R.message,status:n})).then(R=>{d(!1),l(R),r(R.status)})},k=Kw(m)?"come back to this tab":`press ${Vw} here`,w=n.step,j=E=>{if(!o)return null;const I=!o.ok&&E===4==(w===4);return o.kind===(E===4?"bot":"app")||I?i.jsx("div",{className:`test-line ${o.ok?"ok":"alert"}`,children:qw(o)}):null},T={1:i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:["Slack opens with the Scout app filled in from a manifest: the ",n.command," command, Save as decision, and Socket Mode. Nothing is hosted by ",ge.name,"."]}),i.jsx("div",{className:"sl-actions",children:i.jsx(oo,{primary:!0,href:n.links.create,onClick:()=>void Pn.created().then(r,()=>{}),children:"Create Slack app"})})]}),2:i.jsxs("p",{children:["In Slack: pick the workspace → ",i.jsx("b",{children:"Next"})," → ",i.jsx("b",{children:"Create"}),"."]}),3:i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:["On the page Slack just opened: ",i.jsx("b",{children:"App-Level Tokens"})," → ",i.jsx("b",{children:"Generate Token and Scopes"})," → name it"," ",i.jsx("code",{children:"teamtrail"})," → add ",i.jsx("code",{children:"connections:write"})," → ",i.jsx("b",{children:"Generate"})," → ",i.jsx("b",{children:"Copy"}),", then ",k,"."]}),i.jsx("div",{className:"sl-actions",children:i.jsx(Zl,{busy:c,placeholder:"xapp-…",onToken:m})}),j(3),i.jsx(ko,{className:"dim",parts:["Waiting for the app-level token",n.links.create&&i.jsx("a",{href:n.links.create,target:"_blank",rel:"noreferrer",children:"Open the manifest again"},"again")]})]}),4:i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:[h?"Slack's install page is open in a new tab: ":i.jsxs(i.Fragment,{children:[i.jsx("b",{children:"Install to workspace"})," →"," "]}),i.jsx("b",{children:"Allow"})," → copy the ",i.jsx("b",{children:"Bot User OAuth Token"})," (starts with ",i.jsx("code",{children:"xoxb-"}),"), then ",k,"."]}),i.jsxs("div",{className:"sl-actions",children:[i.jsx(oo,{primary:!h,href:n.links.install,children:h?"Open install page again":"Install to workspace"}),i.jsx(Zl,{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=n.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(oo,{primary:!0,href:n.links.home,children:"Open Scout in Slack"}),n.links.homeWeb&&i.jsx(oo,{href:n.links.homeWeb,children:"Open in browser"})]}),i.jsx(Im,{s:n})]})};return i.jsxs(Rt,{tone:"inset",className:"slack-setup",children:[i.jsx("ol",{className:"pipeline sl-pipeline","aria-label":"Slack setup",children:ih.map(E=>i.jsxs("li",{className:rh(w,E.n),children:[i.jsx("i",{}),i.jsxs("span",{children:[E.n," ",E.title]})]},E.n))}),i.jsx("ol",{className:"sl-steps",children:ih.map(E=>{const I=Am(w,E.n),O=jc(w,E.n);return i.jsxs("li",{className:rh(w,E.n),children:[i.jsxs("div",{className:"sl-step-h",children:[i.jsx("span",{className:"sl-n",children:I?"✓":E.n}),i.jsx("b",{children:E.title}),I&&i.jsx(Uw,{s:n,n:E.n})]}),O&&i.jsx("div",{className:"sl-step-b",children:T[E.n]})]},E.n)})})]})}function qw(e){var n,r;return e.ok?e.kind==="app"?`✓ Socket Mode reachable · app ${e.status.setup.appId}`:`✓ Installed in ${(n=e.status.workspace)==null?void 0:n.name} as @${((r=e.status.bot)==null?void 0:r.name)??"scout"}`:`✕ ${e.error}`}function Sc(e=0){const[n,r]=x.useState(),o=x.useCallback(()=>Pn.get().then(r,()=>r(null)),[]);return x.useEffect(()=>{if(o(),!e)return;const l=setInterval(()=>void o(),e);return()=>clearInterval(l)},[o,e]),[n,r]}function Qw(e){const[n,r]=Sc(3e3),[o,l]=x.useState(!1),c=x.useRef(null);if(x.useEffect(()=>{var g;e.focus&&n&&((g=c.current)==null||g.scrollIntoView({block:"start"}))},[e.focus,!!n]),!n)return null;const d=n.step==="done",h=g=>Pn.update(g).then(r,()=>{});return i.jsxs("div",{ref:c,className:"slack-settings",children:[i.jsx(_w,{s:n,setup:o,onSetup:l,onToggle:()=>void h({enabled:!n.enabled}),onRemoved:g=>{r(g),l(!1)}}),!d&&(o||n.step!==1)&&i.jsx(Gw,{s:n,set:r}),o&&d&&n.state==="auth-error"&&i.jsxs(Rt,{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(Aw,{set:r})]}),d&&i.jsx(Fw,{s:n,set:r,patch:g=>void h(g)})]})}function Yw(e){const{api:n,rt:r,brief:o}=e,{snap:l,actions:c}=n,[d]=Sc(15e3),h=Ws(),g=d!=null&&d.enabled&&d.state==="auth-error"?d.error??"Slack rejected the tokens":void 0;return i.jsx(gw,{repo:e.repo,snaps:n.allSnaps,map:l==null?void 0:l.map,activity:n.activity,health:n.health,onNewTrail:e.onNewTrail,trackerLabel:r.adapter.label.toLowerCase(),onSelectMap:c.selectMap,onToggleMode:()=>l&&c.setMode(l.map.mode==="plan-only"?"plan+execute":"plan-only"),onSettings:e.onSettings,onToggleTheme:e.onToggleTheme,attention:e.attention,slackAlert:g,onSlack:e.onSlack,decisions:n.decisions.length,decisionsOpen:e.decisionsOpen,onDecisions:e.onDecisions,onStats:e.onStats,knowledge:h.attention,knowledgeOpen:h.open,onKnowledge:()=>h.setOpen(!h.open),briefingOpen:o.shown,briefingStatus:o.status,onBriefing:()=>o.shown?o.dismiss():o.open()})}function Jw(e){const{m:n}=e,r=n.from==="human"?"human":"agent";return i.jsxs("div",{className:`msg from-${n.from} voice-${r}`,children:[i.jsx(ee,{parts:[n.author,hc(n.at)]}),i.jsx("div",{className:"msg-text",children:n.text}),e.stillOpen&&i.jsx("button",{className:"answer-this t-meta",onClick:e.onAnswerThis,children:"Answer this"})]})}function Xw(e){const{ticket:n}=e;return i.jsxs("div",{className:"comms-ticket",children:[i.jsxs("div",{className:"t-title",title:n&&`${n.key} ${n.title}`,children:[i.jsx("span",{className:"key",children:n==null?void 0:n.key})," ",n==null?void 0:n.title]}),i.jsx(ee,{parts:[e.trail,e.agent]})]})}function Zw({id:e,text:n}){const[r,o]=x.useState(),l=r!==e;return i.jsx(Oo,{size:1,framed:!1,state:l?"speaking":"alert",speaking:l?n.slice(0,60):void 0,onSpeakEnd:()=>o(e),className:"q-avatar"})}function ej(e){const{q:n}=e;return i.jsxs("div",{className:"msg open-q",children:[i.jsx(ee,{parts:[n.agent,hc(n.at)]}),i.jsx(Zw,{id:e.chatId??n.id,text:n.text}),i.jsx("div",{className:"msg-text",children:n.text})]})}function tj(e){var n;return(n=e.options)!=null&&n.length?i.jsx("div",{className:"suggest",children:e.options.map(r=>i.jsx("button",{className:"chip",onClick:()=>e.onPick(r),children:r},r))}):null}function nj(e){const{activity:n,sessionId:r}=e,[o,l]=x.useState(""),[c,d]=x.useState(),h=x.useRef(null),g=x.useRef(null),m=n.sessions.find(R=>R.id===r),v=n.chats.filter(R=>R.sessionId===r),k=_x(n.pending,r,c??e.questionId),w=new Set(n.pending.filter(R=>R.sessionId===r).map(R=>R.id)),j=v.find(R=>!!k&&R.questionId===k.id),T=v.filter(R=>R!==j),S=m?e.snaps[m.mapId]:void 0,E=m!=null&&m.ticketId?S==null?void 0:S.tickets.find(R=>R.id===m.ticketId):void 0;x.useEffect(()=>{const R=h.current;R==null||R.scrollTo({top:R.scrollHeight,behavior:"smooth"})},[T.length,k==null?void 0:k.id]),x.useEffect(()=>{var R;k&&!e.onBack&&((R=g.current)==null||R.focus({preventScroll:!0}))},[k==null?void 0:k.id,e.onBack]);const I=R=>{!k||!R.trim()||(e.onAnswer(k.id,R.trim()),l(""))},O=sj(m,!!k);return i.jsxs("div",{className:`comms ${k?"asking":""}`,children:[i.jsx(bt,{title:"HITL line",right:m?i.jsx("span",{className:`status ${k?"urgent":""}`,children:O}):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(Xw,{ticket:E,trail:S==null?void 0:S.map.title,agent:m.agent}),i.jsx("div",{className:"comms-log",ref:h,children:T.map(R=>i.jsx(Jw,{m:R,stillOpen:!!R.questionId&&w.has(R.questionId),onAnswerThis:()=>d(R.questionId)},R.id))}),k&&i.jsx(ej,{q:k,chatId:j==null?void 0:j.id}),i.jsx(tj,{options:k==null?void 0:k.suggestions,onPick:I}),i.jsx(yc,{ref:g,className:"comms-input",value:o,onValueChange:l,onSubmit:I,disabled:!k,placeholder:k?"Answer":""})]}):i.jsx(Ie,{children:"No conversation"})]})}function sj(e,n){return e?n?"Your answer is needed":Zt(e)?`${e.agent} is working…`:e.status==="done"?"Resolved · ticket closed":"Session ended":""}async function ij(e){const[n,r]=e.ref.split("+"),o=await fetch(`${Ne()}/workspaces/integration`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e.mapId,a:n,b:r})});return o.ok?void 0:(await o.json().catch(()=>({}))).error??`Adding failed (${o.status})`}function rj({item:e}){const[n,r]=x.useState(!1),[o,l]=x.useState(),c=()=>{r(!0),l(void 0),ij(e).then(l,d=>l(d.message)).finally(()=>r(!1))};return i.jsxs("div",{className:"att-action",children:[i.jsx(K,{size:"sm",className:"integration-add",disabled:n,onClick:c,children:n?"Adding…":"Add integration ticket"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}const oj=/(\S*\/\S*|#\d+)/g;function aj({reasons:e}){return e.length?i.jsx("span",{className:"reason-line",children:e.map((n,r)=>i.jsxs("span",{children:[r>0&&i.jsx("span",{className:"sep",children:" · "}),n.split(oj).map((o,l)=>l%2===1?i.jsx("span",{className:"t-code",children:o},l):o)]},n))}):null}const Rm={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"},lj={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"},cj=[{minutes:30,label:"30 min"},{minutes:120,label:"2 hours"},{minutes:1440,label:"Tomorrow"}],uj=["blocked","flag","stalled","policy","reroute","overlap","integration","model"];function Lm(e,n){return n||e.urgency==="blocking"?"urgent":uj.includes(e.kind)?"attention":"neutral"}const dj=[/^marked blocking$/,/^fyi\b/,/^soon\b/,/^waiting \d/,/^answer together/,/questions from /];function Om(e){return e.reasons.filter(n=>!dj.some(r=>r.test(n)))}function fj(e){const{item:n,snap:r}=e,o=r==null?void 0:r.tickets.find(h=>h.id===n.ticketId),l=n.kind==="question"&&n.agent?`${n.agent} asks`:Rm[n.kind],c=[];n.urgency==="blocking"&&c.push({text:"Blocking",urgent:!0,className:"urgency-tag"}),c.push({text:l,strong:!0});const d=o&&hj(n.title,o);return d&&c.push(d),e.otherTrail&&c.push((r==null?void 0:r.map.title)??n.mapId),c}function hj(e,n){if(!e.includes(n.key))return e.includes(n.title)?{text:n.key,code:!0}:`${n.key} ${n.title}`}function mj(e){const[n,r]=x.useState(!1),o=l=>{r(!1),l()};return i.jsxs("span",{className:"snooze",children:[i.jsx("button",{type:"button",className:"snooze-btn","aria-expanded":n,"aria-label":`Later: ${e.title}`,onClick:()=>r(!n),children:"Later"}),n&&i.jsxs("span",{className:"snooze-menu",role:"menu",children:[cj.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 gj(e){const{item:n}=e,r=n.title.split(`
124
+ `)[0],o=Om(n),l=e.now-n.since<pj;return i.jsx(Re,{as:"li",className:`att-item k-${n.kind} u-${n.urgency} ${e.selected?"sel":""} ${l?"incoming":""}`,edge:Lm(n,e.interrupting),selected:e.selected,title:r,titleText:n.title,context:i.jsx(ee,{parts:fj({item:n,snap:e.snap,otherTrail:e.otherTrail})}),detail:o.length>0&&i.jsx(aj,{reasons:o}),detailText:o.join(`
125
+ `),trailing:en(e.now-n.since),onOpen:e.onOpen,actions:i.jsx(mj,{title:n.title,canDismiss:yk(n),onSnooze:e.onSnooze,onDismiss:e.onDismiss}),below:n.kind==="integration"&&i.jsx(rj,{item:n})})}function vj(e){const n=[];for(const r of e){const o=n.at(-1);(o==null?void 0:o.key)===r.batchKey?o.items.push(r):n.push({key:r.batchKey,kind:r.kind,mapId:r.mapId,items:[r]})}return n}const yj={question:"inbox-list",approval:"inbox-list approvals"};function kj(e){const{batch:n}=e,r=n.items.length>1,o=n.kind==="question"?"answer together":"review together",l=[`${n.items.length} ${lj[n.kind]}`,e.trail,o].filter(Boolean);return i.jsxs("div",{className:`att-batch ${r?"many":""}`,children:[r&&i.jsx("span",{className:"batch-head t-label",children:l.join(" · ")}),i.jsx("ul",{className:`att-list ${yj[n.kind]??""}`,children:e.children})]})}function xj(e,n){e.ticketId?n.openTicket(e.mapId,e.ticketId):n.selectTrail(e.mapId)}function _m(e,n){switch(e.kind){case"question":return n.openQuestion(e.ref);case"approval":case"blocked":case"policy":case"flag":case"stalled":case"hitl-ready":case"overlap":case"integration":case"model":return xj(e,n);case"knowledge":return n.openKnowledge();case"brief":return n.openBrief(e.mapId);case"reroute":case"reroute-suggested":return n.openReroute(e);case"guide":case"guide-checks":return n.openGuides();default:return e.kind}}function wj(e){const n=tn(1e3),{view:r}=e;if(!r.items.length)return i.jsx(_n,{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:vj(r.items).map(h=>{var g;return i.jsx(kj,{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(gj,{item:m,snap:e.snaps[m.mapId],otherTrail:l(m.mapId)&&h.items.length<2,selected:m.kind==="question"&&d(m.ref)===e.selected,interrupting:c.has(m.id),now:n,onOpen:()=>_m(m,e.handlers),onSnooze:v=>e.onSnooze(m.id,v),onDismiss:()=>e.onDismiss(m.id)},m.id))},h.key)})})}const jj=60*6e4;function Sj(e){const{view:n}=e,r=(n.prefs.focusUntil??0)>Date.now(),o=n.interrupting.length,l=n.focused?"Focus is on: nothing interrupts you. Everything still waits in Waiting on you. Click to end focus.":"Focus for an hour: nothing interrupts you, everything still waits in Waiting on you.";return i.jsxs("span",{className:"attention-head",children:[i.jsx(K,{variant:"ghost",className:"focus-btn",on:n.focused,"aria-pressed":n.focused,"data-tip":l,onClick:()=>e.onFocus(r?void 0:Date.now()+jj),children:"Focus"}),o>0&&i.jsxs("span",{className:"waiting-chip interrupting",title:`${o} need you now`,children:[i.jsx(Us,{variant:"alert",size:14}),i.jsx("b",{children:o}),i.jsx("span",{className:"wl",children:" need you now"})]})]})}const Pm=`${Ne()}/attention`,Nj=250;async function oh(e,n,r){var c;const o=await fetch(`${Pm}${e}`,{method:n,headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),l=await o.json().catch(()=>({}));if(!o.ok)throw new Error(((c=l.errors)==null?void 0:c.join("; "))??l.error??`HTTP ${o.status}`);return l}function Dm(e){const[n,r]=x.useState(),[o,l]=x.useState(),c=x.useCallback(()=>{fetch(Pm).then(h=>h.ok?h.json():void 0).then(h=>h&&r(h)).catch(()=>{})},[]);x.useEffect(()=>Do("attention",h=>r(JSON.parse(h))),[]),x.useEffect(()=>{const h=setTimeout(c,Nj);return()=>clearTimeout(h)},[c,e]);const d=(h,g)=>void oh(h,"POST",g).then(()=>(l(void 0),c()),m=>l(m.message));return{view:n,error:o,snooze:(h,g)=>d("/snooze",{id:h,minutes:g}),dismiss:h=>d("/dismiss",{id:h}),savePrefs:h=>oh("/prefs","PUT",h).then(()=>(l(void 0),c(),!0),g=>(l(g.message),!1))}}function bj(e){return e.prefs.channel!=="browser"?!1:typeof Notification<"u"&&Notification.permission==="granted"}function Cj(e){const n=new Notification(`${ge.name} · needs you`,{body:e.title,tag:e.id});n.onclick=()=>{window.focus(),n.close()}}function $j(e){const n=x.useRef();x.useEffect(()=>{if(!e)return;const r=new Set(e.interrupting),o=n.current;if(n.current=r,!(!o||!bj(e)))for(const l of e.items)r.has(l.id)&&!o.has(l.id)&&Cj(l)},[e])}function Tj(e){const n=tn(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(Re,{as:"li",edge:o?"attention":"neutral",title:`${o?"Decide":"Approve"}: ${r.title}`,context:i.jsx(ee,{parts:[o?"Held":"Verified",{text:r.ticketKey,code:!0},l]}),detail:r.reason,detailText:r.reason,trailing:en(n-r.at),onOpen:()=>e.onOpen(r.mapId,r.ticketId)},`${r.mapId}/${r.ticketId}`)})}):null}function ah({activity:e}){const n=tn(1e3),r=Ny(e);return i.jsxs("div",{className:"hitl-readout",children:[i.jsx(Jt,{layout:"inline",label:"Oldest",value:r.oldestAt?Ut(n-r.oldestAt):"—",urgent:!!r.oldestAt&&n-r.oldestAt>6e4,title:"Oldest open question"}),i.jsx(Jt,{layout:"inline",label:"Avg wait",value:r.avgWaitMs!==void 0?Ut(r.avgWaitMs):"—",title:`Average wait over ${r.answered} answered questions`}),i.jsx(Jt,{layout:"inline",label:"Answered",value:r.answered})]})}function Ej(e){const n=tn(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(Re,{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(ee,{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:en(n-r.at),onOpen:()=>e.onOpen(r.sessionId,r.ticketId)},r.id)})}):i.jsx(_n,{title:"Nothing waiting on you",hint:"When an agent needs your call, its question lands here."})}const Mj={pass:"Passed",fail:"Failed",error:"Could not run",interrupted:"Interrupted"},Bi={off:"Off",checks:"Checks","checks+review":"Checks + review","checks+review+human":"Checks + review + you"},Bm={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."},Ij=e=>e.exitCode===0&&!e.timedOut&&!e.error;async function lh(e){const n=await e.json().catch(()=>({}));if(!e.ok)throw new Error(n.error??`HTTP ${e.status}`);return n}const ao=`${Ne()}/verification`,Vi={ticket:(e,n)=>fetch(`${ao}/ticket?mapId=${encodeURIComponent(e)}&ticketId=${encodeURIComponent(n)}`).then(r=>r.ok?r.json():void 0,()=>{}),inbox:()=>fetch(`${ao}/inbox`).then(e=>e.ok?e.json().then(n=>n.items):[],()=>[]),log:e=>fetch(`${ao}/log?path=${encodeURIComponent(e)}`).then(n=>lh(n)),act:e=>fetch(`${ao}/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(n=>lh(n))};function Aj(e){const[n,r]=x.useState([]),o=Object.values(e).map(l=>l.tickets.map(c=>`${c.id}:${c.state}:${c.status??""}`).join()).join("|");return x.useEffect(()=>{let l=!0;const c=()=>void Vi.inbox().then(h=>l&&r(h));c();const d=Bs.onEvidence(c);return()=>{l=!1,d()}},[o]),n}function Rj(e,n){return{...e,items:e.items.filter(r=>!(r.kind==="brief"&&r.mapId===n))}}function Lj(e){var h;const n=[...e.activity.pending].sort((g,m)=>g.at-m.at),r=Aj(e.snaps),o=(h=e.attention)==null?void 0:h.view,l=o&&e.briefShown?Rj(o,e.currentMapId):o,c=l?l.items.length:n.length+r.length,d=i.jsx(bt,{hot:c>0,title:i.jsxs(i.Fragment,{children:[c>0&&i.jsx(Us,{variant:"alert",size:12}),"Waiting on you"]}),count:i.jsx(Zn,{n:c,urgent:c>0,pop:!0},c)});return l&&e.attention&&e.handlers?i.jsxs("div",{className:"inbox-part",children:[d,i.jsx(ah,{activity:e.activity}),i.jsx(wj,{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(ah,{activity:e.activity}),i.jsx(Tj,{items:r,snaps:e.snaps,currentMapId:e.currentMapId,onOpen:e.onOpenTicket}),(n.length>0||!r.length)&&i.jsx(Ej,{items:n,snaps:e.snaps,currentMapId:e.currentMapId,selected:e.sessionId,onOpen:e.onOpenQuestion})]})}function Oj(e){const[n,r]=x.useState("list"),[o,l]=x.useState();x.useEffect(()=>{e.convRequest&&r("conv")},[e.convRequest]);const c=(v,k)=>{e.onOpen(v,k),r("conv")},d=v=>{const k=e.activity.pending.find(w=>w.id===v);k&&(l(k.id),c(k.sessionId,k.ticketId))},h=i.jsx(Lj,{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(nj,{activity:e.activity,snaps:e.snaps,sessionId:e.sessionId,questionId:o,onAnswer:e.onAnswer,onBack:e.layout==="stack"?()=>r("list"):void 0});if(e.layout==="stack")return i.jsx(We,{className:"zone inbox stack",children:n==="conv"&&e.sessionId?g:i.jsxs("div",{className:"stack-scroll",children:[e.above,h,e.below]})});const m=!!e.activity.sessions.find(v=>v.id===e.sessionId);return i.jsxs(We,{className:`zone inbox split ${m?"has-conv":""}`,style:{gridArea:"inbox"},children:[i.jsx(bt,{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 _j(e){var h;const{snap:n}=e,r=n?Fs(n.tickets,n.map.mode):new Map,o={claimed:0,frontier:1},l=((n==null?void 0:n.tickets)??[]).filter(g=>o[r.get(g.id)]!==void 0).sort((g,m)=>o[r.get(g.id)]-o[r.get(m.id)]),c=new Set(e.sessions.filter(Sm).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(bt,{title:"Up next",count:i.jsx("span",{className:"n mono-label",children:l.length})}),!n&&i.jsx(Ie,{children:"Ready tickets show here"}),n&&!l.length&&i.jsx(Ie,{children:"Nothing ready"}),n&&l.length>0&&i.jsx("ul",{className:"ticket-list",children:l.map(g=>{const m=r.get(g.id),v=Pj({state:m,waiting:c.has(g.id),assignee:g.assignee,hitl:Fi(g)==="hitl"});return i.jsx("li",{className:`${d===g.id?"sel":""} st-${c.has(g.id)?"waiting":m}`,children:i.jsxs("button",{onClick:()=>e.onSelect({kind:"ticket",id:g.id}),children:[i.jsx("i",{className:"dot"}),i.jsx("span",{className:"key t-code",children:g.key}),i.jsx("span",{className:"ttl t-body",children:g.title}),i.jsx("span",{className:"st-text t-meta",children:v})]})},g.id)})})]})}function Pj(e){if(e.waiting)return"waiting on you";if(e.state==="claimed")return e.assignee??"claimed";const n=ym[e.state].toLowerCase();return e.hitl?`${n}, needs you`:n}function Dj(e){const{api:n,nav:r}=e;return i.jsx(Oj,{activity:n.activity,snaps:n.allSnaps,currentMapId:n.mapId,sessionId:n.chatSession,layout:e.bp==="mobile"?"stack":"split",convRequest:r.convRequest,onOpen:r.openChat,onAnswer:n.actions.answer,onOpenTicket:r.openTicket,attention:e.attn.attention,handlers:e.attn.handlers,below:i.jsx(_j,{snap:n.snap,sessions:e.scoped.sessions,selection:n.selection,onSelect:r.select}),above:e.above})}function xo({command:e,label:n="Copy"}){const[r,o]=x.useState(!1);return i.jsxs("span",{className:"agent-cmd",children:[i.jsx("code",{children:e}),i.jsx("button",{type:"button",className:"btn sm","data-tip":"Copy, then paste it in Claude Code or Codex",onClick:()=>void navigator.clipboard.writeText(e).then(()=>{o(!0),setTimeout(()=>o(!1),1500)}),children:r?"Copied":n})]})}const lo=[{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"}],Bj=9e3;function zj(){const[e,n]=x.useState(0),[r,o]=x.useState(!1);x.useEffect(()=>{if(r)return;const c=setInterval(()=>n(d=>(d+1)%lo.length),Bj);return()=>clearInterval(c)},[r]);const l=lo[e];return i.jsxs("div",{className:"command-bar real",children:[i.jsx(bm,{name:"map"}),i.jsx(Ke,{as:"h2",className:"zone-title-label",children:"Trail map"}),i.jsx(Hi,{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:()=>n(c=>(c+1)%lo.length),children:[e+1,"/",lo.length," ›"]})]})}function Fj(e){const n=[{v:"plan+execute",title:"Plan + execute"},{v:"plan-only",title:"Plan only"}];return i.jsx("div",{className:"choice-row",children:n.map(r=>i.jsx(ht,{on:e.value===r.v,title:r.title,onClick:()=>e.onChange(r.v)},r.v))})}function Uj({onClose:e,tracker:n,onCreate:r}){const[o,l]=x.useState(),[c,d]=x.useState(!1),[h,g]=x.useState(),[m,v]=x.useState(""),[k,w]=x.useState(""),[j,T]=x.useState(""),[S,E]=x.useState(""),I=[m.trim(),k.trim(),j.trim()].filter(Boolean).join(". ").replace(/"/g,"'");return x.useEffect(()=>{const O=R=>R.key==="Escape"&&e();return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[e]),i.jsx("div",{className:"scrim",onClick:e,children:i.jsxs(We,{as:"div",className:"dialog",onClick:O=>O.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:O=>v(O.target.value),autoFocus:!0})}),i.jsx(Ye,{label:"Destination",children:i.jsx("textarea",{rows:3,value:k,onChange:O=>w(O.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:O=>T(O.target.value)})}),i.jsx(Ye,{label:"Assumptions (optional, one per line)",children:i.jsx("textarea",{className:"new-trail-assumptions",rows:2,value:S,onChange:O=>E(O.target.value),placeholder:"What the plan takes for granted, e.g. The v2 API supports batch writes"})}),i.jsxs("div",{className:"agent-draft",children:[i.jsxs("span",{className:"dim",children:["Paste this in Claude Code or Codex. Scout frames the trail with you there, then charts it here in ",n,"."]}),i.jsx(xo,{command:`/scout new "${I||"your idea"}"`,label:"Copy command"})]}),o?i.jsxs("div",{className:"agent-draft created",children:[i.jsxs("span",{children:["Trail ",o," is on the map, starting with discovery. To get it moving, run this in Claude Code or Codex:"]}),i.jsx(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()||!k.trim(),"data-tip":"Put the trail on the map now; any agent picks it up with /scout resume",onClick:()=>{d(!0);const O=S.split(`
127
+ `).map(R=>R.trim());r({title:m.trim(),destination:k.trim(),notes:j.trim(),assumptions:O.filter(Boolean)}).then(R=>l(R.key)).catch(R=>g(R.message)).finally(()=>d(!1))},children:"Create trail"})]})]})})}const ch=["Ready when you are","What's the next big idea?","I keep the party on the trail","Describe it, I frame it"],Wj=5e3;function Hj(){const e=kc(),[n,r]=x.useState(0),[o,l]=x.useState(!0);return x.useEffect(()=>{if(o)return;const c=setTimeout(()=>{r(d=>(d+1)%ch.length),l(!0)},Wj);return()=>clearTimeout(c)},[o]),i.jsxs("div",{className:"floating-scout","aria-hidden":"true",children:[i.jsx(Oo,{variant:e?"night":"crt",size:3,framed:!1,speaking:o?ch[n]:void 0,onSpeakEnd:()=>l(!1),className:"fm-avatar"}),i.jsx("span",{className:"fm-shadow"})]})}function Vj(e){return i.jsx(Uj,{onClose:e.onClose,tracker:e.rt.adapter.label,onCreate:async n=>{const r=await Nx(e.rt.adapter,n);return e.onCreated(r.id),r}})}const Kj={gh:"your gh login",GITHUB_TOKEN:"GITHUB_TOKEN",GH_TOKEN:"GH_TOKEN",stored:"a saved token",LINEAR_API_KEY:"LINEAR_API_KEY"},Nc=e=>Kj[e];function bc(e){var n;return((n=e.account)==null?void 0:n.kind)==="user"?e.account.login:void 0}const Gj=e=>!!e.auth&&!!bc(e);function zm(e,n){const r=bc(e);return!e.auth||!r?void 0:`Will use ${n||"the repo you pick"} as ${r} (${Nc(e.auth)})`}function qj(e){if(!e.repo)return;const n=bc(e),r=n?` as ${n}`:"",o=e.auth?`, using ${Nc(e.auth)}`:"";return`Connected to ${e.repo}${r}${o}`}function Qj(e,n){if(!e.pushedAt)return;const r=Math.floor((n-Date.parse(e.pushedAt))/864e5);return r<1?"Pushed today":r<60?`Pushed ${r}d ago`:`Pushed ${Math.floor(r/30)}mo ago`}function Yj(e){const{gh:n}=e;if(!n.auth)return null;const r=zm(n,e.repo);return i.jsxs("div",{className:"gh-identity",children:[r&&i.jsx("span",{className:"t-body",children:r}),i.jsx("button",{type:"button",className:"btn ghost sm",onClick:e.onUseAnother,children:"Use another token"})]})}const Jj=/^[\w.-]+\/[\w.-]+$/;function Xj(e){const n=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=n?l.filter(g=>g.fullName.toLowerCase().includes(n)):l,h=Jj.test(e.query.trim())&&c.every(g=>g.fullName.toLowerCase()!==n)?e.query.trim():void 0;return{shown:c.slice(0,e.limit),matches:c.length,typed:h}}function uh(e){const{repo:n,listed:r}=e,o=n.private?"Private":"Public";return i.jsx(Re,{as:"li",className:"repo-row",selected:e.selected,title:i.jsx("span",{className:"t-code",children:n.fullName}),context:i.jsx(ee,{parts:[e.detected&&{text:"This project's repo",strong:!0},r&&o,r&&Qj(n,e.now),!r&&"Checked when you connect"]}),onOpen:e.onPick})}const Zj=40;function dh(e){const[n,r]=x.useState(""),o=x.useMemo(()=>Date.now(),[]),l=x.useMemo(()=>new Set(e.repos.map(v=>v.fullName)),[e.repos]),{shown:c,matches:d,typed:h}=Xj({repos:e.repos,detected:e.detected,query:n,limit:Zj}),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:n,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(uh,{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(uh,{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(ee,{parts:[!d&&!h&&"No repo matches",g,m]})]})}function e0(e){const{list:n}=e;if(!n)return i.jsx(ee,{parts:["Loading your repos…"]});switch(n.kind){case"ok":return i.jsx(dh,{repos:n.repos,truncated:n.truncated,detected:n.detectedRepo??e.detected,value:e.value,onChange:e.onChange});case"no-token":return i.jsx(ee,{parts:["No GitHub token found"]});case"error":return i.jsxs(i.Fragment,{children:[i.jsx(ee,{parts:["Couldn't list your repos",n.error]}),i.jsx(dh,{repos:[],truncated:!1,detected:e.detected,value:e.value,onChange:e.onChange})]});default:return n}}const t0={stored:"Saved token",gh:"gh CLI",GITHUB_TOKEN:"$GITHUB_TOKEN",GH_TOKEN:"$GH_TOKEN",LINEAR_API_KEY:"$LINEAR_API_KEY"},Li=e=>e==="github"||e==="linear";function Fm(e){const[n,r]=x.useState(!e.source);return e.source&&!n?i.jsxs("div",{className:"ts-auth",children:[i.jsx("span",{className:"mono-label",children:e.label}),i.jsx("span",{className:"pill on",children:t0[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 n0(e){var l,c;const{gh:n}=e,r=n.auth&&((l=n.account)==null?void 0:l.kind)==="unknown"?`Found ${Nc(n.auth)}, but GitHub didn't accept it`:"",o=((c=n.account)==null?void 0:c.kind)==="unknown"?n.account.error:"";return i.jsxs(i.Fragment,{children:[r&&i.jsx(ee,{parts:[r,o]}),i.jsx(Fm,{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:d=>e.onRepo(d.target.value.trim())})]})]})}function Um({r:e}){var o,l;if(!e)return null;if(!e.ok)return i.jsxs("div",{className:"test-line alert",children:["✕ ",e.error]});const n=(o=e.rate)!=null&&o.limit?`${(l=e.rate.remaining)==null?void 0:l.toLocaleString()}/${e.rate.limit.toLocaleString()} req`:"";let r="";return e.canWrite===!1?r="read-only":e.canWrite&&(r="read/write"),i.jsxs("div",{className:"test-line ok",children:["✓ ",[e.account,e.target,r,n].filter(Boolean).join(" · ")]})}const es=Dk(Ne());function Oi(e,n){e({tracker:n});const r=new URL(location.href);r.searchParams.delete("tracker"),location.href=r.toString()}function s0(e){const[n,r]=x.useState();return x.useEffect(()=>{if(!e)return;let o=!0;return es.githubRepos().then(l=>o&&r(l),l=>o&&r({kind:"error",error:l.message})),()=>{o=!1}},[e]),n}function Wm(e){const n=e.s.github,r=Gj(n),[o,l]=x.useState(!r),[c,d]=x.useState(n.repo??n.detectedRepo??""),[h,g]=x.useState(""),[m,v]=x.useState(),[k,w]=x.useState(!1),j=s0(!o);x.useEffect(()=>{r&&!h&&l(!1)},[r]);const T=async()=>{w(!0),v(void 0);try{await es.connect({active:"github",github:{repo:c,token:o?h:void 0}}),e.onConnected()}catch(E){v({ok:!1,error:E.message}),w(!1)}},S=!!c&&(!o||!!h||r);return i.jsxs("div",{className:"card inset tracker-setup",children:[o?i.jsx(n0,{gh:n,token:h,onToken:g,repo:c,onRepo:d}):i.jsxs(i.Fragment,{children:[i.jsx(Yj,{gh:n,repo:c,onUseAnother:()=>l(!0)}),i.jsx(e0,{list:j,detected:n.detectedRepo,value:c,onChange:d})]}),i.jsx(Um,{r:m}),i.jsx("footer",{children:i.jsx("button",{type:"button",className:"btn primary",disabled:k||!S,onClick:()=>void T(),children:k?"Connecting…":"Connect"})})]})}function Hm(e){var O;const n=e.s.linear,[r,o]=x.useState(""),[l,c]=x.useState(n.teamId??""),[d,h]=x.useState(n.projectId??""),[g,m]=x.useState(),[v,k]=x.useState([]),[w,j]=x.useState(),T=x.useCallback(async(R=l)=>{j("test");const X=await es.test({kind:"linear",apiKey:r||void 0,teamId:R||void 0}).catch(te=>({ok:!1,error:te.message}));m(X),X.teams&&(k(X.teams),!R&&X.teams.length===1&&c(X.teams[0].id)),j(void 0)},[r,l]);x.useEffect(()=>{n.auth&&T()},[]);const S=v.find(R=>R.id===l),E=(O=g==null?void 0:g.projects)==null?void 0:O.find(R=>R.id===d),I=async()=>{if(S){j("connect");try{await es.connect({active:"linear",linear:{teamId:S.id,teamKey:S.key,teamName:S.name,projectId:E==null?void 0:E.id,projectName:E==null?void 0:E.name,apiKey:r||void 0}}),e.onConnected()}catch(R){m({ok:!1,error:R.message}),j(void 0)}}};return i.jsxs("div",{className:"card inset tracker-setup",children:[i.jsx(Fm,{source:n.auth,value:r,onChange:o,label:"API key",placeholder:"lin_api_…",link:{href:"https://linear.app/settings/account/security",text:"New key"}}),v.length>0&&i.jsxs("div",{className:"ts-row",children:[i.jsxs("label",{className:"field",children:["Team",i.jsx(ct,{"aria-label":"Team",value:l,onChange:R=>{c(R),h(""),T(R)},options:[...l?[]:[{value:"",label:"Choose…"}],...v.map(R=>({value:R.id,label:`${R.key} · ${R.name}`}))]})]}),i.jsxs("label",{className:"field",children:["Project",i.jsx(ct,{"aria-label":"Project",value:d,onChange:h,disabled:!(g!=null&&g.projects),options:[{value:"",label:"All projects"},...((g==null?void 0:g.projects)??[]).map(R=>({value:R.id,label:R.name}))]})]})]}),i.jsx(Um,{r:g}),i.jsxs("footer",{children:[i.jsx("button",{type:"button",className:"btn",disabled:!!w||!n.auth&&!r,onClick:()=>void T(),children:w==="test"?"Testing…":"Test connection"}),i.jsx("button",{type:"button",className:"btn primary",disabled:!!w||!S,onClick:()=>void I(),children:w==="connect"?"Connecting…":"Connect"})]})]})}function i0(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 r0(e){const{id:n,active:r,s:o}=e,l=Li(n),c=n==="github"&&r&&o?qj(o.github):void 0;return c?i.jsx(ee,{className:"c-who",parts:[c]}):r&&(n==="markdown"||l)?i.jsx("div",{className:"c-loc",children:e.location}):l&&e.configured&&o?i.jsx("div",{className:"c-loc",children:o0(n,o)}):null}function o0(e,n){return e==="github"?n.github.repo:[n.linear.teamKey,n.linear.projectName].filter(Boolean).join(" · ")}function a0({status:e}){var c,d;if(!e)return null;const n=(c=e.rate)!=null&&c.limit?`${((d=e.rate.remaining)==null?void 0:d.toLocaleString())??"?"}/${e.rate.limit.toLocaleString()} req`:"",r=e.queued?` · ${e.queued} queued`:"",[o,l]=l0(e,r);return i.jsxs("div",{className:`sync-line ${o}`,title:e.error,children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:l}),n&&i.jsx("span",{className:"rate",children:n})]})}function l0(e,n){switch(e.state){case"online":return["ok",`Online · synced ${vm(e.lastSyncAt)}${n}`];case"offline":return["warn",`Offline${n}`];case"rate-limited":return["warn",`Rate limited · resumes ${Wi(e.resetAt)}${n}`];case"auth-error":return["alert",`Credentials rejected${n}`];default:return["",`Connecting${n}`]}}function c0(e){const{id:n,active:r,configured:o,s:l}=e,c=Li(n),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(r0,{id:n,active:r,configured:o,location:e.location,s:l}),c&&r&&i.jsx(a0,{status:l==null?void 0:l[n].status}),i.jsx(i0,{canSwitch:!r&&(!c||o),remote:c,usable:d,configured:o,open:e.open,onSwitch:e.onSwitch,onToggle:e.onToggle})]})}function Vm(e=0){const[n,r]=x.useState(),o=x.useCallback(()=>es.get().then(r,()=>r(null)),[]);return x.useEffect(()=>{if(o(),!e)return;const l=setInterval(()=>void o(),e);return()=>clearInterval(l)},[o,e]),[n,r,o]}function u0(e){const[n]=Vm(5e3),[r,o]=x.useState(null),l=async d=>{n&&(d==="markdown"||Li(d))&&await es.connect({active:d==="markdown"?"markdown":d,...d==="github"&&n.github.repo?{github:{repo:n.github.repo}}:{},...d==="linear"&&n.linear.teamId?{linear:{teamId:n.linear.teamId,teamKey:n.linear.teamKey,teamName:n.linear.teamName,projectId:n.linear.projectId,projectName:n.linear.projectName}}:{}}).catch(()=>{}),Oi(e.update,d)},c=x.useMemo(()=>({github:!!(n!=null&&n.github.repo),linear:!!(n!=null&&n.linear.teamId)}),[n]);return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"connectors",children:Bk.map(d=>{const h=d.id;return i.jsx(c0,{id:h,name:d.name,active:h===e.activeTracker,configured:Li(h)&&c[h],open:r===h,location:e.location,s:n,onSwitch:()=>void l(h),onToggle:()=>Li(h)&&o(r===h?null:h)},d.id)})}),n&&r==="github"&&i.jsx(Wm,{s:n,onConnected:()=>Oi(e.update,"github")}),n&&r==="linear"&&i.jsx(Hm,{s:n,onConnected:()=>Oi(e.update,"linear")})]})}function Ge(e){return i.jsxs("section",{className:"set-sec",children:[i.jsx(Ke,{as:"h4",children:e.title}),e.children]})}function Km(e){const n=[{v:"summary",title:"Summary"},{v:"full",title:"Full transcript"}];return i.jsx("div",{className:"choice-row",children:n.map(r=>i.jsx(ht,{on:e.value===r.v,title:r.title,onClick:()=>e.onChange(r.v)},r.v))})}function d0(e){const{prefs:n,update:r}=e,[o]=Vm(5e3),[l,c]=x.useState(!1),d=o==null?void 0:o.github;let h;d&&n.tracker!=="github"&&(h=zm(d,d.repo??d.detectedRepo));const g=[{id:"markdown",title:"Local markdown",sub:"Files in .teamtrail/ in this repo"},{id:"github",title:"GitHub Issues",sub:h??"Trails as labelled issues in your repo"},{id:"linear",title:"Linear",sub:"Trails and tickets in your Linear team"}],m=(o==null?void 0:o.active)===n.tracker&&n.tracker==="github",v=n.tracker==="github"&&!m||n.tracker==="linear",k=j=>{r({onboarded:!0}),Oi(r,j)},w=async()=>{c(!0),n.tracker==="markdown"&&o&&await es.connect({active:"markdown"}).catch(()=>{}),r({onboarded:!0}),n.tracker!==e.activeTracker&&Oi(r,n.tracker)};return i.jsx("div",{className:"scrim",children:i.jsxs(We,{as:"div",className:"dialog onboarding",children:[i.jsxs("div",{className:"onb-brand",children:[i.jsx(Fx,{size:64}),i.jsx($m,{as:"div",className:"onb-title"})]}),i.jsx("div",{className:"onb-cat mono-label",children:ge.category}),i.jsx("p",{className:"onb-tagline",children:ge.tagline}),i.jsxs("p",{className:"scout-line",children:[i.jsxs(Ke,{children:[i.jsx(Nm,{className:"voice-badge"})," ",ge.assistant.name]})," ","Where should your trails live?"]}),i.jsxs(Ge,{title:"Tracker",children:[i.jsx("div",{className:"choice-row",children:g.map(j=>i.jsx(ht,{on:n.tracker===j.id,title:j.title,sub:j.sub,onClick:()=>r({tracker:j.id})},j.id))}),o&&n.tracker==="github"&&!m&&i.jsx(Wm,{s:o,onConnected:()=>k("github")}),o&&n.tracker==="linear"&&i.jsx(Hm,{s:o,onConnected:()=>k("linear")})]}),i.jsx(Ge,{title:"HITL transcript",children:i.jsx(Km,{value:n.hitlTranscript,onChange:j=>r({hitlTranscript:j})})}),i.jsx("footer",{children:i.jsx(K,{variant:"primary",disabled:l||v,onClick:()=>void w(),children:"Get started"})})]})})}const zi=[{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 Gm(e){if(e===null)return null;const n=zi.find(l=>l.id===e);if(n)return{group:n.id};const r=zi.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 fh={from:"18:00",to:"09:00"};function f0(e){const n=e.focus!==void 0,r=e.focus??fh;return i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Quiet hours"}),i.jsx(K,{size:"sm",on:n,"aria-pressed":n,onClick:()=>e.onChange(n?void 0:fh),children:n?"On":"Off"}),n&&i.jsxs(i.Fragment,{children:[i.jsx("input",{type:"time","aria-label":"Quiet from",value:r.from,onChange:o=>o.target.value&&e.onChange({...r,from:o.target.value})}),i.jsx("span",{className:"t-meta",children:"to"}),i.jsx("input",{type:"time","aria-label":"Quiet until",value:r.to,onChange:o=>o.target.value&&e.onChange({...r,to:o.target.value})})]})]})}const h0=[{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 m0(){typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()}function p0(){const{view:e,error:n,savePrefs:r}=Dm(0);if(!e)return null;const o=e.policy.value,l=`${ge.dataDir}/attention.json`,c=h=>void r({...e.prefs,...h}),d=typeof Notification<"u"&&Notification.permission==="denied";return i.jsxs(Ge,{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(ct,{compact:!0,"aria-label":"Interrupt me by",value:e.prefs.channel,options:h0,onChange:h=>{h==="browser"&&m0(),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(f0,{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(ee,{className:"set-hint",parts:[e.policy.exists?{text:l,code:!0}:"Team defaults",`interrupt at ${o.interrupt}`,o.digestMinutes?`Slack digest every ${o.digestMinutes} min`:"Slack digest off"]}),n&&i.jsx("span",{className:"vf-err",children:n})]})}const g0=[5,15,30,60];function v0(e){const{value:n}=e;return i.jsxs("div",{className:"choice-row compact",children:[i.jsx(ht,{on:!n.enabled,title:"Off",onClick:()=>e.onChange({...n,enabled:!1})}),g0.map(r=>i.jsx(ht,{on:n.enabled&&n.awayMinutes===r,title:`Away ${r} min`,onClick:()=>e.onChange({enabled:!0,awayMinutes:r})},r))]})}const y0={repo:"Committed to the repo",machine:"Only on this machine",browser:"Only in this browser"};function it(e){const n=e.storage&&y0[e.storage];return i.jsxs("div",{className:"sp-slot",id:`settings-${e.id}`,children:[e.children,n&&i.jsx(ee,{className:"sp-where",parts:[n]})]})}function k0(e){const[n]=Sc();return n?i.jsx(Ge,{title:"Slack",children:i.jsx(Qw,{focus:e.focus})}):null}function x0({data:e,route:n}){return i.jsxs(i.Fragment,{children:[i.jsx(it,{id:"attention",storage:"repo",children:i.jsx(p0,{})}),i.jsx(it,{id:"slack",storage:"machine",children:i.jsx(k0,{focus:n.section==="slack"})}),i.jsx(it,{id:"trip-report",storage:"browser",children:i.jsx(Ge,{title:"Trip report",children:i.jsx(v0,{value:e.prefs.briefing,onChange:r=>e.update({briefing:r})})})})]})}const w0=[{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"]}],j0=[{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","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"]},{area:"Trackers",items:['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']},{area:"Teamtrail Cloud",items:["Agents that run in the cloud, steered from the same Lookout"]}],S0=[{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"]},...w0];function N0(){return i.jsxs("div",{className:"changelog",children:[i.jsxs("div",{className:"about",children:[i.jsx($m,{className:"about-name"}),i.jsx("span",{className:"mono-label",children:ge.category}),i.jsx("p",{className:"onb-tagline",children:ge.tagline}),i.jsx(ee,{parts:[ge.assistant.name]})]}),i.jsx(Ge,{title:"Next",children:j0.map(e=>i.jsxs("div",{className:"cl-row",children:[i.jsx("span",{className:"mono-label",children:e.area}),i.jsx("ul",{children:e.items.map(n=>i.jsx("li",{children:n},n))})]},e.area))}),S0.map(e=>i.jsx(Ge,{title:`${e.version} · ${e.date}`,children:i.jsx("ul",{children:e.items.map(n=>i.jsx("li",{children:n},n))})},e.version))]})}function qm(e){return i.jsx("ul",{className:"checklist-answers",children:e.answers.map(n=>i.jsxs("li",{className:n.done?"done":"not-done",children:[i.jsx("span",{className:"mark","aria-label":n.done?"Done":"Not done",children:n.done?"✓":"–"}),i.jsx("span",{className:"t-body",children:n.item}),n.note&&i.jsx("span",{className:"t-meta note",children:n.note})]},n.item))})}const Qm=`${ge.apiPrefix}`;async function Ym(e){const n=await e.json().catch(()=>({}));if(!e.ok)throw new Error(n.error??`Request failed (${e.status})`);return n}const wo=async e=>Ym(await fetch(`${Qm}${e}`)),Jm=async(e,n)=>Ym(await fetch(`${Qm}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}));let Xm;const mo=new Set;let Es;function jo(e){Xm=e;for(const n of mo)n()}function hh(){wo("/guides").then(jo,()=>jo(null))}const b0=()=>Xm;function C0(e){return mo.add(e),Es||(hh(),Es=hn(n=>{n.includes("guides")&&hh()})),()=>{mo.delete(e),!mo.size&&(Es==null||Es(),Es=void 0)}}function mn(){const e=x.useSyncExternalStore(C0,b0),n=x.useCallback(async(o,l)=>{try{jo(await Jm(o,l));return}catch(c){return c.message}},[]),r=x.useCallback(o=>o?e==null?void 0:e.guides.find(l=>l.id===o):void 0,[e]);return{view:e,act:n,find:r}}function $0(e){var h;const{view:n,find:r}=mn(),o=r(e.id),l=n!=null&&(o==null?void 0:o.status)!=="active",c=((h=o==null?void 0:o.guide)==null?void 0:h.name)??e.id,d=l?`${c}: ${(o==null?void 0:o.reason)??"not installed"}`:`Guide: ${c}`;return i.jsx("span",{className:tt("guide-chip",l&&"off"),"data-guide-id":e.id,title:d,children:c})}const T0={active:"Active",unapproved:"New, waiting for your approval",tampered:"Changed since you approved it",invalid:"Can't be used"};function E0(e){var r;if(e.origin==="builtin")return"Built in";const n=(r=e.lock)==null?void 0:r.source;if(!n||n==="local")return e.overridesBuiltin?"Local file, replaces the built-in":"Local file";try{return`From ${new URL(n.registry).host}`}catch{return"From a catalog"}}const Cc=e=>e.map(n=>/\s/.test(n)?JSON.stringify(n):n).join(" "),mh=3;function M0(e,n){return e.length<=Math.max(n,mh+1)?e:`${e.slice(0,Math.max(n-1,mh)).trimEnd()}…`}function I0(e){var o;const n=(o=e.lock)==null?void 0:o.review;return!n||e.status!=="active"?void 0:n.verified?{text:"Verified",strong:!0,tip:n.reviewedBy.length>0?`Reviewed by ${n.reviewedBy.join(", ")}`:void 0}:"Not reviewed"}function A0(e){const n=e.guide;return n?i.jsxs("tspan",{className:tt("guide",n.off&&"off"),"data-guide-id":n.id,children:[i.jsx("title",{children:n.tip})," · ",e.text??n.name]}):null}var R0=zh();function L0(e){var w;const{preview:n}=e,{act:r,find:o}=mn(),[l,c]=x.useState({kind:"ready"}),[d,h]=x.useState(),g=n.entry.id,m=async()=>{h(void 0),c({kind:"adding"});try{c({kind:"added",pending:(await e.add(g)).pendingChecks})}catch(j){h(j.message),c({kind:"ready"})}};if(n.entry.builtin)return i.jsxs("span",{className:"t-meta",children:["Built into ",ge.name,": already available to every trail, nothing to add."]});if(l.kind!=="added"){const j=e.installed===n.entry.version,T=e.installed?"Update guide":"Add guide";return i.jsxs("div",{className:"add-guide",children:[!n.ok&&i.jsx("span",{className:"t-meta",children:"The safety lint found errors, so this guide can't be added."}),i.jsx(K,{variant:"primary",disabled:!n.ok||j||l.kind==="adding",onClick:()=>void m(),children:j?"Added":T}),d&&i.jsx("span",{className:"vf-err",children:d})]})}const v=((w=o(g))==null?void 0:w.pendingChecks)??l.pending,k=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} ${n.entry.version}. Approve each command it proposes; none runs until you do.`:`Added ${g} ${n.entry.version}. Agents get its instructions on tickets that ask for ${g}.`}),v.map(j=>{var T,S;return i.jsxs("span",{className:"guide-check",children:[i.jsxs("code",{className:"t-code",children:[j,": ",Cc(((S=(T=n.guide)==null?void 0:T.proposedChecks[j])==null?void 0:S.run)??[])]}),i.jsxs(K,{size:"sm",onClick:()=>void k(j),children:["Approve check ",j]})]},j)}),d&&i.jsx("span",{className:"vf-err",children:d})]})}function O0(e){return e.findings.length?i.jsx("ul",{className:"vf-findings guide-findings",children:e.findings.map((n,r)=>i.jsxs("li",{className:`sev-${n.level}`,children:[i.jsxs("code",{className:"t-code",children:["line ",n.line]})," ",n.message," ",i.jsxs("span",{className:"t-meta",children:["(",n.rule,")"]})]},r))}):i.jsx("p",{className:"t-meta",children:"The safety lint found nothing."})}function _0(e){var o,l;const{p:n}=e,r=Object.entries(((o=n.guide)==null?void 0:o.proposedChecks)??{});return i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"t-label",children:"Safety lint"}),i.jsx(O0,{findings:n.findings}),n.guide&&n.guide.checklist.length>0&&i.jsx("span",{className:"t-label",children:"Checklist"}),n.guide&&i.jsx("ul",{className:"catalog-checklist t-body",children:n.guide.checklist.map(c=>i.jsx("li",{children:c},c))}),r.length>0&&i.jsx("span",{className:"t-label",children:"Commands it proposes"}),r.map(([c,d])=>i.jsxs("code",{className:"t-code guide-check",children:[c,": ",Cc(d.run)]},c)),i.jsx("span",{className:"t-label",children:"Instructions"}),i.jsx("pre",{className:"guide-preview",children:((l=n.guide)==null?void 0:l.instructions)??n.text})]})}function P0(e){if(!e.repo)return null;const n=encodeURIComponent(`Report: ${e.id} ${e.version}`),r=`${e.repo.replace(/\/+$/,"")}/issues/new?template=report-guide.yml&title=${n}`;return i.jsx("a",{className:"report-link t-meta",href:r,target:"_blank",rel:"noreferrer",children:"Report this guide"})}function D0(e){const n=e.entry,[r,o]=x.useState(),[l,c]=x.useState();return x.useEffect(()=>{e.preview(n.id).then(o,d=>c(d.message))},[n.id]),i.jsxs("div",{className:"catalog-entry",children:[i.jsx(K,{size:"sm",variant:"ghost",onClick:e.onBack,children:"← All guides"}),i.jsx("h3",{className:"t-title",children:n.name??n.id}),i.jsx(ee,{parts:[{text:n.id,code:!0},n.version,`by ${n.author}`,B0(n),n.reviewedBy.length>0&&`reviewed by ${n.reviewedBy.join(", ")}`]}),i.jsx("p",{className:"t-body",children:n.summary}),n.history.length>0&&i.jsx("ul",{className:"catalog-history",children:n.history.map(d=>i.jsxs("li",{className:"t-meta",children:[d.version," · ",i.jsx("code",{className:"t-code",children:d.commit.slice(0,8)})," · ",d.at.slice(0,10),d.reviewer&&` · reviewed by ${d.reviewer}`]},`${d.version}-${d.commit}`))}),l&&i.jsx("span",{className:"vf-err",children:l}),r&&i.jsx(_0,{p:r}),r&&i.jsx(P0,{repo:r.repo,id:n.id,version:n.version}),r&&i.jsx(L0,{preview:r,installed:e.installed,add:e.add})]})}function B0(e){return e.builtin?{text:"Built in",strong:!0}:e.verified?{text:"Verified",strong:!0}:"Not reviewed"}function z0(e){const n=e.entry;return i.jsx("li",{className:"catalog-row","data-guide-id":n.id,children:i.jsx(Re,{title:n.name??n.id,context:i.jsx(ee,{parts:[{text:n.id,code:!0},n.version,n.author,F0(n),n.reported&&"Reported"]}),detail:n.summary,trailing:e.installed&&`installed ${e.installed}`,onOpen:e.onOpen})})}function F0(e){return e.builtin?{text:"Built in",strong:!0}:e.verified?{text:"Verified",strong:!0}:"Not reviewed"}const ph=e=>e?`registry=${encodeURIComponent(e)}`:"";function U0(e){const[n,r]=x.useState(),[o,l]=x.useState();x.useEffect(()=>{let h=!0;return r(void 0),l(void 0),wo(`/guides/catalog?${ph(e)}`).then(g=>h&&r(g),g=>h&&l(g.message)),()=>{h=!1}},[e]);const c=x.useCallback(h=>wo(`/guides/catalog/preview?${ph(e)}&id=${encodeURIComponent(h)}`),[e]),d=x.useCallback(async h=>{const g=await Jm("/guides/catalog/add",{registry:e,id:h});return jo(g),g.installed},[e]);return{index:n,error:o,preview:c,add:d}}function W0(e){var T,S;const[n,r]=x.useState(((T=e.registries[0])==null?void 0:T.name)??""),o=U0(n||void 0),{find:l}=mn(),[c,d]=x.useState(""),[h,g]=x.useState(!0),[m,v]=x.useState(),k=o.index?Fk({guides:o.index.guides},{query:c,verifiedOnly:h}):[],w=(S=o.index)==null?void 0:S.guides.find(E=>E.id===m),j=E=>{var I,O,R;return((I=l(E))==null?void 0:I.origin)==="local"?(R=(O=l(E))==null?void 0:O.guide)==null?void 0:R.version:void 0};return R0.createPortal(i.jsx("div",{className:"scrim catalog-scrim",onClick:E=>{E.stopPropagation(),e.onClose()},children:i.jsxs(We,{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(ct,{compact:!0,"aria-label":"Catalog",value:n,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:"×"})]}),w?i.jsx(D0,{entry:w,installed:j(w.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(Ie,{children:"Reading the catalog…"}),o.index&&!k.length&&i.jsx(Ie,{children:"No guides match."}),i.jsx("ul",{className:"catalog-list",children:k.map(E=>i.jsx(z0,{entry:E,installed:j(E.id),onOpen:()=>v(E.id)},E.id))})]})]})}),document.body)}function H0(e){const n=e.r.guide;if(!n)return null;const r=Object.entries(n.proposedChecks);if(!n.requiresChecks.length&&!r.length)return null;const o=e.r.status==="active";return i.jsxs("div",{className:"guide-checks",children:[n.requiresChecks.length>0&&i.jsxs("span",{className:"t-meta",children:["Adds checks ",i.jsx("code",{className:"t-code",children:n.requiresChecks.join(", ")})," to its tickets"]}),r.map(([l,c])=>{const d=e.r.pendingChecks.includes(l);return i.jsxs("span",{className:"guide-check",children:[i.jsxs("code",{className:"t-code",children:[l,": ",Cc(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 V0(e){var d;const{r:n}=e,r=n.id,o=n.status!=="active"||n.pendingChecks.length>0,l=(n.status==="unapproved"||n.status==="tampered")&&!!n.guide,c=n.guide?`${n.guide.name} ${n.guide.version}`:r;return i.jsx("li",{className:"guide-row","data-guide-id":r,children:i.jsx(Re,{edge:o?"attention":"neutral",title:c,context:i.jsx(ee,{parts:[{text:r,code:!0},E0(n),I0(n),n.status!=="active"&&T0[n.status],n.guide&&K0(n.guide.checklist.length)]}),detail:n.reason??((d=n.guide)==null?void 0:d.summary),actions:n.origin==="local"&&i.jsxs(K,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>e.onAct("/guides/remove",{id:r}),children:["Remove guide ",r]}),below:i.jsxs(i.Fragment,{children:[l&&i.jsxs(K,{size:"sm",disabled:e.busy,onClick:()=>e.onAct("/guides/approve",{id:r}),children:["Approve guide ",r]}),i.jsx(H0,{r:n,busy:e.busy,onApprove:h=>e.onAct("/guides/checks/approve",{id:r,name:h})})]})})})}const K0=e=>e===1?"1 checklist item":`${e} checklist items`;function G0(e){const{view:n,act:r}=mn(),[o,l]=x.useState(),[c,d]=x.useState(!1),[h,g]=x.useState(!1),m=x.useRef(null);if(x.useEffect(()=>{var k;e.focus&&n&&((k=m.current)==null||k.scrollIntoView({block:"start"}))},[e.focus,!!n]),!n)return null;const v=async(k,w)=>{d(!0),l(await r(k,w)),d(!1)};return i.jsxs("div",{className:"guides-section",ref:m,children:[i.jsxs(Ge,{title:"Guides",children:[i.jsx("p",{className:"vf-intro",children:"Guides give an agent instructions and a checklist for the tickets that ask for them. A guide can add checks, never remove them, and its commands only run once you approve them."}),i.jsx("ul",{className:"guides-list",children:n.guides.map(k=>i.jsx(V0,{r:k,busy:c,onAct:(w,j)=>void v(w,j)},k.id))}),i.jsxs("div",{className:"guides-foot",children:[i.jsx(K,{size:"sm",onClick:()=>g(!0),children:"Browse guides"}),i.jsx(ee,{parts:[{text:`${ge.dataDir}/guides/`,code:!0},{text:"guides.lock.json",code:!0}]})]}),n.configErrors.length>0&&i.jsx("ul",{className:"vf-errors",children:n.configErrors.map(k=>i.jsx("li",{children:k},k))}),o&&i.jsx("span",{className:"vf-err",children:o})]}),h&&i.jsx(W0,{registries:n.registries,onClose:()=>g(!1)})]})}function q0(e){const{view:n,act:r}=mn(),[o,l]=x.useState();if(!n)return null;const c=e.map.guides??[],d=n.guides.filter(g=>g.status==="active"&&g.guide),h=g=>{const m=c.includes(g)?c.filter(v=>v!==g):[...c,g];l(void 0),r("/guides/team",{mapId:e.map.id,guides:m}).then(l)};return i.jsxs(Ge,{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 Q0(e,n){const[r,o]=x.useState();return x.useEffect(()=>{const l=`/guides/checklist?mapId=${encodeURIComponent(e)}&ticketId=${encodeURIComponent(n)}`,c=()=>wo(l).then(d=>o(d.checklist),()=>o(null));return c(),hn(d=>{d.endsWith("checklist.json")&&c()})},[e,n]),r}function Y0(e){const n=Q0(e.mapId,e.ticketId);if(!n)return null;const r=n.answers.filter(o=>!o.done).length;return i.jsxs("div",{className:"checklist-panel",children:[i.jsx(ee,{parts:[`${n.guide.id} ${n.guide.version} checklist`,n.by,Wi(n.at),r?`${r} not done`:"all done"]}),i.jsx(qm,{answers:n.answers})]})}const gh="";function J0(e){const{view:n,act:r}=mn(),[o,l]=x.useState();if(!n)return null;const c=e.ticket,d=n.guides.filter(m=>{var v;return m.status==="active"&&((v=m.guide)==null?void 0:v.handles.types.includes(c.type))}),h=[{value:gh,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(ct,{compact:!0,"aria-label":"Ticket guide",value:c.guide??gh,options:h,onChange:g}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function X0(e){const{view:n,find:r}=mn();if(!n)return null;const o=r(e.id);if((o==null?void 0:o.status)==="active")return null;const l=o?o.reason??o.status:"it is not installed";return i.jsxs("p",{className:"guide-warning t-meta",children:["Guide ",e.id," can't be used: ",l,". Claims get no guide instructions until you approve it in Settings → Guides."]})}function Z0(e){const{view:n}=mn(),r=e.ticket;return!n||r.state!=="open"&&!r.guide?null:i.jsxs("section",{className:"ticket-guide d-section",children:[i.jsxs("span",{className:"guide-head",children:[i.jsx("span",{className:"t-label",children:"Guide"}),r.state==="open"?i.jsx(J0,{mapId:e.mapId,ticket:r}):r.guide&&i.jsx($0,{id:r.guide})]}),r.guide&&i.jsx(X0,{id:r.guide}),i.jsx(Y0,{mapId:e.mapId,ticketId:r.id})]})}function eS(e){var g;const{view:n,find:r}=mn();if(!e)return;const o=r(e),l=n!=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 vh={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"},tS={low:"the agent decides",medium:"the agent decides and records it",high:"you decide"},nS=e=>e[0].toUpperCase()+e.slice(1),ec=nm.map(e=>({value:e,label:nS(e),hint:tS[e]}));function sS(e){const[n,r]=x.useState(""),[o,l]=x.useState("high"),{rules:c,onChange:d}=e,h=()=>{const g=n.trim();!g||c.some(m=>m.glob===g)||(d([...c,{glob:g,level:o}]),r(""))};return i.jsxs("div",{className:"risk-paths",children:[i.jsx("span",{className:"mono-label",children:"Files"}),c.map((g,m)=>i.jsxs("div",{className:"risk-row",children:[i.jsx("code",{children:g.glob}),i.jsx(ct,{compact:!0,"aria-label":`${g.glob} risk`,value:g.level,options:ec,onChange:v=>d(c.map((k,w)=>w===m?{...k,level:v}:k))}),i.jsx("button",{className:"icon-btn","aria-label":`Remove ${g.glob}`,onClick:()=>d(c.filter((v,k)=>k!==m)),children:"×"})]},g.glob)),i.jsxs("div",{className:"risk-row",children:[i.jsx("input",{value:n,placeholder:"src/payments/**","aria-label":"New file pattern",onChange:g=>r(g.target.value),onKeyDown:g=>g.key==="Enter"&&h()}),i.jsx(ct,{compact:!0,"aria-label":"New pattern risk",value:o,options:ec,onChange:l}),i.jsx(K,{onClick:h,disabled:!n.trim(),children:"Add"})]})]})}const Zm=`${Ne()}/policy`;async function iS(){const e=await fetch(Zm);return e.ok?await e.json():null}function rS(){const[e,n]=x.useState(),r=x.useCallback(()=>{iS().then(n,()=>n(null))},[]);x.useEffect(()=>(r(),hn(l=>{l.endsWith("policy.json")&&r()})),[r]);const o=x.useCallback(async l=>{const c=await fetch(Zm,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)}),d=await c.json();if(!c.ok)return d.error??`Saving failed (${c.status})`;n(d)},[]);return{view:e,save:o}}function oS(){const{view:e,save:n}=rS(),[r,o]=x.useState();if(!e)return null;const l=`${ge.dataDir}/policy.json`,c=d=>{o(void 0),n(d).then(o,h=>o(h.message))};return i.jsxs(Ge,{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:tm.map(d=>i.jsxs("label",{className:"risk-row",children:[i.jsx("span",{children:vh[d]}),i.jsx(ct,{compact:!0,"aria-label":`${vh[d]} risk`,value:e.policy.categories[d],options:ec,onChange:h=>c({...e.policy,categories:{...e.policy.categories,[d]:h}})})]},d))}),i.jsx(sS,{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 tc=`${Ne()}/workspaces`;async function aS(){const e=await fetch(tc);return e.ok?await e.json():null}function ep(){const[e,n]=x.useState(),r=x.useCallback(()=>{aS().then(n,()=>n(null))},[]);x.useEffect(()=>(r(),hn(c=>{(c.endsWith("workspaces.json")||c.includes("workspaces/")||c.includes("leases/"))&&r()})),[r]);const o=x.useCallback(async c=>{const d=await fetch(tc,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)}),h=await d.json();if(!d.ok)return h.error??`Saving failed (${d.status})`;n(h)},[]),l=x.useCallback(async(c,d,h=!1)=>{const g=await fetch(`${tc}/remove`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:c,ticketId:d,force:h})}),m=await g.json();return g.ok?(n(m),{}):{error:m.error??`Removing failed (${g.status})`,dirty:m.dirty??!1}},[]);return{view:e,save:o,remove:l}}function tp(e){const[n,r]=x.useState(!1),[o,l]=x.useState(),[c,d]=x.useState(!1),h=async g=>{d(!0),l(void 0);const m=await e.onRemove(g).catch(v=>({error:v.message,dirty:!1}));d(!1),r(!!m.dirty&&!g),m.dirty||l(m.error)};return n?i.jsxs("span",{className:"ws-remove ask",children:[i.jsx("span",{className:"vf-err",children:"Uncommitted changes in this workspace will be lost."}),i.jsx(K,{size:"sm",disabled:c,onClick:()=>h(!0),children:"Remove anyway"}),i.jsx(K,{size:"sm",variant:"ghost",onClick:()=>r(!1),children:"Keep"})]}):i.jsxs("span",{className:"ws-remove",children:[i.jsx(K,{size:"sm",disabled:c,onClick:()=>h(!1),children:e.label??"Remove"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function lS(e){return e.rows.length?i.jsx("ul",{className:"ws-list",children:e.rows.map(n=>i.jsx(Re,{as:"li",className:`ws-row ${n.active?"active":"finished"}`,title:i.jsx("span",{className:"t-code",children:n.branch}),titleText:n.branch,context:i.jsx(ee,{parts:[{text:n.ticketKey,code:!0},n.active?`Active · ${n.agent}`:"Finished"]}),detail:i.jsx("span",{className:"t-code",children:n.path}),detailText:n.path,below:n.active?void 0:i.jsx(tp,{onRemove:r=>e.onRemove(n.mapId,n.ticketId,r)})},`${n.mapId}/${n.ticketId}`))}):null}function cS(e){const{view:n,remove:r}=ep(),o=n==null?void 0:n.workspaces.find(l=>l.mapId===e.mapId&&l.ticketId===e.ticketId);return!o||o.active?null:i.jsxs("section",{className:"ticket-workspace d-section",children:[i.jsx("span",{className:"t-label",children:"Workspace"}),i.jsxs("p",{className:"t-meta",children:["Branch ",i.jsx("code",{className:"t-code",children:o.branch})," in"," ",i.jsx("code",{className:"t-code",title:o.path,children:o.path})]}),i.jsx(tp,{label:"Remove workspace",onRemove:l=>r(e.mapId,e.ticketId,l)})]})}function uS(){const{view:e,save:n,remove:r}=ep(),[o,l]=x.useState();if(!e)return null;const c=e.settings.worktrees,d=()=>{l(void 0),n({...e.settings,worktrees:!c}).then(l,h=>l(h.message))};return i.jsxs(Ge,{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; ",ge.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(ee,{className:"set-hint",parts:[{text:`${ge.dataDir}/workspaces.json`,code:!0},yh(e.workspaces.filter(h=>h.active).length,"active"),yh(e.workspaces.filter(h=>!h.active).length,"finished")]}),i.jsx(lS,{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 yh=(e,n)=>`${e} ${n}`;function dS({data:e,route:n}){return i.jsxs(i.Fragment,{children:[i.jsx(it,{id:"tracker",children:i.jsx(Ge,{title:"Tracker",children:i.jsx(u0,{activeTracker:e.activeTracker,location:e.location,update:e.update})})}),i.jsx(it,{id:"workspaces",storage:"repo",children:i.jsx(uS,{})}),i.jsx(it,{id:"policy",storage:"repo",children:i.jsx(oS,{})}),i.jsx(it,{id:"guides",storage:"repo",children:i.jsx(G0,{focus:n.section==="guides"})}),i.jsx(it,{id:"labels",children:i.jsx(Ge,{title:"Labels",children:i.jsxs("div",{className:"label-codes",children:[i.jsx("code",{children:rc}),i.jsxs("code",{children:[ge.labelPrefix,":<type>"]}),i.jsx("code",{children:oc}),i.jsx("code",{children:ac})]})})})]})}const nc=`${ge.apiPrefix}/projects`;async function co(e,n,r){const o=await fetch(`${nc}${e}`,{method:n,headers:{"Content-Type":"application/json"},body:r===void 0?void 0:JSON.stringify(r)}),l=await o.json().catch(()=>({}));if(!o.ok)throw new Error(l.error??`HTTP ${o.status}`);return l}const zs={url:nc,add:e=>co("","POST",{path:e}),remove:e=>co(`/${e}`,"DELETE"),setAutoRegister:e=>co("/settings","PUT",{autoRegister:e}),answer:(e,n)=>co(`/${e}/answer`,"POST",n),async briefing(e){const n=await fetch(`${nc}/briefing?since=${e}`);return n.ok?await n.json():void 0}};function np(e){const[n,r]=x.useState(""),[o,l]=x.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(yc,{value:n,onValueChange:r,onSubmit:c,action:"Add project",placeholder:`/path/to/repo (a ${ge.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,n)=>e>0&&`${e} ${n}`;function fS(e){var r;const n=((r=e.briefing)==null?void 0:r.projects)??[];return!e.briefing||!n.length?null:i.jsxs("section",{className:"pj-section pj-briefing",children:[i.jsx(bt,{title:"While you were away",count:n.length,info:`What changed in each project since ${en(e.now-e.briefing.since)} ago`}),i.jsx("ul",{className:"pj-list",children:n.map(({projectId:o,project:l,briefing:c})=>i.jsx(Re,{as:"li",edge:c.totals.waiting>0?"attention":"neutral",title:l,context:i.jsx(ee,{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 hS(e){const[n,r]=x.useState(""),[o,l]=x.useState(!1),[c,d]=x.useState(),h=g=>{!g.trim()||o||(l(!0),d(void 0),e.onAnswer(g.trim()).then(()=>r(""),m=>d(m.message)).finally(()=>l(!1)))};return i.jsxs("div",{className:"pj-answer",children:[i.jsx(yc,{value:n,onValueChange:r,onSubmit:h,action:"Answer",disabled:o,placeholder:"Your answer","aria-label":"Your answer"}),c&&i.jsx("span",{className:"vf-err",children:c})]})}function mS(e){const{item:n}=e,r=Om(n),o=n.kind==="question"&&n.agent?`${n.agent} asks`:Rm[n.kind],l=n.urgency==="blocking"&&{text:"Blocking",urgent:!0,className:"urgency-tag"};return i.jsx(Re,{as:"li",className:`att-item pj-item k-${n.kind}`,edge:Lm(n,n.interrupting),title:n.title.split(`
128
+ `)[0],titleText:n.title,context:i.jsx(ee,{parts:[l,{text:n.project,strong:!0},o]}),detail:r.length>0&&r.join(" · "),detailText:r.join(`
129
+ `),trailing:en(e.now-n.since),onOpen:e.onOpen,below:e.onAnswer&&i.jsx(hS,{onAnswer:e.onAnswer})})}function pS(e){const n=e.view.attention,r=o=>{var l;return((l=e.view.projects.find(c=>c.id===o))==null?void 0:l.state.kind)!=="missing"};return i.jsxs("section",{className:"pj-section pj-attention",children:[i.jsx(bt,{title:"Needs you",count:n.length,hot:n.some(o=>o.interrupting),info:"One queue across projects, ranked the way each project ranks its own. Answer questions here; the agent in that repo gets the answer."}),n.length===0&&i.jsx(_n,{title:"Nothing needs you",hint:"Agents in every project can keep going."}),i.jsx("ul",{className:"pj-list",children:n.map(o=>i.jsx(mS,{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 zl=(e,n,r=`${n}s`)=>`${e} ${e===1?n:r}`;function gS(e){return e.interrupting>0?"urgent":e.phases.blocked+e.phases.rework+e.flags+e.stalled>0||e.state.kind==="missing"?"attention":"neutral"}function vS(e){if(e.state.kind==="missing")return[{text:"Missing",strong:!0},{text:e.path,code:!0}];const n=[];e.needsYou&&n.push({text:`${e.needsYou} ${e.needsYou===1?"needs":"need"} you`,strong:!0,urgent:e.interrupting>0}),e.agents&&n.push(zl(e.agents,"agent"));const{working:r,verifying:o,rework:l,blocked:c}=e.phases;return r&&n.push(`${r} working`),o&&n.push(`${o} verifying`),l&&n.push(`${l} rework`),c&&n.push(`${c} blocked`),e.flags&&n.push(zl(e.flags,"PR flag")),e.stalled&&n.push(zl(e.stalled,"stalled claim")),n.length||n.push(e.trails?"Nothing waiting":"No trails yet"),e.tracker.kind==="github"&&e.tracker.repo&&n.push(`Issues in ${e.tracker.repo}`),n}function yS(e){var n;return e.state.kind==="elsewhere"?`Served by another Lookout · ${e.state.url}`:((n=e.top)==null?void 0:n.title)??e.note??e.path}function So(e,n,r){if(e.state.kind!=="missing"){if(e.state.kind==="elsewhere"){const o=new URL(e.state.url);r&&o.searchParams.set(_s,r),window.open(o.toString(),"_blank","noopener");return}location.href=Sx({id:e.id,home:n,tracker:e.tracker.kind,item:r})}}function sp(e){const{p:n}=e,r=yS(n);return i.jsx(Re,{as:"li",className:`project-card st-${n.state.kind}`,edge:gS(n),selected:e.current,title:n.name,titleText:n.path,context:i.jsx(ee,{parts:vS(n)}),detail:r,detailText:r,trailing:n.lastActivity?en(e.now-n.lastActivity):void 0,onOpen:e.onOpen})}const ip=`${$o}:projects:seen`,kh=24*36e5;function kS(e){try{const n=Number(localStorage.getItem(ip));return n>0?n:e-kh}catch{return e-kh}}function xS(e){try{localStorage.setItem(ip,String(e))}catch{}}function wS(){const[e,n]=x.useState();return x.useEffect(()=>{const r=Date.now();return zs.briefing(kS(r)).then(n).catch(()=>{}),()=>xS(r)},[]),e}function jS(e){const{view:n,reload:r}=e.projects,o=tn(15e3),l=wS();if(x.useEffect(()=>{const g=m=>m.key==="Escape"&&e.onClose();return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[e]),!n)return null;const c=_o()??n.home,d=g=>{const m=n.projects.find(v=>v.id===g);(m==null?void 0:m.id)===c?e.onClose():m&&So(m,n.home)},h=(g,m)=>{const v=n.projects.find(k=>k.id===g);if(v){if(v.id!==c)return So(v,n.home,m);e.onClose(),e.onItemHere(m)}};return i.jsxs(We,{className:`zone decisions-view projects-view dv-${e.bp}`,children:[i.jsxs("header",{className:"dv-head",children:[i.jsx(Ke,{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(pS,{view:n,now:o,onOpen:h,onAnswered:r}),i.jsxs("section",{className:"pj-section pj-projects",children:[i.jsx(bt,{title:"Projects",count:n.projects.length,info:"Each repo registered on this machine, read from its own files. Nothing leaves your machine."}),i.jsx("ul",{className:"pj-list",children:n.projects.map(g=>i.jsx(sp,{p:g,current:g.id===c,now:o,onOpen:g.state.kind==="missing"?void 0:()=>d(g.id)},g.id))}),i.jsx(np,{onAdded:r})]}),i.jsx(fS,{briefing:l,now:o,onOpen:d})]})]})}function SS(e){const[n,r]=x.useState(!1),o=x.useRef(null);x.useEffect(()=>{if(!n)return;const h=g=>{var m;(g instanceof KeyboardEvent?g.key==="Escape":!((m=o.current)!=null&&m.contains(g.target)))&&r(!1)};return window.addEventListener("mousedown",h),window.addEventListener("keydown",h),()=>{window.removeEventListener("mousedown",h),window.removeEventListener("keydown",h)}},[n]);const{view:l}=e.projects;if(!l||!e.projects.many)return i.jsx("span",{className:"repo",children:e.repo});const c=_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":n,"data-tip":"Switch project, or see all of them",children:[i.jsx("span",{className:"project-name",children:e.repo}),d>0&&i.jsx(Zn,{n:d,urgent:!0}),i.jsx("span",{className:"caret",children:"▾"})]}),n&&i.jsxs("div",{className:"trail-menu",role:"menu",children:[i.jsxs("button",{role:"menuitem",className:"trail-item all-projects",onClick:()=>{r(!1),e.onOverview()},children:[i.jsx("span",{className:"mi-title",children:"All projects"}),i.jsx(Zn,{n:l.attention.length,urgent:l.attention.some(h=>h.interrupting),hideZero:!0})]}),i.jsx(Ke,{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&&So(h,l.home)},children:[i.jsx("span",{className:"mi-title",children:h.name}),i.jsx("span",{className:"mi-progress",children:NS(h.state.kind)}),i.jsx(Zn,{n:h.needsYou,urgent:h.interrupting>0,hideZero:!0})]},h.id))]})]})}function NS(e){return e==="missing"?"missing":e==="elsewhere"?"other Lookout":""}function bS(e){const n=tn(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(bt,{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(sp,{p:l,current:!1,now:n,onOpen:l.state.kind==="missing"?void 0:()=>So(l,r.home)},l.id))})]})}function rp(){const[e,n]=x.useState(),r=x.useCallback(()=>{fetch(zs.url).then(o=>o.ok?o.json():void 0).then(o=>o&&n(o)).catch(()=>{})},[]);return x.useEffect(()=>Do("projects",o=>n(JSON.parse(o))),[]),x.useEffect(r,[r]),{view:e,many:((e==null?void 0:e.projects.length)??0)>1,reload:r}}const CS=e=>[e.home&&{text:"This Lookout",strong:!0},e.state.kind==="missing"&&"Missing",{text:e.path,code:!0}];function $S(){const{view:e,reload:n}=rp(),[r,o]=x.useState();if(!e)return null;const l=c=>{o(void 0),c.then(n,d=>o(d.message))};return i.jsxs(Ge,{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(Re,{as:"li",edge:c.state.kind==="missing"?"attention":"neutral",title:c.name,context:i.jsx(ee,{parts:CS(c)}),actions:!c.home&&i.jsx(K,{size:"sm",variant:"ghost",onClick:()=>l(zs.remove(c.id)),children:"Remove"})},c.id))}),i.jsx(np,{onAdded:n}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Agents add their repo when they connect"}),i.jsx(K,{size:"sm",on:e.autoRegister,"aria-pressed":e.autoRegister,className:"auto-register-toggle",onClick:()=>l(zs.setAutoRegister(!e.autoRegister)),children:e.autoRegister?"On":"Off"})]}),i.jsx(ee,{className:"set-hint",parts:[{text:`${ge.slug} projects add <path>`,code:!0},`--no-register or ${ge.noRegisterEnv} opts one agent out`]}),r&&i.jsx("span",{className:"vf-err",children:r})]})}const TS=`${ge.apiPrefix}/models`;function $c(){const[e,n]=x.useState(),r=x.useCallback(()=>{fetch(TS).then(o=>o.ok?o.json():null).then(n,()=>n(null))},[]);return x.useEffect(()=>{r();const o=hn(c=>{(c.endsWith("models.json")||c.endsWith("map.md")||c.includes("/tickets/"))&&r()}),l=Do("attention",r);return()=>{o(),l()}},[r]),e}function ES({mapId:e,ticketId:n}){const r=$c(),o=r==null?void 0:r.waiting.find(l=>l.mapId===e&&l.ticketId===n);return o?i.jsx(Re,{className:"model-wait d-section",edge:"attention",title:`Needs a ${o.tier} model`,context:i.jsx(ee,{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 MS({view:e}){if(!e)return null;const n=`${ge.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(ee,{className:"set-hint",parts:[{text:n,code:!0},e.exists?`${r} of your own models`:"add new or custom models here","unknown models count as balanced"]}),o&&i.jsx(ee,{className:"set-hint models-connected",parts:[`Connected now: ${o}`]}),e.errors.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[n," has errors, so only the built-in models count until it is fixed."]})]}),i.jsx("ul",{className:"vf-errors",children:e.errors.map(l=>i.jsx("li",{children:l},l))})]})]})}const op={fast:"Fast",balanced:"Balanced",strongest:"Strongest"},IS={fast:"Haiku, mini and nano models",balanced:"Sonnet, GPT-4 models",strongest:"Opus, GPT-5 and o-series models"},AS=Wh.map(e=>({value:e,label:op[e],hint:IS[e]}));function RS(e){return i.jsx("div",{className:"tier-grid",children:Eo.map(n=>{const r=e.tiers[n],o=cc[n];return i.jsxs("div",{className:"tier-row",children:[i.jsx("span",{children:Pi[n]}),i.jsx(ct,{compact:!0,"aria-label":`${Pi[n]} tickets' model`,className:`tier-select tier-${n}`,value:r,options:AS,onChange:l=>e.onChange(n,l)}),i.jsx(ee,{className:"tier-hint",parts:[r!==o&&`default ${op[o].toLowerCase()}`,e.hints[n]]})]},n)})})}const uo=(e,n)=>`${e} ${n}${e===1?"":"s"}`;function LS({rows:e}){return e.length?i.jsx("ul",{className:"perf-rows",children:e.map(n=>i.jsx(Re,{as:"li",className:"perf-row",title:n.key,trailing:i.jsx("span",{title:"Median time from first claim to done",children:Xt(n.medianLeadMs)}),context:i.jsx(ee,{parts:[`${n.done} of ${uo(n.tickets,"ticket")} done`,n.cancelled>0&&`${n.cancelled} cancelled`,uo(n.reworkCycles,"rework"),`reviews ${n.reviews.passed} passed, ${n.reviews.failed} failed`,n.answers>0&&uo(n.answers,"question")]}),detail:n.findings.raised>0?`As reviewer: ${n.findings.upheld} of ${uo(n.findings.raised,"finding")} upheld`:void 0},n.key))}):i.jsx(Ie,{children:"No claimed tickets yet"})}function ap(e){const[n,r]=x.useState({}),o=e.map(l=>`${l.map.id}:${l.tickets.reduce((c,d)=>Math.max(c,d.updatedAt),0)}`).join();return x.useEffect(()=>{let l=!0;return Promise.all(e.map(async c=>{const d=await fetch(`${Ne()}/journal?mapId=${encodeURIComponent(c.map.id)}`).catch(()=>{}),h=d!=null&&d.ok?await d.json():{entries:[]};return[c.map.id,h.entries]})).then(c=>{l&&r(Object.fromEntries(c))}),()=>{l=!1}},[o]),n}const OS=[{id:"byVendor",title:"By vendor"},{id:"byAgent",title:"By agent"},{id:"byType",title:"By ticket type"}];function _S({api:e,bp:n,onClose:r}){const[o,l]=x.useState("byVendor"),c=x.useMemo(()=>Object.values(e.allSnaps),[e.allSnaps]),d=ap(c),h=e.activity.answered,g=x.useMemo(()=>am(c.map(m=>({snap:m,journal:d[m.map.id]??[],answered:h}))),[c,d,h]);return x.useEffect(()=>{const m=v=>v.key==="Escape"&&r();return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[r]),i.jsxs(We,{className:`zone decisions-view perf-view dv-${n}`,children:[i.jsxs("header",{className:"dv-head",children:[i.jsx(Ke,{as:"h2",children:"Trail stats"}),i.jsx(ee,{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(Ke,{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(Ie,{children:"Nothing yet. This needs at least 5 results from two vendors to compare."})]}),i.jsxs("section",{className:"perf-section",children:[i.jsx("div",{className:"choice-row compact",children:OS.map(m=>i.jsx(ht,{on:o===m.id,title:m.title,onClick:()=>l(m.id)},m.id))}),i.jsx(LS,{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 PS(e,n){const r=ap(e);return x.useMemo(()=>{var c;const o=am(e.map(d=>({snap:d,journal:r[d.map.id]??[],answered:n}))),l={};for(const d of o.byType){if(!d.done)continue;const h=(c=o.recommendations.find(m=>m.id===`speed-${d.key}`))==null?void 0:c.text,g=[`Trail stats: ${d.done} done`,d.medianLeadMs!==void 0&&`median ${Xt(d.medianLeadMs)}`,d.reworkCycles>0&&`${d.reworkCycles} back to rework`,h];l[d.key]=g.filter(Boolean).join(" · ")}return l},[e,r,n])}function DS(e){var d,h;const n=$c(),r=PS(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(Ge,{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(RS,{tiers:Nv(o),hints:r,onChange:(g,m)=>{const v={...c,[g]:m};m===cc[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(MS,{view:n})]})}function BS(){const[e,n]=x.useState();return x.useEffect(()=>{let r=!0;return fetch(`${Ne()}/verification/config`).then(o=>o.ok?o.json():null).then(o=>r&&n(o),()=>r&&n(null)),()=>{r=!1}},[]),e}const xh=`{
130
+ "v": 1,
131
+ "checks": {
132
+ "test": { "run": ["npm", "test"] },
133
+ "lint": { "run": ["npm", "run", "lint"] }
134
+ },
135
+ "run": ["test", "lint"]
136
+ }
137
+ `;function zS({file:e}){const[n,r]=x.useState(!1),o=()=>void navigator.clipboard.writeText(xh).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:xh}),i.jsx(K,{size:"sm",variant:"ghost",onClick:o,children:n?"Copied":"Copy"})]}),i.jsxs("p",{className:"dim",children:[i.jsx("code",{children:"run"})," lists the checks that run on every completion. Each ",i.jsx("code",{children:"run"})," command is a list of words, not a shell line. Until the file exists, levels above Off can’t run their checks, so those completions stop and wait for you."]})]})}function FS(e){const n=BS(),[r,o]=x.useState();if(!n)return null;const l=e.map,c=n.config,d=`${ge.dataDir}/${n.file}`,h=(l==null?void 0:l.verification)??"off",g=(c??qh).appliesTo.join(" and ");return i.jsxs(Ge,{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:lc.map(m=>i.jsx(ht,{on:h===m,title:Bi[m],sub:Bm[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})]}),n.errors.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line alert",title:n.hash,children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[d," has errors. Completions that need checks wait for you until it is fixed."]})]}),i.jsx("ul",{className:"vf-errors",children:n.errors.map(m=>i.jsx("li",{children:m},m))})]}),!n.exists&&i.jsx(zS,{file:d}),c&&n.exists&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line ok",title:n.hash,children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[i.jsx("span",{className:"t-code",children:d})," · ",c.run.length," checks run on every completion"]})]}),i.jsx(ee,{className:"set-hint",parts:[`New trails start at ${Bi[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 US({data:e}){const{map:n}=e;return i.jsxs(i.Fragment,{children:[n?i.jsx(it,{id:"mode",children:i.jsx(Ge,{title:`Trail ${n.key}`,children:i.jsx(Fj,{value:n.mode,onChange:e.onMapMode})})}):i.jsx(Ie,{children:"Chart or pick a trail to set its mode, model matching and team."}),i.jsx(it,{id:"verification",storage:"repo",children:i.jsx(FS,{map:n})}),i.jsx(it,{id:"models",children:i.jsx(DS,{map:n,snaps:e.snaps,answered:e.answered,onChange:e.onModelMatching})}),n&&i.jsx(it,{id:"team",children:i.jsx(q0,{map:n})})]})}const WS=[{value:"auto",title:"Match my system"},{value:"day",title:"Day"},{value:"night",title:"Night"}];function HS(e){return i.jsx("div",{className:"choice-row compact",children:WS.map(n=>i.jsx(ht,{on:e.value===n.value,title:n.title,onClick:()=>e.onChange(n.value)},n.value))})}function VS({data:e}){const{prefs:n,update:r}=e;return i.jsxs(i.Fragment,{children:[i.jsx(it,{id:"appearance",storage:"browser",children:i.jsx(Ge,{title:"Appearance",children:i.jsx(HS,{value:n.theme,onChange:o=>r({theme:o})})})}),i.jsx(it,{id:"transcript",storage:"browser",children:i.jsx(Ge,{title:"HITL transcript",children:i.jsx(Km,{value:n.hitlTranscript,onChange:o=>r({hitlTranscript:o})})})}),i.jsx(it,{id:"agent",children:i.jsx(Ge,{title:"Agent",children:i.jsx("div",{className:"choice-row",children:dm.map(o=>i.jsx(ht,{on:o.status==="primary",disabled:o.status!=="primary",title:o.name},o.id))})})})]})}function KS(e){const{data:n,route:r}=e;switch(e.group){case"trail":return i.jsx(US,{data:n});case"project":return i.jsx(dS,{data:n,route:r});case"alerts":return i.jsx(x0,{data:n,route:r});case"you":return i.jsx(VS,{data:n});case"projects":return i.jsx(it,{id:"projects",storage:"machine",children:i.jsx($S,{})});case"about":return i.jsx(it,{id:"changelog",children:i.jsx(N0,{})});default:return e.group}}function GS(e){const{group:n,route:r}=e,o=x.useRef(null),l=x.useRef(null);return x.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})},[n.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:n.label}),i.jsx("p",{className:"sp-intro t-meta",children:n.intro})]}),i.jsx(KS,{group:n.id,data:e.data,route:r})]})})}function qS(e){return i.jsx("nav",{className:"sp-nav","aria-label":"Settings groups",children:i.jsx("ul",{children:zi.map(n=>{const r=n.id===e.current;return i.jsx(Re,{as:"li",className:"sp-nav-row",selected:r,current:r?"page":void 0,title:n.label,context:i.jsx(ee,{parts:n.sections.map(o=>o.title)}),trailing:e.drill&&"›",onOpen:()=>e.onPick(n.id)},n.id)})})})}function QS(e,n){return e.group?zi.find(r=>r.id===e.group):n==="mobile"?void 0:zi[0]}const YS={page:"Back to the Lookout",list:"Lookout",group:"Settings"},JS=(e,n)=>e?n?"group":"list":"page";function XS(e){const{bp:n,route:r}=e,o=n==="mobile",l=QS(r,n),c=JS(o,!!l),d=()=>c==="group"?e.onShow({}):e.onClose();x.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(qS,{current:l==null?void 0:l.id,onPick:h,drill:o});return i.jsxs(We,{className:`zone decisions-view settings-page sp-${n}`,"aria-label":"Settings",children:[i.jsxs("header",{className:"dv-head",children:[i.jsxs("button",{className:"back",onClick:d,children:["‹ ",YS[c]]}),c!=="group"&&i.jsx(Ke,{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(GS,{group:l,data:e.data,route:r})]})]})}function fo(e,n){const r=new URL(e);return r.searchParams.delete("settings"),n&&r.searchParams.set("settings",n.section??n.group??""),r.toString()}function ZS(e){var l;const{rt:n,api:r,settings:o}=e;return o.route?i.jsx(XS,{bp:e.bp,route:o.route,onShow:o.show,onClose:o.close,data:{prefs:e.prefs,update:e.update,activeTracker:n.kind,location:n.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(We,{className:"zone side",style:{gridArea:"inspector"},children:[i.jsx(Cm,{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 lp(e){return e.filter(n=>n.state!=="out-of-scope").map(n=>({x:n.x,y:n.y,w:Ue,h:Ve}))}function t1(e){const{obstacles:n,from:r,to:o,clear:l}=e,c=n.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 n=e.filter((l,c)=>c===0||l.x!==e[c-1].x||l.y!==e[c-1].y);let r=`M${n[0].x} ${n[0].y}`;for(let l=1;l<n.length-1;l++){const[c,d,h]=[n[l-1],n[l],n[l+1]],g=Math.min(n1,wh(c,d)/2,wh(d,h)/2),m=jh(d,c,g),v=jh(d,h,g);r+=`L${m.x} ${m.y}Q${d.x} ${d.y} ${v.x} ${v.y}`}const o=n[n.length-1];return`${r}L${o.x} ${o.y}`}function wh(e,n){return Math.abs(e.x-n.x)+Math.abs(e.y-n.y)}function jh(e,n,r){return{x:e.x+Math.sign(n.x-e.x)*r,y:e.y+Math.sign(n.y-e.y)*r}}function No(e){const n=e.direction==="TB",r=d=>n?{x:d.y,y:d.x}:d,o=r(e.a),l=r(e.b),c=e.obstacles.map(d=>n?{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:n,obstacles:r,gap:o}){const l=r.filter(m=>m.x+m.w>e.x+1&&m.x<n.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+n.x)/2),h=Math.max(n.x-o/2,(e.x+n.x)/2);if(c(e.y))return[e,{x:h,y:e.y},{x:h,y:n.y},n];if(c(n.y))return[e,{x:d,y:e.y},{x:d,y:n.y},n];const g=t1({obstacles:l,from:e.y,to:n.y,clear:c});return[e,{x:d,y:e.y},{x:d,y:g},{x:h,y:g},{x:h,y:n.y},n]}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 n=e.graphH+76;return{x:e.width/2,y:n,right:e.width,bottom:Math.max(e.height,n+70)}}function o1(e,n){const r=new Set(e.edges.map(c=>c.from)),o=e.nodes.filter(c=>c.state!=="out-of-scope"&&!r.has(c)),l=lp(e.nodes);return o.map(c=>{if(e.direction==="LR"){const g={x:c.x+Ue,y:c.y+Ve/2},m={x:n.x-44,y:n.y};return No({direction:"LR",a:g,b:m,obstacles:l,gap:96})}const d={x:c.x+Ue/2,y:c.y+Ve},h={x:n.x,y:n.y-44};return No({direction:"TB",a:d,b:h,obstacles:l,gap:48})})}function a1({x:e,y:n}){return i.jsxs("g",{className:"destination",transform:`translate(${e} ${n})`,"aria-label":"Destination",children:[i.jsx("path",{className:"x-stroke",d:"M-32 -35 C-20 -22 4 8 33 36"}),i.jsx("path",{className:"x-stroke",d:"M35 -33 C14 -18 -12 10 -35 37"}),i.jsx("path",{className:"x-sketch",d:"M-29 -29 C-14 -13 8 8 28 29 M30 -28 C12 -13 -8 6 -29 31"}),i.jsx("text",{y:58,textAnchor:"middle",children:"Destination"})]})}function l1({trails:e}){return e.map(n=>i.jsx("path",{className:"edge edge-open edge-destination",d:n},n))}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 bo=(e,n)=>`${e}>${n}`;function u1(e,n,r=[]){const o=new Map(e.tickets.map(c=>[c.id,c]));return{tickets:n.nodes.map(c=>{const d=o.get(c.id);return d?{...d,blockedBy:[...c.blockedBy,...c.removedEdges??[]]}:{id:c.id,key:"+",title:c.title,type:c.type,body:"",state:"open",blockedBy:c.blockedBy,comments:[],createdAt:e.map.updatedAt,updatedAt:e.map.updatedAt}}),marks:new Map(n.nodes.map(c=>[c.id,c.mark])),newEdges:new Set(n.nodes.flatMap(c=>c.newEdges.map(d=>bo(d,c.id)))),removedEdges:new Set(n.nodes.flatMap(c=>(c.removedEdges??[]).map(d=>bo(d,c.id)))),frozen:new Set(r)}}function d1(e,n){const r=jy({...e,tickets:n}),o=new Set;for(let l=1;l<r.length;l++)o.add(bo(r[l-1].id,r[l].id));return o}const Sh={LR:130,TB:68};function f1(e){const{direction:n,from:r,to:o,cards:l}=e;if(n==="LR"){const h={x:r.x+Ue,y:r.y+Ve/2},g={x:o.x,y:o.y+Ve/2};return No({direction:n,a:h,b:g,obstacles:l,gap:Sh.LR})}const c={x:r.x+Ue/2,y:r.y+Ve},d={x:o.x+Ue/2,y:o.y};return No({direction:n,a:c,b:d,obstacles:l,gap:Sh.TB})}function h1(e){const{from:n,to:r,direction:o}=e,c=["edge",n.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:f1({direction:o,from:n,to:r,cards:e.cards})})}function m1(e){const{snap:n,tickets:r,direction:o,preview:l}=e,c=x.useMemo(()=>d1(n,r),[n,r]),d=x.useMemo(()=>lp(e.nodes),[e.nodes]);return e.edges.map(({from:h,to:g})=>{const m=bo(h.ticket.id,g.ticket.id);return i.jsx(h1,{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 sc=24,Nh=31,p1=Ue-sc-10,g1=9;function v1(e){const n=e.parts.filter(Boolean).join(" · ").length,r=e.guide===void 0?void 0:M0(e.guide,Math.max(g1,Nh-n-3)),l=(r===void 0?n:n+3+r.length)>Nh?{textLength:p1,lengthAdjust:"spacingAndGlyphs"}:{};return{guideText:r,squeeze:l}}function y1(e,n,r){const o=e.state==="frontier"||e.state==="rework";if(!(!n||r||e.ticket.assignee||!o))return n}function k1(e){const n=["node",`st-${e.n.state}`,`tone-${e.tone}`,e.hitl?"hitl":"afk"];return e.selected&&n.push("sel"),e.live&&n.push("live"),e.waiting&&n.push("waiting"),e.stalled&&!e.waiting&&n.push("stalled"),e.mark&&n.push(`mark-${e.mark}`),e.frozen&&n.push("frozen"),n.join(" ")}function x1({wait:e,session:n}){return e?i.jsx("title",{children:`Needs a ${e} model: no connected agent runs one`}):n?i.jsx("title",{children:`${n.agent} · step ${n.step}/${n.total} · ${n.stepLabel.toLowerCase()}`}):null}const w1={claimed:"working",verifying:"working",frontier:"ready",blocked:"backlog",parked:"backlog",decided:"done","out-of-scope":"cancelled",rework:"attention",held:"attention"};function j1(e){const n=w1[e.state];return n==="done"||n==="cancelled"?n:e.attention?"attention":e.live?"working":n}function S1({mark:e,frozen:n}){const r=e&&e!=="unchanged"&&e!=="cancelled"?e:void 0;return i.jsxs(i.Fragment,{children:[e==="cancelled"&&i.jsx("line",{className:"strike",x1:8,y1:Ve/2,x2:Ue-8,y2:Ve/2}),r&&i.jsx("text",{className:"reroute-tag",x:Ue-8,y:Ve-7,textAnchor:"end",children:r}),n&&i.jsx("text",{className:"freeze",x:Ue-(r?58:8),y:Ve-7,textAnchor:"end",children:"❄"})]})}function N1(e){const{n,session:r}=e,o=n.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"}:n.state==="claimed"?{text:o??"working",tone:"agent"}:{text:Cx[n.state],tone:""}}function b1({tone:e,cy:n}){return e==="done"?i.jsx("path",{className:"dot dot-done",d:`M10 ${n}l2.5 2.5 4.5 -5`}):i.jsx("circle",{className:`dot dot-${e}`,cx:13,cy:n,r:e==="backlog"?3:3.5})}function C1(e,n,r=2){const o=e.split(/\s+/),l=[];let c="";for(const d of o)(c+" "+d).trim().length>n?(l.push(c.trim()),c=d):c+=" "+d;if(l.push(c.trim()),l.length>r){const d=l.slice(0,r);return d[r-1]=d[r-1].slice(0,n-1)+"…",d}return l}const $1=26;function T1({n:e,session:n,stalled:r,flag:o,selected:l,onSelect:c,mark:d,frozen:h,needs:g}){const m=e.ticket,v=C1(m.title,$1),k=Fi(m)==="hitl",w=!!(n!=null&&n.waitingOn),j=!!d&&d!=="unchanged",T=y1(e,g,!!n),S=eS(m.guide),E=j?void 0:N1({n:e,session:n,waiting:w,stalled:r,wait:T,step:!S}),I=k&&!j&&(m.type==="task"||m.type==="execute"),O=w||!!r||!!T||I&&e.state==="frontier",R=j1({state:e.state,live:!!n,attention:O}),X=Pi[m.type],te=v1({parts:[m.key,X,E==null?void 0:E.text,I&&"needs you"],guide:S==null?void 0:S.name}),B=v.length>1?19:24;return i.jsxs("g",{className:k1({n:e,tone:R,hitl:k,selected:l,live:!!n,waiting:w,stalled:r,mark:d,frozen:h}),style:{transform:`translate(${e.x}px, ${e.y}px)`},onClick:se=>{se.stopPropagation(),c({kind:"ticket",id:m.id})},children:[i.jsx(x1,{wait:T,session:n}),i.jsx("rect",{className:"ring",x:-3.5,y:-3.5,width:Ue+7,height:Ve+7,rx:9}),i.jsx("rect",{className:"card",x:.5,y:.5,width:Ue-1,height:Ve-1,rx:6}),i.jsx(b1,{tone:R,cy:B-4}),v.map((se,oe)=>i.jsx("text",{className:"title",x:sc,y:B+oe*14,children:se},oe)),i.jsxs("text",{className:"meta",x:sc,y:B+v.length*14+2,...te.squeeze,children:[i.jsx("tspan",{className:"key",children:m.key}),i.jsxs("tspan",{children:[" · ",X]}),i.jsx(A0,{guide:S,text:te.guideText}),E&&i.jsxs("tspan",{className:E.tone,children:[" · ",E.text]}),I&&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 bh=.72;function E1(e){const{fit:n,nodes:r,size:o,pad:l}=e;if(n.k>=bh)return n;const c=r.find(h=>h.state==="claimed")??r.find(h=>h.state==="frontier")??r[0];if(!c)return n;const d=bh;return{k:d,x:o.w/2-(c.x+l+Ue/2)*d,y:o.h/2-(c.y+l+Ve/2)*d}}function M1({y:e,width:n,height:r}){return i.jsxs("g",{className:"quarantine",children:[i.jsx("rect",{x:-20,y:e-30,width:n+40,height:r+18,fill:"url(#hatch-oos)"}),i.jsx("text",{x:-12,y:e-14,children:"Out of scope"})]})}const et=280,Ch=4,I1=220,Rs=e=>Math.round(e/Ch)*Ch;function A1(e){let n=2166136261;for(const r of e)n=Math.imul(n^r.charCodeAt(0),16777619);return()=>{n=n+1831565813|0;let r=Math.imul(n^n>>>15,1|n);return r=r+Math.imul(r^r>>>7,61|r)^r,((r^r>>>14)>>>0)/4294967296}}function Fl(e,n,r,o){return Array.from({length:6},()=>{const l=o*(.5+e()*.7),c=o*(.3+e()*.4);return{x:Rs(n+(e()-.5)*o*.8-l/2),y:Rs(r+(e()-.5)*o*.5-c/2),w:Rs(l),h:Rs(c)}})}function R1(e){const{width:n,height:r,nodes:o}=e,l=A1(e.seed),c=(w,j)=>w+l()*(j-w),d=(w,j)=>!o.some(T=>w>T.x-52&&w<T.x+Ue+28&&j>T.y-52&&j<T.y+Ve+28),h=(n+et*2)*(r+et*2),g=Array.from({length:Math.round(h/9e4)},()=>Fl(l,c(-et,n+et),c(-et,r+et),c(160,360))).flat(),m=[...Fl(l,n+et*.55,r+et*.55,300),...Fl(l,-et*.5,-et*.45,220)],v=[],k=(w,j,T)=>{v.length<I1&&d(j,T)&&v.push({sprite:w,x:Rs(j),y:Rs(T)})};for(let w=0;w<Math.round(h/3e4);w++){const j=c(-et,n+et),T=c(-et,r+et),S=3+Math.floor(l()*5);for(let E=0;E<S;E++)k(l()<.65?"pine":"oak",j+c(-70,70),T+c(-44,44))}for(let w=0;w<Math.round(h/45e3);w++)k(l()<.4?"rock":"tuft",c(-et,n+et),c(-et,r+et));return v.sort((w,j)=>w.y-j.y),{grass:g,water:m,items:v}}const cp={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 L1({name:e}){return i.jsx("symbol",{id:`terrain-${e}`,overflow:"visible",children:cp[e]})}const O1=Object.keys(cp),_1=x.memo(function(n){const{seed:r,width:o,height:l,nodes:c}=n,d=x.useMemo(()=>R1({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(L1,{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))]})}),P1=380;function D1(e){const{selId:n,size:r}=e,o=x.useRef(e);o.current=e;const l=x.useRef(!0);x.useEffect(()=>{if(l.current){l.current=!1;return}const{nodes:c,pad:d,view:h,setView:g,onFocus:m}=o.current,v=n?c.find(I=>I.ticket.id===n):void 0;if(!v||!r.w)return;m();const k=Math.min(1.4,Math.max(h.k,1.05)),w={k,x:r.w/2-(d+v.x+Ue/2)*k,y:r.h/2-(d+v.y+Ve/2)*k};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return g(w);const j=h,T=performance.now();let S=0;const E=I=>{const O=Math.min(1,(I-T)/P1),R=1-(1-O)**3;g({k:j.k+(w.k-j.k)*R,x:j.x+(w.x-j.x)*R,y:j.y+(w.y-j.y)*R}),O<1&&(S=requestAnimationFrame(E))};return S=requestAnimationFrame(E),()=>cancelAnimationFrame(S)},[n])}function B1(e,n){const r=x.useRef(n);r.current=n,x.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 $h(e,n,r){const o=Math.min(3,Math.max(.2,n));return{k:o,x:r.x-(r.x-e.x)*o/e.k,y:r.y-(r.y-e.y)*o/e.k}}const qt=32,z1=1.8;function F1(e){var ie;const{snap:n,selection:r,onSelect:o,preview:l}=e,c=(l==null?void 0:l.tickets)??n.tickets,d=x.useRef(null),[h,g]=x.useState({w:0,h:0});x.useEffect(()=>{const D=d.current;if(!D)return;const q=new ResizeObserver(([ae])=>g({w:ae.contentRect.width,h:ae.contentRect.height}));return q.observe(D),()=>q.disconnect()},[]);const m=x.useMemo(()=>{const D=Af(c,"LR",n.map.mode),q=Af(c,"TB",n.map.mode),ae=Y=>Math.min(h.w/(Y.width+qt*2),h.h/(Y.height+qt*2+16));return ae(D)*z1>=ae(q)?D:q},[c,n.map.mode,h.w,h.h]),v=(D,q)=>Math.min(1.25,Math.max(e.minFit??0,Math.min(h.w/D,h.h/q))),k=x.useMemo(()=>{const D=m.width+qt*2,q=m.height+qt*2+16,Y=m.nodes.some(P=>P.state==="out-of-scope")&&h.h?Math.max(0,h.h/v(D,q)-q):0;if(!Y)return{...m,slack:Y};const U=new Map(m.nodes.map(P=>[P,{...P,y:P.y+(P.state==="out-of-scope"?Y:Y/2)}]));return{...m,slack:Y,nodes:[...U.values()],edges:m.edges.map(P=>({from:U.get(P.from),to:U.get(P.to)})),quarantineY:m.quarantineY+Y,height:m.height+Y}},[m,h.w,h.h,e.minFit]),w=r1(k),j=w.right+qt*2,T=w.bottom+qt*2+16,S=()=>{const D=v(j,T);return{k:D,x:Math.max(0,(h.w-j*D)/2),y:Math.max(0,(h.h-T*D)/2)}},[E,I]=x.useState({k:1,x:0,y:0}),O=x.useRef(!1);x.useEffect(()=>{O.current=!1},[n.map.id]),x.useEffect(()=>{!O.current&&h.w&&I(E1({fit:S(),nodes:k.nodes,size:h,pad:qt}))},[h.w,h.h,j,T,n.map.id]);const R=x.useRef(new Map),X=x.useRef(null),te=D=>{const q=d.current.getBoundingClientRect();return{x:D.clientX-q.left,y:D.clientY-q.top}},B=()=>{var Y;const D=[...R.current.values()],q=D.length>1?{x:(D[0].x+D[1].x)/2,y:(D[0].y+D[1].y)/2}:D[0],ae=D.length>1?Math.hypot(D[0].x-D[1].x,D[0].y-D[1].y):0;X.current={view:E,dist:ae,mid:q,moved:((Y=X.current)==null?void 0:Y.moved)??!1}};B1(d,(D,q)=>{O.current=!0,I(ae=>$h(ae,ae.k*D,q))});const se=tn(5e3),oe=pc(e.leases,n.map.id),G=xc(),ve=(ie=$c())==null?void 0:ie.waiting,Be=new Map(e.sessions.filter(D=>Zt(D)&&D.ticketId).map(D=>[D.ticketId,D])),$e=(r==null?void 0:r.kind)==="ticket"?r.id:void 0;return D1({selId:$e,nodes:k.nodes,size:h,pad:qt,view:E,setView:I,onFocus:()=>O.current=!0}),i.jsxs("div",{className:"graph-box",ref:d,onPointerDown:D=>{R.current.set(D.pointerId,te(D)),R.current.size===1&&(X.current=null),B()},onPointerMove:D=>{var Y;if(!R.current.has(D.pointerId)||!X.current)return;R.current.set(D.pointerId,te(D));const q=X.current,ae=[...R.current.values()];if(ae.length>1){const U={x:(ae[0].x+ae[1].x)/2,y:(ae[0].y+ae[1].y)/2},P=Math.hypot(ae[0].x-ae[1].x,ae[0].y-ae[1].y),W=$h(q.view,q.view.k*P/(q.dist||P),q.mid);I({...W,x:W.x+U.x-q.mid.x,y:W.y+U.y-q.mid.y}),q.moved=!0}else{const U=ae[0].x-q.mid.x,P=ae[0].y-q.mid.y;if(!q.moved&&Math.hypot(U,P)<5)return;q.moved||(Y=d.current)==null||Y.setPointerCapture(D.pointerId),q.moved=!0,I({...q.view,x:q.view.x+U,y:q.view.y+P})}O.current=!0},onPointerUp:D=>{R.current.delete(D.pointerId),R.current.size&&B()},onPointerCancel:D=>R.current.delete(D.pointerId),onClickCapture:D=>{var q;(q=X.current)!=null&&q.moved&&(D.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(${qt} ${qt})`,children:[i.jsx(_1,{seed:n.map.id,width:j,height:T,nodes:k.nodes}),k.nodes.some(D=>D.state==="out-of-scope")&&i.jsx(M1,{y:k.quarantineY,width:k.width,height:k.quarantineH}),i.jsx(m1,{snap:n,tickets:c,direction:k.direction,nodes:k.nodes,edges:k.edges,preview:l}),i.jsx(l1,{trails:o1(k,w)}),k.nodes.length>0&&i.jsx(a1,{x:w.x,y:w.y}),k.nodes.map(D=>{var q;return i.jsx(T1,{n:D,session:Be.get(D.ticket.id),stalled:!!oe.get(D.ticket.id)&&Lo(oe.get(D.ticket.id),se)!=="live",flag:$x(Bs.ticket(G,n.map.id,D.ticket.id)),selected:$e===D.ticket.id,onSelect:o,mark:l==null?void 0:l.marks.get(D.ticket.id),frozen:l==null?void 0:l.frozen.has(D.ticket.id),needs:(q=ve==null?void 0:ve.find(ae=>ae.mapId===n.map.id&&ae.ticketId===D.ticket.id))==null?void 0:q.tier},D.ticket.id)})]})})]}),i.jsx("button",{className:"btn sm fit-btn","data-tip":"Fit the whole trail in view",onPointerDown:D=>D.stopPropagation(),onClick:D=>{D.stopPropagation(),O.current=!0,I(S())},children:"Fit"})]})}const Ul=[["decided","Done"],["claimed","Working"],["frontier","Ready"],["blocked","Backlog"],["parked","Parked"],["out-of-scope","Cancelled"]],Th=[["verifying","Verifying"],["rework","Rework"],["held","Blocked"]];function U1({snap:e,sessions:n}){const r=Yh(e),o=m=>r[m],l=n.filter(Sm).length,c=Sy(e),d=Math.max(1,...c.map(m=>m.open+m.closed)),g=(e.map.verification??"off")!=="off"||Th.some(([m])=>o(m))?[...Ul.slice(0,2),...Th,...Ul.slice(2)]:Ul;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(Ke,{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:Pi[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 W1(e){const[n,r]=x.useState(!1);return i.jsxs("div",{className:n?"status-drawer open":"status-drawer",children:[i.jsxs("button",{type:"button",className:"status-toggle","aria-expanded":n,onPointerDown:o=>o.stopPropagation(),onClick:()=>r(!n),children:["Summary ",i.jsx("span",{className:"caret",children:n?"▾":"▴"})]}),i.jsx(U1,{snap:e.snap,sessions:e.sessions})]})}function H1({planOnly:e,verifies:n}){const r=[["frontier","Ready"],["claimed","Working"],...n?[["verifying","Verifying"],["rework","Rework"],["held","Blocked"]]:[],["stalled","Stalled"],["blocked","Backlog"],["decided","Done"],...e?[["parked","Parked"]]:[],["out-of-scope","Cancelled"],["waiting","Waiting on you"]];return i.jsxs("div",{className:"legend",children:[r.map(([o,l])=>i.jsxs("span",{className:`lg st-${o}`,children:[i.jsx("i",{}),l]},o)),i.jsx("span",{className:"lg hitl",children:"● needs human"})]})}function V1(e){var o,l;const{snap:n,selection:r}=e.api;return i.jsxs(We,{as:"main",className:"zone map-zone",style:{gridArea:"map"},children:[n&&i.jsx(zj,{}),(o=e.trail)==null?void 0:o.banner,i.jsxs("div",{className:"map-area",children:[n&&!e.compact&&i.jsx(W1,{snap:n,sessions:e.sessions}),n?i.jsx(F1,{snap:n,sessions:e.sessions,leases:e.api.leases,selection:r,onSelect:e.onSelect,minFit:e.minFit,preview:(l=e.trail)==null?void 0:l.preview}):i.jsxs("div",{className:"nomap",children:[i.jsx(Hj,{}),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"'})]}),n&&e.compact&&i.jsx(H1,{planOnly:n.map.mode==="plan-only",verifies:(n.map.verification??"off")!=="off"})]})]})}const K1=[["home","Inbox"],["map","Map"],["ticket","Ticket"],["activity","Activity"],["plan","Plan"]];function G1(e){const{tab:n,covered:r,pending:o}=e;return i.jsx("nav",{className:"tabbar",children:K1.map(([l,c])=>i.jsxs("button",{className:n===l&&!r?"on":"",onClick:()=>e.onPick(l),children:[c,l==="home"&&o>0&&i.jsx(Zn,{n:o,urgent:!0,pop:!0},o)]},l))})}function q1(e){const n={home:e.projects?i.jsxs("div",{className:"phone-home",children:[e.projects,e.inbox]}):e.inbox,map:e.map,ticket:i.jsx(We,{className:"zone",children:e.ticket}),activity:i.jsx(We,{className:"zone",children:e.activity}),plan:e.plan};return i.jsx("main",{className:"phone-view",children:e.decisions||n[e.tab]})}const Eh={settingsPage:!0},Mh=()=>Gm(new URLSearchParams(location.search).get("settings")),Ih=()=>{var e;return!!((e=history.state)!=null&&e.settingsPage)};function Q1(){const[e,n]=x.useState(Mh);x.useEffect(()=>{e&&!Ih()&&(history.replaceState(null,"",fo(location.href,null)),history.pushState(Eh,"",fo(location.href,e)));const c=()=>n(Mh());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(Eh,"",d),n(c)},o=()=>{e&&(n(null),Ih()?history.back():history.replaceState(null,"",fo(location.href,null)))},l=c=>r(Gm(c??"")??{});return{route:e,open:l,show:r,close:o,toggle:()=>e?o():l()}}function Y1(e,n){const{activity:r,selection:o,setSelection:l,actions:c}=e,[d,h]=x.useState("ticket"),[g,m]=x.useState("home"),[v,k]=x.useState(0),[w,j]=x.useState(null),[T,S]=x.useState(!1),E=B=>{S(!1),j({focus:B})},I=()=>{j(null),S(B=>!B)};x.useEffect(()=>{const B=r.sessions.find(se=>se.id===e.chatSession);!o&&(B!=null&&B.ticketId)&&B.mapId===e.mapId&&l({kind:"ticket",id:B.ticketId})},[e.chatSession,e.mapId]);const O=B=>{l(B),B&&(n==="laptop"&&h("ticket"),n==="mobile"&&m("ticket"))},R=(B,se,oe)=>{oe&&oe!==e.mapId&&c.selectMap(oe),c.openChat(B);const G=r.sessions.find(ve=>ve.id===B);se&&(G==null?void 0:G.mapId)===(oe??e.mapId)&&l({kind:"ticket",id:se}),n==="mobile"&&(m("home"),k(ve=>ve+1))};return{sideTab:d,setSideTab:h,phoneTab:g,setPhoneTab:m,convRequest:v,decisionsView:w,setDecisionsView:j,openDecisions:E,statsOpen:T,setStatsOpen:S,toggleStats:I,select:O,openChat:R,showChat:(B,se,oe)=>{R(B,se,oe),k(G=>G+1)},openTicket:(B,se)=>{B!==e.mapId&&c.selectMap(B),l({kind:"ticket",id:se}),j(null),n==="laptop"&&h("ticket"),n==="mobile"&&m("ticket")}}}function J1(e,n){x.useEffect(()=>{document.title=`${ge.name}: ${e?`(${e}) `:""}${n??"No trail"}`},[e,n])}function X1(e){const[n,r]=x.useState("…");return x.useEffect(()=>{fetch(`${Ne()}/list`).then(o=>o.json()).then(o=>{var c;const l=o.root.split("/").filter(Boolean);r((c=l[l.length-1])!=null&&c.startsWith(".")?l[l.length-2]??"repo":l[l.length-1]??"repo")}).catch(()=>r("repo"))},[e]),n}function Z1(e,n){return x.useMemo(()=>{const r=e.sessions.filter(l=>l.mapId===n),o=new Set(e.sessions.filter(l=>l.mapId!==n).map(l=>l.id));return{...e,sessions:r,feed:e.feed.filter(l=>!l.sessionId||!o.has(l.sessionId))}},[e,n])}function eN({text:e}){return e.trim()?i.jsx("div",{className:"brief-prose",children:e.split(`
138
+ `).map((n,r)=>i.jsx("p",{children:n.split(/(`[^`]+`|\/?\b[\w.-]+\/[\w./-]+\b)/g).map((o,l)=>l%2===1?i.jsx("code",{children:o.replace(/`/g,"")},l):o)},r))}):i.jsx(Ie,{children:"Not covered"})}const Ah=["summary","productContext","existing","conventions","dataModel","api","risks"];function tN(e){const{brief:n}=e,[r,o]=x.useState(!1),[l,c]=x.useState("");x.useEffect(()=>{const m=v=>v.key==="Escape"&&e.onClose();return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[e]);const d=n.sections,h=Ah.filter(m=>d[m].trim()),g=Ah.filter(m=>!d[m].trim());return i.jsx("div",{className:"scrim",onClick:e.onClose,children:i.jsxs(We,{as:"div",className:"dialog brief-dialog",onClick:m=>m.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:"Discovery brief"}),i.jsx("span",{className:"t-meta",children:nN(n)})]}),i.jsxs("div",{className:"brief-body",children:[h.map(m=>i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:Ii[m]}),i.jsx(eN,{text:d[m]}),(m==="conventions"||m==="productContext")&&d[m].trim()&&i.jsx(wc,{draft:()=>({title:`${Ii[m]}: ${d[m].split(`
139
+ `)[0].slice(0,80)}`,body:d[m],kind:m==="conventions"?"convention":"business-rule",sources:[`brief:${n.mapId}`]})})]},m)),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:Ii.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(ee,{parts:[{text:m.id,code:!0}]})]},m.id))}):i.jsx(Ie,{children:"None listed"})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:Ii.openQuestions}),d.openQuestions.length?i.jsx("ul",{className:"brief-list",children:d.openQuestions.map(m=>i.jsx("li",{children:m},m))}):i.jsx(Ie,{children:"None"})]}),g.length>0&&i.jsxs("p",{className:"t-meta brief-empty",children:["Nothing noted on ",g.map(m=>Ii[m].toLowerCase()).join(", "),"."]}),n.note&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Your last request"}),i.jsx("p",{children:n.note})]})]}),r&&i.jsx(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:[n.status==="submitted"&&!r&&i.jsxs(i.Fragment,{children:[i.jsx(K,{onClick:()=>o(!0),children:"Request changes"}),i.jsx(K,{variant:"primary",onClick:e.onAccept,children:"Accept brief"})]}),r&&i.jsxs(i.Fragment,{children:[i.jsx(K,{variant:"ghost",onClick:()=>o(!1),children:"Back"}),i.jsx(K,{variant:"primary",disabled:!l.trim(),onClick:()=>e.onRequestChanges(l.trim()),children:"Send to the agent"})]}),i.jsx(K,{variant:"ghost",onClick:e.onClose,children:"Close"})]})]})})}function nN(e){if(e.status==="draft")return"Not submitted yet";const n=[e.status.replace("-"," ")];return e.author&&n.push(`by ${e.author}`),e.submittedAt&&n.push(`${en(Date.now()-e.submittedAt)} ago`),n.join(" · ")}function sN({brief:e,onReview:n}){return e.status!=="submitted"?null:i.jsx("div",{className:"brief-card",children:i.jsx(Re,{edge:"attention",title:"Discovery brief ready for your review",context:i.jsx(ee,{parts:["Discovery brief",e.author&&`by ${e.author}`]}),detail:e.sections.summary.split(`
140
+ `)[0],detailText:e.sections.summary,onOpen:n})})}const iN={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 rN({brief:e,onReview:n}){if(e.status==="accepted")return null;const[r,o]=iN[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(Hi,{text:"Before implementation, an agent maps the existing system: the files involved, conventions, data and API impact, risks and assumptions. You accept the brief or ask for changes; task, execute and prototype tickets can't be claimed until you accept it."}),i.jsx(K,{size:"sm",variant:e.status==="submitted"?"primary":"ghost",onClick:n,children:e.status==="submitted"?"Review brief":"Open brief"})]})}const Rh=`${Ne()}/briefs`;function oN(e){const n=e==null?void 0:e.map.id,[r,o]=x.useState(null),[l,c]=x.useState(),d=x.useCallback(()=>{if(!n)return o(null);fetch(`${Rh}?mapId=${encodeURIComponent(n)}`).then(v=>v.ok?v.json():{brief:null}).then(v=>o(v.brief)).catch(()=>o(null))},[n]),h=e==null?void 0:e.tickets.reduce((v,k)=>Math.max(v,k.updatedAt),e.map.updatedAt);x.useEffect(d,[d,h]),x.useEffect(()=>hn(v=>v.startsWith("briefs/")&&d()),[d]);const g=(v,k)=>fetch(`${Rh}/${v}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:n,note:k})}).then(async w=>{const j=await w.json().catch(()=>({}));if(!w.ok||!j.brief)throw new Error(j.error??`HTTP ${w.status}`);c(void 0),o(j.brief)}),m=(v,k)=>g(v,k).then(()=>!0,w=>(c(w.message),!1));return{brief:r,error:l,accept:()=>m("accept"),requestChanges:v=>m("request-changes",v)}}function aN(e){const n=oN(e),[r,o]=x.useState(!1),l=()=>o(!0),c=n.brief,d=c==null?void 0:c.sections;return{review:l,briefText:d?[d.existing,d.conventions,d.dataModel,d.api].join(`
141
+ `):"",banner:c&&i.jsx(rN,{brief:c,onReview:l}),inboxCard:c&&i.jsx(sN,{brief:c,onReview:l}),dialog:c&&r&&i.jsx(tN,{brief:c,error:n.error,onAccept:()=>void n.accept().then(h=>h&&o(!1)),onRequestChanges:h=>void n.requestChanges(h).then(g=>g&&o(!1)),onClose:()=>o(!1)})}}function lN({reroute:e,onReview:n}){var h;const r=e.kind==="challenge-destination",o=((h=e.frozen)==null?void 0:h.length)??0,l=r?"wrong mountain?":"proposes a new plan",c=o?` ${o} ticket${o===1?" is":"s are"} closed until you decide.`:"",d=`${e.reason.replace(/\.$/,"")}.${c}`;return i.jsxs("div",{className:"reroute-banner map-banner edge-attention",role:"status",title:d,children:[i.jsxs("span",{className:"mb-text",children:[i.jsxs("span",{className:"mb-lead",children:[e.by," ",l]}),i.jsx("span",{className:"t-meta",children:d})]}),i.jsx(Hi,{text:"An agent found that an assumption or the plan no longer holds and proposes changes. The map shows them: dashed outlines are tickets it adds, struck ones it cancels, ❄ marks tickets frozen until you approve or reject. Nothing changes until you decide."}),i.jsx(K,{size:"sm",variant:"primary",onClick:n,children:"Review"})]})}const cN={"already-exists":"The work already exists","wrong-problem":"The trail targets the wrong problem",rescope:"The trail should be rescoped"};function uN(e,n){var r;switch(e.op){case"add_ticket":{const o=(r=e.blockedBy)!=null&&r.length?`after ${e.blockedBy.map(n).join(", ")}`:void 0;return{verb:"Add",text:e.title,detail:[`new ${e.type} ticket`,o].filter(Boolean).join(" · ")}}case"cancel_ticket":return{verb:"Cancel",text:n(e.ticket),detail:e.reason};case"edit_ticket":return{verb:"Revise",text:n(e.ticket),detail:e.title?`New title: ${e.title}`:"New description"};case"rewire":return{verb:"Rewire",text:n(e.ticket),detail:dN(e,n)};case"supersede_decision":return{verb:"Supersede",text:e.decision,detail:`${e.answer}. ${e.rationale}`};case"update_destination":return{verb:"Destination",text:e.text};case"add_unspecified":return{verb:"Not yet specified",text:e.text};case"add_out_of_scope":return{verb:"Out of scope",text:e.text};case"reopen":return{verb:"Reopen",text:n(e.ticket),detail:`Back in the queue: ${e.reason}`};default:return e}}function dN(e,n){var o,l;return[...(o=e.addBlockedBy)!=null&&o.length?[`now also after ${e.addBlockedBy.map(n).join(", ")}`]:[],...(l=e.removeBlockedBy)!=null&&l.length?[`no longer after ${e.removeBlockedBy.map(n).join(", ")}`]:[]].join(" · ")}const fN=new Set(["cancel_ticket","update_destination"]);function hN({change:e,name:n}){const r=uN(e,n);return i.jsx(Re,{as:"li",className:`reroute-change op-${e.op}`,edge:fN.has(e.op)?"attention":"neutral",title:r.text,titleText:r.text,context:i.jsx(ee,{parts:[{text:r.verb,strong:!0}]}),detail:r.detail,detailText:r.detail})}function mN(e){const{reason:n,destination:r}=e;return i.jsxs("section",{className:"reroute-destination",children:[n&&i.jsx("p",{className:"reroute-destination-why",children:cN[n]}),r&&i.jsxs("div",{className:"reroute-destination-diff",children:[i.jsxs("div",{children:[i.jsx("span",{className:"mono-label",children:"Destination now"}),i.jsx("p",{className:"before",children:r.before||"—"})]}),i.jsxs("div",{children:[i.jsx("span",{className:"mono-label",children:"Suggested destination"}),i.jsx("p",{className:"after",children:r.after})]})]})]})}function pN(e,n){const r=new Map(e.tickets.map(l=>[l.id,l.key])),o=new Map(n.flatMap(l=>l.op==="add_ticket"?[[l.ref,l.title]]:[]));return l=>{const c=r.get(l);if(c)return c;const d=o.get(l);return d?`new: ${d}`:l}}function gN(e){var w,j;const{reroute:n,snap:r}=e,[o,l]=x.useState("");x.useEffect(()=>{const T=S=>S.key==="Escape"&&e.onClose();return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[e]);const c=pN(r,n.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=n.invalidates.map(T=>g.find(S=>S.id===T)??{id:T,text:""}),v=n.status==="pending",k=n.kind==="challenge-destination";return i.jsx("div",{className:"scrim",onClick:e.onClose,children:i.jsxs(We,{as:"div",className:"dialog reroute-dialog",onClick:T=>T.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:k?"Destination challenged":"Reroute proposal"}),i.jsx(ee,{parts:[{text:n.id,code:!0},n.status,`by ${n.by}`,`${en(Date.now()-n.at)} ago`]})]}),i.jsxs("div",{className:"reroute-body",children:[k&&i.jsx(mN,{reason:n.destinationReason,destination:(w=n.diff)==null?void 0:w.destination}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Why"}),i.jsx("p",{children:n.reason})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Evidence"}),i.jsx("p",{className:"reroute-evidence",children:n.evidence})]}),m.length>0&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Assumptions it invalidates"}),i.jsx("ul",{className:"item-list",children:m.map(T=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:T.text}),i.jsx(ee,{parts:[{text:T.id,code:!0}]})]},T.id))})]}),i.jsxs("section",{children:[i.jsxs("h3",{className:"mono-label",children:["Changes · ",n.changes.length]}),i.jsx("ul",{className:"reroute-changes row-list",children:n.changes.map((T,S)=>i.jsx(hN,{change:T,name:h},S))})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Closed until you decide"}),(j=n.frozen)!=null&&j.length?i.jsx("ul",{className:"item-list",children:n.frozen.map(T=>i.jsx("li",{className:"item-text",children:h(T)},T))}):i.jsx(Ie,{children:"No tickets closed"})]}),n.note&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Your note"}),i.jsx("p",{children:n.note})]})]}),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 Lh=`${Ne()}/reroutes`;function vN(e){const n=e==null?void 0:e.map.id,[r,o]=x.useState([]),[l,c]=x.useState(),d=x.useCallback(()=>{if(!n)return o([]);fetch(`${Lh}?map=${encodeURIComponent(n)}`).then(m=>m.ok?m.json():{reroutes:[]}).then(m=>o(m.reroutes)).catch(()=>o([]))},[n]),h=e==null?void 0:e.tickets.reduce((m,v)=>Math.max(m,v.updatedAt),e.map.updatedAt);x.useEffect(d,[d,h]),x.useEffect(()=>Mx("reroute",m=>{m.mapId===n&&d()}),[d,n]);const g=async(m,v,k)=>{var S;const w=await fetch(`${Lh}/${m}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:n,id:v,note:k})}),j=await w.json().catch(()=>({}));if(w.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 ${w.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 yN(e,n){const r=vN(e),[o,l]=x.useState(),c=r.reroutes.find(m=>m.id===o),d=c!=null&&c.diff?c:r.pending,h=()=>{l(void 0),r.clearError()},g=m=>m&&h();return{banner:r.pending&&i.jsx(lN,{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)&&(n==null||n(m)),l(v)},dialog:e&&c&&i.jsx(gN,{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 kN(e,n){const r=aN(e),o=yN(e,n);return{briefText:r.briefText,inboxCard:r.inboxCard,review:r.review,banner:i.jsxs(i.Fragment,{children:[r.banner,o.banner]}),preview:o.preview,openReroute:o.openReroute,dialog:i.jsxs(i.Fragment,{children:[r.dialog,o.dialog]})}}function xN(){const e=new URL(location.href);e.searchParams.has(_s)&&(e.searchParams.delete(_s),history.replaceState(history.state,"",e))}function wN(e,n){return e.kind!=="question"||n.pending.some(r=>r.id===e.ref)}function jN(e){const[n,r]=x.useState(()=>new URLSearchParams(location.search).get(_s)??void 0),{loaded:o,view:l,activity:c,handlers:d,showChat:h}=e;return x.useEffect(()=>{if(!n||!o||!l)return;const g=l.items.find(v=>v.id===n);if(g&&!wN(g,c)||(r(void 0),xN(),!g))return;_m(g,{...d,openQuestion:v=>{const k=c.pending.find(w=>w.id===v);k&&h(k.sessionId,k.ticketId)}})},[n,o,l,c,d,h]),{request:x.useCallback(g=>r(g),[])}}function SN(e){const{api:n,nav:r}=e,o=Dm(n.allSnaps);$j(o.view);const l=m=>m&&n.actions.selectMap(m),c={openTicket:r.openTicket,openKnowledge:()=>e.knowledge.setOpen(!0),openBrief:m=>m===n.mapId?e.reviewBrief():l(m),openReroute:e.openReroute??(m=>m.ticketId?r.openTicket(m.mapId,m.ticketId):l(m.mapId)),selectTrail:l,openGuides:e.openGuides},d=o.view,h=jN({loaded:n.loaded,view:d,activity:n.activity,handlers:c,showChat:r.showChat});return{attention:o,handlers:c,header:d&&i.jsx(Sj,{view:d,onFocus:m=>void o.savePrefs({...d.prefs,focusUntil:m})}),link:h}}function NN(e){const{d:n,snap:r}=e,[o,l]=x.useState(!1),[c,d]=x.useState(""),[h,g]=x.useState("");x.useEffect(()=>{l(!1),d(""),g("")},[n.id,n.mapId]);const m=ry(e.all.filter(j=>j.mapId===n.mapId),n.id),v=Ui(n),k=n.ticketId?r==null?void 0:r.tickets.find(j=>j.id===n.ticketId):void 0,w=Date.now();return i.jsxs("div",{className:"detail dv-d",children:[i.jsxs("div",{className:"d-head",children:[i.jsx("span",{className:"key",children:n.id}),i.jsx(Dn,{tone:"state",className:`dv-st-${v}`,children:v}),i.jsx(ee,{parts:[bx(n.decidedAt),`${en(w-n.decidedAt)} ago`]})]}),i.jsx("h3",{className:"t-heading",children:n.question}),i.jsxs("div",{className:"resolution",children:[i.jsx(ko,{parts:["Decision"]}),i.jsx("p",{children:n.answer})]}),i.jsxs("dl",{className:"facts",children:[i.jsx("dt",{children:"Trail"}),i.jsx("dd",{children:r?`${r.map.key} ${r.map.title}`:n.mapId}),i.jsx("dt",{children:"Ticket"}),i.jsx("dd",{children:n.ticketId?i.jsxs("button",{className:"link",onClick:()=>e.onOpenTicket(n.mapId,n.ticketId),children:[n.ticketKey," ",(k==null?void 0:k.title)??""," · open in trail ›"]}):"—"}),i.jsx("dt",{children:"Decided by"}),i.jsx("dd",{children:n.decidedBy}),n.participants.length>1&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Participants"}),i.jsx("dd",{children:n.participants.map(j=>j.name??j.id).join(", ")})]}),i.jsx("dt",{children:"Source"}),i.jsxs("dd",{children:[On[n.source.kind].label,n.source.url&&i.jsxs(i.Fragment,{children:[" · ",i.jsx("a",{href:n.source.url,target:"_blank",rel:"noreferrer",children:n.source.label??"link"})]}),!n.source.url&&n.source.label&&` · ${n.source.label}`,n.source.ref&&i.jsxs("span",{className:"ref",children:[" ",n.source.ref]})]})]}),n.alternatives.length>0&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Alternatives"}),i.jsx("ul",{className:"dv-alts",children:n.alternatives.map(j=>i.jsx("li",{children:j},j))})]}),n.rationale&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Rationale"}),i.jsx("p",{children:n.rationale})]}),m.length>1&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Supersession"}),i.jsx("ol",{className:"dv-chain",children:m.map(j=>i.jsx("li",{className:`${j.id===n.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(ee,{parts:[j.decidedBy,Ds(j.decidedAt)]})]})},j.id))})]}),i.jsxs("div",{className:"actions",children:[i.jsx(wc,{draft:()=>({title:n.summary||n.question,body:[n.answer,n.rationale&&`Why: ${n.rationale}`].filter(Boolean).join(`
142
+
143
+ `),kind:"product-decision",sources:[`decision:${n.id}`,...n.ticketKey?[`ticket:${n.ticketKey}`]:[]]})}),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(Rt,{as:"form",tone:"inset",className:"inline-form",onSubmit:j=>{j.preventDefault(),c.trim()&&(e.onSupersede(n,{answer:c.trim(),rationale:h.trim(),alternatives:[n.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:n.transcript.length})]}),n.transcript.length?i.jsx("div",{className:"dv-transcript comms-log",children:n.transcript.map((j,T)=>i.jsxs("div",{className:`msg from-${j.from} voice-${j.from==="human"?"human":"agent"}`,children:[i.jsx(ko,{parts:[j.author,mc(j.at)]}),i.jsx("div",{className:"msg-text",children:j.text})]},T))}):i.jsx(Ie,{children:"None recorded"})]})]})}function At(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 bN(e){const{filter:n,set:r,all:o}=e,l=c=>o.filter(c).length;return e.compact?i.jsxs("div",{className:"dv-filters compact",children:[i.jsx(ct,{compact:!0,"aria-label":"Trail",value:n.mapId??"",onChange:c=>r({mapId:c||void 0}),options:[{value:"",label:"All trails"},...e.trails.map(c=>({value:c.map.id,label:`${c.map.key} ${c.map.title}`}))]}),i.jsx(ct,{compact:!0,"aria-label":"Source",value:n.source??"",onChange:c=>r({source:c||void 0}),options:[{value:"",label:"All sources"},...go.map(c=>({value:c,label:On[c].label}))]}),i.jsx(ct,{compact:!0,"aria-label":"Decided by",value:n.decidedBy??"",onChange:c=>r({decidedBy:c||void 0}),options:[{value:"",label:"Anyone"},...e.people.map(c=>({value:c,label:c}))]}),i.jsx(ct,{compact:!0,"aria-label":"Status",value:n.status??"",onChange:c=>r({status:c||void 0}),options:[{value:"",label:"Any status"},{value:"active",label:"Active"},{value:"superseded",label:"Superseded"}]})]}):i.jsxs("aside",{className:"dv-filters",children:[i.jsx("h3",{className:"mono-label",children:"Trail"}),i.jsxs("ul",{children:[i.jsx(At,{on:!n.mapId,label:"All trails",n:o.length,onClick:()=>r({mapId:void 0})}),e.trails.map(c=>i.jsx(At,{on:n.mapId===c.map.id,label:`${c.map.key} ${c.map.title}`,n:l(d=>d.mapId===c.map.id),onClick:()=>r({mapId:c.map.id})},c.map.id))]}),i.jsx("h3",{className:"mono-label",children:"Source"}),i.jsxs("ul",{children:[i.jsx(At,{on:!n.source,label:"All",n:o.length,onClick:()=>r({source:void 0})}),go.map(c=>i.jsx(At,{cls:`src-${c}`,on:n.source===c,label:On[c].label,n:l(d=>d.source.kind===c),onClick:()=>r({source:n.source===c?void 0:c})},c))]}),i.jsx("h3",{className:"mono-label",children:"Made by"}),i.jsxs("ul",{children:[i.jsx(At,{on:!n.madeBy,label:"Anyone",n:o.length,onClick:()=>r({madeBy:void 0})}),i.jsx(At,{on:n.madeBy==="agent",label:"Agents, on their own",n:l(c=>_i(c)==="agent"),onClick:()=>r({madeBy:n.madeBy==="agent"?void 0:"agent"})}),i.jsx(At,{on:n.madeBy==="human",label:"People",n:l(c=>_i(c)==="human"),onClick:()=>r({madeBy:n.madeBy==="human"?void 0:"human"})})]}),i.jsx("h3",{className:"mono-label",children:"Decided by"}),i.jsxs("ul",{children:[i.jsx(At,{on:!n.decidedBy,label:"Anyone",n:o.length,onClick:()=>r({decidedBy:void 0})}),e.people.map(c=>i.jsx(At,{on:n.decidedBy===c,label:c,n:l(d=>d.decidedBy===c),onClick:()=>r({decidedBy:n.decidedBy===c?void 0:c})},c))]}),i.jsx("h3",{className:"mono-label",children:"Status"}),i.jsxs("ul",{children:[i.jsx(At,{on:!n.status,label:"Any",n:o.length,onClick:()=>r({status:void 0})}),i.jsx(At,{on:n.status==="active",label:"Active",n:l(c=>!c.supersededBy),onClick:()=>r({status:n.status==="active"?void 0:"active"})}),i.jsx(At,{on:n.status==="superseded",label:"Superseded",n:l(c=>!!c.supersededBy),onClick:()=>r({status:n.status==="superseded"?void 0:"superseded"})})]})]})}function CN(e){if(Ui(e)==="superseded")return`Replaced by ${e.supersededBy}`;if(e.supersedes)return`Replaces ${e.supersedes}`}function $N(e){const{d:n}=e,r=Ui(n);return i.jsxs(i.Fragment,{children:[e.newDay&&i.jsx("li",{className:"dv-day t-label",children:Ds(n.decidedAt)}),i.jsx(Re,{as:"li",className:`dv-row ${r}`,selected:e.on,onOpen:e.onClick,title:n.question,titleText:n.question,trailing:mc(n.decidedAt),context:i.jsx(ee,{parts:[{text:n.id,code:!0},n.ticketKey&&{text:n.ticketKey,code:!0},e.showTrail&&e.trail,n.decidedBy,On[n.source.kind].label,CN(n)]}),detail:n.summary,detailText:n.summary})]})}function TN(e){const{rows:n,current:r}=e;return i.jsx("ol",{className:"dv-list","aria-label":"Logbook",children:n.length?n.map((o,l)=>{var c;return i.jsx($N,{d:o,newDay:l===0||Ds(n[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(Ie,{children:"No decisions"})})}function EN({stats:e}){return i.jsxs("span",{className:"dv-readouts",children:[i.jsx(Jt,{layout:"start",label:"Active",value:e.active}),i.jsx(Jt,{layout:"start",label:"Superseded",value:e.superseded}),i.jsx(Jt,{layout:"start",label:"Last 24h",value:e.last24h}),i.jsx(Jt,{layout:"start",label:"Human",value:`${e.total?Math.round(e.human/e.total*100):0}%`}),i.jsx(ee,{className:"dv-src-mix",parts:go.filter(n=>e.bySource[n]).map(n=>`${On[n].label} ${e.bySource[n]}`)})]})}function MN(e){const{filter:n}=e,o=Object.values(n).filter(Boolean).length-(n.query?1:0),l=e.filtersOpen||o>0;return i.jsxs("div",{className:"dv-search",children:[i.jsx("input",{type:"search",placeholder:"Search decisions",value:n.query??"",onChange:c=>e.set({query:c.target.value})}),e.showToggle&&i.jsxs("button",{className:`chip ${l?"on":""}`,onClick:e.onToggle,children:["Filters",o>0?` · ${o}`:""]})]})}function IN(e){const{api:n,bp:r}=e,o=n.decisions,[l,c]=x.useState({}),[d,h]=x.useState(e.focus),[g,m]=x.useState(!1);x.useEffect(()=>h(e.focus),[e.focus]),x.useEffect(()=>{const O=R=>{R.key==="Escape"&&(r==="mobile"&&d?h(void 0):e.onClose())};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[r,d,e]);const v=x.useMemo(()=>$y(o,l),[o,l]),k=x.useMemo(()=>Ty(o),[o]),w=o.find(O=>O.id===d&&(!l.mapId||O.mapId===l.mapId))??(r==="mobile"?void 0:v[0]),j=x.useMemo(()=>Object.values(n.allSnaps).sort((O,R)=>R.map.createdAt-O.map.createdAt),[n.allSnaps]),T=x.useMemo(()=>[...new Set(o.map(O=>O.decidedBy))].sort(),[o]),S=O=>c(R=>({...R,...O})),E=()=>{const O=Object.fromEntries(j.map(R=>[R.map.id,{key:R.map.key,title:R.map.title}]));pm(`${ge.slug}-decisions-${Ds(Date.now())}.md`,By(v,O,{title:`${ge.name} decisions`}))},I=r==="mobile"&&!!w;return i.jsxs(We,{className:`zone decisions-view dv-${r}`,children:[i.jsxs("header",{className:"dv-head",children:[I?i.jsx("button",{className:"back",onClick:()=>h(void 0),children:"‹ Decisions"}):i.jsxs(Ke,{as:"h2",children:["Decisions ",v.length!==o.length&&i.jsx("span",{className:"n",children:`${v.length}/${o.length}`})]}),r!=="mobile"&&i.jsx(EN,{stats:k}),i.jsxs("span",{className:"dv-head-right",children:[!I&&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:"×"})]})]}),!I&&i.jsx(MN,{filter:l,set:S,showToggle:r!=="wide",filtersOpen:g,onToggle:()=>m(O=>!O)}),i.jsxs("div",{className:"dv-body",children:[(r==="wide"||g&&!I)&&i.jsx(bN,{filter:l,set:S,all:o,trails:j,people:T,compact:r!=="wide"}),!I&&i.jsx(TN,{rows:v,current:w,snaps:n.allSnaps,showTrail:r==="wide",onSelect:h}),(r!=="mobile"||w)&&i.jsx("div",{className:"dv-detail",children:w?i.jsx(NN,{d:w,all:o,snap:n.allSnaps[w.mapId],onSelect:h,onOpenTicket:e.onOpenTicket,onSupersede:n.actions.supersede}):i.jsx(Ie,{children:"No decision selected"})})]})]})}function AN({api:e,bp:n,nav:r}){return r.statsOpen?i.jsx(_S,{api:e,bp:n,onClose:()=>r.setStatsOpen(!1)}):r.decisionsView?i.jsx(IN,{api:e,bp:n,focus:r.decisionsView.focus,onClose:()=>r.setDecisionsView(null),onOpenTicket:r.openTicket}):null}function RN(e,n,r){const o=rp(),[l,c]=x.useState(()=>new URLSearchParams(location.search).has("projects")),d=l&&o.many&&i.jsx(jS,{projects:o,bp:e,onClose:()=>c(!1),onItemHere:r});return{projects:o,overview:d,openOverview:()=>{n.setDecisionsView(null),n.setStatsOpen(!1),c(!0)}}}function up({activity:e,onTicket:n}){const r=e.feed.slice(-120).reverse();return r.length?i.jsx("div",{className:"log",children:r.map(o=>i.jsxs("div",{className:`log-row lv-${o.level} src-${o.source} ${o.signal?"signal":""}`,onClick:()=>o.ticketId&&n(o.ticketId),children:[i.jsx("span",{className:"t t-meta",children:hc(o.at)}),i.jsxs("span",{className:"src t-meta",children:[o.source==="system"&&i.jsx(Nm,{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(_n,{title:"Nothing has happened yet",hint:"Claims, steps, questions and decisions appear here as agents work."})}function Oh({lease:e,now:n}){if(!e)return null;const r=Lo(e,n);if(r==="live")return null;const o=e.expiresAt-n;return i.jsxs(Dn,{tone:"amber",className:"stalled",title:`No activity from ${e.agent}; the ticket returns to the queue when the lease runs out`,children:["stalled · ",r==="expired"?"returning":Ut(o)]})}function LN({total:e,step:n}){return i.jsx("span",{className:"segs","aria-label":`Step ${n} of ${e}`,children:Array.from({length:e},(r,o)=>i.jsx("i",{className:ON(o+1,n)},o))})}function ON(e,n){return e<n?"done":e===n?"cur":""}function dp({snap:e,activity:n,leases:r,onSelect:o,onOpenChat:l}){var w;const c=tn(1e3),d=n.sessions.filter(Zt),h=new Set(d.map(j=>j.ticketId)),g=pc(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(Ie,{children:"No agent on a ticket"});const v=j=>!!j&&Lo(j,c)!=="live",k=!!((w=e==null?void 0:e.map.modelMatching)!=null&&w.enabled);return i.jsxs("ul",{className:"sessions-list",children:[d.map(j=>{const T=e==null?void 0:e.tickets.find(I=>I.id===j.ticketId),S=T?Fi(T)==="hitl":!1,E=T&&g.get(T.id);return i.jsx(Re,{as:"li",className:j.waitingOn?"waiting":void 0,edge:_N(j,v(E)),title:BN(T,j.mode)||j.agent,context:i.jsx(ee,{parts:[{text:j.agent,strong:!0},k&&PN(j),j.waitingOn?{text:"Waiting on you",urgent:!0}:`${j.mode} · ${j.stepLabel.toLowerCase()}`,S&&!j.waitingOn&&"with you",DN(j)],children:i.jsx(Oh,{lease:E,now:c})}),trailing:gm(c-j.startedAt),below:i.jsx(LN,{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(Re,{as:"li",className:"claim",edge:v(g.get(j.id))?"attention":"neutral",title:`${j.key} ${j.title}`,context:i.jsx(ee,{parts:[{text:j.assignee??"",strong:!0},"claimed, no live session"],children:i.jsx(Oh,{lease:g.get(j.id),now:c})}),onOpen:()=>o({kind:"ticket",id:j.id})},j.id))]})}function _N(e,n){return e.waitingOn?"urgent":n?"attention":"neutral"}function PN(e){const n=e.model?`Runs ${e.model}`:"No model reported, so it counts as balanced";return{text:e.tier??"balanced",tip:n,className:"session-tier"}}function DN(e){if(e.usage)return`${Po(by(e))} tok · ${Ps(e.usage.costUsd)}`}function BN(e,n){return e?`${e.key} ${e.title}`:n==="chart"?"Charting trail":""}function fp({activity:e,snap:n,running:r,usage:o=!0}){const l=Xh(e,n==null?void 0:n.map.id),c=em(e,n==null?void 0:n.map.id),d=new Set(e.sessions.filter(Zt).map(g=>g.ticketId)),h=(n==null?void 0:n.tickets.filter(g=>g.state==="open"&&g.assignee&&!d.has(g.id)).length)??0;return i.jsx(bt,{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=>Zh[g].text)].join(`
144
+ `),children:[i.jsx("span",{className:"mono-label",children:"Trail"})," ",Po(l.inputTokens+l.outputTokens)," tok · ",Ps(l.costUsd)]}):void 0})}function zN(e){const n=[...e.feed].reverse().find(r=>r.level==="step"&&r.sessionId);return n?e.sessions.find(r=>r.id===n.sessionId):void 0}const FN={running:"Working",done:"Done",failed:"Stopped"};function hp({activity:e,snap:n}){const r=zN(e);if(!r)return i.jsx(_n,{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?n==null?void 0:n.tickets.find(d=>d.id===r.ticketId):void 0,l=Mo[r.mode],c=r.waitingOn?"Waiting on you":FN[r.status];return i.jsxs("div",{className:`step-tracker ${r.waitingOn?"waiting":""}`,children:[i.jsxs("div",{className:"st-meta",children:[i.jsx(ee,{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 _h(e){return i.jsxs("div",{className:"zone-b activity-stack",children:[i.jsx(hp,{activity:e.activity,snap:e.snap}),i.jsx(fp,{activity:e.activity,snap:e.snap,running:e.activity.sessions.filter(Zt).length}),i.jsx(dp,{snap:e.snap,activity:e.activity,leases:e.leases,onSelect:n=>(n==null?void 0:n.kind)==="ticket"&&e.onTicket(n.id),onOpenChat:e.onOpenChat}),i.jsx(bt,{sub:!0,title:"Activity log"}),i.jsx(up,{activity:e.activity,onTicket:e.onTicket})]})}function UN(e){return i.jsx(Tm,{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(up,{activity:e.activity,onTicket:e.onTicket})})}function WN(e){var o;const n=e.activity.sessions.filter(Zt).length,r=!e.activity.sessions.length&&!((o=e.snap)!=null&&o.tickets.some(l=>l.state==="open"&&l.assignee));return i.jsxs(We,{className:"zone step-zone",style:{gridArea:"step"},children:[i.jsx(bt,{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(hp,{activity:e.activity,snap:e.snap}),!r&&i.jsxs(i.Fragment,{children:[i.jsx(fp,{activity:e.activity,snap:e.snap,running:n,usage:!1}),i.jsx(dp,{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 Ph=`${Ne()}/criteria`;function HN(e){const[n,r]=x.useState([]),o=x.useCallback(()=>{if(!e)return r([]);fetch(`${Ph}?mapId=${encodeURIComponent(e)}`).then(c=>c.ok?c.json():{tickets:[]}).then(c=>r(c.tickets)).catch(()=>r([]))},[e]);return x.useEffect(()=>(o(),hn(c=>c.startsWith("criteria/")&&o())),[o]),{tickets:n,confirm:c=>fetch(`${Ph}/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,...c})}).then(o)}}function VN({snap:e,t:n}){const{tickets:r,confirm:o}=HN(e.map.id),l=Ws(),c=r.find(m=>m.ticketId===n.id),d=(c==null?void 0:c.criteria)??[],g=cm(l.entries,{trailKey:e.map.key,ticket:{type:n.type,title:n.title,body:n.body},paths:um(`${n.body}
145
+ ${l.briefText}`)}).filter(m=>m.kind==="business-rule").filter(m=>rk(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(ee,{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(ee,{parts:[{text:m.id,code:!0},"business rule"]})]},m.id))})]}),d.length>0&&n.state==="open"&&i.jsx(K,{size:"sm",variant:c!=null&&c.confirmed?"ghost":"default","data-tip":c!=null&&c.confirmed?"Take your confirmation back":"Agree that these criteria define done for this ticket",onClick:()=>void o({title:e.map.title,ticketId:n.id,ticketKey:n.key,confirmed:!(c!=null&&c.confirmed)}),children:c!=null&&c.confirmed?"Unconfirm":"Confirm criteria"})]})}const Co="";function KN(e){const n=lc.map(o=>({value:o,label:Bi[o],hint:Bm[o]})),r=[...GN(e),...n];return i.jsx(ct,{compact:!0,className:"vf-level","aria-label":"Verification level",value:e.value??Co,options:r,onChange:o=>e.onChange(o===Co?null:o)})}function GN(e){return e.inherit!==void 0?[{value:Co,label:e.inherit,hint:"Use the trail’s level for this ticket."}]:e.value===void 0?[{value:Co,label:"Off (not set)"}]:[]}function qN({check:e}){const n=Ij(e),[r,o]=x.useState(),[l,c]=x.useState(),d=QN(e);return i.jsxs("details",{className:`vf-row ${n?"ok":"bad"}`,open:!n,children:[i.jsxs("summary",{children:[i.jsx("span",{className:"vf-mark",children:n?"✓":"✕"}),i.jsx("span",{className:"t-code vf-name",children:e.name}),i.jsx("span",{className:"t-meta",children:d}),i.jsx("span",{className:"t-meta vf-dur",children:Ut(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]
146
+ ${h.text}`:h.text),h=>c(h.message)),children:"Full log ›"}),e.truncated&&i.jsx("span",{className:"dim",children:"log capped at 1 MB"}),l&&i.jsx("span",{className:"vf-err",children:l})]})]})}function QN(e){return e.error?"did not start":e.timedOut?"timed out":`exit ${e.exitCode??e.signal??"?"}`}const Dh=e=>(e==null?void 0:e.slice(0,8))??"none",Bh=e=>e===null?"·":String(e);function YN({attempt:e}){const n=e.git;if(!n)return null;const{files:r,add:o,del:l}=n.stats;return i.jsxs("div",{className:"vf-git",children:[i.jsx(ee,{parts:[n.tree?{text:`${n.base?`${Dh(n.base.head)} → `:""}${Dh(n.tree.head)}`,code:!0}:"not a git repo",n.tree&&{text:n.tree.branch??"detached HEAD",code:!!n.tree.branch},n.tree&&`${r} file${r===1?"":"s"} +${o} −${l}`]}),n.flags.filter(c=>c.kind!=="no-git").map(c=>{var d;return i.jsxs("p",{className:`vf-flag lv-${c.level}`,title:(d=c.files)==null?void 0:d.join(`
147
+ `),children:[i.jsx("span",{className:"t-code",children:c.kind})," ",c.message]},c.kind)}),n.changed.length>0&&i.jsxs("details",{className:"vf-files",children:[i.jsx("summary",{className:"t-label",children:"Changed files"}),i.jsx("ul",{children:n.changed.map(c=>i.jsxs("li",{children:[i.jsx("code",{children:c.path}),i.jsxs("span",{className:"dim",children:[c.untracked?"new":`+${Bh(c.add)} −${Bh(c.del)}`,c.dirtyAtClaim?" · dirty at claim":""]})]},c.path))})]})]})}function JN({attempt:e,latest:n}){return i.jsxs("details",{className:`vf-attempt r-${e.result}`,open:n,children:[i.jsxs("summary",{children:[i.jsx(Dn,{tone:"state",className:`r-${e.result}`,children:Mj[e.result]}),i.jsx(ee,{parts:[{text:e.id,code:!0},e.agent,Wi(e.submittedAt),Ut(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:XN(r),children:r},r))}),i.jsx(YN,{attempt:e}),e.checks.map(r=>i.jsx(qN,{check:r},r.name))]})}function XN(e){return e.includes(" ✓ ")?"ok":e.includes(" ✗ ")?"bad":"wait"}const ZN={PASS:"Passed",FAIL:"Sent back",NEEDS_HUMAN:"Needs you"};function eb({verdict:e}){const{guide:n,checklist:r}=e;return i.jsxs("div",{className:`vf-verdict v-${e.verdict.toLowerCase()}`,children:[i.jsx(ee,{parts:[{text:e.byKind==="trail lead"&&e.verdict==="PASS"?"Approved":ZN[e.verdict],strong:!0},{text:e.id,code:!0},e.byKind==="trail lead"?e.by:`review ${e.by}`,e.sessionId&&`session ${e.sessionId.slice(0,8)}`,n&&`as ${n.id} ${n.version}`,`on ${e.attemptId}`,Wi(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(qm,{answers:r})]})}function tb(e,n,r){const[o,l]=x.useState(),c=x.useCallback(()=>{Vi.ticket(e,n).then(l)},[e,n]);return x.useEffect(()=>(l(void 0),c(),Bs.onEvidence(c)),[c]),x.useEffect(c,[c,r]),{data:o,reload:c}}const Wl={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 nb(e){const[n,r]=x.useState(),[o,l]=x.useState(""),[c,d]=x.useState("rework"),{state:h,submitted:g,running:m,act:v}=e;if(m||h!=="verifying"&&h!=="held")return null;const k=j=>{r(n===j?void 0:j),l("")},w=j=>{j.preventDefault(),!(!n||!o.trim())&&(v({action:n,reason:o.trim(),...n==="unblock"?{to:c}:{}}),r(void 0))};return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"actions vf-actions",children:[h==="verifying"&&g&&i.jsx(K,{variant:"primary",onClick:()=>void 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:n==="rework",onClick:()=>k("rework"),"data-tip":"Send it back to an agent with what to fix",children:"Rework…"}),h==="held"&&i.jsxs(i.Fragment,{children:[i.jsx(K,{on:n==="accept",onClick:()=>k("accept"),"data-tip":"Close it as done despite the failing checks",children:"Accept anyway…"}),i.jsx(K,{on:n==="unblock",onClick:()=>k("unblock"),"data-tip":"Put it back in the queue without running checks",children:"Unblock…"})]})]}),n&&i.jsxs(Rt,{as:"form",tone:"inset",className:"inline-form",onSubmit:w,children:[i.jsx(Ye,{label:Wl[n].label,children:i.jsx("textarea",{rows:2,value:o,onChange:j=>l(j.target.value),autoFocus:!0})}),n==="unblock"&&i.jsx(Ye,{label:"Back to",children:i.jsx(ct,{"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:Wl[n].hint}),i.jsxs("div",{className:"form-actions",children:[i.jsx(K,{variant:"ghost",onClick:()=>r(void 0),children:"Cancel"}),i.jsx(K,{type:"submit",variant:n==="accept"?"danger":"primary",disabled:!o.trim(),children:Wl[n].submit})]})]})]})}const sb={ticket:"set on this ticket",trail:"from the trail",none:"not set"},ib=new Set(["verifying","rework","held"]);function rb(e){const{mapId:n,ticket:r,state:o}=e,{data:l,reload:c}=tb(n,r.id,r.updatedAt),[d,h]=x.useState();if(!l||l.level.level==="off"&&!l.attempts.length&&!ib.has(o))return null;const g=v=>(h(void 0),Vi.act({...v,mapId:n,ticketId:r.id,by:xt}).then(c,k=>h(k.message))),m=l.running;return i.jsxs("section",{className:"vf-panel",children:[i.jsxs("div",{className:"vf-head",children:[i.jsx(Ke,{as:"h4",children:"Verification"}),i.jsx(ee,{parts:[Bi[l.level.level],sb[l.level.source]]}),r.state==="open"&&i.jsx(KN,{value:r.verification,inherit:`Trail (${Bi[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 ",Wi(m.startedAt)]})]}),i.jsx(nb,{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(eb,{verdict:v},v.id)),l.attempts.map((v,k)=>i.jsx(JN,{attempt:v,latest:k===0},v.id)),!l.attempts.length&&!m&&i.jsx(ee,{parts:[`Checks: ${l.level.checks.join(", ")||"none"}`,"run when the ticket is submitted"]})]})}function ob({lease:e,onRelease:n}){const r=tn(1e3),o=Lo(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(ee,{parts:[{text:`Claimed by ${e.agent}`,strong:!0},`active ${en(r-e.renewedAt)} ago`]}),!l&&i.jsx(Dn,{tone:"amber",children:"Stalled"})]}),i.jsx("p",{className:"t-meta lease-line",children:ab(o,lb(e.expiresAt-r))}),e.workspace&&i.jsxs("p",{className:"t-meta lease-branch",children:["Works on ",i.jsx("code",{className:"t-code",children:e.workspace.branch})," in its own worktree"]}),e.touches&&e.touches.length>0&&i.jsxs("p",{className:"t-meta lease-touches",children:["Expects to change"," ",e.touches.map((c,d)=>i.jsxs("span",{children:[d>0&&", ",i.jsx("code",{className:"t-code",children:c})]},c))]}),e.notes.length>0&&i.jsx("ul",{className:"lease-notes t-meta",children:e.notes.slice(-3).map((c,d)=>i.jsx("li",{children:c},d))}),i.jsx("div",{className:"actions",children:i.jsx(K,{variant:l?"default":"urgent",onClick:n,children:"Release to queue"})})]})}function ab(e,n){return e==="expired"?"Lease expired, going back to the queue":e==="stalled"?`The agent went quiet. Back in the queue in ${n}.`:`Back in the queue after ${n} without activity.`}function lb(e){const n=e/864e5;return n>=2?`${Math.round(n)} days`:Ut(Math.max(0,e))}function cb({comments:e}){if(!e.length)return null;const n=e.length>1?"s":"";return i.jsxs("details",{className:"comments",children:[i.jsxs("summary",{className:"t-label",children:[e.length," other comment",n]}),e.map(r=>i.jsxs("div",{className:"comment",children:[i.jsx(ee,{parts:[{text:r.author,strong:!0}]}),i.jsx("div",{className:"c-body",children:r.body.replace(/\*\*/g,"")})]},r.id))]})}function ub({resolution:e,decisions:n,onOpenDecision:r}){const o=n.find(d=>!d.supersededBy)??n[0],l=e.body.startsWith("**Ruled")?"ruled out":"resolution",c=n.length>1?` · ${n.length} in chain`:"";return i.jsxs("div",{className:"resolution edge-note edge-done",children:[i.jsxs("div",{className:"edge-note-head",children:[i.jsx(ee,{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 db(e){const{t:n,state:r,session:o,mine:l,form:c,setForm:d,actions:h,onOpenChat:g}=e;return i.jsxs("div",{className:"actions",children:[o&&i.jsx(K,{variant:o.waitingOn?"urgent":"default",onClick:()=>g(o.id),"data-tip":o.waitingOn?"The agent is waiting for your answer":"Open the conversation with this agent",children:o.waitingOn?"Answer":"Conversation"}),r==="frontier"&&i.jsx(K,{onClick:()=>h.claim(n.id),"data-tip":"Take this ticket yourself, so no agent picks it up",children:"Claim"}),(r==="frontier"||r==="claimed"&&l)&&i.jsx(K,{on:c==="resolve",onClick:()=>d(c==="resolve"?null:"resolve"),"data-tip":"Answer it yourself and close the ticket, with a decision record",children:"Resolve…"}),l&&r==="claimed"&&i.jsx(K,{onClick:()=>h.release(n.id),"data-tip":"Give the ticket back to the queue",children:"Release"}),(r==="frontier"||r==="blocked"||r==="parked")&&i.jsx(K,{variant:"danger",on:c==="rule",onClick:()=>d(c==="rule"?null:"rule"),"data-tip":"Move it out of scope. It's set aside with your reason, not deleted",children:"Rule out…"})]})}function fb({t:e,state:n,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",Pi[e.type]],["Assignee",e.assignee],["Blocked by",c],["Blocks",d],["Reviews",e.reviewOf&&l(e.reviewOf)]],g=Fi(e)==="hitl";return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"d-head",children:[i.jsx("span",{className:"key t-code",children:e.key}),i.jsx(Dn,{tone:"state",className:`st-${n}`,children:ym[n]}),i.jsx("span",{className:"d-att t-meta","data-tip":g?"A person takes this one":"An agent takes this alone",children:g?"Needs a person":"Agent work"})]}),i.jsx("h3",{className:"t-heading",children:e.title}),i.jsx("dl",{className:"facts",children:h.filter(([,m])=>m).flatMap(([m,v])=>[i.jsx("dt",{className:"t-label",children:m},`${m}-k`),i.jsx("dd",{children:v},`${m}-v`)])})]})}function hb(e){const{snap:n,api:r,form:o,setForm:l}=e,{actions:c}=r,[d,h]=x.useState(""),[g,m]=x.useState(""),[v,k]=x.useState(""),[w,j]=x.useState("Not needed to reach the destination."),T=n.tickets.find(B=>B.id===e.id);if(!T)return i.jsx(Ie,{children:"Ticket not found."});const S=Fs(n.tickets,n.map.mode).get(T.id),E=e.sessions.find(B=>B.ticketId===T.id&&Zt(B)),I=T.assignee===xt,O=T.state==="open"?pc(r.leases,n.map.id).get(T.id):void 0,R=[...T.comments].reverse().find(B=>/^\*\*(Resolution|Ruled out of scope)\*\*/.test(B.body)),X=T.comments.filter(B=>B!==R),te=r.decisions.filter(B=>B.mapId===n.map.id&&B.ticketId===T.id);return i.jsxs("div",{className:"detail",children:[i.jsx(fb,{t:T,state:S,tickets:n.tickets}),i.jsx(ES,{mapId:n.map.id,ticketId:T.id}),i.jsx(sw,{mapId:n.map.id,ticketId:T.id}),i.jsx(Z0,{mapId:n.map.id,ticket:T}),i.jsx(VN,{snap:n,t:T}),i.jsx(vw,{snap:n,t:T}),T.closeReason==="not_planned"&&i.jsx(wc,{label:"Save as dead end",draft:()=>{var B;return{title:`Ruled out: ${T.title}`,body:((B=T.comments.at(-1))==null?void 0:B.body)??T.body,kind:"dead-end",sources:[`trail:${n.map.key}`,`ticket:${T.key}`]}}}),O&&i.jsx(ob,{lease:O,onRelease:()=>c.releaseLease(T.id)}),!O&&i.jsx(cS,{mapId:n.map.id,ticketId:T.id}),i.jsx(rb,{mapId:n.map.id,trail:n.map.verification,ticket:T,state:S}),i.jsx(db,{t:T,state:S,session:E,mine:I,form:o,setForm:l,actions:c,onOpenChat:e.onOpenChat}),o==="resolve"&&i.jsxs(Rt,{as:"form",tone:"inset",className:"inline-form",onSubmit:B=>{B.preventDefault(),d.trim()&&(c.resolve(T.id,d.trim(),{rationale:g.trim(),alternatives:v.split(`
148
+ `).map(se=>se.trim()).filter(Boolean)}),l(null),h(""),m(""),k(""))},children:[i.jsx(Ye,{label:"Resolution",children:i.jsx("textarea",{rows:3,value:d,onChange:B=>h(B.target.value),autoFocus:!0})}),i.jsx(Ye,{label:"Rationale",children:i.jsx("input",{value:g,onChange:B=>m(B.target.value)})}),i.jsx(Ye,{label:"Alternatives considered",children:i.jsx("textarea",{rows:2,value:v,onChange:B=>k(B.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(Rt,{as:"form",tone:"inset",className:"inline-form",onSubmit:B=>{B.preventDefault(),c.ruleOut({ticketId:T.id},w),l(null)},children:[i.jsx(Ye,{label:"Reason",children:i.jsx("input",{value:w,onChange:B=>j(B.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"})]})]}),R&&i.jsx(ub,{resolution:R,decisions:te,onOpenDecision:e.onOpenDecision}),i.jsx("p",{className:"body",children:T.body}),i.jsx(cb,{comments:X})]})}function mb({snap:e,item:n,api:r}){const o=Gh(e.map.mode),[l,c]=x.useState("research"),[d,h]=x.useState(n),[g,m]=x.useState(!1),[v,k]=x.useState([]),[w,j]=x.useState("Not needed to reach the destination.");x.useEffect(()=>h(n),[n]);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(Dn,{tone:"state",className:"st-unspecified",children:"Not yet specified"})}),i.jsx("h3",{className:"t-heading",children:n}),i.jsxs(Rt,{as:"form",tone:"inset",className:"inline-form",onSubmit:S=>{S.preventDefault(),r.actions.graduate({unspecified:n,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)),jv.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:()=>k(E=>E.includes(S.id)?E.filter(I=>I!==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(Rt,{as:"form",tone:"inset",className:"inline-form",onSubmit:S=>{S.preventDefault(),r.actions.ruleOut({unspecified:n},w)},children:[i.jsx(Ye,{label:"Reason",children:i.jsx("input",{value:w,onChange:S=>j(S.target.value)})}),i.jsx("div",{className:"form-actions",children:i.jsx(K,{type:"submit",variant:"danger",children:"Rule out"})})]})]})}function pb({api:e,sessions:n,bare:r,onOpenChat:o,onOpenDecision:l}){const{snap:c,selection:d,actions:h}=e,[g,m]=x.useState(null),v=gb(d);x.useEffect(()=>m(null),[v]);let k;return c?d?d.kind==="unspecified"?k=i.jsx(mb,{snap:c,item:d.item,api:e}):k=i.jsx(hb,{snap:c,id:d.id,api:e,sessions:n,form:g,setForm:m,onOpenChat:o??h.openChat,onOpenDecision:l}):k=i.jsx(_n,{title:"No ticket selected",hint:"Pick a ticket on the map: what it is, who has it, what blocks it, and its decision."}):k=i.jsx(_n,{title:"No trail yet",hint:"Once there's a trail, pick a ticket on the map to see it here."}),i.jsx(Tm,{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:k})}function gb(e){return(e==null?void 0:e.kind)==="ticket"?e.id:(e==null?void 0:e.kind)==="unspecified"?e.item:""}const vb={holding:"Holding",challenged:"Challenged",invalidated:"Invalidated",confirmed:"Confirmed"};function yb(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 kb(e){const{a:n,snap:r}=e,o=n.tickets.flatMap(c=>r.tickets.filter(d=>d.id===c)),l=n.challenge&&`${n.challenge.by}: ${n.challenge.evidence}`;return i.jsx(Re,{as:"li",className:`assumption st-${n.status}`,edge:n.status==="challenged"?"attention":"neutral",title:n.text,titleText:n.text,context:i.jsx(ee,{parts:[{text:n.id,code:!0},vb[n.status],yb(n)],children:o.length>0&&i.jsxs("span",{className:"assumption-tickets",children:[i.jsx("span",{className:"sep",children:" · "}),"relied on by",o.map(c=>i.jsx("button",{className:"link t-code",onClick:()=>e.onSelect({kind:"ticket",id:c.id}),children:c.key},c.id))]})}),detail:l,detailText:l,trailing:e.onConfirm&&i.jsx(K,{size:"sm",variant:"ghost",disabled:e.busy,onClick:e.onConfirm,children:"Confirm"})})}function xb(e){const[n,r]=x.useState(),[o,l]=x.useState();return{confirm:async d=>{l(d);const h=await fetch(`${Ne()}/assumptions/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,id:d})}).catch(()=>{});if(l(void 0),h!=null&&h.ok)return r(void 0);const g=await(h==null?void 0:h.json().catch(()=>({})));r((g==null?void 0:g.error)??"Could not confirm it; is the Lookout connected?")},busy:o,error:n}}function wb({snap:e,onSelect:n}){const{confirm:r,busy:o,error:l}=xb(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(kb,{a:d,snap:e,onSelect:n,onConfirm:h?()=>void r(d.id):void 0,busy:o===d.id},d.id)})})]}):i.jsx(Ie,{children:"None yet. They come from the accepted discovery brief or the trail's start."})}function jb(e){const[n,r]=x.useState([]),o=e==null?void 0:e.map.id,l=(e==null?void 0:e.tickets.reduce((c,d)=>Math.max(c,d.updatedAt),e.map.updatedAt))??0;return x.useEffect(()=>{if(!o)return;let c=!0;return fetch(`${Ne()}/journal?mapId=${encodeURIComponent(o)}`).then(d=>d.ok?d.json():{entries:[]}).then(d=>c&&r(d.entries)).catch(()=>c&&r([])),()=>{c=!1}},[o,l]),n}function Sb({snap:e,activity:n,onTicket:r}){const o=jb(e),l=n.usageByMap[e.map.id],c=x.useMemo(()=>sm({snap:e,journal:o,answered:n.answered,usage:l}),[e,o,n.answered,l]),d=c.interventions,h=[["Done",`${c.done}`,`${c.done} done · ${c.cancelled} cancelled · ${c.open} open`],["Lead time",Xt(c.trailLeadMs),"Trail lead time: from when the trail was charted to its last done ticket"],["Median ticket",Xt(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?"—":Ps(c.spend.perVerifiedTicketUsd),`Cost per verified ticket: trail spend ${Ps(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:()=>pm(`${e.map.key.replace("#","trail-")}-report.md`,qy(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"?Xt(g.leadMs):g.outcome})]})},g.id))}):i.jsx(Ie,{children:"No tickets yet"})]})}function Nb({tab:e,snap:n,selection:r,onSelect:o,activity:l}){const c=n.map.sections;switch(e){case"report":return l?i.jsx(Sb,{snap:n,activity:l,onTicket:d=>o({kind:"ticket",id:d})}):i.jsx(Ie,{children:"No activity yet"});case"assumptions":return i.jsx(wb,{snap:n,onSelect:o});case"decisions":return c.decisions.length?i.jsx("ol",{className:"row-list decisions",children:[...c.decisions].reverse().map((d,h)=>i.jsx(Re,{as:"li",title:d.text,titleText:d.text,context:d.ticketKey&&i.jsx(ee,{parts:[{text:d.ticketKey,code:!0}]}),onOpen:d.ticketId?()=>o({kind:"ticket",id:d.ticketId}):void 0},`${d.ticketKey}-${h}`))}):i.jsx(Ie,{children:"None"});case"unspecified":return c.unspecified.length?i.jsx("ul",{className:"row-list unspecified",children:c.unspecified.map(d=>i.jsx(Re,{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(Ie,{children:"None"});case"oos":return c.outOfScope.length?i.jsx("ul",{className:"row-list oos",children:c.outOfScope.map(d=>i.jsx(Re,{as:"li",title:d,titleText:d},d))}):i.jsx(Ie,{children:"None"});case"notes":return i.jsx("p",{className:"notes t-body",children:c.notes||"No notes yet."});default:return e}}function bb({snap:e,selection:n,onSelect:r,bare:o,onAudit:l,activity:c}){var k;const[d,h]=x.useState("unspecified"),g=e==null?void 0:e.map.sections,m=[{id:"unspecified",label:"Not yet specified",n:g==null?void 0:g.unspecified.length},{id:"assumptions",label:"Assumptions",n:(k=g==null?void 0:g.assumptions)==null?void 0:k.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(Nb,{tab:d,snap:e,selection:n,onSelect:r,activity:c}):i.jsx(_n,{title:"No plan yet",hint:"Open questions, decisions, what's ruled out, notes and the trail report collect here."});return i.jsxs(We,{className:`zone sections ${o?"bare":""}`,style:o?void 0:{gridArea:"plan"},children:[!o&&i.jsx(bt,{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(Cm,{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 Cb(){var ae;const e=x.useMemo(()=>Lx(Rx()),[]),n=Kx(e),{snap:r,activity:o,selection:l,actions:c}=n,[d,h]=Gx();x.useEffect(()=>km(d.theme),[d.theme]);const g=Q1(),[m,v]=x.useState(!1),k=X1(e.kind),w=Ux(),j=o.pending.length,T=Z1(o,n.mapId);J1(j,r==null?void 0:r.map.title);const S=Y1(n,w),E=kN(r,c.selectMap),I=jw(E.briefText),O=SN({api:n,nav:S,knowledge:I,reviewBrief:E.review,openReroute:Y=>E.openReroute(Y.mapId,Y.ref),openGuides:()=>g.open("guides")}),R=Hx(e,n,d.briefing,(ae=O.attention.view)==null?void 0:ae.items),X=i.jsx(Dj,{api:n,nav:S,bp:w,scoped:T,attn:O,above:E.inboxCard}),te=i.jsx(V1,{api:n,sessions:T.sessions,onSelect:S.select,onNewTrail:()=>v(!0),compact:w==="mobile",minFit:w==="mobile"?.7:0,trail:E}),B=Y=>i.jsx(pb,{api:n,sessions:T.sessions,bare:Y,onOpenChat:U=>S.openChat(U),onOpenDecision:S.openDecisions}),se={activity:T,snap:r,leases:n.leases,onTicket:Y=>S.select({kind:"ticket",id:Y}),onOpenChat:Y=>S.openChat(Y)},oe=Y=>i.jsx(bb,{snap:r,selection:l,onSelect:S.select,bare:Y,onAudit:()=>S.openDecisions(),activity:T}),{projects:G,overview:ve,openOverview:Be}=RN(w,S,O.link.request),$e=g.route&&i.jsx(ZS,{rt:e,api:n,bp:w,prefs:d,update:h,settings:g}),ie=(S.statsOpen||S.decisionsView)&&i.jsx(AN,{api:n,bp:w,nav:S}),D=$e||ve||ie,q=R.shown&&i.jsx(tw,{brief:R,snaps:n.allSnaps,bp:w,openTicket:S.openTicket,openChat:S.openChat,openDecisions:S.openDecisions,closeDecisions:()=>S.setDecisionsView(null),showPhoneHome:()=>S.setPhoneTab("home")});return i.jsx(Em.Provider,{value:I,children:i.jsxs("div",{className:`app bp-${w}`,children:[i.jsx(Yw,{api:n,rt:e,repo:i.jsx(SS,{repo:k,projects:G,onOverview:Be}),brief:R,attention:O.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:Y=>h({theme:Y?"night":"day"})}),w==="wide"&&i.jsxs(i.Fragment,{children:[X,te,B(!1),i.jsx(WN,{...se}),i.jsx(UN,{...se}),oe(!1),D]}),w==="laptop"&&i.jsxs(i.Fragment,{children:[X,te,i.jsx(e1,{tab:S.sideTab,onTab:S.setSideTab,unspecified:r==null?void 0:r.map.sections.unspecified.length,ticket:B(!0),activity:i.jsx(_h,{...se}),plan:oe(!0)}),D]}),w==="mobile"&&i.jsxs(i.Fragment,{children:[i.jsx(q1,{tab:S.phoneTab,decisions:D,inbox:X,projects:G.many&&i.jsx(bS,{projects:G,onOverview:Be}),map:te,ticket:B(!0),activity:i.jsx(_h,{...se}),plan:oe(!0)}),i.jsx(G1,{tab:S.phoneTab,covered:!!D,pending:j,onPick:Y=>{g.close(),S.setPhoneTab(Y),S.setDecisionsView(null)}})]}),q,E.dialog,n.error&&i.jsx("div",{className:"error-toast",children:n.error}),m&&i.jsx(Vj,{rt:e,onClose:()=>v(!1),onCreated:Y=>c.selectMap(Y)}),!d.onboarded&&i.jsx(d0,{prefs:d,update:h,activeTracker:e.kind}),i.jsx(ww,{})]})})}km(vc().theme);kv.createRoot(document.getElementById("root")).render(i.jsxs(i.Fragment,{children:[i.jsx(Cb,{}),i.jsx(Yx,{})]}));