@abstractframework/code 0.6.2 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,72 @@
1
+ var Mg=Object.defineProperty;var Lg=(e,n,s)=>n in e?Mg(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s;var yn=(e,n,s)=>Lg(e,typeof n!="symbol"?n+"":n,s);(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))a(l);new MutationObserver(l=>{for(const u of l)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&a(d)}).observe(document,{childList:!0,subtree:!0});function s(l){const u={};return l.integrity&&(u.integrity=l.integrity),l.referrerPolicy&&(u.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?u.credentials="include":l.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function a(l){if(l.ep)return;l.ep=!0;const u=s(l);fetch(l.href,u)}})();function Uh(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var kc={exports:{}},oa={},jc={exports:{}},Ue={};/**
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 Df;function Pg(){if(Df)return Ue;Df=1;var e=Symbol.for("react.element"),n=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),d=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),x=Symbol.iterator;function b(N){return N===null||typeof N!="object"?null:(N=x&&N[x]||N["@@iterator"],typeof N=="function"?N:null)}var _={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},E=Object.assign,C={};function j(N,B,F){this.props=N,this.context=B,this.refs=C,this.updater=F||_}j.prototype.isReactComponent={},j.prototype.setState=function(N,B){if(typeof N!="object"&&typeof N!="function"&&N!=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,N,B,"setState")},j.prototype.forceUpdate=function(N){this.updater.enqueueForceUpdate(this,N,"forceUpdate")};function T(){}T.prototype=j.prototype;function A(N,B,F){this.props=N,this.context=B,this.refs=C,this.updater=F||_}var $=A.prototype=new T;$.constructor=A,E($,j.prototype),$.isPureReactComponent=!0;var k=Array.isArray,P=Object.prototype.hasOwnProperty,V={current:null},H={key:!0,ref:!0,__self:!0,__source:!0};function L(N,B,F){var W,ie={},le=null,he=null;if(B!=null)for(W in B.ref!==void 0&&(he=B.ref),B.key!==void 0&&(le=""+B.key),B)P.call(B,W)&&!H.hasOwnProperty(W)&&(ie[W]=B[W]);var X=arguments.length-2;if(X===1)ie.children=F;else if(1<X){for(var $e=Array(X),We=0;We<X;We++)$e[We]=arguments[We+2];ie.children=$e}if(N&&N.defaultProps)for(W in X=N.defaultProps,X)ie[W]===void 0&&(ie[W]=X[W]);return{$$typeof:e,type:N,key:le,ref:he,props:ie,_owner:V.current}}function de(N,B){return{$$typeof:e,type:N.type,key:B,ref:N.ref,props:N.props,_owner:N._owner}}function re(N){return typeof N=="object"&&N!==null&&N.$$typeof===e}function Q(N){var B={"=":"=0",":":"=2"};return"$"+N.replace(/[=:]/g,function(F){return B[F]})}var U=/\/+/g;function J(N,B){return typeof N=="object"&&N!==null&&N.key!=null?Q(""+N.key):B.toString(36)}function fe(N,B,F,W,ie){var le=typeof N;(le==="undefined"||le==="boolean")&&(N=null);var he=!1;if(N===null)he=!0;else switch(le){case"string":case"number":he=!0;break;case"object":switch(N.$$typeof){case e:case n:he=!0}}if(he)return he=N,ie=ie(he),N=W===""?"."+J(he,0):W,k(ie)?(F="",N!=null&&(F=N.replace(U,"$&/")+"/"),fe(ie,B,F,"",function(We){return We})):ie!=null&&(re(ie)&&(ie=de(ie,F+(!ie.key||he&&he.key===ie.key?"":(""+ie.key).replace(U,"$&/")+"/")+N)),B.push(ie)),1;if(he=0,W=W===""?".":W+":",k(N))for(var X=0;X<N.length;X++){le=N[X];var $e=W+J(le,X);he+=fe(le,B,F,$e,ie)}else if($e=b(N),typeof $e=="function")for(N=$e.call(N),X=0;!(le=N.next()).done;)le=le.value,$e=W+J(le,X++),he+=fe(le,B,F,$e,ie);else if(le==="object")throw B=String(N),Error("Objects are not valid as a React child (found: "+(B==="[object Object]"?"object with keys {"+Object.keys(N).join(", ")+"}":B)+"). If you meant to render a collection of children, use an array instead.");return he}function ce(N,B,F){if(N==null)return N;var W=[],ie=0;return fe(N,W,"","",function(le){return B.call(F,le,ie++)}),W}function ye(N){if(N._status===-1){var B=N._result;B=B(),B.then(function(F){(N._status===0||N._status===-1)&&(N._status=1,N._result=F)},function(F){(N._status===0||N._status===-1)&&(N._status=2,N._result=F)}),N._status===-1&&(N._status=0,N._result=B)}if(N._status===1)return N._result.default;throw N._result}var ve={current:null},q={transition:null},oe={ReactCurrentDispatcher:ve,ReactCurrentBatchConfig:q,ReactCurrentOwner:V};function G(){throw Error("act(...) is not supported in production builds of React.")}return Ue.Children={map:ce,forEach:function(N,B,F){ce(N,function(){B.apply(this,arguments)},F)},count:function(N){var B=0;return ce(N,function(){B++}),B},toArray:function(N){return ce(N,function(B){return B})||[]},only:function(N){if(!re(N))throw Error("React.Children.only expected to receive a single React element child.");return N}},Ue.Component=j,Ue.Fragment=s,Ue.Profiler=l,Ue.PureComponent=A,Ue.StrictMode=a,Ue.Suspense=h,Ue.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=oe,Ue.act=G,Ue.cloneElement=function(N,B,F){if(N==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+N+".");var W=E({},N.props),ie=N.key,le=N.ref,he=N._owner;if(B!=null){if(B.ref!==void 0&&(le=B.ref,he=V.current),B.key!==void 0&&(ie=""+B.key),N.type&&N.type.defaultProps)var X=N.type.defaultProps;for($e in B)P.call(B,$e)&&!H.hasOwnProperty($e)&&(W[$e]=B[$e]===void 0&&X!==void 0?X[$e]:B[$e])}var $e=arguments.length-2;if($e===1)W.children=F;else if(1<$e){X=Array($e);for(var We=0;We<$e;We++)X[We]=arguments[We+2];W.children=X}return{$$typeof:e,type:N.type,key:ie,ref:le,props:W,_owner:he}},Ue.createContext=function(N){return N={$$typeof:d,_currentValue:N,_currentValue2:N,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},N.Provider={$$typeof:u,_context:N},N.Consumer=N},Ue.createElement=L,Ue.createFactory=function(N){var B=L.bind(null,N);return B.type=N,B},Ue.createRef=function(){return{current:null}},Ue.forwardRef=function(N){return{$$typeof:f,render:N}},Ue.isValidElement=re,Ue.lazy=function(N){return{$$typeof:y,_payload:{_status:-1,_result:N},_init:ye}},Ue.memo=function(N,B){return{$$typeof:g,type:N,compare:B===void 0?null:B}},Ue.startTransition=function(N){var B=q.transition;q.transition={};try{N()}finally{q.transition=B}},Ue.unstable_act=G,Ue.useCallback=function(N,B){return ve.current.useCallback(N,B)},Ue.useContext=function(N){return ve.current.useContext(N)},Ue.useDebugValue=function(){},Ue.useDeferredValue=function(N){return ve.current.useDeferredValue(N)},Ue.useEffect=function(N,B){return ve.current.useEffect(N,B)},Ue.useId=function(){return ve.current.useId()},Ue.useImperativeHandle=function(N,B,F){return ve.current.useImperativeHandle(N,B,F)},Ue.useInsertionEffect=function(N,B){return ve.current.useInsertionEffect(N,B)},Ue.useLayoutEffect=function(N,B){return ve.current.useLayoutEffect(N,B)},Ue.useMemo=function(N,B){return ve.current.useMemo(N,B)},Ue.useReducer=function(N,B,F){return ve.current.useReducer(N,B,F)},Ue.useRef=function(N){return ve.current.useRef(N)},Ue.useState=function(N){return ve.current.useState(N)},Ue.useSyncExternalStore=function(N,B,F){return ve.current.useSyncExternalStore(N,B,F)},Ue.useTransition=function(){return ve.current.useTransition()},Ue.version="18.3.1",Ue}var Ff;function cu(){return Ff||(Ff=1,jc.exports=Pg()),jc.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 zf;function Og(){if(zf)return oa;zf=1;var e=cu(),n=Symbol.for("react.element"),s=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,l=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function d(f,h,g){var y,x={},b=null,_=null;g!==void 0&&(b=""+g),h.key!==void 0&&(b=""+h.key),h.ref!==void 0&&(_=h.ref);for(y in h)a.call(h,y)&&!u.hasOwnProperty(y)&&(x[y]=h[y]);if(f&&f.defaultProps)for(y in h=f.defaultProps,h)x[y]===void 0&&(x[y]=h[y]);return{$$typeof:n,type:f,key:b,ref:_,props:x,_owner:l.current}}return oa.Fragment=s,oa.jsx=d,oa.jsxs=d,oa}var Wf;function Dg(){return Wf||(Wf=1,kc.exports=Og()),kc.exports}var i=Dg(),w=cu();const wt=Uh(w);var Ao={},Sc={exports:{}},nn={},Nc={exports:{}},Cc={};/**
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 Uf;function Fg(){return Uf||(Uf=1,(function(e){function n(q,oe){var G=q.length;q.push(oe);e:for(;0<G;){var N=G-1>>>1,B=q[N];if(0<l(B,oe))q[N]=oe,q[G]=B,G=N;else break e}}function s(q){return q.length===0?null:q[0]}function a(q){if(q.length===0)return null;var oe=q[0],G=q.pop();if(G!==oe){q[0]=G;e:for(var N=0,B=q.length,F=B>>>1;N<F;){var W=2*(N+1)-1,ie=q[W],le=W+1,he=q[le];if(0>l(ie,G))le<B&&0>l(he,ie)?(q[N]=he,q[le]=G,N=le):(q[N]=ie,q[W]=G,N=W);else if(le<B&&0>l(he,G))q[N]=he,q[le]=G,N=le;else break e}}return oe}function l(q,oe){var G=q.sortIndex-oe.sortIndex;return G!==0?G:q.id-oe.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;e.unstable_now=function(){return u.now()}}else{var d=Date,f=d.now();e.unstable_now=function(){return d.now()-f}}var h=[],g=[],y=1,x=null,b=3,_=!1,E=!1,C=!1,j=typeof setTimeout=="function"?setTimeout:null,T=typeof clearTimeout=="function"?clearTimeout:null,A=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function $(q){for(var oe=s(g);oe!==null;){if(oe.callback===null)a(g);else if(oe.startTime<=q)a(g),oe.sortIndex=oe.expirationTime,n(h,oe);else break;oe=s(g)}}function k(q){if(C=!1,$(q),!E)if(s(h)!==null)E=!0,ye(P);else{var oe=s(g);oe!==null&&ve(k,oe.startTime-q)}}function P(q,oe){E=!1,C&&(C=!1,T(L),L=-1),_=!0;var G=b;try{for($(oe),x=s(h);x!==null&&(!(x.expirationTime>oe)||q&&!Q());){var N=x.callback;if(typeof N=="function"){x.callback=null,b=x.priorityLevel;var B=N(x.expirationTime<=oe);oe=e.unstable_now(),typeof B=="function"?x.callback=B:x===s(h)&&a(h),$(oe)}else a(h);x=s(h)}if(x!==null)var F=!0;else{var W=s(g);W!==null&&ve(k,W.startTime-oe),F=!1}return F}finally{x=null,b=G,_=!1}}var V=!1,H=null,L=-1,de=5,re=-1;function Q(){return!(e.unstable_now()-re<de)}function U(){if(H!==null){var q=e.unstable_now();re=q;var oe=!0;try{oe=H(!0,q)}finally{oe?J():(V=!1,H=null)}}else V=!1}var J;if(typeof A=="function")J=function(){A(U)};else if(typeof MessageChannel<"u"){var fe=new MessageChannel,ce=fe.port2;fe.port1.onmessage=U,J=function(){ce.postMessage(null)}}else J=function(){j(U,0)};function ye(q){H=q,V||(V=!0,J())}function ve(q,oe){L=j(function(){q(e.unstable_now())},oe)}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(q){q.callback=null},e.unstable_continueExecution=function(){E||_||(E=!0,ye(P))},e.unstable_forceFrameRate=function(q){0>q||125<q?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):de=0<q?Math.floor(1e3/q):5},e.unstable_getCurrentPriorityLevel=function(){return b},e.unstable_getFirstCallbackNode=function(){return s(h)},e.unstable_next=function(q){switch(b){case 1:case 2:case 3:var oe=3;break;default:oe=b}var G=b;b=oe;try{return q()}finally{b=G}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(q,oe){switch(q){case 1:case 2:case 3:case 4:case 5:break;default:q=3}var G=b;b=q;try{return oe()}finally{b=G}},e.unstable_scheduleCallback=function(q,oe,G){var N=e.unstable_now();switch(typeof G=="object"&&G!==null?(G=G.delay,G=typeof G=="number"&&0<G?N+G:N):G=N,q){case 1:var B=-1;break;case 2:B=250;break;case 5:B=1073741823;break;case 4:B=1e4;break;default:B=5e3}return B=G+B,q={id:y++,callback:oe,priorityLevel:q,startTime:G,expirationTime:B,sortIndex:-1},G>N?(q.sortIndex=G,n(g,q),s(h)===null&&q===s(g)&&(C?(T(L),L=-1):C=!0,ve(k,G-N))):(q.sortIndex=B,n(h,q),E||_||(E=!0,ye(P))),q},e.unstable_shouldYield=Q,e.unstable_wrapCallback=function(q){var oe=b;return function(){var G=b;b=oe;try{return q.apply(this,arguments)}finally{b=G}}}})(Cc)),Cc}var Bf;function zg(){return Bf||(Bf=1,Nc.exports=Fg()),Nc.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 Vf;function Wg(){if(Vf)return nn;Vf=1;var e=cu(),n=zg();function s(t){for(var r="https://reactjs.org/docs/error-decoder.html?invariant="+t,o=1;o<arguments.length;o++)r+="&args[]="+encodeURIComponent(arguments[o]);return"Minified React error #"+t+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var a=new Set,l={};function u(t,r){d(t,r),d(t+"Capture",r)}function d(t,r){for(l[t]=r,t=0;t<r.length;t++)a.add(r[t])}var f=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),h=Object.prototype.hasOwnProperty,g=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,y={},x={};function b(t){return h.call(x,t)?!0:h.call(y,t)?!1:g.test(t)?x[t]=!0:(y[t]=!0,!1)}function _(t,r,o,c){if(o!==null&&o.type===0)return!1;switch(typeof r){case"function":case"symbol":return!0;case"boolean":return c?!1:o!==null?!o.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function E(t,r,o,c){if(r===null||typeof r>"u"||_(t,r,o,c))return!0;if(c)return!1;if(o!==null)switch(o.type){case 3:return!r;case 4:return r===!1;case 5:return isNaN(r);case 6:return isNaN(r)||1>r}return!1}function C(t,r,o,c,p,m,v){this.acceptsBooleans=r===2||r===3||r===4,this.attributeName=c,this.attributeNamespace=p,this.mustUseProperty=o,this.propertyName=t,this.type=r,this.sanitizeURL=m,this.removeEmptyString=v}var j={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){j[t]=new C(t,0,!1,t,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var r=t[0];j[r]=new C(r,1,!1,t[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(t){j[t]=new C(t,2,!1,t.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){j[t]=new C(t,2,!1,t,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){j[t]=new C(t,3,!1,t.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(t){j[t]=new C(t,3,!0,t,null,!1,!1)}),["capture","download"].forEach(function(t){j[t]=new C(t,4,!1,t,null,!1,!1)}),["cols","rows","size","span"].forEach(function(t){j[t]=new C(t,6,!1,t,null,!1,!1)}),["rowSpan","start"].forEach(function(t){j[t]=new C(t,5,!1,t.toLowerCase(),null,!1,!1)});var T=/[\-:]([a-z])/g;function A(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var r=t.replace(T,A);j[r]=new C(r,1,!1,t,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var r=t.replace(T,A);j[r]=new C(r,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(t){var r=t.replace(T,A);j[r]=new C(r,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(t){j[t]=new C(t,1,!1,t.toLowerCase(),null,!1,!1)}),j.xlinkHref=new C("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(t){j[t]=new C(t,1,!1,t.toLowerCase(),null,!0,!0)});function $(t,r,o,c){var p=j.hasOwnProperty(r)?j[r]:null;(p!==null?p.type!==0:c||!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(E(r,o,p,c)&&(o=null),c||p===null?b(r)&&(o===null?t.removeAttribute(r):t.setAttribute(r,""+o)):p.mustUseProperty?t[p.propertyName]=o===null?p.type===3?!1:"":o:(r=p.attributeName,c=p.attributeNamespace,o===null?t.removeAttribute(r):(p=p.type,o=p===3||p===4&&o===!0?"":""+o,c?t.setAttributeNS(c,r,o):t.setAttribute(r,o))))}var k=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,P=Symbol.for("react.element"),V=Symbol.for("react.portal"),H=Symbol.for("react.fragment"),L=Symbol.for("react.strict_mode"),de=Symbol.for("react.profiler"),re=Symbol.for("react.provider"),Q=Symbol.for("react.context"),U=Symbol.for("react.forward_ref"),J=Symbol.for("react.suspense"),fe=Symbol.for("react.suspense_list"),ce=Symbol.for("react.memo"),ye=Symbol.for("react.lazy"),ve=Symbol.for("react.offscreen"),q=Symbol.iterator;function oe(t){return t===null||typeof t!="object"?null:(t=q&&t[q]||t["@@iterator"],typeof t=="function"?t:null)}var G=Object.assign,N;function B(t){if(N===void 0)try{throw Error()}catch(o){var r=o.stack.trim().match(/\n( *(at )?)/);N=r&&r[1]||""}return`
34
+ `+N+t}var F=!1;function W(t,r){if(!t||F)return"";F=!0;var o=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(r)if(r=function(){throw Error()},Object.defineProperty(r.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(r,[])}catch(z){var c=z}Reflect.construct(t,[],r)}else{try{r.call()}catch(z){c=z}t.call(r.prototype)}else{try{throw Error()}catch(z){c=z}t()}}catch(z){if(z&&c&&typeof z.stack=="string"){for(var p=z.stack.split(`
35
+ `),m=c.stack.split(`
36
+ `),v=p.length-1,S=m.length-1;1<=v&&0<=S&&p[v]!==m[S];)S--;for(;1<=v&&0<=S;v--,S--)if(p[v]!==m[S]){if(v!==1||S!==1)do if(v--,S--,0>S||p[v]!==m[S]){var R=`
37
+ `+p[v].replace(" at new "," at ");return t.displayName&&R.includes("<anonymous>")&&(R=R.replace("<anonymous>",t.displayName)),R}while(1<=v&&0<=S);break}}}finally{F=!1,Error.prepareStackTrace=o}return(t=t?t.displayName||t.name:"")?B(t):""}function ie(t){switch(t.tag){case 5:return B(t.type);case 16:return B("Lazy");case 13:return B("Suspense");case 19:return B("SuspenseList");case 0:case 2:case 15:return t=W(t.type,!1),t;case 11:return t=W(t.type.render,!1),t;case 1:return t=W(t.type,!0),t;default:return""}}function le(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case H:return"Fragment";case V:return"Portal";case de:return"Profiler";case L:return"StrictMode";case J:return"Suspense";case fe:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case Q:return(t.displayName||"Context")+".Consumer";case re:return(t._context.displayName||"Context")+".Provider";case U:var r=t.render;return t=t.displayName,t||(t=r.displayName||r.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case ce:return r=t.displayName||null,r!==null?r:le(t.type)||"Memo";case ye:r=t._payload,t=t._init;try{return le(t(r))}catch{}}return null}function he(t){var r=t.type;switch(t.tag){case 24:return"Cache";case 9:return(r.displayName||"Context")+".Consumer";case 10:return(r._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=r.render,t=t.displayName||t.name||"",r.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return r;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return le(r);case 8:return r===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 r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r}return null}function X(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function $e(t){var r=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function We(t){var r=$e(t)?"checked":"value",o=Object.getOwnPropertyDescriptor(t.constructor.prototype,r),c=""+t[r];if(!t.hasOwnProperty(r)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var p=o.get,m=o.set;return Object.defineProperty(t,r,{configurable:!0,get:function(){return p.call(this)},set:function(v){c=""+v,m.call(this,v)}}),Object.defineProperty(t,r,{enumerable:o.enumerable}),{getValue:function(){return c},setValue:function(v){c=""+v},stopTracking:function(){t._valueTracker=null,delete t[r]}}}}function ke(t){t._valueTracker||(t._valueTracker=We(t))}function Y(t){if(!t)return!1;var r=t._valueTracker;if(!r)return!0;var o=r.getValue(),c="";return t&&(c=$e(t)?t.checked?"true":"false":t.value),t=c,t!==o?(r.setValue(t),!0):!1}function ee(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function pe(t,r){var o=r.checked;return G({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:o??t._wrapperState.initialChecked})}function Oe(t,r){var o=r.defaultValue==null?"":r.defaultValue,c=r.checked!=null?r.checked:r.defaultChecked;o=X(r.value!=null?r.value:o),t._wrapperState={initialChecked:c,initialValue:o,controlled:r.type==="checkbox"||r.type==="radio"?r.checked!=null:r.value!=null}}function we(t,r){r=r.checked,r!=null&&$(t,"checked",r,!1)}function Pe(t,r){we(t,r);var o=X(r.value),c=r.type;if(o!=null)c==="number"?(o===0&&t.value===""||t.value!=o)&&(t.value=""+o):t.value!==""+o&&(t.value=""+o);else if(c==="submit"||c==="reset"){t.removeAttribute("value");return}r.hasOwnProperty("value")?rt(t,r.type,o):r.hasOwnProperty("defaultValue")&&rt(t,r.type,X(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(t.defaultChecked=!!r.defaultChecked)}function Be(t,r,o){if(r.hasOwnProperty("value")||r.hasOwnProperty("defaultValue")){var c=r.type;if(!(c!=="submit"&&c!=="reset"||r.value!==void 0&&r.value!==null))return;r=""+t._wrapperState.initialValue,o||r===t.value||(t.value=r),t.defaultValue=r}o=t.name,o!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,o!==""&&(t.name=o)}function rt(t,r,o){(r!=="number"||ee(t.ownerDocument)!==t)&&(o==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+o&&(t.defaultValue=""+o))}var K=Array.isArray;function me(t,r,o,c){if(t=t.options,r){r={};for(var p=0;p<o.length;p++)r["$"+o[p]]=!0;for(o=0;o<t.length;o++)p=r.hasOwnProperty("$"+t[o].value),t[o].selected!==p&&(t[o].selected=p),p&&c&&(t[o].defaultSelected=!0)}else{for(o=""+X(o),r=null,p=0;p<t.length;p++){if(t[p].value===o){t[p].selected=!0,c&&(t[p].defaultSelected=!0);return}r!==null||t[p].disabled||(r=t[p])}r!==null&&(r.selected=!0)}}function De(t,r){if(r.dangerouslySetInnerHTML!=null)throw Error(s(91));return G({},r,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function Ke(t,r){var o=r.value;if(o==null){if(o=r.children,r=r.defaultValue,o!=null){if(r!=null)throw Error(s(92));if(K(o)){if(1<o.length)throw Error(s(93));o=o[0]}r=o}r==null&&(r=""),o=r}t._wrapperState={initialValue:X(o)}}function He(t,r){var o=X(r.value),c=X(r.defaultValue);o!=null&&(o=""+o,o!==t.value&&(t.value=o),r.defaultValue==null&&t.defaultValue!==o&&(t.defaultValue=o)),c!=null&&(t.defaultValue=""+c)}function Xn(t){var r=t.textContent;r===t._wrapperState.initialValue&&r!==""&&r!==null&&(t.value=r)}function Mt(t){switch(t){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Cn(t,r){return t==null||t==="http://www.w3.org/1999/xhtml"?Mt(r):t==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var Zn,En=(function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(r,o,c,p){MSApp.execUnsafeLocalFunction(function(){return t(r,o,c,p)})}:t})(function(t,r){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=r;else{for(Zn=Zn||document.createElement("div"),Zn.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=Zn.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;r.firstChild;)t.appendChild(r.firstChild)}});function Zr(t,r){if(r){var o=t.firstChild;if(o&&o===t.lastChild&&o.nodeType===3){o.nodeValue=r;return}}t.textContent=r}var vr={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},qo=["Webkit","ms","Moz","O"];Object.keys(vr).forEach(function(t){qo.forEach(function(r){r=r+t.charAt(0).toUpperCase()+t.substring(1),vr[r]=vr[t]})});function xi(t,r,o){return r==null||typeof r=="boolean"||r===""?"":o||typeof r!="number"||r===0||vr.hasOwnProperty(t)&&vr[t]?(""+r).trim():r+"px"}function qr(t,r){t=t.style;for(var o in r)if(r.hasOwnProperty(o)){var c=o.indexOf("--")===0,p=xi(o,r[o],c);o==="float"&&(o="cssFloat"),c?t.setProperty(o,p):t[o]=p}}var bi=G({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 ki(t,r){if(r){if(bi[t]&&(r.children!=null||r.dangerouslySetInnerHTML!=null))throw Error(s(137,t));if(r.dangerouslySetInnerHTML!=null){if(r.children!=null)throw Error(s(60));if(typeof r.dangerouslySetInnerHTML!="object"||!("__html"in r.dangerouslySetInnerHTML))throw Error(s(61))}if(r.style!=null&&typeof r.style!="object")throw Error(s(62))}}function As(t,r){if(t.indexOf("-")===-1)return typeof r.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var _r=null;function Kt(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Ts=null,cn=null,On=null;function xr(t){if(t=Hi(t)){if(typeof Ts!="function")throw Error(s(280));var r=t.stateNode;r&&(r=Va(r),Ts(t.stateNode,t.type,r))}}function br(t){cn?On?On.push(t):On=[t]:cn=t}function ka(){if(cn){var t=cn,r=On;if(On=cn=null,xr(t),r)for(t=0;t<r.length;t++)xr(r[t])}}function ji(t,r){return t(r)}function Rs(){}var es=!1;function ja(t,r,o){if(es)return t(r,o);es=!0;try{return ji(t,r,o)}finally{es=!1,(cn!==null||On!==null)&&(Rs(),ka())}}function kr(t,r){var o=t.stateNode;if(o===null)return null;var c=Va(o);if(c===null)return null;o=c[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(c=!c.disabled)||(t=t.type,c=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!c;break e;default:t=!1}if(t)return null;if(o&&typeof o!="function")throw Error(s(231,r,typeof o));return o}var qn=!1;if(f)try{var ts={};Object.defineProperty(ts,"passive",{get:function(){qn=!0}}),window.addEventListener("test",ts,ts),window.removeEventListener("test",ts,ts)}catch{qn=!1}function er(t,r,o,c,p,m,v,S,R){var z=Array.prototype.slice.call(arguments,3);try{r.apply(o,z)}catch(ne){this.onError(ne)}}var Jt=!1,jr=null,Qt=!1,Is=null,Si={onError:function(t){Jt=!0,jr=t}};function Ms(t,r,o,c,p,m,v,S,R){Jt=!1,jr=null,er.apply(Si,arguments)}function Ni(t,r,o,c,p,m,v,S,R){if(Ms.apply(this,arguments),Jt){if(Jt){var z=jr;Jt=!1,jr=null}else throw Error(s(198));Qt||(Qt=!0,Is=z)}}function tr(t){var r=t,o=t;if(t.alternate)for(;r.return;)r=r.return;else{t=r;do r=t,(r.flags&4098)!==0&&(o=r.return),t=r.return;while(t)}return r.tag===3?o:null}function Ls(t){if(t.tag===13){var r=t.memoizedState;if(r===null&&(t=t.alternate,t!==null&&(r=t.memoizedState)),r!==null)return r.dehydrated}return null}function Ci(t){if(tr(t)!==t)throw Error(s(188))}function Sa(t){var r=t.alternate;if(!r){if(r=tr(t),r===null)throw Error(s(188));return r!==t?null:t}for(var o=t,c=r;;){var p=o.return;if(p===null)break;var m=p.alternate;if(m===null){if(c=p.return,c!==null){o=c;continue}break}if(p.child===m.child){for(m=p.child;m;){if(m===o)return Ci(p),t;if(m===c)return Ci(p),r;m=m.sibling}throw Error(s(188))}if(o.return!==c.return)o=p,c=m;else{for(var v=!1,S=p.child;S;){if(S===o){v=!0,o=p,c=m;break}if(S===c){v=!0,c=p,o=m;break}S=S.sibling}if(!v){for(S=m.child;S;){if(S===o){v=!0,o=m,c=p;break}if(S===c){v=!0,c=m,o=p;break}S=S.sibling}if(!v)throw Error(s(189))}}if(o.alternate!==c)throw Error(s(190))}if(o.tag!==3)throw Error(s(188));return o.stateNode.current===o?t:r}function Ei(t){return t=Sa(t),t!==null?Na(t):null}function Na(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var r=Na(t);if(r!==null)return r;t=t.sibling}return null}var Ca=n.unstable_scheduleCallback,Dn=n.unstable_cancelCallback,Ve=n.unstable_shouldYield,un=n.unstable_requestPaint,st=n.unstable_now,nr=n.unstable_getCurrentPriorityLevel,Sr=n.unstable_ImmediatePriority,ns=n.unstable_UserBlockingPriority,dn=n.unstable_NormalPriority,Ea=n.unstable_LowPriority,rr=n.unstable_IdlePriority,rs=null,pt=null;function $a(t){if(pt&&typeof pt.onCommitFiberRoot=="function")try{pt.onCommitFiberRoot(rs,t,void 0,(t.current.flags&128)===128)}catch{}}var mt=Math.clz32?Math.clz32:ss,Aa=Math.log,Nr=Math.LN2;function ss(t){return t>>>=0,t===0?32:31-(Aa(t)/Nr|0)|0}var sr=64,Lt=4194304;function Cr(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function is(t,r){var o=t.pendingLanes;if(o===0)return 0;var c=0,p=t.suspendedLanes,m=t.pingedLanes,v=o&268435455;if(v!==0){var S=v&~p;S!==0?c=Cr(S):(m&=v,m!==0&&(c=Cr(m)))}else v=o&~p,v!==0?c=Cr(v):m!==0&&(c=Cr(m));if(c===0)return 0;if(r!==0&&r!==c&&(r&p)===0&&(p=c&-c,m=r&-r,p>=m||p===16&&(m&4194240)!==0))return r;if((c&4)!==0&&(c|=o&16),r=t.entangledLanes,r!==0)for(t=t.entanglements,r&=c;0<r;)o=31-mt(r),p=1<<o,c|=t[o],r&=~p;return c}function $i(t,r){switch(t){case 1:case 2:case 4:return r+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 r+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 el(t,r){for(var o=t.suspendedLanes,c=t.pingedLanes,p=t.expirationTimes,m=t.pendingLanes;0<m;){var v=31-mt(m),S=1<<v,R=p[v];R===-1?((S&o)===0||(S&c)!==0)&&(p[v]=$i(S,r)):R<=r&&(t.expiredLanes|=S),m&=~S}}function Ps(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function Os(){var t=sr;return sr<<=1,(sr&4194240)===0&&(sr=64),t}function ir(t){for(var r=[],o=0;31>o;o++)r.push(t);return r}function lt(t,r,o){t.pendingLanes|=r,r!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,r=31-mt(r),t[r]=o}function Ai(t,r){var o=t.pendingLanes&~r;t.pendingLanes=r,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=r,t.mutableReadLanes&=r,t.entangledLanes&=r,r=t.entanglements;var c=t.eventTimes;for(t=t.expirationTimes;0<o;){var p=31-mt(o),m=1<<p;r[p]=0,c[p]=-1,t[p]=-1,o&=~m}}function _t(t,r){var o=t.entangledLanes|=r;for(t=t.entanglements;o;){var c=31-mt(o),p=1<<c;p&r|t[c]&r&&(t[c]|=r),o&=~p}}var Je=0;function as(t){return t&=-t,1<t?4<t?(t&268435455)!==0?16:536870912:4:1}var Ds,Er,Ta,Ti,Ri,os=!1,Fs=[],Fn=null,zn=null,Yt=null,$n=new Map,$r=new Map,Wn=[],Ra="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 Ii(t,r){switch(t){case"focusin":case"focusout":Fn=null;break;case"dragenter":case"dragleave":zn=null;break;case"mouseover":case"mouseout":Yt=null;break;case"pointerover":case"pointerout":$n.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":$r.delete(r.pointerId)}}function Ar(t,r,o,c,p,m){return t===null||t.nativeEvent!==m?(t={blockedOn:r,domEventName:o,eventSystemFlags:c,nativeEvent:m,targetContainers:[p]},r!==null&&(r=Hi(r),r!==null&&Er(r)),t):(t.eventSystemFlags|=c,r=t.targetContainers,p!==null&&r.indexOf(p)===-1&&r.push(p),t)}function Ia(t,r,o,c,p){switch(r){case"focusin":return Fn=Ar(Fn,t,r,o,c,p),!0;case"dragenter":return zn=Ar(zn,t,r,o,c,p),!0;case"mouseover":return Yt=Ar(Yt,t,r,o,c,p),!0;case"pointerover":var m=p.pointerId;return $n.set(m,Ar($n.get(m)||null,t,r,o,c,p)),!0;case"gotpointercapture":return m=p.pointerId,$r.set(m,Ar($r.get(m)||null,t,r,o,c,p)),!0}return!1}function Mi(t){var r=fs(t.target);if(r!==null){var o=tr(r);if(o!==null){if(r=o.tag,r===13){if(r=Ls(o),r!==null){t.blockedOn=r,Ri(t.priority,function(){Ta(o)});return}}else if(r===3&&o.stateNode.current.memoizedState.isDehydrated){t.blockedOn=o.tag===3?o.stateNode.containerInfo:null;return}}}t.blockedOn=null}function ls(t){if(t.blockedOn!==null)return!1;for(var r=t.targetContainers;0<r.length;){var o=Ws(t.domEventName,t.eventSystemFlags,r[0],t.nativeEvent);if(o===null){o=t.nativeEvent;var c=new o.constructor(o.type,o);_r=c,o.target.dispatchEvent(c),_r=null}else return r=Hi(o),r!==null&&Er(r),t.blockedOn=o,!1;r.shift()}return!0}function Li(t,r,o){ls(t)&&o.delete(r)}function Ma(){os=!1,Fn!==null&&ls(Fn)&&(Fn=null),zn!==null&&ls(zn)&&(zn=null),Yt!==null&&ls(Yt)&&(Yt=null),$n.forEach(Li),$r.forEach(Li)}function Tr(t,r){t.blockedOn===r&&(t.blockedOn=null,os||(os=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,Ma)))}function Rr(t){function r(p){return Tr(p,t)}if(0<Fs.length){Tr(Fs[0],t);for(var o=1;o<Fs.length;o++){var c=Fs[o];c.blockedOn===t&&(c.blockedOn=null)}}for(Fn!==null&&Tr(Fn,t),zn!==null&&Tr(zn,t),Yt!==null&&Tr(Yt,t),$n.forEach(r),$r.forEach(r),o=0;o<Wn.length;o++)c=Wn[o],c.blockedOn===t&&(c.blockedOn=null);for(;0<Wn.length&&(o=Wn[0],o.blockedOn===null);)Mi(o),o.blockedOn===null&&Wn.shift()}var ar=k.ReactCurrentBatchConfig,cs=!0;function La(t,r,o,c){var p=Je,m=ar.transition;ar.transition=null;try{Je=1,zs(t,r,o,c)}finally{Je=p,ar.transition=m}}function Pa(t,r,o,c){var p=Je,m=ar.transition;ar.transition=null;try{Je=4,zs(t,r,o,c)}finally{Je=p,ar.transition=m}}function zs(t,r,o,c){if(cs){var p=Ws(t,r,o,c);if(p===null)hl(t,r,c,us,o),Ii(t,c);else if(Ia(p,t,r,o,c))c.stopPropagation();else if(Ii(t,c),r&4&&-1<Ra.indexOf(t)){for(;p!==null;){var m=Hi(p);if(m!==null&&Ds(m),m=Ws(t,r,o,c),m===null&&hl(t,r,c,us,o),m===p)break;p=m}p!==null&&c.stopPropagation()}else hl(t,r,c,null,o)}}var us=null;function Ws(t,r,o,c){if(us=null,t=Kt(c),t=fs(t),t!==null)if(r=tr(t),r===null)t=null;else if(o=r.tag,o===13){if(t=Ls(r),t!==null)return t;t=null}else if(o===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;t=null}else r!==t&&(t=null);return us=t,null}function Pi(t){switch(t){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(nr()){case Sr:return 1;case ns:return 4;case dn:case Ea:return 16;case rr:return 536870912;default:return 16}default:return 16}}var An=null,Us=null,ds=null;function I(){if(ds)return ds;var t,r=Us,o=r.length,c,p="value"in An?An.value:An.textContent,m=p.length;for(t=0;t<o&&r[t]===p[t];t++);var v=o-t;for(c=1;c<=v&&r[o-c]===p[m-c];c++);return ds=p.slice(t,1<c?1-c:void 0)}function Z(t){var r=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&r===13&&(t=13)):t=r,t===10&&(t=13),32<=t||t===13?t:0}function Ee(){return!0}function Fe(){return!1}function Ce(t){function r(o,c,p,m,v){this._reactName=o,this._targetInst=p,this.type=c,this.nativeEvent=m,this.target=v,this.currentTarget=null;for(var S in t)t.hasOwnProperty(S)&&(o=t[S],this[S]=o?o(m):m[S]);return this.isDefaultPrevented=(m.defaultPrevented!=null?m.defaultPrevented:m.returnValue===!1)?Ee:Fe,this.isPropagationStopped=Fe,this}return G(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var o=this.nativeEvent;o&&(o.preventDefault?o.preventDefault():typeof o.returnValue!="unknown"&&(o.returnValue=!1),this.isDefaultPrevented=Ee)},stopPropagation:function(){var o=this.nativeEvent;o&&(o.stopPropagation?o.stopPropagation():typeof o.cancelBubble!="unknown"&&(o.cancelBubble=!0),this.isPropagationStopped=Ee)},persist:function(){},isPersistent:Ee}),r}var gt={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Un=Ce(gt),wn=G({},gt,{view:0,detail:0}),jt=Ce(wn),Pt,Ot,fn,hn=G({},wn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:nl,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==fn&&(fn&&t.type==="mousemove"?(Pt=t.screenX-fn.screenX,Ot=t.screenY-fn.screenY):Ot=Pt=0,fn=t),Pt)},movementY:function(t){return"movementY"in t?t.movementY:Ot}}),Nu=Ce(hn),lm=G({},hn,{dataTransfer:0}),cm=Ce(lm),um=G({},wn,{relatedTarget:0}),tl=Ce(um),dm=G({},gt,{animationName:0,elapsedTime:0,pseudoElement:0}),fm=Ce(dm),hm=G({},gt,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),pm=Ce(hm),mm=G({},gt,{data:0}),Cu=Ce(mm),gm={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},ym={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"},wm={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function vm(t){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(t):(t=wm[t])?!!r[t]:!1}function nl(){return vm}var _m=G({},wn,{key:function(t){if(t.key){var r=gm[t.key]||t.key;if(r!=="Unidentified")return r}return t.type==="keypress"?(t=Z(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?ym[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:nl,charCode:function(t){return t.type==="keypress"?Z(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Z(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),xm=Ce(_m),bm=G({},hn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Eu=Ce(bm),km=G({},wn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:nl}),jm=Ce(km),Sm=G({},gt,{propertyName:0,elapsedTime:0,pseudoElement:0}),Nm=Ce(Sm),Cm=G({},hn,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),Em=Ce(Cm),$m=[9,13,27,32],rl=f&&"CompositionEvent"in window,Oi=null;f&&"documentMode"in document&&(Oi=document.documentMode);var Am=f&&"TextEvent"in window&&!Oi,$u=f&&(!rl||Oi&&8<Oi&&11>=Oi),Au=" ",Tu=!1;function Ru(t,r){switch(t){case"keyup":return $m.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Iu(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Bs=!1;function Tm(t,r){switch(t){case"compositionend":return Iu(r);case"keypress":return r.which!==32?null:(Tu=!0,Au);case"textInput":return t=r.data,t===Au&&Tu?null:t;default:return null}}function Rm(t,r){if(Bs)return t==="compositionend"||!rl&&Ru(t,r)?(t=I(),ds=Us=An=null,Bs=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return $u&&r.locale!=="ko"?null:r.data;default:return null}}var Im={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 Mu(t){var r=t&&t.nodeName&&t.nodeName.toLowerCase();return r==="input"?!!Im[t.type]:r==="textarea"}function Lu(t,r,o,c){br(c),r=Wa(r,"onChange"),0<r.length&&(o=new Un("onChange","change",null,o,c),t.push({event:o,listeners:r}))}var Di=null,Fi=null;function Mm(t){qu(t,0)}function Oa(t){var r=Js(t);if(Y(r))return t}function Lm(t,r){if(t==="change")return r}var Pu=!1;if(f){var sl;if(f){var il="oninput"in document;if(!il){var Ou=document.createElement("div");Ou.setAttribute("oninput","return;"),il=typeof Ou.oninput=="function"}sl=il}else sl=!1;Pu=sl&&(!document.documentMode||9<document.documentMode)}function Du(){Di&&(Di.detachEvent("onpropertychange",Fu),Fi=Di=null)}function Fu(t){if(t.propertyName==="value"&&Oa(Fi)){var r=[];Lu(r,Fi,t,Kt(t)),ja(Mm,r)}}function Pm(t,r,o){t==="focusin"?(Du(),Di=r,Fi=o,Di.attachEvent("onpropertychange",Fu)):t==="focusout"&&Du()}function Om(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return Oa(Fi)}function Dm(t,r){if(t==="click")return Oa(r)}function Fm(t,r){if(t==="input"||t==="change")return Oa(r)}function zm(t,r){return t===r&&(t!==0||1/t===1/r)||t!==t&&r!==r}var Tn=typeof Object.is=="function"?Object.is:zm;function zi(t,r){if(Tn(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;var o=Object.keys(t),c=Object.keys(r);if(o.length!==c.length)return!1;for(c=0;c<o.length;c++){var p=o[c];if(!h.call(r,p)||!Tn(t[p],r[p]))return!1}return!0}function zu(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function Wu(t,r){var o=zu(t);t=0;for(var c;o;){if(o.nodeType===3){if(c=t+o.textContent.length,t<=r&&c>=r)return{node:o,offset:r-t};t=c}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=zu(o)}}function Uu(t,r){return t&&r?t===r?!0:t&&t.nodeType===3?!1:r&&r.nodeType===3?Uu(t,r.parentNode):"contains"in t?t.contains(r):t.compareDocumentPosition?!!(t.compareDocumentPosition(r)&16):!1:!1}function Bu(){for(var t=window,r=ee();r instanceof t.HTMLIFrameElement;){try{var o=typeof r.contentWindow.location.href=="string"}catch{o=!1}if(o)t=r.contentWindow;else break;r=ee(t.document)}return r}function al(t){var r=t&&t.nodeName&&t.nodeName.toLowerCase();return r&&(r==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||r==="textarea"||t.contentEditable==="true")}function Wm(t){var r=Bu(),o=t.focusedElem,c=t.selectionRange;if(r!==o&&o&&o.ownerDocument&&Uu(o.ownerDocument.documentElement,o)){if(c!==null&&al(o)){if(r=c.start,t=c.end,t===void 0&&(t=r),"selectionStart"in o)o.selectionStart=r,o.selectionEnd=Math.min(t,o.value.length);else if(t=(r=o.ownerDocument||document)&&r.defaultView||window,t.getSelection){t=t.getSelection();var p=o.textContent.length,m=Math.min(c.start,p);c=c.end===void 0?m:Math.min(c.end,p),!t.extend&&m>c&&(p=c,c=m,m=p),p=Wu(o,m);var v=Wu(o,c);p&&v&&(t.rangeCount!==1||t.anchorNode!==p.node||t.anchorOffset!==p.offset||t.focusNode!==v.node||t.focusOffset!==v.offset)&&(r=r.createRange(),r.setStart(p.node,p.offset),t.removeAllRanges(),m>c?(t.addRange(r),t.extend(v.node,v.offset)):(r.setEnd(v.node,v.offset),t.addRange(r)))}}for(r=[],t=o;t=t.parentNode;)t.nodeType===1&&r.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof o.focus=="function"&&o.focus(),o=0;o<r.length;o++)t=r[o],t.element.scrollLeft=t.left,t.element.scrollTop=t.top}}var Um=f&&"documentMode"in document&&11>=document.documentMode,Vs=null,ol=null,Wi=null,ll=!1;function Vu(t,r,o){var c=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;ll||Vs==null||Vs!==ee(c)||(c=Vs,"selectionStart"in c&&al(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),Wi&&zi(Wi,c)||(Wi=c,c=Wa(ol,"onSelect"),0<c.length&&(r=new Un("onSelect","select",null,r,o),t.push({event:r,listeners:c}),r.target=Vs)))}function Da(t,r){var o={};return o[t.toLowerCase()]=r.toLowerCase(),o["Webkit"+t]="webkit"+r,o["Moz"+t]="moz"+r,o}var Gs={animationend:Da("Animation","AnimationEnd"),animationiteration:Da("Animation","AnimationIteration"),animationstart:Da("Animation","AnimationStart"),transitionend:Da("Transition","TransitionEnd")},cl={},Gu={};f&&(Gu=document.createElement("div").style,"AnimationEvent"in window||(delete Gs.animationend.animation,delete Gs.animationiteration.animation,delete Gs.animationstart.animation),"TransitionEvent"in window||delete Gs.transitionend.transition);function Fa(t){if(cl[t])return cl[t];if(!Gs[t])return t;var r=Gs[t],o;for(o in r)if(r.hasOwnProperty(o)&&o in Gu)return cl[t]=r[o];return t}var Hu=Fa("animationend"),Ku=Fa("animationiteration"),Ju=Fa("animationstart"),Qu=Fa("transitionend"),Yu=new Map,Xu="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 Ir(t,r){Yu.set(t,r),u(r,[t])}for(var ul=0;ul<Xu.length;ul++){var dl=Xu[ul],Bm=dl.toLowerCase(),Vm=dl[0].toUpperCase()+dl.slice(1);Ir(Bm,"on"+Vm)}Ir(Hu,"onAnimationEnd"),Ir(Ku,"onAnimationIteration"),Ir(Ju,"onAnimationStart"),Ir("dblclick","onDoubleClick"),Ir("focusin","onFocus"),Ir("focusout","onBlur"),Ir(Qu,"onTransitionEnd"),d("onMouseEnter",["mouseout","mouseover"]),d("onMouseLeave",["mouseout","mouseover"]),d("onPointerEnter",["pointerout","pointerover"]),d("onPointerLeave",["pointerout","pointerover"]),u("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),u("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),u("onBeforeInput",["compositionend","keypress","textInput","paste"]),u("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ui="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Gm=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ui));function Zu(t,r,o){var c=t.type||"unknown-event";t.currentTarget=o,Ni(c,r,void 0,t),t.currentTarget=null}function qu(t,r){r=(r&4)!==0;for(var o=0;o<t.length;o++){var c=t[o],p=c.event;c=c.listeners;e:{var m=void 0;if(r)for(var v=c.length-1;0<=v;v--){var S=c[v],R=S.instance,z=S.currentTarget;if(S=S.listener,R!==m&&p.isPropagationStopped())break e;Zu(p,S,z),m=R}else for(v=0;v<c.length;v++){if(S=c[v],R=S.instance,z=S.currentTarget,S=S.listener,R!==m&&p.isPropagationStopped())break e;Zu(p,S,z),m=R}}}if(Qt)throw t=Is,Qt=!1,Is=null,t}function it(t,r){var o=r[vl];o===void 0&&(o=r[vl]=new Set);var c=t+"__bubble";o.has(c)||(ed(r,t,2,!1),o.add(c))}function fl(t,r,o){var c=0;r&&(c|=4),ed(o,t,c,r)}var za="_reactListening"+Math.random().toString(36).slice(2);function Bi(t){if(!t[za]){t[za]=!0,a.forEach(function(o){o!=="selectionchange"&&(Gm.has(o)||fl(o,!1,t),fl(o,!0,t))});var r=t.nodeType===9?t:t.ownerDocument;r===null||r[za]||(r[za]=!0,fl("selectionchange",!1,r))}}function ed(t,r,o,c){switch(Pi(r)){case 1:var p=La;break;case 4:p=Pa;break;default:p=zs}o=p.bind(null,r,o,t),p=void 0,!qn||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(p=!0),c?p!==void 0?t.addEventListener(r,o,{capture:!0,passive:p}):t.addEventListener(r,o,!0):p!==void 0?t.addEventListener(r,o,{passive:p}):t.addEventListener(r,o,!1)}function hl(t,r,o,c,p){var m=c;if((r&1)===0&&(r&2)===0&&c!==null)e:for(;;){if(c===null)return;var v=c.tag;if(v===3||v===4){var S=c.stateNode.containerInfo;if(S===p||S.nodeType===8&&S.parentNode===p)break;if(v===4)for(v=c.return;v!==null;){var R=v.tag;if((R===3||R===4)&&(R=v.stateNode.containerInfo,R===p||R.nodeType===8&&R.parentNode===p))return;v=v.return}for(;S!==null;){if(v=fs(S),v===null)return;if(R=v.tag,R===5||R===6){c=m=v;continue e}S=S.parentNode}}c=c.return}ja(function(){var z=m,ne=Kt(o),se=[];e:{var te=Yu.get(t);if(te!==void 0){var ge=Un,xe=t;switch(t){case"keypress":if(Z(o)===0)break e;case"keydown":case"keyup":ge=xm;break;case"focusin":xe="focus",ge=tl;break;case"focusout":xe="blur",ge=tl;break;case"beforeblur":case"afterblur":ge=tl;break;case"click":if(o.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ge=Nu;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ge=cm;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ge=jm;break;case Hu:case Ku:case Ju:ge=fm;break;case Qu:ge=Nm;break;case"scroll":ge=jt;break;case"wheel":ge=Em;break;case"copy":case"cut":case"paste":ge=pm;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ge=Eu}var be=(r&4)!==0,yt=!be&&t==="scroll",O=be?te!==null?te+"Capture":null:te;be=[];for(var M=z,D;M!==null;){D=M;var ue=D.stateNode;if(D.tag===5&&ue!==null&&(D=ue,O!==null&&(ue=kr(M,O),ue!=null&&be.push(Vi(M,ue,D)))),yt)break;M=M.return}0<be.length&&(te=new ge(te,xe,null,o,ne),se.push({event:te,listeners:be}))}}if((r&7)===0){e:{if(te=t==="mouseover"||t==="pointerover",ge=t==="mouseout"||t==="pointerout",te&&o!==_r&&(xe=o.relatedTarget||o.fromElement)&&(fs(xe)||xe[or]))break e;if((ge||te)&&(te=ne.window===ne?ne:(te=ne.ownerDocument)?te.defaultView||te.parentWindow:window,ge?(xe=o.relatedTarget||o.toElement,ge=z,xe=xe?fs(xe):null,xe!==null&&(yt=tr(xe),xe!==yt||xe.tag!==5&&xe.tag!==6)&&(xe=null)):(ge=null,xe=z),ge!==xe)){if(be=Nu,ue="onMouseLeave",O="onMouseEnter",M="mouse",(t==="pointerout"||t==="pointerover")&&(be=Eu,ue="onPointerLeave",O="onPointerEnter",M="pointer"),yt=ge==null?te:Js(ge),D=xe==null?te:Js(xe),te=new be(ue,M+"leave",ge,o,ne),te.target=yt,te.relatedTarget=D,ue=null,fs(ne)===z&&(be=new be(O,M+"enter",xe,o,ne),be.target=D,be.relatedTarget=yt,ue=be),yt=ue,ge&&xe)t:{for(be=ge,O=xe,M=0,D=be;D;D=Hs(D))M++;for(D=0,ue=O;ue;ue=Hs(ue))D++;for(;0<M-D;)be=Hs(be),M--;for(;0<D-M;)O=Hs(O),D--;for(;M--;){if(be===O||O!==null&&be===O.alternate)break t;be=Hs(be),O=Hs(O)}be=null}else be=null;ge!==null&&td(se,te,ge,be,!1),xe!==null&&yt!==null&&td(se,yt,xe,be,!0)}}e:{if(te=z?Js(z):window,ge=te.nodeName&&te.nodeName.toLowerCase(),ge==="select"||ge==="input"&&te.type==="file")var je=Lm;else if(Mu(te))if(Pu)je=Fm;else{je=Om;var Ae=Pm}else(ge=te.nodeName)&&ge.toLowerCase()==="input"&&(te.type==="checkbox"||te.type==="radio")&&(je=Dm);if(je&&(je=je(t,z))){Lu(se,je,o,ne);break e}Ae&&Ae(t,te,z),t==="focusout"&&(Ae=te._wrapperState)&&Ae.controlled&&te.type==="number"&&rt(te,"number",te.value)}switch(Ae=z?Js(z):window,t){case"focusin":(Mu(Ae)||Ae.contentEditable==="true")&&(Vs=Ae,ol=z,Wi=null);break;case"focusout":Wi=ol=Vs=null;break;case"mousedown":ll=!0;break;case"contextmenu":case"mouseup":case"dragend":ll=!1,Vu(se,o,ne);break;case"selectionchange":if(Um)break;case"keydown":case"keyup":Vu(se,o,ne)}var Te;if(rl)e:{switch(t){case"compositionstart":var Me="onCompositionStart";break e;case"compositionend":Me="onCompositionEnd";break e;case"compositionupdate":Me="onCompositionUpdate";break e}Me=void 0}else Bs?Ru(t,o)&&(Me="onCompositionEnd"):t==="keydown"&&o.keyCode===229&&(Me="onCompositionStart");Me&&($u&&o.locale!=="ko"&&(Bs||Me!=="onCompositionStart"?Me==="onCompositionEnd"&&Bs&&(Te=I()):(An=ne,Us="value"in An?An.value:An.textContent,Bs=!0)),Ae=Wa(z,Me),0<Ae.length&&(Me=new Cu(Me,t,null,o,ne),se.push({event:Me,listeners:Ae}),Te?Me.data=Te:(Te=Iu(o),Te!==null&&(Me.data=Te)))),(Te=Am?Tm(t,o):Rm(t,o))&&(z=Wa(z,"onBeforeInput"),0<z.length&&(ne=new Cu("onBeforeInput","beforeinput",null,o,ne),se.push({event:ne,listeners:z}),ne.data=Te))}qu(se,r)})}function Vi(t,r,o){return{instance:t,listener:r,currentTarget:o}}function Wa(t,r){for(var o=r+"Capture",c=[];t!==null;){var p=t,m=p.stateNode;p.tag===5&&m!==null&&(p=m,m=kr(t,o),m!=null&&c.unshift(Vi(t,m,p)),m=kr(t,r),m!=null&&c.push(Vi(t,m,p))),t=t.return}return c}function Hs(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5);return t||null}function td(t,r,o,c,p){for(var m=r._reactName,v=[];o!==null&&o!==c;){var S=o,R=S.alternate,z=S.stateNode;if(R!==null&&R===c)break;S.tag===5&&z!==null&&(S=z,p?(R=kr(o,m),R!=null&&v.unshift(Vi(o,R,S))):p||(R=kr(o,m),R!=null&&v.push(Vi(o,R,S)))),o=o.return}v.length!==0&&t.push({event:r,listeners:v})}var Hm=/\r\n?/g,Km=/\u0000|\uFFFD/g;function nd(t){return(typeof t=="string"?t:""+t).replace(Hm,`
38
+ `).replace(Km,"")}function Ua(t,r,o){if(r=nd(r),nd(t)!==r&&o)throw Error(s(425))}function Ba(){}var pl=null,ml=null;function gl(t,r){return t==="textarea"||t==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var yl=typeof setTimeout=="function"?setTimeout:void 0,Jm=typeof clearTimeout=="function"?clearTimeout:void 0,rd=typeof Promise=="function"?Promise:void 0,Qm=typeof queueMicrotask=="function"?queueMicrotask:typeof rd<"u"?function(t){return rd.resolve(null).then(t).catch(Ym)}:yl;function Ym(t){setTimeout(function(){throw t})}function wl(t,r){var o=r,c=0;do{var p=o.nextSibling;if(t.removeChild(o),p&&p.nodeType===8)if(o=p.data,o==="/$"){if(c===0){t.removeChild(p),Rr(r);return}c--}else o!=="$"&&o!=="$?"&&o!=="$!"||c++;o=p}while(o);Rr(r)}function Mr(t){for(;t!=null;t=t.nextSibling){var r=t.nodeType;if(r===1||r===3)break;if(r===8){if(r=t.data,r==="$"||r==="$!"||r==="$?")break;if(r==="/$")return null}}return t}function sd(t){t=t.previousSibling;for(var r=0;t;){if(t.nodeType===8){var o=t.data;if(o==="$"||o==="$!"||o==="$?"){if(r===0)return t;r--}else o==="/$"&&r++}t=t.previousSibling}return null}var Ks=Math.random().toString(36).slice(2),Bn="__reactFiber$"+Ks,Gi="__reactProps$"+Ks,or="__reactContainer$"+Ks,vl="__reactEvents$"+Ks,Xm="__reactListeners$"+Ks,Zm="__reactHandles$"+Ks;function fs(t){var r=t[Bn];if(r)return r;for(var o=t.parentNode;o;){if(r=o[or]||o[Bn]){if(o=r.alternate,r.child!==null||o!==null&&o.child!==null)for(t=sd(t);t!==null;){if(o=t[Bn])return o;t=sd(t)}return r}t=o,o=t.parentNode}return null}function Hi(t){return t=t[Bn]||t[or],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function Js(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(s(33))}function Va(t){return t[Gi]||null}var _l=[],Qs=-1;function Lr(t){return{current:t}}function at(t){0>Qs||(t.current=_l[Qs],_l[Qs]=null,Qs--)}function nt(t,r){Qs++,_l[Qs]=t.current,t.current=r}var Pr={},Dt=Lr(Pr),Xt=Lr(!1),hs=Pr;function Ys(t,r){var o=t.type.contextTypes;if(!o)return Pr;var c=t.stateNode;if(c&&c.__reactInternalMemoizedUnmaskedChildContext===r)return c.__reactInternalMemoizedMaskedChildContext;var p={},m;for(m in o)p[m]=r[m];return c&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=r,t.__reactInternalMemoizedMaskedChildContext=p),p}function Zt(t){return t=t.childContextTypes,t!=null}function Ga(){at(Xt),at(Dt)}function id(t,r,o){if(Dt.current!==Pr)throw Error(s(168));nt(Dt,r),nt(Xt,o)}function ad(t,r,o){var c=t.stateNode;if(r=r.childContextTypes,typeof c.getChildContext!="function")return o;c=c.getChildContext();for(var p in c)if(!(p in r))throw Error(s(108,he(t)||"Unknown",p));return G({},o,c)}function Ha(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Pr,hs=Dt.current,nt(Dt,t),nt(Xt,Xt.current),!0}function od(t,r,o){var c=t.stateNode;if(!c)throw Error(s(169));o?(t=ad(t,r,hs),c.__reactInternalMemoizedMergedChildContext=t,at(Xt),at(Dt),nt(Dt,t)):at(Xt),nt(Xt,o)}var lr=null,Ka=!1,xl=!1;function ld(t){lr===null?lr=[t]:lr.push(t)}function qm(t){Ka=!0,ld(t)}function Or(){if(!xl&&lr!==null){xl=!0;var t=0,r=Je;try{var o=lr;for(Je=1;t<o.length;t++){var c=o[t];do c=c(!0);while(c!==null)}lr=null,Ka=!1}catch(p){throw lr!==null&&(lr=lr.slice(t+1)),Ca(Sr,Or),p}finally{Je=r,xl=!1}}return null}var Xs=[],Zs=0,Ja=null,Qa=0,vn=[],_n=0,ps=null,cr=1,ur="";function ms(t,r){Xs[Zs++]=Qa,Xs[Zs++]=Ja,Ja=t,Qa=r}function cd(t,r,o){vn[_n++]=cr,vn[_n++]=ur,vn[_n++]=ps,ps=t;var c=cr;t=ur;var p=32-mt(c)-1;c&=~(1<<p),o+=1;var m=32-mt(r)+p;if(30<m){var v=p-p%5;m=(c&(1<<v)-1).toString(32),c>>=v,p-=v,cr=1<<32-mt(r)+p|o<<p|c,ur=m+t}else cr=1<<m|o<<p|c,ur=t}function bl(t){t.return!==null&&(ms(t,1),cd(t,1,0))}function kl(t){for(;t===Ja;)Ja=Xs[--Zs],Xs[Zs]=null,Qa=Xs[--Zs],Xs[Zs]=null;for(;t===ps;)ps=vn[--_n],vn[_n]=null,ur=vn[--_n],vn[_n]=null,cr=vn[--_n],vn[_n]=null}var pn=null,mn=null,ot=!1,Rn=null;function ud(t,r){var o=jn(5,null,null,0);o.elementType="DELETED",o.stateNode=r,o.return=t,r=t.deletions,r===null?(t.deletions=[o],t.flags|=16):r.push(o)}function dd(t,r){switch(t.tag){case 5:var o=t.type;return r=r.nodeType!==1||o.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(t.stateNode=r,pn=t,mn=Mr(r.firstChild),!0):!1;case 6:return r=t.pendingProps===""||r.nodeType!==3?null:r,r!==null?(t.stateNode=r,pn=t,mn=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(o=ps!==null?{id:cr,overflow:ur}:null,t.memoizedState={dehydrated:r,treeContext:o,retryLane:1073741824},o=jn(18,null,null,0),o.stateNode=r,o.return=t,t.child=o,pn=t,mn=null,!0):!1;default:return!1}}function jl(t){return(t.mode&1)!==0&&(t.flags&128)===0}function Sl(t){if(ot){var r=mn;if(r){var o=r;if(!dd(t,r)){if(jl(t))throw Error(s(418));r=Mr(o.nextSibling);var c=pn;r&&dd(t,r)?ud(c,o):(t.flags=t.flags&-4097|2,ot=!1,pn=t)}}else{if(jl(t))throw Error(s(418));t.flags=t.flags&-4097|2,ot=!1,pn=t}}}function fd(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;pn=t}function Ya(t){if(t!==pn)return!1;if(!ot)return fd(t),ot=!0,!1;var r;if((r=t.tag!==3)&&!(r=t.tag!==5)&&(r=t.type,r=r!=="head"&&r!=="body"&&!gl(t.type,t.memoizedProps)),r&&(r=mn)){if(jl(t))throw hd(),Error(s(418));for(;r;)ud(t,r),r=Mr(r.nextSibling)}if(fd(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(s(317));e:{for(t=t.nextSibling,r=0;t;){if(t.nodeType===8){var o=t.data;if(o==="/$"){if(r===0){mn=Mr(t.nextSibling);break e}r--}else o!=="$"&&o!=="$!"&&o!=="$?"||r++}t=t.nextSibling}mn=null}}else mn=pn?Mr(t.stateNode.nextSibling):null;return!0}function hd(){for(var t=mn;t;)t=Mr(t.nextSibling)}function qs(){mn=pn=null,ot=!1}function Nl(t){Rn===null?Rn=[t]:Rn.push(t)}var eg=k.ReactCurrentBatchConfig;function Ki(t,r,o){if(t=o.ref,t!==null&&typeof t!="function"&&typeof t!="object"){if(o._owner){if(o=o._owner,o){if(o.tag!==1)throw Error(s(309));var c=o.stateNode}if(!c)throw Error(s(147,t));var p=c,m=""+t;return r!==null&&r.ref!==null&&typeof r.ref=="function"&&r.ref._stringRef===m?r.ref:(r=function(v){var S=p.refs;v===null?delete S[m]:S[m]=v},r._stringRef=m,r)}if(typeof t!="string")throw Error(s(284));if(!o._owner)throw Error(s(290,t))}return t}function Xa(t,r){throw t=Object.prototype.toString.call(r),Error(s(31,t==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":t))}function pd(t){var r=t._init;return r(t._payload)}function md(t){function r(O,M){if(t){var D=O.deletions;D===null?(O.deletions=[M],O.flags|=16):D.push(M)}}function o(O,M){if(!t)return null;for(;M!==null;)r(O,M),M=M.sibling;return null}function c(O,M){for(O=new Map;M!==null;)M.key!==null?O.set(M.key,M):O.set(M.index,M),M=M.sibling;return O}function p(O,M){return O=Gr(O,M),O.index=0,O.sibling=null,O}function m(O,M,D){return O.index=D,t?(D=O.alternate,D!==null?(D=D.index,D<M?(O.flags|=2,M):D):(O.flags|=2,M)):(O.flags|=1048576,M)}function v(O){return t&&O.alternate===null&&(O.flags|=2),O}function S(O,M,D,ue){return M===null||M.tag!==6?(M=yc(D,O.mode,ue),M.return=O,M):(M=p(M,D),M.return=O,M)}function R(O,M,D,ue){var je=D.type;return je===H?ne(O,M,D.props.children,ue,D.key):M!==null&&(M.elementType===je||typeof je=="object"&&je!==null&&je.$$typeof===ye&&pd(je)===M.type)?(ue=p(M,D.props),ue.ref=Ki(O,M,D),ue.return=O,ue):(ue=bo(D.type,D.key,D.props,null,O.mode,ue),ue.ref=Ki(O,M,D),ue.return=O,ue)}function z(O,M,D,ue){return M===null||M.tag!==4||M.stateNode.containerInfo!==D.containerInfo||M.stateNode.implementation!==D.implementation?(M=wc(D,O.mode,ue),M.return=O,M):(M=p(M,D.children||[]),M.return=O,M)}function ne(O,M,D,ue,je){return M===null||M.tag!==7?(M=ks(D,O.mode,ue,je),M.return=O,M):(M=p(M,D),M.return=O,M)}function se(O,M,D){if(typeof M=="string"&&M!==""||typeof M=="number")return M=yc(""+M,O.mode,D),M.return=O,M;if(typeof M=="object"&&M!==null){switch(M.$$typeof){case P:return D=bo(M.type,M.key,M.props,null,O.mode,D),D.ref=Ki(O,null,M),D.return=O,D;case V:return M=wc(M,O.mode,D),M.return=O,M;case ye:var ue=M._init;return se(O,ue(M._payload),D)}if(K(M)||oe(M))return M=ks(M,O.mode,D,null),M.return=O,M;Xa(O,M)}return null}function te(O,M,D,ue){var je=M!==null?M.key:null;if(typeof D=="string"&&D!==""||typeof D=="number")return je!==null?null:S(O,M,""+D,ue);if(typeof D=="object"&&D!==null){switch(D.$$typeof){case P:return D.key===je?R(O,M,D,ue):null;case V:return D.key===je?z(O,M,D,ue):null;case ye:return je=D._init,te(O,M,je(D._payload),ue)}if(K(D)||oe(D))return je!==null?null:ne(O,M,D,ue,null);Xa(O,D)}return null}function ge(O,M,D,ue,je){if(typeof ue=="string"&&ue!==""||typeof ue=="number")return O=O.get(D)||null,S(M,O,""+ue,je);if(typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case P:return O=O.get(ue.key===null?D:ue.key)||null,R(M,O,ue,je);case V:return O=O.get(ue.key===null?D:ue.key)||null,z(M,O,ue,je);case ye:var Ae=ue._init;return ge(O,M,D,Ae(ue._payload),je)}if(K(ue)||oe(ue))return O=O.get(D)||null,ne(M,O,ue,je,null);Xa(M,ue)}return null}function xe(O,M,D,ue){for(var je=null,Ae=null,Te=M,Me=M=0,Ct=null;Te!==null&&Me<D.length;Me++){Te.index>Me?(Ct=Te,Te=null):Ct=Te.sibling;var Ye=te(O,Te,D[Me],ue);if(Ye===null){Te===null&&(Te=Ct);break}t&&Te&&Ye.alternate===null&&r(O,Te),M=m(Ye,M,Me),Ae===null?je=Ye:Ae.sibling=Ye,Ae=Ye,Te=Ct}if(Me===D.length)return o(O,Te),ot&&ms(O,Me),je;if(Te===null){for(;Me<D.length;Me++)Te=se(O,D[Me],ue),Te!==null&&(M=m(Te,M,Me),Ae===null?je=Te:Ae.sibling=Te,Ae=Te);return ot&&ms(O,Me),je}for(Te=c(O,Te);Me<D.length;Me++)Ct=ge(Te,O,Me,D[Me],ue),Ct!==null&&(t&&Ct.alternate!==null&&Te.delete(Ct.key===null?Me:Ct.key),M=m(Ct,M,Me),Ae===null?je=Ct:Ae.sibling=Ct,Ae=Ct);return t&&Te.forEach(function(Hr){return r(O,Hr)}),ot&&ms(O,Me),je}function be(O,M,D,ue){var je=oe(D);if(typeof je!="function")throw Error(s(150));if(D=je.call(D),D==null)throw Error(s(151));for(var Ae=je=null,Te=M,Me=M=0,Ct=null,Ye=D.next();Te!==null&&!Ye.done;Me++,Ye=D.next()){Te.index>Me?(Ct=Te,Te=null):Ct=Te.sibling;var Hr=te(O,Te,Ye.value,ue);if(Hr===null){Te===null&&(Te=Ct);break}t&&Te&&Hr.alternate===null&&r(O,Te),M=m(Hr,M,Me),Ae===null?je=Hr:Ae.sibling=Hr,Ae=Hr,Te=Ct}if(Ye.done)return o(O,Te),ot&&ms(O,Me),je;if(Te===null){for(;!Ye.done;Me++,Ye=D.next())Ye=se(O,Ye.value,ue),Ye!==null&&(M=m(Ye,M,Me),Ae===null?je=Ye:Ae.sibling=Ye,Ae=Ye);return ot&&ms(O,Me),je}for(Te=c(O,Te);!Ye.done;Me++,Ye=D.next())Ye=ge(Te,O,Me,Ye.value,ue),Ye!==null&&(t&&Ye.alternate!==null&&Te.delete(Ye.key===null?Me:Ye.key),M=m(Ye,M,Me),Ae===null?je=Ye:Ae.sibling=Ye,Ae=Ye);return t&&Te.forEach(function(Ig){return r(O,Ig)}),ot&&ms(O,Me),je}function yt(O,M,D,ue){if(typeof D=="object"&&D!==null&&D.type===H&&D.key===null&&(D=D.props.children),typeof D=="object"&&D!==null){switch(D.$$typeof){case P:e:{for(var je=D.key,Ae=M;Ae!==null;){if(Ae.key===je){if(je=D.type,je===H){if(Ae.tag===7){o(O,Ae.sibling),M=p(Ae,D.props.children),M.return=O,O=M;break e}}else if(Ae.elementType===je||typeof je=="object"&&je!==null&&je.$$typeof===ye&&pd(je)===Ae.type){o(O,Ae.sibling),M=p(Ae,D.props),M.ref=Ki(O,Ae,D),M.return=O,O=M;break e}o(O,Ae);break}else r(O,Ae);Ae=Ae.sibling}D.type===H?(M=ks(D.props.children,O.mode,ue,D.key),M.return=O,O=M):(ue=bo(D.type,D.key,D.props,null,O.mode,ue),ue.ref=Ki(O,M,D),ue.return=O,O=ue)}return v(O);case V:e:{for(Ae=D.key;M!==null;){if(M.key===Ae)if(M.tag===4&&M.stateNode.containerInfo===D.containerInfo&&M.stateNode.implementation===D.implementation){o(O,M.sibling),M=p(M,D.children||[]),M.return=O,O=M;break e}else{o(O,M);break}else r(O,M);M=M.sibling}M=wc(D,O.mode,ue),M.return=O,O=M}return v(O);case ye:return Ae=D._init,yt(O,M,Ae(D._payload),ue)}if(K(D))return xe(O,M,D,ue);if(oe(D))return be(O,M,D,ue);Xa(O,D)}return typeof D=="string"&&D!==""||typeof D=="number"?(D=""+D,M!==null&&M.tag===6?(o(O,M.sibling),M=p(M,D),M.return=O,O=M):(o(O,M),M=yc(D,O.mode,ue),M.return=O,O=M),v(O)):o(O,M)}return yt}var ei=md(!0),gd=md(!1),Za=Lr(null),qa=null,ti=null,Cl=null;function El(){Cl=ti=qa=null}function $l(t){var r=Za.current;at(Za),t._currentValue=r}function Al(t,r,o){for(;t!==null;){var c=t.alternate;if((t.childLanes&r)!==r?(t.childLanes|=r,c!==null&&(c.childLanes|=r)):c!==null&&(c.childLanes&r)!==r&&(c.childLanes|=r),t===o)break;t=t.return}}function ni(t,r){qa=t,Cl=ti=null,t=t.dependencies,t!==null&&t.firstContext!==null&&((t.lanes&r)!==0&&(qt=!0),t.firstContext=null)}function xn(t){var r=t._currentValue;if(Cl!==t)if(t={context:t,memoizedValue:r,next:null},ti===null){if(qa===null)throw Error(s(308));ti=t,qa.dependencies={lanes:0,firstContext:t}}else ti=ti.next=t;return r}var gs=null;function Tl(t){gs===null?gs=[t]:gs.push(t)}function yd(t,r,o,c){var p=r.interleaved;return p===null?(o.next=o,Tl(r)):(o.next=p.next,p.next=o),r.interleaved=o,dr(t,c)}function dr(t,r){t.lanes|=r;var o=t.alternate;for(o!==null&&(o.lanes|=r),o=t,t=t.return;t!==null;)t.childLanes|=r,o=t.alternate,o!==null&&(o.childLanes|=r),o=t,t=t.return;return o.tag===3?o.stateNode:null}var Dr=!1;function Rl(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function wd(t,r){t=t.updateQueue,r.updateQueue===t&&(r.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function fr(t,r){return{eventTime:t,lane:r,tag:0,payload:null,callback:null,next:null}}function Fr(t,r,o){var c=t.updateQueue;if(c===null)return null;if(c=c.shared,(Qe&2)!==0){var p=c.pending;return p===null?r.next=r:(r.next=p.next,p.next=r),c.pending=r,dr(t,o)}return p=c.interleaved,p===null?(r.next=r,Tl(c)):(r.next=p.next,p.next=r),c.interleaved=r,dr(t,o)}function eo(t,r,o){if(r=r.updateQueue,r!==null&&(r=r.shared,(o&4194240)!==0)){var c=r.lanes;c&=t.pendingLanes,o|=c,r.lanes=o,_t(t,o)}}function vd(t,r){var o=t.updateQueue,c=t.alternate;if(c!==null&&(c=c.updateQueue,o===c)){var p=null,m=null;if(o=o.firstBaseUpdate,o!==null){do{var v={eventTime:o.eventTime,lane:o.lane,tag:o.tag,payload:o.payload,callback:o.callback,next:null};m===null?p=m=v:m=m.next=v,o=o.next}while(o!==null);m===null?p=m=r:m=m.next=r}else p=m=r;o={baseState:c.baseState,firstBaseUpdate:p,lastBaseUpdate:m,shared:c.shared,effects:c.effects},t.updateQueue=o;return}t=o.lastBaseUpdate,t===null?o.firstBaseUpdate=r:t.next=r,o.lastBaseUpdate=r}function to(t,r,o,c){var p=t.updateQueue;Dr=!1;var m=p.firstBaseUpdate,v=p.lastBaseUpdate,S=p.shared.pending;if(S!==null){p.shared.pending=null;var R=S,z=R.next;R.next=null,v===null?m=z:v.next=z,v=R;var ne=t.alternate;ne!==null&&(ne=ne.updateQueue,S=ne.lastBaseUpdate,S!==v&&(S===null?ne.firstBaseUpdate=z:S.next=z,ne.lastBaseUpdate=R))}if(m!==null){var se=p.baseState;v=0,ne=z=R=null,S=m;do{var te=S.lane,ge=S.eventTime;if((c&te)===te){ne!==null&&(ne=ne.next={eventTime:ge,lane:0,tag:S.tag,payload:S.payload,callback:S.callback,next:null});e:{var xe=t,be=S;switch(te=r,ge=o,be.tag){case 1:if(xe=be.payload,typeof xe=="function"){se=xe.call(ge,se,te);break e}se=xe;break e;case 3:xe.flags=xe.flags&-65537|128;case 0:if(xe=be.payload,te=typeof xe=="function"?xe.call(ge,se,te):xe,te==null)break e;se=G({},se,te);break e;case 2:Dr=!0}}S.callback!==null&&S.lane!==0&&(t.flags|=64,te=p.effects,te===null?p.effects=[S]:te.push(S))}else ge={eventTime:ge,lane:te,tag:S.tag,payload:S.payload,callback:S.callback,next:null},ne===null?(z=ne=ge,R=se):ne=ne.next=ge,v|=te;if(S=S.next,S===null){if(S=p.shared.pending,S===null)break;te=S,S=te.next,te.next=null,p.lastBaseUpdate=te,p.shared.pending=null}}while(!0);if(ne===null&&(R=se),p.baseState=R,p.firstBaseUpdate=z,p.lastBaseUpdate=ne,r=p.shared.interleaved,r!==null){p=r;do v|=p.lane,p=p.next;while(p!==r)}else m===null&&(p.shared.lanes=0);vs|=v,t.lanes=v,t.memoizedState=se}}function _d(t,r,o){if(t=r.effects,r.effects=null,t!==null)for(r=0;r<t.length;r++){var c=t[r],p=c.callback;if(p!==null){if(c.callback=null,c=o,typeof p!="function")throw Error(s(191,p));p.call(c)}}}var Ji={},Vn=Lr(Ji),Qi=Lr(Ji),Yi=Lr(Ji);function ys(t){if(t===Ji)throw Error(s(174));return t}function Il(t,r){switch(nt(Yi,r),nt(Qi,t),nt(Vn,Ji),t=r.nodeType,t){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:Cn(null,"");break;default:t=t===8?r.parentNode:r,r=t.namespaceURI||null,t=t.tagName,r=Cn(r,t)}at(Vn),nt(Vn,r)}function ri(){at(Vn),at(Qi),at(Yi)}function xd(t){ys(Yi.current);var r=ys(Vn.current),o=Cn(r,t.type);r!==o&&(nt(Qi,t),nt(Vn,o))}function Ml(t){Qi.current===t&&(at(Vn),at(Qi))}var ct=Lr(0);function no(t){for(var r=t;r!==null;){if(r.tag===13){var o=r.memoizedState;if(o!==null&&(o=o.dehydrated,o===null||o.data==="$?"||o.data==="$!"))return r}else if(r.tag===19&&r.memoizedProps.revealOrder!==void 0){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===t)break;for(;r.sibling===null;){if(r.return===null||r.return===t)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var Ll=[];function Pl(){for(var t=0;t<Ll.length;t++)Ll[t]._workInProgressVersionPrimary=null;Ll.length=0}var ro=k.ReactCurrentDispatcher,Ol=k.ReactCurrentBatchConfig,ws=0,ut=null,xt=null,St=null,so=!1,Xi=!1,Zi=0,tg=0;function Ft(){throw Error(s(321))}function Dl(t,r){if(r===null)return!1;for(var o=0;o<r.length&&o<t.length;o++)if(!Tn(t[o],r[o]))return!1;return!0}function Fl(t,r,o,c,p,m){if(ws=m,ut=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,ro.current=t===null||t.memoizedState===null?ig:ag,t=o(c,p),Xi){m=0;do{if(Xi=!1,Zi=0,25<=m)throw Error(s(301));m+=1,St=xt=null,r.updateQueue=null,ro.current=og,t=o(c,p)}while(Xi)}if(ro.current=oo,r=xt!==null&&xt.next!==null,ws=0,St=xt=ut=null,so=!1,r)throw Error(s(300));return t}function zl(){var t=Zi!==0;return Zi=0,t}function Gn(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return St===null?ut.memoizedState=St=t:St=St.next=t,St}function bn(){if(xt===null){var t=ut.alternate;t=t!==null?t.memoizedState:null}else t=xt.next;var r=St===null?ut.memoizedState:St.next;if(r!==null)St=r,xt=t;else{if(t===null)throw Error(s(310));xt=t,t={memoizedState:xt.memoizedState,baseState:xt.baseState,baseQueue:xt.baseQueue,queue:xt.queue,next:null},St===null?ut.memoizedState=St=t:St=St.next=t}return St}function qi(t,r){return typeof r=="function"?r(t):r}function Wl(t){var r=bn(),o=r.queue;if(o===null)throw Error(s(311));o.lastRenderedReducer=t;var c=xt,p=c.baseQueue,m=o.pending;if(m!==null){if(p!==null){var v=p.next;p.next=m.next,m.next=v}c.baseQueue=p=m,o.pending=null}if(p!==null){m=p.next,c=c.baseState;var S=v=null,R=null,z=m;do{var ne=z.lane;if((ws&ne)===ne)R!==null&&(R=R.next={lane:0,action:z.action,hasEagerState:z.hasEagerState,eagerState:z.eagerState,next:null}),c=z.hasEagerState?z.eagerState:t(c,z.action);else{var se={lane:ne,action:z.action,hasEagerState:z.hasEagerState,eagerState:z.eagerState,next:null};R===null?(S=R=se,v=c):R=R.next=se,ut.lanes|=ne,vs|=ne}z=z.next}while(z!==null&&z!==m);R===null?v=c:R.next=S,Tn(c,r.memoizedState)||(qt=!0),r.memoizedState=c,r.baseState=v,r.baseQueue=R,o.lastRenderedState=c}if(t=o.interleaved,t!==null){p=t;do m=p.lane,ut.lanes|=m,vs|=m,p=p.next;while(p!==t)}else p===null&&(o.lanes=0);return[r.memoizedState,o.dispatch]}function Ul(t){var r=bn(),o=r.queue;if(o===null)throw Error(s(311));o.lastRenderedReducer=t;var c=o.dispatch,p=o.pending,m=r.memoizedState;if(p!==null){o.pending=null;var v=p=p.next;do m=t(m,v.action),v=v.next;while(v!==p);Tn(m,r.memoizedState)||(qt=!0),r.memoizedState=m,r.baseQueue===null&&(r.baseState=m),o.lastRenderedState=m}return[m,c]}function bd(){}function kd(t,r){var o=ut,c=bn(),p=r(),m=!Tn(c.memoizedState,p);if(m&&(c.memoizedState=p,qt=!0),c=c.queue,Bl(Nd.bind(null,o,c,t),[t]),c.getSnapshot!==r||m||St!==null&&St.memoizedState.tag&1){if(o.flags|=2048,ea(9,Sd.bind(null,o,c,p,r),void 0,null),Nt===null)throw Error(s(349));(ws&30)!==0||jd(o,r,p)}return p}function jd(t,r,o){t.flags|=16384,t={getSnapshot:r,value:o},r=ut.updateQueue,r===null?(r={lastEffect:null,stores:null},ut.updateQueue=r,r.stores=[t]):(o=r.stores,o===null?r.stores=[t]:o.push(t))}function Sd(t,r,o,c){r.value=o,r.getSnapshot=c,Cd(r)&&Ed(t)}function Nd(t,r,o){return o(function(){Cd(r)&&Ed(t)})}function Cd(t){var r=t.getSnapshot;t=t.value;try{var o=r();return!Tn(t,o)}catch{return!0}}function Ed(t){var r=dr(t,1);r!==null&&Pn(r,t,1,-1)}function $d(t){var r=Gn();return typeof t=="function"&&(t=t()),r.memoizedState=r.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:qi,lastRenderedState:t},r.queue=t,t=t.dispatch=sg.bind(null,ut,t),[r.memoizedState,t]}function ea(t,r,o,c){return t={tag:t,create:r,destroy:o,deps:c,next:null},r=ut.updateQueue,r===null?(r={lastEffect:null,stores:null},ut.updateQueue=r,r.lastEffect=t.next=t):(o=r.lastEffect,o===null?r.lastEffect=t.next=t:(c=o.next,o.next=t,t.next=c,r.lastEffect=t)),t}function Ad(){return bn().memoizedState}function io(t,r,o,c){var p=Gn();ut.flags|=t,p.memoizedState=ea(1|r,o,void 0,c===void 0?null:c)}function ao(t,r,o,c){var p=bn();c=c===void 0?null:c;var m=void 0;if(xt!==null){var v=xt.memoizedState;if(m=v.destroy,c!==null&&Dl(c,v.deps)){p.memoizedState=ea(r,o,m,c);return}}ut.flags|=t,p.memoizedState=ea(1|r,o,m,c)}function Td(t,r){return io(8390656,8,t,r)}function Bl(t,r){return ao(2048,8,t,r)}function Rd(t,r){return ao(4,2,t,r)}function Id(t,r){return ao(4,4,t,r)}function Md(t,r){if(typeof r=="function")return t=t(),r(t),function(){r(null)};if(r!=null)return t=t(),r.current=t,function(){r.current=null}}function Ld(t,r,o){return o=o!=null?o.concat([t]):null,ao(4,4,Md.bind(null,r,t),o)}function Vl(){}function Pd(t,r){var o=bn();r=r===void 0?null:r;var c=o.memoizedState;return c!==null&&r!==null&&Dl(r,c[1])?c[0]:(o.memoizedState=[t,r],t)}function Od(t,r){var o=bn();r=r===void 0?null:r;var c=o.memoizedState;return c!==null&&r!==null&&Dl(r,c[1])?c[0]:(t=t(),o.memoizedState=[t,r],t)}function Dd(t,r,o){return(ws&21)===0?(t.baseState&&(t.baseState=!1,qt=!0),t.memoizedState=o):(Tn(o,r)||(o=Os(),ut.lanes|=o,vs|=o,t.baseState=!0),r)}function ng(t,r){var o=Je;Je=o!==0&&4>o?o:4,t(!0);var c=Ol.transition;Ol.transition={};try{t(!1),r()}finally{Je=o,Ol.transition=c}}function Fd(){return bn().memoizedState}function rg(t,r,o){var c=Br(t);if(o={lane:c,action:o,hasEagerState:!1,eagerState:null,next:null},zd(t))Wd(r,o);else if(o=yd(t,r,o,c),o!==null){var p=Gt();Pn(o,t,c,p),Ud(o,r,c)}}function sg(t,r,o){var c=Br(t),p={lane:c,action:o,hasEagerState:!1,eagerState:null,next:null};if(zd(t))Wd(r,p);else{var m=t.alternate;if(t.lanes===0&&(m===null||m.lanes===0)&&(m=r.lastRenderedReducer,m!==null))try{var v=r.lastRenderedState,S=m(v,o);if(p.hasEagerState=!0,p.eagerState=S,Tn(S,v)){var R=r.interleaved;R===null?(p.next=p,Tl(r)):(p.next=R.next,R.next=p),r.interleaved=p;return}}catch{}finally{}o=yd(t,r,p,c),o!==null&&(p=Gt(),Pn(o,t,c,p),Ud(o,r,c))}}function zd(t){var r=t.alternate;return t===ut||r!==null&&r===ut}function Wd(t,r){Xi=so=!0;var o=t.pending;o===null?r.next=r:(r.next=o.next,o.next=r),t.pending=r}function Ud(t,r,o){if((o&4194240)!==0){var c=r.lanes;c&=t.pendingLanes,o|=c,r.lanes=o,_t(t,o)}}var oo={readContext:xn,useCallback:Ft,useContext:Ft,useEffect:Ft,useImperativeHandle:Ft,useInsertionEffect:Ft,useLayoutEffect:Ft,useMemo:Ft,useReducer:Ft,useRef:Ft,useState:Ft,useDebugValue:Ft,useDeferredValue:Ft,useTransition:Ft,useMutableSource:Ft,useSyncExternalStore:Ft,useId:Ft,unstable_isNewReconciler:!1},ig={readContext:xn,useCallback:function(t,r){return Gn().memoizedState=[t,r===void 0?null:r],t},useContext:xn,useEffect:Td,useImperativeHandle:function(t,r,o){return o=o!=null?o.concat([t]):null,io(4194308,4,Md.bind(null,r,t),o)},useLayoutEffect:function(t,r){return io(4194308,4,t,r)},useInsertionEffect:function(t,r){return io(4,2,t,r)},useMemo:function(t,r){var o=Gn();return r=r===void 0?null:r,t=t(),o.memoizedState=[t,r],t},useReducer:function(t,r,o){var c=Gn();return r=o!==void 0?o(r):r,c.memoizedState=c.baseState=r,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:r},c.queue=t,t=t.dispatch=rg.bind(null,ut,t),[c.memoizedState,t]},useRef:function(t){var r=Gn();return t={current:t},r.memoizedState=t},useState:$d,useDebugValue:Vl,useDeferredValue:function(t){return Gn().memoizedState=t},useTransition:function(){var t=$d(!1),r=t[0];return t=ng.bind(null,t[1]),Gn().memoizedState=t,[r,t]},useMutableSource:function(){},useSyncExternalStore:function(t,r,o){var c=ut,p=Gn();if(ot){if(o===void 0)throw Error(s(407));o=o()}else{if(o=r(),Nt===null)throw Error(s(349));(ws&30)!==0||jd(c,r,o)}p.memoizedState=o;var m={value:o,getSnapshot:r};return p.queue=m,Td(Nd.bind(null,c,m,t),[t]),c.flags|=2048,ea(9,Sd.bind(null,c,m,o,r),void 0,null),o},useId:function(){var t=Gn(),r=Nt.identifierPrefix;if(ot){var o=ur,c=cr;o=(c&~(1<<32-mt(c)-1)).toString(32)+o,r=":"+r+"R"+o,o=Zi++,0<o&&(r+="H"+o.toString(32)),r+=":"}else o=tg++,r=":"+r+"r"+o.toString(32)+":";return t.memoizedState=r},unstable_isNewReconciler:!1},ag={readContext:xn,useCallback:Pd,useContext:xn,useEffect:Bl,useImperativeHandle:Ld,useInsertionEffect:Rd,useLayoutEffect:Id,useMemo:Od,useReducer:Wl,useRef:Ad,useState:function(){return Wl(qi)},useDebugValue:Vl,useDeferredValue:function(t){var r=bn();return Dd(r,xt.memoizedState,t)},useTransition:function(){var t=Wl(qi)[0],r=bn().memoizedState;return[t,r]},useMutableSource:bd,useSyncExternalStore:kd,useId:Fd,unstable_isNewReconciler:!1},og={readContext:xn,useCallback:Pd,useContext:xn,useEffect:Bl,useImperativeHandle:Ld,useInsertionEffect:Rd,useLayoutEffect:Id,useMemo:Od,useReducer:Ul,useRef:Ad,useState:function(){return Ul(qi)},useDebugValue:Vl,useDeferredValue:function(t){var r=bn();return xt===null?r.memoizedState=t:Dd(r,xt.memoizedState,t)},useTransition:function(){var t=Ul(qi)[0],r=bn().memoizedState;return[t,r]},useMutableSource:bd,useSyncExternalStore:kd,useId:Fd,unstable_isNewReconciler:!1};function In(t,r){if(t&&t.defaultProps){r=G({},r),t=t.defaultProps;for(var o in t)r[o]===void 0&&(r[o]=t[o]);return r}return r}function Gl(t,r,o,c){r=t.memoizedState,o=o(c,r),o=o==null?r:G({},r,o),t.memoizedState=o,t.lanes===0&&(t.updateQueue.baseState=o)}var lo={isMounted:function(t){return(t=t._reactInternals)?tr(t)===t:!1},enqueueSetState:function(t,r,o){t=t._reactInternals;var c=Gt(),p=Br(t),m=fr(c,p);m.payload=r,o!=null&&(m.callback=o),r=Fr(t,m,p),r!==null&&(Pn(r,t,p,c),eo(r,t,p))},enqueueReplaceState:function(t,r,o){t=t._reactInternals;var c=Gt(),p=Br(t),m=fr(c,p);m.tag=1,m.payload=r,o!=null&&(m.callback=o),r=Fr(t,m,p),r!==null&&(Pn(r,t,p,c),eo(r,t,p))},enqueueForceUpdate:function(t,r){t=t._reactInternals;var o=Gt(),c=Br(t),p=fr(o,c);p.tag=2,r!=null&&(p.callback=r),r=Fr(t,p,c),r!==null&&(Pn(r,t,c,o),eo(r,t,c))}};function Bd(t,r,o,c,p,m,v){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(c,m,v):r.prototype&&r.prototype.isPureReactComponent?!zi(o,c)||!zi(p,m):!0}function Vd(t,r,o){var c=!1,p=Pr,m=r.contextType;return typeof m=="object"&&m!==null?m=xn(m):(p=Zt(r)?hs:Dt.current,c=r.contextTypes,m=(c=c!=null)?Ys(t,p):Pr),r=new r(o,m),t.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=lo,t.stateNode=r,r._reactInternals=t,c&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=p,t.__reactInternalMemoizedMaskedChildContext=m),r}function Gd(t,r,o,c){t=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(o,c),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(o,c),r.state!==t&&lo.enqueueReplaceState(r,r.state,null)}function Hl(t,r,o,c){var p=t.stateNode;p.props=o,p.state=t.memoizedState,p.refs={},Rl(t);var m=r.contextType;typeof m=="object"&&m!==null?p.context=xn(m):(m=Zt(r)?hs:Dt.current,p.context=Ys(t,m)),p.state=t.memoizedState,m=r.getDerivedStateFromProps,typeof m=="function"&&(Gl(t,r,m,o),p.state=t.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof p.getSnapshotBeforeUpdate=="function"||typeof p.UNSAFE_componentWillMount!="function"&&typeof p.componentWillMount!="function"||(r=p.state,typeof p.componentWillMount=="function"&&p.componentWillMount(),typeof p.UNSAFE_componentWillMount=="function"&&p.UNSAFE_componentWillMount(),r!==p.state&&lo.enqueueReplaceState(p,p.state,null),to(t,o,p,c),p.state=t.memoizedState),typeof p.componentDidMount=="function"&&(t.flags|=4194308)}function si(t,r){try{var o="",c=r;do o+=ie(c),c=c.return;while(c);var p=o}catch(m){p=`
39
+ Error generating stack: `+m.message+`
40
+ `+m.stack}return{value:t,source:r,stack:p,digest:null}}function Kl(t,r,o){return{value:t,source:null,stack:o??null,digest:r??null}}function Jl(t,r){try{console.error(r.value)}catch(o){setTimeout(function(){throw o})}}var lg=typeof WeakMap=="function"?WeakMap:Map;function Hd(t,r,o){o=fr(-1,o),o.tag=3,o.payload={element:null};var c=r.value;return o.callback=function(){go||(go=!0,cc=c),Jl(t,r)},o}function Kd(t,r,o){o=fr(-1,o),o.tag=3;var c=t.type.getDerivedStateFromError;if(typeof c=="function"){var p=r.value;o.payload=function(){return c(p)},o.callback=function(){Jl(t,r)}}var m=t.stateNode;return m!==null&&typeof m.componentDidCatch=="function"&&(o.callback=function(){Jl(t,r),typeof c!="function"&&(Wr===null?Wr=new Set([this]):Wr.add(this));var v=r.stack;this.componentDidCatch(r.value,{componentStack:v!==null?v:""})}),o}function Jd(t,r,o){var c=t.pingCache;if(c===null){c=t.pingCache=new lg;var p=new Set;c.set(r,p)}else p=c.get(r),p===void 0&&(p=new Set,c.set(r,p));p.has(o)||(p.add(o),t=bg.bind(null,t,r,o),r.then(t,t))}function Qd(t){do{var r;if((r=t.tag===13)&&(r=t.memoizedState,r=r!==null?r.dehydrated!==null:!0),r)return t;t=t.return}while(t!==null);return null}function Yd(t,r,o,c,p){return(t.mode&1)===0?(t===r?t.flags|=65536:(t.flags|=128,o.flags|=131072,o.flags&=-52805,o.tag===1&&(o.alternate===null?o.tag=17:(r=fr(-1,1),r.tag=2,Fr(o,r,1))),o.lanes|=1),t):(t.flags|=65536,t.lanes=p,t)}var cg=k.ReactCurrentOwner,qt=!1;function Vt(t,r,o,c){r.child=t===null?gd(r,null,o,c):ei(r,t.child,o,c)}function Xd(t,r,o,c,p){o=o.render;var m=r.ref;return ni(r,p),c=Fl(t,r,o,c,m,p),o=zl(),t!==null&&!qt?(r.updateQueue=t.updateQueue,r.flags&=-2053,t.lanes&=~p,hr(t,r,p)):(ot&&o&&bl(r),r.flags|=1,Vt(t,r,c,p),r.child)}function Zd(t,r,o,c,p){if(t===null){var m=o.type;return typeof m=="function"&&!gc(m)&&m.defaultProps===void 0&&o.compare===null&&o.defaultProps===void 0?(r.tag=15,r.type=m,qd(t,r,m,c,p)):(t=bo(o.type,null,c,r,r.mode,p),t.ref=r.ref,t.return=r,r.child=t)}if(m=t.child,(t.lanes&p)===0){var v=m.memoizedProps;if(o=o.compare,o=o!==null?o:zi,o(v,c)&&t.ref===r.ref)return hr(t,r,p)}return r.flags|=1,t=Gr(m,c),t.ref=r.ref,t.return=r,r.child=t}function qd(t,r,o,c,p){if(t!==null){var m=t.memoizedProps;if(zi(m,c)&&t.ref===r.ref)if(qt=!1,r.pendingProps=c=m,(t.lanes&p)!==0)(t.flags&131072)!==0&&(qt=!0);else return r.lanes=t.lanes,hr(t,r,p)}return Ql(t,r,o,c,p)}function ef(t,r,o){var c=r.pendingProps,p=c.children,m=t!==null?t.memoizedState:null;if(c.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},nt(ai,gn),gn|=o;else{if((o&1073741824)===0)return t=m!==null?m.baseLanes|o:o,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:t,cachePool:null,transitions:null},r.updateQueue=null,nt(ai,gn),gn|=t,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},c=m!==null?m.baseLanes:o,nt(ai,gn),gn|=c}else m!==null?(c=m.baseLanes|o,r.memoizedState=null):c=o,nt(ai,gn),gn|=c;return Vt(t,r,p,o),r.child}function tf(t,r){var o=r.ref;(t===null&&o!==null||t!==null&&t.ref!==o)&&(r.flags|=512,r.flags|=2097152)}function Ql(t,r,o,c,p){var m=Zt(o)?hs:Dt.current;return m=Ys(r,m),ni(r,p),o=Fl(t,r,o,c,m,p),c=zl(),t!==null&&!qt?(r.updateQueue=t.updateQueue,r.flags&=-2053,t.lanes&=~p,hr(t,r,p)):(ot&&c&&bl(r),r.flags|=1,Vt(t,r,o,p),r.child)}function nf(t,r,o,c,p){if(Zt(o)){var m=!0;Ha(r)}else m=!1;if(ni(r,p),r.stateNode===null)uo(t,r),Vd(r,o,c),Hl(r,o,c,p),c=!0;else if(t===null){var v=r.stateNode,S=r.memoizedProps;v.props=S;var R=v.context,z=o.contextType;typeof z=="object"&&z!==null?z=xn(z):(z=Zt(o)?hs:Dt.current,z=Ys(r,z));var ne=o.getDerivedStateFromProps,se=typeof ne=="function"||typeof v.getSnapshotBeforeUpdate=="function";se||typeof v.UNSAFE_componentWillReceiveProps!="function"&&typeof v.componentWillReceiveProps!="function"||(S!==c||R!==z)&&Gd(r,v,c,z),Dr=!1;var te=r.memoizedState;v.state=te,to(r,c,v,p),R=r.memoizedState,S!==c||te!==R||Xt.current||Dr?(typeof ne=="function"&&(Gl(r,o,ne,c),R=r.memoizedState),(S=Dr||Bd(r,o,S,c,te,R,z))?(se||typeof v.UNSAFE_componentWillMount!="function"&&typeof v.componentWillMount!="function"||(typeof v.componentWillMount=="function"&&v.componentWillMount(),typeof v.UNSAFE_componentWillMount=="function"&&v.UNSAFE_componentWillMount()),typeof v.componentDidMount=="function"&&(r.flags|=4194308)):(typeof v.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=c,r.memoizedState=R),v.props=c,v.state=R,v.context=z,c=S):(typeof v.componentDidMount=="function"&&(r.flags|=4194308),c=!1)}else{v=r.stateNode,wd(t,r),S=r.memoizedProps,z=r.type===r.elementType?S:In(r.type,S),v.props=z,se=r.pendingProps,te=v.context,R=o.contextType,typeof R=="object"&&R!==null?R=xn(R):(R=Zt(o)?hs:Dt.current,R=Ys(r,R));var ge=o.getDerivedStateFromProps;(ne=typeof ge=="function"||typeof v.getSnapshotBeforeUpdate=="function")||typeof v.UNSAFE_componentWillReceiveProps!="function"&&typeof v.componentWillReceiveProps!="function"||(S!==se||te!==R)&&Gd(r,v,c,R),Dr=!1,te=r.memoizedState,v.state=te,to(r,c,v,p);var xe=r.memoizedState;S!==se||te!==xe||Xt.current||Dr?(typeof ge=="function"&&(Gl(r,o,ge,c),xe=r.memoizedState),(z=Dr||Bd(r,o,z,c,te,xe,R)||!1)?(ne||typeof v.UNSAFE_componentWillUpdate!="function"&&typeof v.componentWillUpdate!="function"||(typeof v.componentWillUpdate=="function"&&v.componentWillUpdate(c,xe,R),typeof v.UNSAFE_componentWillUpdate=="function"&&v.UNSAFE_componentWillUpdate(c,xe,R)),typeof v.componentDidUpdate=="function"&&(r.flags|=4),typeof v.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof v.componentDidUpdate!="function"||S===t.memoizedProps&&te===t.memoizedState||(r.flags|=4),typeof v.getSnapshotBeforeUpdate!="function"||S===t.memoizedProps&&te===t.memoizedState||(r.flags|=1024),r.memoizedProps=c,r.memoizedState=xe),v.props=c,v.state=xe,v.context=R,c=z):(typeof v.componentDidUpdate!="function"||S===t.memoizedProps&&te===t.memoizedState||(r.flags|=4),typeof v.getSnapshotBeforeUpdate!="function"||S===t.memoizedProps&&te===t.memoizedState||(r.flags|=1024),c=!1)}return Yl(t,r,o,c,m,p)}function Yl(t,r,o,c,p,m){tf(t,r);var v=(r.flags&128)!==0;if(!c&&!v)return p&&od(r,o,!1),hr(t,r,m);c=r.stateNode,cg.current=r;var S=v&&typeof o.getDerivedStateFromError!="function"?null:c.render();return r.flags|=1,t!==null&&v?(r.child=ei(r,t.child,null,m),r.child=ei(r,null,S,m)):Vt(t,r,S,m),r.memoizedState=c.state,p&&od(r,o,!0),r.child}function rf(t){var r=t.stateNode;r.pendingContext?id(t,r.pendingContext,r.pendingContext!==r.context):r.context&&id(t,r.context,!1),Il(t,r.containerInfo)}function sf(t,r,o,c,p){return qs(),Nl(p),r.flags|=256,Vt(t,r,o,c),r.child}var Xl={dehydrated:null,treeContext:null,retryLane:0};function Zl(t){return{baseLanes:t,cachePool:null,transitions:null}}function af(t,r,o){var c=r.pendingProps,p=ct.current,m=!1,v=(r.flags&128)!==0,S;if((S=v)||(S=t!==null&&t.memoizedState===null?!1:(p&2)!==0),S?(m=!0,r.flags&=-129):(t===null||t.memoizedState!==null)&&(p|=1),nt(ct,p&1),t===null)return Sl(r),t=r.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?((r.mode&1)===0?r.lanes=1:t.data==="$!"?r.lanes=8:r.lanes=1073741824,null):(v=c.children,t=c.fallback,m?(c=r.mode,m=r.child,v={mode:"hidden",children:v},(c&1)===0&&m!==null?(m.childLanes=0,m.pendingProps=v):m=ko(v,c,0,null),t=ks(t,c,o,null),m.return=r,t.return=r,m.sibling=t,r.child=m,r.child.memoizedState=Zl(o),r.memoizedState=Xl,t):ql(r,v));if(p=t.memoizedState,p!==null&&(S=p.dehydrated,S!==null))return ug(t,r,v,c,S,p,o);if(m){m=c.fallback,v=r.mode,p=t.child,S=p.sibling;var R={mode:"hidden",children:c.children};return(v&1)===0&&r.child!==p?(c=r.child,c.childLanes=0,c.pendingProps=R,r.deletions=null):(c=Gr(p,R),c.subtreeFlags=p.subtreeFlags&14680064),S!==null?m=Gr(S,m):(m=ks(m,v,o,null),m.flags|=2),m.return=r,c.return=r,c.sibling=m,r.child=c,c=m,m=r.child,v=t.child.memoizedState,v=v===null?Zl(o):{baseLanes:v.baseLanes|o,cachePool:null,transitions:v.transitions},m.memoizedState=v,m.childLanes=t.childLanes&~o,r.memoizedState=Xl,c}return m=t.child,t=m.sibling,c=Gr(m,{mode:"visible",children:c.children}),(r.mode&1)===0&&(c.lanes=o),c.return=r,c.sibling=null,t!==null&&(o=r.deletions,o===null?(r.deletions=[t],r.flags|=16):o.push(t)),r.child=c,r.memoizedState=null,c}function ql(t,r){return r=ko({mode:"visible",children:r},t.mode,0,null),r.return=t,t.child=r}function co(t,r,o,c){return c!==null&&Nl(c),ei(r,t.child,null,o),t=ql(r,r.pendingProps.children),t.flags|=2,r.memoizedState=null,t}function ug(t,r,o,c,p,m,v){if(o)return r.flags&256?(r.flags&=-257,c=Kl(Error(s(422))),co(t,r,v,c)):r.memoizedState!==null?(r.child=t.child,r.flags|=128,null):(m=c.fallback,p=r.mode,c=ko({mode:"visible",children:c.children},p,0,null),m=ks(m,p,v,null),m.flags|=2,c.return=r,m.return=r,c.sibling=m,r.child=c,(r.mode&1)!==0&&ei(r,t.child,null,v),r.child.memoizedState=Zl(v),r.memoizedState=Xl,m);if((r.mode&1)===0)return co(t,r,v,null);if(p.data==="$!"){if(c=p.nextSibling&&p.nextSibling.dataset,c)var S=c.dgst;return c=S,m=Error(s(419)),c=Kl(m,c,void 0),co(t,r,v,c)}if(S=(v&t.childLanes)!==0,qt||S){if(c=Nt,c!==null){switch(v&-v){case 4:p=2;break;case 16:p=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:p=32;break;case 536870912:p=268435456;break;default:p=0}p=(p&(c.suspendedLanes|v))!==0?0:p,p!==0&&p!==m.retryLane&&(m.retryLane=p,dr(t,p),Pn(c,t,p,-1))}return mc(),c=Kl(Error(s(421))),co(t,r,v,c)}return p.data==="$?"?(r.flags|=128,r.child=t.child,r=kg.bind(null,t),p._reactRetry=r,null):(t=m.treeContext,mn=Mr(p.nextSibling),pn=r,ot=!0,Rn=null,t!==null&&(vn[_n++]=cr,vn[_n++]=ur,vn[_n++]=ps,cr=t.id,ur=t.overflow,ps=r),r=ql(r,c.children),r.flags|=4096,r)}function of(t,r,o){t.lanes|=r;var c=t.alternate;c!==null&&(c.lanes|=r),Al(t.return,r,o)}function ec(t,r,o,c,p){var m=t.memoizedState;m===null?t.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:c,tail:o,tailMode:p}:(m.isBackwards=r,m.rendering=null,m.renderingStartTime=0,m.last=c,m.tail=o,m.tailMode=p)}function lf(t,r,o){var c=r.pendingProps,p=c.revealOrder,m=c.tail;if(Vt(t,r,c.children,o),c=ct.current,(c&2)!==0)c=c&1|2,r.flags|=128;else{if(t!==null&&(t.flags&128)!==0)e:for(t=r.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&of(t,o,r);else if(t.tag===19)of(t,o,r);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===r)break e;for(;t.sibling===null;){if(t.return===null||t.return===r)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}c&=1}if(nt(ct,c),(r.mode&1)===0)r.memoizedState=null;else switch(p){case"forwards":for(o=r.child,p=null;o!==null;)t=o.alternate,t!==null&&no(t)===null&&(p=o),o=o.sibling;o=p,o===null?(p=r.child,r.child=null):(p=o.sibling,o.sibling=null),ec(r,!1,p,o,m);break;case"backwards":for(o=null,p=r.child,r.child=null;p!==null;){if(t=p.alternate,t!==null&&no(t)===null){r.child=p;break}t=p.sibling,p.sibling=o,o=p,p=t}ec(r,!0,o,null,m);break;case"together":ec(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function uo(t,r){(r.mode&1)===0&&t!==null&&(t.alternate=null,r.alternate=null,r.flags|=2)}function hr(t,r,o){if(t!==null&&(r.dependencies=t.dependencies),vs|=r.lanes,(o&r.childLanes)===0)return null;if(t!==null&&r.child!==t.child)throw Error(s(153));if(r.child!==null){for(t=r.child,o=Gr(t,t.pendingProps),r.child=o,o.return=r;t.sibling!==null;)t=t.sibling,o=o.sibling=Gr(t,t.pendingProps),o.return=r;o.sibling=null}return r.child}function dg(t,r,o){switch(r.tag){case 3:rf(r),qs();break;case 5:xd(r);break;case 1:Zt(r.type)&&Ha(r);break;case 4:Il(r,r.stateNode.containerInfo);break;case 10:var c=r.type._context,p=r.memoizedProps.value;nt(Za,c._currentValue),c._currentValue=p;break;case 13:if(c=r.memoizedState,c!==null)return c.dehydrated!==null?(nt(ct,ct.current&1),r.flags|=128,null):(o&r.child.childLanes)!==0?af(t,r,o):(nt(ct,ct.current&1),t=hr(t,r,o),t!==null?t.sibling:null);nt(ct,ct.current&1);break;case 19:if(c=(o&r.childLanes)!==0,(t.flags&128)!==0){if(c)return lf(t,r,o);r.flags|=128}if(p=r.memoizedState,p!==null&&(p.rendering=null,p.tail=null,p.lastEffect=null),nt(ct,ct.current),c)break;return null;case 22:case 23:return r.lanes=0,ef(t,r,o)}return hr(t,r,o)}var cf,tc,uf,df;cf=function(t,r){for(var o=r.child;o!==null;){if(o.tag===5||o.tag===6)t.appendChild(o.stateNode);else if(o.tag!==4&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===r)break;for(;o.sibling===null;){if(o.return===null||o.return===r)return;o=o.return}o.sibling.return=o.return,o=o.sibling}},tc=function(){},uf=function(t,r,o,c){var p=t.memoizedProps;if(p!==c){t=r.stateNode,ys(Vn.current);var m=null;switch(o){case"input":p=pe(t,p),c=pe(t,c),m=[];break;case"select":p=G({},p,{value:void 0}),c=G({},c,{value:void 0}),m=[];break;case"textarea":p=De(t,p),c=De(t,c),m=[];break;default:typeof p.onClick!="function"&&typeof c.onClick=="function"&&(t.onclick=Ba)}ki(o,c);var v;o=null;for(z in p)if(!c.hasOwnProperty(z)&&p.hasOwnProperty(z)&&p[z]!=null)if(z==="style"){var S=p[z];for(v in S)S.hasOwnProperty(v)&&(o||(o={}),o[v]="")}else z!=="dangerouslySetInnerHTML"&&z!=="children"&&z!=="suppressContentEditableWarning"&&z!=="suppressHydrationWarning"&&z!=="autoFocus"&&(l.hasOwnProperty(z)?m||(m=[]):(m=m||[]).push(z,null));for(z in c){var R=c[z];if(S=p!=null?p[z]:void 0,c.hasOwnProperty(z)&&R!==S&&(R!=null||S!=null))if(z==="style")if(S){for(v in S)!S.hasOwnProperty(v)||R&&R.hasOwnProperty(v)||(o||(o={}),o[v]="");for(v in R)R.hasOwnProperty(v)&&S[v]!==R[v]&&(o||(o={}),o[v]=R[v])}else o||(m||(m=[]),m.push(z,o)),o=R;else z==="dangerouslySetInnerHTML"?(R=R?R.__html:void 0,S=S?S.__html:void 0,R!=null&&S!==R&&(m=m||[]).push(z,R)):z==="children"?typeof R!="string"&&typeof R!="number"||(m=m||[]).push(z,""+R):z!=="suppressContentEditableWarning"&&z!=="suppressHydrationWarning"&&(l.hasOwnProperty(z)?(R!=null&&z==="onScroll"&&it("scroll",t),m||S===R||(m=[])):(m=m||[]).push(z,R))}o&&(m=m||[]).push("style",o);var z=m;(r.updateQueue=z)&&(r.flags|=4)}},df=function(t,r,o,c){o!==c&&(r.flags|=4)};function ta(t,r){if(!ot)switch(t.tailMode){case"hidden":r=t.tail;for(var o=null;r!==null;)r.alternate!==null&&(o=r),r=r.sibling;o===null?t.tail=null:o.sibling=null;break;case"collapsed":o=t.tail;for(var c=null;o!==null;)o.alternate!==null&&(c=o),o=o.sibling;c===null?r||t.tail===null?t.tail=null:t.tail.sibling=null:c.sibling=null}}function zt(t){var r=t.alternate!==null&&t.alternate.child===t.child,o=0,c=0;if(r)for(var p=t.child;p!==null;)o|=p.lanes|p.childLanes,c|=p.subtreeFlags&14680064,c|=p.flags&14680064,p.return=t,p=p.sibling;else for(p=t.child;p!==null;)o|=p.lanes|p.childLanes,c|=p.subtreeFlags,c|=p.flags,p.return=t,p=p.sibling;return t.subtreeFlags|=c,t.childLanes=o,r}function fg(t,r,o){var c=r.pendingProps;switch(kl(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return zt(r),null;case 1:return Zt(r.type)&&Ga(),zt(r),null;case 3:return c=r.stateNode,ri(),at(Xt),at(Dt),Pl(),c.pendingContext&&(c.context=c.pendingContext,c.pendingContext=null),(t===null||t.child===null)&&(Ya(r)?r.flags|=4:t===null||t.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,Rn!==null&&(fc(Rn),Rn=null))),tc(t,r),zt(r),null;case 5:Ml(r);var p=ys(Yi.current);if(o=r.type,t!==null&&r.stateNode!=null)uf(t,r,o,c,p),t.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!c){if(r.stateNode===null)throw Error(s(166));return zt(r),null}if(t=ys(Vn.current),Ya(r)){c=r.stateNode,o=r.type;var m=r.memoizedProps;switch(c[Bn]=r,c[Gi]=m,t=(r.mode&1)!==0,o){case"dialog":it("cancel",c),it("close",c);break;case"iframe":case"object":case"embed":it("load",c);break;case"video":case"audio":for(p=0;p<Ui.length;p++)it(Ui[p],c);break;case"source":it("error",c);break;case"img":case"image":case"link":it("error",c),it("load",c);break;case"details":it("toggle",c);break;case"input":Oe(c,m),it("invalid",c);break;case"select":c._wrapperState={wasMultiple:!!m.multiple},it("invalid",c);break;case"textarea":Ke(c,m),it("invalid",c)}ki(o,m),p=null;for(var v in m)if(m.hasOwnProperty(v)){var S=m[v];v==="children"?typeof S=="string"?c.textContent!==S&&(m.suppressHydrationWarning!==!0&&Ua(c.textContent,S,t),p=["children",S]):typeof S=="number"&&c.textContent!==""+S&&(m.suppressHydrationWarning!==!0&&Ua(c.textContent,S,t),p=["children",""+S]):l.hasOwnProperty(v)&&S!=null&&v==="onScroll"&&it("scroll",c)}switch(o){case"input":ke(c),Be(c,m,!0);break;case"textarea":ke(c),Xn(c);break;case"select":case"option":break;default:typeof m.onClick=="function"&&(c.onclick=Ba)}c=p,r.updateQueue=c,c!==null&&(r.flags|=4)}else{v=p.nodeType===9?p:p.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=Mt(o)),t==="http://www.w3.org/1999/xhtml"?o==="script"?(t=v.createElement("div"),t.innerHTML="<script><\/script>",t=t.removeChild(t.firstChild)):typeof c.is=="string"?t=v.createElement(o,{is:c.is}):(t=v.createElement(o),o==="select"&&(v=t,c.multiple?v.multiple=!0:c.size&&(v.size=c.size))):t=v.createElementNS(t,o),t[Bn]=r,t[Gi]=c,cf(t,r,!1,!1),r.stateNode=t;e:{switch(v=As(o,c),o){case"dialog":it("cancel",t),it("close",t),p=c;break;case"iframe":case"object":case"embed":it("load",t),p=c;break;case"video":case"audio":for(p=0;p<Ui.length;p++)it(Ui[p],t);p=c;break;case"source":it("error",t),p=c;break;case"img":case"image":case"link":it("error",t),it("load",t),p=c;break;case"details":it("toggle",t),p=c;break;case"input":Oe(t,c),p=pe(t,c),it("invalid",t);break;case"option":p=c;break;case"select":t._wrapperState={wasMultiple:!!c.multiple},p=G({},c,{value:void 0}),it("invalid",t);break;case"textarea":Ke(t,c),p=De(t,c),it("invalid",t);break;default:p=c}ki(o,p),S=p;for(m in S)if(S.hasOwnProperty(m)){var R=S[m];m==="style"?qr(t,R):m==="dangerouslySetInnerHTML"?(R=R?R.__html:void 0,R!=null&&En(t,R)):m==="children"?typeof R=="string"?(o!=="textarea"||R!=="")&&Zr(t,R):typeof R=="number"&&Zr(t,""+R):m!=="suppressContentEditableWarning"&&m!=="suppressHydrationWarning"&&m!=="autoFocus"&&(l.hasOwnProperty(m)?R!=null&&m==="onScroll"&&it("scroll",t):R!=null&&$(t,m,R,v))}switch(o){case"input":ke(t),Be(t,c,!1);break;case"textarea":ke(t),Xn(t);break;case"option":c.value!=null&&t.setAttribute("value",""+X(c.value));break;case"select":t.multiple=!!c.multiple,m=c.value,m!=null?me(t,!!c.multiple,m,!1):c.defaultValue!=null&&me(t,!!c.multiple,c.defaultValue,!0);break;default:typeof p.onClick=="function"&&(t.onclick=Ba)}switch(o){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break e;case"img":c=!0;break e;default:c=!1}}c&&(r.flags|=4)}r.ref!==null&&(r.flags|=512,r.flags|=2097152)}return zt(r),null;case 6:if(t&&r.stateNode!=null)df(t,r,t.memoizedProps,c);else{if(typeof c!="string"&&r.stateNode===null)throw Error(s(166));if(o=ys(Yi.current),ys(Vn.current),Ya(r)){if(c=r.stateNode,o=r.memoizedProps,c[Bn]=r,(m=c.nodeValue!==o)&&(t=pn,t!==null))switch(t.tag){case 3:Ua(c.nodeValue,o,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&Ua(c.nodeValue,o,(t.mode&1)!==0)}m&&(r.flags|=4)}else c=(o.nodeType===9?o:o.ownerDocument).createTextNode(c),c[Bn]=r,r.stateNode=c}return zt(r),null;case 13:if(at(ct),c=r.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(ot&&mn!==null&&(r.mode&1)!==0&&(r.flags&128)===0)hd(),qs(),r.flags|=98560,m=!1;else if(m=Ya(r),c!==null&&c.dehydrated!==null){if(t===null){if(!m)throw Error(s(318));if(m=r.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(s(317));m[Bn]=r}else qs(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;zt(r),m=!1}else Rn!==null&&(fc(Rn),Rn=null),m=!0;if(!m)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=o,r):(c=c!==null,c!==(t!==null&&t.memoizedState!==null)&&c&&(r.child.flags|=8192,(r.mode&1)!==0&&(t===null||(ct.current&1)!==0?bt===0&&(bt=3):mc())),r.updateQueue!==null&&(r.flags|=4),zt(r),null);case 4:return ri(),tc(t,r),t===null&&Bi(r.stateNode.containerInfo),zt(r),null;case 10:return $l(r.type._context),zt(r),null;case 17:return Zt(r.type)&&Ga(),zt(r),null;case 19:if(at(ct),m=r.memoizedState,m===null)return zt(r),null;if(c=(r.flags&128)!==0,v=m.rendering,v===null)if(c)ta(m,!1);else{if(bt!==0||t!==null&&(t.flags&128)!==0)for(t=r.child;t!==null;){if(v=no(t),v!==null){for(r.flags|=128,ta(m,!1),c=v.updateQueue,c!==null&&(r.updateQueue=c,r.flags|=4),r.subtreeFlags=0,c=o,o=r.child;o!==null;)m=o,t=c,m.flags&=14680066,v=m.alternate,v===null?(m.childLanes=0,m.lanes=t,m.child=null,m.subtreeFlags=0,m.memoizedProps=null,m.memoizedState=null,m.updateQueue=null,m.dependencies=null,m.stateNode=null):(m.childLanes=v.childLanes,m.lanes=v.lanes,m.child=v.child,m.subtreeFlags=0,m.deletions=null,m.memoizedProps=v.memoizedProps,m.memoizedState=v.memoizedState,m.updateQueue=v.updateQueue,m.type=v.type,t=v.dependencies,m.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),o=o.sibling;return nt(ct,ct.current&1|2),r.child}t=t.sibling}m.tail!==null&&st()>oi&&(r.flags|=128,c=!0,ta(m,!1),r.lanes=4194304)}else{if(!c)if(t=no(v),t!==null){if(r.flags|=128,c=!0,o=t.updateQueue,o!==null&&(r.updateQueue=o,r.flags|=4),ta(m,!0),m.tail===null&&m.tailMode==="hidden"&&!v.alternate&&!ot)return zt(r),null}else 2*st()-m.renderingStartTime>oi&&o!==1073741824&&(r.flags|=128,c=!0,ta(m,!1),r.lanes=4194304);m.isBackwards?(v.sibling=r.child,r.child=v):(o=m.last,o!==null?o.sibling=v:r.child=v,m.last=v)}return m.tail!==null?(r=m.tail,m.rendering=r,m.tail=r.sibling,m.renderingStartTime=st(),r.sibling=null,o=ct.current,nt(ct,c?o&1|2:o&1),r):(zt(r),null);case 22:case 23:return pc(),c=r.memoizedState!==null,t!==null&&t.memoizedState!==null!==c&&(r.flags|=8192),c&&(r.mode&1)!==0?(gn&1073741824)!==0&&(zt(r),r.subtreeFlags&6&&(r.flags|=8192)):zt(r),null;case 24:return null;case 25:return null}throw Error(s(156,r.tag))}function hg(t,r){switch(kl(r),r.tag){case 1:return Zt(r.type)&&Ga(),t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 3:return ri(),at(Xt),at(Dt),Pl(),t=r.flags,(t&65536)!==0&&(t&128)===0?(r.flags=t&-65537|128,r):null;case 5:return Ml(r),null;case 13:if(at(ct),t=r.memoizedState,t!==null&&t.dehydrated!==null){if(r.alternate===null)throw Error(s(340));qs()}return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 19:return at(ct),null;case 4:return ri(),null;case 10:return $l(r.type._context),null;case 22:case 23:return pc(),null;case 24:return null;default:return null}}var fo=!1,Wt=!1,pg=typeof WeakSet=="function"?WeakSet:Set,_e=null;function ii(t,r){var o=t.ref;if(o!==null)if(typeof o=="function")try{o(null)}catch(c){dt(t,r,c)}else o.current=null}function nc(t,r,o){try{o()}catch(c){dt(t,r,c)}}var ff=!1;function mg(t,r){if(pl=cs,t=Bu(),al(t)){if("selectionStart"in t)var o={start:t.selectionStart,end:t.selectionEnd};else e:{o=(o=t.ownerDocument)&&o.defaultView||window;var c=o.getSelection&&o.getSelection();if(c&&c.rangeCount!==0){o=c.anchorNode;var p=c.anchorOffset,m=c.focusNode;c=c.focusOffset;try{o.nodeType,m.nodeType}catch{o=null;break e}var v=0,S=-1,R=-1,z=0,ne=0,se=t,te=null;t:for(;;){for(var ge;se!==o||p!==0&&se.nodeType!==3||(S=v+p),se!==m||c!==0&&se.nodeType!==3||(R=v+c),se.nodeType===3&&(v+=se.nodeValue.length),(ge=se.firstChild)!==null;)te=se,se=ge;for(;;){if(se===t)break t;if(te===o&&++z===p&&(S=v),te===m&&++ne===c&&(R=v),(ge=se.nextSibling)!==null)break;se=te,te=se.parentNode}se=ge}o=S===-1||R===-1?null:{start:S,end:R}}else o=null}o=o||{start:0,end:0}}else o=null;for(ml={focusedElem:t,selectionRange:o},cs=!1,_e=r;_e!==null;)if(r=_e,t=r.child,(r.subtreeFlags&1028)!==0&&t!==null)t.return=r,_e=t;else for(;_e!==null;){r=_e;try{var xe=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(xe!==null){var be=xe.memoizedProps,yt=xe.memoizedState,O=r.stateNode,M=O.getSnapshotBeforeUpdate(r.elementType===r.type?be:In(r.type,be),yt);O.__reactInternalSnapshotBeforeUpdate=M}break;case 3:var D=r.stateNode.containerInfo;D.nodeType===1?D.textContent="":D.nodeType===9&&D.documentElement&&D.removeChild(D.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(s(163))}}catch(ue){dt(r,r.return,ue)}if(t=r.sibling,t!==null){t.return=r.return,_e=t;break}_e=r.return}return xe=ff,ff=!1,xe}function na(t,r,o){var c=r.updateQueue;if(c=c!==null?c.lastEffect:null,c!==null){var p=c=c.next;do{if((p.tag&t)===t){var m=p.destroy;p.destroy=void 0,m!==void 0&&nc(r,o,m)}p=p.next}while(p!==c)}}function ho(t,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var o=r=r.next;do{if((o.tag&t)===t){var c=o.create;o.destroy=c()}o=o.next}while(o!==r)}}function rc(t){var r=t.ref;if(r!==null){var o=t.stateNode;switch(t.tag){case 5:t=o;break;default:t=o}typeof r=="function"?r(t):r.current=t}}function hf(t){var r=t.alternate;r!==null&&(t.alternate=null,hf(r)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(r=t.stateNode,r!==null&&(delete r[Bn],delete r[Gi],delete r[vl],delete r[Xm],delete r[Zm])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function pf(t){return t.tag===5||t.tag===3||t.tag===4}function mf(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||pf(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function sc(t,r,o){var c=t.tag;if(c===5||c===6)t=t.stateNode,r?o.nodeType===8?o.parentNode.insertBefore(t,r):o.insertBefore(t,r):(o.nodeType===8?(r=o.parentNode,r.insertBefore(t,o)):(r=o,r.appendChild(t)),o=o._reactRootContainer,o!=null||r.onclick!==null||(r.onclick=Ba));else if(c!==4&&(t=t.child,t!==null))for(sc(t,r,o),t=t.sibling;t!==null;)sc(t,r,o),t=t.sibling}function ic(t,r,o){var c=t.tag;if(c===5||c===6)t=t.stateNode,r?o.insertBefore(t,r):o.appendChild(t);else if(c!==4&&(t=t.child,t!==null))for(ic(t,r,o),t=t.sibling;t!==null;)ic(t,r,o),t=t.sibling}var $t=null,Mn=!1;function zr(t,r,o){for(o=o.child;o!==null;)gf(t,r,o),o=o.sibling}function gf(t,r,o){if(pt&&typeof pt.onCommitFiberUnmount=="function")try{pt.onCommitFiberUnmount(rs,o)}catch{}switch(o.tag){case 5:Wt||ii(o,r);case 6:var c=$t,p=Mn;$t=null,zr(t,r,o),$t=c,Mn=p,$t!==null&&(Mn?(t=$t,o=o.stateNode,t.nodeType===8?t.parentNode.removeChild(o):t.removeChild(o)):$t.removeChild(o.stateNode));break;case 18:$t!==null&&(Mn?(t=$t,o=o.stateNode,t.nodeType===8?wl(t.parentNode,o):t.nodeType===1&&wl(t,o),Rr(t)):wl($t,o.stateNode));break;case 4:c=$t,p=Mn,$t=o.stateNode.containerInfo,Mn=!0,zr(t,r,o),$t=c,Mn=p;break;case 0:case 11:case 14:case 15:if(!Wt&&(c=o.updateQueue,c!==null&&(c=c.lastEffect,c!==null))){p=c=c.next;do{var m=p,v=m.destroy;m=m.tag,v!==void 0&&((m&2)!==0||(m&4)!==0)&&nc(o,r,v),p=p.next}while(p!==c)}zr(t,r,o);break;case 1:if(!Wt&&(ii(o,r),c=o.stateNode,typeof c.componentWillUnmount=="function"))try{c.props=o.memoizedProps,c.state=o.memoizedState,c.componentWillUnmount()}catch(S){dt(o,r,S)}zr(t,r,o);break;case 21:zr(t,r,o);break;case 22:o.mode&1?(Wt=(c=Wt)||o.memoizedState!==null,zr(t,r,o),Wt=c):zr(t,r,o);break;default:zr(t,r,o)}}function yf(t){var r=t.updateQueue;if(r!==null){t.updateQueue=null;var o=t.stateNode;o===null&&(o=t.stateNode=new pg),r.forEach(function(c){var p=jg.bind(null,t,c);o.has(c)||(o.add(c),c.then(p,p))})}}function Ln(t,r){var o=r.deletions;if(o!==null)for(var c=0;c<o.length;c++){var p=o[c];try{var m=t,v=r,S=v;e:for(;S!==null;){switch(S.tag){case 5:$t=S.stateNode,Mn=!1;break e;case 3:$t=S.stateNode.containerInfo,Mn=!0;break e;case 4:$t=S.stateNode.containerInfo,Mn=!0;break e}S=S.return}if($t===null)throw Error(s(160));gf(m,v,p),$t=null,Mn=!1;var R=p.alternate;R!==null&&(R.return=null),p.return=null}catch(z){dt(p,r,z)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)wf(r,t),r=r.sibling}function wf(t,r){var o=t.alternate,c=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(Ln(r,t),Hn(t),c&4){try{na(3,t,t.return),ho(3,t)}catch(be){dt(t,t.return,be)}try{na(5,t,t.return)}catch(be){dt(t,t.return,be)}}break;case 1:Ln(r,t),Hn(t),c&512&&o!==null&&ii(o,o.return);break;case 5:if(Ln(r,t),Hn(t),c&512&&o!==null&&ii(o,o.return),t.flags&32){var p=t.stateNode;try{Zr(p,"")}catch(be){dt(t,t.return,be)}}if(c&4&&(p=t.stateNode,p!=null)){var m=t.memoizedProps,v=o!==null?o.memoizedProps:m,S=t.type,R=t.updateQueue;if(t.updateQueue=null,R!==null)try{S==="input"&&m.type==="radio"&&m.name!=null&&we(p,m),As(S,v);var z=As(S,m);for(v=0;v<R.length;v+=2){var ne=R[v],se=R[v+1];ne==="style"?qr(p,se):ne==="dangerouslySetInnerHTML"?En(p,se):ne==="children"?Zr(p,se):$(p,ne,se,z)}switch(S){case"input":Pe(p,m);break;case"textarea":He(p,m);break;case"select":var te=p._wrapperState.wasMultiple;p._wrapperState.wasMultiple=!!m.multiple;var ge=m.value;ge!=null?me(p,!!m.multiple,ge,!1):te!==!!m.multiple&&(m.defaultValue!=null?me(p,!!m.multiple,m.defaultValue,!0):me(p,!!m.multiple,m.multiple?[]:"",!1))}p[Gi]=m}catch(be){dt(t,t.return,be)}}break;case 6:if(Ln(r,t),Hn(t),c&4){if(t.stateNode===null)throw Error(s(162));p=t.stateNode,m=t.memoizedProps;try{p.nodeValue=m}catch(be){dt(t,t.return,be)}}break;case 3:if(Ln(r,t),Hn(t),c&4&&o!==null&&o.memoizedState.isDehydrated)try{Rr(r.containerInfo)}catch(be){dt(t,t.return,be)}break;case 4:Ln(r,t),Hn(t);break;case 13:Ln(r,t),Hn(t),p=t.child,p.flags&8192&&(m=p.memoizedState!==null,p.stateNode.isHidden=m,!m||p.alternate!==null&&p.alternate.memoizedState!==null||(lc=st())),c&4&&yf(t);break;case 22:if(ne=o!==null&&o.memoizedState!==null,t.mode&1?(Wt=(z=Wt)||ne,Ln(r,t),Wt=z):Ln(r,t),Hn(t),c&8192){if(z=t.memoizedState!==null,(t.stateNode.isHidden=z)&&!ne&&(t.mode&1)!==0)for(_e=t,ne=t.child;ne!==null;){for(se=_e=ne;_e!==null;){switch(te=_e,ge=te.child,te.tag){case 0:case 11:case 14:case 15:na(4,te,te.return);break;case 1:ii(te,te.return);var xe=te.stateNode;if(typeof xe.componentWillUnmount=="function"){c=te,o=te.return;try{r=c,xe.props=r.memoizedProps,xe.state=r.memoizedState,xe.componentWillUnmount()}catch(be){dt(c,o,be)}}break;case 5:ii(te,te.return);break;case 22:if(te.memoizedState!==null){xf(se);continue}}ge!==null?(ge.return=te,_e=ge):xf(se)}ne=ne.sibling}e:for(ne=null,se=t;;){if(se.tag===5){if(ne===null){ne=se;try{p=se.stateNode,z?(m=p.style,typeof m.setProperty=="function"?m.setProperty("display","none","important"):m.display="none"):(S=se.stateNode,R=se.memoizedProps.style,v=R!=null&&R.hasOwnProperty("display")?R.display:null,S.style.display=xi("display",v))}catch(be){dt(t,t.return,be)}}}else if(se.tag===6){if(ne===null)try{se.stateNode.nodeValue=z?"":se.memoizedProps}catch(be){dt(t,t.return,be)}}else if((se.tag!==22&&se.tag!==23||se.memoizedState===null||se===t)&&se.child!==null){se.child.return=se,se=se.child;continue}if(se===t)break e;for(;se.sibling===null;){if(se.return===null||se.return===t)break e;ne===se&&(ne=null),se=se.return}ne===se&&(ne=null),se.sibling.return=se.return,se=se.sibling}}break;case 19:Ln(r,t),Hn(t),c&4&&yf(t);break;case 21:break;default:Ln(r,t),Hn(t)}}function Hn(t){var r=t.flags;if(r&2){try{e:{for(var o=t.return;o!==null;){if(pf(o)){var c=o;break e}o=o.return}throw Error(s(160))}switch(c.tag){case 5:var p=c.stateNode;c.flags&32&&(Zr(p,""),c.flags&=-33);var m=mf(t);ic(t,m,p);break;case 3:case 4:var v=c.stateNode.containerInfo,S=mf(t);sc(t,S,v);break;default:throw Error(s(161))}}catch(R){dt(t,t.return,R)}t.flags&=-3}r&4096&&(t.flags&=-4097)}function gg(t,r,o){_e=t,vf(t)}function vf(t,r,o){for(var c=(t.mode&1)!==0;_e!==null;){var p=_e,m=p.child;if(p.tag===22&&c){var v=p.memoizedState!==null||fo;if(!v){var S=p.alternate,R=S!==null&&S.memoizedState!==null||Wt;S=fo;var z=Wt;if(fo=v,(Wt=R)&&!z)for(_e=p;_e!==null;)v=_e,R=v.child,v.tag===22&&v.memoizedState!==null?bf(p):R!==null?(R.return=v,_e=R):bf(p);for(;m!==null;)_e=m,vf(m),m=m.sibling;_e=p,fo=S,Wt=z}_f(t)}else(p.subtreeFlags&8772)!==0&&m!==null?(m.return=p,_e=m):_f(t)}}function _f(t){for(;_e!==null;){var r=_e;if((r.flags&8772)!==0){var o=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:Wt||ho(5,r);break;case 1:var c=r.stateNode;if(r.flags&4&&!Wt)if(o===null)c.componentDidMount();else{var p=r.elementType===r.type?o.memoizedProps:In(r.type,o.memoizedProps);c.componentDidUpdate(p,o.memoizedState,c.__reactInternalSnapshotBeforeUpdate)}var m=r.updateQueue;m!==null&&_d(r,m,c);break;case 3:var v=r.updateQueue;if(v!==null){if(o=null,r.child!==null)switch(r.child.tag){case 5:o=r.child.stateNode;break;case 1:o=r.child.stateNode}_d(r,v,o)}break;case 5:var S=r.stateNode;if(o===null&&r.flags&4){o=S;var R=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":R.autoFocus&&o.focus();break;case"img":R.src&&(o.src=R.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(r.memoizedState===null){var z=r.alternate;if(z!==null){var ne=z.memoizedState;if(ne!==null){var se=ne.dehydrated;se!==null&&Rr(se)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(s(163))}Wt||r.flags&512&&rc(r)}catch(te){dt(r,r.return,te)}}if(r===t){_e=null;break}if(o=r.sibling,o!==null){o.return=r.return,_e=o;break}_e=r.return}}function xf(t){for(;_e!==null;){var r=_e;if(r===t){_e=null;break}var o=r.sibling;if(o!==null){o.return=r.return,_e=o;break}_e=r.return}}function bf(t){for(;_e!==null;){var r=_e;try{switch(r.tag){case 0:case 11:case 15:var o=r.return;try{ho(4,r)}catch(R){dt(r,o,R)}break;case 1:var c=r.stateNode;if(typeof c.componentDidMount=="function"){var p=r.return;try{c.componentDidMount()}catch(R){dt(r,p,R)}}var m=r.return;try{rc(r)}catch(R){dt(r,m,R)}break;case 5:var v=r.return;try{rc(r)}catch(R){dt(r,v,R)}}}catch(R){dt(r,r.return,R)}if(r===t){_e=null;break}var S=r.sibling;if(S!==null){S.return=r.return,_e=S;break}_e=r.return}}var yg=Math.ceil,po=k.ReactCurrentDispatcher,ac=k.ReactCurrentOwner,kn=k.ReactCurrentBatchConfig,Qe=0,Nt=null,vt=null,At=0,gn=0,ai=Lr(0),bt=0,ra=null,vs=0,mo=0,oc=0,sa=null,en=null,lc=0,oi=1/0,pr=null,go=!1,cc=null,Wr=null,yo=!1,Ur=null,wo=0,ia=0,uc=null,vo=-1,_o=0;function Gt(){return(Qe&6)!==0?st():vo!==-1?vo:vo=st()}function Br(t){return(t.mode&1)===0?1:(Qe&2)!==0&&At!==0?At&-At:eg.transition!==null?(_o===0&&(_o=Os()),_o):(t=Je,t!==0||(t=window.event,t=t===void 0?16:Pi(t.type)),t)}function Pn(t,r,o,c){if(50<ia)throw ia=0,uc=null,Error(s(185));lt(t,o,c),((Qe&2)===0||t!==Nt)&&(t===Nt&&((Qe&2)===0&&(mo|=o),bt===4&&Vr(t,At)),tn(t,c),o===1&&Qe===0&&(r.mode&1)===0&&(oi=st()+500,Ka&&Or()))}function tn(t,r){var o=t.callbackNode;el(t,r);var c=is(t,t===Nt?At:0);if(c===0)o!==null&&Dn(o),t.callbackNode=null,t.callbackPriority=0;else if(r=c&-c,t.callbackPriority!==r){if(o!=null&&Dn(o),r===1)t.tag===0?qm(jf.bind(null,t)):ld(jf.bind(null,t)),Qm(function(){(Qe&6)===0&&Or()}),o=null;else{switch(as(c)){case 1:o=Sr;break;case 4:o=ns;break;case 16:o=dn;break;case 536870912:o=rr;break;default:o=dn}o=Rf(o,kf.bind(null,t))}t.callbackPriority=r,t.callbackNode=o}}function kf(t,r){if(vo=-1,_o=0,(Qe&6)!==0)throw Error(s(327));var o=t.callbackNode;if(li()&&t.callbackNode!==o)return null;var c=is(t,t===Nt?At:0);if(c===0)return null;if((c&30)!==0||(c&t.expiredLanes)!==0||r)r=xo(t,c);else{r=c;var p=Qe;Qe|=2;var m=Nf();(Nt!==t||At!==r)&&(pr=null,oi=st()+500,xs(t,r));do try{_g();break}catch(S){Sf(t,S)}while(!0);El(),po.current=m,Qe=p,vt!==null?r=0:(Nt=null,At=0,r=bt)}if(r!==0){if(r===2&&(p=Ps(t),p!==0&&(c=p,r=dc(t,p))),r===1)throw o=ra,xs(t,0),Vr(t,c),tn(t,st()),o;if(r===6)Vr(t,c);else{if(p=t.current.alternate,(c&30)===0&&!wg(p)&&(r=xo(t,c),r===2&&(m=Ps(t),m!==0&&(c=m,r=dc(t,m))),r===1))throw o=ra,xs(t,0),Vr(t,c),tn(t,st()),o;switch(t.finishedWork=p,t.finishedLanes=c,r){case 0:case 1:throw Error(s(345));case 2:bs(t,en,pr);break;case 3:if(Vr(t,c),(c&130023424)===c&&(r=lc+500-st(),10<r)){if(is(t,0)!==0)break;if(p=t.suspendedLanes,(p&c)!==c){Gt(),t.pingedLanes|=t.suspendedLanes&p;break}t.timeoutHandle=yl(bs.bind(null,t,en,pr),r);break}bs(t,en,pr);break;case 4:if(Vr(t,c),(c&4194240)===c)break;for(r=t.eventTimes,p=-1;0<c;){var v=31-mt(c);m=1<<v,v=r[v],v>p&&(p=v),c&=~m}if(c=p,c=st()-c,c=(120>c?120:480>c?480:1080>c?1080:1920>c?1920:3e3>c?3e3:4320>c?4320:1960*yg(c/1960))-c,10<c){t.timeoutHandle=yl(bs.bind(null,t,en,pr),c);break}bs(t,en,pr);break;case 5:bs(t,en,pr);break;default:throw Error(s(329))}}}return tn(t,st()),t.callbackNode===o?kf.bind(null,t):null}function dc(t,r){var o=sa;return t.current.memoizedState.isDehydrated&&(xs(t,r).flags|=256),t=xo(t,r),t!==2&&(r=en,en=o,r!==null&&fc(r)),t}function fc(t){en===null?en=t:en.push.apply(en,t)}function wg(t){for(var r=t;;){if(r.flags&16384){var o=r.updateQueue;if(o!==null&&(o=o.stores,o!==null))for(var c=0;c<o.length;c++){var p=o[c],m=p.getSnapshot;p=p.value;try{if(!Tn(m(),p))return!1}catch{return!1}}}if(o=r.child,r.subtreeFlags&16384&&o!==null)o.return=r,r=o;else{if(r===t)break;for(;r.sibling===null;){if(r.return===null||r.return===t)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function Vr(t,r){for(r&=~oc,r&=~mo,t.suspendedLanes|=r,t.pingedLanes&=~r,t=t.expirationTimes;0<r;){var o=31-mt(r),c=1<<o;t[o]=-1,r&=~c}}function jf(t){if((Qe&6)!==0)throw Error(s(327));li();var r=is(t,0);if((r&1)===0)return tn(t,st()),null;var o=xo(t,r);if(t.tag!==0&&o===2){var c=Ps(t);c!==0&&(r=c,o=dc(t,c))}if(o===1)throw o=ra,xs(t,0),Vr(t,r),tn(t,st()),o;if(o===6)throw Error(s(345));return t.finishedWork=t.current.alternate,t.finishedLanes=r,bs(t,en,pr),tn(t,st()),null}function hc(t,r){var o=Qe;Qe|=1;try{return t(r)}finally{Qe=o,Qe===0&&(oi=st()+500,Ka&&Or())}}function _s(t){Ur!==null&&Ur.tag===0&&(Qe&6)===0&&li();var r=Qe;Qe|=1;var o=kn.transition,c=Je;try{if(kn.transition=null,Je=1,t)return t()}finally{Je=c,kn.transition=o,Qe=r,(Qe&6)===0&&Or()}}function pc(){gn=ai.current,at(ai)}function xs(t,r){t.finishedWork=null,t.finishedLanes=0;var o=t.timeoutHandle;if(o!==-1&&(t.timeoutHandle=-1,Jm(o)),vt!==null)for(o=vt.return;o!==null;){var c=o;switch(kl(c),c.tag){case 1:c=c.type.childContextTypes,c!=null&&Ga();break;case 3:ri(),at(Xt),at(Dt),Pl();break;case 5:Ml(c);break;case 4:ri();break;case 13:at(ct);break;case 19:at(ct);break;case 10:$l(c.type._context);break;case 22:case 23:pc()}o=o.return}if(Nt=t,vt=t=Gr(t.current,null),At=gn=r,bt=0,ra=null,oc=mo=vs=0,en=sa=null,gs!==null){for(r=0;r<gs.length;r++)if(o=gs[r],c=o.interleaved,c!==null){o.interleaved=null;var p=c.next,m=o.pending;if(m!==null){var v=m.next;m.next=p,c.next=v}o.pending=c}gs=null}return t}function Sf(t,r){do{var o=vt;try{if(El(),ro.current=oo,so){for(var c=ut.memoizedState;c!==null;){var p=c.queue;p!==null&&(p.pending=null),c=c.next}so=!1}if(ws=0,St=xt=ut=null,Xi=!1,Zi=0,ac.current=null,o===null||o.return===null){bt=1,ra=r,vt=null;break}e:{var m=t,v=o.return,S=o,R=r;if(r=At,S.flags|=32768,R!==null&&typeof R=="object"&&typeof R.then=="function"){var z=R,ne=S,se=ne.tag;if((ne.mode&1)===0&&(se===0||se===11||se===15)){var te=ne.alternate;te?(ne.updateQueue=te.updateQueue,ne.memoizedState=te.memoizedState,ne.lanes=te.lanes):(ne.updateQueue=null,ne.memoizedState=null)}var ge=Qd(v);if(ge!==null){ge.flags&=-257,Yd(ge,v,S,m,r),ge.mode&1&&Jd(m,z,r),r=ge,R=z;var xe=r.updateQueue;if(xe===null){var be=new Set;be.add(R),r.updateQueue=be}else xe.add(R);break e}else{if((r&1)===0){Jd(m,z,r),mc();break e}R=Error(s(426))}}else if(ot&&S.mode&1){var yt=Qd(v);if(yt!==null){(yt.flags&65536)===0&&(yt.flags|=256),Yd(yt,v,S,m,r),Nl(si(R,S));break e}}m=R=si(R,S),bt!==4&&(bt=2),sa===null?sa=[m]:sa.push(m),m=v;do{switch(m.tag){case 3:m.flags|=65536,r&=-r,m.lanes|=r;var O=Hd(m,R,r);vd(m,O);break e;case 1:S=R;var M=m.type,D=m.stateNode;if((m.flags&128)===0&&(typeof M.getDerivedStateFromError=="function"||D!==null&&typeof D.componentDidCatch=="function"&&(Wr===null||!Wr.has(D)))){m.flags|=65536,r&=-r,m.lanes|=r;var ue=Kd(m,S,r);vd(m,ue);break e}}m=m.return}while(m!==null)}Ef(o)}catch(je){r=je,vt===o&&o!==null&&(vt=o=o.return);continue}break}while(!0)}function Nf(){var t=po.current;return po.current=oo,t===null?oo:t}function mc(){(bt===0||bt===3||bt===2)&&(bt=4),Nt===null||(vs&268435455)===0&&(mo&268435455)===0||Vr(Nt,At)}function xo(t,r){var o=Qe;Qe|=2;var c=Nf();(Nt!==t||At!==r)&&(pr=null,xs(t,r));do try{vg();break}catch(p){Sf(t,p)}while(!0);if(El(),Qe=o,po.current=c,vt!==null)throw Error(s(261));return Nt=null,At=0,bt}function vg(){for(;vt!==null;)Cf(vt)}function _g(){for(;vt!==null&&!Ve();)Cf(vt)}function Cf(t){var r=Tf(t.alternate,t,gn);t.memoizedProps=t.pendingProps,r===null?Ef(t):vt=r,ac.current=null}function Ef(t){var r=t;do{var o=r.alternate;if(t=r.return,(r.flags&32768)===0){if(o=fg(o,r,gn),o!==null){vt=o;return}}else{if(o=hg(o,r),o!==null){o.flags&=32767,vt=o;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{bt=6,vt=null;return}}if(r=r.sibling,r!==null){vt=r;return}vt=r=t}while(r!==null);bt===0&&(bt=5)}function bs(t,r,o){var c=Je,p=kn.transition;try{kn.transition=null,Je=1,xg(t,r,o,c)}finally{kn.transition=p,Je=c}return null}function xg(t,r,o,c){do li();while(Ur!==null);if((Qe&6)!==0)throw Error(s(327));o=t.finishedWork;var p=t.finishedLanes;if(o===null)return null;if(t.finishedWork=null,t.finishedLanes=0,o===t.current)throw Error(s(177));t.callbackNode=null,t.callbackPriority=0;var m=o.lanes|o.childLanes;if(Ai(t,m),t===Nt&&(vt=Nt=null,At=0),(o.subtreeFlags&2064)===0&&(o.flags&2064)===0||yo||(yo=!0,Rf(dn,function(){return li(),null})),m=(o.flags&15990)!==0,(o.subtreeFlags&15990)!==0||m){m=kn.transition,kn.transition=null;var v=Je;Je=1;var S=Qe;Qe|=4,ac.current=null,mg(t,o),wf(o,t),Wm(ml),cs=!!pl,ml=pl=null,t.current=o,gg(o),un(),Qe=S,Je=v,kn.transition=m}else t.current=o;if(yo&&(yo=!1,Ur=t,wo=p),m=t.pendingLanes,m===0&&(Wr=null),$a(o.stateNode),tn(t,st()),r!==null)for(c=t.onRecoverableError,o=0;o<r.length;o++)p=r[o],c(p.value,{componentStack:p.stack,digest:p.digest});if(go)throw go=!1,t=cc,cc=null,t;return(wo&1)!==0&&t.tag!==0&&li(),m=t.pendingLanes,(m&1)!==0?t===uc?ia++:(ia=0,uc=t):ia=0,Or(),null}function li(){if(Ur!==null){var t=as(wo),r=kn.transition,o=Je;try{if(kn.transition=null,Je=16>t?16:t,Ur===null)var c=!1;else{if(t=Ur,Ur=null,wo=0,(Qe&6)!==0)throw Error(s(331));var p=Qe;for(Qe|=4,_e=t.current;_e!==null;){var m=_e,v=m.child;if((_e.flags&16)!==0){var S=m.deletions;if(S!==null){for(var R=0;R<S.length;R++){var z=S[R];for(_e=z;_e!==null;){var ne=_e;switch(ne.tag){case 0:case 11:case 15:na(8,ne,m)}var se=ne.child;if(se!==null)se.return=ne,_e=se;else for(;_e!==null;){ne=_e;var te=ne.sibling,ge=ne.return;if(hf(ne),ne===z){_e=null;break}if(te!==null){te.return=ge,_e=te;break}_e=ge}}}var xe=m.alternate;if(xe!==null){var be=xe.child;if(be!==null){xe.child=null;do{var yt=be.sibling;be.sibling=null,be=yt}while(be!==null)}}_e=m}}if((m.subtreeFlags&2064)!==0&&v!==null)v.return=m,_e=v;else e:for(;_e!==null;){if(m=_e,(m.flags&2048)!==0)switch(m.tag){case 0:case 11:case 15:na(9,m,m.return)}var O=m.sibling;if(O!==null){O.return=m.return,_e=O;break e}_e=m.return}}var M=t.current;for(_e=M;_e!==null;){v=_e;var D=v.child;if((v.subtreeFlags&2064)!==0&&D!==null)D.return=v,_e=D;else e:for(v=M;_e!==null;){if(S=_e,(S.flags&2048)!==0)try{switch(S.tag){case 0:case 11:case 15:ho(9,S)}}catch(je){dt(S,S.return,je)}if(S===v){_e=null;break e}var ue=S.sibling;if(ue!==null){ue.return=S.return,_e=ue;break e}_e=S.return}}if(Qe=p,Or(),pt&&typeof pt.onPostCommitFiberRoot=="function")try{pt.onPostCommitFiberRoot(rs,t)}catch{}c=!0}return c}finally{Je=o,kn.transition=r}}return!1}function $f(t,r,o){r=si(o,r),r=Hd(t,r,1),t=Fr(t,r,1),r=Gt(),t!==null&&(lt(t,1,r),tn(t,r))}function dt(t,r,o){if(t.tag===3)$f(t,t,o);else for(;r!==null;){if(r.tag===3){$f(r,t,o);break}else if(r.tag===1){var c=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(Wr===null||!Wr.has(c))){t=si(o,t),t=Kd(r,t,1),r=Fr(r,t,1),t=Gt(),r!==null&&(lt(r,1,t),tn(r,t));break}}r=r.return}}function bg(t,r,o){var c=t.pingCache;c!==null&&c.delete(r),r=Gt(),t.pingedLanes|=t.suspendedLanes&o,Nt===t&&(At&o)===o&&(bt===4||bt===3&&(At&130023424)===At&&500>st()-lc?xs(t,0):oc|=o),tn(t,r)}function Af(t,r){r===0&&((t.mode&1)===0?r=1:(r=Lt,Lt<<=1,(Lt&130023424)===0&&(Lt=4194304)));var o=Gt();t=dr(t,r),t!==null&&(lt(t,r,o),tn(t,o))}function kg(t){var r=t.memoizedState,o=0;r!==null&&(o=r.retryLane),Af(t,o)}function jg(t,r){var o=0;switch(t.tag){case 13:var c=t.stateNode,p=t.memoizedState;p!==null&&(o=p.retryLane);break;case 19:c=t.stateNode;break;default:throw Error(s(314))}c!==null&&c.delete(r),Af(t,o)}var Tf;Tf=function(t,r,o){if(t!==null)if(t.memoizedProps!==r.pendingProps||Xt.current)qt=!0;else{if((t.lanes&o)===0&&(r.flags&128)===0)return qt=!1,dg(t,r,o);qt=(t.flags&131072)!==0}else qt=!1,ot&&(r.flags&1048576)!==0&&cd(r,Qa,r.index);switch(r.lanes=0,r.tag){case 2:var c=r.type;uo(t,r),t=r.pendingProps;var p=Ys(r,Dt.current);ni(r,o),p=Fl(null,r,c,t,p,o);var m=zl();return r.flags|=1,typeof p=="object"&&p!==null&&typeof p.render=="function"&&p.$$typeof===void 0?(r.tag=1,r.memoizedState=null,r.updateQueue=null,Zt(c)?(m=!0,Ha(r)):m=!1,r.memoizedState=p.state!==null&&p.state!==void 0?p.state:null,Rl(r),p.updater=lo,r.stateNode=p,p._reactInternals=r,Hl(r,c,t,o),r=Yl(null,r,c,!0,m,o)):(r.tag=0,ot&&m&&bl(r),Vt(null,r,p,o),r=r.child),r;case 16:c=r.elementType;e:{switch(uo(t,r),t=r.pendingProps,p=c._init,c=p(c._payload),r.type=c,p=r.tag=Ng(c),t=In(c,t),p){case 0:r=Ql(null,r,c,t,o);break e;case 1:r=nf(null,r,c,t,o);break e;case 11:r=Xd(null,r,c,t,o);break e;case 14:r=Zd(null,r,c,In(c.type,t),o);break e}throw Error(s(306,c,""))}return r;case 0:return c=r.type,p=r.pendingProps,p=r.elementType===c?p:In(c,p),Ql(t,r,c,p,o);case 1:return c=r.type,p=r.pendingProps,p=r.elementType===c?p:In(c,p),nf(t,r,c,p,o);case 3:e:{if(rf(r),t===null)throw Error(s(387));c=r.pendingProps,m=r.memoizedState,p=m.element,wd(t,r),to(r,c,null,o);var v=r.memoizedState;if(c=v.element,m.isDehydrated)if(m={element:c,isDehydrated:!1,cache:v.cache,pendingSuspenseBoundaries:v.pendingSuspenseBoundaries,transitions:v.transitions},r.updateQueue.baseState=m,r.memoizedState=m,r.flags&256){p=si(Error(s(423)),r),r=sf(t,r,c,o,p);break e}else if(c!==p){p=si(Error(s(424)),r),r=sf(t,r,c,o,p);break e}else for(mn=Mr(r.stateNode.containerInfo.firstChild),pn=r,ot=!0,Rn=null,o=gd(r,null,c,o),r.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling;else{if(qs(),c===p){r=hr(t,r,o);break e}Vt(t,r,c,o)}r=r.child}return r;case 5:return xd(r),t===null&&Sl(r),c=r.type,p=r.pendingProps,m=t!==null?t.memoizedProps:null,v=p.children,gl(c,p)?v=null:m!==null&&gl(c,m)&&(r.flags|=32),tf(t,r),Vt(t,r,v,o),r.child;case 6:return t===null&&Sl(r),null;case 13:return af(t,r,o);case 4:return Il(r,r.stateNode.containerInfo),c=r.pendingProps,t===null?r.child=ei(r,null,c,o):Vt(t,r,c,o),r.child;case 11:return c=r.type,p=r.pendingProps,p=r.elementType===c?p:In(c,p),Xd(t,r,c,p,o);case 7:return Vt(t,r,r.pendingProps,o),r.child;case 8:return Vt(t,r,r.pendingProps.children,o),r.child;case 12:return Vt(t,r,r.pendingProps.children,o),r.child;case 10:e:{if(c=r.type._context,p=r.pendingProps,m=r.memoizedProps,v=p.value,nt(Za,c._currentValue),c._currentValue=v,m!==null)if(Tn(m.value,v)){if(m.children===p.children&&!Xt.current){r=hr(t,r,o);break e}}else for(m=r.child,m!==null&&(m.return=r);m!==null;){var S=m.dependencies;if(S!==null){v=m.child;for(var R=S.firstContext;R!==null;){if(R.context===c){if(m.tag===1){R=fr(-1,o&-o),R.tag=2;var z=m.updateQueue;if(z!==null){z=z.shared;var ne=z.pending;ne===null?R.next=R:(R.next=ne.next,ne.next=R),z.pending=R}}m.lanes|=o,R=m.alternate,R!==null&&(R.lanes|=o),Al(m.return,o,r),S.lanes|=o;break}R=R.next}}else if(m.tag===10)v=m.type===r.type?null:m.child;else if(m.tag===18){if(v=m.return,v===null)throw Error(s(341));v.lanes|=o,S=v.alternate,S!==null&&(S.lanes|=o),Al(v,o,r),v=m.sibling}else v=m.child;if(v!==null)v.return=m;else for(v=m;v!==null;){if(v===r){v=null;break}if(m=v.sibling,m!==null){m.return=v.return,v=m;break}v=v.return}m=v}Vt(t,r,p.children,o),r=r.child}return r;case 9:return p=r.type,c=r.pendingProps.children,ni(r,o),p=xn(p),c=c(p),r.flags|=1,Vt(t,r,c,o),r.child;case 14:return c=r.type,p=In(c,r.pendingProps),p=In(c.type,p),Zd(t,r,c,p,o);case 15:return qd(t,r,r.type,r.pendingProps,o);case 17:return c=r.type,p=r.pendingProps,p=r.elementType===c?p:In(c,p),uo(t,r),r.tag=1,Zt(c)?(t=!0,Ha(r)):t=!1,ni(r,o),Vd(r,c,p),Hl(r,c,p,o),Yl(null,r,c,!0,t,o);case 19:return lf(t,r,o);case 22:return ef(t,r,o)}throw Error(s(156,r.tag))};function Rf(t,r){return Ca(t,r)}function Sg(t,r,o,c){this.tag=t,this.key=o,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function jn(t,r,o,c){return new Sg(t,r,o,c)}function gc(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Ng(t){if(typeof t=="function")return gc(t)?1:0;if(t!=null){if(t=t.$$typeof,t===U)return 11;if(t===ce)return 14}return 2}function Gr(t,r){var o=t.alternate;return o===null?(o=jn(t.tag,r,t.key,t.mode),o.elementType=t.elementType,o.type=t.type,o.stateNode=t.stateNode,o.alternate=t,t.alternate=o):(o.pendingProps=r,o.type=t.type,o.flags=0,o.subtreeFlags=0,o.deletions=null),o.flags=t.flags&14680064,o.childLanes=t.childLanes,o.lanes=t.lanes,o.child=t.child,o.memoizedProps=t.memoizedProps,o.memoizedState=t.memoizedState,o.updateQueue=t.updateQueue,r=t.dependencies,o.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},o.sibling=t.sibling,o.index=t.index,o.ref=t.ref,o}function bo(t,r,o,c,p,m){var v=2;if(c=t,typeof t=="function")gc(t)&&(v=1);else if(typeof t=="string")v=5;else e:switch(t){case H:return ks(o.children,p,m,r);case L:v=8,p|=8;break;case de:return t=jn(12,o,r,p|2),t.elementType=de,t.lanes=m,t;case J:return t=jn(13,o,r,p),t.elementType=J,t.lanes=m,t;case fe:return t=jn(19,o,r,p),t.elementType=fe,t.lanes=m,t;case ve:return ko(o,p,m,r);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case re:v=10;break e;case Q:v=9;break e;case U:v=11;break e;case ce:v=14;break e;case ye:v=16,c=null;break e}throw Error(s(130,t==null?t:typeof t,""))}return r=jn(v,o,r,p),r.elementType=t,r.type=c,r.lanes=m,r}function ks(t,r,o,c){return t=jn(7,t,c,r),t.lanes=o,t}function ko(t,r,o,c){return t=jn(22,t,c,r),t.elementType=ve,t.lanes=o,t.stateNode={isHidden:!1},t}function yc(t,r,o){return t=jn(6,t,null,r),t.lanes=o,t}function wc(t,r,o){return r=jn(4,t.children!==null?t.children:[],t.key,r),r.lanes=o,r.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},r}function Cg(t,r,o,c,p){this.tag=r,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=ir(0),this.expirationTimes=ir(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ir(0),this.identifierPrefix=c,this.onRecoverableError=p,this.mutableSourceEagerHydrationData=null}function vc(t,r,o,c,p,m,v,S,R){return t=new Cg(t,r,o,S,R),r===1?(r=1,m===!0&&(r|=8)):r=0,m=jn(3,null,null,r),t.current=m,m.stateNode=t,m.memoizedState={element:c,isDehydrated:o,cache:null,transitions:null,pendingSuspenseBoundaries:null},Rl(m),t}function Eg(t,r,o){var c=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:V,key:c==null?null:""+c,children:t,containerInfo:r,implementation:o}}function If(t){if(!t)return Pr;t=t._reactInternals;e:{if(tr(t)!==t||t.tag!==1)throw Error(s(170));var r=t;do{switch(r.tag){case 3:r=r.stateNode.context;break e;case 1:if(Zt(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}}r=r.return}while(r!==null);throw Error(s(171))}if(t.tag===1){var o=t.type;if(Zt(o))return ad(t,o,r)}return r}function Mf(t,r,o,c,p,m,v,S,R){return t=vc(o,c,!0,t,p,m,v,S,R),t.context=If(null),o=t.current,c=Gt(),p=Br(o),m=fr(c,p),m.callback=r??null,Fr(o,m,p),t.current.lanes=p,lt(t,p,c),tn(t,c),t}function jo(t,r,o,c){var p=r.current,m=Gt(),v=Br(p);return o=If(o),r.context===null?r.context=o:r.pendingContext=o,r=fr(m,v),r.payload={element:t},c=c===void 0?null:c,c!==null&&(r.callback=c),t=Fr(p,r,v),t!==null&&(Pn(t,p,v,m),eo(t,p,v)),v}function So(t){if(t=t.current,!t.child)return null;switch(t.child.tag){case 5:return t.child.stateNode;default:return t.child.stateNode}}function Lf(t,r){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var o=t.retryLane;t.retryLane=o!==0&&o<r?o:r}}function _c(t,r){Lf(t,r),(t=t.alternate)&&Lf(t,r)}function $g(){return null}var Pf=typeof reportError=="function"?reportError:function(t){console.error(t)};function xc(t){this._internalRoot=t}No.prototype.render=xc.prototype.render=function(t){var r=this._internalRoot;if(r===null)throw Error(s(409));jo(t,r,null,null)},No.prototype.unmount=xc.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var r=t.containerInfo;_s(function(){jo(null,t,null,null)}),r[or]=null}};function No(t){this._internalRoot=t}No.prototype.unstable_scheduleHydration=function(t){if(t){var r=Ti();t={blockedOn:null,target:t,priority:r};for(var o=0;o<Wn.length&&r!==0&&r<Wn[o].priority;o++);Wn.splice(o,0,t),o===0&&Mi(t)}};function bc(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function Co(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function Of(){}function Ag(t,r,o,c,p){if(p){if(typeof c=="function"){var m=c;c=function(){var z=So(v);m.call(z)}}var v=Mf(r,c,t,0,null,!1,!1,"",Of);return t._reactRootContainer=v,t[or]=v.current,Bi(t.nodeType===8?t.parentNode:t),_s(),v}for(;p=t.lastChild;)t.removeChild(p);if(typeof c=="function"){var S=c;c=function(){var z=So(R);S.call(z)}}var R=vc(t,0,!1,null,null,!1,!1,"",Of);return t._reactRootContainer=R,t[or]=R.current,Bi(t.nodeType===8?t.parentNode:t),_s(function(){jo(r,R,o,c)}),R}function Eo(t,r,o,c,p){var m=o._reactRootContainer;if(m){var v=m;if(typeof p=="function"){var S=p;p=function(){var R=So(v);S.call(R)}}jo(r,v,t,p)}else v=Ag(o,r,t,p,c);return So(v)}Ds=function(t){switch(t.tag){case 3:var r=t.stateNode;if(r.current.memoizedState.isDehydrated){var o=Cr(r.pendingLanes);o!==0&&(_t(r,o|1),tn(r,st()),(Qe&6)===0&&(oi=st()+500,Or()))}break;case 13:_s(function(){var c=dr(t,1);if(c!==null){var p=Gt();Pn(c,t,1,p)}}),_c(t,1)}},Er=function(t){if(t.tag===13){var r=dr(t,134217728);if(r!==null){var o=Gt();Pn(r,t,134217728,o)}_c(t,134217728)}},Ta=function(t){if(t.tag===13){var r=Br(t),o=dr(t,r);if(o!==null){var c=Gt();Pn(o,t,r,c)}_c(t,r)}},Ti=function(){return Je},Ri=function(t,r){var o=Je;try{return Je=t,r()}finally{Je=o}},Ts=function(t,r,o){switch(r){case"input":if(Pe(t,o),r=o.name,o.type==="radio"&&r!=null){for(o=t;o.parentNode;)o=o.parentNode;for(o=o.querySelectorAll("input[name="+JSON.stringify(""+r)+'][type="radio"]'),r=0;r<o.length;r++){var c=o[r];if(c!==t&&c.form===t.form){var p=Va(c);if(!p)throw Error(s(90));Y(c),Pe(c,p)}}}break;case"textarea":He(t,o);break;case"select":r=o.value,r!=null&&me(t,!!o.multiple,r,!1)}},ji=hc,Rs=_s;var Tg={usingClientEntryPoint:!1,Events:[Hi,Js,Va,br,ka,hc]},aa={findFiberByHostInstance:fs,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Rg={bundleType:aa.bundleType,version:aa.version,rendererPackageName:aa.rendererPackageName,rendererConfig:aa.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:k.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=Ei(t),t===null?null:t.stateNode},findFiberByHostInstance:aa.findFiberByHostInstance||$g,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 $o=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!$o.isDisabled&&$o.supportsFiber)try{rs=$o.inject(Rg),pt=$o}catch{}}return nn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Tg,nn.createPortal=function(t,r){var o=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!bc(r))throw Error(s(200));return Eg(t,r,null,o)},nn.createRoot=function(t,r){if(!bc(t))throw Error(s(299));var o=!1,c="",p=Pf;return r!=null&&(r.unstable_strictMode===!0&&(o=!0),r.identifierPrefix!==void 0&&(c=r.identifierPrefix),r.onRecoverableError!==void 0&&(p=r.onRecoverableError)),r=vc(t,1,!1,null,null,o,!1,c,p),t[or]=r.current,Bi(t.nodeType===8?t.parentNode:t),new xc(r)},nn.findDOMNode=function(t){if(t==null)return null;if(t.nodeType===1)return t;var r=t._reactInternals;if(r===void 0)throw typeof t.render=="function"?Error(s(188)):(t=Object.keys(t).join(","),Error(s(268,t)));return t=Ei(r),t=t===null?null:t.stateNode,t},nn.flushSync=function(t){return _s(t)},nn.hydrate=function(t,r,o){if(!Co(r))throw Error(s(200));return Eo(null,t,r,!0,o)},nn.hydrateRoot=function(t,r,o){if(!bc(t))throw Error(s(405));var c=o!=null&&o.hydratedSources||null,p=!1,m="",v=Pf;if(o!=null&&(o.unstable_strictMode===!0&&(p=!0),o.identifierPrefix!==void 0&&(m=o.identifierPrefix),o.onRecoverableError!==void 0&&(v=o.onRecoverableError)),r=Mf(r,null,t,1,o??null,p,!1,m,v),t[or]=r.current,Bi(t),c)for(t=0;t<c.length;t++)o=c[t],p=o._getVersion,p=p(o._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[o,p]:r.mutableSourceEagerHydrationData.push(o,p);return new No(r)},nn.render=function(t,r,o){if(!Co(r))throw Error(s(200));return Eo(null,t,r,!1,o)},nn.unmountComponentAtNode=function(t){if(!Co(t))throw Error(s(40));return t._reactRootContainer?(_s(function(){Eo(null,null,t,!1,function(){t._reactRootContainer=null,t[or]=null})}),!0):!1},nn.unstable_batchedUpdates=hc,nn.unstable_renderSubtreeIntoContainer=function(t,r,o,c){if(!Co(o))throw Error(s(200));if(t==null||t._reactInternals===void 0)throw Error(s(38));return Eo(t,r,o,!1,c)},nn.version="18.3.1-next-f1338f8080-20240426",nn}var Gf;function Bh(){if(Gf)return Sc.exports;Gf=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(n){console.error(n)}}return e(),Sc.exports=Wg(),Sc.exports}var Hf;function Ug(){if(Hf)return Ao;Hf=1;var e=Bh();return Ao.createRoot=e.createRoot,Ao.hydrateRoot=e.hydrateRoot,Ao}var Bg=Ug();const Vg=Uh(Bg),Vh=[{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"]}];Vh.map(e=>({id:e.id,label:e.label}));function Gg(e){return`theme-${String(e||"").trim()||"dark"}`}function Kf(e){try{const n=document.documentElement,s=Array.from(n.classList).filter(a=>a.startsWith("theme-"));for(const a of s)n.classList.remove(a);n.classList.add(Gg(e))}catch{}}const Kc=[{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}],Jc=[{id:"compact",label:"Compact",density:.85},{id:"standard",label:"Standard",density:1},{id:"spacious",label:"Spacious",density:1.2}];function Hg(e){const n=String(e).trim();return Kc.find(s=>s.id===n)||Kc[1]}function Kg(e){const n=String(e).trim();return Jc.find(s=>s.id===n)||Jc[1]}function Jf(e){try{const n=document.documentElement,s=Hg(e.font_scale||"md"),a=Kg(e.header_density||"standard");n.style.setProperty("--font-scale",String(s.scale)),n.style.setProperty("--header-density",String(a.density))}catch{}}var Gh=Bh();function ci(...e){return e.filter(Boolean).join(" ")}function Xr({value:e,options:n,placeholder:s="Select…",disabled:a=!1,loading:l=!1,searchable:u=!0,searchPlaceholder:d="Search…",allowCustom:f=!1,clearable:h=!1,minPopoverWidth:g=240,variant:y="panel",className:x,triggerClassName:b,ariaLabel:_,id:E,includeValueOption:C=!1,onOpen:j,customOptionLabel:T,validateCustomValue:A,onChange:$,renderOption:k,renderValue:P}){const V=w.useRef(null),H=w.useRef(null),L=w.useRef(null),de=w.useRef(j),re=w.useId(),Q=E||`af-select-${re.replace(/[^a-zA-Z0-9_-]/g,"")}`,U=`${Q}-listbox`,[J,fe]=w.useState(!1),[ce,ye]=w.useState(""),[ve,q]=w.useState(0),[oe,G]=w.useState("bottom"),[N,B]=w.useState({left:0,top:0,width:0});w.useEffect(()=>{de.current=j},[j]);const F=w.useMemo(()=>{if(!C)return n;const K=String(e??"").trim();return!K||n.some(me=>me.value===K)?n:[...n,{value:K,label:K}]},[C,n,e]),W=w.useMemo(()=>{const K=String(e??"");return F.find(me=>me.value===K)||null},[F,e]),ie=w.useMemo(()=>(W==null?void 0:W.label)||String(e||"").trim()||"",[W,e]),le=w.useMemo(()=>{const K=ce.trim().toLowerCase();return K?F.filter(me=>me.label.toLowerCase().includes(K)||me.value.toLowerCase().includes(K)):F},[F,ce]),he=w.useMemo(()=>{if(!f)return null;const K=ce.trim();if(!K||F.some(Ke=>Ke.value===K))return null;const De=(A==null?void 0:A(K,{options:F}))||"";return{value:K,label:T?T(K):`Use "${K}"`,disabled:!!De,reason:De}},[f,T,F,ce,A]),X=w.useMemo(()=>{const K=he?[he,...le]:le;if(K.length>0)return K;const me=String(e??"").trim();return l&&me?[{value:me,label:ie||me}]:K},[he,le,l,ie,e]),$e=w.useCallback(()=>{const K=V.current;if(!K)return;const me=K.getBoundingClientRect(),De=Math.max(me.width,g),Ke=Math.max(8,Math.min(me.left,window.innerWidth-De-8)),He=window.innerHeight-me.bottom,Xn=me.top,Mt=He>=220||He>=Xn?"bottom":"top";G(Mt);const Cn=Mt==="bottom"?me.bottom+6:me.top-6;B({left:Ke,top:Cn,width:De})},[g]),We=w.useCallback(()=>{fe(!1),ye("")},[]);w.useEffect(()=>{var K;J&&((K=de.current)==null||K.call(de))},[J]),w.useEffect(()=>{if(!J)return;$e();const K=()=>$e();return window.addEventListener("resize",K),window.addEventListener("scroll",K,!0),()=>{window.removeEventListener("resize",K),window.removeEventListener("scroll",K,!0)}},[J,$e]),w.useEffect(()=>{if(!J)return;const K=me=>{var Ke,He;const De=me.target;De&&((Ke=V.current)!=null&&Ke.contains(De)||(He=H.current)!=null&&He.contains(De)||We())};return document.addEventListener("mousedown",K,!0),()=>document.removeEventListener("mousedown",K,!0)},[J,We]),w.useEffect(()=>{if(!J)return;const K=Math.max(0,X.findIndex(me=>me.value===e));q(K===-1?0:K),u&&setTimeout(()=>{var me;return(me=L.current)==null?void 0:me.focus()},0)},[J,u,e,X]);const ke=K=>{var De;const me=X.find(Ke=>Ke.value===K);me!=null&&me.disabled||($(K),We(),(De=V.current)==null||De.focus())},Y=K=>{var me,De;if(K.key==="Escape")return K.preventDefault(),We(),(me=V.current)==null||me.focus(),!0;if(K.key==="Tab")return We(),(De=V.current)==null||De.focus(),!1;if(K.key==="ArrowDown")return K.preventDefault(),q(Ke=>Math.min(Ke+1,Math.max(0,X.length-1))),!0;if(K.key==="ArrowUp")return K.preventDefault(),q(Ke=>Math.max(Ke-1,0)),!0;if(K.key==="Home")return K.preventDefault(),q(0),!0;if(K.key==="End")return K.preventDefault(),q(Math.max(0,X.length-1)),!0;if(K.key==="Enter"){K.preventDefault();const Ke=X[ve];return Ke&&ke(Ke.value),!0}return!1},ee=K=>{if(!a){if(J){if(Y(K))return;if(K.key===" "&&!u){K.preventDefault();const me=X[ve];me&&ke(me.value)}return}(K.key==="Enter"||K.key===" "||K.key==="ArrowDown"||K.key==="ArrowUp")&&(K.preventDefault(),fe(!0))}},pe=!!String(e||"").trim(),Oe=pe?ie:s,we=he!=null&&he.disabled?he.reason||"Unavailable":"",Pe=J&&X.length>0?`${Q}-opt-${ve}`:void 0,Be=i.jsx("span",{className:ci("af-select-value",!pe&&"af-select-value--placeholder"),children:l&&!pe?"Loading…":Oe}),rt=P?P(W,String(e||"")):Be;return i.jsxs("span",{className:ci("af-select",y==="pin"?"af-select--pin":"af-select--panel",x),children:[i.jsxs("button",{ref:V,id:Q,type:"button",className:ci("af-select-trigger",h&&pe&&"af-select-trigger--clearable",b),disabled:a,onMouseDown:K=>K.stopPropagation(),onClick:K=>{K.stopPropagation(),!a&&fe(me=>!me)},onKeyDown:ee,role:u?void 0:"combobox","aria-haspopup":"listbox","aria-expanded":J,"aria-controls":J?U:void 0,"aria-activedescendant":u?void 0:Pe,"aria-label":_,children:[rt,i.jsx("span",{className:ci("af-select-caret",J&&"af-select-caret--open"),children:"▾"})]}),h&&pe?i.jsx("button",{type:"button",className:"af-select-clear-btn","aria-label":"Clear selection",disabled:a,onMouseDown:K=>{K.preventDefault(),K.stopPropagation()},onClick:K=>{var me;K.preventDefault(),K.stopPropagation(),$(""),We(),(me=V.current)==null||me.focus()},title:"Clear",children:"×"}):null,J?Gh.createPortal(i.jsxs("div",{ref:H,className:ci("af-select-popover",oe==="top"&&"af-select-popover--top"),style:{position:"fixed",left:`${N.left}px`,top:`${N.top}px`,width:`${N.width}px`},onMouseDown:K=>K.stopPropagation(),onClick:K=>K.stopPropagation(),onWheel:K=>K.stopPropagation(),onKeyDown:Y,tabIndex:-1,children:[u?i.jsxs("div",{className:"af-select-search",children:[i.jsx("input",{ref:L,className:"af-select-search-input",value:ce,onChange:K=>ye(K.target.value),placeholder:d,onKeyDown:Y,role:"combobox","aria-expanded":!0,"aria-controls":U,"aria-activedescendant":Pe,"aria-invalid":!!we,"aria-describedby":we?`${Q}-custom-error`:void 0}),we?i.jsx("div",{id:`${Q}-custom-error`,className:"af-select-custom-error",role:"alert",children:we}):null]}):null,i.jsx("div",{className:"af-select-options",role:"listbox",id:U,"aria-label":_,children:l&&X.length===0?i.jsx("div",{className:"af-select-empty",children:"Loading…"}):X.length===0?i.jsx("div",{className:"af-select-empty",children:"No results"}):X.map((K,me)=>{var Cn;const De=K.value===e,Ke=me===ve,He=String(K.group||"").trim(),Xn=me>0?String(((Cn=X[me-1])==null?void 0:Cn.group)||"").trim():"",Mt=!!He&&He!==Xn;return i.jsxs(wt.Fragment,{children:[Mt?i.jsx("div",{className:"af-select-group",role:"presentation",children:He}):null,i.jsx("div",{id:`${Q}-opt-${me}`,role:"option","aria-selected":De,className:ci("af-select-option",De&&"af-select-option--selected",Ke&&"af-select-option--highlighted",K.disabled&&"af-select-option--disabled"),title:K.disabled?K.reason||"Unavailable":void 0,onMouseEnter:()=>q(me),onMouseDown:Zn=>{Zn.preventDefault(),Zn.stopPropagation()},onClick:()=>ke(K.value),"aria-disabled":K.disabled?!0:void 0,children:k?k(K,{selected:De,highlighted:Ke}):i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"af-select-option-label",children:[i.jsx("span",{children:K.label}),K.reason?i.jsx("small",{className:"af-select-option-reason",children:K.reason}):null]}),De?i.jsx("span",{className:"af-select-check",children:"✓"}):null]})})]},K.value)})})]}),document.body):null]})}function Jg(e){const n=new Set,s=[];for(const a of e||[]){if(!a||typeof a!="object")continue;const l=String(a.name||"").trim();!l||n.has(l)||(n.add(l),s.push({name:l,display_name:typeof a.display_name=="string"?a.display_name:void 0}))}return s.sort((a,l)=>a.name.localeCompare(l.name)),s}function Qg(e){const n=new Set,s=[];for(const a of e||[]){const l=String(a||"").trim();!l||n.has(l)||(n.add(l),s.push(l))}return s.sort(),s}function Yg(e){const n=e.disabled===!0,s=e.layout||"stack",a=e.allowGatewayDefault!==!1,l=String(e.gatewayDefaultLabel||"(gateway default)"),u=String(e.providerLabel||"Provider"),d=String(e.modelLabel||"Model"),f=String(e.providerPlaceholder||"(select)"),h=String(e.modelPlaceholder||"(select)"),g=String(e.provider||"").trim(),y=String(e.model||"").trim(),x=Jg(e.providers),b=Qg(e.models),_=n||!!e.loadingProviders,E=n||!!e.loadingModels,C=[...a?[{value:"",label:l}]:[],...x.map(T=>({value:T.name,label:T.display_name?`${T.display_name} (${T.name})`:T.name}))],j=[...a?[{value:"",label:l}]:[],...b.map(T=>({value:T,label:T}))];return i.jsxs("div",{className:e.className,style:s==="row"?{display:"flex",gap:"10px",flexWrap:"wrap",alignItems:"flex-start"}:{display:"flex",flexDirection:"column",gap:"10px"},children:[i.jsxs("div",{style:s==="row"?{flex:"1 1 260px",minWidth:240}:void 0,children:[i.jsx("label",{children:u}),i.jsx(Xr,{value:g,options:C,placeholder:a?l:f,disabled:_,loading:!!e.loadingProviders,searchable:!0,allowCustom:e.allowCustomProvider===!0,clearable:a,variant:"panel",triggerClassName:e.selectClassName,ariaLabel:u,onChange:T=>e.onChange({provider:String(T||"").trim(),model:""})}),e.loadingProviders?i.jsx("div",{className:"mono muted",style:{fontSize:"12px",marginTop:"6px"},children:"Loading providers…"}):null,e.providerError?i.jsx("div",{className:"mono",style:{color:"var(--error)",fontSize:"12px",marginTop:"6px"},children:e.providerError}):null]}),i.jsxs("div",{style:s==="row"?{flex:"1 1 260px",minWidth:240}:void 0,children:[i.jsx("label",{children:d}),i.jsx(Xr,{value:y,options:j,placeholder:a?l:h,disabled:E,loading:!!e.loadingModels,searchable:!0,allowCustom:e.allowCustomModel===!0,clearable:a,variant:"panel",triggerClassName:e.selectClassName,ariaLabel:d,onChange:T=>e.onChange({provider:g,model:String(T||"").trim()})}),e.loadingModels?i.jsx("div",{className:"mono muted",style:{fontSize:"12px",marginTop:"6px"},children:"Loading models…"}):null,e.modelError?i.jsx("div",{className:"mono",style:{color:"var(--error)",fontSize:"12px",marginTop:"6px"},children:e.modelError}):null]})]})}function Hh(e){if(e===!1||e&&typeof e=="object"&&e.mode==="off")return!1;if(!e||typeof e!="object")return;const n=e;if(!(n.mode!=="native_mtp"||!Number.isInteger(n.num_draft_tokens)||Number(n.num_draft_tokens)<1))return{mode:"native_mtp",num_draft_tokens:Number(n.num_draft_tokens),require_acceleration:!0}}function Xg(e){var s;const n=(s=e==null?void 0:e.execution)==null?void 0:s.speculation;return!n||typeof n.supported!="boolean"?null:{supported:n.supported,ready:typeof n.ready=="boolean"?n.ready:null,reason:typeof n.reason=="string"?n.reason:null,supported_depths:n.supported&&Array.isArray(n.supported_depths)?[...new Set(n.supported_depths.filter(a=>typeof a=="number"&&Number.isInteger(a)&&a>0))]:[],default:Object.prototype.hasOwnProperty.call(n,"effective_default")?n.effective_default:n.default,requires_reload:typeof n.requires_reload=="boolean"?n.requires_reload:null}}function Qf(e){const n=Hh(e);return n===!1?"off":n?String(n.num_draft_tokens):""}function Zg(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 qg(e){const n=Xg(e.capabilities),s=Qf(e.value),a=(n==null?void 0:n.supported_depths.map(String))||[],l=Qf(n==null?void 0:n.default),u=e.inheritLabel||"Workflow / Gateway default",d=l?`${u} (${l==="off"?"Off":`depth ${l}`})`:u,f=e.error||(e.loading?"Checking MTP capability…":n?n.reason||(n.requires_reload?"Model reload required before MTP can run.":n.ready===!1?"MTP is supported but not ready on this instance.":n.ready===null&&n.supported?"MTP support verified; loaded-instance readiness is unknown.":n.supported?"":"MTP is not supported on this model/backend."):"MTP capability unknown; no depth is assumed.");return i.jsxs("div",{className:"af-pmp__speculation",children:[i.jsx("label",{children:"MTP depth"}),i.jsx(Xr,{ariaLabel:"MTP depth",value:s,placeholder:d,disabled:e.disabled||e.loading,options:[{value:"",label:d},{value:"off",label:"Off"},...a.map(h=>({value:h,label:`Depth ${h}`})),...s&&s!=="off"&&!a.includes(s)?[{value:s,label:`Depth ${s} (saved; not available)`}]:[]],onChange:h=>e.onChange(Zg(h))}),f?i.jsx("div",{role:"status",className:"af-pmp__hint",children:f}):null]})}function uu(e){var q,oe;const n=e.disabled===!0,s=e.value||{provider:"",model:""},a=!String(s.provider||"").trim()&&!String(s.model||"").trim(),[l,u]=w.useState(!a),d=a&&!l,f=w.useRef(a);w.useEffect(()=>{a&&!f.current&&u(!1),f.current=a},[a]);const[h,g]=w.useState([]),[y,x]=w.useState(!1),[b,_]=w.useState(""),[E,C]=w.useState([]),[j,T]=w.useState(!1),[A,$]=w.useState(""),k=w.useRef(e);k.current=e,w.useEffect(()=>{if(d||n)return;let G=!0;return x(!0),(async()=>{try{const N=await k.current.fetchProviders();if(!G)return;g(Array.isArray(N)?N:[]),_("")}catch(N){if(!G)return;g([]),_(`#FALLBACK provider discovery failed: ${String((N==null?void 0:N.message)||N)}`)}finally{G&&x(!1)}})(),()=>{G=!1}},[d,n]);const P=String(s.provider||"").trim();w.useEffect(()=>{if(!P||n){C([]),$(""),T(!1);return}let G=!0;return C([]),T(!0),$(""),(async()=>{try{const N=await k.current.fetchModels(P);if(!G)return;C(Array.isArray(N)?N:[])}catch(N){if(!G)return;C([]),$(`#FALLBACK model discovery failed: ${String((N==null?void 0:N.message)||N)}`)}finally{G&&T(!1)}})(),()=>{G=!1}},[P,n]);const V=w.useMemo(()=>{const G=[...h];return P&&!G.some(N=>N.name===P)&&G.unshift({name:P}),G},[h,P]),H=String(s.model||"").trim(),L=w.useMemo(()=>{const G=[...E];return H&&!G.includes(H)&&G.unshift(H),G},[E,H]),de=e.defaultModeLabel||"Gateway default",re=e.customModeLabel||"Custom",Q=P||((q=e.effectiveDefault)==null?void 0:q.provider)||"",U=H||(P?"":(oe=e.effectiveDefault)==null?void 0:oe.model)||"",[J,fe]=w.useState({levels:[],error:"",loading:!1}),ce=!!e.fetchModelCapabilities,[ye,ve]=w.useState();return w.useEffect(()=>{let G=!0;if(ve(void 0),fe({levels:[],error:"",loading:ce&&!!U}),!(!ce||!U||n))return k.current.fetchModelCapabilities(U,Q).then(N=>{var ie;if(!G)return;if(N!=null&&N.error)throw new Error(String(N.error));ve(N);const B=(N==null?void 0:N.capabilities)||N||{},F=B.reasoning_levels||B.thinking_levels,W=Array.isArray(F)?[...new Set(F.filter(le=>typeof le=="string"&&!!le.trim()))]:[];!W.length&&B.thinking_support===!0&&((ie=B.thinking_control)!=null&&ie.prompt_disable_token)&&W.push("off","auto"),fe({levels:W,error:"",loading:!1})}).catch(N=>{G&&fe({levels:[],error:`Reasoning options unavailable: ${String((N==null?void 0:N.message)||N)}`,loading:!1})}),()=>{G=!1}},[Q,U,ce,n]),i.jsxs("div",{className:`af-pmp${e.className?` ${e.className}`:""}`,children:[i.jsxs("div",{className:"af-pmp__seg",role:"tablist","aria-label":"Provider mode",children:[i.jsx("button",{type:"button",role:"tab","aria-selected":d,className:`af-pmp__seg-btn${d?" is-active":""}`,onClick:()=>{u(!1),e.onChange({...s,provider:"",model:"",...ce?{reasoning:""}:{}})},disabled:n,children:de}),i.jsx("button",{type:"button",role:"tab","aria-selected":!d,className:`af-pmp__seg-btn${d?"":" is-active"}`,onClick:()=>{u(!0)},disabled:n,children:re})]}),d?i.jsx("div",{className:"af-pmp__hint",children:e.defaultHint||"The gateway picks its configured default provider and model for this task."}):i.jsx(Yg,{provider:P,model:H,providers:V,models:L,disabled:n,loadingProviders:y,loadingModels:j,providerError:b||void 0,modelError:A||void 0,providerLabel:e.providerLabel,modelLabel:e.modelLabel,allowGatewayDefault:!1,allowCustomProvider:e.allowCustom!==!1,allowCustomModel:e.allowCustom!==!1,onChange:G=>e.onChange({...s,provider:G.provider,model:G.model,...ce?{reasoning:""}:{}})}),ce&&(J.levels.length>0||s.reasoning)?i.jsxs("div",{className:"af-pmp__reasoning",children:[i.jsx("label",{children:e.reasoningLabel||"Reasoning effort"}),i.jsx(Xr,{ariaLabel:e.reasoningLabel||"Reasoning effort",placeholder:"Workflow / Gateway default",value:s.reasoning||"",options:[{value:"",label:"Workflow / Gateway default"},...J.levels.map(G=>({value:G,label:G})),...s.reasoning&&!J.levels.includes(s.reasoning)?[{value:s.reasoning,label:`${s.reasoning} (saved; not advertised)`}]:[]],disabled:n||J.loading,onChange:G=>e.onChange({...s,reasoning:G})})]}):null,J.error?i.jsx("div",{role:"status",className:"af-pmp__hint",children:J.error}):null,e.enableSpeculation?i.jsx(qg,{value:s.speculation,onChange:G=>e.onChange({...s,speculation:G}),capabilities:ye,disabled:n,loading:J.loading,error:J.error?J.error.replace("Reasoning options","MTP options"):void 0}):null]})}function Yf(...e){return e.filter(Boolean).join(" ")}function ey({kicker:e="AbstractGateway connection",title:n="Connect to AbstractGateway",description:s="Sign in with the Gateway user token assigned by the Gateway admin.",statusLabel:a="Gateway token missing",statusTone:l="warn",tokenSourceLabel:u="token: missing",showGatewayUrl:d=!1,gatewayUrl:f="",gatewayUrlPlaceholder:h="http://127.0.0.1:8080",onGatewayUrlChange:g,userId:y,userPlaceholder:x="admin",onUserIdChange:b,token:_,tokenPlaceholder:E="Paste Gateway user token",showToken:C=!1,onTokenChange:j,onShowTokenChange:T,remember:A=!1,rememberLabel:$="Remember this browser",onRememberChange:k,loading:P=!1,submitting:V=!1,submitDisabled:H=!1,submitLabel:L="Sign in",submittingLabel:de="Signing in...",closeLabel:re="Close",signOutLabel:Q="Sign out",showClose:U=!1,showSignOut:J=!1,error:fe,message:ce,className:ye,onSubmit:ve,onClose:q,onSignOut:oe}){const G=P||V,N=G||H||!String(y||"").trim()||!String(_||"").trim(),B=F=>{F.preventDefault(),!N&&ve()};return i.jsxs("form",{className:Yf("af-gateway-signin",ye),onSubmit:B,children:[i.jsxs("div",{className:"af-gateway-signin__hero",children:[i.jsxs("div",{children:[i.jsx("div",{className:"af-gateway-signin__kicker",children:e}),i.jsx("h2",{children:n}),s?i.jsx("p",{children:s}):null]}),i.jsx("div",{className:"af-gateway-signin__mark","aria-hidden":"true",children:"↔"})]}),i.jsxs("div",{className:"af-gateway-signin__status-row",children:[i.jsx("span",{className:Yf("af-gateway-signin__status",`af-gateway-signin__status--${l}`),children:a}),u?i.jsx("span",{className:"af-gateway-signin__source",children:u}):null]}),i.jsxs("div",{className:"af-gateway-signin__form",children:[d?i.jsxs(i.Fragment,{children:[i.jsx("label",{className:"af-gateway-signin__label",htmlFor:"gateway-session-url",children:"Gateway URL"}),i.jsx("input",{id:"gateway-session-url",value:f,onChange:F=>g==null?void 0:g(F.target.value),placeholder:h,autoComplete:"url",disabled:G})]}):null,i.jsx("label",{className:"af-gateway-signin__label",htmlFor:"gateway-session-user",children:"Gateway user"}),i.jsx("input",{id:"gateway-session-user",value:y,onChange:F=>b(F.target.value),placeholder:x,autoComplete:"username",disabled:G}),i.jsx("label",{className:"af-gateway-signin__label",htmlFor:"gateway-session-token",children:"Gateway token"}),i.jsxs("div",{className:"af-gateway-signin__token-input",children:[i.jsx("input",{id:"gateway-session-token",type:C?"text":"password",value:_,onChange:F=>j(F.target.value),placeholder:E,autoComplete:"current-password",disabled:G}),i.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:()=>T==null?void 0:T(!C),disabled:G,children:C?"Hide":"Show"})]}),i.jsx("label",{className:"af-gateway-signin__label",children:"Browser session"}),i.jsxs("label",{className:"af-gateway-signin__checkbox",children:[i.jsx("input",{type:"checkbox",checked:!!A,onChange:F=>k==null?void 0:k(F.target.checked),disabled:G}),$]})]}),fe?i.jsx("div",{className:"af-gateway-signin__message af-gateway-signin__message--error",children:fe}):null,!fe&&ce?i.jsx("div",{className:"af-gateway-signin__message af-gateway-signin__message--ok",children:ce}):null,i.jsxs("div",{className:"af-gateway-signin__actions",children:[U?i.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:q,disabled:G,children:re}):null,J?i.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:()=>void(oe==null?void 0:oe()),disabled:G,children:Q}):null,i.jsx("button",{className:"af-gateway-signin__primary",type:"submit",disabled:N,children:V?de:L})]})]})}function ty(e){return e==="light"?"Light":"Dark"}function ny(e){const n=e.themes&&e.themes.length?e.themes:Vh,s=e.showSwatches!==!1,a=e.variant||"panel",l=w.useMemo(()=>{const d={};for(const f of n)d[f.id]=f;return d},[n]),u=w.useMemo(()=>n.map(d=>({value:d.id,label:d.label,group:ty(d.group)})),[n]);return i.jsx(Xr,{value:e.value,options:u,placeholder:e.placeholder||"Select theme…",disabled:e.disabled===!0,searchable:!0,allowCustom:!1,clearable:!1,variant:a,className:e.className,triggerClassName:e.triggerClassName,onChange:d=>e.onChange(String(d||"").trim()),renderValue:(d,f)=>{const h=String(f||"").trim(),g=l[h],y=(g==null?void 0:g.label)||h||e.placeholder||"Select theme…",x=(g==null?void 0:g.swatches)||null,b=!h;return i.jsxs("span",{className:"af-theme-value",children:[i.jsx("span",{className:`af-theme-label ${b?"af-theme-label--placeholder":""}`.trim(),children:y}),s&&x?i.jsx("span",{className:"af-theme-swatches","aria-hidden":"true",children:x.map((_,E)=>i.jsx("span",{className:"af-theme-swatch",style:{background:_}},`${h}:${E}`))}):null]})},renderOption:(d,f)=>{const h=String(d.value||"").trim(),g=l[h],y=(g==null?void 0:g.swatches)||null;return i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"af-theme-option-label",children:d.label}),i.jsxs("span",{className:"af-theme-option-right",children:[s&&y?i.jsx("span",{className:"af-theme-swatches","aria-hidden":"true",children:y.map((x,b)=>i.jsx("span",{className:"af-theme-swatch",style:{background:x}},`${h}:${b}`))}):null,f.selected?i.jsx("span",{className:"af-select-check",children:"✓"}):null]})]})}})}function ry(e){const n=e.scales&&e.scales.length?e.scales:Kc,s=e.variant||"panel",a=w.useMemo(()=>n.map(l=>({value:l.id,label:l.label})),[n]);return i.jsx(Xr,{value:e.value,options:a,placeholder:e.placeholder||"Font size…",disabled:e.disabled===!0,searchable:!1,allowCustom:!1,clearable:!1,variant:s,className:e.className,triggerClassName:e.triggerClassName,onChange:l=>e.onChange(String(l||"").trim())})}function sy(e){const n=e.densities&&e.densities.length?e.densities:Jc,s=e.variant||"panel",a=w.useMemo(()=>n.map(l=>({value:l.id,label:l.label})),[n]);return i.jsx(Xr,{value:e.value,options:a,placeholder:e.placeholder||"Header size…",disabled:e.disabled===!0,searchable:!1,allowCustom:!1,clearable:!1,variant:s,className:e.className,triggerClassName:e.triggerClassName,onChange:l=>e.onChange(String(l||"").trim())})}const iy=new Set(["board","inbox","server","agent","playCircle","list","gear"]);function ay(e){switch(e){case"chat":return i.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 i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 5v14"}),i.jsx("path",{d:"M5 12h14"})]});case"history":return i.jsxs(i.Fragment,{children:[i.jsx("circle",{cx:"12",cy:"12",r:"9"}),i.jsx("path",{d:"M12 7v5l3 3"})]});case"refresh":return i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M21 12a9 9 0 0 0-15.5-6.4L3 8"}),i.jsx("path",{d:"M3 3v5h5"}),i.jsx("path",{d:"M3 12a9 9 0 0 0 15.5 6.4L21 16"}),i.jsx("path",{d:"M21 21v-5h-5"})]});case"settings":return i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M4 6h16"}),i.jsx("circle",{cx:"8",cy:"6",r:"2"}),i.jsx("path",{d:"M4 12h16"}),i.jsx("circle",{cx:"16",cy:"12",r:"2"}),i.jsx("path",{d:"M4 18h16"}),i.jsx("circle",{cx:"10",cy:"18",r:"2"})]});case"user":return i.jsxs(i.Fragment,{children:[i.jsx("circle",{cx:"12",cy:"8",r:"4"}),i.jsx("path",{d:"M4 21a8 8 0 0 1 16 0"})]});case"bot":return i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 2v3"}),i.jsx("rect",{x:"5",y:"6",width:"14",height:"14",rx:"3"}),i.jsx("circle",{cx:"9",cy:"13",r:"1",fill:"currentColor",stroke:"none"}),i.jsx("circle",{cx:"15",cy:"13",r:"1",fill:"currentColor",stroke:"none"}),i.jsx("path",{d:"M9 17h6"})]});case"paperclip":return i.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 i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 14a3 3 0 0 0 3-3V5a3 3 0 0 0-6 0v6a3 3 0 0 0 3 3z"}),i.jsx("path",{d:"M19 11a7 7 0 0 1-14 0"}),i.jsx("path",{d:"M12 18v4"}),i.jsx("path",{d:"M8 22h8"})]});case"speaker":return i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M11 5L6 9H2v6h4l5 4V5z"}),i.jsx("path",{d:"M15.5 8.5a5 5 0 0 1 0 7"}),i.jsx("path",{d:"M18 6a9 9 0 0 1 0 12"})]});case"pause":return i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",fill:"currentColor",stroke:"none"}),i.jsx("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",fill:"currentColor",stroke:"none"})]});case"terminal":return i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",ry:"2"}),i.jsx("path",{d:"M7 9l3 3-3 3"}),i.jsx("path",{d:"M12 15h5"})]});case"edit":return i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 20h9"}),i.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 i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),i.jsx("path",{d:"M7 10l5 5 5-5"}),i.jsx("path",{d:"M12 15V3"})]});case"loader":return i.jsx("path",{d:"M21 12a9 9 0 1 1-3.3-6.9"});case"info":return i.jsxs(i.Fragment,{children:[i.jsx("circle",{cx:"12",cy:"12",r:"10"}),i.jsx("path",{d:"M12 16v-4"}),i.jsx("circle",{cx:"12",cy:"8",r:"0.75",fill:"currentColor",stroke:"none"})]});case"warning":return i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 3l10 18H2L12 3z"}),i.jsx("path",{d:"M12 9v4"}),i.jsx("circle",{cx:"12",cy:"17",r:"0.75",fill:"currentColor",stroke:"none"})]});case"error":return i.jsxs(i.Fragment,{children:[i.jsx("circle",{cx:"12",cy:"12",r:"10"}),i.jsx("path",{d:"M15 9l-6 6"}),i.jsx("path",{d:"M9 9l6 6"})]});case"copy":return i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),i.jsx("path",{d:"M5 15V5a2 2 0 0 1 2-2h10"})]});case"check":return i.jsx("path",{d:"M20 6L9 17l-5-5"});case"x":return i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M18 6L6 18"}),i.jsx("path",{d:"M6 6l12 12"})]});case"chevronDown":return i.jsx("path",{d:"M6 9l6 6 6-6"});case"chevronRight":return i.jsx("path",{d:"M9 18l6-6-6-6"});case"trash":return i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M3 6h18"}),i.jsx("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),i.jsx("path",{d:"M6 6l1 16h10l1-16"}),i.jsx("path",{d:"M10 11v6"}),i.jsx("path",{d:"M14 11v6"})]});case"send":return i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M22 2L11 13"}),i.jsx("path",{d:"M22 2L15 22l-4-9-9-4 20-7z"})]});case"thumbsUp":return i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M7 10v11"}),i.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 i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M17 14V3"}),i.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 i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M7 10v11"}),i.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 i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M17 14V3"}),i.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 i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"1.5",y:"2",width:"3.6",height:"12",rx:"1"}),i.jsx("rect",{x:"6.2",y:"2",width:"3.6",height:"8.5",rx:"1"}),i.jsx("rect",{x:"10.9",y:"2",width:"3.6",height:"5.5",rx:"1"})]});case"inbox":return i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M2 9.5 L4 3.5 h8 l2 6"}),i.jsx("path",{d:"M2 9.5 v3 h12 v-3"}),i.jsx("path",{d:"M2 9.5 h3.4 l1 1.6 h3.2 l1-1.6 H14"})]});case"server":return i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"2",y:"2.5",width:"12",height:"4.6",rx:"1.2"}),i.jsx("rect",{x:"2",y:"8.9",width:"12",height:"4.6",rx:"1.2"}),i.jsx("circle",{cx:"4.6",cy:"4.8",r:"0.8",fill:"currentColor",stroke:"none"}),i.jsx("circle",{cx:"4.6",cy:"11.2",r:"0.8",fill:"currentColor",stroke:"none"})]});case"agent":return i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"3",y:"4.5",width:"10",height:"8",rx:"2"}),i.jsx("path",{d:"M8 4.5V2.2"}),i.jsx("circle",{cx:"8",cy:"1.8",r:"0.9",fill:"currentColor",stroke:"none"}),i.jsx("circle",{cx:"5.8",cy:"8.4",r:"0.9",fill:"currentColor",stroke:"none"}),i.jsx("circle",{cx:"10.2",cy:"8.4",r:"0.9",fill:"currentColor",stroke:"none"})]});case"playCircle":return i.jsxs(i.Fragment,{children:[i.jsx("circle",{cx:"8",cy:"8",r:"6.2"}),i.jsx("path",{d:"M6.5 5.6 L11 8 L6.5 10.4 Z",fill:"currentColor",stroke:"none"})]});case"list":return i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M2.5 4h11"}),i.jsx("path",{d:"M2.5 8h11"}),i.jsx("path",{d:"M2.5 12h7"})]});case"gear":return i.jsxs(i.Fragment,{children:[i.jsx("circle",{cx:"8",cy:"8",r:"2.2"}),i.jsx("path",{d:"M8 1.6v2"}),i.jsx("path",{d:"M8 12.4v2"}),i.jsx("path",{d:"M1.6 8h2"}),i.jsx("path",{d:"M12.4 8h2"}),i.jsx("path",{d:"M3.5 3.5l1.4 1.4"}),i.jsx("path",{d:"M11.1 11.1l1.4 1.4"}),i.jsx("path",{d:"M12.5 3.5l-1.4 1.4"}),i.jsx("path",{d:"M4.9 11.1l-1.4 1.4"})]});case"sparkle":return i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9z"}),i.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 i.jsxs(i.Fragment,{children:[i.jsx("circle",{cx:"12",cy:"12",r:"9"}),i.jsx("path",{d:"M12 3a9 9 0 0 1 0 18z",fill:"currentColor",stroke:"none"})]});case"logout":return i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),i.jsx("path",{d:"M16 17l5-5-5-5"}),i.jsx("path",{d:"M21 12H9"})]});case"play":return i.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 i.jsx("rect",{x:"5",y:"5",width:"14",height:"14",rx:"2",fill:"currentColor",stroke:"none"});case"folder":return i.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 i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),i.jsx("path",{d:"M14 2v6h6"})]});case"archive":return i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"2",y:"3",width:"20",height:"5",rx:"1"}),i.jsx("path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8"}),i.jsx("path",{d:"M10 12h4"})]});case"clock":return i.jsxs(i.Fragment,{children:[i.jsx("circle",{cx:"12",cy:"12",r:"10"}),i.jsx("path",{d:"M12 6v6h4"})]});default:return null}}function ae({name:e,size:n=16,className:s,title:a,...l}){const u=a?void 0:!0,d=iy.has(e);return i.jsxs("svg",{width:n,height:n,viewBox:d?"0 0 16 16":"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:d?1.4:2,strokeLinecap:"round",strokeLinejoin:"round",className:s,"aria-hidden":u,role:a?"img":"presentation",...l,children:[a?i.jsx("title",{children:a}):null,ay(e)]})}const Uo="api/gateway",_a="api/connection/gateway";function Se(e){const n=String(e||"");if(n.startsWith("/"))throw new Error(`gatewayApiPath takes a route relative to the gateway API, got ${JSON.stringify(n)}.`);return n?`${Uo}/${n}`:Uo}function Xe(e,n){const s=String(n||"");if(s.startsWith("/"))throw new Error(`joinBaseUrl takes a relative path, got ${JSON.stringify(s)}.`);let a=String(e??"");for(;a.endsWith("/");)a=a.slice(0,-1);return a?`${a}/${s}`:s}function oy(e){const n=String(e||""),s=`/${Uo}/`;if(!n.startsWith(s)||n.length===s.length)throw new Error(`Not a gateway API path: ${JSON.stringify(n)} (expected ${JSON.stringify(s)}…).`);const a=n.slice(s.length).split(/[?#]/,1)[0];if(/\\|%2f|%5c/i.test(a))throw new Error(`Not a gateway API path: ${JSON.stringify(n)} (encoded slash or backslash).`);for(const l of a.split("/")){const u=l.replace(/%2e/gi,".");if(u==="."||u==="..")throw new Error(`Not a gateway API path: ${JSON.stringify(n)} (a "." or ".." segment).`)}return n.slice(1)}const ly={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 cy(e){const n=new Set,s=[];for(const a of e||[]){if(!a)continue;const l=String(a.name||"").trim();!l||n.has(l)||(n.add(l),s.push({name:l,description:typeof a.description=="string"?a.description:void 0,toolset:typeof a.toolset=="string"?a.toolset:void 0,when_to_use:typeof a.when_to_use=="string"?a.when_to_use:void 0,default_approval:a.default_approval==="approve"||a.default_approval==="ask"?a.default_approval:void 0}))}return s.sort((a,l)=>{const u=String(a.toolset||""),d=String(l.toolset||"");return u!==d?u.localeCompare(d):a.name.localeCompare(l.name)}),s}function uy(e,n){return e.default_approval?e.default_approval:n.requireApproval.includes(e.name)?"ask":n.autoApprove.includes(e.name)?"approve":"ask"}function dy(e,n,s){const a=String(e||"").trim().toLowerCase();if(!a&&!n&&!s)return null;let l;return a==="approval"||a==="local_approval"||a==="local-approval"?l={label:"APPROVAL",detail:"Safe tools auto-run; mutating tools ask for approval.",tone:"safe"}:a==="passthrough"?l={label:"PASSTHROUGH",detail:"All tools require approval before execution.",tone:"warn"}:a==="delegated"||a==="delegate"||a==="job"?l={label:"DELEGATED",detail:"Tool calls wait for external executors.",tone:"info"}:a==="local"||a==="local_all"||a==="local-all"?l={label:"LOCAL",detail:"All tools run locally; client policy may still require approval.",tone:"danger"}:l={label:"UNKNOWN",detail:"#FALLBACK: gateway tool mode not reported.",tone:"warn"},n&&(l={...l,label:n}),s&&(l={...l,detail:s}),l}function fy(e){var de,re;const n=e.defaults||ly,s=e.disabled===!0,a=e.title||"Tools",l=e.subtitle||"Default is all tools. Safe/read-only tools auto-approve; mutating tools ask for approval.",u=String(e.note||"").trim(),d=w.useMemo(()=>dy(e.toolMode,e.toolModeLabel,e.toolModeDetail),[e.toolMode,e.toolModeLabel,e.toolModeDetail]),f=w.useMemo(()=>cy(e.tools),[e.tools]),h=w.useMemo(()=>f.map(Q=>Q.name),[f]),g=w.useMemo(()=>new Set(h),[h]),[y,x]=w.useState(""),b=w.useMemo(()=>{var fe;const Q=Array.isArray((fe=e.value)==null?void 0:fe.selected)?e.value.selected:[],U=new Set,J=[];for(const ce of Q){const ye=String(ce||"").trim();!ye||U.has(ye)||(U.add(ye),J.push(ye))}return J},[(de=e.value)==null?void 0:de.selected]),_=w.useMemo(()=>b.filter(Q=>g.has(Q)),[b,g]),E=w.useMemo(()=>b.filter(Q=>!g.has(Q)),[b,g]),C=((re=e.value)==null?void 0:re.mode)==="custom"?"custom":"all",j=w.useMemo(()=>{const Q=y.trim().toLowerCase();return Q?f.filter(U=>{const J=U.name.toLowerCase(),fe=(U.description||"").toLowerCase();return J.includes(Q)||fe.includes(Q)}):f},[f,y]),T=C==="all"?new Set(h):new Set(_),A=Q=>{e.onChange(Q)},$=Q=>{s||A({...e.value,mode:Q,selected:b})},k=(Q,U)=>{if(s)return;const J=new Set(_);U?J.add(Q):J.delete(Q),A({...e.value,selected:[...E,...Array.from(J)],mode:"custom"})},P=(Q,U)=>{var fe;if(s)return;const J={...((fe=e.value)==null?void 0:fe.approval)||{}};J[Q]=U,A({...e.value,approval:J})},V=()=>{s||A({...e.value,selected:[...E,...h],mode:"custom"})},H=()=>{s||A({...e.value,selected:[...E],mode:"custom"})},L=T.size;return i.jsxs("div",{className:`af-tool-policy ${e.className||""}`.trim(),children:[i.jsxs("div",{className:"af-tool-policy__header",children:[i.jsx("div",{className:"af-tool-policy__title",children:a}),i.jsx("div",{className:"af-tool-policy__subtitle",children:l}),d?i.jsxs("div",{className:`af-tool-policy__mode is-${d.tone}`,children:[i.jsx("div",{className:"af-tool-policy__mode-badge",children:"Tool mode"}),i.jsx("div",{className:"af-tool-policy__mode-value",children:d.label}),i.jsx("div",{className:"af-tool-policy__mode-detail",children:d.detail})]}):null,u?i.jsx("div",{className:"af-tool-policy__note",children:u}):null]}),i.jsxs("div",{className:"af-tool-policy__controls",children:[i.jsxs("div",{className:"af-tool-policy__segmented",role:"group","aria-label":"Tool allowlist mode",children:[i.jsx("button",{type:"button",className:`af-tool-policy__seg-btn ${C==="all"?"is-active":""}`.trim(),onClick:()=>$("all"),disabled:s,"aria-pressed":C==="all",children:"All tools"}),i.jsx("button",{type:"button",className:`af-tool-policy__seg-btn ${C==="custom"?"is-active":""}`.trim(),onClick:()=>$("custom"),disabled:s,"aria-pressed":C==="custom",children:"Custom allowlist"})]}),i.jsxs("div",{className:"af-tool-policy__count",children:[L," / ",h.length," enabled"]}),i.jsxs("div",{className:"af-tool-policy__bulk",children:[i.jsx("button",{type:"button",onClick:V,disabled:s||C!=="custom",children:"Select all"}),i.jsx("button",{type:"button",onClick:H,disabled:s||C!=="custom",children:"Select none"})]})]}),i.jsx("div",{className:"af-tool-policy__filter",children:i.jsx("input",{type:"text",placeholder:"Filter tools...","aria-label":"Filter tools",value:y,onChange:Q=>x(Q.target.value),disabled:s})}),i.jsxs("div",{className:"af-tool-policy__list",children:[j.map(Q=>{var fe,ce;const U=T.has(Q.name),J=((ce=(fe=e.value)==null?void 0:fe.approval)==null?void 0:ce[Q.name])||uy(Q,n);return i.jsxs("div",{className:`af-tool-row ${U?"is-enabled":""}`.trim(),children:[i.jsx("label",{className:"af-tool-row__check",children:i.jsx("input",{type:"checkbox",checked:U,disabled:s||C!=="custom",onChange:ye=>k(Q.name,ye.target.checked),"aria-label":`Enable ${Q.name}`})}),i.jsxs("div",{className:"af-tool-row__meta",children:[i.jsxs("div",{className:"af-tool-row__title",children:[i.jsx("span",{className:"af-tool-row__name",children:Q.name}),Q.toolset?i.jsx("span",{className:"af-tool-row__badge",children:Q.toolset}):null]}),Q.description?i.jsx("div",{className:"af-tool-row__desc",children:Q.description}):null,Q.when_to_use?i.jsx("div",{className:"af-tool-row__hint",children:Q.when_to_use}):null]}),i.jsx("div",{className:"af-tool-row__approval",children:i.jsxs("select",{value:J,disabled:s||!U,onChange:ye=>P(Q.name,ye.target.value),"aria-label":`Approval mode for ${Q.name}`,children:[i.jsx("option",{value:"approve",children:"Approve"}),i.jsx("option",{value:"ask",children:"Ask"})]})})]},Q.name)}),j.length?null:i.jsx("div",{className:"af-tool-policy__empty",children:"No tools match the filter."})]})]})}async function Qc(e=_a){const n=await fetch(e),s=await n.json().catch(()=>null);if(!n.ok){const a=s&&typeof s=="object"&&s.detail?String(s.detail):`HTTP ${n.status}`;throw new Error(a)}return s}async function hy(e,n=_a){const s=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),a=await s.json().catch(()=>null);if(!s.ok){const l=a&&typeof a=="object"&&a.detail?String(a.detail):`HTTP ${s.status}`;throw new Error(l)}return a}async function Kh(e=_a){const n=await fetch(e,{method:"DELETE"});if(!n.ok){const s=await n.json().catch(()=>({})),a=s&&typeof s=="object"&&s.detail?String(s.detail):`HTTP ${n.status}`;throw new Error(a)}}function Ec(e){let n=String(e||"").trim();for(let s=0;s<2&&n;s+=1){try{const u=JSON.parse(n);if(typeof u=="string"&&u!==n){n=u.trim();continue}}catch{}const a=n[0],l=n[n.length-1];if(a==='"'&&l==='"'||a==="'"&&l==="'"){n=n.slice(1,-1).trim();continue}break}return n.replace(/\/+$/,"")}function py(e){var u,d;if(!e)return{label:"Signed out",tone:"warn"};if(!e.has_session)return{label:"Signed out",tone:"warn"};const n=e.gateway||{},s=(u=n.principal)==null?void 0:u.user_id,a=(d=n.principal)==null?void 0:d.runtime_id;if(n.ok&&s)return{label:`Signed in as ${s}${a?` · runtime ${a}`:""}`,tone:"ok"};if(n.ok)return{label:"Signed in",tone:"ok"};const l=n.error||n.detail;return typeof l=="string"&&l.trim()?{label:"Session rejected — sign in again",tone:"err"}:{label:"Sign in required",tone:"err"}}function my(e){const n=e.connectionPath||_a,[s,a]=w.useState(!1),[l,u]=w.useState(!1),[d,f]=w.useState(null),[h,g]=w.useState(!1);w.useEffect(()=>{e.isOpen||g(!1)},[e.isOpen]);const[y,x]=w.useState(e.defaultGatewayUrl||"http://127.0.0.1:8080"),[b,_]=w.useState("admin"),[E,C]=w.useState(""),[j,T]=w.useState(!1),[A,$]=w.useState(!0),[k,P]=w.useState(""),[V,H]=w.useState(""),L=w.useMemo(()=>py(d),[d]),de=J=>{var fe;f(J),(fe=e.onStatusChange)==null||fe.call(e,J)},re=w.useRef(!1);if(w.useEffect(()=>{var fe;if(!e.isOpen)return;const J=!re.current;if(re.current=!0,J&&e.initialStatus!==void 0&&e.initialStatus!==null){const ce=e.initialStatus;de(ce),typeof ce.gateway_url=="string"&&ce.gateway_url.trim()&&x(Ec(ce.gateway_url));const ye=(fe=ce.gateway)==null?void 0:fe.principal;ye!=null&&ye.user_id&&_(ye.user_id);return}a(!0),P(""),Qc(n).then(ce=>{var ve;de(ce),typeof ce.gateway_url=="string"&&ce.gateway_url.trim()&&x(Ec(ce.gateway_url));const ye=(ve=ce.gateway)==null?void 0:ve.principal;ye!=null&&ye.user_id&&_(ye.user_id)}).catch(ce=>P(`Failed to load connection status: ${String((ce==null?void 0:ce.message)||ce)}`)).finally(()=>a(!1))},[e.isOpen]),w.useEffect(()=>{if(!e.isOpen)return;const J=fe=>{fe.key==="Escape"&&!fe.defaultPrevented&&!e.blocking&&(fe.preventDefault(),e.onClose())};return window.addEventListener("keydown",J),()=>window.removeEventListener("keydown",J)},[e.isOpen,e.blocking,e.onClose]),!e.isOpen||h)return null;const Q=async()=>{u(!0),P(""),H("");try{const J=Ec(y);x(J);const fe=await hy({gateway_url:J,gateway_user_id:b,gateway_token:E,persist:A},n);de(fe),C(""),g(!0),e.onClose()}catch(J){P(String((J==null?void 0:J.message)||J))}finally{u(!1)}},U=async()=>{u(!0),P(""),H("");try{await Kh(n),C("");const J=await Qc(n).catch(()=>null);de(J),H("Signed out. This browser no longer holds a gateway session.")}catch(J){P(String((J==null?void 0:J.message)||J))}finally{u(!1)}};return i.jsx("div",{className:"af-connect-overlay",role:"presentation",onMouseDown:J=>{!e.blocking&&J.target===J.currentTarget&&e.onClose()},children:i.jsx("div",{className:"af-connect-modal",role:"dialog","aria-modal":"true","aria-label":"Gateway connection",children:i.jsx(ey,{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,tokenSourceLabel:d!=null&&d.has_session?"token: browser session":"token: missing",showGatewayUrl:!0,gatewayUrl:y,onGatewayUrlChange:J=>x(J),userId:b,onUserIdChange:_,token:E,tokenPlaceholder:d!=null&&d.has_session?"(browser session already signed in)":"Paste Gateway user token",showToken:j,onTokenChange:C,onShowTokenChange:T,remember:A,rememberLabel:"Keep this browser signed in",onRememberChange:$,loading:s,submitting:l,submittingLabel:"Signing in...",showClose:!e.blocking,onClose:e.onClose,showSignOut:!e.blocking&&!!(d!=null&&d.has_session),onSignOut:U,error:k,message:V,onSubmit:Q})})})}function gy(e){return!!(e&&e.ok===!0&&e.has_session===!0)}function yy(e){const n=e||{},s=n.connectionPath||_a,a=n.variant||"dismissable",l=w.useRef(n.onStatusChange);l.current=n.onStatusChange;const u=w.useRef(a);u.current=a;const d=w.useRef(!!n.autoOpenMidSession);d.current=!!n.autoOpenMidSession;const[f,h]=w.useState(null),[g,y]=w.useState("loading"),[x,b]=w.useState(!1),_=w.useRef(!1),E=w.useRef(!1),C=w.useRef("loading"),j=w.useRef("none"),T=w.useRef(!1),A=w.useRef(0),$=w.useCallback(fe=>{var ye;A.current+=1,h(fe),(ye=l.current)==null||ye.call(l,fe);const ce=gy(fe);if(ce)y("connected"),C.current="connected",_.current=!1,j.current="none",E.current||b(!1);else if(fe!==null){const ve=C.current;y("disconnected"),C.current="disconnected",ve!=="disconnected"&&(j.current=T.current?"signout":ve==="connected"?"mid":"boot");const q=u.current==="blocking"||j.current!=="mid"||d.current;!_.current&&q&&b(!0)}fe!==null&&(E.current=ce)},[]),k=w.useCallback(async()=>{const fe=A.current;try{const ce=await Qc(s);if(A.current!==fe)return;$(ce)}catch{if(A.current!==fe)return;$(null)}},[s,$]),[P,V]=w.useState(!1),[H,L]=w.useState(null),de=w.useCallback(async()=>{V(!0),L(null),A.current+=1;let fe=null;try{await Kh(s)}catch(ce){fe=String((ce==null?void 0:ce.message)||ce||"Sign-out request failed")}T.current=!0;try{await k()}finally{T.current=!1}L(fe),V(!1)},[s,k]),re=w.useRef(!1);w.useEffect(()=>{re.current||(re.current=!0,k())},[k]);const Q=w.useCallback(()=>{b(!0)},[]),U=w.useCallback(()=>{const fe=C.current;a==="blocking"&&fe==="disconnected"||(fe==="disconnected"&&(_.current=!0),b(!1))},[a]),J=w.useMemo(()=>({isOpen:x,onClose:U,blocking:a==="blocking"&&g!=="connected",appName:n.appName,connectionPath:s,defaultGatewayUrl:n.defaultGatewayUrl,initialStatus:f,onStatusChange:$}),[x,U,a,g,n.appName,s,n.defaultGatewayUrl,f,$]);return{status:f,phase:g,connected:g==="connected",modalOpen:x,signingOut:P,signOutError:H,openModal:Q,refresh:k,signOut:de,modalProps:J}}function Yc(e){const n=e.closeOnEscape!==!1,s=w.useRef(null);return w.useEffect(()=>{if(!e.open||!n)return;const a=l=>{l.key!=="Escape"||l.defaultPrevented||(l.preventDefault(),e.onClose())};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e.open,n,e.onClose]),w.useEffect(()=>{const a=s.current;a&&(e.open?a.removeAttribute("inert"):a.setAttribute("inert",""))},[e.open]),i.jsxs("div",{ref:s,className:`af-drawer${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?i.jsxs("div",{className:"af-drawer__header",children:[i.jsx("div",{className:"af-drawer__title",children:e.title}),i.jsxs("div",{className:"af-drawer__header-actions",children:[e.headerActions,i.jsx("button",{type:"button",className:"af-drawer__close","aria-label":"Close panel",onClick:e.onClose,children:"×"})]})]}):null,i.jsx("div",{className:"af-drawer__body",children:e.children})]})}const wy={name:"AbstractFramework",website:"https://abstractframework.ai",author:"Laurent-Philippe Albou, PhD",years:"2023-2026",copyright:"© 2023-2026 Laurent-Philippe Albou, PhD. Released under the MIT License.",contact_email:"contact@abstractframework.ai"},vy={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"}},_y={framework:wy,apps:vy},Bo=_y;function xy(){return Object.keys(Bo.apps).sort()}function by(e,n){const s=Object.prototype.hasOwnProperty.call(Bo.apps,e)?Bo.apps[e]:void 0;if(!s)throw new Error(`appIdentity: unknown application id "${e}" (known: ${xy().join(", ")})`);return{id:e,name:s.name,version:n,website:s.website,repo:s.repo,docs:s.docs,issues:s.issues,feedback:s.feedback}}function ky(e,n){const s=Bo.framework,a=[["Application",`${e.name} ${e.version}`],["Part of",`${s.name} — ${s.website}`],["Author",`${s.author} (${s.years})`],["Copyright",s.copyright],["Website",e.website],["Source",e.repo],["Documentation",e.docs],["Report an issue",e.issues],["Give feedback",e.feedback],["Contact",s.contact_email]];for(const[l,u]of n||[])a.push([String(l),String(u)]);return a}function $c(e){return typeof e=="string"?e.trim():""}function Xf(e,n){if(n!=null)return[["Gateway",`unavailable (${String(n).trim()||"unknown error"})`]];const s=e&&typeof e=="object"&&!Array.isArray(e)?e:{},a=$c(s.abstractgateway);if(!a)return[["Gateway","unavailable (the gateway did not report its version)"]];const l=$c(s.abstractframework),u=[["Gateway",`AbstractGateway ${a}`],["Gateway framework",l?`AbstractFramework ${l}`:"not installed on the gateway host"]],d=s.packages&&typeof s.packages=="object"&&!Array.isArray(s.packages)?s.packages:{},f=Object.keys(d).filter(h=>h!=="abstractgateway"&&h!=="abstractframework").sort((h,g)=>h<g?-1:h>g?1:0);for(const h of f){const g=$c(d[h]);g&&u.push([`Gateway package ${h}`,g])}return u}const jy='a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])';function Jh(e,n,s){if(e.key!=="Tab"||!n)return;const a=Array.from(n.querySelectorAll(jy));if(a.length===0){e.preventDefault();return}const l=a[0],u=a[a.length-1],d=!!s&&n.contains(s);e.shiftKey?(s===l||!d)&&(e.preventDefault(),u.focus()):(s===u||!d)&&(e.preventDefault(),l.focus())}const Sy=/https?:\/\/[^\s<>"]+/g;function Ny(e,n){if(e==="Contact")return[{text:n,href:`mailto:${n}`}];const s=[];let a=0;for(const l of n.matchAll(Sy)){const u=l.index??0;u>a&&s.push({text:n.slice(a,u)}),s.push({text:l[0],href:l[0]}),a=u+l[0].length}return(a<n.length||s.length===0)&&s.push({text:n.slice(a)}),s}function Cy({label:e,value:n}){return i.jsx("span",{children:Ny(e,n).map((s,a)=>s.href===void 0?i.jsx(wt.Fragment,{children:s.text},a):s.href.startsWith("mailto:")?i.jsx("a",{className:"af-about__link",href:s.href,children:s.text},a):i.jsx("a",{className:"af-about__link",href:s.href,target:"_blank",rel:"noopener noreferrer",children:s.text},a))})}function Ey(e){const n=w.useRef(null),s=w.useRef(null),a=w.useId(),l=w.useRef(e.onClose);if(l.current=e.onClose,w.useEffect(()=>{var g;if(!e.open)return;const f=document.activeElement;(g=n.current)==null||g.focus();const h=y=>{if(!y.defaultPrevented){if(y.key==="Escape"){y.preventDefault(),l.current();return}Jh(y,s.current,document.activeElement)}};return window.addEventListener("keydown",h),()=>{window.removeEventListener("keydown",h),f&&typeof f.focus=="function"&&f.focus()}},[e.open]),!e.open)return null;const u=e.title||`About ${e.identity.name}`,d=ky(e.identity,e.extraRows);return i.jsx("div",{className:"af-appearance-overlay af-about-overlay",onClick:e.onClose,role:"presentation",children:i.jsxs("div",{ref:s,className:"af-appearance af-about",role:"dialog","aria-modal":"true","aria-labelledby":a,onClick:f=>f.stopPropagation(),children:[i.jsx("div",{className:"af-appearance__title",id:a,children:u}),i.jsx("dl",{className:"af-about__rows",children:d.map(([f,h],g)=>i.jsxs("div",{className:"af-about__row",children:[i.jsx("dt",{className:"af-about__label",children:f}),i.jsx("dd",{className:"af-about__value",children:i.jsx(Cy,{label:f,value:h})})]},`${g}:${f}`))}),i.jsx("div",{className:"af-appearance__actions",children:i.jsx("button",{ref:n,type:"button",className:"af-appearance__close",onClick:e.onClose,children:"Close"})})]})})}function $y(e){const{connection:n}=e,s=n.phase,a=n.signingOut===!0,[l,u]=w.useState(!1),d=e.about,f=a?"Signing out…":s==="connected"?"Disconnect":s==="loading"?"Connecting…":"Connect",h=s==="connected"?"Disconnect from gateway":s==="loading"?"Checking gateway session…":"Connect to gateway";return i.jsxs("div",{className:`af-topbar${e.className?` ${e.className}`:""}`,role:"group","aria-label":"App actions",children:[e.assistant?i.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",title:e.assistant.label||"Assistant",onClick:e.assistant.onToggle,children:i.jsx(ae,{name:"sparkle",size:16})}):null,e.appearance?i.jsx("button",{type:"button",className:"af-topbar__btn","aria-label":e.appearance.label||"Appearance (theme and typography)",title:e.appearance.label||"Appearance",onClick:e.appearance.onOpen,children:i.jsx(ae,{name:"contrast",size:16})}):null,d?i.jsx("button",{type:"button",className:"af-topbar__btn af-topbar__btn--about","aria-label":d.label||`About ${d.identity.name}`,title:d.label||"About","aria-haspopup":"dialog",onClick:()=>{var g;u(!0),(g=d.onOpen)==null||g.call(d)},children:i.jsx(ae,{name:"info",size:16})}):null,e.extraActions,i.jsxs("button",{type:"button",className:`af-topbar__pill af-topbar__pill--${s}`,onClick:s==="connected"?n.onDisconnect:n.onConnect,disabled:a,title:h,"aria-label":h,children:[i.jsx("span",{className:`af-topbar__dot af-topbar__dot--${s}`,"aria-hidden":"true"}),i.jsx("span",{className:"af-topbar__pill-label",children:f})]}),d?i.jsx(Ey,{open:l,onClose:()=>u(!1),identity:d.identity,extraRows:d.extraRows}):null]})}const Do={theme:"dark",font_scale:"md",header_density:"standard"};function Ay(e){const n=e&&typeof e=="object"?e:{};return{theme:typeof n.theme=="string"&&n.theme?n.theme:Do.theme,font_scale:typeof n.font_scale=="string"&&n.font_scale?n.font_scale:Do.font_scale,header_density:typeof n.header_density=="string"&&n.header_density?n.header_density:Do.header_density}}function Ty(e){return`af_appearance_${e}_v1`}function Ry(e,n){const s=Ty(e),a=w.useMemo(()=>({...Do,...(n==null?void 0:n.defaults)||{}}),[JSON.stringify((n==null?void 0:n.defaults)||{})]),[l,u]=w.useState(()=>{let d=a;try{const f=localStorage.getItem(s)??(n!=null&&n.legacyKey?localStorage.getItem(n.legacyKey):null);f&&(d=Ay({...a,...JSON.parse(f)}))}catch{}try{Kf(d.theme),Jf({font_scale:d.font_scale,header_density:d.header_density})}catch{}return d});return w.useEffect(()=>{Kf(l.theme),Jf({font_scale:l.font_scale,header_density:l.header_density});try{localStorage.setItem(s,JSON.stringify(l))}catch{}},[s,l]),[l,u]}function Iy(e){return w.useEffect(()=>{if(!e.open)return;const n=s=>{s.key!=="Escape"||s.defaultPrevented||(s.preventDefault(),e.onClose())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e.open,e.onClose]),e.open?i.jsx("div",{className:"af-appearance-overlay",onClick:e.onClose,role:"presentation",children:i.jsxs("div",{className:"af-appearance",role:"dialog","aria-modal":"true","aria-label":e.title||"Appearance",onClick:n=>n.stopPropagation(),children:[i.jsx("div",{className:"af-appearance__title",children:e.title||"Appearance"}),i.jsx("div",{className:"af-appearance__note",children:e.note||"Stored locally in this browser, per app."}),i.jsxs("div",{className:"af-appearance__grid",children:[i.jsx("label",{className:"af-appearance__label",children:"Theme"}),i.jsx(ny,{value:e.value.theme,onChange:n=>e.onChange({...e.value,theme:n})}),i.jsx("label",{className:"af-appearance__label",children:"Font size"}),i.jsx(ry,{value:e.value.font_scale,onChange:n=>e.onChange({...e.value,font_scale:n})}),i.jsx("label",{className:"af-appearance__label",children:"Header size"}),i.jsx(sy,{value:e.value.header_density,onChange:n=>e.onChange({...e.value,header_density:n})})]}),i.jsx("div",{className:"af-appearance__actions",children:i.jsx("button",{type:"button",className:"af-appearance__close",onClick:e.onClose,children:"Close"})})]})}):null}function My(){var n;if(typeof window>"u")return!1;const e=navigator;return!!((n=e==null?void 0:e.mediaDevices)!=null&&n.getUserMedia)&&typeof window.MediaRecorder=="function"}function Ly(){if(typeof window>"u")return!1;const e=window;return!!(e!=null&&e.AudioContext||e!=null&&e.webkitAudioContext)}function Py(){const e=window.MediaRecorder,n=a=>{var l;try{return!!((l=e==null?void 0:e.isTypeSupported)!=null&&l.call(e,a))}catch{return!1}},s=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus","audio/ogg"];for(const a of s)if(n(a))return a;return""}async function Ac(e,n){var l;const s=n.slice(0),a=(l=e.decodeAudioData)==null?void 0:l.bind(e);if(typeof a!="function")throw new Error("decodeAudioData not available");try{const u=a(s);if(u&&typeof u.then=="function")return await u}catch{}return await new Promise((u,d)=>{try{a(s,u,d)}catch(f){d(f)}})}function Oy(e){const n=new Uint8Array(e);if(n.length<44)return null;const s=u=>String.fromCharCode(n[u],n[u+1],n[u+2],n[u+3]);if(s(0)!=="RIFF"||s(8)!=="WAVE")return null;const a=new DataView(e);let l=12;for(;l+8<=n.length;){const u=s(l),d=a.getUint32(l+4,!0);if(u==="data")return n.slice(0,l+8);l+=8+d+d%2}return null}function Dy(e,n){const s=new Uint8Array(n),a=new Uint8Array(e.length+s.length);a.set(e,0),a.set(s,e.length);const l=new DataView(a.buffer);return l.setUint32(4,a.length-8,!0),l.setUint32(e.length-4,s.length,!0),a.buffer}function Fy(e){const n=w.useRef(e);n.current=e;const s=Y=>{var ee,pe;return(pe=(ee=n.current).on_error)==null?void 0:pe.call(ee,Y)},a=w.useMemo(()=>Ly()&&(typeof e.tts=="function"||typeof e.tts_stream=="function"),[e.tts,e.tts_stream]),l=w.useMemo(()=>My()&&typeof e.transcribe=="function",[e.transcribe]),[u,d]=w.useState({key:"",status:"idle"}),f=w.useRef(u),h=w.useCallback(Y=>{f.current=Y,d(ee=>ee.key===Y.key&&ee.status===Y.status?ee:Y)},[]),g=w.useRef(""),y=w.useRef(""),x=w.useRef(null),b=w.useRef(null),_=w.useRef(null),E=w.useRef(null),C=w.useRef(0),j=w.useRef(0),T=w.useRef(0),A=w.useRef([]),$=w.useRef(0),k=w.useRef(!0),P=w.useRef(!1),V=()=>{try{const Y=globalThis,ee=(Y==null?void 0:Y.AudioContext)||(Y==null?void 0:Y.webkitAudioContext);if(!ee)return null;if(!x.current){const we=new ee,Pe=we.createGain();Pe.gain.value=1,Pe.connect(we.destination),x.current=we,b.current=Pe}const pe=x.current,Oe=b.current;if(!pe||!Oe)return null;try{pe.state==="suspended"&&pe.resume()}catch{}return{ctx:pe,gain:Oe}}catch{return null}},H=w.useCallback(()=>{const Y=_.current;if(_.current=null,!!Y){try{Y.onended=null}catch{}try{Y.stop()}catch{}try{Y.disconnect()}catch{}}},[]),L=w.useCallback(()=>{H(),T.current+=1,A.current=[],$.current=0,k.current=!0,P.current=!1,y.current="",g.current="",E.current=null,C.current=0,j.current=0,h({key:"",status:"idle"})},[H,h]);w.useEffect(()=>()=>{var Y,ee;L();try{(Y=b.current)==null||Y.disconnect()}catch{}try{(ee=x.current)==null||ee.close()}catch{}x.current=null,b.current=null,E.current=null},[]);const de=async(Y,ee,pe)=>{const Oe=T.current,we=V();if(!we)throw new Error("TTS playback is not supported in this browser");const{ctx:Pe,gain:Be}=we;try{Pe.state==="suspended"&&await Pe.resume()}catch{}if(Oe!==T.current)return;H();const rt=Pe.createBufferSource();rt.buffer=ee,rt.connect(Be);const K=Number.isFinite(Number(ee.duration))?Number(ee.duration):0,me=Math.max(0,Math.min(Number(pe||0),K>0?Math.max(0,K-.01):0));j.current=Pe.currentTime-me,C.current=me,_.current=rt,g.current=Y,rt.onended=()=>{_.current===rt&&(_.current=null,C.current=0,j.current=0,g.current="",h({key:"",status:"idle"}))},rt.start(0,me),h({key:Y,status:"playing"})},re=(Y,ee)=>{if(ee!==T.current)return;const pe=V();if(!pe)return;const Oe=A.current,we=$.current;if(we>=Oe.length){k.current&&(g.current="",C.current=0,j.current=0,h({key:"",status:"idle"}));return}const Pe=Oe[we],{ctx:Be,gain:rt}=pe;H();const K=Be.createBufferSource();K.buffer=Pe,K.connect(rt);const me=Number.isFinite(Number(Pe.duration))?Number(Pe.duration):0,De=Math.max(0,Math.min(Number(C.current||0),me>0?Math.max(0,me-.01):0));j.current=Be.currentTime-De,_.current=K,g.current=Y,K.onended=()=>{ee===T.current&&_.current===K&&(_.current=null,$.current=we+1,C.current=0,re(Y,ee))};try{Be.state==="suspended"&&Be.resume()}catch{}K.start(0,De),h({key:Y,status:"playing"})},Q=async(Y,ee,pe)=>{const Oe=V();if(!Oe){s==null||s("TTS playback is not supported in this browser.");return}H();const we=++T.current;A.current=[],$.current=0,k.current=!1,P.current=!1,E.current=null,C.current=0,j.current=0,g.current=Y,y.current=Y,h({key:Y,status:"loading"}),s==null||s("");let Pe=null;try{for await(const Be of pe(ee)){if(we!==T.current)return;let rt;try{rt=await Ac(Oe.ctx,Be),Pe||(Pe=Oy(Be))}catch{if(!Pe)continue;try{rt=await Ac(Oe.ctx,Dy(Pe,Be))}catch{continue}}if(we!==T.current)return;A.current.push(rt),!_.current&&!P.current&&(y.current="",re(Y,we))}if(we!==T.current)return;if(k.current=!0,A.current.length===0){s==null||s("TTS stream produced no audio."),L();return}!_.current&&!P.current&&re(Y,we)}catch(Be){if(we!==T.current)return;s==null||s(String((Be==null?void 0:Be.message)||Be||"TTS stream failed")),L()}},U=w.useCallback(async(Y,ee)=>{const pe=String(Y||"").trim(),Oe=String(ee||"").trim();if(!pe||!Oe)return;const we=n.current.tts,Pe=n.current.tts_stream;if(typeof we!="function"&&typeof Pe!="function"){s==null||s("TTS is not available.");return}const Be=V();if(!Be){s==null||s("TTS playback is not supported in this browser.");return}const rt=f.current,K=rt.key===pe;if(K&&rt.status==="playing"){if(_.current){const De=Math.max(0,Be.ctx.currentTime-Number(j.current||0));C.current=De}else C.current=0;P.current=!0,H(),h({key:pe,status:"paused"});return}if(K&&rt.status==="paused"){if(A.current.length>0){s==null||s(""),P.current=!1,h({key:pe,status:"playing"}),re(pe,T.current);return}const De=E.current;if(De){s==null||s(""),P.current=!1;try{await de(pe,De,C.current)}catch(Ke){s==null||s(String((Ke==null?void 0:Ke.message)||Ke||"TTS play failed")),h({key:"",status:"idle"})}return}}if(K&&rt.status==="loading")return;if(typeof Pe=="function"){await Q(pe,Oe,Pe);return}H(),T.current+=1;const me=T.current;A.current=[],$.current=0,k.current=!0,P.current=!1,E.current=null,C.current=0,j.current=0,g.current=pe,y.current=pe,h({key:pe,status:"loading"}),s==null||s("");try{const De=await we(Oe);if(y.current!==pe||T.current!==me)return;const Ke=await Ac(Be.ctx,De);if(y.current!==pe||T.current!==me)return;E.current=Ke,C.current=0,await de(pe,Ke,0)}catch(De){if(T.current!==me)return;y.current===pe&&(y.current="",g.current="",h({key:"",status:"idle"})),s==null||s(String((De==null?void 0:De.message)||De||"TTS failed"))}},[]),[J,fe]=w.useState(!1),[ce,ye]=w.useState(!1),ve=w.useRef(!1),q=w.useRef(l);q.current=l;const oe=w.useCallback(Y=>{ve.current=Y,fe(ee=>ee===Y?ee:Y)},[]),G=w.useRef(!1),N=w.useRef(null),B=w.useRef(null),F=w.useRef([]),W=w.useRef(""),ie=w.useRef(0),le=w.useRef(!1);function he(){var Y,ee;try{(ee=(Y=N.current)==null?void 0:Y.getTracks)==null||ee.call(Y).forEach(pe=>{try{pe.stop()}catch{}})}catch{}N.current=null}const X=w.useCallback(()=>{ie.current+=1,le.current=!1;const Y=B.current;if(Y){Y.onstop=null,Y.ondataavailable=null,Y.onerror=null;try{Y.stop()}catch{}}B.current=null,he(),oe(!1),G.current=!1,ye(!1),F.current=[]},[oe]);w.useEffect(()=>()=>X(),[X]);async function $e(Y,ee){var we,Pe;if(s==null||s(""),!Y||!Y.size||G.current)return;const pe=n.current.transcribe;if(typeof pe!="function"){s==null||s("Transcription is not available.");return}G.current=!0;const Oe=ie.current;ye(!0);try{const Be=String(await pe(Y,ee)||"").trim();Oe===ie.current&&Be&&((Pe=(we=n.current).on_transcript)==null||Pe.call(we,Be))}catch(Be){Oe===ie.current&&(s==null||s(String((Be==null?void 0:Be.message)||Be||"Transcription failed")))}finally{Oe===ie.current&&(G.current=!1,ye(!1))}}const We=w.useCallback(async()=>{if(s==null||s(""),!q.current){s==null||s("Voice recording is not supported in this browser (MediaRecorder/getUserMedia unavailable).");return}if(G.current||le.current||ve.current||B.current)return;F.current=[];const Y=ie.current;le.current=!0;try{const ee=await navigator.mediaDevices.getUserMedia({audio:!0});if(Y!==ie.current){ee.getTracks().forEach(we=>we.stop());return}N.current=ee;const pe=Py();W.current=pe;const Oe=pe?new MediaRecorder(ee,{mimeType:pe}):new MediaRecorder(ee);B.current=Oe,Oe.ondataavailable=we=>{if(Y===ie.current)try{we!=null&&we.data&&F.current.push(we.data)}catch{}},Oe.onerror=()=>{Y===ie.current&&(s==null||s("Recording failed."))},Oe.onstop=()=>{if(Y===ie.current){oe(!1),he(),B.current=null;try{const we=new Blob(F.current,{type:W.current||""});$e(we,W.current)}catch(we){s==null||s(String((we==null?void 0:we.message)||we||"Failed to build recording"))}}},Oe.start(),oe(!0)}catch(ee){if(Y!==ie.current)return;he(),B.current=null,oe(!1);const pe=String((ee==null?void 0:ee.message)||ee||"Failed to access microphone");s==null||s(pe.toLowerCase().includes("permission")?`Microphone permission denied: ${pe}`:pe)}finally{Y===ie.current&&(le.current=!1)}},[]),ke=w.useCallback(()=>{const Y=B.current;if(!(!ve.current||!Y)){oe(!1);try{Y.stop()}catch(ee){s==null||s(String((ee==null?void 0:ee.message)||ee||"Failed to stop recording"))}}},[]);return w.useEffect(()=>{if(!J)return;const Y=()=>ke();return window.addEventListener("pointerup",Y),window.addEventListener("pointercancel",Y),()=>{window.removeEventListener("pointerup",Y),window.removeEventListener("pointercancel",Y)}},[J]),{tts_supported:a,tts_playback:u,toggle_tts:U,stop_tts:L,voice_ptt_supported:l,voice_ptt_recording:J,voice_ptt_busy:ce,start_voice_ptt_recording:We,stop_voice_ptt_recording:ke,cancel_voice_ptt_recording:X}}const To=e=>Array.isArray(e)?e.map(n=>typeof n=="string"?n:(n==null?void 0:n.id)||(n==null?void 0:n.name)).filter(Boolean):[];function zy({value:e,onChange:n,fetchCatalog:s}){var j,T,A,$;const a=w.useRef(s);a.current=s;const[l,u]=w.useState({}),[d,f]=w.useState(""),[h,g]=w.useState(!1);w.useEffect(()=>{let k=!0;return g(!0),u({}),f(""),a.current(e.provider,e.model).then(P=>{k&&(u(P),f(P.error?String(P.error):""))}).catch(P=>{k&&f(String((P==null?void 0:P.message)||P))}).finally(()=>{k&&g(!1)}),()=>{k=!1}},[e.provider,e.model]);const y=Array.isArray(l.items)?l.items:[...Array.isArray(l.profiles)?l.profiles.map(k=>({...k,voice_kind:"profile"})):[],...Array.isArray(l.voices)?l.voices.map(k=>({...k,voice_kind:"voice"})):[]],x=k=>JSON.stringify([k.provider||"",k.model||"",k.voice_kind==="profile"?"profile":"voice",k.id]),b=y.find(k=>k.id===(e.profile||e.voice)&&k.voice_kind==="profile"==!!e.profile&&(!e.provider||!k.provider||k.provider===e.provider)&&(!e.model||!k.model||k.model===e.model)),_=b?x(b):e.profile||e.voice?JSON.stringify([e.provider||"",e.model||"",e.profile?"profile":"voice",e.profile||e.voice]):"",E=y.filter(k=>(k==null?void 0:k.id)&&(!e.provider||!k.provider||k.provider===e.provider)).map(k=>({value:x(k),label:`${k.label||k.name||k.id}${!e.provider&&k.provider?` · ${k.provider}`:""}`}));_&&!E.some(k=>k.value===_)&&E.unshift({value:_,label:`${e.profile||e.voice} (saved)`});const C=k=>n({...e,...k});return i.jsxs("div",{className:"af-voice-settings",children:[i.jsx("p",{children:"Speech is generated by your authenticated Gateway. Leave routing and voice unset to use its defaults."}),i.jsx(uu,{value:{provider:e.provider||"",model:e.model||""},onChange:k=>n({...e,...k,voice:"",profile:""}),fetchProviders:async()=>{const k=await a.current();if(k.error&&!To(k.tts_providers||k.providers).length)throw new Error(k.error);return To(k.tts_providers||k.providers).map(P=>({name:P}))},fetchModels:async k=>{var V;const P=await a.current(k);return To(((V=P.tts_models_by_provider)==null?void 0:V[k])||P.tts_models||P.models)},providerLabel:"Speech provider",modelLabel:"Speech model"}),i.jsxs("label",{children:["Voice / profile",i.jsx(Xr,{ariaLabel:"AI voice",placeholder:"Gateway / provider default",value:_,disabled:h,options:[{value:"",label:"Gateway / provider default"},...E],onChange:k=>{if(!k){C({voice:"",profile:""});return}const[P,V,H,L]=JSON.parse(k);C({provider:P||e.provider||"",model:V||(P&&P!==e.provider?"":e.model)||"",voice:H==="voice"?L:"",profile:H==="profile"?L:""})}})]}),h?i.jsx("p",{role:"status",children:"Loading available voices…"}):null,d?i.jsxs("p",{role:"alert",children:["Voice discovery unavailable: ",d,". Your saved choice is preserved."]}):null,i.jsxs("label",{children:["Speaking speed",i.jsxs("select",{"aria-label":"Speech speed",value:e.speed??"",onChange:k=>C({speed:k.target.value?Number(k.target.value):void 0}),children:[i.jsx("option",{value:"",children:"Gateway default"}),[.5,.75,1,1.25,1.5,2].map(k=>i.jsxs("option",{value:k,children:[k,"×"]},k))]})]}),(T=(j=l.controls)==null?void 0:j.quality_preset)!=null&&T.supported?i.jsxs("label",{children:["Quality",i.jsxs("select",{"aria-label":"Speech quality",value:e.quality_preset||"",onChange:k=>C({quality_preset:k.target.value}),children:[i.jsx("option",{value:"",children:"Gateway default"}),To(l.controls.quality_preset.values).map(k=>i.jsx("option",{value:k,children:k},k))]})]}):null,($=(A=l.controls)==null?void 0:A.instructions)!=null&&$.supported?i.jsxs("label",{children:["Delivery instructions",i.jsx("textarea",{"aria-label":"Voice delivery instructions",rows:3,placeholder:"For example: calm, clear, and conversational",value:e.instructions||"",onChange:k=>C({instructions:k.target.value})})]}):null,i.jsx("button",{type:"button",onClick:()=>n({}),children:"Reset to Gateway defaults"})]})}const Tc=Se("automations"),Wy=Se("trigger-sources"),Uy=Se("me/email");class Zf extends Error{constructor(n){super(n.message),this.name="AutomationApiError",this.status=n.status,this.code=n.code,n.field!==void 0&&(this.field=n.field),n.command_id!==void 0&&(this.command_id=n.command_id)}}function By(e,n){const s=n&&typeof n=="object"?n.detail:void 0;if(s&&typeof s=="object"&&!Array.isArray(s)){const a=s;if(typeof a.reason_code=="string"&&a.reason_code&&typeof a.message=="string"){const l={status:e,code:a.reason_code,message:a.message};return typeof a.field=="string"&&(l.field=a.field),typeof a.command_id=="string"&&(l.command_id=a.command_id),l}}return{status:e,code:"invalid_response",message:`The gateway answered HTTP ${e} without an automation error envelope.`}}function Rc(e){const n=new URLSearchParams;for(const[a,l]of Object.entries(e))l!==void 0&&n.set(a,String(l));const s=n.toString();return s?`?${s}`:""}function Vy(){const e=globalThis.crypto;if(!e||typeof e.randomUUID!="function")throw new Error("automations client: crypto.randomUUID is unavailable; pass options.newId");return e.randomUUID()}function Gy(e){const n=e.newId??Vy,s=l=>`${Tc}/${encodeURIComponent(l)}`;async function a(l,u,d){const f={accept:"application/json",...e.headers?e.headers():{}},h={method:l,headers:f};d!==void 0&&(f["content-type"]="application/json",h.body=JSON.stringify(d));const g=await e.fetch(Xe(e.baseUrl,u),h),y=await g.text();let x,b=!1;if(y)try{x=JSON.parse(y),b=!0}catch{b=!1}if(!g.ok)throw new Zf(By(g.status,x));if(!b||x===null||typeof x!="object")throw new Zf({status:g.status,code:"invalid_response",message:`The gateway answered ${l} ${u} with a body that is not a JSON object.`});return x}return{listAutomations:(l={})=>a("GET",`${Tc}${Rc({status:l.status,cursor:l.cursor,limit:l.limit})}`),getAutomation:l=>a("GET",s(l)),createAutomation:l=>a("POST",Tc,l),reviseAutomation:(l,u)=>a("PATCH",s(l),{command_id:u.command_id??n(),...u.expected_revision!==void 0?{expected_revision:u.expected_revision}:{},changes:u.changes}),sendAutomationCommand:(l,u)=>a("POST",`${s(l)}/commands`,{command_id:u.command_id??n(),type:u.type,...u.payload!==void 0?{payload:u.payload}:{}}),listOccurrences:(l,u={})=>a("GET",`${s(l)}/occurrences${Rc({cursor:u.cursor,limit:u.limit})}`),discuss:(l,u)=>a("POST",`${s(l)}/discuss`,{request_id:u.request_id??n(),occurrence_index:u.occurrence_index,prompt:u.prompt}),markSeen:(l,u)=>a("POST",`${s(l)}/seen`,{attention_cursor:u}),listAttention:(l,u={})=>a("GET",`${s(l)}/attention${Rc({cursor:u.cursor,limit:u.limit})}`),listTriggerSources:()=>a("GET",Wy),getMyEmail:()=>a("GET",Uy)}}const Hy={pause:"Pause",resume:"Resume",run_now:"Run now",stop_current:"Stop current",revise:"Edit",archive:"Archive",discuss:"Discuss"},Ky={pause:`Stop scheduled runs until you resume.
41
+ A run in progress, with its retries, finishes. Run now still works.`,resume:`Restart the schedule at its next time after now.
42
+ Times missed while paused are skipped; resuming does not run it now.`,run_now:`Run it once now, without waiting for the schedule.
43
+ The schedule does not move: the next scheduled run keeps its time, or starts right after this run if its time comes first.
44
+ Does not count toward a run limit. Works while paused; it stays paused.
45
+ Not available while a run is in progress.`,stop_current:`Cancel the run in progress, or its pending retry.
46
+ It ends as cancelled, with no failure notice. The schedule continues.`,revise:`Change the task, schedule or settings.
47
+ 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.
48
+ A run in progress finishes; the history stays readable.`,discuss:`Talk about the results in a separate conversation, seeded with the runs up to this one.
49
+ It has its own workspace (the automation's files are read-only) and never changes the automation.`},Jy="Next scheduled run: {time}.",Qy="Growing context: later runs see this run in their history.",Yy={run_now:{name:"playCircle"}},Xy={trigger_label:"When an email arrives",not_set_up:"Email isn't set up — 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 me the result",notify_hint:"When a run notifies you, or fails for good, the notice is also emailed to you.",recipients_legend:"May send email without asking to",recipients_self:"Only me (default)",recipients_list:"Me and these addresses",recipients_hint:"Sending to anyone else waits for your approval. Your recipient policy in My email still applies."},Qh={labels:Hy,hints:Ky,run_now_next_run_line:Jy,run_now_growing_line:Qy,icons:Yy,email:Xy},Zy=/^([1-9][0-9]*)([smhd])$/,qy={s:["second","seconds"],m:["minute","minutes"],h:["hour","hours"],d:["day","days"]};function xa(e){if(typeof e!="string")return null;const n=Zy.exec(e);return n?{amount:Number(n[1]),unit:n[2]}:null}function Yh(e){const n=xa(e);if(!n)return`every ${e}`;const[s,a]=qy[n.unit];return n.amount===1?`every ${s}`:`every ${n.amount} ${a}`}function wr(e){if(!e)return"";const n=Date.parse(e);if(Number.isNaN(n))return e;const s=new Date(n).toISOString(),a=s.slice(17,19);return`${s.slice(0,10)} ${s.slice(11,16)}${a==="00"?"":`:${a}`} UTC`}function Xh(e){const n=e;if(typeof n.every!="string")return n.start_at?`once at ${wr(n.start_at)}`:"once, now";const s=[`${Yh(n.every)} (UTC)`];return typeof n.count=="number"&&s.push(`${n.count} ${n.count===1?"run":"runs"} max`),typeof n.until=="string"&&s.push(`until ${wr(n.until)}`),s.join(" · ")}function du(e){return e.source_id==="schedule"&&e.source_version===1?Xh(e.config):e.source_id==="manual"&&e.source_version===1?"manual runs only":Qo(e)?ip(e.config):`${e.source_id}@${e.source_version}`}function Zh(e){return e==="growing"?"Growing — each run sees the previous runs":"Independent — each run starts fresh"}const ew={active:"Active",paused:"Paused",completed:"Completed",failed:"Failed",archived:"Archived"},ze=Qh.email,qh="email.received",ep=1,tw="1h",nw="60s",tp=60,fu=100,Xc=1e3,qf=200,eh=200,th=50;function Qo(e){return!!e&&e.source_id===qh&&e.source_version===ep}function hu(e){return!!e&&e.effective_enabled===!0}function np(e){const n=[];for(const s of String(e??"").split(/[\s,;]+/)){const a=s.trim().toLowerCase();a&&!n.includes(a)&&n.push(a)}return n}const rw=/[\s<>,;:"()[\]]/;function Zc(e){const n=e.trim().toLowerCase(),s=n.indexOf("@");return s<=0||s===n.length-1?!1:!n.slice(s+1).includes("@")&&!rw.test(n)}function sw(e){const n=e.trim().toLowerCase();return!!n&&!n.includes("@")&&n.includes(".")&&!n.startsWith(".")&&!n.endsWith(".")&&!/[\s<>,;:"()[\]/*]/.test(n)}const pu={usesModel:!0,every:null,maxBatch:null,fromIn:"",fromDomainIn:"",toIn:"",subjectContains:"",hasAttachment:"any"};function mu(e){return e?tw:nw}function rp(e){const n=xa(e);return n?n.amount*{s:1,m:60,h:3600,d:86400}[n.unit]:null}function Ic(e,n,s,a,l){const u=np(e);if(!u.length)return null;const d=u.filter(f=>!s(f));return d.length&&l.push(`${n}: ${d.join(", ")} ${d.length===1?"is not":"are not"} ${a}.`),u.length>qf&&l.push(`${n}: at most ${qf} entries.`),u}function sp(e){const n=[],s={uses_model:e.usesModel};e.every===null?s.every=mu(e.usesModel):!Number.isInteger(e.every.amount)||e.every.amount<1?n.push("The check interval must be a whole number of at least 1."):s.every=`${e.every.amount}${e.every.unit}`,s.every!==void 0&&(rp(s.every)??0)<tp&&n.push("The check interval is at least 60 seconds."),e.maxBatch===null?s.max_batch=fu:!Number.isInteger(e.maxBatch)||e.maxBatch<1||e.maxBatch>Xc?n.push(`At most this many emails per run: a whole number from 1 to ${Xc}.`):s.max_batch=e.maxBatch;const a={},l=Ic(e.fromIn,ze.from_in,Zc,"an email address",n);l&&(a.from_in=l);const u=Ic(e.fromDomainIn,ze.from_domain_in,sw,"a domain like example.com",n);u&&(a.from_domain_in=u);const d=Ic(e.toIn,ze.to_in,Zc,"an email address",n);d&&(a.to_in=d);const f=e.subjectContains.trim();return f&&(f.length>eh||/[\r\n]/.test(f)?n.push(`${ze.subject_contains}: one line of at most ${eh} characters.`):a.subject_contains=f),e.hasAttachment==="yes"?a.has_attachment=!0:e.hasAttachment==="no"&&(a.has_attachment=!1),Object.keys(a).length&&(s.filter=a),{config:s,errors:n}}function ip(e){const n=e,s=n.filter??{},a=["when an email arrives"],l=[...s.from_in??[],...s.from_domain_in??[]];l.length&&a.push(`from ${l.join(", ")}`),s.to_in&&s.to_in.length&&a.push(`to ${s.to_in.join(", ")}`),typeof s.subject_contains=="string"&&s.subject_contains&&a.push(`subject contains “${s.subject_contains}”`),s.has_attachment===!0&&a.push("with attachments"),s.has_attachment===!1&&a.push("without attachments");const u=typeof n.every=="string"?n.every:mu(n.uses_model!==!1);a.push(`checked ${Yh(u)}`);const d=typeof n.max_batch=="number"?n.max_batch:fu;return a.push(`up to ${d} per run`),a.join(" · ")}const qc={mode:"self",addresses:""};function eu(e){if(e.mode==="self")return{recipients:["self"],errors:[]};const n=[],s=np(e.addresses).filter(l=>l!=="self");s.length||n.push("Name at least one address the automation may email, or choose Only me.");const a=s.filter(l=>!Zc(l));return a.length&&n.push(`${ze.recipients_list}: ${a.join(", ")} ${a.length===1?"is not an email address":"are not email addresses"}.`),s.length+1>th&&n.push(`At most ${th-1} addresses.`),{recipients:["self",...s],errors:n}}function iw(e){const n=(e??[]).filter(s=>s!=="self");return n.length?{mode:"list",addresses:n.join(", ")}:{mode:"self",addresses:""}}function aw(e){const n=(e??["self"]).filter(s=>s!=="self");return n.length?`Me and ${n.join(", ")}`:"Only me"}function ap(e){return{channels:e?["console","email"]:["console"]}}function op(e){return!!e&&Array.isArray(e.channels)&&e.channels.includes("email")}function ow(e){return op(e)?"In the console and by email":"In the console"}const Qn={pause:"automation.pause",resume:"automation.resume",run_now:"automation.run_now",stop_current:"automation.stop_current",archive:"automation.archive"},lw=new Set(["running","waiting","backoff"]);function cw(e,n=[]){return e.current_occurrence!=null}function lp(e){const n=e.current_occurrence;if(!n)return null;const s=n.attempt>1?` (attempt ${n.attempt})`:"";return n.status==="backoff"?`Run #${n.index} waiting to retry (attempt ${n.attempt+1})`:n.status==="admitted"?`Run #${n.index} starting${s}`:`Run #${n.index} running${s}`}function cp(e,n){const s=Date.parse(e);if(Number.isNaN(s))return"";const a=Math.round((s-n)/6e4);if(a<=0)return"due now";if(a<60)return`in ${a} min`;const l=Math.floor(a/60);return l<24?`in ${l} h${a%60?` ${a%60} min`:""}`:`in ${Math.floor(l/24)} d${l%24?` ${l%24} h`:""}`}function Vo(e,n=[],s=!1){const a=new Set(e.capabilities),l=e.status,u=cw(e,n),d=(h,g,y)=>s?{enabled:!1,reason:"Working…"}:e.legacy?{enabled:!1,reason:"Legacy schedule: managed with its existing controls."}:a.has(h)?l==="archived"?{enabled:!1,reason:"Archived: history is kept, nothing runs."}:g?{enabled:!0}:{enabled:!1,reason:y}:{enabled:!1,reason:"Not permitted for this automation."},f=l==="active"||l==="paused";return{pause:d("pause",l==="active",l==="paused"?"Already paused.":"The automation has ended."),resume:d("resume",l==="paused",l==="active"?"Already running on schedule.":"The automation has ended."),run_now:d("run_now",f&&!u,u?"An occurrence is in progress.":"The automation has ended."),stop_current:d("stop_current",u,"Nothing is running."),revise:d("revise",!0,""),archive:d("archive",!0,""),discuss:s?{enabled:!1,reason:"Working…"}:e.legacy?{enabled:!1,reason:"Legacy schedule: discussion is not available."}:a.has("discuss")?{enabled:!0}:{enabled:!1,reason:"Discussion is not permitted for this automation."}}}function uw(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 dw(e){return[...e].sort((n,s)=>n.index-s.index).map(n=>{const s=uw(n),a=`${n.attempts} ${n.attempts===1?"attempt":"attempts"}`,l=s==="failed"?`Failed after ${a}`:s==="waiting"?"Waiting for you":s==="notified"?"Notified":s==="running"?"Running":null,u=n.status==="completed"&&n.attempts>1?`completed after ${a}`:n.status;return{row:n,tone:s,notable:s==="failed"||s==="waiting"||s==="notified",badge:l,statusText:u,canDiscuss:!lw.has(n.status)}})}function fw(e){const n=e.attention.items;return n.length?n[n.length-1].cursor:null}function up(e){const n=e.attention,s=[];return n.unseen_count>0&&s.push(`${n.unseen_count} unseen`),n.pending_waits>0&&s.push(`${n.pending_waits} waiting for you`),s.length?s.join(" · "):"nothing new"}const hw={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 gu(e){return{title:hw[e.code]??`The gateway refused the request (${e.code}).`,detail:e.message}}function yu(e){if(!e||typeof e!="object")return!1;const n=e;return typeof n.status=="number"&&typeof n.code=="string"&&typeof n.message=="string"}function dp(e,n){const s=e.trigger,a=s.source_id==="schedule"||Qo(s)?s.config.every:void 0,l=n?n.target.input_data.prompt:void 0;return{title:e.title,every:typeof a=="string"?a:null,context:e.context_mode,prompt:typeof l=="string"?l:null,toolApproval:n?n.policy.tool_approval:null,notifyEmail:n?op(n.notify):null,emailRecipients:n?iw(n.policy.email_allowed_recipients):null}}function pw(e,n,s){const a=[],l={},u=n.title.trim();u?u.length>120?a.push("Title is at most 120 characters."):u!==e.title&&(l.title=u):a.push("Title is required.");const d=dp(e,s);if(n.every!==d.every&&n.every!==null){const f=Qo(e.trigger);if(!xa(n.every))a.push("Interval must be a whole number of minutes, hours or days.");else if(f&&(rp(n.every)??0)<tp)a.push("The check interval is at least 60 seconds.");else{const h={...e.trigger.config,every:n.every};f&&delete h.start_at,l.trigger={source_id:e.trigger.source_id,source_version:e.trigger.source_version,config:h}}}if(n.context!==e.context_mode&&(l.context={mode:n.context}),s&&typeof d.prompt=="string"&&typeof n.prompt=="string"&&n.prompt.trim()!==d.prompt.trim()){const f=n.prompt.trim();f?l.target={bundle_ref:s.target.bundle_ref,flow_id:s.target.flow_id,input_data:{...s.target.input_data,prompt:f}}:a.push("Task is required.")}if(s&&n.toolApproval&&n.toolApproval!==d.toolApproval&&(l.policy={tool_approval:n.toolApproval}),s&&typeof n.notifyEmail=="boolean"&&n.notifyEmail!==d.notifyEmail&&(l.notify=ap(n.notifyEmail)),s&&n.emailRecipients){const f=eu(n.emailRecipients),h=eu(d.emailRecipients??qc).recipients;f.errors.length?a.push(...f.errors):JSON.stringify(f.recipients)!==JSON.stringify(h)&&(l.policy={...l.policy??{},email_allowed_recipients:f.recipients})}return a.length?{errors:a}:Object.keys(l).length?l:null}const mw=[{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 Mc(e){if(!e)return null;const n=/^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})(:\d{2})?$/.exec(e.trim());if(!n)return null;const s=`${n[1]}T${n[2]}${n[3]??":00"}Z`;return Number.isNaN(Date.parse(s))?null:s}function gw(e){const n=e.trim().split(`
50
+ `)[0].trim();return n.length>120?`${n.slice(0,119)}…`:n}function fp(e){const n=[],s={};if(e.when.kind==="once"){const l=Mc(e.when.at);return l?s.start_at=l:n.push("Pick the date and time (UTC) to run once."),{config:s,errors:n}}const a=e.when.amount;if(!Number.isInteger(a)||a<1?n.push("The interval must be a whole number of at least 1."):s.every=`${a}${e.when.unit}`,e.startAt){const l=Mc(e.startAt);l?s.start_at=l:n.push("First run must be a date and time (UTC).")}if(e.count!==void 0&&(!Number.isInteger(e.count)||e.count<1?n.push("Maximum runs must be a whole number of at least 1."):s.count=e.count),e.until){const l=Mc(e.until);l?s.until=l:n.push("Stop at must be a date and time (UTC).")}return{config:s,errors:n}}function yw(e){if(e.trigger==="email"){const l=sp(e.email??pu);return l.errors.length?"":ip(l.config)}const{config:n,errors:s}=fp(e);if(s.length)return"";const a=Xh(n);return e.when.kind==="once"?a:`${a}, first run ${n.start_at?`at ${wr(n.start_at)}`:"now"}`}function ww(e,n){const s=[];n.target||s.push("Choose what to run.");const a=e.prompt.trim();a||s.push("Write the task to run.");const l=(e.title??"").trim()||gw(a);l.length>120&&s.push("Title is at most 120 characters.");const u=e.trigger==="email",d=u?sp(e.email??pu):fp(e);s.push(...d.errors);const f=e.emailRecipients&&e.emailRecipients.mode==="list"?eu(e.emailRecipients):null;if(f&&s.push(...f.errors),s.length||!n.target)return{ok:!1,errors:s};const h={...n.target,input_data:{...n.target.input_data??{},prompt:a}},g={request_id:n.requestId,title:l,target:h,trigger:u?{source_id:qh,source_version:ep,config:d.config}:{source_id:"schedule",source_version:1,config:d.config},context:{mode:e.context},policy:{tool_approval:e.toolApproval??"auto",...f?{email_allowed_recipients:f.recipients}:{}}};return e.notifyEmail===!0&&(g.notify=ap(!0)),{ok:!0,body:g}}const vw="Tools run without asking (you approve them now by creating this automation)";function _w(e){if(e.kind!=="tool_approval"||!Array.isArray(e.details))return null;const n=[];for(const s of e.details){if(!s||typeof s!="object"||Array.isArray(s))return null;const a=s;if(typeof a.name!="string"||!a.arguments||typeof a.arguments!="object"||Array.isArray(a.arguments)||a.call_id!==void 0&&typeof a.call_id!="string")return null;n.push({name:a.name,arguments:a.arguments,...typeof a.call_id=="string"?{call_id:a.call_id}:{}})}return n}function xw(e){const n=e.trim();if(!n)return{ok:!1,error:"Enter a JSON payload."};try{return{ok:!0,payload:JSON.parse(n)}}catch(s){return{ok:!1,error:`The payload is not valid JSON (${s instanceof Error?s.message:String(s)}).`}}}const hp={ask_user:"Question for you",tool_approval:"Approval needed",event:"Waiting for an event"};class pp{constructor(n){this.mint=n,this.open=new Map}idFor(n){let s=this.open.get(n);return s===void 0&&(s=this.mint(),this.open.set(n,s)),s}settle(n,s){(s.ok||bw(s.error))&&this.open.delete(n)}}function bw(e){return yu(e)&&e.status>0&&e.code!=="invalid_response"}function mp(){const e=globalThis.crypto;if(!e||typeof e.randomUUID!="function")throw new Error("crypto.randomUUID is unavailable; pass newId");return e.randomUUID()}class kw{constructor(){this.acked=null,this.inflight=null,this.failedKey=null,this.failedToken=void 0}next(n,s){return!n||n===this.acked||n===this.inflight||n===this.failedKey&&s===this.failedToken?null:(this.inflight=n,n)}succeeded(n){this.inflight===n&&(this.inflight=null),this.acked=n,this.failedKey=null}failed(n,s){this.inflight===n&&(this.inflight=null),this.failedKey=n,this.failedToken=s}get acknowledged(){return this.acked}}function nh(e,n){if(!e)return null;for(const s of n){const a=e.querySelector(s);if(a&&a.disabled!==!0&&typeof a.focus=="function")return a}return null}function tu(e){if(hu(e.status))return null;const n=ze.not_set_up,s=ze.open_my_email,a=n.endsWith(s)?n.slice(0,n.length-s.length):`${n} `,l=e.status&&e.status.admin_disabled&&typeof e.status.admin_disabled.cause=="string"?e.status.admin_disabled.cause:"";return i.jsxs("p",{className:"af-auto__hint af-email__notice",role:"note","data-email-setup":"missing",children:[a,e.onOpenMyEmail?i.jsx("button",{type:"button",className:"af-auto__linkbtn","data-action":"open-my-email",onClick:e.onOpenMyEmail,children:s}):s,l?i.jsxs("span",{className:"af-email__cause",children:[" (",l,")"]}):null]})}function jw(e){const n=e.value,s=f=>e.onChange({...n,...f}),a=f=>`${e.idBase}-email-${f}`,l=xa(mu(n.usesModel)),u=n.every??(l&&l.unit==="s"?{amount:Math.max(1,Math.round(l.amount/60)),unit:"m"}:{amount:l?l.amount:1,unit:l?l.unit:"h"}),d=e.disabled===!0;return i.jsxs("div",{className:"af-email__trigger","data-field":"email-trigger",children:[i.jsxs("div",{className:"af-auto__row",children:[i.jsx("span",{children:ze.every_label}),i.jsx("input",{type:"number",min:1,step:1,value:String(u.amount),disabled:d,"aria-label":"Check interval amount",name:"email_every_amount",onChange:f=>s({every:{amount:Number(f.target.value),unit:u.unit}})}),i.jsxs("select",{value:u.unit,disabled:d,"aria-label":"Check interval unit",name:"email_every_unit",onChange:f=>s({every:{amount:u.amount,unit:f.target.value}}),children:[i.jsx("option",{value:"m",children:"minutes"}),i.jsx("option",{value:"h",children:"hours"}),i.jsx("option",{value:"d",children:"days"})]})]}),i.jsx("p",{className:"af-auto__hint","data-email-rule":"interval",children:ze.interval_rule}),i.jsxs("label",{className:"af-auto__field",htmlFor:a("batch"),children:[i.jsx("span",{children:ze.max_batch_label}),i.jsx("input",{id:a("batch"),name:"email_max_batch",type:"number",min:1,max:Xc,step:1,disabled:d,value:String(n.maxBatch??fu),onChange:f=>s({maxBatch:f.target.value.trim()===""?null:Number(f.target.value)})})]}),i.jsx("p",{className:"af-auto__hint",children:ze.max_batch_hint}),i.jsxs("fieldset",{className:"af-auto__field af-email__filters",disabled:d,children:[i.jsx("legend",{children:ze.filters_legend}),i.jsxs("label",{className:"af-auto__field",htmlFor:a("from"),children:[i.jsx("span",{children:ze.from_in}),i.jsx("input",{id:a("from"),name:"email_from_in",value:n.fromIn,spellCheck:!1,placeholder:"alice@example.com, billing@example.org",onChange:f=>s({fromIn:f.target.value})})]}),i.jsxs("label",{className:"af-auto__field",htmlFor:a("domain"),children:[i.jsx("span",{children:ze.from_domain_in}),i.jsx("input",{id:a("domain"),name:"email_from_domain_in",value:n.fromDomainIn,spellCheck:!1,placeholder:"example.com",onChange:f=>s({fromDomainIn:f.target.value})})]}),i.jsxs("label",{className:"af-auto__field",htmlFor:a("to"),children:[i.jsx("span",{children:ze.to_in}),i.jsx("input",{id:a("to"),name:"email_to_in",value:n.toIn,spellCheck:!1,onChange:f=>s({toIn:f.target.value})})]}),i.jsxs("label",{className:"af-auto__field",htmlFor:a("subject"),children:[i.jsx("span",{children:ze.subject_contains}),i.jsx("input",{id:a("subject"),name:"email_subject_contains",value:n.subjectContains,maxLength:200,onChange:f=>s({subjectContains:f.target.value})})]}),i.jsxs("label",{className:"af-auto__field",htmlFor:a("attach"),children:[i.jsx("span",{children:ze.has_attachment}),i.jsxs("select",{id:a("attach"),name:"email_has_attachment",value:n.hasAttachment,onChange:f=>s({hasAttachment:f.target.value}),children:[i.jsx("option",{value:"any",children:ze.has_attachment_any}),i.jsx("option",{value:"yes",children:ze.has_attachment_yes}),i.jsx("option",{value:"no",children:ze.has_attachment_no})]})]}),i.jsx("p",{className:"af-auto__hint",children:ze.list_hint})]})]})}function Sw(e){const n=a=>`${e.idBase}-email-${a}`,s=e.disabled===!0;return i.jsxs("div",{className:"af-email__options","data-field":"email-options",children:[i.jsxs("label",{className:"af-email__check",children:[i.jsx("input",{type:"checkbox",name:"notify_email",checked:e.notifyEmail,disabled:s,onChange:a=>e.onNotifyEmailChange(a.target.checked)})," ",ze.notify_label]}),i.jsx("p",{className:"af-auto__hint",children:ze.notify_hint}),i.jsxs("fieldset",{className:"af-auto__field",disabled:s,"data-field":"email-recipients",children:[i.jsx("legend",{children:ze.recipients_legend}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",name:n("rcpt"),value:"self",checked:e.recipients.mode==="self",onChange:()=>e.onRecipientsChange({...e.recipients,mode:"self"})})," ",ze.recipients_self]}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",name:n("rcpt"),value:"list",checked:e.recipients.mode==="list",onChange:()=>e.onRecipientsChange({...e.recipients,mode:"list"})})," ",ze.recipients_list]}),e.recipients.mode==="list"?i.jsx("textarea",{name:"email_recipient_list","aria-label":ze.recipients_list,rows:2,spellCheck:!1,value:e.recipients.addresses,placeholder:"colleague@example.com",onChange:a=>e.onRecipientsChange({mode:"list",addresses:a.target.value})}):null,i.jsx("p",{className:"af-auto__hint",children:ze.recipients_hint})]})]})}const Nw={active:"play",paused:"pause",completed:"check",failed:"error",archived:"archive"};function gp(e){const n=String(e.status),s=Nw[n];return i.jsxs("span",{className:`af-auto__status af-auto__status--${n}${e.className?` ${e.className}`:""}`,"data-state":n,children:[i.jsx("span",{className:"af-auto__status-word",children:ew[n]??n}),s?i.jsx(ae,{name:s,size:e.iconSize??11,className:"af-auto__status-icon"}):null]})}const rh="Discuss — fork at this occurrence (own workspace, automation files read-only)",Yo=e=>i.jsx("div",{className:"af-auto-text","data-unformatted":"true",children:e});function Cw(e){return yu(e)?e:{status:0,code:"client_error",message:e&&typeof e=="object"&&"message"in e?String(e.message):String(e)}}function sh(e){const n=e.path.split(new RegExp("(?<=[/\\\\_-])"));return i.jsx("code",{className:"af-auto__path-text",children:n.map((s,a)=>i.jsxs(wt.Fragment,{children:[s,a<n.length-1?i.jsx("wbr",{}):null]},a))})}function Ew(e,n){const s=e.trigger,a=n.find(l=>l.id===s.source_id&&l.version===s.source_version);return a?"available"in a&&a.available===!1?`Trigger source ${s.source_id}@${s.source_version} is unavailable${a.unavailable_reason?`: ${a.unavailable_reason}`:"."}`:null:`This gateway does not list the trigger source ${s.source_id}@${s.source_version}.`}function $w(e){const n=e.summary,s=lp(n),a=Ew(n,e.triggerSources),l=n.next_fire_at?`${wr(n.next_fire_at)} (${cp(n.next_fire_at,e.nowMs??Date.now())})`:n.status==="paused"?"none while paused":"none scheduled";return i.jsxs("header",{className:"af-auto__head",children:[i.jsxs("div",{className:"af-auto__titlebar",children:[i.jsx("h2",{className:"af-auto__title",id:e.titleId,tabIndex:-1,children:n.title}),i.jsx(gp,{status:n.status}),n.legacy?i.jsx("span",{className:"af-auto__legacy",children:"Legacy schedule"}):null]}),i.jsxs("dl",{className:"af-auto__facts",children:[i.jsx("dt",{children:"When"}),i.jsxs("dd",{"data-fact":"trigger",children:[du(n.trigger),a?i.jsxs("span",{className:"af-auto__warn",role:"note",children:[" ",a]}):null]}),i.jsx("dt",{children:"Context"}),i.jsx("dd",{"data-fact":"context",children:Zh(n.context_mode)}),s?i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Now"}),i.jsx("dd",{"data-fact":"current",className:"is-notable",children:s})]}):null,i.jsx("dt",{children:"Next run"}),i.jsx("dd",{"data-fact":"next",children:l}),i.jsx("dt",{children:"Runs"}),i.jsx("dd",{"data-fact":"count",children:n.occurrence_count}),n.workspace_root?i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Workspace"}),i.jsx("dd",{"data-fact":"workspace",className:"af-auto__workspace",children:e.onOpenWorkspace?i.jsxs("button",{type:"button",className:"af-auto__path","data-action":"open-workspace",title:`Browse the automation's folder
51
+ ${n.workspace_root}`,"aria-label":`Browse the automation's folder ${n.workspace_root}`,onClick:()=>{var u;return(u=e.onOpenWorkspace)==null?void 0:u.call(e,n.automation_id)},children:[i.jsx(ae,{name:"folder",size:14,className:"af-auto__path-icon"}),i.jsx(sh,{path:n.workspace_root})]}):i.jsxs("span",{className:"af-auto__path af-auto__path--static",children:[i.jsx(ae,{name:"folder",size:14,className:"af-auto__path-icon"}),i.jsx(sh,{path:n.workspace_root})]})})]}):null,i.jsx("dt",{children:"Attention"}),i.jsx("dd",{"data-fact":"attention",className:n.attention.unread||n.attention.pending_waits?"is-notable":void 0,children:up(n)}),n.revision!==null?i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Revision"}),i.jsx("dd",{"data-fact":"revision",children:n.revision})]}):null]})]})}function Aw(e){const n=e.definition,s=e.renderText??Yo,a=n.target.input_data.prompt,l=n.policy.retry,u=n.policy.tool_approval;return i.jsxs("details",{className:"af-auto__definition","data-definition-revision":n.revision,open:e.open,children:[i.jsxs("summary",{children:[i.jsx(ae,{name:"chevronRight",size:14,className:"af-auto__definition-chevron"}),i.jsx(ae,{name:"file",size:14}),i.jsx("span",{className:"af-auto__definition-title",children:"Definition"}),i.jsxs("span",{className:"af-auto__definition-meta",children:["revision ",n.revision]})]}),i.jsxs("dl",{className:"af-auto__facts",children:[i.jsx("dt",{children:"Target"}),i.jsx("dd",{"data-def":"target",children:i.jsx("code",{children:n.target.workflow_id})}),typeof a=="string"&&a?i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Task"}),i.jsx("dd",{"data-def":"prompt",children:s(a)})]}):null,i.jsx("dt",{children:"Trigger"}),i.jsxs("dd",{"data-def":"trigger",children:[n.trigger.source_id,"@",n.trigger.source_version," · ",du(n.trigger),i.jsx("pre",{className:"af-auto__json",children:JSON.stringify(n.trigger.config,null,2)})]}),i.jsx("dt",{children:"Context"}),i.jsx("dd",{"data-def":"context",children:Zh(n.context.mode)}),i.jsx("dt",{children:"Tools"}),i.jsx("dd",{"data-def":"tool_approval",children:u==="ask"?"Ask before each tool call (ask)":u==="auto"?"Run without asking (auto)":String(u)}),i.jsx("dt",{children:"Notify"}),i.jsx("dd",{"data-def":"notify",children:ow(n.notify)}),i.jsx("dt",{children:"May email"}),i.jsx("dd",{"data-def":"email_allowed_recipients",children:aw(n.policy.email_allowed_recipients)}),i.jsx("dt",{children:"Retries"}),i.jsxs("dd",{"data-def":"retry",children:[l.max_attempts," ",l.max_attempts===1?"attempt":"attempts",", backoff ",l.backoff.initial," ×",l.backoff.factor," up to ",l.backoff.max]}),i.jsx("dt",{children:"Revision"}),i.jsx("dd",{"data-def":"revision",children:n.revision})]})]})}const ba=Qh,yp=ba.labels,wp={pause:"pause",resume:"play",run_now:ba.icons.run_now.name,stop_current:"stop",revise:"edit",archive:"archive",discuss:"chat"},nu=ba.hints,Tw=ba.run_now_next_run_line,Rw=ba.run_now_growing_line;function Iw(e,n){const s=[nu[e]];return e==="run_now"&&n&&(n.next_fire_at&&s.push(Tw.replace("{time}",wr(n.next_fire_at))),n.context_mode==="growing"&&s.push(Rw)),s.join(`
52
+ `)}function Mw(e,n,s){const a=new Map;for(const d of n){const f=e[d];if(f.enabled)continue;const h=f.reason??"Not available now.";a.set(h,[...a.get(h)??[],d])}const l=[],u={};return[...a.entries()].forEach(([d,f],h)=>{const g=`${s}-why-${h}`;l.push({id:g,text:`${f.map(y=>yp[y]).join(", ")}: ${d}`});for(const y of f)u[y]=g}),{lines:l,describedBy:u}}function Bt(e){return i.jsxs(i.Fragment,{children:[i.jsx(ae,{name:e.icon,size:14,className:"af-auto__btn-icon"}),i.jsx("span",{children:e.label})]})}function Lw(e){const n=Vo(e.summary,e.occurrences,e.busy),s=[e.summary.status==="paused"?"resume":"pause","run_now","stop_current","revise","archive"],a=Mw(n,s,e.idBase??`af-auto-${e.summary.automation_id}`),l=(u,d,f)=>{const h=Iw(u,e.summary);return i.jsx("button",{type:"button",className:`af-auto__btn${f!=null&&f.danger?" af-auto__btn--danger":""}`,"data-action":(f==null?void 0:f.action)??u,disabled:!n[u].enabled,title:n[u].enabled?h:`${n[u].reason}
53
+ ${h}`,"aria-description":h,"aria-describedby":a.describedBy[u],"aria-pressed":f==null?void 0:f.pressed,onClick:d,children:i.jsx(Bt,{icon:wp[u],label:(f==null?void 0:f.label)??yp[u]})},u)};return i.jsxs("div",{className:"af-auto__controls-wrap",children:[i.jsxs("div",{className:"af-auto__actionbar",children:[i.jsxs("div",{className:"af-auto__controls",role:"toolbar","aria-label":"Automation controls",children:[e.summary.status==="paused"?l("resume",()=>e.onCommand(Qn.resume)):l("pause",()=>e.onCommand(Qn.pause)),l("run_now",()=>e.onCommand(Qn.run_now)),l("stop_current",()=>e.onCommand(Qn.stop_current)),l("revise",e.onToggleRevise,{pressed:e.reviseOpen,action:"edit"}),l("archive",e.onAskArchive,{danger:!0,label:"Archive…"})]}),i.jsx("span",{className:`af-auto__notice${e.notice?" af-auto__notice--on":""}`,role:"status",tabIndex:-1,children:e.notice?i.jsxs(i.Fragment,{children:[i.jsx(ae,{name:"check",size:13}),i.jsx("span",{className:"af-auto__notice-text",children:e.notice}),e.onDismissNotice?i.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:i.jsx(ae,{name:"x",size:12})}):null]}):null})]}),a.lines.length?i.jsxs("p",{className:"af-auto__reasons",children:[i.jsx(ae,{name:"info",size:12,className:"af-auto__reasons-icon"}),a.lines.map(u=>i.jsx("span",{id:u.id,children:u.text},u.id))]}):null,e.summary.status==="paused"&&n.run_now.enabled?i.jsx("p",{className:"af-auto__hint",children:"Paused: scheduled runs are skipped. Run now works and keeps it paused."}):null,e.confirmingArchive?i.jsxs("div",{className:"af-auto__confirm",role:"group","aria-label":"Confirm archive",children:[i.jsxs("p",{children:["Archive “",e.summary.title,"”? Its history stays readable; it will not run again. The current run, if any, finishes."]}),i.jsxs("div",{className:"af-auto__row",children:[i.jsx("button",{type:"button",className:"af-auto__btn af-auto__btn--danger","data-action":"archive-confirm",disabled:!n.archive.enabled,onClick:()=>e.onCommand(Qn.archive),children:i.jsx(Bt,{icon:"archive",label:"Archive"})}),i.jsx("button",{type:"button",className:"af-auto__btn","data-action":"archive-cancel",onClick:e.onCancelArchive,children:i.jsx(Bt,{icon:"x",label:"Keep it"})})]})]}):null]})}const ih=[["m","minutes"],["h","hours"],["d","days"]];function Pw(e,n){const s=j=>{const T=e.elements.namedItem(j);return T&&typeof T.value=="string"?T.value:null},a=s("every_amount"),l=s("every_unit"),u=a!==null&&l!==null?`${a.trim()}${l}`:n.every,d=e.elements.namedItem("context"),f=d&&(d.value==="growing"||d.value==="independent")?d.value:n.context,h=s("prompt"),g=e.elements.namedItem("tool_approval"),y=g&&(g.value==="auto"||g.value==="ask")?g.value:n.toolApproval??null,x=e.elements.namedItem("notify_email"),b=x&&typeof x.checked=="boolean"?x.checked:n.notifyEmail??null,_=e.elements.namedItem("email_recipients"),E=s("email_recipient_list"),C=_&&(_.value==="self"||_.value==="list")?{mode:_.value,addresses:E??""}:n.emailRecipients??null;return{title:s("title")??n.title,every:u,context:f,prompt:h??n.prompt??null,toolApproval:y,notifyEmail:b,emailRecipients:C}}function Ow(e){const n=dp(e.summary,e.definition),s=n.every?xa(n.every):null,a=s&&s.unit==="s"?[["s","seconds"],...ih]:ih,l=`af-auto-revise-${e.summary.automation_id}`,u=hu(e.emailStatus),d=Qo(e.summary.trigger);return i.jsxs("form",{className:"af-auto__revise","aria-labelledby":`${l}-heading`,onSubmit:f=>{f.preventDefault(),e.onSubmit(Pw(f.currentTarget,n))},onKeyDown:f=>{f.key==="Escape"&&(f.preventDefault(),e.onCancel())},children:[i.jsxs("h3",{className:"af-auto__form-title",id:`${l}-heading`,children:[i.jsx(ae,{name:"edit",size:14})," Edit automation"]}),i.jsxs("label",{className:"af-auto__field",htmlFor:`${l}-title`,children:[i.jsx("span",{children:"Title"}),i.jsx("input",{id:`${l}-title`,name:"title",defaultValue:n.title,maxLength:120,required:!0})]}),n.prompt!==null&&n.prompt!==void 0?i.jsxs("label",{className:"af-auto__field",htmlFor:`${l}-prompt`,children:[i.jsx("span",{children:"Task"}),i.jsx("textarea",{id:`${l}-prompt`,name:"prompt",defaultValue:n.prompt,rows:Math.min(10,Math.max(3,n.prompt.split(`
54
+ `).length+1)),required:!0})]}):null,s?i.jsxs("fieldset",{className:"af-auto__field",children:[i.jsx("legend",{children:d?ze.every_label:"Repeat every (UTC)"}),i.jsxs("div",{className:"af-auto__row",children:[i.jsx("input",{name:"every_amount",type:"number",min:1,step:1,defaultValue:s.amount,"aria-label":"Interval amount"}),i.jsx("select",{name:"every_unit",defaultValue:s.unit,"aria-label":"Interval unit",children:a.map(([f,h])=>i.jsx("option",{value:f,children:h},f))})]}),d?i.jsx("p",{className:"af-auto__hint","data-email-rule":"interval",children:ze.interval_rule}):null]}):i.jsx("p",{className:"af-auto__hint",children:"This trigger has no interval to change."}),i.jsxs("fieldset",{className:"af-auto__field",children:[i.jsx("legend",{children:"Context"}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",name:"context",value:"independent",defaultChecked:n.context==="independent"})," Independent — each run starts fresh"]}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",name:"context",value:"growing",defaultChecked:n.context==="growing"})," Growing — each run sees the previous runs"]})]}),n.toolApproval?i.jsxs("fieldset",{className:"af-auto__field",children:[i.jsx("legend",{children:"Tools"}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",name:"tool_approval",value:"auto",defaultChecked:n.toolApproval==="auto"})," Run without asking"]}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",name:"tool_approval",value:"ask",defaultChecked:n.toolApproval==="ask"})," Ask before each tool call"]})]}):null,n.notifyEmail!==null&&n.notifyEmail!==void 0&&n.emailRecipients?i.jsxs("fieldset",{className:"af-auto__field","data-field":"email",children:[i.jsx("legend",{children:"Email"}),u?null:i.jsx(tu,{status:e.emailStatus,onOpenMyEmail:e.onOpenMyEmail}),i.jsxs("label",{className:"af-email__check",children:[i.jsx("input",{type:"checkbox",name:"notify_email",defaultChecked:n.notifyEmail,disabled:!u&&!n.notifyEmail})," ",ze.notify_label]}),i.jsx("p",{className:"af-auto__hint",children:ze.notify_hint}),i.jsxs("fieldset",{className:"af-auto__field","data-field":"email-recipients",children:[i.jsx("legend",{children:ze.recipients_legend}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",name:"email_recipients",value:"self",defaultChecked:n.emailRecipients.mode==="self"})," ",ze.recipients_self]}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",name:"email_recipients",value:"list",defaultChecked:n.emailRecipients.mode==="list",disabled:!u&&n.emailRecipients.mode!=="list"})," ",ze.recipients_list]}),i.jsx("textarea",{name:"email_recipient_list","aria-label":ze.recipients_list,rows:2,spellCheck:!1,defaultValue:n.emailRecipients.addresses,disabled:!u&&n.emailRecipients.mode!=="list"}),i.jsx("p",{className:"af-auto__hint",children:ze.recipients_hint})]})]}):null,i.jsx("p",{className:"af-auto__hint",children:"Changes apply from the next run; a new interval never fires past ticks."}),e.errors.length?i.jsx("ul",{className:"af-auto__form-errors",role:"alert",children:e.errors.map(f=>i.jsx("li",{children:f},f))}):null,i.jsxs("div",{className:"af-auto__row",children:[i.jsx("button",{type:"submit",className:"af-auto__btn af-auto__btn--primary","data-action":"edit-save",disabled:e.busy,children:i.jsx(Bt,{icon:"check",label:"Save changes"})}),i.jsx("button",{type:"button",className:"af-auto__btn","data-action":"edit-cancel",onClick:e.onCancel,children:i.jsx(Bt,{icon:"x",label:"Cancel"})})]})]})}function ru(e,n){const s=e.elements.namedItem(n);return s&&typeof s.value=="string"?s.value.trim():""}function Dw(e){const n=e.wait,s=`${e.idBase}-${n.run_id}-${n.wait_key}-prompt`,a=d=>e.onAnswerWait(n.run_id,n.wait_key,d),l=e.renderText??Yo,u=d=>i.jsxs("div",{className:"af-auto-wait__prompt",id:s,children:[i.jsx("span",{className:"af-auto-wait__kind",children:hp[n.kind]??"Waiting"}),n.prompt?l(n.prompt):i.jsxs("span",{children:[" ",d]})]});if(n.kind==="tool_approval"){const d=_w(n);return i.jsxs("div",{className:"af-auto-wait af-auto-wait--tool_approval",role:"group","data-wait-key":n.wait_key,"data-wait-kind":n.kind,"aria-labelledby":s,children:[u("A tool call needs your approval."),d&&d.length?i.jsx("ul",{className:"af-auto-wait__calls","aria-label":"Tool calls to approve",children:d.map((f,h)=>i.jsxs("li",{"data-tool":f.name,children:[i.jsx("code",{className:"af-auto-wait__tool",children:f.name}),i.jsx("pre",{className:"af-auto-wait__args",children:JSON.stringify(f.arguments,null,2)})]},f.call_id??`${f.name}:${h}`))}):i.jsx("p",{className:"af-auto__hint",children:"The gateway did not list the tool calls; open the run to see them before approving."}),i.jsxs("div",{className:"af-auto__row",children:[i.jsx("button",{type:"button",className:"af-auto__btn af-auto__btn--primary","data-action":"wait-approve",disabled:e.busy,onClick:()=>a({approved:!0}),children:i.jsx(Bt,{icon:"check",label:"Approve"})}),i.jsx("button",{type:"button",className:"af-auto__btn af-auto__btn--danger","data-action":"wait-deny",disabled:e.busy,onClick:()=>a({approved:!1}),children:i.jsx(Bt,{icon:"x",label:"Deny"})})]})]})}return n.kind==="event"?i.jsxs("form",{className:"af-auto-wait af-auto-wait--event","data-wait-key":n.wait_key,"data-wait-kind":n.kind,"aria-labelledby":s,onSubmit:d=>{var h;d.preventDefault();const f=xw(ru(d.currentTarget,"payload"));f.ok?a({payload:f.payload}):(h=e.onWaitError)==null||h.call(e,f.error)},children:[u("The run waits for an event."),i.jsx("textarea",{name:"payload",rows:3,"aria-label":"Event payload (JSON)",placeholder:'{"key": "value"}',disabled:e.busy}),i.jsx("div",{className:"af-auto__row",children:i.jsx("button",{type:"submit",className:"af-auto__btn af-auto__btn--primary","data-action":"wait-send-event",disabled:e.busy,children:i.jsx(Bt,{icon:"send",label:"Send event"})})})]}):n.kind==="ask_user"?i.jsxs("form",{className:"af-auto-wait af-auto-wait--ask_user","data-wait-key":n.wait_key,"data-wait-kind":n.kind,"aria-labelledby":s,onSubmit:d=>{d.preventDefault();const f=ru(d.currentTarget,"response");f&&a({response:f})},children:[u("The run is waiting for your input."),n.choices&&n.choices.length?i.jsx("div",{className:"af-auto__row",role:"group","aria-label":"Choices",children:n.choices.map(d=>i.jsx("button",{type:"button",className:"af-auto__btn","data-action":"wait-choice",disabled:e.busy,onClick:()=>a({response:d}),children:d},d))}):null,i.jsxs("div",{className:"af-auto__row",children:[i.jsx("input",{name:"response","aria-label":"Your answer",placeholder:"Your answer",disabled:e.busy}),i.jsx("button",{type:"submit",className:"af-auto__btn af-auto__btn--primary","data-action":"wait-answer",disabled:e.busy,children:i.jsx(Bt,{icon:"send",label:"Answer"})})]})]}):i.jsxs("div",{className:"af-auto-wait",role:"group","data-wait-key":n.wait_key,"data-wait-kind":String(n.kind),"aria-labelledby":s,children:[u("The run is waiting."),i.jsxs("p",{className:"af-auto__hint",children:["This kind of wait (",String(n.kind),") cannot be answered here; open the run."]})]})}function Fw(e){const{row:n,tone:s,badge:a,statusText:l}=e.view,u=`af-auto-occ-${n.run_id}`,d=e.renderText??Yo,f=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.",g=(b,_)=>e.renderTurn?e.renderTurn({kind:b,role:b==="trigger"?"user":"assistant",text:_,index:n.index,runId:n.run_id}):d(_),y=e.renderTurn?" af-auto-turn--card":"",x=s==="failed"?n.failure?"No answer.":"No answer: the run failed.":s==="waiting"?"Waiting for your answer.":s==="running"?"Running…":"No answer.";return i.jsxs("li",{className:`af-auto-occ af-auto-occ--${s}`,"data-index":n.index,"data-tone":s,"aria-labelledby":`${u}-h`,children:[i.jsxs("div",{className:`af-auto-turn af-auto-turn--trigger${y}`,"data-turn":"trigger",children:[i.jsxs("div",{className:"af-auto-turn__meta",id:`${u}-h`,children:[i.jsxs("span",{className:"af-auto-turn__index",children:["#",n.index]})," · ",n.trigger.summary," · fired ",wr(n.fired_at)]}),i.jsx("div",{className:"af-auto-turn__text",children:g("trigger",n.user_turn)})]}),i.jsxs("div",{className:`af-auto-turn af-auto-turn--answer${y}`,"data-turn":"answer",children:[i.jsxs("div",{className:"af-auto-turn__meta",children:[a?i.jsx("span",{className:`af-auto-badge af-auto-badge--${s}`,children:a}):null,i.jsx("span",{className:"af-auto-turn__status",children:l}),n.finished_at?i.jsxs("span",{children:[" · ",wr(n.finished_at)]}):null]}),n.notify?i.jsxs("div",{className:"af-auto-notify","data-notify":"true",children:[i.jsx("strong",{children:n.notify.title}),n.notify.body?i.jsx("div",{className:"af-auto-notify__body",children:d(n.notify.body)}):null]}):null,n.failure?i.jsxs("div",{className:"af-auto-failure","data-failure":n.failure.reason_code,children:[i.jsx("strong",{children:n.failure.reason_code}),": ",n.failure.message," ",i.jsxs("span",{className:"af-auto-turn__muted",children:["(after ",n.failure.attempts," ",n.failure.attempts===1?"attempt":"attempts",")"]})]}):null,n.answer?i.jsx("div",{className:"af-auto-turn__text",children:g("answer",n.answer)}):i.jsx("div",{className:"af-auto-turn__empty",children:x}),n.artifacts.length?i.jsx("ul",{className:"af-auto-artifacts","aria-label":"Artifacts",children:n.artifacts.map(b=>i.jsxs("li",{children:[e.onOpenResource?i.jsxs("button",{type:"button",className:"af-auto__linkbtn","data-action":"open-artifact",onClick:()=>{var _;return(_=e.onOpenResource)==null?void 0:_.call(e,{kind:"artifact",url:b.url,name:b.name,mimeType:b.mime_type,runId:n.run_id})},children:[i.jsx(ae,{name:"file",size:13,className:"af-auto__btn-icon"})," ",b.name]}):i.jsx("span",{className:"af-auto-artifact__name",children:b.name})," ",i.jsx("span",{className:"af-auto-turn__muted",children:b.mime_type})]},b.artifact_id))}):null,n.waits.map(b=>i.jsx(Dw,{wait:b,busy:e.busy,idBase:u,onAnswerWait:e.onAnswerWait,onWaitError:e.onWaitError,renderText:e.renderText},`${b.run_id}:${b.wait_key}`))]}),i.jsxs("div",{className:"af-auto-occ__foot",children:[i.jsxs("details",{className:"af-auto-occ__details",children:[i.jsx("summary",{children:"Run details"}),i.jsxs("dl",{className:"af-auto__facts",children:[i.jsx("dt",{children:"Run"}),i.jsx("dd",{children:i.jsx("code",{children:n.run_id})}),i.jsx("dt",{children:"Attempts"}),i.jsx("dd",{children:n.attempts})]}),i.jsxs("div",{className:"af-auto__row",children:[i.jsx("button",{type:"button",className:"af-auto__btn","data-action":"open-run",onClick:()=>e.onOpenRun(n.run_id),children:i.jsx(Bt,{icon:"list",label:"Open run ledger"})}),e.onOpenResource?i.jsx("button",{type:"button",className:"af-auto__btn","data-action":"open-ledger-json",onClick:()=>{var b;return(b=e.onOpenResource)==null?void 0:b.call(e,{kind:"ledger",url:n.ledger_url,name:`run-${n.run_id}-ledger.json`,runId:n.run_id})},children:i.jsx(Bt,{icon:"file",label:"Ledger (JSON)"})}):null,n.workspace_url&&e.onOpenWorkspace?i.jsx("button",{type:"button",className:"af-auto__btn","data-action":"open-workspace",title:"Browse this run's folder",onClick:()=>{var b;return(b=e.onOpenWorkspace)==null?void 0:b.call(e,n.run_id)},children:i.jsx(Bt,{icon:"folder",label:"Workspace"})}):null]})]}),e.discussOpen?i.jsxs("form",{className:"af-auto-discuss","aria-label":`${rh}, from occurrence ${n.index}`,onSubmit:b=>{b.preventDefault();const _=ru(b.currentTarget,"prompt");_&&e.onDiscussSubmit(n.index,_)},children:[i.jsxs("p",{className:"af-auto__hint",children:["Starts a new session that forks this automation at #",n.index," with its full history (runs 1–",n.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."]}),i.jsx("textarea",{name:"prompt",rows:3,"aria-label":"Your message",placeholder:"Ask about this result…",required:!0}),i.jsxs("div",{className:"af-auto__row",children:[i.jsx("button",{type:"submit",className:"af-auto__btn af-auto__btn--primary","data-action":"discuss-submit",disabled:e.busy,children:i.jsx(Bt,{icon:"send",label:"Start discussion"})}),i.jsx("button",{type:"button",className:"af-auto__btn","data-action":"discuss-cancel",onClick:e.onDiscussCancel,children:i.jsx(Bt,{icon:"x",label:"Cancel"})})]})]}):i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"af-auto__btn af-auto__btn--quiet","data-action":"discuss",disabled:!f,title:nu.discuss,"aria-description":nu.discuss,"aria-describedby":h?`${u}-discuss-why`:void 0,onClick:()=>e.onDiscussOpen(n.index),children:i.jsx(Bt,{icon:wp.discuss,label:rh})}),h?i.jsx("span",{className:"af-auto__reasons",id:`${u}-discuss-why`,children:h}):null]})]})]})}const zw=5e3,Ww={[Qn.pause]:"Pause sent.",[Qn.resume]:"Resume sent.",[Qn.run_now]:"Run requested.",[Qn.stop_current]:"Stop sent."};function Uw(e){const{summary:n,busy:s}=e,a=e.renderText??Yo,l=w.useId(),u=w.useRef(null),[d,f]=w.useState(!1),h=e.editOpen!==void 0,y=Vo(n,e.occurrences,!1).revise.enabled&&(h?e.editOpen===!0:d),x=w.useRef(null);y?(!x.current||x.current.summary.automation_id!==n.automation_id)&&(x.current={summary:n,definition:e.definition}):x.current=null;const b=x.current,_=w.useRef(e.onEditOpenChange);_.current=e.onEditOpenChange;const E=W=>{var ie;h||f(W),(ie=_.current)==null||ie.call(_,W)},[C,j]=w.useState([]),[T,A]=w.useState(!1),[$,k]=w.useState(null),[P,V]=w.useState(null),[H,L]=w.useState(null);w.useEffect(()=>{if(!H)return;const W=setTimeout(()=>L(null),zw);return()=>clearTimeout(W)},[H]),w.useEffect(()=>{var ie;if(!y)return;j([]);const W=nh(u.current,['.af-auto__revise [name="title"]']);W==null||W.focus(),(ie=W==null?void 0:W.scrollIntoView)==null||ie.call(W,{block:"nearest"})},[y,n.automation_id]);const[de,re]=w.useState(null);w.useEffect(()=>{var W;de&&((W=nh(u.current,[...de,".af-auto__notice",".af-auto__title"]))==null||W.focus(),re(null))},[de]);const Q=w.useRef(null);Q.current||(Q.current=new pp(e.newId??mp));const U=Q.current,J=W=>V(Cw(W)),fe=(W,ie,le)=>{V(null),L(null),ie(U.idFor(W)).then(he=>{U.settle(W,{ok:!0}),le(he)},he=>{U.settle(W,{ok:!1,error:he}),J(he)})},ce=fw(n),ye=w.useRef(e.onSeen);ye.current=e.onSeen;const ve=w.useRef(null);ve.current||(ve.current=new kw),w.useEffect(()=>{const W=ve.current,ie=ce?`${n.automation_id}|${ce}`:null;if(!ce||!W.next(ie,n))return;const le=n;ye.current(ce).then(()=>W.succeeded(ie),he=>{W.failed(ie,le),J(he)})});const q=Vo(n,e.occurrences,s),oe=dw(e.occurrences),G=n.occurrence_count-e.occurrences.length,N=P??e.error??null,B=N?gu(N):null,F=n.attention;return i.jsxs("section",{ref:u,className:`af-auto${e.className?` ${e.className}`:""}`,"aria-labelledby":l,"aria-busy":s,"data-text-rendering":e.renderText?"rich":"unformatted",children:[i.jsx($w,{summary:n,triggerSources:e.triggerSources,titleId:l,nowMs:e.nowMs,onOpenWorkspace:e.onOpenWorkspace}),i.jsx(Lw,{summary:n,occurrences:e.occurrences,busy:s,confirmingArchive:T,reviseOpen:y,notice:H,onDismissNotice:()=>L(null),idBase:`${l}-ctl`,onCommand:W=>fe(`command:${W}`,ie=>e.onCommand(W,void 0,{command_id:ie}),()=>{W===Qn.archive?(A(!1),L("Archive requested."),re(['[data-action="archive"]'])):L(Ww[W]??"Command sent.")}),onToggleRevise:()=>{j([]),E(!y)},onAskArchive:()=>A(!0),onCancelArchive:()=>{A(!1),re(['[data-action="archive"]'])}}),y&&b?i.jsx(Ow,{summary:b.summary,definition:b.definition,busy:s,errors:C,emailStatus:e.emailStatus,onOpenMyEmail:e.onOpenMyEmail,onCancel:()=>{E(!1),re(['[data-action="edit"]'])},onSubmit:W=>{const ie=b.summary,le=pw(ie,W,b.definition);if(le===null){j(["Nothing changed."]);return}if("errors"in le){j(le.errors);return}j([]),fe(`revise:${ie.revision}:${JSON.stringify(le)}`,he=>e.onRevise(le,ie.revision,{command_id:he}),()=>{L("Saved; applies from the next run."),E(!1),re(['[data-action="edit"]'])})}}):e.definition?i.jsx(Aw,{definition:e.definition,renderText:a}):null,B?i.jsxs("div",{className:"af-auto__error",role:"alert","data-code":N==null?void 0:N.code,children:[i.jsx(ae,{name:"error",size:14,className:"af-auto__btn-icon"}),i.jsxs("span",{className:"af-auto__error-text",children:[i.jsx("strong",{children:B.title})," ",i.jsx("span",{children:B.detail})]}),P?i.jsx("button",{type:"button",className:"af-auto__icon-btn af-auto__icon-btn--bare","data-action":"dismiss-error","aria-label":"Dismiss",title:"Dismiss",onClick:()=>V(null),children:i.jsx(ae,{name:"x",size:12})}):null]}):null,F.items.length||F.waits.length?i.jsx("section",{className:"af-auto__attention","aria-label":"Needs attention",children:i.jsxs("ul",{children:[F.items.map(W=>i.jsxs("li",{className:`af-auto__attention-item af-auto__attention-item--${W.kind}`,"data-cursor":W.cursor,children:[i.jsx("span",{className:`af-auto-badge af-auto-badge--${W.kind==="failure"?"failed":"notified"}`,children:W.kind==="failure"?"Failed":"Notified"})," ",i.jsx("strong",{children:W.title})," ",i.jsxs("span",{className:"af-auto-turn__muted",children:["#",W.index," · ",wr(W.at)]}),W.body?i.jsx("div",{className:"af-auto__attention-body",children:a(W.body)}):null]},W.cursor)),F.waits.map(W=>i.jsxs("li",{className:"af-auto__attention-item af-auto__attention-item--wait",children:[i.jsx("span",{className:"af-auto-badge af-auto-badge--waiting","data-wait-kind":W.kind,children:hp[W.kind]??"Waiting for you"})," ",i.jsxs("span",{className:"af-auto-turn__muted",children:["#",W.index]}),W.prompt?i.jsx("div",{className:"af-auto__attention-body",children:a(W.prompt)}):null]},`${W.run_id}:${W.wait_key}`))]})}):null,G>0?i.jsx("button",{type:"button",className:"af-auto__btn af-auto__more","data-action":"load-more",disabled:s,onClick:e.onLoadMore,children:i.jsx(Bt,{icon:"history",label:`Load earlier occurrences (${G} more)`})}):null,oe.length?i.jsx("ol",{className:"af-auto__timeline","aria-label":"Occurrences",children:oe.map(W=>{const ie=`[data-index="${W.row.index}"]`;return i.jsx(Fw,{view:W,busy:s,discuss:q.discuss,renderText:a,renderTurn:e.renderTurn,onOpenWorkspace:e.onOpenWorkspace,onOpenResource:e.onOpenResource?le=>{var he;V(null);try{Promise.resolve((he=e.onOpenResource)==null?void 0:he.call(e,le)).catch(J)}catch(X){J(X)}}:void 0,discussOpen:$===W.row.index,onOpenRun:e.onOpenRun,onAnswerWait:(le,he,X)=>{V(null),e.onAnswerWait(le,he,X).then(()=>L("Answer sent."),J)},onWaitError:le=>V({status:0,code:"invalid_payload",message:le}),onDiscussOpen:k,onDiscussCancel:()=>{k(null),re([`${ie} [data-action="discuss"]`])},onDiscussSubmit:(le,he)=>fe(`discuss:${le}:${he}`,X=>e.onDiscuss(le,he,{request_id:X}),X=>{k(null),L(`Discussion started (session ${X.session_id}).`),re([`${ie} [data-action="discuss"]`])})},W.row.run_id)})}):i.jsx("p",{className:"af-auto__empty",children:"No occurrences yet."})]})}function Bw(e){var We;const n=w.useId(),s=w.useId(),a=w.useRef(null),l=w.useRef(null),u=w.useRef(e.onClose);u.current=e.onClose;const[d,f]=w.useState(e.initialPrompt??""),[h,g]=w.useState("every"),[y,x]=w.useState(pu),[b,_]=w.useState(!1),[E,C]=w.useState(qc),[j,T]=w.useState("24"),[A,$]=w.useState("h"),[k,P]=w.useState(""),[V,H]=w.useState("independent"),[L,de]=w.useState("auto"),[re,Q]=w.useState(e.initialTitle??""),[U,J]=w.useState(""),[fe,ce]=w.useState(""),[ye,ve]=w.useState(""),[q,oe]=w.useState([]),G=w.useRef(null);if(G.current||(G.current=new pp(()=>(e.newRequestId??mp)())),w.useEffect(()=>{var ee;if(!e.open)return;const ke=document.activeElement;(ee=l.current)==null||ee.focus();const Y=pe=>{if(!pe.defaultPrevented){if(pe.key==="Escape"){pe.preventDefault(),u.current();return}Jh(pe,a.current,document.activeElement)}};return window.addEventListener("keydown",Y),()=>{window.removeEventListener("keydown",Y),ke&&typeof ke.focus=="function"&&ke.focus()}},[e.open]),!e.open)return null;const N=hu(e.emailStatus),B=h==="email"&&N,F=h==="email"&&!N?"every":h,W={prompt:d,when:h==="once"?{kind:"once",at:k}:{kind:"every",amount:Number(j),unit:A},...B?{trigger:"email",email:{...y,usesModel:e.targetUsesModel!==!1}}:{},...N&&b?{notifyEmail:!0}:{},...N&&E.mode==="list"?{emailRecipients:E}:{},context:V,toolApproval:L,title:re,...F==="every"&&U?{startAt:U}:{},...F==="every"&&fe.trim()?{count:Number(fe)}:{},...F==="every"&&ye?{until:ye}:{}},ie=yw(W),le=e.busy===!0,he=e.error?gu(e.error):null,X=ke=>`${s}-${ke}`,$e=ke=>{ke.preventDefault();const Y=ww(W,{target:e.target,requestId:""});if(!Y.ok){oe(Y.errors);return}oe([]);const ee=G.current,pe=JSON.stringify(Y.body),Oe={...Y.body,request_id:ee.idFor(pe)};Promise.resolve(e.onSubmit(Oe)).then(()=>ee.settle(pe,{ok:!0}),we=>ee.settle(pe,{ok:!1,error:we}))};return i.jsx("div",{className:"af-appearance-overlay af-schedule-overlay",onClick:e.onClose,role:"presentation",children:i.jsxs("div",{ref:a,className:"af-appearance af-schedule",role:"dialog","aria-modal":"true","aria-labelledby":n,onClick:ke=>ke.stopPropagation(),children:[i.jsx("div",{className:"af-appearance__title",id:n,children:e.title??"Schedule a task"}),i.jsxs("form",{className:"af-schedule__form",onSubmit:$e,"aria-busy":le,children:[i.jsxs("fieldset",{className:"af-auto__field",children:[i.jsx("legend",{children:"What"}),e.workflowPicker?i.jsx("div",{className:"af-schedule__picker",children:e.workflowPicker}):null,e.target?null:i.jsx("p",{className:"af-auto__hint",children:"Choose what to run."}),i.jsxs("label",{className:"af-auto__field",htmlFor:X("prompt"),children:[i.jsx("span",{children:"Task"}),i.jsx("textarea",{id:X("prompt"),ref:l,rows:3,value:d,onChange:ke=>f(ke.target.value),placeholder:"e.g. Check the price of ACME shares and notify me if it moved more than 2%.",required:!0})]})]}),i.jsxs("fieldset",{className:"af-auto__field",children:[i.jsx("legend",{children:"When (UTC)"}),i.jsxs("div",{className:"af-auto__row",role:"radiogroup","aria-label":"Schedule kind",children:[i.jsxs("label",{children:[i.jsx("input",{type:"radio",name:X("kind"),value:"every",checked:F==="every",onChange:()=>g("every")})," Repeat"]}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",name:X("kind"),value:"once",checked:h==="once",onChange:()=>g("once")})," Once at…"]}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",name:X("kind"),value:"email",checked:B,disabled:!N,onChange:()=>g("email")})," ",ze.trigger_label]})]}),N?null:i.jsx(tu,{status:e.emailStatus,onOpenMyEmail:e.onOpenMyEmail}),B?i.jsx(jw,{value:{...y,usesModel:e.targetUsesModel!==!1},onChange:x,idBase:s}):F==="every"?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"af-auto__row af-schedule__presets",role:"group","aria-label":"Presets",children:mw.map(ke=>ke.when.kind==="every"?i.jsx("button",{type:"button",className:"af-auto__btn af-auto__btn--quiet","aria-pressed":Number(j)===ke.when.amount&&A===ke.when.unit,onClick:()=>{ke.when.kind==="every"&&(T(String(ke.when.amount)),$(ke.when.unit))},children:ke.label},ke.label):null)}),i.jsxs("div",{className:"af-auto__row",children:[i.jsx("span",{children:"Every"}),i.jsx("input",{type:"number",min:1,step:1,value:j,onChange:ke=>T(ke.target.value),"aria-label":"Interval amount"}),i.jsxs("select",{value:A,onChange:ke=>$(ke.target.value),"aria-label":"Interval unit",children:[i.jsx("option",{value:"m",children:"minutes"}),i.jsx("option",{value:"h",children:"hours"}),i.jsx("option",{value:"d",children:"days"})]})]})]}):i.jsxs("label",{className:"af-auto__field",htmlFor:X("once"),children:[i.jsx("span",{children:"Run once at (UTC)"}),i.jsx("input",{id:X("once"),type:"datetime-local",value:k,onChange:ke=>P(ke.target.value)})]}),i.jsx("p",{className:"af-schedule__preview","aria-live":"polite","data-preview":"true",children:ie?`Runs ${ie}.`:B?"Incomplete email trigger.":"Incomplete schedule."})]}),i.jsxs("fieldset",{className:"af-auto__field",children:[i.jsx("legend",{children:"Context"}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",name:X("ctx"),value:"independent",checked:V==="independent",onChange:()=>H("independent")})," Independent — each run starts fresh"]}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",name:X("ctx"),value:"growing",checked:V==="growing",onChange:()=>H("growing")})," Growing — each run sees the previous runs"]})]}),i.jsxs("fieldset",{className:"af-auto__field","data-field":"tool-approval",children:[i.jsx("legend",{children:"Tools"}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",name:X("tools"),value:"auto",checked:L==="auto",onChange:()=>de("auto")})," Run without asking"]}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",name:X("tools"),value:"ask",checked:L==="ask",onChange:()=>de("ask")})," Ask me before each tool call (the run waits for you)"]}),B?i.jsx("p",{className:"af-auto__hint","data-email-rule":"untrusted",children:ze.untrusted_hint}):null,L==="auto"?i.jsxs("p",{className:"af-schedule__consent","data-consent":"true",children:[vw,e.targetTools&&e.targetTools.length?`: ${e.targetTools.join(", ")}.`:"."]}):i.jsx("p",{className:"af-auto__hint",children:"Each tool call waits for your approval in the automation's timeline."})]}),i.jsxs("fieldset",{className:"af-auto__field","data-field":"email",children:[i.jsx("legend",{children:"Email"}),N?null:i.jsx(tu,{status:e.emailStatus,onOpenMyEmail:e.onOpenMyEmail}),i.jsx(Sw,{notifyEmail:N&&b,onNotifyEmailChange:_,recipients:N?E:qc,onRecipientsChange:C,disabled:!N,idBase:s})]}),i.jsxs("details",{className:"af-schedule__advanced",children:[i.jsx("summary",{children:"Advanced"}),i.jsxs("label",{className:"af-auto__field",htmlFor:X("title"),children:[i.jsx("span",{children:"Title"}),i.jsx("input",{id:X("title"),value:re,maxLength:120,onChange:ke=>Q(ke.target.value),placeholder:"Defaults to the task's first line"})]}),F==="every"?i.jsxs(i.Fragment,{children:[i.jsxs("label",{className:"af-auto__field",htmlFor:X("start"),children:[i.jsx("span",{children:"First run at (UTC; empty = now)"}),i.jsx("input",{id:X("start"),type:"datetime-local",value:U,onChange:ke=>J(ke.target.value)})]}),i.jsxs("label",{className:"af-auto__field",htmlFor:X("count"),children:[i.jsx("span",{children:"Stop after this many runs"}),i.jsx("input",{id:X("count"),type:"number",min:1,step:1,value:fe,onChange:ke=>ce(ke.target.value)})]}),i.jsxs("label",{className:"af-auto__field",htmlFor:X("until"),children:[i.jsx("span",{children:"Stop at (UTC)"}),i.jsx("input",{id:X("until"),type:"datetime-local",value:ye,onChange:ke=>ve(ke.target.value)})]})]}):null]}),q.length?i.jsx("ul",{className:"af-auto__form-errors",role:"alert",children:q.map(ke=>i.jsx("li",{children:ke},ke))}):null,he?i.jsxs("div",{className:"af-auto__error",role:"alert","data-code":(We=e.error)==null?void 0:We.code,children:[i.jsx("strong",{children:he.title})," ",i.jsx("span",{children:he.detail})]}):null,i.jsxs("div",{className:"af-appearance__actions af-auto__row",children:[i.jsx("button",{type:"button",className:"af-auto__btn",onClick:e.onClose,children:"Cancel"}),i.jsx("button",{type:"submit",className:"af-auto__btn af-auto__btn--primary",disabled:le,children:"Create automation"})]})]})]})})}function vp(e){const n=String(e??"").trim();if(!n||!(n.startsWith("{")&&n.endsWith("}")||n.startsWith("[")&&n.endsWith("]")))return null;try{return JSON.parse(n)}catch{return null}}function Vw(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Gw(e){const n=String(e.role||"message").trim()||"message",s=String(e.title||"").trim(),a=String(e.ts||"").trim(),l=[n];return s&&l.push(s),a&&l.push(a),l.join(" · ")}function Hw(e){return e.endsWith(`
55
+ `)?e:`${e}
56
+ `}function Kw(e){return String(e||"").trimStart().startsWith("```")}function Jw(e,n){const a=[`# ${"Chat".trim()||"Chat"}`,""];for(const l of e){const u=Gw(l);a.push(`## ${u}`,"");const d=String(l.content||""),f=vp(d);f!==null&&!Kw(d)?a.push("```json",Vw(f).trimEnd(),"```",""):a.push(Hw(d).trimEnd(),""),a.push("---","")}for(;a.length&&!a[a.length-1].trim();)a.pop();return a.length&&a[a.length-1]==="---"&&a.pop(),`${a.join(`
57
+ `).trimEnd()}
58
+ `}async function wu(e){const n=String(e||"");if(!n)return!1;try{return await navigator.clipboard.writeText(n),!0}catch{try{const s=document.createElement("textarea");return s.value=n,s.style.position="fixed",s.style.left="-9999px",document.body.appendChild(s),s.select(),document.execCommand("copy"),document.body.removeChild(s),!0}catch{return!1}}}function Qw(e){const n=String(e.filename).trim()||"export.txt",s=String(e.text||""),a=String(e.mime||"text/plain;charset=utf-8"),l=new Blob([s],{type:a}),u=URL.createObjectURL(l),d=document.createElement("a");d.href=u,d.download=n,document.body.appendChild(d),d.click(),d.remove(),window.setTimeout(()=>URL.revokeObjectURL(u),1e3)}const Yw=3,Xw=Number.MAX_SAFE_INTEGER;function _p(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function xp(e){return Array.isArray(e)}function Zw(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function wi({kind:e,children:n}){return i.jsx("span",{className:`pc-json-token ${e}`,children:n})}function qw(e){const n=JSON.stringify(e.value),s=n.length>96||n.includes("\\n")||n.includes("\\r")||n.includes("\\t"),[a,l]=w.useState(!s||e.expansionMode==="unfolded");return w.useEffect(()=>{s&&l(e.expansionMode==="unfolded")},[s,e.expansionMode,e.expansionVersion]),s?i.jsxs("span",{className:`pc-json-string ${a?"open":"collapsed"}`,children:[i.jsx("button",{type:"button",className:"pc-json-string__toggle",onClick:()=>l(u=>!u),"aria-label":a?"Collapse string value":"Expand string value","aria-expanded":a,children:a?"▾":"▸"}),a?i.jsx("span",{className:"pc-json-token string pc-json-string__value",children:n}):i.jsxs("button",{type:"button",className:"pc-json-string__preview",onClick:()=>l(!0),"aria-label":"Expand string value",children:[i.jsx("span",{className:"pc-json-token string pc-json-string__preview_text",children:n}),i.jsx("span",{className:"pc-json-string__suffix",children:"(...)"})]})]}):i.jsx(wi,{kind:"string",children:n})}function ev(e,n,s){return e===null?i.jsx(wi,{kind:"null",children:"null"}):typeof e=="string"?i.jsx(qw,{value:e,expansionMode:n,expansionVersion:s}):typeof e=="number"?i.jsx(wi,{kind:"number",children:String(e)}):typeof e=="boolean"?i.jsx(wi,{kind:"boolean",children:e?"true":"false"}):i.jsx(wi,{kind:"string",children:JSON.stringify(String(e))})}function tv(e){return xp(e)?e.length===1?"1 item":`${e.length} items`:_p(e)?Object.keys(e).length===1?"1 key":`${Object.keys(e).length} keys`:""}function bp(e){const{label:n,value:s,depth:a,collapseAfterDepth:l,expansionMode:u,expansionVersion:d,trailingComma:f}=e,h=a*14,g=_p(s),y=xp(s),x=g||y,b=a<l,[_,E]=w.useState(b);w.useEffect(()=>{E(b)},[b,d]);const C=n?i.jsxs(i.Fragment,{children:[i.jsx(wi,{kind:"key",children:JSON.stringify(n)}),": "]}):null;if(!x)return i.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:h},children:[C,ev(s,u,d),f?",":""]});const j=y?"[":"{",T=y?"]":"}",A=tv(s),$=_?`${j}`:`${j}…${T}${A?` (${A})`:""}`,k=y?s.map((P,V)=>({key:String(V),label:void 0,value:P})):Object.entries(s).map(([P,V])=>({key:P,label:P,value:V}));return i.jsxs("details",{className:"pc-json-viewer__details",open:_,onToggle:P=>E(P.currentTarget.open),children:[i.jsxs("summary",{className:"pc-json-viewer__summary",style:{paddingLeft:h},children:[C,i.jsx("span",{className:"pc-json-viewer__caret","aria-hidden":"true",children:_?"▾":"▸"}),i.jsx("span",{className:"pc-json-viewer__punct",children:$}),!_&&f?i.jsx("span",{className:"pc-json-viewer__punct",children:","}):null]}),_?i.jsx("div",{className:"pc-json-viewer__children",children:k.length===0?i.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:h},children:[i.jsx("span",{className:"pc-json-viewer__punct",children:T}),f?",":""]}):i.jsxs(i.Fragment,{children:[k.map((P,V)=>{const H=V===k.length-1;return i.jsx(bp,{label:P.label,value:P.value,depth:a+1,collapseAfterDepth:l,expansionMode:u,expansionVersion:d,trailingComma:!H},`${a}:${n||"root"}:${P.key}`)}),i.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:h},children:[i.jsx("span",{className:"pc-json-viewer__punct",children:T}),f?",":""]})]})}):null]})}function nv(e){const n=e.trim();if(!n)return e;if(n.startsWith("{")&&n.endsWith("}")||n.startsWith("[")&&n.endsWith("]"))try{return JSON.parse(n)}catch{return e}return e}function Cs(e){const{value:n,className:s,showCopy:a=!0}=e,[l,u]=w.useState({mode:"folded",version:0}),d=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):Yw,f=l.mode==="unfolded"?Xw:d,h=w.useMemo(()=>typeof n=="string"?nv(n):n,[n]),g=w.useMemo(()=>Zw(n),[n]),y=["pc-json-viewer",s].filter(Boolean).join(" ");w.useEffect(()=>{u(b=>({mode:"folded",version:b.version+1}))},[h]);const x=()=>{u(b=>({mode:b.mode==="unfolded"?"folded":"unfolded",version:b.version+1}))};return i.jsxs("div",{className:y,children:[i.jsxs("div",{className:"pc-json-viewer__toolbar",children:[i.jsx("button",{type:"button",className:"pc-btn pc-json-viewer__toggle-all",onClick:x,"aria-expanded":l.mode==="unfolded",children:l.mode==="unfolded"?"Fold all":"Unfold all"}),a?i.jsx("button",{type:"button",className:"pc-btn pc-json-viewer__copy",onClick:()=>void wu(g),children:"Copy JSON"}):null]}),i.jsx("div",{className:"pc-json-viewer__tree",role:"tree","aria-label":"JSON viewer",children:i.jsx(bp,{value:h,depth:0,collapseAfterDepth:f,expansionMode:l.mode,expansionVersion:l.version,trailingComma:!1})})]})}function la(e,n){const s=String(e??"");if(!n||!n.needles.length)return[s];const a=[],l=s.toLowerCase();let u=0;for(;u<s.length;){let d=-1,f="";for(let y=0;y<n.needlesLower.length;y++){const x=n.needlesLower[y];if(!x)continue;const b=l.indexOf(x,u);if(b===-1)continue;const _=n.needles[y]||"";_&&(d===-1||b<d||b===d&&_.length>f.length)&&(d=b,f=_)}if(d===-1||!f){a.push(s.slice(u));break}d>u&&a.push(s.slice(u,d));const h=n.hits===0&&n.id?n.id:void 0,g=s.slice(d,d+f.length);a.push(i.jsx("span",{id:h,className:n.className,children:g},`hl:${n.hits}`)),n.hits+=1,u=d+f.length}return a}function kp(e){const n=String(e||"").trim();if(n&&/^(https?:|mailto:|tel:|#|\/)/i.test(n))return n}const su="http://same-origin.invalid/";function rv(e){try{const n=new URL(e,su);return n.protocol==="http:"&&n.origin===new URL(su).origin}catch{return!1}}function jp(e){const n=String(e||"").trim();return kp(n)??(n&&rv(n)?n:void 0)}let Es=null;function sv(e){const n=String(e||"").trim();if(!n)return!1;const s=typeof document<"u"&&document.baseURI?document.baseURI:null;if(s===null&&/^[a-z][a-z0-9+.-]*:/i.test(n))return!1;const a=s??su;let l,u;try{l=new URL(a).origin,u=new URL(n,a)}catch{return!1}return u.protocol!=="http:"&&u.protocol!=="https:"?!1:u.origin===l}function Sp(e,n,s){return i.jsx("a",{className:"pc-md_link pc-md_image_link",href:n,target:"_blank",rel:"noopener noreferrer",children:`image: ${s||n}`},e)}function Qr(e,n){const s=[],a=String(e??"");let l=0,u="";const d=()=>{if(u){for(const f of la(u,n))s.push(f);u=""}};for(;l<a.length;){const f=a[l];if(f==="!"&&a[l+1]==="["){const h=a.indexOf("]",l+2);if(h!==-1&&a[h+1]==="("){const g=a.indexOf(")",h+2);if(g!==-1){const y=a.slice(l+2,h),x=jp(a.slice(h+2,g));if(x&&Es&&!Es(x)){d(),s.push(Sp(`img:${l}`,x,y)),l=g+1;continue}if(x){d(),s.push(i.jsxs("span",{className:"pc-md_image_inline",children:[i.jsx("img",{className:"pc-md_img",src:x,alt:y,loading:"lazy"}),y?i.jsx("span",{className:"pc-md_img_caption",children:n?la(y,n):y}):null]},`img:${l}`)),l=g+1;continue}}}}if(f==="["){const h=a.indexOf("]",l+1);if(h!==-1&&a[h+1]==="("){const g=a.indexOf(")",h+2);if(g!==-1){const y=a.slice(l+1,h),x=kp(a.slice(h+2,g));if(x){d(),s.push(i.jsx("a",{className:"pc-md_link",href:x,target:x.startsWith("#")?void 0:"_blank",rel:"noreferrer",children:Qr(y,n)},`link:${l}`)),l=g+1;continue}}}}if(f==="`"){const h=a.indexOf("`",l+1);if(h!==-1){d();const g=a.slice(l+1,h);s.push(i.jsx("code",{children:n?la(g,n):g},`code:${l}`)),l=h+1;continue}}if(f==="*"&&a[l+1]==="*"){const h=a.indexOf("**",l+2);if(h!==-1){d();const g=a.slice(l+2,h);s.push(i.jsx("strong",{children:n?la(g,n):g},`bold:${l}`)),l=h+2;continue}}if(f==="*"&&a[l+1]!=="*"){const h=a.indexOf("*",l+1);if(h!==-1){d();const g=a.slice(l+1,h);s.push(i.jsx("em",{children:n?la(g,n):g},`em:${l}`)),l=h+1;continue}}u+=f,l+=1}return d(),s}function iv(e){return String(e??"").replace(/\r\n/g,`
59
+ `).replace(/\r/g,`
60
+ `).split(`
61
+ `)}function Fo(e){const s=String(e??"").match(/^([ \t]*)(?:([-*+])|(\d{1,9})[.)])\s+(.*)$/);return s?{indent:s[1].replace(/\t/g," ").length,ordered:!!s[3],start:s[3]?Math.max(1,parseInt(s[3],10)||1):1,content:s[4]??""}:null}function av(e){const n=[];for(const l of e){const u=Fo(l);u?n.push(u):n.length>0&&l.trim()&&(n[n.length-1].content+=` ${l.trim()}`)}const s=[],a=[];for(const l of n){for(;a.length>0&&l.indent<a[a.length-1].indent;)a.pop();let u=a.length>0?a[a.length-1]:null;if(u&&l.indent>u.indent){const d=u.node.items,f=d[d.length-1];if(f){const h={ordered:l.ordered,start:l.start,items:[]};f.children.push(h),a.push({indent:l.indent,node:h}),u=a[a.length-1]}}else if(u&&u.node.ordered!==l.ordered){a.pop();const d=a.length>0?a[a.length-1]:null,f={ordered:l.ordered,start:l.start,items:[]};if(d){const h=d.node.items,g=h[h.length-1];g?g.children.push(f):d.node.items.push({content:"",children:[f]})}else s.push(f);a.push({indent:l.indent,node:f}),u=a[a.length-1]}if(!u){const d={ordered:l.ordered,start:l.start,items:[]};s.push(d),a.push({indent:l.indent,node:d}),u=a[a.length-1]}u.node.items.push({content:l.content,children:[]})}return s}function Np(e,n,s){const a=e.items.map((l,u)=>i.jsxs("li",{children:[Qr(l.content,n),l.children.map((d,f)=>Np(d,n,`${s}:${u}:${f}`))]},`${s}:li:${u}`));return e.ordered?i.jsx("ol",{className:"pc-md_ol",start:e.start!==1?e.start:void 0,children:a},s):i.jsx("ul",{className:"pc-md_ul",children:a},s)}function ov(e,n,s){return av(e).map((a,l)=>Np(a,n,`${s}:${l}`))}function ah(e){let n=String(e??"").trim();return n?(n.startsWith("|")&&(n=n.slice(1)),n.endsWith("|")&&(n=n.slice(0,-1)),n.split("|").map(s=>String(s??"").trim())):[]}function oh(e){let n=String(e??"").trim();if(!n)return!1;n.startsWith("|")&&(n=n.slice(1)),n.endsWith("|")&&(n=n.slice(0,-1));const s=n.split("|").map(a=>String(a??"").trim());return s.length<2?!1:s.every(a=>/^:?-{3,}:?$/.test(a))}const lh=/^(#{1,5})\s+(.*)$/;function ch(e){return e.trim().startsWith("```")}function uh(e){return e.trimStart().startsWith(">")}function Cp(e){const n=Es;Es=e.images==="link"?e.inlineImage||sv:null;try{return lv(e)}finally{Es=n}}function lv({text:e,className:n,highlight:s,highlights:a,highlightClassName:l,highlightId:u}){const d=iv(e),f=[],h=[];Array.isArray(a)&&h.push(...a),typeof s=="string"&&s.trim()&&h.push(s);const g=Array.from(new Set(h.map(_=>String(_??"").trim()).filter(Boolean))).filter(_=>_.length>=4),y=g.length?{needles:g,needlesLower:g.map(_=>_.toLowerCase()),className:l||"pc-md_hl",id:u,hits:0}:null;let x=0;for(;x<d.length;){const _=String(d[x]??"");if(!_.trim()){x+=1;continue}const E=_.trim();if(/^([-_*])(\s*\1){2,}$/.test(E)){f.push(i.jsx("hr",{className:"pc-md_hr"},`hr:${x}`)),x+=1;continue}const C=_.match(/^\s*!\[([^\]]*)\]\(([^)]+)\)\s*$/);if(C){const A=jp(C[2]||"");if(A&&Es&&!Es(A)){f.push(i.jsx("p",{className:"pc-md_p",children:Sp(`img:${x}`,A,C[1]||"")},`p:${x}`)),x+=1;continue}if(A){const $=C[1]||"";f.push(i.jsxs("figure",{className:"pc-md_figure",children:[i.jsx("img",{className:"pc-md_img",src:A,alt:$,loading:"lazy"}),$?i.jsx("figcaption",{children:Qr($,y)}):null]},`figure:${x}`)),x+=1;continue}}if(ch(_)){const $=_.trim().replace(/```/g,"").trim(),k=[];for(x+=1;x<d.length&&!String(d[x]??"").trim().startsWith("```");)k.push(String(d[x]??"")),x+=1;x<d.length&&(x+=1);const P=k.join(`
62
+ `);f.push(i.jsx("pre",{className:"pc-md_pre",children:i.jsx("code",{className:$?`language-${$}`:void 0,children:P})},`pre:${x}`));continue}const j=_.match(lh);if(j){const A=j[1].length,$=j[2]||"",k=Qr($,y);A===1?f.push(i.jsx("h1",{children:k},`h1:${x}`)):A===2?f.push(i.jsx("h2",{children:k},`h2:${x}`)):A===3?f.push(i.jsx("h3",{children:k},`h3:${x}`)):A===4?f.push(i.jsx("h4",{children:k},`h4:${x}`)):f.push(i.jsx("h5",{children:k},`h5:${x}`)),x+=1;continue}if(uh(_)){const A=[];for(;x<d.length&&String(d[x]??"").trimStart().startsWith(">");){const k=String(d[x]??"").trimStart();A.push(k.replace(/^>\s?/,"")),x+=1}f.push(i.jsx("blockquote",{className:"pc-md_quote",children:A.map(($,k)=>i.jsxs(wt.Fragment,{children:[Qr($,y),k<A.length-1?i.jsx("br",{}):null]},`q:${x}:${k}`))},`quote:${x}`));continue}if(_.includes("|")&&x+1<d.length&&oh(String(d[x+1]??""))){const A=ah(_),$=Math.max(1,A.length),k=[];for(x+=2;x<d.length;){const P=String(d[x]??"");if(!P.trim()||!P.includes("|"))break;const V=ah(P),H=[];for(let L=0;L<$;L++)H.push(V[L]??"");k.push(H),x+=1}f.push(i.jsx("div",{className:"pc-md_table_wrap",children:i.jsxs("table",{className:"pc-md_table",children:[i.jsx("thead",{children:i.jsx("tr",{children:A.slice(0,$).map((P,V)=>i.jsx("th",{children:Qr(P,y)},`th:${x}:${V}`))})}),i.jsx("tbody",{children:k.map((P,V)=>i.jsx("tr",{children:P.map((H,L)=>i.jsx("td",{children:Qr(H,y)},`td:${x}:${V}:${L}`))},`tr:${x}:${V}`))})]})},`table:${x}`));continue}if(Fo(_)){const A=[];for(;x<d.length;){const $=String(d[x]??"");if(!$.trim()||$.trimStart().startsWith("```"))break;if(Fo($)||/^\s{2,}\S/.test($)){A.push($),x+=1;continue}break}f.push(i.jsx(wt.Fragment,{children:ov(A,y,`list:${x}`)},`list:${x}`));continue}const T=[];for(;x<d.length&&String(d[x]??"").trim()&&!(T.length>0&&Fo(String(d[x]??"")));){const A=String(d[x]??"");if(T.length>0&&(lh.test(A)||ch(A)||uh(A))||T.length>0&&A.includes("|")&&x+1<d.length&&oh(String(d[x+1]??"")))break;T.push(A),x+=1}f.push(i.jsx("p",{className:"pc-md_p",children:T.map((A,$)=>i.jsxs(wt.Fragment,{children:[Qr(A,y),$<T.length-1?i.jsx("br",{}):null]},`pl:${x}:${$}`))},`p:${x}`))}const b=["pc-md",n].filter(Boolean).join(" ");return i.jsx("div",{className:b,children:f})}function Ep(e){const n=String(e.text??""),s=w.useMemo(()=>vp(n),[n]),a=["pc-chat-content",e.className].filter(Boolean).join(" ");return s!==null?i.jsx("div",{className:a,children:i.jsx(Cs,{value:s,collapseAfterDepth:e.jsonCollapseAfterDepth})}):e.renderMarkdown?i.jsx("div",{className:a,children:e.renderMarkdown(n)}):i.jsx("div",{className:a,children:i.jsx(Cp,{text:n,images:e.images,inlineImage:e.inlineImage})})}function $p(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}}function Ap(e){const n=$p(e);if(!n||typeof n!="object"||Array.isArray(n))return{label:"input",value:n==null?"":String(n)};const s=Object.entries(n),l=["command","query","url","file_path","path","pattern","name"].map(u=>s.find(([d])=>d===u)).find(Boolean)||s[0];return l?{label:l[0].replace(/_/g," "),value:typeof l[1]=="string"?l[1]:JSON.stringify(l[1])??""}:{label:"",value:""}}function Tp({tool:e,showCopy:n=!0}){const[s,a]=w.useState(!1),l=$p(e.arguments),u=Ap(e.arguments),d=["file path","path"].includes(u.label)&&u.value.length>60?`${u.value.split(/[\\/]/).pop()} · ${u.value.slice(0,24)}…`:u.value,f=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"},g=e.startedAt&&e.endedAt?Date.parse(e.endedAt)-Date.parse(e.startedAt):NaN,y=l&&typeof l=="object"&&!Array.isArray(l)?Object.entries(l):null;return i.jsxs("details",{className:`pc-tool-activity pc-tool-activity--${e.status}`,children:[i.jsxs("summary",{className:"pc-tool-activity__summary",children:[i.jsx("span",{className:"pc-tool-activity__state-icon","aria-hidden":"true",children:i.jsx(ae,{name:e.status==="completed"?"check":e.status==="failed"?"x":e.status==="waiting"?"warning":"loader",size:15})}),i.jsx("strong",{children:e.name}),i.jsx("span",{className:"pc-tool-activity__preview",title:u.value,children:u.value?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"pc-tool-activity__key",children:u.label}),d]}):"No parameters"}),i.jsx("span",{className:"pc-tool-activity__status",children:h[e.status]}),Number.isFinite(g)&&g>=0?i.jsxs("span",{className:"pc-tool-activity__duration",children:[(g/1e3).toFixed(1),"s"]}):null,i.jsx("span",{className:"pc-tool-activity__chevron","aria-hidden":"true",children:i.jsx(ae,{name:"chevronRight",size:13})}),e.error?i.jsx("span",{className:"pc-tool-activity__error",title:e.error,children:f}):null]}),i.jsxs("div",{className:"pc-tool-activity__detail",children:[e.error?i.jsxs(i.Fragment,{children:[i.jsx("h4",{children:"Error"}),i.jsx("pre",{className:"pc-tool-activity__output",children:e.error})]}):null,i.jsxs("div",{className:"pc-tool-activity__detail-heading",children:[i.jsx("h4",{children:"Parameters"}),n?i.jsxs("button",{type:"button",onClick:async()=>a(await wu(JSON.stringify(e,null,2))),children:[i.jsx(ae,{name:"copy",size:13}),s?"Copied":"Copy details"]}):null]}),y?i.jsx("dl",{className:"pc-tool-activity__parameters",children:y.map(([x,b])=>i.jsxs(wt.Fragment,{children:[i.jsx("dt",{children:x}),i.jsx("dd",{children:b&&typeof b=="object"?i.jsx(Cs,{value:b}):i.jsx("code",{children:typeof b=="string"?b:JSON.stringify(b)})})]},x))}):e.arguments===void 0?i.jsx("p",{children:"Arguments are unavailable in this ledger."}):i.jsx(Cs,{value:l}),e.output!==void 0?i.jsxs(i.Fragment,{children:[i.jsx("h4",{children:"Result"}),typeof e.output=="string"?i.jsx("pre",{className:"pc-tool-activity__output",children:e.output}):i.jsx("div",{className:"pc-tool-activity__output",children:i.jsx(Cs,{value:e.output})})]}):null]})]})}function Rp({tools:e,showCopy:n}){const s=a=>e.filter(l=>l.status===a).length;return i.jsxs("section",{className:"pc-tool-group","aria-label":"Tool activity",children:[i.jsxs("div",{className:"pc-tool-group__heading",children:[i.jsx(ae,{name:"terminal",size:14}),i.jsx("strong",{children:"Tools"}),i.jsxs("span",{children:[e.length," ",e.length===1?"call":"calls"]}),i.jsx("div",{}),s("running")?i.jsxs("span",{className:"pc-tool-group__running",children:[s("running")," running"]}):null,s("waiting")?i.jsxs("span",{className:"pc-tool-group__waiting",children:[s("waiting")," need approval"]}):null,s("failed")?i.jsxs("span",{className:"pc-tool-group__failed",children:[s("failed")," failed"]}):null,s("completed")?i.jsxs("span",{className:"pc-tool-group__completed",children:[s("completed")," done"]}):null]}),e.map(a=>i.jsx(Tp,{tool:a,showCopy:n},a.id))]})}const Tt="not reported",Ht=e=>e===void 0?Tt:Math.round(e).toLocaleString(),sn=e=>{if(e===void 0)return Tt;if(e<6e4)return`${(e/1e3).toFixed(1)}s`;const n=Math.round(e/1e3);return`${Math.floor(n/60)}m ${String(n%60).padStart(2,"0")}s`},Ip=e=>e===void 0?Tt:`${Math.round(e).toLocaleString()} tok/s`,cv=(e,n)=>n>0?`${Math.round(e/n*100)}%`:"",$s=(e,n,s=`${n}s`)=>`${e.toLocaleString()} ${e===1?n:s}`,uv=e=>{const n=e.split("#")[0].replace(/\/+$/,"");return n.slice(n.lastIndexOf("/")+1)||e};function dv(e){const n=new Map;for(const s of e)s&&n.set(s,(n.get(s)||0)+1);return[...n].map(([s,a])=>a>1?`${s} ×${a}`:s).join(" · ")}function Go(e){const n=[],s=(e.models||[]).map(uv),a=e.providers||[];return(s.length||a.length)&&n.push([s.join(", ")||"model not reported",a.join(", ")].filter(Boolean).join(" · ")),n.push("From the run ledger; summed across this turn and its child runs."),n}function fv(e){const n=e.modelCalls||[],s=[],a=[{label:"Input",value:Ht(e.inputTokens)},{label:"Output",value:Ht(e.outputTokens)}];if(e.reasoningTokens!==void 0&&a.push({label:"Reasoning",value:Ht(e.reasoningTokens),hint:"part of output"}),a.push({label:"Total",value:Ht(e.totalTokens)}),s.push({heading:`Usage · ${$s(e.llmCalls,"model call")}`,rows:a}),e.measuredCacheCalls){const u=e.cachedTokens||0,d=e.fedTokens||0,f=[{label:"Reused from cache",value:`${Ht(u)}${u+d?` (${cv(u,u+d)})`:""}`},{label:"Newly processed",value:Ht(e.fedTokens)},{label:"Outcome",value:dv(n.map(h=>h.cacheOutcome))||(e.cacheOutcomes||[]).join(" · ")||Tt},{label:"Backend",value:(e.cacheBackends||[]).join(", ")||Tt}];e.measuredCacheCalls!==e.llmCalls&&f.push({label:"Measured on",value:`${e.measuredCacheCalls} of ${e.llmCalls} calls`}),s.push({heading:"Prompt cache",rows:f})}else e.llmCalls&&s.push({heading:"Prompt cache",rows:[{label:"Cache reuse",value:Tt}]});const l=n.filter(u=>u.inputTokens!==void 0);return l.length===1&&n.length===1?s.push({heading:"Context",rows:[{label:"Prompt size",value:`${Ht(l[0].inputTokens)} tokens`}]}):l.length>1&&s.push({heading:"Context",rows:[{label:"First → last call",value:`${Ht(l[0].inputTokens)} → ${Ht(l[l.length-1].inputTokens)} tokens`}],note:"Each call re-sends the conversation, so the input total counts the context once per call."}),n.length>1&&s.push({heading:"Per call",table:{columns:["#","Input","Cached","New","Output","Cache"],rows:n.map((u,d)=>[String(d+1),Ht(u.inputTokens),u.cachedTokens===void 0?"—":Ht(u.cachedTokens),u.fedTokens===void 0?"—":Ht(u.fedTokens),Ht(u.outputTokens),u.cacheOutcome||"—"])}}),{kind:"tokens",title:"Tokens",headline:e.totalTokens===void 0?Tt:`${e.totalTokens.toLocaleString()} total`,sections:s,footer:Go(e)}}function Ro(e,n,s,a){if(e===void 0)return Tt;const l=[sn(e)];return n!==void 0&&l.push(`${n.toLocaleString()} ${a}${s!==void 0?` at ${Ip(s)}`:""}`),l.join(" · ")}function hv(e){var g,y,x;const n=e.modelCalls||[],s=[],a=e.durationMs,l=[{label:"Wall clock",value:sn(a)}];if(l.push({label:"Model",value:e.genTimeMs===void 0?Tt:`${sn(e.genTimeMs)} · ${$s(e.timedCalls||0,"call")}${e.timedCalls!==e.llmCalls?` (of ${e.llmCalls})`:""}`}),l.push({label:"Tools",value:e.toolTimeMs!==void 0?`${sn(e.toolTimeMs)} · ${$s(e.toolBatches||0,"batch","batches")}`:e.toolCalls?Tt:"none",hint:e.toolTimeIncludesApproval?"includes approval wait":void 0}),a!==void 0&&e.genTimeMs!==void 0){const b=a-e.genTimeMs-(e.toolTimeMs||0);l.push({label:"Orchestration",value:b>=0?sn(b):"overlaps (parallel runs)",hint:"wall − model − tools: routing, hand-offs, model load"})}s.push({heading:"Turn",rows:l});const u=[],d=e.ttftCalls||0,f=e.promptPhaseCalls||0;e.promptPhaseMs!==void 0?u.push({label:d&&d===f?"Prefill (TTFT)":"Prefill",value:Ro(e.promptPhaseMs,e.promptPhaseNewTokens,e.promptPhaseTokensPerSecond,"new tok"),hint:d===f?"measured time to first token":d?`TTFT measured on ${d} of ${f}; rest from provider rate`:"derived: prompt ÷ provider rate"}):e.prefillMs!==void 0&&e.prefillNewTokensPerSecond!==void 0?u.push({label:"Prefill",value:Ro(e.prefillMs,e.prefillNewTokens,e.prefillNewTokensPerSecond,"new tok"),hint:"derived: prompt ÷ provider rate"}):e.prefillMs!==void 0?u.push({label:"Prefill",value:`${sn(e.prefillMs)}${e.promptTokensPerSecond!==void 0?` at ${Ip(e.promptTokensPerSecond)}`:""}`,hint:"provider rate over all prompt tokens, restored included"}):u.push({label:"Prefill",value:Tt}),e.cachedTokens&&(e.promptPhaseMs??e.prefillMs)!==void 0&&u.push({label:"Restored",value:`${e.cachedTokens.toLocaleString()} tok from cache`,hint:"not recomputed"}),u.push({label:"Generation",value:e.generationPhaseMs!==void 0?Ro(e.generationPhaseMs,e.generationPhaseTokens,e.generationPhaseTokensPerSecond,"tok"):Ro(e.decodeMs,e.outputTokens,e.generationTokensPerSecond,"tok")}),e.measuredSpeedCalls&&e.measuredSpeedCalls!==e.llmCalls&&u.push({label:"Speeds from",value:`${e.measuredSpeedCalls} of ${e.llmCalls} calls`}),s.push({heading:"Model",rows:u});const h=e.speculation;if(h){const b=(h.draftKinds||[]).map(E=>E.toUpperCase()).join(", "),_=[{label:"Mode",value:`${h.used?"on":"off"}${b?` · ${b}`:""}${(g=h.modes)!=null&&g.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?Tt:`${Math.round(h.acceptanceRate*100)}% · ${Ht(h.acceptedTokens)} of ${Ht(h.draftedTokens)} drafted`}];((y=h.draftLengths)!=null&&y.length||h.rounds!==void 0)&&_.push({label:"Draft length",value:`${(x=h.draftLengths)!=null&&x.length?`${h.draftLengths.join("/")} tok/round`:Tt}${h.rounds!==void 0?` · ${h.rounds.toLocaleString()} rounds`:""}`}),s.push({heading:"Speculation",rows:_})}return e.slowestToolBatch&&s.push({heading:"Tools",rows:[{label:"Total",value:`${sn(e.toolTimeMs)} · ${$s(e.toolBatches||0,"batch","batches")}`},{label:"Slowest",value:`${sn(e.slowestToolBatch.ms)} · ${Mp(e.slowestToolBatch)}`}],note:e.toolTimeIncludesApproval?"Gated calls are timed from request to result, so this includes waiting for your approval.":void 0}),n.length>1&&s.push({heading:"Per call",table:{columns:["#","Prefill","New tok/s","Gen","Gen tok/s","Cache"],rows:n.map((b,_)=>[String(_+1),b.promptMs===void 0?"—":`${sn(b.promptMs)}${b.promptSource==="rate"?"*":""}`,b.promptNewTokensPerSecond===void 0?"—":Math.round(b.promptNewTokensPerSecond).toLocaleString(),b.generationMs===void 0?"—":sn(b.generationMs),b.generationTokensPerSecond===void 0?"—":Math.round(b.generationTokensPerSecond).toLocaleString(),b.cacheOutcome||"—"])},note:n.some(b=>b.promptSource==="rate")?"* derived from the provider's prompt rate (no TTFT event).":void 0}),{kind:"time",title:"Time",headline:a===void 0?Tt:`${sn(a)} wall clock`,sections:s,footer:Go(e)}}function Mp(e){return e.tools.length===1?`${e.tools[0]} ×${e.calls}`:`${$s(e.calls,"call")} (${e.tools.join(", ")})`}function pv(e){const n=[],s=(e.toolsWaiting||0)+(e.toolsRunning||0);if(!e.toolCalls&&!s)return n.push({heading:"Outcome",rows:[{label:"Tools called",value:"none"}]}),{kind:"tools",title:"Tools",headline:"none",sections:n,footer:Go(e)};const a=[{label:"Succeeded",value:(e.toolCalls-(e.toolsFailed||0)).toLocaleString()},{label:"Failed",value:(e.toolsFailed||0).toLocaleString()}];e.toolsRunning&&a.push({label:"Running",value:e.toolsRunning.toLocaleString()}),e.toolsWaiting&&a.push({label:"Awaiting approval",value:e.toolsWaiting.toLocaleString(),hint:"not run yet — not a failure"}),n.push({heading:"Outcome",rows:a});const l=Object.entries(e.toolBreakdown||{}).sort((f,h)=>h[1].calls-f[1].calls||f[0].localeCompare(h[0]));l.length&&n.push({heading:"By tool",table:{columns:["Tool","Calls","Failed","Time"],rows:l.map(([f,h])=>[f,h.calls.toLocaleString(),h.failed.toLocaleString(),h.ms!==void 0?`${sn(h.ms)}${h.sharedBatches?" +shared":""}`:h.sharedBatches?"shared":Tt])},note:l.some(([,f])=>f.sharedBatches)?"A batch that mixed tools ran them together; its time is not split between them.":void 0});const u=l.filter(([,f])=>f.errors&&Object.keys(f.errors).length);u.length&&n.push({heading:"Failures",rows:u.map(([f,h])=>({label:f,value:Object.entries(h.errors).sort((g,y)=>y[1]-g[1]).map(([g,y])=>y>1?`${g} ×${y}`:g).join(" · ")}))});const d=[{label:"Tool time",value:e.toolTimeMs===void 0?Tt:`${sn(e.toolTimeMs)} · ${$s(e.toolBatches||0,"batch","batches")}`}];return e.slowestToolBatch&&d.push({label:"Slowest batch",value:`${sn(e.slowestToolBatch.ms)} · ${Mp(e.slowestToolBatch)}`}),n.push({heading:"Timing",rows:d,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:`${$s(e.toolCalls,"call")}${e.toolsFailed?` · ${e.toolsFailed} failed`:""}`,sections:n,footer:Go(e)}}function Lc(e,n){return e==="tokens"?fv(n):e==="time"?hv(n):pv(n)}function mv(e){const n=e.detail;return i.jsxs("div",{ref:e.panelRef,id:e.id,role:"tooltip",className:`pc-stat-detail pc-stat-detail--${n.kind}`,style:e.style,onMouseEnter:e.onMouseEnter,onMouseLeave:e.onMouseLeave,children:[i.jsxs("div",{className:"pc-stat-detail-head",children:[i.jsx("span",{className:"pc-stat-detail-title",children:n.title}),i.jsx("span",{className:"pc-stat-detail-headline",children:n.headline})]}),n.sections.map(s=>{var a;return i.jsxs("div",{className:"pc-stat-detail-section",children:[i.jsx("div",{className:"pc-stat-detail-heading",children:s.heading}),(a=s.rows)!=null&&a.length?i.jsx("dl",{className:"pc-stat-detail-rows",children:s.rows.map(l=>i.jsxs(wt.Fragment,{children:[i.jsx("dt",{children:l.label}),i.jsxs("dd",{children:[i.jsx("span",{className:l.value===Tt?"pc-stat-detail-value pc-stat-detail-value--absent":"pc-stat-detail-value",children:l.value}),l.hint?i.jsx("span",{className:"pc-stat-detail-hint",children:l.hint}):null]})]},l.label))}):null,s.table?i.jsxs("table",{className:"pc-stat-detail-table",children:[i.jsx("thead",{children:i.jsx("tr",{children:s.table.columns.map(l=>i.jsx("th",{scope:"col",children:l},l))})}),i.jsx("tbody",{children:s.table.rows.map((l,u)=>i.jsx("tr",{children:l.map((d,f)=>i.jsx("td",{children:d},f))},u))})]}):null,s.note?i.jsx("p",{className:"pc-stat-detail-note",children:s.note}):null]},s.heading)}),i.jsx("div",{className:"pc-stat-detail-foot",children:n.footer.map(s=>i.jsx("div",{children:s},s))})]})}const mr=8;function gv(e){const[n,s]=w.useState(!!e.defaultOpen),[a,l]=w.useState(null),u=w.useRef(null),d=w.useRef(null),f=w.useRef(null),h=`pc-stat-${w.useId().replace(/[^a-zA-Z0-9_-]/g,"")}`,g=w.useCallback(()=>{f.current!==null&&window.clearTimeout(f.current),f.current=null},[]),y=w.useCallback(()=>{g(),s(!0)},[g]),x=w.useCallback(()=>{g(),f.current=window.setTimeout(()=>s(!1),120)},[g]);w.useEffect(()=>g,[g]),w.useLayoutEffect(()=>{if(!n){l(null);return}const C=()=>{const j=u.current,T=d.current;if(!j||!T)return;const A=j.getBoundingClientRect(),$=T.offsetWidth,k=T.offsetHeight,P=window.innerWidth,V=window.innerHeight,H=A.top-mr-k,L=A.bottom+mr,de=H>=mr?H:L+k<=V-mr?L:Math.max(mr,V-mr-k),re=Math.min(Math.max(mr,A.left),Math.max(mr,P-mr-$));l({top:de,left:re})};return C(),window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[n]),w.useEffect(()=>{if(!n)return;const C=j=>{j.key==="Escape"&&s(!1)};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[n]);const b=typeof e.onClick=="function",_=b?"button":"span",E=n?i.jsx(mv,{detail:e.detail,id:h,panelRef:d,onMouseEnter:g,onMouseLeave:x,style:{position:"fixed",top:(a==null?void 0:a.top)??0,left:(a==null?void 0:a.left)??0,visibility:a?"visible":"hidden"}}):null;return i.jsxs(i.Fragment,{children:[i.jsxs(_,{ref:u,...b?{type:"button"}:{tabIndex:0},className:["pc-chat-stat","pc-chat-stat--detail",b?"pc-chat-stat--clickable":"",e.className].filter(Boolean).join(" "),"aria-label":`${e.label} — ${e.detail.title.toLowerCase()} details`,"aria-describedby":n?h:void 0,"data-stat-kind":e.detail.kind,onMouseEnter:y,onMouseLeave:x,onFocus:y,onBlur:()=>s(!1),onKeyDown:C=>{C.key==="Escape"&&s(!1)},onClick:b?()=>{var C;return(C=e.onClick)==null?void 0:C.call(e)}:void 0,children:[e.icon?i.jsx("span",{className:"pc-chat-stat-icon","aria-hidden":"true",children:e.icon}):null,i.jsx("span",{className:"pc-chat-stat-label",children:e.label})]}),E&&typeof document<"u"?Gh.createPortal(E,document.body):E]})}function yv(e){const n=e.totalTokens!==void 0?Lc("tokens",e):null,s=Lc("tools",e),a=e.durationMs!==void 0?Lc("time",e):null;return[...n?[{label:`${e.totalTokens.toLocaleString()} tokens`,detail:n}]:[],{label:`${e.toolCalls} ${e.toolCalls===1?"tool":"tools"}`,detail:s},...e.changedFiles.length?[{label:`${e.changedFiles.length} ${e.changedFiles.length===1?"file":"files"} changed`,title:e.changedFiles.join(`
63
+ `)}]:[],...a?[{label:`${(e.durationMs/1e3).toFixed(e.durationMs<1e4?1:0)}s`,detail:a}]:[]]}function wv(e){const n=String(e.role||"").trim().toLowerCase()||"system",s=String(e.kind||"").trim().toLowerCase(),a=String(e.level||"").trim().toLowerCase();return n==="system"&&s==="report_bug"?{label:String(e.title||"").trim()||"Bug report",icon:"warning",variant:"report_bug"}:n==="system"&&s==="report_feature"?{label:String(e.title||"").trim()||"Feature request",icon:"check",variant:"report_feature"}:n==="user"?{label:String(e.title||"").trim()||"You",icon:"user",variant:"user"}:n==="assistant"?{label:String(e.title||"").trim()||"Agent",icon:"bot",variant:"assistant"}:{label:String(e.title||"").trim()||(a==="error"?"Error":a==="warn"?"Warning":"System"),icon:a==="error"?"error":a==="warn"?"warning":"info",variant:a==="error"?"error":a==="warn"?"warn":"status"}}function Lp(e){var T;const n=e.message,s=w.useMemo(()=>wv(n),[n.kind,n.level,n.role,n.title]),a=String(n.ts||"").trim(),l=w.useMemo(()=>{if(!a)return"";const A=new Date(a);return Number.isFinite(A.getTime())?A.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):""},[a]),[u,d]=w.useState("idle"),f=w.useRef(null);w.useEffect(()=>()=>{f.current!==null&&window.clearTimeout(f.current)},[]);const h=n.live,g=!h&&typeof e.onSpeakToggle=="function"&&s.variant==="assistant"&&!!String(n.content||"").trim(),y=g&&((T=e.getSpeakState)==null?void 0:T.call(e,n))||"idle",x=y==="loading"?"loader":y==="playing"?"pause":"speaker",b=y==="loading"?"Generating audio…":y==="playing"?"Pause":y==="paused"?"Resume":"Speak (TTS)",_=e.showCopy!==!1,E=Array.isArray(e.attachments)?e.attachments:[],C=n.statistics,j=w.useMemo(()=>Array.isArray(e.stats)?e.stats:C?yv(C):[],[e.stats,C]);return n.toolActivity?i.jsx(Tp,{tool:n.toolActivity,showCopy:e.showCopy}):i.jsxs("div",{className:["pc-chat-item",`pc-chat-item--${s.variant}`,h?"pc-chat-item--live":"",e.className].filter(Boolean).join(" "),...h?{"aria-busy":!0}:{},children:[i.jsxs("div",{className:"pc-chat-header",children:[i.jsx("div",{className:"pc-chat-avatar","aria-hidden":"true",children:i.jsx(ae,{name:s.icon,size:14})}),i.jsx("span",{className:"pc-chat-role",children:s.label}),h?i.jsxs("span",{className:"pc-chat-live-indicator",title:"The reply is still being written",children:[i.jsx("span",{className:"pc-chat-live-dot","aria-hidden":"true"}),"streaming"]}):null,h!=null&&h.caption?i.jsx("span",{className:"pc-chat-live-caption",children:h.caption}):null,i.jsx("span",{className:"pc-chat-header-spacer"}),l?i.jsx("span",{className:"pc-chat-time",children:l}):null,i.jsxs("div",{className:"pc-chat-header-actions",children:[g?i.jsx("button",{className:"pc-chat-icon-btn",type:"button","aria-label":b,title:b,onClick:()=>{var A;return(A=e.onSpeakToggle)==null?void 0:A.call(e,n)},children:i.jsx(ae,{name:x,size:22})}):null,_?i.jsx("button",{className:`pc-chat-icon-btn ${u!=="idle"?`pc-chat-icon-btn--${u}`:""}`.trim(),type:"button","aria-label":"Copy message",title:u==="idle"?"Copy":u==="copied"?"Copied":"Copy failed",onClick:async()=>{const A=await wu(String(n.content||""));d(A?"copied":"failed"),f.current!==null&&window.clearTimeout(f.current),f.current=window.setTimeout(()=>d("idle"),900)},children:i.jsx(ae,{name:"copy",size:22})}):null]})]}),h!=null&&h.reasoning?i.jsxs("details",{className:"pc-chat-thinking",children:[i.jsx("summary",{children:"Thinking"}),i.jsx("div",{className:"pc-chat-thinking-body",children:h.reasoning})]}):null,!h||String(n.content||"").trim()?i.jsx("div",{className:"pc-chat-body",children:i.jsx(Ep,{text:String(n.content||""),renderMarkdown:e.renderMarkdown,jsonCollapseAfterDepth:e.jsonCollapseAfterDepth,images:e.images||(s.variant==="user"?"inline":"link"),inlineImage:e.inlineImage})}):null,E.length?i.jsx("div",{className:"pc-chat-attachments","aria-label":"Attachments",children:E.slice(0,24).map((A,$)=>{const k=String(A.label||"").trim()||"attachment",P=String(A.target||"").trim(),V=String(A.title||"").trim(),H=!!A.disabled||typeof A.onClick!="function";return i.jsxs("button",{type:"button",className:"pc-chat-attachment-chip",title:V||k,onClick:H?void 0:A.onClick,disabled:H,children:[i.jsx(ae,{name:"paperclip",size:14}),P?i.jsx("span",{className:`pc-chat-attachment-target pc-chat-attachment-target--${P}`,children:P}):null,i.jsx("span",{className:"pc-chat-attachment-name",children:k})]},A.id||`${k}:${$}`)})}):null,j.length?i.jsx("div",{className:"pc-chat-stats","aria-label":"Stats",children:j.slice(0,12).map((A,$)=>{const k=String(A.label||"").trim();if(!k)return null;if(A.detail)return i.jsx(gv,{label:k,detail:A.detail,icon:A.icon,onClick:A.onClick},A.id||`${k}:${$}`);const P=String(A.title||"").trim(),V=typeof A.onClick=="function",H=V?"button":"span";return i.jsxs(H,{...V?{type:"button"}:{},className:["pc-chat-stat",V?"pc-chat-stat--clickable":""].filter(Boolean).join(" "),title:P||void 0,onClick:V?()=>{var L;return(L=A.onClick)==null?void 0:L.call(A)}:void 0,children:[A.icon?i.jsx("span",{className:"pc-chat-stat-icon","aria-hidden":"true",children:A.icon}):null,i.jsx("span",{className:"pc-chat-stat-label",children:k})]},A.id||`${k}:${$}`)})}):null]})}function vv(e,n){const s=Math.max(0,Math.trunc(n));return e.scrollHeight-e.scrollTop-e.clientHeight<=s}function _v(e){const n=typeof e.autoScrollThresholdPx=="number"&&Number.isFinite(e.autoScrollThresholdPx)?e.autoScrollThresholdPx:120,s=e.autoScroll!==!1,a=w.useRef(null),l=w.useRef(null),[u,d]=w.useState(!0),f=w.useMemo(()=>Array.isArray(e.messages)?e.messages:[],[e.messages]),h=w.useMemo(()=>{var x;const y=[];for(const b of f){const _=y[y.length-1];b.toolActivity&&((x=_==null?void 0:_[0])!=null&&x.toolActivity)&&_[0].runId===b.runId?_.push(b):y.push([b])}return y},[f]);w.useEffect(()=>{if(!s)return;const y=a.current;if(!y)return;const x=()=>{d(vv(y,n))};return y.addEventListener("scroll",x,{passive:!0}),x(),()=>y.removeEventListener("scroll",x)},[s,n]);const g=w.useMemo(()=>{let y=0;for(const x of f)y+=String(x.content??"").length;return`${f.length}:${y}:${String(e.afterKey??"")}`},[f,e.afterKey]);return w.useEffect(()=>{if(!s||!u)return;const y=a.current;y&&(y.scrollTop=y.scrollHeight)},[s,u,g]),i.jsxs("div",{ref:a,className:["pc-chat-thread",e.className].filter(Boolean).join(" "),children:[f.length?null:e.empty||null,h.map((y,x)=>{var E;const b=y[0],_=String(b.id||"")||String(b.ts||"")+":"+String(b.role||"")+":"+x;return b.toolActivity?i.jsx(Rp,{tools:y.map(C=>C.toolActivity),showCopy:(E=e.messageProps)==null?void 0:E.showCopy},_):i.jsx(Lp,{message:b,...e.messageProps||{}},_)}),e.after,i.jsx("div",{ref:l})]})}const xv=wt.forwardRef(function(n,s){const a=typeof n.rows=="number"&&Number.isFinite(n.rows)?Math.max(1,Math.trunc(n.rows)):3,l=!!n.disabled,u=!!n.busy,d=!l&&!u&&!!String(n.value||"").trim();return i.jsxs("div",{className:["pc-composer",n.className].filter(Boolean).join(" "),children:[n.leading,i.jsx("textarea",{ref:s,className:["pc-composer__textarea",n.textareaClassName].filter(Boolean).join(" "),value:n.value,onChange:f=>n.onChange(f.target.value),rows:a,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",autoComplete:"off",placeholder:n.placeholder||"","aria-label":n.ariaLabel||n.placeholder||"Message",disabled:l,autoFocus:!!n.autoFocus,onPaste:n.onPaste,onKeyDown:f=>{f.key!=="Enter"||f.shiftKey||f.nativeEvent.isComposing||f.keyCode===229||(f.preventDefault(),d&&n.onSubmit())}}),i.jsxs("div",{className:"pc-composer__row",children:[i.jsx("div",{className:"pc-composer__actions",children:n.actions}),i.jsx("button",{type:"button",className:n.sendButtonClassName||"pc-btn",disabled:!d,onClick:()=>n.onSubmit(),children:u?n.busyLabel||"Thinking…":n.sendLabel||"Send"})]}),n.overlay]})}),et=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{},zo=e=>Array.isArray(e)?e.map(et):[],Ge=e=>typeof e=="string"?e:"",ca=e=>Ge(e.runtime_call_id||e.call_uid),ua=e=>Ge(e.call_id||e.id);function Pp(e,n){const s=n.record,a=et(s.effect);if(a.type!=="tool_calls")return[];const l=et(s.result),u=zo(et(a.payload).tool_calls),d=u.length||s.status!=="waiting"?u:zo(et(et(l.wait).details).tool_calls),f=zo(l.results),h=d.length?d:f,g=[];return h.forEach((y,x)=>{let b=ca(y)?f.filter(V=>ca(V)===ca(y)):[];!b.length&&ua(y)&&d.filter(V=>ua(V)===ua(y)).length===1&&(b=f.filter(V=>ua(V)===ua(y)));const _=d.length?b.length===1?b[0]:d.length===f.length?f[x]:{}:y,E=ca(y)||ca(_)||`${Ge(s.idempotency_key)||Ge(s.step_id)||n.cursor}:${x}`,C=`${n.runId}:${E}`,j=e.get(C),T=Ge(y.name||_.name)||(j==null?void 0:j.name);if(!T)return;const A=s.status==="completed"||s.status==="failed",$=s.status==="failed"||_.success===!1||!!_.error,k=y.arguments??_.arguments??(j==null?void 0:j.arguments),P={...j,id:C,runId:n.runId,name:T,arguments:k,status:A?$?"failed":"completed":s.status==="waiting"?"waiting":"running",...typeof _.success=="boolean"?{success:_.success}:{},..._.output!==void 0||_.result!==void 0?{output:_.output??_.result}:{},..._.error?{error:String(_.error)}:{},startedAt:(j==null?void 0:j.startedAt)||Ge(s.started_at)||void 0,endedAt:A&&Ge(s.ended_at)||(j==null?void 0:j.endedAt)};j&&["completed","failed"].includes(j.status)&&!A||(e.set(C,P),g.push(P))}),g}function gi(e){if(e==null||e===""||typeof e=="boolean")return;const n=Number(e);return Number.isFinite(n)&&n>=0?n:void 0}function Jn(e,n){for(const s of n){const a=e==null?void 0:e[s];if(a==null||a===""||typeof a=="boolean")continue;const l=Number(a);if(Number.isFinite(l)&&l>=0)return Math.trunc(l)}}function Op(e){if(typeof e=="string")try{return et(JSON.parse(e))}catch{return{}}return et(e)}function ui(e,n){if(n===void 0||n==="")return e;const s=e||[];return s.includes(n)||s.push(n),s}function bv(e){return Jn(e,["reasoning_tokens","thinking_tokens"])??Jn(et(e.completion_tokens_details),["reasoning_tokens"])??Jn(et(e.output_tokens_details),["reasoning_tokens"])}function kv(e){const n=et(typeof e=="string"&&e.trim().startsWith("{")?Op(e):e);return Ge(n.error_class)}function jv(e){const n=new Map;for(const s of e){const a=s.record;if(et(a.effect).type!=="emit_event")continue;const l=et(a.result);if(Ge(l.name)!=="abstract.progress")continue;const u=et(l.payload);if(Ge(u.kind)!=="llm"||!Ge(u.step_id))continue;const d=`${Ge(u.run_id)||s.runId}:${Ge(u.step_id)}`,f=n.get(d)||{},h=gi(u.ttft_s);h!==void 0&&(f.ttftS=h),f.provider=f.provider||Ge(u.provider)||void 0,f.model=f.model||Ge(u.model)||void 0,n.set(d,f)}return n}function Wo(e){var C,j,T,A;const n=new Map,s=new Set,a=new Set,l={llmCalls:0,toolCalls:0,changedFiles:[]};let u=1/0,d=-1/0,f=!1,h=0,g=0,y=0;const x=jv(e),b=[],_=new Set;for(const $ of e){const k=$.record,P=`${$.runId}:${k.step_id||$.cursor}:${k.status}`;if(s.has(P))continue;s.add(P);for(const X of[k.started_at,k.ended_at]){const $e=Date.parse(Ge(X));Number.isFinite($e)&&(u=Math.min(u,$e),d=Math.max(d,$e))}for(const X of Pp(n,$))X.status==="waiting"&&_.add(X.id);if(et(k.effect).type!=="llm_call"||k.status!=="completed")continue;l.llmCalls+=1;const V=et(k.result),H=et(V.output),L=et(V.usage||V.token_usage||V.tokens||H.usage||H.token_usage||H.tokens),de=Jn(L,["input_tokens","prompt_tokens","prompt","input","in"]),re=Jn(L,["output_tokens","completion_tokens","completion","output","out"]),Q=Jn(L,["total_tokens","total"])??(de!==void 0||re!==void 0?(de||0)+(re||0):void 0);Q!==void 0&&(de===void 0||re===void 0||de+re!==Q)&&(f=!0),de!==void 0&&(l.inputTokens=(l.inputTokens||0)+de),re!==void 0&&(l.outputTokens=(l.outputTokens||0)+re),Q!==void 0&&(l.totalTokens=(l.totalTokens||0)+Q);const U=gi(V.gen_time??H.gen_time);U!==void 0&&(l.genTimeMs=(l.genTimeMs||0)+U,l.timedCalls=(l.timedCalls||0)+1);const J=et(V.metadata||H.metadata),fe=et(J.performance),ce=gi(fe.prompt_tokens_per_second),ye=gi(fe.generation_tokens_per_second),ve=et(J.prompt_cache),q=gi(ve.cached_tokens),oe=gi(ve.fed_tokens);if(ce!==void 0||ye!==void 0){if(l.measuredSpeedCalls=(l.measuredSpeedCalls||0)+1,ce!==void 0&&ce>0&&(l.promptTokensPerSecond=(l.promptTokensPerSecond||0)+ce,de!==void 0)){const X=de/ce*1e3;l.prefillMs=(l.prefillMs||0)+X,oe!==void 0&&(h+=oe,g+=X)}ye!==void 0&&ye>0&&(l.generationTokensPerSecond=(l.generationTokensPerSecond||0)+ye,re!==void 0&&(l.decodeMs=(l.decodeMs||0)+re/ye*1e3))}if(q!==void 0||oe!==void 0){l.measuredCacheCalls=(l.measuredCacheCalls||0)+1,l.cachedTokens=(l.cachedTokens||0)+(q||0),l.fedTokens=(l.fedTokens||0)+(oe||0);const X=Ge(ve.outcome);if(X){const $e=l.cacheOutcomes||[];$e.includes(X)||$e.push(X),l.cacheOutcomes=$e}}const G=Ge(k.step_id)||void 0,N=G&&x.get(`${$.runId}:${G}`)||{},B=et(V.route),F={runId:$.runId};G&&(F.stepId=G),Ge(k.started_at)&&(F.startedAt=Ge(k.started_at));const W=Ge(V.model||H.model)||Ge(B.model)||N.model,ie=Ge(B.provider)||Ge(et(J._provider_request).provider)||N.provider||Ge(V.provider);W&&(F.model=W),ie&&(F.provider=ie),W&&(l.models=ui(l.models,W)),ie&&(l.providers=ui(l.providers,ie)),(Q===void 0||de!==void 0&&re!==void 0&&de+re===Q)&&(de!==void 0&&(F.inputTokens=de),re!==void 0&&(F.outputTokens=re)),Q!==void 0&&(F.totalTokens=Q);const le=bv(L);le!==void 0&&(F.reasoningTokens=le,l.reasoningTokens=(l.reasoningTokens||0)+le),q!==void 0&&(F.cachedTokens=q),oe!==void 0&&(F.fedTokens=oe),Ge(ve.outcome)&&(F.cacheOutcome=Ge(ve.outcome)),Ge(ve.backend)&&(F.cacheBackend=Ge(ve.backend),l.cacheBackends=ui(l.cacheBackends,F.cacheBackend)),U!==void 0&&(F.genTimeMs=U),ce!==void 0&&ce>0&&(F.promptTokensPerSecond=ce),ye!==void 0&&ye>0&&(F.generationTokensPerSecond=ye),N.ttftS!==void 0?(F.ttftMs=N.ttftS*1e3,F.promptMs=F.ttftMs,F.promptSource="ttft",l.ttftMs=(l.ttftMs||0)+F.ttftMs,l.ttftCalls=(l.ttftCalls||0)+1):F.promptTokensPerSecond!==void 0&&de!==void 0&&(F.promptMs=de/F.promptTokensPerSecond*1e3,F.promptSource="rate"),F.promptMs!==void 0&&(l.promptPhaseMs=(l.promptPhaseMs||0)+F.promptMs,l.promptPhaseCalls=(l.promptPhaseCalls||0)+1,oe!==void 0&&F.promptMs>0&&(F.promptNewTokensPerSecond=oe/(F.promptMs/1e3),l.promptPhaseNewTokens=(l.promptPhaseNewTokens||0)+oe,y+=F.promptMs)),F.ttftMs!==void 0&&U!==void 0&&U>=F.ttftMs?F.generationMs=U-F.ttftMs:F.generationTokensPerSecond!==void 0&&re!==void 0&&(F.generationMs=re/F.generationTokensPerSecond*1e3),F.generationMs!==void 0&&re!==void 0&&(l.generationPhaseMs=(l.generationPhaseMs||0)+F.generationMs,l.generationPhaseTokens=(l.generationPhaseTokens||0)+re);const he=et(J.speculation);if(Object.keys(he).length){const X={};Ge(he.mode)&&(X.mode=Ge(he.mode)),typeof he.used=="boolean"&&(X.used=he.used),Ge(he.draft_kind)&&(X.draftKind=Ge(he.draft_kind));const $e=Jn(he,["accepted_tokens"]),We=Jn(he,["drafted_tokens"]),ke=Jn(he,["rounds"]),Y=Jn(he,["num_draft_tokens"]);$e!==void 0&&(X.acceptedTokens=$e),We!==void 0&&(X.draftedTokens=We),$e!==void 0&&We&&(X.acceptanceRate=$e/We),ke!==void 0&&(X.rounds=ke),Y!==void 0&&(X.draftLength=Y),F.speculation=X;const ee=l.speculation||(l.speculation={calls:0,used:0});ee.calls+=1,X.used&&(ee.used+=1),X.mode&&(ee.modes=ui(ee.modes,X.mode)),X.draftKind&&(ee.draftKinds=ui(ee.draftKinds,X.draftKind)),$e!==void 0&&We!==void 0&&(ee.acceptedTokens=(ee.acceptedTokens||0)+$e,ee.draftedTokens=(ee.draftedTokens||0)+We),ke!==void 0&&(ee.rounds=(ee.rounds||0)+ke),Y!==void 0&&(ee.draftLengths=ui(ee.draftLengths,Y))}b.push(F)}b.length&&(b.every($=>$.startedAt)&&b.sort(($,k)=>Date.parse($.startedAt)-Date.parse(k.startedAt)),l.modelCalls=b),y>0&&l.promptPhaseNewTokens!==void 0&&(l.promptPhaseTokensPerSecond=l.promptPhaseNewTokens/(y/1e3)),l.generationPhaseMs&&l.generationPhaseTokens!==void 0&&(l.generationPhaseTokensPerSecond=l.generationPhaseTokens/(l.generationPhaseMs/1e3)),(C=l.speculation)!=null&&C.draftedTokens&&(l.speculation.acceptanceRate=(l.speculation.acceptedTokens||0)/l.speculation.draftedTokens),l.measuredSpeedCalls&&(l.promptTokensPerSecond!==void 0&&(l.promptTokensPerSecond/=l.measuredSpeedCalls),l.generationTokensPerSecond!==void 0&&(l.generationTokensPerSecond/=l.measuredSpeedCalls)),g>0&&(l.prefillNewTokens=h,l.prefillNewTokensPerSecond=h/(g/1e3));const E=new Map;for(const $ of n.values()){if($.status==="waiting"){l.toolsWaiting=(l.toolsWaiting||0)+1;continue}if($.status==="running"){l.toolsRunning=(l.toolsRunning||0)+1;continue}if(!["completed","failed"].includes($.status))continue;l.toolCalls+=1;const k=$.status==="failed";k&&(l.toolsFailed=(l.toolsFailed||0)+1);const P=l.toolBreakdown||(l.toolBreakdown={}),V=P[$.name]||(P[$.name]={calls:0,failed:0});if(V.calls+=1,k){V.failed+=1;const Q=kv($.output);Q&&((V.errors||(V.errors={}))[Q]=(((j=V.errors)==null?void 0:j[Q])||0)+1)}const H=Date.parse(Ge($.startedAt)),L=Date.parse(Ge($.endedAt));if(Number.isFinite(H)&&Number.isFinite(L)&&L>=H){const Q=`${$.runId}|${$.startedAt}|${$.endedAt}`,U=E.get(Q)||{ms:L-H,calls:0,names:new Map,waited:!1};U.calls+=1,U.names.set($.name,(U.names.get($.name)||0)+1),_.has($.id)&&(U.waited=!0),E.set(Q,U)}if($.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($.name))continue;const de=Op($.arguments),re=Ge(de.destination||de.destination_path||de.file_path||de.path||de.filename);re&&a.add(re)}for(const $ of E.values()){l.toolBatches=(l.toolBatches||0)+1,l.toolTimeMs=(l.toolTimeMs||0)+$.ms,$.waited&&(l.toolTimeIncludesApproval=!0);const k=[...$.names.keys()].sort();(!l.slowestToolBatch||$.ms>l.slowestToolBatch.ms)&&(l.slowestToolBatch={ms:$.ms,calls:$.calls,tools:k});const P=(T=l.toolBreakdown)==null?void 0:T[k[0]];if(k.length===1&&P)P.ms=(P.ms||0)+$.ms;else for(const V of k){const H=(A=l.toolBreakdown)==null?void 0:A[V];H&&(H.sharedBatches=(H.sharedBatches||0)+1)}}return l.changedFiles=[...a],f&&(delete l.inputTokens,delete l.outputTokens),Number.isFinite(u)&&Number.isFinite(d)&&(l.durationMs=Math.max(0,d-u)),{tools:[...n.values()],statistics:l}}function Sv(e){const n=et(et(e).ledgers);return Object.entries(n).flatMap(([s,a])=>zo(et(a).items).map((l,u)=>({runId:s,cursor:Number(l.cursor)||u+1,record:Object.keys(et(l.record)).length?et(l.record):l})))}const Pc=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{};function Nv(e){var C,j,T,A;const{tools:n,statistics:s}=Wo(e.records),a={toolCalls:s.toolCalls,totalTokens:s.totalTokens,startedAt:String(((C=e.run)==null?void 0:C.created_at)||"")||void 0},l=($,k,P)=>({...a,label:$,detail:k,tone:P});if(e.loading)return l("Loading conversation","Restoring saved activity","neutral");if(["completed","failed","cancelled"].includes(e.status))return l(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 l(e.connection==="reconnecting"?"Reconnecting":"Disconnected",String(e.error||"Live activity is unavailable"),"waiting");if(e.status==="paused"||((T=e.run)==null?void 0:T.paused)===!0)return l("Paused","Resume when you’re ready","waiting");const u=Pc((A=e.interaction)==null?void 0:A.wait),d=Pc(u.details),f=d.kind==="tool_approval"||d.mode==="approval_required",h=f&&e.toolApprovalGranted===!0;if(f&&!h)return l("Approval needed","Review the tool requests below","waiting");if(!f&&["user","ask_user"].includes(u.reason))return l("Your answer is needed",String(u.prompt||"The workflow has a question for you"),"waiting");if(!f&&(u.reason==="event"||String(u.wait_key||"").startsWith("evt:")))return l("Waiting for an event",String(u.prompt||"Listening for the workflow’s trigger"),"waiting");const g=n.filter($=>{var k;return $.status==="running"||h&&$.status==="waiting"&&$.runId===((k=e.interaction)==null?void 0:k.runId)});if(g.length)return l(g.length===1?"Running a tool":`Running ${g.length} tools`,[...new Set(g.map($=>$.name))].join(" · "),"working");const y=new Map;for(const $ of e.records){const k=`${$.runId}:${$.record.step_id||$.record.idempotency_key||$.cursor}`,P=y.get(k);P&&["completed","failed"].includes(String(P.record.status))||y.set(k,$)}if([...y.values()].reverse().find($=>Pc($.record.effect).type==="llm_call"&&["started","running"].includes(String($.record.status))))return l("Thinking","Generating the next response","working");const b=e.displayStatus.trim(),_=!/^(completed|complete|done|finished|ready|success|succeeded|failed|running|working|waiting|thinking|idle|paused|stopped|cancelled)$/i.test(b)&&!b.startsWith("{")?b:"",E=n[n.length-1];return l(e.status==="idle"?"Ready":"Working",_||(E?`Last tool: ${E.name} · ${E.status==="failed"?"failed":E.status==="completed"?"done":"waiting"}`:"Following the workflow"),e.status==="idle"?"neutral":"working")}function Io(e){if(!e)return!1;for(let n=0;n<e.length;n+=1)if(e[n]==="Files")return!0;return!1}function dh(e){var a;const n=e==null?void 0:e.items;if(!n||!n.length)return null;let s=0;for(let l=0;l<n.length;l+=1)((a=n[l])==null?void 0:a.kind)==="file"&&(s+=1);return s>0?s:null}function fh(e){return e===1?"Drop file to attach":typeof e=="number"&&e>1?`Drop ${e} files to attach`:"Drop files to attach"}function Dp(e){const n=[],s=[],a=e==null?void 0:e.items;if(a&&a.length){for(let u=0;u<a.length;u+=1){const d=a[u];if(!d||d.kind!=="file")continue;const f=typeof d.webkitGetAsEntry=="function"?d.webkitGetAsEntry():null,h=typeof d.getAsFile=="function"?d.getAsFile():null;f!=null&&f.isDirectory?s.push(f.name||(h==null?void 0:h.name)||"folder"):h&&n.push(h)}return{files:n,folders:s}}const l=e==null?void 0:e.files;if(l)for(let u=0;u<l.length;u+=1)l[u]&&n.push(l[u]);return{files:n,folders:s}}function Cv(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 Ev={"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/heic":"heic","image/tiff":"tiff","image/bmp":"bmp"};function da(e){return String(e).padStart(2,"0")}function $v(e,n,s){const a=String(e||"").trim();if(a&&!/^image\.(png|jpe?g|gif|webp|heic|tiff?|bmp)$/i.test(a))return a;const l=Ev[String(n||"").toLowerCase()]||a.split(".").pop()||"bin",u=`${s.getFullYear()}-${da(s.getMonth()+1)}-${da(s.getDate())} at ${da(s.getHours())}.${da(s.getMinutes())}.${da(s.getSeconds())}`;return`${String(n||"").startsWith("image/")||!a?"Pasted image":"Pasted file"} ${u}.${l}`}function Av(e,n=new Date){if(!e)return[];const s=e.types?Array.from(e.types):[];if(s.includes("text/plain")&&s.includes("text/html"))return[];const{files:a}=Dp(e);return a.map(l=>{const u=$v(l.name,l.type,n);return u===l.name?l:new File([l],u,{type:l.type,lastModified:l.lastModified})})}class Tv{constructor(n=1200){this.staleMs=n,this.depth=0,this.lastSeen=0}enter(n){this.depth+=1,this.lastSeen=n}over(n){this.depth===0&&(this.depth=1),this.lastSeen=n}leave(n){return this.depth=Math.max(0,this.depth-1),this.lastSeen=n,this.depth>0}reset(){this.depth=0}active(n){return this.depth>0&&n-this.lastSeen<this.staleMs}}function Rv(e,n){if(e.kind==="ask-user"){if(n.kind==="choice"||n.kind==="free-text")return e.onSubmit(n.answer);throw new Error("Invalid submission for ask-user interaction")}if(e.kind==="tool-approval"){if(n.kind==="approve")return e.onApprove();if(n.kind==="deny")return e.onDeny();if(n.kind==="approve-all"&&e.onApproveAll)return e.onApproveAll();throw new Error("Invalid submission for tool-approval interaction")}if(n.kind==="event")return e.onSend(n.payload);throw new Error("Invalid submission for event-wait interaction")}function Iv(e){return(e instanceof Error?e.message:String(e||"Unknown error")).trim()||"Unknown error"}function Mv(e){return i.jsxs("div",{className:"pc-workflow-interaction__error",role:"alert",children:[i.jsxs("span",{children:["Could not complete that action: ",e.message]}),i.jsx("button",{type:"button",className:"pc-workflow-interaction__retry",onClick:e.onRetry,disabled:e.disabled,children:"Try again"})]})}function Lv(e){var H;const n=e.interaction,[s,a]=w.useState(""),[l,u]=w.useState(()=>n.kind==="event-wait"&&n.initialPayload||""),[d,f]=w.useState(null),[h,g]=w.useState(!1),[y,x]=w.useState(""),[b,_]=w.useState(null),E=`${n.kind}:${n.id}`,C=w.useRef(E),j=w.useRef(!1),T=w.useRef(!1),A=w.useRef(!0),$=w.useRef(0);C.current!==E&&(C.current=E,j.current=!1,T.current=!1,$.current+=1);const k=!!e.disabled||d!==null||h||j.current||T.current,P=async(L,de)=>{var U;if(e.disabled||j.current||T.current)return;const re=E,Q=++$.current;j.current=!0,_(null),x(""),f(L);try{if(await de(),!A.current||C.current!==re||$.current!==Q)return;T.current=!0,g(!0),x("Response sent. Waiting for the workflow to continue.")}catch(J){if(!A.current||C.current!==re||$.current!==Q)return;_({submission:L,message:Iv(J)}),x("The action failed. You can try again."),(U=e.onError)==null||U.call(e,J)}finally{if(!A.current||C.current!==re||$.current!==Q)return;j.current=!1,f(null)}};w.useEffect(()=>{a(""),u(n.kind==="event-wait"&&n.initialPayload||""),_(null),f(null),g(!1),x("")},[E]),w.useEffect(()=>(A.current=!0,()=>{A.current=!1,$.current+=1,j.current=!1}),[]);const V=()=>{b&&P(b.submission,()=>Rv(n,b.submission))};return i.jsxs("section",{className:"pc-workflow-interaction","aria-labelledby":`pc-workflow-interaction-${E}`,children:[i.jsxs("div",{className:"pc-workflow-interaction__heading",children:[i.jsx(ae,{name:n.kind==="tool-approval"?"warning":n.kind==="event-wait"?"history":"info",size:16}),i.jsxs("div",{children:[i.jsx("h3",{tabIndex:-1,id:`pc-workflow-interaction-${E}`,children:n.title||(n.kind==="tool-approval"?"Tool approval required":"Input required")}),n.description?i.jsx("div",{className:"pc-workflow-interaction__description",children:n.description}):null]})]}),n.kind==="ask-user"?i.jsxs("div",{className:"pc-workflow-interaction__body",children:[i.jsx("div",{className:"pc-workflow-interaction__prompt",children:n.prompt}),(H=n.choices)!=null&&H.length?i.jsx("div",{className:"pc-workflow-interaction__choices","aria-label":"Choices",children:n.choices.map(L=>i.jsxs("button",{type:"button",className:"pc-workflow-interaction__choice",disabled:k||L.disabled,onClick:()=>void P({kind:"choice",answer:L.id},()=>n.onSubmit(L.id)),children:[i.jsx("span",{children:L.label}),L.description?i.jsx("small",{children:L.description}):null]},L.id))}):null,n.allowFreeText!==!1?i.jsxs("div",{className:"pc-workflow-interaction__entry",children:[i.jsx("textarea",{"aria-label":"Response",value:s,onChange:L=>a(L.target.value),placeholder:n.freeTextPlaceholder||"Type a response",rows:2,disabled:k,onKeyDown:L=>{L.key!=="Enter"||L.shiftKey||L.nativeEvent.isComposing||L.keyCode===229||(L.preventDefault(),s.trim()&&P({kind:"free-text",answer:s},()=>n.onSubmit(s)))}},`${E}:text`),i.jsx("button",{type:"button",className:"pc-btn",disabled:k||!s.trim(),onClick:()=>void P({kind:"free-text",answer:s},()=>n.onSubmit(s)),children:(d==null?void 0:d.kind)==="free-text"?"Sending…":n.submitLabel||"Submit"})]}):null]}):n.kind==="tool-approval"?i.jsxs("div",{className:"pc-workflow-interaction__body",children:[i.jsxs("div",{className:"pc-workflow-interaction__prompt",children:["Allow ",i.jsx("strong",{children:n.toolName})," to run?"]}),n.detail?i.jsx("div",{className:"pc-workflow-interaction__detail",children:n.detail}):null,i.jsxs("div",{className:"pc-workflow-interaction__buttons",children:[i.jsx("button",{type:"button",className:"pc-workflow-interaction__deny",disabled:k,onClick:()=>void P({kind:"deny"},n.onDeny),children:(d==null?void 0:d.kind)==="deny"?"Denying…":n.denyLabel||"Deny"}),i.jsx("button",{type:"button",className:"pc-btn",disabled:k,onClick:()=>void P({kind:"approve"},n.onApprove),children:(d==null?void 0:d.kind)==="approve"?"Approving…":n.approveLabel||"Approve"}),n.onApproveAll?i.jsx("button",{type:"button",className:"pc-workflow-interaction__allow-all",disabled:k,onClick:()=>void P({kind:"approve-all"},n.onApproveAll),children:(d==null?void 0:d.kind)==="approve-all"?"Approving…":n.approveAllLabel||"Allow all"}):null]}),n.onApproveAll&&n.approveAllDescription?i.jsx("p",{className:"pc-workflow-interaction__scope",children:n.approveAllDescription}):null]}):i.jsxs("div",{className:"pc-workflow-interaction__body",children:[i.jsx("div",{className:"pc-workflow-interaction__prompt",children:n.prompt}),i.jsxs("label",{className:"pc-workflow-interaction__entry",children:[i.jsx("span",{children:n.payloadLabel||(n.eventName?`Payload for ${n.eventName}`:"Event payload")}),i.jsx("textarea",{value:l,onChange:L=>u(L.target.value),placeholder:n.payloadPlaceholder||"Enter payload",rows:2,"aria-label":n.payloadLabel||(n.eventName?`Payload for ${n.eventName}`:"Event payload"),disabled:k},`${E}:payload`)]}),i.jsx("div",{className:"pc-workflow-interaction__buttons",children:i.jsx("button",{type:"button",className:"pc-btn",disabled:k,onClick:()=>void P({kind:"event",payload:l},()=>n.onSend(l)),children:(d==null?void 0:d.kind)==="event"?"Sending…":n.sendLabel||"Send event"})})]}),b?i.jsx(Mv,{message:b.message,onRetry:V,disabled:k}):null,i.jsx("div",{className:"pc-workflow-interaction__outcome","aria-live":"polite",children:y})]})}function Mo(e){return(e instanceof Error?e.message:String(e||"Unknown error")).trim()||"Unknown error"}function Pv(e){const[n,s]=w.useState(!1),[a,l]=w.useState(!1),[u,d]=w.useState(!1),[f,h]=w.useState(null),g=w.useRef(!0),y=w.useRef(!1),x=w.useRef(!1),b=w.useRef(!1),_=w.useRef(0),E=w.useRef(0),C=w.useRef(0);w.useEffect(()=>(g.current=!0,()=>{g.current=!1,_.current+=1,E.current+=1,C.current+=1,y.current=!1,x.current=!1,b.current=!1}),[]);const j=!!e.blockedNotice,T=!!e.disabled||j,A=!!e.busy||n,$=n||!!e.busy&&!e.sendWhileBusy,k=e.stopState||null,P=(k==null?void 0:k.phase)==="stopping",V=typeof e.onFiles=="function",H=w.useRef(null),[L,de]=w.useState(null),[re,Q]=w.useState(""),U=w.useRef(e.onFiles);U.current=e.onFiles;const J=w.useRef(T);J.current=T;const fe=async(F,W)=>{const ie=U.current;if(ie){if(J.current){h({action:"attach",message:"attachments are unavailable right now."});return}if(W.length)h({action:"attach",message:Cv(W)});else if(F.length)h(null);else{h({action:"attach",message:"the drop contained no files."});return}if(F.length){Q(`Attaching ${F.length} ${F.length===1?"file":"files"}…`);try{await ie(F)}catch(le){g.current&&h({action:"attach",message:Mo(le)})}}}},ce=w.useRef(fe);ce.current=fe,w.useEffect(()=>{if(!V||typeof window>"u")return;const F=new Tv;let W=0;const ie=ee=>!!(H.current&&ee instanceof Node&&H.current.contains(ee)),le=()=>{F.reset(),W&&window.clearInterval(W),W=0,de(null)},he=()=>{W||(W=window.setInterval(()=>{F.active(Date.now())||le()},250))},X=ee=>{var we;if(!Io((we=ee.dataTransfer)==null?void 0:we.types))return;F.enter(Date.now());const pe=ie(ee.target),Oe=dh(ee.dataTransfer);de(Pe=>Pe&&Pe.over===pe&&Pe.count===(Oe??Pe.count)?Pe:{count:Oe??(Pe==null?void 0:Pe.count)??null,over:pe}),he()},$e=ee=>{var Oe;if(!Io((Oe=ee.dataTransfer)==null?void 0:Oe.types))return;ee.preventDefault(),F.over(Date.now());const pe=ie(ee.target);ee.dataTransfer&&(ee.dataTransfer.dropEffect=pe&&!J.current?"copy":"none"),de(we=>we&&we.over===pe?we:{count:(we==null?void 0:we.count)??dh(ee.dataTransfer),over:pe}),he()},We=ee=>{var pe;Io((pe=ee.dataTransfer)==null?void 0:pe.types)&&(F.leave(Date.now())||le())},ke=ee=>{var Be;if(!Io((Be=ee.dataTransfer)==null?void 0:Be.types))return;const pe=ie(ee.target),Oe=ee.defaultPrevented&&!pe;if(ee.preventDefault(),le(),Oe)return;if(!pe){h({action:"attach",message:"drop files on the conversation to attach them."});return}const{files:we,folders:Pe}=Dp(ee.dataTransfer);ce.current(we,Pe)},Y=ee=>{ee.key==="Escape"&&F.depth>0&&le()};return window.addEventListener("dragenter",X),window.addEventListener("dragover",$e),window.addEventListener("dragleave",We),window.addEventListener("drop",ke),window.addEventListener("dragend",le),window.addEventListener("blur",le),window.addEventListener("keydown",Y),()=>{window.removeEventListener("dragenter",X),window.removeEventListener("dragover",$e),window.removeEventListener("dragleave",We),window.removeEventListener("drop",ke),window.removeEventListener("dragend",le),window.removeEventListener("blur",le),window.removeEventListener("keydown",Y),W&&window.clearInterval(W)}},[V]);const ye=F=>{if(!V||T)return;const W=Av(F.clipboardData);W.length&&(F.preventDefault(),fe(W,[]))},ve=L?i.jsxs("div",{className:["pc-workflow-chat__dropzone",L.over?"is-over":"",T?"is-disabled":""].filter(Boolean).join(" "),"aria-hidden":"true",children:[i.jsx("span",{className:"pc-workflow-chat__dropzone-icon",children:i.jsx(ae,{name:"paperclip",size:18})}),i.jsxs("span",{className:"pc-workflow-chat__dropzone-text",children:[i.jsx("strong",{children:T?"Attachments are unavailable right now":fh(L.count)}),T?null:i.jsx("span",{children:L.over?"Release to upload to this conversation":"Drop anywhere on the conversation"})]})]}):null,q=L?T?"Attachments are unavailable right now":fh(L.count):re,oe=async()=>{const F=String(e.draft||"");if(T||y.current||!e.sendWhileBusy&&e.busy||!F.trim())return;const W=++_.current;y.current=!0,h(null),s(!0);try{await e.onSend(F)}catch(ie){g.current&&_.current===W&&h({action:"send",message:Mo(ie)})}finally{g.current&&_.current===W&&(y.current=!1,s(!1))}},G=async()=>{if(T||x.current||!e.onCancel)return;const F=++E.current;x.current=!0,h(null),l(!0);try{await e.onCancel()}catch(W){g.current&&E.current===F&&h({action:"cancel",message:Mo(W)})}finally{g.current&&E.current===F&&(x.current=!1,l(!1))}},N=async()=>{if(T||b.current||!e.onAttach)return;const F=++C.current;b.current=!0,h(null),d(!0);try{await e.onAttach()}catch(W){g.current&&C.current===F&&h({action:"attach",message:Mo(W)})}finally{g.current&&C.current===F&&(b.current=!1,d(!1))}},B=()=>{f&&(f.action==="send"&&oe(),f.action==="cancel"&&G(),f.action==="attach"&&N())};return i.jsxs("section",{ref:H,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?i.jsx("header",{className:"pc-workflow-chat__header",children:e.header}):null,i.jsx("div",{className:"pc-workflow-chat__transcript",children:i.jsx(_v,{messages:Array.isArray(e.messages)?e.messages:[],empty:e.emptyState,autoScroll:!0,messageProps:{...e.messageProps,...e.renderMarkdown?{renderMarkdown:e.renderMarkdown}:{}},after:i.jsxs(i.Fragment,{children:[e.interaction?i.jsx(Lv,{interaction:e.interaction,disabled:T}):null,j?i.jsx("div",{className:"pc-workflow-chat__blocked",role:"status",children:e.blockedNotice}):null]}),afterKey:`${e.interaction?`${e.interaction.kind}:${e.interaction.id}`:""}:${j?"blocked":""}`})}),f?i.jsxs("div",{className:"pc-workflow-chat__error",role:"alert",children:[i.jsxs("span",{children:["Could not ",f.action==="send"?"send this message":f.action==="attach"?"attach a file":"stop the run",": ",f.message]}),i.jsx("button",{type:"button",onClick:B,disabled:T,children:"Try again"})]}):null,i.jsxs("div",{className:"pc-workflow-chat__composer",children:[i.jsx(xv,{value:e.draft,onChange:e.onDraftChange,onSubmit:()=>void oe(),placeholder:e.placeholder||"Send a message",ariaLabel:"Message",disabled:T,busy:$,sendLabel:e.sendLabel,busyLabel:e.busyLabel,rows:2,leading:e.attachments?i.jsx("div",{className:"pc-workflow-chat__attachments",children:e.attachments}):null,overlay:ve,onPaste:V?ye:void 0,actions:i.jsxs(i.Fragment,{children:[e.onAttach?i.jsxs("button",{type:"button",className:"pc-workflow-chat__icon-button","aria-label":"Attach file",title:"Attach file",disabled:T||u,onClick:()=>void N(),children:[i.jsx(ae,{name:"paperclip",size:16}),i.jsx("span",{children:u?"Attaching…":"Attach"})]}):null,e.composerExtras,A&&e.onCancel?i.jsxs("button",{type:"button",className:"pc-workflow-chat__stop",disabled:T||a||P,onClick:()=>void G(),children:[i.jsx(ae,{name:"x",size:14}),i.jsx("span",{children:a||P?"Stopping…":"Stop"})]}):k?i.jsx("span",{className:`pc-workflow-chat__stop-state pc-workflow-chat__stop-state--${k.phase}`,role:"status","aria-live":"polite",children:k.label}):null]})}),V?i.jsx("div",{className:"pc-sr-only",role:"status","aria-live":"polite",children:q}):null]}),e.footer?i.jsx("footer",{className:"pc-workflow-chat__footer",children:e.footer}):null]})}const ha="llm.delta",yi="llm.delta_end";function Ov(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function js(e){return typeof e=="string"&&e.trim()!==""}function Dv(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0}function Fv(e){return"reason"in e}function Fp(e,n){const s=Ov(e),a=s==null?void 0:s.kind,l=n||(typeof a=="string"&&a?a:s&&"reason"in s?yi:ha),u=h=>{throw new Error(`Malformed ${l} event from the gateway: ${h}`)};if(n!==void 0&&n!==ha&&n!==yi&&u(`unknown event name ${JSON.stringify(n)}`),!s)return u("the payload is not an object");a!==void 0&&a!==ha&&a!==yi&&u(`unknown kind ${JSON.stringify(a)}`),a!==void 0&&n!==void 0&&a!==n&&u(`kind ${JSON.stringify(a)} does not match the event name`),js(s.run_id)||u("run_id is missing"),js(s.call_id)||u("call_id is missing"),Dv(s.seq)||u("seq is not a non-negative integer");const d=n||a?(n||a)===yi:"reason"in s;s.root_run_id!==void 0&&!js(s.root_run_id)&&u("root_run_id is not a run id"),s.parent_run_id!==void 0&&s.parent_run_id!==null&&!js(s.parent_run_id)&&u("parent_run_id is neither a run id nor null");const f={run_id:s.run_id,...js(s.root_run_id)?{root_run_id:s.root_run_id}:{},...s.parent_run_id!==void 0?{parent_run_id:s.parent_run_id}:{},...js(s.node_id)?{node_id:s.node_id}:{},call_id:s.call_id,seq:s.seq};return d?(["completed","failed","cancelled","unavailable"].includes(String(s.reason))||u(`unknown reason ${JSON.stringify(s.reason)}`),s.detail!==void 0&&s.detail!==null&&typeof s.detail!="string"&&u("detail is not a string"),{kind:yi,...f,reason:s.reason,...js(s.detail)?{detail:s.detail}:{}}):(typeof s.text!="string"&&u("text is not a string"),s.channel!=="content"&&s.channel!=="reasoning"&&u(`unknown channel ${JSON.stringify(s.channel)}`),typeof s.snapshot!="boolean"&&u("snapshot is not a boolean"),{kind:ha,...f,text:s.text,channel:s.channel,snapshot:s.snapshot})}function zv(e,n){if(e!==ha&&e!==yi)return null;let s=n;if(typeof n=="string")try{s=JSON.parse(n)}catch{throw new Error(`Malformed ${e} event from the gateway: data is not JSON`)}return Fp(s,e)}function Wv(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 Uv={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 Bv(e){return`This reply is not streamed: ${e?Uv[e]||`the gateway reported "${e}"`:"the gateway gave no reason"}. It appears when it is complete.`}function Vv(e){return e.toolApprovalGranted?null:e.interaction}const hh={messages:[],records:[],run:null,interaction:null,status:"idle",displayStatus:"",loading:!1,error:null,connection:"idle",toolApprovalGranted:!1,stop:null};function Ie(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Re(e){return typeof e=="string"?e.trim():e==null?"":typeof e=="number"||typeof e=="boolean"?String(e):""}function pa(e){return Array.isArray(e)?e:[]}function rn(e){return Re(e==null?void 0:e.status).toLowerCase()||"unknown"}function kt(e){return["completed","failed","cancelled"].includes(e.toLowerCase())}function Kr(e){const n=Ie(e),s=Number((n==null?void 0:n.status)??(n==null?void 0:n.statusCode));return s===401||s===403}function Gv(e){const n=Ie(e);return Number((n==null?void 0:n.status)??(n==null?void 0:n.statusCode))}function Oc(e){const n=s=>{if(Array.isArray(s))return s.map(n);const a=Ie(s);if(!a)return s;const l={};for(const u of Object.keys(a).sort())l[u]=n(a[u]);return l};try{return JSON.stringify(n(e))}catch{return"[unserializable]"}}function iu(e){if(typeof e=="string")return e.trim();const n=Ie(e);if(!n)return"";for(const s of["answer","response","message","text","content","output"]){const a=n[s];if(typeof a=="string"&&a.trim())return a.trim()}return""}function di(e){const n=iu(e);if(n)return n;if(!Ie(e)&&!Array.isArray(e))return"";try{return JSON.stringify(e,null,2)}catch{return""}}function ph(e){if(!e)return"";for(const a of["prompt","request","task","message","query","input"]){const l=Re(e[a]);if(l)return l}const n=Ie(e.context);for(const a of["task","message"]){const l=Re(n==null?void 0:n[a]);if(l)return l}const s=pa(n==null?void 0:n.messages);for(let a=s.length-1;a>=0;a-=1){const l=Ie(s[a]);if(Re(l==null?void 0:l.role).toLowerCase()!=="user")continue;const u=Re(l==null?void 0:l.content);if(u)return u}return""}function zp(e){const n=Ie(e.result);return Ie(n==null?void 0:n.wait)}function Dc(e){return e?Re(e.reason)==="subworkflow"||Re(e.wait_key).startsWith("subworkflow:"):!1}function mh(e,n){return!!(e&&e.runId===n.runId&&Re(e.wait.wait_key)===Re(n.wait.wait_key))}function au(e){return Ie(e.effect)||{}}function Hv(e,n){return Re(e.run_id)||n}function gh(e){return Re(e.ended_at)||Re(e.started_at)||void 0}function yh(e){const n=new Set,s=g=>{const y=Re(g);y&&n.add(y)},a=Ie(e.result);s(a==null?void 0:a.sub_run_id),s(a==null?void 0:a.subRunId),s(a==null?void 0:a.child_run_id);const l=au(e),u=Ie(l.payload);Re(l.type)==="start_subworkflow"&&(s(u==null?void 0:u.sub_run_id),s(u==null?void 0:u.subRunId),s(u==null?void 0:u.child_run_id));const d=zp(e),f=Ie(d==null?void 0:d.details);s(f==null?void 0:f.sub_run_id),s(f==null?void 0:f.subRunId),s(f==null?void 0:f.child_run_id);const h=Re(d==null?void 0:d.wait_key);return h.startsWith("subworkflow:")&&s(h.slice(12)),[...n]}class Kv{constructor(n,s={}){this.transport=n,this.options=s,this.snapshot={...hh},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 a=s.liveRenderIntervalMs??60;if(typeof a!="number"||!Number.isFinite(a)||a<0)throw new Error(`liveRenderIntervalMs must be a non-negative number of milliseconds, got ${JSON.stringify(s.liveRenderIntervalMs)}`);this.liveRenderIntervalMs=a}subscribe(n){return this.subscribers.add(n),()=>this.subscribers.delete(n)}getSnapshot(){return this.snapshot}reset(){var n;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,(n=this.controller)==null||n.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({...hh})}dispose(){this.reset(),this.subscribers.clear()}async load(n){const s=Re(n);if(this.reset(),!s)return;const a=++this.generation,l=new AbortController;this.controller=l,this.rootRunId=s,this.set({...this.snapshot,loading:!0,status:"loading",error:null,connection:"connecting"});try{const[u,d]=await Promise.all([this.transport.getRun(s,l.signal),this.transport.getHistory(s,l.signal)]);if(!this.live(a))return;const f=Ie(u),h=Ie(f==null?void 0:f.waiting),g=rn(f);if(await this.ingestHistory(d,s,a),!this.live(a))return;if(this.set({...this.snapshot,run:f,status:g,loading:!1,...h&&!kt(g)?{interaction:this.interactionWith({runId:s,wait:h})}:{}}),f&&this.updateRunState(s,f),h)for(const y of yh({result:{wait:h}}))y!==s&&this.catchUpAndWatch(y,a);await this.catchUpAndWatch(s,a),this.pollRootLifecycle(s,a)}catch(u){!l.signal.aborted&&this.live(a)&&this.fail(u)}}async sendCommand(n,s={}){var y,x;n==="cancel"&&(this.toolApprovalStopped=!0,this.revokeToolApproval(),this.stopRequested=!0,this.recomputeStop());const a=Re(s.wait_key),l=n==="resume"?a?this.interactionRunId()||this.rootRunId:this.rootRunId:n==="emit_event"?this.interactionRunId()||this.rootRunId:this.rootRunId;if(!l)throw new Error("No workflow run is loaded");const u=n==="resume"&&a&&((y=this.snapshot.interaction)==null?void 0:y.stepId)||"",d=`${l}\0${n}\0${u}\0${Oc(s)}`;let f=this.commandIds.get(d);f||(f=this.newCommandId(),this.commandIds.set(d,f));const h=this.generation,g=(x=this.controller)==null?void 0:x.signal;try{const b=await this.transport.submitCommand({command_id:f,run_id:l,type:n,payload:s,...this.options.clientId?{client_id:this.options.clientId}:{}},g);if(!this.live(h))return b;const _=Ie(b);if(_&&_.accepted===!1)throw n==="cancel"&&(this.stopRequested=!1,this.recomputeStop()),new Error(Re(_.detail)||"Gateway did not accept the command");return this.commandIds.delete(d),l===this.rootRunId&&["pause","resume","cancel"].includes(n)&&this.refreshRunState(l,h),b}catch(b){throw this.live(h)&&this.fail(b,!1),b}}resume(n){const s=this.requireInteraction();return this.sendCommand("resume",{wait_key:Re(s.wait.wait_key),payload:{response:n}})}approve(n,s){const a=this.requireInteraction();if(kt(this.snapshot.status))throw new Error("This run has already ended.");if(s&&(a.runId!==s.runId||Re(a.wait.wait_key)!==s.waitKey||s.stepId!==void 0&&a.stepId!==s.stepId))throw new Error("This approval request has changed. Review the current request before deciding.");if(n&&this.toolApprovalPolicy&&!this.toolCallsMatch(a,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 l=this.generation;return this.sendCommand("resume",{wait_key:Re(a.wait.wait_key),payload:{approved:!!n}}).then(u=>{if(!this.live(l))return u;const d=this.occurrenceKey(a);return this.approvedWaits.add(d),n&&this.isToolApproval(a)&&!this.grantedToolWaits.has(d)&&(this.grantedToolWaits.add(d),this.set({...this.snapshot})),u})}async approveWithPolicyChange(n,s){const a=this.generation,l=this.approvalEpoch;if(!this.isToolApproval(this.requireInteraction()))throw new Error("This is not a tool approval request.");await this.approve(!0,n),!(!this.live(a)||l!==this.approvalEpoch||this.toolApprovalStopped||kt(this.snapshot.status))&&s()}async allowAllToolsForRun(n){const s=this.generation,a=this.approvalEpoch,l=this.requireInteraction();if(!this.isToolApproval(l))throw new Error("This is not a tool approval request.");await this.approve(!0,n),!(!this.live(s)||a!==this.approvalEpoch||kt(this.snapshot.status))&&(this.approvedWaits.add(`${n.runId}:${n.waitKey}${l.stepId?`:${l.stepId}`:""}`),this.set({...this.snapshot,autoApproveTools:!0}))}revokeToolApproval(){this.approvalEpoch+=1,this.toolApprovalSuspended=!0,this.set({...this.snapshot,autoApproveTools:!1})}setToolApprovalPolicy(n){Oc(n)!==Oc(this.toolApprovalPolicy)&&(this.approvalEpoch+=1,this.toolApprovalSuspended=!1,this.toolApprovalPolicy=n?{enabledTools:[...n.enabledTools],autoApproveTools:[...n.autoApproveTools]}:null,this.set({...this.snapshot}))}occurrenceKey(n){return`${n.runId}:${Re(n.wait.wait_key)}${n.stepId?`:${n.stepId}`:""}`}interactionWith(n){const s=this.snapshot.interaction;return s&&Dc(n.wait)&&!Dc(s.wait)?s:s&&mh(s,n)&&n.stepId===void 0&&s.stepId!==void 0?{...n,stepId:s.stepId}:n}adoptDurableWait(n,s){const a=Ie(s.waiting);if(!a||rn(s)!=="waiting"||Dc(a)||kt(this.snapshot.status)||this.resolvedWaits.has(`${n}:${Re(a.wait_key)}`))return;const l=this.interactionWith({runId:n,wait:a}),u=this.snapshot.interaction;u&&mh(u,l)&&u.stepId===l.stepId||this.set({...this.snapshot,interaction:l})}coveredByStandingPermission(n,s){var a;return n.loading||this.toolApprovalStopped||this.toolApprovalSuspended||!this.toolApprovalPolicy&&!n.autoApproveTools||kt(n.status)||((a=n.run)==null?void 0:a.paused)===!0||n.status==="paused"||!s||!this.isToolApproval(s)||this.toolApprovalPolicy&&(!this.toolCallsMatch(s,this.toolApprovalPolicy.enabledTools)||!this.toolCallsMatch(s,this.toolApprovalPolicy.autoApproveTools))?!1:!!Re(s.wait.wait_key)}present(n){const s=n.interaction,a=s?this.occurrenceKey(s):"",l=!!(s&&this.isToolApproval(s)&&(this.grantedToolWaits.has(a)||!this.approvedWaits.has(a)&&this.coveredByStandingPermission({...n,loading:!1},s)));if(!l&&!this.snapshot.toolApprovalGranted&&!n.toolApprovalGranted)return n.toolApprovalGranted===!1?n:{...n,toolApprovalGranted:!1};let u=!1;const d=n.messages.map(f=>{var y;const h=f.toolActivity;if(!h||((y=this.toolActivities.get(h.id))==null?void 0:y.status)!=="waiting")return f;const g=l&&h.runId===(s==null?void 0:s.runId)?"running":"waiting";return h.status===g?f:(u=!0,this.toolMessage({...h,status:g}))});return{...n,toolApprovalGranted:l,...u?{messages:d}:{}}}toolCallsMatch(n,s){var l;const a=pa((l=Ie(n.wait.details))==null?void 0:l.tool_calls);return a.length>0&&a.every(u=>{var f;const d=Re((f=Ie(u))==null?void 0:f.name);return!!d&&s.includes(d)})}isToolApproval(n){const s=Ie(n.wait.details);return(s==null?void 0:s.mode)==="approval_required"||(s==null?void 0:s.kind)==="tool_approval"}autoApproveCurrentWait(){const n=this.snapshot.interaction;if(!this.coveredByStandingPermission(this.snapshot,n))return;const s={runId:n.runId,waitKey:Re(n.wait.wait_key),stepId:n.stepId},a=this.occurrenceKey(n);if(this.approvedWaits.has(a))return;this.approvedWaits.add(a),this.grantedToolWaits.add(a);const l=this.generation,u=this.approvalEpoch;this.approve(!0,s).catch(d=>{if(this.live(l)){if(this.grantedToolWaits.delete(a),u!==this.approvalEpoch){this.set({...this.snapshot});return}this.toolApprovalSuspended=!0,this.set({...this.snapshot,autoApproveTools:!1}),this.fail(d,!1)}})}emitEvent(n){return this.sendCommand("emit_event",n)}cancel(){return this.sendCommand("cancel",{})}requireInteraction(){if(!this.snapshot.interaction)throw new Error("This workflow is not waiting for input");if(!Re(this.snapshot.interaction.wait.wait_key))throw new Error("The workflow wait has no wait_key");return this.snapshot.interaction}interactionRunId(){var n;return((n=this.snapshot.interaction)==null?void 0:n.runId)||""}live(n){var s;return n===this.generation&&!((s=this.controller)!=null&&s.signal.aborted)}set(n){this.snapshot=this.present(n);for(const s of this.subscribers)s();this.autoApproveCurrentWait()}async catchUpAndWatch(n,s){var a;if(!(!this.live(s)||this.watchedRuns.has(n))){this.watchedRuns.add(n);try{if(n!==this.rootRunId)try{const l=Ie(await this.transport.getRun(n,(a=this.controller)==null?void 0:a.signal));if(!this.live(s))return;l&&this.updateRunState(n,l)}catch(l){if(!this.live(s))return;if(Kr(l))throw l;this.fail(l,!1)}if(await this.catchUp(n,s),!this.live(s)||kt(rn(this.runStates.get(n)||null)))return;this.childCatchUpAttempts.delete(n),this.watch(n,s)}catch(l){if(!this.live(s))return;if(this.watchedRuns.delete(n),n===this.rootRunId)throw l;if(Kr(l)){this.fail(l);return}const u=(this.childCatchUpAttempts.get(n)||0)+1;if(this.childCatchUpAttempts.set(n,u),this.fail(l,!1),u>=5)return;await this.waitForRetry(Math.min(2e3,150*2**(u-1))),this.live(s)&&this.catchUpAndWatch(n,s)}}}async catchUp(n,s){var a;for(let l=0;l<100&&this.live(s);l+=1){const u=this.cursors.get(n)||0,d=await this.transport.getLedger(n,u,(a=this.controller)==null?void 0:a.signal);if(!this.live(s))return;const f=Ie(d),h=Array.isArray(d)?d:pa(f==null?void 0:f.items);for(const y of h)this.ingestItem(n,y);const g=Number(f==null?void 0:f.next_after);if(!h.length||!Number.isFinite(g)||g<=u)break;this.cursors.set(n,g)}}async watch(n,s){try{await this.followStream(n,s)}finally{this.live(s)&&this.closeLiveRepliesVia(n)}}async followStream(n,s){var l;let a=0;for(;this.live(s)&&!kt(rn(this.runStates.get(n)||null));){const u=this.cursors.get(n)||0;this.set({...this.snapshot,connection:a?"reconnecting":"connecting"});try{let d=!1;const f=()=>{!this.live(s)||d||(d=!0,this.set({...this.snapshot,connection:"connected",error:null}))};if(this.dropLiveRepliesVia(n),await this.transport.streamLedger(n,u,g=>{this.live(s)&&(f(),this.ingestItem(n,g))},this.controller.signal,f,g=>{this.live(s)&&(f(),this.ingestDelta(n,g))}),!this.live(s)||(await this.catchUp(n,s),!this.live(s)))return;const h=Ie(await this.transport.getRun(n,(l=this.controller)==null?void 0:l.signal));if(!this.live(s))return;h&&this.updateRunState(n,h),a+=1}catch(d){if(!this.live(s))return;if(a+=1,this.fail(d,!1),Kr(d)){this.set({...this.snapshot,connection:"disconnected"});return}}if(a>=5||!this.live(s))break;await this.waitForRetry(Math.min(2e3,150*2**(a-1)))}if(this.live(s)){if(kt(rn(this.runStates.get(n)||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(n,s,a){const l=Ie(n);if(!l)return;const u=Ie(l.session),d=pa(u==null?void 0:u.turns).map(Ie).filter(g=>!!g);if(await this.hydrateHistoricalSessionRuns(d,s,a),!this.live(a))return;for(const g of d){const y=Re(g==null?void 0:g.run_id)||s;this.ingestSessionTurn(g,s,y!==s&&this.historicalRuns.get(y)||null)}const f=`turn:${s}:user`;if(!this.seenMessages.has(f)){const g=ph(Ie(l.input_data));g&&this.addMessage({id:f,role:"user",content:g})}const h=Ie(l.ledgers);if(h)for(const[g,y]of Object.entries(h)){const x=Ie(y);for(const b of pa(x==null?void 0:x.items))this.ingestItem(g,b)}}ingestSessionTurn(n,s,a){if(!n)return;const l=Re(n.run_id)||s,u=Ie(n.input_data)||Ie(n.input)||{},d=Re(n.prompt)||ph(u);d&&this.addMessage({id:`turn:${l}:user`,role:"user",content:d,ts:Re(n.created_at)||void 0});const f=this.historicalRunFailures.get(l);if(f){const x=Re(n.answer)||iu(n.output),b=f.missing?"is unavailable because the run no longer exists":"could not be restored",_=x?` Saved reply (not verified as the final result): ${x}`:"";this.addMessage({id:`history:${l}:unavailable`,role:"system",level:"warn",title:"History",content:`The final output for an earlier turn ${b}.${_}`});return}const g=(a&&kt(rn(a))?di(a.output):"")||(a?Re(n.answer)||iu(n.output):""),y=this.historicalEvidence.get(l);for(const x of(y==null?void 0:y.tools)||[])this.upsertTool(x);g&&this.addRunAssistantMessage(l,{id:`final:${l}`,role:"assistant",content:g,runId:l,statistics:y==null?void 0:y.statistics,ts:Re(n.updated_at)||void 0})}async hydrateHistoricalSessionRuns(n,s,a){const l=[...new Set(n.map(h=>Re(h.run_id)).filter(h=>h&&h!==s&&!this.historicalRuns.has(h)&&!this.historicalRunFailures.has(h)))];if(!l.length||!this.live(a))return;let u=0,d=!1;const f=async()=>{var h,g,y;for(;!d&&this.live(a);){const x=l[u++];if(!x)return;try{const b=Ie(await this.transport.getRun(x,(h=this.controller)==null?void 0:h.signal));if(!this.live(a))return;if(b){this.historicalRuns.set(x,b);try{const _=await this.transport.getHistory(x,(g=this.controller)==null?void 0:g.signal);if(!this.live(a))return;this.historicalEvidence.set(x,Wo(Sv(_)))}catch(_){if(!this.live(a))return;if(Kr(_))throw _;this.fail(new Error(`Earlier turn activity could not be restored: ${_ instanceof Error?_.message:String(_)}`),!1)}}else this.historicalRuns.set(x,null),this.historicalRunFailures.set(x,{missing:!1,detail:"gateway returned an invalid historical run snapshot"})}catch(b){if(!this.live(a))return;const _=Gv(b)===404;this.historicalRuns.set(x,null),this.historicalRunFailures.set(x,{missing:_,detail:b instanceof Error?b.message:Re((y=Ie(b))==null?void 0:y.detail)||"request failed"}),Kr(b)&&(d=!0,this.fail(b))}}};if(await Promise.all(Array.from({length:Math.min(4,l.length)},()=>f())),d&&this.live(a))for(const h of l)!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(n,s){const a=Ie(s),l=Ie(a==null?void 0:a.record)||a;if(!l)return;const u=Hv(l,n),d=Number(a==null?void 0:a.cursor),f=Number.isFinite(d)&&d>0?d:(this.cursors.get(u)||0)+1,h=`${u}:${f}`;if(!this.seenRecords.has(h)){if(this.seenRecords.add(h),this.cursors.set(u,Math.max(this.cursors.get(u)||0,f)),this.set({...this.snapshot,records:[...this.snapshot.records,{cursor:f,record:l,runId:u}]}),this.foldRecord(u,l,h),this.snapshot.messages.some(g=>g.id===`final:${this.rootRunId}`)){const g=Wo(this.snapshot.records).statistics;this.set({...this.snapshot,messages:this.snapshot.messages.map(y=>y.id===`final:${this.rootRunId}`?{...y,statistics:g}:y)})}for(const g of yh(l))g!==u&&this.catchUpAndWatch(g,this.generation)}}foldRecord(n,s,a){var y,x,b;const l=au(s),u=Re(l.type).toLowerCase(),d=Ie(s.result),f=Re(s.status).toLowerCase(),h=gh(s);if(this.foldStopEvidence(n,s,u,f),["llm_call","tool_calls"].includes(u)&&["started","running"].includes(f)){const _=Date.parse(h||"");(!Number.isFinite(_)||_>=this.displayStatusAt)&&(Number.isFinite(_)&&(this.displayStatusAt=_),this.snapshot.displayStatus&&this.set({...this.snapshot,displayStatus:""}))}if(u==="answer_user"&&f==="completed"){const _=di(d)||di(Ie(l.payload));_&&this.addRunAssistantMessage(n,{id:`answer:${n}:${a}`,role:"assistant",content:_,ts:h})}if(u==="emit_event"&&f==="completed"){const _=Ie(l.payload)||{},E=Ie(d),C=Re(_.name)||Re(E==null?void 0:E.name),j=_.payload!==void 0?_.payload:E==null?void 0:E.payload;if(["abstract.message","abstractcode.message"].includes(C)){const T=di(j);if(T){const A=Re((y=Ie(j))==null?void 0:y.level).toLowerCase(),$=A==="error"?"error":["warn","warning"].includes(A)?"warn":"info";this.addMessage({id:`event:${n}:${a}`,role:"system",title:"Workflow",content:T,level:$,ts:h})}}if(["abstract.status","abstractcode.status"].includes(C)){const T=Ie(j),A=T?T.status??T.text??T.value:j,$=Date.parse(h||"");!kt(this.snapshot.status)&&typeof A=="string"&&(!Number.isFinite($)||$>=this.displayStatusAt)&&(Number.isFinite($)&&(this.displayStatusAt=$),this.set({...this.snapshot,displayStatus:A.trim()}))}if(["abstract.tool_execution","abstractcode.tool_execution","abstract.tool_result","abstractcode.tool_result"].includes(C)){const T=di(j);T&&this.addMessage({id:`event:${n}:${a}`,role:"system",title:"Tool activity",content:T,ts:h})}}const g=zp(s);if(f==="waiting"&&g&&!kt(this.snapshot.status)&&!kt(rn(this.runStates.get(n)||null))&&(this.resolvedWaits.delete(`${n}:${Re(g.wait_key)}`),this.set({...this.snapshot,interaction:this.interactionWith({runId:n,wait:g,...Re(s.step_id)?{stepId:Re(s.step_id)}:{}})})),u==="tool_calls")for(const _ of Pp(this.toolActivities,{runId:n,cursor:this.cursors.get(n)||0,record:s}))this.upsertTool(_);if(u==="resume"&&(d==null?void 0:d.resumed)===!0){const _=Re((x=Ie(l.payload))==null?void 0:x.wait_key);_&&this.resolvedWaits.add(`${n}:${_}`),((b=this.snapshot.interaction)==null?void 0:b.runId)===n&&(this.set({...this.snapshot,interaction:null}),this.refreshRunState(n,this.generation))}}foldStopEvidence(n,s,a,l){let u=!1;if(a==="llm_call"){const d=Re(s.step_id);if(d){const f=`${n}:${d}`;l==="started"?(this.openLlmSteps.add(f),u=!0):["completed","failed","cancelled","waiting"].includes(l)&&(u=this.openLlmSteps.delete(f)||u),["completed","failed","cancelled"].includes(l)&&this.closeLiveReply(f)}}if(a==="emit_event"&&l==="completed"){const d=Ie(au(s).payload)||{},f=Ie(s.result),h=Re(d.name)||Re(f==null?void 0:f.name),g=Ie(d.payload!==void 0?d.payload:f==null?void 0:f.payload);h==="abstract.status"&&Re(g==null?void 0:g.killed_by)==="kill_switch"&&(this.forcedStop=g,u=!0)}u&&this.recomputeStop()}recomputeStop(){let n=null;this.forcedStop?n={phase:"forced",label:Re(this.forcedStop.text)||"Stop forced: inference killed",record:this.forcedStop}:this.stopRequested&&(n=this.snapshot.status==="cancelled"&&this.openLlmSteps.size===0?{phase:"stopped",label:"Stopped"}:{phase:"stopping",label:"Stopping…"});const s=this.snapshot.stop||null;((s==null?void 0:s.phase)!==(n==null?void 0:n.phase)||(s==null?void 0:s.label)!==(n==null?void 0:n.label))&&this.set({...this.snapshot,stop:n}),(n==null?void 0:n.phase)==="stopping"&&this.snapshot.status==="cancelled"&&this.followStop(this.generation)}async followStop(n){var s;if(!this.stopFollowing){this.stopFollowing=!0;try{let a=500,l=null;for(;this.live(n)&&((s=this.snapshot.stop)==null?void 0:s.phase)==="stopping";){if(await this.waitForRetry(a),!this.live(n))return;const u=[this.rootRunId,...[...this.watchedRuns].filter(f=>f!==this.rootRunId)];let d=!1;for(const f of u)try{await this.catchUp(f,n)}catch(h){d=!0,this.live(n)&&(this.fail(h,!1),l=this.snapshot.error)}!d&&l&&this.snapshot.error===l&&(this.set({...this.snapshot,error:null}),l=null),a=Math.min(5e3,a*2)}}finally{this.generation===n&&(this.stopFollowing=!1)}}}addMessage(n){const s=Re(n.id)||`${n.role}:${n.content}:${n.ts||""}`;this.seenMessages.has(s)||(this.seenMessages.add(s),this.set({...this.snapshot,messages:[...this.snapshot.messages,{...n,id:s}]}))}toolMessage(n){return{id:`tool:${n.id}`,role:"system",kind:"tool_activity",title:"Tool activity",runId:n.runId,toolActivity:n,content:JSON.stringify({tool:n.name,status:n.status,arguments:n.arguments,output:n.output,error:n.error},null,2),ts:n.endedAt||n.startedAt}}upsertTool(n){const s=this.toolMessage(n),a=this.snapshot.messages.findIndex(u=>u.id===s.id);if(a<0){this.addMessage(s);return}const l=[...this.snapshot.messages];l[a]=s,this.set({...this.snapshot,messages:l})}addRunAssistantMessage(n,s){this.closeLiveRepliesOfRun(n);const a=`answer:${n}:`,l=`final:${n}`;this.snapshot.messages.some(u=>u.role==="assistant"&&u.content===s.content&&(u.id===l||String(u.id||"").startsWith(a)))||this.addMessage(s)}ingestDelta(n,s){let a;try{a=Fp(s)}catch(h){this.fail(h,!1);return}const l=`${a.run_id}:${a.call_id}`;if(Fv(a)){if(a.reason==="unavailable"){this.noteStreamUnavailable(a);return}if(a.reason==="cancelled"&&a.detail==="reinvoked"){this.closeLiveReply(l,"restarted");return}this.closeLiveReply(l,a.reason==="completed"?void 0:a.reason);return}if(this.closedLiveCalls.has(l)||this.runEnded(a.run_id)||this.runEnded(this.rootRunId))return;const u=this.liveReplies.get(l)||{runId:a.run_id,callId:a.call_id,nodeId:a.node_id||"",via:n,text:"",reasoning:"",seq:{content:-1,reasoning:-1}},d=a.channel==="reasoning"?"reasoning":"text",f=u.seq[a.channel];if(a.snapshot){if(a.seq<f)return;u[d]=a.text}else{if(a.seq<=f)return;u[d]+=a.text}u.seq[a.channel]=a.seq,u.via=n,this.liveReplies.set(l,u),this.liveDirty.add(l),this.scheduleLiveRender()}runEnded(n){return kt(rn(this.runStates.get(n)||null))}scheduleLiveRender(){if(this.liveRenderTimer)return;const n=this.lastLiveRender+this.liveRenderIntervalMs-Date.now();if(n<=0){this.renderLiveReplies();return}this.liveRenderTimer=setTimeout(()=>{this.liveRenderTimer=null,this.renderLiveReplies()},n)}renderLiveReplies(){if(this.lastLiveRender=Date.now(),!this.liveDirty.size)return;const n=[...this.snapshot.messages];for(const s of this.liveDirty){const a=this.liveReplies.get(s);if(!a)continue;const l=this.liveMessage(a),u=n.findIndex(d=>d.id===l.id);u<0?n.push(l):n[u]=l,this.shownLiveCalls.add(s)}this.liveDirty.clear(),this.set({...this.snapshot,messages:n})}liveMessage(n){const s=n.runId!==this.rootRunId;return{id:`live:${n.runId}:${n.callId}`,role:"assistant",content:n.text,runId:n.runId,live:{callId:n.callId,reasoning:n.reasoning,...s?{caption:`sub-agent · ${n.nodeId||n.runId}`}:{}}}}closeLiveReply(n,s){this.closedLiveCalls.add(n);const a=this.liveReplies.get(n);if(!a){s==="restarted"&&this.shownLiveCalls.has(n)&&this.addMessage(this.restartNote(n));return}this.liveReplies.delete(n),this.liveDirty.delete(n);const l=`live:${a.runId}:${a.callId}`,u=this.snapshot.messages.findIndex(f=>f.id===l);if(u<0)return;const d=[...this.snapshot.messages];if(s==="restarted"){const f=this.restartNote(n);this.seenMessages.add(String(f.id)),d[u]=f}else if(s){const f=`live-end:${a.runId}:${a.callId}`;this.seenMessages.add(f),d[u]={id:f,role:"system",level:"warn",title:"Reply",runId:a.runId,content:s==="failed"?"The reply stopped because the model call failed.":"The reply stopped because the model call was cancelled."}}else d.splice(u,1);this.set({...this.snapshot,messages:d})}restartNote(n){const s=n.slice(0,n.indexOf(":"));return{id:`live-end:${n}`,role:"system",level:"info",title:"Reply",runId:s,content:"Reply restarted: the model call was interrupted and is running again."}}noteStreamUnavailable(n){const s=`${n.run_id}:${n.call_id}`;this.closeLiveReply(s),this.addMessage({id:`stream-unavailable:${n.run_id}:${n.detail||"unknown"}`,role:"system",level:"info",title:"Reply",runId:n.run_id,content:Bv(n.detail)})}closeLiveRepliesOfRun(n){for(const s of[...this.liveReplies.values()])s.runId===n&&this.closeLiveReply(`${s.runId}:${s.callId}`)}closeLiveRepliesVia(n,s){for(const a of[...this.liveReplies.values()])(a.via===n||a.runId===n)&&this.closeLiveReply(`${a.runId}:${a.callId}`,s)}endLiveRepliesOfRun(n,s){const a=s==="failed"||s==="cancelled"?s:void 0;if(n===this.rootRunId){for(const l of[...this.liveReplies.values()])this.closeLiveReply(`${l.runId}:${l.callId}`,a);this.closedLiveCalls.clear(),this.shownLiveCalls.clear();return}this.closeLiveRepliesVia(n,a);for(const l of[...this.closedLiveCalls])l.startsWith(`${n}:`)&&this.closedLiveCalls.delete(l);for(const l of[...this.shownLiveCalls])l.startsWith(`${n}:`)&&this.shownLiveCalls.delete(l)}dropLiveRepliesVia(n){const s=new Set;for(const[a,l]of this.liveReplies)l.via===n&&(this.liveReplies.delete(a),this.liveDirty.delete(a),s.add(`live:${l.runId}:${l.callId}`));s.size&&this.set({...this.snapshot,messages:this.snapshot.messages.filter(a=>!s.has(String(a.id)))})}fail(n,s=!0){var a,l,u;Kr(n)&&(this.approvalEpoch+=1,this.toolApprovalStopped=!0,this.toolApprovalSuspended=!0,(l=(a=this.options).onAuthError)==null||l.call(a,n)),this.set({...this.snapshot,error:n instanceof Error?n.message:Re((u=Ie(n))==null?void 0:u.detail)||String(n),...Kr(n)?{autoApproveTools:!1}:{},...s?{connection:"disconnected"}:{}})}newCommandId(){const n=globalThis.crypto;return n&&typeof n.randomUUID=="function"?n.randomUUID():`workflow-${Date.now()}-${Math.random().toString(36).slice(2)}`}updateRunState(n,s){var u;if(this.runStates.set(n,s),kt(rn(s))&&this.endLiveRepliesOfRun(n,rn(s)),n!==this.rootRunId){kt(rn(s))&&((u=this.snapshot.interaction)==null?void 0:u.runId)===n?this.set({...this.snapshot,interaction:null}):this.adoptDurableWait(n,s);return}const a=rn(s),l=kt(a);if(l){const d=di(s.output);d&&this.upsertFinal(n,d,gh(s))}this.set({...this.snapshot,run:s,status:a,...l?{interaction:null,autoApproveTools:!1,displayStatus:""}:{}}),l||this.adoptDurableWait(n,s),(this.stopRequested||this.forcedStop)&&this.recomputeStop()}upsertFinal(n,s,a){this.closeLiveRepliesOfRun(n);const l=`final:${n}`;this.seenMessages.add(l);const u={id:l,role:"assistant",content:s,ts:a,runId:n,statistics:Wo(this.snapshot.records).statistics},d=this.snapshot.messages.findIndex(h=>h.id===l||String(h.id||"").startsWith(`answer:${n}:`)&&h.content===s);if(d<0){this.set({...this.snapshot,messages:[...this.snapshot.messages,u]});return}const f=[...this.snapshot.messages];f[d]=u,this.set({...this.snapshot,messages:f})}async refreshRunState(n,s){var a;try{const l=Ie(await this.transport.getRun(n,(a=this.controller)==null?void 0:a.signal));l&&this.live(s)&&this.updateRunState(n,l)}catch(l){this.live(s)&&this.fail(l,!1)}}async pollRootLifecycle(n,s){var a;for(;this.live(s)&&this.rootRunId===n&&!kt(rn(this.runStates.get(n)||null));){if(await this.waitForRetry(2e3),!this.live(s)||this.rootRunId!==n||kt(rn(this.runStates.get(n)||null)))return;try{const l=Ie(await this.transport.getRun(n,(a=this.controller)==null?void 0:a.signal));l&&this.live(s)&&this.rootRunId===n&&this.updateRunState(n,l)}catch(l){if(!this.live(s))return;if(Kr(l)){this.fail(l);return}this.fail(l,!1)}}}waitForRetry(n){var l;const s=(l=this.controller)==null?void 0:l.signal;if(!s||s.aborted)return Promise.resolve();const a=s;return new Promise(u=>{const d=setTimeout(h,n),f=()=>{clearTimeout(d),h()};function h(){a.removeEventListener("abort",f),u()}a.addEventListener("abort",f,{once:!0})})}}function Jv(e){const n=w.useMemo(()=>new Kv(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]),s=w.useSyncExternalStore(l=>n.subscribe(l),()=>n.getSnapshot(),()=>n.getSnapshot()),a=String(e.runId||"").trim();return w.useEffect(()=>{n.setToolApprovalPolicy(e.enabled===!1?{enabledTools:[],autoApproveTools:[]}:e.toolApprovalPolicy??null)},[n,e.toolApprovalPolicy,e.enabled]),w.useEffect(()=>{if(e.enabled===!1||!a){n.reset();return}return n.load(a),()=>n.reset()},[n,a,e.enabled]),{controller:n,snapshot:s}}function Ss(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Ut(e){return typeof e=="string"?e.trim():e==null?"":typeof e=="number"||typeof e=="boolean"?String(e):""}function wh(e){return["session","workflow","run","global"].includes(e)?e:null}function Jr(e){return{scope:Ut(e==null?void 0:e.scope).toLowerCase(),name:Ut(e==null?void 0:e.name)||Ut(e==null?void 0:e.event_name),scopeId:Ut(e==null?void 0:e.scope_id)||Ut(e==null?void 0:e.scopeId),sessionId:Ut(e==null?void 0:e.session_id)||Ut(e==null?void 0:e.sessionId),workflowId:Ut(e==null?void 0:e.workflow_id)||Ut(e==null?void 0:e.workflowId),runId:Ut(e==null?void 0:e.run_id)||Ut(e==null?void 0:e.runId)}}function Qv(e,n){const s=e.wait,a=Ut(s.wait_key),l=[Jr(s),Jr(Ss(s.details))];for(const u of n){if(u.runId!==e.runId)continue;const d=u.record,f=Ss(d.result),h=Ss(f==null?void 0:f.wait),g=Ss(d.effect),y=Ss(g==null?void 0:g.payload);Ut(h==null?void 0:h.wait_key)!==a&&Ut(y==null?void 0:y.wait_key)!==a||l.push(Jr(d),Jr(y),Jr(Ss(y==null?void 0:y.details)),Jr(h),Jr(Ss(h==null?void 0:h.details)))}return l}function Fc(e,n){return n.scopeId?n.scopeId:e==="session"?n.sessionId:e==="workflow"?n.workflowId:e==="run"?n.runId:"global"}function Wp(e,n,s){return{scope:e,scopeId:n,name:s,...e==="session"?{sessionId:n}:{},...e==="workflow"?{workflowId:n}:{},...e==="run"?{runId:n}:{}}}function Yv(e,n,s){if(!s)return null;const a=`evt:${n}:${s}:`;if(!e.startsWith(a))return null;const l=e.slice(a.length);return l?Wp(n,s,l):null}function Xv(e,n=[],s){if(!e)return{target:null,error:"No event wait is available."};const a=Ut(e.wait.wait_key),l=/^evt:(session|workflow|run|global):/.exec(a);if(!l)return{target:null,error:"The gateway did not provide a canonical event wait key."};const u=wh(l[1]);if(!u)return{target:null,error:"The event wait uses an unsupported scope."};const d=Qv(e,Array.isArray(n)?n:[]),f=new Map;for(const b of d){const _=wh(b.scope);if(!_||!b.name)continue;if(_!==u)return{target:null,error:"Event metadata conflicts with the canonical wait scope."};const E=`evt:${_}:`,C=`:${b.name}`;if(!a.startsWith(E)||!a.endsWith(C)||a.length<=E.length+C.length)return{target:null,error:"Event metadata does not exactly match the canonical wait key."};const j=a.slice(E.length,-C.length),T=Fc(_,b);if(T&&T!==j)return{target:null,error:"Event metadata conflicts with the canonical wait target."};const A=Wp(_,j,b.name);f.set(`${A.scope}\0${A.scopeId}\0${A.name}`,A)}if(f.size>1)return{target:null,error:"Multiple event targets match this wait; routing is unavailable."};if(f.size===1)return{target:[...f.values()][0]};const h=new Set;u==="run"&&h.add(e.runId),u==="global"&&h.add("global");for(const b of d){const _=Fc(u,b);_&&h.add(_)}if(Ut(s==null?void 0:s.run_id)===e.runId){const b=Jr(s||null),_=Fc(u,b);_&&h.add(_)}const y=[...h].map(b=>Yv(a,u,b)).filter(b=>!!b),x=new Map(y.map(b=>[`${b.scope}\0${b.scopeId}\0${b.name}`,b]));return x.size===1?{target:[...x.values()][0]}:x.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."}}const vu=e=>Se(`runs/${encodeURIComponent(e)}/workspace`);function Zv(e){return vu(e)}function qv(e,n){return`${vu(e)}/files?${new URLSearchParams({path:n,recursive:"false"})}`}function ya(e,n){return`${vu(e)}/content?${new URLSearchParams({path:n})}`}async function Xo(e,n){let s="";try{const a=await e.text();try{const l=JSON.parse(a),u=(l==null?void 0:l.detail)??(l==null?void 0:l.error)??(l==null?void 0:l.message);s=typeof u=="string"?u:u&&typeof u.message=="string"?u.message:a}catch{s=a}}catch{s=""}return new Error(`${n} (HTTP ${e.status}): ${s.trim()||e.statusText||"no reason given"}`)}function e_(e,n){const s=e&&typeof e=="object"&&!Array.isArray(e)?e:null,a=d=>{throw new Error(`Unexpected /workspace/files response from the gateway: ${d}.`)};if(!s)return a("not an object");Array.isArray(s.entries)||a("no `entries` list"),typeof s.truncated!="boolean"&&a("no `truncated` flag");const l=s.entries.map((d,f)=>{const h=d&&typeof d=="object"?d:{};return(typeof h.name!="string"||typeof h.path!="string"||h.type!=="file"&&h.type!=="dir")&&a(`entry ${f+1} lacks a name, path or file/dir type`),h}),u=s.hidden&&typeof s.hidden=="object"&&!Array.isArray(s.hidden)?s.hidden:void 0;return{path:typeof s.path=="string"?s.path:n,entries:l,truncated:s.truncated,...u?{hidden:u}:{}}}async function t_(e,n,s){const a=await e(Zv(n),{signal:s});if(!a.ok)throw await Xo(a,"The workspace is not available");const l=await a.json();if(!l||typeof l.workspace_root!="string"||typeof l.exists!="boolean")throw new Error("Unexpected /workspace response from the gateway: no `workspace_root` / `exists`.");return l}async function n_(e,n,s,a){const l=await e(qv(n,s),{signal:a});if(!l.ok)throw await Xo(l,"The folder could not be listed");return e_(await l.json(),s)}async function r_(e,n,s,a){const l=await e(ya(n,s),{signal:a});if(!l.ok)throw await Xo(l,"The file could not be read");return await l.blob()}async function s_(e,n,s,a){const l=await t_(e,n,a);return{where:l,listing:l.exists?await n_(e,n,s,a):null}}function i_(e){const n=String(e||"").split("/").filter(Boolean),s=[{label:"Workspace",path:""}];return n.forEach((a,l)=>s.push({label:a,path:n.slice(0,l+1).join("/")})),s}function Up(e){if(typeof e!="number"||!Number.isFinite(e)||e<0)return"";if(e<1024)return`${e} B`;const n=["KiB","MiB","GiB","TiB"];let s=e/1024,a=0;for(;s>=1024&&a<n.length-1;)s/=1024,a+=1;return`${s<10?s.toFixed(1):Math.round(s)} ${n[a]}`}function a_(e){return[...e].sort((n,s)=>n.type===s.type?n.name.localeCompare(s.name):n.type==="dir"?-1:1)}function o_(e){const n=e.hidden||{},s=Number(n.blocked||0)+Number(n.outside_links||0)+Number(n.other||0),a=[];return s>0&&a.push(`${s} ${s===1?"entry":"entries"} hidden by the gateway's workspace rules`),e.truncated&&a.push("the list is truncated"),a.join("; ")}const l_=new Set(["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","application/pdf","text/plain","application/json"]);function c_(e){const n=String(e||"").split(";",1)[0].trim().toLowerCase();return l_.has(n)?{mode:"open",type:n}:n.startsWith("text/")||n.endsWith("+xml")||n.endsWith("+json")||n.endsWith("/xml")||n.endsWith("/javascript")||n.endsWith("/x-yaml")||n.endsWith("/toml")?{mode:"open",type:"text/plain;charset=utf-8"}:{mode:"download"}}function Bp(e,n,s){const a=s==="open"?c_(e.type):{mode:"download"},l=a.mode==="open"&&a.type!==e.type?new Blob([e],{type:a.type}):e,u=URL.createObjectURL(l);if(a.mode==="open")window.open(u,"_blank","noopener");else{const d=document.createElement("a");d.href=u,d.download=n,document.body.appendChild(d),d.click(),d.remove()}window.setTimeout(()=>URL.revokeObjectURL(u),6e4)}async function u_(e,n,s){const a=await e(oy(n),{signal:s.signal});if(!a.ok)throw await Xo(a,`${s.name} could not be read`);Bp(await a.blob(),s.name,s.mode??"open")}function Vp(e){const{fetchGateway:n,runId:s}=e,[a,l]=w.useState({runId:s,path:""}),u=a.runId===s?a.path:"",[d,f]=w.useState(null),[h,g]=w.useState(""),[y,x]=w.useState(!!s),[b,_]=w.useState(""),[E,C]=w.useState(0);w.useEffect(()=>{if(!s)return;const A=new AbortController;return x(!0),g(""),(async()=>{try{const $=await s_(n,s,u,A.signal);A.signal.aborted||f({runId:s,...$})}catch($){A.signal.aborted||g(String(($==null?void 0:$.message)||$))}finally{A.signal.aborted||x(!1)}})(),()=>A.abort()},[n,s,u,E,e.refreshKey]);const j=d&&d.runId===s?d:null,T=w.useCallback(async(A,$)=>{_(A.path),g("");try{Bp(await r_(n,s,A.path),A.name,$)}catch(k){g(String((k==null?void 0:k.message)||k))}finally{_("")}},[n,s]);return i.jsx(d_,{title:e.title,note:e.note,where:(j==null?void 0:j.where)??null,path:u,listing:(j==null?void 0:j.listing)??null,error:h,loading:y,fileBusy:b,selectedPath:e.selectedPath,className:e.className,onNavigate:A=>l({runId:s,path:A}),onRefresh:()=>C(A=>A+1),onFile:e.onSelectFile?void 0:(A,$)=>void T(A,$),onSelectFile:e.onSelectFile,onClose:e.onClose})}function d_(e){var a,l,u,d;const n=e.listing?o_(e.listing):"",s=(l=(a=e.where)==null?void 0:a.host)==null?void 0:l.hostname;return i.jsxs("section",{className:`pc-ws${e.className?` ${e.className}`:""}`,"aria-label":e.title,"data-workspace-root":((u=e.where)==null?void 0:u.workspace_root)||void 0,children:[i.jsxs("header",{className:"pc-ws__head",children:[i.jsxs("span",{className:"pc-ws__title",children:[i.jsx(ae,{name:"folder",size:15})," ",e.title]}),i.jsx("span",{className:"pc-ws__spacer"}),i.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:i.jsx(ae,{name:"refresh",size:14})}),e.onClose?i.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:i.jsx(ae,{name:"x",size:14})}):null]}),e.where?i.jsxs("div",{className:"pc-ws__root",children:[i.jsx("code",{children:e.where.workspace_root}),s&&((d=e.where.host)==null?void 0:d.caller_is_this_machine)!==!0?i.jsxs("span",{className:"pc-ws__muted",children:[" on the gateway host ",s]}):null]}):null,e.note?i.jsx("div",{className:"pc-ws__muted",children:e.note}):null,i.jsx("nav",{className:"pc-ws__crumbs","aria-label":"Folder",children:i_(e.path).map((f,h,g)=>h===g.length-1?i.jsx("span",{"aria-current":"page",children:f.label},f.path):i.jsxs(wt.Fragment,{children:[i.jsx("button",{type:"button",className:"pc-ws__crumb",onClick:()=>e.onNavigate(f.path),children:f.label}),i.jsx("span",{className:"pc-ws__muted",children:" / "})]},f.path))}),e.error?i.jsx("div",{className:"pc-ws__error",role:"alert",children:e.error}):null,e.loading&&!e.listing?i.jsx("div",{className:"pc-ws__muted",role:"status",children:"Loading…"}):null,e.where&&!e.where.exists?i.jsx("div",{className:"pc-ws__muted",children:"The folder does not exist yet: nothing has been written."}):null,e.listing?e.listing.entries.length?i.jsx("ul",{className:"pc-ws__entries",children:a_(e.listing.entries).map(f=>i.jsx("li",{className:`pc-ws__entry${e.selectedPath===f.path?" is-selected":""}`,"data-type":f.type,"data-path":f.path,children:f.type==="dir"?i.jsxs("button",{type:"button",className:"pc-ws__name","data-action":"open-dir",onClick:()=>e.onNavigate(f.path),children:[i.jsx(ae,{name:"folder",size:14})," ",f.name,"/"]}):i.jsxs(i.Fragment,{children:[e.onSelectFile?i.jsxs("button",{type:"button",className:"pc-ws__name","data-action":"select-file","aria-pressed":e.selectedPath===f.path,onClick:()=>{var h;return(h=e.onSelectFile)==null?void 0:h.call(e,f)},children:[i.jsx(ae,{name:"file",size:14})," ",f.name]}):i.jsxs("span",{className:"pc-ws__name",children:[i.jsx(ae,{name:"file",size:14})," ",f.name]}),i.jsx("span",{className:"pc-ws__size",children:Up(f.size_bytes)}),e.onFile?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"pc-ws__btn","data-action":"open-file",disabled:e.fileBusy===f.path,onClick:()=>{var h;return(h=e.onFile)==null?void 0:h.call(e,f,"open")},children:"Open"}),i.jsx("button",{type:"button",className:"pc-ws__icon-btn","data-action":"download-file",disabled:e.fileBusy===f.path,onClick:()=>{var h;return(h=e.onFile)==null?void 0:h.call(e,f,"download")},title:`Download ${f.name}`,"aria-label":`Download ${f.name}`,children:i.jsx(ae,{name:"download",size:14})})]}):null]})},f.path))}):i.jsx("div",{className:"pc-ws__muted",children:"This folder is empty."}):null,n?i.jsx("div",{className:"pc-ws__muted","data-hidden-note":"true",children:n}):null]})}function f_(e){return i.jsx(Ep,{text:e,images:"link"})}const h_={trigger:"Trigger",answer:"Automation"};function p_(e){return i.jsx(Lp,{message:{id:`${e.runId}:${e.kind}`,role:e.role,content:e.text,title:h_[e.kind],runId:e.runId},images:"link"})}const m_={renderText:f_,renderTurn:p_};function g_(e){const{fetchGateway:n,...s}=e,a=s.onOpenResource??(n?l=>u_(n,l.url,{name:l.name}):void 0);return i.jsx(Uw,{...s,onOpenResource:a,...m_})}function y_(e,n,s={}){if(!e)return null;const a=e.wait,l=`${e.runId}:${a.wait_key}:${e.stepId||""}`,u=a.details||{};if(u.mode==="approval_required"||u.kind==="tool_approval"){const f=Array.isArray(u.tool_calls)?u.tool_calls:[],h={runId:e.runId,waitKey:String(a.wait_key||""),stepId:e.stepId},g=[...new Set(f.map(x=>String((x==null?void 0:x.name)||"tool")))],y=s.onPermissionsAll;return{id:l,kind:"tool-approval",title:`${f.length||"Requested"} ${f.length===1?"action needs":"actions need"} permission`,toolName:g.join(", ")||"the requested tools",description:"Review the targets below. Allow once approves this batch only.",detail:i.jsxs("div",{className:"pc-approval-summary",children:[i.jsx(Rp,{tools:f.map((x,b)=>({id:String((x==null?void 0:x.call_id)||(x==null?void 0:x.id)||b),runId:e.runId,name:(x==null?void 0:x.name)||"Tool",arguments:x==null?void 0:x.arguments,status:"waiting"}))}),i.jsxs("details",{children:[i.jsx("summary",{children:"Review full tool arguments (JSON)"}),i.jsx(Cs,{value:f.length?f:u})]})]}),approveLabel:"Allow once",denyLabel:"Deny",approveAllLabel:y?"Allow all enabled tools":void 0,approveAllDescription:y?"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:y?async()=>{await n.approveWithPolicyChange(h,()=>{y()})}:void 0,onApprove:async()=>{await n.approve(!0,h)},onDeny:async()=>{await n.approve(!1,h)}}}if(a.reason==="user"||a.reason==="ask_user")return{id:l,kind:"ask-user",title:"A question for you",prompt:String(a.prompt||u.prompt||"How would you like to continue?"),allowFreeText:a.allow_free_text!==!1,choices:(Array.isArray(a.choices)?a.choices:[]).map(f=>typeof f=="object"&&f!==null?{id:String(f.value??f.id??f.label),label:String(f.label??f.text??f.value??f.id),description:f.description}:{id:String(f),label:String(f)}),onSubmit:async f=>{await n.resume(f)}};const d=String(a.wait_key||"");if(a.reason==="event"||d.startsWith("evt:")){const f=Xv(e,s.records||[],s.currentRun??null),h=f.target,g=(h==null?void 0:h.name)||"";return{id:l,kind:"event-wait",title:h?"Waiting for an event":"Event routing unavailable",eventName:g,prompt:String(a.prompt||`This workflow will continue when “${g||"its trigger"}” arrives.`),description:h?"You can also send the expected event here.":`This event cannot be sent safely. ${f.error}`,initialPayload:"{}",payloadLabel:"Event data (JSON)",sendLabel:"Send event",onSend:async y=>{if(!h)throw new Error(f.error);const x=JSON.parse(y||"{}"),b={name:h.name,scope:h.scope,payload:x};h.scope==="session"?b.session_id=h.scopeId:h.scope==="workflow"?b.workflow_id=h.scopeId:h.scope==="run"&&(b.run_id=h.scopeId),await n.emitEvent(b)}}}return null}const w_="abstractcode.agent.v1";function _u(e){return!!(e!=null&&e.interfaces.some(n=>[w_,"abstractassistant.agent.v1"].includes(n)))}function tt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function Ho(e){return Array.isArray(e)?e:[]}function Ne(e){return typeof e!="string"?void 0:e.trim()||void 0}function Gp(e){return Ho(e).flatMap(n=>{const s=Ne(n);return s?[s]:[]})}function wa(e,n=0){if(typeof e!="number"||!Number.isFinite(e))return;const s=Math.trunc(e);return s>=n?s:void 0}function xu(e,n){if(Array.isArray(e))return e;const s=tt(e);if(!s)return[];for(const a of n)if(Array.isArray(s[a]))return s[a];return[]}function Hp(e){const n=tt(e);return n?{...n}:void 0}function vh(e){const n=Hp(e.input_schema??e.inputSchema??e.inputs_schema);if(n)return n;const s=tt(e.inputs);if(s&&("properties"in s||"type"in s||"$schema"in s))return{...s}}function v_(e){const n=Ne(e.bundle_version??e.bundleVersion??e.version);if(n)return n;const s=Ne(e.bundle_ref??e.bundleRef);if(!s)return;const a=s.lastIndexOf("@");return a>0&&a<s.length-1?s.slice(a+1):void 0}function __(e,n,s){return e?`${e}${n?`@${n}`:""}:${s}`:s}function _h(e,n,s){var f;const a=tt(e),l=Ne((a==null?void 0:a.default_bundle_id)??(a==null?void 0:a.defaultBundleId)),u=xu(e,["items","bundles"]),d=[];for(const h of u){const g=tt(h);if(!g)continue;const y=tt(g.actions);if((y==null?void 0:y.can_run)===!1)continue;const x=(f=Ne(g.status))==null?void 0:f.toLowerCase();if(g.is_draft===!0||g.is_published===!1||g.version_channel==="draft"||x&&!["published","deprecated"].includes(x)||!s.includeDeprecated&&(x==="deprecated"||x==="deleted"||x==="disabled"))continue;const b=Ne(g.bundle_id??g.bundleId??g.id),_=v_(g);if(_&&/(?:^|[.\-])draft(?:[.\-]|$)/i.test(_))continue;const E=Ne(g.default_entrypoint??g.defaultEntrypoint),C=n==="private"&&(g.is_default===!0||g.isDefault===!0||!!b&&b===l);for(const j of Ho(g.entrypoints)){const T=tt(j);if(!T||!s.includeDeprecated&&(T.deprecated===!0||T.enabled===!1))continue;const A=Ne(T.flow_id??T.flowId??T.id);if(!A)continue;const $=Gp(T.interfaces??T.interface_ids??T.interfaceIds);if(s.interfaceId&&!$.includes(s.interfaceId))continue;const k=Ne(T.workflow_id??T.workflowId)??__(b,_,A),P=E?E===A:Ho(g.entrypoints).length===1;d.push({id:`${n}:${k}`,workflowId:k,...b?{bundleId:b}:{},..._?{bundleVersion:_}:{},flowId:A,name:Ne(T.name??T.title)??A,description:Ne(T.description)??"",interfaces:$,...vh(T)?{inputSchema:vh(T)}:{},registryScope:n,isPreferredVersion:n==="tenant_catalog"?g.is_default===!0||g.default_version===_:g.latest_published_version===_,...C&&P?{isDefault:!0}:{}})}}return d}function x_(e){var a;const n=new Map;for(const l of e){const u=l.bundleId||l.id;n.set(u,[...n.get(u)||[],l])}const s=[];for(const l of n.values()){const u=l.filter(g=>g.registryScope==="tenant_catalog"),d=u.length?u:l,f=[...d].sort((g,y)=>+!!y.isPreferredVersion-+!!g.isPreferredVersion||(y.bundleVersion||"").localeCompare(g.bundleVersion||"",void 0,{numeric:!0}))[0],h=(a=l.find(g=>g.isDefault))==null?void 0:a.flowId;for(const g of d.filter(y=>y.bundleVersion===f.bundleVersion))s.push({...g,isDefault:g.flowId===h})}return s.sort((l,u)=>+!!u.isDefault-+!!l.isDefault||l.name.localeCompare(u.name)||l.id.localeCompare(u.id))}function b_(e,n){return n.some(s=>s.id!==e.id&&s.name===e.name)?`${e.name} · ${e.bundleId||e.flowId}`:e.name}function xh(e,n,s={}){const a=[..._h(e,"private",s),..._h(n,"tenant_catalog",s)],l=new Map;for(const u of a)l.set(u.id,u);return[...l.values()].sort((u,d)=>+!!d.isDefault-+!!u.isDefault||u.name.localeCompare(d.name)||u.id.localeCompare(d.id))}function k_(e){const n=tt(e);if(!n)return;const s=tt(n.workflow_selection??n.workflowSelection);if(s)return s;const a=tt(n._runtime),l=tt((a==null?void 0:a.workflow_policy)??(a==null?void 0:a.workflowPolicy));if(l)return l;const u=tt(n.input_data??n.inputData),d=tt(u==null?void 0:u._runtime);return tt((d==null?void 0:d.workflow_policy)??(d==null?void 0:d.workflowPolicy))}function j_(e,n){const s=k_(n.inputData);if(s){const u=Ne(s.registry_scope??s.registryScope),d=Ne(s.bundle_id??s.bundleId),f=Ne(s.bundle_version??s.bundleVersion),h=Ne(s.flow_id??s.flowId);if((u==="private"||u==="tenant_catalog")&&d&&h){const g=e.filter(y=>(y.registryScope??"private")===u&&y.bundleId===d&&y.flowId===h&&(!f||y.bundleVersion===f));if(g.length===1)return g[0]}return}const a=Ne(n.runWorkflowId);if(!a)return;const l=e.filter(u=>(u.registryScope??"private")==="private"&&u.workflowId===a);return l.length===1?l[0]:void 0}function S_(e){const n=tt(e)??{},s=tt(n.policy)??n,l=Ho(s.mounts??s.workspace_mounts).flatMap((d,f)=>{const h=tt(d);if(!h)return[];const g=Ne(h.path??h.root),y=Ne(h.id??h.name)??g??`mount-${f+1}`;return[{id:y,label:Ne(h.label??h.name)??y,...g?{path:g}:{},readOnly:h.read_only===!0||h.readOnly===!0||h.writable===!1,raw:{...h}}]}),u=wa(s.max_attachment_bytes??s.maxAttachmentBytes,1);return{raw:{...s},clientWorkspaceScopeOverrides:s.client_workspace_scope_overrides===!0||s.clientWorkspaceScopeOverrides===!0,allowedAccessModes:Gp(s.allowed_access_modes??s.allowedAccessModes),mounts:l,...u!==void 0?{maxAttachmentBytes:u}:{}}}function N_(e){const n=xu(e,["items","tools"]),s=new Set,a=[];for(const l of n){const u=tt(l);if(!u)continue;const d=Ne(u.name??u.tool_name??u.id);if(!d||s.has(d))continue;s.add(d);const f=u.enabled!==!1&&u.served_disabled!==!0&&u.servedDisabled!==!0,h=wa(u.risk_rank??u.riskRank),g=Hp(u.input_schema??u.inputSchema??u.parameters);a.push({name:d,description:Ne(u.description)??"",...Ne(u.toolset)?{toolset:Ne(u.toolset)}:{},...Ne(u.tier)?{tier:Ne(u.tier)}:{},...Ne(u.approval_default??u.default_approval??u.approvalDefault??u.defaultApproval??u.approval)?{approval:Ne(u.approval_default??u.default_approval??u.approvalDefault??u.defaultApproval??u.approval)}:{},...h!==void 0?{riskRank:h}:{},enabled:f,servedDisabled:!f,...Ne(u.enable_gate??u.enableGate)?{enableGate:Ne(u.enable_gate??u.enableGate)}:{},...Ne(u.why_disabled??u.whyDisabled)?{whyDisabled:Ne(u.why_disabled??u.whyDisabled)}:{},...g?{inputSchema:g}:{},raw:{...u}})}return a.sort((l,u)=>l.name.localeCompare(u.name))}function C_(e){var a;const n=(a=Ne(e.status??e.state))==null?void 0:a.toLowerCase();return Ne(e.wait_reason??e.waitReason)||e.waiting===!0||n==="waiting"||n==="paused"?"waiting":n==="running"||n==="queued"||n==="pending"||n==="created"?"running":n==="failed"||n==="error"||n==="cancelled"||n==="canceled"?"failed":n==="completed"||n==="complete"||n==="done"?"done":"unknown"}const bh={waiting:4,running:3,failed:2,done:1,unknown:0};function fi(e){return Ne(e.updated_at??e.updatedAt??e.finished_at??e.finishedAt??e.created_at??e.createdAt)}function hi(e){if(!e)return Number.NEGATIVE_INFINITY;const n=Date.parse(e);return Number.isFinite(n)?n:Number.NEGATIVE_INFINITY}function kh(e){var d;const n=Ne(e);if(n)return n;const s=tt(e);if(!s)return;const a=Ne(s.prompt);if(a)return a;const l=tt(s.input_data??s.inputData),u=["prompt","request","task","message","query","input"].map(f=>Ne(l==null?void 0:l[f])).find(Boolean);return u||Ne((d=tt(l==null?void 0:l.context))==null?void 0:d.task)}function zc(e,n={}){const s=tt(e),a=(s==null?void 0:s.has_more)===!0||(s==null?void 0:s.hasMore)===!0,l=xu(e,["items","runs"]),u=new Map;l.forEach((f,h)=>{const g=tt(f);if(!g||Ne(g.parent_run_id??g.parentRunId))return;const y=Ne(g.session_id??g.sessionId),x=Ne(g.run_id??g.runId??g.id);if(!y||!x)return;const b=u.get(y)??[];b.push({run:g,index:h}),u.set(y,b)});const d=[];for(const[f,h]of u){const g=[...h].sort((E,C)=>hi(fi(C.run))-hi(fi(E.run))||E.index-C.index),y=[...h].sort((E,C)=>{const j=Ne(E.run.created_at??E.run.createdAt)??fi(E.run),T=Ne(C.run.created_at??C.run.createdAt)??fi(C.run);return hi(j)-hi(T)||E.index-C.index}),x=g.flatMap(({run:E})=>{const C=Ne(E.run_id??E.runId??E.id);return C?[C]:[]});if(!x.length)continue;let b="unknown";for(const{run:E}of h){const C=C_(E);bh[C]>bh[b]&&(b=C)}let _;for(const{run:E}of y){const C=Ne(E.run_id??E.runId??E.id);if(_=(C?kh(n[C]):void 0)??kh(E),_)break}d.push({sessionId:f,state:b,...fi(g[0].run)?{updatedAt:fi(g[0].run)}:{},firstRunId:Ne(y[0].run.run_id??y[0].run.runId??y[0].run.id),latestRunId:x[0],runIds:x,turnCount:h.length,..._?{prompt:_}:{},truncated:a})}return d.sort((f,h)=>hi(h.updatedAt)-hi(f.updatedAt)||f.sessionId.localeCompare(h.sessionId))}function Ko(e){return e?{...e}:{}}function pi(e){if(e!==void 0)return e.flatMap(n=>{const s=Ne(n);return s?[s]:[]})}function E_(e,n,s){var T,A,$,k,P,V,H,L,de;const a=(re,Q)=>{var U,J;!_u(n.workflow)&&!((J=tt((U=n.inputSchema)==null?void 0:U.properties))!=null&&J[re])||Q!==void 0&&s&&(e[re]=Q)},l=Ne((T=n.model)==null?void 0:T.provider),u=Ne((A=n.model)==null?void 0:A.model);if(!!l!=!!u)throw new Error("Choose both a provider and a model, or use the workflow / Gateway defaults.");a("provider",l),a("model",u),n.tools!==void 0&&a("tools",pi(n.tools)??[]);const d=pi(n.skills);d!=null&&d.length&&(e.skills=d);const f=Ne(($=n.workspace)==null?void 0:$.root),h=Ne((k=n.workspace)==null?void 0:k.accessMode),g=pi((P=n.workspace)==null?void 0:P.allowedPaths);f!==void 0&&(e.workspace_root=f),h!==void 0&&(e.workspace_access_mode=h),g!=null&&g.length&&(e.workspace_allowed_paths=g),a("system",Ne(n.system));const y=Ko(tt(e._runtime)),x=(re,Q)=>{Q!==void 0&&s&&(y[re]=Q)};if(x("provider",l),x("model",u),x("thinking",Ne(n.reasoning)),x("speculation",n.speculation),n.streamReplies!==void 0&&x("stream",Wv(n.streamReplies).stream),x("system_prompt_extra",Ne(n.systemPromptExtra)),n.tools!==void 0){const re=pi(n.tools)??[],Q=Array.isArray(y.allowed_tools)?y.allowed_tools:null;y.allowed_tools=Q?re.filter(U=>Q.includes(U)):re}if(n.review!==void 0&&n.reviewCapable!==!1){x("review_mode",n.review.enabled);const re=n.review.enabled?wa(n.review.maxRounds,1):void 0;x("review_max_rounds",re)}const b=pi((V=n.toolPolicy)==null?void 0:V.autoApproveTools),_=pi((H=n.toolPolicy)==null?void 0:H.requireApprovalTools);(((b==null?void 0:b.length)??0)>0||((_==null?void 0:_.length)??0)>0)&&x("tool_policy",{...b!=null&&b.length?{auto_approve_tools:b}:{},..._!=null&&_.length?{require_approval_tools:_}:{}}),n.promptCache!==void 0&&x("prompt_cache",n.promptCache),Object.keys(y).length&&(e._runtime=y);const E=Ko(tt(e._limits)),C=wa((L=n.limits)==null?void 0:L.maxIterations,1),j=wa((de=n.limits)==null?void 0:de.maxTokens,1);C!==void 0&&s&&(E.max_iterations=C),j!==void 0&&s&&(E.max_tokens=j),Object.keys(E).length&&(e._limits=E),a("max_iterations",C),n.gatingMode==="auto"&&a("gating_mode","auto")}function $_(e){var a,l;const n=Ko(e.schemaInputs),s=_u(e.workflow);if(e.promptProperty){const u=Ne(e.promptProperty);u&&((a=e.prompt)!=null&&a.trim())&&(n[u]=e.prompt)}if(s){const u=e.prompt??"";n.prompt=u;const d=Ko(tt(n.context));d.task=u,delete d.messages,n.use_context=!1,(l=e.attachments)!=null&&l.length&&(d.attachments=e.attachments.map(f=>({...f}))),n.context=d,n.use_session_history=e.useSessionHistory??!0}return E_(n,e,!0),n}class A_{constructor(){yn(this,"_buffer","");yn(this,"_current",{data_lines:[]})}push(n,s){for(this._buffer+=n;;){const a=this._buffer.indexOf(`
64
+ `);if(a===-1)return;const l=this._buffer.slice(0,a);this._buffer=this._buffer.slice(a+1);const u=l.endsWith("\r")?l.slice(0,-1):l;if(u.startsWith(":"))continue;if(u===""){if(this._current.data_lines.length>0||this._current.event||this._current.id){const g={id:this._current.id,event:this._current.event,data:this._current.data_lines.join(`
65
+ `)};s(g)}this._current={data_lines:[]};continue}const d=u.indexOf(":"),f=d===-1?u:u.slice(0,d),h=d===-1?"":u.slice(d+1).trimStart();f==="id"?this._current.id=h:f==="event"?this._current.event=h:f==="data"&&this._current.data_lines.push(h)}}}function Ze(e){var a;const n=(e||"").trim(),s={};n&&(s.Authorization=`Bearer ${n}`);try{const l=(a=document.cookie.split(";").map(u=>u.trim()).find(u=>u.startsWith("abstractcode_gateway_csrf=")))==null?void 0:a.slice(26);l&&(s["X-AbstractCode-CSRF"]=decodeURIComponent(l))}catch{}return s}function T_(e){const n=e.headers.get("retry-after");if(!n)return;const s=Number(n);if(Number.isFinite(s)&&s>0)return s}async function R_(e){var n;try{if(String(e.headers.get("content-type")||"").toLowerCase().includes("application/json")){const l=await e.json().catch(()=>null);if(l&&typeof l=="object"){const u=l.detail;if(typeof u=="string"&&u.trim())return u.trim();const d=(n=l.error)==null?void 0:n.message;if(typeof d=="string"&&d.trim())return d.trim();try{const f=JSON.stringify(l);if(f&&f!=="{}")return f}catch{}}}const a=await e.text();return a!=null&&a.trim()?a.trim():`${e.status}`}catch{return`${e.status}`}}class Kp extends Error{constructor(s,a){super(s);yn(this,"status");yn(this,"retry_after_s");yn(this,"body_text");this.name="GatewayHttpError",this.status=Number.isFinite(Number(a.status))?Number(a.status):0,this.retry_after_s=a.retry_after_s,this.body_text=a.body_text}}async function qe(e,n){const s=await R_(e);throw new Kp(`${n}: ${s}`,{status:e.status,retry_after_s:T_(e),body_text:s})}class I_{constructor(n){yn(this,"_cfg");this._cfg={...n,base_url:(n.base_url||"").trim()}}async start_run(n,s,a){const l=String((a==null?void 0:a.bundle_id)||"").trim(),u=(a==null?void 0:a.session_id)===null||(a==null?void 0:a.session_id)===void 0?"":String(a.session_id||"").trim(),d=String(n||"").trim(),f={input_data:s||{}};l&&(f.bundle_id=l),d&&(f.flow_id=d),u&&(f.session_id=u);const h=await fetch(Xe(this._cfg.base_url.trim(),Se("runs/start")),{method:"POST",headers:{"Content-Type":"application/json",...Ze(this._cfg.auth_token)},body:JSON.stringify(f)});if(!h.ok)return await qe(h,"start_run failed");const g=await h.json(),y=g==null?void 0:g.run_id;if(typeof y!="string"||!y)throw new Error("start_run: missing run_id");return y}async get_run(n){const s=String(n||"").trim();if(!s)throw new Error("get_run: run_id is required");const a=await fetch(Xe(this._cfg.base_url.trim(),Se(`runs/${encodeURIComponent(s)}`)),{headers:{...Ze(this._cfg.auth_token)}});return a.ok?await a.json():await qe(a,"get_run failed")}async get_run_history_bundle(n,s){const a=String(n||"").trim();if(!a)throw new Error("get_run_history_bundle: run_id is required");const l=new URLSearchParams;(s==null?void 0:s.include_subruns)===!1&&l.set("include_subruns","false"),(s==null?void 0:s.include_session)===!0&&l.set("include_session","true"),typeof(s==null?void 0:s.session_turn_limit)=="number"&&Number.isFinite(s.session_turn_limit)&&l.set("session_turn_limit",String(Math.max(1,Math.trunc(s.session_turn_limit)))),s!=null&&s.ledger_mode&&l.set("ledger_mode",String(s.ledger_mode)),typeof(s==null?void 0:s.ledger_max_items)=="number"&&Number.isFinite(s.ledger_max_items)&&l.set("ledger_max_items",String(Math.max(0,Math.trunc(s.ledger_max_items))));const u=Xe(this._cfg.base_url.trim(),Se(`runs/${encodeURIComponent(a)}/history_bundle?${l.toString()}`)),d=await fetch(u,{headers:{...Ze(this._cfg.auth_token)}});return d.ok?await d.json():await qe(d,"get_run_history_bundle failed")}async list_runs(n){const s=new URLSearchParams,a=typeof(n==null?void 0:n.limit)=="number"?n.limit:50;s.set("limit",String(a));const l=String((n==null?void 0:n.status)||"").trim();l&&s.set("status",l);const u=String((n==null?void 0:n.workflow_id)||"").trim();u&&s.set("workflow_id",u);const d=String((n==null?void 0:n.session_id)||"").trim();d&&s.set("session_id",d),(n==null?void 0:n.root_only)===!0&&s.set("root_only","true"),(n==null?void 0:n.include_ledger_len)===!1&&s.set("include_ledger_len","false"),(n==null?void 0:n.include_metrics)===!0&&s.set("include_metrics","true");const f=Xe(this._cfg.base_url.trim(),Se(`runs?${s.toString()}`)),h=await fetch(f,{headers:{...Ze(this._cfg.auth_token)}});return h.ok?await h.json():await qe(h,"list_runs failed")}async get_ledger(n,s){const a=String(n||"").trim();if(!a)throw new Error("get_ledger: run_id is required");const l=Number((s==null?void 0:s.after)||0),u=Number((s==null?void 0:s.limit)||0),d=Xe(this._cfg.base_url.trim(),Se(`runs/${encodeURIComponent(a)}/ledger?after=${encodeURIComponent(String(l))}&limit=${encodeURIComponent(String(u))}`)),f=await fetch(d,{headers:{...Ze(this._cfg.auth_token)}});if(!f.ok)return await qe(f,"get_ledger failed");const h=await f.json(),g=Array.isArray(h==null?void 0:h.items)?h.items:[],y=typeof(h==null?void 0:h.next_after)=="number"?h.next_after:l;return{items:g,next_after:y}}async stream_ledger(n,s){var E;const a=String(n||"").trim();if(!a)throw new Error("stream_ledger: run_id is required");if(s.on_delta&&!s.on_delta_error)throw new Error("stream_ledger: on_delta requires on_delta_error (malformed live frames must be reported)");const l=Number((s==null?void 0:s.after)||0),u=s.on_step,d=s.signal,f=Xe(this._cfg.base_url.trim(),Se(`runs/${encodeURIComponent(a)}/ledger/stream?after=${encodeURIComponent(String(l))}`)),h=await fetch(f,{headers:{Accept:"text/event-stream",...Ze(this._cfg.auth_token)},signal:d});if(!h.ok)return await qe(h,"stream_ledger failed");if(!h.body)throw new Error("stream_ledger: response body is missing");(E=s.on_open)==null||E.call(s);const g=h.body.getReader(),y=new TextDecoder("utf-8"),x=new A_,b=s.on_delta,_=s.on_delta_error;for(;;){const{value:C,done:j}=await g.read();if(j)return;const T=y.decode(C,{stream:!0});x.push(T,A=>{if(b&&_){const $=A.event||"message",k=A.data??"";let P;try{P=zv($,k)}catch(V){_(V instanceof Error?V:new Error(String(V)),{event:$,data:k});return}if(P){b(P);return}}if(!(A.event!=="step"||!A.data))try{const $=JSON.parse(A.data);$&&typeof $.cursor=="number"&&$.record&&u($)}catch{}})}}async list_bundles(){const n=await fetch(Xe(this._cfg.base_url.trim(),Se("bundles")),{headers:{...Ze(this._cfg.auth_token)}});return n.ok?await n.json():await qe(n,"list_bundles failed")}async reload_bundles(){const n=await fetch(Xe(this._cfg.base_url.trim(),Se("bundles/reload")),{method:"POST",headers:{...Ze(this._cfg.auth_token)}});return n.ok?await n.json():await qe(n,"reload_bundles failed")}async upload_bundle(n,s){const a=(s==null?void 0:s.overwrite)===!0,l=(s==null?void 0:s.reload)!==!1,u=new FormData;u.set("overwrite",a?"true":"false"),u.set("reload",l?"true":"false"),u.set("file",n,n.name||"upload.flow");const d=await fetch(Xe(this._cfg.base_url.trim(),Se("bundles/upload")),{method:"POST",headers:{...Ze(this._cfg.auth_token)},body:u});return d.ok?await d.json():await qe(d,"upload_bundle failed")}async discovery_tools(){const n=await fetch(Xe(this._cfg.base_url.trim(),Se("discovery/tools")),{headers:{...Ze(this._cfg.auth_token)}});return n.ok?await n.json():await qe(n,"discovery_tools failed")}async discovery_providers(n){const s=(n==null?void 0:n.include_models)===!0,a=Xe(this._cfg.base_url.trim(),Se(`discovery/providers?include_models=${encodeURIComponent(String(s))}`)),l=await fetch(a,{headers:{...Ze(this._cfg.auth_token)}});return l.ok?await l.json():await qe(l,"discovery_providers failed")}async discovery_provider_models(n){const s=String(n||"").trim();if(!s)throw new Error("discovery_provider_models: provider_name is required");const a=await fetch(Xe(this._cfg.base_url.trim(),Se(`discovery/providers/${encodeURIComponent(s)}/models`)),{headers:{...Ze(this._cfg.auth_token)}});return a.ok?await a.json():await qe(a,"discovery_provider_models failed")}async discovery_model_capabilities(n,s=""){const a=String(n||"").trim();if(!a)throw new Error("discovery_model_capabilities: model_name is required");const l=new URLSearchParams({model_name:a});s.trim()&&l.set("provider",s.trim());const u=Xe(this._cfg.base_url.trim(),Se(`discovery/models/capabilities?${l}`)),d=await fetch(u,{headers:{...Ze(this._cfg.auth_token)}});return d.ok?await d.json():await qe(d,"discovery_model_capabilities failed")}async workspace_policy(){const n=await fetch(Xe(this._cfg.base_url.trim(),Se("workspace/policy")),{headers:{...Ze(this._cfg.auth_token)}});return n.ok?await n.json():await qe(n,"workspace_policy failed")}async files_search(n,s){const a=String(n||"").trim(),l=typeof(s==null?void 0:s.limit)=="number"&&Number.isFinite(s.limit)?Math.max(1,Math.trunc(s.limit)):20,u=new URLSearchParams;u.set("query",a),u.set("limit",String(l));const d=s==null?void 0:s.scope;if(d&&typeof d=="object"){const g=String(d.workspace_root||"").trim(),y=String(d.workspace_access_mode||"").trim(),x=String(d.workspace_allowed_paths||"").trim(),b=String(d.workspace_ignored_paths||"").trim();g&&u.set("workspace_root",g),y&&u.set("workspace_access_mode",y),x&&u.set("workspace_allowed_paths",x),b&&u.set("workspace_ignored_paths",b)}const f=Xe(this._cfg.base_url.trim(),Se(`files/search?${u.toString()}`)),h=await fetch(f,{headers:{...Ze(this._cfg.auth_token)},signal:s==null?void 0:s.signal});return h.ok?await h.json():await qe(h,"files_search failed")}async list_run_artifacts(n,s){const a=String(n||"").trim();if(!a)throw new Error("list_run_artifacts: run_id is required");const l=typeof(s==null?void 0:s.limit)=="number"?s.limit:200,u=Xe(this._cfg.base_url.trim(),Se(`runs/${encodeURIComponent(a)}/artifacts?limit=${encodeURIComponent(String(l))}`)),d=await fetch(u,{headers:{...Ze(this._cfg.auth_token)}});return d.ok?await d.json():await qe(d,"list_run_artifacts failed")}async get_run_artifact_blob(n,s,a){const l=String(n||"").trim(),u=String(s||"").trim();if(!l)throw new Error("get_run_artifact_blob: run_id is required");if(!u)throw new Error("get_run_artifact_blob: artifact_id is required");const d=Xe(this._cfg.base_url.trim(),Se(`runs/${encodeURIComponent(l)}/artifacts/${encodeURIComponent(u)}/content`)),f=await fetch(d,{headers:{...Ze(this._cfg.auth_token)}});if(!f.ok)return await qe(f,"get_run_artifact_blob failed");const h=await f.blob(),g=typeof(a==null?void 0:a.max_bytes)=="number"&&Number.isFinite(a.max_bytes)?Math.max(0,Math.trunc(a.max_bytes)):0;if(g>0&&h.size>g)throw new Error(`Artifact too large (${h.size} bytes > ${g} bytes)`);const y=String(f.headers.get("content-type")||"").trim()||"application/octet-stream";return{blob:h,content_type:y}}async get_run_artifact_text(n,s,a){const{blob:l}=await this.get_run_artifact_blob(n,s,a);return await l.text()}async attachments_ingest(n,s,a){const l=String(n||"").trim(),u=String(s||"").trim();if(!l)throw new Error("attachments_ingest: session_id is required");if(!u)throw new Error("attachments_ingest: path is required");const d={session_id:l,path:u},f=a==null?void 0:a.scope;if(f&&typeof f=="object"){const b=String(f.workspace_root||"").trim(),_=String(f.workspace_access_mode||"").trim(),E=String(f.workspace_allowed_paths||"").trim(),C=String(f.workspace_ignored_paths||"").trim();b&&(d.workspace_root=b),_&&(d.workspace_access_mode=_),E&&(d.workspace_allowed_paths=E),C&&(d.workspace_ignored_paths=C)}const h=await fetch(Xe(this._cfg.base_url.trim(),Se("attachments/ingest")),{method:"POST",headers:{"Content-Type":"application/json",...Ze(this._cfg.auth_token)},body:JSON.stringify(d)});if(!h.ok)return await qe(h,"attachments_ingest failed");const g=await h.json(),y=g==null?void 0:g.attachment;if(!y||typeof y!="object")throw new Error("attachments_ingest: missing attachment");if(!String(y.$artifact||"").trim())throw new Error("attachments_ingest: missing attachment.$artifact");return y}async attachments_upload(n,s,a){const l=String(n||"").trim();if(!l)throw new Error("attachments_upload: session_id is required");if(!s)throw new Error("attachments_upload: file is required");const u=String((a==null?void 0:a.filename)||"").trim()||String((s==null?void 0:s.name)||"").trim()||"upload.bin",d=String((a==null?void 0:a.content_type)||"").trim()||String((s==null?void 0:s.type)||"").trim(),f=new FormData;f.append("session_id",l),f.append("file",s,u),f.append("filename",u),d&&f.append("content_type",d);const h=await fetch(Xe(this._cfg.base_url.trim(),Se("attachments/upload")),{method:"POST",headers:{...Ze(this._cfg.auth_token)},body:f});if(!h.ok)return await qe(h,"attachments_upload failed");const g=await h.json(),y=g==null?void 0:g.attachment;if(!y||typeof y!="object")throw new Error("attachments_upload: missing attachment");if(!String(y.$artifact||"").trim())throw new Error("attachments_upload: missing attachment.$artifact");return y}async audio_transcribe(n,s){const a=String(n||"").trim();if(!a)throw new Error("audio_transcribe: run_id is required");const l={audio_artifact:s==null?void 0:s.audio_artifact,request_id:(s==null?void 0:s.request_id)||void 0},u=(s==null?void 0:s.language)===null||(s==null?void 0:s.language)===void 0?"":String(s.language||"").trim();u&&(l.language=u);const d=await fetch(Xe(this._cfg.base_url.trim(),Se(`runs/${encodeURIComponent(a)}/audio/transcribe`)),{method:"POST",headers:{"Content-Type":"application/json",...Ze(this._cfg.auth_token)},body:JSON.stringify(l)});return d.ok?await d.json():await qe(d,"audio_transcribe failed")}async voice_tts(n,s){const a=String(n||"").trim();if(!a)throw new Error("voice_tts: run_id is required");const l={text:String((s==null?void 0:s.text)||"")},u=(s==null?void 0:s.voice)===null||(s==null?void 0:s.voice)===void 0?"":String(s.voice||"").trim(),d=(s==null?void 0:s.format)===null||(s==null?void 0:s.format)===void 0?"":String(s.format||"").trim(),f=(s==null?void 0:s.request_id)===null||(s==null?void 0:s.request_id)===void 0?"":String(s.request_id||"").trim();u&&(l.voice=u),d&&(l.format=d),f&&(l.request_id=f);const h=await fetch(Xe(this._cfg.base_url.trim(),Se(`runs/${encodeURIComponent(a)}/voice/tts`)),{method:"POST",headers:{"Content-Type":"application/json",...Ze(this._cfg.auth_token)},body:JSON.stringify(l)});return h.ok?await h.json():await qe(h,"voice_tts failed")}async submit_command(n){const s={command_id:String((n==null?void 0:n.command_id)||"").trim(),run_id:String((n==null?void 0:n.run_id)||"").trim(),type:String((n==null?void 0:n.type)||"").trim(),payload:n!=null&&n.payload&&typeof n.payload=="object"?n.payload:{}},a=String((n==null?void 0:n.ts)||"").trim();a&&(s.ts=a);const l=String((n==null?void 0:n.client_id)||"").trim();l&&(s.client_id=l);const u=await fetch(Xe(this._cfg.base_url.trim(),Se("commands")),{method:"POST",headers:{"Content-Type":"application/json",...Ze(this._cfg.auth_token)},body:JSON.stringify(s)});return u.ok?await u.json():await qe(u,"submit_command failed")}async bug_report_create(n){const s={session_id:String((n==null?void 0:n.session_id)||"").trim(),description:String((n==null?void 0:n.description)||"")},a=String((n==null?void 0:n.active_run_id)||"").trim();a&&(s.active_run_id=a);const l=String((n==null?void 0:n.workflow_id)||"").trim();l&&(s.workflow_id=l);const u=String((n==null?void 0:n.client)||"").trim();u&&(s.client=u);const d=String((n==null?void 0:n.client_version)||"").trim();d&&(s.client_version=d);const f=String((n==null?void 0:n.user_agent)||"").trim();f&&(s.user_agent=f);const h=String((n==null?void 0:n.url)||"").trim();h&&(s.url=h);const g=String((n==null?void 0:n.provider)||"").trim();g&&(s.provider=g);const y=String((n==null?void 0:n.model)||"").trim();y&&(s.model=y);const x=String((n==null?void 0:n.template)||"").trim();x&&(s.template=x);const b=n==null?void 0:n.context;b&&typeof b=="object"&&(s.context=b);const _=await fetch(Xe(this._cfg.base_url.trim(),Se("bugs/report")),{method:"POST",headers:{"Content-Type":"application/json",...Ze(this._cfg.auth_token)},body:JSON.stringify(s)});return _.ok?await _.json():await qe(_,"bug_report_create failed")}async feature_report_create(n){const s={session_id:String((n==null?void 0:n.session_id)||"").trim(),description:String((n==null?void 0:n.description)||"")},a=String((n==null?void 0:n.active_run_id)||"").trim();a&&(s.active_run_id=a);const l=String((n==null?void 0:n.workflow_id)||"").trim();l&&(s.workflow_id=l);const u=String((n==null?void 0:n.client)||"").trim();u&&(s.client=u);const d=String((n==null?void 0:n.client_version)||"").trim();d&&(s.client_version=d);const f=String((n==null?void 0:n.user_agent)||"").trim();f&&(s.user_agent=f);const h=String((n==null?void 0:n.url)||"").trim();h&&(s.url=h);const g=String((n==null?void 0:n.provider)||"").trim();g&&(s.provider=g);const y=String((n==null?void 0:n.model)||"").trim();y&&(s.model=y);const x=String((n==null?void 0:n.template)||"").trim();x&&(s.template=x);const b=n==null?void 0:n.context;b&&typeof b=="object"&&(s.context=b);const _=await fetch(Xe(this._cfg.base_url.trim(),Se("features/report")),{method:"POST",headers:{"Content-Type":"application/json",...Ze(this._cfg.auth_token)},body:JSON.stringify(s)});return _.ok?await _.json():await qe(_,"feature_report_create failed")}async prompt_cache_stats(n,s){const a=String(n||"").trim(),l=String(s||"").trim();if(!a||!l)throw new Error("prompt_cache_stats: provider and model are required");const u=Xe(this._cfg.base_url.trim(),Se(`prompt_cache/stats?provider=${encodeURIComponent(a)}&model=${encodeURIComponent(l)}`)),d=await fetch(u,{headers:{...Ze(this._cfg.auth_token)}});return d.ok?await d.json():await qe(d,"prompt_cache_stats failed")}async prompt_cache_capabilities(n,s){const a=String(n||"").trim(),l=String(s||"").trim();if(!a||!l)throw new Error("prompt_cache_capabilities: provider and model are required");const u=Xe(this._cfg.base_url.trim(),Se(`prompt_cache/capabilities?provider=${encodeURIComponent(a)}&model=${encodeURIComponent(l)}`)),d=await fetch(u,{headers:{...Ze(this._cfg.auth_token)}});return d.ok?await d.json():await qe(d,"prompt_cache_capabilities failed")}async prompt_cache_saved(n,s){const a=String(n||"").trim(),l=String(s||"").trim();if(!a||!l)throw new Error("prompt_cache_saved: provider and model are required");const u=Xe(this._cfg.base_url.trim(),Se(`prompt_cache/saved?provider=${encodeURIComponent(a)}&model=${encodeURIComponent(l)}`)),d=await fetch(u,{headers:{...Ze(this._cfg.auth_token)}});return d.ok?await d.json():await qe(d,"prompt_cache_saved failed")}async prompt_cache_clear(n){const s={provider:String((n==null?void 0:n.provider)||"").trim(),model:String((n==null?void 0:n.model)||"").trim()},a=(n==null?void 0:n.key)===null||(n==null?void 0:n.key)===void 0?"":String(n.key||"").trim();a&&(s.key=a);const l=await fetch(Xe(this._cfg.base_url.trim(),Se("prompt_cache/clear")),{method:"POST",headers:{"Content-Type":"application/json",...Ze(this._cfg.auth_token)},body:JSON.stringify(s)});return l.ok?await l.json():await qe(l,"prompt_cache_clear failed")}async prompt_cache_save(n){const s={provider:String((n==null?void 0:n.provider)||"").trim(),model:String((n==null?void 0:n.model)||"").trim(),name:String((n==null?void 0:n.name)||"").trim(),key:String((n==null?void 0:n.key)||"").trim(),q8:!!(n!=null&&n.q8)},a=await fetch(Xe(this._cfg.base_url.trim(),Se("prompt_cache/save")),{method:"POST",headers:{"Content-Type":"application/json",...Ze(this._cfg.auth_token)},body:JSON.stringify(s)});return a.ok?await a.json():await qe(a,"prompt_cache_save failed")}async prompt_cache_load(n){const s={provider:String((n==null?void 0:n.provider)||"").trim(),model:String((n==null?void 0:n.model)||"").trim(),name:String((n==null?void 0:n.name)||"").trim(),key:String((n==null?void 0:n.key)||"").trim(),clear_existing:!!(n!=null&&n.clear_existing)},a=await fetch(Xe(this._cfg.base_url.trim(),Se("prompt_cache/load")),{method:"POST",headers:{"Content-Type":"application/json",...Ze(this._cfg.auth_token)},body:JSON.stringify(s)});return a.ok?await a.json():await qe(a,"prompt_cache_load failed")}}function Jp(){const e=document.cookie.split(";").map(n=>n.trim()).find(n=>n.startsWith("abstractcode_gateway_csrf="));return e?{"X-AbstractCode-CSRF":decodeURIComponent(e.slice(26))}:{}}async function ht(e,n={}){if(!e.startsWith(`${Uo}/`))throw new Error("Gateway requests must use the app's authenticated proxy (a relative api/gateway/… path).");const s=new Headers(n.headers);s.set("Accept","application/json"),n.body&&!(n.body instanceof FormData)&&s.set("Content-Type","application/json");for(const[l,u]of Object.entries(Jp()))s.set(l,u);const a=await fetch(e,{...n,headers:s,credentials:"same-origin"});if(!a.ok){const l=await a.text();let u=l;try{const d=JSON.parse(l);u=typeof d.detail=="string"?d.detail:JSON.stringify(d.detail||d)}catch{}throw new Kp(u||`Gateway request failed (${a.status})`,{status:a.status,body_text:l})}if(a.status!==204)return a.json()}const Nn=new I_({base_url:""});function Et(e){return e instanceof Error?e.message:String(e)}function Yr(){return crypto.randomUUID()}async function M_(e,n,s){const{blob:a}=await Nn.get_run_artifact_blob(e,n),l=URL.createObjectURL(a),u=document.createElement("a");u.href=l,u.download=s.replace(/[\\/]/g,"_")||"artifact",u.click(),window.setTimeout(()=>URL.revokeObjectURL(l),1e3)}const ln=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{};function L_(e,n){const s=ln(n);return Object.fromEntries(Object.keys(ln(e.properties)).flatMap(a=>["_runtime","_limits"].includes(a)||!Object.prototype.hasOwnProperty.call(s,a)?[]:[[a,structuredClone(s[a])]]))}function jh(e){if(!e)return;const n=ln(e.input_data_schema||e.input_schema||e.schema||e),s=Object.fromEntries(Object.entries(ln(n.properties)).map(([a,l])=>[a,{...ln(l)}]));for(const a of Array.isArray(e.inputs)?e.inputs:[])a!=null&&a.id&&(s[a.id]={...ln(a.schema),...s[a.id],...a.type?{"x-abstract-type":a.type}:{},...a.label?{title:a.label}:{},...Object.prototype.hasOwnProperty.call(a,"default")?{default:a.default}:{}});for(const[a,l]of Object.entries(ln(e.defaults)))s[a]={...s[a],default:l};return{...n,properties:s}}function P_(e,n){var g;const s=ln(n).nodes;if(!Array.isArray(s))throw new Error("The workflow input declarations could not be verified. Please retry.");const a=s.find(y=>{var x;return(((x=y==null?void 0:y.data)==null?void 0:x.nodeType)||(y==null?void 0:y.type))==="on_flow_start"});if(!a||!Array.isArray((g=a.data)==null?void 0:g.outputs))throw new Error("The workflow start inputs could not be verified. Please retry.");const l=a.data.outputs.filter(y=>typeof(y==null?void 0:y.id)=="string"&&y.id&&y.type!=="execution"&&!["exec","exec-out"].includes(y.id)),u=new Set(l.map(y=>y.id)),d=new Set((Array.isArray(e.required)?e.required:[]).filter(y=>!u.has(y))),f={...e.properties},h=ln(a.data.pinDefaults);for(const y of l)y.required===!0&&d.add(y.id),f[y.id]={...ln(f[y.id]),...ln(y.schema),...y.type?{"x-abstract-type":y.type}:{},...y.label?{title:y.label}:{},...Object.prototype.hasOwnProperty.call(h,y.id)?{default:structuredClone(h[y.id])}:{}};return{...e,properties:f,required:[...d]}}function ma(e){return Object.fromEntries(Object.entries((e==null?void 0:e.properties)||{}).flatMap(([n,s])=>Object.prototype.hasOwnProperty.call(ln(s),"default")?[[n,structuredClone(ln(s).default)]]:[]))}function O_(e){const n=Array.isArray(e.type)?e.type.find(a=>a!=="null"):e.type;if(n)return n;const s=e["x-abstract-type"];return["tools","assertions"].includes(s)?"array":["json_schema","memory","assertion"].includes(s)?"object":"string"}function D_(e){const n=(e==null?void 0:e.properties)||{},s=l=>{const u=n[l];return u&&(u.type==="string"||Array.isArray(u.type)&&u.type.includes("string")||!u.type&&u["x-abstract-type"]==="string")},a=Object.keys(n).filter(l=>{var u;return((u=n[l])==null?void 0:u["x-abstract-role"])==="prompt"&&s(l)});return a.length?a.length===1?a[0]:void 0:["prompt","request","task","message","query","input"].find(s)}function F_(e,n){var l,u,d;if(!e)return[];const s={...ma(e),...n},a=[];for(const f of Array.isArray(e.required)?e.required:[])s[f]===void 0&&a.push(`${((u=(l=e.properties)==null?void 0:l[f])==null?void 0:u.title)||f} is required.`);for(const[f,h]of Object.entries(s)){const g=(d=e.properties)==null?void 0:d[f];if(!g||h===void 0)continue;const y=g.title||f;Array.isArray(g.enum)&&!g.enum.some(E=>JSON.stringify(E)===JSON.stringify(h))&&a.push(`${y} must be one of the available choices.`);const x=Array.isArray(g.type)?g.type:g.type?[g.type]:[];if(h===null&&(x.includes("null")||!x.length))continue;const b=Array.isArray(h)?"array":h===null?"null":typeof h,_=x.includes(b)?b:b==="number"&&x.includes("integer")?"integer":x[0];(_==="number"||_==="integer")&&(typeof h!="number"||!Number.isFinite(h)||_==="integer"&&!Number.isInteger(h))&&a.push(`${y} must be ${_==="integer"?"a whole number":"a number"}.`),typeof h=="number"&&g.minimum!==void 0&&h<g.minimum&&a.push(`${y} must be at least ${g.minimum}.`),typeof h=="number"&&g.maximum!==void 0&&h>g.maximum&&a.push(`${y} must be at most ${g.maximum}.`),_==="string"&&typeof h!="string"&&a.push(`${y} must be text.`),typeof h=="string"&&g.minLength!==void 0&&h.length<g.minLength&&a.push(`${y} must contain at least ${g.minLength} characters.`),_==="boolean"&&typeof h!="boolean"&&a.push(`${y} must be true or false.`),_==="array"&&!Array.isArray(h)&&a.push(`${y} must be a JSON array.`),_==="object"&&(h===null||typeof h!="object"||Array.isArray(h))&&a.push(`${y} must be a JSON object.`)}return a}function Qp(e){const n=(e==null?void 0:e.properties)||{},s=[];for(const[a,l]of Object.entries(n)){const u=ln(l);if(!(a==="provider"||a.endsWith("_provider")||String(u["x-abstract-type"]||"").startsWith("provider")))continue;const d=String(u["x-abstract-type"]||""),f=a.replace("provider","model"),h=Object.keys(n).filter(_=>{var E;return((E=n[_])==null?void 0:E["x-abstract-type"])===d.replace(/^provider/,"model")}),g=f!==a&&n[f]?f:h.length===1?h[0]:"";if(!g)continue;const y=a==="provider"?"":a.startsWith("provider_")?a.slice(9):a.endsWith("_provider")?a.slice(0,-9):d.replace(/^provider_?/,""),x=y&&y!=="text"?`${y}_`:"",b=[`${x}reasoning`,`${x}thinking`,`${x}reasoning_effort`,`reasoning_${y}`,`thinking_${y}`].find(_=>n[_]);s.push({provider:a,model:g,reasoning:b,title:x?x.replace(/_/g," ").trim():"Text model"})}return s}const bu={fetchProviders:async()=>{const e=await Nn.discovery_providers(),n=e.providers||e.items;return Array.isArray(n)?n.map(s=>typeof s=="string"?{name:s}:s):[]},fetchModels:async e=>{const n=await Nn.discovery_provider_models(e),s=n.models||n.items;return Array.isArray(s)?s.map(a=>typeof a=="string"?a:a.id||a.name).filter(Boolean):[]},fetchModelCapabilities:(e,n="")=>Nn.discovery_model_capabilities(e,n)};function z_(e){for(const n of["output.text","input.text"]){const s=(Array.isArray(e==null?void 0:e.routes)?e.routes:[]).find(a=>a.key===n&&a.source!=="not_configured"&&a.provider&&a.model);if(s)return{provider:s.provider,model:s.model}}}function W_(e,n){e.startsWith("provider_")?e=`${e.slice(9)}_provider`:n!=null&&n.startsWith("provider_")&&!e.endsWith("_provider")&&(e=`${n.slice(9)}_provider`);const s={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(!s&&!["music_provider","voice_provider"].includes(e))return bu;const a=e==="voice_provider",l=Se(s?`vision/provider_models?task=${s}`:a?"audio/speech/models?compact=true":"audio/music/models?task=text_to_music"),u=s?`${l}&providers_only=true`:Se(a?"voice/voices?providers_only=true&compact=true":"audio/music/providers?task=text_to_music"),d=f=>Array.isArray(f)?f.map(h=>typeof h=="string"?h:h.id||h.name).filter(Boolean):[];return{fetchProviders:async()=>{const f=await ht(u);if(f.error)throw new Error(f.error);return d(f.providers||f.available_providers||f.items).map(h=>({name:h}))},fetchModels:async f=>{var g,y,x;const h=await ht(`${l}&provider=${encodeURIComponent(f)}`);if(h.error)throw new Error(h.error);return d(((g=h.models_by_provider)==null?void 0:g[f])||((y=h.tts_models_by_provider)==null?void 0:y[f])||((x=h.music_models_by_provider)==null?void 0:x[f])||h.models||h.items)}}}const U_=["gateway_default","on","off"],Yp={status:"loading"};function B_(e,n){if(n)return{status:"unsupported",reason:`the gateway's capabilities could not be read (${n})`};const s=e==null?void 0:e.capabilities,a=s==null?void 0:s.streaming;return!a||typeof a!="object"||a.deltas!==!0?{status:"unsupported",reason:"not supported by this gateway (it does not advertise live replies)"}:{status:"supported",gatewayDefault:typeof a.default=="boolean"?a.default:null}}function V_(e){return U_.includes(e)?e:"gateway_default"}function G_(e,n){return e==="on"&&n.status!=="supported"?"gateway_default":e}function H_(e,n,s){if(e!=="on"||n.status!=="unsupported"||!s.length)return null;const a=s.find(l=>l.role==="user")||s[0];return{after:a.id?String(a.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: ${n.reason}. Replies appear when they are complete.`}}}function K_(e){try{const n=JSON.parse(e);return typeof(n==null?void 0:n.call_id)=="string"&&n.call_id?n.call_id:""}catch{return""}}function J_(e,n){const s=K_(e.frame.data),a=s?`call:${s}`:`error:${e.error.message}`;return{after:n,message:{id:`stream-replies:malformed:${e.runId}:${a}`,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 Q_(e,n){return e.some(s=>s.message.id===n.message.id)?[...e]:[...e,n]}function Y_(e,n){const s=n.filter(f=>!!f);if(!s.length)return[...e];const a=[],l=new Set;for(const f of e){a.push(f);for(const h of s)!l.has(h)&&h.after!==null&&String(f.id)===h.after&&(a.push(h.message),l.add(h))}const u=s.filter(f=>!l.has(f)&&f.after===null),d=s.filter(f=>!l.has(f)&&f.after!==null);return[...u.map(f=>f.message),...a,...d.map(f=>f.message)]}function X_(e){return e.status==="supported"&&e.gatewayDefault!==null?`Gateway default (${e.gatewayDefault?"on":"off"})`:"Gateway default"}const Sn="@default",_i="abstractcode.agent.v1";function Yn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function an(e){return typeof e=="string"&&e.trim()?e.trim():void 0}const Z_="gateway does not report a default agent workflow";function q_(e,n=_i){var y,x;const s=Yn(e);if(!s)return{status:"unavailable",reason:"the gateway's workflow list could not be loaded"};const a=Yn(s.default_agent_workflows);if(!a)return{status:"unavailable",reason:Z_};const l=Yn(a[n]);if(!l){const b=an((x=Yn((y=Yn(s.default_agent_workflows_unavailable))==null?void 0:y[n]))==null?void 0:x.reason);return{status:"unavailable",reason:b?`no default workflow for ${n}: ${b}`:`gateway reports no default workflow for ${n}`}}const u=an(l.bundle_id),d=an(l.flow_id),f=an(l.registry_scope);if(!u||!d||!f)return{status:"unavailable",reason:`gateway's default workflow for ${n} is missing its bundle, flow or registry scope`};const h=an(l.bundle_version);return{status:"ok",workflow:{workflowId:an(l.workflow_id)??`${u}${h?`@${h}`:""}:${d}`,bundleId:u,...h?{bundleVersion:h}:{},flowId:d,registryScope:f,name:an(l.name)??d,...an(l.source)?{source:an(l.source)}:{}}}}function Sh(e){if(e.status==="loading")return"Gateway default (loading…)";if(e.status==="unavailable")return`Gateway default — ${e.reason}`;const{name:n,bundleVersion:s}=e.workflow;return`Gateway default → ${n}${s?` @${s}`:""}`}function ex(e,n,s=_i){if(e.status!=="ok")return null;const a=e.workflow,l=n.find(u=>(u.registryScope??"private")===a.registryScope&&u.bundleId===a.bundleId&&u.flowId===a.flowId&&(!a.bundleVersion||u.bundleVersion===a.bundleVersion));return l||{id:`${a.registryScope}:${a.workflowId}`,workflowId:a.workflowId,bundleId:a.bundleId,...a.bundleVersion?{bundleVersion:a.bundleVersion}:{},flowId:a.flowId,name:a.name,description:"",interfaces:[s],registryScope:a.registryScope}}function Wc(e,n=_i){if(!e||e.interfaces.includes(n))return"";const s=e.interfaces.length?e.interfaces.join(", "):"no interface";return`The gateway default ${e.name} does not declare ${n} (it declares ${s}); it will not run as a coding agent here.`}function tx(e,n,s=_i){return n?[...e]:e.filter(a=>a.interfaces.includes(s))}function nx(e){const n=s=>s===Sn||e.visible.some(a=>a.id===s)||!!e.runId&&e.workflows.some(a=>a.id===s);return e.selection&&n(e.selection)?e.selection:e.preferred&&n(e.preferred)?e.preferred:Sn}function ku(e){var s,a;const n=Yn((a=Yn((s=Yn(e))==null?void 0:s.input_data))==null?void 0:a.workflow_selection);return an(n==null?void 0:n.source)}function rx(e){var n;return ku(e.restoredInputs)==="gateway_default"?Sn:(n=e.restored)==null?void 0:n.id}function sx(e){return!Yn(e)||ku(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 ix(e){return e.selection===Sn?{flow_id:Sn,interface:e.interfaceId??_i,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 ax(e){const n=Yn(e);if(!n)return{text:"the gateway did not report which workflow it started",missing:!0};const s=an(n.name)??an(n.workflow_id)??an(n.flow_id)??"unnamed workflow",a=an(n.bundle_version);return{text:`running ${s}${a?` @${a}`:""}${n.source==="gateway_default"?" (gateway default)":""}`,missing:!1}}const Uc={gatewayDefault:{status:"loading"},workflows:[],choices:[],policy:null,tools:[],sessions:[],capabilities:{},streaming:Yp,loading:!1,errors:[],hasMore:!1};function ox(e){var s;const n=((s=e==null?void 0:e.capabilities)==null?void 0:s.contracts)??(e==null?void 0:e.contracts)??e;return n&&typeof n=="object"&&!Array.isArray(n)?n:{}}function lx(e,n){const[s,a]=w.useState(Uc),[l,u]=w.useState(100),d=w.useRef(0),f=w.useRef(),h=w.useRef({identity:"",values:{}}),g=w.useCallback(async()=>{var T,A;const y=++d.current;(T=f.current)==null||T.abort();const x=new AbortController;if(f.current=x,h.current.identity!==e&&(h.current={identity:e,values:{}}),!e){a(Uc);return}a($=>({...$,loading:!0,errors:[]}));const b=["bundles?all_versions=true&include_drafts=false","workspace/policy","discovery/tools",`runs?root_only=true&include_ledger_len=false&limit=${l}`,"discovery/capabilities","workflow-catalog?scope=tenant","config/capability-defaults"],_=await Promise.allSettled(b.map($=>ht(Se(`${$}`),{signal:x.signal})));if(d.current!==y)return;const E=$=>_[$].status==="fulfilled"?_[$].value:void 0,C=[];_.forEach(($,k)=>{var P,V;$.status==="rejected"&&(((P=$.reason)==null?void 0:P.status)===401&&n(),!(k===5&&[403,404,501].includes((V=$.reason)==null?void 0:V.status))&&C.push(`${["Workflows","Workspace policy","Tools","Conversations","Capabilities","Shared workflows","Gateway defaults"][k]}: ${Et($.reason)}`))}),a({workflows:xh(E(0),E(5)),choices:x_(xh(E(0),E(5))),policy:E(1)?S_(E(1)):null,tools:N_(E(2)),sessions:zc(E(3),h.current.values),capabilities:ox(E(4)),streaming:B_(E(4),_[4].status==="rejected"?Et(_[4].reason):void 0),defaultModel:z_(E(6)),gatewayDefault:q_(E(0)),loading:!1,errors:C,hasMore:!!((A=E(3))!=null&&A.has_more)});const j=zc(E(3),h.current.values).filter($=>!$.prompt&&!($.firstRunId in h.current.values));for(let $=0;$<j.length;$+=4){if(d.current!==y||x.signal.aborted||(await Promise.all(j.slice($,$+4).map(async k=>{try{const P=await ht(Se(`runs/${encodeURIComponent(k.firstRunId)}/input_data`),{signal:x.signal});d.current===y&&!x.signal.aborted&&(h.current.values[k.firstRunId]=P)}catch(P){!x.signal.aborted&&(P==null?void 0:P.status)===401&&n()}})),d.current!==y||x.signal.aborted))return;a(k=>({...k,sessions:zc(E(3),h.current.values)}))}},[e,l,n]);return w.useEffect(()=>{u(100)},[e]),w.useEffect(()=>(a(Uc),g(),()=>{var y;d.current+=1,(y=f.current)==null||y.abort()}),[g]),{...s,refresh:g,loadMore:()=>u(y=>y+100)}}async function cx(e){if(e.inputSchema)return jh(e.inputSchema);if(!e.bundleId)return;const n=encodeURIComponent(e.bundleId),s=encodeURIComponent(e.flowId),a=e.registryScope==="tenant_catalog"&&e.bundleVersion?Se(`workflow-catalog/${n}/versions/${encodeURIComponent(e.bundleVersion)}/flows/${s}/input_schema?scope=tenant`):Se(`bundles/${n}/flows/${s}/input_schema${e.bundleVersion?`?bundle_version=${encodeURIComponent(e.bundleVersion)}`:""}`),l=await ht(a),u=jh(l);if(!u||l!=null&&l.native_loop_factory||(l==null?void 0:l.version)!==1||!Array.isArray(l==null?void 0:l.inputs)||!(l!=null&&l.input_data_schema)||!Array.isArray(u.required)||!u.required.length)return u;const d=e.bundleVersion||l.bundle_version;if(!d)throw new Error("The Gateway did not identify the workflow version. Refresh workflows and retry.");const f={bundle_id:e.bundleId,bundle_version:d,flow_id:e.flowId},h=x=>{for(const[b,_]of Object.entries(f))if((x==null?void 0:x[b])!==_)throw new Error("The Gateway returned inputs for a different workflow version. Refresh workflows and retry.");if(e.registryScope==="tenant_catalog"&&(x==null?void 0:x.registry_scope)!=="tenant_catalog")throw new Error("The Gateway returned inputs from a different workflow registry. Refresh workflows and retry.")};h(l);const g=e.registryScope==="tenant_catalog"?Se(`workflow-catalog/${n}/versions/${encodeURIComponent(d)}/flows/${s}?scope=tenant`):Se(`bundles/${n}/flows/${s}?bundle_version=${encodeURIComponent(d)}`),y=await ht(g);return h(y),P_(u,y.flow)}const Bc=e=>Se(`runs/${encodeURIComponent(e)}`);function ux(e){return{getRun:(n,s)=>ht(Bc(n),{signal:s}),getHistory:(n,s)=>ht(`${Bc(n)}/history_bundle?include_subruns=true&include_session=true&ledger_mode=full`,{signal:s}),getLedger:(n,s,a)=>ht(`${Bc(n)}/ledger?after=${s}&limit=200`,{signal:a}),streamLedger:(n,s,a,l,u,d)=>Nn.stream_ledger(n,{after:s,on_step:a,signal:l,on_open:u,on_delta:d,on_delta_error:(f,h)=>e.onDeltaError({runId:n,error:f,frame:h})}),submitCommand:(n,s)=>ht(Se("commands"),{method:"POST",body:JSON.stringify(n),signal:s})}}function Kn(e){return typeof e=="string"?e.trim():""}function dx(e){const n=e&&typeof e=="object"&&!Array.isArray(e)?e:{},a=(Array.isArray(n.skills)?n.skills:[]).flatMap(f=>{const h=f&&typeof f=="object"&&!Array.isArray(f)?f:null,g=Kn(h==null?void 0:h.name);if(!h||!g)return[];const y=h.source&&typeof h.source=="object"&&!Array.isArray(h.source)?h.source:void 0;return[{name:g,description:Kn(h.description),trustLevel:Kn(h.trust_level)||"unverified",blocked:h.blocked===!0,requiresReview:h.requires_review===!0,reasons:Array.isArray(h.reasons)?h.reasons.map(Kn).filter(Boolean):[],source:y?{source:Kn(y.source),binding:Kn(y.binding),ambiguous:y.ambiguous===!0}:void 0}]}),l=Array.isArray(n.warnings)?n.warnings.map(Kn).filter(Boolean):[],u=Kn(n.shelf),d=Kn(n.shelf_source);return{skills:a.sort((f,h)=>f.name.localeCompare(h.name)),warnings:l,...u?{shelf:u}:{},...d?{shelfSource:d}:{}}}function fx({inventory:e}){return i.jsxs("div",{className:"code-skills-empty",role:"status",children:[i.jsx("p",{children:i.jsx("strong",{children:"This gateway offers no skills."})}),e.warnings.length?e.warnings.map((n,s)=>i.jsx("p",{children:e.shelf?n:`The gateway has no skill shelf: ${n}`},`${n}:${s}`)):i.jsx("p",{children:"The gateway gave no reason for the empty list."}),e.shelf?i.jsxs("p",{className:"code-field-help",children:["Skill shelf: ",i.jsx("code",{children:e.shelf}),e.shelfSource?` (source: ${e.shelfSource})`:""]}):i.jsx("p",{className:"code-field-help",children:"The gateway did not report a skill shelf location."})]})}function hx(e){var a;const n=e.trustLevel.replace(/[_-]+/g," "),s=(a=e.source)!=null&&a.source?`Adopted from ${e.source.source}`:"Source has no adoption record";return`Trust: ${n}. ${s}${e.requiresReview?". Review required":""}.`}function px({value:e,onChange:n,disabled:s}){const[a,l]=w.useState({skills:[],warnings:[]}),[u,d]=w.useState(""),[f,h]=w.useState(!0),[g,y]=w.useState(""),[x,b]=w.useState(0);w.useEffect(()=>{const j=new AbortController;return h(!0),y(""),ht(Se("skills"),{signal:j.signal}).then(T=>{j.signal.aborted||l(dx(T))}).catch(T=>{j.signal.aborted||y(Et(T))}).finally(()=>{j.signal.aborted||h(!1)}),()=>j.abort()},[x]);const _=w.useMemo(()=>new Set(e.map(Kn).filter(Boolean)),[e]),E=w.useMemo(()=>{const j=u.trim().toLocaleLowerCase();return j?a.skills.filter(T=>`${T.name}
66
+ ${T.description}
67
+ ${T.trustLevel}`.toLocaleLowerCase().includes(j)):a.skills},[a.skills,u]),C=(j,T)=>{const A=T?[..._,j]:[..._].filter($=>$!==j);n([...new Set(A)])};return i.jsxs("section",{className:"code-settings-section","aria-labelledby":"code-skills-heading",children:[i.jsx("h3",{id:"code-skills-heading",children:"Skills"}),i.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."}),i.jsxs("label",{className:"code-field",children:["Find a skill",i.jsx("input",{type:"search",value:u,onChange:j=>d(j.target.value),disabled:s||f,placeholder:"Search names, descriptions, or trust"})]}),f?i.jsx("p",{className:"code-muted",role:"status",children:"Loading skills from the gateway…"}):null,g?i.jsxs("div",{className:"code-inline-error",role:"alert",children:["Skill selection is unavailable: ",g," ",i.jsx("button",{className:"code-text-button",type:"button",onClick:()=>b(j=>j+1),disabled:s,children:"Retry"})]}):null,a.warnings.length&&a.skills.length?i.jsxs("details",{className:"code-disabled-tools",children:[i.jsxs("summary",{children:["Gateway reported ",a.warnings.length," skills warning",a.warnings.length===1?"":"s"]}),a.warnings.map((j,T)=>i.jsx("p",{children:j},`${j}:${T}`))]}):null,!f&&!g&&!a.skills.length?i.jsx(fx,{inventory:a}):null,!f&&!g&&a.skills.length&&!E.length?i.jsx("p",{className:"code-muted",children:"No skills match your search."}):null,E.map(j=>{const T=j.reasons.join(" ")||"Blocked by gateway policy.",A=_.has(j.name),$=s||j.blocked;return i.jsxs("label",{className:"code-field",children:[i.jsxs("span",{children:[i.jsx("input",{type:"checkbox",checked:A,disabled:$,onChange:k=>C(j.name,k.target.checked)})," ",i.jsx("strong",{children:j.name})]}),j.description?i.jsx("span",{className:"code-field-help",children:j.description}):null,i.jsx("span",{className:"code-field-help",children:hx(j)}),j.blocked?i.jsxs("span",{className:"code-error-text",children:["Blocked by the gateway: ",T]}):null]},j.name)})]})}function ju(e){if(!["ArrowLeft","ArrowRight","Home","End"].includes(e.key))return;const n=[...e.currentTarget.querySelectorAll('button[role="tab"]')].filter(l=>!l.disabled),s=n.indexOf(e.target);if(s<0||!n.length)return;e.preventDefault();const a=e.key==="Home"?0:e.key==="End"?n.length-1:(s+(e.key==="ArrowRight"?1:-1)+n.length)%n.length;n[a].focus(),n[a].click()}function Xp(e,n,s="default"){const a=e.filter(u=>u.enabled&&!u.servedDisabled&&(n.mode==="all"||n.selected.includes(u.name))),l=u=>{const d=n.approval[u.name];if(d==="ask")return!1;if(d==="approve"||s==="all")return!0;const f=["auto","approve"].includes((u.approval||"").trim().toLowerCase());if(s==="default")return f;const h=f?1:["write_file","edit_file"].includes(u.name)?2:3,g=u.riskRank===void 0||u.riskRank===1?1:u.riskRank===2?2:3;return Math.max(h,g)<=(s==="write"?2:1)};return{enabledTools:a.map(u=>u.name),autoApproveTools:a.filter(l).map(u=>u.name),requireApprovalTools:a.filter(u=>!l(u)).map(u=>u.name)}}function mx(e,n){if(!Array.isArray(n))return e;const s=a=>n.includes(a);return{enabledTools:e.enabledTools.filter(s),autoApproveTools:e.autoApproveTools.filter(s),requireApprovalTools:e.requireApprovalTools.filter(s)}}const yr={provider:"",model:"",reasoning:"",maxIterations:"",maxTokens:"",system:"",workspaceRoot:"",workspaceMode:"",allowedPaths:"",tools:{mode:"all",selected:[],approval:{}},toolsCustomized:!1,permissions:"default",skills:[],workflow:"@default",showAllWorkflows:!1,streamReplies:"gateway_default"};function gx({open:e,onClose:n,tab:s,onTab:a,value:l,onChange:u,policy:d,tools:f,disabled:h,defaultModel:g,workflowDefault:y,streaming:x=Yp}){const b=_=>u({...l,..._});return i.jsx(Yc,{open:e,onClose:n,label:"Run settings",title:"Run settings",width:480,topOffset:60,className:"code-settings-drawer",children:i.jsxs("div",{className:"code-settings",children:[i.jsx("p",{className:"code-muted",children:"Settings apply to the next turn. Your gateway enforces the available permissions."}),i.jsx("div",{className:"code-settings-tabs",role:"tablist","aria-label":"Settings sections",onKeyDown:ju,children:["model","workspace","tools","skills"].map(_=>i.jsx("button",{role:"tab",tabIndex:s===_?0:-1,"aria-selected":s===_,onClick:()=>a(_),children:_==="model"?"Model & behavior":_==="workspace"?"Workspace":_==="tools"?"Tools":"Skills"},_))}),h?i.jsx("p",{className:"code-notice",children:"Settings are unavailable while disconnected or while a run is active. Reconnect, or finish or stop the run, then try again."}):null,s==="model"?i.jsxs(i.Fragment,{children:[i.jsxs("section",{className:"code-settings-section",children:[i.jsx("h3",{children:"Model"}),i.jsx(uu,{defaultModeLabel:y?"Workflow default":"Gateway default",value:l,onChange:b,disabled:h,effectiveDefault:g,fetchModelCapabilities:bu.fetchModelCapabilities,enableSpeculation:!0,defaultHint:g?`${y?"Workflow":"Gateway"} default: ${g.provider} · ${g.model}.`:void 0,fetchProviders:async()=>{const _=await Nn.discovery_providers();return Array.isArray(_.providers)?_.providers:Array.isArray(_.items)?_.items:[]},fetchModels:async _=>{const E=await Nn.discovery_provider_models(_);return(Array.isArray(E.models)?E.models:Array.isArray(E.items)?E.items:[]).map(C=>typeof C=="string"?C:C.id||C.name)}})]}),i.jsxs("section",{className:"code-settings-section",children:[i.jsx("h3",{children:"Behavior"}),i.jsxs("div",{className:"code-field-pair",children:[i.jsxs("label",{className:"code-field",children:["Iteration limit",i.jsx("input",{type:"number",min:1,step:1,placeholder:"Workflow default",value:l.maxIterations,disabled:h,onChange:_=>b({maxIterations:_.target.value})})]}),i.jsxs("label",{className:"code-field",children:["Context token limit",i.jsx("input",{type:"number",min:1,step:1,placeholder:"Gateway default",value:l.maxTokens,disabled:h,onChange:_=>b({maxTokens:_.target.value})})]})]}),i.jsxs("label",{className:"code-field",children:["Additional instructions",i.jsx("textarea",{rows:5,value:l.system,placeholder:"Project conventions or guidance for this conversation…",disabled:h,onChange:_=>b({system:_.target.value})})]}),i.jsx("p",{className:"code-field-help",children:"Reasoning and additional instructions depend on the selected workflow and model."}),i.jsx(yx,{value:l.streamReplies,onChange:_=>b({streamReplies:_}),disabled:h,streaming:x})]})]}):s==="workspace"?i.jsxs("section",{className:"code-settings-section",children:[i.jsx("h3",{children:"Workspace access"}),i.jsxs("div",{className:"code-policy",children:[i.jsx("strong",{children:d!=null&&d.clientWorkspaceScopeOverrides?"Client scope requests enabled":"Managed by your gateway"}),i.jsx("p",{children:d!=null&&d.clientWorkspaceScopeOverrides?"You may request a workspace scope. Gateway policy remains authoritative.":"The gateway chooses and restricts the workspace. File browsing and tool execution follow the same policy."})]}),i.jsxs("dl",{className:"code-facts",children:[i.jsx("dt",{children:"Allowed access modes"}),i.jsx("dd",{children:(d==null?void 0:d.allowedAccessModes.join(", "))||"Gateway default"}),i.jsx("dt",{children:"Available mounts"}),i.jsx("dd",{children:d!=null&&d.mounts.length?d.mounts.map(_=>_.label).join(", "):"Default workspace"})]}),d!=null&&d.clientWorkspaceScopeOverrides?i.jsxs(i.Fragment,{children:[i.jsxs("label",{className:"code-field",children:["Workspace root",i.jsx("input",{value:l.workspaceRoot,placeholder:"Gateway default",disabled:h,onChange:_=>b({workspaceRoot:_.target.value})})]}),i.jsxs("label",{className:"code-field",children:["Access mode",i.jsxs("select",{value:l.workspaceMode,disabled:h,onChange:_=>b({workspaceMode:_.target.value}),children:[i.jsx("option",{value:"",children:"Gateway default"}),d.allowedAccessModes.map(_=>i.jsx("option",{value:_,children:_.replace(/_/g," ")},_))]})]}),l.workspaceMode==="workspace_or_allowed"?i.jsxs("label",{className:"code-field",children:["Additional allowed paths",i.jsx("textarea",{rows:3,value:l.allowedPaths,disabled:h,placeholder:"One path per line",onChange:_=>b({allowedPaths:_.target.value})})]}):null]}):null]}):s==="tools"?i.jsxs("section",{className:"code-settings-section",children:[i.jsxs("label",{className:"code-field",children:["Permissions",i.jsxs("select",{"aria-label":"Permissions",value:l.permissions,disabled:h,onChange:_=>b({permissions:_.target.value}),children:[i.jsx("option",{value:"default",children:"Workflow / Gateway defaults"}),i.jsx("option",{value:"read",children:"Read"}),i.jsx("option",{value:"write",children:"Write"}),i.jsx("option",{value:"all",children:"All enabled tools"})]})]}),i.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."}),i.jsx(fy,{tools:f.filter(_=>_.enabled).map(_=>({..._,default_approval:Xp(f,l.tools,l.permissions).autoApproveTools.includes(_.name)?"approve":"ask"})),value:l.tools,onChange:_=>b({tools:_,toolsCustomized:!0}),disabled:h,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."}),f.some(_=>!_.enabled)?i.jsxs("details",{className:"code-disabled-tools",children:[i.jsxs("summary",{children:[f.filter(_=>!_.enabled).length," tools unavailable under gateway policy"]}),f.filter(_=>!_.enabled).map(_=>i.jsxs("p",{children:[i.jsx("strong",{children:_.name}),i.jsx("br",{}),_.whyDisabled||"Disabled by the gateway"]},_.name))]}):null,i.jsx("button",{className:"code-text-button",disabled:h,onClick:()=>b({toolsCustomized:!1,tools:yr.tools,permissions:"default"}),children:"Use workflow tool defaults"})]}):i.jsx(px,{value:l.skills,onChange:_=>b({skills:_}),disabled:h})]})})}function yx({value:e,onChange:n,disabled:s,streaming:a}){const l=a.status!=="supported",u=a.status==="unsupported"?`Unavailable: ${a.reason}. Replies appear when they are complete.`:a.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 i.jsxs(i.Fragment,{children:[i.jsxs("label",{className:"code-field",children:["Stream replies",i.jsxs("select",{"aria-label":"Stream replies","aria-describedby":"code-stream-replies-help",value:e,disabled:s||l,onChange:d=>n(d.target.value),children:[i.jsx("option",{value:"gateway_default",children:X_(a)}),i.jsx("option",{value:"on",children:"On"}),i.jsx("option",{value:"off",children:"Off"})]})]}),i.jsx("p",{id:"code-stream-replies-help",className:"code-field-help","data-streaming":a.status,children:u})]})}async function wx(e){var s;const n=String(e??"");if(!n)return!1;try{if((s=navigator==null?void 0:navigator.clipboard)!=null&&s.writeText)return await navigator.clipboard.writeText(n),!0}catch{}try{const a=document.createElement("textarea");a.value=n,a.setAttribute("readonly","true"),a.style.position="fixed",a.style.top="-1000px",a.style.left="-1000px",document.body.appendChild(a),a.select(),a.setSelectionRange(0,a.value.length);const l=document.execCommand("copy");return document.body.removeChild(a),!!l}catch{return!1}}const vx=3,Nh=["KB","MB","GB","TB"];function va(e){const n=Math.max(0,Number(e)||0);if(n<1024)return`${n} B`;let s=n/1024,a=0;for(;s>=1024&&a<Nh.length-1;)s/=1024,a+=1;return`${s<10?Math.round(s*10)/10:Math.round(s)} ${Nh[a]}`}function Ch(e){return`${Math.round(e).toLocaleString("en-US")} bytes`}function Zp(e,n){if(!n||!(n>0)||e.size<=n)return null;let s=va(e.size),a=va(n);return s===a&&(s=Ch(e.size),a=Ch(n)),`${e.name||"This file"} is ${s}; the gateway accepts files up to ${a}.`}function _x(e){return`Upload failed: ${String(e||"").replace(/^attachments_upload failed:?\s*/i,"").trim()||"the gateway did not say why"}`}function xx(e,n,s){return e.map(a=>{const l=Zp(a,n);return{id:s(),file:a,name:a.name||"Untitled file",size:a.size,status:l?"refused":"queued",...l?{message:l}:{}}})}async function bx(e,n,s){let a=0;const l=Array.from({length:Math.max(1,Math.min(Math.floor(n)||1,e.length))},async()=>{for(;a<e.length;){const u=e[a];a+=1,await s(u)}});await Promise.all(l)}function Jo(e){return`${e} ${e===1?"file":"files"}`}function Eh(e,n){const s=[];return e&&s.push(`${Jo(e)} attached`),n&&s.push(`${Jo(n)} could not be attached`),s.join(", ")}function kx(e){const n=e.filter(l=>l.status==="queued"||l.status==="uploading").length;if(n)return`Wait for ${Jo(n)} to finish uploading.`;const s=e.filter(l=>l.status==="failed"||l.status==="refused");if(!s.length)return null;const a=s.some(l=>l.status==="failed");return s.length===1?`"${s[0].name}" was not attached. ${a?"Retry or remove":"Remove"} it before sending.`:`${Jo(s.length)} were not attached. ${a?"Retry or remove":"Remove"} them before sending.`}const $h=1024*1024,jx="1 MiB",Ah=e=>Se(`runs/${encodeURIComponent(e)}/workspace`),ou=(e,n)=>fetch(e,{...n,credentials:"same-origin"}),Sx=new Set("txt log csv tsv py js mjs cjs ts tsx jsx rs go java kt c h cc cpp hpp cs rb php swift sh bash zsh fish ps1 toml yaml yml ini cfg conf env xml css scss less sql graphql proto gradle make mk dockerfile gitignore lock r jl lua pl ex exs erl hs ml vue svelte tex rst adoc org diff patch".split(" ")),Nx=new Set("png jpg jpeg gif webp bmp ico avif svg".split(" "));function Cx(e){const n=e.split("/").pop()||e,s=n.lastIndexOf(".");return s>0?n.slice(s+1).toLowerCase():n.toLowerCase()}function Th(e,n=""){const s=Cx(e),a=n.split(";",1)[0].trim().toLowerCase();return s==="md"||s==="markdown"||a==="text/markdown"?"markdown":s==="json"||s==="jsonl"||a==="application/json"||a.endsWith("+json")?s==="jsonl"?"text":"json":Nx.has(s)||a.startsWith("image/")?"image":s==="html"||s==="htm"||a==="text/html"?"html":Sx.has(s)||a.startsWith("text/")||["application/javascript","application/xml","application/x-yaml","application/toml"].includes(a)?"text":"binary"}function Ex(e){var n;return e.open_supported===!0&&((n=e.host)==null?void 0:n.caller_is_this_machine)===!0}function $x({info:e,onCopy:n,onOpen:s,opening:a}){var u,d;const l=((u=e.host)==null?void 0:u.caller_is_this_machine)!==!0;return i.jsxs("div",{className:"code-session-workspace",children:[i.jsxs("div",{className:"code-session-workspace-path",children:[i.jsx("code",{title:e.workspace_root,children:e.workspace_root}),i.jsx("button",{className:"code-icon-button","aria-label":"Copy workspace path",title:"Copy path",onClick:n,children:i.jsx(ae,{name:"copy",size:13})})]}),l?i.jsxs("p",{className:"code-field-help",children:["on the gateway host ",((d=e.host)==null?void 0:d.hostname)||"(hostname not reported)"]}):null,e.exists?null:i.jsx("p",{className:"code-field-help",children:"This folder does not exist yet. It appears when the workflow writes its first file."}),Ex(e)?i.jsxs("button",{className:"code-subtle-button",onClick:s,disabled:a,children:[i.jsx(ae,{name:"terminal",size:13}),i.jsx("span",{children:a?"Opening…":"Open folder"})]}):null]})}function Rh(e,n){return typeof e.size_bytes!="number"?null:Zp({name:e.name,size:e.size_bytes},n)}function Ax(e,n){return n?n.status==="refused"?`Not attached: ${n.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.`}function qp(e){const n=e.headers.get("content-range"),s=n?Number(n.split("/")[1]):NaN;if(Number.isFinite(s))return s;const a=Number(e.headers.get("content-length"));return e.status===200&&Number.isFinite(a)&&e.headers.has("content-length")?a:void 0}async function Tx(e,n,s){var g;const a=new TextDecoder;let l="",u=0;const d=(g=e.body)==null?void 0:g.getReader();if(d){for(;u<n;){const{done:y,value:x}=await d.read();if(y)break;const b=x.subarray(0,n-u);u+=b.length,l+=a.decode(b,{stream:!0})}await d.cancel().catch(()=>{})}const f=qp(e)??s,h=f!==void 0?f>u:u>=n;return{text:l,received:u,total:f,partial:h}}function Rx(e){return`Showing the first ${jx} of ${e!==void 0?Up(e):"a file of unknown size"}; download for the rest.`}function Ix(e,n,s){const a=Se(`runs/${encodeURIComponent(n)}/workspace/content?`),l=s.split("/").slice(0,-1),u=h=>{if(/^[a-z][a-z0-9+.-]*:/i.test(h)||h.startsWith("/")||h.startsWith("#"))return null;const g=[...l];for(const y of h.split(/[?#]/,1)[0].split("/"))if(!(!y||y==="."))if(y===".."){if(!g.length)return null;g.pop()}else g.push(Mx(y));return g.length?ya(n,g.join("/")):null},d=h=>{let g="",y=0;for(;y<h.length;){if(h[y]==="!"&&h[y+1]==="["){const x=h.indexOf("]",y+2);if(x!==-1&&h[x+1]==="("){const b=h.indexOf(")",x+2);if(b!==-1){const _=h.slice(y+2,x),E=h.slice(x+2,b).trim(),C=E.startsWith(a)?E:u(E);g+=C?`![${_}](${C})`:`[image: ${_||E}](${E})`,y=b+1;continue}}}g+=h[y],y+=1}return g};let f=!1;return e.split(`
68
+ `).map(h=>/^\s*(```|~~~)/.test(h)?(f=!f,h):f?h:d(h)).join(`
69
+ `)}function Mx(e){try{return decodeURIComponent(e)}catch{return e}}function Lx({entry:e,url:n,state:s,onAttach:a,attaching:l}){return i.jsxs("div",{className:"code-file-preview","aria-label":`Preview of ${e.name}`,children:[i.jsxs("div",{className:"code-file-preview-head",children:[i.jsx("strong",{title:e.path,children:e.name}),i.jsx("a",{className:"code-text-button",href:n,download:e.name,children:"Download"}),i.jsx("button",{className:"code-text-button",onClick:a,disabled:l,children:l?"Attaching…":"Attach to conversation"})]}),s.status==="loading"?i.jsx("p",{className:"code-muted",role:"status",children:"Loading preview…"}):s.status==="error"?i.jsx("p",{className:"code-error-text",role:"alert",children:s.message}):s.status==="ready"?i.jsxs(i.Fragment,{children:[s.partial?i.jsx("p",{className:"code-field-help",role:"status",children:Rx(s.total)}):null,s.kind==="image"?i.jsx("img",{className:"code-file-preview-image",src:n,alt:e.name}):s.kind==="markdown"?i.jsx(Cp,{text:s.text||""}):s.kind==="json"?i.jsx(Px,{text:s.text||""}):s.kind==="binary"?i.jsx("p",{className:"code-field-help",children:"No preview for this file type. Use Download to open it."}):i.jsx("pre",{className:"code-file-preview-text",children:s.text})]}):null]})}function Px({text:e}){try{return i.jsx(Cs,{value:JSON.parse(e),collapseAfterDepth:2})}catch(n){return i.jsxs(i.Fragment,{children:[i.jsxs("p",{className:"code-field-help",children:["Not valid JSON (",Et(n),"); shown as text."]}),i.jsx("pre",{className:"code-file-preview-text",children:e})]})}}function Ox({runId:e,enabled:n,refreshKey:s,maxAttachmentBytes:a,onAttachFiles:l,heading:u="Conversation workspace"}){const[d,f]=w.useState(null),[h,g]=w.useState(""),[y,x]=w.useState(0),[b,_]=w.useState(""),[E,C]=w.useState(!1),[j,T]=w.useState(null),[A,$]=w.useState({status:"idle"}),[k,P]=w.useState(!1),V=w.useCallback(L=>T(L),[]);if(w.useEffect(()=>{T(null)},[e]),w.useEffect(()=>{if(f(null),g(""),!n||!e)return;const L=new AbortController;return ht(Ah(e),{signal:L.signal}).then(de=>f(de)).catch(de=>{L.signal.aborted||g(Et(de))}),()=>L.abort()},[n,e,y]),w.useEffect(()=>{if(!j||!e){$({status:"idle"});return}if(Th(j.name)==="image"){$({status:"ready",kind:"image",partial:!1});return}const de=new AbortController;return $({status:"loading"}),fetch(ya(e,j.path),{credentials:"same-origin",signal:de.signal,headers:{Range:`bytes=0-${$h-1}`}}).then(async re=>{var J;if(!re.ok)throw new Error(`Preview failed (${re.status}): ${await re.text()||re.statusText}`);const Q=Th(j.name,re.headers.get("content-type")||"");if(Q==="binary"||Q==="image"){await((J=re.body)==null?void 0:J.cancel().catch(()=>{})),$({status:"ready",kind:Q,partial:!1});return}const U=await Tx(re,$h,j.size_bytes);$({status:"ready",kind:Q,text:Q==="markdown"?Ix(U.text,e,j.path):U.text,partial:U.partial,total:U.total})}).catch(re=>{de.signal.aborted||$({status:"error",message:Et(re)})}),()=>de.abort()},[e,j,s]),!e)return i.jsxs("div",{className:"code-pane-empty",children:[i.jsx(ae,{name:"terminal",size:28}),i.jsx("p",{children:"This conversation's files appear here."}),i.jsx("small",{children:"Start a conversation; the files its workflow creates and edits are listed and previewed here."})]});const H=async()=>{if(!j)return;_("");const L=Rh(j,a);if(L){_(`Not attached: ${L}`);return}P(!0);try{const de=new AbortController,re=await fetch(ya(e,j.path),{credentials:"same-origin",signal:de.signal});if(!re.ok)throw new Error(`Could not read ${j.name} (${re.status}): ${await re.text()}`);const Q=Rh({...j,size_bytes:qp(re)},a);if(Q){de.abort(),_(`Not attached: ${Q}`);return}const U=await re.blob(),[J]=l([new File([U],j.name,{type:U.type})]);_(Ax(j.name,J))}catch(de){_(Et(de))}finally{P(!1)}};return i.jsxs(i.Fragment,{children:[h?i.jsxs("div",{className:"code-inline-error",role:"alert",children:["Workspace unavailable: ",h,i.jsx("button",{onClick:()=>x(L=>L+1),children:"Retry"})]}):null,d?i.jsx($x,{info:d,opening:E,onCopy:()=>{wx(d.workspace_root).then(L=>_(L?"Path copied.":"Could not copy; select the path instead."))},onOpen:()=>{C(!0),_(""),ht(`${Ah(e)}/open`,{method:"POST"}).then(()=>_("Folder opened on this machine.")).catch(L=>_(`Open folder failed: ${Et(L)}`)).finally(()=>C(!1))}}):null,b?i.jsx("p",{className:"code-field-help",role:"status",children:b}):null,n?i.jsx(Vp,{fetchGateway:ou,runId:e,title:u,onSelectFile:V,selectedPath:j==null?void 0:j.path,refreshKey:`${s??""}:${y}`,className:"code-workspace-browser"},e):null,j?i.jsx(Lx,{entry:j,url:ya(e,j.path),state:A,attaching:k,onAttach:()=>void H()}):null]})}const Dx=new Set(["abstract.progress","abstractcode.progress"]);function mi(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Ns(e){const n=typeof e=="number"?e:Number(e);return Number.isFinite(n)?n:null}function Fx(e){if(!mi(e))return null;const n=mi(e.effect)?e.effect:null;if(!n||String(n.type||"")!=="emit_event")return null;const s=mi(n.payload)?n.payload:null,a=String((s==null?void 0:s.name)??(s==null?void 0:s.event_name)??"").trim();if(!Dx.has(a))return null;const l=mi(e.result)?e.result:null,u=mi(l==null?void 0:l.payload)?l==null?void 0:l.payload:null,d=mi(s==null?void 0:s.payload)?s==null?void 0:s.payload:null,f=u||d;if(!f||String(f.kind||"")!=="llm")return null;const h=String(f.phase||"").trim();return h!=="prefill"&&h!=="generate"&&h!=="complete"?null:f}function zx(e){let n=null;for(const s of e||[]){const a=Fx(s);a&&(n=a)}return!n||n.phase==="complete"||n.final===!0?null:n}function vi(e){return Math.round(e).toLocaleString()}function em(e){if(!e||e.phase!=="prefill")return null;const n=Ns(e.prompt_tokens),s=Ns(e.prefill_processed_tokens);if(n===null||n<=0||s===null||s<0)return null;const a=Math.min(s,n),l=Math.min(99,Math.round(a/n*100));return{processed:a,total:n,percent:l}}function tm(e){return`${vi(e.processed)} / ${vi(e.total)} tokens (${e.percent}%)`}function Wx(e){if(!e)return"";if(e.phase==="prefill"){const n=em(e);if(n)return`Prefill · ${tm(n)}`;const s=Ns(e.prompt_tokens);if(s===null||s<=0)return"Prefill";const a=Ns(e.cached_tokens),l=Ns(e.fed_tokens),u=[];a!==null&&a>0&&u.push(`${vi(a)} cached`),l!==null&&l>0&&u.push(`${vi(l)} new`);const d=u.length?` (${u.join(", ")})`:"";return`Prefill · ${vi(s)} tokens${d}`}if(e.phase==="generate"){const n=Ns(e.generated_tokens)??0,s=Math.round(n)===1?"token":"tokens",a=Ns(e.tokens_per_second),l=a!==null&&a>0?` · ${Math.round(a)} tok/s`:"";return`Generating · ${vi(n)} ${s}${l}`}return""}function Ux(e){return Wx(zx(e))}const nm=new Set(["abstract.progress","abstractcode.progress"]),Bx=new Set(["abstract.status","abstractcode.status"]);function Le(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Su(e){const n=Le(e);return!!(n&&n.$slim)}function ft(e){const n=typeof e=="number"?e:Number(e);return Number.isFinite(n)?n:null}function on(e){return Math.round(e).toLocaleString("en-US")}function Rt(e,n=120){const s=e.replace(/\s+/g," ").trim();return s.length>n?`${s.slice(0,n-1)}…`:s}function ga(e,n=120){var l,u;if(e==null)return"";if(typeof e=="string")return Rt(e,n);if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return Rt(e.length===0?"[]":`${e.length} ${e.length===1?"item":"items"}`,n);const s=Le(e);if(!s)return"";if(Su(s)){const d=String(((l=s.$slim)==null?void 0:l.field)||""),f=ft((u=s.$slim)==null?void 0:u.bytes);return`${d||"payload"} stored${f?` · ${on(f)} bytes`:""}`}const a=[];for(const[d,f]of Object.entries(s)){const h=typeof f=="string"?Rt(f,60):typeof f=="number"||typeof f=="boolean"?String(f):Array.isArray(f)?`${f.length} items`:f==null?"":"{…}";if(h&&(a.push(`${d.replace(/_/g," ")} ${h}`),a.join(" · ").length>=n))break}return Rt(a.join(" · "),n)}function Zo(e){return`${e>=100?String(Math.round(e)):e.toFixed(e<1?2:1).replace(/\.0+$/,"")} s`}function rm(e,n){const s=Date.parse(String(e||"")),a=Date.parse(String(n||""));if(!Number.isFinite(s)||!Number.isFinite(a))return null;const l=(a-s)/1e3;return l>=0?l:null}function Vx(e){const n=String(e||""),s=/T(\d{2}:\d{2}:\d{2})/.exec(n);return s?s[1]:""}function sm(e){const n=String(e||"").trim();if(!n)return"";const s=n.split("/").pop()||n;return s.length>48?`${s.slice(0,47)}…`:s}function It(e,n=" · "){return e.filter(s=>!!s).join(n)}const Ih="visual_react_agent_";function Gx(e){if(!/^[A-Za-z0-9_-]{8,}$/.test(e))return null;try{const n=e.replace(/-/g,"+").replace(/_/g,"/"),s=atob(n+"=".repeat((4-n.length%4)%4));return!/^[ -~]{3,}$/.test(s)||!/[a-z]/i.test(s)?null:s}catch{return null}}function Hx(e){const n=String(e||"").trim();if(!n)return{name:"",node:""};const s=/^([^@]+)@([^:]+)(?::(.+))?$/.exec(n);if(s)return{name:s[1],node:s[3]||""};if(n.startsWith(Ih)){const a=n.slice(Ih.length),l=/^(.*)_(\d+)_(\d+)_(\d+)_([0-9a-f]{6,12})_(.+)$/.exec(a);if(l){let u=l[1];if(u.includes("__")){const d=u.split("__").filter(Boolean);for(let f=d.length-1;f>=0;f-=1){const h=Gx(d[f]);if(h&&h.length>3){u=h;break}}}return{name:u,node:l[6]}}return{name:a,node:""}}return{name:n,node:""}}function Kx(e){var s;if(!Array.isArray(e)||!e.length)return"";const n=new Map;for(const a of e){const l=String(((s=Le(a))==null?void 0:s.name)||"").trim()||"tool";n.set(l,(n.get(l)||0)+1)}return[...n.entries()].map(([a,l])=>l>1?`${a} ×${l}`:a).join(", ")}function Jx(e){var f;const n=Le(e);if(!n)return null;const s=Le(n.effect);if(!s||String(s.type||"")!=="emit_event")return null;const a=Le(s.payload),l=String((a==null?void 0:a.name)??(a==null?void 0:a.event_name)??"").trim();if(!nm.has(l))return null;const u=Le((f=Le(n.result))==null?void 0:f.payload),d=Le(a==null?void 0:a.payload);return u||d}function Qx(e){if(!e.length)return"";const n=e[e.length-1];let s=null,a=null,l=null,u=null,d=null;for(const y of e)s=ft(y.prompt_tokens)??s,a=ft(y.cached_tokens)??a,l=ft(y.generated_tokens)??l,u=ft(y.tokens_per_second)??u,d=ft(y.elapsed_s)??d;if(n.final===!0||String(n.phase||"")==="complete")return It([s!==null?`${on(s)} tokens in`:null,a!==null&&a>0?`${on(a)} cached`:null,l!==null?`${on(l)} out`:null,d!==null?Zo(d):null,u!==null&&u>0?`${Math.round(u)} tok/s`:null]);const h=s!==null?`prefill ${on(s)} tokens${a!==null&&a>0?` (${on(a)} cached)`:""}`:"prefill";if(String(n.phase||"")==="prefill"){const y=em(n);return y?`prefill ${tm(y)}`:h}const g=It([`generating ${on(l??0)} ${Math.round(l??0)===1?"token":"tokens"}`,u!==null&&u>0?`${Math.round(u)} tok/s`:null]);return`${h} → ${g}`}function Yx(e){if(!e.length)return"";const n=e[e.length-1],s=ft(n.step)??ft(n.index),a=ft(n.total)??ft(n.steps),l=ft(n.percent)??ft(n.progress),u=ft(n.frame),d=ft(n.elapsed_s);return It([typeof n.label=="string"?Rt(n.label,60):null,typeof n.phase=="string"&&!n.label?Rt(n.phase,40):null,s!==null?`step ${on(s)}${a!==null?`/${on(a)}`:""}`:null,u!==null?`frame ${on(u)}`:null,l!==null?`${Math.round(l<=1?l*100:l)}%`:null,d!==null?Zo(d):null])}function Mh(e){return e.length?String(e[e.length-1].kind||"")==="llm"?Qx(e):Yx(e):""}function Xx(e,n,s){var T;const a=String(e.provider||"").trim(),l=sm(e.model||(n==null?void 0:n.model)),u=It(["llm",a,l])||"llm call";if(!n){const A=Le(e.params)||{};return{title:u,detail:It([ft(A.temperature)!==null?`temperature ${A.temperature}`:null,A.thinking?`thinking ${A.thinking}`:null,(T=Le(A.speculation))!=null&&T.mode?`speculation ${Le(A.speculation).mode}`:null])}}const d=Le(n.usage)||{},f=Le(n.metadata)||{},h=Le(f.prompt_cache)||{},g=Le(f.performance)||{},y=ft(d.prompt_tokens)??ft(d.input_tokens),x=ft(d.completion_tokens)??ft(d.output_tokens),b=ft(h.cached_tokens),_=String(h.outcome||"").trim(),E=rm(s.started_at,s.ended_at),C=ft(g.generation_tokens_per_second),j=Array.isArray(n.tool_calls)?n.tool_calls.length:0;return{title:u,detail:It([y!==null?`${on(y)} tokens in`:null,b!==null&&b>0?`${on(b)} cached`:_?`${_} cache`:null,x!==null?`${on(x)} out`:null,E!==null?Zo(E):null,C!==null&&C>0?`${Math.round(C)} tok/s`:null,j?`${j} tool ${j===1?"call":"calls"}`:null])}}function Zx(e,n){if(n.length<=60)return Rt(n,60);if(e==="url")try{const s=new URL(n),a=s.pathname.split("/").filter(Boolean).pop()||"";return Rt(`${s.host}${a?` · …/${a}`:""}`,72)}catch{}if(e==="file path"||e==="path"){const s=n.split(/[\\/]/).pop()||n;return Rt(`${s} · ${n.slice(0,24)}…`,60)}return Rt(n,60)}function qx(e,n){const s=Array.isArray(e.tool_calls)?e.tool_calls:[],a=Kx(s),l=Le(s[0]),u=l?Ap(l.arguments):{label:"",value:""},d=Array.isArray(n==null?void 0:n.results)?n.results:[],f=d.filter(g=>{var y;return((y=Le(g))==null?void 0:y.success)===!0}).length,h=d.length-f;return{title:It(["tools",a||"tool call"]),detail:It([u.value?`${u.label} ${Zx(u.label,u.value)}`:null,d.length?`${f} ok`:null,h>0?`${h} failed`:null])}}function eb(e,n){var g,y;const{name:s,node:a}=Hx(e.workflow_id),l=Le(e.vars),u=l&&!Su(l)?l:null,d=Le(u==null?void 0:u.context),f=typeof(d==null?void 0:d.task)=="string"?d.task:typeof(u==null?void 0:u.request)=="string"?u.request:"",h=String(((y=Le((g=Le(n==null?void 0:n.wait))==null?void 0:g.details))==null?void 0:y.sub_run_id)||"").slice(0,8);return u&&typeof u.state=="string"&&!d?{title:"subflow · status",detail:It([Rt(u.state,80),h&&`run ${h}`])}:f?{title:"subflow · agent loop",detail:It([s,Rt(f,90),h&&`run ${h}`])}:{title:It(["subflow",s||"workflow"]),detail:It([a,u?ga(u,80):null,h&&`run ${h}`])}}function tb(e,n){const s=e.until,a=rm(n.started_at,s),l=Vx(s);return{title:a!==null?`wait · delay ${Zo(a)}`:`wait · until ${l}`,detail:It([a!==null&&l?`until ${l}`:null,e.resume_to_node?`resumes at ${e.resume_to_node}`:null])}}function Lh(e){var f;const n=Le(e)||{},s=Le(n.effect),a=String((s==null?void 0:s.type)||"").trim(),l=Le(s==null?void 0:s.payload)||{},u=Le(n.result);if(a==="emit_event"){const h=String(l.name??l.event_name??"").trim();if(nm.has(h))return{kind:"progress",title:"progress",detail:"",isProgress:!0,isStatus:!1,isResume:!1,hidden:!0};if(Bx.has(h))return{kind:"event",title:"status",detail:ga(l.payload,80),isProgress:!1,isStatus:!0,isResume:!1,hidden:!0};const g=String(l.scope||"").trim();return{kind:"event",title:`event · ${h||"unnamed"}${g?` (${g})`:""}`,detail:ga(l.payload??(u==null?void 0:u.payload),110),isProgress:!1,isStatus:!1,isResume:!1,hidden:!1}}if(a==="resume")return{kind:"step",title:"resume",detail:String(l.wait_reason||""),isProgress:!1,isStatus:!1,isResume:!0,hidden:!0};const d={isProgress:!1,isStatus:!1,isResume:!1,hidden:!1};if(a==="llm_call")return{kind:"llm",...Xx(l,u,n),...d};if(a==="tool_calls")return{kind:"tools",...qx(l,u),...d};if(a==="start_subworkflow")return{kind:"subflow",...eb(l,u),...d};if(a==="wait_until")return{kind:"wait",...tb(l,n),...d};if(a==="wait_event")return{kind:"wait",title:"wait · event",detail:It([typeof l.prompt=="string"?Rt(l.prompt,90):null,!l.prompt&&l.wait_key?Rt(String(l.wait_key),70):null]),...d};if(a==="ask_user")return{kind:"ask",title:"ask · your input",detail:Rt(String(l.prompt||((f=Le(u==null?void 0:u.wait))==null?void 0:f.prompt)||"").split(`
70
+ `)[0],110),...d};if(a==="answer_user")return{kind:"message",title:"message",detail:Rt(String(l.message||""),110),...d};if(!a){if((u==null?void 0:u.completed)===!0){const h=Le(u.output)||{},g=Le(h.stop_reason)||{},y=ft(h.iterations),x=It([String(g.code||h.outcome||"").replace(/_/g," ")||null,y!==null?`${on(y)} ${y===1?"iteration":"iterations"}`:null]),b=[h.answer,h.response,h.result].find(_=>typeof _=="string"&&_.trim());return{kind:"run",title:"run finished",detail:x||(typeof b=="string"?Rt(b,110):ga(h,110)),...d}}return{kind:"step",title:String(n.node_id||"workflow step"),detail:"",...d}}return{kind:"step",title:a.replace(/_/g," "),detail:ga(l,110),...d}}function nb(e,n,s){var u,d;const a=Le(e)||{},l=String(a.status||"").trim();if(a.error)return{status:"failed",statusLabel:"failed"};if(l==="failed")return{status:"failed",statusLabel:"failed"};if(l==="completed")return{status:"completed",statusLabel:"completed"};if(l==="waiting"){if(s)return{status:"completed",statusLabel:"completed"};const f=Le((u=Le(a.result))==null?void 0:u.wait);return String(((d=Le(f==null?void 0:f.details))==null?void 0:d.mode)||"")==="approval_required"?{status:"waiting",statusLabel:"approval needed"}:n==="subflow"?{status:"waiting",statusLabel:"waiting for subflow"}:n==="ask"?{status:"waiting",statusLabel:"waiting for you"}:n==="wait"?{status:"waiting",statusLabel:String((f==null?void 0:f.reason)||"")==="until"?"waiting":"waiting for event"}:{status:"waiting",statusLabel:"waiting"}}return l==="started"?{status:"started",statusLabel:"running"}:{status:l||"started",statusLabel:l||"running"}}function rb(e){var l;const n=Le(e.record)||{},s=String(((l=Le(n.effect))==null?void 0:l.type)||"(none)"),a=String(n.idempotency_key||n.step_id||e.cursor);return`${e.runId}|${s}|${a}|${n.attempt??1}`}function sb(e){var h;const n=e.map(g=>Le(g.record)||{}),s=n[n.length-1]||{},a={};for(const g of n){const y=Le((h=Le(g.effect))==null?void 0:h.payload);if(y)for(const[x,b]of Object.entries(y))Su(b)&&x in a||(a[x]=b)}let l=null,u=null,d=null,f=null;for(const g of n)g.result!==null&&g.result!==void 0&&(l=g.result),g.error!==null&&g.error!==void 0&&(u=g.error),!d&&g.started_at&&(d=g.started_at),g.ended_at&&(f=g.ended_at);return{...s,effect:s.effect?{...s.effect,payload:a}:s.effect,result:l,error:u,started_at:d,ended_at:f}}function ib(e){var s,a;const n=[];for(const l of e){const u=Le((a=Le((s=Le(l.record))==null?void 0:s.result))==null?void 0:a.wait),d=String((u==null?void 0:u.wait_key)||"").trim();d&&n.push(d)}return n}function ab(e,n){return`${e}|${String(n.step_id||n.node_id||"")}`}function ob(e,n){const s=new Map;for(const u of n){const d=Jx(u.record);if(!d)continue;const f=ab(u.runId,d),h=s.get(f)||{entries:[],payloads:[]};h.entries.push(u),h.payloads.push(d),s.set(f,h)}if(!s.size)return e.map(u=>({...u}));const a=new Set,l=e.map(u=>{const d=u.stepIds.map(_=>`${u.runId}|${_}`).filter(_=>s.has(_));if(!d.length)return{...u};const f=[],h=[];for(const _ of d)a.add(_),f.push(...s.get(_).payloads),h.push(...s.get(_).entries);const g=Mh(f),y=f[f.length-1],x=y.final===!0||String(y.phase||"")==="complete",b=!(x&&u.status==="completed"&&u.detail);return{...u,progress:b?g:"",progressFinal:x,progressEvents:h.map(_=>Le(_.record)||{})}});for(const[u,d]of s.entries()){if(a.has(u))continue;const f=d.payloads,h=f[f.length-1],g=String(h.kind||""),y=d.entries[0];l.push({key:`progress:${u}`,runId:y.runId,cursor:d.entries[d.entries.length-1].cursor,kind:"progress",title:It(g==="llm"?["llm",String(h.provider||""),sm(h.model)]:["progress",g]),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:Mh(f),progressFinal:h.final===!0||String(h.phase||"")==="complete",entries:d.entries,progressEvents:d.entries.map(x=>Le(x.record)||{}),merged:Le(d.entries[d.entries.length-1].record)||{}})}return l}function lb(e){var f,h,g;const n=new Map,s=[],a=[],l=[];for(const y of e||[]){const x=Lh(y.record);if(x.isProgress){l.push(y);continue}if(x.isStatus)continue;if(x.isResume){const _=String(((g=(h=Le((f=Le(y.record))==null?void 0:f.effect))==null?void 0:h.payload)==null?void 0:g.wait_key)||"").trim();_&&a.push(_);continue}const b=rb(y);n.has(b)||(n.set(b,[]),s.push(b)),n.get(b).push(y)}const u=new Set(a),d=s.map(y=>{const x=n.get(y),b=sb(x),_=Lh(b),E=ib(x).some(j=>u.has(j)),C=nb(b,_.kind,E);return{key:y,runId:x[0].runId,cursor:x[x.length-1].cursor,kind:_.kind,title:_.title,detail:_.detail,status:C.status,statusLabel:C.statusLabel,nodeId:String(b.node_id||""),stepIds:[...new Set(x.map(j=>{var T;return String(((T=Le(j.record))==null?void 0:T.step_id)||"")}).filter(Boolean))],progress:"",progressFinal:!1,entries:x,progressEvents:[],merged:b}});return ob(d,l)}function cb({tab:e,onTab:n,policy:s,runId:a,records:l,enabled:u,isAdmin:d,refreshKey:f,onAttach:h,onAttachFiles:g,onClose:y}){const[x,b]=w.useState("session"),_=w.useMemo(()=>lb(l),[l]);return i.jsxs("aside",{className:"code-inspector","aria-label":"Workspace inspector",children:[i.jsxs("div",{className:"code-inspector-heading",children:[i.jsx("span",{children:"WORKSPACE"}),i.jsx("button",{className:"code-icon-button","aria-label":"Close workspace inspector",onClick:y,children:i.jsx(ae,{name:"x",size:15})})]}),i.jsx("div",{className:"code-inspector-tabs",role:"tablist","aria-label":"Workspace views",onKeyDown:ju,children:["files","activity","artifacts"].map(E=>i.jsxs("button",{id:`inspector-tab-${E}`,role:"tab",tabIndex:e===E?0:-1,"aria-selected":e===E,"aria-controls":`inspector-panel-${E}`,onClick:()=>n(E),children:[E==="files"?"Files":E==="activity"?"Activity":"Artifacts",E==="activity"&&_.length?i.jsx("span",{children:_.length}):null]},E))}),i.jsx("div",{className:"code-inspector-content",id:`inspector-panel-${e}`,role:"tabpanel","aria-labelledby":`inspector-tab-${e}`,children:e==="files"?i.jsxs(i.Fragment,{children:[d?i.jsxs("div",{className:"code-files-mode",role:"group","aria-label":"Files source",children:[i.jsx("button",{"aria-pressed":x==="session",onClick:()=>b("session"),children:"This conversation"}),i.jsx("button",{"aria-pressed":x==="shared",onClick:()=>b("shared"),children:"Shared workspace (admin)"})]}):null,d&&x==="shared"?i.jsx(ub,{policy:s,enabled:u,runId:a,onAttach:h}):i.jsx(Ox,{runId:a,enabled:u,refreshKey:f,maxAttachmentBytes:s==null?void 0:s.maxAttachmentBytes,onAttachFiles:g})]}):e==="activity"?i.jsx(fb,{rows:_}):i.jsx(hb,{runId:a,enabled:u})}),i.jsxs("div",{className:"code-inspector-foot",children:[i.jsx(ae,{name:"server",size:14}),i.jsx("span",{children:"Access enforced by your gateway"})]})]})}function ub({policy:e,enabled:n,runId:s,onAttach:a}){const[l,u]=w.useState(""),[d,f]=w.useState(""),[h,g]=w.useState([]),[y,x]=w.useState(!1),[b,_]=w.useState(""),[E,C]=w.useState(""),[j,T]=w.useState(0),[A,$]=w.useState("");return w.useEffect(()=>{const k=new AbortController;if(g([]),_(""),C(""),!n||!e)return;x(!0);const P=window.setTimeout(()=>{const V=new URLSearchParams({limit:"100"});l.trim()?V.set("query",l.trim()):d&&V.set("path",d),ht(Se(`files/${l.trim()?"search":"list"}?${V}`),{signal:k.signal}).then(H=>{if(H.error)throw new Error(String(H.error));g(Array.isArray(H.items)?H.items:[]),(H.truncated||H.has_more)&&C("Showing the first 100 results. Search to narrow the list.")}).catch(H=>{k.signal.aborted||_(Et(H))}).finally(()=>{k.signal.aborted||x(!1)})},l?220:0);return()=>{window.clearTimeout(P),k.abort()}},[n,e,l,d,j,s]),i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"code-pane-intro",children:[i.jsx(ae,{name:"terminal",size:17}),i.jsxs("div",{children:[i.jsx("strong",{children:"Shared workspace (admin)"}),i.jsx("span",{children:d||"Authorized shared workspace"})]}),i.jsx("button",{className:"code-icon-button","aria-label":"Refresh files",onClick:()=>T(k=>k+1),disabled:!n,children:i.jsx(ae,{name:"refresh",size:14})})]}),i.jsx("input",{className:"code-search","aria-label":"Search workspace files",placeholder:"Search files…",value:l,onChange:k=>u(k.target.value),disabled:!n}),d?i.jsx("button",{className:"code-back",onClick:()=>{f(d.split("/").slice(0,-1).join("/")),u("")},children:"← Parent folder"}):null,n?null:i.jsx("p",{className:"code-pane-empty",children:"Connect to browse your workspace."}),y?i.jsx("p",{className:"code-muted",role:"status",children:"Loading files…"}):null,b?i.jsxs("div",{className:"code-inline-error",role:"alert",children:[b,i.jsx("button",{onClick:()=>T(k=>k+1),children:"Retry"})]}):null,E?i.jsx("p",{className:"code-field-help",role:"status",children:E}):null,i.jsx("ul",{className:"code-file-list",children:h.map(k=>{const P=k.kind==="folder"||k.is_dir||k.type==="directory"||k.type==="dir";return i.jsx("li",{children:i.jsxs("button",{title:P?`Open ${k.path}`:`Attach ${k.path} to the conversation`,disabled:!!A,onClick:async()=>{if(P){f(k.path),u("");return}$(k.path),_("");try{await a(k.path),C(`${k.name||k.path} attached.`)}catch(V){_(Et(V))}finally{$("")}},children:[i.jsx(ae,{name:P?"chevronRight":"edit",size:14}),i.jsx("span",{children:k.name||k.path}),A===k.path?i.jsx(ae,{name:"loader",size:13}):i.jsx("span",{className:"code-file-action",children:P?"Open":"+"})]})},k.path)})}),!y&&!b&&n&&!h.length?i.jsxs("div",{className:"code-pane-empty",children:[i.jsx(ae,{name:"terminal",size:28}),i.jsx("p",{children:l?"No matching files.":"No shared files yet."}),i.jsx("small",{children:l?"Try a shorter name or another folder.":"Browse files exposed by your gateway or attach files from your device. Generated output is available in Artifacts."})]}):null]})}const db={llm:"sparkle",tools:"terminal",subflow:"agent",event:"info",wait:"history",ask:"chat",message:"send",run:"playCircle",progress:"loader",step:"list"};function fb({rows:e}){return e.length?i.jsx("div",{className:"code-activity",children:e.map(n=>{const s=n.merged,a=s.effect||{};return i.jsxs("details",{className:`code-activity-row code-activity-row--${n.kind}`,children:[i.jsxs("summary",{children:[i.jsx("span",{className:"code-activity-icon","aria-hidden":"true",children:i.jsx(ae,{name:db[n.kind],size:14})}),i.jsxs("span",{className:"code-activity-text",children:[i.jsx("span",{className:"code-activity-title",children:n.title}),n.detail?i.jsx("span",{className:"code-activity-sub",children:n.detail}):null,n.progress?i.jsx("span",{className:"code-activity-progress",children:n.progress}):null]}),i.jsx("span",{className:`code-step-dot is-${n.status}`}),i.jsx("small",{children:n.statusLabel})]}),i.jsxs("div",{className:"code-activity-detail",children:[i.jsxs("div",{className:"code-field-help",children:[n.nodeId?`${n.nodeId} · `:"","run ",n.runId.slice(0,8)," ","· ",n.entries.length," ",n.entries.length===1?"record":"records",n.progressEvents.length?` · ${n.progressEvents.length} progress`:""]}),i.jsx(Cs,{value:{input:a.payload,result:s.result,error:s.error,records:n.entries.map(l=>l.record),...n.progressEvents.length?{progress:n.progressEvents}:{}},collapseAfterDepth:2})]})]},n.key)})}):i.jsxs("div",{className:"code-pane-empty",children:[i.jsx(ae,{name:"playCircle",size:28}),i.jsx("p",{children:"Follow the work as it happens."}),i.jsx("small",{children:"Workflow steps, tool calls, and results will appear here."})]})}function hb({runId:e,enabled:n}){const[s,a]=w.useState([]),[l,u]=w.useState(""),[d,f]=w.useState(0);return w.useEffect(()=>{if(a([]),u(""),!e||!n)return;const h=new AbortController;return ht(Se(`runs/${encodeURIComponent(e)}/artifacts?limit=200`),{signal:h.signal}).then(g=>a(Array.isArray(g.items)?g.items:Array.isArray(g.artifacts)?g.artifacts:[])).catch(g=>{h.signal.aborted||u(Et(g))}),()=>h.abort()},[e,n,d]),i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"code-pane-intro",children:[i.jsx(ae,{name:"paperclip",size:17}),i.jsxs("div",{children:[i.jsx("strong",{children:"Run artifacts"}),i.jsx("span",{children:"Files and generated output"})]}),i.jsx("button",{className:"code-icon-button","aria-label":"Refresh artifacts",onClick:()=>f(h=>h+1),children:i.jsx(ae,{name:"refresh",size:14})})]}),l?i.jsx("p",{role:"alert",className:"code-error-text",children:l}):null,s.map(h=>{var x;const g=h.artifact_id||h.id,y=h.filename||((x=h.metadata)==null?void 0:x.filename)||g;return i.jsxs("button",{className:"code-artifact",onClick:()=>{M_(e,g,y).catch(b=>u(Et(b)))},children:[i.jsx(ae,{name:"download",size:16}),i.jsxs("span",{children:[i.jsx("strong",{children:y}),i.jsx("small",{children:h.content_type||"Artifact"})]})]},g)}),!s.length&&!l?i.jsxs("div",{className:"code-pane-empty",children:[i.jsx(ae,{name:"paperclip",size:28}),i.jsx("p",{children:"Everything the workflow creates."}),i.jsx("small",{children:"Generated files and attachments are stored by the gateway and can be downloaded here."})]}):null]})}const pb=[["Gateway","checking…"]];function mb(e){return e?e.ok?Xf(e.value):Xf(null,e.status?`HTTP ${e.status}`:e.message):pb}const gb=3e4,Lo=50;function yb(){return Gy({fetch:(e,n)=>fetch(e,{...n,credentials:"same-origin"}),baseUrl:"",headers:Jp})}function wb(e){const n=String(e||"").trim();if(!n)return null;try{const s=new URL(n);return s.protocol!=="http:"&&s.protocol!=="https:"?null:`${s.origin}${s.pathname.replace(/\/+$/,"")}/console#users`}catch{return null}}function vb(e){var s;const n=(s=e==null?void 0:e.common)==null?void 0:s.automations;return n&&typeof n=="object"&&n.available===!0?{available:!0,reason:""}:n&&typeof n=="object"&&n.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 _b(e,n){return e===Sn?{flow_id:"@default",interface:_i}:!(n!=null&&n.bundleId)||!n.flowId?null:{bundle_ref:n.bundleVersion?`${n.bundleId}@${n.bundleVersion}`:n.bundleId,flow_id:n.flowId}}function xb(e,n=Date.now()){const s=e.attention.unseen_count>0||e.attention.pending_waits>0;return{id:e.automation_id,title:e.title,cadence:du(e.trigger),current:lp(e),next:e.next_fire_at?`${wr(e.next_fire_at)} (${cp(e.next_fire_at,n)})`:e.status==="paused"?"none while paused":"none scheduled",attention:s?up(e):null,legacy:e.legacy===!0||e.capabilities.includes("legacy")}}function bb(e,n){return n?e:e.filter(s=>s.status!=="archived")}function kb(e,n){if(e==="ask_user"){if(typeof n.response!="string")throw new Error("An ask_user wait is answered with {response: string}.");return{response:n.response}}if(e==="tool_approval"){if(typeof n.approved!="boolean")throw new Error("A tool_approval wait is answered with {approved: true|false}.");return{approved:n.approved}}if(e==="event"){if(!("payload"in n))throw new Error("An event wait is answered with {payload}.");return{payload:n.payload}}throw new Error(`This wait has no known kind (${JSON.stringify(e)}); open its run to answer it.`)}function jb(e,n,s,a){return{command_id:e,run_id:n,type:"resume",payload:{wait_key:s,payload:a},client_id:"abstractcode-web"}}function im(e,n){return`Discussion forked from run #${e}. It works in its own workspace ${n.workspace_root}; the automation's files are mounted read-only at ${n.mounted_workspace} for the file tools (shell commands are not sandboxed), and nothing is written back into the automation's session.`}function gr(e){return yu(e)?e:{status:0,code:"client_error",message:e&&typeof e=="object"&&"message"in e?String(e.message):String(e)}}function Vc(e,n){const s=new Map;for(const a of e)s.set(a.run_id,a);for(const a of n)s.set(a.run_id,a);return Array.from(s.values()).sort((a,l)=>l.index-a.index)}const Sb={items:[],loaded:!1,loading:!1,listError:null,error:null,showArchived:!1,selectedId:"",detail:null,triggerSources:[],busy:!1,notice:"",emailStatus:null};function Nb(e){return async(n,s,a)=>{await ht(Se("commands"),{method:"POST",body:JSON.stringify(jb(e(),n,s,a))})}}class Cb{constructor(n,s,a=[1500,4e3]){yn(this,"state",{...Sb});yn(this,"listeners",new Set);yn(this,"listSeq",0);yn(this,"detailSeq",0);yn(this,"sourcesLoaded",!1);this.client=n,this.answerWaitVia=s,this.followupsMs=a}subscribe(n){return this.listeners.add(n),()=>{this.listeners.delete(n)}}set(n){this.state={...this.state,...n};for(const s of this.listeners)s()}async listAll(){const n=[];let s;for(let a=0;a<200;a+=1){const l=await this.client.listAutomations({...s?{cursor:s}:{},limit:Lo});if(n.push(...l.items),!l.next_cursor)return n;s=l.next_cursor}throw new Error("GET /api/gateway/automations kept returning next_cursor after 200 pages.")}async loadEmailStatus(){try{const n=await this.client.getMyEmail();this.set({emailStatus:n&&typeof n=="object"?n:null})}catch{this.set({emailStatus:null})}}async refresh(){const n=++this.listSeq;this.set({loading:!0});try{const s=await this.listAll();if(this.loadEmailStatus(),n!==this.listSeq)return;const a=this.state.detail,l=a?s.find(u=>u.automation_id===a.automationId):void 0;this.set({items:s,loaded:!0,loading:!1,listError:null,...a&&l?{detail:{...a,summary:l}}:{}}),a&&await this.reloadDetail(a.automationId)}catch(s){if(n!==this.listSeq)return;this.set({loading:!1,loaded:!0,listError:gr(s)})}}setShowArchived(n){this.set({showArchived:n})}async select(n){var l;const s=n.trim(),a=++this.detailSeq;if(!s){this.set({selectedId:"",detail:null});return}this.set({selectedId:s,notice:"",error:null,...((l=this.state.detail)==null?void 0:l.automationId)!==s?{detail:null}:{}});try{const[u,d]=await Promise.all([this.client.getAutomation(s),this.client.listOccurrences(s,{limit:Lo})]);if(a!==this.detailSeq)return;const f=this.state.items.find(h=>h.automation_id===s);if(this.set({detail:{automationId:s,summary:f??u.summary,definition:u.definition,occurrences:Vc([],d.items),nextCursor:d.next_cursor}}),!this.sourcesLoaded){const h=await this.client.listTriggerSources();this.sourcesLoaded=!0,this.set({triggerSources:h.items})}}catch(u){if(a!==this.detailSeq)return;this.set({error:gr(u)})}}async reloadDetail(n){const[s,a]=await Promise.all([this.client.getAutomation(n),this.client.listOccurrences(n,{limit:Lo})]),l=this.state.detail;if(!l||l.automationId!==n)return;const u=this.state.items.find(d=>d.automation_id===n);this.set({detail:{...l,summary:u??s.summary,definition:s.definition,occurrences:Vc(l.occurrences,a.items),nextCursor:l.occurrences.length>a.items.length?l.nextCursor:a.next_cursor}})}async loadMore(){const n=this.state.detail;if(!(!n||!n.nextCursor))try{const s=await this.client.listOccurrences(n.automationId,{cursor:n.nextCursor,limit:Lo}),a=this.state.detail;if(!a||a.automationId!==n.automationId)return;this.set({detail:{...a,occurrences:Vc(a.occurrences,s.items),nextCursor:s.next_cursor}})}catch(s){this.set({error:gr(s)})}}async afterChange(){await this.refresh();for(const n of this.followupsMs)setTimeout(()=>void this.refresh(),n)}async busyCall(n){this.set({busy:!0});try{const s=await n();return await this.afterChange(),s}catch(s){throw gr(s)}finally{this.set({busy:!1})}}command(n,s,a){return this.busyCall(()=>this.client.sendAutomationCommand(n,{type:s,...a?{command_id:a}:{}}))}revise(n,s,a,l){return this.busyCall(()=>this.client.reviseAutomation(n,{changes:s,...a!==null?{expected_revision:a}:{},...l?{command_id:l}:{}}))}async create(n){this.set({busy:!0,error:null});try{const s=await this.client.createAutomation(n);this.set({notice:`Automation created: ${s.summary.title}.`}),await this.refresh(),await this.select(s.automation_id);for(const a of this.followupsMs)setTimeout(()=>void this.refresh(),a);return s}catch(s){throw gr(s)}finally{this.set({busy:!1})}}async discuss(n,s,a,l){this.set({busy:!0});try{const u=await this.client.discuss(n,{occurrence_index:s,prompt:a,...l?{request_id:l}:{}});return this.set({notice:im(s,u)}),u}catch(u){throw gr(u)}finally{this.set({busy:!1})}}async seen(n,s){try{await this.client.markSeen(n,s)}catch(a){throw gr(a)}}answerWait(n,s,a){return this.busyCall(async()=>{var u;const l=(((u=this.state.detail)==null?void 0:u.occurrences)||[]).flatMap(d=>d.waits).find(d=>d.run_id===n&&d.wait_key===s);if(!l)throw new Error(`No loaded wait ${s} on run ${n}; reload the automation.`);await this.answerWaitVia(n,s,kb(l.kind,a))})}rowControls(n){return Vo(n,[],this.state.busy)}reportError(n){this.set({error:gr(n)})}clearNotice(){this.set({notice:"",error:null})}}function Eb(e,n){const s=w.useMemo(()=>new Cb(yb(),Nb(Yr)),[e]),a=w.useSyncExternalStore(d=>s.subscribe(d),()=>s.state),[l,u]=w.useState(()=>typeof document>"u"||document.visibilityState!=="hidden");return w.useEffect(()=>{const d=()=>u(document.visibilityState!=="hidden");return document.addEventListener("visibilitychange",d),()=>document.removeEventListener("visibilitychange",d)},[]),w.useEffect(()=>{if(!e||!n||!l)return;s.refresh();const d=window.setInterval(()=>void s.refresh(),gb);return()=>window.clearInterval(d)},[s,e,n,l]),{ctl:s,state:a}}function am({error:e}){if(!e)return null;const n=gu(e);return i.jsxs("p",{className:"code-inline-error",role:"alert","data-code":e.code,children:[i.jsx("strong",{children:n.title})," ",n.detail]})}function $b(e){const n=e.state,s=bb(n.items,n.showArchived),a=n.items.filter(u=>u.status==="archived").length,l=n.items.reduce((u,d)=>u+d.attention.pending_waits+d.attention.unseen_count,0);return i.jsxs("section",{className:"code-automations","aria-label":"Automations",children:[i.jsxs("div",{className:"code-section-label",children:[i.jsxs("span",{children:["AUTOMATIONS",l?i.jsx("span",{className:"code-auto-badge","data-field":"attention-total",children:l}):null]}),i.jsxs("span",{className:"code-auto-actions",children:[i.jsx("button",{className:"code-icon-button","aria-label":"New automation",title:"New automation (runs the toolbar's workflow on a schedule)",disabled:!e.available.available,onClick:e.onNew,children:i.jsx(ae,{name:"plus",size:13})}),i.jsx("button",{className:"code-icon-button","aria-label":"Refresh automations",disabled:!e.available.available||n.loading,onClick:e.onRefresh,children:i.jsx(ae,{name:"refresh",size:13})})]})]}),i.jsxs("div",{className:"code-auto-rows",children:[e.available.available?null:i.jsx("p",{className:"code-history-empty",role:"note","data-unavailable":"true",children:e.available.reason}),i.jsx(am,{error:n.listError}),e.available.available&&n.loaded&&!n.items.length?i.jsx("p",{className:"code-history-empty",children:"No automations yet. + runs the toolbar's workflow on a schedule."}):null,s.map(u=>{const d=xb(u,e.nowMs),f=e.selectedId===u.automation_id;return i.jsxs("button",{className:`code-session code-auto-row${f?" is-selected":""}`,"aria-current":f?"page":void 0,"data-automation-id":u.automation_id,"data-status":u.status,title:`${d.title} — ${d.cadence}`,onClick:()=>e.onSelect(u.automation_id),children:[i.jsx(ae,{name:"history",size:15}),i.jsxs("span",{children:[i.jsx("strong",{children:d.title}),i.jsxs("small",{children:[i.jsx("span",{"data-field":"state",children:i.jsx(gp,{status:u.status})})," ",d.cadence,d.legacy?" · legacy schedule":""]}),d.current?i.jsxs("small",{"data-field":"current",children:["now: ",d.current]}):null,i.jsxs("small",{"data-field":"next",children:["next: ",d.next]}),d.attention?i.jsx("small",{className:"code-auto-attention","data-field":"attention",children:d.attention}):null]})]},u.automation_id)}),a>0?i.jsxs("label",{className:"code-auto-archived",children:[i.jsx("input",{type:"checkbox","data-action":"show-archived",checked:n.showArchived,onChange:u=>e.onShowArchived(u.target.checked)})," Show archived (",a,")"]}):null]})]})}function Ab(e,n){const s=e.state.detail;if(!s)return null;const a=s.automationId;return{summary:s.summary,...s.definition?{definition:s.definition}:{},occurrences:s.occurrences,triggerSources:e.state.triggerSources,busy:e.state.busy,...e.state.error?{error:e.state.error}:{},onRevise:(l,u,d)=>e.revise(a,l,u,d==null?void 0:d.command_id),onCommand:(l,u,d)=>e.command(a,l,d==null?void 0:d.command_id),onDiscuss:async(l,u,d)=>{const f=await e.discuss(a,l,u,d==null?void 0:d.request_id);return n.openConversation(f.session_id,f.run_id,im(l,f)),f},onSeen:l=>e.seen(a,l),onLoadMore:()=>void e.loadMore(),onOpenRun:l=>n.openRun(l),onOpenWorkspace:l=>n.openWorkspace(l),onAnswerWait:(l,u,d)=>e.answerWait(l,u,d),emailStatus:e.state.emailStatus,...n.openMyEmail?{onOpenMyEmail:()=>{var l;return(l=n.openMyEmail)==null?void 0:l.call(n)}}:{}}}function Tb(e){const n=e.last_occurrence,s=e.current_occurrence;return[e.occurrence_count,n?`${n.index}:${n.status}:${n.finished_at??""}`:"",s?`${s.index}:${s.status}`:""].join("|")}function Rb(e,n,s){if(n===e)return"Automation folder";const a=s.find(l=>l.run_id===n);return a?`Run #${a.index} folder`:"Run folder"}function Ib(e){const n=e.ctl.state,s=n.detail,[a,l]=w.useState({automationId:"",runId:""}),u=(s==null?void 0:s.automationId)??"",d=a.automationId===u&&a.runId?a.runId:u,f=Ab(e.ctl,{...e.host,openWorkspace:h=>l({automationId:u,runId:h})});return i.jsxs("main",{className:"code-conversation code-automation-main",id:"code-conversation",tabIndex:-1,"aria-label":"Automation",children:[i.jsxs("div",{className:"code-auto-main-head",children:[i.jsxs("button",{className:"code-subtle-button",onClick:e.onClose,children:[i.jsx(ae,{name:"chat",size:14})," ",i.jsx("span",{children:"Back to the conversation"})]}),n.notice?i.jsx("p",{className:"code-field-help",role:"status",children:n.notice}):null]}),s?i.jsxs("div",{className:"code-auto-main-body",children:[f?i.jsx(g_,{...f,fetchGateway:ou}):null,e.enabled?i.jsx(Vp,{className:"code-auto-folder",fetchGateway:ou,runId:d,title:Rb(s.automationId,d,s.occurrences),refreshKey:Tb(s.summary),onClose:d!==s.automationId?()=>l({automationId:u,runId:""}):void 0}):null]}):n.error?i.jsx(am,{error:n.error}):i.jsx("p",{className:"code-muted",role:"status",children:"Loading the automation…"})]})}function Mb(e){const[n,s]=w.useState();return w.useEffect(()=>{e.open&&(s(void 0),e.ctl.loadEmailStatus())},[e.open]),i.jsx(Bw,{open:e.open,onClose:e.onClose,target:e.target,workflowPicker:i.jsx("p",{className:"code-field-help","data-field":"target",children:e.target?`Runs ${e.workflowLabel} (the toolbar's workflow).`:"Choose a published workflow in the toolbar first."}),initialPrompt:e.initialPrompt,emailStatus:e.ctl.state.emailStatus,onOpenMyEmail:e.onOpenMyEmail,busy:e.ctl.state.busy,error:n,onSubmit:a=>e.ctl.create(a).then(l=>(e.onCreated(l.automation_id),e.onClose(),l),l=>{throw s(gr(l)),l})})}function om(e){return`abstractcode.workspace.v2:${e}`}function Lb(e){try{const n=JSON.parse(e||"{}"),s=typeof n.workflow=="string"&&n.workflow.trim()?n.workflow.trim():yr.workflow;return{...yr,...n,workflow:s,showAllWorkflows:n.showAllWorkflows===!0,speculation:Hh(n.speculation),streamReplies:V_(n.streamReplies),tools:{...yr.tools,...n.tools}}}catch{return yr}}function Pb(e){try{return Lb(localStorage.getItem(om(e)))}catch{return yr}}function Ob(e,n){try{localStorage.setItem(om(e),JSON.stringify(n))}catch{}}function Db(e){var h,g;const n=Object.keys(((h=e.schema)==null?void 0:h.properties)||{}),s=((g=e.schema)==null?void 0:g.required)||[],a=[e.promptProperty||"prompt","context","messages","attachments"],l=["provider","model","tools","skills","max_iterations","use_context","use_session_history"],u=Qp(e.schema).map(y=>[y.provider,y.model,y.reasoning].filter(x=>!!x)),d=new Set(n.filter(y=>s.includes(y)&&!a.includes(y)));for(const y of u)y.some(x=>d.has(x))&&y.forEach(x=>d.add(x));const f=new Set(n.filter(y=>!d.has(y)&&!a.includes(y)&&!l.includes(y)));for(const y of u)y.some(x=>f.has(x))&&y.forEach(x=>f.add(x));return i.jsxs(i.Fragment,{children:[i.jsxs("section",{className:"code-settings-section","aria-label":"Automatic agent configuration",children:[i.jsx("h3",{children:d.size?"Workflow inputs":"Ready to chat"}),i.jsxs("p",{className:"code-field-help",children:[d.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."]})]}),d.size?i.jsx(lu,{...e,omit:n.filter(y=>!d.has(y)),rawObject:!1}):null,f.size?i.jsxs("details",{className:"code-advanced-inputs",children:[i.jsxs("summary",{children:["Advanced workflow inputs"," ",i.jsx("span",{className:"code-muted",children:"Optional"})]}),i.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."}),i.jsx(lu,{...e,omit:n.filter(y=>!f.has(y)),rawObject:!1})]}):null]})}function Fb(e,n,s){var l;if(!s.length)return n;const a=(l=e==null?void 0:e.properties)==null?void 0:l.attachments;if(!a||a.type&&a.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{...n,attachments:[...Array.isArray(n.attachments)?n.attachments:[],...s]}}function zb(e){if(!e.trim())return{ok:!0,value:{}};let n;try{n=JSON.parse(e)}catch{return{ok:!1,error:"Enter valid JSON."}}return n===null||typeof n!="object"||Array.isArray(n)?{ok:!1,error:"The workflow input payload must be a JSON object."}:{ok:!0,value:n}}function lu({schema:e,values:n,onChange:s,disabled:a=!1,omit:l=[],rawObject:u=!1,onEditorError:d,defaultModel:f}){const[h,g]=wt.useState("fields"),y=Object.entries((e==null?void 0:e.properties)||{}).filter(([C])=>!l.includes(C)),x=Qp(e),b=new Set(x.flatMap(C=>[C.provider,C.model,C.reasoning].filter(Boolean))),_=C=>{g(C),d==null||d("")},E=y.length?i.jsx("div",{className:"code-input-fields",children:y.map(([C,j])=>{const T={...j,type:O_(j)},A=x.find(H=>H.provider===C);if(A)return i.jsxs("section",{className:"code-settings-section",children:[i.jsx("h3",{children:A.title}),i.jsx(uu,{value:{provider:String(n[A.provider]||""),model:String(n[A.model]||""),...A.reasoning?{reasoning:String(n[A.reasoning]||"")}:{}},onChange:H=>s({...n,[A.provider]:H.provider,[A.model]:H.model,...A.reasoning?{[A.reasoning]:H.reasoning||""}:{}}),...W_(A.provider,T["x-abstract-type"]),fetchModelCapabilities:A.reasoning?bu.fetchModelCapabilities:void 0,effectiveDefault:A.provider==="provider"?f:void 0,defaultHint:A.provider==="provider"&&(f!=null&&f.model)?`Gateway default: ${f.provider} · ${f.model}. Workflow defaults take precedence.`:"Empty routing pins inherit the Gateway defaults. Registered workflow defaults are loaded above any Gateway default.",disabled:a})]},C);if(b.has(C))return null;const $=`workflow-input-${C}`,k=String(T.title||C).replace(/_/g," "),P=Array.isArray(e==null?void 0:e.required)&&e.required.includes(C),V=H=>{const L={...n};H===void 0?delete L[C]:L[C]=H,s(L)};return i.jsxs("div",{className:"code-field",children:[i.jsxs("label",{htmlFor:$,children:[k,P?i.jsx("span",{"aria-label":"required",children:" *"}):null]}),T.enum?i.jsxs("select",{id:$,value:n[C]===void 0?"":JSON.stringify(n[C]),disabled:a,onChange:H=>V(H.target.value?JSON.parse(H.target.value):void 0),children:[i.jsxs("option",{value:"",children:["Choose ",k]}),T.enum.map(H=>i.jsx("option",{value:JSON.stringify(H),children:String(H)},JSON.stringify(H)))]}):T.type==="boolean"?i.jsxs("select",{id:$,value:n[C]===void 0?"":String(n[C]),disabled:a,onChange:H=>V(H.target.value?H.target.value==="true":void 0),children:[i.jsx("option",{value:"",children:"Workflow default"}),i.jsx("option",{value:"true",children:"Yes"}),i.jsx("option",{value:"false",children:"No"})]}):T.type==="number"||T.type==="integer"?i.jsx("input",{id:$,type:"number",value:typeof n[C]=="number"?String(n[C]):"",min:T.minimum,max:T.maximum,step:T.type==="integer"?1:"any",disabled:a,onChange:H=>V(H.target.value===""?void 0:Number(H.target.value))}):T.type==="object"||T.type==="array"?i.jsx(Ub,{id:$,value:n[C],disabled:a,onChange:V},C):i.jsx("textarea",{id:$,rows:2,value:String(n[C]??""),disabled:a,onChange:H=>V(H.target.value)}),T.description?i.jsx("p",{className:"code-field-help",id:`${$}-help`,children:T.description}):null]},C)})}):i.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 u?i.jsxs("div",{children:[i.jsxs("div",{className:"code-settings-tabs",role:"tablist","aria-label":"Workflow input editor",onKeyDown:ju,children:[i.jsx("button",{type:"button",role:"tab",tabIndex:h==="fields"?0:-1,"aria-selected":h==="fields",onClick:()=>_("fields"),children:"Fields"}),i.jsx("button",{type:"button",role:"tab",tabIndex:h==="json"?0:-1,"aria-selected":h==="json",onClick:()=>_("json"),children:"JSON payload"})]}),h==="json"?i.jsxs(i.Fragment,{children:[i.jsx(Wb,{value:n,disabled:a,onChange:s,onError:C=>d==null?void 0:d(C)}),i.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."})]}):E]}):E}function Wb({value:e,onChange:n,onError:s,disabled:a}){const[l,u]=wt.useState(JSON.stringify(e,null,2)),[d,f]=wt.useState(""),h=wt.useRef(e);return wt.useEffect(()=>{e!==h.current&&(h.current=e,u(JSON.stringify(e,null,2)),f(""),s(""))},[e,s]),i.jsxs("div",{className:"code-field",children:[i.jsx("label",{htmlFor:"workflow-input-payload",children:"Complete input object"}),i.jsx("textarea",{id:"workflow-input-payload",className:"code-mono",rows:12,value:l,disabled:a,"aria-invalid":!!d,onChange:g=>{u(g.target.value);const y=zb(g.target.value);if(!y.ok){f(y.error),s(y.error);return}h.current=y.value,f(""),s(""),n(y.value)}}),d?i.jsx("span",{role:"alert",className:"code-error-text",children:d}):null]})}function Ub({id:e,value:n,onChange:s,disabled:a}){const[l,u]=wt.useState(n===void 0?"":JSON.stringify(n,null,2)),[d,f]=wt.useState(""),h=wt.useRef(n);return wt.useEffect(()=>{n!==h.current&&(h.current=n,u(n===void 0?"":JSON.stringify(n,null,2)),f(""))},[n]),i.jsxs(i.Fragment,{children:[i.jsx("textarea",{id:e,className:"code-mono",rows:4,value:l,disabled:a,"aria-invalid":!!d,onChange:g=>{u(g.target.value);try{const y=g.target.value.trim()?JSON.parse(g.target.value):void 0;h.current=y,s(y),f("")}catch{h.current=g.target.value,s(g.target.value),f("Enter valid JSON.")}}}),d?i.jsx("span",{role:"alert",className:"code-error-text",children:d}):null]})}function Bb({attachments:e,uploads:n,sizes:s,onRemoveAttachment:a,onRemoveUpload:l,onRetryUpload:u}){return i.jsxs("div",{className:"code-attachments",role:"list","aria-label":"Attached files",children:[e.map((d,f)=>{const h=d.filename||d.path||"Attachment",g=typeof d.size_bytes=="number"?d.size_bytes:s==null?void 0:s.get(d.$artifact),y=typeof g=="number"?va(g):"";return i.jsxs("div",{role:"listitem",tabIndex:0,className:"code-attachment is-attached","aria-label":`${h}${y?`, ${y}`:""}, attached`,children:[i.jsx("span",{className:"code-attachment__icon","aria-hidden":"true",children:i.jsx(ae,{name:"paperclip",size:13})}),i.jsxs("span",{className:"code-attachment__body",children:[i.jsx("span",{className:"code-attachment__name",title:h,children:h}),y?i.jsx("span",{className:"code-attachment__meta",children:y}):null]}),i.jsx("button",{type:"button",className:"code-attachment__action","aria-label":`Remove ${h}`,title:`Remove ${h}`,onClick:()=>a(f),children:i.jsx(ae,{name:"x",size:12})})]},`${d.$artifact}:${f}`)}),n.map(d=>{const f=d.status==="queued"||d.status==="uploading",h=d.status==="queued"?`Waiting · ${va(d.size)}`:d.status==="uploading"?`Uploading · ${va(d.size)}`:d.message||"Not attached",g=d.status==="queued"?"waiting to upload":d.status==="uploading"?"uploading":`not attached: ${h}`;return i.jsxs("div",{role:"listitem",tabIndex:0,className:`code-attachment is-${d.status}`,"aria-label":`${d.name}, ${g}`,"aria-busy":f||void 0,children:[i.jsx("span",{className:"code-attachment__icon","aria-hidden":"true",children:f?i.jsx("span",{className:"code-attachment__spinner"}):i.jsx(ae,{name:"warning",size:13})}),i.jsxs("span",{className:"code-attachment__body",children:[i.jsx("span",{className:"code-attachment__name",title:d.name,children:d.name}),i.jsx("span",{className:"code-attachment__meta",children:h})]}),d.status==="failed"?i.jsxs("button",{type:"button",className:"code-attachment__action code-attachment__retry","aria-label":`Retry ${d.name}`,title:"Retry upload",onClick:()=>u(d.id),children:[i.jsx(ae,{name:"refresh",size:12}),i.jsx("span",{children:"Retry"})]}):null,i.jsx("button",{type:"button",className:"code-attachment__action","aria-label":`Remove ${d.name}`,title:`Remove ${d.name}`,onClick:()=>l(d.id),children:i.jsx(ae,{name:"x",size:12})})]},d.id)})]})}function Vb({active:e,paused:n,snapshot:s,onRevokeApproval:a,onCommand:l,onActivity:u,onInteraction:d,permissionsAll:f}){const h=w.useMemo(()=>Nv(s),[s]),y=w.useMemo(()=>h.tone==="working"?Ux(s.records.map(j=>j.record)):"",[h.tone,s.records])||h.detail,[x,b]=w.useState(Date.now);w.useEffect(()=>{if(!e)return;const j=window.setInterval(()=>b(Date.now()),1e3);return()=>window.clearInterval(j)},[e]);const _=Date.parse(h.startedAt||""),E=Number.isFinite(_)?Math.max(0,Math.floor((x-_)/1e3)):null,C=E===null?"":E<60?`${E}s`:`${Math.floor(E/60)}m ${E%60}s`;return i.jsxs("div",{className:`code-run-strip code-run-strip--${h.tone}`,children:[i.jsxs("div",{className:"code-run-strip__activity",role:"status","aria-live":"polite",children:[i.jsx("span",{className:"code-run-strip__icon","aria-hidden":"true",children:i.jsx(ae,{name:h.tone==="working"?"loader":h.tone==="success"?"check":h.tone==="error"?"error":h.tone==="waiting"?"history":"info",size:15})}),d&&h.tone==="waiting"?i.jsxs("button",{className:"code-run-strip__attention",onClick:d,title:"Go to the pending request",children:[i.jsx("strong",{children:h.label}),i.jsx(ae,{name:"chevronRight",size:12})]}):i.jsx("strong",{children:h.label}),i.jsx("span",{className:"code-run-strip__detail",title:y,children:y})]}),i.jsxs("span",{className:"code-run-strip__metrics","aria-label":"Run activity metrics",children:[e&&C?i.jsx("span",{children:C}):null,h.toolCalls?i.jsxs("span",{children:[h.toolCalls," ",h.toolCalls===1?"tool":"tools"]}):null,h.totalTokens!==void 0?i.jsxs("span",{children:[h.totalTokens.toLocaleString()," tokens"]}):null]}),e?i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:()=>l(n?"resume":"pause"),children:n?"Resume":"Pause"}),i.jsx("button",{onClick:()=>l("conclude"),children:"Conclude"})]}):null,i.jsxs("button",{onClick:u,children:["View activity ",i.jsx(ae,{name:"chevronRight",size:12})]}),f?i.jsxs("div",{className:"code-run-strip__consent",children:[i.jsx(ae,{name:"check",size:13}),i.jsx("span",{children:"Permissions: all · enabled tools only"}),i.jsx("button",{onClick:a,children:"Revoke"})]}):null]})}function Gb({runId:e,sessionId:n,capability:s,scope:a,preferences:l,onTranscript:u,onError:d}){var x,b;const f=w.useRef(!0),h=w.useRef(a);h.current=a,w.useEffect(()=>(f.current=!0,()=>{f.current=!1}),[]);const g=()=>{if(!f.current||h.current!==a)throw new Error("Voice session changed.")},y=Fy({tts:((x=s.tts)==null?void 0:x.available)===!0&&e?async _=>{g();const E=await ht(Se(`runs/${encodeURIComponent(e)}/voice/tts`),{method:"POST",body:JSON.stringify({text:_,request_id:Yr(),...Object.fromEntries(Object.entries(l).filter(([,T])=>T!==""&&T!==void 0))})});g();const C=E==null?void 0:E.audio_artifact;if(!(C!=null&&C.$artifact))throw new Error("The gateway did not return an audio artifact.");const{blob:j}=await Nn.get_run_artifact_blob(String(C.run_id||E.child_run_id||e),C.$artifact,{max_bytes:25e6});return g(),j.arrayBuffer()}:void 0,transcribe:((b=s.stt)==null?void 0:b.available)===!0&&e?async(_,E)=>{var k;g();const C=Number(((k=s.stt)==null?void 0:k.max_upload_bytes)||0);if(C>0&&_.size>C)throw new Error("Recording exceeds the gateway's upload limit. Try a shorter recording.");const j=E.includes("mp4")?"m4a":E.includes("ogg")?"ogg":E.includes("wav")?"wav":"webm",T=new File([_],`recording.${j}`,{type:E||"audio/webm"}),A=await Nn.attachments_upload(n,T);g();const $=await Nn.audio_transcribe(e,{audio_artifact:A,request_id:Yr()});return g(),String($.text||"")}:void 0,on_transcript:_=>{f.current&&h.current===a&&u(_)},on_error:_=>{f.current&&h.current===a&&d(_)}});return w.useEffect(()=>{var _;return y.stop_tts(),(_=y.cancel_voice_ptt_recording)==null||_.call(y),()=>{var E;y.stop_tts(),(E=y.cancel_voice_ptt_recording)==null||E.call(y)}},[a,y.stop_tts,y.cancel_voice_ptt_recording]),y}function Hb({voice:e,runId:n,capability:s,answer:a,onSettings:l}){var g,y,x,b,_;const u=w.useRef(!1),d=w.useRef(!0);w.useEffect(()=>(d.current=!0,()=>{d.current=!1,u.current=!1}),[]);const f=()=>{u.current=!0,e.start_voice_ptt_recording().then(()=>{(!u.current||!d.current)&&e.stop_voice_ptt_recording()})},h=()=>{u.current=!1,e.stop_voice_ptt_recording()};return w.useEffect(()=>(window.addEventListener("pointerup",h),window.addEventListener("pointercancel",h),window.addEventListener("blur",h),()=>{window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",h),window.removeEventListener("blur",h)}),[e.stop_voice_ptt_recording]),!((g=s.tts)!=null&&g.available)&&!((y=s.stt)!=null&&y.available)?null:i.jsxs(i.Fragment,{children:[(x=s.stt)!=null&&x.available?i.jsx("button",{className:"code-icon-button","aria-label":e.voice_ptt_recording?"Recording — release to transcribe":"Hold to dictate",title:n?"Hold to dictate (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:E=>{E.button===0&&f()},onPointerUp:h,onPointerCancel:h,onKeyDown:E=>{[" ","Enter"].includes(E.key)&&!E.repeat&&(E.preventDefault(),f())},onKeyUp:E=>{[" ","Enter"].includes(E.key)&&(E.preventDefault(),h())},onBlur:h,children:i.jsx(ae,{name:e.voice_ptt_busy?"loader":"mic",size:15})}):null,(b=s.tts)!=null&&b.available?i.jsx("button",{className:"code-icon-button","aria-label":e.tts_playback.status==="playing"?"Pause spoken reply":e.tts_playback.status==="paused"?"Resume spoken reply":"Read latest reply aloud",disabled:!e.tts_supported||!a||e.tts_playback.status==="loading",onClick:()=>{a&&e.toggle_tts(["playing","paused"].includes(e.tts_playback.status)?e.tts_playback.key:a.id||"latest",a.content)},children:i.jsx(ae,{name:e.tts_playback.status==="playing"?"pause":e.tts_playback.status==="loading"?"loader":"speaker",size:15})}):null,e.tts_playback.status!=="idle"?i.jsx("button",{className:"code-icon-button","aria-label":"Stop spoken reply",onClick:e.stop_tts,children:i.jsx(ae,{name:"x",size:14})}):null,l&&((_=s.tts)!=null&&_.available)?i.jsx("button",{className:"code-icon-button","aria-label":"Voice settings",title:"Voice settings",onClick:l,children:i.jsx(ae,{name:"settings",size:14})}):null,e.voice_ptt_recording||e.voice_ptt_busy?i.jsx("span",{role:"status",children:e.voice_ptt_recording?"Recording…":"Transcribing…"}):null]})}function Gc(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function Po(e){return typeof e=="string"?e.trim():""}function Kb(e){const n=Gc(e),s=Gc(n==null?void 0:n.gateway),a=Gc(s==null?void 0:s.principal);return JSON.stringify([Po((n==null?void 0:n.gateway_url)??(n==null?void 0:n.gatewayUrl)),Po((a==null?void 0:a.tenant_id)??(a==null?void 0:a.tenantId)),Po((a==null?void 0:a.runtime_id)??(a==null?void 0:a.runtimeId)),Po((a==null?void 0:a.user_id)??(a==null?void 0:a.userId))||"session"])}function Ph(e,n){return!!e.sourceRunId&&e.sessionId===n.sessionId&&e.sessionId===n.snapshotSessionId&&e.sourceRunId===n.runId&&e.sourceRunId===n.snapshotRunId&&e.authEpoch===n.authEpoch}function Jb(e){const n=typeof e=="string"?e.trim().toLowerCase():"";return["completed","complete","done"].includes(n)?"advance":["failed","error","cancelled","canceled"].includes(n)?"pause":"wait"}function Qb(e,n,s){return e.flatMap(a=>a.id===n.id?[]:a.sessionId!==n.sessionId||a.authEpoch!==n.authEpoch||a.sourceRunId!==n.sourceRunId?[a]:[{...a,sourceRunId:s}])}function Oh(){return new DOMException("The conversation changed before the run was attached.","AbortError")}const Yb=by("abstractcode","0.7.0"),Hc=e=>["completed","failed","cancelled","canceled"].includes(e);function Dh(){const e=new URLSearchParams(window.location.hash.replace(/^#/,""));return{sessionId:e.get("session")||Yr(),runId:e.get("run")||""}}function fa(e,n=""){const s=new URLSearchParams({session:e});n&&s.set("run",n),window.history.replaceState(null,"",`#${s}`)}function Xb(){var Ra,Ii,Ar,Ia,Mi,ls,Li,Ma,Tr,Rr,ar,cs,La,Pa,zs,us,Ws,Pi,An,Us,ds;const e=yy({appName:"AbstractCode",variant:"blocking"}),n=e.connected?Kb(e.status):"",s=w.useCallback(()=>{e.refresh()},[e.refresh]),a=lx(n,s),[l,u]=Ry("abstractcode",{defaults:{theme:"observer-night"}}),[d,f]=w.useState(!1),[h,g]=w.useState(),y=w.useCallback(()=>{g(void 0),ht(Se("about")).then(I=>g({ok:!0,value:I})).catch(I=>g({ok:!1,status:I==null?void 0:I.status,message:Et(I)}))},[]),[x,b]=w.useState(!1),[_,E]=w.useState({});w.useEffect(()=>{try{E(JSON.parse(localStorage.getItem(`abstractcode.voice:${n}`)||"{}"))}catch{E({})}b(!1)},[n]);const C=I=>{if(E(I),n)try{localStorage.setItem(`abstractcode.voice:${n}`,JSON.stringify(I))}catch{}},[j,T]=w.useState(yr),A=w.useRef(j);A.current=j;const $=G_(j.streamReplies,a.streaming),[k,P]=w.useState(yr.workflow),V=w.useMemo(()=>tx(a.choices,j.showAllWorkflows),[a.choices,j.showAllWorkflows]),H=w.useMemo(()=>ex(a.gatewayDefault,a.workflows),[a.gatewayDefault,a.workflows]),L=k===Sn?H:a.workflows.find(I=>I.id===k)||null,[de,re]=w.useState(null),Q=_u(L),[U,J]=w.useState(Dh),[fe,ce]=w.useState(""),[ye,ve]=w.useState(""),[q,oe]=w.useState(""),[G,N]=w.useState(!1),B=w.useRef(!1),[F,W]=w.useState([]),[ie,le]=w.useState([]),he=w.useRef(new Set),X=w.useRef(new Map),[$e,We]=w.useState(""),ke=w.useRef(null),[Y,ee]=w.useState(),[pe,Oe]=w.useState(!1),[we,Pe]=w.useState(""),[Be,rt]=w.useState(0),[K,me]=w.useState({}),[De,Ke]=w.useState(""),[He,Xn]=w.useState(null),[Mt,Cn]=w.useState(""),[Zn,En]=w.useState(!1),[Zr,vr]=w.useState(!1),[qo,xi]=w.useState("model"),[qr,bi]=w.useState(()=>window.innerWidth>1120),[ki,As]=w.useState("files"),[_r,Kt]=w.useState(!1),Ts=vb(a.capabilities),{ctl:cn,state:On}=Eb(n,e.connected&&Ts.available),[xr,br]=w.useState(!1),[ka,ji]=w.useState(!1),Rs=w.useRef(""),[es,ja]=w.useState(""),kr=w.useRef(null),[qn,ts]=w.useState("steer"),[er,Jt]=w.useState([]),[jr,Qt]=w.useState(!1),[Is,Si]=w.useState([]),Ms=w.useMemo(()=>Xp(a.tools,j.tools,j.permissions),[a.tools,j.tools,j.permissions]),Ni=w.useRef(null),tr=w.useMemo(()=>{var Fe,Ce;const I=((Fe=Ni.current)==null?void 0:Fe.runId)===U.runId?Ni.current.input:null;if(U.runId&&!He&&!I)return{enabledTools:[],autoApproveTools:[]};const Z=He?He.input_data:I,Ee=mx(Ms,(Ce=Z==null?void 0:Z._runtime)==null?void 0:Ce.allowed_tools);return{...Ee,autoApproveTools:j.toolsCustomized||j.permissions!=="default"?Ee.autoApproveTools:[]}},[Ms,He,U.runId,j.toolsCustomized,j.permissions]),Ls=`${n}:${U.sessionId}:${U.runId}`,Ci=w.useRef(Ls);Ci.current=Ls;const Sa=w.useRef(null),[Ei,Na]=w.useState({scope:"",notes:[]}),Ca=w.useMemo(()=>ux({onDeltaError:I=>{const Z=Ci.current,Ee=J_(I,Sa.current);Na(Fe=>({scope:Z,notes:Q_(Fe.scope===Z?Fe.notes:[],Ee)}))}}),[]),{controller:Dn,snapshot:Ve}=Jv({transport:Ca,runId:U.runId,enabled:e.connected,onAuthError:s,clientId:"abstractcode-web",authScopeKey:n,toolApprovalPolicy:tr}),un=!!U.runId&&!Hc(Ve.status)&&Ve.status!=="idle",st=((Ra=Ve.run)==null?void 0:Ra.paused)===!0||Ve.status==="paused",nr=un||G,Sr=Ve.loading&&Is.length?Is:Ve.messages,ns=Sr[Sr.length-1];Sa.current=ns!=null&&ns.id?String(ns.id):null;const dn=Y_(Sr,[H_(j.streamReplies,a.streaming,Sr),...Ei.scope===Ls?Ei.notes:[]]),Ea=((Ar=(Ii=a.capabilities)==null?void 0:Ii.assistant)==null?void 0:Ar.voice)||{},rr=Gb({scope:`${n}:${U.sessionId}:${U.runId}`,runId:n?U.runId:"",sessionId:U.sessionId,capability:Ea,preferences:_,onTranscript:I=>ce(Z=>Z?`${Z.trimEnd()}
71
+ ${I}`:I),onError:ve}),rs=Vv(Ve),pt=w.useMemo(()=>y_(rs,Dn,{records:Ve.records,currentRun:Ve.run,onPermissionsAll:async()=>{T(I=>({...I,permissions:"all"}))}}),[rs,Ve.records,Ve.run,Dn]),$a=!!pt&&qn==="steer",mt=Q?"prompt":D_(Y),Aa=Q||!!(mt&&!((Ia=Y==null?void 0:Y.required)!=null&&Ia.some(I=>I!==mt))),Nr=String(((Mi=He==null?void 0:He.workspace)==null?void 0:Mi.workspace_root)||((Li=(ls=Ve.run)==null?void 0:ls.vars)==null?void 0:Li.workspace_root)||""),ss=w.useMemo(()=>{var I;return j_(a.workflows,{inputData:He,runWorkflowId:(I=Ve.run)==null?void 0:I.workflow_id})},[a.workflows,He,(Ma=Ve.run)==null?void 0:Ma.workflow_id]),sr=U.runId&&He&&!a.loading&&Ve.run&&!ss&&ku(He)!=="gateway_default"?"This conversation's exact workflow version is unavailable. Restore it in the gateway, or start a new conversation with an available workflow.":"",Lt=a.sessions.find(I=>I.sessionId===U.sessionId),Cr=(Lt==null?void 0:Lt.prompt)||((Tr=dn.find(I=>I.role==="user"))==null?void 0:Tr.content)||"New conversation",is=wb((Rr=e.status)==null?void 0:Rr.gateway_url),$i=is?()=>{window.open(is,"_blank","noopener,noreferrer")}:void 0,el={...$i?{openMyEmail:$i}:{},openConversation:(I,Z,Ee)=>{Rs.current=Ee||"",Ds(I,Z)},openRun:I=>{ht(Se(`runs/${encodeURIComponent(I)}`)).then(Z=>{if(!(Z!=null&&Z.session_id))throw new Error(`The gateway reported no session for run ${I}.`);Ds(Z.session_id,I)}).catch(Z=>cn.reportError(Z))}},Ps=((ar=On.detail)==null?void 0:ar.summary.title)||"Automation",Os=w.useRef(""),ir=w.useRef(n),lt=w.useRef(0);ir.current!==n&&(lt.current+=1,ir.current=n);const Ai=w.useRef(!1),_t=w.useRef(U);_t.current=U,w.useEffect(()=>{if(B.current=!1,N(!1),le([]),ve(""),oe(""),!n){W([]),ce(""),Jt([]),Qt(!1),Si([]),T(yr);return}if(Os.current&&Os.current!==n){const Z={sessionId:Yr(),runId:""};J(Z),fa(Z.sessionId)}Os.current=n,Ai.current=!0;const I=Pb(n);T(I),P(I.workflow)},[n]),w.useEffect(()=>{if(n){if(Ai.current){Ai.current=!1;return}Ob(n,j)}},[j,n]),w.useEffect(()=>{if(a.loading||!a.workflows.length)return;const I=nx({selection:k,preferred:j.workflow,visible:V,workflows:a.workflows,runId:U.runId});I!==k&&P(I)},[a.loading,a.workflows,V,k,j.workflow,U.runId]),w.useEffect(()=>{let I=!0;if(me({}),Ke(""),ee(void 0),Pe(""),!L){Oe(!1);return}return Oe(!0),cx(L).then(Z=>{I&&(ee(Z),me(ma(Z)))}).catch(Z=>{I&&Pe(Et(Z))}).finally(()=>{I&&Oe(!1)}),()=>{I=!1}},[L==null?void 0:L.id,Be]),w.useEffect(()=>{if(Xn(null),Cn(""),!n||!U.runId)return;const I=new AbortController;return ht(Se(`runs/${encodeURIComponent(U.runId)}/input_data`),{signal:I.signal}).then(Z=>{Xn(Z)}).catch(Z=>{I.signal.aborted||Cn(Et(Z))}),()=>I.abort()},[U.runId,n]),w.useEffect(()=>{He&&He.flow_id===(L==null?void 0:L.flowId)&&Y&&me({...ma(Y),...L_(Y,He.input_data)})},[He,Y,L==null?void 0:L.flowId]),w.useEffect(()=>{!U.runId&&e.connected&&(Lt!=null&&Lt.latestRunId)&&J(I=>({...I,runId:Lt.latestRunId}))},[U.runId,e.connected,Lt==null?void 0:Lt.latestRunId]),w.useEffect(()=>{fa(U.sessionId,U.runId),B.current=!1,N(!1),le([]),W([]),Si([]),oe(Rs.current),Rs.current="",ve(""),Jt([]),Qt(!1)},[U.sessionId]),w.useEffect(()=>{const I=()=>{const Z=Dh();B.current=!1,N(!1),le([]),Jt([]),Qt(!1),ce(""),J(Z)};return window.addEventListener("hashchange",I),()=>window.removeEventListener("hashchange",I)},[]),w.useEffect(()=>{!U.runId||!Hc(Ve.status)||a.refresh()},[U.runId,Ve.status]),w.useEffect(()=>{if(!U.runId||!He)return;const I=rx({restoredInputs:He,restored:ss});I&&P(I)},[U.runId,He,ss==null?void 0:ss.id]);const Je=U.runId?sx(He):"",as=w.useCallback(()=>{const I={sessionId:Yr(),runId:""};J(I),P(A.current.workflow),fa(I.sessionId),ce(""),Jt([]),Qt(!1),Kt(!1),br(!1)},[]),Ds=w.useCallback((I,Z)=>{B.current=!1,N(!1),le([]),J({sessionId:I,runId:Z}),fa(I,Z),Kt(!1),Jt([]),Qt(!1),ce(""),br(!1)},[]);w.useEffect(()=>{const I=Z=>{var Ee;if(Z.key==="Escape"&&_r){Kt(!1),(Ee=document.querySelector(".code-mobile-nav"))==null||Ee.focus();return}(Z.metaKey||Z.ctrlKey)&&(Z.key.toLowerCase()==="k"&&(Z.preventDefault(),Kt(!0),window.setTimeout(()=>{var Fe;return(Fe=kr.current)==null?void 0:Fe.focus()},0)),Z.key.toLowerCase()==="n"&&Z.shiftKey&&(Z.preventDefault(),as()))};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[as,_r]);async function Er(I){if(B.current)throw new Error("A turn is already being submitted.");if(!e.connected)throw new Error("Connect to your gateway first.");if(k===Sn&&a.gatewayDefault.status==="unavailable")throw new Error(`Gateway default: ${a.gatewayDefault.reason}. Choose a workflow from the list.`);if(!L)throw new Error("Choose a workflow first.");if(!a.policy)throw new Error("Workspace policy is unavailable. Reconnect or refresh before starting.");if(U.runId&&(!He||Mt))throw new Error(Mt||"Wait for the gateway to restore this conversation's workspace.");if(sr)throw new Error(sr);if(pe||we)throw new Error(we||"Wait for workflow inputs to load.");if(De)throw En(!0),new Error(De);const Z=kx(ie);if(Z)throw new Error(Z);if(un)throw new Error("The current run is still active.");if(!Q&&I.trim()&&!mt)throw En(!0),new Error("This workflow uses structured inputs. Configure its inputs, then select Run workflow.");const Ee={...ma(Y),...K,...mt&&I.trim()?{[mt]:I.trim()}:{}},Fe=Q?Ee:Fb(Y,Ee,F);for(const[Pt,Ot]of[["Iteration limit",j.maxIterations],["Context token limit",j.maxTokens]])if(Ot&&(!Number.isInteger(Number(Ot))||Number(Ot)<=0))throw new Error(`${Pt} must be a positive whole number.`);B.current=!0,N(!0),ve(""),oe("");const Ce=U.sessionId,gt=U.runId,Un=n,wn=lt.current;let jt="";try{const Pt=$_({workflow:L,inputSchema:Y,schemaInputs:Fe,prompt:I,promptProperty:mt,model:j,reasoning:j.reasoning||void 0,speculation:j.speculation,streamReplies:$,systemPromptExtra:j.system||void 0,attachments:F,limits:{maxIterations:j.maxIterations?Number(j.maxIterations):void 0,maxTokens:j.maxTokens?Number(j.maxTokens):void 0},workspace:a.policy.clientWorkspaceScopeOverrides?{root:j.workspaceRoot||Nr||void 0,accessMode:j.workspaceMode||void 0,allowedPaths:j.allowedPaths.split(`
72
+ `).filter(Boolean)}:Nr?{root:Nr}:void 0,tools:j.toolsCustomized?Ms.enabledTools:void 0,toolPolicy:j.toolsCustomized||j.permissions!=="default"?{autoApproveTools:[],requireApprovalTools:Ms.enabledTools}:void 0,skills:j.skills.length?j.skills:void 0}),Ot=F_(Y,Pt);if(Ot.length)throw En(!0),new Error(Ot.join(" "));const fn=ix({selection:k,workflow:L,sessionId:Ce,input:Pt}),hn=await ht(Se("runs/start"),{method:"POST",body:JSON.stringify(fn)});if(!hn.run_id)throw new Error("The gateway did not return a run identifier.");if(_t.current.sessionId!==Ce||_t.current.runId!==gt||ir.current!==Un||lt.current!==wn)throw Oh();return jt=String(hn.run_id),Ni.current={runId:jt,input:Pt},re({runId:jt,...ax(hn.resolved_workflow)}),Si([...dn,...I.trim()?[{id:`pending:${hn.run_id}`,role:"user",content:I.trim()}]:[]]),J({sessionId:Ce,runId:hn.run_id}),fa(Ce,hn.run_id),ce(""),W([]),En(!1),hn.runner_warning&&oe(String(hn.runner_warning)),a.refresh(),jt}finally{_t.current.sessionId===Ce&&(_t.current.runId===gt||_t.current.runId===jt)&&ir.current===Un&&lt.current===wn&&(B.current=!1,N(!1))}}async function Ta(I){if(!un)return Er(I);if(qn==="queue")Jt(Z=>[...Z,{id:Yr(),text:I,sessionId:U.sessionId,sourceRunId:U.runId,authEpoch:lt.current}]),Qt(!0),ce(""),oe("Queued for the next turn.");else{if(pt)throw new Error("Answer the pending workflow request above, or choose Queue next turn.");const Z=U.sessionId,Ee=U.runId,Fe=lt.current;if(await Dn.sendCommand("inject_guidance",{guidance:I}),_t.current.sessionId!==Z||_t.current.runId!==Ee||lt.current!==Fe)return;ce(""),oe("Guidance queued. The workflow will read it at its next supported boundary.")}}async function Ti(I){var Fe,Ce;const Z=String(((Fe=Ve.run)==null?void 0:Fe.run_id)||"");if(!Ph(I,{sessionId:U.sessionId,runId:U.runId,snapshotRunId:Z,snapshotSessionId:String(((Ce=Ve.run)==null?void 0:Ce.session_id)||""),authEpoch:lt.current}))throw Oh();const Ee=await Er(I.text);Jt(gt=>Qb(gt,I,Ee))}w.useEffect(()=>{var Ee,Fe;if(!jr||!er.length||!e.connected||!He||Mt||B.current)return;const I=Jb(Ve.status);if(I==="wait")return;if(I==="pause"){Qt(!1);const Ce=["failed","error"].includes(Ve.status.toLowerCase());oe(`Queue paused because the run ${Ce?"failed":"was cancelled"}. Review the result, then use Run next to continue explicitly.`);return}const Z=er[0];Ph(Z,{sessionId:U.sessionId,runId:U.runId,snapshotRunId:String(((Ee=Ve.run)==null?void 0:Ee.run_id)||""),snapshotSessionId:String(((Fe=Ve.run)==null?void 0:Fe.session_id)||""),authEpoch:lt.current})&&Ti(Z).catch(Ce=>{Ce instanceof DOMException&&Ce.name==="AbortError"||(Qt(!1),ve(Et(Ce)))})},[jr,er,Ve.status,(cs=Ve.run)==null?void 0:cs.run_id,(La=Ve.run)==null?void 0:La.session_id,e.connected,He,Mt,U.sessionId,U.runId]);async function Ri(I){const Z=U.sessionId,Ee=n,Fe=lt.current,Ce=()=>_t.current.sessionId!==Z||ir.current!==Ee||lt.current!==Fe,gt=(jt,Pt)=>le(Ot=>Ot.map(fn=>fn.id===jt?{...fn,...Pt}:fn));let Un=0,wn=0;await bx(I,vx,async jt=>{if(!(Ce()||he.current.has(jt.id))){gt(jt.id,{status:"uploading",message:void 0});try{const Pt=await Nn.attachments_upload(Z,jt.file);if(Ce()||he.current.has(jt.id))return;X.current.set(Pt.$artifact,jt.size),le(Ot=>Ot.filter(fn=>fn.id!==jt.id)),W(Ot=>[...Ot,Pt]),Un+=1}catch(Pt){if(Ce()||he.current.has(jt.id))return;gt(jt.id,{status:"failed",message:_x(Et(Pt))}),wn+=1}}}),!Ce()&&(Un||wn)&&We(Eh(Un,wn))}function os(I){var Fe;if(!I.length)return[];const Z=xx(I,(Fe=a.policy)==null?void 0:Fe.maxAttachmentBytes,Yr);le(Ce=>[...Ce,...Z]);const Ee=Z.filter(Ce=>Ce.status==="refused").length;return Ee&&We(Eh(0,Ee)),Ri(Z.filter(Ce=>Ce.status==="queued")),Z}function Fs(I){const Z=ie.find(Fe=>Fe.id===I);if(!Z||Z.status!=="failed")return;const Ee={...Z,status:"queued",message:void 0};le(Fe=>Fe.map(Ce=>Ce.id===I?Ee:Ce)),Ri([Ee])}function Fn(I){he.current.add(I),le(Z=>Z.filter(Ee=>Ee.id!==I))}async function zn(){const I=U.sessionId,Z=U.runId,Ee=lt.current;await Dn.cancel(),_t.current.sessionId===I&&_t.current.runId===Z&&lt.current===Ee&&oe("")}const Yt=I=>{xi(I),vr(!0)},$n=I=>{const Z=lt.current,Ee=U.sessionId,Fe=U.runId;ve(""),I().catch(Ce=>{Ce instanceof DOMException&&Ce.name==="AbortError"||lt.current===Z&&_t.current.sessionId===Ee&&_t.current.runId===Fe&&ve(Et(Ce))})},$r=a.sessions.filter(I=>`${I.prompt||""} ${I.sessionId}`.toLowerCase().includes(es.toLowerCase())),Wn=(()=>{var I;try{return new URL(((I=e.status)==null?void 0:I.gateway_url)||"").host}catch{return"Your gateway"}})();return i.jsxs("div",{className:`code-app${_r?" code-app--nav-open":""}${qr?" code-app--inspector":""}`,children:[i.jsx("a",{className:"code-skip-link",href:"#code-conversation",children:"Skip to conversation"}),i.jsxs("aside",{className:"code-sidebar","aria-label":"Conversations",children:[i.jsxs("div",{className:"code-brand",children:[i.jsxs("span",{className:"code-brand-mark","aria-hidden":"true",children:["a",i.jsx("span",{children:"c"})]}),i.jsxs("div",{children:[i.jsx("strong",{children:"AbstractCode"}),i.jsx("span",{children:"YOUR WORK, IN CONTEXT"})]}),i.jsx("button",{className:"code-mobile-close code-icon-button","aria-label":"Close navigation",onClick:()=>Kt(!1),children:i.jsx(ae,{name:"x",size:18})})]}),i.jsxs("button",{className:"code-new-chat",onClick:as,children:[i.jsx(ae,{name:"plus",size:17}),i.jsx("span",{children:"New conversation"}),i.jsx("kbd",{children:"⇧⌘N"})]}),i.jsxs("div",{className:"code-session-search",children:[i.jsx(ae,{name:"history",size:14}),i.jsx("input",{ref:kr,"aria-label":"Search conversations",placeholder:"Search conversations",value:es,onChange:I=>ja(I.target.value)}),i.jsx("kbd",{children:"⌘K"})]}),i.jsx($b,{state:On,available:Ts,selectedId:xr?On.selectedId:"",onSelect:I=>{br(!0),Kt(!1),cn.select(I)},onNew:()=>ji(!0),onRefresh:()=>void cn.refresh(),onShowArchived:I=>cn.setShowArchived(I)}),i.jsxs("div",{className:"code-section-label",children:[i.jsx("span",{children:"CONVERSATIONS"}),i.jsx("button",{className:"code-icon-button","aria-label":"Refresh conversations",disabled:!e.connected||a.loading,onClick:()=>void a.refresh(),children:i.jsx(ae,{name:"refresh",size:13})})]}),i.jsxs("nav",{className:"code-sessions","aria-label":"Conversation history",children:[Lt?null:i.jsxs("button",{className:"code-session is-selected",onClick:()=>Kt(!1),children:[i.jsx(ae,{name:"chat",size:15}),i.jsxs("span",{children:[i.jsx("strong",{children:"New conversation"}),i.jsx("small",{children:"Ready when you are"})]})]}),$r.map(I=>i.jsx(Zb,{item:I,selected:I.sessionId===U.sessionId,onClick:()=>Ds(I.sessionId,I.latestRunId)},I.sessionId)),!a.loading&&!$r.length?i.jsx("p",{className:"code-history-empty",children:es?"No conversations match your search.":"Your conversations will live here. Pick up where you left off, on any device."}):null,a.loading?i.jsx("p",{className:"code-history-empty",role:"status",children:"Loading conversations…"}):null,a.hasMore?i.jsx("button",{className:"code-load-more",onClick:a.loadMore,children:"Load more conversations"}):null]}),i.jsxs("div",{className:"code-sidebar-bottom",children:[i.jsxs("button",{onClick:()=>Yt("workspace"),children:[i.jsx(ae,{name:"terminal",size:17}),i.jsxs("span",{children:[i.jsx("strong",{children:"Workspace"}),i.jsx("small",{children:Nr.split("/").filter(Boolean).pop()||"Gateway managed"})]}),i.jsx(ae,{name:"chevronRight",size:14})]}),i.jsxs("button",{onClick:()=>Yt("model"),children:[i.jsx(ae,{name:"settings",size:17}),i.jsx("span",{children:"Settings"})]}),i.jsxs("div",{className:"code-gateway-foot",children:[i.jsx("span",{className:`code-status-dot ${e.connected?"is-online":""}`}),i.jsx("span",{children:Wn}),i.jsx("small",{children:((us=(zs=(Pa=e.status)==null?void 0:Pa.gateway)==null?void 0:zs.principal)==null?void 0:us.user_id)||"Signed out"})]})]})]}),_r?i.jsx("button",{className:"code-nav-scrim","aria-label":"Close conversation navigation",onClick:()=>Kt(!1)}):null,i.jsxs("div",{className:"code-main-shell",children:[i.jsxs("header",{className:"code-topbar",children:[i.jsx("button",{className:"code-mobile-nav code-icon-button","aria-label":"Open conversation navigation",onClick:()=>Kt(!0),children:i.jsx(ae,{name:"list",size:19})}),i.jsxs("div",{className:"code-breadcrumb",children:[i.jsx("span",{children:xr?"Automations":"Conversations"}),i.jsx("span",{"aria-hidden":"true",children:"/"}),i.jsx("strong",{title:xr?Ps:Cr,children:xr?Ps:Cr})]}),i.jsx($y,{appearance:{onOpen:()=>f(!0)},about:{identity:Yb,extraRows:mb(h),onOpen:y},extraActions:i.jsx("button",{className:`af-topbar__btn${qr?" is-active":""}`,"aria-label":"Toggle workspace inspector","aria-pressed":qr,onClick:()=>bi(I=>!I),children:i.jsx(ae,{name:"board",size:17})}),connection:{phase:e.phase,signingOut:e.signingOut,onConnect:e.openModal,onDisconnect:()=>{e.signOut()}}})]}),i.jsxs("div",{className:"code-toolbar",children:[i.jsxs("div",{className:"code-workflow-select",children:[i.jsx(ae,{name:"agent",size:17}),i.jsxs("select",{"aria-label":"Workflow",value:k,disabled:nr||a.loading||!e.connected,onChange:I=>{const Z=I.target.value;P(Z),T(Ee=>({...Ee,workflow:Z}))},children:[i.jsx("option",{value:Sn,children:Sh(a.gatewayDefault)}),L&&k!==Sn&&!V.some(I=>I.id===L.id)?i.jsxs("option",{value:L.id,children:[L.name,U.runId?` · conversation version ${L.bundleVersion||""}`:""]}):null,V.map(I=>i.jsx("option",{value:I.id,children:b_(I,V)},I.id))]}),i.jsx("span",{className:"code-workflow-kind",children:Q?"AGENT":"WORKFLOW"}),i.jsxs("label",{className:"code-workflow-all",title:"List workflows that are not coding agents too",children:[i.jsx("input",{type:"checkbox",checked:j.showAllWorkflows,disabled:nr||!e.connected,onChange:I=>T(Z=>({...Z,showAllWorkflows:I.target.checked}))}),i.jsx("span",{children:"Show all workflows"})]}),k===Sn&&Wc(H)?i.jsx("span",{className:"code-workflow-resolved is-missing",role:"alert",title:Wc(H),children:Wc(H)}):null,Je?i.jsx("span",{className:"code-workflow-resolved is-missing",role:"status",title:Je,children:Je}):null,de&&de.runId===U.runId?i.jsx("span",{className:`code-workflow-resolved${de.missing?" is-missing":""}`,role:"status",children:de.text}):null]}),i.jsx("span",{className:"code-toolbar-divider"}),i.jsxs("button",{className:"code-model-button",onClick:()=>Yt("model"),children:[i.jsx(ae,{name:"sparkle",size:14}),i.jsx("span",{children:j.model||(K.provider&&K.model?`Workflow · ${K.model}`:"Gateway default")}),i.jsx(ae,{name:"chevronDown",size:12})]}),i.jsx("div",{className:"code-toolbar-spacer"}),i.jsxs("button",{className:"code-subtle-button",onClick:()=>En(!0),disabled:!L,children:[i.jsx(ae,{name:"settings",size:14}),i.jsx("span",{children:"Inputs"})]}),i.jsxs("button",{className:"code-subtle-button",onClick:()=>Yt("tools"),children:[i.jsx(ae,{name:"terminal",size:14}),i.jsx("span",{children:"Tools"})]}),dn.length?i.jsx("button",{className:"code-icon-button","aria-label":"Export conversation",title:"Export conversation",onClick:()=>Qw({filename:"conversation.md",text:Jw(dn)}),children:i.jsx(ae,{name:"download",size:15})}):null]}),i.jsxs("div",{className:"code-content",children:[xr?i.jsx(Ib,{ctl:cn,host:el,enabled:e.connected,onClose:()=>br(!1)}):i.jsxs("main",{className:"code-conversation",id:"code-conversation",tabIndex:-1,children:[ye||Ve.error||e.signOutError||Mt?i.jsxs("div",{className:"code-alert",role:"alert",children:[i.jsx(ae,{name:"warning",size:16}),i.jsx("span",{children:ye||Ve.error||e.signOutError||Mt}),Ve.error||Mt?i.jsx("button",{onClick:()=>{Mt?window.location.reload():$n(()=>Dn.load(U.runId))},children:"Reconnect"}):i.jsx("button",{"aria-label":"Dismiss error",onClick:()=>ve(""),children:i.jsx(ae,{name:"x",size:14})})]}):null,a.errors.length?i.jsx("div",{className:"code-discovery-errors",role:"status",children:i.jsxs("details",{children:[i.jsx("summary",{children:"Some gateway information could not be loaded"}),a.errors.map(I=>i.jsx("p",{children:I},I)),i.jsx("button",{onClick:()=>void a.refresh(),children:"Retry discovery"})]})}):null,sr?i.jsxs("div",{className:"code-alert",role:"alert",children:[i.jsx("span",{children:sr}),i.jsx("button",{onClick:as,children:"New conversation"})]}):null,we?i.jsxs("div",{className:"code-alert",role:"alert",children:[i.jsxs("span",{children:["Workflow inputs: ",we]}),i.jsx("button",{onClick:()=>rt(I=>I+1),children:"Retry"})]}):null,q?i.jsxs("div",{className:"code-notice",role:"status",children:[q,i.jsx("button",{"aria-label":"Dismiss notice",onClick:()=>oe(""),children:i.jsx(ae,{name:"x",size:13})})]}):null,un||Hc(Ve.status)?i.jsx(Vb,{active:un,paused:st,snapshot:Ve,permissionsAll:j.permissions==="all",onInteraction:pt&&!st?()=>{var Ee;const I=document.querySelector(".code-conversation .pc-chat-thread"),Z=I==null?void 0:I.querySelector(".pc-workflow-interaction");!I||!Z||(I.scrollTop+=Z.getBoundingClientRect().top-I.getBoundingClientRect().top,(Ee=Z.querySelector("h3"))==null||Ee.focus({preventScroll:!0}))}:void 0,onRevokeApproval:()=>{Dn.revokeToolApproval(),T(I=>({...I,permissions:"default"}))},onCommand:I=>$n(()=>Dn.sendCommand(I,{})),onActivity:()=>{As("activity"),bi(!0)}}):null,i.jsx(Pv,{streamReplies:$,messages:(pt==null?void 0:pt.kind)==="tool-approval"?dn.filter(I=>{var Z,Ee;return!(((Z=I.toolActivity)==null?void 0:Z.status)==="waiting"&&I.toolActivity.runId===((Ee=Ve.interaction)==null?void 0:Ee.runId))}):dn,messageProps:{...rr.tts_supported?{onSpeakToggle:I=>{rr.toggle_tts(I.id||I.content,I.content)}}:{},getSpeakState:I=>rr.tts_playback.key===(I.id||I.content)?rr.tts_playback.status:"idle"},draft:fe,onDraftChange:ce,onSend:Ta,busy:nr,busyLabel:$a?"Waiting for you":G?"Starting…":st?"Paused":"Working…",sendWhileBusy:un&&!G&&!$a,sendLabel:un?qn==="queue"?"Queue":"Steer":"Send",onCancel:zn,stopState:Ve.stop??null,disabled:!e.connected,interaction:pt,onAttach:()=>{var I;return(I=ke.current)==null?void 0:I.click()},onFiles:I=>{os(I)},attachments:F.length||ie.length?i.jsx(Bb,{attachments:F,uploads:ie,sizes:X.current,onRemoveAttachment:I=>W(Z=>Z.filter((Ee,Fe)=>Fe!==I)),onRemoveUpload:Fn,onRetryUpload:Fs}):null,placeholder:un?qn==="queue"?"Queue the next task after this run…":pt?"Answer the request above, or choose Queue next turn…":"Guide the current workflow…":"Describe what you want to build, fix, or explore…",emptyState:un?null:i.jsx(qb,{workflow:L,loading:a.loading||pe,onSuggestion:ce,onInputs:()=>En(!0),isAgent:Aa,onRun:()=>$n(()=>Er(fe)),connected:e.connected}),composerExtras:i.jsxs(i.Fragment,{children:[i.jsxs("button",{className:"code-composer-workspace",onClick:()=>Yt("workspace"),title:Nr||"Workspace is managed by the gateway",children:[i.jsx(ae,{name:"terminal",size:14}),i.jsx("span",{children:Nr.split("/").filter(Boolean).pop()||"Gateway workspace"})]}),e.connected?i.jsx(Hb,{runId:U.runId,voice:rr,capability:Ea,onSettings:()=>b(!0),answer:[...dn].reverse().find(I=>I.role==="assistant")},`${n}:${U.sessionId}:${U.runId}`):null,un?i.jsxs("select",{"aria-label":"Message destination",value:qn,onChange:I=>ts(I.target.value),children:[i.jsxs("option",{value:"steer",disabled:!!pt,children:["Guide this run",pt?" (answer above)":""]}),i.jsx("option",{value:"queue",children:"Queue next turn"})]}):null]}),footer:i.jsxs(i.Fragment,{children:[i.jsxs("span",{children:["Enter to send ",i.jsx("span",{"aria-hidden":"true",children:"·"})," Shift + Enter for a new line"]}),i.jsxs("span",{children:[(Ws=a.policy)!=null&&Ws.clientWorkspaceScopeOverrides?"Gateway policy enforced":"Managed workspace",i.jsx("span",{className:"code-small-dot"})]})]})}),er.length?i.jsxs("div",{className:"code-queue",children:[i.jsxs("div",{children:[i.jsxs("strong",{children:[er.length," queued"," ",er.length===1?"turn":"turns"]}),i.jsx("button",{onClick:()=>Qt(I=>!I),children:jr?"Pause queue":"Resume queue"})]}),er.map(I=>i.jsxs("div",{children:[i.jsx("span",{children:I.text}),un?null:i.jsx("button",{onClick:()=>$n(()=>Ti(I)),children:"Run next"}),i.jsx("button",{"aria-label":"Remove queued turn",onClick:()=>Jt(Z=>Z.filter(Ee=>Ee.id!==I.id)),children:i.jsx(ae,{name:"x",size:13})})]},I.id))]}):null]}),qr?i.jsx(cb,{tab:ki,onTab:As,policy:a.policy,runId:U.runId,records:Ve.records,enabled:e.connected,isAdmin:((Us=(An=(Pi=e.status)==null?void 0:Pi.gateway)==null?void 0:An.principal)==null?void 0:Us.admin)===!0,refreshKey:Ve.status,onAttachFiles:os,onClose:()=>bi(!1),onAttach:async I=>{const Z=U.sessionId,Ee=U.runId,Fe=lt.current,Ce=await Nn.attachments_ingest(Z,I);_t.current.sessionId===Z&&_t.current.runId===Ee&&lt.current===Fe&&W(gt=>[...gt,Ce])}}):null]}),i.jsxs("footer",{className:"code-statusbar",children:[i.jsxs("span",{children:[i.jsx("span",{className:`code-status-dot ${e.connected?"is-online":""}`}),e.connected?"Connected":e.phase==="loading"?"Connecting":"Disconnected"]}),i.jsx("span",{children:(L==null?void 0:L.name)||"No workflow selected"}),i.jsx("div",{}),i.jsx("span",{children:U.runId?`Run ${U.runId.slice(0,8)}`:"Ready to start"}),i.jsx("button",{onClick:()=>f(!0),children:l.theme.replace(/-/g," ")})]})]}),i.jsx("div",{className:"pc-sr-only",role:"status","aria-live":"polite",children:$e}),i.jsx("input",{ref:ke,hidden:!0,type:"file",multiple:!0,onChange:I=>{os(Array.from(I.target.files||[])),I.target.value=""}}),i.jsx(Mb,{open:ka,onClose:()=>ji(!1),target:_b(k,L),workflowLabel:k===Sn?Sh(a.gatewayDefault):(L==null?void 0:L.name)||"the selected workflow",initialPrompt:fe||((ds=[...dn].reverse().find(I=>I.role==="user"))==null?void 0:ds.content)||"",ctl:cn,onOpenMyEmail:$i,onCreated:()=>{br(!0),Kt(!1)}}),i.jsx(my,{...e.modalProps}),i.jsx(Yc,{open:x,onClose:()=>b(!1),label:"Voice settings",title:"AI voice",width:480,topOffset:60,className:"code-settings-drawer",children:i.jsx("div",{className:"code-settings",children:i.jsx(zy,{value:_,onChange:I=>{rr.stop_tts(),C(I)},fetchCatalog:(I,Z)=>ht(Se(`voice/voices?compact=true${I?`&provider=${encodeURIComponent(I)}`:""}${Z?`&model=${encodeURIComponent(Z)}`:""}`))})})}),i.jsx(Iy,{open:d,onClose:()=>f(!1),value:l,onChange:u}),i.jsx(gx,{open:Zr,onClose:()=>vr(!1),tab:qo,onTab:xi,value:j,onChange:I=>{const Z=[];(j.provider||j.model)&&!I.provider&&!I.model&&Z.push("provider","model"),j.toolsCustomized&&!I.toolsCustomized&&Z.push("tools"),j.maxIterations&&!I.maxIterations&&Z.push("max_iterations"),Z.length&&me(Ee=>{const Fe={...Ee},Ce=ma(Y);for(const gt of Z)delete Fe[gt],Object.prototype.hasOwnProperty.call(Ce,gt)&&(Fe[gt]=Ce[gt]);return Fe}),T(I)},policy:a.policy,tools:a.tools,defaultModel:K.provider&&K.model?{provider:String(K.provider),model:String(K.model)}:a.defaultModel,workflowDefault:!!(K.provider&&K.model),streaming:a.streaming,disabled:nr||!e.connected},n),i.jsx(Yc,{open:Zn,onClose:()=>En(!1),label:"Workflow inputs",title:(L==null?void 0:L.name)||"Workflow inputs",width:480,topOffset:60,className:"code-settings-drawer",children:i.jsxs("div",{className:"code-settings",children:[i.jsx("p",{className:"code-muted",children:(L==null?void 0:L.description)||"Configure the values this workflow needs to run."}),pe?i.jsx("p",{role:"status",children:"Loading input schema…"}):we?null:Q||mt?i.jsx(Db,{schema:Y,promptProperty:mt,defaultModel:a.defaultModel,values:K,onChange:me,disabled:nr,onEditorError:Ke},L==null?void 0:L.id):i.jsx(lu,{schema:Y,defaultModel:a.defaultModel,values:K,onChange:me,disabled:nr,rawObject:!0,onEditorError:Ke},L==null?void 0:L.id),we?i.jsx("p",{role:"alert",className:"code-error-text",children:we}):null,Aa?i.jsxs("button",{className:"code-primary-button",onClick:()=>En(!1),children:["Back to chat ",i.jsx(ae,{name:"chat",size:16})]}):i.jsxs("button",{className:"code-primary-button",disabled:nr||pe||!!we||!!De||!e.connected,onClick:()=>$n(()=>Er(fe||String(K[mt||"prompt"]||""))),children:["Run workflow ",i.jsx(ae,{name:"playCircle",size:16})]})]})})]})}function Zb({item:e,selected:n,onClick:s}){const a=e.prompt||`Conversation ${e.sessionId.slice(0,8)}`,l=e.updatedAt?new Date(e.updatedAt):null;return i.jsxs("button",{className:`code-session${n?" is-selected":""}`,"aria-current":n?"page":void 0,onClick:s,title:a,children:[i.jsx(ae,{name:"chat",size:15}),i.jsxs("span",{children:[i.jsx("strong",{children:a}),i.jsxs("small",{children:[l&&Number.isFinite(l.getTime())?l.toLocaleDateString(void 0,{month:"short",day:"numeric"}):"Saved conversation"," ",i.jsx("span",{"aria-hidden":"true",children:"·"})," ",e.turnCount," ",e.turnCount===1?"turn":"turns"]})]}),e.state==="running"||e.state==="waiting"?i.jsx("span",{className:`code-status-dot ${e.state==="running"?"is-working":"is-waiting"}`,title:e.state}):null]})}function qb({workflow:e,loading:n,onSuggestion:s,onInputs:a,isAgent:l,onRun:u,connected:d}){return i.jsxs("div",{className:"code-welcome",children:[i.jsxs("div",{className:"code-welcome-symbol","aria-hidden":"true",children:[i.jsx("span",{children:"›"}),i.jsx("span",{children:"_"})]}),i.jsx("p",{className:"code-eyebrow",children:"A LITTLE CONTEXT. A LOT OF POSSIBILITY."}),i.jsx("h1",{children:"What are we building?"}),i.jsxs("p",{className:"code-welcome-description",children:["A focused space to think, code, and get things done.",i.jsx("br",{}),"Your workflows. Your tools. One conversation."]}),e&&!l?i.jsxs("div",{className:"code-workflow-welcome",children:[i.jsx(ae,{name:"playCircle",size:21}),i.jsxs("div",{children:[i.jsx("strong",{children:e.name}),i.jsx("p",{children:e.description||"Run this workflow with its registered inputs."})]}),i.jsx("button",{onClick:a,children:"Configure inputs"}),i.jsx("button",{onClick:u,disabled:n||!d,children:"Run workflow"})]}):i.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(f=>i.jsxs("button",{onClick:()=>s(f.prompt),disabled:n,children:[i.jsx(ae,{name:f.icon,size:18}),i.jsxs("span",{children:[i.jsx("strong",{children:f.title}),i.jsx("small",{children:f.detail})]}),i.jsx(ae,{name:"chevronRight",size:13})]},f.title))}),i.jsx("p",{className:"code-welcome-hint",children:n?"Discovering your workflows…":e?i.jsxs(i.Fragment,{children:["Using ",i.jsx("strong",{children:e.name})," · Change workflows above"]}):d?"Register a workflow with AbstractGateway to get started.":"Connect your gateway to get started."})]})}class ek extends wt.Component{constructor(){super(...arguments);yn(this,"state",{error:""})}static getDerivedStateFromError(s){return{error:s.message}}render(){return this.state.error?i.jsxs("div",{className:"code-crash",role:"alert",children:[i.jsx("h1",{children:"Something interrupted this view."}),i.jsx("p",{children:this.state.error}),i.jsx("p",{children:"Your runs are stored by the gateway."}),i.jsx("button",{onClick:()=>window.location.reload(),children:"Reload AbstractCode"})]}):this.props.children}}function Oo(){try{const e=window.visualViewport,n=typeof(e==null?void 0:e.height)=="number"&&Number.isFinite(e.height)?e.height:window.innerHeight;document.documentElement.style.setProperty("--vh",`${Math.max(1,n)*.01}px`)}catch{}}const Fh="__abstractcode_web_vh_listener_v1";var zh,Wh;globalThis[Fh]||(globalThis[Fh]=!0,Oo(),window.addEventListener("resize",Oo),(zh=window.visualViewport)==null||zh.addEventListener("resize",Oo),(Wh=window.visualViewport)==null||Wh.addEventListener("scroll",Oo));"serviceWorker"in navigator&&window.addEventListener("load",()=>{navigator.serviceWorker.register("sw.js").catch(()=>{})});Vg.createRoot(document.getElementById("root")).render(i.jsx(wt.StrictMode,{children:i.jsx(ek,{children:i.jsx(Xb,{})})}));