teamtrail 0.0.2 → 0.7.0-next.14

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 Kp=Object.defineProperty;var Vp=(t,s,r)=>s in t?Kp(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r;var oe=(t,s,r)=>Vp(t,typeof s!="symbol"?s+"":s,r);(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))a(c);new MutationObserver(c=>{for(const u of c)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(c){const u={};return c.integrity&&(u.integrity=c.integrity),c.referrerPolicy&&(u.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?u.credentials="include":c.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function a(c){if(c.ep)return;c.ep=!0;const u=r(c);fetch(c.href,u)}})();var cl={exports:{}},xi={},ul={exports:{}},ke={};/**
2
+ * @license React
3
+ * react.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var Hd;function Qp(){if(Hd)return ke;Hd=1;var t=Symbol.for("react.element"),s=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),c=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"),y=Symbol.for("react.lazy"),v=Symbol.iterator;function j(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 O(b,P,fe){this.props=b,this.context=P,this.refs=S,this.updater=fe||N}var L=O.prototype=new I;L.constructor=O,M(L,E.prototype),L.isPureReactComponent=!0;var J=Array.isArray,Z=Object.prototype.hasOwnProperty,K={current:null},le={key:!0,ref:!0,__self:!0,__source:!0};function de(b,P,fe){var pe,ae={},ye=null,he=null;if(P!=null)for(pe in P.ref!==void 0&&(he=P.ref),P.key!==void 0&&(ye=""+P.key),P)Z.call(P,pe)&&!le.hasOwnProperty(pe)&&(ae[pe]=P[pe]);var ve=arguments.length-2;if(ve===1)ae.children=fe;else if(1<ve){for(var be=Array(ve),it=0;it<ve;it++)be[it]=arguments[it+2];ae.children=be}if(b&&b.defaultProps)for(pe in ve=b.defaultProps,ve)ae[pe]===void 0&&(ae[pe]=ve[pe]);return{$$typeof:t,type:b,key:ye,ref:he,props:ae,_owner:K.current}}function Q(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 De(b){var P={"=":"=0",":":"=2"};return"$"+b.replace(/[=:]/g,function(fe){return P[fe]})}var $e=/\/+/g;function R(b,P){return typeof b=="object"&&b!==null&&b.key!=null?De(""+b.key):P.toString(36)}function V(b,P,fe,pe,ae){var ye=typeof b;(ye==="undefined"||ye==="boolean")&&(b=null);var he=!1;if(b===null)he=!0;else switch(ye){case"string":case"number":he=!0;break;case"object":switch(b.$$typeof){case t:case s:he=!0}}if(he)return he=b,ae=ae(he),b=pe===""?"."+R(he,0):pe,J(ae)?(fe="",b!=null&&(fe=b.replace($e,"$&/")+"/"),V(ae,P,fe,"",function(it){return it})):ae!=null&&(xe(ae)&&(ae=Q(ae,fe+(!ae.key||he&&he.key===ae.key?"":(""+ae.key).replace($e,"$&/")+"/")+b)),P.push(ae)),1;if(he=0,pe=pe===""?".":pe+":",J(b))for(var ve=0;ve<b.length;ve++){ye=b[ve];var be=pe+R(ye,ve);he+=V(ye,P,fe,be,ae)}else if(be=j(b),typeof be=="function")for(b=be.call(b),ve=0;!(ye=b.next()).done;)ye=ye.value,be=pe+R(ye,ve++),he+=V(ye,P,fe,be,ae);else if(ye==="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=[],ae=0;return V(b,pe,"","",function(ye){return P.call(fe,ye,ae++)}),pe}function ce(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:K};function W(){throw Error("act(...) is not supported in production builds of React.")}return ke.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}},ke.Component=E,ke.Fragment=r,ke.Profiler=c,ke.PureComponent=O,ke.StrictMode=a,ke.Suspense=g,ke.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=F,ke.act=W,ke.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),ae=b.key,ye=b.ref,he=b._owner;if(P!=null){if(P.ref!==void 0&&(ye=P.ref,he=K.current),P.key!==void 0&&(ae=""+P.key),b.type&&b.type.defaultProps)var ve=b.type.defaultProps;for(be in P)Z.call(P,be)&&!le.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 it=0;it<be;it++)ve[it]=arguments[it+2];pe.children=ve}return{$$typeof:t,type:b.type,key:ae,ref:ye,props:pe,_owner:he}},ke.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},ke.createElement=de,ke.createFactory=function(b){var P=de.bind(null,b);return P.type=b,P},ke.createRef=function(){return{current:null}},ke.forwardRef=function(b){return{$$typeof:m,render:b}},ke.isValidElement=xe,ke.lazy=function(b){return{$$typeof:y,_payload:{_status:-1,_result:b},_init:ce}},ke.memo=function(b,P){return{$$typeof:p,type:b,compare:P===void 0?null:P}},ke.startTransition=function(b){var P=B.transition;B.transition={};try{b()}finally{B.transition=P}},ke.unstable_act=W,ke.useCallback=function(b,P){return me.current.useCallback(b,P)},ke.useContext=function(b){return me.current.useContext(b)},ke.useDebugValue=function(){},ke.useDeferredValue=function(b){return me.current.useDeferredValue(b)},ke.useEffect=function(b,P){return me.current.useEffect(b,P)},ke.useId=function(){return me.current.useId()},ke.useImperativeHandle=function(b,P,fe){return me.current.useImperativeHandle(b,P,fe)},ke.useInsertionEffect=function(b,P){return me.current.useInsertionEffect(b,P)},ke.useLayoutEffect=function(b,P){return me.current.useLayoutEffect(b,P)},ke.useMemo=function(b,P){return me.current.useMemo(b,P)},ke.useReducer=function(b,P,fe){return me.current.useReducer(b,P,fe)},ke.useRef=function(b){return me.current.useRef(b)},ke.useState=function(b){return me.current.useState(b)},ke.useSyncExternalStore=function(b,P,fe){return me.current.useSyncExternalStore(b,P,fe)},ke.useTransition=function(){return me.current.useTransition()},ke.version="18.3.1",ke}var Kd;function Ml(){return Kd||(Kd=1,ul.exports=Qp()),ul.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 Vd;function qp(){if(Vd)return xi;Vd=1;var t=Ml(),s=Symbol.for("react.element"),r=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,c=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 y,v={},j=null,N=null;p!==void 0&&(j=""+p),g.key!==void 0&&(j=""+g.key),g.ref!==void 0&&(N=g.ref);for(y in g)a.call(g,y)&&!u.hasOwnProperty(y)&&(v[y]=g[y]);if(m&&m.defaultProps)for(y in g=m.defaultProps,g)v[y]===void 0&&(v[y]=g[y]);return{$$typeof:s,type:m,key:j,ref:N,props:v,_owner:c.current}}return xi.Fragment=r,xi.jsx=f,xi.jsxs=f,xi}var Qd;function Gp(){return Qd||(Qd=1,cl.exports=qp()),cl.exports}var i=Gp(),Kr={},dl={exports:{}},ht={},fl={exports:{}},hl={};/**
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 qd;function Yp(){return qd||(qd=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<c(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,ae=B[pe],ye=pe+1,he=B[ye];if(0>c(ae,W))ye<P&&0>c(he,ae)?(B[b]=he,B[ye]=W,b=ye):(B[b]=ae,B[pe]=W,b=pe);else if(ye<P&&0>c(he,W))B[b]=he,B[ye]=W,b=ye;else break e}}return F}function c(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=[],y=1,v=null,j=3,N=!1,M=!1,S=!1,E=typeof setTimeout=="function"?setTimeout:null,I=typeof clearTimeout=="function"?clearTimeout:null,O=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function L(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 J(B){if(S=!1,L(B),!M)if(r(g)!==null)M=!0,ce(Z);else{var F=r(p);F!==null&&me(J,F.startTime-B)}}function Z(B,F){M=!1,S&&(S=!1,I(de),de=-1),N=!0;var W=j;try{for(L(F),v=r(g);v!==null&&(!(v.expirationTime>F)||B&&!De());){var b=v.callback;if(typeof b=="function"){v.callback=null,j=v.priorityLevel;var P=b(v.expirationTime<=F);F=t.unstable_now(),typeof P=="function"?v.callback=P:v===r(g)&&a(g),L(F)}else a(g);v=r(g)}if(v!==null)var fe=!0;else{var pe=r(p);pe!==null&&me(J,pe.startTime-F),fe=!1}return fe}finally{v=null,j=W,N=!1}}var K=!1,le=null,de=-1,Q=5,xe=-1;function De(){return!(t.unstable_now()-xe<Q)}function $e(){if(le!==null){var B=t.unstable_now();xe=B;var F=!0;try{F=le(!0,B)}finally{F?R():(K=!1,le=null)}}else K=!1}var R;if(typeof O=="function")R=function(){O($e)};else if(typeof MessageChannel<"u"){var V=new MessageChannel,se=V.port2;V.port1.onmessage=$e,R=function(){se.postMessage(null)}}else R=function(){E($e,0)};function ce(B){le=B,K||(K=!0,R())}function me(B,F){de=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,ce(Z))},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"):Q=0<B?Math.floor(1e3/B):5},t.unstable_getCurrentPriorityLevel=function(){return j},t.unstable_getFirstCallbackNode=function(){return r(g)},t.unstable_next=function(B){switch(j){case 1:case 2:case 3:var F=3;break;default:F=j}var W=j;j=F;try{return B()}finally{j=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=j;j=B;try{return F()}finally{j=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:y++,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(de),de=-1):S=!0,me(J,W-b))):(B.sortIndex=P,s(g,B),M||N||(M=!0,ce(Z))),B},t.unstable_shouldYield=De,t.unstable_wrapCallback=function(B){var F=j;return function(){var W=j;j=F;try{return B.apply(this,arguments)}finally{j=W}}}})(hl)),hl}var Gd;function Jp(){return Gd||(Gd=1,fl.exports=Yp()),fl.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 Yd;function Xp(){if(Yd)return ht;Yd=1;var t=Ml(),s=Jp();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,c={};function u(e,n){f(e,n),f(e+"Capture",n)}function f(e,n){for(c[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]*$/,y={},v={};function j(e){return g.call(v,e)?!0:g.call(y,e)?!1:p.test(e)?v[e]=!0:(y[e]=!0,!1)}function N(e,n,o,l){if(o!==null&&o.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return l?!1:o!==null?!o.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function M(e,n,o,l){if(n===null||typeof n>"u"||N(e,n,o,l))return!0;if(l)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,l,d,h,k){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=l,this.attributeNamespace=d,this.mustUseProperty=o,this.propertyName=e,this.type=n,this.sanitizeURL=h,this.removeEmptyString=k}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 O(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,O);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,O);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,O);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 L(e,n,o,l){var d=E.hasOwnProperty(n)?E[n]:null;(d!==null?d.type!==0:l||!(2<n.length)||n[0]!=="o"&&n[0]!=="O"||n[1]!=="n"&&n[1]!=="N")&&(M(n,o,d,l)&&(o=null),l||d===null?j(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,l=d.attributeNamespace,o===null?e.removeAttribute(n):(d=d.type,o=d===3||d===4&&o===!0?"":""+o,l?e.setAttributeNS(l,n,o):e.setAttribute(n,o))))}var J=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Z=Symbol.for("react.element"),K=Symbol.for("react.portal"),le=Symbol.for("react.fragment"),de=Symbol.for("react.strict_mode"),Q=Symbol.for("react.profiler"),xe=Symbol.for("react.provider"),De=Symbol.for("react.context"),$e=Symbol.for("react.forward_ref"),R=Symbol.for("react.suspense"),V=Symbol.for("react.suspense_list"),se=Symbol.for("react.memo"),ce=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(_){var l=_}Reflect.construct(e,[],n)}else{try{n.call()}catch(_){l=_}e.call(n.prototype)}else{try{throw Error()}catch(_){l=_}e()}}catch(_){if(_&&l&&typeof _.stack=="string"){for(var d=_.stack.split(`
35
+ `),h=l.stack.split(`
36
+ `),k=d.length-1,w=h.length-1;1<=k&&0<=w&&d[k]!==h[w];)w--;for(;1<=k&&0<=w;k--,w--)if(d[k]!==h[w]){if(k!==1||w!==1)do if(k--,w--,0>w||d[k]!==h[w]){var C=`
37
+ `+d[k].replace(" at new "," at ");return e.displayName&&C.includes("<anonymous>")&&(C=C.replace("<anonymous>",e.displayName)),C}while(1<=k&&0<=w);break}}}finally{fe=!1,Error.prepareStackTrace=o}return(e=e?e.displayName||e.name:"")?P(e):""}function ae(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 ye(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 le:return"Fragment";case K:return"Portal";case Q:return"Profiler";case de:return"StrictMode";case R:return"Suspense";case V:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case De: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:ye(e.type)||"Memo";case ce:n=e._payload,e=e._init;try{return ye(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 ye(n);case 8:return n===de?"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 it(e){var n=be(e)?"checked":"value",o=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),l=""+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(k){l=""+k,h.call(this,k)}}),Object.defineProperty(e,n,{enumerable:o.enumerable}),{getValue:function(){return l},setValue:function(k){l=""+k},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function Yn(e){e._valueTracker||(e._valueTracker=it(e))}function Yl(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var o=n.getValue(),l="";return e&&(l=be(e)?e.checked?"true":"false":e.value),e=l,e!==o?(n.setValue(e),!0):!1}function Oi(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 go(e,n){var o=n.checked;return W({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:o??e._wrapperState.initialChecked})}function Jl(e,n){var o=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;o=ve(n.value!=null?n.value:o),e._wrapperState={initialChecked:l,initialValue:o,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function Xl(e,n){n=n.checked,n!=null&&L(e,"checked",n,!1)}function vo(e,n){Xl(e,n);var o=ve(n.value),l=n.type;if(o!=null)l==="number"?(o===0&&e.value===""||e.value!=o)&&(e.value=""+o):e.value!==""+o&&(e.value=""+o);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?ko(e,n.type,o):n.hasOwnProperty("defaultValue")&&ko(e,n.type,ve(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function Zl(e,n,o){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var l=n.type;if(!(l!=="submit"&&l!=="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 ko(e,n,o){(n!=="number"||Oi(e.ownerDocument)!==e)&&(o==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+o&&(e.defaultValue=""+o))}var _s=Array.isArray;function Jn(e,n,o,l){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&&l&&(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,l&&(e[d].defaultSelected=!0);return}n!==null||e[d].disabled||(n=e[d])}n!==null&&(n.selected=!0)}}function yo(e,n){if(n.dangerouslySetInnerHTML!=null)throw Error(r(91));return W({},n,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function ec(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(_s(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 tc(e,n){var o=ve(n.value),l=ve(n.defaultValue);o!=null&&(o=""+o,o!==e.value&&(e.value=o),n.defaultValue==null&&e.defaultValue!==o&&(e.defaultValue=o)),l!=null&&(e.defaultValue=""+l)}function nc(e){var n=e.textContent;n===e._wrapperState.initialValue&&n!==""&&n!==null&&(e.value=n)}function sc(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 xo(e,n){return e==null||e==="http://www.w3.org/1999/xhtml"?sc(n):e==="http://www.w3.org/2000/svg"&&n==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Pi,ic=(function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(n,o,l,d){MSApp.execUnsafeLocalFunction(function(){return e(n,o,l,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 Os(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},Gh=["Webkit","ms","Moz","O"];Object.keys(Ps).forEach(function(e){Gh.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),Ps[n]=Ps[e]})});function rc(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 oc(e,n){e=e.style;for(var o in n)if(n.hasOwnProperty(o)){var l=o.indexOf("--")===0,d=rc(o,n[o],l);o==="float"&&(o="cssFloat"),l?e.setProperty(o,d):e[o]=d}}var Yh=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 wo(e,n){if(n){if(Yh[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 jo(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 So=null;function No(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Co=null,Xn=null,Zn=null;function ac(e){if(e=ri(e)){if(typeof Co!="function")throw Error(r(280));var n=e.stateNode;n&&(n=or(n),Co(e.stateNode,e.type,n))}}function lc(e){Xn?Zn?Zn.push(e):Zn=[e]:Xn=e}function cc(){if(Xn){var e=Xn,n=Zn;if(Zn=Xn=null,ac(e),n)for(e=0;e<n.length;e++)ac(n[e])}}function uc(e,n){return e(n)}function dc(){}var $o=!1;function fc(e,n,o){if($o)return e(n,o);$o=!0;try{return uc(e,n,o)}finally{$o=!1,(Xn!==null||Zn!==null)&&(dc(),cc())}}function Ds(e,n){var o=e.stateNode;if(o===null)return null;var l=or(o);if(l===null)return null;o=l[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":(l=!l.disabled)||(e=e.type,l=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!l;break e;default:e=!1}if(e)return null;if(o&&typeof o!="function")throw Error(r(231,n,typeof o));return o}var bo=!1;if(m)try{var zs={};Object.defineProperty(zs,"passive",{get:function(){bo=!0}}),window.addEventListener("test",zs,zs),window.removeEventListener("test",zs,zs)}catch{bo=!1}function Jh(e,n,o,l,d,h,k,w,C){var _=Array.prototype.slice.call(arguments,3);try{n.apply(o,_)}catch(z){this.onError(z)}}var Bs=!1,Di=null,zi=!1,To=null,Xh={onError:function(e){Bs=!0,Di=e}};function Zh(e,n,o,l,d,h,k,w,C){Bs=!1,Di=null,Jh.apply(Xh,arguments)}function em(e,n,o,l,d,h,k,w,C){if(Zh.apply(this,arguments),Bs){if(Bs){var _=Di;Bs=!1,Di=null}else throw Error(r(198));zi||(zi=!0,To=_)}}function An(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 hc(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 mc(e){if(An(e)!==e)throw Error(r(188))}function tm(e){var n=e.alternate;if(!n){if(n=An(e),n===null)throw Error(r(188));return n!==e?null:e}for(var o=e,l=n;;){var d=o.return;if(d===null)break;var h=d.alternate;if(h===null){if(l=d.return,l!==null){o=l;continue}break}if(d.child===h.child){for(h=d.child;h;){if(h===o)return mc(d),e;if(h===l)return mc(d),n;h=h.sibling}throw Error(r(188))}if(o.return!==l.return)o=d,l=h;else{for(var k=!1,w=d.child;w;){if(w===o){k=!0,o=d,l=h;break}if(w===l){k=!0,l=d,o=h;break}w=w.sibling}if(!k){for(w=h.child;w;){if(w===o){k=!0,o=h,l=d;break}if(w===l){k=!0,l=h,o=d;break}w=w.sibling}if(!k)throw Error(r(189))}}if(o.alternate!==l)throw Error(r(190))}if(o.tag!==3)throw Error(r(188));return o.stateNode.current===o?e:n}function pc(e){return e=tm(e),e!==null?gc(e):null}function gc(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var n=gc(e);if(n!==null)return n;e=e.sibling}return null}var vc=s.unstable_scheduleCallback,kc=s.unstable_cancelCallback,nm=s.unstable_shouldYield,sm=s.unstable_requestPaint,Oe=s.unstable_now,im=s.unstable_getCurrentPriorityLevel,Eo=s.unstable_ImmediatePriority,yc=s.unstable_UserBlockingPriority,Bi=s.unstable_NormalPriority,rm=s.unstable_LowPriority,xc=s.unstable_IdlePriority,Fi=null,Dt=null;function om(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:cm,am=Math.log,lm=Math.LN2;function cm(e){return e>>>=0,e===0?32:31-(am(e)/lm|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 l=0,d=e.suspendedLanes,h=e.pingedLanes,k=o&268435455;if(k!==0){var w=k&~d;w!==0?l=Fs(w):(h&=k,h!==0&&(l=Fs(h)))}else k=o&~d,k!==0?l=Fs(k):h!==0&&(l=Fs(h));if(l===0)return 0;if(n!==0&&n!==l&&(n&d)===0&&(d=l&-l,h=n&-n,d>=h||d===16&&(h&4194240)!==0))return n;if((l&4)!==0&&(l|=o&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=l;0<n;)o=31-Mt(n),d=1<<o,l|=e[o],n&=~d;return l}function um(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 dm(e,n){for(var o=e.suspendedLanes,l=e.pingedLanes,d=e.expirationTimes,h=e.pendingLanes;0<h;){var k=31-Mt(h),w=1<<k,C=d[k];C===-1?((w&o)===0||(w&l)!==0)&&(d[k]=um(w,n)):C<=n&&(e.expiredLanes|=w),h&=~w}}function Mo(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function wc(){var e=Ui;return Ui<<=1,(Ui&4194240)===0&&(Ui=64),e}function Io(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 fm(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 l=e.eventTimes;for(e=e.expirationTimes;0<o;){var d=31-Mt(o),h=1<<d;n[d]=0,l[d]=-1,e[d]=-1,o&=~h}}function Ao(e,n){var o=e.entangledLanes|=n;for(e=e.entanglements;o;){var l=31-Mt(o),d=1<<l;d&n|e[l]&n&&(e[l]|=n),o&=~d}}var Ne=0;function jc(e){return e&=-e,1<e?4<e?(e&268435455)!==0?16:536870912:4:1}var Sc,Lo,Nc,Cc,$c,Ro=!1,Ki=[],on=null,an=null,ln=null,Ws=new Map,Hs=new Map,cn=[],hm="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 bc(e,n){switch(e){case"focusin":case"focusout":on=null;break;case"dragenter":case"dragleave":an=null;break;case"mouseover":case"mouseout":ln=null;break;case"pointerover":case"pointerout":Ws.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":Hs.delete(n.pointerId)}}function Ks(e,n,o,l,d,h){return e===null||e.nativeEvent!==h?(e={blockedOn:n,domEventName:o,eventSystemFlags:l,nativeEvent:h,targetContainers:[d]},n!==null&&(n=ri(n),n!==null&&Lo(n)),e):(e.eventSystemFlags|=l,n=e.targetContainers,d!==null&&n.indexOf(d)===-1&&n.push(d),e)}function mm(e,n,o,l,d){switch(n){case"focusin":return on=Ks(on,e,n,o,l,d),!0;case"dragenter":return an=Ks(an,e,n,o,l,d),!0;case"mouseover":return ln=Ks(ln,e,n,o,l,d),!0;case"pointerover":var h=d.pointerId;return Ws.set(h,Ks(Ws.get(h)||null,e,n,o,l,d)),!0;case"gotpointercapture":return h=d.pointerId,Hs.set(h,Ks(Hs.get(h)||null,e,n,o,l,d)),!0}return!1}function Tc(e){var n=Ln(e.target);if(n!==null){var o=An(n);if(o!==null){if(n=o.tag,n===13){if(n=hc(o),n!==null){e.blockedOn=n,$c(e.priority,function(){Nc(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 Vi(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContainers;0<n.length;){var o=Oo(e.domEventName,e.eventSystemFlags,n[0],e.nativeEvent);if(o===null){o=e.nativeEvent;var l=new o.constructor(o.type,o);So=l,o.target.dispatchEvent(l),So=null}else return n=ri(o),n!==null&&Lo(n),e.blockedOn=o,!1;n.shift()}return!0}function Ec(e,n,o){Vi(e)&&o.delete(n)}function pm(){Ro=!1,on!==null&&Vi(on)&&(on=null),an!==null&&Vi(an)&&(an=null),ln!==null&&Vi(ln)&&(ln=null),Ws.forEach(Ec),Hs.forEach(Ec)}function Vs(e,n){e.blockedOn===n&&(e.blockedOn=null,Ro||(Ro=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,pm)))}function Qs(e){function n(d){return Vs(d,e)}if(0<Ki.length){Vs(Ki[0],e);for(var o=1;o<Ki.length;o++){var l=Ki[o];l.blockedOn===e&&(l.blockedOn=null)}}for(on!==null&&Vs(on,e),an!==null&&Vs(an,e),ln!==null&&Vs(ln,e),Ws.forEach(n),Hs.forEach(n),o=0;o<cn.length;o++)l=cn[o],l.blockedOn===e&&(l.blockedOn=null);for(;0<cn.length&&(o=cn[0],o.blockedOn===null);)Tc(o),o.blockedOn===null&&cn.shift()}var es=J.ReactCurrentBatchConfig,Qi=!0;function gm(e,n,o,l){var d=Ne,h=es.transition;es.transition=null;try{Ne=1,_o(e,n,o,l)}finally{Ne=d,es.transition=h}}function vm(e,n,o,l){var d=Ne,h=es.transition;es.transition=null;try{Ne=4,_o(e,n,o,l)}finally{Ne=d,es.transition=h}}function _o(e,n,o,l){if(Qi){var d=Oo(e,n,o,l);if(d===null)Zo(e,n,l,qi,o),bc(e,l);else if(mm(d,e,n,o,l))l.stopPropagation();else if(bc(e,l),n&4&&-1<hm.indexOf(e)){for(;d!==null;){var h=ri(d);if(h!==null&&Sc(h),h=Oo(e,n,o,l),h===null&&Zo(e,n,l,qi,o),h===d)break;d=h}d!==null&&l.stopPropagation()}else Zo(e,n,l,null,o)}}var qi=null;function Oo(e,n,o,l){if(qi=null,e=No(l),e=Ln(e),e!==null)if(n=An(e),n===null)e=null;else if(o=n.tag,o===13){if(e=hc(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 Mc(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(im()){case Eo:return 1;case yc:return 4;case Bi:case rm:return 16;case xc:return 536870912;default:return 16}default:return 16}}var un=null,Po=null,Gi=null;function Ic(){if(Gi)return Gi;var e,n=Po,o=n.length,l,d="value"in un?un.value:un.textContent,h=d.length;for(e=0;e<o&&n[e]===d[e];e++);var k=o-e;for(l=1;l<=k&&n[o-l]===d[h-l];l++);return Gi=d.slice(e,1<l?1-l: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 Ac(){return!1}function vt(e){function n(o,l,d,h,k){this._reactName=o,this._targetInst=d,this.type=l,this.nativeEvent=h,this.target=k,this.currentTarget=null;for(var w in e)e.hasOwnProperty(w)&&(o=e[w],this[w]=o?o(h):h[w]);return this.isDefaultPrevented=(h.defaultPrevented!=null?h.defaultPrevented:h.returnValue===!1)?Ji:Ac,this.isPropagationStopped=Ac,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 ts={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Do=vt(ts),qs=W({},ts,{view:0,detail:0}),km=vt(qs),zo,Bo,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:Uo,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"?(zo=e.screenX-Gs.screenX,Bo=e.screenY-Gs.screenY):Bo=zo=0,Gs=e),zo)},movementY:function(e){return"movementY"in e?e.movementY:Bo}}),Lc=vt(Xi),ym=W({},Xi,{dataTransfer:0}),xm=vt(ym),wm=W({},qs,{relatedTarget:0}),Fo=vt(wm),jm=W({},ts,{animationName:0,elapsedTime:0,pseudoElement:0}),Sm=vt(jm),Nm=W({},ts,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Cm=vt(Nm),$m=W({},ts,{data:0}),Rc=vt($m),bm={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Tm={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"},Em={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Mm(e){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(e):(e=Em[e])?!!n[e]:!1}function Uo(){return Mm}var Im=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"?Tm[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Uo,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}}),Am=vt(Im),Lm=W({},Xi,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),_c=vt(Lm),Rm=W({},qs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Uo}),_m=vt(Rm),Om=W({},ts,{propertyName:0,elapsedTime:0,pseudoElement:0}),Pm=vt(Om),Dm=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}),zm=vt(Dm),Bm=[9,13,27,32],Wo=m&&"CompositionEvent"in window,Ys=null;m&&"documentMode"in document&&(Ys=document.documentMode);var Fm=m&&"TextEvent"in window&&!Ys,Oc=m&&(!Wo||Ys&&8<Ys&&11>=Ys),Pc=" ",Dc=!1;function zc(e,n){switch(e){case"keyup":return Bm.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Bc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ns=!1;function Um(e,n){switch(e){case"compositionend":return Bc(n);case"keypress":return n.which!==32?null:(Dc=!0,Pc);case"textInput":return e=n.data,e===Pc&&Dc?null:e;default:return null}}function Wm(e,n){if(ns)return e==="compositionend"||!Wo&&zc(e,n)?(e=Ic(),Gi=Po=un=null,ns=!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 Oc&&n.locale!=="ko"?null:n.data;default:return null}}var Hm={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 Fc(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n==="input"?!!Hm[e.type]:n==="textarea"}function Uc(e,n,o,l){lc(l),n=sr(n,"onChange"),0<n.length&&(o=new Do("onChange","change",null,o,l),e.push({event:o,listeners:n}))}var Js=null,Xs=null;function Km(e){ou(e,0)}function Zi(e){var n=as(e);if(Yl(n))return e}function Vm(e,n){if(e==="change")return n}var Wc=!1;if(m){var Ho;if(m){var Ko="oninput"in document;if(!Ko){var Hc=document.createElement("div");Hc.setAttribute("oninput","return;"),Ko=typeof Hc.oninput=="function"}Ho=Ko}else Ho=!1;Wc=Ho&&(!document.documentMode||9<document.documentMode)}function Kc(){Js&&(Js.detachEvent("onpropertychange",Vc),Xs=Js=null)}function Vc(e){if(e.propertyName==="value"&&Zi(Xs)){var n=[];Uc(n,Xs,e,No(e)),fc(Km,n)}}function Qm(e,n,o){e==="focusin"?(Kc(),Js=n,Xs=o,Js.attachEvent("onpropertychange",Vc)):e==="focusout"&&Kc()}function qm(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Zi(Xs)}function Gm(e,n){if(e==="click")return Zi(n)}function Ym(e,n){if(e==="input"||e==="change")return Zi(n)}function Jm(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}var It=typeof Object.is=="function"?Object.is:Jm;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),l=Object.keys(n);if(o.length!==l.length)return!1;for(l=0;l<o.length;l++){var d=o[l];if(!g.call(n,d)||!It(e[d],n[d]))return!1}return!0}function Qc(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function qc(e,n){var o=Qc(e);e=0;for(var l;o;){if(o.nodeType===3){if(l=e+o.textContent.length,e<=n&&l>=n)return{node:o,offset:n-e};e=l}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=Qc(o)}}function Gc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Gc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function Yc(){for(var e=window,n=Oi();n instanceof e.HTMLIFrameElement;){try{var o=typeof n.contentWindow.location.href=="string"}catch{o=!1}if(o)e=n.contentWindow;else break;n=Oi(e.document)}return n}function Vo(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 Xm(e){var n=Yc(),o=e.focusedElem,l=e.selectionRange;if(n!==o&&o&&o.ownerDocument&&Gc(o.ownerDocument.documentElement,o)){if(l!==null&&Vo(o)){if(n=l.start,e=l.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(l.start,d);l=l.end===void 0?h:Math.min(l.end,d),!e.extend&&h>l&&(d=l,l=h,h=d),d=qc(o,h);var k=qc(o,l);d&&k&&(e.rangeCount!==1||e.anchorNode!==d.node||e.anchorOffset!==d.offset||e.focusNode!==k.node||e.focusOffset!==k.offset)&&(n=n.createRange(),n.setStart(d.node,d.offset),e.removeAllRanges(),h>l?(e.addRange(n),e.extend(k.node,k.offset)):(n.setEnd(k.node,k.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 Zm=m&&"documentMode"in document&&11>=document.documentMode,ss=null,Qo=null,ei=null,qo=!1;function Jc(e,n,o){var l=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;qo||ss==null||ss!==Oi(l)||(l=ss,"selectionStart"in l&&Vo(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),ei&&Zs(ei,l)||(ei=l,l=sr(Qo,"onSelect"),0<l.length&&(n=new Do("onSelect","select",null,n,o),e.push({event:n,listeners:l}),n.target=ss)))}function er(e,n){var o={};return o[e.toLowerCase()]=n.toLowerCase(),o["Webkit"+e]="webkit"+n,o["Moz"+e]="moz"+n,o}var is={animationend:er("Animation","AnimationEnd"),animationiteration:er("Animation","AnimationIteration"),animationstart:er("Animation","AnimationStart"),transitionend:er("Transition","TransitionEnd")},Go={},Xc={};m&&(Xc=document.createElement("div").style,"AnimationEvent"in window||(delete is.animationend.animation,delete is.animationiteration.animation,delete is.animationstart.animation),"TransitionEvent"in window||delete is.transitionend.transition);function tr(e){if(Go[e])return Go[e];if(!is[e])return e;var n=is[e],o;for(o in n)if(n.hasOwnProperty(o)&&o in Xc)return Go[e]=n[o];return e}var Zc=tr("animationend"),eu=tr("animationiteration"),tu=tr("animationstart"),nu=tr("transitionend"),su=new Map,iu="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 dn(e,n){su.set(e,n),u(n,[e])}for(var Yo=0;Yo<iu.length;Yo++){var Jo=iu[Yo],ep=Jo.toLowerCase(),tp=Jo[0].toUpperCase()+Jo.slice(1);dn(ep,"on"+tp)}dn(Zc,"onAnimationEnd"),dn(eu,"onAnimationIteration"),dn(tu,"onAnimationStart"),dn("dblclick","onDoubleClick"),dn("focusin","onFocus"),dn("focusout","onBlur"),dn(nu,"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(" "),np=new Set("cancel close invalid load scroll toggle".split(" ").concat(ti));function ru(e,n,o){var l=e.type||"unknown-event";e.currentTarget=o,em(l,n,void 0,e),e.currentTarget=null}function ou(e,n){n=(n&4)!==0;for(var o=0;o<e.length;o++){var l=e[o],d=l.event;l=l.listeners;e:{var h=void 0;if(n)for(var k=l.length-1;0<=k;k--){var w=l[k],C=w.instance,_=w.currentTarget;if(w=w.listener,C!==h&&d.isPropagationStopped())break e;ru(d,w,_),h=C}else for(k=0;k<l.length;k++){if(w=l[k],C=w.instance,_=w.currentTarget,w=w.listener,C!==h&&d.isPropagationStopped())break e;ru(d,w,_),h=C}}}if(zi)throw e=To,zi=!1,To=null,e}function Me(e,n){var o=n[ra];o===void 0&&(o=n[ra]=new Set);var l=e+"__bubble";o.has(l)||(au(n,e,2,!1),o.add(l))}function Xo(e,n,o){var l=0;n&&(l|=4),au(o,e,l,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"&&(np.has(o)||Xo(o,!1,e),Xo(o,!0,e))});var n=e.nodeType===9?e:e.ownerDocument;n===null||n[nr]||(n[nr]=!0,Xo("selectionchange",!1,n))}}function au(e,n,o,l){switch(Mc(n)){case 1:var d=gm;break;case 4:d=vm;break;default:d=_o}o=d.bind(null,n,o,e),d=void 0,!bo||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(d=!0),l?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 Zo(e,n,o,l,d){var h=l;if((n&1)===0&&(n&2)===0&&l!==null)e:for(;;){if(l===null)return;var k=l.tag;if(k===3||k===4){var w=l.stateNode.containerInfo;if(w===d||w.nodeType===8&&w.parentNode===d)break;if(k===4)for(k=l.return;k!==null;){var C=k.tag;if((C===3||C===4)&&(C=k.stateNode.containerInfo,C===d||C.nodeType===8&&C.parentNode===d))return;k=k.return}for(;w!==null;){if(k=Ln(w),k===null)return;if(C=k.tag,C===5||C===6){l=h=k;continue e}w=w.parentNode}}l=l.return}fc(function(){var _=h,z=No(o),U=[];e:{var D=su.get(e);if(D!==void 0){var G=Do,X=e;switch(e){case"keypress":if(Yi(o)===0)break e;case"keydown":case"keyup":G=Am;break;case"focusin":X="focus",G=Fo;break;case"focusout":X="blur",G=Fo;break;case"beforeblur":case"afterblur":G=Fo;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":G=Lc;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":G=xm;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":G=_m;break;case Zc:case eu:case tu:G=Sm;break;case nu:G=Pm;break;case"scroll":G=km;break;case"wheel":G=zm;break;case"copy":case"cut":case"paste":G=Cm;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":G=_c}var ee=(n&4)!==0,Pe=!ee&&e==="scroll",T=ee?D!==null?D+"Capture":null:D;ee=[];for(var $=_,A;$!==null;){A=$;var H=A.stateNode;if(A.tag===5&&H!==null&&(A=H,T!==null&&(H=Ds($,T),H!=null&&ee.push(si($,H,A)))),Pe)break;$=$.return}0<ee.length&&(D=new G(D,X,null,o,z),U.push({event:D,listeners:ee}))}}if((n&7)===0){e:{if(D=e==="mouseover"||e==="pointerover",G=e==="mouseout"||e==="pointerout",D&&o!==So&&(X=o.relatedTarget||o.fromElement)&&(Ln(X)||X[qt]))break e;if((G||D)&&(D=z.window===z?z:(D=z.ownerDocument)?D.defaultView||D.parentWindow:window,G?(X=o.relatedTarget||o.toElement,G=_,X=X?Ln(X):null,X!==null&&(Pe=An(X),X!==Pe||X.tag!==5&&X.tag!==6)&&(X=null)):(G=null,X=_),G!==X)){if(ee=Lc,H="onMouseLeave",T="onMouseEnter",$="mouse",(e==="pointerout"||e==="pointerover")&&(ee=_c,H="onPointerLeave",T="onPointerEnter",$="pointer"),Pe=G==null?D:as(G),A=X==null?D:as(X),D=new ee(H,$+"leave",G,o,z),D.target=Pe,D.relatedTarget=A,H=null,Ln(z)===_&&(ee=new ee(T,$+"enter",X,o,z),ee.target=A,ee.relatedTarget=Pe,H=ee),Pe=H,G&&X)t:{for(ee=G,T=X,$=0,A=ee;A;A=rs(A))$++;for(A=0,H=T;H;H=rs(H))A++;for(;0<$-A;)ee=rs(ee),$--;for(;0<A-$;)T=rs(T),A--;for(;$--;){if(ee===T||T!==null&&ee===T.alternate)break t;ee=rs(ee),T=rs(T)}ee=null}else ee=null;G!==null&&lu(U,D,G,ee,!1),X!==null&&Pe!==null&&lu(U,Pe,X,ee,!0)}}e:{if(D=_?as(_):window,G=D.nodeName&&D.nodeName.toLowerCase(),G==="select"||G==="input"&&D.type==="file")var te=Vm;else if(Fc(D))if(Wc)te=Ym;else{te=qm;var ie=Qm}else(G=D.nodeName)&&G.toLowerCase()==="input"&&(D.type==="checkbox"||D.type==="radio")&&(te=Gm);if(te&&(te=te(e,_))){Uc(U,te,o,z);break e}ie&&ie(e,D,_),e==="focusout"&&(ie=D._wrapperState)&&ie.controlled&&D.type==="number"&&ko(D,"number",D.value)}switch(ie=_?as(_):window,e){case"focusin":(Fc(ie)||ie.contentEditable==="true")&&(ss=ie,Qo=_,ei=null);break;case"focusout":ei=Qo=ss=null;break;case"mousedown":qo=!0;break;case"contextmenu":case"mouseup":case"dragend":qo=!1,Jc(U,o,z);break;case"selectionchange":if(Zm)break;case"keydown":case"keyup":Jc(U,o,z)}var re;if(Wo)e:{switch(e){case"compositionstart":var ue="onCompositionStart";break e;case"compositionend":ue="onCompositionEnd";break e;case"compositionupdate":ue="onCompositionUpdate";break e}ue=void 0}else ns?zc(e,o)&&(ue="onCompositionEnd"):e==="keydown"&&o.keyCode===229&&(ue="onCompositionStart");ue&&(Oc&&o.locale!=="ko"&&(ns||ue!=="onCompositionStart"?ue==="onCompositionEnd"&&ns&&(re=Ic()):(un=z,Po="value"in un?un.value:un.textContent,ns=!0)),ie=sr(_,ue),0<ie.length&&(ue=new Rc(ue,e,null,o,z),U.push({event:ue,listeners:ie}),re?ue.data=re:(re=Bc(o),re!==null&&(ue.data=re)))),(re=Fm?Um(e,o):Wm(e,o))&&(_=sr(_,"onBeforeInput"),0<_.length&&(z=new Rc("onBeforeInput","beforeinput",null,o,z),U.push({event:z,listeners:_}),z.data=re))}ou(U,n)})}function si(e,n,o){return{instance:e,listener:n,currentTarget:o}}function sr(e,n){for(var o=n+"Capture",l=[];e!==null;){var d=e,h=d.stateNode;d.tag===5&&h!==null&&(d=h,h=Ds(e,o),h!=null&&l.unshift(si(e,h,d)),h=Ds(e,n),h!=null&&l.push(si(e,h,d))),e=e.return}return l}function rs(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function lu(e,n,o,l,d){for(var h=n._reactName,k=[];o!==null&&o!==l;){var w=o,C=w.alternate,_=w.stateNode;if(C!==null&&C===l)break;w.tag===5&&_!==null&&(w=_,d?(C=Ds(o,h),C!=null&&k.unshift(si(o,C,w))):d||(C=Ds(o,h),C!=null&&k.push(si(o,C,w)))),o=o.return}k.length!==0&&e.push({event:n,listeners:k})}var sp=/\r\n?/g,ip=/\u0000|\uFFFD/g;function cu(e){return(typeof e=="string"?e:""+e).replace(sp,`
38
+ `).replace(ip,"")}function ir(e,n,o){if(n=cu(n),cu(e)!==n&&o)throw Error(r(425))}function rr(){}var ea=null,ta=null;function na(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 sa=typeof setTimeout=="function"?setTimeout:void 0,rp=typeof clearTimeout=="function"?clearTimeout:void 0,uu=typeof Promise=="function"?Promise:void 0,op=typeof queueMicrotask=="function"?queueMicrotask:typeof uu<"u"?function(e){return uu.resolve(null).then(e).catch(ap)}:sa;function ap(e){setTimeout(function(){throw e})}function ia(e,n){var o=n,l=0;do{var d=o.nextSibling;if(e.removeChild(o),d&&d.nodeType===8)if(o=d.data,o==="/$"){if(l===0){e.removeChild(d),Qs(n);return}l--}else o!=="$"&&o!=="$?"&&o!=="$!"||l++;o=d}while(o);Qs(n)}function fn(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 du(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 os=Math.random().toString(36).slice(2),zt="__reactFiber$"+os,ii="__reactProps$"+os,qt="__reactContainer$"+os,ra="__reactEvents$"+os,lp="__reactListeners$"+os,cp="__reactHandles$"+os;function Ln(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=du(e);e!==null;){if(o=e[zt])return o;e=du(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 as(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(r(33))}function or(e){return e[ii]||null}var oa=[],ls=-1;function hn(e){return{current:e}}function Ie(e){0>ls||(e.current=oa[ls],oa[ls]=null,ls--)}function Ee(e,n){ls++,oa[ls]=e.current,e.current=n}var mn={},Xe=hn(mn),lt=hn(!1),Rn=mn;function cs(e,n){var o=e.type.contextTypes;if(!o)return mn;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var d={},h;for(h in o)d[h]=n[h];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=d),d}function ct(e){return e=e.childContextTypes,e!=null}function ar(){Ie(lt),Ie(Xe)}function fu(e,n,o){if(Xe.current!==mn)throw Error(r(168));Ee(Xe,n),Ee(lt,o)}function hu(e,n,o){var l=e.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return o;l=l.getChildContext();for(var d in l)if(!(d in n))throw Error(r(108,he(e)||"Unknown",d));return W({},o,l)}function lr(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||mn,Rn=Xe.current,Ee(Xe,e),Ee(lt,lt.current),!0}function mu(e,n,o){var l=e.stateNode;if(!l)throw Error(r(169));o?(e=hu(e,n,Rn),l.__reactInternalMemoizedMergedChildContext=e,Ie(lt),Ie(Xe),Ee(Xe,e)):Ie(lt),Ee(lt,o)}var Gt=null,cr=!1,aa=!1;function pu(e){Gt===null?Gt=[e]:Gt.push(e)}function up(e){cr=!0,pu(e)}function pn(){if(!aa&&Gt!==null){aa=!0;var e=0,n=Ne;try{var o=Gt;for(Ne=1;e<o.length;e++){var l=o[e];do l=l(!0);while(l!==null)}Gt=null,cr=!1}catch(d){throw Gt!==null&&(Gt=Gt.slice(e+1)),vc(Eo,pn),d}finally{Ne=n,aa=!1}}return null}var us=[],ds=0,ur=null,dr=0,jt=[],St=0,_n=null,Yt=1,Jt="";function On(e,n){us[ds++]=dr,us[ds++]=ur,ur=e,dr=n}function gu(e,n,o){jt[St++]=Yt,jt[St++]=Jt,jt[St++]=_n,_n=e;var l=Yt;e=Jt;var d=32-Mt(l)-1;l&=~(1<<d),o+=1;var h=32-Mt(n)+d;if(30<h){var k=d-d%5;h=(l&(1<<k)-1).toString(32),l>>=k,d-=k,Yt=1<<32-Mt(n)+d|o<<d|l,Jt=h+e}else Yt=1<<h|o<<d|l,Jt=e}function la(e){e.return!==null&&(On(e,1),gu(e,1,0))}function ca(e){for(;e===ur;)ur=us[--ds],us[ds]=null,dr=us[--ds],us[ds]=null;for(;e===_n;)_n=jt[--St],jt[St]=null,Jt=jt[--St],jt[St]=null,Yt=jt[--St],jt[St]=null}var kt=null,yt=null,Ae=!1,At=null;function vu(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 ku(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,kt=e,yt=fn(n.firstChild),!0):!1;case 6:return n=e.pendingProps===""||n.nodeType!==3?null:n,n!==null?(e.stateNode=n,kt=e,yt=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,kt=e,yt=null,!0):!1;default:return!1}}function ua(e){return(e.mode&1)!==0&&(e.flags&128)===0}function da(e){if(Ae){var n=yt;if(n){var o=n;if(!ku(e,n)){if(ua(e))throw Error(r(418));n=fn(o.nextSibling);var l=kt;n&&ku(e,n)?vu(l,o):(e.flags=e.flags&-4097|2,Ae=!1,kt=e)}}else{if(ua(e))throw Error(r(418));e.flags=e.flags&-4097|2,Ae=!1,kt=e}}}function yu(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;kt=e}function fr(e){if(e!==kt)return!1;if(!Ae)return yu(e),Ae=!0,!1;var n;if((n=e.tag!==3)&&!(n=e.tag!==5)&&(n=e.type,n=n!=="head"&&n!=="body"&&!na(e.type,e.memoizedProps)),n&&(n=yt)){if(ua(e))throw xu(),Error(r(418));for(;n;)vu(e,n),n=fn(n.nextSibling)}if(yu(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){yt=fn(e.nextSibling);break e}n--}else o!=="$"&&o!=="$!"&&o!=="$?"||n++}e=e.nextSibling}yt=null}}else yt=kt?fn(e.stateNode.nextSibling):null;return!0}function xu(){for(var e=yt;e;)e=fn(e.nextSibling)}function fs(){yt=kt=null,Ae=!1}function fa(e){At===null?At=[e]:At.push(e)}var dp=J.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 l=o.stateNode}if(!l)throw Error(r(147,e));var d=l,h=""+e;return n!==null&&n.ref!==null&&typeof n.ref=="function"&&n.ref._stringRef===h?n.ref:(n=function(k){var w=d.refs;k===null?delete w[h]:w[h]=k},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 wu(e){var n=e._init;return n(e._payload)}function ju(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 l(T,$){for(T=new Map;$!==null;)$.key!==null?T.set($.key,$):T.set($.index,$),$=$.sibling;return T}function d(T,$){return T=Sn(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 k(T){return e&&T.alternate===null&&(T.flags|=2),T}function w(T,$,A,H){return $===null||$.tag!==6?($=sl(A,T.mode,H),$.return=T,$):($=d($,A),$.return=T,$)}function C(T,$,A,H){var te=A.type;return te===le?z(T,$,A.props.children,H,A.key):$!==null&&($.elementType===te||typeof te=="object"&&te!==null&&te.$$typeof===ce&&wu(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 _(T,$,A,H){return $===null||$.tag!==4||$.stateNode.containerInfo!==A.containerInfo||$.stateNode.implementation!==A.implementation?($=il(A,T.mode,H),$.return=T,$):($=d($,A.children||[]),$.return=T,$)}function z(T,$,A,H,te){return $===null||$.tag!==7?($=Hn(A,T.mode,H,te),$.return=T,$):($=d($,A),$.return=T,$)}function U(T,$,A){if(typeof $=="string"&&$!==""||typeof $=="number")return $=sl(""+$,T.mode,A),$.return=T,$;if(typeof $=="object"&&$!==null){switch($.$$typeof){case Z:return A=Pr($.type,$.key,$.props,null,T.mode,A),A.ref=oi(T,null,$),A.return=T,A;case K:return $=il($,T.mode,A),$.return=T,$;case ce:var H=$._init;return U(T,H($._payload),A)}if(_s($)||F($))return $=Hn($,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:w(T,$,""+A,H);if(typeof A=="object"&&A!==null){switch(A.$$typeof){case Z:return A.key===te?C(T,$,A,H):null;case K:return A.key===te?_(T,$,A,H):null;case ce:return te=A._init,D(T,$,te(A._payload),H)}if(_s(A)||F(A))return te!==null?null:z(T,$,A,H,null);hr(T,A)}return null}function G(T,$,A,H,te){if(typeof H=="string"&&H!==""||typeof H=="number")return T=T.get(A)||null,w($,T,""+H,te);if(typeof H=="object"&&H!==null){switch(H.$$typeof){case Z:return T=T.get(H.key===null?A:H.key)||null,C($,T,H,te);case K:return T=T.get(H.key===null?A:H.key)||null,_($,T,H,te);case ce:var ie=H._init;return G(T,$,A,ie(H._payload),te)}if(_s(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,ie=null,re=$,ue=$=0,Qe=null;re!==null&&ue<A.length;ue++){re.index>ue?(Qe=re,re=null):Qe=re.sibling;var Se=D(T,re,A[ue],H);if(Se===null){re===null&&(re=Qe);break}e&&re&&Se.alternate===null&&n(T,re),$=h(Se,$,ue),ie===null?te=Se:ie.sibling=Se,ie=Se,re=Qe}if(ue===A.length)return o(T,re),Ae&&On(T,ue),te;if(re===null){for(;ue<A.length;ue++)re=U(T,A[ue],H),re!==null&&($=h(re,$,ue),ie===null?te=re:ie.sibling=re,ie=re);return Ae&&On(T,ue),te}for(re=l(T,re);ue<A.length;ue++)Qe=G(re,T,ue,A[ue],H),Qe!==null&&(e&&Qe.alternate!==null&&re.delete(Qe.key===null?ue:Qe.key),$=h(Qe,$,ue),ie===null?te=Qe:ie.sibling=Qe,ie=Qe);return e&&re.forEach(function(Nn){return n(T,Nn)}),Ae&&On(T,ue),te}function ee(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 ie=te=null,re=$,ue=$=0,Qe=null,Se=A.next();re!==null&&!Se.done;ue++,Se=A.next()){re.index>ue?(Qe=re,re=null):Qe=re.sibling;var Nn=D(T,re,Se.value,H);if(Nn===null){re===null&&(re=Qe);break}e&&re&&Nn.alternate===null&&n(T,re),$=h(Nn,$,ue),ie===null?te=Nn:ie.sibling=Nn,ie=Nn,re=Qe}if(Se.done)return o(T,re),Ae&&On(T,ue),te;if(re===null){for(;!Se.done;ue++,Se=A.next())Se=U(T,Se.value,H),Se!==null&&($=h(Se,$,ue),ie===null?te=Se:ie.sibling=Se,ie=Se);return Ae&&On(T,ue),te}for(re=l(T,re);!Se.done;ue++,Se=A.next())Se=G(re,T,ue,Se.value,H),Se!==null&&(e&&Se.alternate!==null&&re.delete(Se.key===null?ue:Se.key),$=h(Se,$,ue),ie===null?te=Se:ie.sibling=Se,ie=Se);return e&&re.forEach(function(Hp){return n(T,Hp)}),Ae&&On(T,ue),te}function Pe(T,$,A,H){if(typeof A=="object"&&A!==null&&A.type===le&&A.key===null&&(A=A.props.children),typeof A=="object"&&A!==null){switch(A.$$typeof){case Z:e:{for(var te=A.key,ie=$;ie!==null;){if(ie.key===te){if(te=A.type,te===le){if(ie.tag===7){o(T,ie.sibling),$=d(ie,A.props.children),$.return=T,T=$;break e}}else if(ie.elementType===te||typeof te=="object"&&te!==null&&te.$$typeof===ce&&wu(te)===ie.type){o(T,ie.sibling),$=d(ie,A.props),$.ref=oi(T,ie,A),$.return=T,T=$;break e}o(T,ie);break}else n(T,ie);ie=ie.sibling}A.type===le?($=Hn(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 k(T);case K:e:{for(ie=A.key;$!==null;){if($.key===ie)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}$=il(A,T.mode,H),$.return=T,T=$}return k(T);case ce:return ie=A._init,Pe(T,$,ie(A._payload),H)}if(_s(A))return X(T,$,A,H);if(F(A))return ee(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,$),$=sl(A,T.mode,H),$.return=T,T=$),k(T)):o(T,$)}return Pe}var hs=ju(!0),Su=ju(!1),mr=hn(null),pr=null,ms=null,ha=null;function ma(){ha=ms=pr=null}function pa(e){var n=mr.current;Ie(mr),e._currentValue=n}function ga(e,n,o){for(;e!==null;){var l=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),e===o)break;e=e.return}}function ps(e,n){pr=e,ha=ms=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(ut=!0),e.firstContext=null)}function Nt(e){var n=e._currentValue;if(ha!==e)if(e={context:e,memoizedValue:n,next:null},ms===null){if(pr===null)throw Error(r(308));ms=e,pr.dependencies={lanes:0,firstContext:e}}else ms=ms.next=e;return n}var Pn=null;function va(e){Pn===null?Pn=[e]:Pn.push(e)}function Nu(e,n,o,l){var d=n.interleaved;return d===null?(o.next=o,va(n)):(o.next=d.next,d.next=o),n.interleaved=o,Xt(e,l)}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 gn=!1;function ka(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Cu(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 vn(e,n,o){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,(je&2)!==0){var d=l.pending;return d===null?n.next=n:(n.next=d.next,d.next=n),l.pending=n,Xt(e,o)}return d=l.interleaved,d===null?(n.next=n,va(l)):(n.next=d.next,d.next=n),l.interleaved=n,Xt(e,o)}function gr(e,n,o){if(n=n.updateQueue,n!==null&&(n=n.shared,(o&4194240)!==0)){var l=n.lanes;l&=e.pendingLanes,o|=l,n.lanes=o,Ao(e,o)}}function $u(e,n){var o=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,o===l)){var d=null,h=null;if(o=o.firstBaseUpdate,o!==null){do{var k={eventTime:o.eventTime,lane:o.lane,tag:o.tag,payload:o.payload,callback:o.callback,next:null};h===null?d=h=k:h=h.next=k,o=o.next}while(o!==null);h===null?d=h=n:h=h.next=n}else d=h=n;o={baseState:l.baseState,firstBaseUpdate:d,lastBaseUpdate:h,shared:l.shared,effects:l.effects},e.updateQueue=o;return}e=o.lastBaseUpdate,e===null?o.firstBaseUpdate=n:e.next=n,o.lastBaseUpdate=n}function vr(e,n,o,l){var d=e.updateQueue;gn=!1;var h=d.firstBaseUpdate,k=d.lastBaseUpdate,w=d.shared.pending;if(w!==null){d.shared.pending=null;var C=w,_=C.next;C.next=null,k===null?h=_:k.next=_,k=C;var z=e.alternate;z!==null&&(z=z.updateQueue,w=z.lastBaseUpdate,w!==k&&(w===null?z.firstBaseUpdate=_:w.next=_,z.lastBaseUpdate=C))}if(h!==null){var U=d.baseState;k=0,z=_=C=null,w=h;do{var D=w.lane,G=w.eventTime;if((l&D)===D){z!==null&&(z=z.next={eventTime:G,lane:0,tag:w.tag,payload:w.payload,callback:w.callback,next:null});e:{var X=e,ee=w;switch(D=n,G=o,ee.tag){case 1:if(X=ee.payload,typeof X=="function"){U=X.call(G,U,D);break e}U=X;break e;case 3:X.flags=X.flags&-65537|128;case 0:if(X=ee.payload,D=typeof X=="function"?X.call(G,U,D):X,D==null)break e;U=W({},U,D);break e;case 2:gn=!0}}w.callback!==null&&w.lane!==0&&(e.flags|=64,D=d.effects,D===null?d.effects=[w]:D.push(w))}else G={eventTime:G,lane:D,tag:w.tag,payload:w.payload,callback:w.callback,next:null},z===null?(_=z=G,C=U):z=z.next=G,k|=D;if(w=w.next,w===null){if(w=d.shared.pending,w===null)break;D=w,w=D.next,D.next=null,d.lastBaseUpdate=D,d.shared.pending=null}}while(!0);if(z===null&&(C=U),d.baseState=C,d.firstBaseUpdate=_,d.lastBaseUpdate=z,n=d.shared.interleaved,n!==null){d=n;do k|=d.lane,d=d.next;while(d!==n)}else h===null&&(d.shared.lanes=0);Bn|=k,e.lanes=k,e.memoizedState=U}}function bu(e,n,o){if(e=n.effects,n.effects=null,e!==null)for(n=0;n<e.length;n++){var l=e[n],d=l.callback;if(d!==null){if(l.callback=null,l=o,typeof d!="function")throw Error(r(191,d));d.call(l)}}}var ai={},Bt=hn(ai),li=hn(ai),ci=hn(ai);function Dn(e){if(e===ai)throw Error(r(174));return e}function ya(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:xo(null,"");break;default:e=e===8?n.parentNode:n,n=e.namespaceURI||null,e=e.tagName,n=xo(n,e)}Ie(Bt),Ee(Bt,n)}function gs(){Ie(Bt),Ie(li),Ie(ci)}function Tu(e){Dn(ci.current);var n=Dn(Bt.current),o=xo(n,e.type);n!==o&&(Ee(li,e),Ee(Bt,o))}function xa(e){li.current===e&&(Ie(Bt),Ie(li))}var Le=hn(0);function kr(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 wa=[];function ja(){for(var e=0;e<wa.length;e++)wa[e]._workInProgressVersionPrimary=null;wa.length=0}var yr=J.ReactCurrentDispatcher,Sa=J.ReactCurrentBatchConfig,zn=0,Re=null,Fe=null,Ke=null,xr=!1,ui=!1,di=0,fp=0;function Ze(){throw Error(r(321))}function Na(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 Ca(e,n,o,l,d,h){if(zn=h,Re=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,yr.current=e===null||e.memoizedState===null?gp:vp,e=o(l,d),ui){h=0;do{if(ui=!1,di=0,25<=h)throw Error(r(301));h+=1,Ke=Fe=null,n.updateQueue=null,yr.current=kp,e=o(l,d)}while(ui)}if(yr.current=Sr,n=Fe!==null&&Fe.next!==null,zn=0,Ke=Fe=Re=null,xr=!1,n)throw Error(r(300));return e}function $a(){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 ba(e){var n=Ct(),o=n.queue;if(o===null)throw Error(r(311));o.lastRenderedReducer=e;var l=Fe,d=l.baseQueue,h=o.pending;if(h!==null){if(d!==null){var k=d.next;d.next=h.next,h.next=k}l.baseQueue=d=h,o.pending=null}if(d!==null){h=d.next,l=l.baseState;var w=k=null,C=null,_=h;do{var z=_.lane;if((zn&z)===z)C!==null&&(C=C.next={lane:0,action:_.action,hasEagerState:_.hasEagerState,eagerState:_.eagerState,next:null}),l=_.hasEagerState?_.eagerState:e(l,_.action);else{var U={lane:z,action:_.action,hasEagerState:_.hasEagerState,eagerState:_.eagerState,next:null};C===null?(w=C=U,k=l):C=C.next=U,Re.lanes|=z,Bn|=z}_=_.next}while(_!==null&&_!==h);C===null?k=l:C.next=w,It(l,n.memoizedState)||(ut=!0),n.memoizedState=l,n.baseState=k,n.baseQueue=C,o.lastRenderedState=l}if(e=o.interleaved,e!==null){d=e;do h=d.lane,Re.lanes|=h,Bn|=h,d=d.next;while(d!==e)}else d===null&&(o.lanes=0);return[n.memoizedState,o.dispatch]}function Ta(e){var n=Ct(),o=n.queue;if(o===null)throw Error(r(311));o.lastRenderedReducer=e;var l=o.dispatch,d=o.pending,h=n.memoizedState;if(d!==null){o.pending=null;var k=d=d.next;do h=e(h,k.action),k=k.next;while(k!==d);It(h,n.memoizedState)||(ut=!0),n.memoizedState=h,n.baseQueue===null&&(n.baseState=h),o.lastRenderedState=h}return[h,l]}function Eu(){}function Mu(e,n){var o=Re,l=Ct(),d=n(),h=!It(l.memoizedState,d);if(h&&(l.memoizedState=d,ut=!0),l=l.queue,Ea(Lu.bind(null,o,l,e),[e]),l.getSnapshot!==n||h||Ke!==null&&Ke.memoizedState.tag&1){if(o.flags|=2048,hi(9,Au.bind(null,o,l,d,n),void 0,null),Ve===null)throw Error(r(349));(zn&30)!==0||Iu(o,n,d)}return d}function Iu(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 Au(e,n,o,l){n.value=o,n.getSnapshot=l,Ru(n)&&_u(e)}function Lu(e,n,o){return o(function(){Ru(n)&&_u(e)})}function Ru(e){var n=e.getSnapshot;e=e.value;try{var o=n();return!It(e,o)}catch{return!0}}function _u(e){var n=Xt(e,1);n!==null&&Ot(n,e,1,-1)}function Ou(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=pp.bind(null,Re,e),[n.memoizedState,e]}function hi(e,n,o,l){return e={tag:e,create:n,destroy:o,deps:l,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:(l=o.next,o.next=e,e.next=l,n.lastEffect=e)),e}function Pu(){return Ct().memoizedState}function wr(e,n,o,l){var d=Ft();Re.flags|=e,d.memoizedState=hi(1|n,o,void 0,l===void 0?null:l)}function jr(e,n,o,l){var d=Ct();l=l===void 0?null:l;var h=void 0;if(Fe!==null){var k=Fe.memoizedState;if(h=k.destroy,l!==null&&Na(l,k.deps)){d.memoizedState=hi(n,o,h,l);return}}Re.flags|=e,d.memoizedState=hi(1|n,o,h,l)}function Du(e,n){return wr(8390656,8,e,n)}function Ea(e,n){return jr(2048,8,e,n)}function zu(e,n){return jr(4,2,e,n)}function Bu(e,n){return jr(4,4,e,n)}function Fu(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 Uu(e,n,o){return o=o!=null?o.concat([e]):null,jr(4,4,Fu.bind(null,n,e),o)}function Ma(){}function Wu(e,n){var o=Ct();n=n===void 0?null:n;var l=o.memoizedState;return l!==null&&n!==null&&Na(n,l[1])?l[0]:(o.memoizedState=[e,n],e)}function Hu(e,n){var o=Ct();n=n===void 0?null:n;var l=o.memoizedState;return l!==null&&n!==null&&Na(n,l[1])?l[0]:(e=e(),o.memoizedState=[e,n],e)}function Ku(e,n,o){return(zn&21)===0?(e.baseState&&(e.baseState=!1,ut=!0),e.memoizedState=o):(It(o,n)||(o=wc(),Re.lanes|=o,Bn|=o,e.baseState=!0),n)}function hp(e,n){var o=Ne;Ne=o!==0&&4>o?o:4,e(!0);var l=Sa.transition;Sa.transition={};try{e(!1),n()}finally{Ne=o,Sa.transition=l}}function Vu(){return Ct().memoizedState}function mp(e,n,o){var l=wn(e);if(o={lane:l,action:o,hasEagerState:!1,eagerState:null,next:null},Qu(e))qu(n,o);else if(o=Nu(e,n,o,l),o!==null){var d=ot();Ot(o,e,l,d),Gu(o,n,l)}}function pp(e,n,o){var l=wn(e),d={lane:l,action:o,hasEagerState:!1,eagerState:null,next:null};if(Qu(e))qu(n,d);else{var h=e.alternate;if(e.lanes===0&&(h===null||h.lanes===0)&&(h=n.lastRenderedReducer,h!==null))try{var k=n.lastRenderedState,w=h(k,o);if(d.hasEagerState=!0,d.eagerState=w,It(w,k)){var C=n.interleaved;C===null?(d.next=d,va(n)):(d.next=C.next,C.next=d),n.interleaved=d;return}}catch{}finally{}o=Nu(e,n,d,l),o!==null&&(d=ot(),Ot(o,e,l,d),Gu(o,n,l))}}function Qu(e){var n=e.alternate;return e===Re||n!==null&&n===Re}function qu(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 Gu(e,n,o){if((o&4194240)!==0){var l=n.lanes;l&=e.pendingLanes,o|=l,n.lanes=o,Ao(e,o)}}var Sr={readContext:Nt,useCallback:Ze,useContext:Ze,useEffect:Ze,useImperativeHandle:Ze,useInsertionEffect:Ze,useLayoutEffect:Ze,useMemo:Ze,useReducer:Ze,useRef:Ze,useState:Ze,useDebugValue:Ze,useDeferredValue:Ze,useTransition:Ze,useMutableSource:Ze,useSyncExternalStore:Ze,useId:Ze,unstable_isNewReconciler:!1},gp={readContext:Nt,useCallback:function(e,n){return Ft().memoizedState=[e,n===void 0?null:n],e},useContext:Nt,useEffect:Du,useImperativeHandle:function(e,n,o){return o=o!=null?o.concat([e]):null,wr(4194308,4,Fu.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 l=Ft();return n=o!==void 0?o(n):n,l.memoizedState=l.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},l.queue=e,e=e.dispatch=mp.bind(null,Re,e),[l.memoizedState,e]},useRef:function(e){var n=Ft();return e={current:e},n.memoizedState=e},useState:Ou,useDebugValue:Ma,useDeferredValue:function(e){return Ft().memoizedState=e},useTransition:function(){var e=Ou(!1),n=e[0];return e=hp.bind(null,e[1]),Ft().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,o){var l=Re,d=Ft();if(Ae){if(o===void 0)throw Error(r(407));o=o()}else{if(o=n(),Ve===null)throw Error(r(349));(zn&30)!==0||Iu(l,n,o)}d.memoizedState=o;var h={value:o,getSnapshot:n};return d.queue=h,Du(Lu.bind(null,l,h,e),[e]),l.flags|=2048,hi(9,Au.bind(null,l,h,o,n),void 0,null),o},useId:function(){var e=Ft(),n=Ve.identifierPrefix;if(Ae){var o=Jt,l=Yt;o=(l&~(1<<32-Mt(l)-1)).toString(32)+o,n=":"+n+"R"+o,o=di++,0<o&&(n+="H"+o.toString(32)),n+=":"}else o=fp++,n=":"+n+"r"+o.toString(32)+":";return e.memoizedState=n},unstable_isNewReconciler:!1},vp={readContext:Nt,useCallback:Wu,useContext:Nt,useEffect:Ea,useImperativeHandle:Uu,useInsertionEffect:zu,useLayoutEffect:Bu,useMemo:Hu,useReducer:ba,useRef:Pu,useState:function(){return ba(fi)},useDebugValue:Ma,useDeferredValue:function(e){var n=Ct();return Ku(n,Fe.memoizedState,e)},useTransition:function(){var e=ba(fi)[0],n=Ct().memoizedState;return[e,n]},useMutableSource:Eu,useSyncExternalStore:Mu,useId:Vu,unstable_isNewReconciler:!1},kp={readContext:Nt,useCallback:Wu,useContext:Nt,useEffect:Ea,useImperativeHandle:Uu,useInsertionEffect:zu,useLayoutEffect:Bu,useMemo:Hu,useReducer:Ta,useRef:Pu,useState:function(){return Ta(fi)},useDebugValue:Ma,useDeferredValue:function(e){var n=Ct();return Fe===null?n.memoizedState=e:Ku(n,Fe.memoizedState,e)},useTransition:function(){var e=Ta(fi)[0],n=Ct().memoizedState;return[e,n]},useMutableSource:Eu,useSyncExternalStore:Mu,useId:Vu,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 Ia(e,n,o,l){n=e.memoizedState,o=o(l,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)?An(e)===e:!1},enqueueSetState:function(e,n,o){e=e._reactInternals;var l=ot(),d=wn(e),h=Zt(l,d);h.payload=n,o!=null&&(h.callback=o),n=vn(e,h,d),n!==null&&(Ot(n,e,d,l),gr(n,e,d))},enqueueReplaceState:function(e,n,o){e=e._reactInternals;var l=ot(),d=wn(e),h=Zt(l,d);h.tag=1,h.payload=n,o!=null&&(h.callback=o),n=vn(e,h,d),n!==null&&(Ot(n,e,d,l),gr(n,e,d))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var o=ot(),l=wn(e),d=Zt(o,l);d.tag=2,n!=null&&(d.callback=n),n=vn(e,d,l),n!==null&&(Ot(n,e,l,o),gr(n,e,l))}};function Yu(e,n,o,l,d,h,k){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(l,h,k):n.prototype&&n.prototype.isPureReactComponent?!Zs(o,l)||!Zs(d,h):!0}function Ju(e,n,o){var l=!1,d=mn,h=n.contextType;return typeof h=="object"&&h!==null?h=Nt(h):(d=ct(n)?Rn:Xe.current,l=n.contextTypes,h=(l=l!=null)?cs(e,d):mn),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,l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=d,e.__reactInternalMemoizedMaskedChildContext=h),n}function Xu(e,n,o,l){e=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(o,l),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(o,l),n.state!==e&&Nr.enqueueReplaceState(n,n.state,null)}function Aa(e,n,o,l){var d=e.stateNode;d.props=o,d.state=e.memoizedState,d.refs={},ka(e);var h=n.contextType;typeof h=="object"&&h!==null?d.context=Nt(h):(h=ct(n)?Rn:Xe.current,d.context=cs(e,h)),d.state=e.memoizedState,h=n.getDerivedStateFromProps,typeof h=="function"&&(Ia(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,l),d.state=e.memoizedState),typeof d.componentDidMount=="function"&&(e.flags|=4194308)}function vs(e,n){try{var o="",l=n;do o+=ae(l),l=l.return;while(l);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 La(e,n,o){return{value:e,source:null,stack:o??null,digest:n??null}}function Ra(e,n){try{console.error(n.value)}catch(o){setTimeout(function(){throw o})}}var yp=typeof WeakMap=="function"?WeakMap:Map;function Zu(e,n,o){o=Zt(-1,o),o.tag=3,o.payload={element:null};var l=n.value;return o.callback=function(){Ir||(Ir=!0,Ga=l),Ra(e,n)},o}function ed(e,n,o){o=Zt(-1,o),o.tag=3;var l=e.type.getDerivedStateFromError;if(typeof l=="function"){var d=n.value;o.payload=function(){return l(d)},o.callback=function(){Ra(e,n)}}var h=e.stateNode;return h!==null&&typeof h.componentDidCatch=="function"&&(o.callback=function(){Ra(e,n),typeof l!="function"&&(yn===null?yn=new Set([this]):yn.add(this));var k=n.stack;this.componentDidCatch(n.value,{componentStack:k!==null?k:""})}),o}function td(e,n,o){var l=e.pingCache;if(l===null){l=e.pingCache=new yp;var d=new Set;l.set(n,d)}else d=l.get(n),d===void 0&&(d=new Set,l.set(n,d));d.has(o)||(d.add(o),e=Lp.bind(null,e,n,o),n.then(e,e))}function nd(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 sd(e,n,o,l,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,vn(o,n,1))),o.lanes|=1),e):(e.flags|=65536,e.lanes=d,e)}var xp=J.ReactCurrentOwner,ut=!1;function rt(e,n,o,l){n.child=e===null?Su(n,null,o,l):hs(n,e.child,o,l)}function id(e,n,o,l,d){o=o.render;var h=n.ref;return ps(n,d),l=Ca(e,n,o,l,h,d),o=$a(),e!==null&&!ut?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~d,en(e,n,d)):(Ae&&o&&la(n),n.flags|=1,rt(e,n,l,d),n.child)}function rd(e,n,o,l,d){if(e===null){var h=o.type;return typeof h=="function"&&!nl(h)&&h.defaultProps===void 0&&o.compare===null&&o.defaultProps===void 0?(n.tag=15,n.type=h,od(e,n,h,l,d)):(e=Pr(o.type,null,l,n,n.mode,d),e.ref=n.ref,e.return=n,n.child=e)}if(h=e.child,(e.lanes&d)===0){var k=h.memoizedProps;if(o=o.compare,o=o!==null?o:Zs,o(k,l)&&e.ref===n.ref)return en(e,n,d)}return n.flags|=1,e=Sn(h,l),e.ref=n.ref,e.return=n,n.child=e}function od(e,n,o,l,d){if(e!==null){var h=e.memoizedProps;if(Zs(h,l)&&e.ref===n.ref)if(ut=!1,n.pendingProps=l=h,(e.lanes&d)!==0)(e.flags&131072)!==0&&(ut=!0);else return n.lanes=e.lanes,en(e,n,d)}return _a(e,n,o,l,d)}function ad(e,n,o){var l=n.pendingProps,d=l.children,h=e!==null?e.memoizedState:null;if(l.mode==="hidden")if((n.mode&1)===0)n.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ee(ys,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(ys,xt),xt|=e,null;n.memoizedState={baseLanes:0,cachePool:null,transitions:null},l=h!==null?h.baseLanes:o,Ee(ys,xt),xt|=l}else h!==null?(l=h.baseLanes|o,n.memoizedState=null):l=o,Ee(ys,xt),xt|=l;return rt(e,n,d,o),n.child}function ld(e,n){var o=n.ref;(e===null&&o!==null||e!==null&&e.ref!==o)&&(n.flags|=512,n.flags|=2097152)}function _a(e,n,o,l,d){var h=ct(o)?Rn:Xe.current;return h=cs(n,h),ps(n,d),o=Ca(e,n,o,l,h,d),l=$a(),e!==null&&!ut?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~d,en(e,n,d)):(Ae&&l&&la(n),n.flags|=1,rt(e,n,o,d),n.child)}function cd(e,n,o,l,d){if(ct(o)){var h=!0;lr(n)}else h=!1;if(ps(n,d),n.stateNode===null)$r(e,n),Ju(n,o,l),Aa(n,o,l,d),l=!0;else if(e===null){var k=n.stateNode,w=n.memoizedProps;k.props=w;var C=k.context,_=o.contextType;typeof _=="object"&&_!==null?_=Nt(_):(_=ct(o)?Rn:Xe.current,_=cs(n,_));var z=o.getDerivedStateFromProps,U=typeof z=="function"||typeof k.getSnapshotBeforeUpdate=="function";U||typeof k.UNSAFE_componentWillReceiveProps!="function"&&typeof k.componentWillReceiveProps!="function"||(w!==l||C!==_)&&Xu(n,k,l,_),gn=!1;var D=n.memoizedState;k.state=D,vr(n,l,k,d),C=n.memoizedState,w!==l||D!==C||lt.current||gn?(typeof z=="function"&&(Ia(n,o,z,l),C=n.memoizedState),(w=gn||Yu(n,o,w,l,D,C,_))?(U||typeof k.UNSAFE_componentWillMount!="function"&&typeof k.componentWillMount!="function"||(typeof k.componentWillMount=="function"&&k.componentWillMount(),typeof k.UNSAFE_componentWillMount=="function"&&k.UNSAFE_componentWillMount()),typeof k.componentDidMount=="function"&&(n.flags|=4194308)):(typeof k.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=l,n.memoizedState=C),k.props=l,k.state=C,k.context=_,l=w):(typeof k.componentDidMount=="function"&&(n.flags|=4194308),l=!1)}else{k=n.stateNode,Cu(e,n),w=n.memoizedProps,_=n.type===n.elementType?w:Lt(n.type,w),k.props=_,U=n.pendingProps,D=k.context,C=o.contextType,typeof C=="object"&&C!==null?C=Nt(C):(C=ct(o)?Rn:Xe.current,C=cs(n,C));var G=o.getDerivedStateFromProps;(z=typeof G=="function"||typeof k.getSnapshotBeforeUpdate=="function")||typeof k.UNSAFE_componentWillReceiveProps!="function"&&typeof k.componentWillReceiveProps!="function"||(w!==U||D!==C)&&Xu(n,k,l,C),gn=!1,D=n.memoizedState,k.state=D,vr(n,l,k,d);var X=n.memoizedState;w!==U||D!==X||lt.current||gn?(typeof G=="function"&&(Ia(n,o,G,l),X=n.memoizedState),(_=gn||Yu(n,o,_,l,D,X,C)||!1)?(z||typeof k.UNSAFE_componentWillUpdate!="function"&&typeof k.componentWillUpdate!="function"||(typeof k.componentWillUpdate=="function"&&k.componentWillUpdate(l,X,C),typeof k.UNSAFE_componentWillUpdate=="function"&&k.UNSAFE_componentWillUpdate(l,X,C)),typeof k.componentDidUpdate=="function"&&(n.flags|=4),typeof k.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof k.componentDidUpdate!="function"||w===e.memoizedProps&&D===e.memoizedState||(n.flags|=4),typeof k.getSnapshotBeforeUpdate!="function"||w===e.memoizedProps&&D===e.memoizedState||(n.flags|=1024),n.memoizedProps=l,n.memoizedState=X),k.props=l,k.state=X,k.context=C,l=_):(typeof k.componentDidUpdate!="function"||w===e.memoizedProps&&D===e.memoizedState||(n.flags|=4),typeof k.getSnapshotBeforeUpdate!="function"||w===e.memoizedProps&&D===e.memoizedState||(n.flags|=1024),l=!1)}return Oa(e,n,o,l,h,d)}function Oa(e,n,o,l,d,h){ld(e,n);var k=(n.flags&128)!==0;if(!l&&!k)return d&&mu(n,o,!1),en(e,n,h);l=n.stateNode,xp.current=n;var w=k&&typeof o.getDerivedStateFromError!="function"?null:l.render();return n.flags|=1,e!==null&&k?(n.child=hs(n,e.child,null,h),n.child=hs(n,null,w,h)):rt(e,n,w,h),n.memoizedState=l.state,d&&mu(n,o,!0),n.child}function ud(e){var n=e.stateNode;n.pendingContext?fu(e,n.pendingContext,n.pendingContext!==n.context):n.context&&fu(e,n.context,!1),ya(e,n.containerInfo)}function dd(e,n,o,l,d){return fs(),fa(d),n.flags|=256,rt(e,n,o,l),n.child}var Pa={dehydrated:null,treeContext:null,retryLane:0};function Da(e){return{baseLanes:e,cachePool:null,transitions:null}}function fd(e,n,o){var l=n.pendingProps,d=Le.current,h=!1,k=(n.flags&128)!==0,w;if((w=k)||(w=e!==null&&e.memoizedState===null?!1:(d&2)!==0),w?(h=!0,n.flags&=-129):(e===null||e.memoizedState!==null)&&(d|=1),Ee(Le,d&1),e===null)return da(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):(k=l.children,e=l.fallback,h?(l=n.mode,h=n.child,k={mode:"hidden",children:k},(l&1)===0&&h!==null?(h.childLanes=0,h.pendingProps=k):h=Dr(k,l,0,null),e=Hn(e,l,o,null),h.return=n,e.return=n,h.sibling=e,n.child=h,n.child.memoizedState=Da(o),n.memoizedState=Pa,e):za(n,k));if(d=e.memoizedState,d!==null&&(w=d.dehydrated,w!==null))return wp(e,n,k,l,w,d,o);if(h){h=l.fallback,k=n.mode,d=e.child,w=d.sibling;var C={mode:"hidden",children:l.children};return(k&1)===0&&n.child!==d?(l=n.child,l.childLanes=0,l.pendingProps=C,n.deletions=null):(l=Sn(d,C),l.subtreeFlags=d.subtreeFlags&14680064),w!==null?h=Sn(w,h):(h=Hn(h,k,o,null),h.flags|=2),h.return=n,l.return=n,l.sibling=h,n.child=l,l=h,h=n.child,k=e.child.memoizedState,k=k===null?Da(o):{baseLanes:k.baseLanes|o,cachePool:null,transitions:k.transitions},h.memoizedState=k,h.childLanes=e.childLanes&~o,n.memoizedState=Pa,l}return h=e.child,e=h.sibling,l=Sn(h,{mode:"visible",children:l.children}),(n.mode&1)===0&&(l.lanes=o),l.return=n,l.sibling=null,e!==null&&(o=n.deletions,o===null?(n.deletions=[e],n.flags|=16):o.push(e)),n.child=l,n.memoizedState=null,l}function za(e,n){return n=Dr({mode:"visible",children:n},e.mode,0,null),n.return=e,e.child=n}function Cr(e,n,o,l){return l!==null&&fa(l),hs(n,e.child,null,o),e=za(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function wp(e,n,o,l,d,h,k){if(o)return n.flags&256?(n.flags&=-257,l=La(Error(r(422))),Cr(e,n,k,l)):n.memoizedState!==null?(n.child=e.child,n.flags|=128,null):(h=l.fallback,d=n.mode,l=Dr({mode:"visible",children:l.children},d,0,null),h=Hn(h,d,k,null),h.flags|=2,l.return=n,h.return=n,l.sibling=h,n.child=l,(n.mode&1)!==0&&hs(n,e.child,null,k),n.child.memoizedState=Da(k),n.memoizedState=Pa,h);if((n.mode&1)===0)return Cr(e,n,k,null);if(d.data==="$!"){if(l=d.nextSibling&&d.nextSibling.dataset,l)var w=l.dgst;return l=w,h=Error(r(419)),l=La(h,l,void 0),Cr(e,n,k,l)}if(w=(k&e.childLanes)!==0,ut||w){if(l=Ve,l!==null){switch(k&-k){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&(l.suspendedLanes|k))!==0?0:d,d!==0&&d!==h.retryLane&&(h.retryLane=d,Xt(e,d),Ot(l,e,d,-1))}return tl(),l=La(Error(r(421))),Cr(e,n,k,l)}return d.data==="$?"?(n.flags|=128,n.child=e.child,n=Rp.bind(null,e),d._reactRetry=n,null):(e=h.treeContext,yt=fn(d.nextSibling),kt=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=za(n,l.children),n.flags|=4096,n)}function hd(e,n,o){e.lanes|=n;var l=e.alternate;l!==null&&(l.lanes|=n),ga(e.return,n,o)}function Ba(e,n,o,l,d){var h=e.memoizedState;h===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:l,tail:o,tailMode:d}:(h.isBackwards=n,h.rendering=null,h.renderingStartTime=0,h.last=l,h.tail=o,h.tailMode=d)}function md(e,n,o){var l=n.pendingProps,d=l.revealOrder,h=l.tail;if(rt(e,n,l.children,o),l=Le.current,(l&2)!==0)l=l&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&&hd(e,o,n);else if(e.tag===19)hd(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}l&=1}if(Ee(Le,l),(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&&kr(e)===null&&(d=o),o=o.sibling;o=d,o===null?(d=n.child,n.child=null):(d=o.sibling,o.sibling=null),Ba(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&&kr(e)===null){n.child=d;break}e=d.sibling,d.sibling=o,o=d,d=e}Ba(n,!0,o,null,h);break;case"together":Ba(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),Bn|=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=Sn(e,e.pendingProps),n.child=o,o.return=n;e.sibling!==null;)e=e.sibling,o=o.sibling=Sn(e,e.pendingProps),o.return=n;o.sibling=null}return n.child}function jp(e,n,o){switch(n.tag){case 3:ud(n),fs();break;case 5:Tu(n);break;case 1:ct(n.type)&&lr(n);break;case 4:ya(n,n.stateNode.containerInfo);break;case 10:var l=n.type._context,d=n.memoizedProps.value;Ee(mr,l._currentValue),l._currentValue=d;break;case 13:if(l=n.memoizedState,l!==null)return l.dehydrated!==null?(Ee(Le,Le.current&1),n.flags|=128,null):(o&n.child.childLanes)!==0?fd(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(l=(o&n.childLanes)!==0,(e.flags&128)!==0){if(l)return md(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),l)break;return null;case 22:case 23:return n.lanes=0,ad(e,n,o)}return en(e,n,o)}var pd,Fa,gd,vd;pd=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}},Fa=function(){},gd=function(e,n,o,l){var d=e.memoizedProps;if(d!==l){e=n.stateNode,Dn(Bt.current);var h=null;switch(o){case"input":d=go(e,d),l=go(e,l),h=[];break;case"select":d=W({},d,{value:void 0}),l=W({},l,{value:void 0}),h=[];break;case"textarea":d=yo(e,d),l=yo(e,l),h=[];break;default:typeof d.onClick!="function"&&typeof l.onClick=="function"&&(e.onclick=rr)}wo(o,l);var k;o=null;for(_ in d)if(!l.hasOwnProperty(_)&&d.hasOwnProperty(_)&&d[_]!=null)if(_==="style"){var w=d[_];for(k in w)w.hasOwnProperty(k)&&(o||(o={}),o[k]="")}else _!=="dangerouslySetInnerHTML"&&_!=="children"&&_!=="suppressContentEditableWarning"&&_!=="suppressHydrationWarning"&&_!=="autoFocus"&&(c.hasOwnProperty(_)?h||(h=[]):(h=h||[]).push(_,null));for(_ in l){var C=l[_];if(w=d!=null?d[_]:void 0,l.hasOwnProperty(_)&&C!==w&&(C!=null||w!=null))if(_==="style")if(w){for(k in w)!w.hasOwnProperty(k)||C&&C.hasOwnProperty(k)||(o||(o={}),o[k]="");for(k in C)C.hasOwnProperty(k)&&w[k]!==C[k]&&(o||(o={}),o[k]=C[k])}else o||(h||(h=[]),h.push(_,o)),o=C;else _==="dangerouslySetInnerHTML"?(C=C?C.__html:void 0,w=w?w.__html:void 0,C!=null&&w!==C&&(h=h||[]).push(_,C)):_==="children"?typeof C!="string"&&typeof C!="number"||(h=h||[]).push(_,""+C):_!=="suppressContentEditableWarning"&&_!=="suppressHydrationWarning"&&(c.hasOwnProperty(_)?(C!=null&&_==="onScroll"&&Me("scroll",e),h||w===C||(h=[])):(h=h||[]).push(_,C))}o&&(h=h||[]).push("style",o);var _=h;(n.updateQueue=_)&&(n.flags|=4)}},vd=function(e,n,o,l){o!==l&&(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 l=null;o!==null;)o.alternate!==null&&(l=o),o=o.sibling;l===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:l.sibling=null}}function et(e){var n=e.alternate!==null&&e.alternate.child===e.child,o=0,l=0;if(n)for(var d=e.child;d!==null;)o|=d.lanes|d.childLanes,l|=d.subtreeFlags&14680064,l|=d.flags&14680064,d.return=e,d=d.sibling;else for(d=e.child;d!==null;)o|=d.lanes|d.childLanes,l|=d.subtreeFlags,l|=d.flags,d.return=e,d=d.sibling;return e.subtreeFlags|=l,e.childLanes=o,n}function Sp(e,n,o){var l=n.pendingProps;switch(ca(n),n.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return et(n),null;case 1:return ct(n.type)&&ar(),et(n),null;case 3:return l=n.stateNode,gs(),Ie(lt),Ie(Xe),ja(),l.pendingContext&&(l.context=l.pendingContext,l.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&&(Xa(At),At=null))),Fa(e,n),et(n),null;case 5:xa(n);var d=Dn(ci.current);if(o=n.type,e!==null&&n.stateNode!=null)gd(e,n,o,l,d),e.ref!==n.ref&&(n.flags|=512,n.flags|=2097152);else{if(!l){if(n.stateNode===null)throw Error(r(166));return et(n),null}if(e=Dn(Bt.current),fr(n)){l=n.stateNode,o=n.type;var h=n.memoizedProps;switch(l[zt]=n,l[ii]=h,e=(n.mode&1)!==0,o){case"dialog":Me("cancel",l),Me("close",l);break;case"iframe":case"object":case"embed":Me("load",l);break;case"video":case"audio":for(d=0;d<ti.length;d++)Me(ti[d],l);break;case"source":Me("error",l);break;case"img":case"image":case"link":Me("error",l),Me("load",l);break;case"details":Me("toggle",l);break;case"input":Jl(l,h),Me("invalid",l);break;case"select":l._wrapperState={wasMultiple:!!h.multiple},Me("invalid",l);break;case"textarea":ec(l,h),Me("invalid",l)}wo(o,h),d=null;for(var k in h)if(h.hasOwnProperty(k)){var w=h[k];k==="children"?typeof w=="string"?l.textContent!==w&&(h.suppressHydrationWarning!==!0&&ir(l.textContent,w,e),d=["children",w]):typeof w=="number"&&l.textContent!==""+w&&(h.suppressHydrationWarning!==!0&&ir(l.textContent,w,e),d=["children",""+w]):c.hasOwnProperty(k)&&w!=null&&k==="onScroll"&&Me("scroll",l)}switch(o){case"input":Yn(l),Zl(l,h,!0);break;case"textarea":Yn(l),nc(l);break;case"select":case"option":break;default:typeof h.onClick=="function"&&(l.onclick=rr)}l=d,n.updateQueue=l,l!==null&&(n.flags|=4)}else{k=d.nodeType===9?d:d.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=sc(o)),e==="http://www.w3.org/1999/xhtml"?o==="script"?(e=k.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=k.createElement(o,{is:l.is}):(e=k.createElement(o),o==="select"&&(k=e,l.multiple?k.multiple=!0:l.size&&(k.size=l.size))):e=k.createElementNS(e,o),e[zt]=n,e[ii]=l,pd(e,n,!1,!1),n.stateNode=e;e:{switch(k=jo(o,l),o){case"dialog":Me("cancel",e),Me("close",e),d=l;break;case"iframe":case"object":case"embed":Me("load",e),d=l;break;case"video":case"audio":for(d=0;d<ti.length;d++)Me(ti[d],e);d=l;break;case"source":Me("error",e),d=l;break;case"img":case"image":case"link":Me("error",e),Me("load",e),d=l;break;case"details":Me("toggle",e),d=l;break;case"input":Jl(e,l),d=go(e,l),Me("invalid",e);break;case"option":d=l;break;case"select":e._wrapperState={wasMultiple:!!l.multiple},d=W({},l,{value:void 0}),Me("invalid",e);break;case"textarea":ec(e,l),d=yo(e,l),Me("invalid",e);break;default:d=l}wo(o,d),w=d;for(h in w)if(w.hasOwnProperty(h)){var C=w[h];h==="style"?oc(e,C):h==="dangerouslySetInnerHTML"?(C=C?C.__html:void 0,C!=null&&ic(e,C)):h==="children"?typeof C=="string"?(o!=="textarea"||C!=="")&&Os(e,C):typeof C=="number"&&Os(e,""+C):h!=="suppressContentEditableWarning"&&h!=="suppressHydrationWarning"&&h!=="autoFocus"&&(c.hasOwnProperty(h)?C!=null&&h==="onScroll"&&Me("scroll",e):C!=null&&L(e,h,C,k))}switch(o){case"input":Yn(e),Zl(e,l,!1);break;case"textarea":Yn(e),nc(e);break;case"option":l.value!=null&&e.setAttribute("value",""+ve(l.value));break;case"select":e.multiple=!!l.multiple,h=l.value,h!=null?Jn(e,!!l.multiple,h,!1):l.defaultValue!=null&&Jn(e,!!l.multiple,l.defaultValue,!0);break;default:typeof d.onClick=="function"&&(e.onclick=rr)}switch(o){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}}l&&(n.flags|=4)}n.ref!==null&&(n.flags|=512,n.flags|=2097152)}return et(n),null;case 6:if(e&&n.stateNode!=null)vd(e,n,e.memoizedProps,l);else{if(typeof l!="string"&&n.stateNode===null)throw Error(r(166));if(o=Dn(ci.current),Dn(Bt.current),fr(n)){if(l=n.stateNode,o=n.memoizedProps,l[zt]=n,(h=l.nodeValue!==o)&&(e=kt,e!==null))switch(e.tag){case 3:ir(l.nodeValue,o,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&ir(l.nodeValue,o,(e.mode&1)!==0)}h&&(n.flags|=4)}else l=(o.nodeType===9?o:o.ownerDocument).createTextNode(l),l[zt]=n,n.stateNode=l}return et(n),null;case 13:if(Ie(Le),l=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Ae&&yt!==null&&(n.mode&1)!==0&&(n.flags&128)===0)xu(),fs(),n.flags|=98560,h=!1;else if(h=fr(n),l!==null&&l.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 fs(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;et(n),h=!1}else At!==null&&(Xa(At),At=null),h=!0;if(!h)return n.flags&65536?n:null}return(n.flags&128)!==0?(n.lanes=o,n):(l=l!==null,l!==(e!==null&&e.memoizedState!==null)&&l&&(n.child.flags|=8192,(n.mode&1)!==0&&(e===null||(Le.current&1)!==0?Ue===0&&(Ue=3):tl())),n.updateQueue!==null&&(n.flags|=4),et(n),null);case 4:return gs(),Fa(e,n),e===null&&ni(n.stateNode.containerInfo),et(n),null;case 10:return pa(n.type._context),et(n),null;case 17:return ct(n.type)&&ar(),et(n),null;case 19:if(Ie(Le),h=n.memoizedState,h===null)return et(n),null;if(l=(n.flags&128)!==0,k=h.rendering,k===null)if(l)mi(h,!1);else{if(Ue!==0||e!==null&&(e.flags&128)!==0)for(e=n.child;e!==null;){if(k=kr(e),k!==null){for(n.flags|=128,mi(h,!1),l=k.updateQueue,l!==null&&(n.updateQueue=l,n.flags|=4),n.subtreeFlags=0,l=o,o=n.child;o!==null;)h=o,e=l,h.flags&=14680066,k=h.alternate,k===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=k.childLanes,h.lanes=k.lanes,h.child=k.child,h.subtreeFlags=0,h.deletions=null,h.memoizedProps=k.memoizedProps,h.memoizedState=k.memoizedState,h.updateQueue=k.updateQueue,h.type=k.type,e=k.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&&Oe()>xs&&(n.flags|=128,l=!0,mi(h,!1),n.lanes=4194304)}else{if(!l)if(e=kr(k),e!==null){if(n.flags|=128,l=!0,o=e.updateQueue,o!==null&&(n.updateQueue=o,n.flags|=4),mi(h,!0),h.tail===null&&h.tailMode==="hidden"&&!k.alternate&&!Ae)return et(n),null}else 2*Oe()-h.renderingStartTime>xs&&o!==1073741824&&(n.flags|=128,l=!0,mi(h,!1),n.lanes=4194304);h.isBackwards?(k.sibling=n.child,n.child=k):(o=h.last,o!==null?o.sibling=k:n.child=k,h.last=k)}return h.tail!==null?(n=h.tail,h.rendering=n,h.tail=n.sibling,h.renderingStartTime=Oe(),n.sibling=null,o=Le.current,Ee(Le,l?o&1|2:o&1),n):(et(n),null);case 22:case 23:return el(),l=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(n.flags|=8192),l&&(n.mode&1)!==0?(xt&1073741824)!==0&&(et(n),n.subtreeFlags&6&&(n.flags|=8192)):et(n),null;case 24:return null;case 25:return null}throw Error(r(156,n.tag))}function Np(e,n){switch(ca(n),n.tag){case 1:return ct(n.type)&&ar(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return gs(),Ie(lt),Ie(Xe),ja(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return xa(n),null;case 13:if(Ie(Le),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(r(340));fs()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Ie(Le),null;case 4:return gs(),null;case 10:return pa(n.type._context),null;case 22:case 23:return el(),null;case 24:return null;default:return null}}var br=!1,tt=!1,Cp=typeof WeakSet=="function"?WeakSet:Set,Y=null;function ks(e,n){var o=e.ref;if(o!==null)if(typeof o=="function")try{o(null)}catch(l){_e(e,n,l)}else o.current=null}function Ua(e,n,o){try{o()}catch(l){_e(e,n,l)}}var kd=!1;function $p(e,n){if(ea=Qi,e=Yc(),Vo(e)){if("selectionStart"in e)var o={start:e.selectionStart,end:e.selectionEnd};else e:{o=(o=e.ownerDocument)&&o.defaultView||window;var l=o.getSelection&&o.getSelection();if(l&&l.rangeCount!==0){o=l.anchorNode;var d=l.anchorOffset,h=l.focusNode;l=l.focusOffset;try{o.nodeType,h.nodeType}catch{o=null;break e}var k=0,w=-1,C=-1,_=0,z=0,U=e,D=null;t:for(;;){for(var G;U!==o||d!==0&&U.nodeType!==3||(w=k+d),U!==h||l!==0&&U.nodeType!==3||(C=k+l),U.nodeType===3&&(k+=U.nodeValue.length),(G=U.firstChild)!==null;)D=U,U=G;for(;;){if(U===e)break t;if(D===o&&++_===d&&(w=k),D===h&&++z===l&&(C=k),(G=U.nextSibling)!==null)break;U=D,D=U.parentNode}U=G}o=w===-1||C===-1?null:{start:w,end:C}}else o=null}o=o||{start:0,end:0}}else o=null;for(ta={focusedElem:e,selectionRange:o},Qi=!1,Y=n;Y!==null;)if(n=Y,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,Y=e;else for(;Y!==null;){n=Y;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 ee=X.memoizedProps,Pe=X.memoizedState,T=n.stateNode,$=T.getSnapshotBeforeUpdate(n.elementType===n.type?ee:Lt(n.type,ee),Pe);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){_e(n,n.return,H)}if(e=n.sibling,e!==null){e.return=n.return,Y=e;break}Y=n.return}return X=kd,kd=!1,X}function pi(e,n,o){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var d=l=l.next;do{if((d.tag&e)===e){var h=d.destroy;d.destroy=void 0,h!==void 0&&Ua(n,o,h)}d=d.next}while(d!==l)}}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 l=o.create;o.destroy=l()}o=o.next}while(o!==n)}}function Wa(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 yd(e){var n=e.alternate;n!==null&&(e.alternate=null,yd(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[ra],delete n[lp],delete n[cp])),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 xd(e){return e.tag===5||e.tag===3||e.tag===4}function wd(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||xd(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 Ha(e,n,o){var l=e.tag;if(l===5||l===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(l!==4&&(e=e.child,e!==null))for(Ha(e,n,o),e=e.sibling;e!==null;)Ha(e,n,o),e=e.sibling}function Ka(e,n,o){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?o.insertBefore(e,n):o.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(Ka(e,n,o),e=e.sibling;e!==null;)Ka(e,n,o),e=e.sibling}var Ye=null,Rt=!1;function kn(e,n,o){for(o=o.child;o!==null;)jd(e,n,o),o=o.sibling}function jd(e,n,o){if(Dt&&typeof Dt.onCommitFiberUnmount=="function")try{Dt.onCommitFiberUnmount(Fi,o)}catch{}switch(o.tag){case 5:tt||ks(o,n);case 6:var l=Ye,d=Rt;Ye=null,kn(e,n,o),Ye=l,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?ia(e.parentNode,o):e.nodeType===1&&ia(e,o),Qs(e)):ia(Ye,o.stateNode));break;case 4:l=Ye,d=Rt,Ye=o.stateNode.containerInfo,Rt=!0,kn(e,n,o),Ye=l,Rt=d;break;case 0:case 11:case 14:case 15:if(!tt&&(l=o.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){d=l=l.next;do{var h=d,k=h.destroy;h=h.tag,k!==void 0&&((h&2)!==0||(h&4)!==0)&&Ua(o,n,k),d=d.next}while(d!==l)}kn(e,n,o);break;case 1:if(!tt&&(ks(o,n),l=o.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=o.memoizedProps,l.state=o.memoizedState,l.componentWillUnmount()}catch(w){_e(o,n,w)}kn(e,n,o);break;case 21:kn(e,n,o);break;case 22:o.mode&1?(tt=(l=tt)||o.memoizedState!==null,kn(e,n,o),tt=l):kn(e,n,o);break;default:kn(e,n,o)}}function Sd(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var o=e.stateNode;o===null&&(o=e.stateNode=new Cp),n.forEach(function(l){var d=_p.bind(null,e,l);o.has(l)||(o.add(l),l.then(d,d))})}}function _t(e,n){var o=n.deletions;if(o!==null)for(var l=0;l<o.length;l++){var d=o[l];try{var h=e,k=n,w=k;e:for(;w!==null;){switch(w.tag){case 5:Ye=w.stateNode,Rt=!1;break e;case 3:Ye=w.stateNode.containerInfo,Rt=!0;break e;case 4:Ye=w.stateNode.containerInfo,Rt=!0;break e}w=w.return}if(Ye===null)throw Error(r(160));jd(h,k,d),Ye=null,Rt=!1;var C=d.alternate;C!==null&&(C.return=null),d.return=null}catch(_){_e(d,n,_)}}if(n.subtreeFlags&12854)for(n=n.child;n!==null;)Nd(n,e),n=n.sibling}function Nd(e,n){var o=e.alternate,l=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(_t(n,e),Ut(e),l&4){try{pi(3,e,e.return),Tr(3,e)}catch(ee){_e(e,e.return,ee)}try{pi(5,e,e.return)}catch(ee){_e(e,e.return,ee)}}break;case 1:_t(n,e),Ut(e),l&512&&o!==null&&ks(o,o.return);break;case 5:if(_t(n,e),Ut(e),l&512&&o!==null&&ks(o,o.return),e.flags&32){var d=e.stateNode;try{Os(d,"")}catch(ee){_e(e,e.return,ee)}}if(l&4&&(d=e.stateNode,d!=null)){var h=e.memoizedProps,k=o!==null?o.memoizedProps:h,w=e.type,C=e.updateQueue;if(e.updateQueue=null,C!==null)try{w==="input"&&h.type==="radio"&&h.name!=null&&Xl(d,h),jo(w,k);var _=jo(w,h);for(k=0;k<C.length;k+=2){var z=C[k],U=C[k+1];z==="style"?oc(d,U):z==="dangerouslySetInnerHTML"?ic(d,U):z==="children"?Os(d,U):L(d,z,U,_)}switch(w){case"input":vo(d,h);break;case"textarea":tc(d,h);break;case"select":var D=d._wrapperState.wasMultiple;d._wrapperState.wasMultiple=!!h.multiple;var G=h.value;G!=null?Jn(d,!!h.multiple,G,!1):D!==!!h.multiple&&(h.defaultValue!=null?Jn(d,!!h.multiple,h.defaultValue,!0):Jn(d,!!h.multiple,h.multiple?[]:"",!1))}d[ii]=h}catch(ee){_e(e,e.return,ee)}}break;case 6:if(_t(n,e),Ut(e),l&4){if(e.stateNode===null)throw Error(r(162));d=e.stateNode,h=e.memoizedProps;try{d.nodeValue=h}catch(ee){_e(e,e.return,ee)}}break;case 3:if(_t(n,e),Ut(e),l&4&&o!==null&&o.memoizedState.isDehydrated)try{Qs(n.containerInfo)}catch(ee){_e(e,e.return,ee)}break;case 4:_t(n,e),Ut(e);break;case 13:_t(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||(qa=Oe())),l&4&&Sd(e);break;case 22:if(z=o!==null&&o.memoizedState!==null,e.mode&1?(tt=(_=tt)||z,_t(n,e),tt=_):_t(n,e),Ut(e),l&8192){if(_=e.memoizedState!==null,(e.stateNode.isHidden=_)&&!z&&(e.mode&1)!==0)for(Y=e,z=e.child;z!==null;){for(U=Y=z;Y!==null;){switch(D=Y,G=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"){l=D,o=D.return;try{n=l,X.props=n.memoizedProps,X.state=n.memoizedState,X.componentWillUnmount()}catch(ee){_e(l,o,ee)}}break;case 5:ks(D,D.return);break;case 22:if(D.memoizedState!==null){bd(U);continue}}G!==null?(G.return=D,Y=G):bd(U)}z=z.sibling}e:for(z=null,U=e;;){if(U.tag===5){if(z===null){z=U;try{d=U.stateNode,_?(h=d.style,typeof h.setProperty=="function"?h.setProperty("display","none","important"):h.display="none"):(w=U.stateNode,C=U.memoizedProps.style,k=C!=null&&C.hasOwnProperty("display")?C.display:null,w.style.display=rc("display",k))}catch(ee){_e(e,e.return,ee)}}}else if(U.tag===6){if(z===null)try{U.stateNode.nodeValue=_?"":U.memoizedProps}catch(ee){_e(e,e.return,ee)}}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:_t(n,e),Ut(e),l&4&&Sd(e);break;case 21:break;default:_t(n,e),Ut(e)}}function Ut(e){var n=e.flags;if(n&2){try{e:{for(var o=e.return;o!==null;){if(xd(o)){var l=o;break e}o=o.return}throw Error(r(160))}switch(l.tag){case 5:var d=l.stateNode;l.flags&32&&(Os(d,""),l.flags&=-33);var h=wd(e);Ka(e,h,d);break;case 3:case 4:var k=l.stateNode.containerInfo,w=wd(e);Ha(e,w,k);break;default:throw Error(r(161))}}catch(C){_e(e,e.return,C)}e.flags&=-3}n&4096&&(e.flags&=-4097)}function bp(e,n,o){Y=e,Cd(e)}function Cd(e,n,o){for(var l=(e.mode&1)!==0;Y!==null;){var d=Y,h=d.child;if(d.tag===22&&l){var k=d.memoizedState!==null||br;if(!k){var w=d.alternate,C=w!==null&&w.memoizedState!==null||tt;w=br;var _=tt;if(br=k,(tt=C)&&!_)for(Y=d;Y!==null;)k=Y,C=k.child,k.tag===22&&k.memoizedState!==null?Td(d):C!==null?(C.return=k,Y=C):Td(d);for(;h!==null;)Y=h,Cd(h),h=h.sibling;Y=d,br=w,tt=_}$d(e)}else(d.subtreeFlags&8772)!==0&&h!==null?(h.return=d,Y=h):$d(e)}}function $d(e){for(;Y!==null;){var n=Y;if((n.flags&8772)!==0){var o=n.alternate;try{if((n.flags&8772)!==0)switch(n.tag){case 0:case 11:case 15:tt||Tr(5,n);break;case 1:var l=n.stateNode;if(n.flags&4&&!tt)if(o===null)l.componentDidMount();else{var d=n.elementType===n.type?o.memoizedProps:Lt(n.type,o.memoizedProps);l.componentDidUpdate(d,o.memoizedState,l.__reactInternalSnapshotBeforeUpdate)}var h=n.updateQueue;h!==null&&bu(n,h,l);break;case 3:var k=n.updateQueue;if(k!==null){if(o=null,n.child!==null)switch(n.child.tag){case 5:o=n.child.stateNode;break;case 1:o=n.child.stateNode}bu(n,k,o)}break;case 5:var w=n.stateNode;if(o===null&&n.flags&4){o=w;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 _=n.alternate;if(_!==null){var z=_.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))}tt||n.flags&512&&Wa(n)}catch(D){_e(n,n.return,D)}}if(n===e){Y=null;break}if(o=n.sibling,o!==null){o.return=n.return,Y=o;break}Y=n.return}}function bd(e){for(;Y!==null;){var n=Y;if(n===e){Y=null;break}var o=n.sibling;if(o!==null){o.return=n.return,Y=o;break}Y=n.return}}function Td(e){for(;Y!==null;){var n=Y;try{switch(n.tag){case 0:case 11:case 15:var o=n.return;try{Tr(4,n)}catch(C){_e(n,o,C)}break;case 1:var l=n.stateNode;if(typeof l.componentDidMount=="function"){var d=n.return;try{l.componentDidMount()}catch(C){_e(n,d,C)}}var h=n.return;try{Wa(n)}catch(C){_e(n,h,C)}break;case 5:var k=n.return;try{Wa(n)}catch(C){_e(n,k,C)}}}catch(C){_e(n,n.return,C)}if(n===e){Y=null;break}var w=n.sibling;if(w!==null){w.return=n.return,Y=w;break}Y=n.return}}var Tp=Math.ceil,Er=J.ReactCurrentDispatcher,Va=J.ReactCurrentOwner,$t=J.ReactCurrentBatchConfig,je=0,Ve=null,ze=null,Je=0,xt=0,ys=hn(0),Ue=0,gi=null,Bn=0,Mr=0,Qa=0,vi=null,dt=null,qa=0,xs=1/0,tn=null,Ir=!1,Ga=null,yn=null,Ar=!1,xn=null,Lr=0,ki=0,Ya=null,Rr=-1,_r=0;function ot(){return(je&6)!==0?Oe():Rr!==-1?Rr:Rr=Oe()}function wn(e){return(e.mode&1)===0?1:(je&2)!==0&&Je!==0?Je&-Je:dp.transition!==null?(_r===0&&(_r=wc()),_r):(e=Ne,e!==0||(e=window.event,e=e===void 0?16:Mc(e.type)),e)}function Ot(e,n,o,l){if(50<ki)throw ki=0,Ya=null,Error(r(185));Us(e,o,l),((je&2)===0||e!==Ve)&&(e===Ve&&((je&2)===0&&(Mr|=o),Ue===4&&jn(e,Je)),ft(e,l),o===1&&je===0&&(n.mode&1)===0&&(xs=Oe()+500,cr&&pn()))}function ft(e,n){var o=e.callbackNode;dm(e,n);var l=Hi(e,e===Ve?Je:0);if(l===0)o!==null&&kc(o),e.callbackNode=null,e.callbackPriority=0;else if(n=l&-l,e.callbackPriority!==n){if(o!=null&&kc(o),n===1)e.tag===0?up(Md.bind(null,e)):pu(Md.bind(null,e)),op(function(){(je&6)===0&&pn()}),o=null;else{switch(jc(l)){case 1:o=Eo;break;case 4:o=yc;break;case 16:o=Bi;break;case 536870912:o=xc;break;default:o=Bi}o=Dd(o,Ed.bind(null,e))}e.callbackPriority=n,e.callbackNode=o}}function Ed(e,n){if(Rr=-1,_r=0,(je&6)!==0)throw Error(r(327));var o=e.callbackNode;if(ws()&&e.callbackNode!==o)return null;var l=Hi(e,e===Ve?Je:0);if(l===0)return null;if((l&30)!==0||(l&e.expiredLanes)!==0||n)n=Or(e,l);else{n=l;var d=je;je|=2;var h=Ad();(Ve!==e||Je!==n)&&(tn=null,xs=Oe()+500,Un(e,n));do try{Ip();break}catch(w){Id(e,w)}while(!0);ma(),Er.current=h,je=d,ze!==null?n=0:(Ve=null,Je=0,n=Ue)}if(n!==0){if(n===2&&(d=Mo(e),d!==0&&(l=d,n=Ja(e,d))),n===1)throw o=gi,Un(e,0),jn(e,l),ft(e,Oe()),o;if(n===6)jn(e,l);else{if(d=e.current.alternate,(l&30)===0&&!Ep(d)&&(n=Or(e,l),n===2&&(h=Mo(e),h!==0&&(l=h,n=Ja(e,h))),n===1))throw o=gi,Un(e,0),jn(e,l),ft(e,Oe()),o;switch(e.finishedWork=d,e.finishedLanes=l,n){case 0:case 1:throw Error(r(345));case 2:Wn(e,dt,tn);break;case 3:if(jn(e,l),(l&130023424)===l&&(n=qa+500-Oe(),10<n)){if(Hi(e,0)!==0)break;if(d=e.suspendedLanes,(d&l)!==l){ot(),e.pingedLanes|=e.suspendedLanes&d;break}e.timeoutHandle=sa(Wn.bind(null,e,dt,tn),n);break}Wn(e,dt,tn);break;case 4:if(jn(e,l),(l&4194240)===l)break;for(n=e.eventTimes,d=-1;0<l;){var k=31-Mt(l);h=1<<k,k=n[k],k>d&&(d=k),l&=~h}if(l=d,l=Oe()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Tp(l/1960))-l,10<l){e.timeoutHandle=sa(Wn.bind(null,e,dt,tn),l);break}Wn(e,dt,tn);break;case 5:Wn(e,dt,tn);break;default:throw Error(r(329))}}}return ft(e,Oe()),e.callbackNode===o?Ed.bind(null,e):null}function Ja(e,n){var o=vi;return e.current.memoizedState.isDehydrated&&(Un(e,n).flags|=256),e=Or(e,n),e!==2&&(n=dt,dt=o,n!==null&&Xa(n)),e}function Xa(e){dt===null?dt=e:dt.push.apply(dt,e)}function Ep(e){for(var n=e;;){if(n.flags&16384){var o=n.updateQueue;if(o!==null&&(o=o.stores,o!==null))for(var l=0;l<o.length;l++){var d=o[l],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 jn(e,n){for(n&=~Qa,n&=~Mr,e.suspendedLanes|=n,e.pingedLanes&=~n,e=e.expirationTimes;0<n;){var o=31-Mt(n),l=1<<o;e[o]=-1,n&=~l}}function Md(e){if((je&6)!==0)throw Error(r(327));ws();var n=Hi(e,0);if((n&1)===0)return ft(e,Oe()),null;var o=Or(e,n);if(e.tag!==0&&o===2){var l=Mo(e);l!==0&&(n=l,o=Ja(e,l))}if(o===1)throw o=gi,Un(e,0),jn(e,n),ft(e,Oe()),o;if(o===6)throw Error(r(345));return e.finishedWork=e.current.alternate,e.finishedLanes=n,Wn(e,dt,tn),ft(e,Oe()),null}function Za(e,n){var o=je;je|=1;try{return e(n)}finally{je=o,je===0&&(xs=Oe()+500,cr&&pn())}}function Fn(e){xn!==null&&xn.tag===0&&(je&6)===0&&ws();var n=je;je|=1;var o=$t.transition,l=Ne;try{if($t.transition=null,Ne=1,e)return e()}finally{Ne=l,$t.transition=o,je=n,(je&6)===0&&pn()}}function el(){xt=ys.current,Ie(ys)}function Un(e,n){e.finishedWork=null,e.finishedLanes=0;var o=e.timeoutHandle;if(o!==-1&&(e.timeoutHandle=-1,rp(o)),ze!==null)for(o=ze.return;o!==null;){var l=o;switch(ca(l),l.tag){case 1:l=l.type.childContextTypes,l!=null&&ar();break;case 3:gs(),Ie(lt),Ie(Xe),ja();break;case 5:xa(l);break;case 4:gs();break;case 13:Ie(Le);break;case 19:Ie(Le);break;case 10:pa(l.type._context);break;case 22:case 23:el()}o=o.return}if(Ve=e,ze=e=Sn(e.current,null),Je=xt=n,Ue=0,gi=null,Qa=Mr=Bn=0,dt=vi=null,Pn!==null){for(n=0;n<Pn.length;n++)if(o=Pn[n],l=o.interleaved,l!==null){o.interleaved=null;var d=l.next,h=o.pending;if(h!==null){var k=h.next;h.next=d,l.next=k}o.pending=l}Pn=null}return e}function Id(e,n){do{var o=ze;try{if(ma(),yr.current=Sr,xr){for(var l=Re.memoizedState;l!==null;){var d=l.queue;d!==null&&(d.pending=null),l=l.next}xr=!1}if(zn=0,Ke=Fe=Re=null,ui=!1,di=0,Va.current=null,o===null||o.return===null){Ue=1,gi=n,ze=null;break}e:{var h=e,k=o.return,w=o,C=n;if(n=Je,w.flags|=32768,C!==null&&typeof C=="object"&&typeof C.then=="function"){var _=C,z=w,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 G=nd(k);if(G!==null){G.flags&=-257,sd(G,k,w,h,n),G.mode&1&&td(h,_,n),n=G,C=_;var X=n.updateQueue;if(X===null){var ee=new Set;ee.add(C),n.updateQueue=ee}else X.add(C);break e}else{if((n&1)===0){td(h,_,n),tl();break e}C=Error(r(426))}}else if(Ae&&w.mode&1){var Pe=nd(k);if(Pe!==null){(Pe.flags&65536)===0&&(Pe.flags|=256),sd(Pe,k,w,h,n),fa(vs(C,w));break e}}h=C=vs(C,w),Ue!==4&&(Ue=2),vi===null?vi=[h]:vi.push(h),h=k;do{switch(h.tag){case 3:h.flags|=65536,n&=-n,h.lanes|=n;var T=Zu(h,C,n);$u(h,T);break e;case 1:w=C;var $=h.type,A=h.stateNode;if((h.flags&128)===0&&(typeof $.getDerivedStateFromError=="function"||A!==null&&typeof A.componentDidCatch=="function"&&(yn===null||!yn.has(A)))){h.flags|=65536,n&=-n,h.lanes|=n;var H=ed(h,w,n);$u(h,H);break e}}h=h.return}while(h!==null)}Rd(o)}catch(te){n=te,ze===o&&o!==null&&(ze=o=o.return);continue}break}while(!0)}function Ad(){var e=Er.current;return Er.current=Sr,e===null?Sr:e}function tl(){(Ue===0||Ue===3||Ue===2)&&(Ue=4),Ve===null||(Bn&268435455)===0&&(Mr&268435455)===0||jn(Ve,Je)}function Or(e,n){var o=je;je|=2;var l=Ad();(Ve!==e||Je!==n)&&(tn=null,Un(e,n));do try{Mp();break}catch(d){Id(e,d)}while(!0);if(ma(),je=o,Er.current=l,ze!==null)throw Error(r(261));return Ve=null,Je=0,Ue}function Mp(){for(;ze!==null;)Ld(ze)}function Ip(){for(;ze!==null&&!nm();)Ld(ze)}function Ld(e){var n=Pd(e.alternate,e,xt);e.memoizedProps=e.pendingProps,n===null?Rd(e):ze=n,Va.current=null}function Rd(e){var n=e;do{var o=n.alternate;if(e=n.return,(n.flags&32768)===0){if(o=Sp(o,n,xt),o!==null){ze=o;return}}else{if(o=Np(o,n),o!==null){o.flags&=32767,ze=o;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Ue=6,ze=null;return}}if(n=n.sibling,n!==null){ze=n;return}ze=n=e}while(n!==null);Ue===0&&(Ue=5)}function Wn(e,n,o){var l=Ne,d=$t.transition;try{$t.transition=null,Ne=1,Ap(e,n,o,l)}finally{$t.transition=d,Ne=l}return null}function Ap(e,n,o,l){do ws();while(xn!==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(fm(e,h),e===Ve&&(ze=Ve=null,Je=0),(o.subtreeFlags&2064)===0&&(o.flags&2064)===0||Ar||(Ar=!0,Dd(Bi,function(){return ws(),null})),h=(o.flags&15990)!==0,(o.subtreeFlags&15990)!==0||h){h=$t.transition,$t.transition=null;var k=Ne;Ne=1;var w=je;je|=4,Va.current=null,$p(e,o),Nd(o,e),Xm(ta),Qi=!!ea,ta=ea=null,e.current=o,bp(o),sm(),je=w,Ne=k,$t.transition=h}else e.current=o;if(Ar&&(Ar=!1,xn=e,Lr=d),h=e.pendingLanes,h===0&&(yn=null),om(o.stateNode),ft(e,Oe()),n!==null)for(l=e.onRecoverableError,o=0;o<n.length;o++)d=n[o],l(d.value,{componentStack:d.stack,digest:d.digest});if(Ir)throw Ir=!1,e=Ga,Ga=null,e;return(Lr&1)!==0&&e.tag!==0&&ws(),h=e.pendingLanes,(h&1)!==0?e===Ya?ki++:(ki=0,Ya=e):ki=0,pn(),null}function ws(){if(xn!==null){var e=jc(Lr),n=$t.transition,o=Ne;try{if($t.transition=null,Ne=16>e?16:e,xn===null)var l=!1;else{if(e=xn,xn=null,Lr=0,(je&6)!==0)throw Error(r(331));var d=je;for(je|=4,Y=e.current;Y!==null;){var h=Y,k=h.child;if((Y.flags&16)!==0){var w=h.deletions;if(w!==null){for(var C=0;C<w.length;C++){var _=w[C];for(Y=_;Y!==null;){var z=Y;switch(z.tag){case 0:case 11:case 15:pi(8,z,h)}var U=z.child;if(U!==null)U.return=z,Y=U;else for(;Y!==null;){z=Y;var D=z.sibling,G=z.return;if(yd(z),z===_){Y=null;break}if(D!==null){D.return=G,Y=D;break}Y=G}}}var X=h.alternate;if(X!==null){var ee=X.child;if(ee!==null){X.child=null;do{var Pe=ee.sibling;ee.sibling=null,ee=Pe}while(ee!==null)}}Y=h}}if((h.subtreeFlags&2064)!==0&&k!==null)k.return=h,Y=k;else e:for(;Y!==null;){if(h=Y,(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,Y=T;break e}Y=h.return}}var $=e.current;for(Y=$;Y!==null;){k=Y;var A=k.child;if((k.subtreeFlags&2064)!==0&&A!==null)A.return=k,Y=A;else e:for(k=$;Y!==null;){if(w=Y,(w.flags&2048)!==0)try{switch(w.tag){case 0:case 11:case 15:Tr(9,w)}}catch(te){_e(w,w.return,te)}if(w===k){Y=null;break e}var H=w.sibling;if(H!==null){H.return=w.return,Y=H;break e}Y=w.return}}if(je=d,pn(),Dt&&typeof Dt.onPostCommitFiberRoot=="function")try{Dt.onPostCommitFiberRoot(Fi,e)}catch{}l=!0}return l}finally{Ne=o,$t.transition=n}}return!1}function _d(e,n,o){n=vs(o,n),n=Zu(e,n,1),e=vn(e,n,1),n=ot(),e!==null&&(Us(e,1,n),ft(e,n))}function _e(e,n,o){if(e.tag===3)_d(e,e,o);else for(;n!==null;){if(n.tag===3){_d(n,e,o);break}else if(n.tag===1){var l=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(yn===null||!yn.has(l))){e=vs(o,e),e=ed(n,e,1),n=vn(n,e,1),e=ot(),n!==null&&(Us(n,1,e),ft(n,e));break}}n=n.return}}function Lp(e,n,o){var l=e.pingCache;l!==null&&l.delete(n),n=ot(),e.pingedLanes|=e.suspendedLanes&o,Ve===e&&(Je&o)===o&&(Ue===4||Ue===3&&(Je&130023424)===Je&&500>Oe()-qa?Un(e,0):Qa|=o),ft(e,n)}function Od(e,n){n===0&&((e.mode&1)===0?n=1:(n=Wi,Wi<<=1,(Wi&130023424)===0&&(Wi=4194304)));var o=ot();e=Xt(e,n),e!==null&&(Us(e,n,o),ft(e,o))}function Rp(e){var n=e.memoizedState,o=0;n!==null&&(o=n.retryLane),Od(e,o)}function _p(e,n){var o=0;switch(e.tag){case 13:var l=e.stateNode,d=e.memoizedState;d!==null&&(o=d.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(r(314))}l!==null&&l.delete(n),Od(e,o)}var Pd;Pd=function(e,n,o){if(e!==null)if(e.memoizedProps!==n.pendingProps||lt.current)ut=!0;else{if((e.lanes&o)===0&&(n.flags&128)===0)return ut=!1,jp(e,n,o);ut=(e.flags&131072)!==0}else ut=!1,Ae&&(n.flags&1048576)!==0&&gu(n,dr,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;$r(e,n),e=n.pendingProps;var d=cs(n,Xe.current);ps(n,o),d=Ca(null,n,l,e,d,o);var h=$a();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,ct(l)?(h=!0,lr(n)):h=!1,n.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,ka(n),d.updater=Nr,n.stateNode=d,d._reactInternals=n,Aa(n,l,e,o),n=Oa(null,n,l,!0,h,o)):(n.tag=0,Ae&&h&&la(n),rt(null,n,d,o),n=n.child),n;case 16:l=n.elementType;e:{switch($r(e,n),e=n.pendingProps,d=l._init,l=d(l._payload),n.type=l,d=n.tag=Pp(l),e=Lt(l,e),d){case 0:n=_a(null,n,l,e,o);break e;case 1:n=cd(null,n,l,e,o);break e;case 11:n=id(null,n,l,e,o);break e;case 14:n=rd(null,n,l,Lt(l.type,e),o);break e}throw Error(r(306,l,""))}return n;case 0:return l=n.type,d=n.pendingProps,d=n.elementType===l?d:Lt(l,d),_a(e,n,l,d,o);case 1:return l=n.type,d=n.pendingProps,d=n.elementType===l?d:Lt(l,d),cd(e,n,l,d,o);case 3:e:{if(ud(n),e===null)throw Error(r(387));l=n.pendingProps,h=n.memoizedState,d=h.element,Cu(e,n),vr(n,l,null,o);var k=n.memoizedState;if(l=k.element,h.isDehydrated)if(h={element:l,isDehydrated:!1,cache:k.cache,pendingSuspenseBoundaries:k.pendingSuspenseBoundaries,transitions:k.transitions},n.updateQueue.baseState=h,n.memoizedState=h,n.flags&256){d=vs(Error(r(423)),n),n=dd(e,n,l,o,d);break e}else if(l!==d){d=vs(Error(r(424)),n),n=dd(e,n,l,o,d);break e}else for(yt=fn(n.stateNode.containerInfo.firstChild),kt=n,Ae=!0,At=null,o=Su(n,null,l,o),n.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling;else{if(fs(),l===d){n=en(e,n,o);break e}rt(e,n,l,o)}n=n.child}return n;case 5:return Tu(n),e===null&&da(n),l=n.type,d=n.pendingProps,h=e!==null?e.memoizedProps:null,k=d.children,na(l,d)?k=null:h!==null&&na(l,h)&&(n.flags|=32),ld(e,n),rt(e,n,k,o),n.child;case 6:return e===null&&da(n),null;case 13:return fd(e,n,o);case 4:return ya(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=hs(n,null,l,o):rt(e,n,l,o),n.child;case 11:return l=n.type,d=n.pendingProps,d=n.elementType===l?d:Lt(l,d),id(e,n,l,d,o);case 7:return rt(e,n,n.pendingProps,o),n.child;case 8:return rt(e,n,n.pendingProps.children,o),n.child;case 12:return rt(e,n,n.pendingProps.children,o),n.child;case 10:e:{if(l=n.type._context,d=n.pendingProps,h=n.memoizedProps,k=d.value,Ee(mr,l._currentValue),l._currentValue=k,h!==null)if(It(h.value,k)){if(h.children===d.children&&!lt.current){n=en(e,n,o);break e}}else for(h=n.child,h!==null&&(h.return=n);h!==null;){var w=h.dependencies;if(w!==null){k=h.child;for(var C=w.firstContext;C!==null;){if(C.context===l){if(h.tag===1){C=Zt(-1,o&-o),C.tag=2;var _=h.updateQueue;if(_!==null){_=_.shared;var z=_.pending;z===null?C.next=C:(C.next=z.next,z.next=C),_.pending=C}}h.lanes|=o,C=h.alternate,C!==null&&(C.lanes|=o),ga(h.return,o,n),w.lanes|=o;break}C=C.next}}else if(h.tag===10)k=h.type===n.type?null:h.child;else if(h.tag===18){if(k=h.return,k===null)throw Error(r(341));k.lanes|=o,w=k.alternate,w!==null&&(w.lanes|=o),ga(k,o,n),k=h.sibling}else k=h.child;if(k!==null)k.return=h;else for(k=h;k!==null;){if(k===n){k=null;break}if(h=k.sibling,h!==null){h.return=k.return,k=h;break}k=k.return}h=k}rt(e,n,d.children,o),n=n.child}return n;case 9:return d=n.type,l=n.pendingProps.children,ps(n,o),d=Nt(d),l=l(d),n.flags|=1,rt(e,n,l,o),n.child;case 14:return l=n.type,d=Lt(l,n.pendingProps),d=Lt(l.type,d),rd(e,n,l,d,o);case 15:return od(e,n,n.type,n.pendingProps,o);case 17:return l=n.type,d=n.pendingProps,d=n.elementType===l?d:Lt(l,d),$r(e,n),n.tag=1,ct(l)?(e=!0,lr(n)):e=!1,ps(n,o),Ju(n,l,d),Aa(n,l,d,o),Oa(null,n,l,!0,e,o);case 19:return md(e,n,o);case 22:return ad(e,n,o)}throw Error(r(156,n.tag))};function Dd(e,n){return vc(e,n)}function Op(e,n,o,l){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=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function bt(e,n,o,l){return new Op(e,n,o,l)}function nl(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Pp(e){if(typeof e=="function")return nl(e)?1:0;if(e!=null){if(e=e.$$typeof,e===$e)return 11;if(e===se)return 14}return 2}function Sn(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,l,d,h){var k=2;if(l=e,typeof e=="function")nl(e)&&(k=1);else if(typeof e=="string")k=5;else e:switch(e){case le:return Hn(o.children,d,h,n);case de:k=8,d|=8;break;case Q:return e=bt(12,o,n,d|2),e.elementType=Q,e.lanes=h,e;case R:return e=bt(13,o,n,d),e.elementType=R,e.lanes=h,e;case V:return e=bt(19,o,n,d),e.elementType=V,e.lanes=h,e;case me:return Dr(o,d,h,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case xe:k=10;break e;case De:k=9;break e;case $e:k=11;break e;case se:k=14;break e;case ce:k=16,l=null;break e}throw Error(r(130,e==null?e:typeof e,""))}return n=bt(k,o,n,d),n.elementType=e,n.type=l,n.lanes=h,n}function Hn(e,n,o,l){return e=bt(7,e,l,n),e.lanes=o,e}function Dr(e,n,o,l){return e=bt(22,e,l,n),e.elementType=me,e.lanes=o,e.stateNode={isHidden:!1},e}function sl(e,n,o){return e=bt(6,e,null,n),e.lanes=o,e}function il(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 Dp(e,n,o,l,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=Io(0),this.expirationTimes=Io(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Io(0),this.identifierPrefix=l,this.onRecoverableError=d,this.mutableSourceEagerHydrationData=null}function rl(e,n,o,l,d,h,k,w,C){return e=new Dp(e,n,o,w,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:l,isDehydrated:o,cache:null,transitions:null,pendingSuspenseBoundaries:null},ka(h),e}function zp(e,n,o){var l=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:K,key:l==null?null:""+l,children:e,containerInfo:n,implementation:o}}function zd(e){if(!e)return mn;e=e._reactInternals;e:{if(An(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(ct(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(ct(o))return hu(e,o,n)}return n}function Bd(e,n,o,l,d,h,k,w,C){return e=rl(o,l,!0,e,d,h,k,w,C),e.context=zd(null),o=e.current,l=ot(),d=wn(o),h=Zt(l,d),h.callback=n??null,vn(o,h,d),e.current.lanes=d,Us(e,d,l),ft(e,l),e}function zr(e,n,o,l){var d=n.current,h=ot(),k=wn(d);return o=zd(o),n.context===null?n.context=o:n.pendingContext=o,n=Zt(h,k),n.payload={element:e},l=l===void 0?null:l,l!==null&&(n.callback=l),e=vn(d,n,k),e!==null&&(Ot(e,d,k,h),gr(e,d,k)),k}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 Fd(e,n){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var o=e.retryLane;e.retryLane=o!==0&&o<n?o:n}}function ol(e,n){Fd(e,n),(e=e.alternate)&&Fd(e,n)}function Bp(){return null}var Ud=typeof reportError=="function"?reportError:function(e){console.error(e)};function al(e){this._internalRoot=e}Fr.prototype.render=al.prototype.render=function(e){var n=this._internalRoot;if(n===null)throw Error(r(409));zr(e,n,null,null)},Fr.prototype.unmount=al.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var n=e.containerInfo;Fn(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=Cc();e={blockedOn:null,target:e,priority:n};for(var o=0;o<cn.length&&n!==0&&n<cn[o].priority;o++);cn.splice(o,0,e),o===0&&Tc(e)}};function ll(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 Wd(){}function Fp(e,n,o,l,d){if(d){if(typeof l=="function"){var h=l;l=function(){var _=Br(k);h.call(_)}}var k=Bd(n,l,e,0,null,!1,!1,"",Wd);return e._reactRootContainer=k,e[qt]=k.current,ni(e.nodeType===8?e.parentNode:e),Fn(),k}for(;d=e.lastChild;)e.removeChild(d);if(typeof l=="function"){var w=l;l=function(){var _=Br(C);w.call(_)}}var C=rl(e,0,!1,null,null,!1,!1,"",Wd);return e._reactRootContainer=C,e[qt]=C.current,ni(e.nodeType===8?e.parentNode:e),Fn(function(){zr(n,C,o,l)}),C}function Wr(e,n,o,l,d){var h=o._reactRootContainer;if(h){var k=h;if(typeof d=="function"){var w=d;d=function(){var C=Br(k);w.call(C)}}zr(n,k,e,d)}else k=Fp(o,n,e,d,l);return Br(k)}Sc=function(e){switch(e.tag){case 3:var n=e.stateNode;if(n.current.memoizedState.isDehydrated){var o=Fs(n.pendingLanes);o!==0&&(Ao(n,o|1),ft(n,Oe()),(je&6)===0&&(xs=Oe()+500,pn()))}break;case 13:Fn(function(){var l=Xt(e,1);if(l!==null){var d=ot();Ot(l,e,1,d)}}),ol(e,1)}},Lo=function(e){if(e.tag===13){var n=Xt(e,134217728);if(n!==null){var o=ot();Ot(n,e,134217728,o)}ol(e,134217728)}},Nc=function(e){if(e.tag===13){var n=wn(e),o=Xt(e,n);if(o!==null){var l=ot();Ot(o,e,n,l)}ol(e,n)}},Cc=function(){return Ne},$c=function(e,n){var o=Ne;try{return Ne=e,n()}finally{Ne=o}},Co=function(e,n,o){switch(n){case"input":if(vo(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 l=o[n];if(l!==e&&l.form===e.form){var d=or(l);if(!d)throw Error(r(90));Yl(l),vo(l,d)}}}break;case"textarea":tc(e,o);break;case"select":n=o.value,n!=null&&Jn(e,!!o.multiple,n,!1)}},uc=Za,dc=Fn;var Up={usingClientEntryPoint:!1,Events:[ri,as,or,lc,cc,Za]},yi={findFiberByHostInstance:Ln,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Wp={bundleType:yi.bundleType,version:yi.version,rendererPackageName:yi.rendererPackageName,rendererConfig:yi.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:J.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=pc(e),e===null?null:e.stateNode},findFiberByHostInstance:yi.findFiberByHostInstance||Bp,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(Wp),Dt=Hr}catch{}}return ht.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Up,ht.createPortal=function(e,n){var o=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!ll(n))throw Error(r(200));return zp(e,n,null,o)},ht.createRoot=function(e,n){if(!ll(e))throw Error(r(299));var o=!1,l="",d=Ud;return n!=null&&(n.unstable_strictMode===!0&&(o=!0),n.identifierPrefix!==void 0&&(l=n.identifierPrefix),n.onRecoverableError!==void 0&&(d=n.onRecoverableError)),n=rl(e,1,!1,null,null,o,!1,l,d),e[qt]=n.current,ni(e.nodeType===8?e.parentNode:e),new al(n)},ht.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=pc(n),e=e===null?null:e.stateNode,e},ht.flushSync=function(e){return Fn(e)},ht.hydrate=function(e,n,o){if(!Ur(n))throw Error(r(200));return Wr(null,e,n,!0,o)},ht.hydrateRoot=function(e,n,o){if(!ll(e))throw Error(r(405));var l=o!=null&&o.hydratedSources||null,d=!1,h="",k=Ud;if(o!=null&&(o.unstable_strictMode===!0&&(d=!0),o.identifierPrefix!==void 0&&(h=o.identifierPrefix),o.onRecoverableError!==void 0&&(k=o.onRecoverableError)),n=Bd(n,null,e,1,o??null,d,!1,h,k),e[qt]=n.current,ni(e),l)for(e=0;e<l.length;e++)o=l[e],d=o._getVersion,d=d(o._source),n.mutableSourceEagerHydrationData==null?n.mutableSourceEagerHydrationData=[o,d]:n.mutableSourceEagerHydrationData.push(o,d);return new Fr(n)},ht.render=function(e,n,o){if(!Ur(n))throw Error(r(200));return Wr(null,e,n,!1,o)},ht.unmountComponentAtNode=function(e){if(!Ur(e))throw Error(r(40));return e._reactRootContainer?(Fn(function(){Wr(null,null,e,!1,function(){e._reactRootContainer=null,e[qt]=null})}),!0):!1},ht.unstable_batchedUpdates=Za,ht.unstable_renderSubtreeIntoContainer=function(e,n,o,l){if(!Ur(o))throw Error(r(200));if(e==null||e._reactInternals===void 0)throw Error(r(38));return Wr(e,n,o,!1,l)},ht.version="18.3.1-next-f1338f8080-20240426",ht}var Jd;function Zp(){if(Jd)return dl.exports;Jd=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(),dl.exports=Xp(),dl.exports}var Xd;function eg(){if(Xd)return Kr;Xd=1;var t=Zp();return Kr.createRoot=t.createRoot,Kr.hydrateRoot=t.hydrateRoot,Kr}var tg=eg(),x=Ml();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}`},Il=`${Ni}.prefs`,oo=t=>`${ne.labelPrefix}:${t}`,Al=oo("map"),Ll=oo("hitl"),ng=t=>t==="task"||t==="execute",Rl=oo("plan-only"),yl=["research","prototype","junction","task","execute"],qn="plan+execute",sg=["verifying","rework","blocked"],_l=["off","checks","checks+review","checks+review+human"],Vf=t=>_l.find(s=>s===t);function Ii(t){return t.type==="junction"||t.type==="prototype"?"hitl":t.type==="research"?"afk":t.hitl?"hitl":"afk"}const ig=["task","execute"];function Qf(t,s,r=qn){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(c=>{var u;return((u=s.get(c))==null?void 0:u.state)==="open"})?"blocked":"frontier"}function Is(t,s=qn){const r=new Map(t.map(a=>[a.id,a]));return new Map(t.map(a=>[a.id,Qf(a,r,s)]))}const Te=200,Ce=56;function Zd(t,s="LR",r=qn){var $e;const a=s==="LR"?330:124,c=s==="LR"?112:262,u=Is(t,r),f=new Map(t.map(R=>[R.id,R])),m=new Map,g=new Set,p=R=>{if(m.has(R))return m.get(R);if(g.has(R))return 0;g.add(R);const V=f.get(R),se=V&&V.blockedBy.length?1+Math.max(...V.blockedBy.filter(ce=>f.has(ce)).map(p),-1):0;return g.delete(R),m.set(R,se),se},y=t.filter(R=>u.get(R.id)!=="out-of-scope"),v=t.filter(R=>u.get(R.id)==="out-of-scope"),j=[];for(const R of y)(j[$e=p(R.id)]??(j[$e]=[])).push(R);const N=[],M=new Map;let S=0;j.forEach(R=>{R&&(R.sort((V,se)=>{const ce=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 ce(V)-ce(se)||V.createdAt-se.createdAt}),S=Math.max(S,R.length),R.forEach((V,se)=>M.set(V.id,se)))}),j.forEach((R,V)=>{if(!R)return;const se=(S-R.length)*c/2;R.forEach((ce,me)=>{const B=V*a,F=se+me*c;N.push({ticket:ce,state:u.get(ce.id),layer:V,x:s==="LR"?B:F,y:s==="LR"?F:B})})});const I=Math.max(j.length,1)*a-(a-(s==="LR"?Te:Ce)),O=Math.max(S,1)*c-(c-(s==="LR"?Ce:Te)),L=s==="LR"?I:O,J=s==="LR"?O:I,Z=J+54,K=Math.max(1,Math.floor((L+24)/(Te+24)));v.forEach((R,V)=>{N.push({ticket:R,state:"out-of-scope",layer:-1,x:V%K*(Te+24),y:Z+Math.floor(V/K)*(Ce+16)})});const le=[],de=new Map(N.map(R=>[R.ticket.id,R]));for(const R of N)for(const V of R.ticket.blockedBy){const se=de.get(V);se&&le.push({from:se,to:R})}const Q=Math.ceil(v.length/K),xe=Math.max(L,Math.min(v.length,K)*(Te+24)-24),De=v.length?Z+Q*(Ce+16)-16:J;return{direction:s,nodes:N,edges:le,width:xe,graphH:J,quarantineY:Z,height:De,quarantineH:Q*(Ce+16)+24}}const rg=["holding","challenged","invalidated","confirmed"],og=t=>rg.includes(t),qf=ne.labelPrefix,ag=new RegExp(`^-\\s+(?:\\[([a-z]+)\\]\\s+)?(.*?)\\s*(?:<!-- ${qf}:asm (\\{.*\\}) -->)?\\s*$`),lg=1e3,cg=t=>t.replace(/--/g,"-\\u002d"),ug=t=>t.replace(/\s*\n\s*/g," ").trim();function dg(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,lg)}}:{},...t.decidedBy?{decidedBy:t.decidedBy}:{}};return`- [${t.status}] ${ug(t.text)} <!-- ${qf}:asm ${cg(JSON.stringify(s))} -->`}function fg(t){const s=t.map(hg);let r=Math.max(0,...s.map(a=>pg(a.id)))+1;return s.map(a=>a.id?a:{...a,id:`S-${r++}`})}function hg(t){const s=t.match(ag),r=s==null?void 0:s[1],a=(s==null?void 0:s[2])??t.replace(/^-\s+/,""),c=mg(s==null?void 0:s[3]);return{id:c.id??"",text:a,status:og(r)?r:"holding",tickets:Array.isArray(c.tickets)?c.tickets.map(String):[],...c.source?{source:c.source}:{},...c.challenge?{challenge:c.challenge}:{},...c.decidedBy?{decidedBy:c.decidedBy}:{}}}function mg(t){if(!t)return{};try{const s=JSON.parse(t);return s&&typeof s=="object"?s:{}}catch{return{}}}function pg(t){const s=t==null?void 0:t.match(/^S-(\d+)$/);return s?Number(s[1]):0}const Gf=[["destination","Destination"],["notes","Notes"],["assumptions","Assumptions"],["decisions","Decisions so far"],["unspecified","Not yet specified"],["outOfScope","Out of scope"]],gg=Object.fromEntries(Gf),vg=/^-\s+(?:\[?([#A-Z0-9-]+)\]?:?\s+)?(.*)$/;function kg(t){var a;const s=c=>c.length?c.map(u=>`- ${u}`).join(`
41
+ `):"_None yet._",r=c=>c.length?c.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(dg).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 yg(t){var a;const s={destination:"",notes:"",decisions:[],unspecified:[],outOfScope:[]},r=t.split(/^##\s+/m).slice(1);for(const c of r){const u=c.indexOf(`
59
+ `),f=c.slice(0,u===-1?void 0:u).trim().toLowerCase(),m=(u===-1?"":c.slice(u+1)).trim(),g=(a=Gf.find(([,v])=>v.toLowerCase()===f))==null?void 0:a[0];if(!g)continue;const p=/^_none yet\._$/i.test(m),y=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=fg(y):g==="decisions"?s.decisions=y.map(v=>{const j=v.match(vg);return j&&j[1]&&/\d/.test(j[1])?{ticketKey:j[1],text:j[2]}:{text:v.slice(2)}}):s[g]=y.map(v=>v.slice(2))}return s}const ao={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"]},xg=(t,s)=>`${t[0].toUpperCase()}${t.slice(1)} ${s}/${ao[t].length}`;async function wg(t,s,r={}){var f,m,g;const a=jg(s,s.mode??qn),c=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,c));const u=new Map;for(const p of a.tickets){const y=await t.createTicket(c.id,{title:p.title,type:p.type,hitl:p.hitl,body:`${p.body}
61
+
62
+ Part of trail ${c.key}.`});u.set(p.ref,y),await((m=r.onTicketCreated)==null?void 0:m.call(r,y,p.ref))}for(const p of a.tickets)for(const y of p.blockedBy??[]){const v=u.get(y),j=u.get(p.ref);v&&(await t.addBlocking(c.id,v.id,j.id),await((g=r.onEdgeWired)==null?void 0:g.call(r,v,j)))}return{map:c,tickets:[...u.values()]}}function jg(t,s){if(s==="plan+execute")return{...t,mode:s};const r=new Map(t.tickets.filter(c=>c.type==="execute").map(c=>[c.ref,c.blockedBy??[]])),a=c=>c.flatMap(u=>r.has(u)?a(r.get(u)):[u]);return{...t,mode:s,tickets:t.tickets.filter(c=>!r.has(c.ref)).map(c=>({...c,blockedBy:[...new Set(a(c.blockedBy??[]))]}))}}class Sg{constructor(){oe(this,"tails",new Map)}run(s,r){const c=(this.tails.get(s)??Promise.resolve()).catch(()=>{}).then(r);return this.tails.set(s,c),c.finally(()=>this.tails.get(s)===c&&this.tails.delete(s)).catch(()=>{}),c}}class We extends Error{}const Ng={frontier:"ready",blocked:"backlog",parked:"backlog",claimed:"working",verifying:"verifying",rework:"rework",held:"blocked",decided:"done","out-of-scope":"cancelled"};function Cg(t,s,r=qn){return Ng[Qf(t,s,r)]}const $g=["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:$g,to:["cancelled"],actors:[...wi,"engine"]},{event:"reopen",from:["done","cancelled"],to:["ready"],actors:["trail lead"]}],Tg=t=>bg.find(s=>s.event===t),Eg=new Sg;function Mg(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 Ig(t,s,r,a){const{to:c,actor:u}=a,f=async m=>{(r.status??null)!==m&&await t.setMeta(s,r.id,{status:m})};switch(c){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(c==="rework"?"rework":null),r.assignee&&await t.assign(s,r.id,null);return;case"verifying":case"blocked":await f(c);return;case"done":case"cancelled":await f(null),await t.close(s,r.id,c==="done"?"completed":"not_planned");return;case"backlog":throw new We("backlog follows from blockers; no transition leads there")}}function lo(t,s,r,a){return Eg.run(`${s}/${r}`,async()=>{var p;const c=await t.loadMap(s),u=c.tickets.find(y=>y.id===r);if(!u)throw new We(`ticket ${r} not found`);const f=Cg(u,new Map(c.tickets.map(y=>[y.id,y])),c.map.mode);if(a.expect&&f!==a.expect)throw new We(`${u.key} changed: it is ${f} now`);const m=Tg(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=Mg(m,u,a.to);await Ig(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 ef(t,s,r,a){const{assignee:c}=a,u=await t.loadMap(s),f=u.tickets.find(y=>y.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 lo(t,s,r,{event:"claim",actor:c,actorKind:a.actorKind??"agent",reason:a.reason,sessionId:a.sessionId,journal:a.journal});const p=(await t.loadMap(s)).tickets.find(y=>y.id===r);if(p.assignee!==c)throw new We(`${f.key} was claimed by ${p.assignee}`);return p}async function Ag(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 lo(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 Ol(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 c=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:c.ticketId,ticketKey:c.ticketKey,text:a.trailLine??c.summary}]})}return c}async function Lg(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),y={ticketId:f.ticketId,ticketKey:f.ticketKey,text:f.summary};return await t.updateMapSections(s,{decisions:p<0?[...g,y]:g.map((v,j)=>j===p?y:v)}),f}async function Rg(t,s,r){await t.setMapMode(s,r)}function Yf(t){return t==="plan-only"?yl.filter(s=>s!=="execute"):yl}function _g(t,s){if(!Yf(t).includes(s))throw new We(`${s} tickets are disabled on plan-only maps`)}const bn={lookout:{label:"Lookout",code:"CMD"},agent:{label:"Agent",code:"AGT"},slack:{label:"Slack",code:"SLK"},tracker:{label:"Tracker",code:"TRK"}},Xr=Object.keys(bn),Og=t=>t in bn,Ti=t=>t.source.kind==="agent"&&t.decidedBy!=="trail lead"&&!t.decidedBy.startsWith("slack:")?"agent":"human",Ai=t=>t.supersededBy?"superseded":"active";function co(t){const s=t.replace(/\s+/g," ").trim(),r=s.match(/^(.{20,180}?[.!?])(\s|$)/);return r?r[1]:s.slice(0,180)}function Pg(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())||co(r.answer),alternatives:r.alternatives??[],rationale:r.rationale??"",participants:r.participants??[{id:r.decidedBy}],transcript:r.transcript??[]}}const Dg=t=>Number(t.replace(/\D/g,""))||0;function zg(t,s){const r=new Map(t.map(f=>[f.id,f])),a=new Set;let c=r.get(s);for(;c!=null&&c.supersedes&&r.has(c.supersedes)&&!a.has(c.id);)a.add(c.id),c=r.get(c.supersedes);const u=[];a.clear();for(let f=c;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 Bg(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 lo(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 Ol(t,s,{ticketId:u.id,ticketKey:u.key,question:f.question??u.title,answer:a.answer,summary:a.summary??co(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 Fg(t,s,r,a){const c=await t.loadMap(s);if(!c.map.sections.unspecified.includes(r))throw new We(`"${r}" is not in Not yet specified`);_g(c.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 ${c.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 Ug(t,s,r,a){const c=await t.loadMap(s),{unspecified:u,outOfScope:f}=c.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=c.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 lo(t,s,m.id,{event:"cancel",actor:a.author,actorKind:a.actorKind??"agent",reason:a.reason,sessionId:a.sessionId,journal:a.journal}),await Ol(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 Wg(t){return{async append(s){await fetch(`${t}/journal`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})}}}const Jf={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(Jf));const Hg=2*6e4,ml=t=>t<6e4?`${Math.round(t/1e3)}s`:`${Math.round(t/6e4)}m`;function Kg(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 ${ml(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 ${ml(Math.max(0,t.nextAt-s))}`:"later"}
72
+ ${a}`}:!t.lastOkAt||t.lastOkAt!==t.lastAttemptAt||t.nextAt!==void 0&&s>t.nextAt+Hg?{tone:"stale",label:"PR sync stale",title:`No recent sync${r}
73
+ ${a}`}:{tone:"ok",label:`PR sync ${ml(s-t.lastOkAt)}`,title:`PR/CI synced${r}, ${a}`}}class bs{constructor(){oe(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 Vg=0;const Yr=(t="id")=>`${t}_${Date.now().toString(36)}${(Vg++).toString(36)}`,xl=(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)}:{}}),Xf=(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 Qg(t,s,r){const a=()=>t.find(s.id)??s,c=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=ao[r][u-1];t.patchSession(s.id,{step:u,stepLabel:g,...m?{ticketId:m}:{}}),c({tag:xg(r,u),level:"step",text:f?`${g}: ${f}`:g,ticketId:m??a().ticketId})},log(u,f="info"){c({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:Yr("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}),c({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),c({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:{...xl(m,u),source:u.source??(m==null?void 0:m.source)}})},setUsage(u){var y;const f=a().usage,m=Xf(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)&&((y=t.ledger())==null||y.add(p,m,s.id)),t.addMapUsage(p,m),t.patchSession(s.id,{usage:u})}}}class qg{constructor(s=400,r){oe(this,"state",{sessions:[],feed:[],chats:[],pending:[],answered:[],usageByMap:{}});oe(this,"changes",new bs);oe(this,"resolvers",new Map);oe(this,"remote",new Map);oe(this,"remoteAnswer");oe(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]:xl(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:Yr("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:Yr("m"),at:Date.now(),...s}].slice(-600)})}answer(s,r,a){const c=this.state.pending.find(m=>m.id===s),u=this.resolvers.get(s),f=!!c&&this.remote.has(c.sessionId)&&!!this.remoteAnswer;return!c||!u&&!f?!1:(this.resolvers.delete(s),this.chat({sessionId:c.sessionId,ticketId:c.ticketId,from:"human",author:a,text:r}),this.set({pending:this.state.pending.filter(m=>m.id!==s),answered:[...this.state.answered,{id:c.id,mapId:c.mapId,sessionId:c.sessionId,agent:c.agent,askedAt:c.at,answeredAt:Date.now()}].slice(-200)}),this.patchSession(c.sessionId,{waitingOn:void 0}),this.push({source:"trail lead",agent:a,level:"ok",ticketId:c.ticketId,sessionId:c.sessionId,text:`Answered ${c.agent}`}),u?u(r):this.remoteAnswer(c,r,a),!0)}syncRemote(s){var p;const{session:r}=s,a=r.id;if(!this.remote.has(a)&&this.state.sessions.some(y=>y.id===a))return;const c=this.remote.get(a);this.remote.set(a,r.mapId?r.usage:c);let u=this.state.usageByMap;if(r.usage&&r.mapId){const y=Xf(r.usage,c);(y.inputTokens||y.outputTokens||y.costUsd)&&(u={...u,[r.mapId]:xl(u[r.mapId],y)}),(p=this.ledger)==null||p.addTotal(r.mapId,a,r.usage)}const f=y=>y.filter(v=>v.sessionId!==a),m=new Set(this.state.answered.map(y=>y.id)),g=this.state.sessions.some(y=>y.id===a)?this.state.sessions.map(y=>y.id===a?r:y):[...this.state.sessions,r].slice(-24);this.set({sessions:g,chats:[...f(this.state.chats),...s.chats].sort((y,v)=>y.at-v.at).slice(-600),pending:[...f(this.state.pending),...s.pending],answered:[...this.state.answered,...s.answered.filter(y=>!m.has(y.id))].sort((y,v)=>y.answeredAt-v.answeredAt).slice(-200),feed:[...this.state.feed.filter(y=>y.sessionId!==a),...s.feed].sort((y,v)=>y.at-v.at).slice(-this.maxFeed),usageByMap:u})}isRemote(s){return this.remote.has(s)}startSession(s){const r={...s,id:s.id??Yr("s"),step:0,total:ao[s.mode].length,stepLabel:"BOOT",status:"running",startedAt:Date.now()};this.set({sessions:[...this.state.sessions,r].slice(-24)});const a=Qg(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 Gg(t,s){const r=a=>{var c;return((c=s(a))==null?void 0:c.key)??a};switch(t.kind){case"map.created":return{source:"tracker",level:"ok",text:`Trail created · label ${Al}`};case"map.updated":return{source:"tracker",level:"info",text:`Trail updated${t.section?` · ${gg[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 Yg=new Set(["createMap","setMapMode","setMapMeta","updateMapSections","createTicket","addBlocking","removeBlocking","editTicket","reopen","assign","comment","close","setMeta","createDecision","markSuperseded"]),Jg=5*6e4;function Xg(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-Jg;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:Yg.has(f)?async(...p)=>{const y=Date.now();a({inflight:s.inflight+1,status:"syncing"});try{const v=await g.apply(u,p),j=s.inflight-1;return a({inflight:j,writes:s.writes+1,lastWriteMs:Date.now()-y,lastWriteAt:Date.now(),status:j?"syncing":"ok",lastError:void 0}),v}catch(v){const j=s.inflight-1;throw a({inflight:j,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 Zf(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 eh(t){const s=Zf(t);return{decided:s.decided,total:s.total-s["out-of-scope"]}}function Zg(t){return yl.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 ev(t,s){const r=t.pending.filter(c=>!0),a=t.answered.filter(c=>!0);return{open:r.length,oldestAt:r.length?Math.min(...r.map(c=>c.at)):void 0,answered:a.length,avgWaitMs:a.length?a.reduce((c,u)=>c+(u.answeredAt-u.askedAt),0)/a.length:void 0}}function th(t,s){return s&&t.usageByMap[s]||{inputTokens:0,outputTokens:0,costUsd:0}}const tv=t=>t.usage?t.usage.inputTokens+t.usage.outputTokens:0,nh={"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 sh(t,s){var a;const r=new Set;for(const c of t.sessions)s&&c.mapId===s&&((a=c.usage)!=null&&a.source)&&r.add(c.usage.source);return[...r].sort()}function nv(t,s){const r=new Set(s.map(c=>c.ticketId).filter(Boolean)),a=t.tickets.filter(c=>c.state==="closed"&&c.closeReason==="completed"&&!r.has(c.id)).map(c=>{var y;const u=[...c.comments].reverse().find(v=>v.body.startsWith("**Resolution**")),f=u?u.body.replace(/^\*\*Resolution\*\*\s*/,""):((y=t.map.sections.decisions.find(v=>v.ticketId===c.id||v.ticketKey===c.key))==null?void 0:y.text)??"",m=(u==null?void 0:u.author)??c.assignee??"unknown",g=c.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${c.key}`,mapId:t.map.id,ticketId:c.id,ticketKey:c.key,question:c.title,answer:f,summary:co(f),alternatives:[],rationale:"",decidedBy:m,decidedAt:c.closedAt??(u==null?void 0:u.createdAt)??c.updatedAt,participants:[...new Set([m,...p.map(v=>v.author)])].map(v=>({id:v})),source:{kind:"tracker",ref:`${t.map.id}/tickets/${c.id}`,label:`${c.key} resolution comment`},transcript:p,derived:!0}});return[...s,...a].sort((c,u)=>u.decidedAt-c.decidedAt)}function sv(t,s){var a;const r=(a=s.query)==null?void 0:a.trim().toLowerCase();return t.filter(c=>(!s.mapId||c.mapId===s.mapId)&&(!s.source||c.source.kind===s.source)&&(!s.decidedBy||c.decidedBy===s.decidedBy)&&(!s.madeBy||Ti(c)===s.madeBy)&&(!s.status||Ai(c)===s.status)&&(!r||[c.id,c.ticketKey,c.question,c.answer,c.summary,c.rationale,c.decidedBy,...c.alternatives,...c.transcript.map(u=>u.text)].join(`
74
+ `).toLowerCase().includes(r)))}function iv(t,s=Date.now()){const r=Object.fromEntries(Xr.map(f=>[f,0]));let a=0,c=0,u=0;for(const f of t)r[f.source.kind]++,f.supersededBy&&a++,s-f.decidedAt<864e5&&c++,(Ti(f)==="human"||f.transcript.some(m=>m.from==="human"))&&u++;return{total:t.length,active:t.length-a,superseded:a,last24h:c,human:u,bySource:r}}function uo(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 c=a.indexOf(":");if(c<0)continue;const u=a.slice(0,c).trim(),f=a.slice(c+1).trim();r[u]=f.startsWith("[")?ov(f.slice(1,-1)).map(nf).filter(Boolean):nf(f)}return{front:r,body:s[2]}}const rv=t=>t===""||/^[\s#&*!|>'"%@`[\]{},?:-]|[:#]\s|\s$|,/.test(t)||/^(true|false|null|~|\d[\d.e+-]*)$/i.test(t),tf=t=>rv(t)?JSON.stringify(t):t;function nf(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 ov(t){const s=[];let r="",a=!1;for(const c of t)c==='"'&&(a=!a),c===","&&!a?(s.push(r.trim()),r=""):r+=c;return r.trim()&&s.push(r.trim()),s}function Pl(t,s){return`---
76
+ ${Object.entries(t).map(([a,c])=>`${a}: ${Array.isArray(c)?`[${c.map(tf).join(", ")}]`:tf(c)}`).join(`
77
+ `)}
78
+ ---
79
+
80
+ ${s.trim()}
81
+ `}const we=t=>Array.isArray(t)?t.join(","):t??"";function $n(t){return Array.isArray(t)?t:t?[t]:[]}const Ns=t=>Date.parse(we(t))||0,Ht=t=>new Date(t).toISOString(),ih=["schema","breaking-api","auth-permissions","billing","data-deletion","product-behaviour","dependencies"],rh=["low","medium","high"],av=t=>ih.includes(t),lv=t=>rh.includes(t);function cv(t){return t?{risk:t.level,...t.category?{risk_category:t.category}:{},risk_reason:t.reason}:{}}function uv(t){const s=we(t.risk);if(!lv(s))return{};const r=we(t.risk_category);return{risk:{level:s,...av(r)?{category:r}:{},reason:we(t.risk_reason)}}}const dv=["Question","Decision","Summary","Alternatives","Rationale","Transcript"],fv=t=>t.name?`${t.id}|${t.name}`:t.id,hv=t=>{const s=t.indexOf("|");return s<0?{id:t}:{id:t.slice(0,s),name:t.slice(s+1)}};function sf(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(fv),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}:{},...cv(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._",c=[`## 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 Pl(s,c)}function wl(t){const{front:s,body:r}=uo(t),a={},c=new RegExp(`^## (${dv.join("|")})\\s*$`,"gm"),u=[...r.matchAll(c)];u.forEach((v,j)=>{var M;const N=r.slice(v.index+v[0].length,((M=u[j+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 j=v.indexOf(`
101
+ `),N=j<0?v:v.slice(0,j),[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:j<0?"":v.slice(j+1).trim()}}),m=we(s.source),g=$n(s.source_meta),p={kind:Og(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)]))}:{}},y=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:y,summary:a.Summary||co(y),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:Ns(s.decided_at),participants:$n(s.participants).map(hv),source:p,supersedes:we(s.supersedes)||void 0,supersededBy:we(s.superseded_by)||void 0,...$n(s.assumes).length?{assumes:$n(s.assumes)}:{},transcript:f,...uv(s)}}function mv(t){return t.url?` · [${t.label??"link"}](${t.url})`:t.label?` · ${t.label}`:""}function pv(t,s,r={}){const a=[`# ${r.title??"Decisions"}`,"",`Exported ${Ht(r.now??Date.now())} · ${t.length} decisions`],c=new Map;for(const u of t)c.set(u.mapId,[...c.get(u.mapId)??[],u]);for(const[u,f]of c){const m=s[u];a.push("",`## Trail ${m?`${m.key} ${m.title}`:u}`);for(const g of f){const p=bn[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}${mv(g.source)}`,...g.participants.length?[`- **Participants:** ${g.participants.map(y=>y.name??y.id).join(", ")}`]:[],"",`**Decision:** ${g.answer}`,...g.alternatives.length?["","**Alternatives:**",...g.alternatives.map(y=>`- ${y}`)]:[],...g.rationale?["",`**Rationale:** ${g.rationale}`]:[],...g.transcript.length?["","<details><summary>Transcript</summary>","",...g.transcript.map(y=>`> **${y.author}:** ${y.text.replace(/\n/g,`
103
+ > `)}
104
+ >`),"","</details>"]:[])}}return a.join(`
105
+ `)+`
106
+ `}function jl(t,s,r){try{const a=t.get(s);return a?JSON.parse(a):r}catch{return r}}class rf{constructor(s,r="presence"){oe(this,"seen");this.store=s,this.key=r,this.seen=jl(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 c of s)(this.seen[c]??0)>=r||(this.seen[c]=r,a=!0);a&&this.store.set(this.key,JSON.stringify(this.seen))}}const pl=5*6e4,gv=14*864e5;class of{constructor(s,r="usage"){oe(this,"buckets");oe(this,"dirty",!1);oe(this,"timer");oe(this,"totals");this.store=s,this.key=r,this.buckets=jl(s,r,{}),this.totals=jl(s,`${r}.totals`,{})}addTotal(s,r,a,c=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:c},f.inputTokens>0||f.outputTokens>0||f.costUsd>0?this.add(s,f,r,c):this.save()}add(s,r,a,c=Date.now()){var g;if(!s)return;const u=Math.floor(c/pl)*pl,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,y)=>p.at-y.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},c=new Set;for(const u of this.buckets[s]??[])u.at+pl<=r||(a.inputTokens+=u.i,a.outputTokens+=u.o,a.costUsd+=u.c,u.s.forEach(f=>c.add(f)));return a.sessions=c.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()-gv;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 vv(t){const s=t.now??Date.now(),r=t.snaps.map(f=>{var de;const m=f.map.id,g=t.since(m),p=Q=>!!Q&&Q>=g,y=Is(f.tickets,f.map.mode),v=new Map(f.tickets.map(Q=>[Q.id,Q])),j=(t.attention??[]).filter(Q=>Q.mapId===m),N=kv(t.activity.pending.filter(Q=>Q.mapId===m),j),M=new Set(N.map(Q=>Q.ticketId)),S=Q=>Q.state==="open"&&(M.has(Q.id)||Ii(Q)==="hitl"),E=f.tickets.filter(Q=>y.get(Q.id)==="blocked").map(Q=>({ticket:Q,on:Q.blockedBy.map(xe=>v.get(xe)).filter(xe=>!!xe&&S(xe))})).filter(Q=>Q.on.length),I=t.decisions.filter(Q=>Q.mapId===m&&p(Q.decidedAt)).sort((Q,xe)=>xe.decidedAt-Q.decidedAt),O=f.tickets.filter(Q=>Q.state==="closed"&&p(Q.closedAt)).sort((Q,xe)=>(Q.closedAt??0)-(xe.closedAt??0)),L=O.filter(Q=>Q.closeReason==="completed"),J=O.filter(Q=>Q.closeReason==="not_planned"),Z=f.tickets.filter(Q=>p(Q.createdAt)),K=((de=t.ledger)==null?void 0:de.since(m,g))??{inputTokens:0,outputTokens:0,costUsd:0,sessions:0},le=t.activity.sessions.filter(Q=>Q.mapId===m&&Q.status==="running");return{mapId:m,key:f.map.key,title:f.map.title,since:g,done:L,ruledOut:J,opened:Z,blocked:E,waiting:N,needsYou:j,decisions:I,agentDecisions:I.filter(Q=>Ti(Q)==="agent"),usage:K,active:le,changed:!!(O.length||Z.length||I.length||N.some(Q=>p(Q.at))||K.costUsd>0)}}),a=r.filter(f=>f.changed||f.waiting.length).sort((f,m)=>+(m.mapId===t.currentMapId)-+(f.mapId===t.currentMapId)),c=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:c("done"),ruledOut:c("ruledOut"),blocked:c("blocked"),waiting:c("waiting"),oldestWaitMs:u===void 0?void 0:s-u,agentDecisions:c("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:c("active")},changed:r.some(f=>f.changed)}}function kv(t,s){const r=new Map(s.filter(c=>c.kind==="question").map((c,u)=>[c.ref,u])),a=c=>r.get(c.id)??Number.MAX_SAFE_INTEGER;return[...t].sort((c,u)=>a(c)-a(u)||c.at-u.at)}const Ci=(t,s,r=`${s}s`)=>`${t} ${t===1?s:r}`;function yv(t){return t.trails.flatMap(s=>{const r=new Set(s.waiting.map(a=>a.ticketId));return s.blocked.filter(a=>a.on.some(c=>r.has(c.id)))})}function xv(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 wv(t,s=new Date(t.now).getHours()){const r=t.totals,c=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=xv(yv(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.`),[c,...u].join(" ")}const jv=t=>{if(!t.length)return;const s=[...t].sort((a,c)=>a-c),r=Math.floor(s.length/2);return s.length%2?s[r]:Math.round((s[r-1]+s[r])/2)};function Sv(t){return t.state==="open"?"open":t.closeReason==="not_planned"?"cancelled":"done"}function Nv({snap:t,journal:s,answered:r,usage:a}){const c=t.map.id,u=s.filter(S=>S.mapId===c).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 J;const E=f.get(S.id)??[],I=Sv(S),O=(J=E.find(Z=>Z.event==="claim"))==null?void 0:J.at,L=I==="done"?S.closedAt:void 0;return{id:S.id,key:S.key,title:S.title,type:S.type,outcome:I,claimedAt:O,doneAt:L,leadMs:L&&O&&L>=O?L-O:void 0,reworks:E.filter(Z=>Z.to==="rework").length,reviews:{passed:E.filter(Z=>Z.event==="review.pass").length,failed:E.filter(Z=>Z.event==="review.fail").length,needsHuman:E.filter(Z=>Z.event==="review.needs_human").length},operatorActions:E.filter(Z=>Z.actorKind==="trail lead").length}}),g=m.filter(S=>S.outcome==="done"),p=Math.max(0,...g.map(S=>S.doneAt??0)),y=u.filter(S=>S.actorKind==="trail lead"),v=new Set(r.filter(S=>S.mapId===c).map(S=>S.id)).size,j=y.length,N=S=>m.reduce((E,I)=>E+S(I),0),M=(a==null?void 0:a.costUsd)??0;return{mapId:c,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:jv(g.flatMap(S=>S.leadMs===void 0?[]:[S.leadMs])),interventions:{answers:v,operatorActions:j,reworkRequested:y.filter(S=>S.event==="reject").length,total:v+j},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}}}function Cs(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 af=t=>t===void 0?"—":`$${t.toFixed(t<1?4:2)}`;function Cv(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) | ${Cs(t.trailLeadMs)} |`,`| Median ticket lead time (claim → done) | ${Cs(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 | ${af(t.spend.costUsd)} · ${t.spend.tokens.toLocaleString("en-US")} tokens |`,`| Cost per verified ticket | ${af(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} | ${Cs(u.leadMs)} | ${u.reworks} | ${u.reviews.passed}/${u.reviews.failed} | ${u.operatorActions} |`),""].join(`
107
+ `)}const $v={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
+ `)},bv=[["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(bv);function Tv(t,s){const r=new Set(t.map(a=>a.source).filter(Boolean));return s.filter(a=>!r.has(a))}const Ev=["architecture","convention","gotcha","dead-end","glossary","fact"],oh=["business-rule","product-decision","persona","ux-principle","pricing"],Mv=[...Ev,...oh],Iv=t=>t.status==="confirmed"||t.status==="assumption";function Av(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 Lv={"business-rule":3,convention:3,"product-decision":2,architecture:2,gotcha:2,"dead-end":2,"ux-principle":2},Rv=["business-rule","ux-principle","convention"],lf=600,_v=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(" ")),cf=t=>new Set((t.toLowerCase().match(/[a-z0-9][a-z0-9_-]{2,}/g)??[]).filter(s=>!_v.has(s)));function ah(t,s,r=4e3,a=()=>[]){const c=s.ticket?cf(`${s.ticket.title} ${s.ticket.body}`):new Set,u=new Set((s.tags??[]).map(p=>p.toLowerCase())),f=t.filter(Iv).map(p=>{const y=[];let v=Lv[p.kind]??1;for(const M of p.scope){const S=s.paths.find(E=>Av(M,E));if(S){v+=6,y.push(`path match ${M} (${S})`);break}}const j=p.tags.filter(M=>u.has(M.toLowerCase())||c.has(M.toLowerCase()));j.length&&(v+=3*j.length,y.push(`tag ${j.join(", ")}`));const N=[...cf(p.title)].filter(M=>c.has(M));return N.length&&(v+=N.length,y.push(`mentions ${N.slice(0,3).join(", ")}`)),s.trailKey&&p.sources.includes(`trail:${s.trailKey}`)&&(v+=3,y.push("same trail")),s.discovery&&oh.includes(p.kind)&&(v+=8,y.push("product context for discovery")),!y.length&&Rv.includes(p.kind)&&!p.scope.length&&y.push(`${p.kind.replace("-"," ")} for the whole project`),{e:p,score:v,why:y}}).filter(p=>p.why.length>0).sort((p,y)=>y.score-p.score||p.e.id.localeCompare(y.e.id,void 0,{numeric:!0})),m=[];let g=0;for(const{e:p,why:y}of f){const v=p.body.length>lf?`${p.body.slice(0,lf)}…`:p.body;if(g+v.length>r&&m.length)break;g+=v.length;const j=a(p);m.push({id:p.id,title:p.title,kind:p.kind,status:p.status,body:v,why:y,...j.length?{mayBeOutdated:j}:{},...p.flag?{flagged:p.flag.reason}:{}})}return m}const Ov=new RegExp("`([^`\\s]+/[^`\\s]+)`|(?:^|[\\s(])/?((?:[\\w.-]+/)+[\\w.-]+)","gm");function lh(t){const s=new Set;for(const r of t.matchAll(Ov))s.add((r[1]??r[2]).replace(/^\.?\//,"").replace(/[.,;:]+$/,""));return[...s]}const Pv=[{level:"high",label:"High risk"},{level:"medium",label:"Medium risk"},{level:"low",label:"Low risk"},{level:"none",label:"No category"}];function Dv(t){return Pv.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 zv=1/3;function fo(t,s=Date.now()){const r=t.expiresAt-s;return r<=0?"expired":r<=t.ttlMs*zv?"stalled":"live"}function Bv(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 Fv=t=>t.urgency==="fyi"||t.kind==="policy";function Uv(t,s){const r={...t};return s.verification===null?delete r.verification:s.verification&&(r.verification=s.verification),r}function Wv(t,s,r){const a=Date.now();return{id:t,key:s,...r,state:"open",blockedBy:[],comments:[],createdAt:a,updatedAt:a}}const Hv=(t,s)=>({...t,blockedBy:t.blockedBy.filter(r=>r!==s)}),Kv=(t,s)=>{var r;return{...t,...(r=s.title)!=null&&r.trim()?{title:s.title.trim()}:{},...s.body!==void 0?{body:s.body}:{}}};function Vv(t){const{closeReason:s,closedAt:r,...a}=t;return{...a,state:"open"}}const Qv=["status","verification","checks","reviewOf"];function qv(t,s){const r={...t};for(const a of Qv)s[a]!==void 0&&(s[a]===null?delete r[a]:r[a]=s[a]);return r}const Gv=/^([^/]+)\/decisions\/([^/]+)\.md$/,Yv=(t,s)=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,40)||`map-${s}`;class Jv{constructor(s,r){oe(this,"seen",new Map);oe(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=>Gv.test(f)),c=[];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=wl(m);this.seen.set(f,{text:m,supersededBy:p.supersededBy}),g?p.supersededBy&&p.supersededBy!==g.supersededBy&&c.push({kind:"decision.superseded",mapId:s,decisionId:p.id,supersededBy:p.supersededBy,external:!0,at:Date.now()}):c.push({kind:"decision.recorded",mapId:s,decisionId:p.id,ticketId:p.ticketId,external:!0,at:Date.now()})}a.length?!c.length&&a.length<r.paths.size&&c.push({kind:"external.changed",mapId:s,at:Date.now()}):c.push({kind:"external.changed",mapId:s,at:Date.now()});const u=f=>f.kind==="decision.recorded"?0:1;c.sort((f,m)=>u(f)-u(m));for(const f of c)this.emit(f)}}function Xv(t,s){const{front:r,body:a}=uo(s),c=Vf(we(r.verification));return{id:t,key:we(r.key)||t,title:we(r.title)||t,mode:we(r.mode)==="plan-only"||$n(r.labels).includes(Rl)?"plan-only":qn,...c?{verification:c}:{},sections:yg(a),createdAt:Ns(r.created),updatedAt:Ns(r.updated)}}function Zv(t){return Pl({key:t.key,title:t.title,mode:t.mode,...t.verification?{verification:t.verification}:{},labels:[Al,...t.mode==="plan-only"?[Rl]:[]],created:Ht(t.createdAt),updated:Ht(t.updatedAt)},kg(t.sections))}async function uf(t){const s=await t.list(),r=s.filter(c=>!c.includes("/decisions/")).map(c=>{var u;return Number(((u=c.match(/(\d+)\.md$/))==null?void 0:u[1])??0)}),a=await Promise.all(s.filter(c=>c.endsWith("/map.md")).map(async c=>Number(we(uo(await t.read(c)).front.key).replace(/\D/g,""))||0));return Math.max(0,...r,...a)+1}function df(t){const{front:s,body:r}=uo(t),[a,c=""]=r.split(/^## Comments\s*$/m),u=c.split(/^### /m).slice(1).map((p,y)=>{const v=p.indexOf(`
109
+ `),[j,N]=p.slice(0,v).split(" @ ");return{id:`c${y}`,author:j.trim(),createdAt:Date.parse(N)||0,body:p.slice(v+1).trim()}}),f=we(s.close_reason),m=sg.find(p=>p===we(s.status)),g=Vf(we(s.verification));return{id:we(s.id),key:`#${we(s.id)}`,title:we(s.title),type:we(s.type)||"task",hitl:$n(s.labels).includes(Ll)||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:$n(s.checks)}:{},...we(s.review_of)?{reviewOf:we(s.review_of)}:{},blockedBy:$n(s.blocked_by),body:a.trim(),comments:u,createdAt:Ns(s.created),updatedAt:Ns(s.updated),closedAt:Ns(s.closed)||void 0}}function ek(t){const s={id:t.id,title:t.title,type:t.type,labels:[oo(t.type),...ng(t.type)&&t.hitl?[Ll]:[]],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 Pl(s,t.body+r)}class tk{constructor(s,r=`./${ne.dataDir}`){oe(this,"kind","markdown");oe(this,"label","Local markdown");oe(this,"events",new bs);oe(this,"selfWrites",new Map);oe(this,"external",new Jv(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,c=>{const u=this.selfWrites.get(c);u&&Date.now()-u<1500||this.external.queue(c)})}async put(s,r){this.selfWrites.set(s,Date.now()),await this.fs.write(s,r)}async readMap(s){return Xv(s,await this.fs.read(`${s}/map.md`))}async writeMap(s){await this.put(`${s.id}/map.md`,Zv(s))}async readTicket(s,r){return df(await this.fs.read(`${s}/tickets/${r}.md`))}async writeTicket(s,r){await this.put(`${s}/tickets/${r.id}.md`,ek({...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 c=await this.readMap(a);return{id:a,key:c.key,title:c.title}}))}async loadMap(s){const r=await this.fs.list(),a=await this.readMap(s),c=r.filter(f=>f.startsWith(`${s}/tickets/`)),u=await Promise.all(c.map(async f=>df(await this.fs.read(f))));return{map:a,tickets:u.sort((f,m)=>f.createdAt-m.createdAt)}}async createMap(s){const r=await uf(this.fs),a=Yv(s.title,r),c={id:a,key:`#${r}`,title:s.title,mode:s.mode??qn,...s.verification?{verification:s.verification}:{},sections:s.sections,createdAt:Date.now(),updatedAt:Date.now()};return await this.writeMap(c),this.events.emit({kind:"map.created",mapId:a,at:Date.now()}),c}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=>Uv(a,r),{kind:"map.updated",mapId:s,at:Date.now()})}updateMapSections(s,r){const a=Object.keys(r)[0];return this.editMap(s,c=>({...c,sections:{...c.sections,...r}}),{kind:"map.updated",mapId:s,section:a,at:Date.now()})}async createTicket(s,r){const a=await uf(this.fs),c=Wv(String(a),`#${a}`,r);return await this.writeTicket(s,c),this.events.emit({kind:"ticket.created",mapId:s,ticketId:c.id,at:Date.now()}),c}async addBlocking(s,r,a){const c=await this.readTicket(s,a);c.blockedBy.includes(r)||await this.writeTicket(s,{...c,blockedBy:[...c.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,c=>Hv(c,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,c=>Kv(c,a)),this.events.emit({kind:"ticket.updated",mapId:s,ticketId:r,at:Date.now()})}async reopen(s,r){await this.update(s,r,Vv),this.events.emit({kind:"ticket.updated",mapId:s,ticketId:r,at:Date.now()})}async assign(s,r,a){await this.update(s,r,c=>({...c,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,c){await this.update(s,r,u=>({...u,comments:[...u.comments,{id:`c${u.comments.length}`,author:a,body:c,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,c=>({...c,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,c=>qv(c,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 c=await this.fs.read(a),u={...wl(c),mapId:s};return this.external.knows(a)||this.external.remember(a,c,u.supersededBy),u}))}async createDecision(s,r){const a=(await this.fs.list()).filter(m=>m.includes("/decisions/")),c=Math.max(0,...a.map(m=>Dg(m.split("/").pop())))+1,u=Pg(`D-${c}`,s,r),f=sf(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 c=`${s}/decisions/${r}.md`,u=wl(await this.fs.read(c)),f=sf({...u,mapId:s,supersededBy:a});this.external.remember(c,f,a),await this.put(c,f),this.events.emit({kind:"decision.superseded",mapId:s,decisionId:r,supersededBy:a,at:Date.now()})}subscribe(s){return this.events.on(s)}}class ff extends Error{constructor(s,r,a,c){super(r),this.code=s,this.status=a,this.resetAt=c,this.name="TrackerError"}}const nk={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 ff("offline","Lookout server unreachable; is `teamtrail` still running?")}const c=await a.json().catch(()=>({}));if(!a.ok)throw new ff(c.code??"http",c.error??`request failed (${a.status})`,a.status,c.resetAt);return c}class sk{constructor(s,r,a=""){oe(this,"label");oe(this,"location");oe(this,"status",{state:"connecting",queued:0});oe(this,"events",new bs);oe(this,"statusEvents",new bs);oe(this,"source");oe(this,"listeners",0);oe(this,"listMaps",()=>this.call("listMaps"));oe(this,"loadMap",s=>this.call("loadMap",s));oe(this,"createMap",s=>this.call("createMap",s));oe(this,"setMapMode",(s,r)=>this.call("setMapMode",s,r));oe(this,"setMapMeta",(s,r)=>this.call("setMapMeta",s,r));oe(this,"updateMapSections",(s,r)=>this.call("updateMapSections",s,r));oe(this,"createTicket",(s,r)=>this.call("createTicket",s,r));oe(this,"addBlocking",(s,r,a)=>this.call("addBlocking",s,r,a));oe(this,"removeBlocking",(s,r,a)=>this.call("removeBlocking",s,r,a));oe(this,"editTicket",(s,r,a)=>this.call("editTicket",s,r,a));oe(this,"reopen",(s,r)=>this.call("reopen",s,r));oe(this,"assign",(s,r,a)=>this.call("assign",s,r,a));oe(this,"comment",(s,r,a,c)=>this.call("comment",s,r,a,c));oe(this,"close",(s,r,a)=>this.call("close",s,r,a));oe(this,"setMeta",(s,r,a)=>this.call("setMeta",s,r,a));oe(this,"listDecisions",s=>this.call("listDecisions",s));oe(this,"createDecision",(s,r)=>this.call("createDecision",s,r));oe(this,"markSuperseded",(s,r,a)=>this.call("markSuperseded",s,r,a));this.kind=s,this.base=r,this.label=nk[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 ik(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 rk=[{id:"markdown",name:"Local markdown",status:"available"},{id:"github",name:"GitHub Issues",status:"available"},{id:"linear",name:"Linear",status:"available"}],ch=[{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"}],ok=ch[0],uh={ink:"#16302a",shell:"#eae3cf",edge:"#c8bea2",glass:"#16302a",glow:"#b4e8c0",hat:"#8a5a38",band:"#e6dcc0",kerchief:"#c8581e",sky:"#d9e4d2",mid:"#7fa888",low:"#3f6b45"},dh={on:"#e2711d",dim:"#a8501c",alert:"#ff5a48"},ak={on:"#ffd166",dim:"#a8501c",alert:"#ff5a48"},$s=(t,s,r)=>`<path d="${t}" fill="none" stroke="${s}" stroke-width="${r}" stroke-linecap="round"/>`;function lk(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 ck(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 uk({eyes:t,mouth:s,light:r="on"},a){const c=uh,u=`stroke="${c.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="${c.shell}" stroke="${c.ink}" stroke-width="8" stroke-linejoin="round"/>`,`<path d="M58 142H142V146A12 12 0 0 1 130 158H70A12 12 0 0 1 58 146Z" fill="${c.edge}"/>`,`<rect x="66" y="104" width="68" height="46" rx="8" fill="${c.glass}"/>`,`<path d="M100 170L82 162H118Z" fill="${c.kerchief}" stroke="${c.ink}" stroke-width="5" stroke-linejoin="round"/>`,lk(t,c.glow),ck(s,c.glow),`<path d="M70 94L76 56Q90 50 100 44Q110 50 124 56L130 94Z" fill="${c.hat}" ${u}/>`,`<path d="M71 82H129V94H71Z" fill="${c.band}" stroke="${c.ink}" stroke-width="4"/>`,`<path d="M34 98Q100 82 166 98Q100 114 34 98Z" fill="${c.hat}" ${u}/>`,`<path d="M100 52l6 9h-3l5 8H92l5-8h-3z" fill="${c.band}"/>`,`<rect x="113" y="83" width="10" height="10" rx="2" fill="${a[r]}" stroke="${c.ink}" stroke-width="3"/>`].join("")}let dk=0;function fk(t,{lamp:s=dh,simple:r=!1}={}){const a=uh,c=`scout-badge-${++dk}`,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="${c}"><circle cx="100" cy="100" r="88"/></clipPath>`,`<g clip-path="url(#${c})"><rect width="200" height="200" fill="${r?a.mid:a.sky}"/>${u}</g>`,`<g transform="${f}">${uk(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 fh={crt:{id:"crt",name:"Day",blurb:"A CRT head in a ranger hat and neckerchief, in a circle with layered hills.",lamp:dh,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:ak,wave:{bar:"#66828d",lead:"#e8833a"}}},hk="crt",mk={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"}},pk={idle:"WATCHING",speaking:"TALKING",alert:"NEEDS YOU",thinking:"THINKING"},nn={msPerChar:55,mouthHoldMs:110,blinkEveryMs:5600,blinkMs:140,thinkingStepMs:520};function gk(t){return t?/[aeiouy]/i.test(t)?"open":/[a-z0-9]/i.test(t)?"mid":"rest":"rest"}function vk(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 kk(t,s,r){return Array.from({length:r},(a,c)=>{const u=s-(r-1-c);return u>=0&&u<t.length?vk(t[u],u):0})}function hh({face:t={eyes:"open",mouth:"rest"},variant:s="crt",size:r,simple:a,className:c}){const{eyes:u,mouth:f,light:m}=t,g=x.useMemo(()=>fk({eyes:u,mouth:f,light:m},{lamp:fh[s].lamp,simple:a??r<28}),[u,f,m,s,a,r]);return i.jsx("svg",{className:c,width:r,height:r,viewBox:"0 0 200 200","aria-hidden":"true",dangerouslySetInnerHTML:{__html:g}})}function yk(t){const[s,r]=x.useState(!1);return x.useEffect(()=>{if(!t){r(!1);return}let a;const c=setInterval(()=>{r(!0),a=setTimeout(()=>r(!1),nn.blinkMs)},nn.blinkEveryMs);return()=>{clearInterval(c),a&&clearTimeout(a)}},[t]),s}const xk={xs:.8,sm:2,md:4,lg:6},wk=40,hf=20,mf="(prefers-reduced-motion: reduce)",jk=40,Sk=350;function Nk(t,s){var m;const r=t.size??"md",a=t.state??"idle",c=((m=t.speaking)==null?void 0:m.trim())??"",u=c&&(a==="idle"||a==="speaking")?"speaking":a,f=r==="xs";return{size:r,text:c,effective:u,talking:u==="speaking"&&c.length>0,mini:f,framed:t.framed??!f,reduced:s||f}}const Ck=t=>t.length*nn.msPerChar,$k=(t,s)=>s&&(t.effective==="idle"||t.effective==="speaking"||t.effective==="alert");function bk(t,s,r,a){const c=mk[t.effective],u=r?"closed":c.eyes;let f=c.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=gk(t.text[Math.min(t.text.length-1,p)])}let g=c.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 Tk(t,s){const r=typeof t.size=="number"?t.size:xk[t.size],a=t.reduced?Math.min(t.text.length-1,hf-1):s;return{base:r,px:wk*r,bars:hf,waveCursor:a}}function Ek(t,{label:s,speechDone:r,cursor:a,caption:c}){const u=t.talking&&r?"idle":t.effective,f=pk[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:c??m,shown:Mk(t,r,a)}}function Mk(t,s,r){return t.talking?t.reduced||s?t.text:t.text.slice(0,r+1):""}function Ik(){const[t,s]=x.useState(()=>{var r;return typeof window<"u"&&!!((r=window.matchMedia)!=null&&r.call(window,mf).matches)});return x.useEffect(()=>{var c;const r=(c=window.matchMedia)==null?void 0:c.call(window,mf);if(!r)return;const a=()=>s(r.matches);return a(),r.addEventListener("change",a),()=>r.removeEventListener("change",a)},[]),t}function Ak(t,s,r){const[a,c]=x.useState(0);return x.useEffect(()=>{if(c(0),!s)return;const u=performance.now(),f=setInterval(()=>c(performance.now()-u),r);return()=>clearInterval(f)},[t,s,r]),a}function Lk(t){const{key:s,talking:r,at:a}=t,c=a!==void 0,u=Ck(t.text),[f,m]=x.useState(""),g=x.useRef(t.onSpeakEnd);g.current=t.onSpeakEnd,x.useEffect(()=>{if(!r||c)return;const N=setTimeout(()=>{var M;m(s),(M=g.current)==null||M.call(g)},u+Sk);return()=>clearTimeout(N)},[r,s,u,c]);const p=r&&f!==s,y=Ak(s,t.animate&&(p||t.thinking),p?jk:nn.thinkingStepMs),v=a??y,j=r&&(c?v>=u:f===s);return{t:v,speechDone:j}}const Rk=t=>t*2,Sl=3.5;function _k(t,s,r){return(t??[]).map((a,c)=>{const u=(1+2*a)*.5;return{x:c*2,y:(Sl-u)/2,width:1,height:u,fill:c>=s-2&&a>0?r.lead:r.bar}})}function Ok({heights:t,bars:s,unit:r,colors:a}){const c=Rk(s);return i.jsx("svg",{className:`scout-wave${t?" on":""}`,width:c*r,height:Sl*r,viewBox:`0 0 ${c} ${Sl}`,"aria-hidden":"true",children:_k(t,s,a).map((u,f)=>i.jsx("rect",{...u},f))})}function Li({state:t="idle",size:s="md",speaking:r,variant:a=hk,framed:c,caption:u,label:f="Scout",onSpeakEnd:m,at:g,className:p,style:y}){const v=Nk({state:t,size:s,speaking:r,framed:c},Ik()),{text:j,effective:N,talking:M,reduced:S}=v,E=fh[a],O=!S&&!(g!==void 0),L=`${N}|${a}|${j}`,{t:J,speechDone:Z}=Lk({key:L,text:j,talking:M,thinking:N==="thinking",animate:O,at:g,onSpeakEnd:m}),K=yk($k(v,O)),le=M&&!Z,{eyes:de,mouth:Q,light:xe,cursor:De}=bk(v,J,K,le),{base:$e,px:R,bars:V,waveCursor:se}=Tk(v,De),ce=x.useMemo(()=>le?kk(j,se,V):null,[le,j,se,V]),{shownState:me,status:B,ariaLabel:F,showCaption:W,shown:b}=Ek(v,{label:f,speechDone:Z,cursor:De,caption:u}),P={...y,"--scout-u":`${$e}px`},fe=i.jsx("span",{className:"scout-sprite",children:i.jsx(hh,{face:{eyes:de,mouth:Q,light:xe},variant:a,size:R,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(Ok,{heights:ce,bars:V,unit:$e,colors:E.wave})]}),W&&i.jsxs("p",{className:"scout-caption","aria-hidden":"true",children:[b,M&&!Z&&!S&&i.jsx("span",{className:"scout-caret",children:"_"})]}),j&&i.jsx("span",{className:"scout-sr","aria-live":"polite",children:j})]}):i.jsx("span",{className:`scout scout-bare scout-${me} ${p??""}`,style:P,role:"img","aria-label":F,children:fe})}let Pk=0;const Vn="#16302a",pf=t=>`<rect x="54" y="88" width="92" height="72" rx="16" fill="#f1e8d3" stroke="${Vn}" stroke-width="8"/><rect x="66" y="100" width="68" height="48" rx="8" fill="${Vn}"/>${t}`,Dk='<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"/>',zk='<circle cx="84" cy="122" r="7" fill="#b4e8c0"/><circle cx="116" cy="122" r="7" fill="#b4e8c0"/>',gf=`<path d="M100 90V70" stroke="${Vn}" stroke-width="8" stroke-linecap="round"/><path d="M100 80C84 80 70 68 68 48C88 48 100 60 100 80Z" fill="#3f6b45" stroke="${Vn}" stroke-width="5" stroke-linejoin="round"/><path d="M100 72C114 72 128 62 130 44C112 44 100 54 100 72Z" fill="#7fa888" stroke="${Vn}" stroke-width="5" stroke-linejoin="round"/>`,Bk=`<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="${Vn}" stroke-width="8"/>`;function Fk({simple:t=!1}={}){const s=`tt-logo-${++Pk}`,r=t?`<g transform="translate(100 98) scale(1.42) translate(-100 -104)">${gf}${pf(zk)}</g>`:`<g transform="translate(100 102) scale(1.22) translate(-100 -104)">${gf}${pf(Dk)}</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?"":Bk}</g>`,r,`<circle cx="100" cy="100" r="88" fill="none" stroke="${Vn}" stroke-width="${t?16:12}"/>`].join("")}function Uk({size:t=40,className:s}){const r=x.useMemo(()=>Fk({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 mt="trail lead";function Wk({rt:t,guard:s,setMapId:r,mapIdRef:a,snapRef:c,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,mt),claim:g=>s("Claim",()=>ef(t.adapter,a.current,g,{...m,assignee:mt})),release:g=>s("Release claim",()=>Ag(t.adapter,a.current,g,{...m,actor:mt})),releaseLease:g=>s("Release to queue",()=>t.leases.release(a.current,g,mt)),resolve:(g,p,y={})=>s("Resolve · record answer",async()=>{var j;const v=(j=c.current)==null?void 0:j.tickets.find(N=>N.id===g);v&&!v.assignee&&await ef(t.adapter,a.current,g,{...m,assignee:mt}),await Bg(t.adapter,a.current,g,{...m,answer:p,author:mt,decision:{...y,source:{kind:"lookout",label:"Ticket inspector"}}})}),supersede:(g,p)=>s(`Supersede ${g.id}`,async()=>{let y=g.id;if(g.derived){const{id:v,mapId:j,derived:N,supersededBy:M,...S}=g;y=(await Ol(t.adapter,g.mapId,S,{appendToTrail:!1})).id}await Lg(t.adapter,g.mapId,y,{...p,decidedBy:mt,participants:[{id:mt}],source:{kind:"lookout",label:"Logbook"}})}),graduate:({unspecified:g,...p})=>s(`Promote to ticket · ${g}`,async()=>{const y=await Fg(t.adapter,a.current,g,p);f({kind:"ticket",id:y.id})}),ruleOut:(g,p)=>s("Rule out of scope",async()=>{await Ug(t.adapter,a.current,g,{...m,reason:p,author:mt,source:{kind:"lookout",label:"Ticket inspector"}}),f(null)}),setMode:g=>s(`Trail mode · ${g}`,()=>Rg(t.adapter,a.current,g))}}const st=(...t)=>t.filter(Boolean).join(" ");async function Hk(t,s){var u;const r=(s.assumptions??[]).map((f,m)=>({id:`S-${m+1}`,text:f,status:"holding",tickets:[]})),{map:a,tickets:c}=await wg(t,{title:s.title,sections:{destination:s.destination,notes:s.notes,decisions:[],unspecified:[],outOfScope:[],...r.length?{assumptions:r}:{}},tickets:[{ref:"discovery",...$v}]});return await fetch(`${ne.apiPrefix}/briefs/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:a.id,ticketId:(u=c[0])==null?void 0:u.id})}),a}function mh(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 Gn(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 ph(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 Dl=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 ho(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),zl=t=>new Date(t).toTimeString().slice(0,5),Kk=t=>`${Es(t)} ${zl(t)}`,gh=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`},mo=t=>t?new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",vh={research:"Research",prototype:"Prototype",junction:"Junction",task:"Task",execute:"Execute",review:"Review"},kh={decided:"Done",claimed:"Working",frontier:"Ready",blocked:"Backlog",parked:"Parked (plan-only)","out-of-scope":"Cancelled",verifying:"Verifying",rework:"Rework",held:"Blocked"},Vk={decided:"done",claimed:"working",frontier:"ready",blocked:"backlog",parked:"parked","out-of-scope":"cancelled",verifying:"verifying",rework:"rework",held:"blocked"};function Bl(t,s){return new Map((t??[]).filter(r=>r.mapId===s&&!r.returned).map(r=>[r.ticketId,r]))}const Fl=(t,s)=>`${t}/${s}`;let sn={reached:!1,live:!1,tickets:{}},Nl=!1;const Cl=new Set,$l=new Set;function Zr(t){sn=t;for(const s of Cl)s()}function vf(){fetch(`${ne.apiPrefix}/verification/sync`).then(t=>t.ok?t.json():Promise.reject()).then(t=>Zr({reached:!0,live:!0,status:t.status,tickets:Object.fromEntries(t.tickets.map(s=>[Fl(s.mapId,s.ticketId),s]))}),()=>sn.reached&&Zr({...sn,live:!1}))}function kf(){Nl=!0,vf();const t=new EventSource(`${ne.apiPrefix}/events`);t.addEventListener("verification",s=>{const r=JSON.parse(s.data);if(r.kind==="evidence")for(const c of $l)c();if(r.kind!=="sync")return;const a={...sn.tickets};for(const c of r.tickets)a[Fl(c.mapId,c.ticketId)]=c;Zr({reached:!0,live:!0,status:r.status,tickets:a})}),t.addEventListener("error",()=>sn.reached&&sn.live&&Zr({...sn,live:!1})),t.addEventListener("open",()=>sn.reached&&vf())}const Ms={subscribe(t){return Nl||kf(),Cl.add(t),()=>void Cl.delete(t)},get:()=>sn,onEvidence(t){return Nl||kf(),$l.add(t),()=>void $l.delete(t)},ticket:(t,s,r)=>t.tickets[Fl(s,r)]};function Qk(t){if(t!=null&&t.flags.length)return t.flags.some(s=>s.severity==="alert")?"alert":"warn"}const yf={onboarded:!1,tracker:"markdown",hitlTranscript:"summary",agent:ok.id,github:{repo:""},linear:{team:""},briefing:{enabled:!0,awayMinutes:15},theme:"night"};function Ul(){try{const t={...yf,...JSON.parse(localStorage.getItem(Il)??"{}")};return["markdown","github","linear"].includes(t.tracker)||(t.tracker="markdown"),t}catch{return yf}}function yh(t){t==="auto"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=t}const qk=15*6e4;class Gk{constructor(s){oe(this,"leases",[]);oe(this,"changes",new bs);oe(this,"logged",new Set);oe(this,"since",Date.now()-qk);this.activity=s}subscribe(s){return this.changes.on(s)}set(s){var r;this.leases=s;for(const a of s){const c=`${a.mapId}/${a.ticketId}/${(r=a.returned)==null?void 0:r.at}`;!a.returned||a.returned.at<this.since||this.logged.has(c)||(this.logged.add(c),this.activity.push({source:"system",level:"warn",ticketId:a.ticketId,text:Bv(a)}))}this.changes.emit(s)}async release(s,r,a){const c=await fetch(`${ne.apiPrefix}/agents/leases/release`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:s,ticketId:r,by:a})});if(!c.ok)throw new Error((await c.json().catch(()=>({}))).error??`HTTP ${c.status}`)}}let Kt;const eo=new Set,Ei=new Map;function xh(t){Kt==null||Kt.addEventListener(t,s=>{for(const r of Ei.get(t)??[])r(s.data)})}function wh(){if(!Kt){Kt=new EventSource(`${ne.apiPrefix}/events`),Kt.onmessage=t=>{const s=JSON.parse(t.data).path;if(typeof s=="string")for(const r of eo)r(s)};for(const t of Ei.keys())xh(t)}}function jh(){const t=[...Ei.values()].some(s=>s.size>0);eo.size||t||(Kt==null||Kt.close(),Kt=void 0)}function As(t){return eo.add(t),wh(),()=>{eo.delete(t),jh()}}function Sh(t,s){let r=Ei.get(t);return r||(r=new Set,Ei.set(t,r),xh(t)),r.add(s),wh(),()=>{r.delete(s),jh()}}function Yk(t,s){return Sh(t,r=>s(JSON.parse(r)))}const Jk={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 xf(t,s){t.remoteAnswer=(a,c,u)=>{fetch(`${ne.apiPrefix}/agents/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:a.sessionId,questionId:a.id,text:c,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(c=>t.syncRemote(c))).catch(()=>{})}function wf(t){const s=r=>`${Il}:${t}:${r}`;return{get:r=>localStorage.getItem(s(r)),set:(r,a)=>{try{localStorage.setItem(s(r),a)}catch{}}}}const Xk=["markdown","github","linear"];function Zk(){const t=new URLSearchParams(location.search).get("tracker");return t&&Xk.includes(t)?t:Ul().tracker}function ey(t){let s,r;const a=new qg,c=new Gk(a),u={},f=Wg(ne.apiPrefix);if(t==="github"||t==="linear"){const p=new sk(t,ne.apiPrefix);s=p,r=fetch(`${ne.apiPrefix}/trackers`).then(y=>y.json()).catch(()=>{}).then(y=>{p.location=(t==="github"?y==null?void 0:y.github.repo:[y==null?void 0:y.linear.teamKey,y==null?void 0:y.linear.projectName].filter(Boolean).join(" · "))||p.location;const v=wf(`${t}:${p.location}`);u.presence=new rf(v),a.ledger=new of(v),xf(a,c)})}else s=new tk(Jk,`./${ne.dataDir}`),r=fetch(`${ne.apiPrefix}/list`).then(p=>p.json()).catch(()=>({root:"default"})).then(({root:p})=>{const y=wf(p);u.presence=new rf(y),a.ledger=new of(y),xf(a,c)});const m=Xg(s),g=m.adapter;return{kind:t,ready:r,get presence(){return u.presence},adapter:g,journal:f,monitor:m,activity:a,leases:c}}const Qt=t=>t.status==="running",Nh=t=>Qt(t)&&!!t.waitingOn,ty={blocking:0,soon:1,fyi:2};function ny(t,s,r){const a=t.filter(f=>f.sessionId===s),c=a.find(f=>f.id===r);if(c)return c;const u=f=>ty[f.urgency??"soon"];return[...a].sort((f,m)=>u(f)-u(m)||f.at-m.at)[0]}function to({n:t,urgent:s,pop:r,hideZero:a}){return i.jsx("span",{className:st("badge",s&&"urgent",r&&s&&"pop",a&&!t&&"zero"),children:a&&!t?"":t})}function q({variant:t="default",size:s="md",on:r,className:a,type:c,...u}){return i.jsx("button",{type:c??"button",className:st("btn",t!=="default"&&t,s==="sm"&&"sm",r&&"on",a),...u})}function Et({as:t="div",tone:s,on:r,className:a,children:c,...u}){return i.jsx(t,{className:st("card",s,r&&"on",a),...u,children:c})}function pt({on:t,title:s,sub:r,disabled:a,onClick:c}){return i.jsxs(Et,{as:"button",type:"button",className:"choice",on:t,disabled:a,onClick:c,children:[i.jsx("b",{className:"choice-title t-row-title",children:s}),r&&i.jsx("span",{className:"c-sub",children:r})]})}function Be({children:t}){return i.jsx("div",{className:"empty",children:t})}const jf=()=>{const t=document.documentElement.dataset.theme;return t?t==="night":matchMedia("(prefers-color-scheme: dark)").matches};function po(){const[t,s]=x.useState(jf);return x.useEffect(()=>{const r=()=>s(jf()),a=matchMedia("(prefers-color-scheme: dark)");a.addEventListener("change",r);const c=new MutationObserver(r);return c.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{a.removeEventListener("change",r),c.disconnect()}},[]),t}function sy(){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 iy=15e3,Sf=["pointerdown","pointermove","keydown","wheel","touchstart"];function ry(t,s,r,a){const[c,u]=x.useState(null),[f,m]=x.useState(!1),[g,p]=x.useState(!1),y=x.useRef(),v=x.useRef(Date.now()),j=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((K,le)=>{const de=M.current;return vv({snaps:Object.values(de.allSnaps),decisions:de.decisions,activity:de.activity,ledger:t.activity.ledger,since:Q=>{var xe;return K[Q]??le??((xe=de.allSnaps[Q])==null?void 0:xe.map.createdAt)??Date.now()},currentMapId:de.mapId,attention:S.current})},[t]),I=x.useCallback((K=Date.now())=>{var le;return(le=t.presence)==null?void 0:le.markSeen(M.current.maps.map(de=>de.id),K)},[t]),O=x.useCallback(()=>{const K=t.presence;if(!K)return;const le=K.lastSeenAny();if(le!==void 0&&Date.now()-le>=N){const de=K.snapshot();E(de,le).changed&&(y.current={seen:de,any:le},m(!0),r.enabled?u(de):p(!0))}I()},[t,N,r.enabled,E,I]);x.useEffect(()=>{!s.loaded||j.current||!t.presence||(j.current=!0,O())},[s.loaded,t,O]),x.useEffect(()=>{const K=()=>{const Q=Date.now()-v.current>=N;v.current=Date.now(),Q&&j.current&&document.visibilityState==="visible"&&O()},le=()=>{if(document.visibilityState!=="visible"){j.current&&I(Date.now()-v.current<N?Date.now():v.current);return}v.current=Date.now(),j.current&&O()};for(const Q of Sf)window.addEventListener(Q,K,{passive:!0});document.addEventListener("visibilitychange",le);const de=setInterval(()=>{j.current&&document.visibilityState==="visible"&&I(v.current)},iy);return()=>{for(const Q of Sf)window.removeEventListener(Q,K);document.removeEventListener("visibilitychange",le),clearInterval(de)}},[N,O,I]);const L=x.useMemo(()=>{var K;return c?E(c,(K=y.current)==null?void 0:K.any):void 0},[c,E,s.allSnaps,s.decisions,s.activity,a]),J=x.useMemo(()=>L?wv(L):"",[L]);x.useEffect(()=>{c&&p(!1)},[c]);let Z="none";return g?Z="new":f&&(Z="seen"),{shown:c!==null,status:Z,briefing:L,line:J,open:()=>{const K=y.current;K&&u(K.seen)},dismiss:()=>u(null)}}function oy(t){const[s,r]=x.useState(t.leases.leases);return x.useEffect(()=>t.leases.subscribe(r),[t]),s}function ay(t){var B;const[s,r]=x.useState([]),[a,c]=x.useState(),[u,f]=x.useState(),[m,g]=x.useState({}),[p,y]=x.useState({}),[v,j]=x.useState(!1),[N,M]=x.useState(t.activity.snapshot),[S,E]=x.useState(t.monitor.health),I=oy(t);x.useEffect(()=>t.monitor.subscribe(E),[t]);const[O,L]=x.useState(null),[J,Z]=x.useState(),[K,le]=x.useState(),de=x.useRef(),Q=x.useRef(),xe=x.useRef(new Set),De=x.useRef();De.current=u;const $e=x.useCallback(F=>{de.current=F,c(F),L(null)},[]),R=x.useCallback(async()=>{var pe;const F=await t.adapter.listMaps();r(F);let W=de.current;const b=Q.current;b&&F.some(ae=>ae.id===b)?(Q.current=void 0,W=b,W!==de.current&&$e(W)):(!W||!F.some(ae=>ae.id===W))&&(W=(pe=F[0])==null?void 0:pe.id,$e(W));const[P,fe]=await Promise.all([Promise.all(F.map(ae=>t.adapter.loadMap(ae.id))),Promise.all(F.map(ae=>t.adapter.listDecisions(ae.id)))]);g(Object.fromEntries(P.map(ae=>[ae.map.id,ae]))),y(Object.fromEntries(F.map((ae,ye)=>[ae.id,fe[ye]]))),j(!0),f(P.find(ae=>ae.map.id===W))},[t,$e]);x.useEffect(()=>{let F,W=()=>{},b=()=>{},P=!0;const fe=()=>{clearTimeout(F),F=setTimeout(()=>void R().catch(he=>Z(String(he))),40)},pe=(he,ve)=>Qt(he)&&t.activity.isRemote(he.id)&&(!ve||!he.mapId||he.mapId===ve),ae=he=>{var ve;return(ve=De.current)==null?void 0:ve.tickets.find(be=>be.id===he)},ye=he=>{const ve=Gg(he,ae),be=he.kind==="external.changed"&&t.activity.snapshot.sessions.some(Yn=>pe(Yn,he.mapId)),it=!("mapId"in he)||!he.mapId||he.mapId===de.current||he.kind==="map.created";ve&&!be&&it&&t.activity.push(ve),fe()};return t.ready.then(()=>{P&&(W=t.adapter.subscribe(ye),b=t.activity.subscribe(M),t.activity.push({source:"system",level:"ok",text:`Online · tracker ${t.adapter.label.toLowerCase()} · ${t.adapter.location}`}),R().catch(he=>Z(String(he))))}),()=>{P=!1,W(),b(),clearTimeout(F)}},[t,R]),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)&&(Q.current=F.mapId,R().catch(W=>Z(String(W)))))},[N.sessions,t,R]);const V=(B=N.pending[0])==null?void 0:B.sessionId;x.useEffect(()=>{if(!V)return;const F=W=>t.activity.snapshot.sessions.some(b=>b.id===W&&Qt(b));le(W=>F(W)?W:V)},[V,t]);const se=x.useCallback(async(F,W)=>{t.activity.push({source:"trail lead",agent:mt,level:"warn",text:F});try{Z(void 0),await W()}catch(b){const P=b.message??String(b);Z(P),t.activity.push({source:"trail lead",agent:mt,level:"alert",text:`Rejected · ${P}`})}},[t]),ce=x.useMemo(()=>Wk({rt:t,guard:se,setMapId:$e,mapIdRef:de,snapRef:De,setChatSession:le,setSelection:L}),[se,t,$e]),me=x.useMemo(()=>Object.values(m).flatMap(F=>nv(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:O,setSelection:L,error:J,chatSession:K,decisions:me,leases:I,loaded:v,actions:ce}}function Mn(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 ly(){const[t,s]=x.useState(Ul),r=x.useCallback(a=>{s(c=>{const u={...c,...a};return localStorage.setItem(Il,JSON.stringify(u)),u})},[]);return[t,r]}function Wl(){return x.useSyncExternalStore(Ms.subscribe,Ms.get)}function Hl({className:t,size:s=18}){return i.jsx("span",{className:t,"aria-hidden":"true",children:i.jsx(hh,{size:s,variant:po()?"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(Hl,{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:st("field",r),children:[t,s]})}const cy=x.forwardRef(function({value:s,onValueChange:r,onSubmit:a,action:c="Send",actionDisabled:u,className:f,...m},g){return i.jsxs("form",{className:st("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(q,{type:"submit",variant:"primary",disabled:u??(m.disabled||!s.trim()),children:c})]})});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 at({as:t="span",variant:s="chip",hot:r,size:a,className:c,children:u,title:f}){return i.jsx(t,{className:st(s==="chip"?"chip-label":"mono-label",r&&"hot",a==="sm"&&(s==="chip"?"sm":"xs"),c),title:f,children:u})}const uy="M25.53 10.5 A11 11 0 1 1 16 5",dy="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:c}){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:c?"img":void 0,"aria-label":c,"aria-hidden":c?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:uy,fill:"none",stroke:"currentColor",strokeWidth:u,strokeLinecap:"butt"}),(t==="mark"||t==="action")&&i.jsx("path",{d:dy,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 no({parts:t,className:s,as:r="div"}){const a=t.filter(c=>c!=null&&c!==!1&&c!=="");return i.jsx(r,{className:st("meta",s),children:a.map((c,u)=>i.jsxs("span",{children:[u>0&&" · ",c]},u))})}const fy=t=>typeof t=="string"?{text:t}:t,hy=t=>st(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(fy);return!s.length&&!t.children?null:i.jsxs("span",{className:st("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:hy(r)||void 0,children:r.text})]},a)),t.children]})}function my({size:t=40,className:s}){return i.jsx(Uk,{size:t,className:s})}function Ge({as:t="section",className:s,style:r,frameless:a,children:c,...u}){return i.jsx(t,{className:st("panel",a&&"frameless",s),style:r,...u,children:c})}function In({tone:t,className:s,children:r,title:a}){return i.jsx("span",{className:st("pill",t,s),title:a,children:r})}function Vt({label:t,value:s,layout:r="stack",urgent:a,title:c,className:u}){return i.jsxs("span",{className:st("readout",r!=="stack"&&r,a&&"urgent",u),title:c,children:[i.jsx("span",{className:"mono-label",children:t}),r==="inline"&&" ",i.jsx("b",{children:s})]})}function gt(t){const{as:s="div",edge:r="neutral"}=t,a=t.onOpen?"button":"div";return i.jsxs(s,{className:st("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 Cn="#c8581e",py={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:Cn,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:Cn})]}),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:Cn})]}),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:Cn,stroke:Cn})]}),tent:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 4L2.5 20h19z"}),i.jsx("path",{d:"M12 11l-4 9h8z",fill:Cn,stroke:Cn}),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:Cn})]})};function Ch({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:py[t]})}function rn({title:t,count:s,right:r,hot:a,sub:c,children:u,className:f,info:m,icon:g}){return i.jsxs("header",{className:st("sec-h",c&&"sub",f),children:[u,g&&i.jsx(Ch,{name:g}),t!==void 0&&i.jsx(at,{as:c?"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,[c,u]=x.useState(!1),[f,m]=x.useState(0),[g,p]=x.useState(),y=x.useRef(null),v=x.useRef(null),j=x.useId(),N=r.find(I=>I.value===s);x.useLayoutEffect(()=>{if(!c||!y.current)return;const I=y.current.getBoundingClientRect();p({left:I.left,top:I.bottom+4,minWidth:I.width})},[c]),x.useEffect(()=>{if(!c)return;const I=L=>{var J,Z;L.target instanceof Node&&((J=v.current)!=null&&J.contains(L.target)||(Z=y.current)!=null&&Z.contains(L.target))||u(!1)},O=()=>u(!1);return document.addEventListener("mousedown",I),window.addEventListener("resize",O),window.addEventListener("scroll",O,!0),()=>{document.removeEventListener("mousedown",I),window.removeEventListener("resize",O),window.removeEventListener("scroll",O,!0)}},[c]),x.useEffect(()=>{var I,O;c&&((O=(I=v.current)==null?void 0:I.querySelector(`[data-i="${f}"]`))==null||O.scrollIntoView({block:"nearest"}))},[c,f]);const M=()=>{m(Math.max(0,r.findIndex(I=>I.value===s))),u(!0)},S=I=>{var L;const O=r[I];u(!1),(L=y.current)==null||L.focus(),O&&O.value!==s&&a(O.value)},E=I=>{if(!c){["ArrowDown","ArrowUp","Enter"," "].includes(I.key)&&(I.preventDefault(),M());return}const O=L=>m(J=>(J+L+r.length)%r.length);if(I.key==="ArrowDown")O(1);else if(I.key==="ArrowUp")O(-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 L=r.findIndex(J=>J.label.toLowerCase().startsWith(I.key.toLowerCase()));L>=0&&m(L);return}else return}I.preventDefault()};return i.jsxs(i.Fragment,{children:[i.jsxs("button",{ref:y,type:"button",className:st("select",t.compact&&"compact",c&&"open",t.className),role:"combobox","aria-haspopup":"listbox","aria-expanded":c,"aria-controls":j,"aria-label":t["aria-label"],"aria-activedescendant":c?`${j}-${f}`:void 0,disabled:t.disabled,onClick:()=>c?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"})]}),c&&g&&i.jsx("ul",{ref:v,id:j,className:"select-menu",role:"listbox",style:g,children:r.map((I,O)=>i.jsxs("li",{id:`${j}-${O}`,"data-i":O,role:"option","aria-selected":I.value===s,className:st(O===f&&"active"),onMouseEnter:()=>m(O),onMouseDown:L=>L.preventDefault(),onClick:()=>S(O),children:[i.jsx("span",{className:"select-label",children:I.label}),I.hint&&i.jsx("span",{className:"select-hint",children:I.hint})]},I.value))})]})}function Kl(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 gy=350;function vy(){const[t,s]=x.useState(null);if(x.useEffect(()=>{let a=0,c=null;const u=()=>{window.clearTimeout(a),c=null,s(null)},f=y=>{const v=y.getAttribute("data-tip");if(!v)return;const j=y.getBoundingClientRect(),N=j.bottom+60>window.innerHeight;s({text:v,x:j.left+j.width/2,y:N?j.top-8:j.bottom+8,above:N,scout:y.hasAttribute("data-tip-scout")})},m=y=>{var N,M;const v=(M=(N=y.target)==null?void 0:N.closest)==null?void 0:M.call(N,"[data-tip], [title]");if(!v||v instanceof SVGElement)return null;const j=v.getAttribute("title");return j&&(v.setAttribute("data-tip",j),v.removeAttribute("title")),v},g=y=>{if(y.pointerType==="touch")return;const v=m(y);v!==c&&(u(),v&&(c=v,a=window.setTimeout(()=>c===v&&f(v),y.type==="focusin"?0:gy)))},p=y=>{c&&!c.contains(y.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 $h({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(Ge,{className:`zone ${t.className??""}`,style:t.area?{gridArea:t.area}:void 0,children:[i.jsx(rn,{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 js(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 Vr(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 ky=864e5;function yy(t,s){const r=new Date(t),a=r.toTimeString().slice(0,5),c=new Date(s).toDateString(),u=new Date(s-ky).toDateString();let f=` ${r.toLocaleDateString(void 0,{month:"short",day:"numeric"})}`;return r.toDateString()===c?f="":r.toDateString()===u&&(f=" yesterday"),`Since ${a}${f} · ${Pt(s-t)}`}function xy(t){const{briefing:s,bp:r,onClose:a}=t;x.useEffect(()=>{const v=j=>j.key==="Escape"&&a();return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[a]);const c=s==null?void 0:s.trails.flatMap(v=>v.waiting).sort((v,j)=>v.at-j.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 j,N;return v.ticketId&&((N=(j=t.snaps[v.mapId])==null?void 0:j.tickets.find(M=>M.id===v.ticketId))==null?void 0:N.title)||v.text},p=v=>{var j,N;return v.ticketId&&((N=(j=t.snaps[v.mapId])==null?void 0:j.tickets.find(M=>M.id===v.ticketId))==null?void 0:N.key)||v.agent},y=v=>{const j=(I,O)=>i.jsx(Vr,{k:I.key,text:I.title,meta:O,onClick:()=>t.onTicket(v.mapId,I.id)},I.id),N=(I,O)=>i.jsx(Vr,{k:I.id,text:I.summary||I.answer,title:I.risk?`${I.question}
118
+
119
+ ${I.risk.reason}`:I.question,meta:O,onClick:()=>t.onDecision(I.id)},I.id),M=Dv(v.agentDecisions).flatMap(I=>I.decisions.map(O=>N(O,I.label))),S=[i.jsx(js,{title:"Done",children:v.done.map(I=>j(I))},"done"),i.jsx(js,{title:"Ruled out",children:m?[]:v.ruledOut.map(I=>j(I))},"oos"),i.jsx(js,{title:"Blocked",children:v.blocked.map(I=>j(I.ticket,`needs ${I.on.map(O=>O.key).join(", ")}`))},"blocked")],E=[i.jsx(js,{title:"Waiting on you",urgent:!0,children:v.waiting.map(I=>i.jsx(Vr,{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(js,{title:"Agent decisions",children:m?[]:M},"agent"),i.jsx(js,{title:"Active sessions",children:m?[]:v.active.map(I=>{var L;const O=I.ticketId?(L=t.snaps[v.mapId])==null?void 0:L.tickets.find(J=>J.id===I.ticketId):void 0;return i.jsx(Vr,{k:(O==null?void 0:O.key)??I.agent,text:O?`${O.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(Ge,{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(at,{className:"bf-since",children:yy(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:wy(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:`${ho(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(y)})]}),i.jsxs("footer",{children:[i.jsx(q,{onClick:a,children:"Dismiss"}),c?i.jsxs(q,{variant:"urgent",onClick:()=>t.onAnswer(c),children:[i.jsx(Ls,{variant:"alert",size:13}),"Answer first decision"]}):i.jsx(q,{variant:"primary",onClick:t.onResume,children:"Resume trail"})]})]})})}function wy(t){if(t!==void 0)return t<6e4?"Just asked":`Oldest ${Pt(t)}`}function jy(t){const{brief:s,bp:r}=t;return i.jsx(xy,{briefing:s.briefing,line:s.line,snaps:t.snaps,bp:r,onClose:s.dismiss,onTicket:(a,c)=>{s.dismiss(),t.openTicket(a,c)},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 Sy={passed:"checks passed",failing:"checks failing",pending:"checks pending",unknown:"checks unknown",none:"no checks"};function Ny({mapId:t,ticketId:s}){const r=Ms.ticket(Wl(),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:Sy[r.checksSummary]}),i.jsx("span",{className:"when",children:Cy(r)})]}),r.flags.map(c=>i.jsx(In,{className:`flag flag-${c.severity}`,title:c.text,children:c.kind},c.kind))]})}function Cy(t){return t.error?"sync failed":t.syncedAt?gh(t.syncedAt):"not synced yet"}const $y={ok:"ok",failed:"error",stale:"syncing",unknown:"idle",off:"idle"};function by({now:t}){const s=Wl();if(!s.reached)return null;const r=Kg(s.live?s.status:null,t);return i.jsxs("span",{className:`tracker-chip pr-sync tone-${r.tone}`,title:r.title,children:[i.jsx(at,{size:"sm",children:"CI"}),i.jsx(Ls,{variant:"status",state:$y[r.tone],size:13,className:"sync-glyph"}),i.jsx("span",{className:"tl",children:r.label})]})}function Ty(t){const[s,r]=x.useState(!1),a=x.useRef(null);return x.useEffect(()=>{if(!s)return;const c=u=>{var m;(u instanceof KeyboardEvent?u.key==="Escape":!((m=a.current)!=null&&m.contains(u.target)))&&r(!1)};return window.addEventListener("mousedown",c),window.addEventListener("keydown",c),()=>{window.removeEventListener("mousedown",c),window.removeEventListener("keydown",c)}},[s]),i.jsxs("div",{className:"header-menu",ref:a,children:[i.jsxs(q,{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 Ey={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 My(t){const s=t.briefingStatus==="new";return i.jsx(Ty,{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:Ey[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})]})]})})}const Iy=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"})]}),Ay=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 Ly({onToggle:t}){const s=po(),r=s?"Switch to the day theme":"Switch to the night theme";return i.jsx(q,{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?Iy:Ay})})}const Ry={idle:"Idle",syncing:"Syncing",ok:"Synced",error:"Sync error"};function _y({label:t,health:s,now:r}){const a=[`${Ry[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(at,{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 Oy(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 c=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(to,{n:f,urgent:!0}),i.jsx("span",{className:"caret",children:"▾"})]}),s&&i.jsxs("div",{className:"trail-menu",role:"menu",children:[i.jsx(at,{variant:"plain",className:"menu-h",children:"Trails"}),c.map(m=>{var y;const g=eh(m),p=u(m.map.id);return i.jsxs("button",{role:"menuitem",className:`trail-item ${m.map.id===((y=t.map)==null?void 0:y.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(to,{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 Py(t){const{map:s}=t,r=Mn(1e3),a=t.activity.pending.length,c=s&&t.snaps[s.id],u=c&&eh(c),f=s&&th(t.activity,s.id);return i.jsxs(Ge,{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(Oy,{...t})]}),i.jsxs("div",{className:"h-dest",title:s==null?void 0:s.sections.destination,children:[i.jsx(at,{size:"sm",children:"Destination"}),(s==null?void 0:s.sections.destination)??"—"]})]}),i.jsxs("div",{className:"h-right",children:[i.jsx(_y,{label:t.trackerLabel,health:t.health,now:r}),i.jsx(by,{now:r}),s&&u&&i.jsxs("span",{className:"trail-meta",children:[i.jsx(Vt,{label:"Trail T+",value:ph(r-s.createdAt),title:"Trail elapsed time, since it was charted"}),i.jsx(Vt,{label:"Done",value:`${u.decided}/${u.total}`}),f&&i.jsx(Vt,{className:"spend",label:"Spent",value:`${Ts(f.costUsd)} · ${ho(f.inputTokens+f.outputTokens)} tok`,title:["Model spend and tokens for this trail, across every session",...sh(t.activity,s.id).map(m=>nh[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(q,{size:"sm",variant:"urgent",onClick:t.onSlack,title:t.slackAlert,children:"Slack disconnected"}),s&&i.jsx(q,{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(My,{decisions:t.decisions,onDecisions:t.onDecisions,knowledge:t.knowledge,onKnowledge:t.onKnowledge,briefingOpen:t.briefingOpen,briefingStatus:t.briefingStatus,onBriefing:t.onBriefing}),i.jsx(Ly,{onToggle:t.onToggleTheme}),i.jsx(q,{variant:"ghost",onClick:t.onSettings,"data-tip":"Tracker, verification, appearance and integrations",children:"Settings"})]})]})}const Th=x.createContext(null);function Rs(){const t=x.useContext(Th);if(!t)throw new Error("useKnowledge needs a KnowledgeContext provider");return t}function Dy({snap:t,t:s}){const r=Rs();if(!r.entries.length||s.state==="closed")return null;const a=ah(r.entries,{trailKey:t.map.key,ticket:{type:s.type,title:s.title,body:s.body},paths:lh(`${s.body}
123
+ ${r.briefText}`)},4e3,c=>r.stale[c.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(c=>i.jsxs("li",{children:[i.jsx("button",{className:"item-text kn-open",onClick:()=>r.setOpen(!0),"data-tip":c.why.join(" · "),children:c.title}),i.jsx(ge,{parts:[{text:c.id,code:!0},c.status==="assumption"&&"assumption",c.mayBeOutdated&&{text:"may be outdated",className:"warn"}]})]},c.id))})]})}const zy={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 By({e:t}){const s=Rs(),[r,a]=x.useState(!1),[c,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:c,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:zy[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(q,{variant:"ghost",onClick:()=>a(!1),children:"Cancel"}),i.jsx(q,{variant:"primary",disabled:!c.trim(),onClick:()=>void s.call(t.id,{kind:"edit",title:c,body:f}).then(p=>p&&a(!1)),children:"Save"})]}):i.jsxs(i.Fragment,{children:[(t.status!=="confirmed"||g)&&i.jsx(q,{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(q,{onClick:()=>void s.call(t.id,{kind:"assumption"}),children:"Keep as assumption"}),t.flag&&i.jsx(q,{onClick:()=>void s.call(t.id,{kind:"resolve-flag"}),children:"Resolve flag"}),i.jsx(q,{variant:"ghost",onClick:()=>a(!0),children:"Edit"}),t.status!=="outdated"&&i.jsx(q,{variant:"ghost",onClick:()=>void s.call(t.id,{kind:"outdated"}),children:"Mark outdated"})]})})]})}const Fy={suggested:"Suggested",confirmed:"Confirmed",assumption:"Assumption",outdated:"Outdated"};function Uy(){const t=Rs(),[s,r]=x.useState("review"),[a,c]=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",y=(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=>y(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 j=v.find(S=>S.id===m)??v[0],N=S=>t.entries.filter(E=>y(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(Ge,{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:c,options:[{value:"",label:"Any kind"},...Mv.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(gt,{as:"li",className:`kn-row st-${S.status}`,edge:p(S)?"attention":"neutral",selected:S===j,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":Fy[S.status]]})},S.id)):i.jsx(Be,{children:s==="review"?"Nothing needs you":"No entries"})}),j?i.jsx(By,{e:j}):i.jsx(Be,{children:"Pick an entry"})]})]})})}function Vl({draft:t,label:s="Save as knowledge"}){const r=Rs(),[a,c]=x.useState();return a?i.jsxs(q,{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(q,{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&&c(u.id)),children:s})}const Eh=`${ne.apiPrefix}/knowledge`;async function Nf(t,s){const r=await fetch(`${Eh}${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 Wy(t){const[s,r]=x.useState([]),[a,c]=x.useState({}),[u,f]=x.useState(!1),[m,g]=x.useState(),p=x.useCallback(()=>{fetch(Eh).then(v=>v.ok?v.json():null).then(v=>{v&&(r(v.entries),c(v.stale))}).catch(()=>{})},[]);x.useEffect(()=>(p(),As(v=>v.startsWith("knowledge/")&&p())),[p]);const y=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:y,open:u,setOpen:f,error:m,call:(v,j)=>Nf("/call",{id:v,call:j}).then(()=>(g(void 0),p(),!0),N=>(g(N.message),!1)),propose:v=>Nf("/propose",v).then(j=>(p(),j.entry),j=>(g(j.message),void 0))}}function bl(t){const[s,r]=x.useState(!1),[a,c]=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(q,{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),c("")},children:[i.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,autoFocus:!0,value:a,placeholder:t.placeholder,"aria-label":"Token",onChange:f=>c(f.target.value)}),i.jsx(q,{type:"submit",disabled:t.busy||!a.trim(),children:"Save"})]}):i.jsx("button",{type:"button",className:"link",onClick:()=>r(!0),children:"Type it instead"})]})}const Hy=["awaiting","blocked","trail.done","resolved"],Ky=["commands","chat:write","im:write","channels:history","groups:history","im:history","mpim:history","users:read"],Vy=["users:read.email"],Qy="save_decision",qy=`/${ne.assistant.name.toLowerCase()}`;function Gy(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??qy,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:Qy,description:`Record this thread as a ${ne.name} decision`}]},oauth_config:{scopes:{bot:[...Ky,...Vy]}},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 Yy={create:t=>`https://api.slack.com/apps?new_app=1&manifest_json=${encodeURIComponent(JSON.stringify(Gy({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 Jy(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)}),c=await a.json().catch(()=>({}));if(!a.ok&&!c.status)throw new Error(c.error??`request failed (${a.status})`);return c}function Xy(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 Tn=Xy(ne.apiPrefix);function Zy(t){const[s,r]=x.useState(!1),[a,c]=x.useState(),u=f=>{r(!0),Tn.token(f).then(m=>{r(!1),c(m.ok?void 0:m.error),t.set(m.status)},m=>{r(!1),c(m.message)})};return i.jsxs(i.Fragment,{children:[i.jsx(bl,{busy:s,placeholder:"xapp-… or xoxb-…",onToken:u}),a&&i.jsxs("div",{className:"test-line alert",children:["✕ ",a]})]})}function ex({onRemoved:t}){const[s,r]=x.useState(!1);if(!s)return i.jsx(q,{size:"sm",variant:"ghost",onClick:()=>r(!0),children:"Remove"});const a=()=>void Tn.remove().then(c=>{r(!1),t(c)},()=>{});return i.jsxs(i.Fragment,{children:[i.jsx(q,{size:"sm",variant:"danger",onClick:a,children:"Remove tokens and settings"}),i.jsx(q,{size:"sm",variant:"ghost",onClick:()=>r(!1),children:"Keep"})]})}const tx={awaiting:"Awaiting you",blocked:"Blocked","trail.done":"Trail done",resolved:"Resolved"};function Mh({s:t}){const[s,r]=nx(t);return i.jsxs("div",{className:`sync-line ${s}`,title:t.error,children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:r})]})}function nx(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 sx(t){const{s,setup:r}=t,a=s.step==="done";return i.jsxs(Et,{className:rx(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(In,{className:s.enabled?"on":"",children:s.enabled?"On":"Off"})]}),a&&i.jsx("div",{className:"c-loc",children:ix(s)}),a&&i.jsx(Mh,{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(q,{size:"sm",variant:"primary",onClick:()=>t.onSetup(!0),children:s.step===1?"Connect":`Resume at step ${s.step}`}),a&&i.jsx(q,{size:"sm",on:s.enabled,onClick:t.onToggle,children:s.enabled?"Turn off":"Turn on"}),a&&s.state==="auth-error"&&i.jsx(q,{size:"sm",variant:"primary",onClick:()=>t.onSetup(!0),children:"Reconnect"}),s.step!==1&&i.jsx(ex,{onRemoved:t.onRemoved})]})]})}function ix(t){var r,a,c;const s=(a=(r=t.workspace)==null?void 0:r.url)==null?void 0:a.replace(/^https?:\/\/|\/$/g,"");return[(c=t.workspace)==null?void 0:c.name,s,t.setup.appId].filter(Boolean).join(" · ")}function rx(t,s){const r=t.step==="done";return`connector ${r&&t.enabled?"active":""} ${s||!r?"open":""}`}function ox(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:c=>{c.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:c=>r(c.target.value)}),i.jsx(q,{type:"submit",disabled:!a||s.trim()===t.value,children:"Save"})]})}function ax(t){const[s,r]=x.useState(),[a,c]=x.useState();x.useEffect(()=>{Tn.members().then(r,m=>c(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(pt,{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 lx(t){const{s,patch:r}=t,[a,c]=x.useState(!1),u=new Set(s.notify.events),f=a||s.notify.target!=="dm",m=s.owners[0],g=p=>{const y=u.has(p)?s.notify.events.filter(v=>v!==p):[...s.notify.events,p];r({notify:{events:y}})};return i.jsxs("div",{className:"sl-groups",children:[i.jsxs("div",{className:"sl-group",children:[i.jsx(at,{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 Tn.resetOwner().then(t.set,()=>{}),children:"Not you? Reset"})]})]}),i.jsxs("div",{className:"sl-group",children:[i.jsx(at,{variant:"plain",size:"sm",children:"Allowed users"}),i.jsx(ax,{value:s.allow,owners:s.owners,onChange:p=>r({allow:p})})]}),i.jsxs("div",{className:"sl-group",children:[i.jsx(at,{variant:"plain",size:"sm",children:"Notify"}),i.jsxs("div",{className:"choice-row compact",children:[i.jsx(pt,{on:!f,title:"DM to owner",onClick:()=>{c(!1),r({notify:{target:"dm",detail:"full"}})}}),i.jsx(pt,{on:f,title:"Channel",sub:s.notify.target!=="dm"?s.notify.target:void 0,onClick:()=>c(!0)})]}),f&&i.jsxs(i.Fragment,{children:[i.jsx(He,{label:"Channel ID (invite @Scout there first)",children:i.jsx(ox,{value:s.notify.target,onSave:p=>r({notify:{target:p}})})}),i.jsxs("div",{className:"choice-row compact",children:[i.jsx(pt,{on:s.notify.detail==="full",title:"Full questions",onClick:()=>r({notify:{detail:"full"}})}),i.jsx(pt,{on:s.notify.detail==="titles-only",title:"Titles only",onClick:()=>r({notify:{detail:"titles-only"}})})]})]}),i.jsx("div",{className:"choice-row compact",children:Hy.map(p=>i.jsx(pt,{on:u.has(p),title:tx[p],onClick:()=>g(p)},p))})]}),i.jsx(no,{className:"dim",parts:[`${s.command} decide`,`${s.command} status`,`${s.command} inbox`,"Save as decision on any message"]})]})}function Qr(t){return i.jsx("a",{className:`btn ${t.primary?"primary":""}`,href:t.href,target:"_blank",rel:"noreferrer",onClick:t.onClick,children:t.children})}function cx({s:t,n:s}){const r=ux(t,s);return r?i.jsx("span",{className:"t-meta",children:r}):null}function ux(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 c=r.via==="git-email"?" · git email":"";return`owner ${r.name??r.id}${c}`}}const Cf=[{n:1,title:"Create app"},{n:2,title:"Workspace"},{n:3,title:"App token"},{n:4,title:"Install"},{n:5,title:"Claim"}],Ql=(t,s)=>t===s||t===2&&s===3,Ih=(t,s)=>t==="done"||typeof t=="number"&&s<t&&!Ql(t,s);function $f(t,s){return Ih(t,s)?"done":Ql(t,s)?"cur":""}const dx=/^(xapp-|xoxb-|xoxp-|xoxe)/,fx=typeof navigator<"u"&&/Mac|iP(hone|ad)/.test(navigator.platform)?"⌘V":"Ctrl+V";function hx(t){const s=x.useRef(t);s.current=t;const[r,a]=x.useState(!1);return x.useEffect(()=>{let c="";const u=(g,p)=>{const y=g.trim();return!dx.test(y)||!p&&y===c?!1:(c=y,s.current(y,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 mx(t){var S;const{s,set:r}=t,[a,c]=x.useState(),[u,f]=x.useState(!1),[m,g]=x.useState(!1),p=(E,I)=>{const O=Jy(E);I&&O&&!s.setup.botToken&&window.open(Yy.install(O),"_blank")&&g(!0),f(!0),Tn.token(E).catch(L=>({ok:!1,error:L.message,status:s})).then(L=>{f(!1),c(L),r(L.status)})},v=hx(p)?"come back to this tab":`press ${fx} here`,j=s.step,N=E=>{if(!a)return null;const I=!a.ok&&E===4==(j===4);return a.kind===(E===4?"bot":"app")||I?i.jsx("div",{className:`test-line ${a.ok?"ok":"alert"}`,children:px(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(Qr,{primary:!0,href:s.links.create,onClick:()=>void Tn.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(bl,{busy:u,placeholder:"xapp-…",onToken:p})}),N(3),i.jsx(no,{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(Qr,{primary:!m,href:s.links.install,children:m?"Open install page again":"Install to workspace"}),i.jsx(bl,{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(Qr,{primary:!0,href:s.links.home,children:"Open Scout in Slack"}),s.links.homeWeb&&i.jsx(Qr,{href:s.links.homeWeb,children:"Open in browser"})]}),i.jsx(Mh,{s})]})};return i.jsxs(Et,{tone:"inset",className:"slack-setup",children:[i.jsx("ol",{className:"pipeline sl-pipeline","aria-label":"Slack setup",children:Cf.map(E=>i.jsxs("li",{className:$f(j,E.n),children:[i.jsx("i",{}),i.jsxs("span",{children:[E.n," ",E.title]})]},E.n))}),i.jsx("ol",{className:"sl-steps",children:Cf.map(E=>{const I=Ih(j,E.n),O=Ql(j,E.n);return i.jsxs("li",{className:$f(j,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(cx,{s,n:E.n})]}),O&&i.jsx("div",{className:"sl-step-b",children:M[E.n]})]},E.n)})})]})}function px(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 ql(t=0){const[s,r]=x.useState(),a=x.useCallback(()=>Tn.get().then(r,()=>r(null)),[]);return x.useEffect(()=>{if(a(),!t)return;const c=setInterval(()=>void a(),t);return()=>clearInterval(c)},[a,t]),[s,r]}function gx(t){const[s,r]=ql(3e3),[a,c]=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=>Tn.update(g).then(r,()=>{});return i.jsxs("div",{ref:u,className:"slack-settings",children:[i.jsx(sx,{s,setup:a,onSetup:c,onToggle:()=>void m({enabled:!s.enabled}),onRemoved:g=>{r(g),c(!1)}}),!f&&(a||s.step!==1)&&i.jsx(mx,{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(Zy,{set:r})]}),f&&i.jsx(lx,{s,set:r,patch:g=>void m(g)})]})}function vx(t){const{api:s,rt:r,brief:a}=t,{snap:c,actions:u}=s,[f]=ql(15e3),m=Rs(),g=f!=null&&f.enabled&&f.state==="auth-error"?f.error??"Slack rejected the tokens":void 0;return i.jsx(Py,{repo:t.repo,snaps:s.allSnaps,map:c==null?void 0:c.map,activity:s.activity,health:s.health,onNewTrail:t.onNewTrail,trackerLabel:r.adapter.label.toLowerCase(),onSelectMap:u.selectMap,onToggleMode:()=>c&&u.setMode(c.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,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 kx(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,Dl(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 yx(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 xx({id:t,text:s}){const[r,a]=x.useState(),c=r!==t;return i.jsx(Li,{size:1,framed:!1,state:c?"speaking":"alert",speaking:c?s.slice(0,60):void 0,onSpeakEnd:()=>a(t),className:"q-avatar"})}function wx(t){const{q:s}=t;return i.jsxs("div",{className:"msg open-q",children:[i.jsx(ge,{parts:[s.agent,Dl(s.at)]}),i.jsx(xx,{id:t.chatId??s.id,text:s.text}),i.jsx("div",{className:"msg-text",children:s.text})]})}function jx(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 Sx(t){const{activity:s,sessionId:r}=t,[a,c]=x.useState(""),[u,f]=x.useState(),m=x.useRef(null),g=x.useRef(null),p=s.sessions.find(L=>L.id===r),y=s.chats.filter(L=>L.sessionId===r),v=ny(s.pending,r,u??t.questionId),j=new Set(s.pending.filter(L=>L.sessionId===r).map(L=>L.id)),N=y.find(L=>!!v&&L.questionId===v.id),M=y.filter(L=>L!==N),S=p?t.snaps[p.mapId]:void 0,E=p!=null&&p.ticketId?S==null?void 0:S.tickets.find(L=>L.id===p.ticketId):void 0;x.useEffect(()=>{const L=m.current;L==null||L.scrollTo({top:L.scrollHeight,behavior:"smooth"})},[M.length,v==null?void 0:v.id]),x.useEffect(()=>{var L;v&&!t.onBack&&((L=g.current)==null||L.focus({preventScroll:!0}))},[v==null?void 0:v.id,t.onBack]);const I=L=>{!v||!L.trim()||(t.onAnswer(v.id,L.trim()),c(""))},O=Nx(p,!!v);return i.jsxs("div",{className:`comms ${v?"asking":""}`,children:[i.jsx(rn,{title:"HITL line",right:p?i.jsx("span",{className:`status ${v?"urgent":""}`,children:O}):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(yx,{ticket:E,trail:S==null?void 0:S.map.title,agent:p.agent}),i.jsx("div",{className:"comms-log",ref:m,children:M.map(L=>i.jsx(kx,{m:L,stillOpen:!!L.questionId&&j.has(L.questionId),onAnswerThis:()=>f(L.questionId)},L.id))}),v&&i.jsx(wx,{q:v,chatId:N==null?void 0:N.id}),i.jsx(jx,{options:v==null?void 0:v.suggestions,onPick:I}),i.jsx(cy,{ref:g,className:"comms-input",value:a,onValueChange:c,onSubmit:I,disabled:!v,placeholder:v?"Answer":""})]}):i.jsx(Be,{children:"No conversation"})]})}function Nx(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 Cx(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 $x({item:t}){const[s,r]=x.useState(!1),[a,c]=x.useState(),u=()=>{r(!0),c(void 0),Cx(t).then(c,f=>c(f.message)).finally(()=>r(!1))};return i.jsxs("div",{className:"att-action",children:[i.jsx(q,{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 bx=/(\S*\/\S*|#\d+)/g;function Tx({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(bx).map((a,c)=>c%2===1?i.jsx("span",{className:"t-code",children:a},c):a)]},s))}):null}const Ex={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"},Mx={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"},Ix=[{minutes:30,label:"30 min"},{minutes:120,label:"2 hours"},{minutes:1440,label:"Tomorrow"}],Ax=["blocked","flag","stalled","policy","reroute","overlap","integration"];function Lx(t,s){return s||t.urgency==="blocking"?"urgent":Ax.includes(t.kind)?"attention":"neutral"}const Rx=[/^marked blocking$/,/^fyi\b/,/^soon\b/,/^waiting \d/,/^answer together/,/questions from /];function _x(t){return t.reasons.filter(s=>!Rx.some(r=>r.test(s)))}function Ox(t){const{item:s,snap:r}=t,a=r==null?void 0:r.tickets.find(m=>m.id===s.ticketId),c=s.kind==="question"&&s.agent?`${s.agent} asks`:Ex[s.kind],u=[];s.urgency==="blocking"&&u.push({text:"Blocking",urgent:!0,className:"urgency-tag"}),u.push({text:c,strong:!0});const f=a&&Px(s.title,a);return f&&u.push(f),t.otherTrail&&u.push((r==null?void 0:r.map.title)??s.mapId),u}function Px(t,s){if(!t.includes(s.key))return t.includes(s.title)?{text:s.key,code:!0}:`${s.key} ${s.title}`}function Dx(t){const[s,r]=x.useState(!1),a=c=>{r(!1),c()};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:[Ix.map(c=>i.jsx("button",{type:"button",role:"menuitem",onClick:()=>a(()=>t.onSnooze(c.minutes)),children:c.label},c.minutes)),t.canDismiss&&i.jsx("button",{type:"button",role:"menuitem",onClick:()=>a(t.onDismiss),children:"Set aside"})]})]})}const zx=15e3;function Bx(t){const{item:s}=t,r=s.title.split(`
124
+ `)[0],a=_x(s),c=t.now-s.since<zx;return i.jsx(gt,{as:"li",className:`att-item k-${s.kind} u-${s.urgency} ${t.selected?"sel":""} ${c?"incoming":""}`,edge:Lx(s,t.interrupting),selected:t.selected,title:r,titleText:s.title,context:i.jsx(ge,{parts:Ox({item:s,snap:t.snap,otherTrail:t.otherTrail})}),detail:a.length>0&&i.jsx(Tx,{reasons:a}),detailText:a.join(`
125
+ `),trailing:Gn(t.now-s.since),onOpen:t.onOpen,actions:i.jsx(Dx,{title:s.title,canDismiss:Fv(s),onSnooze:t.onSnooze,onDismiss:t.onDismiss}),below:s.kind==="integration"&&i.jsx($x,{item:s})})}function Fx(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 Ux={question:"inbox-list",approval:"inbox-list approvals"};function Wx(t){const{batch:s}=t,r=s.items.length>1,a=s.kind==="question"?"answer together":"review together",c=[`${s.items.length} ${Mx[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:c.join(" · ")}),i.jsx("ul",{className:`att-list ${Ux[s.kind]??""}`,children:t.children})]})}function Hx(t,s){t.ticketId?s.openTicket(t.mapId,t.ticketId):s.selectTrail(t.mapId)}function Kx(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 Hx(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 Vx(t){const s=Mn(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,c=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:Fx(r.items).map(m=>{var g;return i.jsx(Wx,{batch:m,trail:c(m.mapId)?(g=t.snaps[m.mapId])==null?void 0:g.map.title:void 0,children:m.items.map(p=>i.jsx(Bx,{item:p,snap:t.snaps[p.mapId],otherTrail:c(p.mapId)&&m.items.length<2,selected:p.kind==="question"&&f(p.ref)===t.selected,interrupting:u.has(p.id),now:s,onOpen:()=>Kx(p,t.handlers),onSnooze:y=>t.onSnooze(p.id,y),onDismiss:()=>t.onDismiss(p.id)},p.id))},m.key)})})}const Qx=60*6e4;function qx(t){const{view:s}=t,r=(s.prefs.focusUntil??0)>Date.now(),a=s.interrupting.length,c=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(q,{variant:"ghost",className:"focus-btn",on:s.focused,"aria-pressed":s.focused,"data-tip":c,onClick:()=>t.onFocus(r?void 0:Date.now()+Qx),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 Ah=`${ne.apiPrefix}/attention`,Gx=250;async function bf(t,s,r){var u;const a=await fetch(`${Ah}${t}`,{method:s,headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),c=await a.json().catch(()=>({}));if(!a.ok)throw new Error(((u=c.errors)==null?void 0:u.join("; "))??c.error??`HTTP ${a.status}`);return c}function Lh(t){const[s,r]=x.useState(),[a,c]=x.useState(),u=x.useCallback(()=>{fetch(Ah).then(m=>m.ok?m.json():void 0).then(m=>m&&r(m)).catch(()=>{})},[]);x.useEffect(()=>Sh("attention",m=>r(JSON.parse(m))),[]),x.useEffect(()=>{const m=setTimeout(u,Gx);return()=>clearTimeout(m)},[u,t]);const f=(m,g)=>void bf(m,"POST",g).then(()=>(c(void 0),u()),p=>c(p.message));return{view:s,error:a,snooze:(m,g)=>f("/snooze",{id:m,minutes:g}),dismiss:m=>f("/dismiss",{id:m}),savePrefs:m=>bf("/prefs","PUT",m).then(()=>(c(void 0),u(),!0),g=>(c(g.message),!1))}}function Yx(t){return t.prefs.channel!=="browser"?!1:typeof Notification<"u"&&Notification.permission==="granted"}function Jx(t){const s=new Notification(`${ne.name} · needs you`,{body:t.title,tag:t.id});s.onclick=()=>{window.focus(),s.close()}}function Xx(t){const s=x.useRef();x.useEffect(()=>{if(!t)return;const r=new Set(t.interrupting),a=s.current;if(s.current=r,!(!a||!Yx(t)))for(const c of t.items)r.has(c.id)&&!a.has(c.id)&&Jx(c)},[t])}function Zx(t){const s=Mn(1e3);return t.items.length?i.jsx("ul",{className:"inbox-list approvals",children:t.items.map(r=>{var u;const a=r.kind!=="approve",c=r.mapId!==t.currentMapId?(u=t.snaps[r.mapId])==null?void 0:u.map.title:void 0;return i.jsx(gt,{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},c]}),detail:r.reason,detailText:r.reason,trailing:Gn(s-r.at),onOpen:()=>t.onOpen(r.mapId,r.ticketId)},`${r.mapId}/${r.ticketId}`)})}):null}function Tf({activity:t}){const s=Mn(1e3),r=ev(t);return i.jsxs("div",{className:"hitl-readout",children:[i.jsx(Vt,{layout:"inline",label:"Oldest",value:r.oldestAt?Pt(s-r.oldestAt):"—",urgent:!!r.oldestAt&&s-r.oldestAt>6e4,title:"Oldest open question"}),i.jsx(Vt,{layout:"inline",label:"Avg wait",value:r.avgWaitMs!==void 0?Pt(r.avgWaitMs):"—",title:`Average wait over ${r.answered} answered questions`}),i.jsx(Vt,{layout:"inline",label:"Answered",value:r.answered})]})}function ew(t){const s=Mn(1e3);return t.items.length?i.jsx("ul",{className:"inbox-list",children:t.items.map(r=>{const a=t.snaps[r.mapId],c=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(gt,{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`,c&&{text:c.key,code:!0},c==null?void 0:c.title,u]}),trailing:Gn(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 tw={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"},Rh={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."},nw=t=>t.exitCode===0&&!t.timedOut&&!t.error;async function Ef(t){const s=await t.json().catch(()=>({}));if(!t.ok)throw new Error(s.error??`HTTP ${t.status}`);return s}const qr=`${ne.apiPrefix}/verification`,_i={ticket:(t,s)=>fetch(`${qr}/ticket?mapId=${encodeURIComponent(t)}&ticketId=${encodeURIComponent(s)}`).then(r=>r.ok?r.json():void 0,()=>{}),inbox:()=>fetch(`${qr}/inbox`).then(t=>t.ok?t.json().then(s=>s.items):[],()=>[]),log:t=>fetch(`${qr}/log?path=${encodeURIComponent(t)}`).then(s=>Ef(s)),act:t=>fetch(`${qr}/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).then(s=>Ef(s))};function sw(t){const[s,r]=x.useState([]),a=Object.values(t).map(c=>c.tickets.map(u=>`${u.id}:${u.state}:${u.status??""}`).join()).join("|");return x.useEffect(()=>{let c=!0;const u=()=>void _i.inbox().then(m=>c&&r(m));u();const f=Ms.onEvidence(u);return()=>{c=!1,f()}},[a]),s}function iw(t,s){return{...t,items:t.items.filter(r=>!(r.kind==="brief"&&r.mapId===s))}}function rw(t){var m;const s=[...t.activity.pending].sort((g,p)=>g.at-p.at),r=sw(t.snaps),a=(m=t.attention)==null?void 0:m.view,c=a&&t.briefShown?iw(a,t.currentMapId):a,u=c?c.items.length:s.length+r.length,f=i.jsx(rn,{hot:u>0,title:i.jsxs(i.Fragment,{children:[u>0&&i.jsx(Ls,{variant:"alert",size:12}),"Waiting on you"]}),count:i.jsx(to,{n:u,urgent:u>0,pop:!0},u)});return c&&t.attention&&t.handlers?i.jsxs("div",{className:"inbox-part",children:[f,i.jsx(Tf,{activity:t.activity}),i.jsx(Vx,{view:c,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(Tf,{activity:t.activity}),i.jsx(Zx,{items:r,snaps:t.snaps,currentMapId:t.currentMapId,onOpen:t.onOpenTicket}),(s.length>0||!r.length)&&i.jsx(ew,{items:s,snaps:t.snaps,currentMapId:t.currentMapId,selected:t.sessionId,onOpen:t.onOpenQuestion})]})}function ow(t){const[s,r]=x.useState("list"),[a,c]=x.useState();x.useEffect(()=>{t.convRequest&&r("conv")},[t.convRequest]);const u=(y,v)=>{t.onOpen(y,v),r("conv")},f=y=>{const v=t.activity.pending.find(j=>j.id===y);v&&(c(v.id),u(v.sessionId,v.ticketId))},m=i.jsx(rw,{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(Sx,{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(Ge,{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(y=>y.id===t.sessionId);return i.jsxs(Ge,{className:`zone inbox split ${p?"has-conv":""}`,style:{gridArea:"inbox"},children:[i.jsx(rn,{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 aw(t){var m;const{snap:s}=t,r=s?Is(s.tickets,s.map.mode):new Map,a={claimed:0,frontier:1},c=((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(Nh).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(rn,{title:"Up next",count:i.jsx("span",{className:"n mono-label",children:c.length})}),!s&&i.jsx(Be,{children:"Ready tickets show here"}),s&&!c.length&&i.jsx(Be,{children:"Nothing ready"}),s&&c.length>0&&i.jsx("ul",{className:"ticket-list",children:c.map(g=>{const p=r.get(g.id),y=lw({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:y})]})},g.id)})})]})}function lw(t){if(t.waiting)return"waiting on you";if(t.state==="claimed")return t.assignee??"claimed";const s=kh[t.state].toLowerCase();return t.hitl?`${s}, needs you`:s}function cw(t){const{api:s,nav:r}=t;return i.jsx(ow,{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(aw,{snap:s.snap,sessions:t.scoped.sessions,selection:s.selection,onSelect:r.select}),above:t.above})}function so({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 Gr=[{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"}],uw=9e3;function dw(){const[t,s]=x.useState(0),[r,a]=x.useState(!1);x.useEffect(()=>{if(r)return;const u=setInterval(()=>s(f=>(f+1)%Gr.length),uw);return()=>clearInterval(u)},[r]);const c=Gr[t];return i.jsxs("div",{className:"command-bar real",children:[i.jsx(Ch,{name:"map"}),i.jsx(at,{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:c.text}),c.command&&i.jsx(so,{command:c.command})]},t),i.jsxs("button",{type:"button",className:"link hint-next","data-tip":"Next hint","aria-label":"Next hint",onClick:()=>s(u=>(u+1)%Gr.length),children:[t+1,"/",Gr.length," ›"]})]})}function fw(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(pt,{on:t.value===r.v,title:r.title,onClick:()=>t.onChange(r.v)},r.v))})}function hw({onClose:t,tracker:s,onCreate:r}){const[a,c]=x.useState(),[u,f]=x.useState(!1),[m,g]=x.useState(),[p,y]=x.useState(""),[v,j]=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=L=>L.key==="Escape"&&t();return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[t]),i.jsx("div",{className:"scrim",onClick:t,children:i.jsxs(Ge,{as:"div",className:"dialog",onClick:O=>O.stopPropagation(),children:[i.jsx("header",{children:i.jsx("h2",{className:"t-heading caps",children:"New trail"})}),i.jsx(He,{label:"Title",children:i.jsx("input",{value:p,onChange:O=>y(O.target.value),autoFocus:!0})}),i.jsx(He,{label:"Destination",children:i.jsx("textarea",{rows:3,value:v,onChange:O=>j(O.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:O=>M(O.target.value)})}),i.jsx(He,{label:"Assumptions (optional, one per line)",children:i.jsx("textarea",{className:"new-trail-assumptions",rows:2,value:S,onChange:O=>E(O.target.value),placeholder:"What the plan takes for granted, e.g. The v2 API supports batch writes"})}),i.jsxs("div",{className:"agent-draft",children:[i.jsxs("span",{className:"dim",children:["Paste this in Claude Code or Codex. Scout frames the trail with you there, then charts it here in ",s,"."]}),i.jsx(so,{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(so,{command:"/scout resume",label:"Copy command"})]}):m&&i.jsx("p",{className:"vf-err",children:m}),i.jsxs("footer",{children:[i.jsx(q,{variant:"ghost",onClick:t,children:"Close"}),!a&&i.jsx(q,{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 O=S.split(`
127
+ `).map(L=>L.trim());r({title:p.trim(),destination:v.trim(),notes:N.trim(),assumptions:O.filter(Boolean)}).then(L=>c(L.key)).catch(L=>g(L.message)).finally(()=>f(!1))},children:"Create trail"})]})]})})}const Mf=["Ready when you are","What's the next big idea?","I keep the party on the trail","Describe it, I frame it"],mw=5e3;function pw(){const t=po(),[s,r]=x.useState(0),[a,c]=x.useState(!0);return x.useEffect(()=>{if(a)return;const u=setTimeout(()=>{r(f=>(f+1)%Mf.length),c(!0)},mw);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?Mf[s]:void 0,onSpeakEnd:()=>c(!1),className:"fm-avatar"}),i.jsx("span",{className:"fm-shadow"})]})}function gw(t){return i.jsx(hw,{onClose:t.onClose,tracker:t.rt.adapter.label,onCreate:async s=>{const r=await Hk(t.rt.adapter,s);return t.onCreated(r.id),r}})}const vw={stored:"Saved token",gh:"gh CLI",GITHUB_TOKEN:"$GITHUB_TOKEN",GH_TOKEN:"$GH_TOKEN",LINEAR_API_KEY:"$LINEAR_API_KEY"},Jr=t=>t==="github"||t==="linear";function _h(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:vw[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 Oh({r:t}){var a,c;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?`${(c=t.rate.remaining)==null?void 0:c.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 En=ik(ne.apiPrefix);function bi(t,s){t({tracker:s});const r=new URL(location.href);r.searchParams.delete("tracker"),location.href=r.toString()}function Ph(t){const s=t.s.github,[r,a]=x.useState(s.repo??s.detectedRepo??""),[c,u]=x.useState(""),[f,m]=x.useState(),[g,p]=x.useState(),y=x.useCallback(async()=>{p("test"),m(await En.test({kind:"github",repo:r,token:c||void 0}).catch(j=>({ok:!1,error:j.message}))),p(void 0)},[r,c]);x.useEffect(()=>{s.auth&&r&&y()},[]);const v=async()=>{p("connect");try{await En.connect({active:"github",github:{repo:r,token:c||void 0}}),t.onConnected()}catch(j){m({ok:!1,error:j.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:j=>a(j.target.value.trim())})]}),i.jsx(_h,{source:s.auth,value:c,onChange:u,label:"Token",placeholder:"ghp_… or github_pat_…",link:{href:"https://github.com/settings/personal-access-tokens/new",text:"New token"}}),i.jsx(Oh,{r:f}),i.jsxs("footer",{children:[i.jsx("button",{type:"button",className:"btn",disabled:!!g||!r,onClick:()=>void y(),children:g==="test"?"Testing…":"Test connection"}),i.jsx("button",{type:"button",className:"btn primary",disabled:!!g||!r||!s.auth&&!c,onClick:()=>void v(),children:g==="connect"?"Connecting…":"Connect"})]})]})}function Dh(t){var O;const s=t.s.linear,[r,a]=x.useState(""),[c,u]=x.useState(s.teamId??""),[f,m]=x.useState(s.projectId??""),[g,p]=x.useState(),[y,v]=x.useState([]),[j,N]=x.useState(),M=x.useCallback(async(L=c)=>{N("test");const J=await En.test({kind:"linear",apiKey:r||void 0,teamId:L||void 0}).catch(Z=>({ok:!1,error:Z.message}));p(J),J.teams&&(v(J.teams),!L&&J.teams.length===1&&u(J.teams[0].id)),N(void 0)},[r,c]);x.useEffect(()=>{s.auth&&M()},[]);const S=y.find(L=>L.id===c),E=(O=g==null?void 0:g.projects)==null?void 0:O.find(L=>L.id===f),I=async()=>{if(S){N("connect");try{await En.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(L){p({ok:!1,error:L.message}),N(void 0)}}};return i.jsxs("div",{className:"card inset tracker-setup",children:[i.jsx(_h,{source:s.auth,value:r,onChange:a,label:"API key",placeholder:"lin_api_…",link:{href:"https://linear.app/settings/account/security",text:"New key"}}),y.length>0&&i.jsxs("div",{className:"ts-row",children:[i.jsxs("label",{className:"field",children:["Team",i.jsx(wt,{"aria-label":"Team",value:c,onChange:L=>{u(L),m(""),M(L)},options:[...c?[]:[{value:"",label:"Choose…"}],...y.map(L=>({value:L.id,label:`${L.key} · ${L.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(L=>({value:L.id,label:L.name}))]})]})]}),i.jsx(Oh,{r:g}),i.jsxs("footer",{children:[i.jsx("button",{type:"button",className:"btn",disabled:!!j||!s.auth&&!r,onClick:()=>void M(),children:j==="test"?"Testing…":"Test connection"}),i.jsx("button",{type:"button",className:"btn primary",disabled:!!j||!S,onClick:()=>void I(),children:j==="connect"?"Connecting…":"Connect"})]})]})}function kw(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 yw({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,c]=xw(t,r);return i.jsxs("div",{className:`sync-line ${a}`,title:t.error,children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:c}),s&&i.jsx("span",{className:"rate",children:s})]})}function xw(t,s){switch(t.state){case"online":return["ok",`Online · synced ${gh(t.lastSyncAt)}${s}`];case"offline":return["warn",`Offline${s}`];case"rate-limited":return["warn",`Rate limited · resumes ${mo(t.resetAt)}${s}`];case"auth-error":return["alert",`Credentials rejected${s}`];default:return["",`Connecting${s}`]}}function ww(t){const{id:s,active:r,configured:a,s:c}=t,u=Jr(s),f=!u||!!c,m=["card connector",r?"active":"",f?"":"disabled",t.open?"open":""],g=(s==="markdown"||u)&&r,p=u&&!r&&a&&c?jw(s,c):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(yw,{status:c==null?void 0:c[s].status}),i.jsx(kw,{canSwitch:!r&&(!u||a),remote:u,usable:f,configured:a,open:t.open,onSwitch:t.onSwitch,onToggle:t.onToggle})]})}function jw(t,s){return t==="github"?s.github.repo:[s.linear.teamKey,s.linear.projectName].filter(Boolean).join(" · ")}function zh(t=0){const[s,r]=x.useState(),a=x.useCallback(()=>En.get().then(r,()=>r(null)),[]);return x.useEffect(()=>{if(a(),!t)return;const c=setInterval(()=>void a(),t);return()=>clearInterval(c)},[a,t]),[s,r,a]}function Sw(t){const[s]=zh(5e3),[r,a]=x.useState(null),c=async f=>{s&&(f==="markdown"||Jr(f))&&await En.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:rk.map(f=>{const m=f.id;return i.jsx(ww,{id:m,name:f.name,active:m===t.activeTracker,configured:Jr(m)&&u[m],open:r===m,location:t.location,s,onSwitch:()=>void c(m),onToggle:()=>Jr(m)&&a(r===m?null:m)},f.id)})}),s&&r==="github"&&i.jsx(Ph,{s,onConnected:()=>bi(t.update,"github")}),s&&r==="linear"&&i.jsx(Dh,{s,onConnected:()=>bi(t.update,"linear")})]})}function nt(t){return i.jsxs("section",{className:"set-sec",children:[i.jsx(at,{as:"h4",children:t.title}),t.children]})}function Bh(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(pt,{on:t.value===r.v,title:r.title,onClick:()=>t.onChange(r.v)},r.v))})}function Nw(t){const{prefs:s,update:r}=t,[a]=zh(),[c,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"},{id:"linear",title:"Linear"}],y=s.tracker==="github"&&!g||s.tracker==="linear",v=N=>{r({onboarded:!0}),bi(r,N)},j=async()=>{if(s.tracker==="github"&&g){m(!0);try{await En.connect({active:"github",github:{repo:g}})}catch(N){u(N.message),m(!1);return}}else s.tracker==="markdown"&&a&&await En.connect({active:"markdown"}).catch(()=>{});r({onboarded:!0}),s.tracker!==t.activeTracker&&bi(r,s.tracker)};return i.jsx("div",{className:"scrim",children:i.jsxs(Ge,{as:"div",className:"dialog onboarding",children:[i.jsxs("div",{className:"onb-brand",children:[i.jsx(my,{size:64}),i.jsx($h,{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(at,{children:[i.jsx(Hl,{className:"voice-badge"})," ",ne.assistant.name]})," ","Where should your trails live?"]}),i.jsxs(nt,{title:"Tracker",children:[i.jsx("div",{className:"choice-row",children:p.map(N=>i.jsx(pt,{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(Ph,{s:a,onConnected:()=>v("github")}),a&&s.tracker==="linear"&&i.jsx(Dh,{s:a,onConnected:()=>v("linear")}),c&&i.jsxs("div",{className:"test-line alert",children:["✕ ",c]})]}),i.jsx(nt,{title:"HITL transcript",children:i.jsx(Bh,{value:s.hitlTranscript,onChange:N=>r({hitlTranscript:N})})}),i.jsx("footer",{children:i.jsx(q,{variant:"primary",disabled:f||y,onClick:()=>void j(),children:"Get started"})})]})})}const If={from:"18:00",to:"09:00"};function Cw(t){const s=t.focus!==void 0,r=t.focus??If;return i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Quiet hours"}),i.jsx(q,{size:"sm",on:s,"aria-pressed":s,onClick:()=>t.onChange(s?void 0:If),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 $w=[{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 bw(){typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()}function Tw(){const{view:t,error:s,savePrefs:r}=Lh(0);if(!t)return null;const a=t.policy.value,c=`${ne.dataDir}/attention.json`,u=m=>void r({...t.prefs,...m}),f=typeof Notification<"u"&&Notification.permission==="denied";return i.jsxs(nt,{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:$w,onChange:m=>{m==="browser"&&bw(),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(Cw,{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:[c,": ",m]},m))}),i.jsx(ge,{className:"set-hint",parts:[t.policy.exists?{text:c,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 Ew=[5,15,30,60];function Mw(t){const{value:s}=t;return i.jsxs("div",{className:"choice-row compact",children:[i.jsx(pt,{on:!s.enabled,title:"Off",onClick:()=>t.onChange({...s,enabled:!1})}),Ew.map(r=>i.jsx(pt,{on:s.enabled&&s.awayMinutes===r,title:`Away ${r} min`,onClick:()=>t.onChange({enabled:!0,awayMinutes:r})},r))]})}const Iw=[{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"]}],Aw=[{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"]}],Lw=[{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"]},...Iw];function Rw(){return i.jsxs("div",{className:"changelog",children:[i.jsxs("div",{className:"about",children:[i.jsx($h,{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(nt,{title:"Next",children:Aw.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))}),Lw.map(t=>i.jsx(nt,{title:`${t.version} · ${t.date}`,children:i.jsx("ul",{children:t.items.map(s=>i.jsx("li",{children:s},s))})},t.version))]})}const Af={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"},_w={low:"the agent decides",medium:"the agent decides and records it",high:"you decide"},Ow=t=>t[0].toUpperCase()+t.slice(1),Tl=rh.map(t=>({value:t,label:Ow(t),hint:_w[t]}));function Pw(t){const[s,r]=x.useState(""),[a,c]=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:Tl,onChange:y=>f(u.map((v,j)=>j===p?{...v,level:y}:v))}),i.jsx("button",{className:"icon-btn","aria-label":`Remove ${g.glob}`,onClick:()=>f(u.filter((y,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:Tl,onChange:c}),i.jsx(q,{onClick:m,disabled:!s.trim(),children:"Add"})]})]})}const Fh=`${ne.apiPrefix}/policy`;async function Dw(){const t=await fetch(Fh);return t.ok?await t.json():null}function zw(){const[t,s]=x.useState(),r=x.useCallback(()=>{Dw().then(s,()=>s(null))},[]);x.useEffect(()=>(r(),As(c=>{c.endsWith("policy.json")&&r()})),[r]);const a=x.useCallback(async c=>{const u=await fetch(Fh,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)}),f=await u.json();if(!u.ok)return f.error??`Saving failed (${u.status})`;s(f)},[]);return{view:t,save:a}}function Bw(){const{view:t,save:s}=zw(),[r,a]=x.useState();if(!t)return null;const c=`${ne.dataDir}/policy.json`,u=f=>{a(void 0),s(f).then(a,m=>a(m.message))};return i.jsxs(nt,{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:ih.map(f=>i.jsxs("label",{className:"risk-row",children:[i.jsx("span",{children:Af[f]}),i.jsx(wt,{compact:!0,"aria-label":`${Af[f]} risk`,value:t.policy.categories[f],options:Tl,onChange:m=>u({...t.policy,categories:{...t.policy.categories,[f]:m}})})]},f))}),i.jsx(Pw,{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:[c," 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 ",c,", so your team shares it."]}),r&&i.jsx("span",{className:"vf-err",children:r})]})}function Fw(t){const[s]=ql();return s?i.jsx(nt,{title:"Slack",children:i.jsx(gx,{focus:t.focus})}):null}const Uw=[{value:"auto",title:"Match my system"},{value:"day",title:"Day"},{value:"night",title:"Night"}];function Ww(t){return i.jsx("div",{className:"choice-row compact",children:Uw.map(s=>i.jsx(pt,{on:t.value===s.value,title:s.title,onClick:()=>t.onChange(s.value)},s.value))})}function Hw(){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 Lf=`{
128
+ "v": 1,
129
+ "checks": {
130
+ "test": { "run": ["npm", "test"] },
131
+ "lint": { "run": ["npm", "run", "lint"] }
132
+ },
133
+ "run": ["test", "lint"]
134
+ }
135
+ `;function Kw({file:t}){const[s,r]=x.useState(!1),a=()=>void navigator.clipboard.writeText(Lf).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:Lf}),i.jsx(q,{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 Vw(t){const s=Hw(),[r,a]=x.useState();if(!s)return null;const c=t.map,u=s.config,f=`${ne.dataDir}/${s.file}`,m=(c==null?void 0:c.verification)??"off",g=(u??Jf).appliesTo.join(" and ");return i.jsxs(nt,{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."]}),c&&i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"set-field-label",children:["How much checking for trail ",c.key]}),i.jsx("div",{className:"choice-row vf-levels",children:_l.map(p=>i.jsx(pt,{on:m===p,title:Mi[p],sub:Rh[p],onClick:()=>{a(void 0),_i.act({action:"level",mapId:c.id,level:p,by:mt}).catch(y=>a(y.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(Kw,{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,y])=>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:y.run.join(" ")}),i.jsxs("span",{className:"dim",children:[y.timeoutSec," s",y.cwd&&y.cwd!=="."?` · in ${y.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 El=`${ne.apiPrefix}/workspaces`;async function Qw(){const t=await fetch(El);return t.ok?await t.json():null}function Uh(){const[t,s]=x.useState(),r=x.useCallback(()=>{Qw().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(El,{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)},[]),c=x.useCallback(async(u,f,m=!1)=>{const g=await fetch(`${El}/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:c}}function Wh(t){const[s,r]=x.useState(!1),[a,c]=x.useState(),[u,f]=x.useState(!1),m=async g=>{f(!0),c(void 0);const p=await t.onRemove(g).catch(y=>({error:y.message,dirty:!1}));f(!1),r(!!p.dirty&&!g),p.dirty||c(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(q,{size:"sm",disabled:u,onClick:()=>m(!0),children:"Remove anyway"}),i.jsx(q,{size:"sm",variant:"ghost",onClick:()=>r(!1),children:"Keep"})]}):i.jsxs("span",{className:"ws-remove",children:[i.jsx(q,{size:"sm",disabled:u,onClick:()=>m(!1),children:t.label??"Remove"}),a&&i.jsx("span",{className:"vf-err",children:a})]})}function qw(t){return t.rows.length?i.jsx("ul",{className:"ws-list",children:t.rows.map(s=>i.jsx(gt,{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(Wh,{onRemove:r=>t.onRemove(s.mapId,s.ticketId,r)})},`${s.mapId}/${s.ticketId}`))}):null}function Gw(t){const{view:s,remove:r}=Uh(),a=s==null?void 0:s.workspaces.find(c=>c.mapId===t.mapId&&c.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(Wh,{label:"Remove workspace",onRemove:c=>r(t.mapId,t.ticketId,c)})]})}function Yw(){const{view:t,save:s,remove:r}=Uh(),[a,c]=x.useState();if(!t)return null;const u=t.settings.worktrees,f=()=>{c(void 0),s({...t.settings,worktrees:!u}).then(c,m=>c(m.message))};return i.jsxs(nt,{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(q,{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},Rf(t.workspaces.filter(m=>m.active).length,"active"),Rf(t.workspaces.filter(m=>!m.active).length,"finished")]}),i.jsx(qw,{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 Rf=(t,s)=>`${t} ${s}`;function Jw(t){const{prefs:s,update:r}=t,[a,c]=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(Ge,{as:"div",className:"dialog settings",onClick:u=>u.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx(Kl,{value:a,onChange:c,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(Rw,{}):i.jsxs(i.Fragment,{children:[t.map&&i.jsx(nt,{title:`Trail ${t.map.key}`,children:i.jsx(fw,{value:t.map.mode,onChange:t.onMapMode})}),i.jsx(nt,{title:"Tracker",children:i.jsx(Sw,{activeTracker:t.activeTracker,location:t.location,update:r})}),i.jsx(Fw,{focus:t.focus==="slack"}),i.jsx(Vw,{map:t.map}),i.jsx(Bw,{}),i.jsx(Tw,{}),i.jsx(Yw,{}),i.jsx(nt,{title:"Labels",children:i.jsxs("div",{className:"label-codes",children:[i.jsx("code",{children:Al}),i.jsxs("code",{children:[ne.labelPrefix,":<type>"]}),i.jsx("code",{children:Ll}),i.jsx("code",{children:Rl})]})}),i.jsx(nt,{title:"HITL transcript",children:i.jsx(Bh,{value:s.hitlTranscript,onChange:u=>r({hitlTranscript:u})})}),i.jsx(nt,{title:"Appearance",children:i.jsx(Ww,{value:s.theme,onChange:u=>r({theme:u})})}),i.jsx(nt,{title:"Trip report",children:i.jsx(Mw,{value:s.briefing,onChange:u=>r({briefing:u})})}),i.jsx(nt,{title:"Agent",children:i.jsx("div",{className:"choice-row",children:ch.map(u=>i.jsx(pt,{on:u.status==="primary",disabled:u.status!=="primary",title:u.name},u.id))})})]})]})})}const Xw=()=>new URLSearchParams(location.search).get("settings")==="slack"?"slack":!1;function Zw(){const t=new URL(location.href);t.searchParams.has("settings")&&(t.searchParams.delete("settings"),history.replaceState(null,"",t))}function e0(t){var a;const{rt:s,api:r}=t;return i.jsx(Jw,{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(),Zw()}})}function t0(t){return i.jsxs(Ge,{className:"zone side",style:{gridArea:"inspector"},children:[i.jsx(Kl,{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 Gl=13;function n0(t,s,r){if(t==="LR"){const g=s.x+Te+Gl,p=s.y+Ce/2,y=r.x-2,v=r.y+Ce/2,j=y-g;if(p===v)return`M${g} ${p}C${g+j*.3} ${p-16} ${g+j*.7} ${p+16} ${y} ${v}`;const N=(g+y)/2;return`M${g} ${p}C${N} ${p} ${N} ${v} ${y} ${v}`}const a=s.x+Te/2,c=s.y+Ce,u=r.x+Te/2,f=r.y-4,m=(c+f)/2;return`M${a} ${c}C${a} ${m} ${u} ${m} ${u} ${f}`}function s0(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 i0(t,s){const r=new Set(t.edges.map(c=>c.from));return t.nodes.filter(c=>c.state!=="out-of-scope"&&!r.has(c)).map(c=>{if(t.direction==="LR"){const p=c.x+Te+Gl,y=c.y+Ce/2,v=s.x-44,j=(p+v)/2;return`M${p} ${y}C${j} ${y} ${j} ${s.y} ${v} ${s.y}`}const u=c.x+Te/2,f=c.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 r0({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 o0({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 a0(){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 l0(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=n0(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 c0({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 u0(t,s,r=2){const a=t.split(/\s+/),c=[];let u="";for(const f of a)(u+" "+f).trim().length>s?(c.push(u.trim()),u=f):u+=" "+f;if(c.push(u.trim()),c.length>r){const f=c.slice(0,r);return f[r-1]=f[r-1].slice(0,s-1)+"…",f}return c}const d0=`M${Te} 0L${Te+Gl} ${Ce/2}L${Te} ${Ce}z`;function f0({n:t,session:s,stalled:r,flag:a,selected:c,onSelect:u,mark:f,frozen:m}){const g=t.ticket,p=u0(g.title,29),y=Ii(g)==="hitl",v=!!(s!=null&&s.waitingOn),j=!!f&&f!=="unchanged",N=j?void 0:m0(t,{waiting:v,stalled:r}),M=y&&!j&&(g.type==="task"||g.type==="execute"),S={hitl:y,selected:c,live:!!s,waiting:v,stalled:r,mark:f,frozen:m};return i.jsxs("g",{className:h0(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:d0}),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(c0,{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 h0(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 m0(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:Vk[t.state],tone:""}}const io=(t,s)=>`${t}>${s}`;function p0(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=>io(f,u.id)))),removedEdges:new Set(s.nodes.flatMap(u=>(u.removedEdges??[]).map(f=>io(f,u.id)))),frozen:new Set(r)}}const _f=.72;function g0(t){const{fit:s,nodes:r,size:a,pad:c}=t;if(s.k>=_f)return s;const u=r.find(m=>m.state==="claimed")??r.find(m=>m.state==="frontier")??r[0];if(!u)return s;const f=_f;return{k:f,x:a.w/2-(u.x+c+Te/2)*f,y:a.h/2-(u.y+c+Ce/2)*f}}function v0({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 qe=280,Of=4,k0=220,Ss=t=>Math.round(t/Of)*Of;function y0(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 gl(t,s,r,a){return Array.from({length:6},()=>{const c=a*(.5+t()*.7),u=a*(.3+t()*.4);return{x:Ss(s+(t()-.5)*a*.8-c/2),y:Ss(r+(t()-.5)*a*.5-u/2),w:Ss(c),h:Ss(u)}})}function x0(t){const{width:s,height:r,nodes:a}=t,c=y0(t.seed),u=(j,N)=>j+c()*(N-j),f=(j,N)=>!a.some(M=>j>M.x-52&&j<M.x+Te+28&&N>M.y-52&&N<M.y+Ce+28),m=(s+qe*2)*(r+qe*2),g=Array.from({length:Math.round(m/9e4)},()=>gl(c,u(-qe,s+qe),u(-qe,r+qe),u(160,360))).flat(),p=[...gl(c,s+qe*.55,r+qe*.55,300),...gl(c,-qe*.5,-qe*.45,220)],y=[],v=(j,N,M)=>{y.length<k0&&f(N,M)&&y.push({sprite:j,x:Ss(N),y:Ss(M)})};for(let j=0;j<Math.round(m/3e4);j++){const N=u(-qe,s+qe),M=u(-qe,r+qe),S=3+Math.floor(c()*5);for(let E=0;E<S;E++)v(c()<.65?"pine":"oak",N+u(-70,70),M+u(-44,44))}for(let j=0;j<Math.round(m/45e3);j++)v(c()<.4?"rock":"tuft",u(-qe,s+qe),u(-qe,r+qe));return y.sort((j,N)=>j.y-N.y),{grass:g,water:p,items:y}}const Hh={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 w0({name:t}){return i.jsx("symbol",{id:`terrain-${t}`,overflow:"visible",children:Hh[t]})}const j0=Object.keys(Hh),S0=x.memo(function(s){const{seed:r,width:a,height:c,nodes:u}=s,f=x.useMemo(()=>x0({seed:r,width:a,height:c,nodes:u}),[r,a,c,u]);return i.jsxs("g",{className:"terrain","aria-hidden":"true",children:[i.jsx("defs",{children:j0.map(m=>i.jsx(w0,{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:c+8e3,fill:"url(#map-grid)"}),f.items.map((m,g)=>i.jsx("use",{href:`#terrain-${m.sprite}`,x:m.x,y:m.y},g))]})}),N0=380;function C0(t){const{selId:s,size:r}=t,a=x.useRef(t);a.current=t;const c=x.useRef(!0);x.useEffect(()=>{if(c.current){c.current=!1;return}const{nodes:u,pad:f,view:m,setView:g,onFocus:p}=a.current,y=s?u.find(I=>I.ticket.id===s):void 0;if(!y||!r.w)return;p();const v=Math.min(1.4,Math.max(m.k,1.05)),j={k:v,x:r.w/2-(f+y.x+Te/2)*v,y:r.h/2-(f+y.y+Ce/2)*v};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return g(j);const N=m,M=performance.now();let S=0;const E=I=>{const O=Math.min(1,(I-M)/N0),L=1-(1-O)**3;g({k:N.k+(j.k-N.k)*L,x:N.x+(j.x-N.x)*L,y:N.y+(j.y-N.y)*L}),O<1&&(S=requestAnimationFrame(E))};return S=requestAnimationFrame(E),()=>cancelAnimationFrame(S)},[s])}function $0(t,s){const r=x.useRef(s);r.current=s,x.useEffect(()=>{const a=t.current;if(!a)return;const c=p=>{const y=a.getBoundingClientRect();return{x:p.clientX-y.left,y:p.clientY-y.top}},u=p=>{p.preventDefault();const y=p.ctrlKey?.01:.0015;r.current(Math.exp(-p.deltaY*y),c(p))};let f=1;const m=p=>{p.preventDefault(),f=1},g=p=>{p.preventDefault();const y=p;r.current(y.scale/f,c(y)),f=y.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,b0=1.8;function T0(t){const{snap:s,selection:r,onSelect:a,preview:c}=t,u=(c==null?void 0:c.tickets)??s.tickets,f=x.useRef(null),[m,g]=x.useState({w:0,h:0});x.useEffect(()=>{const R=f.current;if(!R)return;const V=new ResizeObserver(([se])=>g({w:se.contentRect.width,h:se.contentRect.height}));return V.observe(R),()=>V.disconnect()},[]);const p=x.useMemo(()=>{const R=Zd(u,"LR",s.map.mode),V=Zd(u,"TB",s.map.mode),se=ce=>Math.min(m.w/(ce.width+Wt*2),m.h/(ce.height+Wt*2+16));return se(R)*b0>=se(V)?R:V},[u,s.map.mode,m.w,m.h]),y=(R,V)=>Math.min(1.25,Math.max(t.minFit??0,Math.min(m.w/R,m.h/V))),v=x.useMemo(()=>{const R=p.width+Wt*2,V=p.height+Wt*2+16,ce=p.nodes.some(B=>B.state==="out-of-scope")&&m.h?Math.max(0,m.h/y(R,V)-V):0;if(!ce)return{...p,slack:ce};const me=new Map(p.nodes.map(B=>[B,{...B,y:B.y+(B.state==="out-of-scope"?ce:ce/2)}]));return{...p,slack:ce,nodes:[...me.values()],edges:p.edges.map(B=>({from:me.get(B.from),to:me.get(B.to)})),quarantineY:p.quarantineY+ce,height:p.height+ce}},[p,m.w,m.h,t.minFit]),j=s0(v),N=j.right+Wt*2,M=j.bottom+Wt*2+16,S=()=>{const R=y(N,M);return{k:R,x:Math.max(0,(m.w-N*R)/2),y:Math.max(0,(m.h-M*R)/2)}},[E,I]=x.useState({k:1,x:0,y:0}),O=x.useRef(!1);x.useEffect(()=>{O.current=!1},[s.map.id]),x.useEffect(()=>{!O.current&&m.w&&I(g0({fit:S(),nodes:v.nodes,size:m,pad:Wt}))},[m.w,m.h,N,M,s.map.id]);const L=x.useRef(new Map),J=x.useRef(null),Z=R=>{const V=f.current.getBoundingClientRect();return{x:R.clientX-V.left,y:R.clientY-V.top}},K=()=>{var ce;const R=[...L.current.values()],V=R.length>1?{x:(R[0].x+R[1].x)/2,y:(R[0].y+R[1].y)/2}:R[0],se=R.length>1?Math.hypot(R[0].x-R[1].x,R[0].y-R[1].y):0;J.current={view:E,dist:se,mid:V,moved:((ce=J.current)==null?void 0:ce.moved)??!1}},le=(R,V,se)=>{const ce=Math.min(3,Math.max(.2,V));return{k:ce,x:se.x-(se.x-R.x)*ce/R.k,y:se.y-(se.y-R.y)*ce/R.k}};$0(f,(R,V)=>{O.current=!0,I(se=>le(se,se.k*R,V))});const de=Mn(5e3),Q=Bl(t.leases,s.map.id),xe=Wl(),De=new Map(t.sessions.filter(R=>Qt(R)&&R.ticketId).map(R=>[R.ticketId,R])),$e=(r==null?void 0:r.kind)==="ticket"?r.id:void 0;return C0({selId:$e,nodes:v.nodes,size:m,pad:Wt,view:E,setView:I,onFocus:()=>O.current=!0}),i.jsxs("div",{className:"graph-box",ref:f,onPointerDown:R=>{L.current.set(R.pointerId,Z(R)),L.current.size===1&&(J.current=null),K()},onPointerMove:R=>{var ce;if(!L.current.has(R.pointerId)||!J.current)return;L.current.set(R.pointerId,Z(R));const V=J.current,se=[...L.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=le(V.view,V.view.k*B/(V.dist||B),V.mid);I({...F,x:F.x+me.x-V.mid.x,y:F.y+me.y-V.mid.y}),V.moved=!0}else{const me=se[0].x-V.mid.x,B=se[0].y-V.mid.y;if(!V.moved&&Math.hypot(me,B)<5)return;V.moved||(ce=f.current)==null||ce.setPointerCapture(R.pointerId),V.moved=!0,I({...V.view,x:V.view.x+me,y:V.view.y+B})}O.current=!0},onPointerUp:R=>{L.current.delete(R.pointerId),L.current.size&&K()},onPointerCancel:R=>L.current.delete(R.pointerId),onClickCapture:R=>{var V;(V=J.current)!=null&&V.moved&&(R.stopPropagation(),J.current=null)},children:[i.jsxs("svg",{className:"graph",width:m.w,height:m.h,onClick:()=>a(null),children:[i.jsx(a0,{}),i.jsx("g",{transform:`translate(${E.x} ${E.y}) scale(${E.k})`,children:i.jsxs("g",{transform:`translate(${Wt} ${Wt})`,children:[i.jsx(S0,{seed:s.map.id,width:N,height:M,nodes:v.nodes}),v.nodes.some(R=>R.state==="out-of-scope")&&i.jsx(v0,{y:v.quarantineY,width:v.width,height:v.quarantineH}),v.edges.map(({from:R,to:V})=>i.jsx(l0,{from:R,to:V,direction:v.direction,added:c==null?void 0:c.newEdges.has(io(R.ticket.id,V.ticket.id)),removed:c==null?void 0:c.removedEdges.has(io(R.ticket.id,V.ticket.id))},`${R.ticket.id}-${V.ticket.id}`)),i.jsx(o0,{trails:i0(v,j)}),v.nodes.length>0&&i.jsx(r0,{x:j.x,y:j.y}),v.nodes.map(R=>i.jsx(f0,{n:R,session:De.get(R.ticket.id),stalled:!!Q.get(R.ticket.id)&&fo(Q.get(R.ticket.id),de)!=="live",flag:Qk(Ms.ticket(xe,s.map.id,R.ticket.id)),selected:$e===R.ticket.id,onSelect:a,mark:c==null?void 0:c.marks.get(R.ticket.id),frozen:c==null?void 0:c.frozen.has(R.ticket.id)},R.ticket.id))]})})]}),i.jsx("button",{className:"btn sm fit-btn","data-tip":"Fit the whole trail in view",onPointerDown:R=>R.stopPropagation(),onClick:R=>{R.stopPropagation(),O.current=!0,I(S())},children:"Fit"})]})}const vl=[["decided","Done"],["claimed","Working"],["frontier","Ready"],["blocked","Backlog"],["parked","Parked"],["out-of-scope","Cancelled"]],Pf=[["verifying","Verifying"],["rework","Rework"],["held","Blocked"]];function E0({snap:t,sessions:s}){const r=Zf(t),a=p=>r[p],c=s.filter(Nh).length,u=Zg(t),f=Math.max(1,...u.map(p=>p.open+p.closed)),g=(t.map.verification??"off")!=="off"||Pf.some(([p])=>a(p))?[...vl.slice(0,2),...Pf,...vl.slice(2)]:vl;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(at,{as:"h3",children:"Status"}),i.jsxs("span",{className:"t-meta",children:[r.total," tickets"]})]}),i.jsxs("ul",{children:[g.map(([p,y])=>i.jsxs("li",{className:`st-${p} ${a(p)?"":"zero"}`,children:[i.jsx("i",{}),i.jsx("span",{children:y}),i.jsx("b",{children:a(p)})]},p)),i.jsxs("li",{className:`st-waiting ${c?"":"zero"}`,children:[i.jsx("i",{}),i.jsx("span",{children:"Waiting on you"}),i.jsx("b",{children:c})]})]})]}),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:vh[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 M0(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(E0,{snap:t.snap,sessions:t.sessions})]})}function I0({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,c])=>i.jsxs("span",{className:`lg st-${a}`,children:[i.jsx("i",{}),c]},a)),i.jsx("span",{className:"lg hitl",children:"● needs human"})]})}function A0(t){var a,c;const{snap:s,selection:r}=t.api;return i.jsxs(Ge,{as:"main",className:"zone map-zone",style:{gridArea:"map"},children:[s&&i.jsx(dw,{}),(a=t.trail)==null?void 0:a.banner,i.jsxs("div",{className:"map-area",children:[s&&!t.compact&&i.jsx(M0,{snap:s,sessions:t.sessions}),s?i.jsx(T0,{snap:s,sessions:t.sessions,leases:t.api.leases,selection:r,onSelect:t.onSelect,minFit:t.minFit,preview:(c=t.trail)==null?void 0:c.preview}):i.jsxs("div",{className:"nomap",children:[i.jsx(pw,{}),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(q,{variant:"primary",onClick:t.onNewTrail,"data-tip":"Describe the idea and create the trail",children:"New trail…"})}),i.jsx(so,{command:'/scout new "your idea"'})]}),s&&t.compact&&i.jsx(I0,{planOnly:s.map.mode==="plan-only",verifies:(s.map.verification??"off")!=="off"})]})]})}const L0=[["home","Inbox"],["map","Map"],["ticket","Ticket"],["activity","Activity"],["plan","Plan"]];function R0(t){const{tab:s,covered:r,pending:a}=t;return i.jsx("nav",{className:"tabbar",children:L0.map(([c,u])=>i.jsxs("button",{className:s===c&&!r?"on":"",onClick:()=>t.onPick(c),children:[u,c==="home"&&a>0&&i.jsx(to,{n:a,urgent:!0,pop:!0},a)]},c))})}function _0(t){const s={home:t.inbox,map:t.map,ticket:i.jsx(Ge,{className:"zone",children:t.ticket}),activity:i.jsx(Ge,{className:"zone",children:t.activity}),plan:t.plan};return i.jsx("main",{className:"phone-view",children:t.decisions||s[t.tab]})}function O0(t,s){const{activity:r,selection:a,setSelection:c,actions:u}=t,[f,m]=x.useState("ticket"),[g,p]=x.useState("home"),[y,v]=x.useState(0),[j,N]=x.useState(null),M=O=>N({focus:O});return x.useEffect(()=>{const O=r.sessions.find(L=>L.id===t.chatSession);!a&&(O!=null&&O.ticketId)&&O.mapId===t.mapId&&c({kind:"ticket",id:O.ticketId})},[t.chatSession,t.mapId]),{sideTab:f,setSideTab:m,phoneTab:g,setPhoneTab:p,convRequest:y,decisionsView:j,setDecisionsView:N,openDecisions:M,select:O=>{c(O),O&&(s==="laptop"&&m("ticket"),s==="mobile"&&p("ticket"))},openChat:(O,L,J)=>{J&&J!==t.mapId&&u.selectMap(J),u.openChat(O);const Z=r.sessions.find(K=>K.id===O);L&&(Z==null?void 0:Z.mapId)===(J??t.mapId)&&c({kind:"ticket",id:L}),s==="mobile"&&(p("home"),v(K=>K+1))},openTicket:(O,L)=>{O!==t.mapId&&u.selectMap(O),c({kind:"ticket",id:L}),N(null),s==="laptop"&&m("ticket"),s==="mobile"&&p("ticket")}}}function P0(t,s){x.useEffect(()=>{document.title=`${ne.name}: ${t?`(${t}) `:""}${s??"No trail"}`},[t,s])}function D0(t){const[s,r]=x.useState("…");return x.useEffect(()=>{fetch(`${ne.apiPrefix}/list`).then(a=>a.json()).then(a=>{var u;const c=a.root.split("/").filter(Boolean);r((u=c[c.length-1])!=null&&u.startsWith(".")?c[c.length-2]??"repo":c[c.length-1]??"repo")}).catch(()=>r("repo"))},[t]),s}function z0(t,s){return x.useMemo(()=>{const r=t.sessions.filter(c=>c.mapId===s),a=new Set(t.sessions.filter(c=>c.mapId!==s).map(c=>c.id));return{...t,sessions:r,feed:t.feed.filter(c=>!c.sessionId||!a.has(c.sessionId))}},[t,s])}function B0({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,c)=>c%2===1?i.jsx("code",{children:a.replace(/`/g,"")},c):a)},r))}):i.jsx(Be,{children:"Not covered"})}const Df=["summary","productContext","existing","conventions","dataModel","api","risks"];function F0(t){const{brief:s}=t,[r,a]=x.useState(!1),[c,u]=x.useState("");x.useEffect(()=>{const p=y=>y.key==="Escape"&&t.onClose();return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[t]);const f=s.sections,m=Df.filter(p=>f[p].trim()),g=Df.filter(p=>!f[p].trim());return i.jsx("div",{className:"scrim",onClick:t.onClose,children:i.jsxs(Ge,{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:U0(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(B0,{text:f[p]}),(p==="conventions"||p==="productContext")&&f[p].trim()&&i.jsx(Vl,{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(Be,{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(Be,{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:c,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(q,{onClick:()=>a(!0),children:"Request changes"}),i.jsx(q,{variant:"primary",onClick:t.onAccept,children:"Accept brief"})]}),r&&i.jsxs(i.Fragment,{children:[i.jsx(q,{variant:"ghost",onClick:()=>a(!1),children:"Back"}),i.jsx(q,{variant:"primary",disabled:!c.trim(),onClick:()=>t.onRequestChanges(c.trim()),children:"Send to the agent"})]}),i.jsx(q,{variant:"ghost",onClick:t.onClose,children:"Close"})]})]})})}function U0(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(`${Gn(Date.now()-t.submittedAt)} ago`),s.join(" · ")}function W0({brief:t,onReview:s}){return t.status!=="submitted"?null:i.jsx("div",{className:"brief-card",children:i.jsx(gt,{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 H0={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 K0({brief:t,onReview:s}){if(t.status==="accepted")return null;const[r,a]=H0[t.status],c=t.status==="submitted"?"edge-attention":"edge-neutral";return i.jsxs("div",{className:`discovery-banner map-banner ${c} 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(q,{size:"sm",variant:t.status==="submitted"?"primary":"ghost",onClick:s,children:t.status==="submitted"?"Review brief":"Open brief"})]})}const zf=`${ne.apiPrefix}/briefs`;function V0(t){const s=t==null?void 0:t.map.id,[r,a]=x.useState(null),[c,u]=x.useState(),f=x.useCallback(()=>{if(!s)return a(null);fetch(`${zf}?mapId=${encodeURIComponent(s)}`).then(y=>y.ok?y.json():{brief:null}).then(y=>a(y.brief)).catch(()=>a(null))},[s]),m=t==null?void 0:t.tickets.reduce((y,v)=>Math.max(y,v.updatedAt),t.map.updatedAt);x.useEffect(f,[f,m]),x.useEffect(()=>As(y=>y.startsWith("briefs/")&&f()),[f]);const g=(y,v)=>fetch(`${zf}/${y}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:s,note:v})}).then(async j=>{const N=await j.json().catch(()=>({}));if(!j.ok||!N.brief)throw new Error(N.error??`HTTP ${j.status}`);u(void 0),a(N.brief)}),p=(y,v)=>g(y,v).then(()=>!0,j=>(u(j.message),!1));return{brief:r,error:c,accept:()=>p("accept"),requestChanges:y=>p("request-changes",y)}}function Q0(t){const s=V0(t),[r,a]=x.useState(!1),c=()=>a(!0),u=s.brief,f=u==null?void 0:u.sections;return{review:c,briefText:f?[f.existing,f.conventions,f.dataModel,f.api].join(`
139
+ `):"",banner:u&&i.jsx(K0,{brief:u,onReview:c}),inboxCard:u&&i.jsx(W0,{brief:u,onReview:c}),dialog:u&&r&&i.jsx(F0,{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 q0({reroute:t,onReview:s}){var m;const r=t.kind==="challenge-destination",a=((m=t.frozen)==null?void 0:m.length)??0,c=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," ",c]}),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(q,{size:"sm",variant:"primary",onClick:s,children:"Review"})]})}const G0={"already-exists":"The work already exists","wrong-problem":"The trail targets the wrong problem",rescope:"The trail should be rescoped"};function Y0(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:J0(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 J0(t,s){var a,c;return[...(a=t.addBlockedBy)!=null&&a.length?[`now also after ${t.addBlockedBy.map(s).join(", ")}`]:[],...(c=t.removeBlockedBy)!=null&&c.length?[`no longer after ${t.removeBlockedBy.map(s).join(", ")}`]:[]].join(" · ")}const X0=new Set(["cancel_ticket","update_destination"]);function Z0({change:t,name:s}){const r=Y0(t,s);return i.jsx(gt,{as:"li",className:`reroute-change op-${t.op}`,edge:X0.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 ej(t){const{reason:s,destination:r}=t;return i.jsxs("section",{className:"reroute-destination",children:[s&&i.jsx("p",{className:"reroute-destination-why",children:G0[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 tj(t,s){const r=new Map(t.tickets.map(c=>[c.id,c.key])),a=new Map(s.flatMap(c=>c.op==="add_ticket"?[[c.ref,c.title]]:[]));return c=>{const u=r.get(c);if(u)return u;const f=a.get(c);return f?`new: ${f}`:c}}function nj(t){var j,N;const{reroute:s,snap:r}=t,[a,c]=x.useState("");x.useEffect(()=>{const M=S=>S.key==="Escape"&&t.onClose();return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[t]);const u=tj(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:""}),y=s.status==="pending",v=s.kind==="challenge-destination";return i.jsx("div",{className:"scrim",onClick:t.onClose,children:i.jsxs(Ge,{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}`,`${Gn(Date.now()-s.at)} ago`]})]}),i.jsxs("div",{className:"reroute-body",children:[v&&i.jsx(ej,{reason:s.destinationReason,destination:(j=s.diff)==null?void 0:j.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(Z0,{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(Be,{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})]})]}),y&&i.jsx(He,{label:"Note for the agent (required to reject)",children:i.jsx("textarea",{rows:2,value:a,onChange:M=>c(M.target.value)})}),t.error&&i.jsx("p",{className:"urgent-text",children:t.error}),i.jsxs("div",{className:"actions",children:[y&&i.jsxs(i.Fragment,{children:[i.jsx(q,{className:"reroute-reject",disabled:!a.trim(),onClick:()=>t.onReject(a.trim()),children:"Reject"}),i.jsx(q,{className:"reroute-approve",variant:"primary",onClick:()=>t.onApprove(a.trim()),children:"Approve and apply"})]}),i.jsx(q,{variant:"ghost",onClick:t.onClose,children:"Close"})]})]})})}const Bf=`${ne.apiPrefix}/reroutes`;function sj(t){const s=t==null?void 0:t.map.id,[r,a]=x.useState([]),[c,u]=x.useState(),f=x.useCallback(()=>{if(!s)return a([]);fetch(`${Bf}?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,y)=>Math.max(p,y.updatedAt),t.map.updatedAt);x.useEffect(f,[f,m]),x.useEffect(()=>Yk("reroute",p=>{p.mapId===s&&f()}),[f,s]);const g=async(p,y,v)=>{var S;const j=await fetch(`${Bf}/${p}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:s,id:y,note:v})}),N=await j.json().catch(()=>({}));if(j.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 ${j.status}`,M].filter(Boolean).join(": ")),!1};return{reroutes:r,pending:r.find(p=>p.status==="pending"),error:c,clearError:()=>u(void 0),approve:(p,y)=>g("approve",p,y),reject:(p,y)=>g("reject",p,y)}}function ij(t,s){const r=sj(t),[a,c]=x.useState(),u=r.reroutes.find(p=>p.id===a),f=u!=null&&u.diff?u:r.pending,m=()=>{c(void 0),r.clearError()},g=p=>p&&m();return{banner:r.pending&&i.jsx(q0,{reroute:r.pending,onReview:()=>{var p;return c((p=r.pending)==null?void 0:p.id)}}),preview:t&&(f!=null&&f.diff)?p0(t,f.diff,f.frozen):void 0,openReroute:(p,y)=>{p!==(t==null?void 0:t.map.id)&&(s==null||s(p)),c(y)},dialog:t&&u&&i.jsx(nj,{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 rj(t,s){const r=Q0(t),a=ij(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 oj(t){const{api:s,nav:r}=t,a=Lh(s.allSnaps);Xx(a.view);const c=g=>g&&s.actions.selectMap(g),u={openTicket:r.openTicket,openKnowledge:()=>t.knowledge.setOpen(!0),openBrief:g=>g===s.mapId?t.reviewBrief():c(g),openReroute:t.openReroute??(g=>g.ticketId?r.openTicket(g.mapId,g.ticketId):c(g.mapId)),selectTrail:c},f=a.view;return{attention:a,handlers:u,header:f&&i.jsx(qx,{view:f,onFocus:g=>void a.savePrefs({...f.prefs,focusUntil:g})})}}function Kh({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:Dl(a.at)}),i.jsxs("span",{className:"src t-meta",children:[a.source==="system"&&i.jsx(Hl,{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 Ff({lease:t,now:s}){if(!t)return null;const r=fo(t,s);if(r==="live")return null;const a=t.expiresAt-s;return i.jsxs(In,{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 aj({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:lj(a+1,s)},a))})}function lj(t,s){return t<s?"done":t===s?"cur":""}function Vh({snap:t,activity:s,leases:r,onSelect:a,onOpenChat:c}){const u=Mn(1e3),f=s.sessions.filter(Qt),m=new Set(f.map(v=>v.ticketId)),g=Bl(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(Be,{children:"No agent on a ticket"});const y=v=>!!v&&fo(v,u)!=="live";return i.jsxs("ul",{className:"sessions-list",children:[f.map(v=>{const j=t==null?void 0:t.tickets.find(S=>S.id===v.ticketId),N=j?Ii(j)==="hitl":!1,M=j&&g.get(j.id);return i.jsx(gt,{as:"li",className:v.waitingOn?"waiting":void 0,edge:cj(v,y(M)),title:dj(j,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",uj(v)],children:i.jsx(Ff,{lease:M,now:u})}),trailing:ph(u-v.startedAt),below:i.jsx(aj,{total:v.total,step:v.step}),onOpen:()=>{j&&a({kind:"ticket",id:j.id}),N&&c(v.id)}},v.id)}),p.map(v=>i.jsx(gt,{as:"li",className:"claim",edge:y(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(Ff,{lease:g.get(v.id),now:u})}),onOpen:()=>a({kind:"ticket",id:v.id})},v.id))]})}function cj(t,s){return t.waitingOn?"urgent":s?"attention":"neutral"}function uj(t){if(t.usage)return`${ho(tv(t))} tok · ${Ts(t.usage.costUsd)}`}function dj(t,s){return t?`${t.key} ${t.title}`:s==="chart"?"Charting trail":""}function Qh({activity:t,snap:s,running:r,usage:a=!0}){const c=th(t,s==null?void 0:s.map.id),u=sh(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(rn,{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=>nh[g].text)].join(`
140
+ `),children:[i.jsx("span",{className:"mono-label",children:"Trail"})," ",ho(c.inputTokens+c.outputTokens)," tok · ",Ts(c.costUsd)]}):void 0})}function fj(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 hj={running:"Working",done:"Done",failed:"Stopped"};function qh({activity:t,snap:s}){const r=po(),a=fj(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 c=a.ticketId?s==null?void 0:s.tickets.find(m=>m.id===a.ticketId):void 0,u=ao[a.mode],f=a.waitingOn?"Waiting on you":hj[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,c&&i.jsxs("span",{className:"st-key",children:[" ",c.key]})]}),c&&i.jsx("div",{className:"st-ticket t-meta",children:c.title}),i.jsx("ol",{className:"pipeline",children:u.map((m,g)=>{const p=g+1,y=p<a.step||p===a.step&&a.status==="done";let v="";return y?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 Uf(t){return i.jsxs("div",{className:"zone-b activity-stack",children:[i.jsx(qh,{activity:t.activity,snap:t.snap}),i.jsx(Qh,{activity:t.activity,snap:t.snap,running:t.activity.sessions.filter(Qt).length}),i.jsx(Vh,{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(rn,{sub:!0,title:"Activity log"}),i.jsx(Kh,{activity:t.activity,onTicket:t.onTicket})]})}function mj(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(Kh,{activity:t.activity,onTicket:t.onTicket})})}function pj(t){var a;const s=t.activity.sessions.filter(Qt).length,r=!t.activity.sessions.length&&!((a=t.snap)!=null&&a.tickets.some(c=>c.state==="open"&&c.assignee));return i.jsxs(Ge,{className:"zone step-zone",style:{gridArea:"step"},children:[i.jsx(rn,{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(qh,{activity:t.activity,snap:t.snap}),!r&&i.jsxs(i.Fragment,{children:[i.jsx(Qh,{activity:t.activity,snap:t.snap,running:s,usage:!1}),i.jsx(Vh,{snap:t.snap,activity:t.activity,leases:t.leases,onSelect:c=>(c==null?void 0:c.kind)==="ticket"&&t.onTicket(c.id),onOpenChat:t.onOpenChat})]})]})]})}function gj(t){const{d:s,snap:r}=t,[a,c]=x.useState(!1),[u,f]=x.useState(""),[m,g]=x.useState("");x.useEffect(()=>{c(!1),f(""),g("")},[s.id,s.mapId]);const p=zg(t.all.filter(N=>N.mapId===s.mapId),s.id),y=Ai(s),v=s.ticketId?r==null?void 0:r.tickets.find(N=>N.id===s.ticketId):void 0,j=Date.now();return i.jsxs("div",{className:"detail dv-d",children:[i.jsxs("div",{className:"d-head",children:[i.jsx("span",{className:"key",children:s.id}),i.jsx(In,{tone:"state",className:`dv-st-${y}`,children:y}),i.jsx(ge,{parts:[Kk(s.decidedAt),`${Gn(j-s.decidedAt)} ago`]})]}),i.jsx("h3",{className:"t-heading",children:s.question}),i.jsxs("div",{className:"resolution",children:[i.jsx(no,{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:[bn[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(Vl,{draft:()=>({title:s.summary||s.question,body:[s.answer,s.rationale&&`Why: ${s.rationale}`].filter(Boolean).join(`
141
+
142
+ `),kind:"product-decision",sources:[`decision:${s.id}`,...s.ticketKey?[`ticket:${s.ticketKey}`]:[]]})}),y==="active"&&i.jsx(q,{on:a,onClick:()=>c(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]}),c(!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(q,{variant:"ghost",onClick:()=>c(!1),children:"Cancel"}),i.jsx(q,{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(no,{parts:[N.author,zl(N.at)]}),i.jsx("div",{className:"msg-text",children:N.text})]},M))}):i.jsx(Be,{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 vj(t){const{filter:s,set:r,all:a}=t,c=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"},...Xr.map(u=>({value:u,label:bn[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:c(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})}),Xr.map(u=>i.jsx(Tt,{cls:`src-${u}`,on:s.source===u,label:bn[u].label,n:c(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:c(u=>Ti(u)==="agent"),onClick:()=>r({madeBy:s.madeBy==="agent"?void 0:"agent"})}),i.jsx(Tt,{on:s.madeBy==="human",label:"People",n:c(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:c(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:c(u=>!u.supersededBy),onClick:()=>r({status:s.status==="active"?void 0:"active"})}),i.jsx(Tt,{on:s.status==="superseded",label:"Superseded",n:c(u=>!!u.supersededBy),onClick:()=>r({status:s.status==="superseded"?void 0:"superseded"})})]})]})}function kj(t){if(Ai(t)==="superseded")return`Replaced by ${t.supersededBy}`;if(t.supersedes)return`Replaces ${t.supersedes}`}function yj(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(gt,{as:"li",className:`dv-row ${r}`,selected:t.on,onOpen:t.onClick,title:s.question,titleText:s.question,trailing:zl(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,bn[s.source.kind].label,kj(s)]}),detail:s.summary,detailText:s.summary})]})}function xj(t){const{rows:s,current:r}=t;return i.jsx("ol",{className:"dv-list","aria-label":"Logbook",children:s.length?s.map((a,c)=>{var u;return i.jsx(yj,{d:a,newDay:c===0||Es(s[c-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(Be,{children:"No decisions"})})}function wj({stats:t}){return i.jsxs("span",{className:"dv-readouts",children:[i.jsx(Vt,{layout:"start",label:"Active",value:t.active}),i.jsx(Vt,{layout:"start",label:"Superseded",value:t.superseded}),i.jsx(Vt,{layout:"start",label:"Last 24h",value:t.last24h}),i.jsx(Vt,{layout:"start",label:"Human",value:`${t.total?Math.round(t.human/t.total*100):0}%`}),i.jsx(ge,{className:"dv-src-mix",parts:Xr.filter(s=>t.bySource[s]).map(s=>`${bn[s].label} ${t.bySource[s]}`)})]})}function jj(t){const{filter:s}=t,a=Object.values(s).filter(Boolean).length-(s.query?1:0),c=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 ${c?"on":""}`,onClick:t.onToggle,children:["Filters",a>0?` · ${a}`:""]})]})}function Sj(t){const{api:s,bp:r}=t,a=s.decisions,[c,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=L=>{L.key==="Escape"&&(r==="mobile"&&f?m(void 0):t.onClose())};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[r,f,t]);const y=x.useMemo(()=>sv(a,c),[a,c]),v=x.useMemo(()=>iv(a),[a]),j=a.find(O=>O.id===f&&(!c.mapId||O.mapId===c.mapId))??(r==="mobile"?void 0:y[0]),N=x.useMemo(()=>Object.values(s.allSnaps).sort((O,L)=>L.map.createdAt-O.map.createdAt),[s.allSnaps]),M=x.useMemo(()=>[...new Set(a.map(O=>O.decidedBy))].sort(),[a]),S=O=>u(L=>({...L,...O})),E=()=>{const O=Object.fromEntries(N.map(L=>[L.map.id,{key:L.map.key,title:L.map.title}]));mh(`${ne.slug}-decisions-${Es(Date.now())}.md`,pv(y,O,{title:`${ne.name} decisions`}))},I=r==="mobile"&&!!j;return i.jsxs(Ge,{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(at,{as:"h2",children:["Decisions ",y.length!==a.length&&i.jsx("span",{className:"n",children:`${y.length}/${a.length}`})]}),r!=="mobile"&&i.jsx(wj,{stats:v}),i.jsxs("span",{className:"dv-head-right",children:[!I&&i.jsx(q,{onClick:E,disabled:!y.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(jj,{filter:c,set:S,showToggle:r!=="wide",filtersOpen:g,onToggle:()=>p(O=>!O)}),i.jsxs("div",{className:"dv-body",children:[(r==="wide"||g&&!I)&&i.jsx(vj,{filter:c,set:S,all:a,trails:N,people:M,compact:r!=="wide"}),!I&&i.jsx(xj,{rows:y,current:j,snaps:s.allSnaps,showTrail:r==="wide",onSelect:m}),(r!=="mobile"||j)&&i.jsx("div",{className:"dv-detail",children:j?i.jsx(gj,{d:j,all:a,snap:s.allSnaps[j.mapId],onSelect:m,onOpenTicket:t.onOpenTicket,onSupersede:s.actions.supersede}):i.jsx(Be,{children:"No decision selected"})})]})]})}const Wf=`${ne.apiPrefix}/criteria`;function Nj(t){const[s,r]=x.useState([]),a=x.useCallback(()=>{if(!t)return r([]);fetch(`${Wf}?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(`${Wf}/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,...u})}).then(a)}}function Cj({snap:t,t:s}){const{tickets:r,confirm:a}=Nj(t.map.id),c=Rs(),u=r.find(p=>p.ticketId===s.id),f=(u==null?void 0:u.criteria)??[],g=ah(c.entries,{trailKey:t.map.key,ticket:{type:s.type,title:s.title,body:s.body},paths:lh(`${s.body}
143
+ ${c.briefText}`)}).filter(p=>p.kind==="business-rule").filter(p=>Tv(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(q,{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 ro="";function $j(t){const s=_l.map(a=>({value:a,label:Mi[a],hint:Rh[a]})),r=[...bj(t),...s];return i.jsx(wt,{compact:!0,className:"vf-level","aria-label":"Verification level",value:t.value??ro,options:r,onChange:a=>t.onChange(a===ro?null:a)})}function bj(t){return t.inherit!==void 0?[{value:ro,label:t.inherit,hint:"Use the trail’s level for this ticket."}]:t.value===void 0?[{value:ro,label:"Off (not set)"}]:[]}function Tj({check:t}){const s=nw(t),[r,a]=x.useState(),[c,u]=x.useState(),f=Ej(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:()=>_i.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"}),c&&i.jsx("span",{className:"vf-err",children:c})]})]})}function Ej(t){return t.error?"did not start":t.timedOut?"timed out":`exit ${t.exitCode??t.signal??"?"}`}const Hf=t=>(t==null?void 0:t.slice(0,8))??"none",Kf=t=>t===null?"·":String(t);function Mj({attempt:t}){const s=t.git;if(!s)return null;const{files:r,add:a,del:c}=s.stats;return i.jsxs("div",{className:"vf-git",children:[i.jsx(ge,{parts:[s.tree?{text:`${s.base?`${Hf(s.base.head)} → `:""}${Hf(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} −${c}`]}),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":`+${Kf(u.add)} −${Kf(u.del)}`,u.dirtyAtClaim?" · dirty at claim":""]})]},u.path))})]})]})}function Ij({attempt:t,latest:s}){return i.jsxs("details",{className:`vf-attempt r-${t.result}`,open:s,children:[i.jsxs("summary",{children:[i.jsx(In,{tone:"state",className:`r-${t.result}`,children:tw[t.result]}),i.jsx(ge,{parts:[{text:t.id,code:!0},t.agent,mo(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:Aj(r),children:r},r))}),i.jsx(Mj,{attempt:t}),t.checks.map(r=>i.jsx(Tj,{check:r},r.name))]})}function Aj(t){return t.includes(" ✓ ")?"ok":t.includes(" ✗ ")?"bad":"wait"}const Lj={PASS:"Passed",FAIL:"Sent back",NEEDS_HUMAN:"Needs you"};function Rj({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":Lj[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}`,mo(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 _j(t,s,r){const[a,c]=x.useState(),u=x.useCallback(()=>{_i.ticket(t,s).then(c)},[t,s]);return x.useEffect(()=>(c(void 0),u(),Ms.onEvidence(u)),[u]),x.useEffect(u,[u,r]),{data:a,reload:u}}const kl={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 Oj(t){const[s,r]=x.useState(),[a,c]=x.useState(""),[u,f]=x.useState("rework"),{state:m,submitted:g,running:p,act:y}=t;if(p||m!=="verifying"&&m!=="held")return null;const v=N=>{r(s===N?void 0:N),c("")},j=N=>{N.preventDefault(),!(!s||!a.trim())&&(y({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(q,{variant:"primary",onClick:()=>void y({action:"approve"}),"data-tip":"Checks passed: approve and close the ticket",children:"Approve"}),g&&i.jsx(q,{onClick:()=>void y({action:"rerun"}),"data-tip":"Run the repo's checks again on the current code",children:"Re-run checks"}),i.jsx(q,{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(q,{on:s==="accept",onClick:()=>v("accept"),"data-tip":"Close it as done despite the failing checks",children:"Accept anyway…"}),i.jsx(q,{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:j,children:[i.jsx(He,{label:kl[s].label,children:i.jsx("textarea",{rows:2,value:a,onChange:N=>c(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:kl[s].hint}),i.jsxs("div",{className:"form-actions",children:[i.jsx(q,{variant:"ghost",onClick:()=>r(void 0),children:"Cancel"}),i.jsx(q,{type:"submit",variant:s==="accept"?"danger":"primary",disabled:!a.trim(),children:kl[s].submit})]})]})]})}const Pj={ticket:"set on this ticket",trail:"from the trail",none:"not set"},Dj=new Set(["verifying","rework","held"]);function zj(t){const{mapId:s,ticket:r,state:a}=t,{data:c,reload:u}=_j(s,r.id,r.updatedAt),[f,m]=x.useState();if(!c||c.level.level==="off"&&!c.attempts.length&&!Dj.has(a))return null;const g=y=>(m(void 0),_i.act({...y,mapId:s,ticketId:r.id,by:mt}).then(u,v=>m(v.message))),p=c.running;return i.jsxs("section",{className:"vf-panel",children:[i.jsxs("div",{className:"vf-head",children:[i.jsx(at,{as:"h4",children:"Verification"}),i.jsx(ge,{parts:[Mi[c.level.level],Pj[c.level.source]]}),r.state==="open"&&i.jsx($j,{value:r.verification,inherit:`Trail (${Mi[t.trail??"off"]})`,onChange:y=>void g({action:"level",level:y})})]}),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 ",mo(p.startedAt)]})]}),i.jsx(Oj,{state:a,submitted:c.attempts.length>0,running:!!p,act:g}),f&&i.jsx("p",{className:"vf-err",children:f}),c.verdicts.map(y=>i.jsx(Rj,{verdict:y},y.id)),c.attempts.map((y,v)=>i.jsx(Ij,{attempt:y,latest:v===0},y.id)),!c.attempts.length&&!p&&i.jsx(ge,{parts:[`Checks: ${c.level.checks.join(", ")||"none"}`,"run when the ticket is submitted"]})]})}function Bj({lease:t,onRelease:s}){const r=Mn(1e3),a=fo(t,r),c=a==="live";return i.jsxs("div",{className:`lease lease-${a} edge-note ${c?"":"edge-attention"}`,children:[i.jsxs("div",{className:"edge-note-head",children:[i.jsx(ge,{parts:[{text:`Claimed by ${t.agent}`,strong:!0},`active ${Gn(r-t.renewedAt)} ago`]}),!c&&i.jsx(In,{tone:"amber",children:"Stalled"})]}),i.jsx("p",{className:"t-meta lease-line",children:Fj(a,Uj(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(q,{variant:c?"default":"urgent",onClick:s,children:"Release to queue"})})]})}function Fj(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 Uj(t){const s=t/864e5;return s>=2?`${Math.round(s)} days`:Pt(Math.max(0,t))}function Wj({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 Hj({resolution:t,decisions:s,onOpenDecision:r}){const a=s.find(f=>!f.supersededBy)??s[0],c=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},c]}),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 Kj(t){const{t:s,state:r,session:a,mine:c,form:u,setForm:f,actions:m,onOpenChat:g}=t;return i.jsxs("div",{className:"actions",children:[a&&i.jsx(q,{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(q,{onClick:()=>m.claim(s.id),"data-tip":"Take this ticket yourself, so no agent picks it up",children:"Claim"}),(r==="frontier"||r==="claimed"&&c)&&i.jsx(q,{on:u==="resolve",onClick:()=>f(u==="resolve"?null:"resolve"),"data-tip":"Answer it yourself and close the ticket, with a decision record",children:"Resolve…"}),c&&r==="claimed"&&i.jsx(q,{onClick:()=>m.release(s.id),"data-tip":"Give the ticket back to the queue",children:"Release"}),(r==="frontier"||r==="blocked"||r==="parked")&&i.jsx(q,{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 Vj({t,state:s,tickets:r}){const a=new Map(r.map(p=>[p.id,p])),c=p=>{var y;return((y=a.get(p))==null?void 0:y.key)??p},u=t.blockedBy.map(p=>{var y;return`${c(p)}${((y=a.get(p))==null?void 0:y.state)==="closed"?" ✓":""}`}).join(", "),f=r.filter(p=>p.blockedBy.includes(t.id)).map(p=>p.key).join(", "),m=[["Type",vh[t.type]],["Assignee",t.assignee],["Blocked by",u],["Blocks",f],["Reviews",t.reviewOf&&c(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(In,{tone:"state",className:`st-${s}`,children:kh[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,y])=>[i.jsx("dt",{className:"t-label",children:p},`${p}-k`),i.jsx("dd",{children:y},`${p}-v`)])})]})}function Qj(t){const{snap:s,api:r,form:a,setForm:c}=t,{actions:u}=r,[f,m]=x.useState(""),[g,p]=x.useState(""),[y,v]=x.useState(""),[j,N]=x.useState("Not needed to reach the destination."),M=s.tickets.find(K=>K.id===t.id);if(!M)return i.jsx(Be,{children:"Ticket not found."});const S=Is(s.tickets,s.map.mode).get(M.id),E=t.sessions.find(K=>K.ticketId===M.id&&Qt(K)),I=M.assignee===mt,O=M.state==="open"?Bl(r.leases,s.map.id).get(M.id):void 0,L=[...M.comments].reverse().find(K=>/^\*\*(Resolution|Ruled out of scope)\*\*/.test(K.body)),J=M.comments.filter(K=>K!==L),Z=r.decisions.filter(K=>K.mapId===s.map.id&&K.ticketId===M.id);return i.jsxs("div",{className:"detail",children:[i.jsx(Vj,{t:M,state:S,tickets:s.tickets}),i.jsx(Ny,{mapId:s.map.id,ticketId:M.id}),i.jsx(Cj,{snap:s,t:M}),i.jsx(Dy,{snap:s,t:M}),M.closeReason==="not_planned"&&i.jsx(Vl,{label:"Save as dead end",draft:()=>{var K;return{title:`Ruled out: ${M.title}`,body:((K=M.comments.at(-1))==null?void 0:K.body)??M.body,kind:"dead-end",sources:[`trail:${s.map.key}`,`ticket:${M.key}`]}}}),O&&i.jsx(Bj,{lease:O,onRelease:()=>u.releaseLease(M.id)}),!O&&i.jsx(Gw,{mapId:s.map.id,ticketId:M.id}),i.jsx(zj,{mapId:s.map.id,trail:s.map.verification,ticket:M,state:S}),i.jsx(Kj,{t:M,state:S,session:E,mine:I,form:a,setForm:c,actions:u,onOpenChat:t.onOpenChat}),a==="resolve"&&i.jsxs(Et,{as:"form",tone:"inset",className:"inline-form",onSubmit:K=>{K.preventDefault(),f.trim()&&(u.resolve(M.id,f.trim(),{rationale:g.trim(),alternatives:y.split(`
146
+ `).map(le=>le.trim()).filter(Boolean)}),c(null),m(""),p(""),v(""))},children:[i.jsx(He,{label:"Resolution",children:i.jsx("textarea",{rows:3,value:f,onChange:K=>m(K.target.value),autoFocus:!0})}),i.jsx(He,{label:"Rationale",children:i.jsx("input",{value:g,onChange:K=>p(K.target.value)})}),i.jsx(He,{label:"Alternatives considered",children:i.jsx("textarea",{rows:2,value:y,onChange:K=>v(K.target.value),placeholder:"One per line"})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(q,{variant:"ghost",onClick:()=>c(null),children:"Cancel"}),i.jsx(q,{type:"submit",variant:"primary",disabled:!f.trim(),children:"Resolve"})]})]}),a==="rule"&&i.jsxs(Et,{as:"form",tone:"inset",className:"inline-form",onSubmit:K=>{K.preventDefault(),u.ruleOut({ticketId:M.id},j),c(null)},children:[i.jsx(He,{label:"Reason",children:i.jsx("input",{value:j,onChange:K=>N(K.target.value),autoFocus:!0})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(q,{variant:"ghost",onClick:()=>c(null),children:"Cancel"}),i.jsx(q,{type:"submit",variant:"danger",children:"Rule out"})]})]}),L&&i.jsx(Hj,{resolution:L,decisions:Z,onOpenDecision:t.onOpenDecision}),i.jsx("p",{className:"body",children:M.body}),i.jsx(Wj,{comments:J})]})}function qj({snap:t,item:s,api:r}){const a=Yf(t.map.mode),[c,u]=x.useState("research"),[f,m]=x.useState(s),[g,p]=x.useState(!1),[y,v]=x.useState([]),[j,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(In,{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:c,title:f,blockedBy:y,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 ${c===S?"on":""}`,onClick:()=>u(S),children:S},S)),ig.includes(c)&&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 ${y.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(q,{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},j)},children:[i.jsx(He,{label:"Reason",children:i.jsx("input",{value:j,onChange:S=>N(S.target.value)})}),i.jsx("div",{className:"form-actions",children:i.jsx(q,{type:"submit",variant:"danger",children:"Rule out"})})]})]})}function Gj({api:t,sessions:s,bare:r,onOpenChat:a,onOpenDecision:c}){const{snap:u,selection:f,actions:m}=t,[g,p]=x.useState(null),y=Yj(f);x.useEffect(()=>p(null),[y]);let v;return u?f?f.kind==="unspecified"?v=i.jsx(qj,{snap:u,item:f.item,api:t}):v=i.jsx(Qj,{snap:u,id:f.id,api:t,sessions:s,form:g,setForm:p,onOpenChat:a??m.openChat,onOpenDecision:c}):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 Yj(t){return(t==null?void 0:t.kind)==="ticket"?t.id:(t==null?void 0:t.kind)==="unspecified"?t.item:""}const Jj={holding:"Holding",challenged:"Challenged",invalidated:"Invalidated",confirmed:"Confirmed"};function Xj(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 Zj(t){const{a:s,snap:r}=t,a=s.tickets.flatMap(u=>r.tickets.filter(f=>f.id===u)),c=s.challenge&&`${s.challenge.by}: ${s.challenge.evidence}`;return i.jsx(gt,{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},Jj[s.status],Xj(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:c,detailText:c,trailing:t.onConfirm&&i.jsx(q,{size:"sm",variant:"ghost",disabled:t.busy,onClick:t.onConfirm,children:"Confirm"})})}function e1(t){const[s,r]=x.useState(),[a,c]=x.useState();return{confirm:async f=>{c(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(c(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 t1({snap:t,onSelect:s}){const{confirm:r,busy:a,error:c}=e1(t.map.id),u=t.map.sections.assumptions??[];return u.length?i.jsxs(i.Fragment,{children:[c&&i.jsx("p",{className:"urgent-text",children:c}),i.jsx("ul",{className:"assumptions row-list",children:u.map(f=>{const m=f.status==="holding"||f.status==="challenged";return i.jsx(Zj,{a:f,snap:t,onSelect:s,onConfirm:m?()=>void r(f.id):void 0,busy:a===f.id},f.id)})})]}):i.jsx(Be,{children:"None yet. They come from the accepted discovery brief or the trail's start."})}function n1(t){const[s,r]=x.useState([]),a=t==null?void 0:t.map.id,c=(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,c]),s}function s1({snap:t,activity:s,onTicket:r}){const a=n1(t),c=s.usageByMap[t.map.id],u=x.useMemo(()=>Nv({snap:t,journal:a,answered:s.answered,usage:c}),[t,a,s.answered,c]),f=u.interventions,m=[["Done",`${u.done}`,`${u.done} done · ${u.cancelled} cancelled · ${u.open} open`],["Lead time",Cs(u.trailLeadMs),"Trail lead time: from when the trail was charted to its last done ticket"],["Median ticket",Cs(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,y])=>i.jsxs("li",{"data-tip":y,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(q,{size:"sm",variant:"ghost","data-tip":"Download this report as markdown",onClick:()=>mh(`${t.map.key.replace("#","trail-")}-report.md`,Cv(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"?Cs(g.leadMs):g.outcome})]})},g.id))}):i.jsx(Be,{children:"No tickets yet"})]})}function i1({tab:t,snap:s,selection:r,onSelect:a,activity:c}){const u=s.map.sections;switch(t){case"report":return c?i.jsx(s1,{snap:s,activity:c,onTicket:f=>a({kind:"ticket",id:f})}):i.jsx(Be,{children:"No activity yet"});case"assumptions":return i.jsx(t1,{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(gt,{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(Be,{children:"None"});case"unspecified":return u.unspecified.length?i.jsx("ul",{className:"row-list unspecified",children:u.unspecified.map(f=>i.jsx(gt,{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(Be,{children:"None"});case"oos":return u.outOfScope.length?i.jsx("ul",{className:"row-list oos",children:u.outOfScope.map(f=>i.jsx(gt,{as:"li",title:f,titleText:f},f))}):i.jsx(Be,{children:"None"});case"notes":return i.jsx("p",{className:"notes t-body",children:u.notes||"No notes yet."});default:return t}}function r1({snap:t,selection:s,onSelect:r,bare:a,onAudit:c,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"}],y=t?i.jsx(i1,{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(Ge,{className:`zone sections ${a?"bare":""}`,style:a?void 0:{gridArea:"plan"},children:[!a&&i.jsx(rn,{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(Kl,{className:"sub",value:f,onChange:m,items:p}),f==="decisions"&&c&&i.jsx("button",{className:"link",onClick:c,children:"Audit ›"})]}),i.jsx("div",{className:"zone-b",children:y})]})}function o1(){var $e;const t=x.useMemo(()=>ey(Zk()),[]),s=ay(t),{snap:r,activity:a,selection:c,actions:u}=s,[f,m]=ly();x.useEffect(()=>yh(f.theme),[f.theme]);const[g,p]=x.useState(Xw),[y,v]=x.useState(!1),j=D0(t.kind),N=sy(),M=a.pending.length,S=z0(a,s.mapId);P0(M,r==null?void 0:r.map.title);const E=O0(s,N),I=rj(r,u.selectMap),O=Wy(I.briefText),L=oj({api:s,nav:E,knowledge:O,reviewBrief:I.review,openReroute:R=>I.openReroute(R.mapId,R.ref)}),J=ry(t,s,f.briefing,($e=L.attention.view)==null?void 0:$e.items),Z=i.jsx(cw,{api:s,nav:E,bp:N,scoped:S,attn:L,above:I.inboxCard}),K=i.jsx(A0,{api:s,sessions:S.sessions,onSelect:E.select,onNewTrail:()=>v(!0),compact:N==="mobile",minFit:N==="mobile"?.7:0,trail:I}),le=R=>i.jsx(Gj,{api:s,sessions:S.sessions,bare:R,onOpenChat:V=>E.openChat(V),onOpenDecision:E.openDecisions}),de={activity:S,snap:r,leases:s.leases,onTicket:R=>E.select({kind:"ticket",id:R}),onOpenChat:R=>E.openChat(R)},Q=R=>i.jsx(r1,{snap:r,selection:c,onSelect:E.select,bare:R,onAudit:()=>E.openDecisions(),activity:S}),xe=E.decisionsView&&i.jsx(Sj,{api:s,bp:N,focus:E.decisionsView.focus,onClose:()=>E.setDecisionsView(null),onOpenTicket:E.openTicket}),De=J.shown&&i.jsx(jy,{brief:J,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(Th.Provider,{value:O,children:i.jsxs("div",{className:`app bp-${N}`,children:[i.jsx(vx,{api:s,rt:t,repo:j,brief:J,attention:L.header,decisionsOpen:!!E.decisionsView,onDecisions:()=>E.decisionsView?E.setDecisionsView(null):E.openDecisions(),onNewTrail:()=>v(!0),onSettings:p,onToggleTheme:R=>m({theme:R?"night":"day"})}),N==="wide"&&i.jsxs(i.Fragment,{children:[Z,K,le(!1),i.jsx(pj,{...de}),i.jsx(mj,{...de}),Q(!1),xe]}),N==="laptop"&&i.jsxs(i.Fragment,{children:[Z,K,i.jsx(t0,{tab:E.sideTab,onTab:E.setSideTab,unspecified:r==null?void 0:r.map.sections.unspecified.length,ticket:le(!0),activity:i.jsx(Uf,{...de}),plan:Q(!0)}),xe]}),N==="mobile"&&i.jsxs(i.Fragment,{children:[i.jsx(_0,{tab:E.phoneTab,decisions:xe,inbox:Z,map:K,ticket:le(!0),activity:i.jsx(Uf,{...de}),plan:Q(!0)}),i.jsx(R0,{tab:E.phoneTab,covered:!!E.decisionsView,pending:M,onPick:R=>{E.setPhoneTab(R),E.setDecisionsView(null)}})]}),De,I.dialog,s.error&&i.jsx("div",{className:"error-toast",children:s.error}),g&&i.jsx(e0,{rt:t,api:s,prefs:f,update:m,focus:g,onClose:()=>p(!1)}),y&&i.jsx(gw,{rt:t,onClose:()=>v(!1),onCreated:R=>u.selectMap(R)}),!f.onboarded&&i.jsx(Nw,{prefs:f,update:m,activeTracker:t.kind}),i.jsx(Uy,{})]})})}yh(Ul().theme);tg.createRoot(document.getElementById("root")).render(i.jsxs(i.Fragment,{children:[i.jsx(o1,{}),i.jsx(vy,{})]}));