@abstractframework/code 0.8.0 → 0.9.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.
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
var zg=Object.defineProperty;var Wg=(e,t,s)=>t in e?zg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var mn=(e,t,s)=>Wg(e,typeof t!="symbol"?t+"":t,s);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))o(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"&&o(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 o(l){if(l.ep)return;l.ep=!0;const u=s(l);fetch(l.href,u)}})();function ep(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Lc={exports:{}},_o={},Pc={exports:{}},Be={};/**
|
|
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 Qf;function Ug(){if(Qf)return Be;Qf=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),o=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"),v=Symbol.iterator;function x(C){return C===null||typeof C!="object"?null:(C=v&&C[v]||C["@@iterator"],typeof C=="function"?C:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,E={};function S(C,B,F){this.props=C,this.context=B,this.refs=E,this.updater=F||b}S.prototype.isReactComponent={},S.prototype.setState=function(C,B){if(typeof C!="object"&&typeof C!="function"&&C!=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,C,B,"setState")},S.prototype.forceUpdate=function(C){this.updater.enqueueForceUpdate(this,C,"forceUpdate")};function T(){}T.prototype=S.prototype;function A(C,B,F){this.props=C,this.context=B,this.refs=E,this.updater=F||b}var $=A.prototype=new T;$.constructor=A,k($,S.prototype),$.isPureReactComponent=!0;var j=Array.isArray,P=Object.prototype.hasOwnProperty,V={current:null},H={key:!0,ref:!0,__self:!0,__source:!0};function L(C,B,F){var W,oe={},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)&&(oe[W]=B[W]);var Z=arguments.length-2;if(Z===1)oe.children=F;else if(1<Z){for(var Ce=Array(Z),Ue=0;Ue<Z;Ue++)Ce[Ue]=arguments[Ue+2];oe.children=Ce}if(C&&C.defaultProps)for(W in Z=C.defaultProps,Z)oe[W]===void 0&&(oe[W]=Z[W]);return{$$typeof:e,type:C,key:le,ref:he,props:oe,_owner:V.current}}function de(C,B){return{$$typeof:e,type:C.type,key:B,ref:C.ref,props:C.props,_owner:C._owner}}function re(C){return typeof C=="object"&&C!==null&&C.$$typeof===e}function Q(C){var B={"=":"=0",":":"=2"};return"$"+C.replace(/[=:]/g,function(F){return B[F]})}var U=/\/+/g;function J(C,B){return typeof C=="object"&&C!==null&&C.key!=null?Q(""+C.key):B.toString(36)}function fe(C,B,F,W,oe){var le=typeof C;(le==="undefined"||le==="boolean")&&(C=null);var he=!1;if(C===null)he=!0;else switch(le){case"string":case"number":he=!0;break;case"object":switch(C.$$typeof){case e:case t:he=!0}}if(he)return he=C,oe=oe(he),C=W===""?"."+J(he,0):W,j(oe)?(F="",C!=null&&(F=C.replace(U,"$&/")+"/"),fe(oe,B,F,"",function(Ue){return Ue})):oe!=null&&(re(oe)&&(oe=de(oe,F+(!oe.key||he&&he.key===oe.key?"":(""+oe.key).replace(U,"$&/")+"/")+C)),B.push(oe)),1;if(he=0,W=W===""?".":W+":",j(C))for(var Z=0;Z<C.length;Z++){le=C[Z];var Ce=W+J(le,Z);he+=fe(le,B,F,Ce,oe)}else if(Ce=x(C),typeof Ce=="function")for(C=Ce.call(C),Z=0;!(le=C.next()).done;)le=le.value,Ce=W+J(le,Z++),he+=fe(le,B,F,Ce,oe);else if(le==="object")throw B=String(C),Error("Objects are not valid as a React child (found: "+(B==="[object Object]"?"object with keys {"+Object.keys(C).join(", ")+"}":B)+"). If you meant to render a collection of children, use an array instead.");return he}function ce(C,B,F){if(C==null)return C;var W=[],oe=0;return fe(C,W,"","",function(le){return B.call(F,le,oe++)}),W}function ye(C){if(C._status===-1){var B=C._result;B=B(),B.then(function(F){(C._status===0||C._status===-1)&&(C._status=1,C._result=F)},function(F){(C._status===0||C._status===-1)&&(C._status=2,C._result=F)}),C._status===-1&&(C._status=0,C._result=B)}if(C._status===1)return C._result.default;throw C._result}var ve={current:null},q={transition:null},ae={ReactCurrentDispatcher:ve,ReactCurrentBatchConfig:q,ReactCurrentOwner:V};function G(){throw Error("act(...) is not supported in production builds of React.")}return Be.Children={map:ce,forEach:function(C,B,F){ce(C,function(){B.apply(this,arguments)},F)},count:function(C){var B=0;return ce(C,function(){B++}),B},toArray:function(C){return ce(C,function(B){return B})||[]},only:function(C){if(!re(C))throw Error("React.Children.only expected to receive a single React element child.");return C}},Be.Component=S,Be.Fragment=s,Be.Profiler=l,Be.PureComponent=A,Be.StrictMode=o,Be.Suspense=h,Be.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ae,Be.act=G,Be.cloneElement=function(C,B,F){if(C==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+C+".");var W=k({},C.props),oe=C.key,le=C.ref,he=C._owner;if(B!=null){if(B.ref!==void 0&&(le=B.ref,he=V.current),B.key!==void 0&&(oe=""+B.key),C.type&&C.type.defaultProps)var Z=C.type.defaultProps;for(Ce in B)P.call(B,Ce)&&!H.hasOwnProperty(Ce)&&(W[Ce]=B[Ce]===void 0&&Z!==void 0?Z[Ce]:B[Ce])}var Ce=arguments.length-2;if(Ce===1)W.children=F;else if(1<Ce){Z=Array(Ce);for(var Ue=0;Ue<Ce;Ue++)Z[Ue]=arguments[Ue+2];W.children=Z}return{$$typeof:e,type:C.type,key:oe,ref:le,props:W,_owner:he}},Be.createContext=function(C){return C={$$typeof:d,_currentValue:C,_currentValue2:C,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},C.Provider={$$typeof:u,_context:C},C.Consumer=C},Be.createElement=L,Be.createFactory=function(C){var B=L.bind(null,C);return B.type=C,B},Be.createRef=function(){return{current:null}},Be.forwardRef=function(C){return{$$typeof:f,render:C}},Be.isValidElement=re,Be.lazy=function(C){return{$$typeof:y,_payload:{_status:-1,_result:C},_init:ye}},Be.memo=function(C,B){return{$$typeof:g,type:C,compare:B===void 0?null:B}},Be.startTransition=function(C){var B=q.transition;q.transition={};try{C()}finally{q.transition=B}},Be.unstable_act=G,Be.useCallback=function(C,B){return ve.current.useCallback(C,B)},Be.useContext=function(C){return ve.current.useContext(C)},Be.useDebugValue=function(){},Be.useDeferredValue=function(C){return ve.current.useDeferredValue(C)},Be.useEffect=function(C,B){return ve.current.useEffect(C,B)},Be.useId=function(){return ve.current.useId()},Be.useImperativeHandle=function(C,B,F){return ve.current.useImperativeHandle(C,B,F)},Be.useInsertionEffect=function(C,B){return ve.current.useInsertionEffect(C,B)},Be.useLayoutEffect=function(C,B){return ve.current.useLayoutEffect(C,B)},Be.useMemo=function(C,B){return ve.current.useMemo(C,B)},Be.useReducer=function(C,B,F){return ve.current.useReducer(C,B,F)},Be.useRef=function(C){return ve.current.useRef(C)},Be.useState=function(C){return ve.current.useState(C)},Be.useSyncExternalStore=function(C,B,F){return ve.current.useSyncExternalStore(C,B,F)},Be.useTransition=function(){return ve.current.useTransition()},Be.version="18.3.1",Be}var Yf;function xu(){return Yf||(Yf=1,Pc.exports=Ug()),Pc.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 Xf;function Bg(){if(Xf)return _o;Xf=1;var e=xu(),t=Symbol.for("react.element"),s=Symbol.for("react.fragment"),o=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,v={},x=null,b=null;g!==void 0&&(x=""+g),h.key!==void 0&&(x=""+h.key),h.ref!==void 0&&(b=h.ref);for(y in h)o.call(h,y)&&!u.hasOwnProperty(y)&&(v[y]=h[y]);if(f&&f.defaultProps)for(y in h=f.defaultProps,h)v[y]===void 0&&(v[y]=h[y]);return{$$typeof:t,type:f,key:x,ref:b,props:v,_owner:l.current}}return _o.Fragment=s,_o.jsx=d,_o.jsxs=d,_o}var Zf;function Vg(){return Zf||(Zf=1,Lc.exports=Bg()),Lc.exports}var i=Vg(),w=xu();const gt=ep(w);var Wa={},Oc={exports:{}},en={},Dc={exports:{}},Fc={};/**
|
|
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 qf;function Gg(){return qf||(qf=1,(function(e){function t(q,ae){var G=q.length;q.push(ae);e:for(;0<G;){var C=G-1>>>1,B=q[C];if(0<l(B,ae))q[C]=ae,q[G]=B,G=C;else break e}}function s(q){return q.length===0?null:q[0]}function o(q){if(q.length===0)return null;var ae=q[0],G=q.pop();if(G!==ae){q[0]=G;e:for(var C=0,B=q.length,F=B>>>1;C<F;){var W=2*(C+1)-1,oe=q[W],le=W+1,he=q[le];if(0>l(oe,G))le<B&&0>l(he,oe)?(q[C]=he,q[le]=G,C=le):(q[C]=oe,q[W]=G,C=W);else if(le<B&&0>l(he,G))q[C]=he,q[le]=G,C=le;else break e}}return ae}function l(q,ae){var G=q.sortIndex-ae.sortIndex;return G!==0?G:q.id-ae.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,v=null,x=3,b=!1,k=!1,E=!1,S=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 ae=s(g);ae!==null;){if(ae.callback===null)o(g);else if(ae.startTime<=q)o(g),ae.sortIndex=ae.expirationTime,t(h,ae);else break;ae=s(g)}}function j(q){if(E=!1,$(q),!k)if(s(h)!==null)k=!0,ye(P);else{var ae=s(g);ae!==null&&ve(j,ae.startTime-q)}}function P(q,ae){k=!1,E&&(E=!1,T(L),L=-1),b=!0;var G=x;try{for($(ae),v=s(h);v!==null&&(!(v.expirationTime>ae)||q&&!Q());){var C=v.callback;if(typeof C=="function"){v.callback=null,x=v.priorityLevel;var B=C(v.expirationTime<=ae);ae=e.unstable_now(),typeof B=="function"?v.callback=B:v===s(h)&&o(h),$(ae)}else o(h);v=s(h)}if(v!==null)var F=!0;else{var W=s(g);W!==null&&ve(j,W.startTime-ae),F=!1}return F}finally{v=null,x=G,b=!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 ae=!0;try{ae=H(!0,q)}finally{ae?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(){S(U,0)};function ye(q){H=q,V||(V=!0,J())}function ve(q,ae){L=S(function(){q(e.unstable_now())},ae)}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(){k||b||(k=!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 x},e.unstable_getFirstCallbackNode=function(){return s(h)},e.unstable_next=function(q){switch(x){case 1:case 2:case 3:var ae=3;break;default:ae=x}var G=x;x=ae;try{return q()}finally{x=G}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(q,ae){switch(q){case 1:case 2:case 3:case 4:case 5:break;default:q=3}var G=x;x=q;try{return ae()}finally{x=G}},e.unstable_scheduleCallback=function(q,ae,G){var C=e.unstable_now();switch(typeof G=="object"&&G!==null?(G=G.delay,G=typeof G=="number"&&0<G?C+G:C):G=C,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:ae,priorityLevel:q,startTime:G,expirationTime:B,sortIndex:-1},G>C?(q.sortIndex=G,t(g,q),s(h)===null&&q===s(g)&&(E?(T(L),L=-1):E=!0,ve(j,G-C))):(q.sortIndex=B,t(h,q),k||b||(k=!0,ye(P))),q},e.unstable_shouldYield=Q,e.unstable_wrapCallback=function(q){var ae=x;return function(){var G=x;x=ae;try{return q.apply(this,arguments)}finally{x=G}}}})(Fc)),Fc}var eh;function Hg(){return eh||(eh=1,Dc.exports=Gg()),Dc.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 th;function Kg(){if(th)return en;th=1;var e=xu(),t=Hg();function s(n){for(var r="https://reactjs.org/docs/error-decoder.html?invariant="+n,a=1;a<arguments.length;a++)r+="&args[]="+encodeURIComponent(arguments[a]);return"Minified React error #"+n+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var o=new Set,l={};function u(n,r){d(n,r),d(n+"Capture",r)}function d(n,r){for(l[n]=r,n=0;n<r.length;n++)o.add(r[n])}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={},v={};function x(n){return h.call(v,n)?!0:h.call(y,n)?!1:g.test(n)?v[n]=!0:(y[n]=!0,!1)}function b(n,r,a,c){if(a!==null&&a.type===0)return!1;switch(typeof r){case"function":case"symbol":return!0;case"boolean":return c?!1:a!==null?!a.acceptsBooleans:(n=n.toLowerCase().slice(0,5),n!=="data-"&&n!=="aria-");default:return!1}}function k(n,r,a,c){if(r===null||typeof r>"u"||b(n,r,a,c))return!0;if(c)return!1;if(a!==null)switch(a.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 E(n,r,a,c,p,m,_){this.acceptsBooleans=r===2||r===3||r===4,this.attributeName=c,this.attributeNamespace=p,this.mustUseProperty=a,this.propertyName=n,this.type=r,this.sanitizeURL=m,this.removeEmptyString=_}var S={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(n){S[n]=new E(n,0,!1,n,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(n){var r=n[0];S[r]=new E(r,1,!1,n[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(n){S[n]=new E(n,2,!1,n.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(n){S[n]=new E(n,2,!1,n,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(n){S[n]=new E(n,3,!1,n.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(n){S[n]=new E(n,3,!0,n,null,!1,!1)}),["capture","download"].forEach(function(n){S[n]=new E(n,4,!1,n,null,!1,!1)}),["cols","rows","size","span"].forEach(function(n){S[n]=new E(n,6,!1,n,null,!1,!1)}),["rowSpan","start"].forEach(function(n){S[n]=new E(n,5,!1,n.toLowerCase(),null,!1,!1)});var T=/[\-:]([a-z])/g;function A(n){return n[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(n){var r=n.replace(T,A);S[r]=new E(r,1,!1,n,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(n){var r=n.replace(T,A);S[r]=new E(r,1,!1,n,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(n){var r=n.replace(T,A);S[r]=new E(r,1,!1,n,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(n){S[n]=new E(n,1,!1,n.toLowerCase(),null,!1,!1)}),S.xlinkHref=new E("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(n){S[n]=new E(n,1,!1,n.toLowerCase(),null,!0,!0)});function $(n,r,a,c){var p=S.hasOwnProperty(r)?S[r]:null;(p!==null?p.type!==0:c||!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(k(r,a,p,c)&&(a=null),c||p===null?x(r)&&(a===null?n.removeAttribute(r):n.setAttribute(r,""+a)):p.mustUseProperty?n[p.propertyName]=a===null?p.type===3?!1:"":a:(r=p.attributeName,c=p.attributeNamespace,a===null?n.removeAttribute(r):(p=p.type,a=p===3||p===4&&a===!0?"":""+a,c?n.setAttributeNS(c,r,a):n.setAttribute(r,a))))}var j=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 ae(n){return n===null||typeof n!="object"?null:(n=q&&n[q]||n["@@iterator"],typeof n=="function"?n:null)}var G=Object.assign,C;function B(n){if(C===void 0)try{throw Error()}catch(a){var r=a.stack.trim().match(/\n( *(at )?)/);C=r&&r[1]||""}return`
|
|
34
|
-
`+C+n}var F=!1;function W(n,r){if(!n||F)return"";F=!0;var a=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(n,[],r)}else{try{r.call()}catch(z){c=z}n.call(r.prototype)}else{try{throw Error()}catch(z){c=z}n()}}catch(z){if(z&&c&&typeof z.stack=="string"){for(var p=z.stack.split(`
|
|
35
|
-
`),m=c.stack.split(`
|
|
36
|
-
`),_=p.length-1,N=m.length-1;1<=_&&0<=N&&p[_]!==m[N];)N--;for(;1<=_&&0<=N;_--,N--)if(p[_]!==m[N]){if(_!==1||N!==1)do if(_--,N--,0>N||p[_]!==m[N]){var R=`
|
|
37
|
-
`+p[_].replace(" at new "," at ");return n.displayName&&R.includes("<anonymous>")&&(R=R.replace("<anonymous>",n.displayName)),R}while(1<=_&&0<=N);break}}}finally{F=!1,Error.prepareStackTrace=a}return(n=n?n.displayName||n.name:"")?B(n):""}function oe(n){switch(n.tag){case 5:return B(n.type);case 16:return B("Lazy");case 13:return B("Suspense");case 19:return B("SuspenseList");case 0:case 2:case 15:return n=W(n.type,!1),n;case 11:return n=W(n.type.render,!1),n;case 1:return n=W(n.type,!0),n;default:return""}}function le(n){if(n==null)return null;if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case 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 n=="object")switch(n.$$typeof){case Q:return(n.displayName||"Context")+".Consumer";case re:return(n._context.displayName||"Context")+".Provider";case U:var r=n.render;return n=n.displayName,n||(n=r.displayName||r.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case ce:return r=n.displayName||null,r!==null?r:le(n.type)||"Memo";case ye:r=n._payload,n=n._init;try{return le(n(r))}catch{}}return null}function he(n){var r=n.type;switch(n.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 n=r.render,n=n.displayName||n.name||"",r.displayName||(n!==""?"ForwardRef("+n+")":"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 Z(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function Ce(n){var r=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function Ue(n){var r=Ce(n)?"checked":"value",a=Object.getOwnPropertyDescriptor(n.constructor.prototype,r),c=""+n[r];if(!n.hasOwnProperty(r)&&typeof a<"u"&&typeof a.get=="function"&&typeof a.set=="function"){var p=a.get,m=a.set;return Object.defineProperty(n,r,{configurable:!0,get:function(){return p.call(this)},set:function(_){c=""+_,m.call(this,_)}}),Object.defineProperty(n,r,{enumerable:a.enumerable}),{getValue:function(){return c},setValue:function(_){c=""+_},stopTracking:function(){n._valueTracker=null,delete n[r]}}}}function ke(n){n._valueTracker||(n._valueTracker=Ue(n))}function X(n){if(!n)return!1;var r=n._valueTracker;if(!r)return!0;var a=r.getValue(),c="";return n&&(c=Ce(n)?n.checked?"true":"false":n.value),n=c,n!==a?(r.setValue(n),!0):!1}function ee(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}function pe(n,r){var a=r.checked;return G({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:a??n._wrapperState.initialChecked})}function De(n,r){var a=r.defaultValue==null?"":r.defaultValue,c=r.checked!=null?r.checked:r.defaultChecked;a=Z(r.value!=null?r.value:a),n._wrapperState={initialChecked:c,initialValue:a,controlled:r.type==="checkbox"||r.type==="radio"?r.checked!=null:r.value!=null}}function we(n,r){r=r.checked,r!=null&&$(n,"checked",r,!1)}function Pe(n,r){we(n,r);var a=Z(r.value),c=r.type;if(a!=null)c==="number"?(a===0&&n.value===""||n.value!=a)&&(n.value=""+a):n.value!==""+a&&(n.value=""+a);else if(c==="submit"||c==="reset"){n.removeAttribute("value");return}r.hasOwnProperty("value")?rt(n,r.type,a):r.hasOwnProperty("defaultValue")&&rt(n,r.type,Z(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(n.defaultChecked=!!r.defaultChecked)}function Ve(n,r,a){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=""+n._wrapperState.initialValue,a||r===n.value||(n.value=r),n.defaultValue=r}a=n.name,a!==""&&(n.name=""),n.defaultChecked=!!n._wrapperState.initialChecked,a!==""&&(n.name=a)}function rt(n,r,a){(r!=="number"||ee(n.ownerDocument)!==n)&&(a==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+a&&(n.defaultValue=""+a))}var K=Array.isArray;function me(n,r,a,c){if(n=n.options,r){r={};for(var p=0;p<a.length;p++)r["$"+a[p]]=!0;for(a=0;a<n.length;a++)p=r.hasOwnProperty("$"+n[a].value),n[a].selected!==p&&(n[a].selected=p),p&&c&&(n[a].defaultSelected=!0)}else{for(a=""+Z(a),r=null,p=0;p<n.length;p++){if(n[p].value===a){n[p].selected=!0,c&&(n[p].defaultSelected=!0);return}r!==null||n[p].disabled||(r=n[p])}r!==null&&(r.selected=!0)}}function Fe(n,r){if(r.dangerouslySetInnerHTML!=null)throw Error(s(91));return G({},r,{value:void 0,defaultValue:void 0,children:""+n._wrapperState.initialValue})}function Ke(n,r){var a=r.value;if(a==null){if(a=r.children,r=r.defaultValue,a!=null){if(r!=null)throw Error(s(92));if(K(a)){if(1<a.length)throw Error(s(93));a=a[0]}r=a}r==null&&(r=""),a=r}n._wrapperState={initialValue:Z(a)}}function He(n,r){var a=Z(r.value),c=Z(r.defaultValue);a!=null&&(a=""+a,a!==n.value&&(n.value=a),r.defaultValue==null&&n.defaultValue!==a&&(n.defaultValue=a)),c!=null&&(n.defaultValue=""+c)}function or(n){var r=n.textContent;r===n._wrapperState.initialValue&&r!==""&&r!==null&&(n.value=r)}function Tt(n){switch(n){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function An(n,r){return n==null||n==="http://www.w3.org/1999/xhtml"?Tt(r):n==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":n}var Tn,Rn=(function(n){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(r,a,c,p){MSApp.execUnsafeLocalFunction(function(){return n(r,a,c,p)})}:n})(function(n,r){if(n.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in n)n.innerHTML=r;else{for(Tn=Tn||document.createElement("div"),Tn.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=Tn.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;r.firstChild;)n.appendChild(r.firstChild)}});function ar(n,r){if(r){var a=n.firstChild;if(a&&a===n.lastChild&&a.nodeType===3){a.nodeValue=r;return}}n.textContent=r}var Er={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},cl=["Webkit","ms","Moz","O"];Object.keys(Er).forEach(function(n){cl.forEach(function(r){r=r+n.charAt(0).toUpperCase()+n.substring(1),Er[r]=Er[n]})});function Ri(n,r,a){return r==null||typeof r=="boolean"||r===""?"":a||typeof r!="number"||r===0||Er.hasOwnProperty(n)&&Er[n]?(""+r).trim():r+"px"}function Ps(n,r){n=n.style;for(var a in r)if(r.hasOwnProperty(a)){var c=a.indexOf("--")===0,p=Ri(a,r[a],c);a==="float"&&(a="cssFloat"),c?n.setProperty(a,p):n[a]=p}}var ul=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 gn(n,r){if(r){if(ul[n]&&(r.children!=null||r.dangerouslySetInnerHTML!=null))throw Error(s(137,n));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 ns(n,r){if(n.indexOf("-")===-1)return typeof r.is=="string";switch(n){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var rs=null;function Ii(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var Os=null,zt=null,Bn=null;function lr(n){if(n=so(n)){if(typeof Os!="function")throw Error(s(280));var r=n.stateNode;r&&(r=na(r),Os(n.stateNode,n.type,r))}}function Fo(n){zt?Bn?Bn.push(n):Bn=[n]:zt=n}function Mi(){if(zt){var n=zt,r=Bn;if(Bn=zt=null,lr(n),r)for(n=0;n<r.length;n++)lr(r[n])}}function cr(n,r){return n(r)}function Ht(){}var ss=!1;function Li(n,r,a){if(ss)return n(r,a);ss=!0;try{return cr(n,r,a)}finally{ss=!1,(zt!==null||Bn!==null)&&(Ht(),Mi())}}function $r(n,r){var a=n.stateNode;if(a===null)return null;var c=na(a);if(c===null)return null;a=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)||(n=n.type,c=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!c;break e;default:n=!1}if(n)return null;if(a&&typeof a!="function")throw Error(s(231,r,typeof a));return a}var Vn=!1;if(f)try{var ur={};Object.defineProperty(ur,"passive",{get:function(){Vn=!0}}),window.addEventListener("test",ur,ur),window.removeEventListener("test",ur,ur)}catch{Vn=!1}function is(n,r,a,c,p,m,_,N,R){var z=Array.prototype.slice.call(arguments,3);try{r.apply(a,z)}catch(ne){this.onError(ne)}}var In=!1,Ar=null,os=!1,as=null,Pi={onError:function(n){In=!0,Ar=n}};function dl(n,r,a,c,p,m,_,N,R){In=!1,Ar=null,is.apply(Pi,arguments)}function zo(n,r,a,c,p,m,_,N,R){if(dl.apply(this,arguments),In){if(In){var z=Ar;In=!1,Ar=null}else throw Error(s(198));os||(os=!0,as=z)}}function an(n){var r=n,a=n;if(n.alternate)for(;r.return;)r=r.return;else{n=r;do r=n,(r.flags&4098)!==0&&(a=r.return),n=r.return;while(n)}return r.tag===3?a:null}function Wo(n){if(n.tag===13){var r=n.memoizedState;if(r===null&&(n=n.alternate,n!==null&&(r=n.memoizedState)),r!==null)return r.dehydrated}return null}function Gn(n){if(an(n)!==n)throw Error(s(188))}function Hn(n){var r=n.alternate;if(!r){if(r=an(n),r===null)throw Error(s(188));return r!==n?null:n}for(var a=n,c=r;;){var p=a.return;if(p===null)break;var m=p.alternate;if(m===null){if(c=p.return,c!==null){a=c;continue}break}if(p.child===m.child){for(m=p.child;m;){if(m===a)return Gn(p),n;if(m===c)return Gn(p),r;m=m.sibling}throw Error(s(188))}if(a.return!==c.return)a=p,c=m;else{for(var _=!1,N=p.child;N;){if(N===a){_=!0,a=p,c=m;break}if(N===c){_=!0,c=p,a=m;break}N=N.sibling}if(!_){for(N=m.child;N;){if(N===a){_=!0,a=m,c=p;break}if(N===c){_=!0,c=m,a=p;break}N=N.sibling}if(!_)throw Error(s(189))}}if(a.alternate!==c)throw Error(s(190))}if(a.tag!==3)throw Error(s(188));return a.stateNode.current===a?n:r}function Ds(n){return n=Hn(n),n!==null?yn(n):null}function yn(n){if(n.tag===5||n.tag===6)return n;for(n=n.child;n!==null;){var r=yn(n);if(r!==null)return r;n=n.sibling}return null}var Oi=t.unstable_scheduleCallback,Fs=t.unstable_cancelCallback,zs=t.unstable_shouldYield,Di=t.unstable_requestPaint,lt=t.unstable_now,Fi=t.unstable_getCurrentPriorityLevel,Ws=t.unstable_ImmediatePriority,zi=t.unstable_UserBlockingPriority,ls=t.unstable_NormalPriority,fl=t.unstable_LowPriority,Uo=t.unstable_IdlePriority,wn=null,Le=null;function ln(n){if(Le&&typeof Le.onCommitFiberRoot=="function")try{Le.onCommitFiberRoot(wn,n,void 0,(n.current.flags&128)===128)}catch{}}var Wt=Math.clz32?Math.clz32:Bs,dr=Math.log,Us=Math.LN2;function Bs(n){return n>>>=0,n===0?32:31-(dr(n)/Us|0)|0}var cn=64,cs=4194304;function vn(n){switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return n&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return n}}function us(n,r){var a=n.pendingLanes;if(a===0)return 0;var c=0,p=n.suspendedLanes,m=n.pingedLanes,_=a&268435455;if(_!==0){var N=_&~p;N!==0?c=vn(N):(m&=_,m!==0&&(c=vn(m)))}else _=a&~p,_!==0?c=vn(_):m!==0&&(c=vn(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|=a&16),r=n.entangledLanes,r!==0)for(n=n.entanglements,r&=c;0<r;)a=31-Wt(r),p=1<<a,c|=n[a],r&=~p;return c}function _n(n,r){switch(n){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 Bo(n,r){for(var a=n.suspendedLanes,c=n.pingedLanes,p=n.expirationTimes,m=n.pendingLanes;0<m;){var _=31-Wt(m),N=1<<_,R=p[_];R===-1?((N&a)===0||(N&c)!==0)&&(p[_]=_n(N,r)):R<=r&&(n.expiredLanes|=N),m&=~N}}function un(n){return n=n.pendingLanes&-1073741825,n!==0?n:n&1073741824?1073741824:0}function Wi(){var n=cn;return cn<<=1,(cn&4194240)===0&&(cn=64),n}function Kn(n){for(var r=[],a=0;31>a;a++)r.push(n);return r}function Mn(n,r,a){n.pendingLanes|=r,r!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,r=31-Wt(r),n[r]=a}function Vs(n,r){var a=n.pendingLanes&~r;n.pendingLanes=r,n.suspendedLanes=0,n.pingedLanes=0,n.expiredLanes&=r,n.mutableReadLanes&=r,n.entangledLanes&=r,r=n.entanglements;var c=n.eventTimes;for(n=n.expirationTimes;0<a;){var p=31-Wt(a),m=1<<p;r[p]=0,c[p]=-1,n[p]=-1,a&=~m}}function Ut(n,r){var a=n.entangledLanes|=r;for(n=n.entanglements;a;){var c=31-Wt(a),p=1<<c;p&r|n[c]&r&&(n[c]|=r),a&=~p}}var Qe=0;function Ui(n){return n&=-n,1<n?4<n?(n&268435455)!==0?16:536870912:4:1}var Gs,Bi,Vi,Hs,Tr,pt=!1,Rr=[],ot=null,xn=null,dn=null,fr=new Map,Jn=new Map,Qn=[],Vo="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 Gi(n,r){switch(n){case"focusin":case"focusout":ot=null;break;case"dragenter":case"dragleave":xn=null;break;case"mouseover":case"mouseout":dn=null;break;case"pointerover":case"pointerout":fr.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":Jn.delete(r.pointerId)}}function hr(n,r,a,c,p,m){return n===null||n.nativeEvent!==m?(n={blockedOn:r,domEventName:a,eventSystemFlags:c,nativeEvent:m,targetContainers:[p]},r!==null&&(r=so(r),r!==null&&Bi(r)),n):(n.eventSystemFlags|=c,r=n.targetContainers,p!==null&&r.indexOf(p)===-1&&r.push(p),n)}function hl(n,r,a,c,p){switch(r){case"focusin":return ot=hr(ot,n,r,a,c,p),!0;case"dragenter":return xn=hr(xn,n,r,a,c,p),!0;case"mouseover":return dn=hr(dn,n,r,a,c,p),!0;case"pointerover":var m=p.pointerId;return fr.set(m,hr(fr.get(m)||null,n,r,a,c,p)),!0;case"gotpointercapture":return m=p.pointerId,Jn.set(m,hr(Jn.get(m)||null,n,r,a,c,p)),!0}return!1}function Go(n){var r=ws(n.target);if(r!==null){var a=an(r);if(a!==null){if(r=a.tag,r===13){if(r=Wo(a),r!==null){n.blockedOn=r,Tr(n.priority,function(){Vi(a)});return}}else if(r===3&&a.stateNode.current.memoizedState.isDehydrated){n.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}n.blockedOn=null}function Ks(n){if(n.blockedOn!==null)return!1;for(var r=n.targetContainers;0<r.length;){var a=Qs(n.domEventName,n.eventSystemFlags,r[0],n.nativeEvent);if(a===null){a=n.nativeEvent;var c=new a.constructor(a.type,a);rs=c,a.target.dispatchEvent(c),rs=null}else return r=so(a),r!==null&&Bi(r),n.blockedOn=a,!1;r.shift()}return!0}function Ir(n,r,a){Ks(n)&&a.delete(r)}function ds(){pt=!1,ot!==null&&Ks(ot)&&(ot=null),xn!==null&&Ks(xn)&&(xn=null),dn!==null&&Ks(dn)&&(dn=null),fr.forEach(Ir),Jn.forEach(Ir)}function Mr(n,r){n.blockedOn===r&&(n.blockedOn=null,pt||(pt=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,ds)))}function fs(n){function r(p){return Mr(p,n)}if(0<Rr.length){Mr(Rr[0],n);for(var a=1;a<Rr.length;a++){var c=Rr[a];c.blockedOn===n&&(c.blockedOn=null)}}for(ot!==null&&Mr(ot,n),xn!==null&&Mr(xn,n),dn!==null&&Mr(dn,n),fr.forEach(r),Jn.forEach(r),a=0;a<Qn.length;a++)c=Qn[a],c.blockedOn===n&&(c.blockedOn=null);for(;0<Qn.length&&(a=Qn[0],a.blockedOn===null);)Go(a),a.blockedOn===null&&Qn.shift()}var Yn=j.ReactCurrentBatchConfig,hs=!0;function Ho(n,r,a,c){var p=Qe,m=Yn.transition;Yn.transition=null;try{Qe=1,Js(n,r,a,c)}finally{Qe=p,Yn.transition=m}}function Ko(n,r,a,c){var p=Qe,m=Yn.transition;Yn.transition=null;try{Qe=4,Js(n,r,a,c)}finally{Qe=p,Yn.transition=m}}function Js(n,r,a,c){if(hs){var p=Qs(n,r,a,c);if(p===null)Sl(n,r,c,ps,a),Gi(n,c);else if(hl(p,n,r,a,c))c.stopPropagation();else if(Gi(n,c),r&4&&-1<Vo.indexOf(n)){for(;p!==null;){var m=so(p);if(m!==null&&Gs(m),m=Qs(n,r,a,c),m===null&&Sl(n,r,c,ps,a),m===p)break;p=m}p!==null&&c.stopPropagation()}else Sl(n,r,c,null,a)}}var ps=null;function Qs(n,r,a,c){if(ps=null,n=Ii(c),n=ws(n),n!==null)if(r=an(n),r===null)n=null;else if(a=r.tag,a===13){if(n=Wo(r),n!==null)return n;n=null}else if(a===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;n=null}else r!==n&&(n=null);return ps=n,null}function Hi(n){switch(n){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Fi()){case Ws:return 1;case zi:return 4;case ls:case fl:return 16;case Uo:return 536870912;default:return 16}default:return 16}}var Ln=null,Ys=null,ms=null;function Ki(){if(ms)return ms;var n,r=Ys,a=r.length,c,p="value"in Ln?Ln.value:Ln.textContent,m=p.length;for(n=0;n<a&&r[n]===p[n];n++);var _=a-n;for(c=1;c<=_&&r[a-c]===p[m-c];c++);return ms=p.slice(n,1<c?1-c:void 0)}function gs(n){var r=n.keyCode;return"charCode"in n?(n=n.charCode,n===0&&r===13&&(n=13)):n=r,n===10&&(n=13),32<=n||n===13?n:0}function ys(){return!0}function Ji(){return!1}function Rt(n){function r(a,c,p,m,_){this._reactName=a,this._targetInst=p,this.type=c,this.nativeEvent=m,this.target=_,this.currentTarget=null;for(var N in n)n.hasOwnProperty(N)&&(a=n[N],this[N]=a?a(m):m[N]);return this.isDefaultPrevented=(m.defaultPrevented!=null?m.defaultPrevented:m.returnValue===!1)?ys:Ji,this.isPropagationStopped=Ji,this}return G(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=ys)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=ys)},persist:function(){},isPersistent:ys}),r}var pr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Xs=Rt(pr),Lr=G({},pr,{view:0,detail:0}),Jo=Rt(Lr),Zs,qs,I,Y=G({},Lr,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:pl,button:0,buttons:0,relatedTarget:function(n){return n.relatedTarget===void 0?n.fromElement===n.srcElement?n.toElement:n.fromElement:n.relatedTarget},movementX:function(n){return"movementX"in n?n.movementX:(n!==I&&(I&&n.type==="mousemove"?(Zs=n.screenX-I.screenX,qs=n.screenY-I.screenY):qs=Zs=0,I=n),Zs)},movementY:function(n){return"movementY"in n?n.movementY:qs}}),Te=Rt(Y),ze=G({},Y,{dataTransfer:0}),Oe=Rt(ze),It=G({},Lr,{relatedTarget:0}),Xn=Rt(It),Pr=G({},pr,{animationName:0,elapsedTime:0,pseudoElement:0}),xt=Rt(Pr),Kt=G({},pr,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),Jt=Rt(Kt),mr=G({},pr,{data:0}),Pn=Rt(mr),bm={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},km={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"},jm={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Sm(n){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(n):(n=jm[n])?!!r[n]:!1}function pl(){return Sm}var Nm=G({},Lr,{key:function(n){if(n.key){var r=bm[n.key]||n.key;if(r!=="Unidentified")return r}return n.type==="keypress"?(n=gs(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?km[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:pl,charCode:function(n){return n.type==="keypress"?gs(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?gs(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),Cm=Rt(Nm),Em=G({},Y,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Fu=Rt(Em),$m=G({},Lr,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:pl}),Am=Rt($m),Tm=G({},pr,{propertyName:0,elapsedTime:0,pseudoElement:0}),Rm=Rt(Tm),Im=G({},Y,{deltaX:function(n){return"deltaX"in n?n.deltaX:"wheelDeltaX"in n?-n.wheelDeltaX:0},deltaY:function(n){return"deltaY"in n?n.deltaY:"wheelDeltaY"in n?-n.wheelDeltaY:"wheelDelta"in n?-n.wheelDelta:0},deltaZ:0,deltaMode:0}),Mm=Rt(Im),Lm=[9,13,27,32],ml=f&&"CompositionEvent"in window,Qi=null;f&&"documentMode"in document&&(Qi=document.documentMode);var Pm=f&&"TextEvent"in window&&!Qi,zu=f&&(!ml||Qi&&8<Qi&&11>=Qi),Wu=" ",Uu=!1;function Bu(n,r){switch(n){case"keyup":return Lm.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Vu(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var ei=!1;function Om(n,r){switch(n){case"compositionend":return Vu(r);case"keypress":return r.which!==32?null:(Uu=!0,Wu);case"textInput":return n=r.data,n===Wu&&Uu?null:n;default:return null}}function Dm(n,r){if(ei)return n==="compositionend"||!ml&&Bu(n,r)?(n=Ki(),ms=Ys=Ln=null,ei=!1,n):null;switch(n){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 zu&&r.locale!=="ko"?null:r.data;default:return null}}var Fm={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 Gu(n){var r=n&&n.nodeName&&n.nodeName.toLowerCase();return r==="input"?!!Fm[n.type]:r==="textarea"}function Hu(n,r,a,c){Fo(c),r=qo(r,"onChange"),0<r.length&&(a=new Xs("onChange","change",null,a,c),n.push({event:a,listeners:r}))}var Yi=null,Xi=null;function zm(n){ud(n,0)}function Qo(n){var r=ii(n);if(X(r))return n}function Wm(n,r){if(n==="change")return r}var Ku=!1;if(f){var gl;if(f){var yl="oninput"in document;if(!yl){var Ju=document.createElement("div");Ju.setAttribute("oninput","return;"),yl=typeof Ju.oninput=="function"}gl=yl}else gl=!1;Ku=gl&&(!document.documentMode||9<document.documentMode)}function Qu(){Yi&&(Yi.detachEvent("onpropertychange",Yu),Xi=Yi=null)}function Yu(n){if(n.propertyName==="value"&&Qo(Xi)){var r=[];Hu(r,Xi,n,Ii(n)),Li(zm,r)}}function Um(n,r,a){n==="focusin"?(Qu(),Yi=r,Xi=a,Yi.attachEvent("onpropertychange",Yu)):n==="focusout"&&Qu()}function Bm(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return Qo(Xi)}function Vm(n,r){if(n==="click")return Qo(r)}function Gm(n,r){if(n==="input"||n==="change")return Qo(r)}function Hm(n,r){return n===r&&(n!==0||1/n===1/r)||n!==n&&r!==r}var On=typeof Object.is=="function"?Object.is:Hm;function Zi(n,r){if(On(n,r))return!0;if(typeof n!="object"||n===null||typeof r!="object"||r===null)return!1;var a=Object.keys(n),c=Object.keys(r);if(a.length!==c.length)return!1;for(c=0;c<a.length;c++){var p=a[c];if(!h.call(r,p)||!On(n[p],r[p]))return!1}return!0}function Xu(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function Zu(n,r){var a=Xu(n);n=0;for(var c;a;){if(a.nodeType===3){if(c=n+a.textContent.length,n<=r&&c>=r)return{node:a,offset:r-n};n=c}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Xu(a)}}function qu(n,r){return n&&r?n===r?!0:n&&n.nodeType===3?!1:r&&r.nodeType===3?qu(n,r.parentNode):"contains"in n?n.contains(r):n.compareDocumentPosition?!!(n.compareDocumentPosition(r)&16):!1:!1}function ed(){for(var n=window,r=ee();r instanceof n.HTMLIFrameElement;){try{var a=typeof r.contentWindow.location.href=="string"}catch{a=!1}if(a)n=r.contentWindow;else break;r=ee(n.document)}return r}function wl(n){var r=n&&n.nodeName&&n.nodeName.toLowerCase();return r&&(r==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||r==="textarea"||n.contentEditable==="true")}function Km(n){var r=ed(),a=n.focusedElem,c=n.selectionRange;if(r!==a&&a&&a.ownerDocument&&qu(a.ownerDocument.documentElement,a)){if(c!==null&&wl(a)){if(r=c.start,n=c.end,n===void 0&&(n=r),"selectionStart"in a)a.selectionStart=r,a.selectionEnd=Math.min(n,a.value.length);else if(n=(r=a.ownerDocument||document)&&r.defaultView||window,n.getSelection){n=n.getSelection();var p=a.textContent.length,m=Math.min(c.start,p);c=c.end===void 0?m:Math.min(c.end,p),!n.extend&&m>c&&(p=c,c=m,m=p),p=Zu(a,m);var _=Zu(a,c);p&&_&&(n.rangeCount!==1||n.anchorNode!==p.node||n.anchorOffset!==p.offset||n.focusNode!==_.node||n.focusOffset!==_.offset)&&(r=r.createRange(),r.setStart(p.node,p.offset),n.removeAllRanges(),m>c?(n.addRange(r),n.extend(_.node,_.offset)):(r.setEnd(_.node,_.offset),n.addRange(r)))}}for(r=[],n=a;n=n.parentNode;)n.nodeType===1&&r.push({element:n,left:n.scrollLeft,top:n.scrollTop});for(typeof a.focus=="function"&&a.focus(),a=0;a<r.length;a++)n=r[a],n.element.scrollLeft=n.left,n.element.scrollTop=n.top}}var Jm=f&&"documentMode"in document&&11>=document.documentMode,ti=null,vl=null,qi=null,_l=!1;function td(n,r,a){var c=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;_l||ti==null||ti!==ee(c)||(c=ti,"selectionStart"in c&&wl(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}),qi&&Zi(qi,c)||(qi=c,c=qo(vl,"onSelect"),0<c.length&&(r=new Xs("onSelect","select",null,r,a),n.push({event:r,listeners:c}),r.target=ti)))}function Yo(n,r){var a={};return a[n.toLowerCase()]=r.toLowerCase(),a["Webkit"+n]="webkit"+r,a["Moz"+n]="moz"+r,a}var ni={animationend:Yo("Animation","AnimationEnd"),animationiteration:Yo("Animation","AnimationIteration"),animationstart:Yo("Animation","AnimationStart"),transitionend:Yo("Transition","TransitionEnd")},xl={},nd={};f&&(nd=document.createElement("div").style,"AnimationEvent"in window||(delete ni.animationend.animation,delete ni.animationiteration.animation,delete ni.animationstart.animation),"TransitionEvent"in window||delete ni.transitionend.transition);function Xo(n){if(xl[n])return xl[n];if(!ni[n])return n;var r=ni[n],a;for(a in r)if(r.hasOwnProperty(a)&&a in nd)return xl[n]=r[a];return n}var rd=Xo("animationend"),sd=Xo("animationiteration"),id=Xo("animationstart"),od=Xo("transitionend"),ad=new Map,ld="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 Or(n,r){ad.set(n,r),u(r,[n])}for(var bl=0;bl<ld.length;bl++){var kl=ld[bl],Qm=kl.toLowerCase(),Ym=kl[0].toUpperCase()+kl.slice(1);Or(Qm,"on"+Ym)}Or(rd,"onAnimationEnd"),Or(sd,"onAnimationIteration"),Or(id,"onAnimationStart"),Or("dblclick","onDoubleClick"),Or("focusin","onFocus"),Or("focusout","onBlur"),Or(od,"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 eo="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(" "),Xm=new Set("cancel close invalid load scroll toggle".split(" ").concat(eo));function cd(n,r,a){var c=n.type||"unknown-event";n.currentTarget=a,zo(c,r,void 0,n),n.currentTarget=null}function ud(n,r){r=(r&4)!==0;for(var a=0;a<n.length;a++){var c=n[a],p=c.event;c=c.listeners;e:{var m=void 0;if(r)for(var _=c.length-1;0<=_;_--){var N=c[_],R=N.instance,z=N.currentTarget;if(N=N.listener,R!==m&&p.isPropagationStopped())break e;cd(p,N,z),m=R}else for(_=0;_<c.length;_++){if(N=c[_],R=N.instance,z=N.currentTarget,N=N.listener,R!==m&&p.isPropagationStopped())break e;cd(p,N,z),m=R}}}if(os)throw n=as,os=!1,as=null,n}function st(n,r){var a=r[Tl];a===void 0&&(a=r[Tl]=new Set);var c=n+"__bubble";a.has(c)||(dd(r,n,2,!1),a.add(c))}function jl(n,r,a){var c=0;r&&(c|=4),dd(a,n,c,r)}var Zo="_reactListening"+Math.random().toString(36).slice(2);function to(n){if(!n[Zo]){n[Zo]=!0,o.forEach(function(a){a!=="selectionchange"&&(Xm.has(a)||jl(a,!1,n),jl(a,!0,n))});var r=n.nodeType===9?n:n.ownerDocument;r===null||r[Zo]||(r[Zo]=!0,jl("selectionchange",!1,r))}}function dd(n,r,a,c){switch(Hi(r)){case 1:var p=Ho;break;case 4:p=Ko;break;default:p=Js}a=p.bind(null,r,a,n),p=void 0,!Vn||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(p=!0),c?p!==void 0?n.addEventListener(r,a,{capture:!0,passive:p}):n.addEventListener(r,a,!0):p!==void 0?n.addEventListener(r,a,{passive:p}):n.addEventListener(r,a,!1)}function Sl(n,r,a,c,p){var m=c;if((r&1)===0&&(r&2)===0&&c!==null)e:for(;;){if(c===null)return;var _=c.tag;if(_===3||_===4){var N=c.stateNode.containerInfo;if(N===p||N.nodeType===8&&N.parentNode===p)break;if(_===4)for(_=c.return;_!==null;){var R=_.tag;if((R===3||R===4)&&(R=_.stateNode.containerInfo,R===p||R.nodeType===8&&R.parentNode===p))return;_=_.return}for(;N!==null;){if(_=ws(N),_===null)return;if(R=_.tag,R===5||R===6){c=m=_;continue e}N=N.parentNode}}c=c.return}Li(function(){var z=m,ne=Ii(a),se=[];e:{var te=ad.get(n);if(te!==void 0){var ge=Xs,xe=n;switch(n){case"keypress":if(gs(a)===0)break e;case"keydown":case"keyup":ge=Cm;break;case"focusin":xe="focus",ge=Xn;break;case"focusout":xe="blur",ge=Xn;break;case"beforeblur":case"afterblur":ge=Xn;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ge=Te;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ge=Oe;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ge=Am;break;case rd:case sd:case id:ge=xt;break;case od:ge=Rm;break;case"scroll":ge=Jo;break;case"wheel":ge=Mm;break;case"copy":case"cut":case"paste":ge=Jt;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ge=Fu}var be=(r&4)!==0,mt=!be&&n==="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=$r(M,O),ue!=null&&be.push(no(M,ue,D)))),mt)break;M=M.return}0<be.length&&(te=new ge(te,xe,null,a,ne),se.push({event:te,listeners:be}))}}if((r&7)===0){e:{if(te=n==="mouseover"||n==="pointerover",ge=n==="mouseout"||n==="pointerout",te&&a!==rs&&(xe=a.relatedTarget||a.fromElement)&&(ws(xe)||xe[gr]))break e;if((ge||te)&&(te=ne.window===ne?ne:(te=ne.ownerDocument)?te.defaultView||te.parentWindow:window,ge?(xe=a.relatedTarget||a.toElement,ge=z,xe=xe?ws(xe):null,xe!==null&&(mt=an(xe),xe!==mt||xe.tag!==5&&xe.tag!==6)&&(xe=null)):(ge=null,xe=z),ge!==xe)){if(be=Te,ue="onMouseLeave",O="onMouseEnter",M="mouse",(n==="pointerout"||n==="pointerover")&&(be=Fu,ue="onPointerLeave",O="onPointerEnter",M="pointer"),mt=ge==null?te:ii(ge),D=xe==null?te:ii(xe),te=new be(ue,M+"leave",ge,a,ne),te.target=mt,te.relatedTarget=D,ue=null,ws(ne)===z&&(be=new be(O,M+"enter",xe,a,ne),be.target=D,be.relatedTarget=mt,ue=be),mt=ue,ge&&xe)t:{for(be=ge,O=xe,M=0,D=be;D;D=ri(D))M++;for(D=0,ue=O;ue;ue=ri(ue))D++;for(;0<M-D;)be=ri(be),M--;for(;0<D-M;)O=ri(O),D--;for(;M--;){if(be===O||O!==null&&be===O.alternate)break t;be=ri(be),O=ri(O)}be=null}else be=null;ge!==null&&fd(se,te,ge,be,!1),xe!==null&&mt!==null&&fd(se,mt,xe,be,!0)}}e:{if(te=z?ii(z):window,ge=te.nodeName&&te.nodeName.toLowerCase(),ge==="select"||ge==="input"&&te.type==="file")var je=Wm;else if(Gu(te))if(Ku)je=Gm;else{je=Bm;var Ee=Um}else(ge=te.nodeName)&&ge.toLowerCase()==="input"&&(te.type==="checkbox"||te.type==="radio")&&(je=Vm);if(je&&(je=je(n,z))){Hu(se,je,a,ne);break e}Ee&&Ee(n,te,z),n==="focusout"&&(Ee=te._wrapperState)&&Ee.controlled&&te.type==="number"&&rt(te,"number",te.value)}switch(Ee=z?ii(z):window,n){case"focusin":(Gu(Ee)||Ee.contentEditable==="true")&&(ti=Ee,vl=z,qi=null);break;case"focusout":qi=vl=ti=null;break;case"mousedown":_l=!0;break;case"contextmenu":case"mouseup":case"dragend":_l=!1,td(se,a,ne);break;case"selectionchange":if(Jm)break;case"keydown":case"keyup":td(se,a,ne)}var $e;if(ml)e:{switch(n){case"compositionstart":var Ie="onCompositionStart";break e;case"compositionend":Ie="onCompositionEnd";break e;case"compositionupdate":Ie="onCompositionUpdate";break e}Ie=void 0}else ei?Bu(n,a)&&(Ie="onCompositionEnd"):n==="keydown"&&a.keyCode===229&&(Ie="onCompositionStart");Ie&&(zu&&a.locale!=="ko"&&(ei||Ie!=="onCompositionStart"?Ie==="onCompositionEnd"&&ei&&($e=Ki()):(Ln=ne,Ys="value"in Ln?Ln.value:Ln.textContent,ei=!0)),Ee=qo(z,Ie),0<Ee.length&&(Ie=new Pn(Ie,n,null,a,ne),se.push({event:Ie,listeners:Ee}),$e?Ie.data=$e:($e=Vu(a),$e!==null&&(Ie.data=$e)))),($e=Pm?Om(n,a):Dm(n,a))&&(z=qo(z,"onBeforeInput"),0<z.length&&(ne=new Pn("onBeforeInput","beforeinput",null,a,ne),se.push({event:ne,listeners:z}),ne.data=$e))}ud(se,r)})}function no(n,r,a){return{instance:n,listener:r,currentTarget:a}}function qo(n,r){for(var a=r+"Capture",c=[];n!==null;){var p=n,m=p.stateNode;p.tag===5&&m!==null&&(p=m,m=$r(n,a),m!=null&&c.unshift(no(n,m,p)),m=$r(n,r),m!=null&&c.push(no(n,m,p))),n=n.return}return c}function ri(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5);return n||null}function fd(n,r,a,c,p){for(var m=r._reactName,_=[];a!==null&&a!==c;){var N=a,R=N.alternate,z=N.stateNode;if(R!==null&&R===c)break;N.tag===5&&z!==null&&(N=z,p?(R=$r(a,m),R!=null&&_.unshift(no(a,R,N))):p||(R=$r(a,m),R!=null&&_.push(no(a,R,N)))),a=a.return}_.length!==0&&n.push({event:r,listeners:_})}var Zm=/\r\n?/g,qm=/\u0000|\uFFFD/g;function hd(n){return(typeof n=="string"?n:""+n).replace(Zm,`
|
|
38
|
-
`).replace(qm,"")}function ea(n,r,a){if(r=hd(r),hd(n)!==r&&a)throw Error(s(425))}function ta(){}var Nl=null,Cl=null;function El(n,r){return n==="textarea"||n==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var $l=typeof setTimeout=="function"?setTimeout:void 0,eg=typeof clearTimeout=="function"?clearTimeout:void 0,pd=typeof Promise=="function"?Promise:void 0,tg=typeof queueMicrotask=="function"?queueMicrotask:typeof pd<"u"?function(n){return pd.resolve(null).then(n).catch(ng)}:$l;function ng(n){setTimeout(function(){throw n})}function Al(n,r){var a=r,c=0;do{var p=a.nextSibling;if(n.removeChild(a),p&&p.nodeType===8)if(a=p.data,a==="/$"){if(c===0){n.removeChild(p),fs(r);return}c--}else a!=="$"&&a!=="$?"&&a!=="$!"||c++;a=p}while(a);fs(r)}function Dr(n){for(;n!=null;n=n.nextSibling){var r=n.nodeType;if(r===1||r===3)break;if(r===8){if(r=n.data,r==="$"||r==="$!"||r==="$?")break;if(r==="/$")return null}}return n}function md(n){n=n.previousSibling;for(var r=0;n;){if(n.nodeType===8){var a=n.data;if(a==="$"||a==="$!"||a==="$?"){if(r===0)return n;r--}else a==="/$"&&r++}n=n.previousSibling}return null}var si=Math.random().toString(36).slice(2),Zn="__reactFiber$"+si,ro="__reactProps$"+si,gr="__reactContainer$"+si,Tl="__reactEvents$"+si,rg="__reactListeners$"+si,sg="__reactHandles$"+si;function ws(n){var r=n[Zn];if(r)return r;for(var a=n.parentNode;a;){if(r=a[gr]||a[Zn]){if(a=r.alternate,r.child!==null||a!==null&&a.child!==null)for(n=md(n);n!==null;){if(a=n[Zn])return a;n=md(n)}return r}n=a,a=n.parentNode}return null}function so(n){return n=n[Zn]||n[gr],!n||n.tag!==5&&n.tag!==6&&n.tag!==13&&n.tag!==3?null:n}function ii(n){if(n.tag===5||n.tag===6)return n.stateNode;throw Error(s(33))}function na(n){return n[ro]||null}var Rl=[],oi=-1;function Fr(n){return{current:n}}function it(n){0>oi||(n.current=Rl[oi],Rl[oi]=null,oi--)}function nt(n,r){oi++,Rl[oi]=n.current,n.current=r}var zr={},Mt=Fr(zr),Qt=Fr(!1),vs=zr;function ai(n,r){var a=n.type.contextTypes;if(!a)return zr;var c=n.stateNode;if(c&&c.__reactInternalMemoizedUnmaskedChildContext===r)return c.__reactInternalMemoizedMaskedChildContext;var p={},m;for(m in a)p[m]=r[m];return c&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=r,n.__reactInternalMemoizedMaskedChildContext=p),p}function Yt(n){return n=n.childContextTypes,n!=null}function ra(){it(Qt),it(Mt)}function gd(n,r,a){if(Mt.current!==zr)throw Error(s(168));nt(Mt,r),nt(Qt,a)}function yd(n,r,a){var c=n.stateNode;if(r=r.childContextTypes,typeof c.getChildContext!="function")return a;c=c.getChildContext();for(var p in c)if(!(p in r))throw Error(s(108,he(n)||"Unknown",p));return G({},a,c)}function sa(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||zr,vs=Mt.current,nt(Mt,n),nt(Qt,Qt.current),!0}function wd(n,r,a){var c=n.stateNode;if(!c)throw Error(s(169));a?(n=yd(n,r,vs),c.__reactInternalMemoizedMergedChildContext=n,it(Qt),it(Mt),nt(Mt,n)):it(Qt),nt(Qt,a)}var yr=null,ia=!1,Il=!1;function vd(n){yr===null?yr=[n]:yr.push(n)}function ig(n){ia=!0,vd(n)}function Wr(){if(!Il&&yr!==null){Il=!0;var n=0,r=Qe;try{var a=yr;for(Qe=1;n<a.length;n++){var c=a[n];do c=c(!0);while(c!==null)}yr=null,ia=!1}catch(p){throw yr!==null&&(yr=yr.slice(n+1)),Oi(Ws,Wr),p}finally{Qe=r,Il=!1}}return null}var li=[],ci=0,oa=null,aa=0,bn=[],kn=0,_s=null,wr=1,vr="";function xs(n,r){li[ci++]=aa,li[ci++]=oa,oa=n,aa=r}function _d(n,r,a){bn[kn++]=wr,bn[kn++]=vr,bn[kn++]=_s,_s=n;var c=wr;n=vr;var p=32-Wt(c)-1;c&=~(1<<p),a+=1;var m=32-Wt(r)+p;if(30<m){var _=p-p%5;m=(c&(1<<_)-1).toString(32),c>>=_,p-=_,wr=1<<32-Wt(r)+p|a<<p|c,vr=m+n}else wr=1<<m|a<<p|c,vr=n}function Ml(n){n.return!==null&&(xs(n,1),_d(n,1,0))}function Ll(n){for(;n===oa;)oa=li[--ci],li[ci]=null,aa=li[--ci],li[ci]=null;for(;n===_s;)_s=bn[--kn],bn[kn]=null,vr=bn[--kn],bn[kn]=null,wr=bn[--kn],bn[kn]=null}var fn=null,hn=null,at=!1,Dn=null;function xd(n,r){var a=Cn(5,null,null,0);a.elementType="DELETED",a.stateNode=r,a.return=n,r=n.deletions,r===null?(n.deletions=[a],n.flags|=16):r.push(a)}function bd(n,r){switch(n.tag){case 5:var a=n.type;return r=r.nodeType!==1||a.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(n.stateNode=r,fn=n,hn=Dr(r.firstChild),!0):!1;case 6:return r=n.pendingProps===""||r.nodeType!==3?null:r,r!==null?(n.stateNode=r,fn=n,hn=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(a=_s!==null?{id:wr,overflow:vr}:null,n.memoizedState={dehydrated:r,treeContext:a,retryLane:1073741824},a=Cn(18,null,null,0),a.stateNode=r,a.return=n,n.child=a,fn=n,hn=null,!0):!1;default:return!1}}function Pl(n){return(n.mode&1)!==0&&(n.flags&128)===0}function Ol(n){if(at){var r=hn;if(r){var a=r;if(!bd(n,r)){if(Pl(n))throw Error(s(418));r=Dr(a.nextSibling);var c=fn;r&&bd(n,r)?xd(c,a):(n.flags=n.flags&-4097|2,at=!1,fn=n)}}else{if(Pl(n))throw Error(s(418));n.flags=n.flags&-4097|2,at=!1,fn=n}}}function kd(n){for(n=n.return;n!==null&&n.tag!==5&&n.tag!==3&&n.tag!==13;)n=n.return;fn=n}function la(n){if(n!==fn)return!1;if(!at)return kd(n),at=!0,!1;var r;if((r=n.tag!==3)&&!(r=n.tag!==5)&&(r=n.type,r=r!=="head"&&r!=="body"&&!El(n.type,n.memoizedProps)),r&&(r=hn)){if(Pl(n))throw jd(),Error(s(418));for(;r;)xd(n,r),r=Dr(r.nextSibling)}if(kd(n),n.tag===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(s(317));e:{for(n=n.nextSibling,r=0;n;){if(n.nodeType===8){var a=n.data;if(a==="/$"){if(r===0){hn=Dr(n.nextSibling);break e}r--}else a!=="$"&&a!=="$!"&&a!=="$?"||r++}n=n.nextSibling}hn=null}}else hn=fn?Dr(n.stateNode.nextSibling):null;return!0}function jd(){for(var n=hn;n;)n=Dr(n.nextSibling)}function ui(){hn=fn=null,at=!1}function Dl(n){Dn===null?Dn=[n]:Dn.push(n)}var og=j.ReactCurrentBatchConfig;function io(n,r,a){if(n=a.ref,n!==null&&typeof n!="function"&&typeof n!="object"){if(a._owner){if(a=a._owner,a){if(a.tag!==1)throw Error(s(309));var c=a.stateNode}if(!c)throw Error(s(147,n));var p=c,m=""+n;return r!==null&&r.ref!==null&&typeof r.ref=="function"&&r.ref._stringRef===m?r.ref:(r=function(_){var N=p.refs;_===null?delete N[m]:N[m]=_},r._stringRef=m,r)}if(typeof n!="string")throw Error(s(284));if(!a._owner)throw Error(s(290,n))}return n}function ca(n,r){throw n=Object.prototype.toString.call(r),Error(s(31,n==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":n))}function Sd(n){var r=n._init;return r(n._payload)}function Nd(n){function r(O,M){if(n){var D=O.deletions;D===null?(O.deletions=[M],O.flags|=16):D.push(M)}}function a(O,M){if(!n)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=Qr(O,M),O.index=0,O.sibling=null,O}function m(O,M,D){return O.index=D,n?(D=O.alternate,D!==null?(D=D.index,D<M?(O.flags|=2,M):D):(O.flags|=2,M)):(O.flags|=1048576,M)}function _(O){return n&&O.alternate===null&&(O.flags|=2),O}function N(O,M,D,ue){return M===null||M.tag!==6?(M=$c(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&&Sd(je)===M.type)?(ue=p(M,D.props),ue.ref=io(O,M,D),ue.return=O,ue):(ue=Ia(D.type,D.key,D.props,null,O.mode,ue),ue.ref=io(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=Ac(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=$s(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=$c(""+M,O.mode,D),M.return=O,M;if(typeof M=="object"&&M!==null){switch(M.$$typeof){case P:return D=Ia(M.type,M.key,M.props,null,O.mode,D),D.ref=io(O,null,M),D.return=O,D;case V:return M=Ac(M,O.mode,D),M.return=O,M;case ye:var ue=M._init;return se(O,ue(M._payload),D)}if(K(M)||ae(M))return M=$s(M,O.mode,D,null),M.return=O,M;ca(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:N(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)||ae(D))return je!==null?null:ne(O,M,D,ue,null);ca(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,N(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 Ee=ue._init;return ge(O,M,D,Ee(ue._payload),je)}if(K(ue)||ae(ue))return O=O.get(D)||null,ne(M,O,ue,je,null);ca(M,ue)}return null}function xe(O,M,D,ue){for(var je=null,Ee=null,$e=M,Ie=M=0,jt=null;$e!==null&&Ie<D.length;Ie++){$e.index>Ie?(jt=$e,$e=null):jt=$e.sibling;var Ye=te(O,$e,D[Ie],ue);if(Ye===null){$e===null&&($e=jt);break}n&&$e&&Ye.alternate===null&&r(O,$e),M=m(Ye,M,Ie),Ee===null?je=Ye:Ee.sibling=Ye,Ee=Ye,$e=jt}if(Ie===D.length)return a(O,$e),at&&xs(O,Ie),je;if($e===null){for(;Ie<D.length;Ie++)$e=se(O,D[Ie],ue),$e!==null&&(M=m($e,M,Ie),Ee===null?je=$e:Ee.sibling=$e,Ee=$e);return at&&xs(O,Ie),je}for($e=c(O,$e);Ie<D.length;Ie++)jt=ge($e,O,Ie,D[Ie],ue),jt!==null&&(n&&jt.alternate!==null&&$e.delete(jt.key===null?Ie:jt.key),M=m(jt,M,Ie),Ee===null?je=jt:Ee.sibling=jt,Ee=jt);return n&&$e.forEach(function(Yr){return r(O,Yr)}),at&&xs(O,Ie),je}function be(O,M,D,ue){var je=ae(D);if(typeof je!="function")throw Error(s(150));if(D=je.call(D),D==null)throw Error(s(151));for(var Ee=je=null,$e=M,Ie=M=0,jt=null,Ye=D.next();$e!==null&&!Ye.done;Ie++,Ye=D.next()){$e.index>Ie?(jt=$e,$e=null):jt=$e.sibling;var Yr=te(O,$e,Ye.value,ue);if(Yr===null){$e===null&&($e=jt);break}n&&$e&&Yr.alternate===null&&r(O,$e),M=m(Yr,M,Ie),Ee===null?je=Yr:Ee.sibling=Yr,Ee=Yr,$e=jt}if(Ye.done)return a(O,$e),at&&xs(O,Ie),je;if($e===null){for(;!Ye.done;Ie++,Ye=D.next())Ye=se(O,Ye.value,ue),Ye!==null&&(M=m(Ye,M,Ie),Ee===null?je=Ye:Ee.sibling=Ye,Ee=Ye);return at&&xs(O,Ie),je}for($e=c(O,$e);!Ye.done;Ie++,Ye=D.next())Ye=ge($e,O,Ie,Ye.value,ue),Ye!==null&&(n&&Ye.alternate!==null&&$e.delete(Ye.key===null?Ie:Ye.key),M=m(Ye,M,Ie),Ee===null?je=Ye:Ee.sibling=Ye,Ee=Ye);return n&&$e.forEach(function(Fg){return r(O,Fg)}),at&&xs(O,Ie),je}function mt(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,Ee=M;Ee!==null;){if(Ee.key===je){if(je=D.type,je===H){if(Ee.tag===7){a(O,Ee.sibling),M=p(Ee,D.props.children),M.return=O,O=M;break e}}else if(Ee.elementType===je||typeof je=="object"&&je!==null&&je.$$typeof===ye&&Sd(je)===Ee.type){a(O,Ee.sibling),M=p(Ee,D.props),M.ref=io(O,Ee,D),M.return=O,O=M;break e}a(O,Ee);break}else r(O,Ee);Ee=Ee.sibling}D.type===H?(M=$s(D.props.children,O.mode,ue,D.key),M.return=O,O=M):(ue=Ia(D.type,D.key,D.props,null,O.mode,ue),ue.ref=io(O,M,D),ue.return=O,O=ue)}return _(O);case V:e:{for(Ee=D.key;M!==null;){if(M.key===Ee)if(M.tag===4&&M.stateNode.containerInfo===D.containerInfo&&M.stateNode.implementation===D.implementation){a(O,M.sibling),M=p(M,D.children||[]),M.return=O,O=M;break e}else{a(O,M);break}else r(O,M);M=M.sibling}M=Ac(D,O.mode,ue),M.return=O,O=M}return _(O);case ye:return Ee=D._init,mt(O,M,Ee(D._payload),ue)}if(K(D))return xe(O,M,D,ue);if(ae(D))return be(O,M,D,ue);ca(O,D)}return typeof D=="string"&&D!==""||typeof D=="number"?(D=""+D,M!==null&&M.tag===6?(a(O,M.sibling),M=p(M,D),M.return=O,O=M):(a(O,M),M=$c(D,O.mode,ue),M.return=O,O=M),_(O)):a(O,M)}return mt}var di=Nd(!0),Cd=Nd(!1),ua=Fr(null),da=null,fi=null,Fl=null;function zl(){Fl=fi=da=null}function Wl(n){var r=ua.current;it(ua),n._currentValue=r}function Ul(n,r,a){for(;n!==null;){var c=n.alternate;if((n.childLanes&r)!==r?(n.childLanes|=r,c!==null&&(c.childLanes|=r)):c!==null&&(c.childLanes&r)!==r&&(c.childLanes|=r),n===a)break;n=n.return}}function hi(n,r){da=n,Fl=fi=null,n=n.dependencies,n!==null&&n.firstContext!==null&&((n.lanes&r)!==0&&(Xt=!0),n.firstContext=null)}function jn(n){var r=n._currentValue;if(Fl!==n)if(n={context:n,memoizedValue:r,next:null},fi===null){if(da===null)throw Error(s(308));fi=n,da.dependencies={lanes:0,firstContext:n}}else fi=fi.next=n;return r}var bs=null;function Bl(n){bs===null?bs=[n]:bs.push(n)}function Ed(n,r,a,c){var p=r.interleaved;return p===null?(a.next=a,Bl(r)):(a.next=p.next,p.next=a),r.interleaved=a,_r(n,c)}function _r(n,r){n.lanes|=r;var a=n.alternate;for(a!==null&&(a.lanes|=r),a=n,n=n.return;n!==null;)n.childLanes|=r,a=n.alternate,a!==null&&(a.childLanes|=r),a=n,n=n.return;return a.tag===3?a.stateNode:null}var Ur=!1;function Vl(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function $d(n,r){n=n.updateQueue,r.updateQueue===n&&(r.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,effects:n.effects})}function xr(n,r){return{eventTime:n,lane:r,tag:0,payload:null,callback:null,next:null}}function Br(n,r,a){var c=n.updateQueue;if(c===null)return null;if(c=c.shared,(Je&2)!==0){var p=c.pending;return p===null?r.next=r:(r.next=p.next,p.next=r),c.pending=r,_r(n,a)}return p=c.interleaved,p===null?(r.next=r,Bl(c)):(r.next=p.next,p.next=r),c.interleaved=r,_r(n,a)}function fa(n,r,a){if(r=r.updateQueue,r!==null&&(r=r.shared,(a&4194240)!==0)){var c=r.lanes;c&=n.pendingLanes,a|=c,r.lanes=a,Ut(n,a)}}function Ad(n,r){var a=n.updateQueue,c=n.alternate;if(c!==null&&(c=c.updateQueue,a===c)){var p=null,m=null;if(a=a.firstBaseUpdate,a!==null){do{var _={eventTime:a.eventTime,lane:a.lane,tag:a.tag,payload:a.payload,callback:a.callback,next:null};m===null?p=m=_:m=m.next=_,a=a.next}while(a!==null);m===null?p=m=r:m=m.next=r}else p=m=r;a={baseState:c.baseState,firstBaseUpdate:p,lastBaseUpdate:m,shared:c.shared,effects:c.effects},n.updateQueue=a;return}n=a.lastBaseUpdate,n===null?a.firstBaseUpdate=r:n.next=r,a.lastBaseUpdate=r}function ha(n,r,a,c){var p=n.updateQueue;Ur=!1;var m=p.firstBaseUpdate,_=p.lastBaseUpdate,N=p.shared.pending;if(N!==null){p.shared.pending=null;var R=N,z=R.next;R.next=null,_===null?m=z:_.next=z,_=R;var ne=n.alternate;ne!==null&&(ne=ne.updateQueue,N=ne.lastBaseUpdate,N!==_&&(N===null?ne.firstBaseUpdate=z:N.next=z,ne.lastBaseUpdate=R))}if(m!==null){var se=p.baseState;_=0,ne=z=R=null,N=m;do{var te=N.lane,ge=N.eventTime;if((c&te)===te){ne!==null&&(ne=ne.next={eventTime:ge,lane:0,tag:N.tag,payload:N.payload,callback:N.callback,next:null});e:{var xe=n,be=N;switch(te=r,ge=a,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:Ur=!0}}N.callback!==null&&N.lane!==0&&(n.flags|=64,te=p.effects,te===null?p.effects=[N]:te.push(N))}else ge={eventTime:ge,lane:te,tag:N.tag,payload:N.payload,callback:N.callback,next:null},ne===null?(z=ne=ge,R=se):ne=ne.next=ge,_|=te;if(N=N.next,N===null){if(N=p.shared.pending,N===null)break;te=N,N=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 _|=p.lane,p=p.next;while(p!==r)}else m===null&&(p.shared.lanes=0);Ss|=_,n.lanes=_,n.memoizedState=se}}function Td(n,r,a){if(n=r.effects,r.effects=null,n!==null)for(r=0;r<n.length;r++){var c=n[r],p=c.callback;if(p!==null){if(c.callback=null,c=a,typeof p!="function")throw Error(s(191,p));p.call(c)}}}var oo={},qn=Fr(oo),ao=Fr(oo),lo=Fr(oo);function ks(n){if(n===oo)throw Error(s(174));return n}function Gl(n,r){switch(nt(lo,r),nt(ao,n),nt(qn,oo),n=r.nodeType,n){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:An(null,"");break;default:n=n===8?r.parentNode:r,r=n.namespaceURI||null,n=n.tagName,r=An(r,n)}it(qn),nt(qn,r)}function pi(){it(qn),it(ao),it(lo)}function Rd(n){ks(lo.current);var r=ks(qn.current),a=An(r,n.type);r!==a&&(nt(ao,n),nt(qn,a))}function Hl(n){ao.current===n&&(it(qn),it(ao))}var ct=Fr(0);function pa(n){for(var r=n;r!==null;){if(r.tag===13){var a=r.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||a.data==="$?"||a.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===n)break;for(;r.sibling===null;){if(r.return===null||r.return===n)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var Kl=[];function Jl(){for(var n=0;n<Kl.length;n++)Kl[n]._workInProgressVersionPrimary=null;Kl.length=0}var ma=j.ReactCurrentDispatcher,Ql=j.ReactCurrentBatchConfig,js=0,ut=null,wt=null,bt=null,ga=!1,co=!1,uo=0,ag=0;function Lt(){throw Error(s(321))}function Yl(n,r){if(r===null)return!1;for(var a=0;a<r.length&&a<n.length;a++)if(!On(n[a],r[a]))return!1;return!0}function Xl(n,r,a,c,p,m){if(js=m,ut=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,ma.current=n===null||n.memoizedState===null?dg:fg,n=a(c,p),co){m=0;do{if(co=!1,uo=0,25<=m)throw Error(s(301));m+=1,bt=wt=null,r.updateQueue=null,ma.current=hg,n=a(c,p)}while(co)}if(ma.current=va,r=wt!==null&&wt.next!==null,js=0,bt=wt=ut=null,ga=!1,r)throw Error(s(300));return n}function Zl(){var n=uo!==0;return uo=0,n}function er(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return bt===null?ut.memoizedState=bt=n:bt=bt.next=n,bt}function Sn(){if(wt===null){var n=ut.alternate;n=n!==null?n.memoizedState:null}else n=wt.next;var r=bt===null?ut.memoizedState:bt.next;if(r!==null)bt=r,wt=n;else{if(n===null)throw Error(s(310));wt=n,n={memoizedState:wt.memoizedState,baseState:wt.baseState,baseQueue:wt.baseQueue,queue:wt.queue,next:null},bt===null?ut.memoizedState=bt=n:bt=bt.next=n}return bt}function fo(n,r){return typeof r=="function"?r(n):r}function ql(n){var r=Sn(),a=r.queue;if(a===null)throw Error(s(311));a.lastRenderedReducer=n;var c=wt,p=c.baseQueue,m=a.pending;if(m!==null){if(p!==null){var _=p.next;p.next=m.next,m.next=_}c.baseQueue=p=m,a.pending=null}if(p!==null){m=p.next,c=c.baseState;var N=_=null,R=null,z=m;do{var ne=z.lane;if((js&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:n(c,z.action);else{var se={lane:ne,action:z.action,hasEagerState:z.hasEagerState,eagerState:z.eagerState,next:null};R===null?(N=R=se,_=c):R=R.next=se,ut.lanes|=ne,Ss|=ne}z=z.next}while(z!==null&&z!==m);R===null?_=c:R.next=N,On(c,r.memoizedState)||(Xt=!0),r.memoizedState=c,r.baseState=_,r.baseQueue=R,a.lastRenderedState=c}if(n=a.interleaved,n!==null){p=n;do m=p.lane,ut.lanes|=m,Ss|=m,p=p.next;while(p!==n)}else p===null&&(a.lanes=0);return[r.memoizedState,a.dispatch]}function ec(n){var r=Sn(),a=r.queue;if(a===null)throw Error(s(311));a.lastRenderedReducer=n;var c=a.dispatch,p=a.pending,m=r.memoizedState;if(p!==null){a.pending=null;var _=p=p.next;do m=n(m,_.action),_=_.next;while(_!==p);On(m,r.memoizedState)||(Xt=!0),r.memoizedState=m,r.baseQueue===null&&(r.baseState=m),a.lastRenderedState=m}return[m,c]}function Id(){}function Md(n,r){var a=ut,c=Sn(),p=r(),m=!On(c.memoizedState,p);if(m&&(c.memoizedState=p,Xt=!0),c=c.queue,tc(Od.bind(null,a,c,n),[n]),c.getSnapshot!==r||m||bt!==null&&bt.memoizedState.tag&1){if(a.flags|=2048,ho(9,Pd.bind(null,a,c,p,r),void 0,null),kt===null)throw Error(s(349));(js&30)!==0||Ld(a,r,p)}return p}function Ld(n,r,a){n.flags|=16384,n={getSnapshot:r,value:a},r=ut.updateQueue,r===null?(r={lastEffect:null,stores:null},ut.updateQueue=r,r.stores=[n]):(a=r.stores,a===null?r.stores=[n]:a.push(n))}function Pd(n,r,a,c){r.value=a,r.getSnapshot=c,Dd(r)&&Fd(n)}function Od(n,r,a){return a(function(){Dd(r)&&Fd(n)})}function Dd(n){var r=n.getSnapshot;n=n.value;try{var a=r();return!On(n,a)}catch{return!0}}function Fd(n){var r=_r(n,1);r!==null&&Un(r,n,1,-1)}function zd(n){var r=er();return typeof n=="function"&&(n=n()),r.memoizedState=r.baseState=n,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:fo,lastRenderedState:n},r.queue=n,n=n.dispatch=ug.bind(null,ut,n),[r.memoizedState,n]}function ho(n,r,a,c){return n={tag:n,create:r,destroy:a,deps:c,next:null},r=ut.updateQueue,r===null?(r={lastEffect:null,stores:null},ut.updateQueue=r,r.lastEffect=n.next=n):(a=r.lastEffect,a===null?r.lastEffect=n.next=n:(c=a.next,a.next=n,n.next=c,r.lastEffect=n)),n}function Wd(){return Sn().memoizedState}function ya(n,r,a,c){var p=er();ut.flags|=n,p.memoizedState=ho(1|r,a,void 0,c===void 0?null:c)}function wa(n,r,a,c){var p=Sn();c=c===void 0?null:c;var m=void 0;if(wt!==null){var _=wt.memoizedState;if(m=_.destroy,c!==null&&Yl(c,_.deps)){p.memoizedState=ho(r,a,m,c);return}}ut.flags|=n,p.memoizedState=ho(1|r,a,m,c)}function Ud(n,r){return ya(8390656,8,n,r)}function tc(n,r){return wa(2048,8,n,r)}function Bd(n,r){return wa(4,2,n,r)}function Vd(n,r){return wa(4,4,n,r)}function Gd(n,r){if(typeof r=="function")return n=n(),r(n),function(){r(null)};if(r!=null)return n=n(),r.current=n,function(){r.current=null}}function Hd(n,r,a){return a=a!=null?a.concat([n]):null,wa(4,4,Gd.bind(null,r,n),a)}function nc(){}function Kd(n,r){var a=Sn();r=r===void 0?null:r;var c=a.memoizedState;return c!==null&&r!==null&&Yl(r,c[1])?c[0]:(a.memoizedState=[n,r],n)}function Jd(n,r){var a=Sn();r=r===void 0?null:r;var c=a.memoizedState;return c!==null&&r!==null&&Yl(r,c[1])?c[0]:(n=n(),a.memoizedState=[n,r],n)}function Qd(n,r,a){return(js&21)===0?(n.baseState&&(n.baseState=!1,Xt=!0),n.memoizedState=a):(On(a,r)||(a=Wi(),ut.lanes|=a,Ss|=a,n.baseState=!0),r)}function lg(n,r){var a=Qe;Qe=a!==0&&4>a?a:4,n(!0);var c=Ql.transition;Ql.transition={};try{n(!1),r()}finally{Qe=a,Ql.transition=c}}function Yd(){return Sn().memoizedState}function cg(n,r,a){var c=Kr(n);if(a={lane:c,action:a,hasEagerState:!1,eagerState:null,next:null},Xd(n))Zd(r,a);else if(a=Ed(n,r,a,c),a!==null){var p=Vt();Un(a,n,c,p),qd(a,r,c)}}function ug(n,r,a){var c=Kr(n),p={lane:c,action:a,hasEagerState:!1,eagerState:null,next:null};if(Xd(n))Zd(r,p);else{var m=n.alternate;if(n.lanes===0&&(m===null||m.lanes===0)&&(m=r.lastRenderedReducer,m!==null))try{var _=r.lastRenderedState,N=m(_,a);if(p.hasEagerState=!0,p.eagerState=N,On(N,_)){var R=r.interleaved;R===null?(p.next=p,Bl(r)):(p.next=R.next,R.next=p),r.interleaved=p;return}}catch{}finally{}a=Ed(n,r,p,c),a!==null&&(p=Vt(),Un(a,n,c,p),qd(a,r,c))}}function Xd(n){var r=n.alternate;return n===ut||r!==null&&r===ut}function Zd(n,r){co=ga=!0;var a=n.pending;a===null?r.next=r:(r.next=a.next,a.next=r),n.pending=r}function qd(n,r,a){if((a&4194240)!==0){var c=r.lanes;c&=n.pendingLanes,a|=c,r.lanes=a,Ut(n,a)}}var va={readContext:jn,useCallback:Lt,useContext:Lt,useEffect:Lt,useImperativeHandle:Lt,useInsertionEffect:Lt,useLayoutEffect:Lt,useMemo:Lt,useReducer:Lt,useRef:Lt,useState:Lt,useDebugValue:Lt,useDeferredValue:Lt,useTransition:Lt,useMutableSource:Lt,useSyncExternalStore:Lt,useId:Lt,unstable_isNewReconciler:!1},dg={readContext:jn,useCallback:function(n,r){return er().memoizedState=[n,r===void 0?null:r],n},useContext:jn,useEffect:Ud,useImperativeHandle:function(n,r,a){return a=a!=null?a.concat([n]):null,ya(4194308,4,Gd.bind(null,r,n),a)},useLayoutEffect:function(n,r){return ya(4194308,4,n,r)},useInsertionEffect:function(n,r){return ya(4,2,n,r)},useMemo:function(n,r){var a=er();return r=r===void 0?null:r,n=n(),a.memoizedState=[n,r],n},useReducer:function(n,r,a){var c=er();return r=a!==void 0?a(r):r,c.memoizedState=c.baseState=r,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:r},c.queue=n,n=n.dispatch=cg.bind(null,ut,n),[c.memoizedState,n]},useRef:function(n){var r=er();return n={current:n},r.memoizedState=n},useState:zd,useDebugValue:nc,useDeferredValue:function(n){return er().memoizedState=n},useTransition:function(){var n=zd(!1),r=n[0];return n=lg.bind(null,n[1]),er().memoizedState=n,[r,n]},useMutableSource:function(){},useSyncExternalStore:function(n,r,a){var c=ut,p=er();if(at){if(a===void 0)throw Error(s(407));a=a()}else{if(a=r(),kt===null)throw Error(s(349));(js&30)!==0||Ld(c,r,a)}p.memoizedState=a;var m={value:a,getSnapshot:r};return p.queue=m,Ud(Od.bind(null,c,m,n),[n]),c.flags|=2048,ho(9,Pd.bind(null,c,m,a,r),void 0,null),a},useId:function(){var n=er(),r=kt.identifierPrefix;if(at){var a=vr,c=wr;a=(c&~(1<<32-Wt(c)-1)).toString(32)+a,r=":"+r+"R"+a,a=uo++,0<a&&(r+="H"+a.toString(32)),r+=":"}else a=ag++,r=":"+r+"r"+a.toString(32)+":";return n.memoizedState=r},unstable_isNewReconciler:!1},fg={readContext:jn,useCallback:Kd,useContext:jn,useEffect:tc,useImperativeHandle:Hd,useInsertionEffect:Bd,useLayoutEffect:Vd,useMemo:Jd,useReducer:ql,useRef:Wd,useState:function(){return ql(fo)},useDebugValue:nc,useDeferredValue:function(n){var r=Sn();return Qd(r,wt.memoizedState,n)},useTransition:function(){var n=ql(fo)[0],r=Sn().memoizedState;return[n,r]},useMutableSource:Id,useSyncExternalStore:Md,useId:Yd,unstable_isNewReconciler:!1},hg={readContext:jn,useCallback:Kd,useContext:jn,useEffect:tc,useImperativeHandle:Hd,useInsertionEffect:Bd,useLayoutEffect:Vd,useMemo:Jd,useReducer:ec,useRef:Wd,useState:function(){return ec(fo)},useDebugValue:nc,useDeferredValue:function(n){var r=Sn();return wt===null?r.memoizedState=n:Qd(r,wt.memoizedState,n)},useTransition:function(){var n=ec(fo)[0],r=Sn().memoizedState;return[n,r]},useMutableSource:Id,useSyncExternalStore:Md,useId:Yd,unstable_isNewReconciler:!1};function Fn(n,r){if(n&&n.defaultProps){r=G({},r),n=n.defaultProps;for(var a in n)r[a]===void 0&&(r[a]=n[a]);return r}return r}function rc(n,r,a,c){r=n.memoizedState,a=a(c,r),a=a==null?r:G({},r,a),n.memoizedState=a,n.lanes===0&&(n.updateQueue.baseState=a)}var _a={isMounted:function(n){return(n=n._reactInternals)?an(n)===n:!1},enqueueSetState:function(n,r,a){n=n._reactInternals;var c=Vt(),p=Kr(n),m=xr(c,p);m.payload=r,a!=null&&(m.callback=a),r=Br(n,m,p),r!==null&&(Un(r,n,p,c),fa(r,n,p))},enqueueReplaceState:function(n,r,a){n=n._reactInternals;var c=Vt(),p=Kr(n),m=xr(c,p);m.tag=1,m.payload=r,a!=null&&(m.callback=a),r=Br(n,m,p),r!==null&&(Un(r,n,p,c),fa(r,n,p))},enqueueForceUpdate:function(n,r){n=n._reactInternals;var a=Vt(),c=Kr(n),p=xr(a,c);p.tag=2,r!=null&&(p.callback=r),r=Br(n,p,c),r!==null&&(Un(r,n,c,a),fa(r,n,c))}};function ef(n,r,a,c,p,m,_){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(c,m,_):r.prototype&&r.prototype.isPureReactComponent?!Zi(a,c)||!Zi(p,m):!0}function tf(n,r,a){var c=!1,p=zr,m=r.contextType;return typeof m=="object"&&m!==null?m=jn(m):(p=Yt(r)?vs:Mt.current,c=r.contextTypes,m=(c=c!=null)?ai(n,p):zr),r=new r(a,m),n.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=_a,n.stateNode=r,r._reactInternals=n,c&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=p,n.__reactInternalMemoizedMaskedChildContext=m),r}function nf(n,r,a,c){n=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(a,c),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(a,c),r.state!==n&&_a.enqueueReplaceState(r,r.state,null)}function sc(n,r,a,c){var p=n.stateNode;p.props=a,p.state=n.memoizedState,p.refs={},Vl(n);var m=r.contextType;typeof m=="object"&&m!==null?p.context=jn(m):(m=Yt(r)?vs:Mt.current,p.context=ai(n,m)),p.state=n.memoizedState,m=r.getDerivedStateFromProps,typeof m=="function"&&(rc(n,r,m,a),p.state=n.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&&_a.enqueueReplaceState(p,p.state,null),ha(n,a,p,c),p.state=n.memoizedState),typeof p.componentDidMount=="function"&&(n.flags|=4194308)}function mi(n,r){try{var a="",c=r;do a+=oe(c),c=c.return;while(c);var p=a}catch(m){p=`
|
|
39
|
-
Error generating stack: `+m.message+`
|
|
40
|
-
`+m.stack}return{value:n,source:r,stack:p,digest:null}}function ic(n,r,a){return{value:n,source:null,stack:a??null,digest:r??null}}function oc(n,r){try{console.error(r.value)}catch(a){setTimeout(function(){throw a})}}var pg=typeof WeakMap=="function"?WeakMap:Map;function rf(n,r,a){a=xr(-1,a),a.tag=3,a.payload={element:null};var c=r.value;return a.callback=function(){Ca||(Ca=!0,xc=c),oc(n,r)},a}function sf(n,r,a){a=xr(-1,a),a.tag=3;var c=n.type.getDerivedStateFromError;if(typeof c=="function"){var p=r.value;a.payload=function(){return c(p)},a.callback=function(){oc(n,r)}}var m=n.stateNode;return m!==null&&typeof m.componentDidCatch=="function"&&(a.callback=function(){oc(n,r),typeof c!="function"&&(Gr===null?Gr=new Set([this]):Gr.add(this));var _=r.stack;this.componentDidCatch(r.value,{componentStack:_!==null?_:""})}),a}function of(n,r,a){var c=n.pingCache;if(c===null){c=n.pingCache=new pg;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(a)||(p.add(a),n=Eg.bind(null,n,r,a),r.then(n,n))}function af(n){do{var r;if((r=n.tag===13)&&(r=n.memoizedState,r=r!==null?r.dehydrated!==null:!0),r)return n;n=n.return}while(n!==null);return null}function lf(n,r,a,c,p){return(n.mode&1)===0?(n===r?n.flags|=65536:(n.flags|=128,a.flags|=131072,a.flags&=-52805,a.tag===1&&(a.alternate===null?a.tag=17:(r=xr(-1,1),r.tag=2,Br(a,r,1))),a.lanes|=1),n):(n.flags|=65536,n.lanes=p,n)}var mg=j.ReactCurrentOwner,Xt=!1;function Bt(n,r,a,c){r.child=n===null?Cd(r,null,a,c):di(r,n.child,a,c)}function cf(n,r,a,c,p){a=a.render;var m=r.ref;return hi(r,p),c=Xl(n,r,a,c,m,p),a=Zl(),n!==null&&!Xt?(r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~p,br(n,r,p)):(at&&a&&Ml(r),r.flags|=1,Bt(n,r,c,p),r.child)}function uf(n,r,a,c,p){if(n===null){var m=a.type;return typeof m=="function"&&!Ec(m)&&m.defaultProps===void 0&&a.compare===null&&a.defaultProps===void 0?(r.tag=15,r.type=m,df(n,r,m,c,p)):(n=Ia(a.type,null,c,r,r.mode,p),n.ref=r.ref,n.return=r,r.child=n)}if(m=n.child,(n.lanes&p)===0){var _=m.memoizedProps;if(a=a.compare,a=a!==null?a:Zi,a(_,c)&&n.ref===r.ref)return br(n,r,p)}return r.flags|=1,n=Qr(m,c),n.ref=r.ref,n.return=r,r.child=n}function df(n,r,a,c,p){if(n!==null){var m=n.memoizedProps;if(Zi(m,c)&&n.ref===r.ref)if(Xt=!1,r.pendingProps=c=m,(n.lanes&p)!==0)(n.flags&131072)!==0&&(Xt=!0);else return r.lanes=n.lanes,br(n,r,p)}return ac(n,r,a,c,p)}function ff(n,r,a){var c=r.pendingProps,p=c.children,m=n!==null?n.memoizedState:null;if(c.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},nt(yi,pn),pn|=a;else{if((a&1073741824)===0)return n=m!==null?m.baseLanes|a:a,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:n,cachePool:null,transitions:null},r.updateQueue=null,nt(yi,pn),pn|=n,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},c=m!==null?m.baseLanes:a,nt(yi,pn),pn|=c}else m!==null?(c=m.baseLanes|a,r.memoizedState=null):c=a,nt(yi,pn),pn|=c;return Bt(n,r,p,a),r.child}function hf(n,r){var a=r.ref;(n===null&&a!==null||n!==null&&n.ref!==a)&&(r.flags|=512,r.flags|=2097152)}function ac(n,r,a,c,p){var m=Yt(a)?vs:Mt.current;return m=ai(r,m),hi(r,p),a=Xl(n,r,a,c,m,p),c=Zl(),n!==null&&!Xt?(r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~p,br(n,r,p)):(at&&c&&Ml(r),r.flags|=1,Bt(n,r,a,p),r.child)}function pf(n,r,a,c,p){if(Yt(a)){var m=!0;sa(r)}else m=!1;if(hi(r,p),r.stateNode===null)ba(n,r),tf(r,a,c),sc(r,a,c,p),c=!0;else if(n===null){var _=r.stateNode,N=r.memoizedProps;_.props=N;var R=_.context,z=a.contextType;typeof z=="object"&&z!==null?z=jn(z):(z=Yt(a)?vs:Mt.current,z=ai(r,z));var ne=a.getDerivedStateFromProps,se=typeof ne=="function"||typeof _.getSnapshotBeforeUpdate=="function";se||typeof _.UNSAFE_componentWillReceiveProps!="function"&&typeof _.componentWillReceiveProps!="function"||(N!==c||R!==z)&&nf(r,_,c,z),Ur=!1;var te=r.memoizedState;_.state=te,ha(r,c,_,p),R=r.memoizedState,N!==c||te!==R||Qt.current||Ur?(typeof ne=="function"&&(rc(r,a,ne,c),R=r.memoizedState),(N=Ur||ef(r,a,N,c,te,R,z))?(se||typeof _.UNSAFE_componentWillMount!="function"&&typeof _.componentWillMount!="function"||(typeof _.componentWillMount=="function"&&_.componentWillMount(),typeof _.UNSAFE_componentWillMount=="function"&&_.UNSAFE_componentWillMount()),typeof _.componentDidMount=="function"&&(r.flags|=4194308)):(typeof _.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=c,r.memoizedState=R),_.props=c,_.state=R,_.context=z,c=N):(typeof _.componentDidMount=="function"&&(r.flags|=4194308),c=!1)}else{_=r.stateNode,$d(n,r),N=r.memoizedProps,z=r.type===r.elementType?N:Fn(r.type,N),_.props=z,se=r.pendingProps,te=_.context,R=a.contextType,typeof R=="object"&&R!==null?R=jn(R):(R=Yt(a)?vs:Mt.current,R=ai(r,R));var ge=a.getDerivedStateFromProps;(ne=typeof ge=="function"||typeof _.getSnapshotBeforeUpdate=="function")||typeof _.UNSAFE_componentWillReceiveProps!="function"&&typeof _.componentWillReceiveProps!="function"||(N!==se||te!==R)&&nf(r,_,c,R),Ur=!1,te=r.memoizedState,_.state=te,ha(r,c,_,p);var xe=r.memoizedState;N!==se||te!==xe||Qt.current||Ur?(typeof ge=="function"&&(rc(r,a,ge,c),xe=r.memoizedState),(z=Ur||ef(r,a,z,c,te,xe,R)||!1)?(ne||typeof _.UNSAFE_componentWillUpdate!="function"&&typeof _.componentWillUpdate!="function"||(typeof _.componentWillUpdate=="function"&&_.componentWillUpdate(c,xe,R),typeof _.UNSAFE_componentWillUpdate=="function"&&_.UNSAFE_componentWillUpdate(c,xe,R)),typeof _.componentDidUpdate=="function"&&(r.flags|=4),typeof _.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof _.componentDidUpdate!="function"||N===n.memoizedProps&&te===n.memoizedState||(r.flags|=4),typeof _.getSnapshotBeforeUpdate!="function"||N===n.memoizedProps&&te===n.memoizedState||(r.flags|=1024),r.memoizedProps=c,r.memoizedState=xe),_.props=c,_.state=xe,_.context=R,c=z):(typeof _.componentDidUpdate!="function"||N===n.memoizedProps&&te===n.memoizedState||(r.flags|=4),typeof _.getSnapshotBeforeUpdate!="function"||N===n.memoizedProps&&te===n.memoizedState||(r.flags|=1024),c=!1)}return lc(n,r,a,c,m,p)}function lc(n,r,a,c,p,m){hf(n,r);var _=(r.flags&128)!==0;if(!c&&!_)return p&&wd(r,a,!1),br(n,r,m);c=r.stateNode,mg.current=r;var N=_&&typeof a.getDerivedStateFromError!="function"?null:c.render();return r.flags|=1,n!==null&&_?(r.child=di(r,n.child,null,m),r.child=di(r,null,N,m)):Bt(n,r,N,m),r.memoizedState=c.state,p&&wd(r,a,!0),r.child}function mf(n){var r=n.stateNode;r.pendingContext?gd(n,r.pendingContext,r.pendingContext!==r.context):r.context&&gd(n,r.context,!1),Gl(n,r.containerInfo)}function gf(n,r,a,c,p){return ui(),Dl(p),r.flags|=256,Bt(n,r,a,c),r.child}var cc={dehydrated:null,treeContext:null,retryLane:0};function uc(n){return{baseLanes:n,cachePool:null,transitions:null}}function yf(n,r,a){var c=r.pendingProps,p=ct.current,m=!1,_=(r.flags&128)!==0,N;if((N=_)||(N=n!==null&&n.memoizedState===null?!1:(p&2)!==0),N?(m=!0,r.flags&=-129):(n===null||n.memoizedState!==null)&&(p|=1),nt(ct,p&1),n===null)return Ol(r),n=r.memoizedState,n!==null&&(n=n.dehydrated,n!==null)?((r.mode&1)===0?r.lanes=1:n.data==="$!"?r.lanes=8:r.lanes=1073741824,null):(_=c.children,n=c.fallback,m?(c=r.mode,m=r.child,_={mode:"hidden",children:_},(c&1)===0&&m!==null?(m.childLanes=0,m.pendingProps=_):m=Ma(_,c,0,null),n=$s(n,c,a,null),m.return=r,n.return=r,m.sibling=n,r.child=m,r.child.memoizedState=uc(a),r.memoizedState=cc,n):dc(r,_));if(p=n.memoizedState,p!==null&&(N=p.dehydrated,N!==null))return gg(n,r,_,c,N,p,a);if(m){m=c.fallback,_=r.mode,p=n.child,N=p.sibling;var R={mode:"hidden",children:c.children};return(_&1)===0&&r.child!==p?(c=r.child,c.childLanes=0,c.pendingProps=R,r.deletions=null):(c=Qr(p,R),c.subtreeFlags=p.subtreeFlags&14680064),N!==null?m=Qr(N,m):(m=$s(m,_,a,null),m.flags|=2),m.return=r,c.return=r,c.sibling=m,r.child=c,c=m,m=r.child,_=n.child.memoizedState,_=_===null?uc(a):{baseLanes:_.baseLanes|a,cachePool:null,transitions:_.transitions},m.memoizedState=_,m.childLanes=n.childLanes&~a,r.memoizedState=cc,c}return m=n.child,n=m.sibling,c=Qr(m,{mode:"visible",children:c.children}),(r.mode&1)===0&&(c.lanes=a),c.return=r,c.sibling=null,n!==null&&(a=r.deletions,a===null?(r.deletions=[n],r.flags|=16):a.push(n)),r.child=c,r.memoizedState=null,c}function dc(n,r){return r=Ma({mode:"visible",children:r},n.mode,0,null),r.return=n,n.child=r}function xa(n,r,a,c){return c!==null&&Dl(c),di(r,n.child,null,a),n=dc(r,r.pendingProps.children),n.flags|=2,r.memoizedState=null,n}function gg(n,r,a,c,p,m,_){if(a)return r.flags&256?(r.flags&=-257,c=ic(Error(s(422))),xa(n,r,_,c)):r.memoizedState!==null?(r.child=n.child,r.flags|=128,null):(m=c.fallback,p=r.mode,c=Ma({mode:"visible",children:c.children},p,0,null),m=$s(m,p,_,null),m.flags|=2,c.return=r,m.return=r,c.sibling=m,r.child=c,(r.mode&1)!==0&&di(r,n.child,null,_),r.child.memoizedState=uc(_),r.memoizedState=cc,m);if((r.mode&1)===0)return xa(n,r,_,null);if(p.data==="$!"){if(c=p.nextSibling&&p.nextSibling.dataset,c)var N=c.dgst;return c=N,m=Error(s(419)),c=ic(m,c,void 0),xa(n,r,_,c)}if(N=(_&n.childLanes)!==0,Xt||N){if(c=kt,c!==null){switch(_&-_){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|_))!==0?0:p,p!==0&&p!==m.retryLane&&(m.retryLane=p,_r(n,p),Un(c,n,p,-1))}return Cc(),c=ic(Error(s(421))),xa(n,r,_,c)}return p.data==="$?"?(r.flags|=128,r.child=n.child,r=$g.bind(null,n),p._reactRetry=r,null):(n=m.treeContext,hn=Dr(p.nextSibling),fn=r,at=!0,Dn=null,n!==null&&(bn[kn++]=wr,bn[kn++]=vr,bn[kn++]=_s,wr=n.id,vr=n.overflow,_s=r),r=dc(r,c.children),r.flags|=4096,r)}function wf(n,r,a){n.lanes|=r;var c=n.alternate;c!==null&&(c.lanes|=r),Ul(n.return,r,a)}function fc(n,r,a,c,p){var m=n.memoizedState;m===null?n.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:c,tail:a,tailMode:p}:(m.isBackwards=r,m.rendering=null,m.renderingStartTime=0,m.last=c,m.tail=a,m.tailMode=p)}function vf(n,r,a){var c=r.pendingProps,p=c.revealOrder,m=c.tail;if(Bt(n,r,c.children,a),c=ct.current,(c&2)!==0)c=c&1|2,r.flags|=128;else{if(n!==null&&(n.flags&128)!==0)e:for(n=r.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&wf(n,a,r);else if(n.tag===19)wf(n,a,r);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===r)break e;for(;n.sibling===null;){if(n.return===null||n.return===r)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}c&=1}if(nt(ct,c),(r.mode&1)===0)r.memoizedState=null;else switch(p){case"forwards":for(a=r.child,p=null;a!==null;)n=a.alternate,n!==null&&pa(n)===null&&(p=a),a=a.sibling;a=p,a===null?(p=r.child,r.child=null):(p=a.sibling,a.sibling=null),fc(r,!1,p,a,m);break;case"backwards":for(a=null,p=r.child,r.child=null;p!==null;){if(n=p.alternate,n!==null&&pa(n)===null){r.child=p;break}n=p.sibling,p.sibling=a,a=p,p=n}fc(r,!0,a,null,m);break;case"together":fc(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function ba(n,r){(r.mode&1)===0&&n!==null&&(n.alternate=null,r.alternate=null,r.flags|=2)}function br(n,r,a){if(n!==null&&(r.dependencies=n.dependencies),Ss|=r.lanes,(a&r.childLanes)===0)return null;if(n!==null&&r.child!==n.child)throw Error(s(153));if(r.child!==null){for(n=r.child,a=Qr(n,n.pendingProps),r.child=a,a.return=r;n.sibling!==null;)n=n.sibling,a=a.sibling=Qr(n,n.pendingProps),a.return=r;a.sibling=null}return r.child}function yg(n,r,a){switch(r.tag){case 3:mf(r),ui();break;case 5:Rd(r);break;case 1:Yt(r.type)&&sa(r);break;case 4:Gl(r,r.stateNode.containerInfo);break;case 10:var c=r.type._context,p=r.memoizedProps.value;nt(ua,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):(a&r.child.childLanes)!==0?yf(n,r,a):(nt(ct,ct.current&1),n=br(n,r,a),n!==null?n.sibling:null);nt(ct,ct.current&1);break;case 19:if(c=(a&r.childLanes)!==0,(n.flags&128)!==0){if(c)return vf(n,r,a);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,ff(n,r,a)}return br(n,r,a)}var _f,hc,xf,bf;_f=function(n,r){for(var a=r.child;a!==null;){if(a.tag===5||a.tag===6)n.appendChild(a.stateNode);else if(a.tag!==4&&a.child!==null){a.child.return=a,a=a.child;continue}if(a===r)break;for(;a.sibling===null;){if(a.return===null||a.return===r)return;a=a.return}a.sibling.return=a.return,a=a.sibling}},hc=function(){},xf=function(n,r,a,c){var p=n.memoizedProps;if(p!==c){n=r.stateNode,ks(qn.current);var m=null;switch(a){case"input":p=pe(n,p),c=pe(n,c),m=[];break;case"select":p=G({},p,{value:void 0}),c=G({},c,{value:void 0}),m=[];break;case"textarea":p=Fe(n,p),c=Fe(n,c),m=[];break;default:typeof p.onClick!="function"&&typeof c.onClick=="function"&&(n.onclick=ta)}gn(a,c);var _;a=null;for(z in p)if(!c.hasOwnProperty(z)&&p.hasOwnProperty(z)&&p[z]!=null)if(z==="style"){var N=p[z];for(_ in N)N.hasOwnProperty(_)&&(a||(a={}),a[_]="")}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(N=p!=null?p[z]:void 0,c.hasOwnProperty(z)&&R!==N&&(R!=null||N!=null))if(z==="style")if(N){for(_ in N)!N.hasOwnProperty(_)||R&&R.hasOwnProperty(_)||(a||(a={}),a[_]="");for(_ in R)R.hasOwnProperty(_)&&N[_]!==R[_]&&(a||(a={}),a[_]=R[_])}else a||(m||(m=[]),m.push(z,a)),a=R;else z==="dangerouslySetInnerHTML"?(R=R?R.__html:void 0,N=N?N.__html:void 0,R!=null&&N!==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"&&st("scroll",n),m||N===R||(m=[])):(m=m||[]).push(z,R))}a&&(m=m||[]).push("style",a);var z=m;(r.updateQueue=z)&&(r.flags|=4)}},bf=function(n,r,a,c){a!==c&&(r.flags|=4)};function po(n,r){if(!at)switch(n.tailMode){case"hidden":r=n.tail;for(var a=null;r!==null;)r.alternate!==null&&(a=r),r=r.sibling;a===null?n.tail=null:a.sibling=null;break;case"collapsed":a=n.tail;for(var c=null;a!==null;)a.alternate!==null&&(c=a),a=a.sibling;c===null?r||n.tail===null?n.tail=null:n.tail.sibling=null:c.sibling=null}}function Pt(n){var r=n.alternate!==null&&n.alternate.child===n.child,a=0,c=0;if(r)for(var p=n.child;p!==null;)a|=p.lanes|p.childLanes,c|=p.subtreeFlags&14680064,c|=p.flags&14680064,p.return=n,p=p.sibling;else for(p=n.child;p!==null;)a|=p.lanes|p.childLanes,c|=p.subtreeFlags,c|=p.flags,p.return=n,p=p.sibling;return n.subtreeFlags|=c,n.childLanes=a,r}function wg(n,r,a){var c=r.pendingProps;switch(Ll(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Pt(r),null;case 1:return Yt(r.type)&&ra(),Pt(r),null;case 3:return c=r.stateNode,pi(),it(Qt),it(Mt),Jl(),c.pendingContext&&(c.context=c.pendingContext,c.pendingContext=null),(n===null||n.child===null)&&(la(r)?r.flags|=4:n===null||n.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,Dn!==null&&(jc(Dn),Dn=null))),hc(n,r),Pt(r),null;case 5:Hl(r);var p=ks(lo.current);if(a=r.type,n!==null&&r.stateNode!=null)xf(n,r,a,c,p),n.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!c){if(r.stateNode===null)throw Error(s(166));return Pt(r),null}if(n=ks(qn.current),la(r)){c=r.stateNode,a=r.type;var m=r.memoizedProps;switch(c[Zn]=r,c[ro]=m,n=(r.mode&1)!==0,a){case"dialog":st("cancel",c),st("close",c);break;case"iframe":case"object":case"embed":st("load",c);break;case"video":case"audio":for(p=0;p<eo.length;p++)st(eo[p],c);break;case"source":st("error",c);break;case"img":case"image":case"link":st("error",c),st("load",c);break;case"details":st("toggle",c);break;case"input":De(c,m),st("invalid",c);break;case"select":c._wrapperState={wasMultiple:!!m.multiple},st("invalid",c);break;case"textarea":Ke(c,m),st("invalid",c)}gn(a,m),p=null;for(var _ in m)if(m.hasOwnProperty(_)){var N=m[_];_==="children"?typeof N=="string"?c.textContent!==N&&(m.suppressHydrationWarning!==!0&&ea(c.textContent,N,n),p=["children",N]):typeof N=="number"&&c.textContent!==""+N&&(m.suppressHydrationWarning!==!0&&ea(c.textContent,N,n),p=["children",""+N]):l.hasOwnProperty(_)&&N!=null&&_==="onScroll"&&st("scroll",c)}switch(a){case"input":ke(c),Ve(c,m,!0);break;case"textarea":ke(c),or(c);break;case"select":case"option":break;default:typeof m.onClick=="function"&&(c.onclick=ta)}c=p,r.updateQueue=c,c!==null&&(r.flags|=4)}else{_=p.nodeType===9?p:p.ownerDocument,n==="http://www.w3.org/1999/xhtml"&&(n=Tt(a)),n==="http://www.w3.org/1999/xhtml"?a==="script"?(n=_.createElement("div"),n.innerHTML="<script><\/script>",n=n.removeChild(n.firstChild)):typeof c.is=="string"?n=_.createElement(a,{is:c.is}):(n=_.createElement(a),a==="select"&&(_=n,c.multiple?_.multiple=!0:c.size&&(_.size=c.size))):n=_.createElementNS(n,a),n[Zn]=r,n[ro]=c,_f(n,r,!1,!1),r.stateNode=n;e:{switch(_=ns(a,c),a){case"dialog":st("cancel",n),st("close",n),p=c;break;case"iframe":case"object":case"embed":st("load",n),p=c;break;case"video":case"audio":for(p=0;p<eo.length;p++)st(eo[p],n);p=c;break;case"source":st("error",n),p=c;break;case"img":case"image":case"link":st("error",n),st("load",n),p=c;break;case"details":st("toggle",n),p=c;break;case"input":De(n,c),p=pe(n,c),st("invalid",n);break;case"option":p=c;break;case"select":n._wrapperState={wasMultiple:!!c.multiple},p=G({},c,{value:void 0}),st("invalid",n);break;case"textarea":Ke(n,c),p=Fe(n,c),st("invalid",n);break;default:p=c}gn(a,p),N=p;for(m in N)if(N.hasOwnProperty(m)){var R=N[m];m==="style"?Ps(n,R):m==="dangerouslySetInnerHTML"?(R=R?R.__html:void 0,R!=null&&Rn(n,R)):m==="children"?typeof R=="string"?(a!=="textarea"||R!=="")&&ar(n,R):typeof R=="number"&&ar(n,""+R):m!=="suppressContentEditableWarning"&&m!=="suppressHydrationWarning"&&m!=="autoFocus"&&(l.hasOwnProperty(m)?R!=null&&m==="onScroll"&&st("scroll",n):R!=null&&$(n,m,R,_))}switch(a){case"input":ke(n),Ve(n,c,!1);break;case"textarea":ke(n),or(n);break;case"option":c.value!=null&&n.setAttribute("value",""+Z(c.value));break;case"select":n.multiple=!!c.multiple,m=c.value,m!=null?me(n,!!c.multiple,m,!1):c.defaultValue!=null&&me(n,!!c.multiple,c.defaultValue,!0);break;default:typeof p.onClick=="function"&&(n.onclick=ta)}switch(a){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 Pt(r),null;case 6:if(n&&r.stateNode!=null)bf(n,r,n.memoizedProps,c);else{if(typeof c!="string"&&r.stateNode===null)throw Error(s(166));if(a=ks(lo.current),ks(qn.current),la(r)){if(c=r.stateNode,a=r.memoizedProps,c[Zn]=r,(m=c.nodeValue!==a)&&(n=fn,n!==null))switch(n.tag){case 3:ea(c.nodeValue,a,(n.mode&1)!==0);break;case 5:n.memoizedProps.suppressHydrationWarning!==!0&&ea(c.nodeValue,a,(n.mode&1)!==0)}m&&(r.flags|=4)}else c=(a.nodeType===9?a:a.ownerDocument).createTextNode(c),c[Zn]=r,r.stateNode=c}return Pt(r),null;case 13:if(it(ct),c=r.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(at&&hn!==null&&(r.mode&1)!==0&&(r.flags&128)===0)jd(),ui(),r.flags|=98560,m=!1;else if(m=la(r),c!==null&&c.dehydrated!==null){if(n===null){if(!m)throw Error(s(318));if(m=r.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(s(317));m[Zn]=r}else ui(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Pt(r),m=!1}else Dn!==null&&(jc(Dn),Dn=null),m=!0;if(!m)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=a,r):(c=c!==null,c!==(n!==null&&n.memoizedState!==null)&&c&&(r.child.flags|=8192,(r.mode&1)!==0&&(n===null||(ct.current&1)!==0?vt===0&&(vt=3):Cc())),r.updateQueue!==null&&(r.flags|=4),Pt(r),null);case 4:return pi(),hc(n,r),n===null&&to(r.stateNode.containerInfo),Pt(r),null;case 10:return Wl(r.type._context),Pt(r),null;case 17:return Yt(r.type)&&ra(),Pt(r),null;case 19:if(it(ct),m=r.memoizedState,m===null)return Pt(r),null;if(c=(r.flags&128)!==0,_=m.rendering,_===null)if(c)po(m,!1);else{if(vt!==0||n!==null&&(n.flags&128)!==0)for(n=r.child;n!==null;){if(_=pa(n),_!==null){for(r.flags|=128,po(m,!1),c=_.updateQueue,c!==null&&(r.updateQueue=c,r.flags|=4),r.subtreeFlags=0,c=a,a=r.child;a!==null;)m=a,n=c,m.flags&=14680066,_=m.alternate,_===null?(m.childLanes=0,m.lanes=n,m.child=null,m.subtreeFlags=0,m.memoizedProps=null,m.memoizedState=null,m.updateQueue=null,m.dependencies=null,m.stateNode=null):(m.childLanes=_.childLanes,m.lanes=_.lanes,m.child=_.child,m.subtreeFlags=0,m.deletions=null,m.memoizedProps=_.memoizedProps,m.memoizedState=_.memoizedState,m.updateQueue=_.updateQueue,m.type=_.type,n=_.dependencies,m.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),a=a.sibling;return nt(ct,ct.current&1|2),r.child}n=n.sibling}m.tail!==null&<()>wi&&(r.flags|=128,c=!0,po(m,!1),r.lanes=4194304)}else{if(!c)if(n=pa(_),n!==null){if(r.flags|=128,c=!0,a=n.updateQueue,a!==null&&(r.updateQueue=a,r.flags|=4),po(m,!0),m.tail===null&&m.tailMode==="hidden"&&!_.alternate&&!at)return Pt(r),null}else 2*lt()-m.renderingStartTime>wi&&a!==1073741824&&(r.flags|=128,c=!0,po(m,!1),r.lanes=4194304);m.isBackwards?(_.sibling=r.child,r.child=_):(a=m.last,a!==null?a.sibling=_:r.child=_,m.last=_)}return m.tail!==null?(r=m.tail,m.rendering=r,m.tail=r.sibling,m.renderingStartTime=lt(),r.sibling=null,a=ct.current,nt(ct,c?a&1|2:a&1),r):(Pt(r),null);case 22:case 23:return Nc(),c=r.memoizedState!==null,n!==null&&n.memoizedState!==null!==c&&(r.flags|=8192),c&&(r.mode&1)!==0?(pn&1073741824)!==0&&(Pt(r),r.subtreeFlags&6&&(r.flags|=8192)):Pt(r),null;case 24:return null;case 25:return null}throw Error(s(156,r.tag))}function vg(n,r){switch(Ll(r),r.tag){case 1:return Yt(r.type)&&ra(),n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 3:return pi(),it(Qt),it(Mt),Jl(),n=r.flags,(n&65536)!==0&&(n&128)===0?(r.flags=n&-65537|128,r):null;case 5:return Hl(r),null;case 13:if(it(ct),n=r.memoizedState,n!==null&&n.dehydrated!==null){if(r.alternate===null)throw Error(s(340));ui()}return n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 19:return it(ct),null;case 4:return pi(),null;case 10:return Wl(r.type._context),null;case 22:case 23:return Nc(),null;case 24:return null;default:return null}}var ka=!1,Ot=!1,_g=typeof WeakSet=="function"?WeakSet:Set,_e=null;function gi(n,r){var a=n.ref;if(a!==null)if(typeof a=="function")try{a(null)}catch(c){dt(n,r,c)}else a.current=null}function pc(n,r,a){try{a()}catch(c){dt(n,r,c)}}var kf=!1;function xg(n,r){if(Nl=hs,n=ed(),wl(n)){if("selectionStart"in n)var a={start:n.selectionStart,end:n.selectionEnd};else e:{a=(a=n.ownerDocument)&&a.defaultView||window;var c=a.getSelection&&a.getSelection();if(c&&c.rangeCount!==0){a=c.anchorNode;var p=c.anchorOffset,m=c.focusNode;c=c.focusOffset;try{a.nodeType,m.nodeType}catch{a=null;break e}var _=0,N=-1,R=-1,z=0,ne=0,se=n,te=null;t:for(;;){for(var ge;se!==a||p!==0&&se.nodeType!==3||(N=_+p),se!==m||c!==0&&se.nodeType!==3||(R=_+c),se.nodeType===3&&(_+=se.nodeValue.length),(ge=se.firstChild)!==null;)te=se,se=ge;for(;;){if(se===n)break t;if(te===a&&++z===p&&(N=_),te===m&&++ne===c&&(R=_),(ge=se.nextSibling)!==null)break;se=te,te=se.parentNode}se=ge}a=N===-1||R===-1?null:{start:N,end:R}}else a=null}a=a||{start:0,end:0}}else a=null;for(Cl={focusedElem:n,selectionRange:a},hs=!1,_e=r;_e!==null;)if(r=_e,n=r.child,(r.subtreeFlags&1028)!==0&&n!==null)n.return=r,_e=n;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,mt=xe.memoizedState,O=r.stateNode,M=O.getSnapshotBeforeUpdate(r.elementType===r.type?be:Fn(r.type,be),mt);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(n=r.sibling,n!==null){n.return=r.return,_e=n;break}_e=r.return}return xe=kf,kf=!1,xe}function mo(n,r,a){var c=r.updateQueue;if(c=c!==null?c.lastEffect:null,c!==null){var p=c=c.next;do{if((p.tag&n)===n){var m=p.destroy;p.destroy=void 0,m!==void 0&&pc(r,a,m)}p=p.next}while(p!==c)}}function ja(n,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var a=r=r.next;do{if((a.tag&n)===n){var c=a.create;a.destroy=c()}a=a.next}while(a!==r)}}function mc(n){var r=n.ref;if(r!==null){var a=n.stateNode;switch(n.tag){case 5:n=a;break;default:n=a}typeof r=="function"?r(n):r.current=n}}function jf(n){var r=n.alternate;r!==null&&(n.alternate=null,jf(r)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(r=n.stateNode,r!==null&&(delete r[Zn],delete r[ro],delete r[Tl],delete r[rg],delete r[sg])),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}function Sf(n){return n.tag===5||n.tag===3||n.tag===4}function Nf(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||Sf(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function gc(n,r,a){var c=n.tag;if(c===5||c===6)n=n.stateNode,r?a.nodeType===8?a.parentNode.insertBefore(n,r):a.insertBefore(n,r):(a.nodeType===8?(r=a.parentNode,r.insertBefore(n,a)):(r=a,r.appendChild(n)),a=a._reactRootContainer,a!=null||r.onclick!==null||(r.onclick=ta));else if(c!==4&&(n=n.child,n!==null))for(gc(n,r,a),n=n.sibling;n!==null;)gc(n,r,a),n=n.sibling}function yc(n,r,a){var c=n.tag;if(c===5||c===6)n=n.stateNode,r?a.insertBefore(n,r):a.appendChild(n);else if(c!==4&&(n=n.child,n!==null))for(yc(n,r,a),n=n.sibling;n!==null;)yc(n,r,a),n=n.sibling}var Nt=null,zn=!1;function Vr(n,r,a){for(a=a.child;a!==null;)Cf(n,r,a),a=a.sibling}function Cf(n,r,a){if(Le&&typeof Le.onCommitFiberUnmount=="function")try{Le.onCommitFiberUnmount(wn,a)}catch{}switch(a.tag){case 5:Ot||gi(a,r);case 6:var c=Nt,p=zn;Nt=null,Vr(n,r,a),Nt=c,zn=p,Nt!==null&&(zn?(n=Nt,a=a.stateNode,n.nodeType===8?n.parentNode.removeChild(a):n.removeChild(a)):Nt.removeChild(a.stateNode));break;case 18:Nt!==null&&(zn?(n=Nt,a=a.stateNode,n.nodeType===8?Al(n.parentNode,a):n.nodeType===1&&Al(n,a),fs(n)):Al(Nt,a.stateNode));break;case 4:c=Nt,p=zn,Nt=a.stateNode.containerInfo,zn=!0,Vr(n,r,a),Nt=c,zn=p;break;case 0:case 11:case 14:case 15:if(!Ot&&(c=a.updateQueue,c!==null&&(c=c.lastEffect,c!==null))){p=c=c.next;do{var m=p,_=m.destroy;m=m.tag,_!==void 0&&((m&2)!==0||(m&4)!==0)&&pc(a,r,_),p=p.next}while(p!==c)}Vr(n,r,a);break;case 1:if(!Ot&&(gi(a,r),c=a.stateNode,typeof c.componentWillUnmount=="function"))try{c.props=a.memoizedProps,c.state=a.memoizedState,c.componentWillUnmount()}catch(N){dt(a,r,N)}Vr(n,r,a);break;case 21:Vr(n,r,a);break;case 22:a.mode&1?(Ot=(c=Ot)||a.memoizedState!==null,Vr(n,r,a),Ot=c):Vr(n,r,a);break;default:Vr(n,r,a)}}function Ef(n){var r=n.updateQueue;if(r!==null){n.updateQueue=null;var a=n.stateNode;a===null&&(a=n.stateNode=new _g),r.forEach(function(c){var p=Ag.bind(null,n,c);a.has(c)||(a.add(c),c.then(p,p))})}}function Wn(n,r){var a=r.deletions;if(a!==null)for(var c=0;c<a.length;c++){var p=a[c];try{var m=n,_=r,N=_;e:for(;N!==null;){switch(N.tag){case 5:Nt=N.stateNode,zn=!1;break e;case 3:Nt=N.stateNode.containerInfo,zn=!0;break e;case 4:Nt=N.stateNode.containerInfo,zn=!0;break e}N=N.return}if(Nt===null)throw Error(s(160));Cf(m,_,p),Nt=null,zn=!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;)$f(r,n),r=r.sibling}function $f(n,r){var a=n.alternate,c=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:if(Wn(r,n),tr(n),c&4){try{mo(3,n,n.return),ja(3,n)}catch(be){dt(n,n.return,be)}try{mo(5,n,n.return)}catch(be){dt(n,n.return,be)}}break;case 1:Wn(r,n),tr(n),c&512&&a!==null&&gi(a,a.return);break;case 5:if(Wn(r,n),tr(n),c&512&&a!==null&&gi(a,a.return),n.flags&32){var p=n.stateNode;try{ar(p,"")}catch(be){dt(n,n.return,be)}}if(c&4&&(p=n.stateNode,p!=null)){var m=n.memoizedProps,_=a!==null?a.memoizedProps:m,N=n.type,R=n.updateQueue;if(n.updateQueue=null,R!==null)try{N==="input"&&m.type==="radio"&&m.name!=null&&we(p,m),ns(N,_);var z=ns(N,m);for(_=0;_<R.length;_+=2){var ne=R[_],se=R[_+1];ne==="style"?Ps(p,se):ne==="dangerouslySetInnerHTML"?Rn(p,se):ne==="children"?ar(p,se):$(p,ne,se,z)}switch(N){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[ro]=m}catch(be){dt(n,n.return,be)}}break;case 6:if(Wn(r,n),tr(n),c&4){if(n.stateNode===null)throw Error(s(162));p=n.stateNode,m=n.memoizedProps;try{p.nodeValue=m}catch(be){dt(n,n.return,be)}}break;case 3:if(Wn(r,n),tr(n),c&4&&a!==null&&a.memoizedState.isDehydrated)try{fs(r.containerInfo)}catch(be){dt(n,n.return,be)}break;case 4:Wn(r,n),tr(n);break;case 13:Wn(r,n),tr(n),p=n.child,p.flags&8192&&(m=p.memoizedState!==null,p.stateNode.isHidden=m,!m||p.alternate!==null&&p.alternate.memoizedState!==null||(_c=lt())),c&4&&Ef(n);break;case 22:if(ne=a!==null&&a.memoizedState!==null,n.mode&1?(Ot=(z=Ot)||ne,Wn(r,n),Ot=z):Wn(r,n),tr(n),c&8192){if(z=n.memoizedState!==null,(n.stateNode.isHidden=z)&&!ne&&(n.mode&1)!==0)for(_e=n,ne=n.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:mo(4,te,te.return);break;case 1:gi(te,te.return);var xe=te.stateNode;if(typeof xe.componentWillUnmount=="function"){c=te,a=te.return;try{r=c,xe.props=r.memoizedProps,xe.state=r.memoizedState,xe.componentWillUnmount()}catch(be){dt(c,a,be)}}break;case 5:gi(te,te.return);break;case 22:if(te.memoizedState!==null){Rf(se);continue}}ge!==null?(ge.return=te,_e=ge):Rf(se)}ne=ne.sibling}e:for(ne=null,se=n;;){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"):(N=se.stateNode,R=se.memoizedProps.style,_=R!=null&&R.hasOwnProperty("display")?R.display:null,N.style.display=Ri("display",_))}catch(be){dt(n,n.return,be)}}}else if(se.tag===6){if(ne===null)try{se.stateNode.nodeValue=z?"":se.memoizedProps}catch(be){dt(n,n.return,be)}}else if((se.tag!==22&&se.tag!==23||se.memoizedState===null||se===n)&&se.child!==null){se.child.return=se,se=se.child;continue}if(se===n)break e;for(;se.sibling===null;){if(se.return===null||se.return===n)break e;ne===se&&(ne=null),se=se.return}ne===se&&(ne=null),se.sibling.return=se.return,se=se.sibling}}break;case 19:Wn(r,n),tr(n),c&4&&Ef(n);break;case 21:break;default:Wn(r,n),tr(n)}}function tr(n){var r=n.flags;if(r&2){try{e:{for(var a=n.return;a!==null;){if(Sf(a)){var c=a;break e}a=a.return}throw Error(s(160))}switch(c.tag){case 5:var p=c.stateNode;c.flags&32&&(ar(p,""),c.flags&=-33);var m=Nf(n);yc(n,m,p);break;case 3:case 4:var _=c.stateNode.containerInfo,N=Nf(n);gc(n,N,_);break;default:throw Error(s(161))}}catch(R){dt(n,n.return,R)}n.flags&=-3}r&4096&&(n.flags&=-4097)}function bg(n,r,a){_e=n,Af(n)}function Af(n,r,a){for(var c=(n.mode&1)!==0;_e!==null;){var p=_e,m=p.child;if(p.tag===22&&c){var _=p.memoizedState!==null||ka;if(!_){var N=p.alternate,R=N!==null&&N.memoizedState!==null||Ot;N=ka;var z=Ot;if(ka=_,(Ot=R)&&!z)for(_e=p;_e!==null;)_=_e,R=_.child,_.tag===22&&_.memoizedState!==null?If(p):R!==null?(R.return=_,_e=R):If(p);for(;m!==null;)_e=m,Af(m),m=m.sibling;_e=p,ka=N,Ot=z}Tf(n)}else(p.subtreeFlags&8772)!==0&&m!==null?(m.return=p,_e=m):Tf(n)}}function Tf(n){for(;_e!==null;){var r=_e;if((r.flags&8772)!==0){var a=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:Ot||ja(5,r);break;case 1:var c=r.stateNode;if(r.flags&4&&!Ot)if(a===null)c.componentDidMount();else{var p=r.elementType===r.type?a.memoizedProps:Fn(r.type,a.memoizedProps);c.componentDidUpdate(p,a.memoizedState,c.__reactInternalSnapshotBeforeUpdate)}var m=r.updateQueue;m!==null&&Td(r,m,c);break;case 3:var _=r.updateQueue;if(_!==null){if(a=null,r.child!==null)switch(r.child.tag){case 5:a=r.child.stateNode;break;case 1:a=r.child.stateNode}Td(r,_,a)}break;case 5:var N=r.stateNode;if(a===null&&r.flags&4){a=N;var R=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":R.autoFocus&&a.focus();break;case"img":R.src&&(a.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&&fs(se)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(s(163))}Ot||r.flags&512&&mc(r)}catch(te){dt(r,r.return,te)}}if(r===n){_e=null;break}if(a=r.sibling,a!==null){a.return=r.return,_e=a;break}_e=r.return}}function Rf(n){for(;_e!==null;){var r=_e;if(r===n){_e=null;break}var a=r.sibling;if(a!==null){a.return=r.return,_e=a;break}_e=r.return}}function If(n){for(;_e!==null;){var r=_e;try{switch(r.tag){case 0:case 11:case 15:var a=r.return;try{ja(4,r)}catch(R){dt(r,a,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{mc(r)}catch(R){dt(r,m,R)}break;case 5:var _=r.return;try{mc(r)}catch(R){dt(r,_,R)}}}catch(R){dt(r,r.return,R)}if(r===n){_e=null;break}var N=r.sibling;if(N!==null){N.return=r.return,_e=N;break}_e=r.return}}var kg=Math.ceil,Sa=j.ReactCurrentDispatcher,wc=j.ReactCurrentOwner,Nn=j.ReactCurrentBatchConfig,Je=0,kt=null,yt=null,Ct=0,pn=0,yi=Fr(0),vt=0,go=null,Ss=0,Na=0,vc=0,yo=null,Zt=null,_c=0,wi=1/0,kr=null,Ca=!1,xc=null,Gr=null,Ea=!1,Hr=null,$a=0,wo=0,bc=null,Aa=-1,Ta=0;function Vt(){return(Je&6)!==0?lt():Aa!==-1?Aa:Aa=lt()}function Kr(n){return(n.mode&1)===0?1:(Je&2)!==0&&Ct!==0?Ct&-Ct:og.transition!==null?(Ta===0&&(Ta=Wi()),Ta):(n=Qe,n!==0||(n=window.event,n=n===void 0?16:Hi(n.type)),n)}function Un(n,r,a,c){if(50<wo)throw wo=0,bc=null,Error(s(185));Mn(n,a,c),((Je&2)===0||n!==kt)&&(n===kt&&((Je&2)===0&&(Na|=a),vt===4&&Jr(n,Ct)),qt(n,c),a===1&&Je===0&&(r.mode&1)===0&&(wi=lt()+500,ia&&Wr()))}function qt(n,r){var a=n.callbackNode;Bo(n,r);var c=us(n,n===kt?Ct:0);if(c===0)a!==null&&Fs(a),n.callbackNode=null,n.callbackPriority=0;else if(r=c&-c,n.callbackPriority!==r){if(a!=null&&Fs(a),r===1)n.tag===0?ig(Lf.bind(null,n)):vd(Lf.bind(null,n)),tg(function(){(Je&6)===0&&Wr()}),a=null;else{switch(Ui(c)){case 1:a=Ws;break;case 4:a=zi;break;case 16:a=ls;break;case 536870912:a=Uo;break;default:a=ls}a=Bf(a,Mf.bind(null,n))}n.callbackPriority=r,n.callbackNode=a}}function Mf(n,r){if(Aa=-1,Ta=0,(Je&6)!==0)throw Error(s(327));var a=n.callbackNode;if(vi()&&n.callbackNode!==a)return null;var c=us(n,n===kt?Ct:0);if(c===0)return null;if((c&30)!==0||(c&n.expiredLanes)!==0||r)r=Ra(n,c);else{r=c;var p=Je;Je|=2;var m=Of();(kt!==n||Ct!==r)&&(kr=null,wi=lt()+500,Cs(n,r));do try{Ng();break}catch(N){Pf(n,N)}while(!0);zl(),Sa.current=m,Je=p,yt!==null?r=0:(kt=null,Ct=0,r=vt)}if(r!==0){if(r===2&&(p=un(n),p!==0&&(c=p,r=kc(n,p))),r===1)throw a=go,Cs(n,0),Jr(n,c),qt(n,lt()),a;if(r===6)Jr(n,c);else{if(p=n.current.alternate,(c&30)===0&&!jg(p)&&(r=Ra(n,c),r===2&&(m=un(n),m!==0&&(c=m,r=kc(n,m))),r===1))throw a=go,Cs(n,0),Jr(n,c),qt(n,lt()),a;switch(n.finishedWork=p,n.finishedLanes=c,r){case 0:case 1:throw Error(s(345));case 2:Es(n,Zt,kr);break;case 3:if(Jr(n,c),(c&130023424)===c&&(r=_c+500-lt(),10<r)){if(us(n,0)!==0)break;if(p=n.suspendedLanes,(p&c)!==c){Vt(),n.pingedLanes|=n.suspendedLanes&p;break}n.timeoutHandle=$l(Es.bind(null,n,Zt,kr),r);break}Es(n,Zt,kr);break;case 4:if(Jr(n,c),(c&4194240)===c)break;for(r=n.eventTimes,p=-1;0<c;){var _=31-Wt(c);m=1<<_,_=r[_],_>p&&(p=_),c&=~m}if(c=p,c=lt()-c,c=(120>c?120:480>c?480:1080>c?1080:1920>c?1920:3e3>c?3e3:4320>c?4320:1960*kg(c/1960))-c,10<c){n.timeoutHandle=$l(Es.bind(null,n,Zt,kr),c);break}Es(n,Zt,kr);break;case 5:Es(n,Zt,kr);break;default:throw Error(s(329))}}}return qt(n,lt()),n.callbackNode===a?Mf.bind(null,n):null}function kc(n,r){var a=yo;return n.current.memoizedState.isDehydrated&&(Cs(n,r).flags|=256),n=Ra(n,r),n!==2&&(r=Zt,Zt=a,r!==null&&jc(r)),n}function jc(n){Zt===null?Zt=n:Zt.push.apply(Zt,n)}function jg(n){for(var r=n;;){if(r.flags&16384){var a=r.updateQueue;if(a!==null&&(a=a.stores,a!==null))for(var c=0;c<a.length;c++){var p=a[c],m=p.getSnapshot;p=p.value;try{if(!On(m(),p))return!1}catch{return!1}}}if(a=r.child,r.subtreeFlags&16384&&a!==null)a.return=r,r=a;else{if(r===n)break;for(;r.sibling===null;){if(r.return===null||r.return===n)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function Jr(n,r){for(r&=~vc,r&=~Na,n.suspendedLanes|=r,n.pingedLanes&=~r,n=n.expirationTimes;0<r;){var a=31-Wt(r),c=1<<a;n[a]=-1,r&=~c}}function Lf(n){if((Je&6)!==0)throw Error(s(327));vi();var r=us(n,0);if((r&1)===0)return qt(n,lt()),null;var a=Ra(n,r);if(n.tag!==0&&a===2){var c=un(n);c!==0&&(r=c,a=kc(n,c))}if(a===1)throw a=go,Cs(n,0),Jr(n,r),qt(n,lt()),a;if(a===6)throw Error(s(345));return n.finishedWork=n.current.alternate,n.finishedLanes=r,Es(n,Zt,kr),qt(n,lt()),null}function Sc(n,r){var a=Je;Je|=1;try{return n(r)}finally{Je=a,Je===0&&(wi=lt()+500,ia&&Wr())}}function Ns(n){Hr!==null&&Hr.tag===0&&(Je&6)===0&&vi();var r=Je;Je|=1;var a=Nn.transition,c=Qe;try{if(Nn.transition=null,Qe=1,n)return n()}finally{Qe=c,Nn.transition=a,Je=r,(Je&6)===0&&Wr()}}function Nc(){pn=yi.current,it(yi)}function Cs(n,r){n.finishedWork=null,n.finishedLanes=0;var a=n.timeoutHandle;if(a!==-1&&(n.timeoutHandle=-1,eg(a)),yt!==null)for(a=yt.return;a!==null;){var c=a;switch(Ll(c),c.tag){case 1:c=c.type.childContextTypes,c!=null&&ra();break;case 3:pi(),it(Qt),it(Mt),Jl();break;case 5:Hl(c);break;case 4:pi();break;case 13:it(ct);break;case 19:it(ct);break;case 10:Wl(c.type._context);break;case 22:case 23:Nc()}a=a.return}if(kt=n,yt=n=Qr(n.current,null),Ct=pn=r,vt=0,go=null,vc=Na=Ss=0,Zt=yo=null,bs!==null){for(r=0;r<bs.length;r++)if(a=bs[r],c=a.interleaved,c!==null){a.interleaved=null;var p=c.next,m=a.pending;if(m!==null){var _=m.next;m.next=p,c.next=_}a.pending=c}bs=null}return n}function Pf(n,r){do{var a=yt;try{if(zl(),ma.current=va,ga){for(var c=ut.memoizedState;c!==null;){var p=c.queue;p!==null&&(p.pending=null),c=c.next}ga=!1}if(js=0,bt=wt=ut=null,co=!1,uo=0,wc.current=null,a===null||a.return===null){vt=1,go=r,yt=null;break}e:{var m=n,_=a.return,N=a,R=r;if(r=Ct,N.flags|=32768,R!==null&&typeof R=="object"&&typeof R.then=="function"){var z=R,ne=N,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=af(_);if(ge!==null){ge.flags&=-257,lf(ge,_,N,m,r),ge.mode&1&&of(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){of(m,z,r),Cc();break e}R=Error(s(426))}}else if(at&&N.mode&1){var mt=af(_);if(mt!==null){(mt.flags&65536)===0&&(mt.flags|=256),lf(mt,_,N,m,r),Dl(mi(R,N));break e}}m=R=mi(R,N),vt!==4&&(vt=2),yo===null?yo=[m]:yo.push(m),m=_;do{switch(m.tag){case 3:m.flags|=65536,r&=-r,m.lanes|=r;var O=rf(m,R,r);Ad(m,O);break e;case 1:N=R;var M=m.type,D=m.stateNode;if((m.flags&128)===0&&(typeof M.getDerivedStateFromError=="function"||D!==null&&typeof D.componentDidCatch=="function"&&(Gr===null||!Gr.has(D)))){m.flags|=65536,r&=-r,m.lanes|=r;var ue=sf(m,N,r);Ad(m,ue);break e}}m=m.return}while(m!==null)}Ff(a)}catch(je){r=je,yt===a&&a!==null&&(yt=a=a.return);continue}break}while(!0)}function Of(){var n=Sa.current;return Sa.current=va,n===null?va:n}function Cc(){(vt===0||vt===3||vt===2)&&(vt=4),kt===null||(Ss&268435455)===0&&(Na&268435455)===0||Jr(kt,Ct)}function Ra(n,r){var a=Je;Je|=2;var c=Of();(kt!==n||Ct!==r)&&(kr=null,Cs(n,r));do try{Sg();break}catch(p){Pf(n,p)}while(!0);if(zl(),Je=a,Sa.current=c,yt!==null)throw Error(s(261));return kt=null,Ct=0,vt}function Sg(){for(;yt!==null;)Df(yt)}function Ng(){for(;yt!==null&&!zs();)Df(yt)}function Df(n){var r=Uf(n.alternate,n,pn);n.memoizedProps=n.pendingProps,r===null?Ff(n):yt=r,wc.current=null}function Ff(n){var r=n;do{var a=r.alternate;if(n=r.return,(r.flags&32768)===0){if(a=wg(a,r,pn),a!==null){yt=a;return}}else{if(a=vg(a,r),a!==null){a.flags&=32767,yt=a;return}if(n!==null)n.flags|=32768,n.subtreeFlags=0,n.deletions=null;else{vt=6,yt=null;return}}if(r=r.sibling,r!==null){yt=r;return}yt=r=n}while(r!==null);vt===0&&(vt=5)}function Es(n,r,a){var c=Qe,p=Nn.transition;try{Nn.transition=null,Qe=1,Cg(n,r,a,c)}finally{Nn.transition=p,Qe=c}return null}function Cg(n,r,a,c){do vi();while(Hr!==null);if((Je&6)!==0)throw Error(s(327));a=n.finishedWork;var p=n.finishedLanes;if(a===null)return null;if(n.finishedWork=null,n.finishedLanes=0,a===n.current)throw Error(s(177));n.callbackNode=null,n.callbackPriority=0;var m=a.lanes|a.childLanes;if(Vs(n,m),n===kt&&(yt=kt=null,Ct=0),(a.subtreeFlags&2064)===0&&(a.flags&2064)===0||Ea||(Ea=!0,Bf(ls,function(){return vi(),null})),m=(a.flags&15990)!==0,(a.subtreeFlags&15990)!==0||m){m=Nn.transition,Nn.transition=null;var _=Qe;Qe=1;var N=Je;Je|=4,wc.current=null,xg(n,a),$f(a,n),Km(Cl),hs=!!Nl,Cl=Nl=null,n.current=a,bg(a),Di(),Je=N,Qe=_,Nn.transition=m}else n.current=a;if(Ea&&(Ea=!1,Hr=n,$a=p),m=n.pendingLanes,m===0&&(Gr=null),ln(a.stateNode),qt(n,lt()),r!==null)for(c=n.onRecoverableError,a=0;a<r.length;a++)p=r[a],c(p.value,{componentStack:p.stack,digest:p.digest});if(Ca)throw Ca=!1,n=xc,xc=null,n;return($a&1)!==0&&n.tag!==0&&vi(),m=n.pendingLanes,(m&1)!==0?n===bc?wo++:(wo=0,bc=n):wo=0,Wr(),null}function vi(){if(Hr!==null){var n=Ui($a),r=Nn.transition,a=Qe;try{if(Nn.transition=null,Qe=16>n?16:n,Hr===null)var c=!1;else{if(n=Hr,Hr=null,$a=0,(Je&6)!==0)throw Error(s(331));var p=Je;for(Je|=4,_e=n.current;_e!==null;){var m=_e,_=m.child;if((_e.flags&16)!==0){var N=m.deletions;if(N!==null){for(var R=0;R<N.length;R++){var z=N[R];for(_e=z;_e!==null;){var ne=_e;switch(ne.tag){case 0:case 11:case 15:mo(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(jf(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 mt=be.sibling;be.sibling=null,be=mt}while(be!==null)}}_e=m}}if((m.subtreeFlags&2064)!==0&&_!==null)_.return=m,_e=_;else e:for(;_e!==null;){if(m=_e,(m.flags&2048)!==0)switch(m.tag){case 0:case 11:case 15:mo(9,m,m.return)}var O=m.sibling;if(O!==null){O.return=m.return,_e=O;break e}_e=m.return}}var M=n.current;for(_e=M;_e!==null;){_=_e;var D=_.child;if((_.subtreeFlags&2064)!==0&&D!==null)D.return=_,_e=D;else e:for(_=M;_e!==null;){if(N=_e,(N.flags&2048)!==0)try{switch(N.tag){case 0:case 11:case 15:ja(9,N)}}catch(je){dt(N,N.return,je)}if(N===_){_e=null;break e}var ue=N.sibling;if(ue!==null){ue.return=N.return,_e=ue;break e}_e=N.return}}if(Je=p,Wr(),Le&&typeof Le.onPostCommitFiberRoot=="function")try{Le.onPostCommitFiberRoot(wn,n)}catch{}c=!0}return c}finally{Qe=a,Nn.transition=r}}return!1}function zf(n,r,a){r=mi(a,r),r=rf(n,r,1),n=Br(n,r,1),r=Vt(),n!==null&&(Mn(n,1,r),qt(n,r))}function dt(n,r,a){if(n.tag===3)zf(n,n,a);else for(;r!==null;){if(r.tag===3){zf(r,n,a);break}else if(r.tag===1){var c=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(Gr===null||!Gr.has(c))){n=mi(a,n),n=sf(r,n,1),r=Br(r,n,1),n=Vt(),r!==null&&(Mn(r,1,n),qt(r,n));break}}r=r.return}}function Eg(n,r,a){var c=n.pingCache;c!==null&&c.delete(r),r=Vt(),n.pingedLanes|=n.suspendedLanes&a,kt===n&&(Ct&a)===a&&(vt===4||vt===3&&(Ct&130023424)===Ct&&500>lt()-_c?Cs(n,0):vc|=a),qt(n,r)}function Wf(n,r){r===0&&((n.mode&1)===0?r=1:(r=cs,cs<<=1,(cs&130023424)===0&&(cs=4194304)));var a=Vt();n=_r(n,r),n!==null&&(Mn(n,r,a),qt(n,a))}function $g(n){var r=n.memoizedState,a=0;r!==null&&(a=r.retryLane),Wf(n,a)}function Ag(n,r){var a=0;switch(n.tag){case 13:var c=n.stateNode,p=n.memoizedState;p!==null&&(a=p.retryLane);break;case 19:c=n.stateNode;break;default:throw Error(s(314))}c!==null&&c.delete(r),Wf(n,a)}var Uf;Uf=function(n,r,a){if(n!==null)if(n.memoizedProps!==r.pendingProps||Qt.current)Xt=!0;else{if((n.lanes&a)===0&&(r.flags&128)===0)return Xt=!1,yg(n,r,a);Xt=(n.flags&131072)!==0}else Xt=!1,at&&(r.flags&1048576)!==0&&_d(r,aa,r.index);switch(r.lanes=0,r.tag){case 2:var c=r.type;ba(n,r),n=r.pendingProps;var p=ai(r,Mt.current);hi(r,a),p=Xl(null,r,c,n,p,a);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,Yt(c)?(m=!0,sa(r)):m=!1,r.memoizedState=p.state!==null&&p.state!==void 0?p.state:null,Vl(r),p.updater=_a,r.stateNode=p,p._reactInternals=r,sc(r,c,n,a),r=lc(null,r,c,!0,m,a)):(r.tag=0,at&&m&&Ml(r),Bt(null,r,p,a),r=r.child),r;case 16:c=r.elementType;e:{switch(ba(n,r),n=r.pendingProps,p=c._init,c=p(c._payload),r.type=c,p=r.tag=Rg(c),n=Fn(c,n),p){case 0:r=ac(null,r,c,n,a);break e;case 1:r=pf(null,r,c,n,a);break e;case 11:r=cf(null,r,c,n,a);break e;case 14:r=uf(null,r,c,Fn(c.type,n),a);break e}throw Error(s(306,c,""))}return r;case 0:return c=r.type,p=r.pendingProps,p=r.elementType===c?p:Fn(c,p),ac(n,r,c,p,a);case 1:return c=r.type,p=r.pendingProps,p=r.elementType===c?p:Fn(c,p),pf(n,r,c,p,a);case 3:e:{if(mf(r),n===null)throw Error(s(387));c=r.pendingProps,m=r.memoizedState,p=m.element,$d(n,r),ha(r,c,null,a);var _=r.memoizedState;if(c=_.element,m.isDehydrated)if(m={element:c,isDehydrated:!1,cache:_.cache,pendingSuspenseBoundaries:_.pendingSuspenseBoundaries,transitions:_.transitions},r.updateQueue.baseState=m,r.memoizedState=m,r.flags&256){p=mi(Error(s(423)),r),r=gf(n,r,c,a,p);break e}else if(c!==p){p=mi(Error(s(424)),r),r=gf(n,r,c,a,p);break e}else for(hn=Dr(r.stateNode.containerInfo.firstChild),fn=r,at=!0,Dn=null,a=Cd(r,null,c,a),r.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(ui(),c===p){r=br(n,r,a);break e}Bt(n,r,c,a)}r=r.child}return r;case 5:return Rd(r),n===null&&Ol(r),c=r.type,p=r.pendingProps,m=n!==null?n.memoizedProps:null,_=p.children,El(c,p)?_=null:m!==null&&El(c,m)&&(r.flags|=32),hf(n,r),Bt(n,r,_,a),r.child;case 6:return n===null&&Ol(r),null;case 13:return yf(n,r,a);case 4:return Gl(r,r.stateNode.containerInfo),c=r.pendingProps,n===null?r.child=di(r,null,c,a):Bt(n,r,c,a),r.child;case 11:return c=r.type,p=r.pendingProps,p=r.elementType===c?p:Fn(c,p),cf(n,r,c,p,a);case 7:return Bt(n,r,r.pendingProps,a),r.child;case 8:return Bt(n,r,r.pendingProps.children,a),r.child;case 12:return Bt(n,r,r.pendingProps.children,a),r.child;case 10:e:{if(c=r.type._context,p=r.pendingProps,m=r.memoizedProps,_=p.value,nt(ua,c._currentValue),c._currentValue=_,m!==null)if(On(m.value,_)){if(m.children===p.children&&!Qt.current){r=br(n,r,a);break e}}else for(m=r.child,m!==null&&(m.return=r);m!==null;){var N=m.dependencies;if(N!==null){_=m.child;for(var R=N.firstContext;R!==null;){if(R.context===c){if(m.tag===1){R=xr(-1,a&-a),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|=a,R=m.alternate,R!==null&&(R.lanes|=a),Ul(m.return,a,r),N.lanes|=a;break}R=R.next}}else if(m.tag===10)_=m.type===r.type?null:m.child;else if(m.tag===18){if(_=m.return,_===null)throw Error(s(341));_.lanes|=a,N=_.alternate,N!==null&&(N.lanes|=a),Ul(_,a,r),_=m.sibling}else _=m.child;if(_!==null)_.return=m;else for(_=m;_!==null;){if(_===r){_=null;break}if(m=_.sibling,m!==null){m.return=_.return,_=m;break}_=_.return}m=_}Bt(n,r,p.children,a),r=r.child}return r;case 9:return p=r.type,c=r.pendingProps.children,hi(r,a),p=jn(p),c=c(p),r.flags|=1,Bt(n,r,c,a),r.child;case 14:return c=r.type,p=Fn(c,r.pendingProps),p=Fn(c.type,p),uf(n,r,c,p,a);case 15:return df(n,r,r.type,r.pendingProps,a);case 17:return c=r.type,p=r.pendingProps,p=r.elementType===c?p:Fn(c,p),ba(n,r),r.tag=1,Yt(c)?(n=!0,sa(r)):n=!1,hi(r,a),tf(r,c,p),sc(r,c,p,a),lc(null,r,c,!0,n,a);case 19:return vf(n,r,a);case 22:return ff(n,r,a)}throw Error(s(156,r.tag))};function Bf(n,r){return Oi(n,r)}function Tg(n,r,a,c){this.tag=n,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=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 Cn(n,r,a,c){return new Tg(n,r,a,c)}function Ec(n){return n=n.prototype,!(!n||!n.isReactComponent)}function Rg(n){if(typeof n=="function")return Ec(n)?1:0;if(n!=null){if(n=n.$$typeof,n===U)return 11;if(n===ce)return 14}return 2}function Qr(n,r){var a=n.alternate;return a===null?(a=Cn(n.tag,r,n.key,n.mode),a.elementType=n.elementType,a.type=n.type,a.stateNode=n.stateNode,a.alternate=n,n.alternate=a):(a.pendingProps=r,a.type=n.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=n.flags&14680064,a.childLanes=n.childLanes,a.lanes=n.lanes,a.child=n.child,a.memoizedProps=n.memoizedProps,a.memoizedState=n.memoizedState,a.updateQueue=n.updateQueue,r=n.dependencies,a.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},a.sibling=n.sibling,a.index=n.index,a.ref=n.ref,a}function Ia(n,r,a,c,p,m){var _=2;if(c=n,typeof n=="function")Ec(n)&&(_=1);else if(typeof n=="string")_=5;else e:switch(n){case H:return $s(a.children,p,m,r);case L:_=8,p|=8;break;case de:return n=Cn(12,a,r,p|2),n.elementType=de,n.lanes=m,n;case J:return n=Cn(13,a,r,p),n.elementType=J,n.lanes=m,n;case fe:return n=Cn(19,a,r,p),n.elementType=fe,n.lanes=m,n;case ve:return Ma(a,p,m,r);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case re:_=10;break e;case Q:_=9;break e;case U:_=11;break e;case ce:_=14;break e;case ye:_=16,c=null;break e}throw Error(s(130,n==null?n:typeof n,""))}return r=Cn(_,a,r,p),r.elementType=n,r.type=c,r.lanes=m,r}function $s(n,r,a,c){return n=Cn(7,n,c,r),n.lanes=a,n}function Ma(n,r,a,c){return n=Cn(22,n,c,r),n.elementType=ve,n.lanes=a,n.stateNode={isHidden:!1},n}function $c(n,r,a){return n=Cn(6,n,null,r),n.lanes=a,n}function Ac(n,r,a){return r=Cn(4,n.children!==null?n.children:[],n.key,r),r.lanes=a,r.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},r}function Ig(n,r,a,c,p){this.tag=r,this.containerInfo=n,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Kn(0),this.expirationTimes=Kn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Kn(0),this.identifierPrefix=c,this.onRecoverableError=p,this.mutableSourceEagerHydrationData=null}function Tc(n,r,a,c,p,m,_,N,R){return n=new Ig(n,r,a,N,R),r===1?(r=1,m===!0&&(r|=8)):r=0,m=Cn(3,null,null,r),n.current=m,m.stateNode=n,m.memoizedState={element:c,isDehydrated:a,cache:null,transitions:null,pendingSuspenseBoundaries:null},Vl(m),n}function Mg(n,r,a){var c=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:V,key:c==null?null:""+c,children:n,containerInfo:r,implementation:a}}function Vf(n){if(!n)return zr;n=n._reactInternals;e:{if(an(n)!==n||n.tag!==1)throw Error(s(170));var r=n;do{switch(r.tag){case 3:r=r.stateNode.context;break e;case 1:if(Yt(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}}r=r.return}while(r!==null);throw Error(s(171))}if(n.tag===1){var a=n.type;if(Yt(a))return yd(n,a,r)}return r}function Gf(n,r,a,c,p,m,_,N,R){return n=Tc(a,c,!0,n,p,m,_,N,R),n.context=Vf(null),a=n.current,c=Vt(),p=Kr(a),m=xr(c,p),m.callback=r??null,Br(a,m,p),n.current.lanes=p,Mn(n,p,c),qt(n,c),n}function La(n,r,a,c){var p=r.current,m=Vt(),_=Kr(p);return a=Vf(a),r.context===null?r.context=a:r.pendingContext=a,r=xr(m,_),r.payload={element:n},c=c===void 0?null:c,c!==null&&(r.callback=c),n=Br(p,r,_),n!==null&&(Un(n,p,_,m),fa(n,p,_)),_}function Pa(n){if(n=n.current,!n.child)return null;switch(n.child.tag){case 5:return n.child.stateNode;default:return n.child.stateNode}}function Hf(n,r){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var a=n.retryLane;n.retryLane=a!==0&&a<r?a:r}}function Rc(n,r){Hf(n,r),(n=n.alternate)&&Hf(n,r)}function Lg(){return null}var Kf=typeof reportError=="function"?reportError:function(n){console.error(n)};function Ic(n){this._internalRoot=n}Oa.prototype.render=Ic.prototype.render=function(n){var r=this._internalRoot;if(r===null)throw Error(s(409));La(n,r,null,null)},Oa.prototype.unmount=Ic.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var r=n.containerInfo;Ns(function(){La(null,n,null,null)}),r[gr]=null}};function Oa(n){this._internalRoot=n}Oa.prototype.unstable_scheduleHydration=function(n){if(n){var r=Hs();n={blockedOn:null,target:n,priority:r};for(var a=0;a<Qn.length&&r!==0&&r<Qn[a].priority;a++);Qn.splice(a,0,n),a===0&&Go(n)}};function Mc(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function Da(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11&&(n.nodeType!==8||n.nodeValue!==" react-mount-point-unstable "))}function Jf(){}function Pg(n,r,a,c,p){if(p){if(typeof c=="function"){var m=c;c=function(){var z=Pa(_);m.call(z)}}var _=Gf(r,c,n,0,null,!1,!1,"",Jf);return n._reactRootContainer=_,n[gr]=_.current,to(n.nodeType===8?n.parentNode:n),Ns(),_}for(;p=n.lastChild;)n.removeChild(p);if(typeof c=="function"){var N=c;c=function(){var z=Pa(R);N.call(z)}}var R=Tc(n,0,!1,null,null,!1,!1,"",Jf);return n._reactRootContainer=R,n[gr]=R.current,to(n.nodeType===8?n.parentNode:n),Ns(function(){La(r,R,a,c)}),R}function Fa(n,r,a,c,p){var m=a._reactRootContainer;if(m){var _=m;if(typeof p=="function"){var N=p;p=function(){var R=Pa(_);N.call(R)}}La(r,_,n,p)}else _=Pg(a,r,n,p,c);return Pa(_)}Gs=function(n){switch(n.tag){case 3:var r=n.stateNode;if(r.current.memoizedState.isDehydrated){var a=vn(r.pendingLanes);a!==0&&(Ut(r,a|1),qt(r,lt()),(Je&6)===0&&(wi=lt()+500,Wr()))}break;case 13:Ns(function(){var c=_r(n,1);if(c!==null){var p=Vt();Un(c,n,1,p)}}),Rc(n,1)}},Bi=function(n){if(n.tag===13){var r=_r(n,134217728);if(r!==null){var a=Vt();Un(r,n,134217728,a)}Rc(n,134217728)}},Vi=function(n){if(n.tag===13){var r=Kr(n),a=_r(n,r);if(a!==null){var c=Vt();Un(a,n,r,c)}Rc(n,r)}},Hs=function(){return Qe},Tr=function(n,r){var a=Qe;try{return Qe=n,r()}finally{Qe=a}},Os=function(n,r,a){switch(r){case"input":if(Pe(n,a),r=a.name,a.type==="radio"&&r!=null){for(a=n;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll("input[name="+JSON.stringify(""+r)+'][type="radio"]'),r=0;r<a.length;r++){var c=a[r];if(c!==n&&c.form===n.form){var p=na(c);if(!p)throw Error(s(90));X(c),Pe(c,p)}}}break;case"textarea":He(n,a);break;case"select":r=a.value,r!=null&&me(n,!!a.multiple,r,!1)}},cr=Sc,Ht=Ns;var Og={usingClientEntryPoint:!1,Events:[so,ii,na,Fo,Mi,Sc]},vo={findFiberByHostInstance:ws,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Dg={bundleType:vo.bundleType,version:vo.version,rendererPackageName:vo.rendererPackageName,rendererConfig:vo.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:j.ReactCurrentDispatcher,findHostInstanceByFiber:function(n){return n=Ds(n),n===null?null:n.stateNode},findFiberByHostInstance:vo.findFiberByHostInstance||Lg,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 za=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!za.isDisabled&&za.supportsFiber)try{wn=za.inject(Dg),Le=za}catch{}}return en.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Og,en.createPortal=function(n,r){var a=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Mc(r))throw Error(s(200));return Mg(n,r,null,a)},en.createRoot=function(n,r){if(!Mc(n))throw Error(s(299));var a=!1,c="",p=Kf;return r!=null&&(r.unstable_strictMode===!0&&(a=!0),r.identifierPrefix!==void 0&&(c=r.identifierPrefix),r.onRecoverableError!==void 0&&(p=r.onRecoverableError)),r=Tc(n,1,!1,null,null,a,!1,c,p),n[gr]=r.current,to(n.nodeType===8?n.parentNode:n),new Ic(r)},en.findDOMNode=function(n){if(n==null)return null;if(n.nodeType===1)return n;var r=n._reactInternals;if(r===void 0)throw typeof n.render=="function"?Error(s(188)):(n=Object.keys(n).join(","),Error(s(268,n)));return n=Ds(r),n=n===null?null:n.stateNode,n},en.flushSync=function(n){return Ns(n)},en.hydrate=function(n,r,a){if(!Da(r))throw Error(s(200));return Fa(null,n,r,!0,a)},en.hydrateRoot=function(n,r,a){if(!Mc(n))throw Error(s(405));var c=a!=null&&a.hydratedSources||null,p=!1,m="",_=Kf;if(a!=null&&(a.unstable_strictMode===!0&&(p=!0),a.identifierPrefix!==void 0&&(m=a.identifierPrefix),a.onRecoverableError!==void 0&&(_=a.onRecoverableError)),r=Gf(r,null,n,1,a??null,p,!1,m,_),n[gr]=r.current,to(n),c)for(n=0;n<c.length;n++)a=c[n],p=a._getVersion,p=p(a._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[a,p]:r.mutableSourceEagerHydrationData.push(a,p);return new Oa(r)},en.render=function(n,r,a){if(!Da(r))throw Error(s(200));return Fa(null,n,r,!1,a)},en.unmountComponentAtNode=function(n){if(!Da(n))throw Error(s(40));return n._reactRootContainer?(Ns(function(){Fa(null,null,n,!1,function(){n._reactRootContainer=null,n[gr]=null})}),!0):!1},en.unstable_batchedUpdates=Sc,en.unstable_renderSubtreeIntoContainer=function(n,r,a,c){if(!Da(a))throw Error(s(200));if(n==null||n._reactInternals===void 0)throw Error(s(38));return Fa(n,r,a,!1,c)},en.version="18.3.1-next-f1338f8080-20240426",en}var nh;function tp(){if(nh)return Oc.exports;nh=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Oc.exports=Kg(),Oc.exports}var rh;function Jg(){if(rh)return Wa;rh=1;var e=tp();return Wa.createRoot=e.createRoot,Wa.hydrateRoot=e.hydrateRoot,Wa}var Qg=Jg();const Yg=ep(Qg),np=[{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"]}];np.map(e=>({id:e.id,label:e.label}));function Xg(e){return`theme-${String(e||"").trim()||"dark"}`}function sh(e){try{const t=document.documentElement,s=Array.from(t.classList).filter(o=>o.startsWith("theme-"));for(const o of s)t.classList.remove(o);t.classList.add(Xg(e))}catch{}}const iu=[{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}],ou=[{id:"compact",label:"Compact",density:.85},{id:"standard",label:"Standard",density:1},{id:"spacious",label:"Spacious",density:1.2}];function Zg(e){const t=String(e).trim();return iu.find(s=>s.id===t)||iu[1]}function qg(e){const t=String(e).trim();return ou.find(s=>s.id===t)||ou[1]}function ih(e){try{const t=document.documentElement,s=Zg(e.font_scale||"md"),o=qg(e.header_density||"standard");t.style.setProperty("--font-scale",String(s.scale)),t.style.setProperty("--header-density",String(o.density))}catch{}}const oh={md:"(max-width: 1023.98px)",lg:"(max-width: 1439.98px)"};function ey(e){try{return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(e).matches}catch{return!1}}function ah(e){const[t,s]=w.useState(()=>ey(e));return w.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const o=window.matchMedia(e),l=()=>s(o.matches);return l(),typeof o.addEventListener=="function"?o.addEventListener("change",l):o.addListener(l),()=>{typeof o.removeEventListener=="function"?o.removeEventListener("change",l):o.removeListener(l)}},[e]),t}let xo=null;function ty(e,t){const s=Math.max(0,Math.round(e));if(!(t.scale<=1.01))return{vvHeight:s,keyboardInset:0};const o=Math.max(0,Math.min(s,Math.round(t.height))),l=Math.max(0,Math.round(e-t.height-Math.max(0,t.offsetTop)));return{vvHeight:o,keyboardInset:l}}function ny(){if(xo)return xo;if(typeof window>"u"||typeof document>"u")return()=>{};const e=window.visualViewport;if(!e)return()=>{};const t=document.documentElement;let s=0;const o=()=>{s=0;const{vvHeight:u,keyboardInset:d}=ty(window.innerHeight,{height:e.height,offsetTop:e.offsetTop,scale:e.scale||1});t.style.setProperty("--vv-height",`${u}px`),t.style.setProperty("--keyboard-inset",`${d}px`)},l=()=>{s||(s=window.requestAnimationFrame(o))};return o(),e.addEventListener("resize",l),e.addEventListener("scroll",l),window.addEventListener("orientationchange",l),xo=()=>{e.removeEventListener("resize",l),e.removeEventListener("scroll",l),window.removeEventListener("orientationchange",l),s&&window.cancelAnimationFrame(s),t.style.removeProperty("--vv-height"),t.style.removeProperty("--keyboard-inset"),xo=null},xo}var rp=tp();function _i(...e){return e.filter(Boolean).join(" ")}function ts({value:e,options:t,placeholder:s="Select…",disabled:o=!1,loading:l=!1,searchable:u=!0,searchPlaceholder:d="Search…",allowCustom:f=!1,clearable:h=!1,minPopoverWidth:g=240,variant:y="panel",className:v,triggerClassName:x,ariaLabel:b,id:k,includeValueOption:E=!1,onOpen:S,customOptionLabel:T,validateCustomValue:A,onChange:$,renderOption:j,renderValue:P}){const V=w.useRef(null),H=w.useRef(null),L=w.useRef(null),de=w.useRef(S),re=w.useId(),Q=k||`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),[ae,G]=w.useState("bottom"),[C,B]=w.useState({left:0,top:0,width:0});w.useEffect(()=>{de.current=S},[S]);const F=w.useMemo(()=>{if(!E)return t;const K=String(e??"").trim();return!K||t.some(me=>me.value===K)?t:[...t,{value:K,label:K}]},[E,t,e]),W=w.useMemo(()=>{const K=String(e??"");return F.find(me=>me.value===K)||null},[F,e]),oe=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 Fe=(A==null?void 0:A(K,{options:F}))||"";return{value:K,label:T?T(K):`Use "${K}"`,disabled:!!Fe,reason:Fe}},[f,T,F,ce,A]),Z=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:oe||me}]:K},[he,le,l,oe,e]),Ce=w.useCallback(()=>{const K=V.current;if(!K)return;const me=K.getBoundingClientRect(),Fe=Math.max(me.width,g),Ke=Math.max(8,Math.min(me.left,window.innerWidth-Fe-8)),He=window.innerHeight-me.bottom,or=me.top,Tt=He>=220||He>=or?"bottom":"top";G(Tt);const An=Tt==="bottom"?me.bottom+6:me.top-6;B({left:Ke,top:An,width:Fe})},[g]),Ue=w.useCallback(()=>{fe(!1),ye("")},[]);w.useEffect(()=>{var K;J&&((K=de.current)==null||K.call(de))},[J]),w.useEffect(()=>{if(!J)return;Ce();const K=()=>Ce();return window.addEventListener("resize",K),window.addEventListener("scroll",K,!0),()=>{window.removeEventListener("resize",K),window.removeEventListener("scroll",K,!0)}},[J,Ce]),w.useEffect(()=>{if(!J)return;const K=me=>{var Ke,He;const Fe=me.target;Fe&&((Ke=V.current)!=null&&Ke.contains(Fe)||(He=H.current)!=null&&He.contains(Fe)||Ue())};return document.addEventListener("mousedown",K,!0),()=>document.removeEventListener("mousedown",K,!0)},[J,Ue]),w.useEffect(()=>{if(!J)return;const K=Math.max(0,Z.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,Z]);const ke=K=>{var Fe;const me=Z.find(Ke=>Ke.value===K);me!=null&&me.disabled||($(K),Ue(),(Fe=V.current)==null||Fe.focus())},X=K=>{var me,Fe;if(K.key==="Escape")return K.preventDefault(),Ue(),(me=V.current)==null||me.focus(),!0;if(K.key==="Tab")return Ue(),(Fe=V.current)==null||Fe.focus(),!1;if(K.key==="ArrowDown")return K.preventDefault(),q(Ke=>Math.min(Ke+1,Math.max(0,Z.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,Z.length-1)),!0;if(K.key==="Enter"){K.preventDefault();const Ke=Z[ve];return Ke&&ke(Ke.value),!0}return!1},ee=K=>{if(!o){if(J){if(X(K))return;if(K.key===" "&&!u){K.preventDefault();const me=Z[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(),De=pe?oe:s,we=he!=null&&he.disabled?he.reason||"Unavailable":"",Pe=J&&Z.length>0?`${Q}-opt-${ve}`:void 0,Ve=i.jsx("span",{className:_i("af-select-value",!pe&&"af-select-value--placeholder"),children:l&&!pe?"Loading…":De}),rt=P?P(W,String(e||"")):Ve;return i.jsxs("span",{className:_i("af-select",y==="pin"?"af-select--pin":"af-select--panel",v),children:[i.jsxs("button",{ref:V,id:Q,type:"button",className:_i("af-select-trigger",h&&pe&&"af-select-trigger--clearable",x),disabled:o,onMouseDown:K=>K.stopPropagation(),onClick:K=>{K.stopPropagation(),!o&&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":b,children:[rt,i.jsx("span",{className:_i("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:o,onMouseDown:K=>{K.preventDefault(),K.stopPropagation()},onClick:K=>{var me;K.preventDefault(),K.stopPropagation(),$(""),Ue(),(me=V.current)==null||me.focus()},title:"Clear",children:"×"}):null,J?rp.createPortal(i.jsxs("div",{ref:H,className:_i("af-select-popover",ae==="top"&&"af-select-popover--top"),style:{position:"fixed",left:`${C.left}px`,top:`${C.top}px`,width:`${C.width}px`},onMouseDown:K=>K.stopPropagation(),onClick:K=>K.stopPropagation(),onWheel:K=>K.stopPropagation(),onKeyDown:X,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:X,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":b,children:l&&Z.length===0?i.jsx("div",{className:"af-select-empty",children:"Loading…"}):Z.length===0?i.jsx("div",{className:"af-select-empty",children:"No results"}):Z.map((K,me)=>{var An;const Fe=K.value===e,Ke=me===ve,He=String(K.group||"").trim(),or=me>0?String(((An=Z[me-1])==null?void 0:An.group)||"").trim():"",Tt=!!He&&He!==or;return i.jsxs(gt.Fragment,{children:[Tt?i.jsx("div",{className:"af-select-group",role:"presentation",children:He}):null,i.jsx("div",{id:`${Q}-opt-${me}`,role:"option","aria-selected":Fe,className:_i("af-select-option",Fe&&"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:Tn=>{Tn.preventDefault(),Tn.stopPropagation()},onClick:()=>ke(K.value),"aria-disabled":K.disabled?!0:void 0,children:j?j(K,{selected:Fe,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]}),Fe?i.jsx("span",{className:"af-select-check",children:"✓"}):null]})})]},K.value)})})]}),document.body):null]})}function ry(e){const t=new Set,s=[];for(const o of e||[]){if(!o||typeof o!="object")continue;const l=String(o.name||"").trim();!l||t.has(l)||(t.add(l),s.push({name:l,display_name:typeof o.display_name=="string"?o.display_name:void 0}))}return s.sort((o,l)=>o.name.localeCompare(l.name)),s}function sy(e){const t=new Set,s=[];for(const o of e||[]){const l=String(o||"").trim();!l||t.has(l)||(t.add(l),s.push(l))}return s.sort(),s}function iy(e){const t=e.disabled===!0,s=e.layout||"stack",o=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(),v=ry(e.providers),x=sy(e.models),b=t||!!e.loadingProviders,k=t||!!e.loadingModels,E=[...o?[{value:"",label:l}]:[],...v.map(T=>({value:T.name,label:T.display_name?`${T.display_name} (${T.name})`:T.name}))],S=[...o?[{value:"",label:l}]:[],...x.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(ts,{value:g,options:E,placeholder:o?l:f,disabled:b,loading:!!e.loadingProviders,searchable:!0,allowCustom:e.allowCustomProvider===!0,clearable:o,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(ts,{value:y,options:S,placeholder:o?l:h,disabled:k,loading:!!e.loadingModels,searchable:!0,allowCustom:e.allowCustomModel===!0,clearable:o,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 sp(e){if(e===!1||e&&typeof e=="object"&&e.mode==="off")return!1;if(!e||typeof e!="object")return;const t=e;if(!(t.mode!=="native_mtp"||!Number.isInteger(t.num_draft_tokens)||Number(t.num_draft_tokens)<1))return{mode:"native_mtp",num_draft_tokens:Number(t.num_draft_tokens),require_acceleration:!0}}function oy(e){var s;const t=(s=e==null?void 0:e.execution)==null?void 0:s.speculation;return!t||typeof t.supported!="boolean"?null:{supported:t.supported,ready:typeof t.ready=="boolean"?t.ready:null,reason:typeof t.reason=="string"?t.reason:null,supported_depths:t.supported&&Array.isArray(t.supported_depths)?[...new Set(t.supported_depths.filter(o=>typeof o=="number"&&Number.isInteger(o)&&o>0))]:[],default:Object.prototype.hasOwnProperty.call(t,"effective_default")?t.effective_default:t.default,requires_reload:typeof t.requires_reload=="boolean"?t.requires_reload:null}}function lh(e){const t=sp(e);return t===!1?"off":t?String(t.num_draft_tokens):""}function ay(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 ly(e){const t=oy(e.capabilities),s=lh(e.value),o=(t==null?void 0:t.supported_depths.map(String))||[],l=lh(t==null?void 0:t.default),u=e.inheritLabel||"Workflow / Gateway default",d=l?`${u} (${l==="off"?"Off":`depth ${l}`})`:u,f=e.error||(e.loading?"Checking MTP capability…":t?t.reason||(t.requires_reload?"Model reload required before MTP can run.":t.ready===!1?"MTP is supported but not ready on this instance.":t.ready===null&&t.supported?"MTP support verified; loaded-instance readiness is unknown.":t.supported?"":"MTP is not supported on this model/backend."):"MTP capability unknown; no depth is assumed.");return i.jsxs("div",{className:"af-pmp__speculation",children:[i.jsx("label",{children:"MTP depth"}),i.jsx(ts,{ariaLabel:"MTP depth",value:s,placeholder:d,disabled:e.disabled||e.loading,options:[{value:"",label:d},{value:"off",label:"Off"},...o.map(h=>({value:h,label:`Depth ${h}`})),...s&&s!=="off"&&!o.includes(s)?[{value:s,label:`Depth ${s} (saved; not available)`}]:[]],onChange:h=>e.onChange(ay(h))}),f?i.jsx("div",{role:"status",className:"af-pmp__hint",children:f}):null]})}function bu(e){var q,ae;const t=e.disabled===!0,s=e.value||{provider:"",model:""},o=!String(s.provider||"").trim()&&!String(s.model||"").trim(),[l,u]=w.useState(!o),d=o&&!l,f=w.useRef(o);w.useEffect(()=>{o&&!f.current&&u(!1),f.current=o},[o]);const[h,g]=w.useState([]),[y,v]=w.useState(!1),[x,b]=w.useState(""),[k,E]=w.useState([]),[S,T]=w.useState(!1),[A,$]=w.useState(""),j=w.useRef(e);j.current=e,w.useEffect(()=>{if(d||t)return;let G=!0;return v(!0),(async()=>{try{const C=await j.current.fetchProviders();if(!G)return;g(Array.isArray(C)?C:[]),b("")}catch(C){if(!G)return;g([]),b(`#FALLBACK provider discovery failed: ${String((C==null?void 0:C.message)||C)}`)}finally{G&&v(!1)}})(),()=>{G=!1}},[d,t]);const P=String(s.provider||"").trim();w.useEffect(()=>{if(!P||t){E([]),$(""),T(!1);return}let G=!0;return E([]),T(!0),$(""),(async()=>{try{const C=await j.current.fetchModels(P);if(!G)return;E(Array.isArray(C)?C:[])}catch(C){if(!G)return;E([]),$(`#FALLBACK model discovery failed: ${String((C==null?void 0:C.message)||C)}`)}finally{G&&T(!1)}})(),()=>{G=!1}},[P,t]);const V=w.useMemo(()=>{const G=[...h];return P&&!G.some(C=>C.name===P)&&G.unshift({name:P}),G},[h,P]),H=String(s.model||"").trim(),L=w.useMemo(()=>{const G=[...k];return H&&!G.includes(H)&&G.unshift(H),G},[k,H]),de=e.defaultModeLabel||"Gateway default",re=e.customModeLabel||"Custom",Q=P||((q=e.effectiveDefault)==null?void 0:q.provider)||"",U=H||(P?"":(ae=e.effectiveDefault)==null?void 0:ae.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||t))return j.current.fetchModelCapabilities(U,Q).then(C=>{var oe;if(!G)return;if(C!=null&&C.error)throw new Error(String(C.error));ve(C);const B=(C==null?void 0:C.capabilities)||C||{},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&&((oe=B.thinking_control)!=null&&oe.prompt_disable_token)&&W.push("off","auto"),fe({levels:W,error:"",loading:!1})}).catch(C=>{G&&fe({levels:[],error:`Reasoning options unavailable: ${String((C==null?void 0:C.message)||C)}`,loading:!1})}),()=>{G=!1}},[Q,U,ce,t]),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:t,children:de}),i.jsx("button",{type:"button",role:"tab","aria-selected":!d,className:`af-pmp__seg-btn${d?"":" is-active"}`,onClick:()=>{u(!0)},disabled:t,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(iy,{provider:P,model:H,providers:V,models:L,disabled:t,loadingProviders:y,loadingModels:S,providerError:x||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(ts,{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:t||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(ly,{value:s.speculation,onChange:G=>e.onChange({...s,speculation:G}),capabilities:ye,disabled:t,loading:J.loading,error:J.error?J.error.replace("Reasoning options","MTP options"):void 0}):null]})}function ch(...e){return e.filter(Boolean).join(" ")}function cy({kicker:e="AbstractGateway connection",title:t="Connect to AbstractGateway",description:s="Sign in with the Gateway user token assigned by the Gateway admin.",statusLabel:o="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:v="admin",onUserIdChange:x,token:b,tokenPlaceholder:k="Paste Gateway user token",showToken:E=!1,onTokenChange:S,onShowTokenChange:T,remember:A=!1,rememberLabel:$="Remember this browser",onRememberChange:j,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:ae}){const G=P||V,C=G||H||!String(y||"").trim()||!String(b||"").trim(),B=F=>{F.preventDefault(),!C&&ve()};return i.jsxs("form",{className:ch("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:t}),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:ch("af-gateway-signin__status",`af-gateway-signin__status--${l}`),children:o}),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=>x(F.target.value),placeholder:v,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:E?"text":"password",value:b,onChange:F=>S(F.target.value),placeholder:k,autoComplete:"current-password",disabled:G}),i.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:()=>T==null?void 0:T(!E),disabled:G,children:E?"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=>j==null?void 0:j(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(ae==null?void 0:ae()),disabled:G,children:Q}):null,i.jsx("button",{className:"af-gateway-signin__primary",type:"submit",disabled:C,children:V?de:L})]})]})}function uy(e){return e==="light"?"Light":"Dark"}function dy(e){const t=e.themes&&e.themes.length?e.themes:np,s=e.showSwatches!==!1,o=e.variant||"panel",l=w.useMemo(()=>{const d={};for(const f of t)d[f.id]=f;return d},[t]),u=w.useMemo(()=>t.map(d=>({value:d.id,label:d.label,group:uy(d.group)})),[t]);return i.jsx(ts,{value:e.value,options:u,placeholder:e.placeholder||"Select theme…",disabled:e.disabled===!0,searchable:!0,allowCustom:!1,clearable:!1,variant:o,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…",v=(g==null?void 0:g.swatches)||null,x=!h;return i.jsxs("span",{className:"af-theme-value",children:[i.jsx("span",{className:`af-theme-label ${x?"af-theme-label--placeholder":""}`.trim(),children:y}),s&&v?i.jsx("span",{className:"af-theme-swatches","aria-hidden":"true",children:v.map((b,k)=>i.jsx("span",{className:"af-theme-swatch",style:{background:b}},`${h}:${k}`))}):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((v,x)=>i.jsx("span",{className:"af-theme-swatch",style:{background:v}},`${h}:${x}`))}):null,f.selected?i.jsx("span",{className:"af-select-check",children:"✓"}):null]})]})}})}function fy(e){const t=e.scales&&e.scales.length?e.scales:iu,s=e.variant||"panel",o=w.useMemo(()=>t.map(l=>({value:l.id,label:l.label})),[t]);return i.jsx(ts,{value:e.value,options:o,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 hy(e){const t=e.densities&&e.densities.length?e.densities:ou,s=e.variant||"panel",o=w.useMemo(()=>t.map(l=>({value:l.id,label:l.label})),[t]);return i.jsx(ts,{value:e.value,options:o,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 py=new Set(["board","inbox","server","agent","playCircle","list","gear"]);function my(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 ie({name:e,size:t=16,className:s,title:o,...l}){const u=o?void 0:!0,d=py.has(e);return i.jsxs("svg",{width:t,height:t,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:o?"img":"presentation",...l,children:[o?i.jsx("title",{children:o}):null,my(e)]})}const Za="api/gateway",Po="api/connection/gateway";function Se(e){const t=String(e||"");if(t.startsWith("/"))throw new Error(`gatewayApiPath takes a route relative to the gateway API, got ${JSON.stringify(t)}.`);return t?`${Za}/${t}`:Za}function Xe(e,t){const s=String(t||"");if(s.startsWith("/"))throw new Error(`joinBaseUrl takes a relative path, got ${JSON.stringify(s)}.`);let o=String(e??"");for(;o.endsWith("/");)o=o.slice(0,-1);return o?`${o}/${s}`:s}function gy(e){const t=String(e||""),s=`/${Za}/`;if(!t.startsWith(s)||t.length===s.length)throw new Error(`Not a gateway API path: ${JSON.stringify(t)} (expected ${JSON.stringify(s)}…).`);const o=t.slice(s.length).split(/[?#]/,1)[0];if(/\\|%2f|%5c/i.test(o))throw new Error(`Not a gateway API path: ${JSON.stringify(t)} (encoded slash or backslash).`);for(const l of o.split("/")){const u=l.replace(/%2e/gi,".");if(u==="."||u==="..")throw new Error(`Not a gateway API path: ${JSON.stringify(t)} (a "." or ".." segment).`)}return t.slice(1)}const yy={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 wy(e){const t=new Set,s=[];for(const o of e||[]){if(!o)continue;const l=String(o.name||"").trim();!l||t.has(l)||(t.add(l),s.push({name:l,description:typeof o.description=="string"?o.description:void 0,toolset:typeof o.toolset=="string"?o.toolset:void 0,when_to_use:typeof o.when_to_use=="string"?o.when_to_use:void 0,default_approval:o.default_approval==="approve"||o.default_approval==="ask"?o.default_approval:void 0}))}return s.sort((o,l)=>{const u=String(o.toolset||""),d=String(l.toolset||"");return u!==d?u.localeCompare(d):o.name.localeCompare(l.name)}),s}function vy(e,t){return e.default_approval?e.default_approval:t.requireApproval.includes(e.name)?"ask":t.autoApprove.includes(e.name)?"approve":"ask"}function _y(e,t,s){const o=String(e||"").trim().toLowerCase();if(!o&&!t&&!s)return null;let l;return o==="approval"||o==="local_approval"||o==="local-approval"?l={label:"APPROVAL",detail:"Safe tools auto-run; mutating tools ask for approval.",tone:"safe"}:o==="passthrough"?l={label:"PASSTHROUGH",detail:"All tools require approval before execution.",tone:"warn"}:o==="delegated"||o==="delegate"||o==="job"?l={label:"DELEGATED",detail:"Tool calls wait for external executors.",tone:"info"}:o==="local"||o==="local_all"||o==="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"},t&&(l={...l,label:t}),s&&(l={...l,detail:s}),l}function xy(e){var de,re;const t=e.defaults||yy,s=e.disabled===!0,o=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(()=>_y(e.toolMode,e.toolModeLabel,e.toolModeDetail),[e.toolMode,e.toolModeLabel,e.toolModeDetail]),f=w.useMemo(()=>wy(e.tools),[e.tools]),h=w.useMemo(()=>f.map(Q=>Q.name),[f]),g=w.useMemo(()=>new Set(h),[h]),[y,v]=w.useState(""),x=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]),b=w.useMemo(()=>x.filter(Q=>g.has(Q)),[x,g]),k=w.useMemo(()=>x.filter(Q=>!g.has(Q)),[x,g]),E=((re=e.value)==null?void 0:re.mode)==="custom"?"custom":"all",S=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=E==="all"?new Set(h):new Set(b),A=Q=>{e.onChange(Q)},$=Q=>{s||A({...e.value,mode:Q,selected:x})},j=(Q,U)=>{if(s)return;const J=new Set(b);U?J.add(Q):J.delete(Q),A({...e.value,selected:[...k,...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:[...k,...h],mode:"custom"})},H=()=>{s||A({...e.value,selected:[...k],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:o}),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 ${E==="all"?"is-active":""}`.trim(),onClick:()=>$("all"),disabled:s,"aria-pressed":E==="all",children:"All tools"}),i.jsx("button",{type:"button",className:`af-tool-policy__seg-btn ${E==="custom"?"is-active":""}`.trim(),onClick:()=>$("custom"),disabled:s,"aria-pressed":E==="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||E!=="custom",children:"Select all"}),i.jsx("button",{type:"button",onClick:H,disabled:s||E!=="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=>v(Q.target.value),disabled:s})}),i.jsxs("div",{className:"af-tool-policy__list",children:[S.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])||vy(Q,t);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||E!=="custom",onChange:ye=>j(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)}),S.length?null:i.jsx("div",{className:"af-tool-policy__empty",children:"No tools match the filter."})]})]})}async function au(e=Po){const t=await fetch(e),s=await t.json().catch(()=>null);if(!t.ok){const o=s&&typeof s=="object"&&s.detail?String(s.detail):`HTTP ${t.status}`;throw new Error(o)}return s}async function by(e,t=Po){const s=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),o=await s.json().catch(()=>null);if(!s.ok){const l=o&&typeof o=="object"&&o.detail?String(o.detail):`HTTP ${s.status}`;throw new Error(l)}return o}async function ip(e=Po){const t=await fetch(e,{method:"DELETE"});if(!t.ok){const s=await t.json().catch(()=>({})),o=s&&typeof s=="object"&&s.detail?String(s.detail):`HTTP ${t.status}`;throw new Error(o)}}function zc(e){let t=String(e||"").trim();for(let s=0;s<2&&t;s+=1){try{const u=JSON.parse(t);if(typeof u=="string"&&u!==t){t=u.trim();continue}}catch{}const o=t[0],l=t[t.length-1];if(o==='"'&&l==='"'||o==="'"&&l==="'"){t=t.slice(1,-1).trim();continue}break}return t.replace(/\/+$/,"")}function ky(e){var u,d;if(!e)return{label:"Signed out",tone:"warn"};if(!e.has_session)return{label:"Signed out",tone:"warn"};const t=e.gateway||{},s=(u=t.principal)==null?void 0:u.user_id,o=(d=t.principal)==null?void 0:d.runtime_id;if(t.ok&&s)return{label:`Signed in as ${s}${o?` · runtime ${o}`:""}`,tone:"ok"};if(t.ok)return{label:"Signed in",tone:"ok"};const l=t.error||t.detail;return typeof l=="string"&&l.trim()?{label:"Session rejected — sign in again",tone:"err"}:{label:"Sign in required",tone:"err"}}function jy(e){const t=e.connectionPath||Po,[s,o]=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,v]=w.useState(e.defaultGatewayUrl||"http://127.0.0.1:8080"),[x,b]=w.useState("admin"),[k,E]=w.useState(""),[S,T]=w.useState(!1),[A,$]=w.useState(!0),[j,P]=w.useState(""),[V,H]=w.useState(""),L=w.useMemo(()=>ky(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()&&v(zc(ce.gateway_url));const ye=(fe=ce.gateway)==null?void 0:fe.principal;ye!=null&&ye.user_id&&b(ye.user_id);return}o(!0),P(""),au(t).then(ce=>{var ve;de(ce),typeof ce.gateway_url=="string"&&ce.gateway_url.trim()&&v(zc(ce.gateway_url));const ye=(ve=ce.gateway)==null?void 0:ve.principal;ye!=null&&ye.user_id&&b(ye.user_id)}).catch(ce=>P(`Failed to load connection status: ${String((ce==null?void 0:ce.message)||ce)}`)).finally(()=>o(!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=zc(y);v(J);const fe=await by({gateway_url:J,gateway_user_id:x,gateway_token:k,persist:A},t);de(fe),E(""),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 ip(t),E("");const J=await au(t).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(cy,{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=>v(J),userId:x,onUserIdChange:b,token:k,tokenPlaceholder:d!=null&&d.has_session?"(browser session already signed in)":"Paste Gateway user token",showToken:S,onTokenChange:E,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:j,message:V,onSubmit:Q})})})}function Sy(e){return!!(e&&e.ok===!0&&e.has_session===!0)}function Ny(e){const t=e||{},s=t.connectionPath||Po,o=t.variant||"dismissable",l=w.useRef(t.onStatusChange);l.current=t.onStatusChange;const u=w.useRef(o);u.current=o;const d=w.useRef(!!t.autoOpenMidSession);d.current=!!t.autoOpenMidSession;const[f,h]=w.useState(null),[g,y]=w.useState("loading"),[v,x]=w.useState(!1),b=w.useRef(!1),k=w.useRef(!1),E=w.useRef("loading"),S=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=Sy(fe);if(ce)y("connected"),E.current="connected",b.current=!1,S.current="none",k.current||x(!1);else if(fe!==null){const ve=E.current;y("disconnected"),E.current="disconnected",ve!=="disconnected"&&(S.current=T.current?"signout":ve==="connected"?"mid":"boot");const q=u.current==="blocking"||S.current!=="mid"||d.current;!b.current&&q&&x(!0)}fe!==null&&(k.current=ce)},[]),j=w.useCallback(async()=>{const fe=A.current;try{const ce=await au(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 ip(s)}catch(ce){fe=String((ce==null?void 0:ce.message)||ce||"Sign-out request failed")}T.current=!0;try{await j()}finally{T.current=!1}L(fe),V(!1)},[s,j]),re=w.useRef(!1);w.useEffect(()=>{re.current||(re.current=!0,j())},[j]);const Q=w.useCallback(()=>{x(!0)},[]),U=w.useCallback(()=>{const fe=E.current;o==="blocking"&&fe==="disconnected"||(fe==="disconnected"&&(b.current=!0),x(!1))},[o]),J=w.useMemo(()=>({isOpen:v,onClose:U,blocking:o==="blocking"&&g!=="connected",appName:t.appName,connectionPath:s,defaultGatewayUrl:t.defaultGatewayUrl,initialStatus:f,onStatusChange:$}),[v,U,o,g,t.appName,s,t.defaultGatewayUrl,f,$]);return{status:f,phase:g,connected:g==="connected",modalOpen:v,signingOut:P,signOutError:H,openModal:Q,refresh:j,signOut:de,modalProps:J}}function lu(e){const t=e.closeOnEscape!==!1,s=w.useRef(null);return w.useEffect(()=>{if(!e.open||!t)return;const o=l=>{l.key!=="Escape"||l.defaultPrevented||(l.preventDefault(),e.onClose())};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e.open,t,e.onClose]),w.useEffect(()=>{const o=s.current;o&&(e.open?o.removeAttribute("inert"):o.setAttribute("inert",""))},[e.open]),i.jsxs(i.Fragment,{children:[e.backdrop&&e.open?i.jsx("div",{className:"af-drawer-backdrop","aria-hidden":"true",onClick:e.onClose,style:{top:e.topOffset||0}}):null,i.jsxs("div",{ref:s,className:`af-drawer${e.side==="left"?" af-drawer--left":""}${e.topOffset?" af-drawer--offset":""}${e.open?" af-drawer--open":""}${e.className?` ${e.className}`:""}`,style:{width:e.width||420,top:e.topOffset||0,display:e.open?void 0:"none"},role:"complementary","aria-label":e.label,"aria-hidden":e.open?void 0:!0,children:[e.title!==void 0?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 Cy={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"},Ey={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:Cy,apps:Ey},qa=$y;function Ay(){return Object.keys(qa.apps).sort()}function Ty(e,t){const s=Object.prototype.hasOwnProperty.call(qa.apps,e)?qa.apps[e]:void 0;if(!s)throw new Error(`appIdentity: unknown application id "${e}" (known: ${Ay().join(", ")})`);return{id:e,name:s.name,version:t,website:s.website,repo:s.repo,docs:s.docs,issues:s.issues,feedback:s.feedback}}function Ry(e,t){const s=qa.framework,o=[["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 t||[])o.push([String(l),String(u)]);return o}function Wc(e){return typeof e=="string"?e.trim():""}function uh(e,t){if(t!=null)return[["Gateway",`unavailable (${String(t).trim()||"unknown error"})`]];const s=e&&typeof e=="object"&&!Array.isArray(e)?e:{},o=Wc(s.abstractgateway);if(!o)return[["Gateway","unavailable (the gateway did not report its version)"]];const l=Wc(s.abstractframework),u=[["Gateway",`AbstractGateway ${o}`],["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=Wc(d[h]);g&&u.push([`Gateway package ${h}`,g])}return u}const Iy='a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])';function op(e,t,s){if(e.key!=="Tab"||!t)return;const o=Array.from(t.querySelectorAll(Iy));if(o.length===0){e.preventDefault();return}const l=o[0],u=o[o.length-1],d=!!s&&t.contains(s);e.shiftKey?(s===l||!d)&&(e.preventDefault(),u.focus()):(s===u||!d)&&(e.preventDefault(),l.focus())}const My=/https?:\/\/[^\s<>"]+/g;function Ly(e,t){if(e==="Contact")return[{text:t,href:`mailto:${t}`}];const s=[];let o=0;for(const l of t.matchAll(My)){const u=l.index??0;u>o&&s.push({text:t.slice(o,u)}),s.push({text:l[0],href:l[0]}),o=u+l[0].length}return(o<t.length||s.length===0)&&s.push({text:t.slice(o)}),s}function Py({label:e,value:t}){return i.jsx("span",{children:Ly(e,t).map((s,o)=>s.href===void 0?i.jsx(gt.Fragment,{children:s.text},o):s.href.startsWith("mailto:")?i.jsx("a",{className:"af-about__link",href:s.href,children:s.text},o):i.jsx("a",{className:"af-about__link",href:s.href,target:"_blank",rel:"noopener noreferrer",children:s.text},o))})}function Oy(e){const t=w.useRef(null),s=w.useRef(null),o=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=t.current)==null||g.focus();const h=y=>{if(!y.defaultPrevented){if(y.key==="Escape"){y.preventDefault(),l.current();return}op(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=Ry(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":o,onClick:f=>f.stopPropagation(),children:[i.jsx("div",{className:"af-appearance__title",id:o,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(Py,{label:f,value:h})})]},`${g}:${f}`))}),i.jsx("div",{className:"af-appearance__actions",children:i.jsx("button",{ref:t,type:"button",className:"af-appearance__close",onClick:e.onClose,children:"Close"})})]})})}function Dy(e){const{connection:t}=e,s=t.phase,o=t.signingOut===!0,[l,u]=w.useState(!1),d=e.about,f=o?"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(ie,{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(ie,{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(ie,{name:"info",size:16})}):null,e.extraActions,i.jsxs("button",{type:"button",className:`af-topbar__pill af-topbar__pill--${s}`,onClick:s==="connected"?t.onDisconnect:t.onConnect,disabled:o,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(Oy,{open:l,onClose:()=>u(!1),identity:d.identity,extraRows:d.extraRows}):null]})}const Ja={theme:"dark",font_scale:"md",header_density:"standard"};function Fy(e){const t=e&&typeof e=="object"?e:{};return{theme:typeof t.theme=="string"&&t.theme?t.theme:Ja.theme,font_scale:typeof t.font_scale=="string"&&t.font_scale?t.font_scale:Ja.font_scale,header_density:typeof t.header_density=="string"&&t.header_density?t.header_density:Ja.header_density}}function zy(e){return`af_appearance_${e}_v1`}function Wy(e,t){const s=zy(e),o=w.useMemo(()=>({...Ja,...(t==null?void 0:t.defaults)||{}}),[JSON.stringify((t==null?void 0:t.defaults)||{})]),[l,u]=w.useState(()=>{let d=o;try{const f=localStorage.getItem(s)??(t!=null&&t.legacyKey?localStorage.getItem(t.legacyKey):null);f&&(d=Fy({...o,...JSON.parse(f)}))}catch{}try{sh(d.theme),ih({font_scale:d.font_scale,header_density:d.header_density})}catch{}return d});return w.useEffect(()=>{sh(l.theme),ih({font_scale:l.font_scale,header_density:l.header_density});try{localStorage.setItem(s,JSON.stringify(l))}catch{}},[s,l]),[l,u]}function Uy(e){return w.useEffect(()=>{if(!e.open)return;const t=s=>{s.key!=="Escape"||s.defaultPrevented||(s.preventDefault(),e.onClose())};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[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:t=>t.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(dy,{value:e.value.theme,onChange:t=>e.onChange({...e.value,theme:t})}),i.jsx("label",{className:"af-appearance__label",children:"Font size"}),i.jsx(fy,{value:e.value.font_scale,onChange:t=>e.onChange({...e.value,font_scale:t})}),i.jsx("label",{className:"af-appearance__label",children:"Header size"}),i.jsx(hy,{value:e.value.header_density,onChange:t=>e.onChange({...e.value,header_density:t})})]}),i.jsx("div",{className:"af-appearance__actions",children:i.jsx("button",{type:"button",className:"af-appearance__close",onClick:e.onClose,children:"Close"})})]})}):null}function By(){var t;if(typeof window>"u")return!1;const e=navigator;return!!((t=e==null?void 0:e.mediaDevices)!=null&&t.getUserMedia)&&typeof window.MediaRecorder=="function"}function Vy(){if(typeof window>"u")return!1;const e=window;return!!(e!=null&&e.AudioContext||e!=null&&e.webkitAudioContext)}function Gy(){const e=window.MediaRecorder,t=o=>{var l;try{return!!((l=e==null?void 0:e.isTypeSupported)!=null&&l.call(e,o))}catch{return!1}},s=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus","audio/ogg"];for(const o of s)if(t(o))return o;return""}async function Uc(e,t){var l;const s=t.slice(0),o=(l=e.decodeAudioData)==null?void 0:l.bind(e);if(typeof o!="function")throw new Error("decodeAudioData not available");try{const u=o(s);if(u&&typeof u.then=="function")return await u}catch{}return await new Promise((u,d)=>{try{o(s,u,d)}catch(f){d(f)}})}function Hy(e){const t=new Uint8Array(e);if(t.length<44)return null;const s=u=>String.fromCharCode(t[u],t[u+1],t[u+2],t[u+3]);if(s(0)!=="RIFF"||s(8)!=="WAVE")return null;const o=new DataView(e);let l=12;for(;l+8<=t.length;){const u=s(l),d=o.getUint32(l+4,!0);if(u==="data")return t.slice(0,l+8);l+=8+d+d%2}return null}function Ky(e,t){const s=new Uint8Array(t),o=new Uint8Array(e.length+s.length);o.set(e,0),o.set(s,e.length);const l=new DataView(o.buffer);return l.setUint32(4,o.length-8,!0),l.setUint32(e.length-4,s.length,!0),o.buffer}function Jy(e){const t=w.useRef(e);t.current=e;const s=X=>{var ee,pe;return(pe=(ee=t.current).on_error)==null?void 0:pe.call(ee,X)},o=w.useMemo(()=>Vy()&&(typeof e.tts=="function"||typeof e.tts_stream=="function"),[e.tts,e.tts_stream]),l=w.useMemo(()=>By()&&typeof e.transcribe=="function",[e.transcribe]),[u,d]=w.useState({key:"",status:"idle"}),f=w.useRef(u),h=w.useCallback(X=>{f.current=X,d(ee=>ee.key===X.key&&ee.status===X.status?ee:X)},[]),g=w.useRef(""),y=w.useRef(""),v=w.useRef(null),x=w.useRef(null),b=w.useRef(null),k=w.useRef(null),E=w.useRef(0),S=w.useRef(0),T=w.useRef(0),A=w.useRef([]),$=w.useRef(0),j=w.useRef(!0),P=w.useRef(!1),V=()=>{try{const X=globalThis,ee=(X==null?void 0:X.AudioContext)||(X==null?void 0:X.webkitAudioContext);if(!ee)return null;if(!v.current){const we=new ee,Pe=we.createGain();Pe.gain.value=1,Pe.connect(we.destination),v.current=we,x.current=Pe}const pe=v.current,De=x.current;if(!pe||!De)return null;try{pe.state==="suspended"&&pe.resume()}catch{}return{ctx:pe,gain:De}}catch{return null}},H=w.useCallback(()=>{const X=b.current;if(b.current=null,!!X){try{X.onended=null}catch{}try{X.stop()}catch{}try{X.disconnect()}catch{}}},[]),L=w.useCallback(()=>{H(),T.current+=1,A.current=[],$.current=0,j.current=!0,P.current=!1,y.current="",g.current="",k.current=null,E.current=0,S.current=0,h({key:"",status:"idle"})},[H,h]);w.useEffect(()=>()=>{var X,ee;L();try{(X=x.current)==null||X.disconnect()}catch{}try{(ee=v.current)==null||ee.close()}catch{}v.current=null,x.current=null,k.current=null},[]);const de=async(X,ee,pe)=>{const De=T.current,we=V();if(!we)throw new Error("TTS playback is not supported in this browser");const{ctx:Pe,gain:Ve}=we;try{Pe.state==="suspended"&&await Pe.resume()}catch{}if(De!==T.current)return;H();const rt=Pe.createBufferSource();rt.buffer=ee,rt.connect(Ve);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));S.current=Pe.currentTime-me,E.current=me,b.current=rt,g.current=X,rt.onended=()=>{b.current===rt&&(b.current=null,E.current=0,S.current=0,g.current="",h({key:"",status:"idle"}))},rt.start(0,me),h({key:X,status:"playing"})},re=(X,ee)=>{if(ee!==T.current)return;const pe=V();if(!pe)return;const De=A.current,we=$.current;if(we>=De.length){j.current&&(g.current="",E.current=0,S.current=0,h({key:"",status:"idle"}));return}const Pe=De[we],{ctx:Ve,gain:rt}=pe;H();const K=Ve.createBufferSource();K.buffer=Pe,K.connect(rt);const me=Number.isFinite(Number(Pe.duration))?Number(Pe.duration):0,Fe=Math.max(0,Math.min(Number(E.current||0),me>0?Math.max(0,me-.01):0));S.current=Ve.currentTime-Fe,b.current=K,g.current=X,K.onended=()=>{ee===T.current&&b.current===K&&(b.current=null,$.current=we+1,E.current=0,re(X,ee))};try{Ve.state==="suspended"&&Ve.resume()}catch{}K.start(0,Fe),h({key:X,status:"playing"})},Q=async(X,ee,pe)=>{const De=V();if(!De){s==null||s("TTS playback is not supported in this browser.");return}H();const we=++T.current;A.current=[],$.current=0,j.current=!1,P.current=!1,k.current=null,E.current=0,S.current=0,g.current=X,y.current=X,h({key:X,status:"loading"}),s==null||s("");let Pe=null;try{for await(const Ve of pe(ee)){if(we!==T.current)return;let rt;try{rt=await Uc(De.ctx,Ve),Pe||(Pe=Hy(Ve))}catch{if(!Pe)continue;try{rt=await Uc(De.ctx,Ky(Pe,Ve))}catch{continue}}if(we!==T.current)return;A.current.push(rt),!b.current&&!P.current&&(y.current="",re(X,we))}if(we!==T.current)return;if(j.current=!0,A.current.length===0){s==null||s("TTS stream produced no audio."),L();return}!b.current&&!P.current&&re(X,we)}catch(Ve){if(we!==T.current)return;s==null||s(String((Ve==null?void 0:Ve.message)||Ve||"TTS stream failed")),L()}},U=w.useCallback(async(X,ee)=>{const pe=String(X||"").trim(),De=String(ee||"").trim();if(!pe||!De)return;const we=t.current.tts,Pe=t.current.tts_stream;if(typeof we!="function"&&typeof Pe!="function"){s==null||s("TTS is not available.");return}const Ve=V();if(!Ve){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(b.current){const Fe=Math.max(0,Ve.ctx.currentTime-Number(S.current||0));E.current=Fe}else E.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 Fe=k.current;if(Fe){s==null||s(""),P.current=!1;try{await de(pe,Fe,E.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,De,Pe);return}H(),T.current+=1;const me=T.current;A.current=[],$.current=0,j.current=!0,P.current=!1,k.current=null,E.current=0,S.current=0,g.current=pe,y.current=pe,h({key:pe,status:"loading"}),s==null||s("");try{const Fe=await we(De);if(y.current!==pe||T.current!==me)return;const Ke=await Uc(Ve.ctx,Fe);if(y.current!==pe||T.current!==me)return;k.current=Ke,E.current=0,await de(pe,Ke,0)}catch(Fe){if(T.current!==me)return;y.current===pe&&(y.current="",g.current="",h({key:"",status:"idle"})),s==null||s(String((Fe==null?void 0:Fe.message)||Fe||"TTS failed"))}},[]),[J,fe]=w.useState(!1),[ce,ye]=w.useState(!1),ve=w.useRef(!1),q=w.useRef(l);q.current=l;const ae=w.useCallback(X=>{ve.current=X,fe(ee=>ee===X?ee:X)},[]),G=w.useRef(!1),C=w.useRef(null),B=w.useRef(null),F=w.useRef([]),W=w.useRef(""),oe=w.useRef(0),le=w.useRef(!1);function he(){var X,ee;try{(ee=(X=C.current)==null?void 0:X.getTracks)==null||ee.call(X).forEach(pe=>{try{pe.stop()}catch{}})}catch{}C.current=null}const Z=w.useCallback(()=>{oe.current+=1,le.current=!1;const X=B.current;if(X){X.onstop=null,X.ondataavailable=null,X.onerror=null;try{X.stop()}catch{}}B.current=null,he(),ae(!1),G.current=!1,ye(!1),F.current=[]},[ae]);w.useEffect(()=>()=>Z(),[Z]);async function Ce(X,ee){var we,Pe;if(s==null||s(""),!X||!X.size||G.current)return;const pe=t.current.transcribe;if(typeof pe!="function"){s==null||s("Transcription is not available.");return}G.current=!0;const De=oe.current;ye(!0);try{const Ve=String(await pe(X,ee)||"").trim();De===oe.current&&Ve&&((Pe=(we=t.current).on_transcript)==null||Pe.call(we,Ve))}catch(Ve){De===oe.current&&(s==null||s(String((Ve==null?void 0:Ve.message)||Ve||"Transcription failed")))}finally{De===oe.current&&(G.current=!1,ye(!1))}}const Ue=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 X=oe.current;le.current=!0;try{const ee=await navigator.mediaDevices.getUserMedia({audio:!0});if(X!==oe.current){ee.getTracks().forEach(we=>we.stop());return}C.current=ee;const pe=Gy();W.current=pe;const De=pe?new MediaRecorder(ee,{mimeType:pe}):new MediaRecorder(ee);B.current=De,De.ondataavailable=we=>{if(X===oe.current)try{we!=null&&we.data&&F.current.push(we.data)}catch{}},De.onerror=()=>{X===oe.current&&(s==null||s("Recording failed."))},De.onstop=()=>{if(X===oe.current){ae(!1),he(),B.current=null;try{const we=new Blob(F.current,{type:W.current||""});Ce(we,W.current)}catch(we){s==null||s(String((we==null?void 0:we.message)||we||"Failed to build recording"))}}},De.start(),ae(!0)}catch(ee){if(X!==oe.current)return;he(),B.current=null,ae(!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{X===oe.current&&(le.current=!1)}},[]),ke=w.useCallback(()=>{const X=B.current;if(!(!ve.current||!X)){ae(!1);try{X.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 X=()=>ke();return window.addEventListener("pointerup",X),window.addEventListener("pointercancel",X),()=>{window.removeEventListener("pointerup",X),window.removeEventListener("pointercancel",X)}},[J]),{tts_supported:o,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:Ue,stop_voice_ptt_recording:ke,cancel_voice_ptt_recording:Z}}const Ua=e=>Array.isArray(e)?e.map(t=>typeof t=="string"?t:(t==null?void 0:t.id)||(t==null?void 0:t.name)).filter(Boolean):[];function Qy({value:e,onChange:t,fetchCatalog:s}){var S,T,A,$;const o=w.useRef(s);o.current=s;const[l,u]=w.useState({}),[d,f]=w.useState(""),[h,g]=w.useState(!1);w.useEffect(()=>{let j=!0;return g(!0),u({}),f(""),o.current(e.provider,e.model).then(P=>{j&&(u(P),f(P.error?String(P.error):""))}).catch(P=>{j&&f(String((P==null?void 0:P.message)||P))}).finally(()=>{j&&g(!1)}),()=>{j=!1}},[e.provider,e.model]);const y=Array.isArray(l.items)?l.items:[...Array.isArray(l.profiles)?l.profiles.map(j=>({...j,voice_kind:"profile"})):[],...Array.isArray(l.voices)?l.voices.map(j=>({...j,voice_kind:"voice"})):[]],v=j=>JSON.stringify([j.provider||"",j.model||"",j.voice_kind==="profile"?"profile":"voice",j.id]),x=y.find(j=>j.id===(e.profile||e.voice)&&j.voice_kind==="profile"==!!e.profile&&(!e.provider||!j.provider||j.provider===e.provider)&&(!e.model||!j.model||j.model===e.model)),b=x?v(x):e.profile||e.voice?JSON.stringify([e.provider||"",e.model||"",e.profile?"profile":"voice",e.profile||e.voice]):"",k=y.filter(j=>(j==null?void 0:j.id)&&(!e.provider||!j.provider||j.provider===e.provider)).map(j=>({value:v(j),label:`${j.label||j.name||j.id}${!e.provider&&j.provider?` · ${j.provider}`:""}`}));b&&!k.some(j=>j.value===b)&&k.unshift({value:b,label:`${e.profile||e.voice} (saved)`});const E=j=>t({...e,...j});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(bu,{value:{provider:e.provider||"",model:e.model||""},onChange:j=>t({...e,...j,voice:"",profile:""}),fetchProviders:async()=>{const j=await o.current();if(j.error&&!Ua(j.tts_providers||j.providers).length)throw new Error(j.error);return Ua(j.tts_providers||j.providers).map(P=>({name:P}))},fetchModels:async j=>{var V;const P=await o.current(j);return Ua(((V=P.tts_models_by_provider)==null?void 0:V[j])||P.tts_models||P.models)},providerLabel:"Speech provider",modelLabel:"Speech model"}),i.jsxs("label",{children:["Voice / profile",i.jsx(ts,{ariaLabel:"AI voice",placeholder:"Gateway / provider default",value:b,disabled:h,options:[{value:"",label:"Gateway / provider default"},...k],onChange:j=>{if(!j){E({voice:"",profile:""});return}const[P,V,H,L]=JSON.parse(j);E({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:j=>E({speed:j.target.value?Number(j.target.value):void 0}),children:[i.jsx("option",{value:"",children:"Gateway default"}),[.5,.75,1,1.25,1.5,2].map(j=>i.jsxs("option",{value:j,children:[j,"×"]},j))]})]}),(T=(S=l.controls)==null?void 0:S.quality_preset)!=null&&T.supported?i.jsxs("label",{children:["Quality",i.jsxs("select",{"aria-label":"Speech quality",value:e.quality_preset||"",onChange:j=>E({quality_preset:j.target.value}),children:[i.jsx("option",{value:"",children:"Gateway default"}),Ua(l.controls.quality_preset.values).map(j=>i.jsx("option",{value:j,children:j},j))]})]}):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:j=>E({instructions:j.target.value})})]}):null,i.jsx("button",{type:"button",onClick:()=>t({}),children:"Reset to Gateway defaults"})]})}const Bc=Se("automations"),Yy=Se("trigger-sources"),Xy=Se("me/email");class dh extends Error{constructor(t){super(t.message),this.name="AutomationApiError",this.status=t.status,this.code=t.code,t.field!==void 0&&(this.field=t.field),t.command_id!==void 0&&(this.command_id=t.command_id)}}function Zy(e,t){const s=t&&typeof t=="object"?t.detail:void 0;if(s&&typeof s=="object"&&!Array.isArray(s)){const o=s;if(typeof o.reason_code=="string"&&o.reason_code&&typeof o.message=="string"){const l={status:e,code:o.reason_code,message:o.message};return typeof o.field=="string"&&(l.field=o.field),typeof o.command_id=="string"&&(l.command_id=o.command_id),l}}return{status:e,code:"invalid_response",message:`The gateway answered HTTP ${e} without an automation error envelope.`}}function Vc(e){const t=new URLSearchParams;for(const[o,l]of Object.entries(e))l!==void 0&&t.set(o,String(l));const s=t.toString();return s?`?${s}`:""}function qy(){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 ew(e){const t=e.newId??qy,s=l=>`${Bc}/${encodeURIComponent(l)}`;async function o(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 v,x=!1;if(y)try{v=JSON.parse(y),x=!0}catch{x=!1}if(!g.ok)throw new dh(Zy(g.status,v));if(!x||v===null||typeof v!="object")throw new dh({status:g.status,code:"invalid_response",message:`The gateway answered ${l} ${u} with a body that is not a JSON object.`});return v}return{listAutomations:(l={})=>o("GET",`${Bc}${Vc({status:l.status,cursor:l.cursor,limit:l.limit})}`),getAutomation:l=>o("GET",s(l)),createAutomation:l=>o("POST",Bc,l),reviseAutomation:(l,u)=>o("PATCH",s(l),{command_id:u.command_id??t(),...u.expected_revision!==void 0?{expected_revision:u.expected_revision}:{},changes:u.changes}),sendAutomationCommand:(l,u)=>o("POST",`${s(l)}/commands`,{command_id:u.command_id??t(),type:u.type,...u.payload!==void 0?{payload:u.payload}:{}}),listOccurrences:(l,u={})=>o("GET",`${s(l)}/occurrences${Vc({cursor:u.cursor,limit:u.limit})}`),discuss:(l,u)=>o("POST",`${s(l)}/discuss`,{request_id:u.request_id??t(),occurrence_index:u.occurrence_index,prompt:u.prompt}),markSeen:(l,u)=>o("POST",`${s(l)}/seen`,{attention_cursor:u}),listAttention:(l,u={})=>o("GET",`${s(l)}/attention${Vc({cursor:u.cursor,limit:u.limit})}`),listTriggerSources:()=>o("GET",Yy),getMyEmail:()=>o("GET",Xy)}}const tw={pause:"Pause",resume:"Resume",run_now:"Run now",stop_current:"Stop current",revise:"Edit",archive:"Archive",discuss:"Discuss"},nw={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.`},rw="Next scheduled run: {time}.",sw="Growing context: later runs see this run in their history.",iw={run_now:{name:"playCircle"}},ow={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."},ap={labels:tw,hints:nw,run_now_next_run_line:rw,run_now_growing_line:sw,icons:iw,email:ow},aw=/^([1-9][0-9]*)([smhd])$/,lw={s:["second","seconds"],m:["minute","minutes"],h:["hour","hours"],d:["day","days"]};function Oo(e){if(typeof e!="string")return null;const t=aw.exec(e);return t?{amount:Number(t[1]),unit:t[2]}:null}function lp(e){const t=Oo(e);if(!t)return`every ${e}`;const[s,o]=lw[t.unit];return t.amount===1?`every ${s}`:`every ${t.amount} ${o}`}function Cr(e){if(!e)return"";const t=Date.parse(e);if(Number.isNaN(t))return e;const s=new Date(t).toISOString(),o=s.slice(17,19);return`${s.slice(0,10)} ${s.slice(11,16)}${o==="00"?"":`:${o}`} UTC`}function cp(e){const t=e;if(typeof t.every!="string")return t.start_at?`once at ${Cr(t.start_at)}`:"once, now";const s=[`${lp(t.every)} (UTC)`];return typeof t.count=="number"&&s.push(`${t.count} ${t.count===1?"run":"runs"} max`),typeof t.until=="string"&&s.push(`until ${Cr(t.until)}`),s.join(" · ")}function ku(e){return e.source_id==="schedule"&&e.source_version===1?cp(e.config):e.source_id==="manual"&&e.source_version===1?"manual runs only":il(e)?yp(e.config):`${e.source_id}@${e.source_version}`}function up(e){return e==="growing"?"Growing — each run sees the previous runs":"Independent — each run starts fresh"}const cw={active:"Active",paused:"Paused",completed:"Completed",failed:"Failed",archived:"Archived"},We=ap.email,dp="email.received",fp=1,uw="1h",dw="60s",hp=60,ju=100,cu=1e3,fh=200,hh=200,ph=50;function il(e){return!!e&&e.source_id===dp&&e.source_version===fp}function Su(e){return!!e&&e.effective_enabled===!0}function pp(e){const t=[];for(const s of String(e??"").split(/[\s,;]+/)){const o=s.trim().toLowerCase();o&&!t.includes(o)&&t.push(o)}return t}const fw=/[\s<>,;:"()[\]]/;function uu(e){const t=e.trim().toLowerCase(),s=t.indexOf("@");return s<=0||s===t.length-1?!1:!t.slice(s+1).includes("@")&&!fw.test(t)}function hw(e){const t=e.trim().toLowerCase();return!!t&&!t.includes("@")&&t.includes(".")&&!t.startsWith(".")&&!t.endsWith(".")&&!/[\s<>,;:"()[\]/*]/.test(t)}const Nu={usesModel:!0,every:null,maxBatch:null,fromIn:"",fromDomainIn:"",toIn:"",subjectContains:"",hasAttachment:"any"};function Cu(e){return e?uw:dw}function mp(e){const t=Oo(e);return t?t.amount*{s:1,m:60,h:3600,d:86400}[t.unit]:null}function Gc(e,t,s,o,l){const u=pp(e);if(!u.length)return null;const d=u.filter(f=>!s(f));return d.length&&l.push(`${t}: ${d.join(", ")} ${d.length===1?"is not":"are not"} ${o}.`),u.length>fh&&l.push(`${t}: at most ${fh} entries.`),u}function gp(e){const t=[],s={uses_model:e.usesModel};e.every===null?s.every=Cu(e.usesModel):!Number.isInteger(e.every.amount)||e.every.amount<1?t.push("The check interval must be a whole number of at least 1."):s.every=`${e.every.amount}${e.every.unit}`,s.every!==void 0&&(mp(s.every)??0)<hp&&t.push("The check interval is at least 60 seconds."),e.maxBatch===null?s.max_batch=ju:!Number.isInteger(e.maxBatch)||e.maxBatch<1||e.maxBatch>cu?t.push(`At most this many emails per run: a whole number from 1 to ${cu}.`):s.max_batch=e.maxBatch;const o={},l=Gc(e.fromIn,We.from_in,uu,"an email address",t);l&&(o.from_in=l);const u=Gc(e.fromDomainIn,We.from_domain_in,hw,"a domain like example.com",t);u&&(o.from_domain_in=u);const d=Gc(e.toIn,We.to_in,uu,"an email address",t);d&&(o.to_in=d);const f=e.subjectContains.trim();return f&&(f.length>hh||/[\r\n]/.test(f)?t.push(`${We.subject_contains}: one line of at most ${hh} characters.`):o.subject_contains=f),e.hasAttachment==="yes"?o.has_attachment=!0:e.hasAttachment==="no"&&(o.has_attachment=!1),Object.keys(o).length&&(s.filter=o),{config:s,errors:t}}function yp(e){const t=e,s=t.filter??{},o=["when an email arrives"],l=[...s.from_in??[],...s.from_domain_in??[]];l.length&&o.push(`from ${l.join(", ")}`),s.to_in&&s.to_in.length&&o.push(`to ${s.to_in.join(", ")}`),typeof s.subject_contains=="string"&&s.subject_contains&&o.push(`subject contains “${s.subject_contains}”`),s.has_attachment===!0&&o.push("with attachments"),s.has_attachment===!1&&o.push("without attachments");const u=typeof t.every=="string"?t.every:Cu(t.uses_model!==!1);o.push(`checked ${lp(u)}`);const d=typeof t.max_batch=="number"?t.max_batch:ju;return o.push(`up to ${d} per run`),o.join(" · ")}const du={mode:"self",addresses:""};function fu(e){if(e.mode==="self")return{recipients:["self"],errors:[]};const t=[],s=pp(e.addresses).filter(l=>l!=="self");s.length||t.push("Name at least one address the automation may email, or choose Only me.");const o=s.filter(l=>!uu(l));return o.length&&t.push(`${We.recipients_list}: ${o.join(", ")} ${o.length===1?"is not an email address":"are not email addresses"}.`),s.length+1>ph&&t.push(`At most ${ph-1} addresses.`),{recipients:["self",...s],errors:t}}function pw(e){const t=(e??[]).filter(s=>s!=="self");return t.length?{mode:"list",addresses:t.join(", ")}:{mode:"self",addresses:""}}function mw(e){const t=(e??["self"]).filter(s=>s!=="self");return t.length?`Me and ${t.join(", ")}`:"Only me"}function wp(e){return{channels:e?["console","email"]:["console"]}}function vp(e){return!!e&&Array.isArray(e.channels)&&e.channels.includes("email")}function gw(e){return vp(e)?"In the console and by email":"In the console"}const sr={pause:"automation.pause",resume:"automation.resume",run_now:"automation.run_now",stop_current:"automation.stop_current",archive:"automation.archive"},yw=new Set(["running","waiting","backoff"]);function ww(e,t=[]){return e.current_occurrence!=null}function _p(e){const t=e.current_occurrence;if(!t)return null;const s=t.attempt>1?` (attempt ${t.attempt})`:"";return t.status==="backoff"?`Run #${t.index} waiting to retry (attempt ${t.attempt+1})`:t.status==="admitted"?`Run #${t.index} starting${s}`:`Run #${t.index} running${s}`}function xp(e,t){const s=Date.parse(e);if(Number.isNaN(s))return"";const o=Math.round((s-t)/6e4);if(o<=0)return"due now";if(o<60)return`in ${o} min`;const l=Math.floor(o/60);return l<24?`in ${l} h${o%60?` ${o%60} min`:""}`:`in ${Math.floor(l/24)} d${l%24?` ${l%24} h`:""}`}function el(e,t=[],s=!1){const o=new Set(e.capabilities),l=e.status,u=ww(e,t),d=(h,g,y)=>s?{enabled:!1,reason:"Working…"}:e.legacy?{enabled:!1,reason:"Legacy schedule: managed with its existing controls."}:o.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."}:o.has("discuss")?{enabled:!0}:{enabled:!1,reason:"Discussion is not permitted for this automation."}}}function vw(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 _w(e){return[...e].sort((t,s)=>t.index-s.index).map(t=>{const s=vw(t),o=`${t.attempts} ${t.attempts===1?"attempt":"attempts"}`,l=s==="failed"?`Failed after ${o}`:s==="waiting"?"Waiting for you":s==="notified"?"Notified":s==="running"?"Running":null,u=t.status==="completed"&&t.attempts>1?`completed after ${o}`:t.status;return{row:t,tone:s,notable:s==="failed"||s==="waiting"||s==="notified",badge:l,statusText:u,canDiscuss:!yw.has(t.status)}})}function xw(e){const t=e.attention.items;return t.length?t[t.length-1].cursor:null}function bp(e){const t=e.attention,s=[];return t.unseen_count>0&&s.push(`${t.unseen_count} unseen`),t.pending_waits>0&&s.push(`${t.pending_waits} waiting for you`),s.length?s.join(" · "):"nothing new"}const bw={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 Eu(e){return{title:bw[e.code]??`The gateway refused the request (${e.code}).`,detail:e.message}}function $u(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.status=="number"&&typeof t.code=="string"&&typeof t.message=="string"}function kp(e,t){const s=e.trigger,o=s.source_id==="schedule"||il(s)?s.config.every:void 0,l=t?t.target.input_data.prompt:void 0;return{title:e.title,every:typeof o=="string"?o:null,context:e.context_mode,prompt:typeof l=="string"?l:null,toolApproval:t?t.policy.tool_approval:null,notifyEmail:t?vp(t.notify):null,emailRecipients:t?pw(t.policy.email_allowed_recipients):null}}function kw(e,t,s){const o=[],l={},u=t.title.trim();u?u.length>120?o.push("Title is at most 120 characters."):u!==e.title&&(l.title=u):o.push("Title is required.");const d=kp(e,s);if(t.every!==d.every&&t.every!==null){const f=il(e.trigger);if(!Oo(t.every))o.push("Interval must be a whole number of minutes, hours or days.");else if(f&&(mp(t.every)??0)<hp)o.push("The check interval is at least 60 seconds.");else{const h={...e.trigger.config,every:t.every};f&&delete h.start_at,l.trigger={source_id:e.trigger.source_id,source_version:e.trigger.source_version,config:h}}}if(t.context!==e.context_mode&&(l.context={mode:t.context}),s&&typeof d.prompt=="string"&&typeof t.prompt=="string"&&t.prompt.trim()!==d.prompt.trim()){const f=t.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}}:o.push("Task is required.")}if(s&&t.toolApproval&&t.toolApproval!==d.toolApproval&&(l.policy={tool_approval:t.toolApproval}),s&&typeof t.notifyEmail=="boolean"&&t.notifyEmail!==d.notifyEmail&&(l.notify=wp(t.notifyEmail)),s&&t.emailRecipients){const f=fu(t.emailRecipients),h=fu(d.emailRecipients??du).recipients;f.errors.length?o.push(...f.errors):JSON.stringify(f.recipients)!==JSON.stringify(h)&&(l.policy={...l.policy??{},email_allowed_recipients:f.recipients})}return o.length?{errors:o}:Object.keys(l).length?l:null}const jw=[{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 Hc(e){if(!e)return null;const t=/^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})(:\d{2})?$/.exec(e.trim());if(!t)return null;const s=`${t[1]}T${t[2]}${t[3]??":00"}Z`;return Number.isNaN(Date.parse(s))?null:s}function Sw(e){const t=e.trim().split(`
|
|
50
|
-
`)[0].trim();return t.length>120?`${t.slice(0,119)}…`:t}function jp(e){const t=[],s={};if(e.when.kind==="once"){const l=Hc(e.when.at);return l?s.start_at=l:t.push("Pick the date and time (UTC) to run once."),{config:s,errors:t}}const o=e.when.amount;if(!Number.isInteger(o)||o<1?t.push("The interval must be a whole number of at least 1."):s.every=`${o}${e.when.unit}`,e.startAt){const l=Hc(e.startAt);l?s.start_at=l:t.push("First run must be a date and time (UTC).")}if(e.count!==void 0&&(!Number.isInteger(e.count)||e.count<1?t.push("Maximum runs must be a whole number of at least 1."):s.count=e.count),e.until){const l=Hc(e.until);l?s.until=l:t.push("Stop at must be a date and time (UTC).")}return{config:s,errors:t}}function Nw(e){if(e.trigger==="email"){const l=gp(e.email??Nu);return l.errors.length?"":yp(l.config)}const{config:t,errors:s}=jp(e);if(s.length)return"";const o=cp(t);return e.when.kind==="once"?o:`${o}, first run ${t.start_at?`at ${Cr(t.start_at)}`:"now"}`}function Cw(e,t){const s=[];t.target||s.push("Choose what to run.");const o=e.prompt.trim();o||s.push("Write the task to run.");const l=(e.title??"").trim()||Sw(o);l.length>120&&s.push("Title is at most 120 characters.");const u=e.trigger==="email",d=u?gp(e.email??Nu):jp(e);s.push(...d.errors);const f=e.emailRecipients&&e.emailRecipients.mode==="list"?fu(e.emailRecipients):null;if(f&&s.push(...f.errors),s.length||!t.target)return{ok:!1,errors:s};const h={...t.target,input_data:{...t.target.input_data??{},prompt:o}},g={request_id:t.requestId,title:l,target:h,trigger:u?{source_id:dp,source_version:fp,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=wp(!0)),{ok:!0,body:g}}const Ew="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 t=[];for(const s of e.details){if(!s||typeof s!="object"||Array.isArray(s))return null;const o=s;if(typeof o.name!="string"||!o.arguments||typeof o.arguments!="object"||Array.isArray(o.arguments)||o.call_id!==void 0&&typeof o.call_id!="string")return null;t.push({name:o.name,arguments:o.arguments,...typeof o.call_id=="string"?{call_id:o.call_id}:{}})}return t}function Aw(e){const t=e.trim();if(!t)return{ok:!1,error:"Enter a JSON payload."};try{return{ok:!0,payload:JSON.parse(t)}}catch(s){return{ok:!1,error:`The payload is not valid JSON (${s instanceof Error?s.message:String(s)}).`}}}const Sp={ask_user:"Question for you",tool_approval:"Approval needed",event:"Waiting for an event"};class Np{constructor(t){this.mint=t,this.open=new Map}idFor(t){let s=this.open.get(t);return s===void 0&&(s=this.mint(),this.open.set(t,s)),s}settle(t,s){(s.ok||Tw(s.error))&&this.open.delete(t)}}function Tw(e){return $u(e)&&e.status>0&&e.code!=="invalid_response"}function Cp(){const e=globalThis.crypto;if(!e||typeof e.randomUUID!="function")throw new Error("crypto.randomUUID is unavailable; pass newId");return e.randomUUID()}class Rw{constructor(){this.acked=null,this.inflight=null,this.failedKey=null,this.failedToken=void 0}next(t,s){return!t||t===this.acked||t===this.inflight||t===this.failedKey&&s===this.failedToken?null:(this.inflight=t,t)}succeeded(t){this.inflight===t&&(this.inflight=null),this.acked=t,this.failedKey=null}failed(t,s){this.inflight===t&&(this.inflight=null),this.failedKey=t,this.failedToken=s}get acknowledged(){return this.acked}}function mh(e,t){if(!e)return null;for(const s of t){const o=e.querySelector(s);if(o&&o.disabled!==!0&&typeof o.focus=="function")return o}return null}function hu(e){if(Su(e.status))return null;const t=We.not_set_up,s=We.open_my_email,o=t.endsWith(s)?t.slice(0,t.length-s.length):`${t} `,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:[o,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 Iw(e){const t=e.value,s=f=>e.onChange({...t,...f}),o=f=>`${e.idBase}-email-${f}`,l=Oo(Cu(t.usesModel)),u=t.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:We.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:We.interval_rule}),i.jsxs("label",{className:"af-auto__field",htmlFor:o("batch"),children:[i.jsx("span",{children:We.max_batch_label}),i.jsx("input",{id:o("batch"),name:"email_max_batch",type:"number",min:1,max:cu,step:1,disabled:d,value:String(t.maxBatch??ju),onChange:f=>s({maxBatch:f.target.value.trim()===""?null:Number(f.target.value)})})]}),i.jsx("p",{className:"af-auto__hint",children:We.max_batch_hint}),i.jsxs("fieldset",{className:"af-auto__field af-email__filters",disabled:d,children:[i.jsx("legend",{children:We.filters_legend}),i.jsxs("label",{className:"af-auto__field",htmlFor:o("from"),children:[i.jsx("span",{children:We.from_in}),i.jsx("input",{id:o("from"),name:"email_from_in",value:t.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:o("domain"),children:[i.jsx("span",{children:We.from_domain_in}),i.jsx("input",{id:o("domain"),name:"email_from_domain_in",value:t.fromDomainIn,spellCheck:!1,placeholder:"example.com",onChange:f=>s({fromDomainIn:f.target.value})})]}),i.jsxs("label",{className:"af-auto__field",htmlFor:o("to"),children:[i.jsx("span",{children:We.to_in}),i.jsx("input",{id:o("to"),name:"email_to_in",value:t.toIn,spellCheck:!1,onChange:f=>s({toIn:f.target.value})})]}),i.jsxs("label",{className:"af-auto__field",htmlFor:o("subject"),children:[i.jsx("span",{children:We.subject_contains}),i.jsx("input",{id:o("subject"),name:"email_subject_contains",value:t.subjectContains,maxLength:200,onChange:f=>s({subjectContains:f.target.value})})]}),i.jsxs("label",{className:"af-auto__field",htmlFor:o("attach"),children:[i.jsx("span",{children:We.has_attachment}),i.jsxs("select",{id:o("attach"),name:"email_has_attachment",value:t.hasAttachment,onChange:f=>s({hasAttachment:f.target.value}),children:[i.jsx("option",{value:"any",children:We.has_attachment_any}),i.jsx("option",{value:"yes",children:We.has_attachment_yes}),i.jsx("option",{value:"no",children:We.has_attachment_no})]})]}),i.jsx("p",{className:"af-auto__hint",children:We.list_hint})]})]})}function Mw(e){const t=o=>`${e.idBase}-email-${o}`,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:o=>e.onNotifyEmailChange(o.target.checked)})," ",We.notify_label]}),i.jsx("p",{className:"af-auto__hint",children:We.notify_hint}),i.jsxs("fieldset",{className:"af-auto__field",disabled:s,"data-field":"email-recipients",children:[i.jsx("legend",{children:We.recipients_legend}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",name:t("rcpt"),value:"self",checked:e.recipients.mode==="self",onChange:()=>e.onRecipientsChange({...e.recipients,mode:"self"})})," ",We.recipients_self]}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",name:t("rcpt"),value:"list",checked:e.recipients.mode==="list",onChange:()=>e.onRecipientsChange({...e.recipients,mode:"list"})})," ",We.recipients_list]}),e.recipients.mode==="list"?i.jsx("textarea",{name:"email_recipient_list","aria-label":We.recipients_list,rows:2,spellCheck:!1,value:e.recipients.addresses,placeholder:"colleague@example.com",onChange:o=>e.onRecipientsChange({mode:"list",addresses:o.target.value})}):null,i.jsx("p",{className:"af-auto__hint",children:We.recipients_hint})]})]})}const Lw={active:"play",paused:"pause",completed:"check",failed:"error",archived:"archive"};function Ep(e){const t=String(e.status),s=Lw[t];return i.jsxs("span",{className:`af-auto__status af-auto__status--${t}${e.className?` ${e.className}`:""}`,"data-state":t,children:[i.jsx("span",{className:"af-auto__status-word",children:cw[t]??t}),s?i.jsx(ie,{name:s,size:e.iconSize??11,className:"af-auto__status-icon"}):null]})}const gh="Discuss — fork at this occurrence (own workspace, automation files read-only)",ol=e=>i.jsx("div",{className:"af-auto-text","data-unformatted":"true",children:e});function Pw(e){return $u(e)?e:{status:0,code:"client_error",message:e&&typeof e=="object"&&"message"in e?String(e.message):String(e)}}function yh(e){const t=e.path.split(new RegExp("(?<=[/\\\\_-])"));return i.jsx("code",{className:"af-auto__path-text",children:t.map((s,o)=>i.jsxs(gt.Fragment,{children:[s,o<t.length-1?i.jsx("wbr",{}):null]},o))})}function Ow(e,t){const s=e.trigger,o=t.find(l=>l.id===s.source_id&&l.version===s.source_version);return o?"available"in o&&o.available===!1?`Trigger source ${s.source_id}@${s.source_version} is unavailable${o.unavailable_reason?`: ${o.unavailable_reason}`:"."}`:null:`This gateway does not list the trigger source ${s.source_id}@${s.source_version}.`}function Dw(e){const t=e.summary,s=_p(t),o=Ow(t,e.triggerSources),l=t.next_fire_at?`${Cr(t.next_fire_at)} (${xp(t.next_fire_at,e.nowMs??Date.now())})`:t.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:t.title}),i.jsx(Ep,{status:t.status}),t.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:[ku(t.trigger),o?i.jsxs("span",{className:"af-auto__warn",role:"note",children:[" ",o]}):null]}),i.jsx("dt",{children:"Context"}),i.jsx("dd",{"data-fact":"context",children:up(t.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:t.occurrence_count}),t.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
|
-
${t.workspace_root}`,"aria-label":`Browse the automation's folder ${t.workspace_root}`,onClick:()=>{var u;return(u=e.onOpenWorkspace)==null?void 0:u.call(e,t.automation_id)},children:[i.jsx(ie,{name:"folder",size:14,className:"af-auto__path-icon"}),i.jsx(yh,{path:t.workspace_root})]}):i.jsxs("span",{className:"af-auto__path af-auto__path--static",children:[i.jsx(ie,{name:"folder",size:14,className:"af-auto__path-icon"}),i.jsx(yh,{path:t.workspace_root})]})})]}):null,i.jsx("dt",{children:"Attention"}),i.jsx("dd",{"data-fact":"attention",className:t.attention.unread||t.attention.pending_waits?"is-notable":void 0,children:bp(t)}),t.revision!==null?i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Revision"}),i.jsx("dd",{"data-fact":"revision",children:t.revision})]}):null]})]})}function Fw(e){const t=e.definition,s=e.renderText??ol,o=t.target.input_data.prompt,l=t.policy.retry,u=t.policy.tool_approval;return i.jsxs("details",{className:"af-auto__definition","data-definition-revision":t.revision,open:e.open,children:[i.jsxs("summary",{children:[i.jsx(ie,{name:"chevronRight",size:14,className:"af-auto__definition-chevron"}),i.jsx(ie,{name:"file",size:14}),i.jsx("span",{className:"af-auto__definition-title",children:"Definition"}),i.jsxs("span",{className:"af-auto__definition-meta",children:["revision ",t.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:t.target.workflow_id})}),typeof o=="string"&&o?i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Task"}),i.jsx("dd",{"data-def":"prompt",children:s(o)})]}):null,i.jsx("dt",{children:"Trigger"}),i.jsxs("dd",{"data-def":"trigger",children:[t.trigger.source_id,"@",t.trigger.source_version," · ",ku(t.trigger),i.jsx("pre",{className:"af-auto__json",children:JSON.stringify(t.trigger.config,null,2)})]}),i.jsx("dt",{children:"Context"}),i.jsx("dd",{"data-def":"context",children:up(t.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:gw(t.notify)}),i.jsx("dt",{children:"May email"}),i.jsx("dd",{"data-def":"email_allowed_recipients",children:mw(t.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:t.revision})]})]})}const Do=ap,$p=Do.labels,Ap={pause:"pause",resume:"play",run_now:Do.icons.run_now.name,stop_current:"stop",revise:"edit",archive:"archive",discuss:"chat"},pu=Do.hints,zw=Do.run_now_next_run_line,Ww=Do.run_now_growing_line;function Uw(e,t){const s=[pu[e]];return e==="run_now"&&t&&(t.next_fire_at&&s.push(zw.replace("{time}",Cr(t.next_fire_at))),t.context_mode==="growing"&&s.push(Ww)),s.join(`
|
|
52
|
-
`)}function Bw(e,t,s){const o=new Map;for(const d of t){const f=e[d];if(f.enabled)continue;const h=f.reason??"Not available now.";o.set(h,[...o.get(h)??[],d])}const l=[],u={};return[...o.entries()].forEach(([d,f],h)=>{const g=`${s}-why-${h}`;l.push({id:g,text:`${f.map(y=>$p[y]).join(", ")}: ${d}`});for(const y of f)u[y]=g}),{lines:l,describedBy:u}}function Ft(e){return i.jsxs(i.Fragment,{children:[i.jsx(ie,{name:e.icon,size:14,className:"af-auto__btn-icon"}),i.jsx("span",{children:e.label})]})}function Vw(e){const t=el(e.summary,e.occurrences,e.busy),s=[e.summary.status==="paused"?"resume":"pause","run_now","stop_current","revise","archive"],o=Bw(t,s,e.idBase??`af-auto-${e.summary.automation_id}`),l=(u,d,f)=>{const h=Uw(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:!t[u].enabled,title:t[u].enabled?h:`${t[u].reason}
|
|
53
|
-
${h}`,"aria-description":h,"aria-describedby":o.describedBy[u],"aria-pressed":f==null?void 0:f.pressed,onClick:d,children:i.jsx(Ft,{icon:Ap[u],label:(f==null?void 0:f.label)??$p[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(sr.resume)):l("pause",()=>e.onCommand(sr.pause)),l("run_now",()=>e.onCommand(sr.run_now)),l("stop_current",()=>e.onCommand(sr.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(ie,{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(ie,{name:"x",size:12})}):null]}):null})]}),o.lines.length?i.jsxs("p",{className:"af-auto__reasons",children:[i.jsx(ie,{name:"info",size:12,className:"af-auto__reasons-icon"}),o.lines.map(u=>i.jsx("span",{id:u.id,children:u.text},u.id))]}):null,e.summary.status==="paused"&&t.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:!t.archive.enabled,onClick:()=>e.onCommand(sr.archive),children:i.jsx(Ft,{icon:"archive",label:"Archive"})}),i.jsx("button",{type:"button",className:"af-auto__btn","data-action":"archive-cancel",onClick:e.onCancelArchive,children:i.jsx(Ft,{icon:"x",label:"Keep it"})})]})]}):null]})}const wh=[["m","minutes"],["h","hours"],["d","days"]];function Gw(e,t){const s=S=>{const T=e.elements.namedItem(S);return T&&typeof T.value=="string"?T.value:null},o=s("every_amount"),l=s("every_unit"),u=o!==null&&l!==null?`${o.trim()}${l}`:t.every,d=e.elements.namedItem("context"),f=d&&(d.value==="growing"||d.value==="independent")?d.value:t.context,h=s("prompt"),g=e.elements.namedItem("tool_approval"),y=g&&(g.value==="auto"||g.value==="ask")?g.value:t.toolApproval??null,v=e.elements.namedItem("notify_email"),x=v&&typeof v.checked=="boolean"?v.checked:t.notifyEmail??null,b=e.elements.namedItem("email_recipients"),k=s("email_recipient_list"),E=b&&(b.value==="self"||b.value==="list")?{mode:b.value,addresses:k??""}:t.emailRecipients??null;return{title:s("title")??t.title,every:u,context:f,prompt:h??t.prompt??null,toolApproval:y,notifyEmail:x,emailRecipients:E}}function Hw(e){const t=kp(e.summary,e.definition),s=t.every?Oo(t.every):null,o=s&&s.unit==="s"?[["s","seconds"],...wh]:wh,l=`af-auto-revise-${e.summary.automation_id}`,u=Su(e.emailStatus),d=il(e.summary.trigger);return i.jsxs("form",{className:"af-auto__revise","aria-labelledby":`${l}-heading`,onSubmit:f=>{f.preventDefault(),e.onSubmit(Gw(f.currentTarget,t))},onKeyDown:f=>{f.key==="Escape"&&(f.preventDefault(),e.onCancel())},children:[i.jsxs("h3",{className:"af-auto__form-title",id:`${l}-heading`,children:[i.jsx(ie,{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:t.title,maxLength:120,required:!0})]}),t.prompt!==null&&t.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:t.prompt,rows:Math.min(10,Math.max(3,t.prompt.split(`
|
|
54
|
-
`).length+1)),required:!0})]}):null,s?i.jsxs("fieldset",{className:"af-auto__field",children:[i.jsx("legend",{children:d?We.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:o.map(([f,h])=>i.jsx("option",{value:f,children:h},f))})]}),d?i.jsx("p",{className:"af-auto__hint","data-email-rule":"interval",children:We.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:t.context==="independent"})," Independent — each run starts fresh"]}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",name:"context",value:"growing",defaultChecked:t.context==="growing"})," Growing — each run sees the previous runs"]})]}),t.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:t.toolApproval==="auto"})," Run without asking"]}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",name:"tool_approval",value:"ask",defaultChecked:t.toolApproval==="ask"})," Ask before each tool call"]})]}):null,t.notifyEmail!==null&&t.notifyEmail!==void 0&&t.emailRecipients?i.jsxs("fieldset",{className:"af-auto__field","data-field":"email",children:[i.jsx("legend",{children:"Email"}),u?null:i.jsx(hu,{status:e.emailStatus,onOpenMyEmail:e.onOpenMyEmail}),i.jsxs("label",{className:"af-email__check",children:[i.jsx("input",{type:"checkbox",name:"notify_email",defaultChecked:t.notifyEmail,disabled:!u&&!t.notifyEmail})," ",We.notify_label]}),i.jsx("p",{className:"af-auto__hint",children:We.notify_hint}),i.jsxs("fieldset",{className:"af-auto__field","data-field":"email-recipients",children:[i.jsx("legend",{children:We.recipients_legend}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",name:"email_recipients",value:"self",defaultChecked:t.emailRecipients.mode==="self"})," ",We.recipients_self]}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",name:"email_recipients",value:"list",defaultChecked:t.emailRecipients.mode==="list",disabled:!u&&t.emailRecipients.mode!=="list"})," ",We.recipients_list]}),i.jsx("textarea",{name:"email_recipient_list","aria-label":We.recipients_list,rows:2,spellCheck:!1,defaultValue:t.emailRecipients.addresses,disabled:!u&&t.emailRecipients.mode!=="list"}),i.jsx("p",{className:"af-auto__hint",children:We.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(Ft,{icon:"check",label:"Save changes"})}),i.jsx("button",{type:"button",className:"af-auto__btn","data-action":"edit-cancel",onClick:e.onCancel,children:i.jsx(Ft,{icon:"x",label:"Cancel"})})]})]})}function mu(e,t){const s=e.elements.namedItem(t);return s&&typeof s.value=="string"?s.value.trim():""}function Kw(e){const t=e.wait,s=`${e.idBase}-${t.run_id}-${t.wait_key}-prompt`,o=d=>e.onAnswerWait(t.run_id,t.wait_key,d),l=e.renderText??ol,u=d=>i.jsxs("div",{className:"af-auto-wait__prompt",id:s,children:[i.jsx("span",{className:"af-auto-wait__kind",children:Sp[t.kind]??"Waiting"}),t.prompt?l(t.prompt):i.jsxs("span",{children:[" ",d]})]});if(t.kind==="tool_approval"){const d=$w(t);return i.jsxs("div",{className:"af-auto-wait af-auto-wait--tool_approval",role:"group","data-wait-key":t.wait_key,"data-wait-kind":t.kind,"aria-labelledby":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:()=>o({approved:!0}),children:i.jsx(Ft,{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:()=>o({approved:!1}),children:i.jsx(Ft,{icon:"x",label:"Deny"})})]})]})}return t.kind==="event"?i.jsxs("form",{className:"af-auto-wait af-auto-wait--event","data-wait-key":t.wait_key,"data-wait-kind":t.kind,"aria-labelledby":s,onSubmit:d=>{var h;d.preventDefault();const f=Aw(mu(d.currentTarget,"payload"));f.ok?o({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(Ft,{icon:"send",label:"Send event"})})})]}):t.kind==="ask_user"?i.jsxs("form",{className:"af-auto-wait af-auto-wait--ask_user","data-wait-key":t.wait_key,"data-wait-kind":t.kind,"aria-labelledby":s,onSubmit:d=>{d.preventDefault();const f=mu(d.currentTarget,"response");f&&o({response:f})},children:[u("The run is waiting for your input."),t.choices&&t.choices.length?i.jsx("div",{className:"af-auto__row",role:"group","aria-label":"Choices",children:t.choices.map(d=>i.jsx("button",{type:"button",className:"af-auto__btn","data-action":"wait-choice",disabled:e.busy,onClick:()=>o({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(Ft,{icon:"send",label:"Answer"})})]})]}):i.jsxs("div",{className:"af-auto-wait",role:"group","data-wait-key":t.wait_key,"data-wait-kind":String(t.kind),"aria-labelledby":s,children:[u("The run is waiting."),i.jsxs("p",{className:"af-auto__hint",children:["This kind of wait (",String(t.kind),") cannot be answered here; open the run."]})]})}function Jw(e){const{row:t,tone:s,badge:o,statusText:l}=e.view,u=`af-auto-occ-${t.run_id}`,d=e.renderText??ol,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=(x,b)=>e.renderTurn?e.renderTurn({kind:x,role:x==="trigger"?"user":"assistant",text:b,index:t.index,runId:t.run_id}):d(b),y=e.renderTurn?" af-auto-turn--card":"",v=s==="failed"?t.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":t.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:["#",t.index]})," · ",t.trigger.summary," · fired ",Cr(t.fired_at)]}),i.jsx("div",{className:"af-auto-turn__text",children:g("trigger",t.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:[o?i.jsx("span",{className:`af-auto-badge af-auto-badge--${s}`,children:o}):null,i.jsx("span",{className:"af-auto-turn__status",children:l}),t.finished_at?i.jsxs("span",{children:[" · ",Cr(t.finished_at)]}):null]}),t.notify?i.jsxs("div",{className:"af-auto-notify","data-notify":"true",children:[i.jsx("strong",{children:t.notify.title}),t.notify.body?i.jsx("div",{className:"af-auto-notify__body",children:d(t.notify.body)}):null]}):null,t.failure?i.jsxs("div",{className:"af-auto-failure","data-failure":t.failure.reason_code,children:[i.jsx("strong",{children:t.failure.reason_code}),": ",t.failure.message," ",i.jsxs("span",{className:"af-auto-turn__muted",children:["(after ",t.failure.attempts," ",t.failure.attempts===1?"attempt":"attempts",")"]})]}):null,t.answer?i.jsx("div",{className:"af-auto-turn__text",children:g("answer",t.answer)}):i.jsx("div",{className:"af-auto-turn__empty",children:v}),t.artifacts.length?i.jsx("ul",{className:"af-auto-artifacts","aria-label":"Artifacts",children:t.artifacts.map(x=>i.jsxs("li",{children:[e.onOpenResource?i.jsxs("button",{type:"button",className:"af-auto__linkbtn","data-action":"open-artifact",onClick:()=>{var b;return(b=e.onOpenResource)==null?void 0:b.call(e,{kind:"artifact",url:x.url,name:x.name,mimeType:x.mime_type,runId:t.run_id})},children:[i.jsx(ie,{name:"file",size:13,className:"af-auto__btn-icon"})," ",x.name]}):i.jsx("span",{className:"af-auto-artifact__name",children:x.name})," ",i.jsx("span",{className:"af-auto-turn__muted",children:x.mime_type})]},x.artifact_id))}):null,t.waits.map(x=>i.jsx(Kw,{wait:x,busy:e.busy,idBase:u,onAnswerWait:e.onAnswerWait,onWaitError:e.onWaitError,renderText:e.renderText},`${x.run_id}:${x.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:t.run_id})}),i.jsx("dt",{children:"Attempts"}),i.jsx("dd",{children:t.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(t.run_id),children:i.jsx(Ft,{icon:"list",label:"Open run ledger"})}),e.onOpenResource?i.jsx("button",{type:"button",className:"af-auto__btn","data-action":"open-ledger-json",onClick:()=>{var x;return(x=e.onOpenResource)==null?void 0:x.call(e,{kind:"ledger",url:t.ledger_url,name:`run-${t.run_id}-ledger.json`,runId:t.run_id})},children:i.jsx(Ft,{icon:"file",label:"Ledger (JSON)"})}):null,t.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 x;return(x=e.onOpenWorkspace)==null?void 0:x.call(e,t.run_id)},children:i.jsx(Ft,{icon:"folder",label:"Workspace"})}):null]})]}),e.discussOpen?i.jsxs("form",{className:"af-auto-discuss","aria-label":`${gh}, from occurrence ${t.index}`,onSubmit:x=>{x.preventDefault();const b=mu(x.currentTarget,"prompt");b&&e.onDiscussSubmit(t.index,b)},children:[i.jsxs("p",{className:"af-auto__hint",children:["Starts a new session that forks this automation at #",t.index," with its full history (runs 1–",t.index,"). It works in its own writable workspace; the automation's files are mounted read-only for the file tools (shell commands are not sandboxed), and nothing is written back into the automation's session."]}),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(Ft,{icon:"send",label:"Start discussion"})}),i.jsx("button",{type:"button",className:"af-auto__btn","data-action":"discuss-cancel",onClick:e.onDiscussCancel,children:i.jsx(Ft,{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:pu.discuss,"aria-description":pu.discuss,"aria-describedby":h?`${u}-discuss-why`:void 0,onClick:()=>e.onDiscussOpen(t.index),children:i.jsx(Ft,{icon:Ap.discuss,label:gh})}),h?i.jsx("span",{className:"af-auto__reasons",id:`${u}-discuss-why`,children:h}):null]})]})]})}const Qw=5e3,Yw={[sr.pause]:"Pause sent.",[sr.resume]:"Resume sent.",[sr.run_now]:"Run requested.",[sr.stop_current]:"Stop sent."};function Xw(e){const{summary:t,busy:s}=e,o=e.renderText??ol,l=w.useId(),u=w.useRef(null),[d,f]=w.useState(!1),h=e.editOpen!==void 0,y=el(t,e.occurrences,!1).revise.enabled&&(h?e.editOpen===!0:d),v=w.useRef(null);y?(!v.current||v.current.summary.automation_id!==t.automation_id)&&(v.current={summary:t,definition:e.definition}):v.current=null;const x=v.current,b=w.useRef(e.onEditOpenChange);b.current=e.onEditOpenChange;const k=W=>{var oe;h||f(W),(oe=b.current)==null||oe.call(b,W)},[E,S]=w.useState([]),[T,A]=w.useState(!1),[$,j]=w.useState(null),[P,V]=w.useState(null),[H,L]=w.useState(null);w.useEffect(()=>{if(!H)return;const W=setTimeout(()=>L(null),Qw);return()=>clearTimeout(W)},[H]),w.useEffect(()=>{var oe;if(!y)return;S([]);const W=mh(u.current,['.af-auto__revise [name="title"]']);W==null||W.focus(),(oe=W==null?void 0:W.scrollIntoView)==null||oe.call(W,{block:"nearest"})},[y,t.automation_id]);const[de,re]=w.useState(null);w.useEffect(()=>{var W;de&&((W=mh(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 Np(e.newId??Cp));const U=Q.current,J=W=>V(Pw(W)),fe=(W,oe,le)=>{V(null),L(null),oe(U.idFor(W)).then(he=>{U.settle(W,{ok:!0}),le(he)},he=>{U.settle(W,{ok:!1,error:he}),J(he)})},ce=xw(t),ye=w.useRef(e.onSeen);ye.current=e.onSeen;const ve=w.useRef(null);ve.current||(ve.current=new Rw),w.useEffect(()=>{const W=ve.current,oe=ce?`${t.automation_id}|${ce}`:null;if(!ce||!W.next(oe,t))return;const le=t;ye.current(ce).then(()=>W.succeeded(oe),he=>{W.failed(oe,le),J(he)})});const q=el(t,e.occurrences,s),ae=_w(e.occurrences),G=t.occurrence_count-e.occurrences.length,C=P??e.error??null,B=C?Eu(C):null,F=t.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(Dw,{summary:t,triggerSources:e.triggerSources,titleId:l,nowMs:e.nowMs,onOpenWorkspace:e.onOpenWorkspace}),i.jsx(Vw,{summary:t,occurrences:e.occurrences,busy:s,confirmingArchive:T,reviseOpen:y,notice:H,onDismissNotice:()=>L(null),idBase:`${l}-ctl`,onCommand:W=>fe(`command:${W}`,oe=>e.onCommand(W,void 0,{command_id:oe}),()=>{W===sr.archive?(A(!1),L("Archive requested."),re(['[data-action="archive"]'])):L(Yw[W]??"Command sent.")}),onToggleRevise:()=>{S([]),k(!y)},onAskArchive:()=>A(!0),onCancelArchive:()=>{A(!1),re(['[data-action="archive"]'])}}),y&&x?i.jsx(Hw,{summary:x.summary,definition:x.definition,busy:s,errors:E,emailStatus:e.emailStatus,onOpenMyEmail:e.onOpenMyEmail,onCancel:()=>{k(!1),re(['[data-action="edit"]'])},onSubmit:W=>{const oe=x.summary,le=kw(oe,W,x.definition);if(le===null){S(["Nothing changed."]);return}if("errors"in le){S(le.errors);return}S([]),fe(`revise:${oe.revision}:${JSON.stringify(le)}`,he=>e.onRevise(le,oe.revision,{command_id:he}),()=>{L("Saved; applies from the next run."),k(!1),re(['[data-action="edit"]'])})}}):e.definition?i.jsx(Fw,{definition:e.definition,renderText:o}):null,B?i.jsxs("div",{className:"af-auto__error",role:"alert","data-code":C==null?void 0:C.code,children:[i.jsx(ie,{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(ie,{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," · ",Cr(W.at)]}),W.body?i.jsx("div",{className:"af-auto__attention-body",children:o(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:Sp[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:o(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(Ft,{icon:"history",label:`Load earlier occurrences (${G} more)`})}):null,ae.length?i.jsx("ol",{className:"af-auto__timeline","aria-label":"Occurrences",children:ae.map(W=>{const oe=`[data-index="${W.row.index}"]`;return i.jsx(Jw,{view:W,busy:s,discuss:q.discuss,renderText:o,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(Z){J(Z)}}:void 0,discussOpen:$===W.row.index,onOpenRun:e.onOpenRun,onAnswerWait:(le,he,Z)=>{V(null),e.onAnswerWait(le,he,Z).then(()=>L("Answer sent."),J)},onWaitError:le=>V({status:0,code:"invalid_payload",message:le}),onDiscussOpen:j,onDiscussCancel:()=>{j(null),re([`${oe} [data-action="discuss"]`])},onDiscussSubmit:(le,he)=>fe(`discuss:${le}:${he}`,Z=>e.onDiscuss(le,he,{request_id:Z}),Z=>{j(null),L(`Discussion started (session ${Z.session_id}).`),re([`${oe} [data-action="discuss"]`])})},W.row.run_id)})}):i.jsx("p",{className:"af-auto__empty",children:"No occurrences yet."})]})}function Zw(e){var Ue;const t=w.useId(),s=w.useId(),o=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,v]=w.useState(Nu),[x,b]=w.useState(!1),[k,E]=w.useState(du),[S,T]=w.useState("24"),[A,$]=w.useState("h"),[j,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,ae]=w.useState([]),G=w.useRef(null);if(G.current||(G.current=new Np(()=>(e.newRequestId??Cp)())),w.useEffect(()=>{var ee;if(!e.open)return;const ke=document.activeElement;(ee=l.current)==null||ee.focus();const X=pe=>{if(!pe.defaultPrevented){if(pe.key==="Escape"){pe.preventDefault(),u.current();return}op(pe,o.current,document.activeElement)}};return window.addEventListener("keydown",X),()=>{window.removeEventListener("keydown",X),ke&&typeof ke.focus=="function"&&ke.focus()}},[e.open]),!e.open)return null;const C=Su(e.emailStatus),B=h==="email"&&C,F=h==="email"&&!C?"every":h,W={prompt:d,when:h==="once"?{kind:"once",at:j}:{kind:"every",amount:Number(S),unit:A},...B?{trigger:"email",email:{...y,usesModel:e.targetUsesModel!==!1}}:{},...C&&x?{notifyEmail:!0}:{},...C&&k.mode==="list"?{emailRecipients:k}:{},context:V,toolApproval:L,title:re,...F==="every"&&U?{startAt:U}:{},...F==="every"&&fe.trim()?{count:Number(fe)}:{},...F==="every"&&ye?{until:ye}:{}},oe=Nw(W),le=e.busy===!0,he=e.error?Eu(e.error):null,Z=ke=>`${s}-${ke}`,Ce=ke=>{ke.preventDefault();const X=Cw(W,{target:e.target,requestId:""});if(!X.ok){ae(X.errors);return}ae([]);const ee=G.current,pe=JSON.stringify(X.body),De={...X.body,request_id:ee.idFor(pe)};Promise.resolve(e.onSubmit(De)).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:o,className:"af-appearance af-schedule",role:"dialog","aria-modal":"true","aria-labelledby":t,onClick:ke=>ke.stopPropagation(),children:[i.jsx("div",{className:"af-appearance__title",id:t,children:e.title??"Schedule a task"}),i.jsxs("form",{className:"af-schedule__form",onSubmit:Ce,"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:Z("prompt"),children:[i.jsx("span",{children:"Task"}),i.jsx("textarea",{id:Z("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:Z("kind"),value:"every",checked:F==="every",onChange:()=>g("every")})," Repeat"]}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",name:Z("kind"),value:"once",checked:h==="once",onChange:()=>g("once")})," Once at…"]}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",name:Z("kind"),value:"email",checked:B,disabled:!C,onChange:()=>g("email")})," ",We.trigger_label]})]}),C?null:i.jsx(hu,{status:e.emailStatus,onOpenMyEmail:e.onOpenMyEmail}),B?i.jsx(Iw,{value:{...y,usesModel:e.targetUsesModel!==!1},onChange:v,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:jw.map(ke=>ke.when.kind==="every"?i.jsx("button",{type:"button",className:"af-auto__btn af-auto__btn--quiet","aria-pressed":Number(S)===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:S,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:Z("once"),children:[i.jsx("span",{children:"Run once at (UTC)"}),i.jsx("input",{id:Z("once"),type:"datetime-local",value:j,onChange:ke=>P(ke.target.value)})]}),i.jsx("p",{className:"af-schedule__preview","aria-live":"polite","data-preview":"true",children:oe?`Runs ${oe}.`: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:Z("ctx"),value:"independent",checked:V==="independent",onChange:()=>H("independent")})," Independent — each run starts fresh"]}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",name:Z("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:Z("tools"),value:"auto",checked:L==="auto",onChange:()=>de("auto")})," Run without asking"]}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",name:Z("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:We.untrusted_hint}):null,L==="auto"?i.jsxs("p",{className:"af-schedule__consent","data-consent":"true",children:[Ew,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"}),C?null:i.jsx(hu,{status:e.emailStatus,onOpenMyEmail:e.onOpenMyEmail}),i.jsx(Mw,{notifyEmail:C&&x,onNotifyEmailChange:b,recipients:C?k:du,onRecipientsChange:E,disabled:!C,idBase:s})]}),i.jsxs("details",{className:"af-schedule__advanced",children:[i.jsx("summary",{children:"Advanced"}),i.jsxs("label",{className:"af-auto__field",htmlFor:Z("title"),children:[i.jsx("span",{children:"Title"}),i.jsx("input",{id:Z("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:Z("start"),children:[i.jsx("span",{children:"First run at (UTC; empty = now)"}),i.jsx("input",{id:Z("start"),type:"datetime-local",value:U,onChange:ke=>J(ke.target.value)})]}),i.jsxs("label",{className:"af-auto__field",htmlFor:Z("count"),children:[i.jsx("span",{children:"Stop after this many runs"}),i.jsx("input",{id:Z("count"),type:"number",min:1,step:1,value:fe,onChange:ke=>ce(ke.target.value)})]}),i.jsxs("label",{className:"af-auto__field",htmlFor:Z("until"),children:[i.jsx("span",{children:"Stop at (UTC)"}),i.jsx("input",{id:Z("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":(Ue=e.error)==null?void 0:Ue.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 vh(e,t,s,o){const l=w.useRef(null);w.useEffect(()=>{var f,h;if(!t)return;if(e){l.current=document.activeElement||null;const g=o(),y=window.setTimeout(()=>g==null?void 0:g.focus(),0);return()=>window.clearTimeout(y)}const u=s(),d=document.activeElement;l.current&&(!d||d===document.body||u&&u.contains(d))&&((h=(f=l.current).focus)==null||h.call(f)),l.current=null},[e,t])}function qw(e,t){return t?"drawers":e?"overlay":"docked"}function ev(e){return{open:e==="docked",wanted:!0}}function tv(e,t,s){return t===s?e:s==="docked"?{open:e.wanted,wanted:e.wanted}:{open:!1,wanted:t==="docked"?e.open:e.wanted}}function nv(e,t,s){return t==="docked"?{open:s,wanted:s}:{open:s,wanted:e.wanted}}function rv(e,t){return t==="drawers"?e:!1}function sv(e){return e.key!=="Escape"||e.defaultPrevented||e.overlayOpen?null:e.sidebarOpen?"sidebar":e.inspectorOpen&&e.inspectorIsOverlay?"inspector":null}function iv(e=typeof document<"u"?document:void 0){return!!(e!=null&&e.querySelector('[role="dialog"], [role="alertdialog"]'))}function ov(e){const t=Number.parseFloat(String(e??"").trim());return Number.isFinite(t)&&t>0}let bo=null;function av(){var o;if(bo)return bo;if(typeof document>"u"||typeof MutationObserver>"u")return()=>{};const e=document.documentElement,t=()=>{const l=ov(getComputedStyle(e).getPropertyValue("--keyboard-inset"));l&&e.dataset.keyboard!=="open"?e.dataset.keyboard="open":!l&&e.dataset.keyboard&&delete e.dataset.keyboard},s=new MutationObserver(t);return s.observe(e,{attributes:!0,attributeFilter:["style"]}),(o=window.visualViewport)==null||o.addEventListener("resize",t),t(),bo=()=>{var l;s.disconnect(),(l=window.visualViewport)==null||l.removeEventListener("resize",t),bo=null},bo}function lv(e){const t=e.querySelector(".code-topbar");if(!t)return null;const o=getComputedStyle(t).display==="contents"?e.querySelector(".code-toolbar"):t,l=o==null?void 0:o.getBoundingClientRect().bottom;return typeof l=="number"&&l>0?Math.round(l):null}function cv(e){const[t,s]=w.useState(e);return w.useEffect(()=>{if(typeof window>"u")return;const o=()=>s(lv(document)??e);o();const l=typeof ResizeObserver<"u"?new ResizeObserver(o):null,u=document.querySelector(".code-topbar"),d=document.querySelector(".code-toolbar");return l&&u&&l.observe(u),l&&d&&l.observe(d),window.addEventListener("resize",o),()=>{l==null||l.disconnect(),window.removeEventListener("resize",o)}},[e]),t}function uv(e){const t=e.isDrawer&&!e.open;return i.jsx("aside",{className:"code-sidebar","aria-label":"Conversations",...t?{inert:""}:{},children:e.children})}const Tp="abstractcode.sidebar.panels",ko={automations:!0,conversations:!0};function dv(e){try{const t=e==null?void 0:e.getItem(Tp);if(!t)return{...ko};const s=JSON.parse(t);if(!s||typeof s!="object")return{...ko};const o=s;return{automations:typeof o.automations=="boolean"?o.automations:ko.automations,conversations:typeof o.conversations=="boolean"?o.conversations:ko.conversations}}catch{return{...ko}}}function fv(e,t){try{t==null||t.setItem(Tp,JSON.stringify(e))}catch{}}function hv(e,t){return{...e,[t]:!e[t]}}function _h(){try{return typeof window<"u"?window.localStorage:null}catch{return null}}function pv(){const[e,t]=w.useState(()=>dv(_h())),s=w.useCallback(o=>{t(l=>{const u=hv(l,o);return fv(u,_h()),u})},[]);return[e,s]}const Au=e=>({toggle:`code-panel-${e}-toggle`,region:`code-panel-${e}`});function Rp(e){const t=Au(e.panel);return i.jsxs("div",{className:"code-section-label",children:[i.jsxs("button",{type:"button",className:"code-panel-toggle",id:t.toggle,"aria-expanded":e.open,"aria-controls":t.region,onClick:e.onToggle,children:[i.jsx(ie,{name:"chevronDown",size:11}),i.jsx("span",{children:e.label})]}),e.actions?i.jsx("span",{className:"code-panel-actions",children:e.actions}):null]})}function mv(e){const t=Au("conversations");return i.jsxs("section",{className:"code-panel code-conversations","data-open":e.open?"true":"false",children:[i.jsx(Rp,{panel:"conversations",label:"CONVERSATIONS",open:e.open,onToggle:e.onToggle,actions:e.actions}),i.jsx("nav",{className:"code-sessions",id:t.region,"aria-labelledby":t.toggle,hidden:!e.open,children:e.children})]})}function Ip(e){const t=String(e??"").trim();if(!t||!(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]")))return null;try{return JSON.parse(t)}catch{return null}}function gv(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function yv(e){const t=String(e.role||"message").trim()||"message",s=String(e.title||"").trim(),o=String(e.ts||"").trim(),l=[t];return s&&l.push(s),o&&l.push(o),l.join(" · ")}function wv(e){return e.endsWith(`
|
|
55
|
-
`)?e:`${e}
|
|
56
|
-
`}function vv(e){return String(e||"").trimStart().startsWith("```")}function _v(e,t){const o=[`# ${"Chat".trim()||"Chat"}`,""];for(const l of e){const u=yv(l);o.push(`## ${u}`,"");const d=String(l.content||""),f=Ip(d);f!==null&&!vv(d)?o.push("```json",gv(f).trimEnd(),"```",""):o.push(wv(d).trimEnd(),""),o.push("---","")}for(;o.length&&!o[o.length-1].trim();)o.pop();return o.length&&o[o.length-1]==="---"&&o.pop(),`${o.join(`
|
|
57
|
-
`).trimEnd()}
|
|
58
|
-
`}async function Tu(e){const t=String(e||"");if(!t)return!1;try{return await navigator.clipboard.writeText(t),!0}catch{try{const s=document.createElement("textarea");return s.value=t,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 xv(e){const t=String(e.filename).trim()||"export.txt",s=String(e.text||""),o=String(e.mime||"text/plain;charset=utf-8"),l=new Blob([s],{type:o}),u=URL.createObjectURL(l),d=document.createElement("a");d.href=u,d.download=t,document.body.appendChild(d),d.click(),d.remove(),window.setTimeout(()=>URL.revokeObjectURL(u),1e3)}const bv=3,kv=Number.MAX_SAFE_INTEGER;function Mp(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Lp(e){return Array.isArray(e)}function jv(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function $i({kind:e,children:t}){return i.jsx("span",{className:`pc-json-token ${e}`,children:t})}function Sv(e){const t=JSON.stringify(e.value),s=t.length>96||t.includes("\\n")||t.includes("\\r")||t.includes("\\t"),[o,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 ${o?"open":"collapsed"}`,children:[i.jsx("button",{type:"button",className:"pc-json-string__toggle",onClick:()=>l(u=>!u),"aria-label":o?"Collapse string value":"Expand string value","aria-expanded":o,children:o?"▾":"▸"}),o?i.jsx("span",{className:"pc-json-token string pc-json-string__value",children:t}):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:t}),i.jsx("span",{className:"pc-json-string__suffix",children:"(...)"})]})]}):i.jsx($i,{kind:"string",children:t})}function Nv(e,t,s){return e===null?i.jsx($i,{kind:"null",children:"null"}):typeof e=="string"?i.jsx(Sv,{value:e,expansionMode:t,expansionVersion:s}):typeof e=="number"?i.jsx($i,{kind:"number",children:String(e)}):typeof e=="boolean"?i.jsx($i,{kind:"boolean",children:e?"true":"false"}):i.jsx($i,{kind:"string",children:JSON.stringify(String(e))})}function Cv(e){return Lp(e)?e.length===1?"1 item":`${e.length} items`:Mp(e)?Object.keys(e).length===1?"1 key":`${Object.keys(e).length} keys`:""}function Pp(e){const{label:t,value:s,depth:o,collapseAfterDepth:l,expansionMode:u,expansionVersion:d,trailingComma:f}=e,h=o*14,g=Mp(s),y=Lp(s),v=g||y,x=o<l,[b,k]=w.useState(x);w.useEffect(()=>{k(x)},[x,d]);const E=t?i.jsxs(i.Fragment,{children:[i.jsx($i,{kind:"key",children:JSON.stringify(t)}),": "]}):null;if(!v)return i.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:h},children:[E,Nv(s,u,d),f?",":""]});const S=y?"[":"{",T=y?"]":"}",A=Cv(s),$=b?`${S}`:`${S}…${T}${A?` (${A})`:""}`,j=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:b,onToggle:P=>k(P.currentTarget.open),children:[i.jsxs("summary",{className:"pc-json-viewer__summary",style:{paddingLeft:h},children:[E,i.jsx("span",{className:"pc-json-viewer__caret","aria-hidden":"true",children:b?"▾":"▸"}),i.jsx("span",{className:"pc-json-viewer__punct",children:$}),!b&&f?i.jsx("span",{className:"pc-json-viewer__punct",children:","}):null]}),b?i.jsx("div",{className:"pc-json-viewer__children",children:j.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:[j.map((P,V)=>{const H=V===j.length-1;return i.jsx(Pp,{label:P.label,value:P.value,depth:o+1,collapseAfterDepth:l,expansionMode:u,expansionVersion:d,trailingComma:!H},`${o}:${t||"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 Ev(e){const t=e.trim();if(!t)return e;if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]"))try{return JSON.parse(t)}catch{return e}return e}function Is(e){const{value:t,className:s,showCopy:o=!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):bv,f=l.mode==="unfolded"?kv:d,h=w.useMemo(()=>typeof t=="string"?Ev(t):t,[t]),g=w.useMemo(()=>jv(t),[t]),y=["pc-json-viewer",s].filter(Boolean).join(" ");w.useEffect(()=>{u(x=>({mode:"folded",version:x.version+1}))},[h]);const v=()=>{u(x=>({mode:x.mode==="unfolded"?"folded":"unfolded",version:x.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:v,"aria-expanded":l.mode==="unfolded",children:l.mode==="unfolded"?"Fold all":"Unfold all"}),o?i.jsx("button",{type:"button",className:"pc-btn pc-json-viewer__copy",onClick:()=>void Tu(g),children:"Copy JSON"}):null]}),i.jsx("div",{className:"pc-json-viewer__tree",role:"tree","aria-label":"JSON viewer",children:i.jsx(Pp,{value:h,depth:0,collapseAfterDepth:f,expansionMode:l.mode,expansionVersion:l.version,trailingComma:!1})})]})}function jo(e,t){const s=String(e??"");if(!t||!t.needles.length)return[s];const o=[],l=s.toLowerCase();let u=0;for(;u<s.length;){let d=-1,f="";for(let y=0;y<t.needlesLower.length;y++){const v=t.needlesLower[y];if(!v)continue;const x=l.indexOf(v,u);if(x===-1)continue;const b=t.needles[y]||"";b&&(d===-1||x<d||x===d&&b.length>f.length)&&(d=x,f=b)}if(d===-1||!f){o.push(s.slice(u));break}d>u&&o.push(s.slice(u,d));const h=t.hits===0&&t.id?t.id:void 0,g=s.slice(d,d+f.length);o.push(i.jsx("span",{id:h,className:t.className,children:g},`hl:${t.hits}`)),t.hits+=1,u=d+f.length}return o}function Op(e){const t=String(e||"").trim();if(t&&/^(https?:|mailto:|tel:|#|\/)/i.test(t))return t}const gu="http://same-origin.invalid/";function $v(e){try{const t=new URL(e,gu);return t.protocol==="http:"&&t.origin===new URL(gu).origin}catch{return!1}}function Dp(e){const t=String(e||"").trim();return Op(t)??(t&&$v(t)?t:void 0)}let Ms=null;function Av(e){const t=String(e||"").trim();if(!t)return!1;const s=typeof document<"u"&&document.baseURI?document.baseURI:null;if(s===null&&/^[a-z][a-z0-9+.-]*:/i.test(t))return!1;const o=s??gu;let l,u;try{l=new URL(o).origin,u=new URL(t,o)}catch{return!1}return u.protocol!=="http:"&&u.protocol!=="https:"?!1:u.origin===l}function Fp(e,t,s){return i.jsx("a",{className:"pc-md_link pc-md_image_link",href:t,target:"_blank",rel:"noopener noreferrer",children:`image: ${s||t}`},e)}function qr(e,t){const s=[],o=String(e??"");let l=0,u="";const d=()=>{if(u){for(const f of jo(u,t))s.push(f);u=""}};for(;l<o.length;){const f=o[l];if(f==="!"&&o[l+1]==="["){const h=o.indexOf("]",l+2);if(h!==-1&&o[h+1]==="("){const g=o.indexOf(")",h+2);if(g!==-1){const y=o.slice(l+2,h),v=Dp(o.slice(h+2,g));if(v&&Ms&&!Ms(v)){d(),s.push(Fp(`img:${l}`,v,y)),l=g+1;continue}if(v){d(),s.push(i.jsxs("span",{className:"pc-md_image_inline",children:[i.jsx("img",{className:"pc-md_img",src:v,alt:y,loading:"lazy"}),y?i.jsx("span",{className:"pc-md_img_caption",children:t?jo(y,t):y}):null]},`img:${l}`)),l=g+1;continue}}}}if(f==="["){const h=o.indexOf("]",l+1);if(h!==-1&&o[h+1]==="("){const g=o.indexOf(")",h+2);if(g!==-1){const y=o.slice(l+1,h),v=Op(o.slice(h+2,g));if(v){d(),s.push(i.jsx("a",{className:"pc-md_link",href:v,target:v.startsWith("#")?void 0:"_blank",rel:"noreferrer",children:qr(y,t)},`link:${l}`)),l=g+1;continue}}}}if(f==="`"){const h=o.indexOf("`",l+1);if(h!==-1){d();const g=o.slice(l+1,h);s.push(i.jsx("code",{children:t?jo(g,t):g},`code:${l}`)),l=h+1;continue}}if(f==="*"&&o[l+1]==="*"){const h=o.indexOf("**",l+2);if(h!==-1){d();const g=o.slice(l+2,h);s.push(i.jsx("strong",{children:t?jo(g,t):g},`bold:${l}`)),l=h+2;continue}}if(f==="*"&&o[l+1]!=="*"){const h=o.indexOf("*",l+1);if(h!==-1){d();const g=o.slice(l+1,h);s.push(i.jsx("em",{children:t?jo(g,t):g},`em:${l}`)),l=h+1;continue}}u+=f,l+=1}return d(),s}function Tv(e){return String(e??"").replace(/\r\n/g,`
|
|
59
|
-
`).replace(/\r/g,`
|
|
60
|
-
`).split(`
|
|
61
|
-
`)}function Qa(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 Rv(e){const t=[];for(const l of e){const u=Qa(l);u?t.push(u):t.length>0&&l.trim()&&(t[t.length-1].content+=` ${l.trim()}`)}const s=[],o=[];for(const l of t){for(;o.length>0&&l.indent<o[o.length-1].indent;)o.pop();let u=o.length>0?o[o.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),o.push({indent:l.indent,node:h}),u=o[o.length-1]}}else if(u&&u.node.ordered!==l.ordered){o.pop();const d=o.length>0?o[o.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);o.push({indent:l.indent,node:f}),u=o[o.length-1]}if(!u){const d={ordered:l.ordered,start:l.start,items:[]};s.push(d),o.push({indent:l.indent,node:d}),u=o[o.length-1]}u.node.items.push({content:l.content,children:[]})}return s}function zp(e,t,s){const o=e.items.map((l,u)=>i.jsxs("li",{children:[qr(l.content,t),l.children.map((d,f)=>zp(d,t,`${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:o},s):i.jsx("ul",{className:"pc-md_ul",children:o},s)}function Iv(e,t,s){return Rv(e).map((o,l)=>zp(o,t,`${s}:${l}`))}function xh(e){let t=String(e??"").trim();return t?(t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1)),t.split("|").map(s=>String(s??"").trim())):[]}function bh(e){let t=String(e??"").trim();if(!t)return!1;t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1));const s=t.split("|").map(o=>String(o??"").trim());return s.length<2?!1:s.every(o=>/^:?-{3,}:?$/.test(o))}const kh=/^(#{1,5})\s+(.*)$/;function jh(e){return e.trim().startsWith("```")}function Sh(e){return e.trimStart().startsWith(">")}function Wp(e){const t=Ms;Ms=e.images==="link"?e.inlineImage||Av:null;try{return Mv(e)}finally{Ms=t}}function Mv({text:e,className:t,highlight:s,highlights:o,highlightClassName:l,highlightId:u}){const d=Tv(e),f=[],h=[];Array.isArray(o)&&h.push(...o),typeof s=="string"&&s.trim()&&h.push(s);const g=Array.from(new Set(h.map(b=>String(b??"").trim()).filter(Boolean))).filter(b=>b.length>=4),y=g.length?{needles:g,needlesLower:g.map(b=>b.toLowerCase()),className:l||"pc-md_hl",id:u,hits:0}:null;let v=0;for(;v<d.length;){const b=String(d[v]??"");if(!b.trim()){v+=1;continue}const k=b.trim();if(/^([-_*])(\s*\1){2,}$/.test(k)){f.push(i.jsx("hr",{className:"pc-md_hr"},`hr:${v}`)),v+=1;continue}const E=b.match(/^\s*!\[([^\]]*)\]\(([^)]+)\)\s*$/);if(E){const A=Dp(E[2]||"");if(A&&Ms&&!Ms(A)){f.push(i.jsx("p",{className:"pc-md_p",children:Fp(`img:${v}`,A,E[1]||"")},`p:${v}`)),v+=1;continue}if(A){const $=E[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:${v}`)),v+=1;continue}}if(jh(b)){const $=b.trim().replace(/```/g,"").trim(),j=[];for(v+=1;v<d.length&&!String(d[v]??"").trim().startsWith("```");)j.push(String(d[v]??"")),v+=1;v<d.length&&(v+=1);const P=j.join(`
|
|
62
|
-
`);f.push(i.jsx("pre",{className:"pc-md_pre",children:i.jsx("code",{className:$?`language-${$}`:void 0,children:P})},`pre:${v}`));continue}const S=b.match(kh);if(S){const A=S[1].length,$=S[2]||"",j=qr($,y);A===1?f.push(i.jsx("h1",{children:j},`h1:${v}`)):A===2?f.push(i.jsx("h2",{children:j},`h2:${v}`)):A===3?f.push(i.jsx("h3",{children:j},`h3:${v}`)):A===4?f.push(i.jsx("h4",{children:j},`h4:${v}`)):f.push(i.jsx("h5",{children:j},`h5:${v}`)),v+=1;continue}if(Sh(b)){const A=[];for(;v<d.length&&String(d[v]??"").trimStart().startsWith(">");){const j=String(d[v]??"").trimStart();A.push(j.replace(/^>\s?/,"")),v+=1}f.push(i.jsx("blockquote",{className:"pc-md_quote",children:A.map(($,j)=>i.jsxs(gt.Fragment,{children:[qr($,y),j<A.length-1?i.jsx("br",{}):null]},`q:${v}:${j}`))},`quote:${v}`));continue}if(b.includes("|")&&v+1<d.length&&bh(String(d[v+1]??""))){const A=xh(b),$=Math.max(1,A.length),j=[];for(v+=2;v<d.length;){const P=String(d[v]??"");if(!P.trim()||!P.includes("|"))break;const V=xh(P),H=[];for(let L=0;L<$;L++)H.push(V[L]??"");j.push(H),v+=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:${v}:${V}`))})}),i.jsx("tbody",{children:j.map((P,V)=>i.jsx("tr",{children:P.map((H,L)=>i.jsx("td",{children:qr(H,y)},`td:${v}:${V}:${L}`))},`tr:${v}:${V}`))})]})},`table:${v}`));continue}if(Qa(b)){const A=[];for(;v<d.length;){const $=String(d[v]??"");if(!$.trim()||$.trimStart().startsWith("```"))break;if(Qa($)||/^\s{2,}\S/.test($)){A.push($),v+=1;continue}break}f.push(i.jsx(gt.Fragment,{children:Iv(A,y,`list:${v}`)},`list:${v}`));continue}const T=[];for(;v<d.length&&String(d[v]??"").trim()&&!(T.length>0&&Qa(String(d[v]??"")));){const A=String(d[v]??"");if(T.length>0&&(kh.test(A)||jh(A)||Sh(A))||T.length>0&&A.includes("|")&&v+1<d.length&&bh(String(d[v+1]??"")))break;T.push(A),v+=1}f.push(i.jsx("p",{className:"pc-md_p",children:T.map((A,$)=>i.jsxs(gt.Fragment,{children:[qr(A,y),$<T.length-1?i.jsx("br",{}):null]},`pl:${v}:${$}`))},`p:${v}`))}const x=["pc-md",t].filter(Boolean).join(" ");return i.jsx("div",{className:x,children:f})}function Up(e){const t=String(e.text??""),s=w.useMemo(()=>Ip(t),[t]),o=["pc-chat-content",e.className].filter(Boolean).join(" ");return s!==null?i.jsx("div",{className:o,children:i.jsx(Is,{value:s,collapseAfterDepth:e.jsonCollapseAfterDepth})}):e.renderMarkdown?i.jsx("div",{className:o,children:e.renderMarkdown(t)}):i.jsx("div",{className:o,children:i.jsx(Wp,{text:t,images:e.images,inlineImage:e.inlineImage})})}function Bp(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}}function Vp(e){const t=Bp(e);if(!t||typeof t!="object"||Array.isArray(t))return{label:"input",value:t==null?"":String(t)};const s=Object.entries(t),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 Gp({tool:e,showCopy:t=!0}){const[s,o]=w.useState(!1),l=Bp(e.arguments),u=Vp(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(ie,{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(ie,{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"}),t?i.jsxs("button",{type:"button",onClick:async()=>o(await Tu(JSON.stringify(e,null,2))),children:[i.jsx(ie,{name:"copy",size:13}),s?"Copied":"Copy details"]}):null]}),y?i.jsx("dl",{className:"pc-tool-activity__parameters",children:y.map(([v,x])=>i.jsxs(gt.Fragment,{children:[i.jsx("dt",{children:v}),i.jsx("dd",{children:x&&typeof x=="object"?i.jsx(Is,{value:x}):i.jsx("code",{children:typeof x=="string"?x:JSON.stringify(x)})})]},v))}):e.arguments===void 0?i.jsx("p",{children:"Arguments are unavailable in this ledger."}):i.jsx(Is,{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(Is,{value:e.output})})]}):null]})]})}function Hp({tools:e,showCopy:t}){const s=o=>e.filter(l=>l.status===o).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(ie,{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(o=>i.jsx(Gp,{tool:o,showCopy:t},o.id))]})}const Et="not reported",Gt=e=>e===void 0?Et:Math.round(e).toLocaleString(),nn=e=>{if(e===void 0)return Et;if(e<6e4)return`${(e/1e3).toFixed(1)}s`;const t=Math.round(e/1e3);return`${Math.floor(t/60)}m ${String(t%60).padStart(2,"0")}s`},Kp=e=>e===void 0?Et:`${Math.round(e).toLocaleString()} tok/s`,Lv=(e,t)=>t>0?`${Math.round(e/t*100)}%`:"",Ls=(e,t,s=`${t}s`)=>`${e.toLocaleString()} ${e===1?t:s}`,Pv=e=>{const t=e.split("#")[0].replace(/\/+$/,"");return t.slice(t.lastIndexOf("/")+1)||e};function Ov(e){const t=new Map;for(const s of e)s&&t.set(s,(t.get(s)||0)+1);return[...t].map(([s,o])=>o>1?`${s} ×${o}`:s).join(" · ")}function tl(e){const t=[],s=(e.models||[]).map(Pv),o=e.providers||[];return(s.length||o.length)&&t.push([s.join(", ")||"model not reported",o.join(", ")].filter(Boolean).join(" · ")),t.push("From the run ledger; summed across this turn and its child runs."),t}function Dv(e){const t=e.modelCalls||[],s=[],o=[{label:"Input",value:Gt(e.inputTokens)},{label:"Output",value:Gt(e.outputTokens)}];if(e.reasoningTokens!==void 0&&o.push({label:"Reasoning",value:Gt(e.reasoningTokens),hint:"part of output"}),o.push({label:"Total",value:Gt(e.totalTokens)}),s.push({heading:`Usage · ${Ls(e.llmCalls,"model call")}`,rows:o}),e.measuredCacheCalls){const u=e.cachedTokens||0,d=e.fedTokens||0,f=[{label:"Reused from cache",value:`${Gt(u)}${u+d?` (${Lv(u,u+d)})`:""}`},{label:"Newly processed",value:Gt(e.fedTokens)},{label:"Outcome",value:Ov(t.map(h=>h.cacheOutcome))||(e.cacheOutcomes||[]).join(" · ")||Et},{label:"Backend",value:(e.cacheBackends||[]).join(", ")||Et}];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:Et}]});const l=t.filter(u=>u.inputTokens!==void 0);return l.length===1&&t.length===1?s.push({heading:"Context",rows:[{label:"Prompt size",value:`${Gt(l[0].inputTokens)} tokens`}]}):l.length>1&&s.push({heading:"Context",rows:[{label:"First → last call",value:`${Gt(l[0].inputTokens)} → ${Gt(l[l.length-1].inputTokens)} tokens`}],note:"Each call re-sends the conversation, so the input total counts the context once per call."}),t.length>1&&s.push({heading:"Per call",table:{columns:["#","Input","Cached","New","Output","Cache"],rows:t.map((u,d)=>[String(d+1),Gt(u.inputTokens),u.cachedTokens===void 0?"—":Gt(u.cachedTokens),u.fedTokens===void 0?"—":Gt(u.fedTokens),Gt(u.outputTokens),u.cacheOutcome||"—"])}}),{kind:"tokens",title:"Tokens",headline:e.totalTokens===void 0?Et:`${e.totalTokens.toLocaleString()} total`,sections:s,footer:tl(e)}}function Ba(e,t,s,o){if(e===void 0)return Et;const l=[nn(e)];return t!==void 0&&l.push(`${t.toLocaleString()} ${o}${s!==void 0?` at ${Kp(s)}`:""}`),l.join(" · ")}function Fv(e){var g,y,v;const t=e.modelCalls||[],s=[],o=e.durationMs,l=[{label:"Wall clock",value:nn(o)}];if(l.push({label:"Model",value:e.genTimeMs===void 0?Et:`${nn(e.genTimeMs)} · ${Ls(e.timedCalls||0,"call")}${e.timedCalls!==e.llmCalls?` (of ${e.llmCalls})`:""}`}),l.push({label:"Tools",value:e.toolTimeMs!==void 0?`${nn(e.toolTimeMs)} · ${Ls(e.toolBatches||0,"batch","batches")}`:e.toolCalls?Et:"none",hint:e.toolTimeIncludesApproval?"includes approval wait":void 0}),o!==void 0&&e.genTimeMs!==void 0){const x=o-e.genTimeMs-(e.toolTimeMs||0);l.push({label:"Orchestration",value:x>=0?nn(x):"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:Ba(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:Ba(e.prefillMs,e.prefillNewTokens,e.prefillNewTokensPerSecond,"new tok"),hint:"derived: prompt ÷ provider rate"}):e.prefillMs!==void 0?u.push({label:"Prefill",value:`${nn(e.prefillMs)}${e.promptTokensPerSecond!==void 0?` at ${Kp(e.promptTokensPerSecond)}`:""}`,hint:"provider rate over all prompt tokens, restored included"}):u.push({label:"Prefill",value:Et}),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?Ba(e.generationPhaseMs,e.generationPhaseTokens,e.generationPhaseTokensPerSecond,"tok"):Ba(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 x=(h.draftKinds||[]).map(k=>k.toUpperCase()).join(", "),b=[{label:"Mode",value:`${h.used?"on":"off"}${x?` · ${x}`:""}${(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?Et:`${Math.round(h.acceptanceRate*100)}% · ${Gt(h.acceptedTokens)} of ${Gt(h.draftedTokens)} drafted`}];((y=h.draftLengths)!=null&&y.length||h.rounds!==void 0)&&b.push({label:"Draft length",value:`${(v=h.draftLengths)!=null&&v.length?`${h.draftLengths.join("/")} tok/round`:Et}${h.rounds!==void 0?` · ${h.rounds.toLocaleString()} rounds`:""}`}),s.push({heading:"Speculation",rows:b})}return e.slowestToolBatch&&s.push({heading:"Tools",rows:[{label:"Total",value:`${nn(e.toolTimeMs)} · ${Ls(e.toolBatches||0,"batch","batches")}`},{label:"Slowest",value:`${nn(e.slowestToolBatch.ms)} · ${Jp(e.slowestToolBatch)}`}],note:e.toolTimeIncludesApproval?"Gated calls are timed from request to result, so this includes waiting for your approval.":void 0}),t.length>1&&s.push({heading:"Per call",table:{columns:["#","Prefill","New tok/s","Gen","Gen tok/s","Cache"],rows:t.map((x,b)=>[String(b+1),x.promptMs===void 0?"—":`${nn(x.promptMs)}${x.promptSource==="rate"?"*":""}`,x.promptNewTokensPerSecond===void 0?"—":Math.round(x.promptNewTokensPerSecond).toLocaleString(),x.generationMs===void 0?"—":nn(x.generationMs),x.generationTokensPerSecond===void 0?"—":Math.round(x.generationTokensPerSecond).toLocaleString(),x.cacheOutcome||"—"])},note:t.some(x=>x.promptSource==="rate")?"* derived from the provider's prompt rate (no TTFT event).":void 0}),{kind:"time",title:"Time",headline:o===void 0?Et:`${nn(o)} wall clock`,sections:s,footer:tl(e)}}function Jp(e){return e.tools.length===1?`${e.tools[0]} ×${e.calls}`:`${Ls(e.calls,"call")} (${e.tools.join(", ")})`}function zv(e){const t=[],s=(e.toolsWaiting||0)+(e.toolsRunning||0);if(!e.toolCalls&&!s)return t.push({heading:"Outcome",rows:[{label:"Tools called",value:"none"}]}),{kind:"tools",title:"Tools",headline:"none",sections:t,footer:tl(e)};const o=[{label:"Succeeded",value:(e.toolCalls-(e.toolsFailed||0)).toLocaleString()},{label:"Failed",value:(e.toolsFailed||0).toLocaleString()}];e.toolsRunning&&o.push({label:"Running",value:e.toolsRunning.toLocaleString()}),e.toolsWaiting&&o.push({label:"Awaiting approval",value:e.toolsWaiting.toLocaleString(),hint:"not run yet — not a failure"}),t.push({heading:"Outcome",rows:o});const l=Object.entries(e.toolBreakdown||{}).sort((f,h)=>h[1].calls-f[1].calls||f[0].localeCompare(h[0]));l.length&&t.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?`${nn(h.ms)}${h.sharedBatches?" +shared":""}`:h.sharedBatches?"shared":Et])},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&&t.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?Et:`${nn(e.toolTimeMs)} · ${Ls(e.toolBatches||0,"batch","batches")}`}];return e.slowestToolBatch&&d.push({label:"Slowest batch",value:`${nn(e.slowestToolBatch.ms)} · ${Jp(e.slowestToolBatch)}`}),t.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:`${Ls(e.toolCalls,"call")}${e.toolsFailed?` · ${e.toolsFailed} failed`:""}`,sections:t,footer:tl(e)}}function Kc(e,t){return e==="tokens"?Dv(t):e==="time"?Fv(t):zv(t)}function Wv(e){const t=e.detail;return i.jsxs("div",{ref:e.panelRef,id:e.id,role:"tooltip",className:`pc-stat-detail pc-stat-detail--${t.kind}`,style:e.style,onMouseEnter:e.onMouseEnter,onMouseLeave:e.onMouseLeave,children:[i.jsxs("div",{className:"pc-stat-detail-head",children:[i.jsx("span",{className:"pc-stat-detail-title",children:t.title}),i.jsx("span",{className:"pc-stat-detail-headline",children:t.headline})]}),t.sections.map(s=>{var o;return i.jsxs("div",{className:"pc-stat-detail-section",children:[i.jsx("div",{className:"pc-stat-detail-heading",children:s.heading}),(o=s.rows)!=null&&o.length?i.jsx("dl",{className:"pc-stat-detail-rows",children:s.rows.map(l=>i.jsxs(gt.Fragment,{children:[i.jsx("dt",{children:l.label}),i.jsxs("dd",{children:[i.jsx("span",{className:l.value===Et?"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:t.footer.map(s=>i.jsx("div",{children:s},s))})]})}const jr=8;function Uv(e){const[t,s]=w.useState(!!e.defaultOpen),[o,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]),v=w.useCallback(()=>{g(),f.current=window.setTimeout(()=>s(!1),120)},[g]);w.useEffect(()=>g,[g]),w.useLayoutEffect(()=>{if(!t){l(null);return}const E=()=>{const S=u.current,T=d.current;if(!S||!T)return;const A=S.getBoundingClientRect(),$=T.offsetWidth,j=T.offsetHeight,P=window.innerWidth,V=window.innerHeight,H=A.top-jr-j,L=A.bottom+jr,de=H>=jr?H:L+j<=V-jr?L:Math.max(jr,V-jr-j),re=Math.min(Math.max(jr,A.left),Math.max(jr,P-jr-$));l({top:de,left:re})};return E(),window.addEventListener("resize",E),window.addEventListener("scroll",E,!0),()=>{window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0)}},[t]),w.useEffect(()=>{if(!t)return;const E=S=>{S.key==="Escape"&&s(!1)};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[t]);const x=typeof e.onClick=="function",b=x?"button":"span",k=t?i.jsx(Wv,{detail:e.detail,id:h,panelRef:d,onMouseEnter:g,onMouseLeave:v,style:{position:"fixed",top:(o==null?void 0:o.top)??0,left:(o==null?void 0:o.left)??0,visibility:o?"visible":"hidden"}}):null;return i.jsxs(i.Fragment,{children:[i.jsxs(b,{ref:u,...x?{type:"button"}:{tabIndex:0},className:["pc-chat-stat","pc-chat-stat--detail",x?"pc-chat-stat--clickable":"",e.className].filter(Boolean).join(" "),"aria-label":`${e.label} — ${e.detail.title.toLowerCase()} details`,"aria-describedby":t?h:void 0,"data-stat-kind":e.detail.kind,onMouseEnter:y,onMouseLeave:v,onFocus:y,onBlur:()=>s(!1),onKeyDown:E=>{E.key==="Escape"&&s(!1)},onClick:x?()=>{var E;return(E=e.onClick)==null?void 0:E.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})]}),k&&typeof document<"u"?rp.createPortal(k,document.body):k]})}function Bv(e){const t=e.totalTokens!==void 0?Kc("tokens",e):null,s=Kc("tools",e),o=e.durationMs!==void 0?Kc("time",e):null;return[...t?[{label:`${e.totalTokens.toLocaleString()} tokens`,detail:t}]:[],{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
|
-
`)}]:[],...o?[{label:`${(e.durationMs/1e3).toFixed(e.durationMs<1e4?1:0)}s`,detail:o}]:[]]}function Vv(e){const t=String(e.role||"").trim().toLowerCase()||"system",s=String(e.kind||"").trim().toLowerCase(),o=String(e.level||"").trim().toLowerCase();return t==="system"&&s==="report_bug"?{label:String(e.title||"").trim()||"Bug report",icon:"warning",variant:"report_bug"}:t==="system"&&s==="report_feature"?{label:String(e.title||"").trim()||"Feature request",icon:"check",variant:"report_feature"}:t==="user"?{label:String(e.title||"").trim()||"You",icon:"user",variant:"user"}:t==="assistant"?{label:String(e.title||"").trim()||"Agent",icon:"bot",variant:"assistant"}:{label:String(e.title||"").trim()||(o==="error"?"Error":o==="warn"?"Warning":"System"),icon:o==="error"?"error":o==="warn"?"warning":"info",variant:o==="error"?"error":o==="warn"?"warn":"status"}}function Qp(e){var T;const t=e.message,s=w.useMemo(()=>Vv(t),[t.kind,t.level,t.role,t.title]),o=String(t.ts||"").trim(),l=w.useMemo(()=>{if(!o)return"";const A=new Date(o);return Number.isFinite(A.getTime())?A.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):""},[o]),[u,d]=w.useState("idle"),f=w.useRef(null);w.useEffect(()=>()=>{f.current!==null&&window.clearTimeout(f.current)},[]);const h=t.live,g=!h&&typeof e.onSpeakToggle=="function"&&s.variant==="assistant"&&!!String(t.content||"").trim(),y=g&&((T=e.getSpeakState)==null?void 0:T.call(e,t))||"idle",v=y==="loading"?"loader":y==="playing"?"pause":"speaker",x=y==="loading"?"Generating audio…":y==="playing"?"Pause":y==="paused"?"Resume":"Speak (TTS)",b=e.showCopy!==!1,k=Array.isArray(e.attachments)?e.attachments:[],E=t.statistics,S=w.useMemo(()=>Array.isArray(e.stats)?e.stats:E?Bv(E):[],[e.stats,E]);return t.toolActivity?i.jsx(Gp,{tool:t.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(ie,{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":x,title:x,onClick:()=>{var A;return(A=e.onSpeakToggle)==null?void 0:A.call(e,t)},children:i.jsx(ie,{name:v,size:22})}):null,b?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 Tu(String(t.content||""));d(A?"copied":"failed"),f.current!==null&&window.clearTimeout(f.current),f.current=window.setTimeout(()=>d("idle"),900)},children:i.jsx(ie,{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(t.content||"").trim()?i.jsx("div",{className:"pc-chat-body",children:i.jsx(Up,{text:String(t.content||""),renderMarkdown:e.renderMarkdown,jsonCollapseAfterDepth:e.jsonCollapseAfterDepth,images:e.images||(s.variant==="user"?"inline":"link"),inlineImage:e.inlineImage})}):null,k.length?i.jsx("div",{className:"pc-chat-attachments","aria-label":"Attachments",children:k.slice(0,24).map((A,$)=>{const j=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||j,onClick:H?void 0:A.onClick,disabled:H,children:[i.jsx(ie,{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:j})]},A.id||`${j}:${$}`)})}):null,S.length?i.jsx("div",{className:"pc-chat-stats","aria-label":"Stats",children:S.slice(0,12).map((A,$)=>{const j=String(A.label||"").trim();if(!j)return null;if(A.detail)return i.jsx(Uv,{label:j,detail:A.detail,icon:A.icon,onClick:A.onClick},A.id||`${j}:${$}`);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:j})]},A.id||`${j}:${$}`)})}):null]})}function Gv(e,t){const s=Math.max(0,Math.trunc(t));return e.scrollHeight-e.scrollTop-e.clientHeight<=s}function Hv(e){const t=typeof e.autoScrollThresholdPx=="number"&&Number.isFinite(e.autoScrollThresholdPx)?e.autoScrollThresholdPx:120,s=e.autoScroll!==!1,o=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 v;const y=[];for(const x of f){const b=y[y.length-1];x.toolActivity&&((v=b==null?void 0:b[0])!=null&&v.toolActivity)&&b[0].runId===x.runId?b.push(x):y.push([x])}return y},[f]);w.useEffect(()=>{if(!s)return;const y=o.current;if(!y)return;const v=()=>{d(Gv(y,t))};return y.addEventListener("scroll",v,{passive:!0}),v(),()=>y.removeEventListener("scroll",v)},[s,t]);const g=w.useMemo(()=>{let y=0;for(const v of f)y+=String(v.content??"").length;return`${f.length}:${y}:${String(e.afterKey??"")}`},[f,e.afterKey]);return w.useEffect(()=>{if(!s||!u)return;const y=o.current;y&&(y.scrollTop=y.scrollHeight)},[s,u,g]),i.jsxs("div",{ref:o,className:["pc-chat-thread",e.className].filter(Boolean).join(" "),children:[f.length?null:e.empty||null,h.map((y,v)=>{var k;const x=y[0],b=String(x.id||"")||String(x.ts||"")+":"+String(x.role||"")+":"+v;return x.toolActivity?i.jsx(Hp,{tools:y.map(E=>E.toolActivity),showCopy:(k=e.messageProps)==null?void 0:k.showCopy},b):i.jsx(Qp,{message:x,...e.messageProps||{}},b)}),e.after,i.jsx("div",{ref:l})]})}const Kv=gt.forwardRef(function(t,s){const o=typeof t.rows=="number"&&Number.isFinite(t.rows)?Math.max(1,Math.trunc(t.rows)):3,l=!!t.disabled,u=!!t.busy,d=!l&&!u&&!!String(t.value||"").trim();return i.jsxs("div",{className:["pc-composer",t.className].filter(Boolean).join(" "),children:[t.leading,i.jsx("textarea",{ref:s,className:["pc-composer__textarea",t.textareaClassName].filter(Boolean).join(" "),value:t.value,onChange:f=>t.onChange(f.target.value),rows:o,style:{"--pc-composer-rows":String(o)},spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",autoComplete:"off",placeholder:t.placeholder||"","aria-label":t.ariaLabel||t.placeholder||"Message",disabled:l,autoFocus:!!t.autoFocus,onPaste:t.onPaste,onKeyDown:f=>{f.key!=="Enter"||f.shiftKey||f.nativeEvent.isComposing||f.keyCode===229||(f.preventDefault(),d&&t.onSubmit())}}),i.jsxs("div",{className:"pc-composer__row",children:[i.jsx("div",{className:"pc-composer__actions",children:t.actions}),i.jsx("button",{type:"button",className:t.sendButtonClassName||"pc-btn",disabled:!d,onClick:()=>t.onSubmit(),children:u?t.busyLabel||"Thinking…":t.sendLabel||"Send"})]}),t.overlay]})}),et=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{},Ya=e=>Array.isArray(e)?e.map(et):[],Ge=e=>typeof e=="string"?e:"",So=e=>Ge(e.runtime_call_id||e.call_uid),No=e=>Ge(e.call_id||e.id);function Yp(e,t){const s=t.record,o=et(s.effect);if(o.type!=="tool_calls")return[];const l=et(s.result),u=Ya(et(o.payload).tool_calls),d=u.length||s.status!=="waiting"?u:Ya(et(et(l.wait).details).tool_calls),f=Ya(l.results),h=d.length?d:f,g=[];return h.forEach((y,v)=>{let x=So(y)?f.filter(V=>So(V)===So(y)):[];!x.length&&No(y)&&d.filter(V=>No(V)===No(y)).length===1&&(x=f.filter(V=>No(V)===No(y)));const b=d.length?x.length===1?x[0]:d.length===f.length?f[v]:{}:y,k=So(y)||So(b)||`${Ge(s.idempotency_key)||Ge(s.step_id)||t.cursor}:${v}`,E=`${t.runId}:${k}`,S=e.get(E),T=Ge(y.name||b.name)||(S==null?void 0:S.name);if(!T)return;const A=s.status==="completed"||s.status==="failed",$=s.status==="failed"||b.success===!1||!!b.error,j=y.arguments??b.arguments??(S==null?void 0:S.arguments),P={...S,id:E,runId:t.runId,name:T,arguments:j,status:A?$?"failed":"completed":s.status==="waiting"?"waiting":"running",...typeof b.success=="boolean"?{success:b.success}:{},...b.output!==void 0||b.result!==void 0?{output:b.output??b.result}:{},...b.error?{error:String(b.error)}:{},startedAt:(S==null?void 0:S.startedAt)||Ge(s.started_at)||void 0,endedAt:A&&Ge(s.ended_at)||(S==null?void 0:S.endedAt)};S&&["completed","failed"].includes(S.status)&&!A||(e.set(E,P),g.push(P))}),g}function Ci(e){if(e==null||e===""||typeof e=="boolean")return;const t=Number(e);return Number.isFinite(t)&&t>=0?t:void 0}function rr(e,t){for(const s of t){const o=e==null?void 0:e[s];if(o==null||o===""||typeof o=="boolean")continue;const l=Number(o);if(Number.isFinite(l)&&l>=0)return Math.trunc(l)}}function Xp(e){if(typeof e=="string")try{return et(JSON.parse(e))}catch{return{}}return et(e)}function xi(e,t){if(t===void 0||t==="")return e;const s=e||[];return s.includes(t)||s.push(t),s}function Jv(e){return rr(e,["reasoning_tokens","thinking_tokens"])??rr(et(e.completion_tokens_details),["reasoning_tokens"])??rr(et(e.output_tokens_details),["reasoning_tokens"])}function Qv(e){const t=et(typeof e=="string"&&e.trim().startsWith("{")?Xp(e):e);return Ge(t.error_class)}function Yv(e){const t=new Map;for(const s of e){const o=s.record;if(et(o.effect).type!=="emit_event")continue;const l=et(o.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=t.get(d)||{},h=Ci(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,t.set(d,f)}return t}function Xa(e){var E,S,T,A;const t=new Map,s=new Set,o=new Set,l={llmCalls:0,toolCalls:0,changedFiles:[]};let u=1/0,d=-1/0,f=!1,h=0,g=0,y=0;const v=Yv(e),x=[],b=new Set;for(const $ of e){const j=$.record,P=`${$.runId}:${j.step_id||$.cursor}:${j.status}`;if(s.has(P))continue;s.add(P);for(const Z of[j.started_at,j.ended_at]){const Ce=Date.parse(Ge(Z));Number.isFinite(Ce)&&(u=Math.min(u,Ce),d=Math.max(d,Ce))}for(const Z of Yp(t,$))Z.status==="waiting"&&b.add(Z.id);if(et(j.effect).type!=="llm_call"||j.status!=="completed")continue;l.llmCalls+=1;const V=et(j.result),H=et(V.output),L=et(V.usage||V.token_usage||V.tokens||H.usage||H.token_usage||H.tokens),de=rr(L,["input_tokens","prompt_tokens","prompt","input","in"]),re=rr(L,["output_tokens","completion_tokens","completion","output","out"]),Q=rr(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=Ci(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=Ci(fe.prompt_tokens_per_second),ye=Ci(fe.generation_tokens_per_second),ve=et(J.prompt_cache),q=Ci(ve.cached_tokens),ae=Ci(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 Z=de/ce*1e3;l.prefillMs=(l.prefillMs||0)+Z,ae!==void 0&&(h+=ae,g+=Z)}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||ae!==void 0){l.measuredCacheCalls=(l.measuredCacheCalls||0)+1,l.cachedTokens=(l.cachedTokens||0)+(q||0),l.fedTokens=(l.fedTokens||0)+(ae||0);const Z=Ge(ve.outcome);if(Z){const Ce=l.cacheOutcomes||[];Ce.includes(Z)||Ce.push(Z),l.cacheOutcomes=Ce}}const G=Ge(j.step_id)||void 0,C=G&&v.get(`${$.runId}:${G}`)||{},B=et(V.route),F={runId:$.runId};G&&(F.stepId=G),Ge(j.started_at)&&(F.startedAt=Ge(j.started_at));const W=Ge(V.model||H.model)||Ge(B.model)||C.model,oe=Ge(B.provider)||Ge(et(J._provider_request).provider)||C.provider||Ge(V.provider);W&&(F.model=W),oe&&(F.provider=oe),W&&(l.models=xi(l.models,W)),oe&&(l.providers=xi(l.providers,oe)),(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=Jv(L);le!==void 0&&(F.reasoningTokens=le,l.reasoningTokens=(l.reasoningTokens||0)+le),q!==void 0&&(F.cachedTokens=q),ae!==void 0&&(F.fedTokens=ae),Ge(ve.outcome)&&(F.cacheOutcome=Ge(ve.outcome)),Ge(ve.backend)&&(F.cacheBackend=Ge(ve.backend),l.cacheBackends=xi(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),C.ttftS!==void 0?(F.ttftMs=C.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,ae!==void 0&&F.promptMs>0&&(F.promptNewTokensPerSecond=ae/(F.promptMs/1e3),l.promptPhaseNewTokens=(l.promptPhaseNewTokens||0)+ae,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 Z={};Ge(he.mode)&&(Z.mode=Ge(he.mode)),typeof he.used=="boolean"&&(Z.used=he.used),Ge(he.draft_kind)&&(Z.draftKind=Ge(he.draft_kind));const Ce=rr(he,["accepted_tokens"]),Ue=rr(he,["drafted_tokens"]),ke=rr(he,["rounds"]),X=rr(he,["num_draft_tokens"]);Ce!==void 0&&(Z.acceptedTokens=Ce),Ue!==void 0&&(Z.draftedTokens=Ue),Ce!==void 0&&Ue&&(Z.acceptanceRate=Ce/Ue),ke!==void 0&&(Z.rounds=ke),X!==void 0&&(Z.draftLength=X),F.speculation=Z;const ee=l.speculation||(l.speculation={calls:0,used:0});ee.calls+=1,Z.used&&(ee.used+=1),Z.mode&&(ee.modes=xi(ee.modes,Z.mode)),Z.draftKind&&(ee.draftKinds=xi(ee.draftKinds,Z.draftKind)),Ce!==void 0&&Ue!==void 0&&(ee.acceptedTokens=(ee.acceptedTokens||0)+Ce,ee.draftedTokens=(ee.draftedTokens||0)+Ue),ke!==void 0&&(ee.rounds=(ee.rounds||0)+ke),X!==void 0&&(ee.draftLengths=xi(ee.draftLengths,X))}x.push(F)}x.length&&(x.every($=>$.startedAt)&&x.sort(($,j)=>Date.parse($.startedAt)-Date.parse(j.startedAt)),l.modelCalls=x),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)),(E=l.speculation)!=null&&E.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 k=new Map;for(const $ of t.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 j=$.status==="failed";j&&(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,j){V.failed+=1;const Q=Qv($.output);Q&&((V.errors||(V.errors={}))[Q]=(((S=V.errors)==null?void 0:S[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=k.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),b.has($.id)&&(U.waited=!0),k.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=Xp($.arguments),re=Ge(de.destination||de.destination_path||de.file_path||de.path||de.filename);re&&o.add(re)}for(const $ of k.values()){l.toolBatches=(l.toolBatches||0)+1,l.toolTimeMs=(l.toolTimeMs||0)+$.ms,$.waited&&(l.toolTimeIncludesApproval=!0);const j=[...$.names.keys()].sort();(!l.slowestToolBatch||$.ms>l.slowestToolBatch.ms)&&(l.slowestToolBatch={ms:$.ms,calls:$.calls,tools:j});const P=(T=l.toolBreakdown)==null?void 0:T[j[0]];if(j.length===1&&P)P.ms=(P.ms||0)+$.ms;else for(const V of j){const H=(A=l.toolBreakdown)==null?void 0:A[V];H&&(H.sharedBatches=(H.sharedBatches||0)+1)}}return l.changedFiles=[...o],f&&(delete l.inputTokens,delete l.outputTokens),Number.isFinite(u)&&Number.isFinite(d)&&(l.durationMs=Math.max(0,d-u)),{tools:[...t.values()],statistics:l}}function Xv(e){const t=et(et(e).ledgers);return Object.entries(t).flatMap(([s,o])=>Ya(et(o).items).map((l,u)=>({runId:s,cursor:Number(l.cursor)||u+1,record:Object.keys(et(l.record)).length?et(l.record):l})))}const Jc=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{};function Zv(e){var E,S,T,A;const{tools:t,statistics:s}=Xa(e.records),o={toolCalls:s.toolCalls,totalTokens:s.totalTokens,startedAt:String(((E=e.run)==null?void 0:E.created_at)||"")||void 0},l=($,j,P)=>({...o,label:$,detail:j,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")&&(!((S=e.records)!=null&&S.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=Jc((A=e.interaction)==null?void 0:A.wait),d=Jc(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=t.filter($=>{var j;return $.status==="running"||h&&$.status==="waiting"&&$.runId===((j=e.interaction)==null?void 0:j.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 j=`${$.runId}:${$.record.step_id||$.record.idempotency_key||$.cursor}`,P=y.get(j);P&&["completed","failed"].includes(String(P.record.status))||y.set(j,$)}if([...y.values()].reverse().find($=>Jc($.record.effect).type==="llm_call"&&["started","running"].includes(String($.record.status))))return l("Thinking","Generating the next response","working");const x=e.displayStatus.trim(),b=!/^(completed|complete|done|finished|ready|success|succeeded|failed|running|working|waiting|thinking|idle|paused|stopped|cancelled)$/i.test(x)&&!x.startsWith("{")?x:"",k=t[t.length-1];return l(e.status==="idle"?"Ready":"Working",b||(k?`Last tool: ${k.name} · ${k.status==="failed"?"failed":k.status==="completed"?"done":"waiting"}`:"Following the workflow"),e.status==="idle"?"neutral":"working")}function Va(e){if(!e)return!1;for(let t=0;t<e.length;t+=1)if(e[t]==="Files")return!0;return!1}function Nh(e){var o;const t=e==null?void 0:e.items;if(!t||!t.length)return null;let s=0;for(let l=0;l<t.length;l+=1)((o=t[l])==null?void 0:o.kind)==="file"&&(s+=1);return s>0?s:null}function Ch(e){return e===1?"Drop file to attach":typeof e=="number"&&e>1?`Drop ${e} files to attach`:"Drop files to attach"}function Zp(e){const t=[],s=[],o=e==null?void 0:e.items;if(o&&o.length){for(let u=0;u<o.length;u+=1){const d=o[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&&t.push(h)}return{files:t,folders:s}}const l=e==null?void 0:e.files;if(l)for(let u=0;u<l.length;u+=1)l[u]&&t.push(l[u]);return{files:t,folders:s}}function qv(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 e_={"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/heic":"heic","image/tiff":"tiff","image/bmp":"bmp"};function Co(e){return String(e).padStart(2,"0")}function t_(e,t,s){const o=String(e||"").trim();if(o&&!/^image\.(png|jpe?g|gif|webp|heic|tiff?|bmp)$/i.test(o))return o;const l=e_[String(t||"").toLowerCase()]||o.split(".").pop()||"bin",u=`${s.getFullYear()}-${Co(s.getMonth()+1)}-${Co(s.getDate())} at ${Co(s.getHours())}.${Co(s.getMinutes())}.${Co(s.getSeconds())}`;return`${String(t||"").startsWith("image/")||!o?"Pasted image":"Pasted file"} ${u}.${l}`}function n_(e,t=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:o}=Zp(e);return o.map(l=>{const u=t_(l.name,l.type,t);return u===l.name?l:new File([l],u,{type:l.type,lastModified:l.lastModified})})}class r_{constructor(t=1200){this.staleMs=t,this.depth=0,this.lastSeen=0}enter(t){this.depth+=1,this.lastSeen=t}over(t){this.depth===0&&(this.depth=1),this.lastSeen=t}leave(t){return this.depth=Math.max(0,this.depth-1),this.lastSeen=t,this.depth>0}reset(){this.depth=0}active(t){return this.depth>0&&t-this.lastSeen<this.staleMs}}function s_(e,t){if(e.kind==="ask-user"){if(t.kind==="choice"||t.kind==="free-text")return e.onSubmit(t.answer);throw new Error("Invalid submission for ask-user interaction")}if(e.kind==="tool-approval"){if(t.kind==="approve")return e.onApprove();if(t.kind==="deny")return e.onDeny();if(t.kind==="approve-all"&&e.onApproveAll)return e.onApproveAll();throw new Error("Invalid submission for tool-approval interaction")}if(t.kind==="event")return e.onSend(t.payload);throw new Error("Invalid submission for event-wait interaction")}function i_(e){return(e instanceof Error?e.message:String(e||"Unknown error")).trim()||"Unknown error"}function o_(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 a_(e){var H;const t=e.interaction,[s,o]=w.useState(""),[l,u]=w.useState(()=>t.kind==="event-wait"&&t.initialPayload||""),[d,f]=w.useState(null),[h,g]=w.useState(!1),[y,v]=w.useState(""),[x,b]=w.useState(null),k=`${t.kind}:${t.id}`,E=w.useRef(k),S=w.useRef(!1),T=w.useRef(!1),A=w.useRef(!0),$=w.useRef(0);E.current!==k&&(E.current=k,S.current=!1,T.current=!1,$.current+=1);const j=!!e.disabled||d!==null||h||S.current||T.current,P=async(L,de)=>{var U;if(e.disabled||S.current||T.current)return;const re=k,Q=++$.current;S.current=!0,b(null),v(""),f(L);try{if(await de(),!A.current||E.current!==re||$.current!==Q)return;T.current=!0,g(!0),v("Response sent. Waiting for the workflow to continue.")}catch(J){if(!A.current||E.current!==re||$.current!==Q)return;b({submission:L,message:i_(J)}),v("The action failed. You can try again."),(U=e.onError)==null||U.call(e,J)}finally{if(!A.current||E.current!==re||$.current!==Q)return;S.current=!1,f(null)}};w.useEffect(()=>{o(""),u(t.kind==="event-wait"&&t.initialPayload||""),b(null),f(null),g(!1),v("")},[k]),w.useEffect(()=>(A.current=!0,()=>{A.current=!1,$.current+=1,S.current=!1}),[]);const V=()=>{x&&P(x.submission,()=>s_(t,x.submission))};return i.jsxs("section",{className:"pc-workflow-interaction","aria-labelledby":`pc-workflow-interaction-${k}`,children:[i.jsxs("div",{className:"pc-workflow-interaction__heading",children:[i.jsx(ie,{name:t.kind==="tool-approval"?"warning":t.kind==="event-wait"?"history":"info",size:16}),i.jsxs("div",{children:[i.jsx("h3",{tabIndex:-1,id:`pc-workflow-interaction-${k}`,children:t.title||(t.kind==="tool-approval"?"Tool approval required":"Input required")}),t.description?i.jsx("div",{className:"pc-workflow-interaction__description",children:t.description}):null]})]}),t.kind==="ask-user"?i.jsxs("div",{className:"pc-workflow-interaction__body",children:[i.jsx("div",{className:"pc-workflow-interaction__prompt",children:t.prompt}),(H=t.choices)!=null&&H.length?i.jsx("div",{className:"pc-workflow-interaction__choices","aria-label":"Choices",children:t.choices.map(L=>i.jsxs("button",{type:"button",className:"pc-workflow-interaction__choice",disabled:j||L.disabled,onClick:()=>void P({kind:"choice",answer:L.id},()=>t.onSubmit(L.id)),children:[i.jsx("span",{children:L.label}),L.description?i.jsx("small",{children:L.description}):null]},L.id))}):null,t.allowFreeText!==!1?i.jsxs("div",{className:"pc-workflow-interaction__entry",children:[i.jsx("textarea",{"aria-label":"Response",value:s,onChange:L=>o(L.target.value),placeholder:t.freeTextPlaceholder||"Type a response",rows:2,disabled:j,onKeyDown:L=>{L.key!=="Enter"||L.shiftKey||L.nativeEvent.isComposing||L.keyCode===229||(L.preventDefault(),s.trim()&&P({kind:"free-text",answer:s},()=>t.onSubmit(s)))}},`${k}:text`),i.jsx("button",{type:"button",className:"pc-btn",disabled:j||!s.trim(),onClick:()=>void P({kind:"free-text",answer:s},()=>t.onSubmit(s)),children:(d==null?void 0:d.kind)==="free-text"?"Sending…":t.submitLabel||"Submit"})]}):null]}):t.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:t.toolName})," to run?"]}),t.detail?i.jsx("div",{className:"pc-workflow-interaction__detail",children:t.detail}):null,i.jsxs("div",{className:"pc-workflow-interaction__buttons",children:[i.jsx("button",{type:"button",className:"pc-workflow-interaction__deny",disabled:j,onClick:()=>void P({kind:"deny"},t.onDeny),children:(d==null?void 0:d.kind)==="deny"?"Denying…":t.denyLabel||"Deny"}),i.jsx("button",{type:"button",className:"pc-btn",disabled:j,onClick:()=>void P({kind:"approve"},t.onApprove),children:(d==null?void 0:d.kind)==="approve"?"Approving…":t.approveLabel||"Approve"}),t.onApproveAll?i.jsx("button",{type:"button",className:"pc-workflow-interaction__allow-all",disabled:j,onClick:()=>void P({kind:"approve-all"},t.onApproveAll),children:(d==null?void 0:d.kind)==="approve-all"?"Approving…":t.approveAllLabel||"Allow all"}):null]}),t.onApproveAll&&t.approveAllDescription?i.jsx("p",{className:"pc-workflow-interaction__scope",children:t.approveAllDescription}):null]}):i.jsxs("div",{className:"pc-workflow-interaction__body",children:[i.jsx("div",{className:"pc-workflow-interaction__prompt",children:t.prompt}),i.jsxs("label",{className:"pc-workflow-interaction__entry",children:[i.jsx("span",{children:t.payloadLabel||(t.eventName?`Payload for ${t.eventName}`:"Event payload")}),i.jsx("textarea",{value:l,onChange:L=>u(L.target.value),placeholder:t.payloadPlaceholder||"Enter payload",rows:2,"aria-label":t.payloadLabel||(t.eventName?`Payload for ${t.eventName}`:"Event payload"),disabled:j},`${k}:payload`)]}),i.jsx("div",{className:"pc-workflow-interaction__buttons",children:i.jsx("button",{type:"button",className:"pc-btn",disabled:j,onClick:()=>void P({kind:"event",payload:l},()=>t.onSend(l)),children:(d==null?void 0:d.kind)==="event"?"Sending…":t.sendLabel||"Send event"})})]}),x?i.jsx(o_,{message:x.message,onRetry:V,disabled:j}):null,i.jsx("div",{className:"pc-workflow-interaction__outcome","aria-live":"polite",children:y})]})}function Ga(e){return(e instanceof Error?e.message:String(e||"Unknown error")).trim()||"Unknown error"}function l_(e){const[t,s]=w.useState(!1),[o,l]=w.useState(!1),[u,d]=w.useState(!1),[f,h]=w.useState(null),g=w.useRef(!0),y=w.useRef(!1),v=w.useRef(!1),x=w.useRef(!1),b=w.useRef(0),k=w.useRef(0),E=w.useRef(0);w.useEffect(()=>(g.current=!0,()=>{g.current=!1,b.current+=1,k.current+=1,E.current+=1,y.current=!1,v.current=!1,x.current=!1}),[]);const S=!!e.blockedNotice,T=!!e.disabled||S,A=!!e.busy||t,$=t||!!e.busy&&!e.sendWhileBusy,j=e.stopState||null,P=(j==null?void 0:j.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 oe=U.current;if(oe){if(J.current){h({action:"attach",message:"attachments are unavailable right now."});return}if(W.length)h({action:"attach",message:qv(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 oe(F)}catch(le){g.current&&h({action:"attach",message:Ga(le)})}}}},ce=w.useRef(fe);ce.current=fe,w.useEffect(()=>{if(!V||typeof window>"u")return;const F=new r_;let W=0;const oe=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))},Z=ee=>{var we;if(!Va((we=ee.dataTransfer)==null?void 0:we.types))return;F.enter(Date.now());const pe=oe(ee.target),De=Nh(ee.dataTransfer);de(Pe=>Pe&&Pe.over===pe&&Pe.count===(De??Pe.count)?Pe:{count:De??(Pe==null?void 0:Pe.count)??null,over:pe}),he()},Ce=ee=>{var De;if(!Va((De=ee.dataTransfer)==null?void 0:De.types))return;ee.preventDefault(),F.over(Date.now());const pe=oe(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)??Nh(ee.dataTransfer),over:pe}),he()},Ue=ee=>{var pe;Va((pe=ee.dataTransfer)==null?void 0:pe.types)&&(F.leave(Date.now())||le())},ke=ee=>{var Ve;if(!Va((Ve=ee.dataTransfer)==null?void 0:Ve.types))return;const pe=oe(ee.target),De=ee.defaultPrevented&&!pe;if(ee.preventDefault(),le(),De)return;if(!pe){h({action:"attach",message:"drop files on the conversation to attach them."});return}const{files:we,folders:Pe}=Zp(ee.dataTransfer);ce.current(we,Pe)},X=ee=>{ee.key==="Escape"&&F.depth>0&&le()};return window.addEventListener("dragenter",Z),window.addEventListener("dragover",Ce),window.addEventListener("dragleave",Ue),window.addEventListener("drop",ke),window.addEventListener("dragend",le),window.addEventListener("blur",le),window.addEventListener("keydown",X),()=>{window.removeEventListener("dragenter",Z),window.removeEventListener("dragover",Ce),window.removeEventListener("dragleave",Ue),window.removeEventListener("drop",ke),window.removeEventListener("dragend",le),window.removeEventListener("blur",le),window.removeEventListener("keydown",X),W&&window.clearInterval(W)}},[V]);const ye=F=>{if(!V||T)return;const W=n_(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(ie,{name:"paperclip",size:18})}),i.jsxs("span",{className:"pc-workflow-chat__dropzone-text",children:[i.jsx("strong",{children:T?"Attachments are unavailable right now":Ch(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":Ch(L.count):re,ae=async()=>{const F=String(e.draft||"");if(T||y.current||!e.sendWhileBusy&&e.busy||!F.trim())return;const W=++b.current;y.current=!0,h(null),s(!0);try{await e.onSend(F)}catch(oe){g.current&&b.current===W&&h({action:"send",message:Ga(oe)})}finally{g.current&&b.current===W&&(y.current=!1,s(!1))}},G=async()=>{if(T||v.current||!e.onCancel)return;const F=++k.current;v.current=!0,h(null),l(!0);try{await e.onCancel()}catch(W){g.current&&k.current===F&&h({action:"cancel",message:Ga(W)})}finally{g.current&&k.current===F&&(v.current=!1,l(!1))}},C=async()=>{if(T||x.current||!e.onAttach)return;const F=++E.current;x.current=!0,h(null),d(!0);try{await e.onAttach()}catch(W){g.current&&E.current===F&&h({action:"attach",message:Ga(W)})}finally{g.current&&E.current===F&&(x.current=!1,d(!1))}},B=()=>{f&&(f.action==="send"&&ae(),f.action==="cancel"&&G(),f.action==="attach"&&C())};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(Hv,{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(a_,{interaction:e.interaction,disabled:T}):null,S?i.jsx("div",{className:"pc-workflow-chat__blocked",role:"status",children:e.blockedNotice}):null]}),afterKey:`${e.interaction?`${e.interaction.kind}:${e.interaction.id}`:""}:${S?"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(Kv,{value:e.draft,onChange:e.onDraftChange,onSubmit:()=>void ae(),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 C(),children:[i.jsx(ie,{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||o||P,onClick:()=>void G(),children:[i.jsx(ie,{name:"x",size:14}),i.jsx("span",{children:o||P?"Stopping…":"Stop"})]}):j?i.jsx("span",{className:`pc-workflow-chat__stop-state pc-workflow-chat__stop-state--${j.phase}`,role:"status","aria-live":"polite",children:j.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 $o="llm.delta",Ei="llm.delta_end";function c_(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function As(e){return typeof e=="string"&&e.trim()!==""}function u_(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0}function d_(e){return"reason"in e}function qp(e,t){const s=c_(e),o=s==null?void 0:s.kind,l=t||(typeof o=="string"&&o?o:s&&"reason"in s?Ei:$o),u=h=>{throw new Error(`Malformed ${l} event from the gateway: ${h}`)};if(t!==void 0&&t!==$o&&t!==Ei&&u(`unknown event name ${JSON.stringify(t)}`),!s)return u("the payload is not an object");o!==void 0&&o!==$o&&o!==Ei&&u(`unknown kind ${JSON.stringify(o)}`),o!==void 0&&t!==void 0&&o!==t&&u(`kind ${JSON.stringify(o)} does not match the event name`),As(s.run_id)||u("run_id is missing"),As(s.call_id)||u("call_id is missing"),u_(s.seq)||u("seq is not a non-negative integer");const d=t||o?(t||o)===Ei:"reason"in s;s.root_run_id!==void 0&&!As(s.root_run_id)&&u("root_run_id is not a run id"),s.parent_run_id!==void 0&&s.parent_run_id!==null&&!As(s.parent_run_id)&&u("parent_run_id is neither a run id nor null");const f={run_id:s.run_id,...As(s.root_run_id)?{root_run_id:s.root_run_id}:{},...s.parent_run_id!==void 0?{parent_run_id:s.parent_run_id}:{},...As(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:Ei,...f,reason:s.reason,...As(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:$o,...f,text:s.text,channel:s.channel,snapshot:s.snapshot})}function f_(e,t){if(e!==$o&&e!==Ei)return null;let s=t;if(typeof t=="string")try{s=JSON.parse(t)}catch{throw new Error(`Malformed ${e} event from the gateway: data is not JSON`)}return qp(s,e)}function h_(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 p_={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 m_(e){return`This reply is not streamed: ${e?p_[e]||`the gateway reported "${e}"`:"the gateway gave no reason"}. It appears when it is complete.`}function g_(e){return e.toolApprovalGranted?null:e.interaction}const Eh={messages:[],records:[],run:null,interaction:null,status:"idle",displayStatus:"",loading:!1,error:null,connection:"idle",toolApprovalGranted:!1,stop:null};function Re(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Ae(e){return typeof e=="string"?e.trim():e==null?"":typeof e=="number"||typeof e=="boolean"?String(e):""}function Ao(e){return Array.isArray(e)?e:[]}function tn(e){return Ae(e==null?void 0:e.status).toLowerCase()||"unknown"}function _t(e){return["completed","failed","cancelled"].includes(e.toLowerCase())}function Xr(e){const t=Re(e),s=Number((t==null?void 0:t.status)??(t==null?void 0:t.statusCode));return s===401||s===403}function y_(e){const t=Re(e);return Number((t==null?void 0:t.status)??(t==null?void 0:t.statusCode))}function Qc(e){const t=s=>{if(Array.isArray(s))return s.map(t);const o=Re(s);if(!o)return s;const l={};for(const u of Object.keys(o).sort())l[u]=t(o[u]);return l};try{return JSON.stringify(t(e))}catch{return"[unserializable]"}}function yu(e){if(typeof e=="string")return e.trim();const t=Re(e);if(!t)return"";for(const s of["answer","response","message","text","content","output"]){const o=t[s];if(typeof o=="string"&&o.trim())return o.trim()}return""}function bi(e){const t=yu(e);if(t)return t;if(!Re(e)&&!Array.isArray(e))return"";try{return JSON.stringify(e,null,2)}catch{return""}}function $h(e){if(!e)return"";for(const o of["prompt","request","task","message","query","input"]){const l=Ae(e[o]);if(l)return l}const t=Re(e.context);for(const o of["task","message"]){const l=Ae(t==null?void 0:t[o]);if(l)return l}const s=Ao(t==null?void 0:t.messages);for(let o=s.length-1;o>=0;o-=1){const l=Re(s[o]);if(Ae(l==null?void 0:l.role).toLowerCase()!=="user")continue;const u=Ae(l==null?void 0:l.content);if(u)return u}return""}function em(e){const t=Re(e.result);return Re(t==null?void 0:t.wait)}function Yc(e){return e?Ae(e.reason)==="subworkflow"||Ae(e.wait_key).startsWith("subworkflow:"):!1}function Ah(e,t){return!!(e&&e.runId===t.runId&&Ae(e.wait.wait_key)===Ae(t.wait.wait_key))}function wu(e){return Re(e.effect)||{}}function w_(e,t){return Ae(e.run_id)||t}function Th(e){return Ae(e.ended_at)||Ae(e.started_at)||void 0}function Rh(e){const t=new Set,s=g=>{const y=Ae(g);y&&t.add(y)},o=Re(e.result);s(o==null?void 0:o.sub_run_id),s(o==null?void 0:o.subRunId),s(o==null?void 0:o.child_run_id);const l=wu(e),u=Re(l.payload);Ae(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=em(e),f=Re(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=Ae(d==null?void 0:d.wait_key);return h.startsWith("subworkflow:")&&s(h.slice(12)),[...t]}class v_{constructor(t,s={}){this.transport=t,this.options=s,this.snapshot={...Eh},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 o=s.liveRenderIntervalMs??60;if(typeof o!="number"||!Number.isFinite(o)||o<0)throw new Error(`liveRenderIntervalMs must be a non-negative number of milliseconds, got ${JSON.stringify(s.liveRenderIntervalMs)}`);this.liveRenderIntervalMs=o}subscribe(t){return this.subscribers.add(t),()=>this.subscribers.delete(t)}getSnapshot(){return this.snapshot}reset(){var t;this.toolApprovalSuspended=!1,this.toolApprovalStopped=!1,this.approvalEpoch+=1,this.displayStatusAt=-1/0,this.stopRequested=!1,this.stopFollowing=!1,this.openLlmSteps.clear(),this.forcedStop=null,this.generation+=1,(t=this.controller)==null||t.abort(),this.controller=null,this.rootRunId="",this.cursors.clear(),this.seenRecords.clear(),this.seenMessages.clear(),this.watchedRuns.clear(),this.childCatchUpAttempts.clear(),this.runStates.clear(),this.historicalRuns.clear(),this.historicalRunFailures.clear(),this.commandIds.clear(),this.toolActivities.clear(),this.historicalEvidence.clear(),this.approvedWaits.clear(),this.grantedToolWaits.clear(),this.resolvedWaits.clear(),this.liveReplies.clear(),this.closedLiveCalls.clear(),this.shownLiveCalls.clear(),this.liveDirty.clear(),this.lastLiveRender=-1/0,this.liveRenderTimer&&(clearTimeout(this.liveRenderTimer),this.liveRenderTimer=null),this.set({...Eh})}dispose(){this.reset(),this.subscribers.clear()}async load(t){const s=Ae(t);if(this.reset(),!s)return;const o=++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(o))return;const f=Re(u),h=Re(f==null?void 0:f.waiting),g=tn(f);if(await this.ingestHistory(d,s,o),!this.live(o))return;if(this.set({...this.snapshot,run:f,status:g,loading:!1,...h&&!_t(g)?{interaction:this.interactionWith({runId:s,wait:h})}:{}}),f&&this.updateRunState(s,f),h)for(const y of Rh({result:{wait:h}}))y!==s&&this.catchUpAndWatch(y,o);await this.catchUpAndWatch(s,o),this.pollRootLifecycle(s,o)}catch(u){!l.signal.aborted&&this.live(o)&&this.fail(u)}}async sendCommand(t,s={}){var y,v;t==="cancel"&&(this.toolApprovalStopped=!0,this.revokeToolApproval(),this.stopRequested=!0,this.recomputeStop());const o=Ae(s.wait_key),l=t==="resume"?o?this.interactionRunId()||this.rootRunId:this.rootRunId:t==="emit_event"?this.interactionRunId()||this.rootRunId:this.rootRunId;if(!l)throw new Error("No workflow run is loaded");const u=t==="resume"&&o&&((y=this.snapshot.interaction)==null?void 0:y.stepId)||"",d=`${l}\0${t}\0${u}\0${Qc(s)}`;let f=this.commandIds.get(d);f||(f=this.newCommandId(),this.commandIds.set(d,f));const h=this.generation,g=(v=this.controller)==null?void 0:v.signal;try{const x=await this.transport.submitCommand({command_id:f,run_id:l,type:t,payload:s,...this.options.clientId?{client_id:this.options.clientId}:{}},g);if(!this.live(h))return x;const b=Re(x);if(b&&b.accepted===!1)throw t==="cancel"&&(this.stopRequested=!1,this.recomputeStop()),new Error(Ae(b.detail)||"Gateway did not accept the command");return this.commandIds.delete(d),l===this.rootRunId&&["pause","resume","cancel"].includes(t)&&this.refreshRunState(l,h),x}catch(x){throw this.live(h)&&this.fail(x,!1),x}}resume(t){const s=this.requireInteraction();return this.sendCommand("resume",{wait_key:Ae(s.wait.wait_key),payload:{response:t}})}approve(t,s){const o=this.requireInteraction();if(_t(this.snapshot.status))throw new Error("This run has already ended.");if(s&&(o.runId!==s.runId||Ae(o.wait.wait_key)!==s.waitKey||s.stepId!==void 0&&o.stepId!==s.stepId))throw new Error("This approval request has changed. Review the current request before deciding.");if(t&&this.toolApprovalPolicy&&!this.toolCallsMatch(o,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:Ae(o.wait.wait_key),payload:{approved:!!t}}).then(u=>{if(!this.live(l))return u;const d=this.occurrenceKey(o);return this.approvedWaits.add(d),t&&this.isToolApproval(o)&&!this.grantedToolWaits.has(d)&&(this.grantedToolWaits.add(d),this.set({...this.snapshot})),u})}async approveWithPolicyChange(t,s){const o=this.generation,l=this.approvalEpoch;if(!this.isToolApproval(this.requireInteraction()))throw new Error("This is not a tool approval request.");await this.approve(!0,t),!(!this.live(o)||l!==this.approvalEpoch||this.toolApprovalStopped||_t(this.snapshot.status))&&s()}async allowAllToolsForRun(t){const s=this.generation,o=this.approvalEpoch,l=this.requireInteraction();if(!this.isToolApproval(l))throw new Error("This is not a tool approval request.");await this.approve(!0,t),!(!this.live(s)||o!==this.approvalEpoch||_t(this.snapshot.status))&&(this.approvedWaits.add(`${t.runId}:${t.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(t){Qc(t)!==Qc(this.toolApprovalPolicy)&&(this.approvalEpoch+=1,this.toolApprovalSuspended=!1,this.toolApprovalPolicy=t?{enabledTools:[...t.enabledTools],autoApproveTools:[...t.autoApproveTools]}:null,this.set({...this.snapshot}))}occurrenceKey(t){return`${t.runId}:${Ae(t.wait.wait_key)}${t.stepId?`:${t.stepId}`:""}`}interactionWith(t){const s=this.snapshot.interaction;return s&&Yc(t.wait)&&!Yc(s.wait)?s:s&&Ah(s,t)&&t.stepId===void 0&&s.stepId!==void 0?{...t,stepId:s.stepId}:t}adoptDurableWait(t,s){const o=Re(s.waiting);if(!o||tn(s)!=="waiting"||Yc(o)||_t(this.snapshot.status)||this.resolvedWaits.has(`${t}:${Ae(o.wait_key)}`))return;const l=this.interactionWith({runId:t,wait:o}),u=this.snapshot.interaction;u&&Ah(u,l)&&u.stepId===l.stepId||this.set({...this.snapshot,interaction:l})}coveredByStandingPermission(t,s){var o;return t.loading||this.toolApprovalStopped||this.toolApprovalSuspended||!this.toolApprovalPolicy&&!t.autoApproveTools||_t(t.status)||((o=t.run)==null?void 0:o.paused)===!0||t.status==="paused"||!s||!this.isToolApproval(s)||this.toolApprovalPolicy&&(!this.toolCallsMatch(s,this.toolApprovalPolicy.enabledTools)||!this.toolCallsMatch(s,this.toolApprovalPolicy.autoApproveTools))?!1:!!Ae(s.wait.wait_key)}present(t){const s=t.interaction,o=s?this.occurrenceKey(s):"",l=!!(s&&this.isToolApproval(s)&&(this.grantedToolWaits.has(o)||!this.approvedWaits.has(o)&&this.coveredByStandingPermission({...t,loading:!1},s)));if(!l&&!this.snapshot.toolApprovalGranted&&!t.toolApprovalGranted)return t.toolApprovalGranted===!1?t:{...t,toolApprovalGranted:!1};let u=!1;const d=t.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{...t,toolApprovalGranted:l,...u?{messages:d}:{}}}toolCallsMatch(t,s){var l;const o=Ao((l=Re(t.wait.details))==null?void 0:l.tool_calls);return o.length>0&&o.every(u=>{var f;const d=Ae((f=Re(u))==null?void 0:f.name);return!!d&&s.includes(d)})}isToolApproval(t){const s=Re(t.wait.details);return(s==null?void 0:s.mode)==="approval_required"||(s==null?void 0:s.kind)==="tool_approval"}autoApproveCurrentWait(){const t=this.snapshot.interaction;if(!this.coveredByStandingPermission(this.snapshot,t))return;const s={runId:t.runId,waitKey:Ae(t.wait.wait_key),stepId:t.stepId},o=this.occurrenceKey(t);if(this.approvedWaits.has(o))return;this.approvedWaits.add(o),this.grantedToolWaits.add(o);const l=this.generation,u=this.approvalEpoch;this.approve(!0,s).catch(d=>{if(this.live(l)){if(this.grantedToolWaits.delete(o),u!==this.approvalEpoch){this.set({...this.snapshot});return}this.toolApprovalSuspended=!0,this.set({...this.snapshot,autoApproveTools:!1}),this.fail(d,!1)}})}emitEvent(t){return this.sendCommand("emit_event",t)}cancel(){return this.sendCommand("cancel",{})}requireInteraction(){if(!this.snapshot.interaction)throw new Error("This workflow is not waiting for input");if(!Ae(this.snapshot.interaction.wait.wait_key))throw new Error("The workflow wait has no wait_key");return this.snapshot.interaction}interactionRunId(){var t;return((t=this.snapshot.interaction)==null?void 0:t.runId)||""}live(t){var s;return t===this.generation&&!((s=this.controller)!=null&&s.signal.aborted)}set(t){this.snapshot=this.present(t);for(const s of this.subscribers)s();this.autoApproveCurrentWait()}async catchUpAndWatch(t,s){var o;if(!(!this.live(s)||this.watchedRuns.has(t))){this.watchedRuns.add(t);try{if(t!==this.rootRunId)try{const l=Re(await this.transport.getRun(t,(o=this.controller)==null?void 0:o.signal));if(!this.live(s))return;l&&this.updateRunState(t,l)}catch(l){if(!this.live(s))return;if(Xr(l))throw l;this.fail(l,!1)}if(await this.catchUp(t,s),!this.live(s)||_t(tn(this.runStates.get(t)||null)))return;this.childCatchUpAttempts.delete(t),this.watch(t,s)}catch(l){if(!this.live(s))return;if(this.watchedRuns.delete(t),t===this.rootRunId)throw l;if(Xr(l)){this.fail(l);return}const u=(this.childCatchUpAttempts.get(t)||0)+1;if(this.childCatchUpAttempts.set(t,u),this.fail(l,!1),u>=5)return;await this.waitForRetry(Math.min(2e3,150*2**(u-1))),this.live(s)&&this.catchUpAndWatch(t,s)}}}async catchUp(t,s){var o;for(let l=0;l<100&&this.live(s);l+=1){const u=this.cursors.get(t)||0,d=await this.transport.getLedger(t,u,(o=this.controller)==null?void 0:o.signal);if(!this.live(s))return;const f=Re(d),h=Array.isArray(d)?d:Ao(f==null?void 0:f.items);for(const y of h)this.ingestItem(t,y);const g=Number(f==null?void 0:f.next_after);if(!h.length||!Number.isFinite(g)||g<=u)break;this.cursors.set(t,g)}}async watch(t,s){try{await this.followStream(t,s)}finally{this.live(s)&&this.closeLiveRepliesVia(t)}}async followStream(t,s){var l;let o=0;for(;this.live(s)&&!_t(tn(this.runStates.get(t)||null));){const u=this.cursors.get(t)||0;this.set({...this.snapshot,connection:o?"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(t),await this.transport.streamLedger(t,u,g=>{this.live(s)&&(f(),this.ingestItem(t,g))},this.controller.signal,f,g=>{this.live(s)&&(f(),this.ingestDelta(t,g))}),!this.live(s)||(await this.catchUp(t,s),!this.live(s)))return;const h=Re(await this.transport.getRun(t,(l=this.controller)==null?void 0:l.signal));if(!this.live(s))return;h&&this.updateRunState(t,h),o+=1}catch(d){if(!this.live(s))return;if(o+=1,this.fail(d,!1),Xr(d)){this.set({...this.snapshot,connection:"disconnected"});return}}if(o>=5||!this.live(s))break;await this.waitForRetry(Math.min(2e3,150*2**(o-1)))}if(this.live(s)){if(_t(tn(this.runStates.get(t)||null))){this.set({...this.snapshot,connection:"disconnected"});return}this.set({...this.snapshot,connection:"disconnected",error:this.snapshot.error||"Ledger stream reconnect limit reached. Reconnect the workflow to continue."})}}async ingestHistory(t,s,o){const l=Re(t);if(!l)return;const u=Re(l.session),d=Ao(u==null?void 0:u.turns).map(Re).filter(g=>!!g);if(await this.hydrateHistoricalSessionRuns(d,s,o),!this.live(o))return;for(const g of d){const y=Ae(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=$h(Re(l.input_data));g&&this.addMessage({id:f,role:"user",content:g})}const h=Re(l.ledgers);if(h)for(const[g,y]of Object.entries(h)){const v=Re(y);for(const x of Ao(v==null?void 0:v.items))this.ingestItem(g,x)}}ingestSessionTurn(t,s,o){if(!t)return;const l=Ae(t.run_id)||s,u=Re(t.input_data)||Re(t.input)||{},d=Ae(t.prompt)||$h(u);d&&this.addMessage({id:`turn:${l}:user`,role:"user",content:d,ts:Ae(t.created_at)||void 0});const f=this.historicalRunFailures.get(l);if(f){const v=Ae(t.answer)||yu(t.output),x=f.missing?"is unavailable because the run no longer exists":"could not be restored",b=v?` Saved reply (not verified as the final result): ${v}`:"";this.addMessage({id:`history:${l}:unavailable`,role:"system",level:"warn",title:"History",content:`The final output for an earlier turn ${x}.${b}`});return}const g=(o&&_t(tn(o))?bi(o.output):"")||(o?Ae(t.answer)||yu(t.output):""),y=this.historicalEvidence.get(l);for(const v of(y==null?void 0:y.tools)||[])this.upsertTool(v);g&&this.addRunAssistantMessage(l,{id:`final:${l}`,role:"assistant",content:g,runId:l,statistics:y==null?void 0:y.statistics,ts:Ae(t.updated_at)||void 0})}async hydrateHistoricalSessionRuns(t,s,o){const l=[...new Set(t.map(h=>Ae(h.run_id)).filter(h=>h&&h!==s&&!this.historicalRuns.has(h)&&!this.historicalRunFailures.has(h)))];if(!l.length||!this.live(o))return;let u=0,d=!1;const f=async()=>{var h,g,y;for(;!d&&this.live(o);){const v=l[u++];if(!v)return;try{const x=Re(await this.transport.getRun(v,(h=this.controller)==null?void 0:h.signal));if(!this.live(o))return;if(x){this.historicalRuns.set(v,x);try{const b=await this.transport.getHistory(v,(g=this.controller)==null?void 0:g.signal);if(!this.live(o))return;this.historicalEvidence.set(v,Xa(Xv(b)))}catch(b){if(!this.live(o))return;if(Xr(b))throw b;this.fail(new Error(`Earlier turn activity could not be restored: ${b instanceof Error?b.message:String(b)}`),!1)}}else this.historicalRuns.set(v,null),this.historicalRunFailures.set(v,{missing:!1,detail:"gateway returned an invalid historical run snapshot"})}catch(x){if(!this.live(o))return;const b=y_(x)===404;this.historicalRuns.set(v,null),this.historicalRunFailures.set(v,{missing:b,detail:x instanceof Error?x.message:Ae((y=Re(x))==null?void 0:y.detail)||"request failed"}),Xr(x)&&(d=!0,this.fail(x))}}};if(await Promise.all(Array.from({length:Math.min(4,l.length)},()=>f())),d&&this.live(o))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(t,s){const o=Re(s),l=Re(o==null?void 0:o.record)||o;if(!l)return;const u=w_(l,t),d=Number(o==null?void 0:o.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=Xa(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 Rh(l))g!==u&&this.catchUpAndWatch(g,this.generation)}}foldRecord(t,s,o){var y,v,x;const l=wu(s),u=Ae(l.type).toLowerCase(),d=Re(s.result),f=Ae(s.status).toLowerCase(),h=Th(s);if(this.foldStopEvidence(t,s,u,f),["llm_call","tool_calls"].includes(u)&&["started","running"].includes(f)){const b=Date.parse(h||"");(!Number.isFinite(b)||b>=this.displayStatusAt)&&(Number.isFinite(b)&&(this.displayStatusAt=b),this.snapshot.displayStatus&&this.set({...this.snapshot,displayStatus:""}))}if(u==="answer_user"&&f==="completed"){const b=bi(d)||bi(Re(l.payload));b&&this.addRunAssistantMessage(t,{id:`answer:${t}:${o}`,role:"assistant",content:b,ts:h})}if(u==="emit_event"&&f==="completed"){const b=Re(l.payload)||{},k=Re(d),E=Ae(b.name)||Ae(k==null?void 0:k.name),S=b.payload!==void 0?b.payload:k==null?void 0:k.payload;if(["abstract.message","abstractcode.message"].includes(E)){const T=bi(S);if(T){const A=Ae((y=Re(S))==null?void 0:y.level).toLowerCase(),$=A==="error"?"error":["warn","warning"].includes(A)?"warn":"info";this.addMessage({id:`event:${t}:${o}`,role:"system",title:"Workflow",content:T,level:$,ts:h})}}if(["abstract.status","abstractcode.status"].includes(E)){const T=Re(S),A=T?T.status??T.text??T.value:S,$=Date.parse(h||"");!_t(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(E)){const T=bi(S);T&&this.addMessage({id:`event:${t}:${o}`,role:"system",title:"Tool activity",content:T,ts:h})}}const g=em(s);if(f==="waiting"&&g&&!_t(this.snapshot.status)&&!_t(tn(this.runStates.get(t)||null))&&(this.resolvedWaits.delete(`${t}:${Ae(g.wait_key)}`),this.set({...this.snapshot,interaction:this.interactionWith({runId:t,wait:g,...Ae(s.step_id)?{stepId:Ae(s.step_id)}:{}})})),u==="tool_calls")for(const b of Yp(this.toolActivities,{runId:t,cursor:this.cursors.get(t)||0,record:s}))this.upsertTool(b);if(u==="resume"&&(d==null?void 0:d.resumed)===!0){const b=Ae((v=Re(l.payload))==null?void 0:v.wait_key);b&&this.resolvedWaits.add(`${t}:${b}`),((x=this.snapshot.interaction)==null?void 0:x.runId)===t&&(this.set({...this.snapshot,interaction:null}),this.refreshRunState(t,this.generation))}}foldStopEvidence(t,s,o,l){let u=!1;if(o==="llm_call"){const d=Ae(s.step_id);if(d){const f=`${t}:${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(o==="emit_event"&&l==="completed"){const d=Re(wu(s).payload)||{},f=Re(s.result),h=Ae(d.name)||Ae(f==null?void 0:f.name),g=Re(d.payload!==void 0?d.payload:f==null?void 0:f.payload);h==="abstract.status"&&Ae(g==null?void 0:g.killed_by)==="kill_switch"&&(this.forcedStop=g,u=!0)}u&&this.recomputeStop()}recomputeStop(){let t=null;this.forcedStop?t={phase:"forced",label:Ae(this.forcedStop.text)||"Stop forced: inference killed",record:this.forcedStop}:this.stopRequested&&(t=this.snapshot.status==="cancelled"&&this.openLlmSteps.size===0?{phase:"stopped",label:"Stopped"}:{phase:"stopping",label:"Stopping…"});const s=this.snapshot.stop||null;((s==null?void 0:s.phase)!==(t==null?void 0:t.phase)||(s==null?void 0:s.label)!==(t==null?void 0:t.label))&&this.set({...this.snapshot,stop:t}),(t==null?void 0:t.phase)==="stopping"&&this.snapshot.status==="cancelled"&&this.followStop(this.generation)}async followStop(t){var s;if(!this.stopFollowing){this.stopFollowing=!0;try{let o=500,l=null;for(;this.live(t)&&((s=this.snapshot.stop)==null?void 0:s.phase)==="stopping";){if(await this.waitForRetry(o),!this.live(t))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,t)}catch(h){d=!0,this.live(t)&&(this.fail(h,!1),l=this.snapshot.error)}!d&&l&&this.snapshot.error===l&&(this.set({...this.snapshot,error:null}),l=null),o=Math.min(5e3,o*2)}}finally{this.generation===t&&(this.stopFollowing=!1)}}}addMessage(t){const s=Ae(t.id)||`${t.role}:${t.content}:${t.ts||""}`;this.seenMessages.has(s)||(this.seenMessages.add(s),this.set({...this.snapshot,messages:[...this.snapshot.messages,{...t,id:s}]}))}toolMessage(t){return{id:`tool:${t.id}`,role:"system",kind:"tool_activity",title:"Tool activity",runId:t.runId,toolActivity:t,content:JSON.stringify({tool:t.name,status:t.status,arguments:t.arguments,output:t.output,error:t.error},null,2),ts:t.endedAt||t.startedAt}}upsertTool(t){const s=this.toolMessage(t),o=this.snapshot.messages.findIndex(u=>u.id===s.id);if(o<0){this.addMessage(s);return}const l=[...this.snapshot.messages];l[o]=s,this.set({...this.snapshot,messages:l})}addRunAssistantMessage(t,s){this.closeLiveRepliesOfRun(t);const o=`answer:${t}:`,l=`final:${t}`;this.snapshot.messages.some(u=>u.role==="assistant"&&u.content===s.content&&(u.id===l||String(u.id||"").startsWith(o)))||this.addMessage(s)}ingestDelta(t,s){let o;try{o=qp(s)}catch(h){this.fail(h,!1);return}const l=`${o.run_id}:${o.call_id}`;if(d_(o)){if(o.reason==="unavailable"){this.noteStreamUnavailable(o);return}if(o.reason==="cancelled"&&o.detail==="reinvoked"){this.closeLiveReply(l,"restarted");return}this.closeLiveReply(l,o.reason==="completed"?void 0:o.reason);return}if(this.closedLiveCalls.has(l)||this.runEnded(o.run_id)||this.runEnded(this.rootRunId))return;const u=this.liveReplies.get(l)||{runId:o.run_id,callId:o.call_id,nodeId:o.node_id||"",via:t,text:"",reasoning:"",seq:{content:-1,reasoning:-1}},d=o.channel==="reasoning"?"reasoning":"text",f=u.seq[o.channel];if(o.snapshot){if(o.seq<f)return;u[d]=o.text}else{if(o.seq<=f)return;u[d]+=o.text}u.seq[o.channel]=o.seq,u.via=t,this.liveReplies.set(l,u),this.liveDirty.add(l),this.scheduleLiveRender()}runEnded(t){return _t(tn(this.runStates.get(t)||null))}scheduleLiveRender(){if(this.liveRenderTimer)return;const t=this.lastLiveRender+this.liveRenderIntervalMs-Date.now();if(t<=0){this.renderLiveReplies();return}this.liveRenderTimer=setTimeout(()=>{this.liveRenderTimer=null,this.renderLiveReplies()},t)}renderLiveReplies(){if(this.lastLiveRender=Date.now(),!this.liveDirty.size)return;const t=[...this.snapshot.messages];for(const s of this.liveDirty){const o=this.liveReplies.get(s);if(!o)continue;const l=this.liveMessage(o),u=t.findIndex(d=>d.id===l.id);u<0?t.push(l):t[u]=l,this.shownLiveCalls.add(s)}this.liveDirty.clear(),this.set({...this.snapshot,messages:t})}liveMessage(t){const s=t.runId!==this.rootRunId;return{id:`live:${t.runId}:${t.callId}`,role:"assistant",content:t.text,runId:t.runId,live:{callId:t.callId,reasoning:t.reasoning,...s?{caption:`sub-agent · ${t.nodeId||t.runId}`}:{}}}}closeLiveReply(t,s){this.closedLiveCalls.add(t);const o=this.liveReplies.get(t);if(!o){s==="restarted"&&this.shownLiveCalls.has(t)&&this.addMessage(this.restartNote(t));return}this.liveReplies.delete(t),this.liveDirty.delete(t);const l=`live:${o.runId}:${o.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(t);this.seenMessages.add(String(f.id)),d[u]=f}else if(s){const f=`live-end:${o.runId}:${o.callId}`;this.seenMessages.add(f),d[u]={id:f,role:"system",level:"warn",title:"Reply",runId:o.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(t){const s=t.slice(0,t.indexOf(":"));return{id:`live-end:${t}`,role:"system",level:"info",title:"Reply",runId:s,content:"Reply restarted: the model call was interrupted and is running again."}}noteStreamUnavailable(t){const s=`${t.run_id}:${t.call_id}`;this.closeLiveReply(s),this.addMessage({id:`stream-unavailable:${t.run_id}:${t.detail||"unknown"}`,role:"system",level:"info",title:"Reply",runId:t.run_id,content:m_(t.detail)})}closeLiveRepliesOfRun(t){for(const s of[...this.liveReplies.values()])s.runId===t&&this.closeLiveReply(`${s.runId}:${s.callId}`)}closeLiveRepliesVia(t,s){for(const o of[...this.liveReplies.values()])(o.via===t||o.runId===t)&&this.closeLiveReply(`${o.runId}:${o.callId}`,s)}endLiveRepliesOfRun(t,s){const o=s==="failed"||s==="cancelled"?s:void 0;if(t===this.rootRunId){for(const l of[...this.liveReplies.values()])this.closeLiveReply(`${l.runId}:${l.callId}`,o);this.closedLiveCalls.clear(),this.shownLiveCalls.clear();return}this.closeLiveRepliesVia(t,o);for(const l of[...this.closedLiveCalls])l.startsWith(`${t}:`)&&this.closedLiveCalls.delete(l);for(const l of[...this.shownLiveCalls])l.startsWith(`${t}:`)&&this.shownLiveCalls.delete(l)}dropLiveRepliesVia(t){const s=new Set;for(const[o,l]of this.liveReplies)l.via===t&&(this.liveReplies.delete(o),this.liveDirty.delete(o),s.add(`live:${l.runId}:${l.callId}`));s.size&&this.set({...this.snapshot,messages:this.snapshot.messages.filter(o=>!s.has(String(o.id)))})}fail(t,s=!0){var o,l,u;Xr(t)&&(this.approvalEpoch+=1,this.toolApprovalStopped=!0,this.toolApprovalSuspended=!0,(l=(o=this.options).onAuthError)==null||l.call(o,t)),this.set({...this.snapshot,error:t instanceof Error?t.message:Ae((u=Re(t))==null?void 0:u.detail)||String(t),...Xr(t)?{autoApproveTools:!1}:{},...s?{connection:"disconnected"}:{}})}newCommandId(){const t=globalThis.crypto;return t&&typeof t.randomUUID=="function"?t.randomUUID():`workflow-${Date.now()}-${Math.random().toString(36).slice(2)}`}updateRunState(t,s){var u;if(this.runStates.set(t,s),_t(tn(s))&&this.endLiveRepliesOfRun(t,tn(s)),t!==this.rootRunId){_t(tn(s))&&((u=this.snapshot.interaction)==null?void 0:u.runId)===t?this.set({...this.snapshot,interaction:null}):this.adoptDurableWait(t,s);return}const o=tn(s),l=_t(o);if(l){const d=bi(s.output);d&&this.upsertFinal(t,d,Th(s))}this.set({...this.snapshot,run:s,status:o,...l?{interaction:null,autoApproveTools:!1,displayStatus:""}:{}}),l||this.adoptDurableWait(t,s),(this.stopRequested||this.forcedStop)&&this.recomputeStop()}upsertFinal(t,s,o){this.closeLiveRepliesOfRun(t);const l=`final:${t}`;this.seenMessages.add(l);const u={id:l,role:"assistant",content:s,ts:o,runId:t,statistics:Xa(this.snapshot.records).statistics},d=this.snapshot.messages.findIndex(h=>h.id===l||String(h.id||"").startsWith(`answer:${t}:`)&&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(t,s){var o;try{const l=Re(await this.transport.getRun(t,(o=this.controller)==null?void 0:o.signal));l&&this.live(s)&&this.updateRunState(t,l)}catch(l){this.live(s)&&this.fail(l,!1)}}async pollRootLifecycle(t,s){var o;for(;this.live(s)&&this.rootRunId===t&&!_t(tn(this.runStates.get(t)||null));){if(await this.waitForRetry(2e3),!this.live(s)||this.rootRunId!==t||_t(tn(this.runStates.get(t)||null)))return;try{const l=Re(await this.transport.getRun(t,(o=this.controller)==null?void 0:o.signal));l&&this.live(s)&&this.rootRunId===t&&this.updateRunState(t,l)}catch(l){if(!this.live(s))return;if(Xr(l)){this.fail(l);return}this.fail(l,!1)}}}waitForRetry(t){var l;const s=(l=this.controller)==null?void 0:l.signal;if(!s||s.aborted)return Promise.resolve();const o=s;return new Promise(u=>{const d=setTimeout(h,t),f=()=>{clearTimeout(d),h()};function h(){o.removeEventListener("abort",f),u()}o.addEventListener("abort",f,{once:!0})})}}function __(e){const t=w.useMemo(()=>new v_(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=>t.subscribe(l),()=>t.getSnapshot(),()=>t.getSnapshot()),o=String(e.runId||"").trim();return w.useEffect(()=>{t.setToolApprovalPolicy(e.enabled===!1?{enabledTools:[],autoApproveTools:[]}:e.toolApprovalPolicy??null)},[t,e.toolApprovalPolicy,e.enabled]),w.useEffect(()=>{if(e.enabled===!1||!o){t.reset();return}return t.load(o),()=>t.reset()},[t,o,e.enabled]),{controller:t,snapshot:s}}function Ts(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Dt(e){return typeof e=="string"?e.trim():e==null?"":typeof e=="number"||typeof e=="boolean"?String(e):""}function Ih(e){return["session","workflow","run","global"].includes(e)?e:null}function Zr(e){return{scope:Dt(e==null?void 0:e.scope).toLowerCase(),name:Dt(e==null?void 0:e.name)||Dt(e==null?void 0:e.event_name),scopeId:Dt(e==null?void 0:e.scope_id)||Dt(e==null?void 0:e.scopeId),sessionId:Dt(e==null?void 0:e.session_id)||Dt(e==null?void 0:e.sessionId),workflowId:Dt(e==null?void 0:e.workflow_id)||Dt(e==null?void 0:e.workflowId),runId:Dt(e==null?void 0:e.run_id)||Dt(e==null?void 0:e.runId)}}function x_(e,t){const s=e.wait,o=Dt(s.wait_key),l=[Zr(s),Zr(Ts(s.details))];for(const u of t){if(u.runId!==e.runId)continue;const d=u.record,f=Ts(d.result),h=Ts(f==null?void 0:f.wait),g=Ts(d.effect),y=Ts(g==null?void 0:g.payload);Dt(h==null?void 0:h.wait_key)!==o&&Dt(y==null?void 0:y.wait_key)!==o||l.push(Zr(d),Zr(y),Zr(Ts(y==null?void 0:y.details)),Zr(h),Zr(Ts(h==null?void 0:h.details)))}return l}function Xc(e,t){return t.scopeId?t.scopeId:e==="session"?t.sessionId:e==="workflow"?t.workflowId:e==="run"?t.runId:"global"}function tm(e,t,s){return{scope:e,scopeId:t,name:s,...e==="session"?{sessionId:t}:{},...e==="workflow"?{workflowId:t}:{},...e==="run"?{runId:t}:{}}}function b_(e,t,s){if(!s)return null;const o=`evt:${t}:${s}:`;if(!e.startsWith(o))return null;const l=e.slice(o.length);return l?tm(t,s,l):null}function k_(e,t=[],s){if(!e)return{target:null,error:"No event wait is available."};const o=Dt(e.wait.wait_key),l=/^evt:(session|workflow|run|global):/.exec(o);if(!l)return{target:null,error:"The gateway did not provide a canonical event wait key."};const u=Ih(l[1]);if(!u)return{target:null,error:"The event wait uses an unsupported scope."};const d=x_(e,Array.isArray(t)?t:[]),f=new Map;for(const x of d){const b=Ih(x.scope);if(!b||!x.name)continue;if(b!==u)return{target:null,error:"Event metadata conflicts with the canonical wait scope."};const k=`evt:${b}:`,E=`:${x.name}`;if(!o.startsWith(k)||!o.endsWith(E)||o.length<=k.length+E.length)return{target:null,error:"Event metadata does not exactly match the canonical wait key."};const S=o.slice(k.length,-E.length),T=Xc(b,x);if(T&&T!==S)return{target:null,error:"Event metadata conflicts with the canonical wait target."};const A=tm(b,S,x.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 x of d){const b=Xc(u,x);b&&h.add(b)}if(Dt(s==null?void 0:s.run_id)===e.runId){const x=Zr(s||null),b=Xc(u,x);b&&h.add(b)}const y=[...h].map(x=>b_(o,u,x)).filter(x=>!!x),v=new Map(y.map(x=>[`${x.scope}\0${x.scopeId}\0${x.name}`,x]));return v.size===1?{target:[...v.values()][0]}:v.size>1?{target:null,error:"The event key is ambiguous for the available scope metadata."}:{target:null,error:"The gateway did not provide enough canonical event routing metadata."}}const Ru=e=>Se(`runs/${encodeURIComponent(e)}/workspace`);function j_(e){return Ru(e)}function S_(e,t){return`${Ru(e)}/files?${new URLSearchParams({path:t,recursive:"false"})}`}function Io(e,t){return`${Ru(e)}/content?${new URLSearchParams({path:t})}`}async function al(e,t){let s="";try{const o=await e.text();try{const l=JSON.parse(o),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:o}catch{s=o}}catch{s=""}return new Error(`${t} (HTTP ${e.status}): ${s.trim()||e.statusText||"no reason given"}`)}function N_(e,t){const s=e&&typeof e=="object"&&!Array.isArray(e)?e:null,o=d=>{throw new Error(`Unexpected /workspace/files response from the gateway: ${d}.`)};if(!s)return o("not an object");Array.isArray(s.entries)||o("no `entries` list"),typeof s.truncated!="boolean"&&o("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")&&o(`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:t,entries:l,truncated:s.truncated,...u?{hidden:u}:{}}}async function C_(e,t,s){const o=await e(j_(t),{signal:s});if(!o.ok)throw await al(o,"The workspace is not available");const l=await o.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 E_(e,t,s,o){const l=await e(S_(t,s),{signal:o});if(!l.ok)throw await al(l,"The folder could not be listed");return N_(await l.json(),s)}async function $_(e,t,s,o){const l=await e(Io(t,s),{signal:o});if(!l.ok)throw await al(l,"The file could not be read");return await l.blob()}async function A_(e,t,s,o){const l=await C_(e,t,o);return{where:l,listing:l.exists?await E_(e,t,s,o):null}}function T_(e){const t=String(e||"").split("/").filter(Boolean),s=[{label:"Workspace",path:""}];return t.forEach((o,l)=>s.push({label:o,path:t.slice(0,l+1).join("/")})),s}function nm(e){if(typeof e!="number"||!Number.isFinite(e)||e<0)return"";if(e<1024)return`${e} B`;const t=["KiB","MiB","GiB","TiB"];let s=e/1024,o=0;for(;s>=1024&&o<t.length-1;)s/=1024,o+=1;return`${s<10?s.toFixed(1):Math.round(s)} ${t[o]}`}function R_(e){return[...e].sort((t,s)=>t.type===s.type?t.name.localeCompare(s.name):t.type==="dir"?-1:1)}function I_(e){const t=e.hidden||{},s=Number(t.blocked||0)+Number(t.outside_links||0)+Number(t.other||0),o=[];return s>0&&o.push(`${s} ${s===1?"entry":"entries"} hidden by the gateway's workspace rules`),e.truncated&&o.push("the list is truncated"),o.join("; ")}const M_=new Set(["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","application/pdf","text/plain","application/json"]);function L_(e){const t=String(e||"").split(";",1)[0].trim().toLowerCase();return M_.has(t)?{mode:"open",type:t}:t.startsWith("text/")||t.endsWith("+xml")||t.endsWith("+json")||t.endsWith("/xml")||t.endsWith("/javascript")||t.endsWith("/x-yaml")||t.endsWith("/toml")?{mode:"open",type:"text/plain;charset=utf-8"}:{mode:"download"}}function rm(e,t,s){const o=s==="open"?L_(e.type):{mode:"download"},l=o.mode==="open"&&o.type!==e.type?new Blob([e],{type:o.type}):e,u=URL.createObjectURL(l);if(o.mode==="open")window.open(u,"_blank","noopener");else{const d=document.createElement("a");d.href=u,d.download=t,document.body.appendChild(d),d.click(),d.remove()}window.setTimeout(()=>URL.revokeObjectURL(u),6e4)}async function P_(e,t,s){const o=await e(gy(t),{signal:s.signal});if(!o.ok)throw await al(o,`${s.name} could not be read`);rm(await o.blob(),s.name,s.mode??"open")}function sm(e){const{fetchGateway:t,runId:s}=e,[o,l]=w.useState({runId:s,path:""}),u=o.runId===s?o.path:"",[d,f]=w.useState(null),[h,g]=w.useState(""),[y,v]=w.useState(!!s),[x,b]=w.useState(""),[k,E]=w.useState(0);w.useEffect(()=>{if(!s)return;const A=new AbortController;return v(!0),g(""),(async()=>{try{const $=await A_(t,s,u,A.signal);A.signal.aborted||f({runId:s,...$})}catch($){A.signal.aborted||g(String(($==null?void 0:$.message)||$))}finally{A.signal.aborted||v(!1)}})(),()=>A.abort()},[t,s,u,k,e.refreshKey]);const S=d&&d.runId===s?d:null,T=w.useCallback(async(A,$)=>{b(A.path),g("");try{rm(await $_(t,s,A.path),A.name,$)}catch(j){g(String((j==null?void 0:j.message)||j))}finally{b("")}},[t,s]);return i.jsx(O_,{title:e.title,note:e.note,where:(S==null?void 0:S.where)??null,path:u,listing:(S==null?void 0:S.listing)??null,error:h,loading:y,fileBusy:x,selectedPath:e.selectedPath,className:e.className,onNavigate:A=>l({runId:s,path:A}),onRefresh:()=>E(A=>A+1),onFile:e.onSelectFile?void 0:(A,$)=>void T(A,$),onSelectFile:e.onSelectFile,onClose:e.onClose})}function O_(e){var o,l,u,d;const t=e.listing?I_(e.listing):"",s=(l=(o=e.where)==null?void 0:o.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(ie,{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(ie,{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(ie,{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:T_(e.path).map((f,h,g)=>h===g.length-1?i.jsx("span",{"aria-current":"page",children:f.label},f.path):i.jsxs(gt.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:R_(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(ie,{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(ie,{name:"file",size:14})," ",f.name]}):i.jsxs("span",{className:"pc-ws__name",children:[i.jsx(ie,{name:"file",size:14})," ",f.name]}),i.jsx("span",{className:"pc-ws__size",children:nm(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(ie,{name:"download",size:14})})]}):null]})},f.path))}):i.jsx("div",{className:"pc-ws__muted",children:"This folder is empty."}):null,t?i.jsx("div",{className:"pc-ws__muted","data-hidden-note":"true",children:t}):null]})}function D_(e){return i.jsx(Up,{text:e,images:"link"})}const F_={trigger:"Trigger",answer:"Automation"};function z_(e){return i.jsx(Qp,{message:{id:`${e.runId}:${e.kind}`,role:e.role,content:e.text,title:F_[e.kind],runId:e.runId},images:"link"})}const W_={renderText:D_,renderTurn:z_};function U_(e){const{fetchGateway:t,...s}=e,o=s.onOpenResource??(t?l=>P_(t,l.url,{name:l.name}):void 0);return i.jsx(Xw,{...s,onOpenResource:o,...W_})}function B_(e,t,s={}){if(!e)return null;const o=e.wait,l=`${e.runId}:${o.wait_key}:${e.stepId||""}`,u=o.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(o.wait_key||""),stepId:e.stepId},g=[...new Set(f.map(v=>String((v==null?void 0:v.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(Hp,{tools:f.map((v,x)=>({id:String((v==null?void 0:v.call_id)||(v==null?void 0:v.id)||x),runId:e.runId,name:(v==null?void 0:v.name)||"Tool",arguments:v==null?void 0:v.arguments,status:"waiting"}))}),i.jsxs("details",{children:[i.jsx("summary",{children:"Review full tool arguments (JSON)"}),i.jsx(Is,{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 t.approveWithPolicyChange(h,()=>{y()})}:void 0,onApprove:async()=>{await t.approve(!0,h)},onDeny:async()=>{await t.approve(!1,h)}}}if(o.reason==="user"||o.reason==="ask_user")return{id:l,kind:"ask-user",title:"A question for you",prompt:String(o.prompt||u.prompt||"How would you like to continue?"),allowFreeText:o.allow_free_text!==!1,choices:(Array.isArray(o.choices)?o.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 t.resume(f)}};const d=String(o.wait_key||"");if(o.reason==="event"||d.startsWith("evt:")){const f=k_(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(o.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 v=JSON.parse(y||"{}"),x={name:h.name,scope:h.scope,payload:v};h.scope==="session"?x.session_id=h.scopeId:h.scope==="workflow"?x.workflow_id=h.scopeId:h.scope==="run"&&(x.run_id=h.scopeId),await t.emitEvent(x)}}}return null}const V_="abstractcode.agent.v1";function Iu(e){return!!(e!=null&&e.interfaces.some(t=>[V_,"abstractassistant.agent.v1"].includes(t)))}function tt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function nl(e){return Array.isArray(e)?e:[]}function Ne(e){return typeof e!="string"?void 0:e.trim()||void 0}function im(e){return nl(e).flatMap(t=>{const s=Ne(t);return s?[s]:[]})}function Mo(e,t=0){if(typeof e!="number"||!Number.isFinite(e))return;const s=Math.trunc(e);return s>=t?s:void 0}function Mu(e,t){if(Array.isArray(e))return e;const s=tt(e);if(!s)return[];for(const o of t)if(Array.isArray(s[o]))return s[o];return[]}function om(e){const t=tt(e);return t?{...t}:void 0}function Mh(e){const t=om(e.input_schema??e.inputSchema??e.inputs_schema);if(t)return t;const s=tt(e.inputs);if(s&&("properties"in s||"type"in s||"$schema"in s))return{...s}}function G_(e){const t=Ne(e.bundle_version??e.bundleVersion??e.version);if(t)return t;const s=Ne(e.bundle_ref??e.bundleRef);if(!s)return;const o=s.lastIndexOf("@");return o>0&&o<s.length-1?s.slice(o+1):void 0}function H_(e,t,s){return e?`${e}${t?`@${t}`:""}:${s}`:s}function Lh(e,t,s){var f;const o=tt(e),l=Ne((o==null?void 0:o.default_bundle_id)??(o==null?void 0:o.defaultBundleId)),u=Mu(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 v=(f=Ne(g.status))==null?void 0:f.toLowerCase();if(g.is_draft===!0||g.is_published===!1||g.version_channel==="draft"||v&&!["published","deprecated"].includes(v)||!s.includeDeprecated&&(v==="deprecated"||v==="deleted"||v==="disabled"))continue;const x=Ne(g.bundle_id??g.bundleId??g.id),b=G_(g);if(b&&/(?:^|[.\-])draft(?:[.\-]|$)/i.test(b))continue;const k=Ne(g.default_entrypoint??g.defaultEntrypoint),E=t==="private"&&(g.is_default===!0||g.isDefault===!0||!!x&&x===l);for(const S of nl(g.entrypoints)){const T=tt(S);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 $=im(T.interfaces??T.interface_ids??T.interfaceIds);if(s.interfaceId&&!$.includes(s.interfaceId))continue;const j=Ne(T.workflow_id??T.workflowId)??H_(x,b,A),P=k?k===A:nl(g.entrypoints).length===1;d.push({id:`${t}:${j}`,workflowId:j,...x?{bundleId:x}:{},...b?{bundleVersion:b}:{},flowId:A,name:Ne(T.name??T.title)??A,description:Ne(T.description)??"",interfaces:$,...Mh(T)?{inputSchema:Mh(T)}:{},registryScope:t,isPreferredVersion:t==="tenant_catalog"?g.is_default===!0||g.default_version===b:g.latest_published_version===b,...E&&P?{isDefault:!0}:{}})}}return d}function K_(e){var o;const t=new Map;for(const l of e){const u=l.bundleId||l.id;t.set(u,[...t.get(u)||[],l])}const s=[];for(const l of t.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=(o=l.find(g=>g.isDefault))==null?void 0:o.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 J_(e,t){return t.some(s=>s.id!==e.id&&s.name===e.name)?`${e.name} · ${e.bundleId||e.flowId}`:e.name}function Ph(e,t,s={}){const o=[...Lh(e,"private",s),...Lh(t,"tenant_catalog",s)],l=new Map;for(const u of o)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 Q_(e){const t=tt(e);if(!t)return;const s=tt(t.workflow_selection??t.workflowSelection);if(s)return s;const o=tt(t._runtime),l=tt((o==null?void 0:o.workflow_policy)??(o==null?void 0:o.workflowPolicy));if(l)return l;const u=tt(t.input_data??t.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 Y_(e,t){const s=Q_(t.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 o=Ne(t.runWorkflowId);if(!o)return;const l=e.filter(u=>(u.registryScope??"private")==="private"&&u.workflowId===o);return l.length===1?l[0]:void 0}function X_(e){const t=tt(e)??{},s=tt(t.policy)??t,l=nl(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=Mo(s.max_attachment_bytes??s.maxAttachmentBytes,1);return{raw:{...s},clientWorkspaceScopeOverrides:s.client_workspace_scope_overrides===!0||s.clientWorkspaceScopeOverrides===!0,allowedAccessModes:im(s.allowed_access_modes??s.allowedAccessModes),mounts:l,...u!==void 0?{maxAttachmentBytes:u}:{}}}function Z_(e){const t=Mu(e,["items","tools"]),s=new Set,o=[];for(const l of t){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=Mo(u.risk_rank??u.riskRank),g=om(u.input_schema??u.inputSchema??u.parameters);o.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 o.sort((l,u)=>l.name.localeCompare(u.name))}function q_(e){var o;const t=(o=Ne(e.status??e.state))==null?void 0:o.toLowerCase();return Ne(e.wait_reason??e.waitReason)||e.waiting===!0||t==="waiting"||t==="paused"?"waiting":t==="running"||t==="queued"||t==="pending"||t==="created"?"running":t==="failed"||t==="error"||t==="cancelled"||t==="canceled"?"failed":t==="completed"||t==="complete"||t==="done"?"done":"unknown"}const Oh={waiting:4,running:3,failed:2,done:1,unknown:0};function ki(e){return Ne(e.updated_at??e.updatedAt??e.finished_at??e.finishedAt??e.created_at??e.createdAt)}function ji(e){if(!e)return Number.NEGATIVE_INFINITY;const t=Date.parse(e);return Number.isFinite(t)?t:Number.NEGATIVE_INFINITY}function Dh(e){var d;const t=Ne(e);if(t)return t;const s=tt(e);if(!s)return;const o=Ne(s.prompt);if(o)return o;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,t={}){const s=tt(e),o=(s==null?void 0:s.has_more)===!0||(s==null?void 0:s.hasMore)===!0,l=Mu(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),v=Ne(g.run_id??g.runId??g.id);if(!y||!v)return;const x=u.get(y)??[];x.push({run:g,index:h}),u.set(y,x)});const d=[];for(const[f,h]of u){const g=[...h].sort((k,E)=>ji(ki(E.run))-ji(ki(k.run))||k.index-E.index),y=[...h].sort((k,E)=>{const S=Ne(k.run.created_at??k.run.createdAt)??ki(k.run),T=Ne(E.run.created_at??E.run.createdAt)??ki(E.run);return ji(S)-ji(T)||k.index-E.index}),v=g.flatMap(({run:k})=>{const E=Ne(k.run_id??k.runId??k.id);return E?[E]:[]});if(!v.length)continue;let x="unknown";for(const{run:k}of h){const E=q_(k);Oh[E]>Oh[x]&&(x=E)}let b;for(const{run:k}of y){const E=Ne(k.run_id??k.runId??k.id);if(b=(E?Dh(t[E]):void 0)??Dh(k),b)break}d.push({sessionId:f,state:x,...ki(g[0].run)?{updatedAt:ki(g[0].run)}:{},firstRunId:Ne(y[0].run.run_id??y[0].run.runId??y[0].run.id),latestRunId:v[0],runIds:v,turnCount:h.length,...b?{prompt:b}:{},truncated:o})}return d.sort((f,h)=>ji(h.updatedAt)-ji(f.updatedAt)||f.sessionId.localeCompare(h.sessionId))}function rl(e){return e?{...e}:{}}function Si(e){if(e!==void 0)return e.flatMap(t=>{const s=Ne(t);return s?[s]:[]})}function ex(e,t,s){var T,A,$,j,P,V,H,L,de;const o=(re,Q)=>{var U,J;!Iu(t.workflow)&&!((J=tt((U=t.inputSchema)==null?void 0:U.properties))!=null&&J[re])||Q!==void 0&&s&&(e[re]=Q)},l=Ne((T=t.model)==null?void 0:T.provider),u=Ne((A=t.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.");o("provider",l),o("model",u),t.tools!==void 0&&o("tools",Si(t.tools)??[]);const d=Si(t.skills);d!=null&&d.length&&(e.skills=d);const f=Ne(($=t.workspace)==null?void 0:$.root),h=Ne((j=t.workspace)==null?void 0:j.accessMode),g=Si((P=t.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),o("system",Ne(t.system));const y=rl(tt(e._runtime)),v=(re,Q)=>{Q!==void 0&&s&&(y[re]=Q)};if(v("provider",l),v("model",u),v("thinking",Ne(t.reasoning)),v("speculation",t.speculation),t.streamReplies!==void 0&&v("stream",h_(t.streamReplies).stream),v("system_prompt_extra",Ne(t.systemPromptExtra)),t.tools!==void 0){const re=Si(t.tools)??[],Q=Array.isArray(y.allowed_tools)?y.allowed_tools:null;y.allowed_tools=Q?re.filter(U=>Q.includes(U)):re}if(t.review!==void 0&&t.reviewCapable!==!1){v("review_mode",t.review.enabled);const re=t.review.enabled?Mo(t.review.maxRounds,1):void 0;v("review_max_rounds",re)}const x=Si((V=t.toolPolicy)==null?void 0:V.autoApproveTools),b=Si((H=t.toolPolicy)==null?void 0:H.requireApprovalTools);(((x==null?void 0:x.length)??0)>0||((b==null?void 0:b.length)??0)>0)&&v("tool_policy",{...x!=null&&x.length?{auto_approve_tools:x}:{},...b!=null&&b.length?{require_approval_tools:b}:{}}),t.promptCache!==void 0&&v("prompt_cache",t.promptCache),Object.keys(y).length&&(e._runtime=y);const k=rl(tt(e._limits)),E=Mo((L=t.limits)==null?void 0:L.maxIterations,1),S=Mo((de=t.limits)==null?void 0:de.maxTokens,1);E!==void 0&&s&&(k.max_iterations=E),S!==void 0&&s&&(k.max_tokens=S),Object.keys(k).length&&(e._limits=k),o("max_iterations",E),t.gatingMode==="auto"&&o("gating_mode","auto")}function tx(e){var o,l;const t=rl(e.schemaInputs),s=Iu(e.workflow);if(e.promptProperty){const u=Ne(e.promptProperty);u&&((o=e.prompt)!=null&&o.trim())&&(t[u]=e.prompt)}if(s){const u=e.prompt??"";t.prompt=u;const d=rl(tt(t.context));d.task=u,delete d.messages,t.use_context=!1,(l=e.attachments)!=null&&l.length&&(d.attachments=e.attachments.map(f=>({...f}))),t.context=d,t.use_session_history=e.useSessionHistory??!0}return ex(t,e,!0),t}class nx{constructor(){mn(this,"_buffer","");mn(this,"_current",{data_lines:[]})}push(t,s){for(this._buffer+=t;;){const o=this._buffer.indexOf(`
|
|
64
|
-
`);if(o===-1)return;const l=this._buffer.slice(0,o);this._buffer=this._buffer.slice(o+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 o;const t=(e||"").trim(),s={};t&&(s.Authorization=`Bearer ${t}`);try{const l=(o=document.cookie.split(";").map(u=>u.trim()).find(u=>u.startsWith("abstractcode_gateway_csrf=")))==null?void 0:o.slice(26);l&&(s["X-AbstractCode-CSRF"]=decodeURIComponent(l))}catch{}return s}function rx(e){const t=e.headers.get("retry-after");if(!t)return;const s=Number(t);if(Number.isFinite(s)&&s>0)return s}async function sx(e){var t;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=(t=l.error)==null?void 0:t.message;if(typeof d=="string"&&d.trim())return d.trim();try{const f=JSON.stringify(l);if(f&&f!=="{}")return f}catch{}}}const o=await e.text();return o!=null&&o.trim()?o.trim():`${e.status}`}catch{return`${e.status}`}}class am extends Error{constructor(s,o){super(s);mn(this,"status");mn(this,"retry_after_s");mn(this,"body_text");this.name="GatewayHttpError",this.status=Number.isFinite(Number(o.status))?Number(o.status):0,this.retry_after_s=o.retry_after_s,this.body_text=o.body_text}}async function qe(e,t){const s=await sx(e);throw new am(`${t}: ${s}`,{status:e.status,retry_after_s:rx(e),body_text:s})}class ix{constructor(t){mn(this,"_cfg");this._cfg={...t,base_url:(t.base_url||"").trim()}}async start_run(t,s,o){const l=String((o==null?void 0:o.bundle_id)||"").trim(),u=(o==null?void 0:o.session_id)===null||(o==null?void 0:o.session_id)===void 0?"":String(o.session_id||"").trim(),d=String(t||"").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(t){const s=String(t||"").trim();if(!s)throw new Error("get_run: run_id is required");const o=await fetch(Xe(this._cfg.base_url.trim(),Se(`runs/${encodeURIComponent(s)}`)),{headers:{...Ze(this._cfg.auth_token)}});return o.ok?await o.json():await qe(o,"get_run failed")}async get_run_history_bundle(t,s){const o=String(t||"").trim();if(!o)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(o)}/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(t){const s=new URLSearchParams,o=typeof(t==null?void 0:t.limit)=="number"?t.limit:50;s.set("limit",String(o));const l=String((t==null?void 0:t.status)||"").trim();l&&s.set("status",l);const u=String((t==null?void 0:t.workflow_id)||"").trim();u&&s.set("workflow_id",u);const d=String((t==null?void 0:t.session_id)||"").trim();d&&s.set("session_id",d),(t==null?void 0:t.root_only)===!0&&s.set("root_only","true"),(t==null?void 0:t.include_ledger_len)===!1&&s.set("include_ledger_len","false"),(t==null?void 0:t.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(t,s){const o=String(t||"").trim();if(!o)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(o)}/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(t,s){var k;const o=String(t||"").trim();if(!o)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(o)}/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");(k=s.on_open)==null||k.call(s);const g=h.body.getReader(),y=new TextDecoder("utf-8"),v=new nx,x=s.on_delta,b=s.on_delta_error;for(;;){const{value:E,done:S}=await g.read();if(S)return;const T=y.decode(E,{stream:!0});v.push(T,A=>{if(x&&b){const $=A.event||"message",j=A.data??"";let P;try{P=f_($,j)}catch(V){b(V instanceof Error?V:new Error(String(V)),{event:$,data:j});return}if(P){x(P);return}}if(!(A.event!=="step"||!A.data))try{const $=JSON.parse(A.data);$&&typeof $.cursor=="number"&&$.record&&u($)}catch{}})}}async list_bundles(){const t=await fetch(Xe(this._cfg.base_url.trim(),Se("bundles")),{headers:{...Ze(this._cfg.auth_token)}});return t.ok?await t.json():await qe(t,"list_bundles failed")}async reload_bundles(){const t=await fetch(Xe(this._cfg.base_url.trim(),Se("bundles/reload")),{method:"POST",headers:{...Ze(this._cfg.auth_token)}});return t.ok?await t.json():await qe(t,"reload_bundles failed")}async upload_bundle(t,s){const o=(s==null?void 0:s.overwrite)===!0,l=(s==null?void 0:s.reload)!==!1,u=new FormData;u.set("overwrite",o?"true":"false"),u.set("reload",l?"true":"false"),u.set("file",t,t.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 t=await fetch(Xe(this._cfg.base_url.trim(),Se("discovery/tools")),{headers:{...Ze(this._cfg.auth_token)}});return t.ok?await t.json():await qe(t,"discovery_tools failed")}async discovery_providers(t){const s=(t==null?void 0:t.include_models)===!0,o=Xe(this._cfg.base_url.trim(),Se(`discovery/providers?include_models=${encodeURIComponent(String(s))}`)),l=await fetch(o,{headers:{...Ze(this._cfg.auth_token)}});return l.ok?await l.json():await qe(l,"discovery_providers failed")}async discovery_provider_models(t){const s=String(t||"").trim();if(!s)throw new Error("discovery_provider_models: provider_name is required");const o=await fetch(Xe(this._cfg.base_url.trim(),Se(`discovery/providers/${encodeURIComponent(s)}/models`)),{headers:{...Ze(this._cfg.auth_token)}});return o.ok?await o.json():await qe(o,"discovery_provider_models failed")}async discovery_model_capabilities(t,s=""){const o=String(t||"").trim();if(!o)throw new Error("discovery_model_capabilities: model_name is required");const l=new URLSearchParams({model_name:o});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 t=await fetch(Xe(this._cfg.base_url.trim(),Se("workspace/policy")),{headers:{...Ze(this._cfg.auth_token)}});return t.ok?await t.json():await qe(t,"workspace_policy failed")}async files_search(t,s){const o=String(t||"").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",o),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(),v=String(d.workspace_allowed_paths||"").trim(),x=String(d.workspace_ignored_paths||"").trim();g&&u.set("workspace_root",g),y&&u.set("workspace_access_mode",y),v&&u.set("workspace_allowed_paths",v),x&&u.set("workspace_ignored_paths",x)}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(t,s){const o=String(t||"").trim();if(!o)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(o)}/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(t,s,o){const l=String(t||"").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(o==null?void 0:o.max_bytes)=="number"&&Number.isFinite(o.max_bytes)?Math.max(0,Math.trunc(o.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(t,s,o){const{blob:l}=await this.get_run_artifact_blob(t,s,o);return await l.text()}async attachments_ingest(t,s,o){const l=String(t||"").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=o==null?void 0:o.scope;if(f&&typeof f=="object"){const x=String(f.workspace_root||"").trim(),b=String(f.workspace_access_mode||"").trim(),k=String(f.workspace_allowed_paths||"").trim(),E=String(f.workspace_ignored_paths||"").trim();x&&(d.workspace_root=x),b&&(d.workspace_access_mode=b),k&&(d.workspace_allowed_paths=k),E&&(d.workspace_ignored_paths=E)}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(t,s,o){const l=String(t||"").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((o==null?void 0:o.filename)||"").trim()||String((s==null?void 0:s.name)||"").trim()||"upload.bin",d=String((o==null?void 0:o.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(t,s){const o=String(t||"").trim();if(!o)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(o)}/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(t,s){const o=String(t||"").trim();if(!o)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(o)}/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(t){const s={command_id:String((t==null?void 0:t.command_id)||"").trim(),run_id:String((t==null?void 0:t.run_id)||"").trim(),type:String((t==null?void 0:t.type)||"").trim(),payload:t!=null&&t.payload&&typeof t.payload=="object"?t.payload:{}},o=String((t==null?void 0:t.ts)||"").trim();o&&(s.ts=o);const l=String((t==null?void 0:t.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(t){const s={session_id:String((t==null?void 0:t.session_id)||"").trim(),description:String((t==null?void 0:t.description)||"")},o=String((t==null?void 0:t.active_run_id)||"").trim();o&&(s.active_run_id=o);const l=String((t==null?void 0:t.workflow_id)||"").trim();l&&(s.workflow_id=l);const u=String((t==null?void 0:t.client)||"").trim();u&&(s.client=u);const d=String((t==null?void 0:t.client_version)||"").trim();d&&(s.client_version=d);const f=String((t==null?void 0:t.user_agent)||"").trim();f&&(s.user_agent=f);const h=String((t==null?void 0:t.url)||"").trim();h&&(s.url=h);const g=String((t==null?void 0:t.provider)||"").trim();g&&(s.provider=g);const y=String((t==null?void 0:t.model)||"").trim();y&&(s.model=y);const v=String((t==null?void 0:t.template)||"").trim();v&&(s.template=v);const x=t==null?void 0:t.context;x&&typeof x=="object"&&(s.context=x);const b=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 b.ok?await b.json():await qe(b,"bug_report_create failed")}async feature_report_create(t){const s={session_id:String((t==null?void 0:t.session_id)||"").trim(),description:String((t==null?void 0:t.description)||"")},o=String((t==null?void 0:t.active_run_id)||"").trim();o&&(s.active_run_id=o);const l=String((t==null?void 0:t.workflow_id)||"").trim();l&&(s.workflow_id=l);const u=String((t==null?void 0:t.client)||"").trim();u&&(s.client=u);const d=String((t==null?void 0:t.client_version)||"").trim();d&&(s.client_version=d);const f=String((t==null?void 0:t.user_agent)||"").trim();f&&(s.user_agent=f);const h=String((t==null?void 0:t.url)||"").trim();h&&(s.url=h);const g=String((t==null?void 0:t.provider)||"").trim();g&&(s.provider=g);const y=String((t==null?void 0:t.model)||"").trim();y&&(s.model=y);const v=String((t==null?void 0:t.template)||"").trim();v&&(s.template=v);const x=t==null?void 0:t.context;x&&typeof x=="object"&&(s.context=x);const b=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 b.ok?await b.json():await qe(b,"feature_report_create failed")}async prompt_cache_stats(t,s){const o=String(t||"").trim(),l=String(s||"").trim();if(!o||!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(o)}&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(t,s){const o=String(t||"").trim(),l=String(s||"").trim();if(!o||!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(o)}&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(t,s){const o=String(t||"").trim(),l=String(s||"").trim();if(!o||!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(o)}&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(t){const s={provider:String((t==null?void 0:t.provider)||"").trim(),model:String((t==null?void 0:t.model)||"").trim()},o=(t==null?void 0:t.key)===null||(t==null?void 0:t.key)===void 0?"":String(t.key||"").trim();o&&(s.key=o);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(t){const s={provider:String((t==null?void 0:t.provider)||"").trim(),model:String((t==null?void 0:t.model)||"").trim(),name:String((t==null?void 0:t.name)||"").trim(),key:String((t==null?void 0:t.key)||"").trim(),q8:!!(t!=null&&t.q8)},o=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 o.ok?await o.json():await qe(o,"prompt_cache_save failed")}async prompt_cache_load(t){const s={provider:String((t==null?void 0:t.provider)||"").trim(),model:String((t==null?void 0:t.model)||"").trim(),name:String((t==null?void 0:t.name)||"").trim(),key:String((t==null?void 0:t.key)||"").trim(),clear_existing:!!(t!=null&&t.clear_existing)},o=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 o.ok?await o.json():await qe(o,"prompt_cache_load failed")}}function lm(){const e=document.cookie.split(";").map(t=>t.trim()).find(t=>t.startsWith("abstractcode_gateway_csrf="));return e?{"X-AbstractCode-CSRF":decodeURIComponent(e.slice(26))}:{}}async function ht(e,t={}){if(!e.startsWith(`${Za}/`))throw new Error("Gateway requests must use the app's authenticated proxy (a relative api/gateway/… path).");const s=new Headers(t.headers);s.set("Accept","application/json"),t.body&&!(t.body instanceof FormData)&&s.set("Content-Type","application/json");for(const[l,u]of Object.entries(lm()))s.set(l,u);const o=await fetch(e,{...t,headers:s,credentials:"same-origin"});if(!o.ok){const l=await o.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 am(u||`Gateway request failed (${o.status})`,{status:o.status,body_text:l})}if(o.status!==204)return o.json()}const $n=new ix({base_url:""});function St(e){return e instanceof Error?e.message:String(e)}function es(){return crypto.randomUUID()}async function ox(e,t,s){const{blob:o}=await $n.get_run_artifact_blob(e,t),l=URL.createObjectURL(o),u=document.createElement("a");u.href=l,u.download=s.replace(/[\\/]/g,"_")||"artifact",u.click(),window.setTimeout(()=>URL.revokeObjectURL(l),1e3)}const on=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{};function ax(e,t){const s=on(t);return Object.fromEntries(Object.keys(on(e.properties)).flatMap(o=>["_runtime","_limits"].includes(o)||!Object.prototype.hasOwnProperty.call(s,o)?[]:[[o,structuredClone(s[o])]]))}function Fh(e){if(!e)return;const t=on(e.input_data_schema||e.input_schema||e.schema||e),s=Object.fromEntries(Object.entries(on(t.properties)).map(([o,l])=>[o,{...on(l)}]));for(const o of Array.isArray(e.inputs)?e.inputs:[])o!=null&&o.id&&(s[o.id]={...on(o.schema),...s[o.id],...o.type?{"x-abstract-type":o.type}:{},...o.label?{title:o.label}:{},...Object.prototype.hasOwnProperty.call(o,"default")?{default:o.default}:{}});for(const[o,l]of Object.entries(on(e.defaults)))s[o]={...s[o],default:l};return{...t,properties:s}}function lx(e,t){var g;const s=on(t).nodes;if(!Array.isArray(s))throw new Error("The workflow input declarations could not be verified. Please retry.");const o=s.find(y=>{var v;return(((v=y==null?void 0:y.data)==null?void 0:v.nodeType)||(y==null?void 0:y.type))==="on_flow_start"});if(!o||!Array.isArray((g=o.data)==null?void 0:g.outputs))throw new Error("The workflow start inputs could not be verified. Please retry.");const l=o.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=on(o.data.pinDefaults);for(const y of l)y.required===!0&&d.add(y.id),f[y.id]={...on(f[y.id]),...on(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 To(e){return Object.fromEntries(Object.entries((e==null?void 0:e.properties)||{}).flatMap(([t,s])=>Object.prototype.hasOwnProperty.call(on(s),"default")?[[t,structuredClone(on(s).default)]]:[]))}function cx(e){const t=Array.isArray(e.type)?e.type.find(o=>o!=="null"):e.type;if(t)return t;const s=e["x-abstract-type"];return["tools","assertions"].includes(s)?"array":["json_schema","memory","assertion"].includes(s)?"object":"string"}function ux(e){const t=(e==null?void 0:e.properties)||{},s=l=>{const u=t[l];return u&&(u.type==="string"||Array.isArray(u.type)&&u.type.includes("string")||!u.type&&u["x-abstract-type"]==="string")},o=Object.keys(t).filter(l=>{var u;return((u=t[l])==null?void 0:u["x-abstract-role"])==="prompt"&&s(l)});return o.length?o.length===1?o[0]:void 0:["prompt","request","task","message","query","input"].find(s)}function dx(e,t){var l,u,d;if(!e)return[];const s={...To(e),...t},o=[];for(const f of Array.isArray(e.required)?e.required:[])s[f]===void 0&&o.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(k=>JSON.stringify(k)===JSON.stringify(h))&&o.push(`${y} must be one of the available choices.`);const v=Array.isArray(g.type)?g.type:g.type?[g.type]:[];if(h===null&&(v.includes("null")||!v.length))continue;const x=Array.isArray(h)?"array":h===null?"null":typeof h,b=v.includes(x)?x:x==="number"&&v.includes("integer")?"integer":v[0];(b==="number"||b==="integer")&&(typeof h!="number"||!Number.isFinite(h)||b==="integer"&&!Number.isInteger(h))&&o.push(`${y} must be ${b==="integer"?"a whole number":"a number"}.`),typeof h=="number"&&g.minimum!==void 0&&h<g.minimum&&o.push(`${y} must be at least ${g.minimum}.`),typeof h=="number"&&g.maximum!==void 0&&h>g.maximum&&o.push(`${y} must be at most ${g.maximum}.`),b==="string"&&typeof h!="string"&&o.push(`${y} must be text.`),typeof h=="string"&&g.minLength!==void 0&&h.length<g.minLength&&o.push(`${y} must contain at least ${g.minLength} characters.`),b==="boolean"&&typeof h!="boolean"&&o.push(`${y} must be true or false.`),b==="array"&&!Array.isArray(h)&&o.push(`${y} must be a JSON array.`),b==="object"&&(h===null||typeof h!="object"||Array.isArray(h))&&o.push(`${y} must be a JSON object.`)}return o}function cm(e){const t=(e==null?void 0:e.properties)||{},s=[];for(const[o,l]of Object.entries(t)){const u=on(l);if(!(o==="provider"||o.endsWith("_provider")||String(u["x-abstract-type"]||"").startsWith("provider")))continue;const d=String(u["x-abstract-type"]||""),f=o.replace("provider","model"),h=Object.keys(t).filter(b=>{var k;return((k=t[b])==null?void 0:k["x-abstract-type"])===d.replace(/^provider/,"model")}),g=f!==o&&t[f]?f:h.length===1?h[0]:"";if(!g)continue;const y=o==="provider"?"":o.startsWith("provider_")?o.slice(9):o.endsWith("_provider")?o.slice(0,-9):d.replace(/^provider_?/,""),v=y&&y!=="text"?`${y}_`:"",x=[`${v}reasoning`,`${v}thinking`,`${v}reasoning_effort`,`reasoning_${y}`,`thinking_${y}`].find(b=>t[b]);s.push({provider:o,model:g,reasoning:x,title:v?v.replace(/_/g," ").trim():"Text model"})}return s}const Lu={fetchProviders:async()=>{const e=await $n.discovery_providers(),t=e.providers||e.items;return Array.isArray(t)?t.map(s=>typeof s=="string"?{name:s}:s):[]},fetchModels:async e=>{const t=await $n.discovery_provider_models(e),s=t.models||t.items;return Array.isArray(s)?s.map(o=>typeof o=="string"?o:o.id||o.name).filter(Boolean):[]},fetchModelCapabilities:(e,t="")=>$n.discovery_model_capabilities(e,t)};function fx(e){for(const t of["output.text","input.text"]){const s=(Array.isArray(e==null?void 0:e.routes)?e.routes:[]).find(o=>o.key===t&&o.source!=="not_configured"&&o.provider&&o.model);if(s)return{provider:s.provider,model:s.model}}}function hx(e,t){e.startsWith("provider_")?e=`${e.slice(9)}_provider`:t!=null&&t.startsWith("provider_")&&!e.endsWith("_provider")&&(e=`${t.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 Lu;const o=e==="voice_provider",l=Se(s?`vision/provider_models?task=${s}`:o?"audio/speech/models?compact=true":"audio/music/models?task=text_to_music"),u=s?`${l}&providers_only=true`:Se(o?"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,v;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])||((v=h.music_models_by_provider)==null?void 0:v[f])||h.models||h.items)}}}const px=["gateway_default","on","off"],um={status:"loading"};function mx(e,t){if(t)return{status:"unsupported",reason:`the gateway's capabilities could not be read (${t})`};const s=e==null?void 0:e.capabilities,o=s==null?void 0:s.streaming;return!o||typeof o!="object"||o.deltas!==!0?{status:"unsupported",reason:"not supported by this gateway (it does not advertise live replies)"}:{status:"supported",gatewayDefault:typeof o.default=="boolean"?o.default:null}}function gx(e){return px.includes(e)?e:"gateway_default"}function yx(e,t){return e==="on"&&t.status!=="supported"?"gateway_default":e}function wx(e,t,s){if(e!=="on"||t.status!=="unsupported"||!s.length)return null;const o=s.find(l=>l.role==="user")||s[0];return{after:o.id?String(o.id):null,message:{id:"stream-replies:unsupported",role:"system",level:"info",title:"Stream replies",content:`Streaming is on in your settings but this gateway does not support live replies: ${t.reason}. Replies appear when they are complete.`}}}function vx(e){try{const t=JSON.parse(e);return typeof(t==null?void 0:t.call_id)=="string"&&t.call_id?t.call_id:""}catch{return""}}function _x(e,t){const s=vx(e.frame.data),o=s?`call:${s}`:`error:${e.error.message}`;return{after:t,message:{id:`stream-replies:malformed:${e.runId}:${o}`,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 xx(e,t){return e.some(s=>s.message.id===t.message.id)?[...e]:[...e,t]}function bx(e,t){const s=t.filter(f=>!!f);if(!s.length)return[...e];const o=[],l=new Set;for(const f of e){o.push(f);for(const h of s)!l.has(h)&&h.after!==null&&String(f.id)===h.after&&(o.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),...o,...d.map(f=>f.message)]}function kx(e){return e.status==="supported"&&e.gatewayDefault!==null?`Gateway default (${e.gatewayDefault?"on":"off"})`:"Gateway default"}const En="@default",Ti="abstractcode.agent.v1";function ir(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function rn(e){return typeof e=="string"&&e.trim()?e.trim():void 0}const jx="gateway does not report a default agent workflow";function Sx(e,t=Ti){var y,v;const s=ir(e);if(!s)return{status:"unavailable",reason:"the gateway's workflow list could not be loaded"};const o=ir(s.default_agent_workflows);if(!o)return{status:"unavailable",reason:jx};const l=ir(o[t]);if(!l){const x=rn((v=ir((y=ir(s.default_agent_workflows_unavailable))==null?void 0:y[t]))==null?void 0:v.reason);return{status:"unavailable",reason:x?`no default workflow for ${t}: ${x}`:`gateway reports no default workflow for ${t}`}}const u=rn(l.bundle_id),d=rn(l.flow_id),f=rn(l.registry_scope);if(!u||!d||!f)return{status:"unavailable",reason:`gateway's default workflow for ${t} is missing its bundle, flow or registry scope`};const h=rn(l.bundle_version);return{status:"ok",workflow:{workflowId:rn(l.workflow_id)??`${u}${h?`@${h}`:""}:${d}`,bundleId:u,...h?{bundleVersion:h}:{},flowId:d,registryScope:f,name:rn(l.name)??d,...rn(l.source)?{source:rn(l.source)}:{}}}}function zh(e){if(e.status==="loading")return"Gateway default (loading…)";if(e.status==="unavailable")return`Gateway default — ${e.reason}`;const{name:t,bundleVersion:s}=e.workflow;return`Gateway default → ${t}${s?` @${s}`:""}`}function Nx(e,t,s=Ti){if(e.status!=="ok")return null;const o=e.workflow,l=t.find(u=>(u.registryScope??"private")===o.registryScope&&u.bundleId===o.bundleId&&u.flowId===o.flowId&&(!o.bundleVersion||u.bundleVersion===o.bundleVersion));return l||{id:`${o.registryScope}:${o.workflowId}`,workflowId:o.workflowId,bundleId:o.bundleId,...o.bundleVersion?{bundleVersion:o.bundleVersion}:{},flowId:o.flowId,name:o.name,description:"",interfaces:[s],registryScope:o.registryScope}}function qc(e,t=Ti){if(!e||e.interfaces.includes(t))return"";const s=e.interfaces.length?e.interfaces.join(", "):"no interface";return`The gateway default ${e.name} does not declare ${t} (it declares ${s}); it will not run as a coding agent here.`}function Cx(e,t,s=Ti){return t?[...e]:e.filter(o=>o.interfaces.includes(s))}function Ex(e){const t=s=>s===En||e.visible.some(o=>o.id===s)||!!e.runId&&e.workflows.some(o=>o.id===s);return e.selection&&t(e.selection)?e.selection:e.preferred&&t(e.preferred)?e.preferred:En}function Pu(e){var s,o;const t=ir((o=ir((s=ir(e))==null?void 0:s.input_data))==null?void 0:o.workflow_selection);return rn(t==null?void 0:t.source)}function $x(e){var t;return Pu(e.restoredInputs)==="gateway_default"?En:(t=e.restored)==null?void 0:t.id}function Ax(e){return!ir(e)||Pu(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 Tx(e){return e.selection===En?{flow_id:En,interface:e.interfaceId??Ti,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 Rx(e){const t=ir(e);if(!t)return{text:"the gateway did not report which workflow it started",missing:!0};const s=rn(t.name)??rn(t.workflow_id)??rn(t.flow_id)??"unnamed workflow",o=rn(t.bundle_version);return{text:`running ${s}${o?` @${o}`:""}${t.source==="gateway_default"?" (gateway default)":""}`,missing:!1}}const eu={gatewayDefault:{status:"loading"},workflows:[],choices:[],policy:null,tools:[],sessions:[],capabilities:{},streaming:um,loading:!1,errors:[],hasMore:!1};function Ix(e){var s;const t=((s=e==null?void 0:e.capabilities)==null?void 0:s.contracts)??(e==null?void 0:e.contracts)??e;return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function Mx(e,t){const[s,o]=w.useState(eu),[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 v=new AbortController;if(f.current=v,h.current.identity!==e&&(h.current={identity:e,values:{}}),!e){o(eu);return}o($=>({...$,loading:!0,errors:[]}));const x=["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"],b=await Promise.allSettled(x.map($=>ht(Se(`${$}`),{signal:v.signal})));if(d.current!==y)return;const k=$=>b[$].status==="fulfilled"?b[$].value:void 0,E=[];b.forEach(($,j)=>{var P,V;$.status==="rejected"&&(((P=$.reason)==null?void 0:P.status)===401&&t(),!(j===5&&[403,404,501].includes((V=$.reason)==null?void 0:V.status))&&E.push(`${["Workflows","Workspace policy","Tools","Conversations","Capabilities","Shared workflows","Gateway defaults"][j]}: ${St($.reason)}`))}),o({workflows:Ph(k(0),k(5)),choices:K_(Ph(k(0),k(5))),policy:k(1)?X_(k(1)):null,tools:Z_(k(2)),sessions:Zc(k(3),h.current.values),capabilities:Ix(k(4)),streaming:mx(k(4),b[4].status==="rejected"?St(b[4].reason):void 0),defaultModel:fx(k(6)),gatewayDefault:Sx(k(0)),loading:!1,errors:E,hasMore:!!((A=k(3))!=null&&A.has_more)});const S=Zc(k(3),h.current.values).filter($=>!$.prompt&&!($.firstRunId in h.current.values));for(let $=0;$<S.length;$+=4){if(d.current!==y||v.signal.aborted||(await Promise.all(S.slice($,$+4).map(async j=>{try{const P=await ht(Se(`runs/${encodeURIComponent(j.firstRunId)}/input_data`),{signal:v.signal});d.current===y&&!v.signal.aborted&&(h.current.values[j.firstRunId]=P)}catch(P){!v.signal.aborted&&(P==null?void 0:P.status)===401&&t()}})),d.current!==y||v.signal.aborted))return;o(j=>({...j,sessions:Zc(k(3),h.current.values)}))}},[e,l,t]);return w.useEffect(()=>{u(100)},[e]),w.useEffect(()=>(o(eu),g(),()=>{var y;d.current+=1,(y=f.current)==null||y.abort()}),[g]),{...s,refresh:g,loadMore:()=>u(y=>y+100)}}async function Lx(e){if(e.inputSchema)return Fh(e.inputSchema);if(!e.bundleId)return;const t=encodeURIComponent(e.bundleId),s=encodeURIComponent(e.flowId),o=e.registryScope==="tenant_catalog"&&e.bundleVersion?Se(`workflow-catalog/${t}/versions/${encodeURIComponent(e.bundleVersion)}/flows/${s}/input_schema?scope=tenant`):Se(`bundles/${t}/flows/${s}/input_schema${e.bundleVersion?`?bundle_version=${encodeURIComponent(e.bundleVersion)}`:""}`),l=await ht(o),u=Fh(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=v=>{for(const[x,b]of Object.entries(f))if((v==null?void 0:v[x])!==b)throw new Error("The Gateway returned inputs for a different workflow version. Refresh workflows and retry.");if(e.registryScope==="tenant_catalog"&&(v==null?void 0:v.registry_scope)!=="tenant_catalog")throw new Error("The Gateway returned inputs from a different workflow registry. Refresh workflows and retry.")};h(l);const g=e.registryScope==="tenant_catalog"?Se(`workflow-catalog/${t}/versions/${encodeURIComponent(d)}/flows/${s}?scope=tenant`):Se(`bundles/${t}/flows/${s}?bundle_version=${encodeURIComponent(d)}`),y=await ht(g);return h(y),lx(u,y.flow)}const tu=e=>Se(`runs/${encodeURIComponent(e)}`);function Px(e){return{getRun:(t,s)=>ht(tu(t),{signal:s}),getHistory:(t,s)=>ht(`${tu(t)}/history_bundle?include_subruns=true&include_session=true&ledger_mode=full`,{signal:s}),getLedger:(t,s,o)=>ht(`${tu(t)}/ledger?after=${s}&limit=200`,{signal:o}),streamLedger:(t,s,o,l,u,d)=>$n.stream_ledger(t,{after:s,on_step:o,signal:l,on_open:u,on_delta:d,on_delta_error:(f,h)=>e.onDeltaError({runId:t,error:f,frame:h})}),submitCommand:(t,s)=>ht(Se("commands"),{method:"POST",body:JSON.stringify(t),signal:s})}}function nr(e){return typeof e=="string"?e.trim():""}function Ox(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},o=(Array.isArray(t.skills)?t.skills:[]).flatMap(f=>{const h=f&&typeof f=="object"&&!Array.isArray(f)?f:null,g=nr(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:nr(h.description),trustLevel:nr(h.trust_level)||"unverified",blocked:h.blocked===!0,requiresReview:h.requires_review===!0,reasons:Array.isArray(h.reasons)?h.reasons.map(nr).filter(Boolean):[],source:y?{source:nr(y.source),binding:nr(y.binding),ambiguous:y.ambiguous===!0}:void 0}]}),l=Array.isArray(t.warnings)?t.warnings.map(nr).filter(Boolean):[],u=nr(t.shelf),d=nr(t.shelf_source);return{skills:o.sort((f,h)=>f.name.localeCompare(h.name)),warnings:l,...u?{shelf:u}:{},...d?{shelfSource:d}:{}}}function Dx({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((t,s)=>i.jsx("p",{children:e.shelf?t:`The gateway has no skill shelf: ${t}`},`${t}:${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 Fx(e){var o;const t=e.trustLevel.replace(/[_-]+/g," "),s=(o=e.source)!=null&&o.source?`Adopted from ${e.source.source}`:"Source has no adoption record";return`Trust: ${t}. ${s}${e.requiresReview?". Review required":""}.`}function zx({value:e,onChange:t,disabled:s}){const[o,l]=w.useState({skills:[],warnings:[]}),[u,d]=w.useState(""),[f,h]=w.useState(!0),[g,y]=w.useState(""),[v,x]=w.useState(0);w.useEffect(()=>{const S=new AbortController;return h(!0),y(""),ht(Se("skills"),{signal:S.signal}).then(T=>{S.signal.aborted||l(Ox(T))}).catch(T=>{S.signal.aborted||y(St(T))}).finally(()=>{S.signal.aborted||h(!1)}),()=>S.abort()},[v]);const b=w.useMemo(()=>new Set(e.map(nr).filter(Boolean)),[e]),k=w.useMemo(()=>{const S=u.trim().toLocaleLowerCase();return S?o.skills.filter(T=>`${T.name}
|
|
66
|
-
${T.description}
|
|
67
|
-
${T.trustLevel}`.toLocaleLowerCase().includes(S)):o.skills},[o.skills,u]),E=(S,T)=>{const A=T?[...b,S]:[...b].filter($=>$!==S);t([...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:S=>d(S.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:()=>x(S=>S+1),disabled:s,children:"Retry"})]}):null,o.warnings.length&&o.skills.length?i.jsxs("details",{className:"code-disabled-tools",children:[i.jsxs("summary",{children:["Gateway reported ",o.warnings.length," skills warning",o.warnings.length===1?"":"s"]}),o.warnings.map((S,T)=>i.jsx("p",{children:S},`${S}:${T}`))]}):null,!f&&!g&&!o.skills.length?i.jsx(Dx,{inventory:o}):null,!f&&!g&&o.skills.length&&!k.length?i.jsx("p",{className:"code-muted",children:"No skills match your search."}):null,k.map(S=>{const T=S.reasons.join(" ")||"Blocked by gateway policy.",A=b.has(S.name),$=s||S.blocked;return i.jsxs("label",{className:"code-field",children:[i.jsxs("span",{children:[i.jsx("input",{type:"checkbox",checked:A,disabled:$,onChange:j=>E(S.name,j.target.checked)})," ",i.jsx("strong",{children:S.name})]}),S.description?i.jsx("span",{className:"code-field-help",children:S.description}):null,i.jsx("span",{className:"code-field-help",children:Fx(S)}),S.blocked?i.jsxs("span",{className:"code-error-text",children:["Blocked by the gateway: ",T]}):null]},S.name)})]})}function Ou(e){if(!["ArrowLeft","ArrowRight","Home","End"].includes(e.key))return;const t=[...e.currentTarget.querySelectorAll('button[role="tab"]')].filter(l=>!l.disabled),s=t.indexOf(e.target);if(s<0||!t.length)return;e.preventDefault();const o=e.key==="Home"?0:e.key==="End"?t.length-1:(s+(e.key==="ArrowRight"?1:-1)+t.length)%t.length;t[o].focus(),t[o].click()}function dm(e,t,s="default"){const o=e.filter(u=>u.enabled&&!u.servedDisabled&&(t.mode==="all"||t.selected.includes(u.name))),l=u=>{const d=t.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:o.map(u=>u.name),autoApproveTools:o.filter(l).map(u=>u.name),requireApprovalTools:o.filter(u=>!l(u)).map(u=>u.name)}}function Wx(e,t){if(!Array.isArray(t))return e;const s=o=>t.includes(o);return{enabledTools:e.enabledTools.filter(s),autoApproveTools:e.autoApproveTools.filter(s),requireApprovalTools:e.requireApprovalTools.filter(s)}}const Nr={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 Ux({open:e,onClose:t,tab:s,onTab:o,value:l,onChange:u,policy:d,tools:f,disabled:h,defaultModel:g,workflowDefault:y,streaming:v=um,topOffset:x}){const b=k=>u({...l,...k});return i.jsx(lu,{open:e,onClose:t,label:"Run settings",title:"Run settings",width:480,topOffset:x??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:Ou,children:["model","workspace","tools","skills"].map(k=>i.jsx("button",{role:"tab",tabIndex:s===k?0:-1,"aria-selected":s===k,onClick:()=>o(k),children:k==="model"?"Model & behavior":k==="workspace"?"Workspace":k==="tools"?"Tools":"Skills"},k))}),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(bu,{defaultModeLabel:y?"Workflow default":"Gateway default",value:l,onChange:b,disabled:h,effectiveDefault:g,fetchModelCapabilities:Lu.fetchModelCapabilities,enableSpeculation:!0,defaultHint:g?`${y?"Workflow":"Gateway"} default: ${g.provider} · ${g.model}.`:void 0,fetchProviders:async()=>{const k=await $n.discovery_providers();return Array.isArray(k.providers)?k.providers:Array.isArray(k.items)?k.items:[]},fetchModels:async k=>{const E=await $n.discovery_provider_models(k);return(Array.isArray(E.models)?E.models:Array.isArray(E.items)?E.items:[]).map(S=>typeof S=="string"?S:S.id||S.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:k=>b({maxIterations:k.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:k=>b({maxTokens:k.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:k=>b({system:k.target.value})})]}),i.jsx("p",{className:"code-field-help",children:"Reasoning and additional instructions depend on the selected workflow and model."}),i.jsx(Bx,{value:l.streamReplies,onChange:k=>b({streamReplies:k}),disabled:h,streaming:v})]})]}):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(k=>k.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:k=>b({workspaceRoot:k.target.value})})]}),i.jsxs("label",{className:"code-field",children:["Access mode",i.jsxs("select",{value:l.workspaceMode,disabled:h,onChange:k=>b({workspaceMode:k.target.value}),children:[i.jsx("option",{value:"",children:"Gateway default"}),d.allowedAccessModes.map(k=>i.jsx("option",{value:k,children:k.replace(/_/g," ")},k))]})]}),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:k=>b({allowedPaths:k.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:k=>b({permissions:k.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(xy,{tools:f.filter(k=>k.enabled).map(k=>({...k,default_approval:dm(f,l.tools,l.permissions).autoApproveTools.includes(k.name)?"approve":"ask"})),value:l.tools,onChange:k=>b({tools:k,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(k=>!k.enabled)?i.jsxs("details",{className:"code-disabled-tools",children:[i.jsxs("summary",{children:[f.filter(k=>!k.enabled).length," tools unavailable under gateway policy"]}),f.filter(k=>!k.enabled).map(k=>i.jsxs("p",{children:[i.jsx("strong",{children:k.name}),i.jsx("br",{}),k.whyDisabled||"Disabled by the gateway"]},k.name))]}):null,i.jsx("button",{className:"code-text-button",disabled:h,onClick:()=>b({toolsCustomized:!1,tools:Nr.tools,permissions:"default"}),children:"Use workflow tool defaults"})]}):i.jsx(zx,{value:l.skills,onChange:k=>b({skills:k}),disabled:h})]})})}function Bx({value:e,onChange:t,disabled:s,streaming:o}){const l=o.status!=="supported",u=o.status==="unsupported"?`Unavailable: ${o.reason}. Replies appear when they are complete.`:o.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=>t(d.target.value),children:[i.jsx("option",{value:"gateway_default",children:kx(o)}),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":o.status,children:u})]})}async function Vx(e){var s;const t=String(e??"");if(!t)return!1;try{if((s=navigator==null?void 0:navigator.clipboard)!=null&&s.writeText)return await navigator.clipboard.writeText(t),!0}catch{}try{const o=document.createElement("textarea");o.value=t,o.setAttribute("readonly","true"),o.style.position="fixed",o.style.top="-1000px",o.style.left="-1000px",document.body.appendChild(o),o.select(),o.setSelectionRange(0,o.value.length);const l=document.execCommand("copy");return document.body.removeChild(o),!!l}catch{return!1}}const Gx=3,Wh=["KB","MB","GB","TB"];function Lo(e){const t=Math.max(0,Number(e)||0);if(t<1024)return`${t} B`;let s=t/1024,o=0;for(;s>=1024&&o<Wh.length-1;)s/=1024,o+=1;return`${s<10?Math.round(s*10)/10:Math.round(s)} ${Wh[o]}`}function Uh(e){return`${Math.round(e).toLocaleString("en-US")} bytes`}function fm(e,t){if(!t||!(t>0)||e.size<=t)return null;let s=Lo(e.size),o=Lo(t);return s===o&&(s=Uh(e.size),o=Uh(t)),`${e.name||"This file"} is ${s}; the gateway accepts files up to ${o}.`}function Hx(e){return`Upload failed: ${String(e||"").replace(/^attachments_upload failed:?\s*/i,"").trim()||"the gateway did not say why"}`}function Kx(e,t,s){return e.map(o=>{const l=fm(o,t);return{id:s(),file:o,name:o.name||"Untitled file",size:o.size,status:l?"refused":"queued",...l?{message:l}:{}}})}async function Jx(e,t,s){let o=0;const l=Array.from({length:Math.max(1,Math.min(Math.floor(t)||1,e.length))},async()=>{for(;o<e.length;){const u=e[o];o+=1,await s(u)}});await Promise.all(l)}function sl(e){return`${e} ${e===1?"file":"files"}`}function Bh(e,t){const s=[];return e&&s.push(`${sl(e)} attached`),t&&s.push(`${sl(t)} could not be attached`),s.join(", ")}function Qx(e){const t=e.filter(l=>l.status==="queued"||l.status==="uploading").length;if(t)return`Wait for ${sl(t)} to finish uploading.`;const s=e.filter(l=>l.status==="failed"||l.status==="refused");if(!s.length)return null;const o=s.some(l=>l.status==="failed");return s.length===1?`"${s[0].name}" was not attached. ${o?"Retry or remove":"Remove"} it before sending.`:`${sl(s.length)} were not attached. ${o?"Retry or remove":"Remove"} them before sending.`}const Vh=1024*1024,Yx="1 MiB",Gh=e=>Se(`runs/${encodeURIComponent(e)}/workspace`),vu=(e,t)=>fetch(e,{...t,credentials:"same-origin"}),Xx=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(" ")),Zx=new Set("png jpg jpeg gif webp bmp ico avif svg".split(" "));function qx(e){const t=e.split("/").pop()||e,s=t.lastIndexOf(".");return s>0?t.slice(s+1).toLowerCase():t.toLowerCase()}function Hh(e,t=""){const s=qx(e),o=t.split(";",1)[0].trim().toLowerCase();return s==="md"||s==="markdown"||o==="text/markdown"?"markdown":s==="json"||s==="jsonl"||o==="application/json"||o.endsWith("+json")?s==="jsonl"?"text":"json":Zx.has(s)||o.startsWith("image/")?"image":s==="html"||s==="htm"||o==="text/html"?"html":Xx.has(s)||o.startsWith("text/")||["application/javascript","application/xml","application/x-yaml","application/toml"].includes(o)?"text":"binary"}function eb(e){var t;return e.open_supported===!0&&((t=e.host)==null?void 0:t.caller_is_this_machine)===!0}function tb({info:e,onCopy:t,onOpen:s,opening:o}){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:t,children:i.jsx(ie,{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."}),eb(e)?i.jsxs("button",{className:"code-subtle-button",onClick:s,disabled:o,children:[i.jsx(ie,{name:"terminal",size:13}),i.jsx("span",{children:o?"Opening…":"Open folder"})]}):null]})}function Kh(e,t){return typeof e.size_bytes!="number"?null:fm({name:e.name,size:e.size_bytes},t)}function nb(e,t){return t?t.status==="refused"?`Not attached: ${t.message||"refused by the gateway's attachment policy"}`:`${e} is uploading; its chip in the message box shows when it is attached.`:`${e} was not queued for upload.`}function hm(e){const t=e.headers.get("content-range"),s=t?Number(t.split("/")[1]):NaN;if(Number.isFinite(s))return s;const o=Number(e.headers.get("content-length"));return e.status===200&&Number.isFinite(o)&&e.headers.has("content-length")?o:void 0}async function rb(e,t,s){var g;const o=new TextDecoder;let l="",u=0;const d=(g=e.body)==null?void 0:g.getReader();if(d){for(;u<t;){const{done:y,value:v}=await d.read();if(y)break;const x=v.subarray(0,t-u);u+=x.length,l+=o.decode(x,{stream:!0})}await d.cancel().catch(()=>{})}const f=hm(e)??s,h=f!==void 0?f>u:u>=t;return{text:l,received:u,total:f,partial:h}}function sb(e){return`Showing the first ${Yx} of ${e!==void 0?nm(e):"a file of unknown size"}; download for the rest.`}function ib(e,t,s){const o=Se(`runs/${encodeURIComponent(t)}/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(ob(y));return g.length?Io(t,g.join("/")):null},d=h=>{let g="",y=0;for(;y<h.length;){if(h[y]==="!"&&h[y+1]==="["){const v=h.indexOf("]",y+2);if(v!==-1&&h[v+1]==="("){const x=h.indexOf(")",v+2);if(x!==-1){const b=h.slice(y+2,v),k=h.slice(v+2,x).trim(),E=k.startsWith(o)?k:u(k);g+=E?``:`[image: ${b||k}](${k})`,y=x+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 ob(e){try{return decodeURIComponent(e)}catch{return e}}function ab({entry:e,url:t,state:s,onAttach:o,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:t,download:e.name,children:"Download"}),i.jsx("button",{className:"code-text-button",onClick:o,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:sb(s.total)}):null,s.kind==="image"?i.jsx("img",{className:"code-file-preview-image",src:t,alt:e.name}):s.kind==="markdown"?i.jsx(Wp,{text:s.text||""}):s.kind==="json"?i.jsx(lb,{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 lb({text:e}){try{return i.jsx(Is,{value:JSON.parse(e),collapseAfterDepth:2})}catch(t){return i.jsxs(i.Fragment,{children:[i.jsxs("p",{className:"code-field-help",children:["Not valid JSON (",St(t),"); shown as text."]}),i.jsx("pre",{className:"code-file-preview-text",children:e})]})}}function cb({runId:e,enabled:t,refreshKey:s,maxAttachmentBytes:o,onAttachFiles:l,heading:u="Conversation workspace"}){const[d,f]=w.useState(null),[h,g]=w.useState(""),[y,v]=w.useState(0),[x,b]=w.useState(""),[k,E]=w.useState(!1),[S,T]=w.useState(null),[A,$]=w.useState({status:"idle"}),[j,P]=w.useState(!1),V=w.useCallback(L=>T(L),[]);if(w.useEffect(()=>{T(null)},[e]),w.useEffect(()=>{if(f(null),g(""),!t||!e)return;const L=new AbortController;return ht(Gh(e),{signal:L.signal}).then(de=>f(de)).catch(de=>{L.signal.aborted||g(St(de))}),()=>L.abort()},[t,e,y]),w.useEffect(()=>{if(!S||!e){$({status:"idle"});return}if(Hh(S.name)==="image"){$({status:"ready",kind:"image",partial:!1});return}const de=new AbortController;return $({status:"loading"}),fetch(Io(e,S.path),{credentials:"same-origin",signal:de.signal,headers:{Range:`bytes=0-${Vh-1}`}}).then(async re=>{var J;if(!re.ok)throw new Error(`Preview failed (${re.status}): ${await re.text()||re.statusText}`);const Q=Hh(S.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 rb(re,Vh,S.size_bytes);$({status:"ready",kind:Q,text:Q==="markdown"?ib(U.text,e,S.path):U.text,partial:U.partial,total:U.total})}).catch(re=>{de.signal.aborted||$({status:"error",message:St(re)})}),()=>de.abort()},[e,S,s]),!e)return i.jsxs("div",{className:"code-pane-empty",children:[i.jsx(ie,{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(!S)return;b("");const L=Kh(S,o);if(L){b(`Not attached: ${L}`);return}P(!0);try{const de=new AbortController,re=await fetch(Io(e,S.path),{credentials:"same-origin",signal:de.signal});if(!re.ok)throw new Error(`Could not read ${S.name} (${re.status}): ${await re.text()}`);const Q=Kh({...S,size_bytes:hm(re)},o);if(Q){de.abort(),b(`Not attached: ${Q}`);return}const U=await re.blob(),[J]=l([new File([U],S.name,{type:U.type})]);b(nb(S.name,J))}catch(de){b(St(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:()=>v(L=>L+1),children:"Retry"})]}):null,d?i.jsx(tb,{info:d,opening:k,onCopy:()=>{Vx(d.workspace_root).then(L=>b(L?"Path copied.":"Could not copy; select the path instead."))},onOpen:()=>{E(!0),b(""),ht(`${Gh(e)}/open`,{method:"POST"}).then(()=>b("Folder opened on this machine.")).catch(L=>b(`Open folder failed: ${St(L)}`)).finally(()=>E(!1))}}):null,x?i.jsx("p",{className:"code-field-help",role:"status",children:x}):null,t?i.jsx(sm,{fetchGateway:vu,runId:e,title:u,onSelectFile:V,selectedPath:S==null?void 0:S.path,refreshKey:`${s??""}:${y}`,className:"code-workspace-browser"},e):null,S?i.jsx(ab,{entry:S,url:Io(e,S.path),state:A,attaching:j,onAttach:()=>void H()}):null]})}const ub=new Set(["abstract.progress","abstractcode.progress"]);function Ni(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Rs(e){const t=typeof e=="number"?e:Number(e);return Number.isFinite(t)?t:null}function db(e){if(!Ni(e))return null;const t=Ni(e.effect)?e.effect:null;if(!t||String(t.type||"")!=="emit_event")return null;const s=Ni(t.payload)?t.payload:null,o=String((s==null?void 0:s.name)??(s==null?void 0:s.event_name)??"").trim();if(!ub.has(o))return null;const l=Ni(e.result)?e.result:null,u=Ni(l==null?void 0:l.payload)?l==null?void 0:l.payload:null,d=Ni(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 fb(e){let t=null;for(const s of e||[]){const o=db(s);o&&(t=o)}return!t||t.phase==="complete"||t.final===!0?null:t}function Ai(e){return Math.round(e).toLocaleString()}function pm(e){if(!e||e.phase!=="prefill")return null;const t=Rs(e.prompt_tokens),s=Rs(e.prefill_processed_tokens);if(t===null||t<=0||s===null||s<0)return null;const o=Math.min(s,t),l=Math.min(99,Math.round(o/t*100));return{processed:o,total:t,percent:l}}function mm(e){return`${Ai(e.processed)} / ${Ai(e.total)} tokens (${e.percent}%)`}function hb(e){if(!e)return"";if(e.phase==="prefill"){const t=pm(e);if(t)return`Prefill · ${mm(t)}`;const s=Rs(e.prompt_tokens);if(s===null||s<=0)return"Prefill";const o=Rs(e.cached_tokens),l=Rs(e.fed_tokens),u=[];o!==null&&o>0&&u.push(`${Ai(o)} cached`),l!==null&&l>0&&u.push(`${Ai(l)} new`);const d=u.length?` (${u.join(", ")})`:"";return`Prefill · ${Ai(s)} tokens${d}`}if(e.phase==="generate"){const t=Rs(e.generated_tokens)??0,s=Math.round(t)===1?"token":"tokens",o=Rs(e.tokens_per_second),l=o!==null&&o>0?` · ${Math.round(o)} tok/s`:"";return`Generating · ${Ai(t)} ${s}${l}`}return""}function pb(e){return hb(fb(e))}const gm=new Set(["abstract.progress","abstractcode.progress"]),mb=new Set(["abstract.status","abstractcode.status"]);function Me(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Du(e){const t=Me(e);return!!(t&&t.$slim)}function ft(e){const t=typeof e=="number"?e:Number(e);return Number.isFinite(t)?t:null}function sn(e){return Math.round(e).toLocaleString("en-US")}function $t(e,t=120){const s=e.replace(/\s+/g," ").trim();return s.length>t?`${s.slice(0,t-1)}…`:s}function Ro(e,t=120){var l,u;if(e==null)return"";if(typeof e=="string")return $t(e,t);if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return $t(e.length===0?"[]":`${e.length} ${e.length===1?"item":"items"}`,t);const s=Me(e);if(!s)return"";if(Du(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?` · ${sn(f)} bytes`:""}`}const o=[];for(const[d,f]of Object.entries(s)){const h=typeof f=="string"?$t(f,60):typeof f=="number"||typeof f=="boolean"?String(f):Array.isArray(f)?`${f.length} items`:f==null?"":"{…}";if(h&&(o.push(`${d.replace(/_/g," ")} ${h}`),o.join(" · ").length>=t))break}return $t(o.join(" · "),t)}function ll(e){return`${e>=100?String(Math.round(e)):e.toFixed(e<1?2:1).replace(/\.0+$/,"")} s`}function ym(e,t){const s=Date.parse(String(e||"")),o=Date.parse(String(t||""));if(!Number.isFinite(s)||!Number.isFinite(o))return null;const l=(o-s)/1e3;return l>=0?l:null}function gb(e){const t=String(e||""),s=/T(\d{2}:\d{2}:\d{2})/.exec(t);return s?s[1]:""}function wm(e){const t=String(e||"").trim();if(!t)return"";const s=t.split("/").pop()||t;return s.length>48?`${s.slice(0,47)}…`:s}function At(e,t=" · "){return e.filter(s=>!!s).join(t)}const Jh="visual_react_agent_";function yb(e){if(!/^[A-Za-z0-9_-]{8,}$/.test(e))return null;try{const t=e.replace(/-/g,"+").replace(/_/g,"/"),s=atob(t+"=".repeat((4-t.length%4)%4));return!/^[ -~]{3,}$/.test(s)||!/[a-z]/i.test(s)?null:s}catch{return null}}function wb(e){const t=String(e||"").trim();if(!t)return{name:"",node:""};const s=/^([^@]+)@([^:]+)(?::(.+))?$/.exec(t);if(s)return{name:s[1],node:s[3]||""};if(t.startsWith(Jh)){const o=t.slice(Jh.length),l=/^(.*)_(\d+)_(\d+)_(\d+)_([0-9a-f]{6,12})_(.+)$/.exec(o);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=yb(d[f]);if(h&&h.length>3){u=h;break}}}return{name:u,node:l[6]}}return{name:o,node:""}}return{name:t,node:""}}function vb(e){var s;if(!Array.isArray(e)||!e.length)return"";const t=new Map;for(const o of e){const l=String(((s=Me(o))==null?void 0:s.name)||"").trim()||"tool";t.set(l,(t.get(l)||0)+1)}return[...t.entries()].map(([o,l])=>l>1?`${o} ×${l}`:o).join(", ")}function _b(e){var f;const t=Me(e);if(!t)return null;const s=Me(t.effect);if(!s||String(s.type||"")!=="emit_event")return null;const o=Me(s.payload),l=String((o==null?void 0:o.name)??(o==null?void 0:o.event_name)??"").trim();if(!gm.has(l))return null;const u=Me((f=Me(t.result))==null?void 0:f.payload),d=Me(o==null?void 0:o.payload);return u||d}function xb(e){if(!e.length)return"";const t=e[e.length-1];let s=null,o=null,l=null,u=null,d=null;for(const y of e)s=ft(y.prompt_tokens)??s,o=ft(y.cached_tokens)??o,l=ft(y.generated_tokens)??l,u=ft(y.tokens_per_second)??u,d=ft(y.elapsed_s)??d;if(t.final===!0||String(t.phase||"")==="complete")return At([s!==null?`${sn(s)} tokens in`:null,o!==null&&o>0?`${sn(o)} cached`:null,l!==null?`${sn(l)} out`:null,d!==null?ll(d):null,u!==null&&u>0?`${Math.round(u)} tok/s`:null]);const h=s!==null?`prefill ${sn(s)} tokens${o!==null&&o>0?` (${sn(o)} cached)`:""}`:"prefill";if(String(t.phase||"")==="prefill"){const y=pm(t);return y?`prefill ${mm(y)}`:h}const g=At([`generating ${sn(l??0)} ${Math.round(l??0)===1?"token":"tokens"}`,u!==null&&u>0?`${Math.round(u)} tok/s`:null]);return`${h} → ${g}`}function bb(e){if(!e.length)return"";const t=e[e.length-1],s=ft(t.step)??ft(t.index),o=ft(t.total)??ft(t.steps),l=ft(t.percent)??ft(t.progress),u=ft(t.frame),d=ft(t.elapsed_s);return At([typeof t.label=="string"?$t(t.label,60):null,typeof t.phase=="string"&&!t.label?$t(t.phase,40):null,s!==null?`step ${sn(s)}${o!==null?`/${sn(o)}`:""}`:null,u!==null?`frame ${sn(u)}`:null,l!==null?`${Math.round(l<=1?l*100:l)}%`:null,d!==null?ll(d):null])}function Qh(e){return e.length?String(e[e.length-1].kind||"")==="llm"?xb(e):bb(e):""}function kb(e,t,s){var T;const o=String(e.provider||"").trim(),l=wm(e.model||(t==null?void 0:t.model)),u=At(["llm",o,l])||"llm call";if(!t){const A=Me(e.params)||{};return{title:u,detail:At([ft(A.temperature)!==null?`temperature ${A.temperature}`:null,A.thinking?`thinking ${A.thinking}`:null,(T=Me(A.speculation))!=null&&T.mode?`speculation ${Me(A.speculation).mode}`:null])}}const d=Me(t.usage)||{},f=Me(t.metadata)||{},h=Me(f.prompt_cache)||{},g=Me(f.performance)||{},y=ft(d.prompt_tokens)??ft(d.input_tokens),v=ft(d.completion_tokens)??ft(d.output_tokens),x=ft(h.cached_tokens),b=String(h.outcome||"").trim(),k=ym(s.started_at,s.ended_at),E=ft(g.generation_tokens_per_second),S=Array.isArray(t.tool_calls)?t.tool_calls.length:0;return{title:u,detail:At([y!==null?`${sn(y)} tokens in`:null,x!==null&&x>0?`${sn(x)} cached`:b?`${b} cache`:null,v!==null?`${sn(v)} out`:null,k!==null?ll(k):null,E!==null&&E>0?`${Math.round(E)} tok/s`:null,S?`${S} tool ${S===1?"call":"calls"}`:null])}}function jb(e,t){if(t.length<=60)return $t(t,60);if(e==="url")try{const s=new URL(t),o=s.pathname.split("/").filter(Boolean).pop()||"";return $t(`${s.host}${o?` · …/${o}`:""}`,72)}catch{}if(e==="file path"||e==="path"){const s=t.split(/[\\/]/).pop()||t;return $t(`${s} · ${t.slice(0,24)}…`,60)}return $t(t,60)}function Sb(e,t){const s=Array.isArray(e.tool_calls)?e.tool_calls:[],o=vb(s),l=Me(s[0]),u=l?Vp(l.arguments):{label:"",value:""},d=Array.isArray(t==null?void 0:t.results)?t.results:[],f=d.filter(g=>{var y;return((y=Me(g))==null?void 0:y.success)===!0}).length,h=d.length-f;return{title:At(["tools",o||"tool call"]),detail:At([u.value?`${u.label} ${jb(u.label,u.value)}`:null,d.length?`${f} ok`:null,h>0?`${h} failed`:null])}}function Nb(e,t){var g,y;const{name:s,node:o}=wb(e.workflow_id),l=Me(e.vars),u=l&&!Du(l)?l:null,d=Me(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=Me((g=Me(t==null?void 0:t.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:At([$t(u.state,80),h&&`run ${h}`])}:f?{title:"subflow · agent loop",detail:At([s,$t(f,90),h&&`run ${h}`])}:{title:At(["subflow",s||"workflow"]),detail:At([o,u?Ro(u,80):null,h&&`run ${h}`])}}function Cb(e,t){const s=e.until,o=ym(t.started_at,s),l=gb(s);return{title:o!==null?`wait · delay ${ll(o)}`:`wait · until ${l}`,detail:At([o!==null&&l?`until ${l}`:null,e.resume_to_node?`resumes at ${e.resume_to_node}`:null])}}function Yh(e){var f;const t=Me(e)||{},s=Me(t.effect),o=String((s==null?void 0:s.type)||"").trim(),l=Me(s==null?void 0:s.payload)||{},u=Me(t.result);if(o==="emit_event"){const h=String(l.name??l.event_name??"").trim();if(gm.has(h))return{kind:"progress",title:"progress",detail:"",isProgress:!0,isStatus:!1,isResume:!1,hidden:!0};if(mb.has(h))return{kind:"event",title:"status",detail:Ro(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:Ro(l.payload??(u==null?void 0:u.payload),110),isProgress:!1,isStatus:!1,isResume:!1,hidden:!1}}if(o==="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(o==="llm_call")return{kind:"llm",...kb(l,u,t),...d};if(o==="tool_calls")return{kind:"tools",...Sb(l,u),...d};if(o==="start_subworkflow")return{kind:"subflow",...Nb(l,u),...d};if(o==="wait_until")return{kind:"wait",...Cb(l,t),...d};if(o==="wait_event")return{kind:"wait",title:"wait · event",detail:At([typeof l.prompt=="string"?$t(l.prompt,90):null,!l.prompt&&l.wait_key?$t(String(l.wait_key),70):null]),...d};if(o==="ask_user")return{kind:"ask",title:"ask · your input",detail:$t(String(l.prompt||((f=Me(u==null?void 0:u.wait))==null?void 0:f.prompt)||"").split(`
|
|
70
|
-
`)[0],110),...d};if(o==="answer_user")return{kind:"message",title:"message",detail:$t(String(l.message||""),110),...d};if(!o){if((u==null?void 0:u.completed)===!0){const h=Me(u.output)||{},g=Me(h.stop_reason)||{},y=ft(h.iterations),v=At([String(g.code||h.outcome||"").replace(/_/g," ")||null,y!==null?`${sn(y)} ${y===1?"iteration":"iterations"}`:null]),x=[h.answer,h.response,h.result].find(b=>typeof b=="string"&&b.trim());return{kind:"run",title:"run finished",detail:v||(typeof x=="string"?$t(x,110):Ro(h,110)),...d}}return{kind:"step",title:String(t.node_id||"workflow step"),detail:"",...d}}return{kind:"step",title:o.replace(/_/g," "),detail:Ro(l,110),...d}}function Eb(e,t,s){var u,d;const o=Me(e)||{},l=String(o.status||"").trim();if(o.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=Me((u=Me(o.result))==null?void 0:u.wait);return String(((d=Me(f==null?void 0:f.details))==null?void 0:d.mode)||"")==="approval_required"?{status:"waiting",statusLabel:"approval needed"}:t==="subflow"?{status:"waiting",statusLabel:"waiting for subflow"}:t==="ask"?{status:"waiting",statusLabel:"waiting for you"}:t==="wait"?{status:"waiting",statusLabel:String((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 $b(e){var l;const t=Me(e.record)||{},s=String(((l=Me(t.effect))==null?void 0:l.type)||"(none)"),o=String(t.idempotency_key||t.step_id||e.cursor);return`${e.runId}|${s}|${o}|${t.attempt??1}`}function Ab(e){var h;const t=e.map(g=>Me(g.record)||{}),s=t[t.length-1]||{},o={};for(const g of t){const y=Me((h=Me(g.effect))==null?void 0:h.payload);if(y)for(const[v,x]of Object.entries(y))Du(x)&&v in o||(o[v]=x)}let l=null,u=null,d=null,f=null;for(const g of t)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:o}:s.effect,result:l,error:u,started_at:d,ended_at:f}}function Tb(e){var s,o;const t=[];for(const l of e){const u=Me((o=Me((s=Me(l.record))==null?void 0:s.result))==null?void 0:o.wait),d=String((u==null?void 0:u.wait_key)||"").trim();d&&t.push(d)}return t}function Rb(e,t){return`${e}|${String(t.step_id||t.node_id||"")}`}function Ib(e,t){const s=new Map;for(const u of t){const d=_b(u.record);if(!d)continue;const f=Rb(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 o=new Set,l=e.map(u=>{const d=u.stepIds.map(b=>`${u.runId}|${b}`).filter(b=>s.has(b));if(!d.length)return{...u};const f=[],h=[];for(const b of d)o.add(b),f.push(...s.get(b).payloads),h.push(...s.get(b).entries);const g=Qh(f),y=f[f.length-1],v=y.final===!0||String(y.phase||"")==="complete",x=!(v&&u.status==="completed"&&u.detail);return{...u,progress:x?g:"",progressFinal:v,progressEvents:h.map(b=>Me(b.record)||{})}});for(const[u,d]of s.entries()){if(o.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:At(g==="llm"?["llm",String(h.provider||""),wm(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:Qh(f),progressFinal:h.final===!0||String(h.phase||"")==="complete",entries:d.entries,progressEvents:d.entries.map(v=>Me(v.record)||{}),merged:Me(d.entries[d.entries.length-1].record)||{}})}return l}function Mb(e){var f,h,g;const t=new Map,s=[],o=[],l=[];for(const y of e||[]){const v=Yh(y.record);if(v.isProgress){l.push(y);continue}if(v.isStatus)continue;if(v.isResume){const b=String(((g=(h=Me((f=Me(y.record))==null?void 0:f.effect))==null?void 0:h.payload)==null?void 0:g.wait_key)||"").trim();b&&o.push(b);continue}const x=$b(y);t.has(x)||(t.set(x,[]),s.push(x)),t.get(x).push(y)}const u=new Set(o),d=s.map(y=>{const v=t.get(y),x=Ab(v),b=Yh(x),k=Tb(v).some(S=>u.has(S)),E=Eb(x,b.kind,k);return{key:y,runId:v[0].runId,cursor:v[v.length-1].cursor,kind:b.kind,title:b.title,detail:b.detail,status:E.status,statusLabel:E.statusLabel,nodeId:String(x.node_id||""),stepIds:[...new Set(v.map(S=>{var T;return String(((T=Me(S.record))==null?void 0:T.step_id)||"")}).filter(Boolean))],progress:"",progressFinal:!1,entries:v,progressEvents:[],merged:x}});return Ib(d,l)}function Lb({tab:e,onTab:t,policy:s,runId:o,records:l,enabled:u,isAdmin:d,refreshKey:f,onAttach:h,onAttachFiles:g,onClose:y}){const[v,x]=w.useState("session"),b=w.useMemo(()=>Mb(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(ie,{name:"x",size:15})})]}),i.jsx("div",{className:"code-inspector-tabs",role:"tablist","aria-label":"Workspace views",onKeyDown:Ou,children:["files","activity","artifacts"].map(k=>i.jsxs("button",{id:`inspector-tab-${k}`,role:"tab",tabIndex:e===k?0:-1,"aria-selected":e===k,"aria-controls":`inspector-panel-${k}`,onClick:()=>t(k),children:[k==="files"?"Files":k==="activity"?"Activity":"Artifacts",k==="activity"&&b.length?i.jsx("span",{children:b.length}):null]},k))}),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":v==="session",onClick:()=>x("session"),children:"This conversation"}),i.jsx("button",{"aria-pressed":v==="shared",onClick:()=>x("shared"),children:"Shared workspace (admin)"})]}):null,d&&v==="shared"?i.jsx(Pb,{policy:s,enabled:u,runId:o,onAttach:h}):i.jsx(cb,{runId:o,enabled:u,refreshKey:f,maxAttachmentBytes:s==null?void 0:s.maxAttachmentBytes,onAttachFiles:g})]}):e==="activity"?i.jsx(Db,{rows:b}):i.jsx(Fb,{runId:o,enabled:u})}),i.jsxs("div",{className:"code-inspector-foot",children:[i.jsx(ie,{name:"server",size:14}),i.jsx("span",{children:"Access enforced by your gateway"})]})]})}function Pb({policy:e,enabled:t,runId:s,onAttach:o}){const[l,u]=w.useState(""),[d,f]=w.useState(""),[h,g]=w.useState([]),[y,v]=w.useState(!1),[x,b]=w.useState(""),[k,E]=w.useState(""),[S,T]=w.useState(0),[A,$]=w.useState("");return w.useEffect(()=>{const j=new AbortController;if(g([]),b(""),E(""),!t||!e)return;v(!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:j.signal}).then(H=>{if(H.error)throw new Error(String(H.error));g(Array.isArray(H.items)?H.items:[]),(H.truncated||H.has_more)&&E("Showing the first 100 results. Search to narrow the list.")}).catch(H=>{j.signal.aborted||b(St(H))}).finally(()=>{j.signal.aborted||v(!1)})},l?220:0);return()=>{window.clearTimeout(P),j.abort()}},[t,e,l,d,S,s]),i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"code-pane-intro",children:[i.jsx(ie,{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(j=>j+1),disabled:!t,children:i.jsx(ie,{name:"refresh",size:14})})]}),i.jsx("input",{className:"code-search","aria-label":"Search workspace files",placeholder:"Search files…",value:l,onChange:j=>u(j.target.value),disabled:!t}),d?i.jsx("button",{className:"code-back",onClick:()=>{f(d.split("/").slice(0,-1).join("/")),u("")},children:"← Parent folder"}):null,t?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,x?i.jsxs("div",{className:"code-inline-error",role:"alert",children:[x,i.jsx("button",{onClick:()=>T(j=>j+1),children:"Retry"})]}):null,k?i.jsx("p",{className:"code-field-help",role:"status",children:k}):null,i.jsx("ul",{className:"code-file-list",children:h.map(j=>{const P=j.kind==="folder"||j.is_dir||j.type==="directory"||j.type==="dir";return i.jsx("li",{children:i.jsxs("button",{title:P?`Open ${j.path}`:`Attach ${j.path} to the conversation`,disabled:!!A,onClick:async()=>{if(P){f(j.path),u("");return}$(j.path),b("");try{await o(j.path),E(`${j.name||j.path} attached.`)}catch(V){b(St(V))}finally{$("")}},children:[i.jsx(ie,{name:P?"chevronRight":"edit",size:14}),i.jsx("span",{children:j.name||j.path}),A===j.path?i.jsx(ie,{name:"loader",size:13}):i.jsx("span",{className:"code-file-action",children:P?"Open":"+"})]})},j.path)})}),!y&&!x&&t&&!h.length?i.jsxs("div",{className:"code-pane-empty",children:[i.jsx(ie,{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 Ob={llm:"sparkle",tools:"terminal",subflow:"agent",event:"info",wait:"history",ask:"chat",message:"send",run:"playCircle",progress:"loader",step:"list"};function Db({rows:e}){return e.length?i.jsx("div",{className:"code-activity",children:e.map(t=>{const s=t.merged,o=s.effect||{};return i.jsxs("details",{className:`code-activity-row code-activity-row--${t.kind}`,children:[i.jsxs("summary",{children:[i.jsx("span",{className:"code-activity-icon","aria-hidden":"true",children:i.jsx(ie,{name:Ob[t.kind],size:14})}),i.jsxs("span",{className:"code-activity-text",children:[i.jsx("span",{className:"code-activity-title",children:t.title}),t.detail?i.jsx("span",{className:"code-activity-sub",children:t.detail}):null,t.progress?i.jsx("span",{className:"code-activity-progress",children:t.progress}):null]}),i.jsx("span",{className:`code-step-dot is-${t.status}`}),i.jsx("small",{children:t.statusLabel})]}),i.jsxs("div",{className:"code-activity-detail",children:[i.jsxs("div",{className:"code-field-help",children:[t.nodeId?`${t.nodeId} · `:"","run ",t.runId.slice(0,8)," ","· ",t.entries.length," ",t.entries.length===1?"record":"records",t.progressEvents.length?` · ${t.progressEvents.length} progress`:""]}),i.jsx(Is,{value:{input:o.payload,result:s.result,error:s.error,records:t.entries.map(l=>l.record),...t.progressEvents.length?{progress:t.progressEvents}:{}},collapseAfterDepth:2})]})]},t.key)})}):i.jsxs("div",{className:"code-pane-empty",children:[i.jsx(ie,{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 Fb({runId:e,enabled:t}){const[s,o]=w.useState([]),[l,u]=w.useState(""),[d,f]=w.useState(0);return w.useEffect(()=>{if(o([]),u(""),!e||!t)return;const h=new AbortController;return ht(Se(`runs/${encodeURIComponent(e)}/artifacts?limit=200`),{signal:h.signal}).then(g=>o(Array.isArray(g.items)?g.items:Array.isArray(g.artifacts)?g.artifacts:[])).catch(g=>{h.signal.aborted||u(St(g))}),()=>h.abort()},[e,t,d]),i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"code-pane-intro",children:[i.jsx(ie,{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(ie,{name:"refresh",size:14})})]}),l?i.jsx("p",{role:"alert",className:"code-error-text",children:l}):null,s.map(h=>{var v;const g=h.artifact_id||h.id,y=h.filename||((v=h.metadata)==null?void 0:v.filename)||g;return i.jsxs("button",{className:"code-artifact",onClick:()=>{ox(e,g,y).catch(x=>u(St(x)))},children:[i.jsx(ie,{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(ie,{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 zb=[["Gateway","checking…"]];function Wb(e){return e?e.ok?uh(e.value):uh(null,e.status?`HTTP ${e.status}`:e.message):zb}const Ub=3e4,Ha=50;function Bb(){return ew({fetch:(e,t)=>fetch(e,{...t,credentials:"same-origin"}),baseUrl:"",headers:lm})}function Vb(e){const t=String(e||"").trim();if(!t)return null;try{const s=new URL(t);return s.protocol!=="http:"&&s.protocol!=="https:"?null:`${s.origin}${s.pathname.replace(/\/+$/,"")}/console#users`}catch{return null}}function Gb(e){var s;const t=(s=e==null?void 0:e.common)==null?void 0:s.automations;return t&&typeof t=="object"&&t.available===!0?{available:!0,reason:""}:t&&typeof t=="object"&&t.available===!1?{available:!1,reason:"This gateway has the Automations API turned off."}:{available:!1,reason:"This gateway does not advertise the Automations API (capabilities.contracts.common.automations). Update AbstractGateway (0.6.0 or later) to use automations."}}function Hb(e,t){return e===En?{flow_id:"@default",interface:Ti}:!(t!=null&&t.bundleId)||!t.flowId?null:{bundle_ref:t.bundleVersion?`${t.bundleId}@${t.bundleVersion}`:t.bundleId,flow_id:t.flowId}}function Kb(e,t=Date.now()){const s=e.attention.unseen_count>0||e.attention.pending_waits>0;return{id:e.automation_id,title:e.title,cadence:ku(e.trigger),current:_p(e),next:e.next_fire_at?`${Cr(e.next_fire_at)} (${xp(e.next_fire_at,t)})`:e.status==="paused"?"none while paused":"none scheduled",attention:s?bp(e):null,legacy:e.legacy===!0||e.capabilities.includes("legacy")}}function Jb(e,t){return t?e:e.filter(s=>s.status!=="archived")}function Qb(e,t){if(e==="ask_user"){if(typeof t.response!="string")throw new Error("An ask_user wait is answered with {response: string}.");return{response:t.response}}if(e==="tool_approval"){if(typeof t.approved!="boolean")throw new Error("A tool_approval wait is answered with {approved: true|false}.");return{approved:t.approved}}if(e==="event"){if(!("payload"in t))throw new Error("An event wait is answered with {payload}.");return{payload:t.payload}}throw new Error(`This wait has no known kind (${JSON.stringify(e)}); open its run to answer it.`)}function Yb(e,t,s,o){return{command_id:e,run_id:t,type:"resume",payload:{wait_key:s,payload:o},client_id:"abstractcode-web"}}function vm(e,t){return`Discussion forked from run #${e}. It works in its own workspace ${t.workspace_root}; the automation's files are mounted read-only at ${t.mounted_workspace} for the file tools (shell commands are not sandboxed), and nothing is written back into the automation's session.`}function Sr(e){return $u(e)?e:{status:0,code:"client_error",message:e&&typeof e=="object"&&"message"in e?String(e.message):String(e)}}function nu(e,t){const s=new Map;for(const o of e)s.set(o.run_id,o);for(const o of t)s.set(o.run_id,o);return Array.from(s.values()).sort((o,l)=>l.index-o.index)}const Xb={items:[],loaded:!1,loading:!1,listError:null,error:null,showArchived:!1,selectedId:"",detail:null,triggerSources:[],busy:!1,notice:"",emailStatus:null};function Zb(e){return async(t,s,o)=>{await ht(Se("commands"),{method:"POST",body:JSON.stringify(Yb(e(),t,s,o))})}}class qb{constructor(t,s,o=[1500,4e3]){mn(this,"state",{...Xb});mn(this,"listeners",new Set);mn(this,"listSeq",0);mn(this,"detailSeq",0);mn(this,"sourcesLoaded",!1);this.client=t,this.answerWaitVia=s,this.followupsMs=o}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}set(t){this.state={...this.state,...t};for(const s of this.listeners)s()}async listAll(){const t=[];let s;for(let o=0;o<200;o+=1){const l=await this.client.listAutomations({...s?{cursor:s}:{},limit:Ha});if(t.push(...l.items),!l.next_cursor)return t;s=l.next_cursor}throw new Error("GET /api/gateway/automations kept returning next_cursor after 200 pages.")}async loadEmailStatus(){try{const t=await this.client.getMyEmail();this.set({emailStatus:t&&typeof t=="object"?t:null})}catch{this.set({emailStatus:null})}}async refresh(){const t=++this.listSeq;this.set({loading:!0});try{const s=await this.listAll();if(this.loadEmailStatus(),t!==this.listSeq)return;const o=this.state.detail,l=o?s.find(u=>u.automation_id===o.automationId):void 0;this.set({items:s,loaded:!0,loading:!1,listError:null,...o&&l?{detail:{...o,summary:l}}:{}}),o&&await this.reloadDetail(o.automationId)}catch(s){if(t!==this.listSeq)return;this.set({loading:!1,loaded:!0,listError:Sr(s)})}}setShowArchived(t){this.set({showArchived:t})}async select(t){var l;const s=t.trim(),o=++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:Ha})]);if(o!==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:nu([],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(o!==this.detailSeq)return;this.set({error:Sr(u)})}}async reloadDetail(t){const[s,o]=await Promise.all([this.client.getAutomation(t),this.client.listOccurrences(t,{limit:Ha})]),l=this.state.detail;if(!l||l.automationId!==t)return;const u=this.state.items.find(d=>d.automation_id===t);this.set({detail:{...l,summary:u??s.summary,definition:s.definition,occurrences:nu(l.occurrences,o.items),nextCursor:l.occurrences.length>o.items.length?l.nextCursor:o.next_cursor}})}async loadMore(){const t=this.state.detail;if(!(!t||!t.nextCursor))try{const s=await this.client.listOccurrences(t.automationId,{cursor:t.nextCursor,limit:Ha}),o=this.state.detail;if(!o||o.automationId!==t.automationId)return;this.set({detail:{...o,occurrences:nu(o.occurrences,s.items),nextCursor:s.next_cursor}})}catch(s){this.set({error:Sr(s)})}}async afterChange(){await this.refresh();for(const t of this.followupsMs)setTimeout(()=>void this.refresh(),t)}async busyCall(t){this.set({busy:!0});try{const s=await t();return await this.afterChange(),s}catch(s){throw Sr(s)}finally{this.set({busy:!1})}}command(t,s,o){return this.busyCall(()=>this.client.sendAutomationCommand(t,{type:s,...o?{command_id:o}:{}}))}revise(t,s,o,l){return this.busyCall(()=>this.client.reviseAutomation(t,{changes:s,...o!==null?{expected_revision:o}:{},...l?{command_id:l}:{}}))}async create(t){this.set({busy:!0,error:null});try{const s=await this.client.createAutomation(t);this.set({notice:`Automation created: ${s.summary.title}.`}),await this.refresh(),await this.select(s.automation_id);for(const o of this.followupsMs)setTimeout(()=>void this.refresh(),o);return s}catch(s){throw Sr(s)}finally{this.set({busy:!1})}}async discuss(t,s,o,l){this.set({busy:!0});try{const u=await this.client.discuss(t,{occurrence_index:s,prompt:o,...l?{request_id:l}:{}});return this.set({notice:vm(s,u)}),u}catch(u){throw Sr(u)}finally{this.set({busy:!1})}}async seen(t,s){try{await this.client.markSeen(t,s)}catch(o){throw Sr(o)}}answerWait(t,s,o){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===t&&d.wait_key===s);if(!l)throw new Error(`No loaded wait ${s} on run ${t}; reload the automation.`);await this.answerWaitVia(t,s,Qb(l.kind,o))})}rowControls(t){return el(t,[],this.state.busy)}reportError(t){this.set({error:Sr(t)})}clearNotice(){this.set({notice:"",error:null})}}function ek(e,t){const s=w.useMemo(()=>new qb(Bb(),Zb(es)),[e]),o=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||!t||!l)return;s.refresh();const d=window.setInterval(()=>void s.refresh(),Ub);return()=>window.clearInterval(d)},[s,e,t,l]),{ctl:s,state:o}}function _m({error:e}){if(!e)return null;const t=Eu(e);return i.jsxs("p",{className:"code-inline-error",role:"alert","data-code":e.code,children:[i.jsx("strong",{children:t.title})," ",t.detail]})}function tk(e){const t=e.open??!0,s=Au("automations"),o=e.state,l=Jb(o.items,o.showArchived),u=o.items.filter(f=>f.status==="archived").length,d=o.items.reduce((f,h)=>f+h.attention.pending_waits+h.attention.unseen_count,0);return i.jsxs("section",{className:"code-panel code-automations","aria-label":"Automations","data-open":t?"true":"false","data-fill":t&&e.fill?"true":void 0,children:[i.jsx(Rp,{panel:"automations",open:t,onToggle:()=>{var f;return(f=e.onToggle)==null?void 0:f.call(e)},label:i.jsxs(i.Fragment,{children:["AUTOMATIONS",d?i.jsx("span",{className:"code-auto-badge","data-field":"attention-total",children:d}):null]}),actions: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(ie,{name:"plus",size:13})}),i.jsx("button",{className:"code-icon-button","aria-label":"Refresh automations",disabled:!e.available.available||o.loading,onClick:e.onRefresh,children:i.jsx(ie,{name:"refresh",size:13})})]})}),i.jsxs("div",{className:"code-auto-rows",id:s.region,role:"region","aria-labelledby":s.toggle,hidden:!t,children:[e.available.available?null:i.jsx("p",{className:"code-history-empty",role:"note","data-unavailable":"true",children:e.available.reason}),i.jsx(_m,{error:o.listError}),e.available.available&&o.loaded&&!o.items.length?i.jsx("p",{className:"code-history-empty",children:"No automations yet. + runs the toolbar's workflow on a schedule."}):null,l.map(f=>{const h=Kb(f,e.nowMs),g=e.selectedId===f.automation_id;return i.jsxs("button",{className:`code-session code-auto-row${g?" is-selected":""}`,"aria-current":g?"page":void 0,"data-automation-id":f.automation_id,"data-status":f.status,title:`${h.title} — ${h.cadence}`,onClick:()=>e.onSelect(f.automation_id),children:[i.jsx(ie,{name:"history",size:15}),i.jsxs("span",{children:[i.jsx("strong",{children:h.title}),i.jsxs("small",{children:[i.jsx("span",{"data-field":"state",children:i.jsx(Ep,{status:f.status})})," ",h.cadence,h.legacy?" · legacy schedule":""]}),h.current?i.jsxs("small",{"data-field":"current",children:["now: ",h.current]}):null,i.jsxs("small",{"data-field":"next",children:["next: ",h.next]}),h.attention?i.jsx("small",{className:"code-auto-attention","data-field":"attention",children:h.attention}):null]})]},f.automation_id)}),u>0?i.jsxs("label",{className:"code-auto-archived",children:[i.jsx("input",{type:"checkbox","data-action":"show-archived",checked:o.showArchived,onChange:f=>e.onShowArchived(f.target.checked)})," Show archived (",u,")"]}):null]})]})}function nk(e,t){const s=e.state.detail;if(!s)return null;const o=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(o,l,u,d==null?void 0:d.command_id),onCommand:(l,u,d)=>e.command(o,l,d==null?void 0:d.command_id),onDiscuss:async(l,u,d)=>{const f=await e.discuss(o,l,u,d==null?void 0:d.request_id);return t.openConversation(f.session_id,f.run_id,vm(l,f)),f},onSeen:l=>e.seen(o,l),onLoadMore:()=>void e.loadMore(),onOpenRun:l=>t.openRun(l),onOpenWorkspace:l=>t.openWorkspace(l),onAnswerWait:(l,u,d)=>e.answerWait(l,u,d),emailStatus:e.state.emailStatus,...t.openMyEmail?{onOpenMyEmail:()=>{var l;return(l=t.openMyEmail)==null?void 0:l.call(t)}}:{}}}function rk(e){const t=e.last_occurrence,s=e.current_occurrence;return[e.occurrence_count,t?`${t.index}:${t.status}:${t.finished_at??""}`:"",s?`${s.index}:${s.status}`:""].join("|")}function sk(e,t,s){if(t===e)return"Automation folder";const o=s.find(l=>l.run_id===t);return o?`Run #${o.index} folder`:"Run folder"}function ik(e){const t=e.ctl.state,s=t.detail,[o,l]=w.useState({automationId:"",runId:""}),u=(s==null?void 0:s.automationId)??"",d=o.automationId===u&&o.runId?o.runId:u,f=nk(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(ie,{name:"chat",size:14})," ",i.jsx("span",{children:"Back to the conversation"})]}),t.notice?i.jsx("p",{className:"code-field-help",role:"status",children:t.notice}):null]}),s?i.jsxs("div",{className:"code-auto-main-body",children:[f?i.jsx(U_,{...f,fetchGateway:vu}):null,e.enabled?i.jsx(sm,{className:"code-auto-folder",fetchGateway:vu,runId:d,title:sk(s.automationId,d,s.occurrences),refreshKey:rk(s.summary),onClose:d!==s.automationId?()=>l({automationId:u,runId:""}):void 0}):null]}):t.error?i.jsx(_m,{error:t.error}):i.jsx("p",{className:"code-muted",role:"status",children:"Loading the automation…"})]})}function ok(e){const[t,s]=w.useState();return w.useEffect(()=>{e.open&&(s(void 0),e.ctl.loadEmailStatus())},[e.open]),i.jsx(Zw,{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:t,onSubmit:o=>e.ctl.create(o).then(l=>(e.onCreated(l.automation_id),e.onClose(),l),l=>{throw s(Sr(l)),l})})}function xm(e){return`abstractcode.workspace.v2:${e}`}function ak(e){try{const t=JSON.parse(e||"{}"),s=typeof t.workflow=="string"&&t.workflow.trim()?t.workflow.trim():Nr.workflow;return{...Nr,...t,workflow:s,showAllWorkflows:t.showAllWorkflows===!0,speculation:sp(t.speculation),streamReplies:gx(t.streamReplies),tools:{...Nr.tools,...t.tools}}}catch{return Nr}}function lk(e){try{return ak(localStorage.getItem(xm(e)))}catch{return Nr}}function ck(e,t){try{localStorage.setItem(xm(e),JSON.stringify(t))}catch{}}function uk(e){var h,g;const t=Object.keys(((h=e.schema)==null?void 0:h.properties)||{}),s=((g=e.schema)==null?void 0:g.required)||[],o=[e.promptProperty||"prompt","context","messages","attachments"],l=["provider","model","tools","skills","max_iterations","use_context","use_session_history"],u=cm(e.schema).map(y=>[y.provider,y.model,y.reasoning].filter(v=>!!v)),d=new Set(t.filter(y=>s.includes(y)&&!o.includes(y)));for(const y of u)y.some(v=>d.has(v))&&y.forEach(v=>d.add(v));const f=new Set(t.filter(y=>!d.has(y)&&!o.includes(y)&&!l.includes(y)));for(const y of u)y.some(v=>f.has(v))&&y.forEach(v=>f.add(v));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(_u,{...e,omit:t.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(_u,{...e,omit:t.filter(y=>!f.has(y)),rawObject:!1})]}):null]})}function dk(e,t,s){var l;if(!s.length)return t;const o=(l=e==null?void 0:e.properties)==null?void 0:l.attachments;if(!o||o.type&&o.type!=="array")throw new Error("This workflow does not declare an attachments input. Remove the attached files, or choose an agent or workflow that accepts them.");return{...t,attachments:[...Array.isArray(t.attachments)?t.attachments:[],...s]}}function fk(e){if(!e.trim())return{ok:!0,value:{}};let t;try{t=JSON.parse(e)}catch{return{ok:!1,error:"Enter valid JSON."}}return t===null||typeof t!="object"||Array.isArray(t)?{ok:!1,error:"The workflow input payload must be a JSON object."}:{ok:!0,value:t}}function _u({schema:e,values:t,onChange:s,disabled:o=!1,omit:l=[],rawObject:u=!1,onEditorError:d,defaultModel:f}){const[h,g]=gt.useState("fields"),y=Object.entries((e==null?void 0:e.properties)||{}).filter(([E])=>!l.includes(E)),v=cm(e),x=new Set(v.flatMap(E=>[E.provider,E.model,E.reasoning].filter(Boolean))),b=E=>{g(E),d==null||d("")},k=y.length?i.jsx("div",{className:"code-input-fields",children:y.map(([E,S])=>{const T={...S,type:cx(S)},A=v.find(H=>H.provider===E);if(A)return i.jsxs("section",{className:"code-settings-section",children:[i.jsx("h3",{children:A.title}),i.jsx(bu,{value:{provider:String(t[A.provider]||""),model:String(t[A.model]||""),...A.reasoning?{reasoning:String(t[A.reasoning]||"")}:{}},onChange:H=>s({...t,[A.provider]:H.provider,[A.model]:H.model,...A.reasoning?{[A.reasoning]:H.reasoning||""}:{}}),...hx(A.provider,T["x-abstract-type"]),fetchModelCapabilities:A.reasoning?Lu.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:o})]},E);if(x.has(E))return null;const $=`workflow-input-${E}`,j=String(T.title||E).replace(/_/g," "),P=Array.isArray(e==null?void 0:e.required)&&e.required.includes(E),V=H=>{const L={...t};H===void 0?delete L[E]:L[E]=H,s(L)};return i.jsxs("div",{className:"code-field",children:[i.jsxs("label",{htmlFor:$,children:[j,P?i.jsx("span",{"aria-label":"required",children:" *"}):null]}),T.enum?i.jsxs("select",{id:$,value:t[E]===void 0?"":JSON.stringify(t[E]),disabled:o,onChange:H=>V(H.target.value?JSON.parse(H.target.value):void 0),children:[i.jsxs("option",{value:"",children:["Choose ",j]}),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:t[E]===void 0?"":String(t[E]),disabled:o,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 t[E]=="number"?String(t[E]):"",min:T.minimum,max:T.maximum,step:T.type==="integer"?1:"any",disabled:o,onChange:H=>V(H.target.value===""?void 0:Number(H.target.value))}):T.type==="object"||T.type==="array"?i.jsx(pk,{id:$,value:t[E],disabled:o,onChange:V},E):i.jsx("textarea",{id:$,rows:2,value:String(t[E]??""),disabled:o,onChange:H=>V(H.target.value)}),T.description?i.jsx("p",{className:"code-field-help",id:`${$}-help`,children:T.description}):null]},E)})}):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:Ou,children:[i.jsx("button",{type:"button",role:"tab",tabIndex:h==="fields"?0:-1,"aria-selected":h==="fields",onClick:()=>b("fields"),children:"Fields"}),i.jsx("button",{type:"button",role:"tab",tabIndex:h==="json"?0:-1,"aria-selected":h==="json",onClick:()=>b("json"),children:"JSON payload"})]}),h==="json"?i.jsxs(i.Fragment,{children:[i.jsx(hk,{value:t,disabled:o,onChange:s,onError:E=>d==null?void 0:d(E)}),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."})]}):k]}):k}function hk({value:e,onChange:t,onError:s,disabled:o}){const[l,u]=gt.useState(JSON.stringify(e,null,2)),[d,f]=gt.useState(""),h=gt.useRef(e);return gt.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:o,"aria-invalid":!!d,onChange:g=>{u(g.target.value);const y=fk(g.target.value);if(!y.ok){f(y.error),s(y.error);return}h.current=y.value,f(""),s(""),t(y.value)}}),d?i.jsx("span",{role:"alert",className:"code-error-text",children:d}):null]})}function pk({id:e,value:t,onChange:s,disabled:o}){const[l,u]=gt.useState(t===void 0?"":JSON.stringify(t,null,2)),[d,f]=gt.useState(""),h=gt.useRef(t);return gt.useEffect(()=>{t!==h.current&&(h.current=t,u(t===void 0?"":JSON.stringify(t,null,2)),f(""))},[t]),i.jsxs(i.Fragment,{children:[i.jsx("textarea",{id:e,className:"code-mono",rows:4,value:l,disabled:o,"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 mk({attachments:e,uploads:t,sizes:s,onRemoveAttachment:o,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"?Lo(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(ie,{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:()=>o(f),children:i.jsx(ie,{name:"x",size:12})})]},`${d.$artifact}:${f}`)}),t.map(d=>{const f=d.status==="queued"||d.status==="uploading",h=d.status==="queued"?`Waiting · ${Lo(d.size)}`:d.status==="uploading"?`Uploading · ${Lo(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(ie,{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(ie,{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(ie,{name:"x",size:12})})]},d.id)})]})}function gk({active:e,paused:t,snapshot:s,onRevokeApproval:o,onCommand:l,onActivity:u,onInteraction:d,permissionsAll:f}){const h=w.useMemo(()=>Zv(s),[s]),y=w.useMemo(()=>h.tone==="working"?pb(s.records.map(S=>S.record)):"",[h.tone,s.records])||h.detail,[v,x]=w.useState(Date.now);w.useEffect(()=>{if(!e)return;const S=window.setInterval(()=>x(Date.now()),1e3);return()=>window.clearInterval(S)},[e]);const b=Date.parse(h.startedAt||""),k=Number.isFinite(b)?Math.max(0,Math.floor((v-b)/1e3)):null,E=k===null?"":k<60?`${k}s`:`${Math.floor(k/60)}m ${k%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(ie,{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(ie,{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&&E?i.jsx("span",{children:E}):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(t?"resume":"pause"),children:t?"Resume":"Pause"}),i.jsx("button",{onClick:()=>l("conclude"),children:"Conclude"})]}):null,i.jsxs("button",{onClick:u,children:["View activity ",i.jsx(ie,{name:"chevronRight",size:12})]}),f?i.jsxs("div",{className:"code-run-strip__consent",children:[i.jsx(ie,{name:"check",size:13}),i.jsx("span",{children:"Permissions: all · enabled tools only"}),i.jsx("button",{onClick:o,children:"Revoke"})]}):null]})}function yk({runId:e,sessionId:t,capability:s,scope:o,preferences:l,onTranscript:u,onError:d}){var v,x;const f=w.useRef(!0),h=w.useRef(o);h.current=o,w.useEffect(()=>(f.current=!0,()=>{f.current=!1}),[]);const g=()=>{if(!f.current||h.current!==o)throw new Error("Voice session changed.")},y=Jy({tts:((v=s.tts)==null?void 0:v.available)===!0&&e?async b=>{g();const k=await ht(Se(`runs/${encodeURIComponent(e)}/voice/tts`),{method:"POST",body:JSON.stringify({text:b,request_id:es(),...Object.fromEntries(Object.entries(l).filter(([,T])=>T!==""&&T!==void 0))})});g();const E=k==null?void 0:k.audio_artifact;if(!(E!=null&&E.$artifact))throw new Error("The gateway did not return an audio artifact.");const{blob:S}=await $n.get_run_artifact_blob(String(E.run_id||k.child_run_id||e),E.$artifact,{max_bytes:25e6});return g(),S.arrayBuffer()}:void 0,transcribe:((x=s.stt)==null?void 0:x.available)===!0&&e?async(b,k)=>{var j;g();const E=Number(((j=s.stt)==null?void 0:j.max_upload_bytes)||0);if(E>0&&b.size>E)throw new Error("Recording exceeds the gateway's upload limit. Try a shorter recording.");const S=k.includes("mp4")?"m4a":k.includes("ogg")?"ogg":k.includes("wav")?"wav":"webm",T=new File([b],`recording.${S}`,{type:k||"audio/webm"}),A=await $n.attachments_upload(t,T);g();const $=await $n.audio_transcribe(e,{audio_artifact:A,request_id:es()});return g(),String($.text||"")}:void 0,on_transcript:b=>{f.current&&h.current===o&&u(b)},on_error:b=>{f.current&&h.current===o&&d(b)}});return w.useEffect(()=>{var b;return y.stop_tts(),(b=y.cancel_voice_ptt_recording)==null||b.call(y),()=>{var k;y.stop_tts(),(k=y.cancel_voice_ptt_recording)==null||k.call(y)}},[o,y.stop_tts,y.cancel_voice_ptt_recording]),y}function wk({voice:e,runId:t,capability:s,answer:o,onSettings:l}){var g,y,v,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:[(v=s.stt)!=null&&v.available?i.jsx("button",{className:"code-icon-button","aria-label":e.voice_ptt_recording?"Recording — release to transcribe":"Hold to dictate",title:t?"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:k=>{k.button===0&&f()},onPointerUp:h,onPointerCancel:h,onKeyDown:k=>{[" ","Enter"].includes(k.key)&&!k.repeat&&(k.preventDefault(),f())},onKeyUp:k=>{[" ","Enter"].includes(k.key)&&(k.preventDefault(),h())},onBlur:h,children:i.jsx(ie,{name:e.voice_ptt_busy?"loader":"mic",size:15})}):null,(x=s.tts)!=null&&x.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||!o||e.tts_playback.status==="loading",onClick:()=>{o&&e.toggle_tts(["playing","paused"].includes(e.tts_playback.status)?e.tts_playback.key:o.id||"latest",o.content)},children:i.jsx(ie,{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(ie,{name:"x",size:14})}):null,l&&((b=s.tts)!=null&&b.available)?i.jsx("button",{className:"code-icon-button","aria-label":"Voice settings",title:"Voice settings",onClick:l,children:i.jsx(ie,{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 ru(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function Ka(e){return typeof e=="string"?e.trim():""}function vk(e){const t=ru(e),s=ru(t==null?void 0:t.gateway),o=ru(s==null?void 0:s.principal);return JSON.stringify([Ka((t==null?void 0:t.gateway_url)??(t==null?void 0:t.gatewayUrl)),Ka((o==null?void 0:o.tenant_id)??(o==null?void 0:o.tenantId)),Ka((o==null?void 0:o.runtime_id)??(o==null?void 0:o.runtimeId)),Ka((o==null?void 0:o.user_id)??(o==null?void 0:o.userId))||"session"])}function Xh(e,t){return!!e.sourceRunId&&e.sessionId===t.sessionId&&e.sessionId===t.snapshotSessionId&&e.sourceRunId===t.runId&&e.sourceRunId===t.snapshotRunId&&e.authEpoch===t.authEpoch}function _k(e){const t=typeof e=="string"?e.trim().toLowerCase():"";return["completed","complete","done"].includes(t)?"advance":["failed","error","cancelled","canceled"].includes(t)?"pause":"wait"}function xk(e,t,s){return e.flatMap(o=>o.id===t.id?[]:o.sessionId!==t.sessionId||o.authEpoch!==t.authEpoch||o.sourceRunId!==t.sourceRunId?[o]:[{...o,sourceRunId:s}])}function Zh(){return new DOMException("The conversation changed before the run was attached.","AbortError")}const bk=Ty("abstractcode","0.8.0"),su=e=>["completed","failed","cancelled","canceled"].includes(e);function qh(){const e=new URLSearchParams(window.location.hash.replace(/^#/,""));return{sessionId:e.get("session")||es(),runId:e.get("run")||""}}function Eo(e,t=""){const s=new URLSearchParams({session:e});t&&s.set("run",t),window.history.replaceState(null,"",`#${s}`)}function kk(){var hs,Ho,Ko,Js,ps,Qs,Hi,Ln,Ys,ms,Ki,gs,ys,Ji,Rt,pr,Xs,Lr,Jo,Zs,qs;const e=Ny({appName:"AbstractCode",variant:"blocking"}),t=e.connected?vk(e.status):"",s=w.useCallback(()=>{e.refresh()},[e.refresh]),o=Mx(t,s),[l,u]=Wy("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:St(I)}))},[]),[v,x]=w.useState(!1),[b,k]=w.useState({});w.useEffect(()=>{try{k(JSON.parse(localStorage.getItem(`abstractcode.voice:${t}`)||"{}"))}catch{k({})}x(!1)},[t]);const E=I=>{if(k(I),t)try{localStorage.setItem(`abstractcode.voice:${t}`,JSON.stringify(I))}catch{}},[S,T]=w.useState(Nr),A=w.useRef(S);A.current=S;const $=yx(S.streamReplies,o.streaming),[j,P]=w.useState(Nr.workflow),V=w.useMemo(()=>Cx(o.choices,S.showAllWorkflows),[o.choices,S.showAllWorkflows]),H=w.useMemo(()=>Nx(o.gatewayDefault,o.workflows),[o.gatewayDefault,o.workflows]),L=j===En?H:o.workflows.find(I=>I.id===j)||null,[de,re]=w.useState(null),Q=Iu(L),[U,J]=w.useState(qh),[fe,ce]=w.useState(""),[ye,ve]=w.useState(""),[q,ae]=w.useState(""),[G,C]=w.useState(!1),B=w.useRef(!1),[F,W]=w.useState([]),[oe,le]=w.useState([]),he=w.useRef(new Set),Z=w.useRef(new Map),[Ce,Ue]=w.useState(""),ke=w.useRef(null),[X,ee]=w.useState(),[pe,De]=w.useState(!1),[we,Pe]=w.useState(""),[Ve,rt]=w.useState(0),[K,me]=w.useState({}),[Fe,Ke]=w.useState(""),[He,or]=w.useState(null),[Tt,An]=w.useState(""),[Tn,Rn]=w.useState(!1),[ar,Er]=w.useState(!1),[cl,Ri]=w.useState("model"),Ps=ah(oh.md),ul=ah(oh.lg),gn=qw(ul,Ps),ns=w.useRef(gn),rs=cv(60),[Ii,Os]=w.useState(()=>ev(gn)),zt=Ii.open,Bn=gn!=="docked",lr=w.useCallback(I=>Os(Y=>nv(Y,ns.current,typeof I=="function"?I(Y.open):I)),[]),[Fo,Mi]=w.useState("files"),[cr,Ht]=w.useState(!1),[ss,Li]=pv(),$r=Gb(o.capabilities),{ctl:Vn,state:ur}=ek(t,e.connected&&$r.available),[is,In]=w.useState(!1),[Ar,os]=w.useState(!1),as=w.useRef(""),[Pi,dl]=w.useState(""),zo=w.useRef(null),[an,Wo]=w.useState("steer"),[Gn,Hn]=w.useState([]),[Ds,yn]=w.useState(!1),[Oi,Fs]=w.useState([]),zs=w.useMemo(()=>dm(o.tools,S.tools,S.permissions),[o.tools,S.tools,S.permissions]),Di=w.useRef(null),lt=w.useMemo(()=>{var ze,Oe;const I=((ze=Di.current)==null?void 0:ze.runId)===U.runId?Di.current.input:null;if(U.runId&&!He&&!I)return{enabledTools:[],autoApproveTools:[]};const Y=He?He.input_data:I,Te=Wx(zs,(Oe=Y==null?void 0:Y._runtime)==null?void 0:Oe.allowed_tools);return{...Te,autoApproveTools:S.toolsCustomized||S.permissions!=="default"?Te.autoApproveTools:[]}},[zs,He,U.runId,S.toolsCustomized,S.permissions]),Fi=`${t}:${U.sessionId}:${U.runId}`,Ws=w.useRef(Fi);Ws.current=Fi;const zi=w.useRef(null),[ls,fl]=w.useState({scope:"",notes:[]}),Uo=w.useMemo(()=>Px({onDeltaError:I=>{const Y=Ws.current,Te=_x(I,zi.current);fl(ze=>({scope:Y,notes:xx(ze.scope===Y?ze.notes:[],Te)}))}}),[]),{controller:wn,snapshot:Le}=__({transport:Uo,runId:U.runId,enabled:e.connected,onAuthError:s,clientId:"abstractcode-web",authScopeKey:t,toolApprovalPolicy:lt}),ln=!!U.runId&&!su(Le.status)&&Le.status!=="idle",Wt=((hs=Le.run)==null?void 0:hs.paused)===!0||Le.status==="paused",dr=ln||G,Us=Le.loading&&Oi.length?Oi:Le.messages,Bs=Us[Us.length-1];zi.current=Bs!=null&&Bs.id?String(Bs.id):null;const cn=bx(Us,[wx(S.streamReplies,o.streaming,Us),...ls.scope===Fi?ls.notes:[]]),cs=((Ko=(Ho=o.capabilities)==null?void 0:Ho.assistant)==null?void 0:Ko.voice)||{},vn=yk({scope:`${t}:${U.sessionId}:${U.runId}`,runId:t?U.runId:"",sessionId:U.sessionId,capability:cs,preferences:b,onTranscript:I=>ce(Y=>Y?`${Y.trimEnd()}
|
|
71
|
-
${I}`:I),onError:ve}),us=g_(Le),_n=w.useMemo(()=>B_(us,wn,{records:Le.records,currentRun:Le.run,onPermissionsAll:async()=>{T(I=>({...I,permissions:"all"}))}}),[us,Le.records,Le.run,wn]),Bo=!!_n&&an==="steer",un=Q?"prompt":ux(X),Wi=Q||!!(un&&!((Js=X==null?void 0:X.required)!=null&&Js.some(I=>I!==un))),Kn=String(((ps=He==null?void 0:He.workspace)==null?void 0:ps.workspace_root)||((Hi=(Qs=Le.run)==null?void 0:Qs.vars)==null?void 0:Hi.workspace_root)||""),Mn=w.useMemo(()=>{var I;return Y_(o.workflows,{inputData:He,runWorkflowId:(I=Le.run)==null?void 0:I.workflow_id})},[o.workflows,He,(Ln=Le.run)==null?void 0:Ln.workflow_id]),Vs=U.runId&&He&&!o.loading&&Le.run&&!Mn&&Pu(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.":"",Ut=o.sessions.find(I=>I.sessionId===U.sessionId),Qe=(Ut==null?void 0:Ut.prompt)||((Ys=cn.find(I=>I.role==="user"))==null?void 0:Ys.content)||"New conversation",Ui=Vb((ms=e.status)==null?void 0:ms.gateway_url),Gs=Ui?()=>{window.open(Ui,"_blank","noopener,noreferrer")}:void 0,Bi={...Gs?{openMyEmail:Gs}:{},openConversation:(I,Y,Te)=>{as.current=Te||"",fr(I,Y)},openRun:I=>{ht(Se(`runs/${encodeURIComponent(I)}`)).then(Y=>{if(!(Y!=null&&Y.session_id))throw new Error(`The gateway reported no session for run ${I}.`);fr(Y.session_id,I)}).catch(Y=>Vn.reportError(Y))}},Vi=((Ki=ur.detail)==null?void 0:Ki.summary.title)||"Automation",Hs=w.useRef(""),Tr=w.useRef(t),pt=w.useRef(0);Tr.current!==t&&(pt.current+=1,Tr.current=t);const Rr=w.useRef(!1),ot=w.useRef(U);ot.current=U,w.useEffect(()=>{if(B.current=!1,C(!1),le([]),ve(""),ae(""),!t){W([]),ce(""),Hn([]),yn(!1),Fs([]),T(Nr);return}if(Hs.current&&Hs.current!==t){const Y={sessionId:es(),runId:""};J(Y),Eo(Y.sessionId)}Hs.current=t,Rr.current=!0;const I=lk(t);T(I),P(I.workflow)},[t]),w.useEffect(()=>{if(t){if(Rr.current){Rr.current=!1;return}ck(t,S)}},[S,t]),w.useEffect(()=>{if(o.loading||!o.workflows.length)return;const I=Ex({selection:j,preferred:S.workflow,visible:V,workflows:o.workflows,runId:U.runId});I!==j&&P(I)},[o.loading,o.workflows,V,j,S.workflow,U.runId]),w.useEffect(()=>{let I=!0;if(me({}),Ke(""),ee(void 0),Pe(""),!L){De(!1);return}return De(!0),Lx(L).then(Y=>{I&&(ee(Y),me(To(Y)))}).catch(Y=>{I&&Pe(St(Y))}).finally(()=>{I&&De(!1)}),()=>{I=!1}},[L==null?void 0:L.id,Ve]),w.useEffect(()=>{if(or(null),An(""),!t||!U.runId)return;const I=new AbortController;return ht(Se(`runs/${encodeURIComponent(U.runId)}/input_data`),{signal:I.signal}).then(Y=>{or(Y)}).catch(Y=>{I.signal.aborted||An(St(Y))}),()=>I.abort()},[U.runId,t]),w.useEffect(()=>{He&&He.flow_id===(L==null?void 0:L.flowId)&&X&&me({...To(X),...ax(X,He.input_data)})},[He,X,L==null?void 0:L.flowId]),w.useEffect(()=>{!U.runId&&e.connected&&(Ut!=null&&Ut.latestRunId)&&J(I=>({...I,runId:Ut.latestRunId}))},[U.runId,e.connected,Ut==null?void 0:Ut.latestRunId]),w.useEffect(()=>{Eo(U.sessionId,U.runId),B.current=!1,C(!1),le([]),W([]),Fs([]),ae(as.current),as.current="",ve(""),Hn([]),yn(!1)},[U.sessionId]),w.useEffect(()=>{const I=()=>{const Y=qh();B.current=!1,C(!1),le([]),Hn([]),yn(!1),ce(""),J(Y)};return window.addEventListener("hashchange",I),()=>window.removeEventListener("hashchange",I)},[]),w.useEffect(()=>{!U.runId||!su(Le.status)||o.refresh()},[U.runId,Le.status]),w.useEffect(()=>{if(!U.runId||!He)return;const I=$x({restoredInputs:He,restored:Mn});I&&P(I)},[U.runId,He,Mn==null?void 0:Mn.id]);const xn=U.runId?Ax(He):"",dn=w.useCallback(()=>{const I={sessionId:es(),runId:""};J(I),P(A.current.workflow),Eo(I.sessionId),ce(""),Hn([]),yn(!1),Ht(!1),In(!1)},[]),fr=w.useCallback((I,Y)=>{B.current=!1,C(!1),le([]),J({sessionId:I,runId:Y}),Eo(I,Y),Ht(!1),Hn([]),yn(!1),ce(""),In(!1)},[]);w.useEffect(()=>{const I=ns.current;ns.current=gn,I!==gn&&(Os(Y=>tv(Y,I,gn)),Ht(Y=>rv(Y,gn)))},[gn]),vh(cr,Ps,()=>document.querySelector(".code-sidebar"),()=>document.querySelector(".code-mobile-close")),vh(zt,Bn,()=>document.querySelector(".code-inspector"),()=>document.querySelector(".code-inspector-heading .code-icon-button")),w.useEffect(()=>{const I=Y=>{var ze;const Te=sv({key:Y.key,defaultPrevented:Y.defaultPrevented,overlayOpen:ar||Tn||v||Ar||d||iv(),sidebarOpen:cr,inspectorOpen:zt,inspectorIsOverlay:Bn});if(Te==="sidebar"){Ht(!1),(ze=document.querySelector(".code-mobile-nav"))==null||ze.focus();return}if(Te==="inspector"){lr(!1);return}(Y.metaKey||Y.ctrlKey)&&(Y.key.toLowerCase()==="k"&&(Y.preventDefault(),Ht(!0),window.setTimeout(()=>{var Oe;return(Oe=zo.current)==null?void 0:Oe.focus()},0)),Y.key.toLowerCase()==="n"&&Y.shiftKey&&(Y.preventDefault(),dn()))};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[dn,cr,zt,Bn,ar,Tn,v,Ar,d,lr]);async function Jn(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(j===En&&o.gatewayDefault.status==="unavailable")throw new Error(`Gateway default: ${o.gatewayDefault.reason}. Choose a workflow from the list.`);if(!L)throw new Error("Choose a workflow first.");if(!o.policy)throw new Error("Workspace policy is unavailable. Reconnect or refresh before starting.");if(U.runId&&(!He||Tt))throw new Error(Tt||"Wait for the gateway to restore this conversation's workspace.");if(Vs)throw new Error(Vs);if(pe||we)throw new Error(we||"Wait for workflow inputs to load.");if(Fe)throw Rn(!0),new Error(Fe);const Y=Qx(oe);if(Y)throw new Error(Y);if(ln)throw new Error("The current run is still active.");if(!Q&&I.trim()&&!un)throw Rn(!0),new Error("This workflow uses structured inputs. Configure its inputs, then select Run workflow.");const Te={...To(X),...K,...un&&I.trim()?{[un]:I.trim()}:{}},ze=Q?Te:dk(X,Te,F);for(const[Kt,Jt]of[["Iteration limit",S.maxIterations],["Context token limit",S.maxTokens]])if(Jt&&(!Number.isInteger(Number(Jt))||Number(Jt)<=0))throw new Error(`${Kt} must be a positive whole number.`);B.current=!0,C(!0),ve(""),ae("");const Oe=U.sessionId,It=U.runId,Xn=t,Pr=pt.current;let xt="";try{const Kt=tx({workflow:L,inputSchema:X,schemaInputs:ze,prompt:I,promptProperty:un,model:S,reasoning:S.reasoning||void 0,speculation:S.speculation,streamReplies:$,systemPromptExtra:S.system||void 0,attachments:F,limits:{maxIterations:S.maxIterations?Number(S.maxIterations):void 0,maxTokens:S.maxTokens?Number(S.maxTokens):void 0},workspace:o.policy.clientWorkspaceScopeOverrides?{root:S.workspaceRoot||Kn||void 0,accessMode:S.workspaceMode||void 0,allowedPaths:S.allowedPaths.split(`
|
|
72
|
-
`).filter(Boolean)}:Kn?{root:Kn}:void 0,tools:S.toolsCustomized?zs.enabledTools:void 0,toolPolicy:S.toolsCustomized||S.permissions!=="default"?{autoApproveTools:[],requireApprovalTools:zs.enabledTools}:void 0,skills:S.skills.length?S.skills:void 0}),Jt=dx(X,Kt);if(Jt.length)throw Rn(!0),new Error(Jt.join(" "));const mr=Tx({selection:j,workflow:L,sessionId:Oe,input:Kt}),Pn=await ht(Se("runs/start"),{method:"POST",body:JSON.stringify(mr)});if(!Pn.run_id)throw new Error("The gateway did not return a run identifier.");if(ot.current.sessionId!==Oe||ot.current.runId!==It||Tr.current!==Xn||pt.current!==Pr)throw Zh();return xt=String(Pn.run_id),Di.current={runId:xt,input:Kt},re({runId:xt,...Rx(Pn.resolved_workflow)}),Fs([...cn,...I.trim()?[{id:`pending:${Pn.run_id}`,role:"user",content:I.trim()}]:[]]),J({sessionId:Oe,runId:Pn.run_id}),Eo(Oe,Pn.run_id),ce(""),W([]),Rn(!1),Pn.runner_warning&&ae(String(Pn.runner_warning)),o.refresh(),xt}finally{ot.current.sessionId===Oe&&(ot.current.runId===It||ot.current.runId===xt)&&Tr.current===Xn&&pt.current===Pr&&(B.current=!1,C(!1))}}async function Qn(I){if(!ln)return Jn(I);if(an==="queue")Hn(Y=>[...Y,{id:es(),text:I,sessionId:U.sessionId,sourceRunId:U.runId,authEpoch:pt.current}]),yn(!0),ce(""),ae("Queued for the next turn.");else{if(_n)throw new Error("Answer the pending workflow request above, or choose Queue next turn.");const Y=U.sessionId,Te=U.runId,ze=pt.current;if(await wn.sendCommand("inject_guidance",{guidance:I}),ot.current.sessionId!==Y||ot.current.runId!==Te||pt.current!==ze)return;ce(""),ae("Guidance queued. The workflow will read it at its next supported boundary.")}}async function Vo(I){var ze,Oe;const Y=String(((ze=Le.run)==null?void 0:ze.run_id)||"");if(!Xh(I,{sessionId:U.sessionId,runId:U.runId,snapshotRunId:Y,snapshotSessionId:String(((Oe=Le.run)==null?void 0:Oe.session_id)||""),authEpoch:pt.current}))throw Zh();const Te=await Jn(I.text);Hn(It=>xk(It,I,Te))}w.useEffect(()=>{var Te,ze;if(!Ds||!Gn.length||!e.connected||!He||Tt||B.current)return;const I=_k(Le.status);if(I==="wait")return;if(I==="pause"){yn(!1);const Oe=["failed","error"].includes(Le.status.toLowerCase());ae(`Queue paused because the run ${Oe?"failed":"was cancelled"}. Review the result, then use Run next to continue explicitly.`);return}const Y=Gn[0];Xh(Y,{sessionId:U.sessionId,runId:U.runId,snapshotRunId:String(((Te=Le.run)==null?void 0:Te.run_id)||""),snapshotSessionId:String(((ze=Le.run)==null?void 0:ze.session_id)||""),authEpoch:pt.current})&&Vo(Y).catch(Oe=>{Oe instanceof DOMException&&Oe.name==="AbortError"||(yn(!1),ve(St(Oe)))})},[Ds,Gn,Le.status,(gs=Le.run)==null?void 0:gs.run_id,(ys=Le.run)==null?void 0:ys.session_id,e.connected,He,Tt,U.sessionId,U.runId]);async function Gi(I){const Y=U.sessionId,Te=t,ze=pt.current,Oe=()=>ot.current.sessionId!==Y||Tr.current!==Te||pt.current!==ze,It=(xt,Kt)=>le(Jt=>Jt.map(mr=>mr.id===xt?{...mr,...Kt}:mr));let Xn=0,Pr=0;await Jx(I,Gx,async xt=>{if(!(Oe()||he.current.has(xt.id))){It(xt.id,{status:"uploading",message:void 0});try{const Kt=await $n.attachments_upload(Y,xt.file);if(Oe()||he.current.has(xt.id))return;Z.current.set(Kt.$artifact,xt.size),le(Jt=>Jt.filter(mr=>mr.id!==xt.id)),W(Jt=>[...Jt,Kt]),Xn+=1}catch(Kt){if(Oe()||he.current.has(xt.id))return;It(xt.id,{status:"failed",message:Hx(St(Kt))}),Pr+=1}}}),!Oe()&&(Xn||Pr)&&Ue(Bh(Xn,Pr))}function hr(I){var ze;if(!I.length)return[];const Y=Kx(I,(ze=o.policy)==null?void 0:ze.maxAttachmentBytes,es);le(Oe=>[...Oe,...Y]);const Te=Y.filter(Oe=>Oe.status==="refused").length;return Te&&Ue(Bh(0,Te)),Gi(Y.filter(Oe=>Oe.status==="queued")),Y}function hl(I){const Y=oe.find(ze=>ze.id===I);if(!Y||Y.status!=="failed")return;const Te={...Y,status:"queued",message:void 0};le(ze=>ze.map(Oe=>Oe.id===I?Te:Oe)),Gi([Te])}function Go(I){he.current.add(I),le(Y=>Y.filter(Te=>Te.id!==I))}async function Ks(){const I=U.sessionId,Y=U.runId,Te=pt.current;await wn.cancel(),ot.current.sessionId===I&&ot.current.runId===Y&&pt.current===Te&&ae("")}const Ir=I=>{Ri(I),Er(!0)},ds=I=>{const Y=pt.current,Te=U.sessionId,ze=U.runId;ve(""),I().catch(Oe=>{Oe instanceof DOMException&&Oe.name==="AbortError"||pt.current===Y&&ot.current.sessionId===Te&&ot.current.runId===ze&&ve(St(Oe))})},Mr=o.sessions.filter(I=>`${I.prompt||""} ${I.sessionId}`.toLowerCase().includes(Pi.toLowerCase())),fs=(()=>{var I;try{return new URL(((I=e.status)==null?void 0:I.gateway_url)||"").host}catch{return"Your gateway"}})(),Yn=S.model||(K.provider&&K.model?`Workflow · ${K.model}`:"Gateway default");return i.jsxs("div",{className:`code-app${cr?" code-app--nav-open":""}${zt?" code-app--workspace-open":""}`,children:[i.jsx("a",{className:"code-skip-link",href:"#code-conversation",children:"Skip to conversation"}),i.jsxs(uv,{isDrawer:Ps,open:cr,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:()=>Ht(!1),children:i.jsx(ie,{name:"x",size:18})})]}),i.jsxs("button",{className:"code-new-chat",onClick:dn,children:[i.jsx(ie,{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(ie,{name:"history",size:14}),i.jsx("input",{ref:zo,"aria-label":"Search conversations",placeholder:"Search conversations",value:Pi,onChange:I=>dl(I.target.value)}),i.jsx("kbd",{children:"⌘K"})]}),i.jsx(tk,{state:ur,available:$r,selectedId:is?ur.selectedId:"",onSelect:I=>{In(!0),Ht(!1),Vn.select(I)},onNew:()=>os(!0),onRefresh:()=>void Vn.refresh(),onShowArchived:I=>Vn.setShowArchived(I),open:ss.automations,fill:!ss.conversations,onToggle:()=>Li("automations")}),i.jsxs(mv,{open:ss.conversations,onToggle:()=>Li("conversations"),actions:i.jsx("button",{className:"code-icon-button","aria-label":"Refresh conversations",disabled:!e.connected||o.loading,onClick:()=>void o.refresh(),children:i.jsx(ie,{name:"refresh",size:13})}),children:[Ut?null:i.jsxs("button",{className:"code-session is-selected",onClick:()=>Ht(!1),children:[i.jsx(ie,{name:"chat",size:15}),i.jsxs("span",{children:[i.jsx("strong",{children:"New conversation"}),i.jsx("small",{children:"Ready when you are"})]})]}),Mr.map(I=>i.jsx(jk,{item:I,selected:I.sessionId===U.sessionId,onClick:()=>fr(I.sessionId,I.latestRunId)},I.sessionId)),!o.loading&&!Mr.length?i.jsx("p",{className:"code-history-empty",children:Pi?"No conversations match your search.":"Your conversations will live here. Pick up where you left off, on any device."}):null,o.loading?i.jsx("p",{className:"code-history-empty",role:"status",children:"Loading conversations…"}):null,o.hasMore?i.jsx("button",{className:"code-load-more",onClick:o.loadMore,children:"Load more conversations"}):null]}),i.jsxs("div",{className:"code-sidebar-bottom",children:[i.jsxs("button",{onClick:()=>Ir("workspace"),children:[i.jsx(ie,{name:"terminal",size:17}),i.jsxs("span",{children:[i.jsx("strong",{children:"Workspace"}),i.jsx("small",{children:Kn.split("/").filter(Boolean).pop()||"Gateway managed"})]}),i.jsx(ie,{name:"chevronRight",size:14})]}),i.jsxs("button",{onClick:()=>Ir("model"),children:[i.jsx(ie,{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:fs}),i.jsx("small",{children:((pr=(Rt=(Ji=e.status)==null?void 0:Ji.gateway)==null?void 0:Rt.principal)==null?void 0:pr.user_id)||"Signed out"})]})]})]}),cr?i.jsx("button",{className:"code-nav-scrim","aria-label":"Close conversation navigation",onClick:()=>Ht(!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:()=>Ht(!0),children:i.jsx(ie,{name:"list",size:19})}),i.jsxs("div",{className:"code-breadcrumb",children:[i.jsx("span",{children:is?"Automations":"Conversations"}),i.jsx("span",{"aria-hidden":"true",children:"/"}),i.jsx("strong",{title:is?Vi:Qe,children:is?Vi:Qe})]}),i.jsx(Dy,{appearance:{onOpen:()=>f(!0)},about:{identity:bk,extraRows:Wb(h),onOpen:y},extraActions:i.jsx("button",{className:`af-topbar__btn${zt?" is-active":""}`,"aria-label":"Toggle workspace inspector","aria-pressed":zt,onClick:()=>lr(I=>!I),children:i.jsx(ie,{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(ie,{name:"agent",size:17}),i.jsxs("select",{"aria-label":"Workflow",value:j,disabled:dr||o.loading||!e.connected,onChange:I=>{const Y=I.target.value;P(Y),T(Te=>({...Te,workflow:Y}))},children:[i.jsx("option",{value:En,children:zh(o.gatewayDefault)}),L&&j!==En&&!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:J_(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:S.showAllWorkflows,disabled:dr||!e.connected,onChange:I=>T(Y=>({...Y,showAllWorkflows:I.target.checked}))}),i.jsx("span",{children:"Show all workflows"})]}),j===En&&qc(H)?i.jsx("span",{className:"code-workflow-resolved is-missing",role:"alert",title:qc(H),children:qc(H)}):null,xn?i.jsx("span",{className:"code-workflow-resolved is-missing",role:"status",title:xn,children:xn}):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:()=>Ir("model"),"aria-label":`Model: ${Yn}`,title:`Model: ${Yn}`,children:[i.jsx(ie,{name:"sparkle",size:14}),i.jsx("span",{"aria-hidden":"true",children:Yn}),i.jsx(ie,{name:"chevronDown",size:12})]}),i.jsx("div",{className:"code-toolbar-spacer"}),i.jsxs("button",{className:"code-subtle-button",onClick:()=>Rn(!0),disabled:!L,"aria-label":"Inputs",title:"Workflow inputs",children:[i.jsx(ie,{name:"settings",size:14}),i.jsx("span",{children:"Inputs"})]}),i.jsxs("button",{className:"code-subtle-button",onClick:()=>Ir("tools"),"aria-label":"Tools",title:"Tools",children:[i.jsx(ie,{name:"terminal",size:14}),i.jsx("span",{children:"Tools"})]}),cn.length?i.jsx("button",{className:"code-icon-button","aria-label":"Export conversation",title:"Export conversation",onClick:()=>xv({filename:"conversation.md",text:_v(cn)}),children:i.jsx(ie,{name:"download",size:15})}):null]}),i.jsxs("div",{className:"code-content",children:[is?i.jsx(ik,{ctl:Vn,host:Bi,enabled:e.connected,onClose:()=>In(!1)}):i.jsxs("main",{className:"code-conversation",id:"code-conversation",tabIndex:-1,children:[ye||Le.error||e.signOutError||Tt?i.jsxs("div",{className:"code-alert",role:"alert",children:[i.jsx(ie,{name:"warning",size:16}),i.jsx("span",{children:ye||Le.error||e.signOutError||Tt}),Le.error||Tt?i.jsx("button",{onClick:()=>{Tt?window.location.reload():ds(()=>wn.load(U.runId))},children:"Reconnect"}):i.jsx("button",{"aria-label":"Dismiss error",onClick:()=>ve(""),children:i.jsx(ie,{name:"x",size:14})})]}):null,o.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"}),o.errors.map(I=>i.jsx("p",{children:I},I)),i.jsx("button",{onClick:()=>void o.refresh(),children:"Retry discovery"})]})}):null,Vs?i.jsxs("div",{className:"code-alert",role:"alert",children:[i.jsx("span",{children:Vs}),i.jsx("button",{onClick:dn,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:()=>ae(""),children:i.jsx(ie,{name:"x",size:13})})]}):null,ln||su(Le.status)?i.jsx(gk,{active:ln,paused:Wt,snapshot:Le,permissionsAll:S.permissions==="all",onInteraction:_n&&!Wt?()=>{var Te;const I=document.querySelector(".code-conversation .pc-chat-thread"),Y=I==null?void 0:I.querySelector(".pc-workflow-interaction");!I||!Y||(I.scrollTop+=Y.getBoundingClientRect().top-I.getBoundingClientRect().top,(Te=Y.querySelector("h3"))==null||Te.focus({preventScroll:!0}))}:void 0,onRevokeApproval:()=>{wn.revokeToolApproval(),T(I=>({...I,permissions:"default"}))},onCommand:I=>ds(()=>wn.sendCommand(I,{})),onActivity:()=>{Mi("activity"),lr(!0)}}):null,i.jsx(l_,{streamReplies:$,messages:(_n==null?void 0:_n.kind)==="tool-approval"?cn.filter(I=>{var Y,Te;return!(((Y=I.toolActivity)==null?void 0:Y.status)==="waiting"&&I.toolActivity.runId===((Te=Le.interaction)==null?void 0:Te.runId))}):cn,messageProps:{...vn.tts_supported?{onSpeakToggle:I=>{vn.toggle_tts(I.id||I.content,I.content)}}:{},getSpeakState:I=>vn.tts_playback.key===(I.id||I.content)?vn.tts_playback.status:"idle"},draft:fe,onDraftChange:ce,onSend:Qn,busy:dr,busyLabel:Bo?"Waiting for you":G?"Starting…":Wt?"Paused":"Working…",sendWhileBusy:ln&&!G&&!Bo,sendLabel:ln?an==="queue"?"Queue":"Steer":"Send",onCancel:Ks,stopState:Le.stop??null,disabled:!e.connected,interaction:_n,onAttach:()=>{var I;return(I=ke.current)==null?void 0:I.click()},onFiles:I=>{hr(I)},attachments:F.length||oe.length?i.jsx(mk,{attachments:F,uploads:oe,sizes:Z.current,onRemoveAttachment:I=>W(Y=>Y.filter((Te,ze)=>ze!==I)),onRemoveUpload:Go,onRetryUpload:hl}):null,placeholder:ln?an==="queue"?"Queue the next task after this run…":_n?"Answer the request above, or choose Queue next turn…":"Guide the current workflow…":"Describe what you want to build, fix, or explore…",emptyState:ln?null:i.jsx(Sk,{workflow:L,loading:o.loading||pe,onSuggestion:ce,onInputs:()=>Rn(!0),isAgent:Wi,onRun:()=>ds(()=>Jn(fe)),connected:e.connected}),composerExtras:i.jsxs(i.Fragment,{children:[i.jsxs("button",{className:"code-composer-workspace",onClick:()=>Ir("workspace"),title:Kn||"Workspace is managed by the gateway",children:[i.jsx(ie,{name:"terminal",size:14}),i.jsx("span",{children:Kn.split("/").filter(Boolean).pop()||"Gateway workspace"})]}),e.connected?i.jsx(wk,{runId:U.runId,voice:vn,capability:cs,onSettings:()=>x(!0),answer:[...cn].reverse().find(I=>I.role==="assistant")},`${t}:${U.sessionId}:${U.runId}`):null,ln?i.jsxs("select",{"aria-label":"Message destination",value:an,onChange:I=>Wo(I.target.value),children:[i.jsxs("option",{value:"steer",disabled:!!_n,children:["Guide this run",_n?" (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:[(Xs=o.policy)!=null&&Xs.clientWorkspaceScopeOverrides?"Gateway policy enforced":"Managed workspace",i.jsx("span",{className:"code-small-dot"})]})]})}),Gn.length?i.jsxs("div",{className:"code-queue",children:[i.jsxs("div",{children:[i.jsxs("strong",{children:[Gn.length," queued"," ",Gn.length===1?"turn":"turns"]}),i.jsx("button",{onClick:()=>yn(I=>!I),children:Ds?"Pause queue":"Resume queue"})]}),Gn.map(I=>i.jsxs("div",{children:[i.jsx("span",{children:I.text}),ln?null:i.jsx("button",{onClick:()=>ds(()=>Vo(I)),children:"Run next"}),i.jsx("button",{"aria-label":"Remove queued turn",onClick:()=>Hn(Y=>Y.filter(Te=>Te.id!==I.id)),children:i.jsx(ie,{name:"x",size:13})})]},I.id))]}):null]}),zt?i.jsx("button",{className:"code-inspector-scrim","aria-label":"Close workspace inspector",tabIndex:-1,onClick:()=>lr(!1)}):null,zt?i.jsx(Lb,{tab:Fo,onTab:Mi,policy:o.policy,runId:U.runId,records:Le.records,enabled:e.connected,isAdmin:((Zs=(Jo=(Lr=e.status)==null?void 0:Lr.gateway)==null?void 0:Jo.principal)==null?void 0:Zs.admin)===!0,refreshKey:Le.status,onAttachFiles:hr,onClose:()=>lr(!1),onAttach:async I=>{const Y=U.sessionId,Te=U.runId,ze=pt.current,Oe=await $n.attachments_ingest(Y,I);ot.current.sessionId===Y&&ot.current.runId===Te&&pt.current===ze&&W(It=>[...It,Oe])}}):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:Ce}),i.jsx("input",{ref:ke,hidden:!0,type:"file",multiple:!0,onChange:I=>{hr(Array.from(I.target.files||[])),I.target.value=""}}),i.jsx(ok,{open:Ar,onClose:()=>os(!1),target:Hb(j,L),workflowLabel:j===En?zh(o.gatewayDefault):(L==null?void 0:L.name)||"the selected workflow",initialPrompt:fe||((qs=[...cn].reverse().find(I=>I.role==="user"))==null?void 0:qs.content)||"",ctl:Vn,onOpenMyEmail:Gs,onCreated:()=>{In(!0),Ht(!1)}}),i.jsx(jy,{...e.modalProps}),i.jsx(lu,{open:v,onClose:()=>x(!1),label:"Voice settings",title:"AI voice",width:480,topOffset:rs,className:"code-settings-drawer",children:i.jsx("div",{className:"code-settings",children:e.connected?i.jsx(Qy,{value:b,onChange:I=>{vn.stop_tts(),E(I)},fetchCatalog:(I,Y)=>ht(Se(`voice/voices?compact=true${I?`&provider=${encodeURIComponent(I)}`:""}${Y?`&model=${encodeURIComponent(Y)}`:""}`))}):null})}),i.jsx(Uy,{open:d,onClose:()=>f(!1),value:l,onChange:u}),i.jsx(Ux,{open:ar,topOffset:rs,onClose:()=>Er(!1),tab:cl,onTab:Ri,value:S,onChange:I=>{const Y=[];(S.provider||S.model)&&!I.provider&&!I.model&&Y.push("provider","model"),S.toolsCustomized&&!I.toolsCustomized&&Y.push("tools"),S.maxIterations&&!I.maxIterations&&Y.push("max_iterations"),Y.length&&me(Te=>{const ze={...Te},Oe=To(X);for(const It of Y)delete ze[It],Object.prototype.hasOwnProperty.call(Oe,It)&&(ze[It]=Oe[It]);return ze}),T(I)},policy:o.policy,tools:o.tools,defaultModel:K.provider&&K.model?{provider:String(K.provider),model:String(K.model)}:o.defaultModel,workflowDefault:!!(K.provider&&K.model),streaming:o.streaming,disabled:dr||!e.connected},t),i.jsx(lu,{open:Tn,onClose:()=>Rn(!1),label:"Workflow inputs",title:(L==null?void 0:L.name)||"Workflow inputs",width:480,topOffset:rs,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||un?i.jsx(uk,{schema:X,promptProperty:un,defaultModel:o.defaultModel,values:K,onChange:me,disabled:dr,onEditorError:Ke},L==null?void 0:L.id):i.jsx(_u,{schema:X,defaultModel:o.defaultModel,values:K,onChange:me,disabled:dr,rawObject:!0,onEditorError:Ke},L==null?void 0:L.id),we?i.jsx("p",{role:"alert",className:"code-error-text",children:we}):null,Wi?i.jsxs("button",{className:"code-primary-button",onClick:()=>Rn(!1),children:["Back to chat ",i.jsx(ie,{name:"chat",size:16})]}):i.jsxs("button",{className:"code-primary-button",disabled:dr||pe||!!we||!!Fe||!e.connected,onClick:()=>ds(()=>Jn(fe||String(K[un||"prompt"]||""))),children:["Run workflow ",i.jsx(ie,{name:"playCircle",size:16})]})]})})]})}function jk({item:e,selected:t,onClick:s}){const o=e.prompt||`Conversation ${e.sessionId.slice(0,8)}`,l=e.updatedAt?new Date(e.updatedAt):null;return i.jsxs("button",{className:`code-session${t?" is-selected":""}`,"aria-current":t?"page":void 0,onClick:s,title:o,children:[i.jsx(ie,{name:"chat",size:15}),i.jsxs("span",{children:[i.jsx("strong",{children:o}),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 Sk({workflow:e,loading:t,onSuggestion:s,onInputs:o,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(ie,{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:o,children:"Configure inputs"}),i.jsx("button",{onClick:u,disabled:t||!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:t,children:[i.jsx(ie,{name:f.icon,size:18}),i.jsxs("span",{children:[i.jsx("strong",{children:f.title}),i.jsx("small",{children:f.detail})]}),i.jsx(ie,{name:"chevronRight",size:13})]},f.title))}),i.jsx("p",{className:"code-welcome-hint",children:t?"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 Nk extends gt.Component{constructor(){super(...arguments);mn(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}}ny();av();"serviceWorker"in navigator&&window.addEventListener("load",()=>{navigator.serviceWorker.register("sw.js").catch(()=>{})});Yg.createRoot(document.getElementById("root")).render(i.jsx(gt.StrictMode,{children:i.jsx(Nk,{children:i.jsx(kk,{})})}));
|