teamtrail 0.0.3 → 0.7.0-next.19

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,146 @@
1
+ var ig=Object.defineProperty;var rg=(t,s,r)=>s in t?ig(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r;var le=(t,s,r)=>rg(t,typeof s!="symbol"?s+"":s,r);(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))a(l);new MutationObserver(l=>{for(const u of l)if(u.type==="childList")for(const f of u.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&a(f)}).observe(document,{childList:!0,subtree:!0});function r(l){const u={};return l.integrity&&(u.integrity=l.integrity),l.referrerPolicy&&(u.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?u.credentials="include":l.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function a(l){if(l.ep)return;l.ep=!0;const u=r(l);fetch(l.href,u)}})();var hl={exports:{}},xi={},ml={exports:{}},ye={};/**
2
+ * @license React
3
+ * react.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var Xd;function og(){if(Xd)return ye;Xd=1;var t=Symbol.for("react.element"),s=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),f=Symbol.for("react.context"),m=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),k=Symbol.for("react.lazy"),v=Symbol.iterator;function w(b){return b===null||typeof b!="object"?null:(b=v&&b[v]||b["@@iterator"],typeof b=="function"?b:null)}var N={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},M=Object.assign,S={};function E(b,P,fe){this.props=b,this.context=P,this.refs=S,this.updater=fe||N}E.prototype.isReactComponent={},E.prototype.setState=function(b,P){if(typeof b!="object"&&typeof b!="function"&&b!=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,b,P,"setState")},E.prototype.forceUpdate=function(b){this.updater.enqueueForceUpdate(this,b,"forceUpdate")};function I(){}I.prototype=E.prototype;function _(b,P,fe){this.props=b,this.context=P,this.refs=S,this.updater=fe||N}var O=_.prototype=new I;O.constructor=_,M(O,E.prototype),O.isPureReactComponent=!0;var ee=Array.isArray,q=Object.prototype.hasOwnProperty,V={current:null},ie={key:!0,ref:!0,__self:!0,__source:!0};function ae(b,P,fe){var pe,ce={},ke=null,he=null;if(P!=null)for(pe in P.ref!==void 0&&(he=P.ref),P.key!==void 0&&(ke=""+P.key),P)q.call(P,pe)&&!ie.hasOwnProperty(pe)&&(ce[pe]=P[pe]);var ve=arguments.length-2;if(ve===1)ce.children=fe;else if(1<ve){for(var be=Array(ve),rt=0;rt<ve;rt++)be[rt]=arguments[rt+2];ce.children=be}if(b&&b.defaultProps)for(pe in ve=b.defaultProps,ve)ce[pe]===void 0&&(ce[pe]=ve[pe]);return{$$typeof:t,type:b,key:ke,ref:he,props:ce,_owner:V.current}}function K(b,P){return{$$typeof:t,type:b.type,key:P,ref:b.ref,props:b.props,_owner:b._owner}}function xe(b){return typeof b=="object"&&b!==null&&b.$$typeof===t}function ze(b){var P={"=":"=0",":":"=2"};return"$"+b.replace(/[=:]/g,function(fe){return P[fe]})}var $e=/\/+/g;function L(b,P){return typeof b=="object"&&b!==null&&b.key!=null?ze(""+b.key):P.toString(36)}function Q(b,P,fe,pe,ce){var ke=typeof b;(ke==="undefined"||ke==="boolean")&&(b=null);var he=!1;if(b===null)he=!0;else switch(ke){case"string":case"number":he=!0;break;case"object":switch(b.$$typeof){case t:case s:he=!0}}if(he)return he=b,ce=ce(he),b=pe===""?"."+L(he,0):pe,ee(ce)?(fe="",b!=null&&(fe=b.replace($e,"$&/")+"/"),Q(ce,P,fe,"",function(rt){return rt})):ce!=null&&(xe(ce)&&(ce=K(ce,fe+(!ce.key||he&&he.key===ce.key?"":(""+ce.key).replace($e,"$&/")+"/")+b)),P.push(ce)),1;if(he=0,pe=pe===""?".":pe+":",ee(b))for(var ve=0;ve<b.length;ve++){ke=b[ve];var be=pe+L(ke,ve);he+=Q(ke,P,fe,be,ce)}else if(be=w(b),typeof be=="function")for(b=be.call(b),ve=0;!(ke=b.next()).done;)ke=ke.value,be=pe+L(ke,ve++),he+=Q(ke,P,fe,be,ce);else if(ke==="object")throw P=String(b),Error("Objects are not valid as a React child (found: "+(P==="[object Object]"?"object with keys {"+Object.keys(b).join(", ")+"}":P)+"). If you meant to render a collection of children, use an array instead.");return he}function se(b,P,fe){if(b==null)return b;var pe=[],ce=0;return Q(b,pe,"","",function(ke){return P.call(fe,ke,ce++)}),pe}function ue(b){if(b._status===-1){var P=b._result;P=P(),P.then(function(fe){(b._status===0||b._status===-1)&&(b._status=1,b._result=fe)},function(fe){(b._status===0||b._status===-1)&&(b._status=2,b._result=fe)}),b._status===-1&&(b._status=0,b._result=P)}if(b._status===1)return b._result.default;throw b._result}var me={current:null},B={transition:null},F={ReactCurrentDispatcher:me,ReactCurrentBatchConfig:B,ReactCurrentOwner:V};function W(){throw Error("act(...) is not supported in production builds of React.")}return ye.Children={map:se,forEach:function(b,P,fe){se(b,function(){P.apply(this,arguments)},fe)},count:function(b){var P=0;return se(b,function(){P++}),P},toArray:function(b){return se(b,function(P){return P})||[]},only:function(b){if(!xe(b))throw Error("React.Children.only expected to receive a single React element child.");return b}},ye.Component=E,ye.Fragment=r,ye.Profiler=l,ye.PureComponent=_,ye.StrictMode=a,ye.Suspense=g,ye.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=F,ye.act=W,ye.cloneElement=function(b,P,fe){if(b==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+b+".");var pe=M({},b.props),ce=b.key,ke=b.ref,he=b._owner;if(P!=null){if(P.ref!==void 0&&(ke=P.ref,he=V.current),P.key!==void 0&&(ce=""+P.key),b.type&&b.type.defaultProps)var ve=b.type.defaultProps;for(be in P)q.call(P,be)&&!ie.hasOwnProperty(be)&&(pe[be]=P[be]===void 0&&ve!==void 0?ve[be]:P[be])}var be=arguments.length-2;if(be===1)pe.children=fe;else if(1<be){ve=Array(be);for(var rt=0;rt<be;rt++)ve[rt]=arguments[rt+2];pe.children=ve}return{$$typeof:t,type:b.type,key:ce,ref:ke,props:pe,_owner:he}},ye.createContext=function(b){return b={$$typeof:f,_currentValue:b,_currentValue2:b,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},b.Provider={$$typeof:u,_context:b},b.Consumer=b},ye.createElement=ae,ye.createFactory=function(b){var P=ae.bind(null,b);return P.type=b,P},ye.createRef=function(){return{current:null}},ye.forwardRef=function(b){return{$$typeof:m,render:b}},ye.isValidElement=xe,ye.lazy=function(b){return{$$typeof:k,_payload:{_status:-1,_result:b},_init:ue}},ye.memo=function(b,P){return{$$typeof:p,type:b,compare:P===void 0?null:P}},ye.startTransition=function(b){var P=B.transition;B.transition={};try{b()}finally{B.transition=P}},ye.unstable_act=W,ye.useCallback=function(b,P){return me.current.useCallback(b,P)},ye.useContext=function(b){return me.current.useContext(b)},ye.useDebugValue=function(){},ye.useDeferredValue=function(b){return me.current.useDeferredValue(b)},ye.useEffect=function(b,P){return me.current.useEffect(b,P)},ye.useId=function(){return me.current.useId()},ye.useImperativeHandle=function(b,P,fe){return me.current.useImperativeHandle(b,P,fe)},ye.useInsertionEffect=function(b,P){return me.current.useInsertionEffect(b,P)},ye.useLayoutEffect=function(b,P){return me.current.useLayoutEffect(b,P)},ye.useMemo=function(b,P){return me.current.useMemo(b,P)},ye.useReducer=function(b,P,fe){return me.current.useReducer(b,P,fe)},ye.useRef=function(b){return me.current.useRef(b)},ye.useState=function(b){return me.current.useState(b)},ye.useSyncExternalStore=function(b,P,fe){return me.current.useSyncExternalStore(b,P,fe)},ye.useTransition=function(){return me.current.useTransition()},ye.version="18.3.1",ye}var Zd;function Pl(){return Zd||(Zd=1,ml.exports=og()),ml.exports}/**
10
+ * @license React
11
+ * react-jsx-runtime.production.min.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var ef;function ag(){if(ef)return xi;ef=1;var t=Pl(),s=Symbol.for("react.element"),r=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,l=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function f(m,g,p){var k,v={},w=null,N=null;p!==void 0&&(w=""+p),g.key!==void 0&&(w=""+g.key),g.ref!==void 0&&(N=g.ref);for(k in g)a.call(g,k)&&!u.hasOwnProperty(k)&&(v[k]=g[k]);if(m&&m.defaultProps)for(k in g=m.defaultProps,g)v[k]===void 0&&(v[k]=g[k]);return{$$typeof:s,type:m,key:w,ref:N,props:v,_owner:l.current}}return xi.Fragment=r,xi.jsx=f,xi.jsxs=f,xi}var tf;function lg(){return tf||(tf=1,hl.exports=ag()),hl.exports}var i=lg(),Vr={},pl={exports:{}},pt={},gl={exports:{}},vl={};/**
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 nf;function cg(){return nf||(nf=1,(function(t){function s(B,F){var W=B.length;B.push(F);e:for(;0<W;){var b=W-1>>>1,P=B[b];if(0<l(P,F))B[b]=F,B[W]=P,W=b;else break e}}function r(B){return B.length===0?null:B[0]}function a(B){if(B.length===0)return null;var F=B[0],W=B.pop();if(W!==F){B[0]=W;e:for(var b=0,P=B.length,fe=P>>>1;b<fe;){var pe=2*(b+1)-1,ce=B[pe],ke=pe+1,he=B[ke];if(0>l(ce,W))ke<P&&0>l(he,ce)?(B[b]=he,B[ke]=W,b=ke):(B[b]=ce,B[pe]=W,b=pe);else if(ke<P&&0>l(he,W))B[b]=he,B[ke]=W,b=ke;else break e}}return F}function l(B,F){var W=B.sortIndex-F.sortIndex;return W!==0?W:B.id-F.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var f=Date,m=f.now();t.unstable_now=function(){return f.now()-m}}var g=[],p=[],k=1,v=null,w=3,N=!1,M=!1,S=!1,E=typeof setTimeout=="function"?setTimeout:null,I=typeof clearTimeout=="function"?clearTimeout:null,_=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function O(B){for(var F=r(p);F!==null;){if(F.callback===null)a(p);else if(F.startTime<=B)a(p),F.sortIndex=F.expirationTime,s(g,F);else break;F=r(p)}}function ee(B){if(S=!1,O(B),!M)if(r(g)!==null)M=!0,ue(q);else{var F=r(p);F!==null&&me(ee,F.startTime-B)}}function q(B,F){M=!1,S&&(S=!1,I(ae),ae=-1),N=!0;var W=w;try{for(O(F),v=r(g);v!==null&&(!(v.expirationTime>F)||B&&!ze());){var b=v.callback;if(typeof b=="function"){v.callback=null,w=v.priorityLevel;var P=b(v.expirationTime<=F);F=t.unstable_now(),typeof P=="function"?v.callback=P:v===r(g)&&a(g),O(F)}else a(g);v=r(g)}if(v!==null)var fe=!0;else{var pe=r(p);pe!==null&&me(ee,pe.startTime-F),fe=!1}return fe}finally{v=null,w=W,N=!1}}var V=!1,ie=null,ae=-1,K=5,xe=-1;function ze(){return!(t.unstable_now()-xe<K)}function $e(){if(ie!==null){var B=t.unstable_now();xe=B;var F=!0;try{F=ie(!0,B)}finally{F?L():(V=!1,ie=null)}}else V=!1}var L;if(typeof _=="function")L=function(){_($e)};else if(typeof MessageChannel<"u"){var Q=new MessageChannel,se=Q.port2;Q.port1.onmessage=$e,L=function(){se.postMessage(null)}}else L=function(){E($e,0)};function ue(B){ie=B,V||(V=!0,L())}function me(B,F){ae=E(function(){B(t.unstable_now())},F)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(B){B.callback=null},t.unstable_continueExecution=function(){M||N||(M=!0,ue(q))},t.unstable_forceFrameRate=function(B){0>B||125<B?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):K=0<B?Math.floor(1e3/B):5},t.unstable_getCurrentPriorityLevel=function(){return w},t.unstable_getFirstCallbackNode=function(){return r(g)},t.unstable_next=function(B){switch(w){case 1:case 2:case 3:var F=3;break;default:F=w}var W=w;w=F;try{return B()}finally{w=W}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(B,F){switch(B){case 1:case 2:case 3:case 4:case 5:break;default:B=3}var W=w;w=B;try{return F()}finally{w=W}},t.unstable_scheduleCallback=function(B,F,W){var b=t.unstable_now();switch(typeof W=="object"&&W!==null?(W=W.delay,W=typeof W=="number"&&0<W?b+W:b):W=b,B){case 1:var P=-1;break;case 2:P=250;break;case 5:P=1073741823;break;case 4:P=1e4;break;default:P=5e3}return P=W+P,B={id:k++,callback:F,priorityLevel:B,startTime:W,expirationTime:P,sortIndex:-1},W>b?(B.sortIndex=W,s(p,B),r(g)===null&&B===r(p)&&(S?(I(ae),ae=-1):S=!0,me(ee,W-b))):(B.sortIndex=P,s(g,B),M||N||(M=!0,ue(q))),B},t.unstable_shouldYield=ze,t.unstable_wrapCallback=function(B){var F=w;return function(){var W=w;w=F;try{return B.apply(this,arguments)}finally{w=W}}}})(vl)),vl}var sf;function ug(){return sf||(sf=1,gl.exports=cg()),gl.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 rf;function dg(){if(rf)return pt;rf=1;var t=Pl(),s=ug();function r(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,o=1;o<arguments.length;o++)n+="&args[]="+encodeURIComponent(arguments[o]);return"Minified React error #"+e+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var a=new Set,l={};function u(e,n){f(e,n),f(e+"Capture",n)}function f(e,n){for(l[e]=n,e=0;e<n.length;e++)a.add(n[e])}var m=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),g=Object.prototype.hasOwnProperty,p=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,k={},v={};function w(e){return g.call(v,e)?!0:g.call(k,e)?!1:p.test(e)?v[e]=!0:(k[e]=!0,!1)}function N(e,n,o,c){if(o!==null&&o.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return c?!1:o!==null?!o.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function M(e,n,o,c){if(n===null||typeof n>"u"||N(e,n,o,c))return!0;if(c)return!1;if(o!==null)switch(o.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function S(e,n,o,c,d,h,y){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=c,this.attributeNamespace=d,this.mustUseProperty=o,this.propertyName=e,this.type=n,this.sanitizeURL=h,this.removeEmptyString=y}var E={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){E[e]=new S(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];E[n]=new S(n,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){E[e]=new S(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){E[e]=new S(e,2,!1,e,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(e){E[e]=new S(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){E[e]=new S(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){E[e]=new S(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){E[e]=new S(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){E[e]=new S(e,5,!1,e.toLowerCase(),null,!1,!1)});var I=/[\-:]([a-z])/g;function _(e){return e[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(e){var n=e.replace(I,_);E[n]=new S(n,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var n=e.replace(I,_);E[n]=new S(n,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var n=e.replace(I,_);E[n]=new S(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){E[e]=new S(e,1,!1,e.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(e){E[e]=new S(e,1,!1,e.toLowerCase(),null,!0,!0)});function O(e,n,o,c){var d=E.hasOwnProperty(n)?E[n]:null;(d!==null?d.type!==0:c||!(2<n.length)||n[0]!=="o"&&n[0]!=="O"||n[1]!=="n"&&n[1]!=="N")&&(M(n,o,d,c)&&(o=null),c||d===null?w(n)&&(o===null?e.removeAttribute(n):e.setAttribute(n,""+o)):d.mustUseProperty?e[d.propertyName]=o===null?d.type===3?!1:"":o:(n=d.attributeName,c=d.attributeNamespace,o===null?e.removeAttribute(n):(d=d.type,o=d===3||d===4&&o===!0?"":""+o,c?e.setAttributeNS(c,n,o):e.setAttribute(n,o))))}var ee=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,q=Symbol.for("react.element"),V=Symbol.for("react.portal"),ie=Symbol.for("react.fragment"),ae=Symbol.for("react.strict_mode"),K=Symbol.for("react.profiler"),xe=Symbol.for("react.provider"),ze=Symbol.for("react.context"),$e=Symbol.for("react.forward_ref"),L=Symbol.for("react.suspense"),Q=Symbol.for("react.suspense_list"),se=Symbol.for("react.memo"),ue=Symbol.for("react.lazy"),me=Symbol.for("react.offscreen"),B=Symbol.iterator;function F(e){return e===null||typeof e!="object"?null:(e=B&&e[B]||e["@@iterator"],typeof e=="function"?e:null)}var W=Object.assign,b;function P(e){if(b===void 0)try{throw Error()}catch(o){var n=o.stack.trim().match(/\n( *(at )?)/);b=n&&n[1]||""}return`
34
+ `+b+e}var fe=!1;function pe(e,n){if(!e||fe)return"";fe=!0;var o=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(n)if(n=function(){throw Error()},Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(n,[])}catch(R){var c=R}Reflect.construct(e,[],n)}else{try{n.call()}catch(R){c=R}e.call(n.prototype)}else{try{throw Error()}catch(R){c=R}e()}}catch(R){if(R&&c&&typeof R.stack=="string"){for(var d=R.stack.split(`
35
+ `),h=c.stack.split(`
36
+ `),y=d.length-1,j=h.length-1;1<=y&&0<=j&&d[y]!==h[j];)j--;for(;1<=y&&0<=j;y--,j--)if(d[y]!==h[j]){if(y!==1||j!==1)do if(y--,j--,0>j||d[y]!==h[j]){var C=`
37
+ `+d[y].replace(" at new "," at ");return e.displayName&&C.includes("<anonymous>")&&(C=C.replace("<anonymous>",e.displayName)),C}while(1<=y&&0<=j);break}}}finally{fe=!1,Error.prepareStackTrace=o}return(e=e?e.displayName||e.name:"")?P(e):""}function ce(e){switch(e.tag){case 5:return P(e.type);case 16:return P("Lazy");case 13:return P("Suspense");case 19:return P("SuspenseList");case 0:case 2:case 15:return e=pe(e.type,!1),e;case 11:return e=pe(e.type.render,!1),e;case 1:return e=pe(e.type,!0),e;default:return""}}function ke(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case ie:return"Fragment";case V:return"Portal";case K:return"Profiler";case ae:return"StrictMode";case L:return"Suspense";case Q:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case ze:return(e.displayName||"Context")+".Consumer";case xe:return(e._context.displayName||"Context")+".Provider";case $e:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case se:return n=e.displayName||null,n!==null?n:ke(e.type)||"Memo";case ue:n=e._payload,e=e._init;try{return ke(e(n))}catch{}}return null}function he(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ke(n);case 8:return n===ae?"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 n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function ve(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function be(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function rt(e){var n=be(e)?"checked":"value",o=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),c=""+e[n];if(!e.hasOwnProperty(n)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var d=o.get,h=o.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return d.call(this)},set:function(y){c=""+y,h.call(this,y)}}),Object.defineProperty(e,n,{enumerable:o.enumerable}),{getValue:function(){return c},setValue:function(y){c=""+y},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function Jn(e){e._valueTracker||(e._valueTracker=rt(e))}function ic(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var o=n.getValue(),c="";return e&&(c=be(e)?e.checked?"true":"false":e.value),e=c,e!==o?(n.setValue(e),!0):!1}function _i(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function xo(e,n){var o=n.checked;return W({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:o??e._wrapperState.initialChecked})}function rc(e,n){var o=n.defaultValue==null?"":n.defaultValue,c=n.checked!=null?n.checked:n.defaultChecked;o=ve(n.value!=null?n.value:o),e._wrapperState={initialChecked:c,initialValue:o,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function oc(e,n){n=n.checked,n!=null&&O(e,"checked",n,!1)}function wo(e,n){oc(e,n);var o=ve(n.value),c=n.type;if(o!=null)c==="number"?(o===0&&e.value===""||e.value!=o)&&(e.value=""+o):e.value!==""+o&&(e.value=""+o);else if(c==="submit"||c==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?jo(e,n.type,o):n.hasOwnProperty("defaultValue")&&jo(e,n.type,ve(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function ac(e,n,o){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var c=n.type;if(!(c!=="submit"&&c!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,o||n===e.value||(e.value=n),e.defaultValue=n}o=e.name,o!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,o!==""&&(e.name=o)}function jo(e,n,o){(n!=="number"||_i(e.ownerDocument)!==e)&&(o==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+o&&(e.defaultValue=""+o))}var Os=Array.isArray;function Xn(e,n,o,c){if(e=e.options,n){n={};for(var d=0;d<o.length;d++)n["$"+o[d]]=!0;for(o=0;o<e.length;o++)d=n.hasOwnProperty("$"+e[o].value),e[o].selected!==d&&(e[o].selected=d),d&&c&&(e[o].defaultSelected=!0)}else{for(o=""+ve(o),n=null,d=0;d<e.length;d++){if(e[d].value===o){e[d].selected=!0,c&&(e[d].defaultSelected=!0);return}n!==null||e[d].disabled||(n=e[d])}n!==null&&(n.selected=!0)}}function So(e,n){if(n.dangerouslySetInnerHTML!=null)throw Error(r(91));return W({},n,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function lc(e,n){var o=n.value;if(o==null){if(o=n.children,n=n.defaultValue,o!=null){if(n!=null)throw Error(r(92));if(Os(o)){if(1<o.length)throw Error(r(93));o=o[0]}n=o}n==null&&(n=""),o=n}e._wrapperState={initialValue:ve(o)}}function cc(e,n){var o=ve(n.value),c=ve(n.defaultValue);o!=null&&(o=""+o,o!==e.value&&(e.value=o),n.defaultValue==null&&e.defaultValue!==o&&(e.defaultValue=o)),c!=null&&(e.defaultValue=""+c)}function uc(e){var n=e.textContent;n===e._wrapperState.initialValue&&n!==""&&n!==null&&(e.value=n)}function dc(e){switch(e){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 No(e,n){return e==null||e==="http://www.w3.org/1999/xhtml"?dc(n):e==="http://www.w3.org/2000/svg"&&n==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Pi,fc=(function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(n,o,c,d){MSApp.execUnsafeLocalFunction(function(){return e(n,o,c,d)})}:e})(function(e,n){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=n;else{for(Pi=Pi||document.createElement("div"),Pi.innerHTML="<svg>"+n.valueOf().toString()+"</svg>",n=Pi.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function _s(e,n){if(n){var o=e.firstChild;if(o&&o===e.lastChild&&o.nodeType===3){o.nodeValue=n;return}}e.textContent=n}var Ps={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},lm=["Webkit","ms","Moz","O"];Object.keys(Ps).forEach(function(e){lm.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),Ps[n]=Ps[e]})});function hc(e,n,o){return n==null||typeof n=="boolean"||n===""?"":o||typeof n!="number"||n===0||Ps.hasOwnProperty(e)&&Ps[e]?(""+n).trim():n+"px"}function mc(e,n){e=e.style;for(var o in n)if(n.hasOwnProperty(o)){var c=o.indexOf("--")===0,d=hc(o,n[o],c);o==="float"&&(o="cssFloat"),c?e.setProperty(o,d):e[o]=d}}var cm=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 Co(e,n){if(n){if(cm[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(r(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(r(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(r(61))}if(n.style!=null&&typeof n.style!="object")throw Error(r(62))}}function $o(e,n){if(e.indexOf("-")===-1)return typeof n.is=="string";switch(e){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 bo=null;function To(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Eo=null,Zn=null,es=null;function pc(e){if(e=ri(e)){if(typeof Eo!="function")throw Error(r(280));var n=e.stateNode;n&&(n=or(n),Eo(e.stateNode,e.type,n))}}function gc(e){Zn?es?es.push(e):es=[e]:Zn=e}function vc(){if(Zn){var e=Zn,n=es;if(es=Zn=null,pc(e),n)for(e=0;e<n.length;e++)pc(n[e])}}function yc(e,n){return e(n)}function kc(){}var Mo=!1;function xc(e,n,o){if(Mo)return e(n,o);Mo=!0;try{return yc(e,n,o)}finally{Mo=!1,(Zn!==null||es!==null)&&(kc(),vc())}}function Ds(e,n){var o=e.stateNode;if(o===null)return null;var c=or(o);if(c===null)return null;o=c[n];e:switch(n){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(c=!c.disabled)||(e=e.type,c=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!c;break e;default:e=!1}if(e)return null;if(o&&typeof o!="function")throw Error(r(231,n,typeof o));return o}var Io=!1;if(m)try{var zs={};Object.defineProperty(zs,"passive",{get:function(){Io=!0}}),window.addEventListener("test",zs,zs),window.removeEventListener("test",zs,zs)}catch{Io=!1}function um(e,n,o,c,d,h,y,j,C){var R=Array.prototype.slice.call(arguments,3);try{n.apply(o,R)}catch(z){this.onError(z)}}var Bs=!1,Di=null,zi=!1,Ao=null,dm={onError:function(e){Bs=!0,Di=e}};function fm(e,n,o,c,d,h,y,j,C){Bs=!1,Di=null,um.apply(dm,arguments)}function hm(e,n,o,c,d,h,y,j,C){if(fm.apply(this,arguments),Bs){if(Bs){var R=Di;Bs=!1,Di=null}else throw Error(r(198));zi||(zi=!0,Ao=R)}}function Ln(e){var n=e,o=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do n=e,(n.flags&4098)!==0&&(o=n.return),e=n.return;while(e)}return n.tag===3?o:null}function wc(e){if(e.tag===13){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function jc(e){if(Ln(e)!==e)throw Error(r(188))}function mm(e){var n=e.alternate;if(!n){if(n=Ln(e),n===null)throw Error(r(188));return n!==e?null:e}for(var o=e,c=n;;){var d=o.return;if(d===null)break;var h=d.alternate;if(h===null){if(c=d.return,c!==null){o=c;continue}break}if(d.child===h.child){for(h=d.child;h;){if(h===o)return jc(d),e;if(h===c)return jc(d),n;h=h.sibling}throw Error(r(188))}if(o.return!==c.return)o=d,c=h;else{for(var y=!1,j=d.child;j;){if(j===o){y=!0,o=d,c=h;break}if(j===c){y=!0,c=d,o=h;break}j=j.sibling}if(!y){for(j=h.child;j;){if(j===o){y=!0,o=h,c=d;break}if(j===c){y=!0,c=h,o=d;break}j=j.sibling}if(!y)throw Error(r(189))}}if(o.alternate!==c)throw Error(r(190))}if(o.tag!==3)throw Error(r(188));return o.stateNode.current===o?e:n}function Sc(e){return e=mm(e),e!==null?Nc(e):null}function Nc(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var n=Nc(e);if(n!==null)return n;e=e.sibling}return null}var Cc=s.unstable_scheduleCallback,$c=s.unstable_cancelCallback,pm=s.unstable_shouldYield,gm=s.unstable_requestPaint,Pe=s.unstable_now,vm=s.unstable_getCurrentPriorityLevel,Lo=s.unstable_ImmediatePriority,bc=s.unstable_UserBlockingPriority,Bi=s.unstable_NormalPriority,ym=s.unstable_LowPriority,Tc=s.unstable_IdlePriority,Fi=null,Dt=null;function km(e){if(Dt&&typeof Dt.onCommitFiberRoot=="function")try{Dt.onCommitFiberRoot(Fi,e,void 0,(e.current.flags&128)===128)}catch{}}var Mt=Math.clz32?Math.clz32:jm,xm=Math.log,wm=Math.LN2;function jm(e){return e>>>=0,e===0?32:31-(xm(e)/wm|0)|0}var Ui=64,Wi=4194304;function Fs(e){switch(e&-e){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 e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Hi(e,n){var o=e.pendingLanes;if(o===0)return 0;var c=0,d=e.suspendedLanes,h=e.pingedLanes,y=o&268435455;if(y!==0){var j=y&~d;j!==0?c=Fs(j):(h&=y,h!==0&&(c=Fs(h)))}else y=o&~d,y!==0?c=Fs(y):h!==0&&(c=Fs(h));if(c===0)return 0;if(n!==0&&n!==c&&(n&d)===0&&(d=c&-c,h=n&-n,d>=h||d===16&&(h&4194240)!==0))return n;if((c&4)!==0&&(c|=o&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=c;0<n;)o=31-Mt(n),d=1<<o,c|=e[o],n&=~d;return c}function Sm(e,n){switch(e){case 1:case 2:case 4:return n+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 n+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 Nm(e,n){for(var o=e.suspendedLanes,c=e.pingedLanes,d=e.expirationTimes,h=e.pendingLanes;0<h;){var y=31-Mt(h),j=1<<y,C=d[y];C===-1?((j&o)===0||(j&c)!==0)&&(d[y]=Sm(j,n)):C<=n&&(e.expiredLanes|=j),h&=~j}}function Ro(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function Ec(){var e=Ui;return Ui<<=1,(Ui&4194240)===0&&(Ui=64),e}function Oo(e){for(var n=[],o=0;31>o;o++)n.push(e);return n}function Us(e,n,o){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Mt(n),e[n]=o}function Cm(e,n){var o=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var c=e.eventTimes;for(e=e.expirationTimes;0<o;){var d=31-Mt(o),h=1<<d;n[d]=0,c[d]=-1,e[d]=-1,o&=~h}}function _o(e,n){var o=e.entangledLanes|=n;for(e=e.entanglements;o;){var c=31-Mt(o),d=1<<c;d&n|e[c]&n&&(e[c]|=n),o&=~d}}var Ne=0;function Mc(e){return e&=-e,1<e?4<e?(e&268435455)!==0?16:536870912:4:1}var Ic,Po,Ac,Lc,Rc,Do=!1,Vi=[],an=null,ln=null,cn=null,Ws=new Map,Hs=new Map,un=[],$m="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 Oc(e,n){switch(e){case"focusin":case"focusout":an=null;break;case"dragenter":case"dragleave":ln=null;break;case"mouseover":case"mouseout":cn=null;break;case"pointerover":case"pointerout":Ws.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":Hs.delete(n.pointerId)}}function Vs(e,n,o,c,d,h){return e===null||e.nativeEvent!==h?(e={blockedOn:n,domEventName:o,eventSystemFlags:c,nativeEvent:h,targetContainers:[d]},n!==null&&(n=ri(n),n!==null&&Po(n)),e):(e.eventSystemFlags|=c,n=e.targetContainers,d!==null&&n.indexOf(d)===-1&&n.push(d),e)}function bm(e,n,o,c,d){switch(n){case"focusin":return an=Vs(an,e,n,o,c,d),!0;case"dragenter":return ln=Vs(ln,e,n,o,c,d),!0;case"mouseover":return cn=Vs(cn,e,n,o,c,d),!0;case"pointerover":var h=d.pointerId;return Ws.set(h,Vs(Ws.get(h)||null,e,n,o,c,d)),!0;case"gotpointercapture":return h=d.pointerId,Hs.set(h,Vs(Hs.get(h)||null,e,n,o,c,d)),!0}return!1}function _c(e){var n=Rn(e.target);if(n!==null){var o=Ln(n);if(o!==null){if(n=o.tag,n===13){if(n=wc(o),n!==null){e.blockedOn=n,Rc(e.priority,function(){Ac(o)});return}}else if(n===3&&o.stateNode.current.memoizedState.isDehydrated){e.blockedOn=o.tag===3?o.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Ki(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContainers;0<n.length;){var o=Bo(e.domEventName,e.eventSystemFlags,n[0],e.nativeEvent);if(o===null){o=e.nativeEvent;var c=new o.constructor(o.type,o);bo=c,o.target.dispatchEvent(c),bo=null}else return n=ri(o),n!==null&&Po(n),e.blockedOn=o,!1;n.shift()}return!0}function Pc(e,n,o){Ki(e)&&o.delete(n)}function Tm(){Do=!1,an!==null&&Ki(an)&&(an=null),ln!==null&&Ki(ln)&&(ln=null),cn!==null&&Ki(cn)&&(cn=null),Ws.forEach(Pc),Hs.forEach(Pc)}function Ks(e,n){e.blockedOn===n&&(e.blockedOn=null,Do||(Do=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,Tm)))}function Qs(e){function n(d){return Ks(d,e)}if(0<Vi.length){Ks(Vi[0],e);for(var o=1;o<Vi.length;o++){var c=Vi[o];c.blockedOn===e&&(c.blockedOn=null)}}for(an!==null&&Ks(an,e),ln!==null&&Ks(ln,e),cn!==null&&Ks(cn,e),Ws.forEach(n),Hs.forEach(n),o=0;o<un.length;o++)c=un[o],c.blockedOn===e&&(c.blockedOn=null);for(;0<un.length&&(o=un[0],o.blockedOn===null);)_c(o),o.blockedOn===null&&un.shift()}var ts=ee.ReactCurrentBatchConfig,Qi=!0;function Em(e,n,o,c){var d=Ne,h=ts.transition;ts.transition=null;try{Ne=1,zo(e,n,o,c)}finally{Ne=d,ts.transition=h}}function Mm(e,n,o,c){var d=Ne,h=ts.transition;ts.transition=null;try{Ne=4,zo(e,n,o,c)}finally{Ne=d,ts.transition=h}}function zo(e,n,o,c){if(Qi){var d=Bo(e,n,o,c);if(d===null)sa(e,n,c,qi,o),Oc(e,c);else if(bm(d,e,n,o,c))c.stopPropagation();else if(Oc(e,c),n&4&&-1<$m.indexOf(e)){for(;d!==null;){var h=ri(d);if(h!==null&&Ic(h),h=Bo(e,n,o,c),h===null&&sa(e,n,c,qi,o),h===d)break;d=h}d!==null&&c.stopPropagation()}else sa(e,n,c,null,o)}}var qi=null;function Bo(e,n,o,c){if(qi=null,e=To(c),e=Rn(e),e!==null)if(n=Ln(e),n===null)e=null;else if(o=n.tag,o===13){if(e=wc(n),e!==null)return e;e=null}else if(o===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;e=null}else n!==e&&(e=null);return qi=e,null}function Dc(e){switch(e){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(vm()){case Lo:return 1;case bc:return 4;case Bi:case ym:return 16;case Tc:return 536870912;default:return 16}default:return 16}}var dn=null,Fo=null,Gi=null;function zc(){if(Gi)return Gi;var e,n=Fo,o=n.length,c,d="value"in dn?dn.value:dn.textContent,h=d.length;for(e=0;e<o&&n[e]===d[e];e++);var y=o-e;for(c=1;c<=y&&n[o-c]===d[h-c];c++);return Gi=d.slice(e,1<c?1-c:void 0)}function Yi(e){var n=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&n===13&&(e=13)):e=n,e===10&&(e=13),32<=e||e===13?e:0}function Ji(){return!0}function Bc(){return!1}function vt(e){function n(o,c,d,h,y){this._reactName=o,this._targetInst=d,this.type=c,this.nativeEvent=h,this.target=y,this.currentTarget=null;for(var j in e)e.hasOwnProperty(j)&&(o=e[j],this[j]=o?o(h):h[j]);return this.isDefaultPrevented=(h.defaultPrevented!=null?h.defaultPrevented:h.returnValue===!1)?Ji:Bc,this.isPropagationStopped=Bc,this}return W(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var o=this.nativeEvent;o&&(o.preventDefault?o.preventDefault():typeof o.returnValue!="unknown"&&(o.returnValue=!1),this.isDefaultPrevented=Ji)},stopPropagation:function(){var o=this.nativeEvent;o&&(o.stopPropagation?o.stopPropagation():typeof o.cancelBubble!="unknown"&&(o.cancelBubble=!0),this.isPropagationStopped=Ji)},persist:function(){},isPersistent:Ji}),n}var ns={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Uo=vt(ns),qs=W({},ns,{view:0,detail:0}),Im=vt(qs),Wo,Ho,Gs,Xi=W({},qs,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ko,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==Gs&&(Gs&&e.type==="mousemove"?(Wo=e.screenX-Gs.screenX,Ho=e.screenY-Gs.screenY):Ho=Wo=0,Gs=e),Wo)},movementY:function(e){return"movementY"in e?e.movementY:Ho}}),Fc=vt(Xi),Am=W({},Xi,{dataTransfer:0}),Lm=vt(Am),Rm=W({},qs,{relatedTarget:0}),Vo=vt(Rm),Om=W({},ns,{animationName:0,elapsedTime:0,pseudoElement:0}),_m=vt(Om),Pm=W({},ns,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Dm=vt(Pm),zm=W({},ns,{data:0}),Uc=vt(zm),Bm={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Fm={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"},Um={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Wm(e){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(e):(e=Um[e])?!!n[e]:!1}function Ko(){return Wm}var Hm=W({},qs,{key:function(e){if(e.key){var n=Bm[e.key]||e.key;if(n!=="Unidentified")return n}return e.type==="keypress"?(e=Yi(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Fm[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ko,charCode:function(e){return e.type==="keypress"?Yi(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Yi(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Vm=vt(Hm),Km=W({},Xi,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Wc=vt(Km),Qm=W({},qs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ko}),qm=vt(Qm),Gm=W({},ns,{propertyName:0,elapsedTime:0,pseudoElement:0}),Ym=vt(Gm),Jm=W({},Xi,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),Xm=vt(Jm),Zm=[9,13,27,32],Qo=m&&"CompositionEvent"in window,Ys=null;m&&"documentMode"in document&&(Ys=document.documentMode);var ep=m&&"TextEvent"in window&&!Ys,Hc=m&&(!Qo||Ys&&8<Ys&&11>=Ys),Vc=" ",Kc=!1;function Qc(e,n){switch(e){case"keyup":return Zm.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function qc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ss=!1;function tp(e,n){switch(e){case"compositionend":return qc(n);case"keypress":return n.which!==32?null:(Kc=!0,Vc);case"textInput":return e=n.data,e===Vc&&Kc?null:e;default:return null}}function np(e,n){if(ss)return e==="compositionend"||!Qo&&Qc(e,n)?(e=zc(),Gi=Fo=dn=null,ss=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1<n.char.length)return n.char;if(n.which)return String.fromCharCode(n.which)}return null;case"compositionend":return Hc&&n.locale!=="ko"?null:n.data;default:return null}}var sp={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 Gc(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n==="input"?!!sp[e.type]:n==="textarea"}function Yc(e,n,o,c){gc(c),n=sr(n,"onChange"),0<n.length&&(o=new Uo("onChange","change",null,o,c),e.push({event:o,listeners:n}))}var Js=null,Xs=null;function ip(e){mu(e,0)}function Zi(e){var n=ls(e);if(ic(n))return e}function rp(e,n){if(e==="change")return n}var Jc=!1;if(m){var qo;if(m){var Go="oninput"in document;if(!Go){var Xc=document.createElement("div");Xc.setAttribute("oninput","return;"),Go=typeof Xc.oninput=="function"}qo=Go}else qo=!1;Jc=qo&&(!document.documentMode||9<document.documentMode)}function Zc(){Js&&(Js.detachEvent("onpropertychange",eu),Xs=Js=null)}function eu(e){if(e.propertyName==="value"&&Zi(Xs)){var n=[];Yc(n,Xs,e,To(e)),xc(ip,n)}}function op(e,n,o){e==="focusin"?(Zc(),Js=n,Xs=o,Js.attachEvent("onpropertychange",eu)):e==="focusout"&&Zc()}function ap(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Zi(Xs)}function lp(e,n){if(e==="click")return Zi(n)}function cp(e,n){if(e==="input"||e==="change")return Zi(n)}function up(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}var It=typeof Object.is=="function"?Object.is:up;function Zs(e,n){if(It(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;var o=Object.keys(e),c=Object.keys(n);if(o.length!==c.length)return!1;for(c=0;c<o.length;c++){var d=o[c];if(!g.call(n,d)||!It(e[d],n[d]))return!1}return!0}function tu(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function nu(e,n){var o=tu(e);e=0;for(var c;o;){if(o.nodeType===3){if(c=e+o.textContent.length,e<=n&&c>=n)return{node:o,offset:n-e};e=c}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=tu(o)}}function su(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?su(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function iu(){for(var e=window,n=_i();n instanceof e.HTMLIFrameElement;){try{var o=typeof n.contentWindow.location.href=="string"}catch{o=!1}if(o)e=n.contentWindow;else break;n=_i(e.document)}return n}function Yo(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}function dp(e){var n=iu(),o=e.focusedElem,c=e.selectionRange;if(n!==o&&o&&o.ownerDocument&&su(o.ownerDocument.documentElement,o)){if(c!==null&&Yo(o)){if(n=c.start,e=c.end,e===void 0&&(e=n),"selectionStart"in o)o.selectionStart=n,o.selectionEnd=Math.min(e,o.value.length);else if(e=(n=o.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var d=o.textContent.length,h=Math.min(c.start,d);c=c.end===void 0?h:Math.min(c.end,d),!e.extend&&h>c&&(d=c,c=h,h=d),d=nu(o,h);var y=nu(o,c);d&&y&&(e.rangeCount!==1||e.anchorNode!==d.node||e.anchorOffset!==d.offset||e.focusNode!==y.node||e.focusOffset!==y.offset)&&(n=n.createRange(),n.setStart(d.node,d.offset),e.removeAllRanges(),h>c?(e.addRange(n),e.extend(y.node,y.offset)):(n.setEnd(y.node,y.offset),e.addRange(n)))}}for(n=[],e=o;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof o.focus=="function"&&o.focus(),o=0;o<n.length;o++)e=n[o],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var fp=m&&"documentMode"in document&&11>=document.documentMode,is=null,Jo=null,ei=null,Xo=!1;function ru(e,n,o){var c=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Xo||is==null||is!==_i(c)||(c=is,"selectionStart"in c&&Yo(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),ei&&Zs(ei,c)||(ei=c,c=sr(Jo,"onSelect"),0<c.length&&(n=new Uo("onSelect","select",null,n,o),e.push({event:n,listeners:c}),n.target=is)))}function er(e,n){var o={};return o[e.toLowerCase()]=n.toLowerCase(),o["Webkit"+e]="webkit"+n,o["Moz"+e]="moz"+n,o}var rs={animationend:er("Animation","AnimationEnd"),animationiteration:er("Animation","AnimationIteration"),animationstart:er("Animation","AnimationStart"),transitionend:er("Transition","TransitionEnd")},Zo={},ou={};m&&(ou=document.createElement("div").style,"AnimationEvent"in window||(delete rs.animationend.animation,delete rs.animationiteration.animation,delete rs.animationstart.animation),"TransitionEvent"in window||delete rs.transitionend.transition);function tr(e){if(Zo[e])return Zo[e];if(!rs[e])return e;var n=rs[e],o;for(o in n)if(n.hasOwnProperty(o)&&o in ou)return Zo[e]=n[o];return e}var au=tr("animationend"),lu=tr("animationiteration"),cu=tr("animationstart"),uu=tr("transitionend"),du=new Map,fu="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 fn(e,n){du.set(e,n),u(n,[e])}for(var ea=0;ea<fu.length;ea++){var ta=fu[ea],hp=ta.toLowerCase(),mp=ta[0].toUpperCase()+ta.slice(1);fn(hp,"on"+mp)}fn(au,"onAnimationEnd"),fn(lu,"onAnimationIteration"),fn(cu,"onAnimationStart"),fn("dblclick","onDoubleClick"),fn("focusin","onFocus"),fn("focusout","onBlur"),fn(uu,"onTransitionEnd"),f("onMouseEnter",["mouseout","mouseover"]),f("onMouseLeave",["mouseout","mouseover"]),f("onPointerEnter",["pointerout","pointerover"]),f("onPointerLeave",["pointerout","pointerover"]),u("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),u("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),u("onBeforeInput",["compositionend","keypress","textInput","paste"]),u("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ti="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(" "),pp=new Set("cancel close invalid load scroll toggle".split(" ").concat(ti));function hu(e,n,o){var c=e.type||"unknown-event";e.currentTarget=o,hm(c,n,void 0,e),e.currentTarget=null}function mu(e,n){n=(n&4)!==0;for(var o=0;o<e.length;o++){var c=e[o],d=c.event;c=c.listeners;e:{var h=void 0;if(n)for(var y=c.length-1;0<=y;y--){var j=c[y],C=j.instance,R=j.currentTarget;if(j=j.listener,C!==h&&d.isPropagationStopped())break e;hu(d,j,R),h=C}else for(y=0;y<c.length;y++){if(j=c[y],C=j.instance,R=j.currentTarget,j=j.listener,C!==h&&d.isPropagationStopped())break e;hu(d,j,R),h=C}}}if(zi)throw e=Ao,zi=!1,Ao=null,e}function Me(e,n){var o=n[ca];o===void 0&&(o=n[ca]=new Set);var c=e+"__bubble";o.has(c)||(pu(n,e,2,!1),o.add(c))}function na(e,n,o){var c=0;n&&(c|=4),pu(o,e,c,n)}var nr="_reactListening"+Math.random().toString(36).slice(2);function ni(e){if(!e[nr]){e[nr]=!0,a.forEach(function(o){o!=="selectionchange"&&(pp.has(o)||na(o,!1,e),na(o,!0,e))});var n=e.nodeType===9?e:e.ownerDocument;n===null||n[nr]||(n[nr]=!0,na("selectionchange",!1,n))}}function pu(e,n,o,c){switch(Dc(n)){case 1:var d=Em;break;case 4:d=Mm;break;default:d=zo}o=d.bind(null,n,o,e),d=void 0,!Io||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(d=!0),c?d!==void 0?e.addEventListener(n,o,{capture:!0,passive:d}):e.addEventListener(n,o,!0):d!==void 0?e.addEventListener(n,o,{passive:d}):e.addEventListener(n,o,!1)}function sa(e,n,o,c,d){var h=c;if((n&1)===0&&(n&2)===0&&c!==null)e:for(;;){if(c===null)return;var y=c.tag;if(y===3||y===4){var j=c.stateNode.containerInfo;if(j===d||j.nodeType===8&&j.parentNode===d)break;if(y===4)for(y=c.return;y!==null;){var C=y.tag;if((C===3||C===4)&&(C=y.stateNode.containerInfo,C===d||C.nodeType===8&&C.parentNode===d))return;y=y.return}for(;j!==null;){if(y=Rn(j),y===null)return;if(C=y.tag,C===5||C===6){c=h=y;continue e}j=j.parentNode}}c=c.return}xc(function(){var R=h,z=To(o),U=[];e:{var D=du.get(e);if(D!==void 0){var Y=Uo,X=e;switch(e){case"keypress":if(Yi(o)===0)break e;case"keydown":case"keyup":Y=Vm;break;case"focusin":X="focus",Y=Vo;break;case"focusout":X="blur",Y=Vo;break;case"beforeblur":case"afterblur":Y=Vo;break;case"click":if(o.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Y=Fc;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Y=Lm;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Y=qm;break;case au:case lu:case cu:Y=_m;break;case uu:Y=Ym;break;case"scroll":Y=Im;break;case"wheel":Y=Xm;break;case"copy":case"cut":case"paste":Y=Dm;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Y=Wc}var Z=(n&4)!==0,De=!Z&&e==="scroll",T=Z?D!==null?D+"Capture":null:D;Z=[];for(var $=R,A;$!==null;){A=$;var H=A.stateNode;if(A.tag===5&&H!==null&&(A=H,T!==null&&(H=Ds($,T),H!=null&&Z.push(si($,H,A)))),De)break;$=$.return}0<Z.length&&(D=new Y(D,X,null,o,z),U.push({event:D,listeners:Z}))}}if((n&7)===0){e:{if(D=e==="mouseover"||e==="pointerover",Y=e==="mouseout"||e==="pointerout",D&&o!==bo&&(X=o.relatedTarget||o.fromElement)&&(Rn(X)||X[qt]))break e;if((Y||D)&&(D=z.window===z?z:(D=z.ownerDocument)?D.defaultView||D.parentWindow:window,Y?(X=o.relatedTarget||o.toElement,Y=R,X=X?Rn(X):null,X!==null&&(De=Ln(X),X!==De||X.tag!==5&&X.tag!==6)&&(X=null)):(Y=null,X=R),Y!==X)){if(Z=Fc,H="onMouseLeave",T="onMouseEnter",$="mouse",(e==="pointerout"||e==="pointerover")&&(Z=Wc,H="onPointerLeave",T="onPointerEnter",$="pointer"),De=Y==null?D:ls(Y),A=X==null?D:ls(X),D=new Z(H,$+"leave",Y,o,z),D.target=De,D.relatedTarget=A,H=null,Rn(z)===R&&(Z=new Z(T,$+"enter",X,o,z),Z.target=A,Z.relatedTarget=De,H=Z),De=H,Y&&X)t:{for(Z=Y,T=X,$=0,A=Z;A;A=os(A))$++;for(A=0,H=T;H;H=os(H))A++;for(;0<$-A;)Z=os(Z),$--;for(;0<A-$;)T=os(T),A--;for(;$--;){if(Z===T||T!==null&&Z===T.alternate)break t;Z=os(Z),T=os(T)}Z=null}else Z=null;Y!==null&&gu(U,D,Y,Z,!1),X!==null&&De!==null&&gu(U,De,X,Z,!0)}}e:{if(D=R?ls(R):window,Y=D.nodeName&&D.nodeName.toLowerCase(),Y==="select"||Y==="input"&&D.type==="file")var te=rp;else if(Gc(D))if(Jc)te=cp;else{te=ap;var re=op}else(Y=D.nodeName)&&Y.toLowerCase()==="input"&&(D.type==="checkbox"||D.type==="radio")&&(te=lp);if(te&&(te=te(e,R))){Yc(U,te,o,z);break e}re&&re(e,D,R),e==="focusout"&&(re=D._wrapperState)&&re.controlled&&D.type==="number"&&jo(D,"number",D.value)}switch(re=R?ls(R):window,e){case"focusin":(Gc(re)||re.contentEditable==="true")&&(is=re,Jo=R,ei=null);break;case"focusout":ei=Jo=is=null;break;case"mousedown":Xo=!0;break;case"contextmenu":case"mouseup":case"dragend":Xo=!1,ru(U,o,z);break;case"selectionchange":if(fp)break;case"keydown":case"keyup":ru(U,o,z)}var oe;if(Qo)e:{switch(e){case"compositionstart":var de="onCompositionStart";break e;case"compositionend":de="onCompositionEnd";break e;case"compositionupdate":de="onCompositionUpdate";break e}de=void 0}else ss?Qc(e,o)&&(de="onCompositionEnd"):e==="keydown"&&o.keyCode===229&&(de="onCompositionStart");de&&(Hc&&o.locale!=="ko"&&(ss||de!=="onCompositionStart"?de==="onCompositionEnd"&&ss&&(oe=zc()):(dn=z,Fo="value"in dn?dn.value:dn.textContent,ss=!0)),re=sr(R,de),0<re.length&&(de=new Uc(de,e,null,o,z),U.push({event:de,listeners:re}),oe?de.data=oe:(oe=qc(o),oe!==null&&(de.data=oe)))),(oe=ep?tp(e,o):np(e,o))&&(R=sr(R,"onBeforeInput"),0<R.length&&(z=new Uc("onBeforeInput","beforeinput",null,o,z),U.push({event:z,listeners:R}),z.data=oe))}mu(U,n)})}function si(e,n,o){return{instance:e,listener:n,currentTarget:o}}function sr(e,n){for(var o=n+"Capture",c=[];e!==null;){var d=e,h=d.stateNode;d.tag===5&&h!==null&&(d=h,h=Ds(e,o),h!=null&&c.unshift(si(e,h,d)),h=Ds(e,n),h!=null&&c.push(si(e,h,d))),e=e.return}return c}function os(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function gu(e,n,o,c,d){for(var h=n._reactName,y=[];o!==null&&o!==c;){var j=o,C=j.alternate,R=j.stateNode;if(C!==null&&C===c)break;j.tag===5&&R!==null&&(j=R,d?(C=Ds(o,h),C!=null&&y.unshift(si(o,C,j))):d||(C=Ds(o,h),C!=null&&y.push(si(o,C,j)))),o=o.return}y.length!==0&&e.push({event:n,listeners:y})}var gp=/\r\n?/g,vp=/\u0000|\uFFFD/g;function vu(e){return(typeof e=="string"?e:""+e).replace(gp,`
38
+ `).replace(vp,"")}function ir(e,n,o){if(n=vu(n),vu(e)!==n&&o)throw Error(r(425))}function rr(){}var ia=null,ra=null;function oa(e,n){return e==="textarea"||e==="noscript"||typeof n.children=="string"||typeof n.children=="number"||typeof n.dangerouslySetInnerHTML=="object"&&n.dangerouslySetInnerHTML!==null&&n.dangerouslySetInnerHTML.__html!=null}var aa=typeof setTimeout=="function"?setTimeout:void 0,yp=typeof clearTimeout=="function"?clearTimeout:void 0,yu=typeof Promise=="function"?Promise:void 0,kp=typeof queueMicrotask=="function"?queueMicrotask:typeof yu<"u"?function(e){return yu.resolve(null).then(e).catch(xp)}:aa;function xp(e){setTimeout(function(){throw e})}function la(e,n){var o=n,c=0;do{var d=o.nextSibling;if(e.removeChild(o),d&&d.nodeType===8)if(o=d.data,o==="/$"){if(c===0){e.removeChild(d),Qs(n);return}c--}else o!=="$"&&o!=="$?"&&o!=="$!"||c++;o=d}while(o);Qs(n)}function hn(e){for(;e!=null;e=e.nextSibling){var n=e.nodeType;if(n===1||n===3)break;if(n===8){if(n=e.data,n==="$"||n==="$!"||n==="$?")break;if(n==="/$")return null}}return e}function ku(e){e=e.previousSibling;for(var n=0;e;){if(e.nodeType===8){var o=e.data;if(o==="$"||o==="$!"||o==="$?"){if(n===0)return e;n--}else o==="/$"&&n++}e=e.previousSibling}return null}var as=Math.random().toString(36).slice(2),zt="__reactFiber$"+as,ii="__reactProps$"+as,qt="__reactContainer$"+as,ca="__reactEvents$"+as,wp="__reactListeners$"+as,jp="__reactHandles$"+as;function Rn(e){var n=e[zt];if(n)return n;for(var o=e.parentNode;o;){if(n=o[qt]||o[zt]){if(o=n.alternate,n.child!==null||o!==null&&o.child!==null)for(e=ku(e);e!==null;){if(o=e[zt])return o;e=ku(e)}return n}e=o,o=e.parentNode}return null}function ri(e){return e=e[zt]||e[qt],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function ls(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(r(33))}function or(e){return e[ii]||null}var ua=[],cs=-1;function mn(e){return{current:e}}function Ie(e){0>cs||(e.current=ua[cs],ua[cs]=null,cs--)}function Ee(e,n){cs++,ua[cs]=e.current,e.current=n}var pn={},Ze=mn(pn),ut=mn(!1),On=pn;function us(e,n){var o=e.type.contextTypes;if(!o)return pn;var c=e.stateNode;if(c&&c.__reactInternalMemoizedUnmaskedChildContext===n)return c.__reactInternalMemoizedMaskedChildContext;var d={},h;for(h in o)d[h]=n[h];return c&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=d),d}function dt(e){return e=e.childContextTypes,e!=null}function ar(){Ie(ut),Ie(Ze)}function xu(e,n,o){if(Ze.current!==pn)throw Error(r(168));Ee(Ze,n),Ee(ut,o)}function wu(e,n,o){var c=e.stateNode;if(n=n.childContextTypes,typeof c.getChildContext!="function")return o;c=c.getChildContext();for(var d in c)if(!(d in n))throw Error(r(108,he(e)||"Unknown",d));return W({},o,c)}function lr(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||pn,On=Ze.current,Ee(Ze,e),Ee(ut,ut.current),!0}function ju(e,n,o){var c=e.stateNode;if(!c)throw Error(r(169));o?(e=wu(e,n,On),c.__reactInternalMemoizedMergedChildContext=e,Ie(ut),Ie(Ze),Ee(Ze,e)):Ie(ut),Ee(ut,o)}var Gt=null,cr=!1,da=!1;function Su(e){Gt===null?Gt=[e]:Gt.push(e)}function Sp(e){cr=!0,Su(e)}function gn(){if(!da&&Gt!==null){da=!0;var e=0,n=Ne;try{var o=Gt;for(Ne=1;e<o.length;e++){var c=o[e];do c=c(!0);while(c!==null)}Gt=null,cr=!1}catch(d){throw Gt!==null&&(Gt=Gt.slice(e+1)),Cc(Lo,gn),d}finally{Ne=n,da=!1}}return null}var ds=[],fs=0,ur=null,dr=0,jt=[],St=0,_n=null,Yt=1,Jt="";function Pn(e,n){ds[fs++]=dr,ds[fs++]=ur,ur=e,dr=n}function Nu(e,n,o){jt[St++]=Yt,jt[St++]=Jt,jt[St++]=_n,_n=e;var c=Yt;e=Jt;var d=32-Mt(c)-1;c&=~(1<<d),o+=1;var h=32-Mt(n)+d;if(30<h){var y=d-d%5;h=(c&(1<<y)-1).toString(32),c>>=y,d-=y,Yt=1<<32-Mt(n)+d|o<<d|c,Jt=h+e}else Yt=1<<h|o<<d|c,Jt=e}function fa(e){e.return!==null&&(Pn(e,1),Nu(e,1,0))}function ha(e){for(;e===ur;)ur=ds[--fs],ds[fs]=null,dr=ds[--fs],ds[fs]=null;for(;e===_n;)_n=jt[--St],jt[St]=null,Jt=jt[--St],jt[St]=null,Yt=jt[--St],jt[St]=null}var yt=null,kt=null,Ae=!1,At=null;function Cu(e,n){var o=bt(5,null,null,0);o.elementType="DELETED",o.stateNode=n,o.return=e,n=e.deletions,n===null?(e.deletions=[o],e.flags|=16):n.push(o)}function $u(e,n){switch(e.tag){case 5:var o=e.type;return n=n.nodeType!==1||o.toLowerCase()!==n.nodeName.toLowerCase()?null:n,n!==null?(e.stateNode=n,yt=e,kt=hn(n.firstChild),!0):!1;case 6:return n=e.pendingProps===""||n.nodeType!==3?null:n,n!==null?(e.stateNode=n,yt=e,kt=null,!0):!1;case 13:return n=n.nodeType!==8?null:n,n!==null?(o=_n!==null?{id:Yt,overflow:Jt}:null,e.memoizedState={dehydrated:n,treeContext:o,retryLane:1073741824},o=bt(18,null,null,0),o.stateNode=n,o.return=e,e.child=o,yt=e,kt=null,!0):!1;default:return!1}}function ma(e){return(e.mode&1)!==0&&(e.flags&128)===0}function pa(e){if(Ae){var n=kt;if(n){var o=n;if(!$u(e,n)){if(ma(e))throw Error(r(418));n=hn(o.nextSibling);var c=yt;n&&$u(e,n)?Cu(c,o):(e.flags=e.flags&-4097|2,Ae=!1,yt=e)}}else{if(ma(e))throw Error(r(418));e.flags=e.flags&-4097|2,Ae=!1,yt=e}}}function bu(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;yt=e}function fr(e){if(e!==yt)return!1;if(!Ae)return bu(e),Ae=!0,!1;var n;if((n=e.tag!==3)&&!(n=e.tag!==5)&&(n=e.type,n=n!=="head"&&n!=="body"&&!oa(e.type,e.memoizedProps)),n&&(n=kt)){if(ma(e))throw Tu(),Error(r(418));for(;n;)Cu(e,n),n=hn(n.nextSibling)}if(bu(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(r(317));e:{for(e=e.nextSibling,n=0;e;){if(e.nodeType===8){var o=e.data;if(o==="/$"){if(n===0){kt=hn(e.nextSibling);break e}n--}else o!=="$"&&o!=="$!"&&o!=="$?"||n++}e=e.nextSibling}kt=null}}else kt=yt?hn(e.stateNode.nextSibling):null;return!0}function Tu(){for(var e=kt;e;)e=hn(e.nextSibling)}function hs(){kt=yt=null,Ae=!1}function ga(e){At===null?At=[e]:At.push(e)}var Np=ee.ReactCurrentBatchConfig;function oi(e,n,o){if(e=o.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(o._owner){if(o=o._owner,o){if(o.tag!==1)throw Error(r(309));var c=o.stateNode}if(!c)throw Error(r(147,e));var d=c,h=""+e;return n!==null&&n.ref!==null&&typeof n.ref=="function"&&n.ref._stringRef===h?n.ref:(n=function(y){var j=d.refs;y===null?delete j[h]:j[h]=y},n._stringRef=h,n)}if(typeof e!="string")throw Error(r(284));if(!o._owner)throw Error(r(290,e))}return e}function hr(e,n){throw e=Object.prototype.toString.call(n),Error(r(31,e==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":e))}function Eu(e){var n=e._init;return n(e._payload)}function Mu(e){function n(T,$){if(e){var A=T.deletions;A===null?(T.deletions=[$],T.flags|=16):A.push($)}}function o(T,$){if(!e)return null;for(;$!==null;)n(T,$),$=$.sibling;return null}function c(T,$){for(T=new Map;$!==null;)$.key!==null?T.set($.key,$):T.set($.index,$),$=$.sibling;return T}function d(T,$){return T=Nn(T,$),T.index=0,T.sibling=null,T}function h(T,$,A){return T.index=A,e?(A=T.alternate,A!==null?(A=A.index,A<$?(T.flags|=2,$):A):(T.flags|=2,$)):(T.flags|=1048576,$)}function y(T){return e&&T.alternate===null&&(T.flags|=2),T}function j(T,$,A,H){return $===null||$.tag!==6?($=al(A,T.mode,H),$.return=T,$):($=d($,A),$.return=T,$)}function C(T,$,A,H){var te=A.type;return te===ie?z(T,$,A.props.children,H,A.key):$!==null&&($.elementType===te||typeof te=="object"&&te!==null&&te.$$typeof===ue&&Eu(te)===$.type)?(H=d($,A.props),H.ref=oi(T,$,A),H.return=T,H):(H=Pr(A.type,A.key,A.props,null,T.mode,H),H.ref=oi(T,$,A),H.return=T,H)}function R(T,$,A,H){return $===null||$.tag!==4||$.stateNode.containerInfo!==A.containerInfo||$.stateNode.implementation!==A.implementation?($=ll(A,T.mode,H),$.return=T,$):($=d($,A.children||[]),$.return=T,$)}function z(T,$,A,H,te){return $===null||$.tag!==7?($=Vn(A,T.mode,H,te),$.return=T,$):($=d($,A),$.return=T,$)}function U(T,$,A){if(typeof $=="string"&&$!==""||typeof $=="number")return $=al(""+$,T.mode,A),$.return=T,$;if(typeof $=="object"&&$!==null){switch($.$$typeof){case q:return A=Pr($.type,$.key,$.props,null,T.mode,A),A.ref=oi(T,null,$),A.return=T,A;case V:return $=ll($,T.mode,A),$.return=T,$;case ue:var H=$._init;return U(T,H($._payload),A)}if(Os($)||F($))return $=Vn($,T.mode,A,null),$.return=T,$;hr(T,$)}return null}function D(T,$,A,H){var te=$!==null?$.key:null;if(typeof A=="string"&&A!==""||typeof A=="number")return te!==null?null:j(T,$,""+A,H);if(typeof A=="object"&&A!==null){switch(A.$$typeof){case q:return A.key===te?C(T,$,A,H):null;case V:return A.key===te?R(T,$,A,H):null;case ue:return te=A._init,D(T,$,te(A._payload),H)}if(Os(A)||F(A))return te!==null?null:z(T,$,A,H,null);hr(T,A)}return null}function Y(T,$,A,H,te){if(typeof H=="string"&&H!==""||typeof H=="number")return T=T.get(A)||null,j($,T,""+H,te);if(typeof H=="object"&&H!==null){switch(H.$$typeof){case q:return T=T.get(H.key===null?A:H.key)||null,C($,T,H,te);case V:return T=T.get(H.key===null?A:H.key)||null,R($,T,H,te);case ue:var re=H._init;return Y(T,$,A,re(H._payload),te)}if(Os(H)||F(H))return T=T.get(A)||null,z($,T,H,te,null);hr($,H)}return null}function X(T,$,A,H){for(var te=null,re=null,oe=$,de=$=0,qe=null;oe!==null&&de<A.length;de++){oe.index>de?(qe=oe,oe=null):qe=oe.sibling;var Se=D(T,oe,A[de],H);if(Se===null){oe===null&&(oe=qe);break}e&&oe&&Se.alternate===null&&n(T,oe),$=h(Se,$,de),re===null?te=Se:re.sibling=Se,re=Se,oe=qe}if(de===A.length)return o(T,oe),Ae&&Pn(T,de),te;if(oe===null){for(;de<A.length;de++)oe=U(T,A[de],H),oe!==null&&($=h(oe,$,de),re===null?te=oe:re.sibling=oe,re=oe);return Ae&&Pn(T,de),te}for(oe=c(T,oe);de<A.length;de++)qe=Y(oe,T,de,A[de],H),qe!==null&&(e&&qe.alternate!==null&&oe.delete(qe.key===null?de:qe.key),$=h(qe,$,de),re===null?te=qe:re.sibling=qe,re=qe);return e&&oe.forEach(function(Cn){return n(T,Cn)}),Ae&&Pn(T,de),te}function Z(T,$,A,H){var te=F(A);if(typeof te!="function")throw Error(r(150));if(A=te.call(A),A==null)throw Error(r(151));for(var re=te=null,oe=$,de=$=0,qe=null,Se=A.next();oe!==null&&!Se.done;de++,Se=A.next()){oe.index>de?(qe=oe,oe=null):qe=oe.sibling;var Cn=D(T,oe,Se.value,H);if(Cn===null){oe===null&&(oe=qe);break}e&&oe&&Cn.alternate===null&&n(T,oe),$=h(Cn,$,de),re===null?te=Cn:re.sibling=Cn,re=Cn,oe=qe}if(Se.done)return o(T,oe),Ae&&Pn(T,de),te;if(oe===null){for(;!Se.done;de++,Se=A.next())Se=U(T,Se.value,H),Se!==null&&($=h(Se,$,de),re===null?te=Se:re.sibling=Se,re=Se);return Ae&&Pn(T,de),te}for(oe=c(T,oe);!Se.done;de++,Se=A.next())Se=Y(oe,T,de,Se.value,H),Se!==null&&(e&&Se.alternate!==null&&oe.delete(Se.key===null?de:Se.key),$=h(Se,$,de),re===null?te=Se:re.sibling=Se,re=Se);return e&&oe.forEach(function(sg){return n(T,sg)}),Ae&&Pn(T,de),te}function De(T,$,A,H){if(typeof A=="object"&&A!==null&&A.type===ie&&A.key===null&&(A=A.props.children),typeof A=="object"&&A!==null){switch(A.$$typeof){case q:e:{for(var te=A.key,re=$;re!==null;){if(re.key===te){if(te=A.type,te===ie){if(re.tag===7){o(T,re.sibling),$=d(re,A.props.children),$.return=T,T=$;break e}}else if(re.elementType===te||typeof te=="object"&&te!==null&&te.$$typeof===ue&&Eu(te)===re.type){o(T,re.sibling),$=d(re,A.props),$.ref=oi(T,re,A),$.return=T,T=$;break e}o(T,re);break}else n(T,re);re=re.sibling}A.type===ie?($=Vn(A.props.children,T.mode,H,A.key),$.return=T,T=$):(H=Pr(A.type,A.key,A.props,null,T.mode,H),H.ref=oi(T,$,A),H.return=T,T=H)}return y(T);case V:e:{for(re=A.key;$!==null;){if($.key===re)if($.tag===4&&$.stateNode.containerInfo===A.containerInfo&&$.stateNode.implementation===A.implementation){o(T,$.sibling),$=d($,A.children||[]),$.return=T,T=$;break e}else{o(T,$);break}else n(T,$);$=$.sibling}$=ll(A,T.mode,H),$.return=T,T=$}return y(T);case ue:return re=A._init,De(T,$,re(A._payload),H)}if(Os(A))return X(T,$,A,H);if(F(A))return Z(T,$,A,H);hr(T,A)}return typeof A=="string"&&A!==""||typeof A=="number"?(A=""+A,$!==null&&$.tag===6?(o(T,$.sibling),$=d($,A),$.return=T,T=$):(o(T,$),$=al(A,T.mode,H),$.return=T,T=$),y(T)):o(T,$)}return De}var ms=Mu(!0),Iu=Mu(!1),mr=mn(null),pr=null,ps=null,va=null;function ya(){va=ps=pr=null}function ka(e){var n=mr.current;Ie(mr),e._currentValue=n}function xa(e,n,o){for(;e!==null;){var c=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,c!==null&&(c.childLanes|=n)):c!==null&&(c.childLanes&n)!==n&&(c.childLanes|=n),e===o)break;e=e.return}}function gs(e,n){pr=e,va=ps=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(ft=!0),e.firstContext=null)}function Nt(e){var n=e._currentValue;if(va!==e)if(e={context:e,memoizedValue:n,next:null},ps===null){if(pr===null)throw Error(r(308));ps=e,pr.dependencies={lanes:0,firstContext:e}}else ps=ps.next=e;return n}var Dn=null;function wa(e){Dn===null?Dn=[e]:Dn.push(e)}function Au(e,n,o,c){var d=n.interleaved;return d===null?(o.next=o,wa(n)):(o.next=d.next,d.next=o),n.interleaved=o,Xt(e,c)}function Xt(e,n){e.lanes|=n;var o=e.alternate;for(o!==null&&(o.lanes|=n),o=e,e=e.return;e!==null;)e.childLanes|=n,o=e.alternate,o!==null&&(o.childLanes|=n),o=e,e=e.return;return o.tag===3?o.stateNode:null}var vn=!1;function ja(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Lu(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Zt(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function yn(e,n,o){var c=e.updateQueue;if(c===null)return null;if(c=c.shared,(je&2)!==0){var d=c.pending;return d===null?n.next=n:(n.next=d.next,d.next=n),c.pending=n,Xt(e,o)}return d=c.interleaved,d===null?(n.next=n,wa(c)):(n.next=d.next,d.next=n),c.interleaved=n,Xt(e,o)}function gr(e,n,o){if(n=n.updateQueue,n!==null&&(n=n.shared,(o&4194240)!==0)){var c=n.lanes;c&=e.pendingLanes,o|=c,n.lanes=o,_o(e,o)}}function Ru(e,n){var o=e.updateQueue,c=e.alternate;if(c!==null&&(c=c.updateQueue,o===c)){var d=null,h=null;if(o=o.firstBaseUpdate,o!==null){do{var y={eventTime:o.eventTime,lane:o.lane,tag:o.tag,payload:o.payload,callback:o.callback,next:null};h===null?d=h=y:h=h.next=y,o=o.next}while(o!==null);h===null?d=h=n:h=h.next=n}else d=h=n;o={baseState:c.baseState,firstBaseUpdate:d,lastBaseUpdate:h,shared:c.shared,effects:c.effects},e.updateQueue=o;return}e=o.lastBaseUpdate,e===null?o.firstBaseUpdate=n:e.next=n,o.lastBaseUpdate=n}function vr(e,n,o,c){var d=e.updateQueue;vn=!1;var h=d.firstBaseUpdate,y=d.lastBaseUpdate,j=d.shared.pending;if(j!==null){d.shared.pending=null;var C=j,R=C.next;C.next=null,y===null?h=R:y.next=R,y=C;var z=e.alternate;z!==null&&(z=z.updateQueue,j=z.lastBaseUpdate,j!==y&&(j===null?z.firstBaseUpdate=R:j.next=R,z.lastBaseUpdate=C))}if(h!==null){var U=d.baseState;y=0,z=R=C=null,j=h;do{var D=j.lane,Y=j.eventTime;if((c&D)===D){z!==null&&(z=z.next={eventTime:Y,lane:0,tag:j.tag,payload:j.payload,callback:j.callback,next:null});e:{var X=e,Z=j;switch(D=n,Y=o,Z.tag){case 1:if(X=Z.payload,typeof X=="function"){U=X.call(Y,U,D);break e}U=X;break e;case 3:X.flags=X.flags&-65537|128;case 0:if(X=Z.payload,D=typeof X=="function"?X.call(Y,U,D):X,D==null)break e;U=W({},U,D);break e;case 2:vn=!0}}j.callback!==null&&j.lane!==0&&(e.flags|=64,D=d.effects,D===null?d.effects=[j]:D.push(j))}else Y={eventTime:Y,lane:D,tag:j.tag,payload:j.payload,callback:j.callback,next:null},z===null?(R=z=Y,C=U):z=z.next=Y,y|=D;if(j=j.next,j===null){if(j=d.shared.pending,j===null)break;D=j,j=D.next,D.next=null,d.lastBaseUpdate=D,d.shared.pending=null}}while(!0);if(z===null&&(C=U),d.baseState=C,d.firstBaseUpdate=R,d.lastBaseUpdate=z,n=d.shared.interleaved,n!==null){d=n;do y|=d.lane,d=d.next;while(d!==n)}else h===null&&(d.shared.lanes=0);Fn|=y,e.lanes=y,e.memoizedState=U}}function Ou(e,n,o){if(e=n.effects,n.effects=null,e!==null)for(n=0;n<e.length;n++){var c=e[n],d=c.callback;if(d!==null){if(c.callback=null,c=o,typeof d!="function")throw Error(r(191,d));d.call(c)}}}var ai={},Bt=mn(ai),li=mn(ai),ci=mn(ai);function zn(e){if(e===ai)throw Error(r(174));return e}function Sa(e,n){switch(Ee(ci,n),Ee(li,e),Ee(Bt,ai),e=n.nodeType,e){case 9:case 11:n=(n=n.documentElement)?n.namespaceURI:No(null,"");break;default:e=e===8?n.parentNode:n,n=e.namespaceURI||null,e=e.tagName,n=No(n,e)}Ie(Bt),Ee(Bt,n)}function vs(){Ie(Bt),Ie(li),Ie(ci)}function _u(e){zn(ci.current);var n=zn(Bt.current),o=No(n,e.type);n!==o&&(Ee(li,e),Ee(Bt,o))}function Na(e){li.current===e&&(Ie(Bt),Ie(li))}var Le=mn(0);function yr(e){for(var n=e;n!==null;){if(n.tag===13){var o=n.memoizedState;if(o!==null&&(o=o.dehydrated,o===null||o.data==="$?"||o.data==="$!"))return n}else if(n.tag===19&&n.memoizedProps.revealOrder!==void 0){if((n.flags&128)!==0)return n}else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var Ca=[];function $a(){for(var e=0;e<Ca.length;e++)Ca[e]._workInProgressVersionPrimary=null;Ca.length=0}var kr=ee.ReactCurrentDispatcher,ba=ee.ReactCurrentBatchConfig,Bn=0,Re=null,Fe=null,Ke=null,xr=!1,ui=!1,di=0,Cp=0;function et(){throw Error(r(321))}function Ta(e,n){if(n===null)return!1;for(var o=0;o<n.length&&o<e.length;o++)if(!It(e[o],n[o]))return!1;return!0}function Ea(e,n,o,c,d,h){if(Bn=h,Re=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,kr.current=e===null||e.memoizedState===null?Ep:Mp,e=o(c,d),ui){h=0;do{if(ui=!1,di=0,25<=h)throw Error(r(301));h+=1,Ke=Fe=null,n.updateQueue=null,kr.current=Ip,e=o(c,d)}while(ui)}if(kr.current=Sr,n=Fe!==null&&Fe.next!==null,Bn=0,Ke=Fe=Re=null,xr=!1,n)throw Error(r(300));return e}function Ma(){var e=di!==0;return di=0,e}function Ft(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ke===null?Re.memoizedState=Ke=e:Ke=Ke.next=e,Ke}function Ct(){if(Fe===null){var e=Re.alternate;e=e!==null?e.memoizedState:null}else e=Fe.next;var n=Ke===null?Re.memoizedState:Ke.next;if(n!==null)Ke=n,Fe=e;else{if(e===null)throw Error(r(310));Fe=e,e={memoizedState:Fe.memoizedState,baseState:Fe.baseState,baseQueue:Fe.baseQueue,queue:Fe.queue,next:null},Ke===null?Re.memoizedState=Ke=e:Ke=Ke.next=e}return Ke}function fi(e,n){return typeof n=="function"?n(e):n}function Ia(e){var n=Ct(),o=n.queue;if(o===null)throw Error(r(311));o.lastRenderedReducer=e;var c=Fe,d=c.baseQueue,h=o.pending;if(h!==null){if(d!==null){var y=d.next;d.next=h.next,h.next=y}c.baseQueue=d=h,o.pending=null}if(d!==null){h=d.next,c=c.baseState;var j=y=null,C=null,R=h;do{var z=R.lane;if((Bn&z)===z)C!==null&&(C=C.next={lane:0,action:R.action,hasEagerState:R.hasEagerState,eagerState:R.eagerState,next:null}),c=R.hasEagerState?R.eagerState:e(c,R.action);else{var U={lane:z,action:R.action,hasEagerState:R.hasEagerState,eagerState:R.eagerState,next:null};C===null?(j=C=U,y=c):C=C.next=U,Re.lanes|=z,Fn|=z}R=R.next}while(R!==null&&R!==h);C===null?y=c:C.next=j,It(c,n.memoizedState)||(ft=!0),n.memoizedState=c,n.baseState=y,n.baseQueue=C,o.lastRenderedState=c}if(e=o.interleaved,e!==null){d=e;do h=d.lane,Re.lanes|=h,Fn|=h,d=d.next;while(d!==e)}else d===null&&(o.lanes=0);return[n.memoizedState,o.dispatch]}function Aa(e){var n=Ct(),o=n.queue;if(o===null)throw Error(r(311));o.lastRenderedReducer=e;var c=o.dispatch,d=o.pending,h=n.memoizedState;if(d!==null){o.pending=null;var y=d=d.next;do h=e(h,y.action),y=y.next;while(y!==d);It(h,n.memoizedState)||(ft=!0),n.memoizedState=h,n.baseQueue===null&&(n.baseState=h),o.lastRenderedState=h}return[h,c]}function Pu(){}function Du(e,n){var o=Re,c=Ct(),d=n(),h=!It(c.memoizedState,d);if(h&&(c.memoizedState=d,ft=!0),c=c.queue,La(Fu.bind(null,o,c,e),[e]),c.getSnapshot!==n||h||Ke!==null&&Ke.memoizedState.tag&1){if(o.flags|=2048,hi(9,Bu.bind(null,o,c,d,n),void 0,null),Qe===null)throw Error(r(349));(Bn&30)!==0||zu(o,n,d)}return d}function zu(e,n,o){e.flags|=16384,e={getSnapshot:n,value:o},n=Re.updateQueue,n===null?(n={lastEffect:null,stores:null},Re.updateQueue=n,n.stores=[e]):(o=n.stores,o===null?n.stores=[e]:o.push(e))}function Bu(e,n,o,c){n.value=o,n.getSnapshot=c,Uu(n)&&Wu(e)}function Fu(e,n,o){return o(function(){Uu(n)&&Wu(e)})}function Uu(e){var n=e.getSnapshot;e=e.value;try{var o=n();return!It(e,o)}catch{return!0}}function Wu(e){var n=Xt(e,1);n!==null&&_t(n,e,1,-1)}function Hu(e){var n=Ft();return typeof e=="function"&&(e=e()),n.memoizedState=n.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:fi,lastRenderedState:e},n.queue=e,e=e.dispatch=Tp.bind(null,Re,e),[n.memoizedState,e]}function hi(e,n,o,c){return e={tag:e,create:n,destroy:o,deps:c,next:null},n=Re.updateQueue,n===null?(n={lastEffect:null,stores:null},Re.updateQueue=n,n.lastEffect=e.next=e):(o=n.lastEffect,o===null?n.lastEffect=e.next=e:(c=o.next,o.next=e,e.next=c,n.lastEffect=e)),e}function Vu(){return Ct().memoizedState}function wr(e,n,o,c){var d=Ft();Re.flags|=e,d.memoizedState=hi(1|n,o,void 0,c===void 0?null:c)}function jr(e,n,o,c){var d=Ct();c=c===void 0?null:c;var h=void 0;if(Fe!==null){var y=Fe.memoizedState;if(h=y.destroy,c!==null&&Ta(c,y.deps)){d.memoizedState=hi(n,o,h,c);return}}Re.flags|=e,d.memoizedState=hi(1|n,o,h,c)}function Ku(e,n){return wr(8390656,8,e,n)}function La(e,n){return jr(2048,8,e,n)}function Qu(e,n){return jr(4,2,e,n)}function qu(e,n){return jr(4,4,e,n)}function Gu(e,n){if(typeof n=="function")return e=e(),n(e),function(){n(null)};if(n!=null)return e=e(),n.current=e,function(){n.current=null}}function Yu(e,n,o){return o=o!=null?o.concat([e]):null,jr(4,4,Gu.bind(null,n,e),o)}function Ra(){}function Ju(e,n){var o=Ct();n=n===void 0?null:n;var c=o.memoizedState;return c!==null&&n!==null&&Ta(n,c[1])?c[0]:(o.memoizedState=[e,n],e)}function Xu(e,n){var o=Ct();n=n===void 0?null:n;var c=o.memoizedState;return c!==null&&n!==null&&Ta(n,c[1])?c[0]:(e=e(),o.memoizedState=[e,n],e)}function Zu(e,n,o){return(Bn&21)===0?(e.baseState&&(e.baseState=!1,ft=!0),e.memoizedState=o):(It(o,n)||(o=Ec(),Re.lanes|=o,Fn|=o,e.baseState=!0),n)}function $p(e,n){var o=Ne;Ne=o!==0&&4>o?o:4,e(!0);var c=ba.transition;ba.transition={};try{e(!1),n()}finally{Ne=o,ba.transition=c}}function ed(){return Ct().memoizedState}function bp(e,n,o){var c=jn(e);if(o={lane:c,action:o,hasEagerState:!1,eagerState:null,next:null},td(e))nd(n,o);else if(o=Au(e,n,o,c),o!==null){var d=at();_t(o,e,c,d),sd(o,n,c)}}function Tp(e,n,o){var c=jn(e),d={lane:c,action:o,hasEagerState:!1,eagerState:null,next:null};if(td(e))nd(n,d);else{var h=e.alternate;if(e.lanes===0&&(h===null||h.lanes===0)&&(h=n.lastRenderedReducer,h!==null))try{var y=n.lastRenderedState,j=h(y,o);if(d.hasEagerState=!0,d.eagerState=j,It(j,y)){var C=n.interleaved;C===null?(d.next=d,wa(n)):(d.next=C.next,C.next=d),n.interleaved=d;return}}catch{}finally{}o=Au(e,n,d,c),o!==null&&(d=at(),_t(o,e,c,d),sd(o,n,c))}}function td(e){var n=e.alternate;return e===Re||n!==null&&n===Re}function nd(e,n){ui=xr=!0;var o=e.pending;o===null?n.next=n:(n.next=o.next,o.next=n),e.pending=n}function sd(e,n,o){if((o&4194240)!==0){var c=n.lanes;c&=e.pendingLanes,o|=c,n.lanes=o,_o(e,o)}}var Sr={readContext:Nt,useCallback:et,useContext:et,useEffect:et,useImperativeHandle:et,useInsertionEffect:et,useLayoutEffect:et,useMemo:et,useReducer:et,useRef:et,useState:et,useDebugValue:et,useDeferredValue:et,useTransition:et,useMutableSource:et,useSyncExternalStore:et,useId:et,unstable_isNewReconciler:!1},Ep={readContext:Nt,useCallback:function(e,n){return Ft().memoizedState=[e,n===void 0?null:n],e},useContext:Nt,useEffect:Ku,useImperativeHandle:function(e,n,o){return o=o!=null?o.concat([e]):null,wr(4194308,4,Gu.bind(null,n,e),o)},useLayoutEffect:function(e,n){return wr(4194308,4,e,n)},useInsertionEffect:function(e,n){return wr(4,2,e,n)},useMemo:function(e,n){var o=Ft();return n=n===void 0?null:n,e=e(),o.memoizedState=[e,n],e},useReducer:function(e,n,o){var c=Ft();return n=o!==void 0?o(n):n,c.memoizedState=c.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},c.queue=e,e=e.dispatch=bp.bind(null,Re,e),[c.memoizedState,e]},useRef:function(e){var n=Ft();return e={current:e},n.memoizedState=e},useState:Hu,useDebugValue:Ra,useDeferredValue:function(e){return Ft().memoizedState=e},useTransition:function(){var e=Hu(!1),n=e[0];return e=$p.bind(null,e[1]),Ft().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,o){var c=Re,d=Ft();if(Ae){if(o===void 0)throw Error(r(407));o=o()}else{if(o=n(),Qe===null)throw Error(r(349));(Bn&30)!==0||zu(c,n,o)}d.memoizedState=o;var h={value:o,getSnapshot:n};return d.queue=h,Ku(Fu.bind(null,c,h,e),[e]),c.flags|=2048,hi(9,Bu.bind(null,c,h,o,n),void 0,null),o},useId:function(){var e=Ft(),n=Qe.identifierPrefix;if(Ae){var o=Jt,c=Yt;o=(c&~(1<<32-Mt(c)-1)).toString(32)+o,n=":"+n+"R"+o,o=di++,0<o&&(n+="H"+o.toString(32)),n+=":"}else o=Cp++,n=":"+n+"r"+o.toString(32)+":";return e.memoizedState=n},unstable_isNewReconciler:!1},Mp={readContext:Nt,useCallback:Ju,useContext:Nt,useEffect:La,useImperativeHandle:Yu,useInsertionEffect:Qu,useLayoutEffect:qu,useMemo:Xu,useReducer:Ia,useRef:Vu,useState:function(){return Ia(fi)},useDebugValue:Ra,useDeferredValue:function(e){var n=Ct();return Zu(n,Fe.memoizedState,e)},useTransition:function(){var e=Ia(fi)[0],n=Ct().memoizedState;return[e,n]},useMutableSource:Pu,useSyncExternalStore:Du,useId:ed,unstable_isNewReconciler:!1},Ip={readContext:Nt,useCallback:Ju,useContext:Nt,useEffect:La,useImperativeHandle:Yu,useInsertionEffect:Qu,useLayoutEffect:qu,useMemo:Xu,useReducer:Aa,useRef:Vu,useState:function(){return Aa(fi)},useDebugValue:Ra,useDeferredValue:function(e){var n=Ct();return Fe===null?n.memoizedState=e:Zu(n,Fe.memoizedState,e)},useTransition:function(){var e=Aa(fi)[0],n=Ct().memoizedState;return[e,n]},useMutableSource:Pu,useSyncExternalStore:Du,useId:ed,unstable_isNewReconciler:!1};function Lt(e,n){if(e&&e.defaultProps){n=W({},n),e=e.defaultProps;for(var o in e)n[o]===void 0&&(n[o]=e[o]);return n}return n}function Oa(e,n,o,c){n=e.memoizedState,o=o(c,n),o=o==null?n:W({},n,o),e.memoizedState=o,e.lanes===0&&(e.updateQueue.baseState=o)}var Nr={isMounted:function(e){return(e=e._reactInternals)?Ln(e)===e:!1},enqueueSetState:function(e,n,o){e=e._reactInternals;var c=at(),d=jn(e),h=Zt(c,d);h.payload=n,o!=null&&(h.callback=o),n=yn(e,h,d),n!==null&&(_t(n,e,d,c),gr(n,e,d))},enqueueReplaceState:function(e,n,o){e=e._reactInternals;var c=at(),d=jn(e),h=Zt(c,d);h.tag=1,h.payload=n,o!=null&&(h.callback=o),n=yn(e,h,d),n!==null&&(_t(n,e,d,c),gr(n,e,d))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var o=at(),c=jn(e),d=Zt(o,c);d.tag=2,n!=null&&(d.callback=n),n=yn(e,d,c),n!==null&&(_t(n,e,c,o),gr(n,e,c))}};function id(e,n,o,c,d,h,y){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(c,h,y):n.prototype&&n.prototype.isPureReactComponent?!Zs(o,c)||!Zs(d,h):!0}function rd(e,n,o){var c=!1,d=pn,h=n.contextType;return typeof h=="object"&&h!==null?h=Nt(h):(d=dt(n)?On:Ze.current,c=n.contextTypes,h=(c=c!=null)?us(e,d):pn),n=new n(o,h),e.memoizedState=n.state!==null&&n.state!==void 0?n.state:null,n.updater=Nr,e.stateNode=n,n._reactInternals=e,c&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=d,e.__reactInternalMemoizedMaskedChildContext=h),n}function od(e,n,o,c){e=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(o,c),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(o,c),n.state!==e&&Nr.enqueueReplaceState(n,n.state,null)}function _a(e,n,o,c){var d=e.stateNode;d.props=o,d.state=e.memoizedState,d.refs={},ja(e);var h=n.contextType;typeof h=="object"&&h!==null?d.context=Nt(h):(h=dt(n)?On:Ze.current,d.context=us(e,h)),d.state=e.memoizedState,h=n.getDerivedStateFromProps,typeof h=="function"&&(Oa(e,n,h,o),d.state=e.memoizedState),typeof n.getDerivedStateFromProps=="function"||typeof d.getSnapshotBeforeUpdate=="function"||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(n=d.state,typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount(),n!==d.state&&Nr.enqueueReplaceState(d,d.state,null),vr(e,o,d,c),d.state=e.memoizedState),typeof d.componentDidMount=="function"&&(e.flags|=4194308)}function ys(e,n){try{var o="",c=n;do o+=ce(c),c=c.return;while(c);var d=o}catch(h){d=`
39
+ Error generating stack: `+h.message+`
40
+ `+h.stack}return{value:e,source:n,stack:d,digest:null}}function Pa(e,n,o){return{value:e,source:null,stack:o??null,digest:n??null}}function Da(e,n){try{console.error(n.value)}catch(o){setTimeout(function(){throw o})}}var Ap=typeof WeakMap=="function"?WeakMap:Map;function ad(e,n,o){o=Zt(-1,o),o.tag=3,o.payload={element:null};var c=n.value;return o.callback=function(){Ir||(Ir=!0,Za=c),Da(e,n)},o}function ld(e,n,o){o=Zt(-1,o),o.tag=3;var c=e.type.getDerivedStateFromError;if(typeof c=="function"){var d=n.value;o.payload=function(){return c(d)},o.callback=function(){Da(e,n)}}var h=e.stateNode;return h!==null&&typeof h.componentDidCatch=="function"&&(o.callback=function(){Da(e,n),typeof c!="function"&&(xn===null?xn=new Set([this]):xn.add(this));var y=n.stack;this.componentDidCatch(n.value,{componentStack:y!==null?y:""})}),o}function cd(e,n,o){var c=e.pingCache;if(c===null){c=e.pingCache=new Ap;var d=new Set;c.set(n,d)}else d=c.get(n),d===void 0&&(d=new Set,c.set(n,d));d.has(o)||(d.add(o),e=Kp.bind(null,e,n,o),n.then(e,e))}function ud(e){do{var n;if((n=e.tag===13)&&(n=e.memoizedState,n=n!==null?n.dehydrated!==null:!0),n)return e;e=e.return}while(e!==null);return null}function dd(e,n,o,c,d){return(e.mode&1)===0?(e===n?e.flags|=65536:(e.flags|=128,o.flags|=131072,o.flags&=-52805,o.tag===1&&(o.alternate===null?o.tag=17:(n=Zt(-1,1),n.tag=2,yn(o,n,1))),o.lanes|=1),e):(e.flags|=65536,e.lanes=d,e)}var Lp=ee.ReactCurrentOwner,ft=!1;function ot(e,n,o,c){n.child=e===null?Iu(n,null,o,c):ms(n,e.child,o,c)}function fd(e,n,o,c,d){o=o.render;var h=n.ref;return gs(n,d),c=Ea(e,n,o,c,h,d),o=Ma(),e!==null&&!ft?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~d,en(e,n,d)):(Ae&&o&&fa(n),n.flags|=1,ot(e,n,c,d),n.child)}function hd(e,n,o,c,d){if(e===null){var h=o.type;return typeof h=="function"&&!ol(h)&&h.defaultProps===void 0&&o.compare===null&&o.defaultProps===void 0?(n.tag=15,n.type=h,md(e,n,h,c,d)):(e=Pr(o.type,null,c,n,n.mode,d),e.ref=n.ref,e.return=n,n.child=e)}if(h=e.child,(e.lanes&d)===0){var y=h.memoizedProps;if(o=o.compare,o=o!==null?o:Zs,o(y,c)&&e.ref===n.ref)return en(e,n,d)}return n.flags|=1,e=Nn(h,c),e.ref=n.ref,e.return=n,n.child=e}function md(e,n,o,c,d){if(e!==null){var h=e.memoizedProps;if(Zs(h,c)&&e.ref===n.ref)if(ft=!1,n.pendingProps=c=h,(e.lanes&d)!==0)(e.flags&131072)!==0&&(ft=!0);else return n.lanes=e.lanes,en(e,n,d)}return za(e,n,o,c,d)}function pd(e,n,o){var c=n.pendingProps,d=c.children,h=e!==null?e.memoizedState:null;if(c.mode==="hidden")if((n.mode&1)===0)n.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ee(xs,xt),xt|=o;else{if((o&1073741824)===0)return e=h!==null?h.baseLanes|o:o,n.lanes=n.childLanes=1073741824,n.memoizedState={baseLanes:e,cachePool:null,transitions:null},n.updateQueue=null,Ee(xs,xt),xt|=e,null;n.memoizedState={baseLanes:0,cachePool:null,transitions:null},c=h!==null?h.baseLanes:o,Ee(xs,xt),xt|=c}else h!==null?(c=h.baseLanes|o,n.memoizedState=null):c=o,Ee(xs,xt),xt|=c;return ot(e,n,d,o),n.child}function gd(e,n){var o=n.ref;(e===null&&o!==null||e!==null&&e.ref!==o)&&(n.flags|=512,n.flags|=2097152)}function za(e,n,o,c,d){var h=dt(o)?On:Ze.current;return h=us(n,h),gs(n,d),o=Ea(e,n,o,c,h,d),c=Ma(),e!==null&&!ft?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~d,en(e,n,d)):(Ae&&c&&fa(n),n.flags|=1,ot(e,n,o,d),n.child)}function vd(e,n,o,c,d){if(dt(o)){var h=!0;lr(n)}else h=!1;if(gs(n,d),n.stateNode===null)$r(e,n),rd(n,o,c),_a(n,o,c,d),c=!0;else if(e===null){var y=n.stateNode,j=n.memoizedProps;y.props=j;var C=y.context,R=o.contextType;typeof R=="object"&&R!==null?R=Nt(R):(R=dt(o)?On:Ze.current,R=us(n,R));var z=o.getDerivedStateFromProps,U=typeof z=="function"||typeof y.getSnapshotBeforeUpdate=="function";U||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(j!==c||C!==R)&&od(n,y,c,R),vn=!1;var D=n.memoizedState;y.state=D,vr(n,c,y,d),C=n.memoizedState,j!==c||D!==C||ut.current||vn?(typeof z=="function"&&(Oa(n,o,z,c),C=n.memoizedState),(j=vn||id(n,o,j,c,D,C,R))?(U||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"&&(n.flags|=4194308)):(typeof y.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=c,n.memoizedState=C),y.props=c,y.state=C,y.context=R,c=j):(typeof y.componentDidMount=="function"&&(n.flags|=4194308),c=!1)}else{y=n.stateNode,Lu(e,n),j=n.memoizedProps,R=n.type===n.elementType?j:Lt(n.type,j),y.props=R,U=n.pendingProps,D=y.context,C=o.contextType,typeof C=="object"&&C!==null?C=Nt(C):(C=dt(o)?On:Ze.current,C=us(n,C));var Y=o.getDerivedStateFromProps;(z=typeof Y=="function"||typeof y.getSnapshotBeforeUpdate=="function")||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(j!==U||D!==C)&&od(n,y,c,C),vn=!1,D=n.memoizedState,y.state=D,vr(n,c,y,d);var X=n.memoizedState;j!==U||D!==X||ut.current||vn?(typeof Y=="function"&&(Oa(n,o,Y,c),X=n.memoizedState),(R=vn||id(n,o,R,c,D,X,C)||!1)?(z||typeof y.UNSAFE_componentWillUpdate!="function"&&typeof y.componentWillUpdate!="function"||(typeof y.componentWillUpdate=="function"&&y.componentWillUpdate(c,X,C),typeof y.UNSAFE_componentWillUpdate=="function"&&y.UNSAFE_componentWillUpdate(c,X,C)),typeof y.componentDidUpdate=="function"&&(n.flags|=4),typeof y.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof y.componentDidUpdate!="function"||j===e.memoizedProps&&D===e.memoizedState||(n.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||j===e.memoizedProps&&D===e.memoizedState||(n.flags|=1024),n.memoizedProps=c,n.memoizedState=X),y.props=c,y.state=X,y.context=C,c=R):(typeof y.componentDidUpdate!="function"||j===e.memoizedProps&&D===e.memoizedState||(n.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||j===e.memoizedProps&&D===e.memoizedState||(n.flags|=1024),c=!1)}return Ba(e,n,o,c,h,d)}function Ba(e,n,o,c,d,h){gd(e,n);var y=(n.flags&128)!==0;if(!c&&!y)return d&&ju(n,o,!1),en(e,n,h);c=n.stateNode,Lp.current=n;var j=y&&typeof o.getDerivedStateFromError!="function"?null:c.render();return n.flags|=1,e!==null&&y?(n.child=ms(n,e.child,null,h),n.child=ms(n,null,j,h)):ot(e,n,j,h),n.memoizedState=c.state,d&&ju(n,o,!0),n.child}function yd(e){var n=e.stateNode;n.pendingContext?xu(e,n.pendingContext,n.pendingContext!==n.context):n.context&&xu(e,n.context,!1),Sa(e,n.containerInfo)}function kd(e,n,o,c,d){return hs(),ga(d),n.flags|=256,ot(e,n,o,c),n.child}var Fa={dehydrated:null,treeContext:null,retryLane:0};function Ua(e){return{baseLanes:e,cachePool:null,transitions:null}}function xd(e,n,o){var c=n.pendingProps,d=Le.current,h=!1,y=(n.flags&128)!==0,j;if((j=y)||(j=e!==null&&e.memoizedState===null?!1:(d&2)!==0),j?(h=!0,n.flags&=-129):(e===null||e.memoizedState!==null)&&(d|=1),Ee(Le,d&1),e===null)return pa(n),e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?((n.mode&1)===0?n.lanes=1:e.data==="$!"?n.lanes=8:n.lanes=1073741824,null):(y=c.children,e=c.fallback,h?(c=n.mode,h=n.child,y={mode:"hidden",children:y},(c&1)===0&&h!==null?(h.childLanes=0,h.pendingProps=y):h=Dr(y,c,0,null),e=Vn(e,c,o,null),h.return=n,e.return=n,h.sibling=e,n.child=h,n.child.memoizedState=Ua(o),n.memoizedState=Fa,e):Wa(n,y));if(d=e.memoizedState,d!==null&&(j=d.dehydrated,j!==null))return Rp(e,n,y,c,j,d,o);if(h){h=c.fallback,y=n.mode,d=e.child,j=d.sibling;var C={mode:"hidden",children:c.children};return(y&1)===0&&n.child!==d?(c=n.child,c.childLanes=0,c.pendingProps=C,n.deletions=null):(c=Nn(d,C),c.subtreeFlags=d.subtreeFlags&14680064),j!==null?h=Nn(j,h):(h=Vn(h,y,o,null),h.flags|=2),h.return=n,c.return=n,c.sibling=h,n.child=c,c=h,h=n.child,y=e.child.memoizedState,y=y===null?Ua(o):{baseLanes:y.baseLanes|o,cachePool:null,transitions:y.transitions},h.memoizedState=y,h.childLanes=e.childLanes&~o,n.memoizedState=Fa,c}return h=e.child,e=h.sibling,c=Nn(h,{mode:"visible",children:c.children}),(n.mode&1)===0&&(c.lanes=o),c.return=n,c.sibling=null,e!==null&&(o=n.deletions,o===null?(n.deletions=[e],n.flags|=16):o.push(e)),n.child=c,n.memoizedState=null,c}function Wa(e,n){return n=Dr({mode:"visible",children:n},e.mode,0,null),n.return=e,e.child=n}function Cr(e,n,o,c){return c!==null&&ga(c),ms(n,e.child,null,o),e=Wa(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function Rp(e,n,o,c,d,h,y){if(o)return n.flags&256?(n.flags&=-257,c=Pa(Error(r(422))),Cr(e,n,y,c)):n.memoizedState!==null?(n.child=e.child,n.flags|=128,null):(h=c.fallback,d=n.mode,c=Dr({mode:"visible",children:c.children},d,0,null),h=Vn(h,d,y,null),h.flags|=2,c.return=n,h.return=n,c.sibling=h,n.child=c,(n.mode&1)!==0&&ms(n,e.child,null,y),n.child.memoizedState=Ua(y),n.memoizedState=Fa,h);if((n.mode&1)===0)return Cr(e,n,y,null);if(d.data==="$!"){if(c=d.nextSibling&&d.nextSibling.dataset,c)var j=c.dgst;return c=j,h=Error(r(419)),c=Pa(h,c,void 0),Cr(e,n,y,c)}if(j=(y&e.childLanes)!==0,ft||j){if(c=Qe,c!==null){switch(y&-y){case 4:d=2;break;case 16:d=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:d=32;break;case 536870912:d=268435456;break;default:d=0}d=(d&(c.suspendedLanes|y))!==0?0:d,d!==0&&d!==h.retryLane&&(h.retryLane=d,Xt(e,d),_t(c,e,d,-1))}return rl(),c=Pa(Error(r(421))),Cr(e,n,y,c)}return d.data==="$?"?(n.flags|=128,n.child=e.child,n=Qp.bind(null,e),d._reactRetry=n,null):(e=h.treeContext,kt=hn(d.nextSibling),yt=n,Ae=!0,At=null,e!==null&&(jt[St++]=Yt,jt[St++]=Jt,jt[St++]=_n,Yt=e.id,Jt=e.overflow,_n=n),n=Wa(n,c.children),n.flags|=4096,n)}function wd(e,n,o){e.lanes|=n;var c=e.alternate;c!==null&&(c.lanes|=n),xa(e.return,n,o)}function Ha(e,n,o,c,d){var h=e.memoizedState;h===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:c,tail:o,tailMode:d}:(h.isBackwards=n,h.rendering=null,h.renderingStartTime=0,h.last=c,h.tail=o,h.tailMode=d)}function jd(e,n,o){var c=n.pendingProps,d=c.revealOrder,h=c.tail;if(ot(e,n,c.children,o),c=Le.current,(c&2)!==0)c=c&1|2,n.flags|=128;else{if(e!==null&&(e.flags&128)!==0)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&wd(e,o,n);else if(e.tag===19)wd(e,o,n);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;e.sibling===null;){if(e.return===null||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}c&=1}if(Ee(Le,c),(n.mode&1)===0)n.memoizedState=null;else switch(d){case"forwards":for(o=n.child,d=null;o!==null;)e=o.alternate,e!==null&&yr(e)===null&&(d=o),o=o.sibling;o=d,o===null?(d=n.child,n.child=null):(d=o.sibling,o.sibling=null),Ha(n,!1,d,o,h);break;case"backwards":for(o=null,d=n.child,n.child=null;d!==null;){if(e=d.alternate,e!==null&&yr(e)===null){n.child=d;break}e=d.sibling,d.sibling=o,o=d,d=e}Ha(n,!0,o,null,h);break;case"together":Ha(n,!1,null,null,void 0);break;default:n.memoizedState=null}return n.child}function $r(e,n){(n.mode&1)===0&&e!==null&&(e.alternate=null,n.alternate=null,n.flags|=2)}function en(e,n,o){if(e!==null&&(n.dependencies=e.dependencies),Fn|=n.lanes,(o&n.childLanes)===0)return null;if(e!==null&&n.child!==e.child)throw Error(r(153));if(n.child!==null){for(e=n.child,o=Nn(e,e.pendingProps),n.child=o,o.return=n;e.sibling!==null;)e=e.sibling,o=o.sibling=Nn(e,e.pendingProps),o.return=n;o.sibling=null}return n.child}function Op(e,n,o){switch(n.tag){case 3:yd(n),hs();break;case 5:_u(n);break;case 1:dt(n.type)&&lr(n);break;case 4:Sa(n,n.stateNode.containerInfo);break;case 10:var c=n.type._context,d=n.memoizedProps.value;Ee(mr,c._currentValue),c._currentValue=d;break;case 13:if(c=n.memoizedState,c!==null)return c.dehydrated!==null?(Ee(Le,Le.current&1),n.flags|=128,null):(o&n.child.childLanes)!==0?xd(e,n,o):(Ee(Le,Le.current&1),e=en(e,n,o),e!==null?e.sibling:null);Ee(Le,Le.current&1);break;case 19:if(c=(o&n.childLanes)!==0,(e.flags&128)!==0){if(c)return jd(e,n,o);n.flags|=128}if(d=n.memoizedState,d!==null&&(d.rendering=null,d.tail=null,d.lastEffect=null),Ee(Le,Le.current),c)break;return null;case 22:case 23:return n.lanes=0,pd(e,n,o)}return en(e,n,o)}var Sd,Va,Nd,Cd;Sd=function(e,n){for(var o=n.child;o!==null;){if(o.tag===5||o.tag===6)e.appendChild(o.stateNode);else if(o.tag!==4&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===n)break;for(;o.sibling===null;){if(o.return===null||o.return===n)return;o=o.return}o.sibling.return=o.return,o=o.sibling}},Va=function(){},Nd=function(e,n,o,c){var d=e.memoizedProps;if(d!==c){e=n.stateNode,zn(Bt.current);var h=null;switch(o){case"input":d=xo(e,d),c=xo(e,c),h=[];break;case"select":d=W({},d,{value:void 0}),c=W({},c,{value:void 0}),h=[];break;case"textarea":d=So(e,d),c=So(e,c),h=[];break;default:typeof d.onClick!="function"&&typeof c.onClick=="function"&&(e.onclick=rr)}Co(o,c);var y;o=null;for(R in d)if(!c.hasOwnProperty(R)&&d.hasOwnProperty(R)&&d[R]!=null)if(R==="style"){var j=d[R];for(y in j)j.hasOwnProperty(y)&&(o||(o={}),o[y]="")}else R!=="dangerouslySetInnerHTML"&&R!=="children"&&R!=="suppressContentEditableWarning"&&R!=="suppressHydrationWarning"&&R!=="autoFocus"&&(l.hasOwnProperty(R)?h||(h=[]):(h=h||[]).push(R,null));for(R in c){var C=c[R];if(j=d!=null?d[R]:void 0,c.hasOwnProperty(R)&&C!==j&&(C!=null||j!=null))if(R==="style")if(j){for(y in j)!j.hasOwnProperty(y)||C&&C.hasOwnProperty(y)||(o||(o={}),o[y]="");for(y in C)C.hasOwnProperty(y)&&j[y]!==C[y]&&(o||(o={}),o[y]=C[y])}else o||(h||(h=[]),h.push(R,o)),o=C;else R==="dangerouslySetInnerHTML"?(C=C?C.__html:void 0,j=j?j.__html:void 0,C!=null&&j!==C&&(h=h||[]).push(R,C)):R==="children"?typeof C!="string"&&typeof C!="number"||(h=h||[]).push(R,""+C):R!=="suppressContentEditableWarning"&&R!=="suppressHydrationWarning"&&(l.hasOwnProperty(R)?(C!=null&&R==="onScroll"&&Me("scroll",e),h||j===C||(h=[])):(h=h||[]).push(R,C))}o&&(h=h||[]).push("style",o);var R=h;(n.updateQueue=R)&&(n.flags|=4)}},Cd=function(e,n,o,c){o!==c&&(n.flags|=4)};function mi(e,n){if(!Ae)switch(e.tailMode){case"hidden":n=e.tail;for(var o=null;n!==null;)n.alternate!==null&&(o=n),n=n.sibling;o===null?e.tail=null:o.sibling=null;break;case"collapsed":o=e.tail;for(var c=null;o!==null;)o.alternate!==null&&(c=o),o=o.sibling;c===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:c.sibling=null}}function tt(e){var n=e.alternate!==null&&e.alternate.child===e.child,o=0,c=0;if(n)for(var d=e.child;d!==null;)o|=d.lanes|d.childLanes,c|=d.subtreeFlags&14680064,c|=d.flags&14680064,d.return=e,d=d.sibling;else for(d=e.child;d!==null;)o|=d.lanes|d.childLanes,c|=d.subtreeFlags,c|=d.flags,d.return=e,d=d.sibling;return e.subtreeFlags|=c,e.childLanes=o,n}function _p(e,n,o){var c=n.pendingProps;switch(ha(n),n.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return tt(n),null;case 1:return dt(n.type)&&ar(),tt(n),null;case 3:return c=n.stateNode,vs(),Ie(ut),Ie(Ze),$a(),c.pendingContext&&(c.context=c.pendingContext,c.pendingContext=null),(e===null||e.child===null)&&(fr(n)?n.flags|=4:e===null||e.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,At!==null&&(nl(At),At=null))),Va(e,n),tt(n),null;case 5:Na(n);var d=zn(ci.current);if(o=n.type,e!==null&&n.stateNode!=null)Nd(e,n,o,c,d),e.ref!==n.ref&&(n.flags|=512,n.flags|=2097152);else{if(!c){if(n.stateNode===null)throw Error(r(166));return tt(n),null}if(e=zn(Bt.current),fr(n)){c=n.stateNode,o=n.type;var h=n.memoizedProps;switch(c[zt]=n,c[ii]=h,e=(n.mode&1)!==0,o){case"dialog":Me("cancel",c),Me("close",c);break;case"iframe":case"object":case"embed":Me("load",c);break;case"video":case"audio":for(d=0;d<ti.length;d++)Me(ti[d],c);break;case"source":Me("error",c);break;case"img":case"image":case"link":Me("error",c),Me("load",c);break;case"details":Me("toggle",c);break;case"input":rc(c,h),Me("invalid",c);break;case"select":c._wrapperState={wasMultiple:!!h.multiple},Me("invalid",c);break;case"textarea":lc(c,h),Me("invalid",c)}Co(o,h),d=null;for(var y in h)if(h.hasOwnProperty(y)){var j=h[y];y==="children"?typeof j=="string"?c.textContent!==j&&(h.suppressHydrationWarning!==!0&&ir(c.textContent,j,e),d=["children",j]):typeof j=="number"&&c.textContent!==""+j&&(h.suppressHydrationWarning!==!0&&ir(c.textContent,j,e),d=["children",""+j]):l.hasOwnProperty(y)&&j!=null&&y==="onScroll"&&Me("scroll",c)}switch(o){case"input":Jn(c),ac(c,h,!0);break;case"textarea":Jn(c),uc(c);break;case"select":case"option":break;default:typeof h.onClick=="function"&&(c.onclick=rr)}c=d,n.updateQueue=c,c!==null&&(n.flags|=4)}else{y=d.nodeType===9?d:d.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=dc(o)),e==="http://www.w3.org/1999/xhtml"?o==="script"?(e=y.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof c.is=="string"?e=y.createElement(o,{is:c.is}):(e=y.createElement(o),o==="select"&&(y=e,c.multiple?y.multiple=!0:c.size&&(y.size=c.size))):e=y.createElementNS(e,o),e[zt]=n,e[ii]=c,Sd(e,n,!1,!1),n.stateNode=e;e:{switch(y=$o(o,c),o){case"dialog":Me("cancel",e),Me("close",e),d=c;break;case"iframe":case"object":case"embed":Me("load",e),d=c;break;case"video":case"audio":for(d=0;d<ti.length;d++)Me(ti[d],e);d=c;break;case"source":Me("error",e),d=c;break;case"img":case"image":case"link":Me("error",e),Me("load",e),d=c;break;case"details":Me("toggle",e),d=c;break;case"input":rc(e,c),d=xo(e,c),Me("invalid",e);break;case"option":d=c;break;case"select":e._wrapperState={wasMultiple:!!c.multiple},d=W({},c,{value:void 0}),Me("invalid",e);break;case"textarea":lc(e,c),d=So(e,c),Me("invalid",e);break;default:d=c}Co(o,d),j=d;for(h in j)if(j.hasOwnProperty(h)){var C=j[h];h==="style"?mc(e,C):h==="dangerouslySetInnerHTML"?(C=C?C.__html:void 0,C!=null&&fc(e,C)):h==="children"?typeof C=="string"?(o!=="textarea"||C!=="")&&_s(e,C):typeof C=="number"&&_s(e,""+C):h!=="suppressContentEditableWarning"&&h!=="suppressHydrationWarning"&&h!=="autoFocus"&&(l.hasOwnProperty(h)?C!=null&&h==="onScroll"&&Me("scroll",e):C!=null&&O(e,h,C,y))}switch(o){case"input":Jn(e),ac(e,c,!1);break;case"textarea":Jn(e),uc(e);break;case"option":c.value!=null&&e.setAttribute("value",""+ve(c.value));break;case"select":e.multiple=!!c.multiple,h=c.value,h!=null?Xn(e,!!c.multiple,h,!1):c.defaultValue!=null&&Xn(e,!!c.multiple,c.defaultValue,!0);break;default:typeof d.onClick=="function"&&(e.onclick=rr)}switch(o){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break e;case"img":c=!0;break e;default:c=!1}}c&&(n.flags|=4)}n.ref!==null&&(n.flags|=512,n.flags|=2097152)}return tt(n),null;case 6:if(e&&n.stateNode!=null)Cd(e,n,e.memoizedProps,c);else{if(typeof c!="string"&&n.stateNode===null)throw Error(r(166));if(o=zn(ci.current),zn(Bt.current),fr(n)){if(c=n.stateNode,o=n.memoizedProps,c[zt]=n,(h=c.nodeValue!==o)&&(e=yt,e!==null))switch(e.tag){case 3:ir(c.nodeValue,o,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&ir(c.nodeValue,o,(e.mode&1)!==0)}h&&(n.flags|=4)}else c=(o.nodeType===9?o:o.ownerDocument).createTextNode(c),c[zt]=n,n.stateNode=c}return tt(n),null;case 13:if(Ie(Le),c=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Ae&&kt!==null&&(n.mode&1)!==0&&(n.flags&128)===0)Tu(),hs(),n.flags|=98560,h=!1;else if(h=fr(n),c!==null&&c.dehydrated!==null){if(e===null){if(!h)throw Error(r(318));if(h=n.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));h[zt]=n}else hs(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;tt(n),h=!1}else At!==null&&(nl(At),At=null),h=!0;if(!h)return n.flags&65536?n:null}return(n.flags&128)!==0?(n.lanes=o,n):(c=c!==null,c!==(e!==null&&e.memoizedState!==null)&&c&&(n.child.flags|=8192,(n.mode&1)!==0&&(e===null||(Le.current&1)!==0?Ue===0&&(Ue=3):rl())),n.updateQueue!==null&&(n.flags|=4),tt(n),null);case 4:return vs(),Va(e,n),e===null&&ni(n.stateNode.containerInfo),tt(n),null;case 10:return ka(n.type._context),tt(n),null;case 17:return dt(n.type)&&ar(),tt(n),null;case 19:if(Ie(Le),h=n.memoizedState,h===null)return tt(n),null;if(c=(n.flags&128)!==0,y=h.rendering,y===null)if(c)mi(h,!1);else{if(Ue!==0||e!==null&&(e.flags&128)!==0)for(e=n.child;e!==null;){if(y=yr(e),y!==null){for(n.flags|=128,mi(h,!1),c=y.updateQueue,c!==null&&(n.updateQueue=c,n.flags|=4),n.subtreeFlags=0,c=o,o=n.child;o!==null;)h=o,e=c,h.flags&=14680066,y=h.alternate,y===null?(h.childLanes=0,h.lanes=e,h.child=null,h.subtreeFlags=0,h.memoizedProps=null,h.memoizedState=null,h.updateQueue=null,h.dependencies=null,h.stateNode=null):(h.childLanes=y.childLanes,h.lanes=y.lanes,h.child=y.child,h.subtreeFlags=0,h.deletions=null,h.memoizedProps=y.memoizedProps,h.memoizedState=y.memoizedState,h.updateQueue=y.updateQueue,h.type=y.type,e=y.dependencies,h.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),o=o.sibling;return Ee(Le,Le.current&1|2),n.child}e=e.sibling}h.tail!==null&&Pe()>ws&&(n.flags|=128,c=!0,mi(h,!1),n.lanes=4194304)}else{if(!c)if(e=yr(y),e!==null){if(n.flags|=128,c=!0,o=e.updateQueue,o!==null&&(n.updateQueue=o,n.flags|=4),mi(h,!0),h.tail===null&&h.tailMode==="hidden"&&!y.alternate&&!Ae)return tt(n),null}else 2*Pe()-h.renderingStartTime>ws&&o!==1073741824&&(n.flags|=128,c=!0,mi(h,!1),n.lanes=4194304);h.isBackwards?(y.sibling=n.child,n.child=y):(o=h.last,o!==null?o.sibling=y:n.child=y,h.last=y)}return h.tail!==null?(n=h.tail,h.rendering=n,h.tail=n.sibling,h.renderingStartTime=Pe(),n.sibling=null,o=Le.current,Ee(Le,c?o&1|2:o&1),n):(tt(n),null);case 22:case 23:return il(),c=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==c&&(n.flags|=8192),c&&(n.mode&1)!==0?(xt&1073741824)!==0&&(tt(n),n.subtreeFlags&6&&(n.flags|=8192)):tt(n),null;case 24:return null;case 25:return null}throw Error(r(156,n.tag))}function Pp(e,n){switch(ha(n),n.tag){case 1:return dt(n.type)&&ar(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return vs(),Ie(ut),Ie(Ze),$a(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Na(n),null;case 13:if(Ie(Le),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(r(340));hs()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Ie(Le),null;case 4:return vs(),null;case 10:return ka(n.type._context),null;case 22:case 23:return il(),null;case 24:return null;default:return null}}var br=!1,nt=!1,Dp=typeof WeakSet=="function"?WeakSet:Set,J=null;function ks(e,n){var o=e.ref;if(o!==null)if(typeof o=="function")try{o(null)}catch(c){Oe(e,n,c)}else o.current=null}function Ka(e,n,o){try{o()}catch(c){Oe(e,n,c)}}var $d=!1;function zp(e,n){if(ia=Qi,e=iu(),Yo(e)){if("selectionStart"in e)var o={start:e.selectionStart,end:e.selectionEnd};else e:{o=(o=e.ownerDocument)&&o.defaultView||window;var c=o.getSelection&&o.getSelection();if(c&&c.rangeCount!==0){o=c.anchorNode;var d=c.anchorOffset,h=c.focusNode;c=c.focusOffset;try{o.nodeType,h.nodeType}catch{o=null;break e}var y=0,j=-1,C=-1,R=0,z=0,U=e,D=null;t:for(;;){for(var Y;U!==o||d!==0&&U.nodeType!==3||(j=y+d),U!==h||c!==0&&U.nodeType!==3||(C=y+c),U.nodeType===3&&(y+=U.nodeValue.length),(Y=U.firstChild)!==null;)D=U,U=Y;for(;;){if(U===e)break t;if(D===o&&++R===d&&(j=y),D===h&&++z===c&&(C=y),(Y=U.nextSibling)!==null)break;U=D,D=U.parentNode}U=Y}o=j===-1||C===-1?null:{start:j,end:C}}else o=null}o=o||{start:0,end:0}}else o=null;for(ra={focusedElem:e,selectionRange:o},Qi=!1,J=n;J!==null;)if(n=J,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,J=e;else for(;J!==null;){n=J;try{var X=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(X!==null){var Z=X.memoizedProps,De=X.memoizedState,T=n.stateNode,$=T.getSnapshotBeforeUpdate(n.elementType===n.type?Z:Lt(n.type,Z),De);T.__reactInternalSnapshotBeforeUpdate=$}break;case 3:var A=n.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(H){Oe(n,n.return,H)}if(e=n.sibling,e!==null){e.return=n.return,J=e;break}J=n.return}return X=$d,$d=!1,X}function pi(e,n,o){var c=n.updateQueue;if(c=c!==null?c.lastEffect:null,c!==null){var d=c=c.next;do{if((d.tag&e)===e){var h=d.destroy;d.destroy=void 0,h!==void 0&&Ka(n,o,h)}d=d.next}while(d!==c)}}function Tr(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var o=n=n.next;do{if((o.tag&e)===e){var c=o.create;o.destroy=c()}o=o.next}while(o!==n)}}function Qa(e){var n=e.ref;if(n!==null){var o=e.stateNode;switch(e.tag){case 5:e=o;break;default:e=o}typeof n=="function"?n(e):n.current=e}}function bd(e){var n=e.alternate;n!==null&&(e.alternate=null,bd(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[zt],delete n[ii],delete n[ca],delete n[wp],delete n[jp])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Td(e){return e.tag===5||e.tag===3||e.tag===4}function Ed(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Td(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function qa(e,n,o){var c=e.tag;if(c===5||c===6)e=e.stateNode,n?o.nodeType===8?o.parentNode.insertBefore(e,n):o.insertBefore(e,n):(o.nodeType===8?(n=o.parentNode,n.insertBefore(e,o)):(n=o,n.appendChild(e)),o=o._reactRootContainer,o!=null||n.onclick!==null||(n.onclick=rr));else if(c!==4&&(e=e.child,e!==null))for(qa(e,n,o),e=e.sibling;e!==null;)qa(e,n,o),e=e.sibling}function Ga(e,n,o){var c=e.tag;if(c===5||c===6)e=e.stateNode,n?o.insertBefore(e,n):o.appendChild(e);else if(c!==4&&(e=e.child,e!==null))for(Ga(e,n,o),e=e.sibling;e!==null;)Ga(e,n,o),e=e.sibling}var Ye=null,Rt=!1;function kn(e,n,o){for(o=o.child;o!==null;)Md(e,n,o),o=o.sibling}function Md(e,n,o){if(Dt&&typeof Dt.onCommitFiberUnmount=="function")try{Dt.onCommitFiberUnmount(Fi,o)}catch{}switch(o.tag){case 5:nt||ks(o,n);case 6:var c=Ye,d=Rt;Ye=null,kn(e,n,o),Ye=c,Rt=d,Ye!==null&&(Rt?(e=Ye,o=o.stateNode,e.nodeType===8?e.parentNode.removeChild(o):e.removeChild(o)):Ye.removeChild(o.stateNode));break;case 18:Ye!==null&&(Rt?(e=Ye,o=o.stateNode,e.nodeType===8?la(e.parentNode,o):e.nodeType===1&&la(e,o),Qs(e)):la(Ye,o.stateNode));break;case 4:c=Ye,d=Rt,Ye=o.stateNode.containerInfo,Rt=!0,kn(e,n,o),Ye=c,Rt=d;break;case 0:case 11:case 14:case 15:if(!nt&&(c=o.updateQueue,c!==null&&(c=c.lastEffect,c!==null))){d=c=c.next;do{var h=d,y=h.destroy;h=h.tag,y!==void 0&&((h&2)!==0||(h&4)!==0)&&Ka(o,n,y),d=d.next}while(d!==c)}kn(e,n,o);break;case 1:if(!nt&&(ks(o,n),c=o.stateNode,typeof c.componentWillUnmount=="function"))try{c.props=o.memoizedProps,c.state=o.memoizedState,c.componentWillUnmount()}catch(j){Oe(o,n,j)}kn(e,n,o);break;case 21:kn(e,n,o);break;case 22:o.mode&1?(nt=(c=nt)||o.memoizedState!==null,kn(e,n,o),nt=c):kn(e,n,o);break;default:kn(e,n,o)}}function Id(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var o=e.stateNode;o===null&&(o=e.stateNode=new Dp),n.forEach(function(c){var d=qp.bind(null,e,c);o.has(c)||(o.add(c),c.then(d,d))})}}function Ot(e,n){var o=n.deletions;if(o!==null)for(var c=0;c<o.length;c++){var d=o[c];try{var h=e,y=n,j=y;e:for(;j!==null;){switch(j.tag){case 5:Ye=j.stateNode,Rt=!1;break e;case 3:Ye=j.stateNode.containerInfo,Rt=!0;break e;case 4:Ye=j.stateNode.containerInfo,Rt=!0;break e}j=j.return}if(Ye===null)throw Error(r(160));Md(h,y,d),Ye=null,Rt=!1;var C=d.alternate;C!==null&&(C.return=null),d.return=null}catch(R){Oe(d,n,R)}}if(n.subtreeFlags&12854)for(n=n.child;n!==null;)Ad(n,e),n=n.sibling}function Ad(e,n){var o=e.alternate,c=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Ot(n,e),Ut(e),c&4){try{pi(3,e,e.return),Tr(3,e)}catch(Z){Oe(e,e.return,Z)}try{pi(5,e,e.return)}catch(Z){Oe(e,e.return,Z)}}break;case 1:Ot(n,e),Ut(e),c&512&&o!==null&&ks(o,o.return);break;case 5:if(Ot(n,e),Ut(e),c&512&&o!==null&&ks(o,o.return),e.flags&32){var d=e.stateNode;try{_s(d,"")}catch(Z){Oe(e,e.return,Z)}}if(c&4&&(d=e.stateNode,d!=null)){var h=e.memoizedProps,y=o!==null?o.memoizedProps:h,j=e.type,C=e.updateQueue;if(e.updateQueue=null,C!==null)try{j==="input"&&h.type==="radio"&&h.name!=null&&oc(d,h),$o(j,y);var R=$o(j,h);for(y=0;y<C.length;y+=2){var z=C[y],U=C[y+1];z==="style"?mc(d,U):z==="dangerouslySetInnerHTML"?fc(d,U):z==="children"?_s(d,U):O(d,z,U,R)}switch(j){case"input":wo(d,h);break;case"textarea":cc(d,h);break;case"select":var D=d._wrapperState.wasMultiple;d._wrapperState.wasMultiple=!!h.multiple;var Y=h.value;Y!=null?Xn(d,!!h.multiple,Y,!1):D!==!!h.multiple&&(h.defaultValue!=null?Xn(d,!!h.multiple,h.defaultValue,!0):Xn(d,!!h.multiple,h.multiple?[]:"",!1))}d[ii]=h}catch(Z){Oe(e,e.return,Z)}}break;case 6:if(Ot(n,e),Ut(e),c&4){if(e.stateNode===null)throw Error(r(162));d=e.stateNode,h=e.memoizedProps;try{d.nodeValue=h}catch(Z){Oe(e,e.return,Z)}}break;case 3:if(Ot(n,e),Ut(e),c&4&&o!==null&&o.memoizedState.isDehydrated)try{Qs(n.containerInfo)}catch(Z){Oe(e,e.return,Z)}break;case 4:Ot(n,e),Ut(e);break;case 13:Ot(n,e),Ut(e),d=e.child,d.flags&8192&&(h=d.memoizedState!==null,d.stateNode.isHidden=h,!h||d.alternate!==null&&d.alternate.memoizedState!==null||(Xa=Pe())),c&4&&Id(e);break;case 22:if(z=o!==null&&o.memoizedState!==null,e.mode&1?(nt=(R=nt)||z,Ot(n,e),nt=R):Ot(n,e),Ut(e),c&8192){if(R=e.memoizedState!==null,(e.stateNode.isHidden=R)&&!z&&(e.mode&1)!==0)for(J=e,z=e.child;z!==null;){for(U=J=z;J!==null;){switch(D=J,Y=D.child,D.tag){case 0:case 11:case 14:case 15:pi(4,D,D.return);break;case 1:ks(D,D.return);var X=D.stateNode;if(typeof X.componentWillUnmount=="function"){c=D,o=D.return;try{n=c,X.props=n.memoizedProps,X.state=n.memoizedState,X.componentWillUnmount()}catch(Z){Oe(c,o,Z)}}break;case 5:ks(D,D.return);break;case 22:if(D.memoizedState!==null){Od(U);continue}}Y!==null?(Y.return=D,J=Y):Od(U)}z=z.sibling}e:for(z=null,U=e;;){if(U.tag===5){if(z===null){z=U;try{d=U.stateNode,R?(h=d.style,typeof h.setProperty=="function"?h.setProperty("display","none","important"):h.display="none"):(j=U.stateNode,C=U.memoizedProps.style,y=C!=null&&C.hasOwnProperty("display")?C.display:null,j.style.display=hc("display",y))}catch(Z){Oe(e,e.return,Z)}}}else if(U.tag===6){if(z===null)try{U.stateNode.nodeValue=R?"":U.memoizedProps}catch(Z){Oe(e,e.return,Z)}}else if((U.tag!==22&&U.tag!==23||U.memoizedState===null||U===e)&&U.child!==null){U.child.return=U,U=U.child;continue}if(U===e)break e;for(;U.sibling===null;){if(U.return===null||U.return===e)break e;z===U&&(z=null),U=U.return}z===U&&(z=null),U.sibling.return=U.return,U=U.sibling}}break;case 19:Ot(n,e),Ut(e),c&4&&Id(e);break;case 21:break;default:Ot(n,e),Ut(e)}}function Ut(e){var n=e.flags;if(n&2){try{e:{for(var o=e.return;o!==null;){if(Td(o)){var c=o;break e}o=o.return}throw Error(r(160))}switch(c.tag){case 5:var d=c.stateNode;c.flags&32&&(_s(d,""),c.flags&=-33);var h=Ed(e);Ga(e,h,d);break;case 3:case 4:var y=c.stateNode.containerInfo,j=Ed(e);qa(e,j,y);break;default:throw Error(r(161))}}catch(C){Oe(e,e.return,C)}e.flags&=-3}n&4096&&(e.flags&=-4097)}function Bp(e,n,o){J=e,Ld(e)}function Ld(e,n,o){for(var c=(e.mode&1)!==0;J!==null;){var d=J,h=d.child;if(d.tag===22&&c){var y=d.memoizedState!==null||br;if(!y){var j=d.alternate,C=j!==null&&j.memoizedState!==null||nt;j=br;var R=nt;if(br=y,(nt=C)&&!R)for(J=d;J!==null;)y=J,C=y.child,y.tag===22&&y.memoizedState!==null?_d(d):C!==null?(C.return=y,J=C):_d(d);for(;h!==null;)J=h,Ld(h),h=h.sibling;J=d,br=j,nt=R}Rd(e)}else(d.subtreeFlags&8772)!==0&&h!==null?(h.return=d,J=h):Rd(e)}}function Rd(e){for(;J!==null;){var n=J;if((n.flags&8772)!==0){var o=n.alternate;try{if((n.flags&8772)!==0)switch(n.tag){case 0:case 11:case 15:nt||Tr(5,n);break;case 1:var c=n.stateNode;if(n.flags&4&&!nt)if(o===null)c.componentDidMount();else{var d=n.elementType===n.type?o.memoizedProps:Lt(n.type,o.memoizedProps);c.componentDidUpdate(d,o.memoizedState,c.__reactInternalSnapshotBeforeUpdate)}var h=n.updateQueue;h!==null&&Ou(n,h,c);break;case 3:var y=n.updateQueue;if(y!==null){if(o=null,n.child!==null)switch(n.child.tag){case 5:o=n.child.stateNode;break;case 1:o=n.child.stateNode}Ou(n,y,o)}break;case 5:var j=n.stateNode;if(o===null&&n.flags&4){o=j;var C=n.memoizedProps;switch(n.type){case"button":case"input":case"select":case"textarea":C.autoFocus&&o.focus();break;case"img":C.src&&(o.src=C.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(n.memoizedState===null){var R=n.alternate;if(R!==null){var z=R.memoizedState;if(z!==null){var U=z.dehydrated;U!==null&&Qs(U)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(r(163))}nt||n.flags&512&&Qa(n)}catch(D){Oe(n,n.return,D)}}if(n===e){J=null;break}if(o=n.sibling,o!==null){o.return=n.return,J=o;break}J=n.return}}function Od(e){for(;J!==null;){var n=J;if(n===e){J=null;break}var o=n.sibling;if(o!==null){o.return=n.return,J=o;break}J=n.return}}function _d(e){for(;J!==null;){var n=J;try{switch(n.tag){case 0:case 11:case 15:var o=n.return;try{Tr(4,n)}catch(C){Oe(n,o,C)}break;case 1:var c=n.stateNode;if(typeof c.componentDidMount=="function"){var d=n.return;try{c.componentDidMount()}catch(C){Oe(n,d,C)}}var h=n.return;try{Qa(n)}catch(C){Oe(n,h,C)}break;case 5:var y=n.return;try{Qa(n)}catch(C){Oe(n,y,C)}}}catch(C){Oe(n,n.return,C)}if(n===e){J=null;break}var j=n.sibling;if(j!==null){j.return=n.return,J=j;break}J=n.return}}var Fp=Math.ceil,Er=ee.ReactCurrentDispatcher,Ya=ee.ReactCurrentOwner,$t=ee.ReactCurrentBatchConfig,je=0,Qe=null,Be=null,Je=0,xt=0,xs=mn(0),Ue=0,gi=null,Fn=0,Mr=0,Ja=0,vi=null,ht=null,Xa=0,ws=1/0,tn=null,Ir=!1,Za=null,xn=null,Ar=!1,wn=null,Lr=0,yi=0,el=null,Rr=-1,Or=0;function at(){return(je&6)!==0?Pe():Rr!==-1?Rr:Rr=Pe()}function jn(e){return(e.mode&1)===0?1:(je&2)!==0&&Je!==0?Je&-Je:Np.transition!==null?(Or===0&&(Or=Ec()),Or):(e=Ne,e!==0||(e=window.event,e=e===void 0?16:Dc(e.type)),e)}function _t(e,n,o,c){if(50<yi)throw yi=0,el=null,Error(r(185));Us(e,o,c),((je&2)===0||e!==Qe)&&(e===Qe&&((je&2)===0&&(Mr|=o),Ue===4&&Sn(e,Je)),mt(e,c),o===1&&je===0&&(n.mode&1)===0&&(ws=Pe()+500,cr&&gn()))}function mt(e,n){var o=e.callbackNode;Nm(e,n);var c=Hi(e,e===Qe?Je:0);if(c===0)o!==null&&$c(o),e.callbackNode=null,e.callbackPriority=0;else if(n=c&-c,e.callbackPriority!==n){if(o!=null&&$c(o),n===1)e.tag===0?Sp(Dd.bind(null,e)):Su(Dd.bind(null,e)),kp(function(){(je&6)===0&&gn()}),o=null;else{switch(Mc(c)){case 1:o=Lo;break;case 4:o=bc;break;case 16:o=Bi;break;case 536870912:o=Tc;break;default:o=Bi}o=Kd(o,Pd.bind(null,e))}e.callbackPriority=n,e.callbackNode=o}}function Pd(e,n){if(Rr=-1,Or=0,(je&6)!==0)throw Error(r(327));var o=e.callbackNode;if(js()&&e.callbackNode!==o)return null;var c=Hi(e,e===Qe?Je:0);if(c===0)return null;if((c&30)!==0||(c&e.expiredLanes)!==0||n)n=_r(e,c);else{n=c;var d=je;je|=2;var h=Bd();(Qe!==e||Je!==n)&&(tn=null,ws=Pe()+500,Wn(e,n));do try{Hp();break}catch(j){zd(e,j)}while(!0);ya(),Er.current=h,je=d,Be!==null?n=0:(Qe=null,Je=0,n=Ue)}if(n!==0){if(n===2&&(d=Ro(e),d!==0&&(c=d,n=tl(e,d))),n===1)throw o=gi,Wn(e,0),Sn(e,c),mt(e,Pe()),o;if(n===6)Sn(e,c);else{if(d=e.current.alternate,(c&30)===0&&!Up(d)&&(n=_r(e,c),n===2&&(h=Ro(e),h!==0&&(c=h,n=tl(e,h))),n===1))throw o=gi,Wn(e,0),Sn(e,c),mt(e,Pe()),o;switch(e.finishedWork=d,e.finishedLanes=c,n){case 0:case 1:throw Error(r(345));case 2:Hn(e,ht,tn);break;case 3:if(Sn(e,c),(c&130023424)===c&&(n=Xa+500-Pe(),10<n)){if(Hi(e,0)!==0)break;if(d=e.suspendedLanes,(d&c)!==c){at(),e.pingedLanes|=e.suspendedLanes&d;break}e.timeoutHandle=aa(Hn.bind(null,e,ht,tn),n);break}Hn(e,ht,tn);break;case 4:if(Sn(e,c),(c&4194240)===c)break;for(n=e.eventTimes,d=-1;0<c;){var y=31-Mt(c);h=1<<y,y=n[y],y>d&&(d=y),c&=~h}if(c=d,c=Pe()-c,c=(120>c?120:480>c?480:1080>c?1080:1920>c?1920:3e3>c?3e3:4320>c?4320:1960*Fp(c/1960))-c,10<c){e.timeoutHandle=aa(Hn.bind(null,e,ht,tn),c);break}Hn(e,ht,tn);break;case 5:Hn(e,ht,tn);break;default:throw Error(r(329))}}}return mt(e,Pe()),e.callbackNode===o?Pd.bind(null,e):null}function tl(e,n){var o=vi;return e.current.memoizedState.isDehydrated&&(Wn(e,n).flags|=256),e=_r(e,n),e!==2&&(n=ht,ht=o,n!==null&&nl(n)),e}function nl(e){ht===null?ht=e:ht.push.apply(ht,e)}function Up(e){for(var n=e;;){if(n.flags&16384){var o=n.updateQueue;if(o!==null&&(o=o.stores,o!==null))for(var c=0;c<o.length;c++){var d=o[c],h=d.getSnapshot;d=d.value;try{if(!It(h(),d))return!1}catch{return!1}}}if(o=n.child,n.subtreeFlags&16384&&o!==null)o.return=n,n=o;else{if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return!0;n=n.return}n.sibling.return=n.return,n=n.sibling}}return!0}function Sn(e,n){for(n&=~Ja,n&=~Mr,e.suspendedLanes|=n,e.pingedLanes&=~n,e=e.expirationTimes;0<n;){var o=31-Mt(n),c=1<<o;e[o]=-1,n&=~c}}function Dd(e){if((je&6)!==0)throw Error(r(327));js();var n=Hi(e,0);if((n&1)===0)return mt(e,Pe()),null;var o=_r(e,n);if(e.tag!==0&&o===2){var c=Ro(e);c!==0&&(n=c,o=tl(e,c))}if(o===1)throw o=gi,Wn(e,0),Sn(e,n),mt(e,Pe()),o;if(o===6)throw Error(r(345));return e.finishedWork=e.current.alternate,e.finishedLanes=n,Hn(e,ht,tn),mt(e,Pe()),null}function sl(e,n){var o=je;je|=1;try{return e(n)}finally{je=o,je===0&&(ws=Pe()+500,cr&&gn())}}function Un(e){wn!==null&&wn.tag===0&&(je&6)===0&&js();var n=je;je|=1;var o=$t.transition,c=Ne;try{if($t.transition=null,Ne=1,e)return e()}finally{Ne=c,$t.transition=o,je=n,(je&6)===0&&gn()}}function il(){xt=xs.current,Ie(xs)}function Wn(e,n){e.finishedWork=null,e.finishedLanes=0;var o=e.timeoutHandle;if(o!==-1&&(e.timeoutHandle=-1,yp(o)),Be!==null)for(o=Be.return;o!==null;){var c=o;switch(ha(c),c.tag){case 1:c=c.type.childContextTypes,c!=null&&ar();break;case 3:vs(),Ie(ut),Ie(Ze),$a();break;case 5:Na(c);break;case 4:vs();break;case 13:Ie(Le);break;case 19:Ie(Le);break;case 10:ka(c.type._context);break;case 22:case 23:il()}o=o.return}if(Qe=e,Be=e=Nn(e.current,null),Je=xt=n,Ue=0,gi=null,Ja=Mr=Fn=0,ht=vi=null,Dn!==null){for(n=0;n<Dn.length;n++)if(o=Dn[n],c=o.interleaved,c!==null){o.interleaved=null;var d=c.next,h=o.pending;if(h!==null){var y=h.next;h.next=d,c.next=y}o.pending=c}Dn=null}return e}function zd(e,n){do{var o=Be;try{if(ya(),kr.current=Sr,xr){for(var c=Re.memoizedState;c!==null;){var d=c.queue;d!==null&&(d.pending=null),c=c.next}xr=!1}if(Bn=0,Ke=Fe=Re=null,ui=!1,di=0,Ya.current=null,o===null||o.return===null){Ue=1,gi=n,Be=null;break}e:{var h=e,y=o.return,j=o,C=n;if(n=Je,j.flags|=32768,C!==null&&typeof C=="object"&&typeof C.then=="function"){var R=C,z=j,U=z.tag;if((z.mode&1)===0&&(U===0||U===11||U===15)){var D=z.alternate;D?(z.updateQueue=D.updateQueue,z.memoizedState=D.memoizedState,z.lanes=D.lanes):(z.updateQueue=null,z.memoizedState=null)}var Y=ud(y);if(Y!==null){Y.flags&=-257,dd(Y,y,j,h,n),Y.mode&1&&cd(h,R,n),n=Y,C=R;var X=n.updateQueue;if(X===null){var Z=new Set;Z.add(C),n.updateQueue=Z}else X.add(C);break e}else{if((n&1)===0){cd(h,R,n),rl();break e}C=Error(r(426))}}else if(Ae&&j.mode&1){var De=ud(y);if(De!==null){(De.flags&65536)===0&&(De.flags|=256),dd(De,y,j,h,n),ga(ys(C,j));break e}}h=C=ys(C,j),Ue!==4&&(Ue=2),vi===null?vi=[h]:vi.push(h),h=y;do{switch(h.tag){case 3:h.flags|=65536,n&=-n,h.lanes|=n;var T=ad(h,C,n);Ru(h,T);break e;case 1:j=C;var $=h.type,A=h.stateNode;if((h.flags&128)===0&&(typeof $.getDerivedStateFromError=="function"||A!==null&&typeof A.componentDidCatch=="function"&&(xn===null||!xn.has(A)))){h.flags|=65536,n&=-n,h.lanes|=n;var H=ld(h,j,n);Ru(h,H);break e}}h=h.return}while(h!==null)}Ud(o)}catch(te){n=te,Be===o&&o!==null&&(Be=o=o.return);continue}break}while(!0)}function Bd(){var e=Er.current;return Er.current=Sr,e===null?Sr:e}function rl(){(Ue===0||Ue===3||Ue===2)&&(Ue=4),Qe===null||(Fn&268435455)===0&&(Mr&268435455)===0||Sn(Qe,Je)}function _r(e,n){var o=je;je|=2;var c=Bd();(Qe!==e||Je!==n)&&(tn=null,Wn(e,n));do try{Wp();break}catch(d){zd(e,d)}while(!0);if(ya(),je=o,Er.current=c,Be!==null)throw Error(r(261));return Qe=null,Je=0,Ue}function Wp(){for(;Be!==null;)Fd(Be)}function Hp(){for(;Be!==null&&!pm();)Fd(Be)}function Fd(e){var n=Vd(e.alternate,e,xt);e.memoizedProps=e.pendingProps,n===null?Ud(e):Be=n,Ya.current=null}function Ud(e){var n=e;do{var o=n.alternate;if(e=n.return,(n.flags&32768)===0){if(o=_p(o,n,xt),o!==null){Be=o;return}}else{if(o=Pp(o,n),o!==null){o.flags&=32767,Be=o;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Ue=6,Be=null;return}}if(n=n.sibling,n!==null){Be=n;return}Be=n=e}while(n!==null);Ue===0&&(Ue=5)}function Hn(e,n,o){var c=Ne,d=$t.transition;try{$t.transition=null,Ne=1,Vp(e,n,o,c)}finally{$t.transition=d,Ne=c}return null}function Vp(e,n,o,c){do js();while(wn!==null);if((je&6)!==0)throw Error(r(327));o=e.finishedWork;var d=e.finishedLanes;if(o===null)return null;if(e.finishedWork=null,e.finishedLanes=0,o===e.current)throw Error(r(177));e.callbackNode=null,e.callbackPriority=0;var h=o.lanes|o.childLanes;if(Cm(e,h),e===Qe&&(Be=Qe=null,Je=0),(o.subtreeFlags&2064)===0&&(o.flags&2064)===0||Ar||(Ar=!0,Kd(Bi,function(){return js(),null})),h=(o.flags&15990)!==0,(o.subtreeFlags&15990)!==0||h){h=$t.transition,$t.transition=null;var y=Ne;Ne=1;var j=je;je|=4,Ya.current=null,zp(e,o),Ad(o,e),dp(ra),Qi=!!ia,ra=ia=null,e.current=o,Bp(o),gm(),je=j,Ne=y,$t.transition=h}else e.current=o;if(Ar&&(Ar=!1,wn=e,Lr=d),h=e.pendingLanes,h===0&&(xn=null),km(o.stateNode),mt(e,Pe()),n!==null)for(c=e.onRecoverableError,o=0;o<n.length;o++)d=n[o],c(d.value,{componentStack:d.stack,digest:d.digest});if(Ir)throw Ir=!1,e=Za,Za=null,e;return(Lr&1)!==0&&e.tag!==0&&js(),h=e.pendingLanes,(h&1)!==0?e===el?yi++:(yi=0,el=e):yi=0,gn(),null}function js(){if(wn!==null){var e=Mc(Lr),n=$t.transition,o=Ne;try{if($t.transition=null,Ne=16>e?16:e,wn===null)var c=!1;else{if(e=wn,wn=null,Lr=0,(je&6)!==0)throw Error(r(331));var d=je;for(je|=4,J=e.current;J!==null;){var h=J,y=h.child;if((J.flags&16)!==0){var j=h.deletions;if(j!==null){for(var C=0;C<j.length;C++){var R=j[C];for(J=R;J!==null;){var z=J;switch(z.tag){case 0:case 11:case 15:pi(8,z,h)}var U=z.child;if(U!==null)U.return=z,J=U;else for(;J!==null;){z=J;var D=z.sibling,Y=z.return;if(bd(z),z===R){J=null;break}if(D!==null){D.return=Y,J=D;break}J=Y}}}var X=h.alternate;if(X!==null){var Z=X.child;if(Z!==null){X.child=null;do{var De=Z.sibling;Z.sibling=null,Z=De}while(Z!==null)}}J=h}}if((h.subtreeFlags&2064)!==0&&y!==null)y.return=h,J=y;else e:for(;J!==null;){if(h=J,(h.flags&2048)!==0)switch(h.tag){case 0:case 11:case 15:pi(9,h,h.return)}var T=h.sibling;if(T!==null){T.return=h.return,J=T;break e}J=h.return}}var $=e.current;for(J=$;J!==null;){y=J;var A=y.child;if((y.subtreeFlags&2064)!==0&&A!==null)A.return=y,J=A;else e:for(y=$;J!==null;){if(j=J,(j.flags&2048)!==0)try{switch(j.tag){case 0:case 11:case 15:Tr(9,j)}}catch(te){Oe(j,j.return,te)}if(j===y){J=null;break e}var H=j.sibling;if(H!==null){H.return=j.return,J=H;break e}J=j.return}}if(je=d,gn(),Dt&&typeof Dt.onPostCommitFiberRoot=="function")try{Dt.onPostCommitFiberRoot(Fi,e)}catch{}c=!0}return c}finally{Ne=o,$t.transition=n}}return!1}function Wd(e,n,o){n=ys(o,n),n=ad(e,n,1),e=yn(e,n,1),n=at(),e!==null&&(Us(e,1,n),mt(e,n))}function Oe(e,n,o){if(e.tag===3)Wd(e,e,o);else for(;n!==null;){if(n.tag===3){Wd(n,e,o);break}else if(n.tag===1){var c=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(xn===null||!xn.has(c))){e=ys(o,e),e=ld(n,e,1),n=yn(n,e,1),e=at(),n!==null&&(Us(n,1,e),mt(n,e));break}}n=n.return}}function Kp(e,n,o){var c=e.pingCache;c!==null&&c.delete(n),n=at(),e.pingedLanes|=e.suspendedLanes&o,Qe===e&&(Je&o)===o&&(Ue===4||Ue===3&&(Je&130023424)===Je&&500>Pe()-Xa?Wn(e,0):Ja|=o),mt(e,n)}function Hd(e,n){n===0&&((e.mode&1)===0?n=1:(n=Wi,Wi<<=1,(Wi&130023424)===0&&(Wi=4194304)));var o=at();e=Xt(e,n),e!==null&&(Us(e,n,o),mt(e,o))}function Qp(e){var n=e.memoizedState,o=0;n!==null&&(o=n.retryLane),Hd(e,o)}function qp(e,n){var o=0;switch(e.tag){case 13:var c=e.stateNode,d=e.memoizedState;d!==null&&(o=d.retryLane);break;case 19:c=e.stateNode;break;default:throw Error(r(314))}c!==null&&c.delete(n),Hd(e,o)}var Vd;Vd=function(e,n,o){if(e!==null)if(e.memoizedProps!==n.pendingProps||ut.current)ft=!0;else{if((e.lanes&o)===0&&(n.flags&128)===0)return ft=!1,Op(e,n,o);ft=(e.flags&131072)!==0}else ft=!1,Ae&&(n.flags&1048576)!==0&&Nu(n,dr,n.index);switch(n.lanes=0,n.tag){case 2:var c=n.type;$r(e,n),e=n.pendingProps;var d=us(n,Ze.current);gs(n,o),d=Ea(null,n,c,e,d,o);var h=Ma();return n.flags|=1,typeof d=="object"&&d!==null&&typeof d.render=="function"&&d.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,dt(c)?(h=!0,lr(n)):h=!1,n.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,ja(n),d.updater=Nr,n.stateNode=d,d._reactInternals=n,_a(n,c,e,o),n=Ba(null,n,c,!0,h,o)):(n.tag=0,Ae&&h&&fa(n),ot(null,n,d,o),n=n.child),n;case 16:c=n.elementType;e:{switch($r(e,n),e=n.pendingProps,d=c._init,c=d(c._payload),n.type=c,d=n.tag=Yp(c),e=Lt(c,e),d){case 0:n=za(null,n,c,e,o);break e;case 1:n=vd(null,n,c,e,o);break e;case 11:n=fd(null,n,c,e,o);break e;case 14:n=hd(null,n,c,Lt(c.type,e),o);break e}throw Error(r(306,c,""))}return n;case 0:return c=n.type,d=n.pendingProps,d=n.elementType===c?d:Lt(c,d),za(e,n,c,d,o);case 1:return c=n.type,d=n.pendingProps,d=n.elementType===c?d:Lt(c,d),vd(e,n,c,d,o);case 3:e:{if(yd(n),e===null)throw Error(r(387));c=n.pendingProps,h=n.memoizedState,d=h.element,Lu(e,n),vr(n,c,null,o);var y=n.memoizedState;if(c=y.element,h.isDehydrated)if(h={element:c,isDehydrated:!1,cache:y.cache,pendingSuspenseBoundaries:y.pendingSuspenseBoundaries,transitions:y.transitions},n.updateQueue.baseState=h,n.memoizedState=h,n.flags&256){d=ys(Error(r(423)),n),n=kd(e,n,c,o,d);break e}else if(c!==d){d=ys(Error(r(424)),n),n=kd(e,n,c,o,d);break e}else for(kt=hn(n.stateNode.containerInfo.firstChild),yt=n,Ae=!0,At=null,o=Iu(n,null,c,o),n.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling;else{if(hs(),c===d){n=en(e,n,o);break e}ot(e,n,c,o)}n=n.child}return n;case 5:return _u(n),e===null&&pa(n),c=n.type,d=n.pendingProps,h=e!==null?e.memoizedProps:null,y=d.children,oa(c,d)?y=null:h!==null&&oa(c,h)&&(n.flags|=32),gd(e,n),ot(e,n,y,o),n.child;case 6:return e===null&&pa(n),null;case 13:return xd(e,n,o);case 4:return Sa(n,n.stateNode.containerInfo),c=n.pendingProps,e===null?n.child=ms(n,null,c,o):ot(e,n,c,o),n.child;case 11:return c=n.type,d=n.pendingProps,d=n.elementType===c?d:Lt(c,d),fd(e,n,c,d,o);case 7:return ot(e,n,n.pendingProps,o),n.child;case 8:return ot(e,n,n.pendingProps.children,o),n.child;case 12:return ot(e,n,n.pendingProps.children,o),n.child;case 10:e:{if(c=n.type._context,d=n.pendingProps,h=n.memoizedProps,y=d.value,Ee(mr,c._currentValue),c._currentValue=y,h!==null)if(It(h.value,y)){if(h.children===d.children&&!ut.current){n=en(e,n,o);break e}}else for(h=n.child,h!==null&&(h.return=n);h!==null;){var j=h.dependencies;if(j!==null){y=h.child;for(var C=j.firstContext;C!==null;){if(C.context===c){if(h.tag===1){C=Zt(-1,o&-o),C.tag=2;var R=h.updateQueue;if(R!==null){R=R.shared;var z=R.pending;z===null?C.next=C:(C.next=z.next,z.next=C),R.pending=C}}h.lanes|=o,C=h.alternate,C!==null&&(C.lanes|=o),xa(h.return,o,n),j.lanes|=o;break}C=C.next}}else if(h.tag===10)y=h.type===n.type?null:h.child;else if(h.tag===18){if(y=h.return,y===null)throw Error(r(341));y.lanes|=o,j=y.alternate,j!==null&&(j.lanes|=o),xa(y,o,n),y=h.sibling}else y=h.child;if(y!==null)y.return=h;else for(y=h;y!==null;){if(y===n){y=null;break}if(h=y.sibling,h!==null){h.return=y.return,y=h;break}y=y.return}h=y}ot(e,n,d.children,o),n=n.child}return n;case 9:return d=n.type,c=n.pendingProps.children,gs(n,o),d=Nt(d),c=c(d),n.flags|=1,ot(e,n,c,o),n.child;case 14:return c=n.type,d=Lt(c,n.pendingProps),d=Lt(c.type,d),hd(e,n,c,d,o);case 15:return md(e,n,n.type,n.pendingProps,o);case 17:return c=n.type,d=n.pendingProps,d=n.elementType===c?d:Lt(c,d),$r(e,n),n.tag=1,dt(c)?(e=!0,lr(n)):e=!1,gs(n,o),rd(n,c,d),_a(n,c,d,o),Ba(null,n,c,!0,e,o);case 19:return jd(e,n,o);case 22:return pd(e,n,o)}throw Error(r(156,n.tag))};function Kd(e,n){return Cc(e,n)}function Gp(e,n,o,c){this.tag=e,this.key=o,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function bt(e,n,o,c){return new Gp(e,n,o,c)}function ol(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Yp(e){if(typeof e=="function")return ol(e)?1:0;if(e!=null){if(e=e.$$typeof,e===$e)return 11;if(e===se)return 14}return 2}function Nn(e,n){var o=e.alternate;return o===null?(o=bt(e.tag,n,e.key,e.mode),o.elementType=e.elementType,o.type=e.type,o.stateNode=e.stateNode,o.alternate=e,e.alternate=o):(o.pendingProps=n,o.type=e.type,o.flags=0,o.subtreeFlags=0,o.deletions=null),o.flags=e.flags&14680064,o.childLanes=e.childLanes,o.lanes=e.lanes,o.child=e.child,o.memoizedProps=e.memoizedProps,o.memoizedState=e.memoizedState,o.updateQueue=e.updateQueue,n=e.dependencies,o.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},o.sibling=e.sibling,o.index=e.index,o.ref=e.ref,o}function Pr(e,n,o,c,d,h){var y=2;if(c=e,typeof e=="function")ol(e)&&(y=1);else if(typeof e=="string")y=5;else e:switch(e){case ie:return Vn(o.children,d,h,n);case ae:y=8,d|=8;break;case K:return e=bt(12,o,n,d|2),e.elementType=K,e.lanes=h,e;case L:return e=bt(13,o,n,d),e.elementType=L,e.lanes=h,e;case Q:return e=bt(19,o,n,d),e.elementType=Q,e.lanes=h,e;case me:return Dr(o,d,h,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case xe:y=10;break e;case ze:y=9;break e;case $e:y=11;break e;case se:y=14;break e;case ue:y=16,c=null;break e}throw Error(r(130,e==null?e:typeof e,""))}return n=bt(y,o,n,d),n.elementType=e,n.type=c,n.lanes=h,n}function Vn(e,n,o,c){return e=bt(7,e,c,n),e.lanes=o,e}function Dr(e,n,o,c){return e=bt(22,e,c,n),e.elementType=me,e.lanes=o,e.stateNode={isHidden:!1},e}function al(e,n,o){return e=bt(6,e,null,n),e.lanes=o,e}function ll(e,n,o){return n=bt(4,e.children!==null?e.children:[],e.key,n),n.lanes=o,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function Jp(e,n,o,c,d){this.tag=n,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Oo(0),this.expirationTimes=Oo(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Oo(0),this.identifierPrefix=c,this.onRecoverableError=d,this.mutableSourceEagerHydrationData=null}function cl(e,n,o,c,d,h,y,j,C){return e=new Jp(e,n,o,j,C),n===1?(n=1,h===!0&&(n|=8)):n=0,h=bt(3,null,null,n),e.current=h,h.stateNode=e,h.memoizedState={element:c,isDehydrated:o,cache:null,transitions:null,pendingSuspenseBoundaries:null},ja(h),e}function Xp(e,n,o){var c=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:V,key:c==null?null:""+c,children:e,containerInfo:n,implementation:o}}function Qd(e){if(!e)return pn;e=e._reactInternals;e:{if(Ln(e)!==e||e.tag!==1)throw Error(r(170));var n=e;do{switch(n.tag){case 3:n=n.stateNode.context;break e;case 1:if(dt(n.type)){n=n.stateNode.__reactInternalMemoizedMergedChildContext;break e}}n=n.return}while(n!==null);throw Error(r(171))}if(e.tag===1){var o=e.type;if(dt(o))return wu(e,o,n)}return n}function qd(e,n,o,c,d,h,y,j,C){return e=cl(o,c,!0,e,d,h,y,j,C),e.context=Qd(null),o=e.current,c=at(),d=jn(o),h=Zt(c,d),h.callback=n??null,yn(o,h,d),e.current.lanes=d,Us(e,d,c),mt(e,c),e}function zr(e,n,o,c){var d=n.current,h=at(),y=jn(d);return o=Qd(o),n.context===null?n.context=o:n.pendingContext=o,n=Zt(h,y),n.payload={element:e},c=c===void 0?null:c,c!==null&&(n.callback=c),e=yn(d,n,y),e!==null&&(_t(e,d,y,h),gr(e,d,y)),y}function Br(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function Gd(e,n){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var o=e.retryLane;e.retryLane=o!==0&&o<n?o:n}}function ul(e,n){Gd(e,n),(e=e.alternate)&&Gd(e,n)}function Zp(){return null}var Yd=typeof reportError=="function"?reportError:function(e){console.error(e)};function dl(e){this._internalRoot=e}Fr.prototype.render=dl.prototype.render=function(e){var n=this._internalRoot;if(n===null)throw Error(r(409));zr(e,n,null,null)},Fr.prototype.unmount=dl.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var n=e.containerInfo;Un(function(){zr(null,e,null,null)}),n[qt]=null}};function Fr(e){this._internalRoot=e}Fr.prototype.unstable_scheduleHydration=function(e){if(e){var n=Lc();e={blockedOn:null,target:e,priority:n};for(var o=0;o<un.length&&n!==0&&n<un[o].priority;o++);un.splice(o,0,e),o===0&&_c(e)}};function fl(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Ur(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Jd(){}function eg(e,n,o,c,d){if(d){if(typeof c=="function"){var h=c;c=function(){var R=Br(y);h.call(R)}}var y=qd(n,c,e,0,null,!1,!1,"",Jd);return e._reactRootContainer=y,e[qt]=y.current,ni(e.nodeType===8?e.parentNode:e),Un(),y}for(;d=e.lastChild;)e.removeChild(d);if(typeof c=="function"){var j=c;c=function(){var R=Br(C);j.call(R)}}var C=cl(e,0,!1,null,null,!1,!1,"",Jd);return e._reactRootContainer=C,e[qt]=C.current,ni(e.nodeType===8?e.parentNode:e),Un(function(){zr(n,C,o,c)}),C}function Wr(e,n,o,c,d){var h=o._reactRootContainer;if(h){var y=h;if(typeof d=="function"){var j=d;d=function(){var C=Br(y);j.call(C)}}zr(n,y,e,d)}else y=eg(o,n,e,d,c);return Br(y)}Ic=function(e){switch(e.tag){case 3:var n=e.stateNode;if(n.current.memoizedState.isDehydrated){var o=Fs(n.pendingLanes);o!==0&&(_o(n,o|1),mt(n,Pe()),(je&6)===0&&(ws=Pe()+500,gn()))}break;case 13:Un(function(){var c=Xt(e,1);if(c!==null){var d=at();_t(c,e,1,d)}}),ul(e,1)}},Po=function(e){if(e.tag===13){var n=Xt(e,134217728);if(n!==null){var o=at();_t(n,e,134217728,o)}ul(e,134217728)}},Ac=function(e){if(e.tag===13){var n=jn(e),o=Xt(e,n);if(o!==null){var c=at();_t(o,e,n,c)}ul(e,n)}},Lc=function(){return Ne},Rc=function(e,n){var o=Ne;try{return Ne=e,n()}finally{Ne=o}},Eo=function(e,n,o){switch(n){case"input":if(wo(e,o),n=o.name,o.type==="radio"&&n!=null){for(o=e;o.parentNode;)o=o.parentNode;for(o=o.querySelectorAll("input[name="+JSON.stringify(""+n)+'][type="radio"]'),n=0;n<o.length;n++){var c=o[n];if(c!==e&&c.form===e.form){var d=or(c);if(!d)throw Error(r(90));ic(c),wo(c,d)}}}break;case"textarea":cc(e,o);break;case"select":n=o.value,n!=null&&Xn(e,!!o.multiple,n,!1)}},yc=sl,kc=Un;var tg={usingClientEntryPoint:!1,Events:[ri,ls,or,gc,vc,sl]},ki={findFiberByHostInstance:Rn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},ng={bundleType:ki.bundleType,version:ki.version,rendererPackageName:ki.rendererPackageName,rendererConfig:ki.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:ee.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Sc(e),e===null?null:e.stateNode},findFiberByHostInstance:ki.findFiberByHostInstance||Zp,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 Hr=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Hr.isDisabled&&Hr.supportsFiber)try{Fi=Hr.inject(ng),Dt=Hr}catch{}}return pt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=tg,pt.createPortal=function(e,n){var o=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!fl(n))throw Error(r(200));return Xp(e,n,null,o)},pt.createRoot=function(e,n){if(!fl(e))throw Error(r(299));var o=!1,c="",d=Yd;return n!=null&&(n.unstable_strictMode===!0&&(o=!0),n.identifierPrefix!==void 0&&(c=n.identifierPrefix),n.onRecoverableError!==void 0&&(d=n.onRecoverableError)),n=cl(e,1,!1,null,null,o,!1,c,d),e[qt]=n.current,ni(e.nodeType===8?e.parentNode:e),new dl(n)},pt.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var n=e._reactInternals;if(n===void 0)throw typeof e.render=="function"?Error(r(188)):(e=Object.keys(e).join(","),Error(r(268,e)));return e=Sc(n),e=e===null?null:e.stateNode,e},pt.flushSync=function(e){return Un(e)},pt.hydrate=function(e,n,o){if(!Ur(n))throw Error(r(200));return Wr(null,e,n,!0,o)},pt.hydrateRoot=function(e,n,o){if(!fl(e))throw Error(r(405));var c=o!=null&&o.hydratedSources||null,d=!1,h="",y=Yd;if(o!=null&&(o.unstable_strictMode===!0&&(d=!0),o.identifierPrefix!==void 0&&(h=o.identifierPrefix),o.onRecoverableError!==void 0&&(y=o.onRecoverableError)),n=qd(n,null,e,1,o??null,d,!1,h,y),e[qt]=n.current,ni(e),c)for(e=0;e<c.length;e++)o=c[e],d=o._getVersion,d=d(o._source),n.mutableSourceEagerHydrationData==null?n.mutableSourceEagerHydrationData=[o,d]:n.mutableSourceEagerHydrationData.push(o,d);return new Fr(n)},pt.render=function(e,n,o){if(!Ur(n))throw Error(r(200));return Wr(null,e,n,!1,o)},pt.unmountComponentAtNode=function(e){if(!Ur(e))throw Error(r(40));return e._reactRootContainer?(Un(function(){Wr(null,null,e,!1,function(){e._reactRootContainer=null,e[qt]=null})}),!0):!1},pt.unstable_batchedUpdates=sl,pt.unstable_renderSubtreeIntoContainer=function(e,n,o,c){if(!Ur(o))throw Error(r(200));if(e==null||e._reactInternals===void 0)throw Error(r(38));return Wr(e,n,o,!1,c)},pt.version="18.3.1-next-f1338f8080-20240426",pt}var of;function fg(){if(of)return pl.exports;of=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(s){console.error(s)}}return t(),pl.exports=dg(),pl.exports}var af;function hg(){if(af)return Vr;af=1;var t=fg();return Vr.createRoot=t.createRoot,Vr.hydrateRoot=t.hydrateRoot,Vr}var mg=hg(),x=Pl();const Ni="teamtrail",ne={slug:Ni,name:"Teamtrail",category:"The trail map for AI coding agents",tagline:"You pick the destination. Your agents walk the trail.",assistant:{name:"Scout"},labelPrefix:Ni,dataDir:`.${Ni}`,apiPrefix:`/__${Ni}`},Dl=`${Ni}.prefs`,uo=t=>`${ne.labelPrefix}:${t}`,zl=uo("map"),Bl=uo("hitl"),pg=t=>t==="task"||t==="execute",Fl=uo("plan-only"),Nl=["research","prototype","junction","task","execute"],Gn="plan+execute",gg=["verifying","rework","blocked"],Ul=["off","checks","checks+review","checks+review+human"],th=t=>Ul.find(s=>s===t);function Ii(t){return t.type==="junction"||t.type==="prototype"?"hitl":t.type==="research"?"afk":t.hitl?"hitl":"afk"}const vg=["task","execute"];function nh(t,s,r=Gn){return t.state==="closed"?t.closeReason==="not_planned"?"out-of-scope":"decided":t.status==="verifying"?"verifying":t.status==="blocked"?"held":t.assignee?"claimed":t.status==="rework"?"rework":r==="plan-only"&&t.type==="execute"?"parked":t.blockedBy.some(l=>{var u;return((u=s.get(l))==null?void 0:u.state)==="open"})?"blocked":"frontier"}function Is(t,s=Gn){const r=new Map(t.map(a=>[a.id,a]));return new Map(t.map(a=>[a.id,nh(a,r,s)]))}const Te=200,Ce=56;function lf(t,s="LR",r=Gn){var $e;const a=s==="LR"?330:124,l=s==="LR"?112:262,u=Is(t,r),f=new Map(t.map(L=>[L.id,L])),m=new Map,g=new Set,p=L=>{if(m.has(L))return m.get(L);if(g.has(L))return 0;g.add(L);const Q=f.get(L),se=Q&&Q.blockedBy.length?1+Math.max(...Q.blockedBy.filter(ue=>f.has(ue)).map(p),-1):0;return g.delete(L),m.set(L,se),se},k=t.filter(L=>u.get(L.id)!=="out-of-scope"),v=t.filter(L=>u.get(L.id)==="out-of-scope"),w=[];for(const L of k)(w[$e=p(L.id)]??(w[$e]=[])).push(L);const N=[],M=new Map;let S=0;w.forEach(L=>{L&&(L.sort((Q,se)=>{const ue=me=>{const B=me.blockedBy.map(F=>M.get(F)).filter(F=>F!==void 0);return B.length?B.reduce((F,W)=>F+W,0)/B.length:me.createdAt/1e12};return ue(Q)-ue(se)||Q.createdAt-se.createdAt}),S=Math.max(S,L.length),L.forEach((Q,se)=>M.set(Q.id,se)))}),w.forEach((L,Q)=>{if(!L)return;const se=(S-L.length)*l/2;L.forEach((ue,me)=>{const B=Q*a,F=se+me*l;N.push({ticket:ue,state:u.get(ue.id),layer:Q,x:s==="LR"?B:F,y:s==="LR"?F:B})})});const I=Math.max(w.length,1)*a-(a-(s==="LR"?Te:Ce)),_=Math.max(S,1)*l-(l-(s==="LR"?Ce:Te)),O=s==="LR"?I:_,ee=s==="LR"?_:I,q=ee+54,V=Math.max(1,Math.floor((O+24)/(Te+24)));v.forEach((L,Q)=>{N.push({ticket:L,state:"out-of-scope",layer:-1,x:Q%V*(Te+24),y:q+Math.floor(Q/V)*(Ce+16)})});const ie=[],ae=new Map(N.map(L=>[L.ticket.id,L]));for(const L of N)for(const Q of L.ticket.blockedBy){const se=ae.get(Q);se&&ie.push({from:se,to:L})}const K=Math.ceil(v.length/V),xe=Math.max(O,Math.min(v.length,V)*(Te+24)-24),ze=v.length?q+K*(Ce+16)-16:ee;return{direction:s,nodes:N,edges:ie,width:xe,graphH:ee,quarantineY:q,height:ze,quarantineH:K*(Ce+16)+24}}const yg=["holding","challenged","invalidated","confirmed"],kg=t=>yg.includes(t),sh=ne.labelPrefix,xg=new RegExp(`^-\\s+(?:\\[([a-z]+)\\]\\s+)?(.*?)\\s*(?:<!-- ${sh}:asm (\\{.*\\}) -->)?\\s*$`),wg=1e3,jg=t=>t.replace(/--/g,"-\\u002d"),Sg=t=>t.replace(/\s*\n\s*/g," ").trim();function Ng(t){const s={id:t.id,tickets:t.tickets,...t.source?{source:t.source}:{},...t.challenge?{challenge:{...t.challenge,evidence:t.challenge.evidence.slice(0,wg)}}:{},...t.decidedBy?{decidedBy:t.decidedBy}:{}};return`- [${t.status}] ${Sg(t.text)} <!-- ${sh}:asm ${jg(JSON.stringify(s))} -->`}function Cg(t){const s=t.map($g);let r=Math.max(0,...s.map(a=>Tg(a.id)))+1;return s.map(a=>a.id?a:{...a,id:`S-${r++}`})}function $g(t){const s=t.match(xg),r=s==null?void 0:s[1],a=(s==null?void 0:s[2])??t.replace(/^-\s+/,""),l=bg(s==null?void 0:s[3]);return{id:l.id??"",text:a,status:kg(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 bg(t){if(!t)return{};try{const s=JSON.parse(t);return s&&typeof s=="object"?s:{}}catch{return{}}}function Tg(t){const s=t==null?void 0:t.match(/^S-(\d+)$/);return s?Number(s[1]):0}const ih=[["destination","Destination"],["notes","Notes"],["assumptions","Assumptions"],["decisions","Decisions so far"],["unspecified","Not yet specified"],["outOfScope","Out of scope"]],Eg=Object.fromEntries(ih),Mg=/^-\s+(?:\[?([#A-Z0-9-]+)\]?:?\s+)?(.*)$/;function Ig(t){var a;const s=l=>l.length?l.map(u=>`- ${u}`).join(`
41
+ `):"_None yet._",r=l=>l.length?l.map(u=>`- ${u.ticketKey?`${u.ticketKey}: `:""}${u.text}`).join(`
42
+ `):"_None yet._";return[`## Destination
43
+
44
+ ${t.destination.trim()}`,`## Notes
45
+
46
+ ${t.notes.trim()||"_None yet._"}`,...(a=t.assumptions)!=null&&a.length?[`## Assumptions
47
+
48
+ ${t.assumptions.map(Ng).join(`
49
+ `)}`]:[],`## Decisions so far
50
+
51
+ ${r(t.decisions)}`,`## Not yet specified
52
+
53
+ ${s(t.unspecified)}`,`## Out of scope
54
+
55
+ ${s(t.outOfScope)}`].join(`
56
+
57
+ `)+`
58
+ `}function Ag(t){var a;const s={destination:"",notes:"",decisions:[],unspecified:[],outOfScope:[]},r=t.split(/^##\s+/m).slice(1);for(const l of r){const u=l.indexOf(`
59
+ `),f=l.slice(0,u===-1?void 0:u).trim().toLowerCase(),m=(u===-1?"":l.slice(u+1)).trim(),g=(a=ih.find(([,v])=>v.toLowerCase()===f))==null?void 0:a[0];if(!g)continue;const p=/^_none yet\._$/i.test(m),k=p?[]:m.split(`
60
+ `).map(v=>v.trim()).filter(v=>v.startsWith("- "));g==="destination"?s.destination=m:g==="notes"?s.notes=p?"":m:g==="assumptions"?s.assumptions=Cg(k):g==="decisions"?s.decisions=k.map(v=>{const w=v.match(Mg);return w&&w[1]&&/\d/.test(w[1])?{ticketKey:w[1],text:w[2]}:{text:v.slice(2)}}):s[g]=k.map(v=>v.slice(2))}return s}const fo={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"]},Lg=(t,s)=>`${t[0].toUpperCase()}${t.slice(1)} ${s}/${fo[t].length}`;async function Rg(t,s,r={}){var f,m,g;const a=Og(s,s.mode??Gn),l=await t.createMap({title:a.title,mode:a.mode,sections:a.sections,...a.verification?{verification:a.verification}:{}});await((f=r.onMapCreated)==null?void 0:f.call(r,l));const u=new Map;for(const p of a.tickets){const k=await t.createTicket(l.id,{title:p.title,type:p.type,hitl:p.hitl,body:`${p.body}
61
+
62
+ Part of trail ${l.key}.`});u.set(p.ref,k),await((m=r.onTicketCreated)==null?void 0:m.call(r,k,p.ref))}for(const p of a.tickets)for(const k of p.blockedBy??[]){const v=u.get(k),w=u.get(p.ref);v&&(await t.addBlocking(l.id,v.id,w.id),await((g=r.onEdgeWired)==null?void 0:g.call(r,v,w)))}return{map:l,tickets:[...u.values()]}}function Og(t,s){if(s==="plan+execute")return{...t,mode:s};const r=new Map(t.tickets.filter(l=>l.type==="execute").map(l=>[l.ref,l.blockedBy??[]])),a=l=>l.flatMap(u=>r.has(u)?a(r.get(u)):[u]);return{...t,mode:s,tickets:t.tickets.filter(l=>!r.has(l.ref)).map(l=>({...l,blockedBy:[...new Set(a(l.blockedBy??[]))]}))}}class _g{constructor(){le(this,"tails",new Map)}run(s,r){const l=(this.tails.get(s)??Promise.resolve()).catch(()=>{}).then(r);return this.tails.set(s,l),l.finally(()=>this.tails.get(s)===l&&this.tails.delete(s)).catch(()=>{}),l}}class We extends Error{}const Pg={frontier:"ready",blocked:"backlog",parked:"backlog",claimed:"working",verifying:"verifying",rework:"rework",held:"blocked",decided:"done","out-of-scope":"cancelled"};function Dg(t,s,r=Gn){return Pg[nh(t,s,r)]}const zg=["backlog","ready","working","verifying","rework","blocked"],wi=["agent","trail lead"],Bg=[{event:"claim",from:["ready","rework"],to:["working"],actors:wi},{event:"release",from:["working"],to:["ready","rework"],actors:wi},{event:"expire",from:["working"],to:["ready","rework"],actors:["engine","trail lead"]},{event:"complete",from:["backlog","ready","working","rework"],to:["done"],actors:wi},{event:"submit",from:["working"],to:["verifying"],actors:wi},{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:zg,to:["cancelled"],actors:[...wi,"engine"]},{event:"reopen",from:["done","cancelled"],to:["ready"],actors:["trail lead"]}],Fg=t=>Bg.find(s=>s.event===t),Ug=new _g;function Wg(t,s,r){if(r){if(!t.to.includes(r))throw new We(`${t.event} cannot lead to ${r}`);return r}if(t.to.length===1)return t.to[0];if(t.event==="release"||t.event==="expire")return s.status==="rework"?"rework":"ready";throw new We(`${t.event} needs a target: ${t.to.join(" or ")}`)}async function Hg(t,s,r,a){const{to:l,actor:u}=a,f=async m=>{(r.status??null)!==m&&await t.setMeta(s,r.id,{status:m})};switch(l){case"working":r.assignee!==u&&await t.assign(s,r.id,u);return;case"ready":case"rework":r.state==="closed"&&await t.reopen(s,r.id),await f(l==="rework"?"rework":null),r.assignee&&await t.assign(s,r.id,null);return;case"verifying":case"blocked":await f(l);return;case"done":case"cancelled":await f(null),await t.close(s,r.id,l==="done"?"completed":"not_planned");return;case"backlog":throw new We("backlog follows from blockers; no transition leads there")}}function ho(t,s,r,a){return Ug.run(`${s}/${r}`,async()=>{var p;const l=await t.loadMap(s),u=l.tickets.find(k=>k.id===r);if(!u)throw new We(`ticket ${r} not found`);const f=Dg(u,new Map(l.tickets.map(k=>[k.id,k])),l.map.mode);if(a.expect&&f!==a.expect)throw new We(`${u.key} changed: it is ${f} now`);const m=Fg(a.event);if(!m.from.includes(f))throw new We(`${u.key} is ${f}; ${a.event} needs ${m.from.join(" or ")}`);if(!m.actors.includes(a.actorKind))throw new We(`${a.event} is not for ${a.actorKind}s`);const g=Wg(m,u,a.to);await Hg(t,s,u,{to:g,actor:a.actor});try{await((p=a.journal)==null?void 0:p.append({v:1,kind:"transition",at:Date.now(),mapId:s,ticketId:r,ticketKey:u.key,event:a.event,from:f,to:g,actor:a.actor,actorKind:a.actorKind,...a.reason?{reason:a.reason}:{},...a.sessionId?{sessionId:a.sessionId}:{}}))}catch{}return{ticket:u,from:f,to:g}})}async function cf(t,s,r,a){const{assignee:l}=a,u=await t.loadMap(s),f=u.tickets.find(k=>k.id===r);if(!f)throw new We(`ticket ${r} not found`);const m=Is(u.tickets,u.map.mode).get(r);if(m!=="frontier"&&m!=="rework")throw new We(`${f.key} is ${m}, not on the frontier`);await ho(t,s,r,{event:"claim",actor:l,actorKind:a.actorKind??"agent",reason:a.reason,sessionId:a.sessionId,journal:a.journal});const p=(await t.loadMap(s)).tickets.find(k=>k.id===r);if(p.assignee!==l)throw new We(`${f.key} was claimed by ${p.assignee}`);return p}async function Vg(t,s,r,a={}){const u=(await t.loadMap(s)).tickets.find(f=>f.id===r);if(!u)throw new We(`ticket ${r} not found`);await ho(t,s,r,{event:"release",actor:a.actor??u.assignee??"trail lead",actorKind:a.actorKind??"agent",reason:a.reason,sessionId:a.sessionId,journal:a.journal})}async function Wl(t,s,r,a={}){if(r.source.ref){const u=(await t.listDecisions(s)).find(f=>f.source.kind===r.source.kind&&f.source.ref===r.source.ref);if(u)return u}const l=await t.createDecision(s,r);if(a.appendToTrail??!0){const u=await t.loadMap(s);await t.updateMapSections(s,{decisions:[...u.map.sections.decisions,{ticketId:l.ticketId,ticketKey:l.ticketKey,text:a.trailLine??l.summary}]})}return l}async function Kg(t,s,r,a){const u=(await t.listDecisions(s)).find(v=>v.id===r);if(!u)throw new We(`decision ${r} not found`);if(u.supersededBy)throw new We(`${u.id} is already superseded by ${u.supersededBy}`);const f=await t.createDecision(s,{ticketId:u.ticketId,ticketKey:u.ticketKey,...a,question:a.question??u.question,supersedes:u.id});await t.markSuperseded(s,u.id,f.id);const g=(await t.loadMap(s)).map.sections.decisions,p=g.findIndex(v=>v.text===u.summary||!!u.ticketId&&v.ticketId===u.ticketId||!!u.ticketKey&&v.ticketKey===u.ticketKey),k={ticketId:f.ticketId,ticketKey:f.ticketKey,text:f.summary};return await t.updateMapSections(s,{decisions:p<0?[...g,k]:g.map((v,w)=>w===p?k:v)}),f}async function Qg(t,s,r){await t.setMapMode(s,r)}function rh(t){return t==="plan-only"?Nl.filter(s=>s!=="execute"):Nl}function qg(t,s){if(!rh(t).includes(s))throw new We(`${s} tickets are disabled on plan-only maps`)}const Tn={lookout:{label:"Lookout",code:"CMD"},agent:{label:"Agent",code:"AGT"},slack:{label:"Slack",code:"SLK"},tracker:{label:"Tracker",code:"TRK"}},no=Object.keys(Tn),Gg=t=>t in Tn,Ti=t=>t.source.kind==="agent"&&t.decidedBy!=="trail lead"&&!t.decidedBy.startsWith("slack:")?"agent":"human",Ai=t=>t.supersededBy?"superseded":"active";function mo(t){const s=t.replace(/\s+/g," ").trim(),r=s.match(/^(.{20,180}?[.!?])(\s|$)/);return r?r[1]:s.slice(0,180)}function Yg(t,s,r){var a;return{...r,id:t,mapId:s,decidedAt:r.decidedAt??Date.now(),summary:((a=r.summary)==null?void 0:a.trim())||mo(r.answer),alternatives:r.alternatives??[],rationale:r.rationale??"",participants:r.participants??[{id:r.decidedBy}],transcript:r.transcript??[]}}const Jg=t=>Number(t.replace(/\D/g,""))||0;function Xg(t,s){const r=new Map(t.map(f=>[f.id,f])),a=new Set;let l=r.get(s);for(;l!=null&&l.supersedes&&r.has(l.supersedes)&&!a.has(l.id);)a.add(l.id),l=r.get(l.supersedes);const u=[];a.clear();for(let f=l;f&&!a.has(f.id);f=f.supersededBy?r.get(f.supersededBy):void 0)a.add(f.id),u.push(f);return u}async function Zg(t,s,r,a){var m;const u=(await t.loadMap(s)).tickets.find(g=>g.id===r);if(!u)throw new We(`ticket ${r} not found`);if(u.state==="closed")throw new We(`${u.key} is already closed`);a.transcript&&await t.comment(s,r,a.author,`**HITL transcript**
63
+
64
+ ${a.transcript}`),await t.comment(s,r,a.author,`**Resolution**
65
+
66
+ ${a.answer}`),await ho(t,s,r,{event:a.event??"complete",actor:a.actor??a.author,actorKind:a.actorKind??"agent",sessionId:a.sessionId,reason:a.reason,journal:a.journal,...a.event&&a.event!=="complete"?{to:"done"}:{}});const f=a.decision??{};return await Wl(t,s,{ticketId:u.id,ticketKey:u.key,question:f.question??u.title,answer:a.answer,summary:a.summary??mo(a.answer),alternatives:f.alternatives,rationale:f.rationale,decidedBy:f.decidedBy??a.author,participants:f.participants,source:f.source??{kind:"agent",label:a.author},transcript:f.transcript,...f.risk?{risk:f.risk}:{},...(m=f.assumes)!=null&&m.length?{assumes:f.assumes}:{}},{trailLine:a.trailLine}),u}async function ev(t,s,r,a){const l=await t.loadMap(s);if(!l.map.sections.unspecified.includes(r))throw new We(`"${r}" is not in Not yet specified`);qg(l.map.mode,a.type);const u=await t.createTicket(s,{title:a.title??r,type:a.type,hitl:a.hitl,body:`${a.body??`Promoted from Not yet specified: ${r}`}
67
+
68
+ Part of trail ${l.map.key}.`});for(const m of a.blockedBy??[])await t.addBlocking(s,m,u.id);const f=await t.loadMap(s);return await t.updateMapSections(s,{unspecified:f.map.sections.unspecified.filter(m=>m!==r)}),u}async function tv(t,s,r,a){const l=await t.loadMap(s),{unspecified:u,outOfScope:f}=l.map.sections;if("unspecified"in r){if(!u.includes(r.unspecified))throw new We(`"${r.unspecified}" is not in Not yet specified`);await t.updateMapSections(s,{unspecified:u.filter(p=>p!==r.unspecified),outOfScope:[...f,`${r.unspecified} — ${a.reason}`]});return}const m=l.tickets.find(p=>p.id===r.ticketId);if(!m)throw new We(`ticket ${r.ticketId} not found`);await t.comment(s,m.id,a.author,`**Ruled out of scope**
69
+
70
+ ${a.reason}`),await ho(t,s,m.id,{event:"cancel",actor:a.author,actorKind:a.actorKind??"agent",reason:a.reason,sessionId:a.sessionId,journal:a.journal}),await Wl(t,s,{ticketId:m.id,ticketKey:m.key,question:m.title,answer:`Out of scope: ${a.reason}`,decidedBy:a.author,source:a.source??{kind:"agent",label:a.author}},{appendToTrail:!1});const g=await t.loadMap(s);await t.updateMapSections(s,{outOfScope:[...g.map.sections.outOfScope,`${m.key} ${m.title} — ${a.reason}`]})}function nv(t){return{async append(s){await fetch(`${t}/journal`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})}}}const oh={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(oh));const sv=2*6e4,yl=t=>t<6e4?`${Math.round(t/1e3)}s`:`${Math.round(t/6e4)}m`;function iv(t,s){if(!t)return{tone:"unknown",label:"PR sync ?",title:"PR/CI sync state unavailable"};const r=t.repo?` · ${t.repo}`:"",a=t.lastOkAt?`last ok ${yl(s-t.lastOkAt)} ago`:"never synced";return t.state==="off"?{tone:"off",label:"PR sync off",title:`PR/CI sync off: ${t.reason??"disabled"}`}:t.state==="failed"?{tone:"failed",label:"PR sync failed",title:`${t.reason??"sync failed"}${r}
71
+ ${a}`}:t.state==="rate-limited"?{tone:"failed",label:"PR sync paused",title:`Rate limited${r}; retrying ${t.nextAt?`in ${yl(Math.max(0,t.nextAt-s))}`:"later"}
72
+ ${a}`}:!t.lastOkAt||t.lastOkAt!==t.lastAttemptAt||t.nextAt!==void 0&&s>t.nextAt+sv?{tone:"stale",label:"PR sync stale",title:`No recent sync${r}
73
+ ${a}`}:{tone:"ok",label:`PR sync ${yl(s-t.lastOkAt)}`,title:`PR/CI synced${r}, ${a}`}}class bs{constructor(){le(this,"listeners",new Set)}on(s){return this.listeners.add(s),()=>this.listeners.delete(s)}emit(s){for(const r of[...this.listeners])r(s)}}let rv=0;const eo=(t="id")=>`${t}_${Date.now().toString(36)}${(rv++).toString(36)}`,Cl=(t,s)=>({inputTokens:((t==null?void 0:t.inputTokens)??0)+s.inputTokens,outputTokens:((t==null?void 0:t.outputTokens)??0)+s.outputTokens,costUsd:((t==null?void 0:t.costUsd)??0)+s.costUsd,...t!=null&&t.cachedInputTokens||s.cachedInputTokens?{cachedInputTokens:((t==null?void 0:t.cachedInputTokens)??0)+(s.cachedInputTokens??0)}:{}}),ah=(t,s)=>({inputTokens:t.inputTokens-((s==null?void 0:s.inputTokens)??0),outputTokens:t.outputTokens-((s==null?void 0:s.outputTokens)??0),costUsd:t.costUsd-((s==null?void 0:s.costUsd)??0),...t.cachedInputTokens||s!=null&&s.cachedInputTokens?{cachedInputTokens:(t.cachedInputTokens??0)-((s==null?void 0:s.cachedInputTokens)??0)}:{}});function ov(t,s,r){const a=()=>t.find(s.id)??s,l=u=>t.push({source:"session",sessionId:s.id,agent:s.agent,...u});return{id:s.id,get info(){return a()},step(u,f,m){const g=fo[r][u-1];t.patchSession(s.id,{step:u,stepLabel:g,...m?{ticketId:m}:{}}),l({tag:Lg(r,u),level:"step",text:f?`${g}: ${f}`:g,ticketId:m??a().ticketId})},log(u,f="info"){l({level:f,text:u,ticketId:a().ticketId})},say(u){t.chat({sessionId:s.id,ticketId:a().ticketId,from:"agent",author:s.agent,text:u})},ask(u,f,m){var p;const g={id:eo("q"),sessionId:s.id,mapId:s.mapId,ticketId:a().ticketId,agent:s.agent,text:u,suggestions:f,at:Date.now(),...m!=null&&m.urgency?{urgency:m.urgency}:{},...(p=m==null?void 0:m.blocks)!=null&&p.length?{blocks:m.blocks}:{}};return t.chat({sessionId:s.id,ticketId:g.ticketId,from:"agent",author:s.agent,text:u,questionId:g.id}),t.addPending(g),t.patchSession(s.id,{waitingOn:g.id}),l({level:"alert",ticketId:g.ticketId,text:"Decision request · waiting on you",signal:!0}),t.awaitAnswer(g.id)},done(u=!0,f,m){t.patchSession(s.id,{status:u?"done":"failed",endedAt:Date.now(),waitingOn:void 0}),t.dropPending(s.id),l({level:u?"ok":"alert",text:f??(u?"Session closed":"Session aborted"),signal:m==null?void 0:m.signal})},bindMap(u){var m;const f=a().usage;f&&(t.addMapUsage(u,f),(m=t.ledger())==null||m.add(u,f,s.id)),t.patchSession(s.id,{mapId:u})},usage(u){var g;const f=a().mapId;(g=t.ledger())==null||g.add(f,u,s.id),t.addMapUsage(f,u);const m=a().usage;t.patchSession(s.id,{usage:{...Cl(m,u),source:u.source??(m==null?void 0:m.source)}})},setUsage(u){var k;const f=a().usage,m=ah(u,f);if(!m.inputTokens&&!m.outputTokens&&!m.costUsd&&!m.cachedInputTokens&&(f==null?void 0:f.source)===u.source&&`${f==null?void 0:f.models}`==`${u.models}`)return;const p=a().mapId;(m.inputTokens>0||m.outputTokens>0||m.costUsd>0)&&((k=t.ledger())==null||k.add(p,m,s.id)),t.addMapUsage(p,m),t.patchSession(s.id,{usage:u})}}}class av{constructor(s=400,r){le(this,"state",{sessions:[],feed:[],chats:[],pending:[],answered:[],usageByMap:{}});le(this,"changes",new bs);le(this,"resolvers",new Map);le(this,"remote",new Map);le(this,"remoteAnswer");le(this,"host",{find:s=>this.state.sessions.find(r=>r.id===s),patchSession:(s,r)=>this.patchSession(s,r),push:s=>void this.push(s),chat:s=>this.chat(s),addPending:s=>this.set({pending:[...this.state.pending,s]}),dropPending:s=>{this.state.pending.filter(a=>a.sessionId===s).length&&this.set({pending:this.state.pending.filter(a=>a.sessionId!==s)})},awaitAnswer:s=>new Promise(r=>this.resolvers.set(s,r)),addMapUsage:(s,r)=>{this.state={...this.state,usageByMap:{...this.state.usageByMap,[s]:Cl(this.state.usageByMap[s],r)}}},ledger:()=>this.ledger});this.maxFeed=s,this.ledger=r}get snapshot(){return this.state}subscribe(s){return this.changes.on(s)}set(s){this.state={...this.state,...s},this.changes.emit(this.state)}push(s){const r={id:eo("f"),at:s.at??Date.now(),...s};return r.source==="system"&&!r.agent&&(r.agent=ne.assistant.name),this.set({feed:[...this.state.feed,r].slice(-this.maxFeed)}),r}patchSession(s,r){this.set({sessions:this.state.sessions.map(a=>a.id===s?{...a,...r}:a)})}chat(s){this.set({chats:[...this.state.chats,{id:eo("m"),at:Date.now(),...s}].slice(-600)})}answer(s,r,a){const l=this.state.pending.find(m=>m.id===s),u=this.resolvers.get(s),f=!!l&&this.remote.has(l.sessionId)&&!!this.remoteAnswer;return!l||!u&&!f?!1:(this.resolvers.delete(s),this.chat({sessionId:l.sessionId,ticketId:l.ticketId,from:"human",author:a,text:r}),this.set({pending:this.state.pending.filter(m=>m.id!==s),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:a,level:"ok",ticketId:l.ticketId,sessionId:l.sessionId,text:`Answered ${l.agent}`}),u?u(r):this.remoteAnswer(l,r,a),!0)}syncRemote(s){var p;const{session:r}=s,a=r.id;if(!this.remote.has(a)&&this.state.sessions.some(k=>k.id===a))return;const l=this.remote.get(a);this.remote.set(a,r.mapId?r.usage:l);let u=this.state.usageByMap;if(r.usage&&r.mapId){const k=ah(r.usage,l);(k.inputTokens||k.outputTokens||k.costUsd)&&(u={...u,[r.mapId]:Cl(u[r.mapId],k)}),(p=this.ledger)==null||p.addTotal(r.mapId,a,r.usage)}const f=k=>k.filter(v=>v.sessionId!==a),m=new Set(this.state.answered.map(k=>k.id)),g=this.state.sessions.some(k=>k.id===a)?this.state.sessions.map(k=>k.id===a?r:k):[...this.state.sessions,r].slice(-24);this.set({sessions:g,chats:[...f(this.state.chats),...s.chats].sort((k,v)=>k.at-v.at).slice(-600),pending:[...f(this.state.pending),...s.pending],answered:[...this.state.answered,...s.answered.filter(k=>!m.has(k.id))].sort((k,v)=>k.answeredAt-v.answeredAt).slice(-200),feed:[...this.state.feed.filter(k=>k.sessionId!==a),...s.feed].sort((k,v)=>k.at-v.at).slice(-this.maxFeed),usageByMap:u})}isRemote(s){return this.remote.has(s)}startSession(s){const r={...s,id:s.id??eo("s"),step:0,total:fo[s.mode].length,stepLabel:"BOOT",status:"running",startedAt:Date.now()};this.set({sessions:[...this.state.sessions,r].slice(-24)});const a=ov(this.host,r,s.mode);return this.push({source:"session",sessionId:r.id,agent:r.agent,level:"info",text:`Session opened · ${s.mode}`}),a}}function lv(t,s){const r=a=>{var l;return((l=s(a))==null?void 0:l.key)??a};switch(t.kind){case"map.created":return{source:"tracker",level:"ok",text:`Trail created · label ${zl}`};case"map.updated":return{source:"tracker",level:"info",text:`Trail updated${t.section?` · ${Eg[t.section].toLowerCase()}`:""}`};case"map.mode":return{source:"tracker",level:"warn",text:`Trail mode · ${t.mode}`};case"ticket.created":return{source:"tracker",level:"info",ticketId:t.ticketId,text:`Opened ${r(t.ticketId)}`};case"ticket.claimed":return{source:"tracker",level:"warn",ticketId:t.ticketId,text:`Assigned ${r(t.ticketId)} to ${t.assignee}`};case"ticket.released":return{source:"tracker",level:"info",ticketId:t.ticketId,text:`Unassigned ${r(t.ticketId)}`};case"ticket.closed":return{source:"tracker",level:t.reason==="completed"?"ok":"alert",ticketId:t.ticketId,text:`Closed ${r(t.ticketId)} · ${t.reason==="completed"?"completed":"not planned"}`};case"ticket.commented":return{source:"tracker",level:"info",ticketId:t.ticketId,text:`Comment on ${r(t.ticketId)}`};case"edge.added":return{source:"tracker",level:"info",ticketId:t.blockedId,text:`${r(t.blockerId)} blocks ${r(t.blockedId)}`};case"edge.removed":return{source:"tracker",level:"info",ticketId:t.blockedId,text:`${r(t.blockerId)} no longer blocks ${r(t.blockedId)}`};case"decision.recorded":return{source:"tracker",level:"ok",ticketId:t.ticketId,text:`Decision ${t.decisionId} recorded${t.ticketId?` · ${r(t.ticketId)}`:""}`};case"decision.superseded":return{source:"tracker",level:"warn",text:`Decision ${t.decisionId} superseded by ${t.supersededBy}`};case"external.changed":return{source:"tracker",level:"warn",text:"External change detected · resynced"};default:return null}}const cv=new Set(["createMap","setMapMode","setMapMeta","updateMapSections","createTicket","addBlocking","removeBlocking","editTicket","reopen","assign","comment","close","setMeta","createDecision","markSuperseded"]),uv=5*6e4;function dv(t){let s={status:"idle",inflight:0,writes:0,errors:0,events:[]};const r=new bs,a=u=>{s={...s,...u},r.emit(s)};return t.subscribe(u=>{const f=u.at-uv;a({events:[...s.events.filter(m=>m.at>=f),{at:u.at,external:u.kind==="external.changed"||"external"in u&&!!u.external}]})}),{adapter:new Proxy(t,{get(u,f,m){const g=Reflect.get(u,f,m);return typeof g!="function"?g:cv.has(f)?async(...p)=>{const k=Date.now();a({inflight:s.inflight+1,status:"syncing"});try{const v=await g.apply(u,p),w=s.inflight-1;return a({inflight:w,writes:s.writes+1,lastWriteMs:Date.now()-k,lastWriteAt:Date.now(),status:w?"syncing":"ok",lastError:void 0}),v}catch(v){const w=s.inflight-1;throw a({inflight:w,errors:s.errors+1,status:"error",lastError:String(v.message??v)}),v}}:g.bind(u)}}),get health(){return s},subscribe:u=>r.on(u)}}function lh(t){const s={decided:0,claimed:0,frontier:0,blocked:0,parked:0,"out-of-scope":0,verifying:0,rework:0,held:0,total:t.tickets.length,resolvedPct:0};for(const r of Is(t.tickets,t.map.mode).values())s[r]++;return s.resolvedPct=s.total?Math.round((s.decided+s["out-of-scope"])/s.total*100):0,s}function ch(t){const s=lh(t);return{decided:s.decided,total:s.total-s["out-of-scope"]}}function fv(t){return Nl.map(s=>{const r=t.tickets.filter(a=>a.type===s);return{type:s,open:r.filter(a=>a.state==="open").length,closed:r.filter(a=>a.state==="closed").length}}).filter(s=>s.open+s.closed>0)}function hv(t,s){const r=t.pending.filter(l=>!0),a=t.answered.filter(l=>!0);return{open:r.length,oldestAt:r.length?Math.min(...r.map(l=>l.at)):void 0,answered:a.length,avgWaitMs:a.length?a.reduce((l,u)=>l+(u.answeredAt-u.askedAt),0)/a.length:void 0}}function uh(t,s){return s&&t.usageByMap[s]||{inputTokens:0,outputTokens:0,costUsd:0}}const mv=t=>t.usage?t.usage.inputTokens+t.usage.outputTokens:0,dh={"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 fh(t,s){var a;const r=new Set;for(const l of t.sessions)s&&l.mapId===s&&((a=l.usage)!=null&&a.source)&&r.add(l.usage.source);return[...r].sort()}function pv(t,s){const r=new Set(s.map(l=>l.ticketId).filter(Boolean)),a=t.tickets.filter(l=>l.state==="closed"&&l.closeReason==="completed"&&!r.has(l.id)).map(l=>{var k;const u=[...l.comments].reverse().find(v=>v.body.startsWith("**Resolution**")),f=u?u.body.replace(/^\*\*Resolution\*\*\s*/,""):((k=t.map.sections.decisions.find(v=>v.ticketId===l.id||v.ticketKey===l.key))==null?void 0:k.text)??"",m=(u==null?void 0:u.author)??l.assignee??"unknown",g=l.comments.find(v=>v.body.startsWith("**HITL transcript**")),p=g?g.body.replace(/^\*\*HITL transcript\*\*\s*/,"").split(/\n\n(?=\*\*[^*]+:\*\* )/).map(v=>v.match(/^\*\*([^*]+):\*\* ([\s\S]*)$/)).filter(v=>!!v).map(v=>({from:v[1]===m?"agent":"human",author:v[1],text:v[2].trim(),at:g.createdAt})):[];return{id:`T${l.key}`,mapId:t.map.id,ticketId:l.id,ticketKey:l.key,question:l.title,answer:f,summary:mo(f),alternatives:[],rationale:"",decidedBy:m,decidedAt:l.closedAt??(u==null?void 0:u.createdAt)??l.updatedAt,participants:[...new Set([m,...p.map(v=>v.author)])].map(v=>({id:v})),source:{kind:"tracker",ref:`${t.map.id}/tickets/${l.id}`,label:`${l.key} resolution comment`},transcript:p,derived:!0}});return[...s,...a].sort((l,u)=>u.decidedAt-l.decidedAt)}function gv(t,s){var a;const r=(a=s.query)==null?void 0:a.trim().toLowerCase();return t.filter(l=>(!s.mapId||l.mapId===s.mapId)&&(!s.source||l.source.kind===s.source)&&(!s.decidedBy||l.decidedBy===s.decidedBy)&&(!s.madeBy||Ti(l)===s.madeBy)&&(!s.status||Ai(l)===s.status)&&(!r||[l.id,l.ticketKey,l.question,l.answer,l.summary,l.rationale,l.decidedBy,...l.alternatives,...l.transcript.map(u=>u.text)].join(`
74
+ `).toLowerCase().includes(r)))}function vv(t,s=Date.now()){const r=Object.fromEntries(no.map(f=>[f,0]));let a=0,l=0,u=0;for(const f of t)r[f.source.kind]++,f.supersededBy&&a++,s-f.decidedAt<864e5&&l++,(Ti(f)==="human"||f.transcript.some(m=>m.from==="human"))&&u++;return{total:t.length,active:t.length-a,superseded:a,last24h:l,human:u,bySource:r}}function po(t){const s=t.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);if(!s)return{front:{},body:t};const r={};for(const a of s[1].split(`
75
+ `)){const l=a.indexOf(":");if(l<0)continue;const u=a.slice(0,l).trim(),f=a.slice(l+1).trim();r[u]=f.startsWith("[")?kv(f.slice(1,-1)).map(df).filter(Boolean):df(f)}return{front:r,body:s[2]}}const yv=t=>t===""||/^[\s#&*!|>'"%@`[\]{},?:-]|[:#]\s|\s$|,/.test(t)||/^(true|false|null|~|\d[\d.e+-]*)$/i.test(t),uf=t=>yv(t)?JSON.stringify(t):t;function df(t){if(t.startsWith('"'))try{return JSON.parse(t)}catch{return t.slice(1,-1)}return t.startsWith("'")?t.slice(1,-1).replace(/''/g,"'"):t}function kv(t){const s=[];let r="",a=!1;for(const l of t)l==='"'&&(a=!a),l===","&&!a?(s.push(r.trim()),r=""):r+=l;return r.trim()&&s.push(r.trim()),s}function Hl(t,s){return`---
76
+ ${Object.entries(t).map(([a,l])=>`${a}: ${Array.isArray(l)?`[${l.map(uf).join(", ")}]`:uf(l)}`).join(`
77
+ `)}
78
+ ---
79
+
80
+ ${s.trim()}
81
+ `}const we=t=>Array.isArray(t)?t.join(","):t??"";function bn(t){return Array.isArray(t)?t:t?[t]:[]}const Cs=t=>Date.parse(we(t))||0,Ht=t=>new Date(t).toISOString(),hh=["schema","breaking-api","auth-permissions","billing","data-deletion","product-behaviour","dependencies"],mh=["low","medium","high"],xv=t=>hh.includes(t),wv=t=>mh.includes(t);function jv(t){return t?{risk:t.level,...t.category?{risk_category:t.category}:{},risk_reason:t.reason}:{}}function Sv(t){const s=we(t.risk);if(!wv(s))return{};const r=we(t.risk_category);return{risk:{level:s,...xv(r)?{category:r}:{},reason:we(t.risk_reason)}}}const Nv=["Question","Decision","Summary","Alternatives","Rationale","Transcript"],Cv=t=>t.name?`${t.id}|${t.name}`:t.id,$v=t=>{const s=t.indexOf("|");return s<0?{id:t}:{id:t.slice(0,s),name:t.slice(s+1)}};function ff(t){var u;const s={id:t.id,trail:t.mapId,...t.ticketId?{ticket:t.ticketId,ticket_key:t.ticketKey??""}:{},decided_by:t.decidedBy,decided_at:Ht(t.decidedAt),participants:t.participants.map(Cv),source:t.source.kind,...t.source.ref?{source_ref:t.source.ref}:{},...t.source.url?{source_url:t.source.url}:{},...t.source.label?{source_label:t.source.label}:{},...t.source.meta?{source_meta:Object.entries(t.source.meta).map(([f,m])=>`${f}=${m}`)}:{},...t.supersedes?{supersedes:t.supersedes}:{},...t.supersededBy?{superseded_by:t.supersededBy}:{},...jv(t.risk),...(u=t.assumes)!=null&&u.length?{assumes:t.assumes}:{}},r=f=>f.length?f.map(m=>`- ${m}`).join(`
82
+ `):"_None._",a=t.transcript.length?t.transcript.map(f=>`### ${f.author} · ${f.from} @ ${Ht(f.at)}
83
+
84
+ ${f.text.trim()}`).join(`
85
+
86
+ `):"_None._",l=[`## Question
87
+
88
+ ${t.question.trim()}`,`## Decision
89
+
90
+ ${t.answer.trim()}`,`## Summary
91
+
92
+ ${t.summary.trim()}`,`## Alternatives
93
+
94
+ ${r(t.alternatives)}`,`## Rationale
95
+
96
+ ${t.rationale.trim()||"_None._"}`,`## Transcript
97
+
98
+ ${a}`].join(`
99
+
100
+ `);return Hl(s,l)}function $l(t){const{front:s,body:r}=po(t),a={},l=new RegExp(`^## (${Nv.join("|")})\\s*$`,"gm"),u=[...r.matchAll(l)];u.forEach((v,w)=>{var M;const N=r.slice(v.index+v[0].length,((M=u[w+1])==null?void 0:M.index)??r.length).trim();a[v[1]]=/^_none\._$/i.test(N)?"":N});const f=(a.Transcript??"").split(/^### /m).slice(1).map(v=>{const w=v.indexOf(`
101
+ `),N=w<0?v:v.slice(0,w),[M,S=""]=N.split(" @ "),[E,I="agent"]=M.split(" · ");return{author:E.trim(),from:["agent","human","system"].includes(I.trim())?I.trim():"agent",at:Date.parse(S)||0,text:w<0?"":v.slice(w+1).trim()}}),m=we(s.source),g=bn(s.source_meta),p={kind:Gg(m)?m:"tracker",...we(s.source_ref)?{ref:we(s.source_ref)}:{},...we(s.source_url)?{url:we(s.source_url)}:{},...we(s.source_label)?{label:we(s.source_label)}:{},...g.length?{meta:Object.fromEntries(g.map(v=>[v.slice(0,v.indexOf("=")),v.slice(v.indexOf("=")+1)]))}:{}},k=a.Decision??"";return{id:we(s.id),mapId:we(s.trail),ticketId:we(s.ticket)||void 0,ticketKey:we(s.ticket_key)||void 0,question:a.Question??"",answer:k,summary:a.Summary||mo(k),alternatives:(a.Alternatives??"").split(`
102
+ `).map(v=>v.trim()).filter(v=>v.startsWith("- ")).map(v=>v.slice(2)),rationale:a.Rationale??"",decidedBy:we(s.decided_by),decidedAt:Cs(s.decided_at),participants:bn(s.participants).map($v),source:p,supersedes:we(s.supersedes)||void 0,supersededBy:we(s.superseded_by)||void 0,...bn(s.assumes).length?{assumes:bn(s.assumes)}:{},transcript:f,...Sv(s)}}function bv(t){return t.url?` · [${t.label??"link"}](${t.url})`:t.label?` · ${t.label}`:""}function Tv(t,s,r={}){const a=[`# ${r.title??"Decisions"}`,"",`Exported ${Ht(r.now??Date.now())} · ${t.length} decisions`],l=new Map;for(const u of t)l.set(u.mapId,[...l.get(u.mapId)??[],u]);for(const[u,f]of l){const m=s[u];a.push("",`## Trail ${m?`${m.key} ${m.title}`:u}`);for(const g of f){const p=Tn[g.source.kind].label;a.push("",`### ${g.id}${g.ticketKey?` · ${g.ticketKey}`:""} · ${g.question}`,"",`- **Status:** ${Ai(g)}${g.supersededBy?` (superseded by ${g.supersededBy})`:""}${g.supersedes?` · supersedes ${g.supersedes}`:""}`,`- **Decided by:** ${g.decidedBy} · ${Ht(g.decidedAt)}`,`- **Source:** ${p}${bv(g.source)}`,...g.participants.length?[`- **Participants:** ${g.participants.map(k=>k.name??k.id).join(", ")}`]:[],"",`**Decision:** ${g.answer}`,...g.alternatives.length?["","**Alternatives:**",...g.alternatives.map(k=>`- ${k}`)]:[],...g.rationale?["",`**Rationale:** ${g.rationale}`]:[],...g.transcript.length?["","<details><summary>Transcript</summary>","",...g.transcript.map(k=>`> **${k.author}:** ${k.text.replace(/\n/g,`
103
+ > `)}
104
+ >`),"","</details>"]:[])}}return a.join(`
105
+ `)+`
106
+ `}function bl(t,s,r){try{const a=t.get(s);return a?JSON.parse(a):r}catch{return r}}class hf{constructor(s,r="presence"){le(this,"seen");this.store=s,this.key=r,this.seen=bl(s,r,{})}snapshot(){return{...this.seen}}lastSeen(s){return this.seen[s]}lastSeenAny(){const s=Object.values(this.seen);return s.length?Math.max(...s):void 0}markSeen(s,r=Date.now()){let a=!1;for(const l of s)(this.seen[l]??0)>=r||(this.seen[l]=r,a=!0);a&&this.store.set(this.key,JSON.stringify(this.seen))}}const kl=5*6e4,Ev=14*864e5;class mf{constructor(s,r="usage"){le(this,"buckets");le(this,"dirty",!1);le(this,"timer");le(this,"totals");this.store=s,this.key=r,this.buckets=bl(s,r,{}),this.totals=bl(s,`${r}.totals`,{})}addTotal(s,r,a,l=Date.now()){const u=this.totals[r],f={inputTokens:a.inputTokens-((u==null?void 0:u.inputTokens)??0),outputTokens:a.outputTokens-((u==null?void 0:u.outputTokens)??0),costUsd:a.costUsd-((u==null?void 0:u.costUsd)??0)};this.totals[r]={...a,at:l},f.inputTokens>0||f.outputTokens>0||f.costUsd>0?this.add(s,f,r,l):this.save()}add(s,r,a,l=Date.now()){var g;if(!s)return;const u=Math.floor(l/kl)*kl,f=(g=this.buckets)[s]??(g[s]=[]);let m=f.find(p=>p.at===u);m||(m={at:u,i:0,o:0,c:0,s:[]},f.push(m),f.sort((p,k)=>p.at-k.at)),m.i+=r.inputTokens,m.o+=r.outputTokens,m.c+=r.costUsd,m.s.includes(a)||m.s.push(a),this.save()}since(s,r){const a={inputTokens:0,outputTokens:0,costUsd:0,sessions:0},l=new Set;for(const u of this.buckets[s]??[])u.at+kl<=r||(a.inputTokens+=u.i,a.outputTokens+=u.o,a.costUsd+=u.c,u.s.forEach(f=>l.add(f)));return a.sessions=l.size,a}save(){this.dirty=!0,!this.timer&&(this.timer=setTimeout(()=>{if(this.timer=void 0,!this.dirty)return;this.dirty=!1;const s=Date.now()-Ev;for(const r of Object.keys(this.buckets))this.buckets[r]=this.buckets[r].filter(a=>a.at>=s);for(const[r,a]of Object.entries(this.totals))a.at<s&&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 Mv(t){const s=t.now??Date.now(),r=t.snaps.map(f=>{var ae;const m=f.map.id,g=t.since(m),p=K=>!!K&&K>=g,k=Is(f.tickets,f.map.mode),v=new Map(f.tickets.map(K=>[K.id,K])),w=(t.attention??[]).filter(K=>K.mapId===m),N=Iv(t.activity.pending.filter(K=>K.mapId===m),w),M=new Set(N.map(K=>K.ticketId)),S=K=>K.state==="open"&&(M.has(K.id)||Ii(K)==="hitl"),E=f.tickets.filter(K=>k.get(K.id)==="blocked").map(K=>({ticket:K,on:K.blockedBy.map(xe=>v.get(xe)).filter(xe=>!!xe&&S(xe))})).filter(K=>K.on.length),I=t.decisions.filter(K=>K.mapId===m&&p(K.decidedAt)).sort((K,xe)=>xe.decidedAt-K.decidedAt),_=f.tickets.filter(K=>K.state==="closed"&&p(K.closedAt)).sort((K,xe)=>(K.closedAt??0)-(xe.closedAt??0)),O=_.filter(K=>K.closeReason==="completed"),ee=_.filter(K=>K.closeReason==="not_planned"),q=f.tickets.filter(K=>p(K.createdAt)),V=((ae=t.ledger)==null?void 0:ae.since(m,g))??{inputTokens:0,outputTokens:0,costUsd:0,sessions:0},ie=t.activity.sessions.filter(K=>K.mapId===m&&K.status==="running");return{mapId:m,key:f.map.key,title:f.map.title,since:g,done:O,ruledOut:ee,opened:q,blocked:E,waiting:N,needsYou:w,decisions:I,agentDecisions:I.filter(K=>Ti(K)==="agent"),usage:V,active:ie,changed:!!(_.length||q.length||I.length||N.some(K=>p(K.at))||V.costUsd>0)}}),a=r.filter(f=>f.changed||f.waiting.length).sort((f,m)=>+(m.mapId===t.currentMapId)-+(f.mapId===t.currentMapId)),l=f=>a.reduce((m,g)=>m+g[f].length,0),u=a.flatMap(f=>f.waiting).reduce((f,m)=>f===void 0||m.at<f?m.at:f,void 0);return{since:a.length?Math.min(...a.map(f=>f.since)):s,now:s,trails:a,totals:{done:l("done"),ruledOut:l("ruledOut"),blocked:l("blocked"),waiting:l("waiting"),oldestWaitMs:u===void 0?void 0:s-u,agentDecisions:l("agentDecisions"),usage:a.reduce((f,m)=>({inputTokens:f.inputTokens+m.usage.inputTokens,outputTokens:f.outputTokens+m.usage.outputTokens,costUsd:f.costUsd+m.usage.costUsd,sessions:f.sessions+m.usage.sessions}),{inputTokens:0,outputTokens:0,costUsd:0,sessions:0}),active:l("active")},changed:r.some(f=>f.changed)}}function Iv(t,s){const r=new Map(s.filter(l=>l.kind==="question").map((l,u)=>[l.ref,u])),a=l=>r.get(l.id)??Number.MAX_SAFE_INTEGER;return[...t].sort((l,u)=>a(l)-a(u)||l.at-u.at)}const Ci=(t,s,r=`${s}s`)=>`${t} ${t===1?s:r}`;function Av(t){return t.trails.flatMap(s=>{const r=new Set(s.waiting.map(a=>a.ticketId));return s.blocked.filter(a=>a.on.some(l=>r.has(l.id)))})}function Lv(t){return t.length===1?`, and it holds up ${t[0].ticket.title.replace(/^./,s=>s.toLowerCase())}`:t.length>1?`, holding up ${Ci(t.length,"ticket")}`:""}function Rv(t,s=new Date(t.now).getHours()){const r=t.totals,l=t.now-t.since>=6*36e5&&s>=5&&s<12?"Good morning.":"Welcome back.",u=[];if(r.done&&u.push(`${Ci(r.done,"ticket")} ${r.done===1?"is":"are"} done.`),r.agentDecisions&&u.push(`Agents made ${Ci(r.agentDecisions,"decision")}.`),r.waiting){const f=Lv(Av(t));u.push(`${Ci(r.waiting,"decision")} ${r.waiting===1?"is":"are"} waiting on you${f}.`)}else u.push("Nothing is waiting on you.");return!r.done&&!r.agentDecisions&&r.ruledOut&&u.unshift(`${Ci(r.ruledOut,"ticket")} ruled out of scope.`),[l,...u].join(" ")}const Ov=t=>{if(!t.length)return;const s=[...t].sort((a,l)=>a-l),r=Math.floor(s.length/2);return s.length%2?s[r]:Math.round((s[r-1]+s[r])/2)};function _v(t){return t.state==="open"?"open":t.closeReason==="not_planned"?"cancelled":"done"}function ph({snap:t,journal:s,answered:r,usage:a}){const l=t.map.id,u=s.filter(S=>S.mapId===l).sort((S,E)=>S.at-E.at),f=new Map;for(const S of u)f.set(S.ticketId,[...f.get(S.ticketId)??[],S]);const m=t.tickets.filter(S=>S.type!=="review").map(S=>{var ee;const E=f.get(S.id)??[],I=_v(S),_=(ee=E.find(q=>q.event==="claim"))==null?void 0:ee.at,O=I==="done"?S.closedAt:void 0;return{id:S.id,key:S.key,title:S.title,type:S.type,outcome:I,claimedAt:_,doneAt:O,leadMs:O&&_&&O>=_?O-_:void 0,reworks:E.filter(q=>q.to==="rework").length,reviews:{passed:E.filter(q=>q.event==="review.pass").length,failed:E.filter(q=>q.event==="review.fail").length,needsHuman:E.filter(q=>q.event==="review.needs_human").length},operatorActions:E.filter(q=>q.actorKind==="trail lead").length}}),g=m.filter(S=>S.outcome==="done"),p=Math.max(0,...g.map(S=>S.doneAt??0)),k=u.filter(S=>S.actorKind==="trail lead"),v=new Set(r.filter(S=>S.mapId===l).map(S=>S.id)).size,w=k.length,N=S=>m.reduce((E,I)=>E+S(I),0),M=(a==null?void 0:a.costUsd)??0;return{mapId:l,tickets:m,done:g.length,cancelled:m.filter(S=>S.outcome==="cancelled").length,open:m.filter(S=>S.outcome==="open").length,trailLeadMs:p&&p>=t.map.createdAt?p-t.map.createdAt:void 0,medianLeadMs:Ov(g.flatMap(S=>S.leadMs===void 0?[]:[S.leadMs])),interventions:{answers:v,operatorActions:w,reworkRequested:k.filter(S=>S.event==="reject").length,total:v+w},rework:{tickets:m.filter(S=>S.reworks>0).length,cycles:N(S=>S.reworks)},reviews:{passed:N(S=>S.reviews.passed),failed:N(S=>S.reviews.failed),needsHuman:N(S=>S.reviews.needsHuman)},spend:{costUsd:Math.round(M*1e4)/1e4,tokens:((a==null?void 0:a.inputTokens)??0)+((a==null?void 0:a.outputTokens)??0),perVerifiedTicketUsd:g.length&&M?Math.round(M/g.length*1e4)/1e4:void 0}}}const xl=t=>t.split("-")[0];function rn(t){if(t===void 0)return"—";const s=Math.round(t/6e4);if(s<90)return`${s} min`;const r=t/36e5;return r<48?`${Math.round(r*10)/10} h`:`${Math.round(r/24*10)/10} d`}const pf=t=>t===void 0?"—":`$${t.toFixed(t<1?4:2)}`;function Pv(t,s,r=Date.now()){const a=t.interventions;return[`# Trail report: ${s}`,"",`_Generated ${new Date(r).toISOString()} by Teamtrail._`,"","| Measure | Value |","| --- | --- |",`| Tickets done / cancelled / open | ${t.done} / ${t.cancelled} / ${t.open} |`,`| Trail lead time (created → last done) | ${rn(t.trailLeadMs)} |`,`| Median ticket lead time (claim → done) | ${rn(t.medianLeadMs)} |`,`| Human interventions | ${a.total} (${a.answers} answers, ${a.operatorActions} operator actions, ${a.reworkRequested} sent back) |`,`| Rework | ${t.rework.cycles} cycles on ${t.rework.tickets} tickets |`,`| Reviews | ${t.reviews.passed} passed, ${t.reviews.failed} failed, ${t.reviews.needsHuman} needed a human |`,`| Spend | ${pf(t.spend.costUsd)} · ${t.spend.tokens.toLocaleString("en-US")} tokens |`,`| Cost per verified ticket | ${pf(t.spend.perVerifiedTicketUsd)} |`,"","## Tickets","","| Ticket | Type | Outcome | Lead time | Rework | Reviews (pass/fail) | Operator actions |","| --- | --- | --- | --- | --- | --- | --- |",...t.tickets.map(u=>`| ${u.key} ${u.title.replace(/\|/g,"\\|")} | ${u.type} | ${u.outcome} | ${rn(u.leadMs)} | ${u.reworks} | ${u.reviews.passed}/${u.reviews.failed} | ${u.operatorActions} |`),""].join(`
107
+ `)}const Vl=5,gh=1.5,Dv=15,Kr=t=>Math.round(t*100);function zv(t){const s=t.filter(f=>f.findings.raised>=Vl).sort((f,m)=>m.findings.upheld/m.findings.raised-f.findings.upheld/f.findings.raised||f.key.localeCompare(m.key));if(s.length<2)return[];const[r,a]=[s[0],s[s.length-1]],[l,u]=[r.findings.upheld/r.findings.raised,a.findings.upheld/a.findings.raised];return Kr(l)-Kr(u)<Dv?[]:[{id:"review-findings",text:`${r.key} review findings upheld ${Kr(l)}% vs ${a.key} ${Kr(u)}%`,because:`${r.findings.upheld} of ${r.findings.raised} and ${a.findings.upheld} of ${a.findings.raised} failed reviews stood; a finding is overruled when you accept the work anyway`}]}function Bv(t){const s=u=>u.reworkCycles/u.tickets,r=t.filter(u=>u.tickets>=Vl).sort((u,f)=>s(u)-s(f)||u.key.localeCompare(f.key));if(r.length<2)return[];const[a,l]=[r[0],r[r.length-1]];return s(l)-s(a)<.2||s(l)<s(a)*gh?[]:[{id:"rework",text:`${l.key} work goes back to rework more: ${s(l).toFixed(1)} times per ticket vs ${a.key} ${s(a).toFixed(1)}`,because:`${l.reworkCycles} cycles on ${l.tickets} tickets, and ${a.reworkCycles} on ${a.tickets}`}]}function Fv(t,s){const r=f=>f.medianLeadMs??0,a=s.filter(f=>f.done>=Vl&&f.medianLeadMs!==void 0).sort((f,m)=>r(f)-r(m)||f.key.localeCompare(m.key));if(a.length<2)return[];const[l,u]=[a[0],a[a.length-1]];return r(u)<r(l)*gh?[]:[{id:`speed-${t}`,text:`${t} tickets: ${l.key} is faster, ${rn(l.medianLeadMs)} vs ${u.key} ${rn(u.medianLeadMs)}`,because:`Median first claim to done, over ${l.done} and ${u.done} done tickets`}]}function Uv(t){const s=Object.keys(t.byTypeAndVendor).sort();return[...zv(t.byVendor),...Bv(t.byVendor),...s.flatMap(r=>Fv(r,t.byTypeAndVendor[r]))]}const Wv=t=>{if(!t.length)return;const s=[...t].sort((a,l)=>a-l),r=Math.floor(s.length/2);return s.length%2?s[r]:Math.round((s[r-1]+s[r])/2)},vh=t=>{var s;return(s=t.filter(r=>r.event==="claim"&&r.actorKind==="agent").at(-1))==null?void 0:s.actor},Tl=(t,s,r)=>t.filter(a=>a.mapId===s&&a.ticketId===r).sort((a,l)=>a.at-l.at);function Hv(t,s){return t.tickets.flatMap(r=>{var v;if(r.type!=="review"||!r.reviewOf)return[];const a=Tl(s,t.map.id,r.id),l=vh(a);if(!l)return[];const u=((v=a.filter(w=>w.event==="claim").at(-1))==null?void 0:v.at)??0,f=Tl(s,t.map.id,r.reviewOf),m=f.findIndex(w=>w.at>=u&&w.event.startsWith("review."));if(m<0||f[m].event!=="review.fail")return[];const g=f.slice(m+1),p=g.findIndex(w=>w.event.startsWith("review.")),k=p<0?g:g.slice(0,p);return[{reviewer:l,upheld:!k.some(w=>w.event==="accept"&&w.actorKind==="trail lead")}]})}function Vv(t,s){var a;const r=(a=t.tickets.find(l=>l.id===s))==null?void 0:a.assignee;return r&&/^[a-z]+-\d+$/.test(r)?r:void 0}function yh(t,s){const r=l=>s.reduce((u,{ticket:f})=>u+l(f),0),a=l=>s.filter(u=>u.ticket.outcome===l).length;return{key:t,tickets:s.length,done:a("done"),cancelled:a("cancelled"),open:a("open"),medianLeadMs:Wv(s.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 Qr(t,s){const r=new Map;for(const a of t){const l=s(a);l&&r.set(l,[...r.get(l)??[],a])}return new Map([...r].map(([a,l])=>[a,yh(a,l)]))}const El=(t,s)=>{const r=t.get(s)??yh(s,[]);return t.set(s,r),r};function gf(t,s,r){const a=El(t,s);a.findings.raised+=1,r&&(a.findings.upheld+=1)}const qr=t=>[...t.values()].sort((s,r)=>r.tickets-s.tickets||s.key.localeCompare(r.key));function Kv(t){const s=t.flatMap(({snap:p,journal:k,answered:v,usage:w})=>ph({snap:p,journal:k,answered:v,usage:w}).tickets.map(N=>({ticket:N,agent:vh(Tl(k,p.map.id,N.id))??Vv(p,N.id)}))),r=p=>p.agent?xl(p.agent):void 0,a=Qr(s,p=>p.agent),l=Qr(s,r),u=Qr(s,p=>p.ticket.type),f=new Set;for(const{snap:p,journal:k,answered:v}of t){for(const w of v){const N=`${w.mapId}/${w.id}`;w.mapId!==p.map.id||f.has(N)||(f.add(N),El(a,w.agent).answers+=1,El(l,xl(w.agent)).answers+=1)}for(const w of Hv(p,k))gf(a,w.reviewer,w.upheld),gf(l,xl(w.reviewer),w.upheld)}const m=Object.fromEntries([...u.keys()].map(p=>[p,qr(Qr(s.filter(k=>k.ticket.type===p),r))])),g={trails:t.length,tickets:s.length,byAgent:qr(a),byVendor:qr(l),byType:qr(u),byTypeAndVendor:m};return{...g,recommendations:Uv(g)}}const Qv={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
+ `)},qv=[["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"]],ji=Object.fromEntries(qv);function Gv(t,s){const r=new Set(t.map(a=>a.source).filter(Boolean));return s.filter(a=>!r.has(a))}const Yv=["architecture","convention","gotcha","dead-end","glossary","fact"],kh=["business-rule","product-decision","persona","ux-principle","pricing"],Jv=[...Yv,...kh],Xv=t=>t.status==="confirmed"||t.status==="assumption";function Zv(t,s){const r=t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*\//g,"§DIRS§").replace(/\*\*/g,"§DEEP§").replace(/\*/g,"[^/]*").replace(/§DIRS§/g,"(?:.*/)?").replace(/§DEEP§/g,".*");return new RegExp(`^${r}$`).test(s.replace(/^\.\//,""))}const ey={"business-rule":3,convention:3,"product-decision":2,architecture:2,gotcha:2,"dead-end":2,"ux-principle":2},ty=["business-rule","ux-principle","convention"],vf=600,ny=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(" ")),yf=t=>new Set((t.toLowerCase().match(/[a-z0-9][a-z0-9_-]{2,}/g)??[]).filter(s=>!ny.has(s)));function xh(t,s,r=4e3,a=()=>[]){const l=s.ticket?yf(`${s.ticket.title} ${s.ticket.body}`):new Set,u=new Set((s.tags??[]).map(p=>p.toLowerCase())),f=t.filter(Xv).map(p=>{const k=[];let v=ey[p.kind]??1;for(const M of p.scope){const S=s.paths.find(E=>Zv(M,E));if(S){v+=6,k.push(`path match ${M} (${S})`);break}}const w=p.tags.filter(M=>u.has(M.toLowerCase())||l.has(M.toLowerCase()));w.length&&(v+=3*w.length,k.push(`tag ${w.join(", ")}`));const N=[...yf(p.title)].filter(M=>l.has(M));return N.length&&(v+=N.length,k.push(`mentions ${N.slice(0,3).join(", ")}`)),s.trailKey&&p.sources.includes(`trail:${s.trailKey}`)&&(v+=3,k.push("same trail")),s.discovery&&kh.includes(p.kind)&&(v+=8,k.push("product context for discovery")),!k.length&&ty.includes(p.kind)&&!p.scope.length&&k.push(`${p.kind.replace("-"," ")} for the whole project`),{e:p,score:v,why:k}}).filter(p=>p.why.length>0).sort((p,k)=>k.score-p.score||p.e.id.localeCompare(k.e.id,void 0,{numeric:!0})),m=[];let g=0;for(const{e:p,why:k}of f){const v=p.body.length>vf?`${p.body.slice(0,vf)}…`:p.body;if(g+v.length>r&&m.length)break;g+=v.length;const w=a(p);m.push({id:p.id,title:p.title,kind:p.kind,status:p.status,body:v,why:k,...w.length?{mayBeOutdated:w}:{},...p.flag?{flagged:p.flag.reason}:{}})}return m}const sy=new RegExp("`([^`\\s]+/[^`\\s]+)`|(?:^|[\\s(])/?((?:[\\w.-]+/)+[\\w.-]+)","gm");function wh(t){const s=new Set;for(const r of t.matchAll(sy))s.add((r[1]??r[2]).replace(/^\.?\//,"").replace(/[.,;:]+$/,""));return[...s]}const iy=[{level:"high",label:"High risk"},{level:"medium",label:"Medium risk"},{level:"low",label:"Low risk"},{level:"none",label:"No category"}];function ry(t){return iy.map(s=>({...s,decisions:t.filter(r=>{var a;return(((a=r.risk)==null?void 0:a.level)??"none")===s.level})})).filter(s=>s.decisions.length)}const oy=1/3;function go(t,s=Date.now()){const r=t.expiresAt-s;return r<=0?"expired":r<=t.ttlMs*oy?"stalled":"live"}function ay(t){var s;return((s=t.returned)==null?void 0:s.reason)==="trail lead"?`${t.ticketKey} returned to queue · claim of ${t.agent} released by ${t.returned.by}`:`${t.ticketKey} returned to queue after ${t.agent} went silent`}const ly=t=>t.urgency==="fyi"||t.kind==="policy";function cy(t,s){const r={...t};return s.verification===null?delete r.verification:s.verification&&(r.verification=s.verification),r}function uy(t,s,r){const a=Date.now();return{id:t,key:s,...r,state:"open",blockedBy:[],comments:[],createdAt:a,updatedAt:a}}const dy=(t,s)=>({...t,blockedBy:t.blockedBy.filter(r=>r!==s)}),fy=(t,s)=>{var r;return{...t,...(r=s.title)!=null&&r.trim()?{title:s.title.trim()}:{},...s.body!==void 0?{body:s.body}:{}}};function hy(t){const{closeReason:s,closedAt:r,...a}=t;return{...a,state:"open"}}const my=["status","verification","checks","reviewOf"];function py(t,s){const r={...t};for(const a of my)s[a]!==void 0&&(s[a]===null?delete r[a]:r[a]=s[a]);return r}const gy=/^([^/]+)\/decisions\/([^/]+)\.md$/,vy=(t,s)=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,40)||`map-${s}`;class yy{constructor(s,r){le(this,"seen",new Map);le(this,"pending",new Map);this.read=s,this.emit=r}knows(s){return this.seen.has(s)}remember(s,r,a){this.seen.set(s,{text:r,supersededBy:a})}queue(s){const r=s.split("/")[0],a=this.pending.get(r)??{paths:new Set,timer:setTimeout(()=>void this.flush(r),250)};a.paths.add(s),this.pending.set(r,a)}async flush(s){const r=this.pending.get(s);if(this.pending.delete(s),!r)return;const a=[...r.paths].filter(f=>gy.test(f)),l=[];for(const f of a){const m=await this.read(f).catch(()=>""),g=this.seen.get(f);if(!m||(g==null?void 0:g.text)===m)continue;const p=$l(m);this.seen.set(f,{text:m,supersededBy:p.supersededBy}),g?p.supersededBy&&p.supersededBy!==g.supersededBy&&l.push({kind:"decision.superseded",mapId:s,decisionId:p.id,supersededBy:p.supersededBy,external:!0,at:Date.now()}):l.push({kind:"decision.recorded",mapId:s,decisionId:p.id,ticketId:p.ticketId,external:!0,at:Date.now()})}a.length?!l.length&&a.length<r.paths.size&&l.push({kind:"external.changed",mapId:s,at:Date.now()}):l.push({kind:"external.changed",mapId:s,at:Date.now()});const u=f=>f.kind==="decision.recorded"?0:1;l.sort((f,m)=>u(f)-u(m));for(const f of l)this.emit(f)}}function ky(t,s){const{front:r,body:a}=po(s),l=th(we(r.verification));return{id:t,key:we(r.key)||t,title:we(r.title)||t,mode:we(r.mode)==="plan-only"||bn(r.labels).includes(Fl)?"plan-only":Gn,...l?{verification:l}:{},sections:Ag(a),createdAt:Cs(r.created),updatedAt:Cs(r.updated)}}function xy(t){return Hl({key:t.key,title:t.title,mode:t.mode,...t.verification?{verification:t.verification}:{},labels:[zl,...t.mode==="plan-only"?[Fl]:[]],created:Ht(t.createdAt),updated:Ht(t.updatedAt)},Ig(t.sections))}async function kf(t){const s=await t.list(),r=s.filter(l=>!l.includes("/decisions/")).map(l=>{var u;return Number(((u=l.match(/(\d+)\.md$/))==null?void 0:u[1])??0)}),a=await Promise.all(s.filter(l=>l.endsWith("/map.md")).map(async l=>Number(we(po(await t.read(l)).front.key).replace(/\D/g,""))||0));return Math.max(0,...r,...a)+1}function xf(t){const{front:s,body:r}=po(t),[a,l=""]=r.split(/^## Comments\s*$/m),u=l.split(/^### /m).slice(1).map((p,k)=>{const v=p.indexOf(`
109
+ `),[w,N]=p.slice(0,v).split(" @ ");return{id:`c${k}`,author:w.trim(),createdAt:Date.parse(N)||0,body:p.slice(v+1).trim()}}),f=we(s.close_reason),m=gg.find(p=>p===we(s.status)),g=th(we(s.verification));return{id:we(s.id),key:`#${we(s.id)}`,title:we(s.title),type:we(s.type)||"task",hitl:bn(s.labels).includes(Bl)||void 0,state:we(s.state)==="closed"?"closed":"open",closeReason:f==="completed"||f==="not_planned"?f:void 0,assignee:we(s.assignee)||void 0,...m?{status:m}:{},...g?{verification:g}:{},...s.checks!==void 0?{checks:bn(s.checks)}:{},...we(s.review_of)?{reviewOf:we(s.review_of)}:{},blockedBy:bn(s.blocked_by),body:a.trim(),comments:u,createdAt:Cs(s.created),updatedAt:Cs(s.updated),closedAt:Cs(s.closed)||void 0}}function wy(t){const s={id:t.id,title:t.title,type:t.type,labels:[uo(t.type),...pg(t.type)&&t.hitl?[Bl]:[]],state:t.state,close_reason:t.closeReason??"",assignee:t.assignee??"",...t.status?{status:t.status}:{},...t.verification?{verification:t.verification}:{},...t.checks?{checks:t.checks}:{},...t.reviewOf?{review_of:t.reviewOf}:{},blocked_by:t.blockedBy,created:Ht(t.createdAt),updated:Ht(t.updatedAt),...t.closedAt?{closed:Ht(t.closedAt)}:{}},r=t.comments.length?`
110
+
111
+ ## Comments
112
+
113
+ ${t.comments.map(a=>`### ${a.author} @ ${Ht(a.createdAt)}
114
+
115
+ ${a.body}`).join(`
116
+
117
+ `)}`:"";return Hl(s,t.body+r)}class jy{constructor(s,r=`./${ne.dataDir}`){le(this,"kind","markdown");le(this,"label","Local markdown");le(this,"events",new bs);le(this,"selfWrites",new Map);le(this,"external",new yy(s=>this.fs.read(s),s=>this.events.emit(s)));var a;this.fs=s,this.location=r,(a=s.watch)==null||a.call(s,l=>{const u=this.selfWrites.get(l);u&&Date.now()-u<1500||this.external.queue(l)})}async put(s,r){this.selfWrites.set(s,Date.now()),await this.fs.write(s,r)}async readMap(s){return ky(s,await this.fs.read(`${s}/map.md`))}async writeMap(s){await this.put(`${s.id}/map.md`,xy(s))}async readTicket(s,r){return xf(await this.fs.read(`${s}/tickets/${r}.md`))}async writeTicket(s,r){await this.put(`${s}/tickets/${r.id}.md`,wy({...r,updatedAt:Date.now()}))}async listMaps(){const r=(await this.fs.list()).filter(a=>/^[^/]+\/map\.md$/.test(a)).map(a=>a.split("/")[0]);return Promise.all(r.map(async a=>{const l=await this.readMap(a);return{id:a,key:l.key,title:l.title}}))}async loadMap(s){const r=await this.fs.list(),a=await this.readMap(s),l=r.filter(f=>f.startsWith(`${s}/tickets/`)),u=await Promise.all(l.map(async f=>xf(await this.fs.read(f))));return{map:a,tickets:u.sort((f,m)=>f.createdAt-m.createdAt)}}async createMap(s){const r=await kf(this.fs),a=vy(s.title,r),l={id:a,key:`#${r}`,title:s.title,mode:s.mode??Gn,...s.verification?{verification:s.verification}:{},sections:s.sections,createdAt:Date.now(),updatedAt:Date.now()};return await this.writeMap(l),this.events.emit({kind:"map.created",mapId:a,at:Date.now()}),l}async editMap(s,r,a){await this.writeMap({...r(await this.readMap(s)),updatedAt:Date.now()}),this.events.emit(a)}setMapMode(s,r){return this.editMap(s,a=>({...a,mode:r}),{kind:"map.mode",mapId:s,mode:r,at:Date.now()})}setMapMeta(s,r){return this.editMap(s,a=>cy(a,r),{kind:"map.updated",mapId:s,at:Date.now()})}updateMapSections(s,r){const a=Object.keys(r)[0];return this.editMap(s,l=>({...l,sections:{...l.sections,...r}}),{kind:"map.updated",mapId:s,section:a,at:Date.now()})}async createTicket(s,r){const a=await kf(this.fs),l=uy(String(a),`#${a}`,r);return await this.writeTicket(s,l),this.events.emit({kind:"ticket.created",mapId:s,ticketId:l.id,at:Date.now()}),l}async addBlocking(s,r,a){const l=await this.readTicket(s,a);l.blockedBy.includes(r)||await this.writeTicket(s,{...l,blockedBy:[...l.blockedBy,r]}),this.events.emit({kind:"edge.added",mapId:s,blockerId:r,blockedId:a,at:Date.now()})}async update(s,r,a){await this.writeTicket(s,a(await this.readTicket(s,r)))}async removeBlocking(s,r,a){await this.update(s,a,l=>dy(l,r)),this.events.emit({kind:"edge.removed",mapId:s,blockerId:r,blockedId:a,at:Date.now()})}async editTicket(s,r,a){await this.update(s,r,l=>fy(l,a)),this.events.emit({kind:"ticket.updated",mapId:s,ticketId:r,at:Date.now()})}async reopen(s,r){await this.update(s,r,hy),this.events.emit({kind:"ticket.updated",mapId:s,ticketId:r,at:Date.now()})}async assign(s,r,a){await this.update(s,r,l=>({...l,assignee:a??void 0})),this.events.emit(a?{kind:"ticket.claimed",mapId:s,ticketId:r,assignee:a,at:Date.now()}:{kind:"ticket.released",mapId:s,ticketId:r,at:Date.now()})}async comment(s,r,a,l){await this.update(s,r,u=>({...u,comments:[...u.comments,{id:`c${u.comments.length}`,author:a,body:l,createdAt:Date.now()}]})),this.events.emit({kind:"ticket.commented",mapId:s,ticketId:r,at:Date.now()})}async close(s,r,a){await this.update(s,r,l=>({...l,state:"closed",closeReason:a,closedAt:Date.now()})),this.events.emit({kind:"ticket.closed",mapId:s,ticketId:r,reason:a,at:Date.now()})}async setMeta(s,r,a){await this.update(s,r,l=>py(l,a)),this.events.emit({kind:"ticket.updated",mapId:s,ticketId:r,at:Date.now()})}async listDecisions(s){const r=(await this.fs.list()).filter(a=>a.startsWith(`${s}/decisions/`));return Promise.all(r.map(async a=>{const l=await this.fs.read(a),u={...$l(l),mapId:s};return this.external.knows(a)||this.external.remember(a,l,u.supersededBy),u}))}async createDecision(s,r){const a=(await this.fs.list()).filter(m=>m.includes("/decisions/")),l=Math.max(0,...a.map(m=>Jg(m.split("/").pop())))+1,u=Yg(`D-${l}`,s,r),f=ff(u);return this.external.remember(`${s}/decisions/${u.id}.md`,f),await this.put(`${s}/decisions/${u.id}.md`,f),this.events.emit({kind:"decision.recorded",mapId:s,decisionId:u.id,ticketId:u.ticketId,at:Date.now()}),u}async markSuperseded(s,r,a){const l=`${s}/decisions/${r}.md`,u=$l(await this.fs.read(l)),f=ff({...u,mapId:s,supersededBy:a});this.external.remember(l,f,a),await this.put(l,f),this.events.emit({kind:"decision.superseded",mapId:s,decisionId:r,supersededBy:a,at:Date.now()})}subscribe(s){return this.events.on(s)}}class wf extends Error{constructor(s,r,a,l){super(r),this.code=s,this.status=a,this.resetAt=l,this.name="TrackerError"}}const Sy={github:"GitHub Issues",linear:"Linear"};async function $i(t,s,r){let a;try{a=await fetch(t,{method:s,headers:{"Content-Type":"application/json"},body:r===void 0?void 0:JSON.stringify(r)})}catch{throw new wf("offline","Lookout server unreachable; is `teamtrail` still running?")}const l=await a.json().catch(()=>({}));if(!a.ok)throw new wf(l.code??"http",l.error??`request failed (${a.status})`,a.status,l.resetAt);return l}class Ny{constructor(s,r,a=""){le(this,"label");le(this,"location");le(this,"status",{state:"connecting",queued:0});le(this,"events",new bs);le(this,"statusEvents",new bs);le(this,"source");le(this,"listeners",0);le(this,"listMaps",()=>this.call("listMaps"));le(this,"loadMap",s=>this.call("loadMap",s));le(this,"createMap",s=>this.call("createMap",s));le(this,"setMapMode",(s,r)=>this.call("setMapMode",s,r));le(this,"setMapMeta",(s,r)=>this.call("setMapMeta",s,r));le(this,"updateMapSections",(s,r)=>this.call("updateMapSections",s,r));le(this,"createTicket",(s,r)=>this.call("createTicket",s,r));le(this,"addBlocking",(s,r,a)=>this.call("addBlocking",s,r,a));le(this,"removeBlocking",(s,r,a)=>this.call("removeBlocking",s,r,a));le(this,"editTicket",(s,r,a)=>this.call("editTicket",s,r,a));le(this,"reopen",(s,r)=>this.call("reopen",s,r));le(this,"assign",(s,r,a)=>this.call("assign",s,r,a));le(this,"comment",(s,r,a,l)=>this.call("comment",s,r,a,l));le(this,"close",(s,r,a)=>this.call("close",s,r,a));le(this,"setMeta",(s,r,a)=>this.call("setMeta",s,r,a));le(this,"listDecisions",s=>this.call("listDecisions",s));le(this,"createDecision",(s,r)=>this.call("createDecision",s,r));le(this,"markSuperseded",(s,r,a)=>this.call("markSuperseded",s,r,a));this.kind=s,this.base=r,this.label=Sy[s],this.location=a}async call(s,...r){return(await $i(`${this.base}/tracker/${this.kind}/call`,"POST",{method:s,args:r})).result}open(){const s=new EventSource(`${this.base}/tracker/${this.kind}/events`);s.onmessage=r=>this.events.emit(JSON.parse(r.data)),s.addEventListener("status",r=>{const a=JSON.parse(r.data);a.location&&(this.location=a.location),this.status=a,this.statusEvents.emit(a)}),s.onerror=()=>{this.status.state!=="offline"&&(this.status={...this.status,state:"offline",error:"Lookout server unreachable"},this.statusEvents.emit(this.status))},this.source=s}subscribe(s){const r=this.events.on(s);return++this.listeners===1&&this.open(),()=>{var a;r(),--this.listeners===0&&((a=this.source)==null||a.close(),this.source=void 0)}}onStatus(s){return this.statusEvents.on(s)}}function Cy(t){return{get:()=>$i(`${t}/trackers`,"GET"),test:s=>$i(`${t}/trackers/test`,"POST",s),connect:s=>$i(`${t}/trackers`,"PUT",s),forget:s=>$i(`${t}/trackers/credentials/${s}`,"DELETE")}}const $y=[{id:"markdown",name:"Local markdown",status:"available"},{id:"github",name:"GitHub Issues",status:"available"},{id:"linear",name:"Linear",status:"available"}],jh=[{id:"claude-code",name:"Claude Code",status:"primary",trailName:"claude"},{id:"codex",name:"Codex",status:"primary",trailName:"codex"},{id:"cursor",name:"Cursor",status:"planned",trailName:"cursor"}],by=jh[0],Sh={ink:"#16302a",shell:"#eae3cf",edge:"#c8bea2",glass:"#16302a",glow:"#b4e8c0",hat:"#8a5a38",band:"#e6dcc0",kerchief:"#c8581e",sky:"#d9e4d2",mid:"#7fa888",low:"#3f6b45"},Nh={on:"#e2711d",dim:"#a8501c",alert:"#ff5a48"},Ty={on:"#ffd166",dim:"#a8501c",alert:"#ff5a48"},$s=(t,s,r)=>`<path d="${t}" fill="none" stroke="${s}" stroke-width="${r}" stroke-linecap="round"/>`;function Ey(t,s){return t==="closed"?$s("M80 124h12M108 124h12",s,5.5):t==="aside"?$s("M86 124q6-8 12 0M114 124q6-8 12 0",s,5.5):t==="wide"?`<circle cx="86" cy="122" r="6.5" fill="${s}"/><circle cx="114" cy="122" r="6.5" fill="${s}"/>`:$s("M80 124q6-8 12 0M108 124q6-8 12 0",s,5.5)}function My(t,s){return t==="open"?`<ellipse cx="100" cy="138" rx="7" ry="5" fill="${s}"/>`:$s(t==="mid"?"M92 138h16":t==="aside"?"M104 138q7 2 13-2":"M92 136q8 6 16 0",s,5)}function Iy({eyes:t,mouth:s,light:r="on"},a){const l=Sh,u=`stroke="${l.ink}" stroke-width="6.5" stroke-linejoin="round"`;return[`<path d="M54 94V146A16 16 0 0 0 70 162H130A16 16 0 0 0 146 146V94Z" fill="${l.shell}" stroke="${l.ink}" stroke-width="8" stroke-linejoin="round"/>`,`<path d="M58 142H142V146A12 12 0 0 1 130 158H70A12 12 0 0 1 58 146Z" fill="${l.edge}"/>`,`<rect x="66" y="104" width="68" height="46" rx="8" fill="${l.glass}"/>`,`<path d="M100 170L82 162H118Z" fill="${l.kerchief}" stroke="${l.ink}" stroke-width="5" stroke-linejoin="round"/>`,Ey(t,l.glow),My(s,l.glow),`<path d="M70 94L76 56Q90 50 100 44Q110 50 124 56L130 94Z" fill="${l.hat}" ${u}/>`,`<path d="M71 82H129V94H71Z" fill="${l.band}" stroke="${l.ink}" stroke-width="4"/>`,`<path d="M34 98Q100 82 166 98Q100 114 34 98Z" fill="${l.hat}" ${u}/>`,`<path d="M100 52l6 9h-3l5 8H92l5-8h-3z" fill="${l.band}"/>`,`<rect x="113" y="83" width="10" height="10" rx="2" fill="${a[r]}" stroke="${l.ink}" stroke-width="3"/>`].join("")}let Ay=0;function Ly(t,{lamp:s=Nh,simple:r=!1}={}){const a=Sh,l=`scout-badge-${++Ay}`,u=r?"":`<path d="M0 108Q50 84 100 112T200 100V200H0z" fill="${a.mid}"/><path d="M0 150Q60 128 110 150T200 146V200H0z" fill="${a.low}"/><path d="M0 108Q50 84 100 112T200 100M0 150Q60 128 110 150T200 146" fill="none" stroke="${a.ink}" stroke-width="8"/>`,f=r?"translate(100 94) scale(1.28) translate(-100 -108)":"translate(100 100) scale(1.12) translate(-100 -108)";return['<circle cx="100" cy="100" r="99" fill="var(--tt-keyline, transparent)"/>',`<clipPath id="${l}"><circle cx="100" cy="100" r="88"/></clipPath>`,`<g clip-path="url(#${l})"><rect width="200" height="200" fill="${r?a.mid:a.sky}"/>${u}</g>`,`<g transform="${f}">${Iy(r?{eyes:"wide",mouth:"rest",light:t.light}:t,s)}</g>`,`<circle cx="100" cy="100" r="88" fill="none" stroke="${a.ink}" stroke-width="${r?16:12}"/>`].join("")}const Ch={crt:{id:"crt",name:"Day",blurb:"A CRT head in a ranger hat and neckerchief, in a circle with layered hills.",lamp:Nh,wave:{bar:"#6f8a78",lead:"#c8581e"}},night:{id:"night",name:"Night",blurb:"The same Scout, with the hat lamp burning bright, for the night theme.",lamp:Ty,wave:{bar:"#66828d",lead:"#e8833a"}}},Ry="crt",Oy={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"}},_y={idle:"WATCHING",speaking:"TALKING",alert:"NEEDS YOU",thinking:"THINKING"},nn={msPerChar:55,mouthHoldMs:110,blinkEveryMs:5600,blinkMs:140,thinkingStepMs:520};function Py(t){return t?/[aeiouy]/i.test(t)?"open":/[a-z0-9]/i.test(t)?"mid":"rest":"rest"}function Dy(t,s){return!t||!/[a-z0-9]/i.test(t)?0:/[aeiou]/i.test(t)?2+(t.charCodeAt(0)+s)%2:1+(t.charCodeAt(0)*7+s)%2}function zy(t,s,r){return Array.from({length:r},(a,l)=>{const u=s-(r-1-l);return u>=0&&u<t.length?Dy(t[u],u):0})}function $h({face:t={eyes:"open",mouth:"rest"},variant:s="crt",size:r,simple:a,className:l}){const{eyes:u,mouth:f,light:m}=t,g=x.useMemo(()=>Ly({eyes:u,mouth:f,light:m},{lamp:Ch[s].lamp,simple:a??r<28}),[u,f,m,s,a,r]);return i.jsx("svg",{className:l,width:r,height:r,viewBox:"0 0 200 200","aria-hidden":"true",dangerouslySetInnerHTML:{__html:g}})}function By(t){const[s,r]=x.useState(!1);return x.useEffect(()=>{if(!t){r(!1);return}let a;const l=setInterval(()=>{r(!0),a=setTimeout(()=>r(!1),nn.blinkMs)},nn.blinkEveryMs);return()=>{clearInterval(l),a&&clearTimeout(a)}},[t]),s}const Fy={xs:.8,sm:2,md:4,lg:6},Uy=40,jf=20,Sf="(prefers-reduced-motion: reduce)",Wy=40,Hy=350;function Vy(t,s){var m;const r=t.size??"md",a=t.state??"idle",l=((m=t.speaking)==null?void 0:m.trim())??"",u=l&&(a==="idle"||a==="speaking")?"speaking":a,f=r==="xs";return{size:r,text:l,effective:u,talking:u==="speaking"&&l.length>0,mini:f,framed:t.framed??!f,reduced:s||f}}const Ky=t=>t.length*nn.msPerChar,Qy=(t,s)=>s&&(t.effective==="idle"||t.effective==="speaking"||t.effective==="alert");function qy(t,s,r,a){const l=Oy[t.effective],u=r?"closed":l.eyes;let f=l.mouth,m=t.text.length-1;if(a)if(t.reduced)f="open";else{m=Math.min(t.text.length-1,Math.floor(s/nn.msPerChar));const p=Math.floor(s/nn.mouthHoldMs)*Math.round(nn.mouthHoldMs/nn.msPerChar);f=Py(t.text[Math.min(t.text.length-1,p)])}let g=l.light;return t.effective==="thinking"&&!t.reduced&&Math.floor(s/nn.thinkingStepMs)%2===1&&(g="on"),{eyes:u,mouth:f,light:g,cursor:m}}function Gy(t,s){const r=typeof t.size=="number"?t.size:Fy[t.size],a=t.reduced?Math.min(t.text.length-1,jf-1):s;return{base:r,px:Uy*r,bars:jf,waveCursor:a}}function Yy(t,{label:s,speechDone:r,cursor:a,caption:l}){const u=t.talking&&r?"idle":t.effective,f=_y[u],m=t.size==="md"||t.size==="lg"||typeof t.size=="number"&&t.size>=4;return{shownState:u,status:f,ariaLabel:`${s}, ${f.toLowerCase()}`,showCaption:l??m,shown:Jy(t,r,a)}}function Jy(t,s,r){return t.talking?t.reduced||s?t.text:t.text.slice(0,r+1):""}function Xy(){const[t,s]=x.useState(()=>{var r;return typeof window<"u"&&!!((r=window.matchMedia)!=null&&r.call(window,Sf).matches)});return x.useEffect(()=>{var l;const r=(l=window.matchMedia)==null?void 0:l.call(window,Sf);if(!r)return;const a=()=>s(r.matches);return a(),r.addEventListener("change",a),()=>r.removeEventListener("change",a)},[]),t}function Zy(t,s,r){const[a,l]=x.useState(0);return x.useEffect(()=>{if(l(0),!s)return;const u=performance.now(),f=setInterval(()=>l(performance.now()-u),r);return()=>clearInterval(f)},[t,s,r]),a}function ek(t){const{key:s,talking:r,at:a}=t,l=a!==void 0,u=Ky(t.text),[f,m]=x.useState(""),g=x.useRef(t.onSpeakEnd);g.current=t.onSpeakEnd,x.useEffect(()=>{if(!r||l)return;const N=setTimeout(()=>{var M;m(s),(M=g.current)==null||M.call(g)},u+Hy);return()=>clearTimeout(N)},[r,s,u,l]);const p=r&&f!==s,k=Zy(s,t.animate&&(p||t.thinking),p?Wy:nn.thinkingStepMs),v=a??k,w=r&&(l?v>=u:f===s);return{t:v,speechDone:w}}const tk=t=>t*2,Ml=3.5;function nk(t,s,r){return(t??[]).map((a,l)=>{const u=(1+2*a)*.5;return{x:l*2,y:(Ml-u)/2,width:1,height:u,fill:l>=s-2&&a>0?r.lead:r.bar}})}function sk({heights:t,bars:s,unit:r,colors:a}){const l=tk(s);return i.jsx("svg",{className:`scout-wave${t?" on":""}`,width:l*r,height:Ml*r,viewBox:`0 0 ${l} ${Ml}`,"aria-hidden":"true",children:nk(t,s,a).map((u,f)=>i.jsx("rect",{...u},f))})}function Li({state:t="idle",size:s="md",speaking:r,variant:a=Ry,framed:l,caption:u,label:f="Scout",onSpeakEnd:m,at:g,className:p,style:k}){const v=Vy({state:t,size:s,speaking:r,framed:l},Xy()),{text:w,effective:N,talking:M,reduced:S}=v,E=Ch[a],_=!S&&!(g!==void 0),O=`${N}|${a}|${w}`,{t:ee,speechDone:q}=ek({key:O,text:w,talking:M,thinking:N==="thinking",animate:_,at:g,onSpeakEnd:m}),V=By(Qy(v,_)),ie=M&&!q,{eyes:ae,mouth:K,light:xe,cursor:ze}=qy(v,ee,V,ie),{base:$e,px:L,bars:Q,waveCursor:se}=Gy(v,ze),ue=x.useMemo(()=>ie?zy(w,se,Q):null,[ie,w,se,Q]),{shownState:me,status:B,ariaLabel:F,showCaption:W,shown:b}=Yy(v,{label:f,speechDone:q,cursor:ze,caption:u}),P={...k,"--scout-u":`${$e}px`},fe=i.jsx("span",{className:"scout-sprite",children:i.jsx($h,{face:{eyes:ae,mouth:K,light:xe},variant:a,size:L,simple:v.mini})});return v.framed?i.jsxs("figure",{className:`scout scout-panel scout-${me} scout-v-${a} ${p??""}`,style:P,"data-state":me,children:[i.jsxs("figcaption",{className:"scout-head",children:[i.jsx("span",{className:"scout-name",children:f}),i.jsx("span",{className:"scout-sep",children:"//"}),i.jsx("span",{className:"scout-status",children:B})]}),i.jsxs("div",{className:"scout-feed",role:"img","aria-label":F,children:[fe,i.jsx(sk,{heights:ue,bars:Q,unit:$e,colors:E.wave})]}),W&&i.jsxs("p",{className:"scout-caption","aria-hidden":"true",children:[b,M&&!q&&!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-${me} ${p??""}`,style:P,role:"img","aria-label":F,children:fe})}let ik=0;const Qn="#16302a",Nf=t=>`<rect x="54" y="88" width="92" height="72" rx="16" fill="#f1e8d3" stroke="${Qn}" stroke-width="8"/><rect x="66" y="100" width="68" height="48" rx="8" fill="${Qn}"/>${t}`,rk='<path d="M78 124q6-8 12 0M110 124q6-8 12 0" fill="none" stroke="#b4e8c0" stroke-width="5.5" stroke-linecap="round"/><path d="M90 134q10 7 20 0" fill="none" stroke="#b4e8c0" stroke-width="5" stroke-linecap="round"/>',ok='<circle cx="84" cy="122" r="7" fill="#b4e8c0"/><circle cx="116" cy="122" r="7" fill="#b4e8c0"/>',Cf=`<path d="M100 90V70" stroke="${Qn}" stroke-width="8" stroke-linecap="round"/><path d="M100 80C84 80 70 68 68 48C88 48 100 60 100 80Z" fill="#3f6b45" stroke="${Qn}" stroke-width="5" stroke-linejoin="round"/><path d="M100 72C114 72 128 62 130 44C112 44 100 54 100 72Z" fill="#7fa888" stroke="${Qn}" stroke-width="5" stroke-linejoin="round"/>`,ak=`<path d="M0 108Q50 84 100 112T200 100V200H0z" fill="#7fa888"/><path d="M0 150Q60 128 110 150T200 146V200H0z" fill="#3f6b45"/><path d="M0 108Q50 84 100 112T200 100M0 150Q60 128 110 150T200 146" fill="none" stroke="${Qn}" stroke-width="8"/>`;function lk({simple:t=!1}={}){const s=`tt-logo-${++ik}`,r=t?`<g transform="translate(100 98) scale(1.42) translate(-100 -104)">${Cf}${Nf(ok)}</g>`:`<g transform="translate(100 102) scale(1.22) translate(-100 -104)">${Cf}${Nf(rk)}</g>`;return['<circle cx="100" cy="100" r="99" fill="var(--tt-keyline, transparent)"/>',`<clipPath id="${s}"><circle cx="100" cy="100" r="88"/></clipPath>`,`<g clip-path="url(#${s})"><rect width="200" height="200" fill="#d9e4d2"/>${t?"":ak}</g>`,r,`<circle cx="100" cy="100" r="88" fill="none" stroke="${Qn}" stroke-width="${t?16:12}"/>`].join("")}function ck({size:t=40,className:s}){const r=x.useMemo(()=>lk({simple:t<=32}),[t]);return i.jsx("svg",{className:s,width:t,height:t,viewBox:"0 0 200 200",role:"img","aria-label":"Teamtrail",dangerouslySetInnerHTML:{__html:r}})}const gt="trail lead";function uk({rt:t,guard:s,setMapId:r,mapIdRef:a,snapRef:l,setChatSession:u,setSelection:f}){const m={actorKind:"trail lead",journal:t.journal};return{selectMap:g=>r(g),openChat:g=>u(g),answer:(g,p)=>t.activity.answer(g,p,gt),claim:g=>s("Claim",()=>cf(t.adapter,a.current,g,{...m,assignee:gt})),release:g=>s("Release claim",()=>Vg(t.adapter,a.current,g,{...m,actor:gt})),releaseLease:g=>s("Release to queue",()=>t.leases.release(a.current,g,gt)),resolve:(g,p,k={})=>s("Resolve · record answer",async()=>{var w;const v=(w=l.current)==null?void 0:w.tickets.find(N=>N.id===g);v&&!v.assignee&&await cf(t.adapter,a.current,g,{...m,assignee:gt}),await Zg(t.adapter,a.current,g,{...m,answer:p,author:gt,decision:{...k,source:{kind:"lookout",label:"Ticket inspector"}}})}),supersede:(g,p)=>s(`Supersede ${g.id}`,async()=>{let k=g.id;if(g.derived){const{id:v,mapId:w,derived:N,supersededBy:M,...S}=g;k=(await Wl(t.adapter,g.mapId,S,{appendToTrail:!1})).id}await Kg(t.adapter,g.mapId,k,{...p,decidedBy:gt,participants:[{id:gt}],source:{kind:"lookout",label:"Logbook"}})}),graduate:({unspecified:g,...p})=>s(`Promote to ticket · ${g}`,async()=>{const k=await ev(t.adapter,a.current,g,p);f({kind:"ticket",id:k.id})}),ruleOut:(g,p)=>s("Rule out of scope",async()=>{await tv(t.adapter,a.current,g,{...m,reason:p,author:gt,source:{kind:"lookout",label:"Ticket inspector"}}),f(null)}),setMode:g=>s(`Trail mode · ${g}`,()=>Qg(t.adapter,a.current,g))}}const it=(...t)=>t.filter(Boolean).join(" ");async function dk(t,s){var u;const r=(s.assumptions??[]).map((f,m)=>({id:`S-${m+1}`,text:f,status:"holding",tickets:[]})),{map:a,tickets:l}=await Rg(t,{title:s.title,sections:{destination:s.destination,notes:s.notes,decisions:[],unspecified:[],outOfScope:[],...r.length?{assumptions:r}:{}},tickets:[{ref:"discovery",...Qv}]});return await fetch(`${ne.apiPrefix}/briefs/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:a.id,ticketId:(u=l[0])==null?void 0:u.id})}),a}function bh(t,s){const r=URL.createObjectURL(new Blob([s],{type:"text/markdown;charset=utf-8"}));Object.assign(document.createElement("a"),{href:r,download:t}).click(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}function Yn(t){const s=Math.max(0,Math.floor(t/1e3));return s<60?`${s}s`:s<3600?`${Math.floor(s/60)}m`:`${Math.floor(s/3600)}h`}function Th(t){const s=Math.max(0,Math.floor(t/1e3)),r=a=>String(a).padStart(2,"0");return`${r(Math.floor(s/3600))}:${r(Math.floor(s%3600/60))}:${r(s%60)}`}const Kl=t=>new Date(t).toTimeString().slice(0,8);function Pt(t){if(t<1e3)return`${Math.round(t)}ms`;const s=Math.round(t/1e3);return s<60?`${s}s`:s<3600?`${Math.floor(s/60)}m ${String(s%60).padStart(2,"0")}s`:`${Math.floor(s/3600)}h ${String(Math.floor(s%3600/60)).padStart(2,"0")}m`}function vo(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}const Ts=t=>`$${t<10?t.toFixed(2):t.toFixed(1)}`,Es=t=>new Date(t).toISOString().slice(0,10),Ql=t=>new Date(t).toTimeString().slice(0,5),fk=t=>`${Es(t)} ${Ql(t)}`,Eh=t=>{if(!t)return"";const s=Math.max(0,Math.round((Date.now()-t)/1e3));return s<60?`${s}s ago`:`${Math.round(s/60)}m ago`},yo=t=>t?new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",Mh={research:"Research",prototype:"Prototype",junction:"Junction",task:"Task",execute:"Execute",review:"Review"},Ih={decided:"Done",claimed:"Working",frontier:"Ready",blocked:"Backlog",parked:"Parked (plan-only)","out-of-scope":"Cancelled",verifying:"Verifying",rework:"Rework",held:"Blocked"},hk={decided:"done",claimed:"working",frontier:"ready",blocked:"backlog",parked:"parked","out-of-scope":"cancelled",verifying:"verifying",rework:"rework",held:"blocked"};function ql(t,s){return new Map((t??[]).filter(r=>r.mapId===s&&!r.returned).map(r=>[r.ticketId,r]))}const Gl=(t,s)=>`${t}/${s}`;let sn={reached:!1,live:!1,tickets:{}},Il=!1;const Al=new Set,Ll=new Set;function so(t){sn=t;for(const s of Al)s()}function $f(){fetch(`${ne.apiPrefix}/verification/sync`).then(t=>t.ok?t.json():Promise.reject()).then(t=>so({reached:!0,live:!0,status:t.status,tickets:Object.fromEntries(t.tickets.map(s=>[Gl(s.mapId,s.ticketId),s]))}),()=>sn.reached&&so({...sn,live:!1}))}function bf(){Il=!0,$f();const t=new EventSource(`${ne.apiPrefix}/events`);t.addEventListener("verification",s=>{const r=JSON.parse(s.data);if(r.kind==="evidence")for(const l of Ll)l();if(r.kind!=="sync")return;const a={...sn.tickets};for(const l of r.tickets)a[Gl(l.mapId,l.ticketId)]=l;so({reached:!0,live:!0,status:r.status,tickets:a})}),t.addEventListener("error",()=>sn.reached&&sn.live&&so({...sn,live:!1})),t.addEventListener("open",()=>sn.reached&&$f())}const Ms={subscribe(t){return Il||bf(),Al.add(t),()=>void Al.delete(t)},get:()=>sn,onEvidence(t){return Il||bf(),Ll.add(t),()=>void Ll.delete(t)},ticket:(t,s,r)=>t.tickets[Gl(s,r)]};function mk(t){if(t!=null&&t.flags.length)return t.flags.some(s=>s.severity==="alert")?"alert":"warn"}const Tf={onboarded:!1,tracker:"markdown",hitlTranscript:"summary",agent:by.id,github:{repo:""},linear:{team:""},briefing:{enabled:!0,awayMinutes:15},theme:"night"};function Yl(){try{const t={...Tf,...JSON.parse(localStorage.getItem(Dl)??"{}")};return["markdown","github","linear"].includes(t.tracker)||(t.tracker="markdown"),t}catch{return Tf}}function Ah(t){t==="auto"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=t}const pk=15*6e4;class gk{constructor(s){le(this,"leases",[]);le(this,"changes",new bs);le(this,"logged",new Set);le(this,"since",Date.now()-pk);this.activity=s}subscribe(s){return this.changes.on(s)}set(s){var r;this.leases=s;for(const a of s){const l=`${a.mapId}/${a.ticketId}/${(r=a.returned)==null?void 0:r.at}`;!a.returned||a.returned.at<this.since||this.logged.has(l)||(this.logged.add(l),this.activity.push({source:"system",level:"warn",ticketId:a.ticketId,text:ay(a)}))}this.changes.emit(s)}async release(s,r,a){const l=await fetch(`${ne.apiPrefix}/agents/leases/release`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:s,ticketId:r,by:a})});if(!l.ok)throw new Error((await l.json().catch(()=>({}))).error??`HTTP ${l.status}`)}}let Vt;const io=new Set,Ei=new Map;function Lh(t){Vt==null||Vt.addEventListener(t,s=>{for(const r of Ei.get(t)??[])r(s.data)})}function Rh(){if(!Vt){Vt=new EventSource(`${ne.apiPrefix}/events`),Vt.onmessage=t=>{const s=JSON.parse(t.data).path;if(typeof s=="string")for(const r of io)r(s)};for(const t of Ei.keys())Lh(t)}}function Oh(){const t=[...Ei.values()].some(s=>s.size>0);io.size||t||(Vt==null||Vt.close(),Vt=void 0)}function As(t){return io.add(t),Rh(),()=>{io.delete(t),Oh()}}function _h(t,s){let r=Ei.get(t);return r||(r=new Set,Ei.set(t,r),Lh(t)),r.add(s),Rh(),()=>{r.delete(s),Oh()}}function vk(t,s){return _h(t,r=>s(JSON.parse(r)))}const yk={async list(){return(await(await fetch(`${ne.apiPrefix}/list`)).json()).files},async read(t){const s=await fetch(`${ne.apiPrefix}/file?path=${encodeURIComponent(t)}`);if(!s.ok)throw new Error(`read ${t}: ${s.status}`);return s.text()},async write(t,s){const r=await fetch(`${ne.apiPrefix}/file?path=${encodeURIComponent(t)}`,{method:"PUT",body:s});if(!r.ok)throw new Error(`write ${t}: ${r.status}`)},watch(t){return As(t)}};function Ef(t,s){t.remoteAnswer=(a,l,u)=>{fetch(`${ne.apiPrefix}/agents/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:a.sessionId,questionId:a.id,text:l,author:u})}).then(async f=>{if(!f.ok)throw new Error((await f.json().catch(()=>({}))).error??`HTTP ${f.status}`)}).catch(f=>t.push({source:"system",level:"alert",sessionId:a.sessionId,text:`Answer not delivered to ${a.agent} · ${f.message}`}))};const r=new EventSource(`${ne.apiPrefix}/events`);r.addEventListener("agent",a=>t.syncRemote(JSON.parse(a.data))),r.addEventListener("leases",a=>s.set(JSON.parse(a.data).leases)),fetch(`${ne.apiPrefix}/agents/leases`).then(a=>a.ok?a.json():{leases:[]}).then(({leases:a})=>s.set(a)).catch(()=>{}),fetch(`${ne.apiPrefix}/agents`).then(a=>a.ok?a.json():{sessions:[]}).then(({sessions:a})=>[...a].reverse().forEach(l=>t.syncRemote(l))).catch(()=>{})}function Mf(t){const s=r=>`${Dl}:${t}:${r}`;return{get:r=>localStorage.getItem(s(r)),set:(r,a)=>{try{localStorage.setItem(s(r),a)}catch{}}}}const kk=["markdown","github","linear"];function xk(){const t=new URLSearchParams(location.search).get("tracker");return t&&kk.includes(t)?t:Yl().tracker}function wk(t){let s,r;const a=new av,l=new gk(a),u={},f=nv(ne.apiPrefix);if(t==="github"||t==="linear"){const p=new Ny(t,ne.apiPrefix);s=p,r=fetch(`${ne.apiPrefix}/trackers`).then(k=>k.json()).catch(()=>{}).then(k=>{p.location=(t==="github"?k==null?void 0:k.github.repo:[k==null?void 0:k.linear.teamKey,k==null?void 0:k.linear.projectName].filter(Boolean).join(" · "))||p.location;const v=Mf(`${t}:${p.location}`);u.presence=new hf(v),a.ledger=new mf(v),Ef(a,l)})}else s=new jy(yk,`./${ne.dataDir}`),r=fetch(`${ne.apiPrefix}/list`).then(p=>p.json()).catch(()=>({root:"default"})).then(({root:p})=>{const k=Mf(p);u.presence=new hf(k),a.ledger=new mf(k),Ef(a,l)});const m=dv(s),g=m.adapter;return{kind:t,ready:r,get presence(){return u.presence},adapter:g,journal:f,monitor:m,activity:a,leases:l}}const Qt=t=>t.status==="running",Ph=t=>Qt(t)&&!!t.waitingOn,jk={blocking:0,soon:1,fyi:2};function Sk(t,s,r){const a=t.filter(f=>f.sessionId===s),l=a.find(f=>f.id===r);if(l)return l;const u=f=>jk[f.urgency??"soon"];return[...a].sort((f,m)=>u(f)-u(m)||f.at-m.at)[0]}function ro({n:t,urgent:s,pop:r,hideZero:a}){return i.jsx("span",{className:it("badge",s&&"urgent",r&&s&&"pop",a&&!t&&"zero"),children:a&&!t?"":t})}function G({variant:t="default",size:s="md",on:r,className:a,type:l,...u}){return i.jsx("button",{type:l??"button",className:it("btn",t!=="default"&&t,s==="sm"&&"sm",r&&"on",a),...u})}function Et({as:t="div",tone:s,on:r,className:a,children:l,...u}){return i.jsx(t,{className:it("card",s,r&&"on",a),...u,children:l})}function lt({on:t,title:s,sub:r,disabled:a,onClick:l}){return i.jsxs(Et,{as:"button",type:"button",className:"choice",on:t,disabled:a,onClick:l,children:[i.jsx("b",{className:"choice-title t-row-title",children:s}),r&&i.jsx("span",{className:"c-sub",children:r})]})}function _e({children:t}){return i.jsx("div",{className:"empty",children:t})}const If=()=>{const t=document.documentElement.dataset.theme;return t?t==="night":matchMedia("(prefers-color-scheme: dark)").matches};function ko(){const[t,s]=x.useState(If);return x.useEffect(()=>{const r=()=>s(If()),a=matchMedia("(prefers-color-scheme: dark)");a.addEventListener("change",r);const l=new MutationObserver(r);return l.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{a.removeEventListener("change",r),l.disconnect()}},[]),t}function Nk(){const t=()=>window.innerWidth>=1440?"wide":window.innerWidth>=1024?"laptop":"mobile",[s,r]=x.useState(t);return x.useEffect(()=>{const a=()=>r(t());return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]),s}const Ck=15e3,Af=["pointerdown","pointermove","keydown","wheel","touchstart"];function $k(t,s,r,a){const[l,u]=x.useState(null),[f,m]=x.useState(!1),[g,p]=x.useState(!1),k=x.useRef(),v=x.useRef(Date.now()),w=x.useRef(!1),N=r.awayMinutes*6e4,M=x.useRef(s);M.current=s;const S=x.useRef(a);S.current=a;const E=x.useCallback((V,ie)=>{const ae=M.current;return Mv({snaps:Object.values(ae.allSnaps),decisions:ae.decisions,activity:ae.activity,ledger:t.activity.ledger,since:K=>{var xe;return V[K]??ie??((xe=ae.allSnaps[K])==null?void 0:xe.map.createdAt)??Date.now()},currentMapId:ae.mapId,attention:S.current})},[t]),I=x.useCallback((V=Date.now())=>{var ie;return(ie=t.presence)==null?void 0:ie.markSeen(M.current.maps.map(ae=>ae.id),V)},[t]),_=x.useCallback(()=>{const V=t.presence;if(!V)return;const ie=V.lastSeenAny();if(ie!==void 0&&Date.now()-ie>=N){const ae=V.snapshot();E(ae,ie).changed&&(k.current={seen:ae,any:ie},m(!0),r.enabled?u(ae):p(!0))}I()},[t,N,r.enabled,E,I]);x.useEffect(()=>{!s.loaded||w.current||!t.presence||(w.current=!0,_())},[s.loaded,t,_]),x.useEffect(()=>{const V=()=>{const K=Date.now()-v.current>=N;v.current=Date.now(),K&&w.current&&document.visibilityState==="visible"&&_()},ie=()=>{if(document.visibilityState!=="visible"){w.current&&I(Date.now()-v.current<N?Date.now():v.current);return}v.current=Date.now(),w.current&&_()};for(const K of Af)window.addEventListener(K,V,{passive:!0});document.addEventListener("visibilitychange",ie);const ae=setInterval(()=>{w.current&&document.visibilityState==="visible"&&I(v.current)},Ck);return()=>{for(const K of Af)window.removeEventListener(K,V);document.removeEventListener("visibilitychange",ie),clearInterval(ae)}},[N,_,I]);const O=x.useMemo(()=>{var V;return l?E(l,(V=k.current)==null?void 0:V.any):void 0},[l,E,s.allSnaps,s.decisions,s.activity,a]),ee=x.useMemo(()=>O?Rv(O):"",[O]);x.useEffect(()=>{l&&p(!1)},[l]);let q="none";return g?q="new":f&&(q="seen"),{shown:l!==null,status:q,briefing:O,line:ee,open:()=>{const V=k.current;V&&u(V.seen)},dismiss:()=>u(null)}}function bk(t){const[s,r]=x.useState(t.leases.leases);return x.useEffect(()=>t.leases.subscribe(r),[t]),s}function Tk(t){var B;const[s,r]=x.useState([]),[a,l]=x.useState(),[u,f]=x.useState(),[m,g]=x.useState({}),[p,k]=x.useState({}),[v,w]=x.useState(!1),[N,M]=x.useState(t.activity.snapshot),[S,E]=x.useState(t.monitor.health),I=bk(t);x.useEffect(()=>t.monitor.subscribe(E),[t]);const[_,O]=x.useState(null),[ee,q]=x.useState(),[V,ie]=x.useState(),ae=x.useRef(),K=x.useRef(),xe=x.useRef(new Set),ze=x.useRef();ze.current=u;const $e=x.useCallback(F=>{ae.current=F,l(F),O(null)},[]),L=x.useCallback(async()=>{var pe;const F=await t.adapter.listMaps();r(F);let W=ae.current;const b=K.current;b&&F.some(ce=>ce.id===b)?(K.current=void 0,W=b,W!==ae.current&&$e(W)):(!W||!F.some(ce=>ce.id===W))&&(W=(pe=F[0])==null?void 0:pe.id,$e(W));const[P,fe]=await Promise.all([Promise.all(F.map(ce=>t.adapter.loadMap(ce.id))),Promise.all(F.map(ce=>t.adapter.listDecisions(ce.id)))]);g(Object.fromEntries(P.map(ce=>[ce.map.id,ce]))),k(Object.fromEntries(F.map((ce,ke)=>[ce.id,fe[ke]]))),w(!0),f(P.find(ce=>ce.map.id===W))},[t,$e]);x.useEffect(()=>{let F,W=()=>{},b=()=>{},P=!0;const fe=()=>{clearTimeout(F),F=setTimeout(()=>void L().catch(he=>q(String(he))),40)},pe=(he,ve)=>Qt(he)&&t.activity.isRemote(he.id)&&(!ve||!he.mapId||he.mapId===ve),ce=he=>{var ve;return(ve=ze.current)==null?void 0:ve.tickets.find(be=>be.id===he)},ke=he=>{const ve=lv(he,ce),be=he.kind==="external.changed"&&t.activity.snapshot.sessions.some(Jn=>pe(Jn,he.mapId)),rt=!("mapId"in he)||!he.mapId||he.mapId===ae.current||he.kind==="map.created";ve&&!be&&rt&&t.activity.push(ve),fe()};return t.ready.then(()=>{P&&(W=t.adapter.subscribe(ke),b=t.activity.subscribe(M),t.activity.push({source:"system",level:"ok",text:`Online · tracker ${t.adapter.label.toLowerCase()} · ${t.adapter.location}`}),L().catch(he=>q(String(he))))}),()=>{P=!1,W(),b(),clearTimeout(F)}},[t,L]),x.useEffect(()=>{a&&t.adapter.loadMap(a).then(f)},[a,t]),x.useEffect(()=>{for(const F of N.sessions)F.mode!=="chart"||!F.mapId||!t.activity.isRemote(F.id)||xe.current.has(F.id)||(xe.current.add(F.id),!(F.status!=="running"&&Date.now()-(F.endedAt??0)>6e4)&&(K.current=F.mapId,L().catch(W=>q(String(W)))))},[N.sessions,t,L]);const Q=(B=N.pending[0])==null?void 0:B.sessionId;x.useEffect(()=>{if(!Q)return;const F=W=>t.activity.snapshot.sessions.some(b=>b.id===W&&Qt(b));ie(W=>F(W)?W:Q)},[Q,t]);const se=x.useCallback(async(F,W)=>{t.activity.push({source:"trail lead",agent:gt,level:"warn",text:F});try{q(void 0),await W()}catch(b){const P=b.message??String(b);q(P),t.activity.push({source:"trail lead",agent:gt,level:"alert",text:`Rejected · ${P}`})}},[t]),ue=x.useMemo(()=>uk({rt:t,guard:se,setMapId:$e,mapIdRef:ae,snapRef:ze,setChatSession:ie,setSelection:O}),[se,t,$e]),me=x.useMemo(()=>Object.values(m).flatMap(F=>pv(F,p[F.map.id]??[])).sort((F,W)=>W.decidedAt-F.decidedAt),[m,p]);return{maps:s,allSnaps:m,mapId:a,snap:u,activity:N,health:S,selection:_,setSelection:O,error:ee,chatSession:V,decisions:me,leases:I,loaded:v,actions:ue}}function In(t=1e3){const[s,r]=x.useState(Date.now());return x.useEffect(()=>{const a=setInterval(()=>r(Date.now()),t);return()=>clearInterval(a)},[t]),s}function Ek(){const[t,s]=x.useState(Yl),r=x.useCallback(a=>{s(l=>{const u={...l,...a};return localStorage.setItem(Dl,JSON.stringify(u)),u})},[]);return[t,r]}function Jl(){return x.useSyncExternalStore(Ms.subscribe,Ms.get)}function Xl({className:t,size:s=18}){return i.jsx("span",{className:t,"aria-hidden":"true",children:i.jsx($h,{size:s,variant:ko()?"night":"crt"})})}function qn({title:t,hint:s,art:r}){return i.jsxs("div",{className:r?"empty-state has-art":"empty-state",children:[r??i.jsx(Xl,{className:"es-mark"}),i.jsxs("div",{className:"es-words",children:[i.jsx("span",{className:"es-title",children:t}),s&&i.jsx("span",{className:"es-hint",children:s})]})]})}function He({label:t,children:s,className:r}){return i.jsxs("label",{className:it("field",r),children:[t,s]})}const Mk=x.forwardRef(function({value:s,onValueChange:r,onSubmit:a,action:l="Send",actionDisabled:u,className:f,...m},g){return i.jsxs("form",{className:it("input-row",f),onSubmit:p=>{p.preventDefault(),a(s)},children:[i.jsx("textarea",{ref:g,rows:1,value:s,onChange:p=>r(p.target.value),onKeyDown:p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),a(s))},...m}),i.jsx(G,{type:"submit",variant:"primary",disabled:u??(m.disabled||!s.trim()),children:l})]})});function Ri({text:t}){return i.jsx("span",{className:"info-tip","data-tip":t,"data-tip-scout":!0,tabIndex:0,role:"img","aria-label":t,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 Xe({as:t="span",variant:s="chip",hot:r,size:a,className:l,children:u,title:f}){return i.jsx(t,{className:it(s==="chip"?"chip-label":"mono-label",r&&"hot",a==="sm"&&(s==="chip"?"sm":"xs"),l),title:f,children:u})}const Ik="M25.53 10.5 A11 11 0 1 1 16 5",Ak="M20 5 L14.6 1.6 L14.6 8.4 Z";function Ls({variant:t="mark",state:s="ok",size:r=20,className:a="",title:l}){const u=r<=14?3:2.4;return i.jsxs("svg",{className:`scout-mark mm-${t} mm-${s} ${a}`,viewBox:"0 0 32 32",width:r,height:r,role:l?"img":void 0,"aria-label":l,"aria-hidden":l?void 0:!0,children:[t==="status"||t==="alert"?i.jsx("circle",{cx:"16",cy:"16",r:"11",fill:"none",stroke:"currentColor",strokeWidth:u,strokeDasharray:s==="syncing"?"5 3.6":void 0}):i.jsx("path",{d:Ik,fill:"none",stroke:"currentColor",strokeWidth:u,strokeLinecap:"butt"}),(t==="mark"||t==="action")&&i.jsx("path",{d:Ak,fill:"currentColor"}),t==="action"&&i.jsx("path",{d:"M13 11 L21.5 16 L13 21 Z",fill:"currentColor"}),(t==="mark"||t==="voice")&&i.jsx("circle",{cx:"16",cy:"16",r:t==="voice"?4:3.4,fill:"currentColor"}),t==="status"&&(s==="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"})),t==="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 oo({parts:t,className:s,as:r="div"}){const a=t.filter(l=>l!=null&&l!==!1&&l!=="");return i.jsx(r,{className:it("meta",s),children:a.map((l,u)=>i.jsxs("span",{children:[u>0&&" · ",l]},u))})}const Lk=t=>typeof t=="string"?{text:t}:t,Rk=t=>it(t.code&&"t-code",t.strong&&"strong",t.urgent&&"urgent",t.className);function ge(t){const s=t.parts.filter(r=>!!r&&(typeof r=="string"||!!r.text)).map(Lk);return!s.length&&!t.children?null:i.jsxs("span",{className:it("meta-line t-meta",t.className),children:[s.map((r,a)=>i.jsxs("span",{children:[a>0&&i.jsx("span",{className:"sep",children:" · "}),i.jsx("span",{className:Rk(r)||void 0,children:r.text})]},a)),t.children]})}function Ok({size:t=40,className:s}){return i.jsx(ck,{size:t,className:s})}function Ve({as:t="section",className:s,style:r,frameless:a,children:l,...u}){return i.jsx(t,{className:it("panel",a&&"frameless",s),style:r,...u,children:l})}function An({tone:t,className:s,children:r,title:a}){return i.jsx("span",{className:it("pill",t,s),title:a,children:r})}function Kt({label:t,value:s,layout:r="stack",urgent:a,title:l,className:u}){return i.jsxs("span",{className:it("readout",r!=="stack"&&r,a&&"urgent",u),title:l,children:[i.jsx("span",{className:"mono-label",children:t}),r==="inline"&&" ",i.jsx("b",{children:s})]})}function ct(t){const{as:s="div",edge:r="neutral"}=t,a=t.onOpen?"button":"div";return i.jsxs(s,{className:it("ds-row",`edge-${r}`,t.selected&&"on",t.className),children:[i.jsxs(a,{className:"ds-row-main",...t.onOpen?{type:"button",onClick:t.onOpen}:{},title:t.titleText,children:[i.jsxs("span",{className:"ds-row-top",children:[i.jsx("span",{className:"ds-row-title t-row-title",children:t.title}),t.trailing&&i.jsx("span",{className:"ds-row-trail t-meta",children:t.trailing})]}),t.context&&i.jsx("span",{className:"ds-row-context",children:t.context}),t.detail&&i.jsx("span",{className:"ds-row-detail t-meta",title:t.detailText,children:t.detail})]}),t.actions&&i.jsx("span",{className:"ds-row-actions",children:t.actions}),t.below&&i.jsx("div",{className:"ds-row-below",children:t.below})]})}const $n="#c8581e",_k={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:$n,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:$n})]}),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:$n})]}),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:$n,stroke:$n})]}),tent:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 4L2.5 20h19z"}),i.jsx("path",{d:"M12 11l-4 9h8z",fill:$n,stroke:$n}),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:$n})]})};function Dh({name:t}){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:_k[t]})}function on({title:t,count:s,right:r,hot:a,sub:l,children:u,className:f,info:m,icon:g}){return i.jsxs("header",{className:it("sec-h",l&&"sub",f),children:[u,g&&i.jsx(Dh,{name:g}),t!==void 0&&i.jsx(Xe,{as:l?"h3":"h2",hot:a,children:t}),m&&i.jsx(Ri,{text:m}),s,r!==void 0&&i.jsx("span",{className:"sec-h-right",children:r})]})}function wt(t){const{value:s,options:r,onChange:a}=t,[l,u]=x.useState(!1),[f,m]=x.useState(0),[g,p]=x.useState(),k=x.useRef(null),v=x.useRef(null),w=x.useId(),N=r.find(I=>I.value===s);x.useLayoutEffect(()=>{if(!l||!k.current)return;const I=k.current.getBoundingClientRect();p({left:I.left,top:I.bottom+4,minWidth:I.width})},[l]),x.useEffect(()=>{if(!l)return;const I=O=>{var ee,q;O.target instanceof Node&&((ee=v.current)!=null&&ee.contains(O.target)||(q=k.current)!=null&&q.contains(O.target))||u(!1)},_=()=>u(!1);return document.addEventListener("mousedown",I),window.addEventListener("resize",_),window.addEventListener("scroll",_,!0),()=>{document.removeEventListener("mousedown",I),window.removeEventListener("resize",_),window.removeEventListener("scroll",_,!0)}},[l]),x.useEffect(()=>{var I,_;l&&((_=(I=v.current)==null?void 0:I.querySelector(`[data-i="${f}"]`))==null||_.scrollIntoView({block:"nearest"}))},[l,f]);const M=()=>{m(Math.max(0,r.findIndex(I=>I.value===s))),u(!0)},S=I=>{var O;const _=r[I];u(!1),(O=k.current)==null||O.focus(),_&&_.value!==s&&a(_.value)},E=I=>{if(!l){["ArrowDown","ArrowUp","Enter"," "].includes(I.key)&&(I.preventDefault(),M());return}const _=O=>m(ee=>(ee+O+r.length)%r.length);if(I.key==="ArrowDown")_(1);else if(I.key==="ArrowUp")_(-1);else if(I.key==="Home")m(0);else if(I.key==="End")m(r.length-1);else if(I.key==="Enter"||I.key===" ")S(f);else{if(I.key==="Escape"||I.key==="Tab")return u(!1);if(I.key.length===1){const O=r.findIndex(ee=>ee.label.toLowerCase().startsWith(I.key.toLowerCase()));O>=0&&m(O);return}else return}I.preventDefault()};return i.jsxs(i.Fragment,{children:[i.jsxs("button",{ref:k,type:"button",className:it("select",t.compact&&"compact",l&&"open",t.className),role:"combobox","aria-haspopup":"listbox","aria-expanded":l,"aria-controls":w,"aria-label":t["aria-label"],"aria-activedescendant":l?`${w}-${f}`:void 0,disabled:t.disabled,onClick:()=>l?u(!1):M(),onKeyDown:E,children:[i.jsx("span",{className:"select-value",children:(N==null?void 0:N.label)??"—"}),i.jsx("span",{className:"select-caret","aria-hidden":"true"})]}),l&&g&&i.jsx("ul",{ref:v,id:w,className:"select-menu",role:"listbox",style:g,children:r.map((I,_)=>i.jsxs("li",{id:`${w}-${_}`,"data-i":_,role:"option","aria-selected":I.value===s,className:it(_===f&&"active"),onMouseEnter:()=>m(_),onMouseDown:O=>O.preventDefault(),onClick:()=>S(_),children:[i.jsx("span",{className:"select-label",children:I.label}),I.hint&&i.jsx("span",{className:"select-hint",children:I.hint})]},I.value))})]})}function Zl(t){return i.jsx("div",{className:`tabs ${t.className??""}`,role:"tablist",children:t.items.map(s=>i.jsxs("button",{role:"tab","aria-selected":t.value===s.id,className:`tab ${t.value===s.id?"on":""}`,onClick:()=>t.onChange(s.id),children:[s.label,s.n!==void 0&&i.jsx("span",{className:"n",children:s.n})]},s.id))})}const Pk=350;function Dk(){const[t,s]=x.useState(null);if(x.useEffect(()=>{let a=0,l=null;const u=()=>{window.clearTimeout(a),l=null,s(null)},f=k=>{const v=k.getAttribute("data-tip");if(!v)return;const w=k.getBoundingClientRect(),N=w.bottom+60>window.innerHeight;s({text:v,x:w.left+w.width/2,y:N?w.top-8:w.bottom+8,above:N,scout:k.hasAttribute("data-tip-scout")})},m=k=>{var N,M;const v=(M=(N=k.target)==null?void 0:N.closest)==null?void 0:M.call(N,"[data-tip], [title]");if(!v||v instanceof SVGElement)return null;const w=v.getAttribute("title");return w&&(v.setAttribute("data-tip",w),v.removeAttribute("title")),v},g=k=>{if(k.pointerType==="touch")return;const v=m(k);v!==l&&(u(),v&&(l=v,a=window.setTimeout(()=>l===v&&f(v),k.type==="focusin"?0:Pk)))},p=k=>{l&&!l.contains(k.relatedTarget)&&u()};return document.addEventListener("pointerover",g),document.addEventListener("pointerout",p),document.addEventListener("focusin",g),document.addEventListener("focusout",u),document.addEventListener("pointerdown",u),window.addEventListener("scroll",u,!0),window.addEventListener("keydown",u),()=>{u(),document.removeEventListener("pointerover",g),document.removeEventListener("pointerout",p),document.removeEventListener("focusin",g),document.removeEventListener("focusout",u),document.removeEventListener("pointerdown",u),window.removeEventListener("scroll",u,!0),window.removeEventListener("keydown",u)}},[]),!t)return null;const r=Math.min(Math.max(t.x,140),window.innerWidth-140);if(t.scout){const a=Math.min(Math.max(t.x-24,8),window.innerWidth-340);return i.jsxs("div",{className:`scout-tip ${t.above?"above":""}`,role:"tooltip",style:{left:a,top:t.y,transform:t.above?"translateY(-100%)":void 0},children:[i.jsx(Li,{size:1,framed:!1,speaking:t.text,className:"scout-tip-face"}),i.jsx("p",{className:"scout-tip-bubble",children:t.text})]})}return i.jsx("div",{className:`tooltip ${t.above?"above":""}`,role:"tooltip",style:{left:r,top:t.y,transform:`translate(-50%, ${t.above?"-100%":"0"})`},children:t.text})}function zh({as:t="span",className:s}){return i.jsx(t,{className:s,children:ne.name})}function Bh(t){return t.bare?i.jsx("div",{className:`zone-b ${t.className??""}`,children:t.children}):i.jsxs(Ve,{className:`zone ${t.className??""}`,style:t.area?{gridArea:t.area}:void 0,children:[i.jsx(on,{className:"zone-title",icon:t.icon,title:t.title,info:t.info,count:t.count,right:t.right??null}),i.jsx("div",{className:"zone-b",children:t.children})]})}function Ss(t){return t.children.length?i.jsxs("div",{className:`bf-list ${t.urgent?"urgent":""}`,children:[i.jsx("span",{className:"mono-label",children:t.title}),i.jsx("ul",{children:t.children})]}):null}function Gr(t){return i.jsx("li",{children:i.jsxs("button",{className:"bf-row",onClick:t.onClick,title:t.title,children:[i.jsx("span",{className:"key t-code",children:t.k}),i.jsx("span",{className:"t",children:t.text}),t.meta&&i.jsx("span",{className:"t-meta",children:t.meta})]})})}function Si(t){return i.jsxs(Et,{tone:t.urgent?"urgent":void 0,className:`bf-tile ${t.className??""}`,children:[i.jsx("span",{className:"mono-label",children:t.label}),i.jsx("b",{children:t.value}),t.sub&&i.jsx(ge,{parts:[],children:t.sub})]})}const zk=864e5;function Bk(t,s){const r=new Date(t),a=r.toTimeString().slice(0,5),l=new Date(s).toDateString(),u=new Date(s-zk).toDateString();let f=` ${r.toLocaleDateString(void 0,{month:"short",day:"numeric"})}`;return r.toDateString()===l?f="":r.toDateString()===u&&(f=" yesterday"),`Since ${a}${f} · ${Pt(s-t)}`}function Fk(t){const{briefing:s,bp:r,onClose:a}=t;x.useEffect(()=>{const v=w=>w.key==="Escape"&&a();return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[a]);const l=s==null?void 0:s.trails.flatMap(v=>v.waiting).sort((v,w)=>v.at-w.at)[0],u=s==null?void 0:s.totals,f=((s==null?void 0:s.trails.length)??0)>1,m=r==="mobile",g=v=>{var w,N;return v.ticketId&&((N=(w=t.snaps[v.mapId])==null?void 0:w.tickets.find(M=>M.id===v.ticketId))==null?void 0:N.title)||v.text},p=v=>{var w,N;return v.ticketId&&((N=(w=t.snaps[v.mapId])==null?void 0:w.tickets.find(M=>M.id===v.ticketId))==null?void 0:N.key)||v.agent},k=v=>{const w=(I,_)=>i.jsx(Gr,{k:I.key,text:I.title,meta:_,onClick:()=>t.onTicket(v.mapId,I.id)},I.id),N=(I,_)=>i.jsx(Gr,{k:I.id,text:I.summary||I.answer,title:I.risk?`${I.question}
118
+
119
+ ${I.risk.reason}`:I.question,meta:_,onClick:()=>t.onDecision(I.id)},I.id),M=ry(v.agentDecisions).flatMap(I=>I.decisions.map(_=>N(_,I.label))),S=[i.jsx(Ss,{title:"Done",children:v.done.map(I=>w(I))},"done"),i.jsx(Ss,{title:"Ruled out",children:m?[]:v.ruledOut.map(I=>w(I))},"oos"),i.jsx(Ss,{title:"Blocked",children:v.blocked.map(I=>w(I.ticket,`needs ${I.on.map(_=>_.key).join(", ")}`))},"blocked")],E=[i.jsx(Ss,{title:"Waiting on you",urgent:!0,children:v.waiting.map(I=>i.jsx(Gr,{k:p(I),text:g(I),meta:s.now-I.at<6e4?"now":Pt(s.now-I.at),title:I.text,onClick:()=>t.onAnswer(I)},I.id))},"waiting"),i.jsx(Ss,{title:"Agent decisions",children:m?[]:M},"agent"),i.jsx(Ss,{title:"Active sessions",children:m?[]:v.active.map(I=>{var O;const _=I.ticketId?(O=t.snaps[v.mapId])==null?void 0:O.tickets.find(ee=>ee.id===I.ticketId):void 0;return i.jsx(Gr,{k:(_==null?void 0:_.key)??I.agent,text:_?`${_.title} · ${I.stepLabel}`:I.stepLabel,meta:`${I.step}/${I.total}`,onClick:()=>t.onSession(I)},I.id)})},"active")];return i.jsxs("section",{className:"bf-trail",children:[f&&i.jsxs("div",{className:"bf-trail-h",children:[i.jsx("span",{className:"key",children:v.key})," ",v.title]}),i.jsxs("div",{className:"bf-cols",children:[i.jsx("div",{children:S}),i.jsx("div",{children:E})]})]},v.mapId)};return i.jsx("div",{className:"scrim",onClick:a,children:i.jsxs(Ve,{as:"div",className:"dialog briefing",role:"dialog","aria-label":"While you were away",onClick:v=>v.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:"While you were away"}),s&&s.trails.length>0&&i.jsx(Xe,{className:"bf-since",children:Bk(s.since,s.now)}),i.jsx("button",{className:"icon-btn",onClick:a,"aria-label":"Close",children:"×"})]}),i.jsxs(Et,{className:"bf-scout",children:[i.jsx(Li,{size:m?2:"sm",speaking:t.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:t.line||"Nothing new since you were last here."})]})]}),s&&u&&s.trails.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"bf-tiles",children:[i.jsx(Si,{label:"Done",value:u.done,sub:u.ruledOut?`${u.ruledOut} ruled out`:void 0}),i.jsx(Si,{label:"Blocked",value:u.blocked,sub:u.blocked?"Needs your answer":void 0}),i.jsx(Si,{label:"Waiting on you",value:u.waiting,sub:Uk(u.oldestWaitMs),urgent:u.waiting>0}),i.jsx(Si,{label:"Agent decisions",value:u.agentDecisions,className:"opt"}),i.jsx(Si,{label:"Spend",value:Ts(u.usage.costUsd),sub:`${vo(u.usage.inputTokens+u.usage.outputTokens)} tokens · ${u.usage.sessions} sessions${u.active?` · ${u.active} active`:""}`})]}),i.jsx("div",{className:"bf-body",children:s.trails.map(k)})]}),i.jsxs("footer",{children:[i.jsx(G,{onClick:a,children:"Dismiss"}),l?i.jsxs(G,{variant:"urgent",onClick:()=>t.onAnswer(l),children:[i.jsx(Ls,{variant:"alert",size:13}),"Answer first decision"]}):i.jsx(G,{variant:"primary",onClick:t.onResume,children:"Resume trail"})]})]})})}function Uk(t){if(t!==void 0)return t<6e4?"Just asked":`Oldest ${Pt(t)}`}function Wk(t){const{brief:s,bp:r}=t;return i.jsx(Fk,{briefing:s.briefing,line:s.line,snaps:t.snaps,bp:r,onClose:s.dismiss,onTicket:(a,l)=>{s.dismiss(),t.openTicket(a,l)},onAnswer:a=>{s.dismiss(),t.closeDecisions(),t.openChat(a.sessionId,a.ticketId,a.mapId)},onSession:a=>{s.dismiss(),t.closeDecisions(),t.openChat(a.id,a.ticketId,a.mapId)},onDecision:a=>{s.dismiss(),t.openDecisions(a)},onResume:()=>{s.dismiss(),t.closeDecisions(),r==="mobile"&&t.showPhoneHome()}})}const Hk={passed:"checks passed",failing:"checks failing",pending:"checks pending",unknown:"checks unknown",none:"no checks"};function Vk({mapId:t,ticketId:s}){const r=Ms.ticket(Jl(),t,s);if(!r)return null;const a=r.pr;return i.jsxs("div",{className:"pr-flags",children:[i.jsxs("span",{className:`pr-chip pr-${(a==null?void 0:a.state)??"unread"}`,title:a?`${a.title}
120
+ ${a.headRef}`:void 0,children:[a?i.jsxs("a",{href:a.url,target:"_blank",rel:"noreferrer noopener",children:["PR #",a.number," · ",a.state,a.draft?" · draft":""]}):`PR #${r.link.number}`,i.jsx("span",{className:`ci ci-${r.checksSummary}`,children:Hk[r.checksSummary]}),i.jsx("span",{className:"when",children:Kk(r)})]}),r.flags.map(l=>i.jsx(An,{className:`flag flag-${l.severity}`,title:l.text,children:l.kind},l.kind))]})}function Kk(t){return t.error?"sync failed":t.syncedAt?Eh(t.syncedAt):"not synced yet"}const Qk={ok:"ok",failed:"error",stale:"syncing",unknown:"idle",off:"idle"};function qk({now:t}){const s=Jl();if(!s.reached)return null;const r=iv(s.live?s.status:null,t);return i.jsxs("span",{className:`tracker-chip pr-sync tone-${r.tone}`,title:r.title,children:[i.jsx(Xe,{size:"sm",children:"CI"}),i.jsx(Ls,{variant:"status",state:Qk[r.tone],size:13,className:"sync-glyph"}),i.jsx("span",{className:"tl",children:r.label})]})}function Gk(t){const[s,r]=x.useState(!1),a=x.useRef(null);return x.useEffect(()=>{if(!s)return;const l=u=>{var m;(u instanceof KeyboardEvent?u.key==="Escape":!((m=a.current)!=null&&m.contains(u.target)))&&r(!1)};return window.addEventListener("mousedown",l),window.addEventListener("keydown",l),()=>{window.removeEventListener("mousedown",l),window.removeEventListener("keydown",l)}},[s]),i.jsxs("div",{className:"header-menu",ref:a,children:[i.jsxs(G,{variant:"ghost","aria-haspopup":"menu","aria-expanded":s,on:s,onClick:()=>r(!s),children:[t.label," ",t.badge," ",i.jsx("span",{className:"caret",children:"▾"})]}),s&&i.jsx("div",{className:"header-menu-list",role:"menu",children:t.children(()=>r(!1))})]})}const Yk={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 Jk(t){const s=t.briefingStatus==="new";return i.jsx(Gk,{label:"Records",badge:i.jsxs(i.Fragment,{children:[t.knowledge>0&&i.jsx("span",{className:"n hot",children:t.knowledge}),s&&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:t.briefingStatus==="none"&&!t.briefingOpen,title:Yk[t.briefingStatus],onClick:()=>{r(),t.onBriefing()},children:[i.jsx("span",{children:"Trip report"}),s&&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(),t.onKnowledge()},children:[i.jsx("span",{children:"Field guide"}),t.knowledge>0&&i.jsx("span",{className:"n hot",children:t.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(),t.onDecisions()},children:[i.jsx("span",{children:"Logbook"}),i.jsx("span",{className:"n",children:t.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(),t.onStats()},children:i.jsx("span",{children:"Trail stats"})})]})})}const Xk=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"})]}),Zk=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 ex({onToggle:t}){const s=ko(),r=s?"Switch to the day theme":"Switch to the night theme";return i.jsx(G,{variant:"ghost",className:"icon-only","aria-label":r,"data-tip":r,onClick:()=>t(!s),children:i.jsx("svg",{viewBox:"0 0 18 18",width:"16",height:"16","aria-hidden":"true",children:s?Xk:Zk})})}const tx={idle:"Idle",syncing:"Syncing",ok:"Synced",error:"Sync error"};function nx({label:t,health:s,now:r}){const a=[`${tx[s.status]} · ${s.writes} writes · ${s.errors} errors`,s.lastWriteAt?`Last write ${Pt(s.lastWriteMs??0)}, ${Pt(r-s.lastWriteAt)} ago`:"No writes yet",s.lastError].filter(Boolean).join(`
121
+ `);return i.jsxs("span",{className:`tracker-chip sync-${s.status}`,title:a,children:[i.jsx(Xe,{size:"sm",children:"Tracker"}),i.jsx(Ls,{variant:"status",state:s.status,size:13,className:"sync-glyph"}),i.jsx("span",{className:"tl",children:t})]})}function sx(t){const[s,r]=x.useState(!1),a=x.useRef(null);x.useEffect(()=>{if(!s)return;const m=g=>{var p;(g instanceof KeyboardEvent?g.key==="Escape":!((p=a.current)!=null&&p.contains(g.target)))&&r(!1)};return window.addEventListener("mousedown",m),window.addEventListener("keydown",m),()=>{window.removeEventListener("mousedown",m),window.removeEventListener("keydown",m)}},[s]);const l=Object.values(t.snaps).sort((m,g)=>g.map.createdAt-m.map.createdAt),u=m=>t.activity.pending.filter(g=>g.mapId===m).length,f=t.activity.pending.filter(m=>{var g;return m.mapId!==((g=t.map)==null?void 0:g.id)}).length;return i.jsxs("div",{className:"trail-switcher",ref:a,children:[i.jsxs("button",{className:"trail-btn",onClick:()=>r(m=>!m),"aria-haspopup":"menu","aria-expanded":s,"data-tip":"Switch trail, or start a new one",children:[i.jsx("span",{className:"trail-title",children:t.map?`${t.map.key} ${t.map.title}`:"No trail"}),f>0&&i.jsx(ro,{n:f,urgent:!0}),i.jsx("span",{className:"caret",children:"▾"})]}),s&&i.jsxs("div",{className:"trail-menu",role:"menu",children:[i.jsx(Xe,{variant:"plain",className:"menu-h",children:"Trails"}),l.map(m=>{var k;const g=ch(m),p=u(m.map.id);return i.jsxs("button",{role:"menuitem",className:`trail-item ${m.map.id===((k=t.map)==null?void 0:k.id)?"on":""}`,onClick:()=>{t.onSelectMap(m.map.id),r(!1)},children:[i.jsx("span",{className:"key",children:m.map.key}),i.jsx("span",{className:"mi-title",children:m.map.title}),i.jsxs("span",{className:"mi-progress",children:[g.decided,"/",g.total]}),i.jsx(ro,{n:p,urgent:!!p,hideZero:!0})]},m.map.id)}),i.jsx("button",{role:"menuitem",className:"trail-item new",onClick:()=>{r(!1),t.onNewTrail()},children:"+ New trail"})]})]})}function ix(t){const{map:s}=t,r=In(1e3),a=t.activity.pending.length,l=s&&t.snaps[s.id],u=l&&ch(l),f=s&&uh(t.activity,s.id);return i.jsxs(Ve,{as:"header",className:"header",children:[i.jsxs("div",{className:"h-title",children:[i.jsxs("div",{className:"h-line1",children:[i.jsx("span",{className:"repo",children:t.repo}),i.jsx("span",{className:"sep",children:"/"}),i.jsx(sx,{...t})]}),i.jsxs("div",{className:"h-dest",title:s==null?void 0:s.sections.destination,children:[i.jsx(Xe,{size:"sm",children:"Destination"}),(s==null?void 0:s.sections.destination)??"—"]})]}),i.jsxs("div",{className:"h-right",children:[i.jsx(nx,{label:t.trackerLabel,health:t.health,now:r}),i.jsx(qk,{now:r}),s&&u&&i.jsxs("span",{className:"trail-meta",children:[i.jsx(Kt,{label:"Trail T+",value:Th(r-s.createdAt),title:"Trail elapsed time, since it was charted"}),i.jsx(Kt,{label:"Done",value:`${u.decided}/${u.total}`}),f&&i.jsx(Kt,{className:"spend",label:"Spent",value:`${Ts(f.costUsd)} · ${vo(f.inputTokens+f.outputTokens)} tok`,title:["Model spend and tokens for this trail, across every session",...fh(t.activity,s.id).map(m=>dh[m].text)].join(`
122
+ `)})]}),t.attention,!t.attention&&a>0&&i.jsxs("span",{className:"waiting-chip",title:`${a} waiting on you`,children:[i.jsx(Ls,{variant:"alert",size:14}),i.jsx("b",{children:a}),i.jsx("span",{className:"wl",children:" waiting on you"})]}),t.slackAlert&&i.jsx(G,{size:"sm",variant:"urgent",onClick:t.onSlack,title:t.slackAlert,children:"Slack disconnected"}),s&&i.jsx(G,{variant:"ghost",className:"mode-chip",onClick:t.onToggleMode,"data-tip":s.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:s.mode==="plan-only"?"Plan only":"Plan + execute"}),i.jsx(Jk,{decisions:t.decisions,onDecisions:t.onDecisions,onStats:t.onStats,knowledge:t.knowledge,onKnowledge:t.onKnowledge,briefingOpen:t.briefingOpen,briefingStatus:t.briefingStatus,onBriefing:t.onBriefing}),i.jsx(ex,{onToggle:t.onToggleTheme}),i.jsx(G,{variant:"ghost",onClick:t.onSettings,"data-tip":"Tracker, verification, appearance and integrations",children:"Settings"})]})]})}const Fh=x.createContext(null);function Rs(){const t=x.useContext(Fh);if(!t)throw new Error("useKnowledge needs a KnowledgeContext provider");return t}function rx({snap:t,t:s}){const r=Rs();if(!r.entries.length||s.state==="closed")return null;const a=xh(r.entries,{trailKey:t.map.key,ticket:{type:s.type,title:s.title,body:s.body},paths:wh(`${s.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 · ",a.length]}),a.length>0&&i.jsx("ul",{className:"item-list inline",children:a.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(ge,{parts:[{text:l.id,code:!0},l.status==="assumption"&&"assumption",l.mayBeOutdated&&{text:"may be outdated",className:"warn"}]})]},l.id))})]})}const ox={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 ax({e:t}){const s=Rs(),[r,a]=x.useState(!1),[l,u]=x.useState(t.title),[f,m]=x.useState(t.body);x.useEffect(()=>{a(!1),u(t.title),m(t.body)},[t.id,t.title,t.body]);const g=s.stale[t.id];return i.jsxs("div",{className:"kn-detail",children:[i.jsx(ge,{parts:[{text:t.id,code:!0},t.kind.replace("-"," "),t.status]}),r?i.jsxs(i.Fragment,{children:[i.jsx(He,{label:"Title",children:i.jsx("input",{value:l,onChange:p=>u(p.target.value)})}),i.jsx(He,{label:"Body",children:i.jsx("textarea",{rows:8,value:f,onChange:p=>m(p.target.value)})})]}):i.jsxs(i.Fragment,{children:[i.jsx("h3",{className:"t-title",children:t.title}),i.jsx("p",{className:"kn-body",children:t.body})]}),i.jsx("p",{className:"dim",children:ox[t.status]}),t.flag&&i.jsxs("p",{className:"kn-warn",children:["Flagged by ",t.flag.by,": ",t.flag.reason]}),g&&t.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:[t.scope.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Applies to"}),i.jsx("dd",{children:t.scope.join(", ")})]}),t.tags.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Tags"}),i.jsx("dd",{children:t.tags.join(", ")})]}),i.jsx("dt",{children:"From"}),i.jsx("dd",{children:[t.createdBy,...t.sources].join(" · ")}),t.anchors.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"About files"}),i.jsx("dd",{children:t.anchors.map(p=>p.path).join(", ")})]})]}),s.error&&i.jsx("p",{className:"vf-err",children:s.error}),i.jsx("div",{className:"actions",children:r?i.jsxs(i.Fragment,{children:[i.jsx(G,{variant:"ghost",onClick:()=>a(!1),children:"Cancel"}),i.jsx(G,{variant:"primary",disabled:!l.trim(),onClick:()=>void s.call(t.id,{kind:"edit",title:l,body:f}).then(p=>p&&a(!1)),children:"Save"})]}):i.jsxs(i.Fragment,{children:[(t.status!=="confirmed"||g)&&i.jsx(G,{variant:"primary",onClick:()=>void s.call(t.id,{kind:"confirm"}),children:t.status==="confirmed"?"Re-confirm":"Confirm"}),t.status!=="assumption"&&t.status!=="outdated"&&i.jsx(G,{onClick:()=>void s.call(t.id,{kind:"assumption"}),children:"Keep as assumption"}),t.flag&&i.jsx(G,{onClick:()=>void s.call(t.id,{kind:"resolve-flag"}),children:"Resolve flag"}),i.jsx(G,{variant:"ghost",onClick:()=>a(!0),children:"Edit"}),t.status!=="outdated"&&i.jsx(G,{variant:"ghost",onClick:()=>void s.call(t.id,{kind:"outdated"}),children:"Mark outdated"})]})})]})}const lx={suggested:"Suggested",confirmed:"Confirmed",assumption:"Assumption",outdated:"Outdated"};function cx(){const t=Rs(),[s,r]=x.useState("review"),[a,l]=x.useState(""),[u,f]=x.useState(""),[m,g]=x.useState();x.useEffect(()=>{if(!t.open)return;const S=E=>E.key==="Escape"&&t.setOpen(!1);return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[t]);const p=S=>S.status==="suggested"||!!S.flag||!!t.stale[S.id]&&S.status!=="outdated",k=(S,E)=>E==="all"?!0:E==="review"?p(S):S.status===E,v=x.useMemo(()=>{const S=u.trim().toLowerCase();return t.entries.filter(E=>k(E,s)&&(!a||E.kind===a)&&(!S||`${E.id} ${E.title} ${E.body} ${E.tags.join(" ")}`.toLowerCase().includes(S)))},[t.entries,t.stale,s,a,u]);if(!t.open)return null;const w=v.find(S=>S.id===m)??v[0],N=S=>t.entries.filter(E=>k(E,S)).length,M=[["review","Needs you"],["confirmed","Confirmed"],["assumption","Assumptions"],["outdated","Outdated"],["all","All"]];return i.jsx("div",{className:"scrim",onClick:()=>t.setOpen(!1),children:i.jsxs(Ve,{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(Ri,{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:[M.map(([S,E])=>i.jsxs("button",{className:`chip ${s===S?"on":""}`,onClick:()=>r(S),children:[E," ",i.jsx("span",{className:"n",children:N(S)})]},S)),i.jsx(wt,{compact:!0,"aria-label":"Kind",value:a,onChange:l,options:[{value:"",label:"Any kind"},...Jv.map(S=>({value:S,label:S.replace("-"," ")}))]}),i.jsx("input",{className:"kn-search",placeholder:"Search",value:u,onChange:S=>f(S.target.value)})]}),i.jsxs("div",{className:"kn-body-grid",children:[i.jsx("ul",{className:"kn-list",children:v.length?v.map(S=>i.jsx(ct,{as:"li",className:`kn-row st-${S.status}`,edge:p(S)?"attention":"neutral",selected:S===w,onOpen:()=>g(S.id),title:S.title,titleText:S.title,context:i.jsx(ge,{parts:[{text:S.id,code:!0},S.kind.replace("-"," "),p(S)&&S.status!=="suggested"?"Needs a check":lx[S.status]]})},S.id)):i.jsx(_e,{children:s==="review"?"Nothing needs you":"No entries"})}),w?i.jsx(ax,{e:w}):i.jsx(_e,{children:"Pick an entry"})]})]})})}function ec({draft:t,label:s="Save as knowledge"}){const r=Rs(),[a,l]=x.useState();return a?i.jsxs(G,{size:"sm",variant:"ghost",onClick:()=>r.setOpen(!0),"data-tip":"Open it in the field guide to confirm it",children:["Saved as ",a]}):i.jsx(G,{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(t()).then(u=>u&&l(u.id)),children:s})}const Uh=`${ne.apiPrefix}/knowledge`;async function Lf(t,s){const r=await fetch(`${Uh}${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),a=await r.json().catch(()=>({}));if(!r.ok)throw new Error(a.error??`HTTP ${r.status}`);return a}function ux(t){const[s,r]=x.useState([]),[a,l]=x.useState({}),[u,f]=x.useState(!1),[m,g]=x.useState(),p=x.useCallback(()=>{fetch(Uh).then(v=>v.ok?v.json():null).then(v=>{v&&(r(v.entries),l(v.stale))}).catch(()=>{})},[]);x.useEffect(()=>(p(),As(v=>v.startsWith("knowledge/")&&p())),[p]);const k=x.useMemo(()=>s.filter(v=>v.status==="suggested"||v.flag||a[v.id]&&v.status!=="outdated").length,[s,a]);return{entries:s,stale:a,briefText:t,attention:k,open:u,setOpen:f,error:m,call:(v,w)=>Lf("/call",{id:v,call:w}).then(()=>(g(void 0),p(),!0),N=>(g(N.message),!1)),propose:v=>Lf("/propose",v).then(w=>(p(),w.entry),w=>(g(w.message),void 0))}}function Rl(t){const[s,r]=x.useState(!1),[a,l]=x.useState(""),u=async()=>{let f="";try{f=await navigator.clipboard.readText()}catch{r(!0);return}f.trim()?t.onToken(f,!0):r(!0)};return i.jsxs("div",{className:"sl-paste",children:[i.jsx(G,{variant:"primary",disabled:t.busy,onClick:()=>void u(),children:t.busy?"Checking…":"Paste"}),s?i.jsxs("form",{className:"sl-paste-field",onSubmit:f=>{f.preventDefault(),t.onToken(a,!0),l("")},children:[i.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,autoFocus:!0,value:a,placeholder:t.placeholder,"aria-label":"Token",onChange:f=>l(f.target.value)}),i.jsx(G,{type:"submit",disabled:t.busy||!a.trim(),children:"Save"})]}):i.jsx("button",{type:"button",className:"link",onClick:()=>r(!0),children:"Type it instead"})]})}const dx=["awaiting","blocked","trail.done","resolved"],fx=["commands","chat:write","im:write","channels:history","groups:history","im:history","mpim:history","users:read"],hx=["users:read.email"],mx="save_decision",px=`/${ne.assistant.name.toLowerCase()}`;function gx(t={}){const s=ne.assistant.name;return{display_information:{name:s,description:`${ne.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:s,always_online:!0},slash_commands:[{command:t.command??px,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:mx,description:`Record this thread as a ${ne.name} decision`}]},oauth_config:{scopes:{bot:[...fx,...hx]}},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 vx={create:t=>`https://api.slack.com/apps?new_app=1&manifest_json=${encodeURIComponent(JSON.stringify(gx({command:t})))}`,app:t=>`https://api.slack.com/apps/${t}/general`,install:t=>`https://api.slack.com/apps/${t}/install-on-team`,home:(t,s)=>`slack://app?team=${t}&id=${s}&tab=home`,homeWeb:(t,s)=>`https://slack.com/app_redirect?app=${s}&team=${t}`};function yx(t){const s=t.trim().match(/^xapp-\d+-(A[A-Z0-9]+)-/);return s==null?void 0:s[1]}async function Kn(t,s="GET",r){const a=await fetch(t,{method:s,headers:{"Content-Type":"application/json"},body:r===void 0?void 0:JSON.stringify(r)}),l=await a.json().catch(()=>({}));if(!a.ok&&!l.status)throw new Error(l.error??`request failed (${a.status})`);return l}function kx(t){const s=`${t}/slack`;return{get:()=>Kn(s),created:()=>Kn(`${s}/created`,"POST",{}),token:r=>Kn(`${s}/token`,"POST",{token:r}),update:r=>Kn(`${s}/settings`,"PUT",r),resetOwner:()=>Kn(`${s}/owner/reset`,"POST",{}),members:()=>Kn(`${s}/members`).then(r=>r.members),remove:()=>Kn(s,"DELETE")}}const En=kx(ne.apiPrefix);function xx(t){const[s,r]=x.useState(!1),[a,l]=x.useState(),u=f=>{r(!0),En.token(f).then(m=>{r(!1),l(m.ok?void 0:m.error),t.set(m.status)},m=>{r(!1),l(m.message)})};return i.jsxs(i.Fragment,{children:[i.jsx(Rl,{busy:s,placeholder:"xapp-… or xoxb-…",onToken:u}),a&&i.jsxs("div",{className:"test-line alert",children:["✕ ",a]})]})}function wx({onRemoved:t}){const[s,r]=x.useState(!1);if(!s)return i.jsx(G,{size:"sm",variant:"ghost",onClick:()=>r(!0),children:"Remove"});const a=()=>void En.remove().then(l=>{r(!1),t(l)},()=>{});return i.jsxs(i.Fragment,{children:[i.jsx(G,{size:"sm",variant:"danger",onClick:a,children:"Remove tokens and settings"}),i.jsx(G,{size:"sm",variant:"ghost",onClick:()=>r(!1),children:"Keep"})]})}const jx={awaiting:"Awaiting you",blocked:"Blocked","trail.done":"Trail done",resolved:"Resolved"};function Wh({s:t}){const[s,r]=Sx(t);return i.jsxs("div",{className:`sync-line ${s}`,title:t.error,children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:r})]})}function Sx(t){switch(t.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 s=t.heldBy?` (${t.heldBy})`:"";return["warn",`Connected from another ${ne.slug}${s}`]}case"unsupported":return["alert",t.error??"Not supported here"];default:return["",t.step==="done"?"Off":"Not connected"]}}function Nx(t){const{s,setup:r}=t,a=s.step==="done";return i.jsxs(Et,{className:$x(s,r),children:[i.jsxs("div",{className:"card-row",children:[i.jsx("b",{className:"choice-title t-row-title",children:"Scout app"}),a&&i.jsx(An,{className:s.enabled?"on":"",children:s.enabled?"On":"Off"})]}),a&&i.jsx("div",{className:"c-loc",children:Cx(s)}),a&&i.jsx(Wh,{s}),!a&&s.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:[!a&&!r&&i.jsx(G,{size:"sm",variant:"primary",onClick:()=>t.onSetup(!0),children:s.step===1?"Connect":`Resume at step ${s.step}`}),a&&i.jsx(G,{size:"sm",on:s.enabled,onClick:t.onToggle,children:s.enabled?"Turn off":"Turn on"}),a&&s.state==="auth-error"&&i.jsx(G,{size:"sm",variant:"primary",onClick:()=>t.onSetup(!0),children:"Reconnect"}),s.step!==1&&i.jsx(wx,{onRemoved:t.onRemoved})]})]})}function Cx(t){var r,a,l;const s=(a=(r=t.workspace)==null?void 0:r.url)==null?void 0:a.replace(/^https?:\/\/|\/$/g,"");return[(l=t.workspace)==null?void 0:l.name,s,t.setup.appId].filter(Boolean).join(" · ")}function $x(t,s){const r=t.step==="done";return`connector ${r&&t.enabled?"active":""} ${s||!r?"open":""}`}function bx(t){const[s,r]=x.useState(t.value==="dm"?"":t.value),a=/^[CG][A-Z0-9]{6,}$/.test(s.trim());return i.jsxs("form",{className:"sl-paste-field",onSubmit:l=>{l.preventDefault(),a&&t.onSave(s.trim())},children:[i.jsx("input",{value:s,spellCheck:!1,placeholder:"Channel ID, e.g. C0123ABCD","aria-label":"Channel ID",onChange:l=>r(l.target.value)}),i.jsx(G,{type:"submit",disabled:!a||s.trim()===t.value,children:"Save"})]})}function Tx(t){const[s,r]=x.useState(),[a,l]=x.useState();x.useEffect(()=>{En.members().then(r,m=>l(m.message))},[]);const u=new Set(t.owners.map(m=>m.id)),f=new Set(t.value.map(m=>m.id));return a?i.jsxs("div",{className:"test-line alert",children:["✕ ",a]}):s?i.jsx("div",{className:"choice-row compact sl-members",children:s.map(m=>i.jsx(lt,{on:u.has(m.id)||f.has(m.id),disabled:u.has(m.id),title:`@${m.name??m.id}`,sub:u.has(m.id)?"Owner":void 0,onClick:()=>t.onChange(f.has(m.id)?t.value.filter(g=>g.id!==m.id):[...t.value,m])},m.id))}):i.jsx("span",{className:"t-meta",children:"Loading members…"})}function Ex(t){const{s,patch:r}=t,[a,l]=x.useState(!1),u=new Set(s.notify.events),f=a||s.notify.target!=="dm",m=s.owners[0],g=p=>{const k=u.has(p)?s.notify.events.filter(v=>v!==p):[...s.notify.events,p];r({notify:{events:k}})};return i.jsxs("div",{className:"sl-groups",children:[i.jsxs("div",{className:"sl-group",children:[i.jsx(Xe,{variant:"plain",size:"sm",children:"Owner"}),i.jsxs("div",{className:"sl-owner",children:[i.jsxs("b",{children:["@",(m==null?void 0:m.name)??(m==null?void 0:m.id)]}),(m==null?void 0:m.via)==="git-email"&&i.jsx("span",{className:"t-meta",children:"Matched your git email"}),i.jsx("button",{type:"button",className:"link",onClick:()=>void En.resetOwner().then(t.set,()=>{}),children:"Not you? Reset"})]})]}),i.jsxs("div",{className:"sl-group",children:[i.jsx(Xe,{variant:"plain",size:"sm",children:"Allowed users"}),i.jsx(Tx,{value:s.allow,owners:s.owners,onChange:p=>r({allow:p})})]}),i.jsxs("div",{className:"sl-group",children:[i.jsx(Xe,{variant:"plain",size:"sm",children:"Notify"}),i.jsxs("div",{className:"choice-row compact",children:[i.jsx(lt,{on:!f,title:"DM to owner",onClick:()=>{l(!1),r({notify:{target:"dm",detail:"full"}})}}),i.jsx(lt,{on:f,title:"Channel",sub:s.notify.target!=="dm"?s.notify.target:void 0,onClick:()=>l(!0)})]}),f&&i.jsxs(i.Fragment,{children:[i.jsx(He,{label:"Channel ID (invite @Scout there first)",children:i.jsx(bx,{value:s.notify.target,onSave:p=>r({notify:{target:p}})})}),i.jsxs("div",{className:"choice-row compact",children:[i.jsx(lt,{on:s.notify.detail==="full",title:"Full questions",onClick:()=>r({notify:{detail:"full"}})}),i.jsx(lt,{on:s.notify.detail==="titles-only",title:"Titles only",onClick:()=>r({notify:{detail:"titles-only"}})})]})]}),i.jsx("div",{className:"choice-row compact",children:dx.map(p=>i.jsx(lt,{on:u.has(p),title:jx[p],onClick:()=>g(p)},p))})]}),i.jsx(oo,{className:"dim",parts:[`${s.command} decide`,`${s.command} status`,`${s.command} inbox`,"Save as decision on any message"]})]})}function Yr(t){return i.jsx("a",{className:`btn ${t.primary?"primary":""}`,href:t.href,target:"_blank",rel:"noreferrer",onClick:t.onClick,children:t.children})}function Mx({s:t,n:s}){const r=Ix(t,s);return r?i.jsx("span",{className:"t-meta",children:r}):null}function Ix(t,s){var a;if(s===3)return t.setup.appId&&`app ${t.setup.appId}`;if(s===4)return t.workspace&&`${t.workspace.name} · @${((a=t.bot)==null?void 0:a.name)??"scout"}`;const r=t.owners[0];if(s===5&&r){const l=r.via==="git-email"?" · git email":"";return`owner ${r.name??r.id}${l}`}}const Rf=[{n:1,title:"Create app"},{n:2,title:"Workspace"},{n:3,title:"App token"},{n:4,title:"Install"},{n:5,title:"Claim"}],tc=(t,s)=>t===s||t===2&&s===3,Hh=(t,s)=>t==="done"||typeof t=="number"&&s<t&&!tc(t,s);function Of(t,s){return Hh(t,s)?"done":tc(t,s)?"cur":""}const Ax=/^(xapp-|xoxb-|xoxp-|xoxe)/,Lx=typeof navigator<"u"&&/Mac|iP(hone|ad)/.test(navigator.platform)?"⌘V":"Ctrl+V";function Rx(t){const s=x.useRef(t);s.current=t;const[r,a]=x.useState(!1);return x.useEffect(()=>{let l="";const u=(g,p)=>{const k=g.trim();return!Ax.test(k)||!p&&k===l?!1:(l=k,s.current(k,p),!0)},f=g=>{var p;u(((p=g.clipboardData)==null?void 0:p.getData("text"))??"",!0)&&g.preventDefault()},m=async()=>{if(document.visibilityState==="visible")try{const g=await navigator.permissions.query({name:"clipboard-read"});a(g.state==="granted"),g.state==="granted"&&u(await navigator.clipboard.readText(),!1)}catch{}};return m(),document.addEventListener("paste",f),window.addEventListener("focus",m),document.addEventListener("visibilitychange",m),()=>{document.removeEventListener("paste",f),window.removeEventListener("focus",m),document.removeEventListener("visibilitychange",m)}},[]),r}function Ox(t){var S;const{s,set:r}=t,[a,l]=x.useState(),[u,f]=x.useState(!1),[m,g]=x.useState(!1),p=(E,I)=>{const _=yx(E);I&&_&&!s.setup.botToken&&window.open(vx.install(_),"_blank")&&g(!0),f(!0),En.token(E).catch(O=>({ok:!1,error:O.message,status:s})).then(O=>{f(!1),l(O),r(O.status)})},v=Rx(p)?"come back to this tab":`press ${Lx} here`,w=s.step,N=E=>{if(!a)return null;const I=!a.ok&&E===4==(w===4);return a.kind===(E===4?"bot":"app")||I?i.jsx("div",{className:`test-line ${a.ok?"ok":"alert"}`,children:_x(a)}):null},M={1:i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:["Slack opens with the Scout app filled in from a manifest: the ",s.command," command, Save as decision, and Socket Mode. Nothing is hosted by ",ne.name,"."]}),i.jsx("div",{className:"sl-actions",children:i.jsx(Yr,{primary:!0,href:s.links.create,onClick:()=>void En.created().then(r,()=>{}),children:"Create Slack app"})})]}),2:i.jsxs("p",{children:["In Slack: pick the workspace → ",i.jsx("b",{children:"Next"})," → ",i.jsx("b",{children:"Create"}),"."]}),3:i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:["On the page Slack just opened: ",i.jsx("b",{children:"App-Level Tokens"})," → ",i.jsx("b",{children:"Generate Token and Scopes"})," → name it"," ",i.jsx("code",{children:"teamtrail"})," → add ",i.jsx("code",{children:"connections:write"})," → ",i.jsx("b",{children:"Generate"})," → ",i.jsx("b",{children:"Copy"}),", then ",v,"."]}),i.jsx("div",{className:"sl-actions",children:i.jsx(Rl,{busy:u,placeholder:"xapp-…",onToken:p})}),N(3),i.jsx(oo,{className:"dim",parts:["Waiting for the app-level token",s.links.create&&i.jsx("a",{href:s.links.create,target:"_blank",rel:"noreferrer",children:"Open the manifest again"},"again")]})]}),4:i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:[m?"Slack's install page is open in a new tab: ":i.jsxs(i.Fragment,{children:[i.jsx("b",{children:"Install to workspace"})," →"," "]}),i.jsx("b",{children:"Allow"})," → copy the ",i.jsx("b",{children:"Bot User OAuth Token"})," (starts with ",i.jsx("code",{children:"xoxb-"}),"), then ",v,"."]}),i.jsxs("div",{className:"sl-actions",children:[i.jsx(Yr,{primary:!m,href:s.links.install,children:m?"Open install page again":"Install to workspace"}),i.jsx(Rl,{busy:u,placeholder:"xoxb-…",onToken:p})]}),N(4)]}),5:i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:["Your git email doesn't match a member of ",((S=s.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(Yr,{primary:!0,href:s.links.home,children:"Open Scout in Slack"}),s.links.homeWeb&&i.jsx(Yr,{href:s.links.homeWeb,children:"Open in browser"})]}),i.jsx(Wh,{s})]})};return i.jsxs(Et,{tone:"inset",className:"slack-setup",children:[i.jsx("ol",{className:"pipeline sl-pipeline","aria-label":"Slack setup",children:Rf.map(E=>i.jsxs("li",{className:Of(w,E.n),children:[i.jsx("i",{}),i.jsxs("span",{children:[E.n," ",E.title]})]},E.n))}),i.jsx("ol",{className:"sl-steps",children:Rf.map(E=>{const I=Hh(w,E.n),_=tc(w,E.n);return i.jsxs("li",{className:Of(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(Mx,{s,n:E.n})]}),_&&i.jsx("div",{className:"sl-step-b",children:M[E.n]})]},E.n)})})]})}function _x(t){var s,r;return t.ok?t.kind==="app"?`✓ Socket Mode reachable · app ${t.status.setup.appId}`:`✓ Installed in ${(s=t.status.workspace)==null?void 0:s.name} as @${((r=t.status.bot)==null?void 0:r.name)??"scout"}`:`✕ ${t.error}`}function nc(t=0){const[s,r]=x.useState(),a=x.useCallback(()=>En.get().then(r,()=>r(null)),[]);return x.useEffect(()=>{if(a(),!t)return;const l=setInterval(()=>void a(),t);return()=>clearInterval(l)},[a,t]),[s,r]}function Px(t){const[s,r]=nc(3e3),[a,l]=x.useState(!1),u=x.useRef(null);if(x.useEffect(()=>{var g;t.focus&&s&&((g=u.current)==null||g.scrollIntoView({block:"start"}))},[t.focus,!!s]),!s)return null;const f=s.step==="done",m=g=>En.update(g).then(r,()=>{});return i.jsxs("div",{ref:u,className:"slack-settings",children:[i.jsx(Nx,{s,setup:a,onSetup:l,onToggle:()=>void m({enabled:!s.enabled}),onRemoved:g=>{r(g),l(!1)}}),!f&&(a||s.step!==1)&&i.jsx(Ox,{s,set:r}),a&&f&&s.state==="auth-error"&&i.jsxs(Et,{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(xx,{set:r})]}),f&&i.jsx(Ex,{s,set:r,patch:g=>void m(g)})]})}function Dx(t){const{api:s,rt:r,brief:a}=t,{snap:l,actions:u}=s,[f]=nc(15e3),m=Rs(),g=f!=null&&f.enabled&&f.state==="auth-error"?f.error??"Slack rejected the tokens":void 0;return i.jsx(ix,{repo:t.repo,snaps:s.allSnaps,map:l==null?void 0:l.map,activity:s.activity,health:s.health,onNewTrail:t.onNewTrail,trackerLabel:r.adapter.label.toLowerCase(),onSelectMap:u.selectMap,onToggleMode:()=>l&&u.setMode(l.map.mode==="plan-only"?"plan+execute":"plan-only"),onSettings:()=>t.onSettings("top"),onToggleTheme:t.onToggleTheme,attention:t.attention,slackAlert:g,onSlack:()=>t.onSettings("slack"),decisions:s.decisions.length,decisionsOpen:t.decisionsOpen,onDecisions:t.onDecisions,onStats:t.onStats,knowledge:m.attention,knowledgeOpen:m.open,onKnowledge:()=>m.setOpen(!m.open),briefingOpen:a.shown,briefingStatus:a.status,onBriefing:()=>a.shown?a.dismiss():a.open()})}function zx(t){const{m:s}=t,r=s.from==="human"?"human":"agent";return i.jsxs("div",{className:`msg from-${s.from} voice-${r}`,children:[i.jsx(ge,{parts:[s.author,Kl(s.at)]}),i.jsx("div",{className:"msg-text",children:s.text}),t.stillOpen&&i.jsx("button",{className:"answer-this t-meta",onClick:t.onAnswerThis,children:"Answer this"})]})}function Bx(t){const{ticket:s}=t;return i.jsxs("div",{className:"comms-ticket",children:[i.jsxs("div",{className:"t-title",title:s&&`${s.key} ${s.title}`,children:[i.jsx("span",{className:"key",children:s==null?void 0:s.key})," ",s==null?void 0:s.title]}),i.jsx(ge,{parts:[t.trail,t.agent]})]})}function Fx({id:t,text:s}){const[r,a]=x.useState(),l=r!==t;return i.jsx(Li,{size:1,framed:!1,state:l?"speaking":"alert",speaking:l?s.slice(0,60):void 0,onSpeakEnd:()=>a(t),className:"q-avatar"})}function Ux(t){const{q:s}=t;return i.jsxs("div",{className:"msg open-q",children:[i.jsx(ge,{parts:[s.agent,Kl(s.at)]}),i.jsx(Fx,{id:t.chatId??s.id,text:s.text}),i.jsx("div",{className:"msg-text",children:s.text})]})}function Wx(t){var s;return(s=t.options)!=null&&s.length?i.jsx("div",{className:"suggest",children:t.options.map(r=>i.jsx("button",{className:"chip",onClick:()=>t.onPick(r),children:r},r))}):null}function Hx(t){const{activity:s,sessionId:r}=t,[a,l]=x.useState(""),[u,f]=x.useState(),m=x.useRef(null),g=x.useRef(null),p=s.sessions.find(O=>O.id===r),k=s.chats.filter(O=>O.sessionId===r),v=Sk(s.pending,r,u??t.questionId),w=new Set(s.pending.filter(O=>O.sessionId===r).map(O=>O.id)),N=k.find(O=>!!v&&O.questionId===v.id),M=k.filter(O=>O!==N),S=p?t.snaps[p.mapId]:void 0,E=p!=null&&p.ticketId?S==null?void 0:S.tickets.find(O=>O.id===p.ticketId):void 0;x.useEffect(()=>{const O=m.current;O==null||O.scrollTo({top:O.scrollHeight,behavior:"smooth"})},[M.length,v==null?void 0:v.id]),x.useEffect(()=>{var O;v&&!t.onBack&&((O=g.current)==null||O.focus({preventScroll:!0}))},[v==null?void 0:v.id,t.onBack]);const I=O=>{!v||!O.trim()||(t.onAnswer(v.id,O.trim()),l(""))},_=Vx(p,!!v);return i.jsxs("div",{className:`comms ${v?"asking":""}`,children:[i.jsx(on,{title:"HITL line",right:p?i.jsx("span",{className:`status ${v?"urgent":""}`,children:_}):void 0,children:t.onBack&&i.jsx("button",{className:"back",onClick:t.onBack,"aria-label":"Back to inbox",children:"‹ Inbox"})}),p?i.jsxs(i.Fragment,{children:[i.jsx(Bx,{ticket:E,trail:S==null?void 0:S.map.title,agent:p.agent}),i.jsx("div",{className:"comms-log",ref:m,children:M.map(O=>i.jsx(zx,{m:O,stillOpen:!!O.questionId&&w.has(O.questionId),onAnswerThis:()=>f(O.questionId)},O.id))}),v&&i.jsx(Ux,{q:v,chatId:N==null?void 0:N.id}),i.jsx(Wx,{options:v==null?void 0:v.suggestions,onPick:I}),i.jsx(Mk,{ref:g,className:"comms-input",value:a,onValueChange:l,onSubmit:I,disabled:!v,placeholder:v?"Answer":""})]}):i.jsx(_e,{children:"No conversation"})]})}function Vx(t,s){return t?s?"Your answer is needed":Qt(t)?`${t.agent} is working…`:t.status==="done"?"Resolved · ticket closed":"Session ended":""}async function Kx(t){const[s,r]=t.ref.split("+"),a=await fetch(`${ne.apiPrefix}/workspaces/integration`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t.mapId,a:s,b:r})});return a.ok?void 0:(await a.json().catch(()=>({}))).error??`Adding failed (${a.status})`}function Qx({item:t}){const[s,r]=x.useState(!1),[a,l]=x.useState(),u=()=>{r(!0),l(void 0),Kx(t).then(l,f=>l(f.message)).finally(()=>r(!1))};return i.jsxs("div",{className:"att-action",children:[i.jsx(G,{size:"sm",className:"integration-add",disabled:s,onClick:u,children:s?"Adding…":"Add integration ticket"}),a&&i.jsx("span",{className:"vf-err",children:a})]})}const qx=/(\S*\/\S*|#\d+)/g;function Gx({reasons:t}){return t.length?i.jsx("span",{className:"reason-line",children:t.map((s,r)=>i.jsxs("span",{children:[r>0&&i.jsx("span",{className:"sep",children:" · "}),s.split(qx).map((a,l)=>l%2===1?i.jsx("span",{className:"t-code",children:a},l):a)]},s))}):null}const Yx={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"},Jx={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"},Xx=[{minutes:30,label:"30 min"},{minutes:120,label:"2 hours"},{minutes:1440,label:"Tomorrow"}],Zx=["blocked","flag","stalled","policy","reroute","overlap","integration"];function ew(t,s){return s||t.urgency==="blocking"?"urgent":Zx.includes(t.kind)?"attention":"neutral"}const tw=[/^marked blocking$/,/^fyi\b/,/^soon\b/,/^waiting \d/,/^answer together/,/questions from /];function nw(t){return t.reasons.filter(s=>!tw.some(r=>r.test(s)))}function sw(t){const{item:s,snap:r}=t,a=r==null?void 0:r.tickets.find(m=>m.id===s.ticketId),l=s.kind==="question"&&s.agent?`${s.agent} asks`:Yx[s.kind],u=[];s.urgency==="blocking"&&u.push({text:"Blocking",urgent:!0,className:"urgency-tag"}),u.push({text:l,strong:!0});const f=a&&iw(s.title,a);return f&&u.push(f),t.otherTrail&&u.push((r==null?void 0:r.map.title)??s.mapId),u}function iw(t,s){if(!t.includes(s.key))return t.includes(s.title)?{text:s.key,code:!0}:`${s.key} ${s.title}`}function rw(t){const[s,r]=x.useState(!1),a=l=>{r(!1),l()};return i.jsxs("span",{className:"snooze",children:[i.jsx("button",{type:"button",className:"snooze-btn","aria-expanded":s,"aria-label":`Later: ${t.title}`,onClick:()=>r(!s),children:"Later"}),s&&i.jsxs("span",{className:"snooze-menu",role:"menu",children:[Xx.map(l=>i.jsx("button",{type:"button",role:"menuitem",onClick:()=>a(()=>t.onSnooze(l.minutes)),children:l.label},l.minutes)),t.canDismiss&&i.jsx("button",{type:"button",role:"menuitem",onClick:()=>a(t.onDismiss),children:"Set aside"})]})]})}const ow=15e3;function aw(t){const{item:s}=t,r=s.title.split(`
124
+ `)[0],a=nw(s),l=t.now-s.since<ow;return i.jsx(ct,{as:"li",className:`att-item k-${s.kind} u-${s.urgency} ${t.selected?"sel":""} ${l?"incoming":""}`,edge:ew(s,t.interrupting),selected:t.selected,title:r,titleText:s.title,context:i.jsx(ge,{parts:sw({item:s,snap:t.snap,otherTrail:t.otherTrail})}),detail:a.length>0&&i.jsx(Gx,{reasons:a}),detailText:a.join(`
125
+ `),trailing:Yn(t.now-s.since),onOpen:t.onOpen,actions:i.jsx(rw,{title:s.title,canDismiss:ly(s),onSnooze:t.onSnooze,onDismiss:t.onDismiss}),below:s.kind==="integration"&&i.jsx(Qx,{item:s})})}function lw(t){const s=[];for(const r of t){const a=s.at(-1);(a==null?void 0:a.key)===r.batchKey?a.items.push(r):s.push({key:r.batchKey,kind:r.kind,mapId:r.mapId,items:[r]})}return s}const cw={question:"inbox-list",approval:"inbox-list approvals"};function uw(t){const{batch:s}=t,r=s.items.length>1,a=s.kind==="question"?"answer together":"review together",l=[`${s.items.length} ${Jx[s.kind]}`,t.trail,a].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 ${cw[s.kind]??""}`,children:t.children})]})}function dw(t,s){t.ticketId?s.openTicket(t.mapId,t.ticketId):s.selectTrail(t.mapId)}function fw(t,s){switch(t.kind){case"question":return s.openQuestion(t.ref);case"approval":case"blocked":case"policy":case"flag":case"stalled":case"hitl-ready":case"overlap":case"integration":return dw(t,s);case"knowledge":return s.openKnowledge();case"brief":return s.openBrief(t.mapId);case"reroute":case"reroute-suggested":return s.openReroute(t);default:return t.kind}}function hw(t){const s=In(1e3),{view:r}=t;if(!r.items.length)return i.jsx(qn,{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 a=Object.keys(t.snaps).length>1,l=m=>a&&m!==t.currentMapId,u=new Set(r.interrupting),f=m=>{var g;return(g=t.pending.find(p=>p.id===m))==null?void 0:g.sessionId};return i.jsx("div",{className:"attention-queue",children:lw(r.items).map(m=>{var g;return i.jsx(uw,{batch:m,trail:l(m.mapId)?(g=t.snaps[m.mapId])==null?void 0:g.map.title:void 0,children:m.items.map(p=>i.jsx(aw,{item:p,snap:t.snaps[p.mapId],otherTrail:l(p.mapId)&&m.items.length<2,selected:p.kind==="question"&&f(p.ref)===t.selected,interrupting:u.has(p.id),now:s,onOpen:()=>fw(p,t.handlers),onSnooze:k=>t.onSnooze(p.id,k),onDismiss:()=>t.onDismiss(p.id)},p.id))},m.key)})})}const mw=60*6e4;function pw(t){const{view:s}=t,r=(s.prefs.focusUntil??0)>Date.now(),a=s.interrupting.length,l=s.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(G,{variant:"ghost",className:"focus-btn",on:s.focused,"aria-pressed":s.focused,"data-tip":l,onClick:()=>t.onFocus(r?void 0:Date.now()+mw),children:"Focus"}),a>0&&i.jsxs("span",{className:"waiting-chip interrupting",title:`${a} need you now`,children:[i.jsx(Ls,{variant:"alert",size:14}),i.jsx("b",{children:a}),i.jsx("span",{className:"wl",children:" need you now"})]})]})}const Vh=`${ne.apiPrefix}/attention`,gw=250;async function _f(t,s,r){var u;const a=await fetch(`${Vh}${t}`,{method:s,headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),l=await a.json().catch(()=>({}));if(!a.ok)throw new Error(((u=l.errors)==null?void 0:u.join("; "))??l.error??`HTTP ${a.status}`);return l}function Kh(t){const[s,r]=x.useState(),[a,l]=x.useState(),u=x.useCallback(()=>{fetch(Vh).then(m=>m.ok?m.json():void 0).then(m=>m&&r(m)).catch(()=>{})},[]);x.useEffect(()=>_h("attention",m=>r(JSON.parse(m))),[]),x.useEffect(()=>{const m=setTimeout(u,gw);return()=>clearTimeout(m)},[u,t]);const f=(m,g)=>void _f(m,"POST",g).then(()=>(l(void 0),u()),p=>l(p.message));return{view:s,error:a,snooze:(m,g)=>f("/snooze",{id:m,minutes:g}),dismiss:m=>f("/dismiss",{id:m}),savePrefs:m=>_f("/prefs","PUT",m).then(()=>(l(void 0),u(),!0),g=>(l(g.message),!1))}}function vw(t){return t.prefs.channel!=="browser"?!1:typeof Notification<"u"&&Notification.permission==="granted"}function yw(t){const s=new Notification(`${ne.name} · needs you`,{body:t.title,tag:t.id});s.onclick=()=>{window.focus(),s.close()}}function kw(t){const s=x.useRef();x.useEffect(()=>{if(!t)return;const r=new Set(t.interrupting),a=s.current;if(s.current=r,!(!a||!vw(t)))for(const l of t.items)r.has(l.id)&&!a.has(l.id)&&yw(l)},[t])}function xw(t){const s=In(1e3);return t.items.length?i.jsx("ul",{className:"inbox-list approvals",children:t.items.map(r=>{var u;const a=r.kind!=="approve",l=r.mapId!==t.currentMapId?(u=t.snaps[r.mapId])==null?void 0:u.map.title:void 0;return i.jsx(ct,{as:"li",edge:a?"attention":"neutral",title:`${a?"Decide":"Approve"}: ${r.title}`,context:i.jsx(ge,{parts:[a?"Held":"Verified",{text:r.ticketKey,code:!0},l]}),detail:r.reason,detailText:r.reason,trailing:Yn(s-r.at),onOpen:()=>t.onOpen(r.mapId,r.ticketId)},`${r.mapId}/${r.ticketId}`)})}):null}function Pf({activity:t}){const s=In(1e3),r=hv(t);return i.jsxs("div",{className:"hitl-readout",children:[i.jsx(Kt,{layout:"inline",label:"Oldest",value:r.oldestAt?Pt(s-r.oldestAt):"—",urgent:!!r.oldestAt&&s-r.oldestAt>6e4,title:"Oldest open question"}),i.jsx(Kt,{layout:"inline",label:"Avg wait",value:r.avgWaitMs!==void 0?Pt(r.avgWaitMs):"—",title:`Average wait over ${r.answered} answered questions`}),i.jsx(Kt,{layout:"inline",label:"Answered",value:r.answered})]})}function ww(t){const s=In(1e3);return t.items.length?i.jsx("ul",{className:"inbox-list",children:t.items.map(r=>{const a=t.snaps[r.mapId],l=a==null?void 0:a.tickets.find(m=>m.id===r.ticketId),u=r.mapId!==t.currentMapId?a==null?void 0:a.map.title:void 0,f=r.text.split(`
126
+ `)[0];return i.jsx(ct,{as:"li",className:r.sessionId===t.selected?"sel":void 0,edge:r.urgency==="blocking"?"urgent":"neutral",selected:r.sessionId===t.selected,title:f,titleText:r.text,context:i.jsx(ge,{parts:[r.urgency==="blocking"&&{text:"Blocking",urgent:!0},`${r.agent} asks`,l&&{text:l.key,code:!0},l==null?void 0:l.title,u]}),trailing:Yn(s-r.at),onOpen:()=>t.onOpen(r.sessionId,r.ticketId)},r.id)})}):i.jsx(qn,{title:"Nothing waiting on you",hint:"When an agent needs your call, its question lands here."})}const jw={pass:"Passed",fail:"Failed",error:"Could not run",interrupted:"Interrupted"},Mi={off:"Off",checks:"Checks","checks+review":"Checks + review","checks+review+human":"Checks + review + you"},Qh={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."},Sw=t=>t.exitCode===0&&!t.timedOut&&!t.error;async function Df(t){const s=await t.json().catch(()=>({}));if(!t.ok)throw new Error(s.error??`HTTP ${t.status}`);return s}const Jr=`${ne.apiPrefix}/verification`,Oi={ticket:(t,s)=>fetch(`${Jr}/ticket?mapId=${encodeURIComponent(t)}&ticketId=${encodeURIComponent(s)}`).then(r=>r.ok?r.json():void 0,()=>{}),inbox:()=>fetch(`${Jr}/inbox`).then(t=>t.ok?t.json().then(s=>s.items):[],()=>[]),log:t=>fetch(`${Jr}/log?path=${encodeURIComponent(t)}`).then(s=>Df(s)),act:t=>fetch(`${Jr}/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).then(s=>Df(s))};function Nw(t){const[s,r]=x.useState([]),a=Object.values(t).map(l=>l.tickets.map(u=>`${u.id}:${u.state}:${u.status??""}`).join()).join("|");return x.useEffect(()=>{let l=!0;const u=()=>void Oi.inbox().then(m=>l&&r(m));u();const f=Ms.onEvidence(u);return()=>{l=!1,f()}},[a]),s}function Cw(t,s){return{...t,items:t.items.filter(r=>!(r.kind==="brief"&&r.mapId===s))}}function $w(t){var m;const s=[...t.activity.pending].sort((g,p)=>g.at-p.at),r=Nw(t.snaps),a=(m=t.attention)==null?void 0:m.view,l=a&&t.briefShown?Cw(a,t.currentMapId):a,u=l?l.items.length:s.length+r.length,f=i.jsx(on,{hot:u>0,title:i.jsxs(i.Fragment,{children:[u>0&&i.jsx(Ls,{variant:"alert",size:12}),"Waiting on you"]}),count:i.jsx(ro,{n:u,urgent:u>0,pop:!0},u)});return l&&t.attention&&t.handlers?i.jsxs("div",{className:"inbox-part",children:[f,i.jsx(Pf,{activity:t.activity}),i.jsx(hw,{view:l,snaps:t.snaps,pending:t.activity.pending,currentMapId:t.currentMapId,selected:t.sessionId,handlers:t.handlers,onSnooze:t.attention.snooze,onDismiss:t.attention.dismiss})]}):i.jsxs("div",{className:"inbox-part",children:[f,i.jsx(Pf,{activity:t.activity}),i.jsx(xw,{items:r,snaps:t.snaps,currentMapId:t.currentMapId,onOpen:t.onOpenTicket}),(s.length>0||!r.length)&&i.jsx(ww,{items:s,snaps:t.snaps,currentMapId:t.currentMapId,selected:t.sessionId,onOpen:t.onOpenQuestion})]})}function bw(t){const[s,r]=x.useState("list"),[a,l]=x.useState();x.useEffect(()=>{t.convRequest&&r("conv")},[t.convRequest]);const u=(k,v)=>{t.onOpen(k,v),r("conv")},f=k=>{const v=t.activity.pending.find(w=>w.id===k);v&&(l(v.id),u(v.sessionId,v.ticketId))},m=i.jsx($w,{activity:t.activity,snaps:t.snaps,currentMapId:t.currentMapId,sessionId:t.sessionId,attention:t.attention,handlers:t.handlers&&{...t.handlers,openQuestion:f},briefShown:!!t.above,onOpenQuestion:u,onOpenTicket:t.onOpenTicket}),g=i.jsx(Hx,{activity:t.activity,snaps:t.snaps,sessionId:t.sessionId,questionId:a,onAnswer:t.onAnswer,onBack:t.layout==="stack"?()=>r("list"):void 0});if(t.layout==="stack")return i.jsx(Ve,{className:"zone inbox stack",children:s==="conv"&&t.sessionId?g:i.jsxs("div",{className:"stack-scroll",children:[t.above,m,t.below]})});const p=!!t.activity.sessions.find(k=>k.id===t.sessionId);return i.jsxs(Ve,{className:`zone inbox split ${p?"has-conv":""}`,style:{gridArea:"inbox"},children:[i.jsx(on,{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."}),t.above,m,p&&g,t.below]})}function Tw(t){var m;const{snap:s}=t,r=s?Is(s.tickets,s.map.mode):new Map,a={claimed:0,frontier:1},l=((s==null?void 0:s.tickets)??[]).filter(g=>a[r.get(g.id)]!==void 0).sort((g,p)=>a[r.get(g.id)]-a[r.get(p.id)]),u=new Set(t.sessions.filter(Ph).map(g=>g.ticketId)),f=((m=t.selection)==null?void 0:m.kind)==="ticket"?t.selection.id:void 0;return i.jsxs("div",{className:"upnext",children:[i.jsx(on,{title:"Up next",count:i.jsx("span",{className:"n mono-label",children:l.length})}),!s&&i.jsx(_e,{children:"Ready tickets show here"}),s&&!l.length&&i.jsx(_e,{children:"Nothing ready"}),s&&l.length>0&&i.jsx("ul",{className:"ticket-list",children:l.map(g=>{const p=r.get(g.id),k=Ew({state:p,waiting:u.has(g.id),assignee:g.assignee,hitl:Ii(g)==="hitl"});return i.jsx("li",{className:`${f===g.id?"sel":""} st-${u.has(g.id)?"waiting":p}`,children:i.jsxs("button",{onClick:()=>t.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:k})]})},g.id)})})]})}function Ew(t){if(t.waiting)return"waiting on you";if(t.state==="claimed")return t.assignee??"claimed";const s=Ih[t.state].toLowerCase();return t.hitl?`${s}, needs you`:s}function Mw(t){const{api:s,nav:r}=t;return i.jsx(bw,{activity:s.activity,snaps:s.allSnaps,currentMapId:s.mapId,sessionId:s.chatSession,layout:t.bp==="mobile"?"stack":"split",convRequest:r.convRequest,onOpen:r.openChat,onAnswer:s.actions.answer,onOpenTicket:r.openTicket,attention:t.attn.attention,handlers:t.attn.handlers,below:i.jsx(Tw,{snap:s.snap,sessions:t.scoped.sessions,selection:s.selection,onSelect:r.select}),above:t.above})}function ao({command:t,label:s="Copy"}){const[r,a]=x.useState(!1);return i.jsxs("span",{className:"agent-cmd",children:[i.jsx("code",{children:t}),i.jsx("button",{type:"button",className:"btn sm","data-tip":"Copy, then paste it in Claude Code or Codex",onClick:()=>void navigator.clipboard.writeText(t).then(()=>{a(!0),setTimeout(()=>a(!1),1500)}),children:r?"Copied":s})]})}const Xr=[{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"}],Iw=9e3;function Aw(){const[t,s]=x.useState(0),[r,a]=x.useState(!1);x.useEffect(()=>{if(r)return;const u=setInterval(()=>s(f=>(f+1)%Xr.length),Iw);return()=>clearInterval(u)},[r]);const l=Xr[t];return i.jsxs("div",{className:"command-bar real",children:[i.jsx(Dh,{name:"map"}),i.jsx(Xe,{as:"h2",className:"zone-title-label",children:"Trail map"}),i.jsx(Ri,{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:()=>a(!0),onMouseLeave:()=>a(!1),onFocus:()=>a(!0),onBlur:()=>a(!1),children:[i.jsx("span",{className:"dim",children:l.text}),l.command&&i.jsx(ao,{command:l.command})]},t),i.jsxs("button",{type:"button",className:"link hint-next","data-tip":"Next hint","aria-label":"Next hint",onClick:()=>s(u=>(u+1)%Xr.length),children:[t+1,"/",Xr.length," ›"]})]})}function Lw(t){const s=[{v:"plan+execute",title:"Plan + execute"},{v:"plan-only",title:"Plan only"}];return i.jsx("div",{className:"choice-row",children:s.map(r=>i.jsx(lt,{on:t.value===r.v,title:r.title,onClick:()=>t.onChange(r.v)},r.v))})}function Rw({onClose:t,tracker:s,onCreate:r}){const[a,l]=x.useState(),[u,f]=x.useState(!1),[m,g]=x.useState(),[p,k]=x.useState(""),[v,w]=x.useState(""),[N,M]=x.useState(""),[S,E]=x.useState(""),I=[p.trim(),v.trim(),N.trim()].filter(Boolean).join(". ").replace(/"/g,"'");return x.useEffect(()=>{const _=O=>O.key==="Escape"&&t();return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[t]),i.jsx("div",{className:"scrim",onClick:t,children:i.jsxs(Ve,{as:"div",className:"dialog",onClick:_=>_.stopPropagation(),children:[i.jsx("header",{children:i.jsx("h2",{className:"t-heading caps",children:"New trail"})}),i.jsx(He,{label:"Title",children:i.jsx("input",{value:p,onChange:_=>k(_.target.value),autoFocus:!0})}),i.jsx(He,{label:"Destination",children:i.jsx("textarea",{rows:3,value:v,onChange:_=>w(_.target.value),placeholder:"What is true when this trail is done?"})}),i.jsx(He,{label:"Notes",children:i.jsx("textarea",{rows:2,value:N,onChange:_=>M(_.target.value)})}),i.jsx(He,{label:"Assumptions (optional, one per line)",children:i.jsx("textarea",{className:"new-trail-assumptions",rows:2,value:S,onChange:_=>E(_.target.value),placeholder:"What the plan takes for granted, e.g. The v2 API supports batch writes"})}),i.jsxs("div",{className:"agent-draft",children:[i.jsxs("span",{className:"dim",children:["Paste this in Claude Code or Codex. Scout frames the trail with you there, then charts it here in ",s,"."]}),i.jsx(ao,{command:`/scout new "${I||"your idea"}"`,label:"Copy command"})]}),a?i.jsxs("div",{className:"agent-draft created",children:[i.jsxs("span",{children:["Trail ",a," is on the map, starting with discovery. To get it moving, run this in Claude Code or Codex:"]}),i.jsx(ao,{command:"/scout resume",label:"Copy command"})]}):m&&i.jsx("p",{className:"vf-err",children:m}),i.jsxs("footer",{children:[i.jsx(G,{variant:"ghost",onClick:t,children:"Close"}),!a&&i.jsx(G,{variant:"primary",disabled:u||!p.trim()||!v.trim(),"data-tip":"Put the trail on the map now; any agent picks it up with /scout resume",onClick:()=>{f(!0);const _=S.split(`
127
+ `).map(O=>O.trim());r({title:p.trim(),destination:v.trim(),notes:N.trim(),assumptions:_.filter(Boolean)}).then(O=>l(O.key)).catch(O=>g(O.message)).finally(()=>f(!1))},children:"Create trail"})]})]})})}const zf=["Ready when you are","What's the next big idea?","I keep the party on the trail","Describe it, I frame it"],Ow=5e3;function _w(){const t=ko(),[s,r]=x.useState(0),[a,l]=x.useState(!0);return x.useEffect(()=>{if(a)return;const u=setTimeout(()=>{r(f=>(f+1)%zf.length),l(!0)},Ow);return()=>clearTimeout(u)},[a]),i.jsxs("div",{className:"floating-scout","aria-hidden":"true",children:[i.jsx(Li,{variant:t?"night":"crt",size:3,framed:!1,speaking:a?zf[s]:void 0,onSpeakEnd:()=>l(!1),className:"fm-avatar"}),i.jsx("span",{className:"fm-shadow"})]})}function Pw(t){return i.jsx(Rw,{onClose:t.onClose,tracker:t.rt.adapter.label,onCreate:async s=>{const r=await dk(t.rt.adapter,s);return t.onCreated(r.id),r}})}const Dw={stored:"Saved token",gh:"gh CLI",GITHUB_TOKEN:"$GITHUB_TOKEN",GH_TOKEN:"$GH_TOKEN",LINEAR_API_KEY:"$LINEAR_API_KEY"},to=t=>t==="github"||t==="linear";function qh(t){const[s,r]=x.useState(!t.source);return t.source&&!s?i.jsxs("div",{className:"ts-auth",children:[i.jsx("span",{className:"mono-label",children:t.label}),i.jsx("span",{className:"pill on",children:Dw[t.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:[t.label,t.link&&i.jsx("a",{href:t.link.href,target:"_blank",rel:"noreferrer",children:t.link.text})]}),i.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,value:t.value,placeholder:t.placeholder,onChange:a=>t.onChange(a.target.value)})]})}function Gh({r:t}){var a,l;if(!t)return null;if(!t.ok)return i.jsxs("div",{className:"test-line alert",children:["✕ ",t.error]});const s=(a=t.rate)!=null&&a.limit?`${(l=t.rate.remaining)==null?void 0:l.toLocaleString()}/${t.rate.limit.toLocaleString()} req`:"";let r="";return t.canWrite===!1?r="read-only":t.canWrite&&(r="read/write"),i.jsxs("div",{className:"test-line ok",children:["✓ ",[t.account,t.target,r,s].filter(Boolean).join(" · ")]})}const Mn=Cy(ne.apiPrefix);function bi(t,s){t({tracker:s});const r=new URL(location.href);r.searchParams.delete("tracker"),location.href=r.toString()}function Yh(t){const s=t.s.github,[r,a]=x.useState(s.repo??s.detectedRepo??""),[l,u]=x.useState(""),[f,m]=x.useState(),[g,p]=x.useState(),k=x.useCallback(async()=>{p("test"),m(await Mn.test({kind:"github",repo:r,token:l||void 0}).catch(w=>({ok:!1,error:w.message}))),p(void 0)},[r,l]);x.useEffect(()=>{s.auth&&r&&k()},[]);const v=async()=>{p("connect");try{await Mn.connect({active:"github",github:{repo:r,token:l||void 0}}),t.onConnected()}catch(w){m({ok:!1,error:w.message}),p(void 0)}};return i.jsxs("div",{className:"card inset tracker-setup",children:[i.jsxs("label",{className:"field",children:["Repository",i.jsx("input",{value:r,placeholder:"owner/name",spellCheck:!1,onChange:w=>a(w.target.value.trim())})]}),i.jsx(qh,{source:s.auth,value:l,onChange:u,label:"Token",placeholder:"ghp_… or github_pat_…",link:{href:"https://github.com/settings/personal-access-tokens/new",text:"New token"}}),i.jsx(Gh,{r:f}),i.jsxs("footer",{children:[i.jsx("button",{type:"button",className:"btn",disabled:!!g||!r,onClick:()=>void k(),children:g==="test"?"Testing…":"Test connection"}),i.jsx("button",{type:"button",className:"btn primary",disabled:!!g||!r||!s.auth&&!l,onClick:()=>void v(),children:g==="connect"?"Connecting…":"Connect"})]})]})}function Jh(t){var _;const s=t.s.linear,[r,a]=x.useState(""),[l,u]=x.useState(s.teamId??""),[f,m]=x.useState(s.projectId??""),[g,p]=x.useState(),[k,v]=x.useState([]),[w,N]=x.useState(),M=x.useCallback(async(O=l)=>{N("test");const ee=await Mn.test({kind:"linear",apiKey:r||void 0,teamId:O||void 0}).catch(q=>({ok:!1,error:q.message}));p(ee),ee.teams&&(v(ee.teams),!O&&ee.teams.length===1&&u(ee.teams[0].id)),N(void 0)},[r,l]);x.useEffect(()=>{s.auth&&M()},[]);const S=k.find(O=>O.id===l),E=(_=g==null?void 0:g.projects)==null?void 0:_.find(O=>O.id===f),I=async()=>{if(S){N("connect");try{await Mn.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}}),t.onConnected()}catch(O){p({ok:!1,error:O.message}),N(void 0)}}};return i.jsxs("div",{className:"card inset tracker-setup",children:[i.jsx(qh,{source:s.auth,value:r,onChange:a,label:"API key",placeholder:"lin_api_…",link:{href:"https://linear.app/settings/account/security",text:"New key"}}),k.length>0&&i.jsxs("div",{className:"ts-row",children:[i.jsxs("label",{className:"field",children:["Team",i.jsx(wt,{"aria-label":"Team",value:l,onChange:O=>{u(O),m(""),M(O)},options:[...l?[]:[{value:"",label:"Choose…"}],...k.map(O=>({value:O.id,label:`${O.key} · ${O.name}`}))]})]}),i.jsxs("label",{className:"field",children:["Project",i.jsx(wt,{"aria-label":"Project",value:f,onChange:m,disabled:!(g!=null&&g.projects),options:[{value:"",label:"All projects"},...((g==null?void 0:g.projects)??[]).map(O=>({value:O.id,label:O.name}))]})]})]}),i.jsx(Gh,{r:g}),i.jsxs("footer",{children:[i.jsx("button",{type:"button",className:"btn",disabled:!!w||!s.auth&&!r,onClick:()=>void M(),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 zw(t){return i.jsxs("div",{className:"c-actions",children:[t.canSwitch&&i.jsx("button",{className:"btn sm",disabled:!t.usable,onClick:t.onSwitch,children:"Switch"}),t.remote&&i.jsx("button",{className:`btn sm ${t.open?"on":""}`,disabled:!t.usable,onClick:t.onToggle,children:t.configured?"Edit":"Connect"})]})}function Bw({status:t}){var u,f;if(!t)return null;const s=(u=t.rate)!=null&&u.limit?`${((f=t.rate.remaining)==null?void 0:f.toLocaleString())??"?"}/${t.rate.limit.toLocaleString()} req`:"",r=t.queued?` · ${t.queued} queued`:"",[a,l]=Fw(t,r);return i.jsxs("div",{className:`sync-line ${a}`,title:t.error,children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:l}),s&&i.jsx("span",{className:"rate",children:s})]})}function Fw(t,s){switch(t.state){case"online":return["ok",`Online · synced ${Eh(t.lastSyncAt)}${s}`];case"offline":return["warn",`Offline${s}`];case"rate-limited":return["warn",`Rate limited · resumes ${yo(t.resetAt)}${s}`];case"auth-error":return["alert",`Credentials rejected${s}`];default:return["",`Connecting${s}`]}}function Uw(t){const{id:s,active:r,configured:a,s:l}=t,u=to(s),f=!u||!!l,m=["card connector",r?"active":"",f?"":"disabled",t.open?"open":""],g=(s==="markdown"||u)&&r,p=u&&!r&&a&&l?Ww(s,l):void 0;return i.jsxs("div",{className:m.join(" "),children:[i.jsxs("div",{className:"card-row",children:[i.jsx("b",{className:"choice-title t-row-title",children:t.name}),r&&i.jsx("span",{className:"pill on",children:"Active"})]}),g&&i.jsx("div",{className:"c-loc",children:t.location}),p!==void 0&&i.jsx("div",{className:"c-loc",children:p}),u&&r&&i.jsx(Bw,{status:l==null?void 0:l[s].status}),i.jsx(zw,{canSwitch:!r&&(!u||a),remote:u,usable:f,configured:a,open:t.open,onSwitch:t.onSwitch,onToggle:t.onToggle})]})}function Ww(t,s){return t==="github"?s.github.repo:[s.linear.teamKey,s.linear.projectName].filter(Boolean).join(" · ")}function Xh(t=0){const[s,r]=x.useState(),a=x.useCallback(()=>Mn.get().then(r,()=>r(null)),[]);return x.useEffect(()=>{if(a(),!t)return;const l=setInterval(()=>void a(),t);return()=>clearInterval(l)},[a,t]),[s,r,a]}function Hw(t){const[s]=Xh(5e3),[r,a]=x.useState(null),l=async f=>{s&&(f==="markdown"||to(f))&&await Mn.connect({active:f==="markdown"?"markdown":f,...f==="github"&&s.github.repo?{github:{repo:s.github.repo}}:{},...f==="linear"&&s.linear.teamId?{linear:{teamId:s.linear.teamId,teamKey:s.linear.teamKey,teamName:s.linear.teamName,projectId:s.linear.projectId,projectName:s.linear.projectName}}:{}}).catch(()=>{}),bi(t.update,f)},u=x.useMemo(()=>({github:!!(s!=null&&s.github.repo),linear:!!(s!=null&&s.linear.teamId)}),[s]);return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"connectors",children:$y.map(f=>{const m=f.id;return i.jsx(Uw,{id:m,name:f.name,active:m===t.activeTracker,configured:to(m)&&u[m],open:r===m,location:t.location,s,onSwitch:()=>void l(m),onToggle:()=>to(m)&&a(r===m?null:m)},f.id)})}),s&&r==="github"&&i.jsx(Yh,{s,onConnected:()=>bi(t.update,"github")}),s&&r==="linear"&&i.jsx(Jh,{s,onConnected:()=>bi(t.update,"linear")})]})}function st(t){return i.jsxs("section",{className:"set-sec",children:[i.jsx(Xe,{as:"h4",children:t.title}),t.children]})}function Zh(t){const s=[{v:"summary",title:"Summary"},{v:"full",title:"Full transcript"}];return i.jsx("div",{className:"choice-row",children:s.map(r=>i.jsx(lt,{on:t.value===r.v,title:r.title,onClick:()=>t.onChange(r.v)},r.v))})}function Vw(t){const{prefs:s,update:r}=t,[a]=Xh(),[l,u]=x.useState(),[f,m]=x.useState(!1),g=a!=null&&a.github.auth?a.github.repo??a.github.detectedRepo:void 0,p=[{id:"markdown",title:"Local markdown",sub:"Files in .teamtrail/ in this repo"},{id:"github",title:"GitHub Issues",sub:"Trails as labelled issues in your repo"},{id:"linear",title:"Linear",sub:"Trails and tickets in your Linear team"}],k=s.tracker==="github"&&!g||s.tracker==="linear",v=N=>{r({onboarded:!0}),bi(r,N)},w=async()=>{if(s.tracker==="github"&&g){m(!0);try{await Mn.connect({active:"github",github:{repo:g}})}catch(N){u(N.message),m(!1);return}}else s.tracker==="markdown"&&a&&await Mn.connect({active:"markdown"}).catch(()=>{});r({onboarded:!0}),s.tracker!==t.activeTracker&&bi(r,s.tracker)};return i.jsx("div",{className:"scrim",children:i.jsxs(Ve,{as:"div",className:"dialog onboarding",children:[i.jsxs("div",{className:"onb-brand",children:[i.jsx(Ok,{size:64}),i.jsx(zh,{as:"div",className:"onb-title"})]}),i.jsx("div",{className:"onb-cat mono-label",children:ne.category}),i.jsx("p",{className:"onb-tagline",children:ne.tagline}),i.jsxs("p",{className:"scout-line",children:[i.jsxs(Xe,{children:[i.jsx(Xl,{className:"voice-badge"})," ",ne.assistant.name]})," ","Where should your trails live?"]}),i.jsxs(st,{title:"Tracker",children:[i.jsx("div",{className:"choice-row",children:p.map(N=>i.jsx(lt,{on:s.tracker===N.id,title:N.title,sub:N.sub,onClick:()=>r({tracker:N.id})},N.id))}),a&&s.tracker==="github"&&!g&&i.jsx(Yh,{s:a,onConnected:()=>v("github")}),a&&s.tracker==="linear"&&i.jsx(Jh,{s:a,onConnected:()=>v("linear")}),l&&i.jsxs("div",{className:"test-line alert",children:["✕ ",l]})]}),i.jsx(st,{title:"HITL transcript",children:i.jsx(Zh,{value:s.hitlTranscript,onChange:N=>r({hitlTranscript:N})})}),i.jsx("footer",{children:i.jsx(G,{variant:"primary",disabled:f||k,onClick:()=>void w(),children:"Get started"})})]})})}const Bf={from:"18:00",to:"09:00"};function Kw(t){const s=t.focus!==void 0,r=t.focus??Bf;return i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Quiet hours"}),i.jsx(G,{size:"sm",on:s,"aria-pressed":s,onClick:()=>t.onChange(s?void 0:Bf),children:s?"On":"Off"}),s&&i.jsxs(i.Fragment,{children:[i.jsx("input",{type:"time","aria-label":"Quiet from",value:r.from,onChange:a=>a.target.value&&t.onChange({...r,from:a.target.value})}),i.jsx("span",{className:"t-meta",children:"to"}),i.jsx("input",{type:"time","aria-label":"Quiet until",value:r.to,onChange:a=>a.target.value&&t.onChange({...r,to:a.target.value})})]})]})}const Qw=[{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 qw(){typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()}function Gw(){const{view:t,error:s,savePrefs:r}=Kh(0);if(!t)return null;const a=t.policy.value,l=`${ne.dataDir}/attention.json`,u=m=>void r({...t.prefs,...m}),f=typeof Notification<"u"&&Notification.permission==="denied";return i.jsxs(st,{title:"Attention",children:[i.jsxs("p",{className:"vf-intro",children:["Everything that needs you is ranked in Waiting on you. Only items scoring ",a.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(wt,{compact:!0,"aria-label":"Interrupt me by",value:t.prefs.channel,options:Qw,onChange:m=>{m==="browser"&&qw(),u({channel:m})}})]}),t.prefs.channel==="browser"&&f&&i.jsx("span",{className:"vf-err",children:"The browser blocks notifications for this page. Allow them in its site settings."}),i.jsx(Kw,{focus:t.prefs.focus,onChange:m=>u({focus:m})}),i.jsx("span",{className:"set-hint t-meta",children:"Your channel and quiet hours stay on this machine."}),t.policy.errors.length>0&&i.jsx("ul",{className:"vf-errors",children:t.policy.errors.map(m=>i.jsxs("li",{children:[l,": ",m]},m))}),i.jsx(ge,{className:"set-hint",parts:[t.policy.exists?{text:l,code:!0}:"Team defaults",`interrupt at ${a.interrupt}`,a.digestMinutes?`Slack digest every ${a.digestMinutes} min`:"Slack digest off"]}),s&&i.jsx("span",{className:"vf-err",children:s})]})}const Yw=[5,15,30,60];function Jw(t){const{value:s}=t;return i.jsxs("div",{className:"choice-row compact",children:[i.jsx(lt,{on:!s.enabled,title:"Off",onClick:()=>t.onChange({...s,enabled:!1})}),Yw.map(r=>i.jsx(lt,{on:s.enabled&&s.awayMinutes===r,title:`Away ${r} min`,onClick:()=>t.onChange({enabled:!0,awayMinutes:r})},r))]})}const Xw=[{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"]}],Zw=[{area:"Trail stats",items:["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"]},{area:"New name, new look",items:["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 screen with a sapling growing from it, and a new look for Scout: a CRT head in a ranger hat, in a circle with hills, with a lamp on the hat at night. No more pixel art, and new fonts too"]},{area:"Every repo",items:["All your projects in one view, with one list of what needs you across them"]},{area:"Agents",items:["Smarter model choice: hard calls to stronger models, routine work to cheaper ones, based on past results","Agent roles (reviewer, researcher, builder) and guides you can add to a trail"]},{area:"Teamtrail Cloud",items:["Agents that run in the cloud, steered from the same Lookout"]}],e0=[{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"]},...Xw];function t0(){return i.jsxs("div",{className:"changelog",children:[i.jsxs("div",{className:"about",children:[i.jsx(zh,{className:"about-name"}),i.jsx("span",{className:"mono-label",children:ne.category}),i.jsx("p",{className:"onb-tagline",children:ne.tagline}),i.jsx(ge,{parts:[ne.assistant.name]})]}),i.jsx(st,{title:"Next",children:Zw.map(t=>i.jsxs("div",{className:"cl-row",children:[i.jsx("span",{className:"mono-label",children:t.area}),i.jsx("ul",{children:t.items.map(s=>i.jsx("li",{children:s},s))})]},t.area))}),e0.map(t=>i.jsx(st,{title:`${t.version} · ${t.date}`,children:i.jsx("ul",{children:t.items.map(s=>i.jsx("li",{children:s},s))})},t.version))]})}const Ff={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"},n0={low:"the agent decides",medium:"the agent decides and records it",high:"you decide"},s0=t=>t[0].toUpperCase()+t.slice(1),Ol=mh.map(t=>({value:t,label:s0(t),hint:n0[t]}));function i0(t){const[s,r]=x.useState(""),[a,l]=x.useState("high"),{rules:u,onChange:f}=t,m=()=>{const g=s.trim();!g||u.some(p=>p.glob===g)||(f([...u,{glob:g,level:a}]),r(""))};return i.jsxs("div",{className:"risk-paths",children:[i.jsx("span",{className:"mono-label",children:"Files"}),u.map((g,p)=>i.jsxs("div",{className:"risk-row",children:[i.jsx("code",{children:g.glob}),i.jsx(wt,{compact:!0,"aria-label":`${g.glob} risk`,value:g.level,options:Ol,onChange:k=>f(u.map((v,w)=>w===p?{...v,level:k}:v))}),i.jsx("button",{className:"icon-btn","aria-label":`Remove ${g.glob}`,onClick:()=>f(u.filter((k,v)=>v!==p)),children:"×"})]},g.glob)),i.jsxs("div",{className:"risk-row",children:[i.jsx("input",{value:s,placeholder:"src/payments/**","aria-label":"New file pattern",onChange:g=>r(g.target.value),onKeyDown:g=>g.key==="Enter"&&m()}),i.jsx(wt,{compact:!0,"aria-label":"New pattern risk",value:a,options:Ol,onChange:l}),i.jsx(G,{onClick:m,disabled:!s.trim(),children:"Add"})]})]})}const em=`${ne.apiPrefix}/policy`;async function r0(){const t=await fetch(em);return t.ok?await t.json():null}function o0(){const[t,s]=x.useState(),r=x.useCallback(()=>{r0().then(s,()=>s(null))},[]);x.useEffect(()=>(r(),As(l=>{l.endsWith("policy.json")&&r()})),[r]);const a=x.useCallback(async l=>{const u=await fetch(em,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)}),f=await u.json();if(!u.ok)return f.error??`Saving failed (${u.status})`;s(f)},[]);return{view:t,save:a}}function a0(){const{view:t,save:s}=o0(),[r,a]=x.useState();if(!t)return null;const l=`${ne.dataDir}/policy.json`,u=f=>{a(void 0),s(f).then(a,m=>a(m.message))};return i.jsxs(st,{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:hh.map(f=>i.jsxs("label",{className:"risk-row",children:[i.jsx("span",{children:Ff[f]}),i.jsx(wt,{compact:!0,"aria-label":`${Ff[f]} risk`,value:t.policy.categories[f],options:Ol,onChange:m=>u({...t.policy,categories:{...t.policy.categories,[f]:m}})})]},f))}),i.jsx(i0,{rules:t.policy.paths,onChange:f=>u({...t.policy,paths:f})}),t.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:t.errors.map(f=>i.jsx("li",{children:f},f))})]}),t.defaults&&t.errors.length===0&&i.jsxs("span",{className:"set-hint t-meta",children:["Defaults. Changing anything saves ",l,", so your team shares it."]}),r&&i.jsx("span",{className:"vf-err",children:r})]})}function l0(t){const[s]=nc();return s?i.jsx(st,{title:"Slack",children:i.jsx(Px,{focus:t.focus})}):null}const c0=[{value:"auto",title:"Match my system"},{value:"day",title:"Day"},{value:"night",title:"Night"}];function u0(t){return i.jsx("div",{className:"choice-row compact",children:c0.map(s=>i.jsx(lt,{on:t.value===s.value,title:s.title,onClick:()=>t.onChange(s.value)},s.value))})}function d0(){const[t,s]=x.useState();return x.useEffect(()=>{let r=!0;return fetch(`${ne.apiPrefix}/verification/config`).then(a=>a.ok?a.json():null).then(a=>r&&s(a),()=>r&&s(null)),()=>{r=!1}},[]),t}const Uf=`{
128
+ "v": 1,
129
+ "checks": {
130
+ "test": { "run": ["npm", "test"] },
131
+ "lint": { "run": ["npm", "run", "lint"] }
132
+ },
133
+ "run": ["test", "lint"]
134
+ }
135
+ `;function f0({file:t}){const[s,r]=x.useState(!1),a=()=>void navigator.clipboard.writeText(Uf).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:t})," in your repo. Create it with the commands you trust, then commit it:"]}),i.jsxs("div",{className:"vf-snippet",children:[i.jsx("pre",{children:Uf}),i.jsx(G,{size:"sm",variant:"ghost",onClick:a,children:s?"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 h0(t){const s=d0(),[r,a]=x.useState();if(!s)return null;const l=t.map,u=s.config,f=`${ne.dataDir}/${s.file}`,m=(l==null?void 0:l.verification)??"off",g=(u??oh).appliesTo.join(" and ");return i.jsxs(st,{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:Ul.map(p=>i.jsx(lt,{on:m===p,title:Mi[p],sub:Qh[p],onClick:()=>{a(void 0),Oi.act({action:"level",mapId:l.id,level:p,by:gt}).catch(k=>a(k.message))}},p))}),m!=="off"&&!u&&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})]}),s.errors.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line alert",title:s.hash,children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[f," has errors. Completions that need checks wait for you until it is fixed."]})]}),i.jsx("ul",{className:"vf-errors",children:s.errors.map(p=>i.jsx("li",{children:p},p))})]}),!s.exists&&i.jsx(f0,{file:f}),u&&s.exists&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line ok",title:s.hash,children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[i.jsx("span",{className:"t-code",children:f})," · ",u.run.length," checks run on every completion"]})]}),i.jsx(ge,{className:"set-hint",parts:[`New trails start at ${Mi[u.default]}`,`${u.maxAttempts} attempts before it waits for you`,u.failFast&&"Stops at the first failure"]}),i.jsx("div",{className:"vf-checks",children:Object.entries(u.checks).map(([p,k])=>i.jsxs("div",{className:"vf-check",children:[i.jsx("span",{className:"t-code",children:u.run.includes(p)?p:`${p} (on request)`}),i.jsx("code",{children:k.run.join(" ")}),i.jsxs("span",{className:"dim",children:[k.timeoutSec," s",k.cwd&&k.cwd!=="."?` · in ${k.cwd}`:""]})]},p))})]}),i.jsxs("span",{className:"set-hint t-meta",children:["Teamtrail never edits ",f,". Change checks in the repo, so no agent can change what verifies its own work."]})]})}const _l=`${ne.apiPrefix}/workspaces`;async function m0(){const t=await fetch(_l);return t.ok?await t.json():null}function tm(){const[t,s]=x.useState(),r=x.useCallback(()=>{m0().then(s,()=>s(null))},[]);x.useEffect(()=>(r(),As(u=>{(u.endsWith("workspaces.json")||u.includes("workspaces/")||u.includes("leases/"))&&r()})),[r]);const a=x.useCallback(async u=>{const f=await fetch(_l,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)}),m=await f.json();if(!f.ok)return m.error??`Saving failed (${f.status})`;s(m)},[]),l=x.useCallback(async(u,f,m=!1)=>{const g=await fetch(`${_l}/remove`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:u,ticketId:f,force:m})}),p=await g.json();return g.ok?(s(p),{}):{error:p.error??`Removing failed (${g.status})`,dirty:p.dirty??!1}},[]);return{view:t,save:a,remove:l}}function nm(t){const[s,r]=x.useState(!1),[a,l]=x.useState(),[u,f]=x.useState(!1),m=async g=>{f(!0),l(void 0);const p=await t.onRemove(g).catch(k=>({error:k.message,dirty:!1}));f(!1),r(!!p.dirty&&!g),p.dirty||l(p.error)};return s?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(G,{size:"sm",disabled:u,onClick:()=>m(!0),children:"Remove anyway"}),i.jsx(G,{size:"sm",variant:"ghost",onClick:()=>r(!1),children:"Keep"})]}):i.jsxs("span",{className:"ws-remove",children:[i.jsx(G,{size:"sm",disabled:u,onClick:()=>m(!1),children:t.label??"Remove"}),a&&i.jsx("span",{className:"vf-err",children:a})]})}function p0(t){return t.rows.length?i.jsx("ul",{className:"ws-list",children:t.rows.map(s=>i.jsx(ct,{as:"li",className:`ws-row ${s.active?"active":"finished"}`,title:i.jsx("span",{className:"t-code",children:s.branch}),titleText:s.branch,context:i.jsx(ge,{parts:[{text:s.ticketKey,code:!0},s.active?`Active · ${s.agent}`:"Finished"]}),detail:i.jsx("span",{className:"t-code",children:s.path}),detailText:s.path,below:s.active?void 0:i.jsx(nm,{onRemove:r=>t.onRemove(s.mapId,s.ticketId,r)})},`${s.mapId}/${s.ticketId}`))}):null}function g0(t){const{view:s,remove:r}=tm(),a=s==null?void 0:s.workspaces.find(l=>l.mapId===t.mapId&&l.ticketId===t.ticketId);return!a||a.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:a.branch})," in"," ",i.jsx("code",{className:"t-code",title:a.path,children:a.path})]}),i.jsx(nm,{label:"Remove workspace",onRemove:l=>r(t.mapId,t.ticketId,l)})]})}function v0(){const{view:t,save:s,remove:r}=tm(),[a,l]=x.useState();if(!t)return null;const u=t.settings.worktrees,f=()=>{l(void 0),s({...t.settings,worktrees:!u}).then(l,m=>l(m.message))};return i.jsxs(st,{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; ",ne.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(G,{size:"sm",on:u,"aria-pressed":u,className:"worktrees-toggle",onClick:f,children:u?"On":"Off"})]}),i.jsx(ge,{className:"set-hint",parts:[{text:`${ne.dataDir}/workspaces.json`,code:!0},Wf(t.workspaces.filter(m=>m.active).length,"active"),Wf(t.workspaces.filter(m=>!m.active).length,"finished")]}),i.jsx(p0,{rows:t.workspaces,onRemove:r}),t.errors.length>0&&i.jsx("ul",{className:"vf-errors",children:t.errors.map(m=>i.jsx("li",{children:m},m))}),a&&i.jsx("span",{className:"vf-err",children:a})]})}const Wf=(t,s)=>`${t} ${s}`;function y0(t){const{prefs:s,update:r}=t,[a,l]=x.useState(t.initialTab??"settings");return x.useEffect(()=>{const u=f=>f.key==="Escape"&&t.onClose();return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[t]),i.jsx("div",{className:"scrim",onClick:t.onClose,children:i.jsxs(Ve,{as:"div",className:"dialog settings",onClick:u=>u.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx(Zl,{value:a,onChange:l,items:[{id:"settings",label:"Settings"},{id:"changelog",label:"Changelog"}]}),i.jsx("button",{className:"icon-btn",onClick:t.onClose,"aria-label":"Close",children:"×"})]}),a==="changelog"?i.jsx(t0,{}):i.jsxs(i.Fragment,{children:[t.map&&i.jsx(st,{title:`Trail ${t.map.key}`,children:i.jsx(Lw,{value:t.map.mode,onChange:t.onMapMode})}),i.jsx(st,{title:"Tracker",children:i.jsx(Hw,{activeTracker:t.activeTracker,location:t.location,update:r})}),i.jsx(l0,{focus:t.focus==="slack"}),i.jsx(h0,{map:t.map}),i.jsx(a0,{}),i.jsx(Gw,{}),i.jsx(v0,{}),i.jsx(st,{title:"Labels",children:i.jsxs("div",{className:"label-codes",children:[i.jsx("code",{children:zl}),i.jsxs("code",{children:[ne.labelPrefix,":<type>"]}),i.jsx("code",{children:Bl}),i.jsx("code",{children:Fl})]})}),i.jsx(st,{title:"HITL transcript",children:i.jsx(Zh,{value:s.hitlTranscript,onChange:u=>r({hitlTranscript:u})})}),i.jsx(st,{title:"Appearance",children:i.jsx(u0,{value:s.theme,onChange:u=>r({theme:u})})}),i.jsx(st,{title:"Trip report",children:i.jsx(Jw,{value:s.briefing,onChange:u=>r({briefing:u})})}),i.jsx(st,{title:"Agent",children:i.jsx("div",{className:"choice-row",children:jh.map(u=>i.jsx(lt,{on:u.status==="primary",disabled:u.status!=="primary",title:u.name},u.id))})})]})]})})}const k0=()=>new URLSearchParams(location.search).get("settings")==="slack"?"slack":!1;function x0(){const t=new URL(location.href);t.searchParams.has("settings")&&(t.searchParams.delete("settings"),history.replaceState(null,"",t))}function w0(t){var a;const{rt:s,api:r}=t;return i.jsx(y0,{prefs:t.prefs,update:t.update,activeTracker:s.kind,location:s.adapter.location,map:(a=r.snap)==null?void 0:a.map,onMapMode:r.actions.setMode,focus:t.focus==="slack"?"slack":void 0,onClose:()=>{t.onClose(),x0()}})}function j0(t){return i.jsxs(Ve,{className:"zone side",style:{gridArea:"inspector"},children:[i.jsx(Zl,{className:"zone-tabs",value:t.tab,onChange:t.onTab,items:[{id:"ticket",label:"Ticket"},{id:"activity",label:"Activity"},{id:"plan",label:"Plan",n:t.unspecified}]}),{ticket:t.ticket,activity:t.activity,plan:t.plan}[t.tab]]})}const sc=13;function S0(t,s,r){if(t==="LR"){const g=s.x+Te+sc,p=s.y+Ce/2,k=r.x-2,v=r.y+Ce/2,w=k-g;if(p===v)return`M${g} ${p}C${g+w*.3} ${p-16} ${g+w*.7} ${p+16} ${k} ${v}`;const N=(g+k)/2;return`M${g} ${p}C${N} ${p} ${N} ${v} ${k} ${v}`}const a=s.x+Te/2,l=s.y+Ce,u=r.x+Te/2,f=r.y-4,m=(l+f)/2;return`M${a} ${l}C${a} ${m} ${u} ${m} ${u} ${f}`}function N0(t){if(t.direction==="LR"){const r=t.width+96;return{x:r,y:t.graphH/2,right:r+60,bottom:t.height}}const s=t.graphH+76;return{x:t.width/2,y:s,right:t.width,bottom:Math.max(t.height,s+70)}}function C0(t,s){const r=new Set(t.edges.map(l=>l.from));return t.nodes.filter(l=>l.state!=="out-of-scope"&&!r.has(l)).map(l=>{if(t.direction==="LR"){const p=l.x+Te+sc,k=l.y+Ce/2,v=s.x-44,w=(p+v)/2;return`M${p} ${k}C${w} ${k} ${w} ${s.y} ${v} ${s.y}`}const u=l.x+Te/2,f=l.y+Ce+16,m=s.y-44,g=(f+m)/2;return`M${u} ${f}C${u} ${g} ${s.x} ${g} ${s.x} ${m}`})}function $0({x:t,y:s}){return i.jsxs("g",{className:"destination",transform:`translate(${t} ${s})`,"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 b0({trails:t}){return t.map(s=>i.jsxs("g",{children:[i.jsx("path",{className:"edge-path",d:s}),i.jsx("path",{className:"edge edge-open",d:s})]},s))}function T0(){return i.jsxs("defs",{children:[i.jsx("pattern",{id:"map-grid",width:"40",height:"40",patternUnits:"userSpaceOnUse",children:i.jsx("path",{d:"M40 0H0V40",fill:"none",stroke:"var(--map-grid)",strokeWidth:"1"})}),i.jsx("pattern",{id:"sign-grain",width:"200",height:"9",patternUnits:"userSpaceOnUse",children:i.jsx("rect",{y:"8",width:"200",height:"1",fill:"var(--sign-grain)"})}),i.jsx("pattern",{id:"hatch-oos",width:"10",height:"10",patternUnits:"userSpaceOnUse",patternTransform:"rotate(45)",children:i.jsx("line",{x1:"0",y1:"0",x2:"0",y2:"10",stroke:"var(--line)",strokeWidth:"2"})}),i.jsx("pattern",{id:"hatch-dim",width:"6",height:"6",patternUnits:"userSpaceOnUse",patternTransform:"rotate(45)",children:i.jsx("line",{x1:"0",y1:"0",x2:"0",y2:"6",stroke:"var(--sign-grain)",strokeWidth:"1.5"})})]})}function E0(t){const{from:s,to:r,direction:a}=t,u=["edge",s.ticket.state!=="open"?"edge-done":"edge-open",t.added?"edge-added":"",t.removed?"edge-removed":""],f=S0(a,s,r);return i.jsxs(i.Fragment,{children:[i.jsx("path",{className:"edge-path",d:f}),i.jsx("path",{className:u.join(" "),d:f})]})}function M0({mark:t,frozen:s}){const r=t&&t!=="unchanged"&&t!=="cancelled"?t:void 0;return i.jsxs(i.Fragment,{children:[t==="cancelled"&&i.jsx("line",{className:"strike",x1:8,y1:Ce/2,x2:Te-8,y2:Ce/2}),r&&i.jsx("text",{className:"reroute-tag",x:Te-8,y:Ce-8,textAnchor:"end",children:r}),s&&i.jsx("text",{className:"freeze",x:Te-(r?58:8),y:Ce-8,textAnchor:"end",children:"❄"})]})}function I0(t,s,r=2){const a=t.split(/\s+/),l=[];let u="";for(const f of a)(u+" "+f).trim().length>s?(l.push(u.trim()),u=f):u+=" "+f;if(l.push(u.trim()),l.length>r){const f=l.slice(0,r);return f[r-1]=f[r-1].slice(0,s-1)+"…",f}return l}const A0=`M${Te} 0L${Te+sc} ${Ce/2}L${Te} ${Ce}z`;function L0({n:t,session:s,stalled:r,flag:a,selected:l,onSelect:u,mark:f,frozen:m}){const g=t.ticket,p=I0(g.title,29),k=Ii(g)==="hitl",v=!!(s!=null&&s.waitingOn),w=!!f&&f!=="unchanged",N=w?void 0:O0(t,{waiting:v,stalled:r}),M=k&&!w&&(g.type==="task"||g.type==="execute"),S={hitl:k,selected:l,live:!!s,waiting:v,stalled:r,mark:f,frozen:m};return i.jsxs("g",{className:R0(t,S),style:{transform:`translate(${t.x}px, ${t.y}px)`},onClick:E=>{E.stopPropagation(),u({kind:"ticket",id:g.id})},children:[v&&i.jsx("rect",{className:"alarm",x:-6,y:-6,width:Te+12,height:Ce+12}),i.jsx("rect",{className:"post",x:Te/2-6,y:Ce,width:12,height:12}),i.jsx("rect",{className:"tuft",x:Te/2-11,y:Ce+12,width:22,height:3}),i.jsx("path",{className:"body tip",d:A0}),i.jsx("rect",{className:"body",width:Te,height:Ce}),i.jsx("rect",{width:Te,height:Ce,fill:"url(#sign-grain)"}),(t.state==="blocked"||t.state==="parked")&&i.jsx("rect",{width:Te,height:Ce,fill:"url(#hatch-dim)"}),t.state==="out-of-scope"&&i.jsx("rect",{width:Te,height:Ce,fill:"url(#hatch-oos)"}),i.jsx("rect",{className:"edge-bar",width:4,height:Ce}),p.map((E,I)=>i.jsx("text",{className:"title",x:12,y:19+I*14,children:E},I)),i.jsxs("text",{className:"meta",x:12,y:Ce-8,children:[i.jsx("tspan",{className:"key",children:g.key}),i.jsxs("tspan",{children:[" · ",g.type]}),N&&i.jsxs("tspan",{className:N.tone,children:[" · ",N.text]}),M&&i.jsx("tspan",{children:" · needs you"})]}),a&&i.jsx("circle",{className:`pr-flag-dot ${a}`,cx:Te-2,cy:2,r:4}),i.jsx(M0,{mark:f,frozen:m}),s&&!v&&i.jsxs("text",{className:"live-tag",x:Te,y:Ce+13,textAnchor:"end",children:[s.agent," · step ",s.step,"/",s.total," · ",s.stepLabel.toLowerCase()]})]})}function R0(t,s){const r=["node",`st-${t.state}`,s.hitl?"hitl":"afk"];return s.selected&&r.push("sel"),s.live&&r.push("live"),s.waiting&&r.push("waiting"),s.stalled&&!s.waiting&&r.push("stalled"),s.mark&&r.push(`mark-${s.mark}`),s.frozen&&r.push("frozen"),r.join(" ")}function O0(t,s){const r=t.ticket.assignee;return s.waiting?{text:"waiting on you",tone:"urgent"}:s.stalled?{text:`stalled · ${r}`,tone:"warn"}:t.state==="claimed"?{text:r??"working",tone:"agent"}:{text:hk[t.state],tone:""}}const lo=(t,s)=>`${t}>${s}`;function _0(t,s,r=[]){const a=new Map(t.tickets.map(u=>[u.id,u]));return{tickets:s.nodes.map(u=>{const f=a.get(u.id);return f?{...f,blockedBy:[...u.blockedBy,...u.removedEdges??[]]}:{id:u.id,key:"+",title:u.title,type:u.type,body:"",state:"open",blockedBy:u.blockedBy,comments:[],createdAt:t.map.updatedAt,updatedAt:t.map.updatedAt}}),marks:new Map(s.nodes.map(u=>[u.id,u.mark])),newEdges:new Set(s.nodes.flatMap(u=>u.newEdges.map(f=>lo(f,u.id)))),removedEdges:new Set(s.nodes.flatMap(u=>(u.removedEdges??[]).map(f=>lo(f,u.id)))),frozen:new Set(r)}}const Hf=.72;function P0(t){const{fit:s,nodes:r,size:a,pad:l}=t;if(s.k>=Hf)return s;const u=r.find(m=>m.state==="claimed")??r.find(m=>m.state==="frontier")??r[0];if(!u)return s;const f=Hf;return{k:f,x:a.w/2-(u.x+l+Te/2)*f,y:a.h/2-(u.y+l+Ce/2)*f}}function D0({y:t,width:s,height:r}){return i.jsxs("g",{className:"quarantine",children:[i.jsx("rect",{x:-20,y:t-30,width:s+40,height:r+18,fill:"url(#hatch-oos)"}),i.jsx("text",{x:-12,y:t-14,children:"Out of scope"})]})}const Ge=280,Vf=4,z0=220,Ns=t=>Math.round(t/Vf)*Vf;function B0(t){let s=2166136261;for(const r of t)s=Math.imul(s^r.charCodeAt(0),16777619);return()=>{s=s+1831565813|0;let r=Math.imul(s^s>>>15,1|s);return r=r+Math.imul(r^r>>>7,61|r)^r,((r^r>>>14)>>>0)/4294967296}}function wl(t,s,r,a){return Array.from({length:6},()=>{const l=a*(.5+t()*.7),u=a*(.3+t()*.4);return{x:Ns(s+(t()-.5)*a*.8-l/2),y:Ns(r+(t()-.5)*a*.5-u/2),w:Ns(l),h:Ns(u)}})}function F0(t){const{width:s,height:r,nodes:a}=t,l=B0(t.seed),u=(w,N)=>w+l()*(N-w),f=(w,N)=>!a.some(M=>w>M.x-52&&w<M.x+Te+28&&N>M.y-52&&N<M.y+Ce+28),m=(s+Ge*2)*(r+Ge*2),g=Array.from({length:Math.round(m/9e4)},()=>wl(l,u(-Ge,s+Ge),u(-Ge,r+Ge),u(160,360))).flat(),p=[...wl(l,s+Ge*.55,r+Ge*.55,300),...wl(l,-Ge*.5,-Ge*.45,220)],k=[],v=(w,N,M)=>{k.length<z0&&f(N,M)&&k.push({sprite:w,x:Ns(N),y:Ns(M)})};for(let w=0;w<Math.round(m/3e4);w++){const N=u(-Ge,s+Ge),M=u(-Ge,r+Ge),S=3+Math.floor(l()*5);for(let E=0;E<S;E++)v(l()<.65?"pine":"oak",N+u(-70,70),M+u(-44,44))}for(let w=0;w<Math.round(m/45e3);w++)v(l()<.4?"rock":"tuft",u(-Ge,s+Ge),u(-Ge,r+Ge));return k.sort((w,N)=>w.y-N.y),{grass:g,water:p,items:k}}const sm={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 U0({name:t}){return i.jsx("symbol",{id:`terrain-${t}`,overflow:"visible",children:sm[t]})}const W0=Object.keys(sm),H0=x.memo(function(s){const{seed:r,width:a,height:l,nodes:u}=s,f=x.useMemo(()=>F0({seed:r,width:a,height:l,nodes:u}),[r,a,l,u]);return i.jsxs("g",{className:"terrain","aria-hidden":"true",children:[i.jsx("defs",{children:W0.map(m=>i.jsx(U0,{name:m},m))}),f.grass.map((m,g)=>i.jsx("rect",{x:m.x,y:m.y,width:m.w,height:m.h,fill:"var(--map-grass)"},g)),f.water.map((m,g)=>i.jsx("rect",{x:m.x,y:m.y,width:m.w,height:m.h,fill:"var(--map-water)"},g)),i.jsx("rect",{x:-4e3,y:-4e3,width:a+8e3,height:l+8e3,fill:"url(#map-grid)"}),f.items.map((m,g)=>i.jsx("use",{href:`#terrain-${m.sprite}`,x:m.x,y:m.y},g))]})}),V0=380;function K0(t){const{selId:s,size:r}=t,a=x.useRef(t);a.current=t;const l=x.useRef(!0);x.useEffect(()=>{if(l.current){l.current=!1;return}const{nodes:u,pad:f,view:m,setView:g,onFocus:p}=a.current,k=s?u.find(I=>I.ticket.id===s):void 0;if(!k||!r.w)return;p();const v=Math.min(1.4,Math.max(m.k,1.05)),w={k:v,x:r.w/2-(f+k.x+Te/2)*v,y:r.h/2-(f+k.y+Ce/2)*v};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return g(w);const N=m,M=performance.now();let S=0;const E=I=>{const _=Math.min(1,(I-M)/V0),O=1-(1-_)**3;g({k:N.k+(w.k-N.k)*O,x:N.x+(w.x-N.x)*O,y:N.y+(w.y-N.y)*O}),_<1&&(S=requestAnimationFrame(E))};return S=requestAnimationFrame(E),()=>cancelAnimationFrame(S)},[s])}function Q0(t,s){const r=x.useRef(s);r.current=s,x.useEffect(()=>{const a=t.current;if(!a)return;const l=p=>{const k=a.getBoundingClientRect();return{x:p.clientX-k.left,y:p.clientY-k.top}},u=p=>{p.preventDefault();const k=p.ctrlKey?.01:.0015;r.current(Math.exp(-p.deltaY*k),l(p))};let f=1;const m=p=>{p.preventDefault(),f=1},g=p=>{p.preventDefault();const k=p;r.current(k.scale/f,l(k)),f=k.scale};return a.addEventListener("wheel",u,{passive:!1}),a.addEventListener("gesturestart",m,{passive:!1}),a.addEventListener("gesturechange",g,{passive:!1}),()=>{a.removeEventListener("wheel",u),a.removeEventListener("gesturestart",m),a.removeEventListener("gesturechange",g)}},[t])}const Wt=32,q0=1.8;function G0(t){const{snap:s,selection:r,onSelect:a,preview:l}=t,u=(l==null?void 0:l.tickets)??s.tickets,f=x.useRef(null),[m,g]=x.useState({w:0,h:0});x.useEffect(()=>{const L=f.current;if(!L)return;const Q=new ResizeObserver(([se])=>g({w:se.contentRect.width,h:se.contentRect.height}));return Q.observe(L),()=>Q.disconnect()},[]);const p=x.useMemo(()=>{const L=lf(u,"LR",s.map.mode),Q=lf(u,"TB",s.map.mode),se=ue=>Math.min(m.w/(ue.width+Wt*2),m.h/(ue.height+Wt*2+16));return se(L)*q0>=se(Q)?L:Q},[u,s.map.mode,m.w,m.h]),k=(L,Q)=>Math.min(1.25,Math.max(t.minFit??0,Math.min(m.w/L,m.h/Q))),v=x.useMemo(()=>{const L=p.width+Wt*2,Q=p.height+Wt*2+16,ue=p.nodes.some(B=>B.state==="out-of-scope")&&m.h?Math.max(0,m.h/k(L,Q)-Q):0;if(!ue)return{...p,slack:ue};const me=new Map(p.nodes.map(B=>[B,{...B,y:B.y+(B.state==="out-of-scope"?ue:ue/2)}]));return{...p,slack:ue,nodes:[...me.values()],edges:p.edges.map(B=>({from:me.get(B.from),to:me.get(B.to)})),quarantineY:p.quarantineY+ue,height:p.height+ue}},[p,m.w,m.h,t.minFit]),w=N0(v),N=w.right+Wt*2,M=w.bottom+Wt*2+16,S=()=>{const L=k(N,M);return{k:L,x:Math.max(0,(m.w-N*L)/2),y:Math.max(0,(m.h-M*L)/2)}},[E,I]=x.useState({k:1,x:0,y:0}),_=x.useRef(!1);x.useEffect(()=>{_.current=!1},[s.map.id]),x.useEffect(()=>{!_.current&&m.w&&I(P0({fit:S(),nodes:v.nodes,size:m,pad:Wt}))},[m.w,m.h,N,M,s.map.id]);const O=x.useRef(new Map),ee=x.useRef(null),q=L=>{const Q=f.current.getBoundingClientRect();return{x:L.clientX-Q.left,y:L.clientY-Q.top}},V=()=>{var ue;const L=[...O.current.values()],Q=L.length>1?{x:(L[0].x+L[1].x)/2,y:(L[0].y+L[1].y)/2}:L[0],se=L.length>1?Math.hypot(L[0].x-L[1].x,L[0].y-L[1].y):0;ee.current={view:E,dist:se,mid:Q,moved:((ue=ee.current)==null?void 0:ue.moved)??!1}},ie=(L,Q,se)=>{const ue=Math.min(3,Math.max(.2,Q));return{k:ue,x:se.x-(se.x-L.x)*ue/L.k,y:se.y-(se.y-L.y)*ue/L.k}};Q0(f,(L,Q)=>{_.current=!0,I(se=>ie(se,se.k*L,Q))});const ae=In(5e3),K=ql(t.leases,s.map.id),xe=Jl(),ze=new Map(t.sessions.filter(L=>Qt(L)&&L.ticketId).map(L=>[L.ticketId,L])),$e=(r==null?void 0:r.kind)==="ticket"?r.id:void 0;return K0({selId:$e,nodes:v.nodes,size:m,pad:Wt,view:E,setView:I,onFocus:()=>_.current=!0}),i.jsxs("div",{className:"graph-box",ref:f,onPointerDown:L=>{O.current.set(L.pointerId,q(L)),O.current.size===1&&(ee.current=null),V()},onPointerMove:L=>{var ue;if(!O.current.has(L.pointerId)||!ee.current)return;O.current.set(L.pointerId,q(L));const Q=ee.current,se=[...O.current.values()];if(se.length>1){const me={x:(se[0].x+se[1].x)/2,y:(se[0].y+se[1].y)/2},B=Math.hypot(se[0].x-se[1].x,se[0].y-se[1].y),F=ie(Q.view,Q.view.k*B/(Q.dist||B),Q.mid);I({...F,x:F.x+me.x-Q.mid.x,y:F.y+me.y-Q.mid.y}),Q.moved=!0}else{const me=se[0].x-Q.mid.x,B=se[0].y-Q.mid.y;if(!Q.moved&&Math.hypot(me,B)<5)return;Q.moved||(ue=f.current)==null||ue.setPointerCapture(L.pointerId),Q.moved=!0,I({...Q.view,x:Q.view.x+me,y:Q.view.y+B})}_.current=!0},onPointerUp:L=>{O.current.delete(L.pointerId),O.current.size&&V()},onPointerCancel:L=>O.current.delete(L.pointerId),onClickCapture:L=>{var Q;(Q=ee.current)!=null&&Q.moved&&(L.stopPropagation(),ee.current=null)},children:[i.jsxs("svg",{className:"graph",width:m.w,height:m.h,onClick:()=>a(null),children:[i.jsx(T0,{}),i.jsx("g",{transform:`translate(${E.x} ${E.y}) scale(${E.k})`,children:i.jsxs("g",{transform:`translate(${Wt} ${Wt})`,children:[i.jsx(H0,{seed:s.map.id,width:N,height:M,nodes:v.nodes}),v.nodes.some(L=>L.state==="out-of-scope")&&i.jsx(D0,{y:v.quarantineY,width:v.width,height:v.quarantineH}),v.edges.map(({from:L,to:Q})=>i.jsx(E0,{from:L,to:Q,direction:v.direction,added:l==null?void 0:l.newEdges.has(lo(L.ticket.id,Q.ticket.id)),removed:l==null?void 0:l.removedEdges.has(lo(L.ticket.id,Q.ticket.id))},`${L.ticket.id}-${Q.ticket.id}`)),i.jsx(b0,{trails:C0(v,w)}),v.nodes.length>0&&i.jsx($0,{x:w.x,y:w.y}),v.nodes.map(L=>i.jsx(L0,{n:L,session:ze.get(L.ticket.id),stalled:!!K.get(L.ticket.id)&&go(K.get(L.ticket.id),ae)!=="live",flag:mk(Ms.ticket(xe,s.map.id,L.ticket.id)),selected:$e===L.ticket.id,onSelect:a,mark:l==null?void 0:l.marks.get(L.ticket.id),frozen:l==null?void 0:l.frozen.has(L.ticket.id)},L.ticket.id))]})})]}),i.jsx("button",{className:"btn sm fit-btn","data-tip":"Fit the whole trail in view",onPointerDown:L=>L.stopPropagation(),onClick:L=>{L.stopPropagation(),_.current=!0,I(S())},children:"Fit"})]})}const jl=[["decided","Done"],["claimed","Working"],["frontier","Ready"],["blocked","Backlog"],["parked","Parked"],["out-of-scope","Cancelled"]],Kf=[["verifying","Verifying"],["rework","Rework"],["held","Blocked"]];function Y0({snap:t,sessions:s}){const r=lh(t),a=p=>r[p],l=s.filter(Ph).length,u=fv(t),f=Math.max(1,...u.map(p=>p.open+p.closed)),g=(t.map.verification??"off")!=="off"||Kf.some(([p])=>a(p))?[...jl.slice(0,2),...Kf,...jl.slice(2)]:jl;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(Xe,{as:"h3",children:"Status"}),i.jsxs("span",{className:"t-meta",children:[r.total," tickets"]})]}),i.jsxs("ul",{children:[g.map(([p,k])=>i.jsxs("li",{className:`st-${p} ${a(p)?"":"zero"}`,children:[i.jsx("i",{}),i.jsx("span",{children:k}),i.jsx("b",{children:a(p)})]},p)),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:u.map(p=>i.jsxs("li",{title:`${p.type}: ${p.closed} closed, ${p.open} open`,children:[i.jsx("span",{className:"t-meta",children:Mh[p.type]}),i.jsxs("span",{className:"mix-bar",children:[i.jsx("i",{className:"closed",style:{width:`${p.closed/f*100}%`}}),i.jsx("i",{className:"open",style:{width:`${p.open/f*100}%`}})]}),i.jsx("b",{children:p.open+p.closed})]},p.type))})]})]})}function J0(t){const[s,r]=x.useState(!1);return i.jsxs("div",{className:s?"status-drawer open":"status-drawer",children:[i.jsxs("button",{type:"button",className:"status-toggle","aria-expanded":s,onPointerDown:a=>a.stopPropagation(),onClick:()=>r(!s),children:["Summary ",i.jsx("span",{className:"caret",children:s?"▾":"▴"})]}),i.jsx(Y0,{snap:t.snap,sessions:t.sessions})]})}function X0({planOnly:t,verifies:s}){const r=[["frontier","Ready"],["claimed","Working"],...s?[["verifying","Verifying"],["rework","Rework"],["held","Blocked"]]:[],["stalled","Stalled"],["blocked","Backlog"],["decided","Done"],...t?[["parked","Parked"]]:[],["out-of-scope","Cancelled"],["waiting","Waiting on you"]];return i.jsxs("div",{className:"legend",children:[r.map(([a,l])=>i.jsxs("span",{className:`lg st-${a}`,children:[i.jsx("i",{}),l]},a)),i.jsx("span",{className:"lg hitl",children:"● needs human"})]})}function Z0(t){var a,l;const{snap:s,selection:r}=t.api;return i.jsxs(Ve,{as:"main",className:"zone map-zone",style:{gridArea:"map"},children:[s&&i.jsx(Aw,{}),(a=t.trail)==null?void 0:a.banner,i.jsxs("div",{className:"map-area",children:[s&&!t.compact&&i.jsx(J0,{snap:s,sessions:t.sessions}),s?i.jsx(G0,{snap:s,sessions:t.sessions,leases:t.api.leases,selection:r,onSelect:t.onSelect,minFit:t.minFit,preview:(l=t.trail)==null?void 0:l.preview}):i.jsxs("div",{className:"nomap",children:[i.jsx(_w,{}),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(G,{variant:"primary",onClick:t.onNewTrail,"data-tip":"Describe the idea and create the trail",children:"New trail…"})}),i.jsx(ao,{command:'/scout new "your idea"'})]}),s&&t.compact&&i.jsx(X0,{planOnly:s.map.mode==="plan-only",verifies:(s.map.verification??"off")!=="off"})]})]})}const ej=[["home","Inbox"],["map","Map"],["ticket","Ticket"],["activity","Activity"],["plan","Plan"]];function tj(t){const{tab:s,covered:r,pending:a}=t;return i.jsx("nav",{className:"tabbar",children:ej.map(([l,u])=>i.jsxs("button",{className:s===l&&!r?"on":"",onClick:()=>t.onPick(l),children:[u,l==="home"&&a>0&&i.jsx(ro,{n:a,urgent:!0,pop:!0},a)]},l))})}function nj(t){const s={home:t.inbox,map:t.map,ticket:i.jsx(Ve,{className:"zone",children:t.ticket}),activity:i.jsx(Ve,{className:"zone",children:t.activity}),plan:t.plan};return i.jsx("main",{className:"phone-view",children:t.decisions||s[t.tab]})}function sj(t,s){const{activity:r,selection:a,setSelection:l,actions:u}=t,[f,m]=x.useState("ticket"),[g,p]=x.useState("home"),[k,v]=x.useState(0),[w,N]=x.useState(null),[M,S]=x.useState(!1),E=q=>{S(!1),N({focus:q})},I=()=>{N(null),S(q=>!q)};return x.useEffect(()=>{const q=r.sessions.find(V=>V.id===t.chatSession);!a&&(q!=null&&q.ticketId)&&q.mapId===t.mapId&&l({kind:"ticket",id:q.ticketId})},[t.chatSession,t.mapId]),{sideTab:f,setSideTab:m,phoneTab:g,setPhoneTab:p,convRequest:k,decisionsView:w,setDecisionsView:N,openDecisions:E,statsOpen:M,setStatsOpen:S,toggleStats:I,select:q=>{l(q),q&&(s==="laptop"&&m("ticket"),s==="mobile"&&p("ticket"))},openChat:(q,V,ie)=>{ie&&ie!==t.mapId&&u.selectMap(ie),u.openChat(q);const ae=r.sessions.find(K=>K.id===q);V&&(ae==null?void 0:ae.mapId)===(ie??t.mapId)&&l({kind:"ticket",id:V}),s==="mobile"&&(p("home"),v(K=>K+1))},openTicket:(q,V)=>{q!==t.mapId&&u.selectMap(q),l({kind:"ticket",id:V}),N(null),s==="laptop"&&m("ticket"),s==="mobile"&&p("ticket")}}}function ij(t,s){x.useEffect(()=>{document.title=`${ne.name}: ${t?`(${t}) `:""}${s??"No trail"}`},[t,s])}function rj(t){const[s,r]=x.useState("…");return x.useEffect(()=>{fetch(`${ne.apiPrefix}/list`).then(a=>a.json()).then(a=>{var u;const l=a.root.split("/").filter(Boolean);r((u=l[l.length-1])!=null&&u.startsWith(".")?l[l.length-2]??"repo":l[l.length-1]??"repo")}).catch(()=>r("repo"))},[t]),s}function oj(t,s){return x.useMemo(()=>{const r=t.sessions.filter(l=>l.mapId===s),a=new Set(t.sessions.filter(l=>l.mapId!==s).map(l=>l.id));return{...t,sessions:r,feed:t.feed.filter(l=>!l.sessionId||!a.has(l.sessionId))}},[t,s])}function aj({text:t}){return t.trim()?i.jsx("div",{className:"brief-prose",children:t.split(`
136
+ `).map((s,r)=>i.jsx("p",{children:s.split(/(`[^`]+`|\/?\b[\w.-]+\/[\w./-]+\b)/g).map((a,l)=>l%2===1?i.jsx("code",{children:a.replace(/`/g,"")},l):a)},r))}):i.jsx(_e,{children:"Not covered"})}const Qf=["summary","productContext","existing","conventions","dataModel","api","risks"];function lj(t){const{brief:s}=t,[r,a]=x.useState(!1),[l,u]=x.useState("");x.useEffect(()=>{const p=k=>k.key==="Escape"&&t.onClose();return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[t]);const f=s.sections,m=Qf.filter(p=>f[p].trim()),g=Qf.filter(p=>!f[p].trim());return i.jsx("div",{className:"scrim",onClick:t.onClose,children:i.jsxs(Ve,{as:"div",className:"dialog brief-dialog",onClick:p=>p.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:"Discovery brief"}),i.jsx("span",{className:"t-meta",children:cj(s)})]}),i.jsxs("div",{className:"brief-body",children:[m.map(p=>i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:ji[p]}),i.jsx(aj,{text:f[p]}),(p==="conventions"||p==="productContext")&&f[p].trim()&&i.jsx(ec,{draft:()=>({title:`${ji[p]}: ${f[p].split(`
137
+ `)[0].slice(0,80)}`,body:f[p],kind:p==="conventions"?"convention":"business-rule",sources:[`brief:${s.mapId}`]})})]},p)),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:ji.assumptions}),f.assumptions.length?i.jsx("ul",{className:"item-list",children:f.assumptions.map(p=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:p.text}),i.jsx(ge,{parts:[{text:p.id,code:!0}]})]},p.id))}):i.jsx(_e,{children:"None listed"})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:ji.openQuestions}),f.openQuestions.length?i.jsx("ul",{className:"brief-list",children:f.openQuestions.map(p=>i.jsx("li",{children:p},p))}):i.jsx(_e,{children:"None"})]}),g.length>0&&i.jsxs("p",{className:"t-meta brief-empty",children:["Nothing noted on ",g.map(p=>ji[p].toLowerCase()).join(", "),"."]}),s.note&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Your last request"}),i.jsx("p",{children:s.note})]})]}),r&&i.jsx(He,{label:"What should change?",children:i.jsx("textarea",{rows:3,value:l,onChange:p=>u(p.target.value),autoFocus:!0})}),t.error&&i.jsx("p",{className:"urgent-text",children:t.error}),i.jsxs("div",{className:"actions",children:[s.status==="submitted"&&!r&&i.jsxs(i.Fragment,{children:[i.jsx(G,{onClick:()=>a(!0),children:"Request changes"}),i.jsx(G,{variant:"primary",onClick:t.onAccept,children:"Accept brief"})]}),r&&i.jsxs(i.Fragment,{children:[i.jsx(G,{variant:"ghost",onClick:()=>a(!1),children:"Back"}),i.jsx(G,{variant:"primary",disabled:!l.trim(),onClick:()=>t.onRequestChanges(l.trim()),children:"Send to the agent"})]}),i.jsx(G,{variant:"ghost",onClick:t.onClose,children:"Close"})]})]})})}function cj(t){if(t.status==="draft")return"Not submitted yet";const s=[t.status.replace("-"," ")];return t.author&&s.push(`by ${t.author}`),t.submittedAt&&s.push(`${Yn(Date.now()-t.submittedAt)} ago`),s.join(" · ")}function uj({brief:t,onReview:s}){return t.status!=="submitted"?null:i.jsx("div",{className:"brief-card",children:i.jsx(ct,{edge:"attention",title:"Discovery brief ready for your review",context:i.jsx(ge,{parts:["Discovery brief",t.author&&`by ${t.author}`]}),detail:t.sections.summary.split(`
138
+ `)[0],detailText:t.sections.summary,onOpen:s})})}const dj={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 fj({brief:t,onReview:s}){if(t.status==="accepted")return null;const[r,a]=dj[t.status],l=t.status==="submitted"?"edge-attention":"edge-neutral";return i.jsxs("div",{className:`discovery-banner map-banner ${l} st-${t.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:a})]}),i.jsx(Ri,{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(G,{size:"sm",variant:t.status==="submitted"?"primary":"ghost",onClick:s,children:t.status==="submitted"?"Review brief":"Open brief"})]})}const qf=`${ne.apiPrefix}/briefs`;function hj(t){const s=t==null?void 0:t.map.id,[r,a]=x.useState(null),[l,u]=x.useState(),f=x.useCallback(()=>{if(!s)return a(null);fetch(`${qf}?mapId=${encodeURIComponent(s)}`).then(k=>k.ok?k.json():{brief:null}).then(k=>a(k.brief)).catch(()=>a(null))},[s]),m=t==null?void 0:t.tickets.reduce((k,v)=>Math.max(k,v.updatedAt),t.map.updatedAt);x.useEffect(f,[f,m]),x.useEffect(()=>As(k=>k.startsWith("briefs/")&&f()),[f]);const g=(k,v)=>fetch(`${qf}/${k}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:s,note:v})}).then(async w=>{const N=await w.json().catch(()=>({}));if(!w.ok||!N.brief)throw new Error(N.error??`HTTP ${w.status}`);u(void 0),a(N.brief)}),p=(k,v)=>g(k,v).then(()=>!0,w=>(u(w.message),!1));return{brief:r,error:l,accept:()=>p("accept"),requestChanges:k=>p("request-changes",k)}}function mj(t){const s=hj(t),[r,a]=x.useState(!1),l=()=>a(!0),u=s.brief,f=u==null?void 0:u.sections;return{review:l,briefText:f?[f.existing,f.conventions,f.dataModel,f.api].join(`
139
+ `):"",banner:u&&i.jsx(fj,{brief:u,onReview:l}),inboxCard:u&&i.jsx(uj,{brief:u,onReview:l}),dialog:u&&r&&i.jsx(lj,{brief:u,error:s.error,onAccept:()=>void s.accept().then(m=>m&&a(!1)),onRequestChanges:m=>void s.requestChanges(m).then(g=>g&&a(!1)),onClose:()=>a(!1)})}}function pj({reroute:t,onReview:s}){var m;const r=t.kind==="challenge-destination",a=((m=t.frozen)==null?void 0:m.length)??0,l=r?"wrong mountain?":"proposes a new plan",u=a?` ${a} ticket${a===1?" is":"s are"} closed until you decide.`:"",f=`${t.reason.replace(/\.$/,"")}.${u}`;return i.jsxs("div",{className:"reroute-banner map-banner edge-attention",role:"status",title:f,children:[i.jsxs("span",{className:"mb-text",children:[i.jsxs("span",{className:"mb-lead",children:[t.by," ",l]}),i.jsx("span",{className:"t-meta",children:f})]}),i.jsx(Ri,{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(G,{size:"sm",variant:"primary",onClick:s,children:"Review"})]})}const gj={"already-exists":"The work already exists","wrong-problem":"The trail targets the wrong problem",rescope:"The trail should be rescoped"};function vj(t,s){var r;switch(t.op){case"add_ticket":{const a=(r=t.blockedBy)!=null&&r.length?`after ${t.blockedBy.map(s).join(", ")}`:void 0;return{verb:"Add",text:t.title,detail:[`new ${t.type} ticket`,a].filter(Boolean).join(" · ")}}case"cancel_ticket":return{verb:"Cancel",text:s(t.ticket),detail:t.reason};case"edit_ticket":return{verb:"Revise",text:s(t.ticket),detail:t.title?`New title: ${t.title}`:"New description"};case"rewire":return{verb:"Rewire",text:s(t.ticket),detail:yj(t,s)};case"supersede_decision":return{verb:"Supersede",text:t.decision,detail:`${t.answer}. ${t.rationale}`};case"update_destination":return{verb:"Destination",text:t.text};case"add_unspecified":return{verb:"Not yet specified",text:t.text};case"add_out_of_scope":return{verb:"Out of scope",text:t.text};case"reopen":return{verb:"Reopen",text:s(t.ticket),detail:`Back in the queue: ${t.reason}`};default:return t}}function yj(t,s){var a,l;return[...(a=t.addBlockedBy)!=null&&a.length?[`now also after ${t.addBlockedBy.map(s).join(", ")}`]:[],...(l=t.removeBlockedBy)!=null&&l.length?[`no longer after ${t.removeBlockedBy.map(s).join(", ")}`]:[]].join(" · ")}const kj=new Set(["cancel_ticket","update_destination"]);function xj({change:t,name:s}){const r=vj(t,s);return i.jsx(ct,{as:"li",className:`reroute-change op-${t.op}`,edge:kj.has(t.op)?"attention":"neutral",title:r.text,titleText:r.text,context:i.jsx(ge,{parts:[{text:r.verb,strong:!0}]}),detail:r.detail,detailText:r.detail})}function wj(t){const{reason:s,destination:r}=t;return i.jsxs("section",{className:"reroute-destination",children:[s&&i.jsx("p",{className:"reroute-destination-why",children:gj[s]}),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 jj(t,s){const r=new Map(t.tickets.map(l=>[l.id,l.key])),a=new Map(s.flatMap(l=>l.op==="add_ticket"?[[l.ref,l.title]]:[]));return l=>{const u=r.get(l);if(u)return u;const f=a.get(l);return f?`new: ${f}`:l}}function Sj(t){var w,N;const{reroute:s,snap:r}=t,[a,l]=x.useState("");x.useEffect(()=>{const M=S=>S.key==="Escape"&&t.onClose();return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[t]);const u=jj(r,s.changes),f=new Map(r.tickets.map(M=>[M.id,`${M.key} ${M.title}`])),m=M=>f.get(M)??u(M),g=r.map.sections.assumptions??[],p=s.invalidates.map(M=>g.find(S=>S.id===M)??{id:M,text:""}),k=s.status==="pending",v=s.kind==="challenge-destination";return i.jsx("div",{className:"scrim",onClick:t.onClose,children:i.jsxs(Ve,{as:"div",className:"dialog reroute-dialog",onClick:M=>M.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:v?"Destination challenged":"Reroute proposal"}),i.jsx(ge,{parts:[{text:s.id,code:!0},s.status,`by ${s.by}`,`${Yn(Date.now()-s.at)} ago`]})]}),i.jsxs("div",{className:"reroute-body",children:[v&&i.jsx(wj,{reason:s.destinationReason,destination:(w=s.diff)==null?void 0:w.destination}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Why"}),i.jsx("p",{children:s.reason})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Evidence"}),i.jsx("p",{className:"reroute-evidence",children:s.evidence})]}),p.length>0&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Assumptions it invalidates"}),i.jsx("ul",{className:"item-list",children:p.map(M=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:M.text}),i.jsx(ge,{parts:[{text:M.id,code:!0}]})]},M.id))})]}),i.jsxs("section",{children:[i.jsxs("h3",{className:"mono-label",children:["Changes · ",s.changes.length]}),i.jsx("ul",{className:"reroute-changes row-list",children:s.changes.map((M,S)=>i.jsx(xj,{change:M,name:m},S))})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Closed until you decide"}),(N=s.frozen)!=null&&N.length?i.jsx("ul",{className:"item-list",children:s.frozen.map(M=>i.jsx("li",{className:"item-text",children:m(M)},M))}):i.jsx(_e,{children:"No tickets closed"})]}),s.note&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Your note"}),i.jsx("p",{children:s.note})]})]}),k&&i.jsx(He,{label:"Note for the agent (required to reject)",children:i.jsx("textarea",{rows:2,value:a,onChange:M=>l(M.target.value)})}),t.error&&i.jsx("p",{className:"urgent-text",children:t.error}),i.jsxs("div",{className:"actions",children:[k&&i.jsxs(i.Fragment,{children:[i.jsx(G,{className:"reroute-reject",disabled:!a.trim(),onClick:()=>t.onReject(a.trim()),children:"Reject"}),i.jsx(G,{className:"reroute-approve",variant:"primary",onClick:()=>t.onApprove(a.trim()),children:"Approve and apply"})]}),i.jsx(G,{variant:"ghost",onClick:t.onClose,children:"Close"})]})]})})}const Gf=`${ne.apiPrefix}/reroutes`;function Nj(t){const s=t==null?void 0:t.map.id,[r,a]=x.useState([]),[l,u]=x.useState(),f=x.useCallback(()=>{if(!s)return a([]);fetch(`${Gf}?map=${encodeURIComponent(s)}`).then(p=>p.ok?p.json():{reroutes:[]}).then(p=>a(p.reroutes)).catch(()=>a([]))},[s]),m=t==null?void 0:t.tickets.reduce((p,k)=>Math.max(p,k.updatedAt),t.map.updatedAt);x.useEffect(f,[f,m]),x.useEffect(()=>vk("reroute",p=>{p.mapId===s&&f()}),[f,s]);const g=async(p,k,v)=>{var S;const w=await fetch(`${Gf}/${p}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:s,id:k,note:v})}),N=await w.json().catch(()=>({}));if(w.ok)return u(void 0),f(),!0;const M=(S=N.errors)==null?void 0:S.map(E=>E.message).join("; ");return u([N.error??`HTTP ${w.status}`,M].filter(Boolean).join(": ")),!1};return{reroutes:r,pending:r.find(p=>p.status==="pending"),error:l,clearError:()=>u(void 0),approve:(p,k)=>g("approve",p,k),reject:(p,k)=>g("reject",p,k)}}function Cj(t,s){const r=Nj(t),[a,l]=x.useState(),u=r.reroutes.find(p=>p.id===a),f=u!=null&&u.diff?u:r.pending,m=()=>{l(void 0),r.clearError()},g=p=>p&&m();return{banner:r.pending&&i.jsx(pj,{reroute:r.pending,onReview:()=>{var p;return l((p=r.pending)==null?void 0:p.id)}}),preview:t&&(f!=null&&f.diff)?_0(t,f.diff,f.frozen):void 0,openReroute:(p,k)=>{p!==(t==null?void 0:t.map.id)&&(s==null||s(p)),l(k)},dialog:t&&u&&i.jsx(Sj,{reroute:u,snap:t,error:r.error,onApprove:p=>void r.approve(u.id,p||void 0).then(g),onReject:p=>void r.reject(u.id,p).then(g),onClose:m})}}function $j(t,s){const r=mj(t),a=Cj(t,s);return{briefText:r.briefText,inboxCard:r.inboxCard,review:r.review,banner:i.jsxs(i.Fragment,{children:[r.banner,a.banner]}),preview:a.preview,openReroute:a.openReroute,dialog:i.jsxs(i.Fragment,{children:[r.dialog,a.dialog]})}}function bj(t){const{api:s,nav:r}=t,a=Kh(s.allSnaps);kw(a.view);const l=g=>g&&s.actions.selectMap(g),u={openTicket:r.openTicket,openKnowledge:()=>t.knowledge.setOpen(!0),openBrief:g=>g===s.mapId?t.reviewBrief():l(g),openReroute:t.openReroute??(g=>g.ticketId?r.openTicket(g.mapId,g.ticketId):l(g.mapId)),selectTrail:l},f=a.view;return{attention:a,handlers:u,header:f&&i.jsx(pw,{view:f,onFocus:g=>void a.savePrefs({...f.prefs,focusUntil:g})})}}function Tj(t){const{d:s,snap:r}=t,[a,l]=x.useState(!1),[u,f]=x.useState(""),[m,g]=x.useState("");x.useEffect(()=>{l(!1),f(""),g("")},[s.id,s.mapId]);const p=Xg(t.all.filter(N=>N.mapId===s.mapId),s.id),k=Ai(s),v=s.ticketId?r==null?void 0:r.tickets.find(N=>N.id===s.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:s.id}),i.jsx(An,{tone:"state",className:`dv-st-${k}`,children:k}),i.jsx(ge,{parts:[fk(s.decidedAt),`${Yn(w-s.decidedAt)} ago`]})]}),i.jsx("h3",{className:"t-heading",children:s.question}),i.jsxs("div",{className:"resolution",children:[i.jsx(oo,{parts:["Decision"]}),i.jsx("p",{children:s.answer})]}),i.jsxs("dl",{className:"facts",children:[i.jsx("dt",{children:"Trail"}),i.jsx("dd",{children:r?`${r.map.key} ${r.map.title}`:s.mapId}),i.jsx("dt",{children:"Ticket"}),i.jsx("dd",{children:s.ticketId?i.jsxs("button",{className:"link",onClick:()=>t.onOpenTicket(s.mapId,s.ticketId),children:[s.ticketKey," ",(v==null?void 0:v.title)??""," · open in trail ›"]}):"—"}),i.jsx("dt",{children:"Decided by"}),i.jsx("dd",{children:s.decidedBy}),s.participants.length>1&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Participants"}),i.jsx("dd",{children:s.participants.map(N=>N.name??N.id).join(", ")})]}),i.jsx("dt",{children:"Source"}),i.jsxs("dd",{children:[Tn[s.source.kind].label,s.source.url&&i.jsxs(i.Fragment,{children:[" · ",i.jsx("a",{href:s.source.url,target:"_blank",rel:"noreferrer",children:s.source.label??"link"})]}),!s.source.url&&s.source.label&&` · ${s.source.label}`,s.source.ref&&i.jsxs("span",{className:"ref",children:[" ",s.source.ref]})]})]}),s.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:s.alternatives.map(N=>i.jsx("li",{children:N},N))})]}),s.rationale&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Rationale"}),i.jsx("p",{children:s.rationale})]}),p.length>1&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Supersession"}),i.jsx("ol",{className:"dv-chain",children:p.map(N=>i.jsx("li",{className:`${N.id===s.id?"cur":""} ${N.supersededBy?"old":"live"}`,children:i.jsxs("button",{onClick:()=>t.onSelect(N.id),children:[i.jsx("i",{}),i.jsx("span",{className:"id",children:N.id}),i.jsx("span",{className:"a",children:N.summary}),i.jsx(ge,{parts:[N.decidedBy,Es(N.decidedAt)]})]})},N.id))})]}),i.jsxs("div",{className:"actions",children:[i.jsx(ec,{draft:()=>({title:s.summary||s.question,body:[s.answer,s.rationale&&`Why: ${s.rationale}`].filter(Boolean).join(`
140
+
141
+ `),kind:"product-decision",sources:[`decision:${s.id}`,...s.ticketKey?[`ticket:${s.ticketKey}`]:[]]})}),k==="active"&&i.jsx(G,{on:a,onClick:()=>l(N=>!N),"data-tip":"Replace this decision with a new answer. Both stay on record",children:"Supersede…"})]}),a&&i.jsxs(Et,{as:"form",tone:"inset",className:"inline-form",onSubmit:N=>{N.preventDefault(),u.trim()&&(t.onSupersede(s,{answer:u.trim(),rationale:m.trim(),alternatives:[s.summary]}),l(!1))},children:[i.jsx(He,{label:"New decision",children:i.jsx("textarea",{rows:3,value:u,onChange:N=>f(N.target.value),autoFocus:!0})}),i.jsx(He,{label:"Rationale",children:i.jsx("input",{value:m,onChange:N=>g(N.target.value)})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(G,{variant:"ghost",onClick:()=>l(!1),children:"Cancel"}),i.jsx(G,{type:"submit",variant:"primary",disabled:!u.trim(),children:"Supersede"})]})]}),i.jsxs("div",{className:"dv-sec",children:[i.jsxs("h4",{className:"mono-label",children:["Transcript ",i.jsx("span",{className:"n",children:s.transcript.length})]}),s.transcript.length?i.jsx("div",{className:"dv-transcript comms-log",children:s.transcript.map((N,M)=>i.jsxs("div",{className:`msg from-${N.from} voice-${N.from==="human"?"human":"agent"}`,children:[i.jsx(oo,{parts:[N.author,Ql(N.at)]}),i.jsx("div",{className:"msg-text",children:N.text})]},M))}):i.jsx(_e,{children:"None recorded"})]})]})}function Tt(t){return i.jsx("li",{children:i.jsxs("button",{className:`dv-opt ${t.on?"on":""} ${t.cls??""}`,onClick:t.onClick,children:[i.jsx("span",{className:"ttl",children:t.label}),i.jsx("b",{children:t.n})]})})}function Ej(t){const{filter:s,set:r,all:a}=t,l=u=>a.filter(u).length;return t.compact?i.jsxs("div",{className:"dv-filters compact",children:[i.jsx(wt,{compact:!0,"aria-label":"Trail",value:s.mapId??"",onChange:u=>r({mapId:u||void 0}),options:[{value:"",label:"All trails"},...t.trails.map(u=>({value:u.map.id,label:`${u.map.key} ${u.map.title}`}))]}),i.jsx(wt,{compact:!0,"aria-label":"Source",value:s.source??"",onChange:u=>r({source:u||void 0}),options:[{value:"",label:"All sources"},...no.map(u=>({value:u,label:Tn[u].label}))]}),i.jsx(wt,{compact:!0,"aria-label":"Decided by",value:s.decidedBy??"",onChange:u=>r({decidedBy:u||void 0}),options:[{value:"",label:"Anyone"},...t.people.map(u=>({value:u,label:u}))]}),i.jsx(wt,{compact:!0,"aria-label":"Status",value:s.status??"",onChange:u=>r({status:u||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(Tt,{on:!s.mapId,label:"All trails",n:a.length,onClick:()=>r({mapId:void 0})}),t.trails.map(u=>i.jsx(Tt,{on:s.mapId===u.map.id,label:`${u.map.key} ${u.map.title}`,n:l(f=>f.mapId===u.map.id),onClick:()=>r({mapId:u.map.id})},u.map.id))]}),i.jsx("h3",{className:"mono-label",children:"Source"}),i.jsxs("ul",{children:[i.jsx(Tt,{on:!s.source,label:"All",n:a.length,onClick:()=>r({source:void 0})}),no.map(u=>i.jsx(Tt,{cls:`src-${u}`,on:s.source===u,label:Tn[u].label,n:l(f=>f.source.kind===u),onClick:()=>r({source:s.source===u?void 0:u})},u))]}),i.jsx("h3",{className:"mono-label",children:"Made by"}),i.jsxs("ul",{children:[i.jsx(Tt,{on:!s.madeBy,label:"Anyone",n:a.length,onClick:()=>r({madeBy:void 0})}),i.jsx(Tt,{on:s.madeBy==="agent",label:"Agents, on their own",n:l(u=>Ti(u)==="agent"),onClick:()=>r({madeBy:s.madeBy==="agent"?void 0:"agent"})}),i.jsx(Tt,{on:s.madeBy==="human",label:"People",n:l(u=>Ti(u)==="human"),onClick:()=>r({madeBy:s.madeBy==="human"?void 0:"human"})})]}),i.jsx("h3",{className:"mono-label",children:"Decided by"}),i.jsxs("ul",{children:[i.jsx(Tt,{on:!s.decidedBy,label:"Anyone",n:a.length,onClick:()=>r({decidedBy:void 0})}),t.people.map(u=>i.jsx(Tt,{on:s.decidedBy===u,label:u,n:l(f=>f.decidedBy===u),onClick:()=>r({decidedBy:s.decidedBy===u?void 0:u})},u))]}),i.jsx("h3",{className:"mono-label",children:"Status"}),i.jsxs("ul",{children:[i.jsx(Tt,{on:!s.status,label:"Any",n:a.length,onClick:()=>r({status:void 0})}),i.jsx(Tt,{on:s.status==="active",label:"Active",n:l(u=>!u.supersededBy),onClick:()=>r({status:s.status==="active"?void 0:"active"})}),i.jsx(Tt,{on:s.status==="superseded",label:"Superseded",n:l(u=>!!u.supersededBy),onClick:()=>r({status:s.status==="superseded"?void 0:"superseded"})})]})]})}function Mj(t){if(Ai(t)==="superseded")return`Replaced by ${t.supersededBy}`;if(t.supersedes)return`Replaces ${t.supersedes}`}function Ij(t){const{d:s}=t,r=Ai(s);return i.jsxs(i.Fragment,{children:[t.newDay&&i.jsx("li",{className:"dv-day t-label",children:Es(s.decidedAt)}),i.jsx(ct,{as:"li",className:`dv-row ${r}`,selected:t.on,onOpen:t.onClick,title:s.question,titleText:s.question,trailing:Ql(s.decidedAt),context:i.jsx(ge,{parts:[{text:s.id,code:!0},s.ticketKey&&{text:s.ticketKey,code:!0},t.showTrail&&t.trail,s.decidedBy,Tn[s.source.kind].label,Mj(s)]}),detail:s.summary,detailText:s.summary})]})}function Aj(t){const{rows:s,current:r}=t;return i.jsx("ol",{className:"dv-list","aria-label":"Logbook",children:s.length?s.map((a,l)=>{var u;return i.jsx(Ij,{d:a,newDay:l===0||Es(s[l-1].decidedAt)!==Es(a.decidedAt),trail:(u=t.snaps[a.mapId])==null?void 0:u.map.key,on:(r==null?void 0:r.id)===a.id&&r.mapId===a.mapId,showTrail:t.showTrail,onClick:()=>t.onSelect(a.id)},`${a.mapId}:${a.id}`)}):i.jsx(_e,{children:"No decisions"})})}function Lj({stats:t}){return i.jsxs("span",{className:"dv-readouts",children:[i.jsx(Kt,{layout:"start",label:"Active",value:t.active}),i.jsx(Kt,{layout:"start",label:"Superseded",value:t.superseded}),i.jsx(Kt,{layout:"start",label:"Last 24h",value:t.last24h}),i.jsx(Kt,{layout:"start",label:"Human",value:`${t.total?Math.round(t.human/t.total*100):0}%`}),i.jsx(ge,{className:"dv-src-mix",parts:no.filter(s=>t.bySource[s]).map(s=>`${Tn[s].label} ${t.bySource[s]}`)})]})}function Rj(t){const{filter:s}=t,a=Object.values(s).filter(Boolean).length-(s.query?1:0),l=t.filtersOpen||a>0;return i.jsxs("div",{className:"dv-search",children:[i.jsx("input",{type:"search",placeholder:"Search decisions",value:s.query??"",onChange:u=>t.set({query:u.target.value})}),t.showToggle&&i.jsxs("button",{className:`chip ${l?"on":""}`,onClick:t.onToggle,children:["Filters",a>0?` · ${a}`:""]})]})}function Oj(t){const{api:s,bp:r}=t,a=s.decisions,[l,u]=x.useState({}),[f,m]=x.useState(t.focus),[g,p]=x.useState(!1);x.useEffect(()=>m(t.focus),[t.focus]),x.useEffect(()=>{const _=O=>{O.key==="Escape"&&(r==="mobile"&&f?m(void 0):t.onClose())};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[r,f,t]);const k=x.useMemo(()=>gv(a,l),[a,l]),v=x.useMemo(()=>vv(a),[a]),w=a.find(_=>_.id===f&&(!l.mapId||_.mapId===l.mapId))??(r==="mobile"?void 0:k[0]),N=x.useMemo(()=>Object.values(s.allSnaps).sort((_,O)=>O.map.createdAt-_.map.createdAt),[s.allSnaps]),M=x.useMemo(()=>[...new Set(a.map(_=>_.decidedBy))].sort(),[a]),S=_=>u(O=>({...O,..._})),E=()=>{const _=Object.fromEntries(N.map(O=>[O.map.id,{key:O.map.key,title:O.map.title}]));bh(`${ne.slug}-decisions-${Es(Date.now())}.md`,Tv(k,_,{title:`${ne.name} decisions`}))},I=r==="mobile"&&!!w;return i.jsxs(Ve,{className:`zone decisions-view dv-${r}`,children:[i.jsxs("header",{className:"dv-head",children:[I?i.jsx("button",{className:"back",onClick:()=>m(void 0),children:"‹ Decisions"}):i.jsxs(Xe,{as:"h2",children:["Decisions ",k.length!==a.length&&i.jsx("span",{className:"n",children:`${k.length}/${a.length}`})]}),r!=="mobile"&&i.jsx(Lj,{stats:v}),i.jsxs("span",{className:"dv-head-right",children:[!I&&i.jsx(G,{onClick:E,disabled:!k.length,title:"Export the filtered list as markdown",children:"Export .md"}),i.jsx("button",{className:"icon-btn",onClick:t.onClose,"aria-label":"Close",children:"×"})]})]}),!I&&i.jsx(Rj,{filter:l,set:S,showToggle:r!=="wide",filtersOpen:g,onToggle:()=>p(_=>!_)}),i.jsxs("div",{className:"dv-body",children:[(r==="wide"||g&&!I)&&i.jsx(Ej,{filter:l,set:S,all:a,trails:N,people:M,compact:r!=="wide"}),!I&&i.jsx(Aj,{rows:k,current:w,snaps:s.allSnaps,showTrail:r==="wide",onSelect:m}),(r!=="mobile"||w)&&i.jsx("div",{className:"dv-detail",children:w?i.jsx(Tj,{d:w,all:a,snap:s.allSnaps[w.mapId],onSelect:m,onOpenTicket:t.onOpenTicket,onSupersede:s.actions.supersede}):i.jsx(_e,{children:"No decision selected"})})]})]})}const Zr=(t,s)=>`${t} ${s}${t===1?"":"s"}`;function _j({rows:t}){return t.length?i.jsx("ul",{className:"perf-rows",children:t.map(s=>i.jsx(ct,{as:"li",className:"perf-row",title:s.key,trailing:i.jsx("span",{title:"Median time from first claim to done",children:rn(s.medianLeadMs)}),context:i.jsx(ge,{parts:[`${s.done} of ${Zr(s.tickets,"ticket")} done`,s.cancelled>0&&`${s.cancelled} cancelled`,Zr(s.reworkCycles,"rework"),`reviews ${s.reviews.passed} passed, ${s.reviews.failed} failed`,s.answers>0&&Zr(s.answers,"question")]}),detail:s.findings.raised>0?`As reviewer: ${s.findings.upheld} of ${Zr(s.findings.raised,"finding")} upheld`:void 0},s.key))}):i.jsx(_e,{children:"No claimed tickets yet"})}function Pj(t){const[s,r]=x.useState({}),a=t.map(l=>`${l.map.id}:${l.tickets.reduce((u,f)=>Math.max(u,f.updatedAt),0)}`).join();return x.useEffect(()=>{let l=!0;return Promise.all(t.map(async u=>{const f=await fetch(`${ne.apiPrefix}/journal?mapId=${encodeURIComponent(u.map.id)}`).catch(()=>{}),m=f!=null&&f.ok?await f.json():{entries:[]};return[u.map.id,m.entries]})).then(u=>{l&&r(Object.fromEntries(u))}),()=>{l=!1}},[a]),s}const Dj=[{id:"byVendor",title:"By vendor"},{id:"byAgent",title:"By agent"},{id:"byType",title:"By ticket type"}];function zj({api:t,bp:s,onClose:r}){const[a,l]=x.useState("byVendor"),u=x.useMemo(()=>Object.values(t.allSnaps),[t.allSnaps]),f=Pj(u),m=t.activity.answered,g=x.useMemo(()=>Kv(u.map(p=>({snap:p,journal:f[p.map.id]??[],answered:m}))),[u,f,m]);return x.useEffect(()=>{const p=k=>k.key==="Escape"&&r();return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[r]),i.jsxs(Ve,{className:`zone decisions-view perf-view dv-${s}`,children:[i.jsxs("header",{className:"dv-head",children:[i.jsx(Xe,{as:"h2",children:"Trail stats"}),i.jsx(ge,{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(Xe,{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(p=>i.jsxs("li",{title:p.because,children:[i.jsx("span",{children:p.text}),i.jsx("span",{className:"t-meta",children:p.because})]},p.id))}):i.jsx(_e,{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:Dj.map(p=>i.jsx(lt,{on:a===p.id,title:p.title,onClick:()=>l(p.id)},p.id))}),i.jsx(_j,{rows:g[a]}),i.jsx("p",{className:"perf-note t-meta",children:"Spend is tracked per trail, so it isn't split by agent here."})]})]})]})}function Bj({api:t,bp:s,nav:r}){return r.statsOpen?i.jsx(zj,{api:t,bp:s,onClose:()=>r.setStatsOpen(!1)}):r.decisionsView?i.jsx(Oj,{api:t,bp:s,focus:r.decisionsView.focus,onClose:()=>r.setDecisionsView(null),onOpenTicket:r.openTicket}):null}function im({activity:t,onTicket:s}){const r=t.feed.slice(-120).reverse();return r.length?i.jsx("div",{className:"log",children:r.map(a=>i.jsxs("div",{className:`log-row lv-${a.level} src-${a.source} ${a.signal?"signal":""}`,onClick:()=>a.ticketId&&s(a.ticketId),children:[i.jsx("span",{className:"t t-meta",children:Kl(a.at)}),i.jsxs("span",{className:"src t-meta",children:[a.source==="system"&&i.jsx(Xl,{className:"voice-badge"}),a.agent??a.source]}),i.jsxs("span",{className:"msg",children:[a.tag&&i.jsxs("span",{className:"tag t-meta",children:[a.tag," · "]}),a.text]})]},a.id))}):i.jsx(qn,{title:"Nothing has happened yet",hint:"Claims, steps, questions and decisions appear here as agents work."})}function Yf({lease:t,now:s}){if(!t)return null;const r=go(t,s);if(r==="live")return null;const a=t.expiresAt-s;return i.jsxs(An,{tone:"amber",className:"stalled",title:`No activity from ${t.agent}; the ticket returns to the queue when the lease runs out`,children:["stalled · ",r==="expired"?"returning":Pt(a)]})}function Fj({total:t,step:s}){return i.jsx("span",{className:"segs","aria-label":`Step ${s} of ${t}`,children:Array.from({length:t},(r,a)=>i.jsx("i",{className:Uj(a+1,s)},a))})}function Uj(t,s){return t<s?"done":t===s?"cur":""}function rm({snap:t,activity:s,leases:r,onSelect:a,onOpenChat:l}){const u=In(1e3),f=s.sessions.filter(Qt),m=new Set(f.map(v=>v.ticketId)),g=ql(r,t==null?void 0:t.map.id),p=(t==null?void 0:t.tickets.filter(v=>v.state==="open"&&v.assignee&&!m.has(v.id)))??[];if(!f.length&&!p.length)return i.jsx(_e,{children:"No agent on a ticket"});const k=v=>!!v&&go(v,u)!=="live";return i.jsxs("ul",{className:"sessions-list",children:[f.map(v=>{const w=t==null?void 0:t.tickets.find(S=>S.id===v.ticketId),N=w?Ii(w)==="hitl":!1,M=w&&g.get(w.id);return i.jsx(ct,{as:"li",className:v.waitingOn?"waiting":void 0,edge:Wj(v,k(M)),title:Vj(w,v.mode)||v.agent,context:i.jsx(ge,{parts:[{text:v.agent,strong:!0},v.waitingOn?{text:"Waiting on you",urgent:!0}:`${v.mode} · ${v.stepLabel.toLowerCase()}`,N&&!v.waitingOn&&"with you",Hj(v)],children:i.jsx(Yf,{lease:M,now:u})}),trailing:Th(u-v.startedAt),below:i.jsx(Fj,{total:v.total,step:v.step}),onOpen:()=>{w&&a({kind:"ticket",id:w.id}),N&&l(v.id)}},v.id)}),p.map(v=>i.jsx(ct,{as:"li",className:"claim",edge:k(g.get(v.id))?"attention":"neutral",title:`${v.key} ${v.title}`,context:i.jsx(ge,{parts:[{text:v.assignee??"",strong:!0},"claimed, no live session"],children:i.jsx(Yf,{lease:g.get(v.id),now:u})}),onOpen:()=>a({kind:"ticket",id:v.id})},v.id))]})}function Wj(t,s){return t.waitingOn?"urgent":s?"attention":"neutral"}function Hj(t){if(t.usage)return`${vo(mv(t))} tok · ${Ts(t.usage.costUsd)}`}function Vj(t,s){return t?`${t.key} ${t.title}`:s==="chart"?"Charting trail":""}function om({activity:t,snap:s,running:r,usage:a=!0}){const l=uh(t,s==null?void 0:s.map.id),u=fh(t,s==null?void 0:s.map.id),f=new Set(t.sessions.filter(Qt).map(g=>g.ticketId)),m=(s==null?void 0:s.tickets.filter(g=>g.state==="open"&&g.assignee&&!f.has(g.id)).length)??0;return i.jsx(on,{sub:!0,className:"sessions-head",title:i.jsxs(i.Fragment,{children:["Agents on tickets ",i.jsx("span",{className:"n",children:r+m})]}),right:a?i.jsxs("span",{className:"usage",title:["Model usage for this trail, all sessions",...u.map(g=>dh[g].text)].join(`
142
+ `),children:[i.jsx("span",{className:"mono-label",children:"Trail"})," ",vo(l.inputTokens+l.outputTokens)," tok · ",Ts(l.costUsd)]}):void 0})}function Kj(t){const s=[...t.feed].reverse().find(r=>r.level==="step"&&r.sessionId);return s?t.sessions.find(r=>r.id===s.sessionId):void 0}const Qj={running:"Working",done:"Done",failed:"Stopped"};function am({activity:t,snap:s}){const r=ko(),a=Kj(t);if(!a)return i.jsx(qn,{art:i.jsx(Li,{size:1,framed:!1,variant:r?"night":"crt",label:"Scout"}),title:"No agent working yet",hint:"Run /scout resume in Claude Code or Codex. Each step an agent reports shows here."});const l=a.ticketId?s==null?void 0:s.tickets.find(m=>m.id===a.ticketId):void 0,u=fo[a.mode],f=a.waitingOn?"Waiting on you":Qj[a.status];return i.jsxs("div",{className:`step-tracker ${a.waitingOn?"waiting":""}`,children:[i.jsxs("div",{className:"st-meta",children:[i.jsx(ge,{parts:[{text:a.agent,strong:!0},`${a.mode}, step ${a.step} of ${a.total}`]}),i.jsx("span",{className:`t-label st-status ${a.waitingOn?"urgent":""}`,children:f})]}),i.jsxs("div",{className:"st-big",children:[a.stepLabel,l&&i.jsxs("span",{className:"st-key",children:[" ",l.key]})]}),l&&i.jsx("div",{className:"st-ticket t-meta",children:l.title}),i.jsx("ol",{className:"pipeline",children:u.map((m,g)=>{const p=g+1,k=p<a.step||p===a.step&&a.status==="done";let v="";return k?v="done":p===a.step&&(v="cur"),i.jsxs("li",{className:v,children:[i.jsx("i",{}),i.jsxs("span",{children:[String(p).padStart(2,"0")," ",m]})]},m)})})]})}function Jf(t){return i.jsxs("div",{className:"zone-b activity-stack",children:[i.jsx(am,{activity:t.activity,snap:t.snap}),i.jsx(om,{activity:t.activity,snap:t.snap,running:t.activity.sessions.filter(Qt).length}),i.jsx(rm,{snap:t.snap,activity:t.activity,leases:t.leases,onSelect:s=>(s==null?void 0:s.kind)==="ticket"&&t.onTicket(s.id),onOpenChat:t.onOpenChat}),i.jsx(on,{sub:!0,title:"Activity log"}),i.jsx(im,{activity:t.activity,onTicket:t.onTicket})]})}function qj(t){return i.jsx(Bh,{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:[t.activity.feed.length," events"]}),children:i.jsx(im,{activity:t.activity,onTicket:t.onTicket})})}function Gj(t){var a;const s=t.activity.sessions.filter(Qt).length,r=!t.activity.sessions.length&&!((a=t.snap)!=null&&a.tickets.some(l=>l.state==="open"&&l.assignee));return i.jsxs(Ve,{className:"zone step-zone",style:{gridArea:"step"},children:[i.jsx(on,{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(am,{activity:t.activity,snap:t.snap}),!r&&i.jsxs(i.Fragment,{children:[i.jsx(om,{activity:t.activity,snap:t.snap,running:s,usage:!1}),i.jsx(rm,{snap:t.snap,activity:t.activity,leases:t.leases,onSelect:l=>(l==null?void 0:l.kind)==="ticket"&&t.onTicket(l.id),onOpenChat:t.onOpenChat})]})]})]})}const Xf=`${ne.apiPrefix}/criteria`;function Yj(t){const[s,r]=x.useState([]),a=x.useCallback(()=>{if(!t)return r([]);fetch(`${Xf}?mapId=${encodeURIComponent(t)}`).then(u=>u.ok?u.json():{tickets:[]}).then(u=>r(u.tickets)).catch(()=>r([]))},[t]);return x.useEffect(()=>(a(),As(u=>u.startsWith("criteria/")&&a())),[a]),{tickets:s,confirm:u=>fetch(`${Xf}/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,...u})}).then(a)}}function Jj({snap:t,t:s}){const{tickets:r,confirm:a}=Yj(t.map.id),l=Rs(),u=r.find(p=>p.ticketId===s.id),f=(u==null?void 0:u.criteria)??[],g=xh(l.entries,{trailKey:t.map.key,ticket:{type:s.type,title:s.title,body:s.body},paths:wh(`${s.body}
143
+ ${l.briefText}`)}).filter(p=>p.kind==="business-rule").filter(p=>Gv(f,[p.id]).length);return!f.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 · ",f.length,(u==null?void 0:u.confirmed)&&i.jsx("span",{className:"ok-text",children:" · confirmed by you"})]}),f.length>0&&i.jsx("ul",{className:"criteria-list item-list",children:f.map(p=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:p.text}),i.jsx(ge,{parts:[{text:p.id,code:!0},p.kind.replace("-"," "),p.source&&`from ${p.source}`]})]},p.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(p=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:p.title}),i.jsx(ge,{parts:[{text:p.id,code:!0},"business rule"]})]},p.id))})]}),f.length>0&&s.state==="open"&&i.jsx(G,{size:"sm",variant:u!=null&&u.confirmed?"ghost":"default","data-tip":u!=null&&u.confirmed?"Take your confirmation back":"Agree that these criteria define done for this ticket",onClick:()=>void a({title:t.map.title,ticketId:s.id,ticketKey:s.key,confirmed:!(u!=null&&u.confirmed)}),children:u!=null&&u.confirmed?"Unconfirm":"Confirm criteria"})]})}const co="";function Xj(t){const s=Ul.map(a=>({value:a,label:Mi[a],hint:Qh[a]})),r=[...Zj(t),...s];return i.jsx(wt,{compact:!0,className:"vf-level","aria-label":"Verification level",value:t.value??co,options:r,onChange:a=>t.onChange(a===co?null:a)})}function Zj(t){return t.inherit!==void 0?[{value:co,label:t.inherit,hint:"Use the trail’s level for this ticket."}]:t.value===void 0?[{value:co,label:"Off (not set)"}]:[]}function e1({check:t}){const s=Sw(t),[r,a]=x.useState(),[l,u]=x.useState(),f=t1(t);return i.jsxs("details",{className:`vf-row ${s?"ok":"bad"}`,open:!s,children:[i.jsxs("summary",{children:[i.jsx("span",{className:"vf-mark",children:s?"✓":"✕"}),i.jsx("span",{className:"t-code vf-name",children:t.name}),i.jsx("span",{className:"t-meta",children:f}),i.jsx("span",{className:"t-meta vf-dur",children:Pt(t.durationMs)})]}),i.jsx("code",{className:"vf-argv",children:t.argv.join(" ")}),t.error&&i.jsx("p",{className:"vf-note",children:t.error}),i.jsx("pre",{className:"vf-tail",children:r??(t.tail||"No output.")}),i.jsxs("div",{className:"vf-log-line",children:[r===void 0&&i.jsx("button",{className:"link",onClick:()=>Oi.log(t.log).then(m=>a(m.clipped?`[earlier output not shown]
144
+ ${m.text}`:m.text),m=>u(m.message)),children:"Full log ›"}),t.truncated&&i.jsx("span",{className:"dim",children:"log capped at 1 MB"}),l&&i.jsx("span",{className:"vf-err",children:l})]})]})}function t1(t){return t.error?"did not start":t.timedOut?"timed out":`exit ${t.exitCode??t.signal??"?"}`}const Zf=t=>(t==null?void 0:t.slice(0,8))??"none",eh=t=>t===null?"·":String(t);function n1({attempt:t}){const s=t.git;if(!s)return null;const{files:r,add:a,del:l}=s.stats;return i.jsxs("div",{className:"vf-git",children:[i.jsx(ge,{parts:[s.tree?{text:`${s.base?`${Zf(s.base.head)} → `:""}${Zf(s.tree.head)}`,code:!0}:"not a git repo",s.tree&&{text:s.tree.branch??"detached HEAD",code:!!s.tree.branch},s.tree&&`${r} file${r===1?"":"s"} +${a} −${l}`]}),s.flags.filter(u=>u.kind!=="no-git").map(u=>{var f;return i.jsxs("p",{className:`vf-flag lv-${u.level}`,title:(f=u.files)==null?void 0:f.join(`
145
+ `),children:[i.jsx("span",{className:"t-code",children:u.kind})," ",u.message]},u.kind)}),s.changed.length>0&&i.jsxs("details",{className:"vf-files",children:[i.jsx("summary",{className:"t-label",children:"Changed files"}),i.jsx("ul",{children:s.changed.map(u=>i.jsxs("li",{children:[i.jsx("code",{children:u.path}),i.jsxs("span",{className:"dim",children:[u.untracked?"new":`+${eh(u.add)} −${eh(u.del)}`,u.dirtyAtClaim?" · dirty at claim":""]})]},u.path))})]})]})}function s1({attempt:t,latest:s}){return i.jsxs("details",{className:`vf-attempt r-${t.result}`,open:s,children:[i.jsxs("summary",{children:[i.jsx(An,{tone:"state",className:`r-${t.result}`,children:jw[t.result]}),i.jsx(ge,{parts:[{text:t.id,code:!0},t.agent,yo(t.submittedAt),Pt(t.finishedAt-t.submittedAt)]})]}),i.jsx("p",{className:"vf-claim",children:t.summary??t.resolution}),t.note&&i.jsx("p",{className:"vf-note",children:t.note}),t.criteria&&i.jsx("ul",{className:"vf-criteria",children:t.criteria.lines.map(r=>i.jsx("li",{className:i1(r),children:r},r))}),i.jsx(n1,{attempt:t}),t.checks.map(r=>i.jsx(e1,{check:r},r.name))]})}function i1(t){return t.includes(" ✓ ")?"ok":t.includes(" ✗ ")?"bad":"wait"}const r1={PASS:"Passed",FAIL:"Sent back",NEEDS_HUMAN:"Needs you"};function o1({verdict:t}){return i.jsxs("div",{className:`vf-verdict v-${t.verdict.toLowerCase()}`,children:[i.jsx(ge,{parts:[{text:t.byKind==="trail lead"&&t.verdict==="PASS"?"Approved":r1[t.verdict],strong:!0},{text:t.id,code:!0},t.byKind==="trail lead"?t.by:`review ${t.by}`,t.sessionId&&`session ${t.sessionId.slice(0,8)}`,`on ${t.attemptId}`,yo(t.at)]}),i.jsx("p",{children:t.summary}),t.findings.length>0&&i.jsx("ul",{className:"vf-findings",children:t.findings.map((s,r)=>i.jsxs("li",{className:`sev-${s.severity}`,children:[s.path&&i.jsx("code",{children:s.line?`${s.path}:${s.line}`:s.path})," ",s.text]},r))})]})}function a1(t,s,r){const[a,l]=x.useState(),u=x.useCallback(()=>{Oi.ticket(t,s).then(l)},[t,s]);return x.useEffect(()=>(l(void 0),u(),Ms.onEvidence(u)),[u]),x.useEffect(u,[u,r]),{data:a,reload:u}}const Sl={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 l1(t){const[s,r]=x.useState(),[a,l]=x.useState(""),[u,f]=x.useState("rework"),{state:m,submitted:g,running:p,act:k}=t;if(p||m!=="verifying"&&m!=="held")return null;const v=N=>{r(s===N?void 0:N),l("")},w=N=>{N.preventDefault(),!(!s||!a.trim())&&(k({action:s,reason:a.trim(),...s==="unblock"?{to:u}:{}}),r(void 0))};return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"actions vf-actions",children:[m==="verifying"&&g&&i.jsx(G,{variant:"primary",onClick:()=>void k({action:"approve"}),"data-tip":"Checks passed: approve and close the ticket",children:"Approve"}),g&&i.jsx(G,{onClick:()=>void k({action:"rerun"}),"data-tip":"Run the repo's checks again on the current code",children:"Re-run checks"}),i.jsx(G,{on:s==="rework",onClick:()=>v("rework"),"data-tip":"Send it back to an agent with what to fix",children:"Rework…"}),m==="held"&&i.jsxs(i.Fragment,{children:[i.jsx(G,{on:s==="accept",onClick:()=>v("accept"),"data-tip":"Close it as done despite the failing checks",children:"Accept anyway…"}),i.jsx(G,{on:s==="unblock",onClick:()=>v("unblock"),"data-tip":"Put it back in the queue without running checks",children:"Unblock…"})]})]}),s&&i.jsxs(Et,{as:"form",tone:"inset",className:"inline-form",onSubmit:w,children:[i.jsx(He,{label:Sl[s].label,children:i.jsx("textarea",{rows:2,value:a,onChange:N=>l(N.target.value),autoFocus:!0})}),s==="unblock"&&i.jsx(He,{label:"Back to",children:i.jsx(wt,{"aria-label":"Back to",value:u,onChange:f,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:Sl[s].hint}),i.jsxs("div",{className:"form-actions",children:[i.jsx(G,{variant:"ghost",onClick:()=>r(void 0),children:"Cancel"}),i.jsx(G,{type:"submit",variant:s==="accept"?"danger":"primary",disabled:!a.trim(),children:Sl[s].submit})]})]})]})}const c1={ticket:"set on this ticket",trail:"from the trail",none:"not set"},u1=new Set(["verifying","rework","held"]);function d1(t){const{mapId:s,ticket:r,state:a}=t,{data:l,reload:u}=a1(s,r.id,r.updatedAt),[f,m]=x.useState();if(!l||l.level.level==="off"&&!l.attempts.length&&!u1.has(a))return null;const g=k=>(m(void 0),Oi.act({...k,mapId:s,ticketId:r.id,by:gt}).then(u,v=>m(v.message))),p=l.running;return i.jsxs("section",{className:"vf-panel",children:[i.jsxs("div",{className:"vf-head",children:[i.jsx(Xe,{as:"h4",children:"Verification"}),i.jsx(ge,{parts:[Mi[l.level.level],c1[l.level.source]]}),r.state==="open"&&i.jsx(Xj,{value:r.verification,inherit:`Trail (${Mi[t.trail??"off"]})`,onChange:k=>void g({action:"level",level:k})})]}),p&&i.jsxs("div",{className:"sync-line vf-running",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:["Checking ",p.id," for ",p.agent," · since ",yo(p.startedAt)]})]}),i.jsx(l1,{state:a,submitted:l.attempts.length>0,running:!!p,act:g}),f&&i.jsx("p",{className:"vf-err",children:f}),l.verdicts.map(k=>i.jsx(o1,{verdict:k},k.id)),l.attempts.map((k,v)=>i.jsx(s1,{attempt:k,latest:v===0},k.id)),!l.attempts.length&&!p&&i.jsx(ge,{parts:[`Checks: ${l.level.checks.join(", ")||"none"}`,"run when the ticket is submitted"]})]})}function f1({lease:t,onRelease:s}){const r=In(1e3),a=go(t,r),l=a==="live";return i.jsxs("div",{className:`lease lease-${a} edge-note ${l?"":"edge-attention"}`,children:[i.jsxs("div",{className:"edge-note-head",children:[i.jsx(ge,{parts:[{text:`Claimed by ${t.agent}`,strong:!0},`active ${Yn(r-t.renewedAt)} ago`]}),!l&&i.jsx(An,{tone:"amber",children:"Stalled"})]}),i.jsx("p",{className:"t-meta lease-line",children:h1(a,m1(t.expiresAt-r))}),t.workspace&&i.jsxs("p",{className:"t-meta lease-branch",children:["Works on ",i.jsx("code",{className:"t-code",children:t.workspace.branch})," in its own worktree"]}),t.touches&&t.touches.length>0&&i.jsxs("p",{className:"t-meta lease-touches",children:["Expects to change"," ",t.touches.map((u,f)=>i.jsxs("span",{children:[f>0&&", ",i.jsx("code",{className:"t-code",children:u})]},u))]}),t.notes.length>0&&i.jsx("ul",{className:"lease-notes t-meta",children:t.notes.slice(-3).map((u,f)=>i.jsx("li",{children:u},f))}),i.jsx("div",{className:"actions",children:i.jsx(G,{variant:l?"default":"urgent",onClick:s,children:"Release to queue"})})]})}function h1(t,s){return t==="expired"?"Lease expired, going back to the queue":t==="stalled"?`The agent went quiet. Back in the queue in ${s}.`:`Back in the queue after ${s} without activity.`}function m1(t){const s=t/864e5;return s>=2?`${Math.round(s)} days`:Pt(Math.max(0,t))}function p1({comments:t}){if(!t.length)return null;const s=t.length>1?"s":"";return i.jsxs("details",{className:"comments",children:[i.jsxs("summary",{className:"t-label",children:[t.length," other comment",s]}),t.map(r=>i.jsxs("div",{className:"comment",children:[i.jsx(ge,{parts:[{text:r.author,strong:!0}]}),i.jsx("div",{className:"c-body",children:r.body.replace(/\*\*/g,"")})]},r.id))]})}function g1({resolution:t,decisions:s,onOpenDecision:r}){const a=s.find(f=>!f.supersededBy)??s[0],l=t.body.startsWith("**Ruled")?"ruled out":"resolution",u=s.length>1?` · ${s.length} in chain`:"";return i.jsxs("div",{className:"resolution edge-note edge-done",children:[i.jsxs("div",{className:"edge-note-head",children:[i.jsx(ge,{parts:[{text:t.author,strong:!0},l]}),a&&r&&i.jsxs("button",{className:"link t-meta",onClick:()=>r(a.id),children:[a.id,u," ›"]})]}),i.jsx("p",{children:t.body.replace(/^\*\*[^*]+\*\*\s*/,"")})]})}function v1(t){const{t:s,state:r,session:a,mine:l,form:u,setForm:f,actions:m,onOpenChat:g}=t;return i.jsxs("div",{className:"actions",children:[a&&i.jsx(G,{variant:a.waitingOn?"urgent":"default",onClick:()=>g(a.id),"data-tip":a.waitingOn?"The agent is waiting for your answer":"Open the conversation with this agent",children:a.waitingOn?"Answer":"Conversation"}),r==="frontier"&&i.jsx(G,{onClick:()=>m.claim(s.id),"data-tip":"Take this ticket yourself, so no agent picks it up",children:"Claim"}),(r==="frontier"||r==="claimed"&&l)&&i.jsx(G,{on:u==="resolve",onClick:()=>f(u==="resolve"?null:"resolve"),"data-tip":"Answer it yourself and close the ticket, with a decision record",children:"Resolve…"}),l&&r==="claimed"&&i.jsx(G,{onClick:()=>m.release(s.id),"data-tip":"Give the ticket back to the queue",children:"Release"}),(r==="frontier"||r==="blocked"||r==="parked")&&i.jsx(G,{variant:"danger",on:u==="rule",onClick:()=>f(u==="rule"?null:"rule"),"data-tip":"Move it out of scope. It's set aside with your reason, not deleted",children:"Rule out…"})]})}function y1({t,state:s,tickets:r}){const a=new Map(r.map(p=>[p.id,p])),l=p=>{var k;return((k=a.get(p))==null?void 0:k.key)??p},u=t.blockedBy.map(p=>{var k;return`${l(p)}${((k=a.get(p))==null?void 0:k.state)==="closed"?" ✓":""}`}).join(", "),f=r.filter(p=>p.blockedBy.includes(t.id)).map(p=>p.key).join(", "),m=[["Type",Mh[t.type]],["Assignee",t.assignee],["Blocked by",u],["Blocks",f],["Reviews",t.reviewOf&&l(t.reviewOf)]],g=Ii(t)==="hitl";return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"d-head",children:[i.jsx("span",{className:"key t-code",children:t.key}),i.jsx(An,{tone:"state",className:`st-${s}`,children:Ih[s]}),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:t.title}),i.jsx("dl",{className:"facts",children:m.filter(([,p])=>p).flatMap(([p,k])=>[i.jsx("dt",{className:"t-label",children:p},`${p}-k`),i.jsx("dd",{children:k},`${p}-v`)])})]})}function k1(t){const{snap:s,api:r,form:a,setForm:l}=t,{actions:u}=r,[f,m]=x.useState(""),[g,p]=x.useState(""),[k,v]=x.useState(""),[w,N]=x.useState("Not needed to reach the destination."),M=s.tickets.find(V=>V.id===t.id);if(!M)return i.jsx(_e,{children:"Ticket not found."});const S=Is(s.tickets,s.map.mode).get(M.id),E=t.sessions.find(V=>V.ticketId===M.id&&Qt(V)),I=M.assignee===gt,_=M.state==="open"?ql(r.leases,s.map.id).get(M.id):void 0,O=[...M.comments].reverse().find(V=>/^\*\*(Resolution|Ruled out of scope)\*\*/.test(V.body)),ee=M.comments.filter(V=>V!==O),q=r.decisions.filter(V=>V.mapId===s.map.id&&V.ticketId===M.id);return i.jsxs("div",{className:"detail",children:[i.jsx(y1,{t:M,state:S,tickets:s.tickets}),i.jsx(Vk,{mapId:s.map.id,ticketId:M.id}),i.jsx(Jj,{snap:s,t:M}),i.jsx(rx,{snap:s,t:M}),M.closeReason==="not_planned"&&i.jsx(ec,{label:"Save as dead end",draft:()=>{var V;return{title:`Ruled out: ${M.title}`,body:((V=M.comments.at(-1))==null?void 0:V.body)??M.body,kind:"dead-end",sources:[`trail:${s.map.key}`,`ticket:${M.key}`]}}}),_&&i.jsx(f1,{lease:_,onRelease:()=>u.releaseLease(M.id)}),!_&&i.jsx(g0,{mapId:s.map.id,ticketId:M.id}),i.jsx(d1,{mapId:s.map.id,trail:s.map.verification,ticket:M,state:S}),i.jsx(v1,{t:M,state:S,session:E,mine:I,form:a,setForm:l,actions:u,onOpenChat:t.onOpenChat}),a==="resolve"&&i.jsxs(Et,{as:"form",tone:"inset",className:"inline-form",onSubmit:V=>{V.preventDefault(),f.trim()&&(u.resolve(M.id,f.trim(),{rationale:g.trim(),alternatives:k.split(`
146
+ `).map(ie=>ie.trim()).filter(Boolean)}),l(null),m(""),p(""),v(""))},children:[i.jsx(He,{label:"Resolution",children:i.jsx("textarea",{rows:3,value:f,onChange:V=>m(V.target.value),autoFocus:!0})}),i.jsx(He,{label:"Rationale",children:i.jsx("input",{value:g,onChange:V=>p(V.target.value)})}),i.jsx(He,{label:"Alternatives considered",children:i.jsx("textarea",{rows:2,value:k,onChange:V=>v(V.target.value),placeholder:"One per line"})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(G,{variant:"ghost",onClick:()=>l(null),children:"Cancel"}),i.jsx(G,{type:"submit",variant:"primary",disabled:!f.trim(),children:"Resolve"})]})]}),a==="rule"&&i.jsxs(Et,{as:"form",tone:"inset",className:"inline-form",onSubmit:V=>{V.preventDefault(),u.ruleOut({ticketId:M.id},w),l(null)},children:[i.jsx(He,{label:"Reason",children:i.jsx("input",{value:w,onChange:V=>N(V.target.value),autoFocus:!0})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(G,{variant:"ghost",onClick:()=>l(null),children:"Cancel"}),i.jsx(G,{type:"submit",variant:"danger",children:"Rule out"})]})]}),O&&i.jsx(g1,{resolution:O,decisions:q,onOpenDecision:t.onOpenDecision}),i.jsx("p",{className:"body",children:M.body}),i.jsx(p1,{comments:ee})]})}function x1({snap:t,item:s,api:r}){const a=rh(t.map.mode),[l,u]=x.useState("research"),[f,m]=x.useState(s),[g,p]=x.useState(!1),[k,v]=x.useState([]),[w,N]=x.useState("Not needed to reach the destination.");x.useEffect(()=>m(s),[s]);const M=t.tickets.filter(S=>S.state==="open");return i.jsxs("div",{className:"detail",children:[i.jsx("div",{className:"d-head",children:i.jsx(An,{tone:"state",className:"st-unspecified",children:"Not yet specified"})}),i.jsx("h3",{className:"t-heading",children:s}),i.jsxs(Et,{as:"form",tone:"inset",className:"inline-form",onSubmit:S=>{S.preventDefault(),r.actions.graduate({unspecified:s,type:l,title:f,blockedBy:k,hitl:g})},children:[i.jsx(He,{label:"Title",children:i.jsx("input",{value:f,onChange:S=>m(S.target.value)})}),i.jsxs("div",{className:"chips",children:[a.map(S=>i.jsx("button",{type:"button",className:`chip ${l===S?"on":""}`,onClick:()=>u(S),children:S},S)),vg.includes(l)&&i.jsx("button",{type:"button",className:`chip ${g?"on":""}`,onClick:()=>p(S=>!S),children:"needs human"})]}),i.jsx("span",{className:"field",children:"Blocked by"}),i.jsx("div",{className:"chips",children:M.map(S=>i.jsx("button",{type:"button",className:`chip ${k.includes(S.id)?"on":""}`,onClick:()=>v(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(G,{type:"submit",variant:"primary",children:"Promote to ticket"})})]}),i.jsxs(Et,{as:"form",tone:"inset",className:"inline-form",onSubmit:S=>{S.preventDefault(),r.actions.ruleOut({unspecified:s},w)},children:[i.jsx(He,{label:"Reason",children:i.jsx("input",{value:w,onChange:S=>N(S.target.value)})}),i.jsx("div",{className:"form-actions",children:i.jsx(G,{type:"submit",variant:"danger",children:"Rule out"})})]})]})}function w1({api:t,sessions:s,bare:r,onOpenChat:a,onOpenDecision:l}){const{snap:u,selection:f,actions:m}=t,[g,p]=x.useState(null),k=j1(f);x.useEffect(()=>p(null),[k]);let v;return u?f?f.kind==="unspecified"?v=i.jsx(x1,{snap:u,item:f.item,api:t}):v=i.jsx(k1,{snap:u,id:f.id,api:t,sessions:s,form:g,setForm:p,onOpenChat:a??m.openChat,onOpenDecision:l}):v=i.jsx(qn,{title:"No ticket selected",hint:"Pick a ticket on the map: what it is, who has it, what blocks it, and its decision."}):v=i.jsx(qn,{title:"No trail yet",hint:"Once there's a trail, pick a ticket on the map to see it here."}),i.jsx(Bh,{area:"inspector",icon:"note",title:"Trail step",info:"The ticket you selected on the map: what it is, who has it, what blocks it, and its decision once it's made.",className:"inspector",bare:r,children:v})}function j1(t){return(t==null?void 0:t.kind)==="ticket"?t.id:(t==null?void 0:t.kind)==="unspecified"?t.item:""}const S1={holding:"Holding",challenged:"Challenged",invalidated:"Invalidated",confirmed:"Confirmed"};function N1(t){if(t.decidedBy)return t.status==="invalidated"?`invalidated by ${t.decidedBy}`:t.status==="confirmed"?`confirmed by ${t.decidedBy==="trail lead"?"you":t.decidedBy}`:`kept by ${t.decidedBy}`}function C1(t){const{a:s,snap:r}=t,a=s.tickets.flatMap(u=>r.tickets.filter(f=>f.id===u)),l=s.challenge&&`${s.challenge.by}: ${s.challenge.evidence}`;return i.jsx(ct,{as:"li",className:`assumption st-${s.status}`,edge:s.status==="challenged"?"attention":"neutral",title:s.text,titleText:s.text,context:i.jsx(ge,{parts:[{text:s.id,code:!0},S1[s.status],N1(s)],children:a.length>0&&i.jsxs("span",{className:"assumption-tickets",children:[i.jsx("span",{className:"sep",children:" · "}),"relied on by",a.map(u=>i.jsx("button",{className:"link t-code",onClick:()=>t.onSelect({kind:"ticket",id:u.id}),children:u.key},u.id))]})}),detail:l,detailText:l,trailing:t.onConfirm&&i.jsx(G,{size:"sm",variant:"ghost",disabled:t.busy,onClick:t.onConfirm,children:"Confirm"})})}function $1(t){const[s,r]=x.useState(),[a,l]=x.useState();return{confirm:async f=>{l(f);const m=await fetch(`${ne.apiPrefix}/assumptions/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,id:f})}).catch(()=>{});if(l(void 0),m!=null&&m.ok)return r(void 0);const g=await(m==null?void 0:m.json().catch(()=>({})));r((g==null?void 0:g.error)??"Could not confirm it; is the Lookout connected?")},busy:a,error:s}}function b1({snap:t,onSelect:s}){const{confirm:r,busy:a,error:l}=$1(t.map.id),u=t.map.sections.assumptions??[];return u.length?i.jsxs(i.Fragment,{children:[l&&i.jsx("p",{className:"urgent-text",children:l}),i.jsx("ul",{className:"assumptions row-list",children:u.map(f=>{const m=f.status==="holding"||f.status==="challenged";return i.jsx(C1,{a:f,snap:t,onSelect:s,onConfirm:m?()=>void r(f.id):void 0,busy:a===f.id},f.id)})})]}):i.jsx(_e,{children:"None yet. They come from the accepted discovery brief or the trail's start."})}function T1(t){const[s,r]=x.useState([]),a=t==null?void 0:t.map.id,l=(t==null?void 0:t.tickets.reduce((u,f)=>Math.max(u,f.updatedAt),t.map.updatedAt))??0;return x.useEffect(()=>{if(!a)return;let u=!0;return fetch(`${ne.apiPrefix}/journal?mapId=${encodeURIComponent(a)}`).then(f=>f.ok?f.json():{entries:[]}).then(f=>u&&r(f.entries)).catch(()=>u&&r([])),()=>{u=!1}},[a,l]),s}function E1({snap:t,activity:s,onTicket:r}){const a=T1(t),l=s.usageByMap[t.map.id],u=x.useMemo(()=>ph({snap:t,journal:a,answered:s.answered,usage:l}),[t,a,s.answered,l]),f=u.interventions,m=[["Done",`${u.done}`,`${u.done} done · ${u.cancelled} cancelled · ${u.open} open`],["Lead time",rn(u.trailLeadMs),"Trail lead time: from when the trail was charted to its last done ticket"],["Median ticket",rn(u.medianLeadMs),"Median time from a ticket's first claim to done"],["Interventions",`${f.total}`,`${f.answers} agent questions you answered + ${f.operatorActions} lifecycle calls you made (approve, send back, accept, unblock, cancel, release), of which ${f.reworkRequested} sent work back. Answers count while their sessions are on record.`],["Rework",`${u.rework.cycles}`,`Times work went back to rework, on ${u.rework.tickets} tickets`],["Reviews",`${u.reviews.passed}/${u.reviews.failed}`,`${u.reviews.passed} passed, ${u.reviews.failed} failed, ${u.reviews.needsHuman} needed you`],["Cost / ticket",u.spend.perVerifiedTicketUsd===void 0?"—":Ts(u.spend.perVerifiedTicketUsd),`Cost per verified ticket: trail spend ${Ts(u.spend.costUsd)} ÷ ${u.done} done tickets`]];return i.jsxs("div",{className:"report",children:[i.jsx("ul",{className:"report-stats",children:m.map(([g,p,k])=>i.jsxs("li",{"data-tip":k,children:[i.jsx("span",{className:"mono-label",children:g}),i.jsx("b",{children:p})]},g))}),i.jsxs("div",{className:"report-bar",children:[i.jsx("span",{className:"mono-label",children:"Tickets"}),i.jsx(G,{size:"sm",variant:"ghost","data-tip":"Download this report as markdown",onClick:()=>bh(`${t.map.key.replace("#","trail-")}-report.md`,Pv(u,t.map.title)),children:"Export markdown"})]}),u.tickets.length?i.jsx("ul",{className:"list report-tickets",children:u.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"?rn(g.leadMs):g.outcome})]})},g.id))}):i.jsx(_e,{children:"No tickets yet"})]})}function M1({tab:t,snap:s,selection:r,onSelect:a,activity:l}){const u=s.map.sections;switch(t){case"report":return l?i.jsx(E1,{snap:s,activity:l,onTicket:f=>a({kind:"ticket",id:f})}):i.jsx(_e,{children:"No activity yet"});case"assumptions":return i.jsx(b1,{snap:s,onSelect:a});case"decisions":return u.decisions.length?i.jsx("ol",{className:"row-list decisions",children:[...u.decisions].reverse().map((f,m)=>i.jsx(ct,{as:"li",title:f.text,titleText:f.text,context:f.ticketKey&&i.jsx(ge,{parts:[{text:f.ticketKey,code:!0}]}),onOpen:f.ticketId?()=>a({kind:"ticket",id:f.ticketId}):void 0},`${f.ticketKey}-${m}`))}):i.jsx(_e,{children:"None"});case"unspecified":return u.unspecified.length?i.jsx("ul",{className:"row-list unspecified",children:u.unspecified.map(f=>i.jsx(ct,{as:"li",title:f,titleText:f,selected:(r==null?void 0:r.kind)==="unspecified"&&r.item===f,onOpen:()=>a({kind:"unspecified",item:f})},f))}):i.jsx(_e,{children:"None"});case"oos":return u.outOfScope.length?i.jsx("ul",{className:"row-list oos",children:u.outOfScope.map(f=>i.jsx(ct,{as:"li",title:f,titleText:f},f))}):i.jsx(_e,{children:"None"});case"notes":return i.jsx("p",{className:"notes t-body",children:u.notes||"No notes yet."});default:return t}}function I1({snap:t,selection:s,onSelect:r,bare:a,onAudit:l,activity:u}){var v;const[f,m]=x.useState("unspecified"),g=t==null?void 0:t.map.sections,p=[{id:"unspecified",label:"Not yet specified",n:g==null?void 0:g.unspecified.length},{id:"assumptions",label:"Assumptions",n:(v=g==null?void 0:g.assumptions)==null?void 0:v.length},{id:"decisions",label:"Decisions",n:g==null?void 0:g.decisions.length},{id:"oos",label:"Out of scope",n:g==null?void 0:g.outOfScope.length},{id:"notes",label:"Notes"},{id:"report",label:"Report"}],k=t?i.jsx(M1,{tab:f,snap:t,selection:s,onSelect:r,activity:u}):i.jsx(qn,{title:"No plan yet",hint:"Open questions, decisions, what's ruled out, notes and the trail report collect here."});return i.jsxs(Ve,{className:`zone sections ${a?"bare":""}`,style:a?void 0:{gridArea:"plan"},children:[!a&&i.jsx(on,{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(Zl,{className:"sub",value:f,onChange:m,items:p}),f==="decisions"&&l&&i.jsx("button",{className:"link",onClick:l,children:"Audit ›"})]}),i.jsx("div",{className:"zone-b",children:k})]})}function A1(){var $e;const t=x.useMemo(()=>wk(xk()),[]),s=Tk(t),{snap:r,activity:a,selection:l,actions:u}=s,[f,m]=Ek();x.useEffect(()=>Ah(f.theme),[f.theme]);const[g,p]=x.useState(k0),[k,v]=x.useState(!1),w=rj(t.kind),N=Nk(),M=a.pending.length,S=oj(a,s.mapId);ij(M,r==null?void 0:r.map.title);const E=sj(s,N),I=$j(r,u.selectMap),_=ux(I.briefText),O=bj({api:s,nav:E,knowledge:_,reviewBrief:I.review,openReroute:L=>I.openReroute(L.mapId,L.ref)}),ee=$k(t,s,f.briefing,($e=O.attention.view)==null?void 0:$e.items),q=i.jsx(Mw,{api:s,nav:E,bp:N,scoped:S,attn:O,above:I.inboxCard}),V=i.jsx(Z0,{api:s,sessions:S.sessions,onSelect:E.select,onNewTrail:()=>v(!0),compact:N==="mobile",minFit:N==="mobile"?.7:0,trail:I}),ie=L=>i.jsx(w1,{api:s,sessions:S.sessions,bare:L,onOpenChat:Q=>E.openChat(Q),onOpenDecision:E.openDecisions}),ae={activity:S,snap:r,leases:s.leases,onTicket:L=>E.select({kind:"ticket",id:L}),onOpenChat:L=>E.openChat(L)},K=L=>i.jsx(I1,{snap:r,selection:l,onSelect:E.select,bare:L,onAudit:()=>E.openDecisions(),activity:S}),xe=(E.statsOpen||E.decisionsView)&&i.jsx(Bj,{api:s,bp:N,nav:E}),ze=ee.shown&&i.jsx(Wk,{brief:ee,snaps:s.allSnaps,bp:N,openTicket:E.openTicket,openChat:E.openChat,openDecisions:E.openDecisions,closeDecisions:()=>E.setDecisionsView(null),showPhoneHome:()=>E.setPhoneTab("home")});return i.jsx(Fh.Provider,{value:_,children:i.jsxs("div",{className:`app bp-${N}`,children:[i.jsx(Dx,{api:s,rt:t,repo:w,brief:ee,attention:O.header,decisionsOpen:!!E.decisionsView,onDecisions:()=>E.decisionsView?E.setDecisionsView(null):E.openDecisions(),onStats:E.toggleStats,onNewTrail:()=>v(!0),onSettings:p,onToggleTheme:L=>m({theme:L?"night":"day"})}),N==="wide"&&i.jsxs(i.Fragment,{children:[q,V,ie(!1),i.jsx(Gj,{...ae}),i.jsx(qj,{...ae}),K(!1),xe]}),N==="laptop"&&i.jsxs(i.Fragment,{children:[q,V,i.jsx(j0,{tab:E.sideTab,onTab:E.setSideTab,unspecified:r==null?void 0:r.map.sections.unspecified.length,ticket:ie(!0),activity:i.jsx(Jf,{...ae}),plan:K(!0)}),xe]}),N==="mobile"&&i.jsxs(i.Fragment,{children:[i.jsx(nj,{tab:E.phoneTab,decisions:xe,inbox:q,map:V,ticket:ie(!0),activity:i.jsx(Jf,{...ae}),plan:K(!0)}),i.jsx(tj,{tab:E.phoneTab,covered:!!xe,pending:M,onPick:L=>{E.setPhoneTab(L),E.setDecisionsView(null)}})]}),ze,I.dialog,s.error&&i.jsx("div",{className:"error-toast",children:s.error}),g&&i.jsx(w0,{rt:t,api:s,prefs:f,update:m,focus:g,onClose:()=>p(!1)}),k&&i.jsx(Pw,{rt:t,onClose:()=>v(!1),onCreated:L=>u.selectMap(L)}),!f.onboarded&&i.jsx(Vw,{prefs:f,update:m,activeTracker:t.kind}),i.jsx(cx,{})]})})}Ah(Yl().theme);mg.createRoot(document.getElementById("root")).render(i.jsxs(i.Fragment,{children:[i.jsx(A1,{}),i.jsx(Dk,{})]}));