@abstractframework/code 0.11.0 → 0.11.1
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.
- package/dist/assets/index-DsTMDyHq.js +92 -0
- package/dist/index.html +1 -1
- package/dist/llms.txt +1 -1
- package/package.json +3 -2
- package/dist/assets/index-CByxvQB0.js +0 -92
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
var Kv=Object.defineProperty;var Jv=(e,t,n)=>t in e?Kv(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Mn=(e,t,n)=>Jv(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const c of i)if(c.type==="childList")for(const u of c.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&r(u)}).observe(document,{childList:!0,subtree:!0});function n(i){const c={};return i.integrity&&(c.integrity=i.integrity),i.referrerPolicy&&(c.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?c.credentials="include":i.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function r(i){if(i.ep)return;i.ep=!0;const c=n(i);fetch(i.href,c)}})();function Cg(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var jd={exports:{}},li={},Sd={exports:{}},Ge={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react.production.min.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var Qm;function Qv(){if(Qm)return Ge;Qm=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),u=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),v=Symbol.iterator;function _(D){return D===null||typeof D!="object"?null:(D=v&&D[v]||D["@@iterator"],typeof D=="function"?D:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,x={};function j(D,I,W){this.props=D,this.context=I,this.refs=x,this.updater=W||b}j.prototype.isReactComponent={},j.prototype.setState=function(D,I){if(typeof D!="object"&&typeof D!="function"&&D!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,D,I,"setState")},j.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function N(){}N.prototype=j.prototype;function $(D,I,W){this.props=D,this.context=I,this.refs=x,this.updater=W||b}var S=$.prototype=new N;S.constructor=$,C(S,j.prototype),S.isPureReactComponent=!0;var E=Array.isArray,A=Object.prototype.hasOwnProperty,R={current:null},z={key:!0,ref:!0,__self:!0,__source:!0};function L(D,I,W){var me,q={},fe=null,de=null;if(I!=null)for(me in I.ref!==void 0&&(de=I.ref),I.key!==void 0&&(fe=""+I.key),I)A.call(I,me)&&!z.hasOwnProperty(me)&&(q[me]=I[me]);var ae=arguments.length-2;if(ae===1)q.children=W;else if(1<ae){for(var we=Array(ae),Pe=0;Pe<ae;Pe++)we[Pe]=arguments[Pe+2];q.children=we}if(D&&D.defaultProps)for(me in ae=D.defaultProps,ae)q[me]===void 0&&(q[me]=ae[me]);return{$$typeof:e,type:D,key:fe,ref:de,props:q,_owner:R.current}}function J(D,I){return{$$typeof:e,type:D.type,key:I,ref:D.ref,props:D.props,_owner:D._owner}}function V(D){return typeof D=="object"&&D!==null&&D.$$typeof===e}function O(D){var I={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function(W){return I[W]})}var ee=/\/+/g;function P(D,I){return typeof D=="object"&&D!==null&&D.key!=null?O(""+D.key):I.toString(36)}function Z(D,I,W,me,q){var fe=typeof D;(fe==="undefined"||fe==="boolean")&&(D=null);var de=!1;if(D===null)de=!0;else switch(fe){case"string":case"number":de=!0;break;case"object":switch(D.$$typeof){case e:case t:de=!0}}if(de)return de=D,q=q(de),D=me===""?"."+P(de,0):me,E(q)?(W="",D!=null&&(W=D.replace(ee,"$&/")+"/"),Z(q,I,W,"",function(Pe){return Pe})):q!=null&&(V(q)&&(q=J(q,W+(!q.key||de&&de.key===q.key?"":(""+q.key).replace(ee,"$&/")+"/")+D)),I.push(q)),1;if(de=0,me=me===""?".":me+":",E(D))for(var ae=0;ae<D.length;ae++){fe=D[ae];var we=me+P(fe,ae);de+=Z(fe,I,W,we,q)}else if(we=_(D),typeof we=="function")for(D=we.call(D),ae=0;!(fe=D.next()).done;)fe=fe.value,we=me+P(fe,ae++),de+=Z(fe,I,W,we,q);else if(fe==="object")throw I=String(D),Error("Objects are not valid as a React child (found: "+(I==="[object Object]"?"object with keys {"+Object.keys(D).join(", ")+"}":I)+"). If you meant to render a collection of children, use an array instead.");return de}function U(D,I,W){if(D==null)return D;var me=[],q=0;return Z(D,me,"","",function(fe){return I.call(W,fe,q++)}),me}function te(D){if(D._status===-1){var I=D._result;I=I(),I.then(function(W){(D._status===0||D._status===-1)&&(D._status=1,D._result=W)},function(W){(D._status===0||D._status===-1)&&(D._status=2,D._result=W)}),D._status===-1&&(D._status=0,D._result=I)}if(D._status===1)return D._result.default;throw D._result}var se={current:null},G={transition:null},ce={ReactCurrentDispatcher:se,ReactCurrentBatchConfig:G,ReactCurrentOwner:R};function re(){throw Error("act(...) is not supported in production builds of React.")}return Ge.Children={map:U,forEach:function(D,I,W){U(D,function(){I.apply(this,arguments)},W)},count:function(D){var I=0;return U(D,function(){I++}),I},toArray:function(D){return U(D,function(I){return I})||[]},only:function(D){if(!V(D))throw Error("React.Children.only expected to receive a single React element child.");return D}},Ge.Component=j,Ge.Fragment=n,Ge.Profiler=i,Ge.PureComponent=$,Ge.StrictMode=r,Ge.Suspense=h,Ge.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ce,Ge.act=re,Ge.cloneElement=function(D,I,W){if(D==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+D+".");var me=C({},D.props),q=D.key,fe=D.ref,de=D._owner;if(I!=null){if(I.ref!==void 0&&(fe=I.ref,de=R.current),I.key!==void 0&&(q=""+I.key),D.type&&D.type.defaultProps)var ae=D.type.defaultProps;for(we in I)A.call(I,we)&&!z.hasOwnProperty(we)&&(me[we]=I[we]===void 0&&ae!==void 0?ae[we]:I[we])}var we=arguments.length-2;if(we===1)me.children=W;else if(1<we){ae=Array(we);for(var Pe=0;Pe<we;Pe++)ae[Pe]=arguments[Pe+2];me.children=ae}return{$$typeof:e,type:D.type,key:q,ref:fe,props:me,_owner:de}},Ge.createContext=function(D){return D={$$typeof:u,_currentValue:D,_currentValue2:D,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},D.Provider={$$typeof:c,_context:D},D.Consumer=D},Ge.createElement=L,Ge.createFactory=function(D){var I=L.bind(null,D);return I.type=D,I},Ge.createRef=function(){return{current:null}},Ge.forwardRef=function(D){return{$$typeof:d,render:D}},Ge.isValidElement=V,Ge.lazy=function(D){return{$$typeof:p,_payload:{_status:-1,_result:D},_init:te}},Ge.memo=function(D,I){return{$$typeof:m,type:D,compare:I===void 0?null:I}},Ge.startTransition=function(D){var I=G.transition;G.transition={};try{D()}finally{G.transition=I}},Ge.unstable_act=re,Ge.useCallback=function(D,I){return se.current.useCallback(D,I)},Ge.useContext=function(D){return se.current.useContext(D)},Ge.useDebugValue=function(){},Ge.useDeferredValue=function(D){return se.current.useDeferredValue(D)},Ge.useEffect=function(D,I){return se.current.useEffect(D,I)},Ge.useId=function(){return se.current.useId()},Ge.useImperativeHandle=function(D,I,W){return se.current.useImperativeHandle(D,I,W)},Ge.useInsertionEffect=function(D,I){return se.current.useInsertionEffect(D,I)},Ge.useLayoutEffect=function(D,I){return se.current.useLayoutEffect(D,I)},Ge.useMemo=function(D,I){return se.current.useMemo(D,I)},Ge.useReducer=function(D,I,W){return se.current.useReducer(D,I,W)},Ge.useRef=function(D){return se.current.useRef(D)},Ge.useState=function(D){return se.current.useState(D)},Ge.useSyncExternalStore=function(D,I,W){return se.current.useSyncExternalStore(D,I,W)},Ge.useTransition=function(){return se.current.useTransition()},Ge.version="18.3.1",Ge}var Ym;function Cf(){return Ym||(Ym=1,Sd.exports=Qv()),Sd.exports}/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.production.min.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var Xm;function Yv(){if(Xm)return li;Xm=1;var e=Cf(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function u(d,h,m){var p,v={},_=null,b=null;m!==void 0&&(_=""+m),h.key!==void 0&&(_=""+h.key),h.ref!==void 0&&(b=h.ref);for(p in h)r.call(h,p)&&!c.hasOwnProperty(p)&&(v[p]=h[p]);if(d&&d.defaultProps)for(p in h=d.defaultProps,h)v[p]===void 0&&(v[p]=h[p]);return{$$typeof:t,type:d,key:_,ref:b,props:v,_owner:i.current}}return li.Fragment=n,li.jsx=u,li.jsxs=u,li}var qm;function Xv(){return qm||(qm=1,jd.exports=Yv()),jd.exports}var a=Xv(),y=Cf();const lt=Cg(y);var rc={},Nd={exports:{}},_n={},Cd={exports:{}},Ed={};/**
|
|
18
|
+
* @license React
|
|
19
|
+
* scheduler.production.min.js
|
|
20
|
+
*
|
|
21
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
22
|
+
*
|
|
23
|
+
* This source code is licensed under the MIT license found in the
|
|
24
|
+
* LICENSE file in the root directory of this source tree.
|
|
25
|
+
*/var Zm;function qv(){return Zm||(Zm=1,(function(e){function t(G,ce){var re=G.length;G.push(ce);e:for(;0<re;){var D=re-1>>>1,I=G[D];if(0<i(I,ce))G[D]=ce,G[re]=I,re=D;else break e}}function n(G){return G.length===0?null:G[0]}function r(G){if(G.length===0)return null;var ce=G[0],re=G.pop();if(re!==ce){G[0]=re;e:for(var D=0,I=G.length,W=I>>>1;D<W;){var me=2*(D+1)-1,q=G[me],fe=me+1,de=G[fe];if(0>i(q,re))fe<I&&0>i(de,q)?(G[D]=de,G[fe]=re,D=fe):(G[D]=q,G[me]=re,D=me);else if(fe<I&&0>i(de,re))G[D]=de,G[fe]=re,D=fe;else break e}}return ce}function i(G,ce){var re=G.sortIndex-ce.sortIndex;return re!==0?re:G.id-ce.id}if(typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var u=Date,d=u.now();e.unstable_now=function(){return u.now()-d}}var h=[],m=[],p=1,v=null,_=3,b=!1,C=!1,x=!1,j=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,$=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function S(G){for(var ce=n(m);ce!==null;){if(ce.callback===null)r(m);else if(ce.startTime<=G)r(m),ce.sortIndex=ce.expirationTime,t(h,ce);else break;ce=n(m)}}function E(G){if(x=!1,S(G),!C)if(n(h)!==null)C=!0,te(A);else{var ce=n(m);ce!==null&&se(E,ce.startTime-G)}}function A(G,ce){C=!1,x&&(x=!1,N(L),L=-1),b=!0;var re=_;try{for(S(ce),v=n(h);v!==null&&(!(v.expirationTime>ce)||G&&!O());){var D=v.callback;if(typeof D=="function"){v.callback=null,_=v.priorityLevel;var I=D(v.expirationTime<=ce);ce=e.unstable_now(),typeof I=="function"?v.callback=I:v===n(h)&&r(h),S(ce)}else r(h);v=n(h)}if(v!==null)var W=!0;else{var me=n(m);me!==null&&se(E,me.startTime-ce),W=!1}return W}finally{v=null,_=re,b=!1}}var R=!1,z=null,L=-1,J=5,V=-1;function O(){return!(e.unstable_now()-V<J)}function ee(){if(z!==null){var G=e.unstable_now();V=G;var ce=!0;try{ce=z(!0,G)}finally{ce?P():(R=!1,z=null)}}else R=!1}var P;if(typeof $=="function")P=function(){$(ee)};else if(typeof MessageChannel<"u"){var Z=new MessageChannel,U=Z.port2;Z.port1.onmessage=ee,P=function(){U.postMessage(null)}}else P=function(){j(ee,0)};function te(G){z=G,R||(R=!0,P())}function se(G,ce){L=j(function(){G(e.unstable_now())},ce)}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(G){G.callback=null},e.unstable_continueExecution=function(){C||b||(C=!0,te(A))},e.unstable_forceFrameRate=function(G){0>G||125<G?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):J=0<G?Math.floor(1e3/G):5},e.unstable_getCurrentPriorityLevel=function(){return _},e.unstable_getFirstCallbackNode=function(){return n(h)},e.unstable_next=function(G){switch(_){case 1:case 2:case 3:var ce=3;break;default:ce=_}var re=_;_=ce;try{return G()}finally{_=re}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(G,ce){switch(G){case 1:case 2:case 3:case 4:case 5:break;default:G=3}var re=_;_=G;try{return ce()}finally{_=re}},e.unstable_scheduleCallback=function(G,ce,re){var D=e.unstable_now();switch(typeof re=="object"&&re!==null?(re=re.delay,re=typeof re=="number"&&0<re?D+re:D):re=D,G){case 1:var I=-1;break;case 2:I=250;break;case 5:I=1073741823;break;case 4:I=1e4;break;default:I=5e3}return I=re+I,G={id:p++,callback:ce,priorityLevel:G,startTime:re,expirationTime:I,sortIndex:-1},re>D?(G.sortIndex=re,t(m,G),n(h)===null&&G===n(m)&&(x?(N(L),L=-1):x=!0,se(E,re-D))):(G.sortIndex=I,t(h,G),C||b||(C=!0,te(A))),G},e.unstable_shouldYield=O,e.unstable_wrapCallback=function(G){var ce=_;return function(){var re=_;_=ce;try{return G.apply(this,arguments)}finally{_=re}}}})(Ed)),Ed}var ep;function Zv(){return ep||(ep=1,Cd.exports=qv()),Cd.exports}/**
|
|
26
|
+
* @license React
|
|
27
|
+
* react-dom.production.min.js
|
|
28
|
+
*
|
|
29
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
30
|
+
*
|
|
31
|
+
* This source code is licensed under the MIT license found in the
|
|
32
|
+
* LICENSE file in the root directory of this source tree.
|
|
33
|
+
*/var tp;function e_(){if(tp)return _n;tp=1;var e=Cf(),t=Zv();function n(s){for(var o="https://reactjs.org/docs/error-decoder.html?invariant="+s,l=1;l<arguments.length;l++)o+="&args[]="+encodeURIComponent(arguments[l]);return"Minified React error #"+s+"; visit "+o+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,i={};function c(s,o){u(s,o),u(s+"Capture",o)}function u(s,o){for(i[s]=o,s=0;s<o.length;s++)r.add(o[s])}var d=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),h=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]*$/,p={},v={};function _(s){return h.call(v,s)?!0:h.call(p,s)?!1:m.test(s)?v[s]=!0:(p[s]=!0,!1)}function b(s,o,l,f){if(l!==null&&l.type===0)return!1;switch(typeof o){case"function":case"symbol":return!0;case"boolean":return f?!1:l!==null?!l.acceptsBooleans:(s=s.toLowerCase().slice(0,5),s!=="data-"&&s!=="aria-");default:return!1}}function C(s,o,l,f){if(o===null||typeof o>"u"||b(s,o,l,f))return!0;if(f)return!1;if(l!==null)switch(l.type){case 3:return!o;case 4:return o===!1;case 5:return isNaN(o);case 6:return isNaN(o)||1>o}return!1}function x(s,o,l,f,g,w,k){this.acceptsBooleans=o===2||o===3||o===4,this.attributeName=f,this.attributeNamespace=g,this.mustUseProperty=l,this.propertyName=s,this.type=o,this.sanitizeURL=w,this.removeEmptyString=k}var j={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(s){j[s]=new x(s,0,!1,s,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(s){var o=s[0];j[o]=new x(o,1,!1,s[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(s){j[s]=new x(s,2,!1,s.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(s){j[s]=new x(s,2,!1,s,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(s){j[s]=new x(s,3,!1,s.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(s){j[s]=new x(s,3,!0,s,null,!1,!1)}),["capture","download"].forEach(function(s){j[s]=new x(s,4,!1,s,null,!1,!1)}),["cols","rows","size","span"].forEach(function(s){j[s]=new x(s,6,!1,s,null,!1,!1)}),["rowSpan","start"].forEach(function(s){j[s]=new x(s,5,!1,s.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function $(s){return s[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(s){var o=s.replace(N,$);j[o]=new x(o,1,!1,s,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(s){var o=s.replace(N,$);j[o]=new x(o,1,!1,s,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(s){var o=s.replace(N,$);j[o]=new x(o,1,!1,s,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(s){j[s]=new x(s,1,!1,s.toLowerCase(),null,!1,!1)}),j.xlinkHref=new x("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(s){j[s]=new x(s,1,!1,s.toLowerCase(),null,!0,!0)});function S(s,o,l,f){var g=j.hasOwnProperty(o)?j[o]:null;(g!==null?g.type!==0:f||!(2<o.length)||o[0]!=="o"&&o[0]!=="O"||o[1]!=="n"&&o[1]!=="N")&&(C(o,l,g,f)&&(l=null),f||g===null?_(o)&&(l===null?s.removeAttribute(o):s.setAttribute(o,""+l)):g.mustUseProperty?s[g.propertyName]=l===null?g.type===3?!1:"":l:(o=g.attributeName,f=g.attributeNamespace,l===null?s.removeAttribute(o):(g=g.type,l=g===3||g===4&&l===!0?"":""+l,f?s.setAttributeNS(f,o,l):s.setAttribute(o,l))))}var E=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,A=Symbol.for("react.element"),R=Symbol.for("react.portal"),z=Symbol.for("react.fragment"),L=Symbol.for("react.strict_mode"),J=Symbol.for("react.profiler"),V=Symbol.for("react.provider"),O=Symbol.for("react.context"),ee=Symbol.for("react.forward_ref"),P=Symbol.for("react.suspense"),Z=Symbol.for("react.suspense_list"),U=Symbol.for("react.memo"),te=Symbol.for("react.lazy"),se=Symbol.for("react.offscreen"),G=Symbol.iterator;function ce(s){return s===null||typeof s!="object"?null:(s=G&&s[G]||s["@@iterator"],typeof s=="function"?s:null)}var re=Object.assign,D;function I(s){if(D===void 0)try{throw Error()}catch(l){var o=l.stack.trim().match(/\n( *(at )?)/);D=o&&o[1]||""}return`
|
|
34
|
+
`+D+s}var W=!1;function me(s,o){if(!s||W)return"";W=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(o)if(o=function(){throw Error()},Object.defineProperty(o.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(o,[])}catch(Q){var f=Q}Reflect.construct(s,[],o)}else{try{o.call()}catch(Q){f=Q}s.call(o.prototype)}else{try{throw Error()}catch(Q){f=Q}s()}}catch(Q){if(Q&&f&&typeof Q.stack=="string"){for(var g=Q.stack.split(`
|
|
35
|
+
`),w=f.stack.split(`
|
|
36
|
+
`),k=g.length-1,M=w.length-1;1<=k&&0<=M&&g[k]!==w[M];)M--;for(;1<=k&&0<=M;k--,M--)if(g[k]!==w[M]){if(k!==1||M!==1)do if(k--,M--,0>M||g[k]!==w[M]){var F=`
|
|
37
|
+
`+g[k].replace(" at new "," at ");return s.displayName&&F.includes("<anonymous>")&&(F=F.replace("<anonymous>",s.displayName)),F}while(1<=k&&0<=M);break}}}finally{W=!1,Error.prepareStackTrace=l}return(s=s?s.displayName||s.name:"")?I(s):""}function q(s){switch(s.tag){case 5:return I(s.type);case 16:return I("Lazy");case 13:return I("Suspense");case 19:return I("SuspenseList");case 0:case 2:case 15:return s=me(s.type,!1),s;case 11:return s=me(s.type.render,!1),s;case 1:return s=me(s.type,!0),s;default:return""}}function fe(s){if(s==null)return null;if(typeof s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case z:return"Fragment";case R:return"Portal";case J:return"Profiler";case L:return"StrictMode";case P:return"Suspense";case Z:return"SuspenseList"}if(typeof s=="object")switch(s.$$typeof){case O:return(s.displayName||"Context")+".Consumer";case V:return(s._context.displayName||"Context")+".Provider";case ee:var o=s.render;return s=s.displayName,s||(s=o.displayName||o.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case U:return o=s.displayName||null,o!==null?o:fe(s.type)||"Memo";case te:o=s._payload,s=s._init;try{return fe(s(o))}catch{}}return null}function de(s){var o=s.type;switch(s.tag){case 24:return"Cache";case 9:return(o.displayName||"Context")+".Consumer";case 10:return(o._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return s=o.render,s=s.displayName||s.name||"",o.displayName||(s!==""?"ForwardRef("+s+")":"ForwardRef");case 7:return"Fragment";case 5:return o;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return fe(o);case 8:return o===L?"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 o=="function")return o.displayName||o.name||null;if(typeof o=="string")return o}return null}function ae(s){switch(typeof s){case"boolean":case"number":case"string":case"undefined":return s;case"object":return s;default:return""}}function we(s){var o=s.type;return(s=s.nodeName)&&s.toLowerCase()==="input"&&(o==="checkbox"||o==="radio")}function Pe(s){var o=we(s)?"checked":"value",l=Object.getOwnPropertyDescriptor(s.constructor.prototype,o),f=""+s[o];if(!s.hasOwnProperty(o)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var g=l.get,w=l.set;return Object.defineProperty(s,o,{configurable:!0,get:function(){return g.call(this)},set:function(k){f=""+k,w.call(this,k)}}),Object.defineProperty(s,o,{enumerable:l.enumerable}),{getValue:function(){return f},setValue:function(k){f=""+k},stopTracking:function(){s._valueTracker=null,delete s[o]}}}}function Qe(s){s._valueTracker||(s._valueTracker=Pe(s))}function Ye(s){if(!s)return!1;var o=s._valueTracker;if(!o)return!0;var l=o.getValue(),f="";return s&&(f=we(s)?s.checked?"true":"false":s.value),s=f,s!==l?(o.setValue(s),!0):!1}function Ne(s){if(s=s||(typeof document<"u"?document:void 0),typeof s>"u")return null;try{return s.activeElement||s.body}catch{return s.body}}function He(s,o){var l=o.checked;return re({},o,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:l??s._wrapperState.initialChecked})}function ue(s,o){var l=o.defaultValue==null?"":o.defaultValue,f=o.checked!=null?o.checked:o.defaultChecked;l=ae(o.value!=null?o.value:l),s._wrapperState={initialChecked:f,initialValue:l,controlled:o.type==="checkbox"||o.type==="radio"?o.checked!=null:o.value!=null}}function Ue(s,o){o=o.checked,o!=null&&S(s,"checked",o,!1)}function ie(s,o){Ue(s,o);var l=ae(o.value),f=o.type;if(l!=null)f==="number"?(l===0&&s.value===""||s.value!=l)&&(s.value=""+l):s.value!==""+l&&(s.value=""+l);else if(f==="submit"||f==="reset"){s.removeAttribute("value");return}o.hasOwnProperty("value")?ge(s,o.type,l):o.hasOwnProperty("defaultValue")&&ge(s,o.type,ae(o.defaultValue)),o.checked==null&&o.defaultChecked!=null&&(s.defaultChecked=!!o.defaultChecked)}function Ae(s,o,l){if(o.hasOwnProperty("value")||o.hasOwnProperty("defaultValue")){var f=o.type;if(!(f!=="submit"&&f!=="reset"||o.value!==void 0&&o.value!==null))return;o=""+s._wrapperState.initialValue,l||o===s.value||(s.value=o),s.defaultValue=o}l=s.name,l!==""&&(s.name=""),s.defaultChecked=!!s._wrapperState.initialChecked,l!==""&&(s.name=l)}function ge(s,o,l){(o!=="number"||Ne(s.ownerDocument)!==s)&&(l==null?s.defaultValue=""+s._wrapperState.initialValue:s.defaultValue!==""+l&&(s.defaultValue=""+l))}var Y=Array.isArray;function pe(s,o,l,f){if(s=s.options,o){o={};for(var g=0;g<l.length;g++)o["$"+l[g]]=!0;for(l=0;l<s.length;l++)g=o.hasOwnProperty("$"+s[l].value),s[l].selected!==g&&(s[l].selected=g),g&&f&&(s[l].defaultSelected=!0)}else{for(l=""+ae(l),o=null,g=0;g<s.length;g++){if(s[g].value===l){s[g].selected=!0,f&&(s[g].defaultSelected=!0);return}o!==null||s[g].disabled||(o=s[g])}o!==null&&(o.selected=!0)}}function ve(s,o){if(o.dangerouslySetInnerHTML!=null)throw Error(n(91));return re({},o,{value:void 0,defaultValue:void 0,children:""+s._wrapperState.initialValue})}function Ee(s,o){var l=o.value;if(l==null){if(l=o.children,o=o.defaultValue,l!=null){if(o!=null)throw Error(n(92));if(Y(l)){if(1<l.length)throw Error(n(93));l=l[0]}o=l}o==null&&(o=""),l=o}s._wrapperState={initialValue:ae(l)}}function Oe(s,o){var l=ae(o.value),f=ae(o.defaultValue);l!=null&&(l=""+l,l!==s.value&&(s.value=l),o.defaultValue==null&&s.defaultValue!==l&&(s.defaultValue=l)),f!=null&&(s.defaultValue=""+f)}function Be(s){var o=s.textContent;o===s._wrapperState.initialValue&&o!==""&&o!==null&&(s.value=o)}function Xe(s){switch(s){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 mt(s,o){return s==null||s==="http://www.w3.org/1999/xhtml"?Xe(o):s==="http://www.w3.org/2000/svg"&&o==="foreignObject"?"http://www.w3.org/1999/xhtml":s}var Tt,Es=(function(s){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(o,l,f,g){MSApp.execUnsafeLocalFunction(function(){return s(o,l,f,g)})}:s})(function(s,o){if(s.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in s)s.innerHTML=o;else{for(Tt=Tt||document.createElement("div"),Tt.innerHTML="<svg>"+o.valueOf().toString()+"</svg>",o=Tt.firstChild;s.firstChild;)s.removeChild(s.firstChild);for(;o.firstChild;)s.appendChild(o.firstChild)}});function Lr(s,o){if(o){var l=s.firstChild;if(l&&l===s.lastChild&&l.nodeType===3){l.nodeValue=o;return}}s.textContent=o}var Rt={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},$s=["Webkit","ms","Moz","O"];Object.keys(Rt).forEach(function(s){$s.forEach(function(o){o=o+s.charAt(0).toUpperCase()+s.substring(1),Rt[o]=Rt[s]})});function ha(s,o,l){return o==null||typeof o=="boolean"||o===""?"":l||typeof o!="number"||o===0||Rt.hasOwnProperty(s)&&Rt[s]?(""+o).trim():o+"px"}function ma(s,o){s=s.style;for(var l in o)if(o.hasOwnProperty(l)){var f=l.indexOf("--")===0,g=ha(l,o[l],f);l==="float"&&(l="cssFloat"),f?s.setProperty(l,g):s[l]=g}}var pt=re({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 pa(s,o){if(o){if(pt[s]&&(o.children!=null||o.dangerouslySetInnerHTML!=null))throw Error(n(137,s));if(o.dangerouslySetInnerHTML!=null){if(o.children!=null)throw Error(n(60));if(typeof o.dangerouslySetInnerHTML!="object"||!("__html"in o.dangerouslySetInnerHTML))throw Error(n(61))}if(o.style!=null&&typeof o.style!="object")throw Error(n(62))}}function On(s,o){if(s.indexOf("-")===-1)return typeof o.is=="string";switch(s){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 ga=null;function cn(s){return s=s.target||s.srcElement||window,s.correspondingUseElement&&(s=s.correspondingUseElement),s.nodeType===3?s.parentNode:s}var us=null,Ys=null,As=null;function Or(s){if(s=Ko(s)){if(typeof us!="function")throw Error(n(280));var o=s.stateNode;o&&(o=vl(o),us(s.stateNode,s.type,o))}}function wo(s){Ys?As?As.push(s):As=[s]:Ys=s}function Ts(){if(Ys){var s=Ys,o=As;if(As=Ys=null,Or(s),o)for(s=0;s<o.length;s++)Or(o[s])}}function ya(s,o){return s(o)}function Vi(){}var Rs=!1;function vo(s,o,l){if(Rs)return s(o,l);Rs=!0;try{return ya(s,o,l)}finally{Rs=!1,(Ys!==null||As!==null)&&(Vi(),Ts())}}function Pr(s,o){var l=s.stateNode;if(l===null)return null;var f=vl(l);if(f===null)return null;l=f[o];e:switch(o){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(f=!f.disabled)||(s=s.type,f=!(s==="button"||s==="input"||s==="select"||s==="textarea")),s=!f;break e;default:s=!1}if(s)return null;if(l&&typeof l!="function")throw Error(n(231,o,typeof l));return l}var ds=!1;if(d)try{var jt={};Object.defineProperty(jt,"passive",{get:function(){ds=!0}}),window.addEventListener("test",jt,jt),window.removeEventListener("test",jt,jt)}catch{ds=!1}function _o(s,o,l,f,g,w,k,M,F){var Q=Array.prototype.slice.call(arguments,3);try{o.apply(l,Q)}catch(le){this.onError(le)}}var Xs=!1,fs=null,Dr=!1,wa=null,un={onError:function(s){Xs=!0,fs=s}};function Et(s,o,l,f,g,w,k,M,F){Xs=!1,fs=null,_o.apply(un,arguments)}function Qt(s,o,l,f,g,w,k,M,F){if(Et.apply(this,arguments),Xs){if(Xs){var Q=fs;Xs=!1,fs=null}else throw Error(n(198));Dr||(Dr=!0,wa=Q)}}function dn(s){var o=s,l=s;if(s.alternate)for(;o.return;)o=o.return;else{s=o;do o=s,(o.flags&4098)!==0&&(l=o.return),s=o.return;while(s)}return o.tag===3?l:null}function va(s){if(s.tag===13){var o=s.memoizedState;if(o===null&&(s=s.alternate,s!==null&&(o=s.memoizedState)),o!==null)return o.dehydrated}return null}function bo(s){if(dn(s)!==s)throw Error(n(188))}function xo(s){var o=s.alternate;if(!o){if(o=dn(s),o===null)throw Error(n(188));return o!==s?null:s}for(var l=s,f=o;;){var g=l.return;if(g===null)break;var w=g.alternate;if(w===null){if(f=g.return,f!==null){l=f;continue}break}if(g.child===w.child){for(w=g.child;w;){if(w===l)return bo(g),s;if(w===f)return bo(g),o;w=w.sibling}throw Error(n(188))}if(l.return!==f.return)l=g,f=w;else{for(var k=!1,M=g.child;M;){if(M===l){k=!0,l=g,f=w;break}if(M===f){k=!0,f=g,l=w;break}M=M.sibling}if(!k){for(M=w.child;M;){if(M===l){k=!0,l=w,f=g;break}if(M===f){k=!0,f=w,l=g;break}M=M.sibling}if(!k)throw Error(n(189))}}if(l.alternate!==f)throw Error(n(190))}if(l.tag!==3)throw Error(n(188));return l.stateNode.current===l?s:o}function _a(s){return s=xo(s),s!==null?Hi(s):null}function Hi(s){if(s.tag===5||s.tag===6)return s;for(s=s.child;s!==null;){var o=Hi(s);if(o!==null)return o;s=s.sibling}return null}var ko=t.unstable_scheduleCallback,qs=t.unstable_cancelCallback,Xc=t.unstable_shouldYield,Is=t.unstable_requestPaint,nt=t.unstable_now,jo=t.unstable_getCurrentPriorityLevel,Cn=t.unstable_ImmediatePriority,So=t.unstable_UserBlockingPriority,Zs=t.unstable_NormalPriority,Fr=t.unstable_LowPriority,ba=t.unstable_IdlePriority,xa=null,fn=null;function Gi(s){if(fn&&typeof fn.onCommitFiberRoot=="function")try{fn.onCommitFiberRoot(xa,s,void 0,(s.current.flags&128)===128)}catch{}}var hn=Math.clz32?Math.clz32:Zc,Ki=Math.log,qc=Math.LN2;function Zc(s){return s>>>=0,s===0?32:31-(Ki(s)/qc|0)|0}var Pn=64,We=4194304;function Bt(s){switch(s&-s){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 s&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return s&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return s}}function er(s,o){var l=s.pendingLanes;if(l===0)return 0;var f=0,g=s.suspendedLanes,w=s.pingedLanes,k=l&268435455;if(k!==0){var M=k&~g;M!==0?f=Bt(M):(w&=k,w!==0&&(f=Bt(w)))}else k=l&~g,k!==0?f=Bt(k):w!==0&&(f=Bt(w));if(f===0)return 0;if(o!==0&&o!==f&&(o&g)===0&&(g=f&-f,w=o&-o,g>=w||g===16&&(w&4194240)!==0))return o;if((f&4)!==0&&(f|=l&16),o=s.entangledLanes,o!==0)for(s=s.entanglements,o&=f;0<o;)l=31-hn(o),g=1<<l,f|=s[l],o&=~g;return f}function hs(s,o){switch(s){case 1:case 2:case 4:return o+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 o+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 ka(s,o){for(var l=s.suspendedLanes,f=s.pingedLanes,g=s.expirationTimes,w=s.pendingLanes;0<w;){var k=31-hn(w),M=1<<k,F=g[k];F===-1?((M&l)===0||(M&f)!==0)&&(g[k]=hs(M,o)):F<=o&&(s.expiredLanes|=M),w&=~M}}function tr(s){return s=s.pendingLanes&-1073741825,s!==0?s:s&1073741824?1073741824:0}function Qn(){var s=Pn;return Pn<<=1,(Pn&4194240)===0&&(Pn=64),s}function zr(s){for(var o=[],l=0;31>l;l++)o.push(s);return o}function nr(s,o,l){s.pendingLanes|=o,o!==536870912&&(s.suspendedLanes=0,s.pingedLanes=0),s=s.eventTimes,o=31-hn(o),s[o]=l}function Yn(s,o){var l=s.pendingLanes&~o;s.pendingLanes=o,s.suspendedLanes=0,s.pingedLanes=0,s.expiredLanes&=o,s.mutableReadLanes&=o,s.entangledLanes&=o,o=s.entanglements;var f=s.eventTimes;for(s=s.expirationTimes;0<l;){var g=31-hn(l),w=1<<g;o[g]=0,f[g]=-1,s[g]=-1,l&=~w}}function Xn(s,o){var l=s.entangledLanes|=o;for(s=s.entanglements;l;){var f=31-hn(l),g=1<<f;g&o|s[f]&o&&(s[f]|=o),l&=~g}}var Ke=0;function ja(s){return s&=-s,1<s?4<s?(s&268435455)!==0?16:536870912:4:1}var No,mn,Co,Dn,Eo,ms=!1,ps=[],En=null,bt=null,$n=null,sr=new Map,Ms=new Map,Fn=[],Ji="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 Qi(s,o){switch(s){case"focusin":case"focusout":En=null;break;case"dragenter":case"dragleave":bt=null;break;case"mouseover":case"mouseout":$n=null;break;case"pointerover":case"pointerout":sr.delete(o.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ms.delete(o.pointerId)}}function rr(s,o,l,f,g,w){return s===null||s.nativeEvent!==w?(s={blockedOn:o,domEventName:l,eventSystemFlags:f,nativeEvent:w,targetContainers:[g]},o!==null&&(o=Ko(o),o!==null&&mn(o)),s):(s.eventSystemFlags|=f,o=s.targetContainers,g!==null&&o.indexOf(g)===-1&&o.push(g),s)}function Yi(s,o,l,f,g){switch(o){case"focusin":return En=rr(En,s,o,l,f,g),!0;case"dragenter":return bt=rr(bt,s,o,l,f,g),!0;case"mouseover":return $n=rr($n,s,o,l,f,g),!0;case"pointerover":var w=g.pointerId;return sr.set(w,rr(sr.get(w)||null,s,o,l,f,g)),!0;case"gotpointercapture":return w=g.pointerId,Ms.set(w,rr(Ms.get(w)||null,s,o,l,f,g)),!0}return!1}function Sa(s){var o=Gr(s.target);if(o!==null){var l=dn(o);if(l!==null){if(o=l.tag,o===13){if(o=va(l),o!==null){s.blockedOn=o,Eo(s.priority,function(){Co(l)});return}}else if(o===3&&l.stateNode.current.memoizedState.isDehydrated){s.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}s.blockedOn=null}function gs(s){if(s.blockedOn!==null)return!1;for(var o=s.targetContainers;0<o.length;){var l=Ca(s.domEventName,s.eventSystemFlags,o[0],s.nativeEvent);if(l===null){l=s.nativeEvent;var f=new l.constructor(l.type,l);ga=f,l.target.dispatchEvent(f),ga=null}else return o=Ko(l),o!==null&&mn(o),s.blockedOn=l,!1;o.shift()}return!0}function $t(s,o,l){gs(s)&&l.delete(o)}function $o(){ms=!1,En!==null&&gs(En)&&(En=null),bt!==null&&gs(bt)&&(bt=null),$n!==null&&gs($n)&&($n=null),sr.forEach($t),Ms.forEach($t)}function St(s,o){s.blockedOn===o&&(s.blockedOn=null,ms||(ms=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,$o)))}function ar(s){function o(g){return St(g,s)}if(0<ps.length){St(ps[0],s);for(var l=1;l<ps.length;l++){var f=ps[l];f.blockedOn===s&&(f.blockedOn=null)}}for(En!==null&&St(En,s),bt!==null&&St(bt,s),$n!==null&&St($n,s),sr.forEach(o),Ms.forEach(o),l=0;l<Fn.length;l++)f=Fn[l],f.blockedOn===s&&(f.blockedOn=null);for(;0<Fn.length&&(l=Fn[0],l.blockedOn===null);)Sa(l),l.blockedOn===null&&Fn.shift()}var ys=E.ReactCurrentBatchConfig,ws=!0;function Ur(s,o,l,f){var g=Ke,w=ys.transition;ys.transition=null;try{Ke=1,or(s,o,l,f)}finally{Ke=g,ys.transition=w}}function Ao(s,o,l,f){var g=Ke,w=ys.transition;ys.transition=null;try{Ke=4,or(s,o,l,f)}finally{Ke=g,ys.transition=w}}function or(s,o,l,f){if(ws){var g=Ca(s,o,l,f);if(g===null)mu(s,o,f,Na,l),Qi(s,f);else if(Yi(g,s,o,l,f))f.stopPropagation();else if(Qi(s,f),o&4&&-1<Ji.indexOf(s)){for(;g!==null;){var w=Ko(g);if(w!==null&&No(w),w=Ca(s,o,l,f),w===null&&mu(s,o,f,Na,l),w===g)break;g=w}g!==null&&f.stopPropagation()}else mu(s,o,f,null,l)}}var Na=null;function Ca(s,o,l,f){if(Na=null,s=cn(f),s=Gr(s),s!==null)if(o=dn(s),o===null)s=null;else if(l=o.tag,l===13){if(s=va(o),s!==null)return s;s=null}else if(l===3){if(o.stateNode.current.memoizedState.isDehydrated)return o.tag===3?o.stateNode.containerInfo:null;s=null}else o!==s&&(s=null);return Na=s,null}function To(s){switch(s){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(jo()){case Cn:return 1;case So:return 4;case Zs:case Fr:return 16;case ba:return 536870912;default:return 16}default:return 16}}var zn=null,Ro=null,Ea=null;function Xi(){if(Ea)return Ea;var s,o=Ro,l=o.length,f,g="value"in zn?zn.value:zn.textContent,w=g.length;for(s=0;s<l&&o[s]===g[s];s++);var k=l-s;for(f=1;f<=k&&o[l-f]===g[w-f];f++);return Ea=g.slice(s,1<f?1-f:void 0)}function vs(s){var o=s.keyCode;return"charCode"in s?(s=s.charCode,s===0&&o===13&&(s=13)):s=o,s===10&&(s=13),32<=s||s===13?s:0}function ir(){return!0}function An(){return!1}function Wt(s){function o(l,f,g,w,k){this._reactName=l,this._targetInst=g,this.type=f,this.nativeEvent=w,this.target=k,this.currentTarget=null;for(var M in s)s.hasOwnProperty(M)&&(l=s[M],this[M]=l?l(w):w[M]);return this.isDefaultPrevented=(w.defaultPrevented!=null?w.defaultPrevented:w.returnValue===!1)?ir:An,this.isPropagationStopped=An,this}return re(o.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=ir)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=ir)},persist:function(){},isPersistent:ir}),o}var Ls={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(s){return s.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Br=Wt(Ls),Wr=re({},Ls,{view:0,detail:0}),$a=Wt(Wr),Aa,Io,Vr,Hr=re({},Wr,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ta,button:0,buttons:0,relatedTarget:function(s){return s.relatedTarget===void 0?s.fromElement===s.srcElement?s.toElement:s.fromElement:s.relatedTarget},movementX:function(s){return"movementX"in s?s.movementX:(s!==Vr&&(Vr&&s.type==="mousemove"?(Aa=s.screenX-Vr.screenX,Io=s.screenY-Vr.screenY):Io=Aa=0,Vr=s),Aa)},movementY:function(s){return"movementY"in s?s.movementY:Io}}),qi=Wt(Hr),eu=re({},Hr,{dataTransfer:0}),_s=Wt(eu),Zi=re({},Wr,{relatedTarget:0}),ut=Wt(Zi),Os=re({},Ls,{animationName:0,elapsedTime:0,pseudoElement:0}),lr=Wt(Os),tu=re({},Ls,{clipboardData:function(s){return"clipboardData"in s?s.clipboardData:window.clipboardData}}),nu=Wt(tu),su=re({},Ls,{data:0}),el=Wt(su),ru={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},au={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"},Mo={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function tl(s){var o=this.nativeEvent;return o.getModifierState?o.getModifierState(s):(s=Mo[s])?!!o[s]:!1}function Ta(){return tl}var ou=re({},Wr,{key:function(s){if(s.key){var o=ru[s.key]||s.key;if(o!=="Unidentified")return o}return s.type==="keypress"?(s=vs(s),s===13?"Enter":String.fromCharCode(s)):s.type==="keydown"||s.type==="keyup"?au[s.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ta,charCode:function(s){return s.type==="keypress"?vs(s):0},keyCode:function(s){return s.type==="keydown"||s.type==="keyup"?s.keyCode:0},which:function(s){return s.type==="keypress"?vs(s):s.type==="keydown"||s.type==="keyup"?s.keyCode:0}}),nl=Wt(ou),sl=re({},Hr,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Lo=Wt(sl),rl=re({},Wr,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ta}),al=Wt(rl),ol=re({},Ls,{propertyName:0,elapsedTime:0,pseudoElement:0}),il=Wt(ol),ll=re({},Hr,{deltaX:function(s){return"deltaX"in s?s.deltaX:"wheelDeltaX"in s?-s.wheelDeltaX:0},deltaY:function(s){return"deltaY"in s?s.deltaY:"wheelDeltaY"in s?-s.wheelDeltaY:"wheelDelta"in s?-s.wheelDelta:0},deltaZ:0,deltaMode:0}),cl=Wt(ll),ul=[9,13,27,32],Ra=d&&"CompositionEvent"in window,cr=null;d&&"documentMode"in document&&(cr=document.documentMode);var dl=d&&"TextEvent"in window&&!cr,Oo=d&&(!Ra||cr&&8<cr&&11>=cr),Po=" ",Do=!1;function Fo(s,o){switch(s){case"keyup":return ul.indexOf(o.keyCode)!==-1;case"keydown":return o.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function zo(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var Ps=!1;function fl(s,o){switch(s){case"compositionend":return zo(o);case"keypress":return o.which!==32?null:(Do=!0,Po);case"textInput":return s=o.data,s===Po&&Do?null:s;default:return null}}function T(s,o){if(Ps)return s==="compositionend"||!Ra&&Fo(s,o)?(s=Xi(),Ea=Ro=zn=null,Ps=!1,s):null;switch(s){case"paste":return null;case"keypress":if(!(o.ctrlKey||o.altKey||o.metaKey)||o.ctrlKey&&o.altKey){if(o.char&&1<o.char.length)return o.char;if(o.which)return String.fromCharCode(o.which)}return null;case"compositionend":return Oo&&o.locale!=="ko"?null:o.data;default:return null}}var X={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 be(s){var o=s&&s.nodeName&&s.nodeName.toLowerCase();return o==="input"?!!X[s.type]:o==="textarea"}function je(s,o,l,f){wo(f),o=gl(o,"onChange"),0<o.length&&(l=new Br("onChange","change",null,l,f),s.push({event:l,listeners:o}))}var Te=null,at=null;function Nt(s){dh(s,0)}function qn(s){var o=Pa(s);if(Ye(o))return s}function Pt(s,o){if(s==="change")return o}var sn=!1;if(d){var Yt;if(d){var Zn="oninput"in document;if(!Zn){var es=document.createElement("div");es.setAttribute("oninput","return;"),Zn=typeof es.oninput=="function"}Yt=Zn}else Yt=!1;sn=Yt&&(!document.documentMode||9<document.documentMode)}function Yf(){Te&&(Te.detachEvent("onpropertychange",Xf),at=Te=null)}function Xf(s){if(s.propertyName==="value"&&qn(at)){var o=[];je(o,at,s,cn(s)),vo(Nt,o)}}function Qw(s,o,l){s==="focusin"?(Yf(),Te=o,at=l,Te.attachEvent("onpropertychange",Xf)):s==="focusout"&&Yf()}function Yw(s){if(s==="selectionchange"||s==="keyup"||s==="keydown")return qn(at)}function Xw(s,o){if(s==="click")return qn(o)}function qw(s,o){if(s==="input"||s==="change")return qn(o)}function Zw(s,o){return s===o&&(s!==0||1/s===1/o)||s!==s&&o!==o}var ts=typeof Object.is=="function"?Object.is:Zw;function Uo(s,o){if(ts(s,o))return!0;if(typeof s!="object"||s===null||typeof o!="object"||o===null)return!1;var l=Object.keys(s),f=Object.keys(o);if(l.length!==f.length)return!1;for(f=0;f<l.length;f++){var g=l[f];if(!h.call(o,g)||!ts(s[g],o[g]))return!1}return!0}function qf(s){for(;s&&s.firstChild;)s=s.firstChild;return s}function Zf(s,o){var l=qf(s);s=0;for(var f;l;){if(l.nodeType===3){if(f=s+l.textContent.length,s<=o&&f>=o)return{node:l,offset:o-s};s=f}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=qf(l)}}function eh(s,o){return s&&o?s===o?!0:s&&s.nodeType===3?!1:o&&o.nodeType===3?eh(s,o.parentNode):"contains"in s?s.contains(o):s.compareDocumentPosition?!!(s.compareDocumentPosition(o)&16):!1:!1}function th(){for(var s=window,o=Ne();o instanceof s.HTMLIFrameElement;){try{var l=typeof o.contentWindow.location.href=="string"}catch{l=!1}if(l)s=o.contentWindow;else break;o=Ne(s.document)}return o}function iu(s){var o=s&&s.nodeName&&s.nodeName.toLowerCase();return o&&(o==="input"&&(s.type==="text"||s.type==="search"||s.type==="tel"||s.type==="url"||s.type==="password")||o==="textarea"||s.contentEditable==="true")}function ev(s){var o=th(),l=s.focusedElem,f=s.selectionRange;if(o!==l&&l&&l.ownerDocument&&eh(l.ownerDocument.documentElement,l)){if(f!==null&&iu(l)){if(o=f.start,s=f.end,s===void 0&&(s=o),"selectionStart"in l)l.selectionStart=o,l.selectionEnd=Math.min(s,l.value.length);else if(s=(o=l.ownerDocument||document)&&o.defaultView||window,s.getSelection){s=s.getSelection();var g=l.textContent.length,w=Math.min(f.start,g);f=f.end===void 0?w:Math.min(f.end,g),!s.extend&&w>f&&(g=f,f=w,w=g),g=Zf(l,w);var k=Zf(l,f);g&&k&&(s.rangeCount!==1||s.anchorNode!==g.node||s.anchorOffset!==g.offset||s.focusNode!==k.node||s.focusOffset!==k.offset)&&(o=o.createRange(),o.setStart(g.node,g.offset),s.removeAllRanges(),w>f?(s.addRange(o),s.extend(k.node,k.offset)):(o.setEnd(k.node,k.offset),s.addRange(o)))}}for(o=[],s=l;s=s.parentNode;)s.nodeType===1&&o.push({element:s,left:s.scrollLeft,top:s.scrollTop});for(typeof l.focus=="function"&&l.focus(),l=0;l<o.length;l++)s=o[l],s.element.scrollLeft=s.left,s.element.scrollTop=s.top}}var tv=d&&"documentMode"in document&&11>=document.documentMode,Ia=null,lu=null,Bo=null,cu=!1;function nh(s,o,l){var f=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;cu||Ia==null||Ia!==Ne(f)||(f=Ia,"selectionStart"in f&&iu(f)?f={start:f.selectionStart,end:f.selectionEnd}:(f=(f.ownerDocument&&f.ownerDocument.defaultView||window).getSelection(),f={anchorNode:f.anchorNode,anchorOffset:f.anchorOffset,focusNode:f.focusNode,focusOffset:f.focusOffset}),Bo&&Uo(Bo,f)||(Bo=f,f=gl(lu,"onSelect"),0<f.length&&(o=new Br("onSelect","select",null,o,l),s.push({event:o,listeners:f}),o.target=Ia)))}function hl(s,o){var l={};return l[s.toLowerCase()]=o.toLowerCase(),l["Webkit"+s]="webkit"+o,l["Moz"+s]="moz"+o,l}var Ma={animationend:hl("Animation","AnimationEnd"),animationiteration:hl("Animation","AnimationIteration"),animationstart:hl("Animation","AnimationStart"),transitionend:hl("Transition","TransitionEnd")},uu={},sh={};d&&(sh=document.createElement("div").style,"AnimationEvent"in window||(delete Ma.animationend.animation,delete Ma.animationiteration.animation,delete Ma.animationstart.animation),"TransitionEvent"in window||delete Ma.transitionend.transition);function ml(s){if(uu[s])return uu[s];if(!Ma[s])return s;var o=Ma[s],l;for(l in o)if(o.hasOwnProperty(l)&&l in sh)return uu[s]=o[l];return s}var rh=ml("animationend"),ah=ml("animationiteration"),oh=ml("animationstart"),ih=ml("transitionend"),lh=new Map,ch="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 ur(s,o){lh.set(s,o),c(o,[s])}for(var du=0;du<ch.length;du++){var fu=ch[du],nv=fu.toLowerCase(),sv=fu[0].toUpperCase()+fu.slice(1);ur(nv,"on"+sv)}ur(rh,"onAnimationEnd"),ur(ah,"onAnimationIteration"),ur(oh,"onAnimationStart"),ur("dblclick","onDoubleClick"),ur("focusin","onFocus"),ur("focusout","onBlur"),ur(ih,"onTransitionEnd"),u("onMouseEnter",["mouseout","mouseover"]),u("onMouseLeave",["mouseout","mouseover"]),u("onPointerEnter",["pointerout","pointerover"]),u("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 Wo="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(" "),rv=new Set("cancel close invalid load scroll toggle".split(" ").concat(Wo));function uh(s,o,l){var f=s.type||"unknown-event";s.currentTarget=l,Qt(f,o,void 0,s),s.currentTarget=null}function dh(s,o){o=(o&4)!==0;for(var l=0;l<s.length;l++){var f=s[l],g=f.event;f=f.listeners;e:{var w=void 0;if(o)for(var k=f.length-1;0<=k;k--){var M=f[k],F=M.instance,Q=M.currentTarget;if(M=M.listener,F!==w&&g.isPropagationStopped())break e;uh(g,M,Q),w=F}else for(k=0;k<f.length;k++){if(M=f[k],F=M.instance,Q=M.currentTarget,M=M.listener,F!==w&&g.isPropagationStopped())break e;uh(g,M,Q),w=F}}}if(Dr)throw s=wa,Dr=!1,wa=null,s}function ft(s,o){var l=o[_u];l===void 0&&(l=o[_u]=new Set);var f=s+"__bubble";l.has(f)||(fh(o,s,2,!1),l.add(f))}function hu(s,o,l){var f=0;o&&(f|=4),fh(l,s,f,o)}var pl="_reactListening"+Math.random().toString(36).slice(2);function Vo(s){if(!s[pl]){s[pl]=!0,r.forEach(function(l){l!=="selectionchange"&&(rv.has(l)||hu(l,!1,s),hu(l,!0,s))});var o=s.nodeType===9?s:s.ownerDocument;o===null||o[pl]||(o[pl]=!0,hu("selectionchange",!1,o))}}function fh(s,o,l,f){switch(To(o)){case 1:var g=Ur;break;case 4:g=Ao;break;default:g=or}l=g.bind(null,o,l,s),g=void 0,!ds||o!=="touchstart"&&o!=="touchmove"&&o!=="wheel"||(g=!0),f?g!==void 0?s.addEventListener(o,l,{capture:!0,passive:g}):s.addEventListener(o,l,!0):g!==void 0?s.addEventListener(o,l,{passive:g}):s.addEventListener(o,l,!1)}function mu(s,o,l,f,g){var w=f;if((o&1)===0&&(o&2)===0&&f!==null)e:for(;;){if(f===null)return;var k=f.tag;if(k===3||k===4){var M=f.stateNode.containerInfo;if(M===g||M.nodeType===8&&M.parentNode===g)break;if(k===4)for(k=f.return;k!==null;){var F=k.tag;if((F===3||F===4)&&(F=k.stateNode.containerInfo,F===g||F.nodeType===8&&F.parentNode===g))return;k=k.return}for(;M!==null;){if(k=Gr(M),k===null)return;if(F=k.tag,F===5||F===6){f=w=k;continue e}M=M.parentNode}}f=f.return}vo(function(){var Q=w,le=cn(l),he=[];e:{var oe=lh.get(s);if(oe!==void 0){var xe=Br,Se=s;switch(s){case"keypress":if(vs(l)===0)break e;case"keydown":case"keyup":xe=nl;break;case"focusin":Se="focus",xe=ut;break;case"focusout":Se="blur",xe=ut;break;case"beforeblur":case"afterblur":xe=ut;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":xe=qi;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":xe=_s;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":xe=al;break;case rh:case ah:case oh:xe=lr;break;case ih:xe=il;break;case"scroll":xe=$a;break;case"wheel":xe=cl;break;case"copy":case"cut":case"paste":xe=nu;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":xe=Lo}var Ce=(o&4)!==0,Ct=!Ce&&s==="scroll",H=Ce?oe!==null?oe+"Capture":null:oe;Ce=[];for(var B=Q,K;B!==null;){K=B;var ye=K.stateNode;if(K.tag===5&&ye!==null&&(K=ye,H!==null&&(ye=Pr(B,H),ye!=null&&Ce.push(Ho(B,ye,K)))),Ct)break;B=B.return}0<Ce.length&&(oe=new xe(oe,Se,null,l,le),he.push({event:oe,listeners:Ce}))}}if((o&7)===0){e:{if(oe=s==="mouseover"||s==="pointerover",xe=s==="mouseout"||s==="pointerout",oe&&l!==ga&&(Se=l.relatedTarget||l.fromElement)&&(Gr(Se)||Se[Ds]))break e;if((xe||oe)&&(oe=le.window===le?le:(oe=le.ownerDocument)?oe.defaultView||oe.parentWindow:window,xe?(Se=l.relatedTarget||l.toElement,xe=Q,Se=Se?Gr(Se):null,Se!==null&&(Ct=dn(Se),Se!==Ct||Se.tag!==5&&Se.tag!==6)&&(Se=null)):(xe=null,Se=Q),xe!==Se)){if(Ce=qi,ye="onMouseLeave",H="onMouseEnter",B="mouse",(s==="pointerout"||s==="pointerover")&&(Ce=Lo,ye="onPointerLeave",H="onPointerEnter",B="pointer"),Ct=xe==null?oe:Pa(xe),K=Se==null?oe:Pa(Se),oe=new Ce(ye,B+"leave",xe,l,le),oe.target=Ct,oe.relatedTarget=K,ye=null,Gr(le)===Q&&(Ce=new Ce(H,B+"enter",Se,l,le),Ce.target=K,Ce.relatedTarget=Ct,ye=Ce),Ct=ye,xe&&Se)t:{for(Ce=xe,H=Se,B=0,K=Ce;K;K=La(K))B++;for(K=0,ye=H;ye;ye=La(ye))K++;for(;0<B-K;)Ce=La(Ce),B--;for(;0<K-B;)H=La(H),K--;for(;B--;){if(Ce===H||H!==null&&Ce===H.alternate)break t;Ce=La(Ce),H=La(H)}Ce=null}else Ce=null;xe!==null&&hh(he,oe,xe,Ce,!1),Se!==null&&Ct!==null&&hh(he,Ct,Se,Ce,!0)}}e:{if(oe=Q?Pa(Q):window,xe=oe.nodeName&&oe.nodeName.toLowerCase(),xe==="select"||xe==="input"&&oe.type==="file")var $e=Pt;else if(be(oe))if(sn)$e=qw;else{$e=Yw;var Ie=Qw}else(xe=oe.nodeName)&&xe.toLowerCase()==="input"&&(oe.type==="checkbox"||oe.type==="radio")&&($e=Xw);if($e&&($e=$e(s,Q))){je(he,$e,l,le);break e}Ie&&Ie(s,oe,Q),s==="focusout"&&(Ie=oe._wrapperState)&&Ie.controlled&&oe.type==="number"&&ge(oe,"number",oe.value)}switch(Ie=Q?Pa(Q):window,s){case"focusin":(be(Ie)||Ie.contentEditable==="true")&&(Ia=Ie,lu=Q,Bo=null);break;case"focusout":Bo=lu=Ia=null;break;case"mousedown":cu=!0;break;case"contextmenu":case"mouseup":case"dragend":cu=!1,nh(he,l,le);break;case"selectionchange":if(tv)break;case"keydown":case"keyup":nh(he,l,le)}var Me;if(Ra)e:{switch(s){case"compositionstart":var Fe="onCompositionStart";break e;case"compositionend":Fe="onCompositionEnd";break e;case"compositionupdate":Fe="onCompositionUpdate";break e}Fe=void 0}else Ps?Fo(s,l)&&(Fe="onCompositionEnd"):s==="keydown"&&l.keyCode===229&&(Fe="onCompositionStart");Fe&&(Oo&&l.locale!=="ko"&&(Ps||Fe!=="onCompositionStart"?Fe==="onCompositionEnd"&&Ps&&(Me=Xi()):(zn=le,Ro="value"in zn?zn.value:zn.textContent,Ps=!0)),Ie=gl(Q,Fe),0<Ie.length&&(Fe=new el(Fe,s,null,l,le),he.push({event:Fe,listeners:Ie}),Me?Fe.data=Me:(Me=zo(l),Me!==null&&(Fe.data=Me)))),(Me=dl?fl(s,l):T(s,l))&&(Q=gl(Q,"onBeforeInput"),0<Q.length&&(le=new el("onBeforeInput","beforeinput",null,l,le),he.push({event:le,listeners:Q}),le.data=Me))}dh(he,o)})}function Ho(s,o,l){return{instance:s,listener:o,currentTarget:l}}function gl(s,o){for(var l=o+"Capture",f=[];s!==null;){var g=s,w=g.stateNode;g.tag===5&&w!==null&&(g=w,w=Pr(s,l),w!=null&&f.unshift(Ho(s,w,g)),w=Pr(s,o),w!=null&&f.push(Ho(s,w,g))),s=s.return}return f}function La(s){if(s===null)return null;do s=s.return;while(s&&s.tag!==5);return s||null}function hh(s,o,l,f,g){for(var w=o._reactName,k=[];l!==null&&l!==f;){var M=l,F=M.alternate,Q=M.stateNode;if(F!==null&&F===f)break;M.tag===5&&Q!==null&&(M=Q,g?(F=Pr(l,w),F!=null&&k.unshift(Ho(l,F,M))):g||(F=Pr(l,w),F!=null&&k.push(Ho(l,F,M)))),l=l.return}k.length!==0&&s.push({event:o,listeners:k})}var av=/\r\n?/g,ov=/\u0000|\uFFFD/g;function mh(s){return(typeof s=="string"?s:""+s).replace(av,`
|
|
38
|
+
`).replace(ov,"")}function yl(s,o,l){if(o=mh(o),mh(s)!==o&&l)throw Error(n(425))}function wl(){}var pu=null,gu=null;function yu(s,o){return s==="textarea"||s==="noscript"||typeof o.children=="string"||typeof o.children=="number"||typeof o.dangerouslySetInnerHTML=="object"&&o.dangerouslySetInnerHTML!==null&&o.dangerouslySetInnerHTML.__html!=null}var wu=typeof setTimeout=="function"?setTimeout:void 0,iv=typeof clearTimeout=="function"?clearTimeout:void 0,ph=typeof Promise=="function"?Promise:void 0,lv=typeof queueMicrotask=="function"?queueMicrotask:typeof ph<"u"?function(s){return ph.resolve(null).then(s).catch(cv)}:wu;function cv(s){setTimeout(function(){throw s})}function vu(s,o){var l=o,f=0;do{var g=l.nextSibling;if(s.removeChild(l),g&&g.nodeType===8)if(l=g.data,l==="/$"){if(f===0){s.removeChild(g),ar(o);return}f--}else l!=="$"&&l!=="$?"&&l!=="$!"||f++;l=g}while(l);ar(o)}function dr(s){for(;s!=null;s=s.nextSibling){var o=s.nodeType;if(o===1||o===3)break;if(o===8){if(o=s.data,o==="$"||o==="$!"||o==="$?")break;if(o==="/$")return null}}return s}function gh(s){s=s.previousSibling;for(var o=0;s;){if(s.nodeType===8){var l=s.data;if(l==="$"||l==="$!"||l==="$?"){if(o===0)return s;o--}else l==="/$"&&o++}s=s.previousSibling}return null}var Oa=Math.random().toString(36).slice(2),bs="__reactFiber$"+Oa,Go="__reactProps$"+Oa,Ds="__reactContainer$"+Oa,_u="__reactEvents$"+Oa,uv="__reactListeners$"+Oa,dv="__reactHandles$"+Oa;function Gr(s){var o=s[bs];if(o)return o;for(var l=s.parentNode;l;){if(o=l[Ds]||l[bs]){if(l=o.alternate,o.child!==null||l!==null&&l.child!==null)for(s=gh(s);s!==null;){if(l=s[bs])return l;s=gh(s)}return o}s=l,l=s.parentNode}return null}function Ko(s){return s=s[bs]||s[Ds],!s||s.tag!==5&&s.tag!==6&&s.tag!==13&&s.tag!==3?null:s}function Pa(s){if(s.tag===5||s.tag===6)return s.stateNode;throw Error(n(33))}function vl(s){return s[Go]||null}var bu=[],Da=-1;function fr(s){return{current:s}}function ht(s){0>Da||(s.current=bu[Da],bu[Da]=null,Da--)}function dt(s,o){Da++,bu[Da]=s.current,s.current=o}var hr={},Xt=fr(hr),pn=fr(!1),Kr=hr;function Fa(s,o){var l=s.type.contextTypes;if(!l)return hr;var f=s.stateNode;if(f&&f.__reactInternalMemoizedUnmaskedChildContext===o)return f.__reactInternalMemoizedMaskedChildContext;var g={},w;for(w in l)g[w]=o[w];return f&&(s=s.stateNode,s.__reactInternalMemoizedUnmaskedChildContext=o,s.__reactInternalMemoizedMaskedChildContext=g),g}function gn(s){return s=s.childContextTypes,s!=null}function _l(){ht(pn),ht(Xt)}function yh(s,o,l){if(Xt.current!==hr)throw Error(n(168));dt(Xt,o),dt(pn,l)}function wh(s,o,l){var f=s.stateNode;if(o=o.childContextTypes,typeof f.getChildContext!="function")return l;f=f.getChildContext();for(var g in f)if(!(g in o))throw Error(n(108,de(s)||"Unknown",g));return re({},l,f)}function bl(s){return s=(s=s.stateNode)&&s.__reactInternalMemoizedMergedChildContext||hr,Kr=Xt.current,dt(Xt,s),dt(pn,pn.current),!0}function vh(s,o,l){var f=s.stateNode;if(!f)throw Error(n(169));l?(s=wh(s,o,Kr),f.__reactInternalMemoizedMergedChildContext=s,ht(pn),ht(Xt),dt(Xt,s)):ht(pn),dt(pn,l)}var Fs=null,xl=!1,xu=!1;function _h(s){Fs===null?Fs=[s]:Fs.push(s)}function fv(s){xl=!0,_h(s)}function mr(){if(!xu&&Fs!==null){xu=!0;var s=0,o=Ke;try{var l=Fs;for(Ke=1;s<l.length;s++){var f=l[s];do f=f(!0);while(f!==null)}Fs=null,xl=!1}catch(g){throw Fs!==null&&(Fs=Fs.slice(s+1)),ko(Cn,mr),g}finally{Ke=o,xu=!1}}return null}var za=[],Ua=0,kl=null,jl=0,Un=[],Bn=0,Jr=null,zs=1,Us="";function Qr(s,o){za[Ua++]=jl,za[Ua++]=kl,kl=s,jl=o}function bh(s,o,l){Un[Bn++]=zs,Un[Bn++]=Us,Un[Bn++]=Jr,Jr=s;var f=zs;s=Us;var g=32-hn(f)-1;f&=~(1<<g),l+=1;var w=32-hn(o)+g;if(30<w){var k=g-g%5;w=(f&(1<<k)-1).toString(32),f>>=k,g-=k,zs=1<<32-hn(o)+g|l<<g|f,Us=w+s}else zs=1<<w|l<<g|f,Us=s}function ku(s){s.return!==null&&(Qr(s,1),bh(s,1,0))}function ju(s){for(;s===kl;)kl=za[--Ua],za[Ua]=null,jl=za[--Ua],za[Ua]=null;for(;s===Jr;)Jr=Un[--Bn],Un[Bn]=null,Us=Un[--Bn],Un[Bn]=null,zs=Un[--Bn],Un[Bn]=null}var Tn=null,Rn=null,gt=!1,ns=null;function xh(s,o){var l=Gn(5,null,null,0);l.elementType="DELETED",l.stateNode=o,l.return=s,o=s.deletions,o===null?(s.deletions=[l],s.flags|=16):o.push(l)}function kh(s,o){switch(s.tag){case 5:var l=s.type;return o=o.nodeType!==1||l.toLowerCase()!==o.nodeName.toLowerCase()?null:o,o!==null?(s.stateNode=o,Tn=s,Rn=dr(o.firstChild),!0):!1;case 6:return o=s.pendingProps===""||o.nodeType!==3?null:o,o!==null?(s.stateNode=o,Tn=s,Rn=null,!0):!1;case 13:return o=o.nodeType!==8?null:o,o!==null?(l=Jr!==null?{id:zs,overflow:Us}:null,s.memoizedState={dehydrated:o,treeContext:l,retryLane:1073741824},l=Gn(18,null,null,0),l.stateNode=o,l.return=s,s.child=l,Tn=s,Rn=null,!0):!1;default:return!1}}function Su(s){return(s.mode&1)!==0&&(s.flags&128)===0}function Nu(s){if(gt){var o=Rn;if(o){var l=o;if(!kh(s,o)){if(Su(s))throw Error(n(418));o=dr(l.nextSibling);var f=Tn;o&&kh(s,o)?xh(f,l):(s.flags=s.flags&-4097|2,gt=!1,Tn=s)}}else{if(Su(s))throw Error(n(418));s.flags=s.flags&-4097|2,gt=!1,Tn=s}}}function jh(s){for(s=s.return;s!==null&&s.tag!==5&&s.tag!==3&&s.tag!==13;)s=s.return;Tn=s}function Sl(s){if(s!==Tn)return!1;if(!gt)return jh(s),gt=!0,!1;var o;if((o=s.tag!==3)&&!(o=s.tag!==5)&&(o=s.type,o=o!=="head"&&o!=="body"&&!yu(s.type,s.memoizedProps)),o&&(o=Rn)){if(Su(s))throw Sh(),Error(n(418));for(;o;)xh(s,o),o=dr(o.nextSibling)}if(jh(s),s.tag===13){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(n(317));e:{for(s=s.nextSibling,o=0;s;){if(s.nodeType===8){var l=s.data;if(l==="/$"){if(o===0){Rn=dr(s.nextSibling);break e}o--}else l!=="$"&&l!=="$!"&&l!=="$?"||o++}s=s.nextSibling}Rn=null}}else Rn=Tn?dr(s.stateNode.nextSibling):null;return!0}function Sh(){for(var s=Rn;s;)s=dr(s.nextSibling)}function Ba(){Rn=Tn=null,gt=!1}function Cu(s){ns===null?ns=[s]:ns.push(s)}var hv=E.ReactCurrentBatchConfig;function Jo(s,o,l){if(s=l.ref,s!==null&&typeof s!="function"&&typeof s!="object"){if(l._owner){if(l=l._owner,l){if(l.tag!==1)throw Error(n(309));var f=l.stateNode}if(!f)throw Error(n(147,s));var g=f,w=""+s;return o!==null&&o.ref!==null&&typeof o.ref=="function"&&o.ref._stringRef===w?o.ref:(o=function(k){var M=g.refs;k===null?delete M[w]:M[w]=k},o._stringRef=w,o)}if(typeof s!="string")throw Error(n(284));if(!l._owner)throw Error(n(290,s))}return s}function Nl(s,o){throw s=Object.prototype.toString.call(o),Error(n(31,s==="[object Object]"?"object with keys {"+Object.keys(o).join(", ")+"}":s))}function Nh(s){var o=s._init;return o(s._payload)}function Ch(s){function o(H,B){if(s){var K=H.deletions;K===null?(H.deletions=[B],H.flags|=16):K.push(B)}}function l(H,B){if(!s)return null;for(;B!==null;)o(H,B),B=B.sibling;return null}function f(H,B){for(H=new Map;B!==null;)B.key!==null?H.set(B.key,B):H.set(B.index,B),B=B.sibling;return H}function g(H,B){return H=xr(H,B),H.index=0,H.sibling=null,H}function w(H,B,K){return H.index=K,s?(K=H.alternate,K!==null?(K=K.index,K<B?(H.flags|=2,B):K):(H.flags|=2,B)):(H.flags|=1048576,B)}function k(H){return s&&H.alternate===null&&(H.flags|=2),H}function M(H,B,K,ye){return B===null||B.tag!==6?(B=wd(K,H.mode,ye),B.return=H,B):(B=g(B,K),B.return=H,B)}function F(H,B,K,ye){var $e=K.type;return $e===z?le(H,B,K.props.children,ye,K.key):B!==null&&(B.elementType===$e||typeof $e=="object"&&$e!==null&&$e.$$typeof===te&&Nh($e)===B.type)?(ye=g(B,K.props),ye.ref=Jo(H,B,K),ye.return=H,ye):(ye=Yl(K.type,K.key,K.props,null,H.mode,ye),ye.ref=Jo(H,B,K),ye.return=H,ye)}function Q(H,B,K,ye){return B===null||B.tag!==4||B.stateNode.containerInfo!==K.containerInfo||B.stateNode.implementation!==K.implementation?(B=vd(K,H.mode,ye),B.return=H,B):(B=g(B,K.children||[]),B.return=H,B)}function le(H,B,K,ye,$e){return B===null||B.tag!==7?(B=sa(K,H.mode,ye,$e),B.return=H,B):(B=g(B,K),B.return=H,B)}function he(H,B,K){if(typeof B=="string"&&B!==""||typeof B=="number")return B=wd(""+B,H.mode,K),B.return=H,B;if(typeof B=="object"&&B!==null){switch(B.$$typeof){case A:return K=Yl(B.type,B.key,B.props,null,H.mode,K),K.ref=Jo(H,null,B),K.return=H,K;case R:return B=vd(B,H.mode,K),B.return=H,B;case te:var ye=B._init;return he(H,ye(B._payload),K)}if(Y(B)||ce(B))return B=sa(B,H.mode,K,null),B.return=H,B;Nl(H,B)}return null}function oe(H,B,K,ye){var $e=B!==null?B.key:null;if(typeof K=="string"&&K!==""||typeof K=="number")return $e!==null?null:M(H,B,""+K,ye);if(typeof K=="object"&&K!==null){switch(K.$$typeof){case A:return K.key===$e?F(H,B,K,ye):null;case R:return K.key===$e?Q(H,B,K,ye):null;case te:return $e=K._init,oe(H,B,$e(K._payload),ye)}if(Y(K)||ce(K))return $e!==null?null:le(H,B,K,ye,null);Nl(H,K)}return null}function xe(H,B,K,ye,$e){if(typeof ye=="string"&&ye!==""||typeof ye=="number")return H=H.get(K)||null,M(B,H,""+ye,$e);if(typeof ye=="object"&&ye!==null){switch(ye.$$typeof){case A:return H=H.get(ye.key===null?K:ye.key)||null,F(B,H,ye,$e);case R:return H=H.get(ye.key===null?K:ye.key)||null,Q(B,H,ye,$e);case te:var Ie=ye._init;return xe(H,B,K,Ie(ye._payload),$e)}if(Y(ye)||ce(ye))return H=H.get(K)||null,le(B,H,ye,$e,null);Nl(B,ye)}return null}function Se(H,B,K,ye){for(var $e=null,Ie=null,Me=B,Fe=B=0,zt=null;Me!==null&&Fe<K.length;Fe++){Me.index>Fe?(zt=Me,Me=null):zt=Me.sibling;var Ze=oe(H,Me,K[Fe],ye);if(Ze===null){Me===null&&(Me=zt);break}s&&Me&&Ze.alternate===null&&o(H,Me),B=w(Ze,B,Fe),Ie===null?$e=Ze:Ie.sibling=Ze,Ie=Ze,Me=zt}if(Fe===K.length)return l(H,Me),gt&&Qr(H,Fe),$e;if(Me===null){for(;Fe<K.length;Fe++)Me=he(H,K[Fe],ye),Me!==null&&(B=w(Me,B,Fe),Ie===null?$e=Me:Ie.sibling=Me,Ie=Me);return gt&&Qr(H,Fe),$e}for(Me=f(H,Me);Fe<K.length;Fe++)zt=xe(Me,H,Fe,K[Fe],ye),zt!==null&&(s&&zt.alternate!==null&&Me.delete(zt.key===null?Fe:zt.key),B=w(zt,B,Fe),Ie===null?$e=zt:Ie.sibling=zt,Ie=zt);return s&&Me.forEach(function(kr){return o(H,kr)}),gt&&Qr(H,Fe),$e}function Ce(H,B,K,ye){var $e=ce(K);if(typeof $e!="function")throw Error(n(150));if(K=$e.call(K),K==null)throw Error(n(151));for(var Ie=$e=null,Me=B,Fe=B=0,zt=null,Ze=K.next();Me!==null&&!Ze.done;Fe++,Ze=K.next()){Me.index>Fe?(zt=Me,Me=null):zt=Me.sibling;var kr=oe(H,Me,Ze.value,ye);if(kr===null){Me===null&&(Me=zt);break}s&&Me&&kr.alternate===null&&o(H,Me),B=w(kr,B,Fe),Ie===null?$e=kr:Ie.sibling=kr,Ie=kr,Me=zt}if(Ze.done)return l(H,Me),gt&&Qr(H,Fe),$e;if(Me===null){for(;!Ze.done;Fe++,Ze=K.next())Ze=he(H,Ze.value,ye),Ze!==null&&(B=w(Ze,B,Fe),Ie===null?$e=Ze:Ie.sibling=Ze,Ie=Ze);return gt&&Qr(H,Fe),$e}for(Me=f(H,Me);!Ze.done;Fe++,Ze=K.next())Ze=xe(Me,H,Fe,Ze.value,ye),Ze!==null&&(s&&Ze.alternate!==null&&Me.delete(Ze.key===null?Fe:Ze.key),B=w(Ze,B,Fe),Ie===null?$e=Ze:Ie.sibling=Ze,Ie=Ze);return s&&Me.forEach(function(Gv){return o(H,Gv)}),gt&&Qr(H,Fe),$e}function Ct(H,B,K,ye){if(typeof K=="object"&&K!==null&&K.type===z&&K.key===null&&(K=K.props.children),typeof K=="object"&&K!==null){switch(K.$$typeof){case A:e:{for(var $e=K.key,Ie=B;Ie!==null;){if(Ie.key===$e){if($e=K.type,$e===z){if(Ie.tag===7){l(H,Ie.sibling),B=g(Ie,K.props.children),B.return=H,H=B;break e}}else if(Ie.elementType===$e||typeof $e=="object"&&$e!==null&&$e.$$typeof===te&&Nh($e)===Ie.type){l(H,Ie.sibling),B=g(Ie,K.props),B.ref=Jo(H,Ie,K),B.return=H,H=B;break e}l(H,Ie);break}else o(H,Ie);Ie=Ie.sibling}K.type===z?(B=sa(K.props.children,H.mode,ye,K.key),B.return=H,H=B):(ye=Yl(K.type,K.key,K.props,null,H.mode,ye),ye.ref=Jo(H,B,K),ye.return=H,H=ye)}return k(H);case R:e:{for(Ie=K.key;B!==null;){if(B.key===Ie)if(B.tag===4&&B.stateNode.containerInfo===K.containerInfo&&B.stateNode.implementation===K.implementation){l(H,B.sibling),B=g(B,K.children||[]),B.return=H,H=B;break e}else{l(H,B);break}else o(H,B);B=B.sibling}B=vd(K,H.mode,ye),B.return=H,H=B}return k(H);case te:return Ie=K._init,Ct(H,B,Ie(K._payload),ye)}if(Y(K))return Se(H,B,K,ye);if(ce(K))return Ce(H,B,K,ye);Nl(H,K)}return typeof K=="string"&&K!==""||typeof K=="number"?(K=""+K,B!==null&&B.tag===6?(l(H,B.sibling),B=g(B,K),B.return=H,H=B):(l(H,B),B=wd(K,H.mode,ye),B.return=H,H=B),k(H)):l(H,B)}return Ct}var Wa=Ch(!0),Eh=Ch(!1),Cl=fr(null),El=null,Va=null,Eu=null;function $u(){Eu=Va=El=null}function Au(s){var o=Cl.current;ht(Cl),s._currentValue=o}function Tu(s,o,l){for(;s!==null;){var f=s.alternate;if((s.childLanes&o)!==o?(s.childLanes|=o,f!==null&&(f.childLanes|=o)):f!==null&&(f.childLanes&o)!==o&&(f.childLanes|=o),s===l)break;s=s.return}}function Ha(s,o){El=s,Eu=Va=null,s=s.dependencies,s!==null&&s.firstContext!==null&&((s.lanes&o)!==0&&(yn=!0),s.firstContext=null)}function Wn(s){var o=s._currentValue;if(Eu!==s)if(s={context:s,memoizedValue:o,next:null},Va===null){if(El===null)throw Error(n(308));Va=s,El.dependencies={lanes:0,firstContext:s}}else Va=Va.next=s;return o}var Yr=null;function Ru(s){Yr===null?Yr=[s]:Yr.push(s)}function $h(s,o,l,f){var g=o.interleaved;return g===null?(l.next=l,Ru(o)):(l.next=g.next,g.next=l),o.interleaved=l,Bs(s,f)}function Bs(s,o){s.lanes|=o;var l=s.alternate;for(l!==null&&(l.lanes|=o),l=s,s=s.return;s!==null;)s.childLanes|=o,l=s.alternate,l!==null&&(l.childLanes|=o),l=s,s=s.return;return l.tag===3?l.stateNode:null}var pr=!1;function Iu(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ah(s,o){s=s.updateQueue,o.updateQueue===s&&(o.updateQueue={baseState:s.baseState,firstBaseUpdate:s.firstBaseUpdate,lastBaseUpdate:s.lastBaseUpdate,shared:s.shared,effects:s.effects})}function Ws(s,o){return{eventTime:s,lane:o,tag:0,payload:null,callback:null,next:null}}function gr(s,o,l){var f=s.updateQueue;if(f===null)return null;if(f=f.shared,(qe&2)!==0){var g=f.pending;return g===null?o.next=o:(o.next=g.next,g.next=o),f.pending=o,Bs(s,l)}return g=f.interleaved,g===null?(o.next=o,Ru(f)):(o.next=g.next,g.next=o),f.interleaved=o,Bs(s,l)}function $l(s,o,l){if(o=o.updateQueue,o!==null&&(o=o.shared,(l&4194240)!==0)){var f=o.lanes;f&=s.pendingLanes,l|=f,o.lanes=l,Xn(s,l)}}function Th(s,o){var l=s.updateQueue,f=s.alternate;if(f!==null&&(f=f.updateQueue,l===f)){var g=null,w=null;if(l=l.firstBaseUpdate,l!==null){do{var k={eventTime:l.eventTime,lane:l.lane,tag:l.tag,payload:l.payload,callback:l.callback,next:null};w===null?g=w=k:w=w.next=k,l=l.next}while(l!==null);w===null?g=w=o:w=w.next=o}else g=w=o;l={baseState:f.baseState,firstBaseUpdate:g,lastBaseUpdate:w,shared:f.shared,effects:f.effects},s.updateQueue=l;return}s=l.lastBaseUpdate,s===null?l.firstBaseUpdate=o:s.next=o,l.lastBaseUpdate=o}function Al(s,o,l,f){var g=s.updateQueue;pr=!1;var w=g.firstBaseUpdate,k=g.lastBaseUpdate,M=g.shared.pending;if(M!==null){g.shared.pending=null;var F=M,Q=F.next;F.next=null,k===null?w=Q:k.next=Q,k=F;var le=s.alternate;le!==null&&(le=le.updateQueue,M=le.lastBaseUpdate,M!==k&&(M===null?le.firstBaseUpdate=Q:M.next=Q,le.lastBaseUpdate=F))}if(w!==null){var he=g.baseState;k=0,le=Q=F=null,M=w;do{var oe=M.lane,xe=M.eventTime;if((f&oe)===oe){le!==null&&(le=le.next={eventTime:xe,lane:0,tag:M.tag,payload:M.payload,callback:M.callback,next:null});e:{var Se=s,Ce=M;switch(oe=o,xe=l,Ce.tag){case 1:if(Se=Ce.payload,typeof Se=="function"){he=Se.call(xe,he,oe);break e}he=Se;break e;case 3:Se.flags=Se.flags&-65537|128;case 0:if(Se=Ce.payload,oe=typeof Se=="function"?Se.call(xe,he,oe):Se,oe==null)break e;he=re({},he,oe);break e;case 2:pr=!0}}M.callback!==null&&M.lane!==0&&(s.flags|=64,oe=g.effects,oe===null?g.effects=[M]:oe.push(M))}else xe={eventTime:xe,lane:oe,tag:M.tag,payload:M.payload,callback:M.callback,next:null},le===null?(Q=le=xe,F=he):le=le.next=xe,k|=oe;if(M=M.next,M===null){if(M=g.shared.pending,M===null)break;oe=M,M=oe.next,oe.next=null,g.lastBaseUpdate=oe,g.shared.pending=null}}while(!0);if(le===null&&(F=he),g.baseState=F,g.firstBaseUpdate=Q,g.lastBaseUpdate=le,o=g.shared.interleaved,o!==null){g=o;do k|=g.lane,g=g.next;while(g!==o)}else w===null&&(g.shared.lanes=0);Zr|=k,s.lanes=k,s.memoizedState=he}}function Rh(s,o,l){if(s=o.effects,o.effects=null,s!==null)for(o=0;o<s.length;o++){var f=s[o],g=f.callback;if(g!==null){if(f.callback=null,f=l,typeof g!="function")throw Error(n(191,g));g.call(f)}}}var Qo={},xs=fr(Qo),Yo=fr(Qo),Xo=fr(Qo);function Xr(s){if(s===Qo)throw Error(n(174));return s}function Mu(s,o){switch(dt(Xo,o),dt(Yo,s),dt(xs,Qo),s=o.nodeType,s){case 9:case 11:o=(o=o.documentElement)?o.namespaceURI:mt(null,"");break;default:s=s===8?o.parentNode:o,o=s.namespaceURI||null,s=s.tagName,o=mt(o,s)}ht(xs),dt(xs,o)}function Ga(){ht(xs),ht(Yo),ht(Xo)}function Ih(s){Xr(Xo.current);var o=Xr(xs.current),l=mt(o,s.type);o!==l&&(dt(Yo,s),dt(xs,l))}function Lu(s){Yo.current===s&&(ht(xs),ht(Yo))}var yt=fr(0);function Tl(s){for(var o=s;o!==null;){if(o.tag===13){var l=o.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||l.data==="$?"||l.data==="$!"))return o}else if(o.tag===19&&o.memoizedProps.revealOrder!==void 0){if((o.flags&128)!==0)return o}else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===s)break;for(;o.sibling===null;){if(o.return===null||o.return===s)return null;o=o.return}o.sibling.return=o.return,o=o.sibling}return null}var Ou=[];function Pu(){for(var s=0;s<Ou.length;s++)Ou[s]._workInProgressVersionPrimary=null;Ou.length=0}var Rl=E.ReactCurrentDispatcher,Du=E.ReactCurrentBatchConfig,qr=0,wt=null,It=null,Dt=null,Il=!1,qo=!1,Zo=0,mv=0;function qt(){throw Error(n(321))}function Fu(s,o){if(o===null)return!1;for(var l=0;l<o.length&&l<s.length;l++)if(!ts(s[l],o[l]))return!1;return!0}function zu(s,o,l,f,g,w){if(qr=w,wt=o,o.memoizedState=null,o.updateQueue=null,o.lanes=0,Rl.current=s===null||s.memoizedState===null?wv:vv,s=l(f,g),qo){w=0;do{if(qo=!1,Zo=0,25<=w)throw Error(n(301));w+=1,Dt=It=null,o.updateQueue=null,Rl.current=_v,s=l(f,g)}while(qo)}if(Rl.current=Ol,o=It!==null&&It.next!==null,qr=0,Dt=It=wt=null,Il=!1,o)throw Error(n(300));return s}function Uu(){var s=Zo!==0;return Zo=0,s}function ks(){var s={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Dt===null?wt.memoizedState=Dt=s:Dt=Dt.next=s,Dt}function Vn(){if(It===null){var s=wt.alternate;s=s!==null?s.memoizedState:null}else s=It.next;var o=Dt===null?wt.memoizedState:Dt.next;if(o!==null)Dt=o,It=s;else{if(s===null)throw Error(n(310));It=s,s={memoizedState:It.memoizedState,baseState:It.baseState,baseQueue:It.baseQueue,queue:It.queue,next:null},Dt===null?wt.memoizedState=Dt=s:Dt=Dt.next=s}return Dt}function ei(s,o){return typeof o=="function"?o(s):o}function Bu(s){var o=Vn(),l=o.queue;if(l===null)throw Error(n(311));l.lastRenderedReducer=s;var f=It,g=f.baseQueue,w=l.pending;if(w!==null){if(g!==null){var k=g.next;g.next=w.next,w.next=k}f.baseQueue=g=w,l.pending=null}if(g!==null){w=g.next,f=f.baseState;var M=k=null,F=null,Q=w;do{var le=Q.lane;if((qr&le)===le)F!==null&&(F=F.next={lane:0,action:Q.action,hasEagerState:Q.hasEagerState,eagerState:Q.eagerState,next:null}),f=Q.hasEagerState?Q.eagerState:s(f,Q.action);else{var he={lane:le,action:Q.action,hasEagerState:Q.hasEagerState,eagerState:Q.eagerState,next:null};F===null?(M=F=he,k=f):F=F.next=he,wt.lanes|=le,Zr|=le}Q=Q.next}while(Q!==null&&Q!==w);F===null?k=f:F.next=M,ts(f,o.memoizedState)||(yn=!0),o.memoizedState=f,o.baseState=k,o.baseQueue=F,l.lastRenderedState=f}if(s=l.interleaved,s!==null){g=s;do w=g.lane,wt.lanes|=w,Zr|=w,g=g.next;while(g!==s)}else g===null&&(l.lanes=0);return[o.memoizedState,l.dispatch]}function Wu(s){var o=Vn(),l=o.queue;if(l===null)throw Error(n(311));l.lastRenderedReducer=s;var f=l.dispatch,g=l.pending,w=o.memoizedState;if(g!==null){l.pending=null;var k=g=g.next;do w=s(w,k.action),k=k.next;while(k!==g);ts(w,o.memoizedState)||(yn=!0),o.memoizedState=w,o.baseQueue===null&&(o.baseState=w),l.lastRenderedState=w}return[w,f]}function Mh(){}function Lh(s,o){var l=wt,f=Vn(),g=o(),w=!ts(f.memoizedState,g);if(w&&(f.memoizedState=g,yn=!0),f=f.queue,Vu(Dh.bind(null,l,f,s),[s]),f.getSnapshot!==o||w||Dt!==null&&Dt.memoizedState.tag&1){if(l.flags|=2048,ti(9,Ph.bind(null,l,f,g,o),void 0,null),Ft===null)throw Error(n(349));(qr&30)!==0||Oh(l,o,g)}return g}function Oh(s,o,l){s.flags|=16384,s={getSnapshot:o,value:l},o=wt.updateQueue,o===null?(o={lastEffect:null,stores:null},wt.updateQueue=o,o.stores=[s]):(l=o.stores,l===null?o.stores=[s]:l.push(s))}function Ph(s,o,l,f){o.value=l,o.getSnapshot=f,Fh(o)&&zh(s)}function Dh(s,o,l){return l(function(){Fh(o)&&zh(s)})}function Fh(s){var o=s.getSnapshot;s=s.value;try{var l=o();return!ts(s,l)}catch{return!0}}function zh(s){var o=Bs(s,1);o!==null&&os(o,s,1,-1)}function Uh(s){var o=ks();return typeof s=="function"&&(s=s()),o.memoizedState=o.baseState=s,s={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:ei,lastRenderedState:s},o.queue=s,s=s.dispatch=yv.bind(null,wt,s),[o.memoizedState,s]}function ti(s,o,l,f){return s={tag:s,create:o,destroy:l,deps:f,next:null},o=wt.updateQueue,o===null?(o={lastEffect:null,stores:null},wt.updateQueue=o,o.lastEffect=s.next=s):(l=o.lastEffect,l===null?o.lastEffect=s.next=s:(f=l.next,l.next=s,s.next=f,o.lastEffect=s)),s}function Bh(){return Vn().memoizedState}function Ml(s,o,l,f){var g=ks();wt.flags|=s,g.memoizedState=ti(1|o,l,void 0,f===void 0?null:f)}function Ll(s,o,l,f){var g=Vn();f=f===void 0?null:f;var w=void 0;if(It!==null){var k=It.memoizedState;if(w=k.destroy,f!==null&&Fu(f,k.deps)){g.memoizedState=ti(o,l,w,f);return}}wt.flags|=s,g.memoizedState=ti(1|o,l,w,f)}function Wh(s,o){return Ml(8390656,8,s,o)}function Vu(s,o){return Ll(2048,8,s,o)}function Vh(s,o){return Ll(4,2,s,o)}function Hh(s,o){return Ll(4,4,s,o)}function Gh(s,o){if(typeof o=="function")return s=s(),o(s),function(){o(null)};if(o!=null)return s=s(),o.current=s,function(){o.current=null}}function Kh(s,o,l){return l=l!=null?l.concat([s]):null,Ll(4,4,Gh.bind(null,o,s),l)}function Hu(){}function Jh(s,o){var l=Vn();o=o===void 0?null:o;var f=l.memoizedState;return f!==null&&o!==null&&Fu(o,f[1])?f[0]:(l.memoizedState=[s,o],s)}function Qh(s,o){var l=Vn();o=o===void 0?null:o;var f=l.memoizedState;return f!==null&&o!==null&&Fu(o,f[1])?f[0]:(s=s(),l.memoizedState=[s,o],s)}function Yh(s,o,l){return(qr&21)===0?(s.baseState&&(s.baseState=!1,yn=!0),s.memoizedState=l):(ts(l,o)||(l=Qn(),wt.lanes|=l,Zr|=l,s.baseState=!0),o)}function pv(s,o){var l=Ke;Ke=l!==0&&4>l?l:4,s(!0);var f=Du.transition;Du.transition={};try{s(!1),o()}finally{Ke=l,Du.transition=f}}function Xh(){return Vn().memoizedState}function gv(s,o,l){var f=_r(s);if(l={lane:f,action:l,hasEagerState:!1,eagerState:null,next:null},qh(s))Zh(o,l);else if(l=$h(s,o,l,f),l!==null){var g=an();os(l,s,f,g),em(l,o,f)}}function yv(s,o,l){var f=_r(s),g={lane:f,action:l,hasEagerState:!1,eagerState:null,next:null};if(qh(s))Zh(o,g);else{var w=s.alternate;if(s.lanes===0&&(w===null||w.lanes===0)&&(w=o.lastRenderedReducer,w!==null))try{var k=o.lastRenderedState,M=w(k,l);if(g.hasEagerState=!0,g.eagerState=M,ts(M,k)){var F=o.interleaved;F===null?(g.next=g,Ru(o)):(g.next=F.next,F.next=g),o.interleaved=g;return}}catch{}finally{}l=$h(s,o,g,f),l!==null&&(g=an(),os(l,s,f,g),em(l,o,f))}}function qh(s){var o=s.alternate;return s===wt||o!==null&&o===wt}function Zh(s,o){qo=Il=!0;var l=s.pending;l===null?o.next=o:(o.next=l.next,l.next=o),s.pending=o}function em(s,o,l){if((l&4194240)!==0){var f=o.lanes;f&=s.pendingLanes,l|=f,o.lanes=l,Xn(s,l)}}var Ol={readContext:Wn,useCallback:qt,useContext:qt,useEffect:qt,useImperativeHandle:qt,useInsertionEffect:qt,useLayoutEffect:qt,useMemo:qt,useReducer:qt,useRef:qt,useState:qt,useDebugValue:qt,useDeferredValue:qt,useTransition:qt,useMutableSource:qt,useSyncExternalStore:qt,useId:qt,unstable_isNewReconciler:!1},wv={readContext:Wn,useCallback:function(s,o){return ks().memoizedState=[s,o===void 0?null:o],s},useContext:Wn,useEffect:Wh,useImperativeHandle:function(s,o,l){return l=l!=null?l.concat([s]):null,Ml(4194308,4,Gh.bind(null,o,s),l)},useLayoutEffect:function(s,o){return Ml(4194308,4,s,o)},useInsertionEffect:function(s,o){return Ml(4,2,s,o)},useMemo:function(s,o){var l=ks();return o=o===void 0?null:o,s=s(),l.memoizedState=[s,o],s},useReducer:function(s,o,l){var f=ks();return o=l!==void 0?l(o):o,f.memoizedState=f.baseState=o,s={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:o},f.queue=s,s=s.dispatch=gv.bind(null,wt,s),[f.memoizedState,s]},useRef:function(s){var o=ks();return s={current:s},o.memoizedState=s},useState:Uh,useDebugValue:Hu,useDeferredValue:function(s){return ks().memoizedState=s},useTransition:function(){var s=Uh(!1),o=s[0];return s=pv.bind(null,s[1]),ks().memoizedState=s,[o,s]},useMutableSource:function(){},useSyncExternalStore:function(s,o,l){var f=wt,g=ks();if(gt){if(l===void 0)throw Error(n(407));l=l()}else{if(l=o(),Ft===null)throw Error(n(349));(qr&30)!==0||Oh(f,o,l)}g.memoizedState=l;var w={value:l,getSnapshot:o};return g.queue=w,Wh(Dh.bind(null,f,w,s),[s]),f.flags|=2048,ti(9,Ph.bind(null,f,w,l,o),void 0,null),l},useId:function(){var s=ks(),o=Ft.identifierPrefix;if(gt){var l=Us,f=zs;l=(f&~(1<<32-hn(f)-1)).toString(32)+l,o=":"+o+"R"+l,l=Zo++,0<l&&(o+="H"+l.toString(32)),o+=":"}else l=mv++,o=":"+o+"r"+l.toString(32)+":";return s.memoizedState=o},unstable_isNewReconciler:!1},vv={readContext:Wn,useCallback:Jh,useContext:Wn,useEffect:Vu,useImperativeHandle:Kh,useInsertionEffect:Vh,useLayoutEffect:Hh,useMemo:Qh,useReducer:Bu,useRef:Bh,useState:function(){return Bu(ei)},useDebugValue:Hu,useDeferredValue:function(s){var o=Vn();return Yh(o,It.memoizedState,s)},useTransition:function(){var s=Bu(ei)[0],o=Vn().memoizedState;return[s,o]},useMutableSource:Mh,useSyncExternalStore:Lh,useId:Xh,unstable_isNewReconciler:!1},_v={readContext:Wn,useCallback:Jh,useContext:Wn,useEffect:Vu,useImperativeHandle:Kh,useInsertionEffect:Vh,useLayoutEffect:Hh,useMemo:Qh,useReducer:Wu,useRef:Bh,useState:function(){return Wu(ei)},useDebugValue:Hu,useDeferredValue:function(s){var o=Vn();return It===null?o.memoizedState=s:Yh(o,It.memoizedState,s)},useTransition:function(){var s=Wu(ei)[0],o=Vn().memoizedState;return[s,o]},useMutableSource:Mh,useSyncExternalStore:Lh,useId:Xh,unstable_isNewReconciler:!1};function ss(s,o){if(s&&s.defaultProps){o=re({},o),s=s.defaultProps;for(var l in s)o[l]===void 0&&(o[l]=s[l]);return o}return o}function Gu(s,o,l,f){o=s.memoizedState,l=l(f,o),l=l==null?o:re({},o,l),s.memoizedState=l,s.lanes===0&&(s.updateQueue.baseState=l)}var Pl={isMounted:function(s){return(s=s._reactInternals)?dn(s)===s:!1},enqueueSetState:function(s,o,l){s=s._reactInternals;var f=an(),g=_r(s),w=Ws(f,g);w.payload=o,l!=null&&(w.callback=l),o=gr(s,w,g),o!==null&&(os(o,s,g,f),$l(o,s,g))},enqueueReplaceState:function(s,o,l){s=s._reactInternals;var f=an(),g=_r(s),w=Ws(f,g);w.tag=1,w.payload=o,l!=null&&(w.callback=l),o=gr(s,w,g),o!==null&&(os(o,s,g,f),$l(o,s,g))},enqueueForceUpdate:function(s,o){s=s._reactInternals;var l=an(),f=_r(s),g=Ws(l,f);g.tag=2,o!=null&&(g.callback=o),o=gr(s,g,f),o!==null&&(os(o,s,f,l),$l(o,s,f))}};function tm(s,o,l,f,g,w,k){return s=s.stateNode,typeof s.shouldComponentUpdate=="function"?s.shouldComponentUpdate(f,w,k):o.prototype&&o.prototype.isPureReactComponent?!Uo(l,f)||!Uo(g,w):!0}function nm(s,o,l){var f=!1,g=hr,w=o.contextType;return typeof w=="object"&&w!==null?w=Wn(w):(g=gn(o)?Kr:Xt.current,f=o.contextTypes,w=(f=f!=null)?Fa(s,g):hr),o=new o(l,w),s.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,o.updater=Pl,s.stateNode=o,o._reactInternals=s,f&&(s=s.stateNode,s.__reactInternalMemoizedUnmaskedChildContext=g,s.__reactInternalMemoizedMaskedChildContext=w),o}function sm(s,o,l,f){s=o.state,typeof o.componentWillReceiveProps=="function"&&o.componentWillReceiveProps(l,f),typeof o.UNSAFE_componentWillReceiveProps=="function"&&o.UNSAFE_componentWillReceiveProps(l,f),o.state!==s&&Pl.enqueueReplaceState(o,o.state,null)}function Ku(s,o,l,f){var g=s.stateNode;g.props=l,g.state=s.memoizedState,g.refs={},Iu(s);var w=o.contextType;typeof w=="object"&&w!==null?g.context=Wn(w):(w=gn(o)?Kr:Xt.current,g.context=Fa(s,w)),g.state=s.memoizedState,w=o.getDerivedStateFromProps,typeof w=="function"&&(Gu(s,o,w,l),g.state=s.memoizedState),typeof o.getDerivedStateFromProps=="function"||typeof g.getSnapshotBeforeUpdate=="function"||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(o=g.state,typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount(),o!==g.state&&Pl.enqueueReplaceState(g,g.state,null),Al(s,l,g,f),g.state=s.memoizedState),typeof g.componentDidMount=="function"&&(s.flags|=4194308)}function Ka(s,o){try{var l="",f=o;do l+=q(f),f=f.return;while(f);var g=l}catch(w){g=`
|
|
39
|
+
Error generating stack: `+w.message+`
|
|
40
|
+
`+w.stack}return{value:s,source:o,stack:g,digest:null}}function Ju(s,o,l){return{value:s,source:null,stack:l??null,digest:o??null}}function Qu(s,o){try{console.error(o.value)}catch(l){setTimeout(function(){throw l})}}var bv=typeof WeakMap=="function"?WeakMap:Map;function rm(s,o,l){l=Ws(-1,l),l.tag=3,l.payload={element:null};var f=o.value;return l.callback=function(){Vl||(Vl=!0,ud=f),Qu(s,o)},l}function am(s,o,l){l=Ws(-1,l),l.tag=3;var f=s.type.getDerivedStateFromError;if(typeof f=="function"){var g=o.value;l.payload=function(){return f(g)},l.callback=function(){Qu(s,o)}}var w=s.stateNode;return w!==null&&typeof w.componentDidCatch=="function"&&(l.callback=function(){Qu(s,o),typeof f!="function"&&(wr===null?wr=new Set([this]):wr.add(this));var k=o.stack;this.componentDidCatch(o.value,{componentStack:k!==null?k:""})}),l}function om(s,o,l){var f=s.pingCache;if(f===null){f=s.pingCache=new bv;var g=new Set;f.set(o,g)}else g=f.get(o),g===void 0&&(g=new Set,f.set(o,g));g.has(l)||(g.add(l),s=Lv.bind(null,s,o,l),o.then(s,s))}function im(s){do{var o;if((o=s.tag===13)&&(o=s.memoizedState,o=o!==null?o.dehydrated!==null:!0),o)return s;s=s.return}while(s!==null);return null}function lm(s,o,l,f,g){return(s.mode&1)===0?(s===o?s.flags|=65536:(s.flags|=128,l.flags|=131072,l.flags&=-52805,l.tag===1&&(l.alternate===null?l.tag=17:(o=Ws(-1,1),o.tag=2,gr(l,o,1))),l.lanes|=1),s):(s.flags|=65536,s.lanes=g,s)}var xv=E.ReactCurrentOwner,yn=!1;function rn(s,o,l,f){o.child=s===null?Eh(o,null,l,f):Wa(o,s.child,l,f)}function cm(s,o,l,f,g){l=l.render;var w=o.ref;return Ha(o,g),f=zu(s,o,l,f,w,g),l=Uu(),s!==null&&!yn?(o.updateQueue=s.updateQueue,o.flags&=-2053,s.lanes&=~g,Vs(s,o,g)):(gt&&l&&ku(o),o.flags|=1,rn(s,o,f,g),o.child)}function um(s,o,l,f,g){if(s===null){var w=l.type;return typeof w=="function"&&!yd(w)&&w.defaultProps===void 0&&l.compare===null&&l.defaultProps===void 0?(o.tag=15,o.type=w,dm(s,o,w,f,g)):(s=Yl(l.type,null,f,o,o.mode,g),s.ref=o.ref,s.return=o,o.child=s)}if(w=s.child,(s.lanes&g)===0){var k=w.memoizedProps;if(l=l.compare,l=l!==null?l:Uo,l(k,f)&&s.ref===o.ref)return Vs(s,o,g)}return o.flags|=1,s=xr(w,f),s.ref=o.ref,s.return=o,o.child=s}function dm(s,o,l,f,g){if(s!==null){var w=s.memoizedProps;if(Uo(w,f)&&s.ref===o.ref)if(yn=!1,o.pendingProps=f=w,(s.lanes&g)!==0)(s.flags&131072)!==0&&(yn=!0);else return o.lanes=s.lanes,Vs(s,o,g)}return Yu(s,o,l,f,g)}function fm(s,o,l){var f=o.pendingProps,g=f.children,w=s!==null?s.memoizedState:null;if(f.mode==="hidden")if((o.mode&1)===0)o.memoizedState={baseLanes:0,cachePool:null,transitions:null},dt(Qa,In),In|=l;else{if((l&1073741824)===0)return s=w!==null?w.baseLanes|l:l,o.lanes=o.childLanes=1073741824,o.memoizedState={baseLanes:s,cachePool:null,transitions:null},o.updateQueue=null,dt(Qa,In),In|=s,null;o.memoizedState={baseLanes:0,cachePool:null,transitions:null},f=w!==null?w.baseLanes:l,dt(Qa,In),In|=f}else w!==null?(f=w.baseLanes|l,o.memoizedState=null):f=l,dt(Qa,In),In|=f;return rn(s,o,g,l),o.child}function hm(s,o){var l=o.ref;(s===null&&l!==null||s!==null&&s.ref!==l)&&(o.flags|=512,o.flags|=2097152)}function Yu(s,o,l,f,g){var w=gn(l)?Kr:Xt.current;return w=Fa(o,w),Ha(o,g),l=zu(s,o,l,f,w,g),f=Uu(),s!==null&&!yn?(o.updateQueue=s.updateQueue,o.flags&=-2053,s.lanes&=~g,Vs(s,o,g)):(gt&&f&&ku(o),o.flags|=1,rn(s,o,l,g),o.child)}function mm(s,o,l,f,g){if(gn(l)){var w=!0;bl(o)}else w=!1;if(Ha(o,g),o.stateNode===null)Fl(s,o),nm(o,l,f),Ku(o,l,f,g),f=!0;else if(s===null){var k=o.stateNode,M=o.memoizedProps;k.props=M;var F=k.context,Q=l.contextType;typeof Q=="object"&&Q!==null?Q=Wn(Q):(Q=gn(l)?Kr:Xt.current,Q=Fa(o,Q));var le=l.getDerivedStateFromProps,he=typeof le=="function"||typeof k.getSnapshotBeforeUpdate=="function";he||typeof k.UNSAFE_componentWillReceiveProps!="function"&&typeof k.componentWillReceiveProps!="function"||(M!==f||F!==Q)&&sm(o,k,f,Q),pr=!1;var oe=o.memoizedState;k.state=oe,Al(o,f,k,g),F=o.memoizedState,M!==f||oe!==F||pn.current||pr?(typeof le=="function"&&(Gu(o,l,le,f),F=o.memoizedState),(M=pr||tm(o,l,M,f,oe,F,Q))?(he||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"&&(o.flags|=4194308)):(typeof k.componentDidMount=="function"&&(o.flags|=4194308),o.memoizedProps=f,o.memoizedState=F),k.props=f,k.state=F,k.context=Q,f=M):(typeof k.componentDidMount=="function"&&(o.flags|=4194308),f=!1)}else{k=o.stateNode,Ah(s,o),M=o.memoizedProps,Q=o.type===o.elementType?M:ss(o.type,M),k.props=Q,he=o.pendingProps,oe=k.context,F=l.contextType,typeof F=="object"&&F!==null?F=Wn(F):(F=gn(l)?Kr:Xt.current,F=Fa(o,F));var xe=l.getDerivedStateFromProps;(le=typeof xe=="function"||typeof k.getSnapshotBeforeUpdate=="function")||typeof k.UNSAFE_componentWillReceiveProps!="function"&&typeof k.componentWillReceiveProps!="function"||(M!==he||oe!==F)&&sm(o,k,f,F),pr=!1,oe=o.memoizedState,k.state=oe,Al(o,f,k,g);var Se=o.memoizedState;M!==he||oe!==Se||pn.current||pr?(typeof xe=="function"&&(Gu(o,l,xe,f),Se=o.memoizedState),(Q=pr||tm(o,l,Q,f,oe,Se,F)||!1)?(le||typeof k.UNSAFE_componentWillUpdate!="function"&&typeof k.componentWillUpdate!="function"||(typeof k.componentWillUpdate=="function"&&k.componentWillUpdate(f,Se,F),typeof k.UNSAFE_componentWillUpdate=="function"&&k.UNSAFE_componentWillUpdate(f,Se,F)),typeof k.componentDidUpdate=="function"&&(o.flags|=4),typeof k.getSnapshotBeforeUpdate=="function"&&(o.flags|=1024)):(typeof k.componentDidUpdate!="function"||M===s.memoizedProps&&oe===s.memoizedState||(o.flags|=4),typeof k.getSnapshotBeforeUpdate!="function"||M===s.memoizedProps&&oe===s.memoizedState||(o.flags|=1024),o.memoizedProps=f,o.memoizedState=Se),k.props=f,k.state=Se,k.context=F,f=Q):(typeof k.componentDidUpdate!="function"||M===s.memoizedProps&&oe===s.memoizedState||(o.flags|=4),typeof k.getSnapshotBeforeUpdate!="function"||M===s.memoizedProps&&oe===s.memoizedState||(o.flags|=1024),f=!1)}return Xu(s,o,l,f,w,g)}function Xu(s,o,l,f,g,w){hm(s,o);var k=(o.flags&128)!==0;if(!f&&!k)return g&&vh(o,l,!1),Vs(s,o,w);f=o.stateNode,xv.current=o;var M=k&&typeof l.getDerivedStateFromError!="function"?null:f.render();return o.flags|=1,s!==null&&k?(o.child=Wa(o,s.child,null,w),o.child=Wa(o,null,M,w)):rn(s,o,M,w),o.memoizedState=f.state,g&&vh(o,l,!0),o.child}function pm(s){var o=s.stateNode;o.pendingContext?yh(s,o.pendingContext,o.pendingContext!==o.context):o.context&&yh(s,o.context,!1),Mu(s,o.containerInfo)}function gm(s,o,l,f,g){return Ba(),Cu(g),o.flags|=256,rn(s,o,l,f),o.child}var qu={dehydrated:null,treeContext:null,retryLane:0};function Zu(s){return{baseLanes:s,cachePool:null,transitions:null}}function ym(s,o,l){var f=o.pendingProps,g=yt.current,w=!1,k=(o.flags&128)!==0,M;if((M=k)||(M=s!==null&&s.memoizedState===null?!1:(g&2)!==0),M?(w=!0,o.flags&=-129):(s===null||s.memoizedState!==null)&&(g|=1),dt(yt,g&1),s===null)return Nu(o),s=o.memoizedState,s!==null&&(s=s.dehydrated,s!==null)?((o.mode&1)===0?o.lanes=1:s.data==="$!"?o.lanes=8:o.lanes=1073741824,null):(k=f.children,s=f.fallback,w?(f=o.mode,w=o.child,k={mode:"hidden",children:k},(f&1)===0&&w!==null?(w.childLanes=0,w.pendingProps=k):w=Xl(k,f,0,null),s=sa(s,f,l,null),w.return=o,s.return=o,w.sibling=s,o.child=w,o.child.memoizedState=Zu(l),o.memoizedState=qu,s):ed(o,k));if(g=s.memoizedState,g!==null&&(M=g.dehydrated,M!==null))return kv(s,o,k,f,M,g,l);if(w){w=f.fallback,k=o.mode,g=s.child,M=g.sibling;var F={mode:"hidden",children:f.children};return(k&1)===0&&o.child!==g?(f=o.child,f.childLanes=0,f.pendingProps=F,o.deletions=null):(f=xr(g,F),f.subtreeFlags=g.subtreeFlags&14680064),M!==null?w=xr(M,w):(w=sa(w,k,l,null),w.flags|=2),w.return=o,f.return=o,f.sibling=w,o.child=f,f=w,w=o.child,k=s.child.memoizedState,k=k===null?Zu(l):{baseLanes:k.baseLanes|l,cachePool:null,transitions:k.transitions},w.memoizedState=k,w.childLanes=s.childLanes&~l,o.memoizedState=qu,f}return w=s.child,s=w.sibling,f=xr(w,{mode:"visible",children:f.children}),(o.mode&1)===0&&(f.lanes=l),f.return=o,f.sibling=null,s!==null&&(l=o.deletions,l===null?(o.deletions=[s],o.flags|=16):l.push(s)),o.child=f,o.memoizedState=null,f}function ed(s,o){return o=Xl({mode:"visible",children:o},s.mode,0,null),o.return=s,s.child=o}function Dl(s,o,l,f){return f!==null&&Cu(f),Wa(o,s.child,null,l),s=ed(o,o.pendingProps.children),s.flags|=2,o.memoizedState=null,s}function kv(s,o,l,f,g,w,k){if(l)return o.flags&256?(o.flags&=-257,f=Ju(Error(n(422))),Dl(s,o,k,f)):o.memoizedState!==null?(o.child=s.child,o.flags|=128,null):(w=f.fallback,g=o.mode,f=Xl({mode:"visible",children:f.children},g,0,null),w=sa(w,g,k,null),w.flags|=2,f.return=o,w.return=o,f.sibling=w,o.child=f,(o.mode&1)!==0&&Wa(o,s.child,null,k),o.child.memoizedState=Zu(k),o.memoizedState=qu,w);if((o.mode&1)===0)return Dl(s,o,k,null);if(g.data==="$!"){if(f=g.nextSibling&&g.nextSibling.dataset,f)var M=f.dgst;return f=M,w=Error(n(419)),f=Ju(w,f,void 0),Dl(s,o,k,f)}if(M=(k&s.childLanes)!==0,yn||M){if(f=Ft,f!==null){switch(k&-k){case 4:g=2;break;case 16:g=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:g=32;break;case 536870912:g=268435456;break;default:g=0}g=(g&(f.suspendedLanes|k))!==0?0:g,g!==0&&g!==w.retryLane&&(w.retryLane=g,Bs(s,g),os(f,s,g,-1))}return gd(),f=Ju(Error(n(421))),Dl(s,o,k,f)}return g.data==="$?"?(o.flags|=128,o.child=s.child,o=Ov.bind(null,s),g._reactRetry=o,null):(s=w.treeContext,Rn=dr(g.nextSibling),Tn=o,gt=!0,ns=null,s!==null&&(Un[Bn++]=zs,Un[Bn++]=Us,Un[Bn++]=Jr,zs=s.id,Us=s.overflow,Jr=o),o=ed(o,f.children),o.flags|=4096,o)}function wm(s,o,l){s.lanes|=o;var f=s.alternate;f!==null&&(f.lanes|=o),Tu(s.return,o,l)}function td(s,o,l,f,g){var w=s.memoizedState;w===null?s.memoizedState={isBackwards:o,rendering:null,renderingStartTime:0,last:f,tail:l,tailMode:g}:(w.isBackwards=o,w.rendering=null,w.renderingStartTime=0,w.last=f,w.tail=l,w.tailMode=g)}function vm(s,o,l){var f=o.pendingProps,g=f.revealOrder,w=f.tail;if(rn(s,o,f.children,l),f=yt.current,(f&2)!==0)f=f&1|2,o.flags|=128;else{if(s!==null&&(s.flags&128)!==0)e:for(s=o.child;s!==null;){if(s.tag===13)s.memoizedState!==null&&wm(s,l,o);else if(s.tag===19)wm(s,l,o);else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===o)break e;for(;s.sibling===null;){if(s.return===null||s.return===o)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}f&=1}if(dt(yt,f),(o.mode&1)===0)o.memoizedState=null;else switch(g){case"forwards":for(l=o.child,g=null;l!==null;)s=l.alternate,s!==null&&Tl(s)===null&&(g=l),l=l.sibling;l=g,l===null?(g=o.child,o.child=null):(g=l.sibling,l.sibling=null),td(o,!1,g,l,w);break;case"backwards":for(l=null,g=o.child,o.child=null;g!==null;){if(s=g.alternate,s!==null&&Tl(s)===null){o.child=g;break}s=g.sibling,g.sibling=l,l=g,g=s}td(o,!0,l,null,w);break;case"together":td(o,!1,null,null,void 0);break;default:o.memoizedState=null}return o.child}function Fl(s,o){(o.mode&1)===0&&s!==null&&(s.alternate=null,o.alternate=null,o.flags|=2)}function Vs(s,o,l){if(s!==null&&(o.dependencies=s.dependencies),Zr|=o.lanes,(l&o.childLanes)===0)return null;if(s!==null&&o.child!==s.child)throw Error(n(153));if(o.child!==null){for(s=o.child,l=xr(s,s.pendingProps),o.child=l,l.return=o;s.sibling!==null;)s=s.sibling,l=l.sibling=xr(s,s.pendingProps),l.return=o;l.sibling=null}return o.child}function jv(s,o,l){switch(o.tag){case 3:pm(o),Ba();break;case 5:Ih(o);break;case 1:gn(o.type)&&bl(o);break;case 4:Mu(o,o.stateNode.containerInfo);break;case 10:var f=o.type._context,g=o.memoizedProps.value;dt(Cl,f._currentValue),f._currentValue=g;break;case 13:if(f=o.memoizedState,f!==null)return f.dehydrated!==null?(dt(yt,yt.current&1),o.flags|=128,null):(l&o.child.childLanes)!==0?ym(s,o,l):(dt(yt,yt.current&1),s=Vs(s,o,l),s!==null?s.sibling:null);dt(yt,yt.current&1);break;case 19:if(f=(l&o.childLanes)!==0,(s.flags&128)!==0){if(f)return vm(s,o,l);o.flags|=128}if(g=o.memoizedState,g!==null&&(g.rendering=null,g.tail=null,g.lastEffect=null),dt(yt,yt.current),f)break;return null;case 22:case 23:return o.lanes=0,fm(s,o,l)}return Vs(s,o,l)}var _m,nd,bm,xm;_m=function(s,o){for(var l=o.child;l!==null;){if(l.tag===5||l.tag===6)s.appendChild(l.stateNode);else if(l.tag!==4&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===o)break;for(;l.sibling===null;){if(l.return===null||l.return===o)return;l=l.return}l.sibling.return=l.return,l=l.sibling}},nd=function(){},bm=function(s,o,l,f){var g=s.memoizedProps;if(g!==f){s=o.stateNode,Xr(xs.current);var w=null;switch(l){case"input":g=He(s,g),f=He(s,f),w=[];break;case"select":g=re({},g,{value:void 0}),f=re({},f,{value:void 0}),w=[];break;case"textarea":g=ve(s,g),f=ve(s,f),w=[];break;default:typeof g.onClick!="function"&&typeof f.onClick=="function"&&(s.onclick=wl)}pa(l,f);var k;l=null;for(Q in g)if(!f.hasOwnProperty(Q)&&g.hasOwnProperty(Q)&&g[Q]!=null)if(Q==="style"){var M=g[Q];for(k in M)M.hasOwnProperty(k)&&(l||(l={}),l[k]="")}else Q!=="dangerouslySetInnerHTML"&&Q!=="children"&&Q!=="suppressContentEditableWarning"&&Q!=="suppressHydrationWarning"&&Q!=="autoFocus"&&(i.hasOwnProperty(Q)?w||(w=[]):(w=w||[]).push(Q,null));for(Q in f){var F=f[Q];if(M=g!=null?g[Q]:void 0,f.hasOwnProperty(Q)&&F!==M&&(F!=null||M!=null))if(Q==="style")if(M){for(k in M)!M.hasOwnProperty(k)||F&&F.hasOwnProperty(k)||(l||(l={}),l[k]="");for(k in F)F.hasOwnProperty(k)&&M[k]!==F[k]&&(l||(l={}),l[k]=F[k])}else l||(w||(w=[]),w.push(Q,l)),l=F;else Q==="dangerouslySetInnerHTML"?(F=F?F.__html:void 0,M=M?M.__html:void 0,F!=null&&M!==F&&(w=w||[]).push(Q,F)):Q==="children"?typeof F!="string"&&typeof F!="number"||(w=w||[]).push(Q,""+F):Q!=="suppressContentEditableWarning"&&Q!=="suppressHydrationWarning"&&(i.hasOwnProperty(Q)?(F!=null&&Q==="onScroll"&&ft("scroll",s),w||M===F||(w=[])):(w=w||[]).push(Q,F))}l&&(w=w||[]).push("style",l);var Q=w;(o.updateQueue=Q)&&(o.flags|=4)}},xm=function(s,o,l,f){l!==f&&(o.flags|=4)};function ni(s,o){if(!gt)switch(s.tailMode){case"hidden":o=s.tail;for(var l=null;o!==null;)o.alternate!==null&&(l=o),o=o.sibling;l===null?s.tail=null:l.sibling=null;break;case"collapsed":l=s.tail;for(var f=null;l!==null;)l.alternate!==null&&(f=l),l=l.sibling;f===null?o||s.tail===null?s.tail=null:s.tail.sibling=null:f.sibling=null}}function Zt(s){var o=s.alternate!==null&&s.alternate.child===s.child,l=0,f=0;if(o)for(var g=s.child;g!==null;)l|=g.lanes|g.childLanes,f|=g.subtreeFlags&14680064,f|=g.flags&14680064,g.return=s,g=g.sibling;else for(g=s.child;g!==null;)l|=g.lanes|g.childLanes,f|=g.subtreeFlags,f|=g.flags,g.return=s,g=g.sibling;return s.subtreeFlags|=f,s.childLanes=l,o}function Sv(s,o,l){var f=o.pendingProps;switch(ju(o),o.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Zt(o),null;case 1:return gn(o.type)&&_l(),Zt(o),null;case 3:return f=o.stateNode,Ga(),ht(pn),ht(Xt),Pu(),f.pendingContext&&(f.context=f.pendingContext,f.pendingContext=null),(s===null||s.child===null)&&(Sl(o)?o.flags|=4:s===null||s.memoizedState.isDehydrated&&(o.flags&256)===0||(o.flags|=1024,ns!==null&&(hd(ns),ns=null))),nd(s,o),Zt(o),null;case 5:Lu(o);var g=Xr(Xo.current);if(l=o.type,s!==null&&o.stateNode!=null)bm(s,o,l,f,g),s.ref!==o.ref&&(o.flags|=512,o.flags|=2097152);else{if(!f){if(o.stateNode===null)throw Error(n(166));return Zt(o),null}if(s=Xr(xs.current),Sl(o)){f=o.stateNode,l=o.type;var w=o.memoizedProps;switch(f[bs]=o,f[Go]=w,s=(o.mode&1)!==0,l){case"dialog":ft("cancel",f),ft("close",f);break;case"iframe":case"object":case"embed":ft("load",f);break;case"video":case"audio":for(g=0;g<Wo.length;g++)ft(Wo[g],f);break;case"source":ft("error",f);break;case"img":case"image":case"link":ft("error",f),ft("load",f);break;case"details":ft("toggle",f);break;case"input":ue(f,w),ft("invalid",f);break;case"select":f._wrapperState={wasMultiple:!!w.multiple},ft("invalid",f);break;case"textarea":Ee(f,w),ft("invalid",f)}pa(l,w),g=null;for(var k in w)if(w.hasOwnProperty(k)){var M=w[k];k==="children"?typeof M=="string"?f.textContent!==M&&(w.suppressHydrationWarning!==!0&&yl(f.textContent,M,s),g=["children",M]):typeof M=="number"&&f.textContent!==""+M&&(w.suppressHydrationWarning!==!0&&yl(f.textContent,M,s),g=["children",""+M]):i.hasOwnProperty(k)&&M!=null&&k==="onScroll"&&ft("scroll",f)}switch(l){case"input":Qe(f),Ae(f,w,!0);break;case"textarea":Qe(f),Be(f);break;case"select":case"option":break;default:typeof w.onClick=="function"&&(f.onclick=wl)}f=g,o.updateQueue=f,f!==null&&(o.flags|=4)}else{k=g.nodeType===9?g:g.ownerDocument,s==="http://www.w3.org/1999/xhtml"&&(s=Xe(l)),s==="http://www.w3.org/1999/xhtml"?l==="script"?(s=k.createElement("div"),s.innerHTML="<script><\/script>",s=s.removeChild(s.firstChild)):typeof f.is=="string"?s=k.createElement(l,{is:f.is}):(s=k.createElement(l),l==="select"&&(k=s,f.multiple?k.multiple=!0:f.size&&(k.size=f.size))):s=k.createElementNS(s,l),s[bs]=o,s[Go]=f,_m(s,o,!1,!1),o.stateNode=s;e:{switch(k=On(l,f),l){case"dialog":ft("cancel",s),ft("close",s),g=f;break;case"iframe":case"object":case"embed":ft("load",s),g=f;break;case"video":case"audio":for(g=0;g<Wo.length;g++)ft(Wo[g],s);g=f;break;case"source":ft("error",s),g=f;break;case"img":case"image":case"link":ft("error",s),ft("load",s),g=f;break;case"details":ft("toggle",s),g=f;break;case"input":ue(s,f),g=He(s,f),ft("invalid",s);break;case"option":g=f;break;case"select":s._wrapperState={wasMultiple:!!f.multiple},g=re({},f,{value:void 0}),ft("invalid",s);break;case"textarea":Ee(s,f),g=ve(s,f),ft("invalid",s);break;default:g=f}pa(l,g),M=g;for(w in M)if(M.hasOwnProperty(w)){var F=M[w];w==="style"?ma(s,F):w==="dangerouslySetInnerHTML"?(F=F?F.__html:void 0,F!=null&&Es(s,F)):w==="children"?typeof F=="string"?(l!=="textarea"||F!=="")&&Lr(s,F):typeof F=="number"&&Lr(s,""+F):w!=="suppressContentEditableWarning"&&w!=="suppressHydrationWarning"&&w!=="autoFocus"&&(i.hasOwnProperty(w)?F!=null&&w==="onScroll"&&ft("scroll",s):F!=null&&S(s,w,F,k))}switch(l){case"input":Qe(s),Ae(s,f,!1);break;case"textarea":Qe(s),Be(s);break;case"option":f.value!=null&&s.setAttribute("value",""+ae(f.value));break;case"select":s.multiple=!!f.multiple,w=f.value,w!=null?pe(s,!!f.multiple,w,!1):f.defaultValue!=null&&pe(s,!!f.multiple,f.defaultValue,!0);break;default:typeof g.onClick=="function"&&(s.onclick=wl)}switch(l){case"button":case"input":case"select":case"textarea":f=!!f.autoFocus;break e;case"img":f=!0;break e;default:f=!1}}f&&(o.flags|=4)}o.ref!==null&&(o.flags|=512,o.flags|=2097152)}return Zt(o),null;case 6:if(s&&o.stateNode!=null)xm(s,o,s.memoizedProps,f);else{if(typeof f!="string"&&o.stateNode===null)throw Error(n(166));if(l=Xr(Xo.current),Xr(xs.current),Sl(o)){if(f=o.stateNode,l=o.memoizedProps,f[bs]=o,(w=f.nodeValue!==l)&&(s=Tn,s!==null))switch(s.tag){case 3:yl(f.nodeValue,l,(s.mode&1)!==0);break;case 5:s.memoizedProps.suppressHydrationWarning!==!0&&yl(f.nodeValue,l,(s.mode&1)!==0)}w&&(o.flags|=4)}else f=(l.nodeType===9?l:l.ownerDocument).createTextNode(f),f[bs]=o,o.stateNode=f}return Zt(o),null;case 13:if(ht(yt),f=o.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(gt&&Rn!==null&&(o.mode&1)!==0&&(o.flags&128)===0)Sh(),Ba(),o.flags|=98560,w=!1;else if(w=Sl(o),f!==null&&f.dehydrated!==null){if(s===null){if(!w)throw Error(n(318));if(w=o.memoizedState,w=w!==null?w.dehydrated:null,!w)throw Error(n(317));w[bs]=o}else Ba(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;Zt(o),w=!1}else ns!==null&&(hd(ns),ns=null),w=!0;if(!w)return o.flags&65536?o:null}return(o.flags&128)!==0?(o.lanes=l,o):(f=f!==null,f!==(s!==null&&s.memoizedState!==null)&&f&&(o.child.flags|=8192,(o.mode&1)!==0&&(s===null||(yt.current&1)!==0?Mt===0&&(Mt=3):gd())),o.updateQueue!==null&&(o.flags|=4),Zt(o),null);case 4:return Ga(),nd(s,o),s===null&&Vo(o.stateNode.containerInfo),Zt(o),null;case 10:return Au(o.type._context),Zt(o),null;case 17:return gn(o.type)&&_l(),Zt(o),null;case 19:if(ht(yt),w=o.memoizedState,w===null)return Zt(o),null;if(f=(o.flags&128)!==0,k=w.rendering,k===null)if(f)ni(w,!1);else{if(Mt!==0||s!==null&&(s.flags&128)!==0)for(s=o.child;s!==null;){if(k=Tl(s),k!==null){for(o.flags|=128,ni(w,!1),f=k.updateQueue,f!==null&&(o.updateQueue=f,o.flags|=4),o.subtreeFlags=0,f=l,l=o.child;l!==null;)w=l,s=f,w.flags&=14680066,k=w.alternate,k===null?(w.childLanes=0,w.lanes=s,w.child=null,w.subtreeFlags=0,w.memoizedProps=null,w.memoizedState=null,w.updateQueue=null,w.dependencies=null,w.stateNode=null):(w.childLanes=k.childLanes,w.lanes=k.lanes,w.child=k.child,w.subtreeFlags=0,w.deletions=null,w.memoizedProps=k.memoizedProps,w.memoizedState=k.memoizedState,w.updateQueue=k.updateQueue,w.type=k.type,s=k.dependencies,w.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext}),l=l.sibling;return dt(yt,yt.current&1|2),o.child}s=s.sibling}w.tail!==null&&nt()>Ya&&(o.flags|=128,f=!0,ni(w,!1),o.lanes=4194304)}else{if(!f)if(s=Tl(k),s!==null){if(o.flags|=128,f=!0,l=s.updateQueue,l!==null&&(o.updateQueue=l,o.flags|=4),ni(w,!0),w.tail===null&&w.tailMode==="hidden"&&!k.alternate&&!gt)return Zt(o),null}else 2*nt()-w.renderingStartTime>Ya&&l!==1073741824&&(o.flags|=128,f=!0,ni(w,!1),o.lanes=4194304);w.isBackwards?(k.sibling=o.child,o.child=k):(l=w.last,l!==null?l.sibling=k:o.child=k,w.last=k)}return w.tail!==null?(o=w.tail,w.rendering=o,w.tail=o.sibling,w.renderingStartTime=nt(),o.sibling=null,l=yt.current,dt(yt,f?l&1|2:l&1),o):(Zt(o),null);case 22:case 23:return pd(),f=o.memoizedState!==null,s!==null&&s.memoizedState!==null!==f&&(o.flags|=8192),f&&(o.mode&1)!==0?(In&1073741824)!==0&&(Zt(o),o.subtreeFlags&6&&(o.flags|=8192)):Zt(o),null;case 24:return null;case 25:return null}throw Error(n(156,o.tag))}function Nv(s,o){switch(ju(o),o.tag){case 1:return gn(o.type)&&_l(),s=o.flags,s&65536?(o.flags=s&-65537|128,o):null;case 3:return Ga(),ht(pn),ht(Xt),Pu(),s=o.flags,(s&65536)!==0&&(s&128)===0?(o.flags=s&-65537|128,o):null;case 5:return Lu(o),null;case 13:if(ht(yt),s=o.memoizedState,s!==null&&s.dehydrated!==null){if(o.alternate===null)throw Error(n(340));Ba()}return s=o.flags,s&65536?(o.flags=s&-65537|128,o):null;case 19:return ht(yt),null;case 4:return Ga(),null;case 10:return Au(o.type._context),null;case 22:case 23:return pd(),null;case 24:return null;default:return null}}var zl=!1,en=!1,Cv=typeof WeakSet=="function"?WeakSet:Set,ke=null;function Ja(s,o){var l=s.ref;if(l!==null)if(typeof l=="function")try{l(null)}catch(f){xt(s,o,f)}else l.current=null}function sd(s,o,l){try{l()}catch(f){xt(s,o,f)}}var km=!1;function Ev(s,o){if(pu=ws,s=th(),iu(s)){if("selectionStart"in s)var l={start:s.selectionStart,end:s.selectionEnd};else e:{l=(l=s.ownerDocument)&&l.defaultView||window;var f=l.getSelection&&l.getSelection();if(f&&f.rangeCount!==0){l=f.anchorNode;var g=f.anchorOffset,w=f.focusNode;f=f.focusOffset;try{l.nodeType,w.nodeType}catch{l=null;break e}var k=0,M=-1,F=-1,Q=0,le=0,he=s,oe=null;t:for(;;){for(var xe;he!==l||g!==0&&he.nodeType!==3||(M=k+g),he!==w||f!==0&&he.nodeType!==3||(F=k+f),he.nodeType===3&&(k+=he.nodeValue.length),(xe=he.firstChild)!==null;)oe=he,he=xe;for(;;){if(he===s)break t;if(oe===l&&++Q===g&&(M=k),oe===w&&++le===f&&(F=k),(xe=he.nextSibling)!==null)break;he=oe,oe=he.parentNode}he=xe}l=M===-1||F===-1?null:{start:M,end:F}}else l=null}l=l||{start:0,end:0}}else l=null;for(gu={focusedElem:s,selectionRange:l},ws=!1,ke=o;ke!==null;)if(o=ke,s=o.child,(o.subtreeFlags&1028)!==0&&s!==null)s.return=o,ke=s;else for(;ke!==null;){o=ke;try{var Se=o.alternate;if((o.flags&1024)!==0)switch(o.tag){case 0:case 11:case 15:break;case 1:if(Se!==null){var Ce=Se.memoizedProps,Ct=Se.memoizedState,H=o.stateNode,B=H.getSnapshotBeforeUpdate(o.elementType===o.type?Ce:ss(o.type,Ce),Ct);H.__reactInternalSnapshotBeforeUpdate=B}break;case 3:var K=o.stateNode.containerInfo;K.nodeType===1?K.textContent="":K.nodeType===9&&K.documentElement&&K.removeChild(K.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(ye){xt(o,o.return,ye)}if(s=o.sibling,s!==null){s.return=o.return,ke=s;break}ke=o.return}return Se=km,km=!1,Se}function si(s,o,l){var f=o.updateQueue;if(f=f!==null?f.lastEffect:null,f!==null){var g=f=f.next;do{if((g.tag&s)===s){var w=g.destroy;g.destroy=void 0,w!==void 0&&sd(o,l,w)}g=g.next}while(g!==f)}}function Ul(s,o){if(o=o.updateQueue,o=o!==null?o.lastEffect:null,o!==null){var l=o=o.next;do{if((l.tag&s)===s){var f=l.create;l.destroy=f()}l=l.next}while(l!==o)}}function rd(s){var o=s.ref;if(o!==null){var l=s.stateNode;switch(s.tag){case 5:s=l;break;default:s=l}typeof o=="function"?o(s):o.current=s}}function jm(s){var o=s.alternate;o!==null&&(s.alternate=null,jm(o)),s.child=null,s.deletions=null,s.sibling=null,s.tag===5&&(o=s.stateNode,o!==null&&(delete o[bs],delete o[Go],delete o[_u],delete o[uv],delete o[dv])),s.stateNode=null,s.return=null,s.dependencies=null,s.memoizedProps=null,s.memoizedState=null,s.pendingProps=null,s.stateNode=null,s.updateQueue=null}function Sm(s){return s.tag===5||s.tag===3||s.tag===4}function Nm(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||Sm(s.return))return null;s=s.return}for(s.sibling.return=s.return,s=s.sibling;s.tag!==5&&s.tag!==6&&s.tag!==18;){if(s.flags&2||s.child===null||s.tag===4)continue e;s.child.return=s,s=s.child}if(!(s.flags&2))return s.stateNode}}function ad(s,o,l){var f=s.tag;if(f===5||f===6)s=s.stateNode,o?l.nodeType===8?l.parentNode.insertBefore(s,o):l.insertBefore(s,o):(l.nodeType===8?(o=l.parentNode,o.insertBefore(s,l)):(o=l,o.appendChild(s)),l=l._reactRootContainer,l!=null||o.onclick!==null||(o.onclick=wl));else if(f!==4&&(s=s.child,s!==null))for(ad(s,o,l),s=s.sibling;s!==null;)ad(s,o,l),s=s.sibling}function od(s,o,l){var f=s.tag;if(f===5||f===6)s=s.stateNode,o?l.insertBefore(s,o):l.appendChild(s);else if(f!==4&&(s=s.child,s!==null))for(od(s,o,l),s=s.sibling;s!==null;)od(s,o,l),s=s.sibling}var Vt=null,rs=!1;function yr(s,o,l){for(l=l.child;l!==null;)Cm(s,o,l),l=l.sibling}function Cm(s,o,l){if(fn&&typeof fn.onCommitFiberUnmount=="function")try{fn.onCommitFiberUnmount(xa,l)}catch{}switch(l.tag){case 5:en||Ja(l,o);case 6:var f=Vt,g=rs;Vt=null,yr(s,o,l),Vt=f,rs=g,Vt!==null&&(rs?(s=Vt,l=l.stateNode,s.nodeType===8?s.parentNode.removeChild(l):s.removeChild(l)):Vt.removeChild(l.stateNode));break;case 18:Vt!==null&&(rs?(s=Vt,l=l.stateNode,s.nodeType===8?vu(s.parentNode,l):s.nodeType===1&&vu(s,l),ar(s)):vu(Vt,l.stateNode));break;case 4:f=Vt,g=rs,Vt=l.stateNode.containerInfo,rs=!0,yr(s,o,l),Vt=f,rs=g;break;case 0:case 11:case 14:case 15:if(!en&&(f=l.updateQueue,f!==null&&(f=f.lastEffect,f!==null))){g=f=f.next;do{var w=g,k=w.destroy;w=w.tag,k!==void 0&&((w&2)!==0||(w&4)!==0)&&sd(l,o,k),g=g.next}while(g!==f)}yr(s,o,l);break;case 1:if(!en&&(Ja(l,o),f=l.stateNode,typeof f.componentWillUnmount=="function"))try{f.props=l.memoizedProps,f.state=l.memoizedState,f.componentWillUnmount()}catch(M){xt(l,o,M)}yr(s,o,l);break;case 21:yr(s,o,l);break;case 22:l.mode&1?(en=(f=en)||l.memoizedState!==null,yr(s,o,l),en=f):yr(s,o,l);break;default:yr(s,o,l)}}function Em(s){var o=s.updateQueue;if(o!==null){s.updateQueue=null;var l=s.stateNode;l===null&&(l=s.stateNode=new Cv),o.forEach(function(f){var g=Pv.bind(null,s,f);l.has(f)||(l.add(f),f.then(g,g))})}}function as(s,o){var l=o.deletions;if(l!==null)for(var f=0;f<l.length;f++){var g=l[f];try{var w=s,k=o,M=k;e:for(;M!==null;){switch(M.tag){case 5:Vt=M.stateNode,rs=!1;break e;case 3:Vt=M.stateNode.containerInfo,rs=!0;break e;case 4:Vt=M.stateNode.containerInfo,rs=!0;break e}M=M.return}if(Vt===null)throw Error(n(160));Cm(w,k,g),Vt=null,rs=!1;var F=g.alternate;F!==null&&(F.return=null),g.return=null}catch(Q){xt(g,o,Q)}}if(o.subtreeFlags&12854)for(o=o.child;o!==null;)$m(o,s),o=o.sibling}function $m(s,o){var l=s.alternate,f=s.flags;switch(s.tag){case 0:case 11:case 14:case 15:if(as(o,s),js(s),f&4){try{si(3,s,s.return),Ul(3,s)}catch(Ce){xt(s,s.return,Ce)}try{si(5,s,s.return)}catch(Ce){xt(s,s.return,Ce)}}break;case 1:as(o,s),js(s),f&512&&l!==null&&Ja(l,l.return);break;case 5:if(as(o,s),js(s),f&512&&l!==null&&Ja(l,l.return),s.flags&32){var g=s.stateNode;try{Lr(g,"")}catch(Ce){xt(s,s.return,Ce)}}if(f&4&&(g=s.stateNode,g!=null)){var w=s.memoizedProps,k=l!==null?l.memoizedProps:w,M=s.type,F=s.updateQueue;if(s.updateQueue=null,F!==null)try{M==="input"&&w.type==="radio"&&w.name!=null&&Ue(g,w),On(M,k);var Q=On(M,w);for(k=0;k<F.length;k+=2){var le=F[k],he=F[k+1];le==="style"?ma(g,he):le==="dangerouslySetInnerHTML"?Es(g,he):le==="children"?Lr(g,he):S(g,le,he,Q)}switch(M){case"input":ie(g,w);break;case"textarea":Oe(g,w);break;case"select":var oe=g._wrapperState.wasMultiple;g._wrapperState.wasMultiple=!!w.multiple;var xe=w.value;xe!=null?pe(g,!!w.multiple,xe,!1):oe!==!!w.multiple&&(w.defaultValue!=null?pe(g,!!w.multiple,w.defaultValue,!0):pe(g,!!w.multiple,w.multiple?[]:"",!1))}g[Go]=w}catch(Ce){xt(s,s.return,Ce)}}break;case 6:if(as(o,s),js(s),f&4){if(s.stateNode===null)throw Error(n(162));g=s.stateNode,w=s.memoizedProps;try{g.nodeValue=w}catch(Ce){xt(s,s.return,Ce)}}break;case 3:if(as(o,s),js(s),f&4&&l!==null&&l.memoizedState.isDehydrated)try{ar(o.containerInfo)}catch(Ce){xt(s,s.return,Ce)}break;case 4:as(o,s),js(s);break;case 13:as(o,s),js(s),g=s.child,g.flags&8192&&(w=g.memoizedState!==null,g.stateNode.isHidden=w,!w||g.alternate!==null&&g.alternate.memoizedState!==null||(cd=nt())),f&4&&Em(s);break;case 22:if(le=l!==null&&l.memoizedState!==null,s.mode&1?(en=(Q=en)||le,as(o,s),en=Q):as(o,s),js(s),f&8192){if(Q=s.memoizedState!==null,(s.stateNode.isHidden=Q)&&!le&&(s.mode&1)!==0)for(ke=s,le=s.child;le!==null;){for(he=ke=le;ke!==null;){switch(oe=ke,xe=oe.child,oe.tag){case 0:case 11:case 14:case 15:si(4,oe,oe.return);break;case 1:Ja(oe,oe.return);var Se=oe.stateNode;if(typeof Se.componentWillUnmount=="function"){f=oe,l=oe.return;try{o=f,Se.props=o.memoizedProps,Se.state=o.memoizedState,Se.componentWillUnmount()}catch(Ce){xt(f,l,Ce)}}break;case 5:Ja(oe,oe.return);break;case 22:if(oe.memoizedState!==null){Rm(he);continue}}xe!==null?(xe.return=oe,ke=xe):Rm(he)}le=le.sibling}e:for(le=null,he=s;;){if(he.tag===5){if(le===null){le=he;try{g=he.stateNode,Q?(w=g.style,typeof w.setProperty=="function"?w.setProperty("display","none","important"):w.display="none"):(M=he.stateNode,F=he.memoizedProps.style,k=F!=null&&F.hasOwnProperty("display")?F.display:null,M.style.display=ha("display",k))}catch(Ce){xt(s,s.return,Ce)}}}else if(he.tag===6){if(le===null)try{he.stateNode.nodeValue=Q?"":he.memoizedProps}catch(Ce){xt(s,s.return,Ce)}}else if((he.tag!==22&&he.tag!==23||he.memoizedState===null||he===s)&&he.child!==null){he.child.return=he,he=he.child;continue}if(he===s)break e;for(;he.sibling===null;){if(he.return===null||he.return===s)break e;le===he&&(le=null),he=he.return}le===he&&(le=null),he.sibling.return=he.return,he=he.sibling}}break;case 19:as(o,s),js(s),f&4&&Em(s);break;case 21:break;default:as(o,s),js(s)}}function js(s){var o=s.flags;if(o&2){try{e:{for(var l=s.return;l!==null;){if(Sm(l)){var f=l;break e}l=l.return}throw Error(n(160))}switch(f.tag){case 5:var g=f.stateNode;f.flags&32&&(Lr(g,""),f.flags&=-33);var w=Nm(s);od(s,w,g);break;case 3:case 4:var k=f.stateNode.containerInfo,M=Nm(s);ad(s,M,k);break;default:throw Error(n(161))}}catch(F){xt(s,s.return,F)}s.flags&=-3}o&4096&&(s.flags&=-4097)}function $v(s,o,l){ke=s,Am(s)}function Am(s,o,l){for(var f=(s.mode&1)!==0;ke!==null;){var g=ke,w=g.child;if(g.tag===22&&f){var k=g.memoizedState!==null||zl;if(!k){var M=g.alternate,F=M!==null&&M.memoizedState!==null||en;M=zl;var Q=en;if(zl=k,(en=F)&&!Q)for(ke=g;ke!==null;)k=ke,F=k.child,k.tag===22&&k.memoizedState!==null?Im(g):F!==null?(F.return=k,ke=F):Im(g);for(;w!==null;)ke=w,Am(w),w=w.sibling;ke=g,zl=M,en=Q}Tm(s)}else(g.subtreeFlags&8772)!==0&&w!==null?(w.return=g,ke=w):Tm(s)}}function Tm(s){for(;ke!==null;){var o=ke;if((o.flags&8772)!==0){var l=o.alternate;try{if((o.flags&8772)!==0)switch(o.tag){case 0:case 11:case 15:en||Ul(5,o);break;case 1:var f=o.stateNode;if(o.flags&4&&!en)if(l===null)f.componentDidMount();else{var g=o.elementType===o.type?l.memoizedProps:ss(o.type,l.memoizedProps);f.componentDidUpdate(g,l.memoizedState,f.__reactInternalSnapshotBeforeUpdate)}var w=o.updateQueue;w!==null&&Rh(o,w,f);break;case 3:var k=o.updateQueue;if(k!==null){if(l=null,o.child!==null)switch(o.child.tag){case 5:l=o.child.stateNode;break;case 1:l=o.child.stateNode}Rh(o,k,l)}break;case 5:var M=o.stateNode;if(l===null&&o.flags&4){l=M;var F=o.memoizedProps;switch(o.type){case"button":case"input":case"select":case"textarea":F.autoFocus&&l.focus();break;case"img":F.src&&(l.src=F.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(o.memoizedState===null){var Q=o.alternate;if(Q!==null){var le=Q.memoizedState;if(le!==null){var he=le.dehydrated;he!==null&&ar(he)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}en||o.flags&512&&rd(o)}catch(oe){xt(o,o.return,oe)}}if(o===s){ke=null;break}if(l=o.sibling,l!==null){l.return=o.return,ke=l;break}ke=o.return}}function Rm(s){for(;ke!==null;){var o=ke;if(o===s){ke=null;break}var l=o.sibling;if(l!==null){l.return=o.return,ke=l;break}ke=o.return}}function Im(s){for(;ke!==null;){var o=ke;try{switch(o.tag){case 0:case 11:case 15:var l=o.return;try{Ul(4,o)}catch(F){xt(o,l,F)}break;case 1:var f=o.stateNode;if(typeof f.componentDidMount=="function"){var g=o.return;try{f.componentDidMount()}catch(F){xt(o,g,F)}}var w=o.return;try{rd(o)}catch(F){xt(o,w,F)}break;case 5:var k=o.return;try{rd(o)}catch(F){xt(o,k,F)}}}catch(F){xt(o,o.return,F)}if(o===s){ke=null;break}var M=o.sibling;if(M!==null){M.return=o.return,ke=M;break}ke=o.return}}var Av=Math.ceil,Bl=E.ReactCurrentDispatcher,id=E.ReactCurrentOwner,Hn=E.ReactCurrentBatchConfig,qe=0,Ft=null,At=null,Ht=0,In=0,Qa=fr(0),Mt=0,ri=null,Zr=0,Wl=0,ld=0,ai=null,wn=null,cd=0,Ya=1/0,Hs=null,Vl=!1,ud=null,wr=null,Hl=!1,vr=null,Gl=0,oi=0,dd=null,Kl=-1,Jl=0;function an(){return(qe&6)!==0?nt():Kl!==-1?Kl:Kl=nt()}function _r(s){return(s.mode&1)===0?1:(qe&2)!==0&&Ht!==0?Ht&-Ht:hv.transition!==null?(Jl===0&&(Jl=Qn()),Jl):(s=Ke,s!==0||(s=window.event,s=s===void 0?16:To(s.type)),s)}function os(s,o,l,f){if(50<oi)throw oi=0,dd=null,Error(n(185));nr(s,l,f),((qe&2)===0||s!==Ft)&&(s===Ft&&((qe&2)===0&&(Wl|=l),Mt===4&&br(s,Ht)),vn(s,f),l===1&&qe===0&&(o.mode&1)===0&&(Ya=nt()+500,xl&&mr()))}function vn(s,o){var l=s.callbackNode;ka(s,o);var f=er(s,s===Ft?Ht:0);if(f===0)l!==null&&qs(l),s.callbackNode=null,s.callbackPriority=0;else if(o=f&-f,s.callbackPriority!==o){if(l!=null&&qs(l),o===1)s.tag===0?fv(Lm.bind(null,s)):_h(Lm.bind(null,s)),lv(function(){(qe&6)===0&&mr()}),l=null;else{switch(ja(f)){case 1:l=Cn;break;case 4:l=So;break;case 16:l=Zs;break;case 536870912:l=ba;break;default:l=Zs}l=Wm(l,Mm.bind(null,s))}s.callbackPriority=o,s.callbackNode=l}}function Mm(s,o){if(Kl=-1,Jl=0,(qe&6)!==0)throw Error(n(327));var l=s.callbackNode;if(Xa()&&s.callbackNode!==l)return null;var f=er(s,s===Ft?Ht:0);if(f===0)return null;if((f&30)!==0||(f&s.expiredLanes)!==0||o)o=Ql(s,f);else{o=f;var g=qe;qe|=2;var w=Pm();(Ft!==s||Ht!==o)&&(Hs=null,Ya=nt()+500,ta(s,o));do try{Iv();break}catch(M){Om(s,M)}while(!0);$u(),Bl.current=w,qe=g,At!==null?o=0:(Ft=null,Ht=0,o=Mt)}if(o!==0){if(o===2&&(g=tr(s),g!==0&&(f=g,o=fd(s,g))),o===1)throw l=ri,ta(s,0),br(s,f),vn(s,nt()),l;if(o===6)br(s,f);else{if(g=s.current.alternate,(f&30)===0&&!Tv(g)&&(o=Ql(s,f),o===2&&(w=tr(s),w!==0&&(f=w,o=fd(s,w))),o===1))throw l=ri,ta(s,0),br(s,f),vn(s,nt()),l;switch(s.finishedWork=g,s.finishedLanes=f,o){case 0:case 1:throw Error(n(345));case 2:na(s,wn,Hs);break;case 3:if(br(s,f),(f&130023424)===f&&(o=cd+500-nt(),10<o)){if(er(s,0)!==0)break;if(g=s.suspendedLanes,(g&f)!==f){an(),s.pingedLanes|=s.suspendedLanes&g;break}s.timeoutHandle=wu(na.bind(null,s,wn,Hs),o);break}na(s,wn,Hs);break;case 4:if(br(s,f),(f&4194240)===f)break;for(o=s.eventTimes,g=-1;0<f;){var k=31-hn(f);w=1<<k,k=o[k],k>g&&(g=k),f&=~w}if(f=g,f=nt()-f,f=(120>f?120:480>f?480:1080>f?1080:1920>f?1920:3e3>f?3e3:4320>f?4320:1960*Av(f/1960))-f,10<f){s.timeoutHandle=wu(na.bind(null,s,wn,Hs),f);break}na(s,wn,Hs);break;case 5:na(s,wn,Hs);break;default:throw Error(n(329))}}}return vn(s,nt()),s.callbackNode===l?Mm.bind(null,s):null}function fd(s,o){var l=ai;return s.current.memoizedState.isDehydrated&&(ta(s,o).flags|=256),s=Ql(s,o),s!==2&&(o=wn,wn=l,o!==null&&hd(o)),s}function hd(s){wn===null?wn=s:wn.push.apply(wn,s)}function Tv(s){for(var o=s;;){if(o.flags&16384){var l=o.updateQueue;if(l!==null&&(l=l.stores,l!==null))for(var f=0;f<l.length;f++){var g=l[f],w=g.getSnapshot;g=g.value;try{if(!ts(w(),g))return!1}catch{return!1}}}if(l=o.child,o.subtreeFlags&16384&&l!==null)l.return=o,o=l;else{if(o===s)break;for(;o.sibling===null;){if(o.return===null||o.return===s)return!0;o=o.return}o.sibling.return=o.return,o=o.sibling}}return!0}function br(s,o){for(o&=~ld,o&=~Wl,s.suspendedLanes|=o,s.pingedLanes&=~o,s=s.expirationTimes;0<o;){var l=31-hn(o),f=1<<l;s[l]=-1,o&=~f}}function Lm(s){if((qe&6)!==0)throw Error(n(327));Xa();var o=er(s,0);if((o&1)===0)return vn(s,nt()),null;var l=Ql(s,o);if(s.tag!==0&&l===2){var f=tr(s);f!==0&&(o=f,l=fd(s,f))}if(l===1)throw l=ri,ta(s,0),br(s,o),vn(s,nt()),l;if(l===6)throw Error(n(345));return s.finishedWork=s.current.alternate,s.finishedLanes=o,na(s,wn,Hs),vn(s,nt()),null}function md(s,o){var l=qe;qe|=1;try{return s(o)}finally{qe=l,qe===0&&(Ya=nt()+500,xl&&mr())}}function ea(s){vr!==null&&vr.tag===0&&(qe&6)===0&&Xa();var o=qe;qe|=1;var l=Hn.transition,f=Ke;try{if(Hn.transition=null,Ke=1,s)return s()}finally{Ke=f,Hn.transition=l,qe=o,(qe&6)===0&&mr()}}function pd(){In=Qa.current,ht(Qa)}function ta(s,o){s.finishedWork=null,s.finishedLanes=0;var l=s.timeoutHandle;if(l!==-1&&(s.timeoutHandle=-1,iv(l)),At!==null)for(l=At.return;l!==null;){var f=l;switch(ju(f),f.tag){case 1:f=f.type.childContextTypes,f!=null&&_l();break;case 3:Ga(),ht(pn),ht(Xt),Pu();break;case 5:Lu(f);break;case 4:Ga();break;case 13:ht(yt);break;case 19:ht(yt);break;case 10:Au(f.type._context);break;case 22:case 23:pd()}l=l.return}if(Ft=s,At=s=xr(s.current,null),Ht=In=o,Mt=0,ri=null,ld=Wl=Zr=0,wn=ai=null,Yr!==null){for(o=0;o<Yr.length;o++)if(l=Yr[o],f=l.interleaved,f!==null){l.interleaved=null;var g=f.next,w=l.pending;if(w!==null){var k=w.next;w.next=g,f.next=k}l.pending=f}Yr=null}return s}function Om(s,o){do{var l=At;try{if($u(),Rl.current=Ol,Il){for(var f=wt.memoizedState;f!==null;){var g=f.queue;g!==null&&(g.pending=null),f=f.next}Il=!1}if(qr=0,Dt=It=wt=null,qo=!1,Zo=0,id.current=null,l===null||l.return===null){Mt=1,ri=o,At=null;break}e:{var w=s,k=l.return,M=l,F=o;if(o=Ht,M.flags|=32768,F!==null&&typeof F=="object"&&typeof F.then=="function"){var Q=F,le=M,he=le.tag;if((le.mode&1)===0&&(he===0||he===11||he===15)){var oe=le.alternate;oe?(le.updateQueue=oe.updateQueue,le.memoizedState=oe.memoizedState,le.lanes=oe.lanes):(le.updateQueue=null,le.memoizedState=null)}var xe=im(k);if(xe!==null){xe.flags&=-257,lm(xe,k,M,w,o),xe.mode&1&&om(w,Q,o),o=xe,F=Q;var Se=o.updateQueue;if(Se===null){var Ce=new Set;Ce.add(F),o.updateQueue=Ce}else Se.add(F);break e}else{if((o&1)===0){om(w,Q,o),gd();break e}F=Error(n(426))}}else if(gt&&M.mode&1){var Ct=im(k);if(Ct!==null){(Ct.flags&65536)===0&&(Ct.flags|=256),lm(Ct,k,M,w,o),Cu(Ka(F,M));break e}}w=F=Ka(F,M),Mt!==4&&(Mt=2),ai===null?ai=[w]:ai.push(w),w=k;do{switch(w.tag){case 3:w.flags|=65536,o&=-o,w.lanes|=o;var H=rm(w,F,o);Th(w,H);break e;case 1:M=F;var B=w.type,K=w.stateNode;if((w.flags&128)===0&&(typeof B.getDerivedStateFromError=="function"||K!==null&&typeof K.componentDidCatch=="function"&&(wr===null||!wr.has(K)))){w.flags|=65536,o&=-o,w.lanes|=o;var ye=am(w,M,o);Th(w,ye);break e}}w=w.return}while(w!==null)}Fm(l)}catch($e){o=$e,At===l&&l!==null&&(At=l=l.return);continue}break}while(!0)}function Pm(){var s=Bl.current;return Bl.current=Ol,s===null?Ol:s}function gd(){(Mt===0||Mt===3||Mt===2)&&(Mt=4),Ft===null||(Zr&268435455)===0&&(Wl&268435455)===0||br(Ft,Ht)}function Ql(s,o){var l=qe;qe|=2;var f=Pm();(Ft!==s||Ht!==o)&&(Hs=null,ta(s,o));do try{Rv();break}catch(g){Om(s,g)}while(!0);if($u(),qe=l,Bl.current=f,At!==null)throw Error(n(261));return Ft=null,Ht=0,Mt}function Rv(){for(;At!==null;)Dm(At)}function Iv(){for(;At!==null&&!Xc();)Dm(At)}function Dm(s){var o=Bm(s.alternate,s,In);s.memoizedProps=s.pendingProps,o===null?Fm(s):At=o,id.current=null}function Fm(s){var o=s;do{var l=o.alternate;if(s=o.return,(o.flags&32768)===0){if(l=Sv(l,o,In),l!==null){At=l;return}}else{if(l=Nv(l,o),l!==null){l.flags&=32767,At=l;return}if(s!==null)s.flags|=32768,s.subtreeFlags=0,s.deletions=null;else{Mt=6,At=null;return}}if(o=o.sibling,o!==null){At=o;return}At=o=s}while(o!==null);Mt===0&&(Mt=5)}function na(s,o,l){var f=Ke,g=Hn.transition;try{Hn.transition=null,Ke=1,Mv(s,o,l,f)}finally{Hn.transition=g,Ke=f}return null}function Mv(s,o,l,f){do Xa();while(vr!==null);if((qe&6)!==0)throw Error(n(327));l=s.finishedWork;var g=s.finishedLanes;if(l===null)return null;if(s.finishedWork=null,s.finishedLanes=0,l===s.current)throw Error(n(177));s.callbackNode=null,s.callbackPriority=0;var w=l.lanes|l.childLanes;if(Yn(s,w),s===Ft&&(At=Ft=null,Ht=0),(l.subtreeFlags&2064)===0&&(l.flags&2064)===0||Hl||(Hl=!0,Wm(Zs,function(){return Xa(),null})),w=(l.flags&15990)!==0,(l.subtreeFlags&15990)!==0||w){w=Hn.transition,Hn.transition=null;var k=Ke;Ke=1;var M=qe;qe|=4,id.current=null,Ev(s,l),$m(l,s),ev(gu),ws=!!pu,gu=pu=null,s.current=l,$v(l),Is(),qe=M,Ke=k,Hn.transition=w}else s.current=l;if(Hl&&(Hl=!1,vr=s,Gl=g),w=s.pendingLanes,w===0&&(wr=null),Gi(l.stateNode),vn(s,nt()),o!==null)for(f=s.onRecoverableError,l=0;l<o.length;l++)g=o[l],f(g.value,{componentStack:g.stack,digest:g.digest});if(Vl)throw Vl=!1,s=ud,ud=null,s;return(Gl&1)!==0&&s.tag!==0&&Xa(),w=s.pendingLanes,(w&1)!==0?s===dd?oi++:(oi=0,dd=s):oi=0,mr(),null}function Xa(){if(vr!==null){var s=ja(Gl),o=Hn.transition,l=Ke;try{if(Hn.transition=null,Ke=16>s?16:s,vr===null)var f=!1;else{if(s=vr,vr=null,Gl=0,(qe&6)!==0)throw Error(n(331));var g=qe;for(qe|=4,ke=s.current;ke!==null;){var w=ke,k=w.child;if((ke.flags&16)!==0){var M=w.deletions;if(M!==null){for(var F=0;F<M.length;F++){var Q=M[F];for(ke=Q;ke!==null;){var le=ke;switch(le.tag){case 0:case 11:case 15:si(8,le,w)}var he=le.child;if(he!==null)he.return=le,ke=he;else for(;ke!==null;){le=ke;var oe=le.sibling,xe=le.return;if(jm(le),le===Q){ke=null;break}if(oe!==null){oe.return=xe,ke=oe;break}ke=xe}}}var Se=w.alternate;if(Se!==null){var Ce=Se.child;if(Ce!==null){Se.child=null;do{var Ct=Ce.sibling;Ce.sibling=null,Ce=Ct}while(Ce!==null)}}ke=w}}if((w.subtreeFlags&2064)!==0&&k!==null)k.return=w,ke=k;else e:for(;ke!==null;){if(w=ke,(w.flags&2048)!==0)switch(w.tag){case 0:case 11:case 15:si(9,w,w.return)}var H=w.sibling;if(H!==null){H.return=w.return,ke=H;break e}ke=w.return}}var B=s.current;for(ke=B;ke!==null;){k=ke;var K=k.child;if((k.subtreeFlags&2064)!==0&&K!==null)K.return=k,ke=K;else e:for(k=B;ke!==null;){if(M=ke,(M.flags&2048)!==0)try{switch(M.tag){case 0:case 11:case 15:Ul(9,M)}}catch($e){xt(M,M.return,$e)}if(M===k){ke=null;break e}var ye=M.sibling;if(ye!==null){ye.return=M.return,ke=ye;break e}ke=M.return}}if(qe=g,mr(),fn&&typeof fn.onPostCommitFiberRoot=="function")try{fn.onPostCommitFiberRoot(xa,s)}catch{}f=!0}return f}finally{Ke=l,Hn.transition=o}}return!1}function zm(s,o,l){o=Ka(l,o),o=rm(s,o,1),s=gr(s,o,1),o=an(),s!==null&&(nr(s,1,o),vn(s,o))}function xt(s,o,l){if(s.tag===3)zm(s,s,l);else for(;o!==null;){if(o.tag===3){zm(o,s,l);break}else if(o.tag===1){var f=o.stateNode;if(typeof o.type.getDerivedStateFromError=="function"||typeof f.componentDidCatch=="function"&&(wr===null||!wr.has(f))){s=Ka(l,s),s=am(o,s,1),o=gr(o,s,1),s=an(),o!==null&&(nr(o,1,s),vn(o,s));break}}o=o.return}}function Lv(s,o,l){var f=s.pingCache;f!==null&&f.delete(o),o=an(),s.pingedLanes|=s.suspendedLanes&l,Ft===s&&(Ht&l)===l&&(Mt===4||Mt===3&&(Ht&130023424)===Ht&&500>nt()-cd?ta(s,0):ld|=l),vn(s,o)}function Um(s,o){o===0&&((s.mode&1)===0?o=1:(o=We,We<<=1,(We&130023424)===0&&(We=4194304)));var l=an();s=Bs(s,o),s!==null&&(nr(s,o,l),vn(s,l))}function Ov(s){var o=s.memoizedState,l=0;o!==null&&(l=o.retryLane),Um(s,l)}function Pv(s,o){var l=0;switch(s.tag){case 13:var f=s.stateNode,g=s.memoizedState;g!==null&&(l=g.retryLane);break;case 19:f=s.stateNode;break;default:throw Error(n(314))}f!==null&&f.delete(o),Um(s,l)}var Bm;Bm=function(s,o,l){if(s!==null)if(s.memoizedProps!==o.pendingProps||pn.current)yn=!0;else{if((s.lanes&l)===0&&(o.flags&128)===0)return yn=!1,jv(s,o,l);yn=(s.flags&131072)!==0}else yn=!1,gt&&(o.flags&1048576)!==0&&bh(o,jl,o.index);switch(o.lanes=0,o.tag){case 2:var f=o.type;Fl(s,o),s=o.pendingProps;var g=Fa(o,Xt.current);Ha(o,l),g=zu(null,o,f,s,g,l);var w=Uu();return o.flags|=1,typeof g=="object"&&g!==null&&typeof g.render=="function"&&g.$$typeof===void 0?(o.tag=1,o.memoizedState=null,o.updateQueue=null,gn(f)?(w=!0,bl(o)):w=!1,o.memoizedState=g.state!==null&&g.state!==void 0?g.state:null,Iu(o),g.updater=Pl,o.stateNode=g,g._reactInternals=o,Ku(o,f,s,l),o=Xu(null,o,f,!0,w,l)):(o.tag=0,gt&&w&&ku(o),rn(null,o,g,l),o=o.child),o;case 16:f=o.elementType;e:{switch(Fl(s,o),s=o.pendingProps,g=f._init,f=g(f._payload),o.type=f,g=o.tag=Fv(f),s=ss(f,s),g){case 0:o=Yu(null,o,f,s,l);break e;case 1:o=mm(null,o,f,s,l);break e;case 11:o=cm(null,o,f,s,l);break e;case 14:o=um(null,o,f,ss(f.type,s),l);break e}throw Error(n(306,f,""))}return o;case 0:return f=o.type,g=o.pendingProps,g=o.elementType===f?g:ss(f,g),Yu(s,o,f,g,l);case 1:return f=o.type,g=o.pendingProps,g=o.elementType===f?g:ss(f,g),mm(s,o,f,g,l);case 3:e:{if(pm(o),s===null)throw Error(n(387));f=o.pendingProps,w=o.memoizedState,g=w.element,Ah(s,o),Al(o,f,null,l);var k=o.memoizedState;if(f=k.element,w.isDehydrated)if(w={element:f,isDehydrated:!1,cache:k.cache,pendingSuspenseBoundaries:k.pendingSuspenseBoundaries,transitions:k.transitions},o.updateQueue.baseState=w,o.memoizedState=w,o.flags&256){g=Ka(Error(n(423)),o),o=gm(s,o,f,l,g);break e}else if(f!==g){g=Ka(Error(n(424)),o),o=gm(s,o,f,l,g);break e}else for(Rn=dr(o.stateNode.containerInfo.firstChild),Tn=o,gt=!0,ns=null,l=Eh(o,null,f,l),o.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(Ba(),f===g){o=Vs(s,o,l);break e}rn(s,o,f,l)}o=o.child}return o;case 5:return Ih(o),s===null&&Nu(o),f=o.type,g=o.pendingProps,w=s!==null?s.memoizedProps:null,k=g.children,yu(f,g)?k=null:w!==null&&yu(f,w)&&(o.flags|=32),hm(s,o),rn(s,o,k,l),o.child;case 6:return s===null&&Nu(o),null;case 13:return ym(s,o,l);case 4:return Mu(o,o.stateNode.containerInfo),f=o.pendingProps,s===null?o.child=Wa(o,null,f,l):rn(s,o,f,l),o.child;case 11:return f=o.type,g=o.pendingProps,g=o.elementType===f?g:ss(f,g),cm(s,o,f,g,l);case 7:return rn(s,o,o.pendingProps,l),o.child;case 8:return rn(s,o,o.pendingProps.children,l),o.child;case 12:return rn(s,o,o.pendingProps.children,l),o.child;case 10:e:{if(f=o.type._context,g=o.pendingProps,w=o.memoizedProps,k=g.value,dt(Cl,f._currentValue),f._currentValue=k,w!==null)if(ts(w.value,k)){if(w.children===g.children&&!pn.current){o=Vs(s,o,l);break e}}else for(w=o.child,w!==null&&(w.return=o);w!==null;){var M=w.dependencies;if(M!==null){k=w.child;for(var F=M.firstContext;F!==null;){if(F.context===f){if(w.tag===1){F=Ws(-1,l&-l),F.tag=2;var Q=w.updateQueue;if(Q!==null){Q=Q.shared;var le=Q.pending;le===null?F.next=F:(F.next=le.next,le.next=F),Q.pending=F}}w.lanes|=l,F=w.alternate,F!==null&&(F.lanes|=l),Tu(w.return,l,o),M.lanes|=l;break}F=F.next}}else if(w.tag===10)k=w.type===o.type?null:w.child;else if(w.tag===18){if(k=w.return,k===null)throw Error(n(341));k.lanes|=l,M=k.alternate,M!==null&&(M.lanes|=l),Tu(k,l,o),k=w.sibling}else k=w.child;if(k!==null)k.return=w;else for(k=w;k!==null;){if(k===o){k=null;break}if(w=k.sibling,w!==null){w.return=k.return,k=w;break}k=k.return}w=k}rn(s,o,g.children,l),o=o.child}return o;case 9:return g=o.type,f=o.pendingProps.children,Ha(o,l),g=Wn(g),f=f(g),o.flags|=1,rn(s,o,f,l),o.child;case 14:return f=o.type,g=ss(f,o.pendingProps),g=ss(f.type,g),um(s,o,f,g,l);case 15:return dm(s,o,o.type,o.pendingProps,l);case 17:return f=o.type,g=o.pendingProps,g=o.elementType===f?g:ss(f,g),Fl(s,o),o.tag=1,gn(f)?(s=!0,bl(o)):s=!1,Ha(o,l),nm(o,f,g),Ku(o,f,g,l),Xu(null,o,f,!0,s,l);case 19:return vm(s,o,l);case 22:return fm(s,o,l)}throw Error(n(156,o.tag))};function Wm(s,o){return ko(s,o)}function Dv(s,o,l,f){this.tag=s,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=o,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=f,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Gn(s,o,l,f){return new Dv(s,o,l,f)}function yd(s){return s=s.prototype,!(!s||!s.isReactComponent)}function Fv(s){if(typeof s=="function")return yd(s)?1:0;if(s!=null){if(s=s.$$typeof,s===ee)return 11;if(s===U)return 14}return 2}function xr(s,o){var l=s.alternate;return l===null?(l=Gn(s.tag,o,s.key,s.mode),l.elementType=s.elementType,l.type=s.type,l.stateNode=s.stateNode,l.alternate=s,s.alternate=l):(l.pendingProps=o,l.type=s.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=s.flags&14680064,l.childLanes=s.childLanes,l.lanes=s.lanes,l.child=s.child,l.memoizedProps=s.memoizedProps,l.memoizedState=s.memoizedState,l.updateQueue=s.updateQueue,o=s.dependencies,l.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext},l.sibling=s.sibling,l.index=s.index,l.ref=s.ref,l}function Yl(s,o,l,f,g,w){var k=2;if(f=s,typeof s=="function")yd(s)&&(k=1);else if(typeof s=="string")k=5;else e:switch(s){case z:return sa(l.children,g,w,o);case L:k=8,g|=8;break;case J:return s=Gn(12,l,o,g|2),s.elementType=J,s.lanes=w,s;case P:return s=Gn(13,l,o,g),s.elementType=P,s.lanes=w,s;case Z:return s=Gn(19,l,o,g),s.elementType=Z,s.lanes=w,s;case se:return Xl(l,g,w,o);default:if(typeof s=="object"&&s!==null)switch(s.$$typeof){case V:k=10;break e;case O:k=9;break e;case ee:k=11;break e;case U:k=14;break e;case te:k=16,f=null;break e}throw Error(n(130,s==null?s:typeof s,""))}return o=Gn(k,l,o,g),o.elementType=s,o.type=f,o.lanes=w,o}function sa(s,o,l,f){return s=Gn(7,s,f,o),s.lanes=l,s}function Xl(s,o,l,f){return s=Gn(22,s,f,o),s.elementType=se,s.lanes=l,s.stateNode={isHidden:!1},s}function wd(s,o,l){return s=Gn(6,s,null,o),s.lanes=l,s}function vd(s,o,l){return o=Gn(4,s.children!==null?s.children:[],s.key,o),o.lanes=l,o.stateNode={containerInfo:s.containerInfo,pendingChildren:null,implementation:s.implementation},o}function zv(s,o,l,f,g){this.tag=o,this.containerInfo=s,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=zr(0),this.expirationTimes=zr(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=zr(0),this.identifierPrefix=f,this.onRecoverableError=g,this.mutableSourceEagerHydrationData=null}function _d(s,o,l,f,g,w,k,M,F){return s=new zv(s,o,l,M,F),o===1?(o=1,w===!0&&(o|=8)):o=0,w=Gn(3,null,null,o),s.current=w,w.stateNode=s,w.memoizedState={element:f,isDehydrated:l,cache:null,transitions:null,pendingSuspenseBoundaries:null},Iu(w),s}function Uv(s,o,l){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:R,key:f==null?null:""+f,children:s,containerInfo:o,implementation:l}}function Vm(s){if(!s)return hr;s=s._reactInternals;e:{if(dn(s)!==s||s.tag!==1)throw Error(n(170));var o=s;do{switch(o.tag){case 3:o=o.stateNode.context;break e;case 1:if(gn(o.type)){o=o.stateNode.__reactInternalMemoizedMergedChildContext;break e}}o=o.return}while(o!==null);throw Error(n(171))}if(s.tag===1){var l=s.type;if(gn(l))return wh(s,l,o)}return o}function Hm(s,o,l,f,g,w,k,M,F){return s=_d(l,f,!0,s,g,w,k,M,F),s.context=Vm(null),l=s.current,f=an(),g=_r(l),w=Ws(f,g),w.callback=o??null,gr(l,w,g),s.current.lanes=g,nr(s,g,f),vn(s,f),s}function ql(s,o,l,f){var g=o.current,w=an(),k=_r(g);return l=Vm(l),o.context===null?o.context=l:o.pendingContext=l,o=Ws(w,k),o.payload={element:s},f=f===void 0?null:f,f!==null&&(o.callback=f),s=gr(g,o,k),s!==null&&(os(s,g,k,w),$l(s,g,k)),k}function Zl(s){if(s=s.current,!s.child)return null;switch(s.child.tag){case 5:return s.child.stateNode;default:return s.child.stateNode}}function Gm(s,o){if(s=s.memoizedState,s!==null&&s.dehydrated!==null){var l=s.retryLane;s.retryLane=l!==0&&l<o?l:o}}function bd(s,o){Gm(s,o),(s=s.alternate)&&Gm(s,o)}function Bv(){return null}var Km=typeof reportError=="function"?reportError:function(s){console.error(s)};function xd(s){this._internalRoot=s}ec.prototype.render=xd.prototype.render=function(s){var o=this._internalRoot;if(o===null)throw Error(n(409));ql(s,o,null,null)},ec.prototype.unmount=xd.prototype.unmount=function(){var s=this._internalRoot;if(s!==null){this._internalRoot=null;var o=s.containerInfo;ea(function(){ql(null,s,null,null)}),o[Ds]=null}};function ec(s){this._internalRoot=s}ec.prototype.unstable_scheduleHydration=function(s){if(s){var o=Dn();s={blockedOn:null,target:s,priority:o};for(var l=0;l<Fn.length&&o!==0&&o<Fn[l].priority;l++);Fn.splice(l,0,s),l===0&&Sa(s)}};function kd(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11)}function tc(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11&&(s.nodeType!==8||s.nodeValue!==" react-mount-point-unstable "))}function Jm(){}function Wv(s,o,l,f,g){if(g){if(typeof f=="function"){var w=f;f=function(){var Q=Zl(k);w.call(Q)}}var k=Hm(o,f,s,0,null,!1,!1,"",Jm);return s._reactRootContainer=k,s[Ds]=k.current,Vo(s.nodeType===8?s.parentNode:s),ea(),k}for(;g=s.lastChild;)s.removeChild(g);if(typeof f=="function"){var M=f;f=function(){var Q=Zl(F);M.call(Q)}}var F=_d(s,0,!1,null,null,!1,!1,"",Jm);return s._reactRootContainer=F,s[Ds]=F.current,Vo(s.nodeType===8?s.parentNode:s),ea(function(){ql(o,F,l,f)}),F}function nc(s,o,l,f,g){var w=l._reactRootContainer;if(w){var k=w;if(typeof g=="function"){var M=g;g=function(){var F=Zl(k);M.call(F)}}ql(o,k,s,g)}else k=Wv(l,o,s,g,f);return Zl(k)}No=function(s){switch(s.tag){case 3:var o=s.stateNode;if(o.current.memoizedState.isDehydrated){var l=Bt(o.pendingLanes);l!==0&&(Xn(o,l|1),vn(o,nt()),(qe&6)===0&&(Ya=nt()+500,mr()))}break;case 13:ea(function(){var f=Bs(s,1);if(f!==null){var g=an();os(f,s,1,g)}}),bd(s,1)}},mn=function(s){if(s.tag===13){var o=Bs(s,134217728);if(o!==null){var l=an();os(o,s,134217728,l)}bd(s,134217728)}},Co=function(s){if(s.tag===13){var o=_r(s),l=Bs(s,o);if(l!==null){var f=an();os(l,s,o,f)}bd(s,o)}},Dn=function(){return Ke},Eo=function(s,o){var l=Ke;try{return Ke=s,o()}finally{Ke=l}},us=function(s,o,l){switch(o){case"input":if(ie(s,l),o=l.name,l.type==="radio"&&o!=null){for(l=s;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll("input[name="+JSON.stringify(""+o)+'][type="radio"]'),o=0;o<l.length;o++){var f=l[o];if(f!==s&&f.form===s.form){var g=vl(f);if(!g)throw Error(n(90));Ye(f),ie(f,g)}}}break;case"textarea":Oe(s,l);break;case"select":o=l.value,o!=null&&pe(s,!!l.multiple,o,!1)}},ya=md,Vi=ea;var Vv={usingClientEntryPoint:!1,Events:[Ko,Pa,vl,wo,Ts,md]},ii={findFiberByHostInstance:Gr,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Hv={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:E.ReactCurrentDispatcher,findHostInstanceByFiber:function(s){return s=_a(s),s===null?null:s.stateNode},findFiberByHostInstance:ii.findFiberByHostInstance||Bv,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 sc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!sc.isDisabled&&sc.supportsFiber)try{xa=sc.inject(Hv),fn=sc}catch{}}return _n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Vv,_n.createPortal=function(s,o){var l=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!kd(o))throw Error(n(200));return Uv(s,o,null,l)},_n.createRoot=function(s,o){if(!kd(s))throw Error(n(299));var l=!1,f="",g=Km;return o!=null&&(o.unstable_strictMode===!0&&(l=!0),o.identifierPrefix!==void 0&&(f=o.identifierPrefix),o.onRecoverableError!==void 0&&(g=o.onRecoverableError)),o=_d(s,1,!1,null,null,l,!1,f,g),s[Ds]=o.current,Vo(s.nodeType===8?s.parentNode:s),new xd(o)},_n.findDOMNode=function(s){if(s==null)return null;if(s.nodeType===1)return s;var o=s._reactInternals;if(o===void 0)throw typeof s.render=="function"?Error(n(188)):(s=Object.keys(s).join(","),Error(n(268,s)));return s=_a(o),s=s===null?null:s.stateNode,s},_n.flushSync=function(s){return ea(s)},_n.hydrate=function(s,o,l){if(!tc(o))throw Error(n(200));return nc(null,s,o,!0,l)},_n.hydrateRoot=function(s,o,l){if(!kd(s))throw Error(n(405));var f=l!=null&&l.hydratedSources||null,g=!1,w="",k=Km;if(l!=null&&(l.unstable_strictMode===!0&&(g=!0),l.identifierPrefix!==void 0&&(w=l.identifierPrefix),l.onRecoverableError!==void 0&&(k=l.onRecoverableError)),o=Hm(o,null,s,1,l??null,g,!1,w,k),s[Ds]=o.current,Vo(s),f)for(s=0;s<f.length;s++)l=f[s],g=l._getVersion,g=g(l._source),o.mutableSourceEagerHydrationData==null?o.mutableSourceEagerHydrationData=[l,g]:o.mutableSourceEagerHydrationData.push(l,g);return new ec(o)},_n.render=function(s,o,l){if(!tc(o))throw Error(n(200));return nc(null,s,o,!1,l)},_n.unmountComponentAtNode=function(s){if(!tc(s))throw Error(n(40));return s._reactRootContainer?(ea(function(){nc(null,null,s,!1,function(){s._reactRootContainer=null,s[Ds]=null})}),!0):!1},_n.unstable_batchedUpdates=md,_n.unstable_renderSubtreeIntoContainer=function(s,o,l,f){if(!tc(l))throw Error(n(200));if(s==null||s._reactInternals===void 0)throw Error(n(38));return nc(s,o,l,!1,f)},_n.version="18.3.1-next-f1338f8080-20240426",_n}var np;function Eg(){if(np)return Nd.exports;np=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(),Nd.exports=e_(),Nd.exports}var sp;function t_(){if(sp)return rc;sp=1;var e=Eg();return rc.createRoot=e.createRoot,rc.hydrateRoot=e.hydrateRoot,rc}var n_=t_();const s_=Cg(n_),$g=[{id:"dark",label:"Dark (Abstract)",group:"dark",swatches:["#1a1a2e","#16213e","#0f3460","#e94560","#60a5fa","#27ae60"]},{id:"observer-night",label:"Observer Night",group:"dark",swatches:["#0b0f14","#10161e","#161e28","#e8a54a","#6ea8d8","#7bc98c"]},{id:"catppuccin-mocha",label:"Catppuccin Mocha",group:"dark",swatches:["#1e1e2e","#181825","#313244","#cba6f7","#89b4fa","#a6e3a1"]},{id:"catppuccin-macchiato",label:"Catppuccin Macchiato",group:"dark",swatches:["#24273a","#1e2030","#363a4f","#c6a0f6","#8aadf4","#a6da95"]},{id:"catppuccin-frappe",label:"Catppuccin Frappe",group:"dark",swatches:["#303446","#292c3c","#414559","#ca9ee6","#8caaee","#a6d189"]},{id:"rose-pine",label:"Rose Pine",group:"dark",swatches:["#191724","#1f1d2e","#26233a","#c4a7e7","#31748f","#9ccfd8"]},{id:"rose-pine-moon",label:"Rose Pine Moon",group:"dark",swatches:["#232136","#2a273f","#393552","#c4a7e7","#3e8fb0","#9ccfd8"]},{id:"tokyo-night",label:"Tokyo Night",group:"dark",swatches:["#1a1b26","#24283b","#414868","#7aa2f7","#2ac3de","#9ece6a"]},{id:"nord",label:"Nord",group:"dark",swatches:["#2e3440","#3b4252","#434c5e","#88c0d0","#5e81ac","#a3be8c"]},{id:"one-dark",label:"One Dark",group:"dark",swatches:["#282c34","#21252b","#3a3f4b","#61afef","#c678dd","#98c379"]},{id:"dracula",label:"Dracula",group:"dark",swatches:["#282a36","#343746","#44475a","#ff79c6","#8be9fd","#50fa7b"]},{id:"monokai",label:"Monokai",group:"dark",swatches:["#272822","#2d2e27","#3e3d32","#66d9ef","#a1efe4","#a6e22e"]},{id:"gruvbox",label:"Gruvbox",group:"dark",swatches:["#282828","#3c3836","#504945","#fe8019","#83a598","#b8bb26"]},{id:"solarized-dark",label:"Solarized Dark",group:"dark",swatches:["#002b36","#073642","#0b4b5a","#268bd2","#2aa198","#859900"]},{id:"everforest-dark",label:"Everforest Dark",group:"dark",swatches:["#2b3339","#323c41","#3a464c","#a7c080","#7fbbb3","#a7c080"]},{id:"catppuccin-latte",label:"Catppuccin Latte",group:"light",swatches:["#eff1f5","#e6e9ef","#ccd0da","#8839ef","#1e66f5","#40a02b"]},{id:"rose-pine-dawn",label:"Rose Pine Dawn",group:"light",swatches:["#faf4ed","#fffaf3","#f2e9e1","#907aa9","#56949f","#286983"]},{id:"one-light",label:"One Light",group:"light",swatches:["#fafafa","#ffffff","#e5e5e6","#4078f2","#a626a4","#50a14f"]},{id:"everforest-light",label:"Everforest Light",group:"light",swatches:["#fdf6e3","#fffbef","#e8e0cc","#4f8f5a","#3a94c5","#4f8f5a"]},{id:"solarized-light",label:"Solarized Light",group:"light",swatches:["#fdf6e3","#eee8d5","#e3ddc9","#268bd2","#2aa198","#859900"]},{id:"light",label:"Light",group:"light",swatches:["#f7f7fb","#ffffff","#e6e8f0","#e94560","#2563eb","#16a34a"]}];$g.map(e=>({id:e.id,label:e.label}));function r_(e){return`theme-${String(e||"").trim()||"dark"}`}function rp(e){try{const t=document.documentElement,n=Array.from(t.classList).filter(r=>r.startsWith("theme-"));for(const r of n)t.classList.remove(r);t.classList.add(r_(e))}catch{}}const ef=[{id:"sm",label:"Small",scale:.9},{id:"md",label:"Medium",scale:1},{id:"lg",label:"Large",scale:1.1},{id:"xl",label:"Extra Large",scale:1.2}],tf=[{id:"compact",label:"Compact",density:.85},{id:"standard",label:"Standard",density:1},{id:"spacious",label:"Spacious",density:1.2}];function a_(e){const t=String(e).trim();return ef.find(n=>n.id===t)||ef[1]}function o_(e){const t=String(e).trim();return tf.find(n=>n.id===t)||tf[1]}function ap(e){try{const t=document.documentElement,n=a_(e.font_scale||"md"),r=o_(e.header_density||"standard");t.style.setProperty("--font-scale",String(n.scale)),t.style.setProperty("--header-density",String(r.density))}catch{}}const Mi={md:"(max-width: 1023.98px)",lg:"(max-width: 1439.98px)"};function i_(e){try{return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(e).matches}catch{return!1}}function kc(e){const[t,n]=y.useState(()=>i_(e));return y.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const r=window.matchMedia(e),i=()=>n(r.matches);return i(),typeof r.addEventListener=="function"?r.addEventListener("change",i):r.addListener(i),()=>{typeof r.removeEventListener=="function"?r.removeEventListener("change",i):r.removeListener(i)}},[e]),t}let ci=null;function l_(e,t){const n=Math.max(0,Math.round(e));if(!(t.scale<=1.01))return{vvHeight:n,keyboardInset:0};const r=Math.max(0,Math.min(n,Math.round(t.height))),i=Math.max(0,Math.round(e-t.height-Math.max(0,t.offsetTop)));return{vvHeight:r,keyboardInset:i}}function c_(){if(ci)return ci;if(typeof window>"u"||typeof document>"u")return()=>{};const e=window.visualViewport;if(!e)return()=>{};const t=document.documentElement;let n=0;const r=()=>{n=0;const{vvHeight:c,keyboardInset:u}=l_(window.innerHeight,{height:e.height,offsetTop:e.offsetTop,scale:e.scale||1});t.style.setProperty("--vv-height",`${c}px`),t.style.setProperty("--keyboard-inset",`${u}px`)},i=()=>{n||(n=window.requestAnimationFrame(r))};return r(),e.addEventListener("resize",i),e.addEventListener("scroll",i),window.addEventListener("orientationchange",i),ci=()=>{e.removeEventListener("resize",i),e.removeEventListener("scroll",i),window.removeEventListener("orientationchange",i),n&&window.cancelAnimationFrame(n),t.style.removeProperty("--vv-height"),t.style.removeProperty("--keyboard-inset"),ci=null},ci}var Oc=Eg();function qa(...e){return e.filter(Boolean).join(" ")}function Jn({value:e,options:t,placeholder:n="Select…",disabled:r=!1,loading:i=!1,searchable:c=!0,searchPlaceholder:u="Search…",allowCustom:d=!1,clearable:h=!1,minPopoverWidth:m=240,variant:p="panel",className:v,triggerClassName:_,ariaLabel:b,id:C,includeValueOption:x=!1,onOpen:j,customOptionLabel:N,validateCustomValue:$,onChange:S,renderOption:E,renderValue:A}){const R=y.useRef(null),z=y.useRef(null),L=y.useRef(null),J=y.useRef(j),V=y.useId(),O=C||`af-select-${V.replace(/[^a-zA-Z0-9_-]/g,"")}`,ee=`${O}-listbox`,[P,Z]=y.useState(!1),[U,te]=y.useState(""),[se,G]=y.useState(0),[ce,re]=y.useState("bottom"),[D,I]=y.useState({left:0,top:0,width:0});y.useEffect(()=>{J.current=j},[j]);const W=y.useMemo(()=>{if(!x)return t;const Y=String(e??"").trim();return!Y||t.some(pe=>pe.value===Y)?t:[...t,{value:Y,label:Y}]},[x,t,e]),me=y.useMemo(()=>{const Y=String(e??"");return W.find(pe=>pe.value===Y)||null},[W,e]),q=y.useMemo(()=>(me==null?void 0:me.label)||String(e||"").trim()||"",[me,e]),fe=y.useMemo(()=>{const Y=U.trim().toLowerCase();return Y?W.filter(pe=>pe.label.toLowerCase().includes(Y)||pe.value.toLowerCase().includes(Y)):W},[W,U]),de=y.useMemo(()=>{if(!d)return null;const Y=U.trim();if(!Y||W.some(Ee=>Ee.value===Y))return null;const ve=($==null?void 0:$(Y,{options:W}))||"";return{value:Y,label:N?N(Y):`Use "${Y}"`,disabled:!!ve,reason:ve}},[d,N,W,U,$]),ae=y.useMemo(()=>{const Y=de?[de,...fe]:fe;if(Y.length>0)return Y;const pe=String(e??"").trim();return i&&pe?[{value:pe,label:q||pe}]:Y},[de,fe,i,q,e]),we=y.useCallback(()=>{const Y=R.current;if(!Y)return;const pe=Y.getBoundingClientRect(),ve=Math.max(pe.width,m),Ee=Math.max(8,Math.min(pe.left,window.innerWidth-ve-8)),Oe=window.innerHeight-pe.bottom,Be=pe.top,Xe=Oe>=220||Oe>=Be?"bottom":"top";re(Xe);const mt=Xe==="bottom"?pe.bottom+6:pe.top-6;I({left:Ee,top:mt,width:ve})},[m]),Pe=y.useCallback(()=>{Z(!1),te("")},[]);y.useEffect(()=>{var Y;P&&((Y=J.current)==null||Y.call(J))},[P]),y.useEffect(()=>{if(!P)return;we();const Y=()=>we();return window.addEventListener("resize",Y),window.addEventListener("scroll",Y,!0),()=>{window.removeEventListener("resize",Y),window.removeEventListener("scroll",Y,!0)}},[P,we]),y.useEffect(()=>{if(!P)return;const Y=pe=>{var Ee,Oe;const ve=pe.target;ve&&((Ee=R.current)!=null&&Ee.contains(ve)||(Oe=z.current)!=null&&Oe.contains(ve)||Pe())};return document.addEventListener("mousedown",Y,!0),()=>document.removeEventListener("mousedown",Y,!0)},[P,Pe]),y.useEffect(()=>{if(!P)return;const Y=Math.max(0,ae.findIndex(pe=>pe.value===e));G(Y===-1?0:Y),c&&setTimeout(()=>{var pe;return(pe=L.current)==null?void 0:pe.focus()},0)},[P,c,e,ae]);const Qe=Y=>{var ve;const pe=ae.find(Ee=>Ee.value===Y);pe!=null&&pe.disabled||(S(Y),Pe(),(ve=R.current)==null||ve.focus())},Ye=Y=>{var pe,ve;if(Y.key==="Escape")return Y.preventDefault(),Pe(),(pe=R.current)==null||pe.focus(),!0;if(Y.key==="Tab")return Pe(),(ve=R.current)==null||ve.focus(),!1;if(Y.key==="ArrowDown")return Y.preventDefault(),G(Ee=>Math.min(Ee+1,Math.max(0,ae.length-1))),!0;if(Y.key==="ArrowUp")return Y.preventDefault(),G(Ee=>Math.max(Ee-1,0)),!0;if(Y.key==="Home")return Y.preventDefault(),G(0),!0;if(Y.key==="End")return Y.preventDefault(),G(Math.max(0,ae.length-1)),!0;if(Y.key==="Enter"){Y.preventDefault();const Ee=ae[se];return Ee&&Qe(Ee.value),!0}return!1},Ne=Y=>{if(!r){if(P){if(Ye(Y))return;if(Y.key===" "&&!c){Y.preventDefault();const pe=ae[se];pe&&Qe(pe.value)}return}(Y.key==="Enter"||Y.key===" "||Y.key==="ArrowDown"||Y.key==="ArrowUp")&&(Y.preventDefault(),Z(!0))}},He=!!String(e||"").trim(),ue=He?q:n,Ue=de!=null&&de.disabled?de.reason||"Unavailable":"",ie=P&&ae.length>0?`${O}-opt-${se}`:void 0,Ae=a.jsx("span",{className:qa("af-select-value",!He&&"af-select-value--placeholder"),children:i&&!He?"Loading…":ue}),ge=A?A(me,String(e||"")):Ae;return a.jsxs("span",{className:qa("af-select",p==="pin"?"af-select--pin":"af-select--panel",v),children:[a.jsxs("button",{ref:R,id:O,type:"button",className:qa("af-select-trigger",h&&He&&"af-select-trigger--clearable",_),disabled:r,onMouseDown:Y=>Y.stopPropagation(),onClick:Y=>{Y.stopPropagation(),!r&&Z(pe=>!pe)},onKeyDown:Ne,role:c?void 0:"combobox","aria-haspopup":"listbox","aria-expanded":P,"aria-controls":P?ee:void 0,"aria-activedescendant":c?void 0:ie,"aria-label":b,children:[ge,a.jsx("span",{className:qa("af-select-caret",P&&"af-select-caret--open"),children:"▾"})]}),h&&He?a.jsx("button",{type:"button",className:"af-select-clear-btn","aria-label":"Clear selection",disabled:r,onMouseDown:Y=>{Y.preventDefault(),Y.stopPropagation()},onClick:Y=>{var pe;Y.preventDefault(),Y.stopPropagation(),S(""),Pe(),(pe=R.current)==null||pe.focus()},title:"Clear",children:"×"}):null,P?Oc.createPortal(a.jsxs("div",{ref:z,className:qa("af-select-popover",ce==="top"&&"af-select-popover--top"),style:{position:"fixed",left:`${D.left}px`,top:`${D.top}px`,width:`${D.width}px`},onMouseDown:Y=>Y.stopPropagation(),onClick:Y=>Y.stopPropagation(),onWheel:Y=>Y.stopPropagation(),onKeyDown:Ye,tabIndex:-1,children:[c?a.jsxs("div",{className:"af-select-search",children:[a.jsx("input",{ref:L,className:"af-select-search-input",value:U,onChange:Y=>te(Y.target.value),placeholder:u,onKeyDown:Ye,role:"combobox","aria-expanded":!0,"aria-controls":ee,"aria-activedescendant":ie,"aria-invalid":!!Ue,"aria-describedby":Ue?`${O}-custom-error`:void 0}),Ue?a.jsx("div",{id:`${O}-custom-error`,className:"af-select-custom-error",role:"alert",children:Ue}):null]}):null,a.jsx("div",{className:"af-select-options",role:"listbox",id:ee,"aria-label":b,children:i&&ae.length===0?a.jsx("div",{className:"af-select-empty",children:"Loading…"}):ae.length===0?a.jsx("div",{className:"af-select-empty",children:"No results"}):ae.map((Y,pe)=>{var mt;const ve=Y.value===e,Ee=pe===se,Oe=String(Y.group||"").trim(),Be=pe>0?String(((mt=ae[pe-1])==null?void 0:mt.group)||"").trim():"",Xe=!!Oe&&Oe!==Be;return a.jsxs(lt.Fragment,{children:[Xe?a.jsx("div",{className:"af-select-group",role:"presentation",children:Oe}):null,a.jsx("div",{id:`${O}-opt-${pe}`,role:"option","aria-selected":ve,className:qa("af-select-option",ve&&"af-select-option--selected",Ee&&"af-select-option--highlighted",Y.disabled&&"af-select-option--disabled"),title:Y.disabled?Y.reason||"Unavailable":void 0,onMouseEnter:()=>G(pe),onMouseDown:Tt=>{Tt.preventDefault(),Tt.stopPropagation()},onClick:()=>Qe(Y.value),"aria-disabled":Y.disabled?!0:void 0,children:E?E(Y,{selected:ve,highlighted:Ee}):a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"af-select-option-label",children:[a.jsx("span",{children:Y.label}),Y.reason?a.jsx("small",{className:"af-select-option-reason",children:Y.reason}):null]}),ve?a.jsx("span",{className:"af-select-check",children:"✓"}):null]})})]},Y.value)})})]}),document.body):null]})}function u_(e){const t=new Set,n=[];for(const r of e||[]){if(!r||typeof r!="object")continue;const i=String(r.name||"").trim();!i||t.has(i)||(t.add(i),n.push({name:i,display_name:typeof r.display_name=="string"?r.display_name:void 0}))}return n.sort((r,i)=>r.name.localeCompare(i.name)),n}function d_(e){const t=new Set,n=[];for(const r of e||[]){const i=String(r||"").trim();!i||t.has(i)||(t.add(i),n.push(i))}return n.sort(),n}function f_(e){const t=e.disabled===!0,n=e.layout||"stack",r=e.allowGatewayDefault!==!1,i=String(e.gatewayDefaultLabel||"(gateway default)"),c=String(e.providerLabel||"Provider"),u=String(e.modelLabel||"Model"),d=String(e.providerPlaceholder||"(select)"),h=String(e.modelPlaceholder||"(select)"),m=String(e.provider||"").trim(),p=String(e.model||"").trim(),v=u_(e.providers),_=d_(e.models),b=t||!!e.loadingProviders,C=t||!!e.loadingModels,x=[...r?[{value:"",label:i}]:[],...v.map(N=>({value:N.name,label:N.display_name?`${N.display_name} (${N.name})`:N.name}))],j=[...r?[{value:"",label:i}]:[],..._.map(N=>({value:N,label:N}))];return a.jsxs("div",{className:e.className,style:n==="row"?{display:"flex",gap:"10px",flexWrap:"wrap",alignItems:"flex-start"}:{display:"flex",flexDirection:"column",gap:"10px"},children:[a.jsxs("div",{style:n==="row"?{flex:"1 1 260px",minWidth:240}:void 0,children:[a.jsx("label",{children:c}),a.jsx(Jn,{value:m,options:x,placeholder:r?i:d,disabled:b,loading:!!e.loadingProviders,searchable:!0,allowCustom:e.allowCustomProvider===!0,clearable:r,variant:"panel",triggerClassName:e.selectClassName,ariaLabel:c,onChange:N=>e.onChange({provider:String(N||"").trim(),model:""})}),e.loadingProviders?a.jsx("div",{className:"mono muted",style:{fontSize:"12px",marginTop:"6px"},children:"Loading providers…"}):null,e.providerError?a.jsx("div",{className:"mono",style:{color:"var(--error)",fontSize:"12px",marginTop:"6px"},children:e.providerError}):null]}),a.jsxs("div",{style:n==="row"?{flex:"1 1 260px",minWidth:240}:void 0,children:[a.jsx("label",{children:u}),a.jsx(Jn,{value:p,options:j,placeholder:r?i:h,disabled:C,loading:!!e.loadingModels,searchable:!0,allowCustom:e.allowCustomModel===!0,clearable:r,variant:"panel",triggerClassName:e.selectClassName,ariaLabel:u,onChange:N=>e.onChange({provider:m,model:String(N||"").trim()})}),e.loadingModels?a.jsx("div",{className:"mono muted",style:{fontSize:"12px",marginTop:"6px"},children:"Loading models…"}):null,e.modelError?a.jsx("div",{className:"mono",style:{color:"var(--error)",fontSize:"12px",marginTop:"6px"},children:e.modelError}):null]})]})}function Ag(e){if(e===!1||e&&typeof e=="object"&&e.mode==="off")return!1;if(!e||typeof e!="object")return;const t=e;if(!(t.mode!=="native_mtp"||!Number.isInteger(t.num_draft_tokens)||Number(t.num_draft_tokens)<1))return{mode:"native_mtp",num_draft_tokens:Number(t.num_draft_tokens),require_acceleration:!0}}function h_(e){var n;const t=(n=e==null?void 0:e.execution)==null?void 0:n.speculation;return!t||typeof t.supported!="boolean"?null:{supported:t.supported,ready:typeof t.ready=="boolean"?t.ready:null,reason:typeof t.reason=="string"?t.reason:null,supported_depths:t.supported&&Array.isArray(t.supported_depths)?[...new Set(t.supported_depths.filter(r=>typeof r=="number"&&Number.isInteger(r)&&r>0))]:[],default:Object.prototype.hasOwnProperty.call(t,"effective_default")?t.effective_default:t.default,requires_reload:typeof t.requires_reload=="boolean"?t.requires_reload:null}}function op(e){const t=Ag(e);return t===!1?"off":t?String(t.num_draft_tokens):""}function m_(e){if(e==="off")return!1;if(!(!/^\d+$/.test(e)||Number(e)<1))return{mode:"native_mtp",num_draft_tokens:Number(e),require_acceleration:!0}}function p_(e){const t=h_(e.capabilities),n=op(e.value),r=(t==null?void 0:t.supported_depths.map(String))||[],i=op(t==null?void 0:t.default),c=e.inheritLabel||"Workflow / Gateway default",u=i?`${c} (${i==="off"?"Off":`depth ${i}`})`:c,d=e.error||(e.loading?"Checking MTP capability…":t?t.reason||(t.requires_reload?"Model reload required before MTP can run.":t.ready===!1?"MTP is supported but not ready on this instance.":t.ready===null&&t.supported?"MTP support verified; loaded-instance readiness is unknown.":t.supported?"":"MTP is not supported on this model/backend."):"MTP capability unknown; no depth is assumed.");return a.jsxs("div",{className:"af-pmp__speculation",children:[a.jsx("label",{children:"MTP depth"}),a.jsx(Jn,{ariaLabel:"MTP depth",value:n,placeholder:u,disabled:e.disabled||e.loading,options:[{value:"",label:u},{value:"off",label:"Off"},...r.map(h=>({value:h,label:`Depth ${h}`})),...n&&n!=="off"&&!r.includes(n)?[{value:n,label:`Depth ${n} (saved; not available)`}]:[]],onChange:h=>e.onChange(m_(h))}),d&&!e.hideNote?a.jsx("div",{role:"status",className:"af-pmp__hint",children:d}):null]})}const g_="Reasoning and MTP choices appear when the gateway can describe the selected model.",y_="Reasoning choices appear when the gateway can describe the selected model.";function Pc(e){var re,D;const t=e.disabled===!0,n=e.value||{provider:"",model:""},r=!String(n.provider||"").trim()&&!String(n.model||"").trim(),[i,c]=y.useState(!r),u=r&&!i,d=y.useRef(r);y.useEffect(()=>{r&&!d.current&&c(!1),d.current=r},[r]);const[h,m]=y.useState([]),[p,v]=y.useState(!1),[_,b]=y.useState(""),[C,x]=y.useState([]),[j,N]=y.useState(!1),[$,S]=y.useState(""),E=y.useRef(e);E.current=e,y.useEffect(()=>{if(u||t)return;let I=!0;return v(!0),(async()=>{try{const W=await E.current.fetchProviders();if(!I)return;m(Array.isArray(W)?W:[]),b("")}catch(W){if(!I)return;m([]),b(`#FALLBACK provider discovery failed: ${String((W==null?void 0:W.message)||W)}`)}finally{I&&v(!1)}})(),()=>{I=!1}},[u,t]);const A=String(n.provider||"").trim();y.useEffect(()=>{if(!A||t){x([]),S(""),N(!1);return}let I=!0;return x([]),N(!0),S(""),(async()=>{try{const W=await E.current.fetchModels(A);if(!I)return;x(Array.isArray(W)?W:[])}catch(W){if(!I)return;x([]),S(`#FALLBACK model discovery failed: ${String((W==null?void 0:W.message)||W)}`)}finally{I&&N(!1)}})(),()=>{I=!1}},[A,t]);const R=y.useMemo(()=>{const I=[...h];return A&&!I.some(W=>W.name===A)&&I.unshift({name:A}),I},[h,A]),z=String(n.model||"").trim(),L=y.useMemo(()=>{const I=[...C];return z&&!I.includes(z)&&I.unshift(z),I},[C,z]),J=e.defaultModeLabel||"Gateway default",V=e.customModeLabel||"Custom",O=A||((re=e.effectiveDefault)==null?void 0:re.provider)||"",ee=z||(A?"":(D=e.effectiveDefault)==null?void 0:D.model)||"",[P,Z]=y.useState({levels:[],error:"",loading:!1}),U=!!e.fetchModelCapabilities,[te,se]=y.useState();y.useEffect(()=>{let I=!0;if(se(void 0),Z({levels:[],error:"",loading:U&&!!ee}),!(!U||!ee||t))return E.current.fetchModelCapabilities(ee,O).then(W=>{var de;if(!I)return;if(W!=null&&W.error)throw new Error(String(W.error));se(W);const me=(W==null?void 0:W.capabilities)||W||{},q=me.reasoning_levels||me.thinking_levels,fe=Array.isArray(q)?[...new Set(q.filter(ae=>typeof ae=="string"&&!!ae.trim()))]:[];!fe.length&&me.thinking_support===!0&&((de=me.thinking_control)!=null&&de.prompt_disable_token)&&fe.push("off","auto"),Z({levels:fe,error:"",loading:!1})}).catch(W=>{I&&Z({levels:[],error:String((W==null?void 0:W.message)||W),loading:!1})}),()=>{I=!1}},[O,ee,U,t]);const G=e.inheritLabel||"Workflow / Gateway default",ce=!u||e.optionsInDefaultMode!==!1;return a.jsxs("div",{className:`af-pmp${e.className?` ${e.className}`:""}`,children:[a.jsxs("div",{className:"af-pmp__seg",role:"tablist","aria-label":"Provider mode",children:[a.jsx("button",{type:"button",role:"tab","aria-selected":u,className:`af-pmp__seg-btn${u?" is-active":""}`,onClick:()=>{c(!1),e.onChange({...n,provider:"",model:"",...U?{reasoning:""}:{}})},disabled:t,children:J}),a.jsx("button",{type:"button",role:"tab","aria-selected":!u,className:`af-pmp__seg-btn${u?"":" is-active"}`,onClick:()=>{c(!0)},disabled:t,children:V})]}),u?a.jsx("div",{className:"af-pmp__hint",children:e.defaultHint||"The gateway picks its configured default provider and model for this task."}):a.jsx(f_,{provider:A,model:z,providers:R,models:L,disabled:t,loadingProviders:p,loadingModels:j,providerError:_||void 0,modelError:$||void 0,providerLabel:e.providerLabel,modelLabel:e.modelLabel,allowGatewayDefault:!1,allowCustomProvider:e.allowCustom!==!1,allowCustomModel:e.allowCustom!==!1,onChange:I=>e.onChange({...n,provider:I.provider,model:I.model,...U?{reasoning:""}:{}})}),ce&&U&&(P.levels.length>0||n.reasoning)?a.jsxs("div",{className:"af-pmp__reasoning",children:[a.jsx("label",{children:e.reasoningLabel||"Reasoning effort"}),a.jsx(Jn,{ariaLabel:e.reasoningLabel||"Reasoning effort",placeholder:G,value:n.reasoning||"",options:[{value:"",label:G},...P.levels.map(I=>({value:I,label:I})),...n.reasoning&&!P.levels.includes(n.reasoning)?[{value:n.reasoning,label:`${n.reasoning} (saved; not advertised)`}]:[]],disabled:t||P.loading,onChange:I=>e.onChange({...n,reasoning:I})})]}):null,ce&&e.enableSpeculation?a.jsx(p_,{value:n.speculation,inheritLabel:G,onChange:I=>e.onChange({...n,speculation:I}),capabilities:te,disabled:t,loading:P.loading,hideNote:!!P.error}):null,ce&&P.error?a.jsxs("div",{role:"status",className:"af-pmp__hint","data-discovery":"unavailable",children:[e.enableSpeculation?g_:y_,a.jsxs("details",{className:"af-pmp__details",children:[a.jsx("summary",{children:"Technical details"}),a.jsx("span",{children:P.error})]})]}):null]})}function ip(...e){return e.filter(Boolean).join(" ")}function w_({kicker:e="AbstractGateway connection",title:t="Connect to AbstractGateway",description:n="Sign in with the Gateway user token assigned by the Gateway admin.",statusLabel:r="Not signed in",statusTone:i="neutral",showGatewayUrl:c=!1,gatewayUrl:u="",gatewayUrlPlaceholder:d="http://127.0.0.1:8080",onGatewayUrlChange:h,userId:m,userPlaceholder:p="admin",onUserIdChange:v,token:_,tokenPlaceholder:b="Paste Gateway user token",showToken:C=!1,onTokenChange:x,onShowTokenChange:j,remember:N=!1,rememberLabel:$="Remember this browser",onRememberChange:S,loading:E=!1,submitting:A=!1,submitDisabled:R=!1,submitLabel:z="Sign in",submittingLabel:L="Signing in...",closeLabel:J="Close",signOutLabel:V="Sign out",showClose:O=!1,showSignOut:ee=!1,error:P,message:Z,className:U,onSubmit:te,onClose:se,onSignOut:G}){const ce=E||A,re=ce||R||!String(m||"").trim()||!String(_||"").trim(),D=I=>{I.preventDefault(),!re&&te()};return a.jsxs("form",{className:ip("af-gateway-signin",U),onSubmit:D,children:[a.jsxs("div",{className:"af-gateway-signin__hero",children:[a.jsxs("div",{children:[a.jsx("div",{className:"af-gateway-signin__kicker",children:e}),a.jsx("h2",{children:t}),n?a.jsx("p",{children:n}):null]}),a.jsx("div",{className:"af-gateway-signin__mark","aria-hidden":"true",children:"↔"})]}),a.jsx("div",{className:"af-gateway-signin__status-row",children:a.jsx("span",{className:ip("af-gateway-signin__status",`af-gateway-signin__status--${i}`),children:r})}),a.jsxs("div",{className:"af-gateway-signin__form",children:[c?a.jsxs(a.Fragment,{children:[a.jsx("label",{className:"af-gateway-signin__label",htmlFor:"gateway-session-url",children:"Gateway URL"}),a.jsx("input",{id:"gateway-session-url",value:u,onChange:I=>h==null?void 0:h(I.target.value),placeholder:d,autoComplete:"url",disabled:ce})]}):null,a.jsx("label",{className:"af-gateway-signin__label",htmlFor:"gateway-session-user",children:"Gateway user"}),a.jsx("input",{id:"gateway-session-user",value:m,onChange:I=>v(I.target.value),placeholder:p,autoComplete:"username",disabled:ce}),a.jsx("label",{className:"af-gateway-signin__label",htmlFor:"gateway-session-token",children:"Gateway token"}),a.jsxs("div",{className:"af-gateway-signin__token-input",children:[a.jsx("input",{id:"gateway-session-token",type:C?"text":"password",value:_,onChange:I=>x(I.target.value),placeholder:b,autoComplete:"off","data-1p-ignore":"","data-lpignore":"true","data-bwignore":"",spellCheck:!1,disabled:ce}),a.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:()=>j==null?void 0:j(!C),disabled:ce,children:C?"Hide":"Show"})]}),a.jsxs("label",{className:"af-gateway-signin__checkbox",children:[a.jsx("input",{type:"checkbox",checked:!!N,onChange:I=>S==null?void 0:S(I.target.checked),disabled:ce}),$]})]}),P?a.jsx("div",{className:"af-gateway-signin__message af-gateway-signin__message--error",children:P}):null,!P&&Z?a.jsx("div",{className:"af-gateway-signin__message af-gateway-signin__message--ok",children:Z}):null,a.jsxs("div",{className:"af-gateway-signin__actions",children:[O?a.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:se,disabled:ce,children:J}):null,ee?a.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:()=>void(G==null?void 0:G()),disabled:ce,children:V}):null,a.jsx("button",{className:"af-gateway-signin__primary",type:"submit",disabled:re,children:A?L:z})]})]})}function v_(e){return e==="light"?"Light":"Dark"}function __(e){const t=e.themes&&e.themes.length?e.themes:$g,n=e.showSwatches!==!1,r=e.variant||"panel",i=y.useMemo(()=>{const u={};for(const d of t)u[d.id]=d;return u},[t]),c=y.useMemo(()=>t.map(u=>({value:u.id,label:u.label,group:v_(u.group)})),[t]);return a.jsx(Jn,{value:e.value,options:c,placeholder:e.placeholder||"Select theme…",disabled:e.disabled===!0,searchable:!0,allowCustom:!1,clearable:!1,variant:r,className:e.className,triggerClassName:e.triggerClassName,onChange:u=>e.onChange(String(u||"").trim()),renderValue:(u,d)=>{const h=String(d||"").trim(),m=i[h],p=(m==null?void 0:m.label)||h||e.placeholder||"Select theme…",v=(m==null?void 0:m.swatches)||null,_=!h;return a.jsxs("span",{className:"af-theme-value",children:[a.jsx("span",{className:`af-theme-label ${_?"af-theme-label--placeholder":""}`.trim(),children:p}),n&&v?a.jsx("span",{className:"af-theme-swatches","aria-hidden":"true",children:v.map((b,C)=>a.jsx("span",{className:"af-theme-swatch",style:{background:b}},`${h}:${C}`))}):null]})},renderOption:(u,d)=>{const h=String(u.value||"").trim(),m=i[h],p=(m==null?void 0:m.swatches)||null;return a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"af-theme-option-label",children:u.label}),a.jsxs("span",{className:"af-theme-option-right",children:[n&&p?a.jsx("span",{className:"af-theme-swatches","aria-hidden":"true",children:p.map((v,_)=>a.jsx("span",{className:"af-theme-swatch",style:{background:v}},`${h}:${_}`))}):null,d.selected?a.jsx("span",{className:"af-select-check",children:"✓"}):null]})]})}})}function b_(e){const t=e.scales&&e.scales.length?e.scales:ef,n=e.variant||"panel",r=y.useMemo(()=>t.map(i=>({value:i.id,label:i.label})),[t]);return a.jsx(Jn,{value:e.value,options:r,placeholder:e.placeholder||"Font size…",disabled:e.disabled===!0,searchable:!1,allowCustom:!1,clearable:!1,variant:n,className:e.className,triggerClassName:e.triggerClassName,onChange:i=>e.onChange(String(i||"").trim())})}function x_(e){const t=e.densities&&e.densities.length?e.densities:tf,n=e.variant||"panel",r=y.useMemo(()=>t.map(i=>({value:i.id,label:i.label})),[t]);return a.jsx(Jn,{value:e.value,options:r,placeholder:e.placeholder||"Header size…",disabled:e.disabled===!0,searchable:!1,allowCustom:!1,clearable:!1,variant:n,className:e.className,triggerClassName:e.triggerClassName,onChange:i=>e.onChange(String(i||"").trim())})}const k_=new Set(["board","inbox","server","agent","playCircle","list","gear"]);function j_(e){switch(e){case"chat":return a.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"});case"plus":return a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M12 5v14"}),a.jsx("path",{d:"M5 12h14"})]});case"history":return a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:"12",cy:"12",r:"9"}),a.jsx("path",{d:"M12 7v5l3 3"})]});case"refresh":return a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M21 12a9 9 0 0 0-15.5-6.4L3 8"}),a.jsx("path",{d:"M3 3v5h5"}),a.jsx("path",{d:"M3 12a9 9 0 0 0 15.5 6.4L21 16"}),a.jsx("path",{d:"M21 21v-5h-5"})]});case"cog":return a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),a.jsx("circle",{cx:"12",cy:"12",r:"3"})]});case"activity":return a.jsx("path",{d:"M22 12h-4l-3 9L9 3l-3 9H2"});case"settings":return a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M4 6h16"}),a.jsx("circle",{cx:"8",cy:"6",r:"2"}),a.jsx("path",{d:"M4 12h16"}),a.jsx("circle",{cx:"16",cy:"12",r:"2"}),a.jsx("path",{d:"M4 18h16"}),a.jsx("circle",{cx:"10",cy:"18",r:"2"})]});case"user":return a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:"12",cy:"8",r:"4"}),a.jsx("path",{d:"M4 21a8 8 0 0 1 16 0"})]});case"bot":return a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M12 2v3"}),a.jsx("rect",{x:"5",y:"6",width:"14",height:"14",rx:"3"}),a.jsx("circle",{cx:"9",cy:"13",r:"1",fill:"currentColor",stroke:"none"}),a.jsx("circle",{cx:"15",cy:"13",r:"1",fill:"currentColor",stroke:"none"}),a.jsx("path",{d:"M9 17h6"})]});case"paperclip":return a.jsx("path",{d:"M21.44 11.05l-9.19 9.19a5.5 5.5 0 0 1-7.78-7.78l9.19-9.19a3.5 3.5 0 0 1 4.95 4.95l-9.2 9.19a1.5 1.5 0 0 1-2.12-2.12l8.49-8.48"});case"mic":return a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M12 14a3 3 0 0 0 3-3V5a3 3 0 0 0-6 0v6a3 3 0 0 0 3 3z"}),a.jsx("path",{d:"M19 11a7 7 0 0 1-14 0"}),a.jsx("path",{d:"M12 18v4"}),a.jsx("path",{d:"M8 22h8"})]});case"speaker":return a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M11 5L6 9H2v6h4l5 4V5z"}),a.jsx("path",{d:"M15.5 8.5a5 5 0 0 1 0 7"}),a.jsx("path",{d:"M18 6a9 9 0 0 1 0 12"})]});case"pause":return a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",fill:"currentColor",stroke:"none"}),a.jsx("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",fill:"currentColor",stroke:"none"})]});case"terminal":return a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",ry:"2"}),a.jsx("path",{d:"M7 9l3 3-3 3"}),a.jsx("path",{d:"M12 15h5"})]});case"edit":return a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M12 20h9"}),a.jsx("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})]});case"download":return a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),a.jsx("path",{d:"M7 10l5 5 5-5"}),a.jsx("path",{d:"M12 15V3"})]});case"loader":return a.jsx("path",{d:"M21 12a9 9 0 1 1-3.3-6.9"});case"info":return a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("path",{d:"M12 16v-4"}),a.jsx("circle",{cx:"12",cy:"8",r:"0.75",fill:"currentColor",stroke:"none"})]});case"warning":return a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M12 3l10 18H2L12 3z"}),a.jsx("path",{d:"M12 9v4"}),a.jsx("circle",{cx:"12",cy:"17",r:"0.75",fill:"currentColor",stroke:"none"})]});case"error":return a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("path",{d:"M15 9l-6 6"}),a.jsx("path",{d:"M9 9l6 6"})]});case"copy":return a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),a.jsx("path",{d:"M5 15V5a2 2 0 0 1 2-2h10"})]});case"check":return a.jsx("path",{d:"M20 6L9 17l-5-5"});case"x":return a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M18 6L6 18"}),a.jsx("path",{d:"M6 6l12 12"})]});case"chevronDown":return a.jsx("path",{d:"M6 9l6 6 6-6"});case"chevronRight":return a.jsx("path",{d:"M9 18l6-6-6-6"});case"trash":return a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M3 6h18"}),a.jsx("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),a.jsx("path",{d:"M6 6l1 16h10l1-16"}),a.jsx("path",{d:"M10 11v6"}),a.jsx("path",{d:"M14 11v6"})]});case"send":return a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M22 2L11 13"}),a.jsx("path",{d:"M22 2L15 22l-4-9-9-4 20-7z"})]});case"thumbsUp":return a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M7 10v11"}),a.jsx("path",{d:"M7 10l4.5-8a2 2 0 0 1 3.6 1.5L14 8h5.2a2 2 0 0 1 2 2.4l-1.6 8a2 2 0 0 1-2 1.6H7"})]});case"thumbsDown":return a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M17 14V3"}),a.jsx("path",{d:"M17 14l-4.5 8a2 2 0 0 1-3.6-1.5L10 16H4.8a2 2 0 0 1-2-2.4l1.6-8a2 2 0 0 1 2-1.6H17"})]});case"thumbsUpFilled":return a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M7 10v11"}),a.jsx("path",{d:"M7 10l4.5-8a2 2 0 0 1 3.6 1.5L14 8h5.2a2 2 0 0 1 2 2.4l-1.6 8a2 2 0 0 1-2 1.6H7z",fill:"currentColor",stroke:"none"})]});case"thumbsDownFilled":return a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M17 14V3"}),a.jsx("path",{d:"M17 14l-4.5 8a2 2 0 0 1-3.6-1.5L10 16H4.8a2 2 0 0 1-2-2.4l1.6-8a2 2 0 0 1 2-1.6H17z",fill:"currentColor",stroke:"none"})]});case"board":return a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:"1.5",y:"2",width:"3.6",height:"12",rx:"1"}),a.jsx("rect",{x:"6.2",y:"2",width:"3.6",height:"8.5",rx:"1"}),a.jsx("rect",{x:"10.9",y:"2",width:"3.6",height:"5.5",rx:"1"})]});case"inbox":return a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M2 9.5 L4 3.5 h8 l2 6"}),a.jsx("path",{d:"M2 9.5 v3 h12 v-3"}),a.jsx("path",{d:"M2 9.5 h3.4 l1 1.6 h3.2 l1-1.6 H14"})]});case"server":return a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:"2",y:"2.5",width:"12",height:"4.6",rx:"1.2"}),a.jsx("rect",{x:"2",y:"8.9",width:"12",height:"4.6",rx:"1.2"}),a.jsx("circle",{cx:"4.6",cy:"4.8",r:"0.8",fill:"currentColor",stroke:"none"}),a.jsx("circle",{cx:"4.6",cy:"11.2",r:"0.8",fill:"currentColor",stroke:"none"})]});case"agent":return a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:"3",y:"4.5",width:"10",height:"8",rx:"2"}),a.jsx("path",{d:"M8 4.5V2.2"}),a.jsx("circle",{cx:"8",cy:"1.8",r:"0.9",fill:"currentColor",stroke:"none"}),a.jsx("circle",{cx:"5.8",cy:"8.4",r:"0.9",fill:"currentColor",stroke:"none"}),a.jsx("circle",{cx:"10.2",cy:"8.4",r:"0.9",fill:"currentColor",stroke:"none"})]});case"playCircle":return a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:"8",cy:"8",r:"6.2"}),a.jsx("path",{d:"M6.5 5.6 L11 8 L6.5 10.4 Z",fill:"currentColor",stroke:"none"})]});case"list":return a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M2.5 4h11"}),a.jsx("path",{d:"M2.5 8h11"}),a.jsx("path",{d:"M2.5 12h7"})]});case"gear":return a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:"8",cy:"8",r:"2.2"}),a.jsx("path",{d:"M8 1.6v2"}),a.jsx("path",{d:"M8 12.4v2"}),a.jsx("path",{d:"M1.6 8h2"}),a.jsx("path",{d:"M12.4 8h2"}),a.jsx("path",{d:"M3.5 3.5l1.4 1.4"}),a.jsx("path",{d:"M11.1 11.1l1.4 1.4"}),a.jsx("path",{d:"M12.5 3.5l-1.4 1.4"}),a.jsx("path",{d:"M4.9 11.1l-1.4 1.4"})]});case"sparkle":return a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9z"}),a.jsx("path",{d:"M18.5 15.5l.8 2.2 2.2.8-2.2.8-.8 2.2-.8-2.2-2.2-.8 2.2-.8z"})]});case"contrast":return a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:"12",cy:"12",r:"9"}),a.jsx("path",{d:"M12 3a9 9 0 0 1 0 18z",fill:"currentColor",stroke:"none"})]});case"logout":return a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),a.jsx("path",{d:"M16 17l5-5-5-5"}),a.jsx("path",{d:"M21 12H9"})]});case"play":return a.jsx("path",{d:"M7 4.5v15a1 1 0 0 0 1.5.86l12-7.5a1 1 0 0 0 0-1.72l-12-7.5A1 1 0 0 0 7 4.5z",fill:"currentColor",stroke:"none"});case"stop":return a.jsx("rect",{x:"5",y:"5",width:"14",height:"14",rx:"2",fill:"currentColor",stroke:"none"});case"folder":return a.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"});case"file":return a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),a.jsx("path",{d:"M14 2v6h6"})]});case"archive":return a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:"2",y:"3",width:"20",height:"5",rx:"1"}),a.jsx("path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8"}),a.jsx("path",{d:"M10 12h4"})]});case"unarchive":return a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:"2",y:"3",width:"20",height:"5",rx:"1"}),a.jsx("path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8"}),a.jsx("path",{d:"M12 18v-6"}),a.jsx("path",{d:"m9 14 3-3 3 3"})]});case"clock":return a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("path",{d:"M12 6v6h4"})]});case"book":return a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M2 4h6a4 4 0 0 1 4 4v13a3 3 0 0 0-3-3H2z"}),a.jsx("path",{d:"M22 4h-6a4 4 0 0 0-4 4v13a3 3 0 0 1 3-3h7z"})]});case"compose":return a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),a.jsx("path",{d:"M18.4 2.6a2.1 2.1 0 0 1 3 3L12 15l-4 1 1-4z"})]});case"image":return a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),a.jsx("circle",{cx:"9",cy:"9",r:"2"}),a.jsx("path",{d:"M21 15l-3.1-3.1a2 2 0 0 0-2.8 0L6 21"})]});case"video":return a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:"2",y:"6",width:"14",height:"12",rx:"2"}),a.jsx("path",{d:"M16 10.5l5.2-3.1a.5.5 0 0 1 .8.4v8.4a.5.5 0 0 1-.8.4L16 13.5"})]});case"camera":return a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3z"}),a.jsx("circle",{cx:"12",cy:"13",r:"3"})]});case"music":return a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M9 18V5l12-2v13"}),a.jsx("circle",{cx:"6",cy:"18",r:"3"}),a.jsx("circle",{cx:"18",cy:"16",r:"3"})]});case"database":return a.jsxs(a.Fragment,{children:[a.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),a.jsx("path",{d:"M3 5v14a9 3 0 0 0 18 0V5"}),a.jsx("path",{d:"M3 12a9 3 0 0 0 18 0"})]});case"branch":return a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M6 3v12"}),a.jsx("circle",{cx:"18",cy:"6",r:"3"}),a.jsx("circle",{cx:"6",cy:"18",r:"3"}),a.jsx("path",{d:"M18 9a9 9 0 0 1-9 9"})]});case"loop":return a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M17 2l4 4-4 4"}),a.jsx("path",{d:"M3 11v-1a4 4 0 0 1 4-4h14"}),a.jsx("path",{d:"M7 22l-4-4 4-4"}),a.jsx("path",{d:"M21 13v1a4 4 0 0 1-4 4H3"})]});case"variable":return a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M8 21s-4-3-4-9 4-9 4-9"}),a.jsx("path",{d:"M16 3s4 3 4 9-4 9-4 9"}),a.jsx("path",{d:"M15 9l-6 6"}),a.jsx("path",{d:"M9 9l6 6"})]});case"minus":return a.jsx("path",{d:"M5 12h14"});case"divide":return a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:"12",cy:"6",r:"1.25",fill:"currentColor",stroke:"none"}),a.jsx("path",{d:"M5 12h14"}),a.jsx("circle",{cx:"12",cy:"18",r:"1.25",fill:"currentColor",stroke:"none"})]});case"function":return a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),a.jsx("path",{d:"M9 17c2 0 2.8-1 2.8-2.8V10c0-2 1-3.3 3.2-3"}),a.jsx("path",{d:"M9 11.2h5.7"})]});case"zoomIn":return a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:"11",cy:"11",r:"8"}),a.jsx("path",{d:"M21 21l-4.35-4.35"}),a.jsx("path",{d:"M11 8v6"}),a.jsx("path",{d:"M8 11h6"})]});case"zoomOut":return a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:"11",cy:"11",r:"8"}),a.jsx("path",{d:"M21 21l-4.35-4.35"}),a.jsx("path",{d:"M8 11h6"})]});case"fitView":return a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M8 3H5a2 2 0 0 0-2 2v3"}),a.jsx("path",{d:"M21 8V5a2 2 0 0 0-2-2h-3"}),a.jsx("path",{d:"M3 16v3a2 2 0 0 0 2 2h3"}),a.jsx("path",{d:"M16 21h3a2 2 0 0 0 2-2v-3"})]});case"lock":return a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:"4",y:"11",width:"16",height:"10",rx:"2"}),a.jsx("path",{d:"M8 11V7a4 4 0 0 1 8 0v4"})]});default:return null}}function ne({name:e,size:t=16,className:n,title:r,...i}){const c=r?void 0:!0,u=k_.has(e);return a.jsxs("svg",{width:t,height:t,viewBox:u?"0 0 16 16":"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:u?1.4:2,strokeLinecap:"round",strokeLinejoin:"round",className:n,"aria-hidden":c,role:r?"img":"presentation",...i,children:[r?a.jsx("title",{children:r}):null,j_(e)]})}const Rr="api/gateway",Pi="api/connection/gateway";function _e(e){const t=String(e||"");if(t.startsWith("/"))throw new Error(`gatewayApiPath takes a route relative to the gateway API, got ${JSON.stringify(t)}.`);return t?`${Rr}/${t}`:Rr}function et(e,t){const n=String(t||"");if(n.startsWith("/"))throw new Error(`joinBaseUrl takes a relative path, got ${JSON.stringify(n)}.`);let r=String(e??"");for(;r.endsWith("/");)r=r.slice(0,-1);return r?`${r}/${n}`:n}function S_(e){const t=String(e||""),n=`/${Rr}/`;if(!t.startsWith(n)||t.length===n.length)throw new Error(`Not a gateway API path: ${JSON.stringify(t)} (expected ${JSON.stringify(n)}…).`);const r=t.slice(n.length).split(/[?#]/,1)[0];if(/\\|%2f|%5c/i.test(r))throw new Error(`Not a gateway API path: ${JSON.stringify(t)} (encoded slash or backslash).`);for(const i of r.split("/")){const c=i.replace(/%2e/gi,".");if(c==="."||c==="..")throw new Error(`Not a gateway API path: ${JSON.stringify(t)} (a "." or ".." segment).`)}return t.slice(1)}function N_(e){return!String(e.unavailableReason||"").trim()&&!e.busy}function C_(e){return N_(e)?!e.checked:null}let E_=0;function Mr(e){const{label:t,checked:n,onChange:r,description:i,reasonVisible:c=!0,describedBy:u,hint:d,busy:h=!1,variant:m="inline",ariaLabel:p,className:v,id:_,action:b}=e,C=String(e.unavailableReason||"").trim(),x=!!C,j=u||(_?`${_}-reason`:x?`af-switch-reason-${++E_}`:void 0),N=["af-switch",m==="row"?"af-switch--row":m==="sm"?"af-switch--sm":"",x?"af-switch--unavailable":"",v||""].filter(Boolean).join(" "),$=E=>{const A=C_({checked:n,unavailableReason:C,busy:h});if(A===null){E.preventDefault();return}r==null||r(A)},S=a.jsxs("button",{type:"button",role:"switch",id:_,className:N,"data-action":b,"aria-checked":n?"true":"false","aria-disabled":x?"true":void 0,"aria-describedby":x?j:void 0,"aria-busy":h?"true":void 0,"aria-label":p,"aria-description":i?void 0:d,title:x?d?`${C}
|
|
41
|
+
${d}`:C:d,onClick:$,children:[a.jsx("span",{className:"af-switch__track","aria-hidden":"true",children:a.jsx("span",{className:"af-switch__thumb"})}),a.jsxs("span",{className:"af-switch__text",children:[a.jsx("span",{className:"af-switch__label",children:t}),i?a.jsx("span",{className:"af-switch__desc",children:i}):null]})]});return!x||u?S:a.jsxs("span",{className:m==="row"?"af-switch-wrap af-switch-wrap--row":"af-switch-wrap",children:[S,a.jsx("span",{id:j,className:c?"af-switch__reason":"af-switch__reason af-switch__reason--hidden",children:C})]})}function $_(e){const t=String(e.unavailableReason||"").trim(),n=["af-switch","af-switch--native",e.variant==="row"?"af-switch--row":"",t?"af-switch--unavailable":""].filter(Boolean).join(" "),r=t?`${e.id||e.name}-reason`:void 0,i=a.jsxs("label",{className:n,title:t||void 0,"data-action":e.action,children:[a.jsx("input",{type:"checkbox",role:"switch",className:"af-switch__input",id:e.id,name:e.name,defaultChecked:e.defaultChecked,onChange:c=>{var u;return(u=e.onChange)==null?void 0:u.call(e,c.target.checked)},disabled:!!t,"aria-describedby":r}),a.jsx("span",{className:"af-switch__track","aria-hidden":"true",children:a.jsx("span",{className:"af-switch__thumb"})}),a.jsx("span",{className:"af-switch__text",children:a.jsx("span",{className:"af-switch__label",children:e.label})})]});return t?a.jsxs("span",{className:e.variant==="row"?"af-switch-wrap af-switch-wrap--row":"af-switch-wrap",children:[i,a.jsx("span",{id:r,className:"af-switch__reason",children:t})]}):i}const A_=150,Ef="data-af-tip";function T_(e,t,n,r=6,i=8){let c="top",u=e.top-r-t.height;if(u<i){const m=e.bottom+r;(m+t.height<=n.height-i||n.height-e.bottom>e.top)&&(u=m,c="bottom")}let h=(e.left+e.right)/2-t.width/2;return h=Math.max(i,Math.min(h,n.width-i-t.width)),u=Math.max(i,Math.min(u,n.height-i-t.height)),{top:Math.round(u),left:Math.round(h),side:c}}let lp=0;function Tg(e){return e?String(e.getAttribute(Ef)||"").trim():""}function $d(e,t){const n=e;if(!n||typeof n.closest!="function")return null;const r=n.closest(`[${Ef}]`);return!r||!t.contains(r)||!Tg(r)?null:r}function R_(e,t={}){if(!e)throw new Error("bindAfTooltips: a root (document or element) is required");const n=e.nodeType===9?e:e.ownerDocument,r=n.defaultView||globalThis,i=typeof t.delayMs=="number"&&t.delayMs>=0?t.delayMs:A_;lp+=1;const c=n.createElement("div");c.className="af-tooltip",c.setAttribute("role","tooltip");const u=`af-tooltip-${lp}`;c.setAttribute("id",u),c.hidden=!0,(n.body||n.documentElement).appendChild(c);let d=null,h=null,m=null,p=null,v=!1,_=null;const b=()=>{m&&clearTimeout(m),m=null,h=null},C=()=>{p&&clearTimeout(p),p=null},x=()=>{if(!d)return;const U=d.getBoundingClientRect(),te=c.getBoundingClientRect(),se=T_(U,{width:te.width,height:te.height},{width:r.innerWidth,height:r.innerHeight});c.style.top=`${se.top}px`,c.style.left=`${se.left}px`,c.setAttribute("data-side",se.side)},j=()=>{if(b(),C(),!d)return;String(d.getAttribute("aria-describedby")||"").split(/\s+/).includes(u)&&(_?d.setAttribute("aria-describedby",_):d.removeAttribute("aria-describedby")),_=null,d=null,c.hidden=!0,c.textContent=""},N=U=>{b(),C(),d&&d!==U&&j();const te=Tg(U);if(!te||U.isConnected===!1)return;if(d=U,c.textContent=te,c.hidden=!1,String(U.getAttribute("aria-label")||"").trim()!==te){const G=U.getAttribute("aria-describedby");_=G&&G!==u?G:null,U.setAttribute("aria-describedby",_?`${_} ${u}`:u)}x()},$=U=>{C(),d!==U&&h!==U&&(b(),h=U,m=setTimeout(()=>{const te=h;m=null,h=null,te&&N(te)},i))},S=()=>{b(),d&&(C(),p=setTimeout(j,100))},E=U=>{try{if(typeof U.matches=="function")return U.matches(":focus-visible")}catch{}return v},A=U=>{if(U.pointerType==="touch")return;if(c.contains(U.target)){C();return}const se=$d(U.target,e);se&&$(se)},R=U=>{const se=U.relatedTarget||null;if(!(se&&(c.contains(se)||d&&d.contains(se)||h&&h.contains(se)))){if(h&&!d){b();return}d&&S()}},z=U=>{const te=U.relatedTarget||null;te&&(c.contains(te)||d&&d.contains(te))||S()},L=U=>{const te=$d(U.target,e);te&&E(te)&&$(te)},J=U=>{const te=$d(U.target,e);te&&(te===d||te===h)&&j()},V=()=>{v=!1,j()},O=U=>{if(U.key==="Escape"||U.key==="Esc"){d?(U.preventDefault(),j()):b();return}!U.metaKey&&!U.ctrlKey&&!U.altKey&&(v=!0)},ee=()=>j(),P=e;P.addEventListener("pointerover",A),P.addEventListener("pointerout",R),P.addEventListener("focusin",L),P.addEventListener("focusout",J),c.addEventListener("pointerover",A),c.addEventListener("pointerout",z),n.addEventListener("pointerdown",V,!0),r.addEventListener("keydown",O,!0),r.addEventListener("scroll",ee,!0),r.addEventListener("resize",ee);let Z=!1;return()=>{Z||(Z=!0,j(),P.removeEventListener("pointerover",A),P.removeEventListener("pointerout",R),P.removeEventListener("focusin",L),P.removeEventListener("focusout",J),c.removeEventListener("pointerover",A),c.removeEventListener("pointerout",z),n.removeEventListener("pointerdown",V,!0),r.removeEventListener("keydown",O,!0),r.removeEventListener("scroll",ee,!0),r.removeEventListener("resize",ee),c.parentNode&&c.parentNode.removeChild(c))}}const ac=new WeakMap;function I_(e){let t=ac.get(e);t||(t={count:0,release:R_(e)},ac.set(e,t)),t.count+=1;let n=!1;return()=>{if(n)return;n=!0;const r=ac.get(e);r&&(r.count-=1,r.count<=0&&(r.release(),ac.delete(e)))}}function mo(){y.useEffect(()=>{if(!(typeof document>"u"))return I_(document)},[])}function M_(e){mo();const t=lt.Children.only(e.children),n=String(e.content||"").trim();return n?lt.cloneElement(t,{[Ef]:n}):t}function L_(e){if(!e||typeof e!="object")return;const t=e,n=typeof t.label=="string"?t.label.trim():"";if(!n)return;const r=typeof t.tooltip=="string"&&t.tooltip.trim()?t.tooltip.trim():void 0,i=t.tone==="ok"||t.tone==="warn"||t.tone==="danger"?t.tone:void 0;return{label:n,...r?{tooltip:r}:{},...i?{tone:i}:{}}}const O_={autoApprove:["list_files","skim_folders","analyze_code","read_file","skim_files","search_files","open_attachment","web_search","skim_websearch","skim_url","fetch_url","list_email_accounts","list_emails","read_email","list_whatsapp_messages","read_whatsapp_message","send_email","send_whatsapp_message","send_telegram_message","send_telegram_artifact"],requireApproval:["write_file","edit_file","execute_command"]};function P_(e){const t=new Set,n=[];for(const r of e||[]){if(!r)continue;const i=String(r.name||"").trim();!i||t.has(i)||(t.add(i),n.push({name:i,description:typeof r.description=="string"?r.description:void 0,toolset:typeof r.toolset=="string"?r.toolset:void 0,when_to_use:typeof r.when_to_use=="string"?r.when_to_use:void 0,default_approval:r.default_approval==="approve"||r.default_approval==="ask"?r.default_approval:void 0,state:L_(r.state)}))}return n.sort((r,i)=>{const c=String(r.toolset||""),u=String(i.toolset||"");return c!==u?c.localeCompare(u):r.name.localeCompare(i.name)}),n}function D_(e,t){return e.default_approval?e.default_approval:t.requireApproval.includes(e.name)?"ask":t.autoApprove.includes(e.name)?"approve":"ask"}function F_(e,t,n){const r=String(e||"").trim().toLowerCase();if(!r&&!t&&!n)return null;let i;return r==="approval"||r==="local_approval"||r==="local-approval"?i={label:"APPROVAL",detail:"Safe tools auto-run; mutating tools ask for approval.",tone:"safe"}:r==="passthrough"?i={label:"PASSTHROUGH",detail:"All tools require approval before execution.",tone:"warn"}:r==="delegated"||r==="delegate"||r==="job"?i={label:"DELEGATED",detail:"Tool calls wait for external executors.",tone:"info"}:r==="local"||r==="local_all"||r==="local-all"?i={label:"LOCAL",detail:"All tools run locally; client policy may still require approval.",tone:"danger"}:i={label:"UNKNOWN",detail:"#FALLBACK: gateway tool mode not reported.",tone:"warn"},t&&(i={...i,label:t}),n&&(i={...i,detail:n}),i}function z_(e){const t=e.split("_");return t.map((n,r)=>r<t.length-1?a.jsxs(lt.Fragment,{children:[n,"_",a.jsx("wbr",{})]},r):a.jsx(lt.Fragment,{children:n},r))}function U_(e){var J,V;const t=e.defaults||O_,n=e.disabled===!0,r=e.title||"Tools",i=e.subtitle||"Default is all tools. Safe/read-only tools auto-approve; mutating tools ask for approval.",c=String(e.note||"").trim(),u=y.useMemo(()=>F_(e.toolMode,e.toolModeLabel,e.toolModeDetail),[e.toolMode,e.toolModeLabel,e.toolModeDetail]),d=y.useMemo(()=>P_(e.tools),[e.tools]),h=y.useMemo(()=>d.map(O=>O.name),[d]),m=y.useMemo(()=>new Set(h),[h]),[p,v]=y.useState(""),_=y.useMemo(()=>{var Z;const O=Array.isArray((Z=e.value)==null?void 0:Z.selected)?e.value.selected:[],ee=new Set,P=[];for(const U of O){const te=String(U||"").trim();!te||ee.has(te)||(ee.add(te),P.push(te))}return P},[(J=e.value)==null?void 0:J.selected]),b=y.useMemo(()=>_.filter(O=>m.has(O)),[_,m]),C=y.useMemo(()=>_.filter(O=>!m.has(O)),[_,m]),x=((V=e.value)==null?void 0:V.mode)==="custom"?"custom":"all",j=y.useMemo(()=>{const O=p.trim().toLowerCase();return O?d.filter(ee=>{const P=ee.name.toLowerCase(),Z=(ee.description||"").toLowerCase();return P.includes(O)||Z.includes(O)}):d},[d,p]),N=x==="all"?new Set(h):new Set(b),$=O=>{e.onChange(O)},S=O=>{n||$({...e.value,mode:O,selected:_})},E=(O,ee)=>{if(n)return;const P=new Set(b);ee?P.add(O):P.delete(O),$({...e.value,selected:[...C,...Array.from(P)],mode:"custom"})},A=(O,ee)=>{var Z;if(n)return;const P={...((Z=e.value)==null?void 0:Z.approval)||{}};P[O]=ee,$({...e.value,approval:P})},R=()=>{n||$({...e.value,selected:[...C,...h],mode:"custom"})},z=()=>{n||$({...e.value,selected:[...C],mode:"custom"})},L=N.size;return a.jsxs("div",{className:`af-tool-policy ${e.className||""}`.trim(),children:[a.jsxs("div",{className:"af-tool-policy__header",children:[a.jsx("div",{className:"af-tool-policy__title",children:r}),a.jsx("div",{className:"af-tool-policy__subtitle",children:i}),u?a.jsxs("div",{className:`af-tool-policy__mode is-${u.tone}`,children:[a.jsx("div",{className:"af-tool-policy__mode-badge",children:"Tool mode"}),a.jsx("div",{className:"af-tool-policy__mode-value",children:u.label}),a.jsx("div",{className:"af-tool-policy__mode-detail",children:u.detail})]}):null,c?a.jsx("div",{className:"af-tool-policy__note",children:c}):null]}),a.jsxs("div",{className:"af-tool-policy__controls",children:[a.jsxs("div",{className:"af-tool-policy__segmented",role:"group","aria-label":"Tool allowlist mode",children:[a.jsx("button",{type:"button",className:`af-tool-policy__seg-btn ${x==="all"?"is-active":""}`.trim(),onClick:()=>S("all"),disabled:n,"aria-pressed":x==="all",children:"All tools"}),a.jsx("button",{type:"button",className:`af-tool-policy__seg-btn ${x==="custom"?"is-active":""}`.trim(),onClick:()=>S("custom"),disabled:n,"aria-pressed":x==="custom",children:"Custom allowlist"})]}),a.jsxs("div",{className:"af-tool-policy__count",children:[L," / ",h.length," enabled"]}),a.jsxs("div",{className:"af-tool-policy__bulk",children:[a.jsx("button",{type:"button",onClick:R,disabled:n||x!=="custom",children:"Select all"}),a.jsx("button",{type:"button",onClick:z,disabled:n||x!=="custom",children:"Select none"})]})]}),a.jsx("div",{className:"af-tool-policy__filter",children:a.jsx("input",{type:"text",placeholder:"Filter tools...","aria-label":"Filter tools",value:p,onChange:O=>v(O.target.value),disabled:n})}),a.jsxs("div",{className:"af-tool-policy__list",children:[j.map(O=>{var Z,U;const ee=N.has(O.name),P=((U=(Z=e.value)==null?void 0:Z.approval)==null?void 0:U[O.name])||D_(O,t);return a.jsxs("div",{className:`af-tool-row ${ee?"is-enabled":""}`.trim(),children:[a.jsx("div",{className:"af-tool-row__check",children:a.jsx(Mr,{variant:"sm",action:"tool-enabled",label:"",ariaLabel:O.name,checked:ee,busy:n,unavailableReason:x!=="custom"?"Choose Custom to pick tools one by one.":null,reasonVisible:!1,onChange:te=>E(O.name,te)})}),a.jsxs("div",{className:"af-tool-row__meta",children:[a.jsxs("div",{className:"af-tool-row__title",children:[a.jsx("span",{className:"af-tool-row__name",children:z_(O.name)}),O.toolset?a.jsx("span",{className:"af-tool-row__badge",children:O.toolset}):null]}),O.state?a.jsx("div",{className:"af-tool-row__state-line",children:a.jsx(M_,{content:O.state.tooltip||"",children:a.jsx("span",{className:`af-tool-row__state${O.state.tone?` is-${O.state.tone}`:""}`,"data-tool-state":O.name,tabIndex:O.state.tooltip?0:void 0,"aria-label":O.state.tooltip?`${O.state.label}. ${O.state.tooltip}`:void 0,children:O.state.label})})}):null,O.description?a.jsx("div",{className:"af-tool-row__desc",children:O.description}):null,O.when_to_use?a.jsx("div",{className:"af-tool-row__hint",children:O.when_to_use}):null]}),a.jsx("div",{className:"af-tool-row__approval",children:a.jsxs("select",{value:P,disabled:n||!ee,onChange:te=>A(O.name,te.target.value),"aria-label":`Approval mode for ${O.name}`,children:[a.jsx("option",{value:"approve",children:"Approve"}),a.jsx("option",{value:"ask",children:"Ask"})]})})]},O.name)}),j.length?null:a.jsx("div",{className:"af-tool-policy__empty",children:"No tools match the filter."})]})]})}async function nf(e=Pi){const t=await fetch(e),n=await t.json().catch(()=>null);if(!t.ok){const r=n&&typeof n=="object"&&n.detail?String(n.detail):`HTTP ${t.status}`;throw new Error(r)}return n}async function B_(e,t=Pi){const n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),r=await n.json().catch(()=>null);if(!n.ok){const i=r&&typeof r=="object"&&r.detail?String(r.detail):`HTTP ${n.status}`;throw new Error(i)}return r}async function Rg(e=Pi){const t=await fetch(e,{method:"DELETE"});if(!t.ok){const n=await t.json().catch(()=>({})),r=n&&typeof n=="object"&&n.detail?String(n.detail):`HTTP ${t.status}`;throw new Error(r)}}function Ad(e){let t=String(e||"").trim();for(let n=0;n<2&&t;n+=1){try{const c=JSON.parse(t);if(typeof c=="string"&&c!==t){t=c.trim();continue}}catch{}const r=t[0],i=t[t.length-1];if(r==='"'&&i==='"'||r==="'"&&i==="'"){t=t.slice(1,-1).trim();continue}break}return t.replace(/\/+$/,"")}function W_(e){var c,u;if(!e)return{label:"Signed out",tone:"warn"};if(!e.has_session)return{label:"Signed out",tone:"warn"};const t=e.gateway||{},n=(c=t.principal)==null?void 0:c.user_id,r=(u=t.principal)==null?void 0:u.runtime_id;if(t.ok&&n)return{label:`Signed in as ${n}${r?` · runtime ${r}`:""}`,tone:"ok"};if(t.ok)return{label:"Signed in",tone:"ok"};const i=t.error||t.detail;return typeof i=="string"&&i.trim()?{label:"Session rejected — sign in again",tone:"err"}:{label:"Sign in required",tone:"err"}}function V_(e){const t=e.connectionPath||Pi,[n,r]=y.useState(!1),[i,c]=y.useState(!1),[u,d]=y.useState(null),[h,m]=y.useState(!1);y.useEffect(()=>{e.isOpen||m(!1)},[e.isOpen]);const[p,v]=y.useState(e.defaultGatewayUrl||"http://127.0.0.1:8080"),[_,b]=y.useState("admin"),[C,x]=y.useState(""),[j,N]=y.useState(!1),[$,S]=y.useState(!0),[E,A]=y.useState(""),[R,z]=y.useState(""),L=y.useMemo(()=>W_(u),[u]),J=P=>{var Z;d(P),(Z=e.onStatusChange)==null||Z.call(e,P)},V=y.useRef(!1);if(y.useEffect(()=>{var Z;if(!e.isOpen)return;const P=!V.current;if(V.current=!0,P&&e.initialStatus!==void 0&&e.initialStatus!==null){const U=e.initialStatus;J(U),typeof U.gateway_url=="string"&&U.gateway_url.trim()&&v(Ad(U.gateway_url));const te=(Z=U.gateway)==null?void 0:Z.principal;te!=null&&te.user_id&&b(te.user_id);return}r(!0),A(""),nf(t).then(U=>{var se;J(U),typeof U.gateway_url=="string"&&U.gateway_url.trim()&&v(Ad(U.gateway_url));const te=(se=U.gateway)==null?void 0:se.principal;te!=null&&te.user_id&&b(te.user_id)}).catch(U=>A(`Failed to load connection status: ${String((U==null?void 0:U.message)||U)}`)).finally(()=>r(!1))},[e.isOpen]),y.useEffect(()=>{if(!e.isOpen)return;const P=Z=>{Z.key==="Escape"&&!Z.defaultPrevented&&!e.blocking&&(Z.preventDefault(),e.onClose())};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[e.isOpen,e.blocking,e.onClose]),!e.isOpen||h)return null;const O=async()=>{c(!0),A(""),z("");try{const P=Ad(p);v(P);const Z=await B_({gateway_url:P,gateway_user_id:_,gateway_token:C,persist:$},t);J(Z),x(""),m(!0),e.onClose()}catch(P){A(String((P==null?void 0:P.message)||P))}finally{c(!1)}},ee=async()=>{c(!0),A(""),z("");try{await Rg(t),x("");const P=await nf(t).catch(()=>null);J(P),z("Signed out. This browser no longer holds a gateway session.")}catch(P){A(String((P==null?void 0:P.message)||P))}finally{c(!1)}};return a.jsx("div",{className:"af-connect-overlay",role:"presentation",onMouseDown:P=>{!e.blocking&&P.target===P.currentTarget&&e.onClose()},children:a.jsx("div",{className:"af-connect-modal",role:"dialog","aria-modal":"true","aria-label":"Gateway connection",children:a.jsx(w_,{kicker:`${e.appName||"AbstractFramework"} connection`,title:"Connect this browser to AbstractGateway",description:"Sign in with a Gateway user token. The app exchanges it for an HTTP-only browser session and never stores the raw token.",statusLabel:L.label,statusTone:L.tone,showGatewayUrl:!0,gatewayUrl:p,onGatewayUrlChange:P=>v(P),userId:_,onUserIdChange:b,token:C,tokenPlaceholder:u!=null&&u.has_session?"(browser session already signed in)":"Paste Gateway user token",showToken:j,onTokenChange:x,onShowTokenChange:N,remember:$,rememberLabel:"Keep this browser signed in",onRememberChange:S,loading:n,submitting:i,submittingLabel:"Signing in...",showClose:!e.blocking,onClose:e.onClose,showSignOut:!e.blocking&&!!(u!=null&&u.has_session),onSignOut:ee,error:E,message:R,onSubmit:O})})})}function H_(e){return!!(e&&e.ok===!0&&e.has_session===!0)}function G_(e){const t=e||{},n=t.connectionPath||Pi,r=t.variant||"dismissable",i=y.useRef(t.onStatusChange);i.current=t.onStatusChange;const c=y.useRef(r);c.current=r;const u=y.useRef(!!t.autoOpenMidSession);u.current=!!t.autoOpenMidSession;const[d,h]=y.useState(null),[m,p]=y.useState("loading"),[v,_]=y.useState(!1),b=y.useRef(!1),C=y.useRef(!1),x=y.useRef("loading"),j=y.useRef("none"),N=y.useRef(!1),$=y.useRef(0),S=y.useCallback(Z=>{var te;$.current+=1,h(Z),(te=i.current)==null||te.call(i,Z);const U=H_(Z);if(U)p("connected"),x.current="connected",b.current=!1,j.current="none",C.current||_(!1);else if(Z!==null){const se=x.current;p("disconnected"),x.current="disconnected",se!=="disconnected"&&(j.current=N.current?"signout":se==="connected"?"mid":"boot");const G=c.current==="blocking"||j.current!=="mid"||u.current;!b.current&&G&&_(!0)}Z!==null&&(C.current=U)},[]),E=y.useCallback(async()=>{const Z=$.current;try{const U=await nf(n);if($.current!==Z)return;S(U)}catch{if($.current!==Z)return;S(null)}},[n,S]),[A,R]=y.useState(!1),[z,L]=y.useState(null),J=y.useCallback(async()=>{R(!0),L(null),$.current+=1;let Z=null;try{await Rg(n)}catch(U){Z=String((U==null?void 0:U.message)||U||"Sign-out request failed")}N.current=!0;try{await E()}finally{N.current=!1}L(Z),R(!1)},[n,E]),V=y.useRef(!1);y.useEffect(()=>{V.current||(V.current=!0,E())},[E]);const O=y.useCallback(()=>{_(!0)},[]),ee=y.useCallback(()=>{const Z=x.current;r==="blocking"&&Z==="disconnected"||(Z==="disconnected"&&(b.current=!0),_(!1))},[r]),P=y.useMemo(()=>({isOpen:v,onClose:ee,blocking:r==="blocking"&&m!=="connected",appName:t.appName,connectionPath:n,defaultGatewayUrl:t.defaultGatewayUrl,initialStatus:d,onStatusChange:S}),[v,ee,r,m,t.appName,n,t.defaultGatewayUrl,d,S]);return{status:d,phase:m,connected:m==="connected",modalOpen:v,signingOut:A,signOutError:z,openModal:O,refresh:E,signOut:J,modalProps:P}}function K_(){return globalThis.crypto}function J_(e){if(e.length<16)throw new Error("uuidV4FromBytes: needs 16 bytes");const t=Array.from(e.subarray(0,16));t[6]=t[6]&15|64,t[8]=t[8]&63|128;const n=t.map(r=>r.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function la(){const e=K_();if(e&&typeof e.randomUUID=="function")try{return e.randomUUID()}catch{}if(e&&typeof e.getRandomValues=="function")return J_(e.getRandomValues(new Uint8Array(16)));throw new Error("randomId: Web Crypto (crypto.getRandomValues) is unavailable")}function Dc(e){return globalThis.isSecureContext!==!1?null:`This page is loaded over http, so ${e} is unavailable — open it over https (for example through tailscale serve; the gateway console's Network page explains how) or on the gateway's own computer.`}function Q_(e){const t=e.closeOnEscape!==!1,n=y.useRef(null);return y.useEffect(()=>{if(!e.open||!t)return;const r=i=>{i.key!=="Escape"||i.defaultPrevented||(i.preventDefault(),e.onClose())};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e.open,t,e.onClose]),y.useEffect(()=>{const r=n.current;r&&(e.open?r.removeAttribute("inert"):r.setAttribute("inert",""))},[e.open]),a.jsxs(a.Fragment,{children:[e.backdrop&&e.open?a.jsx("div",{className:"af-drawer-backdrop","aria-hidden":"true",onClick:e.onClose,style:{top:e.topOffset||0}}):null,a.jsxs("div",{ref:n,className:`af-drawer${e.side==="left"?" af-drawer--left":""}${e.topOffset?" af-drawer--offset":""}${e.open?" af-drawer--open":""}${e.className?` ${e.className}`:""}`,style:{width:e.width||420,top:e.topOffset||0,display:e.open?void 0:"none"},role:"complementary","aria-label":e.label,"aria-hidden":e.open?void 0:!0,children:[e.title!==void 0?a.jsxs("div",{className:"af-drawer__header",children:[a.jsx("div",{className:"af-drawer__title",children:e.title}),a.jsxs("div",{className:"af-drawer__header-actions",children:[e.headerActions,a.jsx("button",{type:"button",className:"af-drawer__close","aria-label":"Close panel",onClick:e.onClose,children:"×"})]})]}):null,a.jsx("div",{className:"af-drawer__body",children:e.children})]})]})}const Y_=["a[href]","area[href]","button:not([disabled])",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])","iframe","summary",'[contenteditable="true"]','[tabindex]:not([tabindex="-1"])'].join(", ");function X_(e,t,n,r){if(e.length===0)return null;const i=e[0],c=e[e.length-1];return r?n&&t===i?c:!n&&t===c?i:null:n?c:i}function q_(e){for(let t=e.parentElement;t;t=t.parentElement){if(t.tagName.toUpperCase()!=="DETAILS"||t.hasAttribute("open"))continue;if(!(e.tagName.toUpperCase()==="SUMMARY"&&e.parentElement===t))return!0}return!1}function Td(e){return Array.from(e.querySelectorAll(Y_)).filter(n=>!(typeof n.closest=="function"&&n.closest("[hidden], [inert], [aria-hidden='true']")||q_(n)||typeof n.getClientRects=="function"&&n.getClientRects().length===0))}const cp=new WeakMap;function Z_(e,t){const n=t.document||e.ownerDocument,r=e.querySelector(".af-modal")||e,i=n.activeElement,c=cp.get(n)||[];cp.set(n,c),c.push(e);const u=t.lockScroll!==!1;u&&n.documentElement.classList.add("af-modal-open");const d=()=>{const x=r.querySelector(".af-modal__body"),j=t.initialFocus||r.querySelector("[data-af-autofocus], [autofocus]")||(x?Td(x)[0]:void 0)||Td(r)[0]||r;j===r&&!r.hasAttribute("tabindex")&&r.setAttribute("tabindex","-1"),j.focus({preventScroll:!0})};d();const h=()=>c[c.length-1]===e,m=x=>{if(!h())return;if(x.key==="Escape"||x.key==="Esc"){if(x.defaultPrevented||t.closeOnEscape===!1)return;x.preventDefault(),t.onClose();return}if(x.key!=="Tab")return;const j=Td(r),N=n.activeElement,$=!!N&&r.contains(N);if(j.length===0){x.preventDefault(),r.focus({preventScroll:!0});return}const S=X_(j,N,x.shiftKey,$&&N!==r);S&&(x.preventDefault(),S.focus({preventScroll:!0}))},p=x=>{if(!h())return;const j=x.target;j&&!r.contains(j)&&d()};let v=!1;const _=x=>{v=x.target===e},b=x=>{const j=x.target===e&&v;v=!1,!(!j||!h()||t.closeOnBackdrop===!1)&&t.onClose()};n.addEventListener("keydown",m,!0),n.addEventListener("focusin",p,!0),e.addEventListener("mousedown",_),e.addEventListener("click",b);let C=!1;return()=>{if(C)return;C=!0,n.removeEventListener("keydown",m,!0),n.removeEventListener("focusin",p,!0),e.removeEventListener("mousedown",_),e.removeEventListener("click",b);const x=c.lastIndexOf(e);x>=0&&c.splice(x,1),u&&c.length===0&&n.documentElement.classList.remove("af-modal-open"),i&&typeof i.focus=="function"&&i.isConnected!==!1&&i.focus({preventScroll:!0})}}function eb(e){const t=y.useId().replace(/:/g,""),n=e.id||`af-modal-${t}`,r=y.useRef(null),i=y.useRef(e.onClose);if(i.current=e.onClose,y.useEffect(()=>{if(!(!e.open||!r.current))return Z_(r.current,{onClose:()=>i.current(),closeOnEscape:e.closeOnEscape!==!1,closeOnBackdrop:e.closeOnBackdrop!==!1,initialFocus:e.initialFocusRef?e.initialFocusRef.current:null})},[e.open]),!e.open)return null;const c=a.jsx("div",{className:"af-modal-backdrop",ref:r,children:a.jsxs("div",{className:`af-modal${e.size==="narrow"?" af-modal--narrow":e.size==="wide"?" af-modal--wide":""}${e.className?` ${e.className}`:""}`,id:n,role:"dialog","aria-modal":"true","aria-labelledby":`${n}-title`,"aria-describedby":e.describedBy,children:[a.jsxs("div",{className:"af-modal__header",children:[a.jsx("h2",{className:"af-modal__title",id:`${n}-title`,children:e.title}),a.jsx("button",{type:"button",className:"af-modal__close","aria-label":e.closeLabel||"Close",onClick:()=>i.current(),children:a.jsx("span",{"aria-hidden":"true",children:"×"})})]}),a.jsx("div",{className:"af-modal__body",children:e.children}),e.footer!==void 0||e.footerNote!==void 0?a.jsxs("div",{className:"af-modal__footer",children:[e.footerNote!==void 0?a.jsx("p",{className:"af-modal__footer-note",children:e.footerNote}):null,e.footer]}):null]})});return e.portal!==!1&&typeof document<"u"&&!!document.body?Oc.createPortal(c,document.body):c}function tb(e,t,n,r=4,i=8){let c=e.bottom+r,u=!1;if(c+t.height>n.height-i){const m=e.top-r-t.height;(m>=i||e.top>n.height-e.bottom)&&(c=m,u=!0)}let d=e.left,h=!1;return d+t.width>n.width-i&&(d=e.right-t.width,h=!0),d=Math.max(i,Math.min(d,n.width-i-t.width)),c=Math.max(i,c),{top:Math.round(c),left:Math.round(d),up:u,leftward:h}}let up=0;function nb(e,t,n={}){if(!e||!t)throw new Error("bindAfMenu: button and menu are required");const r=n.document||e.ownerDocument,i=r.defaultView||globalThis;t.getAttribute("id")||(up+=1,t.setAttribute("id",`af-menu-${up}`)),e.setAttribute("aria-haspopup","menu"),e.setAttribute("aria-expanded","false"),e.setAttribute("aria-controls",String(t.getAttribute("id"))),t.setAttribute("role","menu"),t.hidden=!0;const c=()=>{const S=Array.from(t.querySelectorAll(".af-menu__item")),E=S.filter(A=>!A.hidden&&!A.hasAttribute("disabled"));for(const A of S)A.setAttribute("role","menuitem"),A.setAttribute("tabindex","-1");return E};c();let u=!1;const d=()=>{if(!u)return;const S=e.getBoundingClientRect(),E=t.getBoundingClientRect(),A=tb(S,{width:E.width,height:E.height},{width:i.innerWidth,height:i.innerHeight});t.style.top=`${A.top}px`,t.style.left=`${A.left}px`,t.setAttribute("data-placement",`${A.up?"top":"bottom"}-${A.leftward?"end":"start"}`)},h=S=>{const E=c();if(!E.length)return;const A=(S%E.length+E.length)%E.length;E[A].focus({preventScroll:!0})},m=S=>{u||(u=!0,t.hidden=!1,e.setAttribute("aria-expanded","true"),d(),h(S),r.addEventListener("pointerdown",v,!0),r.addEventListener("mousedown",v,!0),i.addEventListener("scroll",d,!0),i.addEventListener("resize",_),i.addEventListener("keydown",x,!0),n.onOpen&&n.onOpen())},p=S=>{u&&(u=!1,t.hidden=!0,e.setAttribute("aria-expanded","false"),r.removeEventListener("pointerdown",v,!0),r.removeEventListener("mousedown",v,!0),i.removeEventListener("scroll",d,!0),i.removeEventListener("resize",_),i.removeEventListener("keydown",x,!0),S&&e.focus({preventScroll:!0}),n.onClose&&n.onClose())};function v(S){const E=S.target;E&&(t.contains(E)||e.contains(E))||p(!1)}function _(){p(!1)}const b=S=>{S.preventDefault(),u?p(!0):m(0)},C=S=>{S.key==="ArrowDown"||(S.key==="Enter"||S.key===" ")&&!u?(S.preventDefault(),m(0)):S.key==="ArrowUp"&&(S.preventDefault(),m(-1))},x=S=>{if(!u||S.key!=="Escape"&&S.key!=="Esc")return;const E=S.target;E&&E!==e&&!t.contains(E)&&E!==r.body||(S.preventDefault(),p(!0))},j=S=>{if(!u)return;const A=c().indexOf(r.activeElement);S.key==="ArrowDown"?(S.preventDefault(),h(A+1)):S.key==="ArrowUp"?(S.preventDefault(),h(A<0?-1:A-1)):S.key==="Home"?(S.preventDefault(),h(0)):S.key==="End"?(S.preventDefault(),h(-1)):S.key==="Tab"&&p(!1)},N=S=>{const E=S.target,A=E&&typeof E.closest=="function"?E.closest(".af-menu__item"):null;if(!A||!t.contains(A))return;const R=r.activeElement,z=!R||R===r.body||t.contains(R);p(z)};e.addEventListener("click",b),e.addEventListener("keydown",C),t.addEventListener("keydown",j),t.addEventListener("click",N);let $=!1;return()=>{$||($=!0,p(!1),e.removeEventListener("click",b),e.removeEventListener("keydown",C),t.removeEventListener("keydown",j),t.removeEventListener("click",N))}}function Ig(e){const t=y.useRef(null),n=y.useRef(null),r=e.items.filter(c=>c&&!c.hidden),i=r.length>0;return y.useEffect(()=>{if(!(!i||!t.current||!n.current))return nb(t.current,n.current)},[i]),i?a.jsxs("div",{className:`af-menu${e.className?` ${e.className}`:""}`,children:[a.jsx("button",{type:"button",ref:t,className:`af-menu__button${e.buttonClassName?` ${e.buttonClassName}`:""}`,"aria-label":e.label,title:e.title,"aria-haspopup":"menu","aria-expanded":"false",children:e.buttonContent!==void 0?e.buttonContent:a.jsx("span",{"aria-hidden":"true",children:"⋯"})}),a.jsx("div",{className:"af-menu__list",role:"menu",ref:n,hidden:!0,children:r.map(c=>a.jsx("button",{type:"button",role:"menuitem",tabIndex:-1,"data-menu-id":c.id,className:`af-menu__item${c.danger?" af-menu__item--danger":""}`,onClick:()=>c.onSelect(),children:c.label},c.id))})]}):null}const sb={name:"AbstractFramework",website:"https://abstractframework.ai",github_org:"https://github.com/lpalbou",author:"Laurent-Philippe Albou, PhD",years:"2023-2026",license:"MIT",copyright:"© 2023-2026 Laurent-Philippe Albou, PhD. Released under the MIT License.",contact_email:"contact@abstractframework.ai"},rb={abstractframework:{name:"AbstractFramework",website:"https://abstractframework.ai",repo:"https://github.com/lpalbou/AbstractFramework",docs:"https://github.com/lpalbou/AbstractFramework/tree/main/docs",issues:"https://github.com/lpalbou/AbstractFramework/issues",feedback:"https://github.com/lpalbou/AbstractFramework/issues/new?labels=feedback"},abstractgateway:{name:"AbstractGateway",website:"https://abstractframework.ai/gateway",repo:"https://github.com/lpalbou/AbstractGateway",docs:"https://www.lpalbou.info/AbstractGateway/",issues:"https://github.com/lpalbou/AbstractGateway/issues",feedback:"https://github.com/lpalbou/AbstractGateway/issues/new?labels=feedback"},abstractcode:{name:"AbstractCode",website:"https://abstractframework.ai/code",repo:"https://github.com/lpalbou/AbstractCode",docs:"https://github.com/lpalbou/AbstractCode/tree/main/docs",issues:"https://github.com/lpalbou/AbstractCode/issues",feedback:"https://github.com/lpalbou/AbstractCode/issues/new?labels=feedback"},abstractassistant:{name:"AbstractAssistant",website:"https://abstractframework.ai/assistant",repo:"https://github.com/lpalbou/AbstractAssistant",docs:"https://github.com/lpalbou/AbstractAssistant/blob/main/docs/README.md",issues:"https://github.com/lpalbou/AbstractAssistant/issues",feedback:"https://github.com/lpalbou/AbstractAssistant/issues/new?labels=feedback"},abstractflow:{name:"AbstractFlow",website:"https://abstractframework.ai/flow",repo:"https://github.com/lpalbou/AbstractFlow",docs:"https://github.com/lpalbou/AbstractFlow#readme",issues:"https://github.com/lpalbou/AbstractFlow/issues",feedback:"https://github.com/lpalbou/AbstractFlow/issues/new?labels=feedback"},abstractcontinuum:{name:"AbstractContinuum",website:"https://abstractframework.ai",repo:"https://github.com/lpalbou/AbstractContinuum",docs:"https://github.com/lpalbou/AbstractContinuum/tree/main/docs",issues:"https://github.com/lpalbou/AbstractContinuum/issues",feedback:"https://github.com/lpalbou/AbstractContinuum/issues/new?labels=feedback"},abstractentity:{name:"AbstractEntity",website:"https://abstractframework.ai",repo:"https://github.com/lpalbou/AbstractEntity",docs:"https://github.com/lpalbou/AbstractEntity/tree/main/docs",issues:"https://github.com/lpalbou/AbstractEntity/issues",feedback:"https://github.com/lpalbou/AbstractEntity/issues/new?labels=feedback"},abstractobserver:{name:"AbstractObserver",website:"https://abstractframework.ai/observer",repo:"https://github.com/lpalbou/AbstractObserver",docs:"https://github.com/lpalbou/AbstractObserver#readme",issues:"https://github.com/lpalbou/AbstractObserver/issues",feedback:"https://github.com/lpalbou/AbstractObserver/issues/new?labels=feedback"},abstractcore:{name:"AbstractCore",website:"https://www.abstractcore.ai",repo:"https://github.com/lpalbou/AbstractCore",docs:"https://github.com/lpalbou/AbstractCore/tree/main/docs",issues:"https://github.com/lpalbou/AbstractCore/issues",feedback:"https://github.com/lpalbou/AbstractCore/issues/new?labels=feedback"},abstractuic:{name:"AbstractUIC",website:"https://abstractframework.ai",repo:"https://github.com/lpalbou/AbstractUIC",docs:"https://github.com/lpalbou/AbstractUIC/tree/main/docs",issues:"https://github.com/lpalbou/AbstractUIC/issues",feedback:"https://github.com/lpalbou/AbstractUIC/issues/new?labels=feedback"}},ab={framework:sb,apps:rb},jc=ab;function Mg(){return{...jc.framework}}function ob(){return Object.keys(jc.apps).sort()}function ib(e,t){const n=Object.prototype.hasOwnProperty.call(jc.apps,e)?jc.apps[e]:void 0;if(!n)throw new Error(`appIdentity: unknown application id "${e}" (known: ${ob().join(", ")})`);return{id:e,name:n.name,version:t,website:n.website,repo:n.repo,docs:n.docs,issues:n.issues,feedback:n.feedback}}function oo(e){return typeof e=="string"?e.trim():""}function dp(e,t){if(t!=null)return{framework:null,gateway:null,gatewayNote:`unavailable (${String(t).trim()||"unknown error"})`};const n=e&&typeof e=="object"&&!Array.isArray(e)?e:{},r=oo(n.abstractgateway),i=oo(n.abstractframework);return{framework:i||null,gateway:r||null,...r&&!i?{frameworkNote:"not installed on the gateway host"}:{},...r?{}:{gatewayNote:"unavailable (the gateway did not report its version)"}}}function lb(e){const t=Mg();return[{id:"website",label:"Website",href:e.website,title:e.website},{id:"source",label:"Source",href:e.repo,title:e.repo},{id:"docs",label:"Docs",href:e.docs,title:e.docs},{id:"issues",label:"Issues",href:e.issues,title:e.issues},{id:"feedback",label:"Feedback",href:e.feedback,title:e.feedback},{id:"contact",label:"Contact",href:`mailto:${t.contact_email}`,title:t.contact_email}]}function cb(e){const t=e||{},n=oo(t.framework),r=oo(t.gateway);return[["AbstractFramework",n||oo(t.frameworkNote)||"not reported"],["AbstractGateway",r||oo(t.gatewayNote)||"not connected"]]}const ub='a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])';function Lg(e,t,n){if(e.key!=="Tab"||!t)return;const r=Array.from(t.querySelectorAll(ub));if(r.length===0){e.preventDefault();return}const i=r[0],c=r[r.length-1],u=!!n&&t.contains(n);e.shiftKey?(n===i||!u)&&(e.preventDefault(),c.focus()):(n===c||!u)&&(e.preventDefault(),i.focus())}function db(e){const t=Mg();return a.jsxs("div",{className:`af-about-card${e.className?` ${e.className}`:""}`,"data-app":e.identity.id,children:[a.jsxs("div",{className:"af-about-card__head",children:[a.jsxs("h2",{className:"af-about-card__name",id:e.titleId,children:[e.identity.name," ",a.jsx("span",{className:"af-about-card__version",children:e.identity.version})]}),e.action]}),a.jsx("dl",{className:"af-about-card__versions",children:cb(e.versions).map(([n,r])=>a.jsxs("div",{className:"af-about-card__fact",children:[a.jsx("dt",{children:n}),a.jsx("dd",{children:r})]},n))}),a.jsx("nav",{className:"af-about-card__links","aria-label":`${e.identity.name} links`,children:lb(e.identity).map(n=>n.href.startsWith("mailto:")?a.jsx("a",{className:"af-about-card__link","data-link":n.id,href:n.href,title:n.title,children:n.label},n.id):a.jsx("a",{className:"af-about-card__link","data-link":n.id,href:n.href,title:n.title,target:"_blank",rel:"noopener noreferrer",children:n.label},n.id))}),a.jsx("p",{className:"af-about-card__legal",children:t.copyright})]})}function fb(e){mo();const t=y.useRef(null),n=y.useRef(null),r=y.useId(),i=y.useRef(e.onClose);return i.current=e.onClose,y.useEffect(()=>{var d;if(!e.open)return;const c=document.activeElement;(d=t.current)==null||d.focus();const u=h=>{if(!h.defaultPrevented){if(h.key==="Escape"){h.preventDefault(),i.current();return}Lg(h,n.current,document.activeElement)}};return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u),c&&typeof c.focus=="function"&&c.focus()}},[e.open]),e.open?a.jsx("div",{className:"af-appearance-overlay af-about-overlay",onClick:e.onClose,role:"presentation",children:a.jsx("div",{ref:n,className:"af-appearance af-about",role:"dialog","aria-modal":"true","aria-labelledby":r,onClick:c=>c.stopPropagation(),children:a.jsx(db,{identity:e.identity,versions:e.versions,titleId:r,action:a.jsx("button",{ref:t,type:"button",className:"af-about-card__close","data-action":"close-about",onClick:e.onClose,"aria-label":"Close","data-af-tip":"Close About",children:a.jsx(ne,{name:"x",size:16})})})})}):null}function hb(e){const{connection:t}=e,n=t.phase,r=t.signingOut===!0,[i,c]=y.useState(!1);mo();const u=e.about,d=r?"Signing out…":n==="connected"?"Disconnect":n==="loading"?"Connecting…":"Connect",h=n==="connected"?"Disconnect from gateway":n==="loading"?"Checking gateway session…":"Connect to gateway";return a.jsxs("div",{className:`af-topbar${e.className?` ${e.className}`:""}`,role:"group","aria-label":"App actions",children:[e.docs?a.jsx("button",{type:"button",className:`af-topbar__btn af-topbar__btn--docs${e.docs.open?" is-active":""}`,"aria-pressed":e.docs.open,"aria-label":e.docs.label||"Docs assistant","data-af-tip":e.docs.label||"Docs assistant",onClick:e.docs.onToggle,children:a.jsx(ne,{name:"book",size:16})}):null,e.assistant?a.jsx("button",{type:"button",className:`af-topbar__btn${e.assistant.open?" is-active":""}`,"aria-pressed":e.assistant.open,"aria-label":e.assistant.label||"Open assistant","data-af-tip":e.assistant.label||"Assistant",onClick:e.assistant.onToggle,children:a.jsx(ne,{name:"sparkle",size:16})}):null,e.appearance?a.jsx("button",{type:"button",className:"af-topbar__btn","aria-label":e.appearance.label||"Appearance (theme and typography)","data-af-tip":e.appearance.label||"Appearance (theme and text size)",onClick:e.appearance.onOpen,children:a.jsx(ne,{name:"contrast",size:16})}):null,u?a.jsx("button",{type:"button",className:"af-topbar__btn af-topbar__btn--about","aria-label":u.label||`About ${u.identity.name}`,"data-af-tip":u.label||`About ${u.identity.name}`,"aria-haspopup":"dialog",onClick:()=>{var m;c(!0),(m=u.onOpen)==null||m.call(u)},children:a.jsx(ne,{name:"info",size:16})}):null,e.extraActions,a.jsxs("button",{type:"button",className:`af-topbar__pill af-topbar__pill--${n}`,onClick:n==="connected"?t.onDisconnect:t.onConnect,disabled:r,title:h,"aria-label":h,children:[a.jsx("span",{className:`af-topbar__dot af-topbar__dot--${n}`,"aria-hidden":"true"}),a.jsx("span",{className:"af-topbar__pill-label",children:d})]}),u?a.jsx(fb,{open:i,onClose:()=>c(!1),identity:u.identity,versions:u.versions}):null]})}const vc={theme:"dark",font_scale:"md",header_density:"standard"};function mb(e){const t=e&&typeof e=="object"?e:{};return{theme:typeof t.theme=="string"&&t.theme?t.theme:vc.theme,font_scale:typeof t.font_scale=="string"&&t.font_scale?t.font_scale:vc.font_scale,header_density:typeof t.header_density=="string"&&t.header_density?t.header_density:vc.header_density}}function pb(e){return`af_appearance_${e}_v1`}function gb(e,t){const n=pb(e),r=y.useMemo(()=>({...vc,...(t==null?void 0:t.defaults)||{}}),[JSON.stringify((t==null?void 0:t.defaults)||{})]),[i,c]=y.useState(()=>{let u=r;try{const d=localStorage.getItem(n)??(t!=null&&t.legacyKey?localStorage.getItem(t.legacyKey):null);d&&(u=mb({...r,...JSON.parse(d)}))}catch{}try{rp(u.theme),ap({font_scale:u.font_scale,header_density:u.header_density})}catch{}return u});return y.useEffect(()=>{rp(i.theme),ap({font_scale:i.font_scale,header_density:i.header_density});try{localStorage.setItem(n,JSON.stringify(i))}catch{}},[n,i]),[i,c]}function yb(e){return y.useEffect(()=>{if(!e.open)return;const t=n=>{n.key!=="Escape"||n.defaultPrevented||(n.preventDefault(),e.onClose())};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e.open,e.onClose]),e.open?a.jsx("div",{className:"af-appearance-overlay",onClick:e.onClose,role:"presentation",children:a.jsxs("div",{className:"af-appearance",role:"dialog","aria-modal":"true","aria-label":e.title||"Appearance",onClick:t=>t.stopPropagation(),children:[a.jsx("div",{className:"af-appearance__title",children:e.title||"Appearance"}),a.jsx("div",{className:"af-appearance__note",children:e.note||"Stored locally in this browser, per app."}),a.jsxs("div",{className:"af-appearance__grid",children:[a.jsx("label",{className:"af-appearance__label",children:"Theme"}),a.jsx(__,{value:e.value.theme,onChange:t=>e.onChange({...e.value,theme:t})}),a.jsx("label",{className:"af-appearance__label",children:"Font size"}),a.jsx(b_,{value:e.value.font_scale,onChange:t=>e.onChange({...e.value,font_scale:t})}),a.jsx("label",{className:"af-appearance__label",children:"Header size"}),a.jsx(x_,{value:e.value.header_density,onChange:t=>e.onChange({...e.value,header_density:t})})]}),a.jsx("div",{className:"af-appearance__actions",children:a.jsx("button",{type:"button",className:"af-appearance__close",onClick:e.onClose,children:"Close"})})]})}):null}function sf(e){return e?[e.provider,e.model].map(t=>String(t||"").trim()).filter(Boolean).join(" / "):""}function fp(e,t,n=!1){if(n)return"unknown";if(!e)return"";const r=e[t];return!r||!r.configured?"not set":sf(r)||"not set"}function wb(e,t){var n;return e.stt_provider?sf({provider:e.stt_provider,model:e.stt_model}):(n=t==null?void 0:t.stt)!=null&&n.configured?sf(t.stt):""}function Og(e,t){return`${Math.max(0,Math.floor((t-e)/1e3))} s`}function vb(e,t,n){return`Transcribing… ${Og(e,t)}${n?` · ${n}`:""}`}const Fc=()=>{var e;return(e=globalThis.navigator)==null?void 0:e.mediaDevices};function rf(e){var i;const t=Dc("the microphone");if(t)return t;const n=String((e==null?void 0:e.name)||"");if(n==="NotAllowedError"||n==="SecurityError"||n==="PermissionDeniedError")return"The browser blocked the microphone. Allow it for this site (the icon left of the address), then try again.";if(n==="NotFoundError"||n==="DevicesNotFoundError")return"No microphone was found. Connect one, then try again.";if(n==="OverconstrainedError")return"The chosen microphone is not connected. Pick another one in Settings → Voice.";if(n==="NotReadableError"||n==="TrackStartError")return"Another app is using the microphone. Close it, then try again.";if(!((i=Fc())!=null&&i.getUserMedia))return"This browser cannot record audio.";const r=String((e==null?void 0:e.message)||e||"").trim();return r?`The microphone did not start: ${r.replace(/\.$/,"")}.`:"The microphone did not start."}async function _b(e){const t=Fc();if(!t||typeof t.enumerateDevices!="function")return{devices:[],labelled:!1};const r=(await t.enumerateDevices()).filter(u=>u.kind===e),i=r.some(u=>!!u.label);return{devices:r.filter(u=>u.deviceId&&u.deviceId!=="default"&&u.deviceId!=="communications").map((u,d)=>({id:String(u.deviceId),label:String(u.label||`${e==="audioinput"?"Microphone":"Speaker"} ${d+1}`)})),labelled:i}}async function bb(){const e=Fc();if(!(e!=null&&e.getUserMedia))throw new Error(Dc("the microphone")||"This browser cannot record audio.");(await e.getUserMedia({audio:!0})).getTracks().forEach(n=>n.stop())}async function Pg(e){const t=Fc();if(!(t!=null&&t.getUserMedia))throw Object.assign(new Error("This browser cannot record audio."),{name:"NotSupportedError"});return t.getUserMedia({audio:e?{deviceId:{exact:e}}:!0})}function zc(){const e=globalThis;return e.AudioContext||e.webkitAudioContext||null}function Dg(){const e=zc();return!!(e&&e.prototype&&typeof e.prototype.createMediaStreamDestination=="function")}function xb(e,t,n=1){const r=zc();if(!r)return()=>{};const i=new r,c=i.createMediaStreamSource(e),u=i.createAnalyser();u.fftSize=1024,c.connect(u);const d=new Float32Array(u.fftSize);let h=!0;const p=setInterval(()=>{if(!h)return;u.getFloatTimeDomainData(d);let v=0;for(let _=0;_<d.length;_+=1)v+=d[_]*d[_];t(Math.min(1,Math.sqrt(v/d.length)*4*n))},50);return()=>{var v;h=!1,clearInterval(p);try{c.disconnect()}catch{}(v=i.close)==null||v.call(i)}}const kb=.02;async function jb(e){var c;const t=globalThis.MediaRecorder;if(typeof t!="function")throw Object.assign(new Error("This browser cannot record audio."),{name:"NotSupportedError"});const n=await Pg(e.deviceId);let r=0;const i=xb(n,u=>{var d;r=Math.max(r,u),(d=e.onLevel)==null||d.call(e,u)},e.gain??1);try{const u=new t(n),d=[],h=new Promise((p,v)=>{u.ondataavailable=_=>(_==null?void 0:_.data)&&d.push(_.data),u.onstop=()=>p(),u.onerror=_=>v((_==null?void 0:_.error)||new Error("Recording failed."))});u.start(),await new Promise(p=>{var _;const v=setTimeout(p,e.ms??3e3);(_=e.signal)==null||_.addEventListener("abort",()=>{clearTimeout(v),p()},{once:!0})}),u.stop(),await h;const m=String(u.mimeType||"audio/webm");return{blob:new Blob(d,{type:m}),peak:r,mime:m}}finally{i(),n.getTracks().forEach(u=>u.stop()),(c=e.onLevel)==null||c.call(e,0)}}async function Sb(e,t={}){var i;const n=zc();if(!n)throw new Error("This browser cannot play audio.");const r=new n;try{t.deviceId&&typeof r.setSinkId=="function"&&await r.setSinkId(t.deviceId);const c=e instanceof Blob?await e.arrayBuffer():e,u=await r.decodeAudioData(c.slice(0)),d=r.createGain();d.gain.value=$f(t.volume),d.connect(r.destination);const h=r.createBufferSource();h.buffer=u,h.connect(d),await new Promise(m=>{h.onended=()=>m(),h.start()})}finally{(i=r.close)==null||i.call(r)}}async function Nb(e={}){var r,i;const t=zc();if(!t)throw new Error("This browser cannot play audio.");const n=new t;try{e.deviceId&&typeof n.setSinkId=="function"&&await n.setSinkId(e.deviceId),n.state==="suspended"&&await((r=n.resume)==null?void 0:r.call(n));const c=n.createGain();c.connect(n.destination);const u=.3*$f(e.volume),d=n.currentTime+.02;[660,880].forEach((h,m)=>{const p=n.createOscillator(),v=n.createGain();p.frequency.value=h,p.connect(v),v.connect(c);const _=d+m*.22;v.gain.setValueAtTime(0,_),v.gain.linearRampToValueAtTime(u,_+.02),v.gain.exponentialRampToValueAtTime(1e-4,_+.2),p.start(_),p.stop(_+.21)}),await new Promise(h=>setTimeout(h,520))}finally{(i=n.close)==null||i.call(n)}}function $f(e){const t=Number(e);return e==null||e===""||!Number.isFinite(t)?1:Math.min(1,Math.max(0,t))}async function*Cb(e){var r,i,c;const t=new AbortController,n=()=>t.abort();(r=e.signal)!=null&&r.aborted?n():(i=e.signal)==null||i.addEventListener("abort",n,{once:!0});try{const u=await fetch(e.path,{method:"POST",headers:{"Content-Type":"application/json",...e.csrfToken?{"x-abstract-csrf":e.csrfToken}:{},...e.headers||{}},body:JSON.stringify(e.body),signal:t.signal});if(!u.ok){const p=await u.json().catch(()=>null),v=p&&typeof p=="object"&&p.detail?String(p.detail):`HTTP ${u.status}`;throw new Error(v)}if(!u.body)throw new Error("TTS stream has no body");const d=u.body.getReader(),h=new TextDecoder;let m="";for(;;){const{done:p,value:v}=await d.read();m+=p?h.decode():h.decode(v,{stream:!0}),p&&m.trim()&&(m+=`
|
|
42
|
+
`);let _;for(;(_=m.indexOf(`
|
|
43
|
+
`))>=0;){const b=m.slice(0,_).trim();if(m=m.slice(_+1),!b)continue;let C=null;try{C=JSON.parse(b)}catch{throw new Error("TTS stream returned invalid JSON.")}if(C&&C.type==="error")throw new Error(String(C.error||"TTS stream error"));const x=C&&typeof C.audio_b64=="string"?C.audio_b64:"";if(x){const j=atob(x),N=new Uint8Array(j.length);for(let $=0;$<j.length;$+=1)N[$]=j.charCodeAt($);yield N.buffer}if(C&&(C.type==="done"||C.type==="cancelled"))return}if(p)throw new Error("TTS stream ended before synthesis completed.")}}finally{(c=e.signal)==null||c.removeEventListener("abort",n),t.abort()}}function ui(e,t){const n=String((t==null?void 0:t.message)||t||"").trim().replace(/\.$/,"");return n?`${e}: ${n}.`:`${e}.`}const Eb=350;function $b(){var t;if(typeof window>"u")return!1;const e=navigator;return!!((t=e==null?void 0:e.mediaDevices)!=null&&t.getUserMedia)&&typeof window.MediaRecorder=="function"}function Ab(){if(typeof window>"u")return!1;const e=window;return!!(e!=null&&e.AudioContext||e!=null&&e.webkitAudioContext)}function Tb(){const e=window.MediaRecorder,t=r=>{var i;try{return!!((i=e==null?void 0:e.isTypeSupported)!=null&&i.call(e,r))}catch{return!1}},n=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus","audio/ogg"];for(const r of n)if(t(r))return r;return""}async function Rd(e,t){var i;const n=t.slice(0),r=(i=e.decodeAudioData)==null?void 0:i.bind(e);if(typeof r!="function")throw new Error("decodeAudioData not available");try{const c=r(n);if(c&&typeof c.then=="function")return await c}catch{}return await new Promise((c,u)=>{try{r(n,c,u)}catch(d){u(d)}})}function Rb(e){const t=new Uint8Array(e);if(t.length<44)return null;const n=c=>String.fromCharCode(t[c],t[c+1],t[c+2],t[c+3]);if(n(0)!=="RIFF"||n(8)!=="WAVE")return null;const r=new DataView(e);let i=12;for(;i+8<=t.length;){const c=n(i),u=r.getUint32(i+4,!0);if(c==="data")return t.slice(0,i+8);i+=8+u+u%2}return null}function Ib(e,t){const n=new Uint8Array(t),r=new Uint8Array(e.length+n.length);r.set(e,0),r.set(n,e.length);const i=new DataView(r.buffer);return i.setUint32(4,r.length-8,!0),i.setUint32(e.length-4,n.length,!0),r.buffer}function Mb(){const e=globalThis,t=e==null?void 0:e.AudioContext;return!!(t&&t.prototype&&typeof t.prototype.setSinkId=="function")}const oc=new WeakMap;function Lb(e,t){const n=e;if(!(typeof n.setSinkId!="function"||oc.get(e)===t)){oc.set(e,t);try{Promise.resolve(n.setSinkId(t)).catch(()=>oc.delete(e))}catch{oc.delete(e)}}}function Ob(e){const t=y.useRef(e);t.current=e;const n=ie=>{var Ae,ge;return(ge=(Ae=t.current).on_error)==null?void 0:ge.call(Ae,ie)},r=y.useMemo(()=>Ab()&&(typeof e.tts=="function"||typeof e.tts_stream=="function"),[e.tts,e.tts_stream]),i=y.useMemo(()=>$b()&&typeof e.transcribe=="function",[e.transcribe]),[c,u]=y.useState({key:"",status:"idle"}),d=y.useRef(c),h=y.useCallback(ie=>{d.current=ie,u(Ae=>Ae.key===ie.key&&Ae.status===ie.status?Ae:ie)},[]),m=y.useRef(""),p=y.useRef(""),v=y.useRef(null),_=y.useRef(null),b=y.useRef(null),C=y.useRef(null),x=y.useRef(0),j=y.useRef(0),N=y.useRef(0),$=y.useRef(null),S=y.useRef([]),E=y.useRef(0),A=y.useRef(!0),R=y.useRef(!1),z=()=>{try{const ie=globalThis,Ae=(ie==null?void 0:ie.AudioContext)||(ie==null?void 0:ie.webkitAudioContext);if(!Ae)return null;if(!v.current){const pe=new Ae,ve=pe.createGain();ve.gain.value=1,ve.connect(pe.destination),v.current=pe,_.current=ve}const ge=v.current,Y=_.current;if(!ge||!Y)return null;Lb(ge,t.current.output_device_id||""),Y.gain.value=$f(t.current.volume);try{ge.state==="suspended"&&ge.resume()}catch{}return{ctx:ge,gain:Y}}catch{return null}},L=y.useCallback(()=>{const ie=b.current;if(b.current=null,!!ie){try{ie.onended=null}catch{}try{ie.stop()}catch{}try{ie.disconnect()}catch{}}},[]),J=y.useCallback(()=>{var ie;L(),N.current+=1,(ie=$.current)==null||ie.abort(),$.current=null,S.current=[],E.current=0,A.current=!0,R.current=!1,p.current="",m.current="",C.current=null,x.current=0,j.current=0,h({key:"",status:"idle"})},[L,h]);y.useEffect(()=>()=>{var ie,Ae;J();try{(ie=_.current)==null||ie.disconnect()}catch{}try{(Ae=v.current)==null||Ae.close()}catch{}v.current=null,_.current=null,C.current=null},[]);const V=async(ie,Ae,ge)=>{const Y=N.current,pe=z();if(!pe)throw new Error("TTS playback is not supported in this browser");const{ctx:ve,gain:Ee}=pe;try{ve.state==="suspended"&&await ve.resume()}catch{}if(Y!==N.current)return;L();const Oe=ve.createBufferSource();Oe.buffer=Ae,Oe.connect(Ee);const Be=Number.isFinite(Number(Ae.duration))?Number(Ae.duration):0,Xe=Math.max(0,Math.min(Number(ge||0),Be>0?Math.max(0,Be-.01):0));j.current=ve.currentTime-Xe,x.current=Xe,b.current=Oe,m.current=ie,Oe.onended=()=>{b.current===Oe&&(b.current=null,x.current=0,j.current=0,m.current="",h({key:"",status:"idle"}))},Oe.start(0,Xe),h({key:ie,status:"playing"})},O=(ie,Ae)=>{if(Ae!==N.current)return;const ge=z();if(!ge)return;const Y=S.current,pe=E.current;if(pe>=Y.length){A.current&&(m.current="",x.current=0,j.current=0,h({key:"",status:"idle"}));return}const ve=Y[pe],{ctx:Ee,gain:Oe}=ge;L();const Be=Ee.createBufferSource();Be.buffer=ve,Be.connect(Oe);const Xe=Number.isFinite(Number(ve.duration))?Number(ve.duration):0,mt=Math.max(0,Math.min(Number(x.current||0),Xe>0?Math.max(0,Xe-.01):0));j.current=Ee.currentTime-mt,b.current=Be,m.current=ie,Be.onended=()=>{Ae===N.current&&b.current===Be&&(b.current=null,E.current=pe+1,x.current=0,O(ie,Ae))};try{Ee.state==="suspended"&&Ee.resume()}catch{}Be.start(0,mt),h({key:ie,status:"playing"})},ee=async(ie,Ae,ge)=>{var Oe;const Y=z();if(!Y){n==null||n("This browser cannot play spoken replies.");return}L();const pe=++N.current;(Oe=$.current)==null||Oe.abort();const ve=new AbortController;$.current=ve,S.current=[],E.current=0,A.current=!1,R.current=!1,C.current=null,x.current=0,j.current=0,m.current=ie,p.current=ie,h({key:ie,status:"loading"}),n==null||n("");let Ee=null;try{for await(const Be of ge(Ae,ve.signal)){if(pe!==N.current)return;let Xe;try{Xe=await Rd(Y.ctx,Be),Ee||(Ee=Rb(Be))}catch{if(!Ee)continue;try{Xe=await Rd(Y.ctx,Ib(Ee,Be))}catch{continue}}if(pe!==N.current)return;S.current.push(Xe),!b.current&&!R.current&&(p.current="",O(ie,pe))}if(pe!==N.current)return;if(A.current=!0,S.current.length===0){n==null||n("Reading aloud failed: the voice engine returned no audio."),J();return}!b.current&&!R.current&&O(ie,pe)}catch(Be){if(pe!==N.current)return;n==null||n(ui("Reading aloud failed",Be)),J()}finally{$.current===ve&&($.current=null)}},P=y.useCallback(async(ie,Ae)=>{var mt;const ge=String(ie||"").trim(),Y=String(Ae||"").trim();if(!ge||!Y)return;const pe=t.current.tts,ve=t.current.tts_stream;if(typeof pe!="function"&&typeof ve!="function"){n==null||n("Reading aloud is not available on this gateway.");return}const Ee=z();if(!Ee){n==null||n("This browser cannot play spoken replies.");return}const Oe=d.current,Be=Oe.key===ge;if(Be&&Oe.status==="playing"){if(b.current){const Tt=Math.max(0,Ee.ctx.currentTime-Number(j.current||0));x.current=Tt}else x.current=0;R.current=!0,L(),h({key:ge,status:"paused"});return}if(Be&&Oe.status==="paused"){if(S.current.length>0){n==null||n(""),R.current=!1,h({key:ge,status:"playing"}),O(ge,N.current);return}const Tt=C.current;if(Tt){n==null||n(""),R.current=!1;try{await V(ge,Tt,x.current)}catch(Es){n==null||n(ui("Reading aloud failed",Es)),h({key:"",status:"idle"})}return}}if(Be&&Oe.status==="loading")return;if(typeof ve=="function"){await ee(ge,Y,ve);return}L(),N.current+=1,(mt=$.current)==null||mt.abort(),$.current=null;const Xe=N.current;S.current=[],E.current=0,A.current=!0,R.current=!1,C.current=null,x.current=0,j.current=0,m.current=ge,p.current=ge,h({key:ge,status:"loading"}),n==null||n("");try{const Tt=await pe(Y);if(p.current!==ge||N.current!==Xe)return;const Es=await Rd(Ee.ctx,Tt);if(p.current!==ge||N.current!==Xe)return;C.current=Es,x.current=0,await V(ge,Es,0)}catch(Tt){if(N.current!==Xe)return;p.current===ge&&(p.current="",m.current="",h({key:"",status:"idle"})),n==null||n(ui("Reading aloud failed",Tt))}},[]),[Z,U]=y.useState(!1),[te,se]=y.useState(!1),G=y.useRef(!1),ce=y.useRef(i);ce.current=i;const re=y.useCallback(ie=>{G.current=ie,U(Ae=>Ae===ie?Ae:ie)},[]),D=y.useRef(!1),I=y.useRef(null),W=y.useRef(null),me=y.useRef([]),q=y.useRef(""),fe=y.useRef(0),de=y.useRef(!1),[ae,we]=y.useState(0),Pe=y.useRef(0),Qe=y.useRef(null);function Ye(){var Ae,ge;try{(ge=(Ae=I.current)==null?void 0:Ae.getTracks)==null||ge.call(Ae).forEach(Y=>{try{Y.stop()}catch{}})}catch{}I.current=null;const ie=Qe.current;Qe.current=null;try{ie==null||ie.close()}catch{}}const Ne=y.useCallback(()=>{fe.current+=1,de.current=!1;const ie=W.current;if(ie){ie.onstop=null,ie.ondataavailable=null,ie.onerror=null;try{ie.stop()}catch{}}W.current=null,Ye(),re(!1),D.current=!1,se(!1),we(0),me.current=[]},[re]);y.useEffect(()=>()=>Ne(),[Ne]);async function He(ie,Ae){var ve,Ee;if(n==null||n(""),D.current)return;const ge=Pe.current?Date.now()-Pe.current:1/0;if(!ie||!ie.size||ge<Eb){we(0),n==null||n("The recording was too short. Hold the microphone button while you speak, or tap it once to start and again to stop.");return}const Y=t.current.transcribe;if(typeof Y!="function"){n==null||n("Speech to text is not available on this gateway.");return}D.current=!0;const pe=fe.current;se(!0),we(Date.now());try{const Oe=await Y(ie,Ae),Be=typeof Oe=="string"||!Oe?{text:String(Oe||"")}:Oe,Xe=String(Be.text||"").trim();if(pe!==fe.current)return;Xe?(Ee=(ve=t.current).on_transcript)==null||Ee.call(ve,Xe,{...Be,text:Xe}):n==null||n("Nothing was heard. Check the microphone in Settings → Voice (Test), then try again.")}catch(Oe){if(pe===fe.current){const Be=String((Oe==null?void 0:Oe.message)||Oe||"").trim().replace(/\.$/,"");n==null||n(Be?`Transcription failed: ${Be}.`:"Transcription failed.")}}finally{pe===fe.current&&(D.current=!1,se(!1),we(0))}}const ue=y.useCallback(async()=>{if(n==null||n(""),!ce.current){n==null||n(Dc("the microphone")??"Voice recording is not supported in this browser (MediaRecorder/getUserMedia unavailable).");return}if(D.current||de.current||G.current||W.current)return;me.current=[];const ie=fe.current;de.current=!0;try{const Ae=await Pg(t.current.input_device_id||"");if(ie!==fe.current){Ae.getTracks().forEach(Ee=>Ee.stop());return}I.current=Ae;const ge=Tb();q.current=ge;let Y=Ae;const pe=Number(t.current.input_gain??1);if(Number.isFinite(pe)&&pe>0&&pe!==1&&Dg()){const Ee=globalThis.AudioContext||globalThis.webkitAudioContext,Oe=new Ee,Be=Oe.createGain();Be.gain.value=pe;const Xe=Oe.createMediaStreamDestination();Oe.createMediaStreamSource(Ae).connect(Be),Be.connect(Xe),Qe.current=Oe,Y=Xe.stream}const ve=ge?new MediaRecorder(Y,{mimeType:ge}):new MediaRecorder(Y);W.current=ve,ve.ondataavailable=Ee=>{if(ie===fe.current)try{Ee!=null&&Ee.data&&me.current.push(Ee.data)}catch{}},ve.onerror=()=>{ie===fe.current&&(n==null||n("Recording failed. Try again, or pick another microphone in Settings → Voice."))},ve.onstop=()=>{if(ie===fe.current){re(!1),Ye(),W.current=null;try{const Ee=new Blob(me.current,{type:q.current||""});He(Ee,q.current)}catch(Ee){n==null||n(ui("The recording could not be prepared",Ee))}}},ve.start(),Pe.current=Date.now(),we(Pe.current),re(!0)}catch(Ae){if(ie!==fe.current)return;Ye(),W.current=null,re(!1),we(0),n==null||n(rf(Ae))}finally{ie===fe.current&&(de.current=!1)}},[]),Ue=y.useCallback(()=>{const ie=W.current;if(!(!G.current||!ie)){re(!1);try{ie.stop()}catch(Ae){n==null||n(ui("The recording could not stop",Ae))}}},[]);return y.useEffect(()=>{if(!Z||t.current.stop_on_pointerup===!1)return;const ie=()=>Ue();return window.addEventListener("pointerup",ie),window.addEventListener("pointercancel",ie),()=>{window.removeEventListener("pointerup",ie),window.removeEventListener("pointercancel",ie)}},[Z]),{tts_supported:r,tts_playback:c,toggle_tts:P,stop_tts:J,voice_ptt_supported:i,voice_ptt_recording:Z,voice_ptt_busy:te,start_voice_ptt_recording:ue,stop_voice_ptt_recording:Ue,cancel_voice_ptt_recording:Ne,voice_ptt_since:ae}}const ic=e=>Array.isArray(e)?e.map(t=>typeof t=="string"?t:(t==null?void 0:t.id)||(t==null?void 0:t.name)).filter(Boolean):[];function Pb({value:e,onChange:t,fetchCatalog:n,intro:r,delivery:i=!0,quality:c=!0,showReset:u=!0,defaultHint:d,voiceDefaultLabel:h}){var R,z,L,J;const m=y.useRef(n);m.current=n;const[p,v]=y.useState({}),[_,b]=y.useState(""),[C,x]=y.useState(!1);y.useEffect(()=>{let V=!0;return x(!0),v({}),b(""),m.current(e.provider,e.model).then(O=>{V&&(v(O),b(O.error?String(O.error):""))}).catch(O=>{V&&b(String((O==null?void 0:O.message)||O))}).finally(()=>{V&&x(!1)}),()=>{V=!1}},[e.provider,e.model]);const j=Array.isArray(p.items)?p.items:[...Array.isArray(p.profiles)?p.profiles.map(V=>({...V,voice_kind:"profile"})):[],...Array.isArray(p.voices)?p.voices.map(V=>({...V,voice_kind:"voice"})):[]],N=V=>JSON.stringify([V.provider||"",V.model||"",V.voice_kind==="profile"?"profile":"voice",V.id]),$=j.find(V=>V.id===(e.profile||e.voice)&&V.voice_kind==="profile"==!!e.profile&&(!e.provider||!V.provider||V.provider===e.provider)&&(!e.model||!V.model||V.model===e.model)),S=$?N($):e.profile||e.voice?JSON.stringify([e.provider||"",e.model||"",e.profile?"profile":"voice",e.profile||e.voice]):"",E=j.filter(V=>(V==null?void 0:V.id)&&(!e.provider||!V.provider||V.provider===e.provider)).map(V=>({value:N(V),label:`${V.label||V.name||V.id}${!e.provider&&V.provider?` · ${V.provider}`:""}`}));S&&!E.some(V=>V.value===S)&&E.unshift({value:S,label:`${e.profile||e.voice} (saved)`});const A=V=>t({...e,...V});return a.jsxs("div",{className:"af-voice-settings",children:[r===void 0?a.jsx("p",{children:"Speech is generated by your authenticated Gateway. Leave routing and voice unset to use its defaults."}):r,a.jsx(Pc,{defaultHint:d,value:{provider:e.provider||"",model:e.model||""},onChange:V=>t({...e,...V,voice:"",profile:""}),fetchProviders:async()=>{const V=await m.current();if(V.error&&!ic(V.tts_providers||V.providers).length)throw new Error(V.error);return ic(V.tts_providers||V.providers).map(O=>({name:O}))},fetchModels:async V=>{var ee;const O=await m.current(V);return ic(((ee=O.tts_models_by_provider)==null?void 0:ee[V])||O.tts_models||O.models)},providerLabel:"Speech provider",modelLabel:"Speech model"}),a.jsxs("label",{children:["Voice / profile",a.jsx(Jn,{ariaLabel:"AI voice",placeholder:h||"Gateway / provider default",value:S,disabled:C,options:[{value:"",label:h||"Gateway / provider default"},...E],onChange:V=>{if(!V){A({voice:"",profile:""});return}const[O,ee,P,Z]=JSON.parse(V);A({provider:O||e.provider||"",model:ee||(O&&O!==e.provider?"":e.model)||"",voice:P==="voice"?Z:"",profile:P==="profile"?Z:""})}})]}),C?a.jsx("p",{role:"status",children:"Loading available voices…"}):null,_?a.jsxs("p",{role:"alert",children:["Voice discovery unavailable: ",_,". Your saved choice is preserved."]}):null,i?a.jsxs(a.Fragment,{children:[a.jsxs("label",{children:["Speaking speed",a.jsxs("select",{"aria-label":"Speech speed",value:e.speed??"",onChange:V=>A({speed:V.target.value?Number(V.target.value):void 0}),children:[a.jsx("option",{value:"",children:"Gateway default"}),[.5,.75,1,1.25,1.5,2].map(V=>a.jsxs("option",{value:V,children:[V,"×"]},V))]})]}),c&&((z=(R=p.controls)==null?void 0:R.quality_preset)!=null&&z.supported)?a.jsxs("label",{children:["Quality",a.jsxs("select",{"aria-label":"Speech quality",value:e.quality_preset||"",onChange:V=>A({quality_preset:V.target.value}),children:[a.jsx("option",{value:"",children:"Gateway default"}),ic(p.controls.quality_preset.values).map(V=>a.jsx("option",{value:V,children:V},V))]})]}):null,(J=(L=p.controls)==null?void 0:L.instructions)!=null&&J.supported?a.jsxs("label",{children:["Delivery instructions",a.jsx("textarea",{"aria-label":"Voice delivery instructions",rows:3,placeholder:"For example: calm, clear, and conversational",value:e.instructions||"",onChange:V=>A({instructions:V.target.value})})]}):null]}):null,u?a.jsx("button",{type:"button",onClick:()=>t({}),children:"Reset to Gateway defaults"}):null]})}const Id=_e("automations"),Db=_e("trigger-sources"),Fb=_e("me/email");class hp extends Error{constructor(t){super(t.message),this.name="AutomationApiError",this.status=t.status,this.code=t.code,t.field!==void 0&&(this.field=t.field),t.command_id!==void 0&&(this.command_id=t.command_id)}}function zb(e,t){const n=t&&typeof t=="object"?t.detail:void 0;if(n&&typeof n=="object"&&!Array.isArray(n)){const r=n;if(typeof r.reason_code=="string"&&r.reason_code&&typeof r.message=="string"){const i={status:e,code:r.reason_code,message:r.message};return typeof r.field=="string"&&(i.field=r.field),typeof r.command_id=="string"&&(i.command_id=r.command_id),i}}return{status:e,code:"invalid_response",message:`The gateway answered HTTP ${e} without an automation error envelope.`}}function Md(e){const t=new URLSearchParams;for(const[r,i]of Object.entries(e))i!==void 0&&t.set(r,String(i));const n=t.toString();return n?`?${n}`:""}function Ub(){return la()}function Bb(e){const t=e.newId??Ub,n=i=>`${Id}/${encodeURIComponent(i)}`;async function r(i,c,u){const d={accept:"application/json",...e.headers?e.headers():{}},h={method:i,headers:d};u!==void 0&&(d["content-type"]="application/json",h.body=JSON.stringify(u));const m=await e.fetch(et(e.baseUrl,c),h),p=await m.text();let v,_=!1;if(p)try{v=JSON.parse(p),_=!0}catch{_=!1}if(!m.ok)throw new hp(zb(m.status,v));if(!_||v===null||typeof v!="object")throw new hp({status:m.status,code:"invalid_response",message:`The gateway answered ${i} ${c} with a body that is not a JSON object.`});return v}return{listAutomations:(i={})=>r("GET",`${Id}${Md({status:i.status,cursor:i.cursor,limit:i.limit})}`),getAutomation:i=>r("GET",n(i)),createAutomation:i=>r("POST",Id,i),reviseAutomation:(i,c)=>r("PATCH",n(i),{command_id:c.command_id??t(),...c.expected_revision!==void 0?{expected_revision:c.expected_revision}:{},changes:c.changes}),sendAutomationCommand:(i,c)=>r("POST",`${n(i)}/commands`,{command_id:c.command_id??t(),type:c.type,...c.payload!==void 0?{payload:c.payload}:{}}),listOccurrences:(i,c={})=>r("GET",`${n(i)}/occurrences${Md({cursor:c.cursor,limit:c.limit})}`),discuss:(i,c)=>r("POST",`${n(i)}/discuss`,{request_id:c.request_id??t(),occurrence_index:c.occurrence_index,prompt:c.prompt}),markSeen:(i,c)=>r("POST",`${n(i)}/seen`,{attention_cursor:c}),listAttention:(i,c={})=>r("GET",`${n(i)}/attention${Md({cursor:c.cursor,limit:c.limit})}`),listTriggerSources:()=>r("GET",Db),getMyEmail:()=>r("GET",Fb)}}function Di(e){const t=e==null?void 0:e._runtime,n=Array.isArray(t==null?void 0:t.allowed_tools)?t.allowed_tools:null,r=Array.isArray(e==null?void 0:e.tools)?e.tools:n;return Array.isArray(r)?r.filter(i=>typeof i=="string"&&(!n||n.includes(i))):null}function Uc(e,t){const n={...e},r=e._runtime&&typeof e._runtime=="object"?{...e._runtime}:{};return t===null?(delete n.tools,delete r.allowed_tools):(n.tools=[...t],r.allowed_tools=[...t]),Object.keys(r).length?n._runtime=r:delete n._runtime,n}function Wb(e){const t=["prompt","tools","provider","model","temperature","seed","max_iterations","max_in_tokens","system","_limits"],n={};for(const i of t)i in e&&(n[i]=e[i]);const r=e._runtime;if(r&&typeof r=="object"){const i={};for(const c of["allowed_tools","provider","model","thinking","speculation","stream"])c in r&&(i[c]=r[c]);Object.keys(i).length&&(n._runtime=i)}return n}function af(e){return e.flow_id==="@default"?"@default":`${"bundle_ref"in e?e.bundle_ref:""}:${e.flow_id}`}const Vb={active:"Active",pause:"Pause",resume:"Resume",run_now:"Run now",stop_current:"Stop current",revise:"Edit",archive:"Archive",unarchive:"Unarchive",discuss:"Discuss"},Hb={active:`On: it runs on its schedule. Off: paused, scheduled runs are skipped.
|
|
44
|
+
Pausing lets a run in progress finish, without further retries; Run now still works and keeps it paused.
|
|
45
|
+
Making it active again restarts the schedule at its next time after now; times missed while paused are skipped.`,pause:`Stop scheduled runs until you resume.
|
|
46
|
+
A run in progress finishes; a pending retry is cancelled. Run now still works.`,resume:`Restart the schedule at its next time after now.
|
|
47
|
+
Times missed while paused are skipped; resuming does not run it now.`,run_now:`Run it once now, without waiting for the schedule.
|
|
48
|
+
The schedule does not move: the next scheduled run keeps its time, or starts right after this run if its time comes first.
|
|
49
|
+
Does not count toward a run limit. Works while paused; it stays paused.
|
|
50
|
+
Not available while a run is in progress.`,stop_current:`Cancel the run in progress, or its pending retry.
|
|
51
|
+
It ends as cancelled, with no failure notice. The schedule continues.`,revise:`Change the task, schedule or settings.
|
|
52
|
+
Changes apply from the next run; a run in progress keeps its inputs. A changed schedule restarts from now, so no past time runs.`,archive:`Stop it for good: it will not run again.
|
|
53
|
+
A run in progress finishes; the history stays readable.`,unarchive:`Bring it back from the archive, paused: nothing runs until you make it active.
|
|
54
|
+
An automation that had already finished or failed keeps that status; its history is unchanged.`,discuss:`Talk about the results in a separate conversation, seeded with the runs up to this one.
|
|
55
|
+
It has its own workspace (the automation's files are read-only) and never changes the automation.`},Gb="Next scheduled run: {time}.",Kb="Growing context: later runs see this run in their history.",Jb={run_now:{name:"playCircle"}},Qb={trigger_label:"When an email arrives",not_set_up:"Connect a mailbox first — open My email",open_my_email:"open My email",filters_legend:"Only mail that matches (all optional)",from_in:"From these addresses",from_domain_in:"From these domains",to_in:"Sent to these addresses",subject_contains:"Subject contains",has_attachment:"Attachments",has_attachment_any:"any",has_attachment_yes:"only with attachments",has_attachment_no:"only without attachments",list_hint:"Separate entries with commas or new lines. Exact addresses and domains only (no patterns).",every_label:"Check for new mail every",interval_rule:"An automation that runs a model on new mail checks once an hour by default; one that needs no model checks every 60 s. The shortest interval is 60 s.",max_batch_label:"At most this many emails per run",max_batch_hint:"The rest wait for the next run. Each email is read once by this automation; mail that arrived before it was created, or while it is paused, is not processed.",untrusted_hint:"Incoming mail is data, never instructions: the automation acts only on its task. Link-opening tools (fetch_url, browser_probe) always ask for your approval.",notify_label:"Email result",notify_hint:"Email each completed run’s result to the selected recipients.",recipients_legend:"Recipients",recipients_self:"Only me (default)",recipients_list:"Me and these addresses",recipients_hint:"Separate multiple addresses with commas."},Fg={labels:Vb,hints:Hb,run_now_next_run_line:Gb,run_now_growing_line:Kb,icons:Jb,email:Qb},Yb=/^([1-9][0-9]*)([smhd])$/,Xb={s:["second","seconds"],m:["minute","minutes"],h:["hour","hours"],d:["day","days"]};function po(e){if(typeof e!="string")return null;const t=Yb.exec(e);return t?{amount:Number(t[1]),unit:t[2]}:null}function zg(e){const t=po(e);if(!t)return`every ${e}`;const[n,r]=Xb[t.unit];return t.amount===1?`every ${n}`:`every ${t.amount} ${r}`}function Ir(e){if(!e)return"";const t=Date.parse(e);if(Number.isNaN(t))return e;const n=new Date(t).toISOString(),r=n.slice(17,19);return`${n.slice(0,10)} ${n.slice(11,16)}${r==="00"?"":`:${r}`} UTC`}function Ug(e){const t=e;if(typeof t.every!="string")return t.start_at?`once at ${Ir(t.start_at)}`:"once, now";const n=[`${zg(t.every)} (UTC)`];return typeof t.count=="number"&&n.push(`${t.count} ${t.count===1?"run":"runs"} max`),typeof t.until=="string"&&n.push(`until ${Ir(t.until)}`),n.join(" · ")}function Bg(e){return e.source_id==="schedule"&&e.source_version===1?Ug(e.config):e.source_id==="manual"&&e.source_version===1?"manual runs only":Fi(e)?Yg(e.config):`${e.source_id}@${e.source_version}`}function Wg(e){return e==="growing"?"Growing — each run sees the previous runs":"Independent — each run starts fresh"}const qb={active:"Active",paused:"Paused",completed:"Completed",failed:"Failed",archived:"Archived"},Ve=Fg.email,Vg="email.received",Hg=1,Zb="1h",ex="60s",Gg=60,Af=100,of=1e3,mp=200,pp=200,gp=50;function Fi(e){return!!e&&e.source_id===Vg&&e.source_version===Hg}function Tf(e){return!!e&&e.effective_enabled===!0}function Kg(e){const t=[];for(const n of String(e??"").split(/[\s,;]+/)){const r=n.trim().toLowerCase();r&&!t.includes(r)&&t.push(r)}return t}const tx=/[\s<>,;:"()[\]]/;function lf(e){const t=e.trim().toLowerCase(),n=t.indexOf("@");return n<=0||n===t.length-1?!1:!t.slice(n+1).includes("@")&&!tx.test(t)}function nx(e){const t=e.trim().toLowerCase();return!!t&&!t.includes("@")&&t.includes(".")&&!t.startsWith(".")&&!t.endsWith(".")&&!/[\s<>,;:"()[\]/*]/.test(t)}const Rf={usesModel:!0,every:null,maxBatch:null,fromIn:"",fromDomainIn:"",toIn:"",subjectContains:"",hasAttachment:"any"};function If(e){return e?Zb:ex}function Jg(e){const t=po(e);return t?t.amount*{s:1,m:60,h:3600,d:86400}[t.unit]:null}function Ld(e,t,n,r,i){const c=Kg(e);if(!c.length)return null;const u=c.filter(d=>!n(d));return u.length&&i.push(`${t}: ${u.join(", ")} ${u.length===1?"is not":"are not"} ${r}.`),c.length>mp&&i.push(`${t}: at most ${mp} entries.`),c}function Qg(e){const t=[],n={uses_model:e.usesModel};e.every===null?n.every=If(e.usesModel):!Number.isInteger(e.every.amount)||e.every.amount<1?t.push("The check interval must be a whole number of at least 1."):n.every=`${e.every.amount}${e.every.unit}`,n.every!==void 0&&(Jg(n.every)??0)<Gg&&t.push("The check interval is at least 60 seconds."),e.maxBatch===null?n.max_batch=Af:!Number.isInteger(e.maxBatch)||e.maxBatch<1||e.maxBatch>of?t.push(`At most this many emails per run: a whole number from 1 to ${of}.`):n.max_batch=e.maxBatch;const r={},i=Ld(e.fromIn,Ve.from_in,lf,"an email address",t);i&&(r.from_in=i);const c=Ld(e.fromDomainIn,Ve.from_domain_in,nx,"a domain like example.com",t);c&&(r.from_domain_in=c);const u=Ld(e.toIn,Ve.to_in,lf,"an email address",t);u&&(r.to_in=u);const d=e.subjectContains.trim();return d&&(d.length>pp||/[\r\n]/.test(d)?t.push(`${Ve.subject_contains}: one line of at most ${pp} characters.`):r.subject_contains=d),e.hasAttachment==="yes"?r.has_attachment=!0:e.hasAttachment==="no"&&(r.has_attachment=!1),Object.keys(r).length&&(n.filter=r),{config:n,errors:t}}function Yg(e){const t=e,n=t.filter??{},r=["when an email arrives"],i=[...n.from_in??[],...n.from_domain_in??[]];i.length&&r.push(`from ${i.join(", ")}`),n.to_in&&n.to_in.length&&r.push(`to ${n.to_in.join(", ")}`),typeof n.subject_contains=="string"&&n.subject_contains&&r.push(`subject contains “${n.subject_contains}”`),n.has_attachment===!0&&r.push("with attachments"),n.has_attachment===!1&&r.push("without attachments");const c=typeof t.every=="string"?t.every:If(t.uses_model!==!1);r.push(`checked ${zg(c)}`);const u=typeof t.max_batch=="number"?t.max_batch:Af;return r.push(`up to ${u} per run`),r.join(" · ")}const Ai={mode:"self",addresses:""};function cf(e){if(e.mode==="self")return{recipients:["self"],errors:[]};const t=[],n=Kg(e.addresses).filter(i=>i!=="self");n.length||t.push("Name at least one address the automation may email, or choose Only me.");const r=n.filter(i=>!lf(i));return r.length&&t.push(`${Ve.recipients_list}: ${r.join(", ")} ${r.length===1?"is not an email address":"are not email addresses"}.`),n.length+1>gp&&t.push(`At most ${gp-1} addresses.`),{recipients:["self",...n],errors:t}}function sx(e){const t=(e??[]).filter(n=>n!=="self");return t.length?{mode:"list",addresses:t.join(", ")}:{mode:"self",addresses:""}}function rx(e){const t=(e??["self"]).filter(n=>n!=="self");return t.length?`Me and ${t.join(", ")}`:"Only me"}function Xg(e,t=["self"]){return{channels:e?["console","email"]:["console"],...t.some(n=>n!=="self")?{recipients:t}:{}}}function qg(e){return!!e&&Array.isArray(e.channels)&&e.channels.includes("email")}function ax(e){return qg(e)?"In the console and by email":"In the console"}const _t={pause:"automation.pause",resume:"automation.resume",run_now:"automation.run_now",stop_current:"automation.stop_current",archive:"automation.archive",unarchive:"automation.unarchive"},ox=new Set(["running","waiting","backoff"]);function ix(e,t=[]){return e.current_occurrence!=null}function lx(e){const t=e.current_occurrence;if(!t)return null;const n=t.attempt>1?` (attempt ${t.attempt})`:"";return t.status==="backoff"?`Run #${t.index} waiting to retry (attempt ${t.attempt+1})`:t.status==="admitted"?`Run #${t.index} starting${n}`:`Run #${t.index} running${n}`}function cx(e,t){const n=Date.parse(e);if(Number.isNaN(n))return"";const r=Math.round((n-t)/6e4);if(r<=0)return"due now";if(r<60)return`in ${r} min`;const i=Math.floor(r/60);return i<24?`in ${i} h${r%60?` ${r%60} min`:""}`:`in ${Math.floor(i/24)} d${i%24?` ${i%24} h`:""}`}function uo(e,t=[],n=!1){const r=new Set(e.capabilities),i=e.status,c=ix(e,t),u=(p,v,_)=>n?{enabled:!1,reason:"Working…"}:e.legacy?{enabled:!1,reason:"Legacy schedule: managed with its existing controls."}:r.has(p)?i==="archived"?{enabled:!1,reason:"Archived: history is kept, nothing runs."}:v?{enabled:!0}:{enabled:!1,reason:_}:{enabled:!1,reason:"Not permitted for this automation."},d=i==="active"||i==="paused",h=i==="active"?"pause":"resume";return{active:n?{enabled:!1,reason:"Working…"}:e.legacy?{enabled:!1,reason:"Legacy schedule: managed with its existing controls."}:i==="archived"?{enabled:!1,reason:"Archived: history is kept, nothing runs."}:d?r.has(h)?{enabled:!0}:{enabled:!1,reason:"Not permitted for this automation."}:{enabled:!1,reason:"The automation has ended."},pause:u("pause",i==="active",i==="paused"?"Already paused.":"The automation has ended."),resume:u("resume",i==="paused",i==="active"?"Already running on schedule.":"The automation has ended."),run_now:u("run_now",d&&!c,c?"An occurrence is in progress.":"The automation has ended."),stop_current:u("stop_current",c,"Nothing is running."),revise:u("revise",!0,""),archive:u("archive",!0,""),unarchive:n?{enabled:!1,reason:"Working…"}:e.legacy?{enabled:!1,reason:"Legacy schedule: managed with its existing controls."}:i!=="archived"?{enabled:!1,reason:"Not archived."}:r.has("unarchive")?{enabled:!0}:{enabled:!1,reason:"Not permitted for this automation."},discuss:n?{enabled:!1,reason:"Working…"}:e.legacy?{enabled:!1,reason:"Legacy schedule: discussion is not available."}:r.has("discuss")?{enabled:!0}:{enabled:!1,reason:"Discussion is not permitted for this automation."}}}function Zg(e){return e.status==="active"?_t.pause:_t.resume}function ux(e){return e.status==="failed"?"failed":e.waits.length>0||e.status==="waiting"?"waiting":e.notify!==null?"notified":e.status==="running"||e.status==="backoff"?"running":"quiet"}function dx(e){return[...e].sort((t,n)=>t.index-n.index).map(t=>{const n=ux(t),r=`${t.attempts} ${t.attempts===1?"attempt":"attempts"}`,i=n==="failed"?`Failed after ${r}`:n==="waiting"?"Waiting for you":n==="notified"?"Notified":n==="running"?"Running":null,c=t.status==="completed"&&t.attempts>1?`completed after ${r}`:t.status;return{row:t,tone:n,notable:n==="failed"||n==="waiting"||n==="notified",badge:i,statusText:c,canDiscuss:!ox.has(t.status)}})}function fx(e){const t=e.attention.items;return t.length?t[t.length-1].cursor:null}function hx(e){const t=e.attention,n=[];return t.unseen_count>0&&n.push(`${t.unseen_count} unseen`),t.pending_waits>0&&n.push(`${t.pending_waits} waiting for you`),n.length?n.join(" · "):"nothing new"}const mx={unauthorized:"Sign in to the gateway to manage automations.",forbidden:"You are not allowed to do this with automations.",automation_not_found:"This automation does not exist (or is not yours).",occurrence_not_found:"That occurrence does not exist.",revision_conflict:"The automation changed since this view loaded. Reload it, then try again.",automation_busy:"An occurrence is already running or queued. Wait for it to finish.",invalid_state:"The automation's current state does not allow this.",identity_conflict:"This request id was already used for a different request.",invalid_request:"The gateway rejected the request as malformed.",invalid_definition:"The automation definition is not valid.",unsupported_feature:"The gateway does not support this yet.",unknown_trigger_source:"The gateway does not know this trigger source.",invalid_response:"The gateway gave an unexpected answer.",invalid_payload:"That answer could not be sent."};function go(e){return{title:mx[e.code]??`The gateway refused the request (${e.code}).`,detail:e.message}}function zi(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.status=="number"&&typeof t.code=="string"&&typeof t.message=="string"}function ey(e,t){var c,u,d;const n=e.trigger,r=n.source_id==="schedule"||Fi(n)?n.config.every:void 0,i=t?t.target.input_data.prompt:void 0;return{title:e.title,every:typeof r=="string"?r:null,context:e.context_mode,growingMaxTokens:Number(((u=(c=t==null?void 0:t.context)==null?void 0:c.growing)==null?void 0:u.max_tokens)??e.growing_max_tokens??Li),prompt:typeof i=="string"?i:null,toolApproval:t?t.policy.tool_approval:null,tools:Di(t==null?void 0:t.target.input_data),notifyEmail:t?qg(t.notify):null,emailRecipients:t?sx((d=t.notify)==null?void 0:d.recipients):null}}function ty(e,t,n){var h;const r=[],i={},c=t.title.trim();c?c.length>120?r.push("Title is at most 120 characters."):c!==e.title&&(i.title=c):r.push("Title is required.");const u=ey(e,n);if(t.every!==u.every&&t.every!==null){const m=Fi(e.trigger);if(!po(t.every))r.push("Interval must be a whole number of minutes, hours or days.");else if(m&&(Jg(t.every)??0)<Gg)r.push("The check interval is at least 60 seconds.");else{const p={...e.trigger.config,every:t.every};m&&delete p.start_at,i.trigger={source_id:e.trigger.source_id,source_version:e.trigger.source_version,config:p}}}const d=t.context==="growing"?t.growingMaxTokens??u.growingMaxTokens:u.growingMaxTokens;if(ry(d)||r.push(sy),(t.context!==e.context_mode||d!==u.growingMaxTokens)&&(i.context=ay(t.context,d)),n&&typeof u.prompt=="string"&&typeof t.prompt=="string"&&t.prompt.trim()!==u.prompt.trim()){const m=t.prompt.trim();m?i.target={bundle_ref:n.target.bundle_ref,flow_id:n.target.flow_id,input_data:{...n.target.input_data,prompt:m}}:r.push("Task is required.")}if(n&&t.tools!==void 0&&JSON.stringify(t.tools)!==JSON.stringify(u.tools)){const m=i.target||{bundle_ref:n.target.bundle_ref,flow_id:n.target.flow_id,input_data:n.target.input_data};i.target={...m,input_data:Uc(m.input_data||{},t.tools)}}if(n&&t.toolApproval&&t.toolApproval!==u.toolApproval&&(i.policy={tool_approval:t.toolApproval}),n&&typeof t.notifyEmail=="boolean"){const m=cf(t.notifyEmail?t.emailRecipients??Ai:u.emailRecipients??Ai),p=cf(u.emailRecipients??Ai).recipients;m.errors.length?r.push(...m.errors):(t.notifyEmail!==u.notifyEmail||JSON.stringify(m.recipients)!==JSON.stringify(p))&&(i.notify=Xg(t.notifyEmail,m.recipients))}if(r.length)return{errors:r};if(n&&t.target&&af(t.target)!==af(n.target)){const m=((h=i.target)==null?void 0:h.input_data)||n.target.input_data;i.target={...t.target,input_data:Wb(m)}}return Object.keys(i).length?i:null}const Li=5e4,ny="Limits history carried into the next run, keeping recent whole turns. The newest turn is kept even if oversized. New messages and tool results can grow context beyond this budget.",sy="Max growing context must be a positive whole number of tokens.";function ry(e){return Number.isSafeInteger(e)&&e>0}function ay(e,t){return{mode:e,...t!==Li?{growing:{max_tokens:t}}:{}}}const px=[{label:"every 5 minutes",when:{kind:"every",amount:5,unit:"m"}},{label:"every 30 minutes",when:{kind:"every",amount:30,unit:"m"}},{label:"every hour",when:{kind:"every",amount:1,unit:"h"}},{label:"every 8 hours",when:{kind:"every",amount:8,unit:"h"}},{label:"every 24 hours",when:{kind:"every",amount:24,unit:"h"}},{label:"every 7 days",when:{kind:"every",amount:7,unit:"d"}}];function Od(e){if(!e)return null;const t=/^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})(:\d{2})?$/.exec(e.trim());if(!t)return null;const n=`${t[1]}T${t[2]}${t[3]??":00"}Z`;return Number.isNaN(Date.parse(n))?null:n}function gx(e){const t=e.trim().split(`
|
|
56
|
+
`)[0].trim();return t.length>120?`${t.slice(0,119)}…`:t}function oy(e){const t=[],n={};if(e.when.kind==="once"){const i=Od(e.when.at);return i?n.start_at=i:t.push("Pick the date and time (UTC) to run once."),{config:n,errors:t}}const r=e.when.amount;if(!Number.isInteger(r)||r<1?t.push("The interval must be a whole number of at least 1."):n.every=`${r}${e.when.unit}`,e.startAt){const i=Od(e.startAt);i?n.start_at=i:t.push("First run must be a date and time (UTC).")}if(e.count!==void 0&&(!Number.isInteger(e.count)||e.count<1?t.push("Maximum runs must be a whole number of at least 1."):n.count=e.count),e.until){const i=Od(e.until);i?n.until=i:t.push("Stop at must be a date and time (UTC).")}return{config:n,errors:t}}function yx(e){if(e.trigger==="email"){const i=Qg(e.email??Rf);return i.errors.length?"":Yg(i.config)}const{config:t,errors:n}=oy(e);if(n.length)return"";const r=Ug(t);return e.when.kind==="once"?r:`${r}, first run ${t.start_at?`at ${Ir(t.start_at)}`:"now"}`}function wx(e,t){const n=[];t.target||n.push("Choose what to run.");const r=e.prompt.trim();r||n.push("Write the task to run.");const i=(e.title??"").trim()||gx(r);i.length>120&&n.push("Title is at most 120 characters.");const c=e.trigger==="email",u=c?Qg(e.email??Rf):oy(e);n.push(...u.errors);const d=e.notifyEmail&&e.emailRecipients&&e.emailRecipients.mode==="list"?cf(e.emailRecipients):null;d&&n.push(...d.errors);const h=e.growingMaxTokens??Li;if(e.context==="growing"&&!ry(h)&&n.push(sy),n.length||!t.target)return{ok:!1,errors:n};const m={...t.target,input_data:{...t.target.input_data??{},prompt:r}},p={request_id:t.requestId,title:i,target:m,trigger:c?{source_id:Vg,source_version:Hg,config:u.config}:{source_id:"schedule",source_version:1,config:u.config},context:ay(e.context,e.context==="growing"?h:Li),policy:{tool_approval:e.toolApproval??"auto"}};return e.notifyEmail===!0&&(p.notify=Xg(!0,d==null?void 0:d.recipients)),{ok:!0,body:p}}const vx="Tools run without asking (you approve them now by creating this automation)";function _x(e){if(e.kind!=="tool_approval"||!Array.isArray(e.details))return null;const t=[];for(const n of e.details){if(!n||typeof n!="object"||Array.isArray(n))return null;const r=n;if(typeof r.name!="string"||!r.arguments||typeof r.arguments!="object"||Array.isArray(r.arguments)||r.call_id!==void 0&&typeof r.call_id!="string")return null;t.push({name:r.name,arguments:r.arguments,...typeof r.call_id=="string"?{call_id:r.call_id}:{}})}return t}function bx(e){const t=e.trim();if(!t)return{ok:!1,error:"Enter a JSON payload."};try{return{ok:!0,payload:JSON.parse(t)}}catch(n){return{ok:!1,error:`The payload is not valid JSON (${n instanceof Error?n.message:String(n)}).`}}}const iy={ask_user:"Question for you",tool_approval:"Approval needed",event:"Waiting for an event"};class ly{constructor(t){this.mint=t,this.open=new Map}idFor(t){let n=this.open.get(t);return n===void 0&&(n=this.mint(),this.open.set(t,n)),n}settle(t,n){(n.ok||xx(n.error))&&this.open.delete(t)}}function xx(e){return zi(e)&&e.status>0&&e.code!=="invalid_response"}function cy(){return la()}class kx{constructor(){this.acked=null,this.inflight=null,this.failedKey=null,this.failedToken=void 0}next(t,n){return!t||t===this.acked||t===this.inflight||t===this.failedKey&&n===this.failedToken?null:(this.inflight=t,t)}succeeded(t){this.inflight===t&&(this.inflight=null),this.acked=t,this.failedKey=null}failed(t,n){this.inflight===t&&(this.inflight=null),this.failedKey=t,this.failedToken=n}get acknowledged(){return this.acked}}function yp(e,t){if(!e)return null;for(const n of t){const r=e.querySelector(n);if(r&&r.disabled!==!0&&typeof r.focus=="function")return r}return null}function wp(e){const t=Array.from(new Set(e.map(n=>String(n||"").trim()).filter(Boolean)));return t.sort((n,r)=>n.localeCompare(r)),t}function jx(e){const t=e.disabled===!0,n=y.useMemo(()=>wp([...e.options||[],...e.value||[]]),[e.options,e.value]),r=y.useMemo(()=>wp(e.value||[]),[e.value]),[i,c]=y.useState(!1),[u,d]=y.useState(""),h=y.useMemo(()=>{const v=u.trim().toLowerCase();return v?n.filter(_=>_.toLowerCase().includes(v)):n},[n,u]),m=y.useMemo(()=>new Set(r),[r]),p=typeof e.max_list_height_px=="number"?e.max_list_height_px:220;return a.jsxs("div",{className:"af_multi_select",children:[a.jsxs("div",{className:"af_multi_select_row",children:[a.jsxs("button",{className:"btn",type:"button",onClick:()=>c(v=>!v),disabled:t||!n.length,"aria-expanded":i,children:[i?"Hide":"Select"," • ",r.length>0?`${r.length} of ${n.length}`:e.placeholder||"(none)"]}),a.jsx("button",{className:"btn",type:"button",onClick:()=>e.onChange(n.slice()),disabled:t||!n.length||r.length===n.length,title:"Select all",children:"All"}),a.jsx("button",{className:"btn",type:"button",onClick:()=>e.onChange([]),disabled:t||r.length===0,title:"Clear selection",children:"Clear"})]}),r.length>0?a.jsx("div",{className:"af_multi_select_chips",children:r.map(v=>a.jsxs("button",{type:"button",disabled:t,"aria-label":`Remove ${v}`,className:"af_multi_select_chip",title:v,onClick:()=>{if(t)return;const _=new Set(m);_.delete(v),e.onChange(Array.from(_.values()))},children:[v,t?null:a.jsx("span",{className:"af_multi_select_chip_x",children:"×"})]},v))}):null,i?a.jsxs("div",{className:"af_multi_select_panel",children:[a.jsx("input",{className:"mono",value:u,onChange:v=>d(String(v.target.value||"")),placeholder:"filter…","aria-label":"Filter options",disabled:t}),a.jsxs("div",{className:"af_multi_select_list",style:{maxHeight:`${p}px`},children:[h.map(v=>{const _=m.has(v);return a.jsxs("label",{className:`af_multi_select_item mono ${_?"checked":""}`,children:[a.jsx("input",{type:"checkbox",checked:_,disabled:t,onChange:b=>{const C=new Set(m);b.target.checked?C.add(v):C.delete(v),e.onChange(Array.from(C.values()))}}),a.jsx("span",{children:v})]},v)}),h.length?null:a.jsx("div",{className:"mono muted",children:"(no matches)"})]})]}):null]})}function uy(e){return a.jsxs("div",{className:"af-auto__field","data-field":"tool-selection",children:[a.jsxs("label",{children:[a.jsx("input",{type:"checkbox",checked:e.value===null,disabled:e.disabled,onChange:t=>e.onChange(t.target.checked?null:[])})," Use workflow default tools"]}),e.value!==null?a.jsx(jx,{options:e.availableTools,value:e.value,disabled:e.disabled,placeholder:"No tools enabled",onChange:e.onChange}):null,a.jsx("p",{className:"af-auto__hint",children:"Choose which tools this automation can use. An empty selection disables tools. Gateway restrictions always apply."})]})}const Bc="@default",dy="No workflows available for this app — ask your admin.",fy={shared:"Shared",mine:"Mine"};class jr extends Error{constructor(t){super(t),this.name="WorkflowPickerContractError"}}function hy(e,t={}){const n=String(e||"").trim();if(!n)throw new Error("executableWorkflowsPath needs the interface the app runs (e.g. abstractcode.agent.v1).");return`bundles?executable_for=${encodeURIComponent(n)}${t.allVersions?"&all_versions=true":""}`}function Sx(e={}){return e.allVersions?"bundles?all_versions=true":"bundles"}function Nx(e,t={}){return e===null?Sx(t):hy(e,t)}function Qs(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function Ut(e){return typeof e=="string"?e.trim():""}const lc="update the gateway";function Cx(e,t){var d,h;const n=Qs(e.default_agent_workflows);if(!n)return{status:"unavailable",reason:"the gateway does not report a default workflow"};const r=Qs(n[t]);if(!r)return{status:"unavailable",reason:Ut((h=Qs((d=Qs(e.default_agent_workflows_unavailable))==null?void 0:d[t]))==null?void 0:h.reason)||`no default workflow for ${t}`};const i=Ut(r.bundle_id),c=Ut(r.flow_id);if(!i||!c)return{status:"unavailable",reason:"the gateway's default workflow is missing its bundle or flow"};const u=Ut(r.bundle_version);return{status:"ok",name:Ut(r.name)||c,bundleId:i,bundleVersion:u,flowId:c,workflowId:Ut(r.workflow_id)||`${i}${u?`@${u}`:""}:${c}`}}function Ex(e,t){return my(e,t)}function my(e,t,n={}){var d;const r=Qs(e);if(!r)throw new jr("The gateway's workflow list is not a JSON object.");const i=Ut(r.executable_for);if(t===null){if(i)throw new jr(`Asked for every workflow, the gateway listed only ${i}.`)}else if(i!==t)throw new jr(i?`The gateway listed workflows for ${i}, not ${t}.`:`This gateway does not filter workflows per app (no executable_for in its answer): ${lc}.`);if(!Array.isArray(r.items))throw new jr("The gateway's workflow list has no items.");const c=[];for(const h of r.items){const m=Qs(h),p=Ut(m==null?void 0:m.bundle_id);if(!m||!p)throw new jr("The gateway listed a workflow without a bundle id.");const v=Qs(m.owner),_=Ut(v==null?void 0:v.kind);if(_!=="gateway"&&_!=="user")throw new jr(`The gateway did not say who owns ${p} (owner missing): ${lc}.`);if(typeof m.shipped!="boolean")throw new jr(`The gateway did not say whether ${p} ships with it (shipped missing): ${lc}.`);const b=Ut(m.bundle_version),C=Array.isArray(m.entrypoints)?m.entrypoints:[];for(const x of C){const j=Qs(x),N=Ut(j==null?void 0:j.flow_id);if(!j||!N)continue;const $=Array.isArray(j.interfaces)?j.interfaces.map(Ut).filter(Boolean):[];if(t===null){if(!$.length)continue}else if(!$.includes(t))throw new jr(`The gateway offered ${p}:${N}, which does not declare ${t}: ${lc}.`);c.push({value:Ut(j.workflow_id)||`${p}${b?`@${b}`:""}:${N}`,bundleId:p,bundleVersion:b,flowId:N,name:Ut(j.name)||Ut((d=Qs(m.metadata))==null?void 0:d.name)||p,description:Ut(j.description)||Ut(m.description),registryScope:Ut(m.registry_scope)||"private",group:_==="user"?"mine":"shared",shipped:m.shipped,interfaces:$,...t===null?{showInterfaces:!0}:{}})}}const u=n.defaultInterface??t;return{interfaceId:t,entries:c,gatewayDefault:u?Cx(r,u):{status:"unavailable",reason:"no interface named for the gateway default"}}}function $x(e){const t=(n,r)=>n.name.localeCompare(r.name)||r.bundleVersion.localeCompare(n.bundleVersion,void 0,{numeric:!0})||n.value.localeCompare(r.value);return["shared","mine"].map(n=>({id:n,label:fy[n],entries:e.filter(r=>r.group===n).sort(t)})).filter(n=>n.entries.length>0)}const Ax={"abstractcode.agent.v1":"Code agent","abstractassistant.agent.v1":"Assistant","abstractcode.coding.v1":"Coding",tools:"tools",event:"event",chat:"chat"};function Tx(e){return Ax[e]??e}function Rx(e,t=[]){const n=e.bundleVersion?`@${e.bundleVersion}`:"";return e.showInterfaces?[[...new Set(e.interfaces.map(Tx))].join(", "),n].filter(Boolean).join(" · "):n}function Ix(e){return e.value}function Mx(e){return e?e.status==="unavailable"?e.reason:`${e.name}${e.bundleVersion?` @${e.bundleVersion}`:""}`:""}function Lx(e,t,n){return n<=0?null:e==="ArrowDown"?t<0?0:Math.min(n-1,t+1):e==="ArrowUp"?t<0?n-1:Math.max(0,t-1):e==="Home"?0:e==="End"?n-1:null}function Ox(e,t=!0){const n=(e==null?void 0:e.entries)??[],r=[];t&&r.push({key:"default",value:Bc,name:"Gateway default",detail:Mx((e==null?void 0:e.gatewayDefault)??null),group:null,entry:null});for(const i of $x(n))for(const c of i.entries)r.push({key:c.value,value:c.value,name:c.name,detail:Rx(c,n),title:Ix(c),group:i.id,entry:c});return r}async function Px(e,t,n){var c;const r=await fetch(et(e,_e(t)),{credentials:"include",headers:{Accept:"application/json"},signal:n}),i=await r.json().catch(()=>null);if(!r.ok){const u=((c=i==null?void 0:i.detail)==null?void 0:c.message)||(i==null?void 0:i.message)||(typeof(i==null?void 0:i.detail)=="string"?i.detail:"");throw new Error(u||`The gateway answered ${r.status}.`)}return i}function Dx(e){var n;const t=e;return String(((n=t==null?void 0:t.detail)==null?void 0:n.message)||(t==null?void 0:t.message)||t||"The workflow list could not be loaded.")}function Fx(e){const{interfaceId:t,defaultInterface:n,allVersions:r=!1,enabled:i=!0,gatewayBaseUrl:c,reloadKey:u}=e,d=y.useRef(e.request);d.current=e.request;const[h,m]=y.useState(0),[p,v]=y.useState({status:"idle",data:null,error:""});y.useEffect(()=>{if(!i){v({status:"idle",data:null,error:""});return}const b=new AbortController;v(j=>({...j,status:"loading",error:""}));const C=Nx(t,{allVersions:r});return(d.current?d.current(C,{signal:b.signal}):Px(c,C,b.signal)).then(j=>{b.signal.aborted||v({status:"ready",data:my(j,t,{defaultInterface:n}),error:""})}).catch(j=>{b.signal.aborted||v({status:"error",data:null,error:Dx(j)})}),()=>b.abort()},[t,n,r,i,c,u,h]);const _=y.useCallback(()=>m(b=>b+1),[]);return{...p,reload:_}}function zx(e){if(!e||typeof window>"u")return{};const t=e.getBoundingClientRect(),n=window.innerWidth,r=window.innerHeight,i=Math.min(Math.max(t.width,300),440,n-32),c=Math.max(16,Math.min(t.left,n-16-i)),u=r-t.bottom-16;return u>=220||u>=t.top?{position:"fixed",left:c,width:i,top:t.bottom+4,maxHeight:Math.max(160,u)}:{position:"fixed",left:c,width:i,bottom:r-t.top+4,maxHeight:Math.max(160,t.top-16)}}function py(...e){return e.filter(Boolean).join(" ")}function gy(e){const t=Fx({interfaceId:e.interfaceId,defaultInterface:e.defaultInterface,request:e.request,gatewayBaseUrl:e.gatewayBaseUrl,allVersions:e.allVersions,enabled:e.workflows?!1:e.enabled!==!1}),n=e.workflows??t,r=e.showDefault!==!1&&(e.interfaceId!==null||!!e.defaultInterface),i=y.useId().replace(/:/g,""),c=`${i}-list`,[u,d]=y.useState(!1),[h,m]=y.useState(-1),p=y.useRef(null),v=y.useRef(null),[_,b]=y.useState({}),C=y.useMemo(()=>Ox(n.data,r),[n.data,r]),x=C.find(z=>z.value===e.value),j=x?{name:x.name,detail:x.detail}:e.currentLabel?{name:e.currentLabel.name,detail:e.currentLabel.detail||""}:n.status==="loading"?{name:"Loading workflows…",detail:""}:{name:e.value===Bc?"Gateway default":"Choose a workflow",detail:""},N=String(e.unavailableReason||"").trim(),$=!N&&n.status==="ready",S=y.useCallback(()=>{d(!1),m(-1)},[]),E=y.useCallback(()=>{if(!$)return;b(zx(v.current)),d(!0);const z=C.findIndex(L=>L.value===e.value);m(z>=0?z:0)},[$,C,e.value]),A=y.useCallback(z=>{var L;S(),z.value!==e.value&&e.onChange(z.value,z.entry),(L=v.current)==null||L.focus()},[S,e]);y.useEffect(()=>{if(!u)return;const z=J=>{p.current&&!p.current.contains(J.target)&&S()},L=()=>S();return document.addEventListener("mousedown",z),document.addEventListener("touchstart",z),window.addEventListener("resize",L),()=>{document.removeEventListener("mousedown",z),document.removeEventListener("touchstart",z),window.removeEventListener("resize",L)}},[u,S]),y.useEffect(()=>{var L;if(!u||h<0)return;const z=typeof document<"u"?document.getElementById(`${i}-opt-${h}`):null;(L=z==null?void 0:z.scrollIntoView)==null||L.call(z,{block:"nearest"})},[u,h,i]);const R=z=>{if(!u){["Enter"," ","ArrowDown","ArrowUp"].includes(z.key)&&(z.preventDefault(),E());return}if(z.key==="Escape"){z.preventDefault(),S();return}if(z.key==="Tab"){S();return}if(z.key==="Enter"||z.key===" "){z.preventDefault(),h>=0&&C[h]&&A(C[h]);return}const L=Lx(z.key,h,C.length);L!==null&&(z.preventDefault(),m(L))};return a.jsxs("div",{ref:p,className:py("af-workflow-picker",e.className),"data-interface":e.interfaceId??"any",children:[a.jsxs("button",{ref:v,id:e.id,type:"button",role:"combobox",className:"af-workflow-picker__trigger","aria-label":e.ariaLabel||"Workflow","aria-describedby":`${i}-value`,"aria-haspopup":"listbox","aria-expanded":u,"aria-controls":c,"aria-activedescendant":u&&h>=0?`${i}-opt-${h}`:void 0,"aria-disabled":$?void 0:!0,title:N||void 0,onClick:()=>u?S():E(),onKeyDown:R,children:[a.jsxs("span",{className:"af-workflow-picker__value",id:`${i}-value`,children:[a.jsx("span",{className:"af-workflow-picker__name",children:j.name}),j.detail?a.jsx("span",{className:"af-workflow-picker__detail",children:j.detail}):null]}),a.jsx("span",{className:"af-workflow-picker__caret","aria-hidden":"true"})]}),u?a.jsx(Ux,{id:c,idBase:i,rows:C,value:e.value,highlight:h,ariaLabel:e.ariaLabel||"Workflow",style:_,onHighlight:m,onChoose:A}):null,n.status==="error"?a.jsx("span",{className:"af-workflow-picker__error",role:"alert",children:n.error}):n.status==="ready"&&C.every(z=>!z.entry)&&!r?a.jsx("span",{className:"af-workflow-picker__empty",role:"status",children:dy}):null]})}function Ux(e){const t=(c,u)=>a.jsxs("div",{id:`${e.idBase}-opt-${u}`,role:"option","aria-selected":c.value===e.value,"data-value":c.value,title:c.title,className:py("af-workflow-picker__option",u===e.highlight&&"af-workflow-picker__option--highlighted",c.value===e.value&&"af-workflow-picker__option--selected"),onMouseEnter:()=>e.onHighlight(u),onMouseDown:d=>d.preventDefault(),onClick:()=>e.onChoose(c),children:[a.jsx("span",{className:"af-workflow-picker__name",children:c.name}),c.detail?a.jsx("span",{className:"af-workflow-picker__detail",children:c.detail}):null]},c.key),n=e.rows.map((c,u)=>({row:c,index:u})),r=n.filter(c=>c.row.group===null),i=["shared","mine"].map(c=>({g:c,items:n.filter(u=>u.row.group===c)})).filter(c=>c.items.length>0);return a.jsxs("div",{id:e.id,role:"listbox","aria-label":e.ariaLabel,className:"af-workflow-picker__list",style:e.style,children:[r.map(c=>t(c.row,c.index)),i.map(({g:c,items:u})=>a.jsxs("div",{role:"group","aria-labelledby":`${e.idBase}-g-${c}`,"data-group":c,children:[a.jsx("div",{id:`${e.idBase}-g-${c}`,className:"af-workflow-picker__group",role:"presentation",children:fy[c]}),u.map(d=>t(d.row,d.index))]},c)),i.length===0?a.jsx("p",{className:"af-workflow-picker__empty",children:dy}):null]})}function yy(e){const t=af(e.target);return a.jsxs("div",{className:"af-auto__field",children:[a.jsx("span",{children:"Workflow"}),a.jsx(gy,{...e.options,ariaLabel:"Automation workflow",value:t,currentLabel:{name:t},onChange:(n,r)=>e.onChange(n==="@default"?{flow_id:"@default",interface:e.options.interfaceId||e.options.defaultInterface||"abstractcode.agent.v1"}:{bundle_ref:`${r.bundleId}@${r.bundleVersion}`,flow_id:r.flowId})})]})}async function Bx(e,t){var _,b;const n=e.flow_id==="@default"?(b=(_=t.workflows)==null?void 0:_.data)==null?void 0:b.gatewayDefault:null,r="bundle_ref"in e?e.bundle_ref:(n==null?void 0:n.status)==="ok"?`${n.bundleId}@${n.bundleVersion}`:"",i=e.flow_id!=="@default"?e.flow_id:(n==null?void 0:n.status)==="ok"?n.flowId:"";if(!r||!i||!t.request)throw new Error("Workflow inputs could not be checked. Refresh the workflow list and try again.");const c=r.lastIndexOf("@"),u=c<0?r:r.slice(0,c),d=c<0?"":r.slice(c+1),h=await t.request(`bundles/${encodeURIComponent(u)}/flows/${encodeURIComponent(i)}/input_schema${d?`?bundle_version=${encodeURIComponent(d)}`:""}`,{signal:new AbortController().signal}),m=(h==null?void 0:h.input_data_schema)||h;if(!m||typeof m!="object"||!m.properties)throw new Error("This workflow does not report its input requirements. Choose another workflow.");const p={...h.defaults||{}};for(const[C,x]of Object.entries(m.properties))x&&"default"in x&&(p[C]=x.default);Object.assign(p,e.input_data||{});const v=(Array.isArray(m.required)?m.required:[]).filter(C=>p[C]===void 0);if(v.length)throw new Error(`This workflow needs additional inputs: ${v.join(", ")}. Configure a new automation from that workflow's input form, or choose a compatible workflow.`);return{...e,input_data:p}}function uf(e){if(Tf(e.status))return null;const t=Ve.not_set_up,n=Ve.open_my_email,r=t.endsWith(n)?t.slice(0,t.length-n.length):`${t} `,i=e.status&&e.status.admin_disabled&&typeof e.status.admin_disabled.cause=="string"?e.status.admin_disabled.cause:"";return a.jsxs("p",{className:"af-auto__hint af-email__notice",role:"note","data-email-setup":"missing",children:[r,e.onOpenMyEmail?a.jsx("button",{type:"button",className:"af-auto__linkbtn","data-action":"open-my-email",onClick:e.onOpenMyEmail,children:n}):n,i?a.jsxs("span",{className:"af-email__cause",children:[" (",i,")"]}):null]})}function Wx(e){const t=e.value,n=d=>e.onChange({...t,...d}),r=d=>`${e.idBase}-email-${d}`,i=po(If(t.usesModel)),c=t.every??(i&&i.unit==="s"?{amount:Math.max(1,Math.round(i.amount/60)),unit:"m"}:{amount:i?i.amount:1,unit:i?i.unit:"h"}),u=e.disabled===!0;return a.jsxs("div",{className:"af-email__trigger","data-field":"email-trigger",children:[a.jsxs("div",{className:"af-auto__row",children:[a.jsx("span",{children:Ve.every_label}),a.jsx("input",{type:"number",min:1,step:1,value:String(c.amount),disabled:u,"aria-label":"Check interval amount",name:"email_every_amount",onChange:d=>n({every:{amount:Number(d.target.value),unit:c.unit}})}),a.jsxs("select",{value:c.unit,disabled:u,"aria-label":"Check interval unit",name:"email_every_unit",onChange:d=>n({every:{amount:c.amount,unit:d.target.value}}),children:[a.jsx("option",{value:"m",children:"minutes"}),a.jsx("option",{value:"h",children:"hours"}),a.jsx("option",{value:"d",children:"days"})]})]}),a.jsx("p",{className:"af-auto__hint","data-email-rule":"interval",children:Ve.interval_rule}),a.jsxs("label",{className:"af-auto__field",htmlFor:r("batch"),children:[a.jsx("span",{children:Ve.max_batch_label}),a.jsx("input",{id:r("batch"),name:"email_max_batch",type:"number",min:1,max:of,step:1,disabled:u,value:String(t.maxBatch??Af),onChange:d=>n({maxBatch:d.target.value.trim()===""?null:Number(d.target.value)})})]}),a.jsx("p",{className:"af-auto__hint",children:Ve.max_batch_hint}),a.jsxs("fieldset",{className:"af-auto__field af-email__filters",disabled:u,children:[a.jsx("legend",{children:Ve.filters_legend}),a.jsxs("label",{className:"af-auto__field",htmlFor:r("from"),children:[a.jsx("span",{children:Ve.from_in}),a.jsx("input",{id:r("from"),name:"email_from_in",value:t.fromIn,spellCheck:!1,placeholder:"alice@example.com, billing@example.org",onChange:d=>n({fromIn:d.target.value})})]}),a.jsxs("label",{className:"af-auto__field",htmlFor:r("domain"),children:[a.jsx("span",{children:Ve.from_domain_in}),a.jsx("input",{id:r("domain"),name:"email_from_domain_in",value:t.fromDomainIn,spellCheck:!1,placeholder:"example.com",onChange:d=>n({fromDomainIn:d.target.value})})]}),a.jsxs("label",{className:"af-auto__field",htmlFor:r("to"),children:[a.jsx("span",{children:Ve.to_in}),a.jsx("input",{id:r("to"),name:"email_to_in",value:t.toIn,spellCheck:!1,onChange:d=>n({toIn:d.target.value})})]}),a.jsxs("label",{className:"af-auto__field",htmlFor:r("subject"),children:[a.jsx("span",{children:Ve.subject_contains}),a.jsx("input",{id:r("subject"),name:"email_subject_contains",value:t.subjectContains,maxLength:200,onChange:d=>n({subjectContains:d.target.value})})]}),a.jsxs("label",{className:"af-auto__field",htmlFor:r("attach"),children:[a.jsx("span",{children:Ve.has_attachment}),a.jsxs("select",{id:r("attach"),name:"email_has_attachment",value:t.hasAttachment,onChange:d=>n({hasAttachment:d.target.value}),children:[a.jsx("option",{value:"any",children:Ve.has_attachment_any}),a.jsx("option",{value:"yes",children:Ve.has_attachment_yes}),a.jsx("option",{value:"no",children:Ve.has_attachment_no})]})]}),a.jsx("p",{className:"af-auto__hint",children:Ve.list_hint})]})]})}function Vx(e){const t=r=>`${e.idBase}-email-${r}`,n=e.disabled===!0;return a.jsxs("div",{className:"af-email__options","data-field":"email-options",children:[a.jsx(Mr,{variant:"row",action:"notify-email",label:Ve.notify_label,checked:e.notifyEmail,unavailableReason:n?"Connect a mailbox first.":null,onChange:r=>e.onNotifyEmailChange(r)}),a.jsxs("p",{className:"af-auto__hint",children:[Ve.notify_hint," Turn on Email result to choose yourself or other email addresses."]}),e.notifyEmail?a.jsxs("fieldset",{className:"af-auto__field",disabled:n,"data-field":"email-recipients",children:[a.jsx("legend",{children:Ve.recipients_legend}),a.jsxs("label",{children:[a.jsx("input",{type:"radio",name:t("rcpt"),value:"self",checked:e.recipients.mode==="self",onChange:()=>e.onRecipientsChange({...e.recipients,mode:"self"})})," ",Ve.recipients_self]}),a.jsxs("label",{children:[a.jsx("input",{type:"radio",name:t("rcpt"),value:"list",checked:e.recipients.mode==="list",onChange:()=>e.onRecipientsChange({...e.recipients,mode:"list"})})," ",Ve.recipients_list]}),e.recipients.mode==="list"?a.jsx("textarea",{name:"email_recipient_list","aria-label":Ve.recipients_list,rows:2,spellCheck:!1,value:e.recipients.addresses,placeholder:"colleague@example.com",onChange:r=>e.onRecipientsChange({mode:"list",addresses:r.target.value})}):null,a.jsx("p",{className:"af-auto__hint",children:Ve.recipients_hint})]}):null]})}const Hx={active:"play",paused:"pause",completed:"check",failed:"error",archived:"archive"};function Gx(e){const t=String(e.status),n=Hx[t];return a.jsxs("span",{className:`af-auto__status af-auto__status--${t}${e.className?` ${e.className}`:""}`,"data-state":t,children:[a.jsx("span",{className:"af-auto__status-word",children:qb[t]??t}),n?a.jsx(ne,{name:n,size:e.iconSize??11,className:"af-auto__status-icon"}):null]})}const vp="Discuss — fork at this occurrence (own workspace, automation files read-only)",Wc=e=>a.jsx("div",{className:"af-auto-text","data-unformatted":"true",children:e});function Kx(e){return zi(e)?e:{status:0,code:"client_error",message:e&&typeof e=="object"&&"message"in e?String(e.message):String(e)}}function _p(e){const t=e.path.split(new RegExp("(?<=[/\\\\_-])"));return a.jsx("code",{className:"af-auto__path-text",children:t.map((n,r)=>a.jsxs(lt.Fragment,{children:[n,r<t.length-1?a.jsx("wbr",{}):null]},r))})}function wy(e,t){const n=e.trigger,r=t.find(i=>i.id===n.source_id&&i.version===n.source_version);return r?"available"in r&&r.available===!1?`Trigger source ${n.source_id}@${n.source_version} is unavailable${r.unavailable_reason?`: ${r.unavailable_reason}`:"."}`:null:`This gateway does not list the trigger source ${n.source_id}@${n.source_version}.`}function Jx(e){const t=e.summary,n=lx(t),r=wy(t,e.triggerSources),i=t.next_fire_at?`${Ir(t.next_fire_at)} (${cx(t.next_fire_at,e.nowMs??Date.now())})`:t.status==="paused"?"none while paused":"none scheduled";return a.jsxs("header",{className:"af-auto__head",children:[a.jsxs("div",{className:"af-auto__titlebar",children:[a.jsx("h2",{className:"af-auto__title",id:e.titleId,tabIndex:-1,children:t.title}),a.jsx(Gx,{status:t.status}),t.legacy?a.jsx("span",{className:"af-auto__legacy",children:"Legacy schedule"}):null]}),a.jsxs("dl",{className:"af-auto__facts",children:[e.workflowLabel?a.jsxs(a.Fragment,{children:[a.jsx("dt",{children:"Workflow"}),a.jsx("dd",{"data-fact":"workflow",children:e.workflowLabel})]}):null,a.jsx("dt",{children:"When"}),a.jsxs("dd",{"data-fact":"trigger",children:[Bg(t.trigger),r?a.jsxs("span",{className:"af-auto__warn",role:"note",children:[" ",r]}):null]}),a.jsx("dt",{children:"Context"}),a.jsx("dd",{"data-fact":"context",children:Wg(t.context_mode)}),n?a.jsxs(a.Fragment,{children:[a.jsx("dt",{children:"Now"}),a.jsx("dd",{"data-fact":"current",className:"is-notable",children:n})]}):null,a.jsx("dt",{children:"Next run"}),a.jsx("dd",{"data-fact":"next",children:i}),a.jsx("dt",{children:"Runs"}),a.jsx("dd",{"data-fact":"count",children:t.occurrence_count}),t.workspace_root?a.jsxs(a.Fragment,{children:[a.jsx("dt",{children:"Workspace"}),a.jsx("dd",{"data-fact":"workspace",className:"af-auto__workspace",children:e.onOpenWorkspace?a.jsxs("button",{type:"button",className:"af-auto__path","data-action":"open-workspace",title:`Browse the automation's folder
|
|
57
|
+
${t.workspace_root}`,"aria-label":`Browse the automation's folder ${t.workspace_root}`,onClick:()=>{var c;return(c=e.onOpenWorkspace)==null?void 0:c.call(e,t.automation_id)},children:[a.jsx(ne,{name:"folder",size:14,className:"af-auto__path-icon"}),a.jsx(_p,{path:t.workspace_root})]}):a.jsxs("span",{className:"af-auto__path af-auto__path--static",children:[a.jsx(ne,{name:"folder",size:14,className:"af-auto__path-icon"}),a.jsx(_p,{path:t.workspace_root})]})})]}):null,a.jsx("dt",{children:"Attention"}),a.jsx("dd",{"data-fact":"attention",className:t.attention.unread||t.attention.pending_waits?"is-notable":void 0,children:hx(t)}),t.revision!==null?a.jsxs(a.Fragment,{children:[a.jsx("dt",{children:"Revision"}),a.jsx("dd",{"data-fact":"revision",children:t.revision})]}):null]})]})}function Qx(e){var u,d;const t=e.definition,n=e.renderText??Wc,r=t.target.input_data.prompt,i=t.policy.retry,c=t.policy.tool_approval;return a.jsxs("details",{className:"af-auto__definition","data-definition-revision":t.revision,open:e.open,children:[a.jsxs("summary",{children:[a.jsx(ne,{name:"chevronRight",size:14,className:"af-auto__definition-chevron"}),a.jsx(ne,{name:"file",size:14}),a.jsx("span",{className:"af-auto__definition-title",children:"Definition"}),a.jsxs("span",{className:"af-auto__definition-meta",children:["revision ",t.revision]})]}),a.jsxs("dl",{className:"af-auto__facts",children:[a.jsx("dt",{children:"Target"}),a.jsx("dd",{"data-def":"target",children:a.jsx("code",{children:t.target.workflow_id})}),typeof r=="string"&&r?a.jsxs(a.Fragment,{children:[a.jsx("dt",{children:"Task"}),a.jsx("dd",{"data-def":"prompt",children:n(r)})]}):null,a.jsx("dt",{children:"Trigger"}),a.jsxs("dd",{"data-def":"trigger",children:[t.trigger.source_id,"@",t.trigger.source_version," · ",Bg(t.trigger),a.jsx("pre",{className:"af-auto__json",children:JSON.stringify(t.trigger.config,null,2)})]}),a.jsx("dt",{children:"Context"}),a.jsxs("dd",{"data-def":"context",children:[Wg(t.context.mode),t.context.mode==="growing"?` · ${Number(((u=t.context.growing)==null?void 0:u.max_tokens)??5e4).toLocaleString()} tokens`:""]}),a.jsx("dt",{children:"Tools"}),a.jsx("dd",{"data-def":"tool_approval",children:c==="ask"?"Ask before each tool call (ask)":c==="auto"?"Run without asking (auto)":String(c)}),a.jsx("dt",{children:"Notify"}),a.jsx("dd",{"data-def":"notify",children:ax(t.notify)}),(d=t.notify)!=null&&d.channels.includes("email")?a.jsxs(a.Fragment,{children:[a.jsx("dt",{children:"Recipients"}),a.jsx("dd",{"data-def":"email_recipients",children:rx(t.notify.recipients)})]}):null,a.jsx("dt",{children:"Retries"}),a.jsxs("dd",{"data-def":"retry",children:[i.max_attempts," ",i.max_attempts===1?"attempt":"attempts",", backoff ",i.backoff.initial," ×",i.backoff.factor," up to ",i.backoff.max]}),a.jsx("dt",{children:"Revision"}),a.jsx("dd",{"data-def":"revision",children:t.revision})]})]})}const Ui=Fg,df=Ui.labels,vy={active:"play",pause:"pause",resume:"play",run_now:Ui.icons.run_now.name,stop_current:"stop",revise:"edit",archive:"archive",unarchive:"unarchive",discuss:"chat"},ff=Ui.hints,Yx=Ui.run_now_next_run_line,Xx=Ui.run_now_growing_line;function Oi(e,t){const n=[ff[e]];return e==="run_now"&&t&&(t.next_fire_at&&n.push(Yx.replace("{time}",Ir(t.next_fire_at))),t.context_mode==="growing"&&n.push(Xx)),n.join(`
|
|
58
|
+
`)}function qx(e,t,n){const r=new Map;for(const u of t){const d=e[u];if(d.enabled)continue;const h=d.reason??"Not available now.";r.set(h,[...r.get(h)??[],u])}const i=[],c={};return[...r.entries()].forEach(([u,d],h)=>{const m=`${n}-why-${h}`;i.push({id:m,text:`${d.map(p=>df[p]).join(", ")}: ${u}`});for(const p of d)c[p]=m}),{lines:i,describedBy:c}}function nn(e){return a.jsxs(a.Fragment,{children:[a.jsx(ne,{name:e.icon,size:14,className:"af-auto__btn-icon"}),a.jsx("span",{children:e.label})]})}function Zx(e){const t=uo(e.summary,e.occurrences,e.busy),n=e.summary.status==="archived",i=qx(t,["active","run_now","stop_current","revise",n?"unarchive":"archive"],e.idBase??`af-auto-${e.summary.automation_id}`),c=(u,d,h)=>{const m=Oi(u,e.summary);return a.jsx("button",{type:"button",className:`af-auto__btn${h!=null&&h.danger?" af-auto__btn--danger":""}`,"data-action":(h==null?void 0:h.action)??u,disabled:!t[u].enabled,title:t[u].enabled?m:`${t[u].reason}
|
|
59
|
+
${m}`,"aria-description":m,"aria-describedby":i.describedBy[u],"aria-pressed":h==null?void 0:h.pressed,onClick:d,children:a.jsx(nn,{icon:vy[u],label:(h==null?void 0:h.label)??df[u]})},u)};return a.jsxs("div",{className:"af-auto__controls-wrap",children:[a.jsxs("div",{className:"af-auto__actionbar",children:[a.jsxs("div",{className:"af-auto__controls",role:"toolbar","aria-label":"Automation controls",children:[a.jsx(Mr,{className:"af-auto__switch",action:"active",label:df.active,checked:e.summary.status==="active",unavailableReason:t.active.enabled?null:t.active.reason??"Not available now.",describedBy:i.describedBy.active,busy:e.busy,hint:Oi("active",e.summary),onChange:()=>e.onCommand(Zg(e.summary))},"active"),c("run_now",()=>e.onCommand(_t.run_now)),c("stop_current",()=>e.onCommand(_t.stop_current)),c("revise",e.onToggleRevise,{pressed:e.reviseOpen,action:"edit"}),n?c("unarchive",()=>e.onCommand(_t.unarchive)):c("archive",e.onAskArchive,{danger:!0,label:"Archive…"})]}),a.jsx("span",{className:`af-auto__notice${e.notice?" af-auto__notice--on":""}`,role:"status",tabIndex:-1,children:e.notice?a.jsxs(a.Fragment,{children:[a.jsx(ne,{name:"check",size:13}),a.jsx("span",{className:"af-auto__notice-text",children:e.notice}),e.onDismissNotice?a.jsx("button",{type:"button",className:"af-auto__icon-btn af-auto__icon-btn--bare","data-action":"dismiss-notice","aria-label":"Dismiss",title:"Dismiss",onClick:e.onDismissNotice,children:a.jsx(ne,{name:"x",size:12})}):null]}):null})]}),i.lines.length?a.jsxs("p",{className:"af-auto__reasons",children:[a.jsx(ne,{name:"info",size:12,className:"af-auto__reasons-icon"}),i.lines.map(u=>a.jsx("span",{id:u.id,children:u.text},u.id))]}):null,e.summary.status==="paused"&&t.run_now.enabled?a.jsx("p",{className:"af-auto__hint",children:"Paused: scheduled runs are skipped. Run now works and keeps it paused."}):null,e.confirmingArchive&&!n?a.jsxs("div",{className:"af-auto__confirm",role:"group","aria-label":"Confirm archive",children:[a.jsxs("p",{children:["Archive “",e.summary.title,"”? Its history stays readable; it will not run again. The current run, if any, finishes."]}),a.jsxs("div",{className:"af-auto__row",children:[a.jsx("button",{type:"button",className:"af-auto__btn af-auto__btn--danger","data-action":"archive-confirm",disabled:!t.archive.enabled,onClick:()=>e.onCommand(_t.archive),children:a.jsx(nn,{icon:"archive",label:"Archive"})}),a.jsx("button",{type:"button",className:"af-auto__btn","data-action":"archive-cancel",onClick:e.onCancelArchive,children:a.jsx(nn,{icon:"x",label:"Keep it"})})]})]}):null]})}const bp=[["m","minutes"],["h","hours"],["d","days"]];function ek(e,t){const n=j=>{const N=e.elements.namedItem(j);return N&&typeof N.value=="string"?N.value:null},r=n("every_amount"),i=n("every_unit"),c=r!==null&&i!==null?`${r.trim()}${i}`:t.every,u=e.elements.namedItem("context"),d=u&&(u.value==="growing"||u.value==="independent")?u.value:t.context,h=n("prompt"),m=e.elements.namedItem("tool_approval"),p=m&&(m.value==="auto"||m.value==="ask")?m.value:t.toolApproval??null,v=e.elements.namedItem("notify_email"),_=v&&typeof v.checked=="boolean"?v.checked:t.notifyEmail??null,b=e.elements.namedItem("email_recipients"),C=n("email_recipient_list"),x=b&&(b.value==="self"||b.value==="list")?{mode:b.value,addresses:C??""}:t.emailRecipients??null;return{title:n("title")??t.title,every:c,context:d,growingMaxTokens:n("growing_max_tokens")===null?t.growingMaxTokens:Number(n("growing_max_tokens")),prompt:h??t.prompt??null,toolApproval:p,notifyEmail:_,emailRecipients:x}}function _y(e){const t=ey(e.summary,e.definition),[n,r]=y.useState(),[i,c]=y.useState(t.tools??null),[u,d]=y.useState(t.context),[h,m]=y.useState(!!t.notifyEmail),p=t.every?po(t.every):null,v=p&&p.unit==="s"?[["s","seconds"],...bp]:bp,_=`af-auto-revise-${e.summary.automation_id}`,b=Tf(e.emailStatus),C=Fi(e.summary.trigger);return a.jsxs("form",{className:"af-auto__revise","aria-labelledby":`${_}-heading`,onSubmit:x=>{x.preventDefault(),e.onSubmit({...ek(x.currentTarget,t),...n?{target:n}:{},...e.availableTools!==void 0?{tools:i}:{}})},onKeyDown:x=>{x.key==="Escape"&&e.onCancel&&(x.preventDefault(),e.onCancel())},children:[e.heading===null?a.jsx("span",{id:`${_}-heading`,hidden:!0,children:"Edit automation"}):a.jsxs("h3",{className:"af-auto__form-title",id:`${_}-heading`,children:[a.jsx(ne,{name:"edit",size:14})," ",e.heading??"Edit automation"]}),e.definition&&e.workflowPickerOptions?a.jsx(yy,{target:n||e.definition.target,options:e.workflowPickerOptions,onChange:r}):null,a.jsxs("label",{className:"af-auto__field",htmlFor:`${_}-title`,children:[a.jsx("span",{children:"Title"}),a.jsx("input",{id:`${_}-title`,name:"title",defaultValue:t.title,maxLength:120,required:!0})]}),t.prompt!==null&&t.prompt!==void 0?a.jsxs("label",{className:"af-auto__field",htmlFor:`${_}-prompt`,children:[a.jsx("span",{children:"Task"}),a.jsx("textarea",{id:`${_}-prompt`,name:"prompt",defaultValue:t.prompt,rows:Math.min(10,Math.max(3,t.prompt.split(`
|
|
60
|
+
`).length+1)),required:!0})]}):null,p?a.jsxs("fieldset",{className:"af-auto__field",children:[a.jsx("legend",{children:C?Ve.every_label:"Repeat every (UTC)"}),a.jsxs("div",{className:"af-auto__row",children:[a.jsx("input",{name:"every_amount",type:"number",min:1,step:1,defaultValue:p.amount,"aria-label":"Interval amount"}),a.jsx("select",{name:"every_unit",defaultValue:p.unit,"aria-label":"Interval unit",children:v.map(([x,j])=>a.jsx("option",{value:x,children:j},x))})]}),C?a.jsx("p",{className:"af-auto__hint","data-email-rule":"interval",children:Ve.interval_rule}):null]}):a.jsx("p",{className:"af-auto__hint",children:"This trigger has no interval to change."}),a.jsxs("fieldset",{className:"af-auto__field",children:[a.jsx("legend",{children:"Context"}),a.jsxs("label",{children:[a.jsx("input",{type:"radio",name:"context",value:"independent",defaultChecked:t.context==="independent",onChange:()=>d("independent")})," Independent — each run starts fresh"]}),a.jsxs("label",{children:[a.jsx("input",{type:"radio",name:"context",value:"growing",defaultChecked:t.context==="growing",onChange:()=>d("growing")})," Growing — each run sees the previous runs"]}),a.jsx("div",{hidden:u!=="growing",children:a.jsxs("label",{className:"af-auto__field",children:[a.jsx("span",{children:"Max growing context (tokens)"}),a.jsx("input",{name:"growing_max_tokens",type:"number",min:1,step:1,disabled:e.busy||u!=="growing",defaultValue:t.growingMaxTokens}),a.jsx("span",{className:"af-auto__hint",children:ny})]})})]}),t.toolApproval?a.jsxs("fieldset",{className:"af-auto__field",children:[a.jsx("legend",{children:"Tools"}),e.availableTools!==void 0?a.jsx(uy,{availableTools:e.availableTools,value:i,onChange:c,disabled:e.busy}):null,a.jsxs("label",{children:[a.jsx("input",{type:"radio",name:"tool_approval",value:"auto",defaultChecked:t.toolApproval==="auto"})," Run without asking"]}),a.jsxs("label",{children:[a.jsx("input",{type:"radio",name:"tool_approval",value:"ask",defaultChecked:t.toolApproval==="ask"})," Ask before each tool call"]})]}):null,t.notifyEmail!==null&&t.notifyEmail!==void 0&&t.emailRecipients?a.jsxs("fieldset",{className:"af-auto__field","data-field":"email",children:[a.jsx("legend",{children:"Mailbox"}),b?null:a.jsx(uf,{status:e.emailStatus,onOpenMyEmail:e.onOpenMyEmail}),a.jsx($_,{variant:"row",action:"notify-email",name:"notify_email",label:Ve.notify_label,defaultChecked:!!t.notifyEmail,onChange:m,unavailableReason:!b&&!t.notifyEmail?"Connect a mailbox first.":null}),a.jsxs("p",{className:"af-auto__hint",children:[Ve.notify_hint," Turn on Email result to choose yourself or other email addresses."]}),a.jsx("div",{hidden:!h,children:a.jsxs("fieldset",{className:"af-auto__field",disabled:!h,"data-field":"email-recipients",children:[a.jsx("legend",{children:Ve.recipients_legend}),a.jsxs("label",{children:[a.jsx("input",{type:"radio",name:"email_recipients",value:"self",defaultChecked:t.emailRecipients.mode==="self"})," ",Ve.recipients_self]}),a.jsxs("label",{children:[a.jsx("input",{type:"radio",name:"email_recipients",value:"list",defaultChecked:t.emailRecipients.mode==="list",disabled:!b&&t.emailRecipients.mode!=="list"})," ",Ve.recipients_list]}),a.jsx("textarea",{name:"email_recipient_list","aria-label":Ve.recipients_list,rows:2,spellCheck:!1,defaultValue:t.emailRecipients.addresses,disabled:!b&&t.emailRecipients.mode!=="list"}),a.jsx("p",{className:"af-auto__hint",children:Ve.recipients_hint})]})})]}):null,a.jsx("p",{className:"af-auto__hint",children:"Changes apply from the next run; a new interval never fires past ticks."}),e.errors.length?a.jsx("ul",{className:"af-auto__form-errors",role:"alert",children:e.errors.map(x=>a.jsx("li",{children:x},x))}):null,a.jsxs("div",{className:"af-auto__row",children:[a.jsx("button",{type:"submit",className:"af-auto__btn af-auto__btn--primary","data-action":"edit-save",disabled:e.busy,children:a.jsx(nn,{icon:"check",label:e.submitLabel??"Save changes"})}),e.onCancel?a.jsx("button",{type:"button",className:"af-auto__btn","data-action":"edit-cancel",onClick:e.onCancel,children:a.jsx(nn,{icon:"x",label:"Cancel"})}):null]})]})}function hf(e,t){const n=e.elements.namedItem(t);return n&&typeof n.value=="string"?n.value.trim():""}function tk(e){const t=e.wait,n=`${e.idBase}-${t.run_id}-${t.wait_key}-prompt`,r=u=>e.onAnswerWait(t.run_id,t.wait_key,u),i=e.renderText??Wc,c=u=>a.jsxs("div",{className:"af-auto-wait__prompt",id:n,children:[a.jsx("span",{className:"af-auto-wait__kind",children:iy[t.kind]??"Waiting"}),t.prompt?i(t.prompt):a.jsxs("span",{children:[" ",u]})]});if(t.kind==="tool_approval"){const u=_x(t);return a.jsxs("div",{className:"af-auto-wait af-auto-wait--tool_approval",role:"group","data-wait-key":t.wait_key,"data-wait-kind":t.kind,"aria-labelledby":n,children:[c("A tool call needs your approval."),u&&u.length?a.jsx("ul",{className:"af-auto-wait__calls","aria-label":"Tool calls to approve",children:u.map((d,h)=>a.jsxs("li",{"data-tool":d.name,children:[a.jsx("code",{className:"af-auto-wait__tool",children:d.name}),a.jsx("pre",{className:"af-auto-wait__args",children:JSON.stringify(d.arguments,null,2)})]},d.call_id??`${d.name}:${h}`))}):a.jsx("p",{className:"af-auto__hint",children:"The gateway did not list the tool calls; open the run to see them before approving."}),a.jsxs("div",{className:"af-auto__row",children:[a.jsx("button",{type:"button",className:"af-auto__btn af-auto__btn--primary","data-action":"wait-approve",disabled:e.busy,onClick:()=>r({approved:!0}),children:a.jsx(nn,{icon:"check",label:"Approve"})}),a.jsx("button",{type:"button",className:"af-auto__btn af-auto__btn--danger","data-action":"wait-deny",disabled:e.busy,onClick:()=>r({approved:!1}),children:a.jsx(nn,{icon:"x",label:"Deny"})})]})]})}return t.kind==="event"?a.jsxs("form",{className:"af-auto-wait af-auto-wait--event","data-wait-key":t.wait_key,"data-wait-kind":t.kind,"aria-labelledby":n,onSubmit:u=>{var h;u.preventDefault();const d=bx(hf(u.currentTarget,"payload"));d.ok?r({payload:d.payload}):(h=e.onWaitError)==null||h.call(e,d.error)},children:[c("The run waits for an event."),a.jsx("textarea",{name:"payload",rows:3,"aria-label":"Event payload (JSON)",placeholder:'{"key": "value"}',disabled:e.busy}),a.jsx("div",{className:"af-auto__row",children:a.jsx("button",{type:"submit",className:"af-auto__btn af-auto__btn--primary","data-action":"wait-send-event",disabled:e.busy,children:a.jsx(nn,{icon:"send",label:"Send event"})})})]}):t.kind==="ask_user"?a.jsxs("form",{className:"af-auto-wait af-auto-wait--ask_user","data-wait-key":t.wait_key,"data-wait-kind":t.kind,"aria-labelledby":n,onSubmit:u=>{u.preventDefault();const d=hf(u.currentTarget,"response");d&&r({response:d})},children:[c("The run is waiting for your input."),t.choices&&t.choices.length?a.jsx("div",{className:"af-auto__row",role:"group","aria-label":"Choices",children:t.choices.map(u=>a.jsx("button",{type:"button",className:"af-auto__btn","data-action":"wait-choice",disabled:e.busy,onClick:()=>r({response:u}),children:u},u))}):null,a.jsxs("div",{className:"af-auto__row",children:[a.jsx("input",{name:"response","aria-label":"Your answer",placeholder:"Your answer",disabled:e.busy}),a.jsx("button",{type:"submit",className:"af-auto__btn af-auto__btn--primary","data-action":"wait-answer",disabled:e.busy,children:a.jsx(nn,{icon:"send",label:"Answer"})})]})]}):a.jsxs("div",{className:"af-auto-wait",role:"group","data-wait-key":t.wait_key,"data-wait-kind":String(t.kind),"aria-labelledby":n,children:[c("The run is waiting."),a.jsxs("p",{className:"af-auto__hint",children:["This kind of wait (",String(t.kind),") cannot be answered here; open the run."]})]})}function nk(e){const{row:t,tone:n,badge:r,statusText:i}=e.view,c=`af-auto-occ-${t.run_id}`,u=e.renderText??Wc,d=e.discuss.enabled&&e.view.canDiscuss&&!e.busy,h=e.discuss.enabled?e.view.canDiscuss?null:"Available once this occurrence finishes.":e.discuss.reason??"Not available.",m=(_,b)=>e.renderTurn?e.renderTurn({kind:_,role:_==="trigger"?"user":"assistant",text:b,index:t.index,runId:t.run_id}):u(b),p=e.renderTurn?" af-auto-turn--card":"",v=n==="failed"?t.failure?"No answer.":"No answer: the run failed.":n==="waiting"?"Waiting for your answer.":n==="running"?"Running…":"No answer.";return a.jsxs("li",{className:`af-auto-occ af-auto-occ--${n}`,"data-index":t.index,"data-tone":n,"aria-labelledby":`${c}-h`,children:[a.jsxs("div",{className:`af-auto-turn af-auto-turn--trigger${p}`,"data-turn":"trigger",children:[a.jsxs("div",{className:"af-auto-turn__meta",id:`${c}-h`,children:[a.jsxs("span",{className:"af-auto-turn__index",children:["#",t.index]})," · ",t.trigger.summary," · fired ",Ir(t.fired_at)]}),a.jsx("div",{className:"af-auto-turn__text",children:m("trigger",t.user_turn)})]}),a.jsxs("div",{className:`af-auto-turn af-auto-turn--answer${p}`,"data-turn":"answer",children:[a.jsxs("div",{className:"af-auto-turn__meta",children:[r?a.jsx("span",{className:`af-auto-badge af-auto-badge--${n}`,children:r}):null,a.jsx("span",{className:"af-auto-turn__status",children:i}),t.finished_at?a.jsxs("span",{children:[" · ",Ir(t.finished_at)]}):null]}),t.notify?a.jsxs("div",{className:"af-auto-notify","data-notify":"true",children:[a.jsx("strong",{children:t.notify.title}),t.notify.body?a.jsx("div",{className:"af-auto-notify__body",children:u(t.notify.body)}):null]}):null,t.failure?a.jsxs("div",{className:"af-auto-failure","data-failure":t.failure.reason_code,children:[a.jsx("strong",{children:t.failure.reason_code}),": ",t.failure.message," ",a.jsxs("span",{className:"af-auto-turn__muted",children:["(after ",t.failure.attempts," ",t.failure.attempts===1?"attempt":"attempts",")"]})]}):null,t.answer?a.jsx("div",{className:"af-auto-turn__text",children:m("answer",t.answer)}):a.jsx("div",{className:"af-auto-turn__empty",children:v}),t.artifacts.length?a.jsx("ul",{className:"af-auto-artifacts","aria-label":"Artifacts",children:t.artifacts.map(_=>a.jsxs("li",{children:[e.onOpenResource?a.jsxs("button",{type:"button",className:"af-auto__linkbtn","data-action":"open-artifact",onClick:()=>{var b;return(b=e.onOpenResource)==null?void 0:b.call(e,{kind:"artifact",url:_.url,name:_.name,mimeType:_.mime_type,runId:t.run_id})},children:[a.jsx(ne,{name:"file",size:13,className:"af-auto__btn-icon"})," ",_.name]}):a.jsx("span",{className:"af-auto-artifact__name",children:_.name})," ",a.jsx("span",{className:"af-auto-turn__muted",children:_.mime_type})]},_.artifact_id))}):null,t.waits.map(_=>a.jsx(tk,{wait:_,busy:e.busy,idBase:c,onAnswerWait:e.onAnswerWait,onWaitError:e.onWaitError,renderText:e.renderText},`${_.run_id}:${_.wait_key}`))]}),a.jsxs("div",{className:"af-auto-occ__foot",children:[a.jsxs("details",{className:"af-auto-occ__details",children:[a.jsx("summary",{children:"Run details"}),a.jsxs("dl",{className:"af-auto__facts",children:[a.jsx("dt",{children:"Run"}),a.jsx("dd",{children:a.jsx("code",{children:t.run_id})}),a.jsx("dt",{children:"Attempts"}),a.jsx("dd",{children:t.attempts})]}),a.jsxs("div",{className:"af-auto__row",children:[a.jsx("button",{type:"button",className:"af-auto__btn","data-action":"open-run",onClick:()=>e.onOpenRun(t.run_id),children:a.jsx(nn,{icon:"list",label:"Open run ledger"})}),e.onOpenResource?a.jsx("button",{type:"button",className:"af-auto__btn","data-action":"open-ledger-json",onClick:()=>{var _;return(_=e.onOpenResource)==null?void 0:_.call(e,{kind:"ledger",url:t.ledger_url,name:`run-${t.run_id}-ledger.json`,runId:t.run_id})},children:a.jsx(nn,{icon:"file",label:"Ledger (JSON)"})}):null,t.workspace_url&&e.onOpenWorkspace?a.jsx("button",{type:"button",className:"af-auto__btn","data-action":"open-workspace",title:"Browse this run's folder",onClick:()=>{var _;return(_=e.onOpenWorkspace)==null?void 0:_.call(e,t.run_id)},children:a.jsx(nn,{icon:"folder",label:"Workspace"})}):null]})]}),e.discussOpen?a.jsxs("form",{className:"af-auto-discuss","aria-label":`${vp}, from occurrence ${t.index}`,onSubmit:_=>{_.preventDefault();const b=hf(_.currentTarget,"prompt");b&&e.onDiscussSubmit(t.index,b)},children:[a.jsxs("p",{className:"af-auto__hint",children:["Starts a new session that forks this automation at #",t.index," with its full history (runs 1–",t.index,"). It works in its own writable workspace; the automation's files are mounted read-only for the file tools (shell commands are not sandboxed), and nothing is written back into the automation's session."]}),a.jsx("textarea",{name:"prompt",rows:3,"aria-label":"Your message",placeholder:"Ask about this result…",required:!0}),a.jsxs("div",{className:"af-auto__row",children:[a.jsx("button",{type:"submit",className:"af-auto__btn af-auto__btn--primary","data-action":"discuss-submit",disabled:e.busy,children:a.jsx(nn,{icon:"send",label:"Start discussion"})}),a.jsx("button",{type:"button",className:"af-auto__btn","data-action":"discuss-cancel",onClick:e.onDiscussCancel,children:a.jsx(nn,{icon:"x",label:"Cancel"})})]})]}):a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:"af-auto__btn af-auto__btn--quiet","data-action":"discuss",disabled:!d,title:ff.discuss,"aria-description":ff.discuss,"aria-describedby":h?`${c}-discuss-why`:void 0,onClick:()=>e.onDiscussOpen(t.index),children:a.jsx(nn,{icon:vy.discuss,label:vp})}),h?a.jsx("span",{className:"af-auto__reasons",id:`${c}-discuss-why`,children:h}):null]})]})]})}const sk=5e3,rk={[_t.pause]:"Automation paused.",[_t.resume]:"Automation active.",[_t.run_now]:"Run requested.",[_t.stop_current]:"Stop requested.",[_t.unarchive]:"Unarchived: it is paused until you make it active."};function ak(e){var me;const{summary:t,busy:n}=e,r=e.renderText??Wc,i=y.useId(),c=y.useRef(null),[u,d]=y.useState(!1),h=e.editOpen!==void 0,p=uo(t,e.occurrences,!1).revise.enabled&&(h?e.editOpen===!0:u),v=y.useRef(null);p?(!v.current||v.current.summary.automation_id!==t.automation_id)&&(v.current={summary:t,definition:e.definition}):v.current=null;const _=v.current,b=y.useRef(e.onEditOpenChange);b.current=e.onEditOpenChange;const C=q=>{var fe;h||d(q),(fe=b.current)==null||fe.call(b,q)},[x,j]=y.useState([]),[N,$]=y.useState(!1),[S,E]=y.useState(null),[A,R]=y.useState(null),[z,L]=y.useState(null);y.useEffect(()=>{if(!z)return;const q=setTimeout(()=>L(null),sk);return()=>clearTimeout(q)},[z]),y.useEffect(()=>{var fe;if(!p)return;j([]);const q=yp(c.current,['.af-auto__revise [name="title"]']);q==null||q.focus(),(fe=q==null?void 0:q.scrollIntoView)==null||fe.call(q,{block:"nearest"})},[p,t.automation_id]);const[J,V]=y.useState(null);y.useEffect(()=>{var q;J&&((q=yp(c.current,[...J,".af-auto__notice",".af-auto__title"]))==null||q.focus(),V(null))},[J]);const O=y.useRef(null);O.current||(O.current=new ly(e.newId??cy));const ee=O.current,P=q=>R(Kx(q)),Z=(q,fe,de)=>{R(null),L(null),fe(ee.idFor(q)).then(ae=>{ee.settle(q,{ok:!0}),de(ae)},ae=>{ee.settle(q,{ok:!1,error:ae}),P(ae)})},U=fx(t),te=y.useRef(e.onSeen);te.current=e.onSeen;const se=y.useRef(null);se.current||(se.current=new kx),y.useEffect(()=>{const q=se.current,fe=U?`${t.automation_id}|${U}`:null;if(!U||!q.next(fe,t))return;const de=t;te.current(U).then(()=>q.succeeded(fe),ae=>{q.failed(fe,de),P(ae)})});const G=uo(t,e.occurrences,n),ce=dx(e.occurrences),re=t.occurrence_count-e.occurrences.length,D=A??e.error??null,I=D?go(D):null,W=t.attention;return a.jsxs("section",{ref:c,className:`af-auto${e.className?` ${e.className}`:""}`,...e.hideHeader?{"aria-label":t.title}:{"aria-labelledby":i},"aria-busy":n,"data-text-rendering":e.renderText?"rich":"unformatted",children:[e.hideHeader?null:a.jsxs(a.Fragment,{children:[a.jsx(Jx,{summary:t,workflowLabel:(me=e.definition)==null?void 0:me.target.workflow_id,triggerSources:e.triggerSources,titleId:i,nowMs:e.nowMs,onOpenWorkspace:e.onOpenWorkspace}),a.jsx(Zx,{summary:t,occurrences:e.occurrences,busy:n,confirmingArchive:N,reviseOpen:p,notice:z,onDismissNotice:()=>L(null),idBase:`${i}-ctl`,onCommand:q=>Z(`command:${q}`,fe=>e.onCommand(q,void 0,{command_id:fe}),()=>{q===_t.archive?($(!1),L("Archive requested."),V(['[data-action="archive"]'])):L(rk[q]??"Command sent.")}),onToggleRevise:()=>{j([]),C(!p)},onAskArchive:()=>$(!0),onCancelArchive:()=>{$(!1),V(['[data-action="archive"]'])}})]}),p&&_?a.jsx(_y,{summary:_.summary,definition:_.definition,busy:n,errors:x,availableTools:e.availableTools,workflowPickerOptions:e.workflowPickerOptions,emailStatus:e.emailStatus,onOpenMyEmail:e.onOpenMyEmail,onCancel:()=>{C(!1),V(['[data-action="edit"]'])},onSubmit:q=>{const fe=_.summary,de=ty(fe,q,_.definition);if(de===null){j(["Nothing changed."]);return}if("errors"in de){j(de.errors);return}j([]),Z(`revise:${fe.revision}:${JSON.stringify(de)}`,async ae=>{const we=q.target&&de.target?{...de,target:await(e.prepareTarget?e.prepareTarget(de.target):Bx(de.target,e.workflowPickerOptions))}:de;return e.onRevise(we,fe.revision,{command_id:ae})},()=>{L("Saved; applies from the next run."),C(!1),V(['[data-action="edit"]'])})}}):e.definition?a.jsx(Qx,{definition:e.definition,renderText:r}):null,I?a.jsxs("div",{className:"af-auto__error",role:"alert","data-code":D==null?void 0:D.code,children:[a.jsx(ne,{name:"error",size:14,className:"af-auto__btn-icon"}),a.jsxs("span",{className:"af-auto__error-text",children:[a.jsx("strong",{children:I.title})," ",a.jsx("span",{children:I.detail})]}),A?a.jsx("button",{type:"button",className:"af-auto__icon-btn af-auto__icon-btn--bare","data-action":"dismiss-error","aria-label":"Dismiss",title:"Dismiss",onClick:()=>R(null),children:a.jsx(ne,{name:"x",size:12})}):null]}):null,W.items.length||W.waits.length?a.jsx("section",{className:"af-auto__attention","aria-label":"Needs attention",children:a.jsxs("ul",{children:[W.items.map(q=>a.jsxs("li",{className:`af-auto__attention-item af-auto__attention-item--${q.kind}`,"data-cursor":q.cursor,children:[a.jsx("span",{className:`af-auto-badge af-auto-badge--${q.kind==="failure"?"failed":"notified"}`,children:q.kind==="failure"?"Failed":"Notified"})," ",a.jsx("strong",{children:q.title})," ",a.jsxs("span",{className:"af-auto-turn__muted",children:["#",q.index," · ",Ir(q.at)]}),q.body?a.jsx("div",{className:"af-auto__attention-body",children:r(q.body)}):null]},q.cursor)),W.waits.map(q=>a.jsxs("li",{className:"af-auto__attention-item af-auto__attention-item--wait",children:[a.jsx("span",{className:"af-auto-badge af-auto-badge--waiting","data-wait-kind":q.kind,children:iy[q.kind]??"Waiting for you"})," ",a.jsxs("span",{className:"af-auto-turn__muted",children:["#",q.index]}),q.prompt?a.jsx("div",{className:"af-auto__attention-body",children:r(q.prompt)}):null]},`${q.run_id}:${q.wait_key}`))]})}):null,re>0?a.jsx("button",{type:"button",className:"af-auto__btn af-auto__more","data-action":"load-more",disabled:n,onClick:e.onLoadMore,children:a.jsx(nn,{icon:"history",label:`Load earlier occurrences (${re} more)`})}):null,ce.length?a.jsx("ol",{className:"af-auto__timeline","aria-label":"Occurrences",children:ce.map(q=>{const fe=`[data-index="${q.row.index}"]`;return a.jsx(nk,{view:q,busy:n,discuss:G.discuss,renderText:r,renderTurn:e.renderTurn,onOpenWorkspace:e.onOpenWorkspace,onOpenResource:e.onOpenResource?de=>{var ae;R(null);try{Promise.resolve((ae=e.onOpenResource)==null?void 0:ae.call(e,de)).catch(P)}catch(we){P(we)}}:void 0,discussOpen:S===q.row.index,onOpenRun:e.onOpenRun,onAnswerWait:(de,ae,we)=>{R(null),e.onAnswerWait(de,ae,we).then(()=>L("Answer sent."),P)},onWaitError:de=>R({status:0,code:"invalid_payload",message:de}),onDiscussOpen:E,onDiscussCancel:()=>{E(null),V([`${fe} [data-action="discuss"]`])},onDiscussSubmit:(de,ae)=>Z(`discuss:${de}:${ae}`,we=>e.onDiscuss(de,ae,{request_id:we}),we=>{E(null),L(`Discussion started (session ${we.session_id}).`),V([`${fe} [data-action="discuss"]`])})},q.row.run_id)})}):a.jsx("p",{className:"af-auto__empty",children:"No occurrences yet."})]})}function ok(e){var ie,Ae;const t=y.useId(),n=y.useId(),r=y.useRef(null),i=y.useRef(null),c=y.useRef(e.onClose);c.current=e.onClose;const u=e.initialTools??Di((ie=e.target)==null?void 0:ie.input_data),[d,h]=y.useState({open:e.open,value:u});d.open!==e.open&&h({open:e.open,value:u});const m=d.value,p=ge=>h(Y=>({...Y,value:ge})),[v,_]=y.useState(e.initialPrompt??""),[b,C]=y.useState("every"),[x,j]=y.useState(Rf),[N,$]=y.useState(!1),[S,E]=y.useState(Ai),[A,R]=y.useState("24"),[z,L]=y.useState("h"),[J,V]=y.useState(""),[O,ee]=y.useState(String(Li)),[P,Z]=y.useState("independent"),[U,te]=y.useState("auto"),[se,G]=y.useState(e.initialTitle??""),[ce,re]=y.useState(""),[D,I]=y.useState(""),[W,me]=y.useState(""),[q,fe]=y.useState([]),de=y.useRef(null);if(de.current||(de.current=new ly(()=>(e.newRequestId??cy)())),y.useEffect(()=>{var pe;if(!e.open)return;const ge=document.activeElement;(pe=i.current)==null||pe.focus();const Y=ve=>{if(!ve.defaultPrevented){if(ve.key==="Escape"){ve.preventDefault(),c.current();return}Lg(ve,r.current,document.activeElement)}};return window.addEventListener("keydown",Y),()=>{window.removeEventListener("keydown",Y),ge&&typeof ge.focus=="function"&&ge.focus()}},[e.open]),!e.open)return null;const ae=Tf(e.emailStatus),we=b==="email"&&ae,Pe=b==="email"&&!ae?"every":b,Qe={prompt:v,when:b==="once"?{kind:"once",at:J}:{kind:"every",amount:Number(A),unit:z},...we?{trigger:"email",email:{...x,usesModel:e.targetUsesModel!==!1}}:{},...ae&&N?{notifyEmail:!0}:{},...ae&&S.mode==="list"?{emailRecipients:S}:{},context:P,growingMaxTokens:Number(O),toolApproval:U,title:se,...Pe==="every"&&ce?{startAt:ce}:{},...Pe==="every"&&D.trim()?{count:Number(D)}:{},...Pe==="every"&&W?{until:W}:{}},Ye=yx(Qe),Ne=e.busy===!0,He=e.error?go(e.error):null,ue=ge=>`${n}-${ge}`,Ue=ge=>{ge.preventDefault();const Y=wx(Qe,{target:e.target,requestId:""});if(!Y.ok){fe(Y.errors);return}fe([]);const pe=de.current,ve=e.availableTools===void 0?Y.body:{...Y.body,target:{...Y.body.target,input_data:Uc(Y.body.target.input_data||{},m)}},Ee=JSON.stringify(ve),Oe={...ve,request_id:pe.idFor(Ee)};Promise.resolve(e.onSubmit(Oe)).then(()=>pe.settle(Ee,{ok:!0}),Be=>pe.settle(Ee,{ok:!1,error:Be}))};return a.jsx("div",{className:"af-appearance-overlay af-schedule-overlay",onClick:e.onClose,role:"presentation",children:a.jsxs("div",{ref:r,className:"af-appearance af-schedule",role:"dialog","aria-modal":"true","aria-labelledby":t,onClick:ge=>ge.stopPropagation(),children:[a.jsx("div",{className:"af-appearance__title",id:t,children:e.title??"Schedule a task"}),a.jsxs("form",{className:"af-schedule__form",onSubmit:Ue,"aria-busy":Ne,children:[a.jsxs("fieldset",{className:"af-auto__field",children:[a.jsx("legend",{children:"What"}),e.workflowPicker?a.jsx("div",{className:"af-schedule__picker",children:e.workflowPicker}):null,e.target?null:a.jsx("p",{className:"af-auto__hint",children:"Choose what to run."}),a.jsxs("label",{className:"af-auto__field",htmlFor:ue("prompt"),children:[a.jsx("span",{children:"Task"}),a.jsx("textarea",{id:ue("prompt"),ref:i,rows:3,value:v,onChange:ge=>_(ge.target.value),placeholder:"e.g. Check the price of ACME shares and notify me if it moved more than 2%.",required:!0})]})]}),a.jsxs("fieldset",{className:"af-auto__field",children:[a.jsx("legend",{children:"When (UTC)"}),a.jsxs("div",{className:"af-auto__row",role:"radiogroup","aria-label":"Schedule kind",children:[a.jsxs("label",{children:[a.jsx("input",{type:"radio",name:ue("kind"),value:"every",checked:Pe==="every",onChange:()=>C("every")})," Repeat"]}),a.jsxs("label",{children:[a.jsx("input",{type:"radio",name:ue("kind"),value:"once",checked:b==="once",onChange:()=>C("once")})," Once at…"]}),a.jsxs("label",{children:[a.jsx("input",{type:"radio",name:ue("kind"),value:"email",checked:we,disabled:!ae,onChange:()=>C("email")})," ",Ve.trigger_label]})]}),ae?null:a.jsx(uf,{status:e.emailStatus,onOpenMyEmail:e.onOpenMyEmail}),we?a.jsx(Wx,{value:{...x,usesModel:e.targetUsesModel!==!1},onChange:j,idBase:n}):Pe==="every"?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"af-auto__row af-schedule__presets",role:"group","aria-label":"Presets",children:px.map(ge=>ge.when.kind==="every"?a.jsx("button",{type:"button",className:"af-auto__btn af-auto__btn--quiet","aria-pressed":Number(A)===ge.when.amount&&z===ge.when.unit,onClick:()=>{ge.when.kind==="every"&&(R(String(ge.when.amount)),L(ge.when.unit))},children:ge.label},ge.label):null)}),a.jsxs("div",{className:"af-auto__row",children:[a.jsx("span",{children:"Every"}),a.jsx("input",{type:"number",min:1,step:1,value:A,onChange:ge=>R(ge.target.value),"aria-label":"Interval amount"}),a.jsxs("select",{value:z,onChange:ge=>L(ge.target.value),"aria-label":"Interval unit",children:[a.jsx("option",{value:"m",children:"minutes"}),a.jsx("option",{value:"h",children:"hours"}),a.jsx("option",{value:"d",children:"days"})]})]})]}):a.jsxs("label",{className:"af-auto__field",htmlFor:ue("once"),children:[a.jsx("span",{children:"Run once at (UTC)"}),a.jsx("input",{id:ue("once"),type:"datetime-local",value:J,onChange:ge=>V(ge.target.value)})]}),a.jsx("p",{className:"af-schedule__preview","aria-live":"polite","data-preview":"true",children:Ye?`Runs ${Ye}.`:we?"Incomplete email trigger.":"Incomplete schedule."})]}),a.jsxs("fieldset",{className:"af-auto__field",children:[a.jsx("legend",{children:"Context"}),a.jsxs("label",{children:[a.jsx("input",{type:"radio",name:ue("ctx"),value:"independent",checked:P==="independent",onChange:()=>Z("independent")})," Independent — each run starts fresh"]}),a.jsxs("label",{children:[a.jsx("input",{type:"radio",name:ue("ctx"),value:"growing",checked:P==="growing",onChange:()=>Z("growing")})," Growing — each run sees the previous runs"]}),P==="growing"?a.jsxs("label",{className:"af-auto__field",children:[a.jsx("span",{children:"Max growing context (tokens)"}),a.jsx("input",{type:"number",min:1,step:1,required:!0,disabled:Ne,value:O,onChange:ge=>ee(ge.target.value)}),a.jsx("span",{className:"af-auto__hint",children:ny})]}):null]}),a.jsxs("fieldset",{className:"af-auto__field","data-field":"tool-approval",children:[a.jsx("legend",{children:"Tools"}),e.availableTools!==void 0?a.jsx(uy,{availableTools:e.availableTools,value:m,onChange:p,disabled:Ne}):null,a.jsxs("label",{children:[a.jsx("input",{type:"radio",name:ue("tools"),value:"auto",checked:U==="auto",onChange:()=>te("auto")})," Run without asking"]}),a.jsxs("label",{children:[a.jsx("input",{type:"radio",name:ue("tools"),value:"ask",checked:U==="ask",onChange:()=>te("ask")})," Ask me before each tool call (the run waits for you)"]}),we?a.jsx("p",{className:"af-auto__hint","data-email-rule":"untrusted",children:Ve.untrusted_hint}):null,U==="auto"?a.jsxs("p",{className:"af-schedule__consent","data-consent":"true",children:[vx,e.targetTools&&e.targetTools.length?`: ${e.targetTools.join(", ")}.`:"."]}):a.jsx("p",{className:"af-auto__hint",children:"Each tool call waits for your approval in the automation's timeline."})]}),e.workspaces?a.jsx("div",{className:"af-auto__field","data-field":"workspaces",role:"group","aria-label":"Workspaces",children:e.workspaces}):null,a.jsxs("fieldset",{className:"af-auto__field","data-field":"email",children:[a.jsx("legend",{children:"Mailbox"}),ae?null:a.jsx(uf,{status:e.emailStatus,onOpenMyEmail:e.onOpenMyEmail}),a.jsx(Vx,{notifyEmail:ae&&N,onNotifyEmailChange:$,recipients:ae?S:Ai,onRecipientsChange:E,disabled:!ae,idBase:n})]}),a.jsxs("fieldset",{className:"af-auto__field","data-field":"limits",children:[a.jsx("legend",{children:"Title and limits"}),a.jsxs("label",{className:"af-auto__field",htmlFor:ue("title"),children:[a.jsx("span",{children:"Title"}),a.jsx("input",{id:ue("title"),value:se,maxLength:120,onChange:ge=>G(ge.target.value),placeholder:"Defaults to the task's first line"})]}),Pe==="every"?a.jsxs(a.Fragment,{children:[a.jsxs("label",{className:"af-auto__field",htmlFor:ue("start"),children:[a.jsx("span",{children:"First run at (UTC; empty = now)"}),a.jsx("input",{id:ue("start"),type:"datetime-local",value:ce,onChange:ge=>re(ge.target.value)})]}),a.jsxs("label",{className:"af-auto__field",htmlFor:ue("count"),children:[a.jsx("span",{children:"Stop after this many runs"}),a.jsx("input",{id:ue("count"),type:"number",min:1,step:1,value:D,onChange:ge=>I(ge.target.value)})]}),a.jsxs("label",{className:"af-auto__field",htmlFor:ue("until"),children:[a.jsx("span",{children:"Stop at (UTC)"}),a.jsx("input",{id:ue("until"),type:"datetime-local",value:W,onChange:ge=>me(ge.target.value)})]})]}):null]}),q.length?a.jsx("ul",{className:"af-auto__form-errors",role:"alert",children:q.map(ge=>a.jsx("li",{children:ge},ge))}):null,He?a.jsxs("div",{className:"af-auto__error",role:"alert","data-code":(Ae=e.error)==null?void 0:Ae.code,children:[a.jsx("strong",{children:He.title})," ",a.jsx("span",{children:He.detail})]}):null,a.jsxs("div",{className:"af-appearance__actions af-auto__row",children:[a.jsx("button",{type:"button",className:"af-auto__btn",onClick:e.onClose,children:"Cancel"}),a.jsx("button",{type:"submit",className:"af-auto__btn af-auto__btn--primary",disabled:Ne,children:"Create automation"})]})]})]})})}const Sc=6e4,mf=60*Sc,xp=24*mf;function pf(e){const t=Math.abs(e);return Number.isFinite(t)?t<Sc?"<1 min":t<mf?`${Math.floor(t/Sc)} min`:t<2*xp?`${Math.floor(t/mf)} h`:`${Math.floor(t/xp)} d`:""}const ik={s:["second","s"],m:["minute","min"],h:["hour","h"],d:["day","d"]};function by(e){if(e.source_id==="schedule"){const t=e.config.every,n=po(t);if(!n)return typeof t=="string"?`every ${t}`:"once";if(n.unit==="s"&&n.amount%60===0)return by({...e,config:{every:`${n.amount/60}m`}});const[r,i]=ik[n.unit];return n.amount===1?`every ${r}`:`every ${n.amount} ${i}`}return e.source_id==="manual"?"manual":Fi(e)?"on new email":e.source_id}function _c(e){if(!e)return null;const t=Date.parse(e);return Number.isNaN(t)?null:t}function lk(e,t){var i;if(e.current_occurrence&&(((i=e.attention)==null?void 0:i.pending_waits)??0)>0){const c=e.last_occurrence&&e.last_occurrence.index===e.current_occurrence.index?_c(e.last_occurrence.fired_at):null;return c===null?"":`waiting since ${pf(Math.max(0,t-c))}`}if(e.current_occurrence)return"running now";const n=e.last_occurrence,r=_c(n==null?void 0:n.finished_at)??_c(n==null?void 0:n.fired_at);return r===null?"last never":`last ${pf(Math.max(0,t-r))} ago`}function ck(e,t){const n=_c(e.next_fire_at);return n===null?null:n-t<Sc?"next due now":`next in ${pf(n-t)}`}function xy(e,t){const n=by(e.trigger),r=lk(e,t),i=ck(e,t);return{cadence:n,last:r,next:i,line:[n,r,i].filter(Boolean).join(" · ")}}const ls={min:300,max:960,default:420,step:16,bigStep:64};function ca(e,t=ls.min,n=ls.max,r=ls.default){return Number.isFinite(e)?Math.round(Math.min(n,Math.max(t,e))):Math.min(n,Math.max(t,r))}function uk(e,t,n,r=ls.min,i=ls.max){const c=n?ls.bigStep:ls.step;return t==="ArrowLeft"?ca(e+c,r,i):t==="ArrowRight"?ca(e-c,r,i):t==="Home"?r:t==="End"?i:null}function dk(e,t,n){return e<=0?null:n==="ArrowDown"?(t+1)%e:n==="ArrowUp"?(t-1+e)%e:n==="Home"?0:n==="End"?e-1:null}function fk(e,t){return e===t?null:t}function hk(e,t,n,r){if(!e)return ca(t,n,r);try{const i=Number.parseInt(window.localStorage.getItem(e)||"",10);if(Number.isFinite(i))return ca(i,n,r,t)}catch{}return ca(t,n,r)}function mk(e){const t=e.minWidth??ls.min,n=e.maxWidth??ls.max,r=e.idBase||"af-rail",i=kc(Mi.md),c=e.overlay??i,[u,d]=y.useState(()=>typeof window>"u"?ca(e.defaultWidth??ls.default,t,n):hk(e.storageKey,e.defaultWidth??ls.default,t,n)),h=y.useRef(u);h.current=u;const[m,p]=y.useState(()=>new Set(e.active?[e.active]:[])),v=y.useRef(null),_=y.useRef(null),b=y.useRef(null),C=y.useRef(null),x=e.items.find(L=>L.id===e.active)||null,{onActiveChange:j}=e;y.useEffect(()=>{e.active&&p(L=>L.has(e.active)?L:new Set([...L,e.active]))},[e.active]);const N=y.useCallback(L=>{if(e.storageKey)try{window.localStorage.setItem(e.storageKey,String(Math.round(L)))}catch{}},[e.storageKey]);y.useEffect(()=>{if(!c||!x)return;const L=J=>{J.key!=="Escape"||J.defaultPrevented||(J.preventDefault(),j(null))};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[c,x,j]),y.useEffect(()=>{var L,J;c&&(x?(L=_.current)==null||L.focus({preventScroll:!0}):b.current&&document.activeElement&&((J=_.current)!=null&&J.contains(document.activeElement))&&b.current.focus())},[c,x]);const $=L=>{var ee,P;const J=Array.from(((ee=v.current)==null?void 0:ee.querySelectorAll('[role="tab"]'))||[]),V=J.findIndex(Z=>Z===document.activeElement),O=dk(J.length,V<0?0:V,L.key);O!==null&&(L.preventDefault(),(P=J[O])==null||P.focus())},S=L=>{const J=uk(h.current,L.key,L.shiftKey,t,n);J!==null&&(L.preventDefault(),d(J),N(J))},E=L=>{var J,V;L.button!==0&&L.pointerType==="mouse"||(C.current={startX:L.clientX,startW:h.current,pointerId:L.pointerId},(V=(J=L.currentTarget).setPointerCapture)==null||V.call(J,L.pointerId),L.preventDefault())},A=L=>{const J=C.current;!J||J.pointerId!==L.pointerId||d(ca(J.startW+(J.startX-L.clientX),t,n))},R=L=>{var V,O;const J=C.current;!J||J.pointerId!==L.pointerId||(C.current=null,(O=(V=L.currentTarget).releasePointerCapture)==null||O.call(V,L.pointerId),N(h.current))},z=!!x;return a.jsxs("div",{className:`af-rail${z?" af-rail--open":" af-rail--collapsed"}${c?" af-rail--overlay":" af-rail--docked"}${e.className?` ${e.className}`:""}`,style:{"--af-rail-panel-width":`${u}px`},"data-active":e.active||"",children:[c&&z?a.jsx("div",{className:"af-rail__backdrop","aria-hidden":"true",onClick:()=>j(null)}):null,a.jsxs("div",{className:"af-rail__panel-wrap",hidden:!z,style:!c&&z?{width:u}:void 0,children:[!c&&z?a.jsx("div",{className:"af-rail__resize",role:"separator","aria-orientation":"vertical","aria-label":`Resize the ${(x==null?void 0:x.label)||""} panel`,"aria-valuemin":t,"aria-valuemax":n,"aria-valuenow":u,tabIndex:0,title:"Drag to resize",onKeyDown:S,onPointerDown:E,onPointerMove:A,onPointerUp:R,onPointerCancel:R}):null,a.jsx("div",{ref:_,className:"af-rail__panel",role:c?"dialog":void 0,"aria-label":c?x==null?void 0:x.label:void 0,tabIndex:c?-1:void 0,children:e.items.map(L=>a.jsxs("section",{id:`${r}-panel-${L.id}`,role:"tabpanel","aria-labelledby":`${r}-tab-${L.id}`,className:"af-rail__section","data-panel":L.id,hidden:L.id!==e.active,children:[a.jsxs("header",{className:"af-rail__head",children:[a.jsx("h2",{className:"af-rail__title",children:L.label}),a.jsxs("span",{className:"af-rail__head-actions",children:[L.headerActions,a.jsx("button",{type:"button",className:"af-rail__icon-btn","data-action":"collapse-panel","aria-label":`Collapse ${L.label}`,title:"Collapse",onClick:()=>j(null),children:a.jsx(ne,{name:c?"x":"chevronRight",size:16})})]})]}),a.jsx("div",{className:"af-rail__body",children:m.has(L.id)||L.id===e.active?L.content:null})]},L.id))})]}),a.jsx("div",{ref:v,className:"af-rail__rail",role:"tablist","aria-orientation":"vertical","aria-label":e.ariaLabel,onKeyDown:$,children:e.items.map(L=>{const J=L.id===e.active,V=`${J?`Collapse ${L.label}`:L.label}${L.hint?` · ${L.hint}`:""}`;return a.jsxs("button",{type:"button",role:"tab",id:`${r}-tab-${L.id}`,"aria-selected":J,"aria-controls":`${r}-panel-${L.id}`,"aria-label":L.label,title:V,className:`af-rail__tab${J?" is-active":""}`,"data-rail":L.id,onClick:O=>{b.current=O.currentTarget,j(fk(e.active,L.id))},children:[a.jsx(ne,{name:L.icon,size:19}),typeof L.badge=="number"&&L.badge>0?a.jsx("span",{className:"af-rail__badge","aria-hidden":"true",children:L.badge>99?"99+":L.badge}):L.badge===!0?a.jsx("span",{className:"af-rail__dot","aria-hidden":"true"}):null]},L.id)})})]})}const ky=72;function pk(e,t=ky){const n=Math.max(1,Math.floor(t)),r=new Array(n).fill(0),i=e.length;if(!i)return r;const c=i/n;let u=0;for(let d=0;d<n;d+=1){const h=Math.floor(d*c),m=Math.max(h+1,Math.floor((d+1)*c));let p=0;for(let v=h;v<m&&v<i;v+=1){const _=Math.abs(Number(e[v])||0);_>p&&(p=_)}r[d]=p,p>u&&(u=p)}return u<=0?r:r.map(d=>d/u)}function cc(e){if(typeof e!="number"||!Number.isFinite(e)||e<0)return"--:--";const t=Math.floor(e),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=String(t%60).padStart(2,"0");return n>0?`${n}:${String(r).padStart(2,"0")}:${i}`:`${r}:${i}`}function gk(e,t,n){return!(t>0)||!(n>0)?0:Math.min(n,Math.max(0,e/t*n))}function yk(e,t){const[n,r]=y.useState({peaks:t??null,note:""});return y.useEffect(()=>{if(t){r({peaks:t,note:""});return}let i=!0;r({peaks:null,note:""});const c=typeof window<"u"?window.AudioContext||window.webkitAudioContext:void 0;if(!e||!c||typeof fetch!="function"){r({peaks:null,note:"Waveform unavailable in this browser."});return}return(async()=>{let u=null;try{const d=await(await fetch(e)).arrayBuffer();u=new c;const h=await u.decodeAudioData(d);i&&r({peaks:pk(h.getChannelData(0)),note:""})}catch(d){i&&r({peaks:null,note:`Waveform unavailable: ${d instanceof Error?d.message:String(d)}`})}finally{u&&u.close().catch(()=>{})}})(),()=>{i=!1}},[e,t]),n}function jy(e){const t=y.useRef(null),n=y.useRef(null),[r,i]=y.useState(!1),[c,u]=y.useState(0),[d,h]=y.useState(null),[m,p]=y.useState(""),{peaks:v,note:_}=yk(e.src,e.peaks),b=v??new Array(ky).fill(0),C=d&&d>0?Math.min(1,c/d):0,x=e.name?`Audio ${e.name}`:"Audio",j=y.useCallback(()=>{const E=t.current;E&&(E.paused?E.play().catch(A=>p(A instanceof Error?A.message:String(A))):E.pause())},[]),N=y.useCallback(E=>{const A=t.current;!A||!Number.isFinite(E)||(A.currentTime=E,u(E))},[]),$=E=>{var R;const A=(R=n.current)==null?void 0:R.getBoundingClientRect();!A||!d||N(gk(E-A.left,A.width,d))},S=E=>{if(!d)return;const A=E.key==="ArrowRight"||E.key==="ArrowUp"?5:E.key==="ArrowLeft"||E.key==="ArrowDown"?-5:0;A?(E.preventDefault(),N(Math.min(d,Math.max(0,c+A)))):E.key==="Home"?(E.preventDefault(),N(0)):E.key==="End"?(E.preventDefault(),N(d)):(E.key===" "||E.key==="Enter")&&(E.preventDefault(),j())};return a.jsxs("div",{className:`af-audio${e.className?` ${e.className}`:""}`,"data-playing":r?"true":"false",children:[a.jsx("audio",{ref:t,src:e.src,preload:"metadata",onPlay:()=>i(!0),onPause:()=>i(!1),onEnded:()=>i(!1),onTimeUpdate:E=>u(E.currentTarget.currentTime),onLoadedMetadata:E=>h(Number.isFinite(E.currentTarget.duration)?E.currentTarget.duration:null),onDurationChange:E=>h(Number.isFinite(E.currentTarget.duration)?E.currentTarget.duration:null),onError:()=>p("This audio cannot be played in this browser. Use Download to open it.")}),a.jsx("button",{type:"button",className:"af-audio__play","data-action":r?"pause-audio":"play-audio","aria-label":r?`Pause ${x}`:`Play ${x}`,title:r?"Pause":"Play",onClick:j,children:a.jsx(ne,{name:r?"pause":"play",size:16})}),a.jsx("div",{ref:n,className:"af-audio__wave",role:"slider",tabIndex:0,"aria-label":`Seek in ${x}`,"aria-valuemin":0,"aria-valuemax":Math.round(d??0),"aria-valuenow":Math.round(c),"aria-valuetext":`${cc(c)} of ${cc(d)}`,title:_||void 0,"data-waveform":v?"decoded":"flat",onKeyDown:S,onPointerDown:E=>{var A,R;(R=(A=E.currentTarget).setPointerCapture)==null||R.call(A,E.pointerId),$(E.clientX)},onPointerMove:E=>{E.buttons&1&&$(E.clientX)},children:a.jsx("svg",{viewBox:`0 0 ${b.length*2} 32`,preserveAspectRatio:"none","aria-hidden":"true",focusable:"false",children:b.map((E,A)=>{const R=Math.max(1.5,E*30),z=(A+.5)/b.length<=C;return a.jsx("rect",{className:z?"af-audio__bar af-audio__bar--played":"af-audio__bar",x:A*2+.3,y:16-R/2,width:1.4,height:R,rx:.6},A)})})}),a.jsxs("span",{className:"af-audio__time","aria-hidden":"true",children:[cc(c)," / ",cc(d)]}),m?a.jsx("p",{className:"af-audio__error",role:"alert",children:m}):null]})}const fa=e=>new Set(e.split(/\s+/).filter(Boolean)),wk=fa("if else for while do switch case default break continue return function const let var class extends new this super import export from as async await try catch finally throw typeof instanceof in of void delete yield static public private protected interface type enum implements package struct fn impl trait pub use mod mut match loop where crate self Self func go defer chan map range select int long short char float double bool boolean string true false null nil undefined None True False namespace using template typename virtual override final abstract sealed record val object fun when is"),vk=fa("def class return if elif else for while in not and or is import from as with try except finally raise pass break continue lambda yield global nonlocal assert del async await None True False self match case"),_k=fa("if then else elif fi for while do done case esac in function return export local readonly set unset echo exit source"),bk=fa("select from where insert into values update set delete create table index view drop alter add join left right inner outer on group by order having limit offset as and or not null is in like between union all distinct primary key foreign references default"),kp=fa("true false null yes no on off"),xk={c:{line:["//"],block:["/*","*/"],strings:['"',"'","`"],keywords:wk},python:{line:["#"],strings:['"',"'"],triple:!0,keywords:vk},shell:{line:["#"],strings:['"',"'"],keywords:_k},sql:{line:["--"],block:["/*","*/"],strings:["'",'"'],keywords:bk},data:{line:["#"],strings:['"',"'"],keywords:kp},json:{line:[],strings:['"'],keywords:kp},css:{line:[],block:["/*","*/"],strings:['"',"'"],keywords:fa("")},markup:{line:[],block:["<!--","-->"],strings:['"',"'"],keywords:fa("")}},kk={js:"c",mjs:"c",cjs:"c",jsx:"c",ts:"c",tsx:"c",java:"c",kt:"c",c:"c",h:"c",cc:"c",cpp:"c",hpp:"c",cs:"c",go:"c",rs:"c",swift:"c",scala:"c",dart:"c",php:"c",py:"python",pyi:"python",rb:"shell",sh:"shell",bash:"shell",zsh:"shell",fish:"shell",ps1:"shell",sql:"sql",yaml:"data",yml:"data",toml:"data",ini:"data",cfg:"data",conf:"data",env:"data",json:"json",jsonl:"json",css:"css",scss:"css",less:"css",html:"markup",htm:"markup",xml:"markup",svg:"markup",vue:"markup",javascript:"c",typescript:"c",rust:"c",python:"python",shell:"shell"};function Mf(e){const t=String(e||"").trim().toLowerCase(),n=t.split("/").pop()||t;if(n==="dockerfile"||n==="makefile")return"shell";const r=n.lastIndexOf("."),i=r>=0?n.slice(r+1):n;return kk[i]||""}const jk=e=>e>="0"&&e<="9",Sk=e=>/[A-Za-z_$]/.test(e),jp=e=>/[A-Za-z0-9_$]/.test(e);function Sy(e,t){const n=String(e??""),r=xk[t];if(!r)return n?[{kind:"plain",text:n}]:[];const i=[];let c="";const u=(h,m)=>{if(m){if(h==="plain"){c+=m;return}c&&i.push({kind:"plain",text:c}),c="",i.push({kind:h,text:m})}};let d=0;for(;d<n.length;){const h=n[d];if(r.line.find(p=>n.startsWith(p,d))){const p=n.indexOf(`
|
|
61
|
+
`,d),v=p===-1?n.length:p;u("comment",n.slice(d,v)),d=v;continue}if(r.block&&n.startsWith(r.block[0],d)){const p=n.indexOf(r.block[1],d+r.block[0].length),v=p===-1?n.length:p+r.block[1].length;u("comment",n.slice(d,v)),d=v;continue}if(r.strings.includes(h)){const p=r.triple&&n.startsWith(h.repeat(3),d)?h.repeat(3):"";if(p){const b=n.indexOf(p,d+3),C=b===-1?n.length:b+3;u("string",n.slice(d,C)),d=C;continue}let v=d+1;for(;v<n.length&&n[v]!==h&&(h==="`"||n[v]!==`
|
|
62
|
+
`);)v+=n[v]==="\\"?2:1;const _=Math.min(n.length,v+1);u("string",n.slice(d,_)),d=_;continue}if(jk(h)&&!(d>0&&jp(n[d-1]))){let p=d+1;for(;p<n.length&&/[0-9a-fA-FxXoObB._]/.test(n[p]);)p+=1;u("number",n.slice(d,p)),d=p;continue}if(Sk(h)){let p=d+1;for(;p<n.length&&jp(n[p]);)p+=1;const v=n.slice(d,p),_=t==="sql"?r.keywords.has(v.toLowerCase()):r.keywords.has(v);u(_?"keyword":"plain",v),d=p;continue}u("plain",h),d+=1}return c&&i.push({kind:"plain",text:c}),i}function uc({text:e,language:t="",lineNumbers:n=!0,className:r,ariaLabel:i}){const c=Mf(t),u=Sy(e,c),d=n?String(e??"").split(`
|
|
63
|
+
`).length:0;return a.jsx("pre",{className:`af-code${n?" af-code--numbered":""}${r?` ${r}`:""}`,"data-language":c||"text","aria-label":i,style:n?{"--af-code-gutter":`${String(d).length+1}ch`}:void 0,children:a.jsx("code",{children:n?Nk(u).map((h,m)=>a.jsxs("span",{className:"af-code__line","data-line":m+1,children:[h.map((p,v)=>Sp(p,v)),`
|
|
64
|
+
`]},m)):u.map((h,m)=>Sp(h,m))})})}function Sp(e,t){return e.kind==="plain"?a.jsx(lt.Fragment,{children:e.text},t):a.jsx("span",{className:`af-code__${e.kind}`,children:e.text},t)}function Nk(e){const t=[[]];for(const n of e)n.text.split(`
|
|
65
|
+
`).forEach((i,c)=>{c>0&&t.push([]),i&&t[t.length-1].push({kind:n.kind,text:i})});return t}const Ny=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],xi=6e4,ki=60*xi,dc=24*ki;function Bi(e){if(e==null||e==="")return NaN;if(e instanceof Date)return e.getTime();if(typeof e=="number")return Number.isFinite(e)?e<1e12?e*1e3:e:NaN;const t=String(e).trim();return/^\d+(\.\d+)?$/.test(t)?Bi(Number(t)):Date.parse(t)}function Np(e){return e<10?`0${e}`:String(e)}function Cp(e,t){const n=Bi(e);if(!Number.isFinite(n))return"";const r=new Date(n),i=r.getFullYear()===new Date(t).getFullYear();return`${Ny[r.getMonth()]} ${r.getDate()}${i?"":`, ${r.getFullYear()}`}`}function Vc(e){const t=Bi(e);if(!Number.isFinite(t))return"";const n=new Date(t);return`${Ny[n.getMonth()]} ${n.getDate()}, ${n.getFullYear()}, ${Np(n.getHours())}:${Np(n.getMinutes())}`}function fo(e,t){const n=Bi(e);if(!Number.isFinite(n)||!Number.isFinite(t))return"";const r=t-n;if(r<0){const c=-r;if(c<xi)return"due now";if(c<ki)return`in ${Math.round(c/xi)} min`;if(c<dc)return`in ${Math.round(c/ki)} h`;const u=Math.round(c/dc);return u<7?`in ${u} ${u===1?"day":"days"}`:Cp(n,t)}if(r<xi)return"just now";if(r<ki)return`${Math.floor(r/xi)} min ago`;if(r<dc)return`${Math.floor(r/ki)} h ago`;const i=Math.floor(r/dc);return i===1?"yesterday":i<7?`${i} days ago`:Cp(n,t)}const Ck=new Set("png jpg jpeg gif webp bmp ico avif".split(" ")),Ek=new Set("mp3 wav ogg oga opus m4a aac flac weba".split(" ")),$k=new Set("txt log csv tsv rst adoc org tex diff patch lock".split(" "));function Ak(e){const t=String(e||"").split("/").pop()||"",n=t.lastIndexOf(".");return n>0?t.slice(n+1).toLowerCase():t.toLowerCase()}function Nc(e,t=""){const n=Ak(e),r=String(t||"").split(";",1)[0].trim().toLowerCase();return n==="md"||n==="markdown"||r==="text/markdown"?"markdown":n==="json"||r==="application/json"||r.endsWith("+json")?"json":n==="pdf"||r==="application/pdf"?"pdf":Ck.has(n)||r.startsWith("image/")&&r!=="image/svg+xml"?"image":Ek.has(n)||r.startsWith("audio/")?"audio":Mf(e)?"code":$k.has(n)||r.startsWith("text/")?"text":["application/javascript","application/xml","application/x-yaml","application/toml"].includes(r)?"code":"binary"}function gf(e){return e==="markdown"||e==="code"||e==="json"||e==="text"}function Hc(e){if(typeof e!="number"||!Number.isFinite(e)||e<0)return"";if(e<1024)return`${e} B`;const t=["KiB","MiB","GiB","TiB"];let n=e/1024,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n<10?n.toFixed(1):Math.round(n)} ${t[r]}`}function Tk(e){const t=e.kind??Nc(e.name,e.contentType),n=Hc(e.sizeBytes),r=e.modified!==void 0?fo(e.modified,e.nowMs):"";return a.jsxs("section",{className:`af-file-viewer${e.className?` ${e.className}`:""}`,"aria-label":`Preview of ${e.name}`,"data-kind":t,children:[a.jsxs("header",{className:"af-file-viewer__head",children:[a.jsx(ne,{name:"file",size:15}),a.jsxs("span",{className:"af-file-viewer__title",children:[a.jsx("strong",{className:"af-file-viewer__name",title:e.path||e.name,children:e.name}),n||r?a.jsxs("span",{className:"af-file-viewer__meta",children:[n?a.jsx("span",{"data-meta":"size",children:n}):null,n&&r?a.jsx("span",{"aria-hidden":"true",children:" · "}):null,r?a.jsx("time",{"data-meta":"modified",title:Vc(e.modified),dateTime:new Date(Bi(e.modified)).toISOString(),children:r}):null]}):null]}),e.actions,e.onDownload?a.jsx("button",{type:"button",className:"af-file-viewer__icon-btn","data-action":"download-file",onClick:e.onDownload,title:"Download","aria-label":`Download ${e.name}`,children:a.jsx(ne,{name:"download",size:15})}):null,e.onClose?a.jsx("button",{type:"button",className:"af-file-viewer__icon-btn","data-action":"close-preview",onClick:e.onClose,title:"Close","aria-label":"Close the preview",children:a.jsx(ne,{name:"x",size:15})}):null]}),a.jsx("div",{className:"af-file-viewer__body",children:e.status==="loading"?a.jsx("p",{className:"af-file-viewer__muted",role:"status",children:"Loading preview…"}):e.status==="error"?a.jsx("p",{className:"af-file-viewer__error",role:"alert",children:e.error||"The preview could not be loaded."}):a.jsxs(a.Fragment,{children:[e.partialNote?a.jsx("p",{className:"af-file-viewer__muted",role:"status",children:e.partialNote}):null,a.jsx(Rk,{kind:t,p:e})]})})]})}function Rk({kind:e,p:t}){const n=t.text??"";switch(e){case"image":return t.url?a.jsx("img",{className:"af-file-viewer__image",src:t.url,alt:t.name}):a.jsx(fc,{});case"audio":return t.url?a.jsx(jy,{src:t.url,name:t.name}):a.jsx(fc,{});case"pdf":return t.url?a.jsx("object",{className:"af-file-viewer__pdf",data:t.url,type:"application/pdf","aria-label":t.name,children:a.jsx("p",{className:"af-file-viewer__muted",children:"This browser cannot show PDFs inline. Use Download to open it."})}):a.jsx(fc,{});case"markdown":return t.renderMarkdown?a.jsx("div",{className:"af-file-viewer__markdown",children:t.renderMarkdown(n)}):a.jsx(uc,{text:n,language:""});case"json":{let r=n,i="";try{r=JSON.stringify(JSON.parse(n),null,2)}catch{i=t.partialNote?"":"Not valid JSON; shown as text."}return a.jsxs(a.Fragment,{children:[i?a.jsx("p",{className:"af-file-viewer__muted",children:i}):null,a.jsx(uc,{text:r,language:"json"})]})}case"code":return a.jsx(uc,{text:n,language:t.name});case"text":return a.jsx(uc,{text:n,language:"",lineNumbers:!1});default:return a.jsx(fc,{})}}function fc(){return a.jsx("p",{className:"af-file-viewer__muted",children:"No preview for this file type. Use Download to open it."})}function ji(e){const t=y.useId(),n=`${e.id||t}-title`;return a.jsxs("section",{className:`af-settings-group${e.variant==="flat"?" af-settings-group--flat":""}${e.className?` ${e.className}`:""}`,"aria-labelledby":n,id:e.id,children:[a.jsxs("div",{className:"af-settings-group__head",children:[a.jsx("h3",{className:"af-settings-group__title",id:n,children:e.title}),e.aside?a.jsx("span",{className:"af-settings-group__aside",children:e.aside}):null]}),e.help?a.jsx("p",{className:"af-settings-group__help",children:e.help}):null,a.jsx("div",{className:"af-settings-group__rows",children:e.children})]})}function oa(e){const t=e.htmlFor?"label":"span";return a.jsxs("div",{className:`af-setting-row${e.stack?" af-setting-row--stack":""}${e.className?` ${e.className}`:""}`,"data-setting":e.setting,children:[a.jsxs("div",{className:"af-setting-row__label",children:[a.jsx(t,{className:"af-setting-row__name",...e.htmlFor?{htmlFor:e.htmlFor}:{},children:e.label}),e.help?a.jsx("span",{className:"af-setting-row__help",children:e.help}):null]}),e.children!==void 0||e.trailing?a.jsxs("div",{className:"af-setting-row__control",children:[e.children,e.trailing?a.jsx("span",{className:"af-setting-row__trailing",children:e.trailing}):null]}):null]})}function Ep(e){const t=!!e.overrideSummary,n=y.useId(),r=t?`${e.overrideSummary}${e.overrideOwner?` — ${e.overrideOwner}`:""}`:`Gateway default${e.defaultSummary?` · ${e.defaultSummary}`:""}`;return a.jsxs("div",{className:"af-override","data-setting":e.setting,"data-overridden":t?"true":"false",children:[a.jsx(oa,{label:e.label,help:e.help,trailing:a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:"af-setting-btn","data-action":"change","aria-expanded":e.open,"aria-controls":n,disabled:e.disabled,onClick:e.onToggle,children:e.open?"Done":"Change"}),t&&e.onReset?a.jsx("button",{type:"button",className:"af-setting-btn af-setting-btn--quiet","data-action":"use-default",disabled:e.disabled,onClick:e.onReset,children:"Use gateway default"}):null]}),children:a.jsx("span",{className:"af-override__summary",title:r,children:r})}),a.jsx("div",{className:"af-override__editor",id:n,hidden:!e.open,children:e.open?e.children:null})]})}const tt={title:"Workspaces",gatewayTitle:"Eligible workspaces",gatewayHelp:"The workspaces accounts may choose from, and the most each one allows.",accountHelp:"The workspaces this account's agents use, among the eligible ones.",sessionHelp:"The workspaces this conversation uses, among the eligible ones.",runHelp:"The workspaces this run uses, among the eligible ones.",gatewayPrefix:"Gateway:",postureLabel:"Workspaces agents may use",postureAllowedOnly:"Deny everything, allow listed workspaces",postureAllowedOnlyHelp:"Agents may only work in the listed workspaces.",postureAnyExceptDenied:"Allow everything, refuse listed workspaces",postureAnyExceptDeniedHelp:"Agents may work in any workspace except the refused ones.",accessLabel:"Permission",accessRead:"Read-only",accessReadWrite:"Read & write",accessDenied:"Refused",capReadOnly:"The gateway allows this workspace read-only",capRefused:"The gateway refuses this workspace",everythingElse:"Everything else",allowedTitle:"Allowed workspaces",deniedTitle:"Refused workspaces",builtinRefused:"Always refused: the gateway's own data and credentials",emptyAllowed:"No workspace is listed: agents only use their private workspace.",privateNote:"The private workspace of each run is always available, read & write.",addPlaceholder:"Add a workspace path",add:"Add",choose:"Choose…",remove:"Remove",followGateway:"Follow the gateway policy",followGatewayHelp:"On: this account gets exactly what the gateway allows.",useDefault:"Use my default",useDefaultHelp:"On: the account's default workspaces apply.",locked:"These workspaces can be seen here but not changed.",loading:"Loading…",saved:"Saved",notSaved:"Not saved."},ln=tt;function Ik(e){return e==="any_except_denied"?ln.postureAnyExceptDenied:ln.postureAllowedOnly}function Mk(e){return e==="any_except_denied"?ln.postureAnyExceptDeniedHelp:ln.postureAllowedOnlyHelp}function $p(e){return e==="ro"?ln.accessRead:e==="deny"?ln.accessDenied:ln.accessReadWrite}function Lk(e){return e==="gateway"?ln.gatewayHelp:e==="account"?ln.accountHelp:e==="session"?ln.sessionHelp:ln.runHelp}const Ap={deny:0,ro:1,rw:2},Pd=["rw","ro","deny"];function Ok(e){if(e===null)return{allowed:[...Pd],reasons:{}};const t=e==="deny"?ln.capRefused:ln.capReadOnly,n=Pd.filter(i=>Ap[i]<=Ap[e]),r={};for(const i of Pd)n.includes(i)||(r[i]=t);return{allowed:n,reasons:r}}function Pk(e,t){const{policy:n}=t,r=t.effective;if(e==="gateway"?typeof n.summary!="string":!r)throw new Error(e==="gateway"?"The gateway workspace policy has no summary line.":`A ${e}-level workspace chooser needs the gateway's effective workspaces.`);const i=e!=="gateway"&&n.configured===!1,c=t.can_edit===!1,u=new Map(((r==null?void 0:r.folders)??[]).map(b=>[b.path,b.cap])),d=r,h=i?d.folders.map(b=>({path:b.path,mode:b.mode})):n.folders,m=i?d.posture:n.posture,p=i?d.default_mode??n.default_mode:n.default_mode,v=!i&&!c,_=h.map(b=>{const C=e==="gateway"?null:u.get(b.path)??null,{allowed:x,reasons:j}=Ok(C);return{path:b.path,mode:b.mode,cap:C,allowed:x,reasons:j,builtin:!1,editable:v}});if(e==="gateway")for(const b of n.builtin_refused??[])_.push({path:b,mode:"deny",cap:null,allowed:[],reasons:{},builtin:!0,editable:!1});return{level:e,posture:m,following:i,rows:_,everythingElse:m==="any_except_denied"?{mode:p,editable:v}:null,canAdd:v,gatewayLine:e==="gateway"?null:`${ln.gatewayPrefix} ${d.gateway_summary}`,summary:e==="gateway"?n.summary:d.summary,locked:c}}function Dk(e,t){return t==="any_except_denied"?"deny":e==="gateway"?"rw":"ro"}function Wi(e,t){const n={posture:t.posture,default_mode:t.default_mode,folders:t.folders.map(r=>({path:r.path,mode:r.mode}))};return e==="gateway"?n:{configured:!0,...n}}function Fk(e,t,n,r){return Wi(e,{...t,folders:t.folders.map(i=>i.path===n?{path:n,mode:r}:i)})}function zk(e,t,n){return Wi(e,{...t,posture:n})}function Uk(e,t,n){return Wi(e,{...t,default_mode:n})}function Bk(e,t,n,r){const i=String(n).trim();return Wi(e,{...t,folders:[...t.folders,{path:i,mode:Dk(e,t.posture)}]})}function Wk(e,t,n){return Wi(e,{...t,folders:t.folders.filter(r=>r.path!==n)})}function Vk(e,t){if(t)return{configured:!1};const n=e.effective;if(!n)throw new Error("The follow switch needs the gateway's effective workspaces.");return{configured:!0,posture:n.posture,default_mode:n.default_mode??e.policy.default_mode,folders:n.folders.map(r=>({path:r.path,mode:r.mode}))}}function Cy(e){let t=String(e||"");for(;t.endsWith("/");)t=t.slice(0,-1);return t}function Hk(e,t=Rr){const n=Cy(t);if(e.level==="gateway")return`${n}/workspace/policy`;if(e.level==="account")return`${n}/workspace/policy/${encodeURIComponent(e.account||"me")}`;if(!e.session)throw new Error("A session-level workspace chooser needs the session id.");return`${n}/sessions/${encodeURIComponent(e.session)}/workspaces${e.account?`?account=${encodeURIComponent(e.account)}`:""}`}function Gk(e="me",t=Rr){return`${Cy(t)}/workspace/effective/${encodeURIComponent(e)}`}const yf=e=>e==="ro"||e==="rw"||e==="deny",Ey=e=>e==="ro"||e==="rw",$y=e=>e==="allowed_only"||e==="any_except_denied",Kk=e=>Array.isArray(e)&&e.every(t=>t&&typeof t.path=="string"&&yf(t.mode)),Cc="The gateway answered with an older workspace model (it needs the round-11 workspace API).";function Jk(e,t){const n=e&&typeof e=="object"?e:{},r=n.policy&&typeof n.policy=="object"?n.policy:{};if("shared_workspace"in r||"shared_workspace"in n)throw new Error(Cc);if(!($y(r.posture)&&Ey(r.default_mode)&&Kk(r.folders)&&(t==="gateway"?typeof r.summary=="string":typeof r.configured=="boolean")&&(r.builtin_refused===void 0||Array.isArray(r.builtin_refused)&&r.builtin_refused.every(c=>typeof c=="string"))))throw new Error(`The gateway answered without a workspace policy (policy.posture, default_mode, folders, ${t==="gateway"?"summary":"configured"}). ${Cc}`);return{...typeof r.account=="string"?{account:r.account}:{},...t==="gateway"?{summary:r.summary}:{configured:r.configured},posture:r.posture,default_mode:r.default_mode,folders:r.folders.map(c=>({path:c.path,mode:c.mode})),...Array.isArray(r.builtin_refused)?{builtin_refused:[...r.builtin_refused]}:{}}}function Ay(e){const t=e&&typeof e=="object"?e:{};if("shared_workspace"in t)throw new Error(Cc);if(!($y(t.posture)&&(Ey(t.default_mode)||t.default_mode===null&&t.posture==="allowed_only")&&typeof t.summary=="string"&&typeof t.gateway_summary=="string"&&Array.isArray(t.folders)&&t.folders.every(r=>r&&typeof r.path=="string"&&yf(r.mode)&&yf(r.cap))))throw new Error(`The gateway answered without the effective workspaces (posture, default_mode, folders with cap, summary, gateway_summary). ${Cc}`);return{posture:t.posture,default_mode:t.default_mode,folders:t.folders.map(r=>({path:r.path,mode:r.mode,cap:r.cap,source:r.source})),summary:t.summary,gateway_summary:t.gateway_summary}}function Tp(e,t){const n=Jk(e,t),r=e;return{policy:n,effective:t==="gateway"?null:Ay(r.effective),...typeof r.can_edit=="boolean"?{can_edit:r.can_edit}:{}}}function Rp(e,t,n=Rr){const r=Hk(t,n);return{path:r,load:async()=>Tp(await e(r,{method:"GET"}),t.level),save:async i=>Tp(await e(r,{method:"PUT",body:i}),t.level)}}function wf(e,t="me",n=Rr){const r=Gk(t,n);return async(i,c)=>Ay(await e(r,{method:"POST",body:c?{workspace:i,session:c}:{workspace:i}}))}function Lf(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;const t=e&&typeof e=="object"?e:{},n=t.detail;return n&&typeof n=="object"&&typeof n.message=="string"?n.message:typeof n=="string"?n:typeof t.message=="string"?t.message:""}function Ip(e){const t=Lf(e).trim()||"The gateway refused the change.";return`${t}${/[.!?]$/.test(t)?"":"."} ${ln.notSaved}`}const Qk=e=>!!e&&typeof e=="object"&&"policy"in e&&"effective"in e;function Yk(e,t){return t?{policy:e?{configured:!0,posture:e.posture,default_mode:e.default_mode,folders:e.folders.map(n=>({...n}))}:{configured:!1,posture:t.posture,default_mode:t.default_mode??"rw",folders:[]},effective:t}:null}function Of(e){mo();const t=e.idPrefix||"af-workspace",[n,r]=y.useState(null),[i,c]=y.useState({}),[u,d]=y.useState(null),[h,m]=y.useState(""),[p,v]=y.useState(null),_=String(e.unavailableReason||"").trim(),b=e.level,C=e.level==="run"?Yk(e.value,e.effective):e.state,x=e.level==="run"?e.effective:e.state,j=p&&p.base===x?p.value:C,N=j?Pk(b,j):null,$=U=>{if(e.level==="run"){const te=e,se=U.configured===!1?null:{posture:U.posture,default_mode:U.default_mode,folders:U.folders};return Promise.resolve(te.onChange(se))}return e.save(U)};async function S(U,te){if(n!==null||_)return!1;r(U),d(null),c(se=>{const G={...se};return delete G[U],G});try{const se=await $(te);return Qk(se)&&v({base:x,value:se}),d(U),!0}catch(se){return c(G=>({...G,[U]:Ip(se)})),!1}finally{r(null)}}const E=U=>i[U]?a.jsx("span",{className:"af-workspace__refusal",role:"alert","data-workspace":"refusal",children:i[U]}):u===U?a.jsx("span",{className:"af-workspace__saved",role:"status","data-workspace":"saved",children:tt.saved}):null,A=(U,te)=>a.jsx("span",{className:"af-workspace__access-tag","data-workspace":"access","data-access":U,"data-af-tip":te,tabIndex:te?0:void 0,children:$p(U)}),R=(U,te,se,G,ce)=>a.jsx("span",{className:"af-workspace__access",role:"group","aria-label":U,"data-workspace":ce,"data-access":te,children:se.map(re=>{const D=!!re.reason||!!_;return a.jsx("button",{type:"button",className:"af-workspace__access-btn","aria-pressed":te===re.value?"true":"false","aria-disabled":D?"true":void 0,"data-af-tip":re.reason||void 0,"data-action":`${ce}-${re.value}`,onClick:()=>D||n!==null||re.value===te?void 0:G(re.value),children:re.text},re.value)})}),z=U=>{if(U.builtin)return A("deny",tt.builtinRefused);if(!U.editable||!j)return A(U.mode);const te=j.policy;return a.jsxs(a.Fragment,{children:[R(`${tt.accessLabel} ${U.path}`,U.mode,["rw","ro","deny"].map(se=>({value:se,text:$p(se),reason:U.reasons[se]})),se=>void S(U.path,Fk(b,te,U.path,se)),"workspace-mode"),a.jsx("button",{type:"button",className:"af-workspace__icon-btn","data-action":"workspace-remove","aria-label":`${tt.remove} ${U.path}`,"data-af-tip":`${tt.remove} ${U.path}`,"aria-disabled":_||n!==null?"true":void 0,onClick:()=>_||n!==null?void 0:void S(U.path,Wk(b,te,U.path)),children:a.jsx(ne,{name:"x",size:16})})]})};async function L(U){if(!j||!N||!N.canAdd)return;const te=U.trim();te&&await S("add",Bk(b,j.policy,te))&&m("")}async function J(){if(!e.choose||n!==null||_)return;let U;try{U=await e.choose()}catch(te){c(se=>({...se,add:Ip(te)}));return}U&&await L(U)}const V=N?N.rows.filter(U=>U.mode!=="deny"):[],O=N?N.rows.filter(U=>U.mode==="deny"):[],ee=U=>a.jsxs("li",{className:"af-workspace__row","data-workspace":U.builtin?"builtin":"row","data-path":U.path,"data-mode":U.mode,"data-cap":U.cap??void 0,children:[a.jsx("code",{className:"af-workspace__path",children:U.path}),a.jsx("span",{className:"af-workspace__controls",children:z(U)}),E(U.path)]},`${U.builtin?"builtin:":""}${U.path}`),P=b==="account"?tt.followGateway:tt.useDefault,Z=b==="account"?tt.followGatewayHelp:tt.useDefaultHelp;return a.jsx(ji,{id:t,className:`af-workspace af-workspace--${b}${e.className?` ${e.className}`:""}`,title:b==="gateway"?tt.gatewayTitle:tt.title,help:Lk(b),children:e.loadError?a.jsx("p",{className:"af-workspace__refusal",role:"alert","data-workspace":"load-error",children:e.loadError}):!N||!j?a.jsx("p",{className:"af-workspace__note","data-workspace":"loading",children:tt.loading}):a.jsxs("div",{className:"af-workspace__body","data-level":b,"data-following":N.following?"true":"false",children:[N.gatewayLine?a.jsx("p",{className:"af-workspace__gateway","data-workspace":"gateway-line",children:N.gatewayLine}):null,_?a.jsx("p",{className:"af-workspace__note",id:`${t}-blocked`,"data-workspace":"blocked",children:_}):null,b!=="gateway"?a.jsxs("div",{className:"af-workspace__follow","data-workspace":"follow",children:[a.jsx(Mr,{variant:"row",label:P,description:Z,checked:N.following,busy:n==="follow",unavailableReason:_||(N.locked?tt.locked:null),reasonVisible:!1,describedBy:_?`${t}-blocked`:void 0,action:b==="account"?"workspace-follow-gateway":"workspace-use-default",onChange:U=>void S("follow",Vk(j,U))}),E("follow")]}):null,a.jsxs("div",{className:"af-workspace__posture","data-workspace":"posture","data-posture":N.posture,children:[N.following||N.locked?a.jsx("span",{className:"af-workspace__badge",children:Ik(N.posture)}):R(tt.postureLabel,N.posture,[{value:"allowed_only",text:tt.postureAllowedOnly},{value:"any_except_denied",text:tt.postureAnyExceptDenied}],U=>void S("posture",zk(b,j.policy,U)),"workspace-posture"),a.jsx("span",{className:"af-workspace__note","data-workspace":"posture-help",children:Mk(N.posture)}),E("posture")]}),a.jsxs("ul",{className:"af-workspace__list","aria-label":tt.title,"data-workspace":"list",children:[V.length?a.jsx("li",{className:"af-workspace__caption","data-workspace":"caption-allowed",children:tt.allowedTitle}):null,V.map(ee),O.length?a.jsx("li",{className:"af-workspace__caption","data-workspace":"caption-refused",children:tt.deniedTitle}):null,O.map(ee),N.everythingElse?a.jsxs("li",{className:"af-workspace__row","data-workspace":"everything-else","data-mode":N.everythingElse.mode,children:[a.jsx("span",{className:"af-workspace__name",children:tt.everythingElse}),a.jsx("span",{className:"af-workspace__controls",children:N.everythingElse.editable?R(`${tt.accessLabel} ${tt.everythingElse}`,N.everythingElse.mode,[{value:"rw",text:tt.accessReadWrite},{value:"ro",text:tt.accessRead}],U=>void S("everything-else",Uk(b,j.policy,U)),"workspace-default"):A(N.everythingElse.mode)}),E("everything-else")]}):null,N.canAdd?a.jsxs("li",{className:"af-workspace__add","data-workspace":"add",children:[a.jsx("input",{type:"text",className:"af-workspace__input","aria-label":tt.addPlaceholder,placeholder:tt.addPlaceholder,value:h,disabled:!!_||n==="add",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",onChange:U=>m(U.target.value),onKeyDown:U=>{U.key==="Enter"?(U.preventDefault(),L(h)):U.key==="Escape"&&(U.preventDefault(),m(""),c(te=>{const se={...te};return delete se.add,se}))}}),a.jsx("button",{type:"button",className:"af-workspace__add-btn","data-action":"workspace-add",disabled:!!_||!h.trim()||n!==null,onClick:()=>void L(h),children:tt.add}),e.choose?a.jsx("button",{type:"button",className:"af-workspace__add-btn","data-action":"workspace-choose",disabled:!!_||n!==null,onClick:()=>void J(),children:tt.choose}):null,E("add")]}):null]}),N.posture==="allowed_only"&&!V.length?a.jsx("p",{className:"af-workspace__note","data-workspace":"empty",children:tt.emptyAllowed}):null,b==="session"||b==="run"?a.jsx("p",{className:"af-workspace__note","data-workspace":"private",children:tt.privateNote}):null,a.jsx("p",{className:"af-workspace__effective","data-workspace":"effective",children:N.summary}),e.footer?a.jsx("div",{className:"af-workspace__footer",children:e.footer}):null]})})}const Xk=["provider","model","voice","profile","speed","quality_preset","instructions"];function qk(e){const t={};for(const n of Xk){const r=e[n];r!==void 0&&r!==""&&r!==null&&(t[n]=r)}return t}function Zk(e){return{...e.stt_provider?{provider:e.stt_provider}:{},...e.stt_provider&&e.stt_model?{model:e.stt_model}:{},...e.stt_language?{language:e.stt_language}:{}}}const ej=[{value:"",label:"Detect automatically"},{value:"en",label:"English"},{value:"fr",label:"French"},{value:"de",label:"German"},{value:"es",label:"Spanish"},{value:"it",label:"Italian"},{value:"pt",label:"Portuguese"},{value:"nl",label:"Dutch"},{value:"zh",label:"Chinese"},{value:"ja",label:"Japanese"},{value:"ko",label:"Korean"}];function tj(e){return[e.provider,e.model,e.profile||e.voice].filter(Boolean).join(" · ")}function nj(e){return[e.stt_provider,e.stt_model].filter(Boolean).join(" · ")}const sj=[{value:"",label:"Gateway default"},{value:"standard",label:"Balanced"},{value:"low",label:"Faster (lower quality)"},{value:"high",label:"Higher quality (slower)"}],Mp=e=>Array.isArray(e)?e.map(t=>typeof t=="string"?t:(t==null?void 0:t.id)||(t==null?void 0:t.name)).filter(Boolean):[],di=e=>`${Math.round(e*100)} %`;function rj(e){var Qe,Ye,Ne,He;const t=e.overrideOwner||"this app",n=!!e.unavailableReason,r=y.useRef(e.fetchCatalog);r.current=e.fetchCatalog;const i=y.useRef(e.fetchDefaults);i.current=e.fetchDefaults;const[c,u]=y.useState({}),[d,h]=y.useState({value:null,failed:!1}),m=e.defaults!==void 0?{value:e.defaults,failed:!1}:d,p=e.defaults!==void 0,[v,_]=y.useState(""),[b,C]=y.useState({devices:[],labelled:!0}),[x,j]=y.useState({devices:[],labelled:!0}),[N,$]=y.useState(""),[S,E]=y.useState({text:"",tone:"info"}),[A,R]=y.useState({phase:"idle",message:"",tone:"info"}),[z,L]=y.useState(0),J=e.outputSelectable??Mb(),V=Dg(),O=e.value,ee=e.nested?"flat":"card",P=ue=>e.onChange({...O,...ue}),Z=O.reply_volume===void 0?1:Math.min(1,Math.max(0,Number(O.reply_volume)||0)),U=O.input_gain===void 0?1:Math.min(1.5,Math.max(.5,Number(O.input_gain)||1));y.useEffect(()=>{if(n)return;let ue=!0;return r.current().then(Ue=>ue&&u(Ue||{})).catch(()=>ue&&u({})),p||i.current().then(Ue=>ue&&h({value:Ue||{},failed:!1})).catch(()=>ue&&h({value:null,failed:!0})),()=>{ue=!1}},[n,p]);const te=e.listDevices||_b,se=()=>{J&&te("audiooutput").then(C).catch(()=>C({devices:[],labelled:!1})),te("audioinput").then(j).catch(()=>j({devices:[],labelled:!1}))};y.useEffect(()=>{n||se()},[J,n]);const G=()=>{$(""),bb().then(se).catch(ue=>$(rf(ue)))},ce=()=>{E({text:"Playing a short chime…",tone:"info"}),Nb({deviceId:J&&O.output_device||"",volume:Z}).then(()=>E({text:"Chime played. Heard nothing? Pick another output or raise the volume.",tone:"ok"})).catch(ue=>E({text:`The speaker test failed: ${String((ue==null?void 0:ue.message)||ue).replace(/\.$/,"")}.`,tone:"error"}))},re=()=>{R({phase:"recording",message:"Recording 3 seconds — say something.",tone:"info"}),jb({deviceId:O.input_device||"",ms:3e3,gain:U,onLevel:L}).then(async({blob:ue,peak:Ue})=>{if(Ue<kb){R({phase:"idle",message:"The microphone recorded silence. Pick another input, or raise its level in the system sound settings.",tone:"error"});return}R({phase:"playing",message:"Playing it back…",tone:"info"}),await Sb(ue,{deviceId:J&&O.output_device||"",volume:Z}),R({phase:"idle",message:`The microphone works (peak level ${di(Ue)}).`,tone:"ok"}),se()}).catch(ue=>R({phase:"idle",message:rf(ue),tone:"error"}))},D=fp(m.value,"tts",m.failed),I=fp(m.value,"stt",m.failed),W=[(Qe=m.value)==null?void 0:Qe.tts,(Ye=m.value)==null?void 0:Ye.stt].map(ue=>ue&&!ue.configured?ue.note:"").filter(Boolean),me=!!((He=(Ne=c.controls)==null?void 0:Ne.quality_preset)!=null&&He.supported),q=O.output_device||"",fe=[{value:"",label:"System default"},...b.devices.map(ue=>({value:ue.id,label:ue.label})),...q&&!b.devices.some(ue=>ue.id===q)?[{value:q,label:"Saved speaker (not connected)"}]:[]],de=O.input_device||"",ae=[{value:"",label:"System default"},...x.devices.map(ue=>({value:ue.id,label:ue.label})),...de&&!x.devices.some(ue=>ue.id===de)?[{value:de,label:"Saved microphone (not connected)"}]:[]],we=!x.labelled||J&&!b.labelled,Pe=A.phase!=="idle";return a.jsxs("div",{className:`af-voice-section${e.className?` ${e.className}`:""}`,children:[e.unavailableReason?a.jsx("p",{className:"af-settings-group__help",role:"status",children:e.unavailableReason}):null,a.jsxs(ji,{variant:ee,title:"Engines",help:"Which engines speak and listen.",children:[a.jsx(Ep,{label:"Text → speech",setting:"tts",defaultSummary:D,overrideSummary:tj(O),overrideOwner:t,open:v==="tts",onToggle:()=>_(v==="tts"?"":"tts"),onReset:()=>P({provider:"",model:"",voice:"",profile:""}),disabled:n,children:a.jsx(Pb,{value:O,onChange:ue=>e.onChange({...O,...ue}),fetchCatalog:e.fetchCatalog,intro:null,quality:!1,showReset:!1,voiceDefaultLabel:"Gateway default"})}),a.jsx(Ep,{label:"Speech → text",setting:"stt",defaultSummary:I,overrideSummary:nj(O),overrideOwner:t,open:v==="stt",onToggle:()=>_(v==="stt"?"":"stt"),onReset:()=>P({stt_provider:"",stt_model:""}),disabled:n,children:a.jsx(Pc,{value:{provider:O.stt_provider||"",model:O.stt_model||""},onChange:ue=>P({stt_provider:ue.provider,stt_model:ue.model}),fetchProviders:async()=>{const ue=await r.current();return Mp(ue.stt_providers).map(Ue=>({name:Ue}))},fetchModels:async ue=>{var ie;const Ue=await r.current(ue);return Mp(((ie=Ue.stt_models_by_provider)==null?void 0:ie[ue])||Ue.stt_models)},inheritLabel:"Gateway default",providerLabel:"Transcription provider",modelLabel:"Transcription model"})}),m.failed?a.jsx("p",{className:"af-settings-group__help","data-voice-note":"defaults",role:"status",children:"The gateway's default voice routes could not be read. Requests still use them."}):null,W.map(ue=>a.jsx("p",{className:"af-settings-group__help","data-voice-note":"unset",children:ue},ue))]}),a.jsxs(ji,{variant:ee,title:"Output",children:[a.jsx(oa,{label:"Output device",setting:"output-device",help:J?void 0:"Safari does not let a page choose the output device: replies play on the system output (change it in the system sound settings).",trailing:a.jsx("button",{type:"button",className:"af-setting-btn","data-action":"test-speaker",disabled:n,onClick:ce,children:"Test"}),children:a.jsx(Jn,{ariaLabel:"Output device",placeholder:"System default",value:J?q:"",options:fe,disabled:n||!J,searchable:!1,onOpen:se,onChange:ue=>P({output_device:ue})})}),S.text?a.jsx("p",{className:`af-voice-note af-voice-note--${S.tone}`,role:"status","data-voice-note":"speaker",children:S.text}):null,a.jsxs(oa,{label:"Reply volume",setting:"reply-volume",htmlFor:"af-voice-volume",children:[a.jsx("input",{id:"af-voice-volume",className:"af-voice-range",type:"range",min:0,max:100,step:5,value:Math.round(Z*100),disabled:n,"aria-valuetext":di(Z),onChange:ue=>P({reply_volume:Number(ue.currentTarget.value)/100})}),a.jsx("span",{className:"af-voice-range__value",children:di(Z)})]})]}),a.jsxs(ji,{variant:ee,title:"Microphone",children:[a.jsx(oa,{label:"Input device",setting:"input-device",trailing:a.jsx("button",{type:"button",className:"af-setting-btn","data-action":"test-microphone",disabled:n||Pe,onClick:re,children:A.phase==="recording"?"Recording…":A.phase==="playing"?"Playing…":"Test"}),children:a.jsx(Jn,{ariaLabel:"Input device",placeholder:"System default",value:de,options:ae,disabled:n,searchable:!1,onOpen:se,onChange:ue=>P({input_device:ue})})}),a.jsx("div",{className:"af-voice-meter","data-voice-meter":!0,role:"meter","aria-label":"Microphone level","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(z*100),children:a.jsx("span",{className:"af-voice-meter__fill",style:{width:`${Math.round(z*100)}%`}})}),A.message?a.jsx("p",{className:`af-voice-note af-voice-note--${A.tone}`,role:"status","data-voice-note":"microphone",children:A.message}):null,we&&!n?a.jsxs("p",{className:"af-voice-note","data-voice-note":"labels",children:["Device names appear once the microphone is allowed."," ",a.jsx("button",{type:"button",className:"af-setting-btn af-setting-btn--quiet","data-action":"show-device-names",onClick:G,children:"Show names"})]}):null,N?a.jsx("p",{className:"af-voice-note af-voice-note--error",role:"status",children:N}):null,a.jsx(oa,{label:"Spoken language",setting:"stt-language",help:"Naming it skips detection: transcription is faster.",children:a.jsx(Jn,{ariaLabel:"Spoken language",placeholder:"Detect automatically",value:O.stt_language||"",options:ej,disabled:n,searchable:!1,onChange:ue=>P({stt_language:ue})})}),V?a.jsxs(oa,{label:"Input level",setting:"input-gain",htmlFor:"af-voice-gain",help:"Raises a quiet microphone.",children:[a.jsx("input",{id:"af-voice-gain",className:"af-voice-range",type:"range",min:50,max:150,step:10,value:Math.round(U*100),disabled:n,"aria-valuetext":di(U),onChange:ue=>P({input_gain:Number(ue.currentTarget.value)/100})}),a.jsx("span",{className:"af-voice-range__value",children:di(U)})]}):null]}),a.jsxs(ji,{variant:ee,title:"Replies",children:[a.jsx("div",{className:"af-setting-row af-setting-row--switch","data-setting":"read-aloud",children:a.jsx(Mr,{label:"Read aloud",description:"Speak each new reply.",variant:"row",checked:O.read_aloud===!0,unavailableReason:n?e.unavailableReason:null,reasonVisible:!1,onChange:ue=>P({read_aloud:ue})})}),a.jsx(oa,{label:"Voice latency",setting:"latency",help:me?"Trades quality for a faster first word.":"This gateway's voice engine has no latency control.",children:a.jsx(Jn,{ariaLabel:"Voice latency",placeholder:"Gateway default",value:me&&O.quality_preset||"",options:sj,disabled:n||!me,searchable:!1,onChange:ue=>P({quality_preset:ue})})})]})]})}function Ty(e){const t=String(e??"").trim();if(!t||!(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]")))return null;try{return JSON.parse(t)}catch{return null}}function aj(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function oj(e){const t=String(e.role||"message").trim()||"message",n=String(e.title||"").trim(),r=String(e.ts||"").trim(),i=[t];return n&&i.push(n),r&&i.push(r),i.join(" · ")}function ij(e){return e.endsWith(`
|
|
66
|
+
`)?e:`${e}
|
|
67
|
+
`}function lj(e){return String(e||"").trimStart().startsWith("```")}function cj(e,t){const r=[`# ${"Chat".trim()||"Chat"}`,""];for(const i of e){const c=oj(i);r.push(`## ${c}`,"");const u=String(i.content||""),d=Ty(u);d!==null&&!lj(u)?r.push("```json",aj(d).trimEnd(),"```",""):r.push(ij(u).trimEnd(),""),r.push("---","")}for(;r.length&&!r[r.length-1].trim();)r.pop();return r.length&&r[r.length-1]==="---"&&r.pop(),`${r.join(`
|
|
68
|
+
`).trimEnd()}
|
|
69
|
+
`}async function Gc(e){var n;const t=String(e||"");if(!t)return!1;try{if(typeof navigator<"u"&&typeof((n=navigator.clipboard)==null?void 0:n.writeText)=="function")return await navigator.clipboard.writeText(t),!0}catch{}try{const r=document.createElement("textarea");r.value=t,r.style.position="fixed",r.style.left="-9999px",document.body.appendChild(r),r.select();const i=document.execCommand("copy")===!0;return document.body.removeChild(r),i}catch{return!1}}function uj(e){const t=String(e.filename).trim()||"export.txt",n=String(e.text||""),r=String(e.mime||"text/plain;charset=utf-8"),i=new Blob([n],{type:r}),c=URL.createObjectURL(i),u=document.createElement("a");u.href=c,u.download=t,document.body.appendChild(u),u.click(),u.remove(),window.setTimeout(()=>URL.revokeObjectURL(c),1e3)}const dj=3,fj=Number.MAX_SAFE_INTEGER;function Ry(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Iy(e){return Array.isArray(e)}function hj(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function io({kind:e,children:t}){return a.jsx("span",{className:`pc-json-token ${e}`,children:t})}function mj(e){const t=JSON.stringify(e.value),n=t.length>96||t.includes("\\n")||t.includes("\\r")||t.includes("\\t"),[r,i]=y.useState(!n||e.expansionMode==="unfolded");return y.useEffect(()=>{n&&i(e.expansionMode==="unfolded")},[n,e.expansionMode,e.expansionVersion]),n?a.jsxs("span",{className:`pc-json-string ${r?"open":"collapsed"}`,children:[a.jsx("button",{type:"button",className:"pc-json-string__toggle",onClick:()=>i(c=>!c),"aria-label":r?"Collapse string value":"Expand string value","aria-expanded":r,children:r?"▾":"▸"}),r?a.jsx("span",{className:"pc-json-token string pc-json-string__value",children:t}):a.jsxs("button",{type:"button",className:"pc-json-string__preview",onClick:()=>i(!0),"aria-label":"Expand string value",children:[a.jsx("span",{className:"pc-json-token string pc-json-string__preview_text",children:t}),a.jsx("span",{className:"pc-json-string__suffix",children:"(...)"})]})]}):a.jsx(io,{kind:"string",children:t})}function pj(e,t,n){return e===null?a.jsx(io,{kind:"null",children:"null"}):typeof e=="string"?a.jsx(mj,{value:e,expansionMode:t,expansionVersion:n}):typeof e=="number"?a.jsx(io,{kind:"number",children:String(e)}):typeof e=="boolean"?a.jsx(io,{kind:"boolean",children:e?"true":"false"}):a.jsx(io,{kind:"string",children:JSON.stringify(String(e))})}function gj(e){return Iy(e)?e.length===1?"1 item":`${e.length} items`:Ry(e)?Object.keys(e).length===1?"1 key":`${Object.keys(e).length} keys`:""}function My(e){const{label:t,value:n,depth:r,collapseAfterDepth:i,expansionMode:c,expansionVersion:u,trailingComma:d}=e,h=r*14,m=Ry(n),p=Iy(n),v=m||p,_=r<i,[b,C]=y.useState(_);y.useEffect(()=>{C(_)},[_,u]);const x=t?a.jsxs(a.Fragment,{children:[a.jsx(io,{kind:"key",children:JSON.stringify(t)}),": "]}):null;if(!v)return a.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:h},children:[x,pj(n,c,u),d?",":""]});const j=p?"[":"{",N=p?"]":"}",$=gj(n),S=b?`${j}`:`${j}…${N}${$?` (${$})`:""}`,E=p?n.map((A,R)=>({key:String(R),label:void 0,value:A})):Object.entries(n).map(([A,R])=>({key:A,label:A,value:R}));return a.jsxs("details",{className:"pc-json-viewer__details",open:b,onToggle:A=>C(A.currentTarget.open),children:[a.jsxs("summary",{className:"pc-json-viewer__summary",style:{paddingLeft:h},children:[x,a.jsx("span",{className:"pc-json-viewer__caret","aria-hidden":"true",children:b?"▾":"▸"}),a.jsx("span",{className:"pc-json-viewer__punct",children:S}),!b&&d?a.jsx("span",{className:"pc-json-viewer__punct",children:","}):null]}),b?a.jsx("div",{className:"pc-json-viewer__children",children:E.length===0?a.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:h},children:[a.jsx("span",{className:"pc-json-viewer__punct",children:N}),d?",":""]}):a.jsxs(a.Fragment,{children:[E.map((A,R)=>{const z=R===E.length-1;return a.jsx(My,{label:A.label,value:A.value,depth:r+1,collapseAfterDepth:i,expansionMode:c,expansionVersion:u,trailingComma:!z},`${r}:${t||"root"}:${A.key}`)}),a.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:h},children:[a.jsx("span",{className:"pc-json-viewer__punct",children:N}),d?",":""]})]})}):null]})}function yj(e){const t=e.trim();if(!t)return e;if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]"))try{return JSON.parse(t)}catch{return e}return e}function co(e){const{value:t,className:n,showCopy:r=!0}=e,[i,c]=y.useState({mode:"folded",version:0}),[u,d]=y.useState("idle"),h=typeof e.collapseAfterDepth=="number"&&(Number.isFinite(e.collapseAfterDepth)||e.collapseAfterDepth===1/0)&&e.collapseAfterDepth>=0?e.collapseAfterDepth===1/0?Number.MAX_SAFE_INTEGER:Math.trunc(e.collapseAfterDepth):dj,m=i.mode==="unfolded"?fj:h,p=y.useMemo(()=>typeof t=="string"?yj(t):t,[t]),v=y.useMemo(()=>hj(t),[t]),_=["pc-json-viewer",n].filter(Boolean).join(" ");y.useEffect(()=>{c(C=>({mode:"folded",version:C.version+1}))},[p]);const b=()=>{c(C=>({mode:C.mode==="unfolded"?"folded":"unfolded",version:C.version+1}))};return a.jsxs("div",{className:_,children:[a.jsxs("div",{className:"pc-json-viewer__toolbar",children:[a.jsx("button",{type:"button",className:"pc-btn pc-json-viewer__toggle-all",onClick:b,"aria-expanded":i.mode==="unfolded",children:i.mode==="unfolded"?"Fold all":"Unfold all"}),r?a.jsx("button",{type:"button",className:"pc-btn pc-json-viewer__copy",onClick:()=>void Gc(v).then(C=>{d(C?"copied":"failed"),window.setTimeout(()=>d("idle"),2e3)}),children:u==="copied"?"Copied":u==="failed"?"Copy failed — select and copy":"Copy JSON"}):null]}),a.jsx("div",{className:"pc-json-viewer__tree",role:"tree","aria-label":"JSON viewer",children:a.jsx(My,{value:p,depth:0,collapseAfterDepth:m,expansionMode:i.mode,expansionVersion:i.version,trailingComma:!1})})]})}function wj({code:e,lang:t}){const[n,r]=y.useState("idle"),i=y.useRef(null);y.useEffect(()=>()=>{i.current!==null&&window.clearTimeout(i.current)},[]);const c=Sy(e,Mf(t));return a.jsxs("div",{className:"pc-md_codeblock",children:[a.jsx("button",{type:"button",className:`pc-md_copy${n!=="idle"?` pc-md_copy--${n}`:""}`,"aria-label":"Copy code",title:n==="idle"?"Copy":n==="copied"?"Copied":"Copy failed",onClick:async()=>{const u=await Gc(e);r(u?"copied":"failed"),i.current!==null&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>r("idle"),900)},children:a.jsx(ne,{name:n==="copied"?"check":"copy",size:14})}),a.jsx("pre",{className:"pc-md_pre",children:a.jsx("code",{className:t?`language-${t}`:void 0,children:c.map((u,d)=>u.kind==="plain"?a.jsx(lt.Fragment,{children:u.text},d):a.jsx("span",{className:`af-code__${u.kind}`,children:u.text},d))})})]})}function fi(e,t){const n=String(e??"");if(!t||!t.needles.length)return[n];const r=[],i=n.toLowerCase();let c=0;for(;c<n.length;){let u=-1,d="";for(let p=0;p<t.needlesLower.length;p++){const v=t.needlesLower[p];if(!v)continue;const _=i.indexOf(v,c);if(_===-1)continue;const b=t.needles[p]||"";b&&(u===-1||_<u||_===u&&b.length>d.length)&&(u=_,d=b)}if(u===-1||!d){r.push(n.slice(c));break}u>c&&r.push(n.slice(c,u));const h=t.hits===0&&t.id?t.id:void 0,m=n.slice(u,u+d.length);r.push(a.jsx("span",{id:h,className:t.className,children:m},`hl:${t.hits}`)),t.hits+=1,c=u+d.length}return r}function Ly(e){const t=String(e||"").trim();if(t&&/^(https?:|mailto:|tel:|#|\/)/i.test(t))return t}const vf="http://same-origin.invalid/";function vj(e){try{const t=new URL(e,vf);return t.protocol==="http:"&&t.origin===new URL(vf).origin}catch{return!1}}function Oy(e){const t=String(e||"").trim();return Ly(t)??(t&&vj(t)?t:void 0)}let ua=null;function _j(e){const t=String(e||"").trim();if(!t)return!1;const n=typeof document<"u"&&document.baseURI?document.baseURI:null;if(n===null&&/^[a-z][a-z0-9+.-]*:/i.test(t))return!1;const r=n??vf;let i,c;try{i=new URL(r).origin,c=new URL(t,r)}catch{return!1}return c.protocol!=="http:"&&c.protocol!=="https:"?!1:c.origin===i}function Py(e,t,n){return a.jsx("a",{className:"pc-md_link pc-md_image_link",href:t,target:"_blank",rel:"noopener noreferrer",children:`image: ${n||t}`},e)}function Lp(e){return!!e&&/[\p{L}\p{N}]/u.test(e)}function Js(e,t){const n=[],r=String(e??"");let i=0,c="";const u=()=>{if(c){for(const d of fi(c,t))n.push(d);c=""}};for(;i<r.length;){const d=r[i];if(d==="!"&&r[i+1]==="["){const h=r.indexOf("]",i+2);if(h!==-1&&r[h+1]==="("){const m=r.indexOf(")",h+2);if(m!==-1){const p=r.slice(i+2,h),v=Oy(r.slice(h+2,m));if(v&&ua&&!ua(v)){u(),n.push(Py(`img:${i}`,v,p)),i=m+1;continue}if(v){u(),n.push(a.jsxs("span",{className:"pc-md_image_inline",children:[a.jsx("img",{className:"pc-md_img",src:v,alt:p,loading:"lazy"}),p?a.jsx("span",{className:"pc-md_img_caption",children:t?fi(p,t):p}):null]},`img:${i}`)),i=m+1;continue}}}}if(d==="["){const h=r.indexOf("]",i+1);if(h!==-1&&r[h+1]==="("){const m=r.indexOf(")",h+2);if(m!==-1){const p=r.slice(i+1,h),v=Ly(r.slice(h+2,m));if(v){u(),n.push(a.jsx("a",{className:"pc-md_link",href:v,target:v.startsWith("#")?void 0:"_blank",rel:"noreferrer",children:Js(p,t)},`link:${i}`)),i=m+1;continue}}}}if(d==="`"){const h=r.indexOf("`",i+1);if(h!==-1){u();const m=r.slice(i+1,h);n.push(a.jsx("code",{children:t?fi(m,t):m},`code:${i}`)),i=h+1;continue}}if(d==="_"&&!Lp(r[i-1])){const h=r[i+1]==="_"?"__":"_",m=h.length;if(r[i+m]&&!/\s/.test(r[i+m])&&r[i+m]!=="_"){let p=r.indexOf(h,i+m);for(;p!==-1&&(/\s/.test(r[p-1]||" ")||Lp(r[p+m])||m===1&&r[p+1]==="_");)p=r.indexOf(h,p+1);if(p!==-1&&p>i+m){u();const v=r.slice(i+m,p),_=Js(v,t);n.push(m===2?a.jsx("strong",{children:_},`ubold:${i}`):a.jsx("em",{children:_},`uem:${i}`)),i=p+m;continue}}}if(d==="*"&&r[i+1]==="*"){const h=r.indexOf("**",i+2);if(h!==-1){u();const m=r.slice(i+2,h);n.push(a.jsx("strong",{children:t?fi(m,t):m},`bold:${i}`)),i=h+2;continue}}if(d==="*"&&r[i+1]!=="*"){const h=r.indexOf("*",i+1);if(h!==-1){u();const m=r.slice(i+1,h);n.push(a.jsx("em",{children:t?fi(m,t):m},`em:${i}`)),i=h+1;continue}}c+=d,i+=1}return u(),n}function bj(e){return String(e??"").replace(/\r\n/g,`
|
|
70
|
+
`).replace(/\r/g,`
|
|
71
|
+
`).split(`
|
|
72
|
+
`)}function bc(e){const n=String(e??"").match(/^([ \t]*)(?:([-*+])|(\d{1,9})[.)])\s+(.*)$/);return n?{indent:n[1].replace(/\t/g," ").length,ordered:!!n[3],start:n[3]?Math.max(1,parseInt(n[3],10)||1):1,content:n[4]??""}:null}function xj(e){const t=[];for(const i of e){const c=bc(i);c?t.push(c):t.length>0&&i.trim()&&(t[t.length-1].content+=` ${i.trim()}`)}const n=[],r=[];for(const i of t){for(;r.length>0&&i.indent<r[r.length-1].indent;)r.pop();let c=r.length>0?r[r.length-1]:null;if(c&&i.indent>c.indent){const u=c.node.items,d=u[u.length-1];if(d){const h={ordered:i.ordered,start:i.start,items:[]};d.children.push(h),r.push({indent:i.indent,node:h}),c=r[r.length-1]}}else if(c&&c.node.ordered!==i.ordered){r.pop();const u=r.length>0?r[r.length-1]:null,d={ordered:i.ordered,start:i.start,items:[]};if(u){const h=u.node.items,m=h[h.length-1];m?m.children.push(d):u.node.items.push({content:"",children:[d]})}else n.push(d);r.push({indent:i.indent,node:d}),c=r[r.length-1]}if(!c){const u={ordered:i.ordered,start:i.start,items:[]};n.push(u),r.push({indent:i.indent,node:u}),c=r[r.length-1]}c.node.items.push({content:i.content,children:[]})}return n}function Dy(e,t,n){const r=e.items.map((i,c)=>a.jsxs("li",{children:[Js(i.content,t),i.children.map((u,d)=>Dy(u,t,`${n}:${c}:${d}`))]},`${n}:li:${c}`));return e.ordered?a.jsx("ol",{className:"pc-md_ol",start:e.start!==1?e.start:void 0,children:r},n):a.jsx("ul",{className:"pc-md_ul",children:r},n)}function kj(e,t,n){return xj(e).map((r,i)=>Dy(r,t,`${n}:${i}`))}function Op(e){let t=String(e??"").trim();return t?(t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1)),t.split("|").map(n=>String(n??"").trim())):[]}function Pp(e){let t=String(e??"").trim();if(!t)return!1;t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1));const n=t.split("|").map(r=>String(r??"").trim());return n.length<2?!1:n.every(r=>/^:?-{3,}:?$/.test(r))}const Dp=/^(#{1,5})\s+(.*)$/;function Fp(e){return e.trim().startsWith("```")}function zp(e){return e.trimStart().startsWith(">")}function Fy(e){const t=ua;ua=e.images==="link"?e.inlineImage||_j:null;try{return jj(e)}finally{ua=t}}function jj({text:e,className:t,highlight:n,highlights:r,highlightClassName:i,highlightId:c}){const u=bj(e),d=[],h=[];Array.isArray(r)&&h.push(...r),typeof n=="string"&&n.trim()&&h.push(n);const m=Array.from(new Set(h.map(b=>String(b??"").trim()).filter(Boolean))).filter(b=>b.length>=4),p=m.length?{needles:m,needlesLower:m.map(b=>b.toLowerCase()),className:i||"pc-md_hl",id:c,hits:0}:null;let v=0;for(;v<u.length;){const b=String(u[v]??"");if(!b.trim()){v+=1;continue}const C=b.trim();if(/^([-_*])(\s*\1){2,}$/.test(C)){d.push(a.jsx("hr",{className:"pc-md_hr"},`hr:${v}`)),v+=1;continue}const x=b.match(/^\s*!\[([^\]]*)\]\(([^)]+)\)\s*$/);if(x){const $=Oy(x[2]||"");if($&&ua&&!ua($)){d.push(a.jsx("p",{className:"pc-md_p",children:Py(`img:${v}`,$,x[1]||"")},`p:${v}`)),v+=1;continue}if($){const S=x[1]||"";d.push(a.jsxs("figure",{className:"pc-md_figure",children:[a.jsx("img",{className:"pc-md_img",src:$,alt:S,loading:"lazy"}),S?a.jsx("figcaption",{children:Js(S,p)}):null]},`figure:${v}`)),v+=1;continue}}if(Fp(b)){const S=b.trim().replace(/```/g,"").trim(),E=[];for(v+=1;v<u.length&&!String(u[v]??"").trim().startsWith("```");)E.push(String(u[v]??"")),v+=1;v<u.length&&(v+=1);const A=E.join(`
|
|
73
|
+
`);d.push(a.jsx(wj,{code:A,lang:S},`pre:${v}`));continue}const j=b.match(Dp);if(j){const $=j[1].length,S=j[2]||"",E=Js(S,p);$===1?d.push(a.jsx("h1",{children:E},`h1:${v}`)):$===2?d.push(a.jsx("h2",{children:E},`h2:${v}`)):$===3?d.push(a.jsx("h3",{children:E},`h3:${v}`)):$===4?d.push(a.jsx("h4",{children:E},`h4:${v}`)):d.push(a.jsx("h5",{children:E},`h5:${v}`)),v+=1;continue}if(zp(b)){const $=[];for(;v<u.length&&String(u[v]??"").trimStart().startsWith(">");){const E=String(u[v]??"").trimStart();$.push(E.replace(/^>\s?/,"")),v+=1}d.push(a.jsx("blockquote",{className:"pc-md_quote",children:$.map((S,E)=>a.jsxs(lt.Fragment,{children:[Js(S,p),E<$.length-1?a.jsx("br",{}):null]},`q:${v}:${E}`))},`quote:${v}`));continue}if(b.includes("|")&&v+1<u.length&&Pp(String(u[v+1]??""))){const $=Op(b),S=Math.max(1,$.length),E=[];for(v+=2;v<u.length;){const A=String(u[v]??"");if(!A.trim()||!A.includes("|"))break;const R=Op(A),z=[];for(let L=0;L<S;L++)z.push(R[L]??"");E.push(z),v+=1}d.push(a.jsx("div",{className:"pc-md_table_wrap",children:a.jsxs("table",{className:"pc-md_table",children:[a.jsx("thead",{children:a.jsx("tr",{children:$.slice(0,S).map((A,R)=>a.jsx("th",{children:Js(A,p)},`th:${v}:${R}`))})}),a.jsx("tbody",{children:E.map((A,R)=>a.jsx("tr",{children:A.map((z,L)=>a.jsx("td",{children:Js(z,p)},`td:${v}:${R}:${L}`))},`tr:${v}:${R}`))})]})},`table:${v}`));continue}if(bc(b)){const $=[];for(;v<u.length;){const S=String(u[v]??"");if(!S.trim()||S.trimStart().startsWith("```"))break;if(bc(S)||/^\s{2,}\S/.test(S)){$.push(S),v+=1;continue}break}d.push(a.jsx(lt.Fragment,{children:kj($,p,`list:${v}`)},`list:${v}`));continue}const N=[];for(;v<u.length&&String(u[v]??"").trim()&&!(N.length>0&&bc(String(u[v]??"")));){const $=String(u[v]??"");if(N.length>0&&(Dp.test($)||Fp($)||zp($))||N.length>0&&$.includes("|")&&v+1<u.length&&Pp(String(u[v+1]??"")))break;N.push($),v+=1}d.push(a.jsx("p",{className:"pc-md_p",children:N.map(($,S)=>a.jsxs(lt.Fragment,{children:[Js($,p),S<N.length-1?a.jsx("br",{}):null]},`pl:${v}:${S}`))},`p:${v}`))}const _=["pc-md",t].filter(Boolean).join(" ");return a.jsx("div",{className:_,children:d})}function zy(e){const t=String(e.text??""),n=y.useMemo(()=>Ty(t),[t]),r=["pc-chat-content",e.className].filter(Boolean).join(" ");return n!==null?a.jsx("div",{className:r,children:a.jsx(co,{value:n,collapseAfterDepth:e.jsonCollapseAfterDepth})}):e.renderMarkdown?a.jsx("div",{className:r,children:e.renderMarkdown(t)}):a.jsx("div",{className:r,children:a.jsx(Fy,{text:t,images:e.images,inlineImage:e.inlineImage})})}function Si(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Er(e){return typeof e=="string"?e.trim():""}function Sj(e){var i;const t=Si(e);if(!t)return null;const n=Si(t.sandbox);if(n&&Er(n.kind))return n;const r=Si((i=Si(t.output))==null?void 0:i.sandbox);return r&&Er(r.kind)?r:null}function Up(e){const t=Sj(e);if(!t)return null;const n=Er(t.kind),r=Er(t.label)||n,i=Number.isFinite(Number(t.builtin_refused))?Math.max(0,Math.trunc(Number(t.builtin_refused))):0;if(n==="none")return{state:"refused",kind:n,label:r,line:`Sandbox: ${r} — refused`,rows:[],builtinRefused:0};const c=[],u=Er(t.private_workspace);u&&c.push({path:u,mode:"Read & write",private:!0});for(const h of Array.isArray(t.allowed)?t.allowed:[]){const m=Si(h),p=Er(m==null?void 0:m.path);p&&c.push({path:p,mode:Er(m==null?void 0:m.mode)==="ro"?"Read-only":"Read & write"})}for(const h of Array.isArray(t.refused)?t.refused:[]){const m=Er(h);m&&c.push({path:m,mode:"Refused"})}if(n==="unsandboxed")return{state:"unsandboxed",kind:n,label:r,line:`Sandbox: ${r}`,rows:[],builtinRefused:0};const d=c.length;return{state:"sandboxed",kind:n,label:r,line:`Sandbox: ${r} · ${d} ${d===1?"workspace":"workspaces"} enforced`,rows:c,builtinRefused:i}}function Nj({sandbox:e,className:t}){return e?a.jsxs("div",{className:`pc-tool-sandbox is-${e.state}${t?` ${t}`:""}`,"data-sandbox-kind":e.kind,children:[a.jsx("div",{className:"pc-tool-sandbox__line",children:e.line}),e.rows.length?a.jsxs("ul",{className:"pc-tool-sandbox__rows","aria-label":"Workspaces the sandbox enforced",children:[e.rows.map((n,r)=>a.jsxs("li",{children:[a.jsx("code",{children:n.path}),a.jsx("span",{className:"pc-tool-sandbox__mode",children:n.private?`${n.mode} · this run's folder`:n.mode})]},`${n.mode}:${n.path}:${r}`)),e.builtinRefused?a.jsxs("li",{className:"pc-tool-sandbox__builtin",children:[e.builtinRefused," built-in protected ",e.builtinRefused===1?"folder":"folders"," refused"]}):null]}):null]}):null}function Uy(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}}function By(e){const t=Uy(e);if(!t||typeof t!="object"||Array.isArray(t))return{label:"input",value:t==null?"":String(t)};const n=Object.entries(t),i=["command","query","url","file_path","path","pattern","name"].map(c=>n.find(([u])=>u===c)).find(Boolean)||n[0];return i?{label:i[0].replace(/_/g," "),value:typeof i[1]=="string"?i[1]:JSON.stringify(i[1])??""}:{label:"",value:""}}function Wy({tool:e,showCopy:t=!0}){const[n,r]=y.useState(!1),i=Uy(e.arguments),c=By(e.arguments),u=["file path","path"].includes(c.label)&&c.value.length>60?`${c.value.split(/[\\/]/).pop()} · ${c.value.slice(0,24)}…`:c.value,d=e.error&&/^File ['"].+['"] does not exist\.?$/.test(e.error)?"File not found. Expand for the exact path.":e.error&&e.error.length>180?`${e.error.slice(0,100)}…${e.error.slice(-70)}`:e.error,h={running:"Running",waiting:"Approval needed",completed:"Done",failed:"Failed"},m=e.startedAt&&e.endedAt?Date.parse(e.endedAt)-Date.parse(e.startedAt):NaN,p=i&&typeof i=="object"&&!Array.isArray(i)?Object.entries(i):null;return a.jsxs("details",{className:`pc-tool-activity pc-tool-activity--${e.status}`,children:[a.jsxs("summary",{className:"pc-tool-activity__summary",children:[a.jsx("span",{className:"pc-tool-activity__state-icon","aria-hidden":"true",children:a.jsx(ne,{name:e.status==="completed"?"check":e.status==="failed"?"x":e.status==="waiting"?"warning":"loader",size:15})}),a.jsx("strong",{children:e.name}),a.jsx("span",{className:"pc-tool-activity__preview",title:c.value,children:c.value?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"pc-tool-activity__key",children:c.label}),u]}):"No parameters"}),a.jsx("span",{className:"pc-tool-activity__status",children:h[e.status]}),Number.isFinite(m)&&m>=0?a.jsxs("span",{className:"pc-tool-activity__duration",children:[(m/1e3).toFixed(1),"s"]}):null,a.jsx("span",{className:"pc-tool-activity__chevron","aria-hidden":"true",children:a.jsx(ne,{name:"chevronRight",size:13})}),e.error?a.jsx("span",{className:"pc-tool-activity__error",title:e.error,children:d}):null]}),a.jsxs("div",{className:"pc-tool-activity__detail",children:[a.jsx(Nj,{sandbox:e.sandbox}),e.error?a.jsxs(a.Fragment,{children:[a.jsx("h4",{children:"Error"}),a.jsx("pre",{className:"pc-tool-activity__output",children:e.error})]}):null,a.jsxs("div",{className:"pc-tool-activity__detail-heading",children:[a.jsx("h4",{children:"Parameters"}),t?a.jsxs("button",{type:"button",onClick:async()=>r(await Gc(JSON.stringify(e,null,2))),children:[a.jsx(ne,{name:"copy",size:13}),n?"Copied":"Copy details"]}):null]}),p?a.jsx("dl",{className:"pc-tool-activity__parameters",children:p.map(([v,_])=>a.jsxs(lt.Fragment,{children:[a.jsx("dt",{children:v}),a.jsx("dd",{children:_&&typeof _=="object"?a.jsx(co,{value:_}):a.jsx("code",{children:typeof _=="string"?_:JSON.stringify(_)})})]},v))}):e.arguments===void 0?a.jsx("p",{children:"Arguments are unavailable in this ledger."}):a.jsx(co,{value:i}),e.output!==void 0?a.jsxs(a.Fragment,{children:[a.jsx("h4",{children:"Result"}),typeof e.output=="string"?a.jsx("pre",{className:"pc-tool-activity__output",children:e.output}):a.jsx("div",{className:"pc-tool-activity__output",children:a.jsx(co,{value:e.output})})]}):null]})]})}function Pf({tools:e,showCopy:t}){const n=r=>e.filter(i=>i.status===r).length;return a.jsxs("section",{className:"pc-tool-group","aria-label":"Tool activity",children:[a.jsxs("div",{className:"pc-tool-group__heading",children:[a.jsx(ne,{name:"terminal",size:14}),a.jsx("strong",{children:"Tools"}),a.jsxs("span",{children:[e.length," ",e.length===1?"call":"calls"]}),a.jsx("div",{}),n("running")?a.jsxs("span",{className:"pc-tool-group__running",children:[n("running")," running"]}):null,n("waiting")?a.jsxs("span",{className:"pc-tool-group__waiting",children:[n("waiting")," need approval"]}):null,n("failed")?a.jsxs("span",{className:"pc-tool-group__failed",children:[n("failed")," failed"]}):null,n("completed")?a.jsxs("span",{className:"pc-tool-group__completed",children:[n("completed")," done"]}):null]}),e.map(r=>a.jsx(Wy,{tool:r,showCopy:t},r.id))]})}const Gt="not reported",on=e=>e===void 0?Gt:Math.round(e).toLocaleString(),xn=e=>{if(e===void 0)return Gt;if(e<6e4)return`${(e/1e3).toFixed(1)}s`;const t=Math.round(e/1e3);return`${Math.floor(t/60)}m ${String(t%60).padStart(2,"0")}s`},Vy=e=>e===void 0?Gt:`${Math.round(e).toLocaleString()} tok/s`,Cj=(e,t)=>t>0?`${Math.round(e/t*100)}%`:"",da=(e,t,n=`${t}s`)=>`${e.toLocaleString()} ${e===1?t:n}`,Ej=e=>{const t=e.split("#")[0].replace(/\/+$/,"");return t.slice(t.lastIndexOf("/")+1)||e};function $j(e){const t=new Map;for(const n of e)n&&t.set(n,(t.get(n)||0)+1);return[...t].map(([n,r])=>r>1?`${n} ×${r}`:n).join(" · ")}function Ec(e){const t=[],n=(e.models||[]).map(Ej),r=e.providers||[];return(n.length||r.length)&&t.push([n.join(", ")||"model not reported",r.join(", ")].filter(Boolean).join(" · ")),t.push("From the run ledger; summed across this turn and its child runs."),t}function Aj(e){const t=e.modelCalls||[],n=[],r=[{label:"Input",value:on(e.inputTokens)},{label:"Output",value:on(e.outputTokens)}];if(e.reasoningTokens!==void 0&&r.push({label:"Reasoning",value:on(e.reasoningTokens),hint:"part of output"}),r.push({label:"Total",value:on(e.totalTokens)}),n.push({heading:`Usage · ${da(e.llmCalls,"model call")}`,rows:r}),e.measuredCacheCalls){const c=e.cachedTokens||0,u=e.fedTokens||0,d=[{label:"Reused from cache",value:`${on(c)}${c+u?` (${Cj(c,c+u)})`:""}`},{label:"Newly processed",value:on(e.fedTokens)},{label:"Outcome",value:$j(t.map(h=>h.cacheOutcome))||(e.cacheOutcomes||[]).join(" · ")||Gt},{label:"Backend",value:(e.cacheBackends||[]).join(", ")||Gt}];e.measuredCacheCalls!==e.llmCalls&&d.push({label:"Measured on",value:`${e.measuredCacheCalls} of ${e.llmCalls} calls`}),n.push({heading:"Prompt cache",rows:d})}else e.llmCalls&&n.push({heading:"Prompt cache",rows:[{label:"Cache reuse",value:Gt}]});const i=t.filter(c=>c.inputTokens!==void 0);return i.length===1&&t.length===1?n.push({heading:"Context",rows:[{label:"Prompt size",value:`${on(i[0].inputTokens)} tokens`}]}):i.length>1&&n.push({heading:"Context",rows:[{label:"First → last call",value:`${on(i[0].inputTokens)} → ${on(i[i.length-1].inputTokens)} tokens`}],note:"Each call re-sends the conversation, so the input total counts the context once per call."}),t.length>1&&n.push({heading:"Per call",table:{columns:["#","Input","Cached","New","Output","Cache"],rows:t.map((c,u)=>[String(u+1),on(c.inputTokens),c.cachedTokens===void 0?"—":on(c.cachedTokens),c.fedTokens===void 0?"—":on(c.fedTokens),on(c.outputTokens),c.cacheOutcome||"—"])}}),{kind:"tokens",title:"Tokens",headline:e.totalTokens===void 0?Gt:`${e.totalTokens.toLocaleString()} total`,sections:n,footer:Ec(e)}}function hc(e,t,n,r){if(e===void 0)return Gt;const i=[xn(e)];return t!==void 0&&i.push(`${t.toLocaleString()} ${r}${n!==void 0?` at ${Vy(n)}`:""}`),i.join(" · ")}function Tj(e){var m,p,v;const t=e.modelCalls||[],n=[],r=e.durationMs,i=[{label:"Wall clock",value:xn(r)}];if(i.push({label:"Model",value:e.genTimeMs===void 0?Gt:`${xn(e.genTimeMs)} · ${da(e.timedCalls||0,"call")}${e.timedCalls!==e.llmCalls?` (of ${e.llmCalls})`:""}`}),i.push({label:"Tools",value:e.toolTimeMs!==void 0?`${xn(e.toolTimeMs)} · ${da(e.toolBatches||0,"batch","batches")}`:e.toolCalls?Gt:"none",hint:e.toolTimeIncludesApproval?"includes approval wait":void 0}),r!==void 0&&e.genTimeMs!==void 0){const _=r-e.genTimeMs-(e.toolTimeMs||0);i.push({label:"Orchestration",value:_>=0?xn(_):"overlaps (parallel runs)",hint:"wall − model − tools: routing, hand-offs, model load"})}n.push({heading:"Turn",rows:i});const c=[],u=e.ttftCalls||0,d=e.promptPhaseCalls||0;e.promptPhaseMs!==void 0?c.push({label:u&&u===d?"Prefill (TTFT)":"Prefill",value:hc(e.promptPhaseMs,e.promptPhaseNewTokens,e.promptPhaseTokensPerSecond,"new tok"),hint:u===d?"measured time to first token":u?`TTFT measured on ${u} of ${d}; rest from provider rate`:"derived: prompt ÷ provider rate"}):e.prefillMs!==void 0&&e.prefillNewTokensPerSecond!==void 0?c.push({label:"Prefill",value:hc(e.prefillMs,e.prefillNewTokens,e.prefillNewTokensPerSecond,"new tok"),hint:"derived: prompt ÷ provider rate"}):e.prefillMs!==void 0?c.push({label:"Prefill",value:`${xn(e.prefillMs)}${e.promptTokensPerSecond!==void 0?` at ${Vy(e.promptTokensPerSecond)}`:""}`,hint:"provider rate over all prompt tokens, restored included"}):c.push({label:"Prefill",value:Gt}),e.cachedTokens&&(e.promptPhaseMs??e.prefillMs)!==void 0&&c.push({label:"Restored",value:`${e.cachedTokens.toLocaleString()} tok from cache`,hint:"not recomputed"}),c.push({label:"Generation",value:e.generationPhaseMs!==void 0?hc(e.generationPhaseMs,e.generationPhaseTokens,e.generationPhaseTokensPerSecond,"tok"):hc(e.decodeMs,e.outputTokens,e.generationTokensPerSecond,"tok")}),e.measuredSpeedCalls&&e.measuredSpeedCalls!==e.llmCalls&&c.push({label:"Speeds from",value:`${e.measuredSpeedCalls} of ${e.llmCalls} calls`}),n.push({heading:"Model",rows:c});const h=e.speculation;if(h){const _=(h.draftKinds||[]).map(C=>C.toUpperCase()).join(", "),b=[{label:"Mode",value:`${h.used?"on":"off"}${_?` · ${_}`:""}${(m=h.modes)!=null&&m.length?` (${h.modes.join(", ")})`:""}`,hint:h.calls!==e.llmCalls||h.used!==h.calls?`used on ${h.used} of ${e.llmCalls} calls`:void 0},{label:"Acceptance",value:h.acceptanceRate===void 0?Gt:`${Math.round(h.acceptanceRate*100)}% · ${on(h.acceptedTokens)} of ${on(h.draftedTokens)} drafted`}];((p=h.draftLengths)!=null&&p.length||h.rounds!==void 0)&&b.push({label:"Draft length",value:`${(v=h.draftLengths)!=null&&v.length?`${h.draftLengths.join("/")} tok/round`:Gt}${h.rounds!==void 0?` · ${h.rounds.toLocaleString()} rounds`:""}`}),n.push({heading:"Speculation",rows:b})}return e.slowestToolBatch&&n.push({heading:"Tools",rows:[{label:"Total",value:`${xn(e.toolTimeMs)} · ${da(e.toolBatches||0,"batch","batches")}`},{label:"Slowest",value:`${xn(e.slowestToolBatch.ms)} · ${Hy(e.slowestToolBatch)}`}],note:e.toolTimeIncludesApproval?"Gated calls are timed from request to result, so this includes waiting for your approval.":void 0}),t.length>1&&n.push({heading:"Per call",table:{columns:["#","Prefill","New tok/s","Gen","Gen tok/s","Cache"],rows:t.map((_,b)=>[String(b+1),_.promptMs===void 0?"—":`${xn(_.promptMs)}${_.promptSource==="rate"?"*":""}`,_.promptNewTokensPerSecond===void 0?"—":Math.round(_.promptNewTokensPerSecond).toLocaleString(),_.generationMs===void 0?"—":xn(_.generationMs),_.generationTokensPerSecond===void 0?"—":Math.round(_.generationTokensPerSecond).toLocaleString(),_.cacheOutcome||"—"])},note:t.some(_=>_.promptSource==="rate")?"* derived from the provider's prompt rate (no TTFT event).":void 0}),{kind:"time",title:"Time",headline:r===void 0?Gt:`${xn(r)} wall clock`,sections:n,footer:Ec(e)}}function Hy(e){return e.tools.length===1?`${e.tools[0]} ×${e.calls}`:`${da(e.calls,"call")} (${e.tools.join(", ")})`}function Rj(e){const t=[],n=(e.toolsWaiting||0)+(e.toolsRunning||0);if(!e.toolCalls&&!n)return t.push({heading:"Outcome",rows:[{label:"Tools called",value:"none"}]}),{kind:"tools",title:"Tools",headline:"none",sections:t,footer:Ec(e)};const r=[{label:"Succeeded",value:(e.toolCalls-(e.toolsFailed||0)).toLocaleString()},{label:"Failed",value:(e.toolsFailed||0).toLocaleString()}];e.toolsRunning&&r.push({label:"Running",value:e.toolsRunning.toLocaleString()}),e.toolsWaiting&&r.push({label:"Awaiting approval",value:e.toolsWaiting.toLocaleString(),hint:"not run yet — not a failure"}),t.push({heading:"Outcome",rows:r});const i=Object.entries(e.toolBreakdown||{}).sort((d,h)=>h[1].calls-d[1].calls||d[0].localeCompare(h[0]));i.length&&t.push({heading:"By tool",table:{columns:["Tool","Calls","Failed","Time"],rows:i.map(([d,h])=>[d,h.calls.toLocaleString(),h.failed.toLocaleString(),h.ms!==void 0?`${xn(h.ms)}${h.sharedBatches?" +shared":""}`:h.sharedBatches?"shared":Gt])},note:i.some(([,d])=>d.sharedBatches)?"A batch that mixed tools ran them together; its time is not split between them.":void 0});const c=i.filter(([,d])=>d.errors&&Object.keys(d.errors).length);c.length&&t.push({heading:"Failures",rows:c.map(([d,h])=>({label:d,value:Object.entries(h.errors).sort((m,p)=>p[1]-m[1]).map(([m,p])=>p>1?`${m} ×${p}`:m).join(" · ")}))});const u=[{label:"Tool time",value:e.toolTimeMs===void 0?Gt:`${xn(e.toolTimeMs)} · ${da(e.toolBatches||0,"batch","batches")}`}];return e.slowestToolBatch&&u.push({label:"Slowest batch",value:`${xn(e.slowestToolBatch.ms)} · ${Hy(e.slowestToolBatch)}`}),t.push({heading:"Timing",rows:u,note:e.toolTimeIncludesApproval?"Gated calls are timed from request to result, so this includes waiting for your approval.":void 0}),{kind:"tools",title:"Tools",headline:`${da(e.toolCalls,"call")}${e.toolsFailed?` · ${e.toolsFailed} failed`:""}`,sections:t,footer:Ec(e)}}function Dd(e,t){return e==="tokens"?Aj(t):e==="time"?Tj(t):Rj(t)}function Ij(e){const t=e.detail;return a.jsxs("div",{ref:e.panelRef,id:e.id,role:"tooltip",className:`pc-stat-detail pc-stat-detail--${t.kind}`,style:e.style,onMouseEnter:e.onMouseEnter,onMouseLeave:e.onMouseLeave,children:[a.jsxs("div",{className:"pc-stat-detail-head",children:[a.jsx("span",{className:"pc-stat-detail-title",children:t.title}),a.jsx("span",{className:"pc-stat-detail-headline",children:t.headline})]}),t.sections.map(n=>{var r;return a.jsxs("div",{className:"pc-stat-detail-section",children:[a.jsx("div",{className:"pc-stat-detail-heading",children:n.heading}),(r=n.rows)!=null&&r.length?a.jsx("dl",{className:"pc-stat-detail-rows",children:n.rows.map(i=>a.jsxs(lt.Fragment,{children:[a.jsx("dt",{children:i.label}),a.jsxs("dd",{children:[a.jsx("span",{className:i.value===Gt?"pc-stat-detail-value pc-stat-detail-value--absent":"pc-stat-detail-value",children:i.value}),i.hint?a.jsx("span",{className:"pc-stat-detail-hint",children:i.hint}):null]})]},i.label))}):null,n.table?a.jsxs("table",{className:"pc-stat-detail-table",children:[a.jsx("thead",{children:a.jsx("tr",{children:n.table.columns.map(i=>a.jsx("th",{scope:"col",children:i},i))})}),a.jsx("tbody",{children:n.table.rows.map((i,c)=>a.jsx("tr",{children:i.map((u,d)=>a.jsx("td",{children:u},d))},c))})]}):null,n.note?a.jsx("p",{className:"pc-stat-detail-note",children:n.note}):null]},n.heading)}),a.jsx("div",{className:"pc-stat-detail-foot",children:t.footer.map(n=>a.jsx("div",{children:n},n))})]})}const Gs=8;function Mj(e){const[t,n]=y.useState(!!e.defaultOpen),[r,i]=y.useState(null),c=y.useRef(null),u=y.useRef(null),d=y.useRef(null),h=`pc-stat-${y.useId().replace(/[^a-zA-Z0-9_-]/g,"")}`,m=y.useCallback(()=>{d.current!==null&&window.clearTimeout(d.current),d.current=null},[]),p=y.useCallback(()=>{m(),n(!0)},[m]),v=y.useCallback(()=>{m(),d.current=window.setTimeout(()=>n(!1),120)},[m]);y.useEffect(()=>m,[m]),y.useLayoutEffect(()=>{if(!t){i(null);return}const x=()=>{const j=c.current,N=u.current;if(!j||!N)return;const $=j.getBoundingClientRect(),S=N.offsetWidth,E=N.offsetHeight,A=window.innerWidth,R=window.innerHeight,z=$.top-Gs-E,L=$.bottom+Gs,J=z>=Gs?z:L+E<=R-Gs?L:Math.max(Gs,R-Gs-E),V=Math.min(Math.max(Gs,$.left),Math.max(Gs,A-Gs-S));i({top:J,left:V})};return x(),window.addEventListener("resize",x),window.addEventListener("scroll",x,!0),()=>{window.removeEventListener("resize",x),window.removeEventListener("scroll",x,!0)}},[t]),y.useEffect(()=>{if(!t)return;const x=j=>{j.key==="Escape"&&n(!1)};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[t]);const _=typeof e.onClick=="function",b=_?"button":"span",C=t?a.jsx(Ij,{detail:e.detail,id:h,panelRef:u,onMouseEnter:m,onMouseLeave:v,style:{position:"fixed",top:(r==null?void 0:r.top)??0,left:(r==null?void 0:r.left)??0,visibility:r?"visible":"hidden"}}):null;return a.jsxs(a.Fragment,{children:[a.jsxs(b,{ref:c,..._?{type:"button"}:{tabIndex:0},className:["pc-chat-stat","pc-chat-stat--detail",_?"pc-chat-stat--clickable":"",e.className].filter(Boolean).join(" "),"aria-label":`${e.label} — ${e.detail.title.toLowerCase()} details`,"aria-describedby":t?h:void 0,"data-stat-kind":e.detail.kind,onMouseEnter:p,onMouseLeave:v,onFocus:p,onBlur:()=>n(!1),onKeyDown:x=>{x.key==="Escape"&&n(!1)},onClick:_?()=>{var x;return(x=e.onClick)==null?void 0:x.call(e)}:void 0,children:[e.icon?a.jsx("span",{className:"pc-chat-stat-icon","aria-hidden":"true",children:e.icon}):null,a.jsx("span",{className:"pc-chat-stat-label",children:e.label})]}),C&&typeof document<"u"?Oc.createPortal(C,document.body):C]})}function Lj(e){const t=e.totalTokens!==void 0?Dd("tokens",e):null,n=Dd("tools",e),r=e.durationMs!==void 0?Dd("time",e):null;return[...t?[{label:`${e.totalTokens.toLocaleString()} tokens`,detail:t}]:[],{label:`${e.toolCalls} ${e.toolCalls===1?"tool":"tools"}`,detail:n},...e.changedFiles.length?[{label:`${e.changedFiles.length} ${e.changedFiles.length===1?"file":"files"} changed`,title:e.changedFiles.join(`
|
|
74
|
+
`)}]:[],...r?[{label:`${(e.durationMs/1e3).toFixed(e.durationMs<1e4?1:0)}s`,detail:r}]:[]]}function Oj(e){const t=String(e.role||"").trim().toLowerCase()||"system",n=String(e.kind||"").trim().toLowerCase(),r=String(e.level||"").trim().toLowerCase();return t==="system"&&n==="report_bug"?{label:String(e.title||"").trim()||"Bug report",icon:"warning",variant:"report_bug"}:t==="system"&&n==="report_feature"?{label:String(e.title||"").trim()||"Feature request",icon:"check",variant:"report_feature"}:t==="user"?{label:String(e.title||"").trim()||"You",icon:"user",variant:"user"}:t==="assistant"?{label:String(e.title||"").trim()||"Agent",icon:"bot",variant:"assistant"}:{label:String(e.title||"").trim()||(r==="error"?"Error":r==="warn"?"Warning":"System"),icon:r==="error"?"error":r==="warn"?"warning":"info",variant:r==="error"?"error":r==="warn"?"warn":"status"}}const Pj=new Set(["blob:","data:","http:","https:"]);function Bp(e){const t=String(e||"").trim();if(t)try{const n=typeof window<"u"&&window.location?window.location.href:"http://same-origin.invalid/";return Pj.has(new URL(t,n).protocol)?t:void 0}catch{return}}function Dj({item:e}){const[t,n]=y.useState(!1),r=Bp(e.src),i=e.href?Bp(e.href):void 0,c=e.kind==="image"||e.kind==="audio"||e.kind==="video"?e.kind:null;if(!c||!r&&!i)return null;const u=c==="image"?"Image":c==="video"?"Video":"Audio",d=String(e.label||"").trim()||`Generated ${u.toLowerCase()}`,h=()=>n(!0);return a.jsxs("figure",{className:`pc-chat-media__item pc-chat-media__item--${c}`,children:[r&&c==="image"?a.jsx("img",{className:"pc-chat-media__image",src:r,alt:d,loading:"lazy",onError:h}):null,r&&c==="video"?a.jsx("video",{className:"pc-chat-media__video",src:r,controls:!0,playsInline:!0,preload:"metadata","aria-label":d,onError:h}):null,r&&c==="audio"?a.jsx(jy,{className:"pc-chat-media__audio",src:r,name:d}):null,t?a.jsxs("div",{className:"pc-chat-media__error",role:"note",children:[u," could not be decoded by this browser",i?"; open the raw file with the link.":"."]}):null,i?a.jsx("figcaption",{className:"pc-chat-media__caption",children:a.jsx("a",{className:"pc-chat-media__link",href:i,target:"_blank",rel:"noopener noreferrer",children:d})}):null]})}function Gy(e){var A;const t=e.message,n=y.useMemo(()=>Oj(t),[t.kind,t.level,t.role,t.title]),r=String(t.ts||"").trim(),i=y.useMemo(()=>{if(!r)return"";const R=new Date(r);return Number.isFinite(R.getTime())?R.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):""},[r]),[c,u]=y.useState("idle"),d=y.useRef(null);y.useEffect(()=>()=>{d.current!==null&&window.clearTimeout(d.current)},[]);const h=t.live,m=!h&&typeof e.onSpeakToggle=="function"&&n.variant==="assistant"&&!!String(t.content||"").trim(),p=m&&((A=e.getSpeakState)==null?void 0:A.call(e,t))||"idle",v=p==="loading"?"loader":p==="playing"?"pause":"speaker",_=p==="loading"?"Generating audio…":p==="playing"?"Pause":p==="paused"?"Resume":"Speak (TTS)",b=e.showCopy!==!1,C=Array.isArray(e.attachments)?e.attachments:Array.isArray(t.attachments)?t.attachments:[],x=t.statistics,j=t.stats,N=y.useMemo(()=>Array.isArray(e.stats)?e.stats:Array.isArray(j)?j:x?Lj(x):[],[e.stats,j,x]),$=Array.isArray(t.media)?t.media:[],S=String(h?h.reasoning||"":t.reasoning||""),E=!!String(t.content||"").trim();return t.toolActivity?a.jsx(Wy,{tool:t.toolActivity,showCopy:e.showCopy}):a.jsxs("div",{className:["pc-chat-item",`pc-chat-item--${n.variant}`,h?"pc-chat-item--live":"",e.className].filter(Boolean).join(" "),...h?{"aria-busy":!0}:{},children:[a.jsxs("div",{className:"pc-chat-header",children:[a.jsx("div",{className:"pc-chat-avatar","aria-hidden":"true",children:a.jsx(ne,{name:n.icon,size:14})}),a.jsx("span",{className:"pc-chat-role",children:n.label}),h?a.jsxs("span",{className:"pc-chat-live-indicator",title:h.label?`Pending: ${h.label}`:"The reply is still being written",children:[a.jsx("span",{className:"pc-chat-live-dot","aria-hidden":"true"}),h.label||"streaming"]}):null,h!=null&&h.caption?a.jsx("span",{className:"pc-chat-live-caption",children:h.caption}):null,a.jsx("span",{className:"pc-chat-header-spacer"}),i?a.jsx("span",{className:"pc-chat-time",children:i}):null,a.jsxs("div",{className:"pc-chat-header-actions",children:[m?a.jsx("button",{className:"pc-chat-icon-btn",type:"button","aria-label":_,title:_,onClick:()=>{var R;return(R=e.onSpeakToggle)==null?void 0:R.call(e,t)},children:a.jsx(ne,{name:v,size:22,className:p==="loading"?"pc-chat-speak-spinner":void 0})}):null,b?a.jsx("button",{className:`pc-chat-icon-btn ${c!=="idle"?`pc-chat-icon-btn--${c}`:""}`.trim(),type:"button","aria-label":"Copy message",title:c==="idle"?"Copy":c==="copied"?"Copied":"Copy failed",onClick:async()=>{const R=await Gc(String(t.content||""));u(R?"copied":"failed"),d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>u("idle"),900)},children:a.jsx(ne,{name:"copy",size:22})}):null]})]}),S.trim()?a.jsxs("details",{className:"pc-chat-thinking",children:[a.jsx("summary",{children:"Thinking"}),a.jsx("div",{className:"pc-chat-thinking-body",children:S})]}):null,E||!h&&!$.length?a.jsx("div",{className:"pc-chat-body",children:a.jsx(zy,{text:String(t.content||""),renderMarkdown:e.renderMarkdown,jsonCollapseAfterDepth:e.jsonCollapseAfterDepth,images:e.images||(n.variant==="user"?"inline":"link"),inlineImage:e.inlineImage})}):null,$.length?a.jsx("div",{className:"pc-chat-media",children:$.slice(0,24).map((R,z)=>a.jsx(Dj,{item:R},R.id||`${R.kind}:${R.src}:${z}`))}):null,C.length?a.jsx("div",{className:"pc-chat-attachments","aria-label":"Attachments",children:C.slice(0,24).map((R,z)=>{const L=String(R.label||"").trim()||"attachment",J=String(R.target||"").trim(),V=String(R.title||"").trim(),O=!!R.disabled||typeof R.onClick!="function";return a.jsxs("button",{type:"button",className:"pc-chat-attachment-chip",title:V||L,onClick:O?void 0:R.onClick,disabled:O,children:[a.jsx(ne,{name:"paperclip",size:14}),J?a.jsx("span",{className:`pc-chat-attachment-target pc-chat-attachment-target--${J}`,children:J}):null,a.jsx("span",{className:"pc-chat-attachment-name",children:L})]},R.id||`${L}:${z}`)})}):null,N.length?a.jsx("div",{className:"pc-chat-stats","aria-label":"Stats",children:N.slice(0,12).map((R,z)=>{const L=String(R.label||"").trim();if(!L)return null;if(R.detail)return a.jsx(Mj,{label:L,detail:R.detail,icon:R.icon,onClick:R.onClick},R.id||`${L}:${z}`);const J=String(R.title||"").trim(),V=typeof R.onClick=="function",O=V?"button":"span";return a.jsxs(O,{...V?{type:"button"}:{},className:["pc-chat-stat",V?"pc-chat-stat--clickable":""].filter(Boolean).join(" "),title:J||void 0,onClick:V?()=>{var ee;return(ee=R.onClick)==null?void 0:ee.call(R)}:void 0,children:[R.icon?a.jsx("span",{className:"pc-chat-stat-icon","aria-hidden":"true",children:R.icon}):null,a.jsx("span",{className:"pc-chat-stat-label",children:L})]},R.id||`${L}:${z}`)})}):null]})}function Fj(e,t){const n=Math.max(0,Math.trunc(t));return e.scrollHeight-e.scrollTop-e.clientHeight<=n}function Ky(e){const t=typeof e.autoScrollThresholdPx=="number"&&Number.isFinite(e.autoScrollThresholdPx)?e.autoScrollThresholdPx:120,n=e.autoScroll!==!1,r=y.useRef(null),i=y.useRef(null),[c,u]=y.useState(!0),d=y.useMemo(()=>Array.isArray(e.messages)?e.messages:[],[e.messages]),h=y.useMemo(()=>{var v;const p=[];for(const _ of d){const b=p[p.length-1];_.toolActivity&&((v=b==null?void 0:b[0])!=null&&v.toolActivity)&&b[0].runId===_.runId?b.push(_):p.push([_])}return p},[d]);y.useEffect(()=>{if(!n)return;const p=r.current;if(!p)return;const v=()=>{u(Fj(p,t))};return p.addEventListener("scroll",v,{passive:!0}),v(),()=>p.removeEventListener("scroll",v)},[n,t]);const m=y.useMemo(()=>{let p=0;for(const v of d)if(p+=String(v.content??"").length,Array.isArray(v.media))for(const _ of v.media)p+=String((_==null?void 0:_.src)??"").length+1;return`${d.length}:${p}:${String(e.afterKey??"")}`},[d,e.afterKey]);return y.useEffect(()=>{if(!n||!c)return;const p=r.current;p&&(p.scrollTop=p.scrollHeight)},[n,c,m]),y.useEffect(()=>{if(!n)return;const p=r.current;if(!p)return;const v=()=>{c&&(p.scrollTop=p.scrollHeight)};return p.addEventListener("load",v,!0),p.addEventListener("loadedmetadata",v,!0),()=>{p.removeEventListener("load",v,!0),p.removeEventListener("loadedmetadata",v,!0)}},[n,c]),a.jsxs("div",{ref:r,className:["pc-chat-thread",e.className].filter(Boolean).join(" "),children:[d.length?null:e.empty||null,h.map((p,v)=>{var C;const _=p[0],b=String(_.id||"")||String(_.ts||"")+":"+String(_.role||"")+":"+v;return _.toolActivity?a.jsx(Pf,{tools:p.map(x=>x.toolActivity),showCopy:(C=e.messageProps)==null?void 0:C.showCopy},b):a.jsx(Gy,{message:_,...e.messageProps||{}},b)}),e.after,a.jsx("div",{ref:i})]})}const Jy=lt.forwardRef(function(t,n){const r=typeof t.rows=="number"&&Number.isFinite(t.rows)?Math.max(1,Math.trunc(t.rows)):3,i=!!t.disabled,c=!!t.busy,u=!i&&!c&&!!String(t.value||"").trim();return a.jsxs("div",{className:["pc-composer",t.className].filter(Boolean).join(" "),children:[t.leading,a.jsx("textarea",{ref:n,className:["pc-composer__textarea",t.textareaClassName].filter(Boolean).join(" "),value:t.value,onChange:d=>t.onChange(d.target.value),rows:r,style:{"--pc-composer-rows":String(r)},spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",autoComplete:"off",placeholder:t.placeholder||"","aria-label":t.ariaLabel||t.placeholder||"Message",disabled:i,autoFocus:!!t.autoFocus,onPaste:t.onPaste,onKeyDown:d=>{d.key!=="Enter"||d.shiftKey||d.nativeEvent.isComposing||d.keyCode===229||(d.preventDefault(),u&&t.onSubmit())}}),a.jsxs("div",{className:"pc-composer__row",children:[a.jsx("div",{className:"pc-composer__actions",children:t.actions}),a.jsx("button",{type:"button",className:t.sendButtonClassName||"pc-btn",disabled:!u,onClick:()=>t.onSubmit(),children:c?t.busyLabel||"Thinking…":t.sendLabel||"Send"})]}),t.overlay]})});function Ni(e){if(!e)return!1;for(let t=0;t<e.length;t+=1)if(e[t]==="Files")return!0;return!1}function Wp(e){var r;const t=e==null?void 0:e.items;if(!t||!t.length)return null;let n=0;for(let i=0;i<t.length;i+=1)((r=t[i])==null?void 0:r.kind)==="file"&&(n+=1);return n>0?n:null}function Vp(e){return e===1?"Drop file to attach":typeof e=="number"&&e>1?`Drop ${e} files to attach`:"Drop files to attach"}function Df(e){const t=[],n=[],r=e==null?void 0:e.items;if(r&&r.length){for(let c=0;c<r.length;c+=1){const u=r[c];if(!u||u.kind!=="file")continue;const d=typeof u.webkitGetAsEntry=="function"?u.webkitGetAsEntry():null,h=typeof u.getAsFile=="function"?u.getAsFile():null;d!=null&&d.isDirectory?n.push(d.name||(h==null?void 0:h.name)||"folder"):h&&t.push(h)}return{files:t,folders:n}}const i=e==null?void 0:e.files;if(i)for(let c=0;c<i.length;c+=1)i[c]&&t.push(i[c]);return{files:t,folders:n}}function Qy(e){return e.length?e.length===1?`"${e[0]}" is a folder. Folders are not supported: drop the files inside it instead.`:`${e.length} folders were dropped. Folders are not supported: drop the files inside them instead.`:""}const zj={"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/heic":"heic","image/tiff":"tiff","image/bmp":"bmp"};function hi(e){return String(e).padStart(2,"0")}function Uj(e,t,n){const r=String(e||"").trim();if(r&&!/^image\.(png|jpe?g|gif|webp|heic|tiff?|bmp)$/i.test(r))return r;const i=zj[String(t||"").toLowerCase()]||r.split(".").pop()||"bin",c=`${n.getFullYear()}-${hi(n.getMonth()+1)}-${hi(n.getDate())} at ${hi(n.getHours())}.${hi(n.getMinutes())}.${hi(n.getSeconds())}`;return`${String(t||"").startsWith("image/")||!r?"Pasted image":"Pasted file"} ${c}.${i}`}function Yy(e,t=new Date){if(!e)return[];const n=e.types?Array.from(e.types):[];if(n.includes("text/plain")&&n.includes("text/html"))return[];const{files:r}=Df(e);return r.map(i=>{const c=Uj(i.name,i.type,t);return c===i.name?i:new File([i],c,{type:i.type,lastModified:i.lastModified})})}class Bj{constructor(t=1200){this.staleMs=t,this.depth=0,this.lastSeen=0}enter(t){this.depth+=1,this.lastSeen=t}over(t){this.depth===0&&(this.depth=1),this.lastSeen=t}leave(t){return this.depth=Math.max(0,this.depth-1),this.lastSeen=t,this.depth>0}reset(){this.depth=0}active(t){return this.depth>0&&t-this.lastSeen<this.staleMs}}const Ci="llm.delta",ro="llm.delta_end";function Wj(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function ra(e){return typeof e=="string"&&e.trim()!==""}function Vj(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0}function Xy(e){return"reason"in e}function qy(e,t){const n=Wj(e),r=n==null?void 0:n.kind,i=t||(typeof r=="string"&&r?r:n&&"reason"in n?ro:Ci),c=h=>{throw new Error(`Malformed ${i} event from the gateway: ${h}`)};if(t!==void 0&&t!==Ci&&t!==ro&&c(`unknown event name ${JSON.stringify(t)}`),!n)return c("the payload is not an object");r!==void 0&&r!==Ci&&r!==ro&&c(`unknown kind ${JSON.stringify(r)}`),r!==void 0&&t!==void 0&&r!==t&&c(`kind ${JSON.stringify(r)} does not match the event name`),ra(n.run_id)||c("run_id is missing"),ra(n.call_id)||c("call_id is missing"),Vj(n.seq)||c("seq is not a non-negative integer");const u=t||r?(t||r)===ro:"reason"in n;n.root_run_id!==void 0&&!ra(n.root_run_id)&&c("root_run_id is not a run id"),n.parent_run_id!==void 0&&n.parent_run_id!==null&&!ra(n.parent_run_id)&&c("parent_run_id is neither a run id nor null");const d={run_id:n.run_id,...ra(n.root_run_id)?{root_run_id:n.root_run_id}:{},...n.parent_run_id!==void 0?{parent_run_id:n.parent_run_id}:{},...ra(n.node_id)?{node_id:n.node_id}:{},call_id:n.call_id,seq:n.seq};return u?(["completed","failed","cancelled","unavailable"].includes(String(n.reason))||c(`unknown reason ${JSON.stringify(n.reason)}`),n.detail!==void 0&&n.detail!==null&&typeof n.detail!="string"&&c("detail is not a string"),{kind:ro,...d,reason:n.reason,...ra(n.detail)?{detail:n.detail}:{}}):(typeof n.text!="string"&&c("text is not a string"),n.channel!=="content"&&n.channel!=="reasoning"&&c(`unknown channel ${JSON.stringify(n.channel)}`),typeof n.snapshot!="boolean"&&c("snapshot is not a boolean"),{kind:Ci,...d,text:n.text,channel:n.channel,snapshot:n.snapshot})}function Zy(e,t){if(e!==Ci&&e!==ro)return null;let n=t;if(typeof t=="string")try{n=JSON.parse(t)}catch{throw new Error(`Malformed ${e} event from the gateway: data is not JSON`)}return qy(n,e)}function Hj(e){if(e==="on")return{stream:!0};if(e==="off")return{stream:!1};if(e==="gateway_default")return{};throw new Error(`Unknown streamReplies mode ${JSON.stringify(e)}; use "gateway_default", "on" or "off"`)}const Gj={structured_output:"this step asks the model for structured output",remote_core:"the model runs on a remote AbstractCore server",provider_cannot_stream:"the model provider cannot stream",sink_error:"the gateway could not relay the live text",usage_unavailable:"the provider does not report token usage while streaming"};function Kj(e){return`This reply is not streamed: ${e?Gj[e]||`the gateway reported "${e}"`:"the gateway gave no reason"}. It appears when it is complete.`}const $c=1024*1024,Jj="1 MiB",Qj=25*1024*1024,ew=(e,t)=>`${_e(`runs/${encodeURIComponent(e)}/workspace`)}/content?${new URLSearchParams({path:t})}`;function tw(e){const t=e.headers.get("content-range"),n=t?Number(t.split("/")[1]):NaN;if(Number.isFinite(n))return n;const r=Number(e.headers.get("content-length"));return e.status===200&&Number.isFinite(r)&&e.headers.has("content-length")?r:void 0}async function Yj(e,t,n){var m;const r=new TextDecoder;let i="",c=0;const u=(m=e.body)==null?void 0:m.getReader();if(u){for(;c<t;){const{done:p,value:v}=await u.read();if(p)break;const _=v.subarray(0,t-c);c+=_.length,i+=r.decode(_,{stream:!0})}await u.cancel().catch(()=>{})}else i=(await e.text()).slice(0,t),c=i.length;const d=tw(e)??n,h=d!==void 0?d>c:c>=t;return{text:i,received:c,total:d,partial:h}}function nw(e){return`Showing the first ${Jj} of ${e!==void 0?Hc(e):"a file of unknown size"}; download for the rest.`}function Xj(e){try{return decodeURIComponent(e)}catch{return e}}function qj(e,t,n){const r=`${_e(`runs/${encodeURIComponent(t)}/workspace`)}/content?`,i=n.split("/").slice(0,-1),c=h=>{if(/^[a-z][a-z0-9+.-]*:/i.test(h)||h.startsWith("/")||h.startsWith("#"))return null;const m=[...i];for(const p of h.split(/[?#]/,1)[0].split("/"))if(!(!p||p==="."))if(p===".."){if(!m.length)return null;m.pop()}else m.push(Xj(p));return m.length?ew(t,m.join("/")):null},u=h=>{let m="",p=0;for(;p<h.length;){if(h[p]==="!"&&h[p+1]==="["){const v=h.indexOf("]",p+2);if(v!==-1&&h[v+1]==="("){const _=h.indexOf(")",v+2);if(_!==-1){const b=h.slice(p+2,v),C=h.slice(v+2,_).trim(),x=C.startsWith(r)?C:c(C);m+=x?``:`[image: ${b||C}](${C})`,p=_+1;continue}}}m+=h[p],p+=1}return m};let d=!1;return e.split(`
|
|
75
|
+
`).map(h=>/^\s*(```|~~~)/.test(h)?(d=!d,h):d?h:u(h)).join(`
|
|
76
|
+
`)}function Zj(e,t,n,r){const[i,c]=y.useState({status:"idle"});return y.useEffect(()=>{if(!n||!t){c({status:"idle"});return}const u=new AbortController;let d="";const h=Nc(n.name);if(h==="binary"){c({status:"ready",kind:"binary",contentType:"",partial:!1});return}if((h==="image"||h==="audio"||h==="pdf")&&typeof n.size_bytes=="number"&&n.size_bytes>Qj){c({status:"error",kind:h,message:`Too large to preview (${Hc(n.size_bytes)}); use Download.`});return}c({status:"loading",kind:h});const m=gf(h);return(async()=>{var p;try{const v=await e(ew(t,n.path),{signal:u.signal,...m?{headers:{Range:`bytes=0-${$c-1}`}}:{}});if(!v.ok)throw new Error(`Preview failed (HTTP ${v.status}): ${await v.text().catch(()=>"")||v.statusText||"no reason given"}`);const _=v.headers.get("content-type")||"",b=Nc(n.name,_);if(gf(b)){const C=await Yj(v,$c,n.size_bytes);if(u.signal.aborted)return;c({status:"ready",kind:b,contentType:_,text:b==="markdown"?qj(C.text,t,n.path):C.text,partial:C.partial,total:C.total});return}if(b==="image"||b==="audio"||b==="pdf"){const C=await v.blob();if(u.signal.aborted)return;d=URL.createObjectURL(C.type?C:new Blob([C],{type:b==="pdf"?"application/pdf":_})),c({status:"ready",kind:b,contentType:_,url:d,partial:!1});return}await((p=v.body)==null?void 0:p.cancel().catch(()=>{})),u.signal.aborted||c({status:"ready",kind:"binary",contentType:_,partial:!1})}catch(v){u.signal.aborted||c({status:"error",kind:h,message:String((v==null?void 0:v.message)||v)})}})(),()=>{u.abort(),d&&URL.revokeObjectURL(d)}},[e,t,n==null?void 0:n.path,n==null?void 0:n.name,n==null?void 0:n.size_bytes,r]),i}function sw(e){return a.jsx(Tk,{...e,nowMs:e.nowMs??Date.now(),renderMarkdown:t=>a.jsx(Fy,{text:t})})}function eS(e){return e.status==="idle"||e.status==="loading"?{status:"loading",...e.status==="loading"?{kind:e.kind}:{}}:e.status==="error"?{status:"error",error:e.message,kind:e.kind}:{status:"ready",kind:e.kind,contentType:e.contentType,...e.text!==void 0?{text:e.text}:{},...e.url?{url:e.url}:{},...e.partial?{partialNote:nw(e.total)}:{}}}const Ff=e=>_e(`runs/${encodeURIComponent(e)}/workspace`);function tS(e){return Ff(e)}function nS(e,t){return`${Ff(e)}/files?${new URLSearchParams({path:t,recursive:"false"})}`}function rw(e,t){return`${Ff(e)}/content?${new URLSearchParams({path:t})}`}async function yo(e,t){let n="";try{const r=await e.text();try{const i=JSON.parse(r),c=(i==null?void 0:i.detail)??(i==null?void 0:i.error)??(i==null?void 0:i.message);n=typeof c=="string"?c:c&&typeof c.message=="string"?c.message:r}catch{n=r}}catch{n=""}return new Error(`${t} (HTTP ${e.status}): ${n.trim()||e.statusText||"no reason given"}`)}function sS(e,t){const n=e&&typeof e=="object"&&!Array.isArray(e)?e:null,r=u=>{throw new Error(`Unexpected /workspace/files response from the gateway: ${u}.`)};if(!n)return r("not an object");Array.isArray(n.entries)||r("no `entries` list"),typeof n.truncated!="boolean"&&r("no `truncated` flag");const i=n.entries.map((u,d)=>{const h=u&&typeof u=="object"?u:{};return(typeof h.name!="string"||typeof h.path!="string"||h.type!=="file"&&h.type!=="dir")&&r(`entry ${d+1} lacks a name, path or file/dir type`),h}),c=n.hidden&&typeof n.hidden=="object"&&!Array.isArray(n.hidden)?n.hidden:void 0;return{path:typeof n.path=="string"?n.path:t,entries:i,truncated:n.truncated,...c?{hidden:c}:{}}}async function rS(e,t,n){const r=await e(tS(t),{signal:n});if(!r.ok)throw await yo(r,"The workspace is not available");const i=await r.json();if(!i||typeof i.workspace_root!="string"||typeof i.exists!="boolean")throw new Error("Unexpected /workspace response from the gateway: no `workspace_root` / `exists`.");return i}async function aS(e,t,n,r){const i=await e(nS(t,n),{signal:r});if(!i.ok)throw await yo(i,"The folder could not be listed");return sS(await i.json(),n)}async function oS(e,t,n,r){const i=await e(rw(t,n),{signal:r});if(!i.ok)throw await yo(i,"The file could not be read");return await i.blob()}async function iS(e,t,n,r){const i=await rS(e,t,r);return{where:i,listing:i.exists?await aS(e,t,n,r):null}}function lS(e){const t=String(e||"").split("/").filter(Boolean),n=[{label:"Workspace",path:""}];return t.forEach((r,i)=>n.push({label:r,path:t.slice(0,i+1).join("/")})),n}function cS(e){if(typeof e!="number"||!Number.isFinite(e)||e<0)return"";if(e<1024)return`${e} B`;const t=["KiB","MiB","GiB","TiB"];let n=e/1024,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n<10?n.toFixed(1):Math.round(n)} ${t[r]}`}function uS(e){return[...e].sort((t,n)=>t.type===n.type?t.name.localeCompare(n.name):t.type==="dir"?-1:1)}function dS(e){const t=e.hidden||{},n=Number(t.blocked||0)+Number(t.outside_links||0)+Number(t.other||0),r=[];return n>0&&r.push(`${n} ${n===1?"entry":"entries"} hidden by the gateway's workspace rules`),e.truncated&&r.push("the list is truncated"),r.join("; ")}const fS=new Set(["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","application/pdf","text/plain","application/json"]);function hS(e){const t=String(e||"").split(";",1)[0].trim().toLowerCase();return fS.has(t)?{mode:"open",type:t}:t.startsWith("text/")||t.endsWith("+xml")||t.endsWith("+json")||t.endsWith("/xml")||t.endsWith("/javascript")||t.endsWith("/x-yaml")||t.endsWith("/toml")?{mode:"open",type:"text/plain;charset=utf-8"}:{mode:"download"}}function aw(e,t,n){const r=n==="open"?hS(e.type):{mode:"download"},i=r.mode==="open"&&r.type!==e.type?new Blob([e],{type:r.type}):e,c=URL.createObjectURL(i);if(r.mode==="open")window.open(c,"_blank","noopener");else{const u=document.createElement("a");u.href=c,u.download=t,document.body.appendChild(u),u.click(),u.remove()}window.setTimeout(()=>URL.revokeObjectURL(c),6e4)}async function mS(e,t,n){const r=await e(S_(t),{signal:n.signal});if(!r.ok)throw await yo(r,`${n.name} could not be read`);aw(await r.blob(),n.name,n.mode??"open")}function pS(e){const t=String(e||"").split(/[\\/]/).filter(Boolean);return t.length?t[t.length-1]:String(e||"")}function gS(e){var t;return!!(e&&e.open_supported===!0&&((t=e.host)==null?void 0:t.caller_is_this_machine)===!0&&e.exists)}async function yS(e){try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}function zf(e){var ee;const{fetchGateway:t,runId:n}=e,[r,i]=y.useState({runId:n,path:""}),c=r.runId===n?r.path:"",[u,d]=y.useState(null),[h,m]=y.useState(""),[p,v]=y.useState(""),[_,b]=y.useState(!!n),[C,x]=y.useState(""),[j,N]=y.useState(!1),[$,S]=y.useState(0),[E,A]=y.useState(null),R=E&&E.runId===n&&!e.onSelectFile?E.entry:null,z=Zj(t,n,R,`${e.refreshKey??""}:${$}`);y.useEffect(()=>{if(!n)return;const P=new AbortController;return b(!0),m(""),(async()=>{try{const Z=await iS(t,n,c,P.signal);P.signal.aborted||d({runId:n,...Z})}catch(Z){P.signal.aborted||m(String((Z==null?void 0:Z.message)||Z))}finally{P.signal.aborted||b(!1)}})(),()=>P.abort()},[t,n,c,$,e.refreshKey]),y.useEffect(()=>v(""),[n]);const L=u&&u.runId===n?u:null,J=y.useCallback(async P=>{x(P.path),m("");try{aw(await oS(t,n,P.path),P.name,"download")}catch(Z){m(String((Z==null?void 0:Z.message)||Z))}finally{x("")}},[t,n]),V=(L==null?void 0:L.where.workspace_root)||"",O=e.nowMs??Date.now();return a.jsx(wS,{title:e.title,note:e.note,where:(L==null?void 0:L.where)??null,path:c,listing:(L==null?void 0:L.listing)??null,error:h,notice:p,loading:_,fileBusy:C,selectedPath:e.onSelectFile?e.selectedPath:R==null?void 0:R.path,className:e.className,nowMs:O,openingFolder:j,onNavigate:P=>{A(null),i({runId:n,path:P})},onRefresh:()=>S(P=>P+1),onFile:P=>void J(P),onSelectFile:e.onSelectFile??(P=>A({runId:n,entry:P})),onClose:e.onClose,onCopyPath:V?()=>{(e.copyText||yS)(V).then(P=>v(P?"Path copied.":"Could not copy; select the path instead."))}:void 0,onOpenFolder:e.onOpenFolder&&gS(L==null?void 0:L.where)?()=>{N(!0),v(""),e.onOpenFolder().then(()=>v("Folder opened on this machine.")).catch(P=>v(`Open folder failed: ${String((P==null?void 0:P.message)||P)}`)).finally(()=>N(!1))}:void 0,preview:R?a.jsx(sw,{name:R.name,path:R.path,sizeBytes:R.size_bytes,modified:R.mtime,nowMs:O,...eS(z),actions:(ee=e.fileActions)==null?void 0:ee.call(e,R),onDownload:()=>void J(R),onClose:()=>A(null)}):null})}function wS(e){var c,u,d,h;const t=e.listing?dS(e.listing):"",n=(u=(c=e.where)==null?void 0:c.host)==null?void 0:u.hostname,r=((d=e.where)==null?void 0:d.workspace_root)||"",i=e.nowMs??Date.now();return a.jsxs("section",{className:`pc-ws${e.className?` ${e.className}`:""}`,"aria-label":e.title,"data-workspace-root":r||void 0,children:[a.jsxs("header",{className:"pc-ws__head",children:[a.jsxs("span",{className:"pc-ws__title",children:[a.jsx(ne,{name:"folder",size:15})," ",e.title]}),a.jsx("span",{className:"pc-ws__spacer"}),a.jsx("button",{type:"button",className:"pc-ws__icon-btn","data-action":"refresh-folder",onClick:e.onRefresh,disabled:e.loading,title:"Refresh","aria-label":"Refresh the folder",children:a.jsx(ne,{name:"refresh",size:14})}),e.onClose?a.jsx("button",{type:"button",className:"pc-ws__icon-btn","data-action":"close-folder",onClick:e.onClose,title:"Close","aria-label":"Close the file browser",children:a.jsx(ne,{name:"x",size:14})}):null]}),e.where?a.jsxs("div",{className:"pc-ws__root",children:[a.jsx("span",{className:"pc-ws__root-name",title:r,"data-root-name":"true",children:pS(r)}),e.onOpenFolder?a.jsx("button",{type:"button",className:"pc-ws__icon-btn pc-ws__icon-btn--bare","data-action":"open-folder",onClick:e.onOpenFolder,disabled:e.openingFolder,title:"Open folder","aria-label":"Open the folder on this machine",children:a.jsx(ne,{name:"folder",size:14})}):null,e.onCopyPath?a.jsx("button",{type:"button",className:"pc-ws__icon-btn pc-ws__icon-btn--bare","data-action":"copy-path",onClick:e.onCopyPath,title:"Copy path","aria-label":"Copy the folder path",children:a.jsx(ne,{name:"copy",size:14})}):null,n&&((h=e.where.host)==null?void 0:h.caller_is_this_machine)!==!0?a.jsxs("span",{className:"pc-ws__muted",children:[" on ",n]}):null]}):null,e.note?a.jsx("div",{className:"pc-ws__muted",children:e.note}):null,e.notice?a.jsx("div",{className:"pc-ws__muted",role:"status",children:e.notice}):null,e.error?a.jsx("div",{className:"pc-ws__error",role:"alert",children:e.error}):null,e.preview?a.jsx("div",{className:"pc-ws__preview",children:e.preview}):a.jsxs(a.Fragment,{children:[a.jsx("nav",{className:"pc-ws__crumbs","aria-label":"Folder",children:lS(e.path).map((m,p,v)=>p===v.length-1?a.jsx("span",{"aria-current":"page",children:m.label},m.path):a.jsxs(lt.Fragment,{children:[a.jsx("button",{type:"button",className:"pc-ws__crumb",onClick:()=>e.onNavigate(m.path),children:m.label}),a.jsx("span",{className:"pc-ws__muted",children:" / "})]},m.path))}),e.loading&&!e.listing?a.jsx("div",{className:"pc-ws__muted",role:"status",children:"Loading…"}):null,e.where&&!e.where.exists?a.jsx("div",{className:"pc-ws__muted",children:"The folder does not exist yet: nothing has been written."}):null,e.listing?e.listing.entries.length?a.jsx("ul",{className:"pc-ws__entries",children:uS(e.listing.entries).map(m=>a.jsx("li",{className:`pc-ws__entry${e.selectedPath===m.path?" is-selected":""}`,"data-type":m.type,"data-path":m.path,children:m.type==="dir"?a.jsxs("button",{type:"button",className:"pc-ws__name","data-action":"open-dir",onClick:()=>e.onNavigate(m.path),children:[a.jsx(ne,{name:"folder",size:14})," ",a.jsxs("span",{className:"pc-ws__label",children:[m.name,"/"]})]}):a.jsxs(a.Fragment,{children:[e.onSelectFile?a.jsxs("button",{type:"button",className:"pc-ws__name","data-action":"select-file","aria-pressed":e.selectedPath===m.path,title:`Preview ${m.name}`,onClick:()=>{var p;return(p=e.onSelectFile)==null?void 0:p.call(e,m)},children:[a.jsx(ne,{name:"file",size:14})," ",a.jsx("span",{className:"pc-ws__label",children:m.name})]}):a.jsxs("span",{className:"pc-ws__name",children:[a.jsx(ne,{name:"file",size:14})," ",a.jsx("span",{className:"pc-ws__label",children:m.name})]}),a.jsxs("span",{className:"pc-ws__meta",children:[a.jsx("span",{className:"pc-ws__size",children:cS(m.size_bytes)}),m.mtime!==void 0&&fo(m.mtime,i)?a.jsx("time",{className:"pc-ws__time",title:Vc(m.mtime),"data-meta":"modified",children:fo(m.mtime,i)}):null]}),e.onFile?a.jsx("button",{type:"button",className:"pc-ws__icon-btn pc-ws__icon-btn--bare","data-action":"download-file",disabled:e.fileBusy===m.path,onClick:()=>{var p;return(p=e.onFile)==null?void 0:p.call(e,m,"download")},title:"Download","aria-label":`Download ${m.name}`,children:a.jsx(ne,{name:"download",size:14})}):null]})},m.path))}):a.jsx("div",{className:"pc-ws__muted",children:"This folder is empty."}):null,t?a.jsx("div",{className:"pc-ws__muted","data-hidden-note":"true",children:t}):null]})]})}const vS={registry_scope:"tenant_catalog",bundle_id:"docs-qa",bundle_version:"0.1.1",flow_id:"docsqa001"},ow="docs";function _S(e){return _e(`docs/corpus?${new URLSearchParams({app:String(e||"")})}`)}function Fd(e){return`${String(e||"app")}-docs-assistant:${la()}`}function bS(e){const t={prompt:e.question,docs:e.docs,app:e.appName,use_session_history:!0};return e.attachments&&e.attachments.length&&(t.context={attachments:e.attachments}),{...vS,session_id:e.sessionId,kind:ow,input_data:t}}function iw(e){const t=e==null?void 0:e.output;if(typeof t=="string")return t.trim();const n=t==null?void 0:t.response;return typeof n=="string"?n.trim():""}function xS(e){const t=e&&typeof e=="object"?e:{},n=d=>typeof d=="number"&&Number.isFinite(d)&&d>0?Math.trunc(d):0,r=n(t.dropped_messages);if(!r)return"";const i=n(t.replayed_messages),c=n(t.dropped_tokens),u=n(t.max_tokens);return`Earlier messages not replayed: ${r.toLocaleString("en-US")}${c?` (~${c.toLocaleString("en-US")} tokens)`:""}. The model read the newest ${i.toLocaleString("en-US")} message${i===1?"":"s"}`+(u?` (history window: the most recent ${u.toLocaleString("en-US")} tokens of whole messages).`:".")}async function*kS(e,t){const n=e.getReader(),r=new TextDecoder;let i="";const c=()=>{n.cancel().catch(()=>{})};t==null||t.addEventListener("abort",c,{once:!0});try{for(;;){const{value:u,done:d}=await n.read();if(d)break;i+=r.decode(u,{stream:!0}).replace(/\r\n/g,`
|
|
77
|
+
`);let h=i.indexOf(`
|
|
78
|
+
|
|
79
|
+
`);for(;h>=0;){const m=i.slice(0,h);i=i.slice(h+2);let p="message";const v=[];for(const _ of m.split(`
|
|
80
|
+
`))_.startsWith("event:")?p=_.slice(6).trim():_.startsWith("data:")&&v.push(_.slice(5).replace(/^ /,""));v.length&&(yield{event:p,data:v.join(`
|
|
81
|
+
`)}),h=i.indexOf(`
|
|
82
|
+
|
|
83
|
+
`)}}}finally{t==null||t.removeEventListener("abort",c)}}function jS(e,t){return new Promise((n,r)=>{if(t.aborted)return r(new DOMException("Aborted","AbortError"));const i=setTimeout(()=>{t.removeEventListener("abort",c),n()},e),c=()=>{clearTimeout(i),r(new DOMException("Aborted","AbortError"))};t.addEventListener("abort",c,{once:!0})})}async function $r(e,t){if(!e.ok)throw await yo(e,t);return e.json()}function SS(e){const t=e.pollMs??1e3,n=e.timeoutMs??18e4;let r=null;return async(i,c)=>{var C;const{fetchGateway:u,source:d}=e;if(r===null){const x=await u(_S(d.app),{signal:c.signal,headers:{Accept:"application/json"}}),j=await $r(x,`The ${d.name} documentation could not be read, so nothing was asked`),N=typeof(j==null?void 0:j.text)=="string"?j.text:"";if(!N.trim())throw new Error(`The gateway returned an empty ${d.name} documentation corpus, so nothing was asked.`);r=N}const h=String(r),m=[];for(const x of c.files||[]){const j=new FormData;j.append("session_id",c.sessionId),j.append("file",x,x.name||"upload.bin"),j.append("filename",x.name||"upload.bin"),x.type&&j.append("content_type",x.type);const N=await $r(await u(_e("attachments/upload"),{method:"POST",body:j,signal:c.signal}),`"${x.name}" could not be attached`),$=N==null?void 0:N.attachment;if(!$||typeof $.$artifact!="string"||!$.$artifact)throw new Error(`"${x.name}" could not be attached: the gateway returned no attachment reference.`);m.push($)}const p=await $r(await u(_e("runs/start"),{method:"POST",signal:c.signal,headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(bS({question:i,docs:h,appName:d.name,sessionId:c.sessionId,attachments:m}))}),"The docs-qa workflow could not start"),v=String((p==null?void 0:p.run_id)||"");if(!v)throw new Error("The gateway did not return a run id for the docs-qa workflow.");const _=new AbortController,b=()=>_.abort();c.signal.addEventListener("abort",b,{once:!0}),c.onText&&(async()=>{var x;try{const j=await u(_e(`runs/${encodeURIComponent(v)}/ledger/stream?after=0`),{signal:_.signal,headers:{Accept:"text/event-stream"}});if(!j.ok||!j.body)return;let N="",$="";for await(const S of kS(j.body,_.signal)){const E=Zy(S.event,S.data);!E||Xy(E)||E.channel!=="content"||E.run_id!==v||(E.call_id!==N&&(N=E.call_id,$=""),$=E.snapshot?E.text:$+E.text,(x=c.onText)==null||x.call(c,$))}}catch{}})();try{const x=Date.now()+n;for(;;){await jS(t,c.signal);const j=await $r(await u(_e(`runs/${encodeURIComponent(v)}`),{signal:c.signal}),"The docs-qa run could not be read"),N=String((j==null?void 0:j.status)||"").toLowerCase();if(N==="completed"){(C=c.onHistory)==null||C.call(c,(j==null?void 0:j.session_history)??null);const $=iw(j);if(!$)throw new Error(`The docs-qa run ${v} completed without an answer.`);return $}if(N==="failed"||N==="cancelled"){const $=j==null?void 0:j.error,S=typeof $=="string"?$:typeof($==null?void 0:$.message)=="string"?$.message:"";throw new Error(`The docs-qa run ${N}${S?`: ${S}`:""}.`)}if(N==="waiting")throw new Error(`The docs-qa run ${v} is waiting for input it should never need. Inspect it in Observer.`);if(Date.now()>=x)throw new Error(`The docs-qa run ${v} is still running after ${Math.round(n/1e3)} s. It stays in the gateway's history.`)}}finally{c.signal.removeEventListener("abort",b),_.abort()}}}async function NS(e,t,n={}){const r=new URLSearchParams({root_only:"true",kind:ow,limit:"500",include_ledger_len:"false"}),i=await $r(await e(_e(`runs?${r}`),{signal:n.signal}),"The docs assistant history could not be read"),c=`${String(t||"app")}-docs-assistant:`,u=new Map;for(const h of Array.isArray(i==null?void 0:i.items)?i.items:[]){const m=String((h==null?void 0:h.session_id)||"");if(!m.startsWith(c)||!(h!=null&&h.run_id))continue;const p=u.get(m)||{runs:[],updatedAt:""};p.runs.push({id:String(h.run_id),created:String(h.created_at||"")});const v=String(h.updated_at||h.created_at||"");v>p.updatedAt&&(p.updatedAt=v),u.set(m,p)}const d=[...u.entries()].sort((h,m)=>h[1].updatedAt<m[1].updatedAt?1:-1).slice(0,n.max??20);return Promise.all(d.map(async([h,m])=>{var _;const p=m.runs.sort((b,C)=>b.created<C.created?-1:1).map(b=>b.id);let v="";try{const b=await $r(await e(_e(`runs/${encodeURIComponent(p[0])}/input_data`),{signal:n.signal}),"");v=String(((_=b==null?void 0:b.input_data)==null?void 0:_.prompt)||"").trim()}catch{v=""}return{sessionId:h,title:v||"Untitled question",updatedAt:m.updatedAt,runIds:p}}))}async function CS(e,t,n,r){var c;const i=[];for(const u of t.runIds){const[d,h]=await Promise.all([$r(await e(_e(`runs/${encodeURIComponent(u)}/input_data`),{signal:r}),"A past question could not be read"),$r(await e(_e(`runs/${encodeURIComponent(u)}`),{signal:r}),"A past answer could not be read")]),m=String(((c=d==null?void 0:d.input_data)==null?void 0:c.prompt)||"").trim();m&&i.push({id:`u-${u}`,role:"user",content:m,ts:String((h==null?void 0:h.created_at)||"")||void 0});const p=iw(h),v=String((h==null?void 0:h.status)||"").toLowerCase();i.push(p?{id:`a-${u}`,role:"assistant",title:n,content:p,ts:String((h==null?void 0:h.updated_at)||"")||void 0}:{id:`a-${u}`,role:"assistant",title:n,level:"warn",content:v==="completed"?"This answer was empty.":`No answer: the run is ${v||"unknown"}.`})}return i}function ES(e){const[t,n]=y.useState(null);return e.state==="loading"?a.jsx("div",{className:"pc-docs-history__note",role:"status",children:"Loading past conversations…"}):e.state==="error"?a.jsx("div",{className:"pc-docs-history__note pc-docs-history__note--error",role:"alert",children:e.error||"The history could not be read."}):e.items.length?a.jsx("ul",{className:"pc-docs-history","aria-label":"Past conversations",children:e.items.map(r=>a.jsx("li",{className:`pc-docs-history__row${r.sessionId===e.activeSessionId?" is-active":""}`,children:t===r.sessionId?a.jsxs("div",{className:"pc-docs-history__confirm",children:[a.jsx("span",{children:"Archive this conversation? It stays in the gateway; it leaves this list."}),a.jsx("button",{type:"button",className:"pc-docs-history__btn pc-docs-history__btn--danger",onClick:()=>{n(null),e.onArchive(r)},children:"Archive"}),a.jsx("button",{type:"button",className:"pc-docs-history__btn",onClick:()=>n(null),children:"Cancel"})]}):a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",className:"pc-docs-history__open",onClick:()=>e.onOpen(r),title:r.title,children:[a.jsx("span",{className:"pc-docs-history__title",children:r.title}),a.jsxs("span",{className:"pc-docs-history__meta",children:[fo(r.updatedAt,e.nowMs),r.runIds.length>1?` · ${r.runIds.length} questions`:""]})]}),a.jsx("button",{type:"button",className:"pc-docs-assistant__icon-btn","aria-label":`Archive "${r.title}"`,"data-af-tip":`Archive "${r.title}" (kept, hidden)`,onClick:()=>n(r.sessionId),children:a.jsx(ne,{name:"archive",size:16})})]})},r.sessionId))}):a.jsx("div",{className:"pc-docs-history__note",children:"No past conversations yet."})}const $S=/^image\/(png|jpe?g|gif|webp|avif|bmp|svg\+xml)$/i;function AS(e){const t=y.useRef(null),[n,r]=y.useState(!1),i=!!e.blockedNotice,c=!!e.busy,u=e.files||[],d=typeof e.onAddFiles=="function"&&!i,h=a.jsxs("div",{className:"pc-docs-assistant__empty",children:[a.jsxs("p",{className:"pc-docs-assistant__empty-text",children:["Ask anything about ",e.source.name,"."]}),e.suggestions&&e.suggestions.length?a.jsx("div",{className:"pc-docs-assistant__suggestions",children:e.suggestions.map(m=>a.jsx("button",{type:"button",className:"pc-docs-assistant__suggestion",disabled:c||i,onClick:()=>{var p;return(p=e.onSuggestion)==null?void 0:p.call(e,m)},children:m},m))}):null]});return a.jsxs("div",{className:`pc-docs-assistant${n?" is-dragging":""}`,onDragOver:m=>{var p;!d||!Ni((p=m.dataTransfer)==null?void 0:p.types)||(m.preventDefault(),r(!0))},onDragLeave:()=>r(!1),onDrop:m=>{var v,_;if(!d)return;m.preventDefault(),r(!1);const p=Df(m.dataTransfer);p.files.length&&((v=e.onAddFiles)==null||v.call(e,p.files)),p.folders.length&&((_=e.onNotice)==null||_.call(e,Qy(p.folders)))},children:[a.jsx(Ky,{className:"pc-docs-assistant__thread",messages:e.messages,autoScroll:!0,empty:h,messageProps:{showCopy:!0}}),i?a.jsx("div",{className:"pc-docs-assistant__blocked",role:"status",children:e.blockedNotice}):null,e.notice?a.jsx("div",{className:"pc-docs-assistant__notice",role:"status",children:e.notice}):null,a.jsx("div",{className:"pc-docs-assistant__composer",children:a.jsx(Jy,{value:e.draft,onChange:e.onDraftChange,onSubmit:e.onSend,placeholder:e.placeholder||`Ask about ${e.source.name}…`,ariaLabel:`Question about ${e.source.name}`,disabled:i,busy:c,rows:1,sendLabel:"Send",busyLabel:"Answering…",onPaste:m=>{var v;if(!d)return;const p=Yy(m.clipboardData);p.length&&(m.preventDefault(),(v=e.onAddFiles)==null||v.call(e,p))},leading:u.length?a.jsx("div",{className:"pc-chat-attachments pc-docs-assistant__files",role:"list","aria-label":"Attached files",children:u.map(m=>a.jsxs("span",{role:"listitem",className:"pc-chat-attachment-chip",children:[a.jsx(ne,{name:"paperclip",size:14}),a.jsx("span",{className:"pc-chat-attachment-name",children:m.name}),e.onRemoveFile&&!c?a.jsx("button",{type:"button",className:"pc-docs-assistant__file-remove","aria-label":`Remove ${m.name}`,"data-af-tip":`Remove ${m.name}`,onClick:()=>{var p;return(p=e.onRemoveFile)==null?void 0:p.call(e,m.id)},children:a.jsx(ne,{name:"x",size:12})}):null]},m.id))}):null,actions:a.jsxs(a.Fragment,{children:[d?a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:"pc-docs-assistant__icon-btn","aria-label":"Attach files","data-af-tip":"Attach files to your question",disabled:c,onClick:()=>{var m;return(m=t.current)==null?void 0:m.click()},children:a.jsx(ne,{name:"paperclip",size:16})}),a.jsx("input",{ref:t,type:"file",multiple:!0,hidden:!0,"aria-hidden":"true",tabIndex:-1,onChange:m=>{var v;const p=Array.from(m.currentTarget.files||[]);m.currentTarget.value="",p.length&&((v=e.onAddFiles)==null||v.call(e,p))}})]}):null,c&&e.onStop?a.jsx("button",{type:"button",className:"pc-docs-assistant__icon-btn","aria-label":"Stop","data-af-tip":"Stop the answer",onClick:e.onStop,children:a.jsx(ne,{name:"stop",size:14})}):null]})})}),a.jsxs("div",{className:"pc-docs-assistant__footer",title:`Answers come from ${e.source.name}'s documentation (llms.txt) through the gateway's docs-qa workflow.`,children:["Grounded on ",e.source.name,"’s documentation (llms.txt) · docs-qa"]})]})}function mc(){return new Date().toISOString()}function TS(e){mo();const{source:t}=e,n=y.useRef(e.fetchGateway);n.current=e.fetchGateway;const r=y.useMemo(()=>e.ask||SS({fetchGateway:(O,ee)=>n.current(O,ee),source:t}),[e.ask,t.app,t.name]),i=y.useRef(Fd(t.app)),[c,u]=y.useState([]),d=y.useRef(c);d.current=c;const[h,m]=y.useState(""),[p,v]=y.useState([]),[_,b]=y.useState(!1),[C,x]=y.useState(""),j=y.useRef(null),[N,$]=y.useState(!1),[S,E]=y.useState({state:"loading",items:[]});y.useEffect(()=>()=>{var O;return(O=j.current)==null?void 0:O.abort()},[]);const A=y.useCallback(async()=>{E(O=>({...O,state:"loading"}));try{const O=await NS((ee,P)=>n.current(ee,P),t.app);E({state:"ready",items:O})}catch(O){E({state:"error",items:[],error:String((O==null?void 0:O.message)||O)})}},[t.app]),R=y.useCallback(async O=>{var ee;(ee=j.current)==null||ee.abort(),E(P=>({...P,state:"loading"}));try{const P=await CS((Z,U)=>n.current(Z,U),O,t.name);i.current=O.sessionId,u(P),x(""),$(!1),E(Z=>({...Z,state:"ready"}))}catch(P){E(Z=>({...Z,state:"error",error:String((P==null?void 0:P.message)||P)}))}},[t.name]),z=y.useCallback(async O=>{try{const ee=await n.current(_e(`sessions/${encodeURIComponent(O.sessionId)}/archive`),{method:"POST"});if(!ee.ok)throw await yo(ee,"The conversation could not be archived");i.current===O.sessionId&&(i.current=Fd(t.app),u([])),E(P=>({...P,items:P.items.filter(Z=>Z.sessionId!==O.sessionId)}))}catch(ee){E(P=>({...P,state:"error",error:String((ee==null?void 0:ee.message)||ee)}))}},[t.app]);y.useEffect(()=>{var O;e.connected||(O=j.current)==null||O.abort()},[e.connected]),y.useEffect(()=>()=>{for(const O of p)O.preview&&URL.revokeObjectURL(O.preview)},[]);const L=y.useCallback(O=>{x(""),v(ee=>[...ee,...O.map(P=>({id:la(),file:P,preview:$S.test(P.type)&&typeof URL<"u"&&typeof URL.createObjectURL=="function"?URL.createObjectURL(P):void 0}))])},[]),J=y.useCallback(async O=>{const ee=String(O||"").trim();if(!ee||_||!e.connected)return;const P=p;m(""),v([]),x("");const Z=P.filter(I=>I.preview).map(I=>({kind:"image",src:I.preview,label:I.file.name})),U=P.map(I=>({id:I.id,label:I.file.name,title:I.file.name,disabled:!0})),te={id:`u-${la()}`,role:"user",content:ee,ts:mc(),...Z.length?{media:Z}:{},...U.length?{attachments:U}:{}},se=`a-${la()}`,G=[...d.current,te],ce={id:se,role:"assistant",title:t.name,content:"",ts:mc(),live:{callId:se,reasoning:"",label:"answering"}};u([...G,ce]),b(!0);const re=new AbortController;j.current=re;const D=I=>u([...G,I]);try{const I=await r(ee,{signal:re.signal,sessionId:i.current,files:P.map(W=>W.file),onText:W=>{re.signal.aborted||D({...ce,content:W,live:{callId:se,reasoning:"",label:"streaming"}})},onHistory:W=>x(xS(W))});re.signal.aborted||D({id:se,role:"assistant",title:t.name,content:I,ts:mc()})}catch(I){const W=re.signal.aborted;D({id:se,role:"assistant",title:t.name,level:W?"warn":"error",content:W?"Stopped. Nothing more will be shown for this question.":String((I==null?void 0:I.message)||I||"The docs assistant failed."),ts:mc()})}finally{j.current===re&&(j.current=null),b(!1)}},[r,_,p,e.connected,t.name]),V=()=>{var O;(O=j.current)==null||O.abort(),i.current=Fd(t.app),u([]),v([]),m(""),x("")};return a.jsxs(Q_,{open:e.open,onClose:e.onClose,label:"Docs assistant",title:a.jsxs("span",{className:"pc-docs-assistant__title",children:[a.jsx(ne,{name:"book",size:16}),"Docs assistant"]}),width:e.width||420,topOffset:e.topOffset,className:`pc-docs-assistant-drawer${e.className?` ${e.className}`:""}`,headerActions:a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:`pc-docs-assistant__icon-btn${N?" is-active":""}`,"aria-label":"Past conversations","data-af-tip":"Past conversations","aria-pressed":N,disabled:!e.connected||_,onClick:()=>{const O=!N;$(O),O&&A()},children:a.jsx(ne,{name:"history",size:16})}),a.jsx("button",{type:"button",className:"pc-docs-assistant__icon-btn","aria-label":"New conversation","data-af-tip":"Start a new conversation",disabled:!c.length&&!h&&!p.length&&!N,onClick:()=>{V(),$(!1)},children:a.jsx(ne,{name:"compose",size:16})})]}),children:[N?a.jsx("div",{className:"pc-docs-assistant pc-docs-assistant--history",children:a.jsx(ES,{items:S.items,state:S.state,error:S.error,nowMs:Date.now(),activeSessionId:i.current,onOpen:O=>void R(O),onArchive:O=>void z(O)})}):null,a.jsx("div",{hidden:N,style:{display:N?"none":"contents"},children:a.jsx(AS,{source:t,messages:c,draft:h,onDraftChange:m,onSend:()=>void J(h),onStop:()=>{var O;return(O=j.current)==null?void 0:O.abort()},busy:_,blockedNotice:e.connected?void 0:"Connect to the gateway to use the docs assistant.",files:p.map(O=>({id:O.id,name:O.file.name})),onAddFiles:L,onNotice:x,onRemoveFile:O=>v(ee=>{const P=ee.find(Z=>Z.id===O);return P!=null&&P.preview&&URL.revokeObjectURL(P.preview),ee.filter(Z=>Z.id!==O)}),notice:C,suggestions:e.suggestions,onSuggestion:O=>void J(O),placeholder:e.placeholder})})]})}const ot=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{},xc=e=>Array.isArray(e)?e.map(ot):[],Je=e=>typeof e=="string"?e:"",mi=e=>Je(e.runtime_call_id||e.call_uid),pi=e=>Je(e.call_id||e.id);function lw(e,t){const n=t.record,r=ot(n.effect);if(r.type!=="tool_calls")return[];const i=ot(n.result),c=xc(ot(r.payload).tool_calls),u=c.length||n.status!=="waiting"?c:xc(ot(ot(i.wait).details).tool_calls),d=xc(i.results),h=u.length?u:d,m=[];return h.forEach((p,v)=>{let _=mi(p)?d.filter(R=>mi(R)===mi(p)):[];!_.length&&pi(p)&&u.filter(R=>pi(R)===pi(p)).length===1&&(_=d.filter(R=>pi(R)===pi(p)));const b=u.length?_.length===1?_[0]:u.length===d.length?d[v]:{}:p,C=mi(p)||mi(b)||`${Je(n.idempotency_key)||Je(n.step_id)||t.cursor}:${v}`,x=`${t.runId}:${C}`,j=e.get(x),N=Je(p.name||b.name)||(j==null?void 0:j.name);if(!N)return;const $=n.status==="completed"||n.status==="failed",S=n.status==="failed"||b.success===!1||!!b.error,E=p.arguments??b.arguments??(j==null?void 0:j.arguments),A={...j,id:x,runId:t.runId,name:N,arguments:E,status:$?S?"failed":"completed":n.status==="waiting"?"waiting":"running",...typeof b.success=="boolean"?{success:b.success}:{},...b.output!==void 0||b.result!==void 0?{output:b.output??b.result}:{},...b.error?{error:String(b.error)}:{},...Up(b)?{sandbox:Up(b)}:{},startedAt:(j==null?void 0:j.startedAt)||Je(n.started_at)||void 0,endedAt:$&&Je(n.ended_at)||(j==null?void 0:j.endedAt)};j&&["completed","failed"].includes(j.status)&&!$||(e.set(x,A),m.push(A))}),m}function ao(e){if(e==null||e===""||typeof e=="boolean")return;const t=Number(e);return Number.isFinite(t)&&t>=0?t:void 0}function Ns(e,t){for(const n of t){const r=e==null?void 0:e[n];if(r==null||r===""||typeof r=="boolean")continue;const i=Number(r);if(Number.isFinite(i)&&i>=0)return Math.trunc(i)}}function cw(e){if(typeof e=="string")try{return ot(JSON.parse(e))}catch{return{}}return ot(e)}function Za(e,t){if(t===void 0||t==="")return e;const n=e||[];return n.includes(t)||n.push(t),n}function RS(e){return Ns(e,["reasoning_tokens","thinking_tokens"])??Ns(ot(e.completion_tokens_details),["reasoning_tokens"])??Ns(ot(e.output_tokens_details),["reasoning_tokens"])}function IS(e){const t=ot(typeof e=="string"&&e.trim().startsWith("{")?cw(e):e);return Je(t.error_class)}function MS(e){const t=new Map;for(const n of e){const r=n.record;if(ot(r.effect).type!=="emit_event")continue;const i=ot(r.result);if(Je(i.name)!=="abstract.progress")continue;const c=ot(i.payload);if(Je(c.kind)!=="llm"||!Je(c.step_id))continue;const u=`${Je(c.run_id)||n.runId}:${Je(c.step_id)}`,d=t.get(u)||{},h=ao(c.ttft_s);h!==void 0&&(d.ttftS=h),d.provider=d.provider||Je(c.provider)||void 0,d.model=d.model||Je(c.model)||void 0,t.set(u,d)}return t}function Ti(e){var x,j,N,$;const t=new Map,n=new Set,r=new Set,i={llmCalls:0,toolCalls:0,changedFiles:[]};let c=1/0,u=-1/0,d=!1,h=0,m=0,p=0;const v=MS(e),_=[],b=new Set;for(const S of e){const E=S.record,A=`${S.runId}:${E.step_id||S.cursor}:${E.status}`;if(n.has(A))continue;n.add(A);for(const ae of[E.started_at,E.ended_at]){const we=Date.parse(Je(ae));Number.isFinite(we)&&(c=Math.min(c,we),u=Math.max(u,we))}for(const ae of lw(t,S))ae.status==="waiting"&&b.add(ae.id);if(ot(E.effect).type!=="llm_call"||E.status!=="completed")continue;i.llmCalls+=1;const R=ot(E.result),z=ot(R.output),L=ot(R.usage||R.token_usage||R.tokens||z.usage||z.token_usage||z.tokens),J=Ns(L,["input_tokens","prompt_tokens","prompt","input","in"]),V=Ns(L,["output_tokens","completion_tokens","completion","output","out"]),O=Ns(L,["total_tokens","total"])??(J!==void 0||V!==void 0?(J||0)+(V||0):void 0);O!==void 0&&(J===void 0||V===void 0||J+V!==O)&&(d=!0),J!==void 0&&(i.inputTokens=(i.inputTokens||0)+J),V!==void 0&&(i.outputTokens=(i.outputTokens||0)+V),O!==void 0&&(i.totalTokens=(i.totalTokens||0)+O);const ee=ao(R.gen_time??z.gen_time);ee!==void 0&&(i.genTimeMs=(i.genTimeMs||0)+ee,i.timedCalls=(i.timedCalls||0)+1);const P=ot(R.metadata||z.metadata),Z=ot(P.performance),U=ao(Z.prompt_tokens_per_second),te=ao(Z.generation_tokens_per_second),se=ot(P.prompt_cache),G=ao(se.cached_tokens),ce=ao(se.fed_tokens);if(U!==void 0||te!==void 0){if(i.measuredSpeedCalls=(i.measuredSpeedCalls||0)+1,U!==void 0&&U>0&&(i.promptTokensPerSecond=(i.promptTokensPerSecond||0)+U,J!==void 0)){const ae=J/U*1e3;i.prefillMs=(i.prefillMs||0)+ae,ce!==void 0&&(h+=ce,m+=ae)}te!==void 0&&te>0&&(i.generationTokensPerSecond=(i.generationTokensPerSecond||0)+te,V!==void 0&&(i.decodeMs=(i.decodeMs||0)+V/te*1e3))}if(G!==void 0||ce!==void 0){i.measuredCacheCalls=(i.measuredCacheCalls||0)+1,i.cachedTokens=(i.cachedTokens||0)+(G||0),i.fedTokens=(i.fedTokens||0)+(ce||0);const ae=Je(se.outcome);if(ae){const we=i.cacheOutcomes||[];we.includes(ae)||we.push(ae),i.cacheOutcomes=we}}const re=Je(E.step_id)||void 0,D=re&&v.get(`${S.runId}:${re}`)||{},I=ot(R.route),W={runId:S.runId};re&&(W.stepId=re),Je(E.started_at)&&(W.startedAt=Je(E.started_at));const me=Je(R.model||z.model)||Je(I.model)||D.model,q=Je(I.provider)||Je(ot(P._provider_request).provider)||D.provider||Je(R.provider);me&&(W.model=me),q&&(W.provider=q),me&&(i.models=Za(i.models,me)),q&&(i.providers=Za(i.providers,q)),(O===void 0||J!==void 0&&V!==void 0&&J+V===O)&&(J!==void 0&&(W.inputTokens=J),V!==void 0&&(W.outputTokens=V)),O!==void 0&&(W.totalTokens=O);const fe=RS(L);fe!==void 0&&(W.reasoningTokens=fe,i.reasoningTokens=(i.reasoningTokens||0)+fe),G!==void 0&&(W.cachedTokens=G),ce!==void 0&&(W.fedTokens=ce),Je(se.outcome)&&(W.cacheOutcome=Je(se.outcome)),Je(se.backend)&&(W.cacheBackend=Je(se.backend),i.cacheBackends=Za(i.cacheBackends,W.cacheBackend)),ee!==void 0&&(W.genTimeMs=ee),U!==void 0&&U>0&&(W.promptTokensPerSecond=U),te!==void 0&&te>0&&(W.generationTokensPerSecond=te),D.ttftS!==void 0?(W.ttftMs=D.ttftS*1e3,W.promptMs=W.ttftMs,W.promptSource="ttft",i.ttftMs=(i.ttftMs||0)+W.ttftMs,i.ttftCalls=(i.ttftCalls||0)+1):W.promptTokensPerSecond!==void 0&&J!==void 0&&(W.promptMs=J/W.promptTokensPerSecond*1e3,W.promptSource="rate"),W.promptMs!==void 0&&(i.promptPhaseMs=(i.promptPhaseMs||0)+W.promptMs,i.promptPhaseCalls=(i.promptPhaseCalls||0)+1,ce!==void 0&&W.promptMs>0&&(W.promptNewTokensPerSecond=ce/(W.promptMs/1e3),i.promptPhaseNewTokens=(i.promptPhaseNewTokens||0)+ce,p+=W.promptMs)),W.ttftMs!==void 0&&ee!==void 0&&ee>=W.ttftMs?W.generationMs=ee-W.ttftMs:W.generationTokensPerSecond!==void 0&&V!==void 0&&(W.generationMs=V/W.generationTokensPerSecond*1e3),W.generationMs!==void 0&&V!==void 0&&(i.generationPhaseMs=(i.generationPhaseMs||0)+W.generationMs,i.generationPhaseTokens=(i.generationPhaseTokens||0)+V);const de=ot(P.speculation);if(Object.keys(de).length){const ae={};Je(de.mode)&&(ae.mode=Je(de.mode)),typeof de.used=="boolean"&&(ae.used=de.used),Je(de.draft_kind)&&(ae.draftKind=Je(de.draft_kind));const we=Ns(de,["accepted_tokens"]),Pe=Ns(de,["drafted_tokens"]),Qe=Ns(de,["rounds"]),Ye=Ns(de,["num_draft_tokens"]);we!==void 0&&(ae.acceptedTokens=we),Pe!==void 0&&(ae.draftedTokens=Pe),we!==void 0&&Pe&&(ae.acceptanceRate=we/Pe),Qe!==void 0&&(ae.rounds=Qe),Ye!==void 0&&(ae.draftLength=Ye),W.speculation=ae;const Ne=i.speculation||(i.speculation={calls:0,used:0});Ne.calls+=1,ae.used&&(Ne.used+=1),ae.mode&&(Ne.modes=Za(Ne.modes,ae.mode)),ae.draftKind&&(Ne.draftKinds=Za(Ne.draftKinds,ae.draftKind)),we!==void 0&&Pe!==void 0&&(Ne.acceptedTokens=(Ne.acceptedTokens||0)+we,Ne.draftedTokens=(Ne.draftedTokens||0)+Pe),Qe!==void 0&&(Ne.rounds=(Ne.rounds||0)+Qe),Ye!==void 0&&(Ne.draftLengths=Za(Ne.draftLengths,Ye))}_.push(W)}_.length&&(_.every(S=>S.startedAt)&&_.sort((S,E)=>Date.parse(S.startedAt)-Date.parse(E.startedAt)),i.modelCalls=_),p>0&&i.promptPhaseNewTokens!==void 0&&(i.promptPhaseTokensPerSecond=i.promptPhaseNewTokens/(p/1e3)),i.generationPhaseMs&&i.generationPhaseTokens!==void 0&&(i.generationPhaseTokensPerSecond=i.generationPhaseTokens/(i.generationPhaseMs/1e3)),(x=i.speculation)!=null&&x.draftedTokens&&(i.speculation.acceptanceRate=(i.speculation.acceptedTokens||0)/i.speculation.draftedTokens),i.measuredSpeedCalls&&(i.promptTokensPerSecond!==void 0&&(i.promptTokensPerSecond/=i.measuredSpeedCalls),i.generationTokensPerSecond!==void 0&&(i.generationTokensPerSecond/=i.measuredSpeedCalls)),m>0&&(i.prefillNewTokens=h,i.prefillNewTokensPerSecond=h/(m/1e3));const C=new Map;for(const S of t.values()){if(S.status==="waiting"){i.toolsWaiting=(i.toolsWaiting||0)+1;continue}if(S.status==="running"){i.toolsRunning=(i.toolsRunning||0)+1;continue}if(!["completed","failed"].includes(S.status))continue;i.toolCalls+=1;const E=S.status==="failed";E&&(i.toolsFailed=(i.toolsFailed||0)+1);const A=i.toolBreakdown||(i.toolBreakdown={}),R=A[S.name]||(A[S.name]={calls:0,failed:0});if(R.calls+=1,E){R.failed+=1;const O=IS(S.output);O&&((R.errors||(R.errors={}))[O]=(((j=R.errors)==null?void 0:j[O])||0)+1)}const z=Date.parse(Je(S.startedAt)),L=Date.parse(Je(S.endedAt));if(Number.isFinite(z)&&Number.isFinite(L)&&L>=z){const O=`${S.runId}|${S.startedAt}|${S.endedAt}`,ee=C.get(O)||{ms:L-z,calls:0,names:new Map,waited:!1};ee.calls+=1,ee.names.set(S.name,(ee.names.get(S.name)||0)+1),b.has(S.id)&&(ee.waited=!0),C.set(O,ee)}if(S.success!==!0||!["write_file","create_file","save_file","edit_file","update_file","replace_in_file","delete_file","remove_file","move_file","rename_file","copy_file"].includes(S.name))continue;const J=cw(S.arguments),V=Je(J.destination||J.destination_path||J.file_path||J.path||J.filename);V&&r.add(V)}for(const S of C.values()){i.toolBatches=(i.toolBatches||0)+1,i.toolTimeMs=(i.toolTimeMs||0)+S.ms,S.waited&&(i.toolTimeIncludesApproval=!0);const E=[...S.names.keys()].sort();(!i.slowestToolBatch||S.ms>i.slowestToolBatch.ms)&&(i.slowestToolBatch={ms:S.ms,calls:S.calls,tools:E});const A=(N=i.toolBreakdown)==null?void 0:N[E[0]];if(E.length===1&&A)A.ms=(A.ms||0)+S.ms;else for(const R of E){const z=($=i.toolBreakdown)==null?void 0:$[R];z&&(z.sharedBatches=(z.sharedBatches||0)+1)}}return i.changedFiles=[...r],d&&(delete i.inputTokens,delete i.outputTokens),Number.isFinite(c)&&Number.isFinite(u)&&(i.durationMs=Math.max(0,u-c)),{tools:[...t.values()],statistics:i}}function LS(e){const t=ot(ot(e).ledgers);return Object.entries(t).flatMap(([n,r])=>xc(ot(r).items).map((i,c)=>({runId:n,cursor:Number(i.cursor)||c+1,record:Object.keys(ot(i.record)).length?ot(i.record):i})))}const zd=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{};function OS(e){var x,j,N,$;const{tools:t,statistics:n}=Ti(e.records),r={toolCalls:n.toolCalls,totalTokens:n.totalTokens,startedAt:String(((x=e.run)==null?void 0:x.created_at)||"")||void 0},i=(S,E,A)=>({...r,label:S,detail:E,tone:A});if(e.loading)return i("Loading conversation","Restoring saved activity","neutral");if(["completed","failed","cancelled"].includes(e.status))return i(e.status==="completed"?"Completed":e.status==="failed"?"Run failed":"Stopped","",e.status==="failed"?"error":e.status==="completed"?"success":"neutral");if((e.connection==="reconnecting"||e.connection==="disconnected")&&(!((j=e.records)!=null&&j.length)||!!e.error))return i(e.connection==="reconnecting"?"Reconnecting":"Disconnected",String(e.error||"Live activity is unavailable"),"waiting");if(e.status==="paused"||((N=e.run)==null?void 0:N.paused)===!0)return i("Paused","Resume when you’re ready","waiting");const c=zd(($=e.interaction)==null?void 0:$.wait),u=zd(c.details),d=u.kind==="tool_approval"||u.mode==="approval_required",h=d&&e.toolApprovalGranted===!0;if(d&&!h)return i("Approval needed","Review the tool requests below","waiting");if(!d&&["user","ask_user"].includes(c.reason))return i("Your answer is needed",String(c.prompt||"The workflow has a question for you"),"waiting");if(!d&&(c.reason==="event"||String(c.wait_key||"").startsWith("evt:")))return i("Waiting for an event",String(c.prompt||"Listening for the workflow’s trigger"),"waiting");const m=t.filter(S=>{var E;return S.status==="running"||h&&S.status==="waiting"&&S.runId===((E=e.interaction)==null?void 0:E.runId)});if(m.length)return i(m.length===1?"Running a tool":`Running ${m.length} tools`,[...new Set(m.map(S=>S.name))].join(" · "),"working");const p=new Map;for(const S of e.records){const E=`${S.runId}:${S.record.step_id||S.record.idempotency_key||S.cursor}`,A=p.get(E);A&&["completed","failed"].includes(String(A.record.status))||p.set(E,S)}if([...p.values()].reverse().find(S=>zd(S.record.effect).type==="llm_call"&&["started","running"].includes(String(S.record.status))))return i("Thinking","Generating the next response","working");const _=e.displayStatus.trim(),b=!/^(completed|complete|done|finished|ready|success|succeeded|failed|running|working|waiting|thinking|idle|paused|stopped|cancelled)$/i.test(_)&&!_.startsWith("{")?_:"",C=t[t.length-1];return i(e.status==="idle"?"Ready":"Working",b||(C?`Last tool: ${C.name} · ${C.status==="failed"?"failed":C.status==="completed"?"done":"waiting"}`:"Following the workflow"),e.status==="idle"?"neutral":"working")}function PS(e,t){if(e.kind==="ask-user"){if(t.kind==="choice"||t.kind==="free-text")return e.onSubmit(t.answer);throw new Error("Invalid submission for ask-user interaction")}if(e.kind==="tool-approval"){if(t.kind==="approve")return e.onApprove();if(t.kind==="deny")return e.onDeny();if(t.kind==="approve-all"&&e.onApproveAll)return e.onApproveAll();throw new Error("Invalid submission for tool-approval interaction")}if(t.kind==="event")return e.onSend(t.payload);throw new Error("Invalid submission for event-wait interaction")}function DS(e){return(e instanceof Error?e.message:String(e||"Unknown error")).trim()||"Unknown error"}function FS(e){return a.jsxs("div",{className:"pc-workflow-interaction__error",role:"alert",children:[a.jsxs("span",{children:["Could not complete that action: ",e.message]}),a.jsx("button",{type:"button",className:"pc-workflow-interaction__retry",onClick:e.onRetry,disabled:e.disabled,children:"Try again"})]})}function zS(e){var z;const t=e.interaction,[n,r]=y.useState(""),[i,c]=y.useState(()=>t.kind==="event-wait"&&t.initialPayload||""),[u,d]=y.useState(null),[h,m]=y.useState(!1),[p,v]=y.useState(""),[_,b]=y.useState(null),C=`${t.kind}:${t.id}`,x=y.useRef(C),j=y.useRef(!1),N=y.useRef(!1),$=y.useRef(!0),S=y.useRef(0);x.current!==C&&(x.current=C,j.current=!1,N.current=!1,S.current+=1);const E=!!e.disabled||u!==null||h||j.current||N.current,A=async(L,J)=>{var ee;if(e.disabled||j.current||N.current)return;const V=C,O=++S.current;j.current=!0,b(null),v(""),d(L);try{if(await J(),!$.current||x.current!==V||S.current!==O)return;N.current=!0,m(!0),v("Response sent. Waiting for the workflow to continue.")}catch(P){if(!$.current||x.current!==V||S.current!==O)return;b({submission:L,message:DS(P)}),v("The action failed. You can try again."),(ee=e.onError)==null||ee.call(e,P)}finally{if(!$.current||x.current!==V||S.current!==O)return;j.current=!1,d(null)}};y.useEffect(()=>{r(""),c(t.kind==="event-wait"&&t.initialPayload||""),b(null),d(null),m(!1),v("")},[C]),y.useEffect(()=>($.current=!0,()=>{$.current=!1,S.current+=1,j.current=!1}),[]);const R=()=>{_&&A(_.submission,()=>PS(t,_.submission))};return a.jsxs("section",{className:"pc-workflow-interaction","aria-labelledby":`pc-workflow-interaction-${C}`,children:[a.jsxs("div",{className:"pc-workflow-interaction__heading",children:[a.jsx(ne,{name:t.kind==="tool-approval"?"warning":t.kind==="event-wait"?"history":"info",size:16}),a.jsxs("div",{children:[a.jsx("h3",{tabIndex:-1,id:`pc-workflow-interaction-${C}`,children:t.title||(t.kind==="tool-approval"?"Tool approval required":"Input required")}),t.description?a.jsx("div",{className:"pc-workflow-interaction__description",children:t.description}):null]})]}),t.kind==="ask-user"?a.jsxs("div",{className:"pc-workflow-interaction__body",children:[a.jsx("div",{className:"pc-workflow-interaction__prompt",children:t.prompt}),(z=t.choices)!=null&&z.length?a.jsx("div",{className:"pc-workflow-interaction__choices","aria-label":"Choices",children:t.choices.map(L=>a.jsxs("button",{type:"button",className:"pc-workflow-interaction__choice",disabled:E||L.disabled,onClick:()=>void A({kind:"choice",answer:L.id},()=>t.onSubmit(L.id)),children:[a.jsx("span",{children:L.label}),L.description?a.jsx("small",{children:L.description}):null]},L.id))}):null,t.allowFreeText!==!1?a.jsxs("div",{className:"pc-workflow-interaction__entry",children:[a.jsx("textarea",{"aria-label":"Response",value:n,onChange:L=>r(L.target.value),placeholder:t.freeTextPlaceholder||"Type a response",rows:2,disabled:E,onKeyDown:L=>{L.key!=="Enter"||L.shiftKey||L.nativeEvent.isComposing||L.keyCode===229||(L.preventDefault(),n.trim()&&A({kind:"free-text",answer:n},()=>t.onSubmit(n)))}},`${C}:text`),a.jsx("button",{type:"button",className:"pc-btn",disabled:E||!n.trim(),onClick:()=>void A({kind:"free-text",answer:n},()=>t.onSubmit(n)),children:(u==null?void 0:u.kind)==="free-text"?"Sending…":t.submitLabel||"Submit"})]}):null]}):t.kind==="tool-approval"?a.jsxs("div",{className:"pc-workflow-interaction__body",children:[a.jsxs("div",{className:"pc-workflow-interaction__prompt",children:["Allow ",a.jsx("strong",{children:t.toolName})," to run?"]}),t.detail?a.jsx("div",{className:"pc-workflow-interaction__detail",children:t.detail}):null,a.jsxs("div",{className:"pc-workflow-interaction__buttons",children:[a.jsx("button",{type:"button",className:"pc-workflow-interaction__deny",disabled:E,onClick:()=>void A({kind:"deny"},t.onDeny),children:(u==null?void 0:u.kind)==="deny"?"Denying…":t.denyLabel||"Deny"}),a.jsx("button",{type:"button",className:"pc-btn",disabled:E,onClick:()=>void A({kind:"approve"},t.onApprove),children:(u==null?void 0:u.kind)==="approve"?"Approving…":t.approveLabel||"Approve"}),t.onApproveAll?a.jsx("button",{type:"button",className:"pc-workflow-interaction__allow-all",disabled:E,onClick:()=>void A({kind:"approve-all"},t.onApproveAll),children:(u==null?void 0:u.kind)==="approve-all"?"Approving…":t.approveAllLabel||"Allow all"}):null]}),t.onApproveAll&&t.approveAllDescription?a.jsx("p",{className:"pc-workflow-interaction__scope",children:t.approveAllDescription}):null]}):a.jsxs("div",{className:"pc-workflow-interaction__body",children:[a.jsx("div",{className:"pc-workflow-interaction__prompt",children:t.prompt}),a.jsxs("label",{className:"pc-workflow-interaction__entry",children:[a.jsx("span",{children:t.payloadLabel||(t.eventName?`Payload for ${t.eventName}`:"Event payload")}),a.jsx("textarea",{value:i,onChange:L=>c(L.target.value),placeholder:t.payloadPlaceholder||"Enter payload",rows:2,"aria-label":t.payloadLabel||(t.eventName?`Payload for ${t.eventName}`:"Event payload"),disabled:E},`${C}:payload`)]}),a.jsx("div",{className:"pc-workflow-interaction__buttons",children:a.jsx("button",{type:"button",className:"pc-btn",disabled:E,onClick:()=>void A({kind:"event",payload:i},()=>t.onSend(i)),children:(u==null?void 0:u.kind)==="event"?"Sending…":t.sendLabel||"Send event"})})]}),_?a.jsx(FS,{message:_.message,onRetry:R,disabled:E}):null,a.jsx("div",{className:"pc-workflow-interaction__outcome","aria-live":"polite",children:p})]})}function pc(e){return(e instanceof Error?e.message:String(e||"Unknown error")).trim()||"Unknown error"}function US(e){mo();const[t,n]=y.useState(!1),[r,i]=y.useState(!1),[c,u]=y.useState(!1),[d,h]=y.useState(null),m=y.useRef(!0),p=y.useRef(!1),v=y.useRef(!1),_=y.useRef(!1),b=y.useRef(0),C=y.useRef(0),x=y.useRef(0);y.useEffect(()=>(m.current=!0,()=>{m.current=!1,b.current+=1,C.current+=1,x.current+=1,p.current=!1,v.current=!1,_.current=!1}),[]);const j=!!e.blockedNotice,N=!!e.disabled||j,$=!!e.busy||t,S=t||!!e.busy&&!e.sendWhileBusy,E=e.stopState||null,A=(E==null?void 0:E.phase)==="stopping",R=typeof e.onFiles=="function",z=y.useRef(null),[L,J]=y.useState(null),[V,O]=y.useState(""),ee=y.useRef(e.onFiles);ee.current=e.onFiles;const P=y.useRef(N);P.current=N;const Z=async(W,me)=>{const q=ee.current;if(q){if(P.current){h({action:"attach",message:"attachments are unavailable right now."});return}if(me.length)h({action:"attach",message:Qy(me)});else if(W.length)h(null);else{h({action:"attach",message:"the drop contained no files."});return}if(W.length){O(`Attaching ${W.length} ${W.length===1?"file":"files"}…`);try{await q(W)}catch(fe){m.current&&h({action:"attach",message:pc(fe)})}}}},U=y.useRef(Z);U.current=Z,y.useEffect(()=>{if(!R||typeof window>"u")return;const W=new Bj;let me=0;const q=Ne=>!!(z.current&&Ne instanceof Node&&z.current.contains(Ne)),fe=()=>{W.reset(),me&&window.clearInterval(me),me=0,J(null)},de=()=>{me||(me=window.setInterval(()=>{W.active(Date.now())||fe()},250))},ae=Ne=>{var Ue;if(!Ni((Ue=Ne.dataTransfer)==null?void 0:Ue.types))return;W.enter(Date.now());const He=q(Ne.target),ue=Wp(Ne.dataTransfer);J(ie=>ie&&ie.over===He&&ie.count===(ue??ie.count)?ie:{count:ue??(ie==null?void 0:ie.count)??null,over:He}),de()},we=Ne=>{var ue;if(!Ni((ue=Ne.dataTransfer)==null?void 0:ue.types))return;Ne.preventDefault(),W.over(Date.now());const He=q(Ne.target);Ne.dataTransfer&&(Ne.dataTransfer.dropEffect=He&&!P.current?"copy":"none"),J(Ue=>Ue&&Ue.over===He?Ue:{count:(Ue==null?void 0:Ue.count)??Wp(Ne.dataTransfer),over:He}),de()},Pe=Ne=>{var He;Ni((He=Ne.dataTransfer)==null?void 0:He.types)&&(W.leave(Date.now())||fe())},Qe=Ne=>{var Ae;if(!Ni((Ae=Ne.dataTransfer)==null?void 0:Ae.types))return;const He=q(Ne.target),ue=Ne.defaultPrevented&&!He;if(Ne.preventDefault(),fe(),ue)return;if(!He){h({action:"attach",message:"drop files on the conversation to attach them."});return}const{files:Ue,folders:ie}=Df(Ne.dataTransfer);U.current(Ue,ie)},Ye=Ne=>{Ne.key==="Escape"&&W.depth>0&&fe()};return window.addEventListener("dragenter",ae),window.addEventListener("dragover",we),window.addEventListener("dragleave",Pe),window.addEventListener("drop",Qe),window.addEventListener("dragend",fe),window.addEventListener("blur",fe),window.addEventListener("keydown",Ye),()=>{window.removeEventListener("dragenter",ae),window.removeEventListener("dragover",we),window.removeEventListener("dragleave",Pe),window.removeEventListener("drop",Qe),window.removeEventListener("dragend",fe),window.removeEventListener("blur",fe),window.removeEventListener("keydown",Ye),me&&window.clearInterval(me)}},[R]);const te=W=>{if(!R||N)return;const me=Yy(W.clipboardData);me.length&&(W.preventDefault(),Z(me,[]))},se=L?a.jsxs("div",{className:["pc-workflow-chat__dropzone",L.over?"is-over":"",N?"is-disabled":""].filter(Boolean).join(" "),"aria-hidden":"true",children:[a.jsx("span",{className:"pc-workflow-chat__dropzone-icon",children:a.jsx(ne,{name:"paperclip",size:18})}),a.jsxs("span",{className:"pc-workflow-chat__dropzone-text",children:[a.jsx("strong",{children:N?"Attachments are unavailable right now":Vp(L.count)}),N?null:a.jsx("span",{children:L.over?"Release to upload to this conversation":"Drop anywhere on the conversation"})]})]}):null,G=L?N?"Attachments are unavailable right now":Vp(L.count):V,ce=async()=>{const W=String(e.draft||"");if(N||p.current||!e.sendWhileBusy&&e.busy||!W.trim())return;const me=++b.current;p.current=!0,h(null),n(!0);try{await e.onSend(W)}catch(q){m.current&&b.current===me&&h({action:"send",message:pc(q)})}finally{m.current&&b.current===me&&(p.current=!1,n(!1))}},re=async()=>{if(N||v.current||!e.onCancel)return;const W=++C.current;v.current=!0,h(null),i(!0);try{await e.onCancel()}catch(me){m.current&&C.current===W&&h({action:"cancel",message:pc(me)})}finally{m.current&&C.current===W&&(v.current=!1,i(!1))}},D=async()=>{if(N||_.current||!e.onAttach)return;const W=++x.current;_.current=!0,h(null),u(!0);try{await e.onAttach()}catch(me){m.current&&x.current===W&&h({action:"attach",message:pc(me)})}finally{m.current&&x.current===W&&(_.current=!1,u(!1))}},I=()=>{d&&(d.action==="send"&&ce(),d.action==="cancel"&&re(),d.action==="attach"&&D())};return a.jsxs("section",{ref:z,className:["pc-workflow-chat",L?"pc-workflow-chat--dragging":"",L!=null&&L.over?"pc-workflow-chat--drag-over":"",e.className].filter(Boolean).join(" "),"aria-label":"Workflow chat","data-stream-replies":e.streamReplies||"gateway_default",children:[e.header?a.jsx("header",{className:"pc-workflow-chat__header",children:e.header}):null,a.jsx("div",{className:"pc-workflow-chat__transcript",children:a.jsx(Ky,{messages:Array.isArray(e.messages)?e.messages:[],empty:e.emptyState,autoScroll:!0,messageProps:{...e.messageProps,...e.renderMarkdown?{renderMarkdown:e.renderMarkdown}:{}},after:a.jsxs(a.Fragment,{children:[e.interaction?a.jsx(zS,{interaction:e.interaction,disabled:N}):null,j?a.jsx("div",{className:"pc-workflow-chat__blocked",role:"status",children:e.blockedNotice}):null]}),afterKey:`${e.interaction?`${e.interaction.kind}:${e.interaction.id}`:""}:${j?"blocked":""}`})}),d?a.jsxs("div",{className:"pc-workflow-chat__error",role:"alert",children:[a.jsxs("span",{children:["Could not ",d.action==="send"?"send this message":d.action==="attach"?"attach a file":"stop the run",": ",d.message]}),a.jsx("button",{type:"button",onClick:I,disabled:N,children:"Try again"})]}):null,a.jsxs("div",{className:"pc-workflow-chat__composer",children:[a.jsx(Jy,{value:e.draft,onChange:e.onDraftChange,onSubmit:()=>void ce(),placeholder:e.placeholder||"Send a message",ariaLabel:"Message",disabled:N,busy:S,sendLabel:e.sendLabel,busyLabel:e.busyLabel,rows:2,leading:e.attachments?a.jsx("div",{className:"pc-workflow-chat__attachments",children:e.attachments}):null,overlay:se,onPaste:R?te:void 0,actions:a.jsxs(a.Fragment,{children:[e.onAttach?a.jsxs("button",{type:"button",className:"pc-workflow-chat__icon-button","aria-label":"Attach file","data-af-tip":"Attach a file",disabled:N||c,onClick:()=>void D(),children:[a.jsx(ne,{name:"paperclip",size:16}),a.jsx("span",{children:c?"Attaching…":"Attach"})]}):null,e.composerExtras,$&&e.onCancel?a.jsxs("button",{type:"button",className:"pc-workflow-chat__stop",disabled:N||r||A,onClick:()=>void re(),children:[a.jsx(ne,{name:"x",size:14}),a.jsx("span",{children:r||A?"Stopping…":"Stop"})]}):E?a.jsx("span",{className:`pc-workflow-chat__stop-state pc-workflow-chat__stop-state--${E.phase}`,role:"status","aria-live":"polite",children:E.label}):null]})}),R?a.jsx("div",{className:"pc-sr-only",role:"status","aria-live":"polite",children:G}):null]}),e.footer?a.jsx("footer",{className:"pc-workflow-chat__footer",children:e.footer}):null]})}function BS(e){return e.toolApprovalGranted?null:e.interaction}const Hp={messages:[],records:[],run:null,interaction:null,status:"idle",displayStatus:"",loading:!1,error:null,connection:"idle",toolApprovalGranted:!1,stop:null};function De(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Le(e){return typeof e=="string"?e.trim():e==null?"":typeof e=="number"||typeof e=="boolean"?String(e):""}function Ei(e){return Array.isArray(e)?e:[]}function bn(e){return Le(e==null?void 0:e.status).toLowerCase()||"unknown"}function Lt(e){return["completed","failed","cancelled"].includes(e.toLowerCase())}function Sr(e){const t=De(e),n=Number((t==null?void 0:t.status)??(t==null?void 0:t.statusCode));return n===401||n===403}function WS(e){const t=De(e);return Number((t==null?void 0:t.status)??(t==null?void 0:t.statusCode))}function Ud(e){const t=n=>{if(Array.isArray(n))return n.map(t);const r=De(n);if(!r)return n;const i={};for(const c of Object.keys(r).sort())i[c]=t(r[c]);return i};try{return JSON.stringify(t(e))}catch{return"[unserializable]"}}function _f(e){if(typeof e=="string")return e.trim();const t=De(e);if(!t)return"";for(const n of["answer","response","message","text","content","output"]){const r=t[n];if(typeof r=="string"&&r.trim())return r.trim()}return""}function eo(e){const t=_f(e);if(t)return t;if(!De(e)&&!Array.isArray(e))return"";try{return JSON.stringify(e,null,2)}catch{return""}}function Gp(e){if(!e)return"";for(const r of["prompt","request","task","message","query","input"]){const i=Le(e[r]);if(i)return i}const t=De(e.context);for(const r of["task","message"]){const i=Le(t==null?void 0:t[r]);if(i)return i}const n=Ei(t==null?void 0:t.messages);for(let r=n.length-1;r>=0;r-=1){const i=De(n[r]);if(Le(i==null?void 0:i.role).toLowerCase()!=="user")continue;const c=Le(i==null?void 0:i.content);if(c)return c}return""}function uw(e){const t=De(e.result);return De(t==null?void 0:t.wait)}function Bd(e){return e?Le(e.reason)==="subworkflow"||Le(e.wait_key).startsWith("subworkflow:"):!1}function Kp(e,t){return!!(e&&e.runId===t.runId&&Le(e.wait.wait_key)===Le(t.wait.wait_key))}function bf(e){return De(e.effect)||{}}function VS(e,t){return Le(e.run_id)||t}function Jp(e){return Le(e.ended_at)||Le(e.started_at)||void 0}function Qp(e){const t=new Set,n=m=>{const p=Le(m);p&&t.add(p)},r=De(e.result);n(r==null?void 0:r.sub_run_id),n(r==null?void 0:r.subRunId),n(r==null?void 0:r.child_run_id);const i=bf(e),c=De(i.payload);Le(i.type)==="start_subworkflow"&&(n(c==null?void 0:c.sub_run_id),n(c==null?void 0:c.subRunId),n(c==null?void 0:c.child_run_id));const u=uw(e),d=De(u==null?void 0:u.details);n(d==null?void 0:d.sub_run_id),n(d==null?void 0:d.subRunId),n(d==null?void 0:d.child_run_id);const h=Le(u==null?void 0:u.wait_key);return h.startsWith("subworkflow:")&&n(h.slice(12)),[...t]}class HS{constructor(t,n={}){this.transport=t,this.options=n,this.snapshot={...Hp},this.subscribers=new Set,this.controller=null,this.generation=0,this.rootRunId="",this.cursors=new Map,this.seenRecords=new Set,this.seenMessages=new Set,this.watchedRuns=new Set,this.childCatchUpAttempts=new Map,this.runStates=new Map,this.historicalRuns=new Map,this.historicalRunFailures=new Map,this.commandIds=new Map,this.toolActivities=new Map,this.historicalEvidence=new Map,this.approvedWaits=new Set,this.grantedToolWaits=new Set,this.resolvedWaits=new Set,this.approvalEpoch=0,this.toolApprovalPolicy=null,this.toolApprovalSuspended=!1,this.toolApprovalStopped=!1,this.displayStatusAt=-1/0,this.stopRequested=!1,this.stopFollowing=!1,this.openLlmSteps=new Set,this.forcedStop=null,this.liveReplies=new Map,this.closedLiveCalls=new Set,this.shownLiveCalls=new Set,this.liveDirty=new Set,this.liveRenderTimer=null,this.lastLiveRender=-1/0;const r=n.liveRenderIntervalMs??60;if(typeof r!="number"||!Number.isFinite(r)||r<0)throw new Error(`liveRenderIntervalMs must be a non-negative number of milliseconds, got ${JSON.stringify(n.liveRenderIntervalMs)}`);this.liveRenderIntervalMs=r}subscribe(t){return this.subscribers.add(t),()=>this.subscribers.delete(t)}getSnapshot(){return this.snapshot}reset(){var t;this.toolApprovalSuspended=!1,this.toolApprovalStopped=!1,this.approvalEpoch+=1,this.displayStatusAt=-1/0,this.stopRequested=!1,this.stopFollowing=!1,this.openLlmSteps.clear(),this.forcedStop=null,this.generation+=1,(t=this.controller)==null||t.abort(),this.controller=null,this.rootRunId="",this.cursors.clear(),this.seenRecords.clear(),this.seenMessages.clear(),this.watchedRuns.clear(),this.childCatchUpAttempts.clear(),this.runStates.clear(),this.historicalRuns.clear(),this.historicalRunFailures.clear(),this.commandIds.clear(),this.toolActivities.clear(),this.historicalEvidence.clear(),this.approvedWaits.clear(),this.grantedToolWaits.clear(),this.resolvedWaits.clear(),this.liveReplies.clear(),this.closedLiveCalls.clear(),this.shownLiveCalls.clear(),this.liveDirty.clear(),this.lastLiveRender=-1/0,this.liveRenderTimer&&(clearTimeout(this.liveRenderTimer),this.liveRenderTimer=null),this.set({...Hp})}dispose(){this.reset(),this.subscribers.clear()}async load(t){const n=Le(t);if(this.reset(),!n)return;const r=++this.generation,i=new AbortController;this.controller=i,this.rootRunId=n,this.set({...this.snapshot,loading:!0,status:"loading",error:null,connection:"connecting"});try{const[c,u]=await Promise.all([this.transport.getRun(n,i.signal),this.transport.getHistory(n,i.signal)]);if(!this.live(r))return;const d=De(c),h=De(d==null?void 0:d.waiting),m=bn(d);if(await this.ingestHistory(u,n,r),!this.live(r))return;if(this.set({...this.snapshot,run:d,status:m,loading:!1,...h&&!Lt(m)?{interaction:this.interactionWith({runId:n,wait:h})}:{}}),d&&this.updateRunState(n,d),h)for(const p of Qp({result:{wait:h}}))p!==n&&this.catchUpAndWatch(p,r);await this.catchUpAndWatch(n,r),this.pollRootLifecycle(n,r)}catch(c){!i.signal.aborted&&this.live(r)&&this.fail(c)}}async sendCommand(t,n={}){var p,v;t==="cancel"&&(this.toolApprovalStopped=!0,this.revokeToolApproval(),this.stopRequested=!0,this.recomputeStop());const r=Le(n.wait_key),i=t==="resume"?r?this.interactionRunId()||this.rootRunId:this.rootRunId:t==="emit_event"?this.interactionRunId()||this.rootRunId:this.rootRunId;if(!i)throw new Error("No workflow run is loaded");const c=t==="resume"&&r&&((p=this.snapshot.interaction)==null?void 0:p.stepId)||"",u=`${i}\0${t}\0${c}\0${Ud(n)}`;let d=this.commandIds.get(u);d||(d=this.newCommandId(),this.commandIds.set(u,d));const h=this.generation,m=(v=this.controller)==null?void 0:v.signal;try{const _=await this.transport.submitCommand({command_id:d,run_id:i,type:t,payload:n,...this.options.clientId?{client_id:this.options.clientId}:{}},m);if(!this.live(h))return _;const b=De(_);if(b&&b.accepted===!1)throw t==="cancel"&&(this.stopRequested=!1,this.recomputeStop()),new Error(Le(b.detail)||"Gateway did not accept the command");return this.commandIds.delete(u),i===this.rootRunId&&["pause","resume","cancel"].includes(t)&&this.refreshRunState(i,h),_}catch(_){throw this.live(h)&&this.fail(_,!1),_}}resume(t){const n=this.requireInteraction();return this.sendCommand("resume",{wait_key:Le(n.wait.wait_key),payload:{response:t}})}approve(t,n){const r=this.requireInteraction();if(Lt(this.snapshot.status))throw new Error("This run has already ended.");if(n&&(r.runId!==n.runId||Le(r.wait.wait_key)!==n.waitKey||n.stepId!==void 0&&r.stepId!==n.stepId))throw new Error("This approval request has changed. Review the current request before deciding.");if(t&&this.toolApprovalPolicy&&!this.toolCallsMatch(r,this.toolApprovalPolicy.enabledTools))throw new Error("This request includes an unavailable or unselected tool. It cannot be authorized. Deny this request or stop the run and change Tools settings.");const i=this.generation;return this.sendCommand("resume",{wait_key:Le(r.wait.wait_key),payload:{approved:!!t}}).then(c=>{if(!this.live(i))return c;const u=this.occurrenceKey(r);return this.approvedWaits.add(u),t&&this.isToolApproval(r)&&!this.grantedToolWaits.has(u)&&(this.grantedToolWaits.add(u),this.set({...this.snapshot})),c})}async approveWithPolicyChange(t,n){const r=this.generation,i=this.approvalEpoch;if(!this.isToolApproval(this.requireInteraction()))throw new Error("This is not a tool approval request.");await this.approve(!0,t),!(!this.live(r)||i!==this.approvalEpoch||this.toolApprovalStopped||Lt(this.snapshot.status))&&n()}async allowAllToolsForRun(t){const n=this.generation,r=this.approvalEpoch,i=this.requireInteraction();if(!this.isToolApproval(i))throw new Error("This is not a tool approval request.");await this.approve(!0,t),!(!this.live(n)||r!==this.approvalEpoch||Lt(this.snapshot.status))&&(this.approvedWaits.add(`${t.runId}:${t.waitKey}${i.stepId?`:${i.stepId}`:""}`),this.set({...this.snapshot,autoApproveTools:!0}))}revokeToolApproval(){this.approvalEpoch+=1,this.toolApprovalSuspended=!0,this.set({...this.snapshot,autoApproveTools:!1})}setToolApprovalPolicy(t){Ud(t)!==Ud(this.toolApprovalPolicy)&&(this.approvalEpoch+=1,this.toolApprovalSuspended=!1,this.toolApprovalPolicy=t?{enabledTools:[...t.enabledTools],autoApproveTools:[...t.autoApproveTools]}:null,this.set({...this.snapshot}))}occurrenceKey(t){return`${t.runId}:${Le(t.wait.wait_key)}${t.stepId?`:${t.stepId}`:""}`}interactionWith(t){const n=this.snapshot.interaction;return n&&Bd(t.wait)&&!Bd(n.wait)?n:n&&Kp(n,t)&&t.stepId===void 0&&n.stepId!==void 0?{...t,stepId:n.stepId}:t}adoptDurableWait(t,n){const r=De(n.waiting);if(!r||bn(n)!=="waiting"||Bd(r)||Lt(this.snapshot.status)||this.resolvedWaits.has(`${t}:${Le(r.wait_key)}`))return;const i=this.interactionWith({runId:t,wait:r}),c=this.snapshot.interaction;c&&Kp(c,i)&&c.stepId===i.stepId||this.set({...this.snapshot,interaction:i})}coveredByStandingPermission(t,n){var r;return t.loading||this.toolApprovalStopped||this.toolApprovalSuspended||!this.toolApprovalPolicy&&!t.autoApproveTools||Lt(t.status)||((r=t.run)==null?void 0:r.paused)===!0||t.status==="paused"||!n||!this.isToolApproval(n)||this.toolApprovalPolicy&&(!this.toolCallsMatch(n,this.toolApprovalPolicy.enabledTools)||!this.toolCallsMatch(n,this.toolApprovalPolicy.autoApproveTools))?!1:!!Le(n.wait.wait_key)}present(t){const n=t.interaction,r=n?this.occurrenceKey(n):"",i=!!(n&&this.isToolApproval(n)&&(this.grantedToolWaits.has(r)||!this.approvedWaits.has(r)&&this.coveredByStandingPermission({...t,loading:!1},n)));if(!i&&!this.snapshot.toolApprovalGranted&&!t.toolApprovalGranted)return t.toolApprovalGranted===!1?t:{...t,toolApprovalGranted:!1};let c=!1;const u=t.messages.map(d=>{var p;const h=d.toolActivity;if(!h||((p=this.toolActivities.get(h.id))==null?void 0:p.status)!=="waiting")return d;const m=i&&h.runId===(n==null?void 0:n.runId)?"running":"waiting";return h.status===m?d:(c=!0,this.toolMessage({...h,status:m}))});return{...t,toolApprovalGranted:i,...c?{messages:u}:{}}}toolCallsMatch(t,n){var i;const r=Ei((i=De(t.wait.details))==null?void 0:i.tool_calls);return r.length>0&&r.every(c=>{var d;const u=Le((d=De(c))==null?void 0:d.name);return!!u&&n.includes(u)})}isToolApproval(t){const n=De(t.wait.details);return(n==null?void 0:n.mode)==="approval_required"||(n==null?void 0:n.kind)==="tool_approval"}autoApproveCurrentWait(){const t=this.snapshot.interaction;if(!this.coveredByStandingPermission(this.snapshot,t))return;const n={runId:t.runId,waitKey:Le(t.wait.wait_key),stepId:t.stepId},r=this.occurrenceKey(t);if(this.approvedWaits.has(r))return;this.approvedWaits.add(r),this.grantedToolWaits.add(r);const i=this.generation,c=this.approvalEpoch;this.approve(!0,n).catch(u=>{if(this.live(i)){if(this.grantedToolWaits.delete(r),c!==this.approvalEpoch){this.set({...this.snapshot});return}this.toolApprovalSuspended=!0,this.set({...this.snapshot,autoApproveTools:!1}),this.fail(u,!1)}})}emitEvent(t){return this.sendCommand("emit_event",t)}cancel(){return this.sendCommand("cancel",{})}requireInteraction(){if(!this.snapshot.interaction)throw new Error("This workflow is not waiting for input");if(!Le(this.snapshot.interaction.wait.wait_key))throw new Error("The workflow wait has no wait_key");return this.snapshot.interaction}interactionRunId(){var t;return((t=this.snapshot.interaction)==null?void 0:t.runId)||""}live(t){var n;return t===this.generation&&!((n=this.controller)!=null&&n.signal.aborted)}set(t){this.snapshot=this.present(t);for(const n of this.subscribers)n();this.autoApproveCurrentWait()}async catchUpAndWatch(t,n){var r;if(!(!this.live(n)||this.watchedRuns.has(t))){this.watchedRuns.add(t);try{if(t!==this.rootRunId)try{const i=De(await this.transport.getRun(t,(r=this.controller)==null?void 0:r.signal));if(!this.live(n))return;i&&this.updateRunState(t,i)}catch(i){if(!this.live(n))return;if(Sr(i))throw i;this.fail(i,!1)}if(await this.catchUp(t,n),!this.live(n)||Lt(bn(this.runStates.get(t)||null)))return;this.childCatchUpAttempts.delete(t),this.watch(t,n)}catch(i){if(!this.live(n))return;if(this.watchedRuns.delete(t),t===this.rootRunId)throw i;if(Sr(i)){this.fail(i);return}const c=(this.childCatchUpAttempts.get(t)||0)+1;if(this.childCatchUpAttempts.set(t,c),this.fail(i,!1),c>=5)return;await this.waitForRetry(Math.min(2e3,150*2**(c-1))),this.live(n)&&this.catchUpAndWatch(t,n)}}}async catchUp(t,n){var r;for(let i=0;i<100&&this.live(n);i+=1){const c=this.cursors.get(t)||0,u=await this.transport.getLedger(t,c,(r=this.controller)==null?void 0:r.signal);if(!this.live(n))return;const d=De(u),h=Array.isArray(u)?u:Ei(d==null?void 0:d.items);for(const p of h)this.ingestItem(t,p);const m=Number(d==null?void 0:d.next_after);if(!h.length||!Number.isFinite(m)||m<=c)break;this.cursors.set(t,m)}}async watch(t,n){try{await this.followStream(t,n)}finally{this.live(n)&&this.closeLiveRepliesVia(t)}}async followStream(t,n){var i;let r=0;for(;this.live(n)&&!Lt(bn(this.runStates.get(t)||null));){const c=this.cursors.get(t)||0;this.set({...this.snapshot,connection:r?"reconnecting":"connecting"});try{let u=!1;const d=()=>{!this.live(n)||u||(u=!0,this.set({...this.snapshot,connection:"connected",error:null}))};if(this.dropLiveRepliesVia(t),await this.transport.streamLedger(t,c,m=>{this.live(n)&&(d(),this.ingestItem(t,m))},this.controller.signal,d,m=>{this.live(n)&&(d(),this.ingestDelta(t,m))}),!this.live(n)||(await this.catchUp(t,n),!this.live(n)))return;const h=De(await this.transport.getRun(t,(i=this.controller)==null?void 0:i.signal));if(!this.live(n))return;h&&this.updateRunState(t,h),r+=1}catch(u){if(!this.live(n))return;if(r+=1,this.fail(u,!1),Sr(u)){this.set({...this.snapshot,connection:"disconnected"});return}}if(r>=5||!this.live(n))break;await this.waitForRetry(Math.min(2e3,150*2**(r-1)))}if(this.live(n)){if(Lt(bn(this.runStates.get(t)||null))){this.set({...this.snapshot,connection:"disconnected"});return}this.set({...this.snapshot,connection:"disconnected",error:this.snapshot.error||"Ledger stream reconnect limit reached. Reconnect the workflow to continue."})}}async ingestHistory(t,n,r){const i=De(t);if(!i)return;const c=De(i.session),u=Ei(c==null?void 0:c.turns).map(De).filter(m=>!!m);if(await this.hydrateHistoricalSessionRuns(u,n,r),!this.live(r))return;for(const m of u){const p=Le(m==null?void 0:m.run_id)||n;this.ingestSessionTurn(m,n,p!==n&&this.historicalRuns.get(p)||null)}const d=`turn:${n}:user`;if(!this.seenMessages.has(d)){const m=Gp(De(i.input_data));m&&this.addMessage({id:d,role:"user",content:m})}const h=De(i.ledgers);if(h)for(const[m,p]of Object.entries(h)){const v=De(p);for(const _ of Ei(v==null?void 0:v.items))this.ingestItem(m,_)}}ingestSessionTurn(t,n,r){if(!t)return;const i=Le(t.run_id)||n,c=De(t.input_data)||De(t.input)||{},u=Le(t.prompt)||Gp(c);u&&this.addMessage({id:`turn:${i}:user`,role:"user",content:u,ts:Le(t.created_at)||void 0});const d=this.historicalRunFailures.get(i);if(d){const v=Le(t.answer)||_f(t.output),_=d.missing?"is unavailable because the run no longer exists":"could not be restored",b=v?` Saved reply (not verified as the final result): ${v}`:"";this.addMessage({id:`history:${i}:unavailable`,role:"system",level:"warn",title:"History",content:`The final output for an earlier turn ${_}.${b}`});return}const m=(r&&Lt(bn(r))?eo(r.output):"")||(r?Le(t.answer)||_f(t.output):""),p=this.historicalEvidence.get(i);for(const v of(p==null?void 0:p.tools)||[])this.upsertTool(v);m&&this.addRunAssistantMessage(i,{id:`final:${i}`,role:"assistant",content:m,runId:i,statistics:p==null?void 0:p.statistics,ts:Le(t.updated_at)||void 0})}async hydrateHistoricalSessionRuns(t,n,r){const i=[...new Set(t.map(h=>Le(h.run_id)).filter(h=>h&&h!==n&&!this.historicalRuns.has(h)&&!this.historicalRunFailures.has(h)))];if(!i.length||!this.live(r))return;let c=0,u=!1;const d=async()=>{var h,m,p;for(;!u&&this.live(r);){const v=i[c++];if(!v)return;try{const _=De(await this.transport.getRun(v,(h=this.controller)==null?void 0:h.signal));if(!this.live(r))return;if(_){this.historicalRuns.set(v,_);try{const b=await this.transport.getHistory(v,(m=this.controller)==null?void 0:m.signal);if(!this.live(r))return;this.historicalEvidence.set(v,Ti(LS(b)))}catch(b){if(!this.live(r))return;if(Sr(b))throw b;this.fail(new Error(`Earlier turn activity could not be restored: ${b instanceof Error?b.message:String(b)}`),!1)}}else this.historicalRuns.set(v,null),this.historicalRunFailures.set(v,{missing:!1,detail:"gateway returned an invalid historical run snapshot"})}catch(_){if(!this.live(r))return;const b=WS(_)===404;this.historicalRuns.set(v,null),this.historicalRunFailures.set(v,{missing:b,detail:_ instanceof Error?_.message:Le((p=De(_))==null?void 0:p.detail)||"request failed"}),Sr(_)&&(u=!0,this.fail(_))}}};if(await Promise.all(Array.from({length:Math.min(4,i.length)},()=>d())),u&&this.live(r))for(const h of i)!this.historicalRuns.has(h)&&!this.historicalRunFailures.has(h)&&(this.historicalRuns.set(h,null),this.historicalRunFailures.set(h,{missing:!1,detail:"authorization expired before this historical run could be restored"}))}ingestItem(t,n){const r=De(n),i=De(r==null?void 0:r.record)||r;if(!i)return;const c=VS(i,t),u=Number(r==null?void 0:r.cursor),d=Number.isFinite(u)&&u>0?u:(this.cursors.get(c)||0)+1,h=`${c}:${d}`;if(!this.seenRecords.has(h)){if(this.seenRecords.add(h),this.cursors.set(c,Math.max(this.cursors.get(c)||0,d)),this.set({...this.snapshot,records:[...this.snapshot.records,{cursor:d,record:i,runId:c}]}),this.foldRecord(c,i,h),this.snapshot.messages.some(m=>m.id===`final:${this.rootRunId}`)){const m=Ti(this.snapshot.records).statistics;this.set({...this.snapshot,messages:this.snapshot.messages.map(p=>p.id===`final:${this.rootRunId}`?{...p,statistics:m}:p)})}for(const m of Qp(i))m!==c&&this.catchUpAndWatch(m,this.generation)}}foldRecord(t,n,r){var p,v,_;const i=bf(n),c=Le(i.type).toLowerCase(),u=De(n.result),d=Le(n.status).toLowerCase(),h=Jp(n);if(this.foldStopEvidence(t,n,c,d),["llm_call","tool_calls"].includes(c)&&["started","running"].includes(d)){const b=Date.parse(h||"");(!Number.isFinite(b)||b>=this.displayStatusAt)&&(Number.isFinite(b)&&(this.displayStatusAt=b),this.snapshot.displayStatus&&this.set({...this.snapshot,displayStatus:""}))}if(c==="answer_user"&&d==="completed"){const b=eo(u)||eo(De(i.payload));b&&this.addRunAssistantMessage(t,{id:`answer:${t}:${r}`,role:"assistant",content:b,ts:h})}if(c==="emit_event"&&d==="completed"){const b=De(i.payload)||{},C=De(u),x=Le(b.name)||Le(C==null?void 0:C.name),j=b.payload!==void 0?b.payload:C==null?void 0:C.payload;if(["abstract.message","abstractcode.message"].includes(x)){const N=eo(j);if(N){const $=Le((p=De(j))==null?void 0:p.level).toLowerCase(),S=$==="error"?"error":["warn","warning"].includes($)?"warn":"info";this.addMessage({id:`event:${t}:${r}`,role:"system",title:"Workflow",content:N,level:S,ts:h})}}if(["abstract.status","abstractcode.status"].includes(x)){const N=De(j),$=N?N.status??N.text??N.value:j,S=Date.parse(h||"");!Lt(this.snapshot.status)&&typeof $=="string"&&(!Number.isFinite(S)||S>=this.displayStatusAt)&&(Number.isFinite(S)&&(this.displayStatusAt=S),this.set({...this.snapshot,displayStatus:$.trim()}))}if(["abstract.tool_execution","abstractcode.tool_execution","abstract.tool_result","abstractcode.tool_result"].includes(x)){const N=eo(j);N&&this.addMessage({id:`event:${t}:${r}`,role:"system",title:"Tool activity",content:N,ts:h})}}const m=uw(n);if(d==="waiting"&&m&&!Lt(this.snapshot.status)&&!Lt(bn(this.runStates.get(t)||null))&&(this.resolvedWaits.delete(`${t}:${Le(m.wait_key)}`),this.set({...this.snapshot,interaction:this.interactionWith({runId:t,wait:m,...Le(n.step_id)?{stepId:Le(n.step_id)}:{}})})),c==="tool_calls")for(const b of lw(this.toolActivities,{runId:t,cursor:this.cursors.get(t)||0,record:n}))this.upsertTool(b);if(c==="resume"&&(u==null?void 0:u.resumed)===!0){const b=Le((v=De(i.payload))==null?void 0:v.wait_key);b&&this.resolvedWaits.add(`${t}:${b}`),((_=this.snapshot.interaction)==null?void 0:_.runId)===t&&(this.set({...this.snapshot,interaction:null}),this.refreshRunState(t,this.generation))}}foldStopEvidence(t,n,r,i){let c=!1;if(r==="llm_call"){const u=Le(n.step_id);if(u){const d=`${t}:${u}`;i==="started"?(this.openLlmSteps.add(d),c=!0):["completed","failed","cancelled","waiting"].includes(i)&&(c=this.openLlmSteps.delete(d)||c),["completed","failed","cancelled"].includes(i)&&this.closeLiveReply(d)}}if(r==="emit_event"&&i==="completed"){const u=De(bf(n).payload)||{},d=De(n.result),h=Le(u.name)||Le(d==null?void 0:d.name),m=De(u.payload!==void 0?u.payload:d==null?void 0:d.payload);h==="abstract.status"&&Le(m==null?void 0:m.killed_by)==="kill_switch"&&(this.forcedStop=m,c=!0)}c&&this.recomputeStop()}recomputeStop(){let t=null;this.forcedStop?t={phase:"forced",label:Le(this.forcedStop.text)||"Stop forced: inference killed",record:this.forcedStop}:this.stopRequested&&(t=this.snapshot.status==="cancelled"&&this.openLlmSteps.size===0?{phase:"stopped",label:"Stopped"}:{phase:"stopping",label:"Stopping…"});const n=this.snapshot.stop||null;((n==null?void 0:n.phase)!==(t==null?void 0:t.phase)||(n==null?void 0:n.label)!==(t==null?void 0:t.label))&&this.set({...this.snapshot,stop:t}),(t==null?void 0:t.phase)==="stopping"&&this.snapshot.status==="cancelled"&&this.followStop(this.generation)}async followStop(t){var n;if(!this.stopFollowing){this.stopFollowing=!0;try{let r=500,i=null;for(;this.live(t)&&((n=this.snapshot.stop)==null?void 0:n.phase)==="stopping";){if(await this.waitForRetry(r),!this.live(t))return;const c=[this.rootRunId,...[...this.watchedRuns].filter(d=>d!==this.rootRunId)];let u=!1;for(const d of c)try{await this.catchUp(d,t)}catch(h){u=!0,this.live(t)&&(this.fail(h,!1),i=this.snapshot.error)}!u&&i&&this.snapshot.error===i&&(this.set({...this.snapshot,error:null}),i=null),r=Math.min(5e3,r*2)}}finally{this.generation===t&&(this.stopFollowing=!1)}}}addMessage(t){const n=Le(t.id)||`${t.role}:${t.content}:${t.ts||""}`;this.seenMessages.has(n)||(this.seenMessages.add(n),this.set({...this.snapshot,messages:[...this.snapshot.messages,{...t,id:n}]}))}toolMessage(t){return{id:`tool:${t.id}`,role:"system",kind:"tool_activity",title:"Tool activity",runId:t.runId,toolActivity:t,content:JSON.stringify({tool:t.name,status:t.status,arguments:t.arguments,output:t.output,error:t.error},null,2),ts:t.endedAt||t.startedAt}}upsertTool(t){const n=this.toolMessage(t),r=this.snapshot.messages.findIndex(c=>c.id===n.id);if(r<0){this.addMessage(n);return}const i=[...this.snapshot.messages];i[r]=n,this.set({...this.snapshot,messages:i})}addRunAssistantMessage(t,n){this.closeLiveRepliesOfRun(t);const r=`answer:${t}:`,i=`final:${t}`;this.snapshot.messages.some(c=>c.role==="assistant"&&c.content===n.content&&(c.id===i||String(c.id||"").startsWith(r)))||this.addMessage(n)}ingestDelta(t,n){let r;try{r=qy(n)}catch(h){this.fail(h,!1);return}const i=`${r.run_id}:${r.call_id}`;if(Xy(r)){if(r.reason==="unavailable"){this.noteStreamUnavailable(r);return}if(r.reason==="cancelled"&&r.detail==="reinvoked"){this.closeLiveReply(i,"restarted");return}this.closeLiveReply(i,r.reason==="completed"?void 0:r.reason);return}if(this.closedLiveCalls.has(i)||this.runEnded(r.run_id)||this.runEnded(this.rootRunId))return;const c=this.liveReplies.get(i)||{runId:r.run_id,callId:r.call_id,nodeId:r.node_id||"",via:t,text:"",reasoning:"",seq:{content:-1,reasoning:-1}},u=r.channel==="reasoning"?"reasoning":"text",d=c.seq[r.channel];if(r.snapshot){if(r.seq<d)return;c[u]=r.text}else{if(r.seq<=d)return;c[u]+=r.text}c.seq[r.channel]=r.seq,c.via=t,this.liveReplies.set(i,c),this.liveDirty.add(i),this.scheduleLiveRender()}runEnded(t){return Lt(bn(this.runStates.get(t)||null))}scheduleLiveRender(){if(this.liveRenderTimer)return;const t=this.lastLiveRender+this.liveRenderIntervalMs-Date.now();if(t<=0){this.renderLiveReplies();return}this.liveRenderTimer=setTimeout(()=>{this.liveRenderTimer=null,this.renderLiveReplies()},t)}renderLiveReplies(){if(this.lastLiveRender=Date.now(),!this.liveDirty.size)return;const t=[...this.snapshot.messages];for(const n of this.liveDirty){const r=this.liveReplies.get(n);if(!r)continue;const i=this.liveMessage(r),c=t.findIndex(u=>u.id===i.id);c<0?t.push(i):t[c]=i,this.shownLiveCalls.add(n)}this.liveDirty.clear(),this.set({...this.snapshot,messages:t})}liveMessage(t){const n=t.runId!==this.rootRunId;return{id:`live:${t.runId}:${t.callId}`,role:"assistant",content:t.text,runId:t.runId,live:{callId:t.callId,reasoning:t.reasoning,...n?{caption:`sub-agent · ${t.nodeId||t.runId}`}:{}}}}closeLiveReply(t,n){this.closedLiveCalls.add(t);const r=this.liveReplies.get(t);if(!r){n==="restarted"&&this.shownLiveCalls.has(t)&&this.addMessage(this.restartNote(t));return}this.liveReplies.delete(t),this.liveDirty.delete(t);const i=`live:${r.runId}:${r.callId}`,c=this.snapshot.messages.findIndex(d=>d.id===i);if(c<0)return;const u=[...this.snapshot.messages];if(n==="restarted"){const d=this.restartNote(t);this.seenMessages.add(String(d.id)),u[c]=d}else if(n){const d=`live-end:${r.runId}:${r.callId}`;this.seenMessages.add(d),u[c]={id:d,role:"system",level:"warn",title:"Reply",runId:r.runId,content:n==="failed"?"The reply stopped because the model call failed.":"The reply stopped because the model call was cancelled."}}else u.splice(c,1);this.set({...this.snapshot,messages:u})}restartNote(t){const n=t.slice(0,t.indexOf(":"));return{id:`live-end:${t}`,role:"system",level:"info",title:"Reply",runId:n,content:"Reply restarted: the model call was interrupted and is running again."}}noteStreamUnavailable(t){const n=`${t.run_id}:${t.call_id}`;this.closeLiveReply(n),this.addMessage({id:`stream-unavailable:${t.run_id}:${t.detail||"unknown"}`,role:"system",level:"info",title:"Reply",runId:t.run_id,content:Kj(t.detail)})}closeLiveRepliesOfRun(t){for(const n of[...this.liveReplies.values()])n.runId===t&&this.closeLiveReply(`${n.runId}:${n.callId}`)}closeLiveRepliesVia(t,n){for(const r of[...this.liveReplies.values()])(r.via===t||r.runId===t)&&this.closeLiveReply(`${r.runId}:${r.callId}`,n)}endLiveRepliesOfRun(t,n){const r=n==="failed"||n==="cancelled"?n:void 0;if(t===this.rootRunId){for(const i of[...this.liveReplies.values()])this.closeLiveReply(`${i.runId}:${i.callId}`,r);this.closedLiveCalls.clear(),this.shownLiveCalls.clear();return}this.closeLiveRepliesVia(t,r);for(const i of[...this.closedLiveCalls])i.startsWith(`${t}:`)&&this.closedLiveCalls.delete(i);for(const i of[...this.shownLiveCalls])i.startsWith(`${t}:`)&&this.shownLiveCalls.delete(i)}dropLiveRepliesVia(t){const n=new Set;for(const[r,i]of this.liveReplies)i.via===t&&(this.liveReplies.delete(r),this.liveDirty.delete(r),n.add(`live:${i.runId}:${i.callId}`));n.size&&this.set({...this.snapshot,messages:this.snapshot.messages.filter(r=>!n.has(String(r.id)))})}fail(t,n=!0){var r,i,c;Sr(t)&&(this.approvalEpoch+=1,this.toolApprovalStopped=!0,this.toolApprovalSuspended=!0,(i=(r=this.options).onAuthError)==null||i.call(r,t)),this.set({...this.snapshot,error:t instanceof Error?t.message:Le((c=De(t))==null?void 0:c.detail)||String(t),...Sr(t)?{autoApproveTools:!1}:{},...n?{connection:"disconnected"}:{}})}newCommandId(){const t=globalThis.crypto;if(t&&typeof t.randomUUID=="function")return t.randomUUID();if(t&&typeof t.getRandomValues=="function"){const n=t.getRandomValues(new Uint8Array(16));n[6]=n[6]&15|64,n[8]=n[8]&63|128;const r=Array.from(n,i=>i.toString(16).padStart(2,"0")).join("");return`${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20)}`}return`workflow-${Date.now()}-${Math.random().toString(36).slice(2)}`}updateRunState(t,n){var c;if(this.runStates.set(t,n),Lt(bn(n))&&this.endLiveRepliesOfRun(t,bn(n)),t!==this.rootRunId){Lt(bn(n))&&((c=this.snapshot.interaction)==null?void 0:c.runId)===t?this.set({...this.snapshot,interaction:null}):this.adoptDurableWait(t,n);return}const r=bn(n),i=Lt(r);if(i){const u=eo(n.output);u&&this.upsertFinal(t,u,Jp(n))}this.set({...this.snapshot,run:n,status:r,...i?{interaction:null,autoApproveTools:!1,displayStatus:""}:{}}),i||this.adoptDurableWait(t,n),(this.stopRequested||this.forcedStop)&&this.recomputeStop()}upsertFinal(t,n,r){this.closeLiveRepliesOfRun(t);const i=`final:${t}`;this.seenMessages.add(i);const c={id:i,role:"assistant",content:n,ts:r,runId:t,statistics:Ti(this.snapshot.records).statistics},u=this.snapshot.messages.findIndex(h=>h.id===i||String(h.id||"").startsWith(`answer:${t}:`)&&h.content===n);if(u<0){this.set({...this.snapshot,messages:[...this.snapshot.messages,c]});return}const d=[...this.snapshot.messages];d[u]=c,this.set({...this.snapshot,messages:d})}async refreshRunState(t,n){var r;try{const i=De(await this.transport.getRun(t,(r=this.controller)==null?void 0:r.signal));i&&this.live(n)&&this.updateRunState(t,i)}catch(i){this.live(n)&&this.fail(i,!1)}}async pollRootLifecycle(t,n){var r;for(;this.live(n)&&this.rootRunId===t&&!Lt(bn(this.runStates.get(t)||null));){if(await this.waitForRetry(2e3),!this.live(n)||this.rootRunId!==t||Lt(bn(this.runStates.get(t)||null)))return;try{const i=De(await this.transport.getRun(t,(r=this.controller)==null?void 0:r.signal));i&&this.live(n)&&this.rootRunId===t&&this.updateRunState(t,i)}catch(i){if(!this.live(n))return;if(Sr(i)){this.fail(i);return}this.fail(i,!1)}}}waitForRetry(t){var i;const n=(i=this.controller)==null?void 0:i.signal;if(!n||n.aborted)return Promise.resolve();const r=n;return new Promise(c=>{const u=setTimeout(h,t),d=()=>{clearTimeout(u),h()};function h(){r.removeEventListener("abort",d),c()}r.addEventListener("abort",d,{once:!0})})}}function GS(e){const t=y.useMemo(()=>new HS(e.transport,{onAuthError:e.onAuthError,clientId:e.clientId,...e.liveRenderIntervalMs!==void 0?{liveRenderIntervalMs:e.liveRenderIntervalMs}:{}}),[e.transport,e.onAuthError,e.clientId,e.authScopeKey,e.liveRenderIntervalMs]),n=y.useSyncExternalStore(i=>t.subscribe(i),()=>t.getSnapshot(),()=>t.getSnapshot()),r=String(e.runId||"").trim();return y.useEffect(()=>{t.setToolApprovalPolicy(e.enabled===!1?{enabledTools:[],autoApproveTools:[]}:e.toolApprovalPolicy??null)},[t,e.toolApprovalPolicy,e.enabled]),y.useEffect(()=>{if(e.enabled===!1||!r){t.reset();return}return t.load(r),()=>t.reset()},[t,r,e.enabled]),{controller:t,snapshot:n}}function aa(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function tn(e){return typeof e=="string"?e.trim():e==null?"":typeof e=="number"||typeof e=="boolean"?String(e):""}function Yp(e){return["session","workflow","run","global"].includes(e)?e:null}function Cr(e){return{scope:tn(e==null?void 0:e.scope).toLowerCase(),name:tn(e==null?void 0:e.name)||tn(e==null?void 0:e.event_name),scopeId:tn(e==null?void 0:e.scope_id)||tn(e==null?void 0:e.scopeId),sessionId:tn(e==null?void 0:e.session_id)||tn(e==null?void 0:e.sessionId),workflowId:tn(e==null?void 0:e.workflow_id)||tn(e==null?void 0:e.workflowId),runId:tn(e==null?void 0:e.run_id)||tn(e==null?void 0:e.runId)}}function KS(e,t){const n=e.wait,r=tn(n.wait_key),i=[Cr(n),Cr(aa(n.details))];for(const c of t){if(c.runId!==e.runId)continue;const u=c.record,d=aa(u.result),h=aa(d==null?void 0:d.wait),m=aa(u.effect),p=aa(m==null?void 0:m.payload);tn(h==null?void 0:h.wait_key)!==r&&tn(p==null?void 0:p.wait_key)!==r||i.push(Cr(u),Cr(p),Cr(aa(p==null?void 0:p.details)),Cr(h),Cr(aa(h==null?void 0:h.details)))}return i}function Wd(e,t){return t.scopeId?t.scopeId:e==="session"?t.sessionId:e==="workflow"?t.workflowId:e==="run"?t.runId:"global"}function dw(e,t,n){return{scope:e,scopeId:t,name:n,...e==="session"?{sessionId:t}:{},...e==="workflow"?{workflowId:t}:{},...e==="run"?{runId:t}:{}}}function JS(e,t,n){if(!n)return null;const r=`evt:${t}:${n}:`;if(!e.startsWith(r))return null;const i=e.slice(r.length);return i?dw(t,n,i):null}function QS(e,t=[],n){if(!e)return{target:null,error:"No event wait is available."};const r=tn(e.wait.wait_key),i=/^evt:(session|workflow|run|global):/.exec(r);if(!i)return{target:null,error:"The gateway did not provide a canonical event wait key."};const c=Yp(i[1]);if(!c)return{target:null,error:"The event wait uses an unsupported scope."};const u=KS(e,Array.isArray(t)?t:[]),d=new Map;for(const _ of u){const b=Yp(_.scope);if(!b||!_.name)continue;if(b!==c)return{target:null,error:"Event metadata conflicts with the canonical wait scope."};const C=`evt:${b}:`,x=`:${_.name}`;if(!r.startsWith(C)||!r.endsWith(x)||r.length<=C.length+x.length)return{target:null,error:"Event metadata does not exactly match the canonical wait key."};const j=r.slice(C.length,-x.length),N=Wd(b,_);if(N&&N!==j)return{target:null,error:"Event metadata conflicts with the canonical wait target."};const $=dw(b,j,_.name);d.set(`${$.scope}\0${$.scopeId}\0${$.name}`,$)}if(d.size>1)return{target:null,error:"Multiple event targets match this wait; routing is unavailable."};if(d.size===1)return{target:[...d.values()][0]};const h=new Set;c==="run"&&h.add(e.runId),c==="global"&&h.add("global");for(const _ of u){const b=Wd(c,_);b&&h.add(b)}if(tn(n==null?void 0:n.run_id)===e.runId){const _=Cr(n||null),b=Wd(c,_);b&&h.add(b)}const p=[...h].map(_=>JS(r,c,_)).filter(_=>!!_),v=new Map(p.map(_=>[`${_.scope}\0${_.scopeId}\0${_.name}`,_]));return v.size===1?{target:[...v.values()][0]}:v.size>1?{target:null,error:"The event key is ambiguous for the available scope metadata."}:{target:null,error:"The gateway did not provide enough canonical event routing metadata."}}function YS(e){return a.jsx(zy,{text:e,images:"link"})}const XS={trigger:"Trigger",answer:"Automation"};function fw(e,t){return a.jsx(Gy,{...t,message:{id:`${e.runId}:${e.kind}`,role:e.role,content:e.text,title:XS[e.kind],runId:e.runId},images:"link"})}const qS={renderText:YS,renderTurn:fw};function ZS(e){const{fetchGateway:t,messageProps:n,...r}=e,i=r.onOpenResource??(t?c=>mS(t,c.url,{name:c.name}):void 0);return a.jsx(ak,{...r,onOpenResource:i,...qS,renderTurn:c=>fw(c,n)})}function e0(e,t,n={}){if(!e)return null;const r=e.wait,i=`${e.runId}:${r.wait_key}:${e.stepId||""}`,c=r.details||{};if(c.mode==="approval_required"||c.kind==="tool_approval"){const d=Array.isArray(c.tool_calls)?c.tool_calls:[],h={runId:e.runId,waitKey:String(r.wait_key||""),stepId:e.stepId},m=[...new Set(d.map(v=>String((v==null?void 0:v.name)||"tool")))],p=n.onPermissionsAll;return{id:i,kind:"tool-approval",title:`${d.length||"Requested"} ${d.length===1?"action needs":"actions need"} permission`,toolName:m.join(", ")||"the requested tools",description:"Review the targets below. Allow once approves this batch only.",detail:a.jsxs("div",{className:"pc-approval-summary",children:[a.jsx(Pf,{tools:d.map((v,_)=>({id:String((v==null?void 0:v.call_id)||(v==null?void 0:v.id)||_),runId:e.runId,name:(v==null?void 0:v.name)||"Tool",arguments:v==null?void 0:v.arguments,status:"waiting"}))}),a.jsxs("details",{children:[a.jsx("summary",{children:"Review full tool arguments (JSON)"}),a.jsx(co,{value:d.length?d:c})]})]}),approveLabel:"Allow once",denyLabel:"Deny",approveAllLabel:p?"Allow all enabled tools":void 0,approveAllDescription:p?"Sets permissions: all for this Gateway account, including future turns. Unchecked tools stay unavailable; explicit Ask overrides and Gateway restrictions remain enforced. Questions still need your answer.":void 0,onApproveAll:p?async()=>{await t.approveWithPolicyChange(h,()=>{p()})}:void 0,onApprove:async()=>{await t.approve(!0,h)},onDeny:async()=>{await t.approve(!1,h)}}}if(r.reason==="user"||r.reason==="ask_user")return{id:i,kind:"ask-user",title:"A question for you",prompt:String(r.prompt||c.prompt||"How would you like to continue?"),allowFreeText:r.allow_free_text!==!1,choices:(Array.isArray(r.choices)?r.choices:[]).map(d=>typeof d=="object"&&d!==null?{id:String(d.value??d.id??d.label),label:String(d.label??d.text??d.value??d.id),description:d.description}:{id:String(d),label:String(d)}),onSubmit:async d=>{await t.resume(d)}};const u=String(r.wait_key||"");if(r.reason==="event"||u.startsWith("evt:")){const d=QS(e,n.records||[],n.currentRun??null),h=d.target,m=(h==null?void 0:h.name)||"";return{id:i,kind:"event-wait",title:h?"Waiting for an event":"Event routing unavailable",eventName:m,prompt:String(r.prompt||`This workflow will continue when “${m||"its trigger"}” arrives.`),description:h?"You can also send the expected event here.":`This event cannot be sent safely. ${d.error}`,initialPayload:"{}",payloadLabel:"Event data (JSON)",sendLabel:"Send event",onSend:async p=>{if(!h)throw new Error(d.error);const v=JSON.parse(p||"{}"),_={name:h.name,scope:h.scope,payload:v};h.scope==="session"?_.session_id=h.scopeId:h.scope==="workflow"?_.workflow_id=h.scopeId:h.scope==="run"&&(_.run_id=h.scopeId),await t.emitEvent(_)}}}return null}function hw(e,t,n,r){const i=y.useRef(null);y.useEffect(()=>{var d,h;if(!t)return;if(e){i.current=document.activeElement||null;const m=r(),p=window.setTimeout(()=>m==null?void 0:m.focus(),0);return()=>window.clearTimeout(p)}const c=n(),u=document.activeElement;i.current&&(!u||u===document.body||c&&c.contains(u))&&((h=(d=i.current).focus)==null||h.call(d)),i.current=null},[e,t])}function t0(e,t){return t?"drawers":e?"overlay":"docked"}function n0(e,t){return t==="drawers"?e:!1}function s0(e){return e.key!=="Escape"||e.defaultPrevented||e.overlayOpen?null:e.sidebarOpen?"sidebar":null}function r0(e=typeof document<"u"?document:void 0){return!!(e!=null&&e.querySelector('[role="dialog"], [role="alertdialog"]'))}function a0(e){const t=Number.parseFloat(String(e??"").trim());return Number.isFinite(t)&&t>0}let gi=null;function o0(){var r;if(gi)return gi;if(typeof document>"u"||typeof MutationObserver>"u")return()=>{};const e=document.documentElement,t=()=>{const i=a0(getComputedStyle(e).getPropertyValue("--keyboard-inset"));i&&e.dataset.keyboard!=="open"?e.dataset.keyboard="open":!i&&e.dataset.keyboard&&delete e.dataset.keyboard},n=new MutationObserver(t);return n.observe(e,{attributes:!0,attributeFilter:["style"]}),(r=window.visualViewport)==null||r.addEventListener("resize",t),t(),gi=()=>{var i;n.disconnect(),(i=window.visualViewport)==null||i.removeEventListener("resize",t),gi=null},gi}function i0(e){const t=e.querySelector(".code-topbar");if(!t)return null;const r=getComputedStyle(t).display==="contents"?e.querySelector(".code-toolbar"):t,i=r==null?void 0:r.getBoundingClientRect().bottom;return typeof i=="number"&&i>0?Math.round(i):null}function l0(e){const[t,n]=y.useState(e);return y.useEffect(()=>{if(typeof window>"u")return;const r=()=>n(i0(document)??e);r();const i=typeof ResizeObserver<"u"?new ResizeObserver(r):null,c=document.querySelector(".code-topbar"),u=document.querySelector(".code-toolbar");return i&&c&&i.observe(c),i&&u&&i.observe(u),window.addEventListener("resize",r),()=>{i==null||i.disconnect(),window.removeEventListener("resize",r)}},[e]),t}class c0{constructor(){Mn(this,"_buffer","");Mn(this,"_current",{data_lines:[]})}push(t,n){for(this._buffer+=t;;){const r=this._buffer.indexOf(`
|
|
84
|
+
`);if(r===-1)return;const i=this._buffer.slice(0,r);this._buffer=this._buffer.slice(r+1);const c=i.endsWith("\r")?i.slice(0,-1):i;if(c.startsWith(":"))continue;if(c===""){if(this._current.data_lines.length>0||this._current.event||this._current.id){const m={id:this._current.id,event:this._current.event,data:this._current.data_lines.join(`
|
|
85
|
+
`)};n(m)}this._current={data_lines:[]};continue}const u=c.indexOf(":"),d=u===-1?c:c.slice(0,u),h=u===-1?"":c.slice(u+1).trimStart();d==="id"?this._current.id=h:d==="event"?this._current.event=h:d==="data"&&this._current.data_lines.push(h)}}}function st(e){var r;const t=(e||"").trim(),n={};t&&(n.Authorization=`Bearer ${t}`);try{const i=(r=document.cookie.split(";").map(c=>c.trim()).find(c=>c.startsWith("abstractcode_gateway_csrf=")))==null?void 0:r.slice(26);i&&(n["X-AbstractCode-CSRF"]=decodeURIComponent(i))}catch{}return n}function u0(e){const t=e.headers.get("retry-after");if(!t)return;const n=Number(t);if(Number.isFinite(n)&&n>0)return n}async function d0(e){var t;try{if(String(e.headers.get("content-type")||"").toLowerCase().includes("application/json")){const i=await e.json().catch(()=>null);if(i&&typeof i=="object"){const c=i.detail;if(typeof c=="string"&&c.trim())return c.trim();const u=(t=i.error)==null?void 0:t.message;if(typeof u=="string"&&u.trim())return u.trim();try{const d=JSON.stringify(i);if(d&&d!=="{}")return d}catch{}}}const r=await e.text();return r!=null&&r.trim()?r.trim():`${e.status}`}catch{return`${e.status}`}}class mw extends Error{constructor(n,r){super(n);Mn(this,"status");Mn(this,"retry_after_s");Mn(this,"body_text");this.name="GatewayHttpError",this.status=Number.isFinite(Number(r.status))?Number(r.status):0,this.retry_after_s=r.retry_after_s,this.body_text=r.body_text}}async function rt(e,t){const n=await d0(e);throw new mw(`${t}: ${n}`,{status:e.status,retry_after_s:u0(e),body_text:n})}class f0{constructor(t){Mn(this,"_cfg");this._cfg={...t,base_url:(t.base_url||"").trim()}}async start_run(t,n,r){const i=String((r==null?void 0:r.bundle_id)||"").trim(),c=(r==null?void 0:r.session_id)===null||(r==null?void 0:r.session_id)===void 0?"":String(r.session_id||"").trim(),u=String(t||"").trim(),d={input_data:n||{}};i&&(d.bundle_id=i),u&&(d.flow_id=u),c&&(d.session_id=c);const h=await fetch(et(this._cfg.base_url.trim(),_e("runs/start")),{method:"POST",headers:{"Content-Type":"application/json",...st(this._cfg.auth_token)},body:JSON.stringify(d)});if(!h.ok)return await rt(h,"start_run failed");const m=await h.json(),p=m==null?void 0:m.run_id;if(typeof p!="string"||!p)throw new Error("start_run: missing run_id");return p}async get_run(t){const n=String(t||"").trim();if(!n)throw new Error("get_run: run_id is required");const r=await fetch(et(this._cfg.base_url.trim(),_e(`runs/${encodeURIComponent(n)}`)),{headers:{...st(this._cfg.auth_token)}});return r.ok?await r.json():await rt(r,"get_run failed")}async get_run_history_bundle(t,n){const r=String(t||"").trim();if(!r)throw new Error("get_run_history_bundle: run_id is required");const i=new URLSearchParams;(n==null?void 0:n.include_subruns)===!1&&i.set("include_subruns","false"),(n==null?void 0:n.include_session)===!0&&i.set("include_session","true"),typeof(n==null?void 0:n.session_turn_limit)=="number"&&Number.isFinite(n.session_turn_limit)&&i.set("session_turn_limit",String(Math.max(1,Math.trunc(n.session_turn_limit)))),n!=null&&n.ledger_mode&&i.set("ledger_mode",String(n.ledger_mode)),typeof(n==null?void 0:n.ledger_max_items)=="number"&&Number.isFinite(n.ledger_max_items)&&i.set("ledger_max_items",String(Math.max(0,Math.trunc(n.ledger_max_items))));const c=et(this._cfg.base_url.trim(),_e(`runs/${encodeURIComponent(r)}/history_bundle?${i.toString()}`)),u=await fetch(c,{headers:{...st(this._cfg.auth_token)}});return u.ok?await u.json():await rt(u,"get_run_history_bundle failed")}async list_runs(t){const n=new URLSearchParams,r=typeof(t==null?void 0:t.limit)=="number"?t.limit:50;n.set("limit",String(r));const i=String((t==null?void 0:t.status)||"").trim();i&&n.set("status",i);const c=String((t==null?void 0:t.workflow_id)||"").trim();c&&n.set("workflow_id",c);const u=String((t==null?void 0:t.session_id)||"").trim();u&&n.set("session_id",u),(t==null?void 0:t.root_only)===!0&&n.set("root_only","true"),(t==null?void 0:t.include_ledger_len)===!1&&n.set("include_ledger_len","false"),(t==null?void 0:t.include_metrics)===!0&&n.set("include_metrics","true");const d=et(this._cfg.base_url.trim(),_e(`runs?${n.toString()}`)),h=await fetch(d,{headers:{...st(this._cfg.auth_token)}});return h.ok?await h.json():await rt(h,"list_runs failed")}async get_ledger(t,n){const r=String(t||"").trim();if(!r)throw new Error("get_ledger: run_id is required");const i=Number((n==null?void 0:n.after)||0),c=Number((n==null?void 0:n.limit)||0),u=et(this._cfg.base_url.trim(),_e(`runs/${encodeURIComponent(r)}/ledger?after=${encodeURIComponent(String(i))}&limit=${encodeURIComponent(String(c))}`)),d=await fetch(u,{headers:{...st(this._cfg.auth_token)}});if(!d.ok)return await rt(d,"get_ledger failed");const h=await d.json(),m=Array.isArray(h==null?void 0:h.items)?h.items:[],p=typeof(h==null?void 0:h.next_after)=="number"?h.next_after:i;return{items:m,next_after:p}}async stream_ledger(t,n){var C;const r=String(t||"").trim();if(!r)throw new Error("stream_ledger: run_id is required");if(n.on_delta&&!n.on_delta_error)throw new Error("stream_ledger: on_delta requires on_delta_error (malformed live frames must be reported)");const i=Number((n==null?void 0:n.after)||0),c=n.on_step,u=n.signal,d=et(this._cfg.base_url.trim(),_e(`runs/${encodeURIComponent(r)}/ledger/stream?after=${encodeURIComponent(String(i))}`)),h=await fetch(d,{headers:{Accept:"text/event-stream",...st(this._cfg.auth_token)},signal:u});if(!h.ok)return await rt(h,"stream_ledger failed");if(!h.body)throw new Error("stream_ledger: response body is missing");(C=n.on_open)==null||C.call(n);const m=h.body.getReader(),p=new TextDecoder("utf-8"),v=new c0,_=n.on_delta,b=n.on_delta_error;for(;;){const{value:x,done:j}=await m.read();if(j)return;const N=p.decode(x,{stream:!0});v.push(N,$=>{if(_&&b){const S=$.event||"message",E=$.data??"";let A;try{A=Zy(S,E)}catch(R){b(R instanceof Error?R:new Error(String(R)),{event:S,data:E});return}if(A){_(A);return}}if(!($.event!=="step"||!$.data))try{const S=JSON.parse($.data);S&&typeof S.cursor=="number"&&S.record&&c(S)}catch{}})}}async list_bundles(){const t=await fetch(et(this._cfg.base_url.trim(),_e("bundles")),{headers:{...st(this._cfg.auth_token)}});return t.ok?await t.json():await rt(t,"list_bundles failed")}async reload_bundles(){const t=await fetch(et(this._cfg.base_url.trim(),_e("bundles/reload")),{method:"POST",headers:{...st(this._cfg.auth_token)}});return t.ok?await t.json():await rt(t,"reload_bundles failed")}async upload_bundle(t,n){const r=(n==null?void 0:n.overwrite)===!0,i=(n==null?void 0:n.reload)!==!1,c=new FormData;c.set("overwrite",r?"true":"false"),c.set("reload",i?"true":"false"),c.set("file",t,t.name||"upload.flow");const u=await fetch(et(this._cfg.base_url.trim(),_e("bundles/upload")),{method:"POST",headers:{...st(this._cfg.auth_token)},body:c});return u.ok?await u.json():await rt(u,"upload_bundle failed")}async discovery_tools(){const t=await fetch(et(this._cfg.base_url.trim(),_e("discovery/tools")),{headers:{...st(this._cfg.auth_token)}});return t.ok?await t.json():await rt(t,"discovery_tools failed")}async discovery_providers(t){const n=(t==null?void 0:t.include_models)===!0,r=et(this._cfg.base_url.trim(),_e(`discovery/providers?include_models=${encodeURIComponent(String(n))}`)),i=await fetch(r,{headers:{...st(this._cfg.auth_token)}});return i.ok?await i.json():await rt(i,"discovery_providers failed")}async discovery_provider_models(t){const n=String(t||"").trim();if(!n)throw new Error("discovery_provider_models: provider_name is required");const r=await fetch(et(this._cfg.base_url.trim(),_e(`discovery/providers/${encodeURIComponent(n)}/models`)),{headers:{...st(this._cfg.auth_token)}});return r.ok?await r.json():await rt(r,"discovery_provider_models failed")}async discovery_model_capabilities(t,n=""){const r=String(t||"").trim();if(!r)throw new Error("discovery_model_capabilities: model_name is required");const i=new URLSearchParams({model_name:r});n.trim()&&i.set("provider",n.trim());const c=et(this._cfg.base_url.trim(),_e(`discovery/models/capabilities?${i}`)),u=await fetch(c,{headers:{...st(this._cfg.auth_token)}});return u.ok?await u.json():await rt(u,"discovery_model_capabilities failed")}async workspace_policy(){const t=await fetch(et(this._cfg.base_url.trim(),_e("workspace/policy")),{headers:{...st(this._cfg.auth_token)}});return t.ok?await t.json():await rt(t,"workspace_policy failed")}async files_search(t,n){const r=String(t||"").trim(),i=typeof(n==null?void 0:n.limit)=="number"&&Number.isFinite(n.limit)?Math.max(1,Math.trunc(n.limit)):20,c=new URLSearchParams;c.set("query",r),c.set("limit",String(i));const u=n==null?void 0:n.scope;if(u&&typeof u=="object"){const m=String(u.workspace_root||"").trim();m&&c.set("workspace_root",m)}const d=et(this._cfg.base_url.trim(),_e(`files/search?${c.toString()}`)),h=await fetch(d,{headers:{...st(this._cfg.auth_token)},signal:n==null?void 0:n.signal});return h.ok?await h.json():await rt(h,"files_search failed")}async list_run_artifacts(t,n){const r=String(t||"").trim();if(!r)throw new Error("list_run_artifacts: run_id is required");const i=typeof(n==null?void 0:n.limit)=="number"?n.limit:200,c=et(this._cfg.base_url.trim(),_e(`runs/${encodeURIComponent(r)}/artifacts?limit=${encodeURIComponent(String(i))}`)),u=await fetch(c,{headers:{...st(this._cfg.auth_token)}});return u.ok?await u.json():await rt(u,"list_run_artifacts failed")}async get_run_artifact_blob(t,n,r){const i=String(t||"").trim(),c=String(n||"").trim();if(!i)throw new Error("get_run_artifact_blob: run_id is required");if(!c)throw new Error("get_run_artifact_blob: artifact_id is required");const u=et(this._cfg.base_url.trim(),_e(`runs/${encodeURIComponent(i)}/artifacts/${encodeURIComponent(c)}/content`)),d=await fetch(u,{headers:{...st(this._cfg.auth_token)}});if(!d.ok)return await rt(d,"get_run_artifact_blob failed");const h=await d.blob(),m=typeof(r==null?void 0:r.max_bytes)=="number"&&Number.isFinite(r.max_bytes)?Math.max(0,Math.trunc(r.max_bytes)):0;if(m>0&&h.size>m)throw new Error(`Artifact too large (${h.size} bytes > ${m} bytes)`);const p=String(d.headers.get("content-type")||"").trim()||"application/octet-stream";return{blob:h,content_type:p}}async get_run_artifact_text(t,n,r){const{blob:i}=await this.get_run_artifact_blob(t,n,r);return await i.text()}async attachments_ingest(t,n,r){const i=String(t||"").trim(),c=String(n||"").trim();if(!i)throw new Error("attachments_ingest: session_id is required");if(!c)throw new Error("attachments_ingest: path is required");const u={session_id:i,path:c},d=r==null?void 0:r.scope;if(d&&typeof d=="object"){const _=String(d.workspace_root||"").trim();_&&(u.workspace_root=_)}const h=await fetch(et(this._cfg.base_url.trim(),_e("attachments/ingest")),{method:"POST",headers:{"Content-Type":"application/json",...st(this._cfg.auth_token)},body:JSON.stringify(u)});if(!h.ok)return await rt(h,"attachments_ingest failed");const m=await h.json(),p=m==null?void 0:m.attachment;if(!p||typeof p!="object")throw new Error("attachments_ingest: missing attachment");if(!String(p.$artifact||"").trim())throw new Error("attachments_ingest: missing attachment.$artifact");return p}async attachments_upload(t,n,r){const i=String(t||"").trim();if(!i)throw new Error("attachments_upload: session_id is required");if(!n)throw new Error("attachments_upload: file is required");const c=String((r==null?void 0:r.filename)||"").trim()||String((n==null?void 0:n.name)||"").trim()||"upload.bin",u=String((r==null?void 0:r.content_type)||"").trim()||String((n==null?void 0:n.type)||"").trim(),d=new FormData;d.append("session_id",i),d.append("file",n,c),d.append("filename",c),u&&d.append("content_type",u);const h=await fetch(et(this._cfg.base_url.trim(),_e("attachments/upload")),{method:"POST",headers:{...st(this._cfg.auth_token)},body:d});if(!h.ok)return await rt(h,"attachments_upload failed");const m=await h.json(),p=m==null?void 0:m.attachment;if(!p||typeof p!="object")throw new Error("attachments_upload: missing attachment");if(!String(p.$artifact||"").trim())throw new Error("attachments_upload: missing attachment.$artifact");return p}async audio_transcribe(t,n){const r=String(t||"").trim();if(!r)throw new Error("audio_transcribe: run_id is required");const i={audio_artifact:n==null?void 0:n.audio_artifact,request_id:(n==null?void 0:n.request_id)||void 0},c=(n==null?void 0:n.language)===null||(n==null?void 0:n.language)===void 0?"":String(n.language||"").trim();c&&(i.language=c),n!=null&&n.provider&&(i.provider=String(n.provider)),n!=null&&n.provider&&(n!=null&&n.model)&&(i.model=String(n.model));const u=await fetch(et(this._cfg.base_url.trim(),_e(`runs/${encodeURIComponent(r)}/audio/transcribe`)),{method:"POST",headers:{"Content-Type":"application/json",...st(this._cfg.auth_token)},body:JSON.stringify(i)});return u.ok?await u.json():await rt(u,"audio_transcribe failed")}async voice_tts(t,n){const r=String(t||"").trim();if(!r)throw new Error("voice_tts: run_id is required");const i={text:String((n==null?void 0:n.text)||"")},c=(n==null?void 0:n.voice)===null||(n==null?void 0:n.voice)===void 0?"":String(n.voice||"").trim(),u=(n==null?void 0:n.format)===null||(n==null?void 0:n.format)===void 0?"":String(n.format||"").trim(),d=(n==null?void 0:n.request_id)===null||(n==null?void 0:n.request_id)===void 0?"":String(n.request_id||"").trim();c&&(i.voice=c),u&&(i.format=u),d&&(i.request_id=d);const h=await fetch(et(this._cfg.base_url.trim(),_e(`runs/${encodeURIComponent(r)}/voice/tts`)),{method:"POST",headers:{"Content-Type":"application/json",...st(this._cfg.auth_token)},body:JSON.stringify(i)});return h.ok?await h.json():await rt(h,"voice_tts failed")}async submit_command(t){const n={command_id:String((t==null?void 0:t.command_id)||"").trim(),run_id:String((t==null?void 0:t.run_id)||"").trim(),type:String((t==null?void 0:t.type)||"").trim(),payload:t!=null&&t.payload&&typeof t.payload=="object"?t.payload:{}},r=String((t==null?void 0:t.ts)||"").trim();r&&(n.ts=r);const i=String((t==null?void 0:t.client_id)||"").trim();i&&(n.client_id=i);const c=await fetch(et(this._cfg.base_url.trim(),_e("commands")),{method:"POST",headers:{"Content-Type":"application/json",...st(this._cfg.auth_token)},body:JSON.stringify(n)});return c.ok?await c.json():await rt(c,"submit_command failed")}async bug_report_create(t){const n={session_id:String((t==null?void 0:t.session_id)||"").trim(),description:String((t==null?void 0:t.description)||"")},r=String((t==null?void 0:t.active_run_id)||"").trim();r&&(n.active_run_id=r);const i=String((t==null?void 0:t.workflow_id)||"").trim();i&&(n.workflow_id=i);const c=String((t==null?void 0:t.client)||"").trim();c&&(n.client=c);const u=String((t==null?void 0:t.client_version)||"").trim();u&&(n.client_version=u);const d=String((t==null?void 0:t.user_agent)||"").trim();d&&(n.user_agent=d);const h=String((t==null?void 0:t.url)||"").trim();h&&(n.url=h);const m=String((t==null?void 0:t.provider)||"").trim();m&&(n.provider=m);const p=String((t==null?void 0:t.model)||"").trim();p&&(n.model=p);const v=String((t==null?void 0:t.template)||"").trim();v&&(n.template=v);const _=t==null?void 0:t.context;_&&typeof _=="object"&&(n.context=_);const b=await fetch(et(this._cfg.base_url.trim(),_e("bugs/report")),{method:"POST",headers:{"Content-Type":"application/json",...st(this._cfg.auth_token)},body:JSON.stringify(n)});return b.ok?await b.json():await rt(b,"bug_report_create failed")}async feature_report_create(t){const n={session_id:String((t==null?void 0:t.session_id)||"").trim(),description:String((t==null?void 0:t.description)||"")},r=String((t==null?void 0:t.active_run_id)||"").trim();r&&(n.active_run_id=r);const i=String((t==null?void 0:t.workflow_id)||"").trim();i&&(n.workflow_id=i);const c=String((t==null?void 0:t.client)||"").trim();c&&(n.client=c);const u=String((t==null?void 0:t.client_version)||"").trim();u&&(n.client_version=u);const d=String((t==null?void 0:t.user_agent)||"").trim();d&&(n.user_agent=d);const h=String((t==null?void 0:t.url)||"").trim();h&&(n.url=h);const m=String((t==null?void 0:t.provider)||"").trim();m&&(n.provider=m);const p=String((t==null?void 0:t.model)||"").trim();p&&(n.model=p);const v=String((t==null?void 0:t.template)||"").trim();v&&(n.template=v);const _=t==null?void 0:t.context;_&&typeof _=="object"&&(n.context=_);const b=await fetch(et(this._cfg.base_url.trim(),_e("features/report")),{method:"POST",headers:{"Content-Type":"application/json",...st(this._cfg.auth_token)},body:JSON.stringify(n)});return b.ok?await b.json():await rt(b,"feature_report_create failed")}async prompt_cache_stats(t,n){const r=String(t||"").trim(),i=String(n||"").trim();if(!r||!i)throw new Error("prompt_cache_stats: provider and model are required");const c=et(this._cfg.base_url.trim(),_e(`prompt_cache/stats?provider=${encodeURIComponent(r)}&model=${encodeURIComponent(i)}`)),u=await fetch(c,{headers:{...st(this._cfg.auth_token)}});return u.ok?await u.json():await rt(u,"prompt_cache_stats failed")}async prompt_cache_capabilities(t,n){const r=String(t||"").trim(),i=String(n||"").trim();if(!r||!i)throw new Error("prompt_cache_capabilities: provider and model are required");const c=et(this._cfg.base_url.trim(),_e(`prompt_cache/capabilities?provider=${encodeURIComponent(r)}&model=${encodeURIComponent(i)}`)),u=await fetch(c,{headers:{...st(this._cfg.auth_token)}});return u.ok?await u.json():await rt(u,"prompt_cache_capabilities failed")}async prompt_cache_saved(t,n){const r=String(t||"").trim(),i=String(n||"").trim();if(!r||!i)throw new Error("prompt_cache_saved: provider and model are required");const c=et(this._cfg.base_url.trim(),_e(`prompt_cache/saved?provider=${encodeURIComponent(r)}&model=${encodeURIComponent(i)}`)),u=await fetch(c,{headers:{...st(this._cfg.auth_token)}});return u.ok?await u.json():await rt(u,"prompt_cache_saved failed")}async prompt_cache_clear(t){const n={provider:String((t==null?void 0:t.provider)||"").trim(),model:String((t==null?void 0:t.model)||"").trim()},r=(t==null?void 0:t.key)===null||(t==null?void 0:t.key)===void 0?"":String(t.key||"").trim();r&&(n.key=r);const i=await fetch(et(this._cfg.base_url.trim(),_e("prompt_cache/clear")),{method:"POST",headers:{"Content-Type":"application/json",...st(this._cfg.auth_token)},body:JSON.stringify(n)});return i.ok?await i.json():await rt(i,"prompt_cache_clear failed")}async prompt_cache_save(t){const n={provider:String((t==null?void 0:t.provider)||"").trim(),model:String((t==null?void 0:t.model)||"").trim(),name:String((t==null?void 0:t.name)||"").trim(),key:String((t==null?void 0:t.key)||"").trim(),q8:!!(t!=null&&t.q8)},r=await fetch(et(this._cfg.base_url.trim(),_e("prompt_cache/save")),{method:"POST",headers:{"Content-Type":"application/json",...st(this._cfg.auth_token)},body:JSON.stringify(n)});return r.ok?await r.json():await rt(r,"prompt_cache_save failed")}async prompt_cache_load(t){const n={provider:String((t==null?void 0:t.provider)||"").trim(),model:String((t==null?void 0:t.model)||"").trim(),name:String((t==null?void 0:t.name)||"").trim(),key:String((t==null?void 0:t.key)||"").trim(),clear_existing:!!(t!=null&&t.clear_existing)},r=await fetch(et(this._cfg.base_url.trim(),_e("prompt_cache/load")),{method:"POST",headers:{"Content-Type":"application/json",...st(this._cfg.auth_token)},body:JSON.stringify(n)});return r.ok?await r.json():await rt(r,"prompt_cache_load failed")}}function Kc(){const e=document.cookie.split(";").map(t=>t.trim()).find(t=>t.startsWith("abstractcode_gateway_csrf="));return e?{"X-AbstractCode-CSRF":decodeURIComponent(e.slice(26))}:{}}async function ct(e,t={}){var i;if(!e.startsWith(`${Rr}/`))throw new Error("Gateway requests must use the app's authenticated proxy (a relative api/gateway/… path).");const n=new Headers(t.headers);n.set("Accept","application/json"),t.body&&!(t.body instanceof FormData)&&n.set("Content-Type","application/json");for(const[c,u]of Object.entries(Kc()))n.set(c,u);const r=await fetch(e,{...t,headers:n,credentials:"same-origin"});if(!r.ok){const c=await r.text();let u=c;try{const d=JSON.parse(c);u=typeof d.detail=="string"?d.detail:typeof((i=d.detail)==null?void 0:i.message)=="string"?d.detail.message:JSON.stringify(d.detail||d)}catch{}throw new mw(u||`Gateway request failed (${r.status})`,{status:r.status,body_text:c})}if(r.status!==204)return r.json()}const Ln=new f0({base_url:""});function vt(e){return e instanceof Error?e.message:String(e)}function Ar(){return la()}async function h0(e,t,n){const{blob:r}=await Ln.get_run_artifact_blob(e,t),i=URL.createObjectURL(r),c=document.createElement("a");c.href=i,c.download=n.replace(/[\\/]/g,"_")||"artifact",c.click(),window.setTimeout(()=>URL.revokeObjectURL(i),1e3)}const m0={app:"code",name:"AbstractCode"},p0=["How do I change the model?","Where are my files and generated outputs?","How do I schedule an automation?"],g0=(e,t={})=>{const n=new Headers(t.headers||{}),r=String(t.method||"GET").toUpperCase();if(r!=="GET"&&r!=="HEAD")for(const[i,c]of Object.entries(Kc()))n.set(i,c);return fetch(e,{...t,headers:n,credentials:"same-origin"})};function y0({open:e,onClose:t,connected:n,topOffset:r}){return hw(e,!0,()=>document.querySelector(".code-app-assistant"),()=>document.querySelector(".code-app-assistant .pc-composer textarea")),a.jsx(TS,{open:e,onClose:t,source:m0,fetchGateway:g0,connected:n,topOffset:r,className:"code-app-assistant",placeholder:"Ask about AbstractCode…",suggestions:p0})}function ho({children:e}){return a.jsxs("p",{className:"code-history-empty code-loading-status",role:"status",children:[a.jsx("span",{className:"code-loading-spinner","aria-hidden":"true"}),e]})}function w0(e){const t=e.isDrawer&&!e.open;return a.jsx("aside",{className:"code-sidebar","aria-label":"Conversations",...t?{inert:""}:{},children:e.children})}const Jc=(e,t)=>ct(e,{method:t.method,...t.body!==void 0?{body:JSON.stringify(t.body)}:{}}),Qc="Connect to your gateway to change workspaces.";function pw(e,t,n,r){const[i,c]=y.useState(null),[u,d]=y.useState(null),h=t?t.level==="session"?`session:${t.session}`:"account":"";y.useEffect(()=>{if(c(null),d(null),!e||!t)return;let p=!0;return Rp(n,t).load().then(v=>p&&c(v)).catch(v=>p&&d(`Could not read the workspaces: ${vt(v)}`)),()=>{p=!1}},[e,h,n,r]);const m=y.useCallback(async p=>{if(!t)throw new Error(Qc);const v=await Rp(n,t).save(p);return c(v),v},[h,n]);return{state:i,error:u,save:m}}function gw(e){return e.automation?a.jsx(x0,{...e,automation:e.automation}):a.jsx(v0,{...e})}function v0({connected:e,sessionId:t,onOpenDefaults:n,refreshKey:r,request:i=Jc}){const c=pw(e,t?{level:"session",session:t}:null,i,r),u=e?t?null:"Open a conversation to choose its workspaces.":Qc;return a.jsxs(a.Fragment,{children:[a.jsx(Of,{level:"session",idPrefix:"code-workspace-session",state:c.state,save:c.save,loadError:u??c.error,unavailableReason:u}),n?a.jsx("p",{className:"code-default-workspaces",children:a.jsx("button",{type:"button",className:"code-text-button","data-action":"open-default-workspaces",onClick:n,disabled:!e,children:"My default workspaces"})}):null]})}function _0({open:e,onClose:t,connected:n,onChanged:r,request:i=Jc}){const c=pw(n&&e,e?{level:"account"}:null,i),u=n?null:Qc,d=y.useCallback(async h=>{const m=await c.save(h);return r==null||r(),m},[c,r]);return a.jsx(eb,{open:e,onClose:t,title:"My default workspaces",size:"narrow",children:a.jsx(Of,{level:"account",idPrefix:"code-workspace-account",state:c.state,save:d,loadError:u??c.error,unavailableReason:u})})}function b0(e,t,n,r){const[i,c]=y.useState(null),[u,d]=y.useState(null),h=JSON.stringify(t);y.useEffect(()=>{if(d(null),!e){c(null);return}let p=!0;return wf(r)(t).then(v=>p&&c(v)).catch(v=>p&&d(`Could not read the workspaces: ${Lf(v)||vt(v)}`)),()=>{p=!1}},[e,h,r]);const m=y.useCallback(async p=>{const v=await wf(r)(p);c(v),n(p)},[r,n]);return{effective:i,error:u,onChange:m}}function x0({connected:e,automation:t,idPrefix:n="code-workspace-automation",request:r=Jc}){const i=b0(e,t.value,t.onChange,r),c=e?null:Qc;return a.jsx(Of,{level:"run",idPrefix:n,value:t.value,effective:i.effective,onChange:i.onChange,loadError:c??i.error,unavailableReason:c})}const yw="abstractcode.sidebar.panels",yi={automations:!0,conversations:!0};function k0(e){try{const t=e==null?void 0:e.getItem(yw);if(!t)return{...yi};const n=JSON.parse(t);if(!n||typeof n!="object")return{...yi};const r=n;return{automations:typeof r.automations=="boolean"?r.automations:yi.automations,conversations:typeof r.conversations=="boolean"?r.conversations:yi.conversations}}catch{return{...yi}}}function j0(e,t){try{t==null||t.setItem(yw,JSON.stringify(e))}catch{}}function S0(e,t){return{...e,[t]:!e[t]}}function Ac(){try{return typeof window<"u"?window.localStorage:null}catch{return null}}function N0(){const[e,t]=y.useState(()=>k0(Ac())),n=y.useCallback(r=>{t(i=>{const c=S0(i,r);return j0(c,Ac()),c})},[]);return[e,n]}const Uf=e=>({toggle:`code-panel-${e}-toggle`,region:`code-panel-${e}`});function ww(e){const t=Uf(e.panel);return a.jsxs("div",{className:"code-panel-header",children:[a.jsxs("button",{type:"button",className:"code-panel-toggle",id:t.toggle,"aria-expanded":e.open,"aria-controls":t.region,onClick:e.onToggle,children:[a.jsx(ne,{name:"chevronDown",size:14}),a.jsx("span",{children:e.label})]}),e.actions?a.jsx("span",{className:"code-panel-actions",children:e.actions}):null]})}function C0(e){return a.jsx("div",{className:"code-sidebar-lists","data-automations":e.panels.automations?"open":"closed","data-conversations":e.panels.conversations?"open":"closed",children:e.children})}function E0(e){const t=Uf("conversations");return a.jsxs("section",{className:"code-panel code-conversations","data-open":e.open?"true":"false",children:[a.jsx(ww,{panel:"conversations",label:"Conversations",open:e.open,onToggle:e.onToggle,actions:e.actions}),a.jsx("nav",{className:"code-sessions",id:t.region,"aria-labelledby":t.toggle,hidden:!e.open,children:e.children})]})}function $0(e){return e.split("/").filter(Boolean).pop()||"Gateway managed"}const vw="abstractcode.sidebar.archived",Xp={automations:!1,conversations:!1};function A0(e){try{const t=e==null?void 0:e.getItem(vw),n=t?JSON.parse(t):null;return!n||typeof n!="object"?{...Xp}:{automations:n.automations===!0,conversations:n.conversations===!0}}catch{return{...Xp}}}function T0(){const[e,t]=y.useState(()=>A0(Ac())),n=y.useCallback(r=>{t(i=>{var u;const c={...i,[r]:!i[r]};try{(u=Ac())==null||u.setItem(vw,JSON.stringify(c))}catch{}return c})},[]);return[e,n]}function _w(e){const t=y.useRef(null),n=y.useRef(!1);if(y.useEffect(()=>{var i,c;!e.open||!n.current||(n.current=!1,(c=(i=t.current)==null?void 0:i.scrollIntoView)==null||c.call(i,{block:"nearest",behavior:"smooth"}))},[e.open]),!(e.count>0))return null;const r=`code-archived-${e.list}`;return a.jsxs("div",{className:"code-archived","data-list":e.list,"data-open":e.open?"true":"false",children:[a.jsxs("button",{type:"button",className:"code-archived-toggle","aria-expanded":e.open,"aria-controls":r,onClick:()=>{n.current=!0,e.onToggle()},children:[a.jsxs("span",{children:["Archived · ",e.count]}),a.jsx(ne,{name:"chevronDown",size:12})]}),e.open?a.jsx("ul",{ref:t,className:"code-archived-list",id:r,"aria-label":`Archived ${e.list}`,children:e.children}):null]})}function bw(e){return a.jsxs("li",{className:"code-archived-row","data-id":e.id,children:[a.jsxs("button",{type:"button",className:"code-archived-name",title:e.title,onClick:e.onOpen,children:[a.jsx("strong",{children:e.title}),e.meta?a.jsx("small",{children:e.meta}):null]}),a.jsxs("button",{type:"button",className:"code-subtle-button code-archived-unarchive","data-action":"unarchive",disabled:e.busy,"aria-busy":e.busy||void 0,onClick:e.onUnarchive,children:[e.busy?a.jsx(ne,{name:"loader",size:12}):a.jsx(ne,{name:"archive",size:12}),a.jsx("span",{children:"Unarchive"})]}),e.error?a.jsx("p",{className:"code-inline-error",role:"alert",children:e.error}):null]})}const R0="Archive this conversation? It stays searchable and auditable; it just leaves this list.";function I0(e){const t=y.useRef(null);return y.useEffect(()=>{var n;(n=t.current)==null||n.focus({preventScroll:!0})},[]),a.jsxs("div",{className:`code-archive-confirm${e.className?` ${e.className}`:""}`,role:"group","aria-label":"Archive conversation",onKeyDown:n=>{n.key==="Escape"&&!e.busy&&(n.preventDefault(),n.stopPropagation(),e.onCancel())},children:[a.jsx("p",{children:R0}),a.jsxs("span",{className:"code-archive-confirm-actions",children:[a.jsxs("button",{type:"button",ref:t,className:"code-archive-confirm-yes","data-action":"confirm-archive",disabled:e.busy,"aria-busy":e.busy||void 0,onClick:e.onConfirm,children:[e.busy?a.jsx(ne,{name:"loader",size:12}):a.jsx(ne,{name:"archive",size:12}),a.jsx("span",{children:"Archive"})]}),a.jsx("button",{type:"button",className:"code-subtle-button","data-action":"cancel-archive",disabled:e.busy,onClick:e.onCancel,children:"Cancel"})]}),e.error?a.jsx("p",{className:"code-inline-error",role:"alert",children:e.error}):null]})}const M0="abstractcode.agent.v1";function Bf(e){return!!(e!=null&&e.interfaces.some(t=>[M0,"abstractassistant.agent.v1"].includes(t)))}function it(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function xf(e){return Array.isArray(e)?e:[]}function Re(e){return typeof e!="string"?void 0:e.trim()||void 0}function L0(e){return xf(e).flatMap(t=>{const n=Re(t);return n?[n]:[]})}function Ri(e,t=0){if(typeof e!="number"||!Number.isFinite(e))return;const n=Math.trunc(e);return n>=t?n:void 0}function Wf(e,t){if(Array.isArray(e))return e;const n=it(e);if(!n)return[];for(const r of t)if(Array.isArray(n[r]))return n[r];return[]}function xw(e){const t=it(e);return t?{...t}:void 0}function qp(e){const t=xw(e.input_schema??e.inputSchema??e.inputs_schema);if(t)return t;const n=it(e.inputs);if(n&&("properties"in n||"type"in n||"$schema"in n))return{...n}}function O0(e){const t=Re(e.bundle_version??e.bundleVersion??e.version);if(t)return t;const n=Re(e.bundle_ref??e.bundleRef);if(!n)return;const r=n.lastIndexOf("@");return r>0&&r<n.length-1?n.slice(r+1):void 0}function P0(e,t,n){return e?`${e}${t?`@${t}`:""}:${n}`:n}function Zp(e,t,n){var d;const r=it(e),i=Re((r==null?void 0:r.default_bundle_id)??(r==null?void 0:r.defaultBundleId)),c=Wf(e,["items","bundles"]),u=[];for(const h of c){const m=it(h);if(!m)continue;const p=it(m.actions);if((p==null?void 0:p.can_run)===!1)continue;const v=(d=Re(m.status))==null?void 0:d.toLowerCase();if(m.is_draft===!0||m.is_published===!1||m.version_channel==="draft"||v&&!["published","deprecated"].includes(v)||!n.includeDeprecated&&(v==="deprecated"||v==="deleted"||v==="disabled"))continue;const _=Re(m.bundle_id??m.bundleId??m.id),b=O0(m);if(b&&/(?:^|[.\-])draft(?:[.\-]|$)/i.test(b))continue;const C=Re(m.default_entrypoint??m.defaultEntrypoint),x=t==="private"&&(m.is_default===!0||m.isDefault===!0||!!_&&_===i);for(const j of xf(m.entrypoints)){const N=it(j);if(!N||!n.includeDeprecated&&(N.deprecated===!0||N.enabled===!1))continue;const $=Re(N.flow_id??N.flowId??N.id);if(!$)continue;const S=L0(N.interfaces??N.interface_ids??N.interfaceIds);if(n.interfaceId&&!S.includes(n.interfaceId))continue;const E=Re(N.workflow_id??N.workflowId)??P0(_,b,$),A=C?C===$:xf(m.entrypoints).length===1;u.push({id:`${t}:${E}`,workflowId:E,..._?{bundleId:_}:{},...b?{bundleVersion:b}:{},flowId:$,name:Re(N.name??N.title)??$,description:Re(N.description)??"",interfaces:S,...qp(N)?{inputSchema:qp(N)}:{},registryScope:t,isPreferredVersion:t==="tenant_catalog"?m.is_default===!0||m.default_version===b:m.latest_published_version===b,...x&&A?{isDefault:!0}:{}})}}return u}function D0(e,t,n={}){const r=[...Zp(e,"private",n),...Zp(t,"tenant_catalog",n)],i=new Map;for(const c of r)i.set(c.id,c);return[...i.values()].sort((c,u)=>+!!u.isDefault-+!!c.isDefault||c.name.localeCompare(u.name)||c.id.localeCompare(u.id))}function F0(e){const t=it(e);if(!t)return;const n=it(t.workflow_selection??t.workflowSelection);if(n)return n;const r=it(t._runtime),i=it((r==null?void 0:r.workflow_policy)??(r==null?void 0:r.workflowPolicy));if(i)return i;const c=it(t.input_data??t.inputData),u=it(c==null?void 0:c._runtime);return it((u==null?void 0:u.workflow_policy)??(u==null?void 0:u.workflowPolicy))}function z0(e,t){const n=F0(t.inputData);if(n){const c=Re(n.registry_scope??n.registryScope),u=Re(n.bundle_id??n.bundleId),d=Re(n.bundle_version??n.bundleVersion),h=Re(n.flow_id??n.flowId);if((c==="private"||c==="tenant_catalog")&&u&&h){const m=e.filter(p=>(p.registryScope??"private")===c&&p.bundleId===u&&p.flowId===h&&(!d||p.bundleVersion===d));if(m.length===1)return m[0]}return}const r=Re(t.runWorkflowId);if(!r)return;const i=e.filter(c=>(c.registryScope??"private")==="private"&&c.workflowId===r);return i.length===1?i[0]:void 0}function U0(e){const t=it(e)??{},n=it(t.policy)??t,r=Ri(n.max_attachment_bytes??n.maxAttachmentBytes,1);return{raw:{...n},...r!==void 0?{maxAttachmentBytes:r}:{}}}function eg(e,t){const n=Re(e.sandbox);if(!n||typeof e.sandboxed!="boolean")return;const r=Re(t==null?void 0:t.sentence),i=e.sandboxed?"ok":Re(t==null?void 0:t.state)==="unsandboxed"?"danger":"warn";return{label:n,...r?{tooltip:r}:{},tone:i}}function B0(e){var c;const t=Wf(e,["items","tools"]),n=it((c=it(e))==null?void 0:c.command_sandbox),r=new Set,i=[];for(const u of t){const d=it(u);if(!d)continue;const h=Re(d.name??d.tool_name??d.id);if(!h||r.has(h))continue;r.add(h);const m=d.enabled!==!1&&d.served_disabled!==!0&&d.servedDisabled!==!0,p=Ri(d.risk_rank??d.riskRank),v=xw(d.input_schema??d.inputSchema??d.parameters);i.push({name:h,description:Re(d.description)??"",...Re(d.toolset)?{toolset:Re(d.toolset)}:{},...Re(d.tier)?{tier:Re(d.tier)}:{},...Re(d.approval_default??d.default_approval??d.approvalDefault??d.defaultApproval??d.approval)?{approval:Re(d.approval_default??d.default_approval??d.approvalDefault??d.defaultApproval??d.approval)}:{},...p!==void 0?{riskRank:p}:{},enabled:m,servedDisabled:!m,...Re(d.enable_gate??d.enableGate)?{enableGate:Re(d.enable_gate??d.enableGate)}:{},...Re(d.why_disabled??d.whyDisabled)?{whyDisabled:Re(d.why_disabled??d.whyDisabled)}:{},...v?{inputSchema:v}:{},...eg(d,n)?{sandboxState:eg(d,n)}:{},raw:{...d}})}return i.sort((u,d)=>u.name.localeCompare(d.name))}function W0(e){var r;const t=(r=Re(e.status??e.state))==null?void 0:r.toLowerCase();return Re(e.wait_reason??e.waitReason)||e.waiting===!0||t==="waiting"||t==="paused"?"waiting":t==="running"||t==="queued"||t==="pending"||t==="created"?"running":t==="failed"||t==="error"||t==="cancelled"||t==="canceled"?"failed":t==="completed"||t==="complete"||t==="done"?"done":"unknown"}const tg={waiting:4,running:3,failed:2,done:1,unknown:0};function to(e){return Re(e.updated_at??e.updatedAt??e.finished_at??e.finishedAt??e.created_at??e.createdAt)}function no(e){if(!e)return Number.NEGATIVE_INFINITY;const t=Date.parse(e);return Number.isFinite(t)?t:Number.NEGATIVE_INFINITY}function ng(e){var u;const t=Re(e);if(t)return t;const n=it(e);if(!n)return;const r=Re(n.prompt);if(r)return r;const i=it(n.input_data??n.inputData),c=["prompt","request","task","message","query","input"].map(d=>Re(i==null?void 0:i[d])).find(Boolean);return c||Re((u=it(i==null?void 0:i.context))==null?void 0:u.task)}function Tc(e,t={}){const n=it(e),r=(n==null?void 0:n.has_more)===!0||(n==null?void 0:n.hasMore)===!0,i=Wf(e,["items","runs"]),c=new Map;i.forEach((d,h)=>{const m=it(d);if(!m||Re(m.parent_run_id??m.parentRunId))return;const p=Re(m.session_id??m.sessionId),v=Re(m.run_id??m.runId??m.id);if(!p||!v)return;const _=c.get(p)??[];_.push({run:m,index:h}),c.set(p,_)});const u=[];for(const[d,h]of c){const m=[...h].sort((x,j)=>no(to(j.run))-no(to(x.run))||x.index-j.index),p=[...h].sort((x,j)=>{const N=Re(x.run.created_at??x.run.createdAt)??to(x.run),$=Re(j.run.created_at??j.run.createdAt)??to(j.run);return no(N)-no($)||x.index-j.index}),v=m.flatMap(({run:x})=>{const j=Re(x.run_id??x.runId??x.id);return j?[j]:[]});if(!v.length)continue;let _="unknown";for(const{run:x}of h){const j=W0(x);tg[j]>tg[_]&&(_=j)}let b;for(const{run:x}of p){const j=Re(x.run_id??x.runId??x.id);if(b=(j?ng(t[j]):void 0)??ng(x),b)break}let C=0;for(const{run:x}of h){const j=x.tool_calls;C=typeof j=="number"&&Number.isFinite(j)&&C!==void 0?C+j:void 0}u.push({sessionId:d,state:_,...to(m[0].run)?{updatedAt:to(m[0].run)}:{},firstRunId:Re(p[0].run.run_id??p[0].run.runId??p[0].run.id),latestRunId:v[0],runIds:v,turnCount:h.length,...C!==void 0?{toolCalls:C}:{},...b?{prompt:b}:{},truncated:r})}return u.sort((d,h)=>no(h.updatedAt)-no(d.updatedAt)||d.sessionId.localeCompare(h.sessionId))}function Rc(e){return e?{...e}:{}}function wi(e){if(e!==void 0)return e.flatMap(t=>{const n=Re(t);return n?[n]:[]})}function V0(e,t,n){var x,j,N,$,S,E,A;const r=(R,z)=>{var L,J;!Bf(t.workflow)&&!((J=it((L=t.inputSchema)==null?void 0:L.properties))!=null&&J[R])||z!==void 0&&n&&(e[R]=z)},i=Re((x=t.model)==null?void 0:x.provider),c=Re((j=t.model)==null?void 0:j.model);if(!!i!=!!c)throw new Error("Choose both a provider and a model, or use the workflow / Gateway defaults.");r("provider",i),r("model",c),t.tools!==void 0&&r("tools",wi(t.tools)??[]);const u=wi(t.skills);u!=null&&u.length&&(e.skills=u);const d=Re((N=t.workspace)==null?void 0:N.root);d!==void 0&&(e.workspace_root=d),r("system",Re(t.system));const h=Rc(it(e._runtime)),m=(R,z)=>{z!==void 0&&n&&(h[R]=z)};if(m("provider",i),m("model",c),m("thinking",Re(t.reasoning)),m("speculation",t.speculation),t.streamReplies!==void 0&&m("stream",Hj(t.streamReplies).stream),m("system_prompt_extra",Re(t.systemPromptExtra)),t.tools!==void 0){const R=wi(t.tools)??[],z=Array.isArray(h.allowed_tools)?h.allowed_tools:null;h.allowed_tools=z?R.filter(L=>z.includes(L)):R}if(t.review!==void 0&&t.reviewCapable!==!1){m("review_mode",t.review.enabled);const R=t.review.enabled?Ri(t.review.maxRounds,1):void 0;m("review_max_rounds",R)}const p=wi(($=t.toolPolicy)==null?void 0:$.autoApproveTools),v=wi((S=t.toolPolicy)==null?void 0:S.requireApprovalTools);(((p==null?void 0:p.length)??0)>0||((v==null?void 0:v.length)??0)>0)&&m("tool_policy",{...p!=null&&p.length?{auto_approve_tools:p}:{},...v!=null&&v.length?{require_approval_tools:v}:{}}),t.promptCache!==void 0&&m("prompt_cache",t.promptCache),Object.keys(h).length&&(e._runtime=h);const _=Rc(it(e._limits)),b=Ri((E=t.limits)==null?void 0:E.maxIterations,1),C=Ri((A=t.limits)==null?void 0:A.maxTokens,1);b!==void 0&&n&&(_.max_iterations=b),C!==void 0&&n&&(_.max_tokens=C),Object.keys(_).length&&(e._limits=_),r("max_iterations",b),t.gatingMode==="auto"&&r("gating_mode","auto")}function H0(e){var r;const t=Rc(e.schemaInputs),n=Bf(e.workflow);if(e.promptProperty){const i=Re(e.promptProperty);i&&((r=e.prompt)!=null&&r.trim())&&(t[i]=e.prompt)}if(n){const i=e.prompt??"";t.prompt=i;const c=Rc(it(t.context));c.task=i,delete c.messages,delete c.media;const u=(e.attachments??[]).map(d=>({...d}));u.length?c.attachments=u:delete c.attachments,t.use_context=!1,delete t.attachments,delete t.media,t.context=c,t.use_session_history=e.useSessionHistory??!0}return V0(t,e,!0),t}const sg=(e,t,n)=>`${e} ${e===1?t:n}`;function kw(e,t={}){const n=e.updatedAt?new Date(e.updatedAt):null,i=[n&&Number.isFinite(n.getTime())?n.toLocaleDateString(t.locale,{month:"short",day:"numeric",...t.timeZone?{timeZone:t.timeZone}:{}}):"Saved conversation",sg(e.turnCount,"turn","turns")];return typeof e.toolCalls=="number"&&e.toolCalls>0&&i.push(sg(e.toolCalls,"tool","tools")),i.join(" · ")}function jw(e){return e.prompt||`Conversation ${e.sessionId.slice(0,8)}`}function G0(e){const{item:t}=e,n=jw(t);return a.jsxs("div",{className:`code-session-item${e.confirm?" is-confirming":""}`,"data-item-id":t.sessionId,children:[a.jsxs("button",{type:"button",className:`code-session code-card${e.selected?" is-selected":""}`,"aria-current":e.selected?"page":void 0,"data-session-id":t.sessionId,onClick:e.onClick,title:n,children:[a.jsxs("span",{children:[a.jsx("strong",{className:"code-card-title",children:n}),a.jsx("small",{className:"code-card-meta","data-field":"meta",children:kw(t)})]}),t.state==="running"||t.state==="waiting"?a.jsx("span",{className:`code-status-dot ${t.state==="running"?"is-working":"is-waiting"}`,title:t.state}):null]}),e.onAskArchive?a.jsx(Ig,{className:"code-card-menu",label:`More actions for ${n}`,title:"More actions",items:[{id:"archive",label:"Archive",danger:!0,onSelect:e.onAskArchive}]}):null,e.confirm]})}function Sw(e){return e.attention.pending_waits>0}function Nw(){return a.jsx("span",{className:"code-waiting-badge","data-field":"waiting",children:"waiting for you"})}function Cw(e){const t=uo(e.summary,[],e.busy).active;return a.jsx(Mr,{className:`${e.className??""}${e.iconOnly?" code-switch-icon-only":""}`.trim()||void 0,variant:e.variant??"sm",action:"active",label:e.iconOnly?a.jsx("span",{className:"code-visually-hidden",children:"Active"}):"Active",ariaLabel:"Active",checked:e.summary.status==="active",unavailableReason:t.enabled||e.busy?null:t.reason??"Not available now.",reasonVisible:!1,busy:e.busy,hint:e.iconOnly?`Active
|
|
86
|
+
${Oi("active",e.summary)}`:Oi("active",e.summary),onChange:()=>e.onToggle()})}function K0(e,t){const n=xy(e,t);return{first:[n.cadence,n.last].filter(Boolean).join(" · "),second:n.next||"",scheduled:e.trigger.source_id==="schedule"}}function J0(e){const t=e.summary,n=K0(t,e.nowMs),r=Sw(t);return a.jsxs("div",{className:`code-card code-auto-card${e.selected?" is-selected":""}`,"data-automation-id":t.automation_id,"data-status":t.status,children:[a.jsxs("button",{type:"button",className:"code-card-main","aria-current":e.selected?"page":void 0,title:`${t.title}
|
|
87
|
+
${[n.first,n.second].filter(Boolean).join(" · ")}`,onClick:e.onSelect,children:[a.jsx("strong",{className:"code-card-title",children:t.title}),r?a.jsx(Nw,{}):null,a.jsxs("small",{className:"code-card-meta","data-field":"timing",children:[n.scheduled?a.jsx(ne,{name:"refresh",size:12,className:"code-card-cadence-icon"}):null,a.jsx("span",{className:"code-card-part",children:n.first})]})]}),a.jsxs("div",{className:"code-card-line2",children:[a.jsx("small",{className:"code-card-meta","data-field":"next",children:n.second}),a.jsx(Cw,{className:"code-card-switch",iconOnly:!0,summary:t,busy:e.busy,onToggle:e.onToggleActive})]})]})}const Q0="runs?root_only=true&archived_only=true&include_ledger_len=false&include_metrics=true&limit=200",Y0=e=>`sessions/${encodeURIComponent(e)}/archive`,X0=e=>`sessions/${encodeURIComponent(e)}/unarchive`;async function q0(e,t=ct){return t(_e(Y0(e)),{method:"POST",body:"{}"})}function Z0(e,t){const n=e.findIndex(i=>i.sessionId===t),r=e.filter(i=>i.sessionId!==t);return r.length?n<0?r[0]:r[Math.min(n,r.length-1)]:null}function rg(e){const t=e==null?void 0:e.archived_sessions;return typeof t=="number"&&Number.isFinite(t)&&t>0?Math.floor(t):0}function e1(e){const t=e.request??ct,[n,r]=y.useState(null),[i,c]=y.useState(""),[u,d]=y.useState(""),[h,m]=y.useState(null);return y.useEffect(()=>{if(!e.enabled)return;const p=new AbortController;return c(""),t(_e(Q0),{signal:p.signal}).then(async v=>{if(p.signal.aborted)return;const _=Tc(v);r(_);const b={};await Promise.all(_.filter(C=>!C.prompt).slice(0,50).map(async C=>{try{b[C.firstRunId]=await t(_e(`runs/${encodeURIComponent(C.firstRunId)}/input_data`),{signal:p.signal})}catch{}})),!p.signal.aborted&&Object.keys(b).length&&r(Tc(v,b))}).catch(v=>!p.signal.aborted&&c(`Archived conversations unavailable: ${vt(v)}`)),()=>p.abort()},[e.enabled,e.revision]),i?a.jsx("li",{className:"code-inline-error",role:"alert",children:i}):n?a.jsx(a.Fragment,{children:n.map(p=>a.jsx(bw,{id:p.sessionId,title:jw(p),meta:kw(p),busy:u===p.sessionId,error:(h==null?void 0:h.id)===p.sessionId?h.message:void 0,onOpen:()=>e.onOpen(p),onUnarchive:()=>{d(p.sessionId),m(null),t(_e(X0(p.sessionId)),{method:"POST",body:"{}"}).then(()=>{r(v=>(v||[]).filter(_=>_.sessionId!==p.sessionId)),e.onUnarchived(p)}).catch(v=>m({id:p.sessionId,message:`Not unarchived: ${vt(v)}`})).finally(()=>d(""))}},p.sessionId))}):a.jsx("li",{children:a.jsx(ho,{children:"Loading archived conversations…"})})}const Sn=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{},t1=["context","messages","attachments","media"];function n1(e){return t1.includes(e)}function s1(e,t){const n=Sn(t);return Object.fromEntries(Object.keys(Sn(e.properties)).flatMap(r=>["_runtime","_limits"].includes(r)||n1(r)||!Object.prototype.hasOwnProperty.call(n,r)?[]:[[r,structuredClone(n[r])]]))}function ag(e){if(!e)return;const t=Sn(e.input_data_schema||e.input_schema||e.schema||e),n=Object.fromEntries(Object.entries(Sn(t.properties)).map(([r,i])=>[r,{...Sn(i)}]));for(const r of Array.isArray(e.inputs)?e.inputs:[])r!=null&&r.id&&(n[r.id]={...Sn(r.schema),...n[r.id],...r.type?{"x-abstract-type":r.type}:{},...r.label?{title:r.label}:{},...Object.prototype.hasOwnProperty.call(r,"default")?{default:r.default}:{}});for(const[r,i]of Object.entries(Sn(e.defaults)))n[r]={...n[r],default:i};return{...t,properties:n}}function r1(e,t){var m;const n=Sn(t).nodes;if(!Array.isArray(n))throw new Error("The workflow input declarations could not be verified. Please retry.");const r=n.find(p=>{var v;return(((v=p==null?void 0:p.data)==null?void 0:v.nodeType)||(p==null?void 0:p.type))==="on_flow_start"});if(!r||!Array.isArray((m=r.data)==null?void 0:m.outputs))throw new Error("The workflow start inputs could not be verified. Please retry.");const i=r.data.outputs.filter(p=>typeof(p==null?void 0:p.id)=="string"&&p.id&&p.type!=="execution"&&!["exec","exec-out"].includes(p.id)),c=new Set(i.map(p=>p.id)),u=new Set((Array.isArray(e.required)?e.required:[]).filter(p=>!c.has(p))),d={...e.properties},h=Sn(r.data.pinDefaults);for(const p of i)p.required===!0&&u.add(p.id),d[p.id]={...Sn(d[p.id]),...Sn(p.schema),...p.type?{"x-abstract-type":p.type}:{},...p.label?{title:p.label}:{},...Object.prototype.hasOwnProperty.call(h,p.id)?{default:structuredClone(h[p.id])}:{}};return{...e,properties:d,required:[...u]}}function Ks(e){return Object.fromEntries(Object.entries((e==null?void 0:e.properties)||{}).flatMap(([t,n])=>Object.prototype.hasOwnProperty.call(Sn(n),"default")?[[t,structuredClone(Sn(n).default)]]:[]))}function a1(e){const t=Array.isArray(e.type)?e.type.find(r=>r!=="null"):e.type;if(t)return t;const n=e["x-abstract-type"];return["tools","assertions"].includes(n)?"array":["json_schema","memory","assertion"].includes(n)?"object":"string"}function o1(e){const t=(e==null?void 0:e.properties)||{},n=i=>{const c=t[i];return c&&(c.type==="string"||Array.isArray(c.type)&&c.type.includes("string")||!c.type&&c["x-abstract-type"]==="string")},r=Object.keys(t).filter(i=>{var c;return((c=t[i])==null?void 0:c["x-abstract-role"])==="prompt"&&n(i)});return r.length?r.length===1?r[0]:void 0:["prompt","request","task","message","query","input"].find(n)}function Vd(e,t){var i,c,u;if(!e)return[];const n={...Ks(e),...t},r=[];for(const d of Array.isArray(e.required)?e.required:[])n[d]===void 0&&r.push(`${((c=(i=e.properties)==null?void 0:i[d])==null?void 0:c.title)||d} is required.`);for(const[d,h]of Object.entries(n)){const m=(u=e.properties)==null?void 0:u[d];if(!m||h===void 0)continue;const p=m.title||d;Array.isArray(m.enum)&&!m.enum.some(C=>JSON.stringify(C)===JSON.stringify(h))&&r.push(`${p} must be one of the available choices.`);const v=Array.isArray(m.type)?m.type:m.type?[m.type]:[];if(h===null&&(v.includes("null")||!v.length))continue;const _=Array.isArray(h)?"array":h===null?"null":typeof h,b=v.includes(_)?_:_==="number"&&v.includes("integer")?"integer":v[0];(b==="number"||b==="integer")&&(typeof h!="number"||!Number.isFinite(h)||b==="integer"&&!Number.isInteger(h))&&r.push(`${p} must be ${b==="integer"?"a whole number":"a number"}.`),typeof h=="number"&&m.minimum!==void 0&&h<m.minimum&&r.push(`${p} must be at least ${m.minimum}.`),typeof h=="number"&&m.maximum!==void 0&&h>m.maximum&&r.push(`${p} must be at most ${m.maximum}.`),b==="string"&&typeof h!="string"&&r.push(`${p} must be text.`),typeof h=="string"&&m.minLength!==void 0&&h.length<m.minLength&&r.push(`${p} must contain at least ${m.minLength} characters.`),b==="boolean"&&typeof h!="boolean"&&r.push(`${p} must be true or false.`),b==="array"&&!Array.isArray(h)&&r.push(`${p} must be a JSON array.`),b==="object"&&(h===null||typeof h!="object"||Array.isArray(h))&&r.push(`${p} must be a JSON object.`)}return r}function Ew(e){const t=(e==null?void 0:e.properties)||{},n=[];for(const[r,i]of Object.entries(t)){const c=Sn(i);if(!(r==="provider"||r.endsWith("_provider")||String(c["x-abstract-type"]||"").startsWith("provider")))continue;const u=String(c["x-abstract-type"]||""),d=r.replace("provider","model"),h=Object.keys(t).filter(b=>{var C;return((C=t[b])==null?void 0:C["x-abstract-type"])===u.replace(/^provider/,"model")}),m=d!==r&&t[d]?d:h.length===1?h[0]:"";if(!m)continue;const p=r==="provider"?"":r.startsWith("provider_")?r.slice(9):r.endsWith("_provider")?r.slice(0,-9):u.replace(/^provider_?/,""),v=p&&p!=="text"?`${p}_`:"",_=[`${v}reasoning`,`${v}thinking`,`${v}reasoning_effort`,`reasoning_${p}`,`thinking_${p}`].find(b=>t[b]);n.push({provider:r,model:m,reasoning:_,title:v?v.replace(/_/g," ").trim():"Text model"})}return n}const Vf={fetchProviders:async()=>{const e=await Ln.discovery_providers(),t=e.providers||e.items;return Array.isArray(t)?t.map(n=>typeof n=="string"?{name:n}:n):[]},fetchModels:async e=>{const t=await Ln.discovery_provider_models(e),n=t.models||t.items;return Array.isArray(n)?n.map(r=>typeof r=="string"?r:r.id||r.name).filter(Boolean):[]},fetchModelCapabilities:(e,t="")=>Ln.discovery_model_capabilities(e,t)};function i1(e){for(const t of["output.text","input.text"]){const n=(Array.isArray(e==null?void 0:e.routes)?e.routes:[]).find(r=>r.key===t&&r.source!=="not_configured"&&r.provider&&r.model);if(n)return{provider:n.provider,model:n.model}}}function l1(e,t){e.startsWith("provider_")?e=`${e.slice(9)}_provider`:t!=null&&t.startsWith("provider_")&&!e.endsWith("_provider")&&(e=`${t.slice(9)}_provider`);const n={image_provider:"text_to_image",image_edit_provider:"image_to_image",image_upscale_provider:"image_upscale",video_provider:"text_to_video",image_to_video_provider:"image_to_video"}[e];if(!n&&!["music_provider","voice_provider"].includes(e))return Vf;const r=e==="voice_provider",i=_e(n?`vision/provider_models?task=${n}`:r?"audio/speech/models?compact=true":"audio/music/models?task=text_to_music"),c=n?`${i}&providers_only=true`:_e(r?"voice/voices?providers_only=true&compact=true":"audio/music/providers?task=text_to_music"),u=d=>Array.isArray(d)?d.map(h=>typeof h=="string"?h:h.id||h.name).filter(Boolean):[];return{fetchProviders:async()=>{const d=await ct(c);if(d.error)throw new Error(d.error);return u(d.providers||d.available_providers||d.items).map(h=>({name:h}))},fetchModels:async d=>{var m,p,v;const h=await ct(`${i}&provider=${encodeURIComponent(d)}`);if(h.error)throw new Error(h.error);return u(((m=h.models_by_provider)==null?void 0:m[d])||((p=h.tts_models_by_provider)==null?void 0:p[d])||((v=h.music_models_by_provider)==null?void 0:v[d])||h.models||h.items)}}}const c1=["gateway_default","on","off"],$w={status:"loading"};function u1(e,t){if(t)return{status:"unsupported",reason:`the gateway's capabilities could not be read (${t})`};const n=e==null?void 0:e.capabilities,r=n==null?void 0:n.streaming;return!r||typeof r!="object"||r.deltas!==!0?{status:"unsupported",reason:"not supported by this gateway (it does not advertise live replies)"}:{status:"supported",gatewayDefault:typeof r.default=="boolean"?r.default:null}}function d1(e){return c1.includes(e)?e:"gateway_default"}function f1(e,t){return e==="on"&&t.status!=="supported"?"gateway_default":e}function h1(e,t,n){if(e!=="on"||t.status!=="unsupported"||!n.length)return null;const r=n.find(i=>i.role==="user")||n[0];return{after:r.id?String(r.id):null,message:{id:"stream-replies:unsupported",role:"system",level:"info",title:"Stream replies",content:`Streaming is on in your settings but this gateway does not support live replies: ${t.reason}. Replies appear when they are complete.`}}}function m1(e){try{const t=JSON.parse(e);return typeof(t==null?void 0:t.call_id)=="string"&&t.call_id?t.call_id:""}catch{return""}}function p1(e,t){const n=m1(e.frame.data),r=n?`call:${n}`:`error:${e.error.message}`;return{after:t,message:{id:`stream-replies:malformed:${e.runId}:${r}`,role:"system",level:"warn",title:"Live reply",runId:e.runId,content:`The gateway sent a malformed live reply update (${e.frame.event}): ${e.error.message}. It was skipped; the complete reply still arrives.`}}}function g1(e,t){return e.some(n=>n.message.id===t.message.id)?[...e]:[...e,t]}function y1(e,t){const n=t.filter(d=>!!d);if(!n.length)return[...e];const r=[],i=new Set;for(const d of e){r.push(d);for(const h of n)!i.has(h)&&h.after!==null&&String(d.id)===h.after&&(r.push(h.message),i.add(h))}const c=n.filter(d=>!i.has(d)&&d.after===null),u=n.filter(d=>!i.has(d)&&d.after!==null);return[...c.map(d=>d.message),...r,...u.map(d=>d.message)]}function w1(e){return e.status==="supported"&&e.gatewayDefault!==null?`Gateway default (${e.gatewayDefault?"on":"off"})`:"Gateway default"}const Ot="@default",Nn="abstractcode.agent.v1";function Cs(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function kn(e){return typeof e=="string"&&e.trim()?e.trim():void 0}const v1="gateway does not report a default agent workflow";function _1(e,t=Nn){var p,v;const n=Cs(e);if(!n)return{status:"unavailable",reason:"the gateway's workflow list could not be loaded"};const r=Cs(n.default_agent_workflows);if(!r)return{status:"unavailable",reason:v1};const i=Cs(r[t]);if(!i){const _=kn((v=Cs((p=Cs(n.default_agent_workflows_unavailable))==null?void 0:p[t]))==null?void 0:v.reason);return{status:"unavailable",reason:_?`no default workflow for ${t}: ${_}`:`gateway reports no default workflow for ${t}`}}const c=kn(i.bundle_id),u=kn(i.flow_id),d=kn(i.registry_scope);if(!c||!u||!d)return{status:"unavailable",reason:`gateway's default workflow for ${t} is missing its bundle, flow or registry scope`};const h=kn(i.bundle_version);return{status:"ok",workflow:{workflowId:kn(i.workflow_id)??`${c}${h?`@${h}`:""}:${u}`,bundleId:c,...h?{bundleVersion:h}:{},flowId:u,registryScope:d,name:kn(i.name)??u,...kn(i.source)?{source:kn(i.source)}:{}}}}function b1(e){if(e.status==="loading")return"Gateway default (loading…)";if(e.status==="unavailable")return`Gateway default — ${e.reason}`;const{name:t,bundleVersion:n}=e.workflow;return`Gateway default → ${t}${n?` @${n}`:""}`}function x1(e,t,n=Nn){if(e.status!=="ok")return null;const r=e.workflow,i=t.find(c=>(c.registryScope??"private")===r.registryScope&&c.bundleId===r.bundleId&&c.flowId===r.flowId&&(!r.bundleVersion||c.bundleVersion===r.bundleVersion));return i||{id:`${r.registryScope}:${r.workflowId}`,workflowId:r.workflowId,bundleId:r.bundleId,...r.bundleVersion?{bundleVersion:r.bundleVersion}:{},flowId:r.flowId,name:r.name,description:"",interfaces:[n],registryScope:r.registryScope}}function Hd(e,t=Nn){if(!e||e.interfaces.includes(t))return"";const n=e.interfaces.length?e.interfaces.join(", "):"no interface";return`The gateway default ${e.name} does not declare ${t} (it declares ${n}); it will not run as a coding agent here.`}function k1(e){return((e==null?void 0:e.entries)??[]).map(t=>({id:`${t.registryScope}:${t.value}`,workflowId:t.value,bundleId:t.bundleId,...t.bundleVersion?{bundleVersion:t.bundleVersion}:{},flowId:t.flowId,name:t.name,description:t.description,interfaces:t.interfaces,registryScope:t.registryScope}))}function j1(e,t){return e===Ot?Bc:(t==null?void 0:t.workflowId)??e}function S1(e,t){return e===Bc||!t?Ot:`${t.registryScope}:${t.value}`}function N1(e){const t=n=>n===Ot||e.visible.some(r=>r.id===n)||!!e.runId&&e.workflows.some(r=>r.id===n);return e.selection&&t(e.selection)?e.selection:e.preferred&&t(e.preferred)?e.preferred:Ot}function Hf(e){var n,r;const t=Cs((r=Cs((n=Cs(e))==null?void 0:n.input_data))==null?void 0:r.workflow_selection);return kn(t==null?void 0:t.source)}function C1(e){var t;return Hf(e.restoredInputs)==="gateway_default"?Ot:(t=e.restored)==null?void 0:t.id}function E1(e){return!Cs(e)||Hf(e)?"":"This gateway does not record whether this conversation used the gateway default workflow; its next turn uses the workflow its last run used."}function $1(e){return e.selection===Ot?{flow_id:Ot,interface:e.interfaceId??Nn,session_id:e.sessionId,input_data:e.input}:{bundle_id:e.workflow.bundleId,bundle_version:e.workflow.bundleVersion,registry_scope:e.workflow.registryScope,flow_id:e.workflow.flowId,session_id:e.sessionId,input_data:e.input}}function A1(e){const t=Cs(e);if(!t)return{text:"the gateway did not report which workflow it started",missing:!0};const n=kn(t.name)??kn(t.workflow_id)??kn(t.flow_id)??"unnamed workflow",r=kn(t.bundle_version);return{text:`running ${n}${r?` @${r}`:""}${t.source==="gateway_default"?" (gateway default)":""}`,missing:!1}}const Gd=25,T1=4,R1=e=>`runs?root_only=true&include_ledger_len=false&include_metrics=true&limit=${e}`;function I1(e){const t=(e==null?void 0:e.items)??(e==null?void 0:e.runs);return Array.isArray(t)?t.length:0}async function M1(e,t){let n=Math.max(1,t)*T1;for(;;){const r=await e(n);if((r==null?void 0:r.has_more)!==!0||I1(r)<n||Tc(r).length>t)return r;n*=2}}function L1(e,t){return{sessions:e.slice(0,t),hasMore:e.length>t}}const Kd={gatewayDefault:{status:"loading"},executable:{status:"idle",data:null,error:""},workflows:[],policy:null,tools:[],sessions:[],capabilities:{},capabilitiesLoading:!0,streaming:$w,loading:!1,sessionsLoaded:!1,errors:[],hasMore:!1,archivedSessions:0};function O1(e){var n;const t=((n=e==null?void 0:e.capabilities)==null?void 0:n.contracts)??(e==null?void 0:e.contracts)??e;return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function P1(e,t){const[n,r]=y.useState(Kd),i=y.useRef(Gd),c=y.useRef(0),u=y.useRef(),d=y.useRef(0),h=y.useRef(),m=y.useRef({identity:"",values:{}}),p=y.useCallback(N=>M1($=>ct(_e(R1($)),{signal:N}),i.current),[]),v=N=>L1(Tc(N,m.current.values),i.current),_=y.useCallback(async(N,$,S)=>{const E=()=>d.current!==$||S.aborted,A=v(N).sessions.filter(R=>!R.prompt&&!(R.firstRunId in m.current.values));for(let R=0;R<A.length;R+=4){if(E()||(await Promise.all(A.slice(R,R+4).map(async z=>{try{const L=await ct(_e(`runs/${encodeURIComponent(z.firstRunId)}/input_data`),{signal:S});E()||(m.current.values[z.firstRunId]=L)}catch(L){!S.aborted&&(L==null?void 0:L.status)===401&&t()}})),E()))return;r(z=>({...z,sessions:v(N).sessions}))}},[t]),b=y.useCallback(async()=>{var S;if(!e)return;const N=++d.current;(S=h.current)==null||S.abort();const $=new AbortController;h.current=$,r(E=>({...E,loading:!0}));try{const E=await p($.signal);if(d.current!==N)return;const A=v(E);r(R=>({...R,loading:!1,sessions:A.sessions,sessionsLoaded:!0,hasMore:A.hasMore,archivedSessions:rg(E),errors:R.errors.filter(z=>!z.startsWith("Conversations: "))})),await _(E,N,$.signal)}catch(E){if($.signal.aborted||d.current!==N)return;(E==null?void 0:E.status)===401&&t(),r(A=>({...A,loading:!1,errors:[...A.errors.filter(R=>!R.startsWith("Conversations: ")),`Conversations: ${vt(E)}`]}))}},[e,p,_,t]),C=y.useCallback(async()=>{var O,ee;const N=++c.current,$=++d.current;(O=h.current)==null||O.abort(),(ee=u.current)==null||ee.abort();const S=new AbortController;if(u.current=S,m.current.identity!==e&&(m.current={identity:e,values:{}}),!e){r(Kd);return}r(P=>({...P,loading:!0,capabilitiesLoading:!0,errors:[],executable:{...P.executable,status:"loading",error:""}}));const E=P=>ct(_e(P),{signal:S.signal}),A=await Promise.allSettled([E("bundles?all_versions=true&include_drafts=false"),E("workspace/policy"),E("discovery/tools"),p(S.signal),E("discovery/capabilities"),E("workflow-catalog?scope=tenant"),E("config/capability-defaults"),E(hy(Nn))]);if(c.current!==N)return;const R=P=>A[P].status==="fulfilled"?A[P].value:void 0,z=[];A.forEach((P,Z)=>{var U,te;P.status==="rejected"&&(((U=P.reason)==null?void 0:U.status)===401&&t(),!(Z===5&&[403,404,501].includes((te=P.reason)==null?void 0:te.status))&&Z!==7&&z.push(`${["Workflows","Workspace policy","Tools","Conversations","Capabilities","Shared workflows","Gateway defaults"][Z]}: ${vt(P.reason)}`))});const L=d.current===$,J=v(R(3));let V;if(A[7].status==="rejected")V={status:"error",data:null,error:`Workflows for this app: ${vt(A[7].reason)}`};else try{V={status:"ready",data:Ex(R(7),Nn),error:""}}catch(P){V={status:"error",data:null,error:String((P==null?void 0:P.message)||P)}}r(P=>({executable:V,workflows:D0(R(0),R(5)),policy:R(1)?U0(R(1)):null,tools:B0(R(2)),sessions:L&&R(3)?J.sessions:P.sessions,sessionsLoaded:P.sessionsLoaded||!!(L&&R(3)),capabilities:O1(R(4)),capabilitiesLoading:!1,streaming:u1(R(4),A[4].status==="rejected"?vt(A[4].reason):void 0),defaultModel:i1(R(6)),gatewayDefault:_1(R(0)),loading:!1,errors:z,hasMore:L&&R(3)?J.hasMore:P.hasMore,archivedSessions:L&&R(3)?rg(R(3)):P.archivedSessions})),L&&R(3)&&await _(R(3),$,S.signal)},[e,t,p,_]);y.useEffect(()=>(i.current=Gd,r(Kd),C(),()=>{var N,$;c.current+=1,d.current+=1,(N=u.current)==null||N.abort(),($=h.current)==null||$.abort()}),[C]);const x=y.useCallback(()=>{i.current+=Gd,b()},[b]),j=y.useCallback(N=>{r($=>({...$,sessions:$.sessions.filter(S=>S.sessionId!==N),archivedSessions:$.archivedSessions+1})),b()},[b]);return{...n,refresh:C,loadMore:x,forgetSession:j}}async function Jd(e){if(e.inputSchema)return ag(e.inputSchema);if(!e.bundleId)return;const t=encodeURIComponent(e.bundleId),n=encodeURIComponent(e.flowId),r=e.registryScope==="tenant_catalog"&&e.bundleVersion?_e(`workflow-catalog/${t}/versions/${encodeURIComponent(e.bundleVersion)}/flows/${n}/input_schema?scope=tenant`):_e(`bundles/${t}/flows/${n}/input_schema${e.bundleVersion?`?bundle_version=${encodeURIComponent(e.bundleVersion)}`:""}`),i=await ct(r),c=ag(i);if(!c||i!=null&&i.native_loop_factory||(i==null?void 0:i.version)!==1||!Array.isArray(i==null?void 0:i.inputs)||!(i!=null&&i.input_data_schema)||!Array.isArray(c.required)||!c.required.length)return c;const u=e.bundleVersion||i.bundle_version;if(!u)throw new Error("The Gateway did not identify the workflow version. Refresh workflows and retry.");const d={bundle_id:e.bundleId,bundle_version:u,flow_id:e.flowId},h=v=>{for(const[_,b]of Object.entries(d))if((v==null?void 0:v[_])!==b)throw new Error("The Gateway returned inputs for a different workflow version. Refresh workflows and retry.");if(e.registryScope==="tenant_catalog"&&(v==null?void 0:v.registry_scope)!=="tenant_catalog")throw new Error("The Gateway returned inputs from a different workflow registry. Refresh workflows and retry.")};h(i);const m=e.registryScope==="tenant_catalog"?_e(`workflow-catalog/${t}/versions/${encodeURIComponent(u)}/flows/${n}?scope=tenant`):_e(`bundles/${t}/flows/${n}?bundle_version=${encodeURIComponent(u)}`),p=await ct(m);return h(p),r1(c,p.flow)}const Qd=e=>_e(`runs/${encodeURIComponent(e)}`);function D1(e){return{getRun:(t,n)=>ct(Qd(t),{signal:n}),getHistory:(t,n)=>ct(`${Qd(t)}/history_bundle?include_subruns=true&include_session=true&ledger_mode=full`,{signal:n}),getLedger:(t,n,r)=>ct(`${Qd(t)}/ledger?after=${n}&limit=200`,{signal:r}),streamLedger:(t,n,r,i,c,u)=>Ln.stream_ledger(t,{after:n,on_step:r,signal:i,on_open:c,on_delta:u,on_delta_error:(d,h)=>e.onDeltaError({runId:t,error:d,frame:h})}),submitCommand:(t,n)=>ct(_e("commands"),{method:"POST",body:JSON.stringify(t),signal:n})}}function Ss(e){return typeof e=="string"?e.trim():""}function F1(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},r=(Array.isArray(t.skills)?t.skills:[]).flatMap(d=>{const h=d&&typeof d=="object"&&!Array.isArray(d)?d:null,m=Ss(h==null?void 0:h.name);if(!h||!m)return[];const p=h.source&&typeof h.source=="object"&&!Array.isArray(h.source)?h.source:void 0;return[{name:m,description:Ss(h.description),trustLevel:Ss(h.trust_level)||"unverified",blocked:h.blocked===!0,requiresReview:h.requires_review===!0,reasons:Array.isArray(h.reasons)?h.reasons.map(Ss).filter(Boolean):[],source:p?{source:Ss(p.source),binding:Ss(p.binding),ambiguous:p.ambiguous===!0}:void 0}]}),i=Array.isArray(t.warnings)?t.warnings.map(Ss).filter(Boolean):[],c=Ss(t.shelf),u=Ss(t.shelf_source);return{skills:r.sort((d,h)=>d.name.localeCompare(h.name)),warnings:i,...c?{shelf:c}:{},...u?{shelfSource:u}:{}}}function z1({inventory:e}){return a.jsxs("div",{className:"code-skills-empty",role:"status",children:[a.jsx("p",{children:a.jsx("strong",{children:"This gateway offers no skills."})}),e.warnings.length?e.warnings.map((t,n)=>a.jsx("p",{children:e.shelf?t:`The gateway has no skill shelf: ${t}`},`${t}:${n}`)):a.jsx("p",{children:"The gateway gave no reason for the empty list."}),e.shelf?a.jsxs("p",{className:"code-field-help",children:["Skill shelf: ",a.jsx("code",{children:e.shelf}),e.shelfSource?` (source: ${e.shelfSource})`:""]}):a.jsx("p",{className:"code-field-help",children:"The gateway did not report a skill shelf location."})]})}function U1(e){var r;const t=e.trustLevel.replace(/[_-]+/g," "),n=(r=e.source)!=null&&r.source?`Adopted from ${e.source.source}`:"Source has no adoption record";return`Trust: ${t}. ${n}${e.requiresReview?". Review required":""}.`}function B1({skill:e,checked:t,disabled:n,onChange:r,lockedReasonId:i}){const c=e.reasons.join(" ")||"Blocked by gateway policy.",u=e.blocked?`Blocked by the gateway: ${c}`:n?"Available when a gateway is connected and no run is in progress.":null;return a.jsx("div",{className:"code-field code-skill-row",children:a.jsx(Mr,{variant:"row",action:"skill",label:e.name,description:a.jsxs(a.Fragment,{children:[e.description?a.jsx("span",{className:"code-skill-row__desc",children:e.description}):null,a.jsx("span",{className:"code-skill-row__trust",children:U1(e)})]}),checked:t,unavailableReason:u,describedBy:!e.blocked&&n?i:void 0,onChange:r})})}function W1({value:e,onChange:t,disabled:n,lockedReasonId:r}){const[i,c]=y.useState({skills:[],warnings:[]}),[u,d]=y.useState(""),[h,m]=y.useState(!0),[p,v]=y.useState(""),[_,b]=y.useState(0);y.useEffect(()=>{const N=new AbortController;return m(!0),v(""),ct(_e("skills"),{signal:N.signal}).then($=>{N.signal.aborted||c(F1($))}).catch($=>{N.signal.aborted||v(vt($))}).finally(()=>{N.signal.aborted||m(!1)}),()=>N.abort()},[_]);const C=y.useMemo(()=>new Set(e.map(Ss).filter(Boolean)),[e]),x=y.useMemo(()=>{const N=u.trim().toLocaleLowerCase();return N?i.skills.filter($=>`${$.name}
|
|
88
|
+
${$.description}
|
|
89
|
+
${$.trustLevel}`.toLocaleLowerCase().includes(N)):i.skills},[i.skills,u]),j=(N,$)=>{const S=$?[...C,N]:[...C].filter(E=>E!==N);t([...new Set(S)])};return a.jsxs("section",{className:"code-settings-section","aria-labelledby":"code-skills-heading",children:[a.jsx("h3",{id:"code-skills-heading",children:"Skills"}),a.jsx("p",{className:"code-muted",children:"Choose curated guidance for the next turn. The gateway evaluates trust and requirements when the run starts; this browser does not load or execute skill scripts."}),a.jsxs("label",{className:"code-field",children:["Find a skill",a.jsx("input",{type:"search",value:u,onChange:N=>d(N.target.value),disabled:n||h,placeholder:"Search names, descriptions, or trust"})]}),h?a.jsx("p",{className:"code-muted",role:"status",children:"Loading skills from the gateway…"}):null,p?a.jsxs("div",{className:"code-inline-error",role:"alert",children:["Skill selection is unavailable: ",p," ",a.jsx("button",{className:"code-text-button",type:"button",onClick:()=>b(N=>N+1),disabled:n,children:"Retry"})]}):null,i.warnings.length&&i.skills.length?a.jsxs("details",{className:"code-disabled-tools",children:[a.jsxs("summary",{children:["Gateway reported ",i.warnings.length," skills warning",i.warnings.length===1?"":"s"]}),i.warnings.map((N,$)=>a.jsx("p",{children:N},`${N}:${$}`))]}):null,!h&&!p&&!i.skills.length?a.jsx(z1,{inventory:i}):null,!h&&!p&&i.skills.length&&!x.length?a.jsx("p",{className:"code-muted",children:"No skills match your search."}):null,x.map(N=>a.jsx(B1,{skill:N,checked:C.has(N.name),disabled:n,lockedReasonId:r,onChange:$=>j(N.name,$)},N.name))]})}function Aw(e,t,n="default"){const r=e.filter(c=>c.enabled&&!c.servedDisabled&&(t.mode==="all"||t.selected.includes(c.name))),i=c=>{const u=t.approval[c.name];if(u==="ask")return!1;if(u==="approve"||n==="all")return!0;const d=["auto","approve"].includes((c.approval||"").trim().toLowerCase());if(n==="default")return d;const h=d?1:["write_file","edit_file"].includes(c.name)?2:3,m=c.riskRank===void 0||c.riskRank===1?1:c.riskRank===2?2:3;return Math.max(h,m)<=(n==="write"?2:1)};return{enabledTools:r.map(c=>c.name),autoApproveTools:r.filter(i).map(c=>c.name),requireApprovalTools:r.filter(c=>!i(c)).map(c=>c.name)}}function V1(e,t){if(!Array.isArray(t))return e;const n=r=>t.includes(r);return{enabledTools:e.enabledTools.filter(n),autoApproveTools:e.autoApproveTools.filter(n),requireApprovalTools:e.requireApprovalTools.filter(n)}}const H1="code-settings-locked",cs={provider:"",model:"",reasoning:"",maxIterations:"",maxTokens:"",system:"",workspace:null,tools:{mode:"all",selected:[],approval:{}},toolsCustomized:!1,permissions:"default",skills:[],workflow:"@default",streamReplies:"gateway_default"};function G1({tab:e,value:t,onChange:n,tools:r,disabled:i,defaultModel:c,workflowDefault:u,streaming:d=$w,lockedReasonId:h=H1,workspaceRootFixed:m,hideStreamReplies:p,lockedText:v,connected:_=!1,automationFolders:b=!1,workspaceRequest:C,sessionId:x,onOpenDefaultWorkspaces:j,workspaceRefreshKey:N}){const $=S=>n({...t,...S});return a.jsxs(a.Fragment,{children:[i?a.jsx("p",{className:"code-notice",id:h,children:v||"Settings are unavailable while disconnected or while a run is active. Reconnect, or finish or stop the run, then try again."}):null,e==="model"?a.jsxs(a.Fragment,{children:[a.jsx("section",{className:"code-settings-section","aria-label":"Model",children:a.jsx(Pc,{defaultModeLabel:u?"Workflow default":"Gateway default",value:t,onChange:$,disabled:i,effectiveDefault:c,fetchModelCapabilities:Vf.fetchModelCapabilities,enableSpeculation:!0,inheritLabel:"Gateway default",defaultHint:c?`${u?"Workflow":"Gateway"} default: ${c.provider} · ${c.model}.`:void 0,fetchProviders:async()=>{const S=await Ln.discovery_providers();return Array.isArray(S.providers)?S.providers:Array.isArray(S.items)?S.items:[]},fetchModels:async S=>{const E=await Ln.discovery_provider_models(S);return(Array.isArray(E.models)?E.models:Array.isArray(E.items)?E.items:[]).map(A=>typeof A=="string"?A:A.id||A.name)}})}),a.jsxs("section",{className:"code-settings-section",children:[a.jsx("h3",{children:"Behavior"}),a.jsxs("div",{className:"code-field-pair",children:[a.jsxs("label",{className:"code-field",children:["Iteration limit",a.jsx("input",{type:"number",min:1,step:1,placeholder:"Workflow default",value:t.maxIterations,disabled:i,onChange:S=>$({maxIterations:S.target.value})})]}),a.jsxs("label",{className:"code-field",children:["Context token limit",a.jsx("input",{type:"number",min:1,step:1,placeholder:"Gateway default",value:t.maxTokens,disabled:i,onChange:S=>$({maxTokens:S.target.value})})]})]}),a.jsxs("label",{className:"code-field",children:["Additional instructions",a.jsx("textarea",{rows:5,value:t.system,placeholder:"Project conventions or guidance for this conversation…",disabled:i,onChange:S=>$({system:S.target.value})})]}),a.jsx("p",{className:"code-field-help",children:"Reasoning and additional instructions depend on the selected workflow and model."}),p?null:a.jsx(K1,{value:t.streamReplies,onChange:S=>$({streamReplies:S}),disabled:i,streaming:d})]})]}):e==="workspace"?a.jsxs("section",{className:"code-settings-section",children:[m?a.jsxs("p",{className:"code-field-help","data-setting":"workspace-root-fixed",children:["Runs work in the automation workspace ",a.jsx("code",{title:m,children:m.split(/[\\/]/).filter(Boolean).pop()||m}),"."]}):null,a.jsx(gw,{connected:_,request:C,sessionId:x,onOpenDefaults:j,refreshKey:N,automation:b?{value:t.workspace,onChange:S=>$({workspace:S})}:void 0})]}):e==="tools"?a.jsxs("section",{className:"code-settings-section",children:[a.jsxs("label",{className:"code-field",children:["Permissions",a.jsxs("select",{"aria-label":"Permissions",value:t.permissions,disabled:i,onChange:S=>$({permissions:S.target.value}),children:[a.jsx("option",{value:"default",children:"Gateway default"}),a.jsx("option",{value:"read",children:"Read"}),a.jsx("option",{value:"write",children:"Write"}),a.jsx("option",{value:"all",children:"All enabled tools"})]})]}),a.jsx("p",{className:"code-field-help",children:"Saved for this Gateway account and future turns. Permissions never enable an unchecked tool. Explicit Ask overrides still ask, even with permissions: all."}),a.jsx(U_,{tools:r.filter(S=>S.enabled).map(S=>({...S,...S.sandboxState?{state:S.sandboxState}:{},default_approval:Aw(r,t.tools,t.permissions).autoApproveTools.includes(S.name)?"approve":"ask"})),value:t.tools,onChange:S=>$({tools:S,toolsCustomized:!0}),disabled:i,subtitle:"Choose available tools and when they should ask you. Gateway restrictions always apply.",note:"An empty custom selection disables every tool. Approvals follow the permissions level and each tool's override."}),r.some(S=>!S.enabled)?a.jsxs("details",{className:"code-disabled-tools",children:[a.jsxs("summary",{children:[r.filter(S=>!S.enabled).length," tools unavailable under gateway policy"]}),r.filter(S=>!S.enabled).map(S=>a.jsxs("p",{children:[a.jsx("strong",{children:S.name}),a.jsx("br",{}),S.whyDisabled||"Disabled by the gateway"]},S.name))]}):null,a.jsx("button",{className:"code-text-button",disabled:i,onClick:()=>$({toolsCustomized:!1,tools:cs.tools,permissions:"default"}),children:"Use gateway default"})]}):a.jsx(W1,{value:t.skills,onChange:S=>$({skills:S}),disabled:i,lockedReasonId:h})]})}function K1({value:e,onChange:t,disabled:n,streaming:r}){const i=r.status!=="supported",c=r.status==="unsupported"?`Unavailable: ${r.reason}. Replies appear when they are complete.`:r.status==="loading"?"Checking whether this gateway supports live replies…":"Show the reply while the model writes it. The complete reply replaces the live text when the model call ends.";return a.jsxs(a.Fragment,{children:[a.jsxs("label",{className:"code-field",children:["Stream replies",a.jsxs("select",{"aria-label":"Stream replies","aria-describedby":"code-stream-replies-help",value:e,disabled:n||i,onChange:u=>t(u.target.value),children:[a.jsx("option",{value:"gateway_default",children:w1(r)}),a.jsx("option",{value:"on",children:"On"}),a.jsx("option",{value:"off",children:"Off"})]})]}),a.jsx("p",{id:"code-stream-replies-help",className:"code-field-help","data-streaming":r.status,children:c})]})}function Tw(e){return`abstractcode.workspace.v2:${e}`}function J1(e){try{const{showAllWorkflows:t,...n}=JSON.parse(e||"{}"),r=typeof n.workflow=="string"&&n.workflow.trim()?n.workflow.trim():cs.workflow;return{...cs,...n,workflow:r,speculation:Ag(n.speculation),streamReplies:d1(n.streamReplies),tools:{...cs.tools,...n.tools}}}catch{return cs}}function Rw(e){try{return J1(localStorage.getItem(Tw(e)))}catch{return cs}}function Q1(e,t){const{workflow:n,...r}=t,i=n&&n!=="@default"?t:r;try{localStorage.setItem(Tw(e),JSON.stringify(i))}catch{}}const kf=_e("accounts/me/preferences");function vi(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function jf(e,t=Nn){var i;const n=vi(e);if(!n||!Array.isArray(n.apps)||!vi((i=vi(n.preferences))==null?void 0:i.default_workflow))throw new Error("The gateway's account preferences answer has no apps or default_workflow.");const r=n.apps.map(vi).find(c=>(c==null?void 0:c.interface)===t);if(!r)throw new Error(`The gateway's account preferences have no row for ${t}.`);if(typeof r.gateway_default_label!="string"||!Array.isArray(r.choices))throw new Error(`The gateway's account preferences row for ${t} has no gateway_default_label or choices.`);return{interface:t,value:typeof r.value=="string"&&r.value.trim()?r.value:null,state:typeof r.state=="string"?r.state:"default",reason:typeof r.reason=="string"&&r.reason?r.reason:null,gatewayDefaultLabel:r.gateway_default_label,choices:r.choices.map(vi).filter(Boolean).map(c=>({value:String(c.value),label:String(c.label??c.name??c.value),workflowId:String(c.workflow_id??"")}))}}function Y1(e){const t=String(e||"").trim();if(!t||t===Ot)return null;const n=t.startsWith("tenant_catalog:")?"catalog":t.startsWith("private:")?"private":"",r=n?t.slice(t.indexOf(":")+1):t,i=r.indexOf(":");if(i<=0)return null;const c=r.slice(0,i).split("@")[0],u=r.slice(i+1);return!c||!u?null:n==="catalog"?`catalog:${c}:${u}`:`${c}:${u}`}function X1(e,t){if(!e)return Ot;const n=e.startsWith("catalog:"),r=n?e.slice(8):e,i=r.indexOf(":");if(i<=0)return Ot;const c=r.slice(0,i),u=r.slice(i+1),d=t.find(h=>h.bundleId===c&&h.flowId===u&&(h.registryScope??"private")==="private"!==n);return d?d.id:Ot}function q1(e){return e instanceof Error?e.message:String(e)}function og(e){const t=e;return typeof(t==null?void 0:t.status)=="number"?t.status:0}async function Z1(e,t,n){let r;try{r=jf(await e(kf))}catch(i){return og(i)===404?{status:"unsupported"}:{status:"error",message:q1(i)}}if(t&&t!==Ot){let i=!0;if(r.value===null){const c=Y1(t);if(c)try{r=jf(await e(kf,{method:"PUT",body:JSON.stringify({default_workflow:{[Nn]:c}})}))}catch(u){i=og(u)===400}}i&&n()}return{status:"ok",row:r}}function eN(e,t){const[n,r]=y.useState({status:"loading"}),i=y.useRef(t);i.current=t,y.useEffect(()=>{let u=!0;if(r({status:"loading"}),!!e)return Z1(ct,Rw(e).workflow,()=>{u&&i.current()}).then(d=>{u&&r(d)}),()=>{u=!1}},[e]);const c=y.useCallback(async u=>{const d=jf(await ct(kf,{method:"PUT",body:JSON.stringify({default_workflow:{[Nn]:u}})}));return r({status:"ok",row:d}),d},[]);return{state:n,save:c}}function tN(e){const{row:t}=e,[n,r]=y.useState(!1),[i,c]=y.useState(null),u=t.value??"",d=t.choices.some(h=>h.value===u);return a.jsxs("div",{className:"code-account-workflow","data-account-workflow":!0,children:[a.jsxs("label",{className:"code-field",children:["Default for new conversations",a.jsxs("select",{"aria-label":"Default for new conversations",value:u,disabled:e.disabled||n,"aria-busy":n||void 0,onChange:async h=>{const m=h.target.value||null;r(!0),c(null);try{await e.save(m),c({ok:!0,text:"Saved."})}catch(p){c({ok:!1,text:`Not saved. ${p instanceof Error?p.message:String(p)}`})}finally{r(!1)}},children:[a.jsx("option",{value:"",children:t.gatewayDefaultLabel}),u&&!d?a.jsx("option",{value:u,children:`${u} (no longer runs)`}):null,t.choices.map(h=>a.jsx("option",{value:h.value,title:h.workflowId||void 0,children:h.label},h.value))]})]}),t.state==="broken"&&t.reason?a.jsx("p",{className:"code-field-help code-workflow-resolved is-missing",role:"alert","data-account-workflow-reason":!0,children:t.reason}):a.jsx("p",{className:"code-field-help",children:"Kept by the gateway for your account: the Assistant and every browser use the same choice. This conversation's workflow is picked above."}),i?a.jsx("p",{className:`code-field-help${i.ok?"":" is-error"}`,role:"status","data-account-workflow-note":!0,children:i.text}):null]})}const ig=Dc("voice and camera")??"Voice and camera are not supported in this browser (getUserMedia unavailable).";function nN(){var t;const e=globalThis.navigator;return typeof((t=e==null?void 0:e.mediaDevices)==null?void 0:t.getUserMedia)=="function"}function sN(e){var i;const t=globalThis.document;if(!t||!t.body||typeof t.execCommand!="function")return!1;const n=t.createElement("textarea");n.value=e,n.setAttribute("readonly",""),n.style.position="fixed",n.style.top="0",n.style.left="-9999px",n.style.opacity="0";const r=t.activeElement;t.body.appendChild(n);try{return n.select(),n.setSelectionRange(0,e.length),t.execCommand("copy")===!0}catch{return!1}finally{t.body.removeChild(n);try{(i=r==null?void 0:r.focus)==null||i.call(r)}catch{}}}async function rN(e){var r;const t=String(e??""),n=globalThis.navigator;if(typeof((r=n==null?void 0:n.clipboard)==null?void 0:r.writeText)=="function")try{return await n.clipboard.writeText(t),!0}catch{}return sN(t)}async function Gf(e){const t=String(e??"");return t?rN(t):!1}const aN=3,lg=["KB","MB","GB","TB"];function Ii(e){const t=Math.max(0,Number(e)||0);if(t<1024)return`${t} B`;let n=t/1024,r=0;for(;n>=1024&&r<lg.length-1;)n/=1024,r+=1;return`${n<10?Math.round(n*10)/10:Math.round(n)} ${lg[r]}`}function cg(e){return`${Math.round(e).toLocaleString("en-US")} bytes`}function Iw(e,t){if(!t||!(t>0)||e.size<=t)return null;let n=Ii(e.size),r=Ii(t);return n===r&&(n=cg(e.size),r=cg(t)),`${e.name||"This file"} is ${n}; the gateway accepts files up to ${r}.`}function oN(e){return`Upload failed: ${String(e||"").replace(/^attachments_upload failed:?\s*/i,"").trim()||"the gateway did not say why"}`}function iN(e,t,n){return e.map(r=>{const i=Iw(r,t);return{id:n(),file:r,name:r.name||"Untitled file",size:r.size,status:i?"refused":"queued",...i?{message:i}:{}}})}async function lN(e,t,n){let r=0;const i=Array.from({length:Math.max(1,Math.min(Math.floor(t)||1,e.length))},async()=>{for(;r<e.length;){const c=e[r];r+=1,await n(c)}});await Promise.all(i)}function Ic(e){return`${e} ${e===1?"file":"files"}`}function ug(e,t){const n=[];return e&&n.push(`${Ic(e)} attached`),t&&n.push(`${Ic(t)} could not be attached`),n.join(", ")}function cN(e){const t=e.filter(i=>i.status==="queued"||i.status==="uploading").length;if(t)return`Wait for ${Ic(t)} to finish uploading.`;const n=e.filter(i=>i.status==="failed"||i.status==="refused");if(!n.length)return null;const r=n.some(i=>i.status==="failed");return n.length===1?`"${n[0].name}" was not attached. ${r?"Retry or remove":"Remove"} it before sending.`:`${Ic(n.length)} were not attached. ${r?"Retry or remove":"Remove"} them before sending.`}const uN=e=>_e(`runs/${encodeURIComponent(e)}/workspace`),Mc=(e,t)=>fetch(e,{...t,credentials:"same-origin"});async function Mw(e){await ct(`${uN(e)}/open`,{method:"POST"})}function dg(e,t){return typeof e.size_bytes!="number"?null:Iw({name:e.name,size:e.size_bytes},t)}function dN(e,t){return t?t.status==="refused"?`Not attached: ${t.message||"refused by the gateway's attachment policy"}`:`${e} is uploading; its chip in the message box shows when it is attached.`:`${e} was not queued for upload.`}async function fN(e,t,n,r){const i=dg(t,n);if(i)return`Not attached: ${i}`;const c=new AbortController,u=await fetch(rw(e,t.path),{credentials:"same-origin",signal:c.signal});if(!u.ok)throw new Error(`Could not read ${t.name} (${u.status}): ${await u.text()}`);const d=dg({...t,size_bytes:tw(u)},n);if(d)return c.abort(),`Not attached: ${d}`;const h=await u.blob(),[m]=r([new File([h],t.name,{type:h.type})]);return dN(t.name,m)}function hN({runId:e,enabled:t,refreshKey:n,maxAttachmentBytes:r,onAttachFiles:i,heading:c="Conversation files"}){const[u,d]=y.useState(""),[h,m]=y.useState("");return e?a.jsxs(a.Fragment,{children:[u?a.jsx("p",{className:"code-field-help",role:"status",children:u}):null,t?a.jsx(zf,{fetchGateway:Mc,runId:e,title:c,refreshKey:n,className:"code-workspace-browser",copyText:Gf,onOpenFolder:()=>Mw(e),fileActions:p=>a.jsx("button",{type:"button",className:"af-file-viewer__icon-btn","data-action":"attach-file",title:"Attach to the next message","aria-label":`Attach ${p.name} to the next message`,disabled:h===p.path,onClick:()=>{m(p.path),d(""),fN(e,p,r,i).then(d).catch(v=>d(vt(v))).finally(()=>m(""))},children:a.jsx(ne,{name:h===p.path?"loader":"paperclip",size:15})})},e):null]}):a.jsxs("div",{className:"code-pane-empty",children:[a.jsx(ne,{name:"folder",size:28}),a.jsx("p",{children:"This conversation's files appear here."}),a.jsx("small",{children:"Start a conversation; the files its workflow creates and edits are listed and previewed here."})]})}const mN=new Set(["abstract.progress","abstractcode.progress"]);function so(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function ia(e){const t=typeof e=="number"?e:Number(e);return Number.isFinite(t)?t:null}function pN(e){if(!so(e))return null;const t=so(e.effect)?e.effect:null;if(!t||String(t.type||"")!=="emit_event")return null;const n=so(t.payload)?t.payload:null,r=String((n==null?void 0:n.name)??(n==null?void 0:n.event_name)??"").trim();if(!mN.has(r))return null;const i=so(e.result)?e.result:null,c=so(i==null?void 0:i.payload)?i==null?void 0:i.payload:null,u=so(n==null?void 0:n.payload)?n==null?void 0:n.payload:null,d=c||u;if(!d||String(d.kind||"")!=="llm")return null;const h=String(d.phase||"").trim();return h!=="prefill"&&h!=="generate"&&h!=="complete"?null:d}function gN(e){let t=null;for(const n of e||[]){const r=pN(n);r&&(t=r)}return!t||t.phase==="complete"||t.final===!0?null:t}function lo(e){return Math.round(e).toLocaleString()}function Lw(e){if(!e||e.phase!=="prefill")return null;const t=ia(e.prompt_tokens),n=ia(e.prefill_processed_tokens);if(t===null||t<=0||n===null||n<0)return null;const r=Math.min(n,t),i=Math.min(99,Math.round(r/t*100));return{processed:r,total:t,percent:i}}function Ow(e){return`${lo(e.processed)} / ${lo(e.total)} tokens (${e.percent}%)`}function yN(e){if(!e)return"";if(e.phase==="prefill"){const t=Lw(e);if(t)return`Prefill · ${Ow(t)}`;const n=ia(e.prompt_tokens);if(n===null||n<=0)return"Prefill";const r=ia(e.cached_tokens),i=ia(e.fed_tokens),c=[];r!==null&&r>0&&c.push(`${lo(r)} cached`),i!==null&&i>0&&c.push(`${lo(i)} new`);const u=c.length?` (${c.join(", ")})`:"";return`Prefill · ${lo(n)} tokens${u}`}if(e.phase==="generate"){const t=ia(e.generated_tokens)??0,n=Math.round(t)===1?"token":"tokens",r=ia(e.tokens_per_second),i=r!==null&&r>0?` · ${Math.round(r)} tok/s`:"";return`Generating · ${lo(t)} ${n}${i}`}return""}function wN(e){return yN(gN(e))}const Pw=new Set(["abstract.progress","abstractcode.progress"]),vN=new Set(["abstract.status","abstractcode.status"]);function ze(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Kf(e){const t=ze(e);return!!(t&&t.$slim)}function kt(e){const t=typeof e=="number"?e:Number(e);return Number.isFinite(t)?t:null}function jn(e){return Math.round(e).toLocaleString("en-US")}function Kt(e,t=120){const n=e.replace(/\s+/g," ").trim();return n.length>t?`${n.slice(0,t-1)}…`:n}function $i(e,t=120){var i,c;if(e==null)return"";if(typeof e=="string")return Kt(e,t);if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return Kt(e.length===0?"[]":`${e.length} ${e.length===1?"item":"items"}`,t);const n=ze(e);if(!n)return"";if(Kf(n)){const u=String(((i=n.$slim)==null?void 0:i.field)||""),d=kt((c=n.$slim)==null?void 0:c.bytes);return`${u||"payload"} stored${d?` · ${jn(d)} bytes`:""}`}const r=[];for(const[u,d]of Object.entries(n)){const h=typeof d=="string"?Kt(d,60):typeof d=="number"||typeof d=="boolean"?String(d):Array.isArray(d)?`${d.length} items`:d==null?"":"{…}";if(h&&(r.push(`${u.replace(/_/g," ")} ${h}`),r.join(" · ").length>=t))break}return Kt(r.join(" · "),t)}function Yc(e){return`${e>=100?String(Math.round(e)):e.toFixed(e<1?2:1).replace(/\.0+$/,"")} s`}function Dw(e,t){const n=Date.parse(String(e||"")),r=Date.parse(String(t||""));if(!Number.isFinite(n)||!Number.isFinite(r))return null;const i=(r-n)/1e3;return i>=0?i:null}function _N(e){const t=String(e||""),n=/T(\d{2}:\d{2}:\d{2})/.exec(t);return n?n[1]:""}function Fw(e){const t=String(e||"").trim();if(!t)return"";const n=t.split("/").pop()||t;return n.length>48?`${n.slice(0,47)}…`:n}function Jt(e,t=" · "){return e.filter(n=>!!n).join(t)}const fg="visual_react_agent_";function bN(e){if(!/^[A-Za-z0-9_-]{8,}$/.test(e))return null;try{const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=atob(t+"=".repeat((4-t.length%4)%4));return!/^[ -~]{3,}$/.test(n)||!/[a-z]/i.test(n)?null:n}catch{return null}}function xN(e){const t=String(e||"").trim();if(!t)return{name:"",node:""};const n=/^([^@]+)@([^:]+)(?::(.+))?$/.exec(t);if(n)return{name:n[1],node:n[3]||""};if(t.startsWith(fg)){const r=t.slice(fg.length),i=/^(.*)_(\d+)_(\d+)_(\d+)_([0-9a-f]{6,12})_(.+)$/.exec(r);if(i){let c=i[1];if(c.includes("__")){const u=c.split("__").filter(Boolean);for(let d=u.length-1;d>=0;d-=1){const h=bN(u[d]);if(h&&h.length>3){c=h;break}}}return{name:c,node:i[6]}}return{name:r,node:""}}return{name:t,node:""}}function kN(e){var n;if(!Array.isArray(e)||!e.length)return"";const t=new Map;for(const r of e){const i=String(((n=ze(r))==null?void 0:n.name)||"").trim()||"tool";t.set(i,(t.get(i)||0)+1)}return[...t.entries()].map(([r,i])=>i>1?`${r} ×${i}`:r).join(", ")}function jN(e){var d;const t=ze(e);if(!t)return null;const n=ze(t.effect);if(!n||String(n.type||"")!=="emit_event")return null;const r=ze(n.payload),i=String((r==null?void 0:r.name)??(r==null?void 0:r.event_name)??"").trim();if(!Pw.has(i))return null;const c=ze((d=ze(t.result))==null?void 0:d.payload),u=ze(r==null?void 0:r.payload);return c||u}function SN(e){if(!e.length)return"";const t=e[e.length-1];let n=null,r=null,i=null,c=null,u=null;for(const p of e)n=kt(p.prompt_tokens)??n,r=kt(p.cached_tokens)??r,i=kt(p.generated_tokens)??i,c=kt(p.tokens_per_second)??c,u=kt(p.elapsed_s)??u;if(t.final===!0||String(t.phase||"")==="complete")return Jt([n!==null?`${jn(n)} tokens in`:null,r!==null&&r>0?`${jn(r)} cached`:null,i!==null?`${jn(i)} out`:null,u!==null?Yc(u):null,c!==null&&c>0?`${Math.round(c)} tok/s`:null]);const h=n!==null?`prefill ${jn(n)} tokens${r!==null&&r>0?` (${jn(r)} cached)`:""}`:"prefill";if(String(t.phase||"")==="prefill"){const p=Lw(t);return p?`prefill ${Ow(p)}`:h}const m=Jt([`generating ${jn(i??0)} ${Math.round(i??0)===1?"token":"tokens"}`,c!==null&&c>0?`${Math.round(c)} tok/s`:null]);return`${h} → ${m}`}function NN(e){if(!e.length)return"";const t=e[e.length-1],n=kt(t.step)??kt(t.index),r=kt(t.total)??kt(t.steps),i=kt(t.percent)??kt(t.progress),c=kt(t.frame),u=kt(t.elapsed_s);return Jt([typeof t.label=="string"?Kt(t.label,60):null,typeof t.phase=="string"&&!t.label?Kt(t.phase,40):null,n!==null?`step ${jn(n)}${r!==null?`/${jn(r)}`:""}`:null,c!==null?`frame ${jn(c)}`:null,i!==null?`${Math.round(i<=1?i*100:i)}%`:null,u!==null?Yc(u):null])}function hg(e){return e.length?String(e[e.length-1].kind||"")==="llm"?SN(e):NN(e):""}function CN(e,t,n){var N;const r=String(e.provider||"").trim(),i=Fw(e.model||(t==null?void 0:t.model)),c=Jt(["llm",r,i])||"llm call";if(!t){const $=ze(e.params)||{};return{title:c,detail:Jt([kt($.temperature)!==null?`temperature ${$.temperature}`:null,$.thinking?`thinking ${$.thinking}`:null,(N=ze($.speculation))!=null&&N.mode?`speculation ${ze($.speculation).mode}`:null])}}const u=ze(t.usage)||{},d=ze(t.metadata)||{},h=ze(d.prompt_cache)||{},m=ze(d.performance)||{},p=kt(u.prompt_tokens)??kt(u.input_tokens),v=kt(u.completion_tokens)??kt(u.output_tokens),_=kt(h.cached_tokens),b=String(h.outcome||"").trim(),C=Dw(n.started_at,n.ended_at),x=kt(m.generation_tokens_per_second),j=Array.isArray(t.tool_calls)?t.tool_calls.length:0;return{title:c,detail:Jt([p!==null?`${jn(p)} tokens in`:null,_!==null&&_>0?`${jn(_)} cached`:b?`${b} cache`:null,v!==null?`${jn(v)} out`:null,C!==null?Yc(C):null,x!==null&&x>0?`${Math.round(x)} tok/s`:null,j?`${j} tool ${j===1?"call":"calls"}`:null])}}function EN(e,t){if(t.length<=60)return Kt(t,60);if(e==="url")try{const n=new URL(t),r=n.pathname.split("/").filter(Boolean).pop()||"";return Kt(`${n.host}${r?` · …/${r}`:""}`,72)}catch{}if(e==="file path"||e==="path"){const n=t.split(/[\\/]/).pop()||t;return Kt(`${n} · ${t.slice(0,24)}…`,60)}return Kt(t,60)}function $N(e,t){const n=Array.isArray(e.tool_calls)?e.tool_calls:[],r=kN(n),i=ze(n[0]),c=i?By(i.arguments):{label:"",value:""},u=Array.isArray(t==null?void 0:t.results)?t.results:[],d=u.filter(m=>{var p;return((p=ze(m))==null?void 0:p.success)===!0}).length,h=u.length-d;return{title:Jt(["tools",r||"tool call"]),detail:Jt([c.value?`${c.label} ${EN(c.label,c.value)}`:null,u.length?`${d} ok`:null,h>0?`${h} failed`:null])}}function AN(e,t){var m,p;const{name:n,node:r}=xN(e.workflow_id),i=ze(e.vars),c=i&&!Kf(i)?i:null,u=ze(c==null?void 0:c.context),d=typeof(u==null?void 0:u.task)=="string"?u.task:typeof(c==null?void 0:c.request)=="string"?c.request:"",h=String(((p=ze((m=ze(t==null?void 0:t.wait))==null?void 0:m.details))==null?void 0:p.sub_run_id)||"").slice(0,8);return c&&typeof c.state=="string"&&!u?{title:"subflow · status",detail:Jt([Kt(c.state,80),h&&`run ${h}`])}:d?{title:"subflow · agent loop",detail:Jt([n,Kt(d,90),h&&`run ${h}`])}:{title:Jt(["subflow",n||"workflow"]),detail:Jt([r,c?$i(c,80):null,h&&`run ${h}`])}}function TN(e,t){const n=e.until,r=Dw(t.started_at,n),i=_N(n);return{title:r!==null?`wait · delay ${Yc(r)}`:`wait · until ${i}`,detail:Jt([r!==null&&i?`until ${i}`:null,e.resume_to_node?`resumes at ${e.resume_to_node}`:null])}}function mg(e){var d;const t=ze(e)||{},n=ze(t.effect),r=String((n==null?void 0:n.type)||"").trim(),i=ze(n==null?void 0:n.payload)||{},c=ze(t.result);if(r==="emit_event"){const h=String(i.name??i.event_name??"").trim();if(Pw.has(h))return{kind:"progress",title:"progress",detail:"",isProgress:!0,isStatus:!1,isResume:!1,hidden:!0};if(vN.has(h))return{kind:"event",title:"status",detail:$i(i.payload,80),isProgress:!1,isStatus:!0,isResume:!1,hidden:!0};const m=String(i.scope||"").trim();return{kind:"event",title:`event · ${h||"unnamed"}${m?` (${m})`:""}`,detail:$i(i.payload??(c==null?void 0:c.payload),110),isProgress:!1,isStatus:!1,isResume:!1,hidden:!1}}if(r==="resume")return{kind:"step",title:"resume",detail:String(i.wait_reason||""),isProgress:!1,isStatus:!1,isResume:!0,hidden:!0};const u={isProgress:!1,isStatus:!1,isResume:!1,hidden:!1};if(r==="llm_call")return{kind:"llm",...CN(i,c,t),...u};if(r==="tool_calls")return{kind:"tools",...$N(i,c),...u};if(r==="start_subworkflow")return{kind:"subflow",...AN(i,c),...u};if(r==="wait_until")return{kind:"wait",...TN(i,t),...u};if(r==="wait_event")return{kind:"wait",title:"wait · event",detail:Jt([typeof i.prompt=="string"?Kt(i.prompt,90):null,!i.prompt&&i.wait_key?Kt(String(i.wait_key),70):null]),...u};if(r==="ask_user")return{kind:"ask",title:"ask · your input",detail:Kt(String(i.prompt||((d=ze(c==null?void 0:c.wait))==null?void 0:d.prompt)||"").split(`
|
|
90
|
+
`)[0],110),...u};if(r==="answer_user")return{kind:"message",title:"message",detail:Kt(String(i.message||""),110),...u};if(!r){if((c==null?void 0:c.completed)===!0){const h=ze(c.output)||{},m=ze(h.stop_reason)||{},p=kt(h.iterations),v=Jt([String(m.code||h.outcome||"").replace(/_/g," ")||null,p!==null?`${jn(p)} ${p===1?"iteration":"iterations"}`:null]),_=[h.answer,h.response,h.result].find(b=>typeof b=="string"&&b.trim());return{kind:"run",title:"run finished",detail:v||(typeof _=="string"?Kt(_,110):$i(h,110)),...u}}return{kind:"step",title:String(t.node_id||"workflow step"),detail:"",...u}}return{kind:"step",title:r.replace(/_/g," "),detail:$i(i,110),...u}}function RN(e,t,n){var c,u;const r=ze(e)||{},i=String(r.status||"").trim();if(r.error)return{status:"failed",statusLabel:"failed"};if(i==="failed")return{status:"failed",statusLabel:"failed"};if(i==="completed")return{status:"completed",statusLabel:"completed"};if(i==="waiting"){if(n)return{status:"completed",statusLabel:"completed"};const d=ze((c=ze(r.result))==null?void 0:c.wait);return String(((u=ze(d==null?void 0:d.details))==null?void 0:u.mode)||"")==="approval_required"?{status:"waiting",statusLabel:"approval needed"}:t==="subflow"?{status:"waiting",statusLabel:"waiting for subflow"}:t==="ask"?{status:"waiting",statusLabel:"waiting for you"}:t==="wait"?{status:"waiting",statusLabel:String((d==null?void 0:d.reason)||"")==="until"?"waiting":"waiting for event"}:{status:"waiting",statusLabel:"waiting"}}return i==="started"?{status:"started",statusLabel:"running"}:{status:i||"started",statusLabel:i||"running"}}function IN(e){var i;const t=ze(e.record)||{},n=String(((i=ze(t.effect))==null?void 0:i.type)||"(none)"),r=String(t.idempotency_key||t.step_id||e.cursor);return`${e.runId}|${n}|${r}|${t.attempt??1}`}function MN(e){var h;const t=e.map(m=>ze(m.record)||{}),n=t[t.length-1]||{},r={};for(const m of t){const p=ze((h=ze(m.effect))==null?void 0:h.payload);if(p)for(const[v,_]of Object.entries(p))Kf(_)&&v in r||(r[v]=_)}let i=null,c=null,u=null,d=null;for(const m of t)m.result!==null&&m.result!==void 0&&(i=m.result),m.error!==null&&m.error!==void 0&&(c=m.error),!u&&m.started_at&&(u=m.started_at),m.ended_at&&(d=m.ended_at);return{...n,effect:n.effect?{...n.effect,payload:r}:n.effect,result:i,error:c,started_at:u,ended_at:d}}function LN(e){var n,r;const t=[];for(const i of e){const c=ze((r=ze((n=ze(i.record))==null?void 0:n.result))==null?void 0:r.wait),u=String((c==null?void 0:c.wait_key)||"").trim();u&&t.push(u)}return t}function ON(e,t){return`${e}|${String(t.step_id||t.node_id||"")}`}function PN(e,t){const n=new Map;for(const c of t){const u=jN(c.record);if(!u)continue;const d=ON(c.runId,u),h=n.get(d)||{entries:[],payloads:[]};h.entries.push(c),h.payloads.push(u),n.set(d,h)}if(!n.size)return e.map(c=>({...c}));const r=new Set,i=e.map(c=>{const u=c.stepIds.map(b=>`${c.runId}|${b}`).filter(b=>n.has(b));if(!u.length)return{...c};const d=[],h=[];for(const b of u)r.add(b),d.push(...n.get(b).payloads),h.push(...n.get(b).entries);const m=hg(d),p=d[d.length-1],v=p.final===!0||String(p.phase||"")==="complete",_=!(v&&c.status==="completed"&&c.detail);return{...c,progress:_?m:"",progressFinal:v,progressEvents:h.map(b=>ze(b.record)||{})}});for(const[c,u]of n.entries()){if(r.has(c))continue;const d=u.payloads,h=d[d.length-1],m=String(h.kind||""),p=u.entries[0];i.push({key:`progress:${c}`,runId:p.runId,cursor:u.entries[u.entries.length-1].cursor,kind:"progress",title:Jt(m==="llm"?["llm",String(h.provider||""),Fw(h.model)]:["progress",m]),detail:"",status:h.final===!0||String(h.phase||"")==="complete"?"completed":"started",statusLabel:h.final===!0||String(h.phase||"")==="complete"?"completed":"running",nodeId:String(h.node_id||""),stepIds:[String(h.step_id||"")],progress:hg(d),progressFinal:h.final===!0||String(h.phase||"")==="complete",entries:u.entries,progressEvents:u.entries.map(v=>ze(v.record)||{}),merged:ze(u.entries[u.entries.length-1].record)||{}})}return i}function Jf(e,t){var v,_,b,C;const n=String(t||((v=e==null?void 0:e[0])==null?void 0:v.runId)||""),r=new Map,i=[],c=[],u=new Map,d=new Map,h=[];for(const x of e||[]){const j=mg(x.record);if(j.isProgress){h.push(x);continue}if(j.isStatus)continue;if(j.isResume){const $=String(((C=(b=ze((_=ze(x.record))==null?void 0:_.effect))==null?void 0:b.payload)==null?void 0:C.wait_key)||"").trim();$&&c.push($);continue}const N=IN(x);d.set(x,d.size),u.set(x.runId,d.size-1),r.has(N)||(r.set(N,[]),i.push(N)),r.get(N).push(x)}const m=new Set(c),p=i.map(x=>{const j=r.get(x),N=MN(j),$=mg(N),S=j[j.length-1],A=(u.get(S.runId)??-1)>(d.get(S)??1/0)||LN(j).some(z=>m.has(z)),R=RN(N,$.kind,A);return{key:x,runId:j[0].runId,cursor:j[j.length-1].cursor,kind:$.kind,title:$.kind==="run"&&n&&j[0].runId!==n?"subflow finished":$.title,detail:$.detail,status:R.status,statusLabel:R.statusLabel,nodeId:String(N.node_id||""),stepIds:[...new Set(j.map(z=>{var L;return String(((L=ze(z.record))==null?void 0:L.step_id)||"")}).filter(Boolean))],progress:"",progressFinal:!1,entries:j,progressEvents:[],merged:N}});return PN(p,h)}const DN=["running","waiting","failed","completed"],FN={running:"Running",failed:"Failed",completed:"Done"},zN=new Set(["waiting for you","approval needed"]);function UN(e,t){var i;if(e!=="waiting")return FN[e]||e;const n=t.filter(c=>c.status==="waiting");if(n.some(c=>zN.has(c.statusLabel)))return"Waiting for you";const r=((i=n[n.length-1])==null?void 0:i.statusLabel)||"waiting";return r.charAt(0).toUpperCase()+r.slice(1)}function BN(e){for(const t of DN)if(e.some(n=>n.status===t))return t;return e.length?e[e.length-1].status:"completed"}function WN(e){const t=[];let n=null,r=0;for(const i of e){if(i.kind==="llm"||!n){const c=i.kind==="llm";c&&(r+=1),n={key:`${c?"step":"start"}:${i.key}`,title:c?`Step ${r}`:"Start",detail:c?i.title:"",status:"completed",statusLabel:"Done",rows:[],toolRows:0},t.push(n)}n.rows.push(i),i.kind==="tools"&&(n.toolRows+=1)}for(const i of t)i.status=BN(i.rows),i.statusLabel=UN(i.status,i.rows);return t}function VN(e){return e.length?e[e.length-1].key:""}function HN({policy:e,runId:t,enabled:n,isAdmin:r,refreshKey:i,onAttach:c,onAttachFiles:u,includeArtifacts:d=!0}){const[h,m]=y.useState("session");return a.jsxs(a.Fragment,{children:[r?a.jsxs("div",{className:"code-files-mode",role:"group","aria-label":"Files source",children:[a.jsx("button",{"aria-pressed":h==="session",onClick:()=>m("session"),children:"This conversation"}),a.jsx("button",{"aria-pressed":h==="shared",onClick:()=>m("shared"),children:"Gateway files (admin)"})]}):null,r?a.jsx("div",{hidden:h!=="shared",children:a.jsx(eC,{policy:e,enabled:n&&h==="shared",runId:t,onAttach:c})}):null,a.jsx("div",{hidden:r&&h!=="session",children:a.jsx(hN,{runId:t,enabled:n&&(!r||h==="session"),refreshKey:i,maxAttachmentBytes:e==null?void 0:e.maxAttachmentBytes,onAttachFiles:u})}),d?a.jsxs("section",{className:"code-rail-section","aria-labelledby":"code-artifacts-title",children:[a.jsx("h3",{id:"code-artifacts-title",className:"code-rail-section-title",children:"Generated outputs & attachments"}),a.jsx(rC,{runId:t,enabled:n,refreshKey:i})]}):null]})}function GN({records:e,runId:t}){const n=y.useMemo(()=>Jf(e,t),[e,t]);return n.length?a.jsx(zw,{rows:n}):a.jsxs("div",{className:"code-pane-empty",children:[a.jsx(ne,{name:"activity",size:28}),a.jsx("p",{children:"Follow the work as it happens."}),a.jsx("small",{children:"Model steps, tool calls and approvals appear here, one group per step."})]})}function KN(e,t){const n=Jf(e,t),r=n.filter(u=>u.status==="waiting").length,i=n.filter(u=>u.status==="running").length,c=[r?`${r} waiting`:"",i?`${i} running`:""].filter(Boolean);return{count:r+i,hint:c.join(" · ")}}function zw({rows:e}){const t=y.useMemo(()=>WN(e),[e]),n=VN(t),[r,i]=y.useState({});return a.jsx("div",{className:"code-activity-groups",children:t.map(c=>{const u=r[c.key]??c.key===n;return a.jsxs("details",{className:`code-activity-group is-${c.status}`,"data-group":c.title,open:u,onToggle:d=>{const h=d.currentTarget.open;h!==u&&i(m=>({...m,[c.key]:h}))},children:[a.jsxs("summary",{children:[a.jsx(ne,{name:"chevronRight",size:14,className:"code-activity-group-chevron"}),a.jsx("strong",{children:c.title}),c.detail?a.jsx("span",{className:"code-activity-group-detail",title:c.detail,children:c.detail}):a.jsx("span",{className:"code-activity-group-detail"}),a.jsx("span",{className:`code-step-dot is-${c.status}`,"aria-hidden":"true"}),a.jsx("small",{children:c.statusLabel})]}),u?a.jsx(JN,{group:c}):null]},c.key)})})}function JN({group:e}){const t=y.useMemo(()=>e.rows.flatMap(i=>i.entries.map(c=>({cursor:c.cursor,record:c.record,runId:c.runId}))),[e]),n=y.useMemo(()=>Ti(t).tools,[t]),r=e.rows.filter(i=>i.kind!=="tools");return a.jsxs("div",{className:"code-activity-group-body",children:[r.map(i=>a.jsx(YN,{row:i},i.key)),n.length?a.jsx(Pf,{tools:n}):null]})}const QN={llm:"sparkle",tools:"terminal",subflow:"agent",event:"info",wait:"history",ask:"chat",message:"send",run:"playCircle",progress:"loader",step:"list"};function YN({row:e}){const t=e.merged,n=t.effect||{};return a.jsxs("details",{className:`code-activity-row code-activity-row--${e.kind}`,children:[a.jsxs("summary",{children:[a.jsx("span",{className:"code-activity-icon","aria-hidden":"true",children:a.jsx(ne,{name:QN[e.kind],size:14})}),a.jsxs("span",{className:"code-activity-text",children:[a.jsx("span",{className:"code-activity-title",children:e.title}),e.detail?a.jsx("span",{className:"code-activity-sub",children:e.detail}):null,e.progress?a.jsx("span",{className:"code-activity-progress",children:e.progress}):null]}),a.jsx("span",{className:`code-step-dot is-${e.status}`}),a.jsx("small",{children:e.statusLabel})]}),a.jsxs("div",{className:"code-activity-detail",children:[a.jsxs("div",{className:"code-field-help",children:[e.nodeId?`${e.nodeId} · `:"","run ",e.runId.slice(0,8)," · ",e.entries.length," ",e.entries.length===1?"record":"records",e.progressEvents.length?` · ${e.progressEvents.length} progress`:""]}),a.jsx(co,{value:{input:n.payload,result:t.result,error:t.error,records:e.entries.map(r=>r.record),...e.progressEvents.length?{progress:e.progressEvents}:{}},collapseAfterDepth:2})]})]})}async function XN(e,t,n=2e3){var c;const r=[];let i=0;for(;r.length<n;){if(t!=null&&t.aborted)throw new DOMException("aborted","AbortError");const u=await Ln.get_ledger(e,{after:i,limit:500}),d=Array.isArray(u.items)?u.items:[];for(const h of d){const m=Number(h==null?void 0:h.cursor)||i+r.length+1;r.push({cursor:m,record:(h==null?void 0:h.record)??h,runId:String(((c=h==null?void 0:h.record)==null?void 0:c.run_id)||e)})}if(!d.length||!u.next_after||u.next_after<=i)break;i=u.next_after}return r}function qN({occurrences:e,nowMs:t,loadRecords:n=XN,onOpenRun:r}){var h;const i=y.useMemo(()=>[...e].sort((m,p)=>p.index-m.index),[e]),c=((h=i[0])==null?void 0:h.run_id)||"",[u,d]=y.useState({});return i.length?a.jsx("div",{className:"code-activity-groups","data-scope":"automation",children:i.map(m=>{const p=u[m.run_id]??m.run_id===c,v=m.finished_at||m.fired_at;return a.jsxs("details",{className:`code-activity-group is-${m.status}`,"data-group":`Run #${m.index}`,open:p,onToggle:_=>{const b=_.currentTarget.open;b!==p&&d(C=>({...C,[m.run_id]:b}))},children:[a.jsxs("summary",{children:[a.jsx(ne,{name:"chevronRight",size:14,className:"code-activity-group-chevron"}),a.jsxs("strong",{children:["Run #",m.index]}),a.jsx("span",{className:"code-activity-group-detail",children:v?a.jsx("time",{title:Vc(v),children:fo(v,t)}):null}),a.jsx("span",{className:`code-step-dot is-${m.status}`,"aria-hidden":"true"}),a.jsx("small",{children:m.status})]}),p?a.jsx(ZN,{occurrence:m,loadRecords:n,onOpenRun:r}):null]},m.run_id)})}):a.jsxs("div",{className:"code-pane-empty",children:[a.jsx(ne,{name:"activity",size:28}),a.jsx("p",{children:"No runs yet."}),a.jsx("small",{children:"Each run of this automation appears here as one group."})]})}function ZN({occurrence:e,loadRecords:t,onOpenRun:n}){var u;const[r,i]=y.useState({status:"loading"});y.useEffect(()=>{const d=new AbortController;return i({status:"loading"}),t(e.run_id,d.signal).then(h=>!d.signal.aborted&&i({status:"ready",records:h})).catch(h=>!d.signal.aborted&&i({status:"error",message:`Run activity unavailable: ${vt(h)}`})),()=>d.abort()},[e.run_id,e.status,t]);const c=y.useMemo(()=>r.status==="ready"?Jf(r.records,e.run_id):[],[r,e.run_id]);return a.jsxs("div",{className:"code-activity-group-body",children:[(u=e.failure)!=null&&u.message?a.jsx("p",{className:"code-error-text",role:"alert",children:e.failure.message}):null,r.status==="loading"?a.jsx("p",{className:"code-muted",role:"status",children:"Loading run activity…"}):null,r.status==="error"?a.jsx("p",{className:"code-error-text",role:"alert",children:r.message}):null,r.status==="ready"?c.length?a.jsx(zw,{rows:c}):a.jsx("p",{className:"code-muted",children:"This run recorded no steps."}):null,n?a.jsxs("button",{type:"button",className:"code-subtle-button",onClick:()=>n(e.run_id),children:[a.jsx(ne,{name:"chat",size:13})," ",a.jsx("span",{children:"Open as conversation"})]}):null]})}function eC({policy:e,enabled:t,runId:n,onAttach:r}){const[i,c]=y.useState(""),[u,d]=y.useState(""),[h,m]=y.useState([]),[p,v]=y.useState(!1),[_,b]=y.useState(""),[C,x]=y.useState(""),[j,N]=y.useState(0),[$,S]=y.useState("");return y.useEffect(()=>{const E=new AbortController;if(m([]),b(""),x(""),!t||!e)return;v(!0);const A=window.setTimeout(()=>{const R=new URLSearchParams({limit:"100"});i.trim()?R.set("query",i.trim()):u&&R.set("path",u),ct(_e(`files/${i.trim()?"search":"list"}?${R}`),{signal:E.signal}).then(z=>{if(z.error)throw new Error(String(z.error));m(Array.isArray(z.items)?z.items:[]),(z.truncated||z.has_more)&&x("Showing the first 100 results. Search to narrow the list.")}).catch(z=>{E.signal.aborted||b(vt(z))}).finally(()=>{E.signal.aborted||v(!1)})},i?220:0);return()=>{window.clearTimeout(A),E.abort()}},[t,e,i,u,j,n]),a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"code-pane-intro",children:[a.jsx(ne,{name:"terminal",size:17}),a.jsxs("div",{children:[a.jsx("strong",{children:"Gateway files (admin)"}),a.jsx("span",{children:u||"The gateway's files"})]}),a.jsx("button",{className:"code-icon-button","aria-label":"Refresh files",onClick:()=>N(E=>E+1),disabled:!t,children:a.jsx(ne,{name:"refresh",size:14})})]}),a.jsx("input",{className:"code-search","aria-label":"Search workspace files",placeholder:"Search files…",value:i,onChange:E=>c(E.target.value),disabled:!t}),u?a.jsx("button",{className:"code-back",onClick:()=>{d(u.split("/").slice(0,-1).join("/")),c("")},children:"← Parent folder"}):null,t?null:a.jsx("p",{className:"code-pane-empty",children:"Connect to browse your workspace."}),p?a.jsx("p",{className:"code-muted",role:"status",children:"Loading files…"}):null,_?a.jsxs("div",{className:"code-inline-error",role:"alert",children:[_,a.jsx("button",{onClick:()=>N(E=>E+1),children:"Retry"})]}):null,C?a.jsx("p",{className:"code-field-help",role:"status",children:C}):null,a.jsx("ul",{className:"code-file-list",children:h.map(E=>{const A=E.kind==="folder"||E.is_dir||E.type==="directory"||E.type==="dir";return a.jsx("li",{children:a.jsxs("button",{title:A?`Show ${E.path}`:`Attach ${E.path} to the conversation`,disabled:!!$,onClick:async()=>{if(A){d(E.path),c("");return}S(E.path),b("");try{await r(E.path),x(`${E.name||E.path} attached.`)}catch(R){b(vt(R))}finally{S("")}},children:[a.jsx(ne,{name:A?"folder":"paperclip",size:14}),a.jsx("span",{children:E.name||E.path}),$===E.path?a.jsx(ne,{name:"loader",size:13}):a.jsx(ne,{name:A?"chevronRight":"plus",size:13,className:"code-file-action"})]})},E.path)})}),!p&&!_&&t&&!h.length?a.jsxs("div",{className:"code-pane-empty",children:[a.jsx(ne,{name:"terminal",size:28}),a.jsx("p",{children:i?"No matching files.":"No shared files yet."}),a.jsx("small",{children:i?"Try a shorter name or another folder.":"Browse files exposed by your gateway or attach files from your device."})]}):null]})}function tC(e){const t=String(e||"").split(";",1)[0].trim().toLowerCase(),n=(t.split("/")[1]||"").replace(/^x-/,"").split("+")[0];return t==="application/pdf"?"PDF document":t==="application/json"||t.endsWith("+json")?"JSON file":t.startsWith("image/")?`${n.toUpperCase()} image`:t.startsWith("audio/")?`${n.toUpperCase()} audio`:t.startsWith("video/")?`${n.toUpperCase()} video`:t==="text/markdown"?"Markdown file":t.startsWith("text/")?"Text file":"File"}function nC(e){var r;const t=String(e.artifact_id||e.id||""),n=String(e.content_type||e.mime_type||"");return{id:t,name:String(e.filename||((r=e.metadata)==null?void 0:r.filename)||e.name||tC(n)),contentType:n,...typeof e.size_bytes=="number"?{size:e.size_bytes}:typeof e.size=="number"?{size:e.size}:{},...e.created_at||e.timestamp?{created:String(e.created_at||e.timestamp)}:{}}}function sC(e){return gf(e)?"text":e==="image"||e==="pdf"||e==="audio"?"url":"none"}function rC({runId:e,enabled:t,refreshKey:n}){const[r,i]=y.useState([]),[c,u]=y.useState(""),[d,h]=y.useState(0),[m,p]=y.useState(null),[v,_]=y.useState({status:"loading"}),b=Date.now();y.useEffect(()=>{if(i([]),u(""),p(null),!e||!t)return;const x=new AbortController;return ct(_e(`runs/${encodeURIComponent(e)}/artifacts?limit=200`),{signal:x.signal}).then(j=>i((Array.isArray(j.items)?j.items:Array.isArray(j.artifacts)?j.artifacts:[]).map(nC))).catch(j=>{x.signal.aborted||u(vt(j))}),()=>x.abort()},[e,t,d,n]),y.useEffect(()=>{if(!m)return;let x=!0,j="";return _({status:"loading"}),Ln.get_run_artifact_blob(e,m.id).then(async({blob:N,content_type:$})=>{const S=sC(Nc(m.name,$));if(S==="text"){const E=await N.slice(0,$c).text();x&&_({status:"ready",text:E,partial:N.size>$c,total:N.size,contentType:$})}else S==="url"?(j=URL.createObjectURL(N.type?N:new Blob([N],{type:$})),x&&_({status:"ready",url:j,partial:!1,contentType:$})):x&&_({status:"ready",partial:!1,contentType:$})}).catch(N=>x&&_({status:"error",message:`Preview failed: ${vt(N)}`})),()=>{x=!1,j&&URL.revokeObjectURL(j)}},[e,m]);const C=x=>void h0(e,x.id,x.name).catch(j=>u(vt(j)));return a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"code-rail-toolbar",children:a.jsx("button",{className:"code-icon-button","aria-label":"Refresh outputs",title:"Refresh",onClick:()=>h(x=>x+1),children:a.jsx(ne,{name:"refresh",size:14})})}),c?a.jsx("p",{role:"alert",className:"code-error-text",children:c}):null,m?a.jsx(sw,{name:m.name,sizeBytes:m.size,modified:m.created,nowMs:b,contentType:v.status==="ready"?v.contentType:m.contentType,status:v.status,...v.status==="error"?{error:v.message}:{},...v.status==="ready"?{text:v.text,url:v.url,...v.partial?{partialNote:nw(v.total)}:{}}:{},onDownload:()=>C(m),onClose:()=>p(null)}):r.length?a.jsx("ul",{className:"code-file-rows",children:r.map(x=>a.jsxs("li",{className:"code-file-row",children:[a.jsxs("button",{className:"code-file-row-name",title:`Preview ${x.name} · ${x.id}`,onClick:()=>p(x),children:[a.jsx(ne,{name:"file",size:14}),a.jsx("span",{children:x.name})]}),a.jsxs("span",{className:"code-file-row-meta",children:[x.size!==void 0?a.jsx("span",{children:Hc(x.size)}):null,x.created?a.jsx("time",{title:Vc(x.created),children:fo(x.created,b)}):null]}),a.jsx("button",{className:"code-icon-button","aria-label":`Download ${x.name}`,title:"Download",onClick:()=>C(x),children:a.jsx(ne,{name:"download",size:14})})]},x.id))}):c?null:a.jsx("p",{className:"code-muted",children:"Generated files and attachments appear here."})]})}const Uw=[{id:"activity",label:"Activity",icon:"activity"},{id:"files",label:"Files",icon:"file"},{id:"model",label:"Model",icon:"sparkle"},{id:"workflow",label:"Workflow",icon:"agent"},{id:"workspace",label:"Workspace",icon:"folder"},{id:"tools",label:"Tools",icon:"terminal"},{id:"skills",label:"Skills",icon:"list"},{id:"voice",label:"Voice",icon:"mic"}],pg=Uw.map(e=>e.id),Bw="abstractcode.rail.panel.v2",aC="abstractcode.rail.panel.v1",oC="abstractcode.rail.width.v1";function iC(e){try{const t=e==null?void 0:e.getItem(Bw);if(t!=null)return pg.includes(t)?t:null;const n=e==null?void 0:e.getItem(aC);return n==="settings"?"model":pg.includes(n)?n:null}catch{return null}}function lC(){try{return typeof window<"u"?window.localStorage:null}catch{return null}}function cC(){const e=kc(Mi.md),[t,n]=y.useState(()=>{var i;return typeof window<"u"&&!((i=window.matchMedia)!=null&&i.call(window,Mi.md).matches)?iC(lC()):null});y.useEffect(()=>{e&&n(null)},[e]);const r=y.useCallback(i=>{if(n(i),!e)try{window.localStorage.setItem(Bw,i??"")}catch{}},[e]);return[t,r,e]}function uC(e){return a.jsx(mk,{className:"code-rail",ariaLabel:"Workspace panels",idBase:"code-rail",storageKey:oC,defaultWidth:420,minWidth:320,maxWidth:900,active:e.panel,onActiveChange:t=>e.onPanel(t),items:Uw.map(t=>({id:t.id,label:t.label,icon:t.icon,content:e.content[t.id],...t.id==="activity"?{badge:e.activityBadge,hint:e.activityHint}:{}}))})}const Tr=e=>e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{},Nr=e=>typeof e=="string"?e:typeof e=="number"?String(e):"",Yd=e=>Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim()!==""):[];function gc(e){const t=Tr(e),n=Tr(t._runtime),r=Tr(t._limits),i=Nr(t.provider)||Nr(n.provider),c=Nr(t.model)||Nr(n.model),u=Di(t),d=Tr(n.tool_policy),h={};for(const p of Yd(d.auto_approve_tools))h[p]="approve";for(const p of Yd(d.require_approval_tools))h[p]="ask";const m=u!==null||Object.keys(h).length>0;return{...cs,provider:i&&c?i:"",model:i&&c?c:"",reasoning:Nr(n.thinking),...n.speculation!==void 0?{speculation:n.speculation}:{},maxIterations:Nr(r.max_iterations),maxTokens:Nr(r.max_tokens),system:Nr(n.system_prompt_extra),workspace:t.workspace&&typeof t.workspace=="object"&&Array.isArray(t.workspace.folders)?t.workspace:null,tools:u===null?{mode:"all",selected:[],approval:h}:{mode:"custom",selected:u,approval:h},toolsCustomized:m,permissions:"default",skills:Yd(t.skills),workflow:cs.workflow,streamReplies:"gateway_default"}}function is(e,t,n){n==null||n===""||Array.isArray(n)&&!n.length?delete e[t]:e[t]=n}function gg(e){const t=Number(e);return Number.isSafeInteger(t)&&t>0?t:void 0}function dC(e,t){let n=Tr(e);const r=Tr(n._runtime),i=Tr(n._limits),c=!!(t.provider&&t.model);is(n,"provider",c?t.provider:""),is(n,"model",c?t.model:""),is(r,"provider",c?t.provider:""),is(r,"model",c?t.model:""),is(r,"thinking",t.reasoning),is(r,"speculation",t.speculation),is(r,"system_prompt_extra",t.system.trim()),is(i,"max_iterations",gg(t.maxIterations)),is(i,"max_tokens",gg(t.maxTokens));const u=Object.entries(t.tools.approval||{}).filter(([,m])=>m==="approve").map(([m])=>m),d=Object.entries(t.tools.approval||{}).filter(([,m])=>m==="ask").map(([m])=>m),h=t.toolsCustomized&&(u.length||d.length)?{...u.length?{auto_approve_tools:u}:{},...d.length?{require_approval_tools:d}:{}}:void 0;return is(r,"tool_policy",h),Object.keys(r).length?n._runtime=r:delete n._runtime,Object.keys(i).length?n._limits=i:delete n._limits,delete n.workspace_access_mode,t.workspace===null?(n.workspace&&typeof n.workspace=="object"&&delete n.workspace_allowed_paths,delete n.workspace):(n.workspace={posture:t.workspace.posture,default_mode:t.workspace.default_mode,folders:t.workspace.folders.map(m=>({path:m.path,mode:m.mode}))},delete n.workspace_allowed_paths),is(n,"skills",t.skills),n=Uc(n,t.toolsCustomized&&t.tools.mode==="custom"?t.tools.selected:null),n}function fC(e,t){const n=Tr(e.target.input_data),r=dC(n,t);return Lc(n)===Lc(r)?null:{target:{bundle_ref:e.target.bundle_ref,flow_id:e.target.flow_id,input_data:r}}}function Lc(e){if(Array.isArray(e))return`[${e.map(Lc).join(",")}]`;if(e&&typeof e=="object"){const t=e;return`{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${Lc(t[n])}`).join(",")}}`}return JSON.stringify(e)}const hC=700;function mC(e){return e.status==="saving"?"Saving…":e.status==="saved"?`Saved as revision ${e.revision}; applies from the next run.`:e.status==="error"?e.message:""}function Ww(e){if(zi(e)){if(e.code==="revision_conflict")return"Not saved: the automation changed elsewhere. The latest revision is shown; make the change again.";const t=go(e);return`Not saved: ${t.title}${t.detail?` ${t.detail}`:""}`}return`Not saved: ${String((e==null?void 0:e.message)||e)}`}function pC(e,t){const n=(e==null?void 0:e.definition)??null,r=(e==null?void 0:e.summary.automation_id)??"",i=(n==null?void 0:n.revision)??0,[c,u]=y.useState(()=>gc(n==null?void 0:n.target.input_data)),[d,h]=y.useState({status:"idle"}),m=y.useRef(null),p=y.useRef(null),v=y.useRef(n);v.current=n;const _=y.useRef(r);_.current=r;const b=y.useRef(t);b.current=t;const C=y.useRef({id:r,def:n}),x=async()=>{var E;p.current&&window.clearTimeout(p.current),p.current=null;const j=m.current;if(m.current=null,!j)return;const N=j.automationId===_.current?v.current:C.current.id===j.automationId?C.current.def:null;if(!N)return;const $=fC(N,j.prefs);if(!$)return;const S=()=>j.automationId===_.current;S()&&h({status:"saving"});try{await b.current(j.automationId,$,N.revision),S()&&h({status:"saved",revision:N.revision+1})}catch(A){if(!S())return;h({status:"error",message:Ww(A)}),u(gc((E=v.current)==null?void 0:E.target.input_data))}};return y.useEffect(()=>{m.current&&m.current.automationId!==r&&x(),C.current={id:r,def:n},h({status:"idle"}),u(gc(n==null?void 0:n.target.input_data))},[r]),y.useEffect(()=>{C.current={id:r,def:n},m.current||u(gc(n==null?void 0:n.target.input_data))},[i]),y.useEffect(()=>()=>{p.current&&window.clearTimeout(p.current)},[]),!e||!n?null:{automationId:r,revision:i,draft:c,save:d,setSave:h,onChange:j=>{u(j),m.current={prefs:j,automationId:r},p.current&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>void x(),hC)}}}function gC(e){return a.jsxs(a.Fragment,{children:[a.jsxs("p",{className:"code-settings-binding",children:[a.jsx("span",{children:"Automation"})," ",a.jsx("strong",{title:e.summary.title,children:e.summary.title}),a.jsxs("span",{className:"code-settings-revision","data-testid":"automation-revision",children:["Revision ",e.settings.revision]})]}),a.jsx("p",{className:`code-settings-save is-${e.settings.save.status}`,role:"status","aria-live":"polite",children:mC(e.settings.save)||"Changes are saved as a new revision and apply from the next run."})]})}function yC(e){const t=e.definition.revision,[n,r]=y.useState([]),i=e.settings.setSave;return a.jsx("div",{className:"code-automation-definition","data-revision":t,children:a.jsx(_y,{summary:e.summary,definition:e.definition,busy:e.busy||e.disabled,errors:n,heading:null,submitLabel:"Save",emailStatus:e.emailStatus,onOpenMyEmail:e.onOpenMyEmail,workflowPickerOptions:e.workflowPickerOptions,onSubmit:c=>{const u=ty(e.summary,c,e.definition);if(u===null){r(["Nothing changed."]);return}if("errors"in u){r(u.errors);return}r([]),i({status:"saving"}),(async()=>{const h=u;return c.target&&h.target&&e.prepareTarget?{...h,target:await e.prepareTarget(h.target)}:h})().then(h=>e.onRevise(h,t)).then(()=>i({status:"saved",revision:t+1})).catch(h=>{zi(h)?i({status:"error",message:Ww(h)}):(i({status:"idle"}),r([String((h==null?void 0:h.message)||h)]))})}},`${e.summary.automation_id}:${t}`)})}const wC={framework:null,frameworkNote:"checking…",gateway:null,gatewayNote:"checking…"};function vC(e){return e?e.ok?dp(e.value):dp(null,e.status?`HTTP ${e.status}`:e.message):wC}const _C=3e4,yc=50;function bC(){return Bb({fetch:(e,t)=>fetch(e,{...t,credentials:"same-origin"}),baseUrl:"",headers:Kc})}function xC(e){const t=String(e||"").trim();if(!t)return null;try{const n=new URL(t);return n.protocol!=="http:"&&n.protocol!=="https:"?null:`${n.origin}${n.pathname.replace(/\/+$/,"")}/console#users`}catch{return null}}function kC(e){var n;const t=(n=e==null?void 0:e.common)==null?void 0:n.automations;return t&&typeof t=="object"&&t.available===!0?{available:!0,reason:""}:t&&typeof t=="object"&&t.available===!1?{available:!1,reason:"This gateway has the Automations API turned off."}:{available:!1,reason:"This gateway does not advertise the Automations API (capabilities.contracts.common.automations). Update AbstractGateway (0.6.0 or later) to use automations."}}function jC(e,t){return e===Ot?{flow_id:"@default",interface:Nn}:!(t!=null&&t.bundleId)||!t.flowId?null:{bundle_ref:t.bundleVersion?`${t.bundleId}@${t.bundleVersion}`:t.bundleId,flow_id:t.flowId}}function SC(e){return e.filter(t=>t.status!=="archived")}function NC(e){const t=e==null?void 0:e.archived_automations;return typeof t=="number"&&Number.isFinite(t)&&t>0?Math.floor(t):0}function CC(e,t){if(e==="ask_user"){if(typeof t.response!="string")throw new Error("An ask_user wait is answered with {response: string}.");return{response:t.response}}if(e==="tool_approval"){if(typeof t.approved!="boolean")throw new Error("A tool_approval wait is answered with {approved: true|false}.");return{approved:t.approved}}if(e==="event"){if(!("payload"in t))throw new Error("An event wait is answered with {payload}.");return{payload:t.payload}}throw new Error(`This wait has no known kind (${JSON.stringify(e)}); open its run to answer it.`)}function EC(e,t,n,r){return{command_id:e,run_id:t,type:"resume",payload:{wait_key:n,payload:r},client_id:"abstractcode-web"}}function Vw(e,t){return`Discussion forked from run #${e}. It works in its own workspace ${t.workspace_root}; the automation's files are mounted read-only at ${t.mounted_workspace} for the file tools (shell commands are not sandboxed), and nothing is written back into the automation's session.`}function Kn(e){return zi(e)?e:{status:0,code:"client_error",message:e&&typeof e=="object"&&"message"in e?String(e.message):String(e)}}function Xd(e,t){const n=new Map;for(const r of e)n.set(r.run_id,r);for(const r of t)n.set(r.run_id,r);return Array.from(n.values()).sort((r,i)=>i.index-r.index)}const $C={items:[],loaded:!1,loading:!1,listError:null,error:null,archivedCount:0,archived:null,selectedId:"",detail:null,triggerSources:[],busy:!1,notice:"",emailStatus:null,rowError:null};function AC(e){return async(t,n,r)=>{await ct(_e("commands"),{method:"POST",body:JSON.stringify(EC(e(),t,n,r))})}}class TC{constructor(t,n,r=[1500,4e3]){Mn(this,"state",{...$C});Mn(this,"listeners",new Set);Mn(this,"listSeq",0);Mn(this,"detailSeq",0);Mn(this,"sourcesLoaded",!1);this.client=t,this.answerWaitVia=n,this.followupsMs=r}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}set(t){this.state={...this.state,...t};for(const n of this.listeners)n()}async listAll(t){return(await this.listPages(t)).items}async listPages(t){const n=[];let r,i=0;for(let c=0;c<200;c+=1){const u=await this.client.listAutomations({...t?{status:t}:{},...r?{cursor:r}:{},limit:yc});if(r||(i=NC(u)),n.push(...u.items),!u.next_cursor)return{items:n,archivedCount:i};r=u.next_cursor}throw new Error("GET /api/gateway/automations kept returning next_cursor after 200 pages.")}async loadArchived(){try{const{items:t}=await this.listPages("archived");this.set({archived:t})}catch(t){this.set({archived:this.state.archived??[],listError:Kn(t)})}}async loadEmailStatus(){try{const t=await this.client.getMyEmail();this.set({emailStatus:t&&typeof t=="object"?t:null})}catch{this.set({emailStatus:null})}}async refresh(){const t=++this.listSeq;this.set({loading:!0});try{const{items:n,archivedCount:r}=await this.listPages();if(this.loadEmailStatus(),t!==this.listSeq)return;const i=this.state.detail,c=i?n.find(u=>u.automation_id===i.automationId):void 0;this.set({items:n,archivedCount:r,loaded:!0,loading:!1,listError:null,...i&&c?{detail:{...i,summary:c}}:{}}),this.state.archived!==null&&this.loadArchived(),i&&await this.reloadDetail(i.automationId)}catch(n){if(t!==this.listSeq)return;this.set({loading:!1,loaded:!0,listError:Kn(n)})}}async select(t){var i;const n=t.trim(),r=++this.detailSeq;if(!n){this.set({selectedId:"",detail:null});return}this.set({selectedId:n,notice:"",error:null,...((i=this.state.detail)==null?void 0:i.automationId)!==n?{detail:null}:{}});try{const[c,u]=await Promise.all([this.client.getAutomation(n),this.client.listOccurrences(n,{limit:yc})]);if(r!==this.detailSeq)return;const d=this.state.items.find(h=>h.automation_id===n);if(this.set({detail:{automationId:n,summary:d??c.summary,definition:c.definition,occurrences:Xd([],u.items),nextCursor:u.next_cursor}}),!this.sourcesLoaded){const h=await this.client.listTriggerSources();this.sourcesLoaded=!0,this.set({triggerSources:h.items})}}catch(c){if(r!==this.detailSeq)return;this.set({error:Kn(c)})}}async reloadDetail(t){const[n,r]=await Promise.all([this.client.getAutomation(t),this.client.listOccurrences(t,{limit:yc})]),i=this.state.detail;if(!i||i.automationId!==t)return;const c=this.state.items.find(u=>u.automation_id===t);this.set({detail:{...i,summary:c??n.summary,definition:n.definition,occurrences:Xd(i.occurrences,r.items),nextCursor:i.occurrences.length>r.items.length?i.nextCursor:r.next_cursor}})}async loadMore(){const t=this.state.detail;if(!(!t||!t.nextCursor))try{const n=await this.client.listOccurrences(t.automationId,{cursor:t.nextCursor,limit:yc}),r=this.state.detail;if(!r||r.automationId!==t.automationId)return;this.set({detail:{...r,occurrences:Xd(r.occurrences,n.items),nextCursor:n.next_cursor}})}catch(n){this.set({error:Kn(n)})}}async afterChange(){await this.refresh();for(const t of this.followupsMs)setTimeout(()=>void this.refresh(),t)}async busyCall(t){this.set({busy:!0});try{const n=await t();return await this.afterChange(),n}catch(n){throw Kn(n)}finally{this.set({busy:!1})}}command(t,n,r){return this.busyCall(()=>this.client.sendAutomationCommand(t,{type:n,...r?{command_id:r}:{}}))}async toggleActive(t,n){this.set({rowError:null});try{return await this.command(t.automation_id,Zg(t),n)}catch(r){const i=Kn(r);throw this.set({rowError:{automationId:t.automation_id,error:i}}),i}}async unarchive(t,n){this.set({rowError:null});try{return await this.command(t,_t.unarchive,n)}catch(r){const i=Kn(r);throw this.set({rowError:{automationId:t,error:i}}),i}}revise(t,n,r,i){return this.busyCall(()=>this.client.reviseAutomation(t,{changes:n,...r!==null?{expected_revision:r}:{},...i?{command_id:i}:{}}))}async create(t){this.set({busy:!0,error:null});try{const n=await this.client.createAutomation(t);this.set({notice:`Automation created: ${n.summary.title}.`}),await this.refresh(),await this.select(n.automation_id);for(const r of this.followupsMs)setTimeout(()=>void this.refresh(),r);return n}catch(n){throw Kn(n)}finally{this.set({busy:!1})}}async discuss(t,n,r,i){this.set({busy:!0});try{const c=await this.client.discuss(t,{occurrence_index:n,prompt:r,...i?{request_id:i}:{}});return this.set({notice:Vw(n,c)}),c}catch(c){throw Kn(c)}finally{this.set({busy:!1})}}async seen(t,n){try{await this.client.markSeen(t,n)}catch(r){throw Kn(r)}}answerWait(t,n,r){return this.busyCall(async()=>{var c;const i=(((c=this.state.detail)==null?void 0:c.occurrences)||[]).flatMap(u=>u.waits).find(u=>u.run_id===t&&u.wait_key===n);if(!i)throw new Error(`No loaded wait ${n} on run ${t}; reload the automation.`);await this.answerWaitVia(t,n,CC(i.kind,r))})}rowControls(t){return uo(t,[],this.state.busy)}reportError(t){this.set({error:Kn(t)})}clearNotice(){this.set({notice:"",error:null})}}const yg={[_t.pause]:"Automation paused.",[_t.resume]:"Automation active.",[_t.run_now]:"Run requested.",[_t.stop_current]:"Stop requested.",[_t.archive]:"Automation archived."},RC=[{id:"run_now",label:"Run now",icon:"playCircle",action:"run_now"},{id:"stop_current",label:"Stop",icon:"stop",action:"stop_current"},{id:"revise",label:"Edit",icon:"edit",action:"edit"},{id:"archive",label:"Archive",icon:"archive",action:"archive"}];function wg(e){const t=e&&typeof e=="object"&&"code"in e?e:null;if(t){const n=go(t);return{tone:"error",text:n.title,detail:n.detail}}return{tone:"error",text:e instanceof Error?e.message:String(e)}}function IC(e){const t=e.summary,n=uo(t,e.occurrences,e.busy),r=xy(t,e.nowMs??Date.now()),[i,c]=y.useState(!1),[u,d]=y.useState(null),h=y.useRef(null);y.useEffect(()=>{c(!1),d(null)},[t.automation_id]),y.useEffect(()=>{var C;i&&((C=h.current)==null||C.focus())},[i]);const m=(C,x,j)=>{d({tone:"busy",text:C}),x().then(()=>d({tone:"ok",text:j}),N=>d(wg(N)))},p=(C,x)=>m(x,()=>e.onCommand(C),yg[C]??"Done."),v=C=>{C==="run_now"?p(_t.run_now,"Starting a run…"):C==="stop_current"?p(_t.stop_current,"Stopping…"):C==="revise"?e.onEdit():C==="archive"&&c(!0)},_=t.workspace_root||"",b=e.triggerSources.length?wy(t,e.triggerSources):null;return a.jsxs("header",{className:"code-auto-header","data-automation-id":t.automation_id,"aria-busy":e.busy||(u==null?void 0:u.tone)==="busy",children:[a.jsx("h2",{className:"code-auto-header__title",tabIndex:-1,children:t.title}),a.jsxs("div",{className:"code-auto-header__state",children:[a.jsx(Cw,{variant:"inline",summary:t,busy:e.busy,onToggle:()=>m(t.status==="active"?"Pausing…":"Activating…",e.onToggleActive,yg[t.status==="active"?_t.pause:_t.resume])}),Sw(t)?a.jsx(Nw,{}):null,a.jsx("span",{className:"code-auto-header__timing","data-field":"timing",children:r.line})]}),b?a.jsxs("p",{className:"code-auto-header__warn",role:"note","data-field":"trigger-problem",children:[a.jsx(ne,{name:"warning",size:13})," ",a.jsx("span",{children:b})]}):null,_?a.jsxs("div",{className:"code-auto-header__workspace","data-field":"workspace",children:[a.jsx("span",{className:"code-auto-header__label",children:"Workspace"}),a.jsx("span",{className:"code-auto-header__folder",title:_,children:$0(_)}),a.jsx("button",{type:"button",className:"code-icon-button","data-action":"open-folder","aria-label":"Open folder",title:"Open folder",onClick:e.onOpenFolder,children:a.jsx(ne,{name:"folder",size:15})}),a.jsx("button",{type:"button",className:"code-icon-button","data-action":"copy-path","aria-label":"Copy path",title:"Copy path",onClick:()=>void e.onCopyPath(_).then(C=>d(C?{tone:"ok",text:"Path copied."}:{tone:"error",text:"The browser refused the clipboard."}),C=>d(wg(C))),children:a.jsx(ne,{name:"copy",size:15})})]}):null,e.workspaces?a.jsxs("div",{className:"code-auto-header__workspaces-row","data-section":"workspaces",children:[e.workspaces,e.onEditWorkspaces?a.jsx("button",{type:"button",className:"code-icon-button","data-action":"edit-workspaces","aria-label":"Change workspaces",title:"Change workspaces",onClick:e.onEditWorkspaces,children:a.jsx(ne,{name:"edit",size:15})}):null]}):null,i?a.jsxs("div",{className:"code-auto-header__confirm",role:"group","aria-label":"Confirm archive",children:[a.jsxs("p",{children:["Archive “",t.title,"”? It will not run again; its history stays readable."]}),a.jsxs("div",{className:"code-auto-header__actions",children:[a.jsxs("button",{ref:h,type:"button",className:"code-subtle-button code-danger-button","data-action":"archive-confirm",disabled:!n.archive.enabled,onClick:()=>{c(!1),p(_t.archive,"Archiving…")},children:[a.jsx(ne,{name:"archive",size:14})," ",a.jsx("span",{children:"Archive"})]}),a.jsx("button",{type:"button",className:"code-subtle-button","data-action":"archive-cancel",onClick:()=>c(!1),children:a.jsx("span",{children:"Keep it"})})]})]}):a.jsx("div",{className:"code-auto-header__actions",role:"toolbar","aria-label":"Automation controls",children:RC.map(C=>{const x=n[C.id],j=Oi(C.id,t);return a.jsxs("button",{type:"button",className:`code-subtle-button${C.id==="archive"?" code-danger-button":""}`,"data-action":C.action,disabled:!x.enabled,title:x.enabled?j:`${x.reason??"Not available now."}
|
|
91
|
+
${j}`,onClick:()=>v(C.id),children:[a.jsx(ne,{name:C.icon,size:14})," ",a.jsx("span",{children:C.label})]},C.id)})}),u?a.jsxs("p",{className:`code-auto-header__result is-${u.tone}`,role:u.tone==="error"?"alert":"status","data-field":"result",children:[a.jsx(ne,{name:u.tone==="busy"?"loader":u.tone==="ok"?"check":"error",size:13}),a.jsxs("span",{children:[u.text,u.detail?` ${u.detail}`:""]})]}):null]})}const Hw="abstractcode.automation.panels",_i={occurrences:!0,folder:!0};function MC(e){try{const t=e==null?void 0:e.getItem(Hw);if(!t)return{..._i};const n=JSON.parse(t);if(!n||typeof n!="object")return{..._i};const r=n;return{occurrences:typeof r.occurrences=="boolean"?r.occurrences:_i.occurrences,folder:typeof r.folder=="boolean"?r.folder:_i.folder}}catch{return{..._i}}}function LC(e,t){try{t==null||t.setItem(Hw,JSON.stringify(e))}catch{}}function OC(e,t){return{...e,[t]:!e[t]}}function vg(){try{return typeof window<"u"?window.localStorage:null}catch{return null}}function PC(){const[e,t]=y.useState(()=>MC(vg())),n=y.useCallback(r=>{t(i=>{const c=OC(i,r);return LC(c,vg()),c})},[]);return[e,n]}const Qf=e=>({toggle:`code-detail-${e}-toggle`,region:`code-detail-${e}`});function Gw(e){const t=Qf(e.panel);return a.jsxs("button",{type:"button",className:"code-detail-toggle",id:t.toggle,"data-panel":e.panel,"aria-expanded":e.open,"aria-controls":t.region,onClick:e.onToggle,children:[a.jsx(ne,{name:"chevronDown",size:13}),a.jsx("span",{className:"code-detail-toggle__label",children:e.label}),typeof e.count=="number"?a.jsx("span",{className:"code-detail-toggle__count",children:e.count}):null]})}const DC=".af-auto__timeline",FC=".af-auto__more";function zC(e,t,n){const r=(e==null?void 0:e.querySelector(DC))??null;if(!r||!r.parentNode)return t.parentNode&&t.remove(),!1;r.id!==n&&(r.id=n);const i=(e==null?void 0:e.querySelector(FC))??null,c=i&&i.parentNode===r.parentNode?i:r;return(t.parentNode!==c.parentNode||t.nextSibling!==c)&&c.parentNode.insertBefore(t,c),!0}function UC(e,t){const n=y.useMemo(()=>{if(typeof document>"u")return null;const c=document.createElement("div");return c.className="code-detail-head code-detail-head--occurrences",c},[]),[r,i]=y.useState(!1);return y.useLayoutEffect(()=>{const c=e.current;if(!n||!c||!t){n==null||n.remove(),i(!1);return}const u=Qf("occurrences").region,d=()=>i(zC(c,n,u));d();const h=new MutationObserver(d);return h.observe(c,{childList:!0,subtree:!0}),()=>{h.disconnect(),n.remove()}},[e,n,t]),r?n:null}function Kw(){return ct(_e("voice/defaults"))}function BC(e,t){const n=new URLSearchParams({compact:"true"});return e&&n.set("provider",e),t&&n.set("model",t),ct(_e(`voice/voices?${n.toString()}`))}function WC(e){const[t,n]=y.useState({value:null,failed:!1});return y.useEffect(()=>{if(!e)return;let r=!0;return Kw().then(i=>r&&n({value:i||{},failed:!1})).catch(()=>r&&n({value:null,failed:!0})),()=>{r=!1}},[e]),t}function VC({value:e,onChange:t,defaults:n,connected:r}){return a.jsx(rj,{value:e,onChange:t,fetchCatalog:BC,fetchDefaults:Kw,defaults:n.value??void 0,overrideOwner:"this app",nested:!0,unavailableReason:r?null:"Connect to a gateway to configure voice."})}const _g=18e4;function Jw({runId:e,sessionId:t,capability:n,scope:r,preferences:i,onTranscript:c,onError:u}){var v,_;const d=y.useRef(!0),h=y.useRef(r);h.current=r,y.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]);const m=()=>{if(!d.current||h.current!==r)throw new Error("Voice session changed.")},p=Ob({output_device_id:i.output_device||"",input_device_id:i.input_device||"",input_gain:i.input_gain,volume:i.reply_volume,stop_on_pointerup:!1,tts_stream:((v=n.tts)==null?void 0:v.available)===!0&&e?async function*(b,C){m(),yield*Cb({path:_e(`runs/${encodeURIComponent(e)}/voice/tts/stream`),headers:Kc(),signal:C,body:{text:b,request_id:Ar(),...qk(i)}})}:void 0,transcribe:((_=n.stt)==null?void 0:_.available)===!0&&e?async(b,C)=>{var A;m();const x=Number(((A=n.stt)==null?void 0:A.max_upload_bytes)||0);if(x>0&&b.size>x)throw new Error("Recording exceeds the gateway's upload limit. Try a shorter recording.");const j=C.includes("mp4")?"m4a":C.includes("ogg")?"ogg":C.includes("wav")?"wav":"webm",N=new File([b],`recording.${j}`,{type:C||"audio/webm"}),$=await Ln.attachments_upload(t,N);m();let S;const E=await Promise.race([Ln.audio_transcribe(e,{audio_artifact:$,request_id:Ar(),...Zk(i)}),new Promise((R,z)=>{S=setTimeout(()=>z(new Error(`the gateway did not answer within ${_g/1e3} s`)),_g)})]).finally(()=>clearTimeout(S));return m(),{text:String(E.text||""),provider:E.provider??null,model:E.model??null}}:void 0,on_transcript:b=>{d.current&&h.current===r&&c(b)},on_error:b=>{d.current&&h.current===r&&u(b)}});return y.useEffect(()=>{var b;return p.stop_tts(),(b=p.cancel_voice_ptt_recording)==null||b.call(p),()=>{var C;p.stop_tts(),(C=p.cancel_voice_ptt_recording)==null||C.call(p)}},[r,p.stop_tts,p.cancel_voice_ptt_recording]),p}const HC=350;function GC(e){const[t,n]=y.useState(()=>Date.now());return y.useEffect(()=>{if(!e)return;n(Date.now());const r=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(r)},[e]),t}function KC({voice:e,runId:t,capability:n,route:r="",onSettings:i}){var j,N,$,S,E;const c=y.useRef(!1),u=y.useRef(!1),d=y.useRef(0),h=y.useRef(!0);y.useEffect(()=>(h.current=!0,()=>{h.current=!1,c.current=!1,u.current=!1}),[]);const m=()=>{if(u.current){u.current=!1,e.stop_voice_ptt_recording();return}c.current=!0,d.current=Date.now(),e.start_voice_ptt_recording().then(()=>{var A;!c.current&&!u.current&&e.stop_voice_ptt_recording(),h.current||(A=e.cancel_voice_ptt_recording)==null||A.call(e)})},p=()=>{if(c.current){if(c.current=!1,Date.now()-d.current<HC){u.current=!0;return}e.stop_voice_ptt_recording()}},v=()=>{c.current=!1,u.current=!1,e.stop_voice_ptt_recording()};y.useEffect(()=>(window.addEventListener("pointerup",p),window.addEventListener("pointercancel",p),window.addEventListener("blur",v),()=>{window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",p),window.removeEventListener("blur",v)}),[e.stop_voice_ptt_recording]),y.useEffect(()=>{e.voice_ptt_recording||(u.current=!1)},[e.voice_ptt_recording]);const _=e.voice_ptt_since||0,b=GC(!!_);if(!((j=n.tts)!=null&&j.available)&&!((N=n.stt)!=null&&N.available))return null;const C=!nN(),x=e.voice_ptt_recording?`Recording… ${_?Og(_,b):""}`.trim():e.voice_ptt_busy?vb(_||b,b,r):"";return a.jsxs(a.Fragment,{children:[($=n.stt)!=null&&$.available&&C?a.jsxs(a.Fragment,{children:[a.jsx("button",{className:"code-icon-button","aria-label":"Dictation unavailable","aria-describedby":"code-voice-https-note",title:ig,disabled:!0,children:a.jsx(ne,{name:"mic",size:15})}),a.jsx("span",{id:"code-voice-https-note",className:"code-voice-note",role:"note",children:ig})]}):null,(S=n.stt)!=null&&S.available&&!C?a.jsx("button",{className:"code-icon-button","aria-label":e.voice_ptt_recording?"Recording — tap or release to transcribe":"Hold to dictate",title:t?"Hold to dictate, or tap to start and tap again to stop (Space or Enter on keyboard)":"Start a conversation to enable dictation",disabled:!e.voice_ptt_supported||e.voice_ptt_busy,"aria-pressed":e.voice_ptt_recording,onPointerDown:A=>{A.button===0&&m()},onPointerUp:p,onPointerCancel:p,onKeyDown:A=>{[" ","Enter"].includes(A.key)&&!A.repeat&&(A.preventDefault(),m())},onKeyUp:A=>{[" ","Enter"].includes(A.key)&&(A.preventDefault(),p())},onBlur:()=>{u.current||p()},children:a.jsx(ne,{name:e.voice_ptt_busy?"loader":"mic",size:15,className:e.voice_ptt_busy?"code-loading-spinner":void 0})}):null,e.tts_playback.status!=="idle"?a.jsx("button",{className:"code-icon-button","aria-label":"Stop spoken reply",onClick:e.stop_tts,children:a.jsx(ne,{name:"x",size:14})}):null,i&&((E=n.tts)!=null&&E.available)?a.jsx("button",{className:"code-icon-button","aria-label":"Voice settings",title:"Voice settings",onClick:i,children:a.jsx(ne,{name:"cog",size:14})}):null,x?a.jsx("span",{role:"status",className:"code-voice-status","data-voice-status":!0,children:x}):null]})}const JC=tt.title;function bg(e){return`${JC}: ${e}`}function QC(e){return!!(e&&typeof e=="object"&&!Array.isArray(e)&&Array.isArray(e.folders))}function YC(e){var n,r;const t=(r=(n=e==null?void 0:e.target)==null?void 0:n.input_data)==null?void 0:r.workspace;return QC(t)?t:null}function XC(e,t){const n={...e||{}};return t===null?(delete n.workspace,n):(delete n.workspace_allowed_paths,delete n.workspace_access_mode,n.workspace={posture:t.posture,default_mode:t.default_mode,folders:t.folders.map(r=>({path:r.path,mode:r.mode}))},n)}const qC=3e4,xg=new WeakMap;function ZC(e,t,n=Date.now()){let r=xg.get(e);r||xg.set(e,r=new Map);const i=JSON.stringify(t),c=r.get(i);if(c&&n-c.at<qC)return c.answer;const u=wf(e)(t).then(d=>d.summary);return u.catch(()=>r==null?void 0:r.delete(i)),r.set(i,{at:n,answer:u}),u}function eE(e){const[t,n]=y.useState(null),r=JSON.stringify(e.value);return y.useEffect(()=>{if(!e.connected){n(null);return}let i=!0;return ZC(e.request,e.value).then(c=>i&&n(bg(c))).catch(c=>i&&n(bg(Lf(c)))),()=>{i=!1}},[e.request,e.connected,r,e.refreshKey]),t?a.jsx("span",{className:"code-auto-header__workspaces","data-field":"workspaces",title:t,children:t}):null}function tE(e,t){const n=y.useMemo(()=>new TC(bC(),AC(Ar)),[e]),r=y.useSyncExternalStore(u=>n.subscribe(u),()=>n.state),[i,c]=y.useState(()=>typeof document>"u"||document.visibilityState!=="hidden");return y.useEffect(()=>{const u=()=>c(document.visibilityState!=="hidden");return document.addEventListener("visibilitychange",u),()=>document.removeEventListener("visibilitychange",u)},[]),y.useEffect(()=>{if(!e||!t||!i)return;n.refresh();const u=window.setInterval(()=>void n.refresh(),_C);return()=>window.clearInterval(u)},[n,e,t,i]),{ctl:n,state:r}}function Sf({error:e}){if(!e)return null;const t=go(e);return a.jsxs("p",{className:"code-inline-error",role:"alert","data-code":e.code,children:[a.jsx("strong",{children:t.title})," ",t.detail]})}function nE(e){const t=e.open??!0,n=Uf("automations"),r=e.state,i=SC(r.items),c=r.archived??[],u=r.items.reduce((d,h)=>d+h.attention.pending_waits+h.attention.unseen_count,0);return a.jsxs("section",{className:"code-panel code-automations","aria-label":"Automations","data-open":t?"true":"false",children:[a.jsx(ww,{panel:"automations",open:t,onToggle:()=>{var d;return(d=e.onToggle)==null?void 0:d.call(e)},label:a.jsxs(a.Fragment,{children:["Automations",u?a.jsx("span",{className:"code-auto-badge","data-field":"attention-total",children:u}):null]}),actions:a.jsxs("span",{className:"code-auto-actions",children:[a.jsx("button",{className:"code-icon-button","aria-label":"New automation",title:"New automation (choose a workflow and schedule)",disabled:!e.available.available||e.createDisabled,onClick:e.onNew,children:a.jsx(ne,{name:"plus",size:13})}),a.jsx("button",{className:"code-icon-button","aria-label":"Refresh automations",disabled:!e.available.available||r.loading,onClick:e.onRefresh,children:a.jsx(ne,{name:"refresh",size:13})})]})}),a.jsxs("div",{className:"code-auto-rows",id:n.region,role:"region","aria-labelledby":n.toggle,hidden:!t,children:[!e.discovering&&!e.available.available?a.jsx("p",{className:"code-history-empty",role:"note","data-unavailable":"true",children:e.available.reason}):null,a.jsx(Sf,{error:r.listError}),!r.loaded&&(e.discovering||e.available.available&&r.loading)?a.jsx(ho,{children:"Loading automations…"}):null,e.available.available&&r.loaded&&!r.listError&&!r.items.length?a.jsx("p",{className:"code-history-empty",children:"No automations yet. + lets you choose a workflow and schedule."}):null,i.map(d=>{var h;return a.jsxs(lt.Fragment,{children:[a.jsx(J0,{summary:d,selected:e.selectedId===d.automation_id,busy:r.busy,nowMs:e.nowMs??Date.now(),onSelect:()=>e.onSelect(d.automation_id),onToggleActive:()=>{var m;return(m=e.onToggleActive)==null?void 0:m.call(e,d)}}),((h=r.rowError)==null?void 0:h.automationId)===d.automation_id?a.jsx(Sf,{error:r.rowError.error}):null]},d.automation_id)}),a.jsxs(_w,{list:"automations",count:r.archivedCount,open:e.archivedOpen===!0,onToggle:()=>{var d;return(d=e.onToggleArchived)==null?void 0:d.call(e)},children:[r.archived===null?a.jsx("li",{children:a.jsx(ho,{children:"Loading archived automations…"})}):null,c.map(d=>{var h;return a.jsx(bw,{id:d.automation_id,title:d.title,busy:r.busy,error:((h=r.rowError)==null?void 0:h.automationId)===d.automation_id?go(r.rowError.error).title:void 0,onOpen:()=>e.onSelect(d.automation_id),onUnarchive:()=>{var m;return(m=e.onUnarchive)==null?void 0:m.call(e,d)}},d.automation_id)})]})]})]})}function sE(e,t){const n=e.state.detail;if(!n)return null;const r=n.automationId;return{summary:n.summary,...n.definition?{definition:n.definition}:{},occurrences:n.occurrences,triggerSources:e.state.triggerSources,busy:e.state.busy,...e.state.error?{error:e.state.error}:{},onRevise:(i,c,u)=>e.revise(r,i,c,u==null?void 0:u.command_id),onCommand:(i,c,u)=>e.command(r,i,u==null?void 0:u.command_id),onDiscuss:async(i,c,u)=>{const d=await e.discuss(r,i,c,u==null?void 0:u.request_id);return t.openConversation(d.session_id,d.run_id,Vw(i,d)),d},onSeen:i=>e.seen(r,i),onLoadMore:()=>void e.loadMore(),onOpenRun:i=>t.openRun(i),onOpenWorkspace:i=>t.openWorkspace(i),onAnswerWait:(i,c,u)=>e.answerWait(i,c,u),emailStatus:e.state.emailStatus,...t.openMyEmail?{onOpenMyEmail:()=>{var i;return(i=t.openMyEmail)==null?void 0:i.call(t)}}:{}}}function rE(e){const t=e.last_occurrence,n=e.current_occurrence;return[e.occurrence_count,t?`${t.index}:${t.status}:${t.finished_at??""}`:"",n?`${n.index}:${n.status}`:""].join("|")}function kg(e,t,n){if(t===e)return"Automation folder";const r=n.find(i=>i.run_id===t);return r?`Run #${r.index} folder`:"Run folder"}function aE(e){const t=e.panels.folder,n=Qf("folder");return a.jsxs("div",{className:"code-auto-folder-section","data-open":t?"true":"false","data-folder":e.own?"automation":"run",children:[a.jsx("div",{className:"code-detail-head",children:a.jsx(Gw,{panel:"folder",label:e.title,open:t,onToggle:e.onToggle})}),a.jsx("div",{className:"code-detail-region",id:n.region,hidden:!t,children:e.children})]})}function oE(e){const t=e.ctl.state,n=t.detail,[r,i]=y.useState({automationId:"",runId:""}),c=(n==null?void 0:n.automationId)??"",[u,d]=y.useState(""),h=Jw({scope:c,runId:e.enabled?c:"",sessionId:c,capability:e.voiceCapability||{},preferences:e.voicePreferences||{},onTranscript:()=>{},onError:d});y.useEffect(()=>d(""),[c]);const m=r.automationId===c&&r.runId?r.runId:c,p=sE(e.ctl,{...e.host,openWorkspace:x=>i({automationId:c,runId:x})}),[v,_]=PC(),b=y.useRef(null),C=UC(b,!!(n&&n.occurrences.length));return a.jsxs("main",{className:"code-conversation code-automation-main",id:"code-conversation",tabIndex:-1,"aria-label":"Automation",children:[a.jsxs("div",{className:"code-auto-main-head",children:[a.jsxs("button",{className:"code-subtle-button",onClick:e.onClose,children:[a.jsx(ne,{name:"chat",size:14})," ",a.jsx("span",{children:"Back to the conversation"})]}),h.tts_playback.status!=="idle"?a.jsx("button",{type:"button",className:"code-subtle-button",onClick:h.stop_tts,children:"Stop audio"}):null,t.notice?a.jsx("p",{className:"code-field-help",role:"status",children:t.notice}):null]}),n?a.jsxs("div",{className:"code-auto-main-body",ref:b,"data-occurrences":v.occurrences?"open":"closed",children:[u?a.jsx("p",{className:"code-inline-error",role:"alert",children:u}):null,a.jsx(IC,{summary:n.summary,occurrences:n.occurrences,triggerSources:t.triggerSources,busy:t.busy,nowMs:e.nowMs,onCommand:x=>e.ctl.command(n.automationId,x),onToggleActive:()=>e.ctl.toggleActive(n.summary),onEdit:()=>e.onEdit(n.automationId),workspaces:n.definition?a.jsx(eE,{request:Jc,connected:e.enabled,value:YC(n.definition),refreshKey:n.summary.revision??""}):null,onEditWorkspaces:e.onEditWorkspaces?()=>{var x;return(x=e.onEditWorkspaces)==null?void 0:x.call(e,n.automationId)}:void 0,onOpenFolder:()=>{i({automationId:c,runId:""}),v.folder||_("folder"),window.requestAnimationFrame(()=>{var x,j;return(j=(x=b.current)==null?void 0:x.querySelector(".code-auto-folder-section"))==null?void 0:j.scrollIntoView({block:"nearest"})})},onCopyPath:Gf}),p?a.jsx(ZS,{...p,hideHeader:!0,prepareTarget:e.prepareTarget,workflowPickerOptions:e.workflowPickerOptions,availableTools:e.availableTools,fetchGateway:Mc,messageProps:{...h.tts_supported?{onSpeakToggle:x=>{h.toggle_tts(String(x.id||x.content),x.content)}}:{},getSpeakState:x=>h.tts_playback.key===String(x.id||x.content)?h.tts_playback.status:"idle"}}):null,C?Oc.createPortal(a.jsx(Gw,{panel:"occurrences",label:"Occurrences",count:n.summary.occurrence_count,open:v.occurrences,onToggle:()=>_("occurrences")}),C):null,e.enabled?a.jsx(aE,{panels:v,onToggle:()=>_("folder"),title:kg(n.automationId,m,n.occurrences),own:m===n.automationId,children:a.jsx(zf,{className:"code-auto-folder",fetchGateway:Mc,runId:m,title:kg(n.automationId,m,n.occurrences),refreshKey:rE(n.summary),onClose:m!==n.automationId?()=>i({automationId:c,runId:""}):void 0})}):null]}):t.error?a.jsx(Sf,{error:t.error}):a.jsx(ho,{children:"Loading automation…"})]})}function iE(e){const[t,n]=y.useState(),[r,i]=y.useState(null);y.useEffect(()=>{e.open||i(null)},[e.open]);const[c,u]=y.useState(!1),d=y.useRef(!1),[h,m]=y.useState();return y.useEffect(()=>{e.open||m(void 0)},[e.open]),y.useEffect(()=>{e.open&&(n(void 0),e.ctl.loadEmailStatus())},[e.open]),a.jsx(ok,{open:e.open,onClose:e.onClose,target:h||e.target,availableTools:e.availableTools,initialTools:h?null:e.initialTools,workflowPicker:e.workflowPickerOptions&&(h||e.target)?a.jsx(yy,{target:h||e.target,options:e.workflowPickerOptions,onChange:m}):a.jsx("p",{className:"code-field-help","data-field":"target",children:e.target?`Initially uses ${e.workflowLabel}. Choose the workflow in this form.`:"Choose a workflow in the Workflow panel first."}),initialPrompt:e.initialPrompt,workspaces:a.jsx(gw,{connected:e.connected!==!1,automation:{value:r,onChange:i},idPrefix:"code-new-automation-workspace"}),emailStatus:e.ctl.state.emailStatus,onOpenMyEmail:e.onOpenMyEmail,busy:e.ctl.state.busy||c,error:t,onSubmit:async p=>{var v,_;if(!d.current){d.current=!0,u(!0);try{const b=await((_=e.buildInput)==null?void 0:_.call(e,String(((v=p.target.input_data)==null?void 0:v.prompt)||""),h)),C=b&&e.availableTools!==void 0?Uc(b,Di(p.target.input_data)):b,x=XC(C||p.target.input_data,r),j=await e.ctl.create({...p,target:{...p.target,input_data:x}});return e.onCreated(j.automation_id),e.onClose(),j}catch(b){throw n(Kn(b)),b}finally{d.current=!1,u(!1)}}}})}function lE(e){if(!["ArrowLeft","ArrowRight","Home","End"].includes(e.key))return;const t=[...e.currentTarget.querySelectorAll('button[role="tab"]')].filter(i=>!i.disabled),n=t.indexOf(e.target);if(n<0||!t.length)return;e.preventDefault();const r=e.key==="Home"?0:e.key==="End"?t.length-1:(n+(e.key==="ArrowRight"?1:-1)+t.length)%t.length;t[r].focus(),t[r].click()}function cE(e){var h,m;const t=Object.keys(((h=e.schema)==null?void 0:h.properties)||{}),n=((m=e.schema)==null?void 0:m.required)||[],r=[e.promptProperty||"prompt","context","messages","attachments"],i=["provider","model","tools","skills","max_iterations","use_context","use_session_history"],c=Ew(e.schema).map(p=>[p.provider,p.model,p.reasoning].filter(v=>!!v)),u=new Set(t.filter(p=>n.includes(p)&&!r.includes(p)));for(const p of c)p.some(v=>u.has(v))&&p.forEach(v=>u.add(v));const d=new Set(t.filter(p=>!u.has(p)&&!r.includes(p)&&!i.includes(p)));for(const p of c)p.some(v=>d.has(v))&&p.forEach(v=>d.add(v));return a.jsxs(a.Fragment,{children:[a.jsxs("section",{className:"code-settings-section","aria-label":"Automatic agent configuration",children:[a.jsx("h3",{children:u.size?"Workflow inputs":"Ready to chat"}),a.jsxs("p",{className:"code-field-help",children:[u.size?"This workflow asks for the inputs below before it can run.":"No setup required. Write a message and press Send."," ","Optional values use workflow and Gateway defaults. Use Settings for model, workspace and tool permission overrides."]})]}),u.size?a.jsx(Nf,{...e,omit:t.filter(p=>!u.has(p)),rawObject:!1}):null,d.size?a.jsxs("details",{className:"code-advanced-inputs",children:[a.jsxs("summary",{children:["Advanced workflow inputs"," ",a.jsx("span",{className:"code-muted",children:"Optional"})]}),a.jsx("p",{className:"code-field-help",children:"Leave these unset to use the workflow and Gateway defaults. Only change them when you need a specific override."}),a.jsx(Nf,{...e,omit:t.filter(p=>!d.has(p)),rawObject:!1})]}):null]})}function uE(e,t,n){var i;if(!n.length)return t;const r=(i=e==null?void 0:e.properties)==null?void 0:i.attachments;if(!r||r.type&&r.type!=="array")throw new Error("This workflow does not declare an attachments input. Remove the attached files, or choose an agent or workflow that accepts them.");return{...t,attachments:[...Array.isArray(t.attachments)?t.attachments:[],...n]}}function dE(e){if(!e.trim())return{ok:!0,value:{}};let t;try{t=JSON.parse(e)}catch{return{ok:!1,error:"Enter valid JSON."}}return t===null||typeof t!="object"||Array.isArray(t)?{ok:!1,error:"The workflow input payload must be a JSON object."}:{ok:!0,value:t}}function Nf({schema:e,values:t,onChange:n,disabled:r=!1,omit:i=[],rawObject:c=!1,onEditorError:u,defaultModel:d}){const[h,m]=lt.useState("fields"),p=Object.entries((e==null?void 0:e.properties)||{}).filter(([x])=>!i.includes(x)),v=Ew(e),_=new Set(v.flatMap(x=>[x.provider,x.model,x.reasoning].filter(Boolean))),b=x=>{m(x),u==null||u("")},C=p.length?a.jsx("div",{className:"code-input-fields",children:p.map(([x,j])=>{const N={...j,type:a1(j)},$=v.find(z=>z.provider===x);if($)return a.jsxs("section",{className:"code-settings-section",children:[a.jsx("h3",{children:$.title}),a.jsx(Pc,{value:{provider:String(t[$.provider]||""),model:String(t[$.model]||""),...$.reasoning?{reasoning:String(t[$.reasoning]||"")}:{}},onChange:z=>n({...t,[$.provider]:z.provider,[$.model]:z.model,...$.reasoning?{[$.reasoning]:z.reasoning||""}:{}}),...l1($.provider,N["x-abstract-type"]),fetchModelCapabilities:$.reasoning?Vf.fetchModelCapabilities:void 0,effectiveDefault:$.provider==="provider"?d:void 0,defaultHint:$.provider==="provider"&&(d!=null&&d.model)?`Gateway default: ${d.provider} · ${d.model}. Workflow defaults take precedence.`:"Empty routing pins inherit the Gateway defaults. Registered workflow defaults are loaded above any Gateway default.",disabled:r})]},x);if(_.has(x))return null;const S=`workflow-input-${x}`,E=String(N.title||x).replace(/_/g," "),A=Array.isArray(e==null?void 0:e.required)&&e.required.includes(x),R=z=>{const L={...t};z===void 0?delete L[x]:L[x]=z,n(L)};return a.jsxs("div",{className:"code-field",children:[a.jsxs("label",{htmlFor:S,children:[E,A?a.jsx("span",{"aria-label":"required",children:" *"}):null]}),N.enum?a.jsxs("select",{id:S,value:t[x]===void 0?"":JSON.stringify(t[x]),disabled:r,onChange:z=>R(z.target.value?JSON.parse(z.target.value):void 0),children:[a.jsxs("option",{value:"",children:["Choose ",E]}),N.enum.map(z=>a.jsx("option",{value:JSON.stringify(z),children:String(z)},JSON.stringify(z)))]}):N.type==="boolean"?a.jsxs("select",{id:S,value:t[x]===void 0?"":String(t[x]),disabled:r,onChange:z=>R(z.target.value?z.target.value==="true":void 0),children:[a.jsx("option",{value:"",children:"Workflow default"}),a.jsx("option",{value:"true",children:"Yes"}),a.jsx("option",{value:"false",children:"No"})]}):N.type==="number"||N.type==="integer"?a.jsx("input",{id:S,type:"number",value:typeof t[x]=="number"?String(t[x]):"",min:N.minimum,max:N.maximum,step:N.type==="integer"?1:"any",disabled:r,onChange:z=>R(z.target.value===""?void 0:Number(z.target.value))}):N.type==="object"||N.type==="array"?a.jsx(hE,{id:S,value:t[x],disabled:r,onChange:R},x):a.jsx("textarea",{id:S,rows:2,value:String(t[x]??""),disabled:r,onChange:z=>R(z.target.value)}),N.description?a.jsx("p",{className:"code-field-help",id:`${S}-help`,children:N.description}):null]},x)})}):a.jsx("p",{className:"code-muted",children:"This workflow declares no named top-level fields. Use JSON payload mode to provide registered or additional inputs."});return c?a.jsxs("div",{children:[a.jsxs("div",{className:"code-settings-tabs",role:"tablist","aria-label":"Workflow input editor",onKeyDown:lE,children:[a.jsx("button",{type:"button",role:"tab",tabIndex:h==="fields"?0:-1,"aria-selected":h==="fields",onClick:()=>b("fields"),children:"Fields"}),a.jsx("button",{type:"button",role:"tab",tabIndex:h==="json"?0:-1,"aria-selected":h==="json",onClick:()=>b("json"),children:"JSON payload"})]}),h==="json"?a.jsxs(a.Fragment,{children:[a.jsx(fE,{value:t,disabled:r,onChange:n,onError:x=>u==null?void 0:u(x)}),a.jsx("p",{className:"code-field-help",children:"The complete object is sent unchanged. Nested and additional properties are allowed here; the gateway validates it against the registered workflow schema."})]}):C]}):C}function fE({value:e,onChange:t,onError:n,disabled:r}){const[i,c]=lt.useState(JSON.stringify(e,null,2)),[u,d]=lt.useState(""),h=lt.useRef(e);return lt.useEffect(()=>{e!==h.current&&(h.current=e,c(JSON.stringify(e,null,2)),d(""),n(""))},[e,n]),a.jsxs("div",{className:"code-field",children:[a.jsx("label",{htmlFor:"workflow-input-payload",children:"Complete input object"}),a.jsx("textarea",{id:"workflow-input-payload",className:"code-mono",rows:12,value:i,disabled:r,"aria-invalid":!!u,onChange:m=>{c(m.target.value);const p=dE(m.target.value);if(!p.ok){d(p.error),n(p.error);return}h.current=p.value,d(""),n(""),t(p.value)}}),u?a.jsx("span",{role:"alert",className:"code-error-text",children:u}):null]})}function hE({id:e,value:t,onChange:n,disabled:r}){const[i,c]=lt.useState(t===void 0?"":JSON.stringify(t,null,2)),[u,d]=lt.useState(""),h=lt.useRef(t);return lt.useEffect(()=>{t!==h.current&&(h.current=t,c(t===void 0?"":JSON.stringify(t,null,2)),d(""))},[t]),a.jsxs(a.Fragment,{children:[a.jsx("textarea",{id:e,className:"code-mono",rows:4,value:i,disabled:r,"aria-invalid":!!u,onChange:m=>{c(m.target.value);try{const p=m.target.value.trim()?JSON.parse(m.target.value):void 0;h.current=p,n(p),d("")}catch{h.current=m.target.value,n(m.target.value),d("Enter valid JSON.")}}}),u?a.jsx("span",{role:"alert",className:"code-error-text",children:u}):null]})}function mE({attachments:e,uploads:t,sizes:n,onRemoveAttachment:r,onRemoveUpload:i,onRetryUpload:c}){return a.jsxs("div",{className:"code-attachments",role:"list","aria-label":"Attached files",children:[e.map((u,d)=>{const h=u.filename||u.path||"Attachment",m=typeof u.size_bytes=="number"?u.size_bytes:n==null?void 0:n.get(u.$artifact),p=typeof m=="number"?Ii(m):"";return a.jsxs("div",{role:"listitem",tabIndex:0,className:"code-attachment is-attached","aria-label":`${h}${p?`, ${p}`:""}, attached`,children:[a.jsx("span",{className:"code-attachment__icon","aria-hidden":"true",children:a.jsx(ne,{name:"paperclip",size:13})}),a.jsxs("span",{className:"code-attachment__body",children:[a.jsx("span",{className:"code-attachment__name",title:h,children:h}),p?a.jsx("span",{className:"code-attachment__meta",children:p}):null]}),a.jsx("button",{type:"button",className:"code-attachment__action","aria-label":`Remove ${h}`,title:`Remove ${h}`,onClick:()=>r(d),children:a.jsx(ne,{name:"x",size:12})})]},`${u.$artifact}:${d}`)}),t.map(u=>{const d=u.status==="queued"||u.status==="uploading",h=u.status==="queued"?`Waiting · ${Ii(u.size)}`:u.status==="uploading"?`Uploading · ${Ii(u.size)}`:u.message||"Not attached",m=u.status==="queued"?"waiting to upload":u.status==="uploading"?"uploading":`not attached: ${h}`;return a.jsxs("div",{role:"listitem",tabIndex:0,className:`code-attachment is-${u.status}`,"aria-label":`${u.name}, ${m}`,"aria-busy":d||void 0,children:[a.jsx("span",{className:"code-attachment__icon","aria-hidden":"true",children:d?a.jsx("span",{className:"code-attachment__spinner"}):a.jsx(ne,{name:"warning",size:13})}),a.jsxs("span",{className:"code-attachment__body",children:[a.jsx("span",{className:"code-attachment__name",title:u.name,children:u.name}),a.jsx("span",{className:"code-attachment__meta",children:h})]}),u.status==="failed"?a.jsxs("button",{type:"button",className:"code-attachment__action code-attachment__retry","aria-label":`Retry ${u.name}`,title:"Retry upload",onClick:()=>c(u.id),children:[a.jsx(ne,{name:"refresh",size:12}),a.jsx("span",{children:"Retry"})]}):null,a.jsx("button",{type:"button",className:"code-attachment__action","aria-label":`Remove ${u.name}`,title:`Remove ${u.name}`,onClick:()=>i(u.id),children:a.jsx(ne,{name:"x",size:12})})]},u.id)})]})}function pE({active:e,paused:t,snapshot:n,onRevokeApproval:r,onCommand:i,onActivity:c,onInteraction:u,permissionsAll:d}){const h=y.useMemo(()=>OS(n),[n]),m=y.useMemo(()=>h.tone==="working"?wN(n.records.map(j=>j.record)):"",[h.tone,n.records]),p=m||h.detail,[v,_]=y.useState(Date.now);y.useEffect(()=>{if(!e)return;const j=window.setInterval(()=>_(Date.now()),1e3);return()=>window.clearInterval(j)},[e]);const b=Date.parse(h.startedAt||""),C=Number.isFinite(b)?Math.max(0,Math.floor((v-b)/1e3)):null,x=C===null?"":C<60?`${C}s`:`${Math.floor(C/60)}m ${C%60}s`;return a.jsxs("div",{className:`code-run-strip code-run-strip--${h.tone}`,children:[a.jsxs("div",{className:"code-run-strip__activity",role:"status","aria-live":"polite",children:[a.jsx("span",{className:"code-run-strip__icon","aria-hidden":"true",children:a.jsx(ne,{name:h.tone==="working"?"loader":h.tone==="success"?"check":h.tone==="error"?"error":h.tone==="waiting"?"history":"info",size:15})}),u&&h.tone==="waiting"?a.jsxs("button",{className:"code-run-strip__attention",onClick:u,title:"Go to the pending request",children:[a.jsx("strong",{children:h.label}),a.jsx(ne,{name:"chevronRight",size:12})]}):a.jsx("strong",{children:h.label}),a.jsx("span",{className:`code-run-strip__detail${m?" code-run-strip__detail--live":""}`,title:p,children:p})]}),a.jsxs("span",{className:"code-run-strip__metrics","aria-label":"Run activity metrics",children:[e&&x?a.jsx("span",{children:x}):null,h.toolCalls?a.jsxs("span",{children:[h.toolCalls," ",h.toolCalls===1?"tool":"tools"]}):null,h.totalTokens!==void 0?a.jsxs("span",{children:[h.totalTokens.toLocaleString()," tokens"]}):null]}),e?a.jsxs(a.Fragment,{children:[a.jsxs("button",{onClick:()=>i(t?"resume":"pause"),children:[t?"Resume":"Pause"," "]}),a.jsx("button",{onClick:()=>i("conclude"),children:"Conclude"})]}):null,a.jsxs("button",{onClick:c,children:["View activity ",a.jsx(ne,{name:"chevronRight",size:12})]}),d?a.jsxs("div",{className:"code-run-strip__consent",children:[a.jsx(ne,{name:"check",size:13}),a.jsx("span",{children:"Permissions: all · enabled tools only"}),a.jsx("button",{onClick:r,children:"Revoke"})]}):null]})}function qd(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function wc(e){return typeof e=="string"?e.trim():""}function gE(e){const t=qd(e),n=qd(t==null?void 0:t.gateway),r=qd(n==null?void 0:n.principal);return JSON.stringify([wc((t==null?void 0:t.gateway_url)??(t==null?void 0:t.gatewayUrl)),wc((r==null?void 0:r.tenant_id)??(r==null?void 0:r.tenantId)),wc((r==null?void 0:r.runtime_id)??(r==null?void 0:r.runtimeId)),wc((r==null?void 0:r.user_id)??(r==null?void 0:r.userId))||"session"])}function jg(e,t){return!!e.sourceRunId&&e.sessionId===t.sessionId&&e.sessionId===t.snapshotSessionId&&e.sourceRunId===t.runId&&e.sourceRunId===t.snapshotRunId&&e.authEpoch===t.authEpoch}function yE(e){const t=typeof e=="string"?e.trim().toLowerCase():"";return["completed","complete","done"].includes(t)?"advance":["failed","error","cancelled","canceled"].includes(t)?"pause":"wait"}function wE(e,t,n){return e.flatMap(r=>r.id===t.id?[]:r.sessionId!==t.sessionId||r.authEpoch!==t.authEpoch||r.sourceRunId!==t.sourceRunId?[r]:[{...r,sourceRunId:n}])}function Sg(){return new DOMException("The conversation changed before the run was attached.","AbortError")}const vE=ib("abstractcode","0.11.1"),Zd=e=>["completed","failed","cancelled","canceled"].includes(e);function Ng(){const e=new URLSearchParams(window.location.hash.replace(/^#/,""));return{sessionId:e.get("session")||Ar(),runId:e.get("run")||""}}function bi(e,t=""){const n=new URLSearchParams({session:e});t&&n.set("run",t),window.history.replaceState(null,"",`#${n}`)}function _E(){var nl,sl,Lo,rl,al,ol,il,ll,cl,ul,Ra,cr,dl,Oo,Po,Do,Fo,zo,Ps,fl;const e=G_({appName:"AbstractCode",variant:"blocking"}),t=e.connected?gE(e.status):"",n=y.useCallback(()=>{e.refresh()},[e.refresh]),r=P1(t,n),[i,c]=gb("abstractcode",{defaults:{theme:"observer-night"}}),[u,d]=y.useState(!1),[h,m]=y.useState(!1),[p,v]=y.useState(!1),[_,b]=y.useState(0),C=y.useCallback(()=>b(T=>T+1),[]),[x,j]=y.useState(),N=y.useCallback(()=>{j(void 0),ct(_e("about")).then(T=>j({ok:!0,value:T})).catch(T=>j({ok:!1,status:T==null?void 0:T.status,message:vt(T)}))},[]),[$,S]=y.useState({});y.useEffect(()=>{try{S(JSON.parse(localStorage.getItem(`abstractcode.voice:${t}`)||"{}"))}catch{S({})}Or(),d(!1)},[t]);const E=T=>{if(S(T),t)try{localStorage.setItem(`abstractcode.voice:${t}`,JSON.stringify(T))}catch{}},[A,R]=y.useState(cs),z=y.useRef(A);z.current=A;const L=f1(A.streamReplies,r.streaming),[J,V]=y.useState(cs.workflow),O=y.useMemo(()=>k1(r.executable.data),[r.executable.data]),ee=y.useCallback(()=>R(T=>({...T,workflow:Ot})),[]),P=eN(t,ee),Z=P.state.status==="ok",U=P.state.status==="ok"?X1(P.state.row.value,O):A.workflow,te=y.useRef(U);te.current=U;const se=y.useMemo(()=>x1(r.gatewayDefault,r.workflows),[r.gatewayDefault,r.workflows]),G=J===Ot?se:r.workflows.find(T=>T.id===J)||O.find(T=>T.id===J)||null,[ce,re]=y.useState(null),D=Bf(G),[I,W]=y.useState(Ng),[me,q]=y.useState(""),[fe,de]=y.useState(""),[ae,we]=y.useState(""),[Pe,Qe]=y.useState(!1),Ye=y.useRef(!1),[Ne,He]=y.useState([]),[ue,Ue]=y.useState([]),ie=y.useRef(new Set),Ae=y.useRef(new Map),[ge,Y]=y.useState(""),pe=y.useRef(null),[ve,Ee]=y.useState(),Oe=y.useRef(ve);Oe.current=ve;const[Be,Xe]=y.useState(!1),[mt,Tt]=y.useState(""),[Es,Lr]=y.useState(0),[Rt,$s]=y.useState({}),[ha,ma]=y.useState(""),[pt,pa]=y.useState(null),[On,ga]=y.useState(""),[cn,us,Ys]=cC(),As=cn!==null,Or=T=>{Ys&&us(null)},wo=T=>{d(!1),jt(!1),us(T)},Ts=T=>{T?wo("workflow"):cn==="workflow"&&us(null)},ya=kc(Mi.md),Vi=kc(Mi.lg),Rs=t0(Vi,ya),vo=y.useRef(Rs),Pr=l0(60),[ds,jt]=y.useState(!1),[_o,Xs]=N0(),[fs,Dr]=T0(),wa=kC(r.capabilities),{ctl:un,state:Et}=tE(t,e.connected&&wa.available);y.useEffect(()=>{fs.automations&&Et.loaded&&Et.archivedCount>0&&Et.archived===null&&un.loadArchived()},[fs.automations,Et.loaded,Et.archivedCount,Et.archived,un]);const[Qt,dn]=y.useState(!1),[va,bo]=y.useState(!1),xo=y.useRef(""),[_a,Hi]=y.useState(""),ko=y.useRef(null),[qs,Xc]=y.useState("steer"),[Is,nt]=y.useState([]),[jo,Cn]=y.useState(!1),[So,Zs]=y.useState([]),Fr=y.useMemo(()=>Aw(r.tools,A.tools,A.permissions),[r.tools,A.tools,A.permissions]),ba=y.useRef(null),xa=y.useMemo(()=>{var je,Te;const T=((je=ba.current)==null?void 0:je.runId)===I.runId?ba.current.input:null;if(I.runId&&!pt&&!T)return{enabledTools:[],autoApproveTools:[]};const X=pt?pt.input_data:T,be=V1(Fr,(Te=X==null?void 0:X._runtime)==null?void 0:Te.allowed_tools);return{...be,autoApproveTools:A.toolsCustomized||A.permissions!=="default"?be.autoApproveTools:[]}},[Fr,pt,I.runId,A.toolsCustomized,A.permissions]),fn=`${t}:${I.sessionId}:${I.runId}`,Gi=y.useRef(fn);Gi.current=fn;const hn=y.useRef(null),[Ki,qc]=y.useState({scope:"",notes:[]}),Zc=y.useMemo(()=>D1({onDeltaError:T=>{const X=Gi.current,be=p1(T,hn.current);qc(je=>({scope:X,notes:g1(je.scope===X?je.notes:[],be)}))}}),[]),{controller:Pn,snapshot:We}=GS({transport:Zc,runId:I.runId,enabled:e.connected,onAuthError:n,clientId:"abstractcode-web",authScopeKey:t,toolApprovalPolicy:xa}),Bt=!!I.runId&&!Zd(We.status)&&We.status!=="idle",er=((nl=We.run)==null?void 0:nl.paused)===!0||We.status==="paused",hs=Bt||Pe,ka=We.loading&&So.length?So:We.messages,tr=ka[ka.length-1];hn.current=tr!=null&&tr.id?String(tr.id):null;const Qn=y1(ka,[h1(A.streamReplies,r.streaming,ka),...Ki.scope===fn?Ki.notes:[]]),zr=((Lo=(sl=r.capabilities)==null?void 0:sl.assistant)==null?void 0:Lo.voice)||{},nr=WC(e.connected),Yn=Jw({scope:`${t}:${I.sessionId}:${I.runId}:${Qt}`,runId:t?I.runId:"",sessionId:I.sessionId,capability:zr,preferences:$,onTranscript:T=>q(X=>X?`${X.trimEnd()}
|
|
92
|
+
${T}`:T),onError:de}),Xn=[...Qn].reverse().find(T=>T.role==="assistant"),Ke=Xn?String(Xn.id||Xn.content):"",ja=y.useRef({scope:"",id:""});y.useEffect(()=>{const T=`${t}:${I.sessionId}`,X=ja.current;if(X.scope!==T){ja.current={scope:T,id:Ke};return}!Ke||Ke===X.id||hs||(ja.current={scope:T,id:Ke},$.read_aloud===!0&&Yn.tts_supported&&(Xn!=null&&Xn.content)&&Yn.toggle_tts(Ke,Xn.content))},[t,I.sessionId,Ke,hs,$.read_aloud,Yn.tts_supported]);const No=BS(We),mn=y.useMemo(()=>e0(No,Pn,{records:We.records,currentRun:We.run,onPermissionsAll:async()=>{R(T=>({...T,permissions:"all"}))}}),[No,We.records,We.run,Pn]),Co=!!mn&&qs==="steer",Dn=D?"prompt":o1(ve),Eo=D||!!(Dn&&!((rl=ve==null?void 0:ve.required)!=null&&rl.some(T=>T!==Dn))),ms=String(((al=pt==null?void 0:pt.workspace)==null?void 0:al.workspace_root)||((il=(ol=We.run)==null?void 0:ol.vars)==null?void 0:il.workspace_root)||""),ps=y.useMemo(()=>{var T;return z0(r.workflows,{inputData:pt,runWorkflowId:(T=We.run)==null?void 0:T.workflow_id})},[r.workflows,pt,(ll=We.run)==null?void 0:ll.workflow_id]),En=I.runId&&pt&&!r.loading&&We.run&&!ps&&Hf(pt)!=="gateway_default"?"This conversation's exact workflow version is unavailable. Restore it in the gateway, or start a new conversation with an available workflow.":"",bt=r.sessions.find(T=>T.sessionId===I.sessionId),$n=(bt==null?void 0:bt.prompt)||((cl=Qn.find(T=>T.role==="user"))==null?void 0:cl.content)||"New conversation",sr=xC((ul=e.status)==null?void 0:ul.gateway_url),Ms=sr?()=>{window.open(sr,"_blank","noopener,noreferrer")}:void 0,Fn={...Ms?{openMyEmail:Ms}:{},openConversation:(T,X,be)=>{xo.current=be||"",Ur(T,X)},openRun:T=>{ct(_e(`runs/${encodeURIComponent(T)}`)).then(X=>{if(!(X!=null&&X.session_id))throw new Error(`The gateway reported no session for run ${T}.`);Ur(X.session_id,T)}).catch(X=>un.reportError(X))}},Ji=T=>{(!Qt||Et.selectedId!==T)&&(dn(!0),un.select(T)),jt(!1),d(!1),us("workflow")},Qi=T=>{Ji(T),us("workspace")},rr=async T=>{const X=T.flow_id==="@default"?se:r.workflows.find(at=>`${at.bundleId}@${at.bundleVersion}`===("bundle_ref"in T?T.bundle_ref:"")&&at.flowId===T.flow_id);if(!X)throw new Error("The selected workflow is no longer available. Refresh the workflow list.");const be=await Jd(X);if(!be)throw new Error("Workflow inputs could not be checked. Refresh the workflow list and try again.");const je={...Ks(be),...T.input_data},Te=Vd(be,je);if(Te.length)throw new Error(`${Te.join(" ")} Configure a new automation from that workflow's input form, or choose a compatible workflow.`);return{...T,input_data:je}},Yi=((Ra=Et.detail)==null?void 0:Ra.summary.title)||"Automation",Sa=y.useRef(""),gs=y.useRef(t),$t=y.useRef(0);gs.current!==t&&($t.current+=1,gs.current=t);const $o=y.useRef(!1),St=y.useRef(I);St.current=I,y.useEffect(()=>{if(Ye.current=!1,Qe(!1),Ue([]),de(""),we(""),!t){He([]),q(""),nt([]),Cn(!1),Zs([]),R(cs);return}if(Sa.current&&Sa.current!==t){const X={sessionId:Ar(),runId:""};W(X),bi(X.sessionId)}Sa.current=t,$o.current=!0;const T=Rw(t);R(T),V(T.workflow)},[t]),y.useEffect(()=>{if(t){if($o.current){$o.current=!1;return}Q1(t,A)}},[A,t]),y.useEffect(()=>{if(r.loading||!r.workflows.length)return;const T=N1({selection:J,preferred:U,visible:O,workflows:r.workflows,runId:I.runId});T!==J&&V(T)},[r.loading,r.workflows,O,J,U,I.runId]);const ar=P.state.status==="ok"?`${t}|${P.state.row.value??""}|${O.length}`:"";y.useEffect(()=>{!ar||I.runId||!O.length||V(te.current)},[ar]),y.useEffect(()=>{let T=!0;if($s({}),ma(""),Ee(void 0),Tt(""),!G){Xe(!1);return}return Xe(!0),Jd(G).then(X=>{T&&(Ee(X),$s(Ks(X)))}).catch(X=>{T&&Tt(vt(X))}).finally(()=>{T&&Xe(!1)}),()=>{T=!1}},[G==null?void 0:G.id,Es]),y.useEffect(()=>{if(pa(null),ga(""),!t||!I.runId)return;const T=new AbortController;return ct(_e(`runs/${encodeURIComponent(I.runId)}/input_data`),{signal:T.signal}).then(X=>{pa(X)}).catch(X=>{T.signal.aborted||ga(vt(X))}),()=>T.abort()},[I.runId,t]),y.useEffect(()=>{pt&&pt.flow_id===(G==null?void 0:G.flowId)&&ve&&$s({...Ks(ve),...s1(ve,pt.input_data)})},[pt,ve,G==null?void 0:G.flowId]),y.useEffect(()=>{!I.runId&&e.connected&&(bt!=null&&bt.latestRunId)&&W(T=>({...T,runId:bt.latestRunId}))},[I.runId,e.connected,bt==null?void 0:bt.latestRunId]),y.useEffect(()=>{bi(I.sessionId,I.runId),Ye.current=!1,Qe(!1),Ue([]),He([]),$s(Ks(Oe.current)),Zs([]),we(xo.current),xo.current="",de(""),nt([]),Cn(!1)},[I.sessionId]),y.useEffect(()=>{const T=()=>{const X=Ng();Ye.current=!1,Qe(!1),Ue([]),nt([]),Cn(!1),q(""),W(X)};return window.addEventListener("hashchange",T),()=>window.removeEventListener("hashchange",T)},[]),y.useEffect(()=>{!I.runId||!Zd(We.status)||r.refresh()},[I.runId,We.status]),y.useEffect(()=>{if(!I.runId||!pt)return;const T=C1({restoredInputs:pt,restored:ps});T&&V(T)},[I.runId,pt,ps==null?void 0:ps.id]);const ys=I.runId?E1(pt):"",ws=y.useCallback(()=>{const T={sessionId:Ar(),runId:""};W(T),V(te.current),bi(T.sessionId),q(""),nt([]),Cn(!1),jt(!1),dn(!1)},[]),Ur=y.useCallback((T,X)=>{Ye.current=!1,Qe(!1),Ue([]),W({sessionId:T,runId:X}),bi(T,X),jt(!1),nt([]),Cn(!1),q(""),dn(!1)},[]);y.useEffect(()=>{const T=vo.current;vo.current=Rs,T!==Rs&&jt(X=>n0(X,Rs))},[Rs]),hw(ds,ya,()=>document.querySelector(".code-sidebar"),()=>document.querySelector(".code-mobile-close")),y.useEffect(()=>{const T=X=>{var je;if(s0({key:X.key,defaultPrevented:X.defaultPrevented,overlayOpen:As||u||va||h||r0(),sidebarOpen:ds})==="sidebar"){jt(!1),(je=document.querySelector(".code-mobile-nav"))==null||je.focus();return}(X.metaKey||X.ctrlKey)&&(X.key.toLowerCase()==="k"&&(X.preventDefault(),Or(),d(!1),jt(!0),window.setTimeout(()=>{var Te;return(Te=ko.current)==null?void 0:Te.focus()},0)),X.key.toLowerCase()==="n"&&X.shiftKey&&(X.preventDefault(),ws()))};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[ws,ds,va,As,u,h]);function Ao(T,X,be=[],je=!1,Te=G,at=ve){const Nt=H0({workflow:Te||void 0,inputSchema:at,schemaInputs:X,prompt:T,promptProperty:Dn,model:A,reasoning:A.reasoning||void 0,speculation:A.speculation,streamReplies:L,systemPromptExtra:A.system||void 0,attachments:be,limits:{maxIterations:A.maxIterations?Number(A.maxIterations):void 0,maxTokens:A.maxTokens?Number(A.maxTokens):void 0},workspace:ms?{root:ms}:void 0,tools:A.toolsCustomized?Fr.enabledTools:void 0,toolPolicy:A.toolsCustomized||A.permissions!=="default"?{autoApproveTools:[],requireApprovalTools:Fr.enabledTools}:void 0,skills:A.skills.length?A.skills:void 0});return je&&(delete Nt.workspace_root,delete Nt.workspace_access_mode,delete Nt.workspace_allowed_paths,delete Nt.workspace,Nt._runtime&&typeof Nt._runtime=="object"&&delete Nt._runtime.tool_policy),Nt}async function or(T){if(Ye.current)throw new Error("A turn is already being submitted.");if(!e.connected)throw new Error("Connect to your gateway first.");if(J===Ot&&r.gatewayDefault.status==="unavailable")throw new Error(`Gateway default: ${r.gatewayDefault.reason}. Choose a workflow from the list.`);if(!G)throw new Error("Choose a workflow first.");if(!r.policy)throw new Error("Workspace policy is unavailable. Reconnect or refresh before starting.");if(I.runId&&(!pt||On))throw new Error(On||"Wait for the gateway to restore this conversation's workspace.");if(En)throw new Error(En);if(Be||mt)throw new Error(mt||"Wait for workflow inputs to load.");if(ha)throw Ts(!0),new Error(ha);const X=cN(ue);if(X)throw new Error(X);if(Bt)throw new Error("The current run is still active.");if(!D&&T.trim()&&!Dn)throw Ts(!0),new Error("This workflow uses structured inputs. Configure its inputs, then select Run workflow.");const be={...Ks(ve),...Rt,...Dn&&T.trim()?{[Dn]:T.trim()}:{}},je=D?be:uE(ve,be,Ne);for(const[sn,Yt]of[["Iteration limit",A.maxIterations],["Context token limit",A.maxTokens]])if(Yt&&(!Number.isInteger(Number(Yt))||Number(Yt)<=0))throw new Error(`${sn} must be a positive whole number.`);Ye.current=!0,Qe(!0),de(""),we("");const Te=I.sessionId,at=I.runId,Nt=t,qn=$t.current;let Pt="";try{const sn=Ao(T,je,Ne),Yt=Vd(ve,sn);if(Yt.length)throw Ts(!0),new Error(Yt.join(" "));const Zn=$1({selection:J,workflow:G,sessionId:Te,input:sn}),es=await ct(_e("runs/start"),{method:"POST",body:JSON.stringify(Zn)});if(!es.run_id)throw new Error("The gateway did not return a run identifier.");if(St.current.sessionId!==Te||St.current.runId!==at||gs.current!==Nt||$t.current!==qn)throw Sg();return Pt=String(es.run_id),ba.current={runId:Pt,input:sn},re({runId:Pt,...A1(es.resolved_workflow)}),Zs([...Qn,...T.trim()?[{id:`pending:${es.run_id}`,role:"user",content:T.trim()}]:[]]),W({sessionId:Te,runId:es.run_id}),bi(Te,es.run_id),q(""),He([]),Ts(!1),es.runner_warning&&we(String(es.runner_warning)),r.refresh(),Pt}finally{St.current.sessionId===Te&&(St.current.runId===at||St.current.runId===Pt)&&gs.current===Nt&&$t.current===qn&&(Ye.current=!1,Qe(!1))}}async function Na(T){if(!Bt)return or(T);if(qs==="queue")nt(X=>[...X,{id:Ar(),text:T,sessionId:I.sessionId,sourceRunId:I.runId,authEpoch:$t.current}]),Cn(!0),q(""),we("Queued for the next turn.");else{if(mn)throw new Error("Answer the pending workflow request above, or choose Queue next turn.");const X=I.sessionId,be=I.runId,je=$t.current;if(await Pn.sendCommand("inject_guidance",{guidance:T}),St.current.sessionId!==X||St.current.runId!==be||$t.current!==je)return;q(""),we("Guidance queued. The workflow will read it at its next supported boundary.")}}async function Ca(T){var je,Te;const X=String(((je=We.run)==null?void 0:je.run_id)||"");if(!jg(T,{sessionId:I.sessionId,runId:I.runId,snapshotRunId:X,snapshotSessionId:String(((Te=We.run)==null?void 0:Te.session_id)||""),authEpoch:$t.current}))throw Sg();const be=await or(T.text);nt(at=>wE(at,T,be))}y.useEffect(()=>{var be,je;if(!jo||!Is.length||!e.connected||!pt||On||Ye.current)return;const T=yE(We.status);if(T==="wait")return;if(T==="pause"){Cn(!1);const Te=["failed","error"].includes(We.status.toLowerCase());we(`Queue paused because the run ${Te?"failed":"was cancelled"}. Review the result, then use Run next to continue explicitly.`);return}const X=Is[0];jg(X,{sessionId:I.sessionId,runId:I.runId,snapshotRunId:String(((be=We.run)==null?void 0:be.run_id)||""),snapshotSessionId:String(((je=We.run)==null?void 0:je.session_id)||""),authEpoch:$t.current})&&Ca(X).catch(Te=>{Te instanceof DOMException&&Te.name==="AbortError"||(Cn(!1),de(vt(Te)))})},[jo,Is,We.status,(cr=We.run)==null?void 0:cr.run_id,(dl=We.run)==null?void 0:dl.session_id,e.connected,pt,On,I.sessionId,I.runId]);async function To(T){const X=I.sessionId,be=t,je=$t.current,Te=()=>St.current.sessionId!==X||gs.current!==be||$t.current!==je,at=(Pt,sn)=>Ue(Yt=>Yt.map(Zn=>Zn.id===Pt?{...Zn,...sn}:Zn));let Nt=0,qn=0;await lN(T,aN,async Pt=>{if(!(Te()||ie.current.has(Pt.id))){at(Pt.id,{status:"uploading",message:void 0});try{const sn=await Ln.attachments_upload(X,Pt.file);if(Te()||ie.current.has(Pt.id))return;Ae.current.set(sn.$artifact,Pt.size),Ue(Yt=>Yt.filter(Zn=>Zn.id!==Pt.id)),He(Yt=>[...Yt,sn]),Nt+=1}catch(sn){if(Te()||ie.current.has(Pt.id))return;at(Pt.id,{status:"failed",message:oN(vt(sn))}),qn+=1}}}),!Te()&&(Nt||qn)&&Y(ug(Nt,qn))}function zn(T){var je;if(!T.length)return[];const X=iN(T,(je=r.policy)==null?void 0:je.maxAttachmentBytes,Ar);Ue(Te=>[...Te,...X]);const be=X.filter(Te=>Te.status==="refused").length;return be&&Y(ug(0,be)),To(X.filter(Te=>Te.status==="queued")),X}function Ro(T){const X=ue.find(je=>je.id===T);if(!X||X.status!=="failed")return;const be={...X,status:"queued",message:void 0};Ue(je=>je.map(Te=>Te.id===T?be:Te)),To([be])}function Ea(T){ie.current.add(T),Ue(X=>X.filter(be=>be.id!==T))}async function Xi(){const T=I.sessionId,X=I.runId,be=$t.current;await Pn.cancel(),St.current.sessionId===T&&St.current.runId===X&&$t.current===be&&we("")}const vs=T=>{const X=$t.current,be=I.sessionId,je=I.runId;de(""),T().catch(Te=>{Te instanceof DOMException&&Te.name==="AbortError"||$t.current===X&&St.current.sessionId===be&&St.current.runId===je&&de(vt(Te))})},ir=r.sessions.filter(T=>`${T.prompt||""} ${T.sessionId}`.toLowerCase().includes(_a.toLowerCase())),[An,Wt]=y.useState(null),[Ls,Br]=y.useState(!1),[Wr,$a]=y.useState(""),Aa=(T,X)=>{$a(""),Wt({sessionId:T,where:X})},Io=()=>{Wt(null),$a("")},Vr=async()=>{if(!An||Ls)return;const{sessionId:T}=An;Br(!0),$a("");try{await q0(T)}catch(X){$a(`Not archived: ${vt(X)}`),Br(!1);return}if(Br(!1),Wt(null),T===I.sessionId){const X=Z0(ir,T);X?Ur(X.sessionId,X.latestRunId):ws()}r.forgetSession(T)},Hr=a.jsx(I0,{busy:Ls,error:Wr,onConfirm:()=>void Vr(),onCancel:Io}),qi=(()=>{var T;try{return new URL(((T=e.status)==null?void 0:T.gateway_url)||"").host}catch{return"Your gateway"}})(),eu=T=>{const X=[];(A.provider||A.model)&&!T.provider&&!T.model&&X.push("provider","model"),A.toolsCustomized&&!T.toolsCustomized&&X.push("tools"),A.maxIterations&&!T.maxIterations&&X.push("max_iterations"),X.length&&$s(be=>{const je={...be},Te=Ks(ve);for(const at of X)delete je[at],Object.prototype.hasOwnProperty.call(Te,at)&&(je[at]=Te[at]);return je}),R(T)},_s=(T,X=A,be=eu,je)=>a.jsx(G1,{tab:T,lockedReasonId:`code-${T}-locked`,value:X,onChange:be,tools:r.tools,connected:e.connected,automationFolders:!!je,defaultModel:!je&&Rt.provider&&Rt.model?{provider:String(Rt.provider),model:String(Rt.model)}:r.defaultModel,workflowDefault:!je&&!!(Rt.provider&&Rt.model),streaming:r.streaming,disabled:je?!e.connected:hs||!e.connected,workspaceRootFixed:je==null?void 0:je.root,sessionId:je?void 0:I.sessionId,onOpenDefaultWorkspaces:()=>v(!0),workspaceRefreshKey:_,hideStreamReplies:!!je,lockedText:je?"Connect to a gateway to edit this automation.":void 0}),Zi=a.jsx(VC,{value:$,onChange:T=>{Yn.stop_tts(),E(T)},defaults:nr,connected:e.connected}),ut=Et.detail,Os=pC(Qt&&(ut!=null&&ut.definition)?{summary:ut.summary,definition:ut.definition}:null,(T,X,be)=>un.revise(T,X,be)),lr=(T,X,be)=>{if(Qt){if(!(ut!=null&&ut.definition)||!Os)return Et.selectedId?a.jsx(ho,{children:"Loading automation…"}):a.jsx("p",{className:"code-muted",children:"Select an automation in the sidebar."});const je={root:ut.definition.workspace_root||""};return a.jsxs("div",{className:"code-automation-settings",id:`code-settings-${T}`,"data-revision":Os.revision,children:[a.jsx(gC,{summary:ut.summary,settings:Os}),be(Os.draft,Os.onChange,je)]})}return a.jsxs("div",{className:"code-conversation-settings",id:`code-settings-${T}`,children:[a.jsxs("p",{className:"code-settings-binding",children:[a.jsx("span",{children:"Conversation"})," ",a.jsx("strong",{title:$n,children:$n})]}),X()]})},tu=lr("model",()=>_s("model"),(T,X,be)=>_s("model",T,X,be)),nu=lr("workflow",()=>a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"code-workflow-select","aria-busy":Be||void 0,children:[a.jsx(ne,{name:"agent",size:17}),a.jsx(gy,{id:"code-workflow-picker",className:"code-workflow-picker",interfaceId:Nn,ariaLabel:"Workflow",workflows:{...r.executable,reload:()=>void r.refresh()},value:j1(J,G),currentLabel:G&&J!==Ot&&!O.some(T=>T.id===G.id)?{name:G.name,detail:I.runId&&G.bundleVersion?`conversation version ${G.bundleVersion}`:G.bundleVersion?`@${G.bundleVersion}`:""}:null,unavailableReason:e.connected?hs?"A run is in progress.":null:"Connect to a gateway first.",onChange:(T,X)=>{const be=S1(T,X);V(be),Z||R(je=>({...je,workflow:be}))}}),J===Ot&&Hd(se)?a.jsx("span",{className:"code-workflow-resolved is-missing",role:"alert",title:Hd(se),children:Hd(se)}):null,ys?a.jsx("span",{className:"code-workflow-resolved is-missing",role:"status",title:ys,children:ys}):null,ce&&ce.runId===I.runId&&ce.missing?a.jsx("span",{className:"code-workflow-resolved is-missing",role:"status",children:ce.text}):null]}),P.state.status==="ok"?a.jsx(tN,{row:P.state.row,save:P.save,disabled:!e.connected}):null,a.jsxs("div",{className:"code-settings code-workflow-inputs",children:[a.jsx("h3",{className:"code-settings-heading",children:"Inputs"}),a.jsx("p",{className:"code-muted",children:(G==null?void 0:G.description)||"Configure the values this workflow needs to run."}),Be?a.jsx("p",{role:"status",children:"Loading input schema…"}):mt?null:D||Dn?a.jsx(cE,{schema:ve,promptProperty:Dn,defaultModel:r.defaultModel,values:Rt,onChange:$s,disabled:hs,onEditorError:ma},G==null?void 0:G.id):a.jsx(Nf,{schema:ve,defaultModel:r.defaultModel,values:Rt,onChange:$s,disabled:hs,rawObject:!0,onEditorError:ma},G==null?void 0:G.id),mt?a.jsx("p",{role:"alert",className:"code-error-text",children:mt}):null,Eo?a.jsxs("button",{className:"code-primary-button",onClick:()=>Ts(!1),children:["Back to chat ",a.jsx(ne,{name:"chat",size:16})]}):a.jsxs("button",{className:"code-primary-button",disabled:hs||Be||!!mt||!!ha||!e.connected,onClick:()=>vs(()=>or(me||String(Rt[Dn||"prompt"]||""))),children:["Run workflow ",a.jsx(ne,{name:"playCircle",size:16})]})]})]}),()=>ut!=null&&ut.definition&&Os?a.jsx(yC,{summary:ut.summary,definition:ut.definition,settings:Os,busy:Et.busy,disabled:!e.connected,emailStatus:Et.emailStatus,onOpenMyEmail:Fn.openMyEmail,onRevise:(T,X)=>un.revise(ut.automationId,T,X),prepareTarget:rr,workflowPickerOptions:{interfaceId:Nn,workflows:{...r.executable,reload:()=>void r.refresh()}}}):null),su=lr("workspace",()=>a.jsxs(a.Fragment,{children:[a.jsxs("p",{className:"code-current-workspace",children:["Current workspace ",a.jsx("code",{title:ms||"Gateway workspace",children:ms.split("/").filter(Boolean).pop()||"Gateway workspace"})]}),_s("workspace")]}),(T,X,be)=>_s("workspace",T,X,be)),el=lr("tools",()=>_s("tools"),(T,X,be)=>_s("tools",T,X,be)),ru=lr("skills",()=>_s("skills"),(T,X,be)=>_s("skills",T,X,be)),au=lr("voice",()=>Zi,()=>Zi),Mo=Qt?`automation:${Et.selectedId}`:`conversation:${I.sessionId}`,tl=y.useRef({});y.useEffect(()=>{!cn||cn==="activity"||cn==="files"||tl.current[cn]===Mo||(tl.current[cn]=Mo,window.requestAnimationFrame(()=>{const T=document.querySelector(`#code-rail-panel-${cn} .af-rail__body`);T&&(T.scrollTop=0)}))},[Mo,cn]);const Ta=Qt?{count:0,hint:""}:KN(We.records,I.runId),ou=a.jsx(uC,{panel:cn,onPanel:T=>{us(T),T&&d(!1)},activityBadge:Ta.count,activityHint:Ta.hint,content:{activity:Qt?a.jsx(qN,{occurrences:(ut==null?void 0:ut.occurrences)||[],nowMs:Date.now(),onOpenRun:Fn.openRun}):a.jsx(GN,{records:We.records,runId:I.runId}),files:Qt?e.connected&&Et.selectedId?a.jsx(zf,{fetchGateway:Mc,runId:Et.selectedId,title:"Automation files",refreshKey:ut==null?void 0:ut.summary.updated_at,copyText:Gf,onOpenFolder:()=>Mw(Et.selectedId)}):a.jsx("p",{className:"code-muted",children:"Connect to a gateway and select an automation to browse its files."}):a.jsxs(a.Fragment,{children:[a.jsx(HN,{policy:r.policy,runId:I.runId,enabled:e.connected,isAdmin:((Do=(Po=(Oo=e.status)==null?void 0:Oo.gateway)==null?void 0:Po.principal)==null?void 0:Do.admin)===!0,refreshKey:We.status,onAttachFiles:zn,onAttach:async T=>{const X=I.sessionId,be=I.runId,je=$t.current,Te=await Ln.attachments_ingest(X,T);St.current.sessionId===X&&St.current.runId===be&&$t.current===je&&He(at=>[...at,Te])}}),Qn.length?a.jsx("button",{className:"code-subtle-button",onClick:()=>uj({filename:"conversation.md",text:cj(Qn)}),children:"Export conversation"}):null]}),model:tu,workflow:nu,workspace:su,tools:el,skills:ru,voice:au}},`rail:${t}`);return a.jsxs("div",{className:`code-app${ds?" code-app--nav-open":""}`,children:[a.jsx("a",{className:"code-skip-link",href:"#code-conversation",children:"Skip to conversation"}),a.jsxs(w0,{isDrawer:ya,open:ds,children:[a.jsxs("div",{className:"code-brand",children:[a.jsxs("span",{className:"code-brand-mark","aria-hidden":"true",children:["a",a.jsx("span",{children:"c"})]}),a.jsxs("div",{children:[a.jsx("strong",{children:"AbstractCode"}),a.jsx("span",{children:"YOUR WORK, IN CONTEXT"})]}),a.jsx("button",{className:"code-mobile-close code-icon-button","aria-label":"Close navigation",onClick:()=>jt(!1),children:a.jsx(ne,{name:"x",size:18})})]}),a.jsxs("div",{className:"code-session-search",children:[a.jsx(ne,{name:"history",size:14}),a.jsx("input",{ref:ko,"aria-label":"Search conversations",placeholder:"Search conversations",value:_a,onChange:T=>Hi(T.target.value)}),a.jsx("kbd",{children:"⌘K"})]}),a.jsxs(C0,{panels:_o,children:[a.jsx(nE,{state:Et,available:wa,discovering:r.capabilitiesLoading,createDisabled:Be||!!mt||!G,selectedId:Qt?Et.selectedId:"",onSelect:T=>{dn(!0),jt(!1),un.select(T)},onNew:()=>bo(!0),onRefresh:()=>void un.refresh(),archivedOpen:fs.automations,onToggleArchived:()=>Dr("automations"),onUnarchive:T=>void un.unarchive(T.automation_id).catch(()=>{}),onToggleActive:T=>void un.toggleActive(T).catch(()=>{}),open:_o.automations,onToggle:()=>Xs("automations")}),a.jsxs(E0,{open:_o.conversations,onToggle:()=>Xs("conversations"),actions:a.jsxs("span",{className:"code-auto-actions",children:[a.jsx("button",{className:"code-icon-button code-new-chat","aria-label":"New conversation",title:"New conversation (⇧⌘N)","aria-keyshortcuts":"Shift+Meta+N",onClick:ws,children:a.jsx(ne,{name:"plus",size:13})}),a.jsx("button",{className:"code-icon-button","aria-label":"Refresh conversations",disabled:!e.connected||r.loading,onClick:()=>void r.refresh(),children:a.jsx(ne,{name:"refresh",size:13})})]}),children:[bt?null:a.jsx("button",{type:"button",className:"code-session code-card is-selected",onClick:()=>jt(!1),children:a.jsxs("span",{children:[a.jsx("strong",{className:"code-card-title",children:"New conversation"}),a.jsx("small",{className:"code-card-meta",children:"Ready when you are"})]})}),ir.map(T=>a.jsx(G0,{item:T,selected:T.sessionId===I.sessionId,onClick:()=>Ur(T.sessionId,T.latestRunId),onAskArchive:e.connected?()=>Aa(T.sessionId,"card"):void 0,confirm:(An==null?void 0:An.where)==="card"&&An.sessionId===T.sessionId?Hr:void 0},T.sessionId)),r.sessionsLoaded&&!ir.length?a.jsx("p",{className:"code-history-empty",children:_a?"No conversations match your search.":"Your conversations will live here. Pick up where you left off, on any device."}):null,r.loading&&!r.sessionsLoaded?a.jsx(ho,{children:"Loading conversations…"}):null,r.hasMore?a.jsx("button",{className:"code-load-more",onClick:r.loadMore,children:"Load more conversations"}):null,a.jsx(_w,{list:"conversations",count:r.archivedSessions,open:fs.conversations,onToggle:()=>Dr("conversations"),children:a.jsx(e1,{enabled:e.connected&&fs.conversations,revision:r.archivedSessions,onOpen:T=>{jt(!1),Ur(T.sessionId,T.latestRunId)},onUnarchived:()=>void r.refresh()})})]})]}),a.jsx("div",{className:"code-sidebar-bottom",children:a.jsxs("div",{className:"code-gateway-foot",children:[a.jsx("span",{className:`code-status-dot ${e.connected?"is-online":""}`}),a.jsx("span",{children:qi}),a.jsx("small",{children:((Ps=(zo=(Fo=e.status)==null?void 0:Fo.gateway)==null?void 0:zo.principal)==null?void 0:Ps.user_id)||"Signed out"})]})})]}),ds?a.jsx("button",{className:"code-nav-scrim","aria-label":"Close conversation navigation",onClick:()=>jt(!1)}):null,a.jsxs("div",{className:"code-main-shell",children:[a.jsxs("header",{className:"code-topbar",children:[a.jsx("button",{className:"code-mobile-nav code-icon-button","aria-label":"Open conversation navigation",onClick:()=>{Or(),d(!1),jt(!0)},children:a.jsx(ne,{name:"list",size:19})}),a.jsxs("div",{className:"code-breadcrumb",children:[a.jsx("span",{children:Qt?"Automations":"Conversations"}),a.jsx("span",{"aria-hidden":"true",children:"/"}),a.jsx("strong",{title:Qt?Yi:$n,children:Qt?Yi:$n})]}),!Qt&&bt&&e.connected?a.jsx(Ig,{className:"code-conversation-menu",label:"Conversation actions",title:"More actions",items:[{id:"archive",label:"Archive",danger:!0,onSelect:()=>Aa(bt.sessionId,"header")}]}):null,a.jsx(hb,{docs:{open:u,onToggle:()=>{d(T=>!T),Or(),jt(!1)},label:"Docs assistant"},appearance:{onOpen:()=>m(!0)},about:{identity:vE,versions:vC(x),onOpen:N},connection:{phase:e.phase,signingOut:e.signingOut,onConnect:e.openModal,onDisconnect:()=>void e.signOut()}})]}),a.jsxs("div",{className:"code-content",children:[Qt?a.jsx(oE,{prepareTarget:rr,workflowPickerOptions:{interfaceId:Nn,workflows:{...r.executable,reload:()=>void r.refresh()}},ctl:un,availableTools:r.tools.filter(T=>T.enabled).map(T=>T.name),host:Fn,voiceCapability:zr,voicePreferences:$,enabled:e.connected,onClose:()=>dn(!1),onEdit:Ji,onEditWorkspaces:Qi}):a.jsxs("main",{className:"code-conversation",id:"code-conversation",tabIndex:-1,children:[fe||We.error||e.signOutError||On?a.jsxs("div",{className:"code-alert",role:"alert",children:[a.jsx(ne,{name:"warning",size:16}),a.jsx("span",{children:fe||We.error||e.signOutError||On}),We.error||On?a.jsx("button",{onClick:()=>{On?window.location.reload():vs(()=>Pn.load(I.runId))},children:"Reconnect"}):a.jsx("button",{"aria-label":"Dismiss error",onClick:()=>de(""),children:a.jsx(ne,{name:"x",size:14})})]}):null,(An==null?void 0:An.where)==="header"&&An.sessionId===I.sessionId?a.jsx("div",{className:"code-archive-confirm-bar",children:Hr}):null,r.errors.length?a.jsx("div",{className:"code-discovery-errors",role:"status",children:a.jsxs("details",{children:[a.jsx("summary",{children:"Some gateway information could not be loaded"}),r.errors.map(T=>a.jsx("p",{children:T},T)),a.jsx("button",{onClick:()=>void r.refresh(),children:"Retry discovery"})]})}):null,En?a.jsxs("div",{className:"code-alert",role:"alert",children:[a.jsx("span",{children:En}),a.jsx("button",{onClick:ws,children:"New conversation"})]}):null,mt?a.jsxs("div",{className:"code-alert",role:"alert",children:[a.jsxs("span",{children:["Workflow inputs: ",mt]}),a.jsx("button",{onClick:()=>Lr(T=>T+1),children:"Retry"})]}):null,ae?a.jsxs("div",{className:"code-notice",role:"status",children:[ae,a.jsx("button",{"aria-label":"Dismiss notice",onClick:()=>we(""),children:a.jsx(ne,{name:"x",size:13})})]}):null,Bt||Zd(We.status)?a.jsx(pE,{active:Bt,paused:er,snapshot:We,permissionsAll:A.permissions==="all",onInteraction:mn&&!er?()=>{var be;const T=document.querySelector(".code-conversation .pc-chat-thread"),X=T==null?void 0:T.querySelector(".pc-workflow-interaction");!T||!X||(T.scrollTop+=X.getBoundingClientRect().top-T.getBoundingClientRect().top,(be=X.querySelector("h3"))==null||be.focus({preventScroll:!0}))}:void 0,onRevokeApproval:()=>{Pn.revokeToolApproval(),R(T=>({...T,permissions:"default"}))},onCommand:T=>vs(()=>Pn.sendCommand(T,{})),onActivity:()=>{wo("activity")}}):null,a.jsx(US,{streamReplies:L,messages:(mn==null?void 0:mn.kind)==="tool-approval"?Qn.filter(T=>{var X,be;return!(((X=T.toolActivity)==null?void 0:X.status)==="waiting"&&T.toolActivity.runId===((be=We.interaction)==null?void 0:be.runId))}):Qn,messageProps:{...Yn.tts_supported?{onSpeakToggle:T=>{Yn.toggle_tts(T.id||T.content,T.content)}}:{},getSpeakState:T=>Yn.tts_playback.key===(T.id||T.content)?Yn.tts_playback.status:"idle"},draft:me,onDraftChange:q,onSend:Na,busy:hs,busyLabel:Co?"Waiting for you":Pe?"Starting…":er?"Paused":"Working…",sendWhileBusy:Bt&&!Pe&&!Co,sendLabel:Bt?qs==="queue"?"Queue":"Steer":"Send",onCancel:Xi,stopState:We.stop??null,disabled:!e.connected,interaction:mn,onAttach:()=>{var T;return(T=pe.current)==null?void 0:T.click()},onFiles:T=>{zn(T)},attachments:Ne.length||ue.length?a.jsx(mE,{attachments:Ne,uploads:ue,sizes:Ae.current,onRemoveAttachment:T=>He(X=>X.filter((be,je)=>je!==T)),onRemoveUpload:Ea,onRetryUpload:Ro}):null,placeholder:Bt?qs==="queue"?"Queue the next task after this run…":mn?"Answer the request above, or choose Queue next turn…":"Guide the current workflow…":"Describe what you want to build, fix, or explore…",emptyState:Bt?null:a.jsx(bE,{workflow:G,loading:r.loading||Be,onSuggestion:q,onInputs:()=>Ts(!0),isAgent:Eo,onRun:()=>vs(()=>or(me)),connected:e.connected}),composerExtras:a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"code-composer-workspace",title:ms||"Workspace is managed by the gateway",children:[a.jsx(ne,{name:"terminal",size:14}),a.jsx("span",{children:ms.split("/").filter(Boolean).pop()||"Gateway workspace"})]}),e.connected?a.jsx(KC,{runId:I.runId,voice:Yn,capability:zr,route:wb($,nr.value)},`${t}:${I.sessionId}:${I.runId}`):null,Bt?a.jsxs("select",{"aria-label":"Message destination",value:qs,onChange:T=>Xc(T.target.value),children:[a.jsxs("option",{value:"steer",disabled:!!mn,children:["Guide this run",mn?" (answer above)":""]}),a.jsx("option",{value:"queue",children:"Queue next turn"})]}):null]}),footer:a.jsxs(a.Fragment,{children:[a.jsxs("span",{children:["Enter to send ",a.jsx("span",{"aria-hidden":"true",children:"·"})," Shift + Enter for a new line"]}),a.jsxs("span",{children:["Managed workspace",a.jsx("span",{className:"code-small-dot"})]})]})}),Is.length?a.jsxs("div",{className:"code-queue",children:[a.jsxs("div",{children:[a.jsxs("strong",{children:[Is.length," queued"," ",Is.length===1?"turn":"turns"]}),a.jsx(Mr,{className:"code-queue__switch",variant:"sm",action:"queue-running",label:"Run queued turns",hint:"On: each queued turn starts when the current run ends. Off: they wait here.",checked:jo,onChange:Cn})]}),Is.map(T=>a.jsxs("div",{children:[a.jsx("span",{children:T.text}),Bt?null:a.jsx("button",{onClick:()=>vs(()=>Ca(T)),children:"Run next"}),a.jsx("button",{"aria-label":"Remove queued turn",onClick:()=>nt(X=>X.filter(be=>be.id!==T.id)),children:a.jsx(ne,{name:"x",size:13})})]},T.id))]}):null]}),ou]}),a.jsxs("footer",{className:"code-statusbar",children:[a.jsxs("span",{children:[a.jsx("span",{className:`code-status-dot ${e.connected?"is-online":""}`}),e.connected?"Connected":e.phase==="loading"?"Connecting":"Disconnected"]}),a.jsx("span",{children:(G==null?void 0:G.name)||"No workflow selected"}),a.jsx("div",{}),a.jsx("span",{children:I.runId?`Run ${I.runId.slice(0,8)}`:"Ready to start"}),a.jsx("span",{children:i.theme.replace(/-/g," ")})]})]}),a.jsx("div",{className:"pc-sr-only",role:"status","aria-live":"polite",children:ge}),a.jsx("input",{ref:pe,hidden:!0,type:"file",multiple:!0,onChange:T=>{zn(Array.from(T.target.files||[])),T.target.value=""}}),a.jsx(iE,{connected:e.connected,workflowPickerOptions:{interfaceId:Nn,workflows:{...r.executable,reload:()=>void r.refresh()}},open:va,onClose:()=>bo(!1),target:jC(J,G),availableTools:r.tools.filter(T=>T.enabled).map(T=>T.name),initialTools:Di(A.toolsCustomized?{...Rt,tools:Fr.enabledTools}:Rt),buildInput:async(T,X)=>{if(!X)return Ao(T,{...Ks(ve),...Rt},[],!0);const be=X.flow_id==="@default"?se:r.workflows.find(Nt=>`${Nt.bundleId}@${Nt.bundleVersion}`===("bundle_ref"in X?X.bundle_ref:"")&&Nt.flowId===X.flow_id);if(!be)throw new Error("The selected workflow is no longer available. Refresh the workflow list.");const je=await Jd(be);if(!je)throw new Error("Workflow inputs could not be checked. Refresh the workflow list and try again.");const Te=Ao(T,Ks(je),[],!0,be,je),at=Vd(je,Te);if(at.length)throw new Error(at.join(" "));return Te},workflowLabel:J===Ot?b1(r.gatewayDefault):(G==null?void 0:G.name)||"the selected workflow",initialPrompt:me||((fl=[...Qn].reverse().find(T=>T.role==="user"))==null?void 0:fl.content)||"",ctl:un,onOpenMyEmail:Ms,onCreated:()=>{dn(!0),jt(!1)}}),a.jsx(V_,{...e.modalProps}),a.jsx(y0,{open:u,onClose:()=>d(!1),connected:e.connected,topOffset:Pr},`assistant:${t}`),a.jsx(yb,{open:h,onClose:()=>m(!1),value:i,onChange:c}),a.jsx(_0,{open:p,onClose:()=>v(!1),connected:e.connected,onChanged:C})]})}function bE({workflow:e,loading:t,onSuggestion:n,onInputs:r,isAgent:i,onRun:c,connected:u}){return a.jsxs("div",{className:"code-welcome",children:[a.jsxs("div",{className:"code-welcome-symbol","aria-hidden":"true",children:[a.jsx("span",{children:"›"}),a.jsx("span",{children:"_"})]}),a.jsx("p",{className:"code-eyebrow",children:"A LITTLE CONTEXT. A LOT OF POSSIBILITY."}),a.jsx("h1",{children:"What are we building?"}),a.jsxs("p",{className:"code-welcome-description",children:["A focused space to think, code, and get things done.",a.jsx("br",{}),"Your workflows. Your tools. One conversation."]}),e&&!i?a.jsxs("div",{className:"code-workflow-welcome",children:[a.jsx(ne,{name:"playCircle",size:21}),a.jsxs("div",{children:[a.jsx("strong",{children:e.name}),a.jsx("p",{children:e.description||"Run this workflow with its registered inputs."})]}),a.jsx("button",{onClick:r,children:"Configure inputs"}),a.jsx("button",{onClick:c,disabled:t||!u,children:"Run workflow"})]}):a.jsx("div",{className:"code-suggestions",children:[{icon:"terminal",title:"Explore this project",detail:"Find your bearings in the codebase",prompt:"Explore this project and explain its architecture, key entry points, and how to run its tests."},{icon:"edit",title:"Build something new",detail:"Turn an idea into working code",prompt:"I'd like to build a new feature. Help me clarify the requirements and plan the implementation."},{icon:"warning",title:"Track down a bug",detail:"Understand what went wrong",prompt:"Help me investigate a bug. Start by asking what happened and what I expected."},{icon:"check",title:"Review my changes",detail:"Get a second pair of eyes",prompt:"Review the current changes for correctness, edge cases, and maintainability. Explain any findings before making edits."}].map(d=>a.jsxs("button",{onClick:()=>n(d.prompt),disabled:t,children:[a.jsx(ne,{name:d.icon,size:18}),a.jsxs("span",{children:[a.jsx("strong",{children:d.title}),a.jsx("small",{children:d.detail})]}),a.jsx(ne,{name:"chevronRight",size:13})]},d.title))}),a.jsx("p",{className:"code-welcome-hint",children:t?"Discovering your workflows…":e?a.jsxs(a.Fragment,{children:["Using ",a.jsx("strong",{children:e.name})," · Choose another in the Workflow panel"]}):u?"Register a workflow with AbstractGateway to get started.":"Connect your gateway to get started."})]})}class xE extends lt.Component{constructor(){super(...arguments);Mn(this,"state",{error:""})}static getDerivedStateFromError(n){return{error:n.message}}render(){return this.state.error?a.jsxs("div",{className:"code-crash",role:"alert",children:[a.jsx("h1",{children:"Something interrupted this view."}),a.jsx("p",{children:this.state.error}),a.jsx("p",{children:"Your runs are stored by the gateway."}),a.jsx("button",{onClick:()=>window.location.reload(),children:"Reload AbstractCode"})]}):this.props.children}}c_();o0();"serviceWorker"in navigator&&window.addEventListener("load",()=>{navigator.serviceWorker.register("sw.js").catch(()=>{})});s_.createRoot(document.getElementById("root")).render(a.jsx(lt.StrictMode,{children:a.jsx(xE,{children:a.jsx(_E,{})})}));
|