teamtrail 0.24.1-next.34 → 0.24.2-next.35
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.
|
@@ -6,7 +6,7 @@ var $v=Object.defineProperty;var Tv=(e,t,r)=>t in e?$v(e,t,{enumerable:!0,config
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var Af;function Ev(){if(Af)return ye;Af=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),d=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),y=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=y&&T[y]||T["@@iterator"],typeof T=="function"?T:null)}var j={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},$=Object.assign,N={};function E(T,_,he){this.props=T,this.context=_,this.refs=N,this.updater=he||j}E.prototype.isReactComponent={},E.prototype.setState=function(T,_){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,_,"setState")},E.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function M(){}M.prototype=E.prototype;function R(T,_,he){this.props=T,this.context=_,this.refs=N,this.updater=he||j}var O=R.prototype=new M;O.constructor=R,$(O,E.prototype),O.isPureReactComponent=!0;var X=Array.isArray,
|
|
9
|
+
*/var Af;function Ev(){if(Af)return ye;Af=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),d=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),y=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=y&&T[y]||T["@@iterator"],typeof T=="function"?T:null)}var j={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},$=Object.assign,N={};function E(T,_,he){this.props=T,this.context=_,this.refs=N,this.updater=he||j}E.prototype.isReactComponent={},E.prototype.setState=function(T,_){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,_,"setState")},E.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function M(){}M.prototype=E.prototype;function R(T,_,he){this.props=T,this.context=_,this.refs=N,this.updater=he||j}var O=R.prototype=new M;O.constructor=R,$(O,E.prototype),O.isPureReactComponent=!0;var X=Array.isArray,se=Object.prototype.hasOwnProperty,Q={current:null},F={key:!0,ref:!0,__self:!0,__source:!0};function ie(T,_,he){var pe,de={},we=null,me=null;if(_!=null)for(pe in _.ref!==void 0&&(me=_.ref),_.key!==void 0&&(we=""+_.key),_)se.call(_,pe)&&!F.hasOwnProperty(pe)&&(de[pe]=_[pe]);var ke=arguments.length-2;if(ke===1)de.children=he;else if(1<ke){for(var $e=Array(ke),ut=0;ut<ke;ut++)$e[ut]=arguments[ut+2];de.children=$e}if(T&&T.defaultProps)for(pe in ke=T.defaultProps,ke)de[pe]===void 0&&(de[pe]=ke[pe]);return{$$typeof:e,type:T,key:we,ref:me,props:de,_owner:Q.current}}function V(T,_){return{$$typeof:e,type:T.type,key:_,ref:T.ref,props:T.props,_owner:T._owner}}function ge(T){return typeof T=="object"&&T!==null&&T.$$typeof===e}function Re(T){var _={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(he){return _[he]})}var be=/\/+/g;function te(T,_){return typeof T=="object"&&T!==null&&T.key!=null?Re(""+T.key):_.toString(36)}function P(T,_,he,pe,de){var we=typeof T;(we==="undefined"||we==="boolean")&&(T=null);var me=!1;if(T===null)me=!0;else switch(we){case"string":case"number":me=!0;break;case"object":switch(T.$$typeof){case e:case t:me=!0}}if(me)return me=T,de=de(me),T=pe===""?"."+te(me,0):pe,X(de)?(he="",T!=null&&(he=T.replace(be,"$&/")+"/"),P(de,_,he,"",function(ut){return ut})):de!=null&&(ge(de)&&(de=V(de,he+(!de.key||me&&me.key===de.key?"":(""+de.key).replace(be,"$&/")+"/")+T)),_.push(de)),1;if(me=0,pe=pe===""?".":pe+":",X(T))for(var ke=0;ke<T.length;ke++){we=T[ke];var $e=pe+te(we,ke);me+=P(we,_,he,$e,de)}else if($e=w(T),typeof $e=="function")for(T=$e.call(T),ke=0;!(we=T.next()).done;)we=we.value,$e=pe+te(we,ke++),me+=P(we,_,he,$e,de);else if(we==="object")throw _=String(T),Error("Objects are not valid as a React child (found: "+(_==="[object Object]"?"object with keys {"+Object.keys(T).join(", ")+"}":_)+"). If you meant to render a collection of children, use an array instead.");return me}function Y(T,_,he){if(T==null)return T;var pe=[],de=0;return P(T,pe,"","",function(we){return _.call(he,we,de++)}),pe}function ae(T){if(T._status===-1){var _=T._result;_=_(),_.then(function(he){(T._status===0||T._status===-1)&&(T._status=1,T._result=he)},function(he){(T._status===0||T._status===-1)&&(T._status=2,T._result=he)}),T._status===-1&&(T._status=0,T._result=_)}if(T._status===1)return T._result.default;throw T._result}var Z={current:null},U={transition:null},D={ReactCurrentDispatcher:Z,ReactCurrentBatchConfig:U,ReactCurrentOwner:Q};function H(){throw Error("act(...) is not supported in production builds of React.")}return ye.Children={map:Y,forEach:function(T,_,he){Y(T,function(){_.apply(this,arguments)},he)},count:function(T){var _=0;return Y(T,function(){_++}),_},toArray:function(T){return Y(T,function(_){return _})||[]},only:function(T){if(!ge(T))throw Error("React.Children.only expected to receive a single React element child.");return T}},ye.Component=E,ye.Fragment=r,ye.Profiler=l,ye.PureComponent=R,ye.StrictMode=o,ye.Suspense=g,ye.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=D,ye.act=H,ye.cloneElement=function(T,_,he){if(T==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+T+".");var pe=$({},T.props),de=T.key,we=T.ref,me=T._owner;if(_!=null){if(_.ref!==void 0&&(we=_.ref,me=Q.current),_.key!==void 0&&(de=""+_.key),T.type&&T.type.defaultProps)var ke=T.type.defaultProps;for($e in _)se.call(_,$e)&&!F.hasOwnProperty($e)&&(pe[$e]=_[$e]===void 0&&ke!==void 0?ke[$e]:_[$e])}var $e=arguments.length-2;if($e===1)pe.children=he;else if(1<$e){ke=Array($e);for(var ut=0;ut<$e;ut++)ke[ut]=arguments[ut+2];pe.children=ke}return{$$typeof:e,type:T.type,key:de,ref:we,props:pe,_owner:me}},ye.createContext=function(T){return T={$$typeof:d,_currentValue:T,_currentValue2:T,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},T.Provider={$$typeof:c,_context:T},T.Consumer=T},ye.createElement=ie,ye.createFactory=function(T){var _=ie.bind(null,T);return _.type=T,_},ye.createRef=function(){return{current:null}},ye.forwardRef=function(T){return{$$typeof:f,render:T}},ye.isValidElement=ge,ye.lazy=function(T){return{$$typeof:v,_payload:{_status:-1,_result:T},_init:ae}},ye.memo=function(T,_){return{$$typeof:m,type:T,compare:_===void 0?null:_}},ye.startTransition=function(T){var _=U.transition;U.transition={};try{T()}finally{U.transition=_}},ye.unstable_act=H,ye.useCallback=function(T,_){return Z.current.useCallback(T,_)},ye.useContext=function(T){return Z.current.useContext(T)},ye.useDebugValue=function(){},ye.useDeferredValue=function(T){return Z.current.useDeferredValue(T)},ye.useEffect=function(T,_){return Z.current.useEffect(T,_)},ye.useId=function(){return Z.current.useId()},ye.useImperativeHandle=function(T,_,he){return Z.current.useImperativeHandle(T,_,he)},ye.useInsertionEffect=function(T,_){return Z.current.useInsertionEffect(T,_)},ye.useLayoutEffect=function(T,_){return Z.current.useLayoutEffect(T,_)},ye.useMemo=function(T,_){return Z.current.useMemo(T,_)},ye.useReducer=function(T,_,he){return Z.current.useReducer(T,_,he)},ye.useRef=function(T){return Z.current.useRef(T)},ye.useState=function(T){return Z.current.useState(T)},ye.useSyncExternalStore=function(T,_,he){return Z.current.useSyncExternalStore(T,_,he)},ye.useTransition=function(){return Z.current.useTransition()},ye.version="18.3.1",ye}var Lf;function uc(){return Lf||(Lf=1,_l.exports=Ev()),_l.exports}/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.production.min.js
|
|
12
12
|
*
|
|
@@ -22,7 +22,7 @@ var $v=Object.defineProperty;var Tv=(e,t,r)=>t in e?$v(e,t,{enumerable:!0,config
|
|
|
22
22
|
*
|
|
23
23
|
* This source code is licensed under the MIT license found in the
|
|
24
24
|
* LICENSE file in the root directory of this source tree.
|
|
25
|
-
*/var Pf;function Av(){return Pf||(Pf=1,(function(e){function t(U,
|
|
25
|
+
*/var Pf;function Av(){return Pf||(Pf=1,(function(e){function t(U,D){var H=U.length;U.push(D);e:for(;0<H;){var T=H-1>>>1,_=U[T];if(0<l(_,D))U[T]=D,U[H]=_,H=T;else break e}}function r(U){return U.length===0?null:U[0]}function o(U){if(U.length===0)return null;var D=U[0],H=U.pop();if(H!==D){U[0]=H;e:for(var T=0,_=U.length,he=_>>>1;T<he;){var pe=2*(T+1)-1,de=U[pe],we=pe+1,me=U[we];if(0>l(de,H))we<_&&0>l(me,de)?(U[T]=me,U[we]=H,T=we):(U[T]=de,U[pe]=H,T=pe);else if(we<_&&0>l(me,H))U[T]=me,U[we]=H,T=we;else break e}}return D}function l(U,D){var H=U.sortIndex-D.sortIndex;return H!==0?H:U.id-D.id}if(typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var d=Date,f=d.now();e.unstable_now=function(){return d.now()-f}}var g=[],m=[],v=1,y=null,w=3,j=!1,$=!1,N=!1,E=typeof setTimeout=="function"?setTimeout:null,M=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function O(U){for(var D=r(m);D!==null;){if(D.callback===null)o(m);else if(D.startTime<=U)o(m),D.sortIndex=D.expirationTime,t(g,D);else break;D=r(m)}}function X(U){if(N=!1,O(U),!$)if(r(g)!==null)$=!0,ae(se);else{var D=r(m);D!==null&&Z(X,D.startTime-U)}}function se(U,D){$=!1,N&&(N=!1,M(ie),ie=-1),j=!0;var H=w;try{for(O(D),y=r(g);y!==null&&(!(y.expirationTime>D)||U&&!Re());){var T=y.callback;if(typeof T=="function"){y.callback=null,w=y.priorityLevel;var _=T(y.expirationTime<=D);D=e.unstable_now(),typeof _=="function"?y.callback=_:y===r(g)&&o(g),O(D)}else o(g);y=r(g)}if(y!==null)var he=!0;else{var pe=r(m);pe!==null&&Z(X,pe.startTime-D),he=!1}return he}finally{y=null,w=H,j=!1}}var Q=!1,F=null,ie=-1,V=5,ge=-1;function Re(){return!(e.unstable_now()-ge<V)}function be(){if(F!==null){var U=e.unstable_now();ge=U;var D=!0;try{D=F(!0,U)}finally{D?te():(Q=!1,F=null)}}else Q=!1}var te;if(typeof R=="function")te=function(){R(be)};else if(typeof MessageChannel<"u"){var P=new MessageChannel,Y=P.port2;P.port1.onmessage=be,te=function(){Y.postMessage(null)}}else te=function(){E(be,0)};function ae(U){F=U,Q||(Q=!0,te())}function Z(U,D){ie=E(function(){U(e.unstable_now())},D)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(U){U.callback=null},e.unstable_continueExecution=function(){$||j||($=!0,ae(se))},e.unstable_forceFrameRate=function(U){0>U||125<U?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):V=0<U?Math.floor(1e3/U):5},e.unstable_getCurrentPriorityLevel=function(){return w},e.unstable_getFirstCallbackNode=function(){return r(g)},e.unstable_next=function(U){switch(w){case 1:case 2:case 3:var D=3;break;default:D=w}var H=w;w=D;try{return U()}finally{w=H}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(U,D){switch(U){case 1:case 2:case 3:case 4:case 5:break;default:U=3}var H=w;w=U;try{return D()}finally{w=H}},e.unstable_scheduleCallback=function(U,D,H){var T=e.unstable_now();switch(typeof H=="object"&&H!==null?(H=H.delay,H=typeof H=="number"&&0<H?T+H:T):H=T,U){case 1:var _=-1;break;case 2:_=250;break;case 5:_=1073741823;break;case 4:_=1e4;break;default:_=5e3}return _=H+_,U={id:v++,callback:D,priorityLevel:U,startTime:H,expirationTime:_,sortIndex:-1},H>T?(U.sortIndex=H,t(m,U),r(g)===null&&U===r(m)&&(N?(M(ie),ie=-1):N=!0,Z(X,H-T))):(U.sortIndex=_,t(g,U),$||j||($=!0,ae(se))),U},e.unstable_shouldYield=Re,e.unstable_wrapCallback=function(U){var D=w;return function(){var H=w;w=D;try{return U.apply(this,arguments)}finally{w=H}}}})(zl)),zl}var _f;function Lv(){return _f||(_f=1,Bl.exports=Av()),Bl.exports}/**
|
|
26
26
|
* @license React
|
|
27
27
|
* react-dom.production.min.js
|
|
28
28
|
*
|
|
@@ -30,14 +30,14 @@ var $v=Object.defineProperty;var Tv=(e,t,r)=>t in e?$v(e,t,{enumerable:!0,config
|
|
|
30
30
|
*
|
|
31
31
|
* This source code is licensed under the MIT license found in the
|
|
32
32
|
* LICENSE file in the root directory of this source tree.
|
|
33
|
-
*/var Df;function Rv(){if(Df)return yt;Df=1;var e=uc(),t=Lv();function r(n){for(var s="https://reactjs.org/docs/error-decoder.html?invariant="+n,a=1;a<arguments.length;a++)s+="&args[]="+encodeURIComponent(arguments[a]);return"Minified React error #"+n+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var o=new Set,l={};function c(n,s){d(n,s),d(n+"Capture",s)}function d(n,s){for(l[n]=s,n=0;n<s.length;n++)o.add(s[n])}var f=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),g=Object.prototype.hasOwnProperty,m=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,v={},y={};function w(n){return g.call(y,n)?!0:g.call(v,n)?!1:m.test(n)?y[n]=!0:(v[n]=!0,!1)}function j(n,s,a,u){if(a!==null&&a.type===0)return!1;switch(typeof s){case"function":case"symbol":return!0;case"boolean":return u?!1:a!==null?!a.acceptsBooleans:(n=n.toLowerCase().slice(0,5),n!=="data-"&&n!=="aria-");default:return!1}}function $(n,s,a,u){if(s===null||typeof s>"u"||j(n,s,a,u))return!0;if(u)return!1;if(a!==null)switch(a.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function N(n,s,a,u,h,p,k){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=u,this.attributeNamespace=h,this.mustUseProperty=a,this.propertyName=n,this.type=s,this.sanitizeURL=p,this.removeEmptyString=k}var E={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(n){E[n]=new N(n,0,!1,n,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(n){var s=n[0];E[s]=new N(s,1,!1,n[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(n){E[n]=new N(n,2,!1,n.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(n){E[n]=new N(n,2,!1,n,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(n){E[n]=new N(n,3,!1,n.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(n){E[n]=new N(n,3,!0,n,null,!1,!1)}),["capture","download"].forEach(function(n){E[n]=new N(n,4,!1,n,null,!1,!1)}),["cols","rows","size","span"].forEach(function(n){E[n]=new N(n,6,!1,n,null,!1,!1)}),["rowSpan","start"].forEach(function(n){E[n]=new N(n,5,!1,n.toLowerCase(),null,!1,!1)});var M=/[\-:]([a-z])/g;function R(n){return n[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(n){var s=n.replace(M,R);E[s]=new N(s,1,!1,n,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(n){var s=n.replace(M,R);E[s]=new N(s,1,!1,n,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(n){var s=n.replace(M,R);E[s]=new N(s,1,!1,n,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(n){E[n]=new N(n,1,!1,n.toLowerCase(),null,!1,!1)}),E.xlinkHref=new N("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(n){E[n]=new N(n,1,!1,n.toLowerCase(),null,!0,!0)});function O(n,s,a,u){var h=E.hasOwnProperty(s)?E[s]:null;(h!==null?h.type!==0:u||!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&($(s,a,h,u)&&(a=null),u||h===null?w(s)&&(a===null?n.removeAttribute(s):n.setAttribute(s,""+a)):h.mustUseProperty?n[h.propertyName]=a===null?h.type===3?!1:"":a:(s=h.attributeName,u=h.attributeNamespace,a===null?n.removeAttribute(s):(h=h.type,a=h===3||h===4&&a===!0?"":""+a,u?n.setAttributeNS(u,s,a):n.setAttribute(s,a))))}var X=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
|
|
33
|
+
*/var Df;function Rv(){if(Df)return yt;Df=1;var e=uc(),t=Lv();function r(n){for(var s="https://reactjs.org/docs/error-decoder.html?invariant="+n,a=1;a<arguments.length;a++)s+="&args[]="+encodeURIComponent(arguments[a]);return"Minified React error #"+n+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var o=new Set,l={};function c(n,s){d(n,s),d(n+"Capture",s)}function d(n,s){for(l[n]=s,n=0;n<s.length;n++)o.add(s[n])}var f=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),g=Object.prototype.hasOwnProperty,m=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,v={},y={};function w(n){return g.call(y,n)?!0:g.call(v,n)?!1:m.test(n)?y[n]=!0:(v[n]=!0,!1)}function j(n,s,a,u){if(a!==null&&a.type===0)return!1;switch(typeof s){case"function":case"symbol":return!0;case"boolean":return u?!1:a!==null?!a.acceptsBooleans:(n=n.toLowerCase().slice(0,5),n!=="data-"&&n!=="aria-");default:return!1}}function $(n,s,a,u){if(s===null||typeof s>"u"||j(n,s,a,u))return!0;if(u)return!1;if(a!==null)switch(a.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function N(n,s,a,u,h,p,k){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=u,this.attributeNamespace=h,this.mustUseProperty=a,this.propertyName=n,this.type=s,this.sanitizeURL=p,this.removeEmptyString=k}var E={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(n){E[n]=new N(n,0,!1,n,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(n){var s=n[0];E[s]=new N(s,1,!1,n[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(n){E[n]=new N(n,2,!1,n.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(n){E[n]=new N(n,2,!1,n,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(n){E[n]=new N(n,3,!1,n.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(n){E[n]=new N(n,3,!0,n,null,!1,!1)}),["capture","download"].forEach(function(n){E[n]=new N(n,4,!1,n,null,!1,!1)}),["cols","rows","size","span"].forEach(function(n){E[n]=new N(n,6,!1,n,null,!1,!1)}),["rowSpan","start"].forEach(function(n){E[n]=new N(n,5,!1,n.toLowerCase(),null,!1,!1)});var M=/[\-:]([a-z])/g;function R(n){return n[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(n){var s=n.replace(M,R);E[s]=new N(s,1,!1,n,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(n){var s=n.replace(M,R);E[s]=new N(s,1,!1,n,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(n){var s=n.replace(M,R);E[s]=new N(s,1,!1,n,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(n){E[n]=new N(n,1,!1,n.toLowerCase(),null,!1,!1)}),E.xlinkHref=new N("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(n){E[n]=new N(n,1,!1,n.toLowerCase(),null,!0,!0)});function O(n,s,a,u){var h=E.hasOwnProperty(s)?E[s]:null;(h!==null?h.type!==0:u||!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&($(s,a,h,u)&&(a=null),u||h===null?w(s)&&(a===null?n.removeAttribute(s):n.setAttribute(s,""+a)):h.mustUseProperty?n[h.propertyName]=a===null?h.type===3?!1:"":a:(s=h.attributeName,u=h.attributeNamespace,a===null?n.removeAttribute(s):(h=h.type,a=h===3||h===4&&a===!0?"":""+a,u?n.setAttributeNS(u,s,a):n.setAttribute(s,a))))}var X=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,se=Symbol.for("react.element"),Q=Symbol.for("react.portal"),F=Symbol.for("react.fragment"),ie=Symbol.for("react.strict_mode"),V=Symbol.for("react.profiler"),ge=Symbol.for("react.provider"),Re=Symbol.for("react.context"),be=Symbol.for("react.forward_ref"),te=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),Y=Symbol.for("react.memo"),ae=Symbol.for("react.lazy"),Z=Symbol.for("react.offscreen"),U=Symbol.iterator;function D(n){return n===null||typeof n!="object"?null:(n=U&&n[U]||n["@@iterator"],typeof n=="function"?n:null)}var H=Object.assign,T;function _(n){if(T===void 0)try{throw Error()}catch(a){var s=a.stack.trim().match(/\n( *(at )?)/);T=s&&s[1]||""}return`
|
|
34
34
|
`+T+n}var he=!1;function pe(n,s){if(!n||he)return"";he=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(s)if(s=function(){throw Error()},Object.defineProperty(s.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(s,[])}catch(L){var u=L}Reflect.construct(n,[],s)}else{try{s.call()}catch(L){u=L}n.call(s.prototype)}else{try{throw Error()}catch(L){u=L}n()}}catch(L){if(L&&u&&typeof L.stack=="string"){for(var h=L.stack.split(`
|
|
35
35
|
`),p=u.stack.split(`
|
|
36
36
|
`),k=h.length-1,S=p.length-1;1<=k&&0<=S&&h[k]!==p[S];)S--;for(;1<=k&&0<=S;k--,S--)if(h[k]!==p[S]){if(k!==1||S!==1)do if(k--,S--,0>S||h[k]!==p[S]){var b=`
|
|
37
|
-
`+h[k].replace(" at new "," at ");return n.displayName&&b.includes("<anonymous>")&&(b=b.replace("<anonymous>",n.displayName)),b}while(1<=k&&0<=S);break}}}finally{he=!1,Error.prepareStackTrace=a}return(n=n?n.displayName||n.name:"")?_(n):""}function de(n){switch(n.tag){case 5:return _(n.type);case 16:return _("Lazy");case 13:return _("Suspense");case 19:return _("SuspenseList");case 0:case 2:case 15:return n=pe(n.type,!1),n;case 11:return n=pe(n.type.render,!1),n;case 1:return n=pe(n.type,!0),n;default:return""}}function we(n){if(n==null)return null;if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case q:return"Fragment";case D:return"Portal";case V:return"Profiler";case re:return"StrictMode";case te:return"Suspense";case P:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case Re:return(n.displayName||"Context")+".Consumer";case ge:return(n._context.displayName||"Context")+".Provider";case be:var s=n.render;return n=n.displayName,n||(n=s.displayName||s.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case Y:return s=n.displayName||null,s!==null?s:we(n.type)||"Memo";case ae:s=n._payload,n=n._init;try{return we(n(s))}catch{}}return null}function me(n){var s=n.type;switch(n.tag){case 24:return"Cache";case 9:return(s.displayName||"Context")+".Consumer";case 10:return(s._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return n=s.render,n=n.displayName||n.name||"",s.displayName||(n!==""?"ForwardRef("+n+")":"ForwardRef");case 7:return"Fragment";case 5:return s;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return we(s);case 8:return s===re?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s}return null}function ke(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function $e(n){var s=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function ut(n){var s=$e(n)?"checked":"value",a=Object.getOwnPropertyDescriptor(n.constructor.prototype,s),u=""+n[s];if(!n.hasOwnProperty(s)&&typeof a<"u"&&typeof a.get=="function"&&typeof a.set=="function"){var h=a.get,p=a.set;return Object.defineProperty(n,s,{configurable:!0,get:function(){return h.call(this)},set:function(k){u=""+k,p.call(this,k)}}),Object.defineProperty(n,s,{enumerable:a.enumerable}),{getValue:function(){return u},setValue:function(k){u=""+k},stopTracking:function(){n._valueTracker=null,delete n[s]}}}}function ss(n){n._valueTracker||(n._valueTracker=ut(n))}function _c(n){if(!n)return!1;var s=n._valueTracker;if(!s)return!0;var a=s.getValue(),u="";return n&&(u=$e(n)?n.checked?"true":"false":n.value),n=u,n!==a?(s.setValue(n),!0):!1}function Qi(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}function Ho(n,s){var a=s.checked;return H({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:a??n._wrapperState.initialChecked})}function Dc(n,s){var a=s.defaultValue==null?"":s.defaultValue,u=s.checked!=null?s.checked:s.defaultChecked;a=ke(s.value!=null?s.value:a),n._wrapperState={initialChecked:u,initialValue:a,controlled:s.type==="checkbox"||s.type==="radio"?s.checked!=null:s.value!=null}}function Bc(n,s){s=s.checked,s!=null&&O(n,"checked",s,!1)}function Wo(n,s){Bc(n,s);var a=ke(s.value),u=s.type;if(a!=null)u==="number"?(a===0&&n.value===""||n.value!=a)&&(n.value=""+a):n.value!==""+a&&(n.value=""+a);else if(u==="submit"||u==="reset"){n.removeAttribute("value");return}s.hasOwnProperty("value")?Ko(n,s.type,a):s.hasOwnProperty("defaultValue")&&Ko(n,s.type,ke(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(n.defaultChecked=!!s.defaultChecked)}function zc(n,s,a){if(s.hasOwnProperty("value")||s.hasOwnProperty("defaultValue")){var u=s.type;if(!(u!=="submit"&&u!=="reset"||s.value!==void 0&&s.value!==null))return;s=""+n._wrapperState.initialValue,a||s===n.value||(n.value=s),n.defaultValue=s}a=n.name,a!==""&&(n.name=""),n.defaultChecked=!!n._wrapperState.initialChecked,a!==""&&(n.name=a)}function Ko(n,s,a){(s!=="number"||Qi(n.ownerDocument)!==n)&&(a==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+a&&(n.defaultValue=""+a))}var Vs=Array.isArray;function is(n,s,a,u){if(n=n.options,s){s={};for(var h=0;h<a.length;h++)s["$"+a[h]]=!0;for(a=0;a<n.length;a++)h=s.hasOwnProperty("$"+n[a].value),n[a].selected!==h&&(n[a].selected=h),h&&u&&(n[a].defaultSelected=!0)}else{for(a=""+ke(a),s=null,h=0;h<n.length;h++){if(n[h].value===a){n[h].selected=!0,u&&(n[h].defaultSelected=!0);return}s!==null||n[h].disabled||(s=n[h])}s!==null&&(s.selected=!0)}}function Vo(n,s){if(s.dangerouslySetInnerHTML!=null)throw Error(r(91));return H({},s,{value:void 0,defaultValue:void 0,children:""+n._wrapperState.initialValue})}function Fc(n,s){var a=s.value;if(a==null){if(a=s.children,s=s.defaultValue,a!=null){if(s!=null)throw Error(r(92));if(Vs(a)){if(1<a.length)throw Error(r(93));a=a[0]}s=a}s==null&&(s=""),a=s}n._wrapperState={initialValue:ke(a)}}function Uc(n,s){var a=ke(s.value),u=ke(s.defaultValue);a!=null&&(a=""+a,a!==n.value&&(n.value=a),s.defaultValue==null&&n.defaultValue!==a&&(n.defaultValue=a)),u!=null&&(n.defaultValue=""+u)}function Hc(n){var s=n.textContent;s===n._wrapperState.initialValue&&s!==""&&s!==null&&(n.value=s)}function Wc(n){switch(n){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Go(n,s){return n==null||n==="http://www.w3.org/1999/xhtml"?Wc(s):n==="http://www.w3.org/2000/svg"&&s==="foreignObject"?"http://www.w3.org/1999/xhtml":n}var qi,Kc=(function(n){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(s,a,u,h){MSApp.execUnsafeLocalFunction(function(){return n(s,a,u,h)})}:n})(function(n,s){if(n.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in n)n.innerHTML=s;else{for(qi=qi||document.createElement("div"),qi.innerHTML="<svg>"+s.valueOf().toString()+"</svg>",s=qi.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;s.firstChild;)n.appendChild(s.firstChild)}});function Gs(n,s){if(s){var a=n.firstChild;if(a&&a===n.lastChild&&a.nodeType===3){a.nodeValue=s;return}}n.textContent=s}var Qs={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Mp=["Webkit","ms","Moz","O"];Object.keys(Qs).forEach(function(n){Mp.forEach(function(s){s=s+n.charAt(0).toUpperCase()+n.substring(1),Qs[s]=Qs[n]})});function Vc(n,s,a){return s==null||typeof s=="boolean"||s===""?"":a||typeof s!="number"||s===0||Qs.hasOwnProperty(n)&&Qs[n]?(""+s).trim():s+"px"}function Gc(n,s){n=n.style;for(var a in s)if(s.hasOwnProperty(a)){var u=a.indexOf("--")===0,h=Vc(a,s[a],u);a==="float"&&(a="cssFloat"),u?n.setProperty(a,h):n[a]=h}}var Ap=H({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Qo(n,s){if(s){if(Ap[n]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(r(137,n));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(r(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(r(61))}if(s.style!=null&&typeof s.style!="object")throw Error(r(62))}}function qo(n,s){if(n.indexOf("-")===-1)return typeof s.is=="string";switch(n){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Yo=null;function Jo(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var Xo=null,rs=null,os=null;function Qc(n){if(n=gi(n)){if(typeof Xo!="function")throw Error(r(280));var s=n.stateNode;s&&(s=kr(s),Xo(n.stateNode,n.type,s))}}function qc(n){rs?os?os.push(n):os=[n]:rs=n}function Yc(){if(rs){var n=rs,s=os;if(os=rs=null,Qc(n),s)for(n=0;n<s.length;n++)Qc(s[n])}}function Jc(n,s){return n(s)}function Xc(){}var Zo=!1;function Zc(n,s,a){if(Zo)return n(s,a);Zo=!0;try{return Jc(n,s,a)}finally{Zo=!1,(rs!==null||os!==null)&&(Xc(),Yc())}}function qs(n,s){var a=n.stateNode;if(a===null)return null;var u=kr(a);if(u===null)return null;a=u[s];e:switch(s){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(u=!u.disabled)||(n=n.type,u=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!u;break e;default:n=!1}if(n)return null;if(a&&typeof a!="function")throw Error(r(231,s,typeof a));return a}var ea=!1;if(f)try{var Ys={};Object.defineProperty(Ys,"passive",{get:function(){ea=!0}}),window.addEventListener("test",Ys,Ys),window.removeEventListener("test",Ys,Ys)}catch{ea=!1}function Lp(n,s,a,u,h,p,k,S,b){var L=Array.prototype.slice.call(arguments,3);try{s.apply(a,L)}catch(F){this.onError(F)}}var Js=!1,Yi=null,Ji=!1,ta=null,Rp={onError:function(n){Js=!0,Yi=n}};function Op(n,s,a,u,h,p,k,S,b){Js=!1,Yi=null,Lp.apply(Rp,arguments)}function Pp(n,s,a,u,h,p,k,S,b){if(Op.apply(this,arguments),Js){if(Js){var L=Yi;Js=!1,Yi=null}else throw Error(r(198));Ji||(Ji=!0,ta=L)}}function Fn(n){var s=n,a=n;if(n.alternate)for(;s.return;)s=s.return;else{n=s;do s=n,(s.flags&4098)!==0&&(a=s.return),n=s.return;while(n)}return s.tag===3?a:null}function eu(n){if(n.tag===13){var s=n.memoizedState;if(s===null&&(n=n.alternate,n!==null&&(s=n.memoizedState)),s!==null)return s.dehydrated}return null}function tu(n){if(Fn(n)!==n)throw Error(r(188))}function _p(n){var s=n.alternate;if(!s){if(s=Fn(n),s===null)throw Error(r(188));return s!==n?null:n}for(var a=n,u=s;;){var h=a.return;if(h===null)break;var p=h.alternate;if(p===null){if(u=h.return,u!==null){a=u;continue}break}if(h.child===p.child){for(p=h.child;p;){if(p===a)return tu(h),n;if(p===u)return tu(h),s;p=p.sibling}throw Error(r(188))}if(a.return!==u.return)a=h,u=p;else{for(var k=!1,S=h.child;S;){if(S===a){k=!0,a=h,u=p;break}if(S===u){k=!0,u=h,a=p;break}S=S.sibling}if(!k){for(S=p.child;S;){if(S===a){k=!0,a=p,u=h;break}if(S===u){k=!0,u=p,a=h;break}S=S.sibling}if(!k)throw Error(r(189))}}if(a.alternate!==u)throw Error(r(190))}if(a.tag!==3)throw Error(r(188));return a.stateNode.current===a?n:s}function nu(n){return n=_p(n),n!==null?su(n):null}function su(n){if(n.tag===5||n.tag===6)return n;for(n=n.child;n!==null;){var s=su(n);if(s!==null)return s;n=n.sibling}return null}var iu=t.unstable_scheduleCallback,ru=t.unstable_cancelCallback,Dp=t.unstable_shouldYield,Bp=t.unstable_requestPaint,ze=t.unstable_now,zp=t.unstable_getCurrentPriorityLevel,na=t.unstable_ImmediatePriority,ou=t.unstable_UserBlockingPriority,Xi=t.unstable_NormalPriority,Fp=t.unstable_LowPriority,au=t.unstable_IdlePriority,Zi=null,Kt=null;function Up(n){if(Kt&&typeof Kt.onCommitFiberRoot=="function")try{Kt.onCommitFiberRoot(Zi,n,void 0,(n.current.flags&128)===128)}catch{}}var Pt=Math.clz32?Math.clz32:Kp,Hp=Math.log,Wp=Math.LN2;function Kp(n){return n>>>=0,n===0?32:31-(Hp(n)/Wp|0)|0}var er=64,tr=4194304;function Xs(n){switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return n&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return n}}function nr(n,s){var a=n.pendingLanes;if(a===0)return 0;var u=0,h=n.suspendedLanes,p=n.pingedLanes,k=a&268435455;if(k!==0){var S=k&~h;S!==0?u=Xs(S):(p&=k,p!==0&&(u=Xs(p)))}else k=a&~h,k!==0?u=Xs(k):p!==0&&(u=Xs(p));if(u===0)return 0;if(s!==0&&s!==u&&(s&h)===0&&(h=u&-u,p=s&-s,h>=p||h===16&&(p&4194240)!==0))return s;if((u&4)!==0&&(u|=a&16),s=n.entangledLanes,s!==0)for(n=n.entanglements,s&=u;0<s;)a=31-Pt(s),h=1<<a,u|=n[a],s&=~h;return u}function Vp(n,s){switch(n){case 1:case 2:case 4:return s+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return s+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Gp(n,s){for(var a=n.suspendedLanes,u=n.pingedLanes,h=n.expirationTimes,p=n.pendingLanes;0<p;){var k=31-Pt(p),S=1<<k,b=h[k];b===-1?((S&a)===0||(S&u)!==0)&&(h[k]=Vp(S,s)):b<=s&&(n.expiredLanes|=S),p&=~S}}function sa(n){return n=n.pendingLanes&-1073741825,n!==0?n:n&1073741824?1073741824:0}function lu(){var n=er;return er<<=1,(er&4194240)===0&&(er=64),n}function ia(n){for(var s=[],a=0;31>a;a++)s.push(n);return s}function Zs(n,s,a){n.pendingLanes|=s,s!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,s=31-Pt(s),n[s]=a}function Qp(n,s){var a=n.pendingLanes&~s;n.pendingLanes=s,n.suspendedLanes=0,n.pingedLanes=0,n.expiredLanes&=s,n.mutableReadLanes&=s,n.entangledLanes&=s,s=n.entanglements;var u=n.eventTimes;for(n=n.expirationTimes;0<a;){var h=31-Pt(a),p=1<<h;s[h]=0,u[h]=-1,n[h]=-1,a&=~p}}function ra(n,s){var a=n.entangledLanes|=s;for(n=n.entanglements;a;){var u=31-Pt(a),h=1<<u;h&s|n[u]&s&&(n[u]|=s),a&=~h}}var Ce=0;function cu(n){return n&=-n,1<n?4<n?(n&268435455)!==0?16:536870912:4:1}var uu,oa,du,fu,hu,aa=!1,sr=[],vn=null,kn=null,yn=null,ei=new Map,ti=new Map,xn=[],qp="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function mu(n,s){switch(n){case"focusin":case"focusout":vn=null;break;case"dragenter":case"dragleave":kn=null;break;case"mouseover":case"mouseout":yn=null;break;case"pointerover":case"pointerout":ei.delete(s.pointerId);break;case"gotpointercapture":case"lostpointercapture":ti.delete(s.pointerId)}}function ni(n,s,a,u,h,p){return n===null||n.nativeEvent!==p?(n={blockedOn:s,domEventName:a,eventSystemFlags:u,nativeEvent:p,targetContainers:[h]},s!==null&&(s=gi(s),s!==null&&oa(s)),n):(n.eventSystemFlags|=u,s=n.targetContainers,h!==null&&s.indexOf(h)===-1&&s.push(h),n)}function Yp(n,s,a,u,h){switch(s){case"focusin":return vn=ni(vn,n,s,a,u,h),!0;case"dragenter":return kn=ni(kn,n,s,a,u,h),!0;case"mouseover":return yn=ni(yn,n,s,a,u,h),!0;case"pointerover":var p=h.pointerId;return ei.set(p,ni(ei.get(p)||null,n,s,a,u,h)),!0;case"gotpointercapture":return p=h.pointerId,ti.set(p,ni(ti.get(p)||null,n,s,a,u,h)),!0}return!1}function pu(n){var s=Un(n.target);if(s!==null){var a=Fn(s);if(a!==null){if(s=a.tag,s===13){if(s=eu(a),s!==null){n.blockedOn=s,hu(n.priority,function(){du(a)});return}}else if(s===3&&a.stateNode.current.memoizedState.isDehydrated){n.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}n.blockedOn=null}function ir(n){if(n.blockedOn!==null)return!1;for(var s=n.targetContainers;0<s.length;){var a=ca(n.domEventName,n.eventSystemFlags,s[0],n.nativeEvent);if(a===null){a=n.nativeEvent;var u=new a.constructor(a.type,a);Yo=u,a.target.dispatchEvent(u),Yo=null}else return s=gi(a),s!==null&&oa(s),n.blockedOn=a,!1;s.shift()}return!0}function gu(n,s,a){ir(n)&&a.delete(s)}function Jp(){aa=!1,vn!==null&&ir(vn)&&(vn=null),kn!==null&&ir(kn)&&(kn=null),yn!==null&&ir(yn)&&(yn=null),ei.forEach(gu),ti.forEach(gu)}function si(n,s){n.blockedOn===s&&(n.blockedOn=null,aa||(aa=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Jp)))}function ii(n){function s(h){return si(h,n)}if(0<sr.length){si(sr[0],n);for(var a=1;a<sr.length;a++){var u=sr[a];u.blockedOn===n&&(u.blockedOn=null)}}for(vn!==null&&si(vn,n),kn!==null&&si(kn,n),yn!==null&&si(yn,n),ei.forEach(s),ti.forEach(s),a=0;a<xn.length;a++)u=xn[a],u.blockedOn===n&&(u.blockedOn=null);for(;0<xn.length&&(a=xn[0],a.blockedOn===null);)pu(a),a.blockedOn===null&&xn.shift()}var as=X.ReactCurrentBatchConfig,rr=!0;function Xp(n,s,a,u){var h=Ce,p=as.transition;as.transition=null;try{Ce=1,la(n,s,a,u)}finally{Ce=h,as.transition=p}}function Zp(n,s,a,u){var h=Ce,p=as.transition;as.transition=null;try{Ce=4,la(n,s,a,u)}finally{Ce=h,as.transition=p}}function la(n,s,a,u){if(rr){var h=ca(n,s,a,u);if(h===null)Ca(n,s,u,or,a),mu(n,u);else if(Yp(h,n,s,a,u))u.stopPropagation();else if(mu(n,u),s&4&&-1<qp.indexOf(n)){for(;h!==null;){var p=gi(h);if(p!==null&&uu(p),p=ca(n,s,a,u),p===null&&Ca(n,s,u,or,a),p===h)break;h=p}h!==null&&u.stopPropagation()}else Ca(n,s,u,null,a)}}var or=null;function ca(n,s,a,u){if(or=null,n=Jo(u),n=Un(n),n!==null)if(s=Fn(n),s===null)n=null;else if(a=s.tag,a===13){if(n=eu(s),n!==null)return n;n=null}else if(a===3){if(s.stateNode.current.memoizedState.isDehydrated)return s.tag===3?s.stateNode.containerInfo:null;n=null}else s!==n&&(n=null);return or=n,null}function vu(n){switch(n){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(zp()){case na:return 1;case ou:return 4;case Xi:case Fp:return 16;case au:return 536870912;default:return 16}default:return 16}}var wn=null,ua=null,ar=null;function ku(){if(ar)return ar;var n,s=ua,a=s.length,u,h="value"in wn?wn.value:wn.textContent,p=h.length;for(n=0;n<a&&s[n]===h[n];n++);var k=a-n;for(u=1;u<=k&&s[a-u]===h[p-u];u++);return ar=h.slice(n,1<u?1-u:void 0)}function lr(n){var s=n.keyCode;return"charCode"in n?(n=n.charCode,n===0&&s===13&&(n=13)):n=s,n===10&&(n=13),32<=n||n===13?n:0}function cr(){return!0}function yu(){return!1}function jt(n){function s(a,u,h,p,k){this._reactName=a,this._targetInst=h,this.type=u,this.nativeEvent=p,this.target=k,this.currentTarget=null;for(var S in n)n.hasOwnProperty(S)&&(a=n[S],this[S]=a?a(p):p[S]);return this.isDefaultPrevented=(p.defaultPrevented!=null?p.defaultPrevented:p.returnValue===!1)?cr:yu,this.isPropagationStopped=yu,this}return H(s.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=cr)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=cr)},persist:function(){},isPersistent:cr}),s}var ls={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},da=jt(ls),ri=H({},ls,{view:0,detail:0}),eg=jt(ri),fa,ha,oi,ur=H({},ri,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:pa,button:0,buttons:0,relatedTarget:function(n){return n.relatedTarget===void 0?n.fromElement===n.srcElement?n.toElement:n.fromElement:n.relatedTarget},movementX:function(n){return"movementX"in n?n.movementX:(n!==oi&&(oi&&n.type==="mousemove"?(fa=n.screenX-oi.screenX,ha=n.screenY-oi.screenY):ha=fa=0,oi=n),fa)},movementY:function(n){return"movementY"in n?n.movementY:ha}}),xu=jt(ur),tg=H({},ur,{dataTransfer:0}),ng=jt(tg),sg=H({},ri,{relatedTarget:0}),ma=jt(sg),ig=H({},ls,{animationName:0,elapsedTime:0,pseudoElement:0}),rg=jt(ig),og=H({},ls,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),ag=jt(og),lg=H({},ls,{data:0}),wu=jt(lg),cg={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},ug={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"},dg={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function fg(n){var s=this.nativeEvent;return s.getModifierState?s.getModifierState(n):(n=dg[n])?!!s[n]:!1}function pa(){return fg}var hg=H({},ri,{key:function(n){if(n.key){var s=cg[n.key]||n.key;if(s!=="Unidentified")return s}return n.type==="keypress"?(n=lr(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?ug[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:pa,charCode:function(n){return n.type==="keypress"?lr(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?lr(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),mg=jt(hg),pg=H({},ur,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ju=jt(pg),gg=H({},ri,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:pa}),vg=jt(gg),kg=H({},ls,{propertyName:0,elapsedTime:0,pseudoElement:0}),yg=jt(kg),xg=H({},ur,{deltaX:function(n){return"deltaX"in n?n.deltaX:"wheelDeltaX"in n?-n.wheelDeltaX:0},deltaY:function(n){return"deltaY"in n?n.deltaY:"wheelDeltaY"in n?-n.wheelDeltaY:"wheelDelta"in n?-n.wheelDelta:0},deltaZ:0,deltaMode:0}),wg=jt(xg),jg=[9,13,27,32],ga=f&&"CompositionEvent"in window,ai=null;f&&"documentMode"in document&&(ai=document.documentMode);var Ng=f&&"TextEvent"in window&&!ai,Nu=f&&(!ga||ai&&8<ai&&11>=ai),Su=" ",bu=!1;function Cu(n,s){switch(n){case"keyup":return jg.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function $u(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var cs=!1;function Sg(n,s){switch(n){case"compositionend":return $u(s);case"keypress":return s.which!==32?null:(bu=!0,Su);case"textInput":return n=s.data,n===Su&&bu?null:n;default:return null}}function bg(n,s){if(cs)return n==="compositionend"||!ga&&Cu(n,s)?(n=ku(),ar=ua=wn=null,cs=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1<s.char.length)return s.char;if(s.which)return String.fromCharCode(s.which)}return null;case"compositionend":return Nu&&s.locale!=="ko"?null:s.data;default:return null}}var Cg={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Tu(n){var s=n&&n.nodeName&&n.nodeName.toLowerCase();return s==="input"?!!Cg[n.type]:s==="textarea"}function Eu(n,s,a,u){qc(u),s=pr(s,"onChange"),0<s.length&&(a=new da("onChange","change",null,a,u),n.push({event:a,listeners:s}))}var li=null,ci=null;function $g(n){Gu(n,0)}function dr(n){var s=ms(n);if(_c(s))return n}function Tg(n,s){if(n==="change")return s}var Iu=!1;if(f){var va;if(f){var ka="oninput"in document;if(!ka){var Mu=document.createElement("div");Mu.setAttribute("oninput","return;"),ka=typeof Mu.oninput=="function"}va=ka}else va=!1;Iu=va&&(!document.documentMode||9<document.documentMode)}function Au(){li&&(li.detachEvent("onpropertychange",Lu),ci=li=null)}function Lu(n){if(n.propertyName==="value"&&dr(ci)){var s=[];Eu(s,ci,n,Jo(n)),Zc($g,s)}}function Eg(n,s,a){n==="focusin"?(Au(),li=s,ci=a,li.attachEvent("onpropertychange",Lu)):n==="focusout"&&Au()}function Ig(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return dr(ci)}function Mg(n,s){if(n==="click")return dr(s)}function Ag(n,s){if(n==="input"||n==="change")return dr(s)}function Lg(n,s){return n===s&&(n!==0||1/n===1/s)||n!==n&&s!==s}var _t=typeof Object.is=="function"?Object.is:Lg;function ui(n,s){if(_t(n,s))return!0;if(typeof n!="object"||n===null||typeof s!="object"||s===null)return!1;var a=Object.keys(n),u=Object.keys(s);if(a.length!==u.length)return!1;for(u=0;u<a.length;u++){var h=a[u];if(!g.call(s,h)||!_t(n[h],s[h]))return!1}return!0}function Ru(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function Ou(n,s){var a=Ru(n);n=0;for(var u;a;){if(a.nodeType===3){if(u=n+a.textContent.length,n<=s&&u>=s)return{node:a,offset:s-n};n=u}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Ru(a)}}function Pu(n,s){return n&&s?n===s?!0:n&&n.nodeType===3?!1:s&&s.nodeType===3?Pu(n,s.parentNode):"contains"in n?n.contains(s):n.compareDocumentPosition?!!(n.compareDocumentPosition(s)&16):!1:!1}function _u(){for(var n=window,s=Qi();s instanceof n.HTMLIFrameElement;){try{var a=typeof s.contentWindow.location.href=="string"}catch{a=!1}if(a)n=s.contentWindow;else break;s=Qi(n.document)}return s}function ya(n){var s=n&&n.nodeName&&n.nodeName.toLowerCase();return s&&(s==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||s==="textarea"||n.contentEditable==="true")}function Rg(n){var s=_u(),a=n.focusedElem,u=n.selectionRange;if(s!==a&&a&&a.ownerDocument&&Pu(a.ownerDocument.documentElement,a)){if(u!==null&&ya(a)){if(s=u.start,n=u.end,n===void 0&&(n=s),"selectionStart"in a)a.selectionStart=s,a.selectionEnd=Math.min(n,a.value.length);else if(n=(s=a.ownerDocument||document)&&s.defaultView||window,n.getSelection){n=n.getSelection();var h=a.textContent.length,p=Math.min(u.start,h);u=u.end===void 0?p:Math.min(u.end,h),!n.extend&&p>u&&(h=u,u=p,p=h),h=Ou(a,p);var k=Ou(a,u);h&&k&&(n.rangeCount!==1||n.anchorNode!==h.node||n.anchorOffset!==h.offset||n.focusNode!==k.node||n.focusOffset!==k.offset)&&(s=s.createRange(),s.setStart(h.node,h.offset),n.removeAllRanges(),p>u?(n.addRange(s),n.extend(k.node,k.offset)):(s.setEnd(k.node,k.offset),n.addRange(s)))}}for(s=[],n=a;n=n.parentNode;)n.nodeType===1&&s.push({element:n,left:n.scrollLeft,top:n.scrollTop});for(typeof a.focus=="function"&&a.focus(),a=0;a<s.length;a++)n=s[a],n.element.scrollLeft=n.left,n.element.scrollTop=n.top}}var Og=f&&"documentMode"in document&&11>=document.documentMode,us=null,xa=null,di=null,wa=!1;function Du(n,s,a){var u=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;wa||us==null||us!==Qi(u)||(u=us,"selectionStart"in u&&ya(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),di&&ui(di,u)||(di=u,u=pr(xa,"onSelect"),0<u.length&&(s=new da("onSelect","select",null,s,a),n.push({event:s,listeners:u}),s.target=us)))}function fr(n,s){var a={};return a[n.toLowerCase()]=s.toLowerCase(),a["Webkit"+n]="webkit"+s,a["Moz"+n]="moz"+s,a}var ds={animationend:fr("Animation","AnimationEnd"),animationiteration:fr("Animation","AnimationIteration"),animationstart:fr("Animation","AnimationStart"),transitionend:fr("Transition","TransitionEnd")},ja={},Bu={};f&&(Bu=document.createElement("div").style,"AnimationEvent"in window||(delete ds.animationend.animation,delete ds.animationiteration.animation,delete ds.animationstart.animation),"TransitionEvent"in window||delete ds.transitionend.transition);function hr(n){if(ja[n])return ja[n];if(!ds[n])return n;var s=ds[n],a;for(a in s)if(s.hasOwnProperty(a)&&a in Bu)return ja[n]=s[a];return n}var zu=hr("animationend"),Fu=hr("animationiteration"),Uu=hr("animationstart"),Hu=hr("transitionend"),Wu=new Map,Ku="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function jn(n,s){Wu.set(n,s),c(s,[n])}for(var Na=0;Na<Ku.length;Na++){var Sa=Ku[Na],Pg=Sa.toLowerCase(),_g=Sa[0].toUpperCase()+Sa.slice(1);jn(Pg,"on"+_g)}jn(zu,"onAnimationEnd"),jn(Fu,"onAnimationIteration"),jn(Uu,"onAnimationStart"),jn("dblclick","onDoubleClick"),jn("focusin","onFocus"),jn("focusout","onBlur"),jn(Hu,"onTransitionEnd"),d("onMouseEnter",["mouseout","mouseover"]),d("onMouseLeave",["mouseout","mouseover"]),d("onPointerEnter",["pointerout","pointerover"]),d("onPointerLeave",["pointerout","pointerover"]),c("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),c("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),c("onBeforeInput",["compositionend","keypress","textInput","paste"]),c("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),c("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),c("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var fi="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(" "),Dg=new Set("cancel close invalid load scroll toggle".split(" ").concat(fi));function Vu(n,s,a){var u=n.type||"unknown-event";n.currentTarget=a,Pp(u,s,void 0,n),n.currentTarget=null}function Gu(n,s){s=(s&4)!==0;for(var a=0;a<n.length;a++){var u=n[a],h=u.event;u=u.listeners;e:{var p=void 0;if(s)for(var k=u.length-1;0<=k;k--){var S=u[k],b=S.instance,L=S.currentTarget;if(S=S.listener,b!==p&&h.isPropagationStopped())break e;Vu(h,S,L),p=b}else for(k=0;k<u.length;k++){if(S=u[k],b=S.instance,L=S.currentTarget,S=S.listener,b!==p&&h.isPropagationStopped())break e;Vu(h,S,L),p=b}}}if(Ji)throw n=ta,Ji=!1,ta=null,n}function Ie(n,s){var a=s[Aa];a===void 0&&(a=s[Aa]=new Set);var u=n+"__bubble";a.has(u)||(Qu(s,n,2,!1),a.add(u))}function ba(n,s,a){var u=0;s&&(u|=4),Qu(a,n,u,s)}var mr="_reactListening"+Math.random().toString(36).slice(2);function hi(n){if(!n[mr]){n[mr]=!0,o.forEach(function(a){a!=="selectionchange"&&(Dg.has(a)||ba(a,!1,n),ba(a,!0,n))});var s=n.nodeType===9?n:n.ownerDocument;s===null||s[mr]||(s[mr]=!0,ba("selectionchange",!1,s))}}function Qu(n,s,a,u){switch(vu(s)){case 1:var h=Xp;break;case 4:h=Zp;break;default:h=la}a=h.bind(null,s,a,n),h=void 0,!ea||s!=="touchstart"&&s!=="touchmove"&&s!=="wheel"||(h=!0),u?h!==void 0?n.addEventListener(s,a,{capture:!0,passive:h}):n.addEventListener(s,a,!0):h!==void 0?n.addEventListener(s,a,{passive:h}):n.addEventListener(s,a,!1)}function Ca(n,s,a,u,h){var p=u;if((s&1)===0&&(s&2)===0&&u!==null)e:for(;;){if(u===null)return;var k=u.tag;if(k===3||k===4){var S=u.stateNode.containerInfo;if(S===h||S.nodeType===8&&S.parentNode===h)break;if(k===4)for(k=u.return;k!==null;){var b=k.tag;if((b===3||b===4)&&(b=k.stateNode.containerInfo,b===h||b.nodeType===8&&b.parentNode===h))return;k=k.return}for(;S!==null;){if(k=Un(S),k===null)return;if(b=k.tag,b===5||b===6){u=p=k;continue e}S=S.parentNode}}u=u.return}Zc(function(){var L=p,F=Jo(a),W=[];e:{var z=Wu.get(n);if(z!==void 0){var J=da,ne=n;switch(n){case"keypress":if(lr(a)===0)break e;case"keydown":case"keyup":J=mg;break;case"focusin":ne="focus",J=ma;break;case"focusout":ne="blur",J=ma;break;case"beforeblur":case"afterblur":J=ma;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":J=xu;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":J=ng;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":J=vg;break;case zu:case Fu:case Uu:J=rg;break;case Hu:J=yg;break;case"scroll":J=eg;break;case"wheel":J=wg;break;case"copy":case"cut":case"paste":J=ag;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":J=ju}var se=(s&4)!==0,Fe=!se&&n==="scroll",I=se?z!==null?z+"Capture":null:z;se=[];for(var C=L,A;C!==null;){A=C;var G=A.stateNode;if(A.tag===5&&G!==null&&(A=G,I!==null&&(G=qs(C,I),G!=null&&se.push(mi(C,G,A)))),Fe)break;C=C.return}0<se.length&&(z=new J(z,ne,null,a,F),W.push({event:z,listeners:se}))}}if((s&7)===0){e:{if(z=n==="mouseover"||n==="pointerover",J=n==="mouseout"||n==="pointerout",z&&a!==Yo&&(ne=a.relatedTarget||a.fromElement)&&(Un(ne)||ne[rn]))break e;if((J||z)&&(z=F.window===F?F:(z=F.ownerDocument)?z.defaultView||z.parentWindow:window,J?(ne=a.relatedTarget||a.toElement,J=L,ne=ne?Un(ne):null,ne!==null&&(Fe=Fn(ne),ne!==Fe||ne.tag!==5&&ne.tag!==6)&&(ne=null)):(J=null,ne=L),J!==ne)){if(se=xu,G="onMouseLeave",I="onMouseEnter",C="mouse",(n==="pointerout"||n==="pointerover")&&(se=ju,G="onPointerLeave",I="onPointerEnter",C="pointer"),Fe=J==null?z:ms(J),A=ne==null?z:ms(ne),z=new se(G,C+"leave",J,a,F),z.target=Fe,z.relatedTarget=A,G=null,Un(F)===L&&(se=new se(I,C+"enter",ne,a,F),se.target=A,se.relatedTarget=Fe,G=se),Fe=G,J&&ne)t:{for(se=J,I=ne,C=0,A=se;A;A=fs(A))C++;for(A=0,G=I;G;G=fs(G))A++;for(;0<C-A;)se=fs(se),C--;for(;0<A-C;)I=fs(I),A--;for(;C--;){if(se===I||I!==null&&se===I.alternate)break t;se=fs(se),I=fs(I)}se=null}else se=null;J!==null&&qu(W,z,J,se,!1),ne!==null&&Fe!==null&&qu(W,Fe,ne,se,!0)}}e:{if(z=L?ms(L):window,J=z.nodeName&&z.nodeName.toLowerCase(),J==="select"||J==="input"&&z.type==="file")var oe=Tg;else if(Tu(z))if(Iu)oe=Ag;else{oe=Ig;var le=Eg}else(J=z.nodeName)&&J.toLowerCase()==="input"&&(z.type==="checkbox"||z.type==="radio")&&(oe=Mg);if(oe&&(oe=oe(n,L))){Eu(W,oe,a,F);break e}le&&le(n,z,L),n==="focusout"&&(le=z._wrapperState)&&le.controlled&&z.type==="number"&&Ko(z,"number",z.value)}switch(le=L?ms(L):window,n){case"focusin":(Tu(le)||le.contentEditable==="true")&&(us=le,xa=L,di=null);break;case"focusout":di=xa=us=null;break;case"mousedown":wa=!0;break;case"contextmenu":case"mouseup":case"dragend":wa=!1,Du(W,a,F);break;case"selectionchange":if(Og)break;case"keydown":case"keyup":Du(W,a,F)}var ce;if(ga)e:{switch(n){case"compositionstart":var fe="onCompositionStart";break e;case"compositionend":fe="onCompositionEnd";break e;case"compositionupdate":fe="onCompositionUpdate";break e}fe=void 0}else cs?Cu(n,a)&&(fe="onCompositionEnd"):n==="keydown"&&a.keyCode===229&&(fe="onCompositionStart");fe&&(Nu&&a.locale!=="ko"&&(cs||fe!=="onCompositionStart"?fe==="onCompositionEnd"&&cs&&(ce=ku()):(wn=F,ua="value"in wn?wn.value:wn.textContent,cs=!0)),le=pr(L,fe),0<le.length&&(fe=new wu(fe,n,null,a,F),W.push({event:fe,listeners:le}),ce?fe.data=ce:(ce=$u(a),ce!==null&&(fe.data=ce)))),(ce=Ng?Sg(n,a):bg(n,a))&&(L=pr(L,"onBeforeInput"),0<L.length&&(F=new wu("onBeforeInput","beforeinput",null,a,F),W.push({event:F,listeners:L}),F.data=ce))}Gu(W,s)})}function mi(n,s,a){return{instance:n,listener:s,currentTarget:a}}function pr(n,s){for(var a=s+"Capture",u=[];n!==null;){var h=n,p=h.stateNode;h.tag===5&&p!==null&&(h=p,p=qs(n,a),p!=null&&u.unshift(mi(n,p,h)),p=qs(n,s),p!=null&&u.push(mi(n,p,h))),n=n.return}return u}function fs(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5);return n||null}function qu(n,s,a,u,h){for(var p=s._reactName,k=[];a!==null&&a!==u;){var S=a,b=S.alternate,L=S.stateNode;if(b!==null&&b===u)break;S.tag===5&&L!==null&&(S=L,h?(b=qs(a,p),b!=null&&k.unshift(mi(a,b,S))):h||(b=qs(a,p),b!=null&&k.push(mi(a,b,S)))),a=a.return}k.length!==0&&n.push({event:s,listeners:k})}var Bg=/\r\n?/g,zg=/\u0000|\uFFFD/g;function Yu(n){return(typeof n=="string"?n:""+n).replace(Bg,`
|
|
38
|
-
`).replace(zg,"")}function gr(n,s,a){if(s=Yu(s),Yu(n)!==s&&a)throw Error(r(425))}function vr(){}var $a=null,Ta=null;function Ea(n,s){return n==="textarea"||n==="noscript"||typeof s.children=="string"||typeof s.children=="number"||typeof s.dangerouslySetInnerHTML=="object"&&s.dangerouslySetInnerHTML!==null&&s.dangerouslySetInnerHTML.__html!=null}var Ia=typeof setTimeout=="function"?setTimeout:void 0,Fg=typeof clearTimeout=="function"?clearTimeout:void 0,Ju=typeof Promise=="function"?Promise:void 0,Ug=typeof queueMicrotask=="function"?queueMicrotask:typeof Ju<"u"?function(n){return Ju.resolve(null).then(n).catch(Hg)}:Ia;function Hg(n){setTimeout(function(){throw n})}function Ma(n,s){var a=s,u=0;do{var h=a.nextSibling;if(n.removeChild(a),h&&h.nodeType===8)if(a=h.data,a==="/$"){if(u===0){n.removeChild(h),ii(s);return}u--}else a!=="$"&&a!=="$?"&&a!=="$!"||u++;a=h}while(a);ii(s)}function Nn(n){for(;n!=null;n=n.nextSibling){var s=n.nodeType;if(s===1||s===3)break;if(s===8){if(s=n.data,s==="$"||s==="$!"||s==="$?")break;if(s==="/$")return null}}return n}function Xu(n){n=n.previousSibling;for(var s=0;n;){if(n.nodeType===8){var a=n.data;if(a==="$"||a==="$!"||a==="$?"){if(s===0)return n;s--}else a==="/$"&&s++}n=n.previousSibling}return null}var hs=Math.random().toString(36).slice(2),Vt="__reactFiber$"+hs,pi="__reactProps$"+hs,rn="__reactContainer$"+hs,Aa="__reactEvents$"+hs,Wg="__reactListeners$"+hs,Kg="__reactHandles$"+hs;function Un(n){var s=n[Vt];if(s)return s;for(var a=n.parentNode;a;){if(s=a[rn]||a[Vt]){if(a=s.alternate,s.child!==null||a!==null&&a.child!==null)for(n=Xu(n);n!==null;){if(a=n[Vt])return a;n=Xu(n)}return s}n=a,a=n.parentNode}return null}function gi(n){return n=n[Vt]||n[rn],!n||n.tag!==5&&n.tag!==6&&n.tag!==13&&n.tag!==3?null:n}function ms(n){if(n.tag===5||n.tag===6)return n.stateNode;throw Error(r(33))}function kr(n){return n[pi]||null}var La=[],ps=-1;function Sn(n){return{current:n}}function Me(n){0>ps||(n.current=La[ps],La[ps]=null,ps--)}function Te(n,s){ps++,La[ps]=n.current,n.current=s}var bn={},rt=Sn(bn),mt=Sn(!1),Hn=bn;function gs(n,s){var a=n.type.contextTypes;if(!a)return bn;var u=n.stateNode;if(u&&u.__reactInternalMemoizedUnmaskedChildContext===s)return u.__reactInternalMemoizedMaskedChildContext;var h={},p;for(p in a)h[p]=s[p];return u&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=s,n.__reactInternalMemoizedMaskedChildContext=h),h}function pt(n){return n=n.childContextTypes,n!=null}function yr(){Me(mt),Me(rt)}function Zu(n,s,a){if(rt.current!==bn)throw Error(r(168));Te(rt,s),Te(mt,a)}function ed(n,s,a){var u=n.stateNode;if(s=s.childContextTypes,typeof u.getChildContext!="function")return a;u=u.getChildContext();for(var h in u)if(!(h in s))throw Error(r(108,me(n)||"Unknown",h));return H({},a,u)}function xr(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||bn,Hn=rt.current,Te(rt,n),Te(mt,mt.current),!0}function td(n,s,a){var u=n.stateNode;if(!u)throw Error(r(169));a?(n=ed(n,s,Hn),u.__reactInternalMemoizedMergedChildContext=n,Me(mt),Me(rt),Te(rt,n)):Me(mt),Te(mt,a)}var on=null,wr=!1,Ra=!1;function nd(n){on===null?on=[n]:on.push(n)}function Vg(n){wr=!0,nd(n)}function Cn(){if(!Ra&&on!==null){Ra=!0;var n=0,s=Ce;try{var a=on;for(Ce=1;n<a.length;n++){var u=a[n];do u=u(!0);while(u!==null)}on=null,wr=!1}catch(h){throw on!==null&&(on=on.slice(n+1)),iu(na,Cn),h}finally{Ce=s,Ra=!1}}return null}var vs=[],ks=0,jr=null,Nr=0,$t=[],Tt=0,Wn=null,an=1,ln="";function Kn(n,s){vs[ks++]=Nr,vs[ks++]=jr,jr=n,Nr=s}function sd(n,s,a){$t[Tt++]=an,$t[Tt++]=ln,$t[Tt++]=Wn,Wn=n;var u=an;n=ln;var h=32-Pt(u)-1;u&=~(1<<h),a+=1;var p=32-Pt(s)+h;if(30<p){var k=h-h%5;p=(u&(1<<k)-1).toString(32),u>>=k,h-=k,an=1<<32-Pt(s)+h|a<<h|u,ln=p+n}else an=1<<p|a<<h|u,ln=n}function Oa(n){n.return!==null&&(Kn(n,1),sd(n,1,0))}function Pa(n){for(;n===jr;)jr=vs[--ks],vs[ks]=null,Nr=vs[--ks],vs[ks]=null;for(;n===Wn;)Wn=$t[--Tt],$t[Tt]=null,ln=$t[--Tt],$t[Tt]=null,an=$t[--Tt],$t[Tt]=null}var Nt=null,St=null,Le=!1,Dt=null;function id(n,s){var a=At(5,null,null,0);a.elementType="DELETED",a.stateNode=s,a.return=n,s=n.deletions,s===null?(n.deletions=[a],n.flags|=16):s.push(a)}function rd(n,s){switch(n.tag){case 5:var a=n.type;return s=s.nodeType!==1||a.toLowerCase()!==s.nodeName.toLowerCase()?null:s,s!==null?(n.stateNode=s,Nt=n,St=Nn(s.firstChild),!0):!1;case 6:return s=n.pendingProps===""||s.nodeType!==3?null:s,s!==null?(n.stateNode=s,Nt=n,St=null,!0):!1;case 13:return s=s.nodeType!==8?null:s,s!==null?(a=Wn!==null?{id:an,overflow:ln}:null,n.memoizedState={dehydrated:s,treeContext:a,retryLane:1073741824},a=At(18,null,null,0),a.stateNode=s,a.return=n,n.child=a,Nt=n,St=null,!0):!1;default:return!1}}function _a(n){return(n.mode&1)!==0&&(n.flags&128)===0}function Da(n){if(Le){var s=St;if(s){var a=s;if(!rd(n,s)){if(_a(n))throw Error(r(418));s=Nn(a.nextSibling);var u=Nt;s&&rd(n,s)?id(u,a):(n.flags=n.flags&-4097|2,Le=!1,Nt=n)}}else{if(_a(n))throw Error(r(418));n.flags=n.flags&-4097|2,Le=!1,Nt=n}}}function od(n){for(n=n.return;n!==null&&n.tag!==5&&n.tag!==3&&n.tag!==13;)n=n.return;Nt=n}function Sr(n){if(n!==Nt)return!1;if(!Le)return od(n),Le=!0,!1;var s;if((s=n.tag!==3)&&!(s=n.tag!==5)&&(s=n.type,s=s!=="head"&&s!=="body"&&!Ea(n.type,n.memoizedProps)),s&&(s=St)){if(_a(n))throw ad(),Error(r(418));for(;s;)id(n,s),s=Nn(s.nextSibling)}if(od(n),n.tag===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(r(317));e:{for(n=n.nextSibling,s=0;n;){if(n.nodeType===8){var a=n.data;if(a==="/$"){if(s===0){St=Nn(n.nextSibling);break e}s--}else a!=="$"&&a!=="$!"&&a!=="$?"||s++}n=n.nextSibling}St=null}}else St=Nt?Nn(n.stateNode.nextSibling):null;return!0}function ad(){for(var n=St;n;)n=Nn(n.nextSibling)}function ys(){St=Nt=null,Le=!1}function Ba(n){Dt===null?Dt=[n]:Dt.push(n)}var Gg=X.ReactCurrentBatchConfig;function vi(n,s,a){if(n=a.ref,n!==null&&typeof n!="function"&&typeof n!="object"){if(a._owner){if(a=a._owner,a){if(a.tag!==1)throw Error(r(309));var u=a.stateNode}if(!u)throw Error(r(147,n));var h=u,p=""+n;return s!==null&&s.ref!==null&&typeof s.ref=="function"&&s.ref._stringRef===p?s.ref:(s=function(k){var S=h.refs;k===null?delete S[p]:S[p]=k},s._stringRef=p,s)}if(typeof n!="string")throw Error(r(284));if(!a._owner)throw Error(r(290,n))}return n}function br(n,s){throw n=Object.prototype.toString.call(s),Error(r(31,n==="[object Object]"?"object with keys {"+Object.keys(s).join(", ")+"}":n))}function ld(n){var s=n._init;return s(n._payload)}function cd(n){function s(I,C){if(n){var A=I.deletions;A===null?(I.deletions=[C],I.flags|=16):A.push(C)}}function a(I,C){if(!n)return null;for(;C!==null;)s(I,C),C=C.sibling;return null}function u(I,C){for(I=new Map;C!==null;)C.key!==null?I.set(C.key,C):I.set(C.index,C),C=C.sibling;return I}function h(I,C){return I=Rn(I,C),I.index=0,I.sibling=null,I}function p(I,C,A){return I.index=A,n?(A=I.alternate,A!==null?(A=A.index,A<C?(I.flags|=2,C):A):(I.flags|=2,C)):(I.flags|=1048576,C)}function k(I){return n&&I.alternate===null&&(I.flags|=2),I}function S(I,C,A,G){return C===null||C.tag!==6?(C=Il(A,I.mode,G),C.return=I,C):(C=h(C,A),C.return=I,C)}function b(I,C,A,G){var oe=A.type;return oe===q?F(I,C,A.props.children,G,A.key):C!==null&&(C.elementType===oe||typeof oe=="object"&&oe!==null&&oe.$$typeof===ae&&ld(oe)===C.type)?(G=h(C,A.props),G.ref=vi(I,C,A),G.return=I,G):(G=qr(A.type,A.key,A.props,null,I.mode,G),G.ref=vi(I,C,A),G.return=I,G)}function L(I,C,A,G){return C===null||C.tag!==4||C.stateNode.containerInfo!==A.containerInfo||C.stateNode.implementation!==A.implementation?(C=Ml(A,I.mode,G),C.return=I,C):(C=h(C,A.children||[]),C.return=I,C)}function F(I,C,A,G,oe){return C===null||C.tag!==7?(C=Zn(A,I.mode,G,oe),C.return=I,C):(C=h(C,A),C.return=I,C)}function W(I,C,A){if(typeof C=="string"&&C!==""||typeof C=="number")return C=Il(""+C,I.mode,A),C.return=I,C;if(typeof C=="object"&&C!==null){switch(C.$$typeof){case ie:return A=qr(C.type,C.key,C.props,null,I.mode,A),A.ref=vi(I,null,C),A.return=I,A;case D:return C=Ml(C,I.mode,A),C.return=I,C;case ae:var G=C._init;return W(I,G(C._payload),A)}if(Vs(C)||B(C))return C=Zn(C,I.mode,A,null),C.return=I,C;br(I,C)}return null}function z(I,C,A,G){var oe=C!==null?C.key:null;if(typeof A=="string"&&A!==""||typeof A=="number")return oe!==null?null:S(I,C,""+A,G);if(typeof A=="object"&&A!==null){switch(A.$$typeof){case ie:return A.key===oe?b(I,C,A,G):null;case D:return A.key===oe?L(I,C,A,G):null;case ae:return oe=A._init,z(I,C,oe(A._payload),G)}if(Vs(A)||B(A))return oe!==null?null:F(I,C,A,G,null);br(I,A)}return null}function J(I,C,A,G,oe){if(typeof G=="string"&&G!==""||typeof G=="number")return I=I.get(A)||null,S(C,I,""+G,oe);if(typeof G=="object"&&G!==null){switch(G.$$typeof){case ie:return I=I.get(G.key===null?A:G.key)||null,b(C,I,G,oe);case D:return I=I.get(G.key===null?A:G.key)||null,L(C,I,G,oe);case ae:var le=G._init;return J(I,C,A,le(G._payload),oe)}if(Vs(G)||B(G))return I=I.get(A)||null,F(C,I,G,oe,null);br(C,G)}return null}function ne(I,C,A,G){for(var oe=null,le=null,ce=C,fe=C=0,et=null;ce!==null&&fe<A.length;fe++){ce.index>fe?(et=ce,ce=null):et=ce.sibling;var Ne=z(I,ce,A[fe],G);if(Ne===null){ce===null&&(ce=et);break}n&&ce&&Ne.alternate===null&&s(I,ce),C=p(Ne,C,fe),le===null?oe=Ne:le.sibling=Ne,le=Ne,ce=et}if(fe===A.length)return a(I,ce),Le&&Kn(I,fe),oe;if(ce===null){for(;fe<A.length;fe++)ce=W(I,A[fe],G),ce!==null&&(C=p(ce,C,fe),le===null?oe=ce:le.sibling=ce,le=ce);return Le&&Kn(I,fe),oe}for(ce=u(I,ce);fe<A.length;fe++)et=J(ce,I,fe,A[fe],G),et!==null&&(n&&et.alternate!==null&&ce.delete(et.key===null?fe:et.key),C=p(et,C,fe),le===null?oe=et:le.sibling=et,le=et);return n&&ce.forEach(function(On){return s(I,On)}),Le&&Kn(I,fe),oe}function se(I,C,A,G){var oe=B(A);if(typeof oe!="function")throw Error(r(150));if(A=oe.call(A),A==null)throw Error(r(151));for(var le=oe=null,ce=C,fe=C=0,et=null,Ne=A.next();ce!==null&&!Ne.done;fe++,Ne=A.next()){ce.index>fe?(et=ce,ce=null):et=ce.sibling;var On=z(I,ce,Ne.value,G);if(On===null){ce===null&&(ce=et);break}n&&ce&&On.alternate===null&&s(I,ce),C=p(On,C,fe),le===null?oe=On:le.sibling=On,le=On,ce=et}if(Ne.done)return a(I,ce),Le&&Kn(I,fe),oe;if(ce===null){for(;!Ne.done;fe++,Ne=A.next())Ne=W(I,Ne.value,G),Ne!==null&&(C=p(Ne,C,fe),le===null?oe=Ne:le.sibling=Ne,le=Ne);return Le&&Kn(I,fe),oe}for(ce=u(I,ce);!Ne.done;fe++,Ne=A.next())Ne=J(ce,I,fe,Ne.value,G),Ne!==null&&(n&&Ne.alternate!==null&&ce.delete(Ne.key===null?fe:Ne.key),C=p(Ne,C,fe),le===null?oe=Ne:le.sibling=Ne,le=Ne);return n&&ce.forEach(function(Cv){return s(I,Cv)}),Le&&Kn(I,fe),oe}function Fe(I,C,A,G){if(typeof A=="object"&&A!==null&&A.type===q&&A.key===null&&(A=A.props.children),typeof A=="object"&&A!==null){switch(A.$$typeof){case ie:e:{for(var oe=A.key,le=C;le!==null;){if(le.key===oe){if(oe=A.type,oe===q){if(le.tag===7){a(I,le.sibling),C=h(le,A.props.children),C.return=I,I=C;break e}}else if(le.elementType===oe||typeof oe=="object"&&oe!==null&&oe.$$typeof===ae&&ld(oe)===le.type){a(I,le.sibling),C=h(le,A.props),C.ref=vi(I,le,A),C.return=I,I=C;break e}a(I,le);break}else s(I,le);le=le.sibling}A.type===q?(C=Zn(A.props.children,I.mode,G,A.key),C.return=I,I=C):(G=qr(A.type,A.key,A.props,null,I.mode,G),G.ref=vi(I,C,A),G.return=I,I=G)}return k(I);case D:e:{for(le=A.key;C!==null;){if(C.key===le)if(C.tag===4&&C.stateNode.containerInfo===A.containerInfo&&C.stateNode.implementation===A.implementation){a(I,C.sibling),C=h(C,A.children||[]),C.return=I,I=C;break e}else{a(I,C);break}else s(I,C);C=C.sibling}C=Ml(A,I.mode,G),C.return=I,I=C}return k(I);case ae:return le=A._init,Fe(I,C,le(A._payload),G)}if(Vs(A))return ne(I,C,A,G);if(B(A))return se(I,C,A,G);br(I,A)}return typeof A=="string"&&A!==""||typeof A=="number"?(A=""+A,C!==null&&C.tag===6?(a(I,C.sibling),C=h(C,A),C.return=I,I=C):(a(I,C),C=Il(A,I.mode,G),C.return=I,I=C),k(I)):a(I,C)}return Fe}var xs=cd(!0),ud=cd(!1),Cr=Sn(null),$r=null,ws=null,za=null;function Fa(){za=ws=$r=null}function Ua(n){var s=Cr.current;Me(Cr),n._currentValue=s}function Ha(n,s,a){for(;n!==null;){var u=n.alternate;if((n.childLanes&s)!==s?(n.childLanes|=s,u!==null&&(u.childLanes|=s)):u!==null&&(u.childLanes&s)!==s&&(u.childLanes|=s),n===a)break;n=n.return}}function js(n,s){$r=n,za=ws=null,n=n.dependencies,n!==null&&n.firstContext!==null&&((n.lanes&s)!==0&&(gt=!0),n.firstContext=null)}function Et(n){var s=n._currentValue;if(za!==n)if(n={context:n,memoizedValue:s,next:null},ws===null){if($r===null)throw Error(r(308));ws=n,$r.dependencies={lanes:0,firstContext:n}}else ws=ws.next=n;return s}var Vn=null;function Wa(n){Vn===null?Vn=[n]:Vn.push(n)}function dd(n,s,a,u){var h=s.interleaved;return h===null?(a.next=a,Wa(s)):(a.next=h.next,h.next=a),s.interleaved=a,cn(n,u)}function cn(n,s){n.lanes|=s;var a=n.alternate;for(a!==null&&(a.lanes|=s),a=n,n=n.return;n!==null;)n.childLanes|=s,a=n.alternate,a!==null&&(a.childLanes|=s),a=n,n=n.return;return a.tag===3?a.stateNode:null}var $n=!1;function Ka(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function fd(n,s){n=n.updateQueue,s.updateQueue===n&&(s.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,effects:n.effects})}function un(n,s){return{eventTime:n,lane:s,tag:0,payload:null,callback:null,next:null}}function Tn(n,s,a){var u=n.updateQueue;if(u===null)return null;if(u=u.shared,(je&2)!==0){var h=u.pending;return h===null?s.next=s:(s.next=h.next,h.next=s),u.pending=s,cn(n,a)}return h=u.interleaved,h===null?(s.next=s,Wa(u)):(s.next=h.next,h.next=s),u.interleaved=s,cn(n,a)}function Tr(n,s,a){if(s=s.updateQueue,s!==null&&(s=s.shared,(a&4194240)!==0)){var u=s.lanes;u&=n.pendingLanes,a|=u,s.lanes=a,ra(n,a)}}function hd(n,s){var a=n.updateQueue,u=n.alternate;if(u!==null&&(u=u.updateQueue,a===u)){var h=null,p=null;if(a=a.firstBaseUpdate,a!==null){do{var k={eventTime:a.eventTime,lane:a.lane,tag:a.tag,payload:a.payload,callback:a.callback,next:null};p===null?h=p=k:p=p.next=k,a=a.next}while(a!==null);p===null?h=p=s:p=p.next=s}else h=p=s;a={baseState:u.baseState,firstBaseUpdate:h,lastBaseUpdate:p,shared:u.shared,effects:u.effects},n.updateQueue=a;return}n=a.lastBaseUpdate,n===null?a.firstBaseUpdate=s:n.next=s,a.lastBaseUpdate=s}function Er(n,s,a,u){var h=n.updateQueue;$n=!1;var p=h.firstBaseUpdate,k=h.lastBaseUpdate,S=h.shared.pending;if(S!==null){h.shared.pending=null;var b=S,L=b.next;b.next=null,k===null?p=L:k.next=L,k=b;var F=n.alternate;F!==null&&(F=F.updateQueue,S=F.lastBaseUpdate,S!==k&&(S===null?F.firstBaseUpdate=L:S.next=L,F.lastBaseUpdate=b))}if(p!==null){var W=h.baseState;k=0,F=L=b=null,S=p;do{var z=S.lane,J=S.eventTime;if((u&z)===z){F!==null&&(F=F.next={eventTime:J,lane:0,tag:S.tag,payload:S.payload,callback:S.callback,next:null});e:{var ne=n,se=S;switch(z=s,J=a,se.tag){case 1:if(ne=se.payload,typeof ne=="function"){W=ne.call(J,W,z);break e}W=ne;break e;case 3:ne.flags=ne.flags&-65537|128;case 0:if(ne=se.payload,z=typeof ne=="function"?ne.call(J,W,z):ne,z==null)break e;W=H({},W,z);break e;case 2:$n=!0}}S.callback!==null&&S.lane!==0&&(n.flags|=64,z=h.effects,z===null?h.effects=[S]:z.push(S))}else J={eventTime:J,lane:z,tag:S.tag,payload:S.payload,callback:S.callback,next:null},F===null?(L=F=J,b=W):F=F.next=J,k|=z;if(S=S.next,S===null){if(S=h.shared.pending,S===null)break;z=S,S=z.next,z.next=null,h.lastBaseUpdate=z,h.shared.pending=null}}while(!0);if(F===null&&(b=W),h.baseState=b,h.firstBaseUpdate=L,h.lastBaseUpdate=F,s=h.shared.interleaved,s!==null){h=s;do k|=h.lane,h=h.next;while(h!==s)}else p===null&&(h.shared.lanes=0);qn|=k,n.lanes=k,n.memoizedState=W}}function md(n,s,a){if(n=s.effects,s.effects=null,n!==null)for(s=0;s<n.length;s++){var u=n[s],h=u.callback;if(h!==null){if(u.callback=null,u=a,typeof h!="function")throw Error(r(191,h));h.call(u)}}}var ki={},Gt=Sn(ki),yi=Sn(ki),xi=Sn(ki);function Gn(n){if(n===ki)throw Error(r(174));return n}function Va(n,s){switch(Te(xi,s),Te(yi,n),Te(Gt,ki),n=s.nodeType,n){case 9:case 11:s=(s=s.documentElement)?s.namespaceURI:Go(null,"");break;default:n=n===8?s.parentNode:s,s=n.namespaceURI||null,n=n.tagName,s=Go(s,n)}Me(Gt),Te(Gt,s)}function Ns(){Me(Gt),Me(yi),Me(xi)}function pd(n){Gn(xi.current);var s=Gn(Gt.current),a=Go(s,n.type);s!==a&&(Te(yi,n),Te(Gt,a))}function Ga(n){yi.current===n&&(Me(Gt),Me(yi))}var Oe=Sn(0);function Ir(n){for(var s=n;s!==null;){if(s.tag===13){var a=s.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||a.data==="$?"||a.data==="$!"))return s}else if(s.tag===19&&s.memoizedProps.revealOrder!==void 0){if((s.flags&128)!==0)return s}else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===n)break;for(;s.sibling===null;){if(s.return===null||s.return===n)return null;s=s.return}s.sibling.return=s.return,s=s.sibling}return null}var Qa=[];function qa(){for(var n=0;n<Qa.length;n++)Qa[n]._workInProgressVersionPrimary=null;Qa.length=0}var Mr=X.ReactCurrentDispatcher,Ya=X.ReactCurrentBatchConfig,Qn=0,Pe=null,Qe=null,Xe=null,Ar=!1,wi=!1,ji=0,Qg=0;function ot(){throw Error(r(321))}function Ja(n,s){if(s===null)return!1;for(var a=0;a<s.length&&a<n.length;a++)if(!_t(n[a],s[a]))return!1;return!0}function Xa(n,s,a,u,h,p){if(Qn=p,Pe=s,s.memoizedState=null,s.updateQueue=null,s.lanes=0,Mr.current=n===null||n.memoizedState===null?Xg:Zg,n=a(u,h),wi){p=0;do{if(wi=!1,ji=0,25<=p)throw Error(r(301));p+=1,Xe=Qe=null,s.updateQueue=null,Mr.current=ev,n=a(u,h)}while(wi)}if(Mr.current=Or,s=Qe!==null&&Qe.next!==null,Qn=0,Xe=Qe=Pe=null,Ar=!1,s)throw Error(r(300));return n}function Za(){var n=ji!==0;return ji=0,n}function Qt(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Xe===null?Pe.memoizedState=Xe=n:Xe=Xe.next=n,Xe}function It(){if(Qe===null){var n=Pe.alternate;n=n!==null?n.memoizedState:null}else n=Qe.next;var s=Xe===null?Pe.memoizedState:Xe.next;if(s!==null)Xe=s,Qe=n;else{if(n===null)throw Error(r(310));Qe=n,n={memoizedState:Qe.memoizedState,baseState:Qe.baseState,baseQueue:Qe.baseQueue,queue:Qe.queue,next:null},Xe===null?Pe.memoizedState=Xe=n:Xe=Xe.next=n}return Xe}function Ni(n,s){return typeof s=="function"?s(n):s}function el(n){var s=It(),a=s.queue;if(a===null)throw Error(r(311));a.lastRenderedReducer=n;var u=Qe,h=u.baseQueue,p=a.pending;if(p!==null){if(h!==null){var k=h.next;h.next=p.next,p.next=k}u.baseQueue=h=p,a.pending=null}if(h!==null){p=h.next,u=u.baseState;var S=k=null,b=null,L=p;do{var F=L.lane;if((Qn&F)===F)b!==null&&(b=b.next={lane:0,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null}),u=L.hasEagerState?L.eagerState:n(u,L.action);else{var W={lane:F,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null};b===null?(S=b=W,k=u):b=b.next=W,Pe.lanes|=F,qn|=F}L=L.next}while(L!==null&&L!==p);b===null?k=u:b.next=S,_t(u,s.memoizedState)||(gt=!0),s.memoizedState=u,s.baseState=k,s.baseQueue=b,a.lastRenderedState=u}if(n=a.interleaved,n!==null){h=n;do p=h.lane,Pe.lanes|=p,qn|=p,h=h.next;while(h!==n)}else h===null&&(a.lanes=0);return[s.memoizedState,a.dispatch]}function tl(n){var s=It(),a=s.queue;if(a===null)throw Error(r(311));a.lastRenderedReducer=n;var u=a.dispatch,h=a.pending,p=s.memoizedState;if(h!==null){a.pending=null;var k=h=h.next;do p=n(p,k.action),k=k.next;while(k!==h);_t(p,s.memoizedState)||(gt=!0),s.memoizedState=p,s.baseQueue===null&&(s.baseState=p),a.lastRenderedState=p}return[p,u]}function gd(){}function vd(n,s){var a=Pe,u=It(),h=s(),p=!_t(u.memoizedState,h);if(p&&(u.memoizedState=h,gt=!0),u=u.queue,nl(xd.bind(null,a,u,n),[n]),u.getSnapshot!==s||p||Xe!==null&&Xe.memoizedState.tag&1){if(a.flags|=2048,Si(9,yd.bind(null,a,u,h,s),void 0,null),Ze===null)throw Error(r(349));(Qn&30)!==0||kd(a,s,h)}return h}function kd(n,s,a){n.flags|=16384,n={getSnapshot:s,value:a},s=Pe.updateQueue,s===null?(s={lastEffect:null,stores:null},Pe.updateQueue=s,s.stores=[n]):(a=s.stores,a===null?s.stores=[n]:a.push(n))}function yd(n,s,a,u){s.value=a,s.getSnapshot=u,wd(s)&&jd(n)}function xd(n,s,a){return a(function(){wd(s)&&jd(n)})}function wd(n){var s=n.getSnapshot;n=n.value;try{var a=s();return!_t(n,a)}catch{return!0}}function jd(n){var s=cn(n,1);s!==null&&Ut(s,n,1,-1)}function Nd(n){var s=Qt();return typeof n=="function"&&(n=n()),s.memoizedState=s.baseState=n,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ni,lastRenderedState:n},s.queue=n,n=n.dispatch=Jg.bind(null,Pe,n),[s.memoizedState,n]}function Si(n,s,a,u){return n={tag:n,create:s,destroy:a,deps:u,next:null},s=Pe.updateQueue,s===null?(s={lastEffect:null,stores:null},Pe.updateQueue=s,s.lastEffect=n.next=n):(a=s.lastEffect,a===null?s.lastEffect=n.next=n:(u=a.next,a.next=n,n.next=u,s.lastEffect=n)),n}function Sd(){return It().memoizedState}function Lr(n,s,a,u){var h=Qt();Pe.flags|=n,h.memoizedState=Si(1|s,a,void 0,u===void 0?null:u)}function Rr(n,s,a,u){var h=It();u=u===void 0?null:u;var p=void 0;if(Qe!==null){var k=Qe.memoizedState;if(p=k.destroy,u!==null&&Ja(u,k.deps)){h.memoizedState=Si(s,a,p,u);return}}Pe.flags|=n,h.memoizedState=Si(1|s,a,p,u)}function bd(n,s){return Lr(8390656,8,n,s)}function nl(n,s){return Rr(2048,8,n,s)}function Cd(n,s){return Rr(4,2,n,s)}function $d(n,s){return Rr(4,4,n,s)}function Td(n,s){if(typeof s=="function")return n=n(),s(n),function(){s(null)};if(s!=null)return n=n(),s.current=n,function(){s.current=null}}function Ed(n,s,a){return a=a!=null?a.concat([n]):null,Rr(4,4,Td.bind(null,s,n),a)}function sl(){}function Id(n,s){var a=It();s=s===void 0?null:s;var u=a.memoizedState;return u!==null&&s!==null&&Ja(s,u[1])?u[0]:(a.memoizedState=[n,s],n)}function Md(n,s){var a=It();s=s===void 0?null:s;var u=a.memoizedState;return u!==null&&s!==null&&Ja(s,u[1])?u[0]:(n=n(),a.memoizedState=[n,s],n)}function Ad(n,s,a){return(Qn&21)===0?(n.baseState&&(n.baseState=!1,gt=!0),n.memoizedState=a):(_t(a,s)||(a=lu(),Pe.lanes|=a,qn|=a,n.baseState=!0),s)}function qg(n,s){var a=Ce;Ce=a!==0&&4>a?a:4,n(!0);var u=Ya.transition;Ya.transition={};try{n(!1),s()}finally{Ce=a,Ya.transition=u}}function Ld(){return It().memoizedState}function Yg(n,s,a){var u=An(n);if(a={lane:u,action:a,hasEagerState:!1,eagerState:null,next:null},Rd(n))Od(s,a);else if(a=dd(n,s,a,u),a!==null){var h=ft();Ut(a,n,u,h),Pd(a,s,u)}}function Jg(n,s,a){var u=An(n),h={lane:u,action:a,hasEagerState:!1,eagerState:null,next:null};if(Rd(n))Od(s,h);else{var p=n.alternate;if(n.lanes===0&&(p===null||p.lanes===0)&&(p=s.lastRenderedReducer,p!==null))try{var k=s.lastRenderedState,S=p(k,a);if(h.hasEagerState=!0,h.eagerState=S,_t(S,k)){var b=s.interleaved;b===null?(h.next=h,Wa(s)):(h.next=b.next,b.next=h),s.interleaved=h;return}}catch{}finally{}a=dd(n,s,h,u),a!==null&&(h=ft(),Ut(a,n,u,h),Pd(a,s,u))}}function Rd(n){var s=n.alternate;return n===Pe||s!==null&&s===Pe}function Od(n,s){wi=Ar=!0;var a=n.pending;a===null?s.next=s:(s.next=a.next,a.next=s),n.pending=s}function Pd(n,s,a){if((a&4194240)!==0){var u=s.lanes;u&=n.pendingLanes,a|=u,s.lanes=a,ra(n,a)}}var Or={readContext:Et,useCallback:ot,useContext:ot,useEffect:ot,useImperativeHandle:ot,useInsertionEffect:ot,useLayoutEffect:ot,useMemo:ot,useReducer:ot,useRef:ot,useState:ot,useDebugValue:ot,useDeferredValue:ot,useTransition:ot,useMutableSource:ot,useSyncExternalStore:ot,useId:ot,unstable_isNewReconciler:!1},Xg={readContext:Et,useCallback:function(n,s){return Qt().memoizedState=[n,s===void 0?null:s],n},useContext:Et,useEffect:bd,useImperativeHandle:function(n,s,a){return a=a!=null?a.concat([n]):null,Lr(4194308,4,Td.bind(null,s,n),a)},useLayoutEffect:function(n,s){return Lr(4194308,4,n,s)},useInsertionEffect:function(n,s){return Lr(4,2,n,s)},useMemo:function(n,s){var a=Qt();return s=s===void 0?null:s,n=n(),a.memoizedState=[n,s],n},useReducer:function(n,s,a){var u=Qt();return s=a!==void 0?a(s):s,u.memoizedState=u.baseState=s,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:s},u.queue=n,n=n.dispatch=Yg.bind(null,Pe,n),[u.memoizedState,n]},useRef:function(n){var s=Qt();return n={current:n},s.memoizedState=n},useState:Nd,useDebugValue:sl,useDeferredValue:function(n){return Qt().memoizedState=n},useTransition:function(){var n=Nd(!1),s=n[0];return n=qg.bind(null,n[1]),Qt().memoizedState=n,[s,n]},useMutableSource:function(){},useSyncExternalStore:function(n,s,a){var u=Pe,h=Qt();if(Le){if(a===void 0)throw Error(r(407));a=a()}else{if(a=s(),Ze===null)throw Error(r(349));(Qn&30)!==0||kd(u,s,a)}h.memoizedState=a;var p={value:a,getSnapshot:s};return h.queue=p,bd(xd.bind(null,u,p,n),[n]),u.flags|=2048,Si(9,yd.bind(null,u,p,a,s),void 0,null),a},useId:function(){var n=Qt(),s=Ze.identifierPrefix;if(Le){var a=ln,u=an;a=(u&~(1<<32-Pt(u)-1)).toString(32)+a,s=":"+s+"R"+a,a=ji++,0<a&&(s+="H"+a.toString(32)),s+=":"}else a=Qg++,s=":"+s+"r"+a.toString(32)+":";return n.memoizedState=s},unstable_isNewReconciler:!1},Zg={readContext:Et,useCallback:Id,useContext:Et,useEffect:nl,useImperativeHandle:Ed,useInsertionEffect:Cd,useLayoutEffect:$d,useMemo:Md,useReducer:el,useRef:Sd,useState:function(){return el(Ni)},useDebugValue:sl,useDeferredValue:function(n){var s=It();return Ad(s,Qe.memoizedState,n)},useTransition:function(){var n=el(Ni)[0],s=It().memoizedState;return[n,s]},useMutableSource:gd,useSyncExternalStore:vd,useId:Ld,unstable_isNewReconciler:!1},ev={readContext:Et,useCallback:Id,useContext:Et,useEffect:nl,useImperativeHandle:Ed,useInsertionEffect:Cd,useLayoutEffect:$d,useMemo:Md,useReducer:tl,useRef:Sd,useState:function(){return tl(Ni)},useDebugValue:sl,useDeferredValue:function(n){var s=It();return Qe===null?s.memoizedState=n:Ad(s,Qe.memoizedState,n)},useTransition:function(){var n=tl(Ni)[0],s=It().memoizedState;return[n,s]},useMutableSource:gd,useSyncExternalStore:vd,useId:Ld,unstable_isNewReconciler:!1};function Bt(n,s){if(n&&n.defaultProps){s=H({},s),n=n.defaultProps;for(var a in n)s[a]===void 0&&(s[a]=n[a]);return s}return s}function il(n,s,a,u){s=n.memoizedState,a=a(u,s),a=a==null?s:H({},s,a),n.memoizedState=a,n.lanes===0&&(n.updateQueue.baseState=a)}var Pr={isMounted:function(n){return(n=n._reactInternals)?Fn(n)===n:!1},enqueueSetState:function(n,s,a){n=n._reactInternals;var u=ft(),h=An(n),p=un(u,h);p.payload=s,a!=null&&(p.callback=a),s=Tn(n,p,h),s!==null&&(Ut(s,n,h,u),Tr(s,n,h))},enqueueReplaceState:function(n,s,a){n=n._reactInternals;var u=ft(),h=An(n),p=un(u,h);p.tag=1,p.payload=s,a!=null&&(p.callback=a),s=Tn(n,p,h),s!==null&&(Ut(s,n,h,u),Tr(s,n,h))},enqueueForceUpdate:function(n,s){n=n._reactInternals;var a=ft(),u=An(n),h=un(a,u);h.tag=2,s!=null&&(h.callback=s),s=Tn(n,h,u),s!==null&&(Ut(s,n,u,a),Tr(s,n,u))}};function _d(n,s,a,u,h,p,k){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(u,p,k):s.prototype&&s.prototype.isPureReactComponent?!ui(a,u)||!ui(h,p):!0}function Dd(n,s,a){var u=!1,h=bn,p=s.contextType;return typeof p=="object"&&p!==null?p=Et(p):(h=pt(s)?Hn:rt.current,u=s.contextTypes,p=(u=u!=null)?gs(n,h):bn),s=new s(a,p),n.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,s.updater=Pr,n.stateNode=s,s._reactInternals=n,u&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=h,n.__reactInternalMemoizedMaskedChildContext=p),s}function Bd(n,s,a,u){n=s.state,typeof s.componentWillReceiveProps=="function"&&s.componentWillReceiveProps(a,u),typeof s.UNSAFE_componentWillReceiveProps=="function"&&s.UNSAFE_componentWillReceiveProps(a,u),s.state!==n&&Pr.enqueueReplaceState(s,s.state,null)}function rl(n,s,a,u){var h=n.stateNode;h.props=a,h.state=n.memoizedState,h.refs={},Ka(n);var p=s.contextType;typeof p=="object"&&p!==null?h.context=Et(p):(p=pt(s)?Hn:rt.current,h.context=gs(n,p)),h.state=n.memoizedState,p=s.getDerivedStateFromProps,typeof p=="function"&&(il(n,s,p,a),h.state=n.memoizedState),typeof s.getDerivedStateFromProps=="function"||typeof h.getSnapshotBeforeUpdate=="function"||typeof h.UNSAFE_componentWillMount!="function"&&typeof h.componentWillMount!="function"||(s=h.state,typeof h.componentWillMount=="function"&&h.componentWillMount(),typeof h.UNSAFE_componentWillMount=="function"&&h.UNSAFE_componentWillMount(),s!==h.state&&Pr.enqueueReplaceState(h,h.state,null),Er(n,a,h,u),h.state=n.memoizedState),typeof h.componentDidMount=="function"&&(n.flags|=4194308)}function Ss(n,s){try{var a="",u=s;do a+=de(u),u=u.return;while(u);var h=a}catch(p){h=`
|
|
37
|
+
`+h[k].replace(" at new "," at ");return n.displayName&&b.includes("<anonymous>")&&(b=b.replace("<anonymous>",n.displayName)),b}while(1<=k&&0<=S);break}}}finally{he=!1,Error.prepareStackTrace=a}return(n=n?n.displayName||n.name:"")?_(n):""}function de(n){switch(n.tag){case 5:return _(n.type);case 16:return _("Lazy");case 13:return _("Suspense");case 19:return _("SuspenseList");case 0:case 2:case 15:return n=pe(n.type,!1),n;case 11:return n=pe(n.type.render,!1),n;case 1:return n=pe(n.type,!0),n;default:return""}}function we(n){if(n==null)return null;if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case F:return"Fragment";case Q:return"Portal";case V:return"Profiler";case ie:return"StrictMode";case te:return"Suspense";case P:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case Re:return(n.displayName||"Context")+".Consumer";case ge:return(n._context.displayName||"Context")+".Provider";case be:var s=n.render;return n=n.displayName,n||(n=s.displayName||s.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case Y:return s=n.displayName||null,s!==null?s:we(n.type)||"Memo";case ae:s=n._payload,n=n._init;try{return we(n(s))}catch{}}return null}function me(n){var s=n.type;switch(n.tag){case 24:return"Cache";case 9:return(s.displayName||"Context")+".Consumer";case 10:return(s._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return n=s.render,n=n.displayName||n.name||"",s.displayName||(n!==""?"ForwardRef("+n+")":"ForwardRef");case 7:return"Fragment";case 5:return s;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return we(s);case 8:return s===ie?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s}return null}function ke(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function $e(n){var s=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function ut(n){var s=$e(n)?"checked":"value",a=Object.getOwnPropertyDescriptor(n.constructor.prototype,s),u=""+n[s];if(!n.hasOwnProperty(s)&&typeof a<"u"&&typeof a.get=="function"&&typeof a.set=="function"){var h=a.get,p=a.set;return Object.defineProperty(n,s,{configurable:!0,get:function(){return h.call(this)},set:function(k){u=""+k,p.call(this,k)}}),Object.defineProperty(n,s,{enumerable:a.enumerable}),{getValue:function(){return u},setValue:function(k){u=""+k},stopTracking:function(){n._valueTracker=null,delete n[s]}}}}function ss(n){n._valueTracker||(n._valueTracker=ut(n))}function _c(n){if(!n)return!1;var s=n._valueTracker;if(!s)return!0;var a=s.getValue(),u="";return n&&(u=$e(n)?n.checked?"true":"false":n.value),n=u,n!==a?(s.setValue(n),!0):!1}function Qi(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}function Ho(n,s){var a=s.checked;return H({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:a??n._wrapperState.initialChecked})}function Dc(n,s){var a=s.defaultValue==null?"":s.defaultValue,u=s.checked!=null?s.checked:s.defaultChecked;a=ke(s.value!=null?s.value:a),n._wrapperState={initialChecked:u,initialValue:a,controlled:s.type==="checkbox"||s.type==="radio"?s.checked!=null:s.value!=null}}function Bc(n,s){s=s.checked,s!=null&&O(n,"checked",s,!1)}function Wo(n,s){Bc(n,s);var a=ke(s.value),u=s.type;if(a!=null)u==="number"?(a===0&&n.value===""||n.value!=a)&&(n.value=""+a):n.value!==""+a&&(n.value=""+a);else if(u==="submit"||u==="reset"){n.removeAttribute("value");return}s.hasOwnProperty("value")?Ko(n,s.type,a):s.hasOwnProperty("defaultValue")&&Ko(n,s.type,ke(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(n.defaultChecked=!!s.defaultChecked)}function zc(n,s,a){if(s.hasOwnProperty("value")||s.hasOwnProperty("defaultValue")){var u=s.type;if(!(u!=="submit"&&u!=="reset"||s.value!==void 0&&s.value!==null))return;s=""+n._wrapperState.initialValue,a||s===n.value||(n.value=s),n.defaultValue=s}a=n.name,a!==""&&(n.name=""),n.defaultChecked=!!n._wrapperState.initialChecked,a!==""&&(n.name=a)}function Ko(n,s,a){(s!=="number"||Qi(n.ownerDocument)!==n)&&(a==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+a&&(n.defaultValue=""+a))}var Vs=Array.isArray;function is(n,s,a,u){if(n=n.options,s){s={};for(var h=0;h<a.length;h++)s["$"+a[h]]=!0;for(a=0;a<n.length;a++)h=s.hasOwnProperty("$"+n[a].value),n[a].selected!==h&&(n[a].selected=h),h&&u&&(n[a].defaultSelected=!0)}else{for(a=""+ke(a),s=null,h=0;h<n.length;h++){if(n[h].value===a){n[h].selected=!0,u&&(n[h].defaultSelected=!0);return}s!==null||n[h].disabled||(s=n[h])}s!==null&&(s.selected=!0)}}function Vo(n,s){if(s.dangerouslySetInnerHTML!=null)throw Error(r(91));return H({},s,{value:void 0,defaultValue:void 0,children:""+n._wrapperState.initialValue})}function Fc(n,s){var a=s.value;if(a==null){if(a=s.children,s=s.defaultValue,a!=null){if(s!=null)throw Error(r(92));if(Vs(a)){if(1<a.length)throw Error(r(93));a=a[0]}s=a}s==null&&(s=""),a=s}n._wrapperState={initialValue:ke(a)}}function Uc(n,s){var a=ke(s.value),u=ke(s.defaultValue);a!=null&&(a=""+a,a!==n.value&&(n.value=a),s.defaultValue==null&&n.defaultValue!==a&&(n.defaultValue=a)),u!=null&&(n.defaultValue=""+u)}function Hc(n){var s=n.textContent;s===n._wrapperState.initialValue&&s!==""&&s!==null&&(n.value=s)}function Wc(n){switch(n){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Go(n,s){return n==null||n==="http://www.w3.org/1999/xhtml"?Wc(s):n==="http://www.w3.org/2000/svg"&&s==="foreignObject"?"http://www.w3.org/1999/xhtml":n}var qi,Kc=(function(n){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(s,a,u,h){MSApp.execUnsafeLocalFunction(function(){return n(s,a,u,h)})}:n})(function(n,s){if(n.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in n)n.innerHTML=s;else{for(qi=qi||document.createElement("div"),qi.innerHTML="<svg>"+s.valueOf().toString()+"</svg>",s=qi.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;s.firstChild;)n.appendChild(s.firstChild)}});function Gs(n,s){if(s){var a=n.firstChild;if(a&&a===n.lastChild&&a.nodeType===3){a.nodeValue=s;return}}n.textContent=s}var Qs={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Mp=["Webkit","ms","Moz","O"];Object.keys(Qs).forEach(function(n){Mp.forEach(function(s){s=s+n.charAt(0).toUpperCase()+n.substring(1),Qs[s]=Qs[n]})});function Vc(n,s,a){return s==null||typeof s=="boolean"||s===""?"":a||typeof s!="number"||s===0||Qs.hasOwnProperty(n)&&Qs[n]?(""+s).trim():s+"px"}function Gc(n,s){n=n.style;for(var a in s)if(s.hasOwnProperty(a)){var u=a.indexOf("--")===0,h=Vc(a,s[a],u);a==="float"&&(a="cssFloat"),u?n.setProperty(a,h):n[a]=h}}var Ap=H({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Qo(n,s){if(s){if(Ap[n]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(r(137,n));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(r(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(r(61))}if(s.style!=null&&typeof s.style!="object")throw Error(r(62))}}function qo(n,s){if(n.indexOf("-")===-1)return typeof s.is=="string";switch(n){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Yo=null;function Jo(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var Xo=null,rs=null,os=null;function Qc(n){if(n=gi(n)){if(typeof Xo!="function")throw Error(r(280));var s=n.stateNode;s&&(s=kr(s),Xo(n.stateNode,n.type,s))}}function qc(n){rs?os?os.push(n):os=[n]:rs=n}function Yc(){if(rs){var n=rs,s=os;if(os=rs=null,Qc(n),s)for(n=0;n<s.length;n++)Qc(s[n])}}function Jc(n,s){return n(s)}function Xc(){}var Zo=!1;function Zc(n,s,a){if(Zo)return n(s,a);Zo=!0;try{return Jc(n,s,a)}finally{Zo=!1,(rs!==null||os!==null)&&(Xc(),Yc())}}function qs(n,s){var a=n.stateNode;if(a===null)return null;var u=kr(a);if(u===null)return null;a=u[s];e:switch(s){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(u=!u.disabled)||(n=n.type,u=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!u;break e;default:n=!1}if(n)return null;if(a&&typeof a!="function")throw Error(r(231,s,typeof a));return a}var ea=!1;if(f)try{var Ys={};Object.defineProperty(Ys,"passive",{get:function(){ea=!0}}),window.addEventListener("test",Ys,Ys),window.removeEventListener("test",Ys,Ys)}catch{ea=!1}function Lp(n,s,a,u,h,p,k,S,b){var L=Array.prototype.slice.call(arguments,3);try{s.apply(a,L)}catch(z){this.onError(z)}}var Js=!1,Yi=null,Ji=!1,ta=null,Rp={onError:function(n){Js=!0,Yi=n}};function Op(n,s,a,u,h,p,k,S,b){Js=!1,Yi=null,Lp.apply(Rp,arguments)}function Pp(n,s,a,u,h,p,k,S,b){if(Op.apply(this,arguments),Js){if(Js){var L=Yi;Js=!1,Yi=null}else throw Error(r(198));Ji||(Ji=!0,ta=L)}}function Fn(n){var s=n,a=n;if(n.alternate)for(;s.return;)s=s.return;else{n=s;do s=n,(s.flags&4098)!==0&&(a=s.return),n=s.return;while(n)}return s.tag===3?a:null}function eu(n){if(n.tag===13){var s=n.memoizedState;if(s===null&&(n=n.alternate,n!==null&&(s=n.memoizedState)),s!==null)return s.dehydrated}return null}function tu(n){if(Fn(n)!==n)throw Error(r(188))}function _p(n){var s=n.alternate;if(!s){if(s=Fn(n),s===null)throw Error(r(188));return s!==n?null:n}for(var a=n,u=s;;){var h=a.return;if(h===null)break;var p=h.alternate;if(p===null){if(u=h.return,u!==null){a=u;continue}break}if(h.child===p.child){for(p=h.child;p;){if(p===a)return tu(h),n;if(p===u)return tu(h),s;p=p.sibling}throw Error(r(188))}if(a.return!==u.return)a=h,u=p;else{for(var k=!1,S=h.child;S;){if(S===a){k=!0,a=h,u=p;break}if(S===u){k=!0,u=h,a=p;break}S=S.sibling}if(!k){for(S=p.child;S;){if(S===a){k=!0,a=p,u=h;break}if(S===u){k=!0,u=p,a=h;break}S=S.sibling}if(!k)throw Error(r(189))}}if(a.alternate!==u)throw Error(r(190))}if(a.tag!==3)throw Error(r(188));return a.stateNode.current===a?n:s}function nu(n){return n=_p(n),n!==null?su(n):null}function su(n){if(n.tag===5||n.tag===6)return n;for(n=n.child;n!==null;){var s=su(n);if(s!==null)return s;n=n.sibling}return null}var iu=t.unstable_scheduleCallback,ru=t.unstable_cancelCallback,Dp=t.unstable_shouldYield,Bp=t.unstable_requestPaint,ze=t.unstable_now,zp=t.unstable_getCurrentPriorityLevel,na=t.unstable_ImmediatePriority,ou=t.unstable_UserBlockingPriority,Xi=t.unstable_NormalPriority,Fp=t.unstable_LowPriority,au=t.unstable_IdlePriority,Zi=null,Kt=null;function Up(n){if(Kt&&typeof Kt.onCommitFiberRoot=="function")try{Kt.onCommitFiberRoot(Zi,n,void 0,(n.current.flags&128)===128)}catch{}}var Pt=Math.clz32?Math.clz32:Kp,Hp=Math.log,Wp=Math.LN2;function Kp(n){return n>>>=0,n===0?32:31-(Hp(n)/Wp|0)|0}var er=64,tr=4194304;function Xs(n){switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return n&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return n}}function nr(n,s){var a=n.pendingLanes;if(a===0)return 0;var u=0,h=n.suspendedLanes,p=n.pingedLanes,k=a&268435455;if(k!==0){var S=k&~h;S!==0?u=Xs(S):(p&=k,p!==0&&(u=Xs(p)))}else k=a&~h,k!==0?u=Xs(k):p!==0&&(u=Xs(p));if(u===0)return 0;if(s!==0&&s!==u&&(s&h)===0&&(h=u&-u,p=s&-s,h>=p||h===16&&(p&4194240)!==0))return s;if((u&4)!==0&&(u|=a&16),s=n.entangledLanes,s!==0)for(n=n.entanglements,s&=u;0<s;)a=31-Pt(s),h=1<<a,u|=n[a],s&=~h;return u}function Vp(n,s){switch(n){case 1:case 2:case 4:return s+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return s+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Gp(n,s){for(var a=n.suspendedLanes,u=n.pingedLanes,h=n.expirationTimes,p=n.pendingLanes;0<p;){var k=31-Pt(p),S=1<<k,b=h[k];b===-1?((S&a)===0||(S&u)!==0)&&(h[k]=Vp(S,s)):b<=s&&(n.expiredLanes|=S),p&=~S}}function sa(n){return n=n.pendingLanes&-1073741825,n!==0?n:n&1073741824?1073741824:0}function lu(){var n=er;return er<<=1,(er&4194240)===0&&(er=64),n}function ia(n){for(var s=[],a=0;31>a;a++)s.push(n);return s}function Zs(n,s,a){n.pendingLanes|=s,s!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,s=31-Pt(s),n[s]=a}function Qp(n,s){var a=n.pendingLanes&~s;n.pendingLanes=s,n.suspendedLanes=0,n.pingedLanes=0,n.expiredLanes&=s,n.mutableReadLanes&=s,n.entangledLanes&=s,s=n.entanglements;var u=n.eventTimes;for(n=n.expirationTimes;0<a;){var h=31-Pt(a),p=1<<h;s[h]=0,u[h]=-1,n[h]=-1,a&=~p}}function ra(n,s){var a=n.entangledLanes|=s;for(n=n.entanglements;a;){var u=31-Pt(a),h=1<<u;h&s|n[u]&s&&(n[u]|=s),a&=~h}}var Ce=0;function cu(n){return n&=-n,1<n?4<n?(n&268435455)!==0?16:536870912:4:1}var uu,oa,du,fu,hu,aa=!1,sr=[],vn=null,kn=null,yn=null,ei=new Map,ti=new Map,xn=[],qp="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function mu(n,s){switch(n){case"focusin":case"focusout":vn=null;break;case"dragenter":case"dragleave":kn=null;break;case"mouseover":case"mouseout":yn=null;break;case"pointerover":case"pointerout":ei.delete(s.pointerId);break;case"gotpointercapture":case"lostpointercapture":ti.delete(s.pointerId)}}function ni(n,s,a,u,h,p){return n===null||n.nativeEvent!==p?(n={blockedOn:s,domEventName:a,eventSystemFlags:u,nativeEvent:p,targetContainers:[h]},s!==null&&(s=gi(s),s!==null&&oa(s)),n):(n.eventSystemFlags|=u,s=n.targetContainers,h!==null&&s.indexOf(h)===-1&&s.push(h),n)}function Yp(n,s,a,u,h){switch(s){case"focusin":return vn=ni(vn,n,s,a,u,h),!0;case"dragenter":return kn=ni(kn,n,s,a,u,h),!0;case"mouseover":return yn=ni(yn,n,s,a,u,h),!0;case"pointerover":var p=h.pointerId;return ei.set(p,ni(ei.get(p)||null,n,s,a,u,h)),!0;case"gotpointercapture":return p=h.pointerId,ti.set(p,ni(ti.get(p)||null,n,s,a,u,h)),!0}return!1}function pu(n){var s=Un(n.target);if(s!==null){var a=Fn(s);if(a!==null){if(s=a.tag,s===13){if(s=eu(a),s!==null){n.blockedOn=s,hu(n.priority,function(){du(a)});return}}else if(s===3&&a.stateNode.current.memoizedState.isDehydrated){n.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}n.blockedOn=null}function ir(n){if(n.blockedOn!==null)return!1;for(var s=n.targetContainers;0<s.length;){var a=ca(n.domEventName,n.eventSystemFlags,s[0],n.nativeEvent);if(a===null){a=n.nativeEvent;var u=new a.constructor(a.type,a);Yo=u,a.target.dispatchEvent(u),Yo=null}else return s=gi(a),s!==null&&oa(s),n.blockedOn=a,!1;s.shift()}return!0}function gu(n,s,a){ir(n)&&a.delete(s)}function Jp(){aa=!1,vn!==null&&ir(vn)&&(vn=null),kn!==null&&ir(kn)&&(kn=null),yn!==null&&ir(yn)&&(yn=null),ei.forEach(gu),ti.forEach(gu)}function si(n,s){n.blockedOn===s&&(n.blockedOn=null,aa||(aa=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Jp)))}function ii(n){function s(h){return si(h,n)}if(0<sr.length){si(sr[0],n);for(var a=1;a<sr.length;a++){var u=sr[a];u.blockedOn===n&&(u.blockedOn=null)}}for(vn!==null&&si(vn,n),kn!==null&&si(kn,n),yn!==null&&si(yn,n),ei.forEach(s),ti.forEach(s),a=0;a<xn.length;a++)u=xn[a],u.blockedOn===n&&(u.blockedOn=null);for(;0<xn.length&&(a=xn[0],a.blockedOn===null);)pu(a),a.blockedOn===null&&xn.shift()}var as=X.ReactCurrentBatchConfig,rr=!0;function Xp(n,s,a,u){var h=Ce,p=as.transition;as.transition=null;try{Ce=1,la(n,s,a,u)}finally{Ce=h,as.transition=p}}function Zp(n,s,a,u){var h=Ce,p=as.transition;as.transition=null;try{Ce=4,la(n,s,a,u)}finally{Ce=h,as.transition=p}}function la(n,s,a,u){if(rr){var h=ca(n,s,a,u);if(h===null)Ca(n,s,u,or,a),mu(n,u);else if(Yp(h,n,s,a,u))u.stopPropagation();else if(mu(n,u),s&4&&-1<qp.indexOf(n)){for(;h!==null;){var p=gi(h);if(p!==null&&uu(p),p=ca(n,s,a,u),p===null&&Ca(n,s,u,or,a),p===h)break;h=p}h!==null&&u.stopPropagation()}else Ca(n,s,u,null,a)}}var or=null;function ca(n,s,a,u){if(or=null,n=Jo(u),n=Un(n),n!==null)if(s=Fn(n),s===null)n=null;else if(a=s.tag,a===13){if(n=eu(s),n!==null)return n;n=null}else if(a===3){if(s.stateNode.current.memoizedState.isDehydrated)return s.tag===3?s.stateNode.containerInfo:null;n=null}else s!==n&&(n=null);return or=n,null}function vu(n){switch(n){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(zp()){case na:return 1;case ou:return 4;case Xi:case Fp:return 16;case au:return 536870912;default:return 16}default:return 16}}var wn=null,ua=null,ar=null;function ku(){if(ar)return ar;var n,s=ua,a=s.length,u,h="value"in wn?wn.value:wn.textContent,p=h.length;for(n=0;n<a&&s[n]===h[n];n++);var k=a-n;for(u=1;u<=k&&s[a-u]===h[p-u];u++);return ar=h.slice(n,1<u?1-u:void 0)}function lr(n){var s=n.keyCode;return"charCode"in n?(n=n.charCode,n===0&&s===13&&(n=13)):n=s,n===10&&(n=13),32<=n||n===13?n:0}function cr(){return!0}function yu(){return!1}function jt(n){function s(a,u,h,p,k){this._reactName=a,this._targetInst=h,this.type=u,this.nativeEvent=p,this.target=k,this.currentTarget=null;for(var S in n)n.hasOwnProperty(S)&&(a=n[S],this[S]=a?a(p):p[S]);return this.isDefaultPrevented=(p.defaultPrevented!=null?p.defaultPrevented:p.returnValue===!1)?cr:yu,this.isPropagationStopped=yu,this}return H(s.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=cr)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=cr)},persist:function(){},isPersistent:cr}),s}var ls={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},da=jt(ls),ri=H({},ls,{view:0,detail:0}),eg=jt(ri),fa,ha,oi,ur=H({},ri,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:pa,button:0,buttons:0,relatedTarget:function(n){return n.relatedTarget===void 0?n.fromElement===n.srcElement?n.toElement:n.fromElement:n.relatedTarget},movementX:function(n){return"movementX"in n?n.movementX:(n!==oi&&(oi&&n.type==="mousemove"?(fa=n.screenX-oi.screenX,ha=n.screenY-oi.screenY):ha=fa=0,oi=n),fa)},movementY:function(n){return"movementY"in n?n.movementY:ha}}),xu=jt(ur),tg=H({},ur,{dataTransfer:0}),ng=jt(tg),sg=H({},ri,{relatedTarget:0}),ma=jt(sg),ig=H({},ls,{animationName:0,elapsedTime:0,pseudoElement:0}),rg=jt(ig),og=H({},ls,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),ag=jt(og),lg=H({},ls,{data:0}),wu=jt(lg),cg={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},ug={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"},dg={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function fg(n){var s=this.nativeEvent;return s.getModifierState?s.getModifierState(n):(n=dg[n])?!!s[n]:!1}function pa(){return fg}var hg=H({},ri,{key:function(n){if(n.key){var s=cg[n.key]||n.key;if(s!=="Unidentified")return s}return n.type==="keypress"?(n=lr(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?ug[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:pa,charCode:function(n){return n.type==="keypress"?lr(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?lr(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),mg=jt(hg),pg=H({},ur,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ju=jt(pg),gg=H({},ri,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:pa}),vg=jt(gg),kg=H({},ls,{propertyName:0,elapsedTime:0,pseudoElement:0}),yg=jt(kg),xg=H({},ur,{deltaX:function(n){return"deltaX"in n?n.deltaX:"wheelDeltaX"in n?-n.wheelDeltaX:0},deltaY:function(n){return"deltaY"in n?n.deltaY:"wheelDeltaY"in n?-n.wheelDeltaY:"wheelDelta"in n?-n.wheelDelta:0},deltaZ:0,deltaMode:0}),wg=jt(xg),jg=[9,13,27,32],ga=f&&"CompositionEvent"in window,ai=null;f&&"documentMode"in document&&(ai=document.documentMode);var Ng=f&&"TextEvent"in window&&!ai,Nu=f&&(!ga||ai&&8<ai&&11>=ai),Su=" ",bu=!1;function Cu(n,s){switch(n){case"keyup":return jg.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function $u(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var cs=!1;function Sg(n,s){switch(n){case"compositionend":return $u(s);case"keypress":return s.which!==32?null:(bu=!0,Su);case"textInput":return n=s.data,n===Su&&bu?null:n;default:return null}}function bg(n,s){if(cs)return n==="compositionend"||!ga&&Cu(n,s)?(n=ku(),ar=ua=wn=null,cs=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1<s.char.length)return s.char;if(s.which)return String.fromCharCode(s.which)}return null;case"compositionend":return Nu&&s.locale!=="ko"?null:s.data;default:return null}}var Cg={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Tu(n){var s=n&&n.nodeName&&n.nodeName.toLowerCase();return s==="input"?!!Cg[n.type]:s==="textarea"}function Eu(n,s,a,u){qc(u),s=pr(s,"onChange"),0<s.length&&(a=new da("onChange","change",null,a,u),n.push({event:a,listeners:s}))}var li=null,ci=null;function $g(n){Gu(n,0)}function dr(n){var s=ms(n);if(_c(s))return n}function Tg(n,s){if(n==="change")return s}var Iu=!1;if(f){var va;if(f){var ka="oninput"in document;if(!ka){var Mu=document.createElement("div");Mu.setAttribute("oninput","return;"),ka=typeof Mu.oninput=="function"}va=ka}else va=!1;Iu=va&&(!document.documentMode||9<document.documentMode)}function Au(){li&&(li.detachEvent("onpropertychange",Lu),ci=li=null)}function Lu(n){if(n.propertyName==="value"&&dr(ci)){var s=[];Eu(s,ci,n,Jo(n)),Zc($g,s)}}function Eg(n,s,a){n==="focusin"?(Au(),li=s,ci=a,li.attachEvent("onpropertychange",Lu)):n==="focusout"&&Au()}function Ig(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return dr(ci)}function Mg(n,s){if(n==="click")return dr(s)}function Ag(n,s){if(n==="input"||n==="change")return dr(s)}function Lg(n,s){return n===s&&(n!==0||1/n===1/s)||n!==n&&s!==s}var _t=typeof Object.is=="function"?Object.is:Lg;function ui(n,s){if(_t(n,s))return!0;if(typeof n!="object"||n===null||typeof s!="object"||s===null)return!1;var a=Object.keys(n),u=Object.keys(s);if(a.length!==u.length)return!1;for(u=0;u<a.length;u++){var h=a[u];if(!g.call(s,h)||!_t(n[h],s[h]))return!1}return!0}function Ru(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function Ou(n,s){var a=Ru(n);n=0;for(var u;a;){if(a.nodeType===3){if(u=n+a.textContent.length,n<=s&&u>=s)return{node:a,offset:s-n};n=u}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Ru(a)}}function Pu(n,s){return n&&s?n===s?!0:n&&n.nodeType===3?!1:s&&s.nodeType===3?Pu(n,s.parentNode):"contains"in n?n.contains(s):n.compareDocumentPosition?!!(n.compareDocumentPosition(s)&16):!1:!1}function _u(){for(var n=window,s=Qi();s instanceof n.HTMLIFrameElement;){try{var a=typeof s.contentWindow.location.href=="string"}catch{a=!1}if(a)n=s.contentWindow;else break;s=Qi(n.document)}return s}function ya(n){var s=n&&n.nodeName&&n.nodeName.toLowerCase();return s&&(s==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||s==="textarea"||n.contentEditable==="true")}function Rg(n){var s=_u(),a=n.focusedElem,u=n.selectionRange;if(s!==a&&a&&a.ownerDocument&&Pu(a.ownerDocument.documentElement,a)){if(u!==null&&ya(a)){if(s=u.start,n=u.end,n===void 0&&(n=s),"selectionStart"in a)a.selectionStart=s,a.selectionEnd=Math.min(n,a.value.length);else if(n=(s=a.ownerDocument||document)&&s.defaultView||window,n.getSelection){n=n.getSelection();var h=a.textContent.length,p=Math.min(u.start,h);u=u.end===void 0?p:Math.min(u.end,h),!n.extend&&p>u&&(h=u,u=p,p=h),h=Ou(a,p);var k=Ou(a,u);h&&k&&(n.rangeCount!==1||n.anchorNode!==h.node||n.anchorOffset!==h.offset||n.focusNode!==k.node||n.focusOffset!==k.offset)&&(s=s.createRange(),s.setStart(h.node,h.offset),n.removeAllRanges(),p>u?(n.addRange(s),n.extend(k.node,k.offset)):(s.setEnd(k.node,k.offset),n.addRange(s)))}}for(s=[],n=a;n=n.parentNode;)n.nodeType===1&&s.push({element:n,left:n.scrollLeft,top:n.scrollTop});for(typeof a.focus=="function"&&a.focus(),a=0;a<s.length;a++)n=s[a],n.element.scrollLeft=n.left,n.element.scrollTop=n.top}}var Og=f&&"documentMode"in document&&11>=document.documentMode,us=null,xa=null,di=null,wa=!1;function Du(n,s,a){var u=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;wa||us==null||us!==Qi(u)||(u=us,"selectionStart"in u&&ya(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),di&&ui(di,u)||(di=u,u=pr(xa,"onSelect"),0<u.length&&(s=new da("onSelect","select",null,s,a),n.push({event:s,listeners:u}),s.target=us)))}function fr(n,s){var a={};return a[n.toLowerCase()]=s.toLowerCase(),a["Webkit"+n]="webkit"+s,a["Moz"+n]="moz"+s,a}var ds={animationend:fr("Animation","AnimationEnd"),animationiteration:fr("Animation","AnimationIteration"),animationstart:fr("Animation","AnimationStart"),transitionend:fr("Transition","TransitionEnd")},ja={},Bu={};f&&(Bu=document.createElement("div").style,"AnimationEvent"in window||(delete ds.animationend.animation,delete ds.animationiteration.animation,delete ds.animationstart.animation),"TransitionEvent"in window||delete ds.transitionend.transition);function hr(n){if(ja[n])return ja[n];if(!ds[n])return n;var s=ds[n],a;for(a in s)if(s.hasOwnProperty(a)&&a in Bu)return ja[n]=s[a];return n}var zu=hr("animationend"),Fu=hr("animationiteration"),Uu=hr("animationstart"),Hu=hr("transitionend"),Wu=new Map,Ku="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function jn(n,s){Wu.set(n,s),c(s,[n])}for(var Na=0;Na<Ku.length;Na++){var Sa=Ku[Na],Pg=Sa.toLowerCase(),_g=Sa[0].toUpperCase()+Sa.slice(1);jn(Pg,"on"+_g)}jn(zu,"onAnimationEnd"),jn(Fu,"onAnimationIteration"),jn(Uu,"onAnimationStart"),jn("dblclick","onDoubleClick"),jn("focusin","onFocus"),jn("focusout","onBlur"),jn(Hu,"onTransitionEnd"),d("onMouseEnter",["mouseout","mouseover"]),d("onMouseLeave",["mouseout","mouseover"]),d("onPointerEnter",["pointerout","pointerover"]),d("onPointerLeave",["pointerout","pointerover"]),c("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),c("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),c("onBeforeInput",["compositionend","keypress","textInput","paste"]),c("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),c("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),c("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var fi="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(" "),Dg=new Set("cancel close invalid load scroll toggle".split(" ").concat(fi));function Vu(n,s,a){var u=n.type||"unknown-event";n.currentTarget=a,Pp(u,s,void 0,n),n.currentTarget=null}function Gu(n,s){s=(s&4)!==0;for(var a=0;a<n.length;a++){var u=n[a],h=u.event;u=u.listeners;e:{var p=void 0;if(s)for(var k=u.length-1;0<=k;k--){var S=u[k],b=S.instance,L=S.currentTarget;if(S=S.listener,b!==p&&h.isPropagationStopped())break e;Vu(h,S,L),p=b}else for(k=0;k<u.length;k++){if(S=u[k],b=S.instance,L=S.currentTarget,S=S.listener,b!==p&&h.isPropagationStopped())break e;Vu(h,S,L),p=b}}}if(Ji)throw n=ta,Ji=!1,ta=null,n}function Ie(n,s){var a=s[Aa];a===void 0&&(a=s[Aa]=new Set);var u=n+"__bubble";a.has(u)||(Qu(s,n,2,!1),a.add(u))}function ba(n,s,a){var u=0;s&&(u|=4),Qu(a,n,u,s)}var mr="_reactListening"+Math.random().toString(36).slice(2);function hi(n){if(!n[mr]){n[mr]=!0,o.forEach(function(a){a!=="selectionchange"&&(Dg.has(a)||ba(a,!1,n),ba(a,!0,n))});var s=n.nodeType===9?n:n.ownerDocument;s===null||s[mr]||(s[mr]=!0,ba("selectionchange",!1,s))}}function Qu(n,s,a,u){switch(vu(s)){case 1:var h=Xp;break;case 4:h=Zp;break;default:h=la}a=h.bind(null,s,a,n),h=void 0,!ea||s!=="touchstart"&&s!=="touchmove"&&s!=="wheel"||(h=!0),u?h!==void 0?n.addEventListener(s,a,{capture:!0,passive:h}):n.addEventListener(s,a,!0):h!==void 0?n.addEventListener(s,a,{passive:h}):n.addEventListener(s,a,!1)}function Ca(n,s,a,u,h){var p=u;if((s&1)===0&&(s&2)===0&&u!==null)e:for(;;){if(u===null)return;var k=u.tag;if(k===3||k===4){var S=u.stateNode.containerInfo;if(S===h||S.nodeType===8&&S.parentNode===h)break;if(k===4)for(k=u.return;k!==null;){var b=k.tag;if((b===3||b===4)&&(b=k.stateNode.containerInfo,b===h||b.nodeType===8&&b.parentNode===h))return;k=k.return}for(;S!==null;){if(k=Un(S),k===null)return;if(b=k.tag,b===5||b===6){u=p=k;continue e}S=S.parentNode}}u=u.return}Zc(function(){var L=p,z=Jo(a),W=[];e:{var B=Wu.get(n);if(B!==void 0){var J=da,ne=n;switch(n){case"keypress":if(lr(a)===0)break e;case"keydown":case"keyup":J=mg;break;case"focusin":ne="focus",J=ma;break;case"focusout":ne="blur",J=ma;break;case"beforeblur":case"afterblur":J=ma;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":J=xu;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":J=ng;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":J=vg;break;case zu:case Fu:case Uu:J=rg;break;case Hu:J=yg;break;case"scroll":J=eg;break;case"wheel":J=wg;break;case"copy":case"cut":case"paste":J=ag;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":J=ju}var re=(s&4)!==0,Fe=!re&&n==="scroll",I=re?B!==null?B+"Capture":null:B;re=[];for(var C=L,A;C!==null;){A=C;var G=A.stateNode;if(A.tag===5&&G!==null&&(A=G,I!==null&&(G=qs(C,I),G!=null&&re.push(mi(C,G,A)))),Fe)break;C=C.return}0<re.length&&(B=new J(B,ne,null,a,z),W.push({event:B,listeners:re}))}}if((s&7)===0){e:{if(B=n==="mouseover"||n==="pointerover",J=n==="mouseout"||n==="pointerout",B&&a!==Yo&&(ne=a.relatedTarget||a.fromElement)&&(Un(ne)||ne[rn]))break e;if((J||B)&&(B=z.window===z?z:(B=z.ownerDocument)?B.defaultView||B.parentWindow:window,J?(ne=a.relatedTarget||a.toElement,J=L,ne=ne?Un(ne):null,ne!==null&&(Fe=Fn(ne),ne!==Fe||ne.tag!==5&&ne.tag!==6)&&(ne=null)):(J=null,ne=L),J!==ne)){if(re=xu,G="onMouseLeave",I="onMouseEnter",C="mouse",(n==="pointerout"||n==="pointerover")&&(re=ju,G="onPointerLeave",I="onPointerEnter",C="pointer"),Fe=J==null?B:ms(J),A=ne==null?B:ms(ne),B=new re(G,C+"leave",J,a,z),B.target=Fe,B.relatedTarget=A,G=null,Un(z)===L&&(re=new re(I,C+"enter",ne,a,z),re.target=A,re.relatedTarget=Fe,G=re),Fe=G,J&&ne)t:{for(re=J,I=ne,C=0,A=re;A;A=fs(A))C++;for(A=0,G=I;G;G=fs(G))A++;for(;0<C-A;)re=fs(re),C--;for(;0<A-C;)I=fs(I),A--;for(;C--;){if(re===I||I!==null&&re===I.alternate)break t;re=fs(re),I=fs(I)}re=null}else re=null;J!==null&&qu(W,B,J,re,!1),ne!==null&&Fe!==null&&qu(W,Fe,ne,re,!0)}}e:{if(B=L?ms(L):window,J=B.nodeName&&B.nodeName.toLowerCase(),J==="select"||J==="input"&&B.type==="file")var oe=Tg;else if(Tu(B))if(Iu)oe=Ag;else{oe=Ig;var le=Eg}else(J=B.nodeName)&&J.toLowerCase()==="input"&&(B.type==="checkbox"||B.type==="radio")&&(oe=Mg);if(oe&&(oe=oe(n,L))){Eu(W,oe,a,z);break e}le&&le(n,B,L),n==="focusout"&&(le=B._wrapperState)&&le.controlled&&B.type==="number"&&Ko(B,"number",B.value)}switch(le=L?ms(L):window,n){case"focusin":(Tu(le)||le.contentEditable==="true")&&(us=le,xa=L,di=null);break;case"focusout":di=xa=us=null;break;case"mousedown":wa=!0;break;case"contextmenu":case"mouseup":case"dragend":wa=!1,Du(W,a,z);break;case"selectionchange":if(Og)break;case"keydown":case"keyup":Du(W,a,z)}var ce;if(ga)e:{switch(n){case"compositionstart":var fe="onCompositionStart";break e;case"compositionend":fe="onCompositionEnd";break e;case"compositionupdate":fe="onCompositionUpdate";break e}fe=void 0}else cs?Cu(n,a)&&(fe="onCompositionEnd"):n==="keydown"&&a.keyCode===229&&(fe="onCompositionStart");fe&&(Nu&&a.locale!=="ko"&&(cs||fe!=="onCompositionStart"?fe==="onCompositionEnd"&&cs&&(ce=ku()):(wn=z,ua="value"in wn?wn.value:wn.textContent,cs=!0)),le=pr(L,fe),0<le.length&&(fe=new wu(fe,n,null,a,z),W.push({event:fe,listeners:le}),ce?fe.data=ce:(ce=$u(a),ce!==null&&(fe.data=ce)))),(ce=Ng?Sg(n,a):bg(n,a))&&(L=pr(L,"onBeforeInput"),0<L.length&&(z=new wu("onBeforeInput","beforeinput",null,a,z),W.push({event:z,listeners:L}),z.data=ce))}Gu(W,s)})}function mi(n,s,a){return{instance:n,listener:s,currentTarget:a}}function pr(n,s){for(var a=s+"Capture",u=[];n!==null;){var h=n,p=h.stateNode;h.tag===5&&p!==null&&(h=p,p=qs(n,a),p!=null&&u.unshift(mi(n,p,h)),p=qs(n,s),p!=null&&u.push(mi(n,p,h))),n=n.return}return u}function fs(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5);return n||null}function qu(n,s,a,u,h){for(var p=s._reactName,k=[];a!==null&&a!==u;){var S=a,b=S.alternate,L=S.stateNode;if(b!==null&&b===u)break;S.tag===5&&L!==null&&(S=L,h?(b=qs(a,p),b!=null&&k.unshift(mi(a,b,S))):h||(b=qs(a,p),b!=null&&k.push(mi(a,b,S)))),a=a.return}k.length!==0&&n.push({event:s,listeners:k})}var Bg=/\r\n?/g,zg=/\u0000|\uFFFD/g;function Yu(n){return(typeof n=="string"?n:""+n).replace(Bg,`
|
|
38
|
+
`).replace(zg,"")}function gr(n,s,a){if(s=Yu(s),Yu(n)!==s&&a)throw Error(r(425))}function vr(){}var $a=null,Ta=null;function Ea(n,s){return n==="textarea"||n==="noscript"||typeof s.children=="string"||typeof s.children=="number"||typeof s.dangerouslySetInnerHTML=="object"&&s.dangerouslySetInnerHTML!==null&&s.dangerouslySetInnerHTML.__html!=null}var Ia=typeof setTimeout=="function"?setTimeout:void 0,Fg=typeof clearTimeout=="function"?clearTimeout:void 0,Ju=typeof Promise=="function"?Promise:void 0,Ug=typeof queueMicrotask=="function"?queueMicrotask:typeof Ju<"u"?function(n){return Ju.resolve(null).then(n).catch(Hg)}:Ia;function Hg(n){setTimeout(function(){throw n})}function Ma(n,s){var a=s,u=0;do{var h=a.nextSibling;if(n.removeChild(a),h&&h.nodeType===8)if(a=h.data,a==="/$"){if(u===0){n.removeChild(h),ii(s);return}u--}else a!=="$"&&a!=="$?"&&a!=="$!"||u++;a=h}while(a);ii(s)}function Nn(n){for(;n!=null;n=n.nextSibling){var s=n.nodeType;if(s===1||s===3)break;if(s===8){if(s=n.data,s==="$"||s==="$!"||s==="$?")break;if(s==="/$")return null}}return n}function Xu(n){n=n.previousSibling;for(var s=0;n;){if(n.nodeType===8){var a=n.data;if(a==="$"||a==="$!"||a==="$?"){if(s===0)return n;s--}else a==="/$"&&s++}n=n.previousSibling}return null}var hs=Math.random().toString(36).slice(2),Vt="__reactFiber$"+hs,pi="__reactProps$"+hs,rn="__reactContainer$"+hs,Aa="__reactEvents$"+hs,Wg="__reactListeners$"+hs,Kg="__reactHandles$"+hs;function Un(n){var s=n[Vt];if(s)return s;for(var a=n.parentNode;a;){if(s=a[rn]||a[Vt]){if(a=s.alternate,s.child!==null||a!==null&&a.child!==null)for(n=Xu(n);n!==null;){if(a=n[Vt])return a;n=Xu(n)}return s}n=a,a=n.parentNode}return null}function gi(n){return n=n[Vt]||n[rn],!n||n.tag!==5&&n.tag!==6&&n.tag!==13&&n.tag!==3?null:n}function ms(n){if(n.tag===5||n.tag===6)return n.stateNode;throw Error(r(33))}function kr(n){return n[pi]||null}var La=[],ps=-1;function Sn(n){return{current:n}}function Me(n){0>ps||(n.current=La[ps],La[ps]=null,ps--)}function Te(n,s){ps++,La[ps]=n.current,n.current=s}var bn={},rt=Sn(bn),mt=Sn(!1),Hn=bn;function gs(n,s){var a=n.type.contextTypes;if(!a)return bn;var u=n.stateNode;if(u&&u.__reactInternalMemoizedUnmaskedChildContext===s)return u.__reactInternalMemoizedMaskedChildContext;var h={},p;for(p in a)h[p]=s[p];return u&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=s,n.__reactInternalMemoizedMaskedChildContext=h),h}function pt(n){return n=n.childContextTypes,n!=null}function yr(){Me(mt),Me(rt)}function Zu(n,s,a){if(rt.current!==bn)throw Error(r(168));Te(rt,s),Te(mt,a)}function ed(n,s,a){var u=n.stateNode;if(s=s.childContextTypes,typeof u.getChildContext!="function")return a;u=u.getChildContext();for(var h in u)if(!(h in s))throw Error(r(108,me(n)||"Unknown",h));return H({},a,u)}function xr(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||bn,Hn=rt.current,Te(rt,n),Te(mt,mt.current),!0}function td(n,s,a){var u=n.stateNode;if(!u)throw Error(r(169));a?(n=ed(n,s,Hn),u.__reactInternalMemoizedMergedChildContext=n,Me(mt),Me(rt),Te(rt,n)):Me(mt),Te(mt,a)}var on=null,wr=!1,Ra=!1;function nd(n){on===null?on=[n]:on.push(n)}function Vg(n){wr=!0,nd(n)}function Cn(){if(!Ra&&on!==null){Ra=!0;var n=0,s=Ce;try{var a=on;for(Ce=1;n<a.length;n++){var u=a[n];do u=u(!0);while(u!==null)}on=null,wr=!1}catch(h){throw on!==null&&(on=on.slice(n+1)),iu(na,Cn),h}finally{Ce=s,Ra=!1}}return null}var vs=[],ks=0,jr=null,Nr=0,$t=[],Tt=0,Wn=null,an=1,ln="";function Kn(n,s){vs[ks++]=Nr,vs[ks++]=jr,jr=n,Nr=s}function sd(n,s,a){$t[Tt++]=an,$t[Tt++]=ln,$t[Tt++]=Wn,Wn=n;var u=an;n=ln;var h=32-Pt(u)-1;u&=~(1<<h),a+=1;var p=32-Pt(s)+h;if(30<p){var k=h-h%5;p=(u&(1<<k)-1).toString(32),u>>=k,h-=k,an=1<<32-Pt(s)+h|a<<h|u,ln=p+n}else an=1<<p|a<<h|u,ln=n}function Oa(n){n.return!==null&&(Kn(n,1),sd(n,1,0))}function Pa(n){for(;n===jr;)jr=vs[--ks],vs[ks]=null,Nr=vs[--ks],vs[ks]=null;for(;n===Wn;)Wn=$t[--Tt],$t[Tt]=null,ln=$t[--Tt],$t[Tt]=null,an=$t[--Tt],$t[Tt]=null}var Nt=null,St=null,Le=!1,Dt=null;function id(n,s){var a=At(5,null,null,0);a.elementType="DELETED",a.stateNode=s,a.return=n,s=n.deletions,s===null?(n.deletions=[a],n.flags|=16):s.push(a)}function rd(n,s){switch(n.tag){case 5:var a=n.type;return s=s.nodeType!==1||a.toLowerCase()!==s.nodeName.toLowerCase()?null:s,s!==null?(n.stateNode=s,Nt=n,St=Nn(s.firstChild),!0):!1;case 6:return s=n.pendingProps===""||s.nodeType!==3?null:s,s!==null?(n.stateNode=s,Nt=n,St=null,!0):!1;case 13:return s=s.nodeType!==8?null:s,s!==null?(a=Wn!==null?{id:an,overflow:ln}:null,n.memoizedState={dehydrated:s,treeContext:a,retryLane:1073741824},a=At(18,null,null,0),a.stateNode=s,a.return=n,n.child=a,Nt=n,St=null,!0):!1;default:return!1}}function _a(n){return(n.mode&1)!==0&&(n.flags&128)===0}function Da(n){if(Le){var s=St;if(s){var a=s;if(!rd(n,s)){if(_a(n))throw Error(r(418));s=Nn(a.nextSibling);var u=Nt;s&&rd(n,s)?id(u,a):(n.flags=n.flags&-4097|2,Le=!1,Nt=n)}}else{if(_a(n))throw Error(r(418));n.flags=n.flags&-4097|2,Le=!1,Nt=n}}}function od(n){for(n=n.return;n!==null&&n.tag!==5&&n.tag!==3&&n.tag!==13;)n=n.return;Nt=n}function Sr(n){if(n!==Nt)return!1;if(!Le)return od(n),Le=!0,!1;var s;if((s=n.tag!==3)&&!(s=n.tag!==5)&&(s=n.type,s=s!=="head"&&s!=="body"&&!Ea(n.type,n.memoizedProps)),s&&(s=St)){if(_a(n))throw ad(),Error(r(418));for(;s;)id(n,s),s=Nn(s.nextSibling)}if(od(n),n.tag===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(r(317));e:{for(n=n.nextSibling,s=0;n;){if(n.nodeType===8){var a=n.data;if(a==="/$"){if(s===0){St=Nn(n.nextSibling);break e}s--}else a!=="$"&&a!=="$!"&&a!=="$?"||s++}n=n.nextSibling}St=null}}else St=Nt?Nn(n.stateNode.nextSibling):null;return!0}function ad(){for(var n=St;n;)n=Nn(n.nextSibling)}function ys(){St=Nt=null,Le=!1}function Ba(n){Dt===null?Dt=[n]:Dt.push(n)}var Gg=X.ReactCurrentBatchConfig;function vi(n,s,a){if(n=a.ref,n!==null&&typeof n!="function"&&typeof n!="object"){if(a._owner){if(a=a._owner,a){if(a.tag!==1)throw Error(r(309));var u=a.stateNode}if(!u)throw Error(r(147,n));var h=u,p=""+n;return s!==null&&s.ref!==null&&typeof s.ref=="function"&&s.ref._stringRef===p?s.ref:(s=function(k){var S=h.refs;k===null?delete S[p]:S[p]=k},s._stringRef=p,s)}if(typeof n!="string")throw Error(r(284));if(!a._owner)throw Error(r(290,n))}return n}function br(n,s){throw n=Object.prototype.toString.call(s),Error(r(31,n==="[object Object]"?"object with keys {"+Object.keys(s).join(", ")+"}":n))}function ld(n){var s=n._init;return s(n._payload)}function cd(n){function s(I,C){if(n){var A=I.deletions;A===null?(I.deletions=[C],I.flags|=16):A.push(C)}}function a(I,C){if(!n)return null;for(;C!==null;)s(I,C),C=C.sibling;return null}function u(I,C){for(I=new Map;C!==null;)C.key!==null?I.set(C.key,C):I.set(C.index,C),C=C.sibling;return I}function h(I,C){return I=Rn(I,C),I.index=0,I.sibling=null,I}function p(I,C,A){return I.index=A,n?(A=I.alternate,A!==null?(A=A.index,A<C?(I.flags|=2,C):A):(I.flags|=2,C)):(I.flags|=1048576,C)}function k(I){return n&&I.alternate===null&&(I.flags|=2),I}function S(I,C,A,G){return C===null||C.tag!==6?(C=Il(A,I.mode,G),C.return=I,C):(C=h(C,A),C.return=I,C)}function b(I,C,A,G){var oe=A.type;return oe===F?z(I,C,A.props.children,G,A.key):C!==null&&(C.elementType===oe||typeof oe=="object"&&oe!==null&&oe.$$typeof===ae&&ld(oe)===C.type)?(G=h(C,A.props),G.ref=vi(I,C,A),G.return=I,G):(G=qr(A.type,A.key,A.props,null,I.mode,G),G.ref=vi(I,C,A),G.return=I,G)}function L(I,C,A,G){return C===null||C.tag!==4||C.stateNode.containerInfo!==A.containerInfo||C.stateNode.implementation!==A.implementation?(C=Ml(A,I.mode,G),C.return=I,C):(C=h(C,A.children||[]),C.return=I,C)}function z(I,C,A,G,oe){return C===null||C.tag!==7?(C=Zn(A,I.mode,G,oe),C.return=I,C):(C=h(C,A),C.return=I,C)}function W(I,C,A){if(typeof C=="string"&&C!==""||typeof C=="number")return C=Il(""+C,I.mode,A),C.return=I,C;if(typeof C=="object"&&C!==null){switch(C.$$typeof){case se:return A=qr(C.type,C.key,C.props,null,I.mode,A),A.ref=vi(I,null,C),A.return=I,A;case Q:return C=Ml(C,I.mode,A),C.return=I,C;case ae:var G=C._init;return W(I,G(C._payload),A)}if(Vs(C)||D(C))return C=Zn(C,I.mode,A,null),C.return=I,C;br(I,C)}return null}function B(I,C,A,G){var oe=C!==null?C.key:null;if(typeof A=="string"&&A!==""||typeof A=="number")return oe!==null?null:S(I,C,""+A,G);if(typeof A=="object"&&A!==null){switch(A.$$typeof){case se:return A.key===oe?b(I,C,A,G):null;case Q:return A.key===oe?L(I,C,A,G):null;case ae:return oe=A._init,B(I,C,oe(A._payload),G)}if(Vs(A)||D(A))return oe!==null?null:z(I,C,A,G,null);br(I,A)}return null}function J(I,C,A,G,oe){if(typeof G=="string"&&G!==""||typeof G=="number")return I=I.get(A)||null,S(C,I,""+G,oe);if(typeof G=="object"&&G!==null){switch(G.$$typeof){case se:return I=I.get(G.key===null?A:G.key)||null,b(C,I,G,oe);case Q:return I=I.get(G.key===null?A:G.key)||null,L(C,I,G,oe);case ae:var le=G._init;return J(I,C,A,le(G._payload),oe)}if(Vs(G)||D(G))return I=I.get(A)||null,z(C,I,G,oe,null);br(C,G)}return null}function ne(I,C,A,G){for(var oe=null,le=null,ce=C,fe=C=0,et=null;ce!==null&&fe<A.length;fe++){ce.index>fe?(et=ce,ce=null):et=ce.sibling;var Ne=B(I,ce,A[fe],G);if(Ne===null){ce===null&&(ce=et);break}n&&ce&&Ne.alternate===null&&s(I,ce),C=p(Ne,C,fe),le===null?oe=Ne:le.sibling=Ne,le=Ne,ce=et}if(fe===A.length)return a(I,ce),Le&&Kn(I,fe),oe;if(ce===null){for(;fe<A.length;fe++)ce=W(I,A[fe],G),ce!==null&&(C=p(ce,C,fe),le===null?oe=ce:le.sibling=ce,le=ce);return Le&&Kn(I,fe),oe}for(ce=u(I,ce);fe<A.length;fe++)et=J(ce,I,fe,A[fe],G),et!==null&&(n&&et.alternate!==null&&ce.delete(et.key===null?fe:et.key),C=p(et,C,fe),le===null?oe=et:le.sibling=et,le=et);return n&&ce.forEach(function(On){return s(I,On)}),Le&&Kn(I,fe),oe}function re(I,C,A,G){var oe=D(A);if(typeof oe!="function")throw Error(r(150));if(A=oe.call(A),A==null)throw Error(r(151));for(var le=oe=null,ce=C,fe=C=0,et=null,Ne=A.next();ce!==null&&!Ne.done;fe++,Ne=A.next()){ce.index>fe?(et=ce,ce=null):et=ce.sibling;var On=B(I,ce,Ne.value,G);if(On===null){ce===null&&(ce=et);break}n&&ce&&On.alternate===null&&s(I,ce),C=p(On,C,fe),le===null?oe=On:le.sibling=On,le=On,ce=et}if(Ne.done)return a(I,ce),Le&&Kn(I,fe),oe;if(ce===null){for(;!Ne.done;fe++,Ne=A.next())Ne=W(I,Ne.value,G),Ne!==null&&(C=p(Ne,C,fe),le===null?oe=Ne:le.sibling=Ne,le=Ne);return Le&&Kn(I,fe),oe}for(ce=u(I,ce);!Ne.done;fe++,Ne=A.next())Ne=J(ce,I,fe,Ne.value,G),Ne!==null&&(n&&Ne.alternate!==null&&ce.delete(Ne.key===null?fe:Ne.key),C=p(Ne,C,fe),le===null?oe=Ne:le.sibling=Ne,le=Ne);return n&&ce.forEach(function(Cv){return s(I,Cv)}),Le&&Kn(I,fe),oe}function Fe(I,C,A,G){if(typeof A=="object"&&A!==null&&A.type===F&&A.key===null&&(A=A.props.children),typeof A=="object"&&A!==null){switch(A.$$typeof){case se:e:{for(var oe=A.key,le=C;le!==null;){if(le.key===oe){if(oe=A.type,oe===F){if(le.tag===7){a(I,le.sibling),C=h(le,A.props.children),C.return=I,I=C;break e}}else if(le.elementType===oe||typeof oe=="object"&&oe!==null&&oe.$$typeof===ae&&ld(oe)===le.type){a(I,le.sibling),C=h(le,A.props),C.ref=vi(I,le,A),C.return=I,I=C;break e}a(I,le);break}else s(I,le);le=le.sibling}A.type===F?(C=Zn(A.props.children,I.mode,G,A.key),C.return=I,I=C):(G=qr(A.type,A.key,A.props,null,I.mode,G),G.ref=vi(I,C,A),G.return=I,I=G)}return k(I);case Q:e:{for(le=A.key;C!==null;){if(C.key===le)if(C.tag===4&&C.stateNode.containerInfo===A.containerInfo&&C.stateNode.implementation===A.implementation){a(I,C.sibling),C=h(C,A.children||[]),C.return=I,I=C;break e}else{a(I,C);break}else s(I,C);C=C.sibling}C=Ml(A,I.mode,G),C.return=I,I=C}return k(I);case ae:return le=A._init,Fe(I,C,le(A._payload),G)}if(Vs(A))return ne(I,C,A,G);if(D(A))return re(I,C,A,G);br(I,A)}return typeof A=="string"&&A!==""||typeof A=="number"?(A=""+A,C!==null&&C.tag===6?(a(I,C.sibling),C=h(C,A),C.return=I,I=C):(a(I,C),C=Il(A,I.mode,G),C.return=I,I=C),k(I)):a(I,C)}return Fe}var xs=cd(!0),ud=cd(!1),Cr=Sn(null),$r=null,ws=null,za=null;function Fa(){za=ws=$r=null}function Ua(n){var s=Cr.current;Me(Cr),n._currentValue=s}function Ha(n,s,a){for(;n!==null;){var u=n.alternate;if((n.childLanes&s)!==s?(n.childLanes|=s,u!==null&&(u.childLanes|=s)):u!==null&&(u.childLanes&s)!==s&&(u.childLanes|=s),n===a)break;n=n.return}}function js(n,s){$r=n,za=ws=null,n=n.dependencies,n!==null&&n.firstContext!==null&&((n.lanes&s)!==0&&(gt=!0),n.firstContext=null)}function Et(n){var s=n._currentValue;if(za!==n)if(n={context:n,memoizedValue:s,next:null},ws===null){if($r===null)throw Error(r(308));ws=n,$r.dependencies={lanes:0,firstContext:n}}else ws=ws.next=n;return s}var Vn=null;function Wa(n){Vn===null?Vn=[n]:Vn.push(n)}function dd(n,s,a,u){var h=s.interleaved;return h===null?(a.next=a,Wa(s)):(a.next=h.next,h.next=a),s.interleaved=a,cn(n,u)}function cn(n,s){n.lanes|=s;var a=n.alternate;for(a!==null&&(a.lanes|=s),a=n,n=n.return;n!==null;)n.childLanes|=s,a=n.alternate,a!==null&&(a.childLanes|=s),a=n,n=n.return;return a.tag===3?a.stateNode:null}var $n=!1;function Ka(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function fd(n,s){n=n.updateQueue,s.updateQueue===n&&(s.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,effects:n.effects})}function un(n,s){return{eventTime:n,lane:s,tag:0,payload:null,callback:null,next:null}}function Tn(n,s,a){var u=n.updateQueue;if(u===null)return null;if(u=u.shared,(je&2)!==0){var h=u.pending;return h===null?s.next=s:(s.next=h.next,h.next=s),u.pending=s,cn(n,a)}return h=u.interleaved,h===null?(s.next=s,Wa(u)):(s.next=h.next,h.next=s),u.interleaved=s,cn(n,a)}function Tr(n,s,a){if(s=s.updateQueue,s!==null&&(s=s.shared,(a&4194240)!==0)){var u=s.lanes;u&=n.pendingLanes,a|=u,s.lanes=a,ra(n,a)}}function hd(n,s){var a=n.updateQueue,u=n.alternate;if(u!==null&&(u=u.updateQueue,a===u)){var h=null,p=null;if(a=a.firstBaseUpdate,a!==null){do{var k={eventTime:a.eventTime,lane:a.lane,tag:a.tag,payload:a.payload,callback:a.callback,next:null};p===null?h=p=k:p=p.next=k,a=a.next}while(a!==null);p===null?h=p=s:p=p.next=s}else h=p=s;a={baseState:u.baseState,firstBaseUpdate:h,lastBaseUpdate:p,shared:u.shared,effects:u.effects},n.updateQueue=a;return}n=a.lastBaseUpdate,n===null?a.firstBaseUpdate=s:n.next=s,a.lastBaseUpdate=s}function Er(n,s,a,u){var h=n.updateQueue;$n=!1;var p=h.firstBaseUpdate,k=h.lastBaseUpdate,S=h.shared.pending;if(S!==null){h.shared.pending=null;var b=S,L=b.next;b.next=null,k===null?p=L:k.next=L,k=b;var z=n.alternate;z!==null&&(z=z.updateQueue,S=z.lastBaseUpdate,S!==k&&(S===null?z.firstBaseUpdate=L:S.next=L,z.lastBaseUpdate=b))}if(p!==null){var W=h.baseState;k=0,z=L=b=null,S=p;do{var B=S.lane,J=S.eventTime;if((u&B)===B){z!==null&&(z=z.next={eventTime:J,lane:0,tag:S.tag,payload:S.payload,callback:S.callback,next:null});e:{var ne=n,re=S;switch(B=s,J=a,re.tag){case 1:if(ne=re.payload,typeof ne=="function"){W=ne.call(J,W,B);break e}W=ne;break e;case 3:ne.flags=ne.flags&-65537|128;case 0:if(ne=re.payload,B=typeof ne=="function"?ne.call(J,W,B):ne,B==null)break e;W=H({},W,B);break e;case 2:$n=!0}}S.callback!==null&&S.lane!==0&&(n.flags|=64,B=h.effects,B===null?h.effects=[S]:B.push(S))}else J={eventTime:J,lane:B,tag:S.tag,payload:S.payload,callback:S.callback,next:null},z===null?(L=z=J,b=W):z=z.next=J,k|=B;if(S=S.next,S===null){if(S=h.shared.pending,S===null)break;B=S,S=B.next,B.next=null,h.lastBaseUpdate=B,h.shared.pending=null}}while(!0);if(z===null&&(b=W),h.baseState=b,h.firstBaseUpdate=L,h.lastBaseUpdate=z,s=h.shared.interleaved,s!==null){h=s;do k|=h.lane,h=h.next;while(h!==s)}else p===null&&(h.shared.lanes=0);qn|=k,n.lanes=k,n.memoizedState=W}}function md(n,s,a){if(n=s.effects,s.effects=null,n!==null)for(s=0;s<n.length;s++){var u=n[s],h=u.callback;if(h!==null){if(u.callback=null,u=a,typeof h!="function")throw Error(r(191,h));h.call(u)}}}var ki={},Gt=Sn(ki),yi=Sn(ki),xi=Sn(ki);function Gn(n){if(n===ki)throw Error(r(174));return n}function Va(n,s){switch(Te(xi,s),Te(yi,n),Te(Gt,ki),n=s.nodeType,n){case 9:case 11:s=(s=s.documentElement)?s.namespaceURI:Go(null,"");break;default:n=n===8?s.parentNode:s,s=n.namespaceURI||null,n=n.tagName,s=Go(s,n)}Me(Gt),Te(Gt,s)}function Ns(){Me(Gt),Me(yi),Me(xi)}function pd(n){Gn(xi.current);var s=Gn(Gt.current),a=Go(s,n.type);s!==a&&(Te(yi,n),Te(Gt,a))}function Ga(n){yi.current===n&&(Me(Gt),Me(yi))}var Oe=Sn(0);function Ir(n){for(var s=n;s!==null;){if(s.tag===13){var a=s.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||a.data==="$?"||a.data==="$!"))return s}else if(s.tag===19&&s.memoizedProps.revealOrder!==void 0){if((s.flags&128)!==0)return s}else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===n)break;for(;s.sibling===null;){if(s.return===null||s.return===n)return null;s=s.return}s.sibling.return=s.return,s=s.sibling}return null}var Qa=[];function qa(){for(var n=0;n<Qa.length;n++)Qa[n]._workInProgressVersionPrimary=null;Qa.length=0}var Mr=X.ReactCurrentDispatcher,Ya=X.ReactCurrentBatchConfig,Qn=0,Pe=null,Qe=null,Xe=null,Ar=!1,wi=!1,ji=0,Qg=0;function ot(){throw Error(r(321))}function Ja(n,s){if(s===null)return!1;for(var a=0;a<s.length&&a<n.length;a++)if(!_t(n[a],s[a]))return!1;return!0}function Xa(n,s,a,u,h,p){if(Qn=p,Pe=s,s.memoizedState=null,s.updateQueue=null,s.lanes=0,Mr.current=n===null||n.memoizedState===null?Xg:Zg,n=a(u,h),wi){p=0;do{if(wi=!1,ji=0,25<=p)throw Error(r(301));p+=1,Xe=Qe=null,s.updateQueue=null,Mr.current=ev,n=a(u,h)}while(wi)}if(Mr.current=Or,s=Qe!==null&&Qe.next!==null,Qn=0,Xe=Qe=Pe=null,Ar=!1,s)throw Error(r(300));return n}function Za(){var n=ji!==0;return ji=0,n}function Qt(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Xe===null?Pe.memoizedState=Xe=n:Xe=Xe.next=n,Xe}function It(){if(Qe===null){var n=Pe.alternate;n=n!==null?n.memoizedState:null}else n=Qe.next;var s=Xe===null?Pe.memoizedState:Xe.next;if(s!==null)Xe=s,Qe=n;else{if(n===null)throw Error(r(310));Qe=n,n={memoizedState:Qe.memoizedState,baseState:Qe.baseState,baseQueue:Qe.baseQueue,queue:Qe.queue,next:null},Xe===null?Pe.memoizedState=Xe=n:Xe=Xe.next=n}return Xe}function Ni(n,s){return typeof s=="function"?s(n):s}function el(n){var s=It(),a=s.queue;if(a===null)throw Error(r(311));a.lastRenderedReducer=n;var u=Qe,h=u.baseQueue,p=a.pending;if(p!==null){if(h!==null){var k=h.next;h.next=p.next,p.next=k}u.baseQueue=h=p,a.pending=null}if(h!==null){p=h.next,u=u.baseState;var S=k=null,b=null,L=p;do{var z=L.lane;if((Qn&z)===z)b!==null&&(b=b.next={lane:0,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null}),u=L.hasEagerState?L.eagerState:n(u,L.action);else{var W={lane:z,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null};b===null?(S=b=W,k=u):b=b.next=W,Pe.lanes|=z,qn|=z}L=L.next}while(L!==null&&L!==p);b===null?k=u:b.next=S,_t(u,s.memoizedState)||(gt=!0),s.memoizedState=u,s.baseState=k,s.baseQueue=b,a.lastRenderedState=u}if(n=a.interleaved,n!==null){h=n;do p=h.lane,Pe.lanes|=p,qn|=p,h=h.next;while(h!==n)}else h===null&&(a.lanes=0);return[s.memoizedState,a.dispatch]}function tl(n){var s=It(),a=s.queue;if(a===null)throw Error(r(311));a.lastRenderedReducer=n;var u=a.dispatch,h=a.pending,p=s.memoizedState;if(h!==null){a.pending=null;var k=h=h.next;do p=n(p,k.action),k=k.next;while(k!==h);_t(p,s.memoizedState)||(gt=!0),s.memoizedState=p,s.baseQueue===null&&(s.baseState=p),a.lastRenderedState=p}return[p,u]}function gd(){}function vd(n,s){var a=Pe,u=It(),h=s(),p=!_t(u.memoizedState,h);if(p&&(u.memoizedState=h,gt=!0),u=u.queue,nl(xd.bind(null,a,u,n),[n]),u.getSnapshot!==s||p||Xe!==null&&Xe.memoizedState.tag&1){if(a.flags|=2048,Si(9,yd.bind(null,a,u,h,s),void 0,null),Ze===null)throw Error(r(349));(Qn&30)!==0||kd(a,s,h)}return h}function kd(n,s,a){n.flags|=16384,n={getSnapshot:s,value:a},s=Pe.updateQueue,s===null?(s={lastEffect:null,stores:null},Pe.updateQueue=s,s.stores=[n]):(a=s.stores,a===null?s.stores=[n]:a.push(n))}function yd(n,s,a,u){s.value=a,s.getSnapshot=u,wd(s)&&jd(n)}function xd(n,s,a){return a(function(){wd(s)&&jd(n)})}function wd(n){var s=n.getSnapshot;n=n.value;try{var a=s();return!_t(n,a)}catch{return!0}}function jd(n){var s=cn(n,1);s!==null&&Ut(s,n,1,-1)}function Nd(n){var s=Qt();return typeof n=="function"&&(n=n()),s.memoizedState=s.baseState=n,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ni,lastRenderedState:n},s.queue=n,n=n.dispatch=Jg.bind(null,Pe,n),[s.memoizedState,n]}function Si(n,s,a,u){return n={tag:n,create:s,destroy:a,deps:u,next:null},s=Pe.updateQueue,s===null?(s={lastEffect:null,stores:null},Pe.updateQueue=s,s.lastEffect=n.next=n):(a=s.lastEffect,a===null?s.lastEffect=n.next=n:(u=a.next,a.next=n,n.next=u,s.lastEffect=n)),n}function Sd(){return It().memoizedState}function Lr(n,s,a,u){var h=Qt();Pe.flags|=n,h.memoizedState=Si(1|s,a,void 0,u===void 0?null:u)}function Rr(n,s,a,u){var h=It();u=u===void 0?null:u;var p=void 0;if(Qe!==null){var k=Qe.memoizedState;if(p=k.destroy,u!==null&&Ja(u,k.deps)){h.memoizedState=Si(s,a,p,u);return}}Pe.flags|=n,h.memoizedState=Si(1|s,a,p,u)}function bd(n,s){return Lr(8390656,8,n,s)}function nl(n,s){return Rr(2048,8,n,s)}function Cd(n,s){return Rr(4,2,n,s)}function $d(n,s){return Rr(4,4,n,s)}function Td(n,s){if(typeof s=="function")return n=n(),s(n),function(){s(null)};if(s!=null)return n=n(),s.current=n,function(){s.current=null}}function Ed(n,s,a){return a=a!=null?a.concat([n]):null,Rr(4,4,Td.bind(null,s,n),a)}function sl(){}function Id(n,s){var a=It();s=s===void 0?null:s;var u=a.memoizedState;return u!==null&&s!==null&&Ja(s,u[1])?u[0]:(a.memoizedState=[n,s],n)}function Md(n,s){var a=It();s=s===void 0?null:s;var u=a.memoizedState;return u!==null&&s!==null&&Ja(s,u[1])?u[0]:(n=n(),a.memoizedState=[n,s],n)}function Ad(n,s,a){return(Qn&21)===0?(n.baseState&&(n.baseState=!1,gt=!0),n.memoizedState=a):(_t(a,s)||(a=lu(),Pe.lanes|=a,qn|=a,n.baseState=!0),s)}function qg(n,s){var a=Ce;Ce=a!==0&&4>a?a:4,n(!0);var u=Ya.transition;Ya.transition={};try{n(!1),s()}finally{Ce=a,Ya.transition=u}}function Ld(){return It().memoizedState}function Yg(n,s,a){var u=An(n);if(a={lane:u,action:a,hasEagerState:!1,eagerState:null,next:null},Rd(n))Od(s,a);else if(a=dd(n,s,a,u),a!==null){var h=ft();Ut(a,n,u,h),Pd(a,s,u)}}function Jg(n,s,a){var u=An(n),h={lane:u,action:a,hasEagerState:!1,eagerState:null,next:null};if(Rd(n))Od(s,h);else{var p=n.alternate;if(n.lanes===0&&(p===null||p.lanes===0)&&(p=s.lastRenderedReducer,p!==null))try{var k=s.lastRenderedState,S=p(k,a);if(h.hasEagerState=!0,h.eagerState=S,_t(S,k)){var b=s.interleaved;b===null?(h.next=h,Wa(s)):(h.next=b.next,b.next=h),s.interleaved=h;return}}catch{}finally{}a=dd(n,s,h,u),a!==null&&(h=ft(),Ut(a,n,u,h),Pd(a,s,u))}}function Rd(n){var s=n.alternate;return n===Pe||s!==null&&s===Pe}function Od(n,s){wi=Ar=!0;var a=n.pending;a===null?s.next=s:(s.next=a.next,a.next=s),n.pending=s}function Pd(n,s,a){if((a&4194240)!==0){var u=s.lanes;u&=n.pendingLanes,a|=u,s.lanes=a,ra(n,a)}}var Or={readContext:Et,useCallback:ot,useContext:ot,useEffect:ot,useImperativeHandle:ot,useInsertionEffect:ot,useLayoutEffect:ot,useMemo:ot,useReducer:ot,useRef:ot,useState:ot,useDebugValue:ot,useDeferredValue:ot,useTransition:ot,useMutableSource:ot,useSyncExternalStore:ot,useId:ot,unstable_isNewReconciler:!1},Xg={readContext:Et,useCallback:function(n,s){return Qt().memoizedState=[n,s===void 0?null:s],n},useContext:Et,useEffect:bd,useImperativeHandle:function(n,s,a){return a=a!=null?a.concat([n]):null,Lr(4194308,4,Td.bind(null,s,n),a)},useLayoutEffect:function(n,s){return Lr(4194308,4,n,s)},useInsertionEffect:function(n,s){return Lr(4,2,n,s)},useMemo:function(n,s){var a=Qt();return s=s===void 0?null:s,n=n(),a.memoizedState=[n,s],n},useReducer:function(n,s,a){var u=Qt();return s=a!==void 0?a(s):s,u.memoizedState=u.baseState=s,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:s},u.queue=n,n=n.dispatch=Yg.bind(null,Pe,n),[u.memoizedState,n]},useRef:function(n){var s=Qt();return n={current:n},s.memoizedState=n},useState:Nd,useDebugValue:sl,useDeferredValue:function(n){return Qt().memoizedState=n},useTransition:function(){var n=Nd(!1),s=n[0];return n=qg.bind(null,n[1]),Qt().memoizedState=n,[s,n]},useMutableSource:function(){},useSyncExternalStore:function(n,s,a){var u=Pe,h=Qt();if(Le){if(a===void 0)throw Error(r(407));a=a()}else{if(a=s(),Ze===null)throw Error(r(349));(Qn&30)!==0||kd(u,s,a)}h.memoizedState=a;var p={value:a,getSnapshot:s};return h.queue=p,bd(xd.bind(null,u,p,n),[n]),u.flags|=2048,Si(9,yd.bind(null,u,p,a,s),void 0,null),a},useId:function(){var n=Qt(),s=Ze.identifierPrefix;if(Le){var a=ln,u=an;a=(u&~(1<<32-Pt(u)-1)).toString(32)+a,s=":"+s+"R"+a,a=ji++,0<a&&(s+="H"+a.toString(32)),s+=":"}else a=Qg++,s=":"+s+"r"+a.toString(32)+":";return n.memoizedState=s},unstable_isNewReconciler:!1},Zg={readContext:Et,useCallback:Id,useContext:Et,useEffect:nl,useImperativeHandle:Ed,useInsertionEffect:Cd,useLayoutEffect:$d,useMemo:Md,useReducer:el,useRef:Sd,useState:function(){return el(Ni)},useDebugValue:sl,useDeferredValue:function(n){var s=It();return Ad(s,Qe.memoizedState,n)},useTransition:function(){var n=el(Ni)[0],s=It().memoizedState;return[n,s]},useMutableSource:gd,useSyncExternalStore:vd,useId:Ld,unstable_isNewReconciler:!1},ev={readContext:Et,useCallback:Id,useContext:Et,useEffect:nl,useImperativeHandle:Ed,useInsertionEffect:Cd,useLayoutEffect:$d,useMemo:Md,useReducer:tl,useRef:Sd,useState:function(){return tl(Ni)},useDebugValue:sl,useDeferredValue:function(n){var s=It();return Qe===null?s.memoizedState=n:Ad(s,Qe.memoizedState,n)},useTransition:function(){var n=tl(Ni)[0],s=It().memoizedState;return[n,s]},useMutableSource:gd,useSyncExternalStore:vd,useId:Ld,unstable_isNewReconciler:!1};function Bt(n,s){if(n&&n.defaultProps){s=H({},s),n=n.defaultProps;for(var a in n)s[a]===void 0&&(s[a]=n[a]);return s}return s}function il(n,s,a,u){s=n.memoizedState,a=a(u,s),a=a==null?s:H({},s,a),n.memoizedState=a,n.lanes===0&&(n.updateQueue.baseState=a)}var Pr={isMounted:function(n){return(n=n._reactInternals)?Fn(n)===n:!1},enqueueSetState:function(n,s,a){n=n._reactInternals;var u=ft(),h=An(n),p=un(u,h);p.payload=s,a!=null&&(p.callback=a),s=Tn(n,p,h),s!==null&&(Ut(s,n,h,u),Tr(s,n,h))},enqueueReplaceState:function(n,s,a){n=n._reactInternals;var u=ft(),h=An(n),p=un(u,h);p.tag=1,p.payload=s,a!=null&&(p.callback=a),s=Tn(n,p,h),s!==null&&(Ut(s,n,h,u),Tr(s,n,h))},enqueueForceUpdate:function(n,s){n=n._reactInternals;var a=ft(),u=An(n),h=un(a,u);h.tag=2,s!=null&&(h.callback=s),s=Tn(n,h,u),s!==null&&(Ut(s,n,u,a),Tr(s,n,u))}};function _d(n,s,a,u,h,p,k){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(u,p,k):s.prototype&&s.prototype.isPureReactComponent?!ui(a,u)||!ui(h,p):!0}function Dd(n,s,a){var u=!1,h=bn,p=s.contextType;return typeof p=="object"&&p!==null?p=Et(p):(h=pt(s)?Hn:rt.current,u=s.contextTypes,p=(u=u!=null)?gs(n,h):bn),s=new s(a,p),n.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,s.updater=Pr,n.stateNode=s,s._reactInternals=n,u&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=h,n.__reactInternalMemoizedMaskedChildContext=p),s}function Bd(n,s,a,u){n=s.state,typeof s.componentWillReceiveProps=="function"&&s.componentWillReceiveProps(a,u),typeof s.UNSAFE_componentWillReceiveProps=="function"&&s.UNSAFE_componentWillReceiveProps(a,u),s.state!==n&&Pr.enqueueReplaceState(s,s.state,null)}function rl(n,s,a,u){var h=n.stateNode;h.props=a,h.state=n.memoizedState,h.refs={},Ka(n);var p=s.contextType;typeof p=="object"&&p!==null?h.context=Et(p):(p=pt(s)?Hn:rt.current,h.context=gs(n,p)),h.state=n.memoizedState,p=s.getDerivedStateFromProps,typeof p=="function"&&(il(n,s,p,a),h.state=n.memoizedState),typeof s.getDerivedStateFromProps=="function"||typeof h.getSnapshotBeforeUpdate=="function"||typeof h.UNSAFE_componentWillMount!="function"&&typeof h.componentWillMount!="function"||(s=h.state,typeof h.componentWillMount=="function"&&h.componentWillMount(),typeof h.UNSAFE_componentWillMount=="function"&&h.UNSAFE_componentWillMount(),s!==h.state&&Pr.enqueueReplaceState(h,h.state,null),Er(n,a,h,u),h.state=n.memoizedState),typeof h.componentDidMount=="function"&&(n.flags|=4194308)}function Ss(n,s){try{var a="",u=s;do a+=de(u),u=u.return;while(u);var h=a}catch(p){h=`
|
|
39
39
|
Error generating stack: `+p.message+`
|
|
40
|
-
`+p.stack}return{value:n,source:s,stack:h,digest:null}}function ol(n,s,a){return{value:n,source:null,stack:a??null,digest:s??null}}function al(n,s){try{console.error(s.value)}catch(a){setTimeout(function(){throw a})}}var tv=typeof WeakMap=="function"?WeakMap:Map;function zd(n,s,a){a=un(-1,a),a.tag=3,a.payload={element:null};var u=s.value;return a.callback=function(){Hr||(Hr=!0,jl=u),al(n,s)},a}function Fd(n,s,a){a=un(-1,a),a.tag=3;var u=n.type.getDerivedStateFromError;if(typeof u=="function"){var h=s.value;a.payload=function(){return u(h)},a.callback=function(){al(n,s)}}var p=n.stateNode;return p!==null&&typeof p.componentDidCatch=="function"&&(a.callback=function(){al(n,s),typeof u!="function"&&(In===null?In=new Set([this]):In.add(this));var k=s.stack;this.componentDidCatch(s.value,{componentStack:k!==null?k:""})}),a}function Ud(n,s,a){var u=n.pingCache;if(u===null){u=n.pingCache=new tv;var h=new Set;u.set(s,h)}else h=u.get(s),h===void 0&&(h=new Set,u.set(s,h));h.has(a)||(h.add(a),n=pv.bind(null,n,s,a),s.then(n,n))}function Hd(n){do{var s;if((s=n.tag===13)&&(s=n.memoizedState,s=s!==null?s.dehydrated!==null:!0),s)return n;n=n.return}while(n!==null);return null}function Wd(n,s,a,u,h){return(n.mode&1)===0?(n===s?n.flags|=65536:(n.flags|=128,a.flags|=131072,a.flags&=-52805,a.tag===1&&(a.alternate===null?a.tag=17:(s=un(-1,1),s.tag=2,Tn(a,s,1))),a.lanes|=1),n):(n.flags|=65536,n.lanes=h,n)}var nv=X.ReactCurrentOwner,gt=!1;function dt(n,s,a,u){s.child=n===null?ud(s,null,a,u):xs(s,n.child,a,u)}function Kd(n,s,a,u,h){a=a.render;var p=s.ref;return js(s,h),u=Xa(n,s,a,u,p,h),a=Za(),n!==null&&!gt?(s.updateQueue=n.updateQueue,s.flags&=-2053,n.lanes&=~h,dn(n,s,h)):(Le&&a&&Oa(s),s.flags|=1,dt(n,s,u,h),s.child)}function Vd(n,s,a,u,h){if(n===null){var p=a.type;return typeof p=="function"&&!El(p)&&p.defaultProps===void 0&&a.compare===null&&a.defaultProps===void 0?(s.tag=15,s.type=p,Gd(n,s,p,u,h)):(n=qr(a.type,null,u,s,s.mode,h),n.ref=s.ref,n.return=s,s.child=n)}if(p=n.child,(n.lanes&h)===0){var k=p.memoizedProps;if(a=a.compare,a=a!==null?a:ui,a(k,u)&&n.ref===s.ref)return dn(n,s,h)}return s.flags|=1,n=Rn(p,u),n.ref=s.ref,n.return=s,s.child=n}function Gd(n,s,a,u,h){if(n!==null){var p=n.memoizedProps;if(ui(p,u)&&n.ref===s.ref)if(gt=!1,s.pendingProps=u=p,(n.lanes&h)!==0)(n.flags&131072)!==0&&(gt=!0);else return s.lanes=n.lanes,dn(n,s,h)}return ll(n,s,a,u,h)}function Qd(n,s,a){var u=s.pendingProps,h=u.children,p=n!==null?n.memoizedState:null;if(u.mode==="hidden")if((s.mode&1)===0)s.memoizedState={baseLanes:0,cachePool:null,transitions:null},Te(Cs,bt),bt|=a;else{if((a&1073741824)===0)return n=p!==null?p.baseLanes|a:a,s.lanes=s.childLanes=1073741824,s.memoizedState={baseLanes:n,cachePool:null,transitions:null},s.updateQueue=null,Te(Cs,bt),bt|=n,null;s.memoizedState={baseLanes:0,cachePool:null,transitions:null},u=p!==null?p.baseLanes:a,Te(Cs,bt),bt|=u}else p!==null?(u=p.baseLanes|a,s.memoizedState=null):u=a,Te(Cs,bt),bt|=u;return dt(n,s,h,a),s.child}function qd(n,s){var a=s.ref;(n===null&&a!==null||n!==null&&n.ref!==a)&&(s.flags|=512,s.flags|=2097152)}function ll(n,s,a,u,h){var p=pt(a)?Hn:rt.current;return p=gs(s,p),js(s,h),a=Xa(n,s,a,u,p,h),u=Za(),n!==null&&!gt?(s.updateQueue=n.updateQueue,s.flags&=-2053,n.lanes&=~h,dn(n,s,h)):(Le&&u&&Oa(s),s.flags|=1,dt(n,s,a,h),s.child)}function Yd(n,s,a,u,h){if(pt(a)){var p=!0;xr(s)}else p=!1;if(js(s,h),s.stateNode===null)Dr(n,s),Dd(s,a,u),rl(s,a,u,h),u=!0;else if(n===null){var k=s.stateNode,S=s.memoizedProps;k.props=S;var b=k.context,L=a.contextType;typeof L=="object"&&L!==null?L=Et(L):(L=pt(a)?Hn:rt.current,L=gs(s,L));var F=a.getDerivedStateFromProps,W=typeof F=="function"||typeof k.getSnapshotBeforeUpdate=="function";W||typeof k.UNSAFE_componentWillReceiveProps!="function"&&typeof k.componentWillReceiveProps!="function"||(S!==u||b!==L)&&Bd(s,k,u,L),$n=!1;var z=s.memoizedState;k.state=z,Er(s,u,k,h),b=s.memoizedState,S!==u||z!==b||mt.current||$n?(typeof F=="function"&&(il(s,a,F,u),b=s.memoizedState),(S=$n||_d(s,a,S,u,z,b,L))?(W||typeof k.UNSAFE_componentWillMount!="function"&&typeof k.componentWillMount!="function"||(typeof k.componentWillMount=="function"&&k.componentWillMount(),typeof k.UNSAFE_componentWillMount=="function"&&k.UNSAFE_componentWillMount()),typeof k.componentDidMount=="function"&&(s.flags|=4194308)):(typeof k.componentDidMount=="function"&&(s.flags|=4194308),s.memoizedProps=u,s.memoizedState=b),k.props=u,k.state=b,k.context=L,u=S):(typeof k.componentDidMount=="function"&&(s.flags|=4194308),u=!1)}else{k=s.stateNode,fd(n,s),S=s.memoizedProps,L=s.type===s.elementType?S:Bt(s.type,S),k.props=L,W=s.pendingProps,z=k.context,b=a.contextType,typeof b=="object"&&b!==null?b=Et(b):(b=pt(a)?Hn:rt.current,b=gs(s,b));var J=a.getDerivedStateFromProps;(F=typeof J=="function"||typeof k.getSnapshotBeforeUpdate=="function")||typeof k.UNSAFE_componentWillReceiveProps!="function"&&typeof k.componentWillReceiveProps!="function"||(S!==W||z!==b)&&Bd(s,k,u,b),$n=!1,z=s.memoizedState,k.state=z,Er(s,u,k,h);var ne=s.memoizedState;S!==W||z!==ne||mt.current||$n?(typeof J=="function"&&(il(s,a,J,u),ne=s.memoizedState),(L=$n||_d(s,a,L,u,z,ne,b)||!1)?(F||typeof k.UNSAFE_componentWillUpdate!="function"&&typeof k.componentWillUpdate!="function"||(typeof k.componentWillUpdate=="function"&&k.componentWillUpdate(u,ne,b),typeof k.UNSAFE_componentWillUpdate=="function"&&k.UNSAFE_componentWillUpdate(u,ne,b)),typeof k.componentDidUpdate=="function"&&(s.flags|=4),typeof k.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof k.componentDidUpdate!="function"||S===n.memoizedProps&&z===n.memoizedState||(s.flags|=4),typeof k.getSnapshotBeforeUpdate!="function"||S===n.memoizedProps&&z===n.memoizedState||(s.flags|=1024),s.memoizedProps=u,s.memoizedState=ne),k.props=u,k.state=ne,k.context=b,u=L):(typeof k.componentDidUpdate!="function"||S===n.memoizedProps&&z===n.memoizedState||(s.flags|=4),typeof k.getSnapshotBeforeUpdate!="function"||S===n.memoizedProps&&z===n.memoizedState||(s.flags|=1024),u=!1)}return cl(n,s,a,u,p,h)}function cl(n,s,a,u,h,p){qd(n,s);var k=(s.flags&128)!==0;if(!u&&!k)return h&&td(s,a,!1),dn(n,s,p);u=s.stateNode,nv.current=s;var S=k&&typeof a.getDerivedStateFromError!="function"?null:u.render();return s.flags|=1,n!==null&&k?(s.child=xs(s,n.child,null,p),s.child=xs(s,null,S,p)):dt(n,s,S,p),s.memoizedState=u.state,h&&td(s,a,!0),s.child}function Jd(n){var s=n.stateNode;s.pendingContext?Zu(n,s.pendingContext,s.pendingContext!==s.context):s.context&&Zu(n,s.context,!1),Va(n,s.containerInfo)}function Xd(n,s,a,u,h){return ys(),Ba(h),s.flags|=256,dt(n,s,a,u),s.child}var ul={dehydrated:null,treeContext:null,retryLane:0};function dl(n){return{baseLanes:n,cachePool:null,transitions:null}}function Zd(n,s,a){var u=s.pendingProps,h=Oe.current,p=!1,k=(s.flags&128)!==0,S;if((S=k)||(S=n!==null&&n.memoizedState===null?!1:(h&2)!==0),S?(p=!0,s.flags&=-129):(n===null||n.memoizedState!==null)&&(h|=1),Te(Oe,h&1),n===null)return Da(s),n=s.memoizedState,n!==null&&(n=n.dehydrated,n!==null)?((s.mode&1)===0?s.lanes=1:n.data==="$!"?s.lanes=8:s.lanes=1073741824,null):(k=u.children,n=u.fallback,p?(u=s.mode,p=s.child,k={mode:"hidden",children:k},(u&1)===0&&p!==null?(p.childLanes=0,p.pendingProps=k):p=Yr(k,u,0,null),n=Zn(n,u,a,null),p.return=s,n.return=s,p.sibling=n,s.child=p,s.child.memoizedState=dl(a),s.memoizedState=ul,n):fl(s,k));if(h=n.memoizedState,h!==null&&(S=h.dehydrated,S!==null))return sv(n,s,k,u,S,h,a);if(p){p=u.fallback,k=s.mode,h=n.child,S=h.sibling;var b={mode:"hidden",children:u.children};return(k&1)===0&&s.child!==h?(u=s.child,u.childLanes=0,u.pendingProps=b,s.deletions=null):(u=Rn(h,b),u.subtreeFlags=h.subtreeFlags&14680064),S!==null?p=Rn(S,p):(p=Zn(p,k,a,null),p.flags|=2),p.return=s,u.return=s,u.sibling=p,s.child=u,u=p,p=s.child,k=n.child.memoizedState,k=k===null?dl(a):{baseLanes:k.baseLanes|a,cachePool:null,transitions:k.transitions},p.memoizedState=k,p.childLanes=n.childLanes&~a,s.memoizedState=ul,u}return p=n.child,n=p.sibling,u=Rn(p,{mode:"visible",children:u.children}),(s.mode&1)===0&&(u.lanes=a),u.return=s,u.sibling=null,n!==null&&(a=s.deletions,a===null?(s.deletions=[n],s.flags|=16):a.push(n)),s.child=u,s.memoizedState=null,u}function fl(n,s){return s=Yr({mode:"visible",children:s},n.mode,0,null),s.return=n,n.child=s}function _r(n,s,a,u){return u!==null&&Ba(u),xs(s,n.child,null,a),n=fl(s,s.pendingProps.children),n.flags|=2,s.memoizedState=null,n}function sv(n,s,a,u,h,p,k){if(a)return s.flags&256?(s.flags&=-257,u=ol(Error(r(422))),_r(n,s,k,u)):s.memoizedState!==null?(s.child=n.child,s.flags|=128,null):(p=u.fallback,h=s.mode,u=Yr({mode:"visible",children:u.children},h,0,null),p=Zn(p,h,k,null),p.flags|=2,u.return=s,p.return=s,u.sibling=p,s.child=u,(s.mode&1)!==0&&xs(s,n.child,null,k),s.child.memoizedState=dl(k),s.memoizedState=ul,p);if((s.mode&1)===0)return _r(n,s,k,null);if(h.data==="$!"){if(u=h.nextSibling&&h.nextSibling.dataset,u)var S=u.dgst;return u=S,p=Error(r(419)),u=ol(p,u,void 0),_r(n,s,k,u)}if(S=(k&n.childLanes)!==0,gt||S){if(u=Ze,u!==null){switch(k&-k){case 4:h=2;break;case 16:h=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:h=32;break;case 536870912:h=268435456;break;default:h=0}h=(h&(u.suspendedLanes|k))!==0?0:h,h!==0&&h!==p.retryLane&&(p.retryLane=h,cn(n,h),Ut(u,n,h,-1))}return Tl(),u=ol(Error(r(421))),_r(n,s,k,u)}return h.data==="$?"?(s.flags|=128,s.child=n.child,s=gv.bind(null,n),h._reactRetry=s,null):(n=p.treeContext,St=Nn(h.nextSibling),Nt=s,Le=!0,Dt=null,n!==null&&($t[Tt++]=an,$t[Tt++]=ln,$t[Tt++]=Wn,an=n.id,ln=n.overflow,Wn=s),s=fl(s,u.children),s.flags|=4096,s)}function ef(n,s,a){n.lanes|=s;var u=n.alternate;u!==null&&(u.lanes|=s),Ha(n.return,s,a)}function hl(n,s,a,u,h){var p=n.memoizedState;p===null?n.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:u,tail:a,tailMode:h}:(p.isBackwards=s,p.rendering=null,p.renderingStartTime=0,p.last=u,p.tail=a,p.tailMode=h)}function tf(n,s,a){var u=s.pendingProps,h=u.revealOrder,p=u.tail;if(dt(n,s,u.children,a),u=Oe.current,(u&2)!==0)u=u&1|2,s.flags|=128;else{if(n!==null&&(n.flags&128)!==0)e:for(n=s.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&ef(n,a,s);else if(n.tag===19)ef(n,a,s);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===s)break e;for(;n.sibling===null;){if(n.return===null||n.return===s)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}u&=1}if(Te(Oe,u),(s.mode&1)===0)s.memoizedState=null;else switch(h){case"forwards":for(a=s.child,h=null;a!==null;)n=a.alternate,n!==null&&Ir(n)===null&&(h=a),a=a.sibling;a=h,a===null?(h=s.child,s.child=null):(h=a.sibling,a.sibling=null),hl(s,!1,h,a,p);break;case"backwards":for(a=null,h=s.child,s.child=null;h!==null;){if(n=h.alternate,n!==null&&Ir(n)===null){s.child=h;break}n=h.sibling,h.sibling=a,a=h,h=n}hl(s,!0,a,null,p);break;case"together":hl(s,!1,null,null,void 0);break;default:s.memoizedState=null}return s.child}function Dr(n,s){(s.mode&1)===0&&n!==null&&(n.alternate=null,s.alternate=null,s.flags|=2)}function dn(n,s,a){if(n!==null&&(s.dependencies=n.dependencies),qn|=s.lanes,(a&s.childLanes)===0)return null;if(n!==null&&s.child!==n.child)throw Error(r(153));if(s.child!==null){for(n=s.child,a=Rn(n,n.pendingProps),s.child=a,a.return=s;n.sibling!==null;)n=n.sibling,a=a.sibling=Rn(n,n.pendingProps),a.return=s;a.sibling=null}return s.child}function iv(n,s,a){switch(s.tag){case 3:Jd(s),ys();break;case 5:pd(s);break;case 1:pt(s.type)&&xr(s);break;case 4:Va(s,s.stateNode.containerInfo);break;case 10:var u=s.type._context,h=s.memoizedProps.value;Te(Cr,u._currentValue),u._currentValue=h;break;case 13:if(u=s.memoizedState,u!==null)return u.dehydrated!==null?(Te(Oe,Oe.current&1),s.flags|=128,null):(a&s.child.childLanes)!==0?Zd(n,s,a):(Te(Oe,Oe.current&1),n=dn(n,s,a),n!==null?n.sibling:null);Te(Oe,Oe.current&1);break;case 19:if(u=(a&s.childLanes)!==0,(n.flags&128)!==0){if(u)return tf(n,s,a);s.flags|=128}if(h=s.memoizedState,h!==null&&(h.rendering=null,h.tail=null,h.lastEffect=null),Te(Oe,Oe.current),u)break;return null;case 22:case 23:return s.lanes=0,Qd(n,s,a)}return dn(n,s,a)}var nf,ml,sf,rf;nf=function(n,s){for(var a=s.child;a!==null;){if(a.tag===5||a.tag===6)n.appendChild(a.stateNode);else if(a.tag!==4&&a.child!==null){a.child.return=a,a=a.child;continue}if(a===s)break;for(;a.sibling===null;){if(a.return===null||a.return===s)return;a=a.return}a.sibling.return=a.return,a=a.sibling}},ml=function(){},sf=function(n,s,a,u){var h=n.memoizedProps;if(h!==u){n=s.stateNode,Gn(Gt.current);var p=null;switch(a){case"input":h=Ho(n,h),u=Ho(n,u),p=[];break;case"select":h=H({},h,{value:void 0}),u=H({},u,{value:void 0}),p=[];break;case"textarea":h=Vo(n,h),u=Vo(n,u),p=[];break;default:typeof h.onClick!="function"&&typeof u.onClick=="function"&&(n.onclick=vr)}Qo(a,u);var k;a=null;for(L in h)if(!u.hasOwnProperty(L)&&h.hasOwnProperty(L)&&h[L]!=null)if(L==="style"){var S=h[L];for(k in S)S.hasOwnProperty(k)&&(a||(a={}),a[k]="")}else L!=="dangerouslySetInnerHTML"&&L!=="children"&&L!=="suppressContentEditableWarning"&&L!=="suppressHydrationWarning"&&L!=="autoFocus"&&(l.hasOwnProperty(L)?p||(p=[]):(p=p||[]).push(L,null));for(L in u){var b=u[L];if(S=h!=null?h[L]:void 0,u.hasOwnProperty(L)&&b!==S&&(b!=null||S!=null))if(L==="style")if(S){for(k in S)!S.hasOwnProperty(k)||b&&b.hasOwnProperty(k)||(a||(a={}),a[k]="");for(k in b)b.hasOwnProperty(k)&&S[k]!==b[k]&&(a||(a={}),a[k]=b[k])}else a||(p||(p=[]),p.push(L,a)),a=b;else L==="dangerouslySetInnerHTML"?(b=b?b.__html:void 0,S=S?S.__html:void 0,b!=null&&S!==b&&(p=p||[]).push(L,b)):L==="children"?typeof b!="string"&&typeof b!="number"||(p=p||[]).push(L,""+b):L!=="suppressContentEditableWarning"&&L!=="suppressHydrationWarning"&&(l.hasOwnProperty(L)?(b!=null&&L==="onScroll"&&Ie("scroll",n),p||S===b||(p=[])):(p=p||[]).push(L,b))}a&&(p=p||[]).push("style",a);var L=p;(s.updateQueue=L)&&(s.flags|=4)}},rf=function(n,s,a,u){a!==u&&(s.flags|=4)};function bi(n,s){if(!Le)switch(n.tailMode){case"hidden":s=n.tail;for(var a=null;s!==null;)s.alternate!==null&&(a=s),s=s.sibling;a===null?n.tail=null:a.sibling=null;break;case"collapsed":a=n.tail;for(var u=null;a!==null;)a.alternate!==null&&(u=a),a=a.sibling;u===null?s||n.tail===null?n.tail=null:n.tail.sibling=null:u.sibling=null}}function at(n){var s=n.alternate!==null&&n.alternate.child===n.child,a=0,u=0;if(s)for(var h=n.child;h!==null;)a|=h.lanes|h.childLanes,u|=h.subtreeFlags&14680064,u|=h.flags&14680064,h.return=n,h=h.sibling;else for(h=n.child;h!==null;)a|=h.lanes|h.childLanes,u|=h.subtreeFlags,u|=h.flags,h.return=n,h=h.sibling;return n.subtreeFlags|=u,n.childLanes=a,s}function rv(n,s,a){var u=s.pendingProps;switch(Pa(s),s.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return at(s),null;case 1:return pt(s.type)&&yr(),at(s),null;case 3:return u=s.stateNode,Ns(),Me(mt),Me(rt),qa(),u.pendingContext&&(u.context=u.pendingContext,u.pendingContext=null),(n===null||n.child===null)&&(Sr(s)?s.flags|=4:n===null||n.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,Dt!==null&&(bl(Dt),Dt=null))),ml(n,s),at(s),null;case 5:Ga(s);var h=Gn(xi.current);if(a=s.type,n!==null&&s.stateNode!=null)sf(n,s,a,u,h),n.ref!==s.ref&&(s.flags|=512,s.flags|=2097152);else{if(!u){if(s.stateNode===null)throw Error(r(166));return at(s),null}if(n=Gn(Gt.current),Sr(s)){u=s.stateNode,a=s.type;var p=s.memoizedProps;switch(u[Vt]=s,u[pi]=p,n=(s.mode&1)!==0,a){case"dialog":Ie("cancel",u),Ie("close",u);break;case"iframe":case"object":case"embed":Ie("load",u);break;case"video":case"audio":for(h=0;h<fi.length;h++)Ie(fi[h],u);break;case"source":Ie("error",u);break;case"img":case"image":case"link":Ie("error",u),Ie("load",u);break;case"details":Ie("toggle",u);break;case"input":Dc(u,p),Ie("invalid",u);break;case"select":u._wrapperState={wasMultiple:!!p.multiple},Ie("invalid",u);break;case"textarea":Fc(u,p),Ie("invalid",u)}Qo(a,p),h=null;for(var k in p)if(p.hasOwnProperty(k)){var S=p[k];k==="children"?typeof S=="string"?u.textContent!==S&&(p.suppressHydrationWarning!==!0&&gr(u.textContent,S,n),h=["children",S]):typeof S=="number"&&u.textContent!==""+S&&(p.suppressHydrationWarning!==!0&&gr(u.textContent,S,n),h=["children",""+S]):l.hasOwnProperty(k)&&S!=null&&k==="onScroll"&&Ie("scroll",u)}switch(a){case"input":ss(u),zc(u,p,!0);break;case"textarea":ss(u),Hc(u);break;case"select":case"option":break;default:typeof p.onClick=="function"&&(u.onclick=vr)}u=h,s.updateQueue=u,u!==null&&(s.flags|=4)}else{k=h.nodeType===9?h:h.ownerDocument,n==="http://www.w3.org/1999/xhtml"&&(n=Wc(a)),n==="http://www.w3.org/1999/xhtml"?a==="script"?(n=k.createElement("div"),n.innerHTML="<script><\/script>",n=n.removeChild(n.firstChild)):typeof u.is=="string"?n=k.createElement(a,{is:u.is}):(n=k.createElement(a),a==="select"&&(k=n,u.multiple?k.multiple=!0:u.size&&(k.size=u.size))):n=k.createElementNS(n,a),n[Vt]=s,n[pi]=u,nf(n,s,!1,!1),s.stateNode=n;e:{switch(k=qo(a,u),a){case"dialog":Ie("cancel",n),Ie("close",n),h=u;break;case"iframe":case"object":case"embed":Ie("load",n),h=u;break;case"video":case"audio":for(h=0;h<fi.length;h++)Ie(fi[h],n);h=u;break;case"source":Ie("error",n),h=u;break;case"img":case"image":case"link":Ie("error",n),Ie("load",n),h=u;break;case"details":Ie("toggle",n),h=u;break;case"input":Dc(n,u),h=Ho(n,u),Ie("invalid",n);break;case"option":h=u;break;case"select":n._wrapperState={wasMultiple:!!u.multiple},h=H({},u,{value:void 0}),Ie("invalid",n);break;case"textarea":Fc(n,u),h=Vo(n,u),Ie("invalid",n);break;default:h=u}Qo(a,h),S=h;for(p in S)if(S.hasOwnProperty(p)){var b=S[p];p==="style"?Gc(n,b):p==="dangerouslySetInnerHTML"?(b=b?b.__html:void 0,b!=null&&Kc(n,b)):p==="children"?typeof b=="string"?(a!=="textarea"||b!=="")&&Gs(n,b):typeof b=="number"&&Gs(n,""+b):p!=="suppressContentEditableWarning"&&p!=="suppressHydrationWarning"&&p!=="autoFocus"&&(l.hasOwnProperty(p)?b!=null&&p==="onScroll"&&Ie("scroll",n):b!=null&&O(n,p,b,k))}switch(a){case"input":ss(n),zc(n,u,!1);break;case"textarea":ss(n),Hc(n);break;case"option":u.value!=null&&n.setAttribute("value",""+ke(u.value));break;case"select":n.multiple=!!u.multiple,p=u.value,p!=null?is(n,!!u.multiple,p,!1):u.defaultValue!=null&&is(n,!!u.multiple,u.defaultValue,!0);break;default:typeof h.onClick=="function"&&(n.onclick=vr)}switch(a){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}}u&&(s.flags|=4)}s.ref!==null&&(s.flags|=512,s.flags|=2097152)}return at(s),null;case 6:if(n&&s.stateNode!=null)rf(n,s,n.memoizedProps,u);else{if(typeof u!="string"&&s.stateNode===null)throw Error(r(166));if(a=Gn(xi.current),Gn(Gt.current),Sr(s)){if(u=s.stateNode,a=s.memoizedProps,u[Vt]=s,(p=u.nodeValue!==a)&&(n=Nt,n!==null))switch(n.tag){case 3:gr(u.nodeValue,a,(n.mode&1)!==0);break;case 5:n.memoizedProps.suppressHydrationWarning!==!0&&gr(u.nodeValue,a,(n.mode&1)!==0)}p&&(s.flags|=4)}else u=(a.nodeType===9?a:a.ownerDocument).createTextNode(u),u[Vt]=s,s.stateNode=u}return at(s),null;case 13:if(Me(Oe),u=s.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(Le&&St!==null&&(s.mode&1)!==0&&(s.flags&128)===0)ad(),ys(),s.flags|=98560,p=!1;else if(p=Sr(s),u!==null&&u.dehydrated!==null){if(n===null){if(!p)throw Error(r(318));if(p=s.memoizedState,p=p!==null?p.dehydrated:null,!p)throw Error(r(317));p[Vt]=s}else ys(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;at(s),p=!1}else Dt!==null&&(bl(Dt),Dt=null),p=!0;if(!p)return s.flags&65536?s:null}return(s.flags&128)!==0?(s.lanes=a,s):(u=u!==null,u!==(n!==null&&n.memoizedState!==null)&&u&&(s.child.flags|=8192,(s.mode&1)!==0&&(n===null||(Oe.current&1)!==0?qe===0&&(qe=3):Tl())),s.updateQueue!==null&&(s.flags|=4),at(s),null);case 4:return Ns(),ml(n,s),n===null&&hi(s.stateNode.containerInfo),at(s),null;case 10:return Ua(s.type._context),at(s),null;case 17:return pt(s.type)&&yr(),at(s),null;case 19:if(Me(Oe),p=s.memoizedState,p===null)return at(s),null;if(u=(s.flags&128)!==0,k=p.rendering,k===null)if(u)bi(p,!1);else{if(qe!==0||n!==null&&(n.flags&128)!==0)for(n=s.child;n!==null;){if(k=Ir(n),k!==null){for(s.flags|=128,bi(p,!1),u=k.updateQueue,u!==null&&(s.updateQueue=u,s.flags|=4),s.subtreeFlags=0,u=a,a=s.child;a!==null;)p=a,n=u,p.flags&=14680066,k=p.alternate,k===null?(p.childLanes=0,p.lanes=n,p.child=null,p.subtreeFlags=0,p.memoizedProps=null,p.memoizedState=null,p.updateQueue=null,p.dependencies=null,p.stateNode=null):(p.childLanes=k.childLanes,p.lanes=k.lanes,p.child=k.child,p.subtreeFlags=0,p.deletions=null,p.memoizedProps=k.memoizedProps,p.memoizedState=k.memoizedState,p.updateQueue=k.updateQueue,p.type=k.type,n=k.dependencies,p.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),a=a.sibling;return Te(Oe,Oe.current&1|2),s.child}n=n.sibling}p.tail!==null&&ze()>$s&&(s.flags|=128,u=!0,bi(p,!1),s.lanes=4194304)}else{if(!u)if(n=Ir(k),n!==null){if(s.flags|=128,u=!0,a=n.updateQueue,a!==null&&(s.updateQueue=a,s.flags|=4),bi(p,!0),p.tail===null&&p.tailMode==="hidden"&&!k.alternate&&!Le)return at(s),null}else 2*ze()-p.renderingStartTime>$s&&a!==1073741824&&(s.flags|=128,u=!0,bi(p,!1),s.lanes=4194304);p.isBackwards?(k.sibling=s.child,s.child=k):(a=p.last,a!==null?a.sibling=k:s.child=k,p.last=k)}return p.tail!==null?(s=p.tail,p.rendering=s,p.tail=s.sibling,p.renderingStartTime=ze(),s.sibling=null,a=Oe.current,Te(Oe,u?a&1|2:a&1),s):(at(s),null);case 22:case 23:return $l(),u=s.memoizedState!==null,n!==null&&n.memoizedState!==null!==u&&(s.flags|=8192),u&&(s.mode&1)!==0?(bt&1073741824)!==0&&(at(s),s.subtreeFlags&6&&(s.flags|=8192)):at(s),null;case 24:return null;case 25:return null}throw Error(r(156,s.tag))}function ov(n,s){switch(Pa(s),s.tag){case 1:return pt(s.type)&&yr(),n=s.flags,n&65536?(s.flags=n&-65537|128,s):null;case 3:return Ns(),Me(mt),Me(rt),qa(),n=s.flags,(n&65536)!==0&&(n&128)===0?(s.flags=n&-65537|128,s):null;case 5:return Ga(s),null;case 13:if(Me(Oe),n=s.memoizedState,n!==null&&n.dehydrated!==null){if(s.alternate===null)throw Error(r(340));ys()}return n=s.flags,n&65536?(s.flags=n&-65537|128,s):null;case 19:return Me(Oe),null;case 4:return Ns(),null;case 10:return Ua(s.type._context),null;case 22:case 23:return $l(),null;case 24:return null;default:return null}}var Br=!1,lt=!1,av=typeof WeakSet=="function"?WeakSet:Set,ee=null;function bs(n,s){var a=n.ref;if(a!==null)if(typeof a=="function")try{a(null)}catch(u){_e(n,s,u)}else a.current=null}function pl(n,s,a){try{a()}catch(u){_e(n,s,u)}}var of=!1;function lv(n,s){if($a=rr,n=_u(),ya(n)){if("selectionStart"in n)var a={start:n.selectionStart,end:n.selectionEnd};else e:{a=(a=n.ownerDocument)&&a.defaultView||window;var u=a.getSelection&&a.getSelection();if(u&&u.rangeCount!==0){a=u.anchorNode;var h=u.anchorOffset,p=u.focusNode;u=u.focusOffset;try{a.nodeType,p.nodeType}catch{a=null;break e}var k=0,S=-1,b=-1,L=0,F=0,W=n,z=null;t:for(;;){for(var J;W!==a||h!==0&&W.nodeType!==3||(S=k+h),W!==p||u!==0&&W.nodeType!==3||(b=k+u),W.nodeType===3&&(k+=W.nodeValue.length),(J=W.firstChild)!==null;)z=W,W=J;for(;;){if(W===n)break t;if(z===a&&++L===h&&(S=k),z===p&&++F===u&&(b=k),(J=W.nextSibling)!==null)break;W=z,z=W.parentNode}W=J}a=S===-1||b===-1?null:{start:S,end:b}}else a=null}a=a||{start:0,end:0}}else a=null;for(Ta={focusedElem:n,selectionRange:a},rr=!1,ee=s;ee!==null;)if(s=ee,n=s.child,(s.subtreeFlags&1028)!==0&&n!==null)n.return=s,ee=n;else for(;ee!==null;){s=ee;try{var ne=s.alternate;if((s.flags&1024)!==0)switch(s.tag){case 0:case 11:case 15:break;case 1:if(ne!==null){var se=ne.memoizedProps,Fe=ne.memoizedState,I=s.stateNode,C=I.getSnapshotBeforeUpdate(s.elementType===s.type?se:Bt(s.type,se),Fe);I.__reactInternalSnapshotBeforeUpdate=C}break;case 3:var A=s.stateNode.containerInfo;A.nodeType===1?A.textContent="":A.nodeType===9&&A.documentElement&&A.removeChild(A.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(G){_e(s,s.return,G)}if(n=s.sibling,n!==null){n.return=s.return,ee=n;break}ee=s.return}return ne=of,of=!1,ne}function Ci(n,s,a){var u=s.updateQueue;if(u=u!==null?u.lastEffect:null,u!==null){var h=u=u.next;do{if((h.tag&n)===n){var p=h.destroy;h.destroy=void 0,p!==void 0&&pl(s,a,p)}h=h.next}while(h!==u)}}function zr(n,s){if(s=s.updateQueue,s=s!==null?s.lastEffect:null,s!==null){var a=s=s.next;do{if((a.tag&n)===n){var u=a.create;a.destroy=u()}a=a.next}while(a!==s)}}function gl(n){var s=n.ref;if(s!==null){var a=n.stateNode;switch(n.tag){case 5:n=a;break;default:n=a}typeof s=="function"?s(n):s.current=n}}function af(n){var s=n.alternate;s!==null&&(n.alternate=null,af(s)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(s=n.stateNode,s!==null&&(delete s[Vt],delete s[pi],delete s[Aa],delete s[Wg],delete s[Kg])),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}function lf(n){return n.tag===5||n.tag===3||n.tag===4}function cf(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||lf(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function vl(n,s,a){var u=n.tag;if(u===5||u===6)n=n.stateNode,s?a.nodeType===8?a.parentNode.insertBefore(n,s):a.insertBefore(n,s):(a.nodeType===8?(s=a.parentNode,s.insertBefore(n,a)):(s=a,s.appendChild(n)),a=a._reactRootContainer,a!=null||s.onclick!==null||(s.onclick=vr));else if(u!==4&&(n=n.child,n!==null))for(vl(n,s,a),n=n.sibling;n!==null;)vl(n,s,a),n=n.sibling}function kl(n,s,a){var u=n.tag;if(u===5||u===6)n=n.stateNode,s?a.insertBefore(n,s):a.appendChild(n);else if(u!==4&&(n=n.child,n!==null))for(kl(n,s,a),n=n.sibling;n!==null;)kl(n,s,a),n=n.sibling}var nt=null,zt=!1;function En(n,s,a){for(a=a.child;a!==null;)uf(n,s,a),a=a.sibling}function uf(n,s,a){if(Kt&&typeof Kt.onCommitFiberUnmount=="function")try{Kt.onCommitFiberUnmount(Zi,a)}catch{}switch(a.tag){case 5:lt||bs(a,s);case 6:var u=nt,h=zt;nt=null,En(n,s,a),nt=u,zt=h,nt!==null&&(zt?(n=nt,a=a.stateNode,n.nodeType===8?n.parentNode.removeChild(a):n.removeChild(a)):nt.removeChild(a.stateNode));break;case 18:nt!==null&&(zt?(n=nt,a=a.stateNode,n.nodeType===8?Ma(n.parentNode,a):n.nodeType===1&&Ma(n,a),ii(n)):Ma(nt,a.stateNode));break;case 4:u=nt,h=zt,nt=a.stateNode.containerInfo,zt=!0,En(n,s,a),nt=u,zt=h;break;case 0:case 11:case 14:case 15:if(!lt&&(u=a.updateQueue,u!==null&&(u=u.lastEffect,u!==null))){h=u=u.next;do{var p=h,k=p.destroy;p=p.tag,k!==void 0&&((p&2)!==0||(p&4)!==0)&&pl(a,s,k),h=h.next}while(h!==u)}En(n,s,a);break;case 1:if(!lt&&(bs(a,s),u=a.stateNode,typeof u.componentWillUnmount=="function"))try{u.props=a.memoizedProps,u.state=a.memoizedState,u.componentWillUnmount()}catch(S){_e(a,s,S)}En(n,s,a);break;case 21:En(n,s,a);break;case 22:a.mode&1?(lt=(u=lt)||a.memoizedState!==null,En(n,s,a),lt=u):En(n,s,a);break;default:En(n,s,a)}}function df(n){var s=n.updateQueue;if(s!==null){n.updateQueue=null;var a=n.stateNode;a===null&&(a=n.stateNode=new av),s.forEach(function(u){var h=vv.bind(null,n,u);a.has(u)||(a.add(u),u.then(h,h))})}}function Ft(n,s){var a=s.deletions;if(a!==null)for(var u=0;u<a.length;u++){var h=a[u];try{var p=n,k=s,S=k;e:for(;S!==null;){switch(S.tag){case 5:nt=S.stateNode,zt=!1;break e;case 3:nt=S.stateNode.containerInfo,zt=!0;break e;case 4:nt=S.stateNode.containerInfo,zt=!0;break e}S=S.return}if(nt===null)throw Error(r(160));uf(p,k,h),nt=null,zt=!1;var b=h.alternate;b!==null&&(b.return=null),h.return=null}catch(L){_e(h,s,L)}}if(s.subtreeFlags&12854)for(s=s.child;s!==null;)ff(s,n),s=s.sibling}function ff(n,s){var a=n.alternate,u=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:if(Ft(s,n),qt(n),u&4){try{Ci(3,n,n.return),zr(3,n)}catch(se){_e(n,n.return,se)}try{Ci(5,n,n.return)}catch(se){_e(n,n.return,se)}}break;case 1:Ft(s,n),qt(n),u&512&&a!==null&&bs(a,a.return);break;case 5:if(Ft(s,n),qt(n),u&512&&a!==null&&bs(a,a.return),n.flags&32){var h=n.stateNode;try{Gs(h,"")}catch(se){_e(n,n.return,se)}}if(u&4&&(h=n.stateNode,h!=null)){var p=n.memoizedProps,k=a!==null?a.memoizedProps:p,S=n.type,b=n.updateQueue;if(n.updateQueue=null,b!==null)try{S==="input"&&p.type==="radio"&&p.name!=null&&Bc(h,p),qo(S,k);var L=qo(S,p);for(k=0;k<b.length;k+=2){var F=b[k],W=b[k+1];F==="style"?Gc(h,W):F==="dangerouslySetInnerHTML"?Kc(h,W):F==="children"?Gs(h,W):O(h,F,W,L)}switch(S){case"input":Wo(h,p);break;case"textarea":Uc(h,p);break;case"select":var z=h._wrapperState.wasMultiple;h._wrapperState.wasMultiple=!!p.multiple;var J=p.value;J!=null?is(h,!!p.multiple,J,!1):z!==!!p.multiple&&(p.defaultValue!=null?is(h,!!p.multiple,p.defaultValue,!0):is(h,!!p.multiple,p.multiple?[]:"",!1))}h[pi]=p}catch(se){_e(n,n.return,se)}}break;case 6:if(Ft(s,n),qt(n),u&4){if(n.stateNode===null)throw Error(r(162));h=n.stateNode,p=n.memoizedProps;try{h.nodeValue=p}catch(se){_e(n,n.return,se)}}break;case 3:if(Ft(s,n),qt(n),u&4&&a!==null&&a.memoizedState.isDehydrated)try{ii(s.containerInfo)}catch(se){_e(n,n.return,se)}break;case 4:Ft(s,n),qt(n);break;case 13:Ft(s,n),qt(n),h=n.child,h.flags&8192&&(p=h.memoizedState!==null,h.stateNode.isHidden=p,!p||h.alternate!==null&&h.alternate.memoizedState!==null||(wl=ze())),u&4&&df(n);break;case 22:if(F=a!==null&&a.memoizedState!==null,n.mode&1?(lt=(L=lt)||F,Ft(s,n),lt=L):Ft(s,n),qt(n),u&8192){if(L=n.memoizedState!==null,(n.stateNode.isHidden=L)&&!F&&(n.mode&1)!==0)for(ee=n,F=n.child;F!==null;){for(W=ee=F;ee!==null;){switch(z=ee,J=z.child,z.tag){case 0:case 11:case 14:case 15:Ci(4,z,z.return);break;case 1:bs(z,z.return);var ne=z.stateNode;if(typeof ne.componentWillUnmount=="function"){u=z,a=z.return;try{s=u,ne.props=s.memoizedProps,ne.state=s.memoizedState,ne.componentWillUnmount()}catch(se){_e(u,a,se)}}break;case 5:bs(z,z.return);break;case 22:if(z.memoizedState!==null){pf(W);continue}}J!==null?(J.return=z,ee=J):pf(W)}F=F.sibling}e:for(F=null,W=n;;){if(W.tag===5){if(F===null){F=W;try{h=W.stateNode,L?(p=h.style,typeof p.setProperty=="function"?p.setProperty("display","none","important"):p.display="none"):(S=W.stateNode,b=W.memoizedProps.style,k=b!=null&&b.hasOwnProperty("display")?b.display:null,S.style.display=Vc("display",k))}catch(se){_e(n,n.return,se)}}}else if(W.tag===6){if(F===null)try{W.stateNode.nodeValue=L?"":W.memoizedProps}catch(se){_e(n,n.return,se)}}else if((W.tag!==22&&W.tag!==23||W.memoizedState===null||W===n)&&W.child!==null){W.child.return=W,W=W.child;continue}if(W===n)break e;for(;W.sibling===null;){if(W.return===null||W.return===n)break e;F===W&&(F=null),W=W.return}F===W&&(F=null),W.sibling.return=W.return,W=W.sibling}}break;case 19:Ft(s,n),qt(n),u&4&&df(n);break;case 21:break;default:Ft(s,n),qt(n)}}function qt(n){var s=n.flags;if(s&2){try{e:{for(var a=n.return;a!==null;){if(lf(a)){var u=a;break e}a=a.return}throw Error(r(160))}switch(u.tag){case 5:var h=u.stateNode;u.flags&32&&(Gs(h,""),u.flags&=-33);var p=cf(n);kl(n,p,h);break;case 3:case 4:var k=u.stateNode.containerInfo,S=cf(n);vl(n,S,k);break;default:throw Error(r(161))}}catch(b){_e(n,n.return,b)}n.flags&=-3}s&4096&&(n.flags&=-4097)}function cv(n,s,a){ee=n,hf(n)}function hf(n,s,a){for(var u=(n.mode&1)!==0;ee!==null;){var h=ee,p=h.child;if(h.tag===22&&u){var k=h.memoizedState!==null||Br;if(!k){var S=h.alternate,b=S!==null&&S.memoizedState!==null||lt;S=Br;var L=lt;if(Br=k,(lt=b)&&!L)for(ee=h;ee!==null;)k=ee,b=k.child,k.tag===22&&k.memoizedState!==null?gf(h):b!==null?(b.return=k,ee=b):gf(h);for(;p!==null;)ee=p,hf(p),p=p.sibling;ee=h,Br=S,lt=L}mf(n)}else(h.subtreeFlags&8772)!==0&&p!==null?(p.return=h,ee=p):mf(n)}}function mf(n){for(;ee!==null;){var s=ee;if((s.flags&8772)!==0){var a=s.alternate;try{if((s.flags&8772)!==0)switch(s.tag){case 0:case 11:case 15:lt||zr(5,s);break;case 1:var u=s.stateNode;if(s.flags&4&&!lt)if(a===null)u.componentDidMount();else{var h=s.elementType===s.type?a.memoizedProps:Bt(s.type,a.memoizedProps);u.componentDidUpdate(h,a.memoizedState,u.__reactInternalSnapshotBeforeUpdate)}var p=s.updateQueue;p!==null&&md(s,p,u);break;case 3:var k=s.updateQueue;if(k!==null){if(a=null,s.child!==null)switch(s.child.tag){case 5:a=s.child.stateNode;break;case 1:a=s.child.stateNode}md(s,k,a)}break;case 5:var S=s.stateNode;if(a===null&&s.flags&4){a=S;var b=s.memoizedProps;switch(s.type){case"button":case"input":case"select":case"textarea":b.autoFocus&&a.focus();break;case"img":b.src&&(a.src=b.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(s.memoizedState===null){var L=s.alternate;if(L!==null){var F=L.memoizedState;if(F!==null){var W=F.dehydrated;W!==null&&ii(W)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(r(163))}lt||s.flags&512&&gl(s)}catch(z){_e(s,s.return,z)}}if(s===n){ee=null;break}if(a=s.sibling,a!==null){a.return=s.return,ee=a;break}ee=s.return}}function pf(n){for(;ee!==null;){var s=ee;if(s===n){ee=null;break}var a=s.sibling;if(a!==null){a.return=s.return,ee=a;break}ee=s.return}}function gf(n){for(;ee!==null;){var s=ee;try{switch(s.tag){case 0:case 11:case 15:var a=s.return;try{zr(4,s)}catch(b){_e(s,a,b)}break;case 1:var u=s.stateNode;if(typeof u.componentDidMount=="function"){var h=s.return;try{u.componentDidMount()}catch(b){_e(s,h,b)}}var p=s.return;try{gl(s)}catch(b){_e(s,p,b)}break;case 5:var k=s.return;try{gl(s)}catch(b){_e(s,k,b)}}}catch(b){_e(s,s.return,b)}if(s===n){ee=null;break}var S=s.sibling;if(S!==null){S.return=s.return,ee=S;break}ee=s.return}}var uv=Math.ceil,Fr=X.ReactCurrentDispatcher,yl=X.ReactCurrentOwner,Mt=X.ReactCurrentBatchConfig,je=0,Ze=null,Ve=null,st=0,bt=0,Cs=Sn(0),qe=0,$i=null,qn=0,Ur=0,xl=0,Ti=null,vt=null,wl=0,$s=1/0,fn=null,Hr=!1,jl=null,In=null,Wr=!1,Mn=null,Kr=0,Ei=0,Nl=null,Vr=-1,Gr=0;function ft(){return(je&6)!==0?ze():Vr!==-1?Vr:Vr=ze()}function An(n){return(n.mode&1)===0?1:(je&2)!==0&&st!==0?st&-st:Gg.transition!==null?(Gr===0&&(Gr=lu()),Gr):(n=Ce,n!==0||(n=window.event,n=n===void 0?16:vu(n.type)),n)}function Ut(n,s,a,u){if(50<Ei)throw Ei=0,Nl=null,Error(r(185));Zs(n,a,u),((je&2)===0||n!==Ze)&&(n===Ze&&((je&2)===0&&(Ur|=a),qe===4&&Ln(n,st)),kt(n,u),a===1&&je===0&&(s.mode&1)===0&&($s=ze()+500,wr&&Cn()))}function kt(n,s){var a=n.callbackNode;Gp(n,s);var u=nr(n,n===Ze?st:0);if(u===0)a!==null&&ru(a),n.callbackNode=null,n.callbackPriority=0;else if(s=u&-u,n.callbackPriority!==s){if(a!=null&&ru(a),s===1)n.tag===0?Vg(kf.bind(null,n)):nd(kf.bind(null,n)),Ug(function(){(je&6)===0&&Cn()}),a=null;else{switch(cu(u)){case 1:a=na;break;case 4:a=ou;break;case 16:a=Xi;break;case 536870912:a=au;break;default:a=Xi}a=Cf(a,vf.bind(null,n))}n.callbackPriority=s,n.callbackNode=a}}function vf(n,s){if(Vr=-1,Gr=0,(je&6)!==0)throw Error(r(327));var a=n.callbackNode;if(Ts()&&n.callbackNode!==a)return null;var u=nr(n,n===Ze?st:0);if(u===0)return null;if((u&30)!==0||(u&n.expiredLanes)!==0||s)s=Qr(n,u);else{s=u;var h=je;je|=2;var p=xf();(Ze!==n||st!==s)&&(fn=null,$s=ze()+500,Jn(n,s));do try{hv();break}catch(S){yf(n,S)}while(!0);Fa(),Fr.current=p,je=h,Ve!==null?s=0:(Ze=null,st=0,s=qe)}if(s!==0){if(s===2&&(h=sa(n),h!==0&&(u=h,s=Sl(n,h))),s===1)throw a=$i,Jn(n,0),Ln(n,u),kt(n,ze()),a;if(s===6)Ln(n,u);else{if(h=n.current.alternate,(u&30)===0&&!dv(h)&&(s=Qr(n,u),s===2&&(p=sa(n),p!==0&&(u=p,s=Sl(n,p))),s===1))throw a=$i,Jn(n,0),Ln(n,u),kt(n,ze()),a;switch(n.finishedWork=h,n.finishedLanes=u,s){case 0:case 1:throw Error(r(345));case 2:Xn(n,vt,fn);break;case 3:if(Ln(n,u),(u&130023424)===u&&(s=wl+500-ze(),10<s)){if(nr(n,0)!==0)break;if(h=n.suspendedLanes,(h&u)!==u){ft(),n.pingedLanes|=n.suspendedLanes&h;break}n.timeoutHandle=Ia(Xn.bind(null,n,vt,fn),s);break}Xn(n,vt,fn);break;case 4:if(Ln(n,u),(u&4194240)===u)break;for(s=n.eventTimes,h=-1;0<u;){var k=31-Pt(u);p=1<<k,k=s[k],k>h&&(h=k),u&=~p}if(u=h,u=ze()-u,u=(120>u?120:480>u?480:1080>u?1080:1920>u?1920:3e3>u?3e3:4320>u?4320:1960*uv(u/1960))-u,10<u){n.timeoutHandle=Ia(Xn.bind(null,n,vt,fn),u);break}Xn(n,vt,fn);break;case 5:Xn(n,vt,fn);break;default:throw Error(r(329))}}}return kt(n,ze()),n.callbackNode===a?vf.bind(null,n):null}function Sl(n,s){var a=Ti;return n.current.memoizedState.isDehydrated&&(Jn(n,s).flags|=256),n=Qr(n,s),n!==2&&(s=vt,vt=a,s!==null&&bl(s)),n}function bl(n){vt===null?vt=n:vt.push.apply(vt,n)}function dv(n){for(var s=n;;){if(s.flags&16384){var a=s.updateQueue;if(a!==null&&(a=a.stores,a!==null))for(var u=0;u<a.length;u++){var h=a[u],p=h.getSnapshot;h=h.value;try{if(!_t(p(),h))return!1}catch{return!1}}}if(a=s.child,s.subtreeFlags&16384&&a!==null)a.return=s,s=a;else{if(s===n)break;for(;s.sibling===null;){if(s.return===null||s.return===n)return!0;s=s.return}s.sibling.return=s.return,s=s.sibling}}return!0}function Ln(n,s){for(s&=~xl,s&=~Ur,n.suspendedLanes|=s,n.pingedLanes&=~s,n=n.expirationTimes;0<s;){var a=31-Pt(s),u=1<<a;n[a]=-1,s&=~u}}function kf(n){if((je&6)!==0)throw Error(r(327));Ts();var s=nr(n,0);if((s&1)===0)return kt(n,ze()),null;var a=Qr(n,s);if(n.tag!==0&&a===2){var u=sa(n);u!==0&&(s=u,a=Sl(n,u))}if(a===1)throw a=$i,Jn(n,0),Ln(n,s),kt(n,ze()),a;if(a===6)throw Error(r(345));return n.finishedWork=n.current.alternate,n.finishedLanes=s,Xn(n,vt,fn),kt(n,ze()),null}function Cl(n,s){var a=je;je|=1;try{return n(s)}finally{je=a,je===0&&($s=ze()+500,wr&&Cn())}}function Yn(n){Mn!==null&&Mn.tag===0&&(je&6)===0&&Ts();var s=je;je|=1;var a=Mt.transition,u=Ce;try{if(Mt.transition=null,Ce=1,n)return n()}finally{Ce=u,Mt.transition=a,je=s,(je&6)===0&&Cn()}}function $l(){bt=Cs.current,Me(Cs)}function Jn(n,s){n.finishedWork=null,n.finishedLanes=0;var a=n.timeoutHandle;if(a!==-1&&(n.timeoutHandle=-1,Fg(a)),Ve!==null)for(a=Ve.return;a!==null;){var u=a;switch(Pa(u),u.tag){case 1:u=u.type.childContextTypes,u!=null&&yr();break;case 3:Ns(),Me(mt),Me(rt),qa();break;case 5:Ga(u);break;case 4:Ns();break;case 13:Me(Oe);break;case 19:Me(Oe);break;case 10:Ua(u.type._context);break;case 22:case 23:$l()}a=a.return}if(Ze=n,Ve=n=Rn(n.current,null),st=bt=s,qe=0,$i=null,xl=Ur=qn=0,vt=Ti=null,Vn!==null){for(s=0;s<Vn.length;s++)if(a=Vn[s],u=a.interleaved,u!==null){a.interleaved=null;var h=u.next,p=a.pending;if(p!==null){var k=p.next;p.next=h,u.next=k}a.pending=u}Vn=null}return n}function yf(n,s){do{var a=Ve;try{if(Fa(),Mr.current=Or,Ar){for(var u=Pe.memoizedState;u!==null;){var h=u.queue;h!==null&&(h.pending=null),u=u.next}Ar=!1}if(Qn=0,Xe=Qe=Pe=null,wi=!1,ji=0,yl.current=null,a===null||a.return===null){qe=1,$i=s,Ve=null;break}e:{var p=n,k=a.return,S=a,b=s;if(s=st,S.flags|=32768,b!==null&&typeof b=="object"&&typeof b.then=="function"){var L=b,F=S,W=F.tag;if((F.mode&1)===0&&(W===0||W===11||W===15)){var z=F.alternate;z?(F.updateQueue=z.updateQueue,F.memoizedState=z.memoizedState,F.lanes=z.lanes):(F.updateQueue=null,F.memoizedState=null)}var J=Hd(k);if(J!==null){J.flags&=-257,Wd(J,k,S,p,s),J.mode&1&&Ud(p,L,s),s=J,b=L;var ne=s.updateQueue;if(ne===null){var se=new Set;se.add(b),s.updateQueue=se}else ne.add(b);break e}else{if((s&1)===0){Ud(p,L,s),Tl();break e}b=Error(r(426))}}else if(Le&&S.mode&1){var Fe=Hd(k);if(Fe!==null){(Fe.flags&65536)===0&&(Fe.flags|=256),Wd(Fe,k,S,p,s),Ba(Ss(b,S));break e}}p=b=Ss(b,S),qe!==4&&(qe=2),Ti===null?Ti=[p]:Ti.push(p),p=k;do{switch(p.tag){case 3:p.flags|=65536,s&=-s,p.lanes|=s;var I=zd(p,b,s);hd(p,I);break e;case 1:S=b;var C=p.type,A=p.stateNode;if((p.flags&128)===0&&(typeof C.getDerivedStateFromError=="function"||A!==null&&typeof A.componentDidCatch=="function"&&(In===null||!In.has(A)))){p.flags|=65536,s&=-s,p.lanes|=s;var G=Fd(p,S,s);hd(p,G);break e}}p=p.return}while(p!==null)}jf(a)}catch(oe){s=oe,Ve===a&&a!==null&&(Ve=a=a.return);continue}break}while(!0)}function xf(){var n=Fr.current;return Fr.current=Or,n===null?Or:n}function Tl(){(qe===0||qe===3||qe===2)&&(qe=4),Ze===null||(qn&268435455)===0&&(Ur&268435455)===0||Ln(Ze,st)}function Qr(n,s){var a=je;je|=2;var u=xf();(Ze!==n||st!==s)&&(fn=null,Jn(n,s));do try{fv();break}catch(h){yf(n,h)}while(!0);if(Fa(),je=a,Fr.current=u,Ve!==null)throw Error(r(261));return Ze=null,st=0,qe}function fv(){for(;Ve!==null;)wf(Ve)}function hv(){for(;Ve!==null&&!Dp();)wf(Ve)}function wf(n){var s=bf(n.alternate,n,bt);n.memoizedProps=n.pendingProps,s===null?jf(n):Ve=s,yl.current=null}function jf(n){var s=n;do{var a=s.alternate;if(n=s.return,(s.flags&32768)===0){if(a=rv(a,s,bt),a!==null){Ve=a;return}}else{if(a=ov(a,s),a!==null){a.flags&=32767,Ve=a;return}if(n!==null)n.flags|=32768,n.subtreeFlags=0,n.deletions=null;else{qe=6,Ve=null;return}}if(s=s.sibling,s!==null){Ve=s;return}Ve=s=n}while(s!==null);qe===0&&(qe=5)}function Xn(n,s,a){var u=Ce,h=Mt.transition;try{Mt.transition=null,Ce=1,mv(n,s,a,u)}finally{Mt.transition=h,Ce=u}return null}function mv(n,s,a,u){do Ts();while(Mn!==null);if((je&6)!==0)throw Error(r(327));a=n.finishedWork;var h=n.finishedLanes;if(a===null)return null;if(n.finishedWork=null,n.finishedLanes=0,a===n.current)throw Error(r(177));n.callbackNode=null,n.callbackPriority=0;var p=a.lanes|a.childLanes;if(Qp(n,p),n===Ze&&(Ve=Ze=null,st=0),(a.subtreeFlags&2064)===0&&(a.flags&2064)===0||Wr||(Wr=!0,Cf(Xi,function(){return Ts(),null})),p=(a.flags&15990)!==0,(a.subtreeFlags&15990)!==0||p){p=Mt.transition,Mt.transition=null;var k=Ce;Ce=1;var S=je;je|=4,yl.current=null,lv(n,a),ff(a,n),Rg(Ta),rr=!!$a,Ta=$a=null,n.current=a,cv(a),Bp(),je=S,Ce=k,Mt.transition=p}else n.current=a;if(Wr&&(Wr=!1,Mn=n,Kr=h),p=n.pendingLanes,p===0&&(In=null),Up(a.stateNode),kt(n,ze()),s!==null)for(u=n.onRecoverableError,a=0;a<s.length;a++)h=s[a],u(h.value,{componentStack:h.stack,digest:h.digest});if(Hr)throw Hr=!1,n=jl,jl=null,n;return(Kr&1)!==0&&n.tag!==0&&Ts(),p=n.pendingLanes,(p&1)!==0?n===Nl?Ei++:(Ei=0,Nl=n):Ei=0,Cn(),null}function Ts(){if(Mn!==null){var n=cu(Kr),s=Mt.transition,a=Ce;try{if(Mt.transition=null,Ce=16>n?16:n,Mn===null)var u=!1;else{if(n=Mn,Mn=null,Kr=0,(je&6)!==0)throw Error(r(331));var h=je;for(je|=4,ee=n.current;ee!==null;){var p=ee,k=p.child;if((ee.flags&16)!==0){var S=p.deletions;if(S!==null){for(var b=0;b<S.length;b++){var L=S[b];for(ee=L;ee!==null;){var F=ee;switch(F.tag){case 0:case 11:case 15:Ci(8,F,p)}var W=F.child;if(W!==null)W.return=F,ee=W;else for(;ee!==null;){F=ee;var z=F.sibling,J=F.return;if(af(F),F===L){ee=null;break}if(z!==null){z.return=J,ee=z;break}ee=J}}}var ne=p.alternate;if(ne!==null){var se=ne.child;if(se!==null){ne.child=null;do{var Fe=se.sibling;se.sibling=null,se=Fe}while(se!==null)}}ee=p}}if((p.subtreeFlags&2064)!==0&&k!==null)k.return=p,ee=k;else e:for(;ee!==null;){if(p=ee,(p.flags&2048)!==0)switch(p.tag){case 0:case 11:case 15:Ci(9,p,p.return)}var I=p.sibling;if(I!==null){I.return=p.return,ee=I;break e}ee=p.return}}var C=n.current;for(ee=C;ee!==null;){k=ee;var A=k.child;if((k.subtreeFlags&2064)!==0&&A!==null)A.return=k,ee=A;else e:for(k=C;ee!==null;){if(S=ee,(S.flags&2048)!==0)try{switch(S.tag){case 0:case 11:case 15:zr(9,S)}}catch(oe){_e(S,S.return,oe)}if(S===k){ee=null;break e}var G=S.sibling;if(G!==null){G.return=S.return,ee=G;break e}ee=S.return}}if(je=h,Cn(),Kt&&typeof Kt.onPostCommitFiberRoot=="function")try{Kt.onPostCommitFiberRoot(Zi,n)}catch{}u=!0}return u}finally{Ce=a,Mt.transition=s}}return!1}function Nf(n,s,a){s=Ss(a,s),s=zd(n,s,1),n=Tn(n,s,1),s=ft(),n!==null&&(Zs(n,1,s),kt(n,s))}function _e(n,s,a){if(n.tag===3)Nf(n,n,a);else for(;s!==null;){if(s.tag===3){Nf(s,n,a);break}else if(s.tag===1){var u=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(In===null||!In.has(u))){n=Ss(a,n),n=Fd(s,n,1),s=Tn(s,n,1),n=ft(),s!==null&&(Zs(s,1,n),kt(s,n));break}}s=s.return}}function pv(n,s,a){var u=n.pingCache;u!==null&&u.delete(s),s=ft(),n.pingedLanes|=n.suspendedLanes&a,Ze===n&&(st&a)===a&&(qe===4||qe===3&&(st&130023424)===st&&500>ze()-wl?Jn(n,0):xl|=a),kt(n,s)}function Sf(n,s){s===0&&((n.mode&1)===0?s=1:(s=tr,tr<<=1,(tr&130023424)===0&&(tr=4194304)));var a=ft();n=cn(n,s),n!==null&&(Zs(n,s,a),kt(n,a))}function gv(n){var s=n.memoizedState,a=0;s!==null&&(a=s.retryLane),Sf(n,a)}function vv(n,s){var a=0;switch(n.tag){case 13:var u=n.stateNode,h=n.memoizedState;h!==null&&(a=h.retryLane);break;case 19:u=n.stateNode;break;default:throw Error(r(314))}u!==null&&u.delete(s),Sf(n,a)}var bf;bf=function(n,s,a){if(n!==null)if(n.memoizedProps!==s.pendingProps||mt.current)gt=!0;else{if((n.lanes&a)===0&&(s.flags&128)===0)return gt=!1,iv(n,s,a);gt=(n.flags&131072)!==0}else gt=!1,Le&&(s.flags&1048576)!==0&&sd(s,Nr,s.index);switch(s.lanes=0,s.tag){case 2:var u=s.type;Dr(n,s),n=s.pendingProps;var h=gs(s,rt.current);js(s,a),h=Xa(null,s,u,n,h,a);var p=Za();return s.flags|=1,typeof h=="object"&&h!==null&&typeof h.render=="function"&&h.$$typeof===void 0?(s.tag=1,s.memoizedState=null,s.updateQueue=null,pt(u)?(p=!0,xr(s)):p=!1,s.memoizedState=h.state!==null&&h.state!==void 0?h.state:null,Ka(s),h.updater=Pr,s.stateNode=h,h._reactInternals=s,rl(s,u,n,a),s=cl(null,s,u,!0,p,a)):(s.tag=0,Le&&p&&Oa(s),dt(null,s,h,a),s=s.child),s;case 16:u=s.elementType;e:{switch(Dr(n,s),n=s.pendingProps,h=u._init,u=h(u._payload),s.type=u,h=s.tag=yv(u),n=Bt(u,n),h){case 0:s=ll(null,s,u,n,a);break e;case 1:s=Yd(null,s,u,n,a);break e;case 11:s=Kd(null,s,u,n,a);break e;case 14:s=Vd(null,s,u,Bt(u.type,n),a);break e}throw Error(r(306,u,""))}return s;case 0:return u=s.type,h=s.pendingProps,h=s.elementType===u?h:Bt(u,h),ll(n,s,u,h,a);case 1:return u=s.type,h=s.pendingProps,h=s.elementType===u?h:Bt(u,h),Yd(n,s,u,h,a);case 3:e:{if(Jd(s),n===null)throw Error(r(387));u=s.pendingProps,p=s.memoizedState,h=p.element,fd(n,s),Er(s,u,null,a);var k=s.memoizedState;if(u=k.element,p.isDehydrated)if(p={element:u,isDehydrated:!1,cache:k.cache,pendingSuspenseBoundaries:k.pendingSuspenseBoundaries,transitions:k.transitions},s.updateQueue.baseState=p,s.memoizedState=p,s.flags&256){h=Ss(Error(r(423)),s),s=Xd(n,s,u,a,h);break e}else if(u!==h){h=Ss(Error(r(424)),s),s=Xd(n,s,u,a,h);break e}else for(St=Nn(s.stateNode.containerInfo.firstChild),Nt=s,Le=!0,Dt=null,a=ud(s,null,u,a),s.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(ys(),u===h){s=dn(n,s,a);break e}dt(n,s,u,a)}s=s.child}return s;case 5:return pd(s),n===null&&Da(s),u=s.type,h=s.pendingProps,p=n!==null?n.memoizedProps:null,k=h.children,Ea(u,h)?k=null:p!==null&&Ea(u,p)&&(s.flags|=32),qd(n,s),dt(n,s,k,a),s.child;case 6:return n===null&&Da(s),null;case 13:return Zd(n,s,a);case 4:return Va(s,s.stateNode.containerInfo),u=s.pendingProps,n===null?s.child=xs(s,null,u,a):dt(n,s,u,a),s.child;case 11:return u=s.type,h=s.pendingProps,h=s.elementType===u?h:Bt(u,h),Kd(n,s,u,h,a);case 7:return dt(n,s,s.pendingProps,a),s.child;case 8:return dt(n,s,s.pendingProps.children,a),s.child;case 12:return dt(n,s,s.pendingProps.children,a),s.child;case 10:e:{if(u=s.type._context,h=s.pendingProps,p=s.memoizedProps,k=h.value,Te(Cr,u._currentValue),u._currentValue=k,p!==null)if(_t(p.value,k)){if(p.children===h.children&&!mt.current){s=dn(n,s,a);break e}}else for(p=s.child,p!==null&&(p.return=s);p!==null;){var S=p.dependencies;if(S!==null){k=p.child;for(var b=S.firstContext;b!==null;){if(b.context===u){if(p.tag===1){b=un(-1,a&-a),b.tag=2;var L=p.updateQueue;if(L!==null){L=L.shared;var F=L.pending;F===null?b.next=b:(b.next=F.next,F.next=b),L.pending=b}}p.lanes|=a,b=p.alternate,b!==null&&(b.lanes|=a),Ha(p.return,a,s),S.lanes|=a;break}b=b.next}}else if(p.tag===10)k=p.type===s.type?null:p.child;else if(p.tag===18){if(k=p.return,k===null)throw Error(r(341));k.lanes|=a,S=k.alternate,S!==null&&(S.lanes|=a),Ha(k,a,s),k=p.sibling}else k=p.child;if(k!==null)k.return=p;else for(k=p;k!==null;){if(k===s){k=null;break}if(p=k.sibling,p!==null){p.return=k.return,k=p;break}k=k.return}p=k}dt(n,s,h.children,a),s=s.child}return s;case 9:return h=s.type,u=s.pendingProps.children,js(s,a),h=Et(h),u=u(h),s.flags|=1,dt(n,s,u,a),s.child;case 14:return u=s.type,h=Bt(u,s.pendingProps),h=Bt(u.type,h),Vd(n,s,u,h,a);case 15:return Gd(n,s,s.type,s.pendingProps,a);case 17:return u=s.type,h=s.pendingProps,h=s.elementType===u?h:Bt(u,h),Dr(n,s),s.tag=1,pt(u)?(n=!0,xr(s)):n=!1,js(s,a),Dd(s,u,h),rl(s,u,h,a),cl(null,s,u,!0,n,a);case 19:return tf(n,s,a);case 22:return Qd(n,s,a)}throw Error(r(156,s.tag))};function Cf(n,s){return iu(n,s)}function kv(n,s,a,u){this.tag=n,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=u,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function At(n,s,a,u){return new kv(n,s,a,u)}function El(n){return n=n.prototype,!(!n||!n.isReactComponent)}function yv(n){if(typeof n=="function")return El(n)?1:0;if(n!=null){if(n=n.$$typeof,n===be)return 11;if(n===Y)return 14}return 2}function Rn(n,s){var a=n.alternate;return a===null?(a=At(n.tag,s,n.key,n.mode),a.elementType=n.elementType,a.type=n.type,a.stateNode=n.stateNode,a.alternate=n,n.alternate=a):(a.pendingProps=s,a.type=n.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=n.flags&14680064,a.childLanes=n.childLanes,a.lanes=n.lanes,a.child=n.child,a.memoizedProps=n.memoizedProps,a.memoizedState=n.memoizedState,a.updateQueue=n.updateQueue,s=n.dependencies,a.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},a.sibling=n.sibling,a.index=n.index,a.ref=n.ref,a}function qr(n,s,a,u,h,p){var k=2;if(u=n,typeof n=="function")El(n)&&(k=1);else if(typeof n=="string")k=5;else e:switch(n){case q:return Zn(a.children,h,p,s);case re:k=8,h|=8;break;case V:return n=At(12,a,s,h|2),n.elementType=V,n.lanes=p,n;case te:return n=At(13,a,s,h),n.elementType=te,n.lanes=p,n;case P:return n=At(19,a,s,h),n.elementType=P,n.lanes=p,n;case Z:return Yr(a,h,p,s);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case ge:k=10;break e;case Re:k=9;break e;case be:k=11;break e;case Y:k=14;break e;case ae:k=16,u=null;break e}throw Error(r(130,n==null?n:typeof n,""))}return s=At(k,a,s,h),s.elementType=n,s.type=u,s.lanes=p,s}function Zn(n,s,a,u){return n=At(7,n,u,s),n.lanes=a,n}function Yr(n,s,a,u){return n=At(22,n,u,s),n.elementType=Z,n.lanes=a,n.stateNode={isHidden:!1},n}function Il(n,s,a){return n=At(6,n,null,s),n.lanes=a,n}function Ml(n,s,a){return s=At(4,n.children!==null?n.children:[],n.key,s),s.lanes=a,s.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},s}function xv(n,s,a,u,h){this.tag=s,this.containerInfo=n,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=ia(0),this.expirationTimes=ia(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ia(0),this.identifierPrefix=u,this.onRecoverableError=h,this.mutableSourceEagerHydrationData=null}function Al(n,s,a,u,h,p,k,S,b){return n=new xv(n,s,a,S,b),s===1?(s=1,p===!0&&(s|=8)):s=0,p=At(3,null,null,s),n.current=p,p.stateNode=n,p.memoizedState={element:u,isDehydrated:a,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ka(p),n}function wv(n,s,a){var u=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:D,key:u==null?null:""+u,children:n,containerInfo:s,implementation:a}}function $f(n){if(!n)return bn;n=n._reactInternals;e:{if(Fn(n)!==n||n.tag!==1)throw Error(r(170));var s=n;do{switch(s.tag){case 3:s=s.stateNode.context;break e;case 1:if(pt(s.type)){s=s.stateNode.__reactInternalMemoizedMergedChildContext;break e}}s=s.return}while(s!==null);throw Error(r(171))}if(n.tag===1){var a=n.type;if(pt(a))return ed(n,a,s)}return s}function Tf(n,s,a,u,h,p,k,S,b){return n=Al(a,u,!0,n,h,p,k,S,b),n.context=$f(null),a=n.current,u=ft(),h=An(a),p=un(u,h),p.callback=s??null,Tn(a,p,h),n.current.lanes=h,Zs(n,h,u),kt(n,u),n}function Jr(n,s,a,u){var h=s.current,p=ft(),k=An(h);return a=$f(a),s.context===null?s.context=a:s.pendingContext=a,s=un(p,k),s.payload={element:n},u=u===void 0?null:u,u!==null&&(s.callback=u),n=Tn(h,s,k),n!==null&&(Ut(n,h,k,p),Tr(n,h,k)),k}function Xr(n){if(n=n.current,!n.child)return null;switch(n.child.tag){case 5:return n.child.stateNode;default:return n.child.stateNode}}function Ef(n,s){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var a=n.retryLane;n.retryLane=a!==0&&a<s?a:s}}function Ll(n,s){Ef(n,s),(n=n.alternate)&&Ef(n,s)}function jv(){return null}var If=typeof reportError=="function"?reportError:function(n){console.error(n)};function Rl(n){this._internalRoot=n}Zr.prototype.render=Rl.prototype.render=function(n){var s=this._internalRoot;if(s===null)throw Error(r(409));Jr(n,s,null,null)},Zr.prototype.unmount=Rl.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var s=n.containerInfo;Yn(function(){Jr(null,n,null,null)}),s[rn]=null}};function Zr(n){this._internalRoot=n}Zr.prototype.unstable_scheduleHydration=function(n){if(n){var s=fu();n={blockedOn:null,target:n,priority:s};for(var a=0;a<xn.length&&s!==0&&s<xn[a].priority;a++);xn.splice(a,0,n),a===0&&pu(n)}};function Ol(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function eo(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11&&(n.nodeType!==8||n.nodeValue!==" react-mount-point-unstable "))}function Mf(){}function Nv(n,s,a,u,h){if(h){if(typeof u=="function"){var p=u;u=function(){var L=Xr(k);p.call(L)}}var k=Tf(s,u,n,0,null,!1,!1,"",Mf);return n._reactRootContainer=k,n[rn]=k.current,hi(n.nodeType===8?n.parentNode:n),Yn(),k}for(;h=n.lastChild;)n.removeChild(h);if(typeof u=="function"){var S=u;u=function(){var L=Xr(b);S.call(L)}}var b=Al(n,0,!1,null,null,!1,!1,"",Mf);return n._reactRootContainer=b,n[rn]=b.current,hi(n.nodeType===8?n.parentNode:n),Yn(function(){Jr(s,b,a,u)}),b}function to(n,s,a,u,h){var p=a._reactRootContainer;if(p){var k=p;if(typeof h=="function"){var S=h;h=function(){var b=Xr(k);S.call(b)}}Jr(s,k,n,h)}else k=Nv(a,s,n,h,u);return Xr(k)}uu=function(n){switch(n.tag){case 3:var s=n.stateNode;if(s.current.memoizedState.isDehydrated){var a=Xs(s.pendingLanes);a!==0&&(ra(s,a|1),kt(s,ze()),(je&6)===0&&($s=ze()+500,Cn()))}break;case 13:Yn(function(){var u=cn(n,1);if(u!==null){var h=ft();Ut(u,n,1,h)}}),Ll(n,1)}},oa=function(n){if(n.tag===13){var s=cn(n,134217728);if(s!==null){var a=ft();Ut(s,n,134217728,a)}Ll(n,134217728)}},du=function(n){if(n.tag===13){var s=An(n),a=cn(n,s);if(a!==null){var u=ft();Ut(a,n,s,u)}Ll(n,s)}},fu=function(){return Ce},hu=function(n,s){var a=Ce;try{return Ce=n,s()}finally{Ce=a}},Xo=function(n,s,a){switch(s){case"input":if(Wo(n,a),s=a.name,a.type==="radio"&&s!=null){for(a=n;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll("input[name="+JSON.stringify(""+s)+'][type="radio"]'),s=0;s<a.length;s++){var u=a[s];if(u!==n&&u.form===n.form){var h=kr(u);if(!h)throw Error(r(90));_c(u),Wo(u,h)}}}break;case"textarea":Uc(n,a);break;case"select":s=a.value,s!=null&&is(n,!!a.multiple,s,!1)}},Jc=Cl,Xc=Yn;var Sv={usingClientEntryPoint:!1,Events:[gi,ms,kr,qc,Yc,Cl]},Ii={findFiberByHostInstance:Un,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},bv={bundleType:Ii.bundleType,version:Ii.version,rendererPackageName:Ii.rendererPackageName,rendererConfig:Ii.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:X.ReactCurrentDispatcher,findHostInstanceByFiber:function(n){return n=nu(n),n===null?null:n.stateNode},findFiberByHostInstance:Ii.findFiberByHostInstance||jv,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 no=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!no.isDisabled&&no.supportsFiber)try{Zi=no.inject(bv),Kt=no}catch{}}return yt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Sv,yt.createPortal=function(n,s){var a=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Ol(s))throw Error(r(200));return wv(n,s,null,a)},yt.createRoot=function(n,s){if(!Ol(n))throw Error(r(299));var a=!1,u="",h=If;return s!=null&&(s.unstable_strictMode===!0&&(a=!0),s.identifierPrefix!==void 0&&(u=s.identifierPrefix),s.onRecoverableError!==void 0&&(h=s.onRecoverableError)),s=Al(n,1,!1,null,null,a,!1,u,h),n[rn]=s.current,hi(n.nodeType===8?n.parentNode:n),new Rl(s)},yt.findDOMNode=function(n){if(n==null)return null;if(n.nodeType===1)return n;var s=n._reactInternals;if(s===void 0)throw typeof n.render=="function"?Error(r(188)):(n=Object.keys(n).join(","),Error(r(268,n)));return n=nu(s),n=n===null?null:n.stateNode,n},yt.flushSync=function(n){return Yn(n)},yt.hydrate=function(n,s,a){if(!eo(s))throw Error(r(200));return to(null,n,s,!0,a)},yt.hydrateRoot=function(n,s,a){if(!Ol(n))throw Error(r(405));var u=a!=null&&a.hydratedSources||null,h=!1,p="",k=If;if(a!=null&&(a.unstable_strictMode===!0&&(h=!0),a.identifierPrefix!==void 0&&(p=a.identifierPrefix),a.onRecoverableError!==void 0&&(k=a.onRecoverableError)),s=Tf(s,null,n,1,a??null,h,!1,p,k),n[rn]=s.current,hi(n),u)for(n=0;n<u.length;n++)a=u[n],h=a._getVersion,h=h(a._source),s.mutableSourceEagerHydrationData==null?s.mutableSourceEagerHydrationData=[a,h]:s.mutableSourceEagerHydrationData.push(a,h);return new Zr(s)},yt.render=function(n,s,a){if(!eo(s))throw Error(r(200));return to(null,n,s,!1,a)},yt.unmountComponentAtNode=function(n){if(!eo(n))throw Error(r(40));return n._reactRootContainer?(Yn(function(){to(null,null,n,!1,function(){n._reactRootContainer=null,n[rn]=null})}),!0):!1},yt.unstable_batchedUpdates=Cl,yt.unstable_renderSubtreeIntoContainer=function(n,s,a,u){if(!eo(a))throw Error(r(200));if(n==null||n._reactInternals===void 0)throw Error(r(38));return to(n,s,a,!1,u)},yt.version="18.3.1-next-f1338f8080-20240426",yt}var Bf;function em(){if(Bf)return Dl.exports;Bf=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Dl.exports=Rv(),Dl.exports}var zf;function Ov(){if(zf)return so;zf=1;var e=em();return so.createRoot=e.createRoot,so.hydrateRoot=e.hydrateRoot,so}var Pv=Ov(),x=uc();const As="teamtrail",ve={slug:As,name:"Teamtrail",category:"The trail map for AI coding agents",tagline:"You pick the destination. Your agents walk the trail.",assistant:{name:"Scout"},labelPrefix:As,dataDir:`.${As}`,apiPrefix:`/__${As}`,noRegisterEnv:`${As.toUpperCase()}_NO_REGISTER`},Eo=`${As}.prefs`,Io=e=>`${ve.labelPrefix}:${e}`,dc=Io("map"),fc=Io("hitl"),_v=e=>e==="task"||e==="execute",hc=Io("plan-only"),vo=["research","prototype","junction","task","execute"],Mo=[...vo,"review"],ns="plan+execute",Dv=["verifying","rework","blocked"],mc=["off","checks","checks+review","checks+review+human"],tm=e=>mc.find(t=>t===e);function Wi(e){return e.type==="junction"||e.type==="prototype"?"hitl":e.type==="research"?"afk":e.hitl?"hitl":"afk"}const Bv=["task","execute"];function nm(e,t,r=ns){return e.state==="closed"?e.closeReason==="not_planned"?"out-of-scope":"decided":e.status==="verifying"?"verifying":e.status==="blocked"?"held":e.assignee?"claimed":e.status==="rework"?"rework":r==="plan-only"&&e.type==="execute"?"parked":e.blockedBy.some(l=>{var c;return((c=t.get(l))==null?void 0:c.state)==="open"})?"blocked":"frontier"}function Fs(e,t=ns){const r=new Map(e.map(o=>[o.id,o]));return new Map(e.map(o=>[o.id,nm(o,r,t)]))}const Ue=200,Ge=56;function Ff(e,t="LR",r=ns){var be;const o=t==="LR"?330:124,l=t==="LR"?112:262,c=Fs(e,r),d=new Map(e.map(te=>[te.id,te])),f=new Map,g=new Set,m=te=>{if(f.has(te))return f.get(te);if(g.has(te))return 0;g.add(te);const P=d.get(te),Y=P&&P.blockedBy.length?1+Math.max(...P.blockedBy.filter(ae=>d.has(ae)).map(m),-1):0;return g.delete(te),f.set(te,Y),Y},v=e.filter(te=>c.get(te.id)!=="out-of-scope"),y=e.filter(te=>c.get(te.id)==="out-of-scope"),w=[];for(const te of v)(w[be=m(te.id)]??(w[be]=[])).push(te);const j=[],$=new Map;let N=0;w.forEach(te=>{te&&(te.sort((P,Y)=>{const ae=Z=>{const U=Z.blockedBy.map(B=>$.get(B)).filter(B=>B!==void 0);return U.length?U.reduce((B,H)=>B+H,0)/U.length:Z.createdAt/1e12};return ae(P)-ae(Y)||P.createdAt-Y.createdAt}),N=Math.max(N,te.length),te.forEach((P,Y)=>$.set(P.id,Y)))}),w.forEach((te,P)=>{if(!te)return;const Y=(N-te.length)*l/2;te.forEach((ae,Z)=>{const U=P*o,B=Y+Z*l;j.push({ticket:ae,state:c.get(ae.id),layer:P,x:t==="LR"?U:B,y:t==="LR"?B:U})})});const M=Math.max(w.length,1)*o-(o-(t==="LR"?Ue:Ge)),R=Math.max(N,1)*l-(l-(t==="LR"?Ge:Ue)),O=t==="LR"?M:R,X=t==="LR"?R:M,ie=X+54,D=Math.max(1,Math.floor((O+24)/(Ue+24)));y.forEach((te,P)=>{j.push({ticket:te,state:"out-of-scope",layer:-1,x:P%D*(Ue+24),y:ie+Math.floor(P/D)*(Ge+16)})});const q=[],re=new Map(j.map(te=>[te.ticket.id,te]));for(const te of j)for(const P of te.ticket.blockedBy){const Y=re.get(P);Y&&q.push({from:Y,to:te})}const V=Math.ceil(y.length/D),ge=Math.max(O,Math.min(y.length,D)*(Ue+24)-24),Re=y.length?ie+V*(Ge+16)-16:X;return{direction:t,nodes:j,edges:q,width:ge,graphH:X,quarantineY:ie,height:Re,quarantineH:V*(Ge+16)+24}}const sm=["fast","balanced","strongest"],im=e=>sm.includes(e),pc={research:"fast",task:"balanced",execute:"balanced",junction:"strongest",prototype:"strongest",review:"strongest"};function zv(e,t){var r,o;return((o=(r=t.modelMatching)==null?void 0:r.tiers)==null?void 0:o[e.type])??pc[e.type]}function Fv(e){return Object.fromEntries(Mo.map(t=>[t,zv({type:t},e)]))}const Uv=["holding","challenged","invalidated","confirmed"],Hv=e=>Uv.includes(e),rm=ve.labelPrefix,Wv=new RegExp(`^-\\s+(?:\\[([a-z]+)\\]\\s+)?(.*?)\\s*(?:<!-- ${rm}:asm (\\{.*\\}) -->)?\\s*$`),Kv=1e3,Vv=e=>e.replace(/--/g,"-\\u002d"),Gv=e=>e.replace(/\s*\n\s*/g," ").trim();function Qv(e){const t={id:e.id,tickets:e.tickets,...e.source?{source:e.source}:{},...e.challenge?{challenge:{...e.challenge,evidence:e.challenge.evidence.slice(0,Kv)}}:{},...e.decidedBy?{decidedBy:e.decidedBy}:{}};return`- [${e.status}] ${Gv(e.text)} <!-- ${rm}:asm ${Vv(JSON.stringify(t))} -->`}function qv(e){const t=e.map(Yv);let r=Math.max(0,...t.map(o=>Xv(o.id)))+1;return t.map(o=>o.id?o:{...o,id:`S-${r++}`})}function Yv(e){const t=e.match(Wv),r=t==null?void 0:t[1],o=(t==null?void 0:t[2])??e.replace(/^-\s+/,""),l=Jv(t==null?void 0:t[3]);return{id:l.id??"",text:o,status:Hv(r)?r:"holding",tickets:Array.isArray(l.tickets)?l.tickets.map(String):[],...l.source?{source:l.source}:{},...l.challenge?{challenge:l.challenge}:{},...l.decidedBy?{decidedBy:l.decidedBy}:{}}}function Jv(e){if(!e)return{};try{const t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}function Xv(e){const t=e==null?void 0:e.match(/^S-(\d+)$/);return t?Number(t[1]):0}const om=[["destination","Destination"],["notes","Notes"],["assumptions","Assumptions"],["decisions","Decisions so far"],["unspecified","Not yet specified"],["outOfScope","Out of scope"]],Zv=Object.fromEntries(om),ek=/^-\s+(?:\[?([#A-Z0-9-]+)\]?:?\s+)?(.*)$/;function tk(e){var o;const t=l=>l.length?l.map(c=>`- ${c}`).join(`
|
|
40
|
+
`+p.stack}return{value:n,source:s,stack:h,digest:null}}function ol(n,s,a){return{value:n,source:null,stack:a??null,digest:s??null}}function al(n,s){try{console.error(s.value)}catch(a){setTimeout(function(){throw a})}}var tv=typeof WeakMap=="function"?WeakMap:Map;function zd(n,s,a){a=un(-1,a),a.tag=3,a.payload={element:null};var u=s.value;return a.callback=function(){Hr||(Hr=!0,jl=u),al(n,s)},a}function Fd(n,s,a){a=un(-1,a),a.tag=3;var u=n.type.getDerivedStateFromError;if(typeof u=="function"){var h=s.value;a.payload=function(){return u(h)},a.callback=function(){al(n,s)}}var p=n.stateNode;return p!==null&&typeof p.componentDidCatch=="function"&&(a.callback=function(){al(n,s),typeof u!="function"&&(In===null?In=new Set([this]):In.add(this));var k=s.stack;this.componentDidCatch(s.value,{componentStack:k!==null?k:""})}),a}function Ud(n,s,a){var u=n.pingCache;if(u===null){u=n.pingCache=new tv;var h=new Set;u.set(s,h)}else h=u.get(s),h===void 0&&(h=new Set,u.set(s,h));h.has(a)||(h.add(a),n=pv.bind(null,n,s,a),s.then(n,n))}function Hd(n){do{var s;if((s=n.tag===13)&&(s=n.memoizedState,s=s!==null?s.dehydrated!==null:!0),s)return n;n=n.return}while(n!==null);return null}function Wd(n,s,a,u,h){return(n.mode&1)===0?(n===s?n.flags|=65536:(n.flags|=128,a.flags|=131072,a.flags&=-52805,a.tag===1&&(a.alternate===null?a.tag=17:(s=un(-1,1),s.tag=2,Tn(a,s,1))),a.lanes|=1),n):(n.flags|=65536,n.lanes=h,n)}var nv=X.ReactCurrentOwner,gt=!1;function dt(n,s,a,u){s.child=n===null?ud(s,null,a,u):xs(s,n.child,a,u)}function Kd(n,s,a,u,h){a=a.render;var p=s.ref;return js(s,h),u=Xa(n,s,a,u,p,h),a=Za(),n!==null&&!gt?(s.updateQueue=n.updateQueue,s.flags&=-2053,n.lanes&=~h,dn(n,s,h)):(Le&&a&&Oa(s),s.flags|=1,dt(n,s,u,h),s.child)}function Vd(n,s,a,u,h){if(n===null){var p=a.type;return typeof p=="function"&&!El(p)&&p.defaultProps===void 0&&a.compare===null&&a.defaultProps===void 0?(s.tag=15,s.type=p,Gd(n,s,p,u,h)):(n=qr(a.type,null,u,s,s.mode,h),n.ref=s.ref,n.return=s,s.child=n)}if(p=n.child,(n.lanes&h)===0){var k=p.memoizedProps;if(a=a.compare,a=a!==null?a:ui,a(k,u)&&n.ref===s.ref)return dn(n,s,h)}return s.flags|=1,n=Rn(p,u),n.ref=s.ref,n.return=s,s.child=n}function Gd(n,s,a,u,h){if(n!==null){var p=n.memoizedProps;if(ui(p,u)&&n.ref===s.ref)if(gt=!1,s.pendingProps=u=p,(n.lanes&h)!==0)(n.flags&131072)!==0&&(gt=!0);else return s.lanes=n.lanes,dn(n,s,h)}return ll(n,s,a,u,h)}function Qd(n,s,a){var u=s.pendingProps,h=u.children,p=n!==null?n.memoizedState:null;if(u.mode==="hidden")if((s.mode&1)===0)s.memoizedState={baseLanes:0,cachePool:null,transitions:null},Te(Cs,bt),bt|=a;else{if((a&1073741824)===0)return n=p!==null?p.baseLanes|a:a,s.lanes=s.childLanes=1073741824,s.memoizedState={baseLanes:n,cachePool:null,transitions:null},s.updateQueue=null,Te(Cs,bt),bt|=n,null;s.memoizedState={baseLanes:0,cachePool:null,transitions:null},u=p!==null?p.baseLanes:a,Te(Cs,bt),bt|=u}else p!==null?(u=p.baseLanes|a,s.memoizedState=null):u=a,Te(Cs,bt),bt|=u;return dt(n,s,h,a),s.child}function qd(n,s){var a=s.ref;(n===null&&a!==null||n!==null&&n.ref!==a)&&(s.flags|=512,s.flags|=2097152)}function ll(n,s,a,u,h){var p=pt(a)?Hn:rt.current;return p=gs(s,p),js(s,h),a=Xa(n,s,a,u,p,h),u=Za(),n!==null&&!gt?(s.updateQueue=n.updateQueue,s.flags&=-2053,n.lanes&=~h,dn(n,s,h)):(Le&&u&&Oa(s),s.flags|=1,dt(n,s,a,h),s.child)}function Yd(n,s,a,u,h){if(pt(a)){var p=!0;xr(s)}else p=!1;if(js(s,h),s.stateNode===null)Dr(n,s),Dd(s,a,u),rl(s,a,u,h),u=!0;else if(n===null){var k=s.stateNode,S=s.memoizedProps;k.props=S;var b=k.context,L=a.contextType;typeof L=="object"&&L!==null?L=Et(L):(L=pt(a)?Hn:rt.current,L=gs(s,L));var z=a.getDerivedStateFromProps,W=typeof z=="function"||typeof k.getSnapshotBeforeUpdate=="function";W||typeof k.UNSAFE_componentWillReceiveProps!="function"&&typeof k.componentWillReceiveProps!="function"||(S!==u||b!==L)&&Bd(s,k,u,L),$n=!1;var B=s.memoizedState;k.state=B,Er(s,u,k,h),b=s.memoizedState,S!==u||B!==b||mt.current||$n?(typeof z=="function"&&(il(s,a,z,u),b=s.memoizedState),(S=$n||_d(s,a,S,u,B,b,L))?(W||typeof k.UNSAFE_componentWillMount!="function"&&typeof k.componentWillMount!="function"||(typeof k.componentWillMount=="function"&&k.componentWillMount(),typeof k.UNSAFE_componentWillMount=="function"&&k.UNSAFE_componentWillMount()),typeof k.componentDidMount=="function"&&(s.flags|=4194308)):(typeof k.componentDidMount=="function"&&(s.flags|=4194308),s.memoizedProps=u,s.memoizedState=b),k.props=u,k.state=b,k.context=L,u=S):(typeof k.componentDidMount=="function"&&(s.flags|=4194308),u=!1)}else{k=s.stateNode,fd(n,s),S=s.memoizedProps,L=s.type===s.elementType?S:Bt(s.type,S),k.props=L,W=s.pendingProps,B=k.context,b=a.contextType,typeof b=="object"&&b!==null?b=Et(b):(b=pt(a)?Hn:rt.current,b=gs(s,b));var J=a.getDerivedStateFromProps;(z=typeof J=="function"||typeof k.getSnapshotBeforeUpdate=="function")||typeof k.UNSAFE_componentWillReceiveProps!="function"&&typeof k.componentWillReceiveProps!="function"||(S!==W||B!==b)&&Bd(s,k,u,b),$n=!1,B=s.memoizedState,k.state=B,Er(s,u,k,h);var ne=s.memoizedState;S!==W||B!==ne||mt.current||$n?(typeof J=="function"&&(il(s,a,J,u),ne=s.memoizedState),(L=$n||_d(s,a,L,u,B,ne,b)||!1)?(z||typeof k.UNSAFE_componentWillUpdate!="function"&&typeof k.componentWillUpdate!="function"||(typeof k.componentWillUpdate=="function"&&k.componentWillUpdate(u,ne,b),typeof k.UNSAFE_componentWillUpdate=="function"&&k.UNSAFE_componentWillUpdate(u,ne,b)),typeof k.componentDidUpdate=="function"&&(s.flags|=4),typeof k.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof k.componentDidUpdate!="function"||S===n.memoizedProps&&B===n.memoizedState||(s.flags|=4),typeof k.getSnapshotBeforeUpdate!="function"||S===n.memoizedProps&&B===n.memoizedState||(s.flags|=1024),s.memoizedProps=u,s.memoizedState=ne),k.props=u,k.state=ne,k.context=b,u=L):(typeof k.componentDidUpdate!="function"||S===n.memoizedProps&&B===n.memoizedState||(s.flags|=4),typeof k.getSnapshotBeforeUpdate!="function"||S===n.memoizedProps&&B===n.memoizedState||(s.flags|=1024),u=!1)}return cl(n,s,a,u,p,h)}function cl(n,s,a,u,h,p){qd(n,s);var k=(s.flags&128)!==0;if(!u&&!k)return h&&td(s,a,!1),dn(n,s,p);u=s.stateNode,nv.current=s;var S=k&&typeof a.getDerivedStateFromError!="function"?null:u.render();return s.flags|=1,n!==null&&k?(s.child=xs(s,n.child,null,p),s.child=xs(s,null,S,p)):dt(n,s,S,p),s.memoizedState=u.state,h&&td(s,a,!0),s.child}function Jd(n){var s=n.stateNode;s.pendingContext?Zu(n,s.pendingContext,s.pendingContext!==s.context):s.context&&Zu(n,s.context,!1),Va(n,s.containerInfo)}function Xd(n,s,a,u,h){return ys(),Ba(h),s.flags|=256,dt(n,s,a,u),s.child}var ul={dehydrated:null,treeContext:null,retryLane:0};function dl(n){return{baseLanes:n,cachePool:null,transitions:null}}function Zd(n,s,a){var u=s.pendingProps,h=Oe.current,p=!1,k=(s.flags&128)!==0,S;if((S=k)||(S=n!==null&&n.memoizedState===null?!1:(h&2)!==0),S?(p=!0,s.flags&=-129):(n===null||n.memoizedState!==null)&&(h|=1),Te(Oe,h&1),n===null)return Da(s),n=s.memoizedState,n!==null&&(n=n.dehydrated,n!==null)?((s.mode&1)===0?s.lanes=1:n.data==="$!"?s.lanes=8:s.lanes=1073741824,null):(k=u.children,n=u.fallback,p?(u=s.mode,p=s.child,k={mode:"hidden",children:k},(u&1)===0&&p!==null?(p.childLanes=0,p.pendingProps=k):p=Yr(k,u,0,null),n=Zn(n,u,a,null),p.return=s,n.return=s,p.sibling=n,s.child=p,s.child.memoizedState=dl(a),s.memoizedState=ul,n):fl(s,k));if(h=n.memoizedState,h!==null&&(S=h.dehydrated,S!==null))return sv(n,s,k,u,S,h,a);if(p){p=u.fallback,k=s.mode,h=n.child,S=h.sibling;var b={mode:"hidden",children:u.children};return(k&1)===0&&s.child!==h?(u=s.child,u.childLanes=0,u.pendingProps=b,s.deletions=null):(u=Rn(h,b),u.subtreeFlags=h.subtreeFlags&14680064),S!==null?p=Rn(S,p):(p=Zn(p,k,a,null),p.flags|=2),p.return=s,u.return=s,u.sibling=p,s.child=u,u=p,p=s.child,k=n.child.memoizedState,k=k===null?dl(a):{baseLanes:k.baseLanes|a,cachePool:null,transitions:k.transitions},p.memoizedState=k,p.childLanes=n.childLanes&~a,s.memoizedState=ul,u}return p=n.child,n=p.sibling,u=Rn(p,{mode:"visible",children:u.children}),(s.mode&1)===0&&(u.lanes=a),u.return=s,u.sibling=null,n!==null&&(a=s.deletions,a===null?(s.deletions=[n],s.flags|=16):a.push(n)),s.child=u,s.memoizedState=null,u}function fl(n,s){return s=Yr({mode:"visible",children:s},n.mode,0,null),s.return=n,n.child=s}function _r(n,s,a,u){return u!==null&&Ba(u),xs(s,n.child,null,a),n=fl(s,s.pendingProps.children),n.flags|=2,s.memoizedState=null,n}function sv(n,s,a,u,h,p,k){if(a)return s.flags&256?(s.flags&=-257,u=ol(Error(r(422))),_r(n,s,k,u)):s.memoizedState!==null?(s.child=n.child,s.flags|=128,null):(p=u.fallback,h=s.mode,u=Yr({mode:"visible",children:u.children},h,0,null),p=Zn(p,h,k,null),p.flags|=2,u.return=s,p.return=s,u.sibling=p,s.child=u,(s.mode&1)!==0&&xs(s,n.child,null,k),s.child.memoizedState=dl(k),s.memoizedState=ul,p);if((s.mode&1)===0)return _r(n,s,k,null);if(h.data==="$!"){if(u=h.nextSibling&&h.nextSibling.dataset,u)var S=u.dgst;return u=S,p=Error(r(419)),u=ol(p,u,void 0),_r(n,s,k,u)}if(S=(k&n.childLanes)!==0,gt||S){if(u=Ze,u!==null){switch(k&-k){case 4:h=2;break;case 16:h=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:h=32;break;case 536870912:h=268435456;break;default:h=0}h=(h&(u.suspendedLanes|k))!==0?0:h,h!==0&&h!==p.retryLane&&(p.retryLane=h,cn(n,h),Ut(u,n,h,-1))}return Tl(),u=ol(Error(r(421))),_r(n,s,k,u)}return h.data==="$?"?(s.flags|=128,s.child=n.child,s=gv.bind(null,n),h._reactRetry=s,null):(n=p.treeContext,St=Nn(h.nextSibling),Nt=s,Le=!0,Dt=null,n!==null&&($t[Tt++]=an,$t[Tt++]=ln,$t[Tt++]=Wn,an=n.id,ln=n.overflow,Wn=s),s=fl(s,u.children),s.flags|=4096,s)}function ef(n,s,a){n.lanes|=s;var u=n.alternate;u!==null&&(u.lanes|=s),Ha(n.return,s,a)}function hl(n,s,a,u,h){var p=n.memoizedState;p===null?n.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:u,tail:a,tailMode:h}:(p.isBackwards=s,p.rendering=null,p.renderingStartTime=0,p.last=u,p.tail=a,p.tailMode=h)}function tf(n,s,a){var u=s.pendingProps,h=u.revealOrder,p=u.tail;if(dt(n,s,u.children,a),u=Oe.current,(u&2)!==0)u=u&1|2,s.flags|=128;else{if(n!==null&&(n.flags&128)!==0)e:for(n=s.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&ef(n,a,s);else if(n.tag===19)ef(n,a,s);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===s)break e;for(;n.sibling===null;){if(n.return===null||n.return===s)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}u&=1}if(Te(Oe,u),(s.mode&1)===0)s.memoizedState=null;else switch(h){case"forwards":for(a=s.child,h=null;a!==null;)n=a.alternate,n!==null&&Ir(n)===null&&(h=a),a=a.sibling;a=h,a===null?(h=s.child,s.child=null):(h=a.sibling,a.sibling=null),hl(s,!1,h,a,p);break;case"backwards":for(a=null,h=s.child,s.child=null;h!==null;){if(n=h.alternate,n!==null&&Ir(n)===null){s.child=h;break}n=h.sibling,h.sibling=a,a=h,h=n}hl(s,!0,a,null,p);break;case"together":hl(s,!1,null,null,void 0);break;default:s.memoizedState=null}return s.child}function Dr(n,s){(s.mode&1)===0&&n!==null&&(n.alternate=null,s.alternate=null,s.flags|=2)}function dn(n,s,a){if(n!==null&&(s.dependencies=n.dependencies),qn|=s.lanes,(a&s.childLanes)===0)return null;if(n!==null&&s.child!==n.child)throw Error(r(153));if(s.child!==null){for(n=s.child,a=Rn(n,n.pendingProps),s.child=a,a.return=s;n.sibling!==null;)n=n.sibling,a=a.sibling=Rn(n,n.pendingProps),a.return=s;a.sibling=null}return s.child}function iv(n,s,a){switch(s.tag){case 3:Jd(s),ys();break;case 5:pd(s);break;case 1:pt(s.type)&&xr(s);break;case 4:Va(s,s.stateNode.containerInfo);break;case 10:var u=s.type._context,h=s.memoizedProps.value;Te(Cr,u._currentValue),u._currentValue=h;break;case 13:if(u=s.memoizedState,u!==null)return u.dehydrated!==null?(Te(Oe,Oe.current&1),s.flags|=128,null):(a&s.child.childLanes)!==0?Zd(n,s,a):(Te(Oe,Oe.current&1),n=dn(n,s,a),n!==null?n.sibling:null);Te(Oe,Oe.current&1);break;case 19:if(u=(a&s.childLanes)!==0,(n.flags&128)!==0){if(u)return tf(n,s,a);s.flags|=128}if(h=s.memoizedState,h!==null&&(h.rendering=null,h.tail=null,h.lastEffect=null),Te(Oe,Oe.current),u)break;return null;case 22:case 23:return s.lanes=0,Qd(n,s,a)}return dn(n,s,a)}var nf,ml,sf,rf;nf=function(n,s){for(var a=s.child;a!==null;){if(a.tag===5||a.tag===6)n.appendChild(a.stateNode);else if(a.tag!==4&&a.child!==null){a.child.return=a,a=a.child;continue}if(a===s)break;for(;a.sibling===null;){if(a.return===null||a.return===s)return;a=a.return}a.sibling.return=a.return,a=a.sibling}},ml=function(){},sf=function(n,s,a,u){var h=n.memoizedProps;if(h!==u){n=s.stateNode,Gn(Gt.current);var p=null;switch(a){case"input":h=Ho(n,h),u=Ho(n,u),p=[];break;case"select":h=H({},h,{value:void 0}),u=H({},u,{value:void 0}),p=[];break;case"textarea":h=Vo(n,h),u=Vo(n,u),p=[];break;default:typeof h.onClick!="function"&&typeof u.onClick=="function"&&(n.onclick=vr)}Qo(a,u);var k;a=null;for(L in h)if(!u.hasOwnProperty(L)&&h.hasOwnProperty(L)&&h[L]!=null)if(L==="style"){var S=h[L];for(k in S)S.hasOwnProperty(k)&&(a||(a={}),a[k]="")}else L!=="dangerouslySetInnerHTML"&&L!=="children"&&L!=="suppressContentEditableWarning"&&L!=="suppressHydrationWarning"&&L!=="autoFocus"&&(l.hasOwnProperty(L)?p||(p=[]):(p=p||[]).push(L,null));for(L in u){var b=u[L];if(S=h!=null?h[L]:void 0,u.hasOwnProperty(L)&&b!==S&&(b!=null||S!=null))if(L==="style")if(S){for(k in S)!S.hasOwnProperty(k)||b&&b.hasOwnProperty(k)||(a||(a={}),a[k]="");for(k in b)b.hasOwnProperty(k)&&S[k]!==b[k]&&(a||(a={}),a[k]=b[k])}else a||(p||(p=[]),p.push(L,a)),a=b;else L==="dangerouslySetInnerHTML"?(b=b?b.__html:void 0,S=S?S.__html:void 0,b!=null&&S!==b&&(p=p||[]).push(L,b)):L==="children"?typeof b!="string"&&typeof b!="number"||(p=p||[]).push(L,""+b):L!=="suppressContentEditableWarning"&&L!=="suppressHydrationWarning"&&(l.hasOwnProperty(L)?(b!=null&&L==="onScroll"&&Ie("scroll",n),p||S===b||(p=[])):(p=p||[]).push(L,b))}a&&(p=p||[]).push("style",a);var L=p;(s.updateQueue=L)&&(s.flags|=4)}},rf=function(n,s,a,u){a!==u&&(s.flags|=4)};function bi(n,s){if(!Le)switch(n.tailMode){case"hidden":s=n.tail;for(var a=null;s!==null;)s.alternate!==null&&(a=s),s=s.sibling;a===null?n.tail=null:a.sibling=null;break;case"collapsed":a=n.tail;for(var u=null;a!==null;)a.alternate!==null&&(u=a),a=a.sibling;u===null?s||n.tail===null?n.tail=null:n.tail.sibling=null:u.sibling=null}}function at(n){var s=n.alternate!==null&&n.alternate.child===n.child,a=0,u=0;if(s)for(var h=n.child;h!==null;)a|=h.lanes|h.childLanes,u|=h.subtreeFlags&14680064,u|=h.flags&14680064,h.return=n,h=h.sibling;else for(h=n.child;h!==null;)a|=h.lanes|h.childLanes,u|=h.subtreeFlags,u|=h.flags,h.return=n,h=h.sibling;return n.subtreeFlags|=u,n.childLanes=a,s}function rv(n,s,a){var u=s.pendingProps;switch(Pa(s),s.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return at(s),null;case 1:return pt(s.type)&&yr(),at(s),null;case 3:return u=s.stateNode,Ns(),Me(mt),Me(rt),qa(),u.pendingContext&&(u.context=u.pendingContext,u.pendingContext=null),(n===null||n.child===null)&&(Sr(s)?s.flags|=4:n===null||n.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,Dt!==null&&(bl(Dt),Dt=null))),ml(n,s),at(s),null;case 5:Ga(s);var h=Gn(xi.current);if(a=s.type,n!==null&&s.stateNode!=null)sf(n,s,a,u,h),n.ref!==s.ref&&(s.flags|=512,s.flags|=2097152);else{if(!u){if(s.stateNode===null)throw Error(r(166));return at(s),null}if(n=Gn(Gt.current),Sr(s)){u=s.stateNode,a=s.type;var p=s.memoizedProps;switch(u[Vt]=s,u[pi]=p,n=(s.mode&1)!==0,a){case"dialog":Ie("cancel",u),Ie("close",u);break;case"iframe":case"object":case"embed":Ie("load",u);break;case"video":case"audio":for(h=0;h<fi.length;h++)Ie(fi[h],u);break;case"source":Ie("error",u);break;case"img":case"image":case"link":Ie("error",u),Ie("load",u);break;case"details":Ie("toggle",u);break;case"input":Dc(u,p),Ie("invalid",u);break;case"select":u._wrapperState={wasMultiple:!!p.multiple},Ie("invalid",u);break;case"textarea":Fc(u,p),Ie("invalid",u)}Qo(a,p),h=null;for(var k in p)if(p.hasOwnProperty(k)){var S=p[k];k==="children"?typeof S=="string"?u.textContent!==S&&(p.suppressHydrationWarning!==!0&&gr(u.textContent,S,n),h=["children",S]):typeof S=="number"&&u.textContent!==""+S&&(p.suppressHydrationWarning!==!0&&gr(u.textContent,S,n),h=["children",""+S]):l.hasOwnProperty(k)&&S!=null&&k==="onScroll"&&Ie("scroll",u)}switch(a){case"input":ss(u),zc(u,p,!0);break;case"textarea":ss(u),Hc(u);break;case"select":case"option":break;default:typeof p.onClick=="function"&&(u.onclick=vr)}u=h,s.updateQueue=u,u!==null&&(s.flags|=4)}else{k=h.nodeType===9?h:h.ownerDocument,n==="http://www.w3.org/1999/xhtml"&&(n=Wc(a)),n==="http://www.w3.org/1999/xhtml"?a==="script"?(n=k.createElement("div"),n.innerHTML="<script><\/script>",n=n.removeChild(n.firstChild)):typeof u.is=="string"?n=k.createElement(a,{is:u.is}):(n=k.createElement(a),a==="select"&&(k=n,u.multiple?k.multiple=!0:u.size&&(k.size=u.size))):n=k.createElementNS(n,a),n[Vt]=s,n[pi]=u,nf(n,s,!1,!1),s.stateNode=n;e:{switch(k=qo(a,u),a){case"dialog":Ie("cancel",n),Ie("close",n),h=u;break;case"iframe":case"object":case"embed":Ie("load",n),h=u;break;case"video":case"audio":for(h=0;h<fi.length;h++)Ie(fi[h],n);h=u;break;case"source":Ie("error",n),h=u;break;case"img":case"image":case"link":Ie("error",n),Ie("load",n),h=u;break;case"details":Ie("toggle",n),h=u;break;case"input":Dc(n,u),h=Ho(n,u),Ie("invalid",n);break;case"option":h=u;break;case"select":n._wrapperState={wasMultiple:!!u.multiple},h=H({},u,{value:void 0}),Ie("invalid",n);break;case"textarea":Fc(n,u),h=Vo(n,u),Ie("invalid",n);break;default:h=u}Qo(a,h),S=h;for(p in S)if(S.hasOwnProperty(p)){var b=S[p];p==="style"?Gc(n,b):p==="dangerouslySetInnerHTML"?(b=b?b.__html:void 0,b!=null&&Kc(n,b)):p==="children"?typeof b=="string"?(a!=="textarea"||b!=="")&&Gs(n,b):typeof b=="number"&&Gs(n,""+b):p!=="suppressContentEditableWarning"&&p!=="suppressHydrationWarning"&&p!=="autoFocus"&&(l.hasOwnProperty(p)?b!=null&&p==="onScroll"&&Ie("scroll",n):b!=null&&O(n,p,b,k))}switch(a){case"input":ss(n),zc(n,u,!1);break;case"textarea":ss(n),Hc(n);break;case"option":u.value!=null&&n.setAttribute("value",""+ke(u.value));break;case"select":n.multiple=!!u.multiple,p=u.value,p!=null?is(n,!!u.multiple,p,!1):u.defaultValue!=null&&is(n,!!u.multiple,u.defaultValue,!0);break;default:typeof h.onClick=="function"&&(n.onclick=vr)}switch(a){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}}u&&(s.flags|=4)}s.ref!==null&&(s.flags|=512,s.flags|=2097152)}return at(s),null;case 6:if(n&&s.stateNode!=null)rf(n,s,n.memoizedProps,u);else{if(typeof u!="string"&&s.stateNode===null)throw Error(r(166));if(a=Gn(xi.current),Gn(Gt.current),Sr(s)){if(u=s.stateNode,a=s.memoizedProps,u[Vt]=s,(p=u.nodeValue!==a)&&(n=Nt,n!==null))switch(n.tag){case 3:gr(u.nodeValue,a,(n.mode&1)!==0);break;case 5:n.memoizedProps.suppressHydrationWarning!==!0&&gr(u.nodeValue,a,(n.mode&1)!==0)}p&&(s.flags|=4)}else u=(a.nodeType===9?a:a.ownerDocument).createTextNode(u),u[Vt]=s,s.stateNode=u}return at(s),null;case 13:if(Me(Oe),u=s.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(Le&&St!==null&&(s.mode&1)!==0&&(s.flags&128)===0)ad(),ys(),s.flags|=98560,p=!1;else if(p=Sr(s),u!==null&&u.dehydrated!==null){if(n===null){if(!p)throw Error(r(318));if(p=s.memoizedState,p=p!==null?p.dehydrated:null,!p)throw Error(r(317));p[Vt]=s}else ys(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;at(s),p=!1}else Dt!==null&&(bl(Dt),Dt=null),p=!0;if(!p)return s.flags&65536?s:null}return(s.flags&128)!==0?(s.lanes=a,s):(u=u!==null,u!==(n!==null&&n.memoizedState!==null)&&u&&(s.child.flags|=8192,(s.mode&1)!==0&&(n===null||(Oe.current&1)!==0?qe===0&&(qe=3):Tl())),s.updateQueue!==null&&(s.flags|=4),at(s),null);case 4:return Ns(),ml(n,s),n===null&&hi(s.stateNode.containerInfo),at(s),null;case 10:return Ua(s.type._context),at(s),null;case 17:return pt(s.type)&&yr(),at(s),null;case 19:if(Me(Oe),p=s.memoizedState,p===null)return at(s),null;if(u=(s.flags&128)!==0,k=p.rendering,k===null)if(u)bi(p,!1);else{if(qe!==0||n!==null&&(n.flags&128)!==0)for(n=s.child;n!==null;){if(k=Ir(n),k!==null){for(s.flags|=128,bi(p,!1),u=k.updateQueue,u!==null&&(s.updateQueue=u,s.flags|=4),s.subtreeFlags=0,u=a,a=s.child;a!==null;)p=a,n=u,p.flags&=14680066,k=p.alternate,k===null?(p.childLanes=0,p.lanes=n,p.child=null,p.subtreeFlags=0,p.memoizedProps=null,p.memoizedState=null,p.updateQueue=null,p.dependencies=null,p.stateNode=null):(p.childLanes=k.childLanes,p.lanes=k.lanes,p.child=k.child,p.subtreeFlags=0,p.deletions=null,p.memoizedProps=k.memoizedProps,p.memoizedState=k.memoizedState,p.updateQueue=k.updateQueue,p.type=k.type,n=k.dependencies,p.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),a=a.sibling;return Te(Oe,Oe.current&1|2),s.child}n=n.sibling}p.tail!==null&&ze()>$s&&(s.flags|=128,u=!0,bi(p,!1),s.lanes=4194304)}else{if(!u)if(n=Ir(k),n!==null){if(s.flags|=128,u=!0,a=n.updateQueue,a!==null&&(s.updateQueue=a,s.flags|=4),bi(p,!0),p.tail===null&&p.tailMode==="hidden"&&!k.alternate&&!Le)return at(s),null}else 2*ze()-p.renderingStartTime>$s&&a!==1073741824&&(s.flags|=128,u=!0,bi(p,!1),s.lanes=4194304);p.isBackwards?(k.sibling=s.child,s.child=k):(a=p.last,a!==null?a.sibling=k:s.child=k,p.last=k)}return p.tail!==null?(s=p.tail,p.rendering=s,p.tail=s.sibling,p.renderingStartTime=ze(),s.sibling=null,a=Oe.current,Te(Oe,u?a&1|2:a&1),s):(at(s),null);case 22:case 23:return $l(),u=s.memoizedState!==null,n!==null&&n.memoizedState!==null!==u&&(s.flags|=8192),u&&(s.mode&1)!==0?(bt&1073741824)!==0&&(at(s),s.subtreeFlags&6&&(s.flags|=8192)):at(s),null;case 24:return null;case 25:return null}throw Error(r(156,s.tag))}function ov(n,s){switch(Pa(s),s.tag){case 1:return pt(s.type)&&yr(),n=s.flags,n&65536?(s.flags=n&-65537|128,s):null;case 3:return Ns(),Me(mt),Me(rt),qa(),n=s.flags,(n&65536)!==0&&(n&128)===0?(s.flags=n&-65537|128,s):null;case 5:return Ga(s),null;case 13:if(Me(Oe),n=s.memoizedState,n!==null&&n.dehydrated!==null){if(s.alternate===null)throw Error(r(340));ys()}return n=s.flags,n&65536?(s.flags=n&-65537|128,s):null;case 19:return Me(Oe),null;case 4:return Ns(),null;case 10:return Ua(s.type._context),null;case 22:case 23:return $l(),null;case 24:return null;default:return null}}var Br=!1,lt=!1,av=typeof WeakSet=="function"?WeakSet:Set,ee=null;function bs(n,s){var a=n.ref;if(a!==null)if(typeof a=="function")try{a(null)}catch(u){_e(n,s,u)}else a.current=null}function pl(n,s,a){try{a()}catch(u){_e(n,s,u)}}var of=!1;function lv(n,s){if($a=rr,n=_u(),ya(n)){if("selectionStart"in n)var a={start:n.selectionStart,end:n.selectionEnd};else e:{a=(a=n.ownerDocument)&&a.defaultView||window;var u=a.getSelection&&a.getSelection();if(u&&u.rangeCount!==0){a=u.anchorNode;var h=u.anchorOffset,p=u.focusNode;u=u.focusOffset;try{a.nodeType,p.nodeType}catch{a=null;break e}var k=0,S=-1,b=-1,L=0,z=0,W=n,B=null;t:for(;;){for(var J;W!==a||h!==0&&W.nodeType!==3||(S=k+h),W!==p||u!==0&&W.nodeType!==3||(b=k+u),W.nodeType===3&&(k+=W.nodeValue.length),(J=W.firstChild)!==null;)B=W,W=J;for(;;){if(W===n)break t;if(B===a&&++L===h&&(S=k),B===p&&++z===u&&(b=k),(J=W.nextSibling)!==null)break;W=B,B=W.parentNode}W=J}a=S===-1||b===-1?null:{start:S,end:b}}else a=null}a=a||{start:0,end:0}}else a=null;for(Ta={focusedElem:n,selectionRange:a},rr=!1,ee=s;ee!==null;)if(s=ee,n=s.child,(s.subtreeFlags&1028)!==0&&n!==null)n.return=s,ee=n;else for(;ee!==null;){s=ee;try{var ne=s.alternate;if((s.flags&1024)!==0)switch(s.tag){case 0:case 11:case 15:break;case 1:if(ne!==null){var re=ne.memoizedProps,Fe=ne.memoizedState,I=s.stateNode,C=I.getSnapshotBeforeUpdate(s.elementType===s.type?re:Bt(s.type,re),Fe);I.__reactInternalSnapshotBeforeUpdate=C}break;case 3:var A=s.stateNode.containerInfo;A.nodeType===1?A.textContent="":A.nodeType===9&&A.documentElement&&A.removeChild(A.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(G){_e(s,s.return,G)}if(n=s.sibling,n!==null){n.return=s.return,ee=n;break}ee=s.return}return ne=of,of=!1,ne}function Ci(n,s,a){var u=s.updateQueue;if(u=u!==null?u.lastEffect:null,u!==null){var h=u=u.next;do{if((h.tag&n)===n){var p=h.destroy;h.destroy=void 0,p!==void 0&&pl(s,a,p)}h=h.next}while(h!==u)}}function zr(n,s){if(s=s.updateQueue,s=s!==null?s.lastEffect:null,s!==null){var a=s=s.next;do{if((a.tag&n)===n){var u=a.create;a.destroy=u()}a=a.next}while(a!==s)}}function gl(n){var s=n.ref;if(s!==null){var a=n.stateNode;switch(n.tag){case 5:n=a;break;default:n=a}typeof s=="function"?s(n):s.current=n}}function af(n){var s=n.alternate;s!==null&&(n.alternate=null,af(s)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(s=n.stateNode,s!==null&&(delete s[Vt],delete s[pi],delete s[Aa],delete s[Wg],delete s[Kg])),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}function lf(n){return n.tag===5||n.tag===3||n.tag===4}function cf(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||lf(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function vl(n,s,a){var u=n.tag;if(u===5||u===6)n=n.stateNode,s?a.nodeType===8?a.parentNode.insertBefore(n,s):a.insertBefore(n,s):(a.nodeType===8?(s=a.parentNode,s.insertBefore(n,a)):(s=a,s.appendChild(n)),a=a._reactRootContainer,a!=null||s.onclick!==null||(s.onclick=vr));else if(u!==4&&(n=n.child,n!==null))for(vl(n,s,a),n=n.sibling;n!==null;)vl(n,s,a),n=n.sibling}function kl(n,s,a){var u=n.tag;if(u===5||u===6)n=n.stateNode,s?a.insertBefore(n,s):a.appendChild(n);else if(u!==4&&(n=n.child,n!==null))for(kl(n,s,a),n=n.sibling;n!==null;)kl(n,s,a),n=n.sibling}var nt=null,zt=!1;function En(n,s,a){for(a=a.child;a!==null;)uf(n,s,a),a=a.sibling}function uf(n,s,a){if(Kt&&typeof Kt.onCommitFiberUnmount=="function")try{Kt.onCommitFiberUnmount(Zi,a)}catch{}switch(a.tag){case 5:lt||bs(a,s);case 6:var u=nt,h=zt;nt=null,En(n,s,a),nt=u,zt=h,nt!==null&&(zt?(n=nt,a=a.stateNode,n.nodeType===8?n.parentNode.removeChild(a):n.removeChild(a)):nt.removeChild(a.stateNode));break;case 18:nt!==null&&(zt?(n=nt,a=a.stateNode,n.nodeType===8?Ma(n.parentNode,a):n.nodeType===1&&Ma(n,a),ii(n)):Ma(nt,a.stateNode));break;case 4:u=nt,h=zt,nt=a.stateNode.containerInfo,zt=!0,En(n,s,a),nt=u,zt=h;break;case 0:case 11:case 14:case 15:if(!lt&&(u=a.updateQueue,u!==null&&(u=u.lastEffect,u!==null))){h=u=u.next;do{var p=h,k=p.destroy;p=p.tag,k!==void 0&&((p&2)!==0||(p&4)!==0)&&pl(a,s,k),h=h.next}while(h!==u)}En(n,s,a);break;case 1:if(!lt&&(bs(a,s),u=a.stateNode,typeof u.componentWillUnmount=="function"))try{u.props=a.memoizedProps,u.state=a.memoizedState,u.componentWillUnmount()}catch(S){_e(a,s,S)}En(n,s,a);break;case 21:En(n,s,a);break;case 22:a.mode&1?(lt=(u=lt)||a.memoizedState!==null,En(n,s,a),lt=u):En(n,s,a);break;default:En(n,s,a)}}function df(n){var s=n.updateQueue;if(s!==null){n.updateQueue=null;var a=n.stateNode;a===null&&(a=n.stateNode=new av),s.forEach(function(u){var h=vv.bind(null,n,u);a.has(u)||(a.add(u),u.then(h,h))})}}function Ft(n,s){var a=s.deletions;if(a!==null)for(var u=0;u<a.length;u++){var h=a[u];try{var p=n,k=s,S=k;e:for(;S!==null;){switch(S.tag){case 5:nt=S.stateNode,zt=!1;break e;case 3:nt=S.stateNode.containerInfo,zt=!0;break e;case 4:nt=S.stateNode.containerInfo,zt=!0;break e}S=S.return}if(nt===null)throw Error(r(160));uf(p,k,h),nt=null,zt=!1;var b=h.alternate;b!==null&&(b.return=null),h.return=null}catch(L){_e(h,s,L)}}if(s.subtreeFlags&12854)for(s=s.child;s!==null;)ff(s,n),s=s.sibling}function ff(n,s){var a=n.alternate,u=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:if(Ft(s,n),qt(n),u&4){try{Ci(3,n,n.return),zr(3,n)}catch(re){_e(n,n.return,re)}try{Ci(5,n,n.return)}catch(re){_e(n,n.return,re)}}break;case 1:Ft(s,n),qt(n),u&512&&a!==null&&bs(a,a.return);break;case 5:if(Ft(s,n),qt(n),u&512&&a!==null&&bs(a,a.return),n.flags&32){var h=n.stateNode;try{Gs(h,"")}catch(re){_e(n,n.return,re)}}if(u&4&&(h=n.stateNode,h!=null)){var p=n.memoizedProps,k=a!==null?a.memoizedProps:p,S=n.type,b=n.updateQueue;if(n.updateQueue=null,b!==null)try{S==="input"&&p.type==="radio"&&p.name!=null&&Bc(h,p),qo(S,k);var L=qo(S,p);for(k=0;k<b.length;k+=2){var z=b[k],W=b[k+1];z==="style"?Gc(h,W):z==="dangerouslySetInnerHTML"?Kc(h,W):z==="children"?Gs(h,W):O(h,z,W,L)}switch(S){case"input":Wo(h,p);break;case"textarea":Uc(h,p);break;case"select":var B=h._wrapperState.wasMultiple;h._wrapperState.wasMultiple=!!p.multiple;var J=p.value;J!=null?is(h,!!p.multiple,J,!1):B!==!!p.multiple&&(p.defaultValue!=null?is(h,!!p.multiple,p.defaultValue,!0):is(h,!!p.multiple,p.multiple?[]:"",!1))}h[pi]=p}catch(re){_e(n,n.return,re)}}break;case 6:if(Ft(s,n),qt(n),u&4){if(n.stateNode===null)throw Error(r(162));h=n.stateNode,p=n.memoizedProps;try{h.nodeValue=p}catch(re){_e(n,n.return,re)}}break;case 3:if(Ft(s,n),qt(n),u&4&&a!==null&&a.memoizedState.isDehydrated)try{ii(s.containerInfo)}catch(re){_e(n,n.return,re)}break;case 4:Ft(s,n),qt(n);break;case 13:Ft(s,n),qt(n),h=n.child,h.flags&8192&&(p=h.memoizedState!==null,h.stateNode.isHidden=p,!p||h.alternate!==null&&h.alternate.memoizedState!==null||(wl=ze())),u&4&&df(n);break;case 22:if(z=a!==null&&a.memoizedState!==null,n.mode&1?(lt=(L=lt)||z,Ft(s,n),lt=L):Ft(s,n),qt(n),u&8192){if(L=n.memoizedState!==null,(n.stateNode.isHidden=L)&&!z&&(n.mode&1)!==0)for(ee=n,z=n.child;z!==null;){for(W=ee=z;ee!==null;){switch(B=ee,J=B.child,B.tag){case 0:case 11:case 14:case 15:Ci(4,B,B.return);break;case 1:bs(B,B.return);var ne=B.stateNode;if(typeof ne.componentWillUnmount=="function"){u=B,a=B.return;try{s=u,ne.props=s.memoizedProps,ne.state=s.memoizedState,ne.componentWillUnmount()}catch(re){_e(u,a,re)}}break;case 5:bs(B,B.return);break;case 22:if(B.memoizedState!==null){pf(W);continue}}J!==null?(J.return=B,ee=J):pf(W)}z=z.sibling}e:for(z=null,W=n;;){if(W.tag===5){if(z===null){z=W;try{h=W.stateNode,L?(p=h.style,typeof p.setProperty=="function"?p.setProperty("display","none","important"):p.display="none"):(S=W.stateNode,b=W.memoizedProps.style,k=b!=null&&b.hasOwnProperty("display")?b.display:null,S.style.display=Vc("display",k))}catch(re){_e(n,n.return,re)}}}else if(W.tag===6){if(z===null)try{W.stateNode.nodeValue=L?"":W.memoizedProps}catch(re){_e(n,n.return,re)}}else if((W.tag!==22&&W.tag!==23||W.memoizedState===null||W===n)&&W.child!==null){W.child.return=W,W=W.child;continue}if(W===n)break e;for(;W.sibling===null;){if(W.return===null||W.return===n)break e;z===W&&(z=null),W=W.return}z===W&&(z=null),W.sibling.return=W.return,W=W.sibling}}break;case 19:Ft(s,n),qt(n),u&4&&df(n);break;case 21:break;default:Ft(s,n),qt(n)}}function qt(n){var s=n.flags;if(s&2){try{e:{for(var a=n.return;a!==null;){if(lf(a)){var u=a;break e}a=a.return}throw Error(r(160))}switch(u.tag){case 5:var h=u.stateNode;u.flags&32&&(Gs(h,""),u.flags&=-33);var p=cf(n);kl(n,p,h);break;case 3:case 4:var k=u.stateNode.containerInfo,S=cf(n);vl(n,S,k);break;default:throw Error(r(161))}}catch(b){_e(n,n.return,b)}n.flags&=-3}s&4096&&(n.flags&=-4097)}function cv(n,s,a){ee=n,hf(n)}function hf(n,s,a){for(var u=(n.mode&1)!==0;ee!==null;){var h=ee,p=h.child;if(h.tag===22&&u){var k=h.memoizedState!==null||Br;if(!k){var S=h.alternate,b=S!==null&&S.memoizedState!==null||lt;S=Br;var L=lt;if(Br=k,(lt=b)&&!L)for(ee=h;ee!==null;)k=ee,b=k.child,k.tag===22&&k.memoizedState!==null?gf(h):b!==null?(b.return=k,ee=b):gf(h);for(;p!==null;)ee=p,hf(p),p=p.sibling;ee=h,Br=S,lt=L}mf(n)}else(h.subtreeFlags&8772)!==0&&p!==null?(p.return=h,ee=p):mf(n)}}function mf(n){for(;ee!==null;){var s=ee;if((s.flags&8772)!==0){var a=s.alternate;try{if((s.flags&8772)!==0)switch(s.tag){case 0:case 11:case 15:lt||zr(5,s);break;case 1:var u=s.stateNode;if(s.flags&4&&!lt)if(a===null)u.componentDidMount();else{var h=s.elementType===s.type?a.memoizedProps:Bt(s.type,a.memoizedProps);u.componentDidUpdate(h,a.memoizedState,u.__reactInternalSnapshotBeforeUpdate)}var p=s.updateQueue;p!==null&&md(s,p,u);break;case 3:var k=s.updateQueue;if(k!==null){if(a=null,s.child!==null)switch(s.child.tag){case 5:a=s.child.stateNode;break;case 1:a=s.child.stateNode}md(s,k,a)}break;case 5:var S=s.stateNode;if(a===null&&s.flags&4){a=S;var b=s.memoizedProps;switch(s.type){case"button":case"input":case"select":case"textarea":b.autoFocus&&a.focus();break;case"img":b.src&&(a.src=b.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(s.memoizedState===null){var L=s.alternate;if(L!==null){var z=L.memoizedState;if(z!==null){var W=z.dehydrated;W!==null&&ii(W)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(r(163))}lt||s.flags&512&&gl(s)}catch(B){_e(s,s.return,B)}}if(s===n){ee=null;break}if(a=s.sibling,a!==null){a.return=s.return,ee=a;break}ee=s.return}}function pf(n){for(;ee!==null;){var s=ee;if(s===n){ee=null;break}var a=s.sibling;if(a!==null){a.return=s.return,ee=a;break}ee=s.return}}function gf(n){for(;ee!==null;){var s=ee;try{switch(s.tag){case 0:case 11:case 15:var a=s.return;try{zr(4,s)}catch(b){_e(s,a,b)}break;case 1:var u=s.stateNode;if(typeof u.componentDidMount=="function"){var h=s.return;try{u.componentDidMount()}catch(b){_e(s,h,b)}}var p=s.return;try{gl(s)}catch(b){_e(s,p,b)}break;case 5:var k=s.return;try{gl(s)}catch(b){_e(s,k,b)}}}catch(b){_e(s,s.return,b)}if(s===n){ee=null;break}var S=s.sibling;if(S!==null){S.return=s.return,ee=S;break}ee=s.return}}var uv=Math.ceil,Fr=X.ReactCurrentDispatcher,yl=X.ReactCurrentOwner,Mt=X.ReactCurrentBatchConfig,je=0,Ze=null,Ve=null,st=0,bt=0,Cs=Sn(0),qe=0,$i=null,qn=0,Ur=0,xl=0,Ti=null,vt=null,wl=0,$s=1/0,fn=null,Hr=!1,jl=null,In=null,Wr=!1,Mn=null,Kr=0,Ei=0,Nl=null,Vr=-1,Gr=0;function ft(){return(je&6)!==0?ze():Vr!==-1?Vr:Vr=ze()}function An(n){return(n.mode&1)===0?1:(je&2)!==0&&st!==0?st&-st:Gg.transition!==null?(Gr===0&&(Gr=lu()),Gr):(n=Ce,n!==0||(n=window.event,n=n===void 0?16:vu(n.type)),n)}function Ut(n,s,a,u){if(50<Ei)throw Ei=0,Nl=null,Error(r(185));Zs(n,a,u),((je&2)===0||n!==Ze)&&(n===Ze&&((je&2)===0&&(Ur|=a),qe===4&&Ln(n,st)),kt(n,u),a===1&&je===0&&(s.mode&1)===0&&($s=ze()+500,wr&&Cn()))}function kt(n,s){var a=n.callbackNode;Gp(n,s);var u=nr(n,n===Ze?st:0);if(u===0)a!==null&&ru(a),n.callbackNode=null,n.callbackPriority=0;else if(s=u&-u,n.callbackPriority!==s){if(a!=null&&ru(a),s===1)n.tag===0?Vg(kf.bind(null,n)):nd(kf.bind(null,n)),Ug(function(){(je&6)===0&&Cn()}),a=null;else{switch(cu(u)){case 1:a=na;break;case 4:a=ou;break;case 16:a=Xi;break;case 536870912:a=au;break;default:a=Xi}a=Cf(a,vf.bind(null,n))}n.callbackPriority=s,n.callbackNode=a}}function vf(n,s){if(Vr=-1,Gr=0,(je&6)!==0)throw Error(r(327));var a=n.callbackNode;if(Ts()&&n.callbackNode!==a)return null;var u=nr(n,n===Ze?st:0);if(u===0)return null;if((u&30)!==0||(u&n.expiredLanes)!==0||s)s=Qr(n,u);else{s=u;var h=je;je|=2;var p=xf();(Ze!==n||st!==s)&&(fn=null,$s=ze()+500,Jn(n,s));do try{hv();break}catch(S){yf(n,S)}while(!0);Fa(),Fr.current=p,je=h,Ve!==null?s=0:(Ze=null,st=0,s=qe)}if(s!==0){if(s===2&&(h=sa(n),h!==0&&(u=h,s=Sl(n,h))),s===1)throw a=$i,Jn(n,0),Ln(n,u),kt(n,ze()),a;if(s===6)Ln(n,u);else{if(h=n.current.alternate,(u&30)===0&&!dv(h)&&(s=Qr(n,u),s===2&&(p=sa(n),p!==0&&(u=p,s=Sl(n,p))),s===1))throw a=$i,Jn(n,0),Ln(n,u),kt(n,ze()),a;switch(n.finishedWork=h,n.finishedLanes=u,s){case 0:case 1:throw Error(r(345));case 2:Xn(n,vt,fn);break;case 3:if(Ln(n,u),(u&130023424)===u&&(s=wl+500-ze(),10<s)){if(nr(n,0)!==0)break;if(h=n.suspendedLanes,(h&u)!==u){ft(),n.pingedLanes|=n.suspendedLanes&h;break}n.timeoutHandle=Ia(Xn.bind(null,n,vt,fn),s);break}Xn(n,vt,fn);break;case 4:if(Ln(n,u),(u&4194240)===u)break;for(s=n.eventTimes,h=-1;0<u;){var k=31-Pt(u);p=1<<k,k=s[k],k>h&&(h=k),u&=~p}if(u=h,u=ze()-u,u=(120>u?120:480>u?480:1080>u?1080:1920>u?1920:3e3>u?3e3:4320>u?4320:1960*uv(u/1960))-u,10<u){n.timeoutHandle=Ia(Xn.bind(null,n,vt,fn),u);break}Xn(n,vt,fn);break;case 5:Xn(n,vt,fn);break;default:throw Error(r(329))}}}return kt(n,ze()),n.callbackNode===a?vf.bind(null,n):null}function Sl(n,s){var a=Ti;return n.current.memoizedState.isDehydrated&&(Jn(n,s).flags|=256),n=Qr(n,s),n!==2&&(s=vt,vt=a,s!==null&&bl(s)),n}function bl(n){vt===null?vt=n:vt.push.apply(vt,n)}function dv(n){for(var s=n;;){if(s.flags&16384){var a=s.updateQueue;if(a!==null&&(a=a.stores,a!==null))for(var u=0;u<a.length;u++){var h=a[u],p=h.getSnapshot;h=h.value;try{if(!_t(p(),h))return!1}catch{return!1}}}if(a=s.child,s.subtreeFlags&16384&&a!==null)a.return=s,s=a;else{if(s===n)break;for(;s.sibling===null;){if(s.return===null||s.return===n)return!0;s=s.return}s.sibling.return=s.return,s=s.sibling}}return!0}function Ln(n,s){for(s&=~xl,s&=~Ur,n.suspendedLanes|=s,n.pingedLanes&=~s,n=n.expirationTimes;0<s;){var a=31-Pt(s),u=1<<a;n[a]=-1,s&=~u}}function kf(n){if((je&6)!==0)throw Error(r(327));Ts();var s=nr(n,0);if((s&1)===0)return kt(n,ze()),null;var a=Qr(n,s);if(n.tag!==0&&a===2){var u=sa(n);u!==0&&(s=u,a=Sl(n,u))}if(a===1)throw a=$i,Jn(n,0),Ln(n,s),kt(n,ze()),a;if(a===6)throw Error(r(345));return n.finishedWork=n.current.alternate,n.finishedLanes=s,Xn(n,vt,fn),kt(n,ze()),null}function Cl(n,s){var a=je;je|=1;try{return n(s)}finally{je=a,je===0&&($s=ze()+500,wr&&Cn())}}function Yn(n){Mn!==null&&Mn.tag===0&&(je&6)===0&&Ts();var s=je;je|=1;var a=Mt.transition,u=Ce;try{if(Mt.transition=null,Ce=1,n)return n()}finally{Ce=u,Mt.transition=a,je=s,(je&6)===0&&Cn()}}function $l(){bt=Cs.current,Me(Cs)}function Jn(n,s){n.finishedWork=null,n.finishedLanes=0;var a=n.timeoutHandle;if(a!==-1&&(n.timeoutHandle=-1,Fg(a)),Ve!==null)for(a=Ve.return;a!==null;){var u=a;switch(Pa(u),u.tag){case 1:u=u.type.childContextTypes,u!=null&&yr();break;case 3:Ns(),Me(mt),Me(rt),qa();break;case 5:Ga(u);break;case 4:Ns();break;case 13:Me(Oe);break;case 19:Me(Oe);break;case 10:Ua(u.type._context);break;case 22:case 23:$l()}a=a.return}if(Ze=n,Ve=n=Rn(n.current,null),st=bt=s,qe=0,$i=null,xl=Ur=qn=0,vt=Ti=null,Vn!==null){for(s=0;s<Vn.length;s++)if(a=Vn[s],u=a.interleaved,u!==null){a.interleaved=null;var h=u.next,p=a.pending;if(p!==null){var k=p.next;p.next=h,u.next=k}a.pending=u}Vn=null}return n}function yf(n,s){do{var a=Ve;try{if(Fa(),Mr.current=Or,Ar){for(var u=Pe.memoizedState;u!==null;){var h=u.queue;h!==null&&(h.pending=null),u=u.next}Ar=!1}if(Qn=0,Xe=Qe=Pe=null,wi=!1,ji=0,yl.current=null,a===null||a.return===null){qe=1,$i=s,Ve=null;break}e:{var p=n,k=a.return,S=a,b=s;if(s=st,S.flags|=32768,b!==null&&typeof b=="object"&&typeof b.then=="function"){var L=b,z=S,W=z.tag;if((z.mode&1)===0&&(W===0||W===11||W===15)){var B=z.alternate;B?(z.updateQueue=B.updateQueue,z.memoizedState=B.memoizedState,z.lanes=B.lanes):(z.updateQueue=null,z.memoizedState=null)}var J=Hd(k);if(J!==null){J.flags&=-257,Wd(J,k,S,p,s),J.mode&1&&Ud(p,L,s),s=J,b=L;var ne=s.updateQueue;if(ne===null){var re=new Set;re.add(b),s.updateQueue=re}else ne.add(b);break e}else{if((s&1)===0){Ud(p,L,s),Tl();break e}b=Error(r(426))}}else if(Le&&S.mode&1){var Fe=Hd(k);if(Fe!==null){(Fe.flags&65536)===0&&(Fe.flags|=256),Wd(Fe,k,S,p,s),Ba(Ss(b,S));break e}}p=b=Ss(b,S),qe!==4&&(qe=2),Ti===null?Ti=[p]:Ti.push(p),p=k;do{switch(p.tag){case 3:p.flags|=65536,s&=-s,p.lanes|=s;var I=zd(p,b,s);hd(p,I);break e;case 1:S=b;var C=p.type,A=p.stateNode;if((p.flags&128)===0&&(typeof C.getDerivedStateFromError=="function"||A!==null&&typeof A.componentDidCatch=="function"&&(In===null||!In.has(A)))){p.flags|=65536,s&=-s,p.lanes|=s;var G=Fd(p,S,s);hd(p,G);break e}}p=p.return}while(p!==null)}jf(a)}catch(oe){s=oe,Ve===a&&a!==null&&(Ve=a=a.return);continue}break}while(!0)}function xf(){var n=Fr.current;return Fr.current=Or,n===null?Or:n}function Tl(){(qe===0||qe===3||qe===2)&&(qe=4),Ze===null||(qn&268435455)===0&&(Ur&268435455)===0||Ln(Ze,st)}function Qr(n,s){var a=je;je|=2;var u=xf();(Ze!==n||st!==s)&&(fn=null,Jn(n,s));do try{fv();break}catch(h){yf(n,h)}while(!0);if(Fa(),je=a,Fr.current=u,Ve!==null)throw Error(r(261));return Ze=null,st=0,qe}function fv(){for(;Ve!==null;)wf(Ve)}function hv(){for(;Ve!==null&&!Dp();)wf(Ve)}function wf(n){var s=bf(n.alternate,n,bt);n.memoizedProps=n.pendingProps,s===null?jf(n):Ve=s,yl.current=null}function jf(n){var s=n;do{var a=s.alternate;if(n=s.return,(s.flags&32768)===0){if(a=rv(a,s,bt),a!==null){Ve=a;return}}else{if(a=ov(a,s),a!==null){a.flags&=32767,Ve=a;return}if(n!==null)n.flags|=32768,n.subtreeFlags=0,n.deletions=null;else{qe=6,Ve=null;return}}if(s=s.sibling,s!==null){Ve=s;return}Ve=s=n}while(s!==null);qe===0&&(qe=5)}function Xn(n,s,a){var u=Ce,h=Mt.transition;try{Mt.transition=null,Ce=1,mv(n,s,a,u)}finally{Mt.transition=h,Ce=u}return null}function mv(n,s,a,u){do Ts();while(Mn!==null);if((je&6)!==0)throw Error(r(327));a=n.finishedWork;var h=n.finishedLanes;if(a===null)return null;if(n.finishedWork=null,n.finishedLanes=0,a===n.current)throw Error(r(177));n.callbackNode=null,n.callbackPriority=0;var p=a.lanes|a.childLanes;if(Qp(n,p),n===Ze&&(Ve=Ze=null,st=0),(a.subtreeFlags&2064)===0&&(a.flags&2064)===0||Wr||(Wr=!0,Cf(Xi,function(){return Ts(),null})),p=(a.flags&15990)!==0,(a.subtreeFlags&15990)!==0||p){p=Mt.transition,Mt.transition=null;var k=Ce;Ce=1;var S=je;je|=4,yl.current=null,lv(n,a),ff(a,n),Rg(Ta),rr=!!$a,Ta=$a=null,n.current=a,cv(a),Bp(),je=S,Ce=k,Mt.transition=p}else n.current=a;if(Wr&&(Wr=!1,Mn=n,Kr=h),p=n.pendingLanes,p===0&&(In=null),Up(a.stateNode),kt(n,ze()),s!==null)for(u=n.onRecoverableError,a=0;a<s.length;a++)h=s[a],u(h.value,{componentStack:h.stack,digest:h.digest});if(Hr)throw Hr=!1,n=jl,jl=null,n;return(Kr&1)!==0&&n.tag!==0&&Ts(),p=n.pendingLanes,(p&1)!==0?n===Nl?Ei++:(Ei=0,Nl=n):Ei=0,Cn(),null}function Ts(){if(Mn!==null){var n=cu(Kr),s=Mt.transition,a=Ce;try{if(Mt.transition=null,Ce=16>n?16:n,Mn===null)var u=!1;else{if(n=Mn,Mn=null,Kr=0,(je&6)!==0)throw Error(r(331));var h=je;for(je|=4,ee=n.current;ee!==null;){var p=ee,k=p.child;if((ee.flags&16)!==0){var S=p.deletions;if(S!==null){for(var b=0;b<S.length;b++){var L=S[b];for(ee=L;ee!==null;){var z=ee;switch(z.tag){case 0:case 11:case 15:Ci(8,z,p)}var W=z.child;if(W!==null)W.return=z,ee=W;else for(;ee!==null;){z=ee;var B=z.sibling,J=z.return;if(af(z),z===L){ee=null;break}if(B!==null){B.return=J,ee=B;break}ee=J}}}var ne=p.alternate;if(ne!==null){var re=ne.child;if(re!==null){ne.child=null;do{var Fe=re.sibling;re.sibling=null,re=Fe}while(re!==null)}}ee=p}}if((p.subtreeFlags&2064)!==0&&k!==null)k.return=p,ee=k;else e:for(;ee!==null;){if(p=ee,(p.flags&2048)!==0)switch(p.tag){case 0:case 11:case 15:Ci(9,p,p.return)}var I=p.sibling;if(I!==null){I.return=p.return,ee=I;break e}ee=p.return}}var C=n.current;for(ee=C;ee!==null;){k=ee;var A=k.child;if((k.subtreeFlags&2064)!==0&&A!==null)A.return=k,ee=A;else e:for(k=C;ee!==null;){if(S=ee,(S.flags&2048)!==0)try{switch(S.tag){case 0:case 11:case 15:zr(9,S)}}catch(oe){_e(S,S.return,oe)}if(S===k){ee=null;break e}var G=S.sibling;if(G!==null){G.return=S.return,ee=G;break e}ee=S.return}}if(je=h,Cn(),Kt&&typeof Kt.onPostCommitFiberRoot=="function")try{Kt.onPostCommitFiberRoot(Zi,n)}catch{}u=!0}return u}finally{Ce=a,Mt.transition=s}}return!1}function Nf(n,s,a){s=Ss(a,s),s=zd(n,s,1),n=Tn(n,s,1),s=ft(),n!==null&&(Zs(n,1,s),kt(n,s))}function _e(n,s,a){if(n.tag===3)Nf(n,n,a);else for(;s!==null;){if(s.tag===3){Nf(s,n,a);break}else if(s.tag===1){var u=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(In===null||!In.has(u))){n=Ss(a,n),n=Fd(s,n,1),s=Tn(s,n,1),n=ft(),s!==null&&(Zs(s,1,n),kt(s,n));break}}s=s.return}}function pv(n,s,a){var u=n.pingCache;u!==null&&u.delete(s),s=ft(),n.pingedLanes|=n.suspendedLanes&a,Ze===n&&(st&a)===a&&(qe===4||qe===3&&(st&130023424)===st&&500>ze()-wl?Jn(n,0):xl|=a),kt(n,s)}function Sf(n,s){s===0&&((n.mode&1)===0?s=1:(s=tr,tr<<=1,(tr&130023424)===0&&(tr=4194304)));var a=ft();n=cn(n,s),n!==null&&(Zs(n,s,a),kt(n,a))}function gv(n){var s=n.memoizedState,a=0;s!==null&&(a=s.retryLane),Sf(n,a)}function vv(n,s){var a=0;switch(n.tag){case 13:var u=n.stateNode,h=n.memoizedState;h!==null&&(a=h.retryLane);break;case 19:u=n.stateNode;break;default:throw Error(r(314))}u!==null&&u.delete(s),Sf(n,a)}var bf;bf=function(n,s,a){if(n!==null)if(n.memoizedProps!==s.pendingProps||mt.current)gt=!0;else{if((n.lanes&a)===0&&(s.flags&128)===0)return gt=!1,iv(n,s,a);gt=(n.flags&131072)!==0}else gt=!1,Le&&(s.flags&1048576)!==0&&sd(s,Nr,s.index);switch(s.lanes=0,s.tag){case 2:var u=s.type;Dr(n,s),n=s.pendingProps;var h=gs(s,rt.current);js(s,a),h=Xa(null,s,u,n,h,a);var p=Za();return s.flags|=1,typeof h=="object"&&h!==null&&typeof h.render=="function"&&h.$$typeof===void 0?(s.tag=1,s.memoizedState=null,s.updateQueue=null,pt(u)?(p=!0,xr(s)):p=!1,s.memoizedState=h.state!==null&&h.state!==void 0?h.state:null,Ka(s),h.updater=Pr,s.stateNode=h,h._reactInternals=s,rl(s,u,n,a),s=cl(null,s,u,!0,p,a)):(s.tag=0,Le&&p&&Oa(s),dt(null,s,h,a),s=s.child),s;case 16:u=s.elementType;e:{switch(Dr(n,s),n=s.pendingProps,h=u._init,u=h(u._payload),s.type=u,h=s.tag=yv(u),n=Bt(u,n),h){case 0:s=ll(null,s,u,n,a);break e;case 1:s=Yd(null,s,u,n,a);break e;case 11:s=Kd(null,s,u,n,a);break e;case 14:s=Vd(null,s,u,Bt(u.type,n),a);break e}throw Error(r(306,u,""))}return s;case 0:return u=s.type,h=s.pendingProps,h=s.elementType===u?h:Bt(u,h),ll(n,s,u,h,a);case 1:return u=s.type,h=s.pendingProps,h=s.elementType===u?h:Bt(u,h),Yd(n,s,u,h,a);case 3:e:{if(Jd(s),n===null)throw Error(r(387));u=s.pendingProps,p=s.memoizedState,h=p.element,fd(n,s),Er(s,u,null,a);var k=s.memoizedState;if(u=k.element,p.isDehydrated)if(p={element:u,isDehydrated:!1,cache:k.cache,pendingSuspenseBoundaries:k.pendingSuspenseBoundaries,transitions:k.transitions},s.updateQueue.baseState=p,s.memoizedState=p,s.flags&256){h=Ss(Error(r(423)),s),s=Xd(n,s,u,a,h);break e}else if(u!==h){h=Ss(Error(r(424)),s),s=Xd(n,s,u,a,h);break e}else for(St=Nn(s.stateNode.containerInfo.firstChild),Nt=s,Le=!0,Dt=null,a=ud(s,null,u,a),s.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(ys(),u===h){s=dn(n,s,a);break e}dt(n,s,u,a)}s=s.child}return s;case 5:return pd(s),n===null&&Da(s),u=s.type,h=s.pendingProps,p=n!==null?n.memoizedProps:null,k=h.children,Ea(u,h)?k=null:p!==null&&Ea(u,p)&&(s.flags|=32),qd(n,s),dt(n,s,k,a),s.child;case 6:return n===null&&Da(s),null;case 13:return Zd(n,s,a);case 4:return Va(s,s.stateNode.containerInfo),u=s.pendingProps,n===null?s.child=xs(s,null,u,a):dt(n,s,u,a),s.child;case 11:return u=s.type,h=s.pendingProps,h=s.elementType===u?h:Bt(u,h),Kd(n,s,u,h,a);case 7:return dt(n,s,s.pendingProps,a),s.child;case 8:return dt(n,s,s.pendingProps.children,a),s.child;case 12:return dt(n,s,s.pendingProps.children,a),s.child;case 10:e:{if(u=s.type._context,h=s.pendingProps,p=s.memoizedProps,k=h.value,Te(Cr,u._currentValue),u._currentValue=k,p!==null)if(_t(p.value,k)){if(p.children===h.children&&!mt.current){s=dn(n,s,a);break e}}else for(p=s.child,p!==null&&(p.return=s);p!==null;){var S=p.dependencies;if(S!==null){k=p.child;for(var b=S.firstContext;b!==null;){if(b.context===u){if(p.tag===1){b=un(-1,a&-a),b.tag=2;var L=p.updateQueue;if(L!==null){L=L.shared;var z=L.pending;z===null?b.next=b:(b.next=z.next,z.next=b),L.pending=b}}p.lanes|=a,b=p.alternate,b!==null&&(b.lanes|=a),Ha(p.return,a,s),S.lanes|=a;break}b=b.next}}else if(p.tag===10)k=p.type===s.type?null:p.child;else if(p.tag===18){if(k=p.return,k===null)throw Error(r(341));k.lanes|=a,S=k.alternate,S!==null&&(S.lanes|=a),Ha(k,a,s),k=p.sibling}else k=p.child;if(k!==null)k.return=p;else for(k=p;k!==null;){if(k===s){k=null;break}if(p=k.sibling,p!==null){p.return=k.return,k=p;break}k=k.return}p=k}dt(n,s,h.children,a),s=s.child}return s;case 9:return h=s.type,u=s.pendingProps.children,js(s,a),h=Et(h),u=u(h),s.flags|=1,dt(n,s,u,a),s.child;case 14:return u=s.type,h=Bt(u,s.pendingProps),h=Bt(u.type,h),Vd(n,s,u,h,a);case 15:return Gd(n,s,s.type,s.pendingProps,a);case 17:return u=s.type,h=s.pendingProps,h=s.elementType===u?h:Bt(u,h),Dr(n,s),s.tag=1,pt(u)?(n=!0,xr(s)):n=!1,js(s,a),Dd(s,u,h),rl(s,u,h,a),cl(null,s,u,!0,n,a);case 19:return tf(n,s,a);case 22:return Qd(n,s,a)}throw Error(r(156,s.tag))};function Cf(n,s){return iu(n,s)}function kv(n,s,a,u){this.tag=n,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=u,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function At(n,s,a,u){return new kv(n,s,a,u)}function El(n){return n=n.prototype,!(!n||!n.isReactComponent)}function yv(n){if(typeof n=="function")return El(n)?1:0;if(n!=null){if(n=n.$$typeof,n===be)return 11;if(n===Y)return 14}return 2}function Rn(n,s){var a=n.alternate;return a===null?(a=At(n.tag,s,n.key,n.mode),a.elementType=n.elementType,a.type=n.type,a.stateNode=n.stateNode,a.alternate=n,n.alternate=a):(a.pendingProps=s,a.type=n.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=n.flags&14680064,a.childLanes=n.childLanes,a.lanes=n.lanes,a.child=n.child,a.memoizedProps=n.memoizedProps,a.memoizedState=n.memoizedState,a.updateQueue=n.updateQueue,s=n.dependencies,a.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},a.sibling=n.sibling,a.index=n.index,a.ref=n.ref,a}function qr(n,s,a,u,h,p){var k=2;if(u=n,typeof n=="function")El(n)&&(k=1);else if(typeof n=="string")k=5;else e:switch(n){case F:return Zn(a.children,h,p,s);case ie:k=8,h|=8;break;case V:return n=At(12,a,s,h|2),n.elementType=V,n.lanes=p,n;case te:return n=At(13,a,s,h),n.elementType=te,n.lanes=p,n;case P:return n=At(19,a,s,h),n.elementType=P,n.lanes=p,n;case Z:return Yr(a,h,p,s);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case ge:k=10;break e;case Re:k=9;break e;case be:k=11;break e;case Y:k=14;break e;case ae:k=16,u=null;break e}throw Error(r(130,n==null?n:typeof n,""))}return s=At(k,a,s,h),s.elementType=n,s.type=u,s.lanes=p,s}function Zn(n,s,a,u){return n=At(7,n,u,s),n.lanes=a,n}function Yr(n,s,a,u){return n=At(22,n,u,s),n.elementType=Z,n.lanes=a,n.stateNode={isHidden:!1},n}function Il(n,s,a){return n=At(6,n,null,s),n.lanes=a,n}function Ml(n,s,a){return s=At(4,n.children!==null?n.children:[],n.key,s),s.lanes=a,s.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},s}function xv(n,s,a,u,h){this.tag=s,this.containerInfo=n,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=ia(0),this.expirationTimes=ia(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ia(0),this.identifierPrefix=u,this.onRecoverableError=h,this.mutableSourceEagerHydrationData=null}function Al(n,s,a,u,h,p,k,S,b){return n=new xv(n,s,a,S,b),s===1?(s=1,p===!0&&(s|=8)):s=0,p=At(3,null,null,s),n.current=p,p.stateNode=n,p.memoizedState={element:u,isDehydrated:a,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ka(p),n}function wv(n,s,a){var u=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Q,key:u==null?null:""+u,children:n,containerInfo:s,implementation:a}}function $f(n){if(!n)return bn;n=n._reactInternals;e:{if(Fn(n)!==n||n.tag!==1)throw Error(r(170));var s=n;do{switch(s.tag){case 3:s=s.stateNode.context;break e;case 1:if(pt(s.type)){s=s.stateNode.__reactInternalMemoizedMergedChildContext;break e}}s=s.return}while(s!==null);throw Error(r(171))}if(n.tag===1){var a=n.type;if(pt(a))return ed(n,a,s)}return s}function Tf(n,s,a,u,h,p,k,S,b){return n=Al(a,u,!0,n,h,p,k,S,b),n.context=$f(null),a=n.current,u=ft(),h=An(a),p=un(u,h),p.callback=s??null,Tn(a,p,h),n.current.lanes=h,Zs(n,h,u),kt(n,u),n}function Jr(n,s,a,u){var h=s.current,p=ft(),k=An(h);return a=$f(a),s.context===null?s.context=a:s.pendingContext=a,s=un(p,k),s.payload={element:n},u=u===void 0?null:u,u!==null&&(s.callback=u),n=Tn(h,s,k),n!==null&&(Ut(n,h,k,p),Tr(n,h,k)),k}function Xr(n){if(n=n.current,!n.child)return null;switch(n.child.tag){case 5:return n.child.stateNode;default:return n.child.stateNode}}function Ef(n,s){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var a=n.retryLane;n.retryLane=a!==0&&a<s?a:s}}function Ll(n,s){Ef(n,s),(n=n.alternate)&&Ef(n,s)}function jv(){return null}var If=typeof reportError=="function"?reportError:function(n){console.error(n)};function Rl(n){this._internalRoot=n}Zr.prototype.render=Rl.prototype.render=function(n){var s=this._internalRoot;if(s===null)throw Error(r(409));Jr(n,s,null,null)},Zr.prototype.unmount=Rl.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var s=n.containerInfo;Yn(function(){Jr(null,n,null,null)}),s[rn]=null}};function Zr(n){this._internalRoot=n}Zr.prototype.unstable_scheduleHydration=function(n){if(n){var s=fu();n={blockedOn:null,target:n,priority:s};for(var a=0;a<xn.length&&s!==0&&s<xn[a].priority;a++);xn.splice(a,0,n),a===0&&pu(n)}};function Ol(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function eo(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11&&(n.nodeType!==8||n.nodeValue!==" react-mount-point-unstable "))}function Mf(){}function Nv(n,s,a,u,h){if(h){if(typeof u=="function"){var p=u;u=function(){var L=Xr(k);p.call(L)}}var k=Tf(s,u,n,0,null,!1,!1,"",Mf);return n._reactRootContainer=k,n[rn]=k.current,hi(n.nodeType===8?n.parentNode:n),Yn(),k}for(;h=n.lastChild;)n.removeChild(h);if(typeof u=="function"){var S=u;u=function(){var L=Xr(b);S.call(L)}}var b=Al(n,0,!1,null,null,!1,!1,"",Mf);return n._reactRootContainer=b,n[rn]=b.current,hi(n.nodeType===8?n.parentNode:n),Yn(function(){Jr(s,b,a,u)}),b}function to(n,s,a,u,h){var p=a._reactRootContainer;if(p){var k=p;if(typeof h=="function"){var S=h;h=function(){var b=Xr(k);S.call(b)}}Jr(s,k,n,h)}else k=Nv(a,s,n,h,u);return Xr(k)}uu=function(n){switch(n.tag){case 3:var s=n.stateNode;if(s.current.memoizedState.isDehydrated){var a=Xs(s.pendingLanes);a!==0&&(ra(s,a|1),kt(s,ze()),(je&6)===0&&($s=ze()+500,Cn()))}break;case 13:Yn(function(){var u=cn(n,1);if(u!==null){var h=ft();Ut(u,n,1,h)}}),Ll(n,1)}},oa=function(n){if(n.tag===13){var s=cn(n,134217728);if(s!==null){var a=ft();Ut(s,n,134217728,a)}Ll(n,134217728)}},du=function(n){if(n.tag===13){var s=An(n),a=cn(n,s);if(a!==null){var u=ft();Ut(a,n,s,u)}Ll(n,s)}},fu=function(){return Ce},hu=function(n,s){var a=Ce;try{return Ce=n,s()}finally{Ce=a}},Xo=function(n,s,a){switch(s){case"input":if(Wo(n,a),s=a.name,a.type==="radio"&&s!=null){for(a=n;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll("input[name="+JSON.stringify(""+s)+'][type="radio"]'),s=0;s<a.length;s++){var u=a[s];if(u!==n&&u.form===n.form){var h=kr(u);if(!h)throw Error(r(90));_c(u),Wo(u,h)}}}break;case"textarea":Uc(n,a);break;case"select":s=a.value,s!=null&&is(n,!!a.multiple,s,!1)}},Jc=Cl,Xc=Yn;var Sv={usingClientEntryPoint:!1,Events:[gi,ms,kr,qc,Yc,Cl]},Ii={findFiberByHostInstance:Un,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},bv={bundleType:Ii.bundleType,version:Ii.version,rendererPackageName:Ii.rendererPackageName,rendererConfig:Ii.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:X.ReactCurrentDispatcher,findHostInstanceByFiber:function(n){return n=nu(n),n===null?null:n.stateNode},findFiberByHostInstance:Ii.findFiberByHostInstance||jv,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 no=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!no.isDisabled&&no.supportsFiber)try{Zi=no.inject(bv),Kt=no}catch{}}return yt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Sv,yt.createPortal=function(n,s){var a=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Ol(s))throw Error(r(200));return wv(n,s,null,a)},yt.createRoot=function(n,s){if(!Ol(n))throw Error(r(299));var a=!1,u="",h=If;return s!=null&&(s.unstable_strictMode===!0&&(a=!0),s.identifierPrefix!==void 0&&(u=s.identifierPrefix),s.onRecoverableError!==void 0&&(h=s.onRecoverableError)),s=Al(n,1,!1,null,null,a,!1,u,h),n[rn]=s.current,hi(n.nodeType===8?n.parentNode:n),new Rl(s)},yt.findDOMNode=function(n){if(n==null)return null;if(n.nodeType===1)return n;var s=n._reactInternals;if(s===void 0)throw typeof n.render=="function"?Error(r(188)):(n=Object.keys(n).join(","),Error(r(268,n)));return n=nu(s),n=n===null?null:n.stateNode,n},yt.flushSync=function(n){return Yn(n)},yt.hydrate=function(n,s,a){if(!eo(s))throw Error(r(200));return to(null,n,s,!0,a)},yt.hydrateRoot=function(n,s,a){if(!Ol(n))throw Error(r(405));var u=a!=null&&a.hydratedSources||null,h=!1,p="",k=If;if(a!=null&&(a.unstable_strictMode===!0&&(h=!0),a.identifierPrefix!==void 0&&(p=a.identifierPrefix),a.onRecoverableError!==void 0&&(k=a.onRecoverableError)),s=Tf(s,null,n,1,a??null,h,!1,p,k),n[rn]=s.current,hi(n),u)for(n=0;n<u.length;n++)a=u[n],h=a._getVersion,h=h(a._source),s.mutableSourceEagerHydrationData==null?s.mutableSourceEagerHydrationData=[a,h]:s.mutableSourceEagerHydrationData.push(a,h);return new Zr(s)},yt.render=function(n,s,a){if(!eo(s))throw Error(r(200));return to(null,n,s,!1,a)},yt.unmountComponentAtNode=function(n){if(!eo(n))throw Error(r(40));return n._reactRootContainer?(Yn(function(){to(null,null,n,!1,function(){n._reactRootContainer=null,n[rn]=null})}),!0):!1},yt.unstable_batchedUpdates=Cl,yt.unstable_renderSubtreeIntoContainer=function(n,s,a,u){if(!eo(a))throw Error(r(200));if(n==null||n._reactInternals===void 0)throw Error(r(38));return to(n,s,a,!1,u)},yt.version="18.3.1-next-f1338f8080-20240426",yt}var Bf;function em(){if(Bf)return Dl.exports;Bf=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Dl.exports=Rv(),Dl.exports}var zf;function Ov(){if(zf)return so;zf=1;var e=em();return so.createRoot=e.createRoot,so.hydrateRoot=e.hydrateRoot,so}var Pv=Ov(),x=uc();const As="teamtrail",ve={slug:As,name:"Teamtrail",category:"The trail map for AI coding agents",tagline:"You pick the destination. Your agents walk the trail.",assistant:{name:"Scout"},labelPrefix:As,dataDir:`.${As}`,apiPrefix:`/__${As}`,noRegisterEnv:`${As.toUpperCase()}_NO_REGISTER`},Eo=`${As}.prefs`,Io=e=>`${ve.labelPrefix}:${e}`,dc=Io("map"),fc=Io("hitl"),_v=e=>e==="task"||e==="execute",hc=Io("plan-only"),vo=["research","prototype","junction","task","execute"],Mo=[...vo,"review"],ns="plan+execute",Dv=["verifying","rework","blocked"],mc=["off","checks","checks+review","checks+review+human"],tm=e=>mc.find(t=>t===e);function Wi(e){return e.type==="junction"||e.type==="prototype"?"hitl":e.type==="research"?"afk":e.hitl?"hitl":"afk"}const Bv=["task","execute"];function nm(e,t,r=ns){return e.state==="closed"?e.closeReason==="not_planned"?"out-of-scope":"decided":e.status==="verifying"?"verifying":e.status==="blocked"?"held":e.assignee?"claimed":e.status==="rework"?"rework":r==="plan-only"&&e.type==="execute"?"parked":e.blockedBy.some(l=>{var c;return((c=t.get(l))==null?void 0:c.state)==="open"})?"blocked":"frontier"}function Fs(e,t=ns){const r=new Map(e.map(o=>[o.id,o]));return new Map(e.map(o=>[o.id,nm(o,r,t)]))}const Ue=200,Ge=56;function Ff(e,t="LR",r=ns){var be;const o=t==="LR"?330:124,l=t==="LR"?112:262,c=Fs(e,r),d=new Map(e.map(te=>[te.id,te])),f=new Map,g=new Set,m=te=>{if(f.has(te))return f.get(te);if(g.has(te))return 0;g.add(te);const P=d.get(te),Y=P&&P.blockedBy.length?1+Math.max(...P.blockedBy.filter(ae=>d.has(ae)).map(m),-1):0;return g.delete(te),f.set(te,Y),Y},v=e.filter(te=>c.get(te.id)!=="out-of-scope"),y=e.filter(te=>c.get(te.id)==="out-of-scope"),w=[];for(const te of v)(w[be=m(te.id)]??(w[be]=[])).push(te);const j=[],$=new Map;let N=0;w.forEach(te=>{te&&(te.sort((P,Y)=>{const ae=Z=>{const U=Z.blockedBy.map(D=>$.get(D)).filter(D=>D!==void 0);return U.length?U.reduce((D,H)=>D+H,0)/U.length:Z.createdAt/1e12};return ae(P)-ae(Y)||P.createdAt-Y.createdAt}),N=Math.max(N,te.length),te.forEach((P,Y)=>$.set(P.id,Y)))}),w.forEach((te,P)=>{if(!te)return;const Y=(N-te.length)*l/2;te.forEach((ae,Z)=>{const U=P*o,D=Y+Z*l;j.push({ticket:ae,state:c.get(ae.id),layer:P,x:t==="LR"?U:D,y:t==="LR"?D:U})})});const M=Math.max(w.length,1)*o-(o-(t==="LR"?Ue:Ge)),R=Math.max(N,1)*l-(l-(t==="LR"?Ge:Ue)),O=t==="LR"?M:R,X=t==="LR"?R:M,se=X+54,Q=Math.max(1,Math.floor((O+24)/(Ue+24)));y.forEach((te,P)=>{j.push({ticket:te,state:"out-of-scope",layer:-1,x:P%Q*(Ue+24),y:se+Math.floor(P/Q)*(Ge+16)})});const F=[],ie=new Map(j.map(te=>[te.ticket.id,te]));for(const te of j)for(const P of te.ticket.blockedBy){const Y=ie.get(P);Y&&F.push({from:Y,to:te})}const V=Math.ceil(y.length/Q),ge=Math.max(O,Math.min(y.length,Q)*(Ue+24)-24),Re=y.length?se+V*(Ge+16)-16:X;return{direction:t,nodes:j,edges:F,width:ge,graphH:X,quarantineY:se,height:Re,quarantineH:V*(Ge+16)+24}}const sm=["fast","balanced","strongest"],im=e=>sm.includes(e),pc={research:"fast",task:"balanced",execute:"balanced",junction:"strongest",prototype:"strongest",review:"strongest"};function zv(e,t){var r,o;return((o=(r=t.modelMatching)==null?void 0:r.tiers)==null?void 0:o[e.type])??pc[e.type]}function Fv(e){return Object.fromEntries(Mo.map(t=>[t,zv({type:t},e)]))}const Uv=["holding","challenged","invalidated","confirmed"],Hv=e=>Uv.includes(e),rm=ve.labelPrefix,Wv=new RegExp(`^-\\s+(?:\\[([a-z]+)\\]\\s+)?(.*?)\\s*(?:<!-- ${rm}:asm (\\{.*\\}) -->)?\\s*$`),Kv=1e3,Vv=e=>e.replace(/--/g,"-\\u002d"),Gv=e=>e.replace(/\s*\n\s*/g," ").trim();function Qv(e){const t={id:e.id,tickets:e.tickets,...e.source?{source:e.source}:{},...e.challenge?{challenge:{...e.challenge,evidence:e.challenge.evidence.slice(0,Kv)}}:{},...e.decidedBy?{decidedBy:e.decidedBy}:{}};return`- [${e.status}] ${Gv(e.text)} <!-- ${rm}:asm ${Vv(JSON.stringify(t))} -->`}function qv(e){const t=e.map(Yv);let r=Math.max(0,...t.map(o=>Xv(o.id)))+1;return t.map(o=>o.id?o:{...o,id:`S-${r++}`})}function Yv(e){const t=e.match(Wv),r=t==null?void 0:t[1],o=(t==null?void 0:t[2])??e.replace(/^-\s+/,""),l=Jv(t==null?void 0:t[3]);return{id:l.id??"",text:o,status:Hv(r)?r:"holding",tickets:Array.isArray(l.tickets)?l.tickets.map(String):[],...l.source?{source:l.source}:{},...l.challenge?{challenge:l.challenge}:{},...l.decidedBy?{decidedBy:l.decidedBy}:{}}}function Jv(e){if(!e)return{};try{const t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}function Xv(e){const t=e==null?void 0:e.match(/^S-(\d+)$/);return t?Number(t[1]):0}const om=[["destination","Destination"],["notes","Notes"],["assumptions","Assumptions"],["decisions","Decisions so far"],["unspecified","Not yet specified"],["outOfScope","Out of scope"]],Zv=Object.fromEntries(om),ek=/^-\s+(?:\[?([#A-Z0-9-]+)\]?:?\s+)?(.*)$/;function tk(e){var o;const t=l=>l.length?l.map(c=>`- ${c}`).join(`
|
|
41
41
|
`):"_None yet._",r=l=>l.length?l.map(c=>`- ${c.ticketKey?`${c.ticketKey}: `:""}${c.text}`).join(`
|
|
42
42
|
`):"_None yet._";return[`## Destination
|
|
43
43
|
|
|
@@ -103,7 +103,7 @@ ${o}`].join(`
|
|
|
103
103
|
> `)}
|
|
104
104
|
>`),"","</details>"]:[])}}return o.join(`
|
|
105
105
|
`)+`
|
|
106
|
-
`}function Xl(e,t,r){try{const o=e.get(t);return o?JSON.parse(o):r}catch{return r}}class Vf{constructor(t,r="presence"){ue(this,"seen");this.store=t,this.key=r,this.seen=Xl(t,r,{})}snapshot(){return{...this.seen}}lastSeen(t){return this.seen[t]}lastSeenAny(){const t=Object.values(this.seen);return t.length?Math.max(...t):void 0}markSeen(t,r=Date.now()){let o=!1;for(const l of t)(this.seen[l]??0)>=r||(this.seen[l]=r,o=!0);o&&this.store.set(this.key,JSON.stringify(this.seen))}}const Ul=5*6e4,sy=14*864e5;class Gf{constructor(t,r="usage"){ue(this,"buckets");ue(this,"dirty",!1);ue(this,"timer");ue(this,"totals");this.store=t,this.key=r,this.buckets=Xl(t,r,{}),this.totals=Xl(t,`${r}.totals`,{})}addTotal(t,r,o,l=Date.now()){const c=this.totals[r],d={inputTokens:o.inputTokens-((c==null?void 0:c.inputTokens)??0),outputTokens:o.outputTokens-((c==null?void 0:c.outputTokens)??0),costUsd:o.costUsd-((c==null?void 0:c.costUsd)??0)};this.totals[r]={...o,at:l},d.inputTokens>0||d.outputTokens>0||d.costUsd>0?this.add(t,d,r,l):this.save()}add(t,r,o,l=Date.now()){var g;if(!t)return;const c=Math.floor(l/Ul)*Ul,d=(g=this.buckets)[t]??(g[t]=[]);let f=d.find(m=>m.at===c);f||(f={at:c,i:0,o:0,c:0,s:[]},d.push(f),d.sort((m,v)=>m.at-v.at)),f.i+=r.inputTokens,f.o+=r.outputTokens,f.c+=r.costUsd,f.s.includes(o)||f.s.push(o),this.save()}since(t,r){const o={inputTokens:0,outputTokens:0,costUsd:0,sessions:0},l=new Set;for(const c of this.buckets[t]??[])c.at+Ul<=r||(o.inputTokens+=c.i,o.outputTokens+=c.o,o.costUsd+=c.c,c.s.forEach(d=>l.add(d)));return o.sessions=l.size,o}save(){this.dirty=!0,!this.timer&&(this.timer=setTimeout(()=>{if(this.timer=void 0,!this.dirty)return;this.dirty=!1;const t=Date.now()-sy;for(const r of Object.keys(this.buckets))this.buckets[r]=this.buckets[r].filter(o=>o.at>=t);for(const[r,o]of Object.entries(this.totals))o.at<t&&delete this.totals[r];this.store.set(this.key,JSON.stringify(this.buckets)),this.store.set(`${this.key}.totals`,JSON.stringify(this.totals))},2e3))}}function iy(e){const t=e.now??Date.now(),r=e.snaps.map(d=>{var
|
|
106
|
+
`}function Xl(e,t,r){try{const o=e.get(t);return o?JSON.parse(o):r}catch{return r}}class Vf{constructor(t,r="presence"){ue(this,"seen");this.store=t,this.key=r,this.seen=Xl(t,r,{})}snapshot(){return{...this.seen}}lastSeen(t){return this.seen[t]}lastSeenAny(){const t=Object.values(this.seen);return t.length?Math.max(...t):void 0}markSeen(t,r=Date.now()){let o=!1;for(const l of t)(this.seen[l]??0)>=r||(this.seen[l]=r,o=!0);o&&this.store.set(this.key,JSON.stringify(this.seen))}}const Ul=5*6e4,sy=14*864e5;class Gf{constructor(t,r="usage"){ue(this,"buckets");ue(this,"dirty",!1);ue(this,"timer");ue(this,"totals");this.store=t,this.key=r,this.buckets=Xl(t,r,{}),this.totals=Xl(t,`${r}.totals`,{})}addTotal(t,r,o,l=Date.now()){const c=this.totals[r],d={inputTokens:o.inputTokens-((c==null?void 0:c.inputTokens)??0),outputTokens:o.outputTokens-((c==null?void 0:c.outputTokens)??0),costUsd:o.costUsd-((c==null?void 0:c.costUsd)??0)};this.totals[r]={...o,at:l},d.inputTokens>0||d.outputTokens>0||d.costUsd>0?this.add(t,d,r,l):this.save()}add(t,r,o,l=Date.now()){var g;if(!t)return;const c=Math.floor(l/Ul)*Ul,d=(g=this.buckets)[t]??(g[t]=[]);let f=d.find(m=>m.at===c);f||(f={at:c,i:0,o:0,c:0,s:[]},d.push(f),d.sort((m,v)=>m.at-v.at)),f.i+=r.inputTokens,f.o+=r.outputTokens,f.c+=r.costUsd,f.s.includes(o)||f.s.push(o),this.save()}since(t,r){const o={inputTokens:0,outputTokens:0,costUsd:0,sessions:0},l=new Set;for(const c of this.buckets[t]??[])c.at+Ul<=r||(o.inputTokens+=c.i,o.outputTokens+=c.o,o.costUsd+=c.c,c.s.forEach(d=>l.add(d)));return o.sessions=l.size,o}save(){this.dirty=!0,!this.timer&&(this.timer=setTimeout(()=>{if(this.timer=void 0,!this.dirty)return;this.dirty=!1;const t=Date.now()-sy;for(const r of Object.keys(this.buckets))this.buckets[r]=this.buckets[r].filter(o=>o.at>=t);for(const[r,o]of Object.entries(this.totals))o.at<t&&delete this.totals[r];this.store.set(this.key,JSON.stringify(this.buckets)),this.store.set(`${this.key}.totals`,JSON.stringify(this.totals))},2e3))}}function iy(e){const t=e.now??Date.now(),r=e.snaps.map(d=>{var ie;const f=d.map.id,g=e.since(f),m=V=>!!V&&V>=g,v=Fs(d.tickets,d.map.mode),y=new Map(d.tickets.map(V=>[V.id,V])),w=(e.attention??[]).filter(V=>V.mapId===f),j=ry(e.activity.pending.filter(V=>V.mapId===f),w),$=new Set(j.map(V=>V.ticketId)),N=V=>V.state==="open"&&($.has(V.id)||Wi(V)==="hitl"),E=d.tickets.filter(V=>v.get(V.id)==="blocked").map(V=>({ticket:V,on:V.blockedBy.map(ge=>y.get(ge)).filter(ge=>!!ge&&N(ge))})).filter(V=>V.on.length),M=e.decisions.filter(V=>V.mapId===f&&m(V.decidedAt)).sort((V,ge)=>ge.decidedAt-V.decidedAt),R=d.tickets.filter(V=>V.state==="closed"&&m(V.closedAt)).sort((V,ge)=>(V.closedAt??0)-(ge.closedAt??0)),O=R.filter(V=>V.closeReason==="completed"),X=R.filter(V=>V.closeReason==="not_planned"),se=d.tickets.filter(V=>m(V.createdAt)),Q=((ie=e.ledger)==null?void 0:ie.since(f,g))??{inputTokens:0,outputTokens:0,costUsd:0,sessions:0},F=e.activity.sessions.filter(V=>V.mapId===f&&V.status==="running");return{mapId:f,key:d.map.key,title:d.map.title,since:g,done:O,ruledOut:X,opened:se,blocked:E,waiting:j,needsYou:w,decisions:M,agentDecisions:M.filter(V=>Bi(V)==="agent"),usage:Q,active:F,changed:!!(R.length||se.length||M.length||j.some(V=>m(V.at))||Q.costUsd>0)}}),o=r.filter(d=>d.changed||d.waiting.length).sort((d,f)=>+(f.mapId===e.currentMapId)-+(d.mapId===e.currentMapId)),l=d=>o.reduce((f,g)=>f+g[d].length,0),c=o.flatMap(d=>d.waiting).reduce((d,f)=>d===void 0||f.at<d?f.at:d,void 0);return{since:o.length?Math.min(...o.map(d=>d.since)):t,now:t,trails:o,totals:{done:l("done"),ruledOut:l("ruledOut"),blocked:l("blocked"),waiting:l("waiting"),oldestWaitMs:c===void 0?void 0:t-c,agentDecisions:l("agentDecisions"),usage:o.reduce((d,f)=>({inputTokens:d.inputTokens+f.usage.inputTokens,outputTokens:d.outputTokens+f.usage.outputTokens,costUsd:d.costUsd+f.usage.costUsd,sessions:d.sessions+f.usage.sessions}),{inputTokens:0,outputTokens:0,costUsd:0,sessions:0}),active:l("active")},changed:r.some(d=>d.changed)}}function ry(e,t){const r=new Map(t.filter(l=>l.kind==="question").map((l,c)=>[l.ref,c])),o=l=>r.get(l.id)??Number.MAX_SAFE_INTEGER;return[...e].sort((l,c)=>o(l)-o(c)||l.at-c.at)}const Pi=(e,t,r=`${t}s`)=>`${e} ${e===1?t:r}`;function oy(e){return e.trails.flatMap(t=>{const r=new Set(t.waiting.map(o=>o.ticketId));return t.blocked.filter(o=>o.on.some(l=>r.has(l.id)))})}function ay(e){return e.length===1?`, and it holds up ${e[0].ticket.title.replace(/^./,t=>t.toLowerCase())}`:e.length>1?`, holding up ${Pi(e.length,"ticket")}`:""}function ly(e,t=new Date(e.now).getHours()){const r=e.totals,l=e.now-e.since>=6*36e5&&t>=5&&t<12?"Good morning.":"Welcome back.",c=[];if(r.done&&c.push(`${Pi(r.done,"ticket")} ${r.done===1?"is":"are"} done.`),r.agentDecisions&&c.push(`Agents made ${Pi(r.agentDecisions,"decision")}.`),r.waiting){const d=ay(oy(e));c.push(`${Pi(r.waiting,"decision")} ${r.waiting===1?"is":"are"} waiting on you${d}.`)}else c.push("Nothing is waiting on you.");return!r.done&&!r.agentDecisions&&r.ruledOut&&c.unshift(`${Pi(r.ruledOut,"ticket")} ruled out of scope.`),[l,...c].join(" ")}const cy=e=>{if(!e.length)return;const t=[...e].sort((o,l)=>o-l),r=Math.floor(t.length/2);return t.length%2?t[r]:Math.round((t[r-1]+t[r])/2)};function uy(e){return e.state==="open"?"open":e.closeReason==="not_planned"?"cancelled":"done"}function vm({snap:e,journal:t,answered:r,usage:o}){const l=e.map.id,c=t.filter(N=>N.mapId===l).sort((N,E)=>N.at-E.at),d=new Map;for(const N of c)d.set(N.ticketId,[...d.get(N.ticketId)??[],N]);const f=e.tickets.filter(N=>N.type!=="review").map(N=>{var X;const E=d.get(N.id)??[],M=uy(N),R=(X=E.find(se=>se.event==="claim"))==null?void 0:X.at,O=M==="done"?N.closedAt:void 0;return{id:N.id,key:N.key,title:N.title,type:N.type,outcome:M,claimedAt:R,doneAt:O,leadMs:O&&R&&O>=R?O-R:void 0,reworks:E.filter(se=>se.to==="rework").length,reviews:{passed:E.filter(se=>se.event==="review.pass").length,failed:E.filter(se=>se.event==="review.fail").length,needsHuman:E.filter(se=>se.event==="review.needs_human").length},operatorActions:E.filter(se=>se.actorKind==="trail lead").length}}),g=f.filter(N=>N.outcome==="done"),m=Math.max(0,...g.map(N=>N.doneAt??0)),v=c.filter(N=>N.actorKind==="trail lead"),y=new Set(r.filter(N=>N.mapId===l).map(N=>N.id)).size,w=v.length,j=N=>f.reduce((E,M)=>E+N(M),0),$=(o==null?void 0:o.costUsd)??0;return{mapId:l,tickets:f,done:g.length,cancelled:f.filter(N=>N.outcome==="cancelled").length,open:f.filter(N=>N.outcome==="open").length,trailLeadMs:m&&m>=e.map.createdAt?m-e.map.createdAt:void 0,medianLeadMs:cy(g.flatMap(N=>N.leadMs===void 0?[]:[N.leadMs])),interventions:{answers:y,operatorActions:w,reworkRequested:v.filter(N=>N.event==="reject").length,total:y+w},rework:{tickets:f.filter(N=>N.reworks>0).length,cycles:j(N=>N.reworks)},reviews:{passed:j(N=>N.reviews.passed),failed:j(N=>N.reviews.failed),needsHuman:j(N=>N.reviews.needsHuman)},spend:{costUsd:Math.round($*1e4)/1e4,tokens:((o==null?void 0:o.inputTokens)??0)+((o==null?void 0:o.outputTokens)??0),perVerifiedTicketUsd:g.length&&$?Math.round($/g.length*1e4)/1e4:void 0}}}const Hl=e=>e.split("-")[0];function en(e){if(e===void 0)return"—";const t=Math.round(e/6e4);if(t<90)return`${t} min`;const r=e/36e5;return r<48?`${Math.round(r*10)/10} h`:`${Math.round(r/24*10)/10} d`}const Qf=e=>e===void 0?"—":`$${e.toFixed(e<1?4:2)}`;function dy(e,t,r=Date.now()){const o=e.interventions;return[`# Trail report: ${t}`,"",`_Generated ${new Date(r).toISOString()} by Teamtrail._`,"","| Measure | Value |","| --- | --- |",`| Tickets done / cancelled / open | ${e.done} / ${e.cancelled} / ${e.open} |`,`| Trail lead time (created → last done) | ${en(e.trailLeadMs)} |`,`| Median ticket lead time (claim → done) | ${en(e.medianLeadMs)} |`,`| Human interventions | ${o.total} (${o.answers} answers, ${o.operatorActions} operator actions, ${o.reworkRequested} sent back) |`,`| Rework | ${e.rework.cycles} cycles on ${e.rework.tickets} tickets |`,`| Reviews | ${e.reviews.passed} passed, ${e.reviews.failed} failed, ${e.reviews.needsHuman} needed a human |`,`| Spend | ${Qf(e.spend.costUsd)} · ${e.spend.tokens.toLocaleString("en-US")} tokens |`,`| Cost per verified ticket | ${Qf(e.spend.perVerifiedTicketUsd)} |`,"","## Tickets","","| Ticket | Type | Outcome | Lead time | Rework | Reviews (pass/fail) | Operator actions |","| --- | --- | --- | --- | --- | --- | --- |",...e.tickets.map(c=>`| ${c.key} ${c.title.replace(/\|/g,"\\|")} | ${c.type} | ${c.outcome} | ${en(c.leadMs)} | ${c.reworks} | ${c.reviews.passed}/${c.reviews.failed} | ${c.operatorActions} |`),""].join(`
|
|
107
107
|
`)}const kc=5,km=1.5,fy=15,io=e=>Math.round(e*100);function hy(e){const t=e.filter(d=>d.findings.raised>=kc).sort((d,f)=>f.findings.upheld/f.findings.raised-d.findings.upheld/d.findings.raised||d.key.localeCompare(f.key));if(t.length<2)return[];const[r,o]=[t[0],t[t.length-1]],[l,c]=[r.findings.upheld/r.findings.raised,o.findings.upheld/o.findings.raised];return io(l)-io(c)<fy?[]:[{id:"review-findings",text:`${r.key} review findings upheld ${io(l)}% vs ${o.key} ${io(c)}%`,because:`${r.findings.upheld} of ${r.findings.raised} and ${o.findings.upheld} of ${o.findings.raised} failed reviews stood; a finding is overruled when you accept the work anyway`}]}function my(e){const t=c=>c.reworkCycles/c.tickets,r=e.filter(c=>c.tickets>=kc).sort((c,d)=>t(c)-t(d)||c.key.localeCompare(d.key));if(r.length<2)return[];const[o,l]=[r[0],r[r.length-1]];return t(l)-t(o)<.2||t(l)<t(o)*km?[]:[{id:"rework",text:`${l.key} work goes back to rework more: ${t(l).toFixed(1)} times per ticket vs ${o.key} ${t(o).toFixed(1)}`,because:`${l.reworkCycles} cycles on ${l.tickets} tickets, and ${o.reworkCycles} on ${o.tickets}`}]}function py(e,t){const r=d=>d.medianLeadMs??0,o=t.filter(d=>d.done>=kc&&d.medianLeadMs!==void 0).sort((d,f)=>r(d)-r(f)||d.key.localeCompare(f.key));if(o.length<2)return[];const[l,c]=[o[0],o[o.length-1]];return r(c)<r(l)*km?[]:[{id:`speed-${e}`,text:`${e} tickets: ${l.key} is faster, ${en(l.medianLeadMs)} vs ${c.key} ${en(c.medianLeadMs)}`,because:`Median first claim to done, over ${l.done} and ${c.done} done tickets`}]}function gy(e){const t=Object.keys(e.byTypeAndVendor).sort();return[...hy(e.byVendor),...my(e.byVendor),...t.flatMap(r=>py(r,e.byTypeAndVendor[r]))]}const vy=e=>{if(!e.length)return;const t=[...e].sort((o,l)=>o-l),r=Math.floor(t.length/2);return t.length%2?t[r]:Math.round((t[r-1]+t[r])/2)},ym=e=>{var t;return(t=e.filter(r=>r.event==="claim"&&r.actorKind==="agent").at(-1))==null?void 0:t.actor},Zl=(e,t,r)=>e.filter(o=>o.mapId===t&&o.ticketId===r).sort((o,l)=>o.at-l.at);function ky(e,t){return e.tickets.flatMap(r=>{var y;if(r.type!=="review"||!r.reviewOf)return[];const o=Zl(t,e.map.id,r.id),l=ym(o);if(!l)return[];const c=((y=o.filter(w=>w.event==="claim").at(-1))==null?void 0:y.at)??0,d=Zl(t,e.map.id,r.reviewOf),f=d.findIndex(w=>w.at>=c&&w.event.startsWith("review."));if(f<0||d[f].event!=="review.fail")return[];const g=d.slice(f+1),m=g.findIndex(w=>w.event.startsWith("review.")),v=m<0?g:g.slice(0,m);return[{reviewer:l,upheld:!v.some(w=>w.event==="accept"&&w.actorKind==="trail lead")}]})}function yy(e,t){var o;const r=(o=e.tickets.find(l=>l.id===t))==null?void 0:o.assignee;return r&&/^[a-z]+-\d+$/.test(r)?r:void 0}function xm(e,t){const r=l=>t.reduce((c,{ticket:d})=>c+l(d),0),o=l=>t.filter(c=>c.ticket.outcome===l).length;return{key:e,tickets:t.length,done:o("done"),cancelled:o("cancelled"),open:o("open"),medianLeadMs:vy(t.flatMap(({ticket:l})=>l.leadMs===void 0?[]:[l.leadMs])),reworkCycles:r(l=>l.reworks),reviews:{passed:r(l=>l.reviews.passed),failed:r(l=>l.reviews.failed),needsHuman:r(l=>l.reviews.needsHuman)},answers:0,findings:{raised:0,upheld:0}}}function ro(e,t){const r=new Map;for(const o of e){const l=t(o);l&&r.set(l,[...r.get(l)??[],o])}return new Map([...r].map(([o,l])=>[o,xm(o,l)]))}const ec=(e,t)=>{const r=e.get(t)??xm(t,[]);return e.set(t,r),r};function qf(e,t,r){const o=ec(e,t);o.findings.raised+=1,r&&(o.findings.upheld+=1)}const oo=e=>[...e.values()].sort((t,r)=>r.tickets-t.tickets||t.key.localeCompare(r.key));function wm(e){const t=e.flatMap(({snap:m,journal:v,answered:y,usage:w})=>vm({snap:m,journal:v,answered:y,usage:w}).tickets.map(j=>({ticket:j,agent:ym(Zl(v,m.map.id,j.id))??yy(m,j.id)}))),r=m=>m.agent?Hl(m.agent):void 0,o=ro(t,m=>m.agent),l=ro(t,r),c=ro(t,m=>m.ticket.type),d=new Set;for(const{snap:m,journal:v,answered:y}of e){for(const w of y){const j=`${w.mapId}/${w.id}`;w.mapId!==m.map.id||d.has(j)||(d.add(j),ec(o,w.agent).answers+=1,ec(l,Hl(w.agent)).answers+=1)}for(const w of ky(m,v))qf(o,w.reviewer,w.upheld),qf(l,Hl(w.reviewer),w.upheld)}const f=Object.fromEntries([...c.keys()].map(m=>[m,oo(ro(t.filter(v=>v.ticket.type===m),r))])),g={trails:e.length,tickets:t.length,byAgent:oo(o),byVendor:oo(l),byType:oo(c),byTypeAndVendor:f};return{...g,recommendations:gy(g)}}const xy={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
108
|
`)},wy=[["summary","Summary"],["productContext","Product context"],["existing","Existing implementation"],["conventions","Conventions and abstractions"],["dataModel","Data model impact"],["api","API impact"],["risks","Risks and possible regressions"],["assumptions","Assumptions"],["openQuestions","Open questions"]],Li=Object.fromEntries(wy);function jy(e,t){const r=new Set(e.map(o=>o.source).filter(Boolean));return t.filter(o=>!r.has(o))}const Ny=["architecture","convention","gotcha","dead-end","glossary","fact"],jm=["business-rule","product-decision","persona","ux-principle","pricing"],Sy=[...Ny,...jm],by=e=>e.status==="confirmed"||e.status==="assumption";function Cy(e,t){const r=e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*\//g,"§DIRS§").replace(/\*\*/g,"§DEEP§").replace(/\*/g,"[^/]*").replace(/§DIRS§/g,"(?:.*/)?").replace(/§DEEP§/g,".*");return new RegExp(`^${r}$`).test(t.replace(/^\.\//,""))}const $y={"business-rule":3,convention:3,"product-decision":2,architecture:2,gotcha:2,"dead-end":2,"ux-principle":2},Ty=["business-rule","ux-principle","convention"],Yf=600,Ey=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(" ")),Jf=e=>new Set((e.toLowerCase().match(/[a-z0-9][a-z0-9_-]{2,}/g)??[]).filter(t=>!Ey.has(t)));function Nm(e,t,r=4e3,o=()=>[]){const l=t.ticket?Jf(`${t.ticket.title} ${t.ticket.body}`):new Set,c=new Set((t.tags??[]).map(m=>m.toLowerCase())),d=e.filter(by).map(m=>{const v=[];let y=$y[m.kind]??1;for(const $ of m.scope){const N=t.paths.find(E=>Cy($,E));if(N){y+=6,v.push(`path match ${$} (${N})`);break}}const w=m.tags.filter($=>c.has($.toLowerCase())||l.has($.toLowerCase()));w.length&&(y+=3*w.length,v.push(`tag ${w.join(", ")}`));const j=[...Jf(m.title)].filter($=>l.has($));return j.length&&(y+=j.length,v.push(`mentions ${j.slice(0,3).join(", ")}`)),t.trailKey&&m.sources.includes(`trail:${t.trailKey}`)&&(y+=3,v.push("same trail")),t.discovery&&jm.includes(m.kind)&&(y+=8,v.push("product context for discovery")),!v.length&&Ty.includes(m.kind)&&!m.scope.length&&v.push(`${m.kind.replace("-"," ")} for the whole project`),{e:m,score:y,why:v}}).filter(m=>m.why.length>0).sort((m,v)=>v.score-m.score||m.e.id.localeCompare(v.e.id,void 0,{numeric:!0})),f=[];let g=0;for(const{e:m,why:v}of d){const y=m.body.length>Yf?`${m.body.slice(0,Yf)}…`:m.body;if(g+y.length>r&&f.length)break;g+=y.length;const w=o(m);f.push({id:m.id,title:m.title,kind:m.kind,status:m.status,body:y,why:v,...w.length?{mayBeOutdated:w}:{},...m.flag?{flagged:m.flag.reason}:{}})}return f}const Iy=new RegExp("`([^`\\s]+/[^`\\s]+)`|(?:^|[\\s(])/?((?:[\\w.-]+/)+[\\w.-]+)","gm");function Sm(e){const t=new Set;for(const r of e.matchAll(Iy))t.add((r[1]??r[2]).replace(/^\.?\//,"").replace(/[.,;:]+$/,""));return[...t]}const My=[{level:"high",label:"High risk"},{level:"medium",label:"Medium risk"},{level:"low",label:"Low risk"},{level:"none",label:"No category"}];function Ay(e){return My.map(t=>({...t,decisions:e.filter(r=>{var o;return(((o=r.risk)==null?void 0:o.level)??"none")===t.level})})).filter(t=>t.decisions.length)}const Ly=1/3;function Po(e,t=Date.now()){const r=e.expiresAt-t;return r<=0?"expired":r<=e.ttlMs*Ly?"stalled":"live"}function Ry(e){var t;return((t=e.returned)==null?void 0:t.reason)==="trail lead"?`${e.ticketKey} returned to queue · claim of ${e.agent} released by ${e.returned.by}`:`${e.ticketKey} returned to queue after ${e.agent} went silent`}const Oy=e=>e.urgency==="fyi"||e.kind==="policy",Xf=e=>Number(e.slice(0,2))*60+Number(e.slice(3,5));function Py(e,t){const r=new Date(t),o=r.getHours()*60+r.getMinutes(),l=Xf(e.from),c=Xf(e.to),d=c<=l;if(!(d?o>=l||o<c:o>=l&&o<c))return!1;if(!e.days)return!0;const g=d&&o<c,m=(r.getDay()+(g?6:0))%7;return e.days.includes(m)}function _y(e,t){const r=new Date(t);return r.setHours(Number(e.to.slice(0,2)),Number(e.to.slice(3,5)),0,0),r.getTime()<=t&&r.setDate(r.getDate()+1),r.getTime()}function Dy(e,t){const r=e.focusUntil??0;if(r>t)return{kind:"manual",until:r};if(!e.focus||!Py(e.focus,t))return{kind:"off"};const o=_y(e.focus,t);return(e.focusOffUntil??0)>t?{kind:"paused",until:o}:{kind:"hours",until:o}}function By(e,t,r){const o={...e};switch(delete o.focusUntil,delete o.focusOffUntil,t.kind){case"for":return{...o,focusUntil:r+t.minutes*6e4};case"resume":return o;case"end":{const l=Dy(o,r);return l.kind==="hours"?{...o,focusOffUntil:l.until}:o}default:return t}}function zy(e,t){var o;const r={...e};return t.verification===null?delete r.verification:t.verification&&(r.verification=t.verification),t.guides===null||((o=t.guides)==null?void 0:o.length)===0?delete r.guides:t.guides&&(r.guides=t.guides),t.modelMatching===null?delete r.modelMatching:t.modelMatching&&(r.modelMatching=t.modelMatching),r}function Fy(e,t,r){const o=Date.now();return{id:e,key:t,...r,state:"open",blockedBy:[],comments:[],createdAt:o,updatedAt:o}}const Uy=(e,t)=>({...e,blockedBy:e.blockedBy.filter(r=>r!==t)}),Hy=(e,t)=>{var r;return{...e,...(r=t.title)!=null&&r.trim()?{title:t.title.trim()}:{},...t.body!==void 0?{body:t.body}:{}}};function Wy(e){const{closeReason:t,closedAt:r,...o}=e;return{...o,state:"open"}}const Ky=["status","verification","checks","reviewOf","guide"];function Vy(e,t){const r={...e};for(const o of Ky)t[o]!==void 0&&(t[o]===null?delete r[o]:r[o]=t[o]);return r}const Gy=/^([^/]+)\/decisions\/([^/]+)\.md$/,Qy=(e,t)=>e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,40)||`map-${t}`;class qy{constructor(t,r){ue(this,"seen",new Map);ue(this,"pending",new Map);this.read=t,this.emit=r}knows(t){return this.seen.has(t)}remember(t,r,o){this.seen.set(t,{text:r,supersededBy:o})}queue(t){const r=t.split("/")[0],o=this.pending.get(r)??{paths:new Set,timer:setTimeout(()=>void this.flush(r),250)};o.paths.add(t),this.pending.set(r,o)}async flush(t){const r=this.pending.get(t);if(this.pending.delete(t),!r)return;const o=[...r.paths].filter(d=>Gy.test(d)),l=[];for(const d of o){const f=await this.read(d).catch(()=>""),g=this.seen.get(d);if(!f||(g==null?void 0:g.text)===f)continue;const m=Jl(f);this.seen.set(d,{text:f,supersededBy:m.supersededBy}),g?m.supersededBy&&m.supersededBy!==g.supersededBy&&l.push({kind:"decision.superseded",mapId:t,decisionId:m.id,supersededBy:m.supersededBy,external:!0,at:Date.now()}):l.push({kind:"decision.recorded",mapId:t,decisionId:m.id,ticketId:m.ticketId,external:!0,at:Date.now()})}o.length?!l.length&&o.length<r.paths.size&&l.push({kind:"external.changed",mapId:t,at:Date.now()}):l.push({kind:"external.changed",mapId:t,at:Date.now()});const c=d=>d.kind==="decision.recorded"?0:1;l.sort((d,f)=>c(d)-c(f));for(const d of l)this.emit(d)}}function Yy(e){const t=e.filter(([r,o])=>Mo.includes(r)&&im(o));return Object.fromEntries(t)}function Jy(e){const t=xe(e["model-matching"]);if(t!=="on"&&t!=="off")return;const r=Yy(Ht(e["model-tiers"]).map(o=>o.split("=").map(l=>l.trim())));return Object.keys(r).length?{enabled:t==="on",tiers:r}:{enabled:t==="on"}}function Xy(e){if(!e)return{};const t=Object.entries(e.tiers??{}).map(([r,o])=>`${r}=${o}`);return{"model-matching":e.enabled?"on":"off",...t.length?{"model-tiers":t}:{}}}function Zy(e,t){const{front:r,body:o}=Oo(t),l=tm(xe(r.verification)),c=Jy(r);return{id:e,key:xe(r.key)||e,title:xe(r.title)||e,mode:xe(r.mode)==="plan-only"||Ht(r.labels).includes(hc)?"plan-only":ns,...l?{verification:l}:{},...Ht(r.guides).length?{guides:Ht(r.guides)}:{},...c?{modelMatching:c}:{},sections:nk(o),createdAt:Rs(r.created),updatedAt:Rs(r.updated)}}function ex(e){var t;return vc({key:e.key,title:e.title,mode:e.mode,...e.verification?{verification:e.verification}:{},...(t=e.guides)!=null&&t.length?{guides:e.guides}:{},...Xy(e.modelMatching),labels:[dc,...e.mode==="plan-only"?[hc]:[]],created:Jt(e.createdAt),updated:Jt(e.updatedAt)},tk(e.sections))}async function Zf(e){const t=await e.list(),r=t.filter(l=>!l.includes("/decisions/")).map(l=>{var c;return Number(((c=l.match(/(\d+)\.md$/))==null?void 0:c[1])??0)}),o=await Promise.all(t.filter(l=>l.endsWith("/map.md")).map(async l=>Number(xe(Oo(await e.read(l)).front.key).replace(/\D/g,""))||0));return Math.max(0,...r,...o)+1}function eh(e){const{front:t,body:r}=Oo(e),[o,l=""]=r.split(/^## Comments\s*$/m),c=l.split(/^### /m).slice(1).map((m,v)=>{const y=m.indexOf(`
|
|
109
109
|
`),[w,j]=m.slice(0,y).split(" @ ");return{id:`c${v}`,author:w.trim(),createdAt:Date.parse(j)||0,body:m.slice(y+1).trim()}}),d=xe(t.close_reason),f=Dv.find(m=>m===xe(t.status)),g=tm(xe(t.verification));return{id:xe(t.id),key:`#${xe(t.id)}`,title:xe(t.title),type:xe(t.type)||"task",hitl:Ht(t.labels).includes(fc)||void 0,state:xe(t.state)==="closed"?"closed":"open",closeReason:d==="completed"||d==="not_planned"?d:void 0,assignee:xe(t.assignee)||void 0,...f?{status:f}:{},...g?{verification:g}:{},...t.checks!==void 0?{checks:Ht(t.checks)}:{},...xe(t.review_of)?{reviewOf:xe(t.review_of)}:{},...xe(t.guide)?{guide:xe(t.guide)}:{},blockedBy:Ht(t.blocked_by),body:o.trim(),comments:c,createdAt:Rs(t.created),updatedAt:Rs(t.updated),closedAt:Rs(t.closed)||void 0}}function tx(e){const t={id:e.id,title:e.title,type:e.type,labels:[Io(e.type),..._v(e.type)&&e.hitl?[fc]:[]],state:e.state,close_reason:e.closeReason??"",assignee:e.assignee??"",...e.status?{status:e.status}:{},...e.verification?{verification:e.verification}:{},...e.checks?{checks:e.checks}:{},...e.reviewOf?{review_of:e.reviewOf}:{},...e.guide?{guide:e.guide}:{},blocked_by:e.blockedBy,created:Jt(e.createdAt),updated:Jt(e.updatedAt),...e.closedAt?{closed:Jt(e.closedAt)}:{}},r=e.comments.length?`
|
|
@@ -114,20 +114,20 @@ ${e.comments.map(o=>`### ${o.author} @ ${Jt(o.createdAt)}
|
|
|
114
114
|
|
|
115
115
|
${o.body}`).join(`
|
|
116
116
|
|
|
117
|
-
`)}`:"";return vc(t,e.body+r)}class nx{constructor(t,r=`./${ve.dataDir}`){ue(this,"kind","markdown");ue(this,"label","Local markdown");ue(this,"events",new Os);ue(this,"selfWrites",new Map);ue(this,"external",new qy(t=>this.fs.read(t),t=>this.events.emit(t)));var o;this.fs=t,this.location=r,(o=t.watch)==null||o.call(t,l=>{const c=this.selfWrites.get(l);c&&Date.now()-c<1500||this.external.queue(l)})}async put(t,r){this.selfWrites.set(t,Date.now()),await this.fs.write(t,r)}async readMap(t){return Zy(t,await this.fs.read(`${t}/map.md`))}async writeMap(t){await this.put(`${t.id}/map.md`,ex(t))}async readTicket(t,r){return eh(await this.fs.read(`${t}/tickets/${r}.md`))}async writeTicket(t,r){await this.put(`${t}/tickets/${r.id}.md`,tx({...r,updatedAt:Date.now()}))}async listMaps(){const r=(await this.fs.list()).filter(o=>/^[^/]+\/map\.md$/.test(o)).map(o=>o.split("/")[0]);return Promise.all(r.map(async o=>{const l=await this.readMap(o);return{id:o,key:l.key,title:l.title}}))}async loadMap(t){const r=await this.fs.list(),o=await this.readMap(t),l=r.filter(d=>d.startsWith(`${t}/tickets/`)),c=await Promise.all(l.map(async d=>eh(await this.fs.read(d))));return{map:o,tickets:c.sort((d,f)=>d.createdAt-f.createdAt)}}async createMap(t){const r=await Zf(this.fs),o=Qy(t.title,r),l={id:o,key:`#${r}`,title:t.title,mode:t.mode??ns,...t.verification?{verification:t.verification}:{},sections:t.sections,createdAt:Date.now(),updatedAt:Date.now()};return await this.writeMap(l),this.events.emit({kind:"map.created",mapId:o,at:Date.now()}),l}async editMap(t,r,o){await this.writeMap({...r(await this.readMap(t)),updatedAt:Date.now()}),this.events.emit(o)}setMapMode(t,r){return this.editMap(t,o=>({...o,mode:r}),{kind:"map.mode",mapId:t,mode:r,at:Date.now()})}setMapMeta(t,r){return this.editMap(t,o=>zy(o,r),{kind:"map.updated",mapId:t,at:Date.now()})}updateMapSections(t,r){const o=Object.keys(r)[0];return this.editMap(t,l=>({...l,sections:{...l.sections,...r}}),{kind:"map.updated",mapId:t,section:o,at:Date.now()})}async createTicket(t,r){const o=await Zf(this.fs),l=Fy(String(o),`#${o}`,r);return await this.writeTicket(t,l),this.events.emit({kind:"ticket.created",mapId:t,ticketId:l.id,at:Date.now()}),l}async addBlocking(t,r,o){const l=await this.readTicket(t,o);l.blockedBy.includes(r)||await this.writeTicket(t,{...l,blockedBy:[...l.blockedBy,r]}),this.events.emit({kind:"edge.added",mapId:t,blockerId:r,blockedId:o,at:Date.now()})}async update(t,r,o){await this.writeTicket(t,o(await this.readTicket(t,r)))}async removeBlocking(t,r,o){await this.update(t,o,l=>Uy(l,r)),this.events.emit({kind:"edge.removed",mapId:t,blockerId:r,blockedId:o,at:Date.now()})}async editTicket(t,r,o){await this.update(t,r,l=>Hy(l,o)),this.events.emit({kind:"ticket.updated",mapId:t,ticketId:r,at:Date.now()})}async reopen(t,r){await this.update(t,r,Wy),this.events.emit({kind:"ticket.updated",mapId:t,ticketId:r,at:Date.now()})}async assign(t,r,o){await this.update(t,r,l=>({...l,assignee:o??void 0})),this.events.emit(o?{kind:"ticket.claimed",mapId:t,ticketId:r,assignee:o,at:Date.now()}:{kind:"ticket.released",mapId:t,ticketId:r,at:Date.now()})}async comment(t,r,o,l){await this.update(t,r,c=>({...c,comments:[...c.comments,{id:`c${c.comments.length}`,author:o,body:l,createdAt:Date.now()}]})),this.events.emit({kind:"ticket.commented",mapId:t,ticketId:r,at:Date.now()})}async close(t,r,o){await this.update(t,r,l=>({...l,state:"closed",closeReason:o,closedAt:Date.now()})),this.events.emit({kind:"ticket.closed",mapId:t,ticketId:r,reason:o,at:Date.now()})}async setMeta(t,r,o){await this.update(t,r,l=>Vy(l,o)),this.events.emit({kind:"ticket.updated",mapId:t,ticketId:r,at:Date.now()})}async listDecisions(t){const r=(await this.fs.list()).filter(o=>o.startsWith(`${t}/decisions/`));return Promise.all(r.map(async o=>{const l=await this.fs.read(o),c={...Jl(l),mapId:t};return this.external.knows(o)||this.external.remember(o,l,c.supersededBy),c}))}async createDecision(t,r){const o=(await this.fs.list()).filter(f=>f.includes("/decisions/")),l=Math.max(0,...o.map(f=>wk(f.split("/").pop())))+1,c=xk(`D-${l}`,t,r),d=Kf(c);return this.external.remember(`${t}/decisions/${c.id}.md`,d),await this.put(`${t}/decisions/${c.id}.md`,d),this.events.emit({kind:"decision.recorded",mapId:t,decisionId:c.id,ticketId:c.ticketId,at:Date.now()}),c}async markSuperseded(t,r,o){const l=`${t}/decisions/${r}.md`,c=Jl(await this.fs.read(l)),d=Kf({...c,mapId:t,supersededBy:o});this.external.remember(l,d,o),await this.put(l,d),this.events.emit({kind:"decision.superseded",mapId:t,decisionId:r,supersededBy:o,at:Date.now()})}subscribe(t){return this.events.on(t)}}class th extends Error{constructor(t,r,o,l){super(r),this.code=t,this.status=o,this.resetAt=l,this.name="TrackerError"}}const sx={github:"GitHub Issues",linear:"Linear"};async function xt(e,t,r){let o;try{o=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:r===void 0?void 0:JSON.stringify(r)})}catch{throw new th("offline","Lookout server unreachable; is `teamtrail` still running?")}const l=await o.json().catch(()=>({}));if(!o.ok)throw new th(l.code??"http",l.error??`request failed (${o.status})`,o.status,l.resetAt);return l}class ix{constructor(t,r,o=""){ue(this,"label");ue(this,"location");ue(this,"status",{state:"connecting",queued:0});ue(this,"events",new Os);ue(this,"statusEvents",new Os);ue(this,"source");ue(this,"listeners",0);ue(this,"listMaps",()=>this.call("listMaps"));ue(this,"loadMap",t=>this.call("loadMap",t));ue(this,"createMap",t=>this.call("createMap",t));ue(this,"setMapMode",(t,r)=>this.call("setMapMode",t,r));ue(this,"setMapMeta",(t,r)=>this.call("setMapMeta",t,r));ue(this,"updateMapSections",(t,r)=>this.call("updateMapSections",t,r));ue(this,"createTicket",(t,r)=>this.call("createTicket",t,r));ue(this,"addBlocking",(t,r,o)=>this.call("addBlocking",t,r,o));ue(this,"removeBlocking",(t,r,o)=>this.call("removeBlocking",t,r,o));ue(this,"editTicket",(t,r,o)=>this.call("editTicket",t,r,o));ue(this,"reopen",(t,r)=>this.call("reopen",t,r));ue(this,"assign",(t,r,o)=>this.call("assign",t,r,o));ue(this,"comment",(t,r,o,l)=>this.call("comment",t,r,o,l));ue(this,"close",(t,r,o)=>this.call("close",t,r,o));ue(this,"setMeta",(t,r,o)=>this.call("setMeta",t,r,o));ue(this,"listDecisions",t=>this.call("listDecisions",t));ue(this,"createDecision",(t,r)=>this.call("createDecision",t,r));ue(this,"markSuperseded",(t,r,o)=>this.call("markSuperseded",t,r,o));this.kind=t,this.base=r,this.label=sx[t],this.location=o}async call(t,...r){return(await xt(`${this.base}/tracker/${this.kind}/call`,"POST",{method:t,args:r})).result}open(){const t=new EventSource(`${this.base}/tracker/${this.kind}/events`);t.onmessage=r=>this.events.emit(JSON.parse(r.data)),t.addEventListener("status",r=>{const o=JSON.parse(r.data);o.location&&(this.location=o.location),this.status=o,this.statusEvents.emit(o)}),t.onerror=()=>{this.status.state!=="offline"&&(this.status={...this.status,state:"offline",error:"Lookout server unreachable"},this.statusEvents.emit(this.status))},this.source=t}subscribe(t){const r=this.events.on(t);return++this.listeners===1&&this.open(),()=>{var o;r(),--this.listeners===0&&((o=this.source)==null||o.close(),this.source=void 0)}}onStatus(t){return this.statusEvents.on(t)}}function rx(e){return{get:()=>xt(`${e}/trackers`,"GET"),test:t=>xt(`${e}/trackers/test`,"POST",t),connect:t=>xt(`${e}/trackers`,"PUT",t),forget:t=>xt(`${e}/trackers/credentials/${t}`,"DELETE"),githubRepos:()=>xt(`${e}/trackers/github/repos`,"GET"),githubSignIn:{start:()=>xt(`${e}/trackers/github/sign-in/start`,"POST"),poll:()=>xt(`${e}/trackers/github/sign-in/poll`,"POST"),cancel:()=>xt(`${e}/trackers/github/sign-in/cancel`,"POST"),signOut:()=>xt(`${e}/trackers/github/sign-in`,"DELETE")},linearTeams:t=>t?xt(`${e}/trackers/linear/teams`,"POST",{apiKey:t}):xt(`${e}/trackers/linear/teams`,"GET"),linearProjects:(t,r)=>r?xt(`${e}/trackers/linear/projects`,"POST",{apiKey:r,teamId:t}):xt(`${e}/trackers/linear/projects?team=${encodeURIComponent(t)}`,"GET")}}const ox=[{id:"markdown",name:"Local markdown",status:"available"},{id:"github",name:"GitHub Issues",status:"available"},{id:"linear",name:"Linear",status:"available"}],bm=[{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"}],ax=bm[0],lx="https://github.com/teamtrailhq/teamtrail-guides",cx=`${lx}/blob/main/CONTRIBUTING.md`;function ux(e,t={}){const r=(t.query??"").toLowerCase().split(/\s+/).filter(Boolean);return e.guides.filter(o=>{if(t.verifiedOnly&&!o.verified&&!o.builtin)return!1;const l=[o.id,o.name??"",o.summary,o.author].join(" ").toLowerCase();return r.every(c=>l.includes(c))})}const dx={ink:"#16302a",shellLight:"#f6f1e2",shell:"#eae3cf",shellShade:"#c8bea2",frame:"#b4aa8f",glass:"#14241f",scan:"#18302a",glow:"#6fbf8f",glowLight:"#b4e8c0",cup:"#b9562a",cupLight:"#d67a45",cupDark:"#8a3d1d",band:"#8f9690",hat:"#8a5a38",visor:"#6b4630",panel:"#e6dcc0",button:"#c8581e"},Cm={on:"#e2711d",dim:"#a8501c",alert:"#ff5a48"},fx={on:"#ffd166",dim:"#a8501c",alert:"#ff5a48"},De=([e,t,r,o],l,c=.35)=>`<rect x="${e}" y="${t}" width="${r}" height="${o}" rx="${c}" fill="${l}"/>`;function nh(e,t,r){if(t==="closed")return De([e,17,3,1],r.glow);if(t==="wide")return De([e,15,3,3],r.glowLight)+De([e+1,16,1,1],r.glass,.2);const o=t==="aside"?e+1:e;return De([o,16,3,1.1],r.glow)+De([o,17,3,1],r.glowLight)}function hx(e,t){return e==="open"?De([13,20,6,1.1],t.glowLight)+De([15,21,2,1],t.glow):e==="mid"?De([14,20,4,1],t.glowLight):De(e==="aside"?[17,20,2,1]:[15,20,2,1],t.glow)}const mx=[13,15,17,19,21,23];function px(e){return[mx.map(t=>De([9.2,t,13.6,1],e.scan,0)).join(""),De([10,13,2,1],e.frame,.2),De([10,14,1,1],e.frame,.2),De([10,25.2,1,1],e.button,.2),De([11.2,25.2,1,1],e.cupDark,.2),[17,19,21].map(t=>De([t,25.2,1,1.6],e.shellLight,.2)+De([t,25.2,1,.8],e.frame,.2)).join("")].join("")}function sh(e,t,r){return[`<rect x="${e}" y="15" width="5.4" height="11" rx="1.7" fill="${t.cup}" ${r}/>`,De([e+1,16,1.2,9],t.cupLight,.5),De([e+3.6,16,.9,9],t.cupDark,.4)].join("")}function gx(e,{lamp:t=Cm,simple:r=!1,colors:o=dx}={}){const l=o,c=r?"open":e.eyes,d=r?"rest":e.mouth,f=`stroke="${l.ink}" stroke-width=".9" stroke-linejoin="round"`;return['<g transform="scale(6.25)">',`<path d="M3 16.5Q3 6 16 5.5Q29 6 29 16.5" fill="none" stroke="${l.ink}" stroke-width="3"/>`,`<path d="M3 16.5Q3 6 16 5.5Q29 6 29 16.5" fill="none" stroke="${l.band}" stroke-width="1.5"/>`,sh(.6,l,f),sh(26,l,f),`<path d="M8 9H24Q26 9 26 11V25L23.5 28.5H8.5L6 25V11Q6 9 8 9Z" fill="${l.shell}" ${f}/>`,`<path d="M6.5 25H25.5L23.3 28H8.7Z" fill="${l.shellShade}"/>`,De([6.6,10,1.6,15],l.shellLight,.6),De([8.4,11,15.2,13.6],l.frame,1.3),De([9,11.6,14,12.4],l.glass,1),r?"":px(l),nh(11,c,l),nh(18,c,l),hx(d,l),`<path d="M6.5 10.5Q5.8 3.5 16 3.100Q26.2 3.5 25.5 10.5Z" fill="${l.hat}" ${f}/>`,`<path d="M10.5 9.5Q10.3 4.9 16 4.5Q21.7 4.9 21.5 9.5Z" fill="${l.panel}" stroke="${l.ink}" stroke-width=".5"/>`,r?"":`<path d="M16 5.400l1.2 1.7h-.6l1 1.5h-3.2l1-1.5h-.6z" fill="${l.hat}"/>`,`<path d="M6.3 9.8Q16 7.9 25.7 9.8Q27.2 12 25 12.600Q16 10.9 7 12.600Q4.8 12 6.3 9.8Z" fill="${l.visor}" ${f}/>`,`<circle cx="16" cy="2.600" r="1.3" fill="${t[e.light??"on"]}" stroke="${l.ink}" stroke-width=".7"/>`,"</g>"].join("")}const $m={crt:{id:"crt",name:"Day",blurb:"The original CRT head with ear cups and a baseball cap.",lamp:Cm,wave:{bar:"#6f8a78",lead:"#c8581e"}},night:{id:"night",name:"Night",blurb:"The same Scout, with the cap lamp burning bright, for the night theme.",lamp:fx,wave:{bar:"#66828d",lead:"#e8833a"}}},vx="crt",kx={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"}},yx={idle:"WATCHING",speaking:"TALKING",alert:"NEEDS YOU",thinking:"THINKING"},hn={msPerChar:55,mouthHoldMs:110,blinkEveryMs:5600,blinkMs:140,thinkingStepMs:520};function xx(e){return e?/[aeiouy]/i.test(e)?"open":/[a-z0-9]/i.test(e)?"mid":"rest":"rest"}function wx(e,t){return!e||!/[a-z0-9]/i.test(e)?0:/[aeiou]/i.test(e)?2+(e.charCodeAt(0)+t)%2:1+(e.charCodeAt(0)*7+t)%2}function jx(e,t,r){return Array.from({length:r},(o,l)=>{const c=t-(r-1-l);return c>=0&&c<e.length?wx(e[c],c):0})}function Tm({face:e={eyes:"open",mouth:"rest"},variant:t="crt",size:r,simple:o,className:l}){const{eyes:c,mouth:d,light:f}=e,g=x.useMemo(()=>gx({eyes:c,mouth:d,light:f},{lamp:$m[t].lamp,simple:o??r<28}),[c,d,f,t,o,r]);return i.jsx("svg",{className:l,width:r,height:r,viewBox:"0 0 200 200","aria-hidden":"true",dangerouslySetInnerHTML:{__html:g}})}function Nx(e){const[t,r]=x.useState(!1);return x.useEffect(()=>{if(!e){r(!1);return}let o;const l=setInterval(()=>{r(!0),o=setTimeout(()=>r(!1),hn.blinkMs)},hn.blinkEveryMs);return()=>{clearInterval(l),o&&clearTimeout(o)}},[e]),t}const Sx={xs:.8,sm:2,md:4,lg:6},bx=40,ih=20,rh="(prefers-reduced-motion: reduce)",Cx=40,$x=350;function Tx(e,t){var f;const r=e.size??"md",o=e.state??"idle",l=((f=e.speaking)==null?void 0:f.trim())??"",c=l&&(o==="idle"||o==="speaking")?"speaking":o,d=r==="xs";return{size:r,text:l,effective:c,talking:c==="speaking"&&l.length>0,mini:d,framed:e.framed??!d,reduced:t||d}}const Ex=e=>e.length*hn.msPerChar,Ix=(e,t)=>t&&(e.effective==="idle"||e.effective==="speaking"||e.effective==="alert");function Mx(e,t,r,o){const l=kx[e.effective],c=r?"closed":l.eyes;let d=l.mouth,f=e.text.length-1;if(o)if(e.reduced)d="open";else{f=Math.min(e.text.length-1,Math.floor(t/hn.msPerChar));const m=Math.floor(t/hn.mouthHoldMs)*Math.round(hn.mouthHoldMs/hn.msPerChar);d=xx(e.text[Math.min(e.text.length-1,m)])}let g=l.light;return e.effective==="thinking"&&!e.reduced&&Math.floor(t/hn.thinkingStepMs)%2===1&&(g="on"),{eyes:c,mouth:d,light:g,cursor:f}}function Ax(e,t){const r=typeof e.size=="number"?e.size:Sx[e.size],o=e.reduced?Math.min(e.text.length-1,ih-1):t;return{base:r,px:bx*r,bars:ih,waveCursor:o}}function Lx(e,{label:t,speechDone:r,cursor:o,caption:l}){const c=e.talking&&r?"idle":e.effective,d=yx[c],f=e.size==="md"||e.size==="lg"||typeof e.size=="number"&&e.size>=4;return{shownState:c,status:d,ariaLabel:`${t}, ${d.toLowerCase()}`,showCaption:l??f,shown:Rx(e,r,o)}}function Rx(e,t,r){return e.talking?e.reduced||t?e.text:e.text.slice(0,r+1):""}function Ox(){const[e,t]=x.useState(()=>{var r;return typeof window<"u"&&!!((r=window.matchMedia)!=null&&r.call(window,rh).matches)});return x.useEffect(()=>{var l;const r=(l=window.matchMedia)==null?void 0:l.call(window,rh);if(!r)return;const o=()=>t(r.matches);return o(),r.addEventListener("change",o),()=>r.removeEventListener("change",o)},[]),e}function Px(e,t,r){const[o,l]=x.useState(0);return x.useEffect(()=>{if(l(0),!t)return;const c=performance.now(),d=setInterval(()=>l(performance.now()-c),r);return()=>clearInterval(d)},[e,t,r]),o}function _x(e){const{key:t,talking:r,at:o}=e,l=o!==void 0,c=Ex(e.text),[d,f]=x.useState(""),g=x.useRef(e.onSpeakEnd);g.current=e.onSpeakEnd,x.useEffect(()=>{if(!r||l)return;const j=setTimeout(()=>{var $;f(t),($=g.current)==null||$.call(g)},c+$x);return()=>clearTimeout(j)},[r,t,c,l]);const m=r&&d!==t,v=Px(t,e.animate&&(m||e.thinking),m?Cx:hn.thinkingStepMs),y=o??v,w=r&&(l?y>=c:d===t);return{t:y,speechDone:w}}const Dx=e=>e*2,tc=3.5;function Bx(e,t,r){return(e??[]).map((o,l)=>{const c=(1+2*o)*.5;return{x:l*2,y:(tc-c)/2,width:1,height:c,fill:l>=t-2&&o>0?r.lead:r.bar}})}function zx({heights:e,bars:t,unit:r,colors:o}){const l=Dx(t);return i.jsx("svg",{className:`scout-wave${e?" on":""}`,width:l*r,height:tc*r,viewBox:`0 0 ${l} ${tc}`,"aria-hidden":"true",children:Bx(e,t,o).map((c,d)=>i.jsx("rect",{...c},d))})}function _o({state:e="idle",size:t="md",speaking:r,variant:o=vx,framed:l,caption:c,label:d="Scout",onSpeakEnd:f,at:g,className:m,style:v}){const y=Tx({state:e,size:t,speaking:r,framed:l},Ox()),{text:w,effective:j,talking:$,reduced:N}=y,E=$m[o],R=!N&&!(g!==void 0),O=`${j}|${o}|${w}`,{t:X,speechDone:ie}=_x({key:O,text:w,talking:$,thinking:j==="thinking",animate:R,at:g,onSpeakEnd:f}),D=Nx(Ix(y,R)),q=$&&!ie,{eyes:re,mouth:V,light:ge,cursor:Re}=Mx(y,X,D,q),{base:be,px:te,bars:P,waveCursor:Y}=Ax(y,Re),ae=x.useMemo(()=>q?jx(w,Y,P):null,[q,w,Y,P]),{shownState:Z,status:U,ariaLabel:B,showCaption:H,shown:T}=Lx(y,{label:d,speechDone:ie,cursor:Re,caption:c}),_={...v,"--scout-u":`${be}px`},he=i.jsx("span",{className:"scout-sprite",children:i.jsx(Tm,{face:{eyes:re,mouth:V,light:ge},variant:o,size:te,simple:y.mini})});return y.framed?i.jsxs("figure",{className:`scout scout-panel scout-${Z} scout-v-${o} ${m??""}`,style:_,"data-state":Z,children:[i.jsxs("figcaption",{className:"scout-head",children:[i.jsx("span",{className:"scout-name",children:d}),i.jsx("span",{className:"scout-sep",children:"//"}),i.jsx("span",{className:"scout-status",children:U})]}),i.jsxs("div",{className:"scout-feed",role:"img","aria-label":B,children:[he,i.jsx(zx,{heights:ae,bars:P,unit:be,colors:E.wave})]}),H&&i.jsxs("p",{className:"scout-caption","aria-hidden":"true",children:[T,$&&!ie&&!N&&i.jsx("span",{className:"scout-caret",children:"_"})]}),w&&i.jsx("span",{className:"scout-sr","aria-live":"polite",children:w})]}):i.jsx("span",{className:`scout scout-bare scout-${Z} ${m??""}`,style:_,role:"img","aria-label":B,children:he})}function Fx(){return['<rect x="1" y="1" width="198" height="198" rx="44" fill="#17211c" stroke="var(--tt-logo-edge, #17211c)" stroke-width="2"/>','<g transform="translate(32 32) scale(.68)">','<path d="M58 8L104 0V132Q104 150 124 150H150V196H112Q58 196 58 142Z" fill="#8fbf84"/>','<path d="M14 58H150V102H14Z" fill="#8fbf84"/>','<circle cx="182" cy="173" r="23" fill="#e8833a"/>',"</g>"].join("")}function Ux(){return['<g transform="translate(-3 2) scale(.98)">','<path d="M58 8L104 0V132Q104 150 124 150H150V196H112Q58 196 58 142Z" fill="#5f9658"/>','<path d="M14 58H150V102H14Z" fill="#5f9658"/>','<circle cx="182" cy="173" r="23" fill="#e8833a"/>',"</g>"].join("")}function Hx({size:e=40,bare:t,className:r}){const o=x.useMemo(()=>t?Ux():Fx(),[t]);return i.jsx("svg",{className:r,width:e,height:e,viewBox:"0 0 200 200",role:"img","aria-label":"Teamtrail",dangerouslySetInnerHTML:{__html:o}})}const wt="trail lead";function Wx({rt:e,guard:t,setMapId:r,mapIdRef:o,snapRef:l,setChatSession:c,setSelection:d}){const f={actorKind:"trail lead",journal:e.journal};return{selectMap:g=>r(g),openChat:g=>c(g),answer:(g,m)=>e.activity.answer(g,m,wt),claim:g=>t("Claim",()=>Uf(e.adapter,o.current,g,{...f,assignee:wt})),release:g=>t("Release claim",()=>pk(e.adapter,o.current,g,{...f,actor:wt})),releaseLease:g=>t("Release to queue",()=>e.leases.release(o.current,g,wt)),resolve:(g,m,v={})=>t("Resolve · record answer",async()=>{var w;const y=(w=l.current)==null?void 0:w.tickets.find(j=>j.id===g);y&&!y.assignee&&await Uf(e.adapter,o.current,g,{...f,assignee:wt}),await Nk(e.adapter,o.current,g,{...f,answer:m,author:wt,decision:{...v,source:{kind:"lookout",label:"Ticket inspector"}}})}),supersede:(g,m)=>t(`Supersede ${g.id}`,async()=>{let v=g.id;if(g.derived){const{id:y,mapId:w,derived:j,supersededBy:$,...N}=g;v=(await gc(e.adapter,g.mapId,N,{appendToTrail:!1})).id}await gk(e.adapter,g.mapId,v,{...m,decidedBy:wt,participants:[{id:wt}],source:{kind:"lookout",label:"Logbook"}})}),graduate:({unspecified:g,...m})=>t(`Promote to ticket · ${g}`,async()=>{const v=await Sk(e.adapter,o.current,g,m);d({kind:"ticket",id:v.id})}),ruleOut:(g,m)=>t("Rule out of scope",async()=>{await bk(e.adapter,o.current,g,{...f,reason:m,author:wt,source:{kind:"lookout",label:"Ticket inspector"}}),d(null)}),setMode:g=>t(`Trail mode · ${g}`,()=>vk(e.adapter,o.current,g)),setModelMatching:g=>t(`Model matching · ${g.enabled?"on":"off"}`,()=>Ck(e.adapter,o.current,g))}}const We=(...e)=>e.filter(Boolean).join(" "),Ps="item",Kx=/^[0-9a-f]{6,64}$/;function Do(){const e=new URLSearchParams(location.search).get("project")??void 0;return e&&Kx.test(e)?e:void 0}function Se(e=Do()){return e?`${ve.apiPrefix}/p/${e}`:ve.apiPrefix}function Vx(e){const t=new URLSearchParams(location.search);for(const o of["projects","project","tracker",Ps])t.delete(o);e.item&&t.set(Ps,e.item),e.id&&e.id!==e.home&&t.set("project",e.id),e.id&&e.id!==e.home&&e.tracker&&t.set("tracker",e.tracker);const r=t.toString();return`${location.pathname}${r?`?${r}`:""}`}async function Gx(e,t){var c;const r=(t.assumptions??[]).map((d,f)=>({id:`S-${f+1}`,text:d,status:"holding",tickets:[]})),{map:o,tickets:l}=await ik(e,{title:t.title,sections:{destination:t.destination,notes:t.notes,decisions:[],unspecified:[],outOfScope:[],...r.length?{assumptions:r}:{}},tickets:[{ref:"discovery",...xy}]});return await fetch(`${Se()}/briefs/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:o.id,ticketId:(c=l[0])==null?void 0:c.id})}),o}function Em(e,t){const r=URL.createObjectURL(new Blob([t],{type:"text/markdown;charset=utf-8"}));Object.assign(document.createElement("a"),{href:r,download:e}).click(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}function nn(e){const t=Math.max(0,Math.floor(e/1e3));return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:`${Math.floor(t/3600)}h`}function Im(e){const t=Math.max(0,Math.floor(e/1e3)),r=o=>String(o).padStart(2,"0");return`${r(Math.floor(t/3600))}:${r(Math.floor(t%3600/60))}:${r(t%60)}`}const Bo=e=>new Date(e).toTimeString().slice(0,8);function Wt(e){if(e<1e3)return`${Math.round(e)}ms`;const t=Math.round(e/1e3);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m ${String(t%60).padStart(2,"0")}s`:`${Math.floor(t/3600)}h ${String(Math.floor(t%3600/60)).padStart(2,"0")}m`}function zo(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}const _s=e=>`$${e<10?e.toFixed(2):e.toFixed(1)}`,Ds=e=>new Date(e).toISOString().slice(0,10),yc=e=>new Date(e).toTimeString().slice(0,5),Qx=e=>`${Ds(e)} ${yc(e)}`,Mm=e=>{if(!e)return"";const t=Math.max(0,Math.round((Date.now()-e)/1e3));return t<60?`${t}s ago`:`${Math.round(t/60)}m ago`},Vi=e=>e?new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",zi={research:"Research",prototype:"Prototype",junction:"Junction",task:"Task",execute:"Execute",review:"Review"},Am={decided:"Done",claimed:"Working",frontier:"Ready",blocked:"Backlog",parked:"Parked (plan-only)","out-of-scope":"Cancelled",verifying:"Verifying",rework:"Rework",held:"Blocked"},qx={decided:"done",claimed:"working",frontier:"ready",blocked:"backlog",parked:"parked","out-of-scope":"cancelled",verifying:"verifying",rework:"rework",held:"blocked"};function xc(e,t){return new Map((e??[]).filter(r=>r.mapId===t&&!r.returned).map(r=>[r.ticketId,r]))}const wc=(e,t)=>`${e}/${t}`;let mn={reached:!1,live:!1,tickets:{}},nc=!1;const sc=new Set,ic=new Set;function yo(e){mn=e;for(const t of sc)t()}function oh(){fetch(`${Se()}/verification/sync`).then(e=>e.ok?e.json():Promise.reject()).then(e=>yo({reached:!0,live:!0,status:e.status,tickets:Object.fromEntries(e.tickets.map(t=>[wc(t.mapId,t.ticketId),t]))}),()=>mn.reached&&yo({...mn,live:!1}))}function ah(){nc=!0,oh();const e=new EventSource(`${Se()}/events`);e.addEventListener("verification",t=>{const r=JSON.parse(t.data);if(r.kind==="evidence")for(const l of ic)l();if(r.kind!=="sync")return;const o={...mn.tickets};for(const l of r.tickets)o[wc(l.mapId,l.ticketId)]=l;yo({reached:!0,live:!0,status:r.status,tickets:o})}),e.addEventListener("error",()=>mn.reached&&mn.live&&yo({...mn,live:!1})),e.addEventListener("open",()=>mn.reached&&oh())}const Bs={subscribe(e){return nc||ah(),sc.add(e),()=>void sc.delete(e)},get:()=>mn,onEvidence(e){return nc||ah(),ic.add(e),()=>void ic.delete(e)},ticket:(e,t,r)=>e.tickets[wc(t,r)]};function Yx(e){if(e!=null&&e.flags.length)return e.flags.some(t=>t.severity==="alert")?"alert":"warn"}const lh={onboarded:!1,tracker:"markdown",hitlTranscript:"summary",agent:ax.id,github:{repo:""},linear:{team:""},briefing:{enabled:!0,awayMinutes:15},theme:"night"};function jc(){try{const e={...lh,...JSON.parse(localStorage.getItem(Eo)??"{}")};return["markdown","github","linear"].includes(e.tracker)||(e.tracker="markdown"),e}catch{return lh}}function Lm(e){e==="auto"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e}const Jx=15*6e4;class Xx{constructor(t){ue(this,"leases",[]);ue(this,"changes",new Os);ue(this,"logged",new Set);ue(this,"since",Date.now()-Jx);this.activity=t}subscribe(t){return this.changes.on(t)}set(t){var r;this.leases=t;for(const o of t){const l=`${o.mapId}/${o.ticketId}/${(r=o.returned)==null?void 0:r.at}`;!o.returned||o.returned.at<this.since||this.logged.has(l)||(this.logged.add(l),this.activity.push({source:"system",level:"warn",ticketId:o.ticketId,text:Ry(o)}))}this.changes.emit(t)}async release(t,r,o){const l=await fetch(`${Se()}/agents/leases/release`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,ticketId:r,by:o})});if(!l.ok)throw new Error((await l.json().catch(()=>({}))).error??`HTTP ${l.status}`)}}let Xt;const xo=new Set,Fi=new Map;function Rm(e){Xt==null||Xt.addEventListener(e,t=>{for(const r of Fi.get(e)??[])r(t.data)})}function Om(){if(!Xt){Xt=new EventSource(`${Se()}/events`),Xt.onmessage=e=>{const t=JSON.parse(e.data).path;if(typeof t=="string")for(const r of xo)r(t)};for(const e of Fi.keys())Rm(e)}}function Pm(){const e=[...Fi.values()].some(t=>t.size>0);xo.size||e||(Xt==null||Xt.close(),Xt=void 0)}function pn(e){return xo.add(e),Om(),()=>{xo.delete(e),Pm()}}function Fo(e,t){let r=Fi.get(e);return r||(r=new Set,Fi.set(e,r),Rm(e)),r.add(t),Om(),()=>{r.delete(t),Pm()}}function Zx(e,t){return Fo(e,r=>t(JSON.parse(r)))}const ew={async list(){return(await(await fetch(`${Se()}/list`)).json()).files},async read(e){const t=await fetch(`${Se()}/file?path=${encodeURIComponent(e)}`);if(!t.ok)throw new Error(`read ${e}: ${t.status}`);return t.text()},async write(e,t){const r=await fetch(`${Se()}/file?path=${encodeURIComponent(e)}`,{method:"PUT",body:t});if(!r.ok)throw new Error(`write ${e}: ${r.status}`)},watch(e){return pn(e)}};function ch(e,t){e.remoteAnswer=(o,l,c)=>{fetch(`${Se()}/agents/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:o.sessionId,questionId:o.id,text:l,author:c})}).then(async d=>{if(!d.ok)throw new Error((await d.json().catch(()=>({}))).error??`HTTP ${d.status}`)}).catch(d=>e.push({source:"system",level:"alert",sessionId:o.sessionId,text:`Answer not delivered to ${o.agent} · ${d.message}`}))};const r=new EventSource(`${Se()}/events`);r.addEventListener("agent",o=>e.syncRemote(JSON.parse(o.data))),r.addEventListener("leases",o=>t.set(JSON.parse(o.data).leases)),fetch(`${Se()}/agents/leases`).then(o=>o.ok?o.json():{leases:[]}).then(({leases:o})=>t.set(o)).catch(()=>{}),fetch(`${Se()}/agents`).then(o=>o.ok?o.json():{sessions:[]}).then(({sessions:o})=>[...o].reverse().forEach(l=>e.syncRemote(l))).catch(()=>{})}function uh(e){const t=r=>`${Eo}:${e}:${r}`;return{get:r=>localStorage.getItem(t(r)),set:(r,o)=>{try{localStorage.setItem(t(r),o)}catch{}}}}const tw=["markdown","github","linear"];function nw(){const e=new URLSearchParams(location.search).get("tracker");return e&&tw.includes(e)?e:jc().tracker}function sw(e){let t,r;const o=new Rk,l=new Xx(o),c={},d=Ek(Se());if(e==="github"||e==="linear"){const m=new ix(e,Se());t=m,r=fetch(`${Se()}/trackers`).then(v=>v.json()).catch(()=>{}).then(v=>{m.location=(e==="github"?v==null?void 0:v.github.repo:[v==null?void 0:v.linear.teamKey,v==null?void 0:v.linear.projectName].filter(Boolean).join(" · "))||m.location;const y=uh(`${e}:${m.location}`);c.presence=new Vf(y),o.ledger=new Gf(y),ch(o,l)})}else t=new nx(ew,`./${ve.dataDir}`),r=fetch(`${Se()}/list`).then(m=>m.json()).catch(()=>({root:"default"})).then(({root:m})=>{const v=uh(m);c.presence=new Vf(v),o.ledger=new Gf(v),ch(o,l)});const f=Dk(t),g=f.adapter;return{kind:e,ready:r,get presence(){return c.presence},adapter:g,journal:d,monitor:f,activity:o,leases:l}}const tn=e=>e.status==="running",_m=e=>tn(e)&&!!e.waitingOn,iw={blocking:0,soon:1,fyi:2};function rw(e,t,r){const o=e.filter(d=>d.sessionId===t),l=o.find(d=>d.id===r);if(l)return l;const c=d=>iw[d.urgency??"soon"];return[...o].sort((d,f)=>c(d)-c(f)||d.at-f.at)[0]}function ts({n:e,urgent:t,pop:r,hideZero:o}){return i.jsx("span",{className:We("badge",t&&"urgent",r&&t&&"pop",o&&!e&&"zero"),children:o&&!e?"":e})}function K({variant:e="default",size:t="md",on:r,className:o,type:l,...c}){return i.jsx("button",{type:l??"button",className:We("btn",e!=="default"&&e,t==="sm"&&"sm",r&&"on",o),...c})}function Ot({as:e="div",tone:t,on:r,className:o,children:l,...c}){return i.jsx(e,{className:We("card",t,r&&"on",o),...c,children:l})}function ht({on:e,title:t,sub:r,disabled:o,onClick:l}){return i.jsxs(Ot,{as:"button",type:"button",className:"choice",on:e,disabled:o,onClick:l,children:[i.jsx("b",{className:"choice-title t-row-title",children:t}),r&&i.jsx("span",{className:"c-sub",children:r})]})}function Ee({children:e}){return i.jsx("div",{className:"empty",children:e})}function Dn({title:e,hint:t,art:r}){return i.jsxs("div",{className:r?"empty-state has-art":"empty-state",children:[r,i.jsxs("div",{className:"es-words",children:[i.jsx("span",{className:"es-title",children:e}),t&&i.jsx("span",{className:"es-hint",children:t})]})]})}function Ye({label:e,children:t,className:r}){return i.jsxs("label",{className:We("field",r),children:[e,t]})}const Nc=x.forwardRef(function({value:t,onValueChange:r,onSubmit:o,action:l="Send",actionDisabled:c,className:d,...f},g){return i.jsxs("form",{className:We("input-row",d),onSubmit:m=>{m.preventDefault(),o(t)},children:[i.jsx("textarea",{ref:g,rows:1,value:t,onChange:m=>r(m.target.value),onKeyDown:m=>{m.key==="Enter"&&!m.shiftKey&&(m.preventDefault(),o(t))},...f}),i.jsx(K,{type:"submit",variant:"primary",disabled:c??(f.disabled||!t.trim()),children:l})]})});function Us({text:e}){return i.jsx("span",{className:"info-tip","data-tip":e,"data-tip-scout":!0,tabIndex:0,role:"img","aria-label":e,children:i.jsxs("svg",{viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":"true",children:[i.jsx("circle",{cx:"7",cy:"3.7",r:"1.3"}),i.jsx("path",{d:"M5.6 6.300H8v4.200h1v1.200H5v-1.200h1.200V7.500h-.6z"})]})})}function Je({as:e="span",variant:t="chip",hot:r,size:o,className:l,children:c,title:d}){return i.jsx(e,{className:We(t==="chip"?"chip-label":"mono-label",r&&"hot",o==="sm"&&(t==="chip"?"sm":"xs"),l),title:d,children:c})}const ow=e=>typeof e=="string"?{text:e}:e,aw=e=>We(e.code&&"t-code",e.strong&&"strong",e.urgent&&"urgent",e.className);function Q(e){const t=e.parts.filter(r=>!!r&&(typeof r=="string"||!!r.text)).map(ow);return!t.length&&!e.children?null:i.jsxs("span",{className:We("meta-line t-meta",e.className),children:[t.map((r,o)=>i.jsxs("span",{children:[o>0&&i.jsx("span",{className:"sep",children:" · "}),i.jsx("span",{className:aw(r)||void 0,title:r.tip,children:r.text})]},o)),e.children]})}function Sc(e){return i.jsxs("div",{className:"ds-load-failed",role:"alert",children:[i.jsx(Q,{parts:[e.what,e.reason]}),i.jsx(K,{size:"sm",variant:"ghost",onClick:e.onRetry,children:"Retry"})]})}function Hs(e){const t=Array.from({length:e.rows??0},(r,o)=>o);return i.jsxs("div",{className:We("ds-loading",e.className),role:"status","aria-live":"polite",children:[i.jsxs("span",{className:"ds-loading-line t-meta",children:[i.jsx("span",{className:"ds-spinner","aria-hidden":"true"}),e.label]}),t.length>0&&i.jsx("ul",{className:"ds-skeleton-list","aria-hidden":"true",children:t.map(r=>i.jsxs("li",{className:"ds-skeleton-row",children:[i.jsx("span",{className:"ds-skeleton-bar title"}),i.jsx("span",{className:"ds-skeleton-bar meta"})]},r))})]})}const lw="M25.53 10.5 A11 11 0 1 1 16 5",cw="M20 5 L14.6 1.6 L14.6 8.4 Z";function Ws({variant:e="mark",state:t="ok",size:r=20,className:o="",title:l}){const c=r<=14?3:2.4;return i.jsxs("svg",{className:`scout-mark mm-${e} mm-${t} ${o}`,viewBox:"0 0 32 32",width:r,height:r,role:l?"img":void 0,"aria-label":l,"aria-hidden":l?void 0:!0,children:[e==="status"||e==="alert"?i.jsx("circle",{cx:"16",cy:"16",r:"11",fill:"none",stroke:"currentColor",strokeWidth:c,strokeDasharray:t==="syncing"?"5 3.6":void 0}):i.jsx("path",{d:lw,fill:"none",stroke:"currentColor",strokeWidth:c,strokeLinecap:"butt"}),(e==="mark"||e==="action")&&i.jsx("path",{d:cw,fill:"currentColor"}),e==="action"&&i.jsx("path",{d:"M13 11 L21.5 16 L13 21 Z",fill:"currentColor"}),(e==="mark"||e==="voice")&&i.jsx("circle",{cx:"16",cy:"16",r:e==="voice"?4:3.4,fill:"currentColor"}),e==="status"&&(t==="idle"?i.jsx("circle",{cx:"16",cy:"16",r:"3.4",fill:"none",stroke:"currentColor",strokeWidth:"1.6"}):i.jsx("circle",{cx:"16",cy:"16",r:"4.2",fill:"currentColor"})),e==="alert"&&i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"14.4",y:"8.5",width:"3.2",height:"9.5",fill:"currentColor"}),i.jsx("rect",{x:"14.4",y:"20.5",width:"3.2",height:"3.2",fill:"currentColor"})]})]})}function wo({parts:e,className:t,as:r="div"}){const o=e.filter(l=>l!=null&&l!==!1&&l!=="");return i.jsx(r,{className:We("meta",t),children:o.map((l,c)=>i.jsxs("span",{children:[c>0&&" · ",l]},c))})}function uw({size:e=40,bare:t,className:r}){return i.jsx(Hx,{size:e,bare:t,className:r})}const dh=()=>{const e=document.documentElement.dataset.theme;return e?e==="night":matchMedia("(prefers-color-scheme: dark)").matches};function bc(){const[e,t]=x.useState(dh);return x.useEffect(()=>{const r=()=>t(dh()),o=matchMedia("(prefers-color-scheme: dark)");o.addEventListener("change",r);const l=new MutationObserver(r);return l.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{o.removeEventListener("change",r),l.disconnect()}},[]),e}function dw(){const e=()=>window.innerWidth>=1440?"wide":window.innerWidth>=1024?"laptop":"mobile",[t,r]=x.useState(e);return x.useEffect(()=>{const o=()=>r(e());return window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)},[]),t}const fw=15e3,fh=["pointerdown","pointermove","keydown","wheel","touchstart"];function hw(e,t,r,o){const[l,c]=x.useState(null),[d,f]=x.useState(!1),[g,m]=x.useState(!1),v=x.useRef(),y=x.useRef(Date.now()),w=x.useRef(!1),j=r.awayMinutes*6e4,$=x.useRef(t);$.current=t;const N=x.useRef(o);N.current=o;const E=x.useCallback((D,q)=>{const re=$.current;return iy({snaps:Object.values(re.allSnaps),decisions:re.decisions,activity:re.activity,ledger:e.activity.ledger,since:V=>{var ge;return D[V]??q??((ge=re.allSnaps[V])==null?void 0:ge.map.createdAt)??Date.now()},currentMapId:re.mapId,attention:N.current})},[e]),M=x.useCallback((D=Date.now())=>{var q;return(q=e.presence)==null?void 0:q.markSeen($.current.maps.map(re=>re.id),D)},[e]),R=x.useCallback(()=>{const D=e.presence;if(!D)return;const q=D.lastSeenAny();if(q!==void 0&&Date.now()-q>=j){const re=D.snapshot();E(re,q).changed&&(v.current={seen:re,any:q},f(!0),r.enabled?c(re):m(!0))}M()},[e,j,r.enabled,E,M]);x.useEffect(()=>{!t.loaded||w.current||!e.presence||(w.current=!0,R())},[t.loaded,e,R]),x.useEffect(()=>{const D=()=>{const V=Date.now()-y.current>=j;y.current=Date.now(),V&&w.current&&document.visibilityState==="visible"&&R()},q=()=>{if(document.visibilityState!=="visible"){w.current&&M(Date.now()-y.current<j?Date.now():y.current);return}y.current=Date.now(),w.current&&R()};for(const V of fh)window.addEventListener(V,D,{passive:!0});document.addEventListener("visibilitychange",q);const re=setInterval(()=>{w.current&&document.visibilityState==="visible"&&M(y.current)},fw);return()=>{for(const V of fh)window.removeEventListener(V,D);document.removeEventListener("visibilitychange",q),clearInterval(re)}},[j,R,M]);const O=x.useMemo(()=>{var D;return l?E(l,(D=v.current)==null?void 0:D.any):void 0},[l,E,t.allSnaps,t.decisions,t.activity,o]),X=x.useMemo(()=>O?ly(O):"",[O]);x.useEffect(()=>{l&&m(!1)},[l]);let ie="none";return g?ie="new":d&&(ie="seen"),{shown:l!==null,status:ie,briefing:O,line:X,open:()=>{const D=v.current;D&&c(D.seen)},dismiss:()=>c(null)}}function mw(e){const[t,r]=x.useState(e.leases.leases);return x.useEffect(()=>e.leases.subscribe(r),[e]),t}function pw(e){var U;const[t,r]=x.useState([]),[o,l]=x.useState(),[c,d]=x.useState(),[f,g]=x.useState({}),[m,v]=x.useState({}),[y,w]=x.useState(!1),[j,$]=x.useState(e.activity.snapshot),[N,E]=x.useState(e.monitor.health),M=mw(e);x.useEffect(()=>e.monitor.subscribe(E),[e]);const[R,O]=x.useState(null),[X,ie]=x.useState(),[D,q]=x.useState(),re=x.useRef(),V=x.useRef(),ge=x.useRef(new Set),Re=x.useRef();Re.current=c;const be=x.useCallback(B=>{re.current=B,l(B),O(null)},[]),te=x.useCallback(async()=>{var pe;const B=await e.adapter.listMaps();r(B);let H=re.current;const T=V.current;T&&B.some(de=>de.id===T)?(V.current=void 0,H=T,H!==re.current&&be(H)):(!H||!B.some(de=>de.id===H))&&(H=(pe=B[0])==null?void 0:pe.id,be(H));const[_,he]=await Promise.all([Promise.all(B.map(de=>e.adapter.loadMap(de.id))),Promise.all(B.map(de=>e.adapter.listDecisions(de.id)))]);g(Object.fromEntries(_.map(de=>[de.map.id,de]))),v(Object.fromEntries(B.map((de,we)=>[de.id,he[we]]))),w(!0),d(_.find(de=>de.map.id===H))},[e,be]);x.useEffect(()=>{let B,H=()=>{},T=()=>{},_=!0;const he=()=>{clearTimeout(B),B=setTimeout(()=>void te().catch(me=>ie(String(me))),40)},pe=(me,ke)=>tn(me)&&e.activity.isRemote(me.id)&&(!ke||!me.mapId||me.mapId===ke),de=me=>{var ke;return(ke=Re.current)==null?void 0:ke.tickets.find($e=>$e.id===me)},we=me=>{const ke=Ok(me,de),$e=me.kind==="external.changed"&&e.activity.snapshot.sessions.some(ss=>pe(ss,me.mapId)),ut=!("mapId"in me)||!me.mapId||me.mapId===re.current||me.kind==="map.created";ke&&!$e&&ut&&e.activity.push(ke),he()};return e.ready.then(()=>{_&&(H=e.adapter.subscribe(we),T=e.activity.subscribe($),e.activity.push({source:"system",level:"ok",text:`Online · tracker ${e.adapter.label.toLowerCase()} · ${e.adapter.location}`}),te().catch(me=>ie(String(me))))}),()=>{_=!1,H(),T(),clearTimeout(B)}},[e,te]),x.useEffect(()=>{o&&e.adapter.loadMap(o).then(d)},[o,e]),x.useEffect(()=>{for(const B of j.sessions)B.mode!=="chart"||!B.mapId||!e.activity.isRemote(B.id)||ge.current.has(B.id)||(ge.current.add(B.id),!(B.status!=="running"&&Date.now()-(B.endedAt??0)>6e4)&&(V.current=B.mapId,te().catch(H=>ie(String(H)))))},[j.sessions,e,te]);const P=(U=j.pending[0])==null?void 0:U.sessionId;x.useEffect(()=>{if(!P)return;const B=H=>e.activity.snapshot.sessions.some(T=>T.id===H&&tn(T));q(H=>B(H)?H:P)},[P,e]);const Y=x.useCallback(async(B,H)=>{e.activity.push({source:"trail lead",agent:wt,level:"warn",text:B});try{ie(void 0),await H()}catch(T){const _=T.message??String(T);ie(_),e.activity.push({source:"trail lead",agent:wt,level:"alert",text:`Rejected · ${_}`})}},[e]),ae=x.useMemo(()=>Wx({rt:e,guard:Y,setMapId:be,mapIdRef:re,snapRef:Re,setChatSession:q,setSelection:O}),[Y,e,be]),Z=x.useMemo(()=>Object.values(f).flatMap(B=>Hk(B,m[B.map.id]??[])).sort((B,H)=>H.decidedAt-B.decidedAt),[f,m]);return{maps:t,allSnaps:f,mapId:o,snap:c,activity:j,health:N,selection:R,setSelection:O,error:X,chatSession:D,decisions:Z,leases:M,loaded:y,actions:ae}}function sn(e=1e3){const[t,r]=x.useState(Date.now());return x.useEffect(()=>{const o=setInterval(()=>r(Date.now()),e);return()=>clearInterval(o)},[e]),t}function gw(){const[e,t]=x.useState(jc),r=x.useCallback(o=>{t(l=>{const c={...l,...o};return localStorage.setItem(Eo,JSON.stringify(c)),c})},[]);return[e,r]}function Cc(){return x.useSyncExternalStore(Bs.subscribe,Bs.get)}function vw({className:e,size:t=18}){return i.jsx("span",{className:e,"aria-hidden":"true",children:i.jsx(Tm,{size:t,variant:bc()?"night":"crt"})})}function Ke({as:e="section",className:t,style:r,frameless:o,children:l,...c}){return i.jsx(e,{className:We("panel",o&&"frameless",t),style:r,...c,children:l})}function zn({tone:e,className:t,children:r,title:o}){return i.jsx("span",{className:We("pill",e,t),title:o,children:r})}function Zt({label:e,value:t,layout:r="stack",urgent:o,title:l,className:c}){return i.jsxs("span",{className:We("readout",r!=="stack"&&r,o&&"urgent",c),title:l,children:[i.jsx("span",{className:"mono-label",children:e}),r==="inline"&&" ",i.jsx("b",{children:t})]})}function Ae(e){const{as:t="div",edge:r="neutral"}=e,o=e.onOpen?"button":"div";return i.jsxs(t,{className:We("ds-row",`edge-${r}`,e.selected&&"on",e.className),children:[i.jsxs(o,{className:"ds-row-main",...e.onOpen?{type:"button",onClick:e.onOpen}:{},title:e.titleText,"aria-current":e.current,children:[i.jsxs("span",{className:"ds-row-top",children:[i.jsx("span",{className:"ds-row-title t-row-title",children:e.title}),e.trailing&&i.jsx("span",{className:"ds-row-trail t-meta",children:e.trailing})]}),e.context&&i.jsx("span",{className:"ds-row-context",children:e.context}),e.detail&&i.jsx("span",{className:"ds-row-detail t-meta",title:e.detailText,children:e.detail})]}),e.actions&&i.jsx("span",{className:"ds-row-actions",children:e.actions}),e.below&&i.jsx("div",{className:"ds-row-below",children:e.below})]})}const Pn="#c8581e",kw={map:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M3 6l6-2.5 6 2.5 6-2.5v14.5L15 20.5 9 18l-6 2.5z"}),i.jsx("path",{d:"M9 3.5V18M15 6v14.5"}),i.jsx("path",{d:"M5.5 15c2-1 3-3 5-3.5s3-3 5-4",stroke:Pn,strokeDasharray:"2 2.2"})]}),note:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M5 3.5h14v13.5l-4 3.5H5z"}),i.jsx("path",{d:"M15 21v-4h4"}),i.jsx("path",{d:"M8.5 8h7M8.5 12h7",stroke:Pn})]}),book:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 6.5C10 4.5 7 4 3.5 4.5v14c3.5-.5 6.5 0 8.5 2 2-2 5-2.5 8.5-2v-14C17 4 14 4.5 12 6.5z"}),i.jsx("path",{d:"M12 6.5v14"}),i.jsx("path",{d:"M15 9.5l3-.5M15 13l3-.5",stroke:Pn})]}),flag:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M6 21.5V3"}),i.jsx("path",{d:"M6 4c4-1.5 7 1.5 12 0v9c-5 1.5-8-1.5-12 0z",fill:Pn,stroke:Pn})]}),tent:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 4L2.5 20h19z"}),i.jsx("path",{d:"M12 11l-4 9h8z",fill:Pn,stroke:Pn}),i.jsx("path",{d:"M12 4l-1.5-2M12 4l1.5-2"})]}),mailbox:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 21.500V14"}),i.jsx("path",{d:"M4 14V9.500A4.5 4.5 0 0 1 8.5 5h7A4.5 4.5 0 0 1 20 9.500V14z"}),i.jsx("path",{d:"M8.5 5A4.5 4.5 0 0 1 13 9.500V14"}),i.jsx("path",{d:"M16 10V6.500M16 6.500h3v2.500h-3",stroke:Pn})]})};function Dm({name:e}){return i.jsx("svg",{className:"zone-icon","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:kw[e]})}function Ct({title:e,count:t,right:r,hot:o,sub:l,children:c,className:d,info:f,icon:g}){return i.jsxs("header",{className:We("sec-h",l&&"sub",d),children:[c,g&&i.jsx(Dm,{name:g}),e!==void 0&&i.jsx(Je,{as:l?"h3":"h2",hot:o,children:e}),f&&i.jsx(Us,{text:f}),t,r!==void 0&&i.jsx("span",{className:"sec-h-right",children:r})]})}function ct(e){const{value:t,options:r,onChange:o}=e,[l,c]=x.useState(!1),[d,f]=x.useState(0),[g,m]=x.useState(),v=x.useRef(null),y=x.useRef(null),w=x.useId(),j=r.find(M=>M.value===t);x.useLayoutEffect(()=>{if(!l||!v.current)return;const M=v.current.getBoundingClientRect();m({left:M.left,top:M.bottom+4,minWidth:M.width})},[l]),x.useEffect(()=>{if(!l)return;const M=O=>{var X,ie;O.target instanceof Node&&((X=y.current)!=null&&X.contains(O.target)||(ie=v.current)!=null&&ie.contains(O.target))||c(!1)},R=()=>c(!1);return document.addEventListener("mousedown",M),window.addEventListener("resize",R),window.addEventListener("scroll",R,!0),()=>{document.removeEventListener("mousedown",M),window.removeEventListener("resize",R),window.removeEventListener("scroll",R,!0)}},[l]),x.useEffect(()=>{var M,R;l&&((R=(M=y.current)==null?void 0:M.querySelector(`[data-i="${d}"]`))==null||R.scrollIntoView({block:"nearest"}))},[l,d]);const $=()=>{f(Math.max(0,r.findIndex(M=>M.value===t))),c(!0)},N=M=>{var O;const R=r[M];c(!1),(O=v.current)==null||O.focus(),R&&R.value!==t&&o(R.value)},E=M=>{if(!l){["ArrowDown","ArrowUp","Enter"," "].includes(M.key)&&(M.preventDefault(),$());return}const R=O=>f(X=>(X+O+r.length)%r.length);if(M.key==="ArrowDown")R(1);else if(M.key==="ArrowUp")R(-1);else if(M.key==="Home")f(0);else if(M.key==="End")f(r.length-1);else if(M.key==="Enter"||M.key===" ")N(d);else{if(M.key==="Escape"||M.key==="Tab")return c(!1);if(M.key.length===1){const O=r.findIndex(X=>X.label.toLowerCase().startsWith(M.key.toLowerCase()));O>=0&&f(O);return}else return}M.preventDefault()};return i.jsxs(i.Fragment,{children:[i.jsxs("button",{ref:v,type:"button",className:We("select",e.compact&&"compact",l&&"open",e.className),role:"combobox","aria-haspopup":"listbox","aria-expanded":l,"aria-controls":w,"aria-label":e["aria-label"],"aria-activedescendant":l?`${w}-${d}`:void 0,disabled:e.disabled,onClick:()=>l?c(!1):$(),onKeyDown:E,children:[i.jsx("span",{className:"select-value",children:(j==null?void 0:j.label)??"—"}),i.jsx("span",{className:"select-caret","aria-hidden":"true"})]}),l&&g&&i.jsx("ul",{ref:y,id:w,className:"select-menu",role:"listbox",style:g,children:r.map((M,R)=>i.jsxs("li",{id:`${w}-${R}`,"data-i":R,role:"option","aria-selected":M.value===t,className:We(R===d&&"active"),onMouseEnter:()=>f(R),onMouseDown:O=>O.preventDefault(),onClick:()=>N(R),children:[i.jsx("span",{className:"select-label",children:M.label}),M.hint&&i.jsx("span",{className:"select-hint",children:M.hint})]},M.value))})]})}function yw(e){return i.jsx("div",{className:`tabs ${e.className??""}`,role:"tablist",children:e.items.map(t=>i.jsxs("button",{role:"tab","aria-selected":e.value===t.id,className:`tab ${e.value===t.id?"on":""}`,onClick:()=>e.onChange(t.id),children:[t.label,t.n!==void 0&&i.jsx("span",{className:"n",children:t.n})]},t.id))})}const xw=350;function ww(){const[e,t]=x.useState(null);if(x.useEffect(()=>{let o=0,l=null;const c=()=>{window.clearTimeout(o),l=null,t(null)},d=v=>{const y=v.getAttribute("data-tip");if(!y)return;const w=v.getBoundingClientRect(),j=w.bottom+60>window.innerHeight;t({text:y,x:w.left+w.width/2,y:j?w.top-8:w.bottom+8,above:j,scout:v.hasAttribute("data-tip-scout")})},f=v=>{var j,$;const y=($=(j=v.target)==null?void 0:j.closest)==null?void 0:$.call(j,"[data-tip], [title]");if(!y||y instanceof SVGElement&&!y.hasAttribute("data-tip"))return null;const w=y.getAttribute("title");return w&&(y.setAttribute("data-tip",w),y.removeAttribute("title")),y},g=v=>{if(v.pointerType==="touch")return;const y=f(v);y!==l&&(c(),y&&(l=y,o=window.setTimeout(()=>l===y&&d(y),v.type==="focusin"?0:xw)))},m=v=>{l&&!l.contains(v.relatedTarget)&&c()};return document.addEventListener("pointerover",g),document.addEventListener("pointerout",m),document.addEventListener("focusin",g),document.addEventListener("focusout",c),document.addEventListener("pointerdown",c),window.addEventListener("scroll",c,!0),window.addEventListener("keydown",c),()=>{c(),document.removeEventListener("pointerover",g),document.removeEventListener("pointerout",m),document.removeEventListener("focusin",g),document.removeEventListener("focusout",c),document.removeEventListener("pointerdown",c),window.removeEventListener("scroll",c,!0),window.removeEventListener("keydown",c)}},[]),!e)return null;const r=Math.min(Math.max(e.x,140),window.innerWidth-140);if(e.scout){const o=Math.min(Math.max(e.x-24,8),window.innerWidth-340);return i.jsxs("div",{className:`scout-tip ${e.above?"above":""}`,role:"tooltip",style:{left:o,top:e.y,transform:e.above?"translateY(-100%)":void 0},children:[i.jsx(_o,{size:1,framed:!1,speaking:e.text,className:"scout-tip-face"}),i.jsx("p",{className:"scout-tip-bubble",children:e.text})]})}return i.jsx("div",{className:`tooltip ${e.above?"above":""}`,role:"tooltip",style:{left:r,top:e.y,transform:`translate(-50%, ${e.above?"-100%":"0"})`},children:e.text})}function Bm({as:e="span",className:t}){return i.jsx(e,{className:t,children:ve.name})}function zm(e){return e.bare?i.jsx("div",{className:`zone-b ${e.className??""}`,children:e.children}):i.jsxs(Ke,{className:`zone ${e.className??""}`,style:e.area?{gridArea:e.area}:void 0,children:[i.jsx(Ct,{className:"zone-title",icon:e.icon,title:e.title,info:e.info,count:e.count,right:e.right??null}),i.jsx("div",{className:"zone-b",children:e.children})]})}function Es(e){return e.children.length?i.jsxs("div",{className:`bf-list ${e.urgent?"urgent":""}`,children:[i.jsx("span",{className:"mono-label",children:e.title}),i.jsx("ul",{children:e.children})]}):null}function ao(e){return i.jsx("li",{children:i.jsxs("button",{className:"bf-row",onClick:e.onClick,title:e.title,children:[i.jsx("span",{className:"key t-code",children:e.k}),i.jsx("span",{className:"t",children:e.text}),e.meta&&i.jsx("span",{className:"t-meta",children:e.meta})]})})}function Ri(e){return i.jsxs(Ot,{tone:e.urgent?"urgent":void 0,className:`bf-tile ${e.className??""}`,children:[i.jsx("span",{className:"mono-label",children:e.label}),i.jsx("b",{children:e.value}),e.sub&&i.jsx(Q,{parts:[],children:e.sub})]})}const jw=864e5;function Nw(e,t){const r=new Date(e),o=r.toTimeString().slice(0,5),l=new Date(t).toDateString(),c=new Date(t-jw).toDateString();let d=` ${r.toLocaleDateString(void 0,{month:"short",day:"numeric"})}`;return r.toDateString()===l?d="":r.toDateString()===c&&(d=" yesterday"),`Since ${o}${d} · ${Wt(t-e)}`}function Sw(e){const{briefing:t,bp:r,onClose:o}=e;x.useEffect(()=>{const y=w=>w.key==="Escape"&&o();return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[o]);const l=t==null?void 0:t.trails.flatMap(y=>y.waiting).sort((y,w)=>y.at-w.at)[0],c=t==null?void 0:t.totals,d=((t==null?void 0:t.trails.length)??0)>1,f=r==="mobile",g=y=>{var w,j;return y.ticketId&&((j=(w=e.snaps[y.mapId])==null?void 0:w.tickets.find($=>$.id===y.ticketId))==null?void 0:j.title)||y.text},m=y=>{var w,j;return y.ticketId&&((j=(w=e.snaps[y.mapId])==null?void 0:w.tickets.find($=>$.id===y.ticketId))==null?void 0:j.key)||y.agent},v=y=>{const w=(M,R)=>i.jsx(ao,{k:M.key,text:M.title,meta:R,onClick:()=>e.onTicket(y.mapId,M.id)},M.id),j=(M,R)=>i.jsx(ao,{k:M.id,text:M.summary||M.answer,title:M.risk?`${M.question}
|
|
117
|
+
`)}`:"";return vc(t,e.body+r)}class nx{constructor(t,r=`./${ve.dataDir}`){ue(this,"kind","markdown");ue(this,"label","Local markdown");ue(this,"events",new Os);ue(this,"selfWrites",new Map);ue(this,"external",new qy(t=>this.fs.read(t),t=>this.events.emit(t)));var o;this.fs=t,this.location=r,(o=t.watch)==null||o.call(t,l=>{const c=this.selfWrites.get(l);c&&Date.now()-c<1500||this.external.queue(l)})}async put(t,r){this.selfWrites.set(t,Date.now()),await this.fs.write(t,r)}async readMap(t){return Zy(t,await this.fs.read(`${t}/map.md`))}async writeMap(t){await this.put(`${t.id}/map.md`,ex(t))}async readTicket(t,r){return eh(await this.fs.read(`${t}/tickets/${r}.md`))}async writeTicket(t,r){await this.put(`${t}/tickets/${r.id}.md`,tx({...r,updatedAt:Date.now()}))}async listMaps(){const r=(await this.fs.list()).filter(o=>/^[^/]+\/map\.md$/.test(o)).map(o=>o.split("/")[0]);return Promise.all(r.map(async o=>{const l=await this.readMap(o);return{id:o,key:l.key,title:l.title}}))}async loadMap(t){const r=await this.fs.list(),o=await this.readMap(t),l=r.filter(d=>d.startsWith(`${t}/tickets/`)),c=await Promise.all(l.map(async d=>eh(await this.fs.read(d))));return{map:o,tickets:c.sort((d,f)=>d.createdAt-f.createdAt)}}async createMap(t){const r=await Zf(this.fs),o=Qy(t.title,r),l={id:o,key:`#${r}`,title:t.title,mode:t.mode??ns,...t.verification?{verification:t.verification}:{},sections:t.sections,createdAt:Date.now(),updatedAt:Date.now()};return await this.writeMap(l),this.events.emit({kind:"map.created",mapId:o,at:Date.now()}),l}async editMap(t,r,o){await this.writeMap({...r(await this.readMap(t)),updatedAt:Date.now()}),this.events.emit(o)}setMapMode(t,r){return this.editMap(t,o=>({...o,mode:r}),{kind:"map.mode",mapId:t,mode:r,at:Date.now()})}setMapMeta(t,r){return this.editMap(t,o=>zy(o,r),{kind:"map.updated",mapId:t,at:Date.now()})}updateMapSections(t,r){const o=Object.keys(r)[0];return this.editMap(t,l=>({...l,sections:{...l.sections,...r}}),{kind:"map.updated",mapId:t,section:o,at:Date.now()})}async createTicket(t,r){const o=await Zf(this.fs),l=Fy(String(o),`#${o}`,r);return await this.writeTicket(t,l),this.events.emit({kind:"ticket.created",mapId:t,ticketId:l.id,at:Date.now()}),l}async addBlocking(t,r,o){const l=await this.readTicket(t,o);l.blockedBy.includes(r)||await this.writeTicket(t,{...l,blockedBy:[...l.blockedBy,r]}),this.events.emit({kind:"edge.added",mapId:t,blockerId:r,blockedId:o,at:Date.now()})}async update(t,r,o){await this.writeTicket(t,o(await this.readTicket(t,r)))}async removeBlocking(t,r,o){await this.update(t,o,l=>Uy(l,r)),this.events.emit({kind:"edge.removed",mapId:t,blockerId:r,blockedId:o,at:Date.now()})}async editTicket(t,r,o){await this.update(t,r,l=>Hy(l,o)),this.events.emit({kind:"ticket.updated",mapId:t,ticketId:r,at:Date.now()})}async reopen(t,r){await this.update(t,r,Wy),this.events.emit({kind:"ticket.updated",mapId:t,ticketId:r,at:Date.now()})}async assign(t,r,o){await this.update(t,r,l=>({...l,assignee:o??void 0})),this.events.emit(o?{kind:"ticket.claimed",mapId:t,ticketId:r,assignee:o,at:Date.now()}:{kind:"ticket.released",mapId:t,ticketId:r,at:Date.now()})}async comment(t,r,o,l){await this.update(t,r,c=>({...c,comments:[...c.comments,{id:`c${c.comments.length}`,author:o,body:l,createdAt:Date.now()}]})),this.events.emit({kind:"ticket.commented",mapId:t,ticketId:r,at:Date.now()})}async close(t,r,o){await this.update(t,r,l=>({...l,state:"closed",closeReason:o,closedAt:Date.now()})),this.events.emit({kind:"ticket.closed",mapId:t,ticketId:r,reason:o,at:Date.now()})}async setMeta(t,r,o){await this.update(t,r,l=>Vy(l,o)),this.events.emit({kind:"ticket.updated",mapId:t,ticketId:r,at:Date.now()})}async listDecisions(t){const r=(await this.fs.list()).filter(o=>o.startsWith(`${t}/decisions/`));return Promise.all(r.map(async o=>{const l=await this.fs.read(o),c={...Jl(l),mapId:t};return this.external.knows(o)||this.external.remember(o,l,c.supersededBy),c}))}async createDecision(t,r){const o=(await this.fs.list()).filter(f=>f.includes("/decisions/")),l=Math.max(0,...o.map(f=>wk(f.split("/").pop())))+1,c=xk(`D-${l}`,t,r),d=Kf(c);return this.external.remember(`${t}/decisions/${c.id}.md`,d),await this.put(`${t}/decisions/${c.id}.md`,d),this.events.emit({kind:"decision.recorded",mapId:t,decisionId:c.id,ticketId:c.ticketId,at:Date.now()}),c}async markSuperseded(t,r,o){const l=`${t}/decisions/${r}.md`,c=Jl(await this.fs.read(l)),d=Kf({...c,mapId:t,supersededBy:o});this.external.remember(l,d,o),await this.put(l,d),this.events.emit({kind:"decision.superseded",mapId:t,decisionId:r,supersededBy:o,at:Date.now()})}subscribe(t){return this.events.on(t)}}class th extends Error{constructor(t,r,o,l){super(r),this.code=t,this.status=o,this.resetAt=l,this.name="TrackerError"}}const sx={github:"GitHub Issues",linear:"Linear"};async function xt(e,t,r){let o;try{o=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:r===void 0?void 0:JSON.stringify(r)})}catch{throw new th("offline","Lookout server unreachable; is `teamtrail` still running?")}const l=await o.json().catch(()=>({}));if(!o.ok)throw new th(l.code??"http",l.error??`request failed (${o.status})`,o.status,l.resetAt);return l}class ix{constructor(t,r,o=""){ue(this,"label");ue(this,"location");ue(this,"status",{state:"connecting",queued:0});ue(this,"events",new Os);ue(this,"statusEvents",new Os);ue(this,"source");ue(this,"listeners",0);ue(this,"listMaps",()=>this.call("listMaps"));ue(this,"loadMap",t=>this.call("loadMap",t));ue(this,"createMap",t=>this.call("createMap",t));ue(this,"setMapMode",(t,r)=>this.call("setMapMode",t,r));ue(this,"setMapMeta",(t,r)=>this.call("setMapMeta",t,r));ue(this,"updateMapSections",(t,r)=>this.call("updateMapSections",t,r));ue(this,"createTicket",(t,r)=>this.call("createTicket",t,r));ue(this,"addBlocking",(t,r,o)=>this.call("addBlocking",t,r,o));ue(this,"removeBlocking",(t,r,o)=>this.call("removeBlocking",t,r,o));ue(this,"editTicket",(t,r,o)=>this.call("editTicket",t,r,o));ue(this,"reopen",(t,r)=>this.call("reopen",t,r));ue(this,"assign",(t,r,o)=>this.call("assign",t,r,o));ue(this,"comment",(t,r,o,l)=>this.call("comment",t,r,o,l));ue(this,"close",(t,r,o)=>this.call("close",t,r,o));ue(this,"setMeta",(t,r,o)=>this.call("setMeta",t,r,o));ue(this,"listDecisions",t=>this.call("listDecisions",t));ue(this,"createDecision",(t,r)=>this.call("createDecision",t,r));ue(this,"markSuperseded",(t,r,o)=>this.call("markSuperseded",t,r,o));this.kind=t,this.base=r,this.label=sx[t],this.location=o}async call(t,...r){return(await xt(`${this.base}/tracker/${this.kind}/call`,"POST",{method:t,args:r})).result}open(){const t=new EventSource(`${this.base}/tracker/${this.kind}/events`);t.onmessage=r=>this.events.emit(JSON.parse(r.data)),t.addEventListener("status",r=>{const o=JSON.parse(r.data);o.location&&(this.location=o.location),this.status=o,this.statusEvents.emit(o)}),t.onerror=()=>{this.status.state!=="offline"&&(this.status={...this.status,state:"offline",error:"Lookout server unreachable"},this.statusEvents.emit(this.status))},this.source=t}subscribe(t){const r=this.events.on(t);return++this.listeners===1&&this.open(),()=>{var o;r(),--this.listeners===0&&((o=this.source)==null||o.close(),this.source=void 0)}}onStatus(t){return this.statusEvents.on(t)}}function rx(e){return{get:()=>xt(`${e}/trackers`,"GET"),test:t=>xt(`${e}/trackers/test`,"POST",t),connect:t=>xt(`${e}/trackers`,"PUT",t),forget:t=>xt(`${e}/trackers/credentials/${t}`,"DELETE"),githubRepos:()=>xt(`${e}/trackers/github/repos`,"GET"),githubSignIn:{start:()=>xt(`${e}/trackers/github/sign-in/start`,"POST"),poll:()=>xt(`${e}/trackers/github/sign-in/poll`,"POST"),cancel:()=>xt(`${e}/trackers/github/sign-in/cancel`,"POST"),signOut:()=>xt(`${e}/trackers/github/sign-in`,"DELETE")},linearTeams:t=>t?xt(`${e}/trackers/linear/teams`,"POST",{apiKey:t}):xt(`${e}/trackers/linear/teams`,"GET"),linearProjects:(t,r)=>r?xt(`${e}/trackers/linear/projects`,"POST",{apiKey:r,teamId:t}):xt(`${e}/trackers/linear/projects?team=${encodeURIComponent(t)}`,"GET")}}const ox=[{id:"markdown",name:"Local markdown",status:"available"},{id:"github",name:"GitHub Issues",status:"available"},{id:"linear",name:"Linear",status:"available"}],bm=[{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"}],ax=bm[0],lx="https://github.com/teamtrailhq/teamtrail-guides",cx=`${lx}/blob/main/CONTRIBUTING.md`;function ux(e,t={}){const r=(t.query??"").toLowerCase().split(/\s+/).filter(Boolean);return e.guides.filter(o=>{if(t.verifiedOnly&&!o.verified&&!o.builtin)return!1;const l=[o.id,o.name??"",o.summary,o.author].join(" ").toLowerCase();return r.every(c=>l.includes(c))})}const dx={ink:"#16302a",shellLight:"#f6f1e2",shell:"#eae3cf",shellShade:"#c8bea2",frame:"#b4aa8f",glass:"#14241f",scan:"#18302a",glow:"#6fbf8f",glowLight:"#b4e8c0",cup:"#b9562a",cupLight:"#d67a45",cupDark:"#8a3d1d",band:"#8f9690",hat:"#8a5a38",visor:"#6b4630",panel:"#e6dcc0",button:"#c8581e"},Cm={on:"#e2711d",dim:"#a8501c",alert:"#ff5a48"},fx={on:"#ffd166",dim:"#a8501c",alert:"#ff5a48"},De=([e,t,r,o],l,c=.35)=>`<rect x="${e}" y="${t}" width="${r}" height="${o}" rx="${c}" fill="${l}"/>`;function nh(e,t,r){if(t==="closed")return De([e,17,3,1],r.glow);if(t==="wide")return De([e,15,3,3],r.glowLight)+De([e+1,16,1,1],r.glass,.2);const o=t==="aside"?e+1:e;return De([o,16,3,1.1],r.glow)+De([o,17,3,1],r.glowLight)}function hx(e,t){return e==="open"?De([13,20,6,1.1],t.glowLight)+De([15,21,2,1],t.glow):e==="mid"?De([14,20,4,1],t.glowLight):De(e==="aside"?[17,20,2,1]:[15,20,2,1],t.glow)}const mx=[13,15,17,19,21,23];function px(e){return[mx.map(t=>De([9.2,t,13.6,1],e.scan,0)).join(""),De([10,13,2,1],e.frame,.2),De([10,14,1,1],e.frame,.2),De([10,25.2,1,1],e.button,.2),De([11.2,25.2,1,1],e.cupDark,.2),[17,19,21].map(t=>De([t,25.2,1,1.6],e.shellLight,.2)+De([t,25.2,1,.8],e.frame,.2)).join("")].join("")}function sh(e,t,r){return[`<rect x="${e}" y="15" width="5.4" height="11" rx="1.7" fill="${t.cup}" ${r}/>`,De([e+1,16,1.2,9],t.cupLight,.5),De([e+3.6,16,.9,9],t.cupDark,.4)].join("")}function gx(e,{lamp:t=Cm,simple:r=!1,colors:o=dx}={}){const l=o,c=r?"open":e.eyes,d=r?"rest":e.mouth,f=`stroke="${l.ink}" stroke-width=".9" stroke-linejoin="round"`;return['<g transform="scale(6.25)">',`<path d="M3 16.5Q3 6 16 5.5Q29 6 29 16.5" fill="none" stroke="${l.ink}" stroke-width="3"/>`,`<path d="M3 16.5Q3 6 16 5.5Q29 6 29 16.5" fill="none" stroke="${l.band}" stroke-width="1.5"/>`,sh(.6,l,f),sh(26,l,f),`<path d="M8 9H24Q26 9 26 11V25L23.5 28.5H8.5L6 25V11Q6 9 8 9Z" fill="${l.shell}" ${f}/>`,`<path d="M6.5 25H25.5L23.3 28H8.7Z" fill="${l.shellShade}"/>`,De([6.6,10,1.6,15],l.shellLight,.6),De([8.4,11,15.2,13.6],l.frame,1.3),De([9,11.6,14,12.4],l.glass,1),r?"":px(l),nh(11,c,l),nh(18,c,l),hx(d,l),`<path d="M6.5 10.5Q5.8 3.5 16 3.100Q26.2 3.5 25.5 10.5Z" fill="${l.hat}" ${f}/>`,`<path d="M10.5 9.5Q10.3 4.9 16 4.5Q21.7 4.9 21.5 9.5Z" fill="${l.panel}" stroke="${l.ink}" stroke-width=".5"/>`,r?"":`<path d="M16 5.400l1.2 1.7h-.6l1 1.5h-3.2l1-1.5h-.6z" fill="${l.hat}"/>`,`<path d="M6.3 9.8Q16 7.9 25.7 9.8Q27.2 12 25 12.600Q16 10.9 7 12.600Q4.8 12 6.3 9.8Z" fill="${l.visor}" ${f}/>`,`<circle cx="16" cy="2.600" r="1.3" fill="${t[e.light??"on"]}" stroke="${l.ink}" stroke-width=".7"/>`,"</g>"].join("")}const $m={crt:{id:"crt",name:"Day",blurb:"The original CRT head with ear cups and a baseball cap.",lamp:Cm,wave:{bar:"#6f8a78",lead:"#c8581e"}},night:{id:"night",name:"Night",blurb:"The same Scout, with the cap lamp burning bright, for the night theme.",lamp:fx,wave:{bar:"#66828d",lead:"#e8833a"}}},vx="crt",kx={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"}},yx={idle:"WATCHING",speaking:"TALKING",alert:"NEEDS YOU",thinking:"THINKING"},hn={msPerChar:55,mouthHoldMs:110,blinkEveryMs:5600,blinkMs:140,thinkingStepMs:520};function xx(e){return e?/[aeiouy]/i.test(e)?"open":/[a-z0-9]/i.test(e)?"mid":"rest":"rest"}function wx(e,t){return!e||!/[a-z0-9]/i.test(e)?0:/[aeiou]/i.test(e)?2+(e.charCodeAt(0)+t)%2:1+(e.charCodeAt(0)*7+t)%2}function jx(e,t,r){return Array.from({length:r},(o,l)=>{const c=t-(r-1-l);return c>=0&&c<e.length?wx(e[c],c):0})}function Tm({face:e={eyes:"open",mouth:"rest"},variant:t="crt",size:r,simple:o,className:l}){const{eyes:c,mouth:d,light:f}=e,g=x.useMemo(()=>gx({eyes:c,mouth:d,light:f},{lamp:$m[t].lamp,simple:o??r<28}),[c,d,f,t,o,r]);return i.jsx("svg",{className:l,width:r,height:r,viewBox:"0 0 200 200","aria-hidden":"true",dangerouslySetInnerHTML:{__html:g}})}function Nx(e){const[t,r]=x.useState(!1);return x.useEffect(()=>{if(!e){r(!1);return}let o;const l=setInterval(()=>{r(!0),o=setTimeout(()=>r(!1),hn.blinkMs)},hn.blinkEveryMs);return()=>{clearInterval(l),o&&clearTimeout(o)}},[e]),t}const Sx={xs:.8,sm:2,md:4,lg:6},bx=40,ih=20,rh="(prefers-reduced-motion: reduce)",Cx=40,$x=350;function Tx(e,t){var f;const r=e.size??"md",o=e.state??"idle",l=((f=e.speaking)==null?void 0:f.trim())??"",c=l&&(o==="idle"||o==="speaking")?"speaking":o,d=r==="xs";return{size:r,text:l,effective:c,talking:c==="speaking"&&l.length>0,mini:d,framed:e.framed??!d,reduced:t||d}}const Ex=e=>e.length*hn.msPerChar,Ix=(e,t)=>t&&(e.effective==="idle"||e.effective==="speaking"||e.effective==="alert");function Mx(e,t,r,o){const l=kx[e.effective],c=r?"closed":l.eyes;let d=l.mouth,f=e.text.length-1;if(o)if(e.reduced)d="open";else{f=Math.min(e.text.length-1,Math.floor(t/hn.msPerChar));const m=Math.floor(t/hn.mouthHoldMs)*Math.round(hn.mouthHoldMs/hn.msPerChar);d=xx(e.text[Math.min(e.text.length-1,m)])}let g=l.light;return e.effective==="thinking"&&!e.reduced&&Math.floor(t/hn.thinkingStepMs)%2===1&&(g="on"),{eyes:c,mouth:d,light:g,cursor:f}}function Ax(e,t){const r=typeof e.size=="number"?e.size:Sx[e.size],o=e.reduced?Math.min(e.text.length-1,ih-1):t;return{base:r,px:bx*r,bars:ih,waveCursor:o}}function Lx(e,{label:t,speechDone:r,cursor:o,caption:l}){const c=e.talking&&r?"idle":e.effective,d=yx[c],f=e.size==="md"||e.size==="lg"||typeof e.size=="number"&&e.size>=4;return{shownState:c,status:d,ariaLabel:`${t}, ${d.toLowerCase()}`,showCaption:l??f,shown:Rx(e,r,o)}}function Rx(e,t,r){return e.talking?e.reduced||t?e.text:e.text.slice(0,r+1):""}function Ox(){const[e,t]=x.useState(()=>{var r;return typeof window<"u"&&!!((r=window.matchMedia)!=null&&r.call(window,rh).matches)});return x.useEffect(()=>{var l;const r=(l=window.matchMedia)==null?void 0:l.call(window,rh);if(!r)return;const o=()=>t(r.matches);return o(),r.addEventListener("change",o),()=>r.removeEventListener("change",o)},[]),e}function Px(e,t,r){const[o,l]=x.useState(0);return x.useEffect(()=>{if(l(0),!t)return;const c=performance.now(),d=setInterval(()=>l(performance.now()-c),r);return()=>clearInterval(d)},[e,t,r]),o}function _x(e){const{key:t,talking:r,at:o}=e,l=o!==void 0,c=Ex(e.text),[d,f]=x.useState(""),g=x.useRef(e.onSpeakEnd);g.current=e.onSpeakEnd,x.useEffect(()=>{if(!r||l)return;const j=setTimeout(()=>{var $;f(t),($=g.current)==null||$.call(g)},c+$x);return()=>clearTimeout(j)},[r,t,c,l]);const m=r&&d!==t,v=Px(t,e.animate&&(m||e.thinking),m?Cx:hn.thinkingStepMs),y=o??v,w=r&&(l?y>=c:d===t);return{t:y,speechDone:w}}const Dx=e=>e*2,tc=3.5;function Bx(e,t,r){return(e??[]).map((o,l)=>{const c=(1+2*o)*.5;return{x:l*2,y:(tc-c)/2,width:1,height:c,fill:l>=t-2&&o>0?r.lead:r.bar}})}function zx({heights:e,bars:t,unit:r,colors:o}){const l=Dx(t);return i.jsx("svg",{className:`scout-wave${e?" on":""}`,width:l*r,height:tc*r,viewBox:`0 0 ${l} ${tc}`,"aria-hidden":"true",children:Bx(e,t,o).map((c,d)=>i.jsx("rect",{...c},d))})}function _o({state:e="idle",size:t="md",speaking:r,variant:o=vx,framed:l,caption:c,label:d="Scout",onSpeakEnd:f,at:g,className:m,style:v}){const y=Tx({state:e,size:t,speaking:r,framed:l},Ox()),{text:w,effective:j,talking:$,reduced:N}=y,E=$m[o],R=!N&&!(g!==void 0),O=`${j}|${o}|${w}`,{t:X,speechDone:se}=_x({key:O,text:w,talking:$,thinking:j==="thinking",animate:R,at:g,onSpeakEnd:f}),Q=Nx(Ix(y,R)),F=$&&!se,{eyes:ie,mouth:V,light:ge,cursor:Re}=Mx(y,X,Q,F),{base:be,px:te,bars:P,waveCursor:Y}=Ax(y,Re),ae=x.useMemo(()=>F?jx(w,Y,P):null,[F,w,Y,P]),{shownState:Z,status:U,ariaLabel:D,showCaption:H,shown:T}=Lx(y,{label:d,speechDone:se,cursor:Re,caption:c}),_={...v,"--scout-u":`${be}px`},he=i.jsx("span",{className:"scout-sprite",children:i.jsx(Tm,{face:{eyes:ie,mouth:V,light:ge},variant:o,size:te,simple:y.mini})});return y.framed?i.jsxs("figure",{className:`scout scout-panel scout-${Z} scout-v-${o} ${m??""}`,style:_,"data-state":Z,children:[i.jsxs("figcaption",{className:"scout-head",children:[i.jsx("span",{className:"scout-name",children:d}),i.jsx("span",{className:"scout-sep",children:"//"}),i.jsx("span",{className:"scout-status",children:U})]}),i.jsxs("div",{className:"scout-feed",role:"img","aria-label":D,children:[he,i.jsx(zx,{heights:ae,bars:P,unit:be,colors:E.wave})]}),H&&i.jsxs("p",{className:"scout-caption","aria-hidden":"true",children:[T,$&&!se&&!N&&i.jsx("span",{className:"scout-caret",children:"_"})]}),w&&i.jsx("span",{className:"scout-sr","aria-live":"polite",children:w})]}):i.jsx("span",{className:`scout scout-bare scout-${Z} ${m??""}`,style:_,role:"img","aria-label":D,children:he})}function Fx(){return['<rect x="1" y="1" width="198" height="198" rx="44" fill="#17211c" stroke="var(--tt-logo-edge, #17211c)" stroke-width="2"/>','<g transform="translate(32 32) scale(.68)">','<path d="M58 8L104 0V132Q104 150 124 150H150V196H112Q58 196 58 142Z" fill="#8fbf84"/>','<path d="M14 58H150V102H14Z" fill="#8fbf84"/>','<circle cx="182" cy="173" r="23" fill="#e8833a"/>',"</g>"].join("")}function Ux(){return['<g transform="translate(-3 2) scale(.98)">','<path d="M58 8L104 0V132Q104 150 124 150H150V196H112Q58 196 58 142Z" fill="#5f9658"/>','<path d="M14 58H150V102H14Z" fill="#5f9658"/>','<circle cx="182" cy="173" r="23" fill="#e8833a"/>',"</g>"].join("")}function Hx({size:e=40,bare:t,className:r}){const o=x.useMemo(()=>t?Ux():Fx(),[t]);return i.jsx("svg",{className:r,width:e,height:e,viewBox:"0 0 200 200",role:"img","aria-label":"Teamtrail",dangerouslySetInnerHTML:{__html:o}})}const wt="trail lead";function Wx({rt:e,guard:t,setMapId:r,mapIdRef:o,snapRef:l,setChatSession:c,setSelection:d}){const f={actorKind:"trail lead",journal:e.journal};return{selectMap:g=>r(g),openChat:g=>c(g),answer:(g,m)=>e.activity.answer(g,m,wt),claim:g=>t("Claim",()=>Uf(e.adapter,o.current,g,{...f,assignee:wt})),release:g=>t("Release claim",()=>pk(e.adapter,o.current,g,{...f,actor:wt})),releaseLease:g=>t("Release to queue",()=>e.leases.release(o.current,g,wt)),resolve:(g,m,v={})=>t("Resolve · record answer",async()=>{var w;const y=(w=l.current)==null?void 0:w.tickets.find(j=>j.id===g);y&&!y.assignee&&await Uf(e.adapter,o.current,g,{...f,assignee:wt}),await Nk(e.adapter,o.current,g,{...f,answer:m,author:wt,decision:{...v,source:{kind:"lookout",label:"Ticket inspector"}}})}),supersede:(g,m)=>t(`Supersede ${g.id}`,async()=>{let v=g.id;if(g.derived){const{id:y,mapId:w,derived:j,supersededBy:$,...N}=g;v=(await gc(e.adapter,g.mapId,N,{appendToTrail:!1})).id}await gk(e.adapter,g.mapId,v,{...m,decidedBy:wt,participants:[{id:wt}],source:{kind:"lookout",label:"Logbook"}})}),graduate:({unspecified:g,...m})=>t(`Promote to ticket · ${g}`,async()=>{const v=await Sk(e.adapter,o.current,g,m);d({kind:"ticket",id:v.id})}),ruleOut:(g,m)=>t("Rule out of scope",async()=>{await bk(e.adapter,o.current,g,{...f,reason:m,author:wt,source:{kind:"lookout",label:"Ticket inspector"}}),d(null)}),setMode:g=>t(`Trail mode · ${g}`,()=>vk(e.adapter,o.current,g)),setModelMatching:g=>t(`Model matching · ${g.enabled?"on":"off"}`,()=>Ck(e.adapter,o.current,g))}}const We=(...e)=>e.filter(Boolean).join(" "),Ps="item",Kx=/^[0-9a-f]{6,64}$/;function Do(){const e=new URLSearchParams(location.search).get("project")??void 0;return e&&Kx.test(e)?e:void 0}function Se(e=Do()){return e?`${ve.apiPrefix}/p/${e}`:ve.apiPrefix}function Vx(e){const t=new URLSearchParams(location.search);for(const o of["projects","project","tracker",Ps])t.delete(o);e.item&&t.set(Ps,e.item),e.id&&e.id!==e.home&&t.set("project",e.id),e.id&&e.id!==e.home&&e.tracker&&t.set("tracker",e.tracker);const r=t.toString();return`${location.pathname}${r?`?${r}`:""}`}async function Gx(e,t){var c;const r=(t.assumptions??[]).map((d,f)=>({id:`S-${f+1}`,text:d,status:"holding",tickets:[]})),{map:o,tickets:l}=await ik(e,{title:t.title,sections:{destination:t.destination,notes:t.notes,decisions:[],unspecified:[],outOfScope:[],...r.length?{assumptions:r}:{}},tickets:[{ref:"discovery",...xy}]});return await fetch(`${Se()}/briefs/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:o.id,ticketId:(c=l[0])==null?void 0:c.id})}),o}function Em(e,t){const r=URL.createObjectURL(new Blob([t],{type:"text/markdown;charset=utf-8"}));Object.assign(document.createElement("a"),{href:r,download:e}).click(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}function nn(e){const t=Math.max(0,Math.floor(e/1e3));return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:`${Math.floor(t/3600)}h`}function Im(e){const t=Math.max(0,Math.floor(e/1e3)),r=o=>String(o).padStart(2,"0");return`${r(Math.floor(t/3600))}:${r(Math.floor(t%3600/60))}:${r(t%60)}`}const Bo=e=>new Date(e).toTimeString().slice(0,8);function Wt(e){if(e<1e3)return`${Math.round(e)}ms`;const t=Math.round(e/1e3);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m ${String(t%60).padStart(2,"0")}s`:`${Math.floor(t/3600)}h ${String(Math.floor(t%3600/60)).padStart(2,"0")}m`}function zo(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}const _s=e=>`$${e<10?e.toFixed(2):e.toFixed(1)}`,Ds=e=>new Date(e).toISOString().slice(0,10),yc=e=>new Date(e).toTimeString().slice(0,5),Qx=e=>`${Ds(e)} ${yc(e)}`,Mm=e=>{if(!e)return"";const t=Math.max(0,Math.round((Date.now()-e)/1e3));return t<60?`${t}s ago`:`${Math.round(t/60)}m ago`},Vi=e=>e?new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",zi={research:"Research",prototype:"Prototype",junction:"Junction",task:"Task",execute:"Execute",review:"Review"},Am={decided:"Done",claimed:"Working",frontier:"Ready",blocked:"Backlog",parked:"Parked (plan-only)","out-of-scope":"Cancelled",verifying:"Verifying",rework:"Rework",held:"Blocked"},qx={decided:"done",claimed:"working",frontier:"ready",blocked:"backlog",parked:"parked","out-of-scope":"cancelled",verifying:"verifying",rework:"rework",held:"blocked"};function xc(e,t){return new Map((e??[]).filter(r=>r.mapId===t&&!r.returned).map(r=>[r.ticketId,r]))}const wc=(e,t)=>`${e}/${t}`;let mn={reached:!1,live:!1,tickets:{}},nc=!1;const sc=new Set,ic=new Set;function yo(e){mn=e;for(const t of sc)t()}function oh(){fetch(`${Se()}/verification/sync`).then(e=>e.ok?e.json():Promise.reject()).then(e=>yo({reached:!0,live:!0,status:e.status,tickets:Object.fromEntries(e.tickets.map(t=>[wc(t.mapId,t.ticketId),t]))}),()=>mn.reached&&yo({...mn,live:!1}))}function ah(){nc=!0,oh();const e=new EventSource(`${Se()}/events`);e.addEventListener("verification",t=>{const r=JSON.parse(t.data);if(r.kind==="evidence")for(const l of ic)l();if(r.kind!=="sync")return;const o={...mn.tickets};for(const l of r.tickets)o[wc(l.mapId,l.ticketId)]=l;yo({reached:!0,live:!0,status:r.status,tickets:o})}),e.addEventListener("error",()=>mn.reached&&mn.live&&yo({...mn,live:!1})),e.addEventListener("open",()=>mn.reached&&oh())}const Bs={subscribe(e){return nc||ah(),sc.add(e),()=>void sc.delete(e)},get:()=>mn,onEvidence(e){return nc||ah(),ic.add(e),()=>void ic.delete(e)},ticket:(e,t,r)=>e.tickets[wc(t,r)]};function Yx(e){if(e!=null&&e.flags.length)return e.flags.some(t=>t.severity==="alert")?"alert":"warn"}const lh={onboarded:!1,tracker:"markdown",hitlTranscript:"summary",agent:ax.id,github:{repo:""},linear:{team:""},briefing:{enabled:!0,awayMinutes:15},theme:"night"};function jc(){try{const e={...lh,...JSON.parse(localStorage.getItem(Eo)??"{}")};return["markdown","github","linear"].includes(e.tracker)||(e.tracker="markdown"),e}catch{return lh}}function Lm(e){e==="auto"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e}const Jx=15*6e4;class Xx{constructor(t){ue(this,"leases",[]);ue(this,"changes",new Os);ue(this,"logged",new Set);ue(this,"since",Date.now()-Jx);this.activity=t}subscribe(t){return this.changes.on(t)}set(t){var r;this.leases=t;for(const o of t){const l=`${o.mapId}/${o.ticketId}/${(r=o.returned)==null?void 0:r.at}`;!o.returned||o.returned.at<this.since||this.logged.has(l)||(this.logged.add(l),this.activity.push({source:"system",level:"warn",ticketId:o.ticketId,text:Ry(o)}))}this.changes.emit(t)}async release(t,r,o){const l=await fetch(`${Se()}/agents/leases/release`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,ticketId:r,by:o})});if(!l.ok)throw new Error((await l.json().catch(()=>({}))).error??`HTTP ${l.status}`)}}let Xt;const xo=new Set,Fi=new Map;function Rm(e){Xt==null||Xt.addEventListener(e,t=>{for(const r of Fi.get(e)??[])r(t.data)})}function Om(){if(!Xt){Xt=new EventSource(`${Se()}/events`),Xt.onmessage=e=>{const t=JSON.parse(e.data).path;if(typeof t=="string")for(const r of xo)r(t)};for(const e of Fi.keys())Rm(e)}}function Pm(){const e=[...Fi.values()].some(t=>t.size>0);xo.size||e||(Xt==null||Xt.close(),Xt=void 0)}function pn(e){return xo.add(e),Om(),()=>{xo.delete(e),Pm()}}function Fo(e,t){let r=Fi.get(e);return r||(r=new Set,Fi.set(e,r),Rm(e)),r.add(t),Om(),()=>{r.delete(t),Pm()}}function Zx(e,t){return Fo(e,r=>t(JSON.parse(r)))}const ew={async list(){return(await(await fetch(`${Se()}/list`)).json()).files},async read(e){const t=await fetch(`${Se()}/file?path=${encodeURIComponent(e)}`);if(!t.ok)throw new Error(`read ${e}: ${t.status}`);return t.text()},async write(e,t){const r=await fetch(`${Se()}/file?path=${encodeURIComponent(e)}`,{method:"PUT",body:t});if(!r.ok)throw new Error(`write ${e}: ${r.status}`)},watch(e){return pn(e)}};function ch(e,t){e.remoteAnswer=(o,l,c)=>{fetch(`${Se()}/agents/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:o.sessionId,questionId:o.id,text:l,author:c})}).then(async d=>{if(!d.ok)throw new Error((await d.json().catch(()=>({}))).error??`HTTP ${d.status}`)}).catch(d=>e.push({source:"system",level:"alert",sessionId:o.sessionId,text:`Answer not delivered to ${o.agent} · ${d.message}`}))};const r=new EventSource(`${Se()}/events`);r.addEventListener("agent",o=>e.syncRemote(JSON.parse(o.data))),r.addEventListener("leases",o=>t.set(JSON.parse(o.data).leases)),fetch(`${Se()}/agents/leases`).then(o=>o.ok?o.json():{leases:[]}).then(({leases:o})=>t.set(o)).catch(()=>{}),fetch(`${Se()}/agents`).then(o=>o.ok?o.json():{sessions:[]}).then(({sessions:o})=>[...o].reverse().forEach(l=>e.syncRemote(l))).catch(()=>{})}function uh(e){const t=r=>`${Eo}:${e}:${r}`;return{get:r=>localStorage.getItem(t(r)),set:(r,o)=>{try{localStorage.setItem(t(r),o)}catch{}}}}const tw=["markdown","github","linear"];function nw(){const e=new URLSearchParams(location.search).get("tracker");return e&&tw.includes(e)?e:jc().tracker}function sw(e){let t,r;const o=new Rk,l=new Xx(o),c={},d=Ek(Se());if(e==="github"||e==="linear"){const m=new ix(e,Se());t=m,r=fetch(`${Se()}/trackers`).then(v=>v.json()).catch(()=>{}).then(v=>{m.location=(e==="github"?v==null?void 0:v.github.repo:[v==null?void 0:v.linear.teamKey,v==null?void 0:v.linear.projectName].filter(Boolean).join(" · "))||m.location;const y=uh(`${e}:${m.location}`);c.presence=new Vf(y),o.ledger=new Gf(y),ch(o,l)})}else t=new nx(ew,`./${ve.dataDir}`),r=fetch(`${Se()}/list`).then(m=>m.json()).catch(()=>({root:"default"})).then(({root:m})=>{const v=uh(m);c.presence=new Vf(v),o.ledger=new Gf(v),ch(o,l)});const f=Dk(t),g=f.adapter;return{kind:e,ready:r,get presence(){return c.presence},adapter:g,journal:d,monitor:f,activity:o,leases:l}}const tn=e=>e.status==="running",_m=e=>tn(e)&&!!e.waitingOn,iw={blocking:0,soon:1,fyi:2};function rw(e,t,r){const o=e.filter(d=>d.sessionId===t),l=o.find(d=>d.id===r);if(l)return l;const c=d=>iw[d.urgency??"soon"];return[...o].sort((d,f)=>c(d)-c(f)||d.at-f.at)[0]}function ts({n:e,urgent:t,pop:r,hideZero:o}){return i.jsx("span",{className:We("badge",t&&"urgent",r&&t&&"pop",o&&!e&&"zero"),children:o&&!e?"":e})}function K({variant:e="default",size:t="md",on:r,className:o,type:l,...c}){return i.jsx("button",{type:l??"button",className:We("btn",e!=="default"&&e,t==="sm"&&"sm",r&&"on",o),...c})}function Ot({as:e="div",tone:t,on:r,className:o,children:l,...c}){return i.jsx(e,{className:We("card",t,r&&"on",o),...c,children:l})}function ht({on:e,title:t,sub:r,disabled:o,onClick:l}){return i.jsxs(Ot,{as:"button",type:"button",className:"choice",on:e,disabled:o,onClick:l,children:[i.jsx("b",{className:"choice-title t-row-title",children:t}),r&&i.jsx("span",{className:"c-sub",children:r})]})}function Ee({children:e}){return i.jsx("div",{className:"empty",children:e})}function Dn({title:e,hint:t,art:r}){return i.jsxs("div",{className:r?"empty-state has-art":"empty-state",children:[r,i.jsxs("div",{className:"es-words",children:[i.jsx("span",{className:"es-title",children:e}),t&&i.jsx("span",{className:"es-hint",children:t})]})]})}function Ye({label:e,children:t,className:r}){return i.jsxs("label",{className:We("field",r),children:[e,t]})}const Nc=x.forwardRef(function({value:t,onValueChange:r,onSubmit:o,action:l="Send",actionDisabled:c,className:d,...f},g){return i.jsxs("form",{className:We("input-row",d),onSubmit:m=>{m.preventDefault(),o(t)},children:[i.jsx("textarea",{ref:g,rows:1,value:t,onChange:m=>r(m.target.value),onKeyDown:m=>{m.key==="Enter"&&!m.shiftKey&&(m.preventDefault(),o(t))},...f}),i.jsx(K,{type:"submit",variant:"primary",disabled:c??(f.disabled||!t.trim()),children:l})]})});function Us({text:e}){return i.jsx("span",{className:"info-tip","data-tip":e,"data-tip-scout":!0,tabIndex:0,role:"img","aria-label":e,children:i.jsxs("svg",{viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":"true",children:[i.jsx("circle",{cx:"7",cy:"3.7",r:"1.3"}),i.jsx("path",{d:"M5.6 6.300H8v4.200h1v1.200H5v-1.200h1.200V7.500h-.6z"})]})})}function Je({as:e="span",variant:t="chip",hot:r,size:o,className:l,children:c,title:d}){return i.jsx(e,{className:We(t==="chip"?"chip-label":"mono-label",r&&"hot",o==="sm"&&(t==="chip"?"sm":"xs"),l),title:d,children:c})}const ow=e=>typeof e=="string"?{text:e}:e,aw=e=>We(e.code&&"t-code",e.strong&&"strong",e.urgent&&"urgent",e.className);function q(e){const t=e.parts.filter(r=>!!r&&(typeof r=="string"||!!r.text)).map(ow);return!t.length&&!e.children?null:i.jsxs("span",{className:We("meta-line t-meta",e.className),children:[t.map((r,o)=>i.jsxs("span",{children:[o>0&&i.jsx("span",{className:"sep",children:" · "}),i.jsx("span",{className:aw(r)||void 0,title:r.tip,children:r.text})]},o)),e.children]})}function Sc(e){return i.jsxs("div",{className:"ds-load-failed",role:"alert",children:[i.jsx(q,{parts:[e.what,e.reason]}),i.jsx(K,{size:"sm",variant:"ghost",onClick:e.onRetry,children:"Retry"})]})}function Hs(e){const t=Array.from({length:e.rows??0},(r,o)=>o);return i.jsxs("div",{className:We("ds-loading",e.className),role:"status","aria-live":"polite",children:[i.jsxs("span",{className:"ds-loading-line t-meta",children:[i.jsx("span",{className:"ds-spinner","aria-hidden":"true"}),e.label]}),t.length>0&&i.jsx("ul",{className:"ds-skeleton-list","aria-hidden":"true",children:t.map(r=>i.jsxs("li",{className:"ds-skeleton-row",children:[i.jsx("span",{className:"ds-skeleton-bar title"}),i.jsx("span",{className:"ds-skeleton-bar meta"})]},r))})]})}const lw="M25.53 10.5 A11 11 0 1 1 16 5",cw="M20 5 L14.6 1.6 L14.6 8.4 Z";function Ws({variant:e="mark",state:t="ok",size:r=20,className:o="",title:l}){const c=r<=14?3:2.4;return i.jsxs("svg",{className:`scout-mark mm-${e} mm-${t} ${o}`,viewBox:"0 0 32 32",width:r,height:r,role:l?"img":void 0,"aria-label":l,"aria-hidden":l?void 0:!0,children:[e==="status"||e==="alert"?i.jsx("circle",{cx:"16",cy:"16",r:"11",fill:"none",stroke:"currentColor",strokeWidth:c,strokeDasharray:t==="syncing"?"5 3.6":void 0}):i.jsx("path",{d:lw,fill:"none",stroke:"currentColor",strokeWidth:c,strokeLinecap:"butt"}),(e==="mark"||e==="action")&&i.jsx("path",{d:cw,fill:"currentColor"}),e==="action"&&i.jsx("path",{d:"M13 11 L21.5 16 L13 21 Z",fill:"currentColor"}),(e==="mark"||e==="voice")&&i.jsx("circle",{cx:"16",cy:"16",r:e==="voice"?4:3.4,fill:"currentColor"}),e==="status"&&(t==="idle"?i.jsx("circle",{cx:"16",cy:"16",r:"3.4",fill:"none",stroke:"currentColor",strokeWidth:"1.6"}):i.jsx("circle",{cx:"16",cy:"16",r:"4.2",fill:"currentColor"})),e==="alert"&&i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"14.4",y:"8.5",width:"3.2",height:"9.5",fill:"currentColor"}),i.jsx("rect",{x:"14.4",y:"20.5",width:"3.2",height:"3.2",fill:"currentColor"})]})]})}function wo({parts:e,className:t,as:r="div"}){const o=e.filter(l=>l!=null&&l!==!1&&l!=="");return i.jsx(r,{className:We("meta",t),children:o.map((l,c)=>i.jsxs("span",{children:[c>0&&" · ",l]},c))})}function uw({size:e=40,bare:t,className:r}){return i.jsx(Hx,{size:e,bare:t,className:r})}const dh=()=>{const e=document.documentElement.dataset.theme;return e?e==="night":matchMedia("(prefers-color-scheme: dark)").matches};function bc(){const[e,t]=x.useState(dh);return x.useEffect(()=>{const r=()=>t(dh()),o=matchMedia("(prefers-color-scheme: dark)");o.addEventListener("change",r);const l=new MutationObserver(r);return l.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{o.removeEventListener("change",r),l.disconnect()}},[]),e}function dw(){const e=()=>window.innerWidth>=1440?"wide":window.innerWidth>=1024?"laptop":"mobile",[t,r]=x.useState(e);return x.useEffect(()=>{const o=()=>r(e());return window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)},[]),t}const fw=15e3,fh=["pointerdown","pointermove","keydown","wheel","touchstart"];function hw(e,t,r,o){const[l,c]=x.useState(null),[d,f]=x.useState(!1),[g,m]=x.useState(!1),v=x.useRef(),y=x.useRef(Date.now()),w=x.useRef(!1),j=r.awayMinutes*6e4,$=x.useRef(t);$.current=t;const N=x.useRef(o);N.current=o;const E=x.useCallback((Q,F)=>{const ie=$.current;return iy({snaps:Object.values(ie.allSnaps),decisions:ie.decisions,activity:ie.activity,ledger:e.activity.ledger,since:V=>{var ge;return Q[V]??F??((ge=ie.allSnaps[V])==null?void 0:ge.map.createdAt)??Date.now()},currentMapId:ie.mapId,attention:N.current})},[e]),M=x.useCallback((Q=Date.now())=>{var F;return(F=e.presence)==null?void 0:F.markSeen($.current.maps.map(ie=>ie.id),Q)},[e]),R=x.useCallback(()=>{const Q=e.presence;if(!Q)return;const F=Q.lastSeenAny();if(F!==void 0&&Date.now()-F>=j){const ie=Q.snapshot();E(ie,F).changed&&(v.current={seen:ie,any:F},f(!0),r.enabled?c(ie):m(!0))}M()},[e,j,r.enabled,E,M]);x.useEffect(()=>{!t.loaded||w.current||!e.presence||(w.current=!0,R())},[t.loaded,e,R]),x.useEffect(()=>{const Q=()=>{const V=Date.now()-y.current>=j;y.current=Date.now(),V&&w.current&&document.visibilityState==="visible"&&R()},F=()=>{if(document.visibilityState!=="visible"){w.current&&M(Date.now()-y.current<j?Date.now():y.current);return}y.current=Date.now(),w.current&&R()};for(const V of fh)window.addEventListener(V,Q,{passive:!0});document.addEventListener("visibilitychange",F);const ie=setInterval(()=>{w.current&&document.visibilityState==="visible"&&M(y.current)},fw);return()=>{for(const V of fh)window.removeEventListener(V,Q);document.removeEventListener("visibilitychange",F),clearInterval(ie)}},[j,R,M]);const O=x.useMemo(()=>{var Q;return l?E(l,(Q=v.current)==null?void 0:Q.any):void 0},[l,E,t.allSnaps,t.decisions,t.activity,o]),X=x.useMemo(()=>O?ly(O):"",[O]);x.useEffect(()=>{l&&m(!1)},[l]);let se="none";return g?se="new":d&&(se="seen"),{shown:l!==null,status:se,briefing:O,line:X,open:()=>{const Q=v.current;Q&&c(Q.seen)},dismiss:()=>c(null)}}function mw(e){const[t,r]=x.useState(e.leases.leases);return x.useEffect(()=>e.leases.subscribe(r),[e]),t}function pw(e){var U;const[t,r]=x.useState([]),[o,l]=x.useState(),[c,d]=x.useState(),[f,g]=x.useState({}),[m,v]=x.useState({}),[y,w]=x.useState(!1),[j,$]=x.useState(e.activity.snapshot),[N,E]=x.useState(e.monitor.health),M=mw(e);x.useEffect(()=>e.monitor.subscribe(E),[e]);const[R,O]=x.useState(null),[X,se]=x.useState(),[Q,F]=x.useState(),ie=x.useRef(),V=x.useRef(),ge=x.useRef(new Set),Re=x.useRef();Re.current=c;const be=x.useCallback(D=>{ie.current=D,l(D),O(null)},[]),te=x.useCallback(async()=>{var pe;const D=await e.adapter.listMaps();r(D);let H=ie.current;const T=V.current;T&&D.some(de=>de.id===T)?(V.current=void 0,H=T,H!==ie.current&&be(H)):(!H||!D.some(de=>de.id===H))&&(H=(pe=D[0])==null?void 0:pe.id,be(H));const[_,he]=await Promise.all([Promise.all(D.map(de=>e.adapter.loadMap(de.id))),Promise.all(D.map(de=>e.adapter.listDecisions(de.id)))]);g(Object.fromEntries(_.map(de=>[de.map.id,de]))),v(Object.fromEntries(D.map((de,we)=>[de.id,he[we]]))),w(!0),d(_.find(de=>de.map.id===H))},[e,be]);x.useEffect(()=>{let D,H=()=>{},T=()=>{},_=!0;const he=()=>{clearTimeout(D),D=setTimeout(()=>void te().catch(me=>se(String(me))),40)},pe=(me,ke)=>tn(me)&&e.activity.isRemote(me.id)&&(!ke||!me.mapId||me.mapId===ke),de=me=>{var ke;return(ke=Re.current)==null?void 0:ke.tickets.find($e=>$e.id===me)},we=me=>{const ke=Ok(me,de),$e=me.kind==="external.changed"&&e.activity.snapshot.sessions.some(ss=>pe(ss,me.mapId)),ut=!("mapId"in me)||!me.mapId||me.mapId===ie.current||me.kind==="map.created";ke&&!$e&&ut&&e.activity.push(ke),he()};return e.ready.then(()=>{_&&(H=e.adapter.subscribe(we),T=e.activity.subscribe($),e.activity.push({source:"system",level:"ok",text:`Online · tracker ${e.adapter.label.toLowerCase()} · ${e.adapter.location}`}),te().catch(me=>se(String(me))))}),()=>{_=!1,H(),T(),clearTimeout(D)}},[e,te]),x.useEffect(()=>{o&&e.adapter.loadMap(o).then(d)},[o,e]),x.useEffect(()=>{for(const D of j.sessions)D.mode!=="chart"||!D.mapId||!e.activity.isRemote(D.id)||ge.current.has(D.id)||(ge.current.add(D.id),!(D.status!=="running"&&Date.now()-(D.endedAt??0)>6e4)&&(V.current=D.mapId,te().catch(H=>se(String(H)))))},[j.sessions,e,te]);const P=(U=j.pending[0])==null?void 0:U.sessionId;x.useEffect(()=>{if(!P)return;const D=H=>e.activity.snapshot.sessions.some(T=>T.id===H&&tn(T));F(H=>D(H)?H:P)},[P,e]);const Y=x.useCallback(async(D,H)=>{e.activity.push({source:"trail lead",agent:wt,level:"warn",text:D});try{se(void 0),await H()}catch(T){const _=T.message??String(T);se(_),e.activity.push({source:"trail lead",agent:wt,level:"alert",text:`Rejected · ${_}`})}},[e]),ae=x.useMemo(()=>Wx({rt:e,guard:Y,setMapId:be,mapIdRef:ie,snapRef:Re,setChatSession:F,setSelection:O}),[Y,e,be]),Z=x.useMemo(()=>Object.values(f).flatMap(D=>Hk(D,m[D.map.id]??[])).sort((D,H)=>H.decidedAt-D.decidedAt),[f,m]);return{maps:t,allSnaps:f,mapId:o,snap:c,activity:j,health:N,selection:R,setSelection:O,error:X,chatSession:Q,decisions:Z,leases:M,loaded:y,actions:ae}}function sn(e=1e3){const[t,r]=x.useState(Date.now());return x.useEffect(()=>{const o=setInterval(()=>r(Date.now()),e);return()=>clearInterval(o)},[e]),t}function gw(){const[e,t]=x.useState(jc),r=x.useCallback(o=>{t(l=>{const c={...l,...o};return localStorage.setItem(Eo,JSON.stringify(c)),c})},[]);return[e,r]}function Cc(){return x.useSyncExternalStore(Bs.subscribe,Bs.get)}function vw({className:e,size:t=18}){return i.jsx("span",{className:e,"aria-hidden":"true",children:i.jsx(Tm,{size:t,variant:bc()?"night":"crt"})})}function Ke({as:e="section",className:t,style:r,frameless:o,children:l,...c}){return i.jsx(e,{className:We("panel",o&&"frameless",t),style:r,...c,children:l})}function zn({tone:e,className:t,children:r,title:o}){return i.jsx("span",{className:We("pill",e,t),title:o,children:r})}function Zt({label:e,value:t,layout:r="stack",urgent:o,title:l,className:c}){return i.jsxs("span",{className:We("readout",r!=="stack"&&r,o&&"urgent",c),title:l,children:[i.jsx("span",{className:"mono-label",children:e}),r==="inline"&&" ",i.jsx("b",{children:t})]})}function Ae(e){const{as:t="div",edge:r="neutral"}=e,o=e.onOpen?"button":"div";return i.jsxs(t,{className:We("ds-row",`edge-${r}`,e.selected&&"on",e.className),children:[i.jsxs(o,{className:"ds-row-main",...e.onOpen?{type:"button",onClick:e.onOpen}:{},title:e.titleText,"aria-current":e.current,children:[i.jsxs("span",{className:"ds-row-top",children:[i.jsx("span",{className:"ds-row-title t-row-title",children:e.title}),e.trailing&&i.jsx("span",{className:"ds-row-trail t-meta",children:e.trailing})]}),e.context&&i.jsx("span",{className:"ds-row-context",children:e.context}),e.detail&&i.jsx("span",{className:"ds-row-detail t-meta",title:e.detailText,children:e.detail})]}),e.actions&&i.jsx("span",{className:"ds-row-actions",children:e.actions}),e.below&&i.jsx("div",{className:"ds-row-below",children:e.below})]})}const Pn="#c8581e",kw={map:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M3 6l6-2.5 6 2.5 6-2.5v14.5L15 20.5 9 18l-6 2.5z"}),i.jsx("path",{d:"M9 3.5V18M15 6v14.5"}),i.jsx("path",{d:"M5.5 15c2-1 3-3 5-3.5s3-3 5-4",stroke:Pn,strokeDasharray:"2 2.2"})]}),note:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M5 3.5h14v13.5l-4 3.5H5z"}),i.jsx("path",{d:"M15 21v-4h4"}),i.jsx("path",{d:"M8.5 8h7M8.5 12h7",stroke:Pn})]}),book:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 6.5C10 4.5 7 4 3.5 4.5v14c3.5-.5 6.5 0 8.5 2 2-2 5-2.5 8.5-2v-14C17 4 14 4.5 12 6.5z"}),i.jsx("path",{d:"M12 6.5v14"}),i.jsx("path",{d:"M15 9.5l3-.5M15 13l3-.5",stroke:Pn})]}),flag:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M6 21.5V3"}),i.jsx("path",{d:"M6 4c4-1.5 7 1.5 12 0v9c-5 1.5-8-1.5-12 0z",fill:Pn,stroke:Pn})]}),tent:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 4L2.5 20h19z"}),i.jsx("path",{d:"M12 11l-4 9h8z",fill:Pn,stroke:Pn}),i.jsx("path",{d:"M12 4l-1.5-2M12 4l1.5-2"})]}),mailbox:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 21.500V14"}),i.jsx("path",{d:"M4 14V9.500A4.5 4.5 0 0 1 8.5 5h7A4.5 4.5 0 0 1 20 9.500V14z"}),i.jsx("path",{d:"M8.5 5A4.5 4.5 0 0 1 13 9.500V14"}),i.jsx("path",{d:"M16 10V6.500M16 6.500h3v2.500h-3",stroke:Pn})]})};function Dm({name:e}){return i.jsx("svg",{className:"zone-icon","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:kw[e]})}function Ct({title:e,count:t,right:r,hot:o,sub:l,children:c,className:d,info:f,icon:g}){return i.jsxs("header",{className:We("sec-h",l&&"sub",d),children:[c,g&&i.jsx(Dm,{name:g}),e!==void 0&&i.jsx(Je,{as:l?"h3":"h2",hot:o,children:e}),f&&i.jsx(Us,{text:f}),t,r!==void 0&&i.jsx("span",{className:"sec-h-right",children:r})]})}function ct(e){const{value:t,options:r,onChange:o}=e,[l,c]=x.useState(!1),[d,f]=x.useState(0),[g,m]=x.useState(),v=x.useRef(null),y=x.useRef(null),w=x.useId(),j=r.find(M=>M.value===t);x.useLayoutEffect(()=>{if(!l||!v.current)return;const M=v.current.getBoundingClientRect();m({left:M.left,top:M.bottom+4,minWidth:M.width})},[l]),x.useEffect(()=>{if(!l)return;const M=O=>{var X,se;O.target instanceof Node&&((X=y.current)!=null&&X.contains(O.target)||(se=v.current)!=null&&se.contains(O.target))||c(!1)},R=()=>c(!1);return document.addEventListener("mousedown",M),window.addEventListener("resize",R),window.addEventListener("scroll",R,!0),()=>{document.removeEventListener("mousedown",M),window.removeEventListener("resize",R),window.removeEventListener("scroll",R,!0)}},[l]),x.useEffect(()=>{var M,R;l&&((R=(M=y.current)==null?void 0:M.querySelector(`[data-i="${d}"]`))==null||R.scrollIntoView({block:"nearest"}))},[l,d]);const $=()=>{f(Math.max(0,r.findIndex(M=>M.value===t))),c(!0)},N=M=>{var O;const R=r[M];c(!1),(O=v.current)==null||O.focus(),R&&R.value!==t&&o(R.value)},E=M=>{if(!l){["ArrowDown","ArrowUp","Enter"," "].includes(M.key)&&(M.preventDefault(),$());return}const R=O=>f(X=>(X+O+r.length)%r.length);if(M.key==="ArrowDown")R(1);else if(M.key==="ArrowUp")R(-1);else if(M.key==="Home")f(0);else if(M.key==="End")f(r.length-1);else if(M.key==="Enter"||M.key===" ")N(d);else{if(M.key==="Escape"||M.key==="Tab")return c(!1);if(M.key.length===1){const O=r.findIndex(X=>X.label.toLowerCase().startsWith(M.key.toLowerCase()));O>=0&&f(O);return}else return}M.preventDefault()};return i.jsxs(i.Fragment,{children:[i.jsxs("button",{ref:v,type:"button",className:We("select",e.compact&&"compact",l&&"open",e.className),role:"combobox","aria-haspopup":"listbox","aria-expanded":l,"aria-controls":w,"aria-label":e["aria-label"],"aria-activedescendant":l?`${w}-${d}`:void 0,disabled:e.disabled,onClick:()=>l?c(!1):$(),onKeyDown:E,children:[i.jsx("span",{className:"select-value",children:(j==null?void 0:j.label)??"—"}),i.jsx("span",{className:"select-caret","aria-hidden":"true"})]}),l&&g&&i.jsx("ul",{ref:y,id:w,className:"select-menu",role:"listbox",style:g,children:r.map((M,R)=>i.jsxs("li",{id:`${w}-${R}`,"data-i":R,role:"option","aria-selected":M.value===t,className:We(R===d&&"active"),onMouseEnter:()=>f(R),onMouseDown:O=>O.preventDefault(),onClick:()=>N(R),children:[i.jsx("span",{className:"select-label",children:M.label}),M.hint&&i.jsx("span",{className:"select-hint",children:M.hint})]},M.value))})]})}function yw(e){return i.jsx("div",{className:`tabs ${e.className??""}`,role:"tablist",children:e.items.map(t=>i.jsxs("button",{role:"tab","aria-selected":e.value===t.id,className:`tab ${e.value===t.id?"on":""}`,onClick:()=>e.onChange(t.id),children:[t.label,t.n!==void 0&&i.jsx("span",{className:"n",children:t.n})]},t.id))})}const xw=350;function ww(){const[e,t]=x.useState(null);if(x.useEffect(()=>{let o=0,l=null;const c=()=>{window.clearTimeout(o),l=null,t(null)},d=v=>{const y=v.getAttribute("data-tip");if(!y)return;const w=v.getBoundingClientRect(),j=w.bottom+60>window.innerHeight;t({text:y,x:w.left+w.width/2,y:j?w.top-8:w.bottom+8,above:j,scout:v.hasAttribute("data-tip-scout")})},f=v=>{var j,$;const y=($=(j=v.target)==null?void 0:j.closest)==null?void 0:$.call(j,"[data-tip], [title]");if(!y||y instanceof SVGElement&&!y.hasAttribute("data-tip"))return null;const w=y.getAttribute("title");return w&&(y.setAttribute("data-tip",w),y.removeAttribute("title")),y},g=v=>{if(v.pointerType==="touch")return;const y=f(v);y!==l&&(c(),y&&(l=y,o=window.setTimeout(()=>l===y&&d(y),v.type==="focusin"?0:xw)))},m=v=>{l&&!l.contains(v.relatedTarget)&&c()};return document.addEventListener("pointerover",g),document.addEventListener("pointerout",m),document.addEventListener("focusin",g),document.addEventListener("focusout",c),document.addEventListener("pointerdown",c),window.addEventListener("scroll",c,!0),window.addEventListener("keydown",c),()=>{c(),document.removeEventListener("pointerover",g),document.removeEventListener("pointerout",m),document.removeEventListener("focusin",g),document.removeEventListener("focusout",c),document.removeEventListener("pointerdown",c),window.removeEventListener("scroll",c,!0),window.removeEventListener("keydown",c)}},[]),!e)return null;const r=Math.min(Math.max(e.x,140),window.innerWidth-140);if(e.scout){const o=Math.min(Math.max(e.x-24,8),window.innerWidth-340);return i.jsxs("div",{className:`scout-tip ${e.above?"above":""}`,role:"tooltip",style:{left:o,top:e.y,transform:e.above?"translateY(-100%)":void 0},children:[i.jsx(_o,{size:1,framed:!1,speaking:e.text,className:"scout-tip-face"}),i.jsx("p",{className:"scout-tip-bubble",children:e.text})]})}return i.jsx("div",{className:`tooltip ${e.above?"above":""}`,role:"tooltip",style:{left:r,top:e.y,transform:`translate(-50%, ${e.above?"-100%":"0"})`},children:e.text})}function Bm({as:e="span",className:t}){return i.jsx(e,{className:t,children:ve.name})}function zm(e){return e.bare?i.jsx("div",{className:`zone-b ${e.className??""}`,children:e.children}):i.jsxs(Ke,{className:`zone ${e.className??""}`,style:e.area?{gridArea:e.area}:void 0,children:[i.jsx(Ct,{className:"zone-title",icon:e.icon,title:e.title,info:e.info,count:e.count,right:e.right??null}),i.jsx("div",{className:"zone-b",children:e.children})]})}function Es(e){return e.children.length?i.jsxs("div",{className:`bf-list ${e.urgent?"urgent":""}`,children:[i.jsx("span",{className:"mono-label",children:e.title}),i.jsx("ul",{children:e.children})]}):null}function ao(e){return i.jsx("li",{children:i.jsxs("button",{className:"bf-row",onClick:e.onClick,title:e.title,children:[i.jsx("span",{className:"key t-code",children:e.k}),i.jsx("span",{className:"t",children:e.text}),e.meta&&i.jsx("span",{className:"t-meta",children:e.meta})]})})}function Ri(e){return i.jsxs(Ot,{tone:e.urgent?"urgent":void 0,className:`bf-tile ${e.className??""}`,children:[i.jsx("span",{className:"mono-label",children:e.label}),i.jsx("b",{children:e.value}),e.sub&&i.jsx(q,{parts:[],children:e.sub})]})}const jw=864e5;function Nw(e,t){const r=new Date(e),o=r.toTimeString().slice(0,5),l=new Date(t).toDateString(),c=new Date(t-jw).toDateString();let d=` ${r.toLocaleDateString(void 0,{month:"short",day:"numeric"})}`;return r.toDateString()===l?d="":r.toDateString()===c&&(d=" yesterday"),`Since ${o}${d} · ${Wt(t-e)}`}function Sw(e){const{briefing:t,bp:r,onClose:o}=e;x.useEffect(()=>{const y=w=>w.key==="Escape"&&o();return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[o]);const l=t==null?void 0:t.trails.flatMap(y=>y.waiting).sort((y,w)=>y.at-w.at)[0],c=t==null?void 0:t.totals,d=((t==null?void 0:t.trails.length)??0)>1,f=r==="mobile",g=y=>{var w,j;return y.ticketId&&((j=(w=e.snaps[y.mapId])==null?void 0:w.tickets.find($=>$.id===y.ticketId))==null?void 0:j.title)||y.text},m=y=>{var w,j;return y.ticketId&&((j=(w=e.snaps[y.mapId])==null?void 0:w.tickets.find($=>$.id===y.ticketId))==null?void 0:j.key)||y.agent},v=y=>{const w=(M,R)=>i.jsx(ao,{k:M.key,text:M.title,meta:R,onClick:()=>e.onTicket(y.mapId,M.id)},M.id),j=(M,R)=>i.jsx(ao,{k:M.id,text:M.summary||M.answer,title:M.risk?`${M.question}
|
|
118
118
|
|
|
119
119
|
${M.risk.reason}`:M.question,meta:R,onClick:()=>e.onDecision(M.id)},M.id),$=Ay(y.agentDecisions).flatMap(M=>M.decisions.map(R=>j(R,M.label))),N=[i.jsx(Es,{title:"Done",children:y.done.map(M=>w(M))},"done"),i.jsx(Es,{title:"Ruled out",children:f?[]:y.ruledOut.map(M=>w(M))},"oos"),i.jsx(Es,{title:"Blocked",children:y.blocked.map(M=>w(M.ticket,`needs ${M.on.map(R=>R.key).join(", ")}`))},"blocked")],E=[i.jsx(Es,{title:"Waiting on you",urgent:!0,children:y.waiting.map(M=>i.jsx(ao,{k:m(M),text:g(M),meta:t.now-M.at<6e4?"now":Wt(t.now-M.at),title:M.text,onClick:()=>e.onAnswer(M)},M.id))},"waiting"),i.jsx(Es,{title:"Agent decisions",children:f?[]:$},"agent"),i.jsx(Es,{title:"Active sessions",children:f?[]:y.active.map(M=>{var O;const R=M.ticketId?(O=e.snaps[y.mapId])==null?void 0:O.tickets.find(X=>X.id===M.ticketId):void 0;return i.jsx(ao,{k:(R==null?void 0:R.key)??M.agent,text:R?`${R.title} · ${M.stepLabel}`:M.stepLabel,meta:`${M.step}/${M.total}`,onClick:()=>e.onSession(M)},M.id)})},"active")];return i.jsxs("section",{className:"bf-trail",children:[d&&i.jsxs("div",{className:"bf-trail-h",children:[i.jsx("span",{className:"key",children:y.key})," ",y.title]}),i.jsxs("div",{className:"bf-cols",children:[i.jsx("div",{children:N}),i.jsx("div",{children:E})]})]},y.mapId)};return i.jsx("div",{className:"scrim",onClick:o,children:i.jsxs(Ke,{as:"div",className:"dialog briefing",role:"dialog","aria-label":"While you were away",onClick:y=>y.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:"While you were away"}),t&&t.trails.length>0&&i.jsx(Je,{className:"bf-since",children:Nw(t.since,t.now)}),i.jsx("button",{className:"icon-btn",onClick:o,"aria-label":"Close",children:"×"})]}),i.jsxs(Ot,{className:"bf-scout",children:[i.jsx(_o,{size:f?1.1:1.3,speaking:e.line||"Nothing new since you were last here.",caption:!1,framed:!1}),i.jsxs("div",{children:[i.jsx("span",{className:"mono-label",children:"Scout"}),i.jsx("p",{children:e.line||"Nothing new since you were last here."})]})]}),t&&c&&t.trails.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"bf-tiles",children:[i.jsx(Ri,{label:"Done",value:c.done,sub:c.ruledOut?`${c.ruledOut} ruled out`:void 0}),i.jsx(Ri,{label:"Blocked",value:c.blocked,sub:c.blocked?"Needs your answer":void 0}),i.jsx(Ri,{label:"Waiting on you",value:c.waiting,sub:bw(c.oldestWaitMs),urgent:c.waiting>0}),i.jsx(Ri,{label:"Agent decisions",value:c.agentDecisions,className:"opt"}),i.jsx(Ri,{label:"Spend",value:_s(c.usage.costUsd),sub:`${zo(c.usage.inputTokens+c.usage.outputTokens)} tokens · ${c.usage.sessions} sessions${c.active?` · ${c.active} active`:""}`})]}),i.jsx("div",{className:"bf-body",children:t.trails.map(v)})]}),i.jsxs("footer",{children:[i.jsx(K,{onClick:o,children:"Dismiss"}),l?i.jsxs(K,{variant:"urgent",onClick:()=>e.onAnswer(l),children:[i.jsx(Ws,{variant:"alert",size:13}),"Answer first decision"]}):i.jsx(K,{variant:"primary",onClick:e.onResume,children:"Resume trail"})]})]})})}function bw(e){if(e!==void 0)return e<6e4?"Just asked":`Oldest ${Wt(e)}`}function Cw(e){const{brief:t,bp:r}=e;return i.jsx(Sw,{briefing:t.briefing,line:t.line,snaps:e.snaps,bp:r,onClose:t.dismiss,onTicket:(o,l)=>{t.dismiss(),e.openTicket(o,l)},onAnswer:o=>{t.dismiss(),e.closeDecisions(),e.openChat(o.sessionId,o.ticketId,o.mapId)},onSession:o=>{t.dismiss(),e.closeDecisions(),e.openChat(o.id,o.ticketId,o.mapId)},onDecision:o=>{t.dismiss(),e.openDecisions(o)},onResume:()=>{t.dismiss(),e.closeDecisions(),r==="mobile"&&e.showPhoneHome()}})}const $w={passed:"checks passed",failing:"checks failing",pending:"checks pending",unknown:"checks unknown",none:"no checks"};function Tw({mapId:e,ticketId:t}){const r=Bs.ticket(Cc(),e,t);if(!r)return null;const o=r.pr;return i.jsxs("div",{className:"pr-flags",children:[i.jsxs("span",{className:`pr-chip pr-${(o==null?void 0:o.state)??"unread"}`,title:o?`${o.title}
|
|
120
120
|
${o.headRef}`:void 0,children:[o?i.jsxs("a",{href:o.url,target:"_blank",rel:"noreferrer noopener",children:["PR #",o.number," · ",o.state,o.draft?" · draft":""]}):`PR #${r.link.number}`,i.jsx("span",{className:`ci ci-${r.checksSummary}`,children:$w[r.checksSummary]}),i.jsx("span",{className:"when",children:Ew(r)})]}),r.flags.map(l=>i.jsx(zn,{className:`flag flag-${l.severity}`,title:l.text,children:l.kind},l.kind))]})}function Ew(e){return e.error?"sync failed":e.syncedAt?Mm(e.syncedAt):"not synced yet"}const Iw={ok:"ok",failed:"error",stale:"syncing",unknown:"idle",off:"idle"};function Mw({now:e}){const t=Cc();if(!t.reached)return null;const r=Mk(t.live?t.status:null,e);return i.jsxs("span",{className:`tracker-chip pr-sync tone-${r.tone}`,title:r.title,children:[i.jsx(Je,{size:"sm",children:"CI"}),i.jsx(Ws,{variant:"status",state:Iw[r.tone],size:13,className:"sync-glyph"}),i.jsx("span",{className:"tl",children:r.label})]})}function Fm(e){const t=e.role??"menu",[r,o]=x.useState(!1),l=x.useRef(null);return x.useEffect(()=>{if(!r)return;const c=d=>{var g;(d instanceof KeyboardEvent?d.key==="Escape":!((g=l.current)!=null&&g.contains(d.target)))&&o(!1)};return window.addEventListener("mousedown",c),window.addEventListener("keydown",c),()=>{window.removeEventListener("mousedown",c),window.removeEventListener("keydown",c)}},[r]),i.jsxs("div",{className:We("header-menu",e.className),ref:l,children:[i.jsxs(K,{variant:"ghost","aria-haspopup":t,"aria-label":e.ariaLabel,"aria-expanded":r,on:r,"data-tip":r?void 0:e.tip,onClick:()=>o(!r),children:[e.label," ",e.badge," ",i.jsx("span",{className:"caret",children:"▾"})]}),r&&i.jsx("div",{className:"header-menu-list",role:t,children:e.children(()=>o(!1))})]})}const Aw={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 Lw(e){const t=e.briefingStatus==="new";return i.jsx(Fm,{label:"Records",badge:i.jsxs(i.Fragment,{children:[e.knowledge>0&&i.jsx("span",{className:"n hot",children:e.knowledge}),t&&i.jsx("span",{className:"new-dot","aria-label":"new trip report"})]}),children:r=>i.jsxs(i.Fragment,{children:[i.jsxs("button",{role:"menuitem",className:"header-menu-item",disabled:e.briefingStatus==="none"&&!e.briefingOpen,title:Aw[e.briefingStatus],onClick:()=>{r(),e.onBriefing()},children:[i.jsx("span",{children:"Trip report"}),t&&i.jsx("span",{className:"new-dot","aria-label":"new"})]}),i.jsxs("button",{role:"menuitem",className:"header-menu-item knowledge-btn",title:"What agents know about this codebase and product. Review suggestions, flags and stale entries",onClick:()=>{r(),e.onKnowledge()},children:[i.jsx("span",{children:"Field guide"}),e.knowledge>0&&i.jsx("span",{className:"n hot",children:e.knowledge})]}),i.jsxs("button",{role:"menuitem",className:"header-menu-item decisions-btn",title:"Every decision across your trails, with its reasoning. Search, filter and export",onClick:()=>{r(),e.onDecisions()},children:[i.jsx("span",{children:"Logbook"}),i.jsx("span",{className:"n",children:e.decisions})]}),i.jsx("button",{role:"menuitem",className:"header-menu-item stats-btn",title:"How your agents deliver across trails, by vendor, agent and ticket type.",onClick:()=>{r(),e.onStats()},children:i.jsx("span",{children:"Trail stats"})})]})})}const Rw=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"})]}),Ow=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 Pw({onToggle:e}){const t=bc(),r=t?"Switch to the day theme":"Switch to the night theme";return i.jsx(K,{variant:"ghost",className:"icon-only","aria-label":r,"data-tip":r,onClick:()=>e(!t),children:i.jsx("svg",{viewBox:"0 0 18 18",width:"16",height:"16","aria-hidden":"true",children:t?Rw:Ow})})}const _w={idle:"Idle",syncing:"Syncing",ok:"Synced",error:"Sync error"};function Dw({label:e,health:t,now:r}){const o=[`${_w[t.status]} · ${t.writes} writes · ${t.errors} errors`,t.lastWriteAt?`Last write ${Wt(t.lastWriteMs??0)}, ${Wt(r-t.lastWriteAt)} ago`:"No writes yet",t.lastError].filter(Boolean).join(`
|
|
121
121
|
`);return i.jsxs("span",{className:`tracker-chip sync-${t.status}`,title:o,children:[i.jsx(Je,{size:"sm",children:"Tracker"}),i.jsx(Ws,{variant:"status",state:t.status,size:13,className:"sync-glyph"}),i.jsx("span",{className:"tl",children:e})]})}function Bw(e){const[t,r]=x.useState(!1),o=x.useRef(null);x.useEffect(()=>{if(!t)return;const f=g=>{var m;(g instanceof KeyboardEvent?g.key==="Escape":!((m=o.current)!=null&&m.contains(g.target)))&&r(!1)};return window.addEventListener("mousedown",f),window.addEventListener("keydown",f),()=>{window.removeEventListener("mousedown",f),window.removeEventListener("keydown",f)}},[t]);const l=Object.values(e.snaps).sort((f,g)=>g.map.createdAt-f.map.createdAt),c=f=>e.activity.pending.filter(g=>g.mapId===f).length,d=e.activity.pending.filter(f=>{var g;return f.mapId!==((g=e.map)==null?void 0:g.id)}).length;return i.jsxs("div",{className:"trail-switcher",ref:o,children:[i.jsxs("button",{className:"trail-btn",onClick:()=>r(f=>!f),"aria-haspopup":"menu","aria-expanded":t,"data-tip":"Switch trail, or start a new one",children:[i.jsx("span",{className:"trail-title",children:e.map?`${e.map.key} ${e.map.title}`:"No trail"}),d>0&&i.jsx(ts,{n:d,urgent:!0}),i.jsx("span",{className:"caret",children:"▾"})]}),t&&i.jsxs("div",{className:"trail-menu",role:"menu",children:[i.jsx(Je,{variant:"plain",className:"menu-h",children:"Trails"}),l.map(f=>{var v;const g=dm(f),m=c(f.map.id);return i.jsxs("button",{role:"menuitem",className:`trail-item ${f.map.id===((v=e.map)==null?void 0:v.id)?"on":""}`,onClick:()=>{e.onSelectMap(f.map.id),r(!1)},children:[i.jsx("span",{className:"key",children:f.map.key}),i.jsx("span",{className:"mi-title",children:f.map.title}),i.jsxs("span",{className:"mi-progress",children:[g.decided,"/",g.total]}),i.jsx(ts,{n:m,urgent:!!m,hideZero:!0})]},f.map.id)}),i.jsx("button",{role:"menuitem",className:"trail-item new",onClick:()=>{r(!1),e.onNewTrail()},children:"+ New trail"})]})]})}function zw(e){const{map:t}=e,r=sn(1e3),o=e.activity.pending.length,l=t&&e.snaps[t.id],c=l&&dm(l),d=t&&fm(e.activity,t.id);return i.jsxs(Ke,{as:"header",className:"header",children:[i.jsxs("div",{className:"h-title",children:[i.jsxs("div",{className:"h-line1",children:[e.repo,i.jsx("span",{className:"sep",children:"/"}),i.jsx(Bw,{...e})]}),i.jsxs("div",{className:"h-dest",title:t==null?void 0:t.sections.destination,children:[i.jsx(Je,{size:"sm",children:"Destination"}),(t==null?void 0:t.sections.destination)??"—"]})]}),i.jsxs("div",{className:"h-right",children:[i.jsx(Dw,{label:e.trackerLabel,health:e.health,now:r}),i.jsx(Mw,{now:r}),t&&c&&i.jsxs("span",{className:"trail-meta",children:[i.jsx(Zt,{label:"Trail T+",value:Im(r-t.createdAt),title:"Trail elapsed time, since it was charted"}),i.jsx(Zt,{label:"Done",value:`${c.decided}/${c.total}`}),d&&i.jsx(Zt,{className:"spend",label:"Spent",value:`${_s(d.costUsd)} · ${zo(d.inputTokens+d.outputTokens)} tok`,title:["Model spend and tokens for this trail, across every session",...mm(e.activity,t.id).map(f=>hm[f].text)].join(`
|
|
122
122
|
`)})]}),e.attention,!e.attention&&o>0&&i.jsxs("span",{className:"waiting-chip",title:`${o} waiting on you`,children:[i.jsx(Ws,{variant:"alert",size:14}),i.jsx("b",{children:o}),i.jsx("span",{className:"wl",children:" waiting on you"})]}),e.slackAlert&&i.jsx(K,{size:"sm",variant:"urgent",onClick:e.onSlack,title:e.slackAlert,children:"Slack disconnected"}),t&&i.jsx(K,{variant:"ghost",className:"mode-chip",onClick:e.onToggleMode,"data-tip":t.mode==="plan-only"?"Plan only: agents research and decide, but no execute tickets run. Click to switch to Plan + execute.":"Plan + execute: agents decide, then build what was decided. Click to switch to Plan only, which parks execute tickets.",children:t.mode==="plan-only"?"Plan only":"Plan + execute"}),i.jsx(Lw,{decisions:e.decisions,onDecisions:e.onDecisions,onStats:e.onStats,knowledge:e.knowledge,onKnowledge:e.onKnowledge,briefingOpen:e.briefingOpen,briefingStatus:e.briefingStatus,onBriefing:e.onBriefing}),i.jsx(K,{variant:"ghost",onClick:e.onSettings,"data-tip":"Tracker, verification, appearance and integrations",children:"Settings"}),i.jsx(Pw,{onToggle:e.onToggleTheme})]})]})}const Um=x.createContext(null);function Ks(){const e=x.useContext(Um);if(!e)throw new Error("useKnowledge needs a KnowledgeContext provider");return e}function Fw({snap:e,t}){const r=Ks();if(!r.entries.length||t.state==="closed")return null;const o=Nm(r.entries,{trailKey:e.map.key,ticket:{type:t.type,title:t.title,body:t.body},paths:Sm(`${t.body}
|
|
123
|
-
${r.briefText}`)},4e3,l=>r.stale[l.id]??[]);return i.jsxs("div",{className:"kn-preview d-section",children:[i.jsxs("span",{className:"t-label","data-tip":"Picked by paths, words, trail and kind; confirmed entries and assumptions only",children:["Knowledge this agent gets · ",o.length]}),o.length>0&&i.jsx("ul",{className:"item-list inline",children:o.map(l=>i.jsxs("li",{children:[i.jsx("button",{className:"item-text kn-open",onClick:()=>r.setOpen(!0),"data-tip":l.why.join(" · "),children:l.title}),i.jsx(Q,{parts:[{text:l.id,code:!0},l.status==="assumption"&&"assumption",l.mayBeOutdated&&{text:"may be outdated",className:"warn"}]})]},l.id))})]})}const Uw={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 Hw({e}){const t=Ks(),[r,o]=x.useState(!1),[l,c]=x.useState(e.title),[d,f]=x.useState(e.body);x.useEffect(()=>{o(!1),c(e.title),f(e.body)},[e.id,e.title,e.body]);const g=t.stale[e.id];return i.jsxs("div",{className:"kn-detail",children:[i.jsx(Q,{parts:[{text:e.id,code:!0},e.kind.replace("-"," "),e.status]}),r?i.jsxs(i.Fragment,{children:[i.jsx(Ye,{label:"Title",children:i.jsx("input",{value:l,onChange:m=>c(m.target.value)})}),i.jsx(Ye,{label:"Body",children:i.jsx("textarea",{rows:8,value:d,onChange:m=>f(m.target.value)})})]}):i.jsxs(i.Fragment,{children:[i.jsx("h3",{className:"t-title",children:e.title}),i.jsx("p",{className:"kn-body",children:e.body})]}),i.jsx("p",{className:"dim",children:Uw[e.status]}),e.flag&&i.jsxs("p",{className:"kn-warn",children:["Flagged by ",e.flag.by,": ",e.flag.reason]}),g&&e.status!=="outdated"&&i.jsxs("p",{className:"kn-warn",children:["May be outdated: ",g.join(", ")," changed since it was confirmed. Re-confirm or edit it."]}),i.jsxs("dl",{className:"facts",children:[e.scope.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Applies to"}),i.jsx("dd",{children:e.scope.join(", ")})]}),e.tags.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Tags"}),i.jsx("dd",{children:e.tags.join(", ")})]}),i.jsx("dt",{children:"From"}),i.jsx("dd",{children:[e.createdBy,...e.sources].join(" · ")}),e.anchors.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"About files"}),i.jsx("dd",{children:e.anchors.map(m=>m.path).join(", ")})]})]}),t.error&&i.jsx("p",{className:"vf-err",children:t.error}),i.jsx("div",{className:"actions",children:r?i.jsxs(i.Fragment,{children:[i.jsx(K,{variant:"ghost",onClick:()=>o(!1),children:"Cancel"}),i.jsx(K,{variant:"primary",disabled:!l.trim(),onClick:()=>void t.call(e.id,{kind:"edit",title:l,body:d}).then(m=>m&&o(!1)),children:"Save"})]}):i.jsxs(i.Fragment,{children:[(e.status!=="confirmed"||g)&&i.jsx(K,{variant:"primary",onClick:()=>void t.call(e.id,{kind:"confirm"}),children:e.status==="confirmed"?"Re-confirm":"Confirm"}),e.status!=="assumption"&&e.status!=="outdated"&&i.jsx(K,{onClick:()=>void t.call(e.id,{kind:"assumption"}),children:"Keep as assumption"}),e.flag&&i.jsx(K,{onClick:()=>void t.call(e.id,{kind:"resolve-flag"}),children:"Resolve flag"}),i.jsx(K,{variant:"ghost",onClick:()=>o(!0),children:"Edit"}),e.status!=="outdated"&&i.jsx(K,{variant:"ghost",onClick:()=>void t.call(e.id,{kind:"outdated"}),children:"Mark outdated"})]})})]})}const Ww={suggested:"Suggested",confirmed:"Confirmed",assumption:"Assumption",outdated:"Outdated"};function Kw(){const e=Ks(),[t,r]=x.useState("review"),[o,l]=x.useState(""),[c,d]=x.useState(""),[f,g]=x.useState();x.useEffect(()=>{if(!e.open)return;const N=E=>E.key==="Escape"&&e.setOpen(!1);return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[e]);const m=N=>N.status==="suggested"||!!N.flag||!!e.stale[N.id]&&N.status!=="outdated",v=(N,E)=>E==="all"?!0:E==="review"?m(N):N.status===E,y=x.useMemo(()=>{const N=c.trim().toLowerCase();return e.entries.filter(E=>v(E,t)&&(!o||E.kind===o)&&(!N||`${E.id} ${E.title} ${E.body} ${E.tags.join(" ")}`.toLowerCase().includes(N)))},[e.entries,e.stale,t,o,c]);if(!e.open)return null;const w=y.find(N=>N.id===f)??y[0],j=N=>e.entries.filter(E=>v(E,N)).length,$=[["review","Needs you"],["confirmed","Confirmed"],["assumption","Assumptions"],["outdated","Outdated"],["all","All"]];return i.jsx("div",{className:"scrim",onClick:()=>e.setOpen(!1),children:i.jsxs(Ke,{as:"div",className:"dialog knowledge-view",onClick:N=>N.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:"Field guide"}),i.jsx(Us,{text:"What agents need to know about this codebase and product. Agents propose entries; only confirmed ones and assumptions reach them, picked for each ticket with the reason. Entries about files are flagged here when those files change. Seed it from a document with: teamtrail knowledge import <file.md>"})]}),i.jsxs("div",{className:"kn-filters",children:[$.map(([N,E])=>i.jsxs("button",{className:`chip ${t===N?"on":""}`,onClick:()=>r(N),children:[E," ",i.jsx("span",{className:"n",children:j(N)})]},N)),i.jsx(ct,{compact:!0,"aria-label":"Kind",value:o,onChange:l,options:[{value:"",label:"Any kind"},...Sy.map(N=>({value:N,label:N.replace("-"," ")}))]}),i.jsx("input",{className:"kn-search",placeholder:"Search",value:c,onChange:N=>d(N.target.value)})]}),i.jsxs("div",{className:"kn-body-grid",children:[i.jsx("ul",{className:"kn-list",children:y.length?y.map(N=>i.jsx(Ae,{as:"li",className:`kn-row st-${N.status}`,edge:m(N)?"attention":"neutral",selected:N===w,onOpen:()=>g(N.id),title:N.title,titleText:N.title,context:i.jsx(Q,{parts:[{text:N.id,code:!0},N.kind.replace("-"," "),m(N)&&N.status!=="suggested"?"Needs a check":Ww[N.status]]})},N.id)):i.jsx(Ee,{children:t==="review"?"Nothing needs you":"No entries"})}),w?i.jsx(Hw,{e:w}):i.jsx(Ee,{children:"Pick an entry"})]})]})})}function $c({draft:e,label:t="Save as knowledge"}){const r=Ks(),[o,l]=x.useState();return o?i.jsxs(K,{size:"sm",variant:"ghost",onClick:()=>r.setOpen(!0),"data-tip":"Open it in the field guide to confirm it",children:["Saved as ",o]}):i.jsx(K,{size:"sm",variant:"ghost","data-tip":"Add it to the field guide as a suggestion; confirm it there and agents get it with related work",onClick:()=>void r.propose(e()).then(c=>c&&l(c.id)),children:t})}const Hm=`${Se()}/knowledge`;async function hh(e,t){const r=await fetch(`${Hm}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),o=await r.json().catch(()=>({}));if(!r.ok)throw new Error(o.error??`HTTP ${r.status}`);return o}function Vw(e){const[t,r]=x.useState([]),[o,l]=x.useState({}),[c,d]=x.useState(!1),[f,g]=x.useState(),m=x.useCallback(()=>{fetch(Hm).then(y=>y.ok?y.json():null).then(y=>{y&&(r(y.entries),l(y.stale))}).catch(()=>{})},[]);x.useEffect(()=>(m(),pn(y=>y.startsWith("knowledge/")&&m())),[m]);const v=x.useMemo(()=>t.filter(y=>y.status==="suggested"||y.flag||o[y.id]&&y.status!=="outdated").length,[t,o]);return{entries:t,stale:o,briefText:e,attention:v,open:c,setOpen:d,error:f,call:(y,w)=>hh("/call",{id:y,call:w}).then(()=>(g(void 0),m(),!0),j=>(g(j.message),!1)),propose:y=>hh("/propose",y).then(w=>(m(),w.entry),w=>(g(w.message),void 0))}}function rc(e){const[t,r]=x.useState(!1),[o,l]=x.useState(""),c=async()=>{let d="";try{d=await navigator.clipboard.readText()}catch{r(!0);return}d.trim()?e.onToken(d,!0):r(!0)};return i.jsxs("div",{className:"sl-paste",children:[i.jsx(K,{variant:"primary",disabled:e.busy,onClick:()=>void c(),children:e.busy?"Checking…":"Paste"}),t?i.jsxs("form",{className:"sl-paste-field",onSubmit:d=>{d.preventDefault(),e.onToken(o,!0),l("")},children:[i.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,autoFocus:!0,value:o,placeholder:e.placeholder,"aria-label":"Token",onChange:d=>l(d.target.value)}),i.jsx(K,{type:"submit",disabled:e.busy||!o.trim(),children:"Save"})]}):i.jsx("button",{type:"button",className:"link",onClick:()=>r(!0),children:"Type it instead"})]})}const Gw=["awaiting","blocked","trail.done","resolved"],Qw=["commands","chat:write","im:write","channels:history","groups:history","im:history","mpim:history","users:read"],qw=["users:read.email"],Yw="save_decision",Jw=`/${ve.assistant.name.toLowerCase()}`;function Xw(e={}){const t=ve.assistant.name;return{display_information:{name:t,description:`${ve.name} decisions and agent questions`,background_color:"#1b2226"},features:{app_home:{home_tab_enabled:!0,messages_tab_enabled:!0,messages_tab_read_only_enabled:!1},bot_user:{display_name:t,always_online:!0},slash_commands:[{command:e.command??Jw,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:Yw,description:`Record this thread as a ${ve.name} decision`}]},oauth_config:{scopes:{bot:[...Qw,...qw]}},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 Zw={create:e=>`https://api.slack.com/apps?new_app=1&manifest_json=${encodeURIComponent(JSON.stringify(Xw({command:e})))}`,app:e=>`https://api.slack.com/apps/${e}/general`,install:e=>`https://api.slack.com/apps/${e}/install-on-team`,home:(e,t)=>`slack://app?team=${e}&id=${t}&tab=home`,homeWeb:(e,t)=>`https://slack.com/app_redirect?app=${t}&team=${e}`};function ej(e){const t=e.trim().match(/^xapp-\d+-(A[A-Z0-9]+)-/);return t==null?void 0:t[1]}async function es(e,t="GET",r){const o=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:r===void 0?void 0:JSON.stringify(r)}),l=await o.json().catch(()=>({}));if(!o.ok&&!l.status)throw new Error(l.error??`request failed (${o.status})`);return l}function tj(e){const t=`${e}/slack`;return{get:()=>es(t),created:()=>es(`${t}/created`,"POST",{}),token:r=>es(`${t}/token`,"POST",{token:r}),update:r=>es(`${t}/settings`,"PUT",r),resetOwner:()=>es(`${t}/owner/reset`,"POST",{}),members:()=>es(`${t}/members`).then(r=>r.members),remove:()=>es(t,"DELETE")}}const Bn=tj(Se());function nj(e){const[t,r]=x.useState(!1),[o,l]=x.useState(),c=d=>{r(!0),Bn.token(d).then(f=>{r(!1),l(f.ok?void 0:f.error),e.set(f.status)},f=>{r(!1),l(f.message)})};return i.jsxs(i.Fragment,{children:[i.jsx(rc,{busy:t,placeholder:"xapp-… or xoxb-…",onToken:c}),o&&i.jsxs("div",{className:"test-line alert",children:["✕ ",o]})]})}function sj({onRemoved:e}){const[t,r]=x.useState(!1);if(!t)return i.jsx(K,{size:"sm",variant:"ghost",onClick:()=>r(!0),children:"Remove"});const o=()=>void Bn.remove().then(l=>{r(!1),e(l)},()=>{});return i.jsxs(i.Fragment,{children:[i.jsx(K,{size:"sm",variant:"danger",onClick:o,children:"Remove tokens and settings"}),i.jsx(K,{size:"sm",variant:"ghost",onClick:()=>r(!1),children:"Keep"})]})}const ij={awaiting:"Awaiting you",blocked:"Blocked","trail.done":"Trail done",resolved:"Resolved"};function Wm({s:e}){const[t,r]=rj(e);return i.jsxs("div",{className:`sync-line ${t}`,title:e.error,children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:r})]})}function rj(e){switch(e.state){case"online":return["ok","Online"];case"connecting":return["","Connecting"];case"offline":return["warn","Offline · reconnecting"];case"auth-error":return["alert","Disconnected · Slack rejected the tokens"];case"elsewhere":{const t=e.heldBy?` (${e.heldBy})`:"";return["warn",`Connected from another ${ve.slug}${t}`]}case"unsupported":return["alert",e.error??"Not supported here"];default:return["",e.step==="done"?"Off":"Not connected"]}}function oj(e){const{s:t,setup:r}=e,o=t.step==="done";return i.jsxs(Ot,{className:lj(t,r),children:[i.jsxs("div",{className:"card-row",children:[i.jsx("b",{className:"choice-title t-row-title",children:"Your Scout app"}),o&&i.jsx(zn,{className:t.enabled?"on":"",children:t.enabled?"On":"Off"})]}),o&&i.jsx("div",{className:"c-loc",children:aj(t)}),o&&i.jsx(Wm,{s:t}),!o&&t.step===1&&!r&&i.jsx("p",{className:"sl-lead",children:"Answer agents and save threads as decisions from Slack. You create your own Scout app in your workspace; it runs from this machine and its tokens stay in your local credential store."}),i.jsxs("div",{className:"c-actions",children:[!o&&!r&&i.jsx(K,{size:"sm",variant:"primary",onClick:()=>e.onSetup(!0),children:t.step===1?"Connect":`Resume at step ${t.step}`}),o&&i.jsx(K,{size:"sm",on:t.enabled,onClick:e.onToggle,children:t.enabled?"Turn off":"Turn on"}),o&&t.state==="auth-error"&&i.jsx(K,{size:"sm",variant:"primary",onClick:()=>e.onSetup(!0),children:"Reconnect"}),t.step!==1&&i.jsx(sj,{onRemoved:e.onRemoved})]})]})}function aj(e){var r,o,l;const t=(o=(r=e.workspace)==null?void 0:r.url)==null?void 0:o.replace(/^https?:\/\/|\/$/g,"");return[(l=e.workspace)==null?void 0:l.name,t,e.setup.appId].filter(Boolean).join(" · ")}function lj(e,t){const r=e.step==="done";return`connector ${r&&e.enabled?"active":""} ${t||!r?"open":""}`}function cj(e){const[t,r]=x.useState(e.value==="dm"?"":e.value),o=/^[CG][A-Z0-9]{6,}$/.test(t.trim());return i.jsxs("form",{className:"sl-paste-field",onSubmit:l=>{l.preventDefault(),o&&e.onSave(t.trim())},children:[i.jsx("input",{value:t,spellCheck:!1,placeholder:"Channel ID, e.g. C0123ABCD","aria-label":"Channel ID",onChange:l=>r(l.target.value)}),i.jsx(K,{type:"submit",disabled:!o||t.trim()===e.value,children:"Save"})]})}function uj(e){const[t,r]=x.useState(),[o,l]=x.useState();x.useEffect(()=>{Bn.members().then(r,f=>l(f.message))},[]);const c=new Set(e.owners.map(f=>f.id)),d=new Set(e.value.map(f=>f.id));return o?i.jsxs("div",{className:"test-line alert",children:["✕ ",o]}):t?i.jsx("div",{className:"choice-row compact sl-members",children:t.map(f=>i.jsx(ht,{on:c.has(f.id)||d.has(f.id),disabled:c.has(f.id),title:`@${f.name??f.id}`,sub:c.has(f.id)?"Owner":void 0,onClick:()=>e.onChange(d.has(f.id)?e.value.filter(g=>g.id!==f.id):[...e.value,f])},f.id))}):i.jsx("span",{className:"t-meta",children:"Loading members…"})}function dj(e){const{s:t,patch:r}=e,[o,l]=x.useState(!1),c=new Set(t.notify.events),d=o||t.notify.target!=="dm",f=t.owners[0],g=m=>{const v=c.has(m)?t.notify.events.filter(y=>y!==m):[...t.notify.events,m];r({notify:{events:v}})};return i.jsxs("div",{className:"sl-groups",children:[i.jsxs("div",{className:"sl-group",children:[i.jsx(Je,{variant:"plain",size:"sm",children:"Owner"}),i.jsxs("div",{className:"sl-owner",children:[i.jsxs("b",{children:["@",(f==null?void 0:f.name)??(f==null?void 0:f.id)]}),(f==null?void 0:f.via)==="git-email"&&i.jsx("span",{className:"t-meta",children:"Matched your git email"}),i.jsx("button",{type:"button",className:"link",onClick:()=>void Bn.resetOwner().then(e.set,()=>{}),children:"Not you? Reset"})]})]}),i.jsxs("div",{className:"sl-group",children:[i.jsx(Je,{variant:"plain",size:"sm",children:"Allowed users"}),i.jsx(uj,{value:t.allow,owners:t.owners,onChange:m=>r({allow:m})})]}),i.jsxs("div",{className:"sl-group",children:[i.jsx(Je,{variant:"plain",size:"sm",children:"Notify"}),i.jsxs("div",{className:"choice-row compact",children:[i.jsx(ht,{on:!d,title:"DM to owner",onClick:()=>{l(!1),r({notify:{target:"dm",detail:"full"}})}}),i.jsx(ht,{on:d,title:"Channel",sub:t.notify.target!=="dm"?t.notify.target:void 0,onClick:()=>l(!0)})]}),d&&i.jsxs(i.Fragment,{children:[i.jsx(Ye,{label:"Channel ID (invite @Scout there first)",children:i.jsx(cj,{value:t.notify.target,onSave:m=>r({notify:{target:m}})})}),i.jsxs("div",{className:"choice-row compact",children:[i.jsx(ht,{on:t.notify.detail==="full",title:"Full questions",onClick:()=>r({notify:{detail:"full"}})}),i.jsx(ht,{on:t.notify.detail==="titles-only",title:"Titles only",onClick:()=>r({notify:{detail:"titles-only"}})})]})]}),i.jsx("div",{className:"choice-row compact",children:Gw.map(m=>i.jsx(ht,{on:c.has(m),title:ij[m],onClick:()=>g(m)},m))})]}),i.jsx(wo,{className:"dim",parts:[`${t.command} decide`,`${t.command} status`,`${t.command} inbox`,"Save as decision on any message"]})]})}function lo(e){return i.jsx("a",{className:`btn ${e.primary?"primary":""}`,href:e.href,target:"_blank",rel:"noreferrer",onClick:e.onClick,children:e.children})}function fj({s:e,n:t}){const r=hj(e,t);return r?i.jsx("span",{className:"t-meta",children:r}):null}function hj(e,t){var o;if(t===3)return e.setup.appId&&`app ${e.setup.appId}`;if(t===4)return e.workspace&&`${e.workspace.name} · @${((o=e.bot)==null?void 0:o.name)??"scout"}`;const r=e.owners[0];if(t===5&&r){const l=r.via==="git-email"?" · git email":"";return`owner ${r.name??r.id}${l}`}}const mh=[{n:1,title:"Create your app"},{n:2,title:"Workspace"},{n:3,title:"App token"},{n:4,title:"Install"},{n:5,title:"Claim"}],Tc=(e,t)=>e===t||e===2&&t===3,Km=(e,t)=>e==="done"||typeof e=="number"&&t<e&&!Tc(e,t);function ph(e,t){return Km(e,t)?"done":Tc(e,t)?"cur":""}const mj=/^(xapp-|xoxb-|xoxp-|xoxe)/,pj=typeof navigator<"u"&&/Mac|iP(hone|ad)/.test(navigator.platform)?"⌘V":"Ctrl+V";function gj(e){const t=x.useRef(e);t.current=e;const[r,o]=x.useState(!1);return x.useEffect(()=>{let l="";const c=(g,m)=>{const v=g.trim();return!mj.test(v)||!m&&v===l?!1:(l=v,t.current(v,m),!0)},d=g=>{var m;c(((m=g.clipboardData)==null?void 0:m.getData("text"))??"",!0)&&g.preventDefault()},f=async()=>{if(document.visibilityState==="visible")try{const g=await navigator.permissions.query({name:"clipboard-read"});o(g.state==="granted"),g.state==="granted"&&c(await navigator.clipboard.readText(),!1)}catch{}};return f(),document.addEventListener("paste",d),window.addEventListener("focus",f),document.addEventListener("visibilitychange",f),()=>{document.removeEventListener("paste",d),window.removeEventListener("focus",f),document.removeEventListener("visibilitychange",f)}},[]),r}function vj(e){var N;const{s:t,set:r}=e,[o,l]=x.useState(),[c,d]=x.useState(!1),[f,g]=x.useState(!1),m=(E,M)=>{const R=ej(E);M&&R&&!t.setup.botToken&&window.open(Zw.install(R),"_blank")&&g(!0),d(!0),Bn.token(E).catch(O=>({ok:!1,error:O.message,status:t})).then(O=>{d(!1),l(O),r(O.status)})},y=gj(m)?"come back to this tab":`press ${pj} here`,w=t.step,j=E=>{if(!o)return null;const M=!o.ok&&E===4==(w===4);return o.kind===(E===4?"bot":"app")||M?i.jsx("div",{className:`test-line ${o.ok?"ok":"alert"}`,children:kj(o)}):null},$={1:i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:["Create your app in Slack. It opens filled in from a manifest, so your app already has the ",t.command," command, Save as decision and Socket Mode."]}),i.jsx("div",{className:"sl-actions",children:i.jsx(lo,{primary:!0,href:t.links.create,onClick:()=>void Bn.created().then(r,()=>{}),children:"Create your Slack app"})})]}),2:i.jsxs("p",{children:["In Slack: pick your workspace → ",i.jsx("b",{children:"Next"})," → ",i.jsx("b",{children:"Create"}),". Your app lives in the workspace you pick."]}),3:i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:["Give your app a token so Scout can connect from this machine. On the page Slack just opened:"," ",i.jsx("b",{children:"App-Level Tokens"})," → ",i.jsx("b",{children:"Generate Token and Scopes"})," → name it ",i.jsx("code",{children:"teamtrail"})," → add"," ",i.jsx("code",{children:"connections:write"})," → ",i.jsx("b",{children:"Generate"})," → ",i.jsx("b",{children:"Copy"}),", then ",y,"."]}),i.jsx("div",{className:"sl-actions",children:i.jsx(rc,{busy:c,placeholder:"xapp-…",onToken:m})}),j(3),i.jsx(wo,{className:"dim",parts:["Waiting for the app-level token",t.links.create&&i.jsx("a",{href:t.links.create,target:"_blank",rel:"noreferrer",children:"Open the manifest again"},"again")]})]}),4:i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:["Install your app so Scout can post and DM you."," ",f?"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 ",y,"."]}),i.jsxs("div",{className:"sl-actions",children:[i.jsx(lo,{primary:!f,href:t.links.install,children:f?"Open install page again":"Install to workspace"}),i.jsx(rc,{busy:c,placeholder:"xoxb-…",onToken:m})]}),j(4)]}),5:i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:["Your git email doesn't match a member of ",((N=t.workspace)==null?void 0:N.name)??"the workspace",", so tell Scout who you are: open its Home tab in Slack and click ",i.jsx("b",{children:"This is me"}),". Scout sends you a DM, and questions from agents arrive there."]}),i.jsxs("div",{className:"sl-actions",children:[i.jsx(lo,{primary:!0,href:t.links.home,children:"Open Scout in Slack"}),t.links.homeWeb&&i.jsx(lo,{href:t.links.homeWeb,children:"Open in browser"})]}),i.jsx(Wm,{s:t})]})};return i.jsxs(Ot,{tone:"inset",className:"slack-setup",children:[i.jsxs("p",{className:"sl-own",children:["You create your own Scout app in your Slack workspace. It runs from this machine over Socket Mode; nothing goes through ",ve.name,". Prefer one click? Add to Slack is coming with ",ve.name," Cloud."]}),i.jsx("ol",{className:"pipeline sl-pipeline","aria-label":"Slack setup",children:mh.map(E=>i.jsxs("li",{className:ph(w,E.n),children:[i.jsx("i",{}),i.jsxs("span",{children:[E.n," ",E.title]})]},E.n))}),i.jsx("ol",{className:"sl-steps",children:mh.map(E=>{const M=Km(w,E.n),R=Tc(w,E.n);return i.jsxs("li",{className:ph(w,E.n),children:[i.jsxs("div",{className:"sl-step-h",children:[i.jsx("span",{className:"sl-n",children:M?"✓":E.n}),i.jsx("b",{children:E.title}),M&&i.jsx(fj,{s:t,n:E.n})]}),R&&i.jsx("div",{className:"sl-step-b",children:$[E.n]})]},E.n)})})]})}function kj(e){var t,r;return e.ok?e.kind==="app"?`✓ Socket Mode reachable · app ${e.status.setup.appId}`:`✓ Installed in ${(t=e.status.workspace)==null?void 0:t.name} as @${((r=e.status.bot)==null?void 0:r.name)??"scout"}`:`✕ ${e.error}`}function Ec(e=0){const[t,r]=x.useState(),o=x.useCallback(()=>Bn.get().then(r,()=>r(null)),[]);return x.useEffect(()=>{if(o(),!e)return;const l=setInterval(()=>void o(),e);return()=>clearInterval(l)},[o,e]),[t,r]}function yj(e){const[t,r]=Ec(3e3),[o,l]=x.useState(!1),c=x.useRef(null);if(x.useEffect(()=>{var g;e.focus&&t&&((g=c.current)==null||g.scrollIntoView({block:"start"}))},[e.focus,!!t]),!t)return null;const d=t.step==="done",f=g=>Bn.update(g).then(r,()=>{});return i.jsxs("div",{ref:c,className:"slack-settings",children:[i.jsx(oj,{s:t,setup:o,onSetup:l,onToggle:()=>void f({enabled:!t.enabled}),onRemoved:g=>{r(g),l(!1)}}),!d&&(o||t.step!==1)&&i.jsx(vj,{s:t,set:r}),o&&d&&t.state==="auth-error"&&i.jsxs(Ot,{tone:"inset",className:"slack-setup",children:[i.jsx("p",{children:"Generate a new app-level token or reinstall the app, then paste the new token. Settings and the owner are kept."}),i.jsx(nj,{set:r})]}),d&&i.jsx(dj,{s:t,set:r,patch:g=>void f(g)})]})}function xj(e){const{api:t,rt:r,brief:o}=e,{snap:l,actions:c}=t,[d]=Ec(15e3),f=Ks(),g=d!=null&&d.enabled&&d.state==="auth-error"?d.error??"Slack rejected the tokens":void 0;return i.jsx(zw,{repo:e.repo,snaps:t.allSnaps,map:l==null?void 0:l.map,activity:t.activity,health:t.health,onNewTrail:e.onNewTrail,trackerLabel:r.adapter.label.toLowerCase(),onSelectMap:c.selectMap,onToggleMode:()=>l&&c.setMode(l.map.mode==="plan-only"?"plan+execute":"plan-only"),onSettings:e.onSettings,onToggleTheme:e.onToggleTheme,attention:e.attention,slackAlert:g,onSlack:e.onSlack,decisions:t.decisions.length,decisionsOpen:e.decisionsOpen,onDecisions:e.onDecisions,onStats:e.onStats,knowledge:f.attention,knowledgeOpen:f.open,onKnowledge:()=>f.setOpen(!f.open),briefingOpen:o.shown,briefingStatus:o.status,onBriefing:()=>o.shown?o.dismiss():o.open()})}function wj(e){const{m:t}=e,r=t.from==="human"?"human":"agent";return i.jsxs("div",{className:`msg from-${t.from} voice-${r}`,children:[i.jsx(Q,{parts:[t.author,Bo(t.at)]}),i.jsx("div",{className:"msg-text",children:t.text}),e.stillOpen&&i.jsx("button",{className:"answer-this t-meta",onClick:e.onAnswerThis,children:"Answer this"})]})}function jj(e){const{ticket:t}=e;return i.jsxs("div",{className:"comms-ticket",children:[i.jsxs("div",{className:"t-title",title:t&&`${t.key} ${t.title}`,children:[i.jsx("span",{className:"key",children:t==null?void 0:t.key})," ",t==null?void 0:t.title]}),i.jsx(Q,{parts:[e.trail,e.agent]})]})}function Nj({id:e,text:t}){const[r,o]=x.useState(),l=r!==e;return i.jsx(_o,{size:1,framed:!1,state:l?"speaking":"alert",speaking:l?t.slice(0,60):void 0,onSpeakEnd:()=>o(e),className:"q-avatar"})}function Sj(e){const{q:t}=e;return i.jsxs("div",{className:"msg open-q",children:[i.jsx(Q,{parts:[t.agent,Bo(t.at)]}),i.jsx(Nj,{id:e.chatId??t.id,text:t.text}),i.jsx("div",{className:"msg-text",children:t.text})]})}function bj(e){var t;return(t=e.options)!=null&&t.length?i.jsx("div",{className:"suggest",children:e.options.map(r=>i.jsx("button",{className:"chip",onClick:()=>e.onPick(r),children:r},r))}):null}function Cj(e){const{activity:t,sessionId:r}=e,[o,l]=x.useState(""),[c,d]=x.useState(),f=x.useRef(null),g=x.useRef(null),m=t.sessions.find(O=>O.id===r),v=t.chats.filter(O=>O.sessionId===r),y=rw(t.pending,r,c??e.questionId),w=new Set(t.pending.filter(O=>O.sessionId===r).map(O=>O.id)),j=v.find(O=>!!y&&O.questionId===y.id),$=v.filter(O=>O!==j),N=m?e.snaps[m.mapId]:void 0,E=m!=null&&m.ticketId?N==null?void 0:N.tickets.find(O=>O.id===m.ticketId):void 0;x.useEffect(()=>{const O=f.current;O==null||O.scrollTo({top:O.scrollHeight,behavior:"smooth"})},[$.length,y==null?void 0:y.id]),x.useEffect(()=>{var O;y&&!e.onBack&&((O=g.current)==null||O.focus({preventScroll:!0}))},[y==null?void 0:y.id,e.onBack]);const M=O=>{!y||!O.trim()||(e.onAnswer(y.id,O.trim()),l(""))},R=$j(m,!!y);return i.jsxs("div",{className:`comms ${y?"asking":""}`,children:[i.jsx(Ct,{title:"HITL line",right:m?i.jsx("span",{className:`status ${y?"urgent":""}`,children:R}):void 0,children:e.onBack&&i.jsx("button",{className:"back",onClick:e.onBack,"aria-label":"Back to inbox",children:"‹ Inbox"})}),m?i.jsxs(i.Fragment,{children:[i.jsx(jj,{ticket:E,trail:N==null?void 0:N.map.title,agent:m.agent}),i.jsx("div",{className:"comms-log",ref:f,children:$.map(O=>i.jsx(wj,{m:O,stillOpen:!!O.questionId&&w.has(O.questionId),onAnswerThis:()=>d(O.questionId)},O.id))}),y&&i.jsx(Sj,{q:y,chatId:j==null?void 0:j.id}),i.jsx(bj,{options:y==null?void 0:y.suggestions,onPick:M}),i.jsx(Nc,{ref:g,className:"comms-input",value:o,onValueChange:l,onSubmit:M,disabled:!y,placeholder:y?"Answer":""})]}):i.jsx(Ee,{children:"No conversation"})]})}function $j(e,t){return e?t?"Your answer is needed":tn(e)?`${e.agent} is working…`:e.status==="done"?"Resolved · ticket closed":"Session ended":""}async function Tj(e){const[t,r]=e.ref.split("+"),o=await fetch(`${Se()}/workspaces/integration`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e.mapId,a:t,b:r})});return o.ok?void 0:(await o.json().catch(()=>({}))).error??`Adding failed (${o.status})`}function Ej({item:e}){const[t,r]=x.useState(!1),[o,l]=x.useState(),c=()=>{r(!0),l(void 0),Tj(e).then(l,d=>l(d.message)).finally(()=>r(!1))};return i.jsxs("div",{className:"att-action",children:[i.jsx(K,{size:"sm",className:"integration-add",disabled:t,onClick:c,children:t?"Adding…":"Add integration ticket"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}const Ij=/(\S*\/\S*|#\d+)/g;function Mj({reasons:e}){return e.length?i.jsx("span",{className:"reason-line",children:e.map((t,r)=>i.jsxs("span",{children:[r>0&&i.jsx("span",{className:"sep",children:" · "}),t.split(Ij).map((o,l)=>l%2===1?i.jsx("span",{className:"t-code",children:o},l):o)]},t))}):null}const Vm={question:"Question",approval:"Approve",blocked:"Blocked",flag:"PR / CI",stalled:"Stalled","hitl-ready":"Needs you",knowledge:"Field guide",brief:"Brief",policy:"Risk",reroute:"Reroute","reroute-suggested":"Reroute?",overlap:"Overlap",integration:"Integrate",guide:"Guide","guide-checks":"Approve",model:"Model"},Aj={question:"questions",approval:"approvals",blocked:"blocked tickets",flag:"PR / CI flags",stalled:"stalled claims","hitl-ready":"tickets for you",knowledge:"field guide entries",brief:"briefs",policy:"risky changes",reroute:"reroutes","reroute-suggested":"suggested reroutes",overlap:"overlapping claims",integration:"clashing branches",guide:"guides to approve","guide-checks":"guide checks to approve",model:"tickets waiting for a model"},Lj=[{minutes:30,label:"30 min"},{minutes:120,label:"2 hours"},{minutes:1440,label:"Tomorrow"}],Rj=["blocked","flag","stalled","policy","reroute","overlap","integration","model"];function Gm(e,t){return t||e.urgency==="blocking"?"urgent":Rj.includes(e.kind)?"attention":"neutral"}const Oj=[/^marked blocking$/,/^fyi\b/,/^soon\b/,/^waiting \d/,/^answer together/,/questions from /];function Qm(e){return e.reasons.filter(t=>!Oj.some(r=>r.test(t)))}function Pj(e){const{item:t,snap:r}=e,o=r==null?void 0:r.tickets.find(f=>f.id===t.ticketId),l=t.kind==="question"&&t.agent?`${t.agent} asks`:Vm[t.kind],c=[];t.urgency==="blocking"&&c.push({text:"Blocking",urgent:!0,className:"urgency-tag"}),c.push({text:l,strong:!0});const d=o&&_j(t.title,o);return d&&c.push(d),e.otherTrail&&c.push((r==null?void 0:r.map.title)??t.mapId),c}function _j(e,t){if(!e.includes(t.key))return e.includes(t.title)?{text:t.key,code:!0}:`${t.key} ${t.title}`}function Dj(e){const[t,r]=x.useState(!1),o=l=>{r(!1),l()};return i.jsxs("span",{className:"snooze",children:[i.jsx("button",{type:"button",className:"snooze-btn","aria-expanded":t,"aria-label":`Later: ${e.title}`,onClick:()=>r(!t),children:"Later"}),t&&i.jsxs("span",{className:"snooze-menu",role:"menu",children:[Lj.map(l=>i.jsx("button",{type:"button",role:"menuitem",onClick:()=>o(()=>e.onSnooze(l.minutes)),children:l.label},l.minutes)),e.canDismiss&&i.jsx("button",{type:"button",role:"menuitem",onClick:()=>o(e.onDismiss),children:"Set aside"})]})]})}const Bj=15e3;function zj(e){const{item:t}=e,r=t.title.split(`
|
|
124
|
-
`)[0],o=Qm(t),l=e.now-t.since<Bj;return i.jsx(Ae,{as:"li",className:`att-item k-${t.kind} u-${t.urgency} ${e.selected?"sel":""} ${l?"incoming":""}`,edge:Gm(t,e.interrupting),selected:e.selected,title:r,titleText:t.title,context:i.jsx(
|
|
125
|
-
`),trailing:nn(e.now-t.since),onOpen:e.onOpen,actions:i.jsx(Dj,{title:t.title,canDismiss:Oy(t),onSnooze:e.onSnooze,onDismiss:e.onDismiss}),below:t.kind==="integration"&&i.jsx(Ej,{item:t})})}function Fj(e){const t=[];for(const r of e){const o=t.at(-1);(o==null?void 0:o.key)===r.batchKey?o.items.push(r):t.push({key:r.batchKey,kind:r.kind,mapId:r.mapId,items:[r]})}return t}const Uj={question:"inbox-list",approval:"inbox-list approvals"};function Hj(e){const{batch:t}=e,r=t.items.length>1,o=t.kind==="question"?"answer together":"review together",l=[`${t.items.length} ${Aj[t.kind]}`,e.trail,o].filter(Boolean);return i.jsxs("div",{className:`att-batch ${r?"many":""}`,children:[r&&i.jsx("span",{className:"batch-head t-label",children:l.join(" · ")}),i.jsx("ul",{className:`att-list ${Uj[t.kind]??""}`,children:e.children})]})}function Wj(e,t){e.ticketId?t.openTicket(e.mapId,e.ticketId):t.selectTrail(e.mapId)}function qm(e,t){switch(e.kind){case"question":return t.openQuestion(e.ref);case"approval":case"blocked":case"policy":case"flag":case"stalled":case"hitl-ready":case"overlap":case"integration":case"model":return Wj(e,t);case"knowledge":return t.openKnowledge();case"brief":return t.openBrief(e.mapId);case"reroute":case"reroute-suggested":return t.openReroute(e);case"guide":case"guide-checks":return t.openGuides();default:return e.kind}}function Kj(e){const t=sn(1e3),{view:r}=e;if(!r.items.length)return i.jsx(Dn,{title:"Nothing waiting on you",hint:r.hidden?`${r.hidden} snoozed or set aside. They come back when the snooze ends.`:"When an agent needs your call, it lands here, most important first."});const o=Object.keys(e.snaps).length>1,l=f=>o&&f!==e.currentMapId,c=new Set(r.interrupting),d=f=>{var g;return(g=e.pending.find(m=>m.id===f))==null?void 0:g.sessionId};return i.jsx("div",{className:"attention-queue",children:Fj(r.items).map(f=>{var g;return i.jsx(Hj,{batch:f,trail:l(f.mapId)?(g=e.snaps[f.mapId])==null?void 0:g.map.title:void 0,children:f.items.map(m=>i.jsx(zj,{item:m,snap:e.snaps[m.mapId],otherTrail:l(m.mapId)&&f.items.length<2,selected:m.kind==="question"&&d(m.ref)===e.selected,interrupting:c.has(m.id),now:t,onOpen:()=>qm(m,e.handlers),onSnooze:v=>e.onSnooze(m.id,v),onDismiss:()=>e.onDismiss(m.id)},m.id))},f.key)})})}const gh={label:"Focus for 1 hour",change:{kind:"for",minutes:60}};function Vj(e){switch(e.kind){case"manual":case"hours":return[{label:"End focus now",change:{kind:"end"},primary:!0}];case"paused":return[{label:"Resume quiet hours",change:{kind:"resume"},primary:!0},gh];case"off":return[{...gh,primary:!0},{label:"Focus for 3 hours",change:{kind:"for",minutes:180}}];default:return e}}const vh=e=>Bo(e).slice(0,5),Gj=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function Qj(e){const t=`${e.items.length} waiting on you`;return e.heldBack===0?`Nothing held back · ${t}`:`${Gj(e.heldBack,"item")} would interrupt you · ${t}`}function Wl(e){const t=e.prefs.focus;return t?`Quiet hours ${t.from}–${t.to}`:"No quiet hours set"}const kh=e=>`Items scoring ${e.policy.value.interrupt} or more interrupt you · ${e.items.length} waiting on you`;function qj(e){const t=e.focus;switch(t.kind){case"manual":case"hours":{const r=vh(t.until),o=t.kind==="manual"?"Switched on here":Wl(e);return{word:"on",until:r,on:!0,title:`Focus is on until ${r}`,reason:o,detail:Qj(e)}}case"paused":{const r=vh(t.until),o=`Quiet hours paused until ${r}`;return{word:"paused",until:r,on:!1,title:o,reason:Wl(e),detail:kh(e)}}case"off":return{word:"off",until:"",on:!1,title:"Focus is off",reason:Wl(e),detail:kh(e)};default:return t}}const Yj="Focus holds back interruptions: no browser notifications or Slack messages, even for urgent items. Nothing is answered or dropped: everything still waits in Waiting on you and the Slack digest. Quiet hours turn it on every day; you can also focus for a while or end it early. This stays on this machine.";function Jj(e){const{view:t}=e,r=qj(t),o=t.focus.kind,l=i.jsxs("span",{className:We("focus-state",`focus-${o}`),children:[i.jsx("i",{className:"focus-dot","aria-hidden":"true"}),i.jsxs("span",{className:"focus-label",children:["Focus",i.jsxs("span",{className:"focus-word",children:[" ",r.word]})]}),r.until&&i.jsxs("span",{className:"focus-until",children:[i.jsx("span",{className:"sep",children:" · "}),i.jsx("span",{className:"focus-until-word",children:"until "}),r.until]})]});return i.jsx(Fm,{className:"focus-menu",label:l,role:"dialog",tip:r.title,ariaLabel:r.title,children:c=>i.jsxs("div",{className:"focus-panel","aria-label":"Focus",children:[i.jsxs("div",{className:"focus-panel-head",children:[i.jsx("span",{className:"t-row-title",children:r.title}),i.jsx(Us,{text:Yj})]}),i.jsx(
|
|
126
|
-
`)[0];return i.jsx(Ae,{as:"li",className:r.sessionId===e.selected?"sel":void 0,edge:r.urgency==="blocking"?"urgent":"neutral",selected:r.sessionId===e.selected,title:d,titleText:r.text,context:i.jsx(Q,{parts:[r.urgency==="blocking"&&{text:"Blocking",urgent:!0},`${r.agent} asks`,l&&{text:l.key,code:!0},l==null?void 0:l.title,c]}),trailing:nn(t-r.at),onOpen:()=>e.onOpen(r.sessionId,r.ticketId)},r.id)})}):i.jsx(Dn,{title:"Nothing waiting on you",hint:"When an agent needs your call, its question lands here."})}const r0={pass:"Passed",fail:"Failed",error:"Could not run",interrupted:"Interrupted"},Ui={off:"Off",checks:"Checks","checks+review":"Checks + review","checks+review+human":"Checks + review + you"},Xm={off:"The agent saying “done” closes the ticket right away.",checks:"Your checks (tests, lint, typecheck…) run in the repo first. A failure goes back to the agent with the output.","checks+review":"After the checks pass, a different agent reviews the change. It is never the agent that did the work.","checks+review+human":"After checks and review, you approve it in the inbox before the ticket closes."},o0=e=>e.exitCode===0&&!e.timedOut&&!e.error;async function wh(e){const t=await e.json().catch(()=>({}));if(!e.ok)throw new Error(t.error??`HTTP ${e.status}`);return t}const co=`${Se()}/verification`,Gi={ticket:(e,t)=>fetch(`${co}/ticket?mapId=${encodeURIComponent(e)}&ticketId=${encodeURIComponent(t)}`).then(r=>r.ok?r.json():void 0,()=>{}),inbox:()=>fetch(`${co}/inbox`).then(e=>e.ok?e.json().then(t=>t.items):[],()=>[]),log:e=>fetch(`${co}/log?path=${encodeURIComponent(e)}`).then(t=>wh(t)),act:e=>fetch(`${co}/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(t=>wh(t))};function a0(e){const[t,r]=x.useState([]),o=Object.values(e).map(l=>l.tickets.map(c=>`${c.id}:${c.state}:${c.status??""}`).join()).join("|");return x.useEffect(()=>{let l=!0;const c=()=>void Gi.inbox().then(f=>l&&r(f));c();const d=Bs.onEvidence(c);return()=>{l=!1,d()}},[o]),t}function l0(e,t){return{...e,items:e.items.filter(r=>!(r.kind==="brief"&&r.mapId===t))}}function c0(e){var f;const t=[...e.activity.pending].sort((g,m)=>g.at-m.at),r=a0(e.snaps),o=(f=e.attention)==null?void 0:f.view,l=o&&e.briefShown?l0(o,e.currentMapId):o,c=l?l.items.length:t.length+r.length,d=i.jsx(Ct,{hot:c>0,title:i.jsxs(i.Fragment,{children:[c>0&&i.jsx(Ws,{variant:"alert",size:12}),"Waiting on you"]}),count:i.jsx(ts,{n:c,urgent:c>0,pop:!0},c)});return l&&e.attention&&e.handlers?i.jsxs("div",{className:"inbox-part",children:[d,i.jsx(xh,{activity:e.activity}),i.jsx(Kj,{view:l,snaps:e.snaps,pending:e.activity.pending,currentMapId:e.currentMapId,selected:e.sessionId,handlers:e.handlers,onSnooze:e.attention.snooze,onDismiss:e.attention.dismiss})]}):i.jsxs("div",{className:"inbox-part",children:[d,i.jsx(xh,{activity:e.activity}),i.jsx(s0,{items:r,snaps:e.snaps,currentMapId:e.currentMapId,onOpen:e.onOpenTicket}),(t.length>0||!r.length)&&i.jsx(i0,{items:t,snaps:e.snaps,currentMapId:e.currentMapId,selected:e.sessionId,onOpen:e.onOpenQuestion})]})}function u0(e){const[t,r]=x.useState("list"),[o,l]=x.useState();x.useEffect(()=>{e.convRequest&&r("conv")},[e.convRequest]);const c=(v,y)=>{e.onOpen(v,y),r("conv")},d=v=>{const y=e.activity.pending.find(w=>w.id===v);y&&(l(y.id),c(y.sessionId,y.ticketId))},f=i.jsx(c0,{activity:e.activity,snaps:e.snaps,currentMapId:e.currentMapId,sessionId:e.sessionId,attention:e.attention,handlers:e.handlers&&{...e.handlers,openQuestion:d},briefShown:!!e.above,onOpenQuestion:c,onOpenTicket:e.onOpenTicket}),g=i.jsx(Cj,{activity:e.activity,snaps:e.snaps,sessionId:e.sessionId,questionId:o,onAnswer:e.onAnswer,onBack:e.layout==="stack"?()=>r("list"):void 0});if(e.layout==="stack")return i.jsx(Ke,{className:"zone inbox stack",children:t==="conv"&&e.sessionId?g:i.jsxs("div",{className:"stack-scroll",children:[e.above,f,e.below]})});const m=!!e.activity.sessions.find(v=>v.id===e.sessionId);return i.jsxs(Ke,{className:`zone inbox split ${m?"has-conv":""}`,style:{gridArea:"inbox"},children:[i.jsx(Ct,{className:"zone-title",icon:"mailbox",title:"Communication",info:"Where your agents reach you: everything waiting on you, ranked with the reasons why, the conversation with the agent that asked, and the tickets coming up next."}),e.above,f,m&&g,e.below]})}function d0(e){var f;const{snap:t}=e,r=t?Fs(t.tickets,t.map.mode):new Map,o={claimed:0,frontier:1},l=((t==null?void 0:t.tickets)??[]).filter(g=>o[r.get(g.id)]!==void 0).sort((g,m)=>o[r.get(g.id)]-o[r.get(m.id)]),c=new Set(e.sessions.filter(_m).map(g=>g.ticketId)),d=((f=e.selection)==null?void 0:f.kind)==="ticket"?e.selection.id:void 0;return i.jsxs("div",{className:"upnext",children:[i.jsx(Ct,{title:"Up next",count:i.jsx("span",{className:"n mono-label",children:l.length})}),!t&&i.jsx(Ee,{children:"Ready tickets show here"}),t&&!l.length&&i.jsx(Ee,{children:"Nothing ready"}),t&&l.length>0&&i.jsx("ul",{className:"ticket-list",children:l.map(g=>{const v={state:r.get(g.id),waiting:c.has(g.id),assignee:g.assignee,hitl:Wi(g)==="hitl"},y=f0(v);return i.jsx("li",{className:`${d===g.id?"sel":""} st-${h0(v)}`,children:i.jsxs("button",{onClick:()=>e.onSelect({kind:"ticket",id:g.id}),children:[i.jsx("i",{className:"dot"}),i.jsx("span",{className:"key t-code",children:g.key}),i.jsx("span",{className:"ttl t-body",children:g.title}),i.jsx("span",{className:"st-text t-meta",children:y})]})},g.id)})})]})}function f0(e){if(e.waiting)return"waiting on you";if(e.state==="claimed")return e.assignee??"claimed";const t=Am[e.state].toLowerCase();return e.hitl?`${t}, needs you`:t}function h0(e){return e.waiting?"waiting":e.state==="frontier"&&e.hitl?"attention":e.state}function m0(e){const{api:t,nav:r}=e;return i.jsx(u0,{activity:t.activity,snaps:t.allSnaps,currentMapId:t.mapId,sessionId:t.chatSession,layout:e.bp==="mobile"?"stack":"split",convRequest:r.convRequest,onOpen:r.openChat,onAnswer:t.actions.answer,onOpenTicket:r.openTicket,attention:e.attn.attention,handlers:e.attn.handlers,below:i.jsx(d0,{snap:t.snap,sessions:e.scoped.sessions,selection:t.selection,onSelect:r.select}),above:e.above})}function jo({command:e,label:t="Copy"}){const[r,o]=x.useState(!1);return i.jsxs("span",{className:"agent-cmd",children:[i.jsx("code",{children:e}),i.jsx("button",{type:"button",className:"btn sm","data-tip":"Copy, then paste it in Claude Code or Codex",onClick:()=>void navigator.clipboard.writeText(e).then(()=>{o(!0),setTimeout(()=>o(!1),1500)}),children:r?"Copied":t})]})}const uo=[{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"}],p0=9e3;function g0(){const[e,t]=x.useState(0),[r,o]=x.useState(!1);x.useEffect(()=>{if(r)return;const c=setInterval(()=>t(d=>(d+1)%uo.length),p0);return()=>clearInterval(c)},[r]);const l=uo[e];return i.jsxs("div",{className:"command-bar real",children:[i.jsx(Dm,{name:"map"}),i.jsx(Je,{as:"h2",className:"zone-title-label",children:"Trail map"}),i.jsx(Us,{text:"Every decision ticket in this trail and what blocks what. Click a ticket to see it in Trail step. The strip below sums up progress."}),i.jsxs("div",{className:"hint",onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),onFocus:()=>o(!0),onBlur:()=>o(!1),children:[i.jsx("span",{className:"dim",children:l.text}),l.command&&i.jsx(jo,{command:l.command})]},e),i.jsxs("button",{type:"button",className:"link hint-next","data-tip":"Next hint","aria-label":"Next hint",onClick:()=>t(c=>(c+1)%uo.length),children:[e+1,"/",uo.length," ›"]})]})}function v0(e){const t=[{v:"plan+execute",title:"Plan + execute"},{v:"plan-only",title:"Plan only"}];return i.jsx("div",{className:"choice-row",children:t.map(r=>i.jsx(ht,{on:e.value===r.v,title:r.title,onClick:()=>e.onChange(r.v)},r.v))})}function k0({onClose:e,tracker:t,onCreate:r}){const[o,l]=x.useState(),[c,d]=x.useState(!1),[f,g]=x.useState(),[m,v]=x.useState(""),[y,w]=x.useState(""),[j,$]=x.useState(""),[N,E]=x.useState(""),M=[m.trim(),y.trim(),j.trim()].filter(Boolean).join(". ").replace(/"/g,"'");return x.useEffect(()=>{const R=O=>O.key==="Escape"&&e();return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[e]),i.jsx("div",{className:"scrim",onClick:e,children:i.jsxs(Ke,{as:"div",className:"dialog",onClick:R=>R.stopPropagation(),children:[i.jsx("header",{children:i.jsx("h2",{className:"t-heading caps",children:"New trail"})}),i.jsx(Ye,{label:"Title",children:i.jsx("input",{value:m,onChange:R=>v(R.target.value),autoFocus:!0})}),i.jsx(Ye,{label:"Destination",children:i.jsx("textarea",{rows:3,value:y,onChange:R=>w(R.target.value),placeholder:"What is true when this trail is done?"})}),i.jsx(Ye,{label:"Notes",children:i.jsx("textarea",{rows:2,value:j,onChange:R=>$(R.target.value)})}),i.jsx(Ye,{label:"Assumptions (optional, one per line)",children:i.jsx("textarea",{className:"new-trail-assumptions",rows:2,value:N,onChange:R=>E(R.target.value),placeholder:"What the plan takes for granted, e.g. The v2 API supports batch writes"})}),i.jsxs("div",{className:"agent-draft",children:[i.jsxs("span",{className:"dim",children:["Paste this in Claude Code or Codex. Scout frames the trail with you there, then charts it here in ",t,"."]}),i.jsx(jo,{command:`/scout new "${M||"your idea"}"`,label:"Copy command"})]}),o?i.jsxs("div",{className:"agent-draft created",children:[i.jsxs("span",{children:["Trail ",o," is on the map, starting with discovery. To get it moving, run this in Claude Code or Codex:"]}),i.jsx(jo,{command:"/scout resume",label:"Copy command"})]}):f&&i.jsx("p",{className:"vf-err",children:f}),i.jsxs("footer",{children:[i.jsx(K,{variant:"ghost",onClick:e,children:"Close"}),!o&&i.jsx(K,{variant:"primary",disabled:c||!m.trim()||!y.trim(),"data-tip":"Put the trail on the map now; any agent picks it up with /scout resume",onClick:()=>{d(!0);const R=N.split(`
|
|
127
|
-
`).map(O=>O.trim());r({title:m.trim(),destination:y.trim(),notes:j.trim(),assumptions:R.filter(Boolean)}).then(O=>l(O.key)).catch(O=>g(O.message)).finally(()=>d(!1))},children:"Create trail"})]})]})})}const jh=["Ready when you are","What's the next big idea?","I keep the party on the trail","Describe it, I frame it"],y0=5e3;function x0(){const e=bc(),[t,r]=x.useState(0),[o,l]=x.useState(!0);return x.useEffect(()=>{if(o)return;const c=setTimeout(()=>{r(d=>(d+1)%jh.length),l(!0)},y0);return()=>clearTimeout(c)},[o]),i.jsxs("div",{className:"floating-scout","aria-hidden":"true",children:[i.jsx(_o,{variant:e?"night":"crt",size:3,framed:!1,speaking:o?jh[t]:void 0,onSpeakEnd:()=>l(!1),className:"fm-avatar"}),i.jsx("span",{className:"fm-shadow"})]})}function w0(e){return i.jsx(k0,{onClose:e.onClose,tracker:e.rt.adapter.label,onCreate:async t=>{const r=await Gx(e.rt.adapter,t);return e.onCreated(r.id),r}})}const j0={gh:"your gh login",GITHUB_TOKEN:"GITHUB_TOKEN",GH_TOKEN:"GH_TOKEN",stored:"a saved token","signed-in":"your GitHub sign-in",LINEAR_API_KEY:"LINEAR_API_KEY"},Ic=e=>j0[e];function Mc(e){var t;return((t=e.account)==null?void 0:t.kind)==="user"?e.account.login:void 0}const Kl=e=>!!e.auth&&!!Mc(e);function Zm(e,t){const r=Mc(e);return!e.auth||!r?void 0:`Will use ${t||"the repo you pick"} as ${r} (${Ic(e.auth)})`}function N0(e){if(!e.repo)return;const t=Mc(e),r=t?` as ${t}`:"",o=e.auth?`, using ${Ic(e.auth)}`:"";return`Connected to ${e.repo}${r}${o}`}function S0(e,t){if(!e.pushedAt)return;const r=Math.floor((t-Date.parse(e.pushedAt))/864e5);return r<1?"Pushed today":r<60?`Pushed ${r}d ago`:`Pushed ${Math.floor(r/30)}mo ago`}function b0(e){const{gh:t}=e;if(!t.auth)return null;const r=Zm(t,e.repo);return i.jsxs("div",{className:"gh-identity",children:[r&&i.jsx("span",{className:"t-body",children:r}),i.jsxs("span",{className:"gh-identity-actions",children:[i.jsx("button",{type:"button",className:"btn ghost sm",onClick:e.onUseAnother,children:"Use another token"}),t.auth==="signed-in"&&i.jsx("button",{type:"button",className:"btn ghost sm",onClick:e.onSignOut,children:"Sign out"})]})]})}const C0=/^[\w.-]+\/[\w.-]+$/;function $0(e){const t=e.query.trim().toLowerCase(),o=!!e.detected&&e.repos.every(g=>g.fullName!==e.detected)?[{fullName:e.detected,private:!1},...e.repos]:e.repos,l=[...o.filter(g=>g.fullName===e.detected),...o.filter(g=>g.fullName!==e.detected)],c=t?l.filter(g=>g.fullName.toLowerCase().includes(t)):l,f=C0.test(e.query.trim())&&c.every(g=>g.fullName.toLowerCase()!==t)?e.query.trim():void 0;return{shown:c.slice(0,e.limit),matches:c.length,typed:f}}function Nh(e){const{repo:t,listed:r}=e,o=t.private?"Private":"Public";return i.jsx(Ae,{as:"li",className:"repo-row",selected:e.selected,title:i.jsx("span",{className:"t-code",children:t.fullName}),context:i.jsx(Q,{parts:[e.detected&&{text:"This project's repo",strong:!0},r&&o,r&&S0(t,e.now),!r&&"Checked when you connect"]}),onOpen:e.onPick})}const T0=40;function Sh(e){const[t,r]=x.useState(""),o=x.useMemo(()=>Date.now(),[]),l=x.useMemo(()=>new Set(e.repos.map(v=>v.fullName)),[e.repos]),{shown:c,matches:d,typed:f}=$0({repos:e.repos,detected:e.detected,query:t,limit:T0}),g=d>c.length?`${d-c.length} more: type to narrow`:"",m=e.truncated?`Your ${e.repos.length} most recently pushed repos`:"";return i.jsxs("div",{className:"repo-picker",children:[i.jsxs("label",{className:"field",children:["Repository",i.jsx("input",{value:t,placeholder:"Search your repos, or type owner/name",spellCheck:!1,"aria-label":"Search repositories",onChange:v=>r(v.target.value)})]}),i.jsxs("ul",{className:"repo-list","aria-label":"Repositories",children:[f&&i.jsx(Nh,{repo:{fullName:f,private:!1},detected:f===e.detected,listed:!1,selected:f===e.value,now:o,onPick:()=>e.onChange(f)}),c.map(v=>i.jsx(Nh,{repo:v,detected:v.fullName===e.detected,listed:l.has(v.fullName),selected:v.fullName===e.value,now:o,onPick:()=>e.onChange(v.fullName)},v.fullName))]}),i.jsx(Q,{parts:[!d&&!f&&"No repo matches",g,m]})]})}function E0(e){const{list:t}=e;if(!t)return i.jsx(Hs,{label:"Loading your repos…",rows:3,className:"picker-loading"});switch(t.kind){case"ok":return i.jsx(Sh,{repos:t.repos,truncated:t.truncated,detected:t.detectedRepo??e.detected,value:e.value,onChange:e.onChange});case"no-token":return i.jsx(Q,{parts:["No GitHub token found"]});case"error":return i.jsxs(i.Fragment,{children:[i.jsx(Sc,{what:"Couldn't list your repos",reason:t.error,onRetry:e.onRetry}),i.jsx(Sh,{repos:[],truncated:!1,detected:e.detected,value:e.value,onChange:e.onChange})]});default:return t}}const I0={stored:"Saved token",gh:"gh CLI",GITHUB_TOKEN:"$GITHUB_TOKEN",GH_TOKEN:"$GH_TOKEN","signed-in":"Signed in with GitHub",LINEAR_API_KEY:"$LINEAR_API_KEY"},_i=e=>e==="github"||e==="linear";function ep(e){const[t,r]=x.useState(!e.source);return e.source&&!t?i.jsxs("div",{className:"ts-auth",children:[i.jsx("span",{className:"mono-label",children:e.label}),i.jsx("span",{className:"pill on",children:I0[e.source]}),i.jsx("button",{type:"button",className:"btn ghost sm",onClick:()=>r(!0),children:"Use another"})]}):i.jsxs("label",{className:"field",children:[i.jsxs("span",{className:"ts-label",children:[e.label,e.link&&i.jsx("a",{href:e.link.href,target:"_blank",rel:"noreferrer",children:e.link.text})]}),i.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,value:e.value,placeholder:e.placeholder,onChange:o=>e.onChange(o.target.value)})]})}function M0(e){const[t,r]=x.useState(!1),o=()=>{var l;return void((l=navigator.clipboard)==null?void 0:l.writeText(e.code).then(()=>r(!0),()=>{}))};return i.jsxs("div",{className:"gh-device",children:[i.jsx("span",{className:"t-label",children:"Enter this code on GitHub"}),i.jsxs("div",{className:"gh-device-row",children:[i.jsx("code",{className:"gh-device-code t-code","aria-label":"Your code",children:e.code}),i.jsx(K,{size:"sm",variant:"ghost",onClick:o,children:t?"Copied":"Copy"})]}),i.jsxs("div",{className:"gh-device-row",children:[i.jsx("a",{className:"btn primary",href:e.href,target:"_blank",rel:"noreferrer",onClick:o,children:"Open GitHub"}),i.jsx(K,{size:"sm",variant:"ghost",onClick:e.onCancel,children:"Cancel"})]}),i.jsx(Hs,{label:"Waiting for you to approve on GitHub…"})]})}function A0(e){switch(e.kind){case"code":return{kind:"code",userCode:e.userCode,verificationUri:e.verificationUri,interval:e.interval,asked:0};case"unavailable":return{kind:"ended",reason:"Sign in with GitHub isn’t set up in this build"};case"error":return{kind:"ended",reason:e.error};default:return e}}function L0(e,t){switch(t.kind){case"waiting":return{...e,interval:t.interval,asked:e.asked+1};case"signed-in":return{kind:"idle"};case"expired":return{kind:"ended",reason:"The code expired before it was approved"};case"denied":return{kind:"ended",reason:"The sign-in was declined on GitHub"};case"none":return{kind:"ended",reason:"The sign-in was stopped"};case"error":return{kind:"ended",reason:t.error};default:return t}}const Rt=rx(Se());function Di(e,t){e({tracker:t});const r=new URL(location.href);r.searchParams.delete("tracker"),location.href=r.toString()}function R0(e){const[t,r]=x.useState({kind:"idle"}),o=x.useRef(e);o.current=e;const l=t.kind==="code";return x.useEffect(()=>{if(t.kind!=="code")return;let c=!0;const d=setTimeout(()=>void Rt.githubSignIn.poll().then(async f=>{c&&(f.kind==="signed-in"&&await o.current(),c&&r(L0(t,f)))},f=>c&&r({kind:"ended",reason:f.message})),Math.max(t.interval,1)*1e3);return()=>{c=!1,clearTimeout(d)}},[t]),x.useEffect(()=>{if(l)return()=>void Rt.githubSignIn.cancel().catch(()=>{})},[l]),{state:t,start(){r({kind:"starting"}),Rt.githubSignIn.start().then(c=>r(A0(c)),c=>r({kind:"ended",reason:c.message}))},cancel(){r({kind:"idle"})}}}function O0(e){const{state:t,start:r,cancel:o}=R0(e.onSignedIn);switch(t.kind){case"idle":return i.jsxs("div",{className:"gh-sign-in",children:[i.jsx(K,{variant:"primary",onClick:r,children:"Sign in with GitHub"}),i.jsx(Q,{parts:["No gh login or token needed","the token stays on this machine"]})]});case"starting":return i.jsx(Hs,{label:"Asking GitHub for a code…"});case"code":return i.jsx(M0,{code:t.userCode,href:t.verificationUri,onCancel:o});case"ended":return i.jsxs("div",{className:"gh-sign-in",children:[i.jsx(K,{onClick:r,children:"Try again"}),i.jsx(Q,{parts:["Didn't sign in",t.reason]})]});default:return t}}function P0(e){var d,f;const{gh:t}=e,r=t.auth&&((d=t.account)==null?void 0:d.kind)==="unknown"?`Found ${Ic(t.auth)}, but GitHub didn't accept it`:"",o=((f=t.account)==null?void 0:f.kind)==="unknown"?t.account.error:"",l=t.auth==="GITHUB_TOKEN"||t.auth==="GH_TOKEN",c=t.signIn.available&&!l;return i.jsxs(i.Fragment,{children:[r&&i.jsx(Q,{parts:[r,o]}),c&&i.jsx(O0,{onSignedIn:e.onSignedIn}),c&&i.jsx("span",{className:"t-label gh-or",children:"Or paste a token"}),i.jsx(ep,{source:null,value:e.token,onChange:e.onToken,label:"Token",placeholder:"ghp_… or github_pat_…",link:{href:"https://github.com/settings/personal-access-tokens/new",text:"New token"}}),i.jsxs("span",{className:"t-meta",children:["Or run ",i.jsx("code",{className:"t-code",children:"gh auth login"})," in a terminal; this finds it in a few seconds."]}),i.jsxs("label",{className:"field",children:["Repository",i.jsx("input",{value:e.repo,placeholder:"owner/name",spellCheck:!1,onChange:g=>e.onRepo(g.target.value.trim())})]})]})}function tp({r:e}){var o,l;if(!e)return null;if(!e.ok)return i.jsxs("div",{className:"test-line alert",children:["✕ ",e.error]});const t=(o=e.rate)!=null&&o.limit?`${(l=e.rate.remaining)==null?void 0:l.toLocaleString()}/${e.rate.limit.toLocaleString()} req`:"";let r="";return e.canWrite===!1?r="read-only":e.canWrite&&(r="read/write"),i.jsxs("div",{className:"test-line ok",children:["✓ ",[e.account,e.target,r,t].filter(Boolean).join(" · ")]})}function Ac(e){const[t,r]=x.useState(),[o,l]=x.useState(0);x.useEffect(()=>{if(r(void 0),!e.enabled)return;let d=!0;return e.load().then(f=>d&&r(f),f=>d&&r(e.failed(f.message))),()=>{d=!1}},[e.enabled,e.key,o]);const c=x.useCallback(()=>l(d=>d+1),[]);return{value:t,retry:c}}function _0(e){const{value:t,retry:r}=Ac({enabled:e.enabled,key:e.auth??"",load:()=>Rt.githubRepos(),failed:o=>({kind:"error",error:o})});return{list:t,retry:r}}function np(e){const t=e.s.github,r=Kl(t),[o,l]=x.useState(!r),[c,d]=x.useState(t.repo??t.detectedRepo??""),[f,g]=x.useState(""),[m,v]=x.useState(),[y,w]=x.useState(!1),{list:j,retry:$}=_0({enabled:!o,auth:t.auth});x.useEffect(()=>{r&&!f&&l(!1)},[r]);const N=async()=>{w(!0),v(void 0);try{await Rt.connect({active:"github",github:{repo:c,token:o?f:void 0}}),e.onConnected()}catch(X){v({ok:!1,error:X.message}),w(!1)}},E=async()=>{const X=await e.reload();X&&Kl(X.github)&&l(!1)},M=async()=>{await Rt.githubSignIn.signOut().catch(()=>{});const X=await e.reload();l(!X||!Kl(X.github))},O=!!c&&!(!o&&!j)&&(!o||!!f||r);return i.jsxs("div",{className:"card inset tracker-setup",children:[o?i.jsx(P0,{gh:t,token:f,onToken:g,repo:c,onRepo:d,onSignedIn:E}):i.jsxs(i.Fragment,{children:[i.jsx(b0,{gh:t,repo:c,onUseAnother:()=>l(!0),onSignOut:()=>void M()}),i.jsx(E0,{list:j,detected:t.detectedRepo,value:c,onChange:d,onRetry:$})]}),i.jsx(tp,{r:m}),i.jsx("footer",{children:i.jsx("button",{type:"button",className:"btn primary",disabled:y||!O,onClick:()=>void N(),children:y?"Connecting…":"Connect"})})]})}function D0(e){return e.line?i.jsxs("div",{className:"gh-identity",children:[i.jsxs("div",{className:"ln-who",children:[i.jsx("span",{className:"t-body",children:e.line}),e.email&&i.jsx(Q,{parts:[e.email]})]}),e.onUseAnother&&i.jsx("button",{type:"button",className:"btn ghost sm",onClick:e.onUseAnother,children:"Use another key"})]}):null}const B0={LINEAR_API_KEY:"LINEAR_API_KEY",stored:"a saved key"},Lc=e=>B0[e]??e;function Uo(e){return(e==null?void 0:e.kind)==="user"?e:void 0}const z0=e=>!!e.auth&&!!Uo(e.viewer);function sp(e,t){if(e)return t?`${e} / ${t}`:e}function ip(e){const t=Uo(e.viewer);if(!t)return;const r=sp(e.team,e.project)??"the team you pick",o=e.source?` (${Lc(e.source)})`:"";return`Will use ${r} in ${t.orgName} as ${t.name}${o}`}function F0(e){const t=sp(e.teamName??e.teamKey,e.projectName);if(!e.teamId||!t)return;const r=Uo(e.viewer),o=e.orgName??(r==null?void 0:r.orgName),l=o?` in ${o}`:"",c=r?` as ${r.name}`:"",d=e.auth?`, using ${Lc(e.auth)}`:"";return`Connected to ${t}${l}${c}${d}`}function U0(e,t){if(!e.activeAt)return"No issues yet";const r=Math.floor((t-Date.parse(e.activeAt))/864e5);return r<1?"Active today":r<60?`Active ${r}d ago`:`Active ${Math.floor(r/30)}mo ago`}function H0(e){var l,c;const{ln:t}=e,r=t.auth&&((l=t.viewer)==null?void 0:l.kind)==="unknown"?`Found ${Lc(t.auth)}, but Linear didn't accept it`:"",o=((c=t.viewer)==null?void 0:c.kind)==="unknown"?t.viewer.error:"";return i.jsxs(i.Fragment,{children:[r&&i.jsx(Q,{parts:[r,o]}),i.jsx(ep,{source:null,value:e.apiKey,onChange:e.onKey,label:"API key",placeholder:"lin_api_…",link:{href:"https://linear.app/settings/account/security",text:"New key"}}),i.jsxs("span",{className:"t-meta",children:["Or set ",i.jsx("code",{className:"t-code",children:"LINEAR_API_KEY"})," before starting Teamtrail."]})]})}function W0(e){const{list:t}=e;if(!t)return i.jsx(Hs,{label:"Loading projects…"});if(t.kind==="error")return i.jsx(Sc,{what:"Couldn't list the team's projects",reason:t.error,onRetry:e.onRetry});if(t.kind!=="ok"||!t.projects.length)return null;const r=[{value:"",label:"All projects"},...t.projects.map(o=>({value:o.id,label:o.state?`${o.name} · ${o.state}`:o.name}))];return i.jsxs("label",{className:"field",children:["Project (optional)",i.jsx(ct,{"aria-label":"Project",value:e.value,onChange:e.onChange,options:r})]})}function K0(e){const t=e.query.trim().toLowerCase(),r=t?e.teams.filter(o=>o.key.toLowerCase().includes(t)||o.name.toLowerCase().includes(t)):e.teams;return{shown:r.slice(0,e.limit),matches:r.length}}function V0(e,t){return t&&e.some(r=>r.id===t)?t:e.length===1?e[0].id:void 0}function G0(e){const{team:t}=e;return i.jsx(Ae,{as:"li",className:"repo-row team-row",selected:e.selected,title:t.name,context:i.jsx(Q,{parts:[{text:t.key,code:!0},U0(t,e.now)]}),onOpen:e.onPick})}const Q0=40;function q0(e){const[t,r]=x.useState(""),o=x.useMemo(()=>Date.now(),[]),{shown:l,matches:c}=K0({teams:e.teams,query:t,limit:Q0}),d=c>l.length?`${c-l.length} more: type to narrow`:"",f=e.truncated?`The first ${e.teams.length} teams`:"",g=e.value?"":"Pick the team your trails go in";return i.jsxs("div",{className:"repo-picker",children:[i.jsxs("label",{className:"field",children:["Team",i.jsx("input",{value:t,placeholder:"Search your teams by key or name",spellCheck:!1,"aria-label":"Search teams",onChange:m=>r(m.target.value)})]}),i.jsx("ul",{className:"repo-list","aria-label":"Teams",children:l.map(m=>i.jsx(G0,{team:m,selected:m.id===e.value,now:o,onPick:()=>e.onChange(m.id)},m.id))}),i.jsx(Q,{parts:[!c&&"No team matches",g,d,f]})]})}function Y0(e){const{list:t}=e;if(!t)return i.jsx(Hs,{label:"Loading teams…",rows:3,className:"picker-loading"});switch(t.kind){case"ok":return i.jsx(q0,{teams:t.teams,truncated:t.truncated,value:e.value,onChange:e.onChange});case"no-key":return i.jsx(Q,{parts:["Paste a Linear API key to list your teams"]});case"error":return i.jsx(Sc,{what:"Couldn't list your teams",reason:t.error,onRetry:e.onRetry});default:return t}}function J0(e,t){const[r,o]=x.useState(e);return x.useEffect(()=>{const l=setTimeout(()=>o(e),t);return()=>clearTimeout(l)},[e,t]),r}function X0(e){const{value:t,retry:r}=Ac({enabled:e.enabled&&!!e.teamId,key:`${e.teamId}
|
|
128
|
-
${e.apiKey??""}`,load:()=>Rt.linearProjects(e.teamId,e.apiKey),failed:o=>({kind:"error",error:o})});return{list:t,retry:r}}function Z0(e){const{value:t,retry:r}=Ac({enabled:e.enabled,key:e.apiKey??"",load:()=>Rt.linearTeams(e.apiKey),failed:o=>({kind:"error",error:o})});return{list:t,retry:r}}function eN(e){const t=J0(e.apiKey.trim(),400),r=e.paste&&t?t:void 0,o=e.paste?!!t:!!e.ln.auth,l=Z0({enabled:o,apiKey:r}),c=X0({teamId:e.teamId,apiKey:r,enabled:o}),d=l.list,f=c.list,g=(d==null?void 0:d.kind)==="ok"?d.teams:[],m=o&&!d,v=o&&!!e.teamId&&!f;return{enabled:o,list:d,teams:g,projects:f,loading:m||v,retryTeams:l.retry,retryProjects:c.retry}}function rp(e){var te;const t=e.s.linear,r=z0(t),[o,l]=x.useState(!r),[c,d]=x.useState(""),[f,g]=x.useState(t.teamId??""),[m,v]=x.useState(t.projectId??""),[y,w]=x.useState(),[j,$]=x.useState(!1),{enabled:N,list:E,teams:M,projects:R,loading:O,retryTeams:X,retryProjects:ie}=eN({ln:t,paste:o,apiKey:c,teamId:f});x.useEffect(()=>{r&&!c&&l(!1)},[r]),x.useEffect(()=>{(E==null?void 0:E.kind)==="ok"&&g(V0(E.teams,t.teamId)??"")},[E]);const D=M.find(P=>P.id===f),q=(R==null?void 0:R.kind)==="ok"?R.projects.find(P=>P.id===m):void 0,re=(E==null?void 0:E.kind)==="ok"?E.viewer:t.viewer,V=o?null:t.auth,ge=ip({viewer:re,team:D==null?void 0:D.name,project:q==null?void 0:q.name,source:V}),Re=async()=>{if(D){$(!0),w(void 0);try{await Rt.connect({active:"linear",linear:{teamId:D.id,teamKey:D.key,teamName:D.name,projectId:q==null?void 0:q.id,projectName:q==null?void 0:q.name,apiKey:o?c.trim():void 0}}),e.onConnected()}catch(P){w({ok:!1,error:P.message}),$(!1)}}},be=P=>{g(P),v("")};return i.jsxs("div",{className:"card inset tracker-setup linear-setup",children:[o&&i.jsx(H0,{ln:t,apiKey:c,onKey:d}),i.jsx(D0,{line:ge,email:(te=Uo(re))==null?void 0:te.email,onUseAnother:o?void 0:()=>l(!0)}),N&&i.jsx(Y0,{list:E,value:f,onChange:be,onRetry:X}),D&&i.jsx(W0,{list:R,value:m,onChange:v,onRetry:ie}),i.jsx(tp,{r:y}),i.jsx("footer",{children:i.jsx("button",{type:"button",className:"btn primary",disabled:j||O||!D,onClick:()=>void Re(),children:j?"Connecting…":"Connect"})})]})}function tN(e){return i.jsxs("div",{className:"c-actions",children:[e.canSwitch&&i.jsx("button",{className:"btn sm",disabled:!e.usable,onClick:e.onSwitch,children:"Switch"}),e.remote&&i.jsx("button",{className:`btn sm ${e.open?"on":""}`,disabled:!e.usable,onClick:e.onToggle,children:e.configured?"Edit":"Connect"})]})}function nN(e){const{id:t,active:r,s:o}=e,l=_i(t),c=r&&o?sN(t,o):void 0;return c?i.jsx(Q,{className:"c-who",parts:[c]}):r&&(t==="markdown"||l)?i.jsx("div",{className:"c-loc",children:e.location}):l&&e.configured&&o?i.jsx("div",{className:"c-loc",children:iN(t,o)}):null}function sN(e,t){if(e==="github")return N0(t.github);if(e==="linear")return F0(t.linear)}function iN(e,t){return e==="github"?t.github.repo:[t.linear.teamKey,t.linear.projectName].filter(Boolean).join(" · ")}function rN({status:e}){var c,d;if(!e)return null;const t=(c=e.rate)!=null&&c.limit?`${((d=e.rate.remaining)==null?void 0:d.toLocaleString())??"?"}/${e.rate.limit.toLocaleString()} req`:"",r=e.queued?` · ${e.queued} queued`:"",[o,l]=oN(e,r);return i.jsxs("div",{className:`sync-line ${o}`,title:e.error,children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:l}),t&&i.jsx("span",{className:"rate",children:t})]})}function oN(e,t){switch(e.state){case"online":return["ok",`Online · synced ${Mm(e.lastSyncAt)}${t}`];case"offline":return["warn",`Offline${t}`];case"rate-limited":return["warn",`Rate limited · resumes ${Vi(e.resetAt)}${t}`];case"auth-error":return["alert",`Credentials rejected${t}`];default:return["",`Connecting${t}`]}}function aN(e){const{id:t,active:r,configured:o,s:l}=e,c=_i(t),d=!c||!!l,f=["card connector",r?"active":"",d?"":"disabled",e.open?"open":""];return i.jsxs("div",{className:f.join(" "),children:[i.jsxs("div",{className:"card-row",children:[i.jsx("b",{className:"choice-title t-row-title",children:e.name}),r&&i.jsx("span",{className:"pill on",children:"Active"})]}),i.jsx(nN,{id:t,active:r,configured:o,location:e.location,s:l}),c&&r&&i.jsx(rN,{status:l==null?void 0:l[t].status}),i.jsx(tN,{canSwitch:!r&&(!c||o),remote:c,usable:d,configured:o,open:e.open,onSwitch:e.onSwitch,onToggle:e.onToggle})]})}function op(e=0){const[t,r]=x.useState(),o=x.useCallback(()=>Rt.get().then(l=>(r(l),l),()=>(r(null),void 0)),[]);return x.useEffect(()=>{if(o(),!e)return;const l=setInterval(()=>void o(),e);return()=>clearInterval(l)},[o,e]),[t,r,o]}function lN(e){const[t,,r]=op(5e3),[o,l]=x.useState(null),c=async f=>{t&&(f==="markdown"||_i(f))&&await Rt.connect({active:f==="markdown"?"markdown":f,...f==="github"&&t.github.repo?{github:{repo:t.github.repo}}:{},...f==="linear"&&t.linear.teamId?{linear:{teamId:t.linear.teamId,teamKey:t.linear.teamKey,teamName:t.linear.teamName,projectId:t.linear.projectId,projectName:t.linear.projectName}}:{}}).catch(()=>{}),Di(e.update,f)},d=x.useMemo(()=>({github:!!(t!=null&&t.github.repo),linear:!!(t!=null&&t.linear.teamId)}),[t]);return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"connectors",children:ox.map(f=>{const g=f.id;return i.jsx(aN,{id:g,name:f.name,active:g===e.activeTracker,configured:_i(g)&&d[g],open:o===g,location:e.location,s:t,onSwitch:()=>void c(g),onToggle:()=>_i(g)&&l(o===g?null:g)},f.id)})}),t&&o==="github"&&i.jsx(np,{s:t,reload:r,onConnected:()=>Di(e.update,"github")}),t&&o==="linear"&&i.jsx(rp,{s:t,onConnected:()=>Di(e.update,"linear")})]})}function cN(e,t){const r=e==null?void 0:e.github,o=e==null?void 0:e.linear,l=r&&t!=="github"?Zm(r,r.repo??r.detectedRepo):void 0,c=o&&t!=="linear"?ip({viewer:o.viewer,team:o.teamName,project:o.projectName,source:o.auth}):void 0;return[{id:"markdown",title:"Local markdown",sub:"Files in .teamtrail/ in this repo"},{id:"github",title:"GitHub Issues",sub:l??"Trails as labelled issues in your repo"},{id:"linear",title:"Linear",sub:c??"Trails and tickets in your Linear team"}]}function He(e){return i.jsxs("section",{className:"set-sec",children:[i.jsx(Je,{as:"h4",children:e.title}),e.children]})}function ap(e){const t=[{v:"summary",title:"Summary"},{v:"full",title:"Full transcript"}];return i.jsx("div",{className:"choice-row",children:t.map(r=>i.jsx(ht,{on:e.value===r.v,title:r.title,onClick:()=>e.onChange(r.v)},r.v))})}const uN={github:"Checking for a GitHub login…",linear:"Checking for a Linear key…"};function dN(e){const{prefs:t,update:r}=e,[o,,l]=op(5e3),[c,d]=x.useState(!1),f=cN(o??void 0,t.tracker),g=t.tracker==="github"||t.tracker==="linear",m=g&&(o==null?void 0:o.active)===t.tracker,v=g&&!m,y=j=>{r({onboarded:!0}),Di(r,j)},w=async()=>{d(!0),t.tracker==="markdown"&&o&&await Rt.connect({active:"markdown"}).catch(()=>{}),r({onboarded:!0}),t.tracker!==e.activeTracker&&Di(r,t.tracker)};return i.jsx("div",{className:"scrim",children:i.jsxs(Ke,{as:"div",className:"dialog onboarding",children:[i.jsxs("div",{className:"onb-brand",children:[i.jsx(uw,{size:22,bare:!0}),i.jsx(Bm,{className:"onb-title"})]}),i.jsxs("h2",{className:"onb-question t-heading",children:[i.jsx(vw,{className:"voice-badge",size:22}),"Where should your trails live?"]}),i.jsxs(He,{title:"Tracker",children:[i.jsx("div",{className:"choice-row",children:f.map(j=>i.jsx(ht,{on:t.tracker===j.id,title:j.title,sub:j.sub,onClick:()=>r({tracker:j.id})},j.id))}),o===void 0&&g&&i.jsx(Hs,{label:uN[t.tracker]??"Checking…"}),o&&t.tracker==="github"&&!m&&i.jsx(np,{s:o,reload:l,onConnected:()=>y("github")}),o&&t.tracker==="linear"&&!m&&i.jsx(rp,{s:o,onConnected:()=>y("linear")})]}),i.jsx(He,{title:"HITL transcript",children:i.jsx(ap,{value:t.hitlTranscript,onChange:j=>r({hitlTranscript:j})})}),i.jsx("footer",{children:i.jsx(K,{variant:"primary",disabled:c||v,onClick:()=>void w(),children:"Get started"})})]})})}const Hi=[{id:"trail",label:"This trail",intro:"How agents work on the trail on screen: its mode, the checks that prove work done, models and guides.",sections:[{id:"mode",title:"Trail mode"},{id:"verification",title:"Verification"},{id:"models",title:"Model matching"},{id:"team",title:"Team"}]},{id:"project",label:"Project",intro:"Where this repo keeps its trails, and the rules every agent working in it follows.",sections:[{id:"tracker",title:"Tracker"},{id:"workspaces",title:"Workspaces"},{id:"policy",title:"Risk policy"},{id:"guides",title:"Guides"},{id:"labels",title:"Labels"}]},{id:"alerts",label:"Attention & alerts",intro:"What interrupts you, where questions reach you, and what Scout tells you when you come back.",sections:[{id:"attention",title:"Attention"},{id:"slack",title:"Slack"},{id:"trip-report",title:"Trip report"}]},{id:"you",label:"You",intro:"How the Lookout looks and reads for you.",sections:[{id:"appearance",title:"Appearance"},{id:"transcript",title:"HITL transcript"},{id:"agent",title:"Agent"}]},{id:"projects",label:"All projects",intro:"Every repo this Lookout knows, so you can switch between them from the header.",sections:[{id:"projects",title:"Projects"}]},{id:"about",label:"About",intro:"What Teamtrail is, and what changed in each release.",sections:[{id:"changelog",title:"Changelog"}]}];function lp(e){if(e===null)return null;const t=Hi.find(l=>l.id===e);if(t)return{group:t.id};const r=Hi.find(l=>l.sections.some(c=>c.id===e));if(!r)return{};const o=r.sections.find(l=>l.id===e);return{group:r.id,section:o==null?void 0:o.id}}const bh={from:"18:00",to:"09:00"};function fN(e){const t=e.focus!==void 0,r=e.focus??bh;return i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Quiet hours"}),i.jsx(K,{size:"sm",on:t,"aria-pressed":t,onClick:()=>e.onChange(t?void 0:bh),children:t?"On":"Off"}),t&&i.jsxs(i.Fragment,{children:[i.jsx("input",{type:"time","aria-label":"Quiet from",value:r.from,onChange:o=>o.target.value&&e.onChange({...r,from:o.target.value})}),i.jsx("span",{className:"t-meta",children:"to"}),i.jsx("input",{type:"time","aria-label":"Quiet until",value:r.to,onChange:o=>o.target.value&&e.onChange({...r,to:o.target.value})})]})]})}const hN=[{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 mN(){typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()}function pN(){const{view:e,error:t,savePrefs:r}=Jm(0);if(!e)return null;const o=e.policy.value,l=`${ve.dataDir}/attention.json`,c=f=>void r({...e.prefs,...f}),d=typeof Notification<"u"&&Notification.permission==="denied";return i.jsxs(He,{title:"Attention",children:[i.jsxs("p",{className:"vf-intro",children:["Everything that needs you is ranked in Waiting on you. Only items scoring ",o.interrupt," or more interrupt you; the rest wait in the queue, and Slack gets them in a digest."]}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Interrupt me by"}),i.jsx(ct,{compact:!0,"aria-label":"Interrupt me by",value:e.prefs.channel,options:hN,onChange:f=>{f==="browser"&&mN(),c({channel:f})}})]}),e.prefs.channel==="browser"&&d&&i.jsx("span",{className:"vf-err",children:"The browser blocks notifications for this page. Allow them in its site settings."}),i.jsx(fN,{focus:e.prefs.focus,onChange:f=>c({focus:f})}),i.jsx("span",{className:"set-hint t-meta",children:"Your channel and quiet hours stay on this machine."}),e.policy.errors.length>0&&i.jsx("ul",{className:"vf-errors",children:e.policy.errors.map(f=>i.jsxs("li",{children:[l,": ",f]},f))}),i.jsx(Q,{className:"set-hint",parts:[e.policy.exists?{text:l,code:!0}:"Team defaults",`interrupt at ${o.interrupt}`,o.digestMinutes?`Slack digest every ${o.digestMinutes} min`:"Slack digest off"]}),t&&i.jsx("span",{className:"vf-err",children:t})]})}const gN=[5,15,30,60];function vN(e){const{value:t}=e;return i.jsxs("div",{className:"choice-row compact",children:[i.jsx(ht,{on:!t.enabled,title:"Off",onClick:()=>e.onChange({...t,enabled:!1})}),gN.map(r=>i.jsx(ht,{on:t.enabled&&t.awayMinutes===r,title:`Away ${r} min`,onClick:()=>e.onChange({enabled:!0,awayMinutes:r})},r))]})}const kN={repo:"Committed to the repo",machine:"Only on this machine",browser:"Only in this browser"};function it(e){const t=e.storage&&kN[e.storage];return i.jsxs("div",{className:"sp-slot",id:`settings-${e.id}`,children:[e.children,t&&i.jsx(Q,{className:"sp-where",parts:[t]})]})}function yN(e){const[t]=Ec();return t?i.jsx(He,{title:"Slack",children:i.jsx(yj,{focus:e.focus})}):null}function xN({data:e,route:t}){return i.jsxs(i.Fragment,{children:[i.jsx(it,{id:"attention",storage:"repo",children:i.jsx(pN,{})}),i.jsx(it,{id:"slack",storage:"machine",children:i.jsx(yN,{focus:t.section==="slack"})}),i.jsx(it,{id:"trip-report",storage:"browser",children:i.jsx(He,{title:"Trip report",children:i.jsx(vN,{value:e.prefs.briefing,onChange:r=>e.update({briefing:r})})})})]})}const wN=[{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"]}],jN=[{area:"Teamtrail Cloud",items:["Agents that run in the cloud, steered from the same Lookout"]}],NN=[{version:"0.24.1",date:"2026-11-10",items:["Buttons in the same row are always the same size"]},{version:"0.24.0",date:"2026-11-10",items:["Focus in the header: see at a glance whether it is on, and start or end it in one click","Sign in with GitHub, and pick your repo or Linear team from a searchable list","Write your own guides with `teamtrail guides new`, approve them in Settings and share them with the catalog","Settings is its own page, and the trail map has a cleaner, flatter look","Smaller polish: one colour for work in progress everywhere, a calmer first run and clearer Slack setup"]},{version:"0.23.0",date:"2026-11-08",items:["Match work to models: switch it on for a trail in Settings and each agent gets the tickets that fit the model it runs on, research on fast models and junctions on the strongest. You set the tier per ticket type; Teamtrail never switches a model, and a ticket no connected agent is strong enough for waits in your queue","Guides: a ticket can ask for a reviewer, QA, security, docs or architect, and the agent that claims it gets that guide’s instructions and a checklist it must answer before the work counts as done. Pick a trail’s team and each ticket’s guide in the Lookout, and add more guides from a moderated catalog in Settings → Guides. A guide can add checks but never remove one, its commands only run after you approve them, and a guide file edited after you approved it is switched off until you look at it again","Records has a new Trail stats view: delivery across every trail, by vendor, agent and ticket type, with plain observations from your own numbers. Teamtrail doesn't route work from them","MILOOPS is now Teamtrail. Missions are trails, the command center is the Lookout, MILO is Scout, and `/milo` is `/scout`","More room for the map: the summary of counts now slides up from a tab when you want it","A new day and night look, starting in night, with an Appearance setting to switch to day or follow your system","The map is now a landscape: tickets are trail signs, the trail shows what is walked and what is ahead, and an X marks the destination","A new greeting when you start `teamtrail` in a terminal","A new logo, a t whose stem runs along a trail to a node, and a new look for Scout: the original CRT head with ear cups and a baseball cap, with a lamp on the cap at night. No more pixel art, and new fonts too","All projects: every repo you supervise in one view, with one list of what needs you across them and what changed while you were away. Answer an agent's question in any repo from there, and switch projects from the header. Agents add their repo when they connect (`--no-register` opts out), or add one with `teamtrail projects add`"]},{version:"0.22.0",date:"2026-11-05",items:["A calmer, clearer command center: every list now reads the same way, what it is first, then one quiet line of context, and details when you want them","Red now only means something needs you now; other states show as a thin edge instead of colored text everywhere","The open question in a conversation can no longer be hidden by its suggested answers, and the phone header no longer runs off the side"]},{version:"0.21.0",date:"2026-11-05",items:["New plans can now edit a ticket, remove a dependency and reopen finished work, instead of working around it","Slack digests follow the team's digest setting (digestMinutes in attention.json); 0 turns them off, and everything still waits in Waiting on you","Remove a finished task's workspace from Settings → Workspaces or the ticket; the branch stays, and MILOOPS asks before discarding uncommitted changes"]},{version:"0.20.0",date:"2026-11-04",items:["Separate workspaces: switch on Settings → Workspaces and each ticket an agent claims gets its own copy of the repo on its own branch, so agents working at the same time don’t step on each other. When the work is done you get the branch to review; MILOOPS never merges or pushes for you","Warnings before a clash: agents say which files they expect to change. When two of them plan to change the same files, the second one is warned, and you see it in Waiting on you; open it to release either claim","When two agents’ branches did change the same files, Waiting on you suggests a ticket to bring the work together. One click adds it, waiting on both tickets, with the files listed","The ticket inspector shows which files an agent expects to change and the branch it works on","Fix: an execute ticket marked as needing you keeps that mark when saved to local files, GitHub Issues or Linear"]},{version:"0.19.0",date:"2026-11-04",items:["Risk policy: you decide what always needs you, such as database changes, logins and permissions, billing, deleting data or new dependencies (Settings → Risk policy). Agents can no longer make those calls on their own; they ask you. Their other decisions are labelled by risk in the briefing, and work that touched risky files without asking comes to you to check","One ranked list of everything that needs you in Waiting on you: questions, approvals, blocked work, briefs, knowledge and new plans, most important first, each with the reason (for example “blocks 3 tickets” or “claude-02 is waiting”). Related items are grouped so you answer them together; snooze what can wait","Fewer interruptions: agents say how urgent a question is, and only urgent items notify you (browser or Slack). Focus for an hour from the header, set quiet hours in Settings → Attention, and the rest waits in the list and the digest","Plans that adapt: missions list the assumptions they rely on, starting with the ones in the discovery brief. When an agent finds one is wrong, it shows the evidence and proposes a new plan; the tickets it would change are paused, the map previews the change, and nothing happens until you approve","Challenge the destination: an agent can tell you the work already exists, the mission targets the wrong problem, or it should be rescoped, with evidence and a suggested new goal","Assumptions on the Plan tab (confirm the ones you know are true) and an assumptions field when you create a mission","Fix: when an agent asks two questions at once, your answer goes to the one you opened; the inbox stats line no longer gets covered by the list"]},{version:"0.18.0",date:"2026-11-04",items:["Acceptance criteria: agents write down what done means before they start (required on missions with a discovery brief). When they finish, each point needs proof: one of your checks, a named test, the pull request, or your sign-off","Work whose criteria lack proof goes back with the reason; points only you can confirm come to your inbox to sign off","Business rules from your project knowledge are suggested as criteria, and the ticket shows any rule no criterion covers yet. Confirm a ticket’s criteria in the inspector","Cross-vendor review: when Claude and Codex agents both run, each reviews the other’s work first","Fix: answers from the command center could hang when too many live updates were open; all updates now share one connection"]},{version:"0.17.0",date:"2026-11-03",items:["Discovery brief: new missions start with an agent mapping the existing system (files, conventions, data and API impact, risks, assumptions, product context). Implementation tickets wait until you accept the brief or ask for changes, from the banner over the map or the card in Communication","Create mission: start a mission from the New mission dialog without a terminal; any agent picks it up with /milo resume","Knowledge: what agents need to know about your codebase and product (architecture, conventions, gotchas, dead ends, business rules, personas, UX principles, pricing). Agents propose, you confirm, keep as an assumption or retire. Confirmed entries reach agents with every claim, picked for the ticket with the reason, and the inspector shows what an agent gets","Knowledge about specific files is flagged for re-confirmation when those files change","Save decisions, cancelled tickets (as dead ends) and brief sections as knowledge in one click; seed it from a document with miloops knowledge import <file.md>"]},{version:"0.16.0",date:"2026-11-03",items:["Mission report (Mission plan → Report): tickets done, mission and median ticket lead time, your interventions, rework, review results and cost per verified ticket. Hover any number to see how it is computed; export it as markdown","Agents report the same numbers in one line from the status tool","Agents use missions for big work only, and decide routine calls themselves, keeping each one as a decision record you can review or reverse; they ask you when the call changes product behaviour, data, security, billing, a public API or the schema","Decisions: filter by who made the call, agents on their own or people. The briefing now counts only the calls agents made themselves, not your answers they recorded"]},{version:"0.15.0",date:"2026-10-31",items:["Verification in the ticket inspector: the level that applies and where it comes from, every attempt newest first with the git evidence (base → head, files changed, flags), its checks, exit codes, durations and the failing output, and the full log on demand","Verifying, Rework and Blocked on the map, in the legend and as status counters on missions that verify completions","Operator calls on a verifying or blocked ticket: Approve, Re-run checks, Send to rework with a note, Accept anyway and Unblock. Overrides need a reason, and each call is kept as a verdict next to the attempts and in the mission history. Approve asks for a re-run when the code changed since the checks passed","Set the verification level of a mission (Settings → Verification) or of one ticket (inspector). Only you can change it; agents cannot","The inspector updates live while checks run","Independent review: at Checks + review, a passing completion gets a review ticket that another agent takes and answers with PASS, FAIL (with findings) or NEEDS_HUMAN. The agent that did the work is never given its own review","Waiting on you lists reviewed work to approve (Checks + review + you) and held tickets, and Slack posts them with Approve and Rework… buttons","Agents can name their pull request in `report_completion` (`pr`); PR and CI tracking then follows that PR first"]},{version:"0.14.0",date:"2026-10-31",items:["Ticket lifecycle in plain words: Ready, Backlog, Working, Done and Cancelled (with Verifying, Rework and Blocked to come with verification)","Every claim, release, return to queue, resolution and rule-out goes through one lifecycle engine that records who, why and when in `.miloops/.events/<mission>.jsonl` (local history, never committed)","Settings → Verification shows the checks in `.miloops/verification.json`: argv commands with timeouts, run without a shell, secrets kept out of their environment. Read-only","Completion is a claim: on missions started with `verification.json` present, an execute or task ticket is only done once its checks pass. A failed check sends it back for Rework with the failing output (agents see it in close_ticket, next_ticket and claim_ticket, and rework comes first in the queue); after 3 failed attempts, or when the checks cannot run, it waits on you as Blocked","New MCP tools `report_completion` and `verification_status`; missions started before verification, and research, grilling and prototype tickets, close exactly as before","Git evidence, no GitHub needed: each claim records HEAD and the uncommitted state, and each completion lists the files changed since then. It flags no changes, overlap with another active ticket, a branch switch or reset, and edits to `verification.json` (which send the ticket to you as Blocked). A pass on code that changed while its checks ran is re-run","Pull request and CI evidence: with `verification.json` and a GitHub token (Settings, `GITHUB_TOKEN` or `gh auth login`), the command center finds each ticket’s PR (its branch `miloops-<mission>-<ticket>`, a `miloops:<mission>#<ticket>` line in the PR body, or a link you set) and flags mismatches: done with the PR still open, PR merged while the ticket is in progress, PR closed unmerged, required checks failing or unknown, PR head not the verified commit. Flags never change a ticket. A CI chip in the header shows sync health and never shows synced after a failed sync"]},{version:"0.13.0",date:"2026-10-31",items:["Crash recovery for claims: an agent’s claim is a lease (15 min by default) that every tool call renews, including waits on your answer","When an agent crashes or goes silent, its ticket goes back to the queue on its own, and the activity log says so; the next agent picks it up from next_ticket or claim_ticket","The returned ticket keeps a handoff comment with the previous agent’s progress notes and decisions, so the next agent resumes instead of starting over","Stalled state on the map, in sessions and in the ticket inspector when a lease is about to run out, with a Release to queue action","Works with GitHub and Linear: the return is an ordinary comment + unassign, queued in the offline outbox like any other write","Set the lease with `miloops mcp --lease-minutes <n>` or `MILOOPS_LEASE_MINUTES`"]},{version:"0.12.0",date:"2026-10-31",items:["Slack: your own MILO app, created from a manifest and connected from your machine over Socket Mode in five guided steps (Settings → Slack or `miloops connect slack`)","Tokens stay in your local credential store next to the GitHub and Linear ones; nothing passes through MILOOPS servers","Agent questions arrive as a Slack DM with answer buttons and a Reply… box; answering there resolves the item in Waiting on you, and answering in the command center closes the DM","Save as decision on any message, or `/milo decide`: the form is prefilled with a summary of the thread, and the decision is recorded with a permalink, resolving the related ticket by default","`/milo status` and `/milo inbox` for the mission at a glance; DMs when a ticket is blocked or a mission is done","Allowed users, notification target and events in Settings → Slack","Slack setup without Paste clicks: press ⌘V / Ctrl+V anywhere, or in Chrome just come back to the tab after copying; pasting the app token opens the install page; MILO recognises you by your git email, so there is nothing to claim in Slack"]},{version:"0.11.0",date:"2026-10-31",items:["GitHub Issues tracker: missions are labelled issues, tickets are sub-issues, blocking uses native issue dependencies",'Linear tracker: missions are labelled issues in a team (optionally one project), tickets are sub-issues, blocking uses "blocks" relations',"Two-way sync: tickets, status, claims, comments, blockers and decisions written from MILOOPS land in the tracker; changes made there show up within seconds","Decisions are posted as comments on their ticket and listed in the mission","Connect from Settings with Test connection; GitHub reuses your gh login or GITHUB_TOKEN, Linear takes a personal API key","Tokens stay on your machine: kept by the local server, never sent to the browser or anywhere else","Offline and rate limits: changes queue and send in order when the tracker answers again; the connector shows status, queue and remaining requests","Connected agents (MCP) work on the active tracker: with GitHub or Linear connected, their missions, claims and decisions land there, and their sessions show live in the command center"]},...wN];function SN(){return i.jsxs("div",{className:"changelog",children:[i.jsxs("div",{className:"about",children:[i.jsx(Bm,{className:"about-name"}),i.jsx("span",{className:"mono-label",children:ve.category}),i.jsx("p",{className:"onb-tagline",children:ve.tagline}),i.jsx(Q,{parts:[ve.assistant.name]})]}),i.jsx(He,{title:"Next",children:jN.map(e=>i.jsxs("div",{className:"cl-row",children:[i.jsx("span",{className:"mono-label",children:e.area}),i.jsx("ul",{children:e.items.map(t=>i.jsx("li",{children:t},t))})]},e.area))}),NN.map(e=>i.jsx(He,{title:`${e.version} · ${e.date}`,children:i.jsx("ul",{children:e.items.map(t=>i.jsx("li",{children:t},t))})},e.version))]})}function cp(e){return i.jsx("ul",{className:"checklist-answers",children:e.answers.map(t=>i.jsxs("li",{className:t.done?"done":"not-done",children:[i.jsx("span",{className:"mark","aria-label":t.done?"Done":"Not done",children:t.done?"✓":"–"}),i.jsx("span",{className:"t-body",children:t.item}),t.note&&i.jsx("span",{className:"t-meta note",children:t.note})]},t.item))})}const up=`${ve.apiPrefix}`;async function dp(e){const t=await e.json().catch(()=>({}));if(!e.ok)throw new Error(t.error??`Request failed (${e.status})`);return t}const No=async e=>dp(await fetch(`${up}${e}`)),fp=async(e,t)=>dp(await fetch(`${up}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}));let hp;const go=new Set;let Is;function So(e){hp=e;for(const t of go)t()}function Ch(){No("/guides").then(So,()=>So(null))}const bN=()=>hp;function CN(e){return go.add(e),Is||(Ch(),Is=pn(t=>{t.includes("guides")&&Ch()})),()=>{go.delete(e),!go.size&&(Is==null||Is(),Is=void 0)}}function gn(){const e=x.useSyncExternalStore(CN,bN),t=x.useCallback(async(o,l)=>{try{So(await fp(o,l));return}catch(c){return c.message}},[]),r=x.useCallback(o=>o?e==null?void 0:e.guides.find(l=>l.id===o):void 0,[e]);return{view:e,act:t,find:r}}function $N(e){var f;const{view:t,find:r}=gn(),o=r(e.id),l=t!=null&&(o==null?void 0:o.status)!=="active",c=((f=o==null?void 0:o.guide)==null?void 0:f.name)??e.id,d=l?`${c}: ${(o==null?void 0:o.reason)??"not installed"}`:`Guide: ${c}`;return i.jsx("span",{className:We("guide-chip",l&&"off"),"data-guide-id":e.id,title:d,children:c})}const TN={active:"Active",unapproved:"New, waiting for your approval",tampered:"Changed since you approved it",invalid:"Can't be used"},EN={active:"Approved",unapproved:"Not approved yet",tampered:"Changed since you approved it",invalid:"Can't be used"},oc=e=>{var t;return e.origin==="local"&&(!((t=e.lock)!=null&&t.source)||e.lock.source==="local")};function IN(e){return oc(e)?{text:EN[e.status],strong:e.status==="active"}:e.status==="active"?void 0:TN[e.status]}function MN(e){var r;if(e.origin==="builtin")return"Built in";const t=(r=e.lock)==null?void 0:r.source;if(!t||t==="local")return e.overridesBuiltin?"Local, replaces the built-in":"Local";try{return`From ${new URL(t.registry).host}`}catch{return"From a catalog"}}const Rc=e=>e.map(t=>/\s/.test(t)?JSON.stringify(t):t).join(" "),$h=3;function AN(e,t){return e.length<=Math.max(t,$h+1)?e:`${e.slice(0,Math.max(t-1,$h)).trimEnd()}…`}function LN(e){var o;const t=(o=e.lock)==null?void 0:o.review;return!t||e.status!=="active"?void 0:t.verified?{text:"Verified",strong:!0,tip:t.reviewedBy.length>0?`Reviewed by ${t.reviewedBy.join(", ")}`:void 0}:"Not reviewed"}var RN=em();function ON(e){var w;const{preview:t}=e,{act:r,find:o}=gn(),[l,c]=x.useState({kind:"ready"}),[d,f]=x.useState(),g=t.entry.id,m=async()=>{f(void 0),c({kind:"adding"});try{c({kind:"added",pending:(await e.add(g)).pendingChecks})}catch(j){f(j.message),c({kind:"ready"})}};if(t.entry.builtin)return i.jsxs("span",{className:"t-meta",children:["Built into ",ve.name,": already available to every trail, nothing to add."]});if(l.kind!=="added"){const j=e.installed===t.entry.version,$=e.installed?"Update guide":"Add guide";return i.jsxs("div",{className:"add-guide",children:[!t.ok&&i.jsx("span",{className:"t-meta",children:"The safety lint found errors, so this guide can't be added."}),i.jsx(K,{variant:"primary",disabled:!t.ok||j||l.kind==="adding",onClick:()=>void m(),children:j?"Added":$}),d&&i.jsx("span",{className:"vf-err",children:d})]})}const v=((w=o(g))==null?void 0:w.pendingChecks)??l.pending,y=async j=>f(await r("/guides/checks/approve",{id:g,name:j}));return i.jsxs("div",{className:"add-guide",children:[i.jsx("p",{className:"t-body",children:v.length?`Added ${g} ${t.entry.version}. Approve each command it proposes; none runs until you do.`:`Added ${g} ${t.entry.version}. Agents get its instructions on tickets that ask for ${g}.`}),v.map(j=>{var $,N;return i.jsxs("span",{className:"guide-check",children:[i.jsxs("code",{className:"t-code",children:[j,": ",Rc(((N=($=t.guide)==null?void 0:$.proposedChecks[j])==null?void 0:N.run)??[])]}),i.jsxs(K,{size:"sm",onClick:()=>void y(j),children:["Approve check ",j]})]},j)}),d&&i.jsx("span",{className:"vf-err",children:d})]})}function PN(e){return e.findings.length?i.jsx("ul",{className:"vf-findings guide-findings",children:e.findings.map((t,r)=>i.jsxs("li",{className:`sev-${t.level}`,children:[i.jsxs("code",{className:"t-code",children:["line ",t.line]})," ",t.message," ",i.jsxs("span",{className:"t-meta",children:["(",t.rule,")"]})]},r))}):i.jsx("p",{className:"t-meta",children:"The safety lint found nothing."})}function _N(e){var o,l;const{p:t}=e,r=Object.entries(((o=t.guide)==null?void 0:o.proposedChecks)??{});return i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"t-label",children:"Safety lint"}),i.jsx(PN,{findings:t.findings}),t.guide&&t.guide.checklist.length>0&&i.jsx("span",{className:"t-label",children:"Checklist"}),t.guide&&i.jsx("ul",{className:"catalog-checklist t-body",children:t.guide.checklist.map(c=>i.jsx("li",{children:c},c))}),r.length>0&&i.jsx("span",{className:"t-label",children:"Commands it proposes"}),r.map(([c,d])=>i.jsxs("code",{className:"t-code guide-check",children:[c,": ",Rc(d.run)]},c)),i.jsx("span",{className:"t-label",children:"Instructions"}),i.jsx("pre",{className:"guide-preview",children:((l=t.guide)==null?void 0:l.instructions)??t.text})]})}function DN(e){if(!e.repo)return null;const t=encodeURIComponent(`Report: ${e.id} ${e.version}`),r=`${e.repo.replace(/\/+$/,"")}/issues/new?template=report-guide.yml&title=${t}`;return i.jsx("a",{className:"report-link t-meta",href:r,target:"_blank",rel:"noreferrer",children:"Report this guide"})}function BN(e){const t=e.entry,[r,o]=x.useState(),[l,c]=x.useState();return x.useEffect(()=>{e.preview(t.id).then(o,d=>c(d.message))},[t.id]),i.jsxs("div",{className:"catalog-entry",children:[i.jsx(K,{size:"sm",variant:"ghost",onClick:e.onBack,children:"← All guides"}),i.jsx("h3",{className:"t-title",children:t.name??t.id}),i.jsx(Q,{parts:[{text:t.id,code:!0},t.version,`by ${t.author}`,zN(t),t.reviewedBy.length>0&&`reviewed by ${t.reviewedBy.join(", ")}`]}),i.jsx("p",{className:"t-body",children:t.summary}),t.history.length>0&&i.jsx("ul",{className:"catalog-history",children:t.history.map(d=>i.jsxs("li",{className:"t-meta",children:[d.version," · ",i.jsx("code",{className:"t-code",children:d.commit.slice(0,8)})," · ",d.at.slice(0,10),d.reviewer&&` · reviewed by ${d.reviewer}`]},`${d.version}-${d.commit}`))}),l&&i.jsx("span",{className:"vf-err",children:l}),r&&i.jsx(_N,{p:r}),r&&i.jsx(DN,{repo:r.repo,id:t.id,version:t.version}),r&&i.jsx(ON,{preview:r,installed:e.installed,add:e.add})]})}function zN(e){return e.builtin?{text:"Built in",strong:!0}:e.verified?{text:"Verified",strong:!0}:"Not reviewed"}function FN(e){const t=e.entry;return i.jsx("li",{className:"catalog-row","data-guide-id":t.id,children:i.jsx(Ae,{title:t.name??t.id,context:i.jsx(Q,{parts:[{text:t.id,code:!0},t.version,t.author,UN(t),t.reported&&"Reported"]}),detail:t.summary,trailing:e.installed&&`installed ${e.installed}`,onOpen:e.onOpen})})}function UN(e){return e.builtin?{text:"Built in",strong:!0}:e.verified?{text:"Verified",strong:!0}:"Not reviewed"}const Th=e=>e?`registry=${encodeURIComponent(e)}`:"";function HN(e){const[t,r]=x.useState(),[o,l]=x.useState();x.useEffect(()=>{let f=!0;return r(void 0),l(void 0),No(`/guides/catalog?${Th(e)}`).then(g=>f&&r(g),g=>f&&l(g.message)),()=>{f=!1}},[e]);const c=x.useCallback(f=>No(`/guides/catalog/preview?${Th(e)}&id=${encodeURIComponent(f)}`),[e]),d=x.useCallback(async f=>{const g=await fp("/guides/catalog/add",{registry:e,id:f});return So(g),g.installed},[e]);return{index:t,error:o,preview:c,add:d}}function WN(e){var $,N;const[t,r]=x.useState((($=e.registries[0])==null?void 0:$.name)??""),o=HN(t||void 0),{find:l}=gn(),[c,d]=x.useState(""),[f,g]=x.useState(!0),[m,v]=x.useState(),y=o.index?ux({guides:o.index.guides},{query:c,verifiedOnly:f}):[],w=(N=o.index)==null?void 0:N.guides.find(E=>E.id===m),j=E=>{var M,R,O;return((M=l(E))==null?void 0:M.origin)==="local"?(O=(R=l(E))==null?void 0:R.guide)==null?void 0:O.version:void 0};return RN.createPortal(i.jsx("div",{className:"scrim catalog-scrim",onClick:E=>{E.stopPropagation(),e.onClose()},children:i.jsxs(Ke,{as:"div",className:"dialog catalog-dialog",onClick:E=>E.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h3",{className:"t-title",children:"Guide catalog"}),e.registries.length>1&&i.jsx(ct,{compact:!0,"aria-label":"Catalog",value:t,options:e.registries.map(E=>({value:E.name,label:E.name,hint:E.url})),onChange:r}),i.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})]}),w?i.jsx(BN,{entry:w,installed:j(w.id),preview:o.preview,add:o.add,onBack:()=>v(void 0)}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"catalog-filters",children:[i.jsx("input",{className:"catalog-search",placeholder:"Search guides","aria-label":"Search guides",value:c,onChange:E=>d(E.target.value)}),i.jsx(K,{size:"sm",on:f,"aria-pressed":f,onClick:()=>g(E=>!E),children:"Verified only"})]}),o.error&&i.jsx("span",{className:"vf-err",children:o.error}),!o.index&&!o.error&&i.jsx(Ee,{children:"Reading the catalog…"}),o.index&&!y.length&&i.jsx(Ee,{children:"No guides match."}),i.jsx("ul",{className:"catalog-list",children:y.map(E=>i.jsx(FN,{entry:E,installed:j(E.id),onOpen:()=>v(E.id)},E.id))})]})]})}),document.body)}function KN(e){const t=e.r.guide;if(!t)return null;const r=Object.entries(t.proposedChecks);if(!t.requiresChecks.length&&!r.length)return null;const o=e.r.status==="active";return i.jsxs("div",{className:"guide-checks",children:[t.requiresChecks.length>0&&i.jsxs("span",{className:"t-meta",children:["Adds checks ",i.jsx("code",{className:"t-code",children:t.requiresChecks.join(", ")})," to its tickets"]}),r.map(([l,c])=>{const d=e.r.pendingChecks.includes(l);return i.jsxs("span",{className:"guide-check",children:[i.jsxs("code",{className:"t-code",children:[l,": ",Rc(c.run)]}),d&&o&&i.jsxs(K,{size:"sm",disabled:e.busy,onClick:()=>e.onApprove(l),children:["Approve check ",l]}),d&&!o&&i.jsx("span",{className:"t-meta",children:"approve the guide first"}),!d&&i.jsx("span",{className:"t-meta",children:"approved"})]},l)})]})}function mp(e){var d,f;const{r:t}=e,r=t.id,o=t.status!=="active"||t.pendingChecks.length>0,l=(t.status==="unapproved"||t.status==="tampered")&&!!t.guide,c=t.guide?`${t.guide.name} ${t.guide.version}`:r;return i.jsx("li",{className:"guide-row","data-guide-id":r,children:i.jsx(Ae,{edge:o?"attention":"neutral",title:c,context:i.jsx(Q,{parts:[{text:r,code:!0},MN(t),LN(t),IN(t),t.guide&&VN(t.guide.checklist.length)]}),detail:t.status==="unapproved"?(d=t.guide)==null?void 0:d.summary:t.reason??((f=t.guide)==null?void 0:f.summary),actions:t.origin==="local"&&i.jsxs(K,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>e.onAct("/guides/remove",{id:r}),children:["Remove guide ",r]}),below:i.jsxs(i.Fragment,{children:[l&&i.jsx(K,{size:"sm","aria-label":`Approve guide ${r}`,disabled:e.busy,onClick:()=>e.onAct("/guides/approve",{id:r}),children:"Approve"}),i.jsx(KN,{r:t,busy:e.busy,onApprove:g=>e.onAct("/guides/checks/approve",{id:r,name:g})})]})})})}const VN=e=>e===1?"1 checklist item":`${e} checklist items`;function GN(e){return i.jsxs(He,{title:"Write your own",children:[i.jsxs("p",{className:"vf-intro",children:["Write a guide for your team in your repo with ",i.jsxs("code",{className:"t-code",children:[ve.slug," guides new <id>"]}),". It starts from a template in ",i.jsxs("code",{className:"t-code",children:[ve.dataDir,"/guides/"]})," that passes the safety lint. Fill in the instructions and checklist, then approve it here: agents can only use it once you have, and again after every edit."]}),e.guides.length>0?i.jsx("ul",{className:"guides-list own-guides",children:e.guides.map(t=>i.jsx(mp,{r:t,busy:e.busy,onAct:e.onAct},t.id))}):i.jsx(Ee,{children:"No guides of your own yet."}),e.error&&i.jsx("span",{className:"vf-err",children:e.error}),i.jsxs("p",{className:"t-meta guides-share",children:["Useful beyond your team? Check it with ",i.jsxs("code",{className:"t-code",children:[ve.slug," guides lint"]})," and"," ",i.jsx("a",{href:cx,target:"_blank",rel:"noreferrer",children:"share it in the public catalog"}),"."]})]})}function QN(e){const{view:t,act:r}=gn(),[o,l]=x.useState(),[c,d]=x.useState(!1),[f,g]=x.useState(!1),m=x.useRef(null);if(x.useEffect(()=>{var w;e.focus&&t&&((w=m.current)==null||w.scrollIntoView({block:"start"}))},[e.focus,!!t]),!t)return null;const v=w=>(j,$)=>{d(!0),r(j,$).then(N=>{l(N?{own:w,message:N}:void 0),d(!1)})},y=w=>o&&o.own===w?o.message:void 0;return i.jsxs("div",{className:"guides-section",ref:m,children:[i.jsxs(He,{title:"Guides",children:[i.jsx("p",{className:"vf-intro",children:"Guides give an agent instructions and a checklist for the tickets that ask for them. A guide can add checks, never remove them, and its commands only run once you approve them."}),i.jsx("ul",{className:"guides-list",children:t.guides.filter(w=>!oc(w)).map(w=>i.jsx(mp,{r:w,busy:c,onAct:v(!1)},w.id))}),i.jsxs("div",{className:"guides-foot",children:[i.jsx(K,{size:"sm",onClick:()=>g(!0),children:"Browse guides"}),i.jsx(Q,{parts:[{text:`${ve.dataDir}/guides/`,code:!0},{text:"guides.lock.json",code:!0}]})]}),t.configErrors.length>0&&i.jsx("ul",{className:"vf-errors",children:t.configErrors.map(w=>i.jsx("li",{children:w},w))}),y(!1)&&i.jsx("span",{className:"vf-err",children:y(!1)})]}),i.jsx(GN,{guides:t.guides.filter(oc),busy:c,onAct:v(!0),error:y(!0)}),f&&i.jsx(WN,{registries:t.registries,onClose:()=>g(!1)})]})}function qN(e){const{view:t,act:r}=gn(),[o,l]=x.useState();if(!t)return null;const c=e.map.guides??[],d=t.guides.filter(g=>g.status==="active"&&g.guide),f=g=>{const m=c.includes(g)?c.filter(v=>v!==g):[...c,g];l(void 0),r("/guides/team",{mapId:e.map.id,guides:m}).then(l)};return i.jsxs(He,{title:`Team of ${e.map.key}`,children:[i.jsx("p",{className:"vf-intro",children:"The guides this trail works with. With Reviewer on the team, review tickets come with the reviewer's instructions and checklist."}),i.jsx("div",{className:"team-guides",children:d.map(g=>{const m=c.includes(g.id);return i.jsx(K,{size:"sm",on:m,"aria-pressed":m,title:g.guide.summary,onClick:()=>f(g.id),children:g.guide.name},g.id)})}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function YN(e,t){const[r,o]=x.useState();return x.useEffect(()=>{const l=`/guides/checklist?mapId=${encodeURIComponent(e)}&ticketId=${encodeURIComponent(t)}`,c=()=>No(l).then(d=>o(d.checklist),()=>o(null));return c(),pn(d=>{d.endsWith("checklist.json")&&c()})},[e,t]),r}function JN(e){const t=YN(e.mapId,e.ticketId);if(!t)return null;const r=t.answers.filter(o=>!o.done).length;return i.jsxs("div",{className:"checklist-panel",children:[i.jsx(Q,{parts:[`${t.guide.id} ${t.guide.version} checklist`,t.by,Vi(t.at),r?`${r} not done`:"all done"]}),i.jsx(cp,{answers:t.answers})]})}const Eh="";function XN(e){const{view:t,act:r}=gn(),[o,l]=x.useState();if(!t)return null;const c=e.ticket,d=t.guides.filter(m=>{var v;return m.status==="active"&&((v=m.guide)==null?void 0:v.handles.types.includes(c.type))}),f=[{value:Eh,label:"No guide"},...d.map(m=>({value:m.id,label:m.guide.name,hint:m.guide.summary}))];c.guide&&!d.some(m=>m.id===c.guide)&&f.push({value:c.guide,label:c.guide});const g=m=>{l(void 0),r("/guides/ticket",{mapId:e.mapId,ticketId:c.id,guide:m||null}).then(l)};return i.jsxs("span",{className:"guide-picker",children:[i.jsx(ct,{compact:!0,"aria-label":"Ticket guide",value:c.guide??Eh,options:f,onChange:g}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function ZN(e){const{view:t,find:r}=gn();if(!t)return null;const o=r(e.id);if((o==null?void 0:o.status)==="active")return null;const l=o?o.reason??o.status:"it is not installed";return i.jsxs("p",{className:"guide-warning t-meta",children:["Guide ",e.id," can't be used: ",l,". Claims get no guide instructions until you approve it in Settings → Guides."]})}function eS(e){const{view:t}=gn(),r=e.ticket;return!t||r.state!=="open"&&!r.guide?null:i.jsxs("section",{className:"ticket-guide d-section",children:[i.jsxs("span",{className:"guide-head",children:[i.jsx("span",{className:"t-label",children:"Guide"}),r.state==="open"?i.jsx(XN,{mapId:e.mapId,ticket:r}):r.guide&&i.jsx($N,{id:r.guide})]}),r.guide&&i.jsx(ZN,{id:r.guide}),i.jsx(JN,{mapId:e.mapId,ticketId:r.id})]})}function tS(e){var g;const{view:t,find:r}=gn();if(!e)return;const o=r(e),l=t!=null&&(o==null?void 0:o.status)!=="active",c=((g=o==null?void 0:o.guide)==null?void 0:g.name)??e,d=o!=null&&o.guide?`${c} ${o.guide.version}`:c,f=l?`Guide ${d}: ${(o==null?void 0:o.reason)??"not installed"}`:`Guide: ${d}`;return{id:e,name:c,tip:f,off:l}}const Ih={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"},nS={low:"the agent decides",medium:"the agent decides and records it",high:"you decide"},sS=e=>e[0].toUpperCase()+e.slice(1),ac=gm.map(e=>({value:e,label:sS(e),hint:nS[e]}));function iS(e){const[t,r]=x.useState(""),[o,l]=x.useState("high"),{rules:c,onChange:d}=e,f=()=>{const g=t.trim();!g||c.some(m=>m.glob===g)||(d([...c,{glob:g,level:o}]),r(""))};return i.jsxs("div",{className:"risk-paths",children:[i.jsx("span",{className:"mono-label",children:"Files"}),c.map((g,m)=>i.jsxs("div",{className:"risk-row",children:[i.jsx("code",{children:g.glob}),i.jsx(ct,{compact:!0,"aria-label":`${g.glob} risk`,value:g.level,options:ac,onChange:v=>d(c.map((y,w)=>w===m?{...y,level:v}:y))}),i.jsx("button",{className:"icon-btn","aria-label":`Remove ${g.glob}`,onClick:()=>d(c.filter((v,y)=>y!==m)),children:"×"})]},g.glob)),i.jsxs("div",{className:"risk-row",children:[i.jsx("input",{value:t,placeholder:"src/payments/**","aria-label":"New file pattern",onChange:g=>r(g.target.value),onKeyDown:g=>g.key==="Enter"&&f()}),i.jsx(ct,{compact:!0,"aria-label":"New pattern risk",value:o,options:ac,onChange:l}),i.jsx(K,{onClick:f,disabled:!t.trim(),children:"Add"})]})]})}const pp=`${Se()}/policy`;async function rS(){const e=await fetch(pp);return e.ok?await e.json():null}function oS(){const[e,t]=x.useState(),r=x.useCallback(()=>{rS().then(t,()=>t(null))},[]);x.useEffect(()=>(r(),pn(l=>{l.endsWith("policy.json")&&r()})),[r]);const o=x.useCallback(async l=>{const c=await fetch(pp,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)}),d=await c.json();if(!c.ok)return d.error??`Saving failed (${c.status})`;t(d)},[]);return{view:e,save:o}}function aS(){const{view:e,save:t}=oS(),[r,o]=x.useState();if(!e)return null;const l=`${ve.dataDir}/policy.json`,c=d=>{o(void 0),t(d).then(o,f=>o(f.message))};return i.jsxs(He,{title:"Risk policy",children:[i.jsx("p",{className:"vf-intro",children:"What agents may decide on their own. High: they must ask you. Medium: they decide, follow your conventions and record it for you to review. Low: they just decide."}),i.jsx("div",{className:"risk-grid",children:pm.map(d=>i.jsxs("label",{className:"risk-row",children:[i.jsx("span",{children:Ih[d]}),i.jsx(ct,{compact:!0,"aria-label":`${Ih[d]} risk`,value:e.policy.categories[d],options:ac,onChange:f=>c({...e.policy,categories:{...e.policy.categories,[d]:f}})})]},d))}),i.jsx(iS,{rules:e.policy.paths,onChange:d=>c({...e.policy,paths:d})}),e.errors.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[l," has errors, so the defaults apply until it is fixed."]})]}),i.jsx("ul",{className:"vf-errors",children:e.errors.map(d=>i.jsx("li",{children:d},d))})]}),e.defaults&&e.errors.length===0&&i.jsxs("span",{className:"set-hint t-meta",children:["Defaults. Changing anything saves ",l,", so your team shares it."]}),r&&i.jsx("span",{className:"vf-err",children:r})]})}const lc=`${Se()}/workspaces`;async function lS(){const e=await fetch(lc);return e.ok?await e.json():null}function gp(){const[e,t]=x.useState(),r=x.useCallback(()=>{lS().then(t,()=>t(null))},[]);x.useEffect(()=>(r(),pn(c=>{(c.endsWith("workspaces.json")||c.includes("workspaces/")||c.includes("leases/"))&&r()})),[r]);const o=x.useCallback(async c=>{const d=await fetch(lc,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)}),f=await d.json();if(!d.ok)return f.error??`Saving failed (${d.status})`;t(f)},[]),l=x.useCallback(async(c,d,f=!1)=>{const g=await fetch(`${lc}/remove`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:c,ticketId:d,force:f})}),m=await g.json();return g.ok?(t(m),{}):{error:m.error??`Removing failed (${g.status})`,dirty:m.dirty??!1}},[]);return{view:e,save:o,remove:l}}function vp(e){const[t,r]=x.useState(!1),[o,l]=x.useState(),[c,d]=x.useState(!1),f=async g=>{d(!0),l(void 0);const m=await e.onRemove(g).catch(v=>({error:v.message,dirty:!1}));d(!1),r(!!m.dirty&&!g),m.dirty||l(m.error)};return t?i.jsxs("span",{className:"ws-remove ask",children:[i.jsx("span",{className:"vf-err",children:"Uncommitted changes in this workspace will be lost."}),i.jsx(K,{size:"sm",disabled:c,onClick:()=>f(!0),children:"Remove anyway"}),i.jsx(K,{size:"sm",variant:"ghost",onClick:()=>r(!1),children:"Keep"})]}):i.jsxs("span",{className:"ws-remove",children:[i.jsx(K,{size:"sm",disabled:c,onClick:()=>f(!1),children:e.label??"Remove"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function cS(e){return e.rows.length?i.jsx("ul",{className:"ws-list",children:e.rows.map(t=>i.jsx(Ae,{as:"li",className:`ws-row ${t.active?"active":"finished"}`,title:i.jsx("span",{className:"t-code",children:t.branch}),titleText:t.branch,context:i.jsx(Q,{parts:[{text:t.ticketKey,code:!0},t.active?`Active · ${t.agent}`:"Finished"]}),detail:i.jsx("span",{className:"t-code",children:t.path}),detailText:t.path,below:t.active?void 0:i.jsx(vp,{onRemove:r=>e.onRemove(t.mapId,t.ticketId,r)})},`${t.mapId}/${t.ticketId}`))}):null}function uS(e){const{view:t,remove:r}=gp(),o=t==null?void 0:t.workspaces.find(l=>l.mapId===e.mapId&&l.ticketId===e.ticketId);return!o||o.active?null:i.jsxs("section",{className:"ticket-workspace d-section",children:[i.jsx("span",{className:"t-label",children:"Workspace"}),i.jsxs("p",{className:"t-meta",children:["Branch ",i.jsx("code",{className:"t-code",children:o.branch})," in"," ",i.jsx("code",{className:"t-code",title:o.path,children:o.path})]}),i.jsx(vp,{label:"Remove workspace",onRemove:l=>r(e.mapId,e.ticketId,l)})]})}function dS(){const{view:e,save:t,remove:r}=gp(),[o,l]=x.useState();if(!e)return null;const c=e.settings.worktrees,d=()=>{l(void 0),t({...e.settings,worktrees:!c}).then(l,f=>l(f.message))};return i.jsxs(He,{title:"Workspaces",children:[i.jsxs("p",{className:"vf-intro",children:["Give each agent its own copy of the repo for every ticket it claims, on its own branch, so agents working at the same time don't step on each other. You review and merge the branches; ",ve.name," never merges or pushes."]}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"A worktree per ticket"}),i.jsx(K,{size:"sm",on:c,"aria-pressed":c,className:"worktrees-toggle",onClick:d,children:c?"On":"Off"})]}),i.jsx(Q,{className:"set-hint",parts:[{text:`${ve.dataDir}/workspaces.json`,code:!0},Mh(e.workspaces.filter(f=>f.active).length,"active"),Mh(e.workspaces.filter(f=>!f.active).length,"finished")]}),i.jsx(cS,{rows:e.workspaces,onRemove:r}),e.errors.length>0&&i.jsx("ul",{className:"vf-errors",children:e.errors.map(f=>i.jsx("li",{children:f},f))}),o&&i.jsx("span",{className:"vf-err",children:o})]})}const Mh=(e,t)=>`${e} ${t}`;function fS({data:e,route:t}){return i.jsxs(i.Fragment,{children:[i.jsx(it,{id:"tracker",children:i.jsx(He,{title:"Tracker",children:i.jsx(lN,{activeTracker:e.activeTracker,location:e.location,update:e.update})})}),i.jsx(it,{id:"workspaces",storage:"repo",children:i.jsx(dS,{})}),i.jsx(it,{id:"policy",storage:"repo",children:i.jsx(aS,{})}),i.jsx(it,{id:"guides",storage:"repo",children:i.jsx(QN,{focus:t.section==="guides"})}),i.jsx(it,{id:"labels",children:i.jsx(He,{title:"Labels",children:i.jsxs("div",{className:"label-codes",children:[i.jsx("code",{children:dc}),i.jsxs("code",{children:[ve.labelPrefix,":<type>"]}),i.jsx("code",{children:fc}),i.jsx("code",{children:hc})]})})})]})}const cc=`${ve.apiPrefix}/projects`;async function fo(e,t,r){const o=await fetch(`${cc}${e}`,{method:t,headers:{"Content-Type":"application/json"},body:r===void 0?void 0:JSON.stringify(r)}),l=await o.json().catch(()=>({}));if(!o.ok)throw new Error(l.error??`HTTP ${o.status}`);return l}const zs={url:cc,add:e=>fo("","POST",{path:e}),remove:e=>fo(`/${e}`,"DELETE"),setAutoRegister:e=>fo("/settings","PUT",{autoRegister:e}),answer:(e,t)=>fo(`/${e}/answer`,"POST",t),async briefing(e){const t=await fetch(`${cc}/briefing?since=${e}`);return t.ok?await t.json():void 0}};function kp(e){const[t,r]=x.useState(""),[o,l]=x.useState(),c=d=>{d.trim()&&(l(void 0),zs.add(d.trim()).then(()=>(r(""),e.onAdded()),f=>l(f.message)))};return i.jsxs("div",{className:"pj-add",children:[i.jsx(Nc,{value:t,onValueChange:r,onSubmit:c,action:"Add project",placeholder:`/path/to/repo (a ${ve.dataDir} folder is created if missing)`,"aria-label":"Repo path",className:"t-code"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}const Ms=(e,t)=>e>0&&`${e} ${t}`;function hS(e){var r;const t=((r=e.briefing)==null?void 0:r.projects)??[];return!e.briefing||!t.length?null:i.jsxs("section",{className:"pj-section pj-briefing",children:[i.jsx(Ct,{title:"While you were away",count:t.length,info:`What changed in each project since ${nn(e.now-e.briefing.since)} ago`}),i.jsx("ul",{className:"pj-list",children:t.map(({projectId:o,project:l,briefing:c})=>i.jsx(Ae,{as:"li",edge:c.totals.waiting>0?"attention":"neutral",title:l,context:i.jsx(Q,{parts:[Ms(c.totals.done,"done"),Ms(c.trails.reduce((d,f)=>d+f.opened.length,0),"new tickets"),Ms(c.totals.agentDecisions,"agent decisions"),Ms(c.totals.waiting,"waiting on you"),Ms(c.totals.ruledOut,"ruled out"),Ms(c.totals.active,"agents active")]}),onOpen:()=>e.onOpen(o)},o))})]})}function mS(e){const[t,r]=x.useState(""),[o,l]=x.useState(!1),[c,d]=x.useState(),f=g=>{!g.trim()||o||(l(!0),d(void 0),e.onAnswer(g.trim()).then(()=>r(""),m=>d(m.message)).finally(()=>l(!1)))};return i.jsxs("div",{className:"pj-answer",children:[i.jsx(Nc,{value:t,onValueChange:r,onSubmit:f,action:"Answer",disabled:o,placeholder:"Your answer","aria-label":"Your answer"}),c&&i.jsx("span",{className:"vf-err",children:c})]})}function pS(e){const{item:t}=e,r=Qm(t),o=t.kind==="question"&&t.agent?`${t.agent} asks`:Vm[t.kind],l=t.urgency==="blocking"&&{text:"Blocking",urgent:!0,className:"urgency-tag"};return i.jsx(Ae,{as:"li",className:`att-item pj-item k-${t.kind}`,edge:Gm(t,t.interrupting),title:t.title.split(`
|
|
129
|
-
`)[0],titleText:t.title,context:i.jsx(
|
|
130
|
-
`),trailing:nn(e.now-t.since),onOpen:e.onOpen,below:e.onAnswer&&i.jsx(mS,{onAnswer:e.onAnswer})})}function gS(e){const t=e.view.attention,r=o=>{var l;return((l=e.view.projects.find(c=>c.id===o))==null?void 0:l.state.kind)!=="missing"};return i.jsxs("section",{className:"pj-section pj-attention",children:[i.jsx(Ct,{title:"Needs you",count:t.length,hot:t.some(o=>o.interrupting),info:"One queue across projects, ranked the way each project ranks its own. Answer questions here; the agent in that repo gets the answer."}),t.length===0&&i.jsx(Dn,{title:"Nothing needs you",hint:"Agents in every project can keep going."}),i.jsx("ul",{className:"pj-list",children:t.map(o=>i.jsx(pS,{item:o,now:e.now,onOpen:()=>e.onOpen(o.projectId,o.id),onAnswer:o.kind==="question"&&r(o.projectId)?l=>zs.answer(o.projectId,{questionId:o.ref,text:l}).then(e.onAnswered):void 0},`${o.projectId}/${o.id}`))})]})}const Vl=(e,t,r=`${t}s`)=>`${e} ${e===1?t:r}`;function vS(e){return e.interrupting>0?"urgent":e.phases.blocked+e.phases.rework+e.flags+e.stalled>0||e.state.kind==="missing"?"attention":"neutral"}function kS(e){if(e.state.kind==="missing")return[{text:"Missing",strong:!0},{text:e.path,code:!0}];const t=[];e.needsYou&&t.push({text:`${e.needsYou} ${e.needsYou===1?"needs":"need"} you`,strong:!0,urgent:e.interrupting>0}),e.agents&&t.push(Vl(e.agents,"agent"));const{working:r,verifying:o,rework:l,blocked:c}=e.phases;r&&t.push(`${r} working`),o&&t.push(`${o} verifying`),l&&t.push(`${l} rework`),c&&t.push(`${c} blocked`),e.flags&&t.push(Vl(e.flags,"PR flag")),e.stalled&&t.push(Vl(e.stalled,"stalled claim")),t.length||t.push(e.trails?"Nothing waiting":"No trails yet");const d=yS(e.tracker);return d&&t.push(d),t}function yS(e){if(e.kind==="github"&&e.repo)return`Issues in ${e.repo}`;if(!(e.kind!=="linear"||!e.team))return e.org?`Linear: ${e.team} in ${e.org}`:`Linear: ${e.team}`}function xS(e){var t;return e.state.kind==="elsewhere"?`Served by another Lookout · ${e.state.url}`:((t=e.top)==null?void 0:t.title)??e.note??e.path}function bo(e,t,r){if(e.state.kind!=="missing"){if(e.state.kind==="elsewhere"){const o=new URL(e.state.url);r&&o.searchParams.set(Ps,r),window.open(o.toString(),"_blank","noopener");return}location.href=Vx({id:e.id,home:t,tracker:e.tracker.kind,item:r})}}function yp(e){const{p:t}=e,r=xS(t);return i.jsx(Ae,{as:"li",className:`project-card st-${t.state.kind}`,edge:vS(t),selected:e.current,title:t.name,titleText:t.path,context:i.jsx(Q,{parts:kS(t)}),detail:r,detailText:r,trailing:t.lastActivity?nn(e.now-t.lastActivity):void 0,onOpen:e.onOpen})}const xp=`${Eo}:projects:seen`,Ah=24*36e5;function wS(e){try{const t=Number(localStorage.getItem(xp));return t>0?t:e-Ah}catch{return e-Ah}}function jS(e){try{localStorage.setItem(xp,String(e))}catch{}}function NS(){const[e,t]=x.useState();return x.useEffect(()=>{const r=Date.now();return zs.briefing(wS(r)).then(t).catch(()=>{}),()=>jS(r)},[]),e}function SS(e){const{view:t,reload:r}=e.projects,o=sn(15e3),l=NS();if(x.useEffect(()=>{const g=m=>m.key==="Escape"&&e.onClose();return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[e]),!t)return null;const c=Do()??t.home,d=g=>{const m=t.projects.find(v=>v.id===g);(m==null?void 0:m.id)===c?e.onClose():m&&bo(m,t.home)},f=(g,m)=>{const v=t.projects.find(y=>y.id===g);if(v){if(v.id!==c)return bo(v,t.home,m);e.onClose(),e.onItemHere(m)}};return i.jsxs(Ke,{className:`zone decisions-view projects-view dv-${e.bp}`,children:[i.jsxs("header",{className:"dv-head",children:[i.jsx(Je,{as:"h2",children:"All projects"}),i.jsx("span",{className:"dv-head-right",children:i.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})})]}),i.jsxs("div",{className:"pj-body",children:[i.jsx(gS,{view:t,now:o,onOpen:f,onAnswered:r}),i.jsxs("section",{className:"pj-section pj-projects",children:[i.jsx(Ct,{title:"Projects",count:t.projects.length,info:"Each repo registered on this machine, read from its own files. Nothing leaves your machine."}),i.jsx("ul",{className:"pj-list",children:t.projects.map(g=>i.jsx(yp,{p:g,current:g.id===c,now:o,onOpen:g.state.kind==="missing"?void 0:()=>d(g.id)},g.id))}),i.jsx(kp,{onAdded:r})]}),i.jsx(hS,{briefing:l,now:o,onOpen:d})]})]})}function bS(e){const[t,r]=x.useState(!1),o=x.useRef(null);x.useEffect(()=>{if(!t)return;const f=g=>{var m;(g instanceof KeyboardEvent?g.key==="Escape":!((m=o.current)!=null&&m.contains(g.target)))&&r(!1)};return window.addEventListener("mousedown",f),window.addEventListener("keydown",f),()=>{window.removeEventListener("mousedown",f),window.removeEventListener("keydown",f)}},[t]);const{view:l}=e.projects;if(!l||!e.projects.many)return i.jsx("span",{className:"repo",children:e.repo});const c=Do()??l.home,d=l.projects.filter(f=>f.id!==c).reduce((f,g)=>f+g.interrupting,0);return i.jsxs("div",{className:"project-switcher",ref:o,children:[i.jsxs("button",{className:"project-btn repo",onClick:()=>r(f=>!f),"aria-haspopup":"menu","aria-expanded":t,"data-tip":"Switch project, or see all of them",children:[i.jsx("span",{className:"project-name",children:e.repo}),d>0&&i.jsx(ts,{n:d,urgent:!0}),i.jsx("span",{className:"caret",children:"▾"})]}),t&&i.jsxs("div",{className:"trail-menu",role:"menu",children:[i.jsxs("button",{role:"menuitem",className:"trail-item all-projects",onClick:()=>{r(!1),e.onOverview()},children:[i.jsx("span",{className:"mi-title",children:"All projects"}),i.jsx(ts,{n:l.attention.length,urgent:l.attention.some(f=>f.interrupting),hideZero:!0})]}),i.jsx(Je,{variant:"plain",className:"menu-h",children:"Projects"}),l.projects.map(f=>i.jsxs("button",{role:"menuitem",className:`trail-item ${f.id===c?"on":""} st-${f.state.kind}`,disabled:f.state.kind==="missing",onClick:()=>{r(!1),f.id!==c&&bo(f,l.home)},children:[i.jsx("span",{className:"mi-title",children:f.name}),i.jsx("span",{className:"mi-progress",children:CS(f.state.kind)}),i.jsx(ts,{n:f.needsYou,urgent:f.interrupting>0,hideZero:!0})]},f.id))]})]})}function CS(e){return e==="missing"?"missing":e==="elsewhere"?"other Lookout":""}function $S(e){const t=sn(15e3),{view:r}=e.projects;if(!r||!e.projects.many)return null;const o=Do()??r.home;return i.jsxs("section",{className:"phone-projects",children:[i.jsx(Ct,{title:"Projects",count:r.projects.length,right:i.jsx(K,{size:"sm",variant:"ghost",onClick:e.onOverview,children:"All projects"})}),i.jsx("ul",{className:"pj-list",children:r.projects.filter(l=>l.id!==o).map(l=>i.jsx(yp,{p:l,current:!1,now:t,onOpen:l.state.kind==="missing"?void 0:()=>bo(l,r.home)},l.id))})]})}function wp(){const[e,t]=x.useState(),r=x.useCallback(()=>{fetch(zs.url).then(o=>o.ok?o.json():void 0).then(o=>o&&t(o)).catch(()=>{})},[]);return x.useEffect(()=>Fo("projects",o=>t(JSON.parse(o))),[]),x.useEffect(r,[r]),{view:e,many:((e==null?void 0:e.projects.length)??0)>1,reload:r}}const TS=e=>[e.home&&{text:"This Lookout",strong:!0},e.state.kind==="missing"&&"Missing",{text:e.path,code:!0}];function ES(){const{view:e,reload:t}=wp(),[r,o]=x.useState();if(!e)return null;const l=c=>{o(void 0),c.then(t,d=>o(d.message))};return i.jsxs(He,{title:"Projects",children:[i.jsx("p",{className:"vf-intro",children:"Supervise several repos from this Lookout: All projects shows what needs you in each of them. The list lives in your config folder on this machine, never in a repo, and agents only ever work in their own repo."}),i.jsx("ul",{className:"pj-list set-projects",children:e.projects.map(c=>i.jsx(Ae,{as:"li",edge:c.state.kind==="missing"?"attention":"neutral",title:c.name,context:i.jsx(Q,{parts:TS(c)}),actions:!c.home&&i.jsx(K,{size:"sm",variant:"ghost",onClick:()=>l(zs.remove(c.id)),children:"Remove"})},c.id))}),i.jsx(kp,{onAdded:t}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Agents add their repo when they connect"}),i.jsx(K,{size:"sm",on:e.autoRegister,"aria-pressed":e.autoRegister,className:"auto-register-toggle",onClick:()=>l(zs.setAutoRegister(!e.autoRegister)),children:e.autoRegister?"On":"Off"})]}),i.jsx(Q,{className:"set-hint",parts:[{text:`${ve.slug} projects add <path>`,code:!0},`--no-register or ${ve.noRegisterEnv} opts one agent out`]}),r&&i.jsx("span",{className:"vf-err",children:r})]})}const IS=`${ve.apiPrefix}/models`;function Oc(){const[e,t]=x.useState(),r=x.useCallback(()=>{fetch(IS).then(o=>o.ok?o.json():null).then(t,()=>t(null))},[]);return x.useEffect(()=>{r();const o=pn(c=>{(c.endsWith("models.json")||c.endsWith("map.md")||c.includes("/tickets/"))&&r()}),l=Fo("attention",r);return()=>{o(),l()}},[r]),e}function MS({mapId:e,ticketId:t}){const r=Oc(),o=r==null?void 0:r.waiting.find(l=>l.mapId===e&&l.ticketId===t);return o?i.jsx(Ae,{className:"model-wait d-section",edge:"attention",title:`Needs a ${o.tier} model`,context:i.jsx(Q,{parts:[`Connected agents run ${o.best} at most`]}),detail:`Connect an agent on a ${o.tier} model, or have one claim ${o.ticketKey} by key.`}):null}function AS({view:e}){if(!e)return null;const t=`${ve.dataDir}/${e.file}`,r=Object.keys(e.models).length,o=e.agents.map(l=>`${l.agent} ${l.tier}`).join(", ");return i.jsxs(i.Fragment,{children:[i.jsx(Q,{className:"set-hint",parts:[{text:t,code:!0},e.exists?`${r} of your own models`:"add new or custom models here","unknown models count as balanced"]}),o&&i.jsx(Q,{className:"set-hint models-connected",parts:[`Connected now: ${o}`]}),e.errors.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[t," has errors, so only the built-in models count until it is fixed."]})]}),i.jsx("ul",{className:"vf-errors",children:e.errors.map(l=>i.jsx("li",{children:l},l))})]})]})}const jp={fast:"Fast",balanced:"Balanced",strongest:"Strongest"},LS={fast:"Haiku, mini and nano models",balanced:"Sonnet, GPT-4 models",strongest:"Opus, GPT-5 and o-series models"},RS=sm.map(e=>({value:e,label:jp[e],hint:LS[e]}));function OS(e){return i.jsx("div",{className:"tier-grid",children:Mo.map(t=>{const r=e.tiers[t],o=pc[t];return i.jsxs("div",{className:"tier-row",children:[i.jsx("span",{children:zi[t]}),i.jsx(ct,{compact:!0,"aria-label":`${zi[t]} tickets' model`,className:`tier-select tier-${t}`,value:r,options:RS,onChange:l=>e.onChange(t,l)}),i.jsx(Q,{className:"tier-hint",parts:[r!==o&&`default ${jp[o].toLowerCase()}`,e.hints[t]]})]},t)})})}const ho=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function PS({rows:e}){return e.length?i.jsx("ul",{className:"perf-rows",children:e.map(t=>i.jsx(Ae,{as:"li",className:"perf-row",title:t.key,trailing:i.jsx("span",{title:"Median time from first claim to done",children:en(t.medianLeadMs)}),context:i.jsx(Q,{parts:[`${t.done} of ${ho(t.tickets,"ticket")} done`,t.cancelled>0&&`${t.cancelled} cancelled`,ho(t.reworkCycles,"rework"),`reviews ${t.reviews.passed} passed, ${t.reviews.failed} failed`,t.answers>0&&ho(t.answers,"question")]}),detail:t.findings.raised>0?`As reviewer: ${t.findings.upheld} of ${ho(t.findings.raised,"finding")} upheld`:void 0},t.key))}):i.jsx(Ee,{children:"No claimed tickets yet"})}function Np(e){const[t,r]=x.useState({}),o=e.map(l=>`${l.map.id}:${l.tickets.reduce((c,d)=>Math.max(c,d.updatedAt),0)}`).join();return x.useEffect(()=>{let l=!0;return Promise.all(e.map(async c=>{const d=await fetch(`${Se()}/journal?mapId=${encodeURIComponent(c.map.id)}`).catch(()=>{}),f=d!=null&&d.ok?await d.json():{entries:[]};return[c.map.id,f.entries]})).then(c=>{l&&r(Object.fromEntries(c))}),()=>{l=!1}},[o]),t}const _S=[{id:"byVendor",title:"By vendor"},{id:"byAgent",title:"By agent"},{id:"byType",title:"By ticket type"}];function DS({api:e,bp:t,onClose:r}){const[o,l]=x.useState("byVendor"),c=x.useMemo(()=>Object.values(e.allSnaps),[e.allSnaps]),d=Np(c),f=e.activity.answered,g=x.useMemo(()=>wm(c.map(m=>({snap:m,journal:d[m.map.id]??[],answered:f}))),[c,d,f]);return x.useEffect(()=>{const m=v=>v.key==="Escape"&&r();return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[r]),i.jsxs(Ke,{className:`zone decisions-view perf-view dv-${t}`,children:[i.jsxs("header",{className:"dv-head",children:[i.jsx(Je,{as:"h2",children:"Trail stats"}),i.jsx(Q,{parts:[`${g.trails} trails`,`${g.tickets} tickets`]}),i.jsx("span",{className:"dv-head-right",children:i.jsx("button",{className:"icon-btn",onClick:r,"aria-label":"Close",children:"×"})})]}),i.jsxs("div",{className:"perf-body",children:[i.jsxs("section",{className:"perf-section",children:[i.jsx(Je,{as:"h3",children:"What stands out"}),i.jsx("p",{className:"perf-note t-meta",children:"From your own numbers, for you to act on or ignore. Teamtrail doesn't route work from these."}),g.recommendations.length?i.jsx("ul",{className:"perf-recs",children:g.recommendations.map(m=>i.jsxs("li",{title:m.because,children:[i.jsx("span",{children:m.text}),i.jsx("span",{className:"t-meta",children:m.because})]},m.id))}):i.jsx(Ee,{children:"Nothing yet. This needs at least 5 results from two vendors to compare."})]}),i.jsxs("section",{className:"perf-section",children:[i.jsx("div",{className:"choice-row compact",children:_S.map(m=>i.jsx(ht,{on:o===m.id,title:m.title,onClick:()=>l(m.id)},m.id))}),i.jsx(PS,{rows:g[o]}),i.jsx("p",{className:"perf-note t-meta",children:"Spend is tracked per trail, so it isn't split by agent here."})]})]})]})}function BS(e,t){const r=Np(e);return x.useMemo(()=>{var c;const o=wm(e.map(d=>({snap:d,journal:r[d.map.id]??[],answered:t}))),l={};for(const d of o.byType){if(!d.done)continue;const f=(c=o.recommendations.find(m=>m.id===`speed-${d.key}`))==null?void 0:c.text,g=[`Trail stats: ${d.done} done`,d.medianLeadMs!==void 0&&`median ${en(d.medianLeadMs)}`,d.reworkCycles>0&&`${d.reworkCycles} back to rework`,f];l[d.key]=g.filter(Boolean).join(" · ")}return l},[e,r,t])}function zS(e){var d,f;const t=Oc(),r=BS(e.snaps,e.answered),o=e.map;if(!o)return null;const l=!!((d=o.modelMatching)!=null&&d.enabled),c=((f=o.modelMatching)==null?void 0:f.tiers)??{};return i.jsxs(He,{title:"Model matching",children:[i.jsx("p",{className:"vf-intro",children:"Give each agent the tickets that fit the model it runs on: research to fast models, junctions, prototypes and reviews to the strongest. Teamtrail reads the model from the agent's log and never switches it. An agent can still claim any ticket by name, and tells you when it does."}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsxs("span",{className:"set-field-label",children:["Match work to models on trail ",o.key]}),i.jsx(K,{size:"sm",on:l,"aria-pressed":l,className:"model-matching-toggle",onClick:()=>e.onChange({...o.modelMatching,enabled:!l}),children:l?"On":"Off"})]}),l&&i.jsx(OS,{tiers:Fv(o),hints:r,onChange:(g,m)=>{const v={...c,[g]:m};m===pc[g]&&delete v[g],e.onChange({enabled:!0,tiers:v})}}),l&&i.jsx("span",{className:"set-hint t-meta",children:"Changes apply to the next claim; nothing running is interrupted."}),i.jsx(AS,{view:t})]})}function FS(){const[e,t]=x.useState();return x.useEffect(()=>{let r=!0;return fetch(`${Se()}/verification/config`).then(o=>o.ok?o.json():null).then(o=>r&&t(o),()=>r&&t(null)),()=>{r=!1}},[]),e}const Lh=`{
|
|
123
|
+
${r.briefText}`)},4e3,l=>r.stale[l.id]??[]);return i.jsxs("div",{className:"kn-preview d-section",children:[i.jsxs("span",{className:"t-label","data-tip":"Picked by paths, words, trail and kind; confirmed entries and assumptions only",children:["Knowledge this agent gets · ",o.length]}),o.length>0&&i.jsx("ul",{className:"item-list inline",children:o.map(l=>i.jsxs("li",{children:[i.jsx("button",{className:"item-text kn-open",onClick:()=>r.setOpen(!0),"data-tip":l.why.join(" · "),children:l.title}),i.jsx(q,{parts:[{text:l.id,code:!0},l.status==="assumption"&&"assumption",l.mayBeOutdated&&{text:"may be outdated",className:"warn"}]})]},l.id))})]})}const Uw={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 Hw({e}){const t=Ks(),[r,o]=x.useState(!1),[l,c]=x.useState(e.title),[d,f]=x.useState(e.body);x.useEffect(()=>{o(!1),c(e.title),f(e.body)},[e.id,e.title,e.body]);const g=t.stale[e.id];return i.jsxs("div",{className:"kn-detail",children:[i.jsx(q,{parts:[{text:e.id,code:!0},e.kind.replace("-"," "),e.status]}),r?i.jsxs(i.Fragment,{children:[i.jsx(Ye,{label:"Title",children:i.jsx("input",{value:l,onChange:m=>c(m.target.value)})}),i.jsx(Ye,{label:"Body",children:i.jsx("textarea",{rows:8,value:d,onChange:m=>f(m.target.value)})})]}):i.jsxs(i.Fragment,{children:[i.jsx("h3",{className:"t-title",children:e.title}),i.jsx("p",{className:"kn-body",children:e.body})]}),i.jsx("p",{className:"dim",children:Uw[e.status]}),e.flag&&i.jsxs("p",{className:"kn-warn",children:["Flagged by ",e.flag.by,": ",e.flag.reason]}),g&&e.status!=="outdated"&&i.jsxs("p",{className:"kn-warn",children:["May be outdated: ",g.join(", ")," changed since it was confirmed. Re-confirm or edit it."]}),i.jsxs("dl",{className:"facts",children:[e.scope.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Applies to"}),i.jsx("dd",{children:e.scope.join(", ")})]}),e.tags.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Tags"}),i.jsx("dd",{children:e.tags.join(", ")})]}),i.jsx("dt",{children:"From"}),i.jsx("dd",{children:[e.createdBy,...e.sources].join(" · ")}),e.anchors.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"About files"}),i.jsx("dd",{children:e.anchors.map(m=>m.path).join(", ")})]})]}),t.error&&i.jsx("p",{className:"vf-err",children:t.error}),i.jsx("div",{className:"actions",children:r?i.jsxs(i.Fragment,{children:[i.jsx(K,{variant:"ghost",onClick:()=>o(!1),children:"Cancel"}),i.jsx(K,{variant:"primary",disabled:!l.trim(),onClick:()=>void t.call(e.id,{kind:"edit",title:l,body:d}).then(m=>m&&o(!1)),children:"Save"})]}):i.jsxs(i.Fragment,{children:[(e.status!=="confirmed"||g)&&i.jsx(K,{variant:"primary",onClick:()=>void t.call(e.id,{kind:"confirm"}),children:e.status==="confirmed"?"Re-confirm":"Confirm"}),e.status!=="assumption"&&e.status!=="outdated"&&i.jsx(K,{onClick:()=>void t.call(e.id,{kind:"assumption"}),children:"Keep as assumption"}),e.flag&&i.jsx(K,{onClick:()=>void t.call(e.id,{kind:"resolve-flag"}),children:"Resolve flag"}),i.jsx(K,{variant:"ghost",onClick:()=>o(!0),children:"Edit"}),e.status!=="outdated"&&i.jsx(K,{variant:"ghost",onClick:()=>void t.call(e.id,{kind:"outdated"}),children:"Mark outdated"})]})})]})}const Ww={suggested:"Suggested",confirmed:"Confirmed",assumption:"Assumption",outdated:"Outdated"};function Kw(){const e=Ks(),[t,r]=x.useState("review"),[o,l]=x.useState(""),[c,d]=x.useState(""),[f,g]=x.useState();x.useEffect(()=>{if(!e.open)return;const N=E=>E.key==="Escape"&&e.setOpen(!1);return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[e]);const m=N=>N.status==="suggested"||!!N.flag||!!e.stale[N.id]&&N.status!=="outdated",v=(N,E)=>E==="all"?!0:E==="review"?m(N):N.status===E,y=x.useMemo(()=>{const N=c.trim().toLowerCase();return e.entries.filter(E=>v(E,t)&&(!o||E.kind===o)&&(!N||`${E.id} ${E.title} ${E.body} ${E.tags.join(" ")}`.toLowerCase().includes(N)))},[e.entries,e.stale,t,o,c]);if(!e.open)return null;const w=y.find(N=>N.id===f)??y[0],j=N=>e.entries.filter(E=>v(E,N)).length,$=[["review","Needs you"],["confirmed","Confirmed"],["assumption","Assumptions"],["outdated","Outdated"],["all","All"]];return i.jsx("div",{className:"scrim",onClick:()=>e.setOpen(!1),children:i.jsxs(Ke,{as:"div",className:"dialog knowledge-view",onClick:N=>N.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:"Field guide"}),i.jsx(Us,{text:"What agents need to know about this codebase and product. Agents propose entries; only confirmed ones and assumptions reach them, picked for each ticket with the reason. Entries about files are flagged here when those files change. Seed it from a document with: teamtrail knowledge import <file.md>"})]}),i.jsxs("div",{className:"kn-filters",children:[$.map(([N,E])=>i.jsxs("button",{className:`chip ${t===N?"on":""}`,onClick:()=>r(N),children:[E," ",i.jsx("span",{className:"n",children:j(N)})]},N)),i.jsx(ct,{compact:!0,"aria-label":"Kind",value:o,onChange:l,options:[{value:"",label:"Any kind"},...Sy.map(N=>({value:N,label:N.replace("-"," ")}))]}),i.jsx("input",{className:"kn-search",placeholder:"Search",value:c,onChange:N=>d(N.target.value)})]}),i.jsxs("div",{className:"kn-body-grid",children:[i.jsx("ul",{className:"kn-list",children:y.length?y.map(N=>i.jsx(Ae,{as:"li",className:`kn-row st-${N.status}`,edge:m(N)?"attention":"neutral",selected:N===w,onOpen:()=>g(N.id),title:N.title,titleText:N.title,context:i.jsx(q,{parts:[{text:N.id,code:!0},N.kind.replace("-"," "),m(N)&&N.status!=="suggested"?"Needs a check":Ww[N.status]]})},N.id)):i.jsx(Ee,{children:t==="review"?"Nothing needs you":"No entries"})}),w?i.jsx(Hw,{e:w}):i.jsx(Ee,{children:"Pick an entry"})]})]})})}function $c({draft:e,label:t="Save as knowledge"}){const r=Ks(),[o,l]=x.useState();return o?i.jsxs(K,{size:"sm",variant:"ghost",onClick:()=>r.setOpen(!0),"data-tip":"Open it in the field guide to confirm it",children:["Saved as ",o]}):i.jsx(K,{size:"sm",variant:"ghost","data-tip":"Add it to the field guide as a suggestion; confirm it there and agents get it with related work",onClick:()=>void r.propose(e()).then(c=>c&&l(c.id)),children:t})}const Hm=`${Se()}/knowledge`;async function hh(e,t){const r=await fetch(`${Hm}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),o=await r.json().catch(()=>({}));if(!r.ok)throw new Error(o.error??`HTTP ${r.status}`);return o}function Vw(e){const[t,r]=x.useState([]),[o,l]=x.useState({}),[c,d]=x.useState(!1),[f,g]=x.useState(),m=x.useCallback(()=>{fetch(Hm).then(y=>y.ok?y.json():null).then(y=>{y&&(r(y.entries),l(y.stale))}).catch(()=>{})},[]);x.useEffect(()=>(m(),pn(y=>y.startsWith("knowledge/")&&m())),[m]);const v=x.useMemo(()=>t.filter(y=>y.status==="suggested"||y.flag||o[y.id]&&y.status!=="outdated").length,[t,o]);return{entries:t,stale:o,briefText:e,attention:v,open:c,setOpen:d,error:f,call:(y,w)=>hh("/call",{id:y,call:w}).then(()=>(g(void 0),m(),!0),j=>(g(j.message),!1)),propose:y=>hh("/propose",y).then(w=>(m(),w.entry),w=>(g(w.message),void 0))}}function rc(e){const[t,r]=x.useState(!1),[o,l]=x.useState(""),c=async()=>{let d="";try{d=await navigator.clipboard.readText()}catch{r(!0);return}d.trim()?e.onToken(d,!0):r(!0)};return i.jsxs("div",{className:"sl-paste",children:[i.jsx(K,{variant:"primary",disabled:e.busy,onClick:()=>void c(),children:e.busy?"Checking…":"Paste"}),t?i.jsxs("form",{className:"sl-paste-field",onSubmit:d=>{d.preventDefault(),e.onToken(o,!0),l("")},children:[i.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,autoFocus:!0,value:o,placeholder:e.placeholder,"aria-label":"Token",onChange:d=>l(d.target.value)}),i.jsx(K,{type:"submit",disabled:e.busy||!o.trim(),children:"Save"})]}):i.jsx("button",{type:"button",className:"link",onClick:()=>r(!0),children:"Type it instead"})]})}const Gw=["awaiting","blocked","trail.done","resolved"],Qw=["commands","chat:write","im:write","channels:history","groups:history","im:history","mpim:history","users:read"],qw=["users:read.email"],Yw="save_decision",Jw=`/${ve.assistant.name.toLowerCase()}`;function Xw(e={}){const t=ve.assistant.name;return{display_information:{name:t,description:`${ve.name} decisions and agent questions`,background_color:"#1b2226"},features:{app_home:{home_tab_enabled:!0,messages_tab_enabled:!0,messages_tab_read_only_enabled:!1},bot_user:{display_name:t,always_online:!0},slash_commands:[{command:e.command??Jw,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:Yw,description:`Record this thread as a ${ve.name} decision`}]},oauth_config:{scopes:{bot:[...Qw,...qw]}},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 Zw={create:e=>`https://api.slack.com/apps?new_app=1&manifest_json=${encodeURIComponent(JSON.stringify(Xw({command:e})))}`,app:e=>`https://api.slack.com/apps/${e}/general`,install:e=>`https://api.slack.com/apps/${e}/install-on-team`,home:(e,t)=>`slack://app?team=${e}&id=${t}&tab=home`,homeWeb:(e,t)=>`https://slack.com/app_redirect?app=${t}&team=${e}`};function ej(e){const t=e.trim().match(/^xapp-\d+-(A[A-Z0-9]+)-/);return t==null?void 0:t[1]}async function es(e,t="GET",r){const o=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:r===void 0?void 0:JSON.stringify(r)}),l=await o.json().catch(()=>({}));if(!o.ok&&!l.status)throw new Error(l.error??`request failed (${o.status})`);return l}function tj(e){const t=`${e}/slack`;return{get:()=>es(t),created:()=>es(`${t}/created`,"POST",{}),token:r=>es(`${t}/token`,"POST",{token:r}),update:r=>es(`${t}/settings`,"PUT",r),resetOwner:()=>es(`${t}/owner/reset`,"POST",{}),members:()=>es(`${t}/members`).then(r=>r.members),remove:()=>es(t,"DELETE")}}const Bn=tj(Se());function nj(e){const[t,r]=x.useState(!1),[o,l]=x.useState(),c=d=>{r(!0),Bn.token(d).then(f=>{r(!1),l(f.ok?void 0:f.error),e.set(f.status)},f=>{r(!1),l(f.message)})};return i.jsxs(i.Fragment,{children:[i.jsx(rc,{busy:t,placeholder:"xapp-… or xoxb-…",onToken:c}),o&&i.jsxs("div",{className:"test-line alert",children:["✕ ",o]})]})}function sj({onRemoved:e}){const[t,r]=x.useState(!1);if(!t)return i.jsx(K,{size:"sm",variant:"ghost",onClick:()=>r(!0),children:"Remove"});const o=()=>void Bn.remove().then(l=>{r(!1),e(l)},()=>{});return i.jsxs(i.Fragment,{children:[i.jsx(K,{size:"sm",variant:"danger",onClick:o,children:"Remove tokens and settings"}),i.jsx(K,{size:"sm",variant:"ghost",onClick:()=>r(!1),children:"Keep"})]})}const ij={awaiting:"Awaiting you",blocked:"Blocked","trail.done":"Trail done",resolved:"Resolved"};function Wm({s:e}){const[t,r]=rj(e);return i.jsxs("div",{className:`sync-line ${t}`,title:e.error,children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:r})]})}function rj(e){switch(e.state){case"online":return["ok","Online"];case"connecting":return["","Connecting"];case"offline":return["warn","Offline · reconnecting"];case"auth-error":return["alert","Disconnected · Slack rejected the tokens"];case"elsewhere":{const t=e.heldBy?` (${e.heldBy})`:"";return["warn",`Connected from another ${ve.slug}${t}`]}case"unsupported":return["alert",e.error??"Not supported here"];default:return["",e.step==="done"?"Off":"Not connected"]}}function oj(e){const{s:t,setup:r}=e,o=t.step==="done";return i.jsxs(Ot,{className:lj(t,r),children:[i.jsxs("div",{className:"card-row",children:[i.jsx("b",{className:"choice-title t-row-title",children:"Your Scout app"}),o&&i.jsx(zn,{className:t.enabled?"on":"",children:t.enabled?"On":"Off"})]}),o&&i.jsx("div",{className:"c-loc",children:aj(t)}),o&&i.jsx(Wm,{s:t}),!o&&t.step===1&&!r&&i.jsx("p",{className:"sl-lead",children:"Answer agents and save threads as decisions from Slack. You create your own Scout app in your workspace; it runs from this machine and its tokens stay in your local credential store."}),i.jsxs("div",{className:"c-actions",children:[!o&&!r&&i.jsx(K,{size:"sm",variant:"primary",onClick:()=>e.onSetup(!0),children:t.step===1?"Connect":`Resume at step ${t.step}`}),o&&i.jsx(K,{size:"sm",on:t.enabled,onClick:e.onToggle,children:t.enabled?"Turn off":"Turn on"}),o&&t.state==="auth-error"&&i.jsx(K,{size:"sm",variant:"primary",onClick:()=>e.onSetup(!0),children:"Reconnect"}),t.step!==1&&i.jsx(sj,{onRemoved:e.onRemoved})]})]})}function aj(e){var r,o,l;const t=(o=(r=e.workspace)==null?void 0:r.url)==null?void 0:o.replace(/^https?:\/\/|\/$/g,"");return[(l=e.workspace)==null?void 0:l.name,t,e.setup.appId].filter(Boolean).join(" · ")}function lj(e,t){const r=e.step==="done";return`connector ${r&&e.enabled?"active":""} ${t||!r?"open":""}`}function cj(e){const[t,r]=x.useState(e.value==="dm"?"":e.value),o=/^[CG][A-Z0-9]{6,}$/.test(t.trim());return i.jsxs("form",{className:"sl-paste-field",onSubmit:l=>{l.preventDefault(),o&&e.onSave(t.trim())},children:[i.jsx("input",{value:t,spellCheck:!1,placeholder:"Channel ID, e.g. C0123ABCD","aria-label":"Channel ID",onChange:l=>r(l.target.value)}),i.jsx(K,{type:"submit",disabled:!o||t.trim()===e.value,children:"Save"})]})}function uj(e){const[t,r]=x.useState(),[o,l]=x.useState();x.useEffect(()=>{Bn.members().then(r,f=>l(f.message))},[]);const c=new Set(e.owners.map(f=>f.id)),d=new Set(e.value.map(f=>f.id));return o?i.jsxs("div",{className:"test-line alert",children:["✕ ",o]}):t?i.jsx("div",{className:"choice-row compact sl-members",children:t.map(f=>i.jsx(ht,{on:c.has(f.id)||d.has(f.id),disabled:c.has(f.id),title:`@${f.name??f.id}`,sub:c.has(f.id)?"Owner":void 0,onClick:()=>e.onChange(d.has(f.id)?e.value.filter(g=>g.id!==f.id):[...e.value,f])},f.id))}):i.jsx("span",{className:"t-meta",children:"Loading members…"})}function dj(e){const{s:t,patch:r}=e,[o,l]=x.useState(!1),c=new Set(t.notify.events),d=o||t.notify.target!=="dm",f=t.owners[0],g=m=>{const v=c.has(m)?t.notify.events.filter(y=>y!==m):[...t.notify.events,m];r({notify:{events:v}})};return i.jsxs("div",{className:"sl-groups",children:[i.jsxs("div",{className:"sl-group",children:[i.jsx(Je,{variant:"plain",size:"sm",children:"Owner"}),i.jsxs("div",{className:"sl-owner",children:[i.jsxs("b",{children:["@",(f==null?void 0:f.name)??(f==null?void 0:f.id)]}),(f==null?void 0:f.via)==="git-email"&&i.jsx("span",{className:"t-meta",children:"Matched your git email"}),i.jsx("button",{type:"button",className:"link",onClick:()=>void Bn.resetOwner().then(e.set,()=>{}),children:"Not you? Reset"})]})]}),i.jsxs("div",{className:"sl-group",children:[i.jsx(Je,{variant:"plain",size:"sm",children:"Allowed users"}),i.jsx(uj,{value:t.allow,owners:t.owners,onChange:m=>r({allow:m})})]}),i.jsxs("div",{className:"sl-group",children:[i.jsx(Je,{variant:"plain",size:"sm",children:"Notify"}),i.jsxs("div",{className:"choice-row compact",children:[i.jsx(ht,{on:!d,title:"DM to owner",onClick:()=>{l(!1),r({notify:{target:"dm",detail:"full"}})}}),i.jsx(ht,{on:d,title:"Channel",sub:t.notify.target!=="dm"?t.notify.target:void 0,onClick:()=>l(!0)})]}),d&&i.jsxs(i.Fragment,{children:[i.jsx(Ye,{label:"Channel ID (invite @Scout there first)",children:i.jsx(cj,{value:t.notify.target,onSave:m=>r({notify:{target:m}})})}),i.jsxs("div",{className:"choice-row compact",children:[i.jsx(ht,{on:t.notify.detail==="full",title:"Full questions",onClick:()=>r({notify:{detail:"full"}})}),i.jsx(ht,{on:t.notify.detail==="titles-only",title:"Titles only",onClick:()=>r({notify:{detail:"titles-only"}})})]})]}),i.jsx("div",{className:"choice-row compact",children:Gw.map(m=>i.jsx(ht,{on:c.has(m),title:ij[m],onClick:()=>g(m)},m))})]}),i.jsx(wo,{className:"dim",parts:[`${t.command} decide`,`${t.command} status`,`${t.command} inbox`,"Save as decision on any message"]})]})}function lo(e){return i.jsx("a",{className:`btn ${e.primary?"primary":""}`,href:e.href,target:"_blank",rel:"noreferrer",onClick:e.onClick,children:e.children})}function fj({s:e,n:t}){const r=hj(e,t);return r?i.jsx("span",{className:"t-meta",children:r}):null}function hj(e,t){var o;if(t===3)return e.setup.appId&&`app ${e.setup.appId}`;if(t===4)return e.workspace&&`${e.workspace.name} · @${((o=e.bot)==null?void 0:o.name)??"scout"}`;const r=e.owners[0];if(t===5&&r){const l=r.via==="git-email"?" · git email":"";return`owner ${r.name??r.id}${l}`}}const mh=[{n:1,title:"Create your app"},{n:2,title:"Workspace"},{n:3,title:"App token"},{n:4,title:"Install"},{n:5,title:"Claim"}],Tc=(e,t)=>e===t||e===2&&t===3,Km=(e,t)=>e==="done"||typeof e=="number"&&t<e&&!Tc(e,t);function ph(e,t){return Km(e,t)?"done":Tc(e,t)?"cur":""}const mj=/^(xapp-|xoxb-|xoxp-|xoxe)/,pj=typeof navigator<"u"&&/Mac|iP(hone|ad)/.test(navigator.platform)?"⌘V":"Ctrl+V";function gj(e){const t=x.useRef(e);t.current=e;const[r,o]=x.useState(!1);return x.useEffect(()=>{let l="";const c=(g,m)=>{const v=g.trim();return!mj.test(v)||!m&&v===l?!1:(l=v,t.current(v,m),!0)},d=g=>{var m;c(((m=g.clipboardData)==null?void 0:m.getData("text"))??"",!0)&&g.preventDefault()},f=async()=>{if(document.visibilityState==="visible")try{const g=await navigator.permissions.query({name:"clipboard-read"});o(g.state==="granted"),g.state==="granted"&&c(await navigator.clipboard.readText(),!1)}catch{}};return f(),document.addEventListener("paste",d),window.addEventListener("focus",f),document.addEventListener("visibilitychange",f),()=>{document.removeEventListener("paste",d),window.removeEventListener("focus",f),document.removeEventListener("visibilitychange",f)}},[]),r}function vj(e){var N;const{s:t,set:r}=e,[o,l]=x.useState(),[c,d]=x.useState(!1),[f,g]=x.useState(!1),m=(E,M)=>{const R=ej(E);M&&R&&!t.setup.botToken&&window.open(Zw.install(R),"_blank")&&g(!0),d(!0),Bn.token(E).catch(O=>({ok:!1,error:O.message,status:t})).then(O=>{d(!1),l(O),r(O.status)})},y=gj(m)?"come back to this tab":`press ${pj} here`,w=t.step,j=E=>{if(!o)return null;const M=!o.ok&&E===4==(w===4);return o.kind===(E===4?"bot":"app")||M?i.jsx("div",{className:`test-line ${o.ok?"ok":"alert"}`,children:kj(o)}):null},$={1:i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:["Create your app in Slack. It opens filled in from a manifest, so your app already has the ",t.command," command, Save as decision and Socket Mode."]}),i.jsx("div",{className:"sl-actions",children:i.jsx(lo,{primary:!0,href:t.links.create,onClick:()=>void Bn.created().then(r,()=>{}),children:"Create your Slack app"})})]}),2:i.jsxs("p",{children:["In Slack: pick your workspace → ",i.jsx("b",{children:"Next"})," → ",i.jsx("b",{children:"Create"}),". Your app lives in the workspace you pick."]}),3:i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:["Give your app a token so Scout can connect from this machine. On the page Slack just opened:"," ",i.jsx("b",{children:"App-Level Tokens"})," → ",i.jsx("b",{children:"Generate Token and Scopes"})," → name it ",i.jsx("code",{children:"teamtrail"})," → add"," ",i.jsx("code",{children:"connections:write"})," → ",i.jsx("b",{children:"Generate"})," → ",i.jsx("b",{children:"Copy"}),", then ",y,"."]}),i.jsx("div",{className:"sl-actions",children:i.jsx(rc,{busy:c,placeholder:"xapp-…",onToken:m})}),j(3),i.jsx(wo,{className:"dim",parts:["Waiting for the app-level token",t.links.create&&i.jsx("a",{href:t.links.create,target:"_blank",rel:"noreferrer",children:"Open the manifest again"},"again")]})]}),4:i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:["Install your app so Scout can post and DM you."," ",f?"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 ",y,"."]}),i.jsxs("div",{className:"sl-actions",children:[i.jsx(lo,{primary:!f,href:t.links.install,children:f?"Open install page again":"Install to workspace"}),i.jsx(rc,{busy:c,placeholder:"xoxb-…",onToken:m})]}),j(4)]}),5:i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:["Your git email doesn't match a member of ",((N=t.workspace)==null?void 0:N.name)??"the workspace",", so tell Scout who you are: open its Home tab in Slack and click ",i.jsx("b",{children:"This is me"}),". Scout sends you a DM, and questions from agents arrive there."]}),i.jsxs("div",{className:"sl-actions",children:[i.jsx(lo,{primary:!0,href:t.links.home,children:"Open Scout in Slack"}),t.links.homeWeb&&i.jsx(lo,{href:t.links.homeWeb,children:"Open in browser"})]}),i.jsx(Wm,{s:t})]})};return i.jsxs(Ot,{tone:"inset",className:"slack-setup",children:[i.jsxs("p",{className:"sl-own",children:["You create your own Scout app in your Slack workspace. It runs from this machine over Socket Mode; nothing goes through ",ve.name,". Prefer one click? Add to Slack is coming with ",ve.name," Cloud."]}),i.jsx("ol",{className:"pipeline sl-pipeline","aria-label":"Slack setup",children:mh.map(E=>i.jsxs("li",{className:ph(w,E.n),children:[i.jsx("i",{}),i.jsxs("span",{children:[E.n," ",E.title]})]},E.n))}),i.jsx("ol",{className:"sl-steps",children:mh.map(E=>{const M=Km(w,E.n),R=Tc(w,E.n);return i.jsxs("li",{className:ph(w,E.n),children:[i.jsxs("div",{className:"sl-step-h",children:[i.jsx("span",{className:"sl-n",children:M?"✓":E.n}),i.jsx("b",{children:E.title}),M&&i.jsx(fj,{s:t,n:E.n})]}),R&&i.jsx("div",{className:"sl-step-b",children:$[E.n]})]},E.n)})})]})}function kj(e){var t,r;return e.ok?e.kind==="app"?`✓ Socket Mode reachable · app ${e.status.setup.appId}`:`✓ Installed in ${(t=e.status.workspace)==null?void 0:t.name} as @${((r=e.status.bot)==null?void 0:r.name)??"scout"}`:`✕ ${e.error}`}function Ec(e=0){const[t,r]=x.useState(),o=x.useCallback(()=>Bn.get().then(r,()=>r(null)),[]);return x.useEffect(()=>{if(o(),!e)return;const l=setInterval(()=>void o(),e);return()=>clearInterval(l)},[o,e]),[t,r]}function yj(e){const[t,r]=Ec(3e3),[o,l]=x.useState(!1),c=x.useRef(null);if(x.useEffect(()=>{var g;e.focus&&t&&((g=c.current)==null||g.scrollIntoView({block:"start"}))},[e.focus,!!t]),!t)return null;const d=t.step==="done",f=g=>Bn.update(g).then(r,()=>{});return i.jsxs("div",{ref:c,className:"slack-settings",children:[i.jsx(oj,{s:t,setup:o,onSetup:l,onToggle:()=>void f({enabled:!t.enabled}),onRemoved:g=>{r(g),l(!1)}}),!d&&(o||t.step!==1)&&i.jsx(vj,{s:t,set:r}),o&&d&&t.state==="auth-error"&&i.jsxs(Ot,{tone:"inset",className:"slack-setup",children:[i.jsx("p",{children:"Generate a new app-level token or reinstall the app, then paste the new token. Settings and the owner are kept."}),i.jsx(nj,{set:r})]}),d&&i.jsx(dj,{s:t,set:r,patch:g=>void f(g)})]})}function xj(e){const{api:t,rt:r,brief:o}=e,{snap:l,actions:c}=t,[d]=Ec(15e3),f=Ks(),g=d!=null&&d.enabled&&d.state==="auth-error"?d.error??"Slack rejected the tokens":void 0;return i.jsx(zw,{repo:e.repo,snaps:t.allSnaps,map:l==null?void 0:l.map,activity:t.activity,health:t.health,onNewTrail:e.onNewTrail,trackerLabel:r.adapter.label.toLowerCase(),onSelectMap:c.selectMap,onToggleMode:()=>l&&c.setMode(l.map.mode==="plan-only"?"plan+execute":"plan-only"),onSettings:e.onSettings,onToggleTheme:e.onToggleTheme,attention:e.attention,slackAlert:g,onSlack:e.onSlack,decisions:t.decisions.length,decisionsOpen:e.decisionsOpen,onDecisions:e.onDecisions,onStats:e.onStats,knowledge:f.attention,knowledgeOpen:f.open,onKnowledge:()=>f.setOpen(!f.open),briefingOpen:o.shown,briefingStatus:o.status,onBriefing:()=>o.shown?o.dismiss():o.open()})}function wj(e){const{m:t}=e,r=t.from==="human"?"human":"agent";return i.jsxs("div",{className:`msg from-${t.from} voice-${r}`,children:[i.jsx(q,{parts:[t.author,Bo(t.at)]}),i.jsx("div",{className:"msg-text",children:t.text}),e.stillOpen&&i.jsx("button",{className:"answer-this t-meta",onClick:e.onAnswerThis,children:"Answer this"})]})}function jj(e){const{ticket:t}=e;return i.jsxs("div",{className:"comms-ticket",children:[i.jsxs("div",{className:"t-title",title:t&&`${t.key} ${t.title}`,children:[i.jsx("span",{className:"key",children:t==null?void 0:t.key})," ",t==null?void 0:t.title]}),i.jsx(q,{parts:[e.trail,e.agent]})]})}function Nj({id:e,text:t}){const[r,o]=x.useState(),l=r!==e;return i.jsx(_o,{size:1,framed:!1,state:l?"speaking":"alert",speaking:l?t.slice(0,60):void 0,onSpeakEnd:()=>o(e),className:"q-avatar"})}function Sj(e){const{q:t}=e;return i.jsxs("div",{className:"msg open-q",children:[i.jsx(q,{parts:[t.agent,Bo(t.at)]}),i.jsx(Nj,{id:e.chatId??t.id,text:t.text}),i.jsx("div",{className:"msg-text",children:t.text})]})}function bj(e){var t;return(t=e.options)!=null&&t.length?i.jsx("div",{className:"suggest",children:e.options.map(r=>i.jsx("button",{className:"chip",onClick:()=>e.onPick(r),children:r},r))}):null}function Cj(e){const{activity:t,sessionId:r}=e,[o,l]=x.useState(""),[c,d]=x.useState(),f=x.useRef(null),g=x.useRef(null),m=t.sessions.find(O=>O.id===r),v=t.chats.filter(O=>O.sessionId===r),y=rw(t.pending,r,c??e.questionId),w=new Set(t.pending.filter(O=>O.sessionId===r).map(O=>O.id)),j=v.find(O=>!!y&&O.questionId===y.id),$=v.filter(O=>O!==j),N=m?e.snaps[m.mapId]:void 0,E=m!=null&&m.ticketId?N==null?void 0:N.tickets.find(O=>O.id===m.ticketId):void 0;x.useEffect(()=>{const O=f.current;O==null||O.scrollTo({top:O.scrollHeight,behavior:"smooth"})},[$.length,y==null?void 0:y.id]),x.useEffect(()=>{var O;y&&!e.onBack&&((O=g.current)==null||O.focus({preventScroll:!0}))},[y==null?void 0:y.id,e.onBack]);const M=O=>{!y||!O.trim()||(e.onAnswer(y.id,O.trim()),l(""))},R=$j(m,!!y);return i.jsxs("div",{className:`comms ${y?"asking":""}`,children:[i.jsx(Ct,{title:"HITL line",right:m?i.jsx("span",{className:`status ${y?"urgent":""}`,children:R}):void 0,children:e.onBack&&i.jsx("button",{className:"back",onClick:e.onBack,"aria-label":"Back to inbox",children:"‹ Inbox"})}),m?i.jsxs(i.Fragment,{children:[i.jsx(jj,{ticket:E,trail:N==null?void 0:N.map.title,agent:m.agent}),i.jsx("div",{className:"comms-log",ref:f,children:$.map(O=>i.jsx(wj,{m:O,stillOpen:!!O.questionId&&w.has(O.questionId),onAnswerThis:()=>d(O.questionId)},O.id))}),y&&i.jsx(Sj,{q:y,chatId:j==null?void 0:j.id}),i.jsx(bj,{options:y==null?void 0:y.suggestions,onPick:M}),i.jsx(Nc,{ref:g,className:"comms-input",value:o,onValueChange:l,onSubmit:M,disabled:!y,placeholder:y?"Answer":""})]}):i.jsx(Ee,{children:"No conversation"})]})}function $j(e,t){return e?t?"Your answer is needed":tn(e)?`${e.agent} is working…`:e.status==="done"?"Resolved · ticket closed":"Session ended":""}async function Tj(e){const[t,r]=e.ref.split("+"),o=await fetch(`${Se()}/workspaces/integration`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e.mapId,a:t,b:r})});return o.ok?void 0:(await o.json().catch(()=>({}))).error??`Adding failed (${o.status})`}function Ej({item:e}){const[t,r]=x.useState(!1),[o,l]=x.useState(),c=()=>{r(!0),l(void 0),Tj(e).then(l,d=>l(d.message)).finally(()=>r(!1))};return i.jsxs("div",{className:"att-action",children:[i.jsx(K,{size:"sm",className:"integration-add",disabled:t,onClick:c,children:t?"Adding…":"Add integration ticket"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}const Ij=/(\S*\/\S*|#\d+)/g;function Mj({reasons:e}){return e.length?i.jsx("span",{className:"reason-line",children:e.map((t,r)=>i.jsxs("span",{children:[r>0&&i.jsx("span",{className:"sep",children:" · "}),t.split(Ij).map((o,l)=>l%2===1?i.jsx("span",{className:"t-code",children:o},l):o)]},t))}):null}const Vm={question:"Question",approval:"Approve",blocked:"Blocked",flag:"PR / CI",stalled:"Stalled","hitl-ready":"Needs you",knowledge:"Field guide",brief:"Brief",policy:"Risk",reroute:"Reroute","reroute-suggested":"Reroute?",overlap:"Overlap",integration:"Integrate",guide:"Guide","guide-checks":"Approve",model:"Model"},Aj={question:"questions",approval:"approvals",blocked:"blocked tickets",flag:"PR / CI flags",stalled:"stalled claims","hitl-ready":"tickets for you",knowledge:"field guide entries",brief:"briefs",policy:"risky changes",reroute:"reroutes","reroute-suggested":"suggested reroutes",overlap:"overlapping claims",integration:"clashing branches",guide:"guides to approve","guide-checks":"guide checks to approve",model:"tickets waiting for a model"},Lj=[{minutes:30,label:"30 min"},{minutes:120,label:"2 hours"},{minutes:1440,label:"Tomorrow"}],Rj=["blocked","flag","stalled","policy","reroute","overlap","integration","model"];function Gm(e,t){return t||e.urgency==="blocking"?"urgent":Rj.includes(e.kind)?"attention":"neutral"}const Oj=[/^marked blocking$/,/^fyi\b/,/^soon\b/,/^waiting \d/,/^answer together/,/questions from /];function Qm(e){return e.reasons.filter(t=>!Oj.some(r=>r.test(t)))}function Pj(e){const{item:t,snap:r}=e,o=r==null?void 0:r.tickets.find(f=>f.id===t.ticketId),l=t.kind==="question"&&t.agent?`${t.agent} asks`:Vm[t.kind],c=[];t.urgency==="blocking"&&c.push({text:"Blocking",urgent:!0,className:"urgency-tag"}),c.push({text:l,strong:!0});const d=o&&_j(t.title,o);return d&&c.push(d),e.otherTrail&&c.push((r==null?void 0:r.map.title)??t.mapId),c}function _j(e,t){if(!e.includes(t.key))return e.includes(t.title)?{text:t.key,code:!0}:`${t.key} ${t.title}`}function Dj(e){const[t,r]=x.useState(!1),o=l=>{r(!1),l()};return i.jsxs("span",{className:"snooze",children:[i.jsx("button",{type:"button",className:"snooze-btn","aria-expanded":t,"aria-label":`Later: ${e.title}`,onClick:()=>r(!t),children:"Later"}),t&&i.jsxs("span",{className:"snooze-menu",role:"menu",children:[Lj.map(l=>i.jsx("button",{type:"button",role:"menuitem",onClick:()=>o(()=>e.onSnooze(l.minutes)),children:l.label},l.minutes)),e.canDismiss&&i.jsx("button",{type:"button",role:"menuitem",onClick:()=>o(e.onDismiss),children:"Set aside"})]})]})}const Bj=15e3;function zj(e){const{item:t}=e,r=t.title.split(`
|
|
124
|
+
`)[0],o=Qm(t),l=e.now-t.since<Bj;return i.jsx(Ae,{as:"li",className:`att-item k-${t.kind} u-${t.urgency} ${e.selected?"sel":""} ${l?"incoming":""}`,edge:Gm(t,e.interrupting),selected:e.selected,title:r,titleText:t.title,context:i.jsx(q,{parts:Pj({item:t,snap:e.snap,otherTrail:e.otherTrail})}),detail:o.length>0&&i.jsx(Mj,{reasons:o}),detailText:o.join(`
|
|
125
|
+
`),trailing:nn(e.now-t.since),onOpen:e.onOpen,actions:i.jsx(Dj,{title:t.title,canDismiss:Oy(t),onSnooze:e.onSnooze,onDismiss:e.onDismiss}),below:t.kind==="integration"&&i.jsx(Ej,{item:t})})}function Fj(e){const t=[];for(const r of e){const o=t.at(-1);(o==null?void 0:o.key)===r.batchKey?o.items.push(r):t.push({key:r.batchKey,kind:r.kind,mapId:r.mapId,items:[r]})}return t}const Uj={question:"inbox-list",approval:"inbox-list approvals"};function Hj(e){const{batch:t}=e,r=t.items.length>1,o=t.kind==="question"?"answer together":"review together",l=[`${t.items.length} ${Aj[t.kind]}`,e.trail,o].filter(Boolean);return i.jsxs("div",{className:`att-batch ${r?"many":""}`,children:[r&&i.jsx("span",{className:"batch-head t-label",children:l.join(" · ")}),i.jsx("ul",{className:`att-list ${Uj[t.kind]??""}`,children:e.children})]})}function Wj(e,t){e.ticketId?t.openTicket(e.mapId,e.ticketId):t.selectTrail(e.mapId)}function qm(e,t){switch(e.kind){case"question":return t.openQuestion(e.ref);case"approval":case"blocked":case"policy":case"flag":case"stalled":case"hitl-ready":case"overlap":case"integration":case"model":return Wj(e,t);case"knowledge":return t.openKnowledge();case"brief":return t.openBrief(e.mapId);case"reroute":case"reroute-suggested":return t.openReroute(e);case"guide":case"guide-checks":return t.openGuides();default:return e.kind}}function Kj(e){const t=sn(1e3),{view:r}=e;if(!r.items.length)return i.jsx(Dn,{title:"Nothing waiting on you",hint:r.hidden?`${r.hidden} snoozed or set aside. They come back when the snooze ends.`:"When an agent needs your call, it lands here, most important first."});const o=Object.keys(e.snaps).length>1,l=f=>o&&f!==e.currentMapId,c=new Set(r.interrupting),d=f=>{var g;return(g=e.pending.find(m=>m.id===f))==null?void 0:g.sessionId};return i.jsx("div",{className:"attention-queue",children:Fj(r.items).map(f=>{var g;return i.jsx(Hj,{batch:f,trail:l(f.mapId)?(g=e.snaps[f.mapId])==null?void 0:g.map.title:void 0,children:f.items.map(m=>i.jsx(zj,{item:m,snap:e.snaps[m.mapId],otherTrail:l(m.mapId)&&f.items.length<2,selected:m.kind==="question"&&d(m.ref)===e.selected,interrupting:c.has(m.id),now:t,onOpen:()=>qm(m,e.handlers),onSnooze:v=>e.onSnooze(m.id,v),onDismiss:()=>e.onDismiss(m.id)},m.id))},f.key)})})}const gh={label:"Focus for 1 hour",change:{kind:"for",minutes:60}};function Vj(e){switch(e.kind){case"manual":case"hours":return[{label:"End focus now",change:{kind:"end"},primary:!0}];case"paused":return[{label:"Resume quiet hours",change:{kind:"resume"},primary:!0},gh];case"off":return[{...gh,primary:!0},{label:"Focus for 3 hours",change:{kind:"for",minutes:180}}];default:return e}}const vh=e=>Bo(e).slice(0,5),Gj=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function Qj(e){const t=`${e.items.length} waiting on you`;return e.heldBack===0?`Nothing held back · ${t}`:`${Gj(e.heldBack,"item")} would interrupt you · ${t}`}function Wl(e){const t=e.prefs.focus;return t?`Quiet hours ${t.from}–${t.to}`:"No quiet hours set"}const kh=e=>`Items scoring ${e.policy.value.interrupt} or more interrupt you · ${e.items.length} waiting on you`;function qj(e){const t=e.focus;switch(t.kind){case"manual":case"hours":{const r=vh(t.until),o=t.kind==="manual"?"Switched on here":Wl(e);return{word:"on",until:r,on:!0,title:`Focus is on until ${r}`,reason:o,detail:Qj(e)}}case"paused":{const r=vh(t.until),o=`Quiet hours paused until ${r}`;return{word:"paused",until:r,on:!1,title:o,reason:Wl(e),detail:kh(e)}}case"off":return{word:"off",until:"",on:!1,title:"Focus is off",reason:Wl(e),detail:kh(e)};default:return t}}const Yj="Focus holds back interruptions: no browser notifications or Slack messages, even for urgent items. Nothing is answered or dropped: everything still waits in Waiting on you and the Slack digest. Quiet hours turn it on every day; you can also focus for a while or end it early. This stays on this machine.";function Jj(e){const{view:t}=e,r=qj(t),o=t.focus.kind,l=i.jsxs("span",{className:We("focus-state",`focus-${o}`),children:[i.jsx("i",{className:"focus-dot","aria-hidden":"true"}),i.jsxs("span",{className:"focus-label",children:["Focus",i.jsxs("span",{className:"focus-word",children:[" ",r.word]})]}),r.until&&i.jsxs("span",{className:"focus-until",children:[i.jsx("span",{className:"sep",children:" · "}),i.jsx("span",{className:"focus-until-word",children:"until "}),r.until]})]});return i.jsx(Fm,{className:"focus-menu",label:l,role:"dialog",tip:r.title,ariaLabel:r.title,children:c=>i.jsxs("div",{className:"focus-panel","aria-label":"Focus",children:[i.jsxs("div",{className:"focus-panel-head",children:[i.jsx("span",{className:"t-row-title",children:r.title}),i.jsx(Us,{text:Yj})]}),i.jsx(q,{parts:[r.reason]}),i.jsx(q,{className:"focus-held",parts:[r.detail]}),i.jsxs("div",{className:"focus-panel-actions",children:[Vj(t.focus).map(d=>i.jsx(K,{size:"sm",variant:d.primary?"primary":"default",onClick:()=>{c(),e.onChange(d.change)},children:d.label},d.label)),i.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{c(),e.onSettings()},children:"Quiet hours"})]})]})})}function Xj(e){const{view:t}=e,r=t.interrupting.length;return i.jsxs("span",{className:"attention-head",children:[i.jsx(Jj,{view:t,onChange:e.onFocus,onSettings:e.onSettings}),r>0&&i.jsxs("span",{className:"waiting-chip interrupting",title:`${r} need you now`,children:[i.jsx(Ws,{variant:"alert",size:14}),i.jsx("b",{children:r}),i.jsx("span",{className:"wl",children:" need you now"})]})]})}const Ym=`${Se()}/attention`,Zj=250;async function yh(e,t,r){var c;const o=await fetch(`${Ym}${e}`,{method:t,headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),l=await o.json().catch(()=>({}));if(!o.ok)throw new Error(((c=l.errors)==null?void 0:c.join("; "))??l.error??`HTTP ${o.status}`);return l}function Jm(e){const[t,r]=x.useState(),[o,l]=x.useState(),c=x.useCallback(()=>{fetch(Ym).then(f=>f.ok?f.json():void 0).then(f=>f&&r(f)).catch(()=>{})},[]);x.useEffect(()=>Fo("attention",f=>r(JSON.parse(f))),[]),x.useEffect(()=>{const f=setTimeout(c,Zj);return()=>clearTimeout(f)},[c,e]);const d=(f,g)=>void yh(f,"POST",g).then(()=>(l(void 0),c()),m=>l(m.message));return{view:t,error:o,snooze:(f,g)=>d("/snooze",{id:f,minutes:g}),dismiss:f=>d("/dismiss",{id:f}),savePrefs:f=>yh("/prefs","PUT",f).then(()=>(l(void 0),c(),!0),g=>(l(g.message),!1))}}function e0(e){return e.prefs.channel!=="browser"?!1:typeof Notification<"u"&&Notification.permission==="granted"}function t0(e){const t=new Notification(`${ve.name} · needs you`,{body:e.title,tag:e.id});t.onclick=()=>{window.focus(),t.close()}}function n0(e){const t=x.useRef();x.useEffect(()=>{if(!e)return;const r=new Set(e.interrupting),o=t.current;if(t.current=r,!(!o||!e0(e)))for(const l of e.items)r.has(l.id)&&!o.has(l.id)&&t0(l)},[e])}function s0(e){const t=sn(1e3);return e.items.length?i.jsx("ul",{className:"inbox-list approvals",children:e.items.map(r=>{var c;const o=r.kind!=="approve",l=r.mapId!==e.currentMapId?(c=e.snaps[r.mapId])==null?void 0:c.map.title:void 0;return i.jsx(Ae,{as:"li",edge:o?"attention":"neutral",title:`${o?"Decide":"Approve"}: ${r.title}`,context:i.jsx(q,{parts:[o?"Held":"Verified",{text:r.ticketKey,code:!0},l]}),detail:r.reason,detailText:r.reason,trailing:nn(t-r.at),onOpen:()=>e.onOpen(r.mapId,r.ticketId)},`${r.mapId}/${r.ticketId}`)})}):null}function xh({activity:e}){const t=sn(1e3),r=Fk(e);return i.jsxs("div",{className:"hitl-readout",children:[i.jsx(Zt,{layout:"inline",label:"Oldest",value:r.oldestAt?Wt(t-r.oldestAt):"—",urgent:!!r.oldestAt&&t-r.oldestAt>6e4,title:"Oldest open question"}),i.jsx(Zt,{layout:"inline",label:"Avg wait",value:r.avgWaitMs!==void 0?Wt(r.avgWaitMs):"—",title:`Average wait over ${r.answered} answered questions`}),i.jsx(Zt,{layout:"inline",label:"Answered",value:r.answered})]})}function i0(e){const t=sn(1e3);return e.items.length?i.jsx("ul",{className:"inbox-list",children:e.items.map(r=>{const o=e.snaps[r.mapId],l=o==null?void 0:o.tickets.find(f=>f.id===r.ticketId),c=r.mapId!==e.currentMapId?o==null?void 0:o.map.title:void 0,d=r.text.split(`
|
|
126
|
+
`)[0];return i.jsx(Ae,{as:"li",className:r.sessionId===e.selected?"sel":void 0,edge:r.urgency==="blocking"?"urgent":"neutral",selected:r.sessionId===e.selected,title:d,titleText:r.text,context:i.jsx(q,{parts:[r.urgency==="blocking"&&{text:"Blocking",urgent:!0},`${r.agent} asks`,l&&{text:l.key,code:!0},l==null?void 0:l.title,c]}),trailing:nn(t-r.at),onOpen:()=>e.onOpen(r.sessionId,r.ticketId)},r.id)})}):i.jsx(Dn,{title:"Nothing waiting on you",hint:"When an agent needs your call, its question lands here."})}const r0={pass:"Passed",fail:"Failed",error:"Could not run",interrupted:"Interrupted"},Ui={off:"Off",checks:"Checks","checks+review":"Checks + review","checks+review+human":"Checks + review + you"},Xm={off:"The agent saying “done” closes the ticket right away.",checks:"Your checks (tests, lint, typecheck…) run in the repo first. A failure goes back to the agent with the output.","checks+review":"After the checks pass, a different agent reviews the change. It is never the agent that did the work.","checks+review+human":"After checks and review, you approve it in the inbox before the ticket closes."},o0=e=>e.exitCode===0&&!e.timedOut&&!e.error;async function wh(e){const t=await e.json().catch(()=>({}));if(!e.ok)throw new Error(t.error??`HTTP ${e.status}`);return t}const co=`${Se()}/verification`,Gi={ticket:(e,t)=>fetch(`${co}/ticket?mapId=${encodeURIComponent(e)}&ticketId=${encodeURIComponent(t)}`).then(r=>r.ok?r.json():void 0,()=>{}),inbox:()=>fetch(`${co}/inbox`).then(e=>e.ok?e.json().then(t=>t.items):[],()=>[]),log:e=>fetch(`${co}/log?path=${encodeURIComponent(e)}`).then(t=>wh(t)),act:e=>fetch(`${co}/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(t=>wh(t))};function a0(e){const[t,r]=x.useState([]),o=Object.values(e).map(l=>l.tickets.map(c=>`${c.id}:${c.state}:${c.status??""}`).join()).join("|");return x.useEffect(()=>{let l=!0;const c=()=>void Gi.inbox().then(f=>l&&r(f));c();const d=Bs.onEvidence(c);return()=>{l=!1,d()}},[o]),t}function l0(e,t){return{...e,items:e.items.filter(r=>!(r.kind==="brief"&&r.mapId===t))}}function c0(e){var f;const t=[...e.activity.pending].sort((g,m)=>g.at-m.at),r=a0(e.snaps),o=(f=e.attention)==null?void 0:f.view,l=o&&e.briefShown?l0(o,e.currentMapId):o,c=l?l.items.length:t.length+r.length,d=i.jsx(Ct,{hot:c>0,title:i.jsxs(i.Fragment,{children:[c>0&&i.jsx(Ws,{variant:"alert",size:12}),"Waiting on you"]}),count:i.jsx(ts,{n:c,urgent:c>0,pop:!0},c)});return l&&e.attention&&e.handlers?i.jsxs("div",{className:"inbox-part",children:[d,i.jsx(xh,{activity:e.activity}),i.jsx(Kj,{view:l,snaps:e.snaps,pending:e.activity.pending,currentMapId:e.currentMapId,selected:e.sessionId,handlers:e.handlers,onSnooze:e.attention.snooze,onDismiss:e.attention.dismiss})]}):i.jsxs("div",{className:"inbox-part",children:[d,i.jsx(xh,{activity:e.activity}),i.jsx(s0,{items:r,snaps:e.snaps,currentMapId:e.currentMapId,onOpen:e.onOpenTicket}),(t.length>0||!r.length)&&i.jsx(i0,{items:t,snaps:e.snaps,currentMapId:e.currentMapId,selected:e.sessionId,onOpen:e.onOpenQuestion})]})}function u0(e){const[t,r]=x.useState("list"),[o,l]=x.useState();x.useEffect(()=>{e.convRequest&&r("conv")},[e.convRequest]);const c=(v,y)=>{e.onOpen(v,y),r("conv")},d=v=>{const y=e.activity.pending.find(w=>w.id===v);y&&(l(y.id),c(y.sessionId,y.ticketId))},f=i.jsx(c0,{activity:e.activity,snaps:e.snaps,currentMapId:e.currentMapId,sessionId:e.sessionId,attention:e.attention,handlers:e.handlers&&{...e.handlers,openQuestion:d},briefShown:!!e.above,onOpenQuestion:c,onOpenTicket:e.onOpenTicket}),g=i.jsx(Cj,{activity:e.activity,snaps:e.snaps,sessionId:e.sessionId,questionId:o,onAnswer:e.onAnswer,onBack:e.layout==="stack"?()=>r("list"):void 0});if(e.layout==="stack")return i.jsx(Ke,{className:"zone inbox stack",children:t==="conv"&&e.sessionId?g:i.jsxs("div",{className:"stack-scroll",children:[e.above,f,e.below]})});const m=!!e.activity.sessions.find(v=>v.id===e.sessionId);return i.jsxs(Ke,{className:`zone inbox split ${m?"has-conv":""}`,style:{gridArea:"inbox"},children:[i.jsx(Ct,{className:"zone-title",icon:"mailbox",title:"Communication",info:"Where your agents reach you: everything waiting on you, ranked with the reasons why, the conversation with the agent that asked, and the tickets coming up next."}),e.above,f,m&&g,e.below]})}function d0(e){var f;const{snap:t}=e,r=t?Fs(t.tickets,t.map.mode):new Map,o={claimed:0,frontier:1},l=((t==null?void 0:t.tickets)??[]).filter(g=>o[r.get(g.id)]!==void 0).sort((g,m)=>o[r.get(g.id)]-o[r.get(m.id)]),c=new Set(e.sessions.filter(_m).map(g=>g.ticketId)),d=((f=e.selection)==null?void 0:f.kind)==="ticket"?e.selection.id:void 0;return i.jsxs("div",{className:"upnext",children:[i.jsx(Ct,{title:"Up next",count:i.jsx("span",{className:"n mono-label",children:l.length})}),!t&&i.jsx(Ee,{children:"Ready tickets show here"}),t&&!l.length&&i.jsx(Ee,{children:"Nothing ready"}),t&&l.length>0&&i.jsx("ul",{className:"ticket-list",children:l.map(g=>{const v={state:r.get(g.id),waiting:c.has(g.id),assignee:g.assignee,hitl:Wi(g)==="hitl"},y=f0(v);return i.jsx("li",{className:`${d===g.id?"sel":""} st-${h0(v)}`,children:i.jsxs("button",{onClick:()=>e.onSelect({kind:"ticket",id:g.id}),children:[i.jsx("i",{className:"dot"}),i.jsx("span",{className:"key t-code",children:g.key}),i.jsx("span",{className:"ttl t-body",children:g.title}),i.jsx("span",{className:"st-text t-meta",children:y})]})},g.id)})})]})}function f0(e){if(e.waiting)return"waiting on you";if(e.state==="claimed")return e.assignee??"claimed";const t=Am[e.state].toLowerCase();return e.hitl?`${t}, needs you`:t}function h0(e){return e.waiting?"waiting":e.state==="frontier"&&e.hitl?"attention":e.state}function m0(e){const{api:t,nav:r}=e;return i.jsx(u0,{activity:t.activity,snaps:t.allSnaps,currentMapId:t.mapId,sessionId:t.chatSession,layout:e.bp==="mobile"?"stack":"split",convRequest:r.convRequest,onOpen:r.openChat,onAnswer:t.actions.answer,onOpenTicket:r.openTicket,attention:e.attn.attention,handlers:e.attn.handlers,below:i.jsx(d0,{snap:t.snap,sessions:e.scoped.sessions,selection:t.selection,onSelect:r.select}),above:e.above})}function jo({command:e,label:t="Copy"}){const[r,o]=x.useState(!1);return i.jsxs("span",{className:"agent-cmd",children:[i.jsx("code",{children:e}),i.jsx("button",{type:"button",className:"btn sm","data-tip":"Copy, then paste it in Claude Code or Codex",onClick:()=>void navigator.clipboard.writeText(e).then(()=>{o(!0),setTimeout(()=>o(!1),1500)}),children:r?"Copied":t})]})}const uo=[{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"}],p0=9e3;function g0(){const[e,t]=x.useState(0),[r,o]=x.useState(!1);x.useEffect(()=>{if(r)return;const c=setInterval(()=>t(d=>(d+1)%uo.length),p0);return()=>clearInterval(c)},[r]);const l=uo[e];return i.jsxs("div",{className:"command-bar real",children:[i.jsx(Dm,{name:"map"}),i.jsx(Je,{as:"h2",className:"zone-title-label",children:"Trail map"}),i.jsx(Us,{text:"Every decision ticket in this trail and what blocks what. Click a ticket to see it in Trail step. The strip below sums up progress."}),i.jsxs("div",{className:"hint",onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),onFocus:()=>o(!0),onBlur:()=>o(!1),children:[i.jsx("span",{className:"dim",children:l.text}),l.command&&i.jsx(jo,{command:l.command})]},e),i.jsxs("button",{type:"button",className:"link hint-next","data-tip":"Next hint","aria-label":"Next hint",onClick:()=>t(c=>(c+1)%uo.length),children:[e+1,"/",uo.length," ›"]})]})}function v0(e){const t=[{v:"plan+execute",title:"Plan + execute"},{v:"plan-only",title:"Plan only"}];return i.jsx("div",{className:"choice-row",children:t.map(r=>i.jsx(ht,{on:e.value===r.v,title:r.title,onClick:()=>e.onChange(r.v)},r.v))})}function k0({onClose:e,tracker:t,onCreate:r}){const[o,l]=x.useState(),[c,d]=x.useState(!1),[f,g]=x.useState(),[m,v]=x.useState(""),[y,w]=x.useState(""),[j,$]=x.useState(""),[N,E]=x.useState(""),M=[m.trim(),y.trim(),j.trim()].filter(Boolean).join(". ").replace(/"/g,"'");return x.useEffect(()=>{const R=O=>O.key==="Escape"&&e();return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[e]),i.jsx("div",{className:"scrim",onClick:e,children:i.jsxs(Ke,{as:"div",className:"dialog",onClick:R=>R.stopPropagation(),children:[i.jsx("header",{children:i.jsx("h2",{className:"t-heading caps",children:"New trail"})}),i.jsx(Ye,{label:"Title",children:i.jsx("input",{value:m,onChange:R=>v(R.target.value),autoFocus:!0})}),i.jsx(Ye,{label:"Destination",children:i.jsx("textarea",{rows:3,value:y,onChange:R=>w(R.target.value),placeholder:"What is true when this trail is done?"})}),i.jsx(Ye,{label:"Notes",children:i.jsx("textarea",{rows:2,value:j,onChange:R=>$(R.target.value)})}),i.jsx(Ye,{label:"Assumptions (optional, one per line)",children:i.jsx("textarea",{className:"new-trail-assumptions",rows:2,value:N,onChange:R=>E(R.target.value),placeholder:"What the plan takes for granted, e.g. The v2 API supports batch writes"})}),i.jsxs("div",{className:"agent-draft",children:[i.jsxs("span",{className:"dim",children:["Paste this in Claude Code or Codex. Scout frames the trail with you there, then charts it here in ",t,"."]}),i.jsx(jo,{command:`/scout new "${M||"your idea"}"`,label:"Copy command"})]}),o?i.jsxs("div",{className:"agent-draft created",children:[i.jsxs("span",{children:["Trail ",o," is on the map, starting with discovery. To get it moving, run this in Claude Code or Codex:"]}),i.jsx(jo,{command:"/scout resume",label:"Copy command"})]}):f&&i.jsx("p",{className:"vf-err",children:f}),i.jsxs("footer",{children:[i.jsx(K,{variant:"ghost",onClick:e,children:"Close"}),!o&&i.jsx(K,{variant:"primary",disabled:c||!m.trim()||!y.trim(),"data-tip":"Put the trail on the map now; any agent picks it up with /scout resume",onClick:()=>{d(!0);const R=N.split(`
|
|
127
|
+
`).map(O=>O.trim());r({title:m.trim(),destination:y.trim(),notes:j.trim(),assumptions:R.filter(Boolean)}).then(O=>l(O.key)).catch(O=>g(O.message)).finally(()=>d(!1))},children:"Create trail"})]})]})})}const jh=["Ready when you are","What's the next big idea?","I keep the party on the trail","Describe it, I frame it"],y0=5e3;function x0(){const e=bc(),[t,r]=x.useState(0),[o,l]=x.useState(!0);return x.useEffect(()=>{if(o)return;const c=setTimeout(()=>{r(d=>(d+1)%jh.length),l(!0)},y0);return()=>clearTimeout(c)},[o]),i.jsxs("div",{className:"floating-scout","aria-hidden":"true",children:[i.jsx(_o,{variant:e?"night":"crt",size:3,framed:!1,speaking:o?jh[t]:void 0,onSpeakEnd:()=>l(!1),className:"fm-avatar"}),i.jsx("span",{className:"fm-shadow"})]})}function w0(e){return i.jsx(k0,{onClose:e.onClose,tracker:e.rt.adapter.label,onCreate:async t=>{const r=await Gx(e.rt.adapter,t);return e.onCreated(r.id),r}})}const j0={gh:"your gh login",GITHUB_TOKEN:"GITHUB_TOKEN",GH_TOKEN:"GH_TOKEN",stored:"a saved token","signed-in":"your GitHub sign-in",LINEAR_API_KEY:"LINEAR_API_KEY"},Ic=e=>j0[e];function Mc(e){var t;return((t=e.account)==null?void 0:t.kind)==="user"?e.account.login:void 0}const Kl=e=>!!e.auth&&!!Mc(e);function Zm(e,t){const r=Mc(e);return!e.auth||!r?void 0:`Will use ${t||"the repo you pick"} as ${r} (${Ic(e.auth)})`}function N0(e){if(!e.repo)return;const t=Mc(e),r=t?` as ${t}`:"",o=e.auth?`, using ${Ic(e.auth)}`:"";return`Connected to ${e.repo}${r}${o}`}function S0(e,t){if(!e.pushedAt)return;const r=Math.floor((t-Date.parse(e.pushedAt))/864e5);return r<1?"Pushed today":r<60?`Pushed ${r}d ago`:`Pushed ${Math.floor(r/30)}mo ago`}function b0(e){const{gh:t}=e;if(!t.auth)return null;const r=Zm(t,e.repo);return i.jsxs("div",{className:"gh-identity",children:[r&&i.jsx("span",{className:"t-body",children:r}),i.jsxs("span",{className:"gh-identity-actions",children:[i.jsx("button",{type:"button",className:"btn ghost sm",onClick:e.onUseAnother,children:"Use another token"}),t.auth==="signed-in"&&i.jsx("button",{type:"button",className:"btn ghost sm",onClick:e.onSignOut,children:"Sign out"})]})]})}const C0=/^[\w.-]+\/[\w.-]+$/;function $0(e){const t=e.query.trim().toLowerCase(),o=!!e.detected&&e.repos.every(g=>g.fullName!==e.detected)?[{fullName:e.detected,private:!1},...e.repos]:e.repos,l=[...o.filter(g=>g.fullName===e.detected),...o.filter(g=>g.fullName!==e.detected)],c=t?l.filter(g=>g.fullName.toLowerCase().includes(t)):l,f=C0.test(e.query.trim())&&c.every(g=>g.fullName.toLowerCase()!==t)?e.query.trim():void 0;return{shown:c.slice(0,e.limit),matches:c.length,typed:f}}function Nh(e){const{repo:t,listed:r}=e,o=t.private?"Private":"Public";return i.jsx(Ae,{as:"li",className:"repo-row",selected:e.selected,title:i.jsx("span",{className:"t-code",children:t.fullName}),context:i.jsx(q,{parts:[e.detected&&{text:"This project's repo",strong:!0},r&&o,r&&S0(t,e.now),!r&&"Checked when you connect"]}),onOpen:e.onPick})}const T0=40;function Sh(e){const[t,r]=x.useState(""),o=x.useMemo(()=>Date.now(),[]),l=x.useMemo(()=>new Set(e.repos.map(v=>v.fullName)),[e.repos]),{shown:c,matches:d,typed:f}=$0({repos:e.repos,detected:e.detected,query:t,limit:T0}),g=d>c.length?`${d-c.length} more: type to narrow`:"",m=e.truncated?`Your ${e.repos.length} most recently pushed repos`:"";return i.jsxs("div",{className:"repo-picker",children:[i.jsxs("label",{className:"field",children:["Repository",i.jsx("input",{value:t,placeholder:"Search your repos, or type owner/name",spellCheck:!1,"aria-label":"Search repositories",onChange:v=>r(v.target.value)})]}),i.jsxs("ul",{className:"repo-list","aria-label":"Repositories",children:[f&&i.jsx(Nh,{repo:{fullName:f,private:!1},detected:f===e.detected,listed:!1,selected:f===e.value,now:o,onPick:()=>e.onChange(f)}),c.map(v=>i.jsx(Nh,{repo:v,detected:v.fullName===e.detected,listed:l.has(v.fullName),selected:v.fullName===e.value,now:o,onPick:()=>e.onChange(v.fullName)},v.fullName))]}),i.jsx(q,{parts:[!d&&!f&&"No repo matches",g,m]})]})}function E0(e){const{list:t}=e;if(!t)return i.jsx(Hs,{label:"Loading your repos…",rows:3,className:"picker-loading"});switch(t.kind){case"ok":return i.jsx(Sh,{repos:t.repos,truncated:t.truncated,detected:t.detectedRepo??e.detected,value:e.value,onChange:e.onChange});case"no-token":return i.jsx(q,{parts:["No GitHub token found"]});case"error":return i.jsxs(i.Fragment,{children:[i.jsx(Sc,{what:"Couldn't list your repos",reason:t.error,onRetry:e.onRetry}),i.jsx(Sh,{repos:[],truncated:!1,detected:e.detected,value:e.value,onChange:e.onChange})]});default:return t}}const I0={stored:"Saved token",gh:"gh CLI",GITHUB_TOKEN:"$GITHUB_TOKEN",GH_TOKEN:"$GH_TOKEN","signed-in":"Signed in with GitHub",LINEAR_API_KEY:"$LINEAR_API_KEY"},_i=e=>e==="github"||e==="linear";function ep(e){const[t,r]=x.useState(!e.source);return e.source&&!t?i.jsxs("div",{className:"ts-auth",children:[i.jsx("span",{className:"mono-label",children:e.label}),i.jsx("span",{className:"pill on",children:I0[e.source]}),i.jsx("button",{type:"button",className:"btn ghost sm",onClick:()=>r(!0),children:"Use another"})]}):i.jsxs("label",{className:"field",children:[i.jsxs("span",{className:"ts-label",children:[e.label,e.link&&i.jsx("a",{href:e.link.href,target:"_blank",rel:"noreferrer",children:e.link.text})]}),i.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,value:e.value,placeholder:e.placeholder,onChange:o=>e.onChange(o.target.value)})]})}function M0(e){const[t,r]=x.useState(!1),o=()=>{var l;return void((l=navigator.clipboard)==null?void 0:l.writeText(e.code).then(()=>r(!0),()=>{}))};return i.jsxs("div",{className:"gh-device",children:[i.jsx("span",{className:"t-label",children:"Enter this code on GitHub"}),i.jsxs("div",{className:"gh-device-row",children:[i.jsx("code",{className:"gh-device-code t-code","aria-label":"Your code",children:e.code}),i.jsx(K,{size:"sm",variant:"ghost",onClick:o,children:t?"Copied":"Copy"})]}),i.jsxs("div",{className:"gh-device-row",children:[i.jsx("a",{className:"btn primary",href:e.href,target:"_blank",rel:"noreferrer",onClick:o,children:"Open GitHub"}),i.jsx(K,{size:"sm",variant:"ghost",onClick:e.onCancel,children:"Cancel"})]}),i.jsx(Hs,{label:"Waiting for you to approve on GitHub…"})]})}function A0(e){switch(e.kind){case"code":return{kind:"code",userCode:e.userCode,verificationUri:e.verificationUri,interval:e.interval,asked:0};case"unavailable":return{kind:"ended",reason:"Sign in with GitHub isn’t set up in this build"};case"error":return{kind:"ended",reason:e.error};default:return e}}function L0(e,t){switch(t.kind){case"waiting":return{...e,interval:t.interval,asked:e.asked+1};case"signed-in":return{kind:"idle"};case"expired":return{kind:"ended",reason:"The code expired before it was approved"};case"denied":return{kind:"ended",reason:"The sign-in was declined on GitHub"};case"none":return{kind:"ended",reason:"The sign-in was stopped"};case"error":return{kind:"ended",reason:t.error};default:return t}}const Rt=rx(Se());function Di(e,t){e({tracker:t});const r=new URL(location.href);r.searchParams.delete("tracker"),location.href=r.toString()}function R0(e){const[t,r]=x.useState({kind:"idle"}),o=x.useRef(e);o.current=e;const l=t.kind==="code";return x.useEffect(()=>{if(t.kind!=="code")return;let c=!0;const d=setTimeout(()=>void Rt.githubSignIn.poll().then(async f=>{c&&(f.kind==="signed-in"&&await o.current(),c&&r(L0(t,f)))},f=>c&&r({kind:"ended",reason:f.message})),Math.max(t.interval,1)*1e3);return()=>{c=!1,clearTimeout(d)}},[t]),x.useEffect(()=>{if(l)return()=>void Rt.githubSignIn.cancel().catch(()=>{})},[l]),{state:t,start(){r({kind:"starting"}),Rt.githubSignIn.start().then(c=>r(A0(c)),c=>r({kind:"ended",reason:c.message}))},cancel(){r({kind:"idle"})}}}function O0(e){const{state:t,start:r,cancel:o}=R0(e.onSignedIn);switch(t.kind){case"idle":return i.jsxs("div",{className:"gh-sign-in",children:[i.jsx(K,{variant:"primary",onClick:r,children:"Sign in with GitHub"}),i.jsx(q,{parts:["No gh login or token needed","the token stays on this machine"]})]});case"starting":return i.jsx(Hs,{label:"Asking GitHub for a code…"});case"code":return i.jsx(M0,{code:t.userCode,href:t.verificationUri,onCancel:o});case"ended":return i.jsxs("div",{className:"gh-sign-in",children:[i.jsx(K,{onClick:r,children:"Try again"}),i.jsx(q,{parts:["Didn't sign in",t.reason]})]});default:return t}}function P0(e){var d,f;const{gh:t}=e,r=t.auth&&((d=t.account)==null?void 0:d.kind)==="unknown"?`Found ${Ic(t.auth)}, but GitHub didn't accept it`:"",o=((f=t.account)==null?void 0:f.kind)==="unknown"?t.account.error:"",l=t.auth==="GITHUB_TOKEN"||t.auth==="GH_TOKEN",c=t.signIn.available&&!l;return i.jsxs(i.Fragment,{children:[r&&i.jsx(q,{parts:[r,o]}),c&&i.jsx(O0,{onSignedIn:e.onSignedIn}),c&&i.jsx("span",{className:"t-label gh-or",children:"Or paste a token"}),i.jsx(ep,{source:null,value:e.token,onChange:e.onToken,label:"Token",placeholder:"ghp_… or github_pat_…",link:{href:"https://github.com/settings/personal-access-tokens/new",text:"New token"}}),i.jsxs("span",{className:"t-meta",children:["Or run ",i.jsx("code",{className:"t-code",children:"gh auth login"})," in a terminal; this finds it in a few seconds."]}),i.jsxs("label",{className:"field",children:["Repository",i.jsx("input",{value:e.repo,placeholder:"owner/name",spellCheck:!1,onChange:g=>e.onRepo(g.target.value.trim())})]})]})}function tp({r:e}){var o,l;if(!e)return null;if(!e.ok)return i.jsxs("div",{className:"test-line alert",children:["✕ ",e.error]});const t=(o=e.rate)!=null&&o.limit?`${(l=e.rate.remaining)==null?void 0:l.toLocaleString()}/${e.rate.limit.toLocaleString()} req`:"";let r="";return e.canWrite===!1?r="read-only":e.canWrite&&(r="read/write"),i.jsxs("div",{className:"test-line ok",children:["✓ ",[e.account,e.target,r,t].filter(Boolean).join(" · ")]})}function Ac(e){const[t,r]=x.useState(),[o,l]=x.useState(0);x.useEffect(()=>{if(r(void 0),!e.enabled)return;let d=!0;return e.load().then(f=>d&&r(f),f=>d&&r(e.failed(f.message))),()=>{d=!1}},[e.enabled,e.key,o]);const c=x.useCallback(()=>l(d=>d+1),[]);return{value:t,retry:c}}function _0(e){const{value:t,retry:r}=Ac({enabled:e.enabled,key:e.auth??"",load:()=>Rt.githubRepos(),failed:o=>({kind:"error",error:o})});return{list:t,retry:r}}function np(e){const t=e.s.github,r=Kl(t),[o,l]=x.useState(!r),[c,d]=x.useState(t.repo??t.detectedRepo??""),[f,g]=x.useState(""),[m,v]=x.useState(),[y,w]=x.useState(!1),{list:j,retry:$}=_0({enabled:!o,auth:t.auth});x.useEffect(()=>{r&&!f&&l(!1)},[r]);const N=async()=>{w(!0),v(void 0);try{await Rt.connect({active:"github",github:{repo:c,token:o?f:void 0}}),e.onConnected()}catch(X){v({ok:!1,error:X.message}),w(!1)}},E=async()=>{const X=await e.reload();X&&Kl(X.github)&&l(!1)},M=async()=>{await Rt.githubSignIn.signOut().catch(()=>{});const X=await e.reload();l(!X||!Kl(X.github))},O=!!c&&!(!o&&!j)&&(!o||!!f||r);return i.jsxs("div",{className:"card inset tracker-setup",children:[o?i.jsx(P0,{gh:t,token:f,onToken:g,repo:c,onRepo:d,onSignedIn:E}):i.jsxs(i.Fragment,{children:[i.jsx(b0,{gh:t,repo:c,onUseAnother:()=>l(!0),onSignOut:()=>void M()}),i.jsx(E0,{list:j,detected:t.detectedRepo,value:c,onChange:d,onRetry:$})]}),i.jsx(tp,{r:m}),i.jsx("footer",{children:i.jsx("button",{type:"button",className:"btn primary",disabled:y||!O,onClick:()=>void N(),children:y?"Connecting…":"Connect"})})]})}function D0(e){return e.line?i.jsxs("div",{className:"gh-identity",children:[i.jsxs("div",{className:"ln-who",children:[i.jsx("span",{className:"t-body",children:e.line}),e.email&&i.jsx(q,{parts:[e.email]})]}),e.onUseAnother&&i.jsx("button",{type:"button",className:"btn ghost sm",onClick:e.onUseAnother,children:"Use another key"})]}):null}const B0={LINEAR_API_KEY:"LINEAR_API_KEY",stored:"a saved key"},Lc=e=>B0[e]??e;function Uo(e){return(e==null?void 0:e.kind)==="user"?e:void 0}const z0=e=>!!e.auth&&!!Uo(e.viewer);function sp(e,t){if(e)return t?`${e} / ${t}`:e}function ip(e){const t=Uo(e.viewer);if(!t)return;const r=sp(e.team,e.project)??"the team you pick",o=e.source?` (${Lc(e.source)})`:"";return`Will use ${r} in ${t.orgName} as ${t.name}${o}`}function F0(e){const t=sp(e.teamName??e.teamKey,e.projectName);if(!e.teamId||!t)return;const r=Uo(e.viewer),o=e.orgName??(r==null?void 0:r.orgName),l=o?` in ${o}`:"",c=r?` as ${r.name}`:"",d=e.auth?`, using ${Lc(e.auth)}`:"";return`Connected to ${t}${l}${c}${d}`}function U0(e,t){if(!e.activeAt)return"No issues yet";const r=Math.floor((t-Date.parse(e.activeAt))/864e5);return r<1?"Active today":r<60?`Active ${r}d ago`:`Active ${Math.floor(r/30)}mo ago`}function H0(e){var l,c;const{ln:t}=e,r=t.auth&&((l=t.viewer)==null?void 0:l.kind)==="unknown"?`Found ${Lc(t.auth)}, but Linear didn't accept it`:"",o=((c=t.viewer)==null?void 0:c.kind)==="unknown"?t.viewer.error:"";return i.jsxs(i.Fragment,{children:[r&&i.jsx(q,{parts:[r,o]}),i.jsx(ep,{source:null,value:e.apiKey,onChange:e.onKey,label:"API key",placeholder:"lin_api_…",link:{href:"https://linear.app/settings/account/security",text:"New key"}}),i.jsxs("span",{className:"t-meta",children:["Or set ",i.jsx("code",{className:"t-code",children:"LINEAR_API_KEY"})," before starting Teamtrail."]})]})}function W0(e){const{list:t}=e;if(!t)return i.jsx(Hs,{label:"Loading projects…"});if(t.kind==="error")return i.jsx(Sc,{what:"Couldn't list the team's projects",reason:t.error,onRetry:e.onRetry});if(t.kind!=="ok"||!t.projects.length)return null;const r=[{value:"",label:"All projects"},...t.projects.map(o=>({value:o.id,label:o.state?`${o.name} · ${o.state}`:o.name}))];return i.jsxs("label",{className:"field",children:["Project (optional)",i.jsx(ct,{"aria-label":"Project",value:e.value,onChange:e.onChange,options:r})]})}function K0(e){const t=e.query.trim().toLowerCase(),r=t?e.teams.filter(o=>o.key.toLowerCase().includes(t)||o.name.toLowerCase().includes(t)):e.teams;return{shown:r.slice(0,e.limit),matches:r.length}}function V0(e,t){return t&&e.some(r=>r.id===t)?t:e.length===1?e[0].id:void 0}function G0(e){const{team:t}=e;return i.jsx(Ae,{as:"li",className:"repo-row team-row",selected:e.selected,title:t.name,context:i.jsx(q,{parts:[{text:t.key,code:!0},U0(t,e.now)]}),onOpen:e.onPick})}const Q0=40;function q0(e){const[t,r]=x.useState(""),o=x.useMemo(()=>Date.now(),[]),{shown:l,matches:c}=K0({teams:e.teams,query:t,limit:Q0}),d=c>l.length?`${c-l.length} more: type to narrow`:"",f=e.truncated?`The first ${e.teams.length} teams`:"",g=e.value?"":"Pick the team your trails go in";return i.jsxs("div",{className:"repo-picker",children:[i.jsxs("label",{className:"field",children:["Team",i.jsx("input",{value:t,placeholder:"Search your teams by key or name",spellCheck:!1,"aria-label":"Search teams",onChange:m=>r(m.target.value)})]}),i.jsx("ul",{className:"repo-list","aria-label":"Teams",children:l.map(m=>i.jsx(G0,{team:m,selected:m.id===e.value,now:o,onPick:()=>e.onChange(m.id)},m.id))}),i.jsx(q,{parts:[!c&&"No team matches",g,d,f]})]})}function Y0(e){const{list:t}=e;if(!t)return i.jsx(Hs,{label:"Loading teams…",rows:3,className:"picker-loading"});switch(t.kind){case"ok":return i.jsx(q0,{teams:t.teams,truncated:t.truncated,value:e.value,onChange:e.onChange});case"no-key":return i.jsx(q,{parts:["Paste a Linear API key to list your teams"]});case"error":return i.jsx(Sc,{what:"Couldn't list your teams",reason:t.error,onRetry:e.onRetry});default:return t}}function J0(e,t){const[r,o]=x.useState(e);return x.useEffect(()=>{const l=setTimeout(()=>o(e),t);return()=>clearTimeout(l)},[e,t]),r}function X0(e){const{value:t,retry:r}=Ac({enabled:e.enabled&&!!e.teamId,key:`${e.teamId}
|
|
128
|
+
${e.apiKey??""}`,load:()=>Rt.linearProjects(e.teamId,e.apiKey),failed:o=>({kind:"error",error:o})});return{list:t,retry:r}}function Z0(e){const{value:t,retry:r}=Ac({enabled:e.enabled,key:e.apiKey??"",load:()=>Rt.linearTeams(e.apiKey),failed:o=>({kind:"error",error:o})});return{list:t,retry:r}}function eN(e){const t=J0(e.apiKey.trim(),400),r=e.paste&&t?t:void 0,o=e.paste?!!t:!!e.ln.auth,l=Z0({enabled:o,apiKey:r}),c=X0({teamId:e.teamId,apiKey:r,enabled:o}),d=l.list,f=c.list,g=(d==null?void 0:d.kind)==="ok"?d.teams:[],m=o&&!d,v=o&&!!e.teamId&&!f;return{enabled:o,list:d,teams:g,projects:f,loading:m||v,retryTeams:l.retry,retryProjects:c.retry}}function rp(e){var te;const t=e.s.linear,r=z0(t),[o,l]=x.useState(!r),[c,d]=x.useState(""),[f,g]=x.useState(t.teamId??""),[m,v]=x.useState(t.projectId??""),[y,w]=x.useState(),[j,$]=x.useState(!1),{enabled:N,list:E,teams:M,projects:R,loading:O,retryTeams:X,retryProjects:se}=eN({ln:t,paste:o,apiKey:c,teamId:f});x.useEffect(()=>{r&&!c&&l(!1)},[r]),x.useEffect(()=>{(E==null?void 0:E.kind)==="ok"&&g(V0(E.teams,t.teamId)??"")},[E]);const Q=M.find(P=>P.id===f),F=(R==null?void 0:R.kind)==="ok"?R.projects.find(P=>P.id===m):void 0,ie=(E==null?void 0:E.kind)==="ok"?E.viewer:t.viewer,V=o?null:t.auth,ge=ip({viewer:ie,team:Q==null?void 0:Q.name,project:F==null?void 0:F.name,source:V}),Re=async()=>{if(Q){$(!0),w(void 0);try{await Rt.connect({active:"linear",linear:{teamId:Q.id,teamKey:Q.key,teamName:Q.name,projectId:F==null?void 0:F.id,projectName:F==null?void 0:F.name,apiKey:o?c.trim():void 0}}),e.onConnected()}catch(P){w({ok:!1,error:P.message}),$(!1)}}},be=P=>{g(P),v("")};return i.jsxs("div",{className:"card inset tracker-setup linear-setup",children:[o&&i.jsx(H0,{ln:t,apiKey:c,onKey:d}),i.jsx(D0,{line:ge,email:(te=Uo(ie))==null?void 0:te.email,onUseAnother:o?void 0:()=>l(!0)}),N&&i.jsx(Y0,{list:E,value:f,onChange:be,onRetry:X}),Q&&i.jsx(W0,{list:R,value:m,onChange:v,onRetry:se}),i.jsx(tp,{r:y}),i.jsx("footer",{children:i.jsx("button",{type:"button",className:"btn primary",disabled:j||O||!Q,onClick:()=>void Re(),children:j?"Connecting…":"Connect"})})]})}function tN(e){return i.jsxs("div",{className:"c-actions",children:[e.canSwitch&&i.jsx("button",{className:"btn sm",disabled:!e.usable,onClick:e.onSwitch,children:"Switch"}),e.remote&&i.jsx("button",{className:`btn sm ${e.open?"on":""}`,disabled:!e.usable,onClick:e.onToggle,children:e.configured?"Edit":"Connect"})]})}function nN(e){const{id:t,active:r,s:o}=e,l=_i(t),c=r&&o?sN(t,o):void 0;return c?i.jsx(q,{className:"c-who",parts:[c]}):r&&(t==="markdown"||l)?i.jsx("div",{className:"c-loc",children:e.location}):l&&e.configured&&o?i.jsx("div",{className:"c-loc",children:iN(t,o)}):null}function sN(e,t){if(e==="github")return N0(t.github);if(e==="linear")return F0(t.linear)}function iN(e,t){return e==="github"?t.github.repo:[t.linear.teamKey,t.linear.projectName].filter(Boolean).join(" · ")}function rN({status:e}){var c,d;if(!e)return null;const t=(c=e.rate)!=null&&c.limit?`${((d=e.rate.remaining)==null?void 0:d.toLocaleString())??"?"}/${e.rate.limit.toLocaleString()} req`:"",r=e.queued?` · ${e.queued} queued`:"",[o,l]=oN(e,r);return i.jsxs("div",{className:`sync-line ${o}`,title:e.error,children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:l}),t&&i.jsx("span",{className:"rate",children:t})]})}function oN(e,t){switch(e.state){case"online":return["ok",`Online · synced ${Mm(e.lastSyncAt)}${t}`];case"offline":return["warn",`Offline${t}`];case"rate-limited":return["warn",`Rate limited · resumes ${Vi(e.resetAt)}${t}`];case"auth-error":return["alert",`Credentials rejected${t}`];default:return["",`Connecting${t}`]}}function aN(e){const{id:t,active:r,configured:o,s:l}=e,c=_i(t),d=!c||!!l,f=["card connector",r?"active":"",d?"":"disabled",e.open?"open":""];return i.jsxs("div",{className:f.join(" "),children:[i.jsxs("div",{className:"card-row",children:[i.jsx("b",{className:"choice-title t-row-title",children:e.name}),r&&i.jsx("span",{className:"pill on",children:"Active"})]}),i.jsx(nN,{id:t,active:r,configured:o,location:e.location,s:l}),c&&r&&i.jsx(rN,{status:l==null?void 0:l[t].status}),i.jsx(tN,{canSwitch:!r&&(!c||o),remote:c,usable:d,configured:o,open:e.open,onSwitch:e.onSwitch,onToggle:e.onToggle})]})}function op(e=0){const[t,r]=x.useState(),o=x.useCallback(()=>Rt.get().then(l=>(r(l),l),()=>(r(null),void 0)),[]);return x.useEffect(()=>{if(o(),!e)return;const l=setInterval(()=>void o(),e);return()=>clearInterval(l)},[o,e]),[t,r,o]}function lN(e){const[t,,r]=op(5e3),[o,l]=x.useState(null),c=async f=>{t&&(f==="markdown"||_i(f))&&await Rt.connect({active:f==="markdown"?"markdown":f,...f==="github"&&t.github.repo?{github:{repo:t.github.repo}}:{},...f==="linear"&&t.linear.teamId?{linear:{teamId:t.linear.teamId,teamKey:t.linear.teamKey,teamName:t.linear.teamName,projectId:t.linear.projectId,projectName:t.linear.projectName}}:{}}).catch(()=>{}),Di(e.update,f)},d=x.useMemo(()=>({github:!!(t!=null&&t.github.repo),linear:!!(t!=null&&t.linear.teamId)}),[t]);return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"connectors",children:ox.map(f=>{const g=f.id;return i.jsx(aN,{id:g,name:f.name,active:g===e.activeTracker,configured:_i(g)&&d[g],open:o===g,location:e.location,s:t,onSwitch:()=>void c(g),onToggle:()=>_i(g)&&l(o===g?null:g)},f.id)})}),t&&o==="github"&&i.jsx(np,{s:t,reload:r,onConnected:()=>Di(e.update,"github")}),t&&o==="linear"&&i.jsx(rp,{s:t,onConnected:()=>Di(e.update,"linear")})]})}function cN(e,t){const r=e==null?void 0:e.github,o=e==null?void 0:e.linear,l=r&&t!=="github"?Zm(r,r.repo??r.detectedRepo):void 0,c=o&&t!=="linear"?ip({viewer:o.viewer,team:o.teamName,project:o.projectName,source:o.auth}):void 0;return[{id:"markdown",title:"Local markdown",sub:"Files in .teamtrail/ in this repo"},{id:"github",title:"GitHub Issues",sub:l??"Trails as labelled issues in your repo"},{id:"linear",title:"Linear",sub:c??"Trails and tickets in your Linear team"}]}function He(e){return i.jsxs("section",{className:"set-sec",children:[i.jsx(Je,{as:"h4",children:e.title}),e.children]})}function ap(e){const t=[{v:"summary",title:"Summary"},{v:"full",title:"Full transcript"}];return i.jsx("div",{className:"choice-row",children:t.map(r=>i.jsx(ht,{on:e.value===r.v,title:r.title,onClick:()=>e.onChange(r.v)},r.v))})}const uN={github:"Checking for a GitHub login…",linear:"Checking for a Linear key…"};function dN(e){const{prefs:t,update:r}=e,[o,,l]=op(5e3),[c,d]=x.useState(!1),f=cN(o??void 0,t.tracker),g=t.tracker==="github"||t.tracker==="linear",m=g&&(o==null?void 0:o.active)===t.tracker,v=g&&!m,y=j=>{r({onboarded:!0}),Di(r,j)},w=async()=>{d(!0),t.tracker==="markdown"&&o&&await Rt.connect({active:"markdown"}).catch(()=>{}),r({onboarded:!0}),t.tracker!==e.activeTracker&&Di(r,t.tracker)};return i.jsx("div",{className:"scrim",children:i.jsxs(Ke,{as:"div",className:"dialog onboarding",children:[i.jsxs("div",{className:"onb-brand",children:[i.jsx(uw,{size:22,bare:!0}),i.jsx(Bm,{className:"onb-title"})]}),i.jsxs("h2",{className:"onb-question t-heading",children:[i.jsx(vw,{className:"voice-badge",size:22}),"Where should your trails live?"]}),i.jsxs(He,{title:"Tracker",children:[i.jsx("div",{className:"choice-row",children:f.map(j=>i.jsx(ht,{on:t.tracker===j.id,title:j.title,sub:j.sub,onClick:()=>r({tracker:j.id})},j.id))}),o===void 0&&g&&i.jsx(Hs,{label:uN[t.tracker]??"Checking…"}),o&&t.tracker==="github"&&!m&&i.jsx(np,{s:o,reload:l,onConnected:()=>y("github")}),o&&t.tracker==="linear"&&!m&&i.jsx(rp,{s:o,onConnected:()=>y("linear")})]}),i.jsx(He,{title:"HITL transcript",children:i.jsx(ap,{value:t.hitlTranscript,onChange:j=>r({hitlTranscript:j})})}),i.jsx("footer",{children:i.jsx(K,{variant:"primary",disabled:c||v,onClick:()=>void w(),children:"Get started"})})]})})}const Hi=[{id:"trail",label:"This trail",intro:"How agents work on the trail on screen: its mode, the checks that prove work done, models and guides.",sections:[{id:"mode",title:"Trail mode"},{id:"verification",title:"Verification"},{id:"models",title:"Model matching"},{id:"team",title:"Team"}]},{id:"project",label:"Project",intro:"Where this repo keeps its trails, and the rules every agent working in it follows.",sections:[{id:"tracker",title:"Tracker"},{id:"workspaces",title:"Workspaces"},{id:"policy",title:"Risk policy"},{id:"guides",title:"Guides"},{id:"labels",title:"Labels"}]},{id:"alerts",label:"Attention & alerts",intro:"What interrupts you, where questions reach you, and what Scout tells you when you come back.",sections:[{id:"attention",title:"Attention"},{id:"slack",title:"Slack"},{id:"trip-report",title:"Trip report"}]},{id:"you",label:"You",intro:"How the Lookout looks and reads for you.",sections:[{id:"appearance",title:"Appearance"},{id:"transcript",title:"HITL transcript"},{id:"agent",title:"Agent"}]},{id:"projects",label:"All projects",intro:"Every repo this Lookout knows, so you can switch between them from the header.",sections:[{id:"projects",title:"Projects"}]},{id:"about",label:"About",intro:"What Teamtrail is, and what changed in each release.",sections:[{id:"changelog",title:"Changelog"}]}];function lp(e){if(e===null)return null;const t=Hi.find(l=>l.id===e);if(t)return{group:t.id};const r=Hi.find(l=>l.sections.some(c=>c.id===e));if(!r)return{};const o=r.sections.find(l=>l.id===e);return{group:r.id,section:o==null?void 0:o.id}}const bh={from:"18:00",to:"09:00"};function fN(e){const t=e.focus!==void 0,r=e.focus??bh;return i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Quiet hours"}),i.jsx(K,{size:"sm",on:t,"aria-pressed":t,onClick:()=>e.onChange(t?void 0:bh),children:t?"On":"Off"}),t&&i.jsxs(i.Fragment,{children:[i.jsx("input",{type:"time","aria-label":"Quiet from",value:r.from,onChange:o=>o.target.value&&e.onChange({...r,from:o.target.value})}),i.jsx("span",{className:"t-meta",children:"to"}),i.jsx("input",{type:"time","aria-label":"Quiet until",value:r.to,onChange:o=>o.target.value&&e.onChange({...r,to:o.target.value})})]})]})}const hN=[{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 mN(){typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()}function pN(){const{view:e,error:t,savePrefs:r}=Jm(0);if(!e)return null;const o=e.policy.value,l=`${ve.dataDir}/attention.json`,c=f=>void r({...e.prefs,...f}),d=typeof Notification<"u"&&Notification.permission==="denied";return i.jsxs(He,{title:"Attention",children:[i.jsxs("p",{className:"vf-intro",children:["Everything that needs you is ranked in Waiting on you. Only items scoring ",o.interrupt," or more interrupt you; the rest wait in the queue, and Slack gets them in a digest."]}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Interrupt me by"}),i.jsx(ct,{compact:!0,"aria-label":"Interrupt me by",value:e.prefs.channel,options:hN,onChange:f=>{f==="browser"&&mN(),c({channel:f})}})]}),e.prefs.channel==="browser"&&d&&i.jsx("span",{className:"vf-err",children:"The browser blocks notifications for this page. Allow them in its site settings."}),i.jsx(fN,{focus:e.prefs.focus,onChange:f=>c({focus:f})}),i.jsx("span",{className:"set-hint t-meta",children:"Your channel and quiet hours stay on this machine."}),e.policy.errors.length>0&&i.jsx("ul",{className:"vf-errors",children:e.policy.errors.map(f=>i.jsxs("li",{children:[l,": ",f]},f))}),i.jsx(q,{className:"set-hint",parts:[e.policy.exists?{text:l,code:!0}:"Team defaults",`interrupt at ${o.interrupt}`,o.digestMinutes?`Slack digest every ${o.digestMinutes} min`:"Slack digest off"]}),t&&i.jsx("span",{className:"vf-err",children:t})]})}const gN=[5,15,30,60];function vN(e){const{value:t}=e;return i.jsxs("div",{className:"choice-row compact",children:[i.jsx(ht,{on:!t.enabled,title:"Off",onClick:()=>e.onChange({...t,enabled:!1})}),gN.map(r=>i.jsx(ht,{on:t.enabled&&t.awayMinutes===r,title:`Away ${r} min`,onClick:()=>e.onChange({enabled:!0,awayMinutes:r})},r))]})}const kN={repo:"Committed to the repo",machine:"Only on this machine",browser:"Only in this browser"};function it(e){const t=e.storage&&kN[e.storage];return i.jsxs("div",{className:"sp-slot",id:`settings-${e.id}`,children:[e.children,t&&i.jsx(q,{className:"sp-where",parts:[t]})]})}function yN(e){const[t]=Ec();return t?i.jsx(He,{title:"Slack",children:i.jsx(yj,{focus:e.focus})}):null}function xN({data:e,route:t}){return i.jsxs(i.Fragment,{children:[i.jsx(it,{id:"attention",storage:"repo",children:i.jsx(pN,{})}),i.jsx(it,{id:"slack",storage:"machine",children:i.jsx(yN,{focus:t.section==="slack"})}),i.jsx(it,{id:"trip-report",storage:"browser",children:i.jsx(He,{title:"Trip report",children:i.jsx(vN,{value:e.prefs.briefing,onChange:r=>e.update({briefing:r})})})})]})}const wN=[{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"]}],jN=[{area:"Teamtrail Cloud",items:["Agents that run in the cloud, steered from the same Lookout"]}],NN=[{version:"0.24.2",date:"2026-11-10",items:["A ticket’s description no longer repeats which trail it is part of"]},{version:"0.24.1",date:"2026-11-10",items:["Buttons in the same row are always the same size"]},{version:"0.24.0",date:"2026-11-10",items:["Focus in the header: see at a glance whether it is on, and start or end it in one click","Sign in with GitHub, and pick your repo or Linear team from a searchable list","Write your own guides with `teamtrail guides new`, approve them in Settings and share them with the catalog","Settings is its own page, and the trail map has a cleaner, flatter look","Smaller polish: one colour for work in progress everywhere, a calmer first run and clearer Slack setup"]},{version:"0.23.0",date:"2026-11-08",items:["Match work to models: switch it on for a trail in Settings and each agent gets the tickets that fit the model it runs on, research on fast models and junctions on the strongest. You set the tier per ticket type; Teamtrail never switches a model, and a ticket no connected agent is strong enough for waits in your queue","Guides: a ticket can ask for a reviewer, QA, security, docs or architect, and the agent that claims it gets that guide’s instructions and a checklist it must answer before the work counts as done. Pick a trail’s team and each ticket’s guide in the Lookout, and add more guides from a moderated catalog in Settings → Guides. A guide can add checks but never remove one, its commands only run after you approve them, and a guide file edited after you approved it is switched off until you look at it again","Records has a new Trail stats view: delivery across every trail, by vendor, agent and ticket type, with plain observations from your own numbers. Teamtrail doesn't route work from them","MILOOPS is now Teamtrail. Missions are trails, the command center is the Lookout, MILO is Scout, and `/milo` is `/scout`","More room for the map: the summary of counts now slides up from a tab when you want it","A new day and night look, starting in night, with an Appearance setting to switch to day or follow your system","The map is now a landscape: tickets are trail signs, the trail shows what is walked and what is ahead, and an X marks the destination","A new greeting when you start `teamtrail` in a terminal","A new logo, a t whose stem runs along a trail to a node, and a new look for Scout: the original CRT head with ear cups and a baseball cap, with a lamp on the cap at night. No more pixel art, and new fonts too","All projects: every repo you supervise in one view, with one list of what needs you across them and what changed while you were away. Answer an agent's question in any repo from there, and switch projects from the header. Agents add their repo when they connect (`--no-register` opts out), or add one with `teamtrail projects add`"]},{version:"0.22.0",date:"2026-11-05",items:["A calmer, clearer command center: every list now reads the same way, what it is first, then one quiet line of context, and details when you want them","Red now only means something needs you now; other states show as a thin edge instead of colored text everywhere","The open question in a conversation can no longer be hidden by its suggested answers, and the phone header no longer runs off the side"]},{version:"0.21.0",date:"2026-11-05",items:["New plans can now edit a ticket, remove a dependency and reopen finished work, instead of working around it","Slack digests follow the team's digest setting (digestMinutes in attention.json); 0 turns them off, and everything still waits in Waiting on you","Remove a finished task's workspace from Settings → Workspaces or the ticket; the branch stays, and MILOOPS asks before discarding uncommitted changes"]},{version:"0.20.0",date:"2026-11-04",items:["Separate workspaces: switch on Settings → Workspaces and each ticket an agent claims gets its own copy of the repo on its own branch, so agents working at the same time don’t step on each other. When the work is done you get the branch to review; MILOOPS never merges or pushes for you","Warnings before a clash: agents say which files they expect to change. When two of them plan to change the same files, the second one is warned, and you see it in Waiting on you; open it to release either claim","When two agents’ branches did change the same files, Waiting on you suggests a ticket to bring the work together. One click adds it, waiting on both tickets, with the files listed","The ticket inspector shows which files an agent expects to change and the branch it works on","Fix: an execute ticket marked as needing you keeps that mark when saved to local files, GitHub Issues or Linear"]},{version:"0.19.0",date:"2026-11-04",items:["Risk policy: you decide what always needs you, such as database changes, logins and permissions, billing, deleting data or new dependencies (Settings → Risk policy). Agents can no longer make those calls on their own; they ask you. Their other decisions are labelled by risk in the briefing, and work that touched risky files without asking comes to you to check","One ranked list of everything that needs you in Waiting on you: questions, approvals, blocked work, briefs, knowledge and new plans, most important first, each with the reason (for example “blocks 3 tickets” or “claude-02 is waiting”). Related items are grouped so you answer them together; snooze what can wait","Fewer interruptions: agents say how urgent a question is, and only urgent items notify you (browser or Slack). Focus for an hour from the header, set quiet hours in Settings → Attention, and the rest waits in the list and the digest","Plans that adapt: missions list the assumptions they rely on, starting with the ones in the discovery brief. When an agent finds one is wrong, it shows the evidence and proposes a new plan; the tickets it would change are paused, the map previews the change, and nothing happens until you approve","Challenge the destination: an agent can tell you the work already exists, the mission targets the wrong problem, or it should be rescoped, with evidence and a suggested new goal","Assumptions on the Plan tab (confirm the ones you know are true) and an assumptions field when you create a mission","Fix: when an agent asks two questions at once, your answer goes to the one you opened; the inbox stats line no longer gets covered by the list"]},{version:"0.18.0",date:"2026-11-04",items:["Acceptance criteria: agents write down what done means before they start (required on missions with a discovery brief). When they finish, each point needs proof: one of your checks, a named test, the pull request, or your sign-off","Work whose criteria lack proof goes back with the reason; points only you can confirm come to your inbox to sign off","Business rules from your project knowledge are suggested as criteria, and the ticket shows any rule no criterion covers yet. Confirm a ticket’s criteria in the inspector","Cross-vendor review: when Claude and Codex agents both run, each reviews the other’s work first","Fix: answers from the command center could hang when too many live updates were open; all updates now share one connection"]},{version:"0.17.0",date:"2026-11-03",items:["Discovery brief: new missions start with an agent mapping the existing system (files, conventions, data and API impact, risks, assumptions, product context). Implementation tickets wait until you accept the brief or ask for changes, from the banner over the map or the card in Communication","Create mission: start a mission from the New mission dialog without a terminal; any agent picks it up with /milo resume","Knowledge: what agents need to know about your codebase and product (architecture, conventions, gotchas, dead ends, business rules, personas, UX principles, pricing). Agents propose, you confirm, keep as an assumption or retire. Confirmed entries reach agents with every claim, picked for the ticket with the reason, and the inspector shows what an agent gets","Knowledge about specific files is flagged for re-confirmation when those files change","Save decisions, cancelled tickets (as dead ends) and brief sections as knowledge in one click; seed it from a document with miloops knowledge import <file.md>"]},{version:"0.16.0",date:"2026-11-03",items:["Mission report (Mission plan → Report): tickets done, mission and median ticket lead time, your interventions, rework, review results and cost per verified ticket. Hover any number to see how it is computed; export it as markdown","Agents report the same numbers in one line from the status tool","Agents use missions for big work only, and decide routine calls themselves, keeping each one as a decision record you can review or reverse; they ask you when the call changes product behaviour, data, security, billing, a public API or the schema","Decisions: filter by who made the call, agents on their own or people. The briefing now counts only the calls agents made themselves, not your answers they recorded"]},{version:"0.15.0",date:"2026-10-31",items:["Verification in the ticket inspector: the level that applies and where it comes from, every attempt newest first with the git evidence (base → head, files changed, flags), its checks, exit codes, durations and the failing output, and the full log on demand","Verifying, Rework and Blocked on the map, in the legend and as status counters on missions that verify completions","Operator calls on a verifying or blocked ticket: Approve, Re-run checks, Send to rework with a note, Accept anyway and Unblock. Overrides need a reason, and each call is kept as a verdict next to the attempts and in the mission history. Approve asks for a re-run when the code changed since the checks passed","Set the verification level of a mission (Settings → Verification) or of one ticket (inspector). Only you can change it; agents cannot","The inspector updates live while checks run","Independent review: at Checks + review, a passing completion gets a review ticket that another agent takes and answers with PASS, FAIL (with findings) or NEEDS_HUMAN. The agent that did the work is never given its own review","Waiting on you lists reviewed work to approve (Checks + review + you) and held tickets, and Slack posts them with Approve and Rework… buttons","Agents can name their pull request in `report_completion` (`pr`); PR and CI tracking then follows that PR first"]},{version:"0.14.0",date:"2026-10-31",items:["Ticket lifecycle in plain words: Ready, Backlog, Working, Done and Cancelled (with Verifying, Rework and Blocked to come with verification)","Every claim, release, return to queue, resolution and rule-out goes through one lifecycle engine that records who, why and when in `.miloops/.events/<mission>.jsonl` (local history, never committed)","Settings → Verification shows the checks in `.miloops/verification.json`: argv commands with timeouts, run without a shell, secrets kept out of their environment. Read-only","Completion is a claim: on missions started with `verification.json` present, an execute or task ticket is only done once its checks pass. A failed check sends it back for Rework with the failing output (agents see it in close_ticket, next_ticket and claim_ticket, and rework comes first in the queue); after 3 failed attempts, or when the checks cannot run, it waits on you as Blocked","New MCP tools `report_completion` and `verification_status`; missions started before verification, and research, grilling and prototype tickets, close exactly as before","Git evidence, no GitHub needed: each claim records HEAD and the uncommitted state, and each completion lists the files changed since then. It flags no changes, overlap with another active ticket, a branch switch or reset, and edits to `verification.json` (which send the ticket to you as Blocked). A pass on code that changed while its checks ran is re-run","Pull request and CI evidence: with `verification.json` and a GitHub token (Settings, `GITHUB_TOKEN` or `gh auth login`), the command center finds each ticket’s PR (its branch `miloops-<mission>-<ticket>`, a `miloops:<mission>#<ticket>` line in the PR body, or a link you set) and flags mismatches: done with the PR still open, PR merged while the ticket is in progress, PR closed unmerged, required checks failing or unknown, PR head not the verified commit. Flags never change a ticket. A CI chip in the header shows sync health and never shows synced after a failed sync"]},{version:"0.13.0",date:"2026-10-31",items:["Crash recovery for claims: an agent’s claim is a lease (15 min by default) that every tool call renews, including waits on your answer","When an agent crashes or goes silent, its ticket goes back to the queue on its own, and the activity log says so; the next agent picks it up from next_ticket or claim_ticket","The returned ticket keeps a handoff comment with the previous agent’s progress notes and decisions, so the next agent resumes instead of starting over","Stalled state on the map, in sessions and in the ticket inspector when a lease is about to run out, with a Release to queue action","Works with GitHub and Linear: the return is an ordinary comment + unassign, queued in the offline outbox like any other write","Set the lease with `miloops mcp --lease-minutes <n>` or `MILOOPS_LEASE_MINUTES`"]},{version:"0.12.0",date:"2026-10-31",items:["Slack: your own MILO app, created from a manifest and connected from your machine over Socket Mode in five guided steps (Settings → Slack or `miloops connect slack`)","Tokens stay in your local credential store next to the GitHub and Linear ones; nothing passes through MILOOPS servers","Agent questions arrive as a Slack DM with answer buttons and a Reply… box; answering there resolves the item in Waiting on you, and answering in the command center closes the DM","Save as decision on any message, or `/milo decide`: the form is prefilled with a summary of the thread, and the decision is recorded with a permalink, resolving the related ticket by default","`/milo status` and `/milo inbox` for the mission at a glance; DMs when a ticket is blocked or a mission is done","Allowed users, notification target and events in Settings → Slack","Slack setup without Paste clicks: press ⌘V / Ctrl+V anywhere, or in Chrome just come back to the tab after copying; pasting the app token opens the install page; MILO recognises you by your git email, so there is nothing to claim in Slack"]},{version:"0.11.0",date:"2026-10-31",items:["GitHub Issues tracker: missions are labelled issues, tickets are sub-issues, blocking uses native issue dependencies",'Linear tracker: missions are labelled issues in a team (optionally one project), tickets are sub-issues, blocking uses "blocks" relations',"Two-way sync: tickets, status, claims, comments, blockers and decisions written from MILOOPS land in the tracker; changes made there show up within seconds","Decisions are posted as comments on their ticket and listed in the mission","Connect from Settings with Test connection; GitHub reuses your gh login or GITHUB_TOKEN, Linear takes a personal API key","Tokens stay on your machine: kept by the local server, never sent to the browser or anywhere else","Offline and rate limits: changes queue and send in order when the tracker answers again; the connector shows status, queue and remaining requests","Connected agents (MCP) work on the active tracker: with GitHub or Linear connected, their missions, claims and decisions land there, and their sessions show live in the command center"]},...wN];function SN(){return i.jsxs("div",{className:"changelog",children:[i.jsxs("div",{className:"about",children:[i.jsx(Bm,{className:"about-name"}),i.jsx("span",{className:"mono-label",children:ve.category}),i.jsx("p",{className:"onb-tagline",children:ve.tagline}),i.jsx(q,{parts:[ve.assistant.name]})]}),i.jsx(He,{title:"Next",children:jN.map(e=>i.jsxs("div",{className:"cl-row",children:[i.jsx("span",{className:"mono-label",children:e.area}),i.jsx("ul",{children:e.items.map(t=>i.jsx("li",{children:t},t))})]},e.area))}),NN.map(e=>i.jsx(He,{title:`${e.version} · ${e.date}`,children:i.jsx("ul",{children:e.items.map(t=>i.jsx("li",{children:t},t))})},e.version))]})}function cp(e){return i.jsx("ul",{className:"checklist-answers",children:e.answers.map(t=>i.jsxs("li",{className:t.done?"done":"not-done",children:[i.jsx("span",{className:"mark","aria-label":t.done?"Done":"Not done",children:t.done?"✓":"–"}),i.jsx("span",{className:"t-body",children:t.item}),t.note&&i.jsx("span",{className:"t-meta note",children:t.note})]},t.item))})}const up=`${ve.apiPrefix}`;async function dp(e){const t=await e.json().catch(()=>({}));if(!e.ok)throw new Error(t.error??`Request failed (${e.status})`);return t}const No=async e=>dp(await fetch(`${up}${e}`)),fp=async(e,t)=>dp(await fetch(`${up}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}));let hp;const go=new Set;let Is;function So(e){hp=e;for(const t of go)t()}function Ch(){No("/guides").then(So,()=>So(null))}const bN=()=>hp;function CN(e){return go.add(e),Is||(Ch(),Is=pn(t=>{t.includes("guides")&&Ch()})),()=>{go.delete(e),!go.size&&(Is==null||Is(),Is=void 0)}}function gn(){const e=x.useSyncExternalStore(CN,bN),t=x.useCallback(async(o,l)=>{try{So(await fp(o,l));return}catch(c){return c.message}},[]),r=x.useCallback(o=>o?e==null?void 0:e.guides.find(l=>l.id===o):void 0,[e]);return{view:e,act:t,find:r}}function $N(e){var f;const{view:t,find:r}=gn(),o=r(e.id),l=t!=null&&(o==null?void 0:o.status)!=="active",c=((f=o==null?void 0:o.guide)==null?void 0:f.name)??e.id,d=l?`${c}: ${(o==null?void 0:o.reason)??"not installed"}`:`Guide: ${c}`;return i.jsx("span",{className:We("guide-chip",l&&"off"),"data-guide-id":e.id,title:d,children:c})}const TN={active:"Active",unapproved:"New, waiting for your approval",tampered:"Changed since you approved it",invalid:"Can't be used"},EN={active:"Approved",unapproved:"Not approved yet",tampered:"Changed since you approved it",invalid:"Can't be used"},oc=e=>{var t;return e.origin==="local"&&(!((t=e.lock)!=null&&t.source)||e.lock.source==="local")};function IN(e){return oc(e)?{text:EN[e.status],strong:e.status==="active"}:e.status==="active"?void 0:TN[e.status]}function MN(e){var r;if(e.origin==="builtin")return"Built in";const t=(r=e.lock)==null?void 0:r.source;if(!t||t==="local")return e.overridesBuiltin?"Local, replaces the built-in":"Local";try{return`From ${new URL(t.registry).host}`}catch{return"From a catalog"}}const Rc=e=>e.map(t=>/\s/.test(t)?JSON.stringify(t):t).join(" "),$h=3;function AN(e,t){return e.length<=Math.max(t,$h+1)?e:`${e.slice(0,Math.max(t-1,$h)).trimEnd()}…`}function LN(e){var o;const t=(o=e.lock)==null?void 0:o.review;return!t||e.status!=="active"?void 0:t.verified?{text:"Verified",strong:!0,tip:t.reviewedBy.length>0?`Reviewed by ${t.reviewedBy.join(", ")}`:void 0}:"Not reviewed"}var RN=em();function ON(e){var w;const{preview:t}=e,{act:r,find:o}=gn(),[l,c]=x.useState({kind:"ready"}),[d,f]=x.useState(),g=t.entry.id,m=async()=>{f(void 0),c({kind:"adding"});try{c({kind:"added",pending:(await e.add(g)).pendingChecks})}catch(j){f(j.message),c({kind:"ready"})}};if(t.entry.builtin)return i.jsxs("span",{className:"t-meta",children:["Built into ",ve.name,": already available to every trail, nothing to add."]});if(l.kind!=="added"){const j=e.installed===t.entry.version,$=e.installed?"Update guide":"Add guide";return i.jsxs("div",{className:"add-guide",children:[!t.ok&&i.jsx("span",{className:"t-meta",children:"The safety lint found errors, so this guide can't be added."}),i.jsx(K,{variant:"primary",disabled:!t.ok||j||l.kind==="adding",onClick:()=>void m(),children:j?"Added":$}),d&&i.jsx("span",{className:"vf-err",children:d})]})}const v=((w=o(g))==null?void 0:w.pendingChecks)??l.pending,y=async j=>f(await r("/guides/checks/approve",{id:g,name:j}));return i.jsxs("div",{className:"add-guide",children:[i.jsx("p",{className:"t-body",children:v.length?`Added ${g} ${t.entry.version}. Approve each command it proposes; none runs until you do.`:`Added ${g} ${t.entry.version}. Agents get its instructions on tickets that ask for ${g}.`}),v.map(j=>{var $,N;return i.jsxs("span",{className:"guide-check",children:[i.jsxs("code",{className:"t-code",children:[j,": ",Rc(((N=($=t.guide)==null?void 0:$.proposedChecks[j])==null?void 0:N.run)??[])]}),i.jsxs(K,{size:"sm",onClick:()=>void y(j),children:["Approve check ",j]})]},j)}),d&&i.jsx("span",{className:"vf-err",children:d})]})}function PN(e){return e.findings.length?i.jsx("ul",{className:"vf-findings guide-findings",children:e.findings.map((t,r)=>i.jsxs("li",{className:`sev-${t.level}`,children:[i.jsxs("code",{className:"t-code",children:["line ",t.line]})," ",t.message," ",i.jsxs("span",{className:"t-meta",children:["(",t.rule,")"]})]},r))}):i.jsx("p",{className:"t-meta",children:"The safety lint found nothing."})}function _N(e){var o,l;const{p:t}=e,r=Object.entries(((o=t.guide)==null?void 0:o.proposedChecks)??{});return i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"t-label",children:"Safety lint"}),i.jsx(PN,{findings:t.findings}),t.guide&&t.guide.checklist.length>0&&i.jsx("span",{className:"t-label",children:"Checklist"}),t.guide&&i.jsx("ul",{className:"catalog-checklist t-body",children:t.guide.checklist.map(c=>i.jsx("li",{children:c},c))}),r.length>0&&i.jsx("span",{className:"t-label",children:"Commands it proposes"}),r.map(([c,d])=>i.jsxs("code",{className:"t-code guide-check",children:[c,": ",Rc(d.run)]},c)),i.jsx("span",{className:"t-label",children:"Instructions"}),i.jsx("pre",{className:"guide-preview",children:((l=t.guide)==null?void 0:l.instructions)??t.text})]})}function DN(e){if(!e.repo)return null;const t=encodeURIComponent(`Report: ${e.id} ${e.version}`),r=`${e.repo.replace(/\/+$/,"")}/issues/new?template=report-guide.yml&title=${t}`;return i.jsx("a",{className:"report-link t-meta",href:r,target:"_blank",rel:"noreferrer",children:"Report this guide"})}function BN(e){const t=e.entry,[r,o]=x.useState(),[l,c]=x.useState();return x.useEffect(()=>{e.preview(t.id).then(o,d=>c(d.message))},[t.id]),i.jsxs("div",{className:"catalog-entry",children:[i.jsx(K,{size:"sm",variant:"ghost",onClick:e.onBack,children:"← All guides"}),i.jsx("h3",{className:"t-title",children:t.name??t.id}),i.jsx(q,{parts:[{text:t.id,code:!0},t.version,`by ${t.author}`,zN(t),t.reviewedBy.length>0&&`reviewed by ${t.reviewedBy.join(", ")}`]}),i.jsx("p",{className:"t-body",children:t.summary}),t.history.length>0&&i.jsx("ul",{className:"catalog-history",children:t.history.map(d=>i.jsxs("li",{className:"t-meta",children:[d.version," · ",i.jsx("code",{className:"t-code",children:d.commit.slice(0,8)})," · ",d.at.slice(0,10),d.reviewer&&` · reviewed by ${d.reviewer}`]},`${d.version}-${d.commit}`))}),l&&i.jsx("span",{className:"vf-err",children:l}),r&&i.jsx(_N,{p:r}),r&&i.jsx(DN,{repo:r.repo,id:t.id,version:t.version}),r&&i.jsx(ON,{preview:r,installed:e.installed,add:e.add})]})}function zN(e){return e.builtin?{text:"Built in",strong:!0}:e.verified?{text:"Verified",strong:!0}:"Not reviewed"}function FN(e){const t=e.entry;return i.jsx("li",{className:"catalog-row","data-guide-id":t.id,children:i.jsx(Ae,{title:t.name??t.id,context:i.jsx(q,{parts:[{text:t.id,code:!0},t.version,t.author,UN(t),t.reported&&"Reported"]}),detail:t.summary,trailing:e.installed&&`installed ${e.installed}`,onOpen:e.onOpen})})}function UN(e){return e.builtin?{text:"Built in",strong:!0}:e.verified?{text:"Verified",strong:!0}:"Not reviewed"}const Th=e=>e?`registry=${encodeURIComponent(e)}`:"";function HN(e){const[t,r]=x.useState(),[o,l]=x.useState();x.useEffect(()=>{let f=!0;return r(void 0),l(void 0),No(`/guides/catalog?${Th(e)}`).then(g=>f&&r(g),g=>f&&l(g.message)),()=>{f=!1}},[e]);const c=x.useCallback(f=>No(`/guides/catalog/preview?${Th(e)}&id=${encodeURIComponent(f)}`),[e]),d=x.useCallback(async f=>{const g=await fp("/guides/catalog/add",{registry:e,id:f});return So(g),g.installed},[e]);return{index:t,error:o,preview:c,add:d}}function WN(e){var $,N;const[t,r]=x.useState((($=e.registries[0])==null?void 0:$.name)??""),o=HN(t||void 0),{find:l}=gn(),[c,d]=x.useState(""),[f,g]=x.useState(!0),[m,v]=x.useState(),y=o.index?ux({guides:o.index.guides},{query:c,verifiedOnly:f}):[],w=(N=o.index)==null?void 0:N.guides.find(E=>E.id===m),j=E=>{var M,R,O;return((M=l(E))==null?void 0:M.origin)==="local"?(O=(R=l(E))==null?void 0:R.guide)==null?void 0:O.version:void 0};return RN.createPortal(i.jsx("div",{className:"scrim catalog-scrim",onClick:E=>{E.stopPropagation(),e.onClose()},children:i.jsxs(Ke,{as:"div",className:"dialog catalog-dialog",onClick:E=>E.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h3",{className:"t-title",children:"Guide catalog"}),e.registries.length>1&&i.jsx(ct,{compact:!0,"aria-label":"Catalog",value:t,options:e.registries.map(E=>({value:E.name,label:E.name,hint:E.url})),onChange:r}),i.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})]}),w?i.jsx(BN,{entry:w,installed:j(w.id),preview:o.preview,add:o.add,onBack:()=>v(void 0)}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"catalog-filters",children:[i.jsx("input",{className:"catalog-search",placeholder:"Search guides","aria-label":"Search guides",value:c,onChange:E=>d(E.target.value)}),i.jsx(K,{size:"sm",on:f,"aria-pressed":f,onClick:()=>g(E=>!E),children:"Verified only"})]}),o.error&&i.jsx("span",{className:"vf-err",children:o.error}),!o.index&&!o.error&&i.jsx(Ee,{children:"Reading the catalog…"}),o.index&&!y.length&&i.jsx(Ee,{children:"No guides match."}),i.jsx("ul",{className:"catalog-list",children:y.map(E=>i.jsx(FN,{entry:E,installed:j(E.id),onOpen:()=>v(E.id)},E.id))})]})]})}),document.body)}function KN(e){const t=e.r.guide;if(!t)return null;const r=Object.entries(t.proposedChecks);if(!t.requiresChecks.length&&!r.length)return null;const o=e.r.status==="active";return i.jsxs("div",{className:"guide-checks",children:[t.requiresChecks.length>0&&i.jsxs("span",{className:"t-meta",children:["Adds checks ",i.jsx("code",{className:"t-code",children:t.requiresChecks.join(", ")})," to its tickets"]}),r.map(([l,c])=>{const d=e.r.pendingChecks.includes(l);return i.jsxs("span",{className:"guide-check",children:[i.jsxs("code",{className:"t-code",children:[l,": ",Rc(c.run)]}),d&&o&&i.jsxs(K,{size:"sm",disabled:e.busy,onClick:()=>e.onApprove(l),children:["Approve check ",l]}),d&&!o&&i.jsx("span",{className:"t-meta",children:"approve the guide first"}),!d&&i.jsx("span",{className:"t-meta",children:"approved"})]},l)})]})}function mp(e){var d,f;const{r:t}=e,r=t.id,o=t.status!=="active"||t.pendingChecks.length>0,l=(t.status==="unapproved"||t.status==="tampered")&&!!t.guide,c=t.guide?`${t.guide.name} ${t.guide.version}`:r;return i.jsx("li",{className:"guide-row","data-guide-id":r,children:i.jsx(Ae,{edge:o?"attention":"neutral",title:c,context:i.jsx(q,{parts:[{text:r,code:!0},MN(t),LN(t),IN(t),t.guide&&VN(t.guide.checklist.length)]}),detail:t.status==="unapproved"?(d=t.guide)==null?void 0:d.summary:t.reason??((f=t.guide)==null?void 0:f.summary),actions:t.origin==="local"&&i.jsxs(K,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>e.onAct("/guides/remove",{id:r}),children:["Remove guide ",r]}),below:i.jsxs(i.Fragment,{children:[l&&i.jsx(K,{size:"sm","aria-label":`Approve guide ${r}`,disabled:e.busy,onClick:()=>e.onAct("/guides/approve",{id:r}),children:"Approve"}),i.jsx(KN,{r:t,busy:e.busy,onApprove:g=>e.onAct("/guides/checks/approve",{id:r,name:g})})]})})})}const VN=e=>e===1?"1 checklist item":`${e} checklist items`;function GN(e){return i.jsxs(He,{title:"Write your own",children:[i.jsxs("p",{className:"vf-intro",children:["Write a guide for your team in your repo with ",i.jsxs("code",{className:"t-code",children:[ve.slug," guides new <id>"]}),". It starts from a template in ",i.jsxs("code",{className:"t-code",children:[ve.dataDir,"/guides/"]})," that passes the safety lint. Fill in the instructions and checklist, then approve it here: agents can only use it once you have, and again after every edit."]}),e.guides.length>0?i.jsx("ul",{className:"guides-list own-guides",children:e.guides.map(t=>i.jsx(mp,{r:t,busy:e.busy,onAct:e.onAct},t.id))}):i.jsx(Ee,{children:"No guides of your own yet."}),e.error&&i.jsx("span",{className:"vf-err",children:e.error}),i.jsxs("p",{className:"t-meta guides-share",children:["Useful beyond your team? Check it with ",i.jsxs("code",{className:"t-code",children:[ve.slug," guides lint"]})," and"," ",i.jsx("a",{href:cx,target:"_blank",rel:"noreferrer",children:"share it in the public catalog"}),"."]})]})}function QN(e){const{view:t,act:r}=gn(),[o,l]=x.useState(),[c,d]=x.useState(!1),[f,g]=x.useState(!1),m=x.useRef(null);if(x.useEffect(()=>{var w;e.focus&&t&&((w=m.current)==null||w.scrollIntoView({block:"start"}))},[e.focus,!!t]),!t)return null;const v=w=>(j,$)=>{d(!0),r(j,$).then(N=>{l(N?{own:w,message:N}:void 0),d(!1)})},y=w=>o&&o.own===w?o.message:void 0;return i.jsxs("div",{className:"guides-section",ref:m,children:[i.jsxs(He,{title:"Guides",children:[i.jsx("p",{className:"vf-intro",children:"Guides give an agent instructions and a checklist for the tickets that ask for them. A guide can add checks, never remove them, and its commands only run once you approve them."}),i.jsx("ul",{className:"guides-list",children:t.guides.filter(w=>!oc(w)).map(w=>i.jsx(mp,{r:w,busy:c,onAct:v(!1)},w.id))}),i.jsxs("div",{className:"guides-foot",children:[i.jsx(K,{size:"sm",onClick:()=>g(!0),children:"Browse guides"}),i.jsx(q,{parts:[{text:`${ve.dataDir}/guides/`,code:!0},{text:"guides.lock.json",code:!0}]})]}),t.configErrors.length>0&&i.jsx("ul",{className:"vf-errors",children:t.configErrors.map(w=>i.jsx("li",{children:w},w))}),y(!1)&&i.jsx("span",{className:"vf-err",children:y(!1)})]}),i.jsx(GN,{guides:t.guides.filter(oc),busy:c,onAct:v(!0),error:y(!0)}),f&&i.jsx(WN,{registries:t.registries,onClose:()=>g(!1)})]})}function qN(e){const{view:t,act:r}=gn(),[o,l]=x.useState();if(!t)return null;const c=e.map.guides??[],d=t.guides.filter(g=>g.status==="active"&&g.guide),f=g=>{const m=c.includes(g)?c.filter(v=>v!==g):[...c,g];l(void 0),r("/guides/team",{mapId:e.map.id,guides:m}).then(l)};return i.jsxs(He,{title:`Team of ${e.map.key}`,children:[i.jsx("p",{className:"vf-intro",children:"The guides this trail works with. With Reviewer on the team, review tickets come with the reviewer's instructions and checklist."}),i.jsx("div",{className:"team-guides",children:d.map(g=>{const m=c.includes(g.id);return i.jsx(K,{size:"sm",on:m,"aria-pressed":m,title:g.guide.summary,onClick:()=>f(g.id),children:g.guide.name},g.id)})}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function YN(e,t){const[r,o]=x.useState();return x.useEffect(()=>{const l=`/guides/checklist?mapId=${encodeURIComponent(e)}&ticketId=${encodeURIComponent(t)}`,c=()=>No(l).then(d=>o(d.checklist),()=>o(null));return c(),pn(d=>{d.endsWith("checklist.json")&&c()})},[e,t]),r}function JN(e){const t=YN(e.mapId,e.ticketId);if(!t)return null;const r=t.answers.filter(o=>!o.done).length;return i.jsxs("div",{className:"checklist-panel",children:[i.jsx(q,{parts:[`${t.guide.id} ${t.guide.version} checklist`,t.by,Vi(t.at),r?`${r} not done`:"all done"]}),i.jsx(cp,{answers:t.answers})]})}const Eh="";function XN(e){const{view:t,act:r}=gn(),[o,l]=x.useState();if(!t)return null;const c=e.ticket,d=t.guides.filter(m=>{var v;return m.status==="active"&&((v=m.guide)==null?void 0:v.handles.types.includes(c.type))}),f=[{value:Eh,label:"No guide"},...d.map(m=>({value:m.id,label:m.guide.name,hint:m.guide.summary}))];c.guide&&!d.some(m=>m.id===c.guide)&&f.push({value:c.guide,label:c.guide});const g=m=>{l(void 0),r("/guides/ticket",{mapId:e.mapId,ticketId:c.id,guide:m||null}).then(l)};return i.jsxs("span",{className:"guide-picker",children:[i.jsx(ct,{compact:!0,"aria-label":"Ticket guide",value:c.guide??Eh,options:f,onChange:g}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function ZN(e){const{view:t,find:r}=gn();if(!t)return null;const o=r(e.id);if((o==null?void 0:o.status)==="active")return null;const l=o?o.reason??o.status:"it is not installed";return i.jsxs("p",{className:"guide-warning t-meta",children:["Guide ",e.id," can't be used: ",l,". Claims get no guide instructions until you approve it in Settings → Guides."]})}function eS(e){const{view:t}=gn(),r=e.ticket;return!t||r.state!=="open"&&!r.guide?null:i.jsxs("section",{className:"ticket-guide d-section",children:[i.jsxs("span",{className:"guide-head",children:[i.jsx("span",{className:"t-label",children:"Guide"}),r.state==="open"?i.jsx(XN,{mapId:e.mapId,ticket:r}):r.guide&&i.jsx($N,{id:r.guide})]}),r.guide&&i.jsx(ZN,{id:r.guide}),i.jsx(JN,{mapId:e.mapId,ticketId:r.id})]})}function tS(e){var g;const{view:t,find:r}=gn();if(!e)return;const o=r(e),l=t!=null&&(o==null?void 0:o.status)!=="active",c=((g=o==null?void 0:o.guide)==null?void 0:g.name)??e,d=o!=null&&o.guide?`${c} ${o.guide.version}`:c,f=l?`Guide ${d}: ${(o==null?void 0:o.reason)??"not installed"}`:`Guide: ${d}`;return{id:e,name:c,tip:f,off:l}}const Ih={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"},nS={low:"the agent decides",medium:"the agent decides and records it",high:"you decide"},sS=e=>e[0].toUpperCase()+e.slice(1),ac=gm.map(e=>({value:e,label:sS(e),hint:nS[e]}));function iS(e){const[t,r]=x.useState(""),[o,l]=x.useState("high"),{rules:c,onChange:d}=e,f=()=>{const g=t.trim();!g||c.some(m=>m.glob===g)||(d([...c,{glob:g,level:o}]),r(""))};return i.jsxs("div",{className:"risk-paths",children:[i.jsx("span",{className:"mono-label",children:"Files"}),c.map((g,m)=>i.jsxs("div",{className:"risk-row",children:[i.jsx("code",{children:g.glob}),i.jsx(ct,{compact:!0,"aria-label":`${g.glob} risk`,value:g.level,options:ac,onChange:v=>d(c.map((y,w)=>w===m?{...y,level:v}:y))}),i.jsx("button",{className:"icon-btn","aria-label":`Remove ${g.glob}`,onClick:()=>d(c.filter((v,y)=>y!==m)),children:"×"})]},g.glob)),i.jsxs("div",{className:"risk-row",children:[i.jsx("input",{value:t,placeholder:"src/payments/**","aria-label":"New file pattern",onChange:g=>r(g.target.value),onKeyDown:g=>g.key==="Enter"&&f()}),i.jsx(ct,{compact:!0,"aria-label":"New pattern risk",value:o,options:ac,onChange:l}),i.jsx(K,{onClick:f,disabled:!t.trim(),children:"Add"})]})]})}const pp=`${Se()}/policy`;async function rS(){const e=await fetch(pp);return e.ok?await e.json():null}function oS(){const[e,t]=x.useState(),r=x.useCallback(()=>{rS().then(t,()=>t(null))},[]);x.useEffect(()=>(r(),pn(l=>{l.endsWith("policy.json")&&r()})),[r]);const o=x.useCallback(async l=>{const c=await fetch(pp,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)}),d=await c.json();if(!c.ok)return d.error??`Saving failed (${c.status})`;t(d)},[]);return{view:e,save:o}}function aS(){const{view:e,save:t}=oS(),[r,o]=x.useState();if(!e)return null;const l=`${ve.dataDir}/policy.json`,c=d=>{o(void 0),t(d).then(o,f=>o(f.message))};return i.jsxs(He,{title:"Risk policy",children:[i.jsx("p",{className:"vf-intro",children:"What agents may decide on their own. High: they must ask you. Medium: they decide, follow your conventions and record it for you to review. Low: they just decide."}),i.jsx("div",{className:"risk-grid",children:pm.map(d=>i.jsxs("label",{className:"risk-row",children:[i.jsx("span",{children:Ih[d]}),i.jsx(ct,{compact:!0,"aria-label":`${Ih[d]} risk`,value:e.policy.categories[d],options:ac,onChange:f=>c({...e.policy,categories:{...e.policy.categories,[d]:f}})})]},d))}),i.jsx(iS,{rules:e.policy.paths,onChange:d=>c({...e.policy,paths:d})}),e.errors.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[l," has errors, so the defaults apply until it is fixed."]})]}),i.jsx("ul",{className:"vf-errors",children:e.errors.map(d=>i.jsx("li",{children:d},d))})]}),e.defaults&&e.errors.length===0&&i.jsxs("span",{className:"set-hint t-meta",children:["Defaults. Changing anything saves ",l,", so your team shares it."]}),r&&i.jsx("span",{className:"vf-err",children:r})]})}const lc=`${Se()}/workspaces`;async function lS(){const e=await fetch(lc);return e.ok?await e.json():null}function gp(){const[e,t]=x.useState(),r=x.useCallback(()=>{lS().then(t,()=>t(null))},[]);x.useEffect(()=>(r(),pn(c=>{(c.endsWith("workspaces.json")||c.includes("workspaces/")||c.includes("leases/"))&&r()})),[r]);const o=x.useCallback(async c=>{const d=await fetch(lc,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)}),f=await d.json();if(!d.ok)return f.error??`Saving failed (${d.status})`;t(f)},[]),l=x.useCallback(async(c,d,f=!1)=>{const g=await fetch(`${lc}/remove`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:c,ticketId:d,force:f})}),m=await g.json();return g.ok?(t(m),{}):{error:m.error??`Removing failed (${g.status})`,dirty:m.dirty??!1}},[]);return{view:e,save:o,remove:l}}function vp(e){const[t,r]=x.useState(!1),[o,l]=x.useState(),[c,d]=x.useState(!1),f=async g=>{d(!0),l(void 0);const m=await e.onRemove(g).catch(v=>({error:v.message,dirty:!1}));d(!1),r(!!m.dirty&&!g),m.dirty||l(m.error)};return t?i.jsxs("span",{className:"ws-remove ask",children:[i.jsx("span",{className:"vf-err",children:"Uncommitted changes in this workspace will be lost."}),i.jsx(K,{size:"sm",disabled:c,onClick:()=>f(!0),children:"Remove anyway"}),i.jsx(K,{size:"sm",variant:"ghost",onClick:()=>r(!1),children:"Keep"})]}):i.jsxs("span",{className:"ws-remove",children:[i.jsx(K,{size:"sm",disabled:c,onClick:()=>f(!1),children:e.label??"Remove"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function cS(e){return e.rows.length?i.jsx("ul",{className:"ws-list",children:e.rows.map(t=>i.jsx(Ae,{as:"li",className:`ws-row ${t.active?"active":"finished"}`,title:i.jsx("span",{className:"t-code",children:t.branch}),titleText:t.branch,context:i.jsx(q,{parts:[{text:t.ticketKey,code:!0},t.active?`Active · ${t.agent}`:"Finished"]}),detail:i.jsx("span",{className:"t-code",children:t.path}),detailText:t.path,below:t.active?void 0:i.jsx(vp,{onRemove:r=>e.onRemove(t.mapId,t.ticketId,r)})},`${t.mapId}/${t.ticketId}`))}):null}function uS(e){const{view:t,remove:r}=gp(),o=t==null?void 0:t.workspaces.find(l=>l.mapId===e.mapId&&l.ticketId===e.ticketId);return!o||o.active?null:i.jsxs("section",{className:"ticket-workspace d-section",children:[i.jsx("span",{className:"t-label",children:"Workspace"}),i.jsxs("p",{className:"t-meta",children:["Branch ",i.jsx("code",{className:"t-code",children:o.branch})," in"," ",i.jsx("code",{className:"t-code",title:o.path,children:o.path})]}),i.jsx(vp,{label:"Remove workspace",onRemove:l=>r(e.mapId,e.ticketId,l)})]})}function dS(){const{view:e,save:t,remove:r}=gp(),[o,l]=x.useState();if(!e)return null;const c=e.settings.worktrees,d=()=>{l(void 0),t({...e.settings,worktrees:!c}).then(l,f=>l(f.message))};return i.jsxs(He,{title:"Workspaces",children:[i.jsxs("p",{className:"vf-intro",children:["Give each agent its own copy of the repo for every ticket it claims, on its own branch, so agents working at the same time don't step on each other. You review and merge the branches; ",ve.name," never merges or pushes."]}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"A worktree per ticket"}),i.jsx(K,{size:"sm",on:c,"aria-pressed":c,className:"worktrees-toggle",onClick:d,children:c?"On":"Off"})]}),i.jsx(q,{className:"set-hint",parts:[{text:`${ve.dataDir}/workspaces.json`,code:!0},Mh(e.workspaces.filter(f=>f.active).length,"active"),Mh(e.workspaces.filter(f=>!f.active).length,"finished")]}),i.jsx(cS,{rows:e.workspaces,onRemove:r}),e.errors.length>0&&i.jsx("ul",{className:"vf-errors",children:e.errors.map(f=>i.jsx("li",{children:f},f))}),o&&i.jsx("span",{className:"vf-err",children:o})]})}const Mh=(e,t)=>`${e} ${t}`;function fS({data:e,route:t}){return i.jsxs(i.Fragment,{children:[i.jsx(it,{id:"tracker",children:i.jsx(He,{title:"Tracker",children:i.jsx(lN,{activeTracker:e.activeTracker,location:e.location,update:e.update})})}),i.jsx(it,{id:"workspaces",storage:"repo",children:i.jsx(dS,{})}),i.jsx(it,{id:"policy",storage:"repo",children:i.jsx(aS,{})}),i.jsx(it,{id:"guides",storage:"repo",children:i.jsx(QN,{focus:t.section==="guides"})}),i.jsx(it,{id:"labels",children:i.jsx(He,{title:"Labels",children:i.jsxs("div",{className:"label-codes",children:[i.jsx("code",{children:dc}),i.jsxs("code",{children:[ve.labelPrefix,":<type>"]}),i.jsx("code",{children:fc}),i.jsx("code",{children:hc})]})})})]})}const cc=`${ve.apiPrefix}/projects`;async function fo(e,t,r){const o=await fetch(`${cc}${e}`,{method:t,headers:{"Content-Type":"application/json"},body:r===void 0?void 0:JSON.stringify(r)}),l=await o.json().catch(()=>({}));if(!o.ok)throw new Error(l.error??`HTTP ${o.status}`);return l}const zs={url:cc,add:e=>fo("","POST",{path:e}),remove:e=>fo(`/${e}`,"DELETE"),setAutoRegister:e=>fo("/settings","PUT",{autoRegister:e}),answer:(e,t)=>fo(`/${e}/answer`,"POST",t),async briefing(e){const t=await fetch(`${cc}/briefing?since=${e}`);return t.ok?await t.json():void 0}};function kp(e){const[t,r]=x.useState(""),[o,l]=x.useState(),c=d=>{d.trim()&&(l(void 0),zs.add(d.trim()).then(()=>(r(""),e.onAdded()),f=>l(f.message)))};return i.jsxs("div",{className:"pj-add",children:[i.jsx(Nc,{value:t,onValueChange:r,onSubmit:c,action:"Add project",placeholder:`/path/to/repo (a ${ve.dataDir} folder is created if missing)`,"aria-label":"Repo path",className:"t-code"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}const Ms=(e,t)=>e>0&&`${e} ${t}`;function hS(e){var r;const t=((r=e.briefing)==null?void 0:r.projects)??[];return!e.briefing||!t.length?null:i.jsxs("section",{className:"pj-section pj-briefing",children:[i.jsx(Ct,{title:"While you were away",count:t.length,info:`What changed in each project since ${nn(e.now-e.briefing.since)} ago`}),i.jsx("ul",{className:"pj-list",children:t.map(({projectId:o,project:l,briefing:c})=>i.jsx(Ae,{as:"li",edge:c.totals.waiting>0?"attention":"neutral",title:l,context:i.jsx(q,{parts:[Ms(c.totals.done,"done"),Ms(c.trails.reduce((d,f)=>d+f.opened.length,0),"new tickets"),Ms(c.totals.agentDecisions,"agent decisions"),Ms(c.totals.waiting,"waiting on you"),Ms(c.totals.ruledOut,"ruled out"),Ms(c.totals.active,"agents active")]}),onOpen:()=>e.onOpen(o)},o))})]})}function mS(e){const[t,r]=x.useState(""),[o,l]=x.useState(!1),[c,d]=x.useState(),f=g=>{!g.trim()||o||(l(!0),d(void 0),e.onAnswer(g.trim()).then(()=>r(""),m=>d(m.message)).finally(()=>l(!1)))};return i.jsxs("div",{className:"pj-answer",children:[i.jsx(Nc,{value:t,onValueChange:r,onSubmit:f,action:"Answer",disabled:o,placeholder:"Your answer","aria-label":"Your answer"}),c&&i.jsx("span",{className:"vf-err",children:c})]})}function pS(e){const{item:t}=e,r=Qm(t),o=t.kind==="question"&&t.agent?`${t.agent} asks`:Vm[t.kind],l=t.urgency==="blocking"&&{text:"Blocking",urgent:!0,className:"urgency-tag"};return i.jsx(Ae,{as:"li",className:`att-item pj-item k-${t.kind}`,edge:Gm(t,t.interrupting),title:t.title.split(`
|
|
129
|
+
`)[0],titleText:t.title,context:i.jsx(q,{parts:[l,{text:t.project,strong:!0},o]}),detail:r.length>0&&r.join(" · "),detailText:r.join(`
|
|
130
|
+
`),trailing:nn(e.now-t.since),onOpen:e.onOpen,below:e.onAnswer&&i.jsx(mS,{onAnswer:e.onAnswer})})}function gS(e){const t=e.view.attention,r=o=>{var l;return((l=e.view.projects.find(c=>c.id===o))==null?void 0:l.state.kind)!=="missing"};return i.jsxs("section",{className:"pj-section pj-attention",children:[i.jsx(Ct,{title:"Needs you",count:t.length,hot:t.some(o=>o.interrupting),info:"One queue across projects, ranked the way each project ranks its own. Answer questions here; the agent in that repo gets the answer."}),t.length===0&&i.jsx(Dn,{title:"Nothing needs you",hint:"Agents in every project can keep going."}),i.jsx("ul",{className:"pj-list",children:t.map(o=>i.jsx(pS,{item:o,now:e.now,onOpen:()=>e.onOpen(o.projectId,o.id),onAnswer:o.kind==="question"&&r(o.projectId)?l=>zs.answer(o.projectId,{questionId:o.ref,text:l}).then(e.onAnswered):void 0},`${o.projectId}/${o.id}`))})]})}const Vl=(e,t,r=`${t}s`)=>`${e} ${e===1?t:r}`;function vS(e){return e.interrupting>0?"urgent":e.phases.blocked+e.phases.rework+e.flags+e.stalled>0||e.state.kind==="missing"?"attention":"neutral"}function kS(e){if(e.state.kind==="missing")return[{text:"Missing",strong:!0},{text:e.path,code:!0}];const t=[];e.needsYou&&t.push({text:`${e.needsYou} ${e.needsYou===1?"needs":"need"} you`,strong:!0,urgent:e.interrupting>0}),e.agents&&t.push(Vl(e.agents,"agent"));const{working:r,verifying:o,rework:l,blocked:c}=e.phases;r&&t.push(`${r} working`),o&&t.push(`${o} verifying`),l&&t.push(`${l} rework`),c&&t.push(`${c} blocked`),e.flags&&t.push(Vl(e.flags,"PR flag")),e.stalled&&t.push(Vl(e.stalled,"stalled claim")),t.length||t.push(e.trails?"Nothing waiting":"No trails yet");const d=yS(e.tracker);return d&&t.push(d),t}function yS(e){if(e.kind==="github"&&e.repo)return`Issues in ${e.repo}`;if(!(e.kind!=="linear"||!e.team))return e.org?`Linear: ${e.team} in ${e.org}`:`Linear: ${e.team}`}function xS(e){var t;return e.state.kind==="elsewhere"?`Served by another Lookout · ${e.state.url}`:((t=e.top)==null?void 0:t.title)??e.note??e.path}function bo(e,t,r){if(e.state.kind!=="missing"){if(e.state.kind==="elsewhere"){const o=new URL(e.state.url);r&&o.searchParams.set(Ps,r),window.open(o.toString(),"_blank","noopener");return}location.href=Vx({id:e.id,home:t,tracker:e.tracker.kind,item:r})}}function yp(e){const{p:t}=e,r=xS(t);return i.jsx(Ae,{as:"li",className:`project-card st-${t.state.kind}`,edge:vS(t),selected:e.current,title:t.name,titleText:t.path,context:i.jsx(q,{parts:kS(t)}),detail:r,detailText:r,trailing:t.lastActivity?nn(e.now-t.lastActivity):void 0,onOpen:e.onOpen})}const xp=`${Eo}:projects:seen`,Ah=24*36e5;function wS(e){try{const t=Number(localStorage.getItem(xp));return t>0?t:e-Ah}catch{return e-Ah}}function jS(e){try{localStorage.setItem(xp,String(e))}catch{}}function NS(){const[e,t]=x.useState();return x.useEffect(()=>{const r=Date.now();return zs.briefing(wS(r)).then(t).catch(()=>{}),()=>jS(r)},[]),e}function SS(e){const{view:t,reload:r}=e.projects,o=sn(15e3),l=NS();if(x.useEffect(()=>{const g=m=>m.key==="Escape"&&e.onClose();return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[e]),!t)return null;const c=Do()??t.home,d=g=>{const m=t.projects.find(v=>v.id===g);(m==null?void 0:m.id)===c?e.onClose():m&&bo(m,t.home)},f=(g,m)=>{const v=t.projects.find(y=>y.id===g);if(v){if(v.id!==c)return bo(v,t.home,m);e.onClose(),e.onItemHere(m)}};return i.jsxs(Ke,{className:`zone decisions-view projects-view dv-${e.bp}`,children:[i.jsxs("header",{className:"dv-head",children:[i.jsx(Je,{as:"h2",children:"All projects"}),i.jsx("span",{className:"dv-head-right",children:i.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})})]}),i.jsxs("div",{className:"pj-body",children:[i.jsx(gS,{view:t,now:o,onOpen:f,onAnswered:r}),i.jsxs("section",{className:"pj-section pj-projects",children:[i.jsx(Ct,{title:"Projects",count:t.projects.length,info:"Each repo registered on this machine, read from its own files. Nothing leaves your machine."}),i.jsx("ul",{className:"pj-list",children:t.projects.map(g=>i.jsx(yp,{p:g,current:g.id===c,now:o,onOpen:g.state.kind==="missing"?void 0:()=>d(g.id)},g.id))}),i.jsx(kp,{onAdded:r})]}),i.jsx(hS,{briefing:l,now:o,onOpen:d})]})]})}function bS(e){const[t,r]=x.useState(!1),o=x.useRef(null);x.useEffect(()=>{if(!t)return;const f=g=>{var m;(g instanceof KeyboardEvent?g.key==="Escape":!((m=o.current)!=null&&m.contains(g.target)))&&r(!1)};return window.addEventListener("mousedown",f),window.addEventListener("keydown",f),()=>{window.removeEventListener("mousedown",f),window.removeEventListener("keydown",f)}},[t]);const{view:l}=e.projects;if(!l||!e.projects.many)return i.jsx("span",{className:"repo",children:e.repo});const c=Do()??l.home,d=l.projects.filter(f=>f.id!==c).reduce((f,g)=>f+g.interrupting,0);return i.jsxs("div",{className:"project-switcher",ref:o,children:[i.jsxs("button",{className:"project-btn repo",onClick:()=>r(f=>!f),"aria-haspopup":"menu","aria-expanded":t,"data-tip":"Switch project, or see all of them",children:[i.jsx("span",{className:"project-name",children:e.repo}),d>0&&i.jsx(ts,{n:d,urgent:!0}),i.jsx("span",{className:"caret",children:"▾"})]}),t&&i.jsxs("div",{className:"trail-menu",role:"menu",children:[i.jsxs("button",{role:"menuitem",className:"trail-item all-projects",onClick:()=>{r(!1),e.onOverview()},children:[i.jsx("span",{className:"mi-title",children:"All projects"}),i.jsx(ts,{n:l.attention.length,urgent:l.attention.some(f=>f.interrupting),hideZero:!0})]}),i.jsx(Je,{variant:"plain",className:"menu-h",children:"Projects"}),l.projects.map(f=>i.jsxs("button",{role:"menuitem",className:`trail-item ${f.id===c?"on":""} st-${f.state.kind}`,disabled:f.state.kind==="missing",onClick:()=>{r(!1),f.id!==c&&bo(f,l.home)},children:[i.jsx("span",{className:"mi-title",children:f.name}),i.jsx("span",{className:"mi-progress",children:CS(f.state.kind)}),i.jsx(ts,{n:f.needsYou,urgent:f.interrupting>0,hideZero:!0})]},f.id))]})]})}function CS(e){return e==="missing"?"missing":e==="elsewhere"?"other Lookout":""}function $S(e){const t=sn(15e3),{view:r}=e.projects;if(!r||!e.projects.many)return null;const o=Do()??r.home;return i.jsxs("section",{className:"phone-projects",children:[i.jsx(Ct,{title:"Projects",count:r.projects.length,right:i.jsx(K,{size:"sm",variant:"ghost",onClick:e.onOverview,children:"All projects"})}),i.jsx("ul",{className:"pj-list",children:r.projects.filter(l=>l.id!==o).map(l=>i.jsx(yp,{p:l,current:!1,now:t,onOpen:l.state.kind==="missing"?void 0:()=>bo(l,r.home)},l.id))})]})}function wp(){const[e,t]=x.useState(),r=x.useCallback(()=>{fetch(zs.url).then(o=>o.ok?o.json():void 0).then(o=>o&&t(o)).catch(()=>{})},[]);return x.useEffect(()=>Fo("projects",o=>t(JSON.parse(o))),[]),x.useEffect(r,[r]),{view:e,many:((e==null?void 0:e.projects.length)??0)>1,reload:r}}const TS=e=>[e.home&&{text:"This Lookout",strong:!0},e.state.kind==="missing"&&"Missing",{text:e.path,code:!0}];function ES(){const{view:e,reload:t}=wp(),[r,o]=x.useState();if(!e)return null;const l=c=>{o(void 0),c.then(t,d=>o(d.message))};return i.jsxs(He,{title:"Projects",children:[i.jsx("p",{className:"vf-intro",children:"Supervise several repos from this Lookout: All projects shows what needs you in each of them. The list lives in your config folder on this machine, never in a repo, and agents only ever work in their own repo."}),i.jsx("ul",{className:"pj-list set-projects",children:e.projects.map(c=>i.jsx(Ae,{as:"li",edge:c.state.kind==="missing"?"attention":"neutral",title:c.name,context:i.jsx(q,{parts:TS(c)}),actions:!c.home&&i.jsx(K,{size:"sm",variant:"ghost",onClick:()=>l(zs.remove(c.id)),children:"Remove"})},c.id))}),i.jsx(kp,{onAdded:t}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Agents add their repo when they connect"}),i.jsx(K,{size:"sm",on:e.autoRegister,"aria-pressed":e.autoRegister,className:"auto-register-toggle",onClick:()=>l(zs.setAutoRegister(!e.autoRegister)),children:e.autoRegister?"On":"Off"})]}),i.jsx(q,{className:"set-hint",parts:[{text:`${ve.slug} projects add <path>`,code:!0},`--no-register or ${ve.noRegisterEnv} opts one agent out`]}),r&&i.jsx("span",{className:"vf-err",children:r})]})}const IS=`${ve.apiPrefix}/models`;function Oc(){const[e,t]=x.useState(),r=x.useCallback(()=>{fetch(IS).then(o=>o.ok?o.json():null).then(t,()=>t(null))},[]);return x.useEffect(()=>{r();const o=pn(c=>{(c.endsWith("models.json")||c.endsWith("map.md")||c.includes("/tickets/"))&&r()}),l=Fo("attention",r);return()=>{o(),l()}},[r]),e}function MS({mapId:e,ticketId:t}){const r=Oc(),o=r==null?void 0:r.waiting.find(l=>l.mapId===e&&l.ticketId===t);return o?i.jsx(Ae,{className:"model-wait d-section",edge:"attention",title:`Needs a ${o.tier} model`,context:i.jsx(q,{parts:[`Connected agents run ${o.best} at most`]}),detail:`Connect an agent on a ${o.tier} model, or have one claim ${o.ticketKey} by key.`}):null}function AS({view:e}){if(!e)return null;const t=`${ve.dataDir}/${e.file}`,r=Object.keys(e.models).length,o=e.agents.map(l=>`${l.agent} ${l.tier}`).join(", ");return i.jsxs(i.Fragment,{children:[i.jsx(q,{className:"set-hint",parts:[{text:t,code:!0},e.exists?`${r} of your own models`:"add new or custom models here","unknown models count as balanced"]}),o&&i.jsx(q,{className:"set-hint models-connected",parts:[`Connected now: ${o}`]}),e.errors.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[t," has errors, so only the built-in models count until it is fixed."]})]}),i.jsx("ul",{className:"vf-errors",children:e.errors.map(l=>i.jsx("li",{children:l},l))})]})]})}const jp={fast:"Fast",balanced:"Balanced",strongest:"Strongest"},LS={fast:"Haiku, mini and nano models",balanced:"Sonnet, GPT-4 models",strongest:"Opus, GPT-5 and o-series models"},RS=sm.map(e=>({value:e,label:jp[e],hint:LS[e]}));function OS(e){return i.jsx("div",{className:"tier-grid",children:Mo.map(t=>{const r=e.tiers[t],o=pc[t];return i.jsxs("div",{className:"tier-row",children:[i.jsx("span",{children:zi[t]}),i.jsx(ct,{compact:!0,"aria-label":`${zi[t]} tickets' model`,className:`tier-select tier-${t}`,value:r,options:RS,onChange:l=>e.onChange(t,l)}),i.jsx(q,{className:"tier-hint",parts:[r!==o&&`default ${jp[o].toLowerCase()}`,e.hints[t]]})]},t)})})}const ho=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function PS({rows:e}){return e.length?i.jsx("ul",{className:"perf-rows",children:e.map(t=>i.jsx(Ae,{as:"li",className:"perf-row",title:t.key,trailing:i.jsx("span",{title:"Median time from first claim to done",children:en(t.medianLeadMs)}),context:i.jsx(q,{parts:[`${t.done} of ${ho(t.tickets,"ticket")} done`,t.cancelled>0&&`${t.cancelled} cancelled`,ho(t.reworkCycles,"rework"),`reviews ${t.reviews.passed} passed, ${t.reviews.failed} failed`,t.answers>0&&ho(t.answers,"question")]}),detail:t.findings.raised>0?`As reviewer: ${t.findings.upheld} of ${ho(t.findings.raised,"finding")} upheld`:void 0},t.key))}):i.jsx(Ee,{children:"No claimed tickets yet"})}function Np(e){const[t,r]=x.useState({}),o=e.map(l=>`${l.map.id}:${l.tickets.reduce((c,d)=>Math.max(c,d.updatedAt),0)}`).join();return x.useEffect(()=>{let l=!0;return Promise.all(e.map(async c=>{const d=await fetch(`${Se()}/journal?mapId=${encodeURIComponent(c.map.id)}`).catch(()=>{}),f=d!=null&&d.ok?await d.json():{entries:[]};return[c.map.id,f.entries]})).then(c=>{l&&r(Object.fromEntries(c))}),()=>{l=!1}},[o]),t}const _S=[{id:"byVendor",title:"By vendor"},{id:"byAgent",title:"By agent"},{id:"byType",title:"By ticket type"}];function DS({api:e,bp:t,onClose:r}){const[o,l]=x.useState("byVendor"),c=x.useMemo(()=>Object.values(e.allSnaps),[e.allSnaps]),d=Np(c),f=e.activity.answered,g=x.useMemo(()=>wm(c.map(m=>({snap:m,journal:d[m.map.id]??[],answered:f}))),[c,d,f]);return x.useEffect(()=>{const m=v=>v.key==="Escape"&&r();return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[r]),i.jsxs(Ke,{className:`zone decisions-view perf-view dv-${t}`,children:[i.jsxs("header",{className:"dv-head",children:[i.jsx(Je,{as:"h2",children:"Trail stats"}),i.jsx(q,{parts:[`${g.trails} trails`,`${g.tickets} tickets`]}),i.jsx("span",{className:"dv-head-right",children:i.jsx("button",{className:"icon-btn",onClick:r,"aria-label":"Close",children:"×"})})]}),i.jsxs("div",{className:"perf-body",children:[i.jsxs("section",{className:"perf-section",children:[i.jsx(Je,{as:"h3",children:"What stands out"}),i.jsx("p",{className:"perf-note t-meta",children:"From your own numbers, for you to act on or ignore. Teamtrail doesn't route work from these."}),g.recommendations.length?i.jsx("ul",{className:"perf-recs",children:g.recommendations.map(m=>i.jsxs("li",{title:m.because,children:[i.jsx("span",{children:m.text}),i.jsx("span",{className:"t-meta",children:m.because})]},m.id))}):i.jsx(Ee,{children:"Nothing yet. This needs at least 5 results from two vendors to compare."})]}),i.jsxs("section",{className:"perf-section",children:[i.jsx("div",{className:"choice-row compact",children:_S.map(m=>i.jsx(ht,{on:o===m.id,title:m.title,onClick:()=>l(m.id)},m.id))}),i.jsx(PS,{rows:g[o]}),i.jsx("p",{className:"perf-note t-meta",children:"Spend is tracked per trail, so it isn't split by agent here."})]})]})]})}function BS(e,t){const r=Np(e);return x.useMemo(()=>{var c;const o=wm(e.map(d=>({snap:d,journal:r[d.map.id]??[],answered:t}))),l={};for(const d of o.byType){if(!d.done)continue;const f=(c=o.recommendations.find(m=>m.id===`speed-${d.key}`))==null?void 0:c.text,g=[`Trail stats: ${d.done} done`,d.medianLeadMs!==void 0&&`median ${en(d.medianLeadMs)}`,d.reworkCycles>0&&`${d.reworkCycles} back to rework`,f];l[d.key]=g.filter(Boolean).join(" · ")}return l},[e,r,t])}function zS(e){var d,f;const t=Oc(),r=BS(e.snaps,e.answered),o=e.map;if(!o)return null;const l=!!((d=o.modelMatching)!=null&&d.enabled),c=((f=o.modelMatching)==null?void 0:f.tiers)??{};return i.jsxs(He,{title:"Model matching",children:[i.jsx("p",{className:"vf-intro",children:"Give each agent the tickets that fit the model it runs on: research to fast models, junctions, prototypes and reviews to the strongest. Teamtrail reads the model from the agent's log and never switches it. An agent can still claim any ticket by name, and tells you when it does."}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsxs("span",{className:"set-field-label",children:["Match work to models on trail ",o.key]}),i.jsx(K,{size:"sm",on:l,"aria-pressed":l,className:"model-matching-toggle",onClick:()=>e.onChange({...o.modelMatching,enabled:!l}),children:l?"On":"Off"})]}),l&&i.jsx(OS,{tiers:Fv(o),hints:r,onChange:(g,m)=>{const v={...c,[g]:m};m===pc[g]&&delete v[g],e.onChange({enabled:!0,tiers:v})}}),l&&i.jsx("span",{className:"set-hint t-meta",children:"Changes apply to the next claim; nothing running is interrupted."}),i.jsx(AS,{view:t})]})}function FS(){const[e,t]=x.useState();return x.useEffect(()=>{let r=!0;return fetch(`${Se()}/verification/config`).then(o=>o.ok?o.json():null).then(o=>r&&t(o),()=>r&&t(null)),()=>{r=!1}},[]),e}const Lh=`{
|
|
131
131
|
"v": 1,
|
|
132
132
|
"checks": {
|
|
133
133
|
"test": { "run": ["npm", "test"] },
|
|
@@ -135,17 +135,17 @@ ${e.apiKey??""}`,load:()=>Rt.linearProjects(e.teamId,e.apiKey),failed:o=>({kind:
|
|
|
135
135
|
},
|
|
136
136
|
"run": ["test", "lint"]
|
|
137
137
|
}
|
|
138
|
-
`;function US({file:e}){const[t,r]=x.useState(!1),o=()=>void navigator.clipboard.writeText(Lh).then(()=>{r(!0),setTimeout(()=>r(!1),1500)});return i.jsxs("div",{className:"vf-setup",children:[i.jsx("b",{className:"vf-setup-h",children:"Set up checks"}),i.jsxs("p",{children:["Checks are the commands that prove a ticket is really done, such as your tests and linter. They live in"," ",i.jsx("code",{children:e})," in your repo. Create it with the commands you trust, then commit it:"]}),i.jsxs("div",{className:"vf-snippet",children:[i.jsx("pre",{children:Lh}),i.jsx(K,{size:"sm",variant:"ghost",onClick:o,children:t?"Copied":"Copy"})]}),i.jsxs("p",{className:"dim",children:[i.jsx("code",{children:"run"})," lists the checks that run on every completion. Each ",i.jsx("code",{children:"run"})," command is a list of words, not a shell line. Until the file exists, levels above Off can’t run their checks, so those completions stop and wait for you."]})]})}function HS(e){const t=FS(),[r,o]=x.useState();if(!t)return null;const l=e.map,c=t.config,d=`${ve.dataDir}/${t.file}`,f=(l==null?void 0:l.verification)??"off",g=(c??lm).appliesTo.join(" and ");return i.jsxs(He,{title:"Verification",children:[i.jsxs("p",{className:"vf-intro",children:["When an agent says a ticket is done, Teamtrail can check the work before the ticket closes. This applies to"," ",g," tickets. Research, junction and prototype tickets close as soon as they are answered."]}),l&&i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"set-field-label",children:["How much checking for trail ",l.key]}),i.jsx("div",{className:"choice-row vf-levels",children:mc.map(m=>i.jsx(ht,{on:f===m,title:Ui[m],sub:Xm[m],onClick:()=>{o(void 0),Gi.act({action:"level",mapId:l.id,level:m,by:wt}).catch(v=>o(v.message))}},m))}),f!=="off"&&!c&&i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:"No working checks yet, so completions at this level stop and wait for you."})]}),r&&i.jsx("span",{className:"vf-err",children:r})]}),t.errors.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line alert",title:t.hash,children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[d," has errors. Completions that need checks wait for you until it is fixed."]})]}),i.jsx("ul",{className:"vf-errors",children:t.errors.map(m=>i.jsx("li",{children:m},m))})]}),!t.exists&&i.jsx(US,{file:d}),c&&t.exists&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line ok",title:t.hash,children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[i.jsx("span",{className:"t-code",children:d})," · ",c.run.length," checks run on every completion"]})]}),i.jsx(Q,{className:"set-hint",parts:[`New trails start at ${Ui[c.default]}`,`${c.maxAttempts} attempts before it waits for you`,c.failFast&&"Stops at the first failure"]}),i.jsx("div",{className:"vf-checks",children:Object.entries(c.checks).map(([m,v])=>i.jsxs("div",{className:"vf-check",children:[i.jsx("span",{className:"t-code",children:c.run.includes(m)?m:`${m} (on request)`}),i.jsx("code",{children:v.run.join(" ")}),i.jsxs("span",{className:"dim",children:[v.timeoutSec," s",v.cwd&&v.cwd!=="."?` · in ${v.cwd}`:""]})]},m))})]}),i.jsxs("span",{className:"set-hint t-meta",children:["Teamtrail never edits ",d,". Change checks in the repo, so no agent can change what verifies its own work."]})]})}function WS({data:e}){const{map:t}=e;return i.jsxs(i.Fragment,{children:[t?i.jsx(it,{id:"mode",children:i.jsx(He,{title:`Trail ${t.key}`,children:i.jsx(v0,{value:t.mode,onChange:e.onMapMode})})}):i.jsx(Ee,{children:"Chart or pick a trail to set its mode, model matching and team."}),i.jsx(it,{id:"verification",storage:"repo",children:i.jsx(HS,{map:t})}),i.jsx(it,{id:"models",children:i.jsx(zS,{map:t,snaps:e.snaps,answered:e.answered,onChange:e.onModelMatching})}),t&&i.jsx(it,{id:"team",children:i.jsx(qN,{map:t})})]})}const KS=[{value:"auto",title:"Match my system"},{value:"day",title:"Day"},{value:"night",title:"Night"}];function VS(e){return i.jsx("div",{className:"choice-row compact",children:KS.map(t=>i.jsx(ht,{on:e.value===t.value,title:t.title,onClick:()=>e.onChange(t.value)},t.value))})}function GS({data:e}){const{prefs:t,update:r}=e;return i.jsxs(i.Fragment,{children:[i.jsx(it,{id:"appearance",storage:"browser",children:i.jsx(He,{title:"Appearance",children:i.jsx(VS,{value:t.theme,onChange:o=>r({theme:o})})})}),i.jsx(it,{id:"transcript",storage:"browser",children:i.jsx(He,{title:"HITL transcript",children:i.jsx(ap,{value:t.hitlTranscript,onChange:o=>r({hitlTranscript:o})})})}),i.jsx(it,{id:"agent",children:i.jsx(He,{title:"Agent",children:i.jsx("div",{className:"choice-row",children:bm.map(o=>i.jsx(ht,{on:o.status==="primary",disabled:o.status!=="primary",title:o.name},o.id))})})})]})}function QS(e){const{data:t,route:r}=e;switch(e.group){case"trail":return i.jsx(WS,{data:t});case"project":return i.jsx(fS,{data:t,route:r});case"alerts":return i.jsx(xN,{data:t,route:r});case"you":return i.jsx(GS,{data:t});case"projects":return i.jsx(it,{id:"projects",storage:"machine",children:i.jsx(ES,{})});case"about":return i.jsx(it,{id:"changelog",children:i.jsx(SN,{})});default:return e.group}}function qS(e){const{group:t,route:r}=e,o=x.useRef(null),l=x.useRef(null);return x.useEffect(()=>{var d,f;(d=o.current)==null||d.focus({preventScroll:!0});const c=r.section&&document.getElementById(`settings-${r.section}`);c?c.scrollIntoView({block:"start"}):(f=l.current)==null||f.scrollTo({top:0})},[t.id,r.section]),i.jsx("div",{className:"sp-pane",ref:l,children:i.jsxs("div",{className:"sp-pane-in",children:[i.jsxs("header",{className:"sp-pane-head",children:[i.jsx("h2",{className:"sp-title t-title",ref:o,tabIndex:-1,children:t.label}),i.jsx("p",{className:"sp-intro t-meta",children:t.intro})]}),i.jsx(QS,{group:t.id,data:e.data,route:r})]})})}function YS(e){return i.jsx("nav",{className:"sp-nav","aria-label":"Settings groups",children:i.jsx("ul",{children:Hi.map(t=>{const r=t.id===e.current;return i.jsx(Ae,{as:"li",className:"sp-nav-row",selected:r,current:r?"page":void 0,title:t.label,context:i.jsx(Q,{parts:t.sections.map(o=>o.title)}),trailing:e.drill&&"›",onOpen:()=>e.onPick(t.id)},t.id)})})})}function JS(e,t){return e.group?Hi.find(r=>r.id===e.group):t==="mobile"?void 0:Hi[0]}const XS={page:"Back to the Lookout",list:"Lookout",group:"Settings"},ZS=(e,t)=>e?t?"group":"list":"page";function e1(e){const{bp:t,route:r}=e,o=t==="mobile",l=JS(r,t),c=ZS(o,!!l),d=()=>c==="group"?e.onShow({}):e.onClose();x.useEffect(()=>{const m=v=>{v.key!=="Escape"||v.defaultPrevented||document.querySelector(".scrim")||(c==="group"?e.onShow({}):e.onClose())};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[c,e]);const f=m=>e.onShow({group:m}),g=c!=="group"&&i.jsx(YS,{current:l==null?void 0:l.id,onPick:f,drill:o});return i.jsxs(Ke,{className:`zone decisions-view settings-page sp-${t}`,"aria-label":"Settings",children:[i.jsxs("header",{className:"dv-head",children:[i.jsxs("button",{className:"back",onClick:d,children:["‹ ",XS[c]]}),c!=="group"&&i.jsx(Je,{as:"h2",children:"Settings"}),!o&&i.jsx("span",{className:"dv-head-right t-meta",children:"Esc"})]}),i.jsxs("div",{className:"sp-body",children:[g,l&&i.jsx(qS,{group:l,data:e.data,route:r})]})]})}function mo(e,t){const r=new URL(e);return r.searchParams.delete("settings"),t&&r.searchParams.set("settings",t.section??t.group??""),r.toString()}function t1(e){var l;const{rt:t,api:r,settings:o}=e;return o.route?i.jsx(e1,{bp:e.bp,route:o.route,onShow:o.show,onClose:o.close,data:{prefs:e.prefs,update:e.update,activeTracker:t.kind,location:t.adapter.location,map:(l=r.snap)==null?void 0:l.map,onMapMode:r.actions.setMode,snaps:Object.values(r.allSnaps),answered:r.activity.answered,onModelMatching:r.actions.setModelMatching}}):null}function n1(e){return i.jsxs(Ke,{className:"zone side",style:{gridArea:"inspector"},children:[i.jsx(yw,{className:"zone-tabs",value:e.tab,onChange:e.onTab,items:[{id:"ticket",label:"Ticket"},{id:"activity",label:"Activity"},{id:"plan",label:"Plan",n:e.unspecified}]}),{ticket:e.ticket,activity:e.activity,plan:e.plan}[e.tab]]})}function Sp(e){return e.filter(t=>t.state!=="out-of-scope").map(t=>({x:t.x,y:t.y,w:Ue,h:Ge}))}function s1(e){const{obstacles:t,from:r,to:o,clear:l}=e,c=t.flatMap(f=>[f.y-28,f.y+f.h+28]).filter(l),d=f=>Math.abs(f-r)+Math.abs(f-o);return c.reduce((f,g)=>d(g)<d(f)?g:f,c[0]??r)}const i1=6;function r1(e){const t=e.filter((l,c)=>c===0||l.x!==e[c-1].x||l.y!==e[c-1].y);let r=`M${t[0].x} ${t[0].y}`;for(let l=1;l<t.length-1;l++){const[c,d,f]=[t[l-1],t[l],t[l+1]],g=Math.min(i1,Rh(c,d)/2,Rh(d,f)/2),m=Oh(d,c,g),v=Oh(d,f,g);r+=`L${m.x} ${m.y}Q${d.x} ${d.y} ${v.x} ${v.y}`}const o=t[t.length-1];return`${r}L${o.x} ${o.y}`}function Rh(e,t){return Math.abs(e.x-t.x)+Math.abs(e.y-t.y)}function Oh(e,t,r){return{x:e.x+Math.sign(t.x-e.x)*r,y:e.y+Math.sign(t.y-e.y)*r}}function Co(e){const t=e.direction==="TB",r=d=>t?{x:d.y,y:d.x}:d,o=r(e.a),l=r(e.b),c=e.obstacles.map(d=>t?{x:d.y,y:d.x,w:d.h,h:d.w}:d);return r1(o1({a:o,b:l,obstacles:c,gap:e.gap}).map(r))}function o1({a:e,b:t,obstacles:r,gap:o}){const l=r.filter(m=>m.x+m.w>e.x+1&&m.x<t.x-1),c=m=>!l.some(v=>m>v.y-8&&m<v.y+v.h+8),d=Math.min(e.x+o/2,(e.x+t.x)/2),f=Math.max(t.x-o/2,(e.x+t.x)/2);if(c(e.y))return[e,{x:f,y:e.y},{x:f,y:t.y},t];if(c(t.y))return[e,{x:d,y:e.y},{x:d,y:t.y},t];const g=s1({obstacles:l,from:e.y,to:t.y,clear:c});return[e,{x:d,y:e.y},{x:d,y:g},{x:f,y:g},{x:f,y:t.y},t]}function a1(e){if(e.direction==="LR"){const r=e.width+96;return{x:r,y:e.graphH/2,right:r+34,bottom:e.height}}const t=e.graphH+76;return{x:e.width/2,y:t,right:e.width,bottom:Math.max(e.height,t+40)}}function l1(e,t){const r=new Set(e.edges.map(c=>c.from)),o=e.nodes.filter(c=>c.state!=="out-of-scope"&&!r.has(c)),l=Sp(e.nodes);return o.map(c=>{if(e.direction==="LR"){const g={x:c.x+Ue,y:c.y+Ge/2},m={x:t.x-30,y:t.y};return Co({direction:"LR",a:g,b:m,obstacles:l,gap:96})}const d={x:c.x+Ue/2,y:c.y+Ge},f={x:t.x,y:t.y-30};return Co({direction:"TB",a:d,b:f,obstacles:l,gap:48})})}function c1({x:e,y:t,text:r}){const o=r!=null&&r.trim()?`Destination
|
|
138
|
+
`;function US({file:e}){const[t,r]=x.useState(!1),o=()=>void navigator.clipboard.writeText(Lh).then(()=>{r(!0),setTimeout(()=>r(!1),1500)});return i.jsxs("div",{className:"vf-setup",children:[i.jsx("b",{className:"vf-setup-h",children:"Set up checks"}),i.jsxs("p",{children:["Checks are the commands that prove a ticket is really done, such as your tests and linter. They live in"," ",i.jsx("code",{children:e})," in your repo. Create it with the commands you trust, then commit it:"]}),i.jsxs("div",{className:"vf-snippet",children:[i.jsx("pre",{children:Lh}),i.jsx(K,{size:"sm",variant:"ghost",onClick:o,children:t?"Copied":"Copy"})]}),i.jsxs("p",{className:"dim",children:[i.jsx("code",{children:"run"})," lists the checks that run on every completion. Each ",i.jsx("code",{children:"run"})," command is a list of words, not a shell line. Until the file exists, levels above Off can’t run their checks, so those completions stop and wait for you."]})]})}function HS(e){const t=FS(),[r,o]=x.useState();if(!t)return null;const l=e.map,c=t.config,d=`${ve.dataDir}/${t.file}`,f=(l==null?void 0:l.verification)??"off",g=(c??lm).appliesTo.join(" and ");return i.jsxs(He,{title:"Verification",children:[i.jsxs("p",{className:"vf-intro",children:["When an agent says a ticket is done, Teamtrail can check the work before the ticket closes. This applies to"," ",g," tickets. Research, junction and prototype tickets close as soon as they are answered."]}),l&&i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"set-field-label",children:["How much checking for trail ",l.key]}),i.jsx("div",{className:"choice-row vf-levels",children:mc.map(m=>i.jsx(ht,{on:f===m,title:Ui[m],sub:Xm[m],onClick:()=>{o(void 0),Gi.act({action:"level",mapId:l.id,level:m,by:wt}).catch(v=>o(v.message))}},m))}),f!=="off"&&!c&&i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:"No working checks yet, so completions at this level stop and wait for you."})]}),r&&i.jsx("span",{className:"vf-err",children:r})]}),t.errors.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line alert",title:t.hash,children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[d," has errors. Completions that need checks wait for you until it is fixed."]})]}),i.jsx("ul",{className:"vf-errors",children:t.errors.map(m=>i.jsx("li",{children:m},m))})]}),!t.exists&&i.jsx(US,{file:d}),c&&t.exists&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line ok",title:t.hash,children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[i.jsx("span",{className:"t-code",children:d})," · ",c.run.length," checks run on every completion"]})]}),i.jsx(q,{className:"set-hint",parts:[`New trails start at ${Ui[c.default]}`,`${c.maxAttempts} attempts before it waits for you`,c.failFast&&"Stops at the first failure"]}),i.jsx("div",{className:"vf-checks",children:Object.entries(c.checks).map(([m,v])=>i.jsxs("div",{className:"vf-check",children:[i.jsx("span",{className:"t-code",children:c.run.includes(m)?m:`${m} (on request)`}),i.jsx("code",{children:v.run.join(" ")}),i.jsxs("span",{className:"dim",children:[v.timeoutSec," s",v.cwd&&v.cwd!=="."?` · in ${v.cwd}`:""]})]},m))})]}),i.jsxs("span",{className:"set-hint t-meta",children:["Teamtrail never edits ",d,". Change checks in the repo, so no agent can change what verifies its own work."]})]})}function WS({data:e}){const{map:t}=e;return i.jsxs(i.Fragment,{children:[t?i.jsx(it,{id:"mode",children:i.jsx(He,{title:`Trail ${t.key}`,children:i.jsx(v0,{value:t.mode,onChange:e.onMapMode})})}):i.jsx(Ee,{children:"Chart or pick a trail to set its mode, model matching and team."}),i.jsx(it,{id:"verification",storage:"repo",children:i.jsx(HS,{map:t})}),i.jsx(it,{id:"models",children:i.jsx(zS,{map:t,snaps:e.snaps,answered:e.answered,onChange:e.onModelMatching})}),t&&i.jsx(it,{id:"team",children:i.jsx(qN,{map:t})})]})}const KS=[{value:"auto",title:"Match my system"},{value:"day",title:"Day"},{value:"night",title:"Night"}];function VS(e){return i.jsx("div",{className:"choice-row compact",children:KS.map(t=>i.jsx(ht,{on:e.value===t.value,title:t.title,onClick:()=>e.onChange(t.value)},t.value))})}function GS({data:e}){const{prefs:t,update:r}=e;return i.jsxs(i.Fragment,{children:[i.jsx(it,{id:"appearance",storage:"browser",children:i.jsx(He,{title:"Appearance",children:i.jsx(VS,{value:t.theme,onChange:o=>r({theme:o})})})}),i.jsx(it,{id:"transcript",storage:"browser",children:i.jsx(He,{title:"HITL transcript",children:i.jsx(ap,{value:t.hitlTranscript,onChange:o=>r({hitlTranscript:o})})})}),i.jsx(it,{id:"agent",children:i.jsx(He,{title:"Agent",children:i.jsx("div",{className:"choice-row",children:bm.map(o=>i.jsx(ht,{on:o.status==="primary",disabled:o.status!=="primary",title:o.name},o.id))})})})]})}function QS(e){const{data:t,route:r}=e;switch(e.group){case"trail":return i.jsx(WS,{data:t});case"project":return i.jsx(fS,{data:t,route:r});case"alerts":return i.jsx(xN,{data:t,route:r});case"you":return i.jsx(GS,{data:t});case"projects":return i.jsx(it,{id:"projects",storage:"machine",children:i.jsx(ES,{})});case"about":return i.jsx(it,{id:"changelog",children:i.jsx(SN,{})});default:return e.group}}function qS(e){const{group:t,route:r}=e,o=x.useRef(null),l=x.useRef(null);return x.useEffect(()=>{var d,f;(d=o.current)==null||d.focus({preventScroll:!0});const c=r.section&&document.getElementById(`settings-${r.section}`);c?c.scrollIntoView({block:"start"}):(f=l.current)==null||f.scrollTo({top:0})},[t.id,r.section]),i.jsx("div",{className:"sp-pane",ref:l,children:i.jsxs("div",{className:"sp-pane-in",children:[i.jsxs("header",{className:"sp-pane-head",children:[i.jsx("h2",{className:"sp-title t-title",ref:o,tabIndex:-1,children:t.label}),i.jsx("p",{className:"sp-intro t-meta",children:t.intro})]}),i.jsx(QS,{group:t.id,data:e.data,route:r})]})})}function YS(e){return i.jsx("nav",{className:"sp-nav","aria-label":"Settings groups",children:i.jsx("ul",{children:Hi.map(t=>{const r=t.id===e.current;return i.jsx(Ae,{as:"li",className:"sp-nav-row",selected:r,current:r?"page":void 0,title:t.label,context:i.jsx(q,{parts:t.sections.map(o=>o.title)}),trailing:e.drill&&"›",onOpen:()=>e.onPick(t.id)},t.id)})})})}function JS(e,t){return e.group?Hi.find(r=>r.id===e.group):t==="mobile"?void 0:Hi[0]}const XS={page:"Back to the Lookout",list:"Lookout",group:"Settings"},ZS=(e,t)=>e?t?"group":"list":"page";function e1(e){const{bp:t,route:r}=e,o=t==="mobile",l=JS(r,t),c=ZS(o,!!l),d=()=>c==="group"?e.onShow({}):e.onClose();x.useEffect(()=>{const m=v=>{v.key!=="Escape"||v.defaultPrevented||document.querySelector(".scrim")||(c==="group"?e.onShow({}):e.onClose())};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[c,e]);const f=m=>e.onShow({group:m}),g=c!=="group"&&i.jsx(YS,{current:l==null?void 0:l.id,onPick:f,drill:o});return i.jsxs(Ke,{className:`zone decisions-view settings-page sp-${t}`,"aria-label":"Settings",children:[i.jsxs("header",{className:"dv-head",children:[i.jsxs("button",{className:"back",onClick:d,children:["‹ ",XS[c]]}),c!=="group"&&i.jsx(Je,{as:"h2",children:"Settings"}),!o&&i.jsx("span",{className:"dv-head-right t-meta",children:"Esc"})]}),i.jsxs("div",{className:"sp-body",children:[g,l&&i.jsx(qS,{group:l,data:e.data,route:r})]})]})}function mo(e,t){const r=new URL(e);return r.searchParams.delete("settings"),t&&r.searchParams.set("settings",t.section??t.group??""),r.toString()}function t1(e){var l;const{rt:t,api:r,settings:o}=e;return o.route?i.jsx(e1,{bp:e.bp,route:o.route,onShow:o.show,onClose:o.close,data:{prefs:e.prefs,update:e.update,activeTracker:t.kind,location:t.adapter.location,map:(l=r.snap)==null?void 0:l.map,onMapMode:r.actions.setMode,snaps:Object.values(r.allSnaps),answered:r.activity.answered,onModelMatching:r.actions.setModelMatching}}):null}function n1(e){return i.jsxs(Ke,{className:"zone side",style:{gridArea:"inspector"},children:[i.jsx(yw,{className:"zone-tabs",value:e.tab,onChange:e.onTab,items:[{id:"ticket",label:"Ticket"},{id:"activity",label:"Activity"},{id:"plan",label:"Plan",n:e.unspecified}]}),{ticket:e.ticket,activity:e.activity,plan:e.plan}[e.tab]]})}function Sp(e){return e.filter(t=>t.state!=="out-of-scope").map(t=>({x:t.x,y:t.y,w:Ue,h:Ge}))}function s1(e){const{obstacles:t,from:r,to:o,clear:l}=e,c=t.flatMap(f=>[f.y-28,f.y+f.h+28]).filter(l),d=f=>Math.abs(f-r)+Math.abs(f-o);return c.reduce((f,g)=>d(g)<d(f)?g:f,c[0]??r)}const i1=6;function r1(e){const t=e.filter((l,c)=>c===0||l.x!==e[c-1].x||l.y!==e[c-1].y);let r=`M${t[0].x} ${t[0].y}`;for(let l=1;l<t.length-1;l++){const[c,d,f]=[t[l-1],t[l],t[l+1]],g=Math.min(i1,Rh(c,d)/2,Rh(d,f)/2),m=Oh(d,c,g),v=Oh(d,f,g);r+=`L${m.x} ${m.y}Q${d.x} ${d.y} ${v.x} ${v.y}`}const o=t[t.length-1];return`${r}L${o.x} ${o.y}`}function Rh(e,t){return Math.abs(e.x-t.x)+Math.abs(e.y-t.y)}function Oh(e,t,r){return{x:e.x+Math.sign(t.x-e.x)*r,y:e.y+Math.sign(t.y-e.y)*r}}function Co(e){const t=e.direction==="TB",r=d=>t?{x:d.y,y:d.x}:d,o=r(e.a),l=r(e.b),c=e.obstacles.map(d=>t?{x:d.y,y:d.x,w:d.h,h:d.w}:d);return r1(o1({a:o,b:l,obstacles:c,gap:e.gap}).map(r))}function o1({a:e,b:t,obstacles:r,gap:o}){const l=r.filter(m=>m.x+m.w>e.x+1&&m.x<t.x-1),c=m=>!l.some(v=>m>v.y-8&&m<v.y+v.h+8),d=Math.min(e.x+o/2,(e.x+t.x)/2),f=Math.max(t.x-o/2,(e.x+t.x)/2);if(c(e.y))return[e,{x:f,y:e.y},{x:f,y:t.y},t];if(c(t.y))return[e,{x:d,y:e.y},{x:d,y:t.y},t];const g=s1({obstacles:l,from:e.y,to:t.y,clear:c});return[e,{x:d,y:e.y},{x:d,y:g},{x:f,y:g},{x:f,y:t.y},t]}function a1(e){if(e.direction==="LR"){const r=e.width+96;return{x:r,y:e.graphH/2,right:r+34,bottom:e.height}}const t=e.graphH+76;return{x:e.width/2,y:t,right:e.width,bottom:Math.max(e.height,t+40)}}function l1(e,t){const r=new Set(e.edges.map(c=>c.from)),o=e.nodes.filter(c=>c.state!=="out-of-scope"&&!r.has(c)),l=Sp(e.nodes);return o.map(c=>{if(e.direction==="LR"){const g={x:c.x+Ue,y:c.y+Ge/2},m={x:t.x-30,y:t.y};return Co({direction:"LR",a:g,b:m,obstacles:l,gap:96})}const d={x:c.x+Ue/2,y:c.y+Ge},f={x:t.x,y:t.y-30};return Co({direction:"TB",a:d,b:f,obstacles:l,gap:48})})}function c1({x:e,y:t,text:r}){const o=r!=null&&r.trim()?`Destination
|
|
139
139
|
${r.trim()}`:`Destination
|
|
140
|
-
Where this trail ends`;return i.jsxs("g",{className:"destination",transform:`translate(${e} ${t})`,"aria-label":o,"data-tip":o,tabIndex:0,children:[i.jsx("rect",{className:"x-hit",x:-24,y:-24,width:48,height:48}),i.jsx("path",{className:"x-stroke",d:"M-15 -16 C-9 -10 2 4 16 17"}),i.jsx("path",{className:"x-stroke",d:"M17 -15 C8 -8 -6 5 -16 17"})]})}function u1({trails:e}){return e.map(t=>i.jsx("path",{className:"edge edge-open edge-destination",d:t},t))}function d1(){return i.jsxs("defs",{children:[i.jsx("pattern",{id:"map-grid",width:"40",height:"40",patternUnits:"userSpaceOnUse",children:i.jsx("path",{d:"M40 0H0V40",fill:"none",stroke:"var(--map-grid)",strokeWidth:"1"})}),i.jsx("pattern",{id:"hatch-oos",width:"10",height:"10",patternUnits:"userSpaceOnUse",patternTransform:"rotate(45)",children:i.jsx("line",{x1:"0",y1:"0",x2:"0",y2:"10",stroke:"var(--line2)",strokeWidth:"1"})})]})}const $o=(e,t)=>`${e}>${t}`;function f1(e,t,r=[]){const o=new Map(e.tickets.map(c=>[c.id,c]));return{tickets:t.nodes.map(c=>{const d=o.get(c.id);return d?{...d,blockedBy:[...c.blockedBy,...c.removedEdges??[]]}:{id:c.id,key:"+",title:c.title,type:c.type,body:"",state:"open",blockedBy:c.blockedBy,comments:[],createdAt:e.map.updatedAt,updatedAt:e.map.updatedAt}}),marks:new Map(t.nodes.map(c=>[c.id,c.mark])),newEdges:new Set(t.nodes.flatMap(c=>c.newEdges.map(d=>$o(d,c.id)))),removedEdges:new Set(t.nodes.flatMap(c=>(c.removedEdges??[]).map(d=>$o(d,c.id)))),frozen:new Set(r)}}function h1(e,t){const r=Bk({...e,tickets:t}),o=new Set;for(let l=1;l<r.length;l++)o.add($o(r[l-1].id,r[l].id));return o}const Ph={LR:130,TB:68};function m1(e){const{direction:t,from:r,to:o,cards:l}=e;if(t==="LR"){const f={x:r.x+Ue,y:r.y+Ge/2},g={x:o.x,y:o.y+Ge/2};return Co({direction:t,a:f,b:g,obstacles:l,gap:Ph.LR})}const c={x:r.x+Ue/2,y:r.y+Ge},d={x:o.x+Ue/2,y:o.y};return Co({direction:t,a:c,b:d,obstacles:l,gap:Ph.TB})}function p1(e){const{from:t,to:r,direction:o}=e,c=["edge",t.ticket.state!=="open"?"edge-done":"edge-open"];return e.critical&&c.push("edge-critical"),e.added&&c.push("edge-added"),e.removed&&c.push("edge-removed"),i.jsx("path",{className:c.join(" "),d:m1({direction:o,from:t,to:r,cards:e.cards})})}function g1(e){const{snap:t,tickets:r,direction:o,preview:l}=e,c=x.useMemo(()=>h1(t,r),[t,r]),d=x.useMemo(()=>Sp(e.nodes),[e.nodes]);return e.edges.map(({from:f,to:g})=>{const m=$o(f.ticket.id,g.ticket.id);return i.jsx(p1,{from:f,to:g,direction:o,cards:d,critical:c.has(m),added:l==null?void 0:l.newEdges.has(m),removed:l==null?void 0:l.removedEdges.has(m)},m)})}const Pc=24,v1=13,k1=9.5;function y1(e){const t=e.guide;return i.jsx("g",{className:"meta",transform:`translate(${Pc} ${e.y})`,children:e.chips.map((r,o)=>{const l=r.kind==="guide"?t:void 0;return i.jsxs("g",{className:We("card-chip",r.kind,r.kind==="state"&&e.tone,(l==null?void 0:l.off)&&"off"),"data-guide-id":l==null?void 0:l.id,transform:`translate(${r.x} 0)`,children:[l&&i.jsx("title",{children:l.tip}),i.jsx("rect",{width:r.w,height:v1,rx:3}),i.jsx("text",{x:(r.w-r.textW)/2,y:k1,textLength:r.textW,lengthAdjust:"spacingAndGlyphs",children:r.text})]},o)})})}const bp=5,x1={sans:"9.5px 'Figtree Variable', system-ui, sans-serif",mono:"8.55px 'JetBrains Mono Variable', ui-monospace, monospace"};let Oi;function w1(){if(Oi!==void 0)return Oi;try{Oi=typeof document>"u"?null:document.createElement("canvas").getContext("2d")}catch{Oi=null}return Oi}function j1(e,t="sans"){const r=w1();return r?(r.font=x1[t],r.measureText(e).width*1.04):e.length*bp}const _h=4,Dh=3,N1=6;function S1(e){var y;const t=Ue-Pc-8-(e.reserve??0),r=((y=e.state)==null?void 0:y.split(" · "))??[],o=[{kind:"key",text:e.key},{kind:"type",text:e.type},...e.guide===void 0?[]:[{kind:"guide",text:e.guide}],...r.map(w=>({kind:"state",text:w})),...e.needsYou?[{kind:"needs",text:"needs you"}]:[]],l=t-o.length*2*_h-(o.length-1)*Dh,c=w=>j1(w.text,w.kind==="key"?"mono":"sans"),d=o.filter(w=>w.kind!=="guide").reduce((w,j)=>w+c(j),0),f=Math.max(N1,Math.floor((l-d)/bp)),g=o.map(w=>w.kind==="guide"?{...w,text:AN(w.text,f)}:w),m=Math.min(1,l/g.reduce((w,j)=>w+c(j),0));let v=0;return g.map(w=>{const j=c(w)*m,$={...w,x:v,w:j+2*_h,textW:j};return v+=$.w+Dh,$})}function b1(e,t,r){const o=e.state==="frontier"||e.state==="rework";if(!(!t||r||e.ticket.assignee||!o))return t}function C1(e){const t=["node",`st-${e.n.state}`,`tone-${e.tone}`,e.hitl?"hitl":"afk"];return e.selected&&t.push("sel"),e.live&&t.push("live"),e.waiting&&t.push("waiting"),e.stalled&&!e.waiting&&t.push("stalled"),e.mark&&t.push(`mark-${e.mark}`),e.frozen&&t.push("frozen"),t.join(" ")}function $1({wait:e,session:t}){return e?i.jsx("title",{children:`Needs a ${e} model: no connected agent runs one`}):t?i.jsx("title",{children:`${t.agent} · step ${t.step}/${t.total} · ${t.stepLabel.toLowerCase()}`}):null}const T1={claimed:"working",verifying:"working",frontier:"ready",blocked:"backlog",parked:"backlog",decided:"done","out-of-scope":"cancelled",rework:"attention",held:"attention"};function E1(e){const t=T1[e.state];return t==="done"||t==="cancelled"?t:e.attention?"attention":e.live?"working":t}function I1({mark:e,frozen:t}){const r=e&&e!=="unchanged"&&e!=="cancelled"?e:void 0;return i.jsxs(i.Fragment,{children:[e==="cancelled"&&i.jsx("line",{className:"strike",x1:8,y1:Ge/2,x2:Ue-8,y2:Ge/2}),r&&i.jsx("text",{className:"reroute-tag",x:Ue-8,y:Ge-7,textAnchor:"end",children:r}),t&&i.jsx("text",{className:"freeze",x:Ue-(r?58:8),y:Ge-7,textAnchor:"end",children:"❄"})]})}function M1(e){const{n:t,session:r}=e,o=t.ticket.assignee;return e.waiting?{text:"waiting on you",tone:"urgent"}:e.stalled?{text:`stalled · ${o}`,tone:"warn"}:e.wait?{text:`needs ${e.wait}`,tone:"warn"}:r&&e.step?{text:`${r.agent} · step ${r.step}/${r.total}`,tone:"agent"}:r?{text:r.agent,tone:"agent"}:t.state==="claimed"?{text:o??"working",tone:"agent"}:{text:qx[t.state],tone:""}}function A1({tone:e,cy:t}){return e==="done"?i.jsx("path",{className:"dot dot-done",d:`M10 ${t}l2.5 2.5 4.5 -5`}):i.jsx("circle",{className:`dot dot-${e}`,cx:13,cy:t,r:e==="backlog"?3:3.5})}function L1(e,t,r=2){const o=e.split(/\s+/),l=[];let c="";for(const d of o)(c+" "+d).trim().length>t?(l.push(c.trim()),c=d):c+=" "+d;if(l.push(c.trim()),l.length>r){const d=l.slice(0,r);return d[r-1]=d[r-1].slice(0,t-1)+"…",d}return l}const R1=26;function O1({n:e,session:t,stalled:r,flag:o,selected:l,onSelect:c,mark:d,frozen:f,needs:g}){const m=e.ticket,v=L1(m.title,R1),y=Wi(m)==="hitl",w=!!(t!=null&&t.waitingOn),j=!!d&&d!=="unchanged",$=b1(e,g,!!t),N=tS(m.guide),E=j?void 0:M1({n:e,session:t,waiting:w,stalled:r,wait:$,step:!N}),M=y&&!j&&(m.type==="task"||m.type==="execute"),R=w||!!r||!!$||M&&e.state==="frontier",O=E1({state:e.state,live:!!t,attention:R}),X=zi[m.type],ie=(j&&d!=="cancelled"?44:0)+(f?12:0),D=S1({key:m.key,type:X,guide:N==null?void 0:N.name,state:E==null?void 0:E.text,needsYou:M,reserve:ie}),q=v.length>1?19:24;return i.jsxs("g",{className:C1({n:e,tone:O,hitl:y,selected:l,live:!!t,waiting:w,stalled:r,mark:d,frozen:f}),style:{transform:`translate(${e.x}px, ${e.y}px)`},onClick:re=>{re.stopPropagation(),c({kind:"ticket",id:m.id})},children:[i.jsx($1,{wait:$,session:t}),i.jsx("rect",{className:"ring",x:-3.5,y:-3.5,width:Ue+7,height:Ge+7,rx:9}),i.jsx("rect",{className:"card",x:.5,y:.5,width:Ue-1,height:Ge-1,rx:6}),i.jsx(A1,{tone:O,cy:q-4}),v.map((re,V)=>i.jsx("text",{className:"title",x:Pc,y:q+V*14,children:re},V)),i.jsx(y1,{chips:D,y:q+v.length*14-8,tone:E==null?void 0:E.tone,guide:N}),o&&i.jsx("circle",{className:`pr-flag-dot ${o}`,cx:Ue-2,cy:2,r:4}),i.jsx(I1,{mark:d,frozen:f})]})}const Bh=.72;function P1(e){const{fit:t,nodes:r,size:o,pad:l}=e;if(t.k>=Bh)return t;const c=r.find(f=>f.state==="claimed")??r.find(f=>f.state==="frontier")??r[0];if(!c)return t;const d=Bh;return{k:d,x:o.w/2-(c.x+l+Ue/2)*d,y:o.h/2-(c.y+l+Ge/2)*d}}function _1(e){const{y:t,width:r,height:o}=e,l=e.nodes.filter(c=>c.state==="out-of-scope").length;return l?i.jsxs("g",{className:"quarantine",children:[i.jsx("rect",{x:-20,y:t-30,width:r+40,height:o+18,fill:"url(#hatch-oos)"}),i.jsx("line",{x1:-20,y1:t-30,x2:r+20,y2:t-30}),i.jsxs("text",{x:-12,y:t-12,children:["Out of scope · ",l]})]}):null}const tt=280,zh=4,D1=220,Ls=e=>Math.round(e/zh)*zh;function B1(e){let t=2166136261;for(const r of e)t=Math.imul(t^r.charCodeAt(0),16777619);return()=>{t=t+1831565813|0;let r=Math.imul(t^t>>>15,1|t);return r=r+Math.imul(r^r>>>7,61|r)^r,((r^r>>>14)>>>0)/4294967296}}function Gl(e,t,r,o){return Array.from({length:6},()=>{const l=o*(.5+e()*.7),c=o*(.3+e()*.4);return{x:Ls(t+(e()-.5)*o*.8-l/2),y:Ls(r+(e()-.5)*o*.5-c/2),w:Ls(l),h:Ls(c)}})}function z1(e){const{width:t,height:r,nodes:o}=e,l=B1(e.seed),c=(w,j)=>w+l()*(j-w),d=(w,j)=>!o.some($=>w>$.x-52&&w<$.x+Ue+28&&j>$.y-52&&j<$.y+Ge+28),f=(t+tt*2)*(r+tt*2),g=Array.from({length:Math.round(f/9e4)},()=>Gl(l,c(-tt,t+tt),c(-tt,r+tt),c(160,360))).flat(),m=[...Gl(l,t+tt*.55,r+tt*.55,300),...Gl(l,-tt*.5,-tt*.45,220)],v=[],y=(w,j,$)=>{v.length<D1&&d(j,$)&&v.push({sprite:w,x:Ls(j),y:Ls($)})};for(let w=0;w<Math.round(f/3e4);w++){const j=c(-tt,t+tt),$=c(-tt,r+tt),N=3+Math.floor(l()*5);for(let E=0;E<N;E++)y(l()<.65?"pine":"oak",j+c(-70,70),$+c(-44,44))}for(let w=0;w<Math.round(f/45e3);w++)y(l()<.4?"rock":"tuft",c(-tt,t+tt),c(-tt,r+tt));return v.sort((w,j)=>w.y-j.y),{grass:g,water:m,items:v}}const Cp={pine:i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"16",y:"30",width:"4",height:"10",fill:"var(--map-trunk)"}),i.jsx("path",{d:"M18 0l9 12h-4l8 10h-4l9 11H0l9-11H5l8-10H9z",fill:"var(--map-pine)"}),i.jsx("path",{d:"M18 0l9 12h-4l8 10h-4l9 11H18z",fill:"var(--map-pine2)"})]}),oak:i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"16",y:"24",width:"4",height:"12",fill:"var(--map-trunk)"}),i.jsx("circle",{cx:"18",cy:"14",r:"14",fill:"var(--map-oak)"}),i.jsx("circle",{cx:"10",cy:"17",r:"8",fill:"var(--map-oak)"}),i.jsx("circle",{cx:"26",cy:"17",r:"8",fill:"var(--map-oak)"}),i.jsx("circle",{cx:"22",cy:"10",r:"6",fill:"var(--map-oak2)"})]}),rock:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M1 16Q2 6 10 3Q18-1 23 6Q28 11 27 16z",fill:"var(--map-rock)"}),i.jsx("path",{d:"M15 16Q15 8 19 4Q25 8 27 16z",fill:"var(--map-rock2)"})]}),tuft:i.jsx("path",{d:"M4 8Q3 4 1 1M14 8Q14 3 14 0M24 8Q25 4 27 1",fill:"none",stroke:"var(--map-pine2)",strokeWidth:"2.5",strokeLinecap:"round"})};function F1({name:e}){return i.jsx("symbol",{id:`terrain-${e}`,overflow:"visible",children:Cp[e]})}const U1=Object.keys(Cp),H1=x.memo(function(t){const{seed:r,width:o,height:l,nodes:c}=t,d=x.useMemo(()=>z1({seed:r,width:o,height:l,nodes:c}),[r,o,l,c]);return i.jsxs("g",{className:"terrain","aria-hidden":"true",children:[i.jsx("defs",{children:U1.map(f=>i.jsx(F1,{name:f},f))}),d.grass.map((f,g)=>i.jsx("rect",{x:f.x,y:f.y,width:f.w,height:f.h,fill:"var(--map-grass)"},g)),d.water.map((f,g)=>i.jsx("rect",{x:f.x,y:f.y,width:f.w,height:f.h,fill:"var(--map-water)"},g)),i.jsx("rect",{x:-4e3,y:-4e3,width:o+8e3,height:l+8e3,fill:"url(#map-grid)"}),d.items.map((f,g)=>i.jsx("use",{href:`#terrain-${f.sprite}`,x:f.x,y:f.y},g))]})}),W1=380;function K1(e){const{selId:t,size:r}=e,o=x.useRef(e);o.current=e;const l=x.useRef(!0);x.useEffect(()=>{if(l.current){l.current=!1;return}const{nodes:c,pad:d,view:f,setView:g,onFocus:m}=o.current,v=t?c.find(M=>M.ticket.id===t):void 0;if(!v||!r.w)return;m();const y=Math.min(1.4,Math.max(f.k,1.05)),w={k:y,x:r.w/2-(d+v.x+Ue/2)*y,y:r.h/2-(d+v.y+Ge/2)*y};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return g(w);const j=f,$=performance.now();let N=0;const E=M=>{const R=Math.min(1,(M-$)/W1),O=1-(1-R)**3;g({k:j.k+(w.k-j.k)*O,x:j.x+(w.x-j.x)*O,y:j.y+(w.y-j.y)*O}),R<1&&(N=requestAnimationFrame(E))};return N=requestAnimationFrame(E),()=>cancelAnimationFrame(N)},[t])}function V1(e,t){const r=x.useRef(t);r.current=t,x.useEffect(()=>{const o=e.current;if(!o)return;const l=m=>{const v=o.getBoundingClientRect();return{x:m.clientX-v.left,y:m.clientY-v.top}},c=m=>{m.preventDefault();const v=m.ctrlKey?.01:.0015;r.current(Math.exp(-m.deltaY*v),l(m))};let d=1;const f=m=>{m.preventDefault(),d=1},g=m=>{m.preventDefault();const v=m;r.current(v.scale/d,l(v)),d=v.scale};return o.addEventListener("wheel",c,{passive:!1}),o.addEventListener("gesturestart",f,{passive:!1}),o.addEventListener("gesturechange",g,{passive:!1}),()=>{o.removeEventListener("wheel",c),o.removeEventListener("gesturestart",f),o.removeEventListener("gesturechange",g)}},[e])}function Fh(e,t,r){const o=Math.min(3,Math.max(.2,t));return{k:o,x:r.x-(r.x-e.x)*o/e.k,y:r.y-(r.y-e.y)*o/e.k}}const Yt=32,G1=1.8;function Q1(e){var te;const{snap:t,selection:r,onSelect:o,preview:l}=e,c=(l==null?void 0:l.tickets)??t.tickets,d=x.useRef(null),[f,g]=x.useState({w:0,h:0});x.useEffect(()=>{const P=d.current;if(!P)return;const Y=new ResizeObserver(([ae])=>g({w:ae.contentRect.width,h:ae.contentRect.height}));return Y.observe(P),()=>Y.disconnect()},[]);const m=x.useMemo(()=>{const P=Ff(c,"LR",t.map.mode),Y=Ff(c,"TB",t.map.mode),ae=Z=>Math.min(f.w/(Z.width+Yt*2),f.h/(Z.height+Yt*2+16));return ae(P)*G1>=ae(Y)?P:Y},[c,t.map.mode,f.w,f.h]),v=(P,Y)=>Math.min(1.25,Math.max(e.minFit??0,Math.min(f.w/P,f.h/Y))),y=x.useMemo(()=>{const P=m.width+Yt*2,Y=m.height+Yt*2+16,Z=m.nodes.some(B=>B.state==="out-of-scope")&&f.h?Math.max(0,f.h/v(P,Y)-Y):0;if(!Z)return{...m,slack:Z};const U=new Map(m.nodes.map(B=>[B,{...B,y:B.y+(B.state==="out-of-scope"?Z:Z/2)}]));return{...m,slack:Z,nodes:[...U.values()],edges:m.edges.map(B=>({from:U.get(B.from),to:U.get(B.to)})),quarantineY:m.quarantineY+Z,height:m.height+Z}},[m,f.w,f.h,e.minFit]),w=a1(y),j=w.right+Yt*2,$=w.bottom+Yt*2+16,N=()=>{const P=v(j,$);return{k:P,x:Math.max(0,(f.w-j*P)/2),y:Math.max(0,(f.h-$*P)/2)}},[E,M]=x.useState({k:1,x:0,y:0}),R=x.useRef(!1);x.useEffect(()=>{R.current=!1},[t.map.id]),x.useEffect(()=>{!R.current&&f.w&&M(P1({fit:N(),nodes:y.nodes,size:f,pad:Yt}))},[f.w,f.h,j,$,t.map.id]);const O=x.useRef(new Map),X=x.useRef(null),ie=P=>{const Y=d.current.getBoundingClientRect();return{x:P.clientX-Y.left,y:P.clientY-Y.top}},D=()=>{var Z;const P=[...O.current.values()],Y=P.length>1?{x:(P[0].x+P[1].x)/2,y:(P[0].y+P[1].y)/2}:P[0],ae=P.length>1?Math.hypot(P[0].x-P[1].x,P[0].y-P[1].y):0;X.current={view:E,dist:ae,mid:Y,moved:((Z=X.current)==null?void 0:Z.moved)??!1}};V1(d,(P,Y)=>{R.current=!0,M(ae=>Fh(ae,ae.k*P,Y))});const q=sn(5e3),re=xc(e.leases,t.map.id),V=Cc(),ge=(te=Oc())==null?void 0:te.waiting,Re=new Map(e.sessions.filter(P=>tn(P)&&P.ticketId).map(P=>[P.ticketId,P])),be=(r==null?void 0:r.kind)==="ticket"?r.id:void 0;return K1({selId:be,nodes:y.nodes,size:f,pad:Yt,view:E,setView:M,onFocus:()=>R.current=!0}),i.jsxs("div",{className:"graph-box",ref:d,onPointerDown:P=>{O.current.set(P.pointerId,ie(P)),O.current.size===1&&(X.current=null),D()},onPointerMove:P=>{var Z;if(!O.current.has(P.pointerId)||!X.current)return;O.current.set(P.pointerId,ie(P));const Y=X.current,ae=[...O.current.values()];if(ae.length>1){const U={x:(ae[0].x+ae[1].x)/2,y:(ae[0].y+ae[1].y)/2},B=Math.hypot(ae[0].x-ae[1].x,ae[0].y-ae[1].y),H=Fh(Y.view,Y.view.k*B/(Y.dist||B),Y.mid);M({...H,x:H.x+U.x-Y.mid.x,y:H.y+U.y-Y.mid.y}),Y.moved=!0}else{const U=ae[0].x-Y.mid.x,B=ae[0].y-Y.mid.y;if(!Y.moved&&Math.hypot(U,B)<5)return;Y.moved||(Z=d.current)==null||Z.setPointerCapture(P.pointerId),Y.moved=!0,M({...Y.view,x:Y.view.x+U,y:Y.view.y+B})}R.current=!0},onPointerUp:P=>{O.current.delete(P.pointerId),O.current.size&&D()},onPointerCancel:P=>O.current.delete(P.pointerId),onClickCapture:P=>{var Y;(Y=X.current)!=null&&Y.moved&&(P.stopPropagation(),X.current=null)},children:[i.jsxs("svg",{className:"graph",width:f.w,height:f.h,onClick:()=>o(null),children:[i.jsx(d1,{}),i.jsx("g",{transform:`translate(${E.x} ${E.y}) scale(${E.k})`,children:i.jsxs("g",{transform:`translate(${Yt} ${Yt})`,children:[i.jsx(H1,{seed:t.map.id,width:j,height:$,nodes:y.nodes}),i.jsx(_1,{y:y.quarantineY,width:y.width,height:y.quarantineH,nodes:y.nodes}),i.jsx(g1,{snap:t,tickets:c,direction:y.direction,nodes:y.nodes,edges:y.edges,preview:l}),i.jsx(u1,{trails:l1(y,w)}),y.nodes.length>0&&i.jsx(c1,{x:w.x,y:w.y,text:t.map.sections.destination}),y.nodes.map(P=>{var Y;return i.jsx(O1,{n:P,session:Re.get(P.ticket.id),stalled:!!re.get(P.ticket.id)&&Po(re.get(P.ticket.id),q)!=="live",flag:Yx(Bs.ticket(V,t.map.id,P.ticket.id)),selected:be===P.ticket.id,onSelect:o,mark:l==null?void 0:l.marks.get(P.ticket.id),frozen:l==null?void 0:l.frozen.has(P.ticket.id),needs:(Y=ge==null?void 0:ge.find(ae=>ae.mapId===t.map.id&&ae.ticketId===P.ticket.id))==null?void 0:Y.tier},P.ticket.id)})]})})]}),i.jsx("button",{className:"btn sm fit-btn","data-tip":"Fit the whole trail in view",onPointerDown:P=>P.stopPropagation(),onClick:P=>{P.stopPropagation(),R.current=!0,M(N())},children:"Fit"})]})}const Ql=[["decided","Done"],["claimed","Working"],["frontier","Ready"],["blocked","Backlog"],["parked","Parked"],["out-of-scope","Cancelled"]],Uh=[["verifying","Verifying"],["rework","Rework"],["held","Blocked"]];function q1({snap:e,sessions:t}){const r=um(e),o=m=>r[m],l=t.filter(_m).length,c=zk(e),d=Math.max(1,...c.map(m=>m.open+m.closed)),g=(e.map.verification??"off")!=="off"||Uh.some(([m])=>o(m))?[...Ql.slice(0,2),...Uh,...Ql.slice(2)]:Ql;return i.jsxs("div",{className:"status-panel",children:[i.jsxs("div",{className:"sp-col sp-status",children:[i.jsxs("div",{className:"sp-head",children:[i.jsx(Je,{as:"h3",children:"Status"}),i.jsxs("span",{className:"t-meta",children:[r.total," tickets"]})]}),i.jsxs("ul",{children:[g.map(([m,v])=>i.jsxs("li",{className:`st-${m} ${o(m)?"":"zero"}`,children:[i.jsx("i",{}),i.jsx("span",{children:v}),i.jsx("b",{children:o(m)})]},m)),i.jsxs("li",{className:`st-waiting ${l?"":"zero"}`,children:[i.jsx("i",{}),i.jsx("span",{children:"Waiting on you"}),i.jsx("b",{children:l})]})]})]}),i.jsxs("div",{className:"sp-block sp-col",children:[i.jsx("span",{className:"t-label",children:"Type mix"}),i.jsx("ul",{className:"mix",children:c.map(m=>i.jsxs("li",{title:`${m.type}: ${m.closed} closed, ${m.open} open`,children:[i.jsx("span",{className:"t-meta",children:zi[m.type]}),i.jsxs("span",{className:"mix-bar",children:[i.jsx("i",{className:"closed",style:{width:`${m.closed/d*100}%`}}),i.jsx("i",{className:"open",style:{width:`${m.open/d*100}%`}})]}),i.jsx("b",{children:m.open+m.closed})]},m.type))})]})]})}function Y1(e){const[t,r]=x.useState(!1);return i.jsxs("div",{className:t?"status-drawer open":"status-drawer",children:[i.jsxs("button",{type:"button",className:"status-toggle","aria-expanded":t,onPointerDown:o=>o.stopPropagation(),onClick:()=>r(!t),children:["Summary ",i.jsx("span",{className:"caret",children:t?"▾":"▴"})]}),i.jsx(q1,{snap:e.snap,sessions:e.sessions})]})}function J1({planOnly:e,verifies:t}){const r=[["frontier","Ready"],["claimed","Working"],...t?[["verifying","Verifying"],["rework","Rework"],["held","Blocked"]]:[],["stalled","Stalled"],["blocked","Backlog"],["decided","Done"],...e?[["parked","Parked"]]:[],["out-of-scope","Cancelled"],["waiting","Waiting on you"]];return i.jsxs("div",{className:"legend",children:[r.map(([o,l])=>i.jsxs("span",{className:`lg st-${o}`,children:[i.jsx("i",{}),l]},o)),i.jsx("span",{className:"lg hitl",children:"● needs human"})]})}function X1(e){var o,l;const{snap:t,selection:r}=e.api;return i.jsxs(Ke,{as:"main",className:"zone map-zone",style:{gridArea:"map"},children:[t&&i.jsx(g0,{}),(o=e.trail)==null?void 0:o.banner,i.jsxs("div",{className:"map-area",children:[t&&!e.compact&&i.jsx(Y1,{snap:t,sessions:e.sessions}),t?i.jsx(Q1,{snap:t,sessions:e.sessions,leases:e.api.leases,selection:r,onSelect:e.onSelect,minFit:e.minFit,preview:(l=e.trail)==null?void 0:l.preview}):i.jsxs("div",{className:"nomap",children:[i.jsx(x0,{}),i.jsx("h2",{children:"No trail"}),i.jsx("p",{className:"nomap-lede",children:"Describe your idea and create the trail here, or start it in your agent's chat. Scout frames it with you, then your agents get to work."}),i.jsx("div",{className:"actions",children:i.jsx(K,{variant:"primary",onClick:e.onNewTrail,"data-tip":"Describe the idea and create the trail",children:"New trail…"})}),i.jsx(jo,{command:'/scout new "your idea"'})]}),t&&e.compact&&i.jsx(J1,{planOnly:t.map.mode==="plan-only",verifies:(t.map.verification??"off")!=="off"})]})]})}const Z1=[["home","Inbox"],["map","Map"],["ticket","Ticket"],["activity","Activity"],["plan","Plan"]];function eb(e){const{tab:t,covered:r,pending:o}=e;return i.jsx("nav",{className:"tabbar",children:Z1.map(([l,c])=>i.jsxs("button",{className:t===l&&!r?"on":"",onClick:()=>e.onPick(l),children:[c,l==="home"&&o>0&&i.jsx(ts,{n:o,urgent:!0,pop:!0},o)]},l))})}function tb(e){const t={home:e.projects?i.jsxs("div",{className:"phone-home",children:[e.projects,e.inbox]}):e.inbox,map:e.map,ticket:i.jsx(Ke,{className:"zone",children:e.ticket}),activity:i.jsx(Ke,{className:"zone",children:e.activity}),plan:e.plan};return i.jsx("main",{className:"phone-view",children:e.decisions||t[e.tab]})}const Hh={settingsPage:!0},Wh=()=>lp(new URLSearchParams(location.search).get("settings")),Kh=()=>{var e;return!!((e=history.state)!=null&&e.settingsPage)};function nb(){const[e,t]=x.useState(Wh);x.useEffect(()=>{e&&!Kh()&&(history.replaceState(null,"",mo(location.href,null)),history.pushState(Hh,"",mo(location.href,e)));const c=()=>t(Wh());return window.addEventListener("popstate",c),()=>window.removeEventListener("popstate",c)},[]);const r=c=>{const d=mo(location.href,c);e?history.replaceState(history.state,"",d):history.pushState(Hh,"",d),t(c)},o=()=>{e&&(t(null),Kh()?history.back():history.replaceState(null,"",mo(location.href,null)))},l=c=>r(lp(c??"")??{});return{route:e,open:l,show:r,close:o,toggle:()=>e?o():l()}}function sb(e,t){const{activity:r,selection:o,setSelection:l,actions:c}=e,[d,f]=x.useState("ticket"),[g,m]=x.useState("home"),[v,y]=x.useState(0),[w,j]=x.useState(null),[$,N]=x.useState(!1),E=D=>{N(!1),j({focus:D})},M=()=>{j(null),N(D=>!D)};x.useEffect(()=>{const D=r.sessions.find(q=>q.id===e.chatSession);!o&&(D!=null&&D.ticketId)&&D.mapId===e.mapId&&l({kind:"ticket",id:D.ticketId})},[e.chatSession,e.mapId]);const R=D=>{l(D),D&&(t==="laptop"&&f("ticket"),t==="mobile"&&m("ticket"))},O=(D,q,re)=>{re&&re!==e.mapId&&c.selectMap(re),c.openChat(D);const V=r.sessions.find(ge=>ge.id===D);q&&(V==null?void 0:V.mapId)===(re??e.mapId)&&l({kind:"ticket",id:q}),t==="mobile"&&(m("home"),y(ge=>ge+1))};return{sideTab:d,setSideTab:f,phoneTab:g,setPhoneTab:m,convRequest:v,decisionsView:w,setDecisionsView:j,openDecisions:E,statsOpen:$,setStatsOpen:N,toggleStats:M,select:R,openChat:O,showChat:(D,q,re)=>{O(D,q,re),y(V=>V+1)},openTicket:(D,q)=>{D!==e.mapId&&c.selectMap(D),l({kind:"ticket",id:q}),j(null),t==="laptop"&&f("ticket"),t==="mobile"&&m("ticket")}}}function ib(e,t){x.useEffect(()=>{document.title=`${ve.name}: ${e?`(${e}) `:""}${t??"No trail"}`},[e,t])}function rb(e){const[t,r]=x.useState("…");return x.useEffect(()=>{fetch(`${Se()}/list`).then(o=>o.json()).then(o=>{var c;const l=o.root.split("/").filter(Boolean);r((c=l[l.length-1])!=null&&c.startsWith(".")?l[l.length-2]??"repo":l[l.length-1]??"repo")}).catch(()=>r("repo"))},[e]),t}function ob(e,t){return x.useMemo(()=>{const r=e.sessions.filter(l=>l.mapId===t),o=new Set(e.sessions.filter(l=>l.mapId!==t).map(l=>l.id));return{...e,sessions:r,feed:e.feed.filter(l=>!l.sessionId||!o.has(l.sessionId))}},[e,t])}function ab({text:e}){return e.trim()?i.jsx("div",{className:"brief-prose",children:e.split(`
|
|
140
|
+
Where this trail ends`;return i.jsxs("g",{className:"destination",transform:`translate(${e} ${t})`,"aria-label":o,"data-tip":o,tabIndex:0,children:[i.jsx("rect",{className:"x-hit",x:-24,y:-24,width:48,height:48}),i.jsx("path",{className:"x-stroke",d:"M-15 -16 C-9 -10 2 4 16 17"}),i.jsx("path",{className:"x-stroke",d:"M17 -15 C8 -8 -6 5 -16 17"})]})}function u1({trails:e}){return e.map(t=>i.jsx("path",{className:"edge edge-open edge-destination",d:t},t))}function d1(){return i.jsxs("defs",{children:[i.jsx("pattern",{id:"map-grid",width:"40",height:"40",patternUnits:"userSpaceOnUse",children:i.jsx("path",{d:"M40 0H0V40",fill:"none",stroke:"var(--map-grid)",strokeWidth:"1"})}),i.jsx("pattern",{id:"hatch-oos",width:"10",height:"10",patternUnits:"userSpaceOnUse",patternTransform:"rotate(45)",children:i.jsx("line",{x1:"0",y1:"0",x2:"0",y2:"10",stroke:"var(--line2)",strokeWidth:"1"})})]})}const $o=(e,t)=>`${e}>${t}`;function f1(e,t,r=[]){const o=new Map(e.tickets.map(c=>[c.id,c]));return{tickets:t.nodes.map(c=>{const d=o.get(c.id);return d?{...d,blockedBy:[...c.blockedBy,...c.removedEdges??[]]}:{id:c.id,key:"+",title:c.title,type:c.type,body:"",state:"open",blockedBy:c.blockedBy,comments:[],createdAt:e.map.updatedAt,updatedAt:e.map.updatedAt}}),marks:new Map(t.nodes.map(c=>[c.id,c.mark])),newEdges:new Set(t.nodes.flatMap(c=>c.newEdges.map(d=>$o(d,c.id)))),removedEdges:new Set(t.nodes.flatMap(c=>(c.removedEdges??[]).map(d=>$o(d,c.id)))),frozen:new Set(r)}}function h1(e,t){const r=Bk({...e,tickets:t}),o=new Set;for(let l=1;l<r.length;l++)o.add($o(r[l-1].id,r[l].id));return o}const Ph={LR:130,TB:68};function m1(e){const{direction:t,from:r,to:o,cards:l}=e;if(t==="LR"){const f={x:r.x+Ue,y:r.y+Ge/2},g={x:o.x,y:o.y+Ge/2};return Co({direction:t,a:f,b:g,obstacles:l,gap:Ph.LR})}const c={x:r.x+Ue/2,y:r.y+Ge},d={x:o.x+Ue/2,y:o.y};return Co({direction:t,a:c,b:d,obstacles:l,gap:Ph.TB})}function p1(e){const{from:t,to:r,direction:o}=e,c=["edge",t.ticket.state!=="open"?"edge-done":"edge-open"];return e.critical&&c.push("edge-critical"),e.added&&c.push("edge-added"),e.removed&&c.push("edge-removed"),i.jsx("path",{className:c.join(" "),d:m1({direction:o,from:t,to:r,cards:e.cards})})}function g1(e){const{snap:t,tickets:r,direction:o,preview:l}=e,c=x.useMemo(()=>h1(t,r),[t,r]),d=x.useMemo(()=>Sp(e.nodes),[e.nodes]);return e.edges.map(({from:f,to:g})=>{const m=$o(f.ticket.id,g.ticket.id);return i.jsx(p1,{from:f,to:g,direction:o,cards:d,critical:c.has(m),added:l==null?void 0:l.newEdges.has(m),removed:l==null?void 0:l.removedEdges.has(m)},m)})}const Pc=24,v1=13,k1=9.5;function y1(e){const t=e.guide;return i.jsx("g",{className:"meta",transform:`translate(${Pc} ${e.y})`,children:e.chips.map((r,o)=>{const l=r.kind==="guide"?t:void 0;return i.jsxs("g",{className:We("card-chip",r.kind,r.kind==="state"&&e.tone,(l==null?void 0:l.off)&&"off"),"data-guide-id":l==null?void 0:l.id,transform:`translate(${r.x} 0)`,children:[l&&i.jsx("title",{children:l.tip}),i.jsx("rect",{width:r.w,height:v1,rx:3}),i.jsx("text",{x:(r.w-r.textW)/2,y:k1,textLength:r.textW,lengthAdjust:"spacingAndGlyphs",children:r.text})]},o)})})}const bp=5,x1={sans:"9.5px 'Figtree Variable', system-ui, sans-serif",mono:"8.55px 'JetBrains Mono Variable', ui-monospace, monospace"};let Oi;function w1(){if(Oi!==void 0)return Oi;try{Oi=typeof document>"u"?null:document.createElement("canvas").getContext("2d")}catch{Oi=null}return Oi}function j1(e,t="sans"){const r=w1();return r?(r.font=x1[t],r.measureText(e).width*1.04):e.length*bp}const _h=4,Dh=3,N1=6;function S1(e){var y;const t=Ue-Pc-8-(e.reserve??0),r=((y=e.state)==null?void 0:y.split(" · "))??[],o=[{kind:"key",text:e.key},{kind:"type",text:e.type},...e.guide===void 0?[]:[{kind:"guide",text:e.guide}],...r.map(w=>({kind:"state",text:w})),...e.needsYou?[{kind:"needs",text:"needs you"}]:[]],l=t-o.length*2*_h-(o.length-1)*Dh,c=w=>j1(w.text,w.kind==="key"?"mono":"sans"),d=o.filter(w=>w.kind!=="guide").reduce((w,j)=>w+c(j),0),f=Math.max(N1,Math.floor((l-d)/bp)),g=o.map(w=>w.kind==="guide"?{...w,text:AN(w.text,f)}:w),m=Math.min(1,l/g.reduce((w,j)=>w+c(j),0));let v=0;return g.map(w=>{const j=c(w)*m,$={...w,x:v,w:j+2*_h,textW:j};return v+=$.w+Dh,$})}function b1(e,t,r){const o=e.state==="frontier"||e.state==="rework";if(!(!t||r||e.ticket.assignee||!o))return t}function C1(e){const t=["node",`st-${e.n.state}`,`tone-${e.tone}`,e.hitl?"hitl":"afk"];return e.selected&&t.push("sel"),e.live&&t.push("live"),e.waiting&&t.push("waiting"),e.stalled&&!e.waiting&&t.push("stalled"),e.mark&&t.push(`mark-${e.mark}`),e.frozen&&t.push("frozen"),t.join(" ")}function $1({wait:e,session:t}){return e?i.jsx("title",{children:`Needs a ${e} model: no connected agent runs one`}):t?i.jsx("title",{children:`${t.agent} · step ${t.step}/${t.total} · ${t.stepLabel.toLowerCase()}`}):null}const T1={claimed:"working",verifying:"working",frontier:"ready",blocked:"backlog",parked:"backlog",decided:"done","out-of-scope":"cancelled",rework:"attention",held:"attention"};function E1(e){const t=T1[e.state];return t==="done"||t==="cancelled"?t:e.attention?"attention":e.live?"working":t}function I1({mark:e,frozen:t}){const r=e&&e!=="unchanged"&&e!=="cancelled"?e:void 0;return i.jsxs(i.Fragment,{children:[e==="cancelled"&&i.jsx("line",{className:"strike",x1:8,y1:Ge/2,x2:Ue-8,y2:Ge/2}),r&&i.jsx("text",{className:"reroute-tag",x:Ue-8,y:Ge-7,textAnchor:"end",children:r}),t&&i.jsx("text",{className:"freeze",x:Ue-(r?58:8),y:Ge-7,textAnchor:"end",children:"❄"})]})}function M1(e){const{n:t,session:r}=e,o=t.ticket.assignee;return e.waiting?{text:"waiting on you",tone:"urgent"}:e.stalled?{text:`stalled · ${o}`,tone:"warn"}:e.wait?{text:`needs ${e.wait}`,tone:"warn"}:r&&e.step?{text:`${r.agent} · step ${r.step}/${r.total}`,tone:"agent"}:r?{text:r.agent,tone:"agent"}:t.state==="claimed"?{text:o??"working",tone:"agent"}:{text:qx[t.state],tone:""}}function A1({tone:e,cy:t}){return e==="done"?i.jsx("path",{className:"dot dot-done",d:`M10 ${t}l2.5 2.5 4.5 -5`}):i.jsx("circle",{className:`dot dot-${e}`,cx:13,cy:t,r:e==="backlog"?3:3.5})}function L1(e,t,r=2){const o=e.split(/\s+/),l=[];let c="";for(const d of o)(c+" "+d).trim().length>t?(l.push(c.trim()),c=d):c+=" "+d;if(l.push(c.trim()),l.length>r){const d=l.slice(0,r);return d[r-1]=d[r-1].slice(0,t-1)+"…",d}return l}const R1=26;function O1({n:e,session:t,stalled:r,flag:o,selected:l,onSelect:c,mark:d,frozen:f,needs:g}){const m=e.ticket,v=L1(m.title,R1),y=Wi(m)==="hitl",w=!!(t!=null&&t.waitingOn),j=!!d&&d!=="unchanged",$=b1(e,g,!!t),N=tS(m.guide),E=j?void 0:M1({n:e,session:t,waiting:w,stalled:r,wait:$,step:!N}),M=y&&!j&&(m.type==="task"||m.type==="execute"),R=w||!!r||!!$||M&&e.state==="frontier",O=E1({state:e.state,live:!!t,attention:R}),X=zi[m.type],se=(j&&d!=="cancelled"?44:0)+(f?12:0),Q=S1({key:m.key,type:X,guide:N==null?void 0:N.name,state:E==null?void 0:E.text,needsYou:M,reserve:se}),F=v.length>1?19:24;return i.jsxs("g",{className:C1({n:e,tone:O,hitl:y,selected:l,live:!!t,waiting:w,stalled:r,mark:d,frozen:f}),style:{transform:`translate(${e.x}px, ${e.y}px)`},onClick:ie=>{ie.stopPropagation(),c({kind:"ticket",id:m.id})},children:[i.jsx($1,{wait:$,session:t}),i.jsx("rect",{className:"ring",x:-3.5,y:-3.5,width:Ue+7,height:Ge+7,rx:9}),i.jsx("rect",{className:"card",x:.5,y:.5,width:Ue-1,height:Ge-1,rx:6}),i.jsx(A1,{tone:O,cy:F-4}),v.map((ie,V)=>i.jsx("text",{className:"title",x:Pc,y:F+V*14,children:ie},V)),i.jsx(y1,{chips:Q,y:F+v.length*14-8,tone:E==null?void 0:E.tone,guide:N}),o&&i.jsx("circle",{className:`pr-flag-dot ${o}`,cx:Ue-2,cy:2,r:4}),i.jsx(I1,{mark:d,frozen:f})]})}const Bh=.72;function P1(e){const{fit:t,nodes:r,size:o,pad:l}=e;if(t.k>=Bh)return t;const c=r.find(f=>f.state==="claimed")??r.find(f=>f.state==="frontier")??r[0];if(!c)return t;const d=Bh;return{k:d,x:o.w/2-(c.x+l+Ue/2)*d,y:o.h/2-(c.y+l+Ge/2)*d}}function _1(e){const{y:t,width:r,height:o}=e,l=e.nodes.filter(c=>c.state==="out-of-scope").length;return l?i.jsxs("g",{className:"quarantine",children:[i.jsx("rect",{x:-20,y:t-30,width:r+40,height:o+18,fill:"url(#hatch-oos)"}),i.jsx("line",{x1:-20,y1:t-30,x2:r+20,y2:t-30}),i.jsxs("text",{x:-12,y:t-12,children:["Out of scope · ",l]})]}):null}const tt=280,zh=4,D1=220,Ls=e=>Math.round(e/zh)*zh;function B1(e){let t=2166136261;for(const r of e)t=Math.imul(t^r.charCodeAt(0),16777619);return()=>{t=t+1831565813|0;let r=Math.imul(t^t>>>15,1|t);return r=r+Math.imul(r^r>>>7,61|r)^r,((r^r>>>14)>>>0)/4294967296}}function Gl(e,t,r,o){return Array.from({length:6},()=>{const l=o*(.5+e()*.7),c=o*(.3+e()*.4);return{x:Ls(t+(e()-.5)*o*.8-l/2),y:Ls(r+(e()-.5)*o*.5-c/2),w:Ls(l),h:Ls(c)}})}function z1(e){const{width:t,height:r,nodes:o}=e,l=B1(e.seed),c=(w,j)=>w+l()*(j-w),d=(w,j)=>!o.some($=>w>$.x-52&&w<$.x+Ue+28&&j>$.y-52&&j<$.y+Ge+28),f=(t+tt*2)*(r+tt*2),g=Array.from({length:Math.round(f/9e4)},()=>Gl(l,c(-tt,t+tt),c(-tt,r+tt),c(160,360))).flat(),m=[...Gl(l,t+tt*.55,r+tt*.55,300),...Gl(l,-tt*.5,-tt*.45,220)],v=[],y=(w,j,$)=>{v.length<D1&&d(j,$)&&v.push({sprite:w,x:Ls(j),y:Ls($)})};for(let w=0;w<Math.round(f/3e4);w++){const j=c(-tt,t+tt),$=c(-tt,r+tt),N=3+Math.floor(l()*5);for(let E=0;E<N;E++)y(l()<.65?"pine":"oak",j+c(-70,70),$+c(-44,44))}for(let w=0;w<Math.round(f/45e3);w++)y(l()<.4?"rock":"tuft",c(-tt,t+tt),c(-tt,r+tt));return v.sort((w,j)=>w.y-j.y),{grass:g,water:m,items:v}}const Cp={pine:i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"16",y:"30",width:"4",height:"10",fill:"var(--map-trunk)"}),i.jsx("path",{d:"M18 0l9 12h-4l8 10h-4l9 11H0l9-11H5l8-10H9z",fill:"var(--map-pine)"}),i.jsx("path",{d:"M18 0l9 12h-4l8 10h-4l9 11H18z",fill:"var(--map-pine2)"})]}),oak:i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"16",y:"24",width:"4",height:"12",fill:"var(--map-trunk)"}),i.jsx("circle",{cx:"18",cy:"14",r:"14",fill:"var(--map-oak)"}),i.jsx("circle",{cx:"10",cy:"17",r:"8",fill:"var(--map-oak)"}),i.jsx("circle",{cx:"26",cy:"17",r:"8",fill:"var(--map-oak)"}),i.jsx("circle",{cx:"22",cy:"10",r:"6",fill:"var(--map-oak2)"})]}),rock:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M1 16Q2 6 10 3Q18-1 23 6Q28 11 27 16z",fill:"var(--map-rock)"}),i.jsx("path",{d:"M15 16Q15 8 19 4Q25 8 27 16z",fill:"var(--map-rock2)"})]}),tuft:i.jsx("path",{d:"M4 8Q3 4 1 1M14 8Q14 3 14 0M24 8Q25 4 27 1",fill:"none",stroke:"var(--map-pine2)",strokeWidth:"2.5",strokeLinecap:"round"})};function F1({name:e}){return i.jsx("symbol",{id:`terrain-${e}`,overflow:"visible",children:Cp[e]})}const U1=Object.keys(Cp),H1=x.memo(function(t){const{seed:r,width:o,height:l,nodes:c}=t,d=x.useMemo(()=>z1({seed:r,width:o,height:l,nodes:c}),[r,o,l,c]);return i.jsxs("g",{className:"terrain","aria-hidden":"true",children:[i.jsx("defs",{children:U1.map(f=>i.jsx(F1,{name:f},f))}),d.grass.map((f,g)=>i.jsx("rect",{x:f.x,y:f.y,width:f.w,height:f.h,fill:"var(--map-grass)"},g)),d.water.map((f,g)=>i.jsx("rect",{x:f.x,y:f.y,width:f.w,height:f.h,fill:"var(--map-water)"},g)),i.jsx("rect",{x:-4e3,y:-4e3,width:o+8e3,height:l+8e3,fill:"url(#map-grid)"}),d.items.map((f,g)=>i.jsx("use",{href:`#terrain-${f.sprite}`,x:f.x,y:f.y},g))]})}),W1=380;function K1(e){const{selId:t,size:r}=e,o=x.useRef(e);o.current=e;const l=x.useRef(!0);x.useEffect(()=>{if(l.current){l.current=!1;return}const{nodes:c,pad:d,view:f,setView:g,onFocus:m}=o.current,v=t?c.find(M=>M.ticket.id===t):void 0;if(!v||!r.w)return;m();const y=Math.min(1.4,Math.max(f.k,1.05)),w={k:y,x:r.w/2-(d+v.x+Ue/2)*y,y:r.h/2-(d+v.y+Ge/2)*y};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return g(w);const j=f,$=performance.now();let N=0;const E=M=>{const R=Math.min(1,(M-$)/W1),O=1-(1-R)**3;g({k:j.k+(w.k-j.k)*O,x:j.x+(w.x-j.x)*O,y:j.y+(w.y-j.y)*O}),R<1&&(N=requestAnimationFrame(E))};return N=requestAnimationFrame(E),()=>cancelAnimationFrame(N)},[t])}function V1(e,t){const r=x.useRef(t);r.current=t,x.useEffect(()=>{const o=e.current;if(!o)return;const l=m=>{const v=o.getBoundingClientRect();return{x:m.clientX-v.left,y:m.clientY-v.top}},c=m=>{m.preventDefault();const v=m.ctrlKey?.01:.0015;r.current(Math.exp(-m.deltaY*v),l(m))};let d=1;const f=m=>{m.preventDefault(),d=1},g=m=>{m.preventDefault();const v=m;r.current(v.scale/d,l(v)),d=v.scale};return o.addEventListener("wheel",c,{passive:!1}),o.addEventListener("gesturestart",f,{passive:!1}),o.addEventListener("gesturechange",g,{passive:!1}),()=>{o.removeEventListener("wheel",c),o.removeEventListener("gesturestart",f),o.removeEventListener("gesturechange",g)}},[e])}function Fh(e,t,r){const o=Math.min(3,Math.max(.2,t));return{k:o,x:r.x-(r.x-e.x)*o/e.k,y:r.y-(r.y-e.y)*o/e.k}}const Yt=32,G1=1.8;function Q1(e){var te;const{snap:t,selection:r,onSelect:o,preview:l}=e,c=(l==null?void 0:l.tickets)??t.tickets,d=x.useRef(null),[f,g]=x.useState({w:0,h:0});x.useEffect(()=>{const P=d.current;if(!P)return;const Y=new ResizeObserver(([ae])=>g({w:ae.contentRect.width,h:ae.contentRect.height}));return Y.observe(P),()=>Y.disconnect()},[]);const m=x.useMemo(()=>{const P=Ff(c,"LR",t.map.mode),Y=Ff(c,"TB",t.map.mode),ae=Z=>Math.min(f.w/(Z.width+Yt*2),f.h/(Z.height+Yt*2+16));return ae(P)*G1>=ae(Y)?P:Y},[c,t.map.mode,f.w,f.h]),v=(P,Y)=>Math.min(1.25,Math.max(e.minFit??0,Math.min(f.w/P,f.h/Y))),y=x.useMemo(()=>{const P=m.width+Yt*2,Y=m.height+Yt*2+16,Z=m.nodes.some(D=>D.state==="out-of-scope")&&f.h?Math.max(0,f.h/v(P,Y)-Y):0;if(!Z)return{...m,slack:Z};const U=new Map(m.nodes.map(D=>[D,{...D,y:D.y+(D.state==="out-of-scope"?Z:Z/2)}]));return{...m,slack:Z,nodes:[...U.values()],edges:m.edges.map(D=>({from:U.get(D.from),to:U.get(D.to)})),quarantineY:m.quarantineY+Z,height:m.height+Z}},[m,f.w,f.h,e.minFit]),w=a1(y),j=w.right+Yt*2,$=w.bottom+Yt*2+16,N=()=>{const P=v(j,$);return{k:P,x:Math.max(0,(f.w-j*P)/2),y:Math.max(0,(f.h-$*P)/2)}},[E,M]=x.useState({k:1,x:0,y:0}),R=x.useRef(!1);x.useEffect(()=>{R.current=!1},[t.map.id]),x.useEffect(()=>{!R.current&&f.w&&M(P1({fit:N(),nodes:y.nodes,size:f,pad:Yt}))},[f.w,f.h,j,$,t.map.id]);const O=x.useRef(new Map),X=x.useRef(null),se=P=>{const Y=d.current.getBoundingClientRect();return{x:P.clientX-Y.left,y:P.clientY-Y.top}},Q=()=>{var Z;const P=[...O.current.values()],Y=P.length>1?{x:(P[0].x+P[1].x)/2,y:(P[0].y+P[1].y)/2}:P[0],ae=P.length>1?Math.hypot(P[0].x-P[1].x,P[0].y-P[1].y):0;X.current={view:E,dist:ae,mid:Y,moved:((Z=X.current)==null?void 0:Z.moved)??!1}};V1(d,(P,Y)=>{R.current=!0,M(ae=>Fh(ae,ae.k*P,Y))});const F=sn(5e3),ie=xc(e.leases,t.map.id),V=Cc(),ge=(te=Oc())==null?void 0:te.waiting,Re=new Map(e.sessions.filter(P=>tn(P)&&P.ticketId).map(P=>[P.ticketId,P])),be=(r==null?void 0:r.kind)==="ticket"?r.id:void 0;return K1({selId:be,nodes:y.nodes,size:f,pad:Yt,view:E,setView:M,onFocus:()=>R.current=!0}),i.jsxs("div",{className:"graph-box",ref:d,onPointerDown:P=>{O.current.set(P.pointerId,se(P)),O.current.size===1&&(X.current=null),Q()},onPointerMove:P=>{var Z;if(!O.current.has(P.pointerId)||!X.current)return;O.current.set(P.pointerId,se(P));const Y=X.current,ae=[...O.current.values()];if(ae.length>1){const U={x:(ae[0].x+ae[1].x)/2,y:(ae[0].y+ae[1].y)/2},D=Math.hypot(ae[0].x-ae[1].x,ae[0].y-ae[1].y),H=Fh(Y.view,Y.view.k*D/(Y.dist||D),Y.mid);M({...H,x:H.x+U.x-Y.mid.x,y:H.y+U.y-Y.mid.y}),Y.moved=!0}else{const U=ae[0].x-Y.mid.x,D=ae[0].y-Y.mid.y;if(!Y.moved&&Math.hypot(U,D)<5)return;Y.moved||(Z=d.current)==null||Z.setPointerCapture(P.pointerId),Y.moved=!0,M({...Y.view,x:Y.view.x+U,y:Y.view.y+D})}R.current=!0},onPointerUp:P=>{O.current.delete(P.pointerId),O.current.size&&Q()},onPointerCancel:P=>O.current.delete(P.pointerId),onClickCapture:P=>{var Y;(Y=X.current)!=null&&Y.moved&&(P.stopPropagation(),X.current=null)},children:[i.jsxs("svg",{className:"graph",width:f.w,height:f.h,onClick:()=>o(null),children:[i.jsx(d1,{}),i.jsx("g",{transform:`translate(${E.x} ${E.y}) scale(${E.k})`,children:i.jsxs("g",{transform:`translate(${Yt} ${Yt})`,children:[i.jsx(H1,{seed:t.map.id,width:j,height:$,nodes:y.nodes}),i.jsx(_1,{y:y.quarantineY,width:y.width,height:y.quarantineH,nodes:y.nodes}),i.jsx(g1,{snap:t,tickets:c,direction:y.direction,nodes:y.nodes,edges:y.edges,preview:l}),i.jsx(u1,{trails:l1(y,w)}),y.nodes.length>0&&i.jsx(c1,{x:w.x,y:w.y,text:t.map.sections.destination}),y.nodes.map(P=>{var Y;return i.jsx(O1,{n:P,session:Re.get(P.ticket.id),stalled:!!ie.get(P.ticket.id)&&Po(ie.get(P.ticket.id),F)!=="live",flag:Yx(Bs.ticket(V,t.map.id,P.ticket.id)),selected:be===P.ticket.id,onSelect:o,mark:l==null?void 0:l.marks.get(P.ticket.id),frozen:l==null?void 0:l.frozen.has(P.ticket.id),needs:(Y=ge==null?void 0:ge.find(ae=>ae.mapId===t.map.id&&ae.ticketId===P.ticket.id))==null?void 0:Y.tier},P.ticket.id)})]})})]}),i.jsx("button",{className:"btn sm fit-btn","data-tip":"Fit the whole trail in view",onPointerDown:P=>P.stopPropagation(),onClick:P=>{P.stopPropagation(),R.current=!0,M(N())},children:"Fit"})]})}const Ql=[["decided","Done"],["claimed","Working"],["frontier","Ready"],["blocked","Backlog"],["parked","Parked"],["out-of-scope","Cancelled"]],Uh=[["verifying","Verifying"],["rework","Rework"],["held","Blocked"]];function q1({snap:e,sessions:t}){const r=um(e),o=m=>r[m],l=t.filter(_m).length,c=zk(e),d=Math.max(1,...c.map(m=>m.open+m.closed)),g=(e.map.verification??"off")!=="off"||Uh.some(([m])=>o(m))?[...Ql.slice(0,2),...Uh,...Ql.slice(2)]:Ql;return i.jsxs("div",{className:"status-panel",children:[i.jsxs("div",{className:"sp-col sp-status",children:[i.jsxs("div",{className:"sp-head",children:[i.jsx(Je,{as:"h3",children:"Status"}),i.jsxs("span",{className:"t-meta",children:[r.total," tickets"]})]}),i.jsxs("ul",{children:[g.map(([m,v])=>i.jsxs("li",{className:`st-${m} ${o(m)?"":"zero"}`,children:[i.jsx("i",{}),i.jsx("span",{children:v}),i.jsx("b",{children:o(m)})]},m)),i.jsxs("li",{className:`st-waiting ${l?"":"zero"}`,children:[i.jsx("i",{}),i.jsx("span",{children:"Waiting on you"}),i.jsx("b",{children:l})]})]})]}),i.jsxs("div",{className:"sp-block sp-col",children:[i.jsx("span",{className:"t-label",children:"Type mix"}),i.jsx("ul",{className:"mix",children:c.map(m=>i.jsxs("li",{title:`${m.type}: ${m.closed} closed, ${m.open} open`,children:[i.jsx("span",{className:"t-meta",children:zi[m.type]}),i.jsxs("span",{className:"mix-bar",children:[i.jsx("i",{className:"closed",style:{width:`${m.closed/d*100}%`}}),i.jsx("i",{className:"open",style:{width:`${m.open/d*100}%`}})]}),i.jsx("b",{children:m.open+m.closed})]},m.type))})]})]})}function Y1(e){const[t,r]=x.useState(!1);return i.jsxs("div",{className:t?"status-drawer open":"status-drawer",children:[i.jsxs("button",{type:"button",className:"status-toggle","aria-expanded":t,onPointerDown:o=>o.stopPropagation(),onClick:()=>r(!t),children:["Summary ",i.jsx("span",{className:"caret",children:t?"▾":"▴"})]}),i.jsx(q1,{snap:e.snap,sessions:e.sessions})]})}function J1({planOnly:e,verifies:t}){const r=[["frontier","Ready"],["claimed","Working"],...t?[["verifying","Verifying"],["rework","Rework"],["held","Blocked"]]:[],["stalled","Stalled"],["blocked","Backlog"],["decided","Done"],...e?[["parked","Parked"]]:[],["out-of-scope","Cancelled"],["waiting","Waiting on you"]];return i.jsxs("div",{className:"legend",children:[r.map(([o,l])=>i.jsxs("span",{className:`lg st-${o}`,children:[i.jsx("i",{}),l]},o)),i.jsx("span",{className:"lg hitl",children:"● needs human"})]})}function X1(e){var o,l;const{snap:t,selection:r}=e.api;return i.jsxs(Ke,{as:"main",className:"zone map-zone",style:{gridArea:"map"},children:[t&&i.jsx(g0,{}),(o=e.trail)==null?void 0:o.banner,i.jsxs("div",{className:"map-area",children:[t&&!e.compact&&i.jsx(Y1,{snap:t,sessions:e.sessions}),t?i.jsx(Q1,{snap:t,sessions:e.sessions,leases:e.api.leases,selection:r,onSelect:e.onSelect,minFit:e.minFit,preview:(l=e.trail)==null?void 0:l.preview}):i.jsxs("div",{className:"nomap",children:[i.jsx(x0,{}),i.jsx("h2",{children:"No trail"}),i.jsx("p",{className:"nomap-lede",children:"Describe your idea and create the trail here, or start it in your agent's chat. Scout frames it with you, then your agents get to work."}),i.jsx("div",{className:"actions",children:i.jsx(K,{variant:"primary",onClick:e.onNewTrail,"data-tip":"Describe the idea and create the trail",children:"New trail…"})}),i.jsx(jo,{command:'/scout new "your idea"'})]}),t&&e.compact&&i.jsx(J1,{planOnly:t.map.mode==="plan-only",verifies:(t.map.verification??"off")!=="off"})]})]})}const Z1=[["home","Inbox"],["map","Map"],["ticket","Ticket"],["activity","Activity"],["plan","Plan"]];function eb(e){const{tab:t,covered:r,pending:o}=e;return i.jsx("nav",{className:"tabbar",children:Z1.map(([l,c])=>i.jsxs("button",{className:t===l&&!r?"on":"",onClick:()=>e.onPick(l),children:[c,l==="home"&&o>0&&i.jsx(ts,{n:o,urgent:!0,pop:!0},o)]},l))})}function tb(e){const t={home:e.projects?i.jsxs("div",{className:"phone-home",children:[e.projects,e.inbox]}):e.inbox,map:e.map,ticket:i.jsx(Ke,{className:"zone",children:e.ticket}),activity:i.jsx(Ke,{className:"zone",children:e.activity}),plan:e.plan};return i.jsx("main",{className:"phone-view",children:e.decisions||t[e.tab]})}const Hh={settingsPage:!0},Wh=()=>lp(new URLSearchParams(location.search).get("settings")),Kh=()=>{var e;return!!((e=history.state)!=null&&e.settingsPage)};function nb(){const[e,t]=x.useState(Wh);x.useEffect(()=>{e&&!Kh()&&(history.replaceState(null,"",mo(location.href,null)),history.pushState(Hh,"",mo(location.href,e)));const c=()=>t(Wh());return window.addEventListener("popstate",c),()=>window.removeEventListener("popstate",c)},[]);const r=c=>{const d=mo(location.href,c);e?history.replaceState(history.state,"",d):history.pushState(Hh,"",d),t(c)},o=()=>{e&&(t(null),Kh()?history.back():history.replaceState(null,"",mo(location.href,null)))},l=c=>r(lp(c??"")??{});return{route:e,open:l,show:r,close:o,toggle:()=>e?o():l()}}function sb(e,t){const{activity:r,selection:o,setSelection:l,actions:c}=e,[d,f]=x.useState("ticket"),[g,m]=x.useState("home"),[v,y]=x.useState(0),[w,j]=x.useState(null),[$,N]=x.useState(!1),E=Q=>{N(!1),j({focus:Q})},M=()=>{j(null),N(Q=>!Q)};x.useEffect(()=>{const Q=r.sessions.find(F=>F.id===e.chatSession);!o&&(Q!=null&&Q.ticketId)&&Q.mapId===e.mapId&&l({kind:"ticket",id:Q.ticketId})},[e.chatSession,e.mapId]);const R=Q=>{l(Q),Q&&(t==="laptop"&&f("ticket"),t==="mobile"&&m("ticket"))},O=(Q,F,ie)=>{ie&&ie!==e.mapId&&c.selectMap(ie),c.openChat(Q);const V=r.sessions.find(ge=>ge.id===Q);F&&(V==null?void 0:V.mapId)===(ie??e.mapId)&&l({kind:"ticket",id:F}),t==="mobile"&&(m("home"),y(ge=>ge+1))};return{sideTab:d,setSideTab:f,phoneTab:g,setPhoneTab:m,convRequest:v,decisionsView:w,setDecisionsView:j,openDecisions:E,statsOpen:$,setStatsOpen:N,toggleStats:M,select:R,openChat:O,showChat:(Q,F,ie)=>{O(Q,F,ie),y(V=>V+1)},openTicket:(Q,F)=>{Q!==e.mapId&&c.selectMap(Q),l({kind:"ticket",id:F}),j(null),t==="laptop"&&f("ticket"),t==="mobile"&&m("ticket")}}}function ib(e,t){x.useEffect(()=>{document.title=`${ve.name}: ${e?`(${e}) `:""}${t??"No trail"}`},[e,t])}function rb(e){const[t,r]=x.useState("…");return x.useEffect(()=>{fetch(`${Se()}/list`).then(o=>o.json()).then(o=>{var c;const l=o.root.split("/").filter(Boolean);r((c=l[l.length-1])!=null&&c.startsWith(".")?l[l.length-2]??"repo":l[l.length-1]??"repo")}).catch(()=>r("repo"))},[e]),t}function ob(e,t){return x.useMemo(()=>{const r=e.sessions.filter(l=>l.mapId===t),o=new Set(e.sessions.filter(l=>l.mapId!==t).map(l=>l.id));return{...e,sessions:r,feed:e.feed.filter(l=>!l.sessionId||!o.has(l.sessionId))}},[e,t])}function ab({text:e}){return e.trim()?i.jsx("div",{className:"brief-prose",children:e.split(`
|
|
141
141
|
`).map((t,r)=>i.jsx("p",{children:t.split(/(`[^`]+`|\/?\b[\w.-]+\/[\w./-]+\b)/g).map((o,l)=>l%2===1?i.jsx("code",{children:o.replace(/`/g,"")},l):o)},r))}):i.jsx(Ee,{children:"Not covered"})}const Vh=["summary","productContext","existing","conventions","dataModel","api","risks"];function lb(e){const{brief:t}=e,[r,o]=x.useState(!1),[l,c]=x.useState("");x.useEffect(()=>{const m=v=>v.key==="Escape"&&e.onClose();return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[e]);const d=t.sections,f=Vh.filter(m=>d[m].trim()),g=Vh.filter(m=>!d[m].trim());return i.jsx("div",{className:"scrim",onClick:e.onClose,children:i.jsxs(Ke,{as:"div",className:"dialog brief-dialog",onClick:m=>m.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:"Discovery brief"}),i.jsx("span",{className:"t-meta",children:cb(t)})]}),i.jsxs("div",{className:"brief-body",children:[f.map(m=>i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:Li[m]}),i.jsx(ab,{text:d[m]}),(m==="conventions"||m==="productContext")&&d[m].trim()&&i.jsx($c,{draft:()=>({title:`${Li[m]}: ${d[m].split(`
|
|
142
|
-
`)[0].slice(0,80)}`,body:d[m],kind:m==="conventions"?"convention":"business-rule",sources:[`brief:${t.mapId}`]})})]},m)),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:Li.assumptions}),d.assumptions.length?i.jsx("ul",{className:"item-list",children:d.assumptions.map(m=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:m.text}),i.jsx(
|
|
142
|
+
`)[0].slice(0,80)}`,body:d[m],kind:m==="conventions"?"convention":"business-rule",sources:[`brief:${t.mapId}`]})})]},m)),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:Li.assumptions}),d.assumptions.length?i.jsx("ul",{className:"item-list",children:d.assumptions.map(m=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:m.text}),i.jsx(q,{parts:[{text:m.id,code:!0}]})]},m.id))}):i.jsx(Ee,{children:"None listed"})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:Li.openQuestions}),d.openQuestions.length?i.jsx("ul",{className:"brief-list",children:d.openQuestions.map(m=>i.jsx("li",{children:m},m))}):i.jsx(Ee,{children:"None"})]}),g.length>0&&i.jsxs("p",{className:"t-meta brief-empty",children:["Nothing noted on ",g.map(m=>Li[m].toLowerCase()).join(", "),"."]}),t.note&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Your last request"}),i.jsx("p",{children:t.note})]})]}),r&&i.jsx(Ye,{label:"What should change?",children:i.jsx("textarea",{rows:3,value:l,onChange:m=>c(m.target.value),autoFocus:!0})}),e.error&&i.jsx("p",{className:"urgent-text",children:e.error}),i.jsxs("div",{className:"actions",children:[t.status==="submitted"&&!r&&i.jsxs(i.Fragment,{children:[i.jsx(K,{onClick:()=>o(!0),children:"Request changes"}),i.jsx(K,{variant:"primary",onClick:e.onAccept,children:"Accept brief"})]}),r&&i.jsxs(i.Fragment,{children:[i.jsx(K,{variant:"ghost",onClick:()=>o(!1),children:"Back"}),i.jsx(K,{variant:"primary",disabled:!l.trim(),onClick:()=>e.onRequestChanges(l.trim()),children:"Send to the agent"})]}),i.jsx(K,{variant:"ghost",onClick:e.onClose,children:"Close"})]})]})})}function cb(e){if(e.status==="draft")return"Not submitted yet";const t=[e.status.replace("-"," ")];return e.author&&t.push(`by ${e.author}`),e.submittedAt&&t.push(`${nn(Date.now()-e.submittedAt)} ago`),t.join(" · ")}function ub({brief:e,onReview:t}){return e.status!=="submitted"?null:i.jsx("div",{className:"brief-card",children:i.jsx(Ae,{edge:"attention",title:"Discovery brief ready for your review",context:i.jsx(q,{parts:["Discovery brief",e.author&&`by ${e.author}`]}),detail:e.sections.summary.split(`
|
|
143
143
|
`)[0],detailText:e.sections.summary,onOpen:t})})}const db={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 fb({brief:e,onReview:t}){if(e.status==="accepted")return null;const[r,o]=db[e.status],l=e.status==="submitted"?"edge-attention":"edge-neutral";return i.jsxs("div",{className:`discovery-banner map-banner ${l} st-${e.status}`,role:"status",children:[i.jsxs("span",{className:"mb-text",children:[i.jsx("span",{className:"mb-lead",children:r}),i.jsx("span",{className:"t-meta",children:o})]}),i.jsx(Us,{text:"Before implementation, an agent maps the existing system: the files involved, conventions, data and API impact, risks and assumptions. You accept the brief or ask for changes; task, execute and prototype tickets can't be claimed until you accept it."}),i.jsx(K,{size:"sm",variant:e.status==="submitted"?"primary":"ghost",onClick:t,children:e.status==="submitted"?"Review brief":"Open brief"})]})}const Gh=`${Se()}/briefs`;function hb(e){const t=e==null?void 0:e.map.id,[r,o]=x.useState(null),[l,c]=x.useState(),d=x.useCallback(()=>{if(!t)return o(null);fetch(`${Gh}?mapId=${encodeURIComponent(t)}`).then(v=>v.ok?v.json():{brief:null}).then(v=>o(v.brief)).catch(()=>o(null))},[t]),f=e==null?void 0:e.tickets.reduce((v,y)=>Math.max(v,y.updatedAt),e.map.updatedAt);x.useEffect(d,[d,f]),x.useEffect(()=>pn(v=>v.startsWith("briefs/")&&d()),[d]);const g=(v,y)=>fetch(`${Gh}/${v}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,note:y})}).then(async w=>{const j=await w.json().catch(()=>({}));if(!w.ok||!j.brief)throw new Error(j.error??`HTTP ${w.status}`);c(void 0),o(j.brief)}),m=(v,y)=>g(v,y).then(()=>!0,w=>(c(w.message),!1));return{brief:r,error:l,accept:()=>m("accept"),requestChanges:v=>m("request-changes",v)}}function mb(e){const t=hb(e),[r,o]=x.useState(!1),l=()=>o(!0),c=t.brief,d=c==null?void 0:c.sections;return{review:l,briefText:d?[d.existing,d.conventions,d.dataModel,d.api].join(`
|
|
144
|
-
`):"",banner:c&&i.jsx(fb,{brief:c,onReview:l}),inboxCard:c&&i.jsx(ub,{brief:c,onReview:l}),dialog:c&&r&&i.jsx(lb,{brief:c,error:t.error,onAccept:()=>void t.accept().then(f=>f&&o(!1)),onRequestChanges:f=>void t.requestChanges(f).then(g=>g&&o(!1)),onClose:()=>o(!1)})}}function pb({reroute:e,onReview:t}){var f;const r=e.kind==="challenge-destination",o=((f=e.frozen)==null?void 0:f.length)??0,l=r?"wrong mountain?":"proposes a new plan",c=o?` ${o} ticket${o===1?" is":"s are"} closed until you decide.`:"",d=`${e.reason.replace(/\.$/,"")}.${c}`;return i.jsxs("div",{className:"reroute-banner map-banner edge-attention",role:"status",title:d,children:[i.jsxs("span",{className:"mb-text",children:[i.jsxs("span",{className:"mb-lead",children:[e.by," ",l]}),i.jsx("span",{className:"t-meta",children:d})]}),i.jsx(Us,{text:"An agent found that an assumption or the plan no longer holds and proposes changes. The map shows them: dashed outlines are tickets it adds, struck ones it cancels, ❄ marks tickets frozen until you approve or reject. Nothing changes until you decide."}),i.jsx(K,{size:"sm",variant:"primary",onClick:t,children:"Review"})]})}const gb={"already-exists":"The work already exists","wrong-problem":"The trail targets the wrong problem",rescope:"The trail should be rescoped"};function vb(e,t){var r;switch(e.op){case"add_ticket":{const o=(r=e.blockedBy)!=null&&r.length?`after ${e.blockedBy.map(t).join(", ")}`:void 0;return{verb:"Add",text:e.title,detail:[`new ${e.type} ticket`,o].filter(Boolean).join(" · ")}}case"cancel_ticket":return{verb:"Cancel",text:t(e.ticket),detail:e.reason};case"edit_ticket":return{verb:"Revise",text:t(e.ticket),detail:e.title?`New title: ${e.title}`:"New description"};case"rewire":return{verb:"Rewire",text:t(e.ticket),detail:kb(e,t)};case"supersede_decision":return{verb:"Supersede",text:e.decision,detail:`${e.answer}. ${e.rationale}`};case"update_destination":return{verb:"Destination",text:e.text};case"add_unspecified":return{verb:"Not yet specified",text:e.text};case"add_out_of_scope":return{verb:"Out of scope",text:e.text};case"reopen":return{verb:"Reopen",text:t(e.ticket),detail:`Back in the queue: ${e.reason}`};default:return e}}function kb(e,t){var o,l;return[...(o=e.addBlockedBy)!=null&&o.length?[`now also after ${e.addBlockedBy.map(t).join(", ")}`]:[],...(l=e.removeBlockedBy)!=null&&l.length?[`no longer after ${e.removeBlockedBy.map(t).join(", ")}`]:[]].join(" · ")}const yb=new Set(["cancel_ticket","update_destination"]);function xb({change:e,name:t}){const r=vb(e,t);return i.jsx(Ae,{as:"li",className:`reroute-change op-${e.op}`,edge:yb.has(e.op)?"attention":"neutral",title:r.text,titleText:r.text,context:i.jsx(Q,{parts:[{text:r.verb,strong:!0}]}),detail:r.detail,detailText:r.detail})}function wb(e){const{reason:t,destination:r}=e;return i.jsxs("section",{className:"reroute-destination",children:[t&&i.jsx("p",{className:"reroute-destination-why",children:gb[t]}),r&&i.jsxs("div",{className:"reroute-destination-diff",children:[i.jsxs("div",{children:[i.jsx("span",{className:"mono-label",children:"Destination now"}),i.jsx("p",{className:"before",children:r.before||"—"})]}),i.jsxs("div",{children:[i.jsx("span",{className:"mono-label",children:"Suggested destination"}),i.jsx("p",{className:"after",children:r.after})]})]})]})}function jb(e,t){const r=new Map(e.tickets.map(l=>[l.id,l.key])),o=new Map(t.flatMap(l=>l.op==="add_ticket"?[[l.ref,l.title]]:[]));return l=>{const c=r.get(l);if(c)return c;const d=o.get(l);return d?`new: ${d}`:l}}function Nb(e){var w,j;const{reroute:t,snap:r}=e,[o,l]=x.useState("");x.useEffect(()=>{const $=N=>N.key==="Escape"&&e.onClose();return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[e]);const c=jb(r,t.changes),d=new Map(r.tickets.map($=>[$.id,`${$.key} ${$.title}`])),f=$=>d.get($)??c($),g=r.map.sections.assumptions??[],m=t.invalidates.map($=>g.find(N=>N.id===$)??{id:$,text:""}),v=t.status==="pending",y=t.kind==="challenge-destination";return i.jsx("div",{className:"scrim",onClick:e.onClose,children:i.jsxs(Ke,{as:"div",className:"dialog reroute-dialog",onClick:$=>$.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:y?"Destination challenged":"Reroute proposal"}),i.jsx(Q,{parts:[{text:t.id,code:!0},t.status,`by ${t.by}`,`${nn(Date.now()-t.at)} ago`]})]}),i.jsxs("div",{className:"reroute-body",children:[y&&i.jsx(wb,{reason:t.destinationReason,destination:(w=t.diff)==null?void 0:w.destination}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Why"}),i.jsx("p",{children:t.reason})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Evidence"}),i.jsx("p",{className:"reroute-evidence",children:t.evidence})]}),m.length>0&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Assumptions it invalidates"}),i.jsx("ul",{className:"item-list",children:m.map($=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:$.text}),i.jsx(Q,{parts:[{text:$.id,code:!0}]})]},$.id))})]}),i.jsxs("section",{children:[i.jsxs("h3",{className:"mono-label",children:["Changes · ",t.changes.length]}),i.jsx("ul",{className:"reroute-changes row-list",children:t.changes.map(($,N)=>i.jsx(xb,{change:$,name:f},N))})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Closed until you decide"}),(j=t.frozen)!=null&&j.length?i.jsx("ul",{className:"item-list",children:t.frozen.map($=>i.jsx("li",{className:"item-text",children:f($)},$))}):i.jsx(Ee,{children:"No tickets closed"})]}),t.note&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Your note"}),i.jsx("p",{children:t.note})]})]}),v&&i.jsx(Ye,{label:"Note for the agent (required to reject)",children:i.jsx("textarea",{rows:2,value:o,onChange:$=>l($.target.value)})}),e.error&&i.jsx("p",{className:"urgent-text",children:e.error}),i.jsxs("div",{className:"actions",children:[v&&i.jsxs(i.Fragment,{children:[i.jsx(K,{className:"reroute-reject",disabled:!o.trim(),onClick:()=>e.onReject(o.trim()),children:"Reject"}),i.jsx(K,{className:"reroute-approve",variant:"primary",onClick:()=>e.onApprove(o.trim()),children:"Approve and apply"})]}),i.jsx(K,{variant:"ghost",onClick:e.onClose,children:"Close"})]})]})})}const Qh=`${Se()}/reroutes`;function Sb(e){const t=e==null?void 0:e.map.id,[r,o]=x.useState([]),[l,c]=x.useState(),d=x.useCallback(()=>{if(!t)return o([]);fetch(`${Qh}?map=${encodeURIComponent(t)}`).then(m=>m.ok?m.json():{reroutes:[]}).then(m=>o(m.reroutes)).catch(()=>o([]))},[t]),f=e==null?void 0:e.tickets.reduce((m,v)=>Math.max(m,v.updatedAt),e.map.updatedAt);x.useEffect(d,[d,f]),x.useEffect(()=>Zx("reroute",m=>{m.mapId===t&&d()}),[d,t]);const g=async(m,v,y)=>{var N;const w=await fetch(`${Qh}/${m}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,id:v,note:y})}),j=await w.json().catch(()=>({}));if(w.ok)return c(void 0),d(),!0;const $=(N=j.errors)==null?void 0:N.map(E=>E.message).join("; ");return c([j.error??`HTTP ${w.status}`,$].filter(Boolean).join(": ")),!1};return{reroutes:r,pending:r.find(m=>m.status==="pending"),error:l,clearError:()=>c(void 0),approve:(m,v)=>g("approve",m,v),reject:(m,v)=>g("reject",m,v)}}function bb(e,t){const r=Sb(e),[o,l]=x.useState(),c=r.reroutes.find(m=>m.id===o),d=c!=null&&c.diff?c:r.pending,f=()=>{l(void 0),r.clearError()},g=m=>m&&f();return{banner:r.pending&&i.jsx(pb,{reroute:r.pending,onReview:()=>{var m;return l((m=r.pending)==null?void 0:m.id)}}),preview:e&&(d!=null&&d.diff)?f1(e,d.diff,d.frozen):void 0,openReroute:(m,v)=>{m!==(e==null?void 0:e.map.id)&&(t==null||t(m)),l(v)},dialog:e&&c&&i.jsx(Nb,{reroute:c,snap:e,error:r.error,onApprove:m=>void r.approve(c.id,m||void 0).then(g),onReject:m=>void r.reject(c.id,m).then(g),onClose:f})}}function Cb(e,t){const r=mb(e),o=bb(e,t);return{briefText:r.briefText,inboxCard:r.inboxCard,review:r.review,banner:i.jsxs(i.Fragment,{children:[r.banner,o.banner]}),preview:o.preview,openReroute:o.openReroute,dialog:i.jsxs(i.Fragment,{children:[r.dialog,o.dialog]})}}function $b(){const e=new URL(location.href);e.searchParams.has(Ps)&&(e.searchParams.delete(Ps),history.replaceState(history.state,"",e))}function Tb(e,t){return e.kind!=="question"||t.pending.some(r=>r.id===e.ref)}function Eb(e){const[t,r]=x.useState(()=>new URLSearchParams(location.search).get(Ps)??void 0),{loaded:o,view:l,activity:c,handlers:d,showChat:f}=e;return x.useEffect(()=>{if(!t||!o||!l)return;const g=l.items.find(v=>v.id===t);if(g&&!Tb(g,c)||(r(void 0),$b(),!g))return;qm(g,{...d,openQuestion:v=>{const y=c.pending.find(w=>w.id===v);y&&f(y.sessionId,y.ticketId)}})},[t,o,l,c,d,f]),{request:x.useCallback(g=>r(g),[])}}function Ib(e){const{api:t,nav:r}=e,o=Jm(t.allSnaps);n0(o.view);const l=m=>m&&t.actions.selectMap(m),c={openTicket:r.openTicket,openKnowledge:()=>e.knowledge.setOpen(!0),openBrief:m=>m===t.mapId?e.reviewBrief():l(m),openReroute:e.openReroute??(m=>m.ticketId?r.openTicket(m.mapId,m.ticketId):l(m.mapId)),selectTrail:l,openGuides:e.openGuides},d=o.view,f=Eb({loaded:t.loaded,view:d,activity:t.activity,handlers:c,showChat:r.showChat}),g=d&&i.jsx(Xj,{view:d,onFocus:m=>void o.savePrefs(By(d.prefs,m,Date.now())),onSettings:e.openFocusSettings});return{attention:o,handlers:c,header:g,link:f}}function Mb(e){const{d:t,snap:r}=e,[o,l]=x.useState(!1),[c,d]=x.useState(""),[f,g]=x.useState("");x.useEffect(()=>{l(!1),d(""),g("")},[t.id,t.mapId]);const m=jk(e.all.filter(j=>j.mapId===t.mapId),t.id),v=Ki(t),y=t.ticketId?r==null?void 0:r.tickets.find(j=>j.id===t.ticketId):void 0,w=Date.now();return i.jsxs("div",{className:"detail dv-d",children:[i.jsxs("div",{className:"d-head",children:[i.jsx("span",{className:"key",children:t.id}),i.jsx(zn,{tone:"state",className:`dv-st-${v}`,children:v}),i.jsx(Q,{parts:[Qx(t.decidedAt),`${nn(w-t.decidedAt)} ago`]})]}),i.jsx("h3",{className:"t-heading",children:t.question}),i.jsxs("div",{className:"resolution",children:[i.jsx(wo,{parts:["Decision"]}),i.jsx("p",{children:t.answer})]}),i.jsxs("dl",{className:"facts",children:[i.jsx("dt",{children:"Trail"}),i.jsx("dd",{children:r?`${r.map.key} ${r.map.title}`:t.mapId}),i.jsx("dt",{children:"Ticket"}),i.jsx("dd",{children:t.ticketId?i.jsxs("button",{className:"link",onClick:()=>e.onOpenTicket(t.mapId,t.ticketId),children:[t.ticketKey," ",(y==null?void 0:y.title)??""," · open in trail ›"]}):"—"}),i.jsx("dt",{children:"Decided by"}),i.jsx("dd",{children:t.decidedBy}),t.participants.length>1&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Participants"}),i.jsx("dd",{children:t.participants.map(j=>j.name??j.id).join(", ")})]}),i.jsx("dt",{children:"Source"}),i.jsxs("dd",{children:[_n[t.source.kind].label,t.source.url&&i.jsxs(i.Fragment,{children:[" · ",i.jsx("a",{href:t.source.url,target:"_blank",rel:"noreferrer",children:t.source.label??"link"})]}),!t.source.url&&t.source.label&&` · ${t.source.label}`,t.source.ref&&i.jsxs("span",{className:"ref",children:[" ",t.source.ref]})]})]}),t.alternatives.length>0&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Alternatives"}),i.jsx("ul",{className:"dv-alts",children:t.alternatives.map(j=>i.jsx("li",{children:j},j))})]}),t.rationale&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Rationale"}),i.jsx("p",{children:t.rationale})]}),m.length>1&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Supersession"}),i.jsx("ol",{className:"dv-chain",children:m.map(j=>i.jsx("li",{className:`${j.id===t.id?"cur":""} ${j.supersededBy?"old":"live"}`,children:i.jsxs("button",{onClick:()=>e.onSelect(j.id),children:[i.jsx("i",{}),i.jsx("span",{className:"id",children:j.id}),i.jsx("span",{className:"a",children:j.summary}),i.jsx(Q,{parts:[j.decidedBy,Ds(j.decidedAt)]})]})},j.id))})]}),i.jsxs("div",{className:"actions",children:[i.jsx($c,{draft:()=>({title:t.summary||t.question,body:[t.answer,t.rationale&&`Why: ${t.rationale}`].filter(Boolean).join(`
|
|
145
|
-
|
|
146
|
-
`),kind:"product-decision",sources:[`decision:${t.id}`,...t.ticketKey?[`ticket:${t.ticketKey}`]:[]]})}),v==="active"&&i.jsx(K,{on:o,onClick:()=>l(j=>!j),"data-tip":"Replace this decision with a new answer. Both stay on record",children:"Supersede…"})]}),o&&i.jsxs(Ot,{as:"form",tone:"inset",className:"inline-form",onSubmit:j=>{j.preventDefault(),c.trim()&&(e.onSupersede(t,{answer:c.trim(),rationale:f.trim(),alternatives:[t.summary]}),l(!1))},children:[i.jsx(Ye,{label:"New decision",children:i.jsx("textarea",{rows:3,value:c,onChange:j=>d(j.target.value),autoFocus:!0})}),i.jsx(Ye,{label:"Rationale",children:i.jsx("input",{value:f,onChange:j=>g(j.target.value)})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(K,{variant:"ghost",onClick:()=>l(!1),children:"Cancel"}),i.jsx(K,{type:"submit",variant:"primary",disabled:!c.trim(),children:"Supersede"})]})]}),i.jsxs("div",{className:"dv-sec",children:[i.jsxs("h4",{className:"mono-label",children:["Transcript ",i.jsx("span",{className:"n",children:t.transcript.length})]}),t.transcript.length?i.jsx("div",{className:"dv-transcript comms-log",children:t.transcript.map((j,$)=>i.jsxs("div",{className:`msg from-${j.from} voice-${j.from==="human"?"human":"agent"}`,children:[i.jsx(wo,{parts:[j.author,yc(j.at)]}),i.jsx("div",{className:"msg-text",children:j.text})]},$))}):i.jsx(Ee,{children:"None recorded"})]})]})}function Lt(e){return i.jsx("li",{children:i.jsxs("button",{className:`dv-opt ${e.on?"on":""} ${e.cls??""}`,onClick:e.onClick,children:[i.jsx("span",{className:"ttl",children:e.label}),i.jsx("b",{children:e.n})]})})}function Ab(e){const{filter:t,set:r,all:o}=e,l=c=>o.filter(c).length;return e.compact?i.jsxs("div",{className:"dv-filters compact",children:[i.jsx(ct,{compact:!0,"aria-label":"Trail",value:t.mapId??"",onChange:c=>r({mapId:c||void 0}),options:[{value:"",label:"All trails"},...e.trails.map(c=>({value:c.map.id,label:`${c.map.key} ${c.map.title}`}))]}),i.jsx(ct,{compact:!0,"aria-label":"Source",value:t.source??"",onChange:c=>r({source:c||void 0}),options:[{value:"",label:"All sources"},...ko.map(c=>({value:c,label:_n[c].label}))]}),i.jsx(ct,{compact:!0,"aria-label":"Decided by",value:t.decidedBy??"",onChange:c=>r({decidedBy:c||void 0}),options:[{value:"",label:"Anyone"},...e.people.map(c=>({value:c,label:c}))]}),i.jsx(ct,{compact:!0,"aria-label":"Status",value:t.status??"",onChange:c=>r({status:c||void 0}),options:[{value:"",label:"Any status"},{value:"active",label:"Active"},{value:"superseded",label:"Superseded"}]})]}):i.jsxs("aside",{className:"dv-filters",children:[i.jsx("h3",{className:"mono-label",children:"Trail"}),i.jsxs("ul",{children:[i.jsx(Lt,{on:!t.mapId,label:"All trails",n:o.length,onClick:()=>r({mapId:void 0})}),e.trails.map(c=>i.jsx(Lt,{on:t.mapId===c.map.id,label:`${c.map.key} ${c.map.title}`,n:l(d=>d.mapId===c.map.id),onClick:()=>r({mapId:c.map.id})},c.map.id))]}),i.jsx("h3",{className:"mono-label",children:"Source"}),i.jsxs("ul",{children:[i.jsx(Lt,{on:!t.source,label:"All",n:o.length,onClick:()=>r({source:void 0})}),ko.map(c=>i.jsx(Lt,{cls:`src-${c}`,on:t.source===c,label:_n[c].label,n:l(d=>d.source.kind===c),onClick:()=>r({source:t.source===c?void 0:c})},c))]}),i.jsx("h3",{className:"mono-label",children:"Made by"}),i.jsxs("ul",{children:[i.jsx(Lt,{on:!t.madeBy,label:"Anyone",n:o.length,onClick:()=>r({madeBy:void 0})}),i.jsx(Lt,{on:t.madeBy==="agent",label:"Agents, on their own",n:l(c=>Bi(c)==="agent"),onClick:()=>r({madeBy:t.madeBy==="agent"?void 0:"agent"})}),i.jsx(Lt,{on:t.madeBy==="human",label:"People",n:l(c=>Bi(c)==="human"),onClick:()=>r({madeBy:t.madeBy==="human"?void 0:"human"})})]}),i.jsx("h3",{className:"mono-label",children:"Decided by"}),i.jsxs("ul",{children:[i.jsx(Lt,{on:!t.decidedBy,label:"Anyone",n:o.length,onClick:()=>r({decidedBy:void 0})}),e.people.map(c=>i.jsx(Lt,{on:t.decidedBy===c,label:c,n:l(d=>d.decidedBy===c),onClick:()=>r({decidedBy:t.decidedBy===c?void 0:c})},c))]}),i.jsx("h3",{className:"mono-label",children:"Status"}),i.jsxs("ul",{children:[i.jsx(Lt,{on:!t.status,label:"Any",n:o.length,onClick:()=>r({status:void 0})}),i.jsx(Lt,{on:t.status==="active",label:"Active",n:l(c=>!c.supersededBy),onClick:()=>r({status:t.status==="active"?void 0:"active"})}),i.jsx(Lt,{on:t.status==="superseded",label:"Superseded",n:l(c=>!!c.supersededBy),onClick:()=>r({status:t.status==="superseded"?void 0:"superseded"})})]})]})}function Lb(e){if(Ki(e)==="superseded")return`Replaced by ${e.supersededBy}`;if(e.supersedes)return`Replaces ${e.supersedes}`}function Rb(e){const{d:t}=e,r=Ki(t);return i.jsxs(i.Fragment,{children:[e.newDay&&i.jsx("li",{className:"dv-day t-label",children:Ds(t.decidedAt)}),i.jsx(Ae,{as:"li",className:`dv-row ${r}`,selected:e.on,onOpen:e.onClick,title:t.question,titleText:t.question,trailing:yc(t.decidedAt),context:i.jsx(Q,{parts:[{text:t.id,code:!0},t.ticketKey&&{text:t.ticketKey,code:!0},e.showTrail&&e.trail,t.decidedBy,_n[t.source.kind].label,Lb(t)]}),detail:t.summary,detailText:t.summary})]})}function Ob(e){const{rows:t,current:r}=e;return i.jsx("ol",{className:"dv-list","aria-label":"Logbook",children:t.length?t.map((o,l)=>{var c;return i.jsx(Rb,{d:o,newDay:l===0||Ds(t[l-1].decidedAt)!==Ds(o.decidedAt),trail:(c=e.snaps[o.mapId])==null?void 0:c.map.key,on:(r==null?void 0:r.id)===o.id&&r.mapId===o.mapId,showTrail:e.showTrail,onClick:()=>e.onSelect(o.id)},`${o.mapId}:${o.id}`)}):i.jsx(Ee,{children:"No decisions"})})}function Pb({stats:e}){return i.jsxs("span",{className:"dv-readouts",children:[i.jsx(Zt,{layout:"start",label:"Active",value:e.active}),i.jsx(Zt,{layout:"start",label:"Superseded",value:e.superseded}),i.jsx(Zt,{layout:"start",label:"Last 24h",value:e.last24h}),i.jsx(Zt,{layout:"start",label:"Human",value:`${e.total?Math.round(e.human/e.total*100):0}%`}),i.jsx(Q,{className:"dv-src-mix",parts:ko.filter(t=>e.bySource[t]).map(t=>`${_n[t].label} ${e.bySource[t]}`)})]})}function _b(e){const{filter:t}=e,o=Object.values(t).filter(Boolean).length-(t.query?1:0),l=e.filtersOpen||o>0;return i.jsxs("div",{className:"dv-search",children:[i.jsx("input",{type:"search",placeholder:"Search decisions",value:t.query??"",onChange:c=>e.set({query:c.target.value})}),e.showToggle&&i.jsxs("button",{className:`chip ${l?"on":""}`,onClick:e.onToggle,children:["Filters",o>0?` · ${o}`:""]})]})}function Db(e){const{api:t,bp:r}=e,o=t.decisions,[l,c]=x.useState({}),[d,f]=x.useState(e.focus),[g,m]=x.useState(!1);x.useEffect(()=>f(e.focus),[e.focus]),x.useEffect(()=>{const R=O=>{O.key==="Escape"&&(r==="mobile"&&d?f(void 0):e.onClose())};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[r,d,e]);const v=x.useMemo(()=>Wk(o,l),[o,l]),y=x.useMemo(()=>Kk(o),[o]),w=o.find(R=>R.id===d&&(!l.mapId||R.mapId===l.mapId))??(r==="mobile"?void 0:v[0]),j=x.useMemo(()=>Object.values(t.allSnaps).sort((R,O)=>O.map.createdAt-R.map.createdAt),[t.allSnaps]),$=x.useMemo(()=>[...new Set(o.map(R=>R.decidedBy))].sort(),[o]),N=R=>c(O=>({...O,...R})),E=()=>{const R=Object.fromEntries(j.map(O=>[O.map.id,{key:O.map.key,title:O.map.title}]));Em(`${ve.slug}-decisions-${Ds(Date.now())}.md`,ny(v,R,{title:`${ve.name} decisions`}))},M=r==="mobile"&&!!w;return i.jsxs(Ke,{className:`zone decisions-view dv-${r}`,children:[i.jsxs("header",{className:"dv-head",children:[M?i.jsx("button",{className:"back",onClick:()=>f(void 0),children:"‹ Decisions"}):i.jsxs(Je,{as:"h2",children:["Decisions ",v.length!==o.length&&i.jsx("span",{className:"n",children:`${v.length}/${o.length}`})]}),r!=="mobile"&&i.jsx(Pb,{stats:y}),i.jsxs("span",{className:"dv-head-right",children:[!M&&i.jsx(K,{onClick:E,disabled:!v.length,title:"Export the filtered list as markdown",children:"Export .md"}),i.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})]})]}),!M&&i.jsx(_b,{filter:l,set:N,showToggle:r!=="wide",filtersOpen:g,onToggle:()=>m(R=>!R)}),i.jsxs("div",{className:"dv-body",children:[(r==="wide"||g&&!M)&&i.jsx(Ab,{filter:l,set:N,all:o,trails:j,people:$,compact:r!=="wide"}),!M&&i.jsx(Ob,{rows:v,current:w,snaps:t.allSnaps,showTrail:r==="wide",onSelect:f}),(r!=="mobile"||w)&&i.jsx("div",{className:"dv-detail",children:w?i.jsx(Mb,{d:w,all:o,snap:t.allSnaps[w.mapId],onSelect:f,onOpenTicket:e.onOpenTicket,onSupersede:t.actions.supersede}):i.jsx(Ee,{children:"No decision selected"})})]})]})}function Bb({api:e,bp:t,nav:r}){return r.statsOpen?i.jsx(DS,{api:e,bp:t,onClose:()=>r.setStatsOpen(!1)}):r.decisionsView?i.jsx(Db,{api:e,bp:t,focus:r.decisionsView.focus,onClose:()=>r.setDecisionsView(null),onOpenTicket:r.openTicket}):null}function zb(e,t,r){const o=wp(),[l,c]=x.useState(()=>new URLSearchParams(location.search).has("projects")),d=l&&o.many&&i.jsx(SS,{projects:o,bp:e,onClose:()=>c(!1),onItemHere:r});return{projects:o,overview:d,openOverview:()=>{t.setDecisionsView(null),t.setStatsOpen(!1),c(!0)}}}function $p({activity:e,onTicket:t}){const r=e.feed.slice(-120).reverse();return r.length?i.jsx("div",{className:"log",children:r.map(o=>i.jsxs("div",{className:`log-row lv-${o.level} src-${o.source} ${o.signal?"signal":""}`,onClick:()=>o.ticketId&&t(o.ticketId),children:[i.jsx("span",{className:"t t-meta",children:Bo(o.at)}),i.jsx("span",{className:"src t-meta",children:o.agent??o.source}),i.jsxs("span",{className:"msg",title:o.tag?`${o.tag} · ${o.text}`:o.text,children:[o.tag&&i.jsxs("span",{className:"tag t-meta",children:[o.tag," · "]}),o.text]})]},o.id))}):i.jsx(Dn,{title:"Nothing has happened yet",hint:"Claims, steps, questions and decisions appear here as agents work."})}function qh({lease:e,now:t}){if(!e)return null;const r=Po(e,t);if(r==="live")return null;const o=e.expiresAt-t;return i.jsxs(zn,{tone:"amber",className:"stalled",title:`No activity from ${e.agent}; the ticket returns to the queue when the lease runs out`,children:["stalled · ",r==="expired"?"returning":Wt(o)]})}function Fb({total:e,step:t}){return i.jsx("span",{className:"segs","aria-label":`Step ${t} of ${e}`,children:Array.from({length:e},(r,o)=>i.jsx("i",{className:Ub(o+1,t)},o))})}function Ub(e,t){return e<t?"done":e===t?"cur":""}function Tp({snap:e,activity:t,leases:r,onSelect:o,onOpenChat:l}){var w;const c=sn(1e3),d=t.sessions.filter(tn),f=new Set(d.map(j=>j.ticketId)),g=xc(r,e==null?void 0:e.map.id),m=(e==null?void 0:e.tickets.filter(j=>j.state==="open"&&j.assignee&&!f.has(j.id)))??[];if(!d.length&&!m.length)return i.jsx(Ee,{children:"No agent on a ticket"});const v=j=>!!j&&Po(j,c)!=="live",y=!!((w=e==null?void 0:e.map.modelMatching)!=null&&w.enabled);return i.jsxs("ul",{className:"sessions-list",children:[d.map(j=>{const $=e==null?void 0:e.tickets.find(M=>M.id===j.ticketId),N=$?Wi($)==="hitl":!1,E=$&&g.get($.id);return i.jsx(Ae,{as:"li",className:j.waitingOn?"waiting":void 0,edge:Hb(j,v(E)),title:Vb($,j.mode)||j.agent,context:i.jsx(Q,{parts:[{text:j.agent,strong:!0},y&&Wb(j),j.waitingOn?{text:"Waiting on you",urgent:!0}:`${j.mode} · ${j.stepLabel.toLowerCase()}`,N&&!j.waitingOn&&"with you",Kb(j)],children:i.jsx(qh,{lease:E,now:c})}),trailing:Im(c-j.startedAt),below:i.jsx(Fb,{total:j.total,step:j.step}),onOpen:()=>{$&&o({kind:"ticket",id:$.id}),N&&l(j.id)}},j.id)}),m.map(j=>i.jsx(Ae,{as:"li",className:"claim",edge:v(g.get(j.id))?"attention":"neutral",title:`${j.key} ${j.title}`,context:i.jsx(Q,{parts:[{text:j.assignee??"",strong:!0},"claimed, no live session"],children:i.jsx(qh,{lease:g.get(j.id),now:c})}),onOpen:()=>o({kind:"ticket",id:j.id})},j.id))]})}function Hb(e,t){return e.waitingOn?"urgent":t?"attention":"neutral"}function Wb(e){const t=e.model?`Runs ${e.model}`:"No model reported, so it counts as balanced";return{text:e.tier??"balanced",tip:t,className:"session-tier"}}function Kb(e){if(e.usage)return`${zo(Uk(e))} tok · ${_s(e.usage.costUsd)}`}function Vb(e,t){return e?`${e.key} ${e.title}`:t==="chart"?"Charting trail":""}function Ep({activity:e,snap:t,running:r,usage:o=!0}){const l=fm(e,t==null?void 0:t.map.id),c=mm(e,t==null?void 0:t.map.id),d=new Set(e.sessions.filter(tn).map(g=>g.ticketId)),f=(t==null?void 0:t.tickets.filter(g=>g.state==="open"&&g.assignee&&!d.has(g.id)).length)??0;return i.jsx(Ct,{sub:!0,className:"sessions-head",title:i.jsxs(i.Fragment,{children:["Agents on tickets ",i.jsx("span",{className:"n",children:r+f})]}),right:o?i.jsxs("span",{className:"usage",title:["Model usage for this trail, all sessions",...c.map(g=>hm[g].text)].join(`
|
|
147
|
-
`),children:[i.jsx("span",{className:"mono-label",children:"Trail"})," ",zo(l.inputTokens+l.outputTokens)," tok · ",_s(l.costUsd)]}):void 0})}function Gb(e){const t=[...e.feed].reverse().find(r=>r.level==="step"&&r.sessionId);return t?e.sessions.find(r=>r.id===t.sessionId):void 0}const Qb={running:"Working",done:"Done",failed:"Stopped"};function Ip({activity:e,snap:t}){const r=Gb(e);if(!r)return i.jsx(Dn,{title:"No agent working yet",hint:"Run /scout resume in Claude Code or Codex. Each step an agent reports shows here."});const o=r.ticketId?t==null?void 0:t.tickets.find(d=>d.id===r.ticketId):void 0,l=Ao[r.mode],c=r.waitingOn?"Waiting on you":Qb[r.status];return i.jsxs("div",{className:`step-tracker ${r.waitingOn?"waiting":""}`,children:[i.jsxs("div",{className:"st-meta",children:[i.jsx(
|
|
148
|
-
${l.briefText}`)}).filter(m=>m.kind==="business-rule").filter(m=>jy(d,[m.id]).length);return!d.length&&!g.length?null:i.jsxs("div",{className:"criteria-section d-section",children:[i.jsxs("span",{className:"t-label","data-tip":"Agreed before the work starts; each needs evidence before the ticket counts as done",children:["Acceptance criteria · ",d.length,(c==null?void 0:c.confirmed)&&i.jsx("span",{className:"ok-text",children:" · confirmed by you"})]}),d.length>0&&i.jsx("ul",{className:"criteria-list item-list",children:d.map(m=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:m.text}),i.jsx(
|
|
149
|
-
${f.text}`:f.text),f=>c(f.message)),children:"Full log ›"}),e.truncated&&i.jsx("span",{className:"dim",children:"log capped at 1 MB"}),l&&i.jsx("span",{className:"vf-err",children:l})]})]})}function nC(e){return e.error?"did not start":e.timedOut?"timed out":`exit ${e.exitCode??e.signal??"?"}`}const Xh=e=>(e==null?void 0:e.slice(0,8))??"none",Zh=e=>e===null?"·":String(e);function sC({attempt:e}){const t=e.git;if(!t)return null;const{files:r,add:o,del:l}=t.stats;return i.jsxs("div",{className:"vf-git",children:[i.jsx(
|
|
150
|
-
`),children:[i.jsx("span",{className:"t-code",children:c.kind})," ",c.message]},c.kind)}),t.changed.length>0&&i.jsxs("details",{className:"vf-files",children:[i.jsx("summary",{className:"t-label",children:"Changed files"}),i.jsx("ul",{children:t.changed.map(c=>i.jsxs("li",{children:[i.jsx("code",{children:c.path}),i.jsxs("span",{className:"dim",children:[c.untracked?"new":`+${Zh(c.add)} −${Zh(c.del)}`,c.dirtyAtClaim?" · dirty at claim":""]})]},c.path))})]})]})}function iC({attempt:e,latest:t}){return i.jsxs("details",{className:`vf-attempt r-${e.result}`,open:t,children:[i.jsxs("summary",{children:[i.jsx(zn,{tone:"state",className:`r-${e.result}`,children:r0[e.result]}),i.jsx(Q,{parts:[{text:e.id,code:!0},e.agent,Vi(e.submittedAt),Wt(e.finishedAt-e.submittedAt)]})]}),i.jsx("p",{className:"vf-claim",children:e.summary??e.resolution}),e.note&&i.jsx("p",{className:"vf-note",children:e.note}),e.criteria&&i.jsx("ul",{className:"vf-criteria",children:e.criteria.lines.map(r=>i.jsx("li",{className:rC(r),children:r},r))}),i.jsx(sC,{attempt:e}),e.checks.map(r=>i.jsx(tC,{check:r},r.name))]})}function rC(e){return e.includes(" ✓ ")?"ok":e.includes(" ✗ ")?"bad":"wait"}const oC={PASS:"Passed",FAIL:"Sent back",NEEDS_HUMAN:"Needs you"};function aC({verdict:e}){const{guide:t,checklist:r}=e;return i.jsxs("div",{className:`vf-verdict v-${e.verdict.toLowerCase()}`,children:[i.jsx(Q,{parts:[{text:e.byKind==="trail lead"&&e.verdict==="PASS"?"Approved":oC[e.verdict],strong:!0},{text:e.id,code:!0},e.byKind==="trail lead"?e.by:`review ${e.by}`,e.sessionId&&`session ${e.sessionId.slice(0,8)}`,t&&`as ${t.id} ${t.version}`,`on ${e.attemptId}`,Vi(e.at)]}),i.jsx("p",{children:e.summary}),e.findings.length>0&&i.jsx("ul",{className:"vf-findings",children:e.findings.map((o,l)=>i.jsxs("li",{className:`sev-${o.severity}`,children:[o.path&&i.jsx("code",{children:o.line?`${o.path}:${o.line}`:o.path})," ",o.text]},l))}),r&&r.length>0&&i.jsx(cp,{answers:r})]})}function lC(e,t,r){const[o,l]=x.useState(),c=x.useCallback(()=>{Gi.ticket(e,t).then(l)},[e,t]);return x.useEffect(()=>(l(void 0),c(),Bs.onEvidence(c)),[c]),x.useEffect(c,[c,r]),{data:o,reload:c}}const ql={rework:{label:"What to fix",submit:"Send to rework",hint:"Posted on the ticket for the next agent."},accept:{label:"Why accept",submit:"Accept anyway",hint:"Closes the ticket as done despite the checks."},unblock:{label:"Why",submit:"Unblock",hint:"Back to the queue without running checks."}};function cC(e){const[t,r]=x.useState(),[o,l]=x.useState(""),[c,d]=x.useState("rework"),{state:f,submitted:g,running:m,act:v}=e;if(m||f!=="verifying"&&f!=="held")return null;const y=j=>{r(t===j?void 0:j),l("")},w=j=>{j.preventDefault(),!(!t||!o.trim())&&(v({action:t,reason:o.trim(),...t==="unblock"?{to:c}:{}}),r(void 0))};return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"actions vf-actions",children:[f==="verifying"&&g&&i.jsx(K,{variant:"primary",onClick:()=>void v({action:"approve"}),"data-tip":"Checks passed: approve and close the ticket",children:"Approve"}),g&&i.jsx(K,{onClick:()=>void v({action:"rerun"}),"data-tip":"Run the repo's checks again on the current code",children:"Re-run checks"}),i.jsx(K,{on:t==="rework",onClick:()=>y("rework"),"data-tip":"Send it back to an agent with what to fix",children:"Rework…"}),f==="held"&&i.jsxs(i.Fragment,{children:[i.jsx(K,{on:t==="accept",onClick:()=>y("accept"),"data-tip":"Close it as done despite the failing checks",children:"Accept anyway…"}),i.jsx(K,{on:t==="unblock",onClick:()=>y("unblock"),"data-tip":"Put it back in the queue without running checks",children:"Unblock…"})]})]}),t&&i.jsxs(Ot,{as:"form",tone:"inset",className:"inline-form",onSubmit:w,children:[i.jsx(Ye,{label:ql[t].label,children:i.jsx("textarea",{rows:2,value:o,onChange:j=>l(j.target.value),autoFocus:!0})}),t==="unblock"&&i.jsx(Ye,{label:"Back to",children:i.jsx(ct,{"aria-label":"Back to",value:c,onChange:d,options:[{value:"rework",label:"Rework",hint:"Keeps the feedback for the next agent."},{value:"ready",label:"Ready",hint:"Back in the queue as a fresh ticket."}]})}),i.jsx("span",{className:"dim vf-hint",children:ql[t].hint}),i.jsxs("div",{className:"form-actions",children:[i.jsx(K,{variant:"ghost",onClick:()=>r(void 0),children:"Cancel"}),i.jsx(K,{type:"submit",variant:t==="accept"?"danger":"primary",disabled:!o.trim(),children:ql[t].submit})]})]})]})}const uC={ticket:"set on this ticket",trail:"from the trail",none:"not set"},dC=new Set(["verifying","rework","held"]);function fC(e){const{mapId:t,ticket:r,state:o}=e,{data:l,reload:c}=lC(t,r.id,r.updatedAt),[d,f]=x.useState();if(!l||l.level.level==="off"&&!l.attempts.length&&!dC.has(o))return null;const g=v=>(f(void 0),Gi.act({...v,mapId:t,ticketId:r.id,by:wt}).then(c,y=>f(y.message))),m=l.running;return i.jsxs("section",{className:"vf-panel",children:[i.jsxs("div",{className:"vf-head",children:[i.jsx(Je,{as:"h4",children:"Verification"}),i.jsx(Q,{parts:[Ui[l.level.level],uC[l.level.source]]}),r.state==="open"&&i.jsx(Zb,{value:r.verification,inherit:`Trail (${Ui[e.trail??"off"]})`,onChange:v=>void g({action:"level",level:v})})]}),m&&i.jsxs("div",{className:"sync-line vf-running",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:["Checking ",m.id," for ",m.agent," · since ",Vi(m.startedAt)]})]}),i.jsx(cC,{state:o,submitted:l.attempts.length>0,running:!!m,act:g}),d&&i.jsx("p",{className:"vf-err",children:d}),l.verdicts.map(v=>i.jsx(aC,{verdict:v},v.id)),l.attempts.map((v,y)=>i.jsx(iC,{attempt:v,latest:y===0},v.id)),!l.attempts.length&&!m&&i.jsx(Q,{parts:[`Checks: ${l.level.checks.join(", ")||"none"}`,"run when the ticket is submitted"]})]})}function hC({lease:e,onRelease:t}){const r=sn(1e3),o=Po(e,r),l=o==="live";return i.jsxs("div",{className:`lease lease-${o} edge-note ${l?"":"edge-attention"}`,children:[i.jsxs("div",{className:"edge-note-head",children:[i.jsx(Q,{parts:[{text:`Claimed by ${e.agent}`,strong:!0},`active ${nn(r-e.renewedAt)} ago`]}),!l&&i.jsx(zn,{tone:"amber",children:"Stalled"})]}),i.jsx("p",{className:"t-meta lease-line",children:mC(o,pC(e.expiresAt-r))}),e.workspace&&i.jsxs("p",{className:"t-meta lease-branch",children:["Works on ",i.jsx("code",{className:"t-code",children:e.workspace.branch})," in its own worktree"]}),e.touches&&e.touches.length>0&&i.jsxs("p",{className:"t-meta lease-touches",children:["Expects to change"," ",e.touches.map((c,d)=>i.jsxs("span",{children:[d>0&&", ",i.jsx("code",{className:"t-code",children:c})]},c))]}),e.notes.length>0&&i.jsx("ul",{className:"lease-notes t-meta",children:e.notes.slice(-3).map((c,d)=>i.jsx("li",{children:c},d))}),i.jsx("div",{className:"actions",children:i.jsx(K,{variant:l?"default":"urgent",onClick:t,children:"Release to queue"})})]})}function mC(e,t){return e==="expired"?"Lease expired, going back to the queue":e==="stalled"?`The agent went quiet. Back in the queue in ${t}.`:`Back in the queue after ${t} without activity.`}function pC(e){const t=e/864e5;return t>=2?`${Math.round(t)} days`:Wt(Math.max(0,e))}function gC({comments:e}){if(!e.length)return null;const t=e.length>1?"s":"";return i.jsxs("details",{className:"comments",children:[i.jsxs("summary",{className:"t-label",children:[e.length," other comment",t]}),e.map(r=>i.jsxs("div",{className:"comment",children:[i.jsx(Q,{parts:[{text:r.author,strong:!0}]}),i.jsx("div",{className:"c-body",children:r.body.replace(/\*\*/g,"")})]},r.id))]})}function vC({resolution:e,decisions:t,onOpenDecision:r}){const o=t.find(d=>!d.supersededBy)??t[0],l=e.body.startsWith("**Ruled")?"ruled out":"resolution",c=t.length>1?` · ${t.length} in chain`:"";return i.jsxs("div",{className:"resolution edge-note edge-done",children:[i.jsxs("div",{className:"edge-note-head",children:[i.jsx(Q,{parts:[{text:e.author,strong:!0},l]}),o&&r&&i.jsxs("button",{className:"link t-meta",onClick:()=>r(o.id),children:[o.id,c," ›"]})]}),i.jsx("p",{children:e.body.replace(/^\*\*[^*]+\*\*\s*/,"")})]})}function kC(e){const{t,state:r,session:o,mine:l,form:c,setForm:d,actions:f,onOpenChat:g}=e;return i.jsxs("div",{className:"actions",children:[o&&i.jsx(K,{variant:o.waitingOn?"urgent":"default",onClick:()=>g(o.id),"data-tip":o.waitingOn?"The agent is waiting for your answer":"Open the conversation with this agent",children:o.waitingOn?"Answer":"Conversation"}),r==="frontier"&&i.jsx(K,{onClick:()=>f.claim(t.id),"data-tip":"Take this ticket yourself, so no agent picks it up",children:"Claim"}),(r==="frontier"||r==="claimed"&&l)&&i.jsx(K,{on:c==="resolve",onClick:()=>d(c==="resolve"?null:"resolve"),"data-tip":"Answer it yourself and close the ticket, with a decision record",children:"Resolve…"}),l&&r==="claimed"&&i.jsx(K,{onClick:()=>f.release(t.id),"data-tip":"Give the ticket back to the queue",children:"Release"}),(r==="frontier"||r==="blocked"||r==="parked")&&i.jsx(K,{variant:"danger",on:c==="rule",onClick:()=>d(c==="rule"?null:"rule"),"data-tip":"Move it out of scope. It's set aside with your reason, not deleted",children:"Rule out…"})]})}function yC({t:e,state:t,tickets:r}){const o=new Map(r.map(m=>[m.id,m])),l=m=>{var v;return((v=o.get(m))==null?void 0:v.key)??m},c=e.blockedBy.map(m=>{var v;return`${l(m)}${((v=o.get(m))==null?void 0:v.state)==="closed"?" ✓":""}`}).join(", "),d=r.filter(m=>m.blockedBy.includes(e.id)).map(m=>m.key).join(", "),f=[["Type",zi[e.type]],["Assignee",e.assignee],["Blocked by",c],["Blocks",d],["Reviews",e.reviewOf&&l(e.reviewOf)]],g=Wi(e)==="hitl";return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"d-head",children:[i.jsx("span",{className:"key t-code",children:e.key}),i.jsx(zn,{tone:"state",className:`st-${t}`,children:Am[t]}),i.jsx("span",{className:"d-att t-meta","data-tip":g?"A person takes this one":"An agent takes this alone",children:g?"Needs a person":"Agent work"})]}),i.jsx("h3",{className:"t-heading",children:e.title}),i.jsx("dl",{className:"facts",children:f.filter(([,m])=>m).flatMap(([m,v])=>[i.jsx("dt",{className:"t-label",children:m},`${m}-k`),i.jsx("dd",{children:v},`${m}-v`)])})]})}function xC(e){const{snap:t,api:r,form:o,setForm:l}=e,{actions:c}=r,[d,f]=x.useState(""),[g,m]=x.useState(""),[v,y]=x.useState(""),[w,j]=x.useState("Not needed to reach the destination."),$=t.tickets.find(D=>D.id===e.id);if(!$)return i.jsx(Ee,{children:"Ticket not found."});const N=Fs(t.tickets,t.map.mode).get($.id),E=e.sessions.find(D=>D.ticketId===$.id&&tn(D)),M=$.assignee===wt,R=$.state==="open"?xc(r.leases,t.map.id).get($.id):void 0,O=[...$.comments].reverse().find(D=>/^\*\*(Resolution|Ruled out of scope)\*\*/.test(D.body)),X=$.comments.filter(D=>D!==O),ie=r.decisions.filter(D=>D.mapId===t.map.id&&D.ticketId===$.id);return i.jsxs("div",{className:"detail",children:[i.jsx(yC,{t:$,state:N,tickets:t.tickets}),$.body.trim()&&i.jsxs("section",{className:"d-section ticket-body",children:[i.jsx("span",{className:"t-label",children:"Description"}),i.jsx("p",{className:"body",children:$.body})]}),i.jsx(MS,{mapId:t.map.id,ticketId:$.id}),i.jsx(Tw,{mapId:t.map.id,ticketId:$.id}),i.jsx(eS,{mapId:t.map.id,ticket:$}),i.jsx(Xb,{snap:t,t:$}),i.jsx(Fw,{snap:t,t:$}),$.closeReason==="not_planned"&&i.jsx($c,{label:"Save as dead end",draft:()=>{var D;return{title:`Ruled out: ${$.title}`,body:((D=$.comments.at(-1))==null?void 0:D.body)??$.body,kind:"dead-end",sources:[`trail:${t.map.key}`,`ticket:${$.key}`]}}}),R&&i.jsx(hC,{lease:R,onRelease:()=>c.releaseLease($.id)}),!R&&i.jsx(uS,{mapId:t.map.id,ticketId:$.id}),i.jsx(fC,{mapId:t.map.id,trail:t.map.verification,ticket:$,state:N}),i.jsx(kC,{t:$,state:N,session:E,mine:M,form:o,setForm:l,actions:c,onOpenChat:e.onOpenChat}),o==="resolve"&&i.jsxs(Ot,{as:"form",tone:"inset",className:"inline-form",onSubmit:D=>{D.preventDefault(),d.trim()&&(c.resolve($.id,d.trim(),{rationale:g.trim(),alternatives:v.split(`
|
|
151
|
-
`).map(q=>q.trim()).filter(Boolean)}),l(null),f(""),m(""),y(""))},children:[i.jsx(Ye,{label:"Resolution",children:i.jsx("textarea",{rows:3,value:d,onChange:D=>f(D.target.value),autoFocus:!0})}),i.jsx(Ye,{label:"Rationale",children:i.jsx("input",{value:g,onChange:D=>m(D.target.value)})}),i.jsx(Ye,{label:"Alternatives considered",children:i.jsx("textarea",{rows:2,value:v,onChange:D=>y(D.target.value),placeholder:"One per line"})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(K,{variant:"ghost",onClick:()=>l(null),children:"Cancel"}),i.jsx(K,{type:"submit",variant:"primary",disabled:!d.trim(),children:"Resolve"})]})]}),o==="rule"&&i.jsxs(Ot,{as:"form",tone:"inset",className:"inline-form",onSubmit:D=>{D.preventDefault(),c.ruleOut({ticketId:$.id},w),l(null)},children:[i.jsx(Ye,{label:"Reason",children:i.jsx("input",{value:w,onChange:D=>j(D.target.value),autoFocus:!0})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(K,{variant:"ghost",onClick:()=>l(null),children:"Cancel"}),i.jsx(K,{type:"submit",variant:"danger",children:"Rule out"})]})]}),O&&i.jsx(vC,{resolution:O,decisions:ie,onOpenDecision:e.onOpenDecision}),i.jsx(gC,{comments:X})]})}function wC({snap:e,item:t,api:r}){const o=am(e.map.mode),[l,c]=x.useState("research"),[d,f]=x.useState(t),[g,m]=x.useState(!1),[v,y]=x.useState([]),[w,j]=x.useState("Not needed to reach the destination.");x.useEffect(()=>f(t),[t]);const $=e.tickets.filter(N=>N.state==="open");return i.jsxs("div",{className:"detail",children:[i.jsx("div",{className:"d-head",children:i.jsx(zn,{tone:"state",className:"st-unspecified",children:"Not yet specified"})}),i.jsx("h3",{className:"t-heading",children:t}),i.jsxs(Ot,{as:"form",tone:"inset",className:"inline-form",onSubmit:N=>{N.preventDefault(),r.actions.graduate({unspecified:t,type:l,title:d,blockedBy:v,hitl:g})},children:[i.jsx(Ye,{label:"Title",children:i.jsx("input",{value:d,onChange:N=>f(N.target.value)})}),i.jsxs("div",{className:"chips",children:[o.map(N=>i.jsx("button",{type:"button",className:`chip ${l===N?"on":""}`,onClick:()=>c(N),children:N},N)),Bv.includes(l)&&i.jsx("button",{type:"button",className:`chip ${g?"on":""}`,onClick:()=>m(N=>!N),children:"needs human"})]}),i.jsx("span",{className:"field",children:"Blocked by"}),i.jsx("div",{className:"chips",children:$.map(N=>i.jsx("button",{type:"button",className:`chip ${v.includes(N.id)?"on":""}`,onClick:()=>y(E=>E.includes(N.id)?E.filter(M=>M!==N.id):[...E,N.id]),children:N.key},N.id))}),i.jsx("div",{className:"form-actions",children:i.jsx(K,{type:"submit",variant:"primary",children:"Promote to ticket"})})]}),i.jsxs(Ot,{as:"form",tone:"inset",className:"inline-form",onSubmit:N=>{N.preventDefault(),r.actions.ruleOut({unspecified:t},w)},children:[i.jsx(Ye,{label:"Reason",children:i.jsx("input",{value:w,onChange:N=>j(N.target.value)})}),i.jsx("div",{className:"form-actions",children:i.jsx(K,{type:"submit",variant:"danger",children:"Rule out"})})]})]})}function jC({api:e,sessions:t,bare:r,onOpenChat:o,onOpenDecision:l}){const{snap:c,selection:d,actions:f}=e,[g,m]=x.useState(null),v=NC(d);x.useEffect(()=>m(null),[v]);let y;return c?d?d.kind==="unspecified"?y=i.jsx(wC,{snap:c,item:d.item,api:e}):y=i.jsx(xC,{snap:c,id:d.id,api:e,sessions:t,form:g,setForm:m,onOpenChat:o??f.openChat,onOpenDecision:l}):y=i.jsx(Dn,{title:"No ticket selected",hint:"Pick a ticket on the map: what it is, who has it, what blocks it, and its decision."}):y=i.jsx(Dn,{title:"No trail yet",hint:"Once there's a trail, pick a ticket on the map to see it here."}),i.jsx(zm,{area:"inspector",icon:"note",title:"Trail step",info:"The ticket you selected on the map: what it is, who has it, what blocks it, and its decision once it's made.",className:"inspector",bare:r,children:y})}function NC(e){return(e==null?void 0:e.kind)==="ticket"?e.id:(e==null?void 0:e.kind)==="unspecified"?e.item:""}const SC={holding:"Holding",challenged:"Challenged",invalidated:"Invalidated",confirmed:"Confirmed"};function bC(e){if(e.decidedBy)return e.status==="invalidated"?`invalidated by ${e.decidedBy}`:e.status==="confirmed"?`confirmed by ${e.decidedBy==="trail lead"?"you":e.decidedBy}`:`kept by ${e.decidedBy}`}function CC(e){const{a:t,snap:r}=e,o=t.tickets.flatMap(c=>r.tickets.filter(d=>d.id===c)),l=t.challenge&&`${t.challenge.by}: ${t.challenge.evidence}`;return i.jsx(Ae,{as:"li",className:`assumption st-${t.status}`,edge:t.status==="challenged"?"attention":"neutral",title:t.text,titleText:t.text,context:i.jsx(Q,{parts:[{text:t.id,code:!0},SC[t.status],bC(t)],children:o.length>0&&i.jsxs("span",{className:"assumption-tickets",children:[i.jsx("span",{className:"sep",children:" · "}),"relied on by",o.map(c=>i.jsx("button",{className:"link t-code",onClick:()=>e.onSelect({kind:"ticket",id:c.id}),children:c.key},c.id))]})}),detail:l,detailText:l,actions:e.onConfirm&&i.jsx(K,{size:"sm",variant:"ghost",disabled:e.busy,onClick:e.onConfirm,children:"Confirm"})})}function $C(e){const[t,r]=x.useState(),[o,l]=x.useState();return{confirm:async d=>{l(d);const f=await fetch(`${Se()}/assumptions/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,id:d})}).catch(()=>{});if(l(void 0),f!=null&&f.ok)return r(void 0);const g=await(f==null?void 0:f.json().catch(()=>({})));r((g==null?void 0:g.error)??"Could not confirm it; is the Lookout connected?")},busy:o,error:t}}function TC({snap:e,onSelect:t}){const{confirm:r,busy:o,error:l}=$C(e.map.id),c=e.map.sections.assumptions??[];return c.length?i.jsxs(i.Fragment,{children:[l&&i.jsx("p",{className:"urgent-text",children:l}),i.jsx("ul",{className:"assumptions row-list",children:c.map(d=>{const f=d.status==="holding"||d.status==="challenged";return i.jsx(CC,{a:d,snap:e,onSelect:t,onConfirm:f?()=>void r(d.id):void 0,busy:o===d.id},d.id)})})]}):i.jsx(Ee,{children:"None yet. They come from the accepted discovery brief or the trail's start."})}function EC(e){const[,t,r=e]=/^(#\d+)\s+(.+)$/.exec(e)??[],[o=r,...l]=r.split(/\s+[—–]\s+/);return{key:t,title:o,reason:l.join(" — ")||void 0}}function IC(e){const[t,r]=x.useState([]),o=e==null?void 0:e.map.id,l=(e==null?void 0:e.tickets.reduce((c,d)=>Math.max(c,d.updatedAt),e.map.updatedAt))??0;return x.useEffect(()=>{if(!o)return;let c=!0;return fetch(`${Se()}/journal?mapId=${encodeURIComponent(o)}`).then(d=>d.ok?d.json():{entries:[]}).then(d=>c&&r(d.entries)).catch(()=>c&&r([])),()=>{c=!1}},[o,l]),t}function MC({snap:e,activity:t,onTicket:r}){const o=IC(e),l=t.usageByMap[e.map.id],c=x.useMemo(()=>vm({snap:e,journal:o,answered:t.answered,usage:l}),[e,o,t.answered,l]),d=c.interventions,f=[["Done",`${c.done}`,`${c.done} done · ${c.cancelled} cancelled · ${c.open} open`],["Lead time",en(c.trailLeadMs),"Trail lead time: from when the trail was charted to its last done ticket"],["Median ticket",en(c.medianLeadMs),"Median time from a ticket's first claim to done"],["Interventions",`${d.total}`,`${d.answers} agent questions you answered + ${d.operatorActions} lifecycle calls you made (approve, send back, accept, unblock, cancel, release), of which ${d.reworkRequested} sent work back. Answers count while their sessions are on record.`],["Rework",`${c.rework.cycles}`,`Times work went back to rework, on ${c.rework.tickets} tickets`],["Reviews",`${c.reviews.passed}/${c.reviews.failed}`,`${c.reviews.passed} passed, ${c.reviews.failed} failed, ${c.reviews.needsHuman} needed you`],["Cost / ticket",c.spend.perVerifiedTicketUsd===void 0?"—":_s(c.spend.perVerifiedTicketUsd),`Cost per verified ticket: trail spend ${_s(c.spend.costUsd)} ÷ ${c.done} done tickets`]];return i.jsxs("div",{className:"report",children:[i.jsx("ul",{className:"report-stats",children:f.map(([g,m,v])=>i.jsxs("li",{"data-tip":v,children:[i.jsx("span",{className:"mono-label",children:g}),i.jsx("b",{children:m})]},g))}),i.jsxs("div",{className:"report-bar",children:[i.jsx("span",{className:"mono-label",children:"Tickets"}),i.jsx(K,{size:"sm",variant:"ghost","data-tip":"Download this report as markdown",onClick:()=>Em(`${e.map.key.replace("#","trail-")}-report.md`,dy(c,e.map.title)),children:"Export markdown"})]}),c.tickets.length?i.jsx("ul",{className:"list report-tickets",children:c.tickets.map(g=>i.jsx("li",{className:`out-${g.outcome}`,children:i.jsxs("button",{onClick:()=>r(g.id),"data-tip":`${g.outcome} · rework ${g.reworks} · reviews ${g.reviews.passed}/${g.reviews.failed} · your calls ${g.operatorActions}`,children:[i.jsx("span",{className:"key",children:g.key}),i.jsx("span",{className:"ttl",children:g.title}),i.jsx("span",{className:"lead",children:g.outcome==="done"?en(g.leadMs):g.outcome})]})},g.id))}):i.jsx(Ee,{children:"No tickets yet"})]})}function AC({tab:e,snap:t,selection:r,onSelect:o,activity:l}){const c=t.map.sections;switch(e){case"report":return l?i.jsx(MC,{snap:t,activity:l,onTicket:d=>o({kind:"ticket",id:d})}):i.jsx(Ee,{children:"No activity yet"});case"assumptions":return i.jsx(TC,{snap:t,onSelect:o});case"decisions":return c.decisions.length?i.jsx("ol",{className:"row-list decisions",children:[...c.decisions].reverse().map((d,f)=>i.jsx(Ae,{as:"li",title:d.text,titleText:d.text,context:d.ticketKey&&i.jsx(Q,{parts:[{text:d.ticketKey,code:!0}]}),onOpen:d.ticketId?()=>o({kind:"ticket",id:d.ticketId}):void 0},`${d.ticketKey}-${f}`))}):i.jsx(Ee,{children:"None"});case"unspecified":return c.unspecified.length?i.jsx("ul",{className:"row-list unspecified",children:c.unspecified.map(d=>i.jsx(Ae,{as:"li",title:d,titleText:d,selected:(r==null?void 0:r.kind)==="unspecified"&&r.item===d,onOpen:()=>o({kind:"unspecified",item:d})},d))}):i.jsx(Ee,{children:"None"});case"oos":return c.outOfScope.length?i.jsx("ul",{className:"row-list oos",children:c.outOfScope.map(d=>{const f=EC(d);return i.jsx(Ae,{as:"li",title:f.title,titleText:d,context:i.jsx(Q,{parts:[f.key&&{text:f.key,code:!0},f.reason]})},d)})}):i.jsx(Ee,{children:"None"});case"notes":return i.jsx("p",{className:"notes t-body",children:c.notes||"No notes yet."});default:return e}}function LC({snap:e,selection:t,onSelect:r,bare:o,onAudit:l,activity:c}){var y;const[d,f]=x.useState("unspecified"),g=e==null?void 0:e.map.sections,m=[{id:"unspecified",label:"Not yet specified",n:g==null?void 0:g.unspecified.length},{id:"assumptions",label:"Assumptions",n:(y=g==null?void 0:g.assumptions)==null?void 0:y.length},{id:"decisions",label:"Decisions",n:g==null?void 0:g.decisions.length},{id:"oos",label:"Out of scope",n:g==null?void 0:g.outOfScope.length},{id:"notes",label:"Notes"},{id:"report",label:"Report"}],v=e?i.jsx(AC,{tab:d,snap:e,selection:t,onSelect:r,activity:c}):i.jsx(Dn,{title:"No plan yet",hint:"Open questions, decisions, what's ruled out, notes and the trail report collect here."});return i.jsxs(Ke,{className:`zone sections ${o?"bare":""}`,style:o?void 0:{gridArea:"plan"},children:[!o&&i.jsx(Ct,{className:"zone-title",icon:"flag",title:"Trail plan",info:"The parts of the plan that aren't tickets yet: open questions still to specify, the assumptions the plan relies on, decisions already made, what's ruled out, and notes. Report shows how the trail is going: lead times, your interventions, rework, reviews and cost per verified ticket."}),i.jsxs("div",{className:"sections-tabs",children:[i.jsx(ct,{compact:!0,"aria-label":"Plan section",value:d,onChange:f,options:m.map(w=>({value:w.id,label:w.n===void 0?w.label:`${w.label} · ${w.n}`}))}),d==="decisions"&&l&&i.jsx("button",{className:"link",onClick:l,children:"Audit ›"})]}),i.jsx("div",{className:"zone-b",children:v})]})}function RC(){var ae;const e=x.useMemo(()=>sw(nw()),[]),t=pw(e),{snap:r,activity:o,selection:l,actions:c}=t,[d,f]=gw();x.useEffect(()=>Lm(d.theme),[d.theme]);const g=nb(),[m,v]=x.useState(!1),y=rb(e.kind),w=dw(),j=o.pending.length,$=ob(o,t.mapId);ib(j,r==null?void 0:r.map.title);const N=sb(t,w),E=Cb(r,c.selectMap),M=Vw(E.briefText),R=Ib({api:t,nav:N,knowledge:M,reviewBrief:E.review,openReroute:Z=>E.openReroute(Z.mapId,Z.ref),openGuides:()=>g.open("guides"),openFocusSettings:()=>g.open("attention")}),O=hw(e,t,d.briefing,(ae=R.attention.view)==null?void 0:ae.items),X=i.jsx(m0,{api:t,nav:N,bp:w,scoped:$,attn:R,above:E.inboxCard}),ie=i.jsx(X1,{api:t,sessions:$.sessions,onSelect:N.select,onNewTrail:()=>v(!0),compact:w==="mobile",minFit:w==="mobile"?.7:0,trail:E}),D=Z=>i.jsx(jC,{api:t,sessions:$.sessions,bare:Z,onOpenChat:U=>N.openChat(U),onOpenDecision:N.openDecisions}),q={activity:$,snap:r,leases:t.leases,onTicket:Z=>N.select({kind:"ticket",id:Z}),onOpenChat:Z=>N.openChat(Z)},re=Z=>i.jsx(LC,{snap:r,selection:l,onSelect:N.select,bare:Z,onAudit:()=>N.openDecisions(),activity:$}),{projects:V,overview:ge,openOverview:Re}=zb(w,N,R.link.request),be=g.route&&i.jsx(t1,{rt:e,api:t,bp:w,prefs:d,update:f,settings:g}),te=(N.statsOpen||N.decisionsView)&&i.jsx(Bb,{api:t,bp:w,nav:N}),P=be||ge||te,Y=O.shown&&i.jsx(Cw,{brief:O,snaps:t.allSnaps,bp:w,openTicket:N.openTicket,openChat:N.openChat,openDecisions:N.openDecisions,closeDecisions:()=>N.setDecisionsView(null),showPhoneHome:()=>N.setPhoneTab("home")});return i.jsx(Um.Provider,{value:M,children:i.jsxs("div",{className:`app bp-${w}`,children:[i.jsx(xj,{api:t,rt:e,repo:i.jsx(bS,{repo:y,projects:V,onOverview:Re}),brief:O,attention:R.header,decisionsOpen:!!N.decisionsView,onDecisions:()=>{g.close(),N.decisionsView?N.setDecisionsView(null):N.openDecisions()},onStats:()=>{g.close(),N.toggleStats()},onNewTrail:()=>v(!0),onSettings:g.toggle,onSlack:()=>g.open("slack"),onToggleTheme:Z=>f({theme:Z?"night":"day"})}),w==="wide"&&i.jsxs(i.Fragment,{children:[X,ie,D(!1),i.jsx(Yb,{...q}),i.jsx(qb,{...q}),re(!1),P]}),w==="laptop"&&i.jsxs(i.Fragment,{children:[X,ie,i.jsx(n1,{tab:N.sideTab,onTab:N.setSideTab,unspecified:r==null?void 0:r.map.sections.unspecified.length,ticket:D(!0),activity:i.jsx(Yh,{...q}),plan:re(!0)}),P]}),w==="mobile"&&i.jsxs(i.Fragment,{children:[i.jsx(tb,{tab:N.phoneTab,decisions:P,inbox:X,projects:V.many&&i.jsx($S,{projects:V,onOverview:Re}),map:ie,ticket:D(!0),activity:i.jsx(Yh,{...q}),plan:re(!0)}),i.jsx(eb,{tab:N.phoneTab,covered:!!P,pending:j,onPick:Z=>{g.close(),N.setPhoneTab(Z),N.setDecisionsView(null)}})]}),Y,E.dialog,t.error&&i.jsx("div",{className:"error-toast",children:t.error}),m&&i.jsx(w0,{rt:e,onClose:()=>v(!1),onCreated:Z=>c.selectMap(Z)}),!d.onboarded&&i.jsx(dN,{prefs:d,update:f,activeTracker:e.kind}),i.jsx(Kw,{})]})})}Lm(jc().theme);Pv.createRoot(document.getElementById("root")).render(i.jsxs(i.Fragment,{children:[i.jsx(RC,{}),i.jsx(ww,{})]}));
|
|
144
|
+
`):"",banner:c&&i.jsx(fb,{brief:c,onReview:l}),inboxCard:c&&i.jsx(ub,{brief:c,onReview:l}),dialog:c&&r&&i.jsx(lb,{brief:c,error:t.error,onAccept:()=>void t.accept().then(f=>f&&o(!1)),onRequestChanges:f=>void t.requestChanges(f).then(g=>g&&o(!1)),onClose:()=>o(!1)})}}function pb({reroute:e,onReview:t}){var f;const r=e.kind==="challenge-destination",o=((f=e.frozen)==null?void 0:f.length)??0,l=r?"wrong mountain?":"proposes a new plan",c=o?` ${o} ticket${o===1?" is":"s are"} closed until you decide.`:"",d=`${e.reason.replace(/\.$/,"")}.${c}`;return i.jsxs("div",{className:"reroute-banner map-banner edge-attention",role:"status",title:d,children:[i.jsxs("span",{className:"mb-text",children:[i.jsxs("span",{className:"mb-lead",children:[e.by," ",l]}),i.jsx("span",{className:"t-meta",children:d})]}),i.jsx(Us,{text:"An agent found that an assumption or the plan no longer holds and proposes changes. The map shows them: dashed outlines are tickets it adds, struck ones it cancels, ❄ marks tickets frozen until you approve or reject. Nothing changes until you decide."}),i.jsx(K,{size:"sm",variant:"primary",onClick:t,children:"Review"})]})}const gb={"already-exists":"The work already exists","wrong-problem":"The trail targets the wrong problem",rescope:"The trail should be rescoped"};function vb(e,t){var r;switch(e.op){case"add_ticket":{const o=(r=e.blockedBy)!=null&&r.length?`after ${e.blockedBy.map(t).join(", ")}`:void 0;return{verb:"Add",text:e.title,detail:[`new ${e.type} ticket`,o].filter(Boolean).join(" · ")}}case"cancel_ticket":return{verb:"Cancel",text:t(e.ticket),detail:e.reason};case"edit_ticket":return{verb:"Revise",text:t(e.ticket),detail:e.title?`New title: ${e.title}`:"New description"};case"rewire":return{verb:"Rewire",text:t(e.ticket),detail:kb(e,t)};case"supersede_decision":return{verb:"Supersede",text:e.decision,detail:`${e.answer}. ${e.rationale}`};case"update_destination":return{verb:"Destination",text:e.text};case"add_unspecified":return{verb:"Not yet specified",text:e.text};case"add_out_of_scope":return{verb:"Out of scope",text:e.text};case"reopen":return{verb:"Reopen",text:t(e.ticket),detail:`Back in the queue: ${e.reason}`};default:return e}}function kb(e,t){var o,l;return[...(o=e.addBlockedBy)!=null&&o.length?[`now also after ${e.addBlockedBy.map(t).join(", ")}`]:[],...(l=e.removeBlockedBy)!=null&&l.length?[`no longer after ${e.removeBlockedBy.map(t).join(", ")}`]:[]].join(" · ")}const yb=new Set(["cancel_ticket","update_destination"]);function xb({change:e,name:t}){const r=vb(e,t);return i.jsx(Ae,{as:"li",className:`reroute-change op-${e.op}`,edge:yb.has(e.op)?"attention":"neutral",title:r.text,titleText:r.text,context:i.jsx(q,{parts:[{text:r.verb,strong:!0}]}),detail:r.detail,detailText:r.detail})}function wb(e){const{reason:t,destination:r}=e;return i.jsxs("section",{className:"reroute-destination",children:[t&&i.jsx("p",{className:"reroute-destination-why",children:gb[t]}),r&&i.jsxs("div",{className:"reroute-destination-diff",children:[i.jsxs("div",{children:[i.jsx("span",{className:"mono-label",children:"Destination now"}),i.jsx("p",{className:"before",children:r.before||"—"})]}),i.jsxs("div",{children:[i.jsx("span",{className:"mono-label",children:"Suggested destination"}),i.jsx("p",{className:"after",children:r.after})]})]})]})}function jb(e,t){const r=new Map(e.tickets.map(l=>[l.id,l.key])),o=new Map(t.flatMap(l=>l.op==="add_ticket"?[[l.ref,l.title]]:[]));return l=>{const c=r.get(l);if(c)return c;const d=o.get(l);return d?`new: ${d}`:l}}function Nb(e){var w,j;const{reroute:t,snap:r}=e,[o,l]=x.useState("");x.useEffect(()=>{const $=N=>N.key==="Escape"&&e.onClose();return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[e]);const c=jb(r,t.changes),d=new Map(r.tickets.map($=>[$.id,`${$.key} ${$.title}`])),f=$=>d.get($)??c($),g=r.map.sections.assumptions??[],m=t.invalidates.map($=>g.find(N=>N.id===$)??{id:$,text:""}),v=t.status==="pending",y=t.kind==="challenge-destination";return i.jsx("div",{className:"scrim",onClick:e.onClose,children:i.jsxs(Ke,{as:"div",className:"dialog reroute-dialog",onClick:$=>$.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:y?"Destination challenged":"Reroute proposal"}),i.jsx(q,{parts:[{text:t.id,code:!0},t.status,`by ${t.by}`,`${nn(Date.now()-t.at)} ago`]})]}),i.jsxs("div",{className:"reroute-body",children:[y&&i.jsx(wb,{reason:t.destinationReason,destination:(w=t.diff)==null?void 0:w.destination}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Why"}),i.jsx("p",{children:t.reason})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Evidence"}),i.jsx("p",{className:"reroute-evidence",children:t.evidence})]}),m.length>0&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Assumptions it invalidates"}),i.jsx("ul",{className:"item-list",children:m.map($=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:$.text}),i.jsx(q,{parts:[{text:$.id,code:!0}]})]},$.id))})]}),i.jsxs("section",{children:[i.jsxs("h3",{className:"mono-label",children:["Changes · ",t.changes.length]}),i.jsx("ul",{className:"reroute-changes row-list",children:t.changes.map(($,N)=>i.jsx(xb,{change:$,name:f},N))})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Closed until you decide"}),(j=t.frozen)!=null&&j.length?i.jsx("ul",{className:"item-list",children:t.frozen.map($=>i.jsx("li",{className:"item-text",children:f($)},$))}):i.jsx(Ee,{children:"No tickets closed"})]}),t.note&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Your note"}),i.jsx("p",{children:t.note})]})]}),v&&i.jsx(Ye,{label:"Note for the agent (required to reject)",children:i.jsx("textarea",{rows:2,value:o,onChange:$=>l($.target.value)})}),e.error&&i.jsx("p",{className:"urgent-text",children:e.error}),i.jsxs("div",{className:"actions",children:[v&&i.jsxs(i.Fragment,{children:[i.jsx(K,{className:"reroute-reject",disabled:!o.trim(),onClick:()=>e.onReject(o.trim()),children:"Reject"}),i.jsx(K,{className:"reroute-approve",variant:"primary",onClick:()=>e.onApprove(o.trim()),children:"Approve and apply"})]}),i.jsx(K,{variant:"ghost",onClick:e.onClose,children:"Close"})]})]})})}const Qh=`${Se()}/reroutes`;function Sb(e){const t=e==null?void 0:e.map.id,[r,o]=x.useState([]),[l,c]=x.useState(),d=x.useCallback(()=>{if(!t)return o([]);fetch(`${Qh}?map=${encodeURIComponent(t)}`).then(m=>m.ok?m.json():{reroutes:[]}).then(m=>o(m.reroutes)).catch(()=>o([]))},[t]),f=e==null?void 0:e.tickets.reduce((m,v)=>Math.max(m,v.updatedAt),e.map.updatedAt);x.useEffect(d,[d,f]),x.useEffect(()=>Zx("reroute",m=>{m.mapId===t&&d()}),[d,t]);const g=async(m,v,y)=>{var N;const w=await fetch(`${Qh}/${m}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,id:v,note:y})}),j=await w.json().catch(()=>({}));if(w.ok)return c(void 0),d(),!0;const $=(N=j.errors)==null?void 0:N.map(E=>E.message).join("; ");return c([j.error??`HTTP ${w.status}`,$].filter(Boolean).join(": ")),!1};return{reroutes:r,pending:r.find(m=>m.status==="pending"),error:l,clearError:()=>c(void 0),approve:(m,v)=>g("approve",m,v),reject:(m,v)=>g("reject",m,v)}}function bb(e,t){const r=Sb(e),[o,l]=x.useState(),c=r.reroutes.find(m=>m.id===o),d=c!=null&&c.diff?c:r.pending,f=()=>{l(void 0),r.clearError()},g=m=>m&&f();return{banner:r.pending&&i.jsx(pb,{reroute:r.pending,onReview:()=>{var m;return l((m=r.pending)==null?void 0:m.id)}}),preview:e&&(d!=null&&d.diff)?f1(e,d.diff,d.frozen):void 0,openReroute:(m,v)=>{m!==(e==null?void 0:e.map.id)&&(t==null||t(m)),l(v)},dialog:e&&c&&i.jsx(Nb,{reroute:c,snap:e,error:r.error,onApprove:m=>void r.approve(c.id,m||void 0).then(g),onReject:m=>void r.reject(c.id,m).then(g),onClose:f})}}function Cb(e,t){const r=mb(e),o=bb(e,t);return{briefText:r.briefText,inboxCard:r.inboxCard,review:r.review,banner:i.jsxs(i.Fragment,{children:[r.banner,o.banner]}),preview:o.preview,openReroute:o.openReroute,dialog:i.jsxs(i.Fragment,{children:[r.dialog,o.dialog]})}}function $b(){const e=new URL(location.href);e.searchParams.has(Ps)&&(e.searchParams.delete(Ps),history.replaceState(history.state,"",e))}function Tb(e,t){return e.kind!=="question"||t.pending.some(r=>r.id===e.ref)}function Eb(e){const[t,r]=x.useState(()=>new URLSearchParams(location.search).get(Ps)??void 0),{loaded:o,view:l,activity:c,handlers:d,showChat:f}=e;return x.useEffect(()=>{if(!t||!o||!l)return;const g=l.items.find(v=>v.id===t);if(g&&!Tb(g,c)||(r(void 0),$b(),!g))return;qm(g,{...d,openQuestion:v=>{const y=c.pending.find(w=>w.id===v);y&&f(y.sessionId,y.ticketId)}})},[t,o,l,c,d,f]),{request:x.useCallback(g=>r(g),[])}}function Ib(e){const{api:t,nav:r}=e,o=Jm(t.allSnaps);n0(o.view);const l=m=>m&&t.actions.selectMap(m),c={openTicket:r.openTicket,openKnowledge:()=>e.knowledge.setOpen(!0),openBrief:m=>m===t.mapId?e.reviewBrief():l(m),openReroute:e.openReroute??(m=>m.ticketId?r.openTicket(m.mapId,m.ticketId):l(m.mapId)),selectTrail:l,openGuides:e.openGuides},d=o.view,f=Eb({loaded:t.loaded,view:d,activity:t.activity,handlers:c,showChat:r.showChat}),g=d&&i.jsx(Xj,{view:d,onFocus:m=>void o.savePrefs(By(d.prefs,m,Date.now())),onSettings:e.openFocusSettings});return{attention:o,handlers:c,header:g,link:f}}function Mb(e){const{d:t,snap:r}=e,[o,l]=x.useState(!1),[c,d]=x.useState(""),[f,g]=x.useState("");x.useEffect(()=>{l(!1),d(""),g("")},[t.id,t.mapId]);const m=jk(e.all.filter(j=>j.mapId===t.mapId),t.id),v=Ki(t),y=t.ticketId?r==null?void 0:r.tickets.find(j=>j.id===t.ticketId):void 0,w=Date.now();return i.jsxs("div",{className:"detail dv-d",children:[i.jsxs("div",{className:"d-head",children:[i.jsx("span",{className:"key",children:t.id}),i.jsx(zn,{tone:"state",className:`dv-st-${v}`,children:v}),i.jsx(q,{parts:[Qx(t.decidedAt),`${nn(w-t.decidedAt)} ago`]})]}),i.jsx("h3",{className:"t-heading",children:t.question}),i.jsxs("div",{className:"resolution",children:[i.jsx(wo,{parts:["Decision"]}),i.jsx("p",{children:t.answer})]}),i.jsxs("dl",{className:"facts",children:[i.jsx("dt",{children:"Trail"}),i.jsx("dd",{children:r?`${r.map.key} ${r.map.title}`:t.mapId}),i.jsx("dt",{children:"Ticket"}),i.jsx("dd",{children:t.ticketId?i.jsxs("button",{className:"link",onClick:()=>e.onOpenTicket(t.mapId,t.ticketId),children:[t.ticketKey," ",(y==null?void 0:y.title)??""," · open in trail ›"]}):"—"}),i.jsx("dt",{children:"Decided by"}),i.jsx("dd",{children:t.decidedBy}),t.participants.length>1&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Participants"}),i.jsx("dd",{children:t.participants.map(j=>j.name??j.id).join(", ")})]}),i.jsx("dt",{children:"Source"}),i.jsxs("dd",{children:[_n[t.source.kind].label,t.source.url&&i.jsxs(i.Fragment,{children:[" · ",i.jsx("a",{href:t.source.url,target:"_blank",rel:"noreferrer",children:t.source.label??"link"})]}),!t.source.url&&t.source.label&&` · ${t.source.label}`,t.source.ref&&i.jsxs("span",{className:"ref",children:[" ",t.source.ref]})]})]}),t.alternatives.length>0&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Alternatives"}),i.jsx("ul",{className:"dv-alts",children:t.alternatives.map(j=>i.jsx("li",{children:j},j))})]}),t.rationale&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Rationale"}),i.jsx("p",{children:t.rationale})]}),m.length>1&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Supersession"}),i.jsx("ol",{className:"dv-chain",children:m.map(j=>i.jsx("li",{className:`${j.id===t.id?"cur":""} ${j.supersededBy?"old":"live"}`,children:i.jsxs("button",{onClick:()=>e.onSelect(j.id),children:[i.jsx("i",{}),i.jsx("span",{className:"id",children:j.id}),i.jsx("span",{className:"a",children:j.summary}),i.jsx(q,{parts:[j.decidedBy,Ds(j.decidedAt)]})]})},j.id))})]}),i.jsxs("div",{className:"actions",children:[i.jsx($c,{draft:()=>({title:t.summary||t.question,body:[t.answer,t.rationale&&`Why: ${t.rationale}`].filter(Boolean).join(`
|
|
145
|
+
|
|
146
|
+
`),kind:"product-decision",sources:[`decision:${t.id}`,...t.ticketKey?[`ticket:${t.ticketKey}`]:[]]})}),v==="active"&&i.jsx(K,{on:o,onClick:()=>l(j=>!j),"data-tip":"Replace this decision with a new answer. Both stay on record",children:"Supersede…"})]}),o&&i.jsxs(Ot,{as:"form",tone:"inset",className:"inline-form",onSubmit:j=>{j.preventDefault(),c.trim()&&(e.onSupersede(t,{answer:c.trim(),rationale:f.trim(),alternatives:[t.summary]}),l(!1))},children:[i.jsx(Ye,{label:"New decision",children:i.jsx("textarea",{rows:3,value:c,onChange:j=>d(j.target.value),autoFocus:!0})}),i.jsx(Ye,{label:"Rationale",children:i.jsx("input",{value:f,onChange:j=>g(j.target.value)})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(K,{variant:"ghost",onClick:()=>l(!1),children:"Cancel"}),i.jsx(K,{type:"submit",variant:"primary",disabled:!c.trim(),children:"Supersede"})]})]}),i.jsxs("div",{className:"dv-sec",children:[i.jsxs("h4",{className:"mono-label",children:["Transcript ",i.jsx("span",{className:"n",children:t.transcript.length})]}),t.transcript.length?i.jsx("div",{className:"dv-transcript comms-log",children:t.transcript.map((j,$)=>i.jsxs("div",{className:`msg from-${j.from} voice-${j.from==="human"?"human":"agent"}`,children:[i.jsx(wo,{parts:[j.author,yc(j.at)]}),i.jsx("div",{className:"msg-text",children:j.text})]},$))}):i.jsx(Ee,{children:"None recorded"})]})]})}function Lt(e){return i.jsx("li",{children:i.jsxs("button",{className:`dv-opt ${e.on?"on":""} ${e.cls??""}`,onClick:e.onClick,children:[i.jsx("span",{className:"ttl",children:e.label}),i.jsx("b",{children:e.n})]})})}function Ab(e){const{filter:t,set:r,all:o}=e,l=c=>o.filter(c).length;return e.compact?i.jsxs("div",{className:"dv-filters compact",children:[i.jsx(ct,{compact:!0,"aria-label":"Trail",value:t.mapId??"",onChange:c=>r({mapId:c||void 0}),options:[{value:"",label:"All trails"},...e.trails.map(c=>({value:c.map.id,label:`${c.map.key} ${c.map.title}`}))]}),i.jsx(ct,{compact:!0,"aria-label":"Source",value:t.source??"",onChange:c=>r({source:c||void 0}),options:[{value:"",label:"All sources"},...ko.map(c=>({value:c,label:_n[c].label}))]}),i.jsx(ct,{compact:!0,"aria-label":"Decided by",value:t.decidedBy??"",onChange:c=>r({decidedBy:c||void 0}),options:[{value:"",label:"Anyone"},...e.people.map(c=>({value:c,label:c}))]}),i.jsx(ct,{compact:!0,"aria-label":"Status",value:t.status??"",onChange:c=>r({status:c||void 0}),options:[{value:"",label:"Any status"},{value:"active",label:"Active"},{value:"superseded",label:"Superseded"}]})]}):i.jsxs("aside",{className:"dv-filters",children:[i.jsx("h3",{className:"mono-label",children:"Trail"}),i.jsxs("ul",{children:[i.jsx(Lt,{on:!t.mapId,label:"All trails",n:o.length,onClick:()=>r({mapId:void 0})}),e.trails.map(c=>i.jsx(Lt,{on:t.mapId===c.map.id,label:`${c.map.key} ${c.map.title}`,n:l(d=>d.mapId===c.map.id),onClick:()=>r({mapId:c.map.id})},c.map.id))]}),i.jsx("h3",{className:"mono-label",children:"Source"}),i.jsxs("ul",{children:[i.jsx(Lt,{on:!t.source,label:"All",n:o.length,onClick:()=>r({source:void 0})}),ko.map(c=>i.jsx(Lt,{cls:`src-${c}`,on:t.source===c,label:_n[c].label,n:l(d=>d.source.kind===c),onClick:()=>r({source:t.source===c?void 0:c})},c))]}),i.jsx("h3",{className:"mono-label",children:"Made by"}),i.jsxs("ul",{children:[i.jsx(Lt,{on:!t.madeBy,label:"Anyone",n:o.length,onClick:()=>r({madeBy:void 0})}),i.jsx(Lt,{on:t.madeBy==="agent",label:"Agents, on their own",n:l(c=>Bi(c)==="agent"),onClick:()=>r({madeBy:t.madeBy==="agent"?void 0:"agent"})}),i.jsx(Lt,{on:t.madeBy==="human",label:"People",n:l(c=>Bi(c)==="human"),onClick:()=>r({madeBy:t.madeBy==="human"?void 0:"human"})})]}),i.jsx("h3",{className:"mono-label",children:"Decided by"}),i.jsxs("ul",{children:[i.jsx(Lt,{on:!t.decidedBy,label:"Anyone",n:o.length,onClick:()=>r({decidedBy:void 0})}),e.people.map(c=>i.jsx(Lt,{on:t.decidedBy===c,label:c,n:l(d=>d.decidedBy===c),onClick:()=>r({decidedBy:t.decidedBy===c?void 0:c})},c))]}),i.jsx("h3",{className:"mono-label",children:"Status"}),i.jsxs("ul",{children:[i.jsx(Lt,{on:!t.status,label:"Any",n:o.length,onClick:()=>r({status:void 0})}),i.jsx(Lt,{on:t.status==="active",label:"Active",n:l(c=>!c.supersededBy),onClick:()=>r({status:t.status==="active"?void 0:"active"})}),i.jsx(Lt,{on:t.status==="superseded",label:"Superseded",n:l(c=>!!c.supersededBy),onClick:()=>r({status:t.status==="superseded"?void 0:"superseded"})})]})]})}function Lb(e){if(Ki(e)==="superseded")return`Replaced by ${e.supersededBy}`;if(e.supersedes)return`Replaces ${e.supersedes}`}function Rb(e){const{d:t}=e,r=Ki(t);return i.jsxs(i.Fragment,{children:[e.newDay&&i.jsx("li",{className:"dv-day t-label",children:Ds(t.decidedAt)}),i.jsx(Ae,{as:"li",className:`dv-row ${r}`,selected:e.on,onOpen:e.onClick,title:t.question,titleText:t.question,trailing:yc(t.decidedAt),context:i.jsx(q,{parts:[{text:t.id,code:!0},t.ticketKey&&{text:t.ticketKey,code:!0},e.showTrail&&e.trail,t.decidedBy,_n[t.source.kind].label,Lb(t)]}),detail:t.summary,detailText:t.summary})]})}function Ob(e){const{rows:t,current:r}=e;return i.jsx("ol",{className:"dv-list","aria-label":"Logbook",children:t.length?t.map((o,l)=>{var c;return i.jsx(Rb,{d:o,newDay:l===0||Ds(t[l-1].decidedAt)!==Ds(o.decidedAt),trail:(c=e.snaps[o.mapId])==null?void 0:c.map.key,on:(r==null?void 0:r.id)===o.id&&r.mapId===o.mapId,showTrail:e.showTrail,onClick:()=>e.onSelect(o.id)},`${o.mapId}:${o.id}`)}):i.jsx(Ee,{children:"No decisions"})})}function Pb({stats:e}){return i.jsxs("span",{className:"dv-readouts",children:[i.jsx(Zt,{layout:"start",label:"Active",value:e.active}),i.jsx(Zt,{layout:"start",label:"Superseded",value:e.superseded}),i.jsx(Zt,{layout:"start",label:"Last 24h",value:e.last24h}),i.jsx(Zt,{layout:"start",label:"Human",value:`${e.total?Math.round(e.human/e.total*100):0}%`}),i.jsx(q,{className:"dv-src-mix",parts:ko.filter(t=>e.bySource[t]).map(t=>`${_n[t].label} ${e.bySource[t]}`)})]})}function _b(e){const{filter:t}=e,o=Object.values(t).filter(Boolean).length-(t.query?1:0),l=e.filtersOpen||o>0;return i.jsxs("div",{className:"dv-search",children:[i.jsx("input",{type:"search",placeholder:"Search decisions",value:t.query??"",onChange:c=>e.set({query:c.target.value})}),e.showToggle&&i.jsxs("button",{className:`chip ${l?"on":""}`,onClick:e.onToggle,children:["Filters",o>0?` · ${o}`:""]})]})}function Db(e){const{api:t,bp:r}=e,o=t.decisions,[l,c]=x.useState({}),[d,f]=x.useState(e.focus),[g,m]=x.useState(!1);x.useEffect(()=>f(e.focus),[e.focus]),x.useEffect(()=>{const R=O=>{O.key==="Escape"&&(r==="mobile"&&d?f(void 0):e.onClose())};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[r,d,e]);const v=x.useMemo(()=>Wk(o,l),[o,l]),y=x.useMemo(()=>Kk(o),[o]),w=o.find(R=>R.id===d&&(!l.mapId||R.mapId===l.mapId))??(r==="mobile"?void 0:v[0]),j=x.useMemo(()=>Object.values(t.allSnaps).sort((R,O)=>O.map.createdAt-R.map.createdAt),[t.allSnaps]),$=x.useMemo(()=>[...new Set(o.map(R=>R.decidedBy))].sort(),[o]),N=R=>c(O=>({...O,...R})),E=()=>{const R=Object.fromEntries(j.map(O=>[O.map.id,{key:O.map.key,title:O.map.title}]));Em(`${ve.slug}-decisions-${Ds(Date.now())}.md`,ny(v,R,{title:`${ve.name} decisions`}))},M=r==="mobile"&&!!w;return i.jsxs(Ke,{className:`zone decisions-view dv-${r}`,children:[i.jsxs("header",{className:"dv-head",children:[M?i.jsx("button",{className:"back",onClick:()=>f(void 0),children:"‹ Decisions"}):i.jsxs(Je,{as:"h2",children:["Decisions ",v.length!==o.length&&i.jsx("span",{className:"n",children:`${v.length}/${o.length}`})]}),r!=="mobile"&&i.jsx(Pb,{stats:y}),i.jsxs("span",{className:"dv-head-right",children:[!M&&i.jsx(K,{onClick:E,disabled:!v.length,title:"Export the filtered list as markdown",children:"Export .md"}),i.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})]})]}),!M&&i.jsx(_b,{filter:l,set:N,showToggle:r!=="wide",filtersOpen:g,onToggle:()=>m(R=>!R)}),i.jsxs("div",{className:"dv-body",children:[(r==="wide"||g&&!M)&&i.jsx(Ab,{filter:l,set:N,all:o,trails:j,people:$,compact:r!=="wide"}),!M&&i.jsx(Ob,{rows:v,current:w,snaps:t.allSnaps,showTrail:r==="wide",onSelect:f}),(r!=="mobile"||w)&&i.jsx("div",{className:"dv-detail",children:w?i.jsx(Mb,{d:w,all:o,snap:t.allSnaps[w.mapId],onSelect:f,onOpenTicket:e.onOpenTicket,onSupersede:t.actions.supersede}):i.jsx(Ee,{children:"No decision selected"})})]})]})}function Bb({api:e,bp:t,nav:r}){return r.statsOpen?i.jsx(DS,{api:e,bp:t,onClose:()=>r.setStatsOpen(!1)}):r.decisionsView?i.jsx(Db,{api:e,bp:t,focus:r.decisionsView.focus,onClose:()=>r.setDecisionsView(null),onOpenTicket:r.openTicket}):null}function zb(e,t,r){const o=wp(),[l,c]=x.useState(()=>new URLSearchParams(location.search).has("projects")),d=l&&o.many&&i.jsx(SS,{projects:o,bp:e,onClose:()=>c(!1),onItemHere:r});return{projects:o,overview:d,openOverview:()=>{t.setDecisionsView(null),t.setStatsOpen(!1),c(!0)}}}function $p({activity:e,onTicket:t}){const r=e.feed.slice(-120).reverse();return r.length?i.jsx("div",{className:"log",children:r.map(o=>i.jsxs("div",{className:`log-row lv-${o.level} src-${o.source} ${o.signal?"signal":""}`,onClick:()=>o.ticketId&&t(o.ticketId),children:[i.jsx("span",{className:"t t-meta",children:Bo(o.at)}),i.jsx("span",{className:"src t-meta",children:o.agent??o.source}),i.jsxs("span",{className:"msg",title:o.tag?`${o.tag} · ${o.text}`:o.text,children:[o.tag&&i.jsxs("span",{className:"tag t-meta",children:[o.tag," · "]}),o.text]})]},o.id))}):i.jsx(Dn,{title:"Nothing has happened yet",hint:"Claims, steps, questions and decisions appear here as agents work."})}function qh({lease:e,now:t}){if(!e)return null;const r=Po(e,t);if(r==="live")return null;const o=e.expiresAt-t;return i.jsxs(zn,{tone:"amber",className:"stalled",title:`No activity from ${e.agent}; the ticket returns to the queue when the lease runs out`,children:["stalled · ",r==="expired"?"returning":Wt(o)]})}function Fb({total:e,step:t}){return i.jsx("span",{className:"segs","aria-label":`Step ${t} of ${e}`,children:Array.from({length:e},(r,o)=>i.jsx("i",{className:Ub(o+1,t)},o))})}function Ub(e,t){return e<t?"done":e===t?"cur":""}function Tp({snap:e,activity:t,leases:r,onSelect:o,onOpenChat:l}){var w;const c=sn(1e3),d=t.sessions.filter(tn),f=new Set(d.map(j=>j.ticketId)),g=xc(r,e==null?void 0:e.map.id),m=(e==null?void 0:e.tickets.filter(j=>j.state==="open"&&j.assignee&&!f.has(j.id)))??[];if(!d.length&&!m.length)return i.jsx(Ee,{children:"No agent on a ticket"});const v=j=>!!j&&Po(j,c)!=="live",y=!!((w=e==null?void 0:e.map.modelMatching)!=null&&w.enabled);return i.jsxs("ul",{className:"sessions-list",children:[d.map(j=>{const $=e==null?void 0:e.tickets.find(M=>M.id===j.ticketId),N=$?Wi($)==="hitl":!1,E=$&&g.get($.id);return i.jsx(Ae,{as:"li",className:j.waitingOn?"waiting":void 0,edge:Hb(j,v(E)),title:Vb($,j.mode)||j.agent,context:i.jsx(q,{parts:[{text:j.agent,strong:!0},y&&Wb(j),j.waitingOn?{text:"Waiting on you",urgent:!0}:`${j.mode} · ${j.stepLabel.toLowerCase()}`,N&&!j.waitingOn&&"with you",Kb(j)],children:i.jsx(qh,{lease:E,now:c})}),trailing:Im(c-j.startedAt),below:i.jsx(Fb,{total:j.total,step:j.step}),onOpen:()=>{$&&o({kind:"ticket",id:$.id}),N&&l(j.id)}},j.id)}),m.map(j=>i.jsx(Ae,{as:"li",className:"claim",edge:v(g.get(j.id))?"attention":"neutral",title:`${j.key} ${j.title}`,context:i.jsx(q,{parts:[{text:j.assignee??"",strong:!0},"claimed, no live session"],children:i.jsx(qh,{lease:g.get(j.id),now:c})}),onOpen:()=>o({kind:"ticket",id:j.id})},j.id))]})}function Hb(e,t){return e.waitingOn?"urgent":t?"attention":"neutral"}function Wb(e){const t=e.model?`Runs ${e.model}`:"No model reported, so it counts as balanced";return{text:e.tier??"balanced",tip:t,className:"session-tier"}}function Kb(e){if(e.usage)return`${zo(Uk(e))} tok · ${_s(e.usage.costUsd)}`}function Vb(e,t){return e?`${e.key} ${e.title}`:t==="chart"?"Charting trail":""}function Ep({activity:e,snap:t,running:r,usage:o=!0}){const l=fm(e,t==null?void 0:t.map.id),c=mm(e,t==null?void 0:t.map.id),d=new Set(e.sessions.filter(tn).map(g=>g.ticketId)),f=(t==null?void 0:t.tickets.filter(g=>g.state==="open"&&g.assignee&&!d.has(g.id)).length)??0;return i.jsx(Ct,{sub:!0,className:"sessions-head",title:i.jsxs(i.Fragment,{children:["Agents on tickets ",i.jsx("span",{className:"n",children:r+f})]}),right:o?i.jsxs("span",{className:"usage",title:["Model usage for this trail, all sessions",...c.map(g=>hm[g].text)].join(`
|
|
147
|
+
`),children:[i.jsx("span",{className:"mono-label",children:"Trail"})," ",zo(l.inputTokens+l.outputTokens)," tok · ",_s(l.costUsd)]}):void 0})}function Gb(e){const t=[...e.feed].reverse().find(r=>r.level==="step"&&r.sessionId);return t?e.sessions.find(r=>r.id===t.sessionId):void 0}const Qb={running:"Working",done:"Done",failed:"Stopped"};function Ip({activity:e,snap:t}){const r=Gb(e);if(!r)return i.jsx(Dn,{title:"No agent working yet",hint:"Run /scout resume in Claude Code or Codex. Each step an agent reports shows here."});const o=r.ticketId?t==null?void 0:t.tickets.find(d=>d.id===r.ticketId):void 0,l=Ao[r.mode],c=r.waitingOn?"Waiting on you":Qb[r.status];return i.jsxs("div",{className:`step-tracker ${r.waitingOn?"waiting":""}`,children:[i.jsxs("div",{className:"st-meta",children:[i.jsx(q,{parts:[{text:r.agent,strong:!0},`${r.mode}, step ${r.step} of ${r.total}`]}),i.jsx("span",{className:`t-label st-status ${r.waitingOn?"urgent":""}`,children:c})]}),i.jsxs("div",{className:"st-big",children:[r.stepLabel,o&&i.jsxs("span",{className:"st-key",children:[" ",o.key]})]}),o&&i.jsx("div",{className:"st-ticket t-meta",children:o.title}),i.jsx("ol",{className:"pipeline",children:l.map((d,f)=>{const g=f+1,m=g<r.step||g===r.step&&r.status==="done";let v="";return m?v="done":g===r.step&&(v="cur"),i.jsxs("li",{className:v,children:[i.jsx("i",{}),i.jsxs("span",{children:[String(g).padStart(2,"0")," ",d]})]},d)})})]})}function Yh(e){return i.jsxs("div",{className:"zone-b activity-stack",children:[i.jsx(Ip,{activity:e.activity,snap:e.snap}),i.jsx(Ep,{activity:e.activity,snap:e.snap,running:e.activity.sessions.filter(tn).length}),i.jsx(Tp,{snap:e.snap,activity:e.activity,leases:e.leases,onSelect:t=>(t==null?void 0:t.kind)==="ticket"&&e.onTicket(t.id),onOpenChat:e.onOpenChat}),i.jsx(Ct,{sub:!0,title:"Activity log"}),i.jsx($p,{activity:e.activity,onTicket:e.onTicket})]})}function qb(e){return i.jsx(zm,{area:"log",className:"log-zone",icon:"book",title:"Activity log",info:"Everything that happened in this trail, newest first: claims, steps, questions, decisions and errors.",right:i.jsxs("span",{className:"mono-label dim",children:[e.activity.feed.length," events"]}),children:i.jsx($p,{activity:e.activity,onTicket:e.onTicket})})}function Yb(e){var o;const t=e.activity.sessions.filter(tn).length,r=!e.activity.sessions.length&&!((o=e.snap)!=null&&o.tickets.some(l=>l.state==="open"&&l.assignee));return i.jsxs(Ke,{className:"zone step-zone",style:{gridArea:"step"},children:[i.jsx(Ct,{className:"zone-title",icon:"tent",title:"Current trail step",info:"What your agents are doing right now. The top shows the latest step an agent reported; below is every agent holding a ticket."}),i.jsxs("div",{className:"zone-b",children:[i.jsx(Ip,{activity:e.activity,snap:e.snap}),!r&&i.jsxs(i.Fragment,{children:[i.jsx(Ep,{activity:e.activity,snap:e.snap,running:t,usage:!1}),i.jsx(Tp,{snap:e.snap,activity:e.activity,leases:e.leases,onSelect:l=>(l==null?void 0:l.kind)==="ticket"&&e.onTicket(l.id),onOpenChat:e.onOpenChat})]})]})]})}const Jh=`${Se()}/criteria`;function Jb(e){const[t,r]=x.useState([]),o=x.useCallback(()=>{if(!e)return r([]);fetch(`${Jh}?mapId=${encodeURIComponent(e)}`).then(c=>c.ok?c.json():{tickets:[]}).then(c=>r(c.tickets)).catch(()=>r([]))},[e]);return x.useEffect(()=>(o(),pn(c=>c.startsWith("criteria/")&&o())),[o]),{tickets:t,confirm:c=>fetch(`${Jh}/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,...c})}).then(o)}}function Xb({snap:e,t}){const{tickets:r,confirm:o}=Jb(e.map.id),l=Ks(),c=r.find(m=>m.ticketId===t.id),d=(c==null?void 0:c.criteria)??[],g=Nm(l.entries,{trailKey:e.map.key,ticket:{type:t.type,title:t.title,body:t.body},paths:Sm(`${t.body}
|
|
148
|
+
${l.briefText}`)}).filter(m=>m.kind==="business-rule").filter(m=>jy(d,[m.id]).length);return!d.length&&!g.length?null:i.jsxs("div",{className:"criteria-section d-section",children:[i.jsxs("span",{className:"t-label","data-tip":"Agreed before the work starts; each needs evidence before the ticket counts as done",children:["Acceptance criteria · ",d.length,(c==null?void 0:c.confirmed)&&i.jsx("span",{className:"ok-text",children:" · confirmed by you"})]}),d.length>0&&i.jsx("ul",{className:"criteria-list item-list",children:d.map(m=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:m.text}),i.jsx(q,{parts:[{text:m.id,code:!0},m.kind.replace("-"," "),m.source&&`from ${m.source}`]})]},m.id))}),g.length>0&&i.jsxs("div",{className:"crit-uncovered edge-note edge-attention",children:[i.jsx("p",{className:"t-meta",children:"No criterion covers these rules yet:"}),i.jsx("ul",{className:"item-list",children:g.map(m=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:m.title}),i.jsx(q,{parts:[{text:m.id,code:!0},"business rule"]})]},m.id))})]}),d.length>0&&t.state==="open"&&i.jsx(K,{size:"sm",variant:c!=null&&c.confirmed?"ghost":"default","data-tip":c!=null&&c.confirmed?"Take your confirmation back":"Agree that these criteria define done for this ticket",onClick:()=>void o({title:e.map.title,ticketId:t.id,ticketKey:t.key,confirmed:!(c!=null&&c.confirmed)}),children:c!=null&&c.confirmed?"Unconfirm":"Confirm criteria"})]})}const To="";function Zb(e){const t=mc.map(o=>({value:o,label:Ui[o],hint:Xm[o]})),r=[...eC(e),...t];return i.jsx(ct,{compact:!0,className:"vf-level","aria-label":"Verification level",value:e.value??To,options:r,onChange:o=>e.onChange(o===To?null:o)})}function eC(e){return e.inherit!==void 0?[{value:To,label:e.inherit,hint:"Use the trail’s level for this ticket."}]:e.value===void 0?[{value:To,label:"Off (not set)"}]:[]}function tC({check:e}){const t=o0(e),[r,o]=x.useState(),[l,c]=x.useState(),d=nC(e);return i.jsxs("details",{className:`vf-row ${t?"ok":"bad"}`,open:!t,children:[i.jsxs("summary",{children:[i.jsx("span",{className:"vf-mark",children:t?"✓":"✕"}),i.jsx("span",{className:"t-code vf-name",children:e.name}),i.jsx("span",{className:"t-meta",children:d}),i.jsx("span",{className:"t-meta vf-dur",children:Wt(e.durationMs)})]}),i.jsx("code",{className:"vf-argv",children:e.argv.join(" ")}),e.error&&i.jsx("p",{className:"vf-note",children:e.error}),i.jsx("pre",{className:"vf-tail",children:r??(e.tail||"No output.")}),i.jsxs("div",{className:"vf-log-line",children:[r===void 0&&i.jsx("button",{className:"link",onClick:()=>Gi.log(e.log).then(f=>o(f.clipped?`[earlier output not shown]
|
|
149
|
+
${f.text}`:f.text),f=>c(f.message)),children:"Full log ›"}),e.truncated&&i.jsx("span",{className:"dim",children:"log capped at 1 MB"}),l&&i.jsx("span",{className:"vf-err",children:l})]})]})}function nC(e){return e.error?"did not start":e.timedOut?"timed out":`exit ${e.exitCode??e.signal??"?"}`}const Xh=e=>(e==null?void 0:e.slice(0,8))??"none",Zh=e=>e===null?"·":String(e);function sC({attempt:e}){const t=e.git;if(!t)return null;const{files:r,add:o,del:l}=t.stats;return i.jsxs("div",{className:"vf-git",children:[i.jsx(q,{parts:[t.tree?{text:`${t.base?`${Xh(t.base.head)} → `:""}${Xh(t.tree.head)}`,code:!0}:"not a git repo",t.tree&&{text:t.tree.branch??"detached HEAD",code:!!t.tree.branch},t.tree&&`${r} file${r===1?"":"s"} +${o} −${l}`]}),t.flags.filter(c=>c.kind!=="no-git").map(c=>{var d;return i.jsxs("p",{className:`vf-flag lv-${c.level}`,title:(d=c.files)==null?void 0:d.join(`
|
|
150
|
+
`),children:[i.jsx("span",{className:"t-code",children:c.kind})," ",c.message]},c.kind)}),t.changed.length>0&&i.jsxs("details",{className:"vf-files",children:[i.jsx("summary",{className:"t-label",children:"Changed files"}),i.jsx("ul",{children:t.changed.map(c=>i.jsxs("li",{children:[i.jsx("code",{children:c.path}),i.jsxs("span",{className:"dim",children:[c.untracked?"new":`+${Zh(c.add)} −${Zh(c.del)}`,c.dirtyAtClaim?" · dirty at claim":""]})]},c.path))})]})]})}function iC({attempt:e,latest:t}){return i.jsxs("details",{className:`vf-attempt r-${e.result}`,open:t,children:[i.jsxs("summary",{children:[i.jsx(zn,{tone:"state",className:`r-${e.result}`,children:r0[e.result]}),i.jsx(q,{parts:[{text:e.id,code:!0},e.agent,Vi(e.submittedAt),Wt(e.finishedAt-e.submittedAt)]})]}),i.jsx("p",{className:"vf-claim",children:e.summary??e.resolution}),e.note&&i.jsx("p",{className:"vf-note",children:e.note}),e.criteria&&i.jsx("ul",{className:"vf-criteria",children:e.criteria.lines.map(r=>i.jsx("li",{className:rC(r),children:r},r))}),i.jsx(sC,{attempt:e}),e.checks.map(r=>i.jsx(tC,{check:r},r.name))]})}function rC(e){return e.includes(" ✓ ")?"ok":e.includes(" ✗ ")?"bad":"wait"}const oC={PASS:"Passed",FAIL:"Sent back",NEEDS_HUMAN:"Needs you"};function aC({verdict:e}){const{guide:t,checklist:r}=e;return i.jsxs("div",{className:`vf-verdict v-${e.verdict.toLowerCase()}`,children:[i.jsx(q,{parts:[{text:e.byKind==="trail lead"&&e.verdict==="PASS"?"Approved":oC[e.verdict],strong:!0},{text:e.id,code:!0},e.byKind==="trail lead"?e.by:`review ${e.by}`,e.sessionId&&`session ${e.sessionId.slice(0,8)}`,t&&`as ${t.id} ${t.version}`,`on ${e.attemptId}`,Vi(e.at)]}),i.jsx("p",{children:e.summary}),e.findings.length>0&&i.jsx("ul",{className:"vf-findings",children:e.findings.map((o,l)=>i.jsxs("li",{className:`sev-${o.severity}`,children:[o.path&&i.jsx("code",{children:o.line?`${o.path}:${o.line}`:o.path})," ",o.text]},l))}),r&&r.length>0&&i.jsx(cp,{answers:r})]})}function lC(e,t,r){const[o,l]=x.useState(),c=x.useCallback(()=>{Gi.ticket(e,t).then(l)},[e,t]);return x.useEffect(()=>(l(void 0),c(),Bs.onEvidence(c)),[c]),x.useEffect(c,[c,r]),{data:o,reload:c}}const ql={rework:{label:"What to fix",submit:"Send to rework",hint:"Posted on the ticket for the next agent."},accept:{label:"Why accept",submit:"Accept anyway",hint:"Closes the ticket as done despite the checks."},unblock:{label:"Why",submit:"Unblock",hint:"Back to the queue without running checks."}};function cC(e){const[t,r]=x.useState(),[o,l]=x.useState(""),[c,d]=x.useState("rework"),{state:f,submitted:g,running:m,act:v}=e;if(m||f!=="verifying"&&f!=="held")return null;const y=j=>{r(t===j?void 0:j),l("")},w=j=>{j.preventDefault(),!(!t||!o.trim())&&(v({action:t,reason:o.trim(),...t==="unblock"?{to:c}:{}}),r(void 0))};return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"actions vf-actions",children:[f==="verifying"&&g&&i.jsx(K,{variant:"primary",onClick:()=>void v({action:"approve"}),"data-tip":"Checks passed: approve and close the ticket",children:"Approve"}),g&&i.jsx(K,{onClick:()=>void v({action:"rerun"}),"data-tip":"Run the repo's checks again on the current code",children:"Re-run checks"}),i.jsx(K,{on:t==="rework",onClick:()=>y("rework"),"data-tip":"Send it back to an agent with what to fix",children:"Rework…"}),f==="held"&&i.jsxs(i.Fragment,{children:[i.jsx(K,{on:t==="accept",onClick:()=>y("accept"),"data-tip":"Close it as done despite the failing checks",children:"Accept anyway…"}),i.jsx(K,{on:t==="unblock",onClick:()=>y("unblock"),"data-tip":"Put it back in the queue without running checks",children:"Unblock…"})]})]}),t&&i.jsxs(Ot,{as:"form",tone:"inset",className:"inline-form",onSubmit:w,children:[i.jsx(Ye,{label:ql[t].label,children:i.jsx("textarea",{rows:2,value:o,onChange:j=>l(j.target.value),autoFocus:!0})}),t==="unblock"&&i.jsx(Ye,{label:"Back to",children:i.jsx(ct,{"aria-label":"Back to",value:c,onChange:d,options:[{value:"rework",label:"Rework",hint:"Keeps the feedback for the next agent."},{value:"ready",label:"Ready",hint:"Back in the queue as a fresh ticket."}]})}),i.jsx("span",{className:"dim vf-hint",children:ql[t].hint}),i.jsxs("div",{className:"form-actions",children:[i.jsx(K,{variant:"ghost",onClick:()=>r(void 0),children:"Cancel"}),i.jsx(K,{type:"submit",variant:t==="accept"?"danger":"primary",disabled:!o.trim(),children:ql[t].submit})]})]})]})}const uC={ticket:"set on this ticket",trail:"from the trail",none:"not set"},dC=new Set(["verifying","rework","held"]);function fC(e){const{mapId:t,ticket:r,state:o}=e,{data:l,reload:c}=lC(t,r.id,r.updatedAt),[d,f]=x.useState();if(!l||l.level.level==="off"&&!l.attempts.length&&!dC.has(o))return null;const g=v=>(f(void 0),Gi.act({...v,mapId:t,ticketId:r.id,by:wt}).then(c,y=>f(y.message))),m=l.running;return i.jsxs("section",{className:"vf-panel",children:[i.jsxs("div",{className:"vf-head",children:[i.jsx(Je,{as:"h4",children:"Verification"}),i.jsx(q,{parts:[Ui[l.level.level],uC[l.level.source]]}),r.state==="open"&&i.jsx(Zb,{value:r.verification,inherit:`Trail (${Ui[e.trail??"off"]})`,onChange:v=>void g({action:"level",level:v})})]}),m&&i.jsxs("div",{className:"sync-line vf-running",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:["Checking ",m.id," for ",m.agent," · since ",Vi(m.startedAt)]})]}),i.jsx(cC,{state:o,submitted:l.attempts.length>0,running:!!m,act:g}),d&&i.jsx("p",{className:"vf-err",children:d}),l.verdicts.map(v=>i.jsx(aC,{verdict:v},v.id)),l.attempts.map((v,y)=>i.jsx(iC,{attempt:v,latest:y===0},v.id)),!l.attempts.length&&!m&&i.jsx(q,{parts:[`Checks: ${l.level.checks.join(", ")||"none"}`,"run when the ticket is submitted"]})]})}function hC({lease:e,onRelease:t}){const r=sn(1e3),o=Po(e,r),l=o==="live";return i.jsxs("div",{className:`lease lease-${o} edge-note ${l?"":"edge-attention"}`,children:[i.jsxs("div",{className:"edge-note-head",children:[i.jsx(q,{parts:[{text:`Claimed by ${e.agent}`,strong:!0},`active ${nn(r-e.renewedAt)} ago`]}),!l&&i.jsx(zn,{tone:"amber",children:"Stalled"})]}),i.jsx("p",{className:"t-meta lease-line",children:mC(o,pC(e.expiresAt-r))}),e.workspace&&i.jsxs("p",{className:"t-meta lease-branch",children:["Works on ",i.jsx("code",{className:"t-code",children:e.workspace.branch})," in its own worktree"]}),e.touches&&e.touches.length>0&&i.jsxs("p",{className:"t-meta lease-touches",children:["Expects to change"," ",e.touches.map((c,d)=>i.jsxs("span",{children:[d>0&&", ",i.jsx("code",{className:"t-code",children:c})]},c))]}),e.notes.length>0&&i.jsx("ul",{className:"lease-notes t-meta",children:e.notes.slice(-3).map((c,d)=>i.jsx("li",{children:c},d))}),i.jsx("div",{className:"actions",children:i.jsx(K,{variant:l?"default":"urgent",onClick:t,children:"Release to queue"})})]})}function mC(e,t){return e==="expired"?"Lease expired, going back to the queue":e==="stalled"?`The agent went quiet. Back in the queue in ${t}.`:`Back in the queue after ${t} without activity.`}function pC(e){const t=e/864e5;return t>=2?`${Math.round(t)} days`:Wt(Math.max(0,e))}function gC({comments:e}){if(!e.length)return null;const t=e.length>1?"s":"";return i.jsxs("details",{className:"comments",children:[i.jsxs("summary",{className:"t-label",children:[e.length," other comment",t]}),e.map(r=>i.jsxs("div",{className:"comment",children:[i.jsx(q,{parts:[{text:r.author,strong:!0}]}),i.jsx("div",{className:"c-body",children:r.body.replace(/\*\*/g,"")})]},r.id))]})}function vC({resolution:e,decisions:t,onOpenDecision:r}){const o=t.find(d=>!d.supersededBy)??t[0],l=e.body.startsWith("**Ruled")?"ruled out":"resolution",c=t.length>1?` · ${t.length} in chain`:"";return i.jsxs("div",{className:"resolution edge-note edge-done",children:[i.jsxs("div",{className:"edge-note-head",children:[i.jsx(q,{parts:[{text:e.author,strong:!0},l]}),o&&r&&i.jsxs("button",{className:"link t-meta",onClick:()=>r(o.id),children:[o.id,c," ›"]})]}),i.jsx("p",{children:e.body.replace(/^\*\*[^*]+\*\*\s*/,"")})]})}function kC(e){const{t,state:r,session:o,mine:l,form:c,setForm:d,actions:f,onOpenChat:g}=e;return i.jsxs("div",{className:"actions",children:[o&&i.jsx(K,{variant:o.waitingOn?"urgent":"default",onClick:()=>g(o.id),"data-tip":o.waitingOn?"The agent is waiting for your answer":"Open the conversation with this agent",children:o.waitingOn?"Answer":"Conversation"}),r==="frontier"&&i.jsx(K,{onClick:()=>f.claim(t.id),"data-tip":"Take this ticket yourself, so no agent picks it up",children:"Claim"}),(r==="frontier"||r==="claimed"&&l)&&i.jsx(K,{on:c==="resolve",onClick:()=>d(c==="resolve"?null:"resolve"),"data-tip":"Answer it yourself and close the ticket, with a decision record",children:"Resolve…"}),l&&r==="claimed"&&i.jsx(K,{onClick:()=>f.release(t.id),"data-tip":"Give the ticket back to the queue",children:"Release"}),(r==="frontier"||r==="blocked"||r==="parked")&&i.jsx(K,{variant:"danger",on:c==="rule",onClick:()=>d(c==="rule"?null:"rule"),"data-tip":"Move it out of scope. It's set aside with your reason, not deleted",children:"Rule out…"})]})}function yC(e){return e.replace(/\s*Part of trail \S+\.\s*$/,"").trim()}function xC({t:e,state:t,tickets:r}){const o=new Map(r.map(m=>[m.id,m])),l=m=>{var v;return((v=o.get(m))==null?void 0:v.key)??m},c=e.blockedBy.map(m=>{var v;return`${l(m)}${((v=o.get(m))==null?void 0:v.state)==="closed"?" ✓":""}`}).join(", "),d=r.filter(m=>m.blockedBy.includes(e.id)).map(m=>m.key).join(", "),f=[["Type",zi[e.type]],["Assignee",e.assignee],["Blocked by",c],["Blocks",d],["Reviews",e.reviewOf&&l(e.reviewOf)]],g=Wi(e)==="hitl";return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"d-head",children:[i.jsx("span",{className:"key t-code",children:e.key}),i.jsx(zn,{tone:"state",className:`st-${t}`,children:Am[t]}),i.jsx("span",{className:"d-att t-meta","data-tip":g?"A person takes this one":"An agent takes this alone",children:g?"Needs a person":"Agent work"})]}),i.jsx("h3",{className:"t-heading",children:e.title}),i.jsx("dl",{className:"facts",children:f.filter(([,m])=>m).flatMap(([m,v])=>[i.jsx("dt",{className:"t-label",children:m},`${m}-k`),i.jsx("dd",{children:v},`${m}-v`)])})]})}function wC(e){const{snap:t,api:r,form:o,setForm:l}=e,{actions:c}=r,[d,f]=x.useState(""),[g,m]=x.useState(""),[v,y]=x.useState(""),[w,j]=x.useState("Not needed to reach the destination."),$=t.tickets.find(F=>F.id===e.id);if(!$)return i.jsx(Ee,{children:"Ticket not found."});const N=Fs(t.tickets,t.map.mode).get($.id),E=e.sessions.find(F=>F.ticketId===$.id&&tn(F)),M=$.assignee===wt,R=$.state==="open"?xc(r.leases,t.map.id).get($.id):void 0,O=[...$.comments].reverse().find(F=>/^\*\*(Resolution|Ruled out of scope)\*\*/.test(F.body)),X=$.comments.filter(F=>F!==O),se=yC($.body),Q=r.decisions.filter(F=>F.mapId===t.map.id&&F.ticketId===$.id);return i.jsxs("div",{className:"detail",children:[i.jsx(xC,{t:$,state:N,tickets:t.tickets}),se&&i.jsxs("section",{className:"d-section ticket-body",children:[i.jsx("span",{className:"t-label",children:"Description"}),i.jsx("p",{className:"body",children:se})]}),i.jsx(MS,{mapId:t.map.id,ticketId:$.id}),i.jsx(Tw,{mapId:t.map.id,ticketId:$.id}),i.jsx(eS,{mapId:t.map.id,ticket:$}),i.jsx(Xb,{snap:t,t:$}),i.jsx(Fw,{snap:t,t:$}),$.closeReason==="not_planned"&&i.jsx($c,{label:"Save as dead end",draft:()=>{var F;return{title:`Ruled out: ${$.title}`,body:((F=$.comments.at(-1))==null?void 0:F.body)??$.body,kind:"dead-end",sources:[`trail:${t.map.key}`,`ticket:${$.key}`]}}}),R&&i.jsx(hC,{lease:R,onRelease:()=>c.releaseLease($.id)}),!R&&i.jsx(uS,{mapId:t.map.id,ticketId:$.id}),i.jsx(fC,{mapId:t.map.id,trail:t.map.verification,ticket:$,state:N}),i.jsx(kC,{t:$,state:N,session:E,mine:M,form:o,setForm:l,actions:c,onOpenChat:e.onOpenChat}),o==="resolve"&&i.jsxs(Ot,{as:"form",tone:"inset",className:"inline-form",onSubmit:F=>{F.preventDefault(),d.trim()&&(c.resolve($.id,d.trim(),{rationale:g.trim(),alternatives:v.split(`
|
|
151
|
+
`).map(ie=>ie.trim()).filter(Boolean)}),l(null),f(""),m(""),y(""))},children:[i.jsx(Ye,{label:"Resolution",children:i.jsx("textarea",{rows:3,value:d,onChange:F=>f(F.target.value),autoFocus:!0})}),i.jsx(Ye,{label:"Rationale",children:i.jsx("input",{value:g,onChange:F=>m(F.target.value)})}),i.jsx(Ye,{label:"Alternatives considered",children:i.jsx("textarea",{rows:2,value:v,onChange:F=>y(F.target.value),placeholder:"One per line"})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(K,{variant:"ghost",onClick:()=>l(null),children:"Cancel"}),i.jsx(K,{type:"submit",variant:"primary",disabled:!d.trim(),children:"Resolve"})]})]}),o==="rule"&&i.jsxs(Ot,{as:"form",tone:"inset",className:"inline-form",onSubmit:F=>{F.preventDefault(),c.ruleOut({ticketId:$.id},w),l(null)},children:[i.jsx(Ye,{label:"Reason",children:i.jsx("input",{value:w,onChange:F=>j(F.target.value),autoFocus:!0})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(K,{variant:"ghost",onClick:()=>l(null),children:"Cancel"}),i.jsx(K,{type:"submit",variant:"danger",children:"Rule out"})]})]}),O&&i.jsx(vC,{resolution:O,decisions:Q,onOpenDecision:e.onOpenDecision}),i.jsx(gC,{comments:X})]})}function jC({snap:e,item:t,api:r}){const o=am(e.map.mode),[l,c]=x.useState("research"),[d,f]=x.useState(t),[g,m]=x.useState(!1),[v,y]=x.useState([]),[w,j]=x.useState("Not needed to reach the destination.");x.useEffect(()=>f(t),[t]);const $=e.tickets.filter(N=>N.state==="open");return i.jsxs("div",{className:"detail",children:[i.jsx("div",{className:"d-head",children:i.jsx(zn,{tone:"state",className:"st-unspecified",children:"Not yet specified"})}),i.jsx("h3",{className:"t-heading",children:t}),i.jsxs(Ot,{as:"form",tone:"inset",className:"inline-form",onSubmit:N=>{N.preventDefault(),r.actions.graduate({unspecified:t,type:l,title:d,blockedBy:v,hitl:g})},children:[i.jsx(Ye,{label:"Title",children:i.jsx("input",{value:d,onChange:N=>f(N.target.value)})}),i.jsxs("div",{className:"chips",children:[o.map(N=>i.jsx("button",{type:"button",className:`chip ${l===N?"on":""}`,onClick:()=>c(N),children:N},N)),Bv.includes(l)&&i.jsx("button",{type:"button",className:`chip ${g?"on":""}`,onClick:()=>m(N=>!N),children:"needs human"})]}),i.jsx("span",{className:"field",children:"Blocked by"}),i.jsx("div",{className:"chips",children:$.map(N=>i.jsx("button",{type:"button",className:`chip ${v.includes(N.id)?"on":""}`,onClick:()=>y(E=>E.includes(N.id)?E.filter(M=>M!==N.id):[...E,N.id]),children:N.key},N.id))}),i.jsx("div",{className:"form-actions",children:i.jsx(K,{type:"submit",variant:"primary",children:"Promote to ticket"})})]}),i.jsxs(Ot,{as:"form",tone:"inset",className:"inline-form",onSubmit:N=>{N.preventDefault(),r.actions.ruleOut({unspecified:t},w)},children:[i.jsx(Ye,{label:"Reason",children:i.jsx("input",{value:w,onChange:N=>j(N.target.value)})}),i.jsx("div",{className:"form-actions",children:i.jsx(K,{type:"submit",variant:"danger",children:"Rule out"})})]})]})}function NC({api:e,sessions:t,bare:r,onOpenChat:o,onOpenDecision:l}){const{snap:c,selection:d,actions:f}=e,[g,m]=x.useState(null),v=SC(d);x.useEffect(()=>m(null),[v]);let y;return c?d?d.kind==="unspecified"?y=i.jsx(jC,{snap:c,item:d.item,api:e}):y=i.jsx(wC,{snap:c,id:d.id,api:e,sessions:t,form:g,setForm:m,onOpenChat:o??f.openChat,onOpenDecision:l}):y=i.jsx(Dn,{title:"No ticket selected",hint:"Pick a ticket on the map: what it is, who has it, what blocks it, and its decision."}):y=i.jsx(Dn,{title:"No trail yet",hint:"Once there's a trail, pick a ticket on the map to see it here."}),i.jsx(zm,{area:"inspector",icon:"note",title:"Trail step",info:"The ticket you selected on the map: what it is, who has it, what blocks it, and its decision once it's made.",className:"inspector",bare:r,children:y})}function SC(e){return(e==null?void 0:e.kind)==="ticket"?e.id:(e==null?void 0:e.kind)==="unspecified"?e.item:""}const bC={holding:"Holding",challenged:"Challenged",invalidated:"Invalidated",confirmed:"Confirmed"};function CC(e){if(e.decidedBy)return e.status==="invalidated"?`invalidated by ${e.decidedBy}`:e.status==="confirmed"?`confirmed by ${e.decidedBy==="trail lead"?"you":e.decidedBy}`:`kept by ${e.decidedBy}`}function $C(e){const{a:t,snap:r}=e,o=t.tickets.flatMap(c=>r.tickets.filter(d=>d.id===c)),l=t.challenge&&`${t.challenge.by}: ${t.challenge.evidence}`;return i.jsx(Ae,{as:"li",className:`assumption st-${t.status}`,edge:t.status==="challenged"?"attention":"neutral",title:t.text,titleText:t.text,context:i.jsx(q,{parts:[{text:t.id,code:!0},bC[t.status],CC(t)],children:o.length>0&&i.jsxs("span",{className:"assumption-tickets",children:[i.jsx("span",{className:"sep",children:" · "}),"relied on by",o.map(c=>i.jsx("button",{className:"link t-code",onClick:()=>e.onSelect({kind:"ticket",id:c.id}),children:c.key},c.id))]})}),detail:l,detailText:l,actions:e.onConfirm&&i.jsx(K,{size:"sm",variant:"ghost",disabled:e.busy,onClick:e.onConfirm,children:"Confirm"})})}function TC(e){const[t,r]=x.useState(),[o,l]=x.useState();return{confirm:async d=>{l(d);const f=await fetch(`${Se()}/assumptions/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,id:d})}).catch(()=>{});if(l(void 0),f!=null&&f.ok)return r(void 0);const g=await(f==null?void 0:f.json().catch(()=>({})));r((g==null?void 0:g.error)??"Could not confirm it; is the Lookout connected?")},busy:o,error:t}}function EC({snap:e,onSelect:t}){const{confirm:r,busy:o,error:l}=TC(e.map.id),c=e.map.sections.assumptions??[];return c.length?i.jsxs(i.Fragment,{children:[l&&i.jsx("p",{className:"urgent-text",children:l}),i.jsx("ul",{className:"assumptions row-list",children:c.map(d=>{const f=d.status==="holding"||d.status==="challenged";return i.jsx($C,{a:d,snap:e,onSelect:t,onConfirm:f?()=>void r(d.id):void 0,busy:o===d.id},d.id)})})]}):i.jsx(Ee,{children:"None yet. They come from the accepted discovery brief or the trail's start."})}function IC(e){const[,t,r=e]=/^(#\d+)\s+(.+)$/.exec(e)??[],[o=r,...l]=r.split(/\s+[—–]\s+/);return{key:t,title:o,reason:l.join(" — ")||void 0}}function MC(e){const[t,r]=x.useState([]),o=e==null?void 0:e.map.id,l=(e==null?void 0:e.tickets.reduce((c,d)=>Math.max(c,d.updatedAt),e.map.updatedAt))??0;return x.useEffect(()=>{if(!o)return;let c=!0;return fetch(`${Se()}/journal?mapId=${encodeURIComponent(o)}`).then(d=>d.ok?d.json():{entries:[]}).then(d=>c&&r(d.entries)).catch(()=>c&&r([])),()=>{c=!1}},[o,l]),t}function AC({snap:e,activity:t,onTicket:r}){const o=MC(e),l=t.usageByMap[e.map.id],c=x.useMemo(()=>vm({snap:e,journal:o,answered:t.answered,usage:l}),[e,o,t.answered,l]),d=c.interventions,f=[["Done",`${c.done}`,`${c.done} done · ${c.cancelled} cancelled · ${c.open} open`],["Lead time",en(c.trailLeadMs),"Trail lead time: from when the trail was charted to its last done ticket"],["Median ticket",en(c.medianLeadMs),"Median time from a ticket's first claim to done"],["Interventions",`${d.total}`,`${d.answers} agent questions you answered + ${d.operatorActions} lifecycle calls you made (approve, send back, accept, unblock, cancel, release), of which ${d.reworkRequested} sent work back. Answers count while their sessions are on record.`],["Rework",`${c.rework.cycles}`,`Times work went back to rework, on ${c.rework.tickets} tickets`],["Reviews",`${c.reviews.passed}/${c.reviews.failed}`,`${c.reviews.passed} passed, ${c.reviews.failed} failed, ${c.reviews.needsHuman} needed you`],["Cost / ticket",c.spend.perVerifiedTicketUsd===void 0?"—":_s(c.spend.perVerifiedTicketUsd),`Cost per verified ticket: trail spend ${_s(c.spend.costUsd)} ÷ ${c.done} done tickets`]];return i.jsxs("div",{className:"report",children:[i.jsx("ul",{className:"report-stats",children:f.map(([g,m,v])=>i.jsxs("li",{"data-tip":v,children:[i.jsx("span",{className:"mono-label",children:g}),i.jsx("b",{children:m})]},g))}),i.jsxs("div",{className:"report-bar",children:[i.jsx("span",{className:"mono-label",children:"Tickets"}),i.jsx(K,{size:"sm",variant:"ghost","data-tip":"Download this report as markdown",onClick:()=>Em(`${e.map.key.replace("#","trail-")}-report.md`,dy(c,e.map.title)),children:"Export markdown"})]}),c.tickets.length?i.jsx("ul",{className:"list report-tickets",children:c.tickets.map(g=>i.jsx("li",{className:`out-${g.outcome}`,children:i.jsxs("button",{onClick:()=>r(g.id),"data-tip":`${g.outcome} · rework ${g.reworks} · reviews ${g.reviews.passed}/${g.reviews.failed} · your calls ${g.operatorActions}`,children:[i.jsx("span",{className:"key",children:g.key}),i.jsx("span",{className:"ttl",children:g.title}),i.jsx("span",{className:"lead",children:g.outcome==="done"?en(g.leadMs):g.outcome})]})},g.id))}):i.jsx(Ee,{children:"No tickets yet"})]})}function LC({tab:e,snap:t,selection:r,onSelect:o,activity:l}){const c=t.map.sections;switch(e){case"report":return l?i.jsx(AC,{snap:t,activity:l,onTicket:d=>o({kind:"ticket",id:d})}):i.jsx(Ee,{children:"No activity yet"});case"assumptions":return i.jsx(EC,{snap:t,onSelect:o});case"decisions":return c.decisions.length?i.jsx("ol",{className:"row-list decisions",children:[...c.decisions].reverse().map((d,f)=>i.jsx(Ae,{as:"li",title:d.text,titleText:d.text,context:d.ticketKey&&i.jsx(q,{parts:[{text:d.ticketKey,code:!0}]}),onOpen:d.ticketId?()=>o({kind:"ticket",id:d.ticketId}):void 0},`${d.ticketKey}-${f}`))}):i.jsx(Ee,{children:"None"});case"unspecified":return c.unspecified.length?i.jsx("ul",{className:"row-list unspecified",children:c.unspecified.map(d=>i.jsx(Ae,{as:"li",title:d,titleText:d,selected:(r==null?void 0:r.kind)==="unspecified"&&r.item===d,onOpen:()=>o({kind:"unspecified",item:d})},d))}):i.jsx(Ee,{children:"None"});case"oos":return c.outOfScope.length?i.jsx("ul",{className:"row-list oos",children:c.outOfScope.map(d=>{const f=IC(d);return i.jsx(Ae,{as:"li",title:f.title,titleText:d,context:i.jsx(q,{parts:[f.key&&{text:f.key,code:!0},f.reason]})},d)})}):i.jsx(Ee,{children:"None"});case"notes":return i.jsx("p",{className:"notes t-body",children:c.notes||"No notes yet."});default:return e}}function RC({snap:e,selection:t,onSelect:r,bare:o,onAudit:l,activity:c}){var y;const[d,f]=x.useState("unspecified"),g=e==null?void 0:e.map.sections,m=[{id:"unspecified",label:"Not yet specified",n:g==null?void 0:g.unspecified.length},{id:"assumptions",label:"Assumptions",n:(y=g==null?void 0:g.assumptions)==null?void 0:y.length},{id:"decisions",label:"Decisions",n:g==null?void 0:g.decisions.length},{id:"oos",label:"Out of scope",n:g==null?void 0:g.outOfScope.length},{id:"notes",label:"Notes"},{id:"report",label:"Report"}],v=e?i.jsx(LC,{tab:d,snap:e,selection:t,onSelect:r,activity:c}):i.jsx(Dn,{title:"No plan yet",hint:"Open questions, decisions, what's ruled out, notes and the trail report collect here."});return i.jsxs(Ke,{className:`zone sections ${o?"bare":""}`,style:o?void 0:{gridArea:"plan"},children:[!o&&i.jsx(Ct,{className:"zone-title",icon:"flag",title:"Trail plan",info:"The parts of the plan that aren't tickets yet: open questions still to specify, the assumptions the plan relies on, decisions already made, what's ruled out, and notes. Report shows how the trail is going: lead times, your interventions, rework, reviews and cost per verified ticket."}),i.jsxs("div",{className:"sections-tabs",children:[i.jsx(ct,{compact:!0,"aria-label":"Plan section",value:d,onChange:f,options:m.map(w=>({value:w.id,label:w.n===void 0?w.label:`${w.label} · ${w.n}`}))}),d==="decisions"&&l&&i.jsx("button",{className:"link",onClick:l,children:"Audit ›"})]}),i.jsx("div",{className:"zone-b",children:v})]})}function OC(){var ae;const e=x.useMemo(()=>sw(nw()),[]),t=pw(e),{snap:r,activity:o,selection:l,actions:c}=t,[d,f]=gw();x.useEffect(()=>Lm(d.theme),[d.theme]);const g=nb(),[m,v]=x.useState(!1),y=rb(e.kind),w=dw(),j=o.pending.length,$=ob(o,t.mapId);ib(j,r==null?void 0:r.map.title);const N=sb(t,w),E=Cb(r,c.selectMap),M=Vw(E.briefText),R=Ib({api:t,nav:N,knowledge:M,reviewBrief:E.review,openReroute:Z=>E.openReroute(Z.mapId,Z.ref),openGuides:()=>g.open("guides"),openFocusSettings:()=>g.open("attention")}),O=hw(e,t,d.briefing,(ae=R.attention.view)==null?void 0:ae.items),X=i.jsx(m0,{api:t,nav:N,bp:w,scoped:$,attn:R,above:E.inboxCard}),se=i.jsx(X1,{api:t,sessions:$.sessions,onSelect:N.select,onNewTrail:()=>v(!0),compact:w==="mobile",minFit:w==="mobile"?.7:0,trail:E}),Q=Z=>i.jsx(NC,{api:t,sessions:$.sessions,bare:Z,onOpenChat:U=>N.openChat(U),onOpenDecision:N.openDecisions}),F={activity:$,snap:r,leases:t.leases,onTicket:Z=>N.select({kind:"ticket",id:Z}),onOpenChat:Z=>N.openChat(Z)},ie=Z=>i.jsx(RC,{snap:r,selection:l,onSelect:N.select,bare:Z,onAudit:()=>N.openDecisions(),activity:$}),{projects:V,overview:ge,openOverview:Re}=zb(w,N,R.link.request),be=g.route&&i.jsx(t1,{rt:e,api:t,bp:w,prefs:d,update:f,settings:g}),te=(N.statsOpen||N.decisionsView)&&i.jsx(Bb,{api:t,bp:w,nav:N}),P=be||ge||te,Y=O.shown&&i.jsx(Cw,{brief:O,snaps:t.allSnaps,bp:w,openTicket:N.openTicket,openChat:N.openChat,openDecisions:N.openDecisions,closeDecisions:()=>N.setDecisionsView(null),showPhoneHome:()=>N.setPhoneTab("home")});return i.jsx(Um.Provider,{value:M,children:i.jsxs("div",{className:`app bp-${w}`,children:[i.jsx(xj,{api:t,rt:e,repo:i.jsx(bS,{repo:y,projects:V,onOverview:Re}),brief:O,attention:R.header,decisionsOpen:!!N.decisionsView,onDecisions:()=>{g.close(),N.decisionsView?N.setDecisionsView(null):N.openDecisions()},onStats:()=>{g.close(),N.toggleStats()},onNewTrail:()=>v(!0),onSettings:g.toggle,onSlack:()=>g.open("slack"),onToggleTheme:Z=>f({theme:Z?"night":"day"})}),w==="wide"&&i.jsxs(i.Fragment,{children:[X,se,Q(!1),i.jsx(Yb,{...F}),i.jsx(qb,{...F}),ie(!1),P]}),w==="laptop"&&i.jsxs(i.Fragment,{children:[X,se,i.jsx(n1,{tab:N.sideTab,onTab:N.setSideTab,unspecified:r==null?void 0:r.map.sections.unspecified.length,ticket:Q(!0),activity:i.jsx(Yh,{...F}),plan:ie(!0)}),P]}),w==="mobile"&&i.jsxs(i.Fragment,{children:[i.jsx(tb,{tab:N.phoneTab,decisions:P,inbox:X,projects:V.many&&i.jsx($S,{projects:V,onOverview:Re}),map:se,ticket:Q(!0),activity:i.jsx(Yh,{...F}),plan:ie(!0)}),i.jsx(eb,{tab:N.phoneTab,covered:!!P,pending:j,onPick:Z=>{g.close(),N.setPhoneTab(Z),N.setDecisionsView(null)}})]}),Y,E.dialog,t.error&&i.jsx("div",{className:"error-toast",children:t.error}),m&&i.jsx(w0,{rt:e,onClose:()=>v(!1),onCreated:Z=>c.selectMap(Z)}),!d.onboarded&&i.jsx(dN,{prefs:d,update:f,activeTracker:e.kind}),i.jsx(Kw,{})]})})}Lm(jc().theme);Pv.createRoot(document.getElementById("root")).render(i.jsxs(i.Fragment,{children:[i.jsx(OC,{}),i.jsx(ww,{})]}));
|